[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#4136: 23.1; delete-pair
From: |
Juri Linkov |
Subject: |
bug#4136: 23.1; delete-pair |
Date: |
Fri, 13 Nov 2020 10:29:08 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) |
>> @@ -802,6 +810,9 @@ delete-pair
>> (if (= (length p) 3) (cdr p) p))
>> insert-pair-alist))
>> (error "Not after matching pair"))
>> + (when (and (natnump delete-pair-blink-delay)
>> + (> delete-pair-blink-delay 0))
>> + (sit-for delete-pair-blink-delay))
>
> Why can't the delay be a float?
My mistake was influenced by the lack of the function that
would check for a positive number (e.g. 'positive-number-p').
I tried to find such a function, then noticed that 'natnump'
at least checks for a non-negative number, but I forgot that
this applies only to integers. So below is a fixed patch:
diff --git a/lisp/emacs-lisp/lisp.el b/lisp/emacs-lisp/lisp.el
index 35590123ee..dca132cc7f 100644
--- a/lisp/emacs-lisp/lisp.el
+++ b/lisp/emacs-lisp/lisp.el
@@ -784,9 +784,18 @@ insert-parentheses
(interactive "P")
(insert-pair arg ?\( ?\)))
+(defcustom delete-pair-blink-delay blink-matching-delay
+ "Time in seconds to delay after showing a pair character to delete.
+The value 0 disables blinking."
+ :type 'number
+ :set-after '(blink-matching-delay)
+ :group 'lisp
+ :version "28.1")
+
(defun delete-pair (&optional arg)
"Delete a pair of characters enclosing ARG sexps that follow point.
-A negative ARG deletes a pair around the preceding ARG sexps instead."
+A negative ARG deletes a pair around the preceding ARG sexps instead.
+The option `delete-pair-blink-delay' can disable blinking."
(interactive "P")
(if arg
(setq arg (prefix-numeric-value arg))
@@ -802,6 +811,9 @@ delete-pair
(if (= (length p) 3) (cdr p) p))
insert-pair-alist))
(error "Not after matching pair"))
+ (when (and (numberp delete-pair-blink-delay)
+ (> delete-pair-blink-delay 0))
+ (sit-for delete-pair-blink-delay))
(delete-char 1)))
(delete-char -1))
(save-excursion
@@ -814,6 +826,9 @@ delete-pair
(if (= (length p) 3) (cdr p) p))
insert-pair-alist))
(error "Not before matching pair"))
+ (when (and (numberp delete-pair-blink-delay)
+ (> delete-pair-blink-delay 0))
+ (sit-for delete-pair-blink-delay))
(delete-char -1)))
(delete-char 1))))
diff --git a/lisp/simple.el b/lisp/simple.el
index e96c7c9a6e..d7626e354a 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -5087,11 +5087,19 @@ kill-ring-save
(if (called-interactively-p 'interactive)
(indicate-copied-region)))
+(defcustom copy-region-blink-delay blink-matching-delay
+ "Time in seconds to delay after showing a pair character to delete.
+The value 0 disables blinking."
+ :type 'number
+ :set-after '(blink-matching-delay)
+ :group 'killing
+ :version "28.1")
+
(defun indicate-copied-region (&optional message-len)
"Indicate that the region text has been copied interactively.
-If the mark is visible in the selected window, blink the cursor
-between point and mark if there is currently no active region
-highlighting.
+If the mark is visible in the selected window, blink the cursor between
+point and mark if there is currently no active region highlighting.
+The option `copy-region-blink-delay' can disable blinking.
If the mark lies outside the selected window, display an
informative message containing a sample of the copied text. The
@@ -5105,12 +5113,14 @@ indicate-copied-region
(if (pos-visible-in-window-p mark (selected-window))
;; Swap point-and-mark quickly so as to show the region that
;; was selected. Don't do it if the region is highlighted.
- (unless (and (region-active-p)
- (face-background 'region nil t))
+ (when (and (numberp copy-region-blink-delay)
+ (> copy-region-blink-delay 0)
+ (or (not (region-active-p))
+ (not (face-background 'region nil t))))
;; Swap point and mark.
(set-marker (mark-marker) (point) (current-buffer))
(goto-char mark)
- (sit-for blink-matching-delay)
+ (sit-for copy-region-blink-delay)
;; Swap back.
(set-marker (mark-marker) mark (current-buffer))
(goto-char point)