[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] regexp-opt support for \_< and \_>
From: |
Daniel Colascione |
Subject: |
[PATCH] regexp-opt support for \_< and \_> |
Date: |
Tue, 26 May 2009 18:18:36 -0400 |
User-agent: |
KMail/1.11.3 (Linux/2.6.27.21-170.2.56.fc10.i686; KDE/4.2.3; i686; ; ) |
Trivial patch to allow regexp-opt to wrap words in \_< and \_> instead of \<
and \>. Also document the behavior of regexp-opt when PAREN is a string.
Index: regexp-opt.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/emacs-lisp/regexp-opt.el,v
retrieving revision 1.42
diff -u -r1.42 regexp-opt.el
--- regexp-opt.el 5 Jan 2009 03:21:08 -0000 1.42
+++ regexp-opt.el 26 May 2009 22:17:43 -0000
@@ -95,20 +95,28 @@
(let ((open (if PAREN \"\\\\(\" \"\")) (close (if PAREN \"\\\\)\" \"\")))
(concat open (mapconcat 'regexp-quote STRINGS \"\\\\|\") close))
-If PAREN is `words', then the resulting regexp is additionally surrounded
-by \\=\\< and \\>."
+If PAREN is a string, use that string instead of the opening
+\\=(. Note that because a closing parenthesis is still added to
+the generated regular expression, PAREN should contain an open
+parenthesis.
+
+If PAREN is `words', then the resulting regexp is additionally
+surrounded 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 "\\(")))
+ (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)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] regexp-opt support for \_< and \_>,
Daniel Colascione <=