# HG changeset patch
# User Nils Bruin <nbruin@sfu.ca>
# Date 1297666400 28800
# Node ID e173f4a68672f4b28a2435a5e26c401e3b92b065
# Parent 2aa53d20ef6082fac0ec6218b29a469ea7cf13ae
Better formatting of error messages thrown when Maxima throws an error
diff -r 2aa53d20ef60 -r e173f4a68672 sage/interfaces/maxima_lib.py
a
|
b
|
|
488 | 488 | ecl_eval("(set-locale-subdir)") |
489 | 489 | ecl_eval("(set-pathnames)") |
490 | 490 | ecl_eval("(defun add-lineinfo (x) x)") |
491 | | ecl_eval("""(defun retrieve (msg flag &aux (print? nil))(error (concatenate 'string "Maxima asks:" (meval (list '($string) msg)))))""") |
| 491 | #the following is a direct adaption of the definition of "retrieve" in the Maxima file |
| 492 | #macsys.lisp. This routine is normally responsible for displaying a question and |
| 493 | #returning the answer. We change it to throw an error in which the text of the question |
| 494 | #is included. We do this by running exactly the same code as in the original definition |
| 495 | #of "retrieve", but with *standard-output* redirected to a string. |
| 496 | ecl_eval(r""" |
| 497 | (defun retrieve (msg flag &aux (print? nil)) |
| 498 | (declare (special msg flag print?)) |
| 499 | (or (eq flag 'noprint) (setq print? t)) |
| 500 | (error (concatenate 'string "Maxima asks:" (with-output-to-string (*standard-output*) |
| 501 | (terpri) |
| 502 | (cond ((not print?) |
| 503 | (setq print? t) |
| 504 | (princ *prompt-prefix*) |
| 505 | (princ *prompt-suffix*)) |
| 506 | ((null msg) |
| 507 | (princ *prompt-prefix*) |
| 508 | (princ *prompt-suffix*)) |
| 509 | ((atom msg) |
| 510 | (format t "~a~a~a" *prompt-prefix* msg *prompt-suffix*) |
| 511 | (mterpri)) |
| 512 | ((eq flag t) |
| 513 | (princ *prompt-prefix*) |
| 514 | (mapc #'princ (cdr msg)) |
| 515 | (princ *prompt-suffix*) |
| 516 | (mterpri)) |
| 517 | (t |
| 518 | (princ *prompt-prefix*) |
| 519 | (displa msg) |
| 520 | (princ *prompt-suffix*) |
| 521 | (mterpri))))))) |
| 522 | """) |
| 523 | |
492 | 524 | ecl_eval('(defparameter *dev-null* (make-two-way-stream (make-concatenated-stream) (make-broadcast-stream)))') |
493 | 525 | ecl_eval('(defun principal nil (error "Divergent Integral"))') |
494 | 526 | |