* simplifying beginning-of-defun (2)
@ 2009-09-27 16:07 Andreas Roehler
0 siblings, 0 replies; only message in thread
From: Andreas Roehler @ 2009-09-27 16:07 UTC (permalink / raw)
To: XEmacs-Beta; +Cc: emacs-devel, Stefan Monnier, python-mode, Eric M. Ludlam
Below again the code, as end-of-defun-raw had a bug last times
;; GNU's lisp.el
;; unhappily sets this var globally, ignoring its use for progmodes
(when (featurep 'emacs) (setq end-of-defun-function nil))
(setq defun-searchform '(if defun-prompt-regexp
(concat "^\\s(\\|"
"\\(" defun-prompt-regexp "\\)\\s(")
"^\\s("))
(defun beginning-of-defun (&optional arg)
"Move backward to the beginning of a functions definition. "
(interactive "P")
(or arg (setq arg 1))
(if beginning-of-defun-function
(funcall beginning-of-defun-function arg)
(beginning-of-defun-raw arg)))
(defun beginning-of-defun-raw (&optional arg)
"Called if progmodes didn't set beginning-of-defun-function. "
(when
(re-search-backward (eval defun-searchform) nil 'move (or arg 1))
(goto-char (match-beginning 0))))
(defun end-of-defun (&optional arg)
"Move backward to the end of a function. "
(interactive "P")
(or arg (setq arg 1))
(if end-of-defun-function
(funcall end-of-defun-function arg)
(end-of-defun-raw arg)))
(defun end-of-defun-raw (&optional arg)
"Called if progmodes didn't set end-of-defun-function. "
(skip-chars-forward " \t\r\n\f")
(unless (looking-at (eval defun-searchform))
(beginning-of-defun 1))
(when (re-search-forward (eval defun-searchform) nil t arg)
(goto-char (match-beginning 0))
(forward-sexp 1)))
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-09-27 16:07 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-27 16:07 simplifying beginning-of-defun (2) Andreas Roehler
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.