summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/lisp.el
diff options
context:
space:
mode:
authorKarl Heuer <kwzh@gnu.org>1994-03-18 02:21:52 +0000
committerKarl Heuer <kwzh@gnu.org>1994-03-18 02:21:52 +0000
commitafa995e19e7c62f03b91b77872afc2d7f899e0f7 (patch)
treeda84bc8ca07fea3d89a170a1bd8b3a4fa3c70def /lisp/emacs-lisp/lisp.el
parent37f31acf876064714d3498ae7436174f0b4c83c5 (diff)
downloademacs-afa995e19e7c62f03b91b77872afc2d7f899e0f7.tar.gz
emacs-afa995e19e7c62f03b91b77872afc2d7f899e0f7.tar.bz2
emacs-afa995e19e7c62f03b91b77872afc2d7f899e0f7.zip
(beginning-of-defun-raw): New function.
(end-of-defun): Handle defun-prompt-regexp correctly.
Diffstat (limited to 'lisp/emacs-lisp/lisp.el')
-rw-r--r--lisp/emacs-lisp/lisp.el22
1 files changed, 15 insertions, 7 deletions
diff --git a/lisp/emacs-lisp/lisp.el b/lisp/emacs-lisp/lisp.el
index ebe0885c769..3156ff39b35 100644
--- a/lisp/emacs-lisp/lisp.el
+++ b/lisp/emacs-lisp/lisp.el
@@ -135,7 +135,15 @@ Returns t unless search stops due to beginning or end of buffer.
Normally a defun starts when there is an char with open-parenthesis
syntax at the beginning of a line. If `defun-prompt-regexp' is
non-nil, then a string which matches that regexp may precede the
-open-parenthesis."
+open-parenthesis, and point ends up at the beginning of the line."
+ (interactive "p")
+ (and (beginning-of-defun-raw arg)
+ (progn (beginning-of-line) t)))
+
+(defun beginning-of-defun-raw (&optional arg)
+ "Move point to the character that starts a defun.
+This is identical to beginning-of-defun, except that point does not move
+to the beginning of the line when `defun-prompt-regexp' is non-nil."
(interactive "p")
(and arg (< arg 0) (forward-char 1))
(and (re-search-backward (if defun-prompt-regexp
@@ -143,7 +151,7 @@ open-parenthesis."
"\\(" defun-prompt-regexp "\\)\\s(")
"^\\s(")
nil 'move (or arg 1))
- (progn (beginning-of-line) t)))
+ (progn (goto-char (1- (match-end 0)))) t))
(defun buffer-end (arg)
(if (> arg 0) (point-max) (point-min)))
@@ -162,11 +170,11 @@ the open-parenthesis that starts a defun; see `beginning-of-defun'."
(while (progn
(if (and first
(progn
- (forward-char 1)
- (beginning-of-defun 1)))
+ (end-of-line 1)
+ (beginning-of-defun-raw 1)))
nil
(or (bobp) (forward-char -1))
- (beginning-of-defun -1))
+ (beginning-of-defun-raw -1))
(setq first nil)
(forward-list 1)
(skip-chars-forward " \t")
@@ -176,11 +184,11 @@ the open-parenthesis that starts a defun; see `beginning-of-defun'."
(setq arg (1- arg)))
(while (< arg 0)
(let ((pos (point)))
- (beginning-of-defun 1)
+ (beginning-of-defun-raw 1)
(forward-sexp 1)
(forward-line 1)
(if (>= (point) pos)
- (if (beginning-of-defun 2)
+ (if (beginning-of-defun-raw 2)
(progn
(forward-list 1)
(skip-chars-forward " \t")