* question about pop-to-buffer
@ 2012-09-29 13:10 Thierry Volpiatto
2012-09-29 19:11 ` martin rudalics
0 siblings, 1 reply; 9+ messages in thread
From: Thierry Volpiatto @ 2012-09-29 13:10 UTC (permalink / raw
To: emacs-devel
Hi,
how can I set pop-to-buffer action arg to create the new window on top
and not on bottom of current window and split the windows equally.
I tried with this:
#+BEGIN_SRC lisp
(pop-to-buffer (get-buffer-create "*toto*")
'(display-buffer-in-side-window . ((side . top) (slot . 0))))
#+END_SRC
I tried several values for slot but it seem to have no effect.
Also if I have two windows the second one is not reused, a new one is
created instead. (but maybe is what `display-buffer-in-side-window' for
?)
Thanks.
--
Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: question about pop-to-buffer
2012-09-29 13:10 question about pop-to-buffer Thierry Volpiatto
@ 2012-09-29 19:11 ` martin rudalics
2012-09-29 19:20 ` Thierry Volpiatto
2012-09-30 10:48 ` martin rudalics
0 siblings, 2 replies; 9+ messages in thread
From: martin rudalics @ 2012-09-29 19:11 UTC (permalink / raw
To: Thierry Volpiatto; +Cc: emacs-devel
> how can I set pop-to-buffer action arg to create the new window on top
> and not on bottom of current window and split the windows equally.
Side windows serve a different purpose and don't care about the selected
window. Moreover you can't set their heights and widths individually:
All side windows on the left or right get the same width once set, all
side windows on the top or bottom have the same height. And you
currently can't set the size of the first window at some side because
there's a bug in `display-buffer-in-major-side-window' :-(
So in `display-buffer-in-major-side-window' you have to replace
(size (or (assq 'size alist)
by
(size (or (cdr (assq 'size alist))
and then use for example
(pop-to-buffer
(get-buffer-create "*toto*")
`(display-buffer-in-side-window . ((side . top) (size . ,(/ (window-total-size (selected-window)) 2)) (slot . 0))))
which is clumsy and won't work if a window of that size exists already.
Interpreting your request literally with "selected" substituting
"current", I suppose the following should do what you want:
(let ((split-window-preferred-function
#'(lambda (window) (split-window (selected-window) nil 'above))))
(pop-to-buffer (get-buffer-create "*toto*")))
> Also if I have two windows the second one is not reused, a new one is
> created instead. (but maybe is what `display-buffer-in-side-window' for
> ?)
I suppose you have to customize `window-sides-slots' appropriately.
martin
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: question about pop-to-buffer
2012-09-29 19:11 ` martin rudalics
@ 2012-09-29 19:20 ` Thierry Volpiatto
2012-09-30 10:48 ` martin rudalics
1 sibling, 0 replies; 9+ messages in thread
From: Thierry Volpiatto @ 2012-09-29 19:20 UTC (permalink / raw
To: martin rudalics; +Cc: emacs-devel
martin rudalics <rudalics@gmx.at> writes:
>> how can I set pop-to-buffer action arg to create the new window on top
>> and not on bottom of current window and split the windows equally.
>
> Side windows serve a different purpose and don't care about the selected
> window. Moreover you can't set their heights and widths individually:
> All side windows on the left or right get the same width once set, all
> side windows on the top or bottom have the same height. And you
> currently can't set the size of the first window at some side because
> there's a bug in `display-buffer-in-major-side-window' :-(
>
> So in `display-buffer-in-major-side-window' you have to replace
>
> (size (or (assq 'size alist)
>
> by
>
> (size (or (cdr (assq 'size alist))
>
> and then use for example
>
> (pop-to-buffer
> (get-buffer-create "*toto*")
> `(display-buffer-in-side-window . ((side . top) (size . ,(/ (window-total-size (selected-window)) 2)) (slot . 0))))
>
> which is clumsy and won't work if a window of that size exists already.
>
> Interpreting your request literally with "selected" substituting
> "current", I suppose the following should do what you want:
>
> (let ((split-window-preferred-function
> #'(lambda (window) (split-window (selected-window) nil 'above))))
> (pop-to-buffer (get-buffer-create "*toto*")))
>
>> Also if I have two windows the second one is not reused, a new one is
>> created instead. (but maybe is what `display-buffer-in-side-window' for
>> ?)
>
> I suppose you have to customize `window-sides-slots' appropriately.
Many thanks to take the time to clarify all this.
--
Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: question about pop-to-buffer
2012-09-29 19:11 ` martin rudalics
2012-09-29 19:20 ` Thierry Volpiatto
@ 2012-09-30 10:48 ` martin rudalics
2012-09-30 11:03 ` Thierry Volpiatto
1 sibling, 1 reply; 9+ messages in thread
From: martin rudalics @ 2012-09-30 10:48 UTC (permalink / raw
To: Thierry Volpiatto; +Cc: emacs-devel
> And you
> currently can't set the size of the first window at some side because
> there's a bug in `display-buffer-in-major-side-window' :-(
This has been fixed now, hopefully.
> (pop-to-buffer
> (get-buffer-create "*toto*")
> `(display-buffer-in-side-window . ((side . top) (size . ,(/
> (window-total-size (selected-window)) 2)) (slot . 0))))
You now have to use something like
(pop-to-buffer
(get-buffer-create "*toto*")
`(display-buffer-in-side-window . ((side . top) (window-height . ,(/ (window-total-size (selected-window)) 2)) (slot . 0))))
martin
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: question about pop-to-buffer
2012-09-30 10:48 ` martin rudalics
@ 2012-09-30 11:03 ` Thierry Volpiatto
2012-09-30 14:23 ` martin rudalics
0 siblings, 1 reply; 9+ messages in thread
From: Thierry Volpiatto @ 2012-09-30 11:03 UTC (permalink / raw
To: martin rudalics; +Cc: emacs-devel
martin rudalics <rudalics@gmx.at> writes:
>> And you
>> currently can't set the size of the first window at some side because
>> there's a bug in `display-buffer-in-major-side-window' :-(
>
> This has been fixed now, hopefully.
Cool.
>> (pop-to-buffer
>> (get-buffer-create "*toto*")
>> `(display-buffer-in-side-window . ((side . top) (size . ,(/
>> (window-total-size (selected-window)) 2)) (slot . 0))))
>
> You now have to use something like
>
> (pop-to-buffer
> (get-buffer-create "*toto*")
> `(display-buffer-in-side-window . ((side . top) (window-height . ,(/ (window-total-size (selected-window)) 2)) (slot . 0))))
Ok good to know, thanks, however I have removed the variable that was
handling that, and I can manage splitting the windows in helm only using
`split-window-preferred-function' following your advice (I use a
specialized function for this).
Also, I have noticed that window-right/left can also handle vertical
splitting (I.e I was looking for something like window-above/bottom and
I discover that window-right/left do this).
Maybe that can be documented somewhere?
Thanks for your help.
--
Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: question about pop-to-buffer
2012-09-30 11:03 ` Thierry Volpiatto
@ 2012-09-30 14:23 ` martin rudalics
2012-09-30 18:37 ` Thierry Volpiatto
0 siblings, 1 reply; 9+ messages in thread
From: martin rudalics @ 2012-09-30 14:23 UTC (permalink / raw
To: Thierry Volpiatto; +Cc: emacs-devel
> Also, I have noticed that window-right/left can also handle vertical
> splitting (I.e I was looking for something like window-above/bottom and
> I discover that window-right/left do this).
> Maybe that can be documented somewhere?
No, and I probably should have called them window--right and
window--left, but I faintly recall having called them from somewhere
outside window.el. These functions are only useful to avoid writing
(and window (window-parent window) (window-next-sibling window)))
which is needed for technical reasons because usually the minibuffer
window is the "sibling" of the frame's root window and the window tree
functions should not work on the minibuffer window. Anyone interested
finds the rationale in the comment preceding `window-right'.
The functions you are interested in are either
`window-next-sibling' and `window-prev-sibling' plus `window-combined-p'
where the latter is needed to find out whether any such sibling is
horizontally or vertically aligned - an information `window-right' and
`window-left' won't give you anyway, or
`window-in-direction'.
If you tell me more precisely how you want to use them, I can provide
more information.
martin
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: question about pop-to-buffer
2012-09-30 14:23 ` martin rudalics
@ 2012-09-30 18:37 ` Thierry Volpiatto
2012-10-01 15:48 ` martin rudalics
0 siblings, 1 reply; 9+ messages in thread
From: Thierry Volpiatto @ 2012-09-30 18:37 UTC (permalink / raw
To: martin rudalics; +Cc: emacs-devel
martin rudalics <rudalics@gmx.at> writes:
>> Also, I have noticed that window-right/left can also handle vertical
>> splitting (I.e I was looking for something like window-above/bottom and
>> I discover that window-right/left do this).
>> Maybe that can be documented somewhere?
>
> No, and I probably should have called them window--right and
> window--left, but I faintly recall having called them from somewhere
> outside window.el. These functions are only useful to avoid writing
>
> (and window (window-parent window) (window-next-sibling window)))
>
> which is needed for technical reasons because usually the minibuffer
> window is the "sibling" of the frame's root window and the window tree
> functions should not work on the minibuffer window. Anyone interested
> finds the rationale in the comment preceding `window-right'.
>
> The functions you are interested in are either
>
> `window-next-sibling' and `window-prev-sibling' plus `window-combined-p'
> where the latter is needed to find out whether any such sibling is
> horizontally or vertically aligned - an information `window-right' and
> `window-left' won't give you anyway, or
>
> `window-in-direction'.
>
> If you tell me more precisely how you want to use them, I can provide
> more information.
I want a function that return the window at the left of the selected one
or nil if none.
Same for above, right, below.
If a window is returned I use it, otherwise (nil) I use the selected
one.
Actually I use window-left/right and it works fine, but IIUC, I don't
need the first checking:
(and window (window-parent window) (window-next-sibling window)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I can use directly window-next/prev-sibling, right?
--
Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: question about pop-to-buffer
2012-09-30 18:37 ` Thierry Volpiatto
@ 2012-10-01 15:48 ` martin rudalics
2012-10-01 16:17 ` Thierry Volpiatto
0 siblings, 1 reply; 9+ messages in thread
From: martin rudalics @ 2012-10-01 15:48 UTC (permalink / raw
To: Thierry Volpiatto; +Cc: emacs-devel
> I want a function that return the window at the left of the selected one
> or nil if none.
> Same for above, right, below.
Then I suppose `window-in-direction' is the function you want.
> If a window is returned I use it, otherwise (nil) I use the selected
> one.
>
> Actually I use window-left/right and it works fine, but IIUC, I don't
> need the first checking:
> (and window (window-parent window) (window-next-sibling window)))
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> I can use directly window-next/prev-sibling, right?
Probably. But note that in a one-window frame after C-x 3 evaluating
(window-next-sibling) gets you the window on the right. If you now do
C-x 2 and then evaluate (window-next-sibling) you get the window below.
martin
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: question about pop-to-buffer
2012-10-01 15:48 ` martin rudalics
@ 2012-10-01 16:17 ` Thierry Volpiatto
0 siblings, 0 replies; 9+ messages in thread
From: Thierry Volpiatto @ 2012-10-01 16:17 UTC (permalink / raw
To: martin rudalics; +Cc: emacs-devel
martin rudalics <rudalics@gmx.at> writes:
>> I want a function that return the window at the left of the selected one
>> or nil if none.
>> Same for above, right, below.
>
> Then I suppose `window-in-direction' is the function you want.
Yes I finally use this one, works very well, thanks.
--
Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2012-10-01 16:17 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-29 13:10 question about pop-to-buffer Thierry Volpiatto
2012-09-29 19:11 ` martin rudalics
2012-09-29 19:20 ` Thierry Volpiatto
2012-09-30 10:48 ` martin rudalics
2012-09-30 11:03 ` Thierry Volpiatto
2012-09-30 14:23 ` martin rudalics
2012-09-30 18:37 ` Thierry Volpiatto
2012-10-01 15:48 ` martin rudalics
2012-10-01 16:17 ` Thierry Volpiatto
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.