-
-
Notifications
You must be signed in to change notification settings - Fork 185
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
Vi non broad word chars #1106
Vi non broad word chars #1106
Conversation
extensions/vi-mode/options.lisp
Outdated
(defun compile-non-broad-word-char (value) | ||
(compile-rules value "non-broad-word-char")) | ||
|
||
(define-option "non-broad-word-char" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like you to take this as a strong opinion, but I'm not sure about this naming.
All Vim options doesn't contains symbols in their name, and all this kind of options starts with is
.
So, maybe isseparator
or isblank
... something like that looks ideal to me.
How do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then I suggest isWORDseparator
because in Vim broad word is called WORD. Otherwise it is not clear separator of what it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even better. That sounds reasonable in some sense, but the upcased name is also strange since all Vim's options have downcased names.
Vim has isprint
to set custom printable chars, so isseparator
doesn't look weird to me, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. Let it be isseparator
then.
(deftest non-broad-word-char-option | ||
(ok (typep (get-option "non-broad-word-char") 'option) | ||
"Can get non-broad-word-char option") | ||
(ok (typep (get-option "nbwc") 'option) | ||
"Can get non-broad-word-char option by alias") | ||
(with-fake-interface () | ||
(with-vi-buffer (#?"abc\n[(]def)\n") | ||
(cmd "E") | ||
(ok (buf= #?"abc\n(def[)]\n"))) | ||
(with-vi-buffer (#?"abc\n[(]def)\n") | ||
(execute-set-command "nbwc+=(") | ||
(execute-set-command "nbwc+=)") | ||
(cmd "WE") | ||
(ok (buf= #?"abc\n(de[f])\n"))))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for writing tests!
We appreciate your contribution! |
Motivation:
Vi mode broad word is not extensible right now in a sense that non broad word characters are hard coded as space characters only. In lisp code it is very inconvenient (or even dangerous) because parentheses here are delimiters as important as spaces. In case of deleting a broad word it can lead to unbalanced parentheses for example.
Implementation:
It is implemented symmetrically to
iskeyword
option. That is ifiskeyword
is made as a white-listnon-broad-word-char
option is made as a black-list with space characters as its default values. Additional characters (parentheses for example) are typically added in theinit.lisp
file. For lisp mode it may be reasonable to add parentheses while initializing the mode but it is not implemented right now.