Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bind all possible ex cmd abbreviations #1924

Merged
merged 1 commit into from
Jul 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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