From 0e453758898b91d01c2d77326851dc3e7274855b Mon Sep 17 00:00:00 2001 From: Jakob L. Kreuze Date: Sat, 4 Jun 2022 22:59:43 -0400 Subject: [term] Support titles for simultaneously-open terminals --- lisp/appearance/modeline.el | 6 ++++-- lisp/terminal.el | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lisp/appearance/modeline.el b/lisp/appearance/modeline.el index 042142f..b598ccd 100644 --- a/lisp/appearance/modeline.el +++ b/lisp/appearance/modeline.el @@ -106,9 +106,11 @@ RIGHT aligned respectively." "] [%*] Ln: %l/" (number-to-string (1+ (count-lines 1 (point-max)))) " Col: %c")) - ((and (eq major-mode 'vterm-mode) (boundp 'vterm-buffer-title) vterm-buffer-title) + ((and (eq major-mode 'vterm-mode) + (boundp 'vterm-buffer-titles) + (gethash (current-buffer) vterm-buffer-titles)) (concat "%b [%m: " - vterm-buffer-title + (gethash (current-buffer) vterm-buffer-titles) "] [%*] Ln: %l/" (number-to-string (1+ (count-lines 1 (point-max)))) " Col: %c")) diff --git a/lisp/terminal.el b/lisp/terminal.el index 31787a1..c69e569 100644 --- a/lisp/terminal.el +++ b/lisp/terminal.el @@ -10,7 +10,7 @@ ;;; ;; Global variable that we use for the custom modeline. -(defvar vterm-buffer-title nil +(defvar vterm-buffer-titles (make-hash-table) "Title set by shell program.") ;; Some niceties for creating VTerm buffers with descriptive names. @@ -45,7 +45,7 @@ Otherwise, switch to the first available vterm buffer." :config (defun vterm--set-title (title) "Use TITLE to set the buffer name according to `vterm-buffer-name-string'." - (setq vterm-buffer-title title)) + (puthash (current-buffer) title vterm-buffer-titles)) ;; Custom keybindings for cycling through open VTerm buffers. :bind -- cgit v1.3