Fix non-interactive behavior of 'kill-region'

* lisp/simple.el (kill-region): Actually ignore BEG and END when
REGION is non-nil.  Doc fix.  (Bug#51320)
This commit is contained in:
Eli Zaretskii 2021-10-21 22:13:09 +03:00
parent 2b7655ca0e
commit ee6bdd6eef

View file

@ -5285,11 +5285,12 @@ Lisp programs should use this function for killing text.
Supply two arguments, character positions BEG and END indicating the
stretch of text to be killed. If the optional argument REGION is
non-nil, the function ignores BEG and END, and kills the current
region instead."
region instead. Interactively, REGION is always non-nil, and so
this command always kills the current region."
;; Pass mark first, then point, because the order matters when
;; calling `kill-append'.
(interactive (list (mark) (point) 'region))
(unless (and beg end)
(unless (or region (and beg end))
(user-error "The mark is not set now, so there is no region"))
(condition-case nil
(let ((string (if region