From unknown Tue Jun 24 13:54:18 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#18031 <18031@debbugs.gnu.org> To: bug#18031 <18031@debbugs.gnu.org> Subject: Status: 24.3.92; bad indentation in shell script mode Reply-To: bug#18031 <18031@debbugs.gnu.org> Date: Tue, 24 Jun 2025 20:54:18 +0000 retitle 18031 24.3.92; bad indentation in shell script mode reassign 18031 emacs submitter 18031 Gilles Pion severity 18031 minor thanks From debbugs-submit-bounces@debbugs.gnu.org Wed Jul 16 08:08:58 2014 Received: (at submit) by debbugs.gnu.org; 16 Jul 2014 12:08:58 +0000 Received: from localhost ([127.0.0.1]:56201 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1X7O13-0005r8-Se for submit@debbugs.gnu.org; Wed, 16 Jul 2014 08:08:58 -0400 Received: from eggs.gnu.org ([208.118.235.92]:46081) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1X7O11-0005qu-Ke for submit@debbugs.gnu.org; Wed, 16 Jul 2014 08:08:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X7O0v-0000oW-9D for submit@debbugs.gnu.org; Wed, 16 Jul 2014 08:08:50 -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.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM, T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:55252) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X7O0v-0000oS-6L for submit@debbugs.gnu.org; Wed, 16 Jul 2014 08:08:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47803) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X7O0u-0000U7-29 for bug-gnu-emacs@gnu.org; Wed, 16 Jul 2014 08:08:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X7O0s-0000oG-W2 for bug-gnu-emacs@gnu.org; Wed, 16 Jul 2014 08:08:47 -0400 Received: from mail-qa0-x22f.google.com ([2607:f8b0:400d:c00::22f]:43268) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X7O0s-0000oC-RB for bug-gnu-emacs@gnu.org; Wed, 16 Jul 2014 08:08:46 -0400 Received: by mail-qa0-f47.google.com with SMTP id i13so606265qae.34 for ; Wed, 16 Jul 2014 05:08:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:from:date:message-id:subject:to:content-type; bh=7GGSTuW5Fuvd384djY3BPSTb0y+m8zHeybm4r+TjVPo=; b=EwbXUN5UymvhqCOxA8H8V2iNGLErZpctS2Zw0AhXymPhMerE2wH73PZVIbiwQVfpZI 3kVkqS/bnRk3iIPmAWnGybTexi0D51U/jBI8WW/Y0d0wrxsIBo7v5HfzqYPEkVGzCTLY jqhh7cA3XWWPIv4MlwXOVGWuAVffbPQlGp/z0Nlf3Kn1NoLXUUeUUNtrAPgRxwgpYknK 0XBkxvHVT5qU9Zm2oYhCff+J9dfJATxaaPYicOodmq6471dOiS5NqETKuu9ozsYoLZp6 I7ImVjc0oOYOZbMMNefDGMWl+p/squ1otLsTAVIkzqClKQ4wEw0GNGbNPZFTCVDglXBx RL/g== X-Received: by 10.224.98.145 with SMTP id q17mr44324782qan.97.1405512526232; Wed, 16 Jul 2014 05:08:46 -0700 (PDT) MIME-Version: 1.0 Received: by 10.224.60.196 with HTTP; Wed, 16 Jul 2014 05:08:26 -0700 (PDT) From: Gilles Pion Date: Wed, 16 Jul 2014 14:08:26 +0200 X-Google-Sender-Auth: znpB87zmPeuGRpThEItxDXZ1LRQ Message-ID: Subject: 24.3.92; bad indentation in shell script mode To: bug-gnu-emacs@gnu.org Content-Type: text/plain; charset=UTF-8 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). 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 (----) Actions to reproduce the bug: * lauch emacs in failsafe mode ("emacs -Q") * create a new buffer named "anythingyouwant.ksh" and insert the following lines ========= cut here =========== #!/bin/ksh grep -e "^$userregexp:" /etc/passwd | cut -d : -f 1 | while read user ; do print -u2 "user=$user" sudo -U $user -ll | while read line ; do : done done ========= cut here =========== * M-x shell-script-mode * M-x mark-whole-buffer * M-x indent-region Here's the result: #!/bin/ksh grep -e "^$userregexp:" /etc/passwd | cut -d : -f 1 | while read user ; do print -u2 "user=$user" sudo -U $user -ll | while read line ; do : done done In GNU Emacs 24.3.92.1 (powerpc-ibm-aix6.1.0.0, X toolkit) of 2014-07-01 on ax30001 Windowing system distributor `The Cygwin/X Project', version 11.0.11501000 Configured using: `configure --prefix=//opt/emacs-24.3.92 --exec-prefix=//opt/emacs-24.3.92 --sysconfdir=/etc//opt/emacs --localstatedir=/var//opt/emacs --without-all --with-x-toolkit=lucid --with-xpm --with-x-toolkit=lucid --enable-locallisppath=//share/emacs/site-lisp 'CFLAGS=-O3 -g3' 'CPPFLAGS=-I//opt/emacs-24.3.92/include -I/opt/freeware/include ' 'LDFLAGS=-L//opt/emacs-24.3.92/lib -Wl,-bstatic -L/opt/freeware/lib -lXpm -Wl,-bdynamic'' Important settings: value of $LANG: C locale-coding-system: iso-latin-1-unix Major mode: Shell-script Minor modes in effect: sh-electric-here-document-mode: t tooltip-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t Load-path shadows: None found. Features: (shadow sort gnus-util mail-extr emacsbug message format-spec rfc822 mml mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util help-fns mail-prsvr mail-utils help-mode easymenu sh-script smie executable dired time-date tooltip electric uniquify ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment lisp-mode prog-mode register page menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core frame cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer nadvice loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote make-network-process dynamic-setting x-toolkit x multi-tty emacs) Memory information: ((conses 8 87772 8428) (symbols 24 18605 0) (miscs 20 60 360) (strings 16 14441 4333) (string-bytes 1 359100) (vectors 8 10219) (vector-slots 4 413533 5420) (floats 8 67 336) (intervals 28 783 438) (buffers 512 16)) -- Gilles From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 04 10:10:03 2014 Received: (at 18031-done) by debbugs.gnu.org; 4 Dec 2014 15:10:03 +0000 Received: from localhost ([127.0.0.1]:53726 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XwY2c-0001t5-BW for submit@debbugs.gnu.org; Thu, 04 Dec 2014 10:10:03 -0500 Received: from ironport2-out.teksavvy.com ([206.248.154.181]:2487) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XwY2a-0001sk-5M for 18031-done@debbugs.gnu.org; Thu, 04 Dec 2014 10:10:01 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Am8PAOwQflRMCqTq/2dsb2JhbABbgweBK4I1hVrFHQQCAoEkFwEBAQEBAXyEAwEBAwFWIwULCw4mEhQYDSQTiDcJ1lkBAQEBAQEEAQEBAQEdkG8HhEgFiwGSMYZRiyyBeIQZITCCRwEBAQ X-IPAS-Result: Am8PAOwQflRMCqTq/2dsb2JhbABbgweBK4I1hVrFHQQCAoEkFwEBAQEBAXyEAwEBAwFWIwULCw4mEhQYDSQTiDcJ1lkBAQEBAQEEAQEBAQEdkG8HhEgFiwGSMYZRiyyBeIQZITCCRwEBAQ X-IronPort-AV: E=Sophos;i="5.07,502,1413259200"; d="scan'208";a="99548122" Received: from 76-10-164-234.dsl.teksavvy.com (HELO pastel.home) ([76.10.164.234]) by ironport2-out.teksavvy.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 04 Dec 2014 10:09:59 -0500 Received: by pastel.home (Postfix, from userid 20848) id 49359996B; Thu, 4 Dec 2014 10:09:59 -0500 (EST) From: Stefan Monnier To: Gilles Pion Subject: Re: bug#18031: 24.3.92; bad indentation in shell script mode Message-ID: References: Date: Thu, 04 Dec 2014 10:09:59 -0500 In-Reply-To: (Gilles Pion's message of "Wed, 16 Jul 2014 14:08:26 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 18031-done Cc: 18031-done@debbugs.gnu.org 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 (/) Version:24.5 > Here's the result: > #!/bin/ksh > grep -e "^$userregexp:" /etc/passwd | cut -d : -f 1 | while read user ; do > print -u2 > "user=$user" > sudo -U > $user -ll | while read line ; do > : > done > done After fixing the above line-wrapping to really reproduce what Emacs does, you'll see that it's indented in a way which is sensible: - The "print -u2" line is indented 4 chars deeper than the "while" in which it's nested. - The "user=$user" line is actually at the end of the previous line. - The "sudo" line is aligned with the previous line. - The ":" is indented 4 chars deeper than the "while" in which it's nested. - The "done" are aligned with the "while" they close. Now, I understand that "sensible" doesn't mean "good" or "desirable", but at least the indentation works sanely (contrary to the bug#18756 case). So it's a "small matter" of teaching sh-mode to indent the body of loops less deeply when the loop itself doesn't start at the beginning of the line. I installed the patch below which seems to do the trick. Stefan diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 12e5ef0..26b09a6 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2014-12-04 Stefan Monnier + + * progmodes/sh-script.el (sh-smie-sh-rules): Go back to the beginning + of the whole pipe when indenting an opening keyword after a |. + Generalize this treatment to opening keywords like "while" (bug#18031). + 2014-12-01 Stefan Monnier * simple.el (newline): Place the hook buffer-locally, diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index 724d22a..1165144 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -1988,12 +1988,12 @@ May return nil if the line should not be treated as continued." (and (numberp indent) (numberp initial) (<= indent initial))))) `(column . ,(+ initial sh-indentation))) - (`(:before . ,(or `"(" `"{" `"[")) + (`(:before . ,(or `"(" `"{" `"[" "while" "if" "for" "case")) (if (not (smie-rule-prev-p "&&" "||" "|")) (when (smie-rule-hanging-p) (smie-rule-parent)) (unless (smie-rule-bolp) - (smie-backward-sexp 'halfexp) + (while (equal "|" (nth 2 (smie-backward-sexp 'halfexp)))) `(column . ,(smie-indent-virtual))))) ;; FIXME: Maybe this handling of ;; should be made into ;; a smie-rule-terminator function that takes the substitute ";" as arg. From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 04 10:54:27 2014 Received: (at 18031-done) by debbugs.gnu.org; 4 Dec 2014 15:54:27 +0000 Received: from localhost ([127.0.0.1]:53759 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XwYjb-0002yj-DK for submit@debbugs.gnu.org; Thu, 04 Dec 2014 10:54:27 -0500 Received: from mx2.lfdj.com ([81.80.56.142]:50292) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XwYjY-0002ya-SL for 18031-done@debbugs.gnu.org; Thu, 04 Dec 2014 10:54:26 -0500 Content-Type: multipart/mixed; boundary="===============0018412818824595087==" MIME-Version: 1.0 Received: from unknown (HELO fire1.prod.fdj.fr) ([164.7.161.10]) by pme-2-smtpi.int.fdj.fr with ESMTP; 04 Dec 2014 16:54:23 +0100 Received: from babel.net.fdj.fr (notes6p1.prod.fdj.fr) by mail.net.fdj.fr (iPlanet Messaging Server 5.2 Patch 1 (built Aug 19 2002)) with ESMTP id <0NG200HKTEUM9N@mail.net.fdj.fr> for 18031-done@debbugs.gnu.org; Thu, 04 Dec 2014 16:54:22 +0100 (MET) Date: Thu, 04 Dec 2014 16:54:19 +0100 From: Gilles Pion Subject: Re: bug#18031: 24.3.92; bad indentation in shell script mode In-reply-to: To: Stefan Monnier Message-id: MIME-version: 1.0 X-Mailer: Lotus Notes Release 8.5.3FP3 November 16, 2012 X-MIMETrack: Serialize by Router on Babel/FDJ(Release 8.5.3FP6HF1017 | October 31, 2014) at 04/12/2014 16:54:21, Serialize complete at 04/12/2014 16:54:21 X-KeepSent: FD8BBD8E:2C012369-C1257DA4:00572573; type=4; name=$KeepSent References: X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 18031-done Cc: 18031-done@debbugs.gnu.org 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.0 (/) --===============0018412818824595087== Content-type: multipart/alternative; boundary="Boundary_(ID_0tmYx7ksrm6N7ponMotpPg)" Message en plusieurs parties au format MIME --Boundary_(ID_0tmYx7ksrm6N7ponMotpPg) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Thanks! Applied and tested: this fix works just fine. -- Gilles --Boundary_(ID_0tmYx7ksrm6N7ponMotpPg) Content-type: text/html; charset=US-ASCII Content-transfer-encoding: 7BIT Thanks!

