* display-buffer-alist actions
@ 2021-02-24 17:44 Eric S Fraga
2021-02-24 19:52 ` Joost Kremers
` (2 more replies)
0 siblings, 3 replies; 18+ messages in thread
From: Eric S Fraga @ 2021-02-24 17:44 UTC (permalink / raw)
To: help-gnu-emacs
Hello all,
I've read and re-read the documentation for display-buffer-alist and I
cannot quite understand it. I have the following, which works:
#+begin_src emacs-lisp
(setq display-buffer-alist
'(("^\\*Async Shell Command*" . (display-buffer-no-window))
("some regexp that works fine"
(display-buffer-in-side-window)
(window-width . 0.28)
(side . left)
(slot . 0))))
#+end_src
I have two monitors, one in landscape for which the above is ideal,
although I do not quite understand it. I got it from somewhere on the
Interweb...
In any case, my other monitor is portrait and I would rather set the
width and the side to be bottom for windows on that monitor. Is it
possible to have a conditional of some sort in the list of conses, one
where I would look at the frame width and height?
(I use exwm, by the way.)
Thank you,
eric
--
Eric S Fraga via Emacs 28.0.50 & org 9.4.4 on Debian bullseye/sid
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: display-buffer-alist actions
2021-02-24 17:44 display-buffer-alist actions Eric S Fraga
@ 2021-02-24 19:52 ` Joost Kremers
2021-02-24 20:08 ` Joost Kremers
` (2 more replies)
2021-02-24 21:15 ` Stefan Monnier
2021-02-25 0:00 ` [External] : " Drew Adams
2 siblings, 3 replies; 18+ messages in thread
From: Joost Kremers @ 2021-02-24 19:52 UTC (permalink / raw)
To: Eric S Fraga; +Cc: help-gnu-emacs
On Wed, Feb 24 2021, Eric S Fraga wrote:
> Hello all,
>
> I've read and re-read the documentation for display-buffer-alist and I
> cannot quite understand it.
Yes, it's the easiest thing to grok. I've found Protesilaos Stavrou's comments
and Youtube video on the topic helpful:
https://protesilaos.com/dotemacs/#h:12591f89-eeea-4b12-93e8-9293504e5a12
> I have the following, which works:
>
> #+begin_src emacs-lisp
> (setq display-buffer-alist
> '(("^\\*Async Shell Command*" . (display-buffer-no-window))
> ("some regexp that works fine"
> (display-buffer-in-side-window)
> (window-width . 0.28)
> (side . left)
> (slot . 0))))
> #+end_src
>
> I have two monitors, one in landscape for which the above is ideal,
> although I do not quite understand it. I got it from somewhere on the
> Interweb...
Watch Protesilaos' video and I think you'll understand better.
> In any case, my other monitor is portrait and I would rather set the
> width and the side to be bottom for windows on that monitor. Is it
> possible to have a conditional of some sort in the list of conses, one
> where I would look at the frame width and height?
IIUC no, the actions (the conses you mention) don't have conditionals. What you
could do, however, is write your own display-buffer function, which checks the
frame dimensions and calls `display-buffer-side-window` with either `(side .
left)` or `(side . bottom)`.
--
Joost Kremers
Life has its moments
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: display-buffer-alist actions
2021-02-24 19:52 ` Joost Kremers
@ 2021-02-24 20:08 ` Joost Kremers
2021-02-24 21:08 ` TRS-80
2021-02-24 20:57 ` Michael Heerdegen
2021-02-25 16:25 ` Eric S Fraga
2 siblings, 1 reply; 18+ messages in thread
From: Joost Kremers @ 2021-02-24 20:08 UTC (permalink / raw)
To: help-gnu-emacs
On Wed, Feb 24 2021, Joost Kremers wrote:
> On Wed, Feb 24 2021, Eric S Fraga wrote:
>> I've read and re-read the documentation for display-buffer-alist and I
>> cannot quite understand it.
>
> Yes, it's the easiest thing to grok.
Of course I meant it's *not* the easiest thing to grok...
--
Joost Kremers
Life has its moments
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: display-buffer-alist actions
2021-02-24 19:52 ` Joost Kremers
2021-02-24 20:08 ` Joost Kremers
@ 2021-02-24 20:57 ` Michael Heerdegen
2021-02-25 16:25 ` Eric S Fraga
2 siblings, 0 replies; 18+ messages in thread
From: Michael Heerdegen @ 2021-02-24 20:57 UTC (permalink / raw)
To: help-gnu-emacs
Joost Kremers <joostkremers@fastmail.fm> writes:
> IIUC no, the actions (the conses you mention) don't have conditionals.
But they are allowed to fail (i.e., return nil). AFAIK actions are
tried in order until one succeeds. So one could use special action
functions (e.g. trivial wrappers around the given actions that just fail
if a condition is not met) to get a conditional behavior inside the
`display-buffer' mechanism.
Michael.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: display-buffer-alist actions
2021-02-24 20:08 ` Joost Kremers
@ 2021-02-24 21:08 ` TRS-80
0 siblings, 0 replies; 18+ messages in thread
From: TRS-80 @ 2021-02-24 21:08 UTC (permalink / raw)
To: help-gnu-emacs
On 2021-02-24 15:08, Joost Kremers wrote:
> On Wed, Feb 24 2021, Joost Kremers wrote:
>> On Wed, Feb 24 2021, Eric S Fraga wrote:
>>> I've read and re-read the documentation for display-buffer-alist and
>>> I
>>> cannot quite understand it.
>>
>> Yes, it's the easiest thing to grok.
>
> Of course I meant it's *not* the easiest thing to grok...
I was going to say, I don't think even jwz understands it...
:D
I will check out the video. Or maybe it was that video that got me to
try it in the first place. I don't remember now. Anyway, Prot is
great. :)
I seem to recall just playing with some of the options to see what they
did, until I eventually I found a couple that did whatever it was I was
trying to do at the time.
Cheers,
TRS-80
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: display-buffer-alist actions
2021-02-24 17:44 display-buffer-alist actions Eric S Fraga
2021-02-24 19:52 ` Joost Kremers
@ 2021-02-24 21:15 ` Stefan Monnier
2021-02-25 16:34 ` Eric S Fraga
2021-02-25 0:00 ` [External] : " Drew Adams
2 siblings, 1 reply; 18+ messages in thread
From: Stefan Monnier @ 2021-02-24 21:15 UTC (permalink / raw)
To: help-gnu-emacs
> #+begin_src emacs-lisp
> (setq display-buffer-alist
> '(("^\\*Async Shell Command*" . (display-buffer-no-window))
> ("some regexp that works fine"
> (display-buffer-in-side-window)
> (window-width . 0.28)
> (side . left)
> (slot . 0))))
> #+end_src
>
> I have two monitors, one in landscape for which the above is ideal,
> although I do not quite understand it. I got it from somewhere on the
> Interweb...
IIRC (my memory is fuzzy, and I'm only to blame for the design of
this monster ;-) you can do:
(setq display-buffer-alist
'(("^\\*Async Shell Command*" . (display-buffer-no-window))
("some regexp that works fine"
my-tall-display-buffer-in-side-window
(window-width . <something>)
(side . bottom)
(slot . 0))
("some regexp that works fine"
display-buffer-in-side-window
(window-width . 0.28)
(side . left)
(slot . 0))))
(defun my-tall-display-buffer-in-side-window (&rest args)
(when (my-current-monitor-is-tall)
(apply #'display-buffer-in-side-window args)))
So the middle entry is only used when `my-current-monitor-is-tall`
returns non-nil.
An alternative would be something like:
(setq display-buffer-alist
'(("^\\*Async Shell Command*" . (display-buffer-no-window))
("some regexp that works fine"
my-display-buffer-in-side-window
(if-tall ((window-width . <something>)
(side . bottom))
((window-width . 0.28)
(side . left)))
(slot . 0))))
(defun my-display-buffer-in-side-window (buf alist)
(display-buffer-in-side-window
buf (append (nth (if (my-current-monitor-is-tall) 1 2)
(assq 'if-tall alist))
alist)))
-- Stefan
^ permalink raw reply [flat|nested] 18+ messages in thread
* RE: [External] : display-buffer-alist actions
2021-02-24 17:44 display-buffer-alist actions Eric S Fraga
2021-02-24 19:52 ` Joost Kremers
2021-02-24 21:15 ` Stefan Monnier
@ 2021-02-25 0:00 ` Drew Adams
2021-02-25 4:28 ` Michael Heerdegen
2021-02-25 16:27 ` Eric S Fraga
2 siblings, 2 replies; 18+ messages in thread
From: Drew Adams @ 2021-02-25 0:00 UTC (permalink / raw)
To: Eric S Fraga, help-gnu-emacs@gnu.org
> I've read and re-read the documentation for
> display-buffer-alist and I cannot quite understand it.
(You're not alone.)
I suspect it's not just a doc problem. It's
the behavior that's complex. That leads to
complicated doc, whether or not the doc is
correct.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [External] : display-buffer-alist actions
2021-02-25 0:00 ` [External] : " Drew Adams
@ 2021-02-25 4:28 ` Michael Heerdegen
2021-02-25 7:00 ` Drew Adams
2021-02-25 16:36 ` Eric S Fraga
2021-02-25 16:27 ` Eric S Fraga
1 sibling, 2 replies; 18+ messages in thread
From: Michael Heerdegen @ 2021-02-25 4:28 UTC (permalink / raw)
To: help-gnu-emacs
Drew Adams <drew.adams@oracle.com> writes:
> > I've read and re-read the documentation for
> > display-buffer-alist and I cannot quite understand it.
>
> (You're not alone.)
>
> I suspect it's not just a doc problem. It's
> the behavior that's complex.
The behavior is complex since the task is. The approach is not
unnecessarily complex in my eyes.
> That leads to complicated doc, whether or not the doc is correct.
At least in my (master) Emacs the docs contain a node
(info "(elisp) The Zen of Buffer Display")
It's quite nice and easy to understand. Must be quite new I guess.
Michael.
^ permalink raw reply [flat|nested] 18+ messages in thread
* RE: [External] : display-buffer-alist actions
2021-02-25 4:28 ` Michael Heerdegen
@ 2021-02-25 7:00 ` Drew Adams
2021-02-25 14:26 ` Stefan Monnier
2021-02-25 16:36 ` Eric S Fraga
1 sibling, 1 reply; 18+ messages in thread
From: Drew Adams @ 2021-02-25 7:00 UTC (permalink / raw)
To: Michael Heerdegen, help-gnu-emacs@gnu.org
> > > I've read and re-read the documentation for
> > > display-buffer-alist and I cannot quite understand it.
> >
> > (You're not alone.)
> >
> > I suspect it's not just a doc problem. It's
> > the behavior that's complex.
>
> The behavior is complex since the task is. The approach is not
> unnecessarily complex in my eyes.
I agree (to the extent that I understand it).
I've said as much several times before.
It provides a comprehensive solution, which is
necessarily complex.
My complaint is that we don't also provide some
simple to use constructs for simple use cases.
In particular, I've very glad we still have
the `special-display' stuff available. Simple,
great for some simple use cases. But when the
new, comprehensive solution was created (a
_good_ thing), Emacs simultaneously deprecated
`special-display'. We _have_ it, but we're
discouraged from using it.
That deprecation I object to.
But I do appreciate that it's still supported.
I hope it will continue to be so. And I still
have hopes that the deprecation will be lifted
from it someday. Users are in general unaware
of it now (it was removed from the manual etc.),
even though it's very good for the simple use
cases it handles.
> > That leads to complicated doc, whether or not the doc is correct.
>
> At least in my (master) Emacs the docs contain a node
>
> (info "(elisp) The Zen of Buffer Display")
>
> It's quite nice and easy to understand. Must be quite new I guess.
Thanks for pointing it out. I'll take a look.
It's not that new apparently - it's in Emacs
26.3, at least.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [External] : display-buffer-alist actions
2021-02-25 7:00 ` Drew Adams
@ 2021-02-25 14:26 ` Stefan Monnier
2021-02-25 16:22 ` Drew Adams
0 siblings, 1 reply; 18+ messages in thread
From: Stefan Monnier @ 2021-02-25 14:26 UTC (permalink / raw)
To: help-gnu-emacs
> My complaint is that we don't also provide some simple to use
> constructs for simple use cases.
Patches welcome in this respect.
> But I do appreciate that it's still supported. I hope it will
> continue to be so. And I still have hopes that the deprecation will
> be lifted from it someday. Users are in general unaware of it now (it
> was removed from the manual etc.), even though it's very good for the
> simple use cases it handles.
I don't think keeping those vars around is the right solution (because
those special-display* vars make the overall system more complex).
Better would be to provide new ways to do the same, which are just as
easy&simple but which rely on `display-buffer-alist`.
Stefan
^ permalink raw reply [flat|nested] 18+ messages in thread
* RE: [External] : display-buffer-alist actions
2021-02-25 14:26 ` Stefan Monnier
@ 2021-02-25 16:22 ` Drew Adams
0 siblings, 0 replies; 18+ messages in thread
From: Drew Adams @ 2021-02-25 16:22 UTC (permalink / raw)
To: Stefan Monnier, help-gnu-emacs@gnu.org
> > My complaint is that we don't also provide some
> > simple to use constructs for simple use cases.
> >
> > But I do appreciate that it's still supported.
> > I hope it will continue to be so. And I still
> > have hopes that the deprecation will be lifted
> > from it someday. Users are in general unaware
> > of it now (it was removed from the manual etc.),
> > even though it's very good for the simple use
> > cases it handles.
>
> I don't think keeping those vars around is the
> right solution (because those special-display*
> vars make the overall system more complex).
>
> Better would be to provide new ways to do the
> same, which are just as easy&simple but which
> rely on `display-buffer-alist`.
Apparently it's not "easy&simple" to provide new
ways to do the same, using `display-buffer-alist'.
That's the problem. (Addition of such replacement,
just-as-easy&simple ways welcome...)
`display-buffer-alist' is indeed super-complex,
and it does let you configure many buffer-display
possibilities - even arcane ones. But apparently
not these simple possibilities.
While waiting for the New, Miraculous, Easy&Simple
ways to get such easy&simple behavior, how about
we UN-deprecate this important feature that Just
Works, and put it back in the manual?
___
Zoom meetings provide lots of flexibility over
getting together physically, but who would think
the _addition_ of Zoom would be a good reason to
deprecate physical get-togethers?
___
special-display-buffer-names
special-display-frame-alist
special-display-function
special-display-regexps
Every one of those now has a big sign out front:
"use `display-buffer-alist' instead"
And yet that's apparently not possible or
straightforward. Or if it really _is_, then
please use `display-buffer-alist' to implement
easy&simple ways to get equivalent behavior.
Hasn't been done so far. Yet we tell users to do it.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: display-buffer-alist actions
2021-02-24 19:52 ` Joost Kremers
2021-02-24 20:08 ` Joost Kremers
2021-02-24 20:57 ` Michael Heerdegen
@ 2021-02-25 16:25 ` Eric S Fraga
2021-02-25 20:40 ` Garjola Dindi
2 siblings, 1 reply; 18+ messages in thread
From: Eric S Fraga @ 2021-02-25 16:25 UTC (permalink / raw)
To: Joost Kremers; +Cc: help-gnu-emacs
On Wednesday, 24 Feb 2021 at 20:52, Joost Kremers wrote:
> Yes, it's the easiest thing to grok. I've found Protesilaos Stavrou's
> comments and Youtube video on the topic helpful:
Indeed. His videos are excellent.
> What you could do, however, is write your own display-buffer function,
> which checks the frame dimensions and calls
> `display-buffer-side-window` with either `(side . left)` or `(side
> . bottom)`.
Yes! Very simple and, in hindsight, kind of obvious <blush>. Thank
you. I have now done this and it works perfectly.
--
Eric S Fraga via Emacs 28.0.50 & org 9.4.4 on Debian bullseye/sid
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [External] : display-buffer-alist actions
2021-02-25 0:00 ` [External] : " Drew Adams
2021-02-25 4:28 ` Michael Heerdegen
@ 2021-02-25 16:27 ` Eric S Fraga
1 sibling, 0 replies; 18+ messages in thread
From: Eric S Fraga @ 2021-02-25 16:27 UTC (permalink / raw)
To: Drew Adams; +Cc: help-gnu-emacs@gnu.org
On Thursday, 25 Feb 2021 at 00:00, Drew Adams wrote:
> I suspect it's not just a doc problem. It's
> the behavior that's complex. That leads to
> complicated doc, whether or not the doc is
> correct.
For me, it was missing how the various conses after the display method
to use were interpreted. I now realise that they are collated into a
list and passed to the specific display function as the alist argument.
All obvious once I have solved it (with help ;-)).
--
Eric S Fraga via Emacs 28.0.50 & org 9.4.4 on Debian bullseye/sid
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: display-buffer-alist actions
2021-02-24 21:15 ` Stefan Monnier
@ 2021-02-25 16:34 ` Eric S Fraga
2021-02-25 16:51 ` Stefan Monnier
0 siblings, 1 reply; 18+ messages in thread
From: Eric S Fraga @ 2021-02-25 16:34 UTC (permalink / raw)
To: help-gnu-emacs
On Wednesday, 24 Feb 2021 at 16:15, Stefan Monnier wrote:
> So the middle entry is only used when `my-current-monitor-is-tall`
> returns non-nil.
Ah, interesting. I took the more simple approach (for me):
#+begin_src emacs-lisp
(defun esf/display-buffer-in-side-window (buffer alist)
;; (message "here we are with alist=%s" alist)
;; (message "frame width=%d height=%d" (frame-width) (frame-height))
(if (> (frame-width) 100)
(display-buffer-in-side-window buffer '((window-width . 0.28)
(side . left)
(slot . 0)))
(display-buffer-in-side-window buffer '((window-height . 0.25)
(side . bottom)
(slot . 0)))))
(setq display-buffer-alist
'(("^\\*Async Shell Command*" . (display-buffer-no-window))
("\\*[Hh]elp\\*" . (esf/display-buffer-in-side-window))))
#+end_src
(elided for clarity)
Thank you all that pointed me in the right direction!
--
Eric S Fraga via Emacs 28.0.50 & org 9.4.4 on Debian bullseye/sid
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [External] : display-buffer-alist actions
2021-02-25 4:28 ` Michael Heerdegen
2021-02-25 7:00 ` Drew Adams
@ 2021-02-25 16:36 ` Eric S Fraga
1 sibling, 0 replies; 18+ messages in thread
From: Eric S Fraga @ 2021-02-25 16:36 UTC (permalink / raw)
To: help-gnu-emacs
On Thursday, 25 Feb 2021 at 05:28, Michael Heerdegen wrote:
> At least in my (master) Emacs the docs contain a node
>
> (info "(elisp) The Zen of Buffer Display")
Didn't get that far in the manual. Ooops. :-(
It does help quite a bit. Thank you for highlighting it.
--
Eric S Fraga via Emacs 28.0.50 & org 9.4.4 on Debian bullseye/sid
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: display-buffer-alist actions
2021-02-25 16:34 ` Eric S Fraga
@ 2021-02-25 16:51 ` Stefan Monnier
2021-02-26 9:43 ` Eric S Fraga
0 siblings, 1 reply; 18+ messages in thread
From: Stefan Monnier @ 2021-02-25 16:51 UTC (permalink / raw)
To: help-gnu-emacs
> Ah, interesting. I took the more simple approach (for me):
That's a fine solution as well.
> (if (> (frame-width) 100)
> (display-buffer-in-side-window buffer '((window-width . 0.28)
> (side . left)
> (slot . 0)))
> (display-buffer-in-side-window buffer '((window-height . 0.25)
> (side . bottom)
> (slot . 0)))))
AKA:
(display-buffer-in-side-window buffer
(if (> (frame-width) 100)
'((window-width . 0.28)
(side . left)
(slot . 0))
'((window-height . 0.25)
(side . bottom)
(slot . 0))))
or even
(display-buffer-in-side-window buffer
`(,@(if (> (frame-width) 100)
'((window-width . 0.28)
(side . left))
'((window-height . 0.25)
(side . bottom)))
(slot . 0)))
-- Stefan
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: display-buffer-alist actions
2021-02-25 16:25 ` Eric S Fraga
@ 2021-02-25 20:40 ` Garjola Dindi
0 siblings, 0 replies; 18+ messages in thread
From: Garjola Dindi @ 2021-02-25 20:40 UTC (permalink / raw)
To: help-gnu-emacs
On Thu 25-Feb-2021 at 17:25:15 +01, Eric S Fraga <e.fraga@ucl.ac.uk>
wrote:
> On Wednesday, 24 Feb 2021 at 20:52, Joost Kremers wrote:
>> Yes, it's the easiest thing to grok. I've found Protesilaos Stavrou's
>> comments and Youtube video on the topic helpful:
>
> Indeed. His videos are excellent.
On the same topic, David Wilson recently did a video explaining how to
customize display-buffer:
https://www.youtube.com/watch?v=-H2nU0rsUMY
And just last Friday, he did a live coding session showing how to write
custom display action functions (starting at 34'30"):
https://www.youtube.com/watch?v=iqNhJsVmVUg
>
>> What you could do, however, is write your own display-buffer function,
>> which checks the frame dimensions and calls
>> `display-buffer-side-window` with either `(side . left)` or `(side
>> . bottom)`.
>
> Yes! Very simple and, in hindsight, kind of obvious <blush>. Thank
> you. I have now done this and it works perfectly.
--
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: display-buffer-alist actions
2021-02-25 16:51 ` Stefan Monnier
@ 2021-02-26 9:43 ` Eric S Fraga
0 siblings, 0 replies; 18+ messages in thread
From: Eric S Fraga @ 2021-02-26 9:43 UTC (permalink / raw)
To: help-gnu-emacs
Yes, simpler. Thank you.
--
Eric S Fraga via Emacs 28.0.50 & org 9.4.4 on Debian bullseye/sid
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2021-02-26 9:43 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-24 17:44 display-buffer-alist actions Eric S Fraga
2021-02-24 19:52 ` Joost Kremers
2021-02-24 20:08 ` Joost Kremers
2021-02-24 21:08 ` TRS-80
2021-02-24 20:57 ` Michael Heerdegen
2021-02-25 16:25 ` Eric S Fraga
2021-02-25 20:40 ` Garjola Dindi
2021-02-24 21:15 ` Stefan Monnier
2021-02-25 16:34 ` Eric S Fraga
2021-02-25 16:51 ` Stefan Monnier
2021-02-26 9:43 ` Eric S Fraga
2021-02-25 0:00 ` [External] : " Drew Adams
2021-02-25 4:28 ` Michael Heerdegen
2021-02-25 7:00 ` Drew Adams
2021-02-25 14:26 ` Stefan Monnier
2021-02-25 16:22 ` Drew Adams
2021-02-25 16:36 ` Eric S Fraga
2021-02-25 16:27 ` 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).