emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r101829: (regexp-opt): Add `symbols'


From: Miles Bader
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r101829: (regexp-opt): Add `symbols' mode.
Date: Thu, 07 Oct 2010 16:24:21 +0900
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 101829
committer: Miles Bader <address@hidden>
branch nick: trunk
timestamp: Thu 2010-10-07 16:24:21 +0900
message:
  (regexp-opt): Add `symbols' mode.
modified:
  doc/lispref/searching.texi
  lisp/ChangeLog
  lisp/emacs-lisp/regexp-opt.el
=== modified file 'doc/lispref/searching.texi'
--- a/doc/lispref/searching.texi        2010-06-23 03:36:56 +0000
+++ b/doc/lispref/searching.texi        2010-10-07 07:24:21 +0000
@@ -918,7 +918,11 @@
 If the optional argument @var{paren} is address@hidden, then the
 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{\>}.
+that construct is additionally surrounded by @samp{\<} and @samp{\>};
+alternatively, if @var{paren} is @code{symbols}, then that construct
+is additionally surrounded by @samp{\_<} and @samp{\_>}
+(@code{symbols} is often appropriate when matching
+programming-language keywords and the like).
 
 This simplified definition of @code{regexp-opt} produces a
 regular expression which is equivalent to the actual value

=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2010-10-07 02:42:30 +0000
+++ b/lisp/ChangeLog    2010-10-07 07:24:21 +0000
@@ -1,3 +1,7 @@
+2010-10-07  Miles Bader  <Miles Bader <address@hidden>>
+
+       * emacs-lisp/regexp-opt.el (regexp-opt): Add `symbols' mode.
+
 2010-10-07  Glenn Morris  <address@hidden>
 
        * mail/rmail.el (mail-sendmail-delimit-header, mail-header-end)

=== modified file 'lisp/emacs-lisp/regexp-opt.el'
--- a/lisp/emacs-lisp/regexp-opt.el     2010-09-10 23:13:42 +0000
+++ b/lisp/emacs-lisp/regexp-opt.el     2010-10-07 07:24:21 +0000
@@ -96,19 +96,24 @@
    (concat open (mapconcat 'regexp-quote STRINGS \"\\\\|\") close))
 
 If PAREN is `words', then the resulting regexp is additionally surrounded
-by \\=\\< and \\>."
+by \\=\\< and \\>.
+If PAREN is `symbols', then the resulting regexp is additionally surrounded
+by \\=\\_< and \\_>."
   (save-match-data
     ;; Recurse on the sorted list.
     (let* ((max-lisp-eval-depth 10000)
           (max-specpdl-size 10000)
           (completion-ignore-case nil)
           (completion-regexp-list nil)
-          (words (eq paren 'words))
           (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 ((eq paren 'words)
+            (concat "\\<" re "\\>"))
+           ((eq paren 'symbols)
+            (concat "\\_<" re "\\_>"))
+           (t re)))))
 
 ;;;###autoload
 (defun regexp-opt-depth (regexp)


reply via email to

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