From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.cc-mode.general,gmane.emacs.devel Subject: Re: CC Mode 5.31.3 Date: Fri, 24 Feb 2006 22:04:03 +0000 (GMT) Message-ID: References: Reply-To: Alan Mackenzie NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: sea.gmane.org 1140818416 13336 80.91.229.2 (24 Feb 2006 22:00:16 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 24 Feb 2006 22:00:16 +0000 (UTC) Cc: cc-mode-help@lists.sourceforge.net, emacs-devel@gnu.org Original-X-From: cc-mode-help-admin@lists.sourceforge.net Fri Feb 24 23:00:11 2006 Return-path: Envelope-to: sf-cc-mode-help@m.gmane.org Original-Received: from lists-outbound.sourceforge.net ([66.35.250.225]) by ciao.gmane.org with esmtp (Exim 4.43) id 1FCkys-0002AO-JT for sf-cc-mode-help@m.gmane.org; Fri, 24 Feb 2006 23:00:07 +0100 Original-Received: from sc8-sf-list1-b.sourceforge.net (sc8-sf-list1-b.sourceforge.net [10.3.1.7]) by sc8-sf-spam1.sourceforge.net (Postfix) with ESMTP id 91DF48D1ED; Fri, 24 Feb 2006 14:00:05 -0800 (PST) Original-Received: from sc8-sf-mx1-b.sourceforge.net ([10.3.1.91] helo=mail.sourceforge.net) by sc8-sf-list1.sourceforge.net with esmtp (Exim 4.30) id 1FCkyE-0003ZI-Sg for cc-mode-help@lists.sourceforge.net; Fri, 24 Feb 2006 13:59:26 -0800 Original-Received: from acm.muc.de ([193.149.49.134] helo=acm.acm ident=root) by mail.sourceforge.net with esmtp (Exim 4.44) id 1FCkyD-0003Fr-GH for cc-mode-help@lists.sourceforge.net; Fri, 24 Feb 2006 13:59:27 -0800 Original-Received: from localhost (root@localhost) by acm.acm (8.8.8/8.8.8) with SMTP id WAA00414; Fri, 24 Feb 2006 22:04:04 GMT X-Sender: root@acm.acm Original-To: "Sean O'Rourke" In-Reply-To: X-Spam-Score: 1.0 (+) X-Spam-Report: Spam Filtering performed by sourceforge.net. See http://spamassassin.org/tag/ for more details. Report problems to http://sf.net/tracker/?func=add&group_id=1&atid=200001 1.0 FORGED_RCVD_HELO Received: contains a forged HELO Original-Sender: cc-mode-help-admin@lists.sourceforge.net Errors-To: cc-mode-help-admin@lists.sourceforge.net X-BeenThere: cc-mode-help@lists.sourceforge.net X-Mailman-Version: 2.0.9-sf.net Precedence: bulk List-Unsubscribe: , List-Id: Bug reports, feature requests, and general talk about CC Mode. List-Post: List-Help: List-Subscribe: , List-Archive: X-Original-Date: Fri, 24 Feb 2006 22:04:03 +0000 (GMT) Xref: news.gmane.org gmane.emacs.cc-mode.general:3077 gmane.emacs.devel:50904 Archived-At: On Fri, 24 Feb 2006, Sean O'Rourke wrote: >Alan Mackenzie writes: >> As agreed with RMS, C-M-[ae] should be be bound to >> c-\(beginning\|end\)-of-defun by default, rather than the standard >> commands \(beginning\|end\)-of-defun. These two CC Mode commands could >> do with some optimisation, but this seems optional rather than necessary. >> This is still to do. However, it is trivial, involving only drudge work, >> mostly in the manual. It should be there in 5.31.4. >Have you thought instead of mode-locally setting >{beginning,end}-of-defun-function? This way, other commands like >mark-defun that operate on functions automatically pick up the >language-specific versions. \(beginning\|end\)-of-defun-function can't get a prefix argument. In Emacs 22, this is mitigated by calling the function in a loop. However, in other (X)Emacsen, the numeric argument is simply discarded, so to use [be]-o-d-f would mean testing for the existence of this loop, then binding key sequences one of two ways. It's doable, but it's hassle. The other problem is that the opportunity for optimisation would go out the window: c-beginning-of-defun essentially moves back to the outermost brace (very rapid operation) then gropes backwards to the start of the function header (slow operation involving lengthy analysis). The easiest optimisation with (c-beginning-of-defun 10) involves skipping back 10 brace blocks and only then finding the start of the header. C-M-h isn't a problem in CC Mode, because it's bound to c-mark-function. However, if mark-defun is called from a lisp function, that would be a problem. Hmmm. Surely I should be setting \(beginning\|end\)-of-defun-function AS WELL AS (not instead of) binding C-M-[aeh]? >I have been using this setting for >about a year without any problems after making the attached >trivial patch, which prevents infinite recursion when >beginning-of-defun-function itself calls beginning-of-defun. Hee hee! Good point. I think your patch should be installed right now. Index: lisp.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/emacs-lisp/lisp.el,v retrieving revision 1.74 diff -p -u -w -u -r1.74 lisp.el --- lisp.el 6 Feb 2006 12:20:06 -0000 1.74 +++ lisp.el 24 Feb 2006 18:44:26 -0000 @@ -210,12 +210,14 @@ If variable `beginning-of-defun-function is called as a function to find the defun's beginning." (interactive "p") (if beginning-of-defun-function + (let ((bodf beginning-of-defun-function) + (beginning-of-defun-function nil)) (if (> (setq arg (or arg 1)) 0) (dotimes (i arg) - (funcall beginning-of-defun-function)) + (funcall bodf)) ;; Better not call end-of-defun-function directly, in case ;; it's not defined. - (end-of-defun (- arg))) + (end-of-defun (- arg)))) (and arg (< arg 0) (not (eobp)) (forward-char 1)) (and (re-search-backward (if defun-prompt-regexp (concat (if open-paren-in-column-0-is-defun-start @@ -255,12 +257,14 @@ is called as a function to find the defu (push-mark)) (if (or (null arg) (= arg 0)) (setq arg 1)) (if end-of-defun-function + (let ((eodf end-of-defun-function) + (end-of-defun-function nil)) (if (> arg 0) (dotimes (i arg) - (funcall end-of-defun-function)) + (funcall eodf)) ;; Better not call beginning-of-defun-function ;; directly, in case it's not defined. - (beginning-of-defun (- arg))) + (beginning-of-defun (- arg)))) (let ((first t)) (while (and (> arg 0) (< (point) (point-max))) (let ((pos (point))) -- Alan Mackenzie (Munich, Germany) ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642