GNU bug report logs - #23004
24.5; Why double intent do sh-script.el after "then" statement?

Previous Next

Package: emacs;

Reported by: Oleksandr Gavenko <gavenkoa <at> gmail.com>

Date: Sun, 13 Mar 2016 09:35:01 UTC

Severity: normal

Tags: confirmed, fixed, patch

Merged with 21751, 24337

Found in versions 24.5, 25.1

Fixed in version 26.1

Done: Noam Postavsky <npostavs <at> users.sourceforge.net>

Bug is archived. No further changes may be made.

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Oleksandr Gavenko <gavenkoa <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.5; Why double intent do sh-script.el after "then" statement?
Date: Sun, 13 Mar 2016 11:34:07 +0200
In GNU Emacs 24.5.1 (x86_64-pc-linux-gnu, GTK+ Version 3.18.2)
 of 2015-10-24 on trouble, modified by Debian
Windowing system distributor `The X.Org Foundation', version 11.0.11702000
System Description:	Debian GNU/Linux testing (stretch)

  $ emacs -q

  M-x sh-mode RET
  M-: (setq sh-basic-offset 2) RET

  if true; then
      <==TAB  4 spaces!!
  else
    <==TAB  2 spaces
  fi

  if true;
  then
      <==TAB  4 spaces!!
  fi

With default 4 offset indent proper after "then" and "else", but changing
`sh-basic-offset' doesn't effect on indent level after "then".

I check:

  /usr/share/emacs/24.5/lisp/progmodes/sh-script.el.gz

  (defun sh-smie-sh-rules (kind token)
    ....
    ;; 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))
    (`(:after . "else") (sh-var-value 'sh-indent-after-else))
    (`(:after . "if") (sh-var-value 'sh-indent-after-if))
    (`(:before . "then") (sh-var-value 'sh-indent-for-then))
    (`(:before . "do") (sh-var-value 'sh-indent-for-do))
    (`(:after . "do")
     (sh-var-value (if (smie-rule-hanging-p)
                       'sh-indent-after-loop-construct 'sh-indent-after-do)))
    ;; sh-indent-after-done: aligned completely differently.
    (`(:after . "in") (sh-var-value 'sh-indent-for-case-label))
    ;; sh-indent-for-continuation: Line continuations are handled differently.
    (`(:after . ,(or `"(" `"{" `"[")) (sh-var-value 'sh-indent-after-open))

I see no (:after . "then") but:

    (`(:after . "else") (sh-var-value 'sh-indent-after-else))
    (`(:before . "then") (sh-var-value 'sh-indent-for-then))

I would like to control indenting after "then" statement. Please add
customisation:

  (defcustom sh-indent-after-then '+
    "How much to indent a statement after an `then' statement."
    :type `(choice ,@ sh-number-or-symbol-list )
    :group 'sh-indentation)

-- 
http://defun.work/




This bug report was last modified 7 years and 241 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.