How to track down where Emacs message " is undefined" comes from?

Emacs Asked by intel_chris on December 11, 2020

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.

One Answer

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)

Answered by intel_chris on December 11, 2020

Add your own answers!

Related Questions

How to check if a customize group exists in Emacs Lisp code?

1  Asked on September 2, 2021 by prouleau


encrypted password file with emacs & gpg

1  Asked on September 2, 2021 by user313032


How to pass an optional agrument to kill-emacs?

1  Asked on September 2, 2021 by ianinini


Tramp can’t connect – cannot find ssh

0  Asked on September 2, 2021 by n1k31t4


Emacs insane CPU load caused by org-superstar-mode

2  Asked on September 2, 2021 by mor3dr3ad


What ASCII character is C-q C-E?

1  Asked on September 2, 2021


M-x man: Can’t find the %s manpage caused by loading helm

0  Asked on September 2, 2021 by wdkrnls


Can the ring data structure really be rotated?

1  Asked on September 2, 2021


How do I compose an email using Emacs’ keybindings?

0  Asked on September 2, 2021 by user81065


Ask a Question

Get help from others!

© 2022 All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir