From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: Explicitly numbered subgroups in regular expressions Date: Tue, 12 Jun 2007 23:56:28 +0300 Organization: JURTA Message-ID: <87fy4wx56r.fsf@jurta.org> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1181682769 12735 80.91.229.12 (12 Jun 2007 21:12:49 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 12 Jun 2007 21:12:49 +0000 (UTC) Cc: rms@gnu.org, emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jun 12 23:12:45 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HyDfQ-00061h-Do for ged-emacs-devel@m.gmane.org; Tue, 12 Jun 2007 23:12:44 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HyDfP-0004k1-TH for ged-emacs-devel@m.gmane.org; Tue, 12 Jun 2007 17:12:43 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HyDfM-0004jt-9x for emacs-devel@gnu.org; Tue, 12 Jun 2007 17:12:40 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HyDfK-0004jc-Tu for emacs-devel@gnu.org; Tue, 12 Jun 2007 17:12:39 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HyDfK-0004jZ-OZ for emacs-devel@gnu.org; Tue, 12 Jun 2007 17:12:38 -0400 Original-Received: from relay02.kiev.sovam.com ([62.64.120.197]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1HyDfJ-0000i3-Ae; Tue, 12 Jun 2007 17:12:37 -0400 Original-Received: from [83.170.232.243] (helo=smtp.svitonline.com) by relay02.kiev.sovam.com with esmtp (Exim 4.67) (envelope-from ) id 1HyDfD-0003aq-L2; Wed, 13 Jun 2007 00:12:34 +0300 In-Reply-To: (Stefan Monnier's message of "Tue\, 12 Jun 2007 14\:42\:24 -0400") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux) X-Scanner-Signature: bb9f355b5be917825c280d06cf0e20ab X-DrWeb-checked: yes X-SpamTest-Envelope-From: juri@jurta.org X-SpamTest-Group-ID: 00000000 X-SpamTest-Header: Not Detected X-SpamTest-Info: Profiles 1133 [June 09 2007] X-SpamTest-Info: helo_type=3 X-SpamTest-Method: none X-SpamTest-Rate: 0 X-SpamTest-Status: Not detected X-SpamTest-Status-Extended: not_detected X-SpamTest-Version: SMTP-Filter Version 3.0.0 [0255], KAS30/Release X-detected-kernel: FreeBSD 4.8-5.1 (or MacOS X 10.2-10.3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:72713 Archived-At: >> The feature seems useful, but how does this affect the numbering of >> groups that don't specify a number? That has to be done right, then >> documented in the two manuals. > > Done. Except I have only documented it in the Elisp manual: I believe it's > only useful for Lisp programming, not for interactive regexp use. This feature makes regexps more readable and less error-prone, so I think it would be useful for interactive usage like in query-replace-regexp. Now since it was installed, I noticed that in Emacs Lisp files numbers in regexps don't get highlighted like grouping constructs in font-lock-regexp-grouping-construct face. The patch below adds highlighting for them. It also uses this new feature in the same regexp ;) Index: lisp/font-lock.el =================================================================== RCS file: /sources/emacs/emacs/lisp/font-lock.el,v retrieving revision 1.317 diff -c -r1.317 font-lock.el *** lisp/font-lock.el 21 Apr 2007 14:30:25 -0000 1.317 --- lisp/font-lock.el 12 Jun 2007 20:55:41 -0000 *************** *** 2279,2285 **** ;; that do not occur in strings. The associated regexp matches one ;; of `\\\\' `\\(' `\\(?:' `\\|' `\\)'. `\\\\' has been included to ;; avoid highlighting, for example, `\\(' in `\\\\('. ! (while (re-search-forward "\\(\\\\\\\\\\)\\(?:\\(\\\\\\\\\\)\\|\\((\\(?:\\?:\\)?\\|[|)]\\)\\)" bound t) (unless (match-beginning 2) (let ((face (get-text-property (1- (point)) 'face))) (when (or (and (listp face) --- 2279,2285 ---- ;; that do not occur in strings. The associated regexp matches one ;; of `\\\\' `\\(' `\\(?:' `\\|' `\\)'. `\\\\' has been included to ;; avoid highlighting, for example, `\\(' in `\\\\('. ! (while (re-search-forward "\\(?1:\\\\\\\\\\)\\(?:\\(?2:\\\\\\\\\\)\\|\\(?3:(\\(?:\\?[0-9]*:\\)?\\|[|)]\\)\\)" bound t) (unless (match-beginning 2) (let ((face (get-text-property (1- (point)) 'face))) (when (or (and (listp face) -- Juri Linkov http://www.jurta.org/emacs/