[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: `looking-back' strange warning
From: |
Tassilo Horn |
Subject: |
Re: `looking-back' strange warning |
Date: |
Sat, 03 Oct 2015 08:26:05 +0200 |
User-agent: |
Gnus/5.130014 (Ma Gnus v0.14) Emacs/25.0.50 (gnu/linux) |
Drew Adams <drew.adams@oracle.com> writes:
>> This version is about 6 times faster in the t case and a still a bit
>> faster in the nil case where the char before point is already different
>> (which is the best case for your function).
>>
>> (defun chars-before (chars)
>> "Return non-nil if the literal string CHARS is right before point.
>> This is more efficient that `looking-back' for this use case."
>> (let ((beg (- (point) (length chars))))
>> (unless (< beg 0)
>> (save-excursion
>> (goto-char beg)
>> (looking-at (regexp-quote chars))))))
>
> OK. Good to know.
>
> See also bug #17284,
> http://debbugs.gnu.org/cgi/bugreport.cgi?bug=17284,
> where this has been discussed and I and others proposed
> code for this.
Martin's version is faster than mine, so no need to propose it.
> You are welcome to contribute to that (short) bug thread,
> or to otherwise try to get such a function added to Emacs.
I think that function is not really a viable drop-in replacement for
typical `looking-back' calls. The latter is most frequently used to
decide "am I behind some word or sequence of words, and I don't care
about whitespace?".
Bye,
Tassilo
- Re: `looking-back' strange warning, (continued)
- Re: `looking-back' strange warning, Andreas Röhler, 2015/10/08
- Re: `looking-back' strange warning, Dmitry Gutov, 2015/10/08
- Re: `looking-back' strange warning, Andreas Röhler, 2015/10/08
- Re: `looking-back' strange warning, Stefan Monnier, 2015/10/08
- Re: `looking-back' strange warning, Michael Heerdegen, 2015/10/08
- Re: `looking-back' strange warning, Michael Heerdegen, 2015/10/08
- RE: `looking-back' strange warning, Drew Adams, 2015/10/08
- RE: `looking-back' strange warning, Drew Adams, 2015/10/08
- Re: `looking-back' strange warning, Tassilo Horn, 2015/10/08
- RE: `looking-back' strange warning, Drew Adams, 2015/10/08
- Re: `looking-back' strange warning,
Tassilo Horn <=
- RE: `looking-back' strange warning, Drew Adams, 2015/10/08
- Re: `looking-back' strange warning, Andreas Röhler, 2015/10/08
- RE: `looking-back' strange warning, Drew Adams, 2015/10/08
- RE: `looking-back' strange warning, Drew Adams, 2015/10/08
- Re: `looking-back' strange warning, Andreas Röhler, 2015/10/08
- Re: `looking-back' strange warning, Michael Heerdegen, 2015/10/08
- Re: `looking-back' strange warning, Stefan Monnier, 2015/10/08
- RE: `looking-back' strange warning, Drew Adams, 2015/10/08
- Re: `looking-back' strange warning, Tom Tromey, 2015/10/08
- Re: `looking-back' strange warning, Stefan Monnier, 2015/10/08