[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[O] SOLUTION - Re: How to colorize text in square brackets?
From: |
Sharon Kimble |
Subject: |
[O] SOLUTION - Re: How to colorize text in square brackets? |
Date: |
Thu, 14 Feb 2019 09:05:30 +0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.1.91 (gnu/linux) |
Sharon Kimble <address@hidden> writes:
> How can I colorize text within square brackets please, like [fu] ?
>
> I need them colorized as they will hold reminders for myself at that position
> whilst I'm writing.
>
When I posted this question I knew that the answer would probably lie somewhere
within font-lock-add-keywords, but I was unable to find it until I started
googling for 'font-lock-keyword-face' which I was already using. This search
then lead me to these two pages [1] and [2].
And that lead to this code which achieves what I was trying to accomplish, the
text within the square boxes to be coloured totally different from its
surrounding text, meaning that now I can write my book and leave myself
reminders of various questions, which when I've found the answers can then be
deleted.
--8<---------------cut here---------------start------------->8---
#+BEGIN_SRC emacs-lisp
(font-lock-add-keywords 'org-mode
'(("\\[\\(.*\\)\\]"
1 font-lock-type-face prepend)))
#+END_SRC
--8<---------------cut here---------------end--------------->8---
Thanks
Sharon.
[1] -
https://stackoverflow.com/questions/7401787/emacs-mode-how-to-specify-that-thing-in-square-brackets-should-be-colored
[2] -
https://www.gnu.org/software/emacs/manual/html_node/elisp/Faces-for-Font-Lock.html
--
A taste of linux = http://www.sharons.org.uk
TGmeds = http://www.tgmeds.org.uk
DrugFacts = https://www.drugfacts.org.uk
Debian 9.5, fluxbox 1.3.7, emacs 26.1.91, org 9.2.1
signature.asc
Description: PGP signature