From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Karl Fogel Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Fix bookmark-bmenu-list sorting. Date: Sun, 06 Mar 2022 21:32:49 -0600 Message-ID: <87h78afndq.fsf@red-bean.com> References: <875yovm1m6.fsf@elite.giraud> <87v8wvkk64.fsf@red-bean.com> <83v8wuj3v0.fsf@gnu.org> <87tucewgu7.fsf@red-bean.com> <83lexqi3z9.fsf@gnu.org> <87tuceuo4b.fsf@red-bean.com> <83czj2hrdv.fsf@gnu.org> <87a6e5lui6.fsf@elite.giraud> <837d99j10x.fsf@gnu.org> <874k4dlpeg.fsf@elite.giraud> <834k4divrt.fsf@gnu.org> <87wnh9k43g.fsf@elite.giraud> <83v8wth5lh.fsf@gnu.org> Reply-To: Karl Fogel Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13733"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: Manuel Giraud , emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Mar 07 04:33:46 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nR480-0003Ko-QO for ged-emacs-devel@m.gmane-mx.org; Mon, 07 Mar 2022 04:33:45 +0100 Original-Received: from localhost ([::1]:46272 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nR47z-0003qR-DP for ged-emacs-devel@m.gmane-mx.org; Sun, 06 Mar 2022 22:33:43 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:53362) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nR47E-00030E-NU for emacs-devel@gnu.org; Sun, 06 Mar 2022 22:32:56 -0500 Original-Received: from sanpietro.red-bean.com ([45.79.25.59]:36474) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nR47C-0002Ej-M6; Sun, 06 Mar 2022 22:32:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=red-bean.com; s=202005newsp; h=Content-Type:MIME-Version:Message-ID: In-Reply-To:Date:Reply-To:References:Subject:Cc:To:From:Sender: Content-Transfer-Encoding:Content-ID:Content-Description; bh=h/aFG5lCP3/cTr93MtbrcmVk+YB358nSVpTngUXJ5cg=; t=1646623972; x=1647833572; b=i0EUZnXRhdKamjDXR+p73dAzq1ijPUr3QAuObll2J/n9ixzMNdfgmHGUwwaiTpSxxDWu3w64Wfj iNi+iEF2WxQXGnIPX9957q+geAZ3EcO2K68o0Z5+SnaW2c84u59jUNC4LQS8/LInK6Mrwc9dqwuHr qZ74p3pqEXDOpc1uAStf2JzB3E5N8qCy5SAliBNUr0EX3smubzk0+YlsqewCPg6cQCBodMWKSxGX+ +v0wxrSpCAjsvYDmwqkDmjbhMI+3OxZkZIAxb/Ar7Kgr84TO3p8bI3rKPaBLv3Z0bhsC3Tt2SUXSz ldOlfoU5lgWZLY3xZCsSQp5gdKopld8olA9g==; Original-Received: from c-98-206-160-251.hsd1.il.comcast.net ([98.206.160.251]:48972 helo=klen) by sanpietro.red-bean.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nR478-00EqHm-B9; Mon, 07 Mar 2022 03:32:51 +0000 In-Reply-To: <83v8wth5lh.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 04 Mar 2022 21:37:14 +0200") Received-SPF: pass client-ip=45.79.25.59; envelope-from=kfogel@red-bean.com; helo=sanpietro.red-bean.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:286876 Archived-At: --=-=-= Content-Type: text/plain; format=flowed >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 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Improve-documentation-of-bookmark-default-sorting.patch >From 053a68966e0911529fffb87f2ea27e6e6597513f Mon Sep 17 00:00:00 2001 From: Karl Fogel 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 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Ensure-bookmark-bmenu-buffer-sorts-when-it-should.patch >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 --=-=-=--