[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 8158874: New user options 'copy-region-blink-delay' and 'delete-p
From: |
Juri Linkov |
Subject: |
master 8158874: New user options 'copy-region-blink-delay' and 'delete-pair-blink-delay' |
Date: |
Sun, 15 Nov 2020 15:32:52 -0500 (EST) |
branch: master
commit 81588748bd85827468e297d3e44a72844438e807
Author: Juri Linkov <juri@linkov.net>
Commit: Juri Linkov <juri@linkov.net>
New user options 'copy-region-blink-delay' and 'delete-pair-blink-delay'
* lisp/emacs-lisp/lisp.el (delete-pair-blink-delay): New defcustom.
(delete-pair): Use it. (Bug#4136)
* lisp/simple.el (copy-region-blink-delay): New defcustom.
(indicate-copied-region): Use it. (Bug#42865)
Thanks to Sean Whitton <spwhitton@spwhitton.name>.
(indicate-copied-region): Use 'query-replace-descr' not to show
newlines literally. Use "Copied text" instead of misleading
"Saved text" (bug#42865).
---
etc/NEWS | 6 ++++++
lisp/emacs-lisp/lisp.el | 16 +++++++++++++++-
lisp/simple.el | 36 +++++++++++++++++++++++++-----------
3 files changed, 46 insertions(+), 12 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index 7aa5488..90e4d29 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -203,6 +203,12 @@ This command would previously not redefine values defined
by these
forms, but this command has now been changed to work more like
'eval-defun', and reset the values as specified.
+---
+** New user options 'copy-region-blink-delay' and 'delete-pair-blink-delay'.
+'copy-region-blink-delay' specifies a delay to indicate the region
+copied by 'kill-ring-save'. 'delete-pair-blink-delay' specifies
+a delay to show a paired character to delete.
+
+++
** New command 'undo-redo'.
It undoes previous undo commands, but doesn't record itself as an
diff --git a/lisp/emacs-lisp/lisp.el b/lisp/emacs-lisp/lisp.el
index 3559012..1249001 100644
--- a/lisp/emacs-lisp/lisp.el
+++ b/lisp/emacs-lisp/lisp.el
@@ -784,9 +784,17 @@ This command assumes point is not in a string or comment."
(interactive "P")
(insert-pair arg ?\( ?\)))
+(defcustom delete-pair-blink-delay blink-matching-delay
+ "Time in seconds to delay after showing a paired character to delete.
+It's used by the command `delete-pair'. The value 0 disables blinking."
+ :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 @@ A negative ARG deletes a pair around the preceding ARG
sexps instead."
(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 +825,9 @@ A negative ARG deletes a pair around the preceding ARG
sexps instead."
(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 e96c7c9..5158bc7 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -5087,11 +5087,20 @@ visual feedback indicating the extent of the region
being copied."
(if (called-interactively-p 'interactive)
(indicate-copied-region)))
+(defcustom copy-region-blink-delay 1
+ "Time in seconds to delay after showing the other end of the region.
+It's used by the command `kill-ring-save' and the function
+`indicate-copied-region' to blink the cursor between point and mark.
+The value 0 disables blinking."
+ :type 'number
+ :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 +5114,14 @@ of this sample text; it defaults to 40."
(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)
@@ -5121,11 +5132,14 @@ of this sample text; it defaults to 40."
(let ((len (min (abs (- mark point))
(or message-len 40))))
(if (< point mark)
- ;; Don't say "killed"; that is misleading.
- (message "Saved text until \"%s\""
- (buffer-substring-no-properties (- mark len) mark))
- (message "Saved text from \"%s\""
- (buffer-substring-no-properties mark (+ mark len))))))))
+ ;; Don't say "killed" or "saved"; that is misleading.
+ (message "Copied text until \"%s\""
+ ;; Don't show newlines literally
+ (query-replace-descr
+ (buffer-substring-no-properties (- mark len) mark)))
+ (message "Copied text from \"%s\""
+ (query-replace-descr
+ (buffer-substring-no-properties mark (+ mark len)))))))))
(defun append-next-kill (&optional interactive)
"Cause following command, if it kills, to add to previous kill.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 8158874: New user options 'copy-region-blink-delay' and 'delete-pair-blink-delay',
Juri Linkov <=