From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Lennart Borgman Newsgroups: gmane.emacs.devel Subject: Displaying errors during startup Date: Wed, 26 Apr 2006 17:13:43 +0200 Message-ID: <444F8E27.10501@student.lu.se> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1146064526 20171 80.91.229.2 (26 Apr 2006 15:15:26 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 26 Apr 2006 15:15:26 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Apr 26 17:15:24 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1FYliO-00012s-NR for ged-emacs-devel@m.gmane.org; Wed, 26 Apr 2006 17:14:05 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FYliN-0002sr-Us for ged-emacs-devel@m.gmane.org; Wed, 26 Apr 2006 11:14:03 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FYli9-0002ry-U8 for emacs-devel@gnu.org; Wed, 26 Apr 2006 11:13:49 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FYli8-0002qs-8X for emacs-devel@gnu.org; Wed, 26 Apr 2006 11:13:48 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FYli8-0002qm-2x for emacs-devel@gnu.org; Wed, 26 Apr 2006 11:13:48 -0400 Original-Received: from [81.228.11.159] (helo=pne-smtpout2-sn1.fre.skanova.net) by monty-python.gnu.org with esmtp (Exim 4.52) id 1FYlko-0003Td-Tu for emacs-devel@gnu.org; Wed, 26 Apr 2006 11:16:35 -0400 Original-Received: from [192.168.123.121] (83.249.218.244) by pne-smtpout2-sn1.fre.skanova.net (7.2.070) id 4444940C0021AFBD for emacs-devel@gnu.org; Wed, 26 Apr 2006 17:13:44 +0200 User-Agent: Thunderbird 1.5.0.2 (Windows/20060308) Original-To: Emacs Devel X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:53479 Archived-At: After the recent discussion about error messages at startup (this time it was about pure-space-overflow) it came to my mind I often tend to miss errors at startup. You can not see them because of the splash screen for example. I just started testing `lwarn' because of this. I did something like this: (condition-case err (require 'something-bad) (error (lwarn '(.emacs) :error "%s" (error-message-string err)))) This displays the error in a nice way even during startup. Looking a bit closer at it it seems to be some trouble with using `pop-to-buffer' in startup.el when loading .emacs. I therefore suggest using `display-buffer' instead like lwarn does. It would also be nice to have a more visible face when putting this in the message buffer. I therefore suggest using something like the code below in startup.el (around line 905): (if init-file-debug (load inner) (condition-case error (load inner) (error (let ((message-log-max nil)) (save-excursion (set-buffer (get-buffer-create "*Messages*")) (let ((s (concat "\n\n" (format "An error has occurred while loading `%s':\n\n" user-init-file) (format "%s%s%s" (get (car error) 'error-message) (if (cdr error) ": " "") (mapconcat (lambda (s) (prin1-to-string s t)) (cdr error) ", ")) "\n\n" "To ensure normal operation, you should investigate and remove the\n" "cause of the error in your initialization file. Start Emacs with\n" "the `--debug-init' option to view a complete error backtrace.\n\n"))) (put-text-property 0 (length s) 'face 'font-lock-warning-face s) (insert s) (insert "\n") ;; Needed to get normal face again. (message "Error in init file: %s%s%s" (get (car error) 'error-message) (if (cdr error) ": " "") (mapconcat 'prin1-to-string (cdr error) ", ")) ;;(let ((pop-up-windows nil)) ;; (pop-to-buffer "*Messages*")) (display-buffer "*Messages*") ;; display-buffer does the job. (sit-for 10) ;; sit-for is necessary to display the info at once. (setq init-file-had-error t))))))) Maybe this would be good to do before the release because it makes it somewhat easier to trap errors.