* Question about display-buffer-overriding-action
@ 2022-03-16 1:34 Eduardo Ochs
2022-03-16 1:53 ` Emanuel Berg via Users list for the GNU Emacs text editor
0 siblings, 1 reply; 15+ messages in thread
From: Eduardo Ochs @ 2022-03-16 1:34 UTC (permalink / raw)
To: help-gnu-emacs
Hi all,
how do I set `display-buffer-overriding-action' in a let to make
`pop-to-buffer' use the current window? The docs are here,
(info "(elisp)Choosing Window")
(info "(elisp)The Zen of Buffer Display")
but I'm probably misreading something over and over, because I've done
lots of tests and I can't get it right...
Here's a concrete example. The package "osm" is new in ELPA, and is an
OpenStreetMap viewer for Emacs. Suppose that we define this:
(setq USETHISWINDOW nil)
(defun find-osm (lat lon zoom &rest comments)
"Open a map. LAT, LON and ZOOM are the latitude, longitude, and zoom factor.
The COMMENTS are ignored. You need to have osm.el - OpenStreetMap
viewer - installed for this to work."
(let ((display-buffer-overriding-action USETHISWINDOW))
(osm-goto lat lon zoom)))
;; Test: (find-osm -22.5 -41.9 15 "Near home")
The function `osm-goto' calls `osm--goto', that calls `pop-to-buffer',
and apparently one of the variables that controls the behavior of
`pop-to-buffer' is `display-buffer-overriding-action'. If we have two
windows open and USETHISWINDOW is nil, then - at least in my setting -
this test
;; Test: (find-osm -22.5 -41.9 15 "Near home")
opens the map in the other window. What is the value of USETHISWINDOW
that would mean "always open in the current window"?
Thanks in advance!
Eduardo Ochs
http://angg.twu.net/#eev
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Question about display-buffer-overriding-action
2022-03-16 1:34 Question about display-buffer-overriding-action Eduardo Ochs
@ 2022-03-16 1:53 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-03-16 2:08 ` Eduardo Ochs
0 siblings, 1 reply; 15+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2022-03-16 1:53 UTC (permalink / raw)
To: help-gnu-emacs
Eduardo Ochs wrote:
> If we have two windows open and USETHISWINDOW is nil, then -
> at least in my setting - this test
>
> ;; Test: (find-osm -22.5 -41.9 15 "Near home")
>
> opens the map in the other window.
`pop-to-buffer' docstring:
If BUFFER-OR-NAME is nil, choose some other buffer [...]
> What is the value of
> USETHISWINDOW that would mean "always open in the current
> window"?
`display-buffer-overriding-action':
The value should be a cons cell (FUNCTIONS . ALIST), where
FUNCTIONS is a function or a list of functions.
Each function should accept two arguments: a buffer to
display and an alist similar to ALIST. See `display-buffer'
for details.
I think you set the mentioned alist to the the "action
function" `display-buffer-same-window' ...
Do as they say and see `display-buffer' for details ...
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Question about display-buffer-overriding-action
2022-03-16 1:53 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2022-03-16 2:08 ` Eduardo Ochs
2022-03-16 2:12 ` Emanuel Berg via Users list for the GNU Emacs text editor
` (2 more replies)
0 siblings, 3 replies; 15+ messages in thread
From: Eduardo Ochs @ 2022-03-16 2:08 UTC (permalink / raw)
To: Emanuel Berg, help-gnu-emacs
On Tue, 15 Mar 2022 at 23:01, Emanuel Berg via Users list for the GNU
Emacs text editor <help-gnu-emacs@gnu.org> wrote:
>
> > What is the value of
> > USETHISWINDOW that would mean "always open in the current
> > window"?
>
> Do as they say and see `display-buffer' for details ...
Send code, please! :-)
Cheers,
E.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Question about display-buffer-overriding-action
2022-03-16 2:08 ` Eduardo Ochs
@ 2022-03-16 2:12 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-03-17 20:19 ` Eduardo Ochs
` (2 more replies)
2022-03-16 2:16 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-03-16 13:51 ` Eric S Fraga
2 siblings, 3 replies; 15+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2022-03-16 2:12 UTC (permalink / raw)
To: help-gnu-emacs
Eduardo Ochs wrote:
>>> What is the value of
>>> USETHISWINDOW that would mean "always open in the current
>>> window"?
>>
>> Do as they say and see `display-buffer' for details ...
>
> Send code, please! :-)
(setq display-buffer-alist '((".*" display-buffer-same-window)))
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Question about display-buffer-overriding-action
2022-03-16 2:12 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2022-03-17 20:19 ` Eduardo Ochs
2022-03-17 21:04 ` Eduardo Ochs
2022-03-25 9:38 ` dal-blazej
2 siblings, 0 replies; 15+ messages in thread
From: Eduardo Ochs @ 2022-03-17 20:19 UTC (permalink / raw)
To: Emanuel Berg, help-gnu-emacs
On Thu, 17 Mar 2022 at 15:59, Emanuel Berg via Users list for the GNU
Emacs text editor <help-gnu-emacs@gnu.org> wrote:
> Eduardo Ochs wrote:
>
> >>> What is the value of
> >>> USETHISWINDOW that would mean "always open in the current
> >>> window"?
> >>
> >> Do as they say and see `display-buffer' for details ...
> >
> > Send code, please! :-)
>
> (setq display-buffer-alist '((".*" display-buffer-same-window)))
Fantastic!!! Thanks!!! =) =) =)
Cheers, E. =) =) =)
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Question about display-buffer-overriding-action
2022-03-16 2:12 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-03-17 20:19 ` Eduardo Ochs
@ 2022-03-17 21:04 ` Eduardo Ochs
2022-03-17 22:14 ` Michael Heerdegen
2022-03-25 9:38 ` dal-blazej
2 siblings, 1 reply; 15+ messages in thread
From: Eduardo Ochs @ 2022-03-17 21:04 UTC (permalink / raw)
To: Emanuel Berg, help-gnu-emacs
On Thu, 17 Mar 2022 at 15:59, Emanuel Berg via Users list for the GNU
Emacs text editor <help-gnu-emacs@gnu.org> wrote:
> (setq display-buffer-alist '((".*" display-buffer-same-window)))
Hi Emanuel,
I found a way to adapt your idea to
`display-buffer-overriding-action'. These two sexps make osm.el use
the current window:
(let ((display-buffer-alist '((".*" display-buffer-same-window))))
(osm-goto -22.5013 -41.9259 15))
(let ((display-buffer-overriding-action '(display-buffer-same-window)))
(osm-goto -22.5013 -41.9259 15))
This is not a universal solution. It doesn't work for man, for
example... See:
(describe-variable 'Man-notify-method)
(find-evardescr 'Man-notify-method "when manpage is ready")
(find-evardescr 'Man-notify-method "pushy" "current window")
Try:
(let ((display-buffer-alist '((".*" display-buffer-same-window))))
(man "cat"))
(let ((display-buffer-overriding-action '(display-buffer-same-window)))
(man "cat"))
(let ((Man-notify-method 'pushy))
(man "cat"))
Cheers,
Eduardo =)
http://angg.twu.net/#eev
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Question about display-buffer-overriding-action
2022-03-17 21:04 ` Eduardo Ochs
@ 2022-03-17 22:14 ` Michael Heerdegen
2022-03-18 4:56 ` Eduardo Ochs
0 siblings, 1 reply; 15+ messages in thread
From: Michael Heerdegen @ 2022-03-17 22:14 UTC (permalink / raw)
To: help-gnu-emacs
Eduardo Ochs <eduardoochs@gmail.com> writes:
> This is not a universal solution. It doesn't work for man,
Maybe it works for women?
> Try:
>
> (let ((display-buffer-alist '((".*" display-buffer-same-window))))
> (man "cat"))
> [...]
Note that `man' is a special (and rare) case: Emacs `man' works
asynchronously; when the buffer has been rendered and the result gets
displayed, your `let' is long gone.
See `Man-notify-when-ready' and `Man-notify-method' for how the buffer
gets displayed.
You probably need an appropriate man buffer specific entry in the
top-level binding of `display-buffer-alist' to get what you want.
Michael
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Question about display-buffer-overriding-action
2022-03-17 22:14 ` Michael Heerdegen
@ 2022-03-18 4:56 ` Eduardo Ochs
2022-03-19 1:30 ` Michael Heerdegen
0 siblings, 1 reply; 15+ messages in thread
From: Eduardo Ochs @ 2022-03-18 4:56 UTC (permalink / raw)
To: Michael Heerdegen; +Cc: help-gnu-emacs
Hi Michael,
> Note that `man' is a special (and rare) case: Emacs `man' works
> asynchronously; when the buffer has been rendered and the result gets
> displayed, your `let' is long gone.
>
> See `Man-notify-when-ready' and `Man-notify-method' for how the buffer
> gets displayed.
>
> You probably need an appropriate man buffer specific entry in the
> top-level binding of `display-buffer-alist' to get what you want.
I spent a lot of time trying to decypher man's code a few
years ago and I think that the right way to do that is with
a "(let ((Man-notify-method ...)) ...)", as in:
(let ((Man-notify-method 'pushy))
(man "cat"))
See the comments and links here:
(find-eev "eev-blinks.el" "find-man")
http://angg.twu.net/eev-current/eev-blinks.el.html#find-man
> Maybe it works for women?
Do you use woman? Most people only mention woman for jokes...
Man and woman handle windows differently. I tried this - and
its interactive version, of course - and woman opened the
manpage in the current window:
(woman-find-file "/usr/share/man/man1/cat.1.gz")
Cheers,
Eduardo
http://angg.twu.net/#eev
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Question about display-buffer-overriding-action
2022-03-18 4:56 ` Eduardo Ochs
@ 2022-03-19 1:30 ` Michael Heerdegen
0 siblings, 0 replies; 15+ messages in thread
From: Michael Heerdegen @ 2022-03-19 1:30 UTC (permalink / raw)
To: help-gnu-emacs
Eduardo Ochs <eduardoochs@gmail.com> writes:
> I spent a lot of time trying to decypher man's code a few
> years ago and I think that the right way to do that is with
> a "(let ((Man-notify-method ...)) ...)", as in:
>
> (let ((Man-notify-method 'pushy))
> (man "cat"))
Looks reasonable, yes.
> > Maybe it works for women?
>
> Do you use woman? Most people only mention woman for jokes...
I never make jokes about women.
Use it only seldom. I mentioned it because I thought that it would not
use asynchronous processes. But ok yes, rather for the joke.
Michael.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Question about display-buffer-overriding-action
2022-03-16 2:12 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-03-17 20:19 ` Eduardo Ochs
2022-03-17 21:04 ` Eduardo Ochs
@ 2022-03-25 9:38 ` dal-blazej
2022-03-25 17:59 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-03-26 1:10 ` Emanuel Berg via Users list for the GNU Emacs text editor
2 siblings, 2 replies; 15+ messages in thread
From: dal-blazej @ 2022-03-25 9:38 UTC (permalink / raw)
To: help-gnu-emacs
Emanuel Berg via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> writes:
> (setq display-buffer-alist '((".*" display-buffer-same-window)))
It is bad practice to use `display-buffer-alist` with a catch-all
regexp. Please use instead `display-buffer-base-action`.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Question about display-buffer-overriding-action
2022-03-25 9:38 ` dal-blazej
@ 2022-03-25 17:59 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-03-25 22:56 ` dal-blazej
2022-03-26 1:10 ` Emanuel Berg via Users list for the GNU Emacs text editor
1 sibling, 1 reply; 15+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2022-03-25 17:59 UTC (permalink / raw)
To: help-gnu-emacs
dal-blazej wrote:
>> (setq display-buffer-alist '((".*" display-buffer-same-window)))
>
> It is bad practice to use `display-buffer-alist` with
> a catch-all regexp.
OK, maybe one should report a bug it should be noted in the
docstring ...
> Please use instead `display-buffer-base-action`
Alright, but how?
The docstring says
It should be a cons cell (FUNCTIONS . ALIST), where
FUNCTIONS is an action function or a list of action
functions and ALIST is an action alist. Each such action
function should accept two arguments: a buffer to display
and an alist of the same form as ALIST.
So it should be
( (af_0 ... af_n) . ((k_0 . a_0) ... (k_m . a_m)) )
where
af = action function
k = key
a = action
where each action function has the form
af(buf, alist)
where alist has the form
( (k_0 . a_0) ... (k_m . a_m) )
Pretty simple, right?
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Question about display-buffer-overriding-action
2022-03-25 9:38 ` dal-blazej
2022-03-25 17:59 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2022-03-26 1:10 ` Emanuel Berg via Users list for the GNU Emacs text editor
1 sibling, 0 replies; 15+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2022-03-26 1:10 UTC (permalink / raw)
To: help-gnu-emacs
dal-blazej wrote:
>> (setq display-buffer-alist '((".*"
>> display-buffer-same-window)))
>
> It is bad practice to use `display-buffer-alist` with
> a catch-all regexp. Please use instead
> `display-buffer-base-action`.
Heh, bad practice indeed, check out the docstring for
`display-buffer'!
For instance:
(setq display-buffer-alist ’((".*" display-buffer-at-bottom)))
and that's even incorrect Lisp!
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Question about display-buffer-overriding-action
2022-03-16 2:08 ` Eduardo Ochs
2022-03-16 2:12 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2022-03-16 2:16 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-03-16 13:51 ` Eric S Fraga
2 siblings, 0 replies; 15+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2022-03-16 2:16 UTC (permalink / raw)
To: help-gnu-emacs
Eduardo Ochs wrote:
>>> What is the value of USETHISWINDOW that would mean "always
>>> open in the current window"?
>>
>> Do as they say and see `display-buffer' for details ...
>
> Send code, please! :-)
Maybe this day and age it should be
(setq display-buffer-alist
(list (list ".*" #'display-buffer-same-window)))
https://dataswamp.org/~incal/emacs-init/window-incal.el
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Question about display-buffer-overriding-action
2022-03-16 2:08 ` Eduardo Ochs
2022-03-16 2:12 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-03-16 2:16 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2022-03-16 13:51 ` Eric S Fraga
2 siblings, 0 replies; 15+ messages in thread
From: Eric S Fraga @ 2022-03-16 13:51 UTC (permalink / raw)
To: help-gnu-emacs
On Tuesday, 15 Mar 2022 at 23:08, Eduardo Ochs wrote:
> Send code, please! :-)
Protesilaos Stavrou has some examples and a good explanation of how to
work with display-buffer-alist, amongst other things, in his video on
youtube:
https://www.youtube.com/watch?v=rjOhJMbA-q0
I found this very useful, together with the Emacs documentation.
--
Eric S Fraga with org 9.5.2 in Emacs 29.0.50 on Debian 11.2
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2022-03-26 1:10 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-16 1:34 Question about display-buffer-overriding-action Eduardo Ochs
2022-03-16 1:53 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-03-16 2:08 ` Eduardo Ochs
2022-03-16 2:12 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-03-17 20:19 ` Eduardo Ochs
2022-03-17 21:04 ` Eduardo Ochs
2022-03-17 22:14 ` Michael Heerdegen
2022-03-18 4:56 ` Eduardo Ochs
2022-03-19 1:30 ` Michael Heerdegen
2022-03-25 9:38 ` dal-blazej
2022-03-25 17:59 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-03-25 22:56 ` dal-blazej
2022-03-26 1:10 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-03-16 2:16 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-03-16 13:51 ` Eric S Fraga
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).