2

Currently in Emacs Lisp files I have the following behavior when I run evil-forward-word-begin

|some-lisp-function
some|-lisp-function
some-|lisp-function
some-lisp|-function
some-lisp-|function

In other words, dash is treated as it's own word.

I'd like it to be this way:

|some-lisp-function
some-|lisp-function
some-lisp-|function

Under syntax table dash is listed as a symbol, so I fugired if I changed dash to whitespace in the syntax table, it would be skipped:

(modify-syntax-entry ?- " ")

However that accomplished nothing. What am I doing wrong?

2
  • Try changing the space for a period.
    – wasamasa
    Commented Mar 20, 2016 at 20:45
  • Still not working. Commented Mar 21, 2016 at 2:40

1 Answer 1

2

Turns out looking at the syntax table had little merit.

The solution that I've found is to just advice the evil-word functions to skip over the dash.

  (defun skip-dash-backward (n &rest foo)
    (if (eq (char-before (point)) ?-)
        (backward-char))
    (message "Skipped dash"))

  (defun skip-dash-forward (n &rest foo)
    (if (eq (char-after (point)) ?-)
        (forward-char))
    (message "Skipped dash"))

  (defun skip-dash-forward-end (n &rest foo)
    (if (eq (char-after (+ 1 (point))) ?-)
        (forward-char))
    (message "Skipped dash"))

  (advice-add 'evil-forward-word-begin :after #'skip-dash-forward)
  (advice-add 'evil-forward-word-end :before #'skip-dash-forward-end)
  (advice-add 'evil-backward-word-begin :before #'skip-dash-backward)
1
  • If this solution fixed your problem, could you please accept your own answer so we can mark it as completed?
    – Dan
    Commented Feb 28, 2017 at 17:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.