unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* How to force display-buffer-in-side-window to open side window on right?
@ 2023-02-02  5:46 Jean Louis
  2023-02-02  6:10 ` Bruno Barbier
  0 siblings, 1 reply; 3+ messages in thread
From: Jean Louis @ 2023-02-02  5:46 UTC (permalink / raw)
  To: Help GNU Emacs


I am trying to make function to provide 2 buffers in 2 windows, side
by side.

(defun rcd-two-windows (buffer-left buffer-right &optional window-register)
  "Display BUFFER-LEFT and BUFFER-RIGHT only.

Previous window configuration is saved register ?r or to optional
WINDOW-REGISTER.

Parent function may restore window configuration by using the
function `jump-to-register' with WINDOW-REGISTER as argument."
  (cond ((and (buffer-live-p buffer-left) (buffer-live-p buffer-right))
	 (let ((register (or window-register ?r)))
	   (window-configuration-to-register register)
	   (switch-to-buffer buffer-left)
	   (delete-other-windows)
	   (display-buffer-in-side-window buffer-right '(side right))))
	(t (user-error "Buffers `%s' and `%s' must be live" buffer-left buffer-right))))


However, with `emacs -Q' this below gives me window and smaller window
down on the bottom instead on right side

(let ((buffer-left (get-buffer-create "*My Left*"))
      (buffer-right (get-buffer-create "*My Right*")))
  (rcd-two-windows buffer-left buffer-right))

What am I doing wrong?


--
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



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

* Re: How to force display-buffer-in-side-window to open side window on right?
  2023-02-02  5:46 How to force display-buffer-in-side-window to open side window on right? Jean Louis
@ 2023-02-02  6:10 ` Bruno Barbier
  2023-02-02 19:38   ` Jean Louis
  0 siblings, 1 reply; 3+ messages in thread
From: Bruno Barbier @ 2023-02-02  6:10 UTC (permalink / raw)
  To: Jean Louis, Help GNU Emacs


Jean Louis <bugs@gnu.support> writes:

>
> What am I doing wrong?

At least the following line is wrong:

   	   (display-buffer-in-side-window buffer-right '(side right))

it should be:

       (display-buffer-in-side-window buffer-right '((side . right)))

Bruno



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

* Re: How to force display-buffer-in-side-window to open side window on right?
  2023-02-02  6:10 ` Bruno Barbier
@ 2023-02-02 19:38   ` Jean Louis
  0 siblings, 0 replies; 3+ messages in thread
From: Jean Louis @ 2023-02-02 19:38 UTC (permalink / raw)
  To: Bruno Barbier; +Cc: Help GNU Emacs

* Bruno Barbier <brubar.cs@gmail.com> [2023-02-02 21:13]:
> 
> Jean Louis <bugs@gnu.support> writes:
> 
> >
> > What am I doing wrong?
> 
> At least the following line is wrong:
> 
>    	   (display-buffer-in-side-window buffer-right '(side right))
> 
> it should be:
> 
>        (display-buffer-in-side-window buffer-right '((side . right)))

Thank you, that is good to understand.

Though I can see tha windows are not equal. So I changed it to:
  (switch-to-buffer-other-window buffer-right)))

and now it works well, but I am not sure how would that be affected by
user options.

(defun rcd-two-windows (buffer-left buffer-right &optional window-register)
  "Display BUFFER-LEFT and BUFFER-RIGHT only.

Previous window configuration is saved register ?r or to optional
WINDOW-REGISTER.

Parent function may restore window configuration by using the
function `jump-to-register' with WINDOW-REGISTER as argument."
  (cond ((and (buffer-live-p buffer-left) (buffer-live-p buffer-right))
	 (let ((register (or window-register ?r)))
	   (window-configuration-to-register register)
	   (switch-to-buffer buffer-left)
	   (delete-other-windows)
	   ;; (display-buffer-in-side-window buffer-right '((side . right)))))
	   (switch-to-buffer-other-window buffer-right)))
	(t (user-error "Buffers `%s' and `%s' must be live" buffer-left buffer-right))))


(let ((buffer-left (get-buffer-create "*My Left*"))
      (buffer-right (get-buffer-create "*My Right*")))
  (rcd-two-windows buffer-left buffer-right))

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



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

end of thread, other threads:[~2023-02-02 19:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-02  5:46 How to force display-buffer-in-side-window to open side window on right? Jean Louis
2023-02-02  6:10 ` Bruno Barbier
2023-02-02 19:38   ` Jean Louis

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