unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Karl Fogel <kfogel@red-bean.com>
To: Manuel Giraud <manuel@ledu-giraud.fr>
Cc: Eli Zaretskii <eliz@gnu.org>, emacs-devel@gnu.org
Subject: Re: [PATCH] Fix bookmark-bmenu-list sorting.
Date: Sun, 20 Mar 2022 18:40:18 -0500	[thread overview]
Message-ID: <87lex4ura5.fsf@red-bean.com> (raw)
In-Reply-To: <87zgm25d9o.fsf@elite.giraud> (Manuel Giraud's message of "Mon, 07 Mar 2022 10:21:23 +0100")

[-- Attachment #1: Type: text/plain, Size: 2253 bytes --]

On 07 Mar 2022, Manuel Giraud wrote:
>Karl Fogel <kfogel@red-bean.com> writes:
>
>>>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.
>
>Thanks. I've tested both of your patch and they are working as 
>intended:
>the order is modified between two `bookmark-bmenu-list' call if I 
>change
>`bookmark-sort-flag'.
>
>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.

Manuel, could you please give me a more verbose reproduction 
recipe for that last paragraph above?  Maybe even include a 
screenshot?

I've attached an updated patch here (please use this version), and 
when I test it, I don't see anything that says "sorted by bookmark 
name".  I don't know what the tabulated-list bar you're referring 
to is, but I don't see anything that would obviously be it.

(I have tried things like turning `menu-bar-mode' on and off. 
I've also tried looking in the code of 
"lisp/emacs-lisp/tabulated-list.el", but I don't see any place 
where a message "sorted by bookmark name" would be set up.)

Now, there is another related UI issue:

In the tabulated-list header line at the top of the buffer, we 
have the expected three columns: "Bookmark", "Type", and "File". 
The first column, "Bookmark", has a down-triangle / up-triangle 
toggle for switching between descending and ascending sort by 
bookmark name.  But if `bookmark-sort-flag' is nil, then when the 
buffer is regenerated the bookmarks will be listed in 
creation-date order -- and the triangular toggle will just keep 
whichever value the triangle had already.

Maybe the right fix for that is for the buffer to somehow indicate 
*which* property the bookmarks are sorted by -- name or 
creation-date -- and make sure that the triangle always reflects 
the sorting direction of whichever thing is currently being sorted 
on.  However, before I go down that road, I'd like to fully 
understand your initial "one minor thing" bug report above first.

Best regards,
-Karl


[-- Attachment #2: 0001-Ensure-bookmark-bmenu-buffer-sorts-when-it-should.patch --]
[-- Type: text/x-diff, Size: 1913 bytes --]

From c8c00cac4bc16e7fccb228756b825ae022b315a0 Mon Sep 17 00:00:00 2001
From: Karl Fogel <kfogel@red-bean.com>
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


  reply	other threads:[~2022-03-20 23:40 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
2022-03-07  9:21                           ` Manuel Giraud
2022-03-20 23:40                             ` Karl Fogel [this message]
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=87lex4ura5.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).