0

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?

  • Try changing the space for a period. – wasamasa Mar 20 '16 at 20:45
  • Still not working. – Russ Kiselev Mar 21 '16 at 2:40
0

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)
  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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