unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#18756: 24.4; shell-script-mode does wrong indentation
@ 2014-10-17 19:36 Daniel Daboul
  2014-10-17 22:35 ` Glenn Morris
                   ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: Daniel Daboul @ 2014-10-17 19:36 UTC (permalink / raw)
  To: 18756

[-- Attachment #1: Type: text/plain, Size: 2721 bytes --]

M-x shell-script-mode<Enter>
#hi<Enter>
ls<Enter>
x-3<Enter>

With every <Enter> key-press the current line gets indeted, so that
the buffer looks like:
    #hi
        ls
            x=3

<Tab> also mis-behaves. Emacs 24.3.1, OTOH, works fine for me.



In GNU Emacs 24.4.1 (x86_64-unknown-linux-gnu, X toolkit, Xaw3d scroll bars)
 of 2014-10-17 on icsl5123
System Description:    SUSE Linux Enterprise Server 10 (x86_64)

Configured using:
 `configure --prefix=/nfs/iil/home/ddaboul/r/sles10 --with-gif=no
 --without-pop --without-sound --without-gpm --without-dbus
 --with-x-toolkit=lucid'

Important settings:
  value of $LC_COLLATE: C
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-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
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
ESC [ > 0 ; 2 0 8 ; 0 c ESC x s h e l l - s c r i p
t - m o d e RET # h i RET l s RET x = 3 RET ESC x r
e p o r t - e m a c s - b u g RET

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
No indentation for this shell type.

Load-path shadows:
None found.

Features:
(shadow sort gnus-util mail-extr emacsbug message format-spec rfc822 mml
easymenu 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 sh-script smie executable xterm
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 16 83253 3991)
 (symbols 48 18103 0)
 (miscs 40 31 113)
 (strings 32 12327 4537)
 (string-bytes 1 361598)
 (vectors 16 7894)
 (vector-slots 8 361363 27987)
 (floats 8 63 284)
 (intervals 56 186 0)
 (buffers 960 11)
 (heap 1024 8017 572))

[-- Attachment #2: Type: text/html, Size: 3113 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* bug#18756: 24.4; shell-script-mode does wrong indentation
  2014-10-17 19:36 bug#18756: 24.4; shell-script-mode does wrong indentation Daniel Daboul
@ 2014-10-17 22:35 ` Glenn Morris
  2014-10-18 18:49   ` Daniel Daboul
  2014-12-04  8:06 ` Gilles Pion
  2014-12-22 20:34 ` bug#18756: Peter Oliver
  2 siblings, 1 reply; 19+ messages in thread
From: Glenn Morris @ 2014-10-17 22:35 UTC (permalink / raw)
  To: Daniel Daboul; +Cc: 18756

Daniel Daboul wrote:

> M-x shell-script-mode<Enter>
> #hi<Enter>
> ls<Enter>
> x-3<Enter>
>
> With every <Enter> key-press the current line gets indeted, so that
> the buffer looks like:
>     #hi
>         ls
>             x=3

I cannot reproduce this with `emacs -Q'.

(Since you reported this twice, I will delete the other bug, #18755)





^ permalink raw reply	[flat|nested] 19+ messages in thread

* bug#18756: 24.4; shell-script-mode does wrong indentation
  2014-10-17 22:35 ` Glenn Morris
@ 2014-10-18 18:49   ` Daniel Daboul
  2014-10-19 17:37     ` Glenn Morris
  0 siblings, 1 reply; 19+ messages in thread
From: Daniel Daboul @ 2014-10-18 18:49 UTC (permalink / raw)
  Cc: 18756

[-- Attachment #1: Type: text/plain, Size: 1011 bytes --]

On Sat, Oct 18, 2014 at 1:35 AM, Glenn Morris <rgm@gnu.org> wrote:

>
> I cannot reproduce this with `emacs -Q'.
>
> (Since you reported this twice, I will delete the other bug, #18755)
>

1. Thank you for deleting the duplicate. I thought my first e-mail
didn't make it.

2. I also used "src/emacs-24.4.1 -Q" or
"src/emacs-24.4.1 -Q -nw", which makes no difference for this problem.

3. However, I get the buggy behavior only on
"SUSE Linux Enterprise Server"  version 10 and 11 (sles10, sles11).
Today I compiled emacs on a "Debian testing" system, where I do
not see the problem.

4. While trying more, I noticed that this is actually not a problem
specific to the shell-mode. It similarly happens in fundamental mode
(but again only on SUSE). So if I type in an empty buffer in
"Fundamental" mode:
1<return>2<return>3<return>4<return>

... I end up with this:
(4 spaces)1
(1 tab)2
(1 tab,4 spaces)3
(2 tabs)4

5. Can someone suggest how to debug this further or find a local fix?

With best regards, Daniel

[-- Attachment #2: Type: text/html, Size: 2046 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* bug#18756: 24.4; shell-script-mode does wrong indentation
  2014-10-18 18:49   ` Daniel Daboul
@ 2014-10-19 17:37     ` Glenn Morris
  2014-10-19 18:35       ` Daniel Daboul
  0 siblings, 1 reply; 19+ messages in thread
From: Glenn Morris @ 2014-10-19 17:37 UTC (permalink / raw)
  To: Daniel Daboul; +Cc: 18756

Daniel Daboul wrote:

> 3. However, I get the buggy behavior only on
> "SUSE Linux Enterprise Server"  version 10 and 11 (sles10, sles11).
> Today I compiled emacs on a "Debian testing" system, where I do
> not see the problem.

I have no idea how a problem like this could be OS-specific.

You are definitely running the same version of Emacs on both systems,
with no local changes, and no .emacs etc issues?





^ permalink raw reply	[flat|nested] 19+ messages in thread

* bug#18756: 24.4; shell-script-mode does wrong indentation
  2014-10-19 17:37     ` Glenn Morris
@ 2014-10-19 18:35       ` Daniel Daboul
  2014-10-20  5:35         ` Glenn Morris
  0 siblings, 1 reply; 19+ messages in thread
From: Daniel Daboul @ 2014-10-19 18:35 UTC (permalink / raw)
  Cc: 18756

[-- Attachment #1: Type: text/plain, Size: 848 bytes --]

On Sun, Oct 19, 2014 at 8:37 PM, Glenn Morris wrote:

> You are definitely running the same version of Emacs on both systems,
> with no local changes, and no .emacs etc issues?
>

Yes, I just downloaded the package you announced
ftp://alpha.gnu.org/gnu/emacs/pretest/emacs-24.4-rc1.tar.xz

and then basically ran ...
../emacs-24.4/configure --prefix=$HOME/r/$VER \
  --with-gif=no --without-pop --without-sound --without-gpm --without-dbus
--with-x-toolkit=lucid
I also made a version with
  --without-x \

make
src/emacs-24.4.1 -Q
src/emacs-24.4.1 -Q -nw

... which, AFAIK, excludes all local configuration files.

BTW, I had seen the problem earlier in some of the 24.3.9x versions
which I tried. But back than, I ignored it, hoping for the best.

I am now using 24.3.1 on Suse which runs fine and which I also
configured as similar as possible.

[-- Attachment #2: Type: text/html, Size: 1397 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* bug#18756: 24.4; shell-script-mode does wrong indentation
  2014-10-19 18:35       ` Daniel Daboul
@ 2014-10-20  5:35         ` Glenn Morris
  2014-10-20 13:59           ` Alexis
  0 siblings, 1 reply; 19+ messages in thread
From: Glenn Morris @ 2014-10-20  5:35 UTC (permalink / raw)
  To: Daniel Daboul; +Cc: 18756


Sorry, no idea.

Anyone?





^ permalink raw reply	[flat|nested] 19+ messages in thread

* bug#18756: 24.4; shell-script-mode does wrong indentation
  2014-10-20  5:35         ` Glenn Morris
@ 2014-10-20 13:59           ` Alexis
  2014-10-20 15:20             ` Eli Zaretskii
  0 siblings, 1 reply; 19+ messages in thread
From: Alexis @ 2014-10-20 13:59 UTC (permalink / raw)
  To: 18756


Glenn Morris writes:

> Sorry, no idea.
>
> Anyone?

Superficially, it looks like return/enter is only sending a line feed,
not a line feed + carriage return[1]; i wonder if there's some SLES setting
influencing this?

(Sometimes after exiting from Emacs back into a shell - zsh on Debian
Wheezy - i observe similar behaviour from the shell, i.e. output seems
to no longer include carriage returns, only line feeds. But i've not
been able to reproduce this reliably.)

[1] In terms of cursor position, not necessarily actual \l and \r
characters.





^ permalink raw reply	[flat|nested] 19+ messages in thread

* bug#18756: 24.4; shell-script-mode does wrong indentation
  2014-10-20 13:59           ` Alexis
@ 2014-10-20 15:20             ` Eli Zaretskii
  2014-10-20 16:13               ` Daniel Daboul
  0 siblings, 1 reply; 19+ messages in thread
From: Eli Zaretskii @ 2014-10-20 15:20 UTC (permalink / raw)
  To: Alexis, Daniel Daboul; +Cc: 18756

> Resent-Sender: help-debbugs@gnu.org
> From: Alexis <flexibeast@gmail.com>
> Date: Tue, 21 Oct 2014 00:59:08 +1100
> 
> Superficially, it looks like return/enter is only sending a line feed,
> not a line feed + carriage return

This doesn't seem to explain what the OP describes as happening both
in GUI and TTY sessions: in the former case, we don't send any CR or
LF characters to the screen to position the cursor, we do that via
Xlib functions.

Daniel, is it true that the problem exists in both GUI and text-mode
sessions?





^ permalink raw reply	[flat|nested] 19+ messages in thread

* bug#18756: 24.4; shell-script-mode does wrong indentation
  2014-10-20 15:20             ` Eli Zaretskii
@ 2014-10-20 16:13               ` Daniel Daboul
  2014-10-22  1:01                 ` Alexis
  0 siblings, 1 reply; 19+ messages in thread
From: Daniel Daboul @ 2014-10-20 16:13 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Alexis, 18756

[-- Attachment #1: Type: text/plain, Size: 1322 bytes --]

On Mon, Oct 20, 2014 at 6:20 PM, Eli Zaretskii  wrote:

> Daniel, is it true that the problem exists in both GUI and text-mode
> sessions?
>

Yes, that is true.

Also, it is noticeable that a line is indented after I press return
and then the point is aligned with the first character in the line above it
(rather than just moving down).

And I think we know that pressing enter usually causes a chain of
events. Help tells me:

RET (translated from <return>) runs the command newline, which is an
interactive compiled Lisp function in `simple.el'.

It is bound to RET.

(newline &optional ARG INTERACTIVE)

Insert a newline, and move to left margin of the new line if it's blank.
If option `use-hard-newlines' is non-nil, the newline is marked with the
text-property `hard'.
With ARG, insert that many newlines.

If `electric-indent-mode' is enabled, this indents the final new line
that it adds, and reindents the preceding line.  To just insert
a newline, use M-x electric-indent-just-newline.

Calls `auto-fill-function' if the current column number is greater
than the value of `fill-column' and ARG is nil.
A non-nil INTERACTIVE argument means to run the `post-self-insert-hook'.

I didn't mention it before, but there are modes that superficially seem
to work OK, like for example c-mode and lisp-interaction-mode.

[-- Attachment #2: Type: text/html, Size: 1909 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* bug#18756: 24.4; shell-script-mode does wrong indentation
  2014-10-20 16:13               ` Daniel Daboul
@ 2014-10-22  1:01                 ` Alexis
  2014-10-22  3:22                   ` Stefan Monnier
  0 siblings, 1 reply; 19+ messages in thread
From: Alexis @ 2014-10-22  1:01 UTC (permalink / raw)
  To: 18756


Daniel Daboul writes:

> I didn't mention it before, but there are modes that superficially
> seem to work OK, like for example c-mode and lisp-interaction-mode.

Out of interest, what's the status of electric-indent-mode (i.e.,
enabled or disabled?) in fundamental-mode, shell-script-mode, c-mode and
lisp-interaction-mode?





^ permalink raw reply	[flat|nested] 19+ messages in thread

* bug#18756: 24.4; shell-script-mode does wrong indentation
  2014-10-22  1:01                 ` Alexis
@ 2014-10-22  3:22                   ` Stefan Monnier
  2014-10-22  3:37                     ` Alexis
  0 siblings, 1 reply; 19+ messages in thread
From: Stefan Monnier @ 2014-10-22  3:22 UTC (permalink / raw)
  To: Alexis; +Cc: 18756

> Out of interest, what's the status of electric-indent-mode (i.e.,
> enabled or disabled?) in fundamental-mode, shell-script-mode, c-mode and
> lisp-interaction-mode?

It's a global mode, so it's either enabled everywhere or nowhere.


        Stefan





^ permalink raw reply	[flat|nested] 19+ messages in thread

* bug#18756: 24.4; shell-script-mode does wrong indentation
  2014-10-22  3:22                   ` Stefan Monnier
@ 2014-10-22  3:37                     ` Alexis
  2014-10-22 13:04                       ` Stefan Monnier
  0 siblings, 1 reply; 19+ messages in thread
From: Alexis @ 2014-10-22  3:37 UTC (permalink / raw)
  To: 18756


Stefan Monnier writes:

>> Out of interest, what's the status of electric-indent-mode (i.e.,
>> enabled or disabled?) in fundamental-mode, shell-script-mode, c-mode and
>> lisp-interaction-mode?
>
> It's a global mode, so it's either enabled everywhere or nowhere.

Ah okay.

The reason i asked is because of this:

https://lists.gnu.org/archive/html/emacs-orgmode/2014-10/msg00607.html
https://lists.gnu.org/archive/html/emacs-orgmode/2014-10/msg00650.html

and this:

https://www.reddit.com/r/emacs/comments/2jxpz9/anyone_having_issues_with_jsmode_in_244/

Since electric-indent-mode was the common factor in those instances, i
was wondering if it might be involved with this issue also ....





^ permalink raw reply	[flat|nested] 19+ messages in thread

* bug#18756: 24.4; shell-script-mode does wrong indentation
  2014-10-22  3:37                     ` Alexis
@ 2014-10-22 13:04                       ` Stefan Monnier
  2014-10-25 19:20                         ` Daniel Daboul
  0 siblings, 1 reply; 19+ messages in thread
From: Stefan Monnier @ 2014-10-22 13:04 UTC (permalink / raw)
  To: Alexis; +Cc: 18756

> Since electric-indent-mode was the common factor in those instances, i
> was wondering if it might be involved with this issue also ....

Probably.  But we'd need actual bug-reports to figure that out.


        Stefan





^ permalink raw reply	[flat|nested] 19+ messages in thread

* bug#18756: 24.4; shell-script-mode does wrong indentation
  2014-10-22 13:04                       ` Stefan Monnier
@ 2014-10-25 19:20                         ` Daniel Daboul
  2014-10-26  2:43                           ` Stefan Monnier
  0 siblings, 1 reply; 19+ messages in thread
From: Daniel Daboul @ 2014-10-25 19:20 UTC (permalink / raw)
  To: 18756

Stefan Monnier writes:

> 
> > Since electric-indent-mode was the common factor in those instances, i
> > was wondering if it might be involved with this issue also ....
> 
> Probably.  But we'd need actual bug-reports to figure that out.

Can one of you advise how I could test "electric-indent-mode" in
isolation on my broken Emacs in SUSE and, if applicable, submit an
"actual bug-report"?

The original mail in this thread was created with "M-x report-emacs-bug"
but apparently it was not good enough for debugging. - Daniel









^ permalink raw reply	[flat|nested] 19+ messages in thread

* bug#18756: 24.4; shell-script-mode does wrong indentation
  2014-10-25 19:20                         ` Daniel Daboul
@ 2014-10-26  2:43                           ` Stefan Monnier
  0 siblings, 0 replies; 19+ messages in thread
From: Stefan Monnier @ 2014-10-26  2:43 UTC (permalink / raw)
  To: Daniel Daboul; +Cc: 18756

> Can one of you advise how I could test "electric-indent-mode" in
> isolation on my broken Emacs in SUSE and, if applicable, submit an
> "actual bug-report"?

You might want to disable electric-indent-mode and then try to reproduce
the same problem by hitting the TAB key before/after RET.


        Stefan





^ permalink raw reply	[flat|nested] 19+ messages in thread

* bug#18756: 24.4; shell-script-mode does wrong indentation
  2014-10-17 19:36 bug#18756: 24.4; shell-script-mode does wrong indentation Daniel Daboul
  2014-10-17 22:35 ` Glenn Morris
@ 2014-12-04  8:06 ` Gilles Pion
  2014-12-04 14:43   ` Stefan Monnier
  2014-12-22 20:34 ` bug#18756: Peter Oliver
  2 siblings, 1 reply; 19+ messages in thread
From: Gilles Pion @ 2014-12-04  8:06 UTC (permalink / raw)
  To: 18756

Daniel Daboul <danieldaboul <at> gmail.com> writes:

> 
> M-x shell-script-mode<Enter>
> #hi<Enter>
> ls<Enter>
> x-3<Enter>
> With every <Enter> key-press the current line gets indeted, 

Could this be related to this other bug: 
https://lists.gnu.org/archive/html/bug-gnu-emacs/2014-07/msg00551.html

Submitted last july, unfortunately got not answer 








^ permalink raw reply	[flat|nested] 19+ messages in thread

* bug#18756: 24.4; shell-script-mode does wrong indentation
  2014-12-04  8:06 ` Gilles Pion
@ 2014-12-04 14:43   ` Stefan Monnier
  0 siblings, 0 replies; 19+ messages in thread
From: Stefan Monnier @ 2014-12-04 14:43 UTC (permalink / raw)
  To: Gilles Pion; +Cc: 18756

> Daniel Daboul <danieldaboul <at> gmail.com> writes:
>> M-x shell-script-mode<Enter>
>> #hi<Enter>
>> ls<Enter>
>> x-3<Enter>
>> With every <Enter> key-press the current line gets indeted, 

> Could this be related to this other bug: 
> https://lists.gnu.org/archive/html/bug-gnu-emacs/2014-07/msg00551.html

No, his problem seems to be quite different because the behavior does
not correspond to any normal behavior of sh-mode's indentation.
Instead, it sounds like something is overriding sh-mode's indentation in
his case.

> Submitted last july, unfortunately got not answer 

Sorry for that.  It happens too often.


        Stefan





^ permalink raw reply	[flat|nested] 19+ messages in thread

* bug#18756:
  2014-10-17 19:36 bug#18756: 24.4; shell-script-mode does wrong indentation Daniel Daboul
  2014-10-17 22:35 ` Glenn Morris
  2014-12-04  8:06 ` Gilles Pion
@ 2014-12-22 20:34 ` Peter Oliver
  2015-01-06 18:55   ` bug#18756: 24.4; shell-script-mode does wrong indentation Glenn Morris
  2 siblings, 1 reply; 19+ messages in thread
From: Peter Oliver @ 2014-12-22 20:34 UTC (permalink / raw)
  To: 18756

I can reproduce this when electric-indent-mode is on and sh-set-shell
is run for a csh-family shell.  See also bug 19433, which causes this
problem to affect modes other than sh-mode.

-- 
Peter Oliver





^ permalink raw reply	[flat|nested] 19+ messages in thread

* bug#18756: 24.4; shell-script-mode does wrong indentation
  2014-12-22 20:34 ` bug#18756: Peter Oliver
@ 2015-01-06 18:55   ` Glenn Morris
  0 siblings, 0 replies; 19+ messages in thread
From: Glenn Morris @ 2015-01-06 18:55 UTC (permalink / raw)
  To: Peter Oliver; +Cc: 18756-done

Version: 24.5

Peter Oliver wrote:

> I can reproduce this when electric-indent-mode is on and sh-set-shell
> is run for a csh-family shell.

Thanks for this vital clue.
I installed the following, which seems to fix it.

diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el
index d79b387..4700324 100644
--- a/lisp/progmodes/sh-script.el
+++ b/lisp/progmodes/sh-script.el
@@ -2477,7 +2475,8 @@ Lines containing only comments are considered empty."
 		    (current-column)))
 	current)
     (save-excursion
-      (indent-to (if (eq this-command 'newline-and-indent)
+      (indent-to (if (or (eq this-command 'newline-and-indent)
+                         (and electric-indent-mode (eq this-command 'newline)))
 		     previous
 		   (if (< (current-column)
 			  (setq current (progn (back-to-indentation)





^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2015-01-06 18:55 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-17 19:36 bug#18756: 24.4; shell-script-mode does wrong indentation Daniel Daboul
2014-10-17 22:35 ` Glenn Morris
2014-10-18 18:49   ` Daniel Daboul
2014-10-19 17:37     ` Glenn Morris
2014-10-19 18:35       ` Daniel Daboul
2014-10-20  5:35         ` Glenn Morris
2014-10-20 13:59           ` Alexis
2014-10-20 15:20             ` Eli Zaretskii
2014-10-20 16:13               ` Daniel Daboul
2014-10-22  1:01                 ` Alexis
2014-10-22  3:22                   ` Stefan Monnier
2014-10-22  3:37                     ` Alexis
2014-10-22 13:04                       ` Stefan Monnier
2014-10-25 19:20                         ` Daniel Daboul
2014-10-26  2:43                           ` Stefan Monnier
2014-12-04  8:06 ` Gilles Pion
2014-12-04 14:43   ` Stefan Monnier
2014-12-22 20:34 ` bug#18756: Peter Oliver
2015-01-06 18:55   ` bug#18756: 24.4; shell-script-mode does wrong indentation Glenn Morris

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).