From debbugs-submit-bounces@debbugs.gnu.org Tue Jun 24 09:49:56 2014 Received: (at submit) by debbugs.gnu.org; 24 Jun 2014 13:49:56 +0000 Received: from localhost ([127.0.0.1]:59098 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WzR6h-0000hL-UN for submit@debbugs.gnu.org; Tue, 24 Jun 2014 09:49:56 -0400 Received: from eggs.gnu.org ([208.118.235.92]:41662) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WzR6f-0000h5-AP for submit@debbugs.gnu.org; Tue, 24 Jun 2014 09:49:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WzR6T-0002vW-Lm for submit@debbugs.gnu.org; Tue, 24 Jun 2014 09:49:47 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_40 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:56838) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WzR6T-0002vN-IU for submit@debbugs.gnu.org; Tue, 24 Jun 2014 09:49:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43313) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WzR6N-0003ii-Rb for bug-gnu-emacs@gnu.org; Tue, 24 Jun 2014 09:49:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WzR6I-0002rD-3g for bug-gnu-emacs@gnu.org; Tue, 24 Jun 2014 09:49:35 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.181]:38171) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WzR6H-0002qv-V9 for bug-gnu-emacs@gnu.org; Tue, 24 Jun 2014 09:49:30 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArQGAIDvNVNLd+D9/2dsb2JhbABZgwY7gw/BVBd0giUBAQRXKEomGA03h3EIn3+yGheOKQEBbIQiBKkZgWqDTCGBNQ X-IPAS-Result: ArQGAIDvNVNLd+D9/2dsb2JhbABZgwY7gw/BVBd0giUBAQRXKEomGA03h3EIn3+yGheOKQEBbIQiBKkZgWqDTCGBNQ X-IronPort-AV: E=Sophos;i="4.97,753,1389762000"; d="scan'208";a="69381054" Received: from 75-119-224-253.dsl.teksavvy.com (HELO pastel.home) ([75.119.224.253]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 24 Jun 2014 09:49:28 -0400 Received: by pastel.home (Postfix, from userid 20848) id 3DBBB6036C; Tue, 24 Jun 2014 09:49:28 -0400 (EDT) From: Stefan Monnier To: bug-gnu-emacs@gnu.org Subject: sh-script's indentation gets confused by \; Message-ID: Date: Tue, 24 Jun 2014 09:49:28 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) --=-=-= Content-Type: text/plain Splitting into another bug. --=-=-= Content-Type: message/rfc822 Content-Disposition: inline Return-Path: X-Original-To: monnier@iro.umontreal.ca Delivered-To: monnier@iro.umontreal.ca Received: from perlin.iro.umontreal.ca (perlin.iro.umontreal.ca [132.204.24.51]) by mercure.iro.umontreal.ca (Postfix) with ESMTP id 240C524216 for ; Mon, 23 Jun 2014 12:10:32 -0400 (EDT) X-Greylist: delayed 318 seconds by postgrey-1.27 at perlin.iro.umontreal.ca; Mon, 23 Jun 2014 12:10:17 EDT Received: from mail.uni-ulm.de (mail.uni-ulm.de [134.60.1.11]) by perlin.iro.umontreal.ca (Postfix) with ESMTP id ACF48830001 for ; Mon, 23 Jun 2014 12:10:17 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) (authenticated bits=0) by mail.uni-ulm.de (8.14.9/8.14.7) with ESMTP id s5NG4oVL025382; Mon, 23 Jun 2014 18:04:50 +0200 (CEST) Received: from 10.196.208.71 (10.196.208.71 [10.196.208.71]) by imap.uni-ulm.de (Horde MIME library) with HTTP; Mon, 23 Jun 2014 18:04:50 +0200 Message-ID: <20140623180450.pgyd1ksywokgcs8s@imap.uni-ulm.de> Date: Mon, 23 Jun 2014 18:04:50 +0200 From: Reiner Steib To: Stefan Monnier Cc: 17818@debbugs.gnu.org Subject: Re: bug#17818: 24.3.91; sh-learn-buffer-indent doesn't learn current indent anymore References: <87ha3fy6lv.fsf@marauder.physik.uni-ulm.de> In-Reply-To: User-Agent: Internet Messaging Program (IMP) H3 (4.1.5) X-DCC-sonic.net-Metrics: poseidon; whitelist X-Virus-Scanned: by amavisd-new X-DIRO-MailScanner-Information: Please contact the ISP for more information X-DIRO-MailScanner: Found to be clean X-DIRO-MailScanner-SpamCheck: n'est pas un polluriel, SpamAssassin (score=-2.599, requis 5, autolearn=not spam, BAYES_00 -2.60, MC_TSTLAST 0.00) X-DIRO-MailScanner-From: reiner.steib@gmx.de X-Spam-Status: No MIME-Version: 1.0 Content-Type: text/plain On Fri, 20 Jun 2014, Stefan Monnier wrote: >> if true; do >> echo "My sh-basic-offset offset should be 2." >> fi > > The above "do" should be "then", right? Sure, sorry. (I corrected it in my test-script, but not in the mail). > I installed the patch below which fixes some of the problem (the first > hunk fixes an incorrect guess and the second fixes the code so the guess > is actually activated). > > Please confirm that the result is OK for your use case. Works much better, thanks. However, I tested[1] the new code with the following script and found some incorrect indents (see diff below, hope the whitespace doesn't get changed). Bye, Reiner. [1] M-x sh-learn-buffer-indent RET, M-x mark-whole-buffer RET, M-x indent-region RET, M-x diff-buffer-with-file RET #!/bin/bash if true; then echo "My sh-basic-offset offset should be 2." fi for a in 1 2; do echo "My sh-basic-offset offset should be 2." done filter_1 () { tr -d '"' | awk -F\; '{ if ($7 == 0 || $7 == 1) { print $7 } ; \ print $5 "," $1 }' | grep -v "^," } filter_3 () { tr -d '"`' | tr ' ' ' ' | \ awk -F\; -f filter.awk | \ grep -v "^," | sort -t, -k2,2 } tail -q -n+2 assets-ws.csv | awk -F \; -f merge.awk \ <( cat file1.csv file2.csv ) - | \ filter_2 | $conv | \ sed -f a.sed | sort -t\; -k3,3 -k1,1 > w.csv # end --- shell-script-test.sh +++ # @@ -12,21 +12,21 @@ filter_1 () { tr -d '"' | - awk -F\; '{ if ($7 == 0 || $7 == 1) { print $7 } ; \ +awk -F\; '{ if ($7 == 0 || $7 == 1) { print $7 } ; \ print $5 "," $1 }' | - grep -v "^," +grep -v "^," } filter_3 () { tr -d '"`' | tr ' ' ' ' | \ - awk -F\; -f filter.awk | \ - grep -v "^," | sort -t, -k2,2 + awk -F\; -f filter.awk | \ +grep -v "^," | sort -t, -k2,2 } tail -q -n+2 assets-ws.csv | awk -F \; -f merge.awk \ - <( cat file1.csv file2.csv ) - | \ - filter_2 | $conv | \ - sed -f a.sed | sort -t\; -k3,3 -k1,1 > w.csv + <( cat file1.csv file2.csv ) - | \ + filter_2 | $conv | \ + sed -f a.sed | sort -t\; -k3,3 -k1,1 > w.csv # end Diff finished. Mon Jun 23 17:56:00 2014 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Tue Jun 24 16:10:10 2014 Received: (at 17842) by debbugs.gnu.org; 24 Jun 2014 20:10:11 +0000 Received: from localhost ([127.0.0.1]:59632 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WzX2f-0003jt-JR for submit@debbugs.gnu.org; Tue, 24 Jun 2014 16:10:10 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.181]:29714) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WzX2d-0003jN-1L for 17842@debbugs.gnu.org; Tue, 24 Jun 2014 16:10:08 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArYGAIDvNVNLd+D9/2dsb2JhbABZgwY7gw/APYEXF3SCJQEBAQECAVYoCws0EhQYDYgoCNIZF48BhDgEqRmBaoNMIQ X-IPAS-Result: ArYGAIDvNVNLd+D9/2dsb2JhbABZgwY7gw/APYEXF3SCJQEBAQECAVYoCws0EhQYDYgoCNIZF48BhDgEqRmBaoNMIQ X-IronPort-AV: E=Sophos;i="4.97,753,1389762000"; d="scan'208";a="69432629" Received: from 75-119-224-253.dsl.teksavvy.com (HELO ceviche.home) ([75.119.224.253]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 24 Jun 2014 16:10:00 -0400 Received: by ceviche.home (Postfix, from userid 20848) id 85A8266167; Tue, 24 Jun 2014 16:10:00 -0400 (EDT) From: Stefan Monnier To: 17842@debbugs.gnu.org Subject: Re: sh-script's indentation gets confused by \; Message-ID: References: X-debbugs-cc: Reiner Steib Date: Tue, 24 Jun 2014 16:10:00 -0400 In-Reply-To: (Stefan Monnier's message of "Tue, 24 Jun 2014 09:49:28 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 17842 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.3 (/) > However, I tested[1] the new code with the following script and found > some incorrect indents (see diff below, hope the whitespace doesn't > get changed). These are due to the new indentation code. > --- shell-script-test.sh > +++ # > @@ -12,21 +12,21 @@ > filter_1 () > { > tr -d '"' | > - awk -F\; '{ if ($7 == 0 || $7 == 1) { print $7 } ; \ > +awk -F\; '{ if ($7 == 0 || $7 == 1) { print $7 } ; \ > print $5 "," $1 }' | > - grep -v "^," > +grep -v "^," > } > filter_3 () > { > tr -d '"`' | tr ' ' ' ' | \ > - awk -F\; -f filter.awk | \ > - grep -v "^," | sort -t, -k2,2 > + awk -F\; -f filter.awk | \ > +grep -v "^," | sort -t, -k2,2 > } > tail -q -n+2 assets-ws.csv | awk -F \; -f merge.awk \ > - <( cat file1.csv file2.csv ) - | \ > - filter_2 | $conv | \ > - sed -f a.sed | sort -t\; -k3,3 -k1,1 > w.csv > + <( cat file1.csv file2.csv ) - | \ > + filter_2 | $conv | \ > + sed -f a.sed | sort -t\; -k3,3 -k1,1 > w.csv I installed the patch below which fixes the problem with \; and also with the indentation after "a | b |". The "<(cat...)" line is still not indented as you want it because you expect a different logic from the one followed by the current indentation code (the current code indents multi-line elements connected by \ as multi line constructs rather than "one long wrapped line", so the <(...) gets aligned with the other arguments to the "sort" command). Stefan === modified file 'lisp/progmodes/sh-script.el' --- lisp/progmodes/sh-script.el 2014-06-20 14:23:30 +0000 +++ lisp/progmodes/sh-script.el 2014-06-24 19:55:01 +0000 @@ -466,6 +466,9 @@ ?~ "_" ?, "_" ?= "." + ?\; "." + ?| "." + ?& "." ?< "." ?> ".") "The syntax table to use for Shell-Script mode. @@ -1837,6 +1840,40 @@ ((equal tok "in") (sh-smie--sh-keyword-in-p)) (t (sh-smie--keyword-p)))) +(defun sh-smie--default-forward-token () + (forward-comment (point-max)) + (buffer-substring-no-properties + (point) + (progn (if (zerop (skip-syntax-forward ".")) + (while (progn (skip-syntax-forward "w_'") + (looking-at "\\\\")) + (forward-char 2))) + (point)))) + +(defun sh-smie--default-backward-token () + (forward-comment (- (point))) + (let ((pos (point)) + (n (skip-syntax-backward "."))) + (if (or (zerop n) + (and (eq n -1) + (let ((p (point))) + (if (eq -1 (% (skip-syntax-backward "\\") 2)) + t + (goto-char p) + nil)))) + (while + (progn (skip-syntax-backward "w_'") + (or (not (zerop (skip-syntax-backward "\\"))) + (when (eq ?\\ (char-before (1- (point)))) + (let ((p (point))) + (forward-char -1) + (if (eq -1 (% (skip-syntax-backward "\\") 2)) + t + (goto-char p) + nil)))))) + (goto-char (- (point) (% (skip-syntax-backward "\\") 2)))) + (buffer-substring-no-properties (point) pos))) + (defun sh-smie-sh-forward-token () (if (and (looking-at "[ \t]*\\(?:#\\|\\(\\s|\\)\\|$\\)") (save-excursion @@ -1865,7 +1902,7 @@ tok)) (t (let* ((pos (point)) - (tok (smie-default-forward-token))) + (tok (sh-smie--default-forward-token))) (cond ((equal tok ")") "case-)") ((equal tok "(") "case-(") @@ -1909,7 +1946,7 @@ (goto-char (match-beginning 1)) (match-string-no-properties 1)) (t - (let ((tok (smie-default-backward-token))) + (let ((tok (sh-smie--default-backward-token))) (cond ((equal tok ")") "case-)") ((equal tok "(") "case-(") @@ -1939,18 +1976,18 @@ (`(:after . "case-)") (- (sh-var-value 'sh-indent-for-case-alt) (sh-var-value 'sh-indent-for-case-label))) ((and `(:before . ,_) - (guard (when sh-indent-after-continuation - (save-excursion + ;; After a line-continuation, make sure the rest is indented. + (guard sh-indent-after-continuation) + (guard (save-excursion (ignore-errors (skip-chars-backward " \t") - (sh-smie--looking-back-at-continuation-p)))))) - ;; After a line-continuation, make sure the rest is indented. - (let* ((sh-indent-after-continuation nil) - (indent (smie-indent-calculate)) - (initial (sh-smie--continuation-start-indent))) - (when (and (numberp indent) (numberp initial) - (<= indent initial)) - `(column . ,(+ initial sh-indentation))))) + (sh-smie--looking-back-at-continuation-p)))) + (let initial (sh-smie--continuation-start-indent)) + (guard (let* ((sh-indent-after-continuation nil) + (indent (smie-indent-calculate))) + (and (numberp indent) (numberp initial) + (<= indent initial))))) + `(column . ,(+ initial sh-indentation))) (`(:before . ,(or `"(" `"{" `"[")) (when (smie-rule-hanging-p) (if (not (smie-rule-prev-p "&&" "||" "|")) @@ -1974,7 +2011,12 @@ (smie-rule-bolp)))) (current-column) (smie-indent-calculate))))) - (`(:after . ,(or `"|" `"&&" `"||")) (if (smie-rule-parent-p token) nil 4)) + (`(:before . ,(or `"|" `"&&" `"||")) + (unless (smie-rule-parent-p token) + (smie-backward-sexp token) + `(column . ,(+ (funcall smie-rules-function :elem 'basic) + (smie-indent-virtual))))) + ;; Attempt at backward compatibility with the old config variables. (`(:before . "fi") (sh-var-value 'sh-indent-for-fi)) (`(:before . "done") (sh-var-value 'sh-indent-for-done)) @@ -2095,7 +2137,7 @@ ;; tok)) (t (let* ((pos (point)) - (tok (smie-default-forward-token))) + (tok (sh-smie--default-forward-token))) (cond ;; ((equal tok ")") "case-)") ((and tok (string-match "\\`[a-z]" tok) @@ -2136,7 +2178,7 @@ ;; (goto-char (match-beginning 1)) ;; (match-string-no-properties 1)) (t - (let ((tok (smie-default-backward-token))) + (let ((tok (sh-smie--default-backward-token))) (cond ;; ((equal tok ")") "case-)") ((and tok (string-match "\\`[a-z]" tok) From debbugs-submit-bounces@debbugs.gnu.org Tue Jul 08 14:56:54 2014 Received: (at control) by debbugs.gnu.org; 8 Jul 2014 18:56:54 +0000 Received: from localhost ([127.0.0.1]:47275 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1X4aZN-00069Q-NF for submit@debbugs.gnu.org; Tue, 08 Jul 2014 14:56:54 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.181]:63729) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1X4aZG-000694-QD for control@debbugs.gnu.org; Tue, 08 Jul 2014 14:56:47 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArQGAIDvNVNLd+D9/2dsb2JhbABZgwaDSsA9gRcXdIImAQUZPTM/EhQYDRgEiBTSGRePARaEIgSpGYFqg0wh X-IPAS-Result: ArQGAIDvNVNLd+D9/2dsb2JhbABZgwaDSsA9gRcXdIImAQUZPTM/EhQYDRgEiBTSGRePARaEIgSpGYFqg0wh X-IronPort-AV: E=Sophos;i="4.97,753,1389762000"; d="scan'208";a="76894755" Received: from 75-119-224-253.dsl.teksavvy.com (HELO pastel.home) ([75.119.224.253]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 08 Jul 2014 14:56:35 -0400 Received: by pastel.home (Postfix, from userid 20848) id B02F660337; Tue, 8 Jul 2014 14:56:35 -0400 (EDT) From: Stefan Monnier To: control@debbugs.gnu.org Subject: blbli Message-ID: References: <4750.1379508841@ES0871.esisar.inpg.fr> Date: Tue, 08 Jul 2014 14:56:35 -0400 In-Reply-To: <4750.1379508841@ES0871.esisar.inpg.fr> (Christophe Deleuze's message of "Wed, 18 Sep 2013 14:54:01 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.3 (/) close 17842 thanks From unknown Mon Aug 18 11:25:22 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Wed, 06 Aug 2014 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator