diff --git a/lisp/init-package.el b/lisp/init-package.el index 1fbb55a..16bb4e8 100644 --- a/lisp/init-package.el +++ b/lisp/init-package.el @@ -9,13 +9,17 @@ (require 'cl-lib) (require 'subr-x) -(defun add-dir-and-subdirs-to-load-path (dir) - "Add directory and its subdirectoris to `load-path'. +(cl-defun add-dir-and-subdirs-to-load-path (dir) + "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'. Do this recursively for subdirectories of DIR." (unless (file-directory-p 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) (files nil) (temp-filepath nil)