[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Redisplaying text in both display margins?
From: |
Eli Zaretskii |
Subject: |
Re: Redisplaying text in both display margins? |
Date: |
Tue, 19 Jan 2021 17:16:51 +0200 |
> Feedback-ID: 791:353:null:purelymail
> Date: Tue, 19 Jan 2021 19:27:34 +1000
> From: pwr--- via Users list for the GNU Emacs text editor
> <help-gnu-emacs@gnu.org>
>
> My intent is to redisplay the string marked here:
>
> HEADING. FOOBAR #5-A#
> ^^^^^^^^
> as:
>
> 5-A HEADING. FOOBAR 5-A
>
> So far clarity, in this particular major mode, a heading may end with an
> arbitrary string between two '#' characters (e.g. "5-A"). This string
> should be redisplayed in the display margins (without the '#'
> characters).
>
> At the moment I'm happily redisplaying the heading number in the right
> margin with the following code (where group 7 is the preceding space,
> group 8 is the first '#', group 9 is the string to redisplay, and gropu
> 10 is the second '#'):
>
> (put-text-property (match-beginning 7) (match-end 10)
> 'display (list '(margin right-margin)
> (match-string-no-properties 9)))
>
> There are a couple of things I can't figure out:
>
> 1. How to put multiple display text properties on the same text, so that
> it may redisplay group 9 in both margins.
You can't, not directly: each text property of a given character can
have only one value in Emacs. But perhaps you could do that with 2
overlay strings, if you put the overlays on the same text?
> 2. When redisplaying a string in the left margin, how to right-align it,
> ideally padded with a couple of spaces away from the body text.
>
> I have read over (info "(elisp) Display Property") a few times, but
> haven't been able to quite grok it for this specific problem.
I think the node "Pixel Specification" there should tell you how to
accomplish that, but if you already read that, please ask more
specific questions, and/or show the code you tried that didn't work.