@@ -310,15 +310,15 @@ The following symbols have reserved meanings within a grammar:
310
310
(defvar evil-ex-reverse-range nil
311
311
" Whether the current Ex range was entered reversed." )
312
312
313
- (defvar evil--ex-expression nil
314
- " The Ex evaluation tree." )
315
-
316
313
(defvar evil--ex-cmd nil
317
314
" The current Ex command string." )
318
315
319
316
(defvar evil--ex-argument-handler nil
320
317
" The argument handler for the current Ex command." )
321
318
319
+ (defvar evil--ex-shortcut-command nil
320
+ " Interactive command to use instead of an Ex command." )
321
+
322
322
(define-error 'evil-ex-error " Ex syntax error" )
323
323
324
324
(defun evil-ex-p ()
@@ -353,7 +353,7 @@ the initial input is the visual region '<,'> or `<,`>. The variable
353
353
(let ((buffer (current-buffer ))
354
354
(previous-command (when evil-want-empty-ex-last-command
355
355
(car evil-ex-history)))
356
- s evil--ex-expression evil--ex-cmd evil--ex-argument-handler )
356
+ s evil--ex-cmd evil--ex-argument-handler evil--ex-shortcut-command )
357
357
(minibuffer-with-setup-hook
358
358
(lambda ()
359
359
(setq-local evil-ex-original-buffer buffer)
@@ -366,17 +366,17 @@ the initial input is the visual region '<,'> or `<,`>. The variable
366
366
(or initial-input
367
367
(and previous-command (propertize previous-command 'face 'shadow )))
368
368
evil-ex-completion-map nil 'evil-ex-history )))
369
- (if evil--ex-expression
370
- (eval evil--ex-expression t )
369
+ (if evil--ex-shortcut-command
370
+ (call-interactively evil--ex-shortcut-command )
371
371
(when (string= s " " ) (setq s previous-command))
372
- (unless (= ( length s) 0 ) (evil-ex-execute s)))))
372
+ (unless (string= s " " ) (evil-ex-execute s)))))
373
373
374
374
(defun evil-ex-execute (string )
375
375
" Execute STRING as an Ex command."
376
376
(eval (or (evil-ex-parse string) (signal 'evil-ex-error string)) t ))
377
377
378
- (defun evil-ex-parse (string &optional syntax entrypoint )
379
- " Parse STRING as an Ex expression and return an evaluation tree.
378
+ (defun evil-ex-parse (&optional string syntax entrypoint )
379
+ " Parse STRING as an Ex expression and return its evaluation tree.
380
380
If STRING is nil, parse the text after point instead. If SYNTAX is
381
381
non-nil, return a syntax tree instead. ENTRYPOINT is the start
382
382
symbol, which defaults to `expression' ."
@@ -416,7 +416,7 @@ actions during Ex state."
416
416
" Return non-nil if the string COMMAND has a \" !\" suffix."
417
417
(and (> (length command) 1 ) (eq (aref command (1- (length command))) ?! )))
418
418
419
- (defun evil--ex-update (&optional beg _end _len string )
419
+ (defun evil--ex-update (&optional beg _end _old-len )
420
420
" Update Ex variables when the minibuffer changes.
421
421
This function is usually called from `after-change-functions'
422
422
hook. If BEG is non-nil (which is the case when called from
@@ -425,22 +425,22 @@ in case of incomplete or unknown commands."
425
425
(when (and beg (eq this-command #'self-insert-command ))
426
426
(let ((cmd (lookup-key evil-ex-shortcut-map (minibuffer-contents-no-properties ))))
427
427
(when (commandp cmd)
428
- (setq evil--ex-expression `( call-interactively #' , cmd) )
428
+ (setq evil--ex-shortcut-command cmd)
429
429
(exit-minibuffer ))))
430
430
431
- (setq evil--ex-expression ( save-excursion ( goto-char ( minibuffer-prompt-end ) )
432
- (evil-ex-parse string ))
433
- evil-- ex-cmd nil )
434
- ( when ( eq ( car evil-- ex-expression) # ' evil-ex-call-command )
435
- (let ( current-prefix-arg func handler evil-ex-range evil-ex-bang evil-ex-argument )
431
+ (setq evil--ex-cmd nil )
432
+ ( let ((expr ( save-excursion ( goto-char ( minibuffer-prompt-end ))
433
+ ( evil-ex-parse)) )
434
+ func handler current-prefix-arg evil- ex-range evil-ex-bang evil-ex-argument )
435
+ (when ( eq ( car expr) # ' evil-ex-call-command )
436
436
(with-current-buffer evil-ex-original-buffer
437
- (let* ((range (eval (nth 1 evil--ex-expression ) t ))
437
+ (let* ((range (eval (nth 1 expr ) t ))
438
438
(count (when (integerp range) range)))
439
439
(setq current-prefix-arg count
440
440
evil-ex-range (if count (evil-ex-range count count) range)
441
- evil--ex-cmd (eval (nth 2 evil--ex-expression ) t )
441
+ evil--ex-cmd (eval (nth 2 expr ) t )
442
442
evil-ex-bang (evil--ex-bang-p evil--ex-cmd)
443
- evil-ex-argument (eval (nth 3 evil--ex-expression ) t ))))
443
+ evil-ex-argument (eval (nth 3 expr ) t ))))
444
444
(cond
445
445
((not beg))
446
446
; ; Test the current command when called from `after-change-functions'
@@ -451,8 +451,7 @@ in case of incomplete or unknown commands."
451
451
(if (eq handler evil--ex-argument-handler)
452
452
(let ((runner (evil-ex-argument-handler-runner handler)))
453
453
(when runner (funcall runner 'update evil-ex-argument)))
454
- (let ((runner (evil-ex-argument-handler-runner
455
- evil--ex-argument-handler)))
454
+ (let ((runner (evil-ex-argument-handler-runner evil--ex-argument-handler)))
456
455
(when runner (funcall runner 'stop )))
457
456
(setq evil--ex-argument-handler handler)
458
457
(let ((runner (evil-ex-argument-handler-runner handler)))
@@ -465,9 +464,6 @@ in case of incomplete or unknown commands."
465
464
(defun evil-ex-teardown ()
466
465
" Deinitialize Ex minibuffer.
467
466
Clean up everything set up by `evil-ex-setup' ."
468
- (when (eq this-command #'exit-minibuffer )
469
- ; ; Call ex--update one last time, in case after-change-functions are combined
470
- (evil--ex-update))
471
467
(let ((runner (evil-ex-argument-handler-runner evil--ex-argument-handler)))
472
468
(when runner (funcall runner 'stop ))))
473
469
@@ -747,6 +743,8 @@ This function interprets special file names like # and %."
747
743
(unless (zerop (length evil-ex-argument))
748
744
(evil-ex-replace-special-filenames evil-ex-argument)))
749
745
746
+ (define-error 'evil-ex-no-previous-cmd " No previous command line" )
747
+
750
748
(defun evil-ex-repeat (&optional count )
751
749
" Repeat the last Ex command."
752
750
(interactive " P" )
@@ -756,10 +754,10 @@ This function interprets special file names like # and %."
756
754
(cl-loop
757
755
with evil-ex-original-buffer = (current-buffer )
758
756
for last-cmd in evil-ex-history do
759
- (evil--ex-update nil nil nil last-cmd)
760
- ( let ((expr ( or evil-- ex-expression ( signal ' evil-ex-error last-cmd) )))
761
- (unless ( eq ( evil-ex-binding evil--ex- cmd) # 'evil-ex-repeat )
762
- ( cl-return ( eval expr t ))) )))
757
+ (condition-case nil
758
+ ( cl-return ( let ( evil-ex-history) ( evil-ex-execute last-cmd)))
759
+ (evil-ex-no-previous- cmd))
760
+ finally ( signal 'evil-ex-no-previous-cmd nil )))
763
761
764
762
(defun evil-ex-call-command (range command argument )
765
763
" Execute the given command COMMAND."
0 commit comments