From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Sean O'Rourke Newsgroups: gmane.emacs.devel Subject: Re: Mysterious fontification/C++ context issue - Patch for beginning-of-defun-raw. Date: Thu, 14 Dec 2006 22:31:37 -0800 Message-ID: References: NNTP-Posting-Host: dough.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: sea.gmane.org 1166164341 12445 80.91.229.10 (15 Dec 2006 06:32:21 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 15 Dec 2006 06:32:21 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Dec 15 07:32:20 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 1Gv6cD-0005HX-Sz for ged-emacs-devel@m.gmane.org; Fri, 15 Dec 2006 07:32:18 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Gv6cD-0003Iq-ER for ged-emacs-devel@m.gmane.org; Fri, 15 Dec 2006 01:32:17 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Gv6c2-0003Ig-JP for emacs-devel@gnu.org; Fri, 15 Dec 2006 01:32:06 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Gv6c0-0003HJ-Vx for emacs-devel@gnu.org; Fri, 15 Dec 2006 01:32:06 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Gv6c0-0003H4-SC for emacs-devel@gnu.org; Fri, 15 Dec 2006 01:32:04 -0500 Original-Received: from [80.91.229.2] (helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1Gv6c0-0004Uo-Ln for emacs-devel@gnu.org; Fri, 15 Dec 2006 01:32:04 -0500 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1Gv6br-00008C-7s for emacs-devel@gnu.org; Fri, 15 Dec 2006 07:31:55 +0100 Original-Received: from csegradus2.ucsd.edu ([132.239.95.209]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 15 Dec 2006 07:31:55 +0100 Original-Received: from sorourke by csegradus2.ucsd.edu with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 15 Dec 2006 07:31:55 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-To: emacs-devel@gnu.org Original-Lines: 78 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: csegradus2.ucsd.edu User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.91 (darwin) Cancel-Lock: sha1:C29MYkzMR5Jw7F8w33OJ9mPmLNI= 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:63754 Archived-At: --=-=-= Richard Stallman writes: > Should C mode do (setq beginning-of-defun-function > 'c-beginning-of-defun) Is there any reason that would be bad? As the code currently stands, this goes into infinite recursion when c-beginning-of-defun calls beginning-of-defun (likewise for end-of-defun{,-function}). I've fixed this locally by let-binding {beginning,end}-of-defun-function, which seems like a reasonable solution (attached). /s --=-=-= Content-Type: text/x-patch Content-Disposition: attachment Index: lisp.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/emacs-lisp/lisp.el,v retrieving revision 1.76 diff -u -r1.76 lisp.el --- lisp.el 7 Dec 2006 04:47:47 -0000 1.76 +++ lisp.el 15 Dec 2006 06:22:10 -0000 @@ -208,17 +208,18 @@ If variable `beginning-of-defun-function' is non-nil, its value is called as a function to find the defun's beginning." - (interactive "p") ; change this to "P", maybe, if we ever come to pass ARG - ; to beginning-of-defun-function. - (unless arg (setq arg 1)) ; The call might not be interactive. + (interactive "p") + (setq arg (or arg 1)) (cond - (beginning-of-defun-function - (if (> arg 0) - (dotimes (i arg) - (funcall beginning-of-defun-function)) - ;; Better not call end-of-defun-function directly, in case - ;; it's not defined. - (end-of-defun (- arg)))) + (beginning-of-defun-function + (let ((bodf beginning-of-defun-function) + beginning-of-defun-function) + (if (> (setq arg (or arg 1)) 0) + (dotimes (i arg) + (funcall bodf)) + ;; Better not call end-of-defun-function directly, in case + ;; it's not defined. + (end-of-defun (- arg))))) ((or defun-prompt-regexp open-paren-in-column-0-is-defun-start) (and (< arg 0) (not (eobp)) (forward-char 1)) @@ -297,12 +298,14 @@ (push-mark)) (if (or (null arg) (= arg 0)) (setq arg 1)) (if end-of-defun-function - (if (> arg 0) - (dotimes (i arg) - (funcall end-of-defun-function)) - ;; Better not call beginning-of-defun-function - ;; directly, in case it's not defined. - (beginning-of-defun (- arg))) + (let ((eodf end-of-defun-function) + end-of-defun-function) + (if (> arg 0) + (dotimes (i arg) + (funcall eodf)) + ;; Better not call beginning-of-defun-function + ;; directly, in case it's not defined. + (beginning-of-defun (- arg)))) (let ((first t)) (while (and (> arg 0) (< (point) (point-max))) (let ((pos (point))) --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel --=-=-=--