[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#4392: (Regexp Functions): The PAREN argument to `regexp-opt' can be
From: |
Devon Sean McCullough |
Subject: |
bug#4392: (Regexp Functions): The PAREN argument to `regexp-opt' can be `symbols'. |
Date: |
Thu, 10 Sep 2009 14:48:08 -0700 (PDT) |
Please patch REGEXP-OPT to take a PAREN 'symbols argument.
Index: emacs/doc/lispref/searching.texi
===================================================================
RCS file: /sources/emacs/emacs/doc/lispref/searching.texi,v
retrieving revision 1.18
diff -u -r1.18 searching.texi
--- emacs/doc/lispref/searching.texi 27 Aug 2009 04:24:02 -0000 1.18
+++ emacs/doc/lispref/searching.texi 10 Sep 2009 20:20:36 -0000
@@ -921,6 +921,7 @@
returned regular expression is always enclosed by at least one
parentheses-grouping construct. If @var{paren} is @code{words}, then
that construct is additionally surrounded by @samp{\<} and @samp{\>}.
+Likewise if @var{paren} is @code{symbols}, by @samp{\_<} and @samp{\_>}.
This simplified definition of @code{regexp-opt} produces a
regular expression which is equivalent to the actual value
Index: emacs/lisp/emacs-lisp/regexp-opt.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/emacs-lisp/regexp-opt.el,v
retrieving revision 1.42
diff -u -r1.42 regexp-opt.el
--- emacs/lisp/emacs-lisp/regexp-opt.el 5 Jan 2009 03:21:08 -0000 1.42
+++ emacs/lisp/emacs-lisp/regexp-opt.el 10 Sep 2009 20:20:36 -0000
@@ -96,7 +96,7 @@
(concat open (mapconcat 'regexp-quote STRINGS \"\\\\|\") close))
If PAREN is `words', then the resulting regexp is additionally surrounded
-by \\=\\< and \\>."
+by \\=\\< and \\>. Likewise if PAREN is `symbols', by \\_< and \\_>."
(save-match-data
;; Recurse on the sorted list.
(let* ((max-lisp-eval-depth 10000)
@@ -104,11 +104,14 @@
(completion-ignore-case nil)
(completion-regexp-list nil)
(words (eq paren 'words))
+ (symbols (eq paren 'symbols))
(open (cond ((stringp paren) paren) (paren "\\(")))
(sorted-strings (delete-dups
(sort (copy-sequence strings) 'string-lessp)))
(re (regexp-opt-group sorted-strings (or open t) (not open))))
- (if words (concat "\\<" re "\\>") re))))
+ (cond (words (concat "\\<" re "\\>"))
+ (symbols (concat "\\_<" re "\\_>"))
+ (t re)))))
;;;###autoload
(defun regexp-opt-depth (regexp)
Peace
--Devon
/~\
\ / Health Care
X not warfare
/ \
- bug#4392: (Regexp Functions): The PAREN argument to `regexp-opt' can be `symbols'.,
Devon Sean McCullough <=