* Re: How to make display-buffer automatically focus (e.g. for help buffers)
@ 2009-07-13 15:10 martin rudalics
2009-07-13 16:02 ` Leo Alekseyev
0 siblings, 1 reply; 5+ messages in thread
From: martin rudalics @ 2009-07-13 15:10 UTC (permalink / raw)
To: dnquark; +Cc: help-gnu-emacs
> I would like to implement the following behavior for buffers that pop
> up when e.g. help is invoked: I want the pop-up buffer to
> automatically take focus.
For help buffers you should be able to do that by customizing
`help-window-select' to t.
> I tried to advise the display-buffer
> function with (other-window 1), but this solution is suboptimal: for
> instance, if I continue browsing help it will be using display-buffer
> but will be reusing its window -- so (other-window 1) makes the
> already selected help window lose focus. Is there a better solution?
The canonical function for this purpose is `pop-to-buffer'. Wherever
`display-buffer' is called, the explicit intention is to _not_ select
the window that command uses.
> In addition: for any buffer that pops up automatically (Help,
> completions, TeX compilation results, etc) I would like to be able to
> create filters based on buffer name and optionally turn on the View
> mode (so that the buffer could be easily searched and/or dismissed by
> pressing 'q'). I searched extensively, but couldn't find a ready-made
> function that would do that...
Most of these buffers should be in View mode and typing `q' should quit
them. Which ones don't?
martin
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How to make display-buffer automatically focus (e.g. for help buffers)
2009-07-13 15:10 How to make display-buffer automatically focus (e.g. for help buffers) martin rudalics
@ 2009-07-13 16:02 ` Leo Alekseyev
2009-07-13 17:31 ` martin rudalics
0 siblings, 1 reply; 5+ messages in thread
From: Leo Alekseyev @ 2009-07-13 16:02 UTC (permalink / raw)
To: martin rudalics; +Cc: help-gnu-emacs
> For help buffers you should be able to do that by customizing
> `help-window-select' to t.
This is terrific, I searched hard for this functionality and couldn't find it!
> The canonical function for this purpose is `pop-to-buffer'. Wherever
> `display-buffer' is called, the explicit intention is to _not_ select
> the window that command uses.
That is true -- but it would be nice if there were a way to override
this; the help-window-select t customization effectively replaces
display-buffer behavior with pop-top-buffer for help buffers; it is
conceivable that one might want to do this for other types of buffers
as well.
> Most of these buffers should be in View mode and typing `q' should quit
> them. Which ones don't?
>
For instance, using AucTeX the TeX errors are displayed in a buffer
that uses display-buffer and is writeable; I've seen other similar
instances before... It would be nice to be able to have them be
automatically focused in view mode and dismissed via 'q'.
One workaround is to bury those buffers via a winner-undo, or perhaps
write a function that switches windows, kills buffer and performs
winner-undo or equivalent, but it's not wholly satisfactory...
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How to make display-buffer automatically focus (e.g. for help buffers)
2009-07-13 16:02 ` Leo Alekseyev
@ 2009-07-13 17:31 ` martin rudalics
2009-07-14 1:36 ` Leo Alekseyev
0 siblings, 1 reply; 5+ messages in thread
From: martin rudalics @ 2009-07-13 17:31 UTC (permalink / raw)
To: Leo Alekseyev; +Cc: help-gnu-emacs
> For instance, using AucTeX the TeX errors are displayed in a buffer
> that uses display-buffer and is writeable; I've seen other similar
> instances before... It would be nice to be able to have them be
> automatically focused in view mode and dismissed via 'q'.
I haven't installed AucTeX here so I can't tell. In any case you could
roll your own `display-buffer-function'. Unfortuantely, the doc-string
of that variable lies because neither `switch-to-buffer-other-window'
nor `find-file-other-window' currently use it ;-)
Basically, you should be able to define a variable which holds the names
of all buffers where you want the view-mode/select-window behavior like
(defvar my-display-buffer-list ...)
write a function like the completely untested
(defun my-display-buffer (buffer-or-name flag)
(let (display-buffer-function window)
(setq window (display-buffer buffer-or-name flag))
(when (memq buffer-or-name my-display-buffer-list)
(select-window window)
(view-mode 1))))
customize `display-buffer-function' to `my-display-buffer' and tell me
whether it does what you want.
martin
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How to make display-buffer automatically focus (e.g. for help buffers)
2009-07-13 17:31 ` martin rudalics
@ 2009-07-14 1:36 ` Leo Alekseyev
0 siblings, 0 replies; 5+ messages in thread
From: Leo Alekseyev @ 2009-07-14 1:36 UTC (permalink / raw)
To: help-gnu-emacs
this is going in the right direction, but isn't working
First, the comparison should be
(when (member (buffer-name buffer-or-name) my-display-buffer-list)
and the function should return a window
However, even so it doesn't work: because the buffer is supposed to
display a message, you can't enable the view mode right after spawning
it -- because then you can't write to it. I actually don't see how
you can get around this.
But even without the view mode, the (select-window window) doesn't
appear to focus the buffer...
>
> (defun my-display-buffer (buffer-or-name flag)
> (let (display-buffer-function window)
> (setq window (display-buffer buffer-or-name flag))
> (when (memq buffer-or-name my-display-buffer-list)
> (select-window window)
> (view-mode 1))))
>
> customize `display-buffer-function' to `my-display-buffer' and tell me
> whether it does what you want.
>
> martin
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* How to make display-buffer automatically focus (e.g. for help buffers)
@ 2009-07-13 11:12 dnquark
0 siblings, 0 replies; 5+ messages in thread
From: dnquark @ 2009-07-13 11:12 UTC (permalink / raw)
To: help-gnu-emacs
I would like to implement the following behavior for buffers that pop
up when e.g. help is invoked: I want the pop-up buffer to
automatically take focus. I tried to advise the display-buffer
function with (other-window 1), but this solution is suboptimal: for
instance, if I continue browsing help it will be using display-buffer
but will be reusing its window -- so (other-window 1) makes the
already selected help window lose focus. Is there a better solution?
In addition: for any buffer that pops up automatically (Help,
completions, TeX compilation results, etc) I would like to be able to
create filters based on buffer name and optionally turn on the View
mode (so that the buffer could be easily searched and/or dismissed by
pressing 'q'). I searched extensively, but couldn't find a ready-made
function that would do that...
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-07-14 1:36 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-13 15:10 How to make display-buffer automatically focus (e.g. for help buffers) martin rudalics
2009-07-13 16:02 ` Leo Alekseyev
2009-07-13 17:31 ` martin rudalics
2009-07-14 1:36 ` Leo Alekseyev
-- strict thread matches above, loose matches on Subject: below --
2009-07-13 11:12 dnquark
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.