From 2d8b3ca06c58c6b9f56c6d9b597eb862d9b425ef Mon Sep 17 00:00:00 2001 From: Justin Smestad Date: Sun, 23 Sep 2018 17:05:04 -0600 Subject: [PATCH] Fix void symbol error when parsing .emacs-profile I also cleaned up a host of compiler warnings related and switched to `defvar` instead of `setq` which eliminated the free variable assignment warnings. --- .emacs | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/.emacs b/.emacs index 39d918d..bb2bc51 100644 --- a/.emacs +++ b/.emacs @@ -1,3 +1,5 @@ +;;; .emacs --- -*- lexical-binding: t; -*- +;;; Commentary: ;; :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ;; ;; ___ ___ ___ ___ ___ ___ ___ @@ -23,7 +25,7 @@ ;; ;; (("default" . ((user-emacs-directory . "~/.emacs.d")))) ;; -;; Now you can start emacs with `--with-profile' to pick a specific profile. A +;; Now you can start Emacs with `--with-profile' to pick a specific profile. A ;; more elaborate example: ;; ;; (("default" . ((user-emacs-directory . "~/emacs-profiles/plexus"))) @@ -41,29 +43,31 @@ ;; `package-initialize' for real in your own init.el ;; (package-initialize) -(setq chemacs-profiles-path "~/.emacs-profiles.el") -(setq chemacs-default-profile-path "~/.emacs-profile") +;;; Code: +(defvar chemacs-profiles-path "~/.emacs-profiles.el") +(defvar chemacs-default-profile-path "~/.emacs-profile") (when (not (file-exists-p chemacs-profiles-path)) (with-temp-file chemacs-profiles-path (insert "((\"default\" . ((user-emacs-directory . \"~/.emacs.d\"))))"))) -(setq chemacs-emacs-profiles - (with-temp-buffer - (insert-file-contents chemacs-profiles-path) - (goto-char (point-min)) - (read (current-buffer)))) - -(setq chemacs-default-profile - (if (file-exists-p chemacs-default-profile-path) - (with-temp-buffer - (insert-file-contents chemacs-default-profile-path) - (goto-char (point-min)) - (symbol-name (read (current-buffer)))) - "default")) +(defvar chemacs-emacs-profiles + (with-temp-buffer + (insert-file-contents chemacs-profiles-path) + (goto-char (point-min)) + (read (current-buffer)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(defun chemacs-detect-default-profile () + (if (file-exists-p chemacs-default-profile-path) + (with-temp-buffer + (insert-file-contents chemacs-default-profile-path) + (goto-char (point-min)) + ;; (buffer-string)) + (symbol-name (read (current-buffer)) )) + "default")) + (defun chemacs-get-emacs-profile (profile) (cdr (assoc profile chemacs-emacs-profiles))) @@ -118,4 +122,7 @@ ;; Or if none given, load the "default" profile (when (not (member "--with-profile" command-line-args)) - (chemacs-load-profile (chemacs-default-profile))) + (chemacs-load-profile (chemacs-detect-default-profile))) + +(provide '.emacs) +;;; .emacs ends here