bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#21751: 24.5; Undesirable sh-mode indent


From: npostavs
Subject: bug#21751: 24.5; Undesirable sh-mode indent
Date: Sat, 26 Aug 2017 08:18:09 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2.50 (gnu/linux)

Bob Proulx <bob@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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]