emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] emacs-25 40ed767: Allow loading modules by 'load-file'


From: Eli Zaretskii
Subject: [Emacs-diffs] emacs-25 40ed767: Allow loading modules by 'load-file'
Date: Sun, 22 Nov 2015 18:40:12 +0000

branch: emacs-25
commit 40ed767ba0a35dbaeee6bdbd85a108d88a982b1a
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    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'.
---
 etc/NEWS      |    7 +++++--
 lisp/files.el |    8 ++++++--
 src/lread.c   |    9 ++++++++-
 3 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index dce02c3..5c5883f 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -308,8 +308,11 @@ few or no entries have changed.
 ** Emacs can now load shared/dynamic libraries (modules).
 A dynamic Emacs module is a shared library that provides additional
 functionality for use in Emacs Lisp programs, just like a package
-written in Emacs Lisp would.  The functions `load' and `require' were
-extended to load such modules, as they do with Emacs Lisp packages.
+written in Emacs Lisp would.  The functions `load', `require',
+`load-file', etc. were extended to load such modules, as they do with
+Emacs Lisp packages.  The new variable `module-file-suffix' holds the
+system-dependent value of the file-name extension (`.so' on Posix
+hosts) of the module files.
 
 A module should export a C-callable function named
 `emacs_module_init', which Emacs will call as part of the call to
diff --git a/lisp/files.el b/lisp/files.el
index fdc27ea..ac44e0f 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -772,11 +772,15 @@ If INCLUDE-DIRECTORIES, also include directories that 
have matching names."
            (push (expand-file-name file dir) files)))))
     (nconc result (nreverse files))))
 
+(defvar module-file-suffix)
+
 (defun load-file (file)
   "Load the Lisp file named FILE."
-  ;; This is a case where .elc makes a lot of sense.
+  ;; This is a case where .elc and .so/.dll make a lot of sense.
   (interactive (list (let ((completion-ignored-extensions
-                           (remove ".elc" completion-ignored-extensions)))
+                            (remove module-file-suffix
+                                    (remove ".elc"
+                                            completion-ignored-extensions))))
                       (read-file-name "Load file: " nil nil 'lambda))))
   (load (expand-file-name file) nil nil t))
 
diff --git a/src/lread.c b/src/lread.c
index 7f0f1d1..2239bfc 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -1164,7 +1164,7 @@ Return t if the file exists and loads successfully.  */)
 
 #ifdef HAVE_MODULES
   if (suffix_p (found, MODULES_SUFFIX))
-    return Fmodule_load (found);
+    return unbind_to (count, Fmodule_load (found));
 #endif
 
   /* 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.  */);
   Vload_suffixes = list2 (build_pure_c_string (".elc"),
                          build_pure_c_string (".el"));
 #endif
+  DEFVAR_LISP ("module-file-suffix", Vmodule_file_suffix,
+              doc: /* Suffix of loadable module file, or nil of modules are 
not supported.  */);
+#ifdef HAVE_MODULES
+  Vmodule_file_suffix = build_pure_c_string (MODULES_SUFFIX);
+#else
+  Vmodule_file_suffix = Qnil;
+#endif
   DEFVAR_LISP ("load-file-rep-suffixes", Vload_file_rep_suffixes,
               doc: /* List of suffixes that indicate representations of \
 the same file.



reply via email to

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