Skip to content

Instantly share code, notes, and snippets.

@ryantm
Last active January 2, 2016 06:19
Show Gist options
  • Save ryantm/8262758 to your computer and use it in GitHub Desktop.
Save ryantm/8262758 to your computer and use it in GitHub Desktop.
Macro for maintaining backward compatibility with functions declared obsolete without byte-compilation warnings
(defun <-running-version (version)
(let* ((split-version (split-string version "\\."))
(major-version (string-to-number (first split-version)))
(minor-version (string-to-number (second split-version))))
(or (< major-version emacs-major-version)
(and (eq major-version emacs-major-version)
(< minor-version emacs-minor-version)))))
(defmacro call-obsolete-function (name new-name when &rest rest)
(let ((function-name (if (<-running-version when)
new-name
name)))
`(,function-name ,@rest)))
(defun current-f () "f!")
(current-f)
(define-obsolete-function-alias 'old-f 'current-f "24.1")
(call-obsolete-function old-f current-f "24.1")
(defun current-one-param-f (param) (+ 1 param))
(current-one-param-f 1)
(define-obsolete-function-alias 'old-one-param-f 'current-one-param-f "24.1")
(call-obsolete-function old-one-param-f-f current-one-param-f "24.1" 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment