unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: martin rudalics <rudalics@gmx.at>
Cc: 62592@debbugs.gnu.org
Subject: bug#62592: Not creating new Tabs with small window
Date: Thu, 18 May 2023 18:50:29 +0300	[thread overview]
Message-ID: <861qjd3agq.fsf@mail.linkov.net> (raw)
In-Reply-To: <493d0d56-2041-81cf-279e-6d6128b366e7@gmx.at> (martin rudalics's message of "Thu, 18 May 2023 10:30:12 +0200")

>> Thanks for the suggestion.  Empirically I found that
>> '(split-window-horizontally 1)' always fails.
>> So the next patch uses '(split-window-horizontally 2)'.
>
> 1 is less than 'window-safe-min-width' (the doc-string of 'split-window'
> says in this regard that "this function can make a new window as small
> as one line or two columns").  And are you sure you want to copy the
> 'quit-restore' parameter?  As a rule, in Lisp code never use the
> -vertically/-horizontally postfixed forms of 'split-window' unless you
> want to mock their interactive behavior.

Then the following patch seems the right way to implement this.

>>> For Emacs 30 I'd recommend a new routine say 'clean-window' to make its
>>> argument window pristine.  The way you do it now loses all overlays with
>>> a window property in the window's buffer.
>>
>> The purpose of this trick is to change window identity.  So maybe
>> a better name would be 'clone-window'?
>
> Funny - here I use that for a window that can shadow an existing window
> for redisplay purposes.  If you want the selected window to change
> identity, you should say that in a comment.

Actually, there are 2 cases:

1. when 'tab-bar-new-tab-choice' is not equal to 'window'
   then need to remove all old window parameters and
   create a new window, this is what split-window/delete-window do;

2. when 'tab-bar-new-tab-choice' is 'window', then need to create
   a new identity that keeps all window parameters, this is done by:
   (window-state-put (window-state-get))
   And comments are trying to explain this.

diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index 9d703b5d048..aae80b28047 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -1585,7 +1585,8 @@ tab-bar-new-tab-to
               (window-state-put (window-state-get))
             ;; Create a new window to get rid of old window parameters
             ;; (e.g. prev/next buffers) of old window.
-            (split-window) (delete-window))))
+            (split-window nil window-safe-min-width t)
+            (delete-window))))
 
       (let ((buffer
              (if (and (functionp tab-bar-new-tab-choice)
diff --git a/lisp/window.el b/lisp/window.el
index aa7520f30fa..ab7dd5ced12 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -6391,7 +6391,7 @@ window-state-put
                      (selected-window)))
       (delete-other-windows-internal window root)
       ;; Create a new window to replace the existing one.
-      (setq window (prog1 (split-window window)
+      (setq window (prog1 (split-window window window-safe-min-width t)
                      (delete-window window)))))
 
   (set-window-dedicated-p window nil)





  reply	other threads:[~2023-05-18 15:50 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-01 12:48 bug#62592: Not creating new Tabs with small window Claudio Grondi
2023-04-02  6:52 ` Juri Linkov
2023-04-02 17:49   ` Juri Linkov
2023-04-02 18:02     ` Eli Zaretskii
2023-04-25 17:28       ` Juri Linkov
2023-05-16 17:34     ` Juri Linkov
2023-05-17  7:07       ` martin rudalics
2023-05-17 16:46         ` Juri Linkov
2023-05-18  8:30           ` martin rudalics
2023-05-18 15:50             ` Juri Linkov [this message]
2023-05-19  7:31               ` martin rudalics
2023-05-19 18:04                 ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=861qjd3agq.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=62592@debbugs.gnu.org \
    --cc=rudalics@gmx.at \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).