unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [patch] two patchs about tab-bar.el
@ 2021-09-10  4:39 tumashu
  2021-09-10  6:33 ` Juri Linkov
  2021-09-10 23:48 ` Feng Shu
  0 siblings, 2 replies; 11+ messages in thread
From: tumashu @ 2021-09-10  4:39 UTC (permalink / raw)
  To: emacs-devel@gnu.org


[-- Attachment #1.1: Type: text/plain, Size: 1 bytes --]



[-- Attachment #1.2: Type: text/html, Size: 111 bytes --]

[-- Attachment #2: 0001-tab-bar-fix-issue-when-current-tab-is-not-at-the-beg.patch --]
[-- Type: application/octet-stream, Size: 1130 bytes --]

From 63ba437acb54fc123b1885de5473345e8b8685f6 Mon Sep 17 00:00:00 2001
From: Feng Shu <tumashu@163.com>
Date: Fri, 10 Sep 2021 12:23:41 +0800
Subject: [PATCH 1/2] tab-bar: fix issue when 'current-tab is not at the
 beginning of tabs.

* lisp/tab-bar.el (tab-bar-get-buffer-tab): Fix issue when
'current-tab is not at the beginning of tabs.
---
 lisp/tab-bar.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index faa155c53f..54fbc04f3f 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -1940,7 +1940,9 @@ tab-bar-get-buffer-tab
                        (member (buffer-name buffer) buffers))))
               (append tab `((index . ,(tab-bar--tab-index tab nil frame))
                             (frame . ,frame)))))
-          (funcall tab-bar-tabs-function frame)))
+          (let ((tabs (funcall tab-bar-tabs-function frame)))
+            ;; Make sure current-tab is alway at the beginning of tabs.
+            (push (assq 'current-tab tabs) tabs))))
        (tab-bar--reusable-frames all-frames)))))
 
 (defun display-buffer-in-tab (buffer alist)
-- 
2.30.2


[-- Attachment #3: 0002-lisp-tab-bar.el-display-buffer-in-tab-Improve-docstr.patch --]
[-- Type: application/octet-stream, Size: 993 bytes --]

From 779dc12d680cd62a5f6da378f9e8bdcebd5602df Mon Sep 17 00:00:00 2001
From: Feng Shu <tumashu@163.com>
Date: Fri, 10 Sep 2021 12:35:37 +0800
Subject: [PATCH 2/2] * lisp/tab-bar.el (display-buffer-in-tab): Improve
 docstring.

---
 lisp/tab-bar.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index 54fbc04f3f..451af70f01 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -1962,11 +1962,12 @@ display-buffer-in-tab
 
 If ALIST contains a `reusable-frames' entry, its value determines
 which frames to search for a reusable tab:
-  nil -- the selected frame (actually the last non-minibuffer frame)
+  nil -- do not reuse any frames.
   A frame   -- just that frame
   `visible' -- all visible frames
   0   -- all frames on the current terminal
   t   -- all frames.
+  others -- selected frame.
 
 This is an action function for buffer display, see Info
 node `(elisp) Buffer Display Action Functions'.  It should be
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [patch] two patchs about tab-bar.el
  2021-09-10  4:39 [patch] two patchs about tab-bar.el tumashu
@ 2021-09-10  6:33 ` Juri Linkov
  2021-09-10 13:18   ` tumashu
                     ` (3 more replies)
  2021-09-10 23:48 ` Feng Shu
  1 sibling, 4 replies; 11+ messages in thread
From: Juri Linkov @ 2021-09-10  6:33 UTC (permalink / raw)
  To: tumashu; +Cc: emacs-devel@gnu.org

> * lisp/tab-bar.el (tab-bar-get-buffer-tab): Fix issue when
> 'current-tab is not at the beginning of tabs.
>
> --- a/lisp/tab-bar.el
> +++ b/lisp/tab-bar.el
> @@ -1940,7 +1940,9 @@ tab-bar-get-buffer-tab
> -          (funcall tab-bar-tabs-function frame)))
> +          (let ((tabs (funcall tab-bar-tabs-function frame)))
> +            ;; Make sure current-tab is alway at the beginning of tabs.
> +            (push (assq 'current-tab tabs) tabs))))

Please explain what problem this patch is intended to fix.

> --- a/lisp/tab-bar.el
> +++ b/lisp/tab-bar.el
> @@ -1962,11 +1962,12 @@ display-buffer-in-tab
>
>  If ALIST contains a `reusable-frames' entry, its value determines
>  which frames to search for a reusable tab:
> -  nil -- the selected frame (actually the last non-minibuffer frame)
> +  nil -- do not reuse any frames.
>    A frame   -- just that frame
>    `visible' -- all visible frames
>    0   -- all frames on the current terminal
>    t   -- all frames.
> +  others -- selected frame.

I wonder where did you get the value 'others' that means the selected frame?



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re:Re: [patch] two patchs about tab-bar.el
  2021-09-10  6:33 ` Juri Linkov
@ 2021-09-10 13:18   ` tumashu
  2021-09-10 13:24   ` tumashu
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 11+ messages in thread
From: tumashu @ 2021-09-10 13:18 UTC (permalink / raw)
  To: Juri Linkov; +Cc: emacs-devel@gnu.org

















At 2021-09-10 14:33:48, "Juri Linkov" <juri@linkov.net> wrote:
>> * lisp/tab-bar.el (tab-bar-get-buffer-tab): Fix issue when
>> 'current-tab is not at the beginning of tabs.
>>
>> --- a/lisp/tab-bar.el
>> +++ b/lisp/tab-bar.el
>> @@ -1940,7 +1940,9 @@ tab-bar-get-buffer-tab
>> -          (funcall tab-bar-tabs-function frame)))
>> +          (let ((tabs (funcall tab-bar-tabs-function frame)))
>> +            ;; Make sure current-tab is alway at the beginning of tabs.
>> +            (push (assq 'current-tab tabs) tabs))))
>
>Please explain what problem this patch is intended to fix.

I have two tabs:

      1. *scratch*  2. *scratch*, *Messages*

and current-tab is 2

 if I switch-to-buffer *scratch*, it will jump to tab 1, instead of to jump to window '*scratch*' in current tab.
for the current-tab is not at the begin of tabs.

(cl-prettyprint (tab-bar-tabs))
((tab (name . "*scratch*")
      (explicit-name)
      (time . 1631279460.570877)
      (ws ((min-height . 4)
           (min-width . 10)
           (min-height-ignore . 3)
           (min-width-ignore . 4)
           (min-height-safe . 1)
           (min-width-safe . 2)
           (min-pixel-height . 92)
           (min-pixel-width . 100)
           (min-pixel-height-ignore . 69)
           (min-pixel-width-ignore . 40)
           (min-pixel-height-safe . 23)
           (min-pixel-width-safe . 20))
          leaf
          (pixel-width . 1366)
          (pixel-height . 663)
          (total-width . 137)
          (total-height . 28)
          (normal-height . 1.0)
          (normal-width . 1.0)
          (buffer "*scratch*"
                  (selected . t)
                  (hscroll . 0)
                  (fringes 8 8 nil nil)
                  (margins nil)
                  (scroll-bars nil 0 t nil 0 t nil)
                  (vscroll . 0)
                  (dedicated)
                  (point . 1)
                  (start . 1)))
      (wc . #<window-configuration>)
      (wc-point . #<marker at 1 in *scratch*>)
      (wc-bl #<buffer *scratch*> #<buffer  *Minibuf-1*>)
      (wc-bbl)
      (wc-history-back ((wc . #<window-configuration>)
                        (wc-point . #<marker at 1 in *scratch*>))
                       ((wc . #<window-configuration>)
                        (wc-point . #<marker at 1 in *scratch*>)))
      (wc-history-forward))
 (current-tab (name . "*scratch*, *Messages*") (explicit-name)))




>
>> --- a/lisp/tab-bar.el
>> +++ b/lisp/tab-bar.el
>> @@ -1962,11 +1962,12 @@ display-buffer-in-tab
>>
>>  If ALIST contains a `reusable-frames' entry, its value determines
>>  which frames to search for a reusable tab:
>> -  nil -- the selected frame (actually the last non-minibuffer frame)
>> +  nil -- do not reuse any frames.
>>    A frame   -- just that frame
>>    `visible' -- all visible frames
>>    0   -- all frames on the current terminal
>>    t   -- all frames.
>> +  others -- selected frame.
>
>I wonder where did you get the value 'others' that means the selected frame?


(defun tab-bar--reusable-frames (all-frames)
  (cond
   ((eq all-frames t) (frame-list))
   ((eq all-frames 'visible) (visible-frame-list))
   ((framep all-frames) (list all-frames))
   (t (list (selected-frame)))))
             ^^^^^^^^^^^^^^

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re:Re: [patch] two patchs about tab-bar.el
  2021-09-10  6:33 ` Juri Linkov
  2021-09-10 13:18   ` tumashu
@ 2021-09-10 13:24   ` tumashu
  2021-09-10 13:36   ` tumashu
  2021-09-10 18:33   ` tumashu
  3 siblings, 0 replies; 11+ messages in thread
From: tumashu @ 2021-09-10 13:24 UTC (permalink / raw)
  To: Juri Linkov; +Cc: emacs-devel@gnu.org

















At 2021-09-10 14:33:48, "Juri Linkov" <juri@linkov.net> wrote:
>> * lisp/tab-bar.el (tab-bar-get-buffer-tab): Fix issue when
>> 'current-tab is not at the beginning of tabs.
>>
>> --- a/lisp/tab-bar.el
>> +++ b/lisp/tab-bar.el
>> @@ -1940,7 +1940,9 @@ tab-bar-get-buffer-tab
>> -          (funcall tab-bar-tabs-function frame)))
>> +          (let ((tabs (funcall tab-bar-tabs-function frame)))
>> +            ;; Make sure current-tab is alway at the beginning of tabs.
>> +            (push (assq 'current-tab tabs) tabs))))
>
>Please explain what problem this patch is intended to fix.


I have two tabs:

1. *scratch*  2. *scratch*, *Messages*

and current-tab is 2

if I switch-to-buffer *scratch*, it will switch to tab 1, instead of jump to window '*scratch*' in current tab.

for current-tab is not at the beginning of tabs.


(cl-prettyprint (tab-bar-tabs))
((tab (name . "*scratch*")
      (explicit-name)
      (time . 1631279460.570877)
      (ws ((min-height . 4)
           (min-width . 10)
           (min-height-ignore . 3)
           (min-width-ignore . 4)
           (min-height-safe . 1)
           (min-width-safe . 2)
           (min-pixel-height . 92)
           (min-pixel-width . 100)
           (min-pixel-height-ignore . 69)
           (min-pixel-width-ignore . 40)
           (min-pixel-height-safe . 23)
           (min-pixel-width-safe . 20))
          leaf
          (pixel-width . 1366)
          (pixel-height . 663)
          (total-width . 137)
          (total-height . 28)
          (normal-height . 1.0)
          (normal-width . 1.0)
          (buffer "*scratch*"
                  (selected . t)
                  (hscroll . 0)
                  (fringes 8 8 nil nil)
                  (margins nil)
                  (scroll-bars nil 0 t nil 0 t nil)
                  (vscroll . 0)
                  (dedicated)
                  (point . 1)
                  (start . 1)))
      (wc . #<window-configuration>)
      (wc-point . #<marker at 1 in *scratch*>)
      (wc-bl #<buffer *scratch*> #<buffer  *Minibuf-1*>)
      (wc-bbl)
      (wc-history-back ((wc . #<window-configuration>)
                        (wc-point . #<marker at 1 in *scratch*>))
                       ((wc . #<window-configuration>)
                        (wc-point . #<marker at 1 in *scratch*>)))
      (wc-history-forward))
 (current-tab (name . "*scratch*, *Messages*") (explicit-name)))


>
>> --- a/lisp/tab-bar.el
>> +++ b/lisp/tab-bar.el
>> @@ -1962,11 +1962,12 @@ display-buffer-in-tab
>>
>>  If ALIST contains a `reusable-frames' entry, its value determines
>>  which frames to search for a reusable tab:
>> -  nil -- the selected frame (actually the last non-minibuffer frame)
>> +  nil -- do not reuse any frames.
>>    A frame   -- just that frame
>>    `visible' -- all visible frames
>>    0   -- all frames on the current terminal
>>    t   -- all frames.
>> +  others -- selected frame.
>
>I wonder where did you get the value 'others' that means the selected frame?

(defun tab-bar--reusable-frames (all-frames)
  (cond
   ((eq all-frames t) (frame-list))
   ((eq all-frames 'visible) (visible-frame-list))
   ((framep all-frames) (list all-frames))
   (t (list (selected-frame)))))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re:Re: [patch] two patchs about tab-bar.el
  2021-09-10  6:33 ` Juri Linkov
  2021-09-10 13:18   ` tumashu
  2021-09-10 13:24   ` tumashu
@ 2021-09-10 13:36   ` tumashu
  2021-09-10 16:17     ` Juri Linkov
  2021-09-10 18:33   ` tumashu
  3 siblings, 1 reply; 11+ messages in thread
From: tumashu @ 2021-09-10 13:36 UTC (permalink / raw)
  To: Juri Linkov; +Cc: emacs-devel@gnu.org



At 2021-09-10 14:33:48, "Juri Linkov" <juri@linkov.net> wrote:
>> * lisp/tab-bar.el (tab-bar-get-buffer-tab): Fix issue when
>> 'current-tab is not at the beginning of tabs.
>>
>> --- a/lisp/tab-bar.el
>> +++ b/lisp/tab-bar.el
>> @@ -1940,7 +1940,9 @@ tab-bar-get-buffer-tab
>> -          (funcall tab-bar-tabs-function frame)))
>> +          (let ((tabs (funcall tab-bar-tabs-function frame)))
>> +            ;; Make sure current-tab is alway at the beginning of tabs.
>> +            (push (assq 'current-tab tabs) tabs))))
>
>Please explain what problem this patch is intended to fix.


I have two tabs:

1. *scratch*  2. *scratch*, *Messages*

and current-tab is 2

if I switch-to-buffer *scratch*, it will switch to tab 1, instead of jump to window '*scratch*' in current tab.

for current-tab is not at the beginning of tabs.


(cl-prettyprint (tab-bar-tabs))
((tab (name . "*scratch*")
      (explicit-name)
      (time . 1631279460.570877)
      (ws ((min-height . 4)
           (min-width . 10)
           (min-height-ignore . 3)
           (min-width-ignore . 4)
           (min-height-safe . 1)
           (min-width-safe . 2)
           (min-pixel-height . 92)
           (min-pixel-width . 100)
           (min-pixel-height-ignore . 69)
           (min-pixel-width-ignore . 40)
           (min-pixel-height-safe . 23)
           (min-pixel-width-safe . 20))
          leaf
          (pixel-width . 1366)
          (pixel-height . 663)
          (total-width . 137)
          (total-height . 28)
          (normal-height . 1.0)
          (normal-width . 1.0)
          (buffer "*scratch*"
                  (selected . t)
                  (hscroll . 0)
                  (fringes 8 8 nil nil)
                  (margins nil)
                  (scroll-bars nil 0 t nil 0 t nil)
                  (vscroll . 0)
                  (dedicated)
                  (point . 1)
                  (start . 1)))
      (wc . #<window-configuration>)
      (wc-point . #<marker at 1 in *scratch*>)
      (wc-bl #<buffer *scratch*> #<buffer  *Minibuf-1*>)
      (wc-bbl)
      (wc-history-back ((wc . #<window-configuration>)
                        (wc-point . #<marker at 1 in *scratch*>))
                       ((wc . #<window-configuration>)
                        (wc-point . #<marker at 1 in *scratch*>)))
      (wc-history-forward))
 (current-tab (name . "*scratch*, *Messages*") (explicit-name)))



>
>> --- a/lisp/tab-bar.el
>> +++ b/lisp/tab-bar.el
>> @@ -1962,11 +1962,12 @@ display-buffer-in-tab
>>
>>  If ALIST contains a `reusable-frames' entry, its value determines
>>  which frames to search for a reusable tab:
>> -  nil -- the selected frame (actually the last non-minibuffer frame)
>> +  nil -- do not reuse any frames.
>>    A frame   -- just that frame
>>    `visible' -- all visible frames
>>    0   -- all frames on the current terminal
>>    t   -- all frames.
>> +  others -- selected frame.
>
>I wonder where did you get the value 'others' that means the selected frame?


(defun tab-bar--reusable-frames (all-frames)
  (cond
   ((eq all-frames t) (frame-list))
   ((eq all-frames 'visible) (visible-frame-list))
   ((framep all-frames) (list all-frames))
   (t (list (selected-frame)))))


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [patch] two patchs about tab-bar.el
  2021-09-10 13:36   ` tumashu
@ 2021-09-10 16:17     ` Juri Linkov
  0 siblings, 0 replies; 11+ messages in thread
From: Juri Linkov @ 2021-09-10 16:17 UTC (permalink / raw)
  To: tumashu; +Cc: emacs-devel@gnu.org

> I have two tabs:
>
> 1. *scratch*  2. *scratch*, *Messages*
>
> and current-tab is 2
>
> if I switch-to-buffer *scratch*, it will switch to tab 1, instead of
> jump to window '*scratch*' in current tab.
>
> for current-tab is not at the beginning of tabs.

Please send your customized settings related to tab-bar.
I see that you set 'tab-bar-tab-name-function' to 'tab-bar-tab-name-all'.
What other tab-bar customization do you have that causes buffer-switching
also select another tab?  Is it something in display-buffer-alist
that is customized to use display-buffer-in-tab?

>>>  If ALIST contains a `reusable-frames' entry, its value determines
>>>  which frames to search for a reusable tab:
>>> -  nil -- the selected frame (actually the last non-minibuffer frame)
>>> +  nil -- do not reuse any frames.
>>>    A frame   -- just that frame
>>>    `visible' -- all visible frames
>>>    0   -- all frames on the current terminal
>>>    t   -- all frames.
>>> +  others -- selected frame.
>>
>> I wonder where did you get the value 'others' that means the selected frame?
>
> (defun tab-bar--reusable-frames (all-frames)
>   (cond
>    ((eq all-frames t) (frame-list))
>    ((eq all-frames 'visible) (visible-frame-list))
>    ((framep all-frames) (list all-frames))
>    (t (list (selected-frame)))))

Thanks, I thought that `others' is a symbol because is looks like `visible'.
If you meant that all other values affect the selected frame, then better
to use such wording: "other non-nil values".



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re:Re: [patch] two patchs about tab-bar.el
  2021-09-10  6:33 ` Juri Linkov
                     ` (2 preceding siblings ...)
  2021-09-10 13:36   ` tumashu
@ 2021-09-10 18:33   ` tumashu
  2021-09-12  7:03     ` Juri Linkov
  3 siblings, 1 reply; 11+ messages in thread
From: tumashu @ 2021-09-10 18:33 UTC (permalink / raw)
  To: Juri Linkov; +Cc: emacs-devel@gnu.org

This is my tab-bar config

---------------------------------------------------------------------

;; ** buffer 显示方式
(setq switch-to-buffer-obey-display-actions t)
(setq display-buffer-alist
      '((eh-display-buffer-in-tab-p
         display-buffer-in-tab
         (reusable-frames . visible))))

(defun eh-display-buffer-in-tab-p (buffer-name alist)
  (with-current-buffer (get-buffer buffer-name)
    (and
     ;; Minibuffer.
     (not (minibufferp buffer-name))
     ;; Python, Term 等 buffer.
     (not (derived-mode-p 'comint-mode))
     (not (derived-mode-p 'term-mode))
     ;; magit 相关 buffer
     (not (string-match-p "magit" buffer-name))
     (not (string-match-p "COMMIT_EDITMSG" buffer-name))
     ;; gnus 相关 buffer
     (not (derived-mode-p 'gnus-article-mode))
     ;; 隐藏的 buffer
     (not (string-match-p "^ +" buffer-name)))))

;; ** 开启 tab-bar
(tab-bar-mode 1)
(tab-bar-history-mode 1)
(global-set-key (kbd "C-t") 'tab-bar-switch-to-recent-tab)
(global-set-key (kbd "C-c t") 'tab-switcher)
(setq tab-bar-format
      '(tab-bar-format-tabs
        tab-bar-separator))
(setq tab-bar-separator " ")
(setq tab-bar-tab-hints t)
(setq tab-bar-close-button-show 'selected)
(setq tab-bar-tab-name-function
      #'eh-tab-bar-tab-name)

(defun eh-tab-bar-tab-name ()
  (mapconcat (lambda (buf)
               (let ((tab-name (buffer-name buf))
                     (length 20))
                 (if (< (string-width tab-name) length)
                     tab-name
                   (propertize (truncate-string-to-width
                                tab-name length nil nil
                                tab-bar-tab-name-ellipsis)
                               'help-echo tab-name))))
             (delete-dups (mapcar #'window-buffer
                                  (window-list-1 (frame-first-window)
                                                 'nomini)))
             ", "))

(defun eh-tab-bar-rename-tab ()
  (tab-bar-rename-tab ""))

(add-hook 'window-configuration-change-hook #'eh-tab-bar-rename-tab)
(add-hook 'buffer-list-update-hook #'eh-tab-bar-rename-tab)

(setq tab-bar-tab-name-format-function
      #'eh-tab-bar-tab-name-format-default)

(defun eh-tab-bar-tab-name-format-default (tab i)
  (let ((current-p (eq (car tab) 'current-tab)))
    (propertize
     (concat (if tab-bar-tab-hints (format "[%d] " i) "")
             (alist-get 'name tab)
             (or (and tab-bar-close-button-show
                      (not (eq tab-bar-close-button-show
                               (if current-p 'non-selected 'selected)))
                      tab-bar-close-button)
                 ""))
     'face (funcall tab-bar-tab-face-function tab))))

(defun eh-buffer-used-by-org-agenda-p (buffer)
  (and (get-buffer "*Org Agenda*")
       (with-current-buffer buffer
         (and (derived-mode-p 'org-mode)
              (member (buffer-file-name)
                      (org-agenda-files))))))

(defun eh-kill-buffer (buffer)
  (interactive)
  (let ((buffer-name (buffer-name buffer)))
    (cond
     ((equal buffer-name "*scratch*")
      (message "NOTE: do not kill *scratch* buffer."))
     ((eh-buffer-used-by-org-agenda-p buffer)
      (message "NOTE: buffer %S is used by org-agenda, do not kill it." buffer-name))
     ((tab-bar-get-buffer-tab buffer t t)
      (message "Warn: buffer %S has been managed by other tab, do not kill it." buffer-name))
     (t (message "Kill buffer %S." buffer-name)
        (kill-buffer buffer)))))

(defun eh-tab-bar-close-tab (orig-func &rest args)
  (interactive)
  (let* ((use-dialog-box t)
         (n (length (window-list)))
         (buffers (mapcar #'window-buffer (window-list)))
         (tabs (funcall tab-bar-tabs-function))
         (current-index (tab-bar--current-tab-index tabs))
         (close-index (when (integerp (car args)) (1- (car args)))))
    (if (or (not close-index)
            (eq close-index current-index))
        ;; 如果要关闭的 tab 是 current tab, 就将 buffer 也删除。
        (progn
          (cond ((memq this-command
                       '(tab-bar-close-tab
                         tab-close))
                 (eh-kill-buffer (current-buffer)))
                ((memq this-command
                       '(tab-bar-mouse-close-tab
                         tab-bar-mouse-select-tab))
                 (dolist (buffer buffers)
                   (eh-kill-buffer buffer)))
                (t (message "Note: do not kill any buffer.")))
          (let ((tab-bar-close-last-tab-choice
                 `(@,tab-bar-close-last-tab-choice eh-tab-bar-rename-tab)))
            (if (and (equal this-command 'tab-bar-close-tab)
                     (> n 1))
                (funcall-interactively #'delete-window)
              (apply orig-func args))))
      ;; 如果删除的 tab 不是 current tab, 就不删除任何 buffer.
      (apply orig-func args))))

(advice-add 'tab-bar-close-tab :around #'eh-tab-bar-close-tab)

(global-set-key (kbd "C-x k") 'tab-bar-close-tab)

















At 2021-09-10 14:33:48, "Juri Linkov" <juri@linkov.net> wrote:
>> * lisp/tab-bar.el (tab-bar-get-buffer-tab): Fix issue when
>> 'current-tab is not at the beginning of tabs.
>>
>> --- a/lisp/tab-bar.el
>> +++ b/lisp/tab-bar.el
>> @@ -1940,7 +1940,9 @@ tab-bar-get-buffer-tab
>> -          (funcall tab-bar-tabs-function frame)))
>> +          (let ((tabs (funcall tab-bar-tabs-function frame)))
>> +            ;; Make sure current-tab is alway at the beginning of tabs.
>> +            (push (assq 'current-tab tabs) tabs))))
>
>Please explain what problem this patch is intended to fix.
>
>> --- a/lisp/tab-bar.el
>> +++ b/lisp/tab-bar.el
>> @@ -1962,11 +1962,12 @@ display-buffer-in-tab
>>
>>  If ALIST contains a `reusable-frames' entry, its value determines
>>  which frames to search for a reusable tab:
>> -  nil -- the selected frame (actually the last non-minibuffer frame)
>> +  nil -- do not reuse any frames.
>>    A frame   -- just that frame
>>    `visible' -- all visible frames
>>    0   -- all frames on the current terminal
>>    t   -- all frames.
>> +  others -- selected frame.
>
>I wonder where did you get the value 'others' that means the selected frame?

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [patch] two patchs about tab-bar.el
  2021-09-10  4:39 [patch] two patchs about tab-bar.el tumashu
  2021-09-10  6:33 ` Juri Linkov
@ 2021-09-10 23:48 ` Feng Shu
  1 sibling, 0 replies; 11+ messages in thread
From: Feng Shu @ 2021-09-10 23:48 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 92 bytes --]

tumashu <tumashu@163.com> writes:

I have update patch 2,  other -> other non-nil values.



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0002-lisp-tab-bar.el-display-buffer-in-tab-Improve-docstr.patch --]
[-- Type: text/x-diff, Size: 1008 bytes --]

From cd58cec7af8260afe5d61770260a49c55227679c Mon Sep 17 00:00:00 2001
From: Feng Shu <tumashu@163.com>
Date: Fri, 10 Sep 2021 12:35:37 +0800
Subject: [PATCH 2/2] * lisp/tab-bar.el (display-buffer-in-tab): Improve
 docstring.

---
 lisp/tab-bar.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index a4a7b4cb65..5f3e415435 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -1955,11 +1955,12 @@ display-buffer-in-tab
 
 If ALIST contains a `reusable-frames' entry, its value determines
 which frames to search for a reusable tab:
-  nil -- the selected frame (actually the last non-minibuffer frame)
+  nil -- do not reuse any frames.
   A frame   -- just that frame
   `visible' -- all visible frames
   0   -- all frames on the current terminal
   t   -- all frames.
+  other non-nil values  -- selected frame.
 
 This is an action function for buffer display, see Info
 node `(elisp) Buffer Display Action Functions'.  It should be
-- 
2.30.2


[-- Attachment #3: Type: text/plain, Size: 7 bytes --]




-- 

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [patch] two patchs about tab-bar.el
  2021-09-10 18:33   ` tumashu
@ 2021-09-12  7:03     ` Juri Linkov
  2021-09-12  9:34       ` tumashu
  0 siblings, 1 reply; 11+ messages in thread
From: Juri Linkov @ 2021-09-12  7:03 UTC (permalink / raw)
  To: tumashu; +Cc: emacs-devel

> This is my tab-bar config
>
> (setq display-buffer-alist
>       '((eh-display-buffer-in-tab-p
>          display-buffer-in-tab
>          (reusable-frames . visible))))

Thanks, now everything is clear.  Then we need to decide
what alist parameters should define your preference
of using the current tab.  One possible new parameter
could be 'prefer-current-tab':

  (setq display-buffer-alist
        '((eh-display-buffer-in-tab-p
           display-buffer-in-tab
           (reusable-frames . visible)
           (prefer-current-tab . t))))

But 'tab-bar-get-buffer-tab' already has argument 'ignore-current-tab'
that could be used to implement what you want.  Then if someone doesn't want
to prefer the current tab, this can be configured with:

  (setq display-buffer-alist
        '((eh-display-buffer-in-tab-p
           display-buffer-in-tab
           (reusable-frames . visible)
           (ignore-current-tab . t))))

So I propose to use the existing argument 'ignore-current-tab'
with these meanings of its values:

- nil: prefer the current tab;
- t: ignore the current tab.

Do you agree?



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re:Re: [patch] two patchs about tab-bar.el
  2021-09-12  7:03     ` Juri Linkov
@ 2021-09-12  9:34       ` tumashu
  2021-09-12 16:10         ` Juri Linkov
  0 siblings, 1 reply; 11+ messages in thread
From: tumashu @ 2021-09-12  9:34 UTC (permalink / raw)
  To: Juri Linkov; +Cc: emacs-devel@gnu.org


















At 2021-09-12 15:03:04, "Juri Linkov" <juri@linkov.net> wrote:
>> This is my tab-bar config
>>
>> (setq display-buffer-alist
>>       '((eh-display-buffer-in-tab-p
>>          display-buffer-in-tab
>>          (reusable-frames . visible))))
>
>Thanks, now everything is clear.  Then we need to decide
>what alist parameters should define your preference
>of using the current tab.  One possible new parameter
>could be 'prefer-current-tab':
>
>  (setq display-buffer-alist
>        '((eh-display-buffer-in-tab-p
>           display-buffer-in-tab
>           (reusable-frames . visible)
>           (prefer-current-tab . t))))
>
>But 'tab-bar-get-buffer-tab' already has argument 'ignore-current-tab'
>that could be used to implement what you want.  Then if someone doesn't want
>to prefer the current tab, this can be configured with:
>
>  (setq display-buffer-alist
>        '((eh-display-buffer-in-tab-p
>           display-buffer-in-tab
>           (reusable-frames . visible)
>           (ignore-current-tab . t))))
>
>So I propose to use the existing argument 'ignore-current-tab'
>with these meanings of its values:
>
>- nil: prefer the current tab;
>- t: ignore the current tab.
>
>Do you agree?

agree





^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [patch] two patchs about tab-bar.el
  2021-09-12  9:34       ` tumashu
@ 2021-09-12 16:10         ` Juri Linkov
  0 siblings, 0 replies; 11+ messages in thread
From: Juri Linkov @ 2021-09-12 16:10 UTC (permalink / raw)
  To: tumashu; +Cc: emacs-devel@gnu.org

>>So I propose to use the existing argument 'ignore-current-tab'
>>with these meanings of its values:
>>
>>- nil: prefer the current tab;
>>- t: ignore the current tab.
>>
>>Do you agree?
>
> agree

Thanks for the suggestion, now pushed to master.
For more requests, please use bug-gnu-emacs@gnu.org.



^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-09-12 16:10 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-10  4:39 [patch] two patchs about tab-bar.el tumashu
2021-09-10  6:33 ` Juri Linkov
2021-09-10 13:18   ` tumashu
2021-09-10 13:24   ` tumashu
2021-09-10 13:36   ` tumashu
2021-09-10 16:17     ` Juri Linkov
2021-09-10 18:33   ` tumashu
2021-09-12  7:03     ` Juri Linkov
2021-09-12  9:34       ` tumashu
2021-09-12 16:10         ` Juri Linkov
2021-09-10 23:48 ` Feng Shu

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).