about summary refs log tree commit diff stats
path: root/init.el
blob: 332468c600ef617b8d111886990376e9e5827e30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
;; init.el -*- lexical-binding: t -*-
;; This file is automatically tangled from config.org.
;; Hand edits will be overwritten!

(setq-default load-prefer-newer t)

(defmacro when-at (conditions &rest commands)
  "Run COMMANDS, or let the user know, when at a specific place.

CONDITIONS are one of `:work', `:home', or a list beginning with
those and other conditions to check.  COMMANDS are only run if
all CONDITIONS are met.

If COMMANDS is empty or nil, simply return the result of CONDITIONS."
  (declare (indent 1))
  (let ((at-work '(memq system-type '(ms-dos windows-nt)))
        (at-home '(memq system-type '(gnu gnu/linux gnu/kfreebsd))))
    (pcase conditions
      (:work (if commands `(when ,at-work ,@commands) at-work))
      (:home (if commands `(when ,at-home ,@commands) at-home))
      ((guard (eq (car conditions) :work))
       (if commands
           `(when (and ,at-work ,@(cdr conditions))
              ,@commands)
         `(and ,at-work ,@(cdr conditions))))
      ((guard (eq (car conditions) :home))
       (if commands
           `(when (and ,at-home ,@(cdr conditions))
              ,@commands)
         `(and ,at-work ,@(cdr conditions)))))))

(let* (;; Speed up init
       (gc-cons-threshold most-positive-fixnum)
       (file-name-handler-alist nil)
       ;; Config file names
       (config (expand-file-name "config"
                                 user-emacs-directory))
       (config.el (concat config ".el"))
       (config.org (concat config ".org"))
       (straight-org-dir (expand-file-name "straight/build/org"
                                           user-emacs-directory)))
  (unless (load config 'no-error))
  ;; A plain require here just loads the older `org'
  ;; in Emacs' install dir.  We need to add the newer
  ;; one to the `load-path', hopefully that's all.
  (when (file-exists-p straight-org-dir)
    (add-to-list 'load-path straight-org-dir))
  ;; Load config.org
  (require 'org)
  (org-babel-load-file config.org :compile))