* Why is `(1 . width)` zero?
@ 2021-01-18 8:51 Jörg Sommer
2021-01-18 15:06 ` Robert Pluim
2021-01-19 6:53 ` Robert Thorpe
0 siblings, 2 replies; 11+ messages in thread
From: Jörg Sommer @ 2021-01-18 8:51 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 1513 bytes --]
Hi,
I'm using GNU Emacs 27.1¹ with X and the font DejaVu Sans Mono. I would like
to align a text on the right side and thought I can use this:
```lisp
(let* ((text " abcd")
(len (length text))
)
(add-text-properties 0 1 `(display (space :align-to (- text (,len . width)))) text)
(insert "\n" (format "%S" text) "\n" text "\n"))
```
but it doesn't work. The text is outside the visible space. Similar with a
text that should be indented:
```lisp
(let ((text " abcd"))
(add-text-properties 0 1 `(display (space :width (10 . width))) text)
(insert "\n" (format "%S" text) "\n" text "\n"))
```
It shows up in the first column. But in the TUI it works. So, what's wrong
with `width` in GUI?
My main goal is to place a text on the right side that the user might scale
down with face attributes:
```lisp
(set-face-attribute 'lsp-ui-sideline-global nil :height 0.5)
(let* ((text " abcd")
(len (length text))
)
(add-text-properties 0 len '(font-lock-face (error lsp-ui-sideline-global)) text)
(add-text-properties 0 1 `(display (space :align-to (- text (,len . width)))) text)
(insert "\n" (format "%S" text) "\n" text "\n"))
```
Are there any other ways to get this?
Kind regards
Jörg
¹ build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.23, cairo version 1.16.0
of 2020-11-08, modified by Debian
--
> Definiere ‚Demokratie‘ …
… eine Mehrheit beweist einer Minderheit, dass Widerstand zwecklos ist.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 269 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Why is `(1 . width)` zero?
2021-01-18 8:51 Why is `(1 . width)` zero? Jörg Sommer
@ 2021-01-18 15:06 ` Robert Pluim
2021-01-18 20:49 ` Michael Heerdegen
2021-01-18 22:23 ` Jörg Sommer
2021-01-19 6:53 ` Robert Thorpe
1 sibling, 2 replies; 11+ messages in thread
From: Robert Pluim @ 2021-01-18 15:06 UTC (permalink / raw)
To: help-gnu-emacs
>>>>> On Mon, 18 Jan 2021 09:51:13 +0100, Jörg Sommer <joerg@jo-so.de> said:
Jörg> Hi,
Jörg> I'm using GNU Emacs 27.1¹ with X and the font DejaVu Sans Mono. I would like
Jörg> to align a text on the right side and thought I can use this:
Jörg> ```lisp
Jörg> (let* ((text " abcd")
Jörg> (len (length text))
Jörg> )
Jörg> (add-text-properties 0 1 `(display (space :align-to (- text (,len . width)))) text)
Jörg> (insert "\n" (format "%S" text) "\n" text "\n"))
Jörg> ```
Jörg> but it doesn't work. The text is outside the visible space. Similar with a
Jörg> text that should be indented:
Jörg> ```lisp
Jörg> (let ((text " abcd"))
Jörg> (add-text-properties 0 1 `(display (space :width (10 . width))) text)
Jörg> (insert "\n" (format "%S" text) "\n" text "\n"))
Jörg> ```
Jörg> It shows up in the first column. But in the TUI it works. So, what's wrong
Jörg> with `width` in GUI?
Both of those work fine for me in emacs-27 under X (using DejaVu Sans
Mono Book). Does it do the same in 'emacs -Q' and in emacs compiled
from the latest emacs-27 sources?
Jörg> Are there any other ways to get this?
:align-to is the way to do it.
Robert
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Why is `(1 . width)` zero?
2021-01-18 15:06 ` Robert Pluim
@ 2021-01-18 20:49 ` Michael Heerdegen
2021-01-18 22:23 ` Jörg Sommer
1 sibling, 0 replies; 11+ messages in thread
From: Michael Heerdegen @ 2021-01-18 20:49 UTC (permalink / raw)
To: help-gnu-emacs
Robert Pluim <rpluim@gmail.com> writes:
> Both of those work fine for me in emacs-27 under X (using DejaVu Sans
> Mono Book). Does it do the same in 'emacs -Q' and in emacs compiled
> from the latest emacs-27 sources?
Works for me as well (master built). But I also have the Debian version
installed, the same as Jörg's, and there it doesn't work indeed, I see
the same as Jörg there.
Michael.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Why is `(1 . width)` zero?
2021-01-18 15:06 ` Robert Pluim
2021-01-18 20:49 ` Michael Heerdegen
@ 2021-01-18 22:23 ` Jörg Sommer
2021-01-19 9:37 ` Jörg Sommer
1 sibling, 1 reply; 11+ messages in thread
From: Jörg Sommer @ 2021-01-18 22:23 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 2380 bytes --]
Robert Pluim schrieb am Mo 18. Jan, 16:06 (+0100):
> >>>>> On Mon, 18 Jan 2021 09:51:13 +0100, Jörg Sommer <joerg@jo-so.de> said:
>
> Jörg> Hi,
> Jörg> I'm using GNU Emacs 27.1¹ with X and the font DejaVu Sans Mono. I would like
> Jörg> to align a text on the right side and thought I can use this:
>
> Jörg> ```lisp
> Jörg> (let* ((text " abcd")
> Jörg> (len (length text))
> Jörg> )
> Jörg> (add-text-properties 0 1 `(display (space :align-to (- text (,len . width)))) text)
> Jörg> (insert "\n" (format "%S" text) "\n" text "\n"))
> Jörg> ```
>
> Jörg> but it doesn't work. The text is outside the visible space. Similar with a
> Jörg> text that should be indented:
>
> Jörg> ```lisp
> Jörg> (let ((text " abcd"))
> Jörg> (add-text-properties 0 1 `(display (space :width (10 . width))) text)
> Jörg> (insert "\n" (format "%S" text) "\n" text "\n"))
> Jörg> ```
>
> Jörg> It shows up in the first column. But in the TUI it works. So, what's wrong
> Jörg> with `width` in GUI?
>
> Both of those work fine for me in emacs-27 under X (using DejaVu Sans
> Mono Book). Does it do the same in 'emacs -Q' and in emacs compiled
> from the latest emacs-27 sources?
Thank you Robert for your feedback. I've tried the latest master and it
works fine. Hence, there was something between 27.1 and 8f4b3b812aa. I've
bisect this range and found this commit:
commit d340a979dbbd6150a3af4783cf8b3b65368bbdad (HEAD)
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Date: Wed Oct 7 10:51:35 2020 -0400
* lisp/doc-view.el: Fix "can't resize root window" error
(doc-view-fit-window-to-page): Change approach to detect when the
frame needs to be resized.
I don't see why, but it fixes the problem of width being zero when Emacs is
built with `--with-cairo`. Hence, an update of the Debian package should
bring a working version.
Kind regards Jörg
PS: Please Cc me. I'm not subscribed to the list.
--
„Es wurden und werden zu viele sprachlose Bücher gedruckt, nach deren
schon flüchtiger Lektüre man all die Bäume um Vergebung bitten möchte,
die für den Schund ihr Leben lassen mussten.“ (Michael Jürgs,
Seichtgebiete – Warum wir hemmungslos verblöden)
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 269 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Why is `(1 . width)` zero?
2021-01-18 8:51 Why is `(1 . width)` zero? Jörg Sommer
2021-01-18 15:06 ` Robert Pluim
@ 2021-01-19 6:53 ` Robert Thorpe
2021-01-19 7:59 ` tomas
1 sibling, 1 reply; 11+ messages in thread
From: Robert Thorpe @ 2021-01-19 6:53 UTC (permalink / raw)
To: Jörg Sommer; +Cc: help-gnu-emacs
Jörg Sommer <joerg@jo-so.de> writes:
> [1:text/plain Hide]
>
> Hi,
>
> I'm using GNU Emacs 27.1¹ with X and the font DejaVu Sans Mono. I would like
> to align a text on the right side and thought I can use this:
>
> ```lisp
> (let* ((text " abcd")
> (len (length text))
> )
> (add-text-properties 0 1 `(display (space :align-to (- text (,len . width)))) text)
> (insert "\n" (format "%S" text) "\n" text "\n"))
> ```
I don't understand your problem. But I this snippet looks wrong:
> (- text (,len . width))
You can't do arithmetic on a pair.
BR,
Robert Thorpe
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Why is `(1 . width)` zero?
2021-01-19 6:53 ` Robert Thorpe
@ 2021-01-19 7:59 ` tomas
2021-01-19 9:37 ` Robert Thorpe
0 siblings, 1 reply; 11+ messages in thread
From: tomas @ 2021-01-19 7:59 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 1126 bytes --]
On Tue, Jan 19, 2021 at 06:53:57AM +0000, Robert Thorpe wrote:
> Jörg Sommer <joerg@jo-so.de> writes:
>
> > [1:text/plain Hide]
> >
> > Hi,
> >
> > I'm using GNU Emacs 27.1¹ with X and the font DejaVu Sans Mono. I would like
> > to align a text on the right side and thought I can use this:
> >
> > ```lisp
> > (let* ((text " abcd")
> > (len (length text))
> > )
> > (add-text-properties 0 1 `(display (space :align-to (- text (,len . width)))) text)
> > (insert "\n" (format "%S" text) "\n" text "\n"))
> > ```
>
> I don't understand your problem. But I this snippet looks wrong:
>
> > (- text (,len . width))
>
> You can't do arithmetic on a pair.
I think this is misleading. The :align-to takes its own mini-language [1],
where this (num . unit) has its own meaning (behind the scenes, unit is
just "how many pixels per unit, in good old TeX tradition, as far as my
yet-coffeine-depleted status allows me to see).
Cheers
[1] 39.16.3 Pixel Specification for Spaces
https://www.gnu.org/software/emacs/manual/html_node/elisp/Pixel-Specification.html
- t
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Why is `(1 . width)` zero?
2021-01-18 22:23 ` Jörg Sommer
@ 2021-01-19 9:37 ` Jörg Sommer
2021-01-19 10:32 ` Robert Pluim
2021-01-24 10:45 ` Robert Pluim
0 siblings, 2 replies; 11+ messages in thread
From: Jörg Sommer @ 2021-01-19 9:37 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 2380 bytes --]
Jörg Sommer schrieb am Mo 18. Jan, 23:23 (+0100):
> Robert Pluim schrieb am Mo 18. Jan, 16:06 (+0100):
> > >>>>> On Mon, 18 Jan 2021 09:51:13 +0100, Jörg Sommer <joerg@jo-so.de> said:
> >
> > Jörg> Hi,
> > Jörg> I'm using GNU Emacs 27.1¹ with X and the font DejaVu Sans Mono. I would like
> > Jörg> to align a text on the right side and thought I can use this:
> >
> > Jörg> ```lisp
> > Jörg> (let* ((text " abcd")
> > Jörg> (len (length text))
> > Jörg> )
> > Jörg> (add-text-properties 0 1 `(display (space :align-to (- text (,len . width)))) text)
> > Jörg> (insert "\n" (format "%S" text) "\n" text "\n"))
> > Jörg> ```
> >
> > Jörg> but it doesn't work. The text is outside the visible space. Similar with a
> > Jörg> text that should be indented:
> >
> > Jörg> ```lisp
> > Jörg> (let ((text " abcd"))
> > Jörg> (add-text-properties 0 1 `(display (space :width (10 . width))) text)
> > Jörg> (insert "\n" (format "%S" text) "\n" text "\n"))
> > Jörg> ```
> >
> > Jörg> It shows up in the first column. But in the TUI it works. So, what's wrong
> > Jörg> with `width` in GUI?
> >
> > Both of those work fine for me in emacs-27 under X (using DejaVu Sans
> > Mono Book). Does it do the same in 'emacs -Q' and in emacs compiled
> > from the latest emacs-27 sources?
>
> Thank you Robert for your feedback. I've tried the latest master and it
> works fine. Hence, there was something between 27.1 and 8f4b3b812aa. I've
> bisect this range and found this commit:
>
Sorry, I've picked the wrong commit. This one fixes the problem and a
backport to 27.1 fixes it there, too.
commit c7804ac4018fb03787f291d7ef1739b34914d930 (HEAD, refs/bisect/with-space)
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Date: Thu Oct 8 09:49:20 2020 -0400
* src/ftcrfont.c (ftcrfont_open): Initialize the `max_width` field
On a 32bit build, Emacs can otherwise crash with a !FIXNUM_OVERFLOW_P
assertion in `Ffont_info` by simply doing `emacs -Q` and then `C-s`.
* src/font.c: Try and detect uninitialized `max_width` fields.
(font_make_object): Set max_width to a silly value.
(Ffont_info): Check the value is not silly any more.
--
$ cat /dev/random
#!/usr/bin/perl -WT
print "hello world\n";
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 269 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Why is `(1 . width)` zero?
2021-01-19 7:59 ` tomas
@ 2021-01-19 9:37 ` Robert Thorpe
0 siblings, 0 replies; 11+ messages in thread
From: Robert Thorpe @ 2021-01-19 9:37 UTC (permalink / raw)
To: tomas, Jörg Sommer; +Cc: help-gnu-emacs
<tomas@tuxteam.de> writes:
>> You can't do arithmetic on a pair.
>
> I think this is misleading. The :align-to takes its own mini-language [1],
> where this (num . unit) has its own meaning (behind the scenes, unit is
> just "how many pixels per unit, in good old TeX tradition, as far as my
> yet-coffeine-depleted status allows me to see).
>
> Cheers
>
> [1] 39.16.3 Pixel Specification for Spaces
> https://www.gnu.org/software/emacs/manual/html_node/elisp/Pixel-Specification.html
I see, that's clever. Jorg, ignore my previous mail.
BR,
Robert Thorpe
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Why is `(1 . width)` zero?
2021-01-19 9:37 ` Jörg Sommer
@ 2021-01-19 10:32 ` Robert Pluim
2021-01-24 10:45 ` Robert Pluim
1 sibling, 0 replies; 11+ messages in thread
From: Robert Pluim @ 2021-01-19 10:32 UTC (permalink / raw)
To: Jörg Sommer; +Cc: help-gnu-emacs
>>>>> On Tue, 19 Jan 2021 10:37:24 +0100, Jörg Sommer <joerg@jo-so.de> said:
Jörg> Jörg Sommer schrieb am Mo 18. Jan, 23:23 (+0100):
>> Robert Pluim schrieb am Mo 18. Jan, 16:06 (+0100):
>> > Both of those work fine for me in emacs-27 under X (using DejaVu Sans
>> > Mono Book). Does it do the same in 'emacs -Q' and in emacs compiled
>> > from the latest emacs-27 sources?
>>
>> Thank you Robert for your feedback. I've tried the latest master and it
>> works fine. Hence, there was something between 27.1 and 8f4b3b812aa. I've
>> bisect this range and found this commit:
>>
Ah, my emacs-27 build wasn't using Cairo, which is why I thought it
worked there.
Jörg> Sorry, I've picked the wrong commit. This one fixes the problem and a
Jörg> backport to 27.1 fixes it there, too.
Yes, the other one looked somewhat unlikely. This one fixes things for
me as well on emacs-27 with Cairo.
Robert
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Why is `(1 . width)` zero?
2021-01-19 9:37 ` Jörg Sommer
2021-01-19 10:32 ` Robert Pluim
@ 2021-01-24 10:45 ` Robert Pluim
2021-01-24 14:54 ` Eli Zaretskii
1 sibling, 1 reply; 11+ messages in thread
From: Robert Pluim @ 2021-01-24 10:45 UTC (permalink / raw)
To: Jörg Sommer; +Cc: help-gnu-emacs
>>>>> On Tue, 19 Jan 2021 10:37:24 +0100, Jörg Sommer <joerg@jo-so.de> said:
Jörg> Sorry, I've picked the wrong commit. This one fixes the problem and a
Jörg> backport to 27.1 fixes it there, too.
Jörg> commit c7804ac4018fb03787f291d7ef1739b34914d930 (HEAD, refs/bisect/with-space)
Jörg> Author: Stefan Monnier <monnier@iro.umontreal.ca>
Jörg> Date: Thu Oct 8 09:49:20 2020 -0400
Jörg> * src/ftcrfont.c (ftcrfont_open): Initialize the `max_width` field
Jörg> On a 32bit build, Emacs can otherwise crash with a !FIXNUM_OVERFLOW_P
Jörg> assertion in `Ffont_info` by simply doing `emacs -Q` and then `C-s`.
Jörg> * src/font.c: Try and detect uninitialized `max_width` fields.
Jörg> (font_make_object): Set max_width to a silly value.
Jörg> (Ffont_info): Check the value is not silly any more.
Eli, is this ok to backport to emacs-27?
Thanks
Robert
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Why is `(1 . width)` zero?
2021-01-24 10:45 ` Robert Pluim
@ 2021-01-24 14:54 ` Eli Zaretskii
0 siblings, 0 replies; 11+ messages in thread
From: Eli Zaretskii @ 2021-01-24 14:54 UTC (permalink / raw)
To: help-gnu-emacs
> From: Robert Pluim <rpluim@gmail.com>
> Cc: help-gnu-emacs@gnu.org, eliz@gnu.org
> Date: Sun, 24 Jan 2021 11:45:15 +0100
>
> Jörg> Author: Stefan Monnier <monnier@iro.umontreal.ca>
> Jörg> Date: Thu Oct 8 09:49:20 2020 -0400
>
> Jörg> * src/ftcrfont.c (ftcrfont_open): Initialize the `max_width` field
>
> Jörg> On a 32bit build, Emacs can otherwise crash with a !FIXNUM_OVERFLOW_P
> Jörg> assertion in `Ffont_info` by simply doing `emacs -Q` and then `C-s`.
>
> Jörg> * src/font.c: Try and detect uninitialized `max_width` fields.
> Jörg> (font_make_object): Set max_width to a silly value.
> Jörg> (Ffont_info): Check the value is not silly any more.
>
> Eli, is this ok to backport to emacs-27?
Hmm... I'm not sure I understand how this solves the issue.
Everything that's in eassert will compile to nothing in a production
build, and the rest doesn't really ensure max_width is initialized to
a reasonable value (zero is as unreasonable as a large value)?
Isn't there a better fix for this?
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2021-01-24 14:54 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-18 8:51 Why is `(1 . width)` zero? Jörg Sommer
2021-01-18 15:06 ` Robert Pluim
2021-01-18 20:49 ` Michael Heerdegen
2021-01-18 22:23 ` Jörg Sommer
2021-01-19 9:37 ` Jörg Sommer
2021-01-19 10:32 ` Robert Pluim
2021-01-24 10:45 ` Robert Pluim
2021-01-24 14:54 ` Eli Zaretskii
2021-01-19 6:53 ` Robert Thorpe
2021-01-19 7:59 ` tomas
2021-01-19 9:37 ` Robert Thorpe
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).