aboutsummaryrefslogtreecommitdiff
path: root/evil-commands.el
diff options
context:
space:
mode:
authorFrank Fischer <frank.fischer@mathematik.tu-chemnitz.de>2013-02-15 14:47:03 +0100
committerFrank Fischer <frank.fischer@mathematik.tu-chemnitz.de>2013-02-15 14:47:03 +0100
commitd17c3a550d4c5aa3eabe10fcc5c1230e1a560254 (patch)
tree73cdb221873ac4f884b001f31246d97d45e1d435 /evil-commands.el
parent15254636a35641d1a8286053a16a5e05c683cbe2 (diff)
Fix the state argument type for ex state.
This argument type, used for :set-initial-state, still used a very old code that is wrong with the current completion system. This change fixes the definition of the completer, adds a new interactive type <state> and changes the interactive code of `evil-ex-set-initial-state` accordingly.
Diffstat (limited to 'evil-commands.el')
-rw-r--r--evil-commands.el52
1 files changed, 32 insertions, 20 deletions
diff --git a/evil-commands.el b/evil-commands.el
index d034a03..4f11355 100644
--- a/evil-commands.el
+++ b/evil-commands.el
@@ -2493,33 +2493,45 @@ the previous shell command is executed instead."
(forward-line (1- line))))
(error "File does not exist."))))
-(evil-ex-define-argument-type state (flag &rest args)
+(evil-ex-define-argument-type state
"Defines an argument type which can take state names."
- (when (eq flag 'complete)
- (let ((arg (pop args))
- (predicate (pop args))
- (flag (pop args))
- (completions
- (append '("nil")
- (mapcar #'(lambda (state)
- (format "%s" (car state)))
- evil-state-properties))))
- (when arg
- (cond
- ((eq flag nil)
- (try-completion arg completions predicate))
- ((eq flag t)
- (all-completions arg completions predicate))
- ((eq flag 'lambda)
- (test-completion arg completions predicate)))))))
+ :completer
+ (lambda ()
+ (list
+ (point-min) (point-max)
+ (lambda (arg predicate flag)
+ (let ((completions
+ (append '("nil")
+ (mapcar #'(lambda (state)
+ (format "%s" (car state)))
+ evil-state-properties))))
+ (when arg
+ (cond
+ ((eq flag nil)
+ (try-completion arg completions predicate))
+ ((eq flag t)
+ (all-completions arg completions predicate))
+ ((eq flag 'lambda)
+ (test-completion arg completions predicate))
+ ((eq (car-safe flag) 'boundaries)
+ (cons 'boundaries
+ (completion-boundaries arg
+ completions
+ predicate
+ (cdr flag)))))))))))
+
+(evil-define-interactive-code "<state>"
+ "A valid evil state."
+ :ex-arg state
+ (list (when (and (evil-ex-p) evil-ex-argument)
+ (intern evil-ex-argument))))
;; TODO: should we merge this command with `evil-set-initial-state'?
(evil-define-command evil-ex-set-initial-state (state)
"Set the initial state for the current major mode to STATE.
This is the state the buffer comes up in. See `evil-set-initial-state'."
- :ex-arg state
:repeat nil
- (interactive "<sym>")
+ (interactive "<state>")
(if (not (or (assq state evil-state-properties)
(null state)))
(error "State %s cannot be set as initial Evil state" state)