GNU bug report logs - #31020
27.0; Please provide a way to know about menu-bar wrapping

Previous Next

Package: emacs;

Reported by: Drew Adams <drew.adams <at> oracle.com>

Date: Mon, 2 Apr 2018 03:04:01 UTC

Severity: wishlist

Tags: wontfix

Found in version 27.0

Done: Stefan Kangas <stefan <at> marxist.se>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 31020 in the body.
You can then email your comments to 31020 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#31020; Package emacs. (Mon, 02 Apr 2018 03:04:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Drew Adams <drew.adams <at> oracle.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 02 Apr 2018 03:04:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 27.0; Please provide a way to know about menu-bar wrapping
Date: Sun, 1 Apr 2018 20:03:00 -0700 (PDT)
Enhancement request.

When a frame is narrower than the text in the
menu-bar, that text is wrapped.  And yet the value of frame parameter
`menu-bar-lines' is not increased (which is good).

It would be good to be able to know (from Elisp) how many "visual"
(effective) menu-bar lines there are currently, that is, how many times
the menu-bar text is wrapped.  (It is typically wrapped zero or one
time, producing text that appears visually to be two lines.)


In GNU Emacs 27.0.50 (build 3, x86_64-w64-mingw32)
 of 2018-03-21
Repository revision: e70d0c9e66d7a8609450b2889869d16aeb0363b5
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
 `configure --without-dbus --host=x86_64-w64-mingw32
 --without-compress-install -C 'CFLAGS=-O2 -static -g3''




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31020; Package emacs. (Mon, 02 Apr 2018 06:10:01 GMT) Full text and rfc822 format available.

Message #8 received at 31020 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: 31020 <at> debbugs.gnu.org
Subject: Re: bug#31020: 27.0;
 Please provide a way to know about menu-bar wrapping
Date: Mon, 02 Apr 2018 09:08:58 +0300
> Date: Sun, 1 Apr 2018 20:03:00 -0700 (PDT)
> From: Drew Adams <drew.adams <at> oracle.com>
> 
> When a frame is narrower than the text in the
> menu-bar, that text is wrapped.  And yet the value of frame parameter
> `menu-bar-lines' is not increased (which is good).
> 
> It would be good to be able to know (from Elisp) how many "visual"
> (effective) menu-bar lines there are currently, that is, how many times
> the menu-bar text is wrapped.  (It is typically wrapped zero or one
> time, producing text that appears visually to be two lines.)

I don't understand why you think that the menu-bar-lines parameter
should not be it.  AFAIU, the problem with setting it (or any other
frame parameter) to the actual value is that with many toolkits Emacs
simply doesn't know the correct value.  But maybe Martin will have
some trick up his sleeves.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31020; Package emacs. (Mon, 02 Apr 2018 08:55:01 GMT) Full text and rfc822 format available.

Message #11 received at 31020 <at> debbugs.gnu.org (full text, mbox):

From: martin rudalics <rudalics <at> gmx.at>
To: Eli Zaretskii <eliz <at> gnu.org>, Drew Adams <drew.adams <at> oracle.com>
Cc: 31020 <at> debbugs.gnu.org
Subject: Re: bug#31020: 27.0; Please provide a way to know about menu-bar
 wrapping
Date: Mon, 02 Apr 2018 10:54:24 +0200
> I don't understand why you think that the menu-bar-lines parameter
> should not be it.  AFAIU, the problem with setting it (or any other
> frame parameter) to the actual value is that with many toolkits Emacs
> simply doesn't know the correct value.  But maybe Martin will have
> some trick up his sleeves.

I am not aware of any toolkit telling us that number or whether the
current menu bar was wrapped at all.  It's nowhere in the various API
descriptions and I suppose the information usually gets lost somewhere
in between calculations of which font the user's theme wants for the
menu bar and how that affects wrapping.  I'm not even sure whether
some toolkit would deliberately truncate our menu bar when it doesn't
fit into one line.  And lets not talk about GTK auto-resizing our
frame when the menu bar gets too long.

So what you can do is the following: Make a frame with a _visibly
unwrapped_ menu bar, get the menu bar height via

(cddr (assq 'menu-bar-size (frame-geometry)))

Do the same for a frame with a _visibly wrapped_ two-lines menu bar.
You can now derive the height of the single-line and any additional
menu bar line and use these values together with 'frame-geometry' for
getting the actual number of lines.

Obviously, this will work only as long as you do not change themes,
the menu bar height of the current theme or the resolution of your
screen or whatever else could affect this.  And since you have to
visuallly check the "wrappedness" of the menu bar, this work cannot be
reasonably done from within Emacs.

martin




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31020; Package emacs. (Mon, 02 Apr 2018 13:26:02 GMT) Full text and rfc822 format available.

Message #14 received at 31020 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 31020 <at> debbugs.gnu.org
Subject: RE: bug#31020: 27.0; Please provide a way to know about menu-bar
 wrapping
Date: Mon, 2 Apr 2018 06:25:30 -0700 (PDT)
> > When a frame is narrower than the text in the
> > menu-bar, that text is wrapped.  And yet the value of frame parameter
> > `menu-bar-lines' is not increased (which is good).
> >
> > It would be good to be able to know (from Elisp) how many "visual"
> > (effective) menu-bar lines there are currently, that is, how many times
> > the menu-bar text is wrapped.  (It is typically wrapped zero or one
> > time, producing text that appears visually to be two lines.)
> 
> I don't understand why you think that the menu-bar-lines parameter
> should not be it.  AFAIU, the problem with setting it (or any other
> frame parameter) to the actual value is that with many toolkits Emacs
> simply doesn't know the correct value.  But maybe Martin will have
> some trick up his sleeves.

