unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#1402: suggestion: add 'symbol to regexp-opt's second parameter
@ 2008-11-21 20:11 xah lee
  0 siblings, 0 replies; only message in thread
From: xah lee @ 2008-11-21 20:11 UTC (permalink / raw)
  To: bug-gnu-emacs

this is a suggestion.

the function regexp-opt takes a second argument “'words” to make  
the regex match word boundary. Perhaps it'd be useful to have  
“'symbol” as the second argument as well.

as far as i know, when people do like this when they need symbol:

(concat "\\_<" (regexp-opt myLang-functions) ">_\\")

having

(regexp-opt myLang-functions 'symbol)

would be convenient and seems to me consistent.

For example, i currently have:

(defvar xlsl-keywords-regexp (regexp-opt xlsl-keywords 'words))
(defvar xlsl-type-regexp (regexp-opt xlsl-types 'words))
(defvar xlsl-constant-regexp (regexp-opt xlsl-constants 'words))
(defvar xlsl-event-regexp (regexp-opt xlsl-events 'words))
(defvar xlsl-functions-regexp (regexp-opt xlsl-functions 'words))

but i'd prefer that each is 'symbol. Using concat makes the code much  
longer and less readable.

Also, i think matching on symbol boundary is probably more commonly  
needed than words, for language major modes.

PS before i send this, i posted to gnu.emacs.help to see if this is  
sensible question. It seems that either this is already supported in  
the dev version of emacs, or that this can still use some  
improvement. I'm logging this suggestion here to be sure. Here's the  
thread:

http://groups.google.com/group/gnu.emacs.help/browse_frm/thread/ 
289e42f24f21f65c

subject: “regex-opt does not accept 'symbol as second arg?”
date: 2008-10-11

   Xah
∑ http://xahlee.org/^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-11-21 20:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-21 20:11 bug#1402: suggestion: add 'symbol to regexp-opt's second parameter xah lee

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).