diff --git a/early-init.el b/early-init.el index 96ff752a..6db5012f 100644 --- a/early-init.el +++ b/early-init.el @@ -15,7 +15,7 @@ ;; `set-language-enviornment' sets `default-input-method', which is unwanted (setq default-input-method nil) -(setq config-dir (file-name-directory (file-truename user-init-file))) ;; user-init-file: ~/.config/emacs/init, file-truename: /opt/emacs-conf/init +(defvar config-dir (file-name-directory (file-truename load-file-name))) (setq user-emacs-directory "~/.config/emacs/") ;; for cache etc. (defconst user-cache-directory (file-name-as-directory (concat user-emacs-directory ".cache")) @@ -48,7 +48,7 @@ (add-to-list 'default-frame-alist '(alpha . (95 . 95))) ;; Custom functions/hooks for persisting/loading frame geometry upon save/load -(setq my-frame-geometry-file (concat user-cache-directory "frame-geometry.el")) +(defvar my-frame-geometry-file (concat user-cache-directory "frame-geometry.el")) (defun my-frame-geometry-save () "Gets the current frame's geometry and save it to `my-frame-geometry-file'." (let ((frameg-font (frame-parameter (selected-frame) 'font)) @@ -87,3 +87,6 @@ (lambda () (if (display-graphic-p) (add-hook 'kill-emacs-hook 'my-frame-geometry-save)))) + +(provide 'early-init) +;;; early-init.el ends here diff --git a/init b/init index 23d2ebd3..2a00b993 100644 --- a/init +++ b/init @@ -4,16 +4,27 @@ ;; Emacs Startup File --- initialization for Emacs ;; https://blog.d46.us/advanced-emacs-startup/ +;; Usage: +;; "emacs --init-directory ~/repos/emacs-conf" +;; "emacs --no-splash -q -l ~/repos/emacs-conf/init" + ;; Requirements: git gnuplot ledger ;;; Code: -;; Emacs 27.1 introduced early-init.el, which is run before init.el, before -;; package and UI initialization happens, and before site files are loaded. -;; In the case that early-init.el wasn't loaded (e.g. using old emacs? Or this -;; file directly loaded?), we do it explicitly: -(unless (version<= "27.1" emacs-version) - (load (concat (file-name-directory (file-truename user-init-file)) "early-init.el") - nil t)) +(require 'early-init + (concat + (file-name-directory (file-truename (or load-file-name + "~/.config/emacs/init"))) + "early-init.el") + t) +;; Load early-init-el if not already +;; - Emacs 27.1 introduced early-init.el, which is run before +;; init.el, before package and UI initialization happens, and +;; before site files are loaded. In the case that early-init.el +;; wasn't loaded (e.g. using old emacs? Or this file directly +;; loaded?), we do it explicitly +;; - for org export async actions, e.g. as in +;; emacs -l ~/.config/emacs/init -l /tmp/org-export-processXYZ (require 'pre-settings) ;; use-package delight functions variables (require 'which-key-settings) ;; https://melpa.org/#/which-key (require 'general-settings) ;; requires which-key