1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2025-01-22 18:35:09 +00:00

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).
This commit is contained in:
Juri Linkov 2020-11-15 22:32:39 +02:00
parent 4ddc38fc59
commit 81588748bd
3 changed files with 46 additions and 12 deletions

View File

@ -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

View File

@ -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))))

View File

@ -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.