]> git.eshelyaron.com Git - emacs.git/commitdiff
New variable 'expose-hidden-buffer' (Bug#75828)
authorMartin Rudalics <rudalics@gmx.at>
Tue, 28 Jan 2025 15:59:45 +0000 (16:59 +0100)
committerEshel Yaron <me@eshelyaron.com>
Thu, 30 Jan 2025 18:11:59 +0000 (19:11 +0100)
* 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'.

(cherry picked from commit 7f01dd8906cbc8839ffecc55cfa7ff789f3fa298)

doc/lispref/frames.texi
lisp/frame.el
src/buffer.c
src/frame.c

index c71b977550e42462f1d0d01da39e309eb801d178..52af34389c5ee7b4a9b89e446f45734d172e3ae7 100644 (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
index eefa64119619fdcc2f47b461d23049e70a9b119c..dc6628b2dd87b54e52d92e5df79ca801f3761840 100644 (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
index 1b9092b107bb038b729e98671eeaeae3a7e34d02..ed2f14ea9c00981386a3983474d0f4391530729d 100644 (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
index 29f270e0bc35c399c340669b9f8492e5a000b001..473254175a2be4411b1afb49b5a055776cfb39e0 100644 (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