]> git.eshelyaron.com Git - emacs.git/commitdiff
Extend bookmark menu with with handler type column
authorMatthias Meulien <orontee@gmail.com>
Tue, 15 Feb 2022 22:39:02 +0000 (23:39 +0100)
committerLars Ingebrigtsen <larsi@gnus.org>
Thu, 17 Feb 2022 11:58:12 +0000 (12:58 +0100)
* lisp/bookmark.el (bookmark-bmenu--revert): Extend table entries with
handler type.
(bookmark-bmenu-mode): Add handler type column.
* lisp/doc-view.el (doc-view-bookmark-jump): Set bookmark handler type.
* lisp/help-mode.el (help-bookmark-jump): Set bookmark handler type.
* lisp/image-dired.el (image-dired-bookmark-jump): Set bookmark handler type.
* lisp/info.el (Info-bookmark-jump): Set bookmark handler type.
* lisp/net/eww.el (eww-bookmark-jump): Set bookmark handler type.
* lisp/vc/vc-dir.el (vc-dir-bookmark-jump): Set bookmark handler type.
* lisp/woman.el (woman-bookmark-jump): Set bookmark handler type.

lisp/bookmark.el
lisp/doc-view.el
lisp/help-mode.el
lisp/image-dired.el
lisp/info.el
lisp/net/eww.el
lisp/vc/vc-dir.el
lisp/woman.el

index 87533268812f6dd1b4d90ec212a0a5ad130b8c30..61c532c1f34f52e169f5c6a38345317c2afc2107 100644 (file)
@@ -344,6 +344,17 @@ This point is in `bookmark-current-buffer'.")
 BOOKMARK-RECORD is, e.g., one element from `bookmark-alist'."
   (car bookmark-record))
 
