GNU bug report logs - #52881
setting tab-line-separator to any value breaks clicking tabs with mouse

Previous Next

Package: emacs;

Reported by: Ben Sferrazza <ben.sferrazza <at> aeonsemi.com>

Date: Wed, 29 Dec 2021 22:14:01 UTC

Severity: normal

Fixed in version 28.0.90

Done: Juri Linkov <juri <at> linkov.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 52881 in the body.
You can then email your comments to 52881 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#52881; Package emacs. (Wed, 29 Dec 2021 22:14:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ben Sferrazza <ben.sferrazza <at> aeonsemi.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 29 Dec 2021 22:14:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ben Sferrazza <ben.sferrazza <at> aeonsemi.com>
To: "bug-gnu-emacs <at> gnu.org" <bug-gnu-emacs <at> gnu.org>
Subject: setting tab-line-separator to any value breaks clicking tabs with
 mouse
Date: Wed, 29 Dec 2021 21:47:27 +0000
[Message part 1 (text/plain, inline)]
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.

Thanks,
Ben
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#52881; Package emacs. (Thu, 30 Dec 2021 08:11:02 GMT) Full text and rfc822 format available.

Message #8 received at 52881 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Ben Sferrazza <ben.sferrazza <at> aeonsemi.com>
Cc: 52881 <at> debbugs.gnu.org
Subject: Re: bug#52881: setting tab-line-separator to any value breaks
 clicking tabs with mouse
Date: Thu, 30 Dec 2021 10:05:24 +0200
[Message part 1 (text/plain, inline)]
> 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:

[tab-line-separator.patch (text/x-diff, inline)]
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))

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#52881; Package emacs. (Thu, 30 Dec 2021 08:45:01 GMT) Full text and rfc822 format available.

Message #11 received at 52881 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: 52881 <at> debbugs.gnu.org, ben.sferrazza <at> aeonsemi.com
Subject: Re: bug#52881: setting tab-line-separator to any value breaks clicking
 tabs with mouse
Date: Thu, 30 Dec 2021 10:44:08 +0200
> From: Juri Linkov <juri <at> linkov.net>
> Date: Thu, 30 Dec 2021 10:05:24 +0200
> Cc: 52881 <at> debbugs.gnu.org
> 
> > 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:

Yes, but can you make it a bit cleaner?  Like having a single function
to do that, and also not calling next-single-property-change twice an
a row?

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#52881; Package emacs. (Thu, 30 Dec 2021 16:12:01 GMT) Full text and rfc822 format available.

Message #14 received at 52881 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 52881 <at> debbugs.gnu.org, ben.sferrazza <at> aeonsemi.com
Subject: Re: bug#52881: setting tab-line-separator to any value breaks
 clicking tabs with mouse
Date: Thu, 30 Dec 2021 18:08:12 +0200
>> Eli, is it ok to push this patch to the release branch
>> to support longer separators:
>
> Yes, but can you make it a bit cleaner?  Like having a single function
> to do that, and also not calling next-single-property-change twice an
> a row?

I could optimize this, but I wonder why there is no simple function
to find a text property and its first value in the string?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#52881; Package emacs. (Thu, 30 Dec 2021 16:44:02 GMT) Full text and rfc822 format available.

Message #17 received at 52881 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: 52881 <at> debbugs.gnu.org, ben.sferrazza <at> aeonsemi.com
Subject: Re: bug#52881: setting tab-line-separator to any value breaks
 clicking tabs with mouse
Date: Thu, 30 Dec 2021 18:43:57 +0200
> From: Juri Linkov <juri <at> linkov.net>
> Cc: ben.sferrazza <at> aeonsemi.com,  52881 <at> debbugs.gnu.org
> Date: Thu, 30 Dec 2021 18:08:12 +0200
> 
> >> Eli, is it ok to push this patch to the release branch
> >> to support longer separators:
> >
> > Yes, but can you make it a bit cleaner?  Like having a single function
> > to do that, and also not calling next-single-property-change twice an
> > a row?
> 
> I could optimize this, but I wonder why there is no simple function
> to find a text property and its first value in the string?

I don't know.  We could add something like that, but that would not be
for the release branch.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#52881; Package emacs. (Fri, 31 Dec 2021 09:23:01 GMT) Full text and rfc822 format available.

Message #20 received at 52881 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 52881 <at> debbugs.gnu.org, ben.sferrazza <at> aeonsemi.com
Subject: Re: bug#52881: setting tab-line-separator to any value breaks
 clicking tabs with mouse
Date: Fri, 31 Dec 2021 11:21:22 +0200
close 52881 28.0.90
quit

>> >> Eli, is it ok to push this patch to the release branch
>> >> to support longer separators:
>> >
>> > Yes, but can you make it a bit cleaner?  Like having a single function
>> > to do that, and also not calling next-single-property-change twice an
>> > a row?
>> 
>> I could optimize this, but I wonder why there is no simple function
>> to find a text property and its first value in the string?
>
> I don't know.  We could add something like that, but that would not be
> for the release branch.

Now fixed in Emacs 28 with an internal function.




bug marked as fixed in version 28.0.90, send any further explanations to 52881 <at> debbugs.gnu.org and Ben Sferrazza <ben.sferrazza <at> aeonsemi.com> Request was from Juri Linkov <juri <at> linkov.net> to control <at> debbugs.gnu.org. (Fri, 31 Dec 2021 09:23:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#52881; Package emacs. (Sun, 02 Jan 2022 18:06:02 GMT) Full text and rfc822 format available.

Message #25 received at 52881 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 52881 <at> debbugs.gnu.org, ben.sferrazza <at> aeonsemi.com
Subject: Re: bug#52881: setting tab-line-separator to any value breaks
 clicking tabs with mouse
Date: Sun, 02 Jan 2022 20:04:15 +0200
>>> >> Eli, is it ok to push this patch to the release branch
>>> >> to support longer separators:
>>> >
>>> > Yes, but can you make it a bit cleaner?  Like having a single function
>>> > to do that, and also not calling next-single-property-change twice an
>>> > a row?
>>>
>>> I could optimize this, but I wonder why there is no simple function
>>> to find a text property and its first value in the string?
>>
>> I don't know.  We could add something like that, but that would not be
>> for the release branch.
>
> Now fixed in Emacs 28 with an internal function.

Oh no, 'get-text-property' can't replace 'get-pos-property'
because it fails after 'previous-single-property-change':

  (progn
    (insert (concat "(" (propertize "1" 'tab 1) ")"))
    (let ((pos (previous-single-property-change (point) 'tab)))
      (cons (get-text-property pos 'tab)
            (get-pos-property pos 'tab))))

in *scratch* it returns (nil . 1).  So now the recent fix was fixed on emacs-28.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 31 Jan 2022 12:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 78 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.