diff options
| author | Axel Forsman <axelsfor@gmail.com> | 2023-02-09 22:14:57 +0100 |
|---|---|---|
| committer | Axel Forsman <axelsfor@gmail.com> | 2023-02-20 19:05:23 +0100 |
| commit | 22d76a4080e40381aae194c94f3bc16ba67a330a (patch) | |
| tree | 5cbb2de1d3c522cd16e610d884d745a60cf1775f /evil-common.el | |
| parent | 2ce03d412c4e93b0b89eb43d796c991806415b8a (diff) | |
Restore match data after eval:ing replacement
This fixes #1481.
Also pass along the number of the current replacement to function called
to generate each replacement, which fixes #1411.
Diffstat (limited to 'evil-common.el')
| -rw-r--r-- | evil-common.el | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/evil-common.el b/evil-common.el index 8db8d3c..ecf0bdd 100644 --- a/evil-common.el +++ b/evil-common.el @@ -3912,26 +3912,17 @@ The magic character , (comma) start an Emacs-lisp expression." (cons 'replace-eval-replacement (car (evil-compile-subreplacement to)))))) -(defun evil-replace-match (replacement &optional fixedcase string) - "Replace text match by last search with REPLACEMENT. -If REPLACEMENT is an expression it will be evaluated to compute -the replacement text, otherwise the function behaves as -`replace-match'." - (if (stringp replacement) - (replace-match replacement fixedcase nil string) - (replace-match (funcall (car replacement) - (cdr replacement) - 0) - fixedcase nil string))) - (defun evil-match-substitute-replacement (replacement &optional fixedcase string) - "Return REPLACEMENT as it will be inserted by `evil-replace-match'." - (if (stringp replacement) - (match-substitute-replacement replacement fixedcase nil string) - (match-substitute-replacement (funcall (car replacement) - (cdr replacement) - 0) - fixedcase nil string))) + "Return REPLACEMENT as it will be inserted by `evil-replace-match'. +If REPLACEMENT is an expression it will be evaluated to compute the +replacement text first." + (match-substitute-replacement + (if (stringp replacement) + replacement + (funcall (car replacement) + (cdr replacement) + 0)) + fixedcase nil string)) ;;; Alignment |
