unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Any way to prevent window splits for a window or a major-mode
@ 2017-12-01 21:35 Robert Weiner
  2017-12-01 21:40 ` Eric Abrahamsen
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Robert Weiner @ 2017-12-01 21:35 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 394 bytes --]

I have looked through the Windows sections of the Elisp manual but did not
see an option that would do this specifically, though I imagine it must be
there.

For a window, I would like to be able to mark it so it is never split.
For a major mode, I would like to say for any windows displaying buffers in
this major mode, don't split them.

Is there a simple way to program that?

Thanks,

Bob

[-- Attachment #2: Type: text/html, Size: 1234 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Any way to prevent window splits for a window or a major-mode
  2017-12-01 21:35 Robert Weiner
@ 2017-12-01 21:40 ` Eric Abrahamsen
  2017-12-01 21:57 ` Drew Adams
  2017-12-02 10:17 ` martin rudalics
  2 siblings, 0 replies; 13+ messages in thread
From: Eric Abrahamsen @ 2017-12-01 21:40 UTC (permalink / raw)
  To: emacs-devel

Robert Weiner <rsw@gnu.org> writes:

> I have looked through the Windows sections of the Elisp manual but did not see an option that would do this specifically, though I imagine it must be there.
>
> For a window, I would like to be able to mark it so it is never split.
> For a major mode, I would like to say for any windows displaying buffers in this major mode, don't split them.
>
> Is there a simple way to program that?

You might look at the Atomic Windows and Preserving Window Sizes
sections of the manual. My guess is something in there would do it.

Yours,
Eric




^ permalink raw reply	[flat|nested] 13+ messages in thread

* RE: Any way to prevent window splits for a window or a major-mode
  2017-12-01 21:35 Robert Weiner
  2017-12-01 21:40 ` Eric Abrahamsen
@ 2017-12-01 21:57 ` Drew Adams
  2017-12-02 10:17 ` martin rudalics
  2 siblings, 0 replies; 13+ messages in thread
From: Drew Adams @ 2017-12-01 21:57 UTC (permalink / raw)
  To: rswgnu, emacs-devel

> I have looked through the Windows sections of the Elisp
> manual but did not see an option that would do this
> specifically, though I imagine it must be there.
>
> For a window, I would like to be able to mark it so it
> is never split.
>
> For a major mode, I would like to say for any windows
> displaying buffers in this major mode, don't split them.
>
> Is there a simple way to program that?

I'm no expert on this.  I just took a look at predicate
`window-splittable-p', and a first impression tells me
that you can set `window-size-fixed' to `t' in a given
buffer/mode to make it unsplittable.  But it apparently
applies to all windows showing the buffer, and I see no
way to apply that to a single window.

