Refactor doom-{path,file,dir,glob}
Breaking change: doom-glob would formerly return a string (if only one match) or a list. Now it always returns a list.
This commit is contained in:
parent
13f316e645
commit
a8e57438dc
6 changed files with 28 additions and 34 deletions
|
@ -36,12 +36,20 @@ This is used by `file-exists-p!' and `project-file-exists-p!'."
|
|||
`(file-exists-p ,filevar))
|
||||
,filevar)))))
|
||||
|
||||
(defun doom--path (&rest segments)
|
||||
(let ((segments (delq nil segments))
|
||||
;;;###autoload
|
||||
(defun doom-path (&rest segments)
|
||||
"Constructs a file path from SEGMENTS.
|
||||
Ignores `nil' elements in SEGMENTS."
|
||||
(let ((segments (remq nil segments))
|
||||
file-name-handler-alist
|
||||
dir)
|
||||
(while segments
|
||||
(setq dir (expand-file-name (car segments) dir)
|
||||
segments (cdr segments)))
|
||||
(setq segment (pop segments)
|
||||
dir (expand-file-name
|
||||
(if (listp segment)
|
||||
(apply #'doom-path dir segment)
|
||||
segment)
|
||||
dir)))
|
||||
dir))
|
||||
|
||||
;;;###autoload
|
||||
|
@ -49,28 +57,16 @@ This is used by `file-exists-p!' and `project-file-exists-p!'."
|
|||
"Construct a path from SEGMENTS and expand glob patterns.
|
||||
Returns nil if the path doesn't exist.
|
||||
Ignores `nil' elements in SEGMENTS."
|
||||
(let* (case-fold-search
|
||||
(dir (apply #'doom--path segments)))
|
||||
(if (string-match-p "[[*?]" dir)
|
||||
(file-expand-wildcards dir t)
|
||||
(if (file-exists-p dir)
|
||||
dir))))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom-path (&rest segments)
|
||||
"Constructs a file path from SEGMENTS.
|
||||
Ignores `nil' elements in SEGMENTS."
|
||||
(if segments
|
||||
(apply #'doom--path segments)
|
||||
(file!)))
|
||||
(let (case-fold-search)
|
||||
(file-expand-wildcards (apply #'doom-path segments) t)))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom-dir (&rest segments)
|
||||
"Constructs a path from SEGMENTS.
|
||||
See `doom-path'.
|
||||
Ignores `nil' elements in SEGMENTS."
|
||||
(when-let (path (apply #'doom-path segments))
|
||||
(directory-file-name (file-name-directory path))))
|
||||
(when-let (path (doom-path segments))
|
||||
(directory-file-name path)))
|
||||
|
||||
;;;###autoload
|
||||
(cl-defun doom-files-in
|
||||
|
|
|
@ -164,8 +164,8 @@ each package."
|
|||
(mapc (fn! ((cat . mod))
|
||||
(if-let (packages-file
|
||||
(pcase cat
|
||||
(:private (doom-glob doom-private-dir "packages.el"))
|
||||
(:core (doom-glob doom-core-dir "packages.el"))
|
||||
(:private (car (doom-glob doom-private-dir "packages.el")))
|
||||
(:core (car (doom-glob doom-core-dir "packages.el")))
|
||||
(_ (doom-module-locate-path cat mod "packages.el"))))
|
||||
(with-current-buffer
|
||||
(or (get-file-buffer packages-file)
|
||||
|
|
|
@ -52,7 +52,7 @@ one wants that.")
|
|||
in (append (list doom-core-dir)
|
||||
(cdr (doom-module-load-path 'all-p))
|
||||
(list doom-private-dir))
|
||||
if (doom-glob dir "autoload.el") collect it
|
||||
if (doom-glob dir "autoload.el") collect (car it)
|
||||
if (doom-glob dir "autoload/*.el") append it)
|
||||
(mapcan #'doom-glob doom-autoloads-files))
|
||||
nil)
|
||||
|
|
|
@ -16,11 +16,9 @@ and your private config files, respectively. To recompile your packages, use
|
|||
'doom build' instead."
|
||||
(doom-cli-byte-compile
|
||||
(if (or core-p private-p)
|
||||
(append (when core-p
|
||||
(list (doom-glob doom-emacs-dir "init.el")
|
||||
doom-core-dir))
|
||||
(when private-p
|
||||
(list doom-private-dir)))
|
||||
(append (if core-p (doom-glob doom-emacs-dir "init.el"))
|
||||
(if core-p (list doom-core-dir))
|
||||
(if private-p (list doom-private-dir)))
|
||||
(or (y-or-n-p
|
||||
(concat "WARNING: Changes made to your config after compiling it won't take effect until\n"
|
||||
"this command is rerun or you run 'doom clean'! It will also make error backtraces\n"
|
||||
|
@ -28,11 +26,11 @@ and your private config files, respectively. To recompile your packages, use
|
|||
"If you intend to use it anyway, remember this or it will come back to bite you!\n\n"
|
||||
"Continue anyway?"))
|
||||
(user-error "Aborted"))
|
||||
(append (list (doom-glob doom-emacs-dir "init.el")
|
||||
doom-core-dir)
|
||||
(cl-remove-if-not
|
||||
(append (doom-glob doom-emacs-dir "init.el")
|
||||
(list doom-core-dir)
|
||||
(seq-filter
|
||||
;; Only compile Doom's modules
|
||||
(lambda (path) (file-in-directory-p path doom-emacs-dir))
|
||||
(doom-rpartial #'file-in-directory-p doom-emacs-dir)
|
||||
;; Omit `doom-private-dir', which is always first
|
||||
(cdr (doom-module-load-path)))))
|
||||
recompile-p
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
(doom-glob (or (getenv "XDG_CONFIG_HOME")
|
||||
"~/.config")
|
||||
"isync/mbsyncrc"))
|
||||
(format "-c %S" config-file)
|
||||
(format "-c %S" (car config-file))
|
||||
"")))
|
||||
(`offlineimap
|
||||
"offlineimap && notmuch new")
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
:config
|
||||
(when (and (featurep! +flutter) IS-LINUX)
|
||||
(when-let (path (doom-glob "/opt/flutter/bin/cache/dart-sdk"))
|
||||
(setq flutter-sdk-path path)))
|
||||
(setq flutter-sdk-path (car path))))
|
||||
(set-ligatures! '(dart-mode)
|
||||
;; Functional
|
||||
:def "Function"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue