From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ryan Bowman Newsgroups: gmane.emacs.help Subject: Replace regex strings with variables for font-lock Date: Thu, 28 Apr 2005 09:03:02 -0700 (PDT) Message-ID: <20050428160302.71528.qmail@web51901.mail.yahoo.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1114704076 18580 80.91.229.2 (28 Apr 2005 16:01:16 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 28 Apr 2005 16:01:16 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Apr 28 18:01:09 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DRBPy-00018Q-9p for geh-help-gnu-emacs@m.gmane.org; Thu, 28 Apr 2005 17:59:10 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DRBW7-00077H-SS for geh-help-gnu-emacs@m.gmane.org; Thu, 28 Apr 2005 12:05:31 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DRBV9-0006gc-9t for help-gnu-emacs@gnu.org; Thu, 28 Apr 2005 12:04:31 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DRBV7-0006et-8j for help-gnu-emacs@gnu.org; Thu, 28 Apr 2005 12:04:30 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DRBV6-0003dd-WB for help-gnu-emacs@gnu.org; Thu, 28 Apr 2005 12:04:29 -0400 Original-Received: from [206.190.39.44] (helo=web51901.mail.yahoo.com) by monty-python.gnu.org with smtp (Exim 4.34) id 1DRBXk-0001gl-DJ for help-gnu-emacs@gnu.org; Thu, 28 Apr 2005 12:07:12 -0400 Original-Received: (qmail 71530 invoked by uid 60001); 28 Apr 2005 16:03:02 -0000 Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; b=aZopT3kBnhArU5Km0VyD4ErB+BiR4ZfiOMzy3UmVnKnuWx1AnvZMDYA+RQY6wOioZAu3wfC+uvl+c0+GNZeT+SoChhyn/lI44VrVtlUfke2/9hWIKl3HqenGK9wFHqvCqNMnfly3Bw9VSD5jBM+oOEDMEEySXnK+LeyQnWKiCOU= ; Original-Received: from [128.187.0.165] by web51901.mail.yahoo.com via HTTP; Thu, 28 Apr 2005 09:03:02 PDT Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:26109 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:26109 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/