* naming and/or directly addressing particular windows?
@ 2012-12-01 15:22 Matt Price
2012-12-01 15:59 ` Drew Adams
2012-12-01 16:58 ` Eduardo Ochs
0 siblings, 2 replies; 5+ messages in thread
From: Matt Price @ 2012-12-01 15:22 UTC (permalink / raw)
To: Bastien; +Cc: drain, Help-gnu-emacs, Org Mode
Hi,
After the recent conversation about Scrivener (on help-gnu-emacs) I
thought the very first step would be to write a simple function that
would create a window layout and populate the windows with a set of
buffers, then set mjor and minor modes for some of hte buffers.
(After that I guess I will have to figure out how to write some very
simple minor modes, or at least some functions that allow e.g. direct
editing of org-mode properties on a selected node.)
So, what I have so far is quite trivial but doesn't seem to work
exactly as I expected:
(delete-other-windows)
(split-window-horizontally)
(windmove-right)
(split-window-horizontally)
(enlarge-window-horizontally 20)
(windmove-right)
(split-window-vertically)
Anyway presumably I'll fiddle with this and eventually it will work,
but something better would be
(set-window-name "outline")
(split-named-window-horizontally-and-name-the-other-window "outline" "main")
(split-named-window-horizontally-and-name-the-other-window "main" "metadata")
(set-width-named-window "main" 60)
and then write a function, bound to say Ctrl-Enter,
open-node-as-indirect-buffer-in-named-window
Anyway: is it possible to give/get a name for a window that persists
long enough to be called in functions?
Thanks,
Matt
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: naming and/or directly addressing particular windows?
2012-12-01 15:22 naming and/or directly addressing particular windows? Matt Price
@ 2012-12-01 15:59 ` Drew Adams
2012-12-02 5:31 ` Matt Price
2012-12-01 16:58 ` Eduardo Ochs
1 sibling, 1 reply; 5+ messages in thread
From: Drew Adams @ 2012-12-01 15:59 UTC (permalink / raw)
To: 'Matt Price', 'Bastien'
Cc: 'drain', Help-gnu-emacs, 'Org Mode'
> 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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: naming and/or directly addressing particular windows?
2012-12-01 15:59 ` Drew Adams
@ 2012-12-02 5:31 ` Matt Price
0 siblings, 0 replies; 5+ messages in thread
From: Matt Price @ 2012-12-02 5:31 UTC (permalink / raw)
To: Drew Adams; +Cc: Bastien, Help-gnu-emacs, Org Mode, drain
On Sat, Dec 1, 2012 at 10:59 AM, Drew Adams <drew.adams@oracle.com> 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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: naming and/or directly addressing particular windows?
2012-12-01 15:22 naming and/or directly addressing particular windows? Matt Price
2012-12-01 15:59 ` Drew Adams
@ 2012-12-01 16:58 ` Eduardo Ochs
2012-12-02 2:41 ` Matt Price
1 sibling, 1 reply; 5+ messages in thread
From: Eduardo Ochs @ 2012-12-01 16:58 UTC (permalink / raw)
To: Matt Price, Org Mode
[-- Attachment #1: Type: text/plain, Size: 1748 bytes --]
Hi Matt,
if you are considering using a little language to create window
configurations
then maybe you will find this interesting:
http://angg.twu.net/eev-intros/find-multiwindow-intro.html
http://angg.twu.net/eev-current/eev-multiwindow.el.html
Cheers!
Eduardo Ochs
eduardoochs@gmail.com
http://angg.twu.net/#eev
On Sat, Dec 1, 2012 at 1:22 PM, Matt Price <moptop99@gmail.com> wrote:
> Hi,
>
> After the recent conversation about Scrivener (on help-gnu-emacs) I
> thought the very first step would be to write a simple function that
> would create a window layout and populate the windows with a set of
> buffers, then set mjor and minor modes for some of hte buffers.
> (After that I guess I will have to figure out how to write some very
> simple minor modes, or at least some functions that allow e.g. direct
> editing of org-mode properties on a selected node.)
>
> So, what I have so far is quite trivial but doesn't seem to work
> exactly as I expected:
>
> (delete-other-windows)
> (split-window-horizontally)
> (windmove-right)
> (split-window-horizontally)
> (enlarge-window-horizontally 20)
> (windmove-right)
> (split-window-vertically)
>
>
> Anyway presumably I'll fiddle with this and eventually it will work,
> but something better would be
>
> (set-window-name "outline")
> (split-named-window-horizontally-and-name-the-other-window "outline"
> "main")
> (split-named-window-horizontally-and-name-the-other-window "main"
> "metadata")
> (set-width-named-window "main" 60)
>
> and then write a function, bound to say Ctrl-Enter,
>
> open-node-as-indirect-buffer-in-named-window
>
> Anyway: is it possible to give/get a name for a window that persists
> long enough to be called in functions?
>
> Thanks,
> Matt
>
>
[-- Attachment #2: Type: text/html, Size: 2564 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-12-02 5:31 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-01 15:22 naming and/or directly addressing particular windows? Matt Price
2012-12-01 15:59 ` Drew Adams
2012-12-02 5:31 ` Matt Price
2012-12-01 16:58 ` Eduardo Ochs
2012-12-02 2:41 ` Matt Price
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
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).