[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Replace regex strings with variables for font-lock
From: |
Ryan Bowman |
Subject: |
Replace regex strings with variables for font-lock |
Date: |
Thu, 28 Apr 2005 09:03:02 -0700 (PDT) |
I'm trying to write a major mode, using the following
from
http://www.emacswiki.org/cgi-bin/wiki/EasyFontLock
(defun my-mode () "my-mode" (interactive)
(kill-all-local-variables)
(make-local-variable 'font-lock-defaults)
(setq font-lock-defaults
'(my-mode-font-lock-keywords t)))
(defvar my-mode-font-lock-keywords nil
"Keywords/Regexp for fontlocking of my-mode")
(setq my-mode-font-lock-keywords
(list
'("^#.*$" 0 'bold)
'("\\(foo\\)\\(bar\\)" ; the word foobar in two
faces
(1 'font-lock-warning-face)
(2 'font-lock-type-face))))
That second part, being able to font-lock with
multiple faces is awesome.
Anyway, I want to replace the regex strings with
customizable variables, so I used defcustom to define
a variable and then in place of '("&#.*S" 0 'bold) I
tried '(my-var 0 'bold) but it didn't work, meaning to
the face wasn't applied. I tried defining the
variable with defcustom and defvar but neither had the
effect I wanted. Is there a way to use defcustom to
define a variable that contains a regex that will be
recognized by font-lock?
----
Ryan Bowman
While any text editor can save your files, only Emacs can save your soul. --
Per Abrahamsen
Emacs is not built by hate of vi. vi is irrelevant - it is no more than a
strange punishment that the unbelievers submit themselves to. -- Matan Ninio
----
__________________________________
Do you Yahoo!?
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/
- Replace regex strings with variables for font-lock,
Ryan Bowman <=