emacs-devel
[Top][All Lists]
Advanced

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

Re: managing windows in two frames


From: martin rudalics
Subject: Re: managing windows in two frames
Date: Tue, 03 Sep 2013 14:52:29 +0200

> (defun display-buffer-reuse-frame (buffer alist)

I'd call it `display-buffer-other-frame' ("reuse" currently has the
connotation that a window already displays the buffer in question).

>   "Display BUFFER in an existing frame other than the current frame.
> If successful, return the window used; otherwise return nil.
>
> If ALIST has a non-nil `inhibit-switch-frame' entry, avoid
> raising the frame.
>
> If ALIST has a non-nil `pop-up-frame-parameters' entry, the
> corresponding value is an alist of frame parameters to give the
> new frame."
>   (let* ((frame (car (filtered-frame-list

This is overly restrictive.  We should be able to choose any window on
any frame.  If necessary, we can invent a new alist element for picking
a frame.

>                  (lambda (frame)
>                    (and
>                     (not (eq frame (selected-frame)))
>                     (not (window-dedicated-p
>                           (or
>                            (get-lru-window frame)
>                            (frame-first-window frame)))))))))

The lru and first window of that frame could denote the same window.
Here too we can add a new alist element for picking the window.

>     (window
>      (and frame
>           (or
>            (get-lru-window frame)
>            ;; lru-window can be nil if window was deleted, by ediff for 
example

Can you give a scenario?  `get-lru-window' doesn't consider/return
deleted windows IIRC.  It can return nil if all windows are dedicated or
slelected.

>            (frame-first-window frame-2))))

What is frame-2 ?

>     )
>     (when window
>       (prog1 (window--display-buffer
>          buffer window 'frame alist display-buffer-mark-dedicated)
>    (unless (cdr (assq 'inhibit-switch-frame alist))
>      (window--maybe-raise-frame frame))))
>     ))
>
> (defun display-buffer-other-window-or-frame (buffer alist)
>   "Depending on `current-prefix-arg', show BUFFER in another window or frame.
> If current-prefix-arg is:
> '(4) - from C-u; show buffer in another window in current frame, creating new 
if needed.
> '(16) - from C-u C-u; show buffer in another frame, creating new if needed.
> other - return nil."

`display-buffer' decisions are currently not based on a prefix argument
given.  Maybe we can reconcile your idea with Stefan's proposal to use
special prefixes for `display-buffer'-based functions.

>   (or
>    (cond
>     ((equal current-prefix-arg '(4)) ;; other window
>      (or (display-buffer-use-some-window buffer '((inhibit-same-window . t)))
>     (display-buffer-pop-up-window buffer nil)))
>
>     ((equal current-prefix-arg '(16)) ;; other frame
>      (or (display-buffer-reuse-frame buffer '((reusable-frames . visible)))   
;; reuse a window in other frame
>     (display-buffer-pop-up-frame buffer nil)))
>
>     (t nil)
>
>     )))
>
> (defun sal-move-to-other-frame ()
>   "Move current buffer to a window in another frame."
>   (interactive)
>   (let ((buffer (current-buffer)))
>     (switch-to-prev-buffer nil 'bury)
>     (let ((display-buffer-overriding-action
>       '((display-buffer-reuse-frame buffer display-buffer-pop-up-frame)
>         . '((reusable-frames . visible)))))   ;; reuse a window in other frame
>       (display-buffer buffer))))
>
>
> The use case for these:
>
> I use two Emacs frames, side by side, filling the screen. This allows
> two things:
>
> 1) opening other applications next to an Emacs frame

If Emacs fills the screen there doesn't seem much space left for other
applications ;-)

> 2) navigating between frames for horizontal movement (using window
> manager keys), and between windows for vertical movement (using Emacs
> keys).
>
> With one Emacs frame, split both horizontally and vertically, I find it
> difficult to navigate among the windows.

I'm using M-S-left, M-S-up ... to navigate to the window in that
direction.

> `display-buffer-reuse-frame' allows displaying a buffer in the other
> frame, without always creating a new frame.

Such functionality is missing, indeed.

> `display-buffer-other-window-or-frame' gives the user flexible control
> of all buffer display functions, via the prefix arg.

We have to decide how to integrate pefix arguments in buffer display
functions.  So far, I don't know of a proposal that allows, for example,
to use the "same" window, thus overriding an application that wants to
display the buffer in another window.

martin



reply via email to

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