diff options
| author | Lars Ingebrigtsen | 2019-10-16 03:47:12 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2019-10-16 03:47:12 +0200 |
| commit | 7fd1093d28e8be4683f45000fa9c0440cbe8182c (patch) | |
| tree | 41923868ecd538db558b7b2656fd2c8cd08c40e7 | |
| parent | 2912de1e1079bfa4e975e6414e171d747c83c202 (diff) | |
| download | emacs-7fd1093d28e8be4683f45000fa9c0440cbe8182c.tar.gz emacs-7fd1093d28e8be4683f45000fa9c0440cbe8182c.zip | |
Tweak heredoc expansion in shell-script-mode
* lisp/progmodes/sh-script.el (sh--maybe-here-document): Allow
expanding <<E, too.
| -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'." | |||
| 4356 | (or arg (sh--maybe-here-document))) | 4356 | (or arg (sh--maybe-here-document))) |
| 4357 | 4357 | ||
| 4358 | (defun sh--maybe-here-document () | 4358 | (defun sh--maybe-here-document () |
| 4359 | (or (not (looking-back "[^<]<< " (line-beginning-position))) | 4359 | (when (and (looking-back "[^<]<<[ E]" (line-beginning-position)) |
| 4360 | (save-excursion | ||
| 4361 | (backward-char 2) | ||
| 4362 | (not | ||
| 4363 | (or (sh-quoted-p) | ||
| 4364 | (sh--inside-noncommand-expression (point))))) | ||
| 4365 | (not (nth 8 (syntax-ppss)))) | ||
| 4366 | (let ((tabs (if (string-match "\\`-" sh-here-document-word) | ||
| 4367 | (make-string (/ (current-indentation) tab-width) ?\t) | ||
| 4368 | "")) | ||
| 4369 | (delim (replace-regexp-in-string "['\"]" "" | ||
| 4370 | sh-here-document-word))) | ||
| 4371 | (delete-char -1) | ||
| 4372 | (insert sh-here-document-word) | ||
| 4373 | (or (eolp) (looking-at "[ \t]") (insert ?\s)) | ||
| 4374 | (end-of-line 1) | ||
| 4375 | (while | ||
| 4376 | (sh-quoted-p) | ||
| 4377 | (end-of-line 2)) | ||
| 4378 | (insert ?\n tabs) | ||
| 4360 | (save-excursion | 4379 | (save-excursion |
| 4361 | (backward-char 2) | 4380 | (insert ?\n tabs (replace-regexp-in-string |
| 4362 | (or (sh-quoted-p) | 4381 | "\\`-?[ \t]*" "" delim)))))) |
| 4363 | (sh--inside-noncommand-expression (point)))) | ||
| 4364 | (nth 8 (syntax-ppss)) | ||
| 4365 | (let ((tabs (if (string-match "\\`-" sh-here-document-word) | ||
| 4366 | (make-string (/ (current-indentation) tab-width) ?\t) | ||
| 4367 | "")) | ||
| 4368 | (delim (replace-regexp-in-string "['\"]" "" | ||
| 4369 | sh-here-document-word))) | ||
| 4370 | (insert sh-here-document-word) | ||
| 4371 | (or (eolp) (looking-at "[ \t]") (insert ?\s)) | ||
| 4372 | (end-of-line 1) | ||
| 4373 | (while | ||
| 4374 | (sh-quoted-p) | ||
| 4375 | (end-of-line 2)) | ||
| 4376 | (insert ?\n tabs) | ||
| 4377 | (save-excursion | ||
| 4378 | (insert ?\n tabs (replace-regexp-in-string | ||
| 4379 | "\\`-?[ \t]*" "" delim)))))) | ||
| 4380 | 4382 | ||
| 4381 | (define-minor-mode sh-electric-here-document-mode | 4383 | (define-minor-mode sh-electric-here-document-mode |
| 4382 | "Make << insert a here document skeleton." | 4384 | "Make << insert a here document skeleton." |