I think it's helpful to distinguish (1) the actual,
current number of lines used, reflecting any possible
wrapping, from (2) the user's setting of how many
lines should be used for the menu-bar.

How those are distinguished doesn't matter to me so
much.

And if you decide that there is no sense in such a
distinction, and that the parameter value should be
automatically changed, dynamically, as a frame's
width is changed (e.g. to force or remove wrapping),
then that would probably be OK too.

The problem, at least on MS Windows, is that the
menu-bar wraps, and there is no way (AFAIK) to know
from Lisp who many actual lines are currently used
to show the menu-bar.

This is an old problem, as you know.  It would be
really good to finally put it to bed, if possible.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31020; Package emacs. (Mon, 02 Apr 2018 13:33:02 GMT) Full text and rfc822 format available.

Message #17 received at 31020 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: martin rudalics <rudalics <at> gmx.at>, Eli Zaretskii <eliz <at> gnu.org>
Cc: 31020 <at> debbugs.gnu.org
Subject: RE: bug#31020: 27.0; Please provide a way to know about menu-bar
 wrapping
Date: Mon, 2 Apr 2018 06:32:49 -0700 (PDT)
> So what you can do is the following: Make a frame with a _visibly
> unwrapped_ menu bar, get the menu bar height via
> (cddr (assq 'menu-bar-size (frame-geometry)))
> 
> Do the same for a frame with a _visibly wrapped_ two-lines menu bar.
> You can now derive the height of the single-line and any additional
> menu bar line and use these values together with 'frame-geometry' for
> getting the actual number of lines.

That's good to know; thanks.  But I don't think it will
help code that has only a given frame to examine, e.g.,
code that doesn't want to bother some user by creating
or resizing frames to determine this.  And anyway, the
_code_ cannot, by itself, tell the _visibly wrapped_
condition.

IOW, that suggestion might help a user to determine,
by looking, what the situation is.  But I don't see how
I could use in from Lisp to know what the situation is.
Let me know, if I'm missing something simple.

> Obviously, this will work only as long as you do not change themes,
> the menu bar height of the current theme or the resolution of your
> screen or whatever else could affect this.  And since you have to
> visuallly check the "wrappedness" of the menu bar, this work cannot be
> reasonably done from within Emacs.

Ah, that's just what I meant above.  Thanks for confirming.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31020; Package emacs. (Tue, 03 Apr 2018 06:50:02 GMT) Full text and rfc822 format available.

Message #20 received at 31020 <at> debbugs.gnu.org (full text, mbox):

From: martin rudalics <rudalics <at> gmx.at>
To: Drew Adams <drew.adams <at> oracle.com>, Eli Zaretskii <eliz <at> gnu.org>
Cc: 31020 <at> debbugs.gnu.org
Subject: Re: bug#31020: 27.0; Please provide a way to know about menu-bar
 wrapping
Date: Tue, 03 Apr 2018 08:49:22 +0200
> The problem, at least on MS Windows, is that the
> menu-bar wraps, and there is no way (AFAIK) to know
> from Lisp who many actual lines are currently used
> to show the menu-bar.
>
> This is an old problem, as you know.  It would be
> really good to finally put it to bed, if possible.

Can you tell me one practical case where you want to know how many
lines are used to show the menu bar?

martin




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31020; Package emacs. (Tue, 03 Apr 2018 14:34:01 GMT) Full text and rfc822 format available.

Message #23 received at 31020 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: martin rudalics <rudalics <at> gmx.at>, Eli Zaretskii <eliz <at> gnu.org>
Cc: 31020 <at> debbugs.gnu.org
Subject: RE: bug#31020: 27.0; Please provide a way to know about menu-bar
 wrapping
Date: Tue, 3 Apr 2018 07:28:32 -0700 (PDT)
>  > The problem, at least on MS Windows, is that the
>  > menu-bar wraps, and there is no way (AFAIK) to know
>  > from Lisp who many actual lines are currently used
>  > to show the menu-bar.
>  >
>  > This is an old problem, as you know.  It would be
>  > really good to finally put it to bed, if possible.
> 
> Can you tell me one practical case where you want to
> know how many lines are used to show the menu bar?

Yes.  But you'll perhaps tell me to do things another
way (e.g., pixelwise). ;-)

My fit-frame.el code changes a frame's width and height
to fit the buffer text.  It also takes into account
things like `menu-bar-lines' and `tool-bar-lines'.  It
does its work using chars, i.e., lines and columns, not
pixels.

If the frame before fitting is narrow enough that the
menu-bar is wrapped, and if the frame is narrower than
its fit width (the width it will be fit to, based on
max line length), then the resulting height is slightly
greater than when the menu-bar is not wrapped.  (The
latter height is what I want.)

This has the effect that two different resulting frame
heights are possible, depending on whether the menu is
wrapped.  So the action is not idempotent if the bar is
wrapped (and the max line length is wider than the
unwrapped menu-bar width): The first `fit-frame' makes
the frame a bit taller; the second and subsequent calls
to `fit-frame' make it the right height.  (All calls
give it the right width.)

