[climacs-devel] command handlers for parse errors

Christophe Rhodes csr21 at cam.ac.uk
Wed May 3 09:22:16 UTC 2006


Hi,

I exposed recently by altering some handler types the possibility of
lisp errors from accept methods when the user emits an activation
gesture when the object being can't be parsed (doesn't complete, has
an ambiguous completion, or isn't of the required type).

Troels' solution is (in his latest patch)

+    (handler-case (set-syntax buffer (accept 'syntax :prompt "Set Syntax"))
+                  (input-not-of-required-type 
+                   (message)
+                   (display-message "Invalid syntax: ~A." message)))))

but I think I have a better way, buried in amongst all the other
mutations I have accumulated.

The trick is to define a stream-accept method for the ESA minibuffer:
something like

(defmethod stream-accept :around ((pane minibuffer-pane) type &rest args)
  (declare (ignore args))
  ;; FIXME: this isn't the friendliest way of indicating a parse
  ;; error: there's no feedback, unlike emacs' quite nice "[no
  ;; match]".
  (loop
   (handler-case 
       (return (call-next-method))
     (parse-error ()
       nil))))

This causes the failing accept to be re-entered, which does almost the
right thing; with my command processor it clears the window and
re-prompts, but it doesn't re-insert the text the user entered because
there's no documented way of getting hold of that in a parse-error
(completion-error, input-not-of-required-type -- well, the latter
/might/ allow for getting hold of the string; it's not completely
clear to me).

I think that a unified, emacs-style method for handling input errors
is likely to be a win, from both reusability and maintainability
aspects.

Comments?

Cheers,

Christophe



More information about the climacs-devel mailing list