![]() (mapc (apply-partially 'add-to-list 'load-path) local-pkgs) (local-pkgs (mapcar 'file-name-directory (directory-files-recursively path ".* \\.el")))) ( let* ((path (expand-file-name "lisp" user-emacs-directory)) If already exists, then add the subdirs to load-path. If user-emacs-directory/lisp does not exist, create it. Adds subdirectories containing ".el" files to load-path inside the directory user-emacs-directory/lisp. Note the use of ‘convert-standard-file-name’ to construct a path that is valid on all supported platforms. If you are using Emacs 23 or later you can use variable ‘user-emacs-directory’ to construct a path to one of its descendant directories. (normal-top-level-add-subdirs-to-load-path))) ![]() (copy-sequence (normal-top-level-add-to-load-path '( "."))) To install all directories to the beginning of the ‘load-path’ use: ( let ((default-directory "~/.emacs.d/lisp/")) Above we only added directory lisp, to avoid loading files that are not libraries. Since various packages store information in ~/.emacs.d/, it is unwise to add all of its descendant directories to ‘load-path’. ( let ((default-directory "~/.emacs.d/lisp/")) ( let ((load-path (copy-sequence load-path))) ShadowĪssuming that you install packages in ~/.emacs.d/lisp/ and that some of the installed packages have only a single file while others have multiple files inside a package-specific directory, you need to combine the steps from above. ![]() To have libraries in particular paths take precedence over other libraries with the same name, elsewhere, put the directories or those prioritized libraries at the beginning of ‘load-path’. (normal-top-level-add-to-load-path '( "emms" "erc" "planner" "w3"))) For example: ( let ((default-directory "~/.emacs.d/lisp/")) To add only some descendant directories, pass the list as a second argument. This omits directories whose names do not start with letters or digits, those named RCS or CVS, and those containing a file named. (normal-top-level-add-subdirs-to-load-path)) To add all of the descendant directories of a directory DIR to your ‘load-path’, bind variable ‘default-directory’ to DIR and then invoke function ‘normal-top-level-add-subdirs-to-load-path’, as follows: ( let ((default-directory "~/.emacs.d/lisp/")) (The directory name does not need to end with a slash ( /).)Īdding a directory to variable ‘load-path’ does not also add any of its descendants (its subdirectories, their subdirectories, and so on, recursively). To add a single directory (e.g., "~/.emacs.d/lisp/") to the front of your ‘load-path’: (add-to-list 'load-path "~/.emacs.d/lisp/") Therefore, be sure to recompile files after making changes to them (or don’t compile them at all). When both a byte-compiled file ( *.elc) and a source file ( *.el) are found for the same library, preference is given to byte-compiled file. ![]() But if you download Emacs Lisp files yourself or you write local Lisp files, just add the directories containing those files to ‘load-path’. If you install an Emacs package using the package manager (see InstallingPackages), it automatically configures ‘load-path’ to handle the packages you install that way. If you do not alter it (directly or indirectly), by default it contains the Lisp source directories for the Emacs distribution. The value of variable ‘load-path’ is a list of directories to search, in order, for EmacsLisp libraries that you load.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |