Skip to content

Commit

Permalink
Don't add anything to load path explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
pkryger committed Nov 26, 2024
1 parent c350c9c commit f613eca
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,19 @@ your `~/.emacs.d` are always first in each respective tapped list. Each tapped
list is processed (each file from it is loaded) as a replacement for a
respective [Local file](#local-files).

Note that Exordium doesn't add any directory to a load path. If your tap expects
that it's directory tree is in load path, you can use the following code to
update the load-path:

```lisp
(eval-when-compile
(unless (featurep 'init-require)
(load (file-name-concat (locate-user-emacs-file "modules") "init-require"))))
(exordium-require 'init-lib)
(when (bound-and-true-p load-file-name)
(exordium-add-directory-tree-to-load-path (file-name-directory load-file-name)))
```

Exordium-specific emacs functions are WIP.

### Preferences
Expand Down
13 changes: 0 additions & 13 deletions init.el
Original file line number Diff line number Diff line change
Expand Up @@ -112,21 +112,10 @@ Set to stable melpa.org if you want stable.")
(defvar exordium-tapped-after-init-files ()
"All tapped after init files, including master one.")

(defun exordium--add-directory-tree-to-load-path (dir &optional ignore-if-absent)
"Add DIR and all its subdirs to the load path.
Warn if DIR is not a directory and IGNORE-IF-ABSENT is nil."
(cond ((file-directory-p dir)
(add-to-list 'load-path dir)
(let ((default-directory dir))
(normal-top-level-add-subdirs-to-load-path)))
((not ignore-if-absent)
(warn "Missing directory: %s" dir))))


(when (file-accessible-directory-p exordium-taps-root)
(dolist (tap (nreverse (directory-files exordium-taps-root t "^[^\.].*")))
(when (file-accessible-directory-p tap)
(exordium--add-directory-tree-to-load-path tap) ;; @todo: remove?
(when-let* ((tapped (file-name-concat tap exordium-before-init))
((file-readable-p tapped)))
(add-to-list 'exordium-tapped-before-init-files tapped))
Expand All @@ -149,8 +138,6 @@ Warn if DIR is not a directory and IGNORE-IF-ABSENT is nil."
(when (file-readable-p exordium-custom-file)
(add-to-list 'exordium-tapped-after-init-files exordium-custom-file))

(exordium--add-directory-tree-to-load-path exordium-local-dir t)

;; Bind this early, and only if it has not been bound already,
;; so customisation from other places (i.e., before-init files)
;; are not overwritten.
Expand Down
10 changes: 10 additions & 0 deletions modules/init-lib.el
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ Input is a string and output is a list of strings."
"Return the path of the DIR's parent directory."
(file-name-directory (directory-file-name dir)))

(defun exordium-add-directory-tree-to-load-path (dir &optional ignore-if-absent)
"Add DIR and all its subdirs to the load path.
Warn if DIR is not a directory and IGNORE-IF-ABSENT is nil."
(cond ((file-directory-p dir)
(add-to-list 'load-path dir)
(let ((default-directory dir))
(normal-top-level-add-subdirs-to-load-path)))
((not ignore-if-absent)
(warn "Missing directory: %s" dir))))


;;; String manipulation functions

Expand Down

0 comments on commit f613eca

Please sign in to comment.