all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Redisplaying text in both display margins?
@ 2021-01-19  9:27 pwr--- via Users list for the GNU Emacs text editor
  2021-01-19 15:16 ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: pwr--- via Users list for the GNU Emacs text editor @ 2021-01-19  9:27 UTC (permalink / raw)
  To: help-gnu-emacs

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.



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-02-01 16:10 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-19  9:27 Redisplaying text in both display margins? pwr--- via Users list for the GNU Emacs text editor
2021-01-19 15:16 ` Eli Zaretskii
2021-01-25  8:28   ` pwr--- via Users list for the GNU Emacs text editor
2021-01-27 15:59     ` Eli Zaretskii
2021-01-27 18:02       ` Alan Third
2021-02-01  7:04         ` pwr--- via Users list for the GNU Emacs text editor
2021-02-01 15:02           ` Eli Zaretskii
2021-02-01 15:44             ` pwr--- via Users list for the GNU Emacs text editor
2021-02-01 16:10               ` moasenwood--- via Users list for the GNU Emacs text editor

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.