Commit afa995e1 authored by Karl Heuer's avatar Karl Heuer
Browse files

(beginning-of-defun-raw): New function.

(end-of-defun): Handle defun-prompt-regexp correctly.
parent 37f31acf
......@@ -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, 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(")
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
(forward-char 1)
(beginning-of-defun 1)))
(end-of-line 1)
(beginning-of-defun-raw 1)))
(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)
(forward-list 1)
(skip-chars-forward " \t")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment