all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Adapting ielm's error reporting to Emacs': proposed patch.
@ 2002-06-10  2:58 Luc Teirlinck
  2002-06-15 14:13 ` Richard Stallman
  0 siblings, 1 reply; 2+ messages in thread
From: Luc Teirlinck @ 2002-06-10  2:58 UTC (permalink / raw)


There are significant differences in the way ielm and Emacs itself
print error messages when an error is signaled using:

(signal error-symbol data)

or:

(error format-string &rest args) which is equivalent with:

(signal 'error (list (format format-string &rest args)))

In: (signal error-symbol data), ielm is going to print: 

First an obviously ielm-specific *** Eval error *** (I have no
problems with that, it makes errors stand out clearly and nicely, good
thing.)

Then:

The error-message property for error-symbol, regardless of
error-symbol or error-message.  "peculiar error" is only used if
error-symbol has no error-message property.

Then: the entire list data.

Emacs behaves differently:

If error-symbol is error, it does not print the error-message
property of error (namely error itself), but uses instead (car data)
as the error message and later only prints (cdr data).
Second difference: if error-message is neither nil nor a string, Emacs
prints "peculiar error", whereas ielm happily uses the printed
representation of whatever Lisp object is stored in error-message.

If one uses ielm to check out pieces of code containing some error
signaling and handling, then the difference in handling between ielm
and Emacs is confusing.  The attached patch would eliminate those
differences, while keeping the ielm-specific
*** Eval error ***
which creates no confusion, because it is so obvious that it is an
ielm feature.

I first include an ielm run to show the effect of the proposed change.
It starts in the unchanged ielm.  Then it loads the changed ielm.el.
Notice the difference and compare with, for instance, the results of
entering the same commands with M-: (make sure debug-on-error is nil).



*** Welcome to IELM ***  Type (describe-mode) for help.
ELISP> (emacs-version)
"GNU Emacs 21.2.90.1 (i686-pc-linux-gnu, X toolkit)\n of 2002-06-09 on
swt40.swt.com"
ELISP> (put 'nifty-error 'error-conditions '(nifty-error error))
(nifty-error error)

ELISP> (put 'nifty-error 'error-message '(1 2))
(1 2)

ELISP> (error "Value is negative")
*** Eval error ***  error: "Value is negative"
ELISP> (error "Error: value is negative")
*** Eval error ***  error: "Error: value is negative"
ELISP> (signal 'nifty-error '("Nice error"))
*** Eval error ***  (1 2): "Nice error"
ELISP> (load "ielm")  ; now the new ielm gets loaded
t
ELISP> (error "Value is negative")
*** Eval error ***  Value is negative
ELISP> (error "Error: value is negative")
*** Eval error ***  Error: value is negative
ELISP> (signal 'nifty-error '("Nice error"))
*** Eval error ***  peculiar error: "Nice error"
ELISP>

Next a ChangeLog and context-diff in case you would agree with the
proposed change.  I believe that if you agree with the change, then,
in addition to the proposed patch below, the functions
ielm-format-error and ielm-format-errors in ielm.el could be
eliminated, because they are no longer used.  (The patch below does
not eliminate the functions themselves, only their uses.)


2002-06-09  Luc Teirlinck  <teirllm@mail.auburn.edu>

	    * ielm.el  (ielm-eval-input): Change the two calls to 
	    ielm-format-error into calls to error-message-string.



===File ~/ielmdiff==========================================
cd /usr/local/share/emacs/21.2.90/lisp/
diff -c /usr/local/share/emacs/21.2.90/lisp/old-ielm.el /usr/local/share/emacs/21.2.90/lisp/ielm.el
*** /usr/local/share/emacs/21.2.90/lisp/old-ielm.el	Tue Oct 10 12:27:38 2000
--- /usr/local/share/emacs/21.2.90/lisp/ielm.el	Sun Jun  9 19:17:04 2002
***************
*** 299,305 ****
  		(setq rout (read-from-string ielm-string))
  		(setq ielm-form (car rout))
  		(setq ielm-pos (cdr rout)))
! 	    (error (setq ielm-result (ielm-format-error err))
  		   (setq ielm-error-type "Read error")))
  	  (if ielm-error-type nil
  	    ;; Make sure working buffer has not been killed
--- 299,305 ----
  		(setq rout (read-from-string ielm-string))
  		(setq ielm-form (car rout))
  		(setq ielm-pos (cdr rout)))
! 	    (error (setq ielm-result (error-message-string err))
  		   (setq ielm-error-type "Read error")))
  	  (if ielm-error-type nil
  	    ;; Make sure working buffer has not been killed
***************
*** 327,333 ****
  			    ;; in let.  Don't want to use save-excursion
  			    ;; because we want to allow changes in point.
  			    (set-buffer ielm-obuf))
! 			(error (setq ielm-result (ielm-format-error err))
  			       (setq ielm-error-type "Eval error"))
  			(quit (setq ielm-result "Quit during evaluation")
  			      (setq ielm-error-type "Eval error")))))
--- 327,333 ----
  			    ;; in let.  Don't want to use save-excursion
  			    ;; because we want to allow changes in point.
  			    (set-buffer ielm-obuf))
! 			(error (setq ielm-result (error-message-string err))
  			       (setq ielm-error-type "Eval error"))
  			(quit (setq ielm-result "Quit during evaluation")
  			      (setq ielm-error-type "Eval error")))))

Diff finished at Sun Jun  9 19:57:18
============================================================

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Adapting ielm's error reporting to Emacs': proposed patch.
  2002-06-10  2:58 Adapting ielm's error reporting to Emacs': proposed patch Luc Teirlinck
@ 2002-06-15 14:13 ` Richard Stallman
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Stallman @ 2002-06-15 14:13 UTC (permalink / raw)
  Cc: emacs-devel

Thanks for the patch.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-06-15 14:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-06-10  2:58 Adapting ielm's error reporting to Emacs': proposed patch Luc Teirlinck
2002-06-15 14:13 ` Richard Stallman

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.