emacs-pretest-bug
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

calling {beginning,end}-of-defun-function


From: Dave Love
Subject: calling {beginning,end}-of-defun-function
Date: Mon, 05 Apr 2004 14:42:37 +0100
User-agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.2 (gnu/linux)

It may be my fault that correct processing of ARG isn't done when
calling the hook functions.  Please check I have the logic right in
this patch.

2004-04-05  Dave Love  <address@hidden>

        * emacs-lisp/lisp.el (beginning-of-defun-raw, end-of-defun): Fix
        calling hook function.

Index: emacs-lisp/lisp.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/emacs-lisp/lisp.el,v
retrieving revision 1.51
diff -u -p -r1.51 lisp.el
--- emacs-lisp/lisp.el  29 Jan 2004 17:56:42 -0000      1.51
+++ emacs-lisp/lisp.el  5 Apr 2004 13:35:29 -0000
@@ -188,8 +188,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
-      (dotimes (i (or arg 1))
-       (funcall beginning-of-defun-function))
+      (progn
+       (setq arg (or arg 1))
+       (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))))
     (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
@@ -219,10 +225,14 @@ matches the open-parenthesis that starts
 If variable `end-of-defun-function' is non-nil, its value
 is called as a function to find the defun's end."
   (interactive "p")
+  (if (or (null arg) (= arg 0)) (setq arg 1))
   (if end-of-defun-function
-      (dotimes (i (or arg 1))
-       (funcall end-of-defun-function))
-    (if (or (null arg) (= arg 0)) (setq arg 1))
+      (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 ((first t))
       (while (and (> arg 0) (< (point) (point-max)))
        (let ((pos (point)) npos)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]