diff options
author | Miles Bader <miles@gnu.org> | 2010-10-07 16:24:21 +0900 |
---|---|---|
committer | Miles Bader <miles@gnu.org> | 2010-10-07 16:24:21 +0900 |
commit | 07ff7702e086ca4eb02aadf438c97a9c87c3389d (patch) | |
tree | cbd1666f876739d276550641ef3aaaaf4e5d95db /lisp/emacs-lisp/regexp-opt.el | |
parent | 814cc274efc3002fa80122a3f5d55ed7493656c3 (diff) | |
download | emacs-07ff7702e086ca4eb02aadf438c97a9c87c3389d.tar.gz emacs-07ff7702e086ca4eb02aadf438c97a9c87c3389d.tar.bz2 emacs-07ff7702e086ca4eb02aadf438c97a9c87c3389d.zip |
(regexp-opt): Add `symbols' mode.
Diffstat (limited to 'lisp/emacs-lisp/regexp-opt.el')
-rw-r--r-- | lisp/emacs-lisp/regexp-opt.el | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lisp/emacs-lisp/regexp-opt.el b/lisp/emacs-lisp/regexp-opt.el index a1494741572..6389b62ea04 100644 --- a/lisp/emacs-lisp/regexp-opt.el +++ b/lisp/emacs-lisp/regexp-opt.el @@ -96,19 +96,24 @@ The returned regexp is typically more efficient than the equivalent regexp: (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) |