bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#19170: 25.0.50; enhancement request: `compare-windows' use across fr


From: Drew Adams
Subject: bug#19170: 25.0.50; enhancement request: `compare-windows' use across frames
Date: Tue, 25 Nov 2014 14:00:25 -0800 (PST)

> > How to choose?  Click the mouse in a window,
> 
> This is what `ediff-get-window-by-clicking' does.

Yes.

> But what to do if the user doesn't use the mouse?

See next.

> > or choose a window by name using the keyboard -
> > those are two possibilities I suggested.
> 
> You mean to choose a window by it's buffer name?
> I.e. like `ediff-buffers'?  But the problem is that the
> uniqueness of buffer names is not guaranteed in this case.

See what I wrote at the outset:

  Choosing a window could take any reasonable form: click mouse-1
  in it, choose by its buffer name (with uniquification when
  multiple windows show the same buffer),...

FWIW, I use this in Icicles.  Maybe it helps to give an idea what
I had in mind wrt window naming.  If not, ignore.

(defun icicle-make-window-alist (&optional all-p)
  "Return an alist of entries (WNAME . WINDOW), where WNAME names WINDOW.
The name of the buffer in a window is used as its name, unless there
is more than one window displaying the same buffer.  In that case,
WNAME includes a suffix [NUMBER], to make it a unique name.  The
NUMBER order among window names that differ only by their [NUMBER] is
arbitrary.

Argument ALL-P determines which frames to use when gathering windows,
as follows:

* `visible'         - include windows from all visible frames.
* otherwise non-nil - include windows from all frames (including
                      those that are iconified and invisible).
* nil               - include only windows from the selected frame."
  (lexical-let ((win-alist  ())
                (count      2)
                wname new-name)
    (walk-windows
     (lambda (w)            ; FREE here: COUNT, NEW-NAME, WIN-ALIST, WNAME.
       (setq wname  (buffer-name (window-buffer w)))
       (if (not (assoc wname win-alist))
           (push (cons wname w) win-alist)
         (setq new-name  wname)
         (while (assoc new-name win-alist)
           (setq new-name  (format "%s[%d]" wname count)
                 count     (1+ count)))
         (push (cons new-name w) win-alist))
       (setq count  2))
     'no-mini
     (case all-p
       (visible 'visible)
       ((nil)   'this-frame)
       (otherwise  t)))
    win-alist))

> What do you think about such workflow: select a target window
> using normal keybindings or mouse clicks.  Then mark the
> selected window as the target window using a new prefix
> of `compare-windows'.  Then switch back to the original window
> using standard keybindings, and run `compare-windows'.
> It could use the remembered target window.

Not sure I understand what you describe, but it sounds like you
mean to just somehow select the other window (the one you want,
not `other-window'), then move back to the original window, and
have the fact that the other window was the previously selected
window let it be used as the default second window for the
comparison.

If so, yes, that's what I was suggesting by comparison with
Ediff.  With buffers it is enough to select another buffer, to
make it become recorded as the previous buffer, so it becomes
the default.

But that works because `buffer-list' records chronological access.
AFAIK, we do not have that (yet) for windows.  And yes, we need
only record the previously selected window, not a whole access
history (at least for this command).

This would be for the click-in-another-window approach.  But
for keyboard use the problem really is, as I see it, that when
there are many windows (this is across possibly many frames)
the usual way to select one of them, which is to repeat `C-x o',
is tedious.  That's why I suggested choosing by name in this case.

HTH.





reply via email to

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