diff options
author | Lars Ingebrigtsen <larsi@gnus.org> | 2019-10-16 03:47:12 +0200 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2019-10-16 03:47:12 +0200 |
commit | 7fd1093d28e8be4683f45000fa9c0440cbe8182c (patch) | |
tree | 41923868ecd538db558b7b2656fd2c8cd08c40e7 /lisp | |
parent | 2912de1e1079bfa4e975e6414e171d747c83c202 (diff) | |
download | emacs-7fd1093d28e8be4683f45000fa9c0440cbe8182c.tar.gz |
Tweak heredoc expansion in shell-script-mode
* lisp/progmodes/sh-script.el (sh--maybe-here-document): Allow
expanding <<E, too.
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/progmodes/sh-script.el | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index 2046080c42f..604d13eabef 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -4356,27 +4356,29 @@ The document is bounded by `sh-here-document-word'." (or arg (sh--maybe-here-document))) (defun sh--maybe-here-document () - (or (not (looking-back "[^<]<< " (line-beginning-position))) + (when (and (looking-back "[^<]<<[ E]" (line-beginning-position)) + (save-excursion + (backward-char 2) + (not + (or (sh-quoted-p) + (sh--inside-noncommand-expression (point))))) + (not (nth 8 (syntax-ppss)))) + (let ((tabs (if (string-match "\\`-" sh-here-document-word) + (make-string (/ (current-indentation) tab-width) ?\t) + "")) + (delim (replace-regexp-in-string "['\"]" "" + sh-here-document-word))) + (delete-char -1) + (insert sh-here-document-word) + (or (eolp) (looking-at "[ \t]") (insert ?\s)) + (end-of-line 1) + (while + (sh-quoted-p) + (end-of-line 2)) + (insert ?\n tabs) (save-excursion - (backward-char 2) - (or (sh-quoted-p) - (sh--inside-noncommand-expression (point)))) - (nth 8 (syntax-ppss)) - (let ((tabs (if (string-match "\\`-" sh-here-document-word) - (make-string (/ (current-indentation) tab-width) ?\t) - "")) - (delim (replace-regexp-in-string "['\"]" "" - sh-here-document-word))) - (insert sh-here-document-word) - (or (eolp) (looking-at "[ \t]") (insert ?\s)) - (end-of-line 1) - (while - (sh-quoted-p) - (end-of-line 2)) - (insert ?\n tabs) - (save-excursion - (insert ?\n tabs (replace-regexp-in-string - "\\`-?[ \t]*" "" delim)))))) + (insert ?\n tabs (replace-regexp-in-string + "\\`-?[ \t]*" "" delim)))))) (define-minor-mode sh-electric-here-document-mode "Make << insert a here document skeleton." |