From: pjb@informatimago.com (Pascal J. Bourguignon)
To: help-gnu-emacs@gnu.org
Subject: Re: changing visuals of code in emacs
Date: Sun, 12 Oct 2008 22:48:44 +0200 [thread overview]
Message-ID: <878wst1qvn.fsf@hubble.informatimago.com> (raw)
In-Reply-To: K8n6rF.ryC@beaver.cs.washington.edu
Andrei Alexandrescu <SeeWebsiteForEmail@erdani.org> writes:
> Hello,
>
>
> I'd like to change code visuals for the D programming language as
> follows. I'd like the construct:
>
> Symbol!(balanced_parens)
>
> to be visualized as:
>
> Symbol«balanced_parens»
>
> The chevrons should appear electrically when I type the closing
> ")". Note that balanced_parens could in turn nested use of "!()", as
> in A!(B!(C)), and they should all be paired using chevrons. The
> underlying file should not contain the chevrons, just the ASCII
> representation using "!(" and ")".
>
> I haven't done much elisp programming beyond the common .emacs
> configuration tricks, so I don't know where to start. A few searches
> suggested that overlays may be what I'm looking for... any ideas and
> pointers? Thank you.
If you didn't ask for recursion, this could have be done with
font-locking.
(font-lock-add-keywords nil
'(("\\(!(\\)[^()]*\\()\\)"
0 (progn
(compose-region (match-beginning 1) (match-end 1) ?« 'decompose-region)
(compose-region (match-beginning 2) (match-end 2) ?» 'decompose-region)
nil))))
But since this uses regular expressions, it won't work for recursive
!(...).
You can still use compose-region, but you'll have to implement the
parsing yourself. Perhaps this could be hooked on the code doing the
parenthesis balancing?
--
__Pascal Bourguignon__ http://www.informatimago.com/
You never feed me.
Perhaps I'll sleep on your face.
That will sure show you.
next prev parent reply other threads:[~2008-10-12 20:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-12 20:11 changing visuals of code in emacs Andrei Alexandrescu
2008-10-12 20:48 ` Pascal J. Bourguignon [this message]
2008-10-12 21:06 ` Andrei Alexandrescu
2008-10-12 21:44 ` Pascal J. Bourguignon
2008-10-12 22:18 ` Andrei Alexandrescu
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=878wst1qvn.fsf@hubble.informatimago.com \
--to=pjb@informatimago.com \
--cc=help-gnu-emacs@gnu.org \
/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.