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: Stefan Monnier
Subject: Re: elisp q: what functions do I need to *visually* replace string foo with bar
Date: Wed, 07 Feb 2007 22:12:57 -0500
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.93 (gnu/linux)

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


reply via email to

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