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

Suggestion - add additional characters to syntax table to support evil mode word motions #647

Open
davesann opened this issue Mar 7, 2023 · 1 comment

Comments

@davesann
Copy link

davesann commented Mar 7, 2023

Expected behavior

in evil mode w motion should work on clojure symbols for example: this-symbol?!

Actual behavior

currently the motion will only include 'this' - i.e up to to the hyphen.

Steps to reproduce the problem

std doom-emacs with clojure mode

Environment & Version information

clojure-mode version

clojure-mode (version 5.16.0)

Emacs version

GNU emascs 27.1

Operating system

Linux 5.15.0-67-generic #74-Ubuntu SMP Wed Feb 22 14:14:39 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

Suggested change

I am not too familiar with emacs lisp or the clojure mode so this is just a suggestion - it has worked for me in my local configs.

add the following extensions to the word syntax definitions in the clojure-mode-syntax-table (there may be a more compact way of expressing that but I am not familiar with required syntax).

you may or may not want to include the # character. I found it useful and it is accepted in symbols

I am not certain how/if to this should be changed where a character is not allowed as the first char of a word....

I note also that motions like yW are a problem because they pick up brackets when at the end of an expression. So I also included # / : and . because these are useful. There may be a better way to include these...

    ;; word syntax: add clojure symbol characters
    ;;  as per https://clojure.org/reference/reader
    (modify-syntax-entry ?* "w" table)
    (modify-syntax-entry ?+ "w" table)
    (modify-syntax-entry ?! "w" table)
    (modify-syntax-entry ?- "w" table)
    (modify-syntax-entry ?_ "w" table)
    (modify-syntax-entry ?' "w" table)
    (modify-syntax-entry ?? "w" table)
    (modify-syntax-entry ?< "w" table)
    (modify-syntax-entry ?> "w" table)

    ;; word-syntax: and other characters that 
    ;;  are useful in word motions
    (modify-syntax-entry ?# "w" table)
    (modify-syntax-entry ?/ "w" table)
    (modify-syntax-entry ?: "w" table)
    (modify-syntax-entry ?. "w" table)    
@yuhan0
Copy link
Contributor

yuhan0 commented Apr 21, 2023

This proposal would introduce inconsistency with all other lisp modes and likely break things for various tools and non-evil users. The "w" and "_" syntax descriptors have specific meanings in Emacs, see https://emacs.stackexchange.com/questions/1075/whats-the-difference-between-words-and-symbols

The issue is that Vi's concept of word/WORD motions are not ergonomic to use with lisps; packages like evil-cleverparens / lispyville address this by defining new motions and remapping the w / b etc. bindings.
https://github.com/emacs-evil/evil-cleverparens#movement
https://github.com/noctuid/lispyville#atom-movement-key-theme (I use this personally)

Edit: it looks like evil-mode has a built-in solution too:
https://evil.readthedocs.io/en/latest/faq.html

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

2 participants