emacs-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] Fix bookmark-bmenu-list sorting.


From: Eli Zaretskii
Subject: Re: [PATCH] Fix bookmark-bmenu-list sorting.
Date: Mon, 07 Mar 2022 15:12:54 +0200

> From: Karl Fogel <kfogel@red-bean.com>
> Cc: Manuel Giraud <manuel@ledu-giraud.fr>,  emacs-devel@gnu.org
> Date: Sun, 06 Mar 2022 21:32:49 -0600
> 
> --- lisp/bookmark.el
> +++ lisp/bookmark.el
> @@ -246,11 +246,13 @@ bookmark-alist
>  Bookmark functions update the value automatically.
>  You probably do NOT want to change the value yourself.
>  
> -The value is an alist with bookmarks of the form
> +The value is an alist whose elements are the form
                               ^^^^^^^^^^^^^^^^^^^^^              
"...elements are of the form", right?

>  
>   (BOOKMARK-NAME . PARAM-ALIST)
>  
> -or the deprecated form (BOOKMARK-NAME PARAM-ALIST).
> +or the deprecated form (BOOKMARK-NAME PARAM-ALIST).  The alist is
> +ordered from most recently created bookmark at the front to least
> +recently created bookmark at the end.
>  
>  BOOKMARK-NAME is the name you gave to the bookmark when creating it.
>  
> @@ -583,10 +585,10 @@ bookmark-store
>            ;; Modify using the new (NAME . ALIST) format.
>            (setcdr bm alist))
>  
> -      ;; otherwise just cons it onto the front (either the bookmark
> -      ;; doesn't exist already, or there is no prefix arg.  In either
> -      ;; case, we want the new bookmark consed onto the alist...)
> -
> +      ;; Otherwise just put it onto the front of the list.  Either the
> +      ;; bookmark doesn't exist already, or there is no prefix arg.
> +      ;; In either case, we want the new bookmark on the front of the
> +      ;; list, since the list is kept in reverse order of creation.
>        (push (cons stripped-name alist) bookmark-alist))
>  
>      ;; Added by db
> @@ -1140,7 +1142,9 @@ bookmark-maybe-load-default-file
>  
>  (defun bookmark-maybe-sort-alist ()
>    "Return `bookmark-alist' for display.
> -If `bookmark-sort-flag' is non-nil, then return a sorted copy of the alist."
> +If `bookmark-sort-flag' is non-nil, then return a sorted copy of the alist.
> +Otherwise, just return `bookmark-alist', which by default is ordered
> +from most recently created to least recently created bookmark."
>    (if bookmark-sort-flag
>        (sort (copy-alist bookmark-alist)
>              (lambda (x y) (string-lessp (car x) (car y))))

These are documentation changes, so if you like, you can install them
on the emacs-28 branch.

> From: Karl Fogel <kfogel@red-bean.com>
> Date: Sun, 6 Mar 2022 21:20:34 -0600
> Subject: [PATCH] Ensure bookmark bmenu buffer sorts when it should
> 
> * lisp/bookmark.el (bookmark-bmenu--revert): Check `bookmark-sort-flag'
>   every time when displaying bookmarks.
> ---
>  lisp/bookmark.el | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git lisp/bookmark.el lisp/bookmark.el
> index 525bc9dc15..6c72621bc3 100644
> --- lisp/bookmark.el
> +++ lisp/bookmark.el
> @@ -1823,7 +1823,15 @@ bookmark-bmenu--revert
>                         (list location))])
>                entries)))
>      (tabulated-list-init-header)
> -    (setq tabulated-list-entries (reverse entries)))
> +    ;; The value of `bookmark-sort-flag' might have changed since the
> +    ;; last time the buffer contents were generated, so re-check it.
> +    (if bookmark-sort-flag
> +        (setq tabulated-list-sort-key '("Bookmark" . nil))
> +      (setq tabulated-list-sort-key nil)
> +      ;; And since we're not sorting by bookmark name, show bookmarks
> +      ;; in reverse order of creation: most recently created at the
> +      ;; top, least recently created at the bottom.
> +      (setq tabulated-list-entries (reverse entries))))
>    (tabulated-list-print t))

This one is still under debate (or at least incomplete), AFAIU.

Thanks.



reply via email to

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