+(defun bookmark-type-from-full-record (bookmark-record)
+  "Return then type of BOOKMARK-RECORD.
+BOOKMARK-RECORD is, e.g., one element from `bookmark-alist'. It's
+type is read from the symbol property named
+`bookmark-handler-type' read on the record handler function."
+  (let ((handler (bookmark-get-handler bookmark-record)))
+    (when (autoloadp (symbol-function handler))
+      (autoload-do-load (symbol-function handler)))
+    (if (symbolp handler)
+        (get handler 'bookmark-handler-type)
+     "")))
 
 (defun bookmark-all-names ()
   "Return a list of all current bookmark names."
@@ -1351,7 +1362,6 @@ minibuffer history list `bookmark-history'."
       (bookmark-get-filename bookmark-name-or-record)
       "-- Unknown location --"))
 
-
 ;;;###autoload
 (defun bookmark-rename (old-name &optional new-name)
   "Change the name of OLD-NAME bookmark to NEW-NAME name.
@@ -1790,6 +1800,7 @@ Don't affect the buffer ring order."
   (let (entries)
     (dolist (full-record (bookmark-maybe-sort-alist))
       (let* ((name       (bookmark-name-from-full-record full-record))
+             (type       (bookmark-type-from-full-record full-record))
              (annotation (bookmark-get-annotation full-record))
              (location   (bookmark-location full-record)))
         (push (list
@@ -1803,6 +1814,7 @@ Don't affect the buffer ring order."
                                   'follow-link t
                                   'help-echo "mouse-2: go to this bookmark in other window")
                     name)
+                 ,(or type "")
                  ,@(if bookmark-bmenu-toggle-filenames
                        (list location))])
               entries)))
@@ -1891,6 +1903,7 @@ Bookmark names preceded by a \"*\" have annotations.
   (setq tabulated-list-format
         `[("" 1) ;; Space to add "*" for bookmark with annotation
           ("Bookmark" ,bookmark-bmenu-file-column bookmark-bmenu--name-predicate)
+          ("Type" 15 bookmark-bmenu--type-predicate)
           ,@(if bookmark-bmenu-toggle-filenames
                 '(("File" 0 bookmark-bmenu--file-predicate)))])
   (setq tabulated-list-padding bookmark-bmenu-marks-width)
@@ -1905,6 +1918,10 @@ Bookmark names preceded by a \"*\" have annotations.
 This is used for `tabulated-list-format' in `bookmark-bmenu-mode'."
   (string< (caar a) (caar b)))
 
+(defun bookmark-bmenu--type-predicate (a b)
+  "Predicate to sort \"*Bookmark List*\" buffer by the type column.
+This is used for `tabulated-list-format' in `bookmark-bmenu-mode'."
+  (string< (elt (cadr a) 2) (elt (cadr b) 2)))
 
 (defun bookmark-bmenu--file-predicate (a b)
   "Predicate to sort \"*Bookmark List*\" buffer by the file column.
index 4979a2c0e2478a308057e59b0e4746f075521b5d..193cf42ea426223baa287dfb547041177d2e2426 100644 (file)
@@ -2247,6 +2247,8 @@ See the command `doc-view-mode' for more information on this mode."
     (add-hook 'bookmark-after-jump-hook show-fn-sym)
     (bookmark-default-handler bmk)))
 
+(put 'doc-view-bookmark-jump 'bookmark-handler-type "Docview")
+
 ;; Obsolete.
 
 (defun doc-view-intersection (l1 l2)
index 5fb5dcfb195365f8e7c04d591e39b60ba42bc957..d1b9357f3c9e0296ce0e4045fa178cc6d1bc45b6 100644 (file)
@@ -936,6 +936,7 @@ BOOKMARK is a bookmark name or a bookmark record."
     (pop-to-buffer "*Help*")
     (goto-char position)))
 
+(put 'help-bookmark-jump 'bookmark-handler-type "Help")
 
 (provide 'help-mode)
 
index 9b0bbb70df91e455c6eed7ddb9b2b2276facf989..d8bd2937db84479463e596f269a50329fc458fc1 100644 (file)
@@ -2792,6 +2792,7 @@ tags to their respective image file.  Internal function used by
     ;; (bookmark-prop-get bookmark 'image-dired-file)
     (goto-char (point-min))))
 
+(put 'image-dired-bookmark-jump 'bookmark-handler-type "Image")
 \f
 ;;; Obsolete
 
index bb8cd0d312fae8794327459bdd183eaa5b404ae8..0565663c38e8df40a8aca24b2a30af93ea353060 100644 (file)
@@ -5449,6 +5449,7 @@ type returned by `Info-bookmark-make-record', which see."
     (bookmark-default-handler
      `("" (buffer . ,buf) . ,(bookmark-get-bookmark-record bmk)))))
 
+(put 'Info-bookmark-jump 'bookmark-handler-type "Info")
 \f
 ;;;###autoload
 (defun info-display-manual (manual)
index eaa5c119385a15ed069b39683b4e325aa9526f9d..9db07b51dbd74357894af9cefa4b0a26b63d6a74 100644 (file)
@@ -2499,6 +2499,8 @@ Otherwise, the restored buffer will contain a prompt to do so by using
   "Default bookmark handler for EWW buffers."
   (eww (bookmark-prop-get bookmark 'location)))
 
+(put 'eww-bookmark-jump 'bookmark-handler-type "EWW")
+
 (provide 'eww)
 
 ;;; eww.el ends here
index ba6e098d987ab483a76b83768d8b8e87567cd56c..944b409ea2829b761bffd0fbd9d4fc5e2af2df5b 100644 (file)
@@ -1560,6 +1560,8 @@ type returned by `vc-dir-bookmark-make-record'."
     (bookmark-default-handler
      `("" (buffer . ,buf) . ,(bookmark-get-bookmark-record bmk)))))
 
+(put 'vc-dir-bookmark-jump 'bookmark-handler-type "VC")
+
 \f
 (provide 'vc-dir)
 
index e16785329a482532503d0687af307966e0602895..c0c8f34348422ae78ebeb1dc741db42169551bc8 100644 (file)
@@ -4579,6 +4579,8 @@ logging the message."
     (bookmark-default-handler
      `("" (buffer . ,buf) . ,(bookmark-get-bookmark-record bookmark)))))
 
+(put 'woman-bookmark-jump 'bookmark-handler-type "WoMan")
+
 ;; Obsolete.
 
 (defvar woman-version "0.551 (beta)" "WoMan version information.")