From 054f553b9ce0bec1ce698464bc4dc498b05a219d Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Thu, 18 Aug 2022 23:05:17 +0200 Subject: [PATCH] Fix region-extract-function compilation warning * lisp/simple.el (region-extract-function): Clean up the logic slightly to avoid a warning. --- lisp/simple.el | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) 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) -- 2.39.2