GNU bug report logs - #4136
23.1; delete-pair

Previous Next

Package: emacs;

Reported by: Eli Barzilay <eli <at> barzilay.org>

Date: Thu, 13 Aug 2009 06:30:04 UTC

Severity: normal

Tags: fixed, moreinfo

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #180 received at 4136 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: "Basil L. Contovounesios" <contovob <at> tcd.ie>
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, 4136 <at> debbugs.gnu.org,
 Eli Barzilay <eli <at> barzilay.org>
Subject: Re: bug#4136: 23.1; delete-pair
Date: Fri, 13 Nov 2020 10:29:08 +0200
[Message part 1 (text/plain, inline)]
>> @@ -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:

[blink-delay-2.patch (text/x-diff, inline)]
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)

This bug report was last modified 4 years and 182 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.