]> git.eshelyaron.com Git - emacs.git/commitdiff
Expand <<- heredocs in sh
authorLars Ingebrigtsen <larsi@gnus.org>
Wed, 16 Oct 2019 07:20:06 +0000 (09:20 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Wed, 16 Oct 2019 07:20:15 +0000 (09:20 +0200)
* lisp/progmodes/sh-script.el (sh--maybe-here-document): Make <<-
expansion work, too.

lisp/progmodes/sh-script.el

index 604d13eabef4135d57b67c488c699fb47ad94654..8177329f32b09891f232b058f42620d6f13a7e7d 100644 (file)
@@ -4356,7 +4356,7 @@ The document is bounded by `sh-here-document-word'."
   (or arg (sh--maybe-here-document)))
 
 (defun sh--maybe-here-document ()
-  (when (and (looking-back "[^<]<<[ E]" (line-beginning-position))
+  (when (and (looking-back "[^<]<<[ E-]" (line-beginning-position))
              (save-excursion
               (backward-char 2)
                (not
@@ -4368,7 +4368,9 @@ The document is bounded by `sh-here-document-word'."
                   ""))
           (delim (replace-regexp-in-string "['\"]" ""
                                            sh-here-document-word)))
-      (delete-char -1)
+      ;; If we're at <<-, we don't want to delete the previous char.
+      (unless (= (preceding-char) ?-)
+        (delete-char -1))
       (insert sh-here-document-word)
       (or (eolp) (looking-at "[ \t]") (insert ?\s))
       (end-of-line 1)