From: Karl Fogel <kfogel@red-bean.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Manuel Giraud <manuel@ledu-giraud.fr>, emacs-devel@gnu.org
Subject: Re: [PATCH] Fix bookmark-bmenu-list sorting.
Date: Sun, 06 Mar 2022 21:32:49 -0600 [thread overview]
Message-ID: <87h78afndq.fsf@red-bean.com> (raw)
In-Reply-To: <83v8wth5lh.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 04 Mar 2022 21:37:14 +0200")
[-- Attachment #1: Type: text/plain, Size: 739 bytes --]
>Thanks.
>
>Let's install this on master. We can consider backporting to the
>emacs-28 branch after Emacs 28.1 is released.
Installed in commit a6abd06c73.
Sorry I forgot to respond to your question earlier ("if this is a
regression, what was the last Emacs version where the reproduction
recipe worked correctly?"), Eli. I didn't know the answer, and
didn't have time to find out then, but I should have said so
explicitly. (There was enough other information in my reply that
I didn't want to delay sending it.)
As I promised, there are two follow-on changes. I think it would
make sense to also put them on 'master', but I'll attach them here
so you can see for yourself; let me know what you think.
Best regards,
-Karl
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Improve-documentation-of-bookmark-default-sorting.patch --]
[-- Type: text/x-diff, Size: 2394 bytes --]
From 053a68966e0911529fffb87f2ea27e6e6597513f Mon Sep 17 00:00:00 2001
From: Karl Fogel <kfogel@red-bean.com>
Date: Sun, 6 Mar 2022 21:16:47 -0600
Subject: [PATCH] Improve documentation of bookmark default sorting
* lisp/bookmark.el (bookmark-alist, bookmark-store,
bookmark-maybe-sort-alist): Update doc strings and comments.
---
lisp/bookmark.el | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git lisp/bookmark.el lisp/bookmark.el
index 80fb1cdfc7..525bc9dc15 100644
--- 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
(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))))
--
2.34.1
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0001-Ensure-bookmark-bmenu-buffer-sorts-when-it-should.patch --]
[-- Type: text/x-diff, Size: 1320 bytes --]
From 4e5c163e32431a54b76aff88b82a1f95bb58efcc Mon Sep 17 00:00:00 2001
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))
;;;###autoload
--
2.34.1
next prev parent reply other threads:[~2022-03-07 3:32 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-03 16:39 [PATCH] Fix bookmark-bmenu-list sorting Manuel Giraud
2022-03-03 17:41 ` Karl Fogel
2022-03-03 18:19 ` Eli Zaretskii
2022-03-04 3:13 ` Karl Fogel
2022-03-04 7:14 ` Eli Zaretskii
2022-03-04 8:18 ` Karl Fogel
2022-03-04 11:46 ` Eli Zaretskii
2022-03-04 13:25 ` Manuel Giraud
2022-03-04 13:33 ` Eli Zaretskii
2022-03-04 15:15 ` Manuel Giraud
2022-03-04 15:26 ` Eli Zaretskii
2022-03-04 17:41 ` Manuel Giraud
2022-03-04 19:37 ` Eli Zaretskii
2022-03-07 3:32 ` Karl Fogel [this message]
2022-03-07 9:21 ` Manuel Giraud
2022-03-20 23:40 ` Karl Fogel
2022-03-21 7:54 ` Manuel Giraud
2022-03-21 14:14 ` Karl Fogel
2022-04-20 18:09 ` [PATCH] Improve sorting in the bookmark list buffer Karl Fogel
2022-04-20 19:02 ` Eli Zaretskii
2022-04-20 19:49 ` Karl Fogel
2022-04-24 17:30 ` Karl Fogel
2022-04-24 18:13 ` Eli Zaretskii
2022-04-24 19:10 ` Karl Fogel
2022-04-25 9:35 ` Manuel Giraud
2022-04-25 17:50 ` Karl Fogel
2022-04-26 7:51 ` Manuel Giraud
2022-03-07 13:12 ` [PATCH] Fix bookmark-bmenu-list sorting Eli Zaretskii
2022-03-07 19:03 ` Karl Fogel
2022-03-07 5:17 ` Karl Fogel
2022-03-04 8:34 ` Manuel Giraud
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87h78afndq.fsf@red-bean.com \
--to=kfogel@red-bean.com \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=manuel@ledu-giraud.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).