Function: avy-kill-ring-save-region

avy-kill-ring-save-region is an autoloaded, interactive and byte-compiled function defined in avy.el.

Signature

(avy-kill-ring-save-region ARG)

Documentation

Select two lines and save the region between them to the kill ring.

The window scope is determined by avy-all-windows. When ARG is non-nil, do the opposite of avy-all-windows.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/avy-20241101.1357/avy.el
;;;###autoload
(defun avy-kill-ring-save-region (arg)
  "Select two lines and save the region between them to the kill ring.
The window scope is determined by `avy-all-windows'.
When ARG is non-nil, do the opposite of `avy-all-windows'."
  (interactive "P")
  (let ((initial-window (selected-window)))
    (avy-with avy-kill-ring-save-region
      (let* ((beg (save-selected-window
                    (list (avy--line arg) (selected-window))))
             (end (list (avy--line arg) (selected-window))))
        (cond
          ((not (numberp (car beg)))
           (user-error "Fail to select the beginning of region"))
          ((not (numberp (car end)))
           (user-error "Fail to select the end of region"))
          ((not (equal (cdr beg) (cdr end)))
           (user-error "Selected points are not in the same window"))
          ((< (car beg) (car end))
           (save-excursion
             (kill-ring-save
              (car beg)
              (progn (goto-char (car end)) (forward-visible-line 1) (point)))))
          (t
           (save-excursion
             (kill-ring-save
              (progn (goto-char (car beg)) (forward-visible-line 1) (point))
              (car end)))))))
    (select-window initial-window)))