aboutsummaryrefslogtreecommitdiff
path: root/evil-commands.el
diff options
context:
space:
mode:
authorAxel Forsman <axelsfor@gmail.com>2023-07-14 22:06:07 +0200
committerAxel Forsman <axelsfor@gmail.com>2023-07-17 19:02:11 +0200
commitf84d3453b312bd8ec0a1c092d075bbc3d91e157b (patch)
tree332c2d802dbda3eef60de8c29e0480e0de1b562e /evil-commands.el
parent4b45f2619258374ebb34b07212806e77bc2997c3 (diff)
Read Ex commands from buffer
When lexing a string with string-match and its START argument, there is no way to anchor matches to the START position. Instead, one must either allocate substrings - as done prior to commit 56b43b6f7e014e905f85df1c542c67f46ea99566 - or use looking-at etc., instead. This commit opts for the latter. The Ex completion-at-point functions are also rewritten in order to avoid having to add ex-index text properties to the command string, since evil--ex-syntactic-context could be extended to provide that information just as easily.
Diffstat (limited to 'evil-commands.el')
-rw-r--r--evil-commands.el33
1 files changed, 13 insertions, 20 deletions
diff --git a/evil-commands.el b/evil-commands.el
index fb8263b..f8b9cd1 100644
--- a/evil-commands.el
+++ b/evil-commands.el
@@ -3560,14 +3560,13 @@ the previous shell command is executed instead."
(if (or current-prefix-arg (evil-visual-state-p))
current-prefix-arg
(goto-char (min beg end))
- (setq current-prefix-arg (count-lines beg end))))
+ (count-lines beg end)))
(evil-ex-initial-input "!"))
(call-interactively #'evil-ex))
- (when command
- (setq command (evil-ex-replace-special-filenames command)))
(if (zerop (length command))
(when previous (setq command evil-previous-shell-command))
- (setq evil-previous-shell-command command))
+ (setq command (evil-ex-replace-special-filenames command)
+ evil-previous-shell-command command))
(cond
((zerop (length command))
(user-error "No%s shell command" (if previous " previous" "")))
@@ -3577,10 +3576,9 @@ the previous shell command is executed instead."
(let ((output-buffer (generate-new-buffer " *temp*"))
(error-buffer (generate-new-buffer " *temp*")))
(unwind-protect
- (if (zerop (shell-command-on-region beg end
- command
- output-buffer nil
- error-buffer))
+ (if (zerop (shell-command-on-region
+ beg end command
+ output-buffer nil error-buffer))
(progn
(delete-region beg end)
(insert-buffer-substring output-buffer)
@@ -3794,7 +3792,7 @@ Signal an error if the file does not exist."
"A valid evil state."
:ex-arg state
(list (when (and (evil-ex-p) evil-ex-argument)
- (intern evil-ex-argument))))
+ (intern-soft evil-ex-argument))))
;; TODO: should we merge this command with `evil-set-initial-state'?
(evil-define-command evil-ex-set-initial-state (state)
@@ -4304,25 +4302,20 @@ range. The given argument is passed straight to
(evil-with-single-undo
(let (markers evil-ex-current-buffer prefix-arg current-prefix-arg)
(goto-char beg)
- (while
- (and (< (point) end)
- (progn
- (push (move-marker (make-marker) (line-beginning-position))
- markers)
- (and (= (forward-line) 0) (bolp)))))
+ (beginning-of-line)
+ (while (when (< (point) end)
+ (push (point-marker) markers)
+ (and (= (forward-line) 0) (bolp))))
(setq markers (nreverse markers))
(deactivate-mark)
(evil-force-normal-state)
;; replace ^[ by escape
(setq commands
(vconcat
- (mapcar #'(lambda (ch) (if (equal ch ?) 'escape ch))
- (append commands nil))))
+ (mapcar (lambda (ch) (if (eq ch ?) 'escape ch)) commands)))
(dolist (marker markers)
(goto-char marker)
- (condition-case nil
- (execute-kbd-macro commands)
- (error nil))
+ (ignore-errors (execute-kbd-macro commands))
(evil-force-normal-state)
(set-marker marker nil)))))