From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.devel Subject: Re: Mysterious fontification/C++ context issue - Patch for beginning-of-defun-raw. Date: Sat, 16 Dec 2006 11:17:55 +0100 Message-ID: <4583C7D3.1070703@gmx.at> References: <45768797.5010106@gmx.at> <87odqhj89q.fsf@stupidchicken.com> <20061210014526.GB3738@muc.de> <877ix0lfm8.fsf@furball.mit.edu> <20061210102249.GA1235@muc.de> <87d56rpk7a.fsf@stupidchicken.com> <20061213224009.GA1206@muc.de> <87odq72ssy.fsf@stupidchicken.com> <20061214084713.GA1333@muc.de> <45812BDF.5050107@gmx.at> NNTP-Posting-Host: dough.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1166264569 8265 80.91.229.10 (16 Dec 2006 10:22:49 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 16 Dec 2006 10:22:49 +0000 (UTC) Cc: Alan Mackenzie , Chong Yidong , Richard Stallman , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Dec 16 11:22:48 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by dough.gmane.org with esmtp (Exim 4.50) id 1GvWgl-0005or-3W for ged-emacs-devel@m.gmane.org; Sat, 16 Dec 2006 11:22:43 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GvWgk-0006EL-5Q for ged-emacs-devel@m.gmane.org; Sat, 16 Dec 2006 05:22:42 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GvWdb-0005I9-SH for emacs-devel@gnu.org; Sat, 16 Dec 2006 05:19:28 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GvWda-0005HT-QF for emacs-devel@gnu.org; Sat, 16 Dec 2006 05:19:27 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GvWda-0005HE-09 for emacs-devel@gnu.org; Sat, 16 Dec 2006 05:19:26 -0500 Original-Received: from [213.165.64.20] (helo=mail.gmx.net) by monty-python.gnu.org with smtp (Exim 4.52) id 1GvWdZ-0003t0-Mo for emacs-devel@gnu.org; Sat, 16 Dec 2006 05:19:26 -0500 Original-Received: (qmail invoked by alias); 16 Dec 2006 10:19:24 -0000 Original-Received: from N712P004.adsl.highway.telekom.at (EHLO [62.47.32.228]) [62.47.32.228] by mail.gmx.net (mp045) with SMTP; 16 Dec 2006 11:19:24 +0100 X-Authenticated: #14592706 User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: de-DE, de, en-us, en Original-To: Stefan Monnier In-Reply-To: X-Y-GMX-Trusted: 0 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:63828 Archived-At: >>M-> ran almost instantaneously before `beginning-of-defun-raw' changed. >>And you did fill CC Mode's cache already before the change. I could >>imagine it's because font-locking runs `beginning-of-defun' repeatedly >>for decreasing buffer positions and the `syntax-ppss' cache doesn't >>handle these cases optimally. > > > I thought "no, can't be, 'cause I was careful to treat this correctly", so > I went and measured it to give a clear proof of it, and much to my surprise > you seemed to be right: > > parse-partial-sexp on the whole buffer takes about 0.08 seconds on my laptop > (1.2GHz P-III M, maybe running at 800MHz at that time). syntax-ppss on that > same buffer takes about 0.24s (about 3 times slower: not great, but seemed > possible), but > > (syntax-ppss (point-max)) > (syntax-ppss (- (point-max) 2000)) > (syntax-ppss (- (point-max) 4000)) > > takes a good 1.8s which doesn't make any sense. I got approximately that far when I wrote the lines above. > After the shock (thinking, > god, I was wrong, how could that be?), I realized that these numbers didn't > make any sense. I simply felt puzzled and didn't dig any further. > And sure enough the problem was that in xdisp.c > syntax-begin-function is not nil but set to c-beginning-of-syntax which > doesn't make any sense: if you don't want to use a heuristic, then set the > damn thing to nil. > > This variable is set to c-beginning-of-defun in cc-mode.el via > font-lock-beginning-of-syntax-function which is set via font-lock-defaults. Does that mean we got the `_c_-beginning-of-defun' behavior through the back-door? All that code existed before the open-paren-... change. > - c-beginning-of-syntax > + nil Jumping to the end of xdisp.c still takes four seconds. I continue to feel puzzled. Note that Alan binds `syntax-begin-function' to nil in his `beginning-of-defun-raw' hence why should this have any impact in the first place? I must take another look in the basements of that.