Skip to content

Commit

Permalink
Bind all possible ex cmd abbreviations
Browse files Browse the repository at this point in the history
Means that :de expands to delete
  • Loading branch information
tomdl89 committed Jul 17, 2024
1 parent 81ec688 commit b07f241
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions evil-ex.el
Original file line number Diff line number Diff line change
Expand Up @@ -585,13 +585,15 @@ in case of incomplete or unknown commands."

(defun evil-ex-define-cmd (cmd function)
"Bind the function FUNCTION to the command CMD."
(if (string-match "\\[\\(.*\\)\\]" cmd)
(let ((abbrev (replace-match "" nil t cmd))
(full (replace-match "\\1" nil nil cmd)))
(if (not (string-match-p "\\[" cmd))
(evil--add-to-alist evil-ex-commands cmd function)
(string-match "\\(.*\\)\\[\\(.*\\)\\]" cmd)
(let ((mandatory (match-string 1 cmd))
(optional (match-string 2 cmd)))
(dotimes (n (1+ (length optional)))
(evil--add-to-alist evil-ex-commands
full function
abbrev full))
(evil--add-to-alist evil-ex-commands cmd function)))
(concat mandatory (substring optional 0 n))
function)))))

(defmacro evil-ex-define-argument-type (arg-type doc &rest body)
"Define a new handler for argument-type ARG-TYPE.
Expand Down

0 comments on commit b07f241

Please sign in to comment.