如果我有一个像这样设置的文件夹结构:
~/Projects emacs package1 package1-helpers package2 package2-helpers package2-more-helpers package3 package3-helpers
如何添加这些文件夹:
〜/项目/ emacs的
〜/项目/ emacs的/包1
〜/项目/ emacs的/包2
〜/项目/ emacs的/包装3
... load-path
来自我的.emacs文件?
我基本上需要这个代码的简短自动化版本:
(add-to-list 'load-path "~/Projects/emacs") (add-to-list 'load-path "~/Projects/emacs/package1") (add-to-list 'load-path "~/Projects/emacs/package2") (add-to-list 'load-path "~/Projects/emacs/package3")
Jouni K. Sep.. 17
(let ((base "~/Projects/emacs")) (add-to-list 'load-path base) (dolist (f (directory-files base)) (let ((name (concat base "/" f))) (when (and (file-directory-p name) (not (equal f "..")) (not (equal f "."))) (add-to-list 'load-path name)))))
Nicholas Ril.. 10
这是我在.emacs中使用的东西:
(let* ((my-lisp-dir "~/.elisp/") (default-directory my-lisp-dir) (orig-load-path load-path)) (setq load-path (cons my-lisp-dir nil)) (normal-top-level-add-subdirs-to-load-path) (nconc load-path orig-load-path))
如果您查看normal-top-level-add-subdirs-to-load-path的描述,那么选择要排除的目录有点聪明.
(let ((base "~/Projects/emacs")) (add-to-list 'load-path base) (dolist (f (directory-files base)) (let ((name (concat base "/" f))) (when (and (file-directory-p name) (not (equal f "..")) (not (equal f "."))) (add-to-list 'load-path name)))))
这是我在.emacs中使用的东西:
(let* ((my-lisp-dir "~/.elisp/") (default-directory my-lisp-dir) (orig-load-path load-path)) (setq load-path (cons my-lisp-dir nil)) (normal-top-level-add-subdirs-to-load-path) (nconc load-path orig-load-path))
如果您查看normal-top-level-add-subdirs-to-load-path的描述,那么选择要排除的目录有点聪明.
我建议你使用subdirs.el