about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--early-init.el51
-rw-r--r--lisp/system.el113
2 files changed, 149 insertions, 15 deletions
diff --git a/early-init.el b/early-init.el index 462643a..1917779 100644 --- a/early-init.el +++ b/early-init.el
@@ -52,41 +52,63 @@ See `no-littering' for examples.")
52(+define-dir sync/ (expand-file-name "~/Sync") 52(+define-dir sync/ (expand-file-name "~/Sync")
53 "My Syncthing directory.") 53 "My Syncthing directory.")
54 54
55;; Load system-specific changes.
56(progn (require 'system)
57 (setq system-load-directory (sync/ "emacs/systems/" t))
58 (system-settings-load nil :nowarn))
59
55;;; Default frame settings 60;;; Default frame settings
56 61
57(setq default-frame-alist '((tool-bar-lines . 0) 62(setq default-frame-alist '((tool-bar-lines . 0)
58 (menu-bar-lines . 0) 63 (menu-bar-lines . 0)
59 (vertical-scroll-bars) 64 (vertical-scroll-bars)
60 (horizontal-scroll-bars)) 65 (horizontal-scroll-bars))
61 frame-inhibit-implied-resize t 66 frame-inhibit-implied-resize t
62 frame-resize-pixelwise t 67 frame-resize-pixelwise t
63 window-resize-pixelwise t 68 window-resize-pixelwise t
64 inhibit-x-resources t 69 inhibit-x-resources t
65 indicate-empty-lines nil 70 indicate-empty-lines nil
66 indicate-buffer-boundaries '((top . right) 71 indicate-buffer-boundaries '((top . right)
67 (bottom . right))) 72 (bottom . right)))
73
74;;; Fonts
68 75
69;; Fonts 76;; Set default faces
70 77
71(let ((font-name "DejaVu Sans Mono") 78(let ((font-name system-default-font)
72 (font-size 105) 79 (font-size system-default-height)
73 (variable-font-name "DejaVu Sans") 80 (variable-font-name system-variable-pitch-font)
74 (variable-font-size 1.0)) 81 (variable-font-size system-variable-pitch-height))
75 (set-face-attribute 'default nil :family font-name 82 (set-face-attribute 'default nil :family system-default-font
76 :height font-size :weight 'book) 83 :height font-size :weight 'book)
77 (set-face-attribute 'italic nil :family font-name 84 (set-face-attribute 'italic nil :family font-name
78 :height font-size :slant 'italic) 85 :height font-size :slant 'italic)
79 (set-face-attribute 'variable-pitch nil :family variable-font-name 86 (set-face-attribute 'variable-pitch nil :family variable-font-name
80 :height variable-font-size)) 87 :height variable-font-size))
81 88
89;; Emoji fonts
90
91(let ((ffl (font-family-list)))
92 (dolist (font '("Noto Color Emoji"
93 "Noto Emoji"
94 "Segoe UI Emoji"
95 "Apple Color Emoji"
96 "FreeSans"
97 "FreeMono"
98 "FreeSerif"
99 "Unifont"
100 "Symbola"))
101 (when (member font ffl)
102 (set-fontset-font t 'symbol (font-spec :family font) nil :append))))
103
82;;; Packages 104;;; Packages
83 105
84(setq package-enable-at-startup nil 106(setq package-enable-at-startup nil
85 package-quickstart nil 107 package-quickstart nil
86 straight-host-usernames '((github . "duckwork") 108 straight-host-usernames '((github . "duckwork")
87 (gitlab . "acdw")) 109 (gitlab . "acdw"))
88 straight-check-for-modifications '(check-on-save 110 straight-check-for-modifications '(check-on-save
89 find-when-checking)) 111 find-when-checking))
90 112
91(setq no-littering-etc-directory .etc 113(setq no-littering-etc-directory .etc
92 no-littering-var-directory .etc 114 no-littering-var-directory .etc
@@ -117,8 +139,8 @@ See `no-littering' for examples.")
117(require 'straight-x) 139(require 'straight-x)
118 140
119(dolist (pkg '(el-patch 141(dolist (pkg '(el-patch
120 no-littering 142 no-littering
121 setup)) 143 setup))
122 (straight-use-package pkg) 144 (straight-use-package pkg)
123 (require pkg) 145 (require pkg)
124 (require (intern (format "+%s" pkg)) nil :noerror)) 146 (require (intern (format "+%s" pkg)) nil :noerror))
@@ -137,4 +159,3 @@ See `no-littering' for examples.")
137 159
138(provide 'early-init) 160(provide 'early-init)
139;;; early-init.el ends here 161;;; early-init.el ends here
140
diff --git a/lisp/system.el b/lisp/system.el new file mode 100644 index 0000000..9bb057c --- /dev/null +++ b/lisp/system.el
@@ -0,0 +1,113 @@
1;;; system.el --- System-specific configuration -*- lexical-binding: t; -*-
2
3;;; Commentary:
4
5;; When using Emacs on separate computers, some variables need different
6;; settings. This library contains functions and variables to work with
7;; different system configurations for Emacs.
8
9;;; Code:
10
11(require 'cl-lib)
12
13(defgroup system nil
14 "System-specific configurations."
15 :group 'emacs
16 :prefix "system-")
17
18;;; Variables
19
20(defcustom system-load-alist '((system-microsoft-p . windows)
21 (system-linux-p . linux))
22 "Alist describing which system Emacs is on.
23Each cell is of the form (PREDICATE . SYSTEM), where PREDICATE is
24a function of no arguments and SYSTEM is a string or symbol that
25will be passed to `system-settings-load'.
26
27This list need not be exhaustive; see `system-settings-load' for
28more details on what happens if this alist is exhausted."
29 :type '(alist :key-type function :value-type (choice string symbol)))
30
31(defcustom system-load-directory (locate-user-emacs-file "systems")
32 "The directory from which to load system-specific configurations."
33 :type 'file)
34
35;; `defcustoms' defined here are best-guess defaults.
36
37(defcustom system-default-font (pcase system-type
38 ((or 'ms-dos 'windows-nt)
39 "Consolas")
40 (_ "monospace"))
41 "The font used for the `default' face."
42 :type 'string)
43
44(defcustom system-default-height 100
45 "The height used for the `default' face."
46 :type 'number)
47
48(defcustom system-variable-pitch-font (pcase system-type
49 ((or 'ms-dos 'windows-nt)
50 "Arial")
51 (_ "sans-serif"))
52 "The font used for the `variable-pitch' face."
53 :type 'string)
54
55(defcustom system-variable-pitch-height 1.0
56 "The height used for the `variable-pitch' face.
57A floating-point number is recommended, since that makes it
58relative to the `default' face height."
59 :type 'number)
60
61;;; Functions
62
63;; Convenience functions for systems
64(defun system-microsoft-p ()
65 "Return non-nil if running in a Microsoft system."
66 (memq system-type '(ms-dos windows-nt)))
67
68(defun system-linux-p ()
69 "Return non-nil if running on a Linux system."
70 (memq system-type '(gnu/linux)))
71
72(defun system-warn (message &rest args)
73 "Display a wraning message made from (format-message MESSAGE ARGS...).
74This function is like `warn', except it uses the `system' type."
75 (display-warning 'system (apply #'format-message message args)))
76
77;;;###autoload
78(defun system-settings-load (&optional system error nomessage)
79 "Load system settings.
80If optional SYSTEM (a symbol or a string) is not provided, loop
81through `system-load-alist', testing the car of each cell there.
82When one matches, use the cdr of that cell as SYSTEM. Either
83way, look in `system-load-directory' for the files to load.
84
85If none match, warn the user.
86
87Optional argument ERROR is similar to in `load', but negated: if
88t, it will generate an error; if nil, it will warn the user;
89otherwise, if ERROR is anything else, it will be completely
90silent.
91
92NOMESSAGE is passed as-is to `load'."
93 (let ((system (or system
94 (cl-loop for (p . s) in system-load-alist
95 if (funcall p)
96 return s))))
97 (if system
98 (condition-case e
99 (load (expand-file-name (format "%s" system) system-load-directory)
100 nil nomessage)
101 (t (cond ((eq error t) (signal (car e) (cdr e)))
102 ((null error) (system-warn
103 (concat
104 "Couldn't find file `%s' to load"
105 " (Looked in %s).")
106 system system-load-directory)))))
107 (funcall (cond ((eq error t) #'error)
108 ((null error) #'system-warn)
109 (t #'ignore))
110 "Could not determine the system being used."))))
111
112(provide 'system)
113;;; system.el ends here