Applied and tested: this fix works just fine.

--
Gilles --Boundary_(ID_0tmYx7ksrm6N7ponMotpPg)-- --===============0018412818824595087== Content-Type: multipart/alternative; boundary="===============5615868226294644002==" MIME-Version: 1.0 Content-Disposition: inline --===============5615868226294644002== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Si vous n=E2=80=99=C3=AAtes pas destinataires de ce message, merci d=E2=80= =99avertir l=E2=80=99exp=C3=A9diteur de l=E2=80=99erreur de distribution et= de le d=C3=A9truire imm=C3=A9diatement. Ce message contient des informatio= ns confidentielles ou appartement =C3=A0 la Fran=C3=A7aise des jeux. Il est= =C3=A9tabli =C3=A0 l=E2=80=99intention exclusive de ses destinataires. Tou= te divulgation, utilisation, diffusion ou reproduction (totale ou partielle= ) de ce message ou des informations qu=E2=80=99il contient, doit =C3=AAtre = pr=C3=A9alablement autoris=C3=A9e. Tout message =C3=A9lectronique est susce= ptible d=E2=80=99alt=C3=A9ration et son int=C3=A9grit=C3=A9 ne peut =C3=AAt= re assure. La Fran=C3=A7aise des Jeux d=C3=A9cline toute responsabilit=C3= =A9 au titre de ce message s=E2=80=99il a =C3=A9t=C3=A9 modifi=C3=A9 ou fal= sifi=C3=A9. --===============5615868226294644002== Content-Type: text/html; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable

