From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Matt Price Newsgroups: gmane.emacs.orgmode,gmane.emacs.help Subject: Re: naming and/or directly addressing particular windows? Date: Sun, 2 Dec 2012 00:31:52 -0500 Message-ID: References: <9480173485434C39B7ACE90E55A0FBD7@us.oracle.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: ger.gmane.org 1354426329 27184 80.91.229.3 (2 Dec 2012 05:32:09 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 2 Dec 2012 05:32:09 +0000 (UTC) Cc: Bastien , Help-gnu-emacs@gnu.org, Org Mode , drain To: Drew Adams Original-X-From: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sun Dec 02 06:32:22 2012 Return-path: Envelope-to: geo-emacs-orgmode@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Tf2A7-00039b-Dd for geo-emacs-orgmode@m.gmane.org; Sun, 02 Dec 2012 06:32:19 +0100 Original-Received: from localhost ([::1]:59360 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tf29v-0008Pr-Qw for geo-emacs-orgmode@m.gmane.org; Sun, 02 Dec 2012 00:32:07 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:39444) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tf29k-00082w-05 for emacs-orgmode@gnu.org; Sun, 02 Dec 2012 00:31:57 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tf29i-0006WQ-JB for emacs-orgmode@gnu.org; Sun, 02 Dec 2012 00:31:55 -0500 Original-Received: from mail-ie0-f169.google.com ([209.85.223.169]:42246) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tf29i-0006WM-E8; Sun, 02 Dec 2012 00:31:54 -0500 Original-Received: by mail-ie0-f169.google.com with SMTP id c14so3115682ieb.0 for ; Sat, 01 Dec 2012 21:31:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=kH95XGSN2zqkhBH9nTHRREE4yPizGdncMfRDm2xhRL4=; b=f3f6ZjQm2FNaPB9vpHBJ9tNh6oXzjgfAWp/aYb/HeAD55IiAffjVs5sKLZ1Ro0j8Ys h/pLPn//o5X/HbheY7X3pvtfJ+rhWaIlYRm8Aypo/dUSD/vmdDxLfatelmmbUNYFHur9 LLQlMyAEK0+AYp43p+WYyNRy5Q85P39D8X24FkjcbDtMw9vokuwAUd+dyWTj5BDonj7Z OVUaGIO88nL11xjOqhhxF7PV3hfeVILvLHx7ZaeEcb1rWFoHlQHhcg3bMDn2Mj45SKa/ v7derAhyiBrsmh+hKtzw5PLeSPQBeeU4kXdzVgKSLrANE2lZzLU39Ak115sHQ3xU3LCS A6UA== Original-Received: by 10.50.150.235 with SMTP id ul11mr3077395igb.31.1354426313117; Sat, 01 Dec 2012 21:31:53 -0800 (PST) Original-Received: by 10.64.176.166 with HTTP; Sat, 1 Dec 2012 21:31:52 -0800 (PST) In-Reply-To: <9480173485434C39B7ACE90E55A0FBD7@us.oracle.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.223.169 X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Original-Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.orgmode:63004 gmane.emacs.help:88015 Archived-At: On Sat, Dec 1, 2012 at 10:59 AM, Drew Adams wrote: >> 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 > I'm slowly starting to understand. I now have this primitive code, which at least sets up the windows the way I want them: (defun my-windows-function () "Trying to figure out how to get a nice windows config for writers-room-mode" (interactive ) (global-linum-mode 0) (delete-other-windows) (setq my-this-win (selected-window)) (setq my-winlist '()) (add-to-list 'my-winlist (cons 'guide (selected-window)) ) (split-window-horizontally) (fix-window-horizontal-size 35) (windmove-right) (add-to-list 'my-winlist (cons 'main (selected-window)) ) (split-window-horizontally) (windmove-right) (fix-window-horizontal-size 35) (add-to-list 'my-winlist (cons 'metadata (selected-window)) ) (split-window-vertically) (windmove-down) (add-to-list 'my-winlist (cons 'not-sure-what-this-is-for (selected-window)) ) (select-window(cdr(assoc 'guide my-winlist)) ) ) The final select-window ommand demonstrates that I can now address the windows by name (yay!). The next step for me is to rewrite the existing org-tree-to-indirect-buffer function so that it reliably sends org subtree indirect buffers to the "main" window (in the middle column of the frame). The function starts at line 7091 of org.el: http://orgmode.org/w/org-mode.git/blob/lisp/org.el I'm not having an easy time figuring out how that function decides which window to use when creating and focussing on the new indirect buffer. I can see (and the documentation states) that a choice is first made between using a new or dedicated frame, or the same frame with either the original or another window. But the code to put the buffer in another window in the same frame is quite simple: ((eq org-indirect-buffer-display 'other-window) (pop-to-buffer ibuf)) I've been chasing the code down to native emacs functions -- pop-to-buffer ends up relying on display-buffer -- but I haven't yet found a place where I an specify a particular window for the new buffer. Does anyone else know a way? Thanks again, Matt