|
From: | Gregory Heytings |
Subject: | Re: Dealing with obsoletion warnings in non-core code |
Date: | Tue, 29 Sep 2020 08:21:10 +0000 |
User-agent: | Alpine 2.22 (NEB 394 2020-01-19) |
The same trick however cannot be used for functions/variables declared obsoleted, the only construct I've found to work in this case is the following:(with-suppressed-warnings ((obsolete old-but-useful-function)) (if (fboundp 'recommended-function) (recommended-function) (old-but-useful-function)))Ideally I'd like to be able to write the following instead to avoid the needless repetition:(if (fboundp 'recommended-function) (recommended-function) (old-but-useful-function))
Here's a proposed solution: (defmacro call (fun &rest args) `(funcall (intern (symbol-name ,fun)) ,@args)) (defun select-text (text) (if (> emacs-major-version 25) (call 'gui-select-text text) (call 'x-select-text text)))It avoids the needless repetition, and does not give warnings on older Emacsen that do not know about gui-select-text, or on newer Emacsen that have x-select-text marked as obsolete.
[Prev in Thread] | Current Thread | [Next in Thread] |