emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 0bfee4b: Bookmark locations can refer to VC directory buffers (bu


From: Juri Linkov
Subject: master 0bfee4b: Bookmark locations can refer to VC directory buffers (bug#39722)
Date: Wed, 20 May 2020 18:38:00 -0400 (EDT)

branch: master
commit 0bfee4b18be9455e33899178fe4ccf2743ea179b
Author: Matthias Meulien <address@hidden>
Commit: Juri Linkov <address@hidden>

    Bookmark locations can refer to VC directory buffers (bug#39722)
    
    * etc/NEWS: Document feature.
    * lisp/vc/vc-dir.el (vc-dir-mode): Set local bookmark-make-record-function.
    (bookmark-make-record-default, bookmark-prop-get, bookmark-default-handler)
    (bookmark-get-bookmark-record): Declarations.
    (vc-dir-bookmark-make-record): Make record used to bookmark a `vc-dir' 
buffer.
    (vc-dir-bookmark-jump): Provides bookmark-jump behavior for a `vc-dir' 
buffer.
---
 etc/NEWS          |  3 +++
 lisp/vc/vc-dir.el | 36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+)

diff --git a/etc/NEWS b/etc/NEWS
index 2cbb7ad..1bf1403 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -139,6 +139,9 @@ directories with the help of new command 
'dired-vc-next-action'.
 *** New commands 'vc-dir-mark-registered-files' (bound to '* r') and
 'vc-dir-mark-unregistered-files'.
 
+*** Support for bookmark.el.
+Bookmark locations can refer to VC directory buffers.
+
 ** Gnus
 
 ---
diff --git a/lisp/vc/vc-dir.el b/lisp/vc/vc-dir.el
index 0c9e656..a86c37c 100644
--- a/lisp/vc/vc-dir.el
+++ b/lisp/vc/vc-dir.el
@@ -1106,6 +1106,7 @@ the *vc-dir* buffer.
   (set (make-local-variable 'vc-dir-backend) use-vc-backend)
   (set (make-local-variable 'desktop-save-buffer)
        'vc-dir-desktop-buffer-misc-data)
+  (setq-local bookmark-make-record-function #'vc-dir-bookmark-make-record)
   (setq buffer-read-only t)
   (when (boundp 'tool-bar-map)
     (set (make-local-variable 'tool-bar-map) vc-dir-tool-bar-map))
@@ -1466,6 +1467,41 @@ These are the commands available for use in the file 
status buffer:
             '(vc-dir-mode . vc-dir-restore-desktop-buffer))
 
 
+;;; Support for bookmark.el (adapted from what info.el does).
+
+(declare-function bookmark-make-record-default
+                  "bookmark" (&optional no-file no-context posn))
+(declare-function bookmark-prop-get "bookmark" (bookmark prop))
+(declare-function bookmark-default-handler "bookmark" (bmk))
+(declare-function bookmark-get-bookmark-record "bookmark" (bmk))
+
+(defun vc-dir-bookmark-make-record ()
+  "Make record used to bookmark a `vc-dir' buffer.
+This implements the `bookmark-make-record-function' type for
+`vc-dir' buffers."
+  (let* ((bookmark-name
+          (concat "(" (symbol-name vc-dir-backend) ") "
+                  (file-name-nondirectory
+                   (directory-file-name default-directory))))
+         (defaults (list bookmark-name default-directory)))
+    `(,bookmark-name
+      ,@(bookmark-make-record-default 'no-file)
+      (filename . ,default-directory)
+      (handler . vc-dir-bookmark-jump)
+      (defaults . ,defaults))))
+
+;;;###autoload
+(defun vc-dir-bookmark-jump (bmk)
+  "Provides the bookmark-jump behavior for a `vc-dir' buffer.
+This implements the `handler' function interface for the record
+type returned by `vc-dir-bookmark-make-record'."
+  (let* ((file (bookmark-prop-get bmk 'filename))
+         (buf (save-window-excursion
+                 (vc-dir file) (current-buffer))))
+    (bookmark-default-handler
+     `("" (buffer . ,buf) . ,(bookmark-get-bookmark-record bmk)))))
+
+
 (provide 'vc-dir)
 
 ;;; vc-dir.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]