# 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.

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

(defvar in-xxx-message nil)
(defun xxx-message (&rest args)
(cond
(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

## Related Questions

### How can I more easily see interactively whether overwrite-mode is enabled?

2  Asked on September 2, 2021 by ruby_object

### How to exit emacs with q when man inside emacs is opened

1  Asked on September 2, 2021

### How to remove day grouping header for today’s date in Agenda View?

1  Asked on September 2, 2021 by fierycod

### Wrong type argument: undo-tree, [cl-struct-undo-tree [nil ([nil ([nil nil ]]]

1  Asked on September 2, 2021

### Magit deprecates magit-popup. Which of my packages depend on it?

1  Asked on September 2, 2021

### How to enable org mode and evil mode for untitled buffer when creating a new frame

1  Asked on September 2, 2021 by will-beethoven

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

1  Asked on September 2, 2021 by prouleau

### Is there a way to spread a list like in Typescript or Golang?

2  Asked on September 2, 2021 by shackra

### emacsclient unable to connect to daemon under snap installation of Emacs

1  Asked on September 2, 2021

### 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

### how to set ranger to be default mode in dired in Doom emacs?

1  Asked on September 2, 2021 by ezio

### Can’t get rid of scratch buffer at startup for Emacs 26.3

1  Asked on September 2, 2021

### 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

### Is it possible to have different color values for a font-lock face in a string?

0  Asked on September 2, 2021 by geza

### How do I compose an email using Emacs’ keybindings?

0  Asked on September 2, 2021 by user81065