don't add to "load-path" any directory contains ".nosearch" file

This commit is contained in:
zedhugh committed 2026-08-31 00:52:45 +08:00
1 parent b301edb39e
commit 78172b20d7
1 file changed
+6 -2
+6 -2
View File
@@ -9,13 +9,17 @@
(require 'cl-lib) (require 'cl-lib)
(require 'subr-x) (require 'subr-x)
(defun add-dir-and-subdirs-to-load-path (dir) (cl-defun add-dir-and-subdirs-to-load-path (dir)
"Add directory and its subdirectoris to `load-path'. "Add directory and its subdirectoris to `load-path' when no `.nosearch' file exists in DIR.
Detect whether there are any loadable module in DIR, if so, add DIR to `load-path'. Detect whether there are any loadable module in DIR, if so, add DIR to `load-path'.
Do this recursively for subdirectories of DIR." Do this recursively for subdirectories of DIR."
(unless (file-directory-p dir) (unless (file-directory-p dir)
(error "%s is not a directory" dir)) (error "%s is not a directory" dir))
;; if a `.nosearch' file exists in dir, skip it directly
(when (file-exists-p (expand-file-name ".nosearch" dir))
(cl-return-from add-dir-and-subdirs-to-load-path))
(let ((subdirs nil) (let ((subdirs nil)
(files nil) (files nil)
(temp-filepath nil) (temp-filepath nil)