From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Matthias Meulien Newsgroups: gmane.emacs.bugs Subject: bug#39722: Support for bookmark.el in VC directory buffers Date: Wed, 13 May 2020 02:35:08 +0200 Message-ID: <874kskwu2r.fsf@gmail.com> References: <4738c0198ff32df9ea59906ef055e68838e921f0.camel@gmail.com> <87imh0n80q.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="56899"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 39722@debbugs.gnu.org To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed May 13 02:36:11 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jYfNa-000Eem-Sg for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 13 May 2020 02:36:10 +0200 Original-Received: from localhost ([::1]:54678 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYfNZ-00052D-Bw for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 12 May 2020 20:36:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35292) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYfNS-00051m-1R for bug-gnu-emacs@gnu.org; Tue, 12 May 2020 20:36:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:45383) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jYfNR-00048f-OF for bug-gnu-emacs@gnu.org; Tue, 12 May 2020 20:36:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jYfNR-0007E1-Ki for bug-gnu-emacs@gnu.org; Tue, 12 May 2020 20:36:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Matthias Meulien Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 13 May 2020 00:36:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 39722 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 39722-submit@debbugs.gnu.org id=B39722.158933011927679 (code B ref 39722); Wed, 13 May 2020 00:36:01 +0000 Original-Received: (at 39722) by debbugs.gnu.org; 13 May 2020 00:35:19 +0000 Original-Received: from localhost ([127.0.0.1]:56923 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jYfMk-0007CM-KP for submit@debbugs.gnu.org; Tue, 12 May 2020 20:35:18 -0400 Original-Received: from mail-wr1-f45.google.com ([209.85.221.45]:45147) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jYfMi-0007By-Ae for 39722@debbugs.gnu.org; Tue, 12 May 2020 20:35:17 -0400 Original-Received: by mail-wr1-f45.google.com with SMTP id v12so18502691wrp.12 for <39722@debbugs.gnu.org>; Tue, 12 May 2020 17:35:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=qcMOMuV95t/nnBsZyevn7HbQe6ZtsO5lgrdVqDlDAW0=; b=MB12a2haOSID85sAYYRZ+utUalBE8KJZPBzu+99SLVULKackc3n2t0BRHmPecSveOp a51kzTzjyx1th+OzB06AJxqn0earFlaQANj6L7NTk8vFuyxV3FeFjWnrJ7CuazvOYDRU 07dTEV/+Gp8sADnJIgwfwztA3M5sspiIhqVgsrLfox3i/y5D5p7HhxBLgz22IWBEiUZk CE4Y70tHZePs8aOMQEL81pxkT6jRofz0j0TDkRBLBnvwJUigHLHGQoIvty7dMyEZ67vL 3Tr154YC5Md6uj9msEDz278amgZ2o4388lwt5UcfS3J9vxquAy4fNTAtjUAR36l0hGmq /rCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=qcMOMuV95t/nnBsZyevn7HbQe6ZtsO5lgrdVqDlDAW0=; b=RROGE6+ZibihjAmMHxGJhp7CsrckNY7F0ApJefCD86QGPXDb7nmqJBNaaon6cG8nog VxLBgNaZsB+IXKC+3+E0A4jxoj3gbIc4NLJYjC+3Z5ePIsI6CBhCFu9PDWcS5fTWjABM tJYnNKrV3Jw0xa/A+iqo99N5Cx4tgPKrrgSTmaQoEDEXghwmuX5LhCQxO3aI47p7Wjf7 GaslG+qNIte/NixQrQyArY1kjy6Ecahh3FXY1AjDksDXcoUGsgca603zAnHnxHYwbxgM Op0GtVdWR+059mgUaptVpwKeKm88s405hwzPtgHjGMyd+3G6lUT3PM+LDoOhnDbWR00N Lx3A== X-Gm-Message-State: AGi0PuYjy7GotevXwly9Ds0A0voYAloyMkFH4cD5a4Z3Q4aGxpeHsmkX CqiPyakBbKzS8QfhvR2WLhKAu4Lzqag= X-Google-Smtp-Source: APiQypJEh27j4ZWXkq5vez7NJ0uo7+VhfQvi4Va5YOGDwJNcTLYzmD9uZ4+qt+e+ZvbnXDKYHC0Udg== X-Received: by 2002:a5d:54c4:: with SMTP id x4mr29513269wrv.73.1589330109841; Tue, 12 May 2020 17:35:09 -0700 (PDT) Original-Received: from carbon.localdomain ([2a01:e0a:252:7910:f1be:8104:293:6ee2]) by smtp.gmail.com with ESMTPSA id l1sm25763916wrc.24.2020.05.12.17.35.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 May 2020 17:35:08 -0700 (PDT) In-Reply-To: <87imh0n80q.fsf@mail.linkov.net> (Juri Linkov's message of "Wed, 13 May 2020 01:46:05 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:180134 Archived-At: --=-=-= Content-Type: text/plain; format=flowed > (...) 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. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Bookmark-locations-can-refer-to-VC-directory-buffers.patch >From 4d4d3e819dc849268e7b3a15ea0d2390c337c23c Mon Sep 17 00:00:00 2001 From: Matthias Meulien 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 --=-=-= Content-Type: text/plain; format=flowed -- Matthias Meulien --=-=-=--