[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: sh-script beg-end of function
From: |
Andreas Röhler |
Subject: |
Re: sh-script beg-end of function |
Date: |
Wed, 21 Nov 2007 16:52:07 +0100 |
User-agent: |
KMail/1.9.5 |
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
;; <address@hidden>
;; 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
- sh-script beg-end of function, Andreas Röhler, 2007/11/19
- Re: sh-script beg-end of function, Richard Stallman, 2007/11/21
- Re: sh-script beg-end of function,
Andreas Röhler <=
- 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
- Re: sh-script beg-end of function, Andreas Röhler, 2007/11/24
- Re: sh-script beg-end of function, Andreas Röhler, 2007/11/23