all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Highlighting words in every possible buffer
@ 2008-08-25  8:12 Sébastien Vauban
  2008-08-25 13:49 ` harven
  0 siblings, 1 reply; 2+ messages in thread
From: Sébastien Vauban @ 2008-08-25  8:12 UTC (permalink / raw)
  To: help-gnu-emacs-mXXj517/zsQ

Hello,

I would like to have some words highlighted in every possible
buffer -- even in mail buffers, I'd like them highlighted
everywhere, always!

For example:

    o   get `error', `failed', `missing', etc. in bold red;
    o   get `warning', `insufficient', etc. in bold orange.

I tried something like:

--8<---------------cut here---------------start------------->8---
    (dolist (mode '(c-mode
                    text-mode
                    java-mode
                    cperl-mode
                    html-mode-hook
                    css-mode-hook
                    emacs-lisp-mode
                    nuweb-mode
                    latex-mode))
      (font-lock-add-keywords mode
       '(("\\<\\(XXX\\|FIXME\\|TODO\\|[eE][rR][rR][oO][rR]\\|BUG\\)"
          0 font-lock-warning-face t)
         ("\\<\\([wW][aA][rR][nN][iI][nN][gG]\\|[mM][iI][sS][sS][iI][nN][gG]\\|[iI][nN][vV][aA][lL][iI][dD]\\|[fF][aA][iI][lL][eE][dD]\\)"
          0 font-lock-warning-face t))))
--8<---------------cut here---------------end--------------->8---

But it does not work like expected...

    o   the words are not highlighted in *LaTeX* compilation
        buffer -- or, only after I manually ask for reverting
        the buffer;

    o   the words are not highlighted in shell outputs and the
        like (*grep* output, etc.).

Can you help?

Best regards,
  Seb

--
Sébastien Vauban


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Highlighting words in every possible buffer
  2008-08-25  8:12 Highlighting words in every possible buffer Sébastien Vauban
@ 2008-08-25 13:49 ` harven
  0 siblings, 0 replies; 2+ messages in thread
From: harven @ 2008-08-25 13:49 UTC (permalink / raw)
  To: help-gnu-emacs

On Aug 25, 10:12 am, Sébastien Vauban <zthjwsqqa...@spammotel.com>
wrote:
> Hello,
>
> I would like to have some words highlighted in every possible
> buffer -- even in mail buffers, I'd like them highlighted
> everywhere, always!
>
> For example:
>
>     o   get `error', `failed', `missing', etc. in bold red;
>     o   get `warning', `insufficient', etc. in bold orange.
>
> I tried something like:
>
> --8<---------------cut here---------------start------------->8---
>     (dolist (mode '(c-mode
>                     text-mode
>                     java-mode
>                     cperl-mode
>                     html-mode-hook
>                     css-mode-hook
>                     emacs-lisp-mode
>                     nuweb-mode
>                     latex-mode))
>       (font-lock-add-keywords mode
>        '(("\\<\\(XXX\\|FIXME\\|TODO\\|[eE][rR][rR][oO][rR]\\|BUG\\)"
>           0 font-lock-warning-face t)
>          ("\\<\\([wW][aA][rR][nN][iI][nN][gG]\\|[mM][iI][sS][sS][iI][nN][gG]\\|[iI][nN][vV][aA][lL][iI][dD]\\|[fF][aA][iI][lL][eE][dD]\\)"
>           0 font-lock-warning-face t))))
> --8<---------------cut here---------------end--------------->8---
>
> But it does not work like expected...
>
>     o   the words are not highlighted in *LaTeX* compilation
>         buffer -- or, only after I manually ask for reverting
>         the buffer;
>
>     o   the words are not highlighted in shell outputs and the
>         like (*grep* output, etc.).
>
> Can you help?
>
> Best regards,
>   Seb
>
> --
> Sébastien Vauban

The following should work in most cases.

(add-hook 'after-change-major-mode-hook
  (lambda ()
   (font-lock-add-keywords nil
    '(("myword" . font-lock-warning-face)))))

Beware that in certain circumstances, the mode may choose to overwrite
your face specification. This happens, for example, in occur mode. It
also happens in grep mode if your word is a substring of a longer word
(e.g. mywords), in which case the matched substring will be
highlighted with some particular face
that will overwrite yours.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-08-25 13:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-25  8:12 Highlighting words in every possible buffer Sébastien Vauban
2008-08-25 13:49 ` harven

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.