RE: Help using font-lock
"Dan Bar Dov" <[email protected]> Sun, 18 Jun 2006 10:59:20 +0300
| Newsgroups | gmane.emacs.xemacs.general |
|---|---|
| Message-ID | <[email protected]> |
Thanks, I'll give it a try. Dan > -----Original Message----- > From: [email protected] > [mailto:[email protected]] On Behalf Of > [email protected] > Sent: Saturday, June 17, 2006 12:36 AM > To: [email protected] > Subject: Re: Help using font-lock > > I am by no stretch of the imagination an expert at this, and > I use emacs, > but here's one of mine. > > If you run this (eval-buffer), you will have a 'faces-mode' > command that > you can then run. > Alt-x faces-mode will then set all new faces for this buffer, > highlighting > each face name with it's attributes. > These were the only ones I knew about. > > Anyway, change a few strings to your regular expressions, add > this to your > .emacs, open your text file, and run "faces-mode" (or > whatever you rename > it to), and you should be good to go. > > Suggestions for improvement are always welcome. > > HIH > > (defvar faces-font-lock-keywords > (list > '("font-lock-builtin-face" . font-lock-builtin-face) > '("font-lock-comment-face" . font-lock-comment-face) > '("font-lock-constant-face" . font-lock-constant-face) > '("font-lock-doc-face" . font-lock-doc-face) > '("font-lock-function-name-face" . font-lock-function-name-face) > '("font-lock-keyword-face" . font-lock-keyword-face) > '("font-lock-reference-face" . font-lock-reference-face) > '("font-lock-string-face" . font-lock-string-face) > '("font-lock-type-face" . font-lock-type-face) > '("font-lock-variable-name-face" . font-lock-variable-name-face) > '("font-lock-warning-face" . font-lock-warning-face) > '("font-lock-syntactic-face" . font-lock-syntactic-face) > ) > "Faces and what they look like.") > > (defvar faces-mode-map nil > "Keymap for faces display mode.") > > (defun faces-mode () > "Major mode for viewing emacs face formats. > > Easiest way is to open ~load\faces-mode.el, then executing > faces-mode on > it. > You should then see how the various formats look." > (interactive) > (kill-all-local-variables) > (use-local-map faces-mode-map) > (setq mode-name "Available Faces mode") > (setq major-mode 'faces-mode) > (set-variable 'tab-width 3) > (set-variable 'indent-tabs-mode nil) > (set-variable 'truncate-partial-width-windows nil) ;line wrap on. > (set-variable 'comment-column 42) > (make-local-variable 'font-lock-defaults) > (setq font-lock-defaults '(faces-font-lock-keywords t)) > > (run-hooks 'faces-mode-hook) ) > [email protected] wrote on 06/15/2006 11:11:35 AM: > > > I'm having a problem understanding how to use font-lock-mode > > without using any major mode. > > > > Actually, I'm editing some text in text-mode and I'd like several > > forms to be highlighted. > > > > I tried to set the following in my init.el, but this does > not seem to > work > > > > (setq font-lock-keywords > > '((" \\*.*" . 'font-lock-string-face) > > ("---+ .*" . 'font-lock-string-face) > > )) > > > > I do not want to write a new major mode or anything fancy, something > > very simple. > > > > I'll appreciate any help > > Dan > > > >