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

Hard-coded whitespace check causing inconsistencies #1958

Open
kim366 opened this issue Jan 27, 2025 · 2 comments
Open

Hard-coded whitespace check causing inconsistencies #1958

kim366 opened this issue Jan 27, 2025 · 2 comments

Comments

@kim366
Copy link

kim366 commented Jan 27, 2025

Say we open a scratch buffer with the following contents:

abc_xyz#
abc xyz#

We run

(modify-syntax-entry ?_ " ")
(modify-category-entry ?_ ?r nil t)

Now (describe-syntax) shows

_                 	which means: whitespace

The parent syntax table is:
@               _ 	which means: symbol

The parent syntax table is:
...
SPC               	which means: whitespace
...

and (describe-categories) shows

character(s)	category mnemonics
------------	------------------
C-@ .. C-_      
SPC             .al
...
_               .al

So now SPC and _ are equivalent for Emacs.

Running (forward-word) twice in each line indeed leads to the same movement.

But if we use Evil (evil-forward-word-begin), the movements in the two lines differ, needing three movements in the first line and two in the second.

I have identified the cause to be this line:

(evil-forward-chars "^[:word:]\n\r\t\f " cnt))

I understand that evil aims to be compatible with Vim, but it should also respect the built-in facilities that Emacs provides, such as the syntax tables, similar to the category tables used a couple lines above.

It seems to me, that these two lines in question handle the case of a non-word non-whitespace character. There exist Emacs character classes for both of those. Would it be fine to replace this with it?

Thanks,
Kim

@kim366
Copy link
Author

kim366 commented Jan 27, 2025

Right below, in the definition of forward-evil-symbol, the Emacs syntax is used, as I would expect:

(evil-forward-syntax "^w_->" cnt))

The definition for word would be very similar:

(evil-forward-syntax "^w->" cnt)

Is there a conscious reason why this was not done this way?

@kim366
Copy link
Author

kim366 commented Jan 27, 2025

From what I gather, by default, the difference between (evil-forward-syntax "^w->" cnt) and (evil-forward-chars "^[:word:]\n\r\t\f " cnt) is the inclusion of Control characters C-@-C-h (ASCII 0-8). Is their inclusion problematic? If so, maybe a compromise would be to remove them from the syntax entry for the duration of the command.

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

No branches or pull requests

1 participant