GNU bug report logs - #21751
24.5; Undesirable sh-mode indent

Previous Next

Package: emacs;

Reported by: Bob Proulx <bob <at> proulx.com>

Date: Sat, 24 Oct 2015 19:06:02 UTC

Severity: normal

Tags: confirmed, fixed, patch

Merged with 23004, 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


View this message in rfc822 format

From: npostavs <at> users.sourceforge.net
To: Bob Proulx <bob <at> proulx.com>, Oleksandr Gavenko <gavenkoa <at> gmail.com>, Phil <p.stephani2 <at> gmail.com>
Cc: 21751 <at> debbugs.gnu.org
Subject: bug#21751: 24.5; Undesirable sh-mode indent
Date: Sat, 26 Aug 2017 08:18:09 -0400
Bob Proulx <bob <at> proulx.com> writes:

> In 24.5.1 from Debian Sid I am now getting an undesirable indent that
> is no longer controlled by sh-basic-offset.  In 23 this worked.
>
> emacs -Q /tmp/trial.sh
>
> M-: (setq sh-basic-offset 2)
>
> if true; then
>     true
>     ^ indent should be 2 not 4 here
>
> C-c ?
> Rules used: :elem basic -> 4, :before "then" -> 0, :after "then" -> nil
>
> Anyone know what is happening here?  I have reviewed the NEWS and the
> latest manual but I didn't find any intentionally noted changes.

Doing M-: (setq sh-indentation 2 sh-basic-offset 2) gives the expected
result.  The smie indentation code is using sh-indentation for
default/basic offset, and sh-basic-offset indirectly for other offsets.
I'm not sure why both sh-indentation and sh-basic-offset exist
(sh-basic-offset was added in [1: f964dfcb0d], sh-indentation in [2:
133693bc90]).  The only other place that uses sh-indentation is
sh-basic-indent-line (which is only used for shells lacking any
indentation rules).  I guess sh-indentation should be made into an
obsolete alias for sh-basic-offset?

    (defcustom sh-basic-offset 4
      "The default indentation increment.
    This value is used for the `+' and `-' symbols in an indentation variable."

    (defcustom sh-indentation 4
      "The width for further indentation in Shell-Script mode."

    (defun sh-basic-indent-line ()
      "Indent a line for Sh mode (shell script mode).
    Indent as far as preceding non-empty line, then by steps of `sh-indentation'.

    (defun sh-set-shell (shell &optional no-query-flag insert-flag)
      "Set this buffer's shell to SHELL (a string)."
      ...
      (if (setq-local sh-indent-supported-here
                      (sh-feature sh-indent-supported))
          (progn
            (message "Setting up indent for shell type %s" sh-shell)
            ...)
        (message "No indentation for this shell type.")
        (setq-local indent-line-function 'sh-basic-indent-line)))

[1: f964dfcb0d]: 1999-10-12 12:30:38 +0000
  Added support for indenting existing scripts.
  http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=f964dfcb0d9dca156cbb29009bf4e399828f9b13

[2: 133693bc90]: 1995-07-07 19:48:24 +0000
  restructured, largely rewritten without the bugs and extended to cover over 15 shells.
  http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=133693bc904830ab88908d7f9806326543264f24




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

Previous Next


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