From: "Andreas Röhler" <andreas.roehler@online.de>
To: emacs-devel@gnu.org
Subject: sh-script beg-end of function
Date: Mon, 19 Nov 2007 21:43:14 +0100 [thread overview]
Message-ID: <200711192143.15056.andreas.roehler@online.de> (raw)
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
next reply other threads:[~2007-11-19 20:43 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-19 20:43 Andreas Röhler [this message]
2007-11-21 12:05 ` sh-script beg-end of function Richard Stallman
2007-11-21 15:52 ` Andreas Röhler
2007-11-22 8:22 ` Richard Stallman
2007-11-21 20:19 ` Stefan Monnier
2007-11-22 7:26 ` Andreas Röhler
2007-11-22 17:39 ` Stefan Monnier
2007-11-22 18:56 ` Andreas Röhler
2007-11-22 21:49 ` Stefan Monnier
2007-11-23 15:33 ` Andreas Röhler
2007-11-23 16:34 ` Stefan Monnier
2007-11-24 13:45 ` Andreas Röhler
2007-11-23 15:56 ` Andreas Röhler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200711192143.15056.andreas.roehler@online.de \
--to=andreas.roehler@online.de \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.