help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: `looking-back' strange warning


From: Drew Adams
Subject: RE: `looking-back' strange warning
Date: Fri, 2 Oct 2015 14:35:03 -0700 (PDT)

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

You are welcome to contribute to that (short) bug thread,
or to otherwise try to get such a function added to Emacs.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]