aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Rudalics2025-01-28 16:59:45 +0100
committerMartin Rudalics2025-01-28 16:59:45 +0100
commit7f01dd8906cbc8839ffecc55cfa7ff789f3fa298 (patch)
tree46f5bf6cf6f63a95e75e4c1438ecff10444df8eb
parentc400ac680f4db86686126876e2d709b1e6099544 (diff)
downloademacs-7f01dd8906cbc8839ffecc55cfa7ff789f3fa298.tar.gz
emacs-7f01dd8906cbc8839ffecc55cfa7ff789f3fa298.zip
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'.
-rw-r--r--doc/lispref/frames.texi7
-rw-r--r--lisp/frame.el8
-rw-r--r--src/buffer.c3
-rw-r--r--src/frame.c19
4 files changed, 33 insertions, 4 deletions
diff --git a/doc/lispref/frames.texi b/doc/lispref/frames.texi
index c71b977550e..52af34389c5 100644
--- a/doc/lispref/frames.texi
+++ b/doc/lispref/frames.texi
@@ -162,6 +162,13 @@ This function itself does not make the new frame the selected frame.
162@xref{Input Focus}. The previously selected frame remains selected. 162@xref{Input Focus}. The previously selected frame remains selected.
163On graphical terminals, however, the window system may select the 163On graphical terminals, however, the window system may select the
164new frame for its own reasons. 164new frame for its own reasons.
165
166By default this function does not display the current buffer in the new
167frame if the buffer is hidden, that is, if its name starts with a space.
168In this case it will show another buffer - one that could be returned by
169the function @code{other-buffer} (@pxref{Buffer List}) - instead.
170However, if the variable @code{expose-hidden-buffer} is non-@code{nil},
171this function will display the current buffer even if it is hidden.
165@end deffn 172@end deffn
166 173
167@defvar before-make-frame-hook 174@defvar before-make-frame-hook
diff --git a/lisp/frame.el b/lisp/frame.el
index 091e84f09c4..df6ef951514 100644
--- a/lisp/frame.el
+++ b/lisp/frame.el
@@ -949,7 +949,13 @@ guess the window-system from the display.
949 949
950On graphical displays, this function does not itself make the new 950On graphical displays, this function does not itself make the new
951frame the selected frame. However, the window system may select 951frame the selected frame. However, the window system may select
952the new frame according to its own rules." 952the new frame according to its own rules.
953
954By default do not display the current buffer in the new frame if the
955buffer is hidden, that is, if the buffer's name starts with a space.
956Display another buffer - one that could be returned by `other-buffer' -
957instead. However, if `expose-hidden-buffer' is non-nil, display the
958current buffer even if it is hidden."
953 (interactive) 959 (interactive)
954 (let* ((display (cdr (assq 'display parameters))) 960 (let* ((display (cdr (assq 'display parameters)))
955 (w (cond 961 (w (cond
diff --git a/src/buffer.c b/src/buffer.c
index 1b9092b107b..ed2f14ea9c0 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1729,7 +1729,8 @@ Buffers not visible in windows are preferred to visible buffers, unless
1729optional second argument VISIBLE-OK is non-nil. Ignore the argument 1729optional second argument VISIBLE-OK is non-nil. Ignore the argument
1730BUFFER unless it denotes a live buffer. If the optional third argument 1730BUFFER unless it denotes a live buffer. If the optional third argument
1731FRAME specifies a live frame, then use that frame's buffer list instead 1731FRAME specifies a live frame, then use that frame's buffer list instead
1732of the selected frame's buffer list. 1732of the selected frame's buffer list. Do not return a hidden buffer - a
1733buffer whose name starts with a space.
1733 1734
1734The buffer is found by scanning the selected or specified frame's buffer 1735The buffer is found by scanning the selected or specified frame's buffer
1735list first, followed by the list of all buffers. If no other buffer 1736list first, followed by the list of all buffers. If no other buffer
diff --git a/src/frame.c b/src/frame.c
index d59b4045c00..4f3c1efc4a7 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -1094,8 +1094,9 @@ make_frame (bool mini_p)
1094 { 1094 {
1095 Lisp_Object buf = Fcurrent_buffer (); 1095 Lisp_Object buf = Fcurrent_buffer ();
1096 1096
1097 /* If current buffer is hidden, try to find another one. */ 1097 /* If the current buffer is hidden and shall not be exposed, try to find
1098 if (BUFFER_HIDDEN_P (XBUFFER (buf))) 1098 another one. */
1099 if (BUFFER_HIDDEN_P (XBUFFER (buf)) && NILP (expose_hidden_buffer))
1099 buf = other_buffer_safely (buf); 1100 buf = other_buffer_safely (buf);
1100 1101
1101 /* Use set_window_buffer, not Fset_window_buffer, and don't let 1102 /* 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
7164iconify the top level frame instead. */); 7165iconify the top level frame instead. */);
7165 iconify_child_frame = Qiconify_top_level; 7166 iconify_child_frame = Qiconify_top_level;
7166 7167
7168 DEFVAR_LISP ("expose-hidden-buffer", expose_hidden_buffer,
7169 doc: /* Non-nil means to make a hidden buffer more visible.
7170A buffer is considered "hidden" if its name starts with a space. By
7171default, many functions disregard hidden buffers. In particular,
7172`make-frame' does not show the current buffer in the new frame's
7173selected window if that buffer is hidden. Rather, `make-frame' will
7174show a buffer that is not hidden instead.
7175
7176If this variable is non-nil, it will override the default behavior and
7177allow `make-frame' to show the current buffer even if its hidden. */);
7178 expose_hidden_buffer = Qnil;
7179 DEFSYM (Qexpose_hidden_buffer, "expose-hidden-buffer");
7180 Fmake_variable_buffer_local (Qexpose_hidden_buffer);
7181
7167 DEFVAR_LISP ("frame-internal-parameters", frame_internal_parameters, 7182 DEFVAR_LISP ("frame-internal-parameters", frame_internal_parameters,
7168 doc: /* Frame parameters specific to every frame. */); 7183 doc: /* Frame parameters specific to every frame. */);
7169#ifdef HAVE_X_WINDOWS 7184#ifdef HAVE_X_WINDOWS