From c568ae124453d59451168b13591f4cb7c5501f27 Mon Sep 17 00:00:00 2001 From: Bozhidar Batsov Date: Wed, 8 Jul 2026 14:28:07 +0300 Subject: [PATCH] Make the grep dependency honest; drop unused requires helm-projectile reads `grep-find-ignored-files'/`-directories' but only relied on `grep' being loaded transitively by Helm. Require `grep' from the two helpers that use those vars, so they are self-sufficient if that transitive load ever goes away. Also drop the `helm-locate' and `helm-global-bindings' requires - nothing here uses a symbol from either. This is dependency hygiene, not a startup-time change: Helm's own module graph still loads all three, so the load cost is unchanged. --- CHANGELOG.md | 1 + helm-projectile.el | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0146f55..3358cf9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,7 @@ ### Internal +* Tidy up top-level dependencies: `require` `grep` from the helpers that actually use `grep-find-ignored-files`/`-directories` (`helm-projectile--ignored-files`/`-directories`) instead of relying on it being pulled in transitively, and drop the unused `helm-locate` and `helm-global-bindings` requires. (No startup-time change - Helm loads all three transitively anyway; this just makes the dependencies honest.) * Drive `helm-projectile-toggle`'s command remaps from a single table (`helm-projectile--command-remaps`) instead of two hand-maintained copies of ~20 `define-key` calls. * Extract the remote virtual-Dired guard duplicated across the three Dired file actions into a `helm-projectile--with-virtual-dired` macro. * Sharp-quote (`#'`) function references so the byte-compiler can catch typos in them. diff --git a/helm-projectile.el b/helm-projectile.el index ee526b4..dd257e3 100644 --- a/helm-projectile.el +++ b/helm-projectile.el @@ -43,12 +43,11 @@ ;; built-in libraries (require 'subr-x) (require 'cl-lib) -(require 'grep) ;; TODO: Probably we should defer this require +;; `grep' is loaded lazily (only when computing ignores for a search); see +;; `helm-projectile--ignored-files'. (require 'helm-core) -(require 'helm-global-bindings) (require 'helm-types) -(require 'helm-locate) (require 'helm-buffers) (require 'helm-files) (require 'helm-grep) @@ -1441,11 +1440,15 @@ When set to `search-tool', the above does not happen." (defun helm-projectile--ignored-files () "Compute ignored files." + ;; `grep' provides `grep-find-ignored-files'; load it on demand rather than + ;; at startup, since it is only needed when a search computes ignores. + (require 'grep) (cl-union (projectile-ignored-files-rel) grep-find-ignored-files :test #'equal)) (defun helm-projectile--ignored-directories () "Compute ignored directories." + (require 'grep) (cl-union (mapcar #'file-name-as-directory (projectile-ignored-directories-rel)) (mapcar #'file-name-as-directory grep-find-ignored-directories) :test #'equal))