aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2015-11-22 20:38:51 +0200
committerEli Zaretskii2015-11-22 20:38:51 +0200
commit40ed767ba0a35dbaeee6bdbd85a108d88a982b1a (patch)
treeb726762b86a3a5b3fdfaf7216e995a21cb2e1e62
parent9f0d19f24cd455765123a378a5e2f3e505cbb5ac (diff)
downloademacs-40ed767ba0a35dbaeee6bdbd85a108d88a982b1a.tar.gz
emacs-40ed767ba0a35dbaeee6bdbd85a108d88a982b1a.zip
Allow loading modules by 'load-file'
* src/lread.c (Fload): Call 'unbind_to' with 'Fmodule_load' as the 2nd arg, to avoid the "binding stack not balanced" error. (syms_of_lread) <module-file-suffix>: New Lisp variable. * lisp/files.el (module-file-suffix): Declare. (load-file): Remove 'module-file-suffix' from 'completion-ignored-extensions', to allow completion on modules. * etc/NEWS: Mention 'module-file-suffix'.
-rw-r--r--etc/NEWS7
-rw-r--r--lisp/files.el8
-rw-r--r--src/lread.c9
3 files changed, 19 insertions, 5 deletions
diff --git a/etc/NEWS b/etc/NEWS
index dce02c31e59..5c5883f55ba 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -308,8 +308,11 @@ few or no entries have changed.
308** Emacs can now load shared/dynamic libraries (modules). 308** Emacs can now load shared/dynamic libraries (modules).
309A dynamic Emacs module is a shared library that provides additional 309A dynamic Emacs module is a shared library that provides additional
310functionality for use in Emacs Lisp programs, just like a package 310functionality for use in Emacs Lisp programs, just like a package
311written in Emacs Lisp would. The functions `load' and `require' were 311written in Emacs Lisp would. The functions `load', `require',
312extended to load such modules, as they do with Emacs Lisp packages. 312`load-file', etc. were extended to load such modules, as they do with
313Emacs Lisp packages. The new variable `module-file-suffix' holds the
314system-dependent value of the file-name extension (`.so' on Posix
315hosts) of the module files.
313 316
314A module should export a C-callable function named 317A module should export a C-callable function named
315`emacs_module_init', which Emacs will call as part of the call to 318`emacs_module_init', which Emacs will call as part of the call to
diff --git a/lisp/files.el b/lisp/files.el
index fdc27ead450..ac44e0f0fc7 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -772,11 +772,15 @@ If INCLUDE-DIRECTORIES, also include directories that have matching names."
772 (push (expand-file-name file dir) files))))) 772 (push (expand-file-name file dir) files)))))
773 (nconc result (nreverse files)))) 773 (nconc result (nreverse files))))
774 774
775(defvar module-file-suffix)
776
775(defun load-file (file) 777(defun load-file (file)
776 "Load the Lisp file named FILE." 778 "Load the Lisp file named FILE."
777 ;; This is a case where .elc makes a lot of sense. 779 ;; This is a case where .elc and .so/.dll make a lot of sense.
778 (interactive (list (let ((completion-ignored-extensions 780 (interactive (list (let ((completion-ignored-extensions
779 (remove ".elc" completion-ignored-extensions))) 781 (remove module-file-suffix
782 (remove ".elc"
783 completion-ignored-extensions))))
780 (read-file-name "Load file: " nil nil 'lambda)))) 784 (read-file-name "Load file: " nil nil 'lambda))))
781 (load (expand-file-name file) nil nil t)) 785 (load (expand-file-name file) nil nil t))
782 786
diff --git a/src/lread.c b/src/lread.c
index 7f0f1d1f6a8..2239bfc452a 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -1164,7 +1164,7 @@ Return t if the file exists and loads successfully. */)
1164 1164
1165#ifdef HAVE_MODULES 1165#ifdef HAVE_MODULES
1166 if (suffix_p (found, MODULES_SUFFIX)) 1166 if (suffix_p (found, MODULES_SUFFIX))
1167 return Fmodule_load (found); 1167 return unbind_to (count, Fmodule_load (found));
1168#endif 1168#endif
1169 1169
1170 /* Check if we're stuck in a recursive load cycle. 1170 /* Check if we're stuck in a recursive load cycle.
@@ -4513,6 +4513,13 @@ to the specified file name if a suffix is allowed or required. */);
4513 Vload_suffixes = list2 (build_pure_c_string (".elc"), 4513 Vload_suffixes = list2 (build_pure_c_string (".elc"),
4514 build_pure_c_string (".el")); 4514 build_pure_c_string (".el"));
4515#endif 4515#endif
4516 DEFVAR_LISP ("module-file-suffix", Vmodule_file_suffix,
4517 doc: /* Suffix of loadable module file, or nil of modules are not supported. */);
4518#ifdef HAVE_MODULES
4519 Vmodule_file_suffix = build_pure_c_string (MODULES_SUFFIX);
4520#else
4521 Vmodule_file_suffix = Qnil;
4522#endif
4516 DEFVAR_LISP ("load-file-rep-suffixes", Vload_file_rep_suffixes, 4523 DEFVAR_LISP ("load-file-rep-suffixes", Vload_file_rep_suffixes,
4517 doc: /* List of suffixes that indicate representations of \ 4524 doc: /* List of suffixes that indicate representations of \
4518the same file. 4525the same file.