summary refs log tree commit diff stats
path: root/init.el
diff options
context:
space:
mode:
Diffstat (limited to 'init.el')
-rw-r--r--init.el47
1 files changed, 36 insertions, 11 deletions
diff --git a/init.el b/init.el index e8a67fd..221956c 100644 --- a/init.el +++ b/init.el
@@ -4,26 +4,51 @@
4 4
5(setq-default load-prefer-newer t) 5(setq-default load-prefer-newer t)
6 6
7(defmacro when-at (conditions &rest commands)
8 "Run COMMANDS, or let the user know, when at a specific place.
9
10CONDITIONS are one of `:work', `:home', or a list beginning with
11those and other conditions to check. COMMANDS are only run if
12all CONDITIONS are met.
13
14If COMMANDS is empty or nil, simply return the result of CONDITIONS."
15 (declare (indent 1))
16 (let ((at-work '(memq system-type '(ms-dos windows-nt)))
17 (at-home '(memq system-type '(gnu gnu/linux gnu/kfreebsd))))
18 (pcase conditions
19 (:work (if commands `(when ,at-work ,@commands) at-work))
20 (:home (if commands `(when ,at-home ,@commands) at-home))
21 ((guard (eq (car conditions) :work))
22 (if commands
23 `(when (and ,at-work ,@(cdr conditions))
24 ,@commands)
25 `(and ,at-work ,@(cdr conditions))))
26 ((guard (eq (car conditions) :home))
27 (if commands
28 `(when (and ,at-home ,@(cdr conditions))
29 ,@commands)
30 `(and ,at-work ,@(cdr conditions)))))))
31
7(let* (;; Speed up init 32(let* (;; Speed up init
8 (gc-cons-threshold most-positive-fixnum) 33 (gc-cons-threshold most-positive-fixnum)
9 (file-name-handler-alist nil) 34 (file-name-handler-alist nil)
10 ;; Config file names 35 ;; Config file names
11 (config (expand-file-name "config" 36 (config (expand-file-name "config"
12 user-emacs-directory)) 37 user-emacs-directory))
13 (config.el (concat config ".el")) 38 (config.el (concat config ".el"))
14 (config.org (concat config ".org")) 39 (config.org (concat config ".org"))
15 (straight-org-dir (expand-file-name "straight/build/org" 40 (straight-org-dir (expand-file-name "straight/build/org"
16 user-emacs-directory))) 41 user-emacs-directory)))
17 ;; Unless config.org is /newer/ than config.el, *or* the config 42 ;; Unless config.org is /newer/ than config.el, *or* the config
18 ;; is able to be loaded without errors, load the config from 43 ;; is able to be loaded without errors, load the config from
19 ;; config.org. 44 ;; config.org.
20 (unless (or (file-newer-than-file-p config.org config.el) 45 (unless (or (file-newer-than-file-p config.org config.el)
21 (load config 'no-error)) 46 (load config 'no-error))
22 ;; A plain require here just loads the older `org' 47 ;; A plain require here just loads the older `org'
23 ;; in Emacs' install dir. We need to add the newer 48 ;; in Emacs' install dir. We need to add the newer
24 ;; one to the `load-path', hopefully that's all. 49 ;; one to the `load-path', hopefully that's all.
25 (when (file-exists-p straight-org-dir) 50 (when (file-exists-p straight-org-dir)
26 (add-to-list 'load-path straight-org-dir)) 51 (add-to-list 'load-path straight-org-dir))
27 ;; Load config.org 52 ;; Load config.org
28 (require 'org) 53 (require 'org)
29 (org-babel-load-file config.org))) 54 (org-babel-load-file config.org)))