Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Move pymacs-load's error handling to python code

This is to provide more helpful message when, for example,
pymacs-loading a python module and one of its dependencies is missing.
  • Loading branch information...
commit 1683219c60e2f24a1d1ce376e264de64359728b3 1 parent 8363300
@leoliu leoliu authored committed
Showing with 7 additions and 5 deletions.
  1. +5 −2 Pymacs.py.in
  2. +2 −3 pymacs.el.in
View
7 Pymacs.py.in
@@ -403,7 +403,7 @@ class Protocol:
sys.stdout.flush()
-def pymacs_load_helper(file_without_extension, prefix):
+def pymacs_load_helper(file_without_extension, prefix, noerror=None):
# This function imports a Python module, then returns a Lisp expression
# which, when later evaluated, will install trampoline definitions
# in Emacs for accessing the Python module facilities. Module, given
@@ -435,7 +435,10 @@ def pymacs_load_helper(file_without_extension, prefix):
for component in module_components[1:]:
module = getattr(module, component)
except ImportError:
- return None
+ if noerror:
+ return None
+ else:
+ raise
load_hook = module.__dict__.get('pymacs_load_hook')
if load_hook:
load_hook()
View
5 pymacs.el.in
@@ -155,7 +155,7 @@ If NOERROR is not nil, do not raise error when the module is not found."
nil nil default)))
(list module prefix)))
(message "Pymacs loading %s..." module)
- (let ((lisp-code (pymacs-call "pymacs_load_helper" module prefix)))
+ (let ((lisp-code (pymacs-call "pymacs_load_helper" module prefix noerror)))
(cond (lisp-code (let ((result (eval lisp-code)))
(add-to-list 'pymacs-load-history
(list module prefix noerror)
@@ -163,8 +163,7 @@ If NOERROR is not nil, do not raise error when the module is not found."
'append)
(message "Pymacs loading %s...done" module)
result))
- (noerror (message "Pymacs loading %s...failed" module) nil)
- (t (pymacs-report-error "Pymacs loading %s...failed" module)))))
+ (noerror (message "Pymacs loading %s...failed" module) nil))))
;;;###autoload
(defun pymacs-autoload (function module &optional prefix docstring interactive)
Please sign in to comment.
Something went wrong with that request. Please try again.