aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2015-11-21 12:49:57 +0200
committerEli Zaretskii2015-11-21 12:49:57 +0200
commit3858b7949fdf5af8dd94cefc5a2684ad285e2cdf (patch)
treef7e4566d0b46d076166bb13d6c6200e089819174
parent2299267805bbf5ece023908922383677b5d4a44b (diff)
downloademacs-3858b7949fdf5af8dd94cefc5a2684ad285e2cdf.tar.gz
emacs-3858b7949fdf5af8dd94cefc5a2684ad285e2cdf.zip
Improve documentation of dynamic modules
* src/fns.c (Frequire): Doc fix to include the dynamic module support. * src/lread.c (Fload, Vload_suffixes): Doc fixes to include the dynamic module support. (Fload): Treat the module suffix the same as '*.el' and '*.elc' wrt the MUST-SUFFIX argument. * etc/NEWS: Expand documentation of dynamically loaded modules.
-rw-r--r--etc/NEWS40
-rw-r--r--src/alloc.c2
-rw-r--r--src/fns.c5
-rw-r--r--src/lread.c22
4 files changed, 49 insertions, 20 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 8ed8133beae..dce02c31e59 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -305,13 +305,39 @@ header.
305which specifies an alternative printing method which is faster when 305which specifies an alternative printing method which is faster when
306few or no entries have changed. 306few or no entries have changed.
307 307
308** Emacs can now load shared/dynamic libraries (modules) that expose a 308** Emacs can now load shared/dynamic libraries (modules).
309C interface. Such modules can provide additional functions or 309A dynamic Emacs module is a shared library that provides additional
310otherwise interact with Emacs just like Lisp code. Modules have to 310functionality for use in Emacs Lisp programs, just like a package
311export a function `emacs_module_init' and conform to the API laid out 311written in Emacs Lisp would. The functions `load' and `require' were
312in emacs-module.h. Modules are disabled by default and need to be 312extended to load such modules, as they do with Emacs Lisp packages.
313enabled using the --with-modules configure flag. They are 313
314experimental and subject to change. 314A module should export a C-callable function named
315`emacs_module_init', which Emacs will call as part of the call to
316`load' or `require' which loads the module. It should also export a
317symbol named `plugin_is_GPL_compatible' to indicate that its code is
318released under the GPL or compatible license; Emacs will refuse to
319load modules that don't export such a symbol.
320
321If a module needs to call Emacs functions, it should do so through the
322API defined and documented in the header file `emacs-module.h'. Note
323that any module that provides Lisp-callable functions will have to use
324Emacs functions such as `fset' and `funcall', in order to register its
325functions with the Emacs Lisp interpreter.
326
327Modules can create `user-ptr' Lisp objects that embed pointers to C
328struct's defined by the module. This is useful for keeping around
329complex data structures created by a module, to be passed back to the
330module's functions. User-ptr objects can also have associated
331"finalizers" -- functions to be run when the object is GC'ed; this is
332useful for freeing any resources allocated for the underlying data
333structure, such as memory, open file descriptors, etc. A new
334predicate `user-ptr-p' returns non-nil if its argument is a `usr-ptr'
335object.
336
337Loadable modules in Emacs are an experimental feature, and subject to
338change in future releases. For that reason, their support is disabled
339by default, and must be enabled by using the `--with-modules' option
340at configure time.
315 341
316 342
317* Editing Changes in Emacs 25.1 343* Editing Changes in Emacs 25.1
diff --git a/src/alloc.c b/src/alloc.c
index 53f974533a8..ad3f5235480 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -3712,7 +3712,7 @@ make_event_array (ptrdiff_t nargs, Lisp_Object *args)
3712} 3712}
3713 3713
3714#ifdef HAVE_MODULES 3714#ifdef HAVE_MODULES
3715/* Create a new module user ptr object. */ 3715/* Create a new module user ptr object. */
3716Lisp_Object 3716Lisp_Object
3717make_user_ptr (void (*finalizer) (void*), void *p) 3717make_user_ptr (void (*finalizer) (void*), void *p)
3718{ 3718{
diff --git a/src/fns.c b/src/fns.c
index 029ac6a83bb..824d96980a0 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -2764,8 +2764,9 @@ DEFUN ("require", Frequire, Srequire, 1, 3, 0,
2764If FEATURE is not a member of the list `features', then the feature 2764If FEATURE is not a member of the list `features', then the feature
2765is not loaded; so load the file FILENAME. 2765is not loaded; so load the file FILENAME.
2766If FILENAME is omitted, the printname of FEATURE is used as the file name, 2766If FILENAME is omitted, the printname of FEATURE is used as the file name,
2767and `load' will try to load this name appended with the suffix `.elc' or 2767and `load' will try to load this name appended with the suffix `.elc',
2768`.el', in that order. The name without appended suffix will not be used. 2768`.el', or the system-dependent suffix for dynamic module files, in that
2769order. The name without appended suffix will not be used.
2769See `get-load-suffixes' for the complete list of suffixes. 2770See `get-load-suffixes' for the complete list of suffixes.
2770If the optional third argument NOERROR is non-nil, 2771If the optional third argument NOERROR is non-nil,
2771then return nil if the file is not found instead of signaling an error. 2772then return nil if the file is not found instead of signaling an error.
diff --git a/src/lread.c b/src/lread.c
index 43100d9f699..bbff21d01d7 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -987,7 +987,8 @@ suffix_p (Lisp_Object string, const char *suffix)
987 987
988DEFUN ("load", Fload, Sload, 1, 5, 0, 988DEFUN ("load", Fload, Sload, 1, 5, 0,
989 doc: /* Execute a file of Lisp code named FILE. 989 doc: /* Execute a file of Lisp code named FILE.
990First try FILE with `.elc' appended, then try with `.el', 990First try FILE with `.elc' appended, then try with `.el', then try
991with a system-dependent suffix of dynamic modules (see `load-suffixes'),
991then try FILE unmodified (the exact suffixes in the exact order are 992then try FILE unmodified (the exact suffixes in the exact order are
992determined by `load-suffixes'). Environment variable references in 993determined by `load-suffixes'). Environment variable references in
993FILE are replaced with their values by calling `substitute-in-file-name'. 994FILE are replaced with their values by calling `substitute-in-file-name'.
@@ -999,10 +1000,10 @@ Print messages at start and end of loading unless
999optional third arg NOMESSAGE is non-nil (but `force-load-messages' 1000optional third arg NOMESSAGE is non-nil (but `force-load-messages'
1000overrides that). 1001overrides that).
1001If optional fourth arg NOSUFFIX is non-nil, don't try adding 1002If optional fourth arg NOSUFFIX is non-nil, don't try adding
1002suffixes `.elc' or `.el' to the specified name FILE. 1003suffixes to the specified name FILE.
1003If optional fifth arg MUST-SUFFIX is non-nil, insist on 1004If optional fifth arg MUST-SUFFIX is non-nil, insist on
1004the suffix `.elc' or `.el'; don't accept just FILE unless 1005the suffix `.elc' or `.el' or the module suffix; don't accept just
1005it ends in one of those suffixes or includes a directory name. 1006FILE unless it ends in one of those suffixes or includes a directory name.
1006 1007
1007If NOSUFFIX is nil, then if a file could not be found, try looking for 1008If NOSUFFIX is nil, then if a file could not be found, try looking for
1008a different representation of the file by adding non-empty suffixes to 1009a different representation of the file by adding non-empty suffixes to
@@ -1084,7 +1085,9 @@ Return t if the file exists and loads successfully. */)
1084 if (! NILP (must_suffix)) 1085 if (! NILP (must_suffix))
1085 { 1086 {
1086 /* Don't insist on adding a suffix if FILE already ends with one. */ 1087 /* Don't insist on adding a suffix if FILE already ends with one. */
1087 if (suffix_p (file, ".el") || suffix_p (file, ".elc")) 1088 if (suffix_p (file, ".el")
1089 || suffix_p (file, ".elc")
1090 || suffix_p (file, MODULES_SUFFIX))
1088 must_suffix = Qnil; 1091 must_suffix = Qnil;
1089 /* Don't insist on adding a suffix 1092 /* Don't insist on adding a suffix
1090 if the argument includes a directory name. */ 1093 if the argument includes a directory name. */
@@ -1158,9 +1161,7 @@ Return t if the file exists and loads successfully. */)
1158 1161
1159#ifdef HAVE_MODULES 1162#ifdef HAVE_MODULES
1160 if (suffix_p (found, MODULES_SUFFIX)) 1163 if (suffix_p (found, MODULES_SUFFIX))
1161 { 1164 return Fmodule_load (found);
1162 return Fmodule_load (found);
1163 }
1164#endif 1165#endif
1165 1166
1166 /* Check if we're stuck in a recursive load cycle. 1167 /* Check if we're stuck in a recursive load cycle.
@@ -4498,10 +4499,11 @@ programs that process this list should tolerate directories both with
4498and without trailing slashes. */); 4499and without trailing slashes. */);
4499 4500
4500 DEFVAR_LISP ("load-suffixes", Vload_suffixes, 4501 DEFVAR_LISP ("load-suffixes", Vload_suffixes,
4501 doc: /* List of suffixes for (compiled or source) Emacs Lisp files. 4502 doc: /* List of suffixes for Emacs Lisp files and dynamic modules.
4503This list includes suffixes for both compiled and source Emacs Lisp files.
4502This list should not include the empty string. 4504This list should not include the empty string.
4503`load' and related functions try to append these suffixes, in order, 4505`load' and related functions try to append these suffixes, in order,
4504to the specified file name if a Lisp suffix is allowed or required. */); 4506to the specified file name if a suffix is allowed or required. */);
4505#ifdef HAVE_MODULES 4507#ifdef HAVE_MODULES
4506 Vload_suffixes = list3 (build_pure_c_string (".elc"), 4508 Vload_suffixes = list3 (build_pure_c_string (".elc"),
4507 build_pure_c_string (".el"), 4509 build_pure_c_string (".el"),