emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/helm d6bdd4c277: Rewrite helm-ff-prefix-filename, use now


From: ELPA Syncer
Subject: [nongnu] elpa/helm d6bdd4c277: Rewrite helm-ff-prefix-filename, use now icons if possible
Date: Thu, 29 Jun 2023 04:01:17 -0400 (EDT)

branch: elpa/helm
commit d6bdd4c27797881bf6933b4a28277eea802ca746
Author: Thierry Volpiatto <thievol@posteo.net>
Commit: Thierry Volpiatto <thievol@posteo.net>

    Rewrite helm-ff-prefix-filename, use now icons if possible
    
    Also when not using icons the prefix has changed to [+].
---
 helm-core.el  |  6 +++---
 helm-files.el | 37 +++++++++++++++++++++++++++----------
 helm-mode.el  |  2 +-
 3 files changed, 31 insertions(+), 14 deletions(-)

diff --git a/helm-core.el b/helm-core.el
index e9b982bcad..7e80c76a47 100644
--- a/helm-core.el
+++ b/helm-core.el
@@ -4452,7 +4452,7 @@ This function is used with sources built with 
`helm-source-sync'."
 (defun helm-score-candidate-for-pattern (candidate pattern)
   "Assign score to CANDIDATE according to PATTERN."
   ;; Unknown candidates always go on top.
-  (if (equal (get-text-property 0 'display candidate) "[?]")
+  (if (get-text-property 0 'helm-new-file candidate)
       200.00
     (funcall helm-fuzzy-default-score-fn candidate pattern)))
 
@@ -7390,7 +7390,7 @@ starting it is not needed."
                      (maxpoint  (or end (point-max))))
                 (while (< (point) maxpoint)
                   (helm-mark-current-line)
-                  (let* ((prefix (get-text-property (point-at-bol) 'display))
+                  (let* ((prefix (get-text-property (point-at-bol) 
'helm-new-file))
                          (cand   (helm-get-selection
                                   nil (helm-get-attr 'marked-with-props src)
                                   src))
@@ -7403,7 +7403,7 @@ starting it is not needed."
                             ;; RFN. Display may be an image. See
                             ;; 
https://github.com/yyoncho/helm-treemacs-icons/issues/5
                             ;; and also Bug#2296.
-                            (equal prefix "[?]")
+                            prefix
                             (and filecomp-p
                                  (or
                                   ;; autosave files
diff --git a/helm-files.el b/helm-files.el
index 25bfe8d9d2..3796395b0c 100644
--- a/helm-files.el
+++ b/helm-files.el
@@ -89,6 +89,7 @@
 (declare-function all-the-icons-icon-for-file "ext:all-the-icons.el")
 (declare-function all-the-icons-octicon "ext:all-the-icons.el")
 (declare-function all-the-icons-match-to-alist "ext:all-the-icons.el")
+(declare-function all-the-icons-material "ext:all-the-icons.el")
 (declare-function helm-adaptive-sort "ext:helm-adaptive.el")
 (declare-function wfnames-setup-buffer "ext:wfnames.el")
 
@@ -3937,23 +3938,39 @@ in `helm-find-files-persistent-action-if'."
 
 (defun helm-ff-prefix-filename (fname &optional file-or-symlinkp new-file)
   "Add display property to FNAME.
-Display property presents a string maybe prefixed with [?] or [@].
+Display property presents a string maybe prefixed with [+] or [@].
 If FILE-OR-SYMLINKP is non-nil this means we assume FNAME is an
 existing filename or valid symlink and there is no need to test
 it.
 NEW-FILE when non-nil means FNAME is a non existing file and
-return FNAME with display property prefixed with [?]."
-  (let* ((prefix-new (propertize
-                      " " 'display
-                      (propertize "[?]" 'face 'helm-ff-prefix)))
-         (prefix-url (propertize
-                      " " 'display
-                      (propertize "[@]" 'face 'helm-ff-prefix))))
+return FNAME with display property prefixed with [+]."
+  (let (prefix-new prefix-url)
     (cond (file-or-symlinkp fname)
           ((or (string-match helm-ff-url-regexp fname)
-               (and helm--url-regexp (string-match helm--url-regexp fname)))
+               (and helm--url-regexp
+                    (string-match helm--url-regexp fname)))
+           (setq prefix-url
+                 (if helm-ff-icon-mode
+                     (helm-acase (match-string 1 fname)
+                       ("mailto:";
+                        (all-the-icons-octicon "mail"))
+                       (t (all-the-icons-octicon "link-external")))
+                   (propertize
+                    " " 'display
+                    (propertize "[@]" 'face 'helm-ff-prefix))))
+           (add-text-properties 0 1 '(helm-url t) prefix-url)
            (concat prefix-url " " fname))
-          (new-file (concat prefix-new " " fname)))))
+          (new-file
+           (setq prefix-new
+                 (if helm-ff-icon-mode
+                     (if (string-match "/\\'" fname)
+                         (all-the-icons-material "create_new_folder")
+                       (all-the-icons-material "note_add"))
+                   (propertize
+                    " " 'display
+                    (propertize "[+]" 'face 'helm-ff-prefix))))
+           (add-text-properties 0 1 '(helm-new-file t) prefix-new)
+           (concat prefix-new " " fname)))))
 
 (defun helm-ff-score-candidate-for-pattern (real disp pattern)
   (cond ((member real '("." "..")) 900000)
diff --git a/helm-mode.el b/helm-mode.el
index aef4ca94a2..7d2858a838 100644
--- a/helm-mode.el
+++ b/helm-mode.el
@@ -544,7 +544,7 @@ If COLLECTION is an `obarray', a TEST should be needed. See 
`obarray'."
 (defun helm-comp-read--move-to-first-real-candidate ()
   (helm-aif (helm-get-selection nil 'withprop)
       ;; Avoid error with candidates with an image as display (Bug#2296).
-      (when (equal (get-text-property 0 'display it) "[?]")
+      (when (get-text-property 0 'helm-new-file it)
         (helm-next-line))))
 
 (defun helm-cr-default (default cands)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]