I set the environment variable EMACSLOADPATH
to change Emacs load-path
this way:
mkdir ~/.emacs.d/site-lisp/
export EMACSLOADPATH="$(
emacs \
-Q --batch \
--eval '(princ user-emacs-directory)'
)"/site-lisp/:
# Let's say there is a teeest library:
echo "(provide 'teeest)" \
> ~/.emacs.d/site-lisp/teeest.el
Then ran Emacs
emacs -Q --batch
got stderr:
Warning: Lisp directory '~/.emacs.d/site-lisp': No such file or directory
Why does Emacs complain?
Actually, require
does know that directory:
emacs \
-Q --batch \
--eval "(princ (require 'teeest))" \
2> /dev/null ; echo
outputs:
teeest
export
. That will allow the shell to expand it properly.~
inEMACSLOADPATH
. Someone will encounter this problem at some time, and he/she probably does not know the reason why Emacs complains. The existence of this question may help.foo*
under your home directory, doexport EMACSLOADPATH=~/foo"*"
. I fail to see why you thinkEMACSLOADPATH
is somehow special or what this has to do with Emacs. The only parsing that Emacs (or any other program) does on a PATH-like environment variable is to split it at colons and construct a list - that's all.USER_EMACS_SITE_LISP="$(emacs -Q --batch --eval '(princ user-emacs-directory)')/site-lisp/"
(this string may also contain whitespaces). A more realistic case: github.com/shynur/.emacs.d/blob/main/etc/use-emacs.bashuser-emacs-directory
is a string containing a tilde. That appeared in the answer, but not in the question.