I see too (in (elisp) `Splitting Windows') that there is
window parameter `split-window', which it seems like
you can use to prevent a given window from being split.

Someone more familiar with this stuff will hopefully
chime in.



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Any way to prevent window splits for a window or a major-mode
  2017-12-01 21:35 Robert Weiner
  2017-12-01 21:40 ` Eric Abrahamsen
  2017-12-01 21:57 ` Drew Adams
@ 2017-12-02 10:17 ` martin rudalics
  2017-12-04 13:44   ` Robert Weiner
  2 siblings, 1 reply; 13+ messages in thread
From: martin rudalics @ 2017-12-02 10:17 UTC (permalink / raw)
  To: rswgnu, emacs-devel

 > For a window, I would like to be able to mark it so it is never split.

The most simple approach is the one Drew mentioned, something like

(set-window-parameter nil 'split-window #'ignore)

for the selected window.  But this might be too strong with functions
(like `display-buffer') that expect a window to be splittable if it's
just large enough.  So fixing the window size by setting its buffer's
`window-size-fixed' variable or the window's 'window-preserved-size'
parameter as Eric suggested could be more appropriate.  But maybe you
should tell us more about the case where you need such a property -
`split-window' is just the Emacs paradigm for creating a new window
adjacent to an existing one.

 > For a major mode, I would like to say for any windows displaying buffers in
 > this major mode, don't split them.
 >
 > Is there a simple way to program that?

You will have to put a function on `window-configuration-change-hook'
which runs through every window and, if it displays a buffer in that
major mode, sets the 'split-window' parameter of that window to 'ignore'
or preserves that window's size.  And obviously the major mode hook
would have to add/remove that parameter for every window showing a
buffer where that mode is turned on/off.

martin



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Any way to prevent window splits for a window or a major-mode
  2017-12-02 10:17 ` martin rudalics
@ 2017-12-04 13:44   ` Robert Weiner
  2017-12-05  8:53     ` martin rudalics
  0 siblings, 1 reply; 13+ messages in thread
From: Robert Weiner @ 2017-12-04 13:44 UTC (permalink / raw)
  To: martin rudalics; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 747 bytes --]

>  But maybe you should tell us more about the case where you need such a
property -
> `split-window' is just the Emacs paradigm for creating a new window adjacent
to an
> existing one.

​The Treemacs package displays a full-frame height window at
the left of the frame that can be used to browse directories
in an outline fashion.  It has some features that make it
attractive at times beyond just using Dired (it also can be
used in tandem with Dired).

Treemacs uses treemacs-mode for its buffers.  So I want any
window with a buffer in that mode to be non-splittable since
it is narrow and it doesn't make sense to split it in either
dimension.

Thanks for the initial pointers.  Martin's pointers sound
promising.

Bob

[-- Attachment #2: Type: text/html, Size: 2554 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Any way to prevent window splits for a window or a major-mode
  2017-12-04 13:44   ` Robert Weiner
@ 2017-12-05  8:53     ` martin rudalics
  2017-12-05 17:04       ` Robert Weiner
  0 siblings, 1 reply; 13+ messages in thread
From: martin rudalics @ 2017-12-05  8:53 UTC (permalink / raw)
  To: rswgnu; +Cc: emacs-devel

 > ​The Treemacs package displays a full-frame height window at
 > the left of the frame that can be used to browse directories
 > in an outline fashion.  It has some features that make it
 > attractive at times beyond just using Dired (it also can be
 > used in tandem with Dired).
 >
 > Treemacs uses treemacs-mode for its buffers.  So I want any
 > window with a buffer in that mode to be non-splittable since
 > it is narrow and it doesn't make sense to split it in either
 > dimension.

You might consider two opportunities here: If the treemacs window is
"frame bound", then it's probably best to make it a side window so that
C-x 1 does not delete it and it does not become the sole window of the
frame.  If the treemacs window is "window bound" (so that two or more
treemacs windows may appear simultaneously on a frame), it might be
better to attach the treemacs window to some other "normal" window and
make these two windows atomic.

martin




^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Any way to prevent window splits for a window or a major-mode
  2017-12-05  8:53     ` martin rudalics
@ 2017-12-05 17:04       ` Robert Weiner
  2017-12-06  8:56         ` martin rudalics
  0 siblings, 1 reply; 13+ messages in thread
From: Robert Weiner @ 2017-12-05 17:04 UTC (permalink / raw)
  To: martin rudalics; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1179 bytes --]

On Tue, Dec 5, 2017 at 3:53 AM, martin rudalics <rudalics@gmx.at> wrote:

> > ​The Treemacs package displays a full-frame height window at
> > the left of the frame that can be used to browse directories
> > in an outline fashion.  It has some features that make it
> > attractive at times beyond just using Dired (it also can be
> > used in tandem with Dired).
> >
> > Treemacs uses treemacs-mode for its buffers.  So I want any
> > window with a buffer in that mode to be non-splittable since
> > it is narrow and it doesn't make sense to split it in either
> > dimension.
>
> You might consider two opportunities here: If the treemacs window is
> "frame bound", then it's probably best to make it a side window so that
> C-x 1 does not delete it and it does not become the sole window of the
> frame.

​​

​It is frame-bound.  I tested display-buffer-in-side-window
and that did the trick.  Thanks.  Is set-window-dedicate-p
also needed or does the side window setup take care of that?

If you don't want delete-other-windows to delete this window,
then also add:

(set-window-parameter (selected-window) 'no-delete-other-windows t)

Bob

[-- Attachment #2: Type: text/html, Size: 2767 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Any way to prevent window splits for a window or a major-mode
@ 2017-12-05 22:45 Robert Weiner
  2017-12-06  8:56 ` martin rudalics
  2017-12-06 18:11 ` Richard Stallman
  0 siblings, 2 replies; 13+ messages in thread
From: Robert Weiner @ 2017-12-05 22:45 UTC (permalink / raw)
  To: emacs-devel; +Cc: Eli Zaretskii, Richard Stallman

[-- Attachment #1: Type: text/plain, Size: 992 bytes --]

On Fri, Dec 1, 2017 at 4:35 PM, Robert Weiner <rsw@gnu.org> wrote:

> I have looked through the Windows sections of the Elisp manual but did not
> see an option that would do this specifically
>

​Now that we have resolved this issue by utilizing
display-buffer-in-side-window, I went back to the Elisp manual to see why I
did not
find this.  I was looking for information related to preserving the display
of a window and window splitting.  That led me to
both the sections on "Preserving Window Sizes" and "Splitting Windows"
neither of which have references to the sections on
Side Windows or Atomic Windows.

The last two paragraphs in the "Displaying Buffers in Side Windows" section
are key to understanding that one would want
to use a side window when a non-splittable window is desired.  I think a
mention of that (and/or link) should be added near the
beginning of the "Splitting Windows" section.  It might save others a lot
of time.

Regards,

Bob

>

[-- Attachment #2: Type: text/html, Size: 2604 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Any way to prevent window splits for a window or a major-mode
  2017-12-05 17:04       ` Robert Weiner
@ 2017-12-06  8:56         ` martin rudalics
  2017-12-06 15:44           ` Robert Weiner
  0 siblings, 1 reply; 13+ messages in thread
From: martin rudalics @ 2017-12-06  8:56 UTC (permalink / raw)
  To: rswgnu; +Cc: emacs-devel

 > ​It is frame-bound.  I tested display-buffer-in-side-window
 > and that did the trick.  Thanks.  Is set-window-dedicate-p
 > also needed or does the side window setup take care of that?

`set-window-dedicated-p' (with a "d") is not needed.  Another buffer may
appear in this window if and only if it has been set up to use the same
side and slot.

 > If you don't want delete-other-windows to delete this window,
 > then also add:
 >
 > (set-window-parameter (selected-window) 'no-delete-other-windows t)

Indeed, see Bug#27999.

martin




^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Any way to prevent window splits for a window or a major-mode
  2017-12-05 22:45 Any way to prevent window splits for a window or a major-mode Robert Weiner
@ 2017-12-06  8:56 ` martin rudalics
  2017-12-06 18:11 ` Richard Stallman
  1 sibling, 0 replies; 13+ messages in thread
From: martin rudalics @ 2017-12-06  8:56 UTC (permalink / raw)
  To: rswgnu, emacs-devel

 > The last two paragraphs in the "Displaying Buffers in Side Windows" section
 > are key to understanding that one would want
 > to use a side window when a non-splittable window is desired.  I think a
 > mention of that (and/or link) should be added near the
 > beginning of the "Splitting Windows" section.  It might save others a lot
 > of time.

I added such links now.  However, keep in mind that due to its anarchic
nature Emacs will never allow to disallow splitting an existing window.
Categorically, at least.

martin



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Any way to prevent window splits for a window or a major-mode
  2017-12-06  8:56         ` martin rudalics
@ 2017-12-06 15:44           ` Robert Weiner
  2017-12-07  9:27             ` martin rudalics
  0 siblings, 1 reply; 13+ messages in thread
From: Robert Weiner @ 2017-12-06 15:44 UTC (permalink / raw)
  To: martin rudalics; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1230 bytes --]

On Wed, Dec 6, 2017 at 3:56 AM, martin rudalics <rudalics@gmx.at> wrote:

> > ​It is frame-bound.  I tested display-buffer-in-side-window
> > and that did the trick.  Thanks.  Is set-window-dedicate-p
> > also needed or does the side window setup take care of that?
>
> `set-window-dedicated-p' (with a "d") is not needed.  Another buffer may
> appear in this window if and only if it has been set up to use the same
> side and slot.


​Great.

In the doc string for display-buffer-in-side-window, it says: "Unless
‘display-buffer-mark-dedicated’ is non-nil, softly
dedicate the side window used to BUFFER."

No one will know what 'softly dedicate' means.  If it means what you said
above, that should be explained in the doc string too.
​

> ​​
>
> ​​
>
> ​​
> > If you don't want delete-other-windows to delete this window,
> ​​
> > then also add:
> ​​
> >
> ​​
> > (set-window-parameter (selected-window) 'no-delete-other-windows t)
> ​​
>
> ​​
> Indeed, see Bug#27999.


​Thanks for the pointer to some of the thinking that went into the design
of the side window feature.
It is working well for me in use with the Treemacs package.

Bob

[-- Attachment #2: Type: text/html, Size: 3578 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Any way to prevent window splits for a window or a major-mode
  2017-12-05 22:45 Any way to prevent window splits for a window or a major-mode Robert Weiner
  2017-12-06  8:56 ` martin rudalics
@ 2017-12-06 18:11 ` Richard Stallman
  1 sibling, 0 replies; 13+ messages in thread
From: Richard Stallman @ 2017-12-06 18:11 UTC (permalink / raw)
  To: rswgnu; +Cc: eliz, emacs-devel

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

In general, the Emacs facilities for controlling which windows can be split
need to be smarter.

-- 
Dr Richard Stallman
President, Free Software Foundation (https://gnu.org, https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)
Skype: No way! See https://stallman.org/skype.html.




^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Any way to prevent window splits for a window or a major-mode
  2017-12-06 15:44           ` Robert Weiner
@ 2017-12-07  9:27             ` martin rudalics
  0 siblings, 0 replies; 13+ messages in thread
From: martin rudalics @ 2017-12-07  9:27 UTC (permalink / raw)
  To: rswgnu; +Cc: emacs-devel

 >> `set-window-dedicated-p' (with a "d") is not needed.  Another buffer may
 >> appear in this window if and only if it has been set up to use the same
 >> side and slot.
 >
 >
 > ​Great.
 >
 > In the doc string for display-buffer-in-side-window, it says: "Unless
 > ‘display-buffer-mark-dedicated’ is non-nil, softly
 > dedicate the side window used to BUFFER."
 >
 > No one will know what 'softly dedicate' means.  If it means what you said
 > above, that should be explained in the doc string too.

It doesn't mean what I said above.  Setting the window's dedicated flag
makes sure that no other action functions reuse that window.

I hopefully managed to clarify the doc-string now.

Many thanks for your careful reading of doc and doc-strings, martin




^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2017-12-07  9:27 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-05 22:45 Any way to prevent window splits for a window or a major-mode Robert Weiner
2017-12-06  8:56 ` martin rudalics
2017-12-06 18:11 ` Richard Stallman
  -- strict thread matches above, loose matches on Subject: below --
2017-12-01 21:35 Robert Weiner
2017-12-01 21:40 ` Eric Abrahamsen
2017-12-01 21:57 ` Drew Adams
2017-12-02 10:17 ` martin rudalics
2017-12-04 13:44   ` Robert Weiner
2017-12-05  8:53     ` martin rudalics
2017-12-05 17:04       ` Robert Weiner
2017-12-06  8:56         ` martin rudalics
2017-12-06 15:44           ` Robert Weiner
2017-12-07  9:27             ` martin rudalics

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).