summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/gv.el2
-rw-r--r--lisp/emacs-lisp/regexp-opt.el46
-rw-r--r--lisp/emacs-lisp/seq.el2
3 files changed, 38 insertions, 12 deletions
diff --git a/lisp/emacs-lisp/gv.el b/lisp/emacs-lisp/gv.el
index 93572e5e658..fa7ac64bf04 100644
--- a/lisp/emacs-lisp/gv.el
+++ b/lisp/emacs-lisp/gv.el
@@ -536,7 +536,7 @@ This macro only makes sense when used in a place."
"Return a reference to PLACE.
This is like the `&' operator of the C language.
Note: this only works reliably with lexical binding mode, except for very
-simple PLACEs such as (function-symbol \\='foo) which will also work in dynamic
+simple PLACEs such as (symbol-function \\='foo) which will also work in dynamic
binding mode."
(let ((code
(gv-letplace (getter setter) place
diff --git a/lisp/emacs-lisp/regexp-opt.el b/lisp/emacs-lisp/regexp-opt.el
index cf6653046b5..ef752858a4c 100644
--- a/lisp/emacs-lisp/regexp-opt.el
+++ b/lisp/emacs-lisp/regexp-opt.el
@@ -86,18 +86,44 @@
;;;###autoload
(defun regexp-opt (strings &optional paren)
"Return a regexp to match a string in the list STRINGS.
-Each string should be unique in STRINGS and should not contain any regexps,
-quoted or not. If optional PAREN is non-nil, ensure that the returned regexp
-is enclosed by at least one regexp grouping construct.
-The returned regexp is typically more efficient than the equivalent regexp:
+Each string should be unique in STRINGS and should not contain
+any regexps, quoted or not. Optional PAREN specifies how the
+returned regexp is surrounded by grouping constructs.
- (let ((open (if PAREN \"\\\\(\" \"\")) (close (if PAREN \"\\\\)\" \"\")))
- (concat open (mapconcat \\='regexp-quote STRINGS \"\\\\|\") close))
+The optional argument PAREN can be any of the following:
-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 \\_>."
+a string
+ the resulting regexp is preceded by PAREN and followed by
+ \\), e.g. use \"\\\\(?1:\" to produce an explicitly numbered
+ group.
+
+`words'
+ the resulting regexp is surrounded by \\=\\<\\( and \\)\\>.
+
+`symbols'
+ the resulting regexp is surrounded by \\_<\\( and \\)\\_>.
+
+non-nil
+ the resulting regexp is surrounded by \\( and \\).
+
+nil
+ the resulting regexp is surrounded by \\(?: and \\), if it is
+ necessary to ensure that a postfix operator appended to it will
+ apply to the whole expression.
+
+The resulting regexp is equivalent to but usually more efficient
+than that of a simplified version:
+
+ (defun simplified-regexp-opt (strings &optional paren)
+ (let ((parens
+ (cond ((stringp paren) (cons paren \"\\\\)\"))
+ ((eq paren 'words) '(\"\\\\\\=<\\\\(\" . \"\\\\)\\\\>\"))
+ ((eq paren 'symbols) '(\"\\\\_<\\\\(\" . \"\\\\)\\\\_>\"))
+ ((null paren) '(\"\\\\(?:\" . \"\\\\)\"))
+ (t '(\"\\\\(\" . \"\\\\)\")))))
+ (concat (car paren)
+ (mapconcat 'regexp-quote strings \"\\\\|\")
+ (cdr paren))))"
(save-match-data
;; Recurse on the sorted list.
(let* ((max-lisp-eval-depth 10000)
diff --git a/lisp/emacs-lisp/seq.el b/lisp/emacs-lisp/seq.el
index e5004f8cdab..9859f28f8e8 100644
--- a/lisp/emacs-lisp/seq.el
+++ b/lisp/emacs-lisp/seq.el
@@ -137,7 +137,7 @@ the sequence, and its index within the sequence."
(cl-defgeneric seq-subseq (sequence start &optional end)
"Return the sequence of elements of SEQUENCE from START to END.
-END is inclusive.
+END is exclusive.
If END is omitted, it defaults to the length of the sequence. If
START or END is negative, it counts from the end. Signal an