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

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

Re: How to "import" font-lock keywords?


From: Joe Corneli
Subject: Re: How to "import" font-lock keywords?
Date: Wed, 01 Dec 2004 03:15:07 -0600

Check out how it is done in tex-mode.el --

you can add font lock keyword collections together as so.

(defconst tex-font-lock-keywords-3
  (append tex-font-lock-keywords-2
   (eval-when-compile
     (let ((general "\\([a-zA-Z@]+\\|[^ \t\n]\\)")
        (slash "\\\\")
           ;; This is not the same regexp as before: it has a `+' removed.
              ;; The + makes the matching faster in the above cases (where we 
can
                 ;; exit as soon as the match fails) but would make this 
matching
                    ;; degenerate to nasty complexity (because we try to match 
the
                       ;; closing brace, which forces trying all matching 
combinations).
                          (arg "{\\(?:[^{}\\]\\|\\\\.\\|{[^}]*}\\)*"))
       `((,(concat "[_^] *\\([^\n\\{}]\\|" slash general "\\|" arg "}\\)")
         (1 (tex-font-lock-suscript (match-beginning 0))
              append))))))
  "Experimental expressions to highlight in TeX modes.")

Or, say, like this:

(setq z-latex-font-lock-keywords (append tex-font-lock-keywords-1
                                         z-latex-font-lock-keywords)
  "What we highlight.")

(Use the source to find the right variable names.)




reply via email to

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