From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andreas =?utf-8?q?R=C3=B6hler?= Newsgroups: gmane.emacs.devel Subject: Re: shell-script indenting of &&, | Date: Fri, 29 Feb 2008 09:04:12 +0100 Message-ID: <200802290904.13271.andreas.roehler@online.de> References: <87zltmkxpd.fsf@jidanni.org> <200802281407.46516.andreas.roehler@online.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1204272219 18397 80.91.229.12 (29 Feb 2008 08:03:39 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 29 Feb 2008 08:03:39 +0000 (UTC) Cc: Stefan Monnier , jidanni@jidanni.org To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Feb 29 09:04:04 2008 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 1JV0Dq-0001YD-Io for ged-emacs-devel@m.gmane.org; Fri, 29 Feb 2008 09:04:02 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JV0DK-0000Y9-8X for ged-emacs-devel@m.gmane.org; Fri, 29 Feb 2008 03:03:30 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JV0DF-0000Xt-QP for emacs-devel@gnu.org; Fri, 29 Feb 2008 03:03:25 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JV0DD-0000Xh-ET for emacs-devel@gnu.org; Fri, 29 Feb 2008 03:03:24 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JV0DD-0000Xe-98 for emacs-devel@gnu.org; Fri, 29 Feb 2008 03:03:23 -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 1JV0DC-0008No-Gf for emacs-devel@gnu.org; Fri, 29 Feb 2008 03:03:22 -0500 Original-Received: from moutng.kundenserver.de ([212.227.126.188]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JV0DB-0004TJ-Iw for emacs-devel@gnu.org; Fri, 29 Feb 2008 03:03:21 -0500 Original-Received: from noname (p54BE885A.dip0.t-ipconnect.de [84.190.136.90]) by mrelayeu.kundenserver.de (node=mrelayeu0) with ESMTP (Nemesis) id 0MKwh2-1JV0Cw1t1C-0002S0; Fri, 29 Feb 2008 09:03:07 +0100 User-Agent: KMail/1.9.5 In-Reply-To: <200802281407.46516.andreas.roehler@online.de> Content-Disposition: inline X-Provags-ID: V01U2FsdGVkX1/c2qMerJwLEQMMn3dWcgsll4KRqDffHApU8QB dkb3vSYzWc1FbTLe1Mn3TME8XbXEiQEDjSfpXeYO4t6G5IS3FX gP6SfYUp0G0DOtZilyx4A== 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:90844 Archived-At: Am Donnerstag, 28. Februar 2008 14:07 schrieb Andreas R=C3=B6hler: > Am Mittwoch, 27. Februar 2008 20:26 schrieb jidanni@jidanni.org: > > >> Line 2 must not, as it's top level IMO. > > > > oops. > > > > >> As `&&' may be considered as if-then form, I would > > >> welcome indentation for lines 3 and 4. > > >> > > >> Respective following || > > > > Anyways, backslash-newline continuation lines are indented. Just use > > the same formula. > > Thanks for the hint. > > Indeed nearly all what had to be done was introducing a > new function `sh-short-if'. > > It proceeds respectivly to `sh-this-is-a-continuation', > which already handles the final "/". > > Patch attached. > > Andreas R=C3=B6hler As new (sh-short-if) is asked twice, it's probably cleaner to introduce a let. Below a diff of the region. *** /tmp/ediff6188MQH 2008-02-29 08:54:43.000000000 +0100 =2D-- /tmp/ediff6188ZaN 2008-02-29 08:54:43.000000000 +0100 *************** *** 1,24 **** ;; Continuation lines are handled specially ! (let ((cont (sh-this-is-a-continuation)) ! (sh-if-short (sh-short-if))) ! (if (or cont sh-if-short) ! (progn ! (setq result ! (if (and (not sh-if-short)=20 ! (save-excursion ! (beginning-of-line) ! (not (memq (char-before (- (point) 2)) '(?\s ?\t))))) ! ;; By convention, if the continuation \ is not ! ;; preceded by a SPC or a TAB it means that the line ! ;; is cut at a place where spaces cannot be freely ! ;; added/removed. I.e. do not indent the line. ! (list '(=3D nil)) ! ;; We assume the line being continued is already ! ;; properly indented... ! ;; (setq prev-line-end (sh-prev-line)) ! (setq align-point (sh-prev-line nil)) ! (list '(+ sh-indent-for-continuation)))) ! (setq have-result t))) (beginning-of-line) (skip-chars-forward " \t") (setq this-kw (sh-get-kw))) =2D-- 1,23 ---- ;; Continuation lines are handled specially ! (if (or (sh-this-is-a-continuation) ! (sh-short-if)) ! (progn ! (setq result ! (if (and (not (sh-short-if))=20 ! (save-excursion ! (beginning-of-line) ! (not (memq (char-before (- (point) 2)) '(?\s ? \t))))) ! ;; By convention, if the continuation \ is not ! ;; preceded by a SPC or a TAB it means that the l= ine ! ;; is cut at a place where spaces cannot be freely ! ;; added/removed. I.e. do not indent the line. ! (list '(=3D nil)) ! ;; We assume the line being continued is already ! ;; properly indented... ! ;; (setq prev-line-end (sh-prev-line)) ! (setq align-point (sh-prev-line nil)) ! (list '(+ sh-indent-for-continuation)))) ! (setq have-result t)) (beginning-of-line) (skip-chars-forward " \t") (setq this-kw (sh-get-kw))) =20 Andreas R=C3=B6hler