Subject: Re: bug#75828: [PATCH] Correct make-frame docstring vis-a-vis make_frame.c

From: martin rudalics <[email-masked]>
Date: Mon, 27 Jan 2025 19:00:55 +0100

> These are the two options on the table?
 >
 > (let ((frame-inhibit-make-frame-hidden-buffer-check t))
 >    (with-current-buffer " *string-pixel-width*"
 >      (make-frame)))
 > ;; could also do this if users want the behavior all the time
 > (setq frame-inhibit-make-frame-hidden-buffer-check t)
 >
 > (with-current-buffer " *string-pixel-width*"
 >    (setq-local frame-inhibit-make-frame-hidden-buffer-check t)
 >    (make-frame)
 >    (kill-local-variable 'frame-inhibit-make-frame-hidden-buffer-check))
 >
 > I prefer the former over the latter.

I prefer these ones

(let ((frame-inhibit-make-frame-hidden-buffer-check t))
   (with-current-buffer " *string-pixel-width*"
     (make-frame)))

;; Set the default for all buffers.
(setq-default frame-inhibit-make-frame-hidden-buffer-check t)

;; Set the buffer-local value.
(with-current-buffer " *string-pixel-width*"
   (setq frame-inhibit-make-frame-hidden-buffer-check t))

with the attached patch.

 > It seems harmonious with other
 > frame-related controls such as frame-resize-pixelwise
 > and frame-inhibit-implied-resize, unless I'm missing some subtlety, which I
 > surely am.

The subtlety is that a leading space in a buffer name is a buffer-local
property, a property which affects only the buffer wearing that name and
no other buffers.

'frame-resize-pixelwise' and 'frame-inhibit-implied-resize' are (or
better should be) frame properties, properties that affect a frame and
consequently all buffers displayed on that frame.

martin

diff --git a/src/frame.c b/src/frame.c
index dbed3f940fb..c59119976c8 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -1095,7 +1095,8 @@ 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 (BUFFER_HIDDEN_P (XBUFFER (buf))
+	&& NILP (frame_inhibit_make_frame_hidden_buffer_check))
       buf = other_buffer_safely (buf);
 
     /* Use set_window_buffer, not Fset_window_buffer, and don't let
@@ -7166,6 +7167,14 @@ focus (where a frame immediately loses focus when it's left by the mouse
 iconify the top level frame instead.  */);
   iconify_child_frame = Qiconify_top_level;
 
+  DEFVAR_LISP ("frame-inhibit-make-frame-hidden-buffer-check",
+	       frame_inhibit_make_frame_hidden_buffer_check,
+	       doc: /* Non-nil means 'make-frame' should not consider buffer as hidden.  */);
+  frame_inhibit_make_frame_hidden_buffer_check = Qnil;
+  DEFSYM (Qframe_inhibit_make_frame_hidden_buffer_check,
+	  "frame-inhibit-make-frame-hidden-buffer-check");
+  Fmake_variable_buffer_local (Qframe_inhibit_make_frame_hidden_buffer_check);
+
   DEFVAR_LISP ("frame-internal-parameters", frame_internal_parameters,
 	       doc: /* Frame parameters specific to every frame.  */);
 #ifdef HAVE_X_WINDOWS