From 78172b20d721a9e548644f04c9d2464438473fd5 Mon Sep 17 00:00:00 2001 From: Zedhugh Chen Date: Mon, 31 Aug 2026 00:52:45 +0800 Subject: [PATCH] don't add to "load-path" any directory contains ".nosearch" file --- lisp/init-package.el | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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)