1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
| | ;;; future-interactive.el --- Forward compatibility for `interactive' in Emacs 28. -*- lexical-binding: t; -*-
;; Copyright (C) 2021 Free Software Foundation, Inc.
;; Author: Stefan Kangas <stefankangas@gmail.com>
;; Keywords: lisp, compatibility
;; This file is part of GNU Emacs.
;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; This is a forward compatibility package to allow maintaining
;; support for older versions of Emacs while also using the new third
;; argument to the `interactive'form added in Emacs 28.
;;
;; To use this in a package, just add a dependency on this package and
;; replace `interactive' with `future-interactive':
;;
;; (require 'future-interactive)
;;
;; (defun foo-command ()
;; (future-interactive nil foo-mode)
;; ... )
;;
;; See the `future-interactive' macro for more information.
;;; Code:
;; This is a GNU ELPA :core package to be able to easily use this in
;; other :core packages.
(defmacro future-interactive (arg-descriptor &rest modes)
"Use the correct `interactive' form for any Emacs version.
This is a forward compatibility macro that allows packages to
provide the third argument to `interactive' (added in Emacs 28)
while still working on older versions of Emacs.
To use it, simply replace `interactive' with `future-interactive'."
(if (< emacs-major-version 28)
`(interactive ,arg-descriptor)
`(interactive ,arg-descriptor ,@modes)))
(provide 'future-interactive)
;;; future-interactive.el ends here
|