diff options
author | Case Duckworth | 2022-01-04 21:09:53 -0600 |
---|---|---|
committer | Case Duckworth | 2022-01-04 21:09:53 -0600 |
commit | 7a1ff0c1bcc76a5eaed2c3bc4ad613bb74f9ee74 (patch) | |
tree | 6a1a4e7c62f9cf66a48b4dbf326057fac4ce494a /lisp | |
parent | Skip word forward (diff) | |
download | emacs-7a1ff0c1bcc76a5eaed2c3bc4ad613bb74f9ee74.tar.gz emacs-7a1ff0c1bcc76a5eaed2c3bc4ad613bb74f9ee74.zip |
Add a function and variable system-system
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/system.el | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/lisp/system.el b/lisp/system.el index f2e85a1..7fe39f1 100644 --- a/lisp/system.el +++ b/lisp/system.el | |||
@@ -58,9 +58,13 @@ A floating-point number is recommended, since that makes it | |||
58 | relative to the `default' face height." | 58 | relative to the `default' face height." |
59 | :type 'number) | 59 | :type 'number) |
60 | 60 | ||
61 | (defvar system-system nil | ||
62 | "The current system's symbol. | ||
63 | Do not edit this by hand. Instead, call `system-get-system'.") | ||
64 | |||
61 | (defvar system-file nil | 65 | (defvar system-file nil |
62 | "The current system's file for system-specific configuration. | 66 | "The current system's file for system-specific configuration. |
63 | Do not edit this by hand. Instead, call `system-system-file'.") | 67 | Do not edit this by hand. Instead, call `system-get-system-file'.") |
64 | 68 | ||
65 | ;;; Functions | 69 | ;;; Functions |
66 | 70 | ||
@@ -78,10 +82,17 @@ Do not edit this by hand. Instead, call `system-system-file'.") | |||
78 | This function is like `warn', except it uses the `system' type." | 82 | This function is like `warn', except it uses the `system' type." |
79 | (display-warning 'system (apply #'format-message message args))) | 83 | (display-warning 'system (apply #'format-message message args))) |
80 | 84 | ||
81 | (defun system-system-file (&optional system refresh-cache set-system-file-p) | 85 | (defun system-get-system () |
86 | "Determine the current system." | ||
87 | (cl-loop for (p . s) in system-load-alist | ||
88 | if (with-demoted-errors (format "Problem running function `%s'" p) | ||
89 | (funcall p)) | ||
90 | return (setq system-system s))) | ||
91 | |||
92 | (defun system-get-system-file (&optional system refresh-cache set-system-file-p) | ||
82 | "Determine the current system's system-specific file. | 93 | "Determine the current system's system-specific file. |
83 | The current system's file will be returned, and the value of | 94 | The current system's file will be returned. The value of |
84 | `system-file' set /unless/ the parameter SYSTEM was passed to | 95 | `system-file' is set, /unless/ the parameter SYSTEM was passed to |
85 | this function and SET-SYSTEM-FILE-P is nil. If both SYSTEM and | 96 | this function and SET-SYSTEM-FILE-P is nil. If both SYSTEM and |
86 | SET-SYSTEM-FILE-P are non-nil, this function will still set | 97 | SET-SYSTEM-FILE-P are non-nil, this function will still set |
87 | `system-file'. | 98 | `system-file'. |
@@ -97,8 +108,7 @@ This function will only look for system-specific files in | |||
97 | `system-load-directory'." | 108 | `system-load-directory'." |
98 | (let* ((system* (or system | 109 | (let* ((system* (or system |
99 | (and system-file (not refresh-cache)) | 110 | (and system-file (not refresh-cache)) |
100 | (cl-loop for (p . s) in system-load-alist | 111 | (system-get-system))) |
101 | if (funcall p) return s))) | ||
102 | (file (expand-file-name (format "%s" system*) system-load-directory))) | 112 | (file (expand-file-name (format "%s" system*) system-load-directory))) |
103 | (when (or (not system) | 113 | (when (or (not system) |
104 | (and system set-system-file-p)) | 114 | (and system set-system-file-p)) |
@@ -109,7 +119,7 @@ This function will only look for system-specific files in | |||
109 | (defun system-settings-load (&optional system error nomessage) | 119 | (defun system-settings-load (&optional system error nomessage) |
110 | "Load system settings. | 120 | "Load system settings. |
111 | Load settings from `system-file', or the `system-file' as | 121 | Load settings from `system-file', or the `system-file' as |
112 | determined by SYSTEM, if passed. See `system-system-file' for | 122 | determined by SYSTEM, if passed. See `system-get-system-file' for |
113 | details on how the `system-file' is determined. | 123 | details on how the `system-file' is determined. |
114 | 124 | ||
115 | ERROR determines how to deal with errors: if nil, warn the user | 125 | ERROR determines how to deal with errors: if nil, warn the user |
@@ -118,7 +128,7 @@ can't be determined. If t, those are elevated to errors. If any | |||
118 | other value, the errors are completely ignored. | 128 | other value, the errors are completely ignored. |
119 | 129 | ||
120 | NOMESSAGE is passed directly to `load'." | 130 | NOMESSAGE is passed directly to `load'." |
121 | (let ((file (system-system-file system))) | 131 | (let ((file (system-get-system-file system))) |
122 | (if file | 132 | (if file |
123 | (condition-case e | 133 | (condition-case e |
124 | (load file nil nomessage) | 134 | (load file nil nomessage) |
@@ -137,10 +147,8 @@ NOMESSAGE is passed directly to `load'." | |||
137 | (mapcar (lambda (a) (format "%s" (cdr a))) | 147 | (mapcar (lambda (a) (format "%s" (cdr a))) |
138 | system-load-alist) | 148 | system-load-alist) |
139 | nil t nil nil | 149 | nil t nil nil |
140 | (cl-loop for (p . s) in system-load-alist | 150 | (format "%s" (system-get-system))))) |
141 | if (funcall p) | 151 | (find-file (cl-loop with file = (system-get-system-file system) |
142 | return (format "%s" s))))) | ||
143 | (find-file (cl-loop with file = (system-system-file system) | ||
144 | for cand in (list file | 152 | for cand in (list file |
145 | (concat file ".el")) | 153 | (concat file ".el")) |
146 | if (file-exists-p cand) | 154 | if (file-exists-p cand) |