Function: bookmark-maybe-sort-alist

bookmark-maybe-sort-alist is a byte-compiled function defined in bookmark.el.gz.

Signature

(bookmark-maybe-sort-alist)

Documentation

Return bookmark-alist for display.

If bookmark-sort-flag is T, then return a sorted by name copy of the alist. If bookmark-sort-flag is LAST-MODIFIED, then return a sorted by last modified copy of the alist. Otherwise, just return bookmark-alist, which by default is ordered from most recently created to least recently created bookmark.

Source Code

;; Defined in /usr/src/emacs/lisp/bookmark.el.gz
(defun bookmark-maybe-sort-alist ()
  "Return `bookmark-alist' for display.
If `bookmark-sort-flag' is T, then return a sorted by name copy of the alist.
If `bookmark-sort-flag' is LAST-MODIFIED, then return a sorted by last modified
copy of the alist.  Otherwise, just return `bookmark-alist', which by default
is ordered from most recently created to least recently created bookmark."
  (let ((copy (copy-alist bookmark-alist)))
    (cond ((eq bookmark-sort-flag t)
           (sort copy (lambda (x y) (string-lessp (car x) (car y)))))
          ((eq bookmark-sort-flag 'last-modified)
           (sort copy (lambda (x y)
                        (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))))