New variable 'expose-hidden-buffer' (Bug#75828)

* src/frame.c (make_frame): Handle 'expose-hidden-buffer'.
(expose-hidden-buffer): New variable to handle hidden buffers.
* src/buffer.c (Fother_buffer): Mention that it does not return
a hidden buffer.
* lisp/frame.el (make-frame): In doc-string describe handling
of hidden buffers.
* doc/lispref/frames.texi (Creating Frames): Explain handling
of hidden buffers in description of 'make-frame'.
This commit is contained in:
Martin Rudalics 2025-01-28 16:59:45 +01:00
parent c400ac680f
commit 7f01dd8906
4 changed files with 33 additions and 4 deletions

View file

@ -162,6 +162,13 @@ This function itself does not make the new frame the selected frame.
@xref{Input Focus}. The previously selected frame remains selected.
On graphical terminals, however, the window system may select the
new frame for its own reasons.
By default this function does not display the current buffer in the new
frame if the buffer is hidden, that is, if its name starts with a space.
In this case it will show another buffer - one that could be returned by
the function @code{other-buffer} (@pxref{Buffer List}) - instead.
However, if the variable @code{expose-hidden-buffer} is non-@code{nil},
this function will display the current buffer even if it is hidden.
@end deffn
@defvar before-make-frame-hook

View file

@ -949,7 +949,13 @@ guess the window-system from the display.
On graphical displays, this function does not itself make the new
frame the selected frame. However, the window system may select
the new frame according to its own rules."
the new frame according to its own rules.
By default do not display the current buffer in the new frame if the
buffer is hidden, that is, if the buffer's name starts with a space.
Display another buffer - one that could be returned by `other-buffer' -
instead. However, if `expose-hidden-buffer' is non-nil, display the
current buffer even if it is hidden."
(interactive)
(let* ((display (cdr (assq 'display parameters)))
(w (cond

View file

@ -1729,7 +1729,8 @@ Buffers not visible in windows are preferred to visible buffers, unless
optional second argument VISIBLE-OK is non-nil. Ignore the argument
BUFFER unless it denotes a live buffer. If the optional third argument
FRAME specifies a live frame, then use that frame's buffer list instead
of the selected frame's buffer list.
of the selected frame's buffer list. Do not return a hidden buffer - a
buffer whose name starts with a space.
The buffer is found by scanning the selected or specified frame's buffer
list first, followed by the list of all buffers. If no other buffer

View file

@ -1094,8 +1094,9 @@ make_frame (bool mini_p)
{
Lisp_Object buf = Fcurrent_buffer ();
/* If current buffer is hidden, try to find another one. */
if (BUFFER_HIDDEN_P (XBUFFER (buf)))
/* If the current buffer is hidden and shall not be exposed, try to find
another one. */
if (BUFFER_HIDDEN_P (XBUFFER (buf)) && NILP (expose_hidden_buffer))
buf = other_buffer_safely (buf);
/* Use set_window_buffer, not Fset_window_buffer, and don't let
@ -7164,6 +7165,20 @@ making the child frame unresponsive to user actions, the default is to
iconify the top level frame instead. */);
iconify_child_frame = Qiconify_top_level;
DEFVAR_LISP ("expose-hidden-buffer", expose_hidden_buffer,
doc: /* Non-nil means to make a hidden buffer more visible.
A buffer is considered "hidden" if its name starts with a space. By
default, many functions disregard hidden buffers. In particular,
`make-frame' does not show the current buffer in the new frame's
selected window if that buffer is hidden. Rather, `make-frame' will
show a buffer that is not hidden instead.
If this variable is non-nil, it will override the default behavior and
allow `make-frame' to show the current buffer even if its hidden. */);
expose_hidden_buffer = Qnil;
DEFSYM (Qexpose_hidden_buffer, "expose-hidden-buffer");
Fmake_variable_buffer_local (Qexpose_hidden_buffer);
DEFVAR_LISP ("frame-internal-parameters", frame_internal_parameters,
doc: /* Frame parameters specific to every frame. */);
#ifdef HAVE_X_WINDOWS