Reputation: 3886
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.
Upvotes: 1
Views: 434
Reputation: 28521
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)
Upvotes: 2
Reputation: 28752
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))
Upvotes: 1