Clojure friendly word definitions in Emacs

Want Emacs to treat some-symbol as a single word for editing? I do! And here is how:
Add to your init.el

(dolist (c (string-to-list ":_-?!#*"))
  (modify-syntax-entry c "w" emacs-lisp-mode-syntax-table))

This works great with evil-mode (vim style) delete word (dw) and change word (cw) shortcuts.

7 comments:

  1. Hi Timothy,

    Nice hack. Thanks.

    If you're editing .clj or .cljs using clojure-mode, you need to add this to clojure-mode-syntax-table instead of emacs-lisp-mode-syntax-table:

    (dolist (c (string-to-list ":_-?!#*"))
    (modify-syntax-entry c "w" clojure-mode-syntax-table ))

    Thanks again.

    ReplyDelete
  2. What are you, a wizard? :)
    I was just thinking about this an hour ago and now I have a solution! Thanks! :)

    ReplyDelete
  3. Replies
    1. You are welcome, I am glad you found it useful.

      Delete
  4. I seem to remember that clojure-mode did this independently, but not for some time now.

    BTW, another big win is evil-enabled search-current-word (`*`).

    Thanks!

    ReplyDelete
    Replies
    1. Ah yes, I love the splat * operator! :)

      Delete
  5. Nice trick indeed! I tried it right away, but adding it completely breaks indentation of maps (Emacs Live, latest clojure-mode)...I had to remove the addition.

    ReplyDelete