aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman2004-01-29 17:56:42 +0000
committerRichard M. Stallman2004-01-29 17:56:42 +0000
commit750e563f99c53f42392134c78148ca61bbc968c7 (patch)
tree39c0f0cd4da36e99894f6e1499a2a0f85fb2292a
parent40f8257f08b9825b9f86bbfb1f313cdeee3eab49 (diff)
downloademacs-750e563f99c53f42392134c78148ca61bbc968c7.tar.gz
emacs-750e563f99c53f42392134c78148ca61bbc968c7.zip
(beginning-of-defun-raw, end-of-defun):
Iterate the hook function if arg is given. (mark-defun, narrow-to-defun): Change order of finding the limits.
-rw-r--r--lisp/emacs-lisp/lisp.el25
1 files changed, 17 insertions, 8 deletions
diff --git a/lisp/emacs-lisp/lisp.el b/lisp/emacs-lisp/lisp.el
index 7f059d3f99f..4d90abd9f4e 100644
--- a/lisp/emacs-lisp/lisp.el
+++ b/lisp/emacs-lisp/lisp.el
@@ -188,7 +188,8 @@ If variable `beginning-of-defun-function' is non-nil, its value
188is called as a function to find the defun's beginning." 188is called as a function to find the defun's beginning."
189 (interactive "p") 189 (interactive "p")
190 (if beginning-of-defun-function 190 (if beginning-of-defun-function
191 (funcall beginning-of-defun-function) 191 (dotimes (i (or arg 1))
192 (funcall beginning-of-defun-function))
192 (and arg (< arg 0) (not (eobp)) (forward-char 1)) 193 (and arg (< arg 0) (not (eobp)) (forward-char 1))
193 (and (re-search-backward (if defun-prompt-regexp 194 (and (re-search-backward (if defun-prompt-regexp
194 (concat (if open-paren-in-column-0-is-defun-start 195 (concat (if open-paren-in-column-0-is-defun-start
@@ -219,7 +220,8 @@ If variable `end-of-defun-function' is non-nil, its value
219is called as a function to find the defun's end." 220is called as a function to find the defun's end."
220 (interactive "p") 221 (interactive "p")
221 (if end-of-defun-function 222 (if end-of-defun-function
222 (funcall end-of-defun-function) 223 (dotimes (i (or arg 1))
224 (funcall end-of-defun-function))
223 (if (or (null arg) (= arg 0)) (setq arg 1)) 225 (if (or (null arg) (= arg 0)) (setq arg 1))
224 (let ((first t)) 226 (let ((first t))
225 (while (and (> arg 0) (< (point) (point-max))) 227 (while (and (> arg 0) (< (point) (point-max)))
@@ -267,10 +269,14 @@ already marked."
267 (end-of-defun) 269 (end-of-defun)
268 (point)))) 270 (point))))
269 (t 271 (t
272 ;; Do it in this order for the sake of languages with nested
273 ;; functions where several can end at the same place as with
274 ;; the offside rule, e.g. Python.
270 (push-mark (point)) 275 (push-mark (point))
271 (end-of-defun)
272 (push-mark (point) nil t)
273 (beginning-of-defun) 276 (beginning-of-defun)
277 (push-mark (point) nil t)
278 (end-of-defun)
279 (exchange-point-and-mark)
274 (re-search-backward "^\n" (- (point) 1) t)))) 280 (re-search-backward "^\n" (- (point) 1) t))))
275 281
276(defun narrow-to-defun (&optional arg) 282(defun narrow-to-defun (&optional arg)
@@ -280,10 +286,13 @@ Optional ARG is ignored."
280 (interactive) 286 (interactive)
281 (save-excursion 287 (save-excursion
282 (widen) 288 (widen)
283 (end-of-defun) 289 ;; Do it in this order for the sake of languages with nested
284 (let ((end (point))) 290 ;; functions where several can end at the same place as with the
285 (beginning-of-defun) 291 ;; offside rule, e.g. Python.
286 (narrow-to-region (point) end)))) 292 (beginning-of-defun)
293 (let ((beg (point)))
294 (end-of-defun)
295 (narrow-to-region beg (point)))))
287 296
288(defun insert-parentheses (arg) 297(defun insert-parentheses (arg)
289 "Enclose following ARG sexps in parentheses. Leave point after open-paren. 298 "Enclose following ARG sexps in parentheses. Leave point after open-paren.