From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?ISO-8859-15?Q?Andreas_R=F6hler?= Newsgroups: gmane.emacs.help Subject: Re: `looking-back' strange warning Date: Sat, 03 Oct 2015 08:45:48 +0200 Message-ID: <560F799C.1010903@easy-emacs.de> References: <560B9C7F.2060301@easy-emacs.de> <560CD7CE.4010404@yandex.ru> <6524c81a-949c-40d1-b990-d214d6ee5b60@default> <560D73DF.8040403@yandex.ru> <560D7A68.8040404@easy-emacs.de> <560D8289.6010409@yandex.ru> <560D8F96.5040200@easy-emacs.de> <877fn66pag.fsf@web.de> <190e27a5-9099-45ce-a8db-a314b9e32b35@default> <87lhblrnpe.fsf@gnu.org> <785d8be4-1024-4635-83ff-7bc51dd4b5bf@default> <87bncgii2q.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1443854793 2970 80.91.229.3 (3 Oct 2015 06:46:33 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 3 Oct 2015 06:46:33 +0000 (UTC) Cc: Tassilo Horn To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Oct 03 08:46:22 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZiGaL-0001St-OM for geh-help-gnu-emacs@m.gmane.org; Sat, 03 Oct 2015 08:46:22 +0200 Original-Received: from localhost ([::1]:37185 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZiGaK-0003pA-Kq for geh-help-gnu-emacs@m.gmane.org; Sat, 03 Oct 2015 02:46:20 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58316) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZiGa8-0003oy-SC for help-gnu-emacs@gnu.org; Sat, 03 Oct 2015 02:46:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZiGa3-0007pg-ST for help-gnu-emacs@gnu.org; Sat, 03 Oct 2015 02:46:08 -0400 Original-Received: from mout.kundenserver.de ([212.227.126.131]:49249) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZiGa3-0007pc-LW; Sat, 03 Oct 2015 02:46:03 -0400 Original-Received: from [192.168.178.31] ([77.12.8.131]) by mrelayeu.kundenserver.de (mreue001) with ESMTPSA (Nemesis) id 0MXRDB-1aBZZE3CtB-00WCUQ; Sat, 03 Oct 2015 08:46:01 +0200 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 In-Reply-To: <87bncgii2q.fsf@gnu.org> X-Provags-ID: V03:K0:zmcmrwVO8i1CrsuS6RvVm4PWPPeS0n0Cwnj5f5jgwcVk/FbDhWL mJvXUhUfHG4IAh3MQhfGLImHGtYdkFXsqpFgsl2u4OQ0IAD9vhOkD/IZbboV++uAfBcT68e TjnneSVzezqTNCry29ZXk4FP/Sp9AlTi66D8ms3nXY6sW/FewMVWBoA1ui7l0iXpz2UI7V1 OKFIkR5Hcpav87bEEgy3A== X-UI-Out-Filterresults: notjunk:1;V01:K0:JeEzA76X+cE=:CR+mmXTnixE+JY03E/Dphu dovn40lKNlmPPDLP82zfbJm6YgPrEV/L//Wk6e38tP7RZpxi+N9lRcoI54l48a2jDMz/NJduC 3IaXtAWXvdD1VyRHozEV431fF120jxRQy3WTkbCb7tlJuoVREGn4NPu+UFmCfTaYcHJvkvWqu L+wjYbERnBRswFeFSt07Z4wKXWX/flgUqHmxFtFkIVt0LL3i8yVejtMj6kk3OL9G/xhkGP8L7 EUMk6QLs9fUFrc+lNhMESrk66aoJD4n7J+Egpliav+Uqqafsqt53PXLZcSi8e7z37JUhcbQCR X/HvStaLCM8fTmweAsfrPpV0xgv57A1YAcSekbFpEu6DQPaa+2iWA0paZzQHJXWSUzwn2yUDe QHtMtt8xqt6S9v0wwMT0uSr66L1IOnustmgUuMxGRJVlDWSFqpqM7GlDYV4q36ijF2Pq3PV1V NB+ogP9DGzIN8BHJicyq3KGXmcIyK3PKRhRhpw/qnpCqbAO7SHwGTt+aIEutjwJgfQ5tbscbo PZ0+NeSBcihnxio6Z/C/xgkUsytR7toBhIQuuf3yc8RpCRZGPBiEjAcRCDnFPEX8mfIIQ+GB7 paSTmlZ0w32L/jHW4CyOgA0Ab8VJTuLQFlk7szpAGnWRiHqLIukTkxsA9256apu5N2x6mBjQD FE6iFTWXFLeOByVzEojWROzCR0rCf4PeRdnTJmezto5PKYD6JXcKoEFOV2pxY3LaUpJDZYDUg ET0CYrA1xneILFrYRt3531myBBrNNlLMWqvG/clui8X0nFKyAK7Z71I0ya+6d3pIKTx4z0CN X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.126.131 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:107494 Archived-At: Am 03.10.2015 um 08:26 schrieb Tassilo Horn: > Drew Adams 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 > Just for fun: (defun looking-back-string (string) "Return non-nil if the literal STRING is right before point. This is more efficient that `looking-back' for this use case." (string= string (ignore-errors (buffer-substring-no-properties (- (point) (length string)) (point)))))