[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 30e2a85717c: Use 'sh-indent-for-continuation' for continued lines
From: |
Eli Zaretskii |
Subject: |
master 30e2a85717c: Use 'sh-indent-for-continuation' for continued lines in 'sh-script-mode' |
Date: |
Thu, 2 Mar 2023 05:38:53 -0500 (EST) |
branch: master
commit 30e2a85717c4189994c7ae759888e257225f0a21
Author: Philippe Altherr <philippe.altherr@gmail.com>
Commit: Eli Zaretskii <eliz@gnu.org>
Use 'sh-indent-for-continuation' for continued lines in 'sh-script-mode'
* lisp/progmodes/sh-script.el (sh-smie--indent-continuation): Use
'sh-indent-for-continuation' instead of 'sh-basic-offset'.
(Bug#60832)
* test/lisp/progmodes/sh-script-tests.el
(test-indent-after-continuation): New test.
---
lisp/progmodes/sh-script.el | 7 +++++--
test/lisp/progmodes/sh-script-tests.el | 18 ++++++++++++++++++
2 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el
index 17c22ff4751..741803a5175 100644
--- a/lisp/progmodes/sh-script.el
+++ b/lisp/progmodes/sh-script.el
@@ -2010,7 +2010,7 @@ May return nil if the line should not be treated as
continued."
(forward-line -1)
(if (sh-smie--looking-back-at-continuation-p)
(current-indentation)
- (+ (current-indentation) sh-basic-offset))))
+ (+ (current-indentation) (sh-var-value 'sh-indent-for-continuation)))))
(t
;; Just make sure a line-continuation is indented deeper.
(save-excursion
@@ -2031,7 +2031,10 @@ May return nil if the line should not be treated as
continued."
;; check the line before that one.
(> ci indent))
(t ;Previous line is the beginning of the continued line.
- (setq indent (min (+ ci sh-basic-offset) max))
+ (setq
+ indent
+ (min
+ (+ ci (sh-var-value 'sh-indent-for-continuation))
max))
nil)))))
indent))))))
diff --git a/test/lisp/progmodes/sh-script-tests.el
b/test/lisp/progmodes/sh-script-tests.el
index c850a5d8af7..52c1303c414 100644
--- a/test/lisp/progmodes/sh-script-tests.el
+++ b/test/lisp/progmodes/sh-script-tests.el
@@ -52,6 +52,24 @@
(ert-deftest test-indentation ()
(ert-test-erts-file (ert-resource-file "sh-indents.erts")))
+(ert-deftest test-indent-after-continuation ()
+ (with-temp-buffer
+ (insert "for f \\\nin a; do \\\ntoto; \\\ndone\n")
+ (shell-script-mode)
+ (let ((sh-indent-for-continuation '++))
+ (let ((sh-indent-after-continuation t))
+ (indent-region (point-min) (point-max))
+ (should (equal (buffer-string)
+ "for f \\\n\tin a; do \\\n toto; \\\n done\n")))
+ (let ((sh-indent-after-continuation 'always))
+ (indent-region (point-min) (point-max))
+ (should (equal (buffer-string)
+ "for f \\\n\tin a; do \\\n\ttoto; \\\n\tdone\n")))
+ (let ((sh-indent-after-continuation nil))
+ (indent-region (point-min) (point-max))
+ (should (equal (buffer-string)
+ "for f \\\nin a; do \\\n toto; \\\ndone\n"))))))
+
(defun test-sh-back (string &optional pos)
(with-temp-buffer
(shell-script-mode)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 30e2a85717c: Use 'sh-indent-for-continuation' for continued lines in 'sh-script-mode',
Eli Zaretskii <=