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 command Date: Thu, 22 Nov 2007 09:10:49 +0100 Message-ID: <200711220910.50079.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 1195719229 13939 80.91.229.12 (22 Nov 2007 08:13:49 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 22 Nov 2007 08:13:49 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Nov 22 09:13:55 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 1Iv7C6-0001wZ-Mk for ged-emacs-devel@m.gmane.org; Thu, 22 Nov 2007 09:13:54 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Iv7Bs-0002Cz-2e for ged-emacs-devel@m.gmane.org; Thu, 22 Nov 2007 03:13:40 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Iv7Bo-0002CJ-DF for emacs-devel@gnu.org; Thu, 22 Nov 2007 03:13:36 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Iv7Bn-0002Bv-Rz for emacs-devel@gnu.org; Thu, 22 Nov 2007 03:13:35 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Iv7Bn-0002Bs-BL for emacs-devel@gnu.org; Thu, 22 Nov 2007 03:13:35 -0500 Original-Received: from mx20.gnu.org ([199.232.41.8]) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Iv7Bl-0003Yw-SC for emacs-devel@gnu.org; Thu, 22 Nov 2007 03:13:34 -0500 Original-Received: from moutng.kundenserver.de ([212.227.126.174]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Iv7Bk-0001Wv-Q5 for emacs-devel@gnu.org; Thu, 22 Nov 2007 03:13:33 -0500 Original-Received: from noname (p54BEBF8F.dip0.t-ipconnect.de [84.190.191.143]) by mrelayeu.kundenserver.de (node=mrelayeu3) with ESMTP (Nemesis) id 0MKxQS-1Iv7Bi3HQh-0005Bj; Thu, 22 Nov 2007 09:13:31 +0100 User-Agent: KMail/1.9.5 Content-Disposition: inline X-Provags-ID: V01U2FsdGVkX19bBVZ2Ntm9tpjVMPp4pZjTcVTxyUFUu55M5km nt6aF94kKOjX5ghvXS0JLpTX5bGI0JE3Y+niy/F/gz8EzcYsWs 9raouCbnl6gP3n0BczqgA== X-detected-kernel: by mx20.gnu.org: Linux 2.6? (barebone, rare!) X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) 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:83845 Archived-At: Hi all, let's consider behaviour of `sh-end-of-command' with this peace of code from install.sh M-e stops at while [ x"$1" !=3D x ]; do ________________________|___ case $1 in ______________|___________ =20 -c) instcmd=3D"$cpprog" __________|__________________=09 shift _________________|___________ =20 continue;; ____________________|_________ =20 =46irst both stops seem ok, third not, fifth at least questionable. Try M-e and M-a from the very beginning of the script to and fro: IMO stops are nearly not predictable. Changed behaviour to that=20 M-a stops at beginnings and M-e at ends=20 of separated lines of code,=20 skipping comments and empty lines and single closing braces. Below der code, any comments welcome. Thanks Andreas R=F6hler ;;; sh-beg-end-of-command.el --- Something useful for ;;; M-a and M-e in sh-script ;; Copyright (C) 2007 Andreas R=F6hler ;; Author: Andreas R=F6hler ;; Keywords: languages ;; 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: ;; Jumps to the beginning or end of command in a given ;; line, forward or backward next beginning or end with ;; repeated execution. With argument doing this as many ;; times. ;;; Code: (require 'newcomment.el) (defun sh-beginning-of-command (&optional arg)=20 "Move point to successive beginnings of commands." (interactive "p") (let ((arg (or arg 1))) (while (< 0 arg) (forward-line (- arg)) (setq arg (1- arg)) ;; skip comments and empty lines and closing braces (while (or (empty-line-p) (looking-at (concat "^[ \t]*" comment-start)) (looking-at "}")) (forward-line -1)) (back-to-indentation) ;; an indented comment may be followed by empty lines (while (or (empty-line-p) (looking-at (concat "^[ \t]*" comment-start)) (looking-at "}")) (forward-line -1)) (back-to-indentation)))) (defun sh-end-of-command (&optional arg)=20 "Move point to successive ends of commands." (interactive "p") (let ((arg (or arg 1)) (pos (point))) (end-of-line) (skip-chars-backward " \t\r\n\f" (line-beginning-position)) (unless (eq pos (point)) ;; point has moved (setq arg (1- arg))) (while (< 0 arg) (forward-line arg) (setq arg (1- arg))) (end-of-line) (skip-chars-backward " \t\r\n\f" (line-beginning-position)) (while (or (empty-line-p) (save-excursion (and (re-search-backward (concat "^[ \t]*" comment-start)=20 (line-beginning-position) t 1) (not (looking-back "[[:alnum:]]\\{2,\\}.*"=20 (line-beginning-position))))))=20 (forward-line 1) (end-of-line)) (skip-chars-backward " \t\r\n\f") (when (and (re-search-backward (concat "^[ \t]*" comment-start)=20 (line-beginning-position) t 1) (looking-back "[[:alnum:]]\\{2,\\}.*" (line-beginning-position))) (skip-chars-backward " \t\r\n\f")))) (provide 'sh-beg-end-of-command) ;;; sh-beg-end-of-command.el ends here