From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: end-of-defun is fubsr. Date: Tue, 03 Feb 2009 15:50:36 -0500 Message-ID: References: <20090202202703.GB11077@muc.de> <20090203105035.GB1396@muc.de> <20090203122906.GC1396@muc.de> <20090203130028.GD1396@muc.de> <20090203160941.GE1396@muc.de> <20090203185812.GH1396@muc.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1233694633 11581 80.91.229.12 (3 Feb 2009 20:57:13 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 3 Feb 2009 20:57:13 +0000 (UTC) Cc: Miles Bader , emacs-devel@gnu.org To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Feb 03 21:58:27 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1LUSLc-0004Dh-GJ for ged-emacs-devel@m.gmane.org; Tue, 03 Feb 2009 21:58:21 +0100 Original-Received: from localhost ([127.0.0.1]:42684 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LUSKJ-0005rY-Fy for ged-emacs-devel@m.gmane.org; Tue, 03 Feb 2009 15:56:59 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LUSEL-0006pi-6R for emacs-devel@gnu.org; Tue, 03 Feb 2009 15:50:49 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LUSEI-0006ml-D5 for emacs-devel@gnu.org; Tue, 03 Feb 2009 15:50:47 -0500 Original-Received: from [199.232.76.173] (port=39811 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LUSEI-0006mX-4h for emacs-devel@gnu.org; Tue, 03 Feb 2009 15:50:46 -0500 Original-Received: from pruche.dit.umontreal.ca ([132.204.246.22]:40413) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LUSED-00046p-7E; Tue, 03 Feb 2009 15:50:41 -0500 Original-Received: from alfajor.home (vpn-132-204-232-163.acd.umontreal.ca [132.204.232.163]) by pruche.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id n13KpHcT028332; Tue, 3 Feb 2009 15:51:18 -0500 Original-Received: by alfajor.home (Postfix, from userid 20848) id 65C7BA22D1; Tue, 3 Feb 2009 15:50:36 -0500 (EST) In-Reply-To: <20090203185812.GH1396@muc.de> (Alan Mackenzie's message of "Tue, 3 Feb 2009 18:58:12 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV3203=0 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) 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:108703 Archived-At: >> It should only move from "right after the closing }" to BOL 7. >> Not "an arbitrary amount of whitespace". Of course, there might be > Sorry, yes, I was wrong. It moves at most one line forward. Yes, the code should be fixed to only move one line forward if it's necessary (i.e. if we're not yet at a line beginning). >> This might be linked to the above problem. For Elisp it seems to >> work correctly. I don't see this problem (actually in my tests, it seems to work fine in C mode as well). Can you provide a test case. > The problem is that end-of-defun calls beginning-of-defun-raw at each > iteration (over ARG). It thus discards the information as to whether > point began in a defun or between 2 defuns. I don't think so. Quite the opposite: it uses BOD and EOD to figure out whether we started inside a defun or between two defuns. Unless by "the problem" you're talking about the performance problem, in which case I understand that each time we call BOD (except for the first call), we know that we're "outside" of a defun (unless there's nesting, of course) but we don't tell that to BOD which may have to redo the work of figuring it out. > What's bugging the Hades out of me is that I've put a LOT of effort into > optimising c-\(beginning\|end\)-of-defun, and that's being rendered > completely useless, at least for C-M-e, by an inept way of calling these > functions. Several bug reports which made this work necessary came > directly from Emacs Developers (for example, C-x 4 a taking a minute to > run, or hassle with potential K&R regions taking just as long). None of the above invloved EOD as far as I can tell. These all do a single call to BOD. > Surely there's nobody here who isn't sick and fed up with this defun > movement business? Surely to goodness, after 25 years, we should be able > to do major-mode specific defun movement as a matter of course? Yes, it worked fine and fast in Emacs-21. I wasn't the one who insisted that we should scan the whole buffer just in order to make sure that we're not bumping into the super-rare case of K&R declaration. I'd *much* rather that C-mode's BOD gets it wrong every blue moon, rather than the current "let's parse the whole damn thing". On my 800MHz machine, C-mode is often borderline unusable nowadays. And it's not the fault of end-of-defun. > It's changed from "move to next end of function" to "move to the end of > the function at whose beginning we now are", Right. As you may notice, the second is a subset of the first (with a few caveats for nested functions, of course, but that shouldn't matter for C-mode), so if your implementation works for the first, it should work for the second as well. It's called backward compatibility. > and its default value is `forward-sexp'. `c-end-of-defun' was a good > fit for the variable as it formerly was, but is now > severely suboptimal. At most by a factor of 2. I.e. if it's slow now, it sure wasn't zippy before. >> Not sure about restoring the previous semantics. But I could agree to >> the additional ARG argument, which could even let it "take over" (so >> beginning-of-defun-raw is not called in that case). > :-) Let's do it! I knew you'd like it. >> > 3/- end-of-defun should be restructured along the lines of >> > beginning-of-defun. >> I don't think that's a good idea. The main reason is to deal with >> languages that allow nested functions. > Don't follow - In the upcoming CC Mode 5.32 code (in the CVS repository > at SourceForge), C-M-[ae] works just fine for C++ defuns nested inside > classes/namespaces and so on. The mechanism is entirely within CC Mode. Yes, but I maintain Emacs, not CC-mode, so I care to move the functionality to the generic code so that all modes (not just CC-modes) benefit. Stefan