From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: SOLUTION - Re: How to colorize text in square brackets? Date: Thu, 14 Feb 2019 08:30:01 -0500 Message-ID: References: <87zhr2idiw.fsf@skimble.plus.com> <87mumyagf9.fsf@skimble.plus.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([209.51.188.92]:57045) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1guH5i-00049P-FH for emacs-orgmode@gnu.org; Thu, 14 Feb 2019 08:30:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1guH5b-0001lQ-HA for emacs-orgmode@gnu.org; Thu, 14 Feb 2019 08:30:14 -0500 Received: from mail-qt1-x82e.google.com ([2607:f8b0:4864:20::82e]:33957) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1guH5b-0001jJ-B0 for emacs-orgmode@gnu.org; Thu, 14 Feb 2019 08:30:07 -0500 Received: by mail-qt1-x82e.google.com with SMTP id w4so6834379qtc.1 for ; Thu, 14 Feb 2019 05:30:05 -0800 (PST) In-reply-to: <87mumyagf9.fsf@skimble.plus.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Sharon Kimble Cc: emacs-orgmode@gnu.org I have been using https://github.com/jkitchin/scimax/blob/master/scimax-editmarks.org for something like this. It allows me to put comments with a little markup that are colored as you describe. There is also support to show a listing of all those comments, so that you don't overlook them by accident. Of course, you can always use occur on the regexp you are fontifying to find those too. Sharon Kimble writes: > Sharon Kimble 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 -- Professor John Kitchin Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu