summaryrefslogtreecommitdiff
path: root/test/lisp/simple-tests.el
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2022-05-20 03:24:30 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2022-05-20 03:24:38 +0200
commit4d7390576b1fdc385e48ae9eab19f70c82643c0c (patch)
treeceb9066661daa03d6bcc02a54d3f418cfdc19f28 /test/lisp/simple-tests.el
parent10411697468ebfcae93ffb48ca773d5321c8a5ec (diff)
downloademacs-4d7390576b1fdc385e48ae9eab19f70c82643c0c.tar.gz
Add a new command 'yank-in-context'
* lisp/simple.el (escaped-string-quote): New variable. (yank-in-context): New command. (yank-in-context--transform): Helper function. * lisp/progmodes/sh-script.el (sh-mode): Set up an escaped-string-quote function. * lisp/progmodes/sql.el (sql-mode): Define escaped-string-quote.
Diffstat (limited to 'test/lisp/simple-tests.el')
-rw-r--r--test/lisp/simple-tests.el34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/lisp/simple-tests.el b/test/lisp/simple-tests.el
index dcab811bb5a..437c62f61d8 100644
--- a/test/lisp/simple-tests.el
+++ b/test/lisp/simple-tests.el
@@ -971,5 +971,39 @@ See Bug#21722."
;;(should (= (length (delq nil (undo-make-selective-list 5 9))) 0))
(should (= (length (delq nil (undo-make-selective-list 6 9))) 0))))
+(ert-deftest test-yank-in-context ()
+ (should
+ (equal
+ (with-temp-buffer
+ (sh-mode)
+ (insert "echo \"foo\"")
+ (kill-new "\"bar\"")
+ (goto-char 8)
+ (yank-in-context)
+ (buffer-string))
+ "echo \"f\\\"bar\\\"oo\""))
+
+ (should
+ (equal
+ (with-temp-buffer
+ (sh-mode)
+ (insert "echo \"foo\"")
+ (kill-new "'bar'")
+ (goto-char 8)
+ (yank-in-context)
+ (buffer-string))
+ "echo \"f'bar'oo\""))
+
+ (should
+ (equal
+ (with-temp-buffer
+ (sh-mode)
+ (insert "echo 'foo'")
+ (kill-new "'bar'")
+ (goto-char 8)
+ (yank-in-context)
+ (buffer-string))
+ "echo 'f'\\''bar'\\''oo'")))
+
(provide 'simple-test)
;;; simple-tests.el ends here