Mercurial > emacs
comparison lisp/emacs-lisp/lisp.el @ 86353:480a058ecb2f
(beginning-of-defun-raw): Pass `arg' down to beginning-of-defun-function.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Thu, 22 Nov 2007 22:12:22 +0000 |
parents | 935157c0b596 |
children | ebd4b500132c |
comparison
equal
deleted
inserted
replaced
86352:8121805fdbcb | 86353:480a058ecb2f |
---|---|
173 This is used to find the beginning of the defun instead of using the | 173 This is used to find the beginning of the defun instead of using the |
174 normal recipe (see `beginning-of-defun'). Major modes can define this | 174 normal recipe (see `beginning-of-defun'). Major modes can define this |
175 if defining `defun-prompt-regexp' is not sufficient to handle the mode's | 175 if defining `defun-prompt-regexp' is not sufficient to handle the mode's |
176 needs. | 176 needs. |
177 | 177 |
178 The function (of no args) should go to the line on which the current | 178 The function takes the same argument as `beginning-of-defun' and should |
179 defun starts, and return non-nil, or should return nil if it can't | 179 behave similarly, returning non-nil if it found the beginning of a defun. |
180 find the beginning.") | 180 Ideally it should move to a point right before an open-paren which encloses |
181 the body of the defun.") | |
181 | 182 |
182 (defun beginning-of-defun (&optional arg) | 183 (defun beginning-of-defun (&optional arg) |
183 "Move backward to the beginning of a defun. | 184 "Move backward to the beginning of a defun. |
184 With ARG, do it that many times. Negative arg -N | 185 With ARG, do it that many times. Negative arg -N |
185 means move forward to Nth following beginning of defun. | 186 means move forward to Nth following beginning of defun. |
216 (interactive "p") ; change this to "P", maybe, if we ever come to pass ARG | 217 (interactive "p") ; change this to "P", maybe, if we ever come to pass ARG |
217 ; to beginning-of-defun-function. | 218 ; to beginning-of-defun-function. |
218 (unless arg (setq arg 1)) | 219 (unless arg (setq arg 1)) |
219 (cond | 220 (cond |
220 (beginning-of-defun-function | 221 (beginning-of-defun-function |
221 (if (> arg 0) | 222 (condition-case nil |
222 (dotimes (i arg) | 223 (funcall beginning-of-defun-function arg) |
223 (funcall beginning-of-defun-function)) | 224 ;; We used to define beginning-of-defun-function as taking no argument |
224 ;; Better not call end-of-defun-function directly, in case | 225 ;; but that makes it impossible to implement correct forward motion: |
225 ;; it's not defined. | 226 ;; we used to use end-of-defun for that, but it's not supposed to do |
226 (end-of-defun (- arg)))) | 227 ;; the same thing (it moves to the end of a defun not to the beginning |
228 ;; of the next). | |
229 ;; In case the beginning-of-defun-function uses the old calling | |
230 ;; convention, fallback on the old implementation. | |
231 (wrong-number-of-arguments | |
232 (if (> arg 0) | |
233 (dotimes (i arg) | |
234 (funcall beginning-of-defun-function)) | |
235 ;; Better not call end-of-defun-function directly, in case | |
236 ;; it's not defined. | |
237 (end-of-defun (- arg)))))) | |
227 | 238 |
228 ((or defun-prompt-regexp open-paren-in-column-0-is-defun-start) | 239 ((or defun-prompt-regexp open-paren-in-column-0-is-defun-start) |
229 (and (< arg 0) (not (eobp)) (forward-char 1)) | 240 (and (< arg 0) (not (eobp)) (forward-char 1)) |
230 (and (re-search-backward (if defun-prompt-regexp | 241 (and (re-search-backward (if defun-prompt-regexp |
231 (concat (if open-paren-in-column-0-is-defun-start | 242 (concat (if open-paren-in-column-0-is-defun-start |