1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-12-11 09:20:51 +00:00

Merge from origin/emacs-28

67400da412 Improve doc strings of fringe indicator variables
a6adfe21e4 * lisp/tab-line.el (tab-line--get-tab-property): New funct...
This commit is contained in:
Stefan Kangas 2022-01-01 06:51:58 +01:00
commit 78066671c0
2 changed files with 20 additions and 13 deletions

View File

@ -617,6 +617,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)
@ -638,7 +644,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
@ -652,13 +658,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)))
@ -679,13 +685,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)))))))))
@ -744,7 +750,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))
@ -860,7 +866,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))

View File

@ -6023,15 +6023,16 @@ specifies. */);
DEFVAR_PER_BUFFER ("indicate-empty-lines", DEFVAR_PER_BUFFER ("indicate-empty-lines",
&BVAR (current_buffer, indicate_empty_lines), Qnil, &BVAR (current_buffer, indicate_empty_lines), Qnil,
doc: /* Visually indicate empty lines after the buffer end. doc: /* Visually indicate unused ("empty") screen lines after the buffer end.
If non-nil, a bitmap is displayed in the left fringe of a window on If non-nil, a bitmap is displayed in the left fringe of a window
window-systems. */); on graphical displays for each screen line that doesn't correspond
to any buffer text. */);
DEFVAR_PER_BUFFER ("indicate-buffer-boundaries", DEFVAR_PER_BUFFER ("indicate-buffer-boundaries",
&BVAR (current_buffer, indicate_buffer_boundaries), Qnil, &BVAR (current_buffer, indicate_buffer_boundaries), Qnil,
doc: /* Visually indicate buffer boundaries and scrolling. doc: /* Visually indicate buffer boundaries and scrolling.
If non-nil, the first and last line of the buffer are marked in the fringe If non-nil, the first and last line of the buffer are marked in the fringe
of a window on window-systems with angle bitmaps, or if the window can be of a window on graphical displays with angle bitmaps, or if the window can be
scrolled, the top and bottom line of the window are marked with up and down scrolled, the top and bottom line of the window are marked with up and down
arrow bitmaps. arrow bitmaps.