unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#52881: setting tab-line-separator to any value breaks clicking tabs with mouse
@ 2021-12-29 21:47 Ben Sferrazza
  2021-12-30  8:05 ` Juri Linkov
  0 siblings, 1 reply; 7+ messages in thread
From: Ben Sferrazza @ 2021-12-29 21:47 UTC (permalink / raw)
  To: 52881

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

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

[-- Attachment #2: Type: text/html, Size: 2154 bytes --]

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

* bug#52881: setting tab-line-separator to any value breaks clicking tabs with mouse
  2021-12-29 21:47 bug#52881: setting tab-line-separator to any value breaks clicking tabs with mouse Ben Sferrazza
@ 2021-12-30  8:05 ` Juri Linkov
  2021-12-30  8:44   ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Juri Linkov @ 2021-12-30  8:05 UTC (permalink / raw)
  To: Ben Sferrazza; +Cc: 52881

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

> 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:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: tab-line-separator.patch --]
[-- Type: text/x-diff, Size: 4363 bytes --]

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))

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

* bug#52881: setting tab-line-separator to any value breaks clicking tabs with mouse
  2021-12-30  8:05 ` Juri Linkov
@ 2021-12-30  8:44   ` Eli Zaretskii
  2021-12-30 16:08     ` Juri Linkov
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2021-12-30  8:44 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 52881, ben.sferrazza

> From: Juri Linkov <juri@linkov.net>
> Date: Thu, 30 Dec 2021 10:05:24 +0200
> Cc: 52881@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.





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

* bug#52881: setting tab-line-separator to any value breaks clicking tabs with mouse
  2021-12-30  8:44   ` Eli Zaretskii
@ 2021-12-30 16:08     ` Juri Linkov
  2021-12-30 16:43       ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Juri Linkov @ 2021-12-30 16:08 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 52881, ben.sferrazza

>> 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?





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

* bug#52881: setting tab-line-separator to any value breaks clicking tabs with mouse
  2021-12-30 16:08     ` Juri Linkov
@ 2021-12-30 16:43       ` Eli Zaretskii
  2021-12-31  9:21         ` Juri Linkov
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2021-12-30 16:43 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 52881, ben.sferrazza

> From: Juri Linkov <juri@linkov.net>
> Cc: ben.sferrazza@aeonsemi.com,  52881@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.





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

* bug#52881: setting tab-line-separator to any value breaks clicking tabs with mouse
  2021-12-30 16:43       ` Eli Zaretskii
@ 2021-12-31  9:21         ` Juri Linkov
  2022-01-02 18:04           ` Juri Linkov
  0 siblings, 1 reply; 7+ messages in thread
From: Juri Linkov @ 2021-12-31  9:21 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 52881, ben.sferrazza

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.





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

* bug#52881: setting tab-line-separator to any value breaks clicking tabs with mouse
  2021-12-31  9:21         ` Juri Linkov
@ 2022-01-02 18:04           ` Juri Linkov
  0 siblings, 0 replies; 7+ messages in thread
From: Juri Linkov @ 2022-01-02 18:04 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 52881, ben.sferrazza

>>> >> 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.





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

end of thread, other threads:[~2022-01-02 18:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-29 21:47 bug#52881: setting tab-line-separator to any value breaks clicking tabs with mouse Ben Sferrazza
2021-12-30  8:05 ` Juri Linkov
2021-12-30  8:44   ` Eli Zaretskii
2021-12-30 16:08     ` Juri Linkov
2021-12-30 16:43       ` Eli Zaretskii
2021-12-31  9:21         ` Juri Linkov
2022-01-02 18:04           ` Juri Linkov

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).