all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: Noam Postavsky <npostavs@gmail.com>
Cc: 39649@debbugs.gnu.org, "João Guerra" <joca.bt@gmail.com>
Subject: bug#39649: 27.0.60; tab-line doesn't scroll
Date: Sun, 23 Feb 2020 01:52:45 +0200	[thread overview]
Message-ID: <87y2sup4c2.fsf@mail.linkov.net> (raw)
In-Reply-To: <87d0a8bu5c.fsf@gmail.com> (Noam Postavsky's message of "Thu, 20 Feb 2020 20:34:23 -0500")

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

>> I don't understand why Emacs doesn't support signed zero.
>> For example in JavaScript: Math.sign(-0) => -0
>
> It does, for floats (afaik, in JavaScript all numbers are floating
> point).
>
>     (copysign 1.0 -0.0) ;=> -1.0

Then if take into use floats, the distinction could be
not between positive/negative floats, but between integers/floats.

João, could you please try a new patch:


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

diff --git a/lisp/tab-line.el b/lisp/tab-line.el
index 8f1221abe4..754a0a95ab 100644
--- a/lisp/tab-line.el
+++ b/lisp/tab-line.el
@@ -446,17 +446,19 @@ tab-line-format-template
            (setq hscroll nil)
            (set-window-parameter nil 'tab-line-hscroll hscroll))
        (list separator
-             (when (and (integerp hscroll) (not (zerop hscroll)))
+             (when (and (numberp hscroll) (not (zerop hscroll)))
                tab-line-left-button)
-             (when (if (integerp hscroll)
-                       (< (abs hscroll) (1- (length strings)))
+             (when (if (numberp hscroll)
+                       (< (truncate hscroll) (1- (length strings)))
                      (> (length strings) 1))
                tab-line-right-button)))
-     (if hscroll (nthcdr (abs hscroll) strings) strings)
+     (if hscroll (nthcdr (truncate hscroll) strings) strings)
      (when (eq tab-line-tabs-function #'tab-line-tabs-window-buffers)
        (list (concat separator (when tab-line-new-tab-choice
                                  tab-line-new-button)))))))
 
+(defvar tab-line-auto-hscroll)
+
 (defun tab-line-format ()
   "Template for displaying tab line for selected window."
   (let* ((tabs (funcall tab-line-tabs-function))
@@ -464,6 +466,13 @@ tab-line-format
                           (window-buffer)
                           (window-parameter nil 'tab-line-hscroll)))
          (cache (window-parameter nil 'tab-line-cache)))
+    ;; Enable auto-hscroll again after it was disabled on manual scrolling.
+    ;; The moment to enable it is when the window-buffer was updated.
+    (when (and tab-line-auto-hscroll        ; if auto-hscroll was enabled
+               (integerp (nth 2 cache-key)) ; integer on manual scroll
+               cache                        ; window-buffer was updated
+               (not (equal (nth 1 (car cache)) (nth 1 cache-key))))
+      (set-window-parameter nil 'tab-line-hscroll (float (nth 2 cache-key))))
     (or (and cache (equal (car cache) cache-key) (cdr cache))
         (cdr (set-window-parameter
               nil 'tab-line-cache
@@ -490,12 +499,12 @@ tab-line-auto-hscroll
       ;; Continuation means tab-line doesn't fit completely,
       ;; thus scroll arrows are needed for scrolling.
       (setq show-arrows (> (vertical-motion 1) 0))
-      ;; Try to auto-scroll only when scrolling is needed,
+      ;; Try to auto-hscroll only when scrolling is needed,
       ;; but no manual scrolling was performed before.
       (when (and tab-line-auto-hscroll
                  show-arrows
                  ;; Do nothing when scrolled manually
-                 (not (and (integerp hscroll) (>= hscroll 0))))
+                 (not (integerp hscroll)))
         (let ((selected (seq-position strings 'selected
                                       (lambda (str prop)
                                         (get-pos-property 1 prop str)))))
@@ -503,7 +512,7 @@ tab-line-auto-hscroll
            ((null selected)
             ;; Do nothing if no tab is selected
             )
-           ((or (not (integerp hscroll)) (< selected (abs hscroll)))
+           ((or (not (numberp hscroll)) (< selected (truncate hscroll)))
             ;; Selected is scrolled to the left, or no scrolling yet
             (erase-buffer)
             (apply 'insert (reverse (seq-subseq strings 0 (1+ selected))))
@@ -520,14 +529,14 @@ tab-line-auto-hscroll
                                                     (lambda (str tab)
                                                       (eq (get-pos-property 1 'tab str) tab))))))
                   (when new-hscroll
-                    (setq hscroll (- new-hscroll))
+                    (setq hscroll (float new-hscroll))
                     (set-window-parameter nil 'tab-line-hscroll hscroll)))
               (setq hscroll nil)
               (set-window-parameter nil 'tab-line-hscroll hscroll)))
            (t
             ;; Check if the selected tab is already visible
             (erase-buffer)
-            (apply 'insert (seq-subseq strings (abs hscroll) (1+ selected)))
+            (apply 'insert (seq-subseq strings (truncate hscroll) (1+ selected)))
             (goto-char (point-min))
             (add-face-text-property (point-min) (point-max) 'tab-line)
             (when (> (vertical-motion 1) 0)
@@ -547,7 +556,7 @@ tab-line-auto-hscroll
                                                     (lambda (str tab)
                                                       (eq (get-pos-property 1 'tab str) tab))))))
                   (when new-hscroll
-                    (setq hscroll (- new-hscroll))
+                    (setq hscroll (float new-hscroll))
                     (set-window-parameter nil 'tab-line-hscroll hscroll)))))))))
       (list show-arrows hscroll))))
 
@@ -559,7 +568,7 @@ tab-line-hscroll
                  (funcall tab-line-tabs-function))))
     (set-window-parameter
      window 'tab-line-hscroll
-     (max 0 (min (+ (if (integerp hscroll) (abs hscroll) 0) (or arg 1))
+     (max 0 (min (+ (if (numberp hscroll) (truncate hscroll) 0) (or arg 1))
                  (1- (length tabs)))))
     (when window
       (force-mode-line-update t))))

  reply	other threads:[~2020-02-22 23:52 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-17 18:51 bug#39649: 27.0.60; tab-line doesn't scroll João Guerra
2020-02-17 23:03 ` Juri Linkov
2020-02-18 20:27   ` João Guerra
2020-02-18 22:39     ` Juri Linkov
2020-02-19  0:24       ` Juri Linkov
2020-02-19 20:57         ` João Guerra
2020-02-20 23:07           ` Juri Linkov
2020-02-21  1:34             ` Noam Postavsky
2020-02-22 23:52               ` Juri Linkov [this message]
2020-02-23 10:35                 ` João Guerra
2020-02-23 23:06                   ` Juri Linkov
2020-02-24 19:11                     ` João Guerra
2020-02-25 21:20                       ` Juri Linkov
2020-02-25 21:49                         ` João Guerra
2020-02-26 23:16                           ` Juri Linkov
2020-02-26 23:33                             ` Juri Linkov
2020-02-28  9:12                               ` Eli Zaretskii
2020-02-29 21:44                                 ` Juri Linkov
2020-03-01 16:12                                   ` Eli Zaretskii
2020-03-01 23:40                                     ` Juri Linkov
2020-09-20  8:40                                       ` Lars Ingebrigtsen
2020-02-27 21:13                             ` João Guerra
2020-02-27 22:37                               ` Juri Linkov
2020-02-28 18:30                                 ` João Guerra
2020-02-29 21:49                                   ` Juri Linkov
2020-03-04 17:25                                     ` João Guerra
2020-03-04 23:52                                       ` Juri Linkov
2020-03-05  8:04                                         ` João Guerra
2020-03-05 23:53                                           ` Juri Linkov
2020-09-20  8:41                                     ` Lars Ingebrigtsen
2020-10-14  6:16                                       ` Lars Ingebrigtsen
2020-02-28 13:16                         ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y2sup4c2.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=39649@debbugs.gnu.org \
    --cc=joca.bt@gmail.com \
    --cc=npostavs@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.