diff options
author | Lars Ingebrigtsen <larsi@gnus.org> | 2021-07-18 16:34:02 +0200 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2021-07-18 16:35:17 +0200 |
commit | e77bd6e8bf0601029465f1af11bbef97ba2d1f49 (patch) | |
tree | 1d60db91083b0f15526b68e4a0d8c89f3aefdd6d /lisp/term.el | |
parent | 595eddd848740bc132ae2bbdf630876114364f98 (diff) | |
download | emacs-e77bd6e8bf0601029465f1af11bbef97ba2d1f49.tar.gz emacs-e77bd6e8bf0601029465f1af11bbef97ba2d1f49.tar.bz2 emacs-e77bd6e8bf0601029465f1af11bbef97ba2d1f49.zip |
Maintain a list of terminal buffers in the menu
* lisp/term.el (term--update-term-menu): New function (bug#5641).
(term-mode): Use it to list terminal buffers.
Diffstat (limited to 'lisp/term.el')
-rw-r--r-- | lisp/term.el | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/lisp/term.el b/lisp/term.el index d41895ad3d9..560549ece90 100644 --- a/lisp/term.el +++ b/lisp/term.el @@ -864,8 +864,30 @@ is buffer-local." ["Paging" term-pager-toggle :style toggle :selected term-pager-count :help "Toggle paging feature"])) +(defun term--update-term-menu (&optional force) + (when (and (lookup-key term-mode-map [menu-bar terminal]) + (or force (frame-or-buffer-changed-p))) + (let ((buffer-list + (seq-filter + (lambda (buffer) + (provided-mode-derived-p (buffer-local-value 'major-mode buffer) + 'term-mode)) + (buffer-list)))) + (easy-menu-change + '("Terminal") + "Terminal Buffers" + (mapcar + (lambda (buffer) + (vector (format "%s (%s)" (buffer-name buffer) + (abbreviate-file-name + (buffer-local-value 'default-directory buffer))) + (lambda () + (interactive) + (switch-to-buffer buffer)))) + buffer-list))))) + (easy-menu-define term-signals-menu - (list term-mode-map term-raw-map term-pager-break-map) + (list term-mode-map term-raw-map term-pager-break-map) "Signals menu for Term mode." '("Signals" ["BREAK" term-interrupt-subjob :active t @@ -1076,6 +1098,7 @@ Entry to this mode runs the hooks on `term-mode-hook'." (setq-local term-pending-delete-marker (make-marker)) (make-local-variable 'term-current-face) (term-ansi-reset) + (add-hook 'menu-bar-update-hook 'term--update-term-menu) (setq-local term-pending-frame nil) ;; Cua-mode's keybindings interfere with the term keybindings, disable it. (setq-local cua-mode nil) |