[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#39649: 27.0.60; tab-line doesn't scroll
From: |
Juri Linkov |
Subject: |
bug#39649: 27.0.60; tab-line doesn't scroll |
Date: |
Sun, 23 Feb 2020 01:52:45 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) |
>> 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:
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))))
- bug#39649: 27.0.60; tab-line doesn't scroll, João Guerra, 2020/02/17
- bug#39649: 27.0.60; tab-line doesn't scroll, Juri Linkov, 2020/02/17
- bug#39649: 27.0.60; tab-line doesn't scroll, João Guerra, 2020/02/18
- bug#39649: 27.0.60; tab-line doesn't scroll, Juri Linkov, 2020/02/18
- bug#39649: 27.0.60; tab-line doesn't scroll, Juri Linkov, 2020/02/18
- bug#39649: 27.0.60; tab-line doesn't scroll, João Guerra, 2020/02/19
- bug#39649: 27.0.60; tab-line doesn't scroll, Juri Linkov, 2020/02/20
- bug#39649: 27.0.60; tab-line doesn't scroll, Noam Postavsky, 2020/02/20
- bug#39649: 27.0.60; tab-line doesn't scroll,
Juri Linkov <=
- bug#39649: 27.0.60; tab-line doesn't scroll, João Guerra, 2020/02/23
- bug#39649: 27.0.60; tab-line doesn't scroll, Juri Linkov, 2020/02/23
- bug#39649: 27.0.60; tab-line doesn't scroll, João Guerra, 2020/02/24
- bug#39649: 27.0.60; tab-line doesn't scroll, Juri Linkov, 2020/02/25
- bug#39649: 27.0.60; tab-line doesn't scroll, João Guerra, 2020/02/25
- bug#39649: 27.0.60; tab-line doesn't scroll, Juri Linkov, 2020/02/26
- bug#39649: 27.0.60; tab-line doesn't scroll, Juri Linkov, 2020/02/26
- bug#39649: 27.0.60; tab-line doesn't scroll, Eli Zaretskii, 2020/02/28
- bug#39649: 27.0.60; tab-line doesn't scroll, Juri Linkov, 2020/02/29
- bug#39649: 27.0.60; tab-line doesn't scroll, João Guerra, 2020/02/27