Fun with error messages

11 views
Skip to first unread message

tinakell...@gmail.com

unread,
Feb 3, 2019, 6:38:38 PM2/3/19
to ErgoEmacs
I thought the “[key] doesn’t do anything!” messages in ErgoEmacs were a bit… brusque. So, I made them brusque and funny.

(defun tina/angry-police-captain (&optional prefix)
  (let ((buffer (ignore-errors (url-retrieve-synchronously "http://theangrypolicecaptain.com/" t t 2))))
    (when buffer
      (with-current-buffer buffer
        (goto-char (point-min))
        (let* ((begin-string "<a href=\"http://theangrypolicecaptain.com\">\n")
               (end-string "\n</a>")
               (begin (when (search-forward begin-string nil t)
                        (point)))
               (end (when (and begin (search-forward end-string nil t))
                      (- (point) (length end-string))))
               (bufstr (when (and begin end) (buffer-substring begin end))))
          (if (and prefix begin end)
              (concat prefix (substring bufstr 24))
            bufstr)))))

(defun tina/angry-police-key (args)
    (if (and (fboundp 'tina/angry-police-captain)
             (member (car args) '("%s does not do anything!"
                                  "Key %s doesn't do anything.")))
        (cons (tina/angry-police-captain "%s") (cdr args))
      args))

(dolist (message-function '(ergoemacs-command-loop--message
                            ergoemacs-command-loop--temp-message))
  (advice-add message-function :filter-args 'tina/angry-police-key))

Now you can enjoy such gems as “Ctrl+F7 wonders just what the hell happened to this town” and “Ctrl+C Ctrl+) knew your father, and he doesn’t want you to end up the same way.” Messing up keyboard input is now much more entertaining!

This was inspired by the “angry-police-captain.el” package, but doesn’t require it. It’s written such that, if there’s no Internet connection or the site takes too long, you get the regular error message instead. I hope you like my silly little diversion.
Reply all
Reply to author
Forward
0 new messages