Re: How to set different string with different colors ?
- From: Michal Nazarewicz <mina86@xxxxxxx>
- Date: Mon, 28 Jan 2008 05:08:53 +0100
Jebel <Jebel.Star@xxxxxxxxx> writes:
Hi.
I usually need to find some special strings in a long text. And I
want to find a way to mark the strings that I 'm finding. Such as set
"FUNC_A" to blue, set "FUNC_B" to green, set "FUNC_C" to red and so
on.
I'm a beginner of emacs and know little of lisp. How can I do this?
You got your answer already but here's another one: I use the following
code in my .emacs file to highlight "FIXME", "TODO" and sort alike; it
also displays tabs with dark background and red if there are more then 3
tabs:
#v+
;; Show blanks and FIXME
;; http://www.emacswiki.org/cgi-bin/wiki/EightyColumnRule
(defface my-tab-face
'((((type graphical) (class color) (min-colors 216)) (:underline "#666"))
(((class color) (min-colors 216)) (:background "#666"))
(((class color) (min-colors 16)) (:background "yellow")))
"Face for showing TABs."
:group 'basic-faces)
(defface my-big-indent-face
'((((type graphical) (class color) (min-colors 216)) (:underline "#966"))
(((class color) (min-colors 216)) (:background "#966"))
(((class color) (min-colors 16)) (:background "red"))
(t :inverse-video t))
"Face for showing sequence of four or five TAB characters in a row."
:group 'basic-faces)
(defface my-huge-indent-face
'((((type graphical) (class color) (min-colors 216)) (:underline "#F00"))
(((class color) (min-colors 216)) (:background "#C66"))
(((class color) (min-colors 16)) (:background "magenta"))
(t :inverse-video t))
"Face for showing sequence of at least six five TAB characters in a row."
:group 'basic-faces)
(defface my-fixme-face
'((t :background "red" :foreground "white" :weight bold))
"Font for showing FIXME and XXX words."
:group 'basic-faces)
(defface my-todo-face
'((t :foreground "red" :weight bold))
"Font for showing TODO words."
:group 'basic-faces)
(add-hook 'font-lock-mode-hook (function (lambda ()
(unless (or (eq 'diff-mode major-mode) (eq 'script-mode major-mode))
(font-lock-add-keywords nil
'(("\t+" 0 'my-tab-face t)
("^\t\\{4,5\\}" 0 'my-big-indent-face t)
("^\t\\{6,\\}" 0 'my-huge-indent-face t)
("\\<\\(TODO:?\\)\\>" 1 'my-todo-face t)
("\\<\\(FIXME:?\\|XXX\\)\\>" 1 'my-fixme-face t)))))))
#v-
--
Best regards, _ _
.o. | Liege of Serenly Enlightened Majesty of o' \,=./ `o
..o | Computer Science, Michal "mina86" Nazarewicz (o o)
ooo +--<mina86*tlen.pl>--<jid:mina86*jabber.org>--ooO--(_)--Ooo--
.
- References:
- Prev by Date: Re: Replacing characters not in default ascii character set
- Next by Date: Re: Show word count for current paragraph in status line
- Previous by thread: Re: How to set different string with different colors ?
- Next by thread: How to start a ediff-directory-revisons session having only the files that do actually differ?
- Index(es):
Relevant Pages
|