[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#39722: Support for bookmark.el in VC directory buffers
From: |
Matthias Meulien |
Subject: |
bug#39722: Support for bookmark.el in VC directory buffers |
Date: |
Wed, 13 May 2020 02:35:08 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
(...) Thanks, this is a useful addition. Please push it after
fixing minor details:
Thanks Juri for your remark. I updated the patch. Unfortunately I
am not authorized to push.
According to the documentation standard described in (info
"(elisp) Documentation Tips") the first line of the docstring
should consist of a complete sentence.
I'll keep this in mind.
>From 4d4d3e819dc849268e7b3a15ea0d2390c337c23c Mon Sep 17 00:00:00 2001
From: Matthias Meulien <orontee@gmail.com>
Date: Fri, 21 Feb 2020 22:13:48 +0100
Subject: [PATCH] Bookmark locations can refer to VC directory buffers
* 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 the bookmark-jump behavior for a `vc-dir'
buffer.
---
etc/NEWS | 4 ++++
lisp/vc/vc-dir.el | 36 ++++++++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+)
diff --git a/etc/NEWS b/etc/NEWS
index ae676a9bf8..01c584833b 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -348,6 +348,10 @@ symbol property to the browsing functions. With a new
command
'browse-url-with-browser-kind', an URL can explicitly be browsed with
either an internal or external browser.
+** vc-dir.el
+
+*** Support for bookmark.el.
+Bookmark locations can refer to VC directory buffers.
* New Modes and Packages in Emacs 28.1
diff --git a/lisp/vc/vc-dir.el b/lisp/vc/vc-dir.el
index 0c9e656add..a86c37c24a 100644
--- a/lisp/vc/vc-dir.el
+++ b/lisp/vc/vc-dir.el
@@ -1106,6 +1106,7 @@ vc-dir-mode
(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 @@ vc-dir-restore-desktop-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
--
2.20.1
--
Matthias Meulien