unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#4392: (Regexp Functions): The PAREN argument to `regexp-opt' can be `symbols'.
@ 2009-09-10 21:48 Devon Sean McCullough
  2009-09-11 19:17 ` Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: Devon Sean McCullough @ 2009-09-10 21:48 UTC (permalink / raw)
  To: bug-gnu-emacs

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
	 / \






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

end of thread, other threads:[~2011-07-09 18:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-10 21:48 bug#4392: (Regexp Functions): The PAREN argument to `regexp-opt' can be `symbols' Devon Sean McCullough
2009-09-11 19:17 ` Stefan Monnier
2009-09-11 19:25   ` Processed: " Emacs bug Tracking System
2011-07-09 18:49   ` Glenn Morris

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).