Commit 2a016475 authored by Juri Linkov's avatar Juri Linkov

Don't use hook pre-redisplay-functions. Set buffer-local tab-line-format.

* lisp/tab-line.el (tab-line-format): Move to C.
(tab-line-update-window-parameter): Remove function.
(global-tab-line-mode): Set the default value of tab-line-format.

* src/buffer.c (syms_of_buffer): Define buffer-local variable
tab-line-format.

* src/buffer.h (struct buffer): Add tab_line_format_.

* src/window.c (window_wants_tab_line):
* src/xdisp.c (pos_visible_p, display_mode_lines):
Check for buffer-local tab_line_format.
parent 7970c89c
Pipeline #3061 passed with stage
in 55 minutes and 33 seconds
...@@ -251,8 +251,6 @@ using the `previous-buffer' command." ...@@ -251,8 +251,6 @@ using the `previous-buffer' command."
(force-mode-line-update)))) (force-mode-line-update))))
(defvar tab-line-format '(:eval (tab-line-format)))
;;;###autoload ;;;###autoload
(define-minor-mode global-tab-line-mode (define-minor-mode global-tab-line-mode
"Display window-local tab line." "Display window-local tab line."
...@@ -260,24 +258,8 @@ using the `previous-buffer' command." ...@@ -260,24 +258,8 @@ using the `previous-buffer' command."
:type 'boolean :type 'boolean
:global t :global t
:init-value nil :init-value nil
:initialize (lambda (sym val) (setq-default tab-line-format (when global-tab-line-mode
(custom-initialize-default sym val) '(:eval (tab-line-format)))))
(when global-tab-line-mode
(add-hook 'pre-redisplay-functions #'tab-line-update-window-parameter)))
(if global-tab-line-mode
(progn
(add-hook 'pre-redisplay-functions #'tab-line-update-window-parameter)
(force-mode-line-update))
(remove-hook 'pre-redisplay-functions #'tab-line-update-window-parameter)
(walk-windows (lambda (w) (tab-line-update-window-parameter w)) t)))
(defun tab-line-update-window-parameter (window)
(let* ((name 'tab-line-format)
(value (window-parameter window name))
(active global-tab-line-mode))
(when (xor value active)
(set-window-parameter
window name (unless value tab-line-format)))))
(provide 'tab-line) (provide 'tab-line)
......
...@@ -249,6 +249,11 @@ bset_header_line_format (struct buffer *b, Lisp_Object val) ...@@ -249,6 +249,11 @@ bset_header_line_format (struct buffer *b, Lisp_Object val)
b->header_line_format_ = val; b->header_line_format_ = val;
} }
static void static void
bset_tab_line_format (struct buffer *b, Lisp_Object val)
{
b->tab_line_format_ = val;
}
static void
bset_indicate_buffer_boundaries (struct buffer *b, Lisp_Object val) bset_indicate_buffer_boundaries (struct buffer *b, Lisp_Object val)
{ {
b->indicate_buffer_boundaries_ = val; b->indicate_buffer_boundaries_ = val;
...@@ -5188,6 +5193,7 @@ init_buffer_once (void) ...@@ -5188,6 +5193,7 @@ init_buffer_once (void)
XSETFASTINT (BVAR (&buffer_local_flags, scroll_up_aggressively), idx); ++idx; XSETFASTINT (BVAR (&buffer_local_flags, scroll_up_aggressively), idx); ++idx;
XSETFASTINT (BVAR (&buffer_local_flags, scroll_down_aggressively), idx); ++idx; XSETFASTINT (BVAR (&buffer_local_flags, scroll_down_aggressively), idx); ++idx;
XSETFASTINT (BVAR (&buffer_local_flags, header_line_format), idx); ++idx; XSETFASTINT (BVAR (&buffer_local_flags, header_line_format), idx); ++idx;
XSETFASTINT (BVAR (&buffer_local_flags, tab_line_format), idx); ++idx;
XSETFASTINT (BVAR (&buffer_local_flags, cursor_type), idx); ++idx; XSETFASTINT (BVAR (&buffer_local_flags, cursor_type), idx); ++idx;
XSETFASTINT (BVAR (&buffer_local_flags, extra_line_spacing), idx); ++idx; XSETFASTINT (BVAR (&buffer_local_flags, extra_line_spacing), idx); ++idx;
XSETFASTINT (BVAR (&buffer_local_flags, cursor_in_non_selected_windows), idx); ++idx; XSETFASTINT (BVAR (&buffer_local_flags, cursor_in_non_selected_windows), idx); ++idx;
...@@ -5233,6 +5239,7 @@ init_buffer_once (void) ...@@ -5233,6 +5239,7 @@ init_buffer_once (void)
/* real setup is done in bindings.el */ /* real setup is done in bindings.el */
bset_mode_line_format (&buffer_defaults, build_pure_c_string ("%-")); bset_mode_line_format (&buffer_defaults, build_pure_c_string ("%-"));
bset_header_line_format (&buffer_defaults, Qnil); bset_header_line_format (&buffer_defaults, Qnil);
bset_tab_line_format (&buffer_defaults, Qnil);
bset_abbrev_mode (&buffer_defaults, Qnil); bset_abbrev_mode (&buffer_defaults, Qnil);
bset_overwrite_mode (&buffer_defaults, Qnil); bset_overwrite_mode (&buffer_defaults, Qnil);
bset_case_fold_search (&buffer_defaults, Qt); bset_case_fold_search (&buffer_defaults, Qt);
...@@ -5504,6 +5511,13 @@ syms_of_buffer (void) ...@@ -5504,6 +5511,13 @@ syms_of_buffer (void)
Fput (Qprotected_field, Qerror_message, Fput (Qprotected_field, Qerror_message,
build_pure_c_string ("Attempt to modify a protected field")); build_pure_c_string ("Attempt to modify a protected field"));
DEFVAR_PER_BUFFER ("tab-line-format",
&BVAR (current_buffer, tab_line_format),
Qnil,
doc: /* Analogous to `mode-line-format', but controls the tab line.
The tab line appears, optionally, at the top of a window;
the mode line appears at the bottom. */);
DEFVAR_PER_BUFFER ("header-line-format", DEFVAR_PER_BUFFER ("header-line-format",
&BVAR (current_buffer, header_line_format), &BVAR (current_buffer, header_line_format),
Qnil, Qnil,
......
...@@ -539,6 +539,10 @@ struct buffer ...@@ -539,6 +539,10 @@ struct buffer
of windows. Nil means don't display that line. */ of windows. Nil means don't display that line. */
Lisp_Object header_line_format_; Lisp_Object header_line_format_;
/* Analogous to mode_line_format for the line displayed at the top
of windows. Nil means don't display that line. */
Lisp_Object tab_line_format_;
/* Keys that are bound local to this buffer. */ /* Keys that are bound local to this buffer. */
Lisp_Object keymap_; Lisp_Object keymap_;
......
...@@ -5419,7 +5419,8 @@ window_wants_tab_line (struct window *w) ...@@ -5419,7 +5419,8 @@ window_wants_tab_line (struct window *w)
&& !MINI_WINDOW_P (w) && !MINI_WINDOW_P (w)
&& !WINDOW_PSEUDO_P (w) && !WINDOW_PSEUDO_P (w)
&& !EQ (window_tab_line_format, Qnone) && !EQ (window_tab_line_format, Qnone)
&& !NILP (window_tab_line_format) && (!NILP (window_tab_line_format)
|| !NILP (BVAR (XBUFFER (WINDOW_BUFFER (w)), tab_line_format)))
&& (WINDOW_PIXEL_HEIGHT (w) && (WINDOW_PIXEL_HEIGHT (w)
> (((window_wants_mode_line (w) ? 1 : 0) > (((window_wants_mode_line (w) ? 1 : 0)
+ (window_wants_header_line (w) ? 1 : 0) + (window_wants_header_line (w) ? 1 : 0)
......
...@@ -1478,7 +1478,10 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int *x, int *y, ...@@ -1478,7 +1478,10 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int *x, int *y,
= window_parameter (w, Qtab_line_format); = window_parameter (w, Qtab_line_format);
w->tab_line_height w->tab_line_height
= display_mode_line (w, TAB_LINE_FACE_ID, window_tab_line_format); = display_mode_line (w, TAB_LINE_FACE_ID,
NILP (window_tab_line_format)
? BVAR (current_buffer, tab_line_format)
: window_tab_line_format);
} }
if (window_wants_header_line (w)) if (window_wants_header_line (w))
...@@ -24743,7 +24746,10 @@ display_mode_lines (struct window *w) ...@@ -24743,7 +24746,10 @@ display_mode_lines (struct window *w)
Lisp_Object window_tab_line_format Lisp_Object window_tab_line_format
= window_parameter (w, Qtab_line_format); = window_parameter (w, Qtab_line_format);
display_mode_line (w, TAB_LINE_FACE_ID, window_tab_line_format); display_mode_line (w, TAB_LINE_FACE_ID,
NILP (window_tab_line_format)
? BVAR (current_buffer, tab_line_format)
: window_tab_line_format);
++n; ++n;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment