From: pwr--- via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org>
To: help-gnu-emacs@gnu.org
Subject: Redisplaying text in both display margins?
Date: Tue, 19 Jan 2021 19:27:34 +1000 [thread overview]
Message-ID: <87a6t546pl.fsf@bydasein.com> (raw)
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.
next reply other threads:[~2021-01-19 9:27 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-19 9:27 pwr--- via Users list for the GNU Emacs text editor [this message]
2021-01-19 15:16 ` Redisplaying text in both display margins? 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87a6t546pl.fsf@bydasein.com \
--to=help-gnu-emacs@gnu.org \
--cc=pwr@bydasein.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.