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?

  • Emacs version 25.0.50.1. – The Unfun Cat Jan 28 '15 at 14:41
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))))) 
  • God, stupid mistake it seems. Will it be fixed by (put (quote ,cmd) 'aa--evil-cmd (quote ,evil-cmd))? Probably. – The Unfun Cat Jan 28 '15 at 14:50
  • _______Probably:) – abo-abo Jan 28 '15 at 14:55
  • Yes, that was it. God how stupid I am. – The Unfun Cat Jan 28 '15 at 15:13
  • Btw., I got the pretty macro expand with keys 'xfM' from github.com/abo-abo/lispy. – abo-abo Jan 28 '15 at 15:19

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.