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

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

RE: naming and/or directly addressing particular windows?


From: Drew Adams
Subject: RE: naming and/or directly addressing particular windows?
Date: Sat, 1 Dec 2012 07:59:39 -0800

> Anyway:  is it possible to give/get a name for a window that persists
> long enough to be called in functions?

This might help:

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

Non-nil argument ALL-P means use windows from all visible frames.
Otherwise, use only windows from the selected frame."
  (lexical-let ((win-alist  ())
                (count      2)
                wname new-name)
    (walk-windows (lambda (w)
                    (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
                  (if all-p 'visible 'this-frame))
    win-alist))

(This is used in command `icicle-select-window-by-name', which in turn is the
action function for multi-command `icicle-select-window'.  Code here:
http://www.emacswiki.org/emacs-en/download/icicles-cmd1.el.)

I'm guessing that there are other, similar functions available on Emacs Wiki -
start here, perhaps: http://www.emacswiki.org/emacs/CategoryWindows




reply via email to

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