]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/tab-bar.el: Don't show window count for one window.
authorJuri Linkov <juri@linkov.net>
Wed, 9 Oct 2019 22:42:56 +0000 (01:42 +0300)
committerJuri Linkov <juri@linkov.net>
Wed, 9 Oct 2019 22:42:56 +0000 (01:42 +0300)
* 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

index 91bc589ae29b51c66635ddb0608795aa87af571e..c4eba8600ac2da8858368a56de74d2714c97f12e 100644 (file)
@@ -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."
 \f
 ;;; 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)
 
 \f
 ;;; Non-graphical access to frame-local tabs (named window configurations)