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

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

[nongnu] elpa/helm 9855b843f3: Allow customizing helm-bookmark sort meth


From: ELPA Syncer
Subject: [nongnu] elpa/helm 9855b843f3: Allow customizing helm-bookmark sort method (#2539)
Date: Thu, 11 Aug 2022 09:58:44 -0400 (EDT)

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

    Allow customizing helm-bookmark sort method (#2539)
    
    This is done through `helm-bookmark-default-sort-method` and apply
    only on helm-filtered-bookmarks.
    The command helm-bookmarks and its source helm-source-bookmarks are
    not affected by this, they use now vanilla bookmark variable
    `bookmark-sort-flag`.
---
 helm-bookmark.el | 28 +++++++++++++++++++++++-----
 1 file changed, 23 insertions(+), 5 deletions(-)

diff --git a/helm-bookmark.el b/helm-bookmark.el
index 12ee1c1460..5cd33c1540 100644
--- a/helm-bookmark.el
+++ b/helm-bookmark.el
@@ -61,6 +61,15 @@
   "Display candidates with an icon with `all-the-icons' when non nil."
   :type 'boolean)
 
+(defcustom helm-bookmark-default-sort-method 'adaptive
+  "Sort method for `helm-filtered-bookmarks'.
+
+Value can be either \\='native' or \\='adaptive'.
+Changes take effect only when Emacs restart."
+  :type '(choice
+          (symbol :tag "Helm adaptive sort method" adaptive)
+          (symbol :tag "Native bookmark sort method" native)))
+
 
 (defgroup helm-bookmark-faces nil
   "Customize the appearance of helm-bookmark."
@@ -133,7 +142,11 @@
                       (bookmark-maybe-load-default-file)
                       (helm-init-candidates-in-buffer
                           'global
-                        (bookmark-all-names))))
+                        (if (and (fboundp 'bookmark-maybe-sort-alist)
+                                 (fboundp 'bookmark-name-from-full-record))
+                            (mapcar 'bookmark-name-from-full-record
+                                    (bookmark-maybe-sort-alist))
+                          (bookmark-all-names)))))
     (filtered-candidate-transformer :initform 'helm-bookmark-transformer)
     (find-file-target :initform #'helm-bookmarks-quit-an-find-file-fn)))
 
@@ -307,7 +320,10 @@ BOOKMARK is a bookmark name or a bookmark record."
 
 (defun helm-bookmark-filter-setup-alist (fn)
   "Return a filtered `bookmark-alist' sorted alphabetically."
-  (cl-loop for b in bookmark-alist
+  (cl-loop for b in (if (and (fboundp 'bookmark-maybe-sort-alist)
+                             (eq helm-bookmark-default-sort-method 'native))
+                             (bookmark-maybe-sort-alist)
+                      bookmark-alist)
            for name = (car b)
            when (funcall fn b) collect
            (propertize name 'location (bookmark-location name))))
@@ -360,8 +376,10 @@ If `browse-url-browser-function' is set to something else 
than
 ;;
 (defclass helm-source-filtered-bookmarks (helm-source-in-buffer 
helm-type-bookmark)
   ((filtered-candidate-transformer
-    :initform '(helm-adaptive-sort
-                helm-highlight-bookmark))
+    :initform (delq nil
+                    `(,(and (eq helm-bookmark-default-sort-method 'adaptive)
+                            'helm-adaptive-sort)
+                       helm-highlight-bookmark)))
    (find-file-target :initform #'helm-bookmarks-quit-an-find-file-fn)))
 
 (defun helm-bookmarks-quit-an-find-file-fn (source)
@@ -542,9 +560,9 @@ If `browse-url-browser-function' is set to something else 
than
             (helm-init-candidates-in-buffer
                 'global (helm-bookmark-uncategorized-setup-alist)))))
 
+
 ;;; Transformer
 ;;
-
 (defun helm-highlight-bookmark (bookmarks _source)
   "Used as `filtered-candidate-transformer' to colorize bookmarks."
   (let ((non-essential t))



reply via email to

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