# HG changeset patch
# User Jean-Pierre Flori <flori@enst.fr>
# Date 1297786445 -3600
# Node ID 1911cc23d6cf59fe9bed5f6964875805955b9c81
# Parent 5bff07b42baf278a7f8154e66e8f3d849eb60561
# Parent 6e6f96f8967a6eaf52fa383bfae6c3554e7d1fcd
Better formatting of error messages thrown when Maxima throws an error
diff -r 5bff07b42baf -r 1911cc23d6cf 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 | |