diff options
| author | Matthias Meulien | 2020-05-21 01:37:30 +0300 |
|---|---|---|
| committer | Juri Linkov | 2020-05-21 01:37:30 +0300 |
| commit | 0bfee4b18be9455e33899178fe4ccf2743ea179b (patch) | |
| tree | 152879fc25f8e4912288805b7fd7feb0937b810d | |
| parent | 5989432d15feb4439e759d2c0e28233ca22a7604 (diff) | |
| download | emacs-0bfee4b18be9455e33899178fe4ccf2743ea179b.tar.gz emacs-0bfee4b18be9455e33899178fe4ccf2743ea179b.zip | |
Bookmark locations can refer to VC directory buffers (bug#39722)
* 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 bookmark-jump behavior for a `vc-dir' buffer.
| -rw-r--r-- | etc/NEWS | 3 | ||||
| -rw-r--r-- | lisp/vc/vc-dir.el | 36 |
2 files changed, 39 insertions, 0 deletions
| @@ -139,6 +139,9 @@ directories with the help of new command 'dired-vc-next-action'. | |||
| 139 | *** New commands 'vc-dir-mark-registered-files' (bound to '* r') and | 139 | *** New commands 'vc-dir-mark-registered-files' (bound to '* r') and |
| 140 | 'vc-dir-mark-unregistered-files'. | 140 | 'vc-dir-mark-unregistered-files'. |
| 141 | 141 | ||
| 142 | *** Support for bookmark.el. | ||
| 143 | Bookmark locations can refer to VC directory buffers. | ||
| 144 | |||
| 142 | ** Gnus | 145 | ** Gnus |
| 143 | 146 | ||
| 144 | --- | 147 | --- |
diff --git a/lisp/vc/vc-dir.el b/lisp/vc/vc-dir.el index 0c9e656add4..a86c37c24ae 100644 --- a/lisp/vc/vc-dir.el +++ b/lisp/vc/vc-dir.el | |||
| @@ -1106,6 +1106,7 @@ the *vc-dir* buffer. | |||
| 1106 | (set (make-local-variable 'vc-dir-backend) use-vc-backend) | 1106 | (set (make-local-variable 'vc-dir-backend) use-vc-backend) |
| 1107 | (set (make-local-variable 'desktop-save-buffer) | 1107 | (set (make-local-variable 'desktop-save-buffer) |
| 1108 | 'vc-dir-desktop-buffer-misc-data) | 1108 | 'vc-dir-desktop-buffer-misc-data) |
| 1109 | (setq-local bookmark-make-record-function #'vc-dir-bookmark-make-record) | ||
| 1109 | (setq buffer-read-only t) | 1110 | (setq buffer-read-only t) |
| 1110 | (when (boundp 'tool-bar-map) | 1111 | (when (boundp 'tool-bar-map) |
| 1111 | (set (make-local-variable 'tool-bar-map) vc-dir-tool-bar-map)) | 1112 | (set (make-local-variable 'tool-bar-map) vc-dir-tool-bar-map)) |
| @@ -1466,6 +1467,41 @@ These are the commands available for use in the file status buffer: | |||
| 1466 | '(vc-dir-mode . vc-dir-restore-desktop-buffer)) | 1467 | '(vc-dir-mode . vc-dir-restore-desktop-buffer)) |
| 1467 | 1468 | ||
| 1468 | 1469 | ||
| 1470 | ;;; Support for bookmark.el (adapted from what info.el does). | ||
| 1471 | |||
| 1472 | (declare-function bookmark-make-record-default | ||
| 1473 | "bookmark" (&optional no-file no-context posn)) | ||
| 1474 | (declare-function bookmark-prop-get "bookmark" (bookmark prop)) | ||
| 1475 | (declare-function bookmark-default-handler "bookmark" (bmk)) | ||
| 1476 | (declare-function bookmark-get-bookmark-record "bookmark" (bmk)) | ||
| 1477 | |||
| 1478 | (defun vc-dir-bookmark-make-record () | ||
| 1479 | "Make record used to bookmark a `vc-dir' buffer. | ||
| 1480 | This implements the `bookmark-make-record-function' type for | ||
| 1481 | `vc-dir' buffers." | ||
| 1482 | (let* ((bookmark-name | ||
| 1483 | (concat "(" (symbol-name vc-dir-backend) ") " | ||
| 1484 | (file-name-nondirectory | ||
| 1485 | (directory-file-name default-directory)))) | ||
| 1486 | (defaults (list bookmark-name default-directory))) | ||
| 1487 | `(,bookmark-name | ||
| 1488 | ,@(bookmark-make-record-default 'no-file) | ||
| 1489 | (filename . ,default-directory) | ||
| 1490 | (handler . vc-dir-bookmark-jump) | ||
| 1491 | (defaults . ,defaults)))) | ||
| 1492 | |||
| 1493 | ;;;###autoload | ||
| 1494 | (defun vc-dir-bookmark-jump (bmk) | ||
| 1495 | "Provides the bookmark-jump behavior for a `vc-dir' buffer. | ||
| 1496 | This implements the `handler' function interface for the record | ||
| 1497 | type returned by `vc-dir-bookmark-make-record'." | ||
| 1498 | (let* ((file (bookmark-prop-get bmk 'filename)) | ||
| 1499 | (buf (save-window-excursion | ||
| 1500 | (vc-dir file) (current-buffer)))) | ||
| 1501 | (bookmark-default-handler | ||
| 1502 | `("" (buffer . ,buf) . ,(bookmark-get-bookmark-record bmk))))) | ||
| 1503 | |||
| 1504 | |||
| 1469 | (provide 'vc-dir) | 1505 | (provide 'vc-dir) |
| 1470 | 1506 | ||
| 1471 | ;;; vc-dir.el ends here | 1507 | ;;; vc-dir.el ends here |