I have the fastnav suite of navigational tools installed and wanted to add them to the list of less annoying alternatives for the various annoying commands, so rather than just altering the calls to aa-add-annoying-arrows-advice, I did this:
(defun aa--maybe-complain (cmd)
(if (and (memq this-command annoying-commands)
(eq this-command last-command))
(when (> annoying-arrows--current-count annoying-arrows-too-far-count)
(let* ((alts (aa--commands-with-shortcuts (get cmd 'aa--alts)))
(alt (nth (random (length alts)) alts))
(key (substitute-command-keys (format "\\[%S]" alt))))
(message "Annoying! How about using %S (%s) instead?" alt key))))
(setq annoying-arrows--current-count 0)))
(defmacro add-annoying-arrows-advice (cmd alternatives)
(add-to-list 'annoying-commands (quote ,cmd))
(put (quote ,cmd) 'aa--alts ,alternatives)
(defadvice ,cmd (before annoying-arrows activate)
(aa--maybe-complain (quote ,cmd))))))
(defun aa-add-suggestion (cmd alternative)
(let ((old-alts (or (get cmd 'aa--alts)
(unless (memq alternative old-alts)
(put cmd 'aa--alts (cons alternative old-alts)))))
And then I could do (aa-add-suggestion next-line 'fastnav-jump-to-char-backward) in my config files and not have to worry about editing annoying-arrows.el again. get and put are two of my favourite elisp commands...
(aa-add-suggestion next-line 'fastnav-jump-to-char-backward)
This is interesting. I'll have a look at it tonight or tomorrow. I'll also have to check out fastnav. Thanks!
That looks pretty nice. I'd be happy to accept a pull request with this change.