unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Philippe Altherr <philippe.altherr@gmail.com>
To: 60832@debbugs.gnu.org
Subject: bug#60832: Acknowledgement ([PATCH] sh-script.el: Use sh-indent-for-continuation to indent line continuations.)
Date: Fri, 17 Feb 2023 16:21:36 +0100	[thread overview]
Message-ID: <CAGdYchuaC263qtmgR3fF2G+8eYrzxWU3G8ELL5bt-8gwwA21zw@mail.gmail.com> (raw)
In-Reply-To: <CAGdYchuyYDjWPMHWDZwGPxnYrKN4Qao=Yfi6DPfbtReNMrxL9A@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 1174 bytes --]

Here is an updated patch against the current master branch.


On Mon, Jan 23, 2023 at 5:18 AM Philippe Altherr <philippe.altherr@gmail.com>
wrote:

> Here is an updated patch that includes a test case. I was able to test it
> in my *scratch* buffer. Please double-check that it works as intended.
>
>
> On Sun, Jan 15, 2023 at 3:14 PM GNU bug Tracking System <
> help-debbugs@gnu.org> wrote:
>
>> Thank you for filing a new bug report with debbugs.gnu.org.
>>
>> This is an automatically generated reply to let you know your message
>> has been received.
>>
>> Your message is being forwarded to the package maintainers and other
>> interested parties for their attention; they will reply in due course.
>>
>> Your message has been sent to the package maintainer(s):
>>  bug-gnu-emacs@gnu.org
>>
>> If you wish to submit further information on this problem, please
>> send it to 60832@debbugs.gnu.org.
>>
>> Please do not send mail to help-debbugs@gnu.org unless you wish
>> to report a problem with the Bug-tracking system.
>>
>> --
>> 60832: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=60832
>> GNU Bug Tracking System
>> Contact help-debbugs@gnu.org with problems
>>
>

[-- Attachment #1.2: Type: text/html, Size: 2225 bytes --]

[-- Attachment #2: 0001-For-line-continuations-use-sh-indent-for-continuatio.patch --]
[-- Type: application/octet-stream, Size: 2846 bytes --]

From 36bce0c7a03bd96687cfb885cfe2fb431d2824ff Mon Sep 17 00:00:00 2001
From: Philippe Altherr <philippe.altherr@gmail.com>
Date: Sat, 14 Jan 2023 05:22:26 +0100
Subject: [PATCH] For line continuations, use sh-indent-for-continuation
 instead of sh-basic-offset.

---
 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 @@ sh-smie--indent-continuation
       (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 @@ sh-smie--indent-continuation
                        ;; 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 @@ test-basic-sh-indentation
 (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)
-- 
2.39.1


  reply	other threads:[~2023-02-17 15:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-15 11:55 bug#60832: [PATCH] sh-script.el: Use sh-indent-for-continuation to indent line continuations Philippe Altherr
     [not found] ` <handler.60832.B.16737920185787.ack@debbugs.gnu.org>
2023-01-23  4:18   ` bug#60832: Acknowledgement ([PATCH] sh-script.el: Use sh-indent-for-continuation to indent line continuations.) Philippe Altherr
2023-02-17 15:21     ` Philippe Altherr [this message]
2023-03-02 10:42       ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAGdYchuaC263qtmgR3fF2G+8eYrzxWU3G8ELL5bt-8gwwA21zw@mail.gmail.com \
    --to=philippe.altherr@gmail.com \
    --cc=60832@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).