GNU bug report logs -
#45748
28.0.50; fit-frame-to-buffer ignores leading spaces
Previous Next
Reported by: Aaron Jensen <aaronjensen <at> gmail.com>
Date: Sat, 9 Jan 2021 15:44:01 UTC
Severity: normal
Found in version 28.0.50
Done: Eli Zaretskii <eliz <at> gnu.org>
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 45748 in the body.
You can then email your comments to 45748 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45748
; Package
emacs
.
(Sat, 09 Jan 2021 15:44:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Aaron Jensen <aaronjensen <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Sat, 09 Jan 2021 15:44:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
From emacs -Q:
Create a buffer with only the following text and no trailing newline
(note the leading space):
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
M-x fit-frame-to-buffer
The frame will be resized to the width of the X's, not including the
leading space, causing the line to wrap.
If the leading space is removed, it works as expected.
Any number of leading spaces are ignored, as are trailing spaces.
This has practical applications with company-posframe, which uses
sometimes one line child windows to show completion options and has
leading and trailing spaces around each completion.
In GNU Emacs 28.0.50 (build 1, x86_64-apple-darwin19.6.0, NS
appkit-1894.60 Version 10.15.7 (Build 19H114))
of 2021-01-08 built on aaron-sub.local
Repository revision: d1c5e7afb1ad9890d925e8c1a5392b701a754dd5
Repository branch: master
Windowing system distributor 'Apple', version 10.3.1894
System Description: Mac OS X 10.15.7
Aaron
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45748
; Package
emacs
.
(Sat, 09 Jan 2021 15:58:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 45748 <at> debbugs.gnu.org (full text, mbox):
I believe the problem is with:
(window-text-pixel-size nil t)
The FROM of t causes window-text-pixel-size to ignore leading spaces.
A TO of t, causes it to ignore trailing spaces. fit-frame-to-buffer
passes both as t. This is hardcoded unless you use
fit-frame-to-buffer-1
I can't say if window-text-pixel-size is behaving as expected or not.
Aaron
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45748
; Package
emacs
.
(Sat, 09 Jan 2021 16:28:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 45748 <at> debbugs.gnu.org (full text, mbox):
On Sat, Jan 9, 2021 at 9:57 AM Aaron Jensen <aaronjensen <at> gmail.com> wrote:
>
> I believe the problem is with:
>
> (window-text-pixel-size nil t)
>
> The FROM of t causes window-text-pixel-size to ignore leading spaces.
> A TO of t, causes it to ignore trailing spaces. fit-frame-to-buffer
> passes both as t. This is hardcoded unless you use
> fit-frame-to-buffer-1
>
> I can't say if window-text-pixel-size is behaving as expected or not.
The problematic code appears to be here in window-text-pixel-size:
else if (EQ (from, Qt))
{
start = BEGV;
bpos = BEGV_BYTE;
while (bpos < ZV_BYTE)
{
c = fetch_char_advance (&start, &bpos);
if (!(c == ' ' || c == '\t' || c == '\n' || c == '\r'))
break;
}
while (bpos > BEGV_BYTE)
{
dec_both (&start, &bpos);
c = FETCH_BYTE (bpos);
if (!(c == ' ' || c == '\t'))
break;
}
}
The second loop looks like it's attempting to backtrack to the
beginning of the line, but FETCH_BYTE (bpos) after a dec_both returns
the same character that the first loop ended on. In other words, start
and bpos are not in sync, or the way that FETCH_BYTE works is
different. If I subtract 1 from bpos when calling FETCH_BYTE, it works
as expected.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45748
; Package
emacs
.
(Sat, 09 Jan 2021 17:08:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 45748 <at> debbugs.gnu.org (full text, mbox):
> I believe the problem is with:
>
> (window-text-pixel-size nil t)
>
> The FROM of t causes window-text-pixel-size to ignore leading spaces.
> A TO of t, causes it to ignore trailing spaces. fit-frame-to-buffer
> passes both as t. This is hardcoded unless you use
> fit-frame-to-buffer-1
>
> I can't say if window-text-pixel-size is behaving as expected or not.
Neither can I but the outcome is annoying. What would you suggest to
do? I ask because with
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
the leading space on the first line must be shown. Maybe I don't see an
all too obvious fix here.
martin
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45748
; Package
emacs
.
(Sat, 09 Jan 2021 17:08:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 45748 <at> debbugs.gnu.org (full text, mbox):
> The problematic code appears to be here in window-text-pixel-size:
>
> else if (EQ (from, Qt))
> {
> start = BEGV;
> bpos = BEGV_BYTE;
> while (bpos < ZV_BYTE)
> {
> c = fetch_char_advance (&start, &bpos);
> if (!(c == ' ' || c == '\t' || c == '\n' || c == '\r'))
> break;
> }
> while (bpos > BEGV_BYTE)
> {
> dec_both (&start, &bpos);
> c = FETCH_BYTE (bpos);
> if (!(c == ' ' || c == '\t'))
> break;
> }
> }
>
> The second loop looks like it's attempting to backtrack to the
> beginning of the line, but FETCH_BYTE (bpos) after a dec_both returns
> the same character that the first loop ended on. In other words, start
> and bpos are not in sync, or the way that FETCH_BYTE works is
> different. If I subtract 1 from bpos when calling FETCH_BYTE, it works
> as expected.
Do you mean the first dec_both skips too much or not enough? That code
was broken when I wrote it initially, someone fixed the char/byte issue
later and now I'm too silly to understand it.
martin
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45748
; Package
emacs
.
(Sat, 09 Jan 2021 17:45:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 45748 <at> debbugs.gnu.org (full text, mbox):
> From: Aaron Jensen <aaronjensen <at> gmail.com>
> Date: Sat, 9 Jan 2021 10:27:12 -0600
>
> On Sat, Jan 9, 2021 at 9:57 AM Aaron Jensen <aaronjensen <at> gmail.com> wrote:
> >
> > I believe the problem is with:
> >
> > (window-text-pixel-size nil t)
You mean with
(window-text-pixel-size t t)
right?
> > The FROM of t causes window-text-pixel-size to ignore leading spaces.
> > A TO of t, causes it to ignore trailing spaces. fit-frame-to-buffer
> > passes both as t. This is hardcoded unless you use
> > fit-frame-to-buffer-1
??? fit-frame-to-buffer always calls fit-frame-to-buffer-1, sow hat do
you mean by "unless"?
> The problematic code appears to be here in window-text-pixel-size:
>
> else if (EQ (from, Qt))
> {
> start = BEGV;
> bpos = BEGV_BYTE;
> while (bpos < ZV_BYTE)
> {
> c = fetch_char_advance (&start, &bpos);
> if (!(c == ' ' || c == '\t' || c == '\n' || c == '\r'))
> break;
> }
> while (bpos > BEGV_BYTE)
> {
> dec_both (&start, &bpos);
> c = FETCH_BYTE (bpos);
> if (!(c == ' ' || c == '\t'))
> break;
> }
> }
>
> The second loop looks like it's attempting to backtrack to the
> beginning of the line, but FETCH_BYTE (bpos) after a dec_both returns
> the same character that the first loop ended on.
No, it doesn't, it returns the byte at bpos after decrementing bpos.
So it's the character before that.
> In other words, start and bpos are not in sync
??? FETCH_BYTE doesn't change bpos, so if it was in sync with start
before FETCH_BYTE, it is still in sync after it. So I don't think I
understand what you mean here.
Can you elaborate on your findings, please?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45748
; Package
emacs
.
(Sat, 09 Jan 2021 17:46:01 GMT)
Full text and
rfc822 format available.
Message #23 received at 45748 <at> debbugs.gnu.org (full text, mbox):
On Sat, Jan 9, 2021 at 11:07 AM martin rudalics <rudalics <at> gmx.at> wrote:
> Do you mean the first dec_both skips too much or not enough? That code
> was broken when I wrote it initially, someone fixed the char/byte issue
> later and now I'm too silly to understand it.
It doesn't skip enough. I believe this fixes both the leading and
trailing space problems:
diff --git a/src/xdisp.c b/src/xdisp.c
index 6a4304d194..20e7ca3a1e 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -10652,7 +10652,10 @@ DEFUN ("window-text-pixel-size",
Fwindow_text_pixel_size, Swindow_text_pixel_siz
{
c = fetch_char_advance (&start, &bpos);
if (!(c == ' ' || c == '\t' || c == '\n' || c == '\r'))
- break;
+ {
+ dec_both (&start, &bpos);
+ break;
+ }
}
while (bpos > BEGV_BYTE)
{
@@ -10680,12 +10683,17 @@ DEFUN ("window-text-pixel-size",
Fwindow_text_pixel_size, Swindow_text_pixel_siz
{
dec_both (&end, &bpos);
c = FETCH_BYTE (bpos);
if (!(c == ' ' || c == '\t' || c == '\n' || c == '\r'))
- break;
+ {
+ inc_both (&end, &bpos);
+ break;
+ }
}
while (bpos < ZV_BYTE)
{
c = fetch_char_advance (&end, &bpos);
if (!(c == ' ' || c == '\t'))
break;
}
The problem is that the first loop leaves the pointer pointing to the
next character and it's only back tracked once.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45748
; Package
emacs
.
(Sat, 09 Jan 2021 17:50:02 GMT)
Full text and
rfc822 format available.
Message #26 received at 45748 <at> debbugs.gnu.org (full text, mbox):
On Sat, Jan 9, 2021 at 11:44 AM Eli Zaretskii <eliz <at> gnu.org> wrote:
>
> You mean with
>
> (window-text-pixel-size t t)
>
> right?
Yes, sorry bad copy/paste.
> ??? fit-frame-to-buffer always calls fit-frame-to-buffer-1, sow hat do
> you mean by "unless"?
I mean unless you call fit-frame-to-buffer-1 passing nil for from and
to, which I believe is the most likely desired behavior for something
like posframe, but I'm not the maintainer of that so I couldn't say
for certain.
> > The second loop looks like it's attempting to backtrack to the
> > beginning of the line, but FETCH_BYTE (bpos) after a dec_both returns
> > the same character that the first loop ended on.
>
> No, it doesn't, it returns the byte at bpos after decrementing bpos.
> So it's the character before that.
Maybe we're just getting hung up on my wording. After
fetch_char_advance, bpos points to the byte of the character after
what was returned from fetch_char_advance. If you then dec_both and
FETCH_BYTE, you will get the same character returned from the last
time fetch_char_advance was called, which was likely not the intent.
> > In other words, start and bpos are not in sync
>
> ??? FETCH_BYTE doesn't change bpos, so if it was in sync with start
> before FETCH_BYTE, it is still in sync after it. So I don't think I
> understand what you mean here.
>
> Can you elaborate on your findings, please?
Yeah, I was mistaken on that point. They stay in sync. They both
needed to backtrack an extra time. See my patch in the email I sent
right before this one.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45748
; Package
emacs
.
(Sat, 09 Jan 2021 17:56:02 GMT)
Full text and
rfc822 format available.
Message #29 received at 45748 <at> debbugs.gnu.org (full text, mbox):
On Sat, Jan 9, 2021 at 11:44 AM Aaron Jensen <aaronjensen <at> gmail.com> wrote:
>
> diff --git a/src/xdisp.c b/src/xdisp.c
> index 6a4304d194..20e7ca3a1e 100644
> --- a/src/xdisp.c
> +++ b/src/xdisp.c
> @@ -10652,7 +10652,10 @@ DEFUN ("window-text-pixel-size",
> Fwindow_text_pixel_size, Swindow_text_pixel_siz
> {
It might actually be easier to read and understand if it was written
without fetch_char_advance and just used inc_both, dec_both and
FETCH_BYTE. I don't know if fetch_char_advance is doing something that
that combination wouldn't do, however, so I can't say if that'd be
safe or not.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45748
; Package
emacs
.
(Sat, 09 Jan 2021 18:04:01 GMT)
Full text and
rfc822 format available.
Message #32 received at 45748 <at> debbugs.gnu.org (full text, mbox):
> From: Aaron Jensen <aaronjensen <at> gmail.com>
> Date: Sat, 9 Jan 2021 11:44:46 -0600
> Cc: 45748 <at> debbugs.gnu.org
>
> diff --git a/src/xdisp.c b/src/xdisp.c
> index 6a4304d194..20e7ca3a1e 100644
> --- a/src/xdisp.c
> +++ b/src/xdisp.c
> @@ -10652,7 +10652,10 @@ DEFUN ("window-text-pixel-size",
> Fwindow_text_pixel_size, Swindow_text_pixel_siz
> {
> c = fetch_char_advance (&start, &bpos);
> if (!(c == ' ' || c == '\t' || c == '\n' || c == '\r'))
> - break;
> + {
> + dec_both (&start, &bpos);
> + break;
> + }
> }
This increments position, then decrements it, which is sub-optimal.
> {
> dec_both (&end, &bpos);
> c = FETCH_BYTE (bpos);
> if (!(c == ' ' || c == '\t' || c == '\n' || c == '\r'))
> - break;
> + {
> + inc_both (&end, &bpos);
> + break;
> + }
> }
Same here.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45748
; Package
emacs
.
(Sat, 09 Jan 2021 18:15:02 GMT)
Full text and
rfc822 format available.
Message #35 received at 45748 <at> debbugs.gnu.org (full text, mbox):
> From: Aaron Jensen <aaronjensen <at> gmail.com>
> Date: Sat, 9 Jan 2021 11:55:06 -0600
> Cc: 45748 <at> debbugs.gnu.org
>
> It might actually be easier to read and understand if it was written
> without fetch_char_advance and just used inc_both, dec_both and
> FETCH_BYTE.
Yes, probably.
But before we do any changes here, we need a test suite. Would you
mind adding the necessary tests to test/src/xdisp-tests.el?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45748
; Package
emacs
.
(Sun, 10 Jan 2021 02:57:01 GMT)
Full text and
rfc822 format available.
Message #38 received at 45748 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On Sat, Jan 9, 2021 at 12:14 PM Eli Zaretskii <eliz <at> gnu.org> wrote:
> Yes, probably.
>
> But before we do any changes here, we need a test suite. Would you
> mind adding the necessary tests to test/src/xdisp-tests.el?
Okay, I added a few basic tests for this case. I don't know if that's
the best way to test it, but it's what I could figure out.
The implementation bypasses the extra backtrack for the FROM, but the
algorithm for the TO is the same as I first submitted. In that case,
it's not really an extra backtrack since I have to dec to read the
byte. If I had access to dec_bytepos declared in syntax.c, I think I
could use that to avoid the extra backtrack (I'd fetch the dec_bytepos
(bpos)) and test that and then only move the pointers if not breaking
from the loop.
I left the fetch_char_advance in the TO algorithm since it didn't seem
necessary to replace it with separate fetch/inc_both.
This could be done w/o the backtracking entirely by keeping two
pointers, but that's more complicated, probably not much more
efficient (if at all) and this will likely never be called in a tight
loop.
Let me know how this looks and if you want me to make any tweaks.
[0001-Fix-window-text-pixel-size-with-leading-trailing-spa.patch (application/octet-stream, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45748
; Package
emacs
.
(Sun, 10 Jan 2021 16:06:02 GMT)
Full text and
rfc822 format available.
Message #41 received at 45748 <at> debbugs.gnu.org (full text, mbox):
> Let me know how this looks and if you want me to make any tweaks.
dec_both (&end, &bpos);
c = FETCH_BYTE (bpos);
if (!(c == ' ' || c == '\t' || c == '\n' || c == '\r'))
Sorry but on that last line I have
if (!(c == ' ' || c == '\t'))
or am I confused?
martin
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45748
; Package
emacs
.
(Sun, 10 Jan 2021 17:33:02 GMT)
Full text and
rfc822 format available.
Message #44 received at 45748 <at> debbugs.gnu.org (full text, mbox):
On Sun, Jan 10, 2021 at 10:05 AM martin rudalics <rudalics <at> gmx.at> wrote:
>
> > Let me know how this looks and if you want me to make any tweaks.
>
> dec_both (&end, &bpos);
> c = FETCH_BYTE (bpos);
> if (!(c == ' ' || c == '\t' || c == '\n' || c == '\r'))
>
> Sorry but on that last line I have
>
> if (!(c == ' ' || c == '\t'))
>
> or am I confused?
Not sure I follow, does the patch not apply?
Here is what I have after my patch for the handling of the TO == t:
end = ZV;
bpos = ZV_BYTE;
while (bpos > BEGV_BYTE)
{
dec_both (&end, &bpos);
c = FETCH_BYTE (bpos);
if (!(c == ' ' || c == '\t' || c == '\n' || c == '\r'))
{
inc_both (&end, &bpos);
break;
}
}
while (bpos < ZV_BYTE)
{
c = fetch_char_advance (&end, &bpos);
if (!(c == ' ' || c == '\t'))
break;
}
and before:
end = ZV;
bpos = ZV_BYTE;
while (bpos > BEGV_BYTE)
{
dec_both (&end, &bpos);
c = FETCH_BYTE (bpos);
if (!(c == ' ' || c == '\t' || c == '\n' || c == '\r'))
break;
}
while (bpos < ZV_BYTE)
{
c = fetch_char_advance (&end, &bpos);
if (!(c == ' ' || c == '\t'))
break;
}
The difference is the inc_both before the break in the *first* loop,
not the second.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45748
; Package
emacs
.
(Sun, 10 Jan 2021 17:50:03 GMT)
Full text and
rfc822 format available.
Message #47 received at 45748 <at> debbugs.gnu.org (full text, mbox):
> Not sure I follow, does the patch not apply?
It didn't for some reason but applies now and seems to DTRT. So I think
you should install it.
Thanks, martin
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45748
; Package
emacs
.
(Sun, 10 Jan 2021 17:52:01 GMT)
Full text and
rfc822 format available.
Message #50 received at 45748 <at> debbugs.gnu.org (full text, mbox):
On Sun, Jan 10, 2021 at 11:49 AM martin rudalics <rudalics <at> gmx.at> wrote:
>
> > Not sure I follow, does the patch not apply?
>
> It didn't for some reason but applies now and seems to DTRT. So I think
> you should install it.
Sorry, dtrt as in dtrt-mode? or something else? And by install do you
mean apply the patch (I'm not a committer). Sorry, just not up on al
the lingo :)
Thanks,
Aaron
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45748
; Package
emacs
.
(Sun, 10 Jan 2021 17:58:02 GMT)
Full text and
rfc822 format available.
Message #53 received at 45748 <at> debbugs.gnu.org (full text, mbox):
>> It didn't for some reason but applies now and seems to DTRT. So I think
>> you should install it.
>
> Sorry, dtrt as in dtrt-mode?
DTRT as in "does the right thing".
> or something else? And by install do you
> mean apply the patch (I'm not a committer).
I meant to push it. Eli, if you are OK with it, please push it.
> Sorry, just not up on al
> the lingo :)
martin, who didn't know that a dtrt-mode existed
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45748
; Package
emacs
.
(Sun, 10 Jan 2021 18:00:02 GMT)
Full text and
rfc822 format available.
Message #56 received at 45748 <at> debbugs.gnu.org (full text, mbox):
On Sun, Jan 10, 2021 at 11:57 AM martin rudalics <rudalics <at> gmx.at> wrote:
>
> DTRT as in "does the right thing".
Ah, TIL (that's Today I Learned ;) )
> martin, who didn't know that a dtrt-mode existed
Hah
Best,
Aaron
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45748
; Package
emacs
.
(Wed, 13 Jan 2021 04:36:01 GMT)
Full text and
rfc822 format available.
Message #59 received at 45748 <at> debbugs.gnu.org (full text, mbox):
Eli,
On Sat, Jan 9, 2021 at 8:56 PM Aaron Jensen <aaronjensen <at> gmail.com> wrote:
>
> On Sat, Jan 9, 2021 at 12:14 PM Eli Zaretskii <eliz <at> gnu.org> wrote:
> > Yes, probably.
> >
> > But before we do any changes here, we need a test suite. Would you
> > mind adding the necessary tests to test/src/xdisp-tests.el?
>
> Okay, I added a few basic tests for this case. I don't know if that's
> the best way to test it, but it's what I could figure out.
> ...
Does this one look good to you?
Aaron
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45748
; Package
emacs
.
(Wed, 13 Jan 2021 14:27:02 GMT)
Full text and
rfc822 format available.
Message #62 received at 45748 <at> debbugs.gnu.org (full text, mbox):
> From: Aaron Jensen <aaronjensen <at> gmail.com>
> Date: Tue, 12 Jan 2021 22:34:42 -0600
> Cc: martin rudalics <rudalics <at> gmx.at>, 45748 <at> debbugs.gnu.org
>
> > On Sat, Jan 9, 2021 at 12:14 PM Eli Zaretskii <eliz <at> gnu.org> wrote:
> > > Yes, probably.
> > >
> > > But before we do any changes here, we need a test suite. Would you
> > > mind adding the necessary tests to test/src/xdisp-tests.el?
> >
> > Okay, I added a few basic tests for this case. I don't know if that's
> > the best way to test it, but it's what I could figure out.
> > ...
>
> Does this one look good to you?
Sorry, I didn't yet have time to take a good look at the changes. I
will do that in a couple of days.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45748
; Package
emacs
.
(Fri, 15 Jan 2021 12:12:02 GMT)
Full text and
rfc822 format available.
Message #65 received at 45748 <at> debbugs.gnu.org (full text, mbox):
> From: Aaron Jensen <aaronjensen <at> gmail.com>
> Date: Sat, 9 Jan 2021 20:56:35 -0600
> Cc: martin rudalics <rudalics <at> gmx.at>, 45748 <at> debbugs.gnu.org
>
> Let me know how this looks and if you want me to make any tweaks.
Thanks, I installed this on the master branch.
However, the new tests fail for me in batch execution on MS-Windows
with this error:
Test xdisp-tests--window-text-pixel-size condition:
(error "Not using an ASCII terminal now; cannot make a new ASCII frame")
It works if I run the test interactively.
The backtrace is
make-terminal-frame(((parent-frame . #<frame F1 062dca38>)))
tty-create-frame-with-faces(((parent-frame . #<frame F1 062dca38>)))
#f(compiled-function (params) #<bytecode 0x6bc24af6be4b5d2>)(((paren
apply(#f(compiled-function (params) #<bytecode 0x6bc24af6be4b5d2>) (
frame-creation-function(((parent-frame . #<frame F1 062dca38>)))
make-frame(((parent-frame . #<frame F1 062dca38>)))
display-buffer-in-child-frame(#<killed buffer> nil)
display-buffer(#<killed buffer> (display-buffer-in-child-frame))
(let* ((window (display-buffer (current-buffer) '(display-buffer-in-
(progn (insert "xx ") (let* ((window (display-buffer (current-buffer
(unwind-protect (progn (insert "xx ") (let* ((window (display-buffer
(save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn
(let ((temp-buffer (generate-new-buffer " *temp*" t))) (save-current
(closure (t) nil (let ((temp-buffer (generate-new-buffer " *temp*" t
ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test
ert-run-test(#s(ert-test :name xdisp-tests--window-text-pixel-size-t
ert-run-or-rerun-test(#s(ert--stats :selector ... :tests ... :test-m
ert-run-tests((not (tag :unstable)) #f(compiled-function (event-type
ert-run-tests-batch((not (tag :unstable)))
ert-run-tests-batch-and-exit((not (tag :unstable)))
eval((ert-run-tests-batch-and-exit '(not (tag :unstable))) t)
I guess you are assuming some functionality that isn't supported on
all platforms? Can you please rewrite the tests so that they work on
all platforms?
Thanks.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45748
; Package
emacs
.
(Fri, 15 Jan 2021 12:35:02 GMT)
Full text and
rfc822 format available.
Message #68 received at 45748 <at> debbugs.gnu.org (full text, mbox):
On Fri, Jan 15, 2021 at 6:11 AM Eli Zaretskii <eliz <at> gnu.org> wrote:
>
> However, the new tests fail for me in batch execution on MS-Windows
> with this error:
>
> Test xdisp-tests--window-text-pixel-size condition:
> (error "Not using an ASCII terminal now; cannot make a new ASCII frame")
>
> It works if I run the test interactively.
The tests do not work in batch mode. I don't know of a way to test
window-text-pixel-size in a terminal since it requires GUI.
> I guess you are assuming some functionality that isn't supported on
> all platforms? Can you please rewrite the tests so that they work on
> all platforms?
I don't think it's a platform issue. Is there a standard for tests
that are GUI/interactive only? Perhaps you could wrap the tests
accordingly?
Thanks,
Aaron
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45748
; Package
emacs
.
(Fri, 15 Jan 2021 13:16:02 GMT)
Full text and
rfc822 format available.
Message #71 received at 45748 <at> debbugs.gnu.org (full text, mbox):
> From: Aaron Jensen <aaronjensen <at> gmail.com>
> Date: Fri, 15 Jan 2021 06:34:34 -0600
> Cc: martin rudalics <rudalics <at> gmx.at>, 45748 <at> debbugs.gnu.org
>
> > Test xdisp-tests--window-text-pixel-size condition:
> > (error "Not using an ASCII terminal now; cannot make a new ASCII frame")
> >
> > It works if I run the test interactively.
>
> The tests do not work in batch mode. I don't know of a way to test
> window-text-pixel-size in a terminal since it requires GUI.
Why does it require GUI?
> I don't think it's a platform issue. Is there a standard for tests
> that are GUI/interactive only?
If we need to do this interactively, we could move the tests to
manual/redisplay-testsuite.el. But I'd like first to try to make them
work in batch.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45748
; Package
emacs
.
(Fri, 15 Jan 2021 14:05:02 GMT)
Full text and
rfc822 format available.
Message #74 received at 45748 <at> debbugs.gnu.org (full text, mbox):
On Fri, Jan 15, 2021 at 7:15 AM Eli Zaretskii <eliz <at> gnu.org> wrote:
> Why does it require GUI?
It may not, but I couldn't figure out how to control the window well
enough to predict its size, which is likely ignorance.
That's why I created a child frame so I knew that only what I wanted
was visible and I could predict its size.
I can try a few things later, though I'm open to any suggestions.
Thanks,
Aaron
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45748
; Package
emacs
.
(Fri, 15 Jan 2021 15:38:01 GMT)
Full text and
rfc822 format available.
Message #77 received at 45748 <at> debbugs.gnu.org (full text, mbox):
> From: Aaron Jensen <aaronjensen <at> gmail.com>
> Date: Fri, 15 Jan 2021 08:04:00 -0600
> Cc: martin rudalics <rudalics <at> gmx.at>, 45748 <at> debbugs.gnu.org
>
> On Fri, Jan 15, 2021 at 7:15 AM Eli Zaretskii <eliz <at> gnu.org> wrote:
> > Why does it require GUI?
>
> It may not, but I couldn't figure out how to control the window well
> enough to predict its size, which is likely ignorance.
> That's why I created a child frame so I knew that only what I wanted
> was visible and I could predict its size.
> I can try a few things later, though I'm open to any suggestions.
We don't really need to resize a frame, we just need to call the
function and check its result, right?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45748
; Package
emacs
.
(Fri, 15 Jan 2021 17:04:02 GMT)
Full text and
rfc822 format available.
Message #80 received at 45748 <at> debbugs.gnu.org (full text, mbox):
On Fri, Jan 15, 2021 at 9:37 AM Eli Zaretskii <eliz <at> gnu.org> wrote:
>
> We don't really need to resize a frame, we just need to call the
> function and check its result, right?
I need to control the contents of a "visible" window and call the
function and check its result. When I attempted to do that, I wasn't
sure if I was getting the size of the test window or something else. I
didn't seem to be able to control it as I wanted to. See how the
current test works.
Aaron
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45748
; Package
emacs
.
(Sat, 16 Jan 2021 17:13:01 GMT)
Full text and
rfc822 format available.
Message #83 received at 45748 <at> debbugs.gnu.org (full text, mbox):
(xdisp-tests--window-text-pixel-size)
(xdisp-tests--window-text-pixel-size-leading-space)
(xdisp-tests--window-text-pixel-size-trailing-space): Fix tests
---
test/src/xdisp-tests.el | 39 +++++++++++++++++++++------------------
1 file changed, 21 insertions(+), 18 deletions(-)
diff --git a/test/src/xdisp-tests.el b/test/src/xdisp-tests.el
index ec96d777ff..09c2fa83b3 100644
--- a/test/src/xdisp-tests.el
+++ b/test/src/xdisp-tests.el
@@ -73,33 +73,36 @@ xdisp-tests--minibuffer-scroll
(should (equal (nth 1 posns) (nth 2 posns)))))
(ert-deftest xdisp-tests--window-text-pixel-size () ;; bug#45748
- (with-temp-buffer
+ (with-current-buffer-window "*test*" 'display-buffer-reuse-window nil
+ (erase-buffer)
(insert "xxx")
- (let* ((window
- (display-buffer (current-buffer) '(display-buffer-in-child-frame . nil)))
- (char-width (frame-char-width))
- (size (window-text-pixel-size nil t t)))
- (delete-frame (window-frame window))
+ (let* ((char-width (frame-char-width))
+ (size (window-text-pixel-size (get-buffer-window) t t)))
+ (message "Size: %S" size)
+ (should (equal (/ (car size) char-width) 3)))))
+
+(ert-deftest xdisp-tests--window-text-pixel-size () ;; bug#45748
+ (with-current-buffer (generate-new-buffer "*test*")
+ (insert "xxx")
+ (switch-to-buffer (current-buffer))
+ (let* ((char-width (frame-char-width))
+ (size (window-text-pixel-size nil t t)))
(should (equal (/ (car size) char-width) 3)))))
(ert-deftest xdisp-tests--window-text-pixel-size-leading-space () ;; bug#45748
- (with-temp-buffer
+ (with-current-buffer (generate-new-buffer "*test*")
(insert " xx")
- (let* ((window
- (display-buffer (current-buffer) '(display-buffer-in-child-frame . nil)))
- (char-width (frame-char-width))
- (size (window-text-pixel-size nil t t)))
- (delete-frame (window-frame window))
+ (switch-to-buffer (current-buffer))
+ (let* ((char-width (frame-char-width))
+ (size (window-text-pixel-size nil t t)))
(should (equal (/ (car size) char-width) 3)))))
(ert-deftest xdisp-tests--window-text-pixel-size-trailing-space () ;; bug#45748
- (with-temp-buffer
+ (with-current-buffer (generate-new-buffer "*test*")
(insert "xx ")
- (let* ((window
- (display-buffer (current-buffer) '(display-buffer-in-child-frame . nil)))
- (char-width (frame-char-width))
- (size (window-text-pixel-size nil t t)))
- (delete-frame (window-frame window))
+ (switch-to-buffer (current-buffer))
+ (let* ((char-width (frame-char-width))
+ (size (window-text-pixel-size nil t t)))
(should (equal (/ (car size) char-width) 3)))))
;;; xdisp-tests.el ends here
--
2.28.0
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45748
; Package
emacs
.
(Sat, 16 Jan 2021 17:59:02 GMT)
Full text and
rfc822 format available.
Message #86 received at 45748 <at> debbugs.gnu.org (full text, mbox):
Aaron Jensen <aaronjensen <at> gmail.com> writes:
> diff --git a/test/src/xdisp-tests.el b/test/src/xdisp-tests.el
> index ec96d777ff..09c2fa83b3 100644
> --- a/test/src/xdisp-tests.el
> +++ b/test/src/xdisp-tests.el
> @@ -73,33 +73,36 @@ xdisp-tests--minibuffer-scroll
> (should (equal (nth 1 posns) (nth 2 posns)))))
>
> (ert-deftest xdisp-tests--window-text-pixel-size () ;; bug#45748
FWIW, you can also include the bug number in the test's docstring, if
you prefer.
> - (with-temp-buffer
> + (with-current-buffer-window "*test*" 'display-buffer-reuse-window nil
Ideally the tests wouldn't leave this buffer lying around after they
have run; see (info "(ert) Tests and Their Environment").
Also, why does this test not use with-current-buffer like the other
ones?
> + (erase-buffer)
> (insert "xxx")
> - (let* ((window
> - (display-buffer (current-buffer) '(display-buffer-in-child-frame . nil)))
> - (char-width (frame-char-width))
> - (size (window-text-pixel-size nil t t)))
> - (delete-frame (window-frame window))
> + (let* ((char-width (frame-char-width))
Nit: this and subsequent let* can also be let.
> + (size (window-text-pixel-size (get-buffer-window) t t)))
Is get-buffer-window necessary?
> + (message "Size: %S" size)
This debugging leftover should probably be removed.
> + (should (equal (/ (car size) char-width) 3)))))
Thanks,
--
Basil
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45748
; Package
emacs
.
(Sat, 16 Jan 2021 18:26:02 GMT)
Full text and
rfc822 format available.
Message #89 received at 45748 <at> debbugs.gnu.org (full text, mbox):
Thanks Basil, updated.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45748
; Package
emacs
.
(Sat, 16 Jan 2021 18:26:02 GMT)
Full text and
rfc822 format available.
Message #92 received at 45748 <at> debbugs.gnu.org (full text, mbox):
(xdisp-tests--window-text-pixel-size)
(xdisp-tests--window-text-pixel-size-leading-space)
(xdisp-tests--window-text-pixel-size-trailing-space): Fix tests
---
test/src/xdisp-tests.el | 42 ++++++++++++++++++++---------------------
1 file changed, 21 insertions(+), 21 deletions(-)
diff --git a/test/src/xdisp-tests.el b/test/src/xdisp-tests.el
index ec96d777ff..637cc796a3 100644
--- a/test/src/xdisp-tests.el
+++ b/test/src/xdisp-tests.el
@@ -73,33 +73,33 @@ xdisp-tests--minibuffer-scroll
(should (equal (nth 1 posns) (nth 2 posns)))))
(ert-deftest xdisp-tests--window-text-pixel-size () ;; bug#45748
- (with-temp-buffer
+ (with-current-buffer (generate-new-buffer "*test*")
(insert "xxx")
- (let* ((window
- (display-buffer (current-buffer) '(display-buffer-in-child-frame . nil)))
- (char-width (frame-char-width))
- (size (window-text-pixel-size nil t t)))
- (delete-frame (window-frame window))
- (should (equal (/ (car size) char-width) 3)))))
+ (switch-to-buffer (current-buffer))
+ (let* ((char-width (frame-char-width))
+ (size (window-text-pixel-size nil t t))
+ (width-in-chars (/ (car size) char-width)))
+ (kill-buffer)
+ (should (equal width-in-chars 3)))))
(ert-deftest xdisp-tests--window-text-pixel-size-leading-space () ;; bug#45748
- (with-temp-buffer
+ (with-current-buffer (generate-new-buffer "*test*")
(insert " xx")
- (let* ((window
- (display-buffer (current-buffer) '(display-buffer-in-child-frame . nil)))
- (char-width (frame-char-width))
- (size (window-text-pixel-size nil t t)))
- (delete-frame (window-frame window))
- (should (equal (/ (car size) char-width) 3)))))
+ (switch-to-buffer (current-buffer))
+ (let* ((char-width (frame-char-width))
+ (size (window-text-pixel-size nil t t))
+ (width-in-chars (/ (car size) char-width)))
+ (kill-buffer)
+ (should (equal width-in-chars 3)))))
(ert-deftest xdisp-tests--window-text-pixel-size-trailing-space () ;; bug#45748
- (with-temp-buffer
+ (with-current-buffer (generate-new-buffer "*test*")
(insert "xx ")
- (let* ((window
- (display-buffer (current-buffer) '(display-buffer-in-child-frame . nil)))
- (char-width (frame-char-width))
- (size (window-text-pixel-size nil t t)))
- (delete-frame (window-frame window))
- (should (equal (/ (car size) char-width) 3)))))
+ (switch-to-buffer (current-buffer))
+ (let* ((char-width (frame-char-width))
+ (size (window-text-pixel-size nil t t))
+ (width-in-chars (/ (car size) char-width)))
+ (kill-buffer)
+ (should (equal width-in-chars 3)))))
;;; xdisp-tests.el ends here
--
2.28.0
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45748
; Package
emacs
.
(Sat, 16 Jan 2021 18:30:02 GMT)
Full text and
rfc822 format available.
Message #95 received at 45748 <at> debbugs.gnu.org (full text, mbox):
Updated again to use with-temp-buffer
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45748
; Package
emacs
.
(Sat, 16 Jan 2021 18:30:02 GMT)
Full text and
rfc822 format available.
Message #98 received at 45748 <at> debbugs.gnu.org (full text, mbox):
(xdisp-tests--window-text-pixel-size)
(xdisp-tests--window-text-pixel-size-leading-space)
(xdisp-tests--window-text-pixel-size-trailing-space): Fix tests
---
test/src/xdisp-tests.el | 33 +++++++++++++++------------------
1 file changed, 15 insertions(+), 18 deletions(-)
diff --git a/test/src/xdisp-tests.el b/test/src/xdisp-tests.el
index ec96d777ff..4e7d2ad8ab 100644
--- a/test/src/xdisp-tests.el
+++ b/test/src/xdisp-tests.el
@@ -75,31 +75,28 @@ xdisp-tests--minibuffer-scroll
(ert-deftest xdisp-tests--window-text-pixel-size () ;; bug#45748
(with-temp-buffer
(insert "xxx")
- (let* ((window
- (display-buffer (current-buffer) '(display-buffer-in-child-frame . nil)))
- (char-width (frame-char-width))
- (size (window-text-pixel-size nil t t)))
- (delete-frame (window-frame window))
- (should (equal (/ (car size) char-width) 3)))))
+ (switch-to-buffer (current-buffer))
+ (let* ((char-width (frame-char-width))
+ (size (window-text-pixel-size nil t t))
+ (width-in-chars (/ (car size) char-width)))
+ (should (equal width-in-chars 3)))))
(ert-deftest xdisp-tests--window-text-pixel-size-leading-space () ;; bug#45748
(with-temp-buffer
(insert " xx")
- (let* ((window
- (display-buffer (current-buffer) '(display-buffer-in-child-frame . nil)))
- (char-width (frame-char-width))
- (size (window-text-pixel-size nil t t)))
- (delete-frame (window-frame window))
- (should (equal (/ (car size) char-width) 3)))))
+ (switch-to-buffer (current-buffer))
+ (let* ((char-width (frame-char-width))
+ (size (window-text-pixel-size nil t t))
+ (width-in-chars (/ (car size) char-width)))
+ (should (equal width-in-chars 3)))))
(ert-deftest xdisp-tests--window-text-pixel-size-trailing-space () ;; bug#45748
(with-temp-buffer
(insert "xx ")
- (let* ((window
- (display-buffer (current-buffer) '(display-buffer-in-child-frame . nil)))
- (char-width (frame-char-width))
- (size (window-text-pixel-size nil t t)))
- (delete-frame (window-frame window))
- (should (equal (/ (car size) char-width) 3)))))
+ (switch-to-buffer (current-buffer))
+ (let* ((char-width (frame-char-width))
+ (size (window-text-pixel-size nil t t))
+ (width-in-chars (/ (car size) char-width)))
+ (should (equal width-in-chars 3)))))
;;; xdisp-tests.el ends here
--
2.28.0
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45748
; Package
emacs
.
(Sat, 16 Jan 2021 18:34:02 GMT)
Full text and
rfc822 format available.
Message #101 received at 45748 <at> debbugs.gnu.org (full text, mbox):
> From: Aaron Jensen <aaronjensen <at> gmail.com>
> Cc: eliz <at> gnu.org,
> contovob <at> tcd.ie,
> Aaron Jensen <aaronjensen <at> gmail.com>
> Date: Sat, 16 Jan 2021 12:28:46 -0600
>
> (xdisp-tests--window-text-pixel-size)
> (xdisp-tests--window-text-pixel-size-leading-space)
> (xdisp-tests--window-text-pixel-size-trailing-space): Fix tests
Thanks, please install this.
Reply sent
to
Eli Zaretskii <eliz <at> gnu.org>
:
You have taken responsibility.
(Mon, 18 Jan 2021 17:05:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Aaron Jensen <aaronjensen <at> gmail.com>
:
bug acknowledged by developer.
(Mon, 18 Jan 2021 17:05:02 GMT)
Full text and
rfc822 format available.
Message #106 received at 45748-done <at> debbugs.gnu.org (full text, mbox):
> From: Aaron Jensen <aaronjensen <at> gmail.com>
> Date: Sat, 16 Jan 2021 12:28:46 -0600
> Cc: contovob <at> tcd.ie, eliz <at> gnu.org, Aaron Jensen <aaronjensen <at> gmail.com>
>
> (xdisp-tests--window-text-pixel-size)
> (xdisp-tests--window-text-pixel-size-leading-space)
> (xdisp-tests--window-text-pixel-size-trailing-space): Fix tests
Thanks, installed, and closing the bug.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Tue, 16 Feb 2021 12:24:07 GMT)
Full text and
rfc822 format available.
This bug report was last modified 3 years and 70 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.