diff options
| author | Mauro Aranda | 2023-10-14 09:05:35 -0300 |
|---|---|---|
| committer | Stefan Monnier | 2023-10-14 11:00:15 -0400 |
| commit | ad02fc212b5a88d2ea793858d538809d9976b154 (patch) | |
| tree | 7552c560f37894fc2c03b8301fb6eddb63443018 /test | |
| parent | 1f95f91d855b8e6fd4221650b7878008f7665454 (diff) | |
| download | emacs-ad02fc212b5a88d2ea793858d538809d9976b154.tar.gz emacs-ad02fc212b5a88d2ea793858d538809d9976b154.zip | |
Fix indentation and fontification in shell-script (Bug#26217)
* lisp/progmodes/sh-script.el (sh-smie--sh-keyword-p): Treat "do" as
special, like we treat "in".
(sh-smie--sh-keyword-in-p): Change signature. Take the token to
decide correctly if it's a keyword.
(sh-font-lock-keywords-var-1): Add do.
* test/lisp/progmodes/sh-script-resources/sh-indents.erts: New test.
* test/lisp/progmodes/sh-script-tests.el
(sh-script-test-do-fontification): New test.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/progmodes/sh-script-resources/sh-indents.erts | 7 | ||||
| -rw-r--r-- | test/lisp/progmodes/sh-script-tests.el | 11 |
2 files changed, 18 insertions, 0 deletions
diff --git a/test/lisp/progmodes/sh-script-resources/sh-indents.erts b/test/lisp/progmodes/sh-script-resources/sh-indents.erts index 1f92610b3aa..36f4e4c22ab 100644 --- a/test/lisp/progmodes/sh-script-resources/sh-indents.erts +++ b/test/lisp/progmodes/sh-script-resources/sh-indents.erts | |||
| @@ -38,3 +38,10 @@ if test ;then | |||
| 38 | fi | 38 | fi |
| 39 | other | 39 | other |
| 40 | =-=-= | 40 | =-=-= |
| 41 | |||
| 42 | Name: sh-indents5 | ||
| 43 | |||
| 44 | =-= | ||
| 45 | for i do echo 1; done | ||
| 46 | for i; do echo 1; done | ||
| 47 | =-=-= | ||
diff --git a/test/lisp/progmodes/sh-script-tests.el b/test/lisp/progmodes/sh-script-tests.el index 52c1303c414..135d7afe3fe 100644 --- a/test/lisp/progmodes/sh-script-tests.el +++ b/test/lisp/progmodes/sh-script-tests.el | |||
| @@ -87,4 +87,15 @@ | |||
| 87 | (should-not (test-sh-back "foo;bar")) | 87 | (should-not (test-sh-back "foo;bar")) |
| 88 | (should (test-sh-back "foo#zot"))) | 88 | (should (test-sh-back "foo#zot"))) |
| 89 | 89 | ||
| 90 | (ert-deftest sh-script-test-do-fontification () | ||
| 91 | "Test that \"do\" gets fontified correctly, even with no \";\"." | ||
| 92 | (with-temp-buffer | ||
| 93 | (shell-script-mode) | ||
| 94 | (insert "for i do echo 1; done") | ||
| 95 | (font-lock-ensure) | ||
| 96 | (goto-char (point-min)) | ||
| 97 | (search-forward "do") | ||
| 98 | (forward-char -1) | ||
| 99 | (should (equal (get-text-property (point) 'face) 'font-lock-keyword-face)))) | ||
| 100 | |||
| 90 | ;;; sh-script-tests.el ends here | 101 | ;;; sh-script-tests.el ends here |