emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: question about pop-to-buffer


From: martin rudalics
Subject: Re: question about pop-to-buffer
Date: Sat, 29 Sep 2012 21:11:38 +0200

> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]