bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#66554: [PATCH] Add the public API of Compat to the core


From: Stefan Kangas
Subject: bug#66554: [PATCH] Add the public API of Compat to the core
Date: Wed, 10 Jan 2024 14:02:02 -0800

Philip Kaludercic <philipk@posteo.net> writes:

> See https://lists.gnu.org/archive/html/emacs-devel/2023-10/msg00260.html
> for the background behind this proposal.

I'm fine with this, and see the same benefits as described above.

I'd like to hear if Eli and Stefan M has anything to add, though, so I'm
copying them in here.

> From 9ab5748d0e93c84c36c5559a4cda2087b3a24560 Mon Sep 17 00:00:00 2001
> From: Philip Kaludercic <philipk@posteo.net>
> Date: Wed, 13 Sep 2023 12:26:22 +0200
> Subject: [PATCH] Add the public API of Compat to the core
>
> * lisp/emacs-lisp/compat.el: Add stub file with minimal definitions,
> so that core packages, that haven't been installed from ELPA, can make
> use of the public API and use more recent function signatures.
> * lisp/progmodes/python.el (compat): Remove 'noerror flag, because
> Compat can now be required without the real package being available.
> ---
>  lisp/emacs-lisp/compat.el | 61 +++++++++++++++++++++++++++++++++++++++
>  lisp/progmodes/python.el  |  2 +-
>  2 files changed, 62 insertions(+), 1 deletion(-)
>  create mode 100644 lisp/emacs-lisp/compat.el
>
> diff --git a/lisp/emacs-lisp/compat.el b/lisp/emacs-lisp/compat.el
> new file mode 100644
> index 00000000000..4c60093b6be
> --- /dev/null
> +++ b/lisp/emacs-lisp/compat.el
> @@ -0,0 +1,61 @@
> +;;; compat.el --- Pseudo-Compatibility for Elisp -*- lexical-binding: t; -*-
> +
> +;; Copyright (C) 2021-2023 Free Software Foundation, Inc.
> +
> +;; Author:                                                           \
> +;;   Philip Kaludercic <philipk@posteo.net>,                         \
> +;;   Daniel Mendler <mail@daniel-mendler.de>
> +;; Maintainer:                                                               
> \
> +;;   Daniel Mendler <mail@daniel-mendler.de>,                                
> \
> +;;   Compat Development <~pkal/compat-devel@lists.sr.ht>,
> +;;   emacs-devel@gnu.org
> +;; URL: https://github.com/emacs-compat/compat
> +;; Version: 1.0
> +;; Keywords: lisp, maint
> +
> +;; This program 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.
> +
> +;; This program 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 this program.  If not, see <https://www.gnu.org/licenses/>.
> +
> +;;; Commentary:
> +
> +;; The Compat package on ELPA provides forward-compatibility
> +;; definitions for other packages.  While mostly transparent, a
> +;; minimal API is necessary whenever core definitions change calling
> +;; conventions (e.g. `plist-get' can be invoked with a predicate from
> +;; Emacs 29.1 onward).  For core packages on ELPA to be able to take
> +;; advantage of this functionality, the macros `compat-function' and
> +;; `compat-call' have to be available in the core, usable even if
> +;; users do not have the Compat package installed, which this file
> +;; ensures.
> +
> +;; Note that Compat is not a core package and this file is not
> +;; available on GNU ELPA.
> +
> +;;; Code:
> +
> +(defmacro compat-function (fun)
> +  "Return compatibility function symbol for FUN.
> +This is a pseudo-compatibility stub for core packages on ELPA,
> +that depend on the Compat package, whenever the user doesn't have
> +the package installed on their current system."
> +  `#',fun)
> +
> +(defmacro compat-call (fun &rest args)
> +  "Call compatibility function or macro FUN with ARGS.
> +This is a pseudo-compatibility stub for core packages on ELPA,
> +that depend on the Compat package, whenever the user doesn't have
> +the package installed on their current system."
> +  (cons fun args))
> +
> +(provide 'compat)
> +;;; compat.el ends here
> diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
> index 4b940b3f13b..bf0e27bc786 100644
> --- a/lisp/progmodes/python.el
> +++ b/lisp/progmodes/python.el
> @@ -264,7 +264,7 @@
>  (eval-when-compile (require 'subr-x))   ;For `string-empty-p' and 
> `string-join'.
>  (require 'treesit)
>  (require 'pcase)
> -(require 'compat nil 'noerror)
> +(require 'compat)
>  (require 'project nil 'noerror)
>  (require 'seq)





reply via email to

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