diff options
| author | Tom Dalziel <tom_dl@hotmail.com> | 2023-05-30 12:49:12 +0100 |
|---|---|---|
| committer | Tom Dalziel <33435574+tomdl89@users.noreply.github.com> | 2023-05-30 16:53:28 +0200 |
| commit | be736b8dbc468d53e6cb3e76db66c1141330b030 (patch) | |
| tree | 98c33d8586f18d87edf9699caeb8c7c5ef786df1 /evil-commands.el | |
| parent | 42f4b7736f5746fd5d072139280997985ea42269 (diff) | |
Support p and # ex-substitute flags
Diffstat (limited to 'evil-commands.el')
| -rw-r--r-- | evil-commands.el | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/evil-commands.el b/evil-commands.el index 6ad0073..2bcf085 100644 --- a/evil-commands.el +++ b/evil-commands.el @@ -3854,6 +3854,25 @@ reveal.el. OPEN-SPOTS is a local version of `reveal-open-spots'." ;; Remove the overlay from the list of open spots. (overlay-put ol 'reveal-invisible nil))))) +(defun evil--ex-substitute-final-message (nreplaced flags) + "Display message according to replacements and flags. +If FLAGS contains `p' or `#' and NREPLACED is more than 0, print the last line +to the echo area. Otherwise, print the number of replacements made or found." + (let ((replaced-any (< 0 nreplaced))) + (cond + ((and replaced-any (memq ?p flags)) + (message "%s" (buffer-substring (line-beginning-position) + (line-end-position)))) + ((and replaced-any (memq ?# flags)) + (message "%s %s" (propertize (number-to-string (line-number-at-pos)) + 'face 'line-number-current-line) + (buffer-substring (line-beginning-position) + (line-end-position)))) + (t (message "%s %d occurrence%s" + (if (memq ?n flags) "Found" "Replaced") + nreplaced + (if (/= nreplaced 1) "s" "")))))) + (evil-define-operator evil-ex-substitute (beg end pattern replacement flags) "The Ex substitute command. @@ -3989,10 +4008,8 @@ reveal.el. OPEN-SPOTS is a local version of `reveal-open-spots'." (when use-reveal (evil-revert-reveal reveal-open-spots))) - (message "%s %d occurrence%s" - (if count-only "Found" "Replaced") - nreplaced - (if (/= nreplaced 1) "s" "")) + (evil--ex-substitute-final-message nreplaced flags) + (if (and (= 0 nreplaced) evil-ex-point) (goto-char evil-ex-point) (evil-first-non-blank)))) |
