TransWikia.com

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)
  (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

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP