bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#52881: setting tab-line-separator to any value breaks clicking tabs


From: Juri Linkov
Subject: bug#52881: setting tab-line-separator to any value breaks clicking tabs with mouse
Date: Thu, 30 Dec 2021 10:05:24 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu)

> This is using Emacs 27.2 on a CentOS8 machine at work. I use Emacs
> exclusively with -nw in a terminal with mouse support enabled.
>
> Using something like
>
> (setq tab-line-separator " | ")
>
> breaks the ability to click on a tab to select it. Leaving it at the
> default value avoids the bug.

Sorry, tab-line had hard-coded assumption on separators
no longer than 1 character wide.

Eli, is it ok to push this patch to the release branch
to support longer separators:

diff --git a/lisp/tab-line.el b/lisp/tab-line.el
index af0647acf7..5eae2eb7c4 100644
--- a/lisp/tab-line.el
+++ b/lisp/tab-line.el
@@ -636,7 +638,10 @@ tab-line-auto-hscroll
                  (not (integerp hscroll)))
         (let ((selected (seq-position strings 'selected
                                       (lambda (str prop)
-                                        (get-pos-property 1 prop str)))))
+                                        (or (get-pos-property 0 prop str)
+                                            (and (next-single-property-change 
0 prop str)
+                                                 (get-pos-property 
(next-single-property-change 0 prop str)
+                                                                   prop 
str)))))))
           (cond
            ((null selected)
             ;; Do nothing if no tab is selected
@@ -656,7 +661,11 @@ tab-line-auto-hscroll
                        (new-hscroll (when tab-prop
                                       (seq-position strings tab-prop
                                                     (lambda (str tab)
-                                                      (eq (get-pos-property 1 
'tab str) tab))))))
+                                                      (eq (or 
(get-pos-property 0 'tab str)
+                                                              (and 
(next-single-property-change 0 'tab str)
+                                                                   
(get-pos-property (next-single-property-change 0 'tab str)
+                                                                               
      'tab str)))
+                                                          tab))))))
                   (when new-hscroll
                     (setq hscroll (float new-hscroll))
                     (set-window-parameter nil 'tab-line-hscroll hscroll)))
@@ -683,7 +692,11 @@ tab-line-auto-hscroll
                        (new-hscroll (when tab-prop
                                       (seq-position strings tab-prop
                                                     (lambda (str tab)
-                                                      (eq (get-pos-property 1 
'tab str) tab))))))
+                                                      (eq (or 
(get-pos-property 0 'tab str)
+                                                              (and 
(next-single-property-change 0 'tab str)
+                                                                   
(get-pos-property (next-single-property-change 0 'tab str)
+                                                                               
      'tab str)))
+                                                          tab))))))
                   (when new-hscroll
                     (setq hscroll (float new-hscroll))
                     (set-window-parameter nil 'tab-line-hscroll 
hscroll)))))))))
@@ -742,7 +755,10 @@ tab-line-select-tab
 using the `previous-buffer' command."
   (interactive "e")
   (let* ((posnp (event-start event))
-         (tab (get-pos-property 1 'tab (car (posn-string posnp))))
+         (tab (or (get-pos-property 0 'tab (car (posn-string posnp)))
+                  (and (next-single-property-change 0 'tab (car (posn-string 
posnp)))
+                       (get-pos-property (next-single-property-change 0 'tab 
(car (posn-string posnp)))
+                                         'tab (car (posn-string posnp))))))
          (buffer (if (bufferp tab) tab (cdr (assq 'buffer tab)))))
     (if buffer
         (tab-line-select-tab-buffer buffer (posn-window posnp))
@@ -858,7 +874,10 @@ tab-line-close-tab
   (interactive (list last-nonmenu-event))
   (let* ((posnp (and (listp event) (event-start event)))
          (window (and posnp (posn-window posnp)))
-         (tab (get-pos-property 1 'tab (car (posn-string posnp))))
+         (tab (or (get-pos-property 0 'tab (car (posn-string posnp)))
+                  (and (next-single-property-change 0 'tab (car (posn-string 
posnp)))
+                       (get-pos-property (next-single-property-change 0 'tab 
(car (posn-string posnp)))
+                                         'tab (car (posn-string posnp))))))
          (buffer (if (bufferp tab) tab (cdr (assq 'buffer tab))))
          (close-function (unless (bufferp tab) (cdr (assq 'close tab)))))
     (with-selected-window (or window (selected-window))

reply via email to

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