From fccde521585c708a9108517204b3e9a88c25ab2f Mon Sep 17 00:00:00 2001 From: Manuel Giraud Date: Wed, 1 Jun 2022 17:32:28 +0200 Subject: [PATCH] Place bookmarks without last-modified at the end * lisp/bookmark.el (bookmark-sort-flag): Typo fix in doc string. (bookmark-maybe-sort-alist): Fix sorting when there's no last modified. --- lisp/bookmark.el | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lisp/bookmark.el b/lisp/bookmark.el index 8e251e9de87..849303fac7e 100644 --- a/lisp/bookmark.el +++ b/lisp/bookmark.el @@ -120,7 +120,7 @@ nil means they will be displayed in LIFO order (that is, most recently created ones come first, oldest ones come last). `last-modified' means that bookmarks will be displayed sorted -from most recently set to last recently set. +from most recently set to least recently set. Other values means that bookmarks will be displayed sorted by bookmark name." @@ -520,8 +520,11 @@ is ordered from most recently created to least recently created bookmark." (sort copy (lambda (x y) (string-lessp (car x) (car y))))) ((eq bookmark-sort-flag 'last-modified) (sort copy (lambda (x y) - (time-less-p (bookmark-get-last-modified y) - (bookmark-get-last-modified x))))) + (let ((tx (bookmark-get-last-modified x)) + (ty (bookmark-get-last-modified y))) + (cond ((null tx) nil) + ((null ty) t) + (t (time-less-p ty tx))))))) (t copy)))) (defun bookmark-completing-read (prompt &optional default) -- 2.39.2