[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/embark cf1325929e 2/3: Tweak whitespace behavior of ins
From: |
ELPA Syncer |
Subject: |
[elpa] externals/embark cf1325929e 2/3: Tweak whitespace behavior of insert actions |
Date: |
Fri, 15 Sep 2023 09:57:43 -0400 (EDT) |
branch: externals/embark
commit cf1325929e804c71b6ad5313228173b54bf2348b
Author: Omar Antolín <omar.antolin@gmail.com>
Commit: Omar Antolín <omar.antolin@gmail.com>
Tweak whitespace behavior of insert actions
---
embark.el | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/embark.el b/embark.el
index f2e0260a4f..e0186c4528 100644
--- a/embark.el
+++ b/embark.el
@@ -3582,13 +3582,19 @@ constituent character next to an existing word
constituent.
2. For a multiline inserted string, newlines may be added before
or after as needed to ensure the inserted string is on lines of
its own."
- (let ((multiline (seq-some (lambda (s) (string-match-p "\n" s)) strings))
- (separator (embark--separator strings)))
+ (let* ((separator (embark--separator strings))
+ (multiline
+ (or (and (cdr strings) (string-match-p "\n" separator))
+ (and (null (cdr strings))
+ (equal (buffer-substring (line-beginning-position)
+ (line-end-position))
+ (car strings)))
+ (seq-some (lambda (s) (string-match-p "\n" s)) strings))))
(cl-labels ((maybe-space ()
(and (looking-at "\\w") (looking-back "\\w" 1)
(insert " ")))
(maybe-newline ()
- (or (looking-back "^[ \t]*" 40) (looking-at "\n\n")
+ (or (looking-back "^[ \t]*" 40) (looking-at "\n")
(newline-and-indent)))
(maybe-whitespace ()
(if multiline (maybe-newline) (maybe-space)))
@@ -3712,7 +3718,7 @@ Returns the new name actually used."
(defun embark-insert-variable-value (var)
"Insert value of VAR."
(interactive "SVariable: ")
- (insert (string-trim (pp-to-string (symbol-value var)))))
+ (embark-insert (list (string-trim (pp-to-string (symbol-value var))))))
(defun embark-toggle-variable (var &optional local)
"Toggle value of boolean variable VAR.
@@ -3729,7 +3735,7 @@ If prefix LOCAL is non-nil make variable local."
"Insert relative path to FILE.
The insert path is relative to `default-directory'."
(interactive "FFile: ")
- (insert (file-relative-name (substitute-in-file-name file))))
+ (embark-insert (list (file-relative-name (substitute-in-file-name file)))))
(defun embark-save-relative-path (file)
"Save the relative path to FILE in the kill ring.