mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-06 14:30:50 -08:00
* lisp/tab-line.el (tab-line--get-tab-property): New function (bug#52881).
(tab-line-auto-hscroll): Use ‘tab-line--get-tab-property’ instead of ‘get-pos-property 1’, and ‘get-text-property’ instead of ‘get-pos-property’. (tab-line-select-tab, tab-line-close-tab): Use tab-line--get-tab-property.
This commit is contained in:
parent
89f205084b
commit
a6adfe21e4
1 changed files with 15 additions and 9 deletions
|
|
@ -615,6 +615,12 @@ the selected tab visible."
|
||||||
|
|
||||||
(defvar tab-line-auto-hscroll-buffer (generate-new-buffer " *tab-line-hscroll*"))
|
(defvar tab-line-auto-hscroll-buffer (generate-new-buffer " *tab-line-hscroll*"))
|
||||||
|
|
||||||
|
(defun tab-line--get-tab-property (prop string)
|
||||||
|
(or (get-text-property 1 prop string) ;; for 99% cases of 1-char separator
|
||||||
|
(get-text-property 0 prop string) ;; for empty separator
|
||||||
|
(let ((pos (next-single-property-change 0 prop string))) ;; long separator
|
||||||
|
(and pos (get-text-property pos prop string)))))
|
||||||
|
|
||||||
(defun tab-line-auto-hscroll (strings hscroll)
|
(defun tab-line-auto-hscroll (strings hscroll)
|
||||||
(with-current-buffer tab-line-auto-hscroll-buffer
|
(with-current-buffer tab-line-auto-hscroll-buffer
|
||||||
(let ((truncate-partial-width-windows nil)
|
(let ((truncate-partial-width-windows nil)
|
||||||
|
|
@ -636,7 +642,7 @@ the selected tab visible."
|
||||||
(not (integerp hscroll)))
|
(not (integerp hscroll)))
|
||||||
(let ((selected (seq-position strings 'selected
|
(let ((selected (seq-position strings 'selected
|
||||||
(lambda (str prop)
|
(lambda (str prop)
|
||||||
(get-pos-property 1 prop str)))))
|
(tab-line--get-tab-property prop str)))))
|
||||||
(cond
|
(cond
|
||||||
((null selected)
|
((null selected)
|
||||||
;; Do nothing if no tab is selected
|
;; Do nothing if no tab is selected
|
||||||
|
|
@ -650,13 +656,13 @@ the selected tab visible."
|
||||||
(if (> (vertical-motion 1) 0)
|
(if (> (vertical-motion 1) 0)
|
||||||
(let* ((point (previous-single-property-change (point) 'tab))
|
(let* ((point (previous-single-property-change (point) 'tab))
|
||||||
(tab-prop (when point
|
(tab-prop (when point
|
||||||
(or (get-pos-property point 'tab)
|
(or (get-text-property point 'tab)
|
||||||
(and (setq point (previous-single-property-change point 'tab))
|
(and (setq point (previous-single-property-change point 'tab))
|
||||||
(get-pos-property point 'tab)))))
|
(get-text-property point 'tab)))))
|
||||||
(new-hscroll (when tab-prop
|
(new-hscroll (when tab-prop
|
||||||
(seq-position strings tab-prop
|
(seq-position strings tab-prop
|
||||||
(lambda (str tab)
|
(lambda (str tab)
|
||||||
(eq (get-pos-property 1 'tab str) tab))))))
|
(eq (tab-line--get-tab-property 'tab str) tab))))))
|
||||||
(when new-hscroll
|
(when new-hscroll
|
||||||
(setq hscroll (float new-hscroll))
|
(setq hscroll (float new-hscroll))
|
||||||
(set-window-parameter nil 'tab-line-hscroll hscroll)))
|
(set-window-parameter nil 'tab-line-hscroll hscroll)))
|
||||||
|
|
@ -677,13 +683,13 @@ the selected tab visible."
|
||||||
(when (> (vertical-motion 1) 0)
|
(when (> (vertical-motion 1) 0)
|
||||||
(let* ((point (previous-single-property-change (point) 'tab))
|
(let* ((point (previous-single-property-change (point) 'tab))
|
||||||
(tab-prop (when point
|
(tab-prop (when point
|
||||||
(or (get-pos-property point 'tab)
|
(or (get-text-property point 'tab)
|
||||||
(and (setq point (previous-single-property-change point 'tab))
|
(and (setq point (previous-single-property-change point 'tab))
|
||||||
(get-pos-property point 'tab)))))
|
(get-text-property point 'tab)))))
|
||||||
(new-hscroll (when tab-prop
|
(new-hscroll (when tab-prop
|
||||||
(seq-position strings tab-prop
|
(seq-position strings tab-prop
|
||||||
(lambda (str tab)
|
(lambda (str tab)
|
||||||
(eq (get-pos-property 1 'tab str) tab))))))
|
(eq (tab-line--get-tab-property 'tab str) tab))))))
|
||||||
(when new-hscroll
|
(when new-hscroll
|
||||||
(setq hscroll (float new-hscroll))
|
(setq hscroll (float new-hscroll))
|
||||||
(set-window-parameter nil 'tab-line-hscroll hscroll)))))))))
|
(set-window-parameter nil 'tab-line-hscroll hscroll)))))))))
|
||||||
|
|
@ -742,7 +748,7 @@ So, for example, switching to a previous tab is equivalent to
|
||||||
using the `previous-buffer' command."
|
using the `previous-buffer' command."
|
||||||
(interactive "e")
|
(interactive "e")
|
||||||
(let* ((posnp (event-start event))
|
(let* ((posnp (event-start event))
|
||||||
(tab (get-pos-property 1 'tab (car (posn-string posnp))))
|
(tab (tab-line--get-tab-property 'tab (car (posn-string posnp))))
|
||||||
(buffer (if (bufferp tab) tab (cdr (assq 'buffer tab)))))
|
(buffer (if (bufferp tab) tab (cdr (assq 'buffer tab)))))
|
||||||
(if buffer
|
(if buffer
|
||||||
(tab-line-select-tab-buffer buffer (posn-window posnp))
|
(tab-line-select-tab-buffer buffer (posn-window posnp))
|
||||||
|
|
@ -854,7 +860,7 @@ sight of the tab line."
|
||||||
(interactive (list last-nonmenu-event))
|
(interactive (list last-nonmenu-event))
|
||||||
(let* ((posnp (and (listp event) (event-start event)))
|
(let* ((posnp (and (listp event) (event-start event)))
|
||||||
(window (and posnp (posn-window posnp)))
|
(window (and posnp (posn-window posnp)))
|
||||||
(tab (get-pos-property 1 'tab (car (posn-string posnp))))
|
(tab (tab-line--get-tab-property 'tab (car (posn-string posnp))))
|
||||||
(buffer (if (bufferp tab) tab (cdr (assq 'buffer tab))))
|
(buffer (if (bufferp tab) tab (cdr (assq 'buffer tab))))
|
||||||
(close-function (unless (bufferp tab) (cdr (assq 'close tab)))))
|
(close-function (unless (bufferp tab) (cdr (assq 'close tab)))))
|
||||||
(with-selected-window (or window (selected-window))
|
(with-selected-window (or window (selected-window))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue