unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* How to "import" font-lock keywords?
@ 2004-12-01  8:31 MH Lee
  2004-12-01  9:15 ` Joe Corneli
  2004-12-01 14:52 ` Stefan Monnier
  0 siblings, 2 replies; 3+ messages in thread
From: MH Lee @ 2004-12-01  8:31 UTC (permalink / raw)


Hi,

I would like to "import" keywords from latex-mode into z-latex-mode,
so that I can reuse the syntax highlighting. Can someone please point
out to me how this can be done?

I am using GNU Emacs 21.3.1 on Gentoo Linux.

Thanks,
MH Lee

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

* Re: How to "import" font-lock keywords?
  2004-12-01  8:31 How to "import" font-lock keywords? MH Lee
@ 2004-12-01  9:15 ` Joe Corneli
  2004-12-01 14:52 ` Stefan Monnier
  1 sibling, 0 replies; 3+ messages in thread
From: Joe Corneli @ 2004-12-01  9:15 UTC (permalink / raw)



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

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

* Re: How to "import" font-lock keywords?
  2004-12-01  8:31 How to "import" font-lock keywords? MH Lee
  2004-12-01  9:15 ` Joe Corneli
@ 2004-12-01 14:52 ` Stefan Monnier
  1 sibling, 0 replies; 3+ messages in thread
From: Stefan Monnier @ 2004-12-01 14:52 UTC (permalink / raw)


> I would like to "import" keywords from latex-mode into z-latex-mode,
> so that I can reuse the syntax highlighting. Can someone please point
> out to me how this can be done?

If you use define-derived-mode, that will happen automatically.


        Stefan

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

end of thread, other threads:[~2004-12-01 14:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-12-01  8:31 How to "import" font-lock keywords? MH Lee
2004-12-01  9:15 ` Joe Corneli
2004-12-01 14:52 ` Stefan Monnier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).