GNU bug report logs -
#20872
24.5; add-face-text-property doesn't work for :height
Previous Next
Reported by: Oleh Krehel <ohwoeowho <at> gmail.com>
Date: Mon, 22 Jun 2015 11:10:03 UTC
Severity: normal
Tags: notabug
Found in version 24.5
Done: Glenn Morris <rgm <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 20872 in the body.
You can then email your comments to 20872 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#20872
; Package
emacs
.
(Mon, 22 Jun 2015 11:10:04 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Oleh Krehel <ohwoeowho <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Mon, 22 Jun 2015 11:10:04 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Here's a code that works for setting a string foreground:
(defface test-face
'((t (:height 1.2 :foreground "green")))
"doc.")
(setq asdf (propertize "asdf" 'face 'test-face))
(add-face-text-property 0 (length asdf) '(:foreground "red") nil asdf)
`asdf' will still have the height 1.2 through `test-face' while gaining
a red foreground, instead of green.
But this doesn't work:
(add-face-text-property 0 (length asdf) '(:height 1.0) nil asdf)
While the text properties will change, when inserting `asdf' into a
`fundamental-mode' buffer, it will still have the height 1.2. How can I
set the height to 1.0, while preserving the face?
The actual use case is to offer propertized strings a choices in the
minibuffer. In that case, I want to keep all face properties, except the
height. Since extra height messes up the trimming of strings to
`window-width'.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#20872
; Package
emacs
.
(Mon, 22 Jun 2015 15:11:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 20872 <at> debbugs.gnu.org (full text, mbox):
> From: Oleh Krehel <ohwoeowho <at> gmail.com>
> Date: Mon, 22 Jun 2015 13:02:45 +0200
>
> (defface test-face
> '((t (:height 1.2 :foreground "green")))
> "doc.")
> (setq asdf (propertize "asdf" 'face 'test-face))
> (add-face-text-property 0 (length asdf) '(:foreground "red") nil asdf)
>
> `asdf' will still have the height 1.2 through `test-face' while gaining
> a red foreground, instead of green.
>
> But this doesn't work:
>
> (add-face-text-property 0 (length asdf) '(:height 1.0) nil asdf)
>
> While the text properties will change, when inserting `asdf' into a
> `fundamental-mode' buffer, it will still have the height 1.2. How can I
> set the height to 1.0, while preserving the face?
Untested: copy the face using copy-face, then change ':height'
attribute of the copied face using set-face-attribute, and finally
apply the modified face to the string.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#20872
; Package
emacs
.
(Mon, 22 Jun 2015 15:34:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 20872 <at> debbugs.gnu.org (full text, mbox):
On Mon, Jun 22 2015, Oleh Krehel wrote:
> But this doesn't work:
>
> (add-face-text-property 0 (length asdf) '(:height 1.0) nil asdf)
>
> While the text properties will change, when inserting `asdf' into a
> `fundamental-mode' buffer, it will still have the height 1.2. How can I
> set the height to 1.0, while preserving the face?
A float as value of the :height attribute works as a scaling factor, see
`set-face-attribute'. So, IIUC, the following would work
(add-face-text-property 0 (length asdf) `(:height ,(/ 1 1.2)) nil asdf)
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#20872
; Package
emacs
.
(Mon, 22 Jun 2015 15:37:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 20872 <at> debbugs.gnu.org (full text, mbox):
Wolfgang Jenkner <wjenkner <at> inode.at> writes:
> A float as value of the :height attribute works as a scaling factor, see
> `set-face-attribute'. So, IIUC, the following would work
>
> (add-face-text-property 0 (length asdf) `(:height ,(/ 1 1.2)) nil asdf)
Genius! This actually works. Thanks a lot.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#20872
; Package
emacs
.
(Mon, 22 Jun 2015 16:08:01 GMT)
Full text and
rfc822 format available.
Message #17 received at 20872 <at> debbugs.gnu.org (full text, mbox):
> (add-face-text-property 0 (length asdf) '(:height 1.0) nil asdf)
":height 1.0" means "multiply the height by 1", i.e. it's a no-op.
> minibuffer. In that case, I want to keep all face properties, except the
> height. Since extra height messes up the trimming of strings to
> `window-width'.
You can try to set :height to the *integer* pixel height of the
minibuffer lines.
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#20872
; Package
emacs
.
(Tue, 23 Jun 2015 09:28:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 20872 <at> debbugs.gnu.org (full text, mbox):
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
>> (add-face-text-property 0 (length asdf) '(:height 1.0) nil asdf)
>
> ":height 1.0" means "multiply the height by 1", i.e. it's a no-op.
>
>> minibuffer. In that case, I want to keep all face properties, except the
>> height. Since extra height messes up the trimming of strings to
>> `window-width'.
>
> You can try to set :height to the *integer* pixel height of the
> minibuffer lines.
Thanks, that's even better. Should I use this:
(add-face-text-property
0 (length asdf)
`(:height ,(face-attribute 'default :height)) nil asdf)
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#20872
; Package
emacs
.
(Tue, 23 Jun 2015 13:40:03 GMT)
Full text and
rfc822 format available.
Message #23 received at 20872 <at> debbugs.gnu.org (full text, mbox):
> Thanks, that's even better. Should I use this:
> (add-face-text-property
> 0 (length asdf)
> `(:height ,(face-attribute 'default :height)) nil asdf)
Looks OK,
Stefan
Added tag(s) notabug.
Request was from
Glenn Morris <rgm <at> gnu.org>
to
control <at> debbugs.gnu.org
.
(Tue, 23 Jun 2015 15:36:02 GMT)
Full text and
rfc822 format available.
bug closed, send any further explanations to
20872 <at> debbugs.gnu.org and Oleh Krehel <ohwoeowho <at> gmail.com>
Request was from
Glenn Morris <rgm <at> gnu.org>
to
control <at> debbugs.gnu.org
.
(Tue, 23 Jun 2015 15:36: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
.
(Wed, 22 Jul 2015 11:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 9 years and 337 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.