Changeset 11804


Ignore:
Timestamp:
Mar 4, 2009, 12:59:04 PM (10 years ago)
Author:
gz
Message:

If *toplevel-commands-dwim* is true, don't enter the debugger for errors during commands, just print a message and continue. In addition, for expressions that look like commands (i.e. keywords), explicitly complain of unknown command

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/working-0711/ccl/level-1/l1-readloop-lds.lisp

    r11751 r11804  
    244244(%use-toplevel-commands :global)
    245245
    246 (defparameter *toplevel-commands-dwim* t "If true, tries to interpret otherwise-erroneous toplevel
    247 expressions as commands")
     246(defparameter *toplevel-commands-dwim* t
     247 "If true, tries to interpret otherwise-erroneous toplevel expressions as commands.
     248In addition, will suppress standard error handling for expressions that look like
     249commands but aren't")
    248250
    249251(defvar *default-integer-command* nil
     
    265267                   (setq cmd (find-symbol (symbol-name cmd) :keyword))))
    266268      (when (eq cmd :help) (setq cmd :?))
    267       (dolist (g *active-toplevel-commands*)
    268         (let* ((pair (assoc cmd (cdr g))))
    269           (when pair
    270             (apply (cadr pair) args)
    271             (return t)))))))
     269      (flet ((run (cmd form)
     270               (or (dolist (g *active-toplevel-commands*)
     271                     (let* ((pair (assoc cmd (cdr g))))
     272                       (when pair
     273                         (apply (cadr pair) args)
     274                         (return t))))
     275                   ;; Try to detect user mistyping a command
     276                   (when (and *toplevel-commands-dwim*
     277                              (if (consp form)
     278                                (and (keywordp (%car form)) (not (fboundp (%car form))))
     279                                (keywordp form)))
     280                     (error "Unknown command ~s" cmd)))))
     281        (declare (dynamic-extent #'run))
     282        (if *toplevel-commands-dwim*
     283          (block nil
     284            (handler-bind ((error (lambda (c)
     285                                    (format t "~&~a" c)
     286                                    (return t))))
     287              (run cmd form)))
     288          (run cmd form))))))
    272289
    273290(defparameter *quit-on-eof* nil)
Note: See TracChangeset for help on using the changeset viewer.