all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Displaying errors during startup
@ 2006-04-26 15:13 Lennart Borgman
  2006-04-26 18:41 ` Kevin Rodgers
  2006-04-27 21:27 ` Richard Stallman
  0 siblings, 2 replies; 4+ messages in thread
From: Lennart Borgman @ 2006-04-26 15:13 UTC (permalink / raw)


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.

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

end of thread, other threads:[~2006-04-27 21:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-26 15:13 Displaying errors during startup Lennart Borgman
2006-04-26 18:41 ` Kevin Rodgers
2006-04-27 21:27 ` Richard Stallman
2006-04-27 21:34   ` Lennart Borgman

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.