emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 235b8b3: * lisp/tab-bar.el: Don't show window count


From: Juri Linkov
Subject: [Emacs-diffs] master 235b8b3: * lisp/tab-bar.el: Don't show window count for one window.
Date: Wed, 9 Oct 2019 18:43:07 -0400 (EDT)

branch: master
commit 235b8b3a6d0b9ece617ab6408e72f1cf69bb919a
Author: Juri Linkov <address@hidden>
Commit: Juri Linkov <address@hidden>

    * lisp/tab-bar.el: Don't show window count for one window.
    
    * lisp/tab-bar.el (tab-bar-tab-name-selected-window): Don't show the number
    of windows when there is only one window in the window configuration.
    (tab-bar-close-other-tabs): Rename from tab-close-other.
    Take into account tab-bar-show to turn off when needed.
    (tab-close-other): Alias to tab-bar-close-other-tabs.
---
 lisp/tab-bar.el | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index 91bc589..c4eba86 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -268,7 +268,10 @@ from all windows in the window configuration."
 (defun tab-bar-tab-name-selected-window ()
   "Generate tab name from the buffer of the selected window.
 Also add the number of windows in the window configuration."
-  (format "%s (%d)" (buffer-name) (length (window-list-1 nil 'nomini))))
+  (let ((count (length (window-list-1 nil 'nomini))))
+    (if (> count 1)
+        (format "%s (%d)" (buffer-name) count)
+      (format "%s" (buffer-name)))))
 
 (defun tab-bar-tab-name-all-windows ()
   "Generate tab name from buffers of all windows."
@@ -576,13 +579,17 @@ TO-INDEX counts from 1."
                                               (tab-bar-tabs)))))
   (tab-bar-close-tab (1+ (tab-bar--tab-index-by-name name))))
 
-(defun tab-close-other ()
+(defun tab-bar-close-other-tabs ()
   "Close all tabs on the selected frame, except the selected one."
   (interactive)
   (let* ((tabs (tab-bar-tabs))
          (current-index (tab-bar--current-tab-index tabs)))
     (when current-index
       (set-frame-parameter nil 'tabs (list (nth current-index tabs)))
+      (when (and tab-bar-mode
+                 (and (natnump tab-bar-show)
+                      (<= 1 tab-bar-show)))
+        (tab-bar-mode -1))
       (if tab-bar-mode
           (force-mode-line-update)
         (message "Deleted all other tabs")))))
@@ -590,12 +597,13 @@ TO-INDEX counts from 1."
 
 ;;; Short aliases
 
-(defalias 'tab-new      'tab-bar-new-tab)
-(defalias 'tab-close    'tab-bar-close-tab)
-(defalias 'tab-select   'tab-bar-select-tab)
-(defalias 'tab-next     'tab-bar-switch-to-next-tab)
-(defalias 'tab-previous 'tab-bar-switch-to-prev-tab)
-(defalias 'tab-list     'tab-bar-list)
+(defalias 'tab-new         'tab-bar-new-tab)
+(defalias 'tab-close       'tab-bar-close-tab)
+(defalias 'tab-close-other 'tab-bar-close-other-tabs)
+(defalias 'tab-select      'tab-bar-select-tab)
+(defalias 'tab-next        'tab-bar-switch-to-next-tab)
+(defalias 'tab-previous    'tab-bar-switch-to-prev-tab)
+(defalias 'tab-list        'tab-bar-list)
 
 
 ;;; Non-graphical access to frame-local tabs (named window configurations)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]