Toshi Isogai writes:
Is there regexp type?
Using string type makes regexps need a lot of backslashes.
There's no regexp "type", but there is a more convenient way to notate
regexps: raw strings. Then this
(if (looking-at "\\s-*\\(in\\|out\\)\\s-*") ....
(if (looking-at #r"\s-*\(in\|out\)\s-*") ....
I don't believe that GNU Emacs supports raw strings yet, and I don't
think the upcoming v23 does, either.
I wonder if it is possible to make it something like
(if (looking-at /\s-*(in|out)\s-*/ ) ....
Sure. Use Perl, not XEmacs. :^)
Adding special syntax for regexps (which really are just strings as a
data type; XEmacs does compile them to a special byte code, but this is
entirely internal) would complicate lexing immensely ("/" is a valid
symbol component, so
(setq /bin/sh "/usr/local/bin/zsh-dev")
actually sets the value of the symbol `/bin/sh').
A PCRE-compatible regular expression syntax would be far more useful
("#r" is only two extra characters), but it would require changing a
lot of things to implement, and for backward compatibility it would
have to exist alongside of the old-style regular expressions. So it
hasn't been done yet. It would be possible to do something like
(defun pcre-compile (regexp)
"Rewrite the Perl-compatible regular expression REGEXP in Emacs syntax."
;; code goes here)
and call it
(if (looking-at (pcre-compile #r"\s-*(in|out)\s-*)) ....
as a first step in that direction. You might want to look at the
re-builder library (supplied in the XEmacs packages distribution) and
the libraries referenced in it (such as rx, sregex, and lisp-re). I
don't know whether any of them provide such translation, but it seems
XEmacs-Beta mailing list