GNU bug report logs -
#21751
24.5; Undesirable sh-mode indent
Previous Next
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.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 21751 in the body.
You can then email your comments to 21751 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#21751
; Package
emacs
.
(Sat, 24 Oct 2015 19:06:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Bob Proulx <bob <at> proulx.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Sat, 24 Oct 2015 19:06:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
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.
Thanks,
Bob
In GNU Emacs 24.5.1 (x86_64-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
of 2015-09-19 on trouble, modified by Debian
System Description: Debian GNU/Linux unstable (sid)
Configured using:
`configure --build x86_64-linux-gnu --prefix=/usr
--sharedstatedir=/var/lib --libexecdir=/usr/lib
--localstatedir=/var/lib --infodir=/usr/share/info
--mandir=/usr/share/man --with-pop=yes
--enable-locallisppath=/etc/emacs24:/etc/emacs:/usr/local/share/emacs/24.5/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.5/site-lisp:/usr/share/emacs/site-lisp
--build x86_64-linux-gnu --prefix=/usr --sharedstatedir=/var/lib
--libexecdir=/usr/lib --localstatedir=/var/lib
--infodir=/usr/share/info --mandir=/usr/share/man --with-pop=yes
--enable-locallisppath=/etc/emacs24:/etc/emacs:/usr/local/share/emacs/24.5/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.5/site-lisp:/usr/share/emacs/site-lisp
--with-x=yes --with-x-toolkit=lucid --with-toolkit-scroll-bars
--without-gconf --without-gsettings 'CFLAGS=-g -O2
-fstack-protector-strong -Wformat -Werror=format-security -Wall'
CPPFLAGS=-D_FORTIFY_SOURCE=2 LDFLAGS=-Wl,-z,relro'
Important settings:
value of $LC_COLLATE: C
value of $LANG: en_US.UTF-8
locale-coding-system: utf-8-unix
Major mode: Fundamental
Minor modes in effect:
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
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
buffer-read-only: t
line-number-mode: t
transient-mark-mode: t
Recent messages:
Loading /etc/emacs/site-start.d/51debian-el.el (source)...done
Loading /etc/emacs/site-start.d/51planner-el.el (source)...
Loading /usr/share/emacs24/site-lisp/planner-el/planner-autoloads.el (source)...done
Loading /etc/emacs/site-start.d/51planner-el.el (source)...done
Loading /etc/emacs/site-start.d/52remember-el.el (source)...
Loading /usr/share/emacs/site-lisp/remember-el/remember-autoloads.el (source)...done
Loading /etc/emacs/site-start.d/52remember-el.el (source)...done
For information about GNU Emacs and the GNU system, type C-h C-a.
e is undefined
p is undefined
Load-path shadows:
/usr/share/emacs24/site-lisp/css-mode/css-mode hides /usr/share/emacs/site-lisp/css-mode/css-mode
/usr/share/emacs24/site-lisp/cmake-data/cmake-mode hides /usr/share/emacs/site-lisp/cmake-mode
/usr/share/emacs/24.5/site-lisp/debian-startup hides /usr/share/emacs/site-lisp/debian-startup
/usr/share/emacs24/site-lisp/flim/hex-util hides /usr/share/emacs/24.5/lisp/hex-util
/usr/share/emacs24/site-lisp/flim/md4 hides /usr/share/emacs/24.5/lisp/md4
/usr/share/emacs24/site-lisp/css-mode/css-mode hides /usr/share/emacs/24.5/lisp/textmodes/css-mode
/usr/share/emacs/site-lisp/remember-el/remember hides /usr/share/emacs/24.5/lisp/textmodes/remember
/usr/share/emacs24/site-lisp/flim/sasl-cram hides /usr/share/emacs/24.5/lisp/net/sasl-cram
/usr/share/emacs24/site-lisp/flim/ntlm hides /usr/share/emacs/24.5/lisp/net/ntlm
/usr/share/emacs24/site-lisp/flim/sasl-ntlm hides /usr/share/emacs/24.5/lisp/net/sasl-ntlm
/usr/share/emacs24/site-lisp/flim/sasl hides /usr/share/emacs/24.5/lisp/net/sasl
/usr/share/emacs24/site-lisp/flim/hmac-md5 hides /usr/share/emacs/24.5/lisp/net/hmac-md5
/usr/share/emacs24/site-lisp/flim/sasl-digest hides /usr/share/emacs/24.5/lisp/net/sasl-digest
/usr/share/emacs24/site-lisp/flim/hmac-def hides /usr/share/emacs/24.5/lisp/net/hmac-def
/usr/share/emacs24/site-lisp/erc/erc-ring hides /usr/share/emacs/24.5/lisp/erc/erc-ring
/usr/share/emacs24/site-lisp/erc/erc-truncate hides /usr/share/emacs/24.5/lisp/erc/erc-truncate
/usr/share/emacs24/site-lisp/erc/erc-match hides /usr/share/emacs/24.5/lisp/erc/erc-match
/usr/share/emacs24/site-lisp/erc/erc-autoaway hides /usr/share/emacs/24.5/lisp/erc/erc-autoaway
/usr/share/emacs24/site-lisp/erc/erc-button hides /usr/share/emacs/24.5/lisp/erc/erc-button
/usr/share/emacs24/site-lisp/erc/erc-goodies hides /usr/share/emacs/24.5/lisp/erc/erc-goodies
/usr/share/emacs24/site-lisp/erc/erc-notify hides /usr/share/emacs/24.5/lisp/erc/erc-notify
/usr/share/emacs24/site-lisp/erc/erc-backend hides /usr/share/emacs/24.5/lisp/erc/erc-backend
/usr/share/emacs24/site-lisp/erc/erc-xdcc hides /usr/share/emacs/24.5/lisp/erc/erc-xdcc
/usr/share/emacs24/site-lisp/erc/erc-join hides /usr/share/emacs/24.5/lisp/erc/erc-join
/usr/share/emacs24/site-lisp/erc/erc-pcomplete hides /usr/share/emacs/24.5/lisp/erc/erc-pcomplete
/usr/share/emacs24/site-lisp/erc/erc-identd hides /usr/share/emacs/24.5/lisp/erc/erc-identd
/usr/share/emacs24/site-lisp/erc/erc-stamp hides /usr/share/emacs/24.5/lisp/erc/erc-stamp
/usr/share/emacs24/site-lisp/erc/erc-page hides /usr/share/emacs/24.5/lisp/erc/erc-page
/usr/share/emacs24/site-lisp/erc/erc hides /usr/share/emacs/24.5/lisp/erc/erc
/usr/share/emacs24/site-lisp/erc/erc-sound hides /usr/share/emacs/24.5/lisp/erc/erc-sound
/usr/share/emacs24/site-lisp/erc/erc-replace hides /usr/share/emacs/24.5/lisp/erc/erc-replace
/usr/share/emacs24/site-lisp/erc/erc-log hides /usr/share/emacs/24.5/lisp/erc/erc-log
/usr/share/emacs24/site-lisp/erc/erc-track hides /usr/share/emacs/24.5/lisp/erc/erc-track
/usr/share/emacs24/site-lisp/erc/erc-imenu hides /usr/share/emacs/24.5/lisp/erc/erc-imenu
/usr/share/emacs24/site-lisp/erc/erc-capab hides /usr/share/emacs/24.5/lisp/erc/erc-capab
/usr/share/emacs24/site-lisp/erc/erc-lang hides /usr/share/emacs/24.5/lisp/erc/erc-lang
/usr/share/emacs24/site-lisp/erc/erc-services hides /usr/share/emacs/24.5/lisp/erc/erc-services
/usr/share/emacs24/site-lisp/erc/erc-ezbounce hides /usr/share/emacs/24.5/lisp/erc/erc-ezbounce
/usr/share/emacs24/site-lisp/erc/erc-speedbar hides /usr/share/emacs/24.5/lisp/erc/erc-speedbar
/usr/share/emacs24/site-lisp/erc/erc-spelling hides /usr/share/emacs/24.5/lisp/erc/erc-spelling
/usr/share/emacs24/site-lisp/erc/erc-list hides /usr/share/emacs/24.5/lisp/erc/erc-list
/usr/share/emacs24/site-lisp/erc/erc-dcc hides /usr/share/emacs/24.5/lisp/erc/erc-dcc
/usr/share/emacs24/site-lisp/erc/erc-menu hides /usr/share/emacs/24.5/lisp/erc/erc-menu
/usr/share/emacs24/site-lisp/erc/erc-netsplit hides /usr/share/emacs/24.5/lisp/erc/erc-netsplit
/usr/share/emacs24/site-lisp/erc/erc-networks hides /usr/share/emacs/24.5/lisp/erc/erc-networks
/usr/share/emacs24/site-lisp/erc/erc-compat hides /usr/share/emacs/24.5/lisp/erc/erc-compat
/usr/share/emacs24/site-lisp/erc/erc-fill hides /usr/share/emacs/24.5/lisp/erc/erc-fill
/usr/share/emacs24/site-lisp/erc/erc-ibuffer hides /usr/share/emacs/24.5/lisp/erc/erc-ibuffer
/usr/share/emacs24/site-lisp/erc/erc-hecomplete hides /usr/share/emacs/24.5/lisp/obsolete/erc-hecomplete
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 xterm time-date info easymenu package
epg-config remember-autoloads planner-autoloads debian-el
debian-el-loaddefs w3m-load muse-autoloads erc-auto jabber-autoloads
emacs-goodies-el emacs-goodies-custom emacs-goodies-loaddefs easy-mmode
dpkg-dev-el dpkg-dev-el-loaddefs dash-functional dash bbdb-autoloads
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
dbusbind gfilenotify dynamic-setting font-render-setting x-toolkit x
multi-tty emacs)
Memory information:
((conses 16 94821 5787)
(symbols 48 19910 0)
(miscs 40 70 107)
(strings 32 16043 5285)
(string-bytes 1 503690)
(vectors 16 8494)
(vector-slots 8 355157 20689)
(floats 8 68 293)
(intervals 56 221 0)
(buffers 960 12)
(heap 1024 23801 864))
Forcibly Merged 21751 23004.
Request was from
npostavs <at> users.sourceforge.net
to
control <at> debbugs.gnu.org
.
(Sun, 03 Jul 2016 01:09:01 GMT)
Full text and
rfc822 format available.
Forcibly Merged 21751 23004 24337.
Request was from
Alex <agrambot <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Fri, 09 Sep 2016 17:19:01 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#21751
; Package
emacs
.
(Sat, 26 Aug 2017 12:17:01 GMT)
Full text and
rfc822 format available.
Message #12 received at 21751 <at> debbugs.gnu.org (full text, mbox):
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
Added tag(s) confirmed.
Request was from
npostavs <at> users.sourceforge.net
to
control <at> debbugs.gnu.org
.
(Sat, 26 Aug 2017 12:18:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#21751
; Package
emacs
.
(Wed, 30 Aug 2017 23:49:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 21751 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
tags 21751 + patch
quit
npostavs <at> users.sourceforge.net writes:
> I guess sh-indentation should be made into an obsolete alias for
> sh-basic-offset?
Here's a patch
[v1-0001-Make-sh-indentation-into-an-alias-for-sh-basic-of.patch (text/x-diff, inline)]
From 2205b597476083579bd3e50b20bc2ce42ca54520 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs <at> gmail.com>
Date: Wed, 30 Aug 2017 19:42:47 -0400
Subject: [PATCH v1] Make sh-indentation into an alias for sh-basic-offset
(Bug#21751)
* lisp/progmodes/sh-script.el (sh-indentation): Redefine as obsolete
variable alias for `sh-basic-offset'.
(sh-mode, sh-smie--indent-continuation)
(sh-smie-rc-rules, sh-basic-indent-line): Replace `sh-indentation'
with `sh-basic-offset'.
---
lisp/progmodes/sh-script.el | 26 +++++++++++---------------
1 file changed, 11 insertions(+), 15 deletions(-)
diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el
index ca31635dbc..2cf7e15540 100644
--- a/lisp/progmodes/sh-script.el
+++ b/lisp/progmodes/sh-script.el
@@ -593,11 +593,7 @@ sh-assignment-regexp
(sexp :format "Evaluate: %v"))))
:group 'sh-script)
-
-(defcustom sh-indentation 4
- "The width for further indentation in Shell-Script mode."
- :type 'integer
- :group 'sh-script)
+(define-obsolete-variable-alias 'sh-indentation 'sh-basic-offset "26.1")
(put 'sh-indentation 'safe-local-variable 'integerp)
(defcustom sh-remember-variable-min 3
@@ -1623,7 +1619,7 @@ sh-mode
(setq-local skeleton-pair-alist '((?` _ ?`)))
(setq-local skeleton-pair-filter-function 'sh-quoted-p)
(setq-local skeleton-further-elements
- '((< '(- (min sh-indentation (current-column))))))
+ '((< '(- (min sh-basic-offset (current-column))))))
(setq-local skeleton-filter-function 'sh-feature)
(setq-local skeleton-newline-indent-rigidly t)
(setq-local defun-prompt-regexp
@@ -2018,7 +2014,7 @@ sh-smie--indent-continuation
(forward-line -1)
(if (sh-smie--looking-back-at-continuation-p)
(current-indentation)
- (+ (current-indentation) sh-indentation))))
+ (+ (current-indentation) sh-basic-offset))))
(t
;; Just make sure a line-continuation is indented deeper.
(save-excursion
@@ -2039,13 +2035,13 @@ sh-smie--indent-continuation
;; check the line before that one.
(> ci indent))
(t ;Previous line is the beginning of the continued line.
- (setq indent (min (+ ci sh-indentation) max))
+ (setq indent (min (+ ci sh-basic-offset) max))
nil)))))
indent))))))
(defun sh-smie-sh-rules (kind token)
(pcase (cons kind token)
- (`(:elem . basic) sh-indentation)
+ (`(:elem . basic) sh-basic-offset)
(`(:after . "case-)") (- (sh-var-value 'sh-indent-for-case-alt)
(sh-var-value 'sh-indent-for-case-label)))
(`(:before . ,(or `"(" `"{" `"[" "while" "if" "for" "case"))
@@ -2254,8 +2250,8 @@ sh-smie-rc-backward-token
(defun sh-smie-rc-rules (kind token)
(pcase (cons kind token)
- (`(:elem . basic) sh-indentation)
- ;; (`(:after . "case") (or sh-indentation smie-indent-basic))
+ (`(:elem . basic) sh-basic-offset)
+ ;; (`(:after . "case") (or sh-basic-offset smie-indent-basic))
(`(:after . ";")
(if (smie-rule-parent-p "case")
(smie-rule-parent (sh-var-value 'sh-indent-after-case))))
@@ -2496,7 +2492,7 @@ sh-modify
(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'.
+Indent as far as preceding non-empty line, then by steps of `sh-basic-offset'.
Lines containing only comments are considered empty."
(interactive)
(let ((previous (save-excursion
@@ -2520,9 +2516,9 @@ sh-basic-indent-line
(delete-region (point)
(progn (beginning-of-line) (point)))
(if (eolp)
- (max previous (* (1+ (/ current sh-indentation))
- sh-indentation))
- (* (1+ (/ current sh-indentation)) sh-indentation))))))
+ (max previous (* (1+ (/ current sh-basic-offset))
+ sh-basic-offset))
+ (* (1+ (/ current sh-basic-offset)) sh-basic-offset))))))
(if (< (current-column) (current-indentation))
(skip-chars-forward " \t"))))
--
2.14.1
Added tag(s) patch.
Request was from
npostavs <at> users.sourceforge.net
to
control <at> debbugs.gnu.org
.
(Wed, 30 Aug 2017 23:49:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#21751
; Package
emacs
.
(Sat, 02 Sep 2017 12:58:02 GMT)
Full text and
rfc822 format available.
Message #22 received at 21751 <at> debbugs.gnu.org (full text, mbox):
> From: npostavs <at> users.sourceforge.net
> Date: Wed, 30 Aug 2017 19:50:30 -0400
> Cc: Phil <p.stephani2 <at> gmail.com>, Oleksandr Gavenko <gavenkoa <at> gmail.com>,
> 21751 <at> debbugs.gnu.org
>
> > I guess sh-indentation should be made into an obsolete alias for
> > sh-basic-offset?
>
> Here's a patch
Thanks. If there are no objections in a few days, please push.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#21751
; Package
emacs
.
(Mon, 25 Sep 2017 23:44:03 GMT)
Full text and
rfc822 format available.
Message #25 received at 21751 <at> debbugs.gnu.org (full text, mbox):
tags 21751 fixed
close 21751 26.1
quit
Eli Zaretskii <eliz <at> gnu.org> writes:
>> > I guess sh-indentation should be made into an obsolete alias for
>> > sh-basic-offset?
>>
>> Here's a patch
>
> Thanks. If there are no objections in a few days, please push.
It's more than a few days (I was travelling, and then waiting to see if
anything unexpected would turn up from Bug#24848), but pushed to
emacs-26 now.
[1: f5e72b04d9]: 2017-09-25 19:39:19 -0400
Make sh-indentation into an alias for sh-basic-offset (Bug#21751)
http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=f5e72b04d930215f6e770e2fe9e02ad6debf03ad
Added tag(s) fixed.
Request was from
Noam Postavsky <npostavs <at> users.sourceforge.net>
to
control <at> debbugs.gnu.org
.
(Mon, 25 Sep 2017 23:44:04 GMT)
Full text and
rfc822 format available.
bug marked as fixed in version 26.1, send any further explanations to
21751 <at> debbugs.gnu.org and Bob Proulx <bob <at> proulx.com>
Request was from
Noam Postavsky <npostavs <at> users.sourceforge.net>
to
control <at> debbugs.gnu.org
.
(Mon, 25 Sep 2017 23:44:04 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Tue, 24 Oct 2017 11:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 6 years and 187 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.