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: Matt Price
Subject: Re: naming and/or directly addressing particular windows?
Date: Mon, 3 Dec 2012 07:38:07 -0500

On Sun, Dec 2, 2012 at 12:46 PM, martin rudalics <rudalics@gmx.at> wrote:
>
> I'm not sure why you need names at all but with Emacs 24 it's simpler to
> use window parameters as
>
> (defun set-window-name (window name)
>   (set-window-parameter window 'name name))
>
> (defun window-with-name (name)
>   (window-with-parameter 'name name))
>
> which also relieves you from the task to recycle dead windows from
> `my-winlist', and rewrite your code as
>
> (let ((new-window (split-window-horizontally -35)))
>   (set-window-name new-window 'metadata))
>
> ...
>
> (select-window (window-with-name 'guide))
>

that is so very helpful, thank you.  I may not really need names but
for someone like me who has a hard time even reading lisp, I think
they will be a helpful mneumonic.  (probably it would be just as good
to assign a variable the value of '(selected-window)' at various
points in the function).  I've rewritten my code like this, which
seems to be much clearer than the original:

(defun set-window-name (window name)
  (set-window-parameter window 'name name))

(defun window-with-name (name)
  (window-with-parameter 'name name))

(defun writers-room-windows (width)
  "Trying to figure out how to get a nice windows config for a writers
room mode"
  (interactive )
  (global-linum-mode 0)
  (delete-other-windows)
  (set-window-name (selected-window) 'guide)
  (let ((new-window (split-window-horizontally width)))
    (set-window-name new-window 'main))
  (select-window (window-with-name 'main))
  (let ((new-window (split-window-horizontally (- width))))
    (set-window-name new-window 'metadata))
  (select-window (window-with-name 'guide))
  )

(writers-room-windows 25)

>
>> 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?
>
> Depends (also) on the version of your Emacs.
>
emacs-version reports:
GNU Emacs 24.2.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.6.0) of
2012-10-09 on meitnerium, modified by Debian

If you have any more hints for this next problem -- forcing an
indirect buffer to open in a particular window -- I'd be very
grateful.

Thanks so much,
Matt



reply via email to

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