about summary refs log tree commit diff stats
path: root/lisp
diff options
context:
space:
mode:
authorCase Duckworth2023-01-08 18:19:04 -0600
committerCase Duckworth2023-01-08 18:19:04 -0600
commit107eab7ef6311a5b5f9c85c179ae83b2e3204094 (patch)
tree08502e554b3a0cf70b6a4f7aa570aecf479d0229 /lisp
parentRestart ... again ... again (diff)
downloademacs-107eab7ef6311a5b5f9c85c179ae83b2e3204094.tar.gz
emacs-107eab7ef6311a5b5f9c85c179ae83b2e3204094.zip
myeahhhhhh
Diffstat (limited to 'lisp')
-rw-r--r--lisp/acdw.el39
1 files changed, 39 insertions, 0 deletions
diff --git a/lisp/acdw.el b/lisp/acdw.el new file mode 100644 index 0000000..f16a679 --- /dev/null +++ b/lisp/acdw.el
@@ -0,0 +1,39 @@
1;;; acdw.el --- My Emacs extras -*- lexical-binding: t; -*-
2
3;;; Code:
4
5(defmacro defdir (name directory &optional docstring makedir)
6 "Define a variable and a function NAME expanding to DIRECTORY.
7DOCSTRING is applied to the variable; its default is DIRECTORY's
8path. If MAKEDIR is non-nil, the directory and its parents will
9be created."
10 (declare (indent 2) (doc-string 3))
11 `(progn
12 (defvar ,name (expand-file-name ,directory)
13 ,(concat (or docstring (format "%s" directory)) "\n"
14 "Defined by `defdir'."))
15 (defun ,name (file &optional mkdir)
16 ,(concat "Expand FILE relative to variable `" (symbol-name name) "'.\n"
17 "If MKDIR is non-nil, parent directories are created.\n"
18 "Defined by `defdir'.")
19 (let ((file-name (expand-file-name
20 (convert-standard-filename file) ,name)))
21 (when mkdir
22 (make-directory (file-name-directory file-name) :parents))
23 file-name))
24 ,(if makedir
25 `(make-directory ,directory :parents)
26 `(unless (file-exists-p ,directory)
27 (warn "Directory `%s' doesn't exist." ,directory)))))
28
29(defun choose-executable (&rest programs)
30 "Return the first of PROGRAMS that exists in the system's $PATH.
31Each of PROGRAMS can be a single string, or a list. If it's a list then its car
32will be tested with `executable-find', and the entire list returned. This
33enables passing arguments to a calling function."
34 (seq-find (lambda (x)
35 (executable-find (car (ensure-list x))))
36 programs))
37
38(provide 'acdw)
39;;; acdw.el ends here