unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Tassilo Horn <tsdh@gnu.org>
To: "Andreas Röhler" <andreas.roehler@easy-emacs.de>
Cc: help-gnu-emacs <help-gnu-emacs@gnu.org>, Dmitry Gutov <dgutov@yandex.ru>
Subject: Re: `looking-back' strange warning
Date: Thu, 01 Oct 2015 11:29:36 +0200	[thread overview]
Message-ID: <874mibhr7j.fsf@gnu.org> (raw)
In-Reply-To: <560CF2F2.1060601@easy-emacs.de> ("Andreas \=\?utf-8\?Q\?R\=C3\=B6h\?\= \=\?utf-8\?Q\?ler\=22's\?\= message of "Thu, 01 Oct 2015 10:46:42 +0200")

Andreas Röhler <andreas.roehler@easy-emacs.de> writes:

>>>>> Docu bug?
>>>> It's a feature: calling `looking-back' without LIMIT is slow, don't do that.
>>> Hmm, would volontier to make that fast instead - if write-permission
>>> is given :)
>> Looking at the code, I'd say `looking-back' is only slow if GREEDY is t
>> in which case the start of the match may be before LIMIT anyhow.  So I
>> don't see how providing a LIMIT would help too much, or is
>> `re-search-backward' already slow without LIMIT?
>
> AFAIK thats it.
>
> Also "greedy" seems not to work at all:
>
> (defun foo3 ())
>
> (progn (re-search-backward "o+" nil t 3)
>        (message "%s" (match-beginning 0)))
>
> The first "o" is reported as match-beginning.

Is it intended that you don't use `looking-back' here?

But you are right that in the situation above, a string like "foo3"
should account for only one single match because the greedy regex "o+"
is allowed to consume any number of consecutive os.  But that doesn't
seem to work for backward searches, and that's probably the cause for
the weird extension mechanism in the greedy case for `looking-back'.

Well, it works fine with forward searches:

(progn (re-search-forward "fo+?" nil t)   ;non-greedy
       ;; (re-search-forward "fo+" nil t) ;greedy
       (message "%s %s" (match-beginning 0) (match-end 0)))

(defun fooooo4 ())
       ^ ^   ^
       | |   `--- end: greedy
       | `------- end: non-greedy
       `--------- beginning

Bye,
Tassilo



  reply	other threads:[~2015-10-01  9:29 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-30  8:25 `looking-back' strange warning Andreas Röhler
2015-10-01  6:20 ` Michael Heerdegen
2015-10-01  6:25 ` Tassilo Horn
2015-10-01  6:50 ` Dmitry Gutov
2015-10-01  7:49   ` Andreas Röhler
2015-10-01  8:20     ` Tassilo Horn
2015-10-01  8:46       ` Andreas Röhler
2015-10-01  9:29         ` Tassilo Horn [this message]
2015-10-02  0:10       ` Stefan Monnier
2015-10-02 15:21         ` Tassilo Horn
2015-10-01 16:00   ` Drew Adams
2015-10-01 17:56     ` Dmitry Gutov
2015-10-01 18:24       ` Andreas Röhler
2015-10-01 18:59         ` Dmitry Gutov
2015-10-01 19:55           ` Andreas Röhler
2015-10-01 20:26             ` Dmitry Gutov
2015-10-02  0:15             ` Stefan Monnier
2015-10-02  1:18               ` Michael Heerdegen
2015-10-02  5:13                 ` Drew Adams
2015-10-02 20:28                   ` Drew Adams
2015-10-02 20:59                     ` Tassilo Horn
2015-10-02 21:35                       ` Drew Adams
2015-10-03  6:26                         ` Tassilo Horn
2015-10-03  6:45                           ` Andreas Röhler
2015-10-03 15:20                             ` Drew Adams
2015-10-03 15:17                           ` Drew Adams
2015-10-02  1:19               ` Michael Heerdegen
2015-10-02  5:12               ` Drew Adams
2015-10-02  6:16                 ` Andreas Röhler
2015-10-02  6:36                   ` Michael Heerdegen
2015-10-02 12:46                 ` Stefan Monnier
2015-10-02 15:02                   ` Drew Adams
2015-10-02 19:08               ` Tom Tromey
2015-10-02 19:33                 ` Stefan Monnier
2015-10-03 18:11                   ` Stefan Monnier
     [not found]   ` <mailman.176.1443721449.16064.help-gnu-emacs@gnu.org>
2015-10-01 18:50     ` Barry Margolin
     [not found]     ` <<barmar-D40496.14502501102015@88-209-239-213.giganet.hu>
2015-10-01 23:42       ` Drew Adams
2015-10-02  0:12         ` Stefan Monnier
2015-10-02  5:10           ` Drew Adams
2015-10-02 12:48             ` Stefan Monnier
2015-10-02 15:03               ` Drew Adams
2015-10-02 15:21                 ` Stefan Monnier
2015-10-02 15:24                   ` Drew Adams
2015-10-02 19:28                     ` Stefan Monnier
2015-10-01 12:35 ` Artur Malabarba
     [not found] <<560B9C7F.2060301@easy-emacs.de>

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=874mibhr7j.fsf@gnu.org \
    --to=tsdh@gnu.org \
    --cc=andreas.roehler@easy-emacs.de \
    --cc=dgutov@yandex.ru \
    --cc=help-gnu-emacs@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.
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).