1

In the following code I have a reproducible example of strange behavior (the macro body is probably not important):

(setq annoying-commands ())

(defmacro add-annoying-arrows-advice (cmd alternatives &optional evil-cmd evil-alternatives)
  `(progn
     (add-to-list 'annoying-commands (quote ,cmd))
     (put (quote ,cmd) 'aa--alts ,alternatives)
     (put (quote ,cmd) 'aa--evil-alts ,evil-alternatives)
     (put (quote ,cmd) 'aa--evil-cmd ,evil-cmd)
     (defadvice ,cmd (before annoying-arrows activate)
       (when annoying-arrows-mode
         (aa--maybe-complain (quote ,cmd))))))

(add-annoying-arrows-advice next-line 
'(ace-jump-mode) evil-next-visual-line '(evil-search-backward))

Evaulating this buffer gives the error:

Symbol's value as variable is void: evil-next-visual-line

This is a shame because I'd like to leave the third argument to the defmacro, namely evil-next-visual-line unquoted, just like next-line (the first argument) is.

Some really flaky behavior shows if I do the following:

(add-annoying-arrows-advice evil-next-visual-line '(smart-up) 'evil-next-visual-line '(evil-find-char-backward))

Now all of a sudden having evil-next-visual-line as an unquoted argument is okay!

How could this possibly be?

1
  • Emacs version 25.0.50.1. Commented Jan 28, 2015 at 14:41

1 Answer 1

4

I don't see an issue. Just macroexpand your stuff and you'll see the obvious errors:

(add-annoying-arrows-advice
 next-line
 '(ace-jump-mode)
 evil-next-visual-line
 '(evil-search-backward))
;; =>
(progn (add-to-list (quote annoying-commands)
                    (quote next-line))
       (put (quote next-line)
            (quote aa--alts)
            (quote (ace-jump-mode)))
       (put (quote next-line)
            (quote aa--evil-alts)
            (quote (evil-search-backward)))
       (put (quote next-line)
            (quote aa--evil-cmd)
            evil-next-visual-line)
       (defadvice next-line (before annoying-arrows activate)
         (when annoying-arrows-mode (aa--maybe-complain (quote next-line)))))

(add-annoying-arrows-advice
 evil-next-visual-line
 '(smart-up)
 'evil-next-visual-line
 '(evil-find-char-backward))
;; =>
(progn (add-to-list (quote annoying-commands)
                    (quote evil-next-visual-line))
       (put (quote evil-next-visual-line)
            (quote aa--alts)
            (quote (smart-up)))
       (put (quote evil-next-visual-line)
            (quote aa--evil-alts)
            (quote (evil-find-char-backward)))
       (put (quote evil-next-visual-line)
            (quote aa--evil-cmd)
            (quote evil-next-visual-line))
       (defadvice evil-next-visual-line (before annoying-arrows activate)
         (when annoying-arrows-mode (aa--maybe-complain (quote evil-next-visual-line))))) 
4
  • God, stupid mistake it seems. Will it be fixed by (put (quote ,cmd) 'aa--evil-cmd (quote ,evil-cmd))? Probably. Commented Jan 28, 2015 at 14:50
  • _______Probably:)
    – abo-abo
    Commented Jan 28, 2015 at 14:55
  • Yes, that was it. God how stupid I am. Commented Jan 28, 2015 at 15:13
  • Btw., I got the pretty macro expand with keys 'xfM' from github.com/abo-abo/lispy.
    – abo-abo
    Commented Jan 28, 2015 at 15:19

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.