Skip to content


Subversion checkout URL

You can clone with
Download ZIP


It's hard to extend the list of alternatives #1

pdcawley opened this Issue · 3 comments

2 participants


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))
        (incf annoying-arrows--current-count)
        (when (> annoying-arrows--current-count annoying-arrows-too-far-count)
          (beep 1)
          (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)
       (when annoying-arrows-mode
         (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...


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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.