Si vous n=E2=80=99=C3=AAtes pas destinataires de ce message, merci d=E2= =80=99avertir l=E2=80=99exp=C3=A9diteur de l=E2=80=99erreur de distribution= et de le d=C3=A9truire imm=C3=A9diatement. Ce message contient des informa= tions confidentielles ou appartement =C3=A0 la Fran=C3=A7aise des jeux. Il = est =C3=A9tabli =C3=A0 l=E2=80=99intention exclusive de ses destinataires. = Toute divulgation, utilisation, diffusion ou reproduction (totale ou partie= lle) de ce message ou des informations qu=E2=80=99il contient, doit =C3=AAt= re pr=C3=A9alablement autoris=C3=A9e. Tout message =C3=A9lectronique est su= sceptible d=E2=80=99alt=C3=A9ration et son int=C3=A9grit=C3=A9 ne peut =C3= =AAtre assure. La Fran=C3=A7aise des Jeux d=C3=A9cline toute responsabilit= =C3=A9 au titre de ce message s=E2=80=99il a =C3=A9t=C3=A9 modifi=C3=A9 ou = falsifi=C3=A9.

--===============5615868226294644002==-- --===============0018412818824595087==-- From unknown Tue Jun 24 13:54:18 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 02 Jan 2015 12: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