From 491f49cfe565bc98db71908598695808bd235d72 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 29 Jul 2022 12:32:35 +0200 Subject: [PATCH] refactor(cli): better error for missing profiles.el Only appears if a profile was requested and no profile file was found. --- core/core-cli.el | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/core/core-cli.el b/core/core-cli.el index 6de7009a3..3b7b1b551 100644 --- a/core/core-cli.el +++ b/core/core-cli.el @@ -47,16 +47,22 @@ (when profile (with-temp-buffer (let ((coding-system-for-read 'utf-8-auto) - (profile-file (expand-file-name "profiles.el" user-emacs-directory))) - (insert-file-contents profile-file) + (profiles-file (expand-file-name "profiles.el" user-emacs-directory))) (condition-case e - (dolist (var (or (cdr (assq (intern profile) (read (current-buffer)))) - (progn (message "No %S profile found" profile) - (kill-emacs 3)))) - (if (eq (car var) 'env) - (dolist (env (cdr var)) (setenv (car env) (cdr env))) - (set (car var) (cdr var)))) - (end-of-file (signal 'end-of-file (list profile-file))) + (progn + (insert-file-contents profiles-file) + (dolist (var (or (cdr (assq (intern profile) (read (current-buffer)))) + (progn (message "No %S profile found" profile) + (kill-emacs 3)))) + (if (eq (car var) 'env) + (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)))))))) ;; HACK Load `cl' and site files manually to prevent polluting logs and stdout