fix(cli): improve end-of-file error in profiles file

Otherwise, the error message complains that the error originates from
core-cli.el.
This commit is contained in:
Henrik Lissner 2022-07-28 18:12:36 +02:00
parent 12b52909e3
commit 7eeec53c30
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -46,15 +46,18 @@
(let ((profile (getenv "DOOMPROFILE"))) (let ((profile (getenv "DOOMPROFILE")))
(when profile (when profile
(with-temp-buffer (with-temp-buffer
(let ((coding-system-for-read 'utf-8-auto)) (let ((coding-system-for-read 'utf-8-auto)
(insert-file-contents (expand-file-name "profiles.el" user-emacs-directory))) (profile-file (expand-file-name "profiles.el" user-emacs-directory)))
(insert-file-contents profile-file)
(condition-case e (condition-case e
(dolist (var (or (cdr (assq (intern profile) (read (current-buffer)))) (dolist (var (or (cdr (assq (intern profile) (read (current-buffer))))
(user-error "No %S profile found" profile))) (progn (message "No %S profile found" profile)
(kill-emacs 3))))
(if (eq (car var) 'env) (if (eq (car var) 'env)
(dolist (env (cdr var)) (setenv (car env) (cdr env))) (dolist (env (cdr var)) (setenv (car env) (cdr env)))
(set (car var) (cdr var)))) (set (car var) (cdr var))))
(error (error "Failed to parse profiles.el: %s" (error-message-string e))))))) (end-of-file (signal 'end-of-file (list profile-file)))
(error (error "Parser error in profiles.el: %s" (error-message-string e))))))))
;; HACK Load `cl' and site files manually to prevent polluting logs and stdout ;; HACK Load `cl' and site files manually to prevent polluting logs and stdout
;; with deprecation and/or file load messages. ;; with deprecation and/or file load messages.