about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--early-init.el2
-rw-r--r--lisp/system.el88
2 files changed, 65 insertions, 25 deletions
diff --git a/early-init.el b/early-init.el index 1917779..17b3844 100644 --- a/early-init.el +++ b/early-init.el
@@ -54,6 +54,8 @@ See `no-littering' for examples.")
54 54
55;; Load system-specific changes. 55;; Load system-specific changes.
56(progn (require 'system) 56(progn (require 'system)
57 (setq system-default-font "DejaVu Sans Mono"
58 system-variable-pitch-font "DejaVu Sans")
57 (setq system-load-directory (sync/ "emacs/systems/" t)) 59 (setq system-load-directory (sync/ "emacs/systems/" t))
58 (system-settings-load nil :nowarn)) 60 (system-settings-load nil :nowarn))
59 61
diff --git a/lisp/system.el b/lisp/system.el index 9bb057c..f2e85a1 100644 --- a/lisp/system.el +++ b/lisp/system.el
@@ -58,6 +58,10 @@ A floating-point number is recommended, since that makes it
58relative to the `default' face height." 58relative to the `default' face height."
59 :type 'number) 59 :type 'number)
60 60
61(defvar system-file nil
62 "The current system's file for system-specific configuration.
63Do not edit this by hand. Instead, call `system-system-file'.")
64
61;;; Functions 65;;; Functions
62 66
63;; Convenience functions for systems 67;; Convenience functions for systems
@@ -74,40 +78,74 @@ relative to the `default' face height."
74This function is like `warn', except it uses the `system' type." 78This function is like `warn', except it uses the `system' type."
75 (display-warning 'system (apply #'format-message message args))) 79 (display-warning 'system (apply #'format-message message args)))
76 80
81(defun system-system-file (&optional system refresh-cache set-system-file-p)
82 "Determine the current system's system-specific file.
83The current system's file will be returned, and the value of
84`system-file' set /unless/ the parameter SYSTEM was passed to
85this function and SET-SYSTEM-FILE-P is nil. If both SYSTEM and
86SET-SYSTEM-FILE-P are non-nil, this function will still set
87`system-file'.
88
89If SYSTEM is not passed, and `system-file' is set, simply return
90its value /unless/ REFRESH-CACHE is non-nil, in which case
91`system-load-alist' will be looped through to find the
92appropriate system by testing the car of each cell there. When
93one matches, use the cdr of that cell as SYSTEM. If none
94matches, return nil.
95
96This function will only look for system-specific files in
97`system-load-directory'."
98 (let* ((system* (or system
99 (and system-file (not refresh-cache))
100 (cl-loop for (p . s) in system-load-alist
101 if (funcall p) return s)))
102 (file (expand-file-name (format "%s" system*) system-load-directory)))
103 (when (or (not system)
104 (and system set-system-file-p))
105 (setq system-file file))
106 file))
107
77;;;###autoload 108;;;###autoload
78(defun system-settings-load (&optional system error nomessage) 109(defun system-settings-load (&optional system error nomessage)
79 "Load system settings. 110 "Load system settings.
80If optional SYSTEM (a symbol or a string) is not provided, loop 111Load settings from `system-file', or the `system-file' as
81through `system-load-alist', testing the car of each cell there. 112determined by SYSTEM, if passed. See `system-system-file' for
82When one matches, use the cdr of that cell as SYSTEM. Either 113details on how the `system-file' is determined.
83way, look in `system-load-directory' for the files to load. 114
84 115ERROR determines how to deal with errors: if nil, warn the user
85If none match, warn the user. 116when `system-file' can't be found or when the system being used
86 117can't be determined. If t, those are elevated to errors. If any
87Optional argument ERROR is similar to in `load', but negated: if 118other value, the errors are completely ignored.
88t, it will generate an error; if nil, it will warn the user; 119
89otherwise, if ERROR is anything else, it will be completely 120NOMESSAGE is passed directly to `load'."
90silent. 121 (let ((file (system-system-file system)))
91 122 (if file
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 123 (condition-case e
99 (load (expand-file-name (format "%s" system) system-load-directory) 124 (load file nil nomessage)
100 nil nomessage)
101 (t (cond ((eq error t) (signal (car e) (cdr e))) 125 (t (cond ((eq error t) (signal (car e) (cdr e)))
102 ((null error) (system-warn 126 ((null error) (system-warn "Couldn't find file `%s'."
103 (concat 127 file)))))
104 "Couldn't find file `%s' to load"
105 " (Looked in %s).")
106 system system-load-directory)))))
107 (funcall (cond ((eq error t) #'error) 128 (funcall (cond ((eq error t) #'error)
108 ((null error) #'system-warn) 129 ((null error) #'system-warn)
109 (t #'ignore)) 130 (t #'ignore))
110 "Could not determine the system being used.")))) 131 "Could not determine the system being used."))))
111 132
133;;;###autoload
134(defun system-find-system-file (&optional system)
135 "Find the current system's system-file."
136 (interactive (list (completing-read "System file: "
137 (mapcar (lambda (a) (format "%s" (cdr a)))
138 system-load-alist)
139 nil t nil nil
140 (cl-loop for (p . s) in system-load-alist
141 if (funcall p)
142 return (format "%s" s)))))
143 (find-file (cl-loop with file = (system-system-file system)
144 for cand in (list file
145 (concat file ".el"))
146 if (file-exists-p cand)
147 return cand
148 finally return cand)))
149
112(provide 'system) 150(provide 'system)
113;;; system.el ends here 151;;; system.el ends here