Function: indicate-copied-region

indicate-copied-region is a byte-compiled function defined in simple.el.gz.

Signature

(indicate-copied-region &optional MESSAGE-LEN)

Documentation

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. 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 optional argument MESSAGE-LEN, if non-nil, specifies the length of this sample text; it defaults to 40.

Source Code

;; Defined in /usr/src/emacs/lisp/simple.el.gz
(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.
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
optional argument MESSAGE-LEN, if non-nil, specifies the length
of this sample text; it defaults to 40."
  (let ((mark (mark t))
	(point (point))
	;; Inhibit quitting so we can make a quit here
	;; look like a C-g typed as a command.
	(inhibit-quit t))
    (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.
	(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 copy-region-blink-delay)
	  ;; Swap back.
	  (set-marker (mark-marker) mark (current-buffer))
	  (goto-char point)
	  ;; If user quit, deactivate the mark
	  ;; as C-g would as a command.
	  (and quit-flag (region-active-p)
	       (deactivate-mark)))
      (let ((len (min (abs (- mark point))
		      (or message-len 40))))
	(if (< point mark)
	    ;; 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)))))))))