[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Select Text Inside Parentheses
From: |
Drew Adams |
Subject: |
RE: Select Text Inside Parentheses |
Date: |
Sat, 1 Sep 2012 18:01:40 -0700 |
> > "(\\(\s-\\|[\n]\\)*\\(.+\\)\\(\s-\\|[\n]\\)*)" nil t)
>
> This is supposed to be
> "(\\(\\s-\\|[\n]\\)*\\(.+\\)\\(\\s-\\|[\n]\\)*)" nil t)
> , right?
Right, sorry. I showed it correctly (\\s-, not \s-) in the detailed rundown
that followed.
> > (goto-char (match-beginning 2))
> > (push-mark nil 'nomsg 'activate)
> > (goto-char (match-end 2))
> > (setq deactivate-mark nil)))
>
> This doesn't seem to do anything.
Did you try with \\s- instead of \s-?
What that code, which you say does nothing, does is to set the mark where the
2nd subgroup-match starts, then move point to where the 2nd subgroup-match ends,
then ensure that the mark remains active after the command.
> nothing seems to happen when I run this code.
> No selection is made.
Works for me. Be sure you corrected the typo from \s- to \\s-.
And be sure you have `transient-mark-mode' turned on.
But again, this is not a real parsing of lists, so there is no treatment of,
say, nested lists. The \\S-+ matches any non-whitespace chars, including ( and
). So using it on (foo (bar))) selects "foo (bar))": everything between the
first ( and the last ).
If you want to handle lists correctly (e.g. nesting) then use the Elisp
functions for traversing or parsing lists/sexps.
And as I say, perhaps someone else will help you more, or differently.
Re: Select Text Inside Parentheses, Andreas Röhler, 2012/09/04