From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michael Welsh Duggan Newsgroups: gmane.emacs.devel Subject: Re: [jidanni@jidanni.org: shell-script-mode case indenting] Date: Thu, 21 Sep 2006 18:29:56 -0400 Message-ID: <87k63wc0pn.fsf@cs.cmu.edu> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: sea.gmane.org 1158877830 23936 80.91.229.2 (21 Sep 2006 22:30:30 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 21 Sep 2006 22:30:30 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Sep 22 00:30:27 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GQX3o-0002Sr-FH for ged-emacs-devel@m.gmane.org; Fri, 22 Sep 2006 00:30:24 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GQX3o-000319-0O for ged-emacs-devel@m.gmane.org; Thu, 21 Sep 2006 18:30:24 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GQX3c-0002wK-3n for emacs-devel@gnu.org; Thu, 21 Sep 2006 18:30:12 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GQX3b-0002ux-9W for emacs-devel@gnu.org; Thu, 21 Sep 2006 18:30:11 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GQX3b-0002ug-4a for emacs-devel@gnu.org; Thu, 21 Sep 2006 18:30:11 -0400 Original-Received: from [205.201.10.244] (helo=maru) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1GQX7B-0006yY-6H; Thu, 21 Sep 2006 18:33:53 -0400 Original-Received: from md5i by maru with local (Exim 4.63) (envelope-from ) id 1GQX3M-00024D-KE; Thu, 21 Sep 2006 18:29:56 -0400 Original-To: rms@gnu.org, Dan Jacobson In-Reply-To: (Richard Stallman's message of "Thu\, 21 Sep 2006 16\:15\:21 -0400") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) 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:60078 Archived-At: --=-=-= Richard Stallman writes: > Would someone please DTRT and ack? This is not a must-fix bug, since > perfect indentation in Shell Script mode is too much to hope for, but > we should fix it if it isn't hard. > > From: Dan Jacobson > Subject: shell-script-mode case indenting > To: emacs-pretest-bug@gnu.org > Date: Thu, 21 Sep 2006 18:28:18 +0800 > X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=failed > version=3.0.4 > > Pressing TAB on each line in this file.sh produces the first line of > this case expression indented different than the rest: > (sed 's/.$/ &/'|while read route company; do case $company in > r)set ???? Renyou;; > z)set ???? Taizhong;; > q)set ???? Quanhang;; > j)set ???? Juye;; > t)set ???? Tonglian;; > *)echo $company: HUH? 1>&2;exit 55;; > esac; echo "[[????:???? ${1}???? - Operator $2 Bus Co.]]" \ > >> $route; done)< 001r > 005q > 006r > EOF The following patch attempts to take `sh-leading-keywords' into account when calculating (sh-prev-thing). This patch seems to work in this and a few other cases I played around with, but I make no guarantees that I haven't broken something along the way: --=-=-= Content-Type: text/x-patch Content-Disposition: inline Index: sh-script.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/progmodes/sh-script.el,v retrieving revision 1.186 diff -u -p -r1.186 sh-script.el --- sh-script.el 8 Aug 2006 15:09:25 -0000 1.186 +++ sh-script.el 21 Sep 2006 22:26:28 -0000 @@ -2473,33 +2473,42 @@ we go to the end of the previous line an (skip-chars-backward " \t;") (unless (looking-at "\\s-*;;") (skip-chars-backward "^)}];\"'`({[") - (setq c (char-before)))) - (sh-debug "stopping at %d c is %s start=%d min-point=%d" - (point) c start min-point) - (if (< (point) min-point) - (error "point %d < min-point %d" (point) min-point)) - (cond - ((looking-at "\\s-*;;") - ;; (message "Found ;; !") - ";;") - ((or (eq c ?\n) - (eq c nil) - (eq c ?\;)) - (save-excursion - ;; skip forward over white space newline and \ at eol - (skip-chars-forward " \t\n\\\\") - (sh-debug "Now at %d start=%d" (point) start) - (if (>= (point) start) - (progn - (sh-debug "point: %d >= start: %d" (point) start) - nil) - (sh-get-word)) - )) - (t - ;; c -- return a string - (char-to-string c) - )) - ))) + (setq c (char-before)) + (sh-debug "stopping at %d c is %s start=%d min-point=%d" + (point) c start min-point) + (if (< (point) min-point) + (error "point %d < min-point %d" (point) min-point)) + (cond + ((looking-at "\\s-*;;") + ;; (message "Found ;; !") + ";;") + ((or (eq c ?\n) + (eq c nil) + (eq c ?\;)) + (let (done kwd next + (boundary (point))) + (skip-chars-forward " \t\n\\\\") + (while (and (not done) (not (eobp))) + (if next (setq boundary next)) + ;; skip forward over white space newline and \ at eol + (sh-debug "Now at %d start=%d" (point) start) + (if (>= (point) start) + (progn + (sh-debug "point: %d >= start: %d" (point) start) + nil) + (setq kwd (sh-get-word)) + (unless (eobp) (forward-char 1)) + (if (member kwd (sh-feature sh-leading-keywords)) + (setq next (point)) + (setq done t))) + (skip-chars-forward " \t\n\\\\")) + (goto-char boundary) + kwd)) + (t + ;; c -- return a string + (char-to-string c) + )) + ))))) (defun sh-this-is-a-continuation () --=-=-= -- Michael Welsh Duggan (md5i@cs.cmu.edu) --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel --=-=-=--