>From c8c00cac4bc16e7fccb228756b825ae022b315a0 Mon Sep 17 00:00:00 2001 From: Karl Fogel Date: Thu, 17 Mar 2022 22:47:16 -0500 Subject: [PATCH] Ensure bookmark bmenu buffer sorts when it should MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch is still WIP, as, as Manuel Giraud has pointed out in his post "Re: [PATCH] Fix bookmark-bmenu-list sorting." of 7 March 2022 (Message-ID: <87zgm25d9o.fsf@elite.giraud>) the following: > There is one minor thing left: the tabulated-list bar (I don't how > it is called) keep the old information « sorted by bookmark name » > when I have revert to `bookmark-sort-flag' as nil. I'm finding out more details from him; once we have it all sorted out, I will update this change. --- lisp/bookmark.el | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git lisp/bookmark.el lisp/bookmark.el index 80fb1cdfc7..400a673447 100644 --- lisp/bookmark.el +++ lisp/bookmark.el @@ -1819,7 +1819,17 @@ 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 + (progn + (setq tabulated-list-sort-key '("Bookmark" . nil)) + (setq tabulated-list-entries entries)) + (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.35.1