help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Redisplaying text in both display margins?


From: Paul W. Rankin
Subject: Redisplaying text in both display margins?
Date: Tue, 19 Jan 2021 19:27:34 +1000
User-agent: mu4e 1.4.14; emacs 27.1

Hello,

I would like to use font-lock and display text properties to redisplay a regular expression group for a heading number in both display margins. n.b. "Margins" here may be ambiguous; I refer to the display margins (info "(elisp) Display Margins") and not the text margins (info "(elisp) Margins").

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.

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.

Any help would be much appreciated. Thank you in advance,

--
Paul W. Rankin
https://bydasein.com

The single best thing you can do for the world is to delete your social media accounts.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]