From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Luc Teirlinck Newsgroups: gmane.emacs.devel Subject: Adapting ielm's error reporting to Emacs': proposed patch. Date: Sun, 9 Jun 2002 21:58:21 -0500 (CDT) Sender: emacs-devel-admin@gnu.org Message-ID: <200206100258.VAA26243@eel.dms.auburn.edu> NNTP-Posting-Host: localhost.gmane.org X-Trace: main.gmane.org 1023678058 13563 127.0.0.1 (10 Jun 2002 03:00:58 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 10 Jun 2002 03:00:58 +0000 (UTC) Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.33 #1 (Debian)) id 17HFQQ-0003WX-00 for ; Mon, 10 Jun 2002 05:00:58 +0200 Original-Received: from fencepost.gnu.org ([199.232.76.164]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 17HFn3-0003Ib-00 for ; Mon, 10 Jun 2002 05:24:22 +0200 Original-Received: from localhost ([127.0.0.1] helo=fencepost.gnu.org) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 17HFPa-0002NT-00; Sun, 09 Jun 2002 23:00:06 -0400 Original-Received: from manatee.dms.auburn.edu ([131.204.53.104]) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 17HFN9-0002Ie-00 for ; Sun, 09 Jun 2002 22:57:35 -0400 Original-Received: from eel.dms.auburn.edu (eel.dms.auburn.edu [131.204.53.108]) by manatee.dms.auburn.edu (8.9.1a/8.9.1) with ESMTP id VAA07086 for ; Sun, 9 Jun 2002 21:57:34 -0500 (CDT) Original-Received: (from teirllm@localhost) by eel.dms.auburn.edu (8.9.3+Sun/8.9.3) id VAA26243; Sun, 9 Jun 2002 21:58:21 -0500 (CDT) X-Authentication-Warning: eel.dms.auburn.edu: teirllm set sender to teirllm@dms.auburn.edu using -f Original-To: emacs-devel@gnu.org Errors-To: emacs-devel-admin@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.0.9 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.devel:4677 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:4677 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 * 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 ============================================================