unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: rms@gnu.org, emacs-devel@gnu.org
Subject: Re: Explicitly numbered subgroups in regular expressions
Date: Tue, 12 Jun 2007 23:56:28 +0300	[thread overview]
Message-ID: <87fy4wx56r.fsf@jurta.org> (raw)
In-Reply-To: <jwvd501yq16.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Tue\, 12 Jun 2007 14\:42\:24 -0400")

>> 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/

  reply	other threads:[~2007-06-12 20:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-09 20:37 Explicitly numbered subgroups in regular expressions Stefan Monnier
2007-06-10 13:19 ` Richard Stallman
2007-06-10 13:44   ` Stefan Monnier
2007-06-11  9:44     ` Richard Stallman
2007-06-12 18:42   ` Stefan Monnier
2007-06-12 20:56     ` Juri Linkov [this message]
2007-06-13 16:23     ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fy4wx56r.fsf@jurta.org \
    --to=juri@jurta.org \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=rms@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).