1

I share my Emacs config across numerous computers. Some of them I can easily maintain my own copy of emacs and on others I do not have that luxury. I am seeing the following message:

'disabled-command-hook' is an obsolete variable (as of Emacs 22.1); use 'disabled-command-function'

This occurs at startup because I have my config set to byte-compile any files that are not already compiled. Problem is, I still have one or two Emacs 21 instances. How do I support both the old and the new? My google-fu is not working for me.

I tried using this macro:

(defmacro WhenEmacsOlderThan (major minor &rest body)
   `(if (or (< emacs-major-version ,major) (and (= emacs-major-version ,major)
                                                                           (< emacs-minor-version ,minor)))
      (progn ,@body)
     nil
    )
 )

Which looks like this in use:

(WhenEmacsOlderThan 22 1
   (setq disabled-command-hook nil)
 )

But I still see the message in the newer Emacs versions about the obsolete variable. What am I missing?

I have found other questions like this but the goal was to hide the message. I want to understand why I am seeing the message and how to avoid the problem in a cross-version compatible way.

Thanks.

2 Answers 2

2

The message is a warning, so your (setq disabled-command-hook nil) will still work, but when that variable will be removed, the warning will also disappear, so better get ready. You can do:

(setq disabled-command-hook nil) ;; Obsolete since Emacs-22.
(setq disabled-command-function nil)

so it will work in all versions. You might also be able to avoid the warning with

(if (boundp 'disabled-command-hook)
    (setq disabled-command-hook nil)) ;; Obsolete since Emacs-22.
(setq disabled-command-function nil)
1
  • Yes, checking with (boundp) works. Hmm, I was sure I had tried that. Oh well, I have updated my code accordingly. Thanks.
    – Sean Perry
    Oct 9, 2012 at 20:35
1

Can you instead directly check if the disabled-command-hook is obsolete?

(defun make-obsolete (obsolete-name current-name &optional when)
  ....
  (put obsolete-name 'byte-obsolete-info

So maybe

(if (not (get disabled-command-hook 'byte-obsolete-info))
  (setq disabled-command-hook nil))
1
  • No, the call to (get) also generates an obsolete variable message.
    – Sean Perry
    Oct 9, 2012 at 19:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.