aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/lispref/searching.texi46
1 files changed, 25 insertions, 21 deletions
diff --git a/doc/lispref/searching.texi b/doc/lispref/searching.texi
index a335e89985f..579460f3227 100644
--- a/doc/lispref/searching.texi
+++ b/doc/lispref/searching.texi
@@ -950,37 +950,41 @@ more efficient, but is almost never worth the effort.}.
950 950
951The optional argument @var{paren} can be any of the following: 951The optional argument @var{paren} can be any of the following:
952 952
953a string 953@table @asis
954 the resulting regexp is preceded by @var{paren} and followed by 954@item a string
955 @samp{\)}, e.g. use @samp{"\\(?1:"} to produce an explicitly 955The resulting regexp is preceded by @var{paren} and followed by
956 numbered group. 956@samp{\)}, e.g. use @samp{"\\(?1:"} to produce an explicitly
957numbered group.
957 958
958@code{words} 959@item @code{words}
959 the resulting regexp is surrounded by @samp{\<\(} and @samp{\)\>}. 960The resulting regexp is surrounded by @samp{\<\(} and @samp{\)\>}.
960 961
961@code{symbols} 962@item @code{symbols}
962 the resulting regexp is surrounded by @samp{\_<\(} and @samp{\)\_>} 963The resulting regexp is surrounded by @samp{\_<\(} and @samp{\)\_>}
963 (this is often appropriate when maching programming-language 964(this is often appropriate when matching programming-language
964 keywords and the like). 965keywords and the like).
965 966
966non-@code{nil} 967@item non-@code{nil}
967 the resulting regexp is surrounded by @samp{\(} and @samp{\)}. 968The resulting regexp is surrounded by @samp{\(} and @samp{\)}.
968 969
969@code{nil} 970@item @code{nil}
970 the resulting regexp is surrounded by @samp{\(?:} and @samp{\)}, 971The resulting regexp is surrounded by @samp{\(?:} and @samp{\)},
971 if it is necessary to ensure that a postfix operator appended to 972if it is necessary to ensure that a postfix operator appended to
972 it will apply to the whole expression. 973it will apply to the whole expression.
974@end table
973 975
974The resulting regexp of @code{regexp-opt} is equivalent to but usually 976The resulting regexp of @code{regexp-opt} is equivalent to but usually
975more efficient than that of a simplified version: 977more efficient than that of a simplified version:
976 978
977@example 979@example
978(defun simplified-regexp-opt (strings &optional paren) 980(defun simplified-regexp-opt (strings &optional paren)
979 (let ((parens (cond ((stringp paren) (cons paren "\\)")) 981 (let ((parens
980 ((eq paren 'words) '("\\<\\(" . "\\)\\>")) 982 (cond
981 ((eq paren 'symbols) '("\\_<\\(" . "\\)\\_>")) 983 ((stringp paren) (cons paren "\\)"))
982 ((null paren) '("\\(?:" . "\\)")) 984 ((eq paren 'words) '("\\<\\(" . "\\)\\>"))
983 (t '("\\(" . "\\)"))))) 985 ((eq paren 'symbols) '("\\_<\\(" . "\\)\\_>"))
986 ((null paren) '("\\(?:" . "\\)"))
987 (t '("\\(" . "\\)")))))
984 (concat (car paren) 988 (concat (car paren)
985 (mapconcat 'regexp-quote strings "\\|") 989 (mapconcat 'regexp-quote strings "\\|")
986 (cdr paren)))) 990 (cdr paren))))