From: "Andreas Röhler" <andreas.roehler@online.de>
To: rms@gnu.org
Cc: emacs-devel@gnu.org
Subject: Re: sh-script beg-end of function
Date: Wed, 21 Nov 2007 16:52:07 +0100 [thread overview]
Message-ID: <200711211652.08126.andreas.roehler@online.de> (raw)
In-Reply-To: <E1IuoKW-00084j-5K@fencepost.gnu.org>
Am Mittwoch, 21. November 2007 13:05 schrieb Richard Stallman:
> This is a good change to make.
> Would others please check the code and send Andreas suggestions?
>
> To use this code, we'd need legal papers of some kind.
> Would you like to sign a copyright assignment?
> (A disclaimer would suffice instead, for this change.)
>
>
Below the code with the disclaimer and some docstrings
inserted.
Please send the papers you want me to sign, so I may
reflect it at least for later occasions. Adress is
known by FSF.
Andreas Röhler
;;; sh-beg-end.el --- Establish something useful for
;;; beginning- and end-of-defun in shell-script-mode
;; Copyright (C) 2007 by Andreas Röhler
;; <andreas.roehler@online.de>
;; This file is free software; you can redistribute it
;; and/or modify it under the terms of the GNU General
;; Public License as published by the Free Software
;; Foundation; either version 3, or (at your option)
;; any later version.
;; This file is distributed in the hope that it will be
;; useful, but WITHOUT ANY WARRANTY; without even the
;; implied warranty of MERCHANTABILITY or FITNESS FOR A
;; PARTICULAR PURPOSE. See the GNU General Public
;; License for more details.
;; You should have received a copy of the GNU General
;; Public License along with GNU Emacs; see the file
;; COPYING. If not, write to the Free Software
;; Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Commentary: Jump to the beginning or end of a
;;; top-level-form in sh-mode - "Shell-script"-mode
;;; Code:
(require 'newcomment)
(defcustom sh-beginning-of-function-regexp "^[A-Za-z_][A-Za-z_0-9]*"
"Regexp to identify the beginning of a top-level-form in
shell-script-mode."
: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
"'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
"Establish useful behavior for `end-of-defun' in `shell-script-mode'."
:type 'symbol
:group 'sh-script)
(defun sh-set-beginning-of-function ()
"'sh-beginning-of-function"
(interactive)
(setq beginning-of-defun-function 'sh-beginning-of-function))
(defun sh-set-end-of-function ()
"'sh-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)
(provide 'sh-beg-end)
;;; sh-beg-end.el ends here
next prev parent reply other threads:[~2007-11-21 15:52 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-19 20:43 sh-script beg-end of function Andreas Röhler
2007-11-21 12:05 ` Richard Stallman
2007-11-21 15:52 ` Andreas Röhler [this message]
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=200711211652.08126.andreas.roehler@online.de \
--to=andreas.roehler@online.de \
--cc=emacs-devel@gnu.org \
--cc=rms@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.