* Unable to set 'display text property, but can set other props
@ 2020-09-11 17:35 Göktuğ Kayaalp
2020-09-11 18:34 ` Eli Zaretskii
0 siblings, 1 reply; 3+ messages in thread
From: Göktuğ Kayaalp @ 2020-09-11 17:35 UTC (permalink / raw)
To: Help Gnu Emacs mailing list
Please observe the snippet at the end of the message.
What I’m trying to do is to expand one space character enough to align
the text following the character on the same line to the right edge of
the window.
Problem is, while I can set properties like 'help-echo on the region, I
can’t set 'display. I’ve tried variations of the below with `(space
. (:width ...)) too.
Maths is probably somewhat off, but the actual problem is that I can’t
set any 'display props, e.g. ‘STRING’ too.
I’ve tried just using things akin to
(put-text-property 67 68 'display '(space-width 10))
using M-:.
Why is this happening? Am I doing something very obviously wrong? Or
is it something else?
(defun ---getposnxy (point)
(posn-x-y
(posn-at-point
point
(get-buffer-window (current-buffer)))))
(with-current-buffer "Todo.org"
(save-excursion
(goto-char (point-min))
(org-next-visible-heading 1)
(goto-char (line-beginning-position))
(let* ((case-fold-search nil)
(elem-at-point (org-element-at-point))
(headline (progn (unless (eq 'headline (car elem-at-point))
(error "Element at point is not a headline"))
(cadr elem-at-point)))
(headline-end-position
(search-forward (plist-get headline :raw-value)
(line-end-position)))
(point-at-tags-beginning
(search-forward ":" (line-end-position))))
(put-text-property
headline-end-position (1+ headline-end-position)
'display
`(space-wdith
,(/
(- (window-pixel-width)
;; width of tags:
(- (car (---getposnxy (1+ headline-end-position)))
(car (---getposnxy (line-end-position)))))
(frame-char-width)))
(current-buffer))
headline-end-position)))
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Unable to set 'display text property, but can set other props
2020-09-11 17:35 Unable to set 'display text property, but can set other props Göktuğ Kayaalp
@ 2020-09-11 18:34 ` Eli Zaretskii
2020-09-11 21:01 ` Göktuğ Kayaalp
0 siblings, 1 reply; 3+ messages in thread
From: Eli Zaretskii @ 2020-09-11 18:34 UTC (permalink / raw)
To: help-gnu-emacs
> From: Göktuğ Kayaalp <self@gkayaalp.com>
> Date: Fri, 11 Sep 2020 20:35:40 +0300
>
> What I’m trying to do is to expand one space character enough to align
> the text following the character on the same line to the right edge of
> the window.
>
> Problem is, while I can set properties like 'help-echo on the region, I
> can’t set 'display. I’ve tried variations of the below with `(space
> . (:width ...)) too.
>
> Maths is probably somewhat off, but the actual problem is that I can’t
> set any 'display props, e.g. ‘STRING’ too.
>
> I’ve tried just using things akin to
>
> (put-text-property 67 68 'display '(space-width 10))
>
> using M-:.
>
> Why is this happening? Am I doing something very obviously wrong? Or
> is it something else?
The character at buffer position where you put this property must be a
SPC character.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Unable to set 'display text property, but can set other props
2020-09-11 18:34 ` Eli Zaretskii
@ 2020-09-11 21:01 ` Göktuğ Kayaalp
0 siblings, 0 replies; 3+ messages in thread
From: Göktuğ Kayaalp @ 2020-09-11 21:01 UTC (permalink / raw)
To: help-gnu-emacs
On 2020-09-11 21:34 +03, Eli Zaretskii <eliz@gnu.org> wrote:
> The character at buffer position where you put this property must be a
> SPC character.
And indeed that’s what it is:
position: 67 of 4457 (1%), column: 41
character: SPC (displayed as SPC) (codepoint 32, #o40, #x20)
charset: ascii (ASCII (ISO646 IRV))
code point in charset: 0x20
Just tried with ‘emacs -q’ and it does work there. But I can’t get it
to work with my config, so I must have broken something.
--
İ. Göktuğ Kayaalp / @cadadr / <https://www.gkayaalp.com/>
pgp: 024C 30DD 597D 142B 49AC 40EB 465C D949 B101 2427
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-09-11 21:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-11 17:35 Unable to set 'display text property, but can set other props Göktuğ Kayaalp
2020-09-11 18:34 ` Eli Zaretskii
2020-09-11 21:01 ` Göktuğ Kayaalp
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).