summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCase Duckworth2022-01-17 13:45:32 -0600
committerCase Duckworth2022-01-17 13:45:32 -0600
commit1394b10658f5059aeb5fa45a2985f4cac97f833d (patch)
tree9a448cbcd0e6d94d337893f764f28fe1f833e77d
parentAdd sort-setq (diff)
downloademacs-1394b10658f5059aeb5fa45a2985f4cac97f833d.tar.gz
emacs-1394b10658f5059aeb5fa45a2985f4cac97f833d.zip
So! Many! Changes!!
-rw-r--r--early-init.el37
-rw-r--r--eshell/aliases4
-rw-r--r--eshell/history14
-rw-r--r--eshell/lastdir11
-rw-r--r--init.el50
-rw-r--r--lisp/+lisp.el2
-rw-r--r--lisp/+org.el3
-rw-r--r--lisp/+vterm.el2
-rw-r--r--lisp/acdw.el13
-rw-r--r--lisp/system.el240
-rw-r--r--systems/bob.el10
-rw-r--r--systems/gnu-linux.el5
-rw-r--r--systems/windows-nt.el23
13 files changed, 259 insertions, 155 deletions
diff --git a/early-init.el b/early-init.el index c87f2df..67b4271 100644 --- a/early-init.el +++ b/early-init.el
@@ -57,8 +57,7 @@ See `no-littering' for examples.")
57(progn (require 'system) 57(progn (require 'system)
58 (setq system-default-font "DejaVu Sans Mono" 58 (setq system-default-font "DejaVu Sans Mono"
59 system-variable-pitch-font "DejaVu Sans") 59 system-variable-pitch-font "DejaVu Sans")
60 (setq system-load-directory (sync/ "emacs/systems/" t)) 60 (system-settings-load))
61 (system-settings-load nil :nowarn))
62 61
63;;; Default frame settings 62;;; Default frame settings
64 63
@@ -75,7 +74,7 @@ See `no-littering' for examples.")
75 (bottom . right))) 74 (bottom . right)))
76 75
77;;; Fonts 76;;; Fonts
78(progn 77(+with-ensure-after-init
79 ;; Set default faces 78 ;; Set default faces
80 (+with-message "Setting default faces" 79 (+with-message "Setting default faces"
81 (let ((font-name system-default-font) 80 (let ((font-name system-default-font)
@@ -90,23 +89,21 @@ See `no-littering' for examples.")
90 :height variable-font-size))) 89 :height variable-font-size)))
91 90
92 ;; Emoji fonts 91 ;; Emoji fonts
93 (+ensure-after-init 92 (+with-message "Adding emoji fonts"
94 (lambda () 93 (let ((ffl (font-family-list)))
95 (+with-message "Adding emoji fonts" 94 (dolist (font '("Noto Color Emoji"
96 (let ((ffl (font-family-list))) 95 "Noto Emoji"
97 (dolist (font '("Noto Color Emoji" 96 "Segoe UI Emoji"
98 "Noto Emoji" 97 "Apple Color Emoji"
99 "Segoe UI Emoji" 98 "FreeSans"
100 "Apple Color Emoji" 99 "FreeMono"
101 "FreeSans" 100 "FreeSerif"
102 "FreeMono" 101 "Unifont"
103 "FreeSerif" 102 "Symbola"))
104 "Unifont" 103 (when (member font ffl)
105 "Symbola")) 104 (message "Found font: %s" font)
106 (when (member font ffl) 105 (set-fontset-font t 'symbol
107 (message "Found font: %s" font) 106 (font-spec :family font) nil :append))))))
108 (set-fontset-font t 'symbol
109 (font-spec :family font) nil :append))))))))
110 107
111;;; Packages 108;;; Packages
112 109
diff --git a/eshell/aliases b/eshell/aliases new file mode 100644 index 0000000..201e556 --- /dev/null +++ b/eshell/aliases
@@ -0,0 +1,4 @@
1alias edit find-file $1
2alias e find-file $1
3alias ff find-file $1
4alias sudo eshell/sudo $*
diff --git a/eshell/history b/eshell/history new file mode 100644 index 0000000..67689e1 --- /dev/null +++ b/eshell/history
@@ -0,0 +1,14 @@
1cd .emacs.d/.etc/straight/build/org/
2ls
3cd ../
4ls
5cd ../repos/org/
6ls
7find-file .emacs.d/init.el
8exit
9apt search font
10cd
11vterm
12cat ~/Sync/fonts-debian.txt | sudo xargs apt install
13cat ~/Sync/fonts-debian.txt | sudo xargs apt install -y
14alias e='find-file $*'
diff --git a/eshell/lastdir b/eshell/lastdir new file mode 100644 index 0000000..1549824 --- /dev/null +++ b/eshell/lastdir
@@ -0,0 +1,11 @@
1~
2/home/case/.emacs.d/.etc/straight/build/org
3/home/case/.emacs.d/.etc/straight/build
4/home/case/.emacs.d/.etc/straight/repos/org
5/home/case
6/home/case/.emacs.d
7~/.emacs.d
8/home/case/Sync/Click Here Digital
9/home/case/Sync
10/home/case
11/home/case/.emacs.d
diff --git a/init.el b/init.el index a938db0..4eb8cdd 100644 --- a/init.el +++ b/init.el
@@ -153,9 +153,11 @@
153 #'browse-url-default-browser) 153 #'browse-url-default-browser)
154 browse-url-new-window-flag nil 154 browse-url-new-window-flag nil
155 browse-url-firefox-arguments '("--new-tab") 155 browse-url-firefox-arguments '("--new-tab")
156 browse-url-firefox-new-window-is-tab t 156 browse-url-firefox-new-window-is-tab t)
157 ;; TODO: Add variables for other transformations and what-not. 157 (defvar +invidious-host
158 +invidious-host "invidious.snopyta.org") 158 ;; TODO: Add variables for other transformations and what-not.
159 "invidious.snopyta.org"
160 "Host for invidious instance.")
159 ;; Set up external browsing URLs. 161 ;; Set up external browsing URLs.
160 (add-to-list '+custom-variable-allowlist 162 (add-to-list '+custom-variable-allowlist
161 '+browse-url-secondary-browser-regexps) 163 '+browse-url-secondary-browser-regexps)
@@ -182,7 +184,7 @@
182 (t #'eww-browse-url)) 184 (t #'eww-browse-url))
183 args))) 185 args)))
184 (cons (rx (or ;; videos 186 (cons (rx (or ;; videos
185 "youtube.com" "youtu.be" (eval +invidious-host) "invidious" 187 "youtube.com" "youtu.be" "invidious" "yewtu.be"
186 (seq "." (or "mp4" "gif" "mov" "MOV" "webm") eos) 188 (seq "." (or "mp4" "gif" "mov" "MOV" "webm") eos)
187 ;; music 189 ;; music
188 "soundcloud.com" "bandcamp.com" 190 "soundcloud.com" "bandcamp.com"
@@ -281,12 +283,17 @@
281 (advice-add #'eval-region :around #'+eval-region@pulse)) 283 (advice-add #'eval-region :around #'+eval-region@pulse))
282 284
283(setup eshell 285(setup eshell
284 (:also-load +eshell 286 (:also-load em-smart
285 em-smart
286 em-tramp) 287 em-tramp)
287 (:option eshell-aliases-file (.etc "eshell/aliases" t) 288 (:require +eshell)
289 (+define-dir eshell/ (locate-user-emacs-file "eshell")
290 "Where to place Eshell-specific files.")
291 (:option eshell-aliases-file (eshell/ "aliases")
292 ;; What are these for???
293 eshell-rc-script (eshell/ "profile")
294 eshell-login-script (eshell/ "login")
288 eshell-destroy-buffer-when-process-dies t 295 eshell-destroy-buffer-when-process-dies t
289 eshell-directory-name (.etc "eshell/" t) 296 eshell-directory-name eshell/
290 eshell-error-if-no-glob t 297 eshell-error-if-no-glob t
291 eshell-hist-ignore-dups t 298 eshell-hist-ignore-dups t
292 eshell-kill-on-exit nil 299 eshell-kill-on-exit nil
@@ -298,9 +305,13 @@
298 eshell-smart-space-goes-to-end t 305 eshell-smart-space-goes-to-end t
299 eshell-where-to-jump 'begin 306 eshell-where-to-jump 'begin
300 eshell-banner-message "") 307 eshell-banner-message "")
301 (setf (alist-get 'eshell-mode mwim-beginning-of-line-function) 308 (with-eval-after-load 'mwim
302 #'eshell-bol) 309 (setf (alist-get 'eshell-mode mwim-beginning-of-line-function)
310 #'eshell-bol))
303 (+eshell-eval-after-load 311 (+eshell-eval-after-load
312 ;; Local modes
313 (dolist (mode '((hungry-delete-mode . -1)))
314 (funcall (car mode) (cdr mode)))
304 ;; Set local settings 315 ;; Set local settings
305 (dolist (setting (list (cons 'outline-regexp eshell-prompt-regexp) 316 (dolist (setting (list (cons 'outline-regexp eshell-prompt-regexp)
306 (cons 'page-delimiter eshell-prompt-regexp) 317 (cons 'page-delimiter eshell-prompt-regexp)
@@ -523,10 +534,11 @@
523 org-agenda-file-regexp 534 org-agenda-file-regexp
524 org-agenda-templates)) 535 org-agenda-templates))
525 (add-to-list '+custom-variable-allowlist var)) 536 (add-to-list '+custom-variable-allowlist var))
526 (defvar org-agenda-files nil) 537 (with-eval-after-load 'org
527 (add-to-list 'org-agenda-files (sync/ "org/" t)) 538 (add-to-list 'org-agenda-files (sync/ "org/" t)))
528 (:+leader "a" #'org-agenda "C-a" #'org-agenda) 539 (:+leader "a" #'org-agenda "C-a" #'org-agenda)
529 (:hook #'hl-line-mode)) 540 (:hook #'hl-line-mode)
541 (add-hook 'org-agenda-after-show-hook 'org-narrow-to-subtree))
530 542
531(setup org-capture 543(setup org-capture
532 (:require +org-capture) 544 (:require +org-capture)
@@ -609,7 +621,8 @@
609 (:hook #'turn-on-auto-fill)) 621 (:hook #'turn-on-auto-fill))
610 622
611(setup time 623(setup time
612 (:option display-time-format "%H:%M" 624 ;; TODO: +display-time-mode with MOAR customizations
625 (:option display-time-format "%H:%M %a %e"
613 display-time-default-load-average nil 626 display-time-default-load-average nil
614 display-time-mail-file :disable) 627 display-time-mail-file :disable)
615 (display-time-mode +1)) 628 (display-time-mode +1))
@@ -1086,7 +1099,7 @@ See also `crux-reopen-as-root-mode'."
1086 (eshell-vterm-mode +1)) 1099 (eshell-vterm-mode +1))
1087 1100
1088(setup (:straight-when exec-path-from-shell 1101(setup (:straight-when exec-path-from-shell
1089 (eq system-system 'linux)) 1102 (eq system-type 'gnu/linux))
1090 (require 'exec-path-from-shell) 1103 (require 'exec-path-from-shell)
1091 (dolist (var '("SSH_AUTH_SOCK" 1104 (dolist (var '("SSH_AUTH_SOCK"
1092 "SSH_AGENT_PID" 1105 "SSH_AGENT_PID"
@@ -1129,7 +1142,7 @@ See also `crux-reopen-as-root-mode'."
1129 1142
1130(setup (:straight-when (forge 1143(setup (:straight-when (forge
1131 :host github :repo "magit/forge") 1144 :host github :repo "magit/forge")
1132 (eq system-system 'linux)) 1145 (eq system-type 'gnu/linux))
1133 (require 'forge) 1146 (require 'forge)
1134 (add-to-list 'forge-alist 1147 (add-to-list 'forge-alist
1135 '("tildegit.org" "tildegit.org/api/v1" "tildegit.org" 1148 '("tildegit.org" "tildegit.org/api/v1" "tildegit.org"
@@ -1284,6 +1297,7 @@ See also `crux-reopen-as-root-mode'."
1284 (minions-mode +1)) 1297 (minions-mode +1))
1285 1298
1286(setup (:straight (mode-line-bell 1299(setup (:straight (mode-line-bell
1300 :host github :repo "purcell/mode-line-bell"
1287 :fork (:host github :repo "duckwork/mode-line-bell"))) 1301 :fork (:host github :repo "duckwork/mode-line-bell")))
1288 (:option mode-line-bell-flash-time 0.1) 1302 (:option mode-line-bell-flash-time 0.1)
1289 (mode-line-bell-mode +1)) 1303 (mode-line-bell-mode +1))
@@ -1388,6 +1402,7 @@ See also `crux-reopen-as-root-mode'."
1388(setup (:straight sicp)) 1402(setup (:straight sicp))
1389 1403
1390(setup (:straight (simple-modeline 1404(setup (:straight (simple-modeline
1405 :host github :repo "gexplorer/simple-modeline"
1391 :fork (:host github :repo "duckwork/simple-modeline"))) 1406 :fork (:host github :repo "duckwork/simple-modeline")))
1392 (:require +modeline) 1407 (:require +modeline)
1393 (:option +modeline-minions-icon ";" 1408 (:option +modeline-minions-icon ";"
@@ -1637,9 +1652,10 @@ See also `crux-reopen-as-root-mode'."
1637 (:global "M-z" #'+zzz-to-char)) 1652 (:global "M-z" #'+zzz-to-char))
1638 1653
1639(setup (:straight (ytdious 1654(setup (:straight (ytdious
1655 :host github :repo "spiderbit/ytdious"
1640 :fork (:host github :repo "duckwork/ytdious"))) 1656 :fork (:host github :repo "duckwork/ytdious")))
1641 (:also-load +ytdious) 1657 (:also-load +ytdious)
1642 (:option ytdious-invidious-api-url (if +invidious-host 1658 (:option ytdious-invidious-api-url (if +invidious-host
1643 (concat "https://" invidious-host) 1659 (concat "https://" +invidious-host)
1644 "https://invidious.snopyta.org")) 1660 "https://invidious.snopyta.org"))
1645 (:bind "y" #'+ytdious-watch)) 1661 (:bind "y" #'+ytdious-watch))
diff --git a/lisp/+lisp.el b/lisp/+lisp.el index c45fdf6..a78e40e 100644 --- a/lisp/+lisp.el +++ b/lisp/+lisp.el
@@ -157,6 +157,8 @@ With a prefix argument N, (un)comment that many sexps."
157 (+lisp-comment-sexp--raw)))) 157 (+lisp-comment-sexp--raw))))
158 158
159;;; Sort `setq' constructs 159;;; Sort `setq' constructs
160;;https://emacs.stackexchange.com/questions/33039/
161
160(defun +lisp-sort-setq () 162(defun +lisp-sort-setq ()
161 (interactive) 163 (interactive)
162 (save-excursion 164 (save-excursion
diff --git a/lisp/+org.el b/lisp/+org.el index 95a3da2..348ba6e 100644 --- a/lisp/+org.el +++ b/lisp/+org.el
@@ -420,8 +420,7 @@ the deletion might narrow the column."
420 "Open thing at point, or if there isn't something, list things." 420 "Open thing at point, or if there isn't something, list things."
421 (interactive "P") 421 (interactive "P")
422 (save-excursion 422 (save-excursion
423 (let* ((browse-url-browser-function #'browse-url-default-browser) 423 (let* ((this-char-type (org-element-type (org-element-context)))
424 (this-char-type (org-element-type (org-element-context)))
425 (prev-char-type (ignore-errors 424 (prev-char-type (ignore-errors
426 (save-excursion 425 (save-excursion
427 (backward-char) 426 (backward-char)
diff --git a/lisp/+vterm.el b/lisp/+vterm.el index 66e226b..06c0028 100644 --- a/lisp/+vterm.el +++ b/lisp/+vterm.el
@@ -4,7 +4,7 @@
4 4
5;;; Code: 5;;; Code:
6 6
7(require +vterm) 7(require 'vterm)
8 8
9(defun +vterm-counsel-yank-pop-action (orig-fun &rest args) 9(defun +vterm-counsel-yank-pop-action (orig-fun &rest args)
10 (if (equal major-mode 'vterm-mode) 10 (if (equal major-mode 'vterm-mode)
diff --git a/lisp/acdw.el b/lisp/acdw.el index 7cad67c..17741ab 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el
@@ -114,13 +114,19 @@ If Emacs is already started, run FUNCTION. Otherwise, add it to
114 (funcall function) 114 (funcall function)
115 (add-hook 'after-init-hook function))) 115 (add-hook 'after-init-hook function)))
116 116
117(defmacro +with-ensure-after-init (&rest body)
118 "Ensure BODY forms run after init.
119Convenience macro wrapper around `+ensure-after-init'."
120 (declare (indent 0) (debug (def-body)))
121 `(+ensure-after-init (lambda () ,@body)))
122
117(defun +remember-prefix-arg (p-arg P-arg) 123(defun +remember-prefix-arg (p-arg P-arg)
118 "Display prefix ARG, in \"p\" and \"P\" `interactive' types. 124 "Display prefix ARG, in \"p\" and \"P\" `interactive' types.
119I keep forgetting how they differ." 125I keep forgetting how they differ."
120 (interactive "p\nP") 126 (interactive "p\nP")
121 (message "p: %S P: %S" p-arg P-arg)) 127 (message "p: %S P: %S" p-arg P-arg))
122 128
123(defmacro +defvar (var value &optional _) 129(defmacro +defvar (var value &rest _)
124 "Quick way to `setq' a variable from a `defvar' form." 130 "Quick way to `setq' a variable from a `defvar' form."
125 (declare (doc-string 3)) 131 (declare (doc-string 3))
126 `(setq ,var ,value)) 132 `(setq ,var ,value))
@@ -133,7 +139,7 @@ If body executes without errors, MESSAGE...Done will be displayed."
133 `(let ((,msg ,message)) 139 `(let ((,msg ,message))
134 (unwind-protect (progn (message "%s..." ,msg) 140 (unwind-protect (progn (message "%s..." ,msg)
135 ,@body) 141 ,@body)
136 (message "%s... Done." ,msg))))) 142 (message "%s...done" ,msg)))))
137 143
138(defun +mapc-some-buffers (func &optional predicate) 144(defun +mapc-some-buffers (func &optional predicate)
139 "Perform FUNC on all buffers satisfied by PREDICATE. 145 "Perform FUNC on all buffers satisfied by PREDICATE.
@@ -171,7 +177,8 @@ active, or else the entire buffer."
171 (replace-match "\n\n")) 177 (replace-match "\n\n"))
172 ;; Insert a newline at the end. 178 ;; Insert a newline at the end.
173 (goto-char (point-max)) 179 (goto-char (point-max))
174 (unless (= (line-beginning-position) (line-end-position)) 180 (unless (or (buffer-narrowed-p)
181 (= (line-beginning-position) (line-end-position)))
175 (insert "\n"))))) 182 (insert "\n")))))
176 183
177(defun +open-paragraph () 184(defun +open-paragraph ()
diff --git a/lisp/system.el b/lisp/system.el index 7fe39f1..0c1e457 100644 --- a/lisp/system.el +++ b/lisp/system.el
@@ -1,9 +1,9 @@
1;;; system.el --- System-specific configuration -*- lexical-binding: t; -*- 1;;; system.el --- Load system-dependendant settings -*- lexical-binding: t; -*-
2 2
3;;; Commentary: 3;;; Commentary:
4 4
5;; When using Emacs on separate computers, some variables need different 5;; When using Emacs on multiple computers, some variables and functions need
6;; settings. This library contains functions and variables to work with 6;; different definitions. This library is built to assist in working with
7;; different system configurations for Emacs. 7;; different system configurations for Emacs.
8 8
9;;; Code: 9;;; Code:
@@ -15,145 +15,161 @@
15 :group 'emacs 15 :group 'emacs
16 :prefix "system-") 16 :prefix "system-")
17 17
18;;; Variables 18;;; Settings
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 19
27This list need not be exhaustive; see `system-settings-load' for 20(defcustom system-load-directory (locate-user-emacs-file "systems"
28more details on what happens if this alist is exhausted." 21 "~/.emacs-systems")
29 :type '(alist :key-type function :value-type (choice string symbol))) 22 "The directory where system-specific configurations live."
30
31(defcustom system-load-directory (locate-user-emacs-file "systems")
32 "The directory from which to load system-specific configurations."
33 :type 'file) 23 :type 'file)
34 24
35;; `defcustoms' defined here are best-guess defaults. 25;; These `defcustom's are best-guess defaults.
36 26
37(defcustom system-default-font (pcase system-type 27(defcustom system-default-font (cond
38 ((or 'ms-dos 'windows-nt) 28 ((memq system-type '(ms-dos windows-nt))
39 "Consolas") 29 "Consolas")
40 (_ "monospace")) 30 (t "monospace"))
41 "The font used for the `default' face." 31 "The font used for the `default' face.
32Set this in your system files."
42 :type 'string) 33 :type 'string)
43 34
44(defcustom system-default-height 100 35(defcustom system-default-height 100
45 "The height used for the `default' face." 36 "The height used for the `default' face.
37Set this in your system files."
46 :type 'number) 38 :type 'number)
47 39
48(defcustom system-variable-pitch-font (pcase system-type 40(defcustom system-variable-pitch-font (cond
49 ((or 'ms-dos 'windows-nt) 41 ((memq system-type '(ms-dos windows-nt))
50 "Arial") 42 "Arial")
51 (_ "sans-serif")) 43 (t "sans-serif"))
52 "The font used for the `variable-pitch' face." 44 "The font used for the `variable-pitch' face.
45Set this in your system files."
53 :type 'string) 46 :type 'string)
54 47
55(defcustom system-variable-pitch-height 1.0 48(defcustom system-variable-pitch-height 1.0
56 "The height used for the `variable-pitch' face. 49 "The height used for the `variable-pitch' face.
57A floating-point number is recommended, since that makes it 50A floating-point number is recommended, since that makes it
58relative to the `default' face height." 51relative to the `default' face height.
52
53Set this in your system files."
59 :type 'number) 54 :type 'number)
60 55
56(defcustom system-files-order '(:type :name :user)
57 "The order to load `system-files' in.
58The elements of this list correspond to the keys in
59`system-system'."
60 :type '(list (const :tag "System type" :type)
61 (const :tag "System name" :name)
62 (const :tag "Current user" :user)))
63
64;;; Variables
65
61(defvar system-system nil 66(defvar system-system nil
62 "The current system's symbol. 67 "Plist of systems that Emacs is in.
63Do not edit this by hand. Instead, call `system-get-system'.") 68The keys are as follows:
64 69
65(defvar system-file nil 70- :name - `system-name'
66 "The current system's file for system-specific configuration. 71- :type - `system-type'
67Do not edit this by hand. Instead, call `system-get-system-file'.") 72- :user - `user-login-name'
68 73
69;;; Functions 74Each value is made safe to be a file name by passing through
75`system--safe'.
76
77Do not edit this by hand. Instead, call `system-get-systems'.")
70 78
71;; Convenience functions for systems 79(defvar system-files nil
72(defun system-microsoft-p () 80 "List of files to load for system-specific configuration.
73 "Return non-nil if running in a Microsoft system." 81Do not edit this by hand. Instead, call `system-get-system-files'.")
74 (memq system-type '(ms-dos windows-nt)))
75 82
76(defun system-linux-p () 83
77 "Return non-nil if running on a Linux system." 84;;; Functions
78 (memq system-type '(gnu/linux)))
79 85
80(defun system-warn (message &rest args) 86(defun system--warn (message &rest args)
81 "Display a wraning message made from (format-message MESSAGE ARGS...). 87 "Display a system-file warning message.
82This function is like `warn', except it uses the `system' type." 88This function is like `warn', except it uses a `system' type."
83 (display-warning 'system (apply #'format-message message args))) 89 (display-warning 'system (apply #'format-message message args)))
84 90
85(defun system-get-system () 91(defun system--safe (str)
86 "Determine the current system." 92 "Make STR safe for a file name."
87 (cl-loop for (p . s) in system-load-alist 93 (let ((bad-char-regexp ))
88 if (with-demoted-errors (format "Problem running function `%s'" p) 94 (downcase (string-trim
89 (funcall p)) 95 (replace-regexp-in-string "[#%&{}\$!'\":@<>*?/ \r\n\t+`|=]+"
90 return (setq system-system s))) 96 "-" str)
91 97 "-" "-"))))
92(defun system-get-system-file (&optional system refresh-cache set-system-file-p) 98
93 "Determine the current system's system-specific file. 99(defun system-get-systems ()
94The current system's file will be returned. The value of 100 "Determine the current system(s).
95`system-file' is set, /unless/ the parameter SYSTEM was passed to 101This system updates `system-system', which see."
96this function and SET-SYSTEM-FILE-P is nil. If both SYSTEM and 102 ;; Add system-name
97SET-SYSTEM-FILE-P are non-nil, this function will still set 103 (setf (plist-get system-system :name)
98`system-file'. 104 (intern (system--safe (system-name))))
99 105 ;; Add system-type
100If SYSTEM is not passed, and `system-file' is set, simply return 106 (setf (plist-get system-system :type)
101its value /unless/ REFRESH-CACHE is non-nil, in which case 107 (intern (system--safe (symbol-name system-type))))
102`system-load-alist' will be looped through to find the 108 ;; Add current user
103appropriate system by testing the car of each cell there. When 109 (setf (plist-get system-system :user)
104one matches, use the cdr of that cell as SYSTEM. If none 110 ;; Use `user-real-login-name' in case Emacs gets called under su.
105matches, return nil. 111 (intern (system--safe (user-real-login-name))))
106 112 system-system)
107This function will only look for system-specific files in 113
108`system-load-directory'." 114(defun system-get-files ()
109 (let* ((system* (or system 115 "Determine the current systems' load-files.
110 (and system-file (not refresh-cache)) 116The system load-files should live in `system-load-directory', and
111 (system-get-system))) 117named using either the raw name given by the values of
112 (file (expand-file-name (format "%s" system*) system-load-directory))) 118`system-system', or that name prepended with the type, e.g.,
113 (when (or (not system) 119\"name-bob.el\", for a system named \"bob\".
114 (and system set-system-file-p)) 120
115 (setq system-file file)) 121The second form of file-name is to work around name collisions,
116 file)) 122e.g. if a there's a user named \"bob\" and a system named
123\"bob\".
124
125This function updates `system-files'."
126 ;; Get systems
127 (system-get-systems)
128 ;; Re-set `system-files'
129 (setq system-files nil)
130
131 (let (ret)
132 (dolist (key (reverse system-files-order))
133 (let* ((val (plist-get system-system key))
134 (key-val (intern (system--safe (format "%s-%s" key val)))))
135 (push (list key-val val) ret)))
136
137 ;; Update `system-files'.
138 (setq system-files ret)))
117 139
118;;;###autoload 140;;;###autoload
119(defun system-settings-load (&optional system error nomessage) 141(defun system-settings-load (&optional error nomessage)
120 "Load system settings. 142 "Load system settings from `system-files'.
121Load settings from `system-file', or the `system-file' as 143Each list in `system-files' will be considered item-by-item; the
122determined by SYSTEM, if passed. See `system-get-system-file' for 144first found file in each will be loaded.
123details on how the `system-file' is determined.
124 145
125ERROR determines how to deal with errors: if nil, warn the user 146ERROR determines how to deal with errors: if nil, warn the user
126when `system-file' can't be found or when the system being used 147when no system-files can be found or when the system being used
127can't be determined. If t, those are elevated to errors. If any 148cannot be determined. If t, these warnings are elevated to
128other value, the errors are completely ignored. 149errors. Any other value ignores the warnings completely.
129 150
130NOMESSAGE is passed directly to `load'." 151NOMESSAGE is passed directly to `load'."
131 (let ((file (system-get-system-file system))) 152 (system-get-files)
132 (if file 153 (if system-files
133 (condition-case e 154 (let (files-loaded)
134 (load file nil nomessage) 155 (dolist (ss system-files)
135 (t (cond ((eq error t) (signal (car e) (cdr e))) 156 (catch :done
136 ((null error) (system-warn "Couldn't find file `%s'." 157 (dolist (s ss)
137 file))))) 158 (let ((fn (expand-file-name (format "%s" s)
138 (funcall (cond ((eq error t) #'error) 159 system-load-directory)))
139 ((null error) #'system-warn) 160 (when (load fn t nomessage)
140 (t #'ignore)) 161 (push fn files-loaded)
141 "Could not determine the system being used.")))) 162 (throw :done nil))))))
142 163 (unless files-loaded
143;;;###autoload 164 (cond ((eq error t) (error "Error loading system-files.")
144(defun system-find-system-file (&optional system) 165 (null error) (system--warn "Couldn't load system-files."))))
145 "Find the current system's system-file." 166 files-loaded)
146 (interactive (list (completing-read "System file: " 167 (funcall (cond ((eq error t) #'error)
147 (mapcar (lambda (a) (format "%s" (cdr a))) 168 ((null error) #'system--warn)
148 system-load-alist) 169 (t #'ignore))
149 nil t nil nil 170 "Couldn't determine the system being used.")))
150 (format "%s" (system-get-system)))))
151 (find-file (cl-loop with file = (system-get-system-file system)
152 for cand in (list file
153 (concat file ".el"))
154 if (file-exists-p cand)
155 return cand
156 finally return cand)))
157 171
158(provide 'system) 172(provide 'system)
159;;; system.el ends here 173;;; system.el ends here
174
175
diff --git a/systems/bob.el b/systems/bob.el new file mode 100644 index 0000000..427f38a --- /dev/null +++ b/systems/bob.el
@@ -0,0 +1,10 @@
1;;; bob.el --- Customizations for "bob" -*- lexical-binding: t; -*-
2
3;;; Commentary:
4
5;;; Code:
6
7(setq system-default-font "DejaVu Sans Mono"
8 system-default-height 105)
9
10;;; bob.el ends here
diff --git a/systems/gnu-linux.el b/systems/gnu-linux.el new file mode 100644 index 0000000..333f15a --- /dev/null +++ b/systems/gnu-linux.el
@@ -0,0 +1,5 @@
1;;; linux.el -*- lexical-binding: t; -*-
2
3(setq system-default-height 105)
4
5;;; linux.el ends here
diff --git a/systems/windows-nt.el b/systems/windows-nt.el new file mode 100644 index 0000000..3a0deee --- /dev/null +++ b/systems/windows-nt.el
@@ -0,0 +1,23 @@
1;;; windows.el --- Windows settings! -*- lexical-binding: t; -*-
2
3;; Annoying gnu-tls bug; I "always" trust the certificate anyway, so let's be
4;; insecure.
5(setq network-security-level 'low
6 debug-on-error t)
7
8;; Fonts
9
10(setq system-default-font "Cascadia Mono"
11 system-default-height 90
12 system-variable-pitch-font "Carlito"
13 system-variable-pitch-height 1.2)
14
15;; Add C:\Program Files\* and C:\Program Files (x86)\* to exec-path
16(dolist (path (append (file-expand-wildcards "C:/Program Files/*")
17 (file-expand-wildcards "c:/Program Files (x86)/*")
18 ;; Others...
19 (save-match-data
20 (split-string (getenv "PATH") ";" t))))
21 (add-to-list 'exec-path path :append))
22
23;;; windows.el ends here