Emacs: Add test-emacs to kill-emacs-query-functions
parent
6fb97bfcb3
commit
a11427e0d6
|
@ -309,6 +309,34 @@ Works on whole buffer if region is unactive."
|
|||
(tabify start end))
|
||||
(setq tabify-regexp tabify-regexp-old))))
|
||||
|
||||
;; Inspired by https://github.com/abo-abo/oremacs.git.
|
||||
(defun ambrevar/test-emacs ()
|
||||
"Return nil on error, t on success so that it can be added to
|
||||
`kill-emacs-query-functions'."
|
||||
(interactive)
|
||||
(let ((output
|
||||
(shell-command-to-string
|
||||
(format "emacs --batch --eval \"
|
||||
(condition-case e
|
||||
(progn
|
||||
(load \\\"%s\\\")
|
||||
(message \\\"-OK-\\\"))
|
||||
(error
|
||||
(message \\\"ERROR:\\\")
|
||||
(signal (car e) (cdr e))))\""
|
||||
user-init-file))))
|
||||
(if (string-match "-OK-" output)
|
||||
(progn
|
||||
(when (called-interactively-p 'any)
|
||||
(message "All is well"))
|
||||
t)
|
||||
(switch-to-buffer-other-window "*init file error*")
|
||||
(erase-buffer)
|
||||
(insert output)
|
||||
(search-backward "ERROR:")
|
||||
nil)))
|
||||
(add-hook 'kill-emacs-query-functions 'ambrevar/test-emacs)
|
||||
|
||||
;;; TODO: Store window configurations in a buffer-name-indexed alist? Not
|
||||
;;; sure that would ever be useful.
|
||||
(defvar single-window--last-configuration nil "Last window configuration before calling `delete-other-windows'.")
|
||||
|
|
Loading…
Reference in New Issue