Function: delete-active-region

delete-active-region is an autoloaded, interactive and byte-compiled function defined in delsel.el.gz.

Signature

(delete-active-region &optional KILLP)

Documentation

Delete the active region.

If KILLP is non-nil, or if called interactively with a prefix argument, the active region is killed instead of deleted.

View in manual

Probably introduced at or before Emacs version 24.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/delsel.el.gz
;;;###autoload
(defun delete-active-region (&optional killp)
  "Delete the active region.
If KILLP is non-nil, or if called interactively with a prefix argument,
the active region is killed instead of deleted."
  (interactive "P")
  (cond
   (killp
    ;; Don't allow `kill-region' to change the value of `this-command'.
    (let (this-command)
      (kill-region (point) (mark) t)))
   (delete-selection-save-to-register
    (set-register delete-selection-save-to-register
                  (funcall region-extract-function t))
    (if (overlayp delete-selection--replacement-text)
        (move-overlay delete-selection--replacement-text
                      (point) (point) (current-buffer))
      (setq delete-selection--replacement-text
            (make-overlay (point) (point) nil nil t))
      (overlay-put delete-selection--replacement-text 'face
                   'delete-selection-replacement))
      ;; Make sure the overlay doesn't linger indefinitely.
      (overlay-put delete-selection--replacement-text
                   'cursor-sensor-functions
                   (list #'delete-selection--replacement-cursor))
      (unless (bound-and-true-p cursor-sensor-mode) (cursor-sensor-mode 1)))
   (t
    (funcall region-extract-function 'delete-only))))