emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/hyperbole f423dd3163 4/9: Refactor to have base behavio


From: ELPA Syncer
Subject: [elpa] externals/hyperbole f423dd3163 4/9: Refactor to have base behavior as kill-region
Date: Sun, 19 Jan 2025 12:58:14 -0500 (EST)

branch: externals/hyperbole
commit f423dd31638d723bccc301c1e7c56369ec547106
Author: Mats Lidell <mats.lidell@lidells.se>
Commit: Mats Lidell <mats.lidell@lidells.se>

    Refactor to have base behavior as kill-region
---
 hui.el            | 25 ++++++++++++-------------
 test/hui-tests.el | 32 +++++++++++++++++++++++++++++---
 2 files changed, 41 insertions(+), 16 deletions(-)

diff --git a/hui.el b/hui.el
index e038f89b51..18c6331bf6 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:     11-Jan-25 at 23:39:13 by Mats Lidell
+;; Last-Mod:     13-Jan-25 at 00:57:43 by Mats Lidell
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -133,6 +133,7 @@ point; see `hui:delimited-selectable-thing'."
 ;; either "completion.el" or "simple.el" when hyperbole-mode is active
 ;; to allow killing kcell references, active regions and delimited
 ;; areas (like sexpressions).
+
 ;;;###autoload
 (defun hui-kill-region (&optional beg end interactive)
   "Kill between point and mark.
@@ -151,22 +152,20 @@ Patched to remove the most recent completion."
   (interactive "r\np")
   (cond ((eq last-command 'complete)
         (hui:kill-region beg end))
-       ((or (use-region-p)
-            (null transient-mark-mode)
-            (not interactive))
+       ((and transient-mark-mode
+              (or (use-region-p)
+                 (not interactive)))
         (unless (and beg end)
           (setq beg (region-beginning)
                 end (region-end)))
         (hui:kill-region beg end))
-       (t (when (or (not (and beg end))
-                     interactive)
-            (cond ((hui-select-delimited-thing)
-                   (setq beg (region-beginning)
-                         end (region-end)))
-                  ((let ((thing-beg-end 
(hui:delimited-selectable-thing-and-bounds)))
-                     (when thing-beg-end
-                       (setq beg (nth 1 thing-beg-end)
-                             end (nth 2 thing-beg-end)))))))
+       (t (cond ((hui-select-delimited-thing)
+                 (setq beg (region-beginning)
+                       end (region-end)))
+                ((let ((thing-beg-end 
(hui:delimited-selectable-thing-and-bounds)))
+                   (when thing-beg-end
+                     (setq beg (nth 1 thing-beg-end)
+                           end (nth 2 thing-beg-end))))))
           (when (and beg end)
             (hui:kill-region beg end)))))
 
diff --git a/test/hui-tests.el b/test/hui-tests.el
index 9998216a12..4ae6b1fb1f 100644
--- a/test/hui-tests.el
+++ b/test/hui-tests.el
@@ -3,7 +3,7 @@
 ;; Author:       Mats Lidell <matsl@gnu.org>
 ;;
 ;; Orig-Date:    30-Jan-21 at 12:00:00
-;; Last-Mod:     11-Jan-25 at 23:40:55 by Mats Lidell
+;; Last-Mod:     13-Jan-25 at 00:58:15 by Mats Lidell
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -1180,7 +1180,7 @@ With point on label suggest that ibut for rename."
       (goto-char 1)
 
       ;; No mark set
-      (should-error (hui-kill-region) :type 'error)
+      (should-error (call-interactively #'hui-kill-region) :type 'error)
 
       (set-mark (point))
       (goto-char 4)
@@ -1206,14 +1206,40 @@ With point on label suggest that ibut for rename."
       (should (string= "def}ghi" (buffer-string))))
 
     (let ((transient-mark-mode nil))
+      (erase-buffer)
+      (insert "abc{def}ghi")
+      (goto-char 1)
+      (set-mark nil)
+
+      ;; No mark set
+      (should-error (call-interactively #'hui-kill-region) :type 'error)
+
       (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)))
+
+      (erase-buffer)
+      (insert "abc{def}ghi")
+      (goto-char 1)
+      (set-mark (point))
+      (goto-char 4)
+      (deactivate-mark)
+      (call-interactively #'hui-kill-region)
+      (should (string= "abcghi" (buffer-string)))
+
+      (erase-buffer)
+      (insert "abc{def}ghi")
+      (goto-char 1)
+      (set-mark (point))
+      (goto-char 5)
       (deactivate-mark)
       (call-interactively #'hui-kill-region)
-      (should (string= "{def}ghi" (buffer-string))))))
+      (should (string= "def}ghi" (buffer-string))))))
 
 ;; This file can't be byte-compiled without `with-simulated-input' which
 ;; is not part of the actual dependencies, so:



reply via email to

[Prev in Thread] Current Thread [Next in Thread]