If my code could know how many _effective_ (i.e.,
visual) `menu-bar-lines' were currently present then
it would just DTRT.

HTH.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31020; Package emacs. (Wed, 04 Apr 2018 07:51:01 GMT) Full text and rfc822 format available.

Message #26 received at 31020 <at> debbugs.gnu.org (full text, mbox):

From: martin rudalics <rudalics <at> gmx.at>
To: Drew Adams <drew.adams <at> oracle.com>, Eli Zaretskii <eliz <at> gnu.org>
Cc: 31020 <at> debbugs.gnu.org
Subject: Re: bug#31020: 27.0; Please provide a way to know about menu-bar
 wrapping
Date: Wed, 04 Apr 2018 09:49:48 +0200
> Yes.  But you'll perhaps tell me to do things another
> way (e.g., pixelwise). ;-)

I'm afraid that both approaches might face similar problems.

> If my code could know how many _effective_ (i.e.,
> visual) `menu-bar-lines' were currently present then
> it would just DTRT.

Why don't you try to divide the value of

(cddr (assq 'menu-bar-size (frame-geometry)))

by 'frame-char-height'?  IIUC the character height used by a toolkit
for drawing the menu bar is of no use to you anyway.

But to fit a frame you (and the pixelwise fitter as well) would have
to be able to tell _in advance_ whether the menu bar will wrap.  And
this is impossible since at least on a proprietary system like Windows
you would have to know which algorithm it uses for aligning menu bar
elements.  Or am I missing something?

martin




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31020; Package emacs. (Sat, 28 Sep 2019 18:43:02 GMT) Full text and rfc822 format available.

Message #29 received at 31020 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefan <at> marxist.se>
To: martin rudalics <rudalics <at> gmx.at>
Cc: 31020 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>,
 Drew Adams <drew.adams <at> oracle.com>
Subject: Re: bug#31020: 27.0;
 Please provide a way to know about menu-bar wrapping
Date: Sat, 28 Sep 2019 20:42:35 +0200
tags 31020 + wontfix
close 31020
quit

martin rudalics <rudalics <at> gmx.at> writes:

>> I don't understand why you think that the menu-bar-lines parameter
>> should not be it.  AFAIU, the problem with setting it (or any other
>> frame parameter) to the actual value is that with many toolkits Emacs
>> simply doesn't know the correct value.  But maybe Martin will have
>> some trick up his sleeves.
>
> I am not aware of any toolkit telling us that number or whether the
> current menu bar was wrapped at all.  It's nowhere in the various API
> descriptions and I suppose the information usually gets lost somewhere
> in between calculations of which font the user's theme wants for the
> menu bar and how that affects wrapping.  I'm not even sure whether
> some toolkit would deliberately truncate our menu bar when it doesn't
> fit into one line.  And lets not talk about GTK auto-resizing our
> frame when the menu bar gets too long.
>
> So what you can do is the following: Make a frame with a _visibly
> unwrapped_ menu bar, get the menu bar height via
>
> (cddr (assq 'menu-bar-size (frame-geometry)))
>
> Do the same for a frame with a _visibly wrapped_ two-lines menu bar.
> You can now derive the height of the single-line and any additional
> menu bar line and use these values together with 'frame-geometry' for
> getting the actual number of lines.
>
> Obviously, this will work only as long as you do not change themes,
> the menu bar height of the current theme or the resolution of your
> screen or whatever else could affect this.  And since you have to
> visuallly check the "wrappedness" of the menu bar, this work cannot be
> reasonably done from within Emacs.

It seems like the conclusion here is that the feature suggestion is not
practical, so I'm closing it as wontfix.

If this is incorrect, please reopen the bug.

Best regards,
Stefan Kangas




Added tag(s) wontfix. Request was from Stefan Kangas <stefan <at> marxist.se> to control <at> debbugs.gnu.org. (Sat, 28 Sep 2019 18:43:03 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 31020 <at> debbugs.gnu.org and Drew Adams <drew.adams <at> oracle.com> Request was from Stefan Kangas <stefan <at> marxist.se> to control <at> debbugs.gnu.org. (Sat, 28 Sep 2019 18:43:03 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 27 Oct 2019 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 182 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.