unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#15613: Wrong indentation in Shell-script[sh] mode?
@ 2013-10-14 20:53 Angelo Graziosi
  2013-10-15 14:37 ` Stefan Monnier
  0 siblings, 1 reply; 10+ messages in thread
From: Angelo Graziosi @ 2013-10-14 20:53 UTC (permalink / raw)
  To: 15613

In the current trunk the indentation for bash scripts looks as in this 
test case:

$ cat test_indent.sh
#!/bin/bash

if [ "${foo_a}" != "${foo_b}" ]; then

     if [ "${foo_c}" = "${foo_d}" ]; then
	echo
	echo "Hello..."
	echo
	exit 1
     fi

     fi


The inner if-fi looks ok but in the outer one expects the last fi under 
the first if.. Or not?

This happens with

$ emacs -Q &

and using TAB to indent..


Ciao,
  Angelo.





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

* bug#15613: Wrong indentation in Shell-script[sh] mode?
  2013-10-14 20:53 bug#15613: Wrong indentation in Shell-script[sh] mode? Angelo Graziosi
@ 2013-10-15 14:37 ` Stefan Monnier
  2013-10-15 14:56   ` Glenn Morris
                     ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Stefan Monnier @ 2013-10-15 14:37 UTC (permalink / raw)
  To: Angelo Graziosi; +Cc: 15613

> In the current trunk the indentation for bash scripts looks as in this test
> case:

> $ cat test_indent.sh
> #!/bin/bash

> if [ "${foo_a}" != "${foo_b}" ]; then

>     if [ "${foo_c}" = "${foo_d}" ]; then
> 	echo
> 	echo "Hello..."
> 	echo
> 	exit 1
>     fi

>     fi

This works correctly if you use (setq sh-use-smie t) which I recommend.

It is currently not the default setting because it doesn't yet support
all the indentation-config variables of the old indentation code, and
doesn't support the "guess indentation settings" feature either.  But in
most other respects it should work "as well or better".


        Stefan





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

* bug#15613: Wrong indentation in Shell-script[sh] mode?
  2013-10-15 14:37 ` Stefan Monnier
@ 2013-10-15 14:56   ` Glenn Morris
  2013-10-15 22:26     ` Angelo Graziosi
  2013-10-15 22:23   ` Angelo Graziosi
  2013-10-16 22:41   ` Glenn Morris
  2 siblings, 1 reply; 10+ messages in thread
From: Glenn Morris @ 2013-10-15 14:56 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 15613, Angelo Graziosi

Stefan Monnier wrote:

> This works correctly if you use (setq sh-use-smie t) which I recommend.

It works fine in 24.3 out-of-the-box.





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

* bug#15613: Wrong indentation in Shell-script[sh] mode?
  2013-10-15 14:37 ` Stefan Monnier
  2013-10-15 14:56   ` Glenn Morris
@ 2013-10-15 22:23   ` Angelo Graziosi
  2013-10-16 22:41   ` Glenn Morris
  2 siblings, 0 replies; 10+ messages in thread
From: Angelo Graziosi @ 2013-10-15 22:23 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 15613

Il 15/10/2013 16.37, Stefan Monnier ha scritto:
>> In the current trunk the indentation for bash scripts looks as in this test
>> case:
>
>> $ cat test_indent.sh
>> #!/bin/bash
>
>> if [ "${foo_a}" != "${foo_b}" ]; then
>
>>      if [ "${foo_c}" = "${foo_d}" ]; then
>> 	echo
>> 	echo "Hello..."
>> 	echo
>> 	exit 1
>>      fi
>
>>      fi
>
> This works correctly if you use (setq sh-use-smie t) which I recommend.
>
> It is currently not the default setting because it doesn't yet support
> all the indentation-config variables of the old indentation code, and
> doesn't support the "guess indentation settings" feature either.  But in
> most other respects it should work "as well or better".

Why, by default, the last "fi" should be under the previous and not 
under _its_ "if"? Should "indent" mean that the matching if-fi, {-}, 
begin-end, if-endif etc. start the same column?

Instead the test case shows that all statements after the first "if"

   if [ "${foo_a}" != "${foo_b}" ]; then

are considered belonging to its block statements. All the next formatted 
code is lost.

This should be called "regression"..


Ciao,
  Angelo.






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

* bug#15613: Wrong indentation in Shell-script[sh] mode?
  2013-10-15 14:56   ` Glenn Morris
@ 2013-10-15 22:26     ` Angelo Graziosi
  0 siblings, 0 replies; 10+ messages in thread
From: Angelo Graziosi @ 2013-10-15 22:26 UTC (permalink / raw)
  To: Glenn Morris, Stefan Monnier; +Cc: 15613

Il 15/10/2013 16.56, Glenn Morris ha scritto:
> Stefan Monnier wrote:
>
>> This works correctly if you use (setq sh-use-smie t) which I recommend.
>
> It works fine in 24.3 out-of-the-box.
>

Also in trunk rev. 114585 (09 October 2013). So, some recent changes 
have broken the indentation of Shell-script[sh] mode...

Ciao,
Angelo.





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

* bug#15613: Wrong indentation in Shell-script[sh] mode?
  2013-10-15 14:37 ` Stefan Monnier
  2013-10-15 14:56   ` Glenn Morris
  2013-10-15 22:23   ` Angelo Graziosi
@ 2013-10-16 22:41   ` Glenn Morris
  2013-10-17  1:03     ` Stefan Monnier
  2 siblings, 1 reply; 10+ messages in thread
From: Glenn Morris @ 2013-10-16 22:41 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 15613, Angelo Graziosi


By experiment, reverting the "Always setup SMIE..." part of your
2013-10-11 change fixes this regression.


*** lisp/progmodes/sh-script.el	2013-10-13 23:21:56 +0000
--- lisp/progmodes/sh-script.el	2013-10-16 22:35:56 +0000
***************
*** 2248,2253 ****
--- 2248,2254 ----
  		  (sh-feature sh-indent-supported))
        (progn
  	(message "Setting up indent for shell type %s" sh-shell)
+         (if sh-use-smie
              (let ((mksym (lambda (name)
                             (intern (format "sh-smie-%s-%s"
                                             sh-indent-supported-here name)))))
***************
*** 2255,2261 ****
                        (funcall mksym "rules")
                        :forward-token  (funcall mksym "forward-token")
                        :backward-token (funcall mksym "backward-token")))
-         (unless sh-use-smie
            (setq-local parse-sexp-lookup-properties t)
            (setq-local sh-kw-alist (sh-feature sh-kw))
            (let ((regexp (sh-feature sh-kws-for-done)))
--- 2256,2261 ----






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

* bug#15613: Wrong indentation in Shell-script[sh] mode?
  2013-10-16 22:41   ` Glenn Morris
@ 2013-10-17  1:03     ` Stefan Monnier
  2013-10-17  2:03       ` Glenn Morris
  0 siblings, 1 reply; 10+ messages in thread
From: Stefan Monnier @ 2013-10-17  1:03 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 15613, Angelo Graziosi

> By experiment, reverting the "Always setup SMIE..." part of your
> 2013-10-11 change fixes this regression.

Aha!  I'll try and see why that introduces such breakage.
Probably a call to backward-sexp somewhere.


        Stefan





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

* bug#15613: Wrong indentation in Shell-script[sh] mode?
  2013-10-17  1:03     ` Stefan Monnier
@ 2013-10-17  2:03       ` Glenn Morris
  2013-10-17  3:57         ` Stefan Monnier
  0 siblings, 1 reply; 10+ messages in thread
From: Glenn Morris @ 2013-10-17  2:03 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 15613, Angelo Graziosi

Stefan Monnier wrote:

>> By experiment, reverting the "Always setup SMIE..." part of your
>> 2013-10-11 change fixes this regression.
>
> Aha!  I'll try and see why that introduces such breakage.
> Probably a call to backward-sexp somewhere.

This specific problem seems due to smie-setup's

  (setq-local forward-sexp-function #'smie-forward-sexp-command)





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

* bug#15613: Wrong indentation in Shell-script[sh] mode?
  2013-10-17  2:03       ` Glenn Morris
@ 2013-10-17  3:57         ` Stefan Monnier
  2013-10-17 16:46           ` Angelo Graziosi
  0 siblings, 1 reply; 10+ messages in thread
From: Stefan Monnier @ 2013-10-17  3:57 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 15613, Angelo Graziosi

I installed the patch below which should fix it, thank you,


        Stefan


--- lisp/progmodes/sh-script.el	2013-10-13 23:21:56 +0000
+++ lisp/progmodes/sh-script.el	2013-10-17 03:53:43 +0000
@@ -3097,6 +3097,7 @@
 OPEN and CLOSE are regexps denoting the tokens to be matched.
 Optional parameter DEPTH (usually 1) says how many to look for."
   (let ((parse-sexp-ignore-comments t)
+        (forward-sexp-function nil)
 	prev)
     (setq depth (or depth 1))
     (save-excursion






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

* bug#15613: Wrong indentation in Shell-script[sh] mode?
  2013-10-17  3:57         ` Stefan Monnier
@ 2013-10-17 16:46           ` Angelo Graziosi
  0 siblings, 0 replies; 10+ messages in thread
From: Angelo Graziosi @ 2013-10-17 16:46 UTC (permalink / raw)
  To: Stefan Monnier, Glenn Morris; +Cc: 15613

Il 17/10/2013 5.57, Stefan Monnier ha scritto:
> I installed the patch below which should fix it, thank you,

Confirmed!

Thanks,
   Angelo.


>
> --- lisp/progmodes/sh-script.el	2013-10-13 23:21:56 +0000
> +++ lisp/progmodes/sh-script.el	2013-10-17 03:53:43 +0000
> @@ -3097,6 +3097,7 @@
>   OPEN and CLOSE are regexps denoting the tokens to be matched.
>   Optional parameter DEPTH (usually 1) says how many to look for."
>     (let ((parse-sexp-ignore-comments t)
> +        (forward-sexp-function nil)
>   	prev)
>       (setq depth (or depth 1))
>       (save-excursion
>






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

end of thread, other threads:[~2013-10-17 16:46 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-14 20:53 bug#15613: Wrong indentation in Shell-script[sh] mode? Angelo Graziosi
2013-10-15 14:37 ` Stefan Monnier
2013-10-15 14:56   ` Glenn Morris
2013-10-15 22:26     ` Angelo Graziosi
2013-10-15 22:23   ` Angelo Graziosi
2013-10-16 22:41   ` Glenn Morris
2013-10-17  1:03     ` Stefan Monnier
2013-10-17  2:03       ` Glenn Morris
2013-10-17  3:57         ` Stefan Monnier
2013-10-17 16:46           ` Angelo Graziosi

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).