From: Stefan Kangas <stefankangas@gmail.com>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: emacs-devel@gnu.org, Dmitry Gutov <dgutov@yandex.ru>
Subject: Re: scratch/command 064f146 1/2: Change command to interactive ... modes
Date: Sun, 14 Feb 2021 14:25:42 -0600 [thread overview]
Message-ID: <CADwFkmmabGLP1Pqnt8O_6RZ53bM_eHBXgA5bKW=Hec5FyVvXPA@mail.gmail.com> (raw)
In-Reply-To: <87r1liblzb.fsf@gnus.org>
[-- Attachment #1: Type: text/plain, Size: 313 bytes --]
Lars Ingebrigtsen <larsi@gnus.org> writes:
> Stefan Kangas <stefankangas@gmail.com> writes:
>
>>> Hm... perhaps a core package would be the best solution here?
>>
>> I don't think we currently have any other way to make it easy to use on
>> master, do we?
>
> Hm... I guess not.
Please find attached a patch.
[-- Attachment #2: 0001-Add-new-forward-compatibility-package-future-interac.patch --]
[-- Type: text/x-diff, Size: 4513 bytes --]
From bfec0bd8971e93c85353f7415960fdbbfe6c3f01 Mon Sep 17 00:00:00 2001
From: Stefan Kangas <stefan@marxist.se>
Date: Sun, 14 Feb 2021 20:45:56 +0100
Subject: [PATCH] Add new forward compatibility package 'future-interactive'
* lisp/emacs-lisp/future-interactive.el:
* test/lisp/emacs-lisp/future-interactive-tests.el: New files.
---
lisp/emacs-lisp/future-interactive.el | 58 +++++++++++++++++++
.../emacs-lisp/future-interactive-tests.el | 38 ++++++++++++
2 files changed, 96 insertions(+)
create mode 100644 lisp/emacs-lisp/future-interactive.el
create mode 100644 test/lisp/emacs-lisp/future-interactive-tests.el
diff --git a/lisp/emacs-lisp/future-interactive.el b/lisp/emacs-lisp/future-interactive.el
new file mode 100644
index 0000000000..fe12924194
--- /dev/null
+++ b/lisp/emacs-lisp/future-interactive.el
@@ -0,0 +1,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
diff --git a/test/lisp/emacs-lisp/future-interactive-tests.el b/test/lisp/emacs-lisp/future-interactive-tests.el
new file mode 100644
index 0000000000..f525d03fcb
--- /dev/null
+++ b/test/lisp/emacs-lisp/future-interactive-tests.el
@@ -0,0 +1,38 @@
+;;; future-interactive-tests.el --- Tests for future-interactive.el -*- lexical-binding: t -*-
+
+;; Copyright (C) 2021 Free Software Foundation, Inc.
+
+;; Author: Stefan Kangas <stefankangas@gmail.com>
+
+;; 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:
+
+;;; Code:
+
+(require 'ert)
+(require 'future-interactive)
+
+(defun foo (args)
+ (future-interactive "P" fundamental-mode)
+ (message "args is %s" args))
+
+(ert-deftest future-interactive-test ()
+ (should (fboundp 'foo))
+ (should (foo t)))
+
+(provide 'future-interactive-tests)
+;;; future-interactive-tests.el ends here
--
2.30.0
next prev parent reply other threads:[~2021-02-14 20:25 UTC|newest]
Thread overview: 96+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20210213141225.11309.86562@vcs0.savannah.gnu.org>
[not found] ` <20210213141226.EEDFE20999@vcs0.savannah.gnu.org>
2021-02-13 20:04 ` scratch/command 064f146 1/2: Change command to interactive ... modes Dmitry Gutov
2021-02-13 21:05 ` Lars Ingebrigtsen
2021-02-13 21:33 ` Dmitry Gutov
2021-02-14 15:29 ` Stefan Kangas
2021-02-14 16:03 ` Stefan Kangas
2021-02-14 16:05 ` Lars Ingebrigtsen
2021-02-14 16:17 ` Stefan Kangas
2021-02-14 16:20 ` Lars Ingebrigtsen
2021-02-14 16:24 ` Stefan Kangas
2021-02-14 17:25 ` Lars Ingebrigtsen
2021-02-14 20:25 ` Stefan Kangas [this message]
2021-02-15 3:38 ` Eli Zaretskii
2021-02-16 12:15 ` Lars Ingebrigtsen
2021-02-16 15:41 ` Eli Zaretskii
2021-02-16 16:31 ` Lars Ingebrigtsen
2021-02-16 17:03 ` Eli Zaretskii
2021-02-16 17:06 ` Lars Ingebrigtsen
2021-02-16 17:36 ` Eli Zaretskii
2021-02-16 17:39 ` Lars Ingebrigtsen
2021-02-16 17:46 ` Eli Zaretskii
2021-02-16 18:10 ` Lars Ingebrigtsen
2021-02-16 18:24 ` Eli Zaretskii
2021-02-16 18:36 ` Lars Ingebrigtsen
2021-02-16 18:49 ` Eli Zaretskii
2021-02-16 19:31 ` Lars Ingebrigtsen
2021-02-16 19:39 ` Eli Zaretskii
2021-02-16 20:30 ` Stefan Kangas
2021-02-16 20:49 ` Eli Zaretskii
2021-02-16 22:00 ` Lars Ingebrigtsen
2021-02-16 22:22 ` Dmitry Gutov
2021-02-16 22:37 ` Lars Ingebrigtsen
2021-02-17 0:48 ` Dmitry Gutov
2021-02-17 11:02 ` Lars Ingebrigtsen
2021-02-17 11:30 ` Dmitry Gutov
2021-02-17 9:10 ` Juri Linkov
2021-02-17 10:16 ` Stefan Kangas
2021-02-17 11:08 ` Lars Ingebrigtsen
2021-02-17 17:45 ` Juri Linkov
2021-02-17 18:42 ` Óscar Fuentes
2021-02-17 8:50 ` Stefan Kangas
2021-02-17 13:57 ` Stefan Monnier
2021-02-17 15:52 ` Eli Zaretskii
2021-02-17 16:19 ` Dmitry Gutov
2021-02-16 22:31 ` [External] : " Drew Adams
2021-02-17 16:53 ` Matt Armstrong
2021-02-16 22:47 ` Alan Mackenzie
2021-02-16 22:55 ` Lars Ingebrigtsen
2021-02-16 23:20 ` Alan Mackenzie
2021-02-16 23:23 ` Lars Ingebrigtsen
2021-02-17 15:28 ` Eli Zaretskii
2021-02-19 5:36 ` Richard Stallman
2021-02-17 15:25 ` Eli Zaretskii
2021-02-17 15:21 ` Eli Zaretskii
2021-02-17 19:01 ` Óscar Fuentes
2021-02-17 19:42 ` Dmitry Gutov
2021-02-17 19:49 ` Lars Ingebrigtsen
2021-02-17 19:30 ` Lars Ingebrigtsen
2021-02-17 20:12 ` Eli Zaretskii
2021-02-18 23:57 ` Rolf Ade
2021-02-16 21:44 ` Dmitry Gutov
2021-02-17 8:58 ` Juri Linkov
2021-02-17 10:16 ` Stefan Kangas
2021-02-17 11:05 ` Lars Ingebrigtsen
2021-02-17 17:45 ` Juri Linkov
2021-02-17 19:26 ` Eli Zaretskii
2021-02-16 12:07 ` Lars Ingebrigtsen
2021-02-17 20:05 ` Lars Ingebrigtsen
2021-02-17 21:03 ` Stefan Monnier
2021-02-17 21:06 ` Lars Ingebrigtsen
2021-02-17 22:26 ` Stefan Monnier
2021-02-18 3:57 ` Stefan Kangas
2021-02-18 4:43 ` Stefan Monnier
2021-02-18 5:20 ` Stefan Kangas
2021-02-18 10:33 ` Lars Ingebrigtsen
2021-02-18 10:38 ` Lars Ingebrigtsen
2021-02-18 10:40 ` Lars Ingebrigtsen
2021-02-18 14:01 ` Stefan Monnier
2021-02-18 16:03 ` Stefan Monnier
2021-02-18 16:47 ` Basil L. Contovounesios
2021-02-19 12:07 ` Lars Ingebrigtsen
2021-02-19 14:29 ` Stefan Monnier
2021-02-20 12:35 ` Lars Ingebrigtsen
2021-02-20 14:38 ` Stefan Monnier
2021-02-20 15:01 ` Lars Ingebrigtsen
2021-02-14 20:37 ` Jose A. Ortega Ruiz
2021-02-14 23:23 ` Stefan Monnier
2021-02-14 16:49 ` Basil L. Contovounesios
2021-02-14 17:23 ` Stefan Kangas
2021-02-14 17:52 ` Basil L. Contovounesios
2021-02-14 19:54 ` Stefan Kangas
2021-02-14 16:58 ` Alan Mackenzie
2021-02-14 17:23 ` Stefan Kangas
2021-02-14 16:02 ` Óscar Fuentes
2021-02-14 16:07 ` Lars Ingebrigtsen
2021-02-14 16:23 ` Óscar Fuentes
2021-02-14 17:05 ` Lars Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CADwFkmmabGLP1Pqnt8O_6RZ53bM_eHBXgA5bKW=Hec5FyVvXPA@mail.gmail.com' \
--to=stefankangas@gmail.com \
--cc=dgutov@yandex.ru \
--cc=emacs-devel@gnu.org \
--cc=larsi@gnus.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).