Mercurial > hg > xemacs-beta
comparison lisp/startup.el @ 5754:b09e3b1b7424
Use #'call-with-condition-handler, #'normal-top-level, instead of resignalling
lisp/ChangeLog addition:
2013-08-21 Aidan Kehoe <kehoea@parhasard.net>
* startup.el (normal-top-level):
Use #'call-with-condition-handler here when calling
#'command-line, giving better backtraces on error.
Be careful about the current buffer in HANDLER.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Wed, 21 Aug 2013 20:16:55 +0100 |
parents | d469c668462e |
children | bbe4146603db |
comparison
equal
deleted
inserted
replaced
5753:dbd8305e13cb | 5754:b09e3b1b7424 |
---|---|
542 ;; Either we need to inhibit messages from do_autoloads, or this | 542 ;; Either we need to inhibit messages from do_autoloads, or this |
543 ;; should go into (command-line) after the initialization of the | 543 ;; should go into (command-line) after the initialization of the |
544 ;; frame? | 544 ;; frame? |
545 (startup-load-autoloads) | 545 (startup-load-autoloads) |
546 | 546 |
547 (let (error-data) | 547 (macrolet |
548 ;; if noninteractive, an error will kill us. by catching and | 548 ((replace-ntl-buffer (&body body) |
549 ;; resignalling, we don't accomplish much, but do make it difficult | 549 ;; Create a dynamic variable that won't escape outside this |
550 ;; to determine where the error really occurred. when interactive, | 550 ;; function (which will not be called recursively, and so won't |
551 ;; however, an error processing the command line does NOT kill us; | 551 ;; shadow itself) and doesn't require consing a closure at |
552 ;; instead, the error handler tries to display an error on the frame. | 552 ;; runtime: |
553 ;; In that case, we must make sure that all the remaining initialization | 553 (cons 'progn (subst '#:ntl-buffer 'ntl-buffer body :test #'eq)))) |
554 ;; gets done!!! | 554 (replace-ntl-buffer |
555 ;; | 555 (let ((ntl-buffer (current-buffer))) |
556 ;; #### A better solution in the interactive case is to use | 556 (labels ((after-command-line (&optional error-data) |
557 ;; call-with-condition-handler, which would let us do the rest of | 557 (with-current-buffer ntl-buffer |
558 ;; the initialization AND allow the user to get an accurate backtrace. | 558 ;; Do this again, in case the init file defined more |
559 (if (noninteractive) | 559 ;; abbreviations. |
560 (command-line) | 560 (setq default-directory |
561 (condition-case data | 561 (abbreviate-file-name default-directory)) |
562 (command-line) | 562 ;; Specify the file for recording all the auto save |
563 ;; catch non-error signals, especially quit | 563 ;; files of this session. This is used by |
564 (t (setq error-data data)))) | 564 ;; recover-session. |
565 ;; Do this again, in case the init file defined more abbreviations. | 565 (if auto-save-list-file-prefix |
566 (setq default-directory (abbreviate-file-name default-directory)) | 566 (setq auto-save-list-file-name |
567 ;; Specify the file for recording all the auto save files of | 567 (expand-file-name |
568 ;; this session. This is used by recover-session. | 568 (format "%s%d-%s" |
569 (if auto-save-list-file-prefix | 569 auto-save-list-file-prefix |
570 (setq auto-save-list-file-name | 570 (emacs-pid) |
571 (expand-file-name | 571 (system-name))))) |
572 (format "%s%d-%s" | 572 (run-hooks 'emacs-startup-hook) |
573 auto-save-list-file-prefix | 573 (and term-setup-hook |
574 (emacs-pid) | 574 (run-hooks 'term-setup-hook)) |
575 (system-name))))) | 575 (setq term-setup-hook nil) |
576 (run-hooks 'emacs-startup-hook) | 576 ;; Modify the initial frame based on what the init file |
577 (and term-setup-hook | 577 ;; puts into ...-frame-alist. |
578 (run-hooks 'term-setup-hook)) | 578 (frame-notice-user-settings) |
579 (setq term-setup-hook nil) | 579 (when window-setup-hook |
580 ;; ;; Modify the initial frame based on what the init file puts into | 580 (run-hooks 'window-setup-hook)) |
581 ;; ;; ...-frame-alist. | 581 (setq window-setup-hook nil)))) |
582 (frame-notice-user-settings) | 582 (call-with-condition-handler |
583 ;; ;;#### GNU Emacs junk | 583 (if (noninteractive) |
584 ;; ;; Now we know the user's default font, so add it to the menu. | 584 #'ignore |
585 ;; (if (fboundp 'font-menu-add-default) | 585 ;; If noninteractive, an error will kill us. When |
586 ;; (font-menu-add-default)) | 586 ;; interactive, however, an error processing the command |
587 (when window-setup-hook | 587 ;; line does NOT kill us; instead, the error handler tries |
588 (run-hooks 'window-setup-hook)) | 588 ;; to display an error on the frame. In that case, we must |
589 (setq window-setup-hook nil) | 589 ;; make sure that all the remaining initialization gets |
590 (if error-data | 590 ;; done. |
591 ;; re-signal, and don't allow continuation as that will probably | 591 #'after-command-line) |
592 ;; wipe out the user's .emacs if she hasn't migrated yet! | 592 #'command-line) |
593 (signal-error (car error-data) (cdr error-data)))) | 593 |
594 ;; If we're here, we haven't errored, and the function still needs | |
595 ;; to be called. | |
596 (after-command-line))))) | |
594 | 597 |
595 (if load-user-init-file-p | 598 (if load-user-init-file-p |
596 (maybe-migrate-user-init-file)) | 599 (maybe-migrate-user-init-file)))) |
597 ;; GNU calls precompute-menubar-bindings. We don't mix menubars | 600 ;; GNU calls precompute-menubar-bindings. We don't mix menubars |
598 ;; and keymaps. | 601 ;; and keymaps. |
599 )) | |
600 | 602 |
601 (defun command-line-early (args) | 603 (defun command-line-early (args) |
602 ;; This processes those switches which need to be processed before | 604 ;; This processes those switches which need to be processed before |
603 ;; starting up the window system. | 605 ;; starting up the window system. |
604 | 606 |