all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* font-locking regexps ?
@ 2005-09-26 19:11 Mads Jensen
  2005-09-26 21:33 ` Kevin Rodgers
  0 siblings, 1 reply; 2+ messages in thread
From: Mads Jensen @ 2005-09-26 19:11 UTC (permalink / raw)


Hi NG,

I am trying to write some code for coloring some regexps, but cannot
really make it work. Since regexps seem to be working a little bit
differently (| = \\| in emacs lisp and so on), I'd like some help. I am
trying to get some items in a list colored:

<code>
        (codes-inducks 
 	 (eval-when-compile
 	   (list 
 	    '("[YZ]. [0-9]{2}-[0-9]{2}-[0-9]" 
 	      "I .{9}" 
 	      "F .{8}" 
 	      "[DH] [0-9-]{6}" 
 	      "D 20[0-9-]{6}" 
 	      "W .{10}")))))
</code>

and I'm using these code for coloring it:

<code>
    (setq inducks-keywords
	  (list (cons keywords-inducks 'inducks-keyword-face)
                (cons codes-inducks 'inducks-code-face)))
</code>

But it's not working.

Please just point me to a major mode, that uses this. Someone refered me
to sql.el in an earlier thread, which helped me get some of the
font-lock part to work in a mode, I'm working on. 
-- 
Mads Jensen - mail sent to address ends in /dev/null
              s/spam/madsj for emailing me 
              gpg: 7E775BDA

It is impossible to make anything foolproof because fools are so
ingenious.

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

* Re: font-locking regexps ?
  2005-09-26 19:11 font-locking regexps ? Mads Jensen
@ 2005-09-26 21:33 ` Kevin Rodgers
  0 siblings, 0 replies; 2+ messages in thread
From: Kevin Rodgers @ 2005-09-26 21:33 UTC (permalink / raw)


Mads Jensen wrote:
 > I am trying to write some code for coloring some regexps, but cannot
 > really make it work. Since regexps seem to be working a little bit
 > differently (| = \\| in emacs lisp and so on), I'd like some help. I am
 > trying to get some items in a list colored:
 >
 > <code>
 >         (codes-inducks
 >  	 (eval-when-compile
 >  	   (list
 >  	    '("[YZ]. [0-9]{2}-[0-9]{2}-[0-9]"
 >  	      "I .{9}"
 >  	      "F .{8}"
 >  	      "[DH] [0-9-]{6}"
 >  	      "D 20[0-9-]{6}"
 >  	      "W .{10}")))))
 > </code>

The syntax of regular expressions is explained in the Regexps node of
the Emacs manual.  The syntax of strings is explained in the Syntax for
Strings node of the Emacs Lisp manual, but the Regexps node of the Emacs
manual mentions the key aspect (that each backslash of the regexp needs
to be doubled in the string):

|    Here is a complicated regexp, stored in `sentence-end' and used by
| Emacs to recognize the end of a sentence together with any whitespace
| that follows.  We show its Lisp syntax to distinguish the spaces from
| the tab characters.  In Lisp syntax, the string constant begins and
| ends with a double-quote.  `\"' stands for a double-quote as part of
| the regexp, `\\' for a backslash as part of the regexp, `\t' for a tab,
| and `\n' for a newline.
|
|      "[.?!][]\"')]*\\($\\| $\\|\t\\|  \\)[ \t\n]*"

So I suspect your code should be:

         (codes-inducks
  	    '("[YZ]. [0-9]\\{2\\}-[0-9]\\{2\\}-[0-9]"
  	      "I .\\{9\\}"
  	      "F .\\{8\\}"
  	      "[DH] [0-9-]\\{6\\}"
  	      "D 20[0-9-]\\{6\\}"
  	      "W .\\{10\\}"))

 > and I'm using these code for coloring it:
 >
 > <code>
 >     (setq inducks-keywords
 > 	  (list (cons keywords-inducks 'inducks-keyword-face)
 >                 (cons codes-inducks 'inducks-code-face)))
 > </code>
 >
 > But it's not working.
 >
 > Please just point me to a major mode, that uses this. Someone refered me
 > to sql.el in an earlier thread, which helped me get some of the
 > font-lock part to work in a mode, I'm working on.

M-x grep font-lock lisp/progmodes/*.el

-- 
Kevin Rodgers

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

end of thread, other threads:[~2005-09-26 21:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-26 19:11 font-locking regexps ? Mads Jensen
2005-09-26 21:33 ` Kevin Rodgers

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.