all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Thien-Thi Nguyen <ttn@gnuvola.org>
To: kfogel@red-bean.com
Cc: emacs-devel@gnu.org
Subject: PATCH: bookmark.el LIFO preservation
Date: Mon, 16 Jul 2007 12:35:11 +0200	[thread overview]
Message-ID: <877ip0myao.fsf@ambire.localdomain> (raw)

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

according to comments in bookmark.el, if `bookmark-sort-flag' is
non-nil, the entries in the menu list are to be displayed in LIFO order.

unfortunately, while `bookmark-maybe-sort-alist' currently does manage a
properly non-destructive sort, it then goes on to assign the result to
`bookmark-alist' anyway, thus losing the original order.  entries have
no timestamp, either, so the order cannot even be recovered.

to see this behavior:

  (setq bookmark-sort-flag t)         ; default t anyway
  (bookmark-bmenu-list)               ; note lexical ordering
  (setq bookmark-sort-flag nil)
  (bookmark-bmenu-list)               ; note lexical ordering
  (describe-variable 'bookmark-alist)

the last form is not strictly necessary; i include it to demonstrate the
lossage at the data-structure level.  below is a small patch that makes
the display option actually only affect display.  here is a ChangeLog
entry:

	* bookmark.el (bookmark-maybe-sort-alist): Don't modify
	bookmark-alist.  Instead, if not sorting, simply return it.
	(bookmark-bmenu-list): Call bookmark-maybe-sort-alist
	for its return value, not for its side effect.

do you mind if i install it?

thi

________________________________________________________

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: .ttn.bookmark.diff --]
[-- Type: text/x-diff, Size: 1852 bytes --]

Index: bookmark.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/bookmark.el,v
retrieving revision 1.94
diff -c -r1.94 bookmark.el
*** bookmark.el	16 Jul 2007 02:16:00 -0000	1.94
--- bookmark.el	16 Jul 2007 10:11:25 -0000
***************
*** 1045,1054 ****
    ;;Return the bookmark-alist for display.  If the bookmark-sort-flag
    ;;is non-nil, then return a sorted copy of the alist.
    (if bookmark-sort-flag
!       (setq bookmark-alist
!             (sort (copy-alist bookmark-alist)
!                   (function
!                    (lambda (x y) (string-lessp (car x) (car y))))))))
  
  
  (defvar bookmark-after-jump-hook nil
--- 1045,1054 ----
    ;;Return the bookmark-alist for display.  If the bookmark-sort-flag
    ;;is non-nil, then return a sorted copy of the alist.
    (if bookmark-sort-flag
!       (sort (copy-alist bookmark-alist)
!             (function
!              (lambda (x y) (string-lessp (car x) (car y)))))
!     bookmark-alist))
  
  
  (defvar bookmark-after-jump-hook nil
***************
*** 1590,1596 ****
      (insert "% Bookmark\n- --------\n")
      (add-text-properties (point-min) (point)
  			 '(font-lock-face bookmark-menu-heading))
-     (bookmark-maybe-sort-alist)
      (mapcar
       (lambda (full-record)
         ;; if a bookmark has an annotation, prepend a "*"
--- 1590,1595 ----
***************
*** 1613,1619 ****
  		  help-echo "mouse-2: go to this bookmark in other window")))
  	   (insert "\n")
  	   )))
!      bookmark-alist))
    (goto-char (point-min))
    (forward-line 2)
    (bookmark-bmenu-mode)
--- 1612,1618 ----
  		  help-echo "mouse-2: go to this bookmark in other window")))
  	   (insert "\n")
  	   )))
!      (bookmark-maybe-sort-alist)))
    (goto-char (point-min))
    (forward-line 2)
    (bookmark-bmenu-mode)

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

             reply	other threads:[~2007-07-16 10:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-16 10:35 Thien-Thi Nguyen [this message]
2007-07-16 16:02 ` PATCH: bookmark.el LIFO preservation Karl Fogel

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877ip0myao.fsf@ambire.localdomain \
    --to=ttn@gnuvola.org \
    --cc=emacs-devel@gnu.org \
    --cc=kfogel@red-bean.com \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.