summaryrefslogtreecommitdiff
path: root/lisp/eshell/esh-mode.el
diff options
context:
space:
mode:
authorStefan Kangas <stefankangas@gmail.com>2020-09-03 14:30:53 +0200
committerStefan Kangas <stefankangas@gmail.com>2020-09-03 14:36:38 +0200
commit23ee78b00512ea0001f8e21646a725ac13c96e17 (patch)
treed6a95a18ad95a2e2025fd8df06312fe0d4927e48 /lisp/eshell/esh-mode.el
parentd37861535dfd452f7c2255ae5edcf7686b75fe5a (diff)
downloademacs-23ee78b00512ea0001f8e21646a725ac13c96e17.tar.gz
Support bookmarking Eshell buffers
* lisp/eshell/esh-mode.el (eshell-bookmark-name) (eshell-bookmark-make-record, eshell-bookmark-jump): New defuns. (eshell-mode): Set up bookmark handler.
Diffstat (limited to 'lisp/eshell/esh-mode.el')
-rw-r--r--lisp/eshell/esh-mode.el25
1 files changed, 25 insertions, 0 deletions
diff --git a/lisp/eshell/esh-mode.el b/lisp/eshell/esh-mode.el
index 8799007c596..791d472ec03 100644
--- a/lisp/eshell/esh-mode.el
+++ b/lisp/eshell/esh-mode.el
@@ -329,6 +329,8 @@ and the hook `eshell-exit-hook'."
(if mode-line-elt
(setcar mode-line-elt 'eshell-command-running-string))))
+ (set (make-local-variable 'bookmark-make-record-function)
+ 'eshell-bookmark-make-record)
(setq local-abbrev-table eshell-mode-abbrev-table)
(set (make-local-variable 'list-buffers-directory)
@@ -1015,5 +1017,28 @@ This function could be in the list `eshell-output-filter-functions'."
(custom-add-option 'eshell-output-filter-functions
'eshell-handle-ansi-color)
+;;; Bookmark support:
+
+(declare-function bookmark-make-record-default
+ "bookmark" (&optional no-file no-context posn))
+(declare-function bookmark-prop-get "bookmark" (bookmark prop))
+
+(defun eshell-bookmark-name ()
+ (format "eshell-%s"
+ (file-name-nondirectory
+ (directory-file-name
+ (file-name-directory default-directory)))))
+
+(defun eshell-bookmark-make-record ()
+ "Create a bookmark for the current Eshell buffer."
+ `(,(eshell-bookmark-name)
+ (location . ,default-directory)
+ (handler . eshell-bookmark-jump)))
+
+(defun eshell-bookmark-jump (bookmark)
+ "Default bookmark handler for Eshell buffers."
+ (let ((default-directory (bookmark-prop-get bookmark 'location)))
+ (eshell)))
+
(provide 'esh-mode)
;;; esh-mode.el ends here