about summary refs log tree commit diff stats
path: root/lisp/acdw.el
diff options
context:
space:
mode:
authorCase Duckworth2021-05-11 09:44:04 -0500
committerCase Duckworth2021-05-11 09:44:04 -0500
commitb727d4f684a2611351189e134b64fcef3661d9f8 (patch)
treea46633d53f0881e62611c87e91b0b9116a9467b3 /lisp/acdw.el
parentChange subscription method to use a file (diff)
downloademacs-b727d4f684a2611351189e134b64fcef3661d9f8.tar.gz
emacs-b727d4f684a2611351189e134b64fcef3661d9f8.zip
Add `acdw/system' macro
`acdw/system' eases configuration -- it returns the system when called with no
arguments, acts as a test with one argument, or as a `pcase' with more than one
argument.
Diffstat (limited to 'lisp/acdw.el')
-rw-r--r--lisp/acdw.el35
1 files changed, 26 insertions, 9 deletions
diff --git a/lisp/acdw.el b/lisp/acdw.el index a798069..a1c364d 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el
@@ -21,12 +21,29 @@
21 21
22;;; Variables 22;;; Variables
23 23
24(defconst acdw/system (pcase system-type 24(defconst acdw/system
25 ('gnu/linux :home) 25 (pcase system-type
26 ((or 'msdos 'windows-nt) :work) 26 ('gnu/linux :home)
27 (_ :other)) 27 ((or 'msdos 'windows-nt) :work)
28 (_ :other))
28 "Which computer system is currently being used.") 29 "Which computer system is currently being used.")
29 30
31(defmacro acdw/system (&rest arg)
32 "Convenience macro for interfacing with `acdw/system'.
33
34When called without arguments, it returns `acdw/system'.
35When called with one argument, it returns (eq acdw/system ARG).
36When called with multiple arguments, it returns `pcase' over each argument."
37 (cond
38 ((not arg) acdw/system)
39 ((not (cdr arg))
40 `(when (eq acdw/system ,(car arg))
41 ,(car arg)))
42 ((cdr arg)
43 `(pcase acdw/system
44 ,@arg))
45 (t (error "Wrong argument type: %s" (type-of arg)))))
46
30 47
31;;; Utility functions 48;;; Utility functions
32;; I don't prefix these because ... reasons. Honestly I probably should prefix 49;; I don't prefix these because ... reasons. Honestly I probably should prefix
@@ -162,11 +179,11 @@ if MAKE-DIRECTORY is non-nil."
162 179
163(defun acdw/find-emacs-source () 180(defun acdw/find-emacs-source ()
164 "Find where Emacs keeps its source tree." 181 "Find where Emacs keeps its source tree."
165 (pcase acdw/system 182 (acdw/system
166 (:work (expand-file-name 183 (:work (expand-file-name
167 (concat "~/src/emacs-" emacs-version "/src"))) 184 (concat "~/src/emacs-" emacs-version "/src")))
168 (:home (expand-file-name "~/src/pkg/emacs/src/emacs-git/src")) 185 (:home (expand-file-name "~/src/pkg/emacs/src/emacs-git/src"))
169 (:other nil))) 186 (:other nil)))
170 187
171(defun acdw/gc-disable () 188(defun acdw/gc-disable ()
172 "Functionally disable the Garbage collector." 189 "Functionally disable the Garbage collector."