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

Vi non broad word chars #1106

Merged
merged 7 commits into from
Sep 28, 2023

Conversation

ilya-fiveisky
Copy link
Contributor

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 if iskeyword is made as a white-list non-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 the init.lisp file. For lisp mode it may be reasonable to add parentheses while initializing the mode but it is not implemented right now.

@cxxxr cxxxr requested review from fukamachi and removed request for fukamachi September 25, 2023 12:42
(defun compile-non-broad-word-char (value)
(compile-rules value "non-broad-word-char"))

(define-option "non-broad-word-char"
Copy link
Collaborator

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?

Copy link
Contributor Author

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.

Copy link
Collaborator

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.

Copy link
Contributor Author

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.

Comment on lines 32 to 45
(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")))))
Copy link
Collaborator

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!

@fukamachi fukamachi merged commit cdf0192 into lem-project:main Sep 28, 2023
1 check passed
@fukamachi
Copy link
Collaborator

We appreciate your contribution!

@ilya-fiveisky ilya-fiveisky deleted the vi-non-broad-word-chars branch September 28, 2023 01:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants