help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: elisp q: what functions do I need to *visually* replace string foo w


From: Mirko
Subject: Re: elisp q: what functions do I need to *visually* replace string foo with bar
Date: 8 Feb 2007 05:36:01 -0800
User-agent: G2/1.0

On Feb 7, 10:12 pm, Stefan Monnier <monn...@iro.umontreal.ca> wrote:
> > (setq font-lock-defaults
> >       '((("\\*self\\.\\(\\(?:\\s_\\|\\sw\\)+\\)" 1 my-italic-face)
> >         ("\\(\\*self\\.\\)\\(?:\\s_\\|\\sw\\)+" 1 my-invisible-face))
> >        ))
>
> This can be advantageously merged:
>
>  (setq font-lock-keywords
>        '(("\\(\\*self\\.\\)\\(\\(?:\\s_\\|\\sw\\)+\\)"
>           (1 'my-invisible-face)
>           (2 'italic))))
>
> And instead of a special transparent face, you can use:
>
>  (setq font-lock-keywords
>        '(("\\(\\*self\\.\\)\\(\\(?:\\s_\\|\\sw\\)+\\)"
>           (1 '(face nil invisible t))
>           (2 'italic))))
>
> but then you'll also have to add `invisible' to
> `font-lock-extra-managed-props'.
>
> And the above setting of `font-lock-keywords' is of course incorrect since
> it erases any other font-lock rules of the major mode.  Maybe something like
>
>   (add-hook 'my-idl-mode-hook
>              (lambda ()
>                (font-lock-add-keywords nil
>                  '(("\\(\\*self\\.\\)\\(\\(?:\\s_\\|\\sw\\)+\\)"
>                     (1 'my-invisible-face)
>                     (2 'italic))))
>                (add-to-list 'font-lock-extra-managed-props 'invisible)))
>
> Of course the above has not been tested at all.
>
>         Stefan

All of you have given me something to play with.  I'll try it over the
weekend.

Thank you very much,

Mirko



reply via email to

[Prev in Thread] Current Thread [Next in Thread]