[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
sh-script beg-end of function
From: |
Andreas Röhler |
Subject: |
sh-script beg-end of function |
Date: |
Mon, 19 Nov 2007 21:43:14 +0100 |
User-agent: |
KMail/1.9.5 |
Hi all,
in sh-script-mode C-M-a jumped to the beginning of the
buffer, C-M-e to the end
with GNU Emacs 23.0.50.2 (i686-pc-linux-gnu, GTK+ Version 2.10.6) of
2007-10-30
To have a more convienent behaviour I made this:
;;;;;;;;;
(require 'newcomment)
(defcustom sh-beginning-of-function-regexp "^[A-Za-z_][A-Za-z_0-9]*"
""
:type 'regexp
:group 'sh-script)
(defun sh-beginning-of-function ()
"Re-search-backward sh-beginning-of-function-regexp nil t 1 "
(interactive)
(re-search-backward sh-beginning-of-function-regexp nil t 1))
(defcustom beginning-of-defun-function 'sh-beginning-of-function
""
:type 'symbol
:group 'sh-script)
(defun sh-end-of-function (&optional arg)
"Move forward to end of a function or command in sh-script.
With numeric argument, do it that many times.
"
(interactive "p")
(or arg (setq arg 1))
(forward-line 1)
;; between functions, skip next beginning
(when (eq 0 (car (parse-partial-sexp (point-min) (point))))
(setq arg (1+ arg)))
(let ((erf
(re-search-forward sh-beginning-of-function-regexp nil t arg)))
(goto-char (match-beginning 0))
(unless erf
;; already last top level form
(goto-char (point-max)))
(skip-chars-backward " \t\r\n\f"))
;; skip comments
(while
(progn
(comment-normalize-vars) (comment-beginning))
(forward-line -1)
(end-of-line)
(skip-chars-backward " \t\r\n\f")))
(defcustom end-of-defun-function 'sh-end-of-function
""
:type 'symbol
:group 'sh-script)
(defun sh-set-beginning-of-function ()
" "
(interactive)
(setq beginning-of-defun-function 'sh-beginning-of-function))
(defun sh-set-end-of-function ()
" "
(interactive)
(setq end-of-defun-function 'sh-end-of-function))
(add-hook 'sh-mode-hook 'sh-set-beginning-of-function)
(add-hook 'sh-mode-hook 'sh-set-end-of-function)
;;;;;;;
Maybe I could use another form already existing?
Comments welcome
Andreas Röhler
- sh-script beg-end of function,
Andreas Röhler <=
- Re: sh-script beg-end of function, Richard Stallman, 2007/11/21
- Re: sh-script beg-end of function, Andreas Röhler, 2007/11/21
- Re: sh-script beg-end of function, Stefan Monnier, 2007/11/21
- Re: sh-script beg-end of function, Andreas Röhler, 2007/11/22
- Re: sh-script beg-end of function, Stefan Monnier, 2007/11/22
- Re: sh-script beg-end of function, Andreas Röhler, 2007/11/22
- Re: sh-script beg-end of function, Stefan Monnier, 2007/11/22
- Re: sh-script beg-end of function, Andreas Röhler, 2007/11/23
- Re: sh-script beg-end of function, Stefan Monnier, 2007/11/23