Re: How to set different string with different colors ?



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--
.



Relevant Pages

  • Re: inbox preview pane
    ... But at the moment all I have showing is 1 huge list of all ... I have tried looking all through the tabs trying to ... | customise this view to be shown but I must be missing it somewhere. ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)
  • Re: Tabs no longer visible in PageControl
    ... with PageControl1 do begin ... NoteBook.ActivePage:= PrevSheet; ... but it seems that you have to select a lower (by tabs showing) ...
    (alt.comp.lang.borland-delphi)
  • Re: How to cache NSTabView items
    ... } my 16 bit background could be showing - always trying to} squeeze into a 65kb space;-) ... If the subviews are not horribly complex and the number of tabs is constant, you might consider putting all of the tab view into one nib so that it all loads automatically for you. ... These objects do take up some amount of space, but not really that much - most Macs these days have enough room to tolerate a well stocked nib, if its structural content is not too extreme. ...
    (comp.sys.mac.programmer.help)
  • Re: microsoft word
    ... > All of my word documents are showing the symbols for "periods, tabs, ... What can I do to get rid of these symbols? ...
    (microsoft.public.windowsxp.newusers)