[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Structural regular expressions
From: |
Tom |
Subject: |
Re: Structural regular expressions |
Date: |
Fri, 10 Sep 2010 20:29:45 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
David House <dmhouse <at> gmail.com> writes:
>
> On 10 September 2010 16:43, Richard Stallman <rms <at> gnu.org> wrote:
> > Could someone please explain what a "structural regular expression"
> > means? The message that started the thread did not say.
>
> It is not a property of the regexps themselves, but pertains to
> functions that use regexps: namely that they only apply to a subset of
> your buffer. For example, you might do a query-replace-regexp on only
> the comments of a C file, or an isearch-regexp on only the strings. So
> note that the subsets they apply to are non-contiguous in general.
>
It is the property of the regexps, because the main point of the
feature is there are enhanced regexps which are aware of the
syntax of the buffer contents, so you can select comments,
strings, scopes, etc.
Examples for the mentioned blog post:
V/pattern select all matches
V|pattern select all lines with match
V{scope select all matching scopes
Vatype select all objects (inclusive)
Vttype select all objects (exclusive)
Y/pattern select everything but matches
Y|pattern select all lines without match
Y{scope select everything but scope
Yatype select everything but objects (inclusive)
Yttype select everything but objects (exclusive)
And you can perform further selections after the first selection
recursively, so you can select comments in scopes, etc.
The document that inspired the above feature of the E editor:
"The current UNIX® text processing tools are weakened by the
built-in concept of a line. There is a simple notation that can
describe the `shape' of files when the typical array-of-lines
picture is inadequate. That notation is regular
expressions. Using regular expressions to describe the structure
in addition to the contents of files has interesting
applications, and yields elegant methods for dealing with some
problems the current tools handle clumsily. When operations using
these expressions are composed, the result is reminiscent of
shell pipelines."
http://doc.cat-v.org/bell_labs/structural_regexps/se.pdf
> It has been proposed to support this by generalizing the concept of
> the region to actually be a list of (contiguous) regions. Another idea
> further up was to use special text properties.
I wonder if there is a simpler solution.
For example, during the selection process a separate buffer could
display interactively the current selection made by the user and
this buffer could be set up with text properties and such, so
that it is known where the individual ranges start and end.
After the user done his work in this temporary buffer the
resulting ranges could be copied back to the appropriate sections
of the original buffer thereby committing the changes.
This way nothing has to be changed in Emacs core.
- Re: Structural regular expressions, (continued)
- Re: Structural regular expressions, Stefan Monnier, 2010/09/08
- Re: Structural regular expressions, David Kastrup, 2010/09/09
- Re: Structural regular expressions, Stefan Monnier, 2010/09/09
- Re: Structural regular expressions, David Kastrup, 2010/09/10
- Re: Structural regular expressions, Stefan Monnier, 2010/09/10
- Re: Structural regular expressions, Davis Herring, 2010/09/09
- Re: Structural regular expressions, Lennart Borgman, 2010/09/09
- Re: Structural regular expressions, Stefan Monnier, 2010/09/10
- Re: Structural regular expressions, Richard Stallman, 2010/09/10
- Re: Structural regular expressions, David House, 2010/09/10
- Message not available
- Re: Structural regular expressions,
Tom <=
- RE: Structural regular expressions, Drew Adams, 2010/09/10
- Re: Structural regular expressions, Miles Bader, 2010/09/10
- Re: Structural regular expressions, Tom, 2010/09/11
- Re: Structural regular expressions, Wojciech Meyer, 2010/09/11
- Re: Structural regular expressions, tomas, 2010/09/11
- RE: Structural regular expressions, Drew Adams, 2010/09/11
- Re: Structural regular expressions, Richard Stallman, 2010/09/11
- Re: Structural regular expressions, Stefan Monnier, 2010/09/12
- Re: Structural regular expressions, Lennart Borgman, 2010/09/12
- RE: Structural regular expressions, Drew Adams, 2010/09/12