diff options
| author | Craig Jennings <c@cjennings.net> | 2026-06-20 12:47:17 -0400 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-06-20 12:47:17 -0400 |
| commit | ffb9a7de2f86ef9f1aab84b197ca5806fe657f0b (patch) | |
| tree | 896dd698ea8f02d48b00985f1e599b7d2e6958d2 /modules/prog-general.el | |
| parent | c8f63debf96f938547a222797dc72e8c1aa5c8eb (diff) | |
| download | dotemacs-ffb9a7de2f86ef9f1aab84b197ca5806fe657f0b.tar.gz dotemacs-ffb9a7de2f86ef9f1aab84b197ca5806fe657f0b.zip | |
refactor(prog-general): lift cj/find-project-root-file out of :config
The pure project-root file finder lived inside the projectile use-package :config, so it was unreachable under make test. Move it to top level (its forward declaration already existed); cj/open-project-root-todo and cj/project-switch-actions still call it. Adds unit coverage for string regexps, rx forms, no-match, and no-project.
Diffstat (limited to 'modules/prog-general.el')
| -rw-r--r-- | modules/prog-general.el | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/modules/prog-general.el b/modules/prog-general.el index 53f20ce46..ae48bc9cb 100644 --- a/modules/prog-general.el +++ b/modules/prog-general.el @@ -64,9 +64,21 @@ (defvar treesit-auto-recipe-list) ;; Forward declarations for functions defined later in this file -(declare-function cj/find-project-root-file "prog-general") (declare-function cj/project-switch-actions "prog-general") (declare-function cj/deadgrep--initial-term "prog-general") + +(defun cj/find-project-root-file (regexp) + "Return first file in the current Projectile project root matching REGEXP. + +Match is done against (downcase file) for case-insensitivity. +REGEXP must be a string or an rx form." + (when-let ((root (projectile-project-root))) + (seq-find (lambda (file) + (string-match-p (if (stringp regexp) + regexp + (rx-to-string regexp)) + (downcase file))) + (directory-files root)))) (declare-function cj/highlight-indent-guides-disable-in-non-prog-modes "prog-general") ;; --------------------- General Programming Mode Settings --------------------- @@ -177,19 +189,6 @@ reuses the current window otherwise, matching `cj/open-project-root-todo'." :config (require 'seq) - (defun cj/find-project-root-file (regexp) - "Return first file in the current Projectile project root matching REGEXP. - -Match is done against (downcase file) for case-insensitivity. -REGEXP must be a string or an rx form." - (when-let ((root (projectile-project-root))) - (seq-find (lambda (file) - (string-match-p (if (stringp regexp) - regexp - (rx-to-string regexp)) - (downcase file))) - (directory-files root)))) - (defun cj/open-project-root-todo () "Open todo.org in the current Projectile project root. |
