diff options
| author | Eli Zaretskii | 2015-11-21 12:49:57 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2015-11-21 12:49:57 +0200 |
| commit | 3858b7949fdf5af8dd94cefc5a2684ad285e2cdf (patch) | |
| tree | f7e4566d0b46d076166bb13d6c6200e089819174 | |
| parent | 2299267805bbf5ece023908922383677b5d4a44b (diff) | |
| download | emacs-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/NEWS | 40 | ||||
| -rw-r--r-- | src/alloc.c | 2 | ||||
| -rw-r--r-- | src/fns.c | 5 | ||||
| -rw-r--r-- | src/lread.c | 22 |
4 files changed, 49 insertions, 20 deletions
| @@ -305,13 +305,39 @@ header. | |||
| 305 | which specifies an alternative printing method which is faster when | 305 | which specifies an alternative printing method which is faster when |
| 306 | few or no entries have changed. | 306 | few 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). |
| 309 | C interface. Such modules can provide additional functions or | 309 | A dynamic Emacs module is a shared library that provides additional |
| 310 | otherwise interact with Emacs just like Lisp code. Modules have to | 310 | functionality for use in Emacs Lisp programs, just like a package |
| 311 | export a function `emacs_module_init' and conform to the API laid out | 311 | written in Emacs Lisp would. The functions `load' and `require' were |
| 312 | in emacs-module.h. Modules are disabled by default and need to be | 312 | extended to load such modules, as they do with Emacs Lisp packages. |
| 313 | enabled using the --with-modules configure flag. They are | 313 | |
| 314 | experimental and subject to change. | 314 | A 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 | ||
| 317 | symbol named `plugin_is_GPL_compatible' to indicate that its code is | ||
| 318 | released under the GPL or compatible license; Emacs will refuse to | ||
| 319 | load modules that don't export such a symbol. | ||
| 320 | |||
| 321 | If a module needs to call Emacs functions, it should do so through the | ||
| 322 | API defined and documented in the header file `emacs-module.h'. Note | ||
| 323 | that any module that provides Lisp-callable functions will have to use | ||
| 324 | Emacs functions such as `fset' and `funcall', in order to register its | ||
| 325 | functions with the Emacs Lisp interpreter. | ||
| 326 | |||
| 327 | Modules can create `user-ptr' Lisp objects that embed pointers to C | ||
| 328 | struct's defined by the module. This is useful for keeping around | ||
| 329 | complex data structures created by a module, to be passed back to the | ||
| 330 | module's functions. User-ptr objects can also have associated | ||
| 331 | "finalizers" -- functions to be run when the object is GC'ed; this is | ||
| 332 | useful for freeing any resources allocated for the underlying data | ||
| 333 | structure, such as memory, open file descriptors, etc. A new | ||
| 334 | predicate `user-ptr-p' returns non-nil if its argument is a `usr-ptr' | ||
| 335 | object. | ||
| 336 | |||
| 337 | Loadable modules in Emacs are an experimental feature, and subject to | ||
| 338 | change in future releases. For that reason, their support is disabled | ||
| 339 | by default, and must be enabled by using the `--with-modules' option | ||
| 340 | at 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. */ |
| 3716 | Lisp_Object | 3716 | Lisp_Object |
| 3717 | make_user_ptr (void (*finalizer) (void*), void *p) | 3717 | make_user_ptr (void (*finalizer) (void*), void *p) |
| 3718 | { | 3718 | { |
| @@ -2764,8 +2764,9 @@ DEFUN ("require", Frequire, Srequire, 1, 3, 0, | |||
| 2764 | If FEATURE is not a member of the list `features', then the feature | 2764 | If FEATURE is not a member of the list `features', then the feature |
| 2765 | is not loaded; so load the file FILENAME. | 2765 | is not loaded; so load the file FILENAME. |
| 2766 | If FILENAME is omitted, the printname of FEATURE is used as the file name, | 2766 | If FILENAME is omitted, the printname of FEATURE is used as the file name, |
| 2767 | and `load' will try to load this name appended with the suffix `.elc' or | 2767 | and `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 |
| 2769 | order. The name without appended suffix will not be used. | ||
| 2769 | See `get-load-suffixes' for the complete list of suffixes. | 2770 | See `get-load-suffixes' for the complete list of suffixes. |
| 2770 | If the optional third argument NOERROR is non-nil, | 2771 | If the optional third argument NOERROR is non-nil, |
| 2771 | then return nil if the file is not found instead of signaling an error. | 2772 | then 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 | ||
| 988 | DEFUN ("load", Fload, Sload, 1, 5, 0, | 988 | DEFUN ("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. |
| 990 | First try FILE with `.elc' appended, then try with `.el', | 990 | First try FILE with `.elc' appended, then try with `.el', then try |
| 991 | with a system-dependent suffix of dynamic modules (see `load-suffixes'), | ||
| 991 | then try FILE unmodified (the exact suffixes in the exact order are | 992 | then try FILE unmodified (the exact suffixes in the exact order are |
| 992 | determined by `load-suffixes'). Environment variable references in | 993 | determined by `load-suffixes'). Environment variable references in |
| 993 | FILE are replaced with their values by calling `substitute-in-file-name'. | 994 | FILE are replaced with their values by calling `substitute-in-file-name'. |
| @@ -999,10 +1000,10 @@ Print messages at start and end of loading unless | |||
| 999 | optional third arg NOMESSAGE is non-nil (but `force-load-messages' | 1000 | optional third arg NOMESSAGE is non-nil (but `force-load-messages' |
| 1000 | overrides that). | 1001 | overrides that). |
| 1001 | If optional fourth arg NOSUFFIX is non-nil, don't try adding | 1002 | If optional fourth arg NOSUFFIX is non-nil, don't try adding |
| 1002 | suffixes `.elc' or `.el' to the specified name FILE. | 1003 | suffixes to the specified name FILE. |
| 1003 | If optional fifth arg MUST-SUFFIX is non-nil, insist on | 1004 | If optional fifth arg MUST-SUFFIX is non-nil, insist on |
| 1004 | the suffix `.elc' or `.el'; don't accept just FILE unless | 1005 | the suffix `.elc' or `.el' or the module suffix; don't accept just |
| 1005 | it ends in one of those suffixes or includes a directory name. | 1006 | FILE unless it ends in one of those suffixes or includes a directory name. |
| 1006 | 1007 | ||
| 1007 | If NOSUFFIX is nil, then if a file could not be found, try looking for | 1008 | If NOSUFFIX is nil, then if a file could not be found, try looking for |
| 1008 | a different representation of the file by adding non-empty suffixes to | 1009 | a 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 | |||
| 4498 | and without trailing slashes. */); | 4499 | and 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. |
| 4503 | This list includes suffixes for both compiled and source Emacs Lisp files. | ||
| 4502 | This list should not include the empty string. | 4504 | This 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, |
| 4504 | to the specified file name if a Lisp suffix is allowed or required. */); | 4506 | to 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"), |