From 4e5c163e32431a54b76aff88b82a1f95bb58efcc Mon Sep 17 00:00:00 2001 From: Karl Fogel 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