GNU bug report logs - #1402
suggestion: add 'symbol to regexp-opt's second parameter

Previous Next

Package: emacs;

Reported by: xah lee <xah <at> xahlee.org>

Date: Fri, 21 Nov 2008 20:20:02 UTC

Severity: wishlist

Tags: wontfix

Merged with 4392

Fixed in version 24.1

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: xah lee <xah <at> xahlee.org>
To: bug-gnu-emacs <at> gnu.org
Subject: bug#1402: suggestion: add 'symbol to regexp-opt's second parameter
Date: Fri, 21 Nov 2008 12:11:36 -0800
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/

This bug report was last modified 14 years and 10 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.