From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tim X Newsgroups: gmane.emacs.help Subject: Re: regexp-opt for all kinds of strings Date: Fri, 20 Jul 2007 13:04:14 +1000 Organization: Posted via Supernews, http://www.supernews.com Message-ID: <87r6n3zsgh.fsf@lion.rapttech.com.au> References: <1184775694.881034.197770@i38g2000prf.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: sea.gmane.org 1184902876 26706 80.91.229.12 (20 Jul 2007 03:41:16 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 20 Jul 2007 03:41:16 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Jul 20 05:41:15 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IBjMg-0000Rq-Rq for geh-help-gnu-emacs@m.gmane.org; Fri, 20 Jul 2007 05:41:15 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IBjMg-0006id-C2 for geh-help-gnu-emacs@m.gmane.org; Thu, 19 Jul 2007 23:41:14 -0400 Original-Path: shelby.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!out03a.usenetserver.com!news.usenetserver.com!in04.usenetserver.com!news.usenetserver.com!news-in-02.newsfeed.easynews.com!easynews.com!easynews!sn-xt-sjc-03!sn-xt-sjc-08!sn-post-sjc-01!supernews.com!corp.supernews.com!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux) Cancel-Lock: sha1:szZwiq/3hjcoXu1nkEndebluI/c= Original-X-Complaints-To: abuse@supernews.com Original-Lines: 37 Original-Xref: shelby.stanford.edu gnu.emacs.help:150241 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:45823 Archived-At: Nordlöw writes: > Hey there! > > Why aren't all kinds of characters allowed in regexp-opt()? I am doing > syntax highlighting of operators in c-mode and would like regexp-opt > to work for lists such: > '("+" "-" "*" "/" "++" "--") > > Have I missed something. Or is the feature a TODO? > > As far as I know, the restrictions you reference don't exist. However, it is possible you are trying to use the wrong tool. In what way did you find it didn't work? The problem could be with boundry situations i.e. only matches ' ++ ' and not the ++ in ++foo or foo++ etc. The regexp-opt is really best applied when you have sets of distinct "words" that you want to match. From your description, I suspect that what you want is just a fairly simple regexp. (One restriction of regexp-opt is that you cannot have regexps in the list). If you just want to match the operators like ++, * and - etc, I suspect you would be better off with just a normal regexp. While regexp-opt is really handy when you have quite long lists of words to match and is pretty good at optimizing the resulting regexp, for simpler patterns, it really is overkill. Maybe if you explain exactly what you are trying to achieve people on this list may be able to provide useful examples/suggestions. regards, Tim -- tcross (at) rapttech dot com dot au