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?

Russ Kiselev
  • 464
  • 3
  • 10

1 Answers1

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)
Russ Kiselev
  • 464
  • 3
  • 10
  • If this solution fixed your problem, could you please accept your own answer so we can mark it as completed? – Dan Feb 28 '17 at 17:40