From: Lars Ingebrigtsen Date: Thu, 18 Aug 2022 21:05:17 +0000 (+0200) Subject: Fix region-extract-function compilation warning X-Git-Tag: emacs-29.0.90~1447^2~50 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=054f553b9ce0bec1ce698464bc4dc498b05a219d;p=emacs.git Fix region-extract-function compilation warning * lisp/simple.el (region-extract-function): Clean up the logic slightly to avoid a warning. --- diff --git a/lisp/simple.el b/lisp/simple.el index 1e6e5e11e00..8fb03f3b04f 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -1402,15 +1402,17 @@ instead of deleted." :version "24.1") (setq region-extract-function - (lambda (method) - (when (region-beginning) - (cond - ((eq method 'bounds) - (list (cons (region-beginning) (region-end)))) - ((eq method 'delete-only) - (delete-region (region-beginning) (region-end))) - (t - (filter-buffer-substring (region-beginning) (region-end) method)))))) + (lambda (method) + ;; This call either signals an error (if there is no region) + ;; or returns a number. + (let ((beg (region-beginning))) + (cond + ((eq method 'bounds) + (list (cons beg (region-end)))) + ((eq method 'delete-only) + (delete-region beg (region-end))) + (t + (filter-buffer-substring beg (region-end) method)))))) (defvar region-insert-function (lambda (lines)