From: Lars Ingebrigtsen Date: Sun, 18 Jul 2021 14:34:02 +0000 (+0200) Subject: Maintain a list of terminal buffers in the menu X-Git-Tag: emacs-28.0.90~1822 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=e77bd6e8bf0601029465f1af11bbef97ba2d1f49;p=emacs.git 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. --- 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)