[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Use symbol anchors in generic.el

From: Miles Bader
Subject: Use symbol anchors in generic.el
Date: Thu, 09 Sep 2004 21:55:56 +0900

What do people think of the following change to generic.el, to use \_<
and \_> when matching keywords, instead of \< and \>?

I defined a mode (for povray) using `define-generic-mode', which uses
_lots_ of keywords, and the annoying result was that the keywords were
highlighted even they occurred as part of user symbols, when adjoined
using `_'.

I could fix this by making `_' a word-constituent instead of a
symbol-constituent, but that's not really right, and makes M-f
etc. behave annoyingly.

The following simple patch makes my mode behave much more reasonably,
and making keywords match whole symbols rather than just words seems
like it would be the more correct behavior in most cases.



diff -u lisp/generic.el.\~1\~ lisp/generic.el
--- lisp/generic.el.~1~ 2004-05-18 21:30:10.000000000 +0900
+++ lisp/generic.el     2004-09-09 21:47:30.000000000 +0900
@@ -405,10 +405,10 @@
 The regexp is highlighted with FACE."
   (unless (listp keywords-list)
     (error "Keywords argument must be a list of strings"))
-  (list (concat prefix "\\<"
+  (list (concat prefix "\\_<"
                ;; Use an optimized regexp.
                (regexp-opt keywords-list t)
-               "\\>" suffix)
+               "\\_>" suffix)

In New York, most people don't have cars, so if you want to kill a person, you
have to take the subway to their house.  And sometimes on the way, the train
is delayed and you get impatient, so you have to kill someone on the subway.
  [George Carlin]

reply via email to

[Prev in Thread] Current Thread [Next in Thread]