unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#39722: Support for bookmark.el in VC directory buffers
@ 2020-02-21 21:19 Matthias Meulien
  2020-05-12 22:46 ` Juri Linkov
  2020-06-04 22:42 ` Juri Linkov
  0 siblings, 2 replies; 7+ messages in thread
From: Matthias Meulien @ 2020-02-21 21:19 UTC (permalink / raw)
  To: 39722


[-- 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 --]

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-06-21 23:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-21 21:19 bug#39722: Support for bookmark.el in VC directory buffers Matthias Meulien
2020-05-12 22:46 ` 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

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).