branch: externals/hyperbole
commit a63b789b0c58b1edfd331b9f3bb1e31352490abc
Author: Mats Lidell <[email protected]>
Commit: Mats Lidell <[email protected]>
Add hui--kill-ring-save--defun test
---
ChangeLog | 2 ++
test/hui-tests.el | 26 +++++++++++++++++++++++++-
2 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 4d56ef450b..a85efb22ef 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
2025-09-14 Mats Lidell <[email protected]>
+* test/hui-tests.el (hui--kill-ring-save--defun): Add test.
+
* test/hypb-tests.el (hypb--in-string-p--max-lines): Update test.
(hypb--string-count-matches): Add test.
diff --git a/test/hui-tests.el b/test/hui-tests.el
index 144d7bb921..4bc32b8375 100644
--- a/test/hui-tests.el
+++ b/test/hui-tests.el
@@ -3,7 +3,7 @@
;; Author: Mats Lidell <[email protected]>
;;
;; Orig-Date: 30-Jan-21 at 12:00:00
-;; Last-Mod: 31-Aug-25 at 01:00:23 by Bob Weiner
+;; Last-Mod: 14-Sep-25 at 19:26:09 by Mats Lidell
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -492,6 +492,30 @@ Ensure modifying the button but keeping the label does not
create a double label
(hy-delete-file-and-buffer other-file)
(delete-directory other-dir))))
+(ert-deftest hui--kill-ring-save--defun ()
+ "Verify `hui:kill-ring-save' grabbs defun.
+Verify same region is grabbed both when calling twice and at both ends
+of the defun."
+ (skip-unless (not noninteractive))
+ (let ((last-command #'ignore)
+ (defun "(defun fun () \"Fun.\" t)")
+ kill-ring)
+ (with-temp-buffer
+ (emacs-lisp-mode)
+ (insert defun "\n")
+ (goto-char 0)
+ (call-interactively #'hui:kill-ring-save)
+ (should (string= (car kill-ring) defun))
+ ;; Call a second time
+ (call-interactively #'hui:kill-ring-save)
+ (should (string= (car kill-ring) defun))
+ (should (string= (cadr kill-ring) defun))
+ ;; Call at end of defun
+ (goto-char (length defun))
+ (call-interactively #'hui:kill-ring-save)
+ (should (string= (car kill-ring) defun))
+ (should (= 3 (length kill-ring))))))
+
(ert-deftest hui--copy-to-register--yank-in-same-kotl ()
"Yank klink in register into same kotl file."
(skip-unless (not noninteractive))