I am using Emacs 25.5 and now am getting the message: "<Scroll_Lock> is undefined" appearing regularly in the Messages buffer. If I turn on debug-on-error, it doesn't stop on it and show me where it is coming from. I suspect it is related to one of the issues preventing me from upgrading to Emacs 27.1 (which is scroll-lock mode keeps getting turned on, which is a feature I don't want). But I don't know what is triggering it or how to even grep for it. It's not in any of my personal .el files.

By the way this Lenovo Flex 5 doesn't even have a key labeled scroll lock. Perhaps it is a feature of the touchpad.

  • You are right, my mind erroneously added the "." to the message. It isn't there is the Messages buffer. This is why I am a terrible proof-reader. Oct 11 '20 at 16:20

I figured out that I should add the following code to my .emacs file:

(defvar in-xxx-message nil)
(defun xxx-message (&rest args)
      (let ((result (apply 'format args)))
        (if (and (not in-xxx-message)
                 (or (string-match "<Scroll_Lock>" result)
                     (string-match "is undefined" result)
                     ) ; or
             ) ; and
           (let ((in-xxx-message t))
              (error result)
              ) ; let
           ;; else
           (orig-message result)
         ) ; if
       ) ; let
     ) ; args
   (t (orig-message))
   ) ; cond
 ) ; defun
(defalias 'orig-message (symbol-function 'message))
(defalias 'message 'xxx-message)

Then I got the *Backtrace* buffer I was hoping for. It turns out that subr.el defines a function undefined() that it maps to all keys that don't have a keydef.

So, my "hack" was the solution I was looking for. I presume something has happened in a recent update (to Windows perhaps) that has started returning this keycode. I still haven't found out why, but at least I know how to make it a no op.

This isn't quite the answer I want, but I did figure out that I could just add a keybinding for it and solve my problem. I would still like to know how to find obscure messages in Emacs and get to the root cause. If I find a better way, to find messages I will add that as an answer. (Or maybe I'll get lucky and someone will tell me.)

Anyway, my workaround:

(defun do-nothing () (interactive))
(global-set-key (kbd "<Scroll_Lock>") 'do-nothing)

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.