From 5e9c020c216e6ad679c0329f4681918d9782e444 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 16 Jun 2019 15:27:49 +0200 Subject: [PATCH] doom-files-in: replace NOSORT w/ SORT; change default MATCH - SORT defaults to t - MATCH's new default regexp excludes files that start with underscore. --- core/autoload/debug.el | 2 +- core/autoload/files.el | 6 +++--- core/autoload/help.el | 8 +++++--- core/autoload/packages.el | 3 ++- core/cli/autoloads.el | 2 +- core/cli/byte-compile.el | 10 +++++----- core/cli/test.el | 2 +- core/core-modules.el | 8 +++++--- 8 files changed, 23 insertions(+), 18 deletions(-) diff --git a/core/autoload/debug.el b/core/autoload/debug.el index ede9828d6..83fa67f00 100644 --- a/core/autoload/debug.el +++ b/core/autoload/debug.el @@ -44,7 +44,7 @@ ready to be pasted in a bug report on github." (length (doom-files-in `(,@doom-modules-dirs ,doom-core-dir ,doom-private-dir) - :type 'files :match "\\.elc$")) + :type 'files :match "\\.elc$" :sort nil)) (if IS-WINDOWS "n/a" (with-temp-buffer diff --git a/core/autoload/files.el b/core/autoload/files.el index 076723583..ffa2b3a53 100644 --- a/core/autoload/files.el +++ b/core/autoload/files.el @@ -10,13 +10,13 @@ filter map full - nosort + (sort t) ; TODO Allow a function for custom sorting? (follow-symlinks t) (type 'files) (relative-to (unless full default-directory)) (depth 99999) (mindepth 0) - (match "/[^.]")) + (match "/[^._]")) "Returns a list of files/directories in PATH-OR-PATHS (one string path or a list of them). @@ -45,7 +45,7 @@ MATCH is a string regexp. Only entries that match it will be included." ((let ((path path-or-paths) result) (when (file-directory-p path) - (dolist (file (directory-files path nil "." nosort)) + (dolist (file (directory-files path nil "." sort)) (unless (member file '("." "..")) (let ((fullpath (expand-file-name file path))) (cond ((file-directory-p fullpath) diff --git a/core/autoload/help.el b/core/autoload/help.el index e648196b3..abcce9566 100644 --- a/core/autoload/help.el +++ b/core/autoload/help.el @@ -194,9 +194,11 @@ selection of all minor-modes, active or not." "Search headlines in Doom's newsletters." (interactive) (doom-completing-read-org-headings - "Find in News: " (doom-files-in (expand-file-name "news" doom-docs-dir) - :match "/[0-9]" - :relative-to doom-docs-dir) + "Find in News: " + (nreverse (doom-files-in (expand-file-name "news" doom-docs-dir) + :match "/[0-9]" + :relative-to doom-docs-dir + :sort t)) nil t initial-input)) ;;;###autoload diff --git a/core/autoload/packages.el b/core/autoload/packages.el index e9e4c762a..8892db757 100644 --- a/core/autoload/packages.el +++ b/core/autoload/packages.el @@ -362,7 +362,8 @@ ones." (doom-files-in doom-modules-dir :depth 2 :full t - :match "/packages\\.el$")) + :match "/packages\\.el$" + :sort nil)) (cl-loop for key being the hash-keys of doom-modules for path = (doom-module-path (car key) (cdr key) "packages.el") for doom--current-module = key diff --git a/core/cli/autoloads.el b/core/cli/autoloads.el index d04a4f696..8bdce2d18 100644 --- a/core/cli/autoloads.el +++ b/core/cli/autoloads.el @@ -255,7 +255,7 @@ Run this whenever your `doom!' block, or a module autoload file, is modified." (when (file-exists-p auto-file) (push auto-file targets) (if module-p (push auto-file enabled-targets))) - (dolist (file (doom-files-in auto-dir :match "\\.el$" :full t)) + (dolist (file (doom-files-in auto-dir :match "\\.el$" :full t :sort nil)) (push file targets) (if module-p (push file enabled-targets))))) (if (and (not force-p) diff --git a/core/cli/byte-compile.el b/core/cli/byte-compile.el index d053ccdab..2d947a4d5 100644 --- a/core/cli/byte-compile.el +++ b/core/cli/byte-compile.el @@ -108,7 +108,7 @@ If RECOMPILE-P is non-nil, only recompile out-of-date files." ;; Assemble el files we want to compile; taking into account that ;; MODULES may be a list of MODULE/SUBMODULE strings from the command ;; line. - (let ((target-files (doom-files-in targets :filter #'doom--byte-compile-ignore-file-p))) + (let ((target-files (doom-files-in targets :filter #'doom--byte-compile-ignore-file-p :sort nil))) (when (or (not modules) (member ":core" modules)) (push (expand-file-name "init.el" doom-emacs-dir) @@ -175,10 +175,10 @@ If RECOMPILE-P is non-nil, only recompile out-of-date files." module. This does not include your byte-compiled, third party packages.'" (cl-loop with default-directory = doom-emacs-dir for path - in (append (doom-files-in doom-emacs-dir :match "\\.elc$" :depth 0) - (doom-files-in doom-private-dir :match "\\.elc$" :depth 1) - (doom-files-in doom-core-dir :match "\\.elc$") - (doom-files-in doom-modules-dirs :match "\\.elc$" :depth 4)) + in (append (doom-files-in doom-emacs-dir :match "\\.elc$" :depth 0 :sort nil) + (doom-files-in doom-private-dir :match "\\.elc$" :depth 1 :sort nil) + (doom-files-in doom-core-dir :match "\\.elc$" :sort nil) + (doom-files-in doom-modules-dirs :match "\\.elc$" :depth 4 :sort nil)) for truepath = (file-truename path) if (file-exists-p path) do (delete-file path) diff --git a/core/cli/test.el b/core/cli/test.el index cb5e32c23..f67953fbc 100644 --- a/core/cli/test.el +++ b/core/cli/test.el @@ -32,7 +32,7 @@ If neither is available, run all tests in all enabled modules." nconc (cl-loop for dir in doom-modules-dirs for path = (expand-file-name arg dir) if (file-directory-p path) - nconc (doom-files-in path :type 'dirs :depth 1 :full t)) + nconc (doom-files-in path :type 'dirs :depth 1 :full t :sort nil)) finally do (setq argv nil)))) (modules ; cons-cells given to MODULES diff --git a/core/core-modules.el b/core/core-modules.el index a00587b23..9ac839e5e 100644 --- a/core/core-modules.el +++ b/core/core-modules.el @@ -195,15 +195,17 @@ This doesn't require modules to be enabled. For enabled modules us (intern module)))))))) (defun doom-module-load-path (&optional all-p) - "Return a list of absolute file paths to activated modules. If ALL-P is -non-nil, return paths of possible modules, activated or otherwise." + "Return an unsorted list of absolute file paths to activated modules. + +If ALL-P is non-nil, return paths of possible modules, activated or otherwise." (declare (pure t) (side-effect-free t)) (append (if all-p (doom-files-in doom-modules-dirs :type 'dirs :mindepth 1 :depth 1 - :full t) + :full t + :sort nil) (cl-loop for plist being the hash-values of (doom-modules) collect (plist-get plist :path))) (list doom-private-dir)))