unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] Export major version of latest Emacs supported by emacs-module.h.
@ 2019-04-24  8:31 Philipp Stephani
  2019-04-25 22:52 ` Paul Eggert
  0 siblings, 1 reply; 3+ messages in thread
From: Philipp Stephani @ 2019-04-24  8:31 UTC (permalink / raw)
  To: emacs-devel; +Cc: Philipp Stephani

This is useful if module authors want to support multiple versions of
emacs-module.h.

* configure.ac (emacs_major_version): Define substitution.

* src/emacs-module.h.in (EMACS_MAJOR_VERSION): Define macro.

* doc/lispref/internals.texi (Module Initialization): Document
EMACS_MODULE_VERSION preprocessor macro.
---
 configure.ac               |  2 ++
 doc/lispref/internals.texi | 11 +++++++++++
 etc/NEWS                   |  3 +++
 src/emacs-module.h.in      |  2 ++
 4 files changed, 18 insertions(+)

diff --git a/configure.ac b/configure.ac
index 810c3219e4..79fe0c98c6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3697,6 +3697,8 @@ AC_DEFUN
 module_env_snippet_25="$srcdir/src/module-env-25.h"
 module_env_snippet_26="$srcdir/src/module-env-26.h"
 module_env_snippet_27="$srcdir/src/module-env-27.h"
+emacs_major_version="${PACKAGE_VERSION%%.*}"
+AC_SUBST(emacs_major_version)
 
 ### Use -lpng if available, unless '--with-png=no'.
 HAVE_PNG=no
diff --git a/doc/lispref/internals.texi b/doc/lispref/internals.texi
index 25892d4b57..d4adb1d7d9 100644
--- a/doc/lispref/internals.texi
+++ b/doc/lispref/internals.texi
@@ -1191,6 +1191,17 @@ Module Initialization
 can use only the parts of the module @acronym{API} that existed in
 that version, since those parts are identical in later versions.
 
+@file{emacs-module.h} defines a preprocessor macro
+@code{EMACS_MODULE_VERSION}.  It expands to an integer literal which
+is the latest major version of Emacs supported by the header.
+@xref{Version Info}.  Note that the value of
+@code{EMACS_MODULE_VERSION} is a compile-time constant and does not
+represent the version of Emacs that is currently running and has
+loaded your module.  If you want your module to be compatible with
+various versions of @file{emacs-module.h} as well as various versions
+of Emacs, you can use conditional compilation based on
+@code{EMACS_MODULE_VERSION}.
+
 We recommend that modules always perform the compatibility
 verification, unless they do their job entirely in the initialization
 function, and don't access any Lisp objects or use any Emacs functions
diff --git a/etc/NEWS b/etc/NEWS
index b13ab47768..483f1dc958 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1910,6 +1910,9 @@ returns a regexp that never matches anything, which is an identity for
 this operation.  Previously, the empty string was returned in this
 case.
 
+** emacs-module.h now defines a macro EMACS_MAJOR_VERSION that expands
+to the major version of the latest Emacs supported by the header.
+
 \f
 * Changes in Emacs 27.1 on Non-Free Operating Systems
 
diff --git a/src/emacs-module.h.in b/src/emacs-module.h.in
index 009d1583fe..dad4453cd8 100644
--- a/src/emacs-module.h.in
+++ b/src/emacs-module.h.in
@@ -27,6 +27,8 @@ along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
 #include <stdbool.h>
 #endif
 
+#define EMACS_MAJOR_VERSION @emacs_major_version@
+
 #if defined __cplusplus && __cplusplus >= 201103L
 # define EMACS_NOEXCEPT noexcept
 #else
-- 
2.20.1 (Apple Git-117)




^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Export major version of latest Emacs supported by emacs-module.h.
  2019-04-24  8:31 [PATCH] Export major version of latest Emacs supported by emacs-module.h Philipp Stephani
@ 2019-04-25 22:52 ` Paul Eggert
  2019-04-28 18:10   ` Philipp Stephani
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Eggert @ 2019-04-25 22:52 UTC (permalink / raw)
  To: Philipp Stephani, emacs-devel; +Cc: Philipp Stephani

This looks good to me, except that it documents EMACS_MODULE_VERSION
while implementing EMACS_MAJOR_VERSION.



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Export major version of latest Emacs supported by emacs-module.h.
  2019-04-25 22:52 ` Paul Eggert
@ 2019-04-28 18:10   ` Philipp Stephani
  0 siblings, 0 replies; 3+ messages in thread
From: Philipp Stephani @ 2019-04-28 18:10 UTC (permalink / raw)
  To: Paul Eggert; +Cc: Philipp Stephani, Emacs developers

Am Fr., 26. Apr. 2019 um 00:53 Uhr schrieb Paul Eggert <eggert@cs.ucla.edu>:
>
> This looks good to me, except that it documents EMACS_MODULE_VERSION
> while implementing EMACS_MAJOR_VERSION.

Thanks, fixed and pushed as commit 4d97e1a9ea.



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-04-28 18:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-24  8:31 [PATCH] Export major version of latest Emacs supported by emacs-module.h Philipp Stephani
2019-04-25 22:52 ` Paul Eggert
2019-04-28 18:10   ` Philipp Stephani

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).