unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Matthias Meulien <orontee@gmail.com>
To: Juri Linkov <juri@linkov.net>
Cc: 39722@debbugs.gnu.org
Subject: bug#39722: Support for bookmark.el in VC directory buffers
Date: Wed, 13 May 2020 02:35:08 +0200	[thread overview]
Message-ID: <874kskwu2r.fsf@gmail.com> (raw)
In-Reply-To: <87imh0n80q.fsf@mail.linkov.net> (Juri Linkov's message of "Wed,  13 May 2020 01:46:05 +0300")

[-- Attachment #1: Type: text/plain, Size: 380 bytes --]

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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Bookmark-locations-can-refer-to-VC-directory-buffers.patch --]
[-- Type: text/x-diff, Size: 3342 bytes --]

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.
 \f
 * 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))
 
 \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 ()
+  "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)))))
+
+\f
 (provide 'vc-dir)
 
 ;;; vc-dir.el ends here
-- 
2.20.1


[-- Attachment #3: Type: text/plain, Size: 22 bytes --]


-- 
Matthias Meulien

  reply	other threads:[~2020-05-13  0:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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=874kskwu2r.fsf@gmail.com \
    --to=orontee@gmail.com \
    --cc=39722@debbugs.gnu.org \
    --cc=juri@linkov.net \
    /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).