GNU bug report logs - #24848
[sh-script] How to save "Local rules set" result from sh-learn-buffer-indent?

Previous Next

Package: emacs;

Reported by: <richard.wiseman <at> bt.com>

Date: Tue, 1 Nov 2016 15:37:01 UTC

Severity: minor

Tags: fixed, patch

Merged with 29414

Found in version 24.5

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: <richard.wiseman <at> bt.com>
To: <npostavs <at> gmail.com>, <24848 <at> debbugs.gnu.org>
Subject: bug#24848: [sh-script] How to save "Local rules set" result from sh-learn-buffer-indent?
Date: Fri, 25 Aug 2017 08:11:38 +0000
Hi Noam,

Thanks for the suggestions.

I don't know whether my Emacs uses smie for sh-mode but there's apparently no sh-use-smie variable set by default.

However, running smie-config-guess seems to have the same effect as sm-learn-buffer-indent so perhaps it does.  Unfortunately, I've still not managed to save the config.

Here's what I did:

1. I ran smie-config-guess on a correctly-indented bash script (see below) and confirmed that it now indents as I would expect when I hit tab on any line).

2. I then ran smie-save-config and it said it saved it to smie-config.

3. I ran customize-variable on smie-config and its value is now ((2 :elem basic 4)) which doesn't make any mention of indenting after "then" which is weird, because as I said, it does now indent correctly in this buffer.

4. I then clicked Apply and Save to add the setting to my ~/.emacs file.

5. I confirmed that it now appears in the (custom-set-variables ... ) section.

6. I restarted Emacs and loaded the bash script.

7. As feared, indentation is back to the way I don't like.

8. I then modified the smie-config entry in (custom-set-variables ... ) to correspond with your expression (that mentions "then").

9. I restarted Emacs and loaded the bash script.

10. Sadly, indentation is still unaffected.

The bash script I've used as a test here is:

#!/usr/bin/env bash

if [ "$1" ]
then
  echo "First argument is: $1"
else
  echo "No arguments"
fi

In case there's a problem with formatting by the time this email reaches you, only the two echo lines are indented, and each by two spaces.  Hitting tab on the first of these changes the indent to four spaces; on the second, indentation remains at two.

Regards,

Richard



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

Previous Next


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