[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: |
Thu, 12 Nov 2020 22:21:21 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) |
>> How about using the same delay blink-matching-delay that is used
>> after showing a matching paren, but in this case to show
>> a character at the other end of the pair with a delay
>> before deleting it?
>
> Makes sense to me, but I'm not a regular user of delete-pair, so I don't
> know whether that'd be annoying or reassuring...
After a month of using it the following patch proved to be useful.
It adds anew new defcustom delete-pair-blink-delay based on the default
value of blink-matching-delay. Exactly the same defcustom is also
added copy-region-blink-delay for the feature request in bug#42865
not to blink when copying a region:
diff --git a/lisp/emacs-lisp/lisp.el b/lisp/emacs-lisp/lisp.el
index 35590123ee..be2adfa848 100644
--- a/lisp/emacs-lisp/lisp.el
+++ b/lisp/emacs-lisp/lisp.el
@@ -784,9 +784,17 @@ 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.
+No timeout in case of 0."
+ :type 'number
+ :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 +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))
(delete-char 1)))
(delete-char -1))
(save-excursion
@@ -814,6 +825,9 @@ delete-pair
(if (= (length p) 3) (cdr p) p))
insert-pair-alist))
(error "Not before matching pair"))
+ (when (and (natnump 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..3d18909f2c 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -5089,9 +5089,9 @@ kill-ring-save
(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
@@ -5106,11 +5106,13 @@ indicate-copied-region
;; 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))
+ (face-background 'region nil t)
+ (natnump copy-region-blink-delay)
+ (> copy-region-blink-delay 0))
;; 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)
@@ -8135,6 +8139,13 @@ blink-paren-post-self-insert-function
;; `sit-for'. That's also the reason it get a `priority' prop
;; of 100.
'append)
+
+(defcustom copy-region-blink-delay blink-matching-delay
+ "Time in seconds to delay after showing a pair character to delete.
+No timeout in case of 0."
+ :type 'number
+ :group 'killing
+ :version "28.1")
;; This executes C-g typed while Emacs is waiting for a command.
;; Quitting out of a program does not go through here;
- bug#4136: 23.1; delete-pair,
Juri Linkov <=