diff options
| author | Eshel Yaron | 2023-06-04 19:41:20 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2023-06-06 15:08:31 +0300 |
| commit | 4f66cbbfe520ee31ef26676e09a926217d9736fe (patch) | |
| tree | 2aad8a7af90b4bdcfe8bb988eb688d2ffc7b6be1 /src | |
| parent | d751915ef4c10f2dc10555c404fac3c981320b4f (diff) | |
| download | emacs-4f66cbbfe520ee31ef26676e09a926217d9736fe.tar.gz emacs-4f66cbbfe520ee31ef26676e09a926217d9736fe.zip | |
Avoid header line with some empty non-nil formats
Allow the value of 'header-line-format' to indicate that no header
line should be displayed when it trivially yields 'nil', even if it is
not plain 'nil'. Previously, any non-nil 'header-line-format'
resulted in a (possibly empty) header line. This change adds some
flexibility by also taking a non-nil value of 'header-line-format' to
mean that no header line should be displayed if it's a list whose
'car' is a symbol and either that symbol is ':eval' and the second
list element evaluates to 'nil', or the symbol's value as a variable
is 'nil' or void.
(Bug#63825)
* src/xdisp.c (safe_eval_inhibit_quit): New function.
* src/lisp.h (safe_eval_inhibit_quit): Declare it.
* src/window.c (null_header_line_format): New function.
(window_wants_header_line): Use it.
* doc/lispref/modes.texi (Header Line): Update to reflect new
conditions for displaying a window's header line.
* etc/NEWS: Announce updated treatment of 'header-line-format'.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lisp.h | 1 | ||||
| -rw-r--r-- | src/window.c | 50 | ||||
| -rw-r--r-- | src/xdisp.c | 6 |
3 files changed, 55 insertions, 2 deletions
diff --git a/src/lisp.h b/src/lisp.h index 2bfcd1a1983..2978de962d9 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -4174,6 +4174,7 @@ void set_frame_cursor_types (struct frame *, Lisp_Object); | |||
| 4174 | extern void syms_of_xdisp (void); | 4174 | extern void syms_of_xdisp (void); |
| 4175 | extern void init_xdisp (void); | 4175 | extern void init_xdisp (void); |
| 4176 | extern Lisp_Object safe_eval (Lisp_Object); | 4176 | extern Lisp_Object safe_eval (Lisp_Object); |
| 4177 | extern Lisp_Object safe_eval_inhibit_quit (Lisp_Object); | ||
| 4177 | extern bool pos_visible_p (struct window *, ptrdiff_t, int *, | 4178 | extern bool pos_visible_p (struct window *, ptrdiff_t, int *, |
| 4178 | int *, int *, int *, int *, int *); | 4179 | int *, int *, int *, int *, int *); |
| 4179 | 4180 | ||
diff --git a/src/window.c b/src/window.c index f4e09f49eae..9429679061e 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -5472,6 +5472,48 @@ window_wants_mode_line (struct window *w) | |||
| 5472 | 5472 | ||
| 5473 | 5473 | ||
| 5474 | /** | 5474 | /** |
| 5475 | * null_header_line_format: | ||
| 5476 | * | ||
| 5477 | * Return non-zero when header line format FMT indicates that the | ||
| 5478 | * header line should not be displayed at all. | ||
| 5479 | * | ||
| 5480 | * This is when FMT is nil, or if FMT is a cons cell and either its | ||
| 5481 | * car is a symbol whose value as a variable is nil or void, or its | ||
| 5482 | * car is the symbol ':eval' and its cadr evaluates to nil. | ||
| 5483 | */ | ||
| 5484 | static bool | ||
| 5485 | null_header_line_format (Lisp_Object fmt, struct frame * f) | ||
| 5486 | { | ||
| 5487 | Lisp_Object car; | ||
| 5488 | Lisp_Object val; | ||
| 5489 | |||
| 5490 | if (NILP (fmt)) | ||
| 5491 | return true; | ||
| 5492 | |||
| 5493 | if (CONSP (fmt)) | ||
| 5494 | { | ||
| 5495 | car = XCAR (fmt); | ||
| 5496 | if (SYMBOLP (car)) | ||
| 5497 | { | ||
| 5498 | if (EQ (car, QCeval)) | ||
| 5499 | { | ||
| 5500 | val = safe_eval_inhibit_quit (XCAR (XCDR (fmt))); | ||
| 5501 | if (!FRAME_LIVE_P (f)) | ||
| 5502 | signal_error (":eval deleted the frame being displayed", fmt); | ||
| 5503 | return NILP (val); | ||
| 5504 | } | ||
| 5505 | val = find_symbol_value (car); | ||
| 5506 | return (SYMBOLP (car) | ||
| 5507 | && (EQ (val, Qunbound) | ||
| 5508 | || NILP (val))); | ||
| 5509 | } | ||
| 5510 | } | ||
| 5511 | |||
| 5512 | return false; | ||
| 5513 | } | ||
| 5514 | |||
| 5515 | |||
| 5516 | /** | ||
| 5475 | * window_wants_header_line: | 5517 | * window_wants_header_line: |
| 5476 | * | 5518 | * |
| 5477 | * Return 1 if window W wants a header line and is high enough to | 5519 | * Return 1 if window W wants a header line and is high enough to |
| @@ -5491,12 +5533,16 @@ window_wants_header_line (struct window *w) | |||
| 5491 | Lisp_Object window_header_line_format = | 5533 | Lisp_Object window_header_line_format = |
| 5492 | window_parameter (w, Qheader_line_format); | 5534 | window_parameter (w, Qheader_line_format); |
| 5493 | 5535 | ||
| 5536 | struct frame * f = WINDOW_XFRAME(w); | ||
| 5537 | |||
| 5494 | return (WINDOW_LEAF_P (w) | 5538 | return (WINDOW_LEAF_P (w) |
| 5495 | && !MINI_WINDOW_P (w) | 5539 | && !MINI_WINDOW_P (w) |
| 5496 | && !WINDOW_PSEUDO_P (w) | 5540 | && !WINDOW_PSEUDO_P (w) |
| 5497 | && !EQ (window_header_line_format, Qnone) | 5541 | && !EQ (window_header_line_format, Qnone) |
| 5498 | && (!NILP (window_header_line_format) | 5542 | && (!null_header_line_format (window_header_line_format, f) |
| 5499 | || !NILP (BVAR (XBUFFER (WINDOW_BUFFER (w)), header_line_format))) | 5543 | || !null_header_line_format (BVAR (XBUFFER (WINDOW_BUFFER (w)), |
| 5544 | header_line_format), | ||
| 5545 | f)) | ||
| 5500 | && (WINDOW_PIXEL_HEIGHT (w) | 5546 | && (WINDOW_PIXEL_HEIGHT (w) |
| 5501 | > (window_wants_mode_line (w) | 5547 | > (window_wants_mode_line (w) |
| 5502 | ? 2 * WINDOW_FRAME_LINE_HEIGHT (w) | 5548 | ? 2 * WINDOW_FRAME_LINE_HEIGHT (w) |
diff --git a/src/xdisp.c b/src/xdisp.c index a6ec966ea3c..5e25857322f 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -3074,6 +3074,12 @@ safe__eval (bool inhibit_quit, Lisp_Object sexpr) | |||
| 3074 | return safe__call1 (inhibit_quit, Qeval, sexpr); | 3074 | return safe__call1 (inhibit_quit, Qeval, sexpr); |
| 3075 | } | 3075 | } |
| 3076 | 3076 | ||
| 3077 | Lisp_Object | ||
| 3078 | safe_eval_inhibit_quit (Lisp_Object sexpr) | ||
| 3079 | { | ||
| 3080 | return safe__eval (true, sexpr); | ||
| 3081 | } | ||
| 3082 | |||
| 3077 | /* Call function FN with two arguments ARG1 and ARG2. | 3083 | /* Call function FN with two arguments ARG1 and ARG2. |
| 3078 | Return the result, or nil if something went wrong. */ | 3084 | Return the result, or nil if something went wrong. */ |
| 3079 | 3085 | ||