From 49fc382e97f1900c228749fa592fd31408d5eb51 Mon Sep 17 00:00:00 2001 From: Axel Forsman Date: Sun, 15 Jan 2023 22:38:07 +0100 Subject: [PATCH] Re-add return-type evil-operator-range argument It was removed by commit 29a5d464e973b66abae20e6c4b402a366547c7a5, however this broke the evil-surround package. --- evil-macros.el | 21 +++++++++++++-------- evil-types.el | 7 ++----- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/evil-macros.el b/evil-macros.el index 5e57f617d..4631a998e 100644 --- a/evil-macros.el +++ b/evil-macros.el @@ -563,24 +563,26 @@ Optional keyword arguments are: (setq evil-inhibit-operator-value nil))))) ;; this is used in the `interactive' specification of an operator command -(defun evil-operator-range () - "Read a motion from the keyboard and return its buffer positions." - (let* ((evil-ex-p (and (not (minibufferp)) (evil-ex-p))) +(defun evil-operator-range (&optional return-type) + "Read a motion from the keyboard and return its buffer positions. +The return value is a list (BEG END), or (BEG END TYPE) if +RETURN-TYPE is non-nil." + (let* ((ex-p (and (not (minibufferp)) (evil-ex-p))) (motion (or evil-operator-range-motion - (when evil-ex-p 'evil-line))) + (when ex-p 'evil-line))) (type evil-operator-range-type) range count) (setq evil-this-type-modified nil) (evil-save-echo-area (cond ;; Ex mode - ((and evil-ex-p evil-ex-range) + ((and ex-p evil-ex-range) (setq range evil-ex-range)) ;; Visual selection - ((and (not evil-ex-p) (evil-visual-state-p)) + ((and (not ex-p) (evil-visual-state-p)) (setq range (evil-visual-range))) ;; active region - ((and (not evil-ex-p) (region-active-p)) + ((and (not ex-p) (region-active-p)) (setq range (evil-range (region-beginning) (region-end) (or evil-this-type 'exclusive)))) @@ -636,7 +638,10 @@ Optional keyword arguments are: (setq evil-operator-range-beginning (evil-range-beginning range) evil-operator-range-end (evil-range-end range) evil-operator-range-type (evil-type range)) - range)) + (if return-type + (list (car range) (cadr range) (evil-type range)) + (setcdr (cdr range) nil) + range))) (defmacro evil-define-type (type doc &rest body) "Define type TYPE. diff --git a/evil-types.el b/evil-types.el index 47b064e3f..276cdbbf1 100644 --- a/evil-types.el +++ b/evil-types.el @@ -305,14 +305,11 @@ directly." (evil-define-interactive-code "" "Untyped motion range (BEG END)." - (let ((range (evil-operator-range))) - (setcdr (cdr range) nil) - range)) + (evil-operator-range)) (evil-define-interactive-code "" "Typed motion range (BEG END TYPE)." - (let ((range (evil-operator-range))) - (list (car range) (cadr range) (evil-type range)))) + (evil-operator-range t)) (evil-define-interactive-code "" "Typed motion range of visual range(BEG END TYPE).