Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
emacs
emacs
Commits
07ff7702
Commit
07ff7702
authored
Oct 07, 2010
by
Miles Bader
Browse files
(regexp-opt): Add `symbols' mode.
parent
814cc274
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
4 deletions
+17
-4
doc/lispref/searching.texi
doc/lispref/searching.texi
+5
-1
lisp/ChangeLog
lisp/ChangeLog
+4
-0
lisp/emacs-lisp/regexp-opt.el
lisp/emacs-lisp/regexp-opt.el
+8
-3
No files found.
doc/lispref/searching.texi
View file @
07ff7702
...
...
@@ -918,7 +918,11 @@ for Font Lock mode.
If the optional argument @var{paren} is non-@code{nil}, 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
...
...
lisp/ChangeLog
View file @
07ff7702
2010-10-07 Miles Bader <Miles Bader <miles@gnu.org>>
* emacs-lisp/regexp-opt.el (regexp-opt): Add `symbols' mode.
2010-10-07 Glenn Morris <rgm@gnu.org>
* mail/rmail.el (mail-sendmail-delimit-header, mail-header-end)
...
...
lisp/emacs-lisp/regexp-opt.el
View file @
07ff7702
...
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment