diff options
author | Juri Linkov <juri@linkov.net> | 2020-11-15 22:32:39 +0200 |
---|---|---|
committer | Juri Linkov <juri@linkov.net> | 2020-11-15 22:32:39 +0200 |
commit | 81588748bd85827468e297d3e44a72844438e807 (patch) | |
tree | 3523ae43b965f962e6742498aa1ab95667bce9b3 /lisp/simple.el | |
parent | 4ddc38fc59845f7fa088121f435f62d1c0295c69 (diff) | |
download | emacs-81588748bd85827468e297d3e44a72844438e807.tar.gz |
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).
Diffstat (limited to 'lisp/simple.el')
-rw-r--r-- | lisp/simple.el | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/lisp/simple.el b/lisp/simple.el index e96c7c9a6ea..5158bc74a9c 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. |