From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andreas =?iso-8859-1?q?R=F6hler?= Newsgroups: gmane.emacs.devel Subject: sh-script beg-end of function Date: Mon, 19 Nov 2007 21:43:14 +0100 Message-ID: <200711192143.15056.andreas.roehler@online.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1195504999 20503 80.91.229.12 (19 Nov 2007 20:43:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 19 Nov 2007 20:43:19 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Nov 19 21:43:24 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IuDSe-0002eX-8S for ged-emacs-devel@m.gmane.org; Mon, 19 Nov 2007 21:43:16 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IuDSQ-0006fv-Nd for ged-emacs-devel@m.gmane.org; Mon, 19 Nov 2007 15:43:02 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IuDRr-0006K9-Fn for emacs-devel@gnu.org; Mon, 19 Nov 2007 15:42:27 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IuDRp-0006JC-HA for emacs-devel@gnu.org; Mon, 19 Nov 2007 15:42:26 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IuDRp-0006J7-7I for emacs-devel@gnu.org; Mon, 19 Nov 2007 15:42:25 -0500 Original-Received: from moutng.kundenserver.de ([212.227.126.174]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IuDRo-0005Q0-Ma for emacs-devel@gnu.org; Mon, 19 Nov 2007 15:42:25 -0500 Original-Received: from noname (p54BEB031.dip0.t-ipconnect.de [84.190.176.49]) by mrelayeu.kundenserver.de (node=mrelayeu8) with ESMTP (Nemesis) id 0ML31I-1IuDRn3sor-0003uZ; Mon, 19 Nov 2007 21:42:24 +0100 User-Agent: KMail/1.9.5 Content-Disposition: inline X-Provags-ID: V01U2FsdGVkX18UkHH+ZAbPedzK6rMflFG4A/8x+DWgsX9ljdu iJ3IcR6bL1OQm+kIm+UtUSzMdtaQOOEE07GKwmJNYPoTJXKq0r 541ETczFkebb+P8z+sS4g== X-detected-kernel: by monty-python.gnu.org: Linux 2.6? (barebone, rare!) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:83689 Archived-At: 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=20 2007-10-30=20 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]*"=20 "" :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=20 "" :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"))=20 ;; skip comments=20 (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=20 "" :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=F6hler