refactor(cli): better error for missing profiles.el

Only appears if a profile was requested and no profile file was found.
This commit is contained in:
Henrik Lissner 2022-07-29 12:32:35 +02:00
parent 068966a4cd
commit 491f49cfe5
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -47,16 +47,22 @@
(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)
(profile-file (expand-file-name "profiles.el" user-emacs-directory))) (profiles-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)))) (progn
(progn (message "No %S profile found" profile) (insert-file-contents profiles-file)
(kill-emacs 3)))) (dolist (var (or (cdr (assq (intern profile) (read (current-buffer))))
(if (eq (car var) 'env) (progn (message "No %S profile found" profile)
(dolist (env (cdr var)) (setenv (car env) (cdr env))) (kill-emacs 3))))
(set (car var) (cdr var)))) (if (eq (car var) 'env)
(end-of-file (signal 'end-of-file (list profile-file))) (dolist (env (cdr var)) (setenv (car env) (cdr env)))
(set (car var) (cdr var)))))
(file-missing
(message "No $EMACSDIR/%s file to look up %S in."
(file-name-nondirectory profiles-file)
profile)
(kill-emacs 3))
(end-of-file (signal 'end-of-file (list profiles-file)))
(error (error "Parser error in profiles.el: %s" (error-message-string e)))))))) (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