aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2020-01-23 01:23:17 +0200
committerJuri Linkov2020-01-23 01:23:17 +0200
commit92f080dda8892861be7c175dc57f71dee0909d82 (patch)
tree75235966aeb408d18ef187a835b884d6086c3fcd
parent224e8d146485ce178086549d41fa8359dcc0e03e (diff)
downloademacs-92f080dda8892861be7c175dc57f71dee0909d82.tar.gz
emacs-92f080dda8892861be7c175dc57f71dee0909d82.zip
Tab-bar related finishing touches.
* lisp/tab-bar.el (tab-bar-tab-name-ellipsis): Use shorter name instead of tab-bar-tab-name-truncated-ellipsis. (tab-bar-new-tab-to) <defcustom>: Add 'function' option. (tab-bar-new-tab-to) <function>: Use it. * lisp/tab-line.el (tab-line-close-tab): Add missing arg 'tab' to tab-line-close-tab-function funcall.
-rw-r--r--lisp/tab-bar.el17
-rw-r--r--lisp/tab-line.el2
2 files changed, 12 insertions, 7 deletions
diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index f70fb6baeee..eccab268dc9 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -360,19 +360,19 @@ to `tab-bar-tab-name-truncated'."
360 :group 'tab-bar 360 :group 'tab-bar
361 :version "27.1") 361 :version "27.1")
362 362
363(defvar tab-bar-tab-name-truncated-ellipsis 363(defvar tab-bar-tab-name-ellipsis
364 (if (char-displayable-p ?…) "…" "...")) 364 (if (char-displayable-p ?…) "…" "..."))
365 365
366(defun tab-bar-tab-name-truncated () 366(defun tab-bar-tab-name-truncated ()
367 "Generate tab name from the buffer of the selected window. 367 "Generate tab name from the buffer of the selected window.
368Truncate it to the length specified by `tab-bar-tab-name-truncated-max'. 368Truncate it to the length specified by `tab-bar-tab-name-truncated-max'.
369Append ellipsis `tab-bar-tab-name-truncated-ellipsis' in this case." 369Append ellipsis `tab-bar-tab-name-ellipsis' in this case."
370 (let ((tab-name (buffer-name (window-buffer (minibuffer-selected-window))))) 370 (let ((tab-name (buffer-name (window-buffer (minibuffer-selected-window)))))
371 (if (< (length tab-name) tab-bar-tab-name-truncated-max) 371 (if (< (length tab-name) tab-bar-tab-name-truncated-max)
372 tab-name 372 tab-name
373 (propertize (truncate-string-to-width 373 (propertize (truncate-string-to-width
374 tab-name tab-bar-tab-name-truncated-max nil nil 374 tab-name tab-bar-tab-name-truncated-max nil nil
375 tab-bar-tab-name-truncated-ellipsis) 375 tab-bar-tab-name-ellipsis)
376 'help-echo tab-name)))) 376 'help-echo tab-name))))
377 377
378 378
@@ -722,11 +722,14 @@ Interactively, ARG selects the ARGth different frame to move to."
722If `leftmost', create as the first tab. 722If `leftmost', create as the first tab.
723If `left', create to the left from the current tab. 723If `left', create to the left from the current tab.
724If `right', create to the right from the current tab. 724If `right', create to the right from the current tab.
725If `rightmost', create as the last tab." 725If `rightmost', create as the last tab.
726If the value is a function, it should return a number as a position
727on the tab bar specifying where to insert a new tab."
726 :type '(choice (const :tag "First tab" leftmost) 728 :type '(choice (const :tag "First tab" leftmost)
727 (const :tag "To the left" left) 729 (const :tag "To the left" left)
728 (const :tag "To the right" right) 730 (const :tag "To the right" right)
729 (const :tag "Last tab" rightmost)) 731 (const :tag "Last tab" rightmost)
732 (function :tag "Function"))
730 :group 'tab-bar 733 :group 'tab-bar
731 :version "27.1") 734 :version "27.1")
732 735
@@ -773,7 +776,9 @@ After the tab is created, the hooks in
773 ('leftmost 0) 776 ('leftmost 0)
774 ('rightmost (length tabs)) 777 ('rightmost (length tabs))
775 ('left (1- (or from-index 1))) 778 ('left (1- (or from-index 1)))
776 ('right (1+ (or from-index 0))))))) 779 ('right (1+ (or from-index 0)))
780 ((pred functionp)
781 (funcall tab-bar-new-tab-to))))))
777 (setq to-index (max 0 (min (or to-index 0) (length tabs)))) 782 (setq to-index (max 0 (min (or to-index 0) (length tabs))))
778 (cl-pushnew to-tab (nthcdr to-index tabs)) 783 (cl-pushnew to-tab (nthcdr to-index tabs))
779 784
diff --git a/lisp/tab-line.el b/lisp/tab-line.el
index ad4050fec59..149fe8289c4 100644
--- a/lisp/tab-line.el
+++ b/lisp/tab-line.el
@@ -709,7 +709,7 @@ from the tab line."
709 (set-window-prev-buffers nil (assq-delete-all buffer (window-prev-buffers))) 709 (set-window-prev-buffers nil (assq-delete-all buffer (window-prev-buffers)))
710 (set-window-next-buffers nil (delq buffer (window-next-buffers))))) 710 (set-window-next-buffers nil (delq buffer (window-next-buffers)))))
711 ((functionp tab-line-close-tab-function) 711 ((functionp tab-line-close-tab-function)
712 (funcall tab-line-close-tab-function))) 712 (funcall tab-line-close-tab-function tab)))
713 (force-mode-line-update)))) 713 (force-mode-line-update))))
714 714
715 715