emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dealing with obsoletion warnings in non-core code


From: Gregory Heytings
Subject: Re: Dealing with obsoletion warnings in non-core code
Date: Tue, 29 Sep 2020 09:33:20 +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.


P.S.:

Obviously

(defun select-text (text)
 (if (fboundp 'gui-select-text)
     (call 'gui-select-text text)
   (call 'x-select-text text)))

also works.


P.P.S.:

And for variables, the equivalent would of course be:

(defmacro assign (var val) `(set (intern (symbol-name ,var)) ,val))

(if (boundp 'switch-to-prev-buffer-skip)
    (assign 'switch-to-prev-buffer-skip t)
  (assign 'switch-to-visible-buffer t))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]