branch: externals/hyperbole
commit a7ba7d86eaec5dcba4862a89f3d2ba3f43e20728
Author: Mats Lidell <[email protected]>
Commit: Mats Lidell <[email protected]>
Fix non-interactive behavior
---
hui.el | 4 +++-
test/hui-tests.el | 58 +++++++++++++++++++++++++++++++++++++++++++++++--------
2 files changed, 53 insertions(+), 9 deletions(-)
diff --git a/hui.el b/hui.el
index 18c6331bf6..40f6982ae6 100644
--- a/hui.el
+++ b/hui.el
@@ -3,7 +3,7 @@
;; Author: Bob Weiner
;;
;; Orig-Date: 19-Sep-91 at 21:42:03
-;; Last-Mod: 13-Jan-25 at 00:57:43 by Mats Lidell
+;; Last-Mod: 13-Jan-25 at 23:34:56 by Mats Lidell
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -159,6 +159,8 @@ Patched to remove the most recent completion."
(setq beg (region-beginning)
end (region-end)))
(hui:kill-region beg end))
+ ((and (not interactive) beg end)
+ (hui:kill-region beg end))
(t (cond ((hui-select-delimited-thing)
(setq beg (region-beginning)
end (region-end)))
diff --git a/test/hui-tests.el b/test/hui-tests.el
index 4ae6b1fb1f..e2e05e2d30 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: 13-Jan-25 at 00:58:15 by Mats Lidell
+;; Last-Mod: 14-Jan-25 at 14:46:42 by Mats Lidell
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -1178,6 +1178,7 @@ With point on label suggest that ibut for rename."
(let ((transient-mark-mode t))
(insert "abc{def}ghi")
(goto-char 1)
+ (set-mark nil)
;; No mark set
(should-error (call-interactively #'hui-kill-region) :type 'error)
@@ -1203,7 +1204,25 @@ With point on label suggest that ibut for rename."
(goto-char 5)
(deactivate-mark)
(call-interactively #'hui-kill-region)
- (should (string= "def}ghi" (buffer-string))))
+ (should (string= "def}ghi" (buffer-string)))
+
+ ;; Not interactive
+ (erase-buffer)
+ (insert "abc{def}ghi")
+ (goto-char 1)
+ (set-mark (point))
+ (goto-char 4)
+ (hui-kill-region)
+ (should (string= "{def}ghi" (buffer-string)))
+
+ (erase-buffer)
+ (insert "abc{def}ghi")
+ (goto-char 1)
+ (set-mark (point))
+ (goto-char 4)
+ (deactivate-mark)
+ (hui-kill-region)
+ (should (string= "{def}ghi" (buffer-string))))
(let ((transient-mark-mode nil))
(erase-buffer)
@@ -1214,31 +1233,54 @@ With point on label suggest that ibut for rename."
;; No mark set
(should-error (call-interactively #'hui-kill-region) :type 'error)
+ (set-mark (point))
+ (goto-char 4)
+ (call-interactively #'hui-kill-region)
+ (should (string= "abcghi" (buffer-string)))
+
(erase-buffer)
(insert "abc{def}ghi")
(goto-char 1)
(set-mark (point))
(goto-char 4)
- (activate-mark)
(call-interactively #'hui-kill-region)
- (should (string= "{def}ghi" (buffer-string)))
+ (should (string= "abcghi" (buffer-string)))
(erase-buffer)
(insert "abc{def}ghi")
(goto-char 1)
(set-mark (point))
- (goto-char 4)
- (deactivate-mark)
+ (goto-char 5)
(call-interactively #'hui-kill-region)
+ (should (string= "def}ghi" (buffer-string)))
+
+ ;; Not interactive
+
+ (erase-buffer)
+ (insert "abc{def}ghi")
+ (goto-char 1)
+ (set-mark (point))
+ (goto-char 4)
+ (hui-kill-region)
(should (string= "abcghi" (buffer-string)))
+ (erase-buffer)
+ (insert "abc{def}ghi")
+ (goto-char 1)
+ (set-mark (point))
+ (goto-char 4)
+ (hui-kill-region (region-beginning) (region-end))
+ (should (string= "{def}ghi" (buffer-string)))
+
(erase-buffer)
(insert "abc{def}ghi")
(goto-char 1)
(set-mark (point))
(goto-char 5)
- (deactivate-mark)
- (call-interactively #'hui-kill-region)
+ (hui-kill-region)
+ (should (string= "abc{def}ghi" (buffer-string))) ;; Nothing
+
+ (hui-kill-region (region-beginning) (region-end))
(should (string= "def}ghi" (buffer-string))))))
;; This file can't be byte-compiled without `with-simulated-input' which