emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] emacs/lisp ChangeLog emacs-lisp/lisp.el


From: Stefan Monnier
Subject: [Emacs-diffs] emacs/lisp ChangeLog emacs-lisp/lisp.el
Date: Thu, 12 Feb 2009 04:31:04 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Changes by:     Stefan Monnier <monnier>        09/02/12 04:31:03

Modified files:
        lisp           : ChangeLog 
        lisp/emacs-lisp: lisp.el 

Log message:
        (end-of-defun): Rewrite, to use the ARG argument to 
beginning-of-defun-raw.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/ChangeLog?cvsroot=emacs&r1=1.15306&r2=1.15307
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/emacs-lisp/lisp.el?cvsroot=emacs&r1=1.96&r2=1.97

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/emacs/emacs/lisp/ChangeLog,v
retrieving revision 1.15306
retrieving revision 1.15307
diff -u -b -r1.15306 -r1.15307
--- ChangeLog   12 Feb 2009 04:16:14 -0000      1.15306
+++ ChangeLog   12 Feb 2009 04:31:01 -0000      1.15307
@@ -1,5 +1,8 @@
 2009-02-12  Stefan Monnier  <address@hidden>
 
+       * emacs-lisp/lisp.el (end-of-defun): Rewrite, to use the ARG argument
+       to beginning-of-defun-raw.
+
        * emacs-lisp/lisp.el (end-of-defun): Don't skip to next line after
        calling end-of-defun-function if it already moved to BOL.
 

Index: emacs-lisp/lisp.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/emacs-lisp/lisp.el,v
retrieving revision 1.96
retrieving revision 1.97
diff -u -b -r1.96 -r1.97
--- emacs-lisp/lisp.el  12 Feb 2009 04:16:17 -0000      1.96
+++ emacs-lisp/lisp.el  12 Feb 2009 04:31:03 -0000      1.97
@@ -341,50 +341,36 @@
       (and transient-mark-mode mark-active)
       (push-mark))
   (if (or (null arg) (= arg 0)) (setq arg 1))
-  (while (> arg 0)
     (let ((pos (point))
-         retry-point)
-      (end-of-line 1)
-      (beginning-of-defun-raw 1)
-      (while (unless (eobp)
+        (beg (progn (end-of-line 1) (beginning-of-defun-raw 1) (point))))
                (funcall end-of-defun-function)
+    (cond
+     ((> arg 0)
+      ;; Moving forward.
+      (if (> (point) pos)
+          ;; We already moved forward by one because we started from
+          ;; within a function.
+          (setq arg (1- arg))
+        ;; We started from after the end of the previous function.
+        (goto-char pos))
+      (unless (zerop arg)
+        (beginning-of-defun-raw (- arg))
+        (funcall end-of-defun-function)))
+     ((< arg 0)
+      ;; Moving backward.
+      (if (< (point) pos)
+          ;; We already moved backward because we started from between
+          ;; two functions.
+          (setq arg (1+ arg))
+        ;; We started from inside a function.
+        (goto-char beg))
+      (unless (zerop arg)
+        (beginning-of-defun-raw (- arg))
+        (funcall end-of-defun-function))))
                (unless (bolp)
                  (skip-chars-forward " \t")
                  (if (looking-at "\\s<\\|\n")
-                     (forward-line 1)))
-               ;; If we started after the end of the previous
-               ;; function, try again with the next one.
-               (unless (or (> (point) pos)
-                          (eq (point) retry-point))
-                (or (bobp) (forward-char -1))
-                (beginning-of-defun-raw -1)
-                (setq retry-point (point)))))
-      ;; Ensure that we move forward.
-      (when (< (point) pos)
-       (goto-char pos)))
-    (setq arg (1- arg)))
-  (while (< arg 0)
-    (let ((pos (point)))
-      (while (unless (bobp)
-               (beginning-of-line 1)
-               (beginning-of-defun-raw 1)
-               (let ((beg (point))
-                    retry-point)
-                 (funcall end-of-defun-function)
-                 (unless (bolp)
-                   (skip-chars-forward " \t")
-                   (if (looking-at "\\s<\\|\n")
-                       (forward-line 1)))
-                 ;; If we started from within the function just found,
-                 ;; try again with the previous one.
-                 (unless (or (< (point) pos)
-                            (eq (point) retry-point))
-                   (goto-char beg)
-                   (setq retry-point (point))))))
-      ;; Ensure that we move backward.
-      (when (> (point) pos)
-       (goto-char pos)))
-    (setq arg (1+ arg))))
+          (forward-line 1)))))
 
 (defun mark-defun (&optional allow-extend)
   "Put mark at end of this defun, point at beginning.




reply via email to

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