diff --git a/init.el b/init.el new file mode 100644 index 0000000..35d8cad --- /dev/null +++ b/init.el @@ -0,0 +1,56 @@ +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Keep emacs clean! +;; Change the user-emacs-directory to keep unwanted things out of ~/.emacs.d +(setq user-emacs-directory (expand-file-name "~/.cache/emacs/") + url-history-file (expand-file-name "url/history" user-emacs-directory)) + +(setq custom-file (expand-file-name "custom.el" user-emacs-directory)) + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; set up straight package manager +(defvar bootstrap-version) +(let ((bootstrap-file + (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory)) + (bootstrap-version 5)) + (unless (file-exists-p bootstrap-file) + (with-current-buffer + (url-retrieve-synchronously + "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el" + 'silent 'inhibit-cookies) + (goto-char (point-max)) + (eval-print-last-sexp))) + (load bootstrap-file nil 'nomessage)) + +(straight-use-package 'use-package) +(setq straight-use-package-by-default t) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Install org-mode +(straight-use-package 'org) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Helper functions + +;; Helper function for loading elisp files +(defun load-elisp-if-exists (f) + "load the elisp file only if it exists and is readable" + (if (file-readable-p f) + (load-file f))) + +;; (defun load-orgfile-if-exists (f) +;; "load the elisp file only if it exists and is readable" +;; (if (file-readable-p f) +;; (org-babel-load-file (f)))) + + + +;; Load configuration +;; Load myconfig.el unless there are changes in myconfig.org +(let ((config-el (expand-file-name "myconfig.el" user-emacs-directory)) + (config-org (expand-file-name "myconfig.org" user-emacs-directory))) + (if (and (file-exists-p config-el) + (time-less-p (file-attribute-modification-time (file-attributes config-org)) + (file-attribute-modification-time (file-attributes config-el)))) + (load-file config-el) + (org-babel-load-file config-org)))