From 6dc12dd7038a913d890870fd91a6c928b3f67e7a Mon Sep 17 00:00:00 2001 From: Vinh Tu Date: Fri, 1 Jul 2016 22:59:56 +0100 Subject: [PATCH] Add import_file_to_globals for use in emacs inferior lisp mode --- hy/importer.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hy/importer.py b/hy/importer.py index 6eca35a..8418b7c 100644 --- a/hy/importer.py +++ b/hy/importer.py @@ -89,6 +89,15 @@ def import_file_to_module(module_name, fpath): return mod +def import_file_to_globals(env, module_name, fpath): + """ Import content from fpath and puts it into the dict provided + (e.g., for use in a REPL) + """ + mod = import_file_to_module(module_name, fpath) + for k, v in mod.__dict__.items(): + env[k] = v + + def import_buffer_to_module(module_name, buf): try: _ast = import_buffer_to_ast(buf, module_name)