From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Fix bookmark-bmenu-list sorting. Date: Mon, 07 Mar 2022 15:12:54 +0200 Message-ID: <83r17dgb3d.fsf@gnu.org> 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> <87h78afndq.fsf@red-bean.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24071"; mail-complaints-to="usenet@ciao.gmane.io" Cc: manuel@ledu-giraud.fr, emacs-devel@gnu.org To: Karl Fogel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Mar 07 14:22:15 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 1nRDJW-0005zm-Rl for ged-emacs-devel@m.gmane-mx.org; Mon, 07 Mar 2022 14:22:15 +0100 Original-Received: from localhost ([::1]:44570 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRDJV-0002MZ-Pu for ged-emacs-devel@m.gmane-mx.org; Mon, 07 Mar 2022 08:22:13 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:49792) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRDAf-000350-PS for emacs-devel@gnu.org; Mon, 07 Mar 2022 08:13:05 -0500 Original-Received: from [2001:470:142:3::e] (port=42122 helo=fencepost.gnu.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRDAe-0001Lp-Ou; Mon, 07 Mar 2022 08:13:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=14vmVIgjjQMqJsmqU5nsyip6LcDJW0/F7So517sUIvM=; b=Hi86ujPOPPHE cdye+u2q/ewjRO0kC1d8lPT4qkPcivjyjiLRPamCFIHODIAqInIKfAFGYA2v6ahfVhzld+SXdEJDp wgYSP9CELs5ifD3/TF02QF54G+a6oiAUgQ/sKYeBjE9/Pv1H+dGcy6TgDy4XutV8j12H5LHF7MfTk sIDil/Q01V1kqqmjzkiQDUav9OECH57/j79AwP3Rryc09jSh+VUOJG8nC2hogYnHQhdxa0tasqnSW sLGitJdEWtvNYU+posVKHwCxJhlLsMvlekFJzggSvCK5T2h3uktpjRbmXJAMmwqxrnoCc5gpTEzLO zbwv6YVQyp+KDCaQKFcjyg==; Original-Received: from [87.69.77.57] (port=1370 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRDAe-0004Hl-6x; Mon, 07 Mar 2022 08:13:04 -0500 In-Reply-To: <87h78afndq.fsf@red-bean.com> (message from Karl Fogel on Sun, 06 Mar 2022 21:32:49 -0600) 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:286886 Archived-At: > From: Karl Fogel > Cc: Manuel Giraud , emacs-devel@gnu.org > Date: Sun, 06 Mar 2022 21:32:49 -0600 > > --- 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 ^^^^^^^^^^^^^^^^^^^^^ "...elements are of the form", right? > > (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)))) These are documentation changes, so if you like, you can install them on the emacs-28 branch. > 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)) This one is still under debate (or at least incomplete), AFAIU. Thanks.