emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] Changes to emacs/lisp/emacs-lisp/lisp.el,v


From: Stefan Monnier
Subject: [Emacs-diffs] Changes to emacs/lisp/emacs-lisp/lisp.el,v
Date: Thu, 22 Nov 2007 22:12:23 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Changes by:     Stefan Monnier <monnier>        07/11/22 22:12:22

Index: lisp/emacs-lisp/lisp.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/emacs-lisp/lisp.el,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -b -r1.80 -r1.81
--- lisp/emacs-lisp/lisp.el     26 Jul 2007 05:26:47 -0000      1.80
+++ lisp/emacs-lisp/lisp.el     22 Nov 2007 22:12:20 -0000      1.81
@@ -175,9 +175,10 @@
 if defining `defun-prompt-regexp' is not sufficient to handle the mode's
 needs.
 
-The function (of no args) should go to the line on which the current
-defun starts, and return non-nil, or should return nil if it can't
-find the beginning.")
+The function takes the same argument as `beginning-of-defun' and should
+behave similarly, returning non-nil if it found the beginning of a defun.
+Ideally it should move to a point right before an open-paren which encloses
+the body of the defun.")
 
 (defun beginning-of-defun (&optional arg)
   "Move backward to the beginning of a defun.
@@ -218,12 +219,22 @@
   (unless arg (setq arg 1))
   (cond
    (beginning-of-defun-function
+    (condition-case nil
+        (funcall beginning-of-defun-function arg)
+      ;; We used to define beginning-of-defun-function as taking no argument
+      ;; but that makes it impossible to implement correct forward motion:
+      ;; we used to use end-of-defun for that, but it's not supposed to do
+      ;; the same thing (it moves to the end of a defun not to the beginning
+      ;; of the next).
+      ;; In case the beginning-of-defun-function uses the old calling
+      ;; convention, fallback on the old implementation.
+      (wrong-number-of-arguments
     (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))))
+         (end-of-defun (- arg))))))
 
    ((or defun-prompt-regexp open-paren-in-column-0-is-defun-start)
     (and (< arg 0) (not (eobp)) (forward-char 1))




reply via email to

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