From: Matthias Meulien <orontee@gmail.com>
To: 39722@debbugs.gnu.org
Subject: bug#39722: Support for bookmark.el in VC directory buffers
Date: Fri, 21 Feb 2020 22:19:34 +0100 [thread overview]
Message-ID: <4738c0198ff32df9ea59906ef055e68838e921f0.camel@gmail.com> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 182 bytes --]
Being able to bookmark VC directory buffers is useful when working on
multiple projects; The proposed patch implements this on the lines of
what I read in info.el.
--
Matthias
[-- Attachment #1.2: 0001-Bookmark-locations-can-refer-to-VC-directory-buffers.patch --]
[-- Type: text/x-patch, Size: 3155 bytes --]
From 13dbe902e95ccd812e490aa7b71daed67954a850 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): Implement bookmark-make-record-function
(vc-dir-bookmark-jump): Implement a bookmark handler for vc-dir buffers
---
etc/NEWS | 5 +++++
lisp/vc/vc-dir.el | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 39 insertions(+)
diff --git a/etc/NEWS b/etc/NEWS
index 0279879836..40f4c78191 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -159,6 +159,11 @@ key binding
/ v package-menu-filter-by-version
/ / package-menu-filter-clear
+** vc-dir.el
+
+*** Support for bookmark.el.
+Bookmark locations can refer to VC directory buffers.
+
\f
* New Modes and Packages in Emacs 28.1
diff --git a/lisp/vc/vc-dir.el b/lisp/vc/vc-dir.el
index 033cb27e33..33ad6243c6 100644
--- a/lisp/vc/vc-dir.el
+++ b/lisp/vc/vc-dir.el
@@ -1061,6 +1061,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))
@@ -1410,6 +1411,39 @@ vc-dir-restore-desktop-buffer
'(vc-dir-mode . vc-dir-restore-desktop-buffer))
\f
+;;; 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 ()
+ "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)
+ "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)))))
+
+\f
(provide 'vc-dir)
;;; vc-dir.el ends here
--
2.20.1
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next reply other threads:[~2020-02-21 21:19 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-21 21:19 Matthias Meulien [this message]
2020-05-12 22:46 ` bug#39722: Support for bookmark.el in VC directory buffers Juri Linkov
2020-05-13 0:35 ` Matthias Meulien
2020-05-20 22:38 ` Juri Linkov
2020-06-04 22:42 ` Juri Linkov
2020-06-06 23:52 ` Juri Linkov
2020-06-21 23:36 ` Juri Linkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4738c0198ff32df9ea59906ef055e68838e921f0.camel@gmail.com \
--to=orontee@gmail.com \
--cc=39722@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).