gpt4 book ai didi

Emacs Lisp : How to add a folder and all its first level sub-folders to the load-path

转载 作者:行者123 更新时间:2023-12-03 15:16:32 24 4
gpt4 key购买 nike

如果我有一个这样设置的文件夹结构:

~/Projects
emacs
package1
package1-helpers
package2
package2-helpers
package2-more-helpers
package3
package3-helpers

如何添加这些文件夹:
  • ~/项目/emacs
  • ~/Projects/emacs/package1
  • ~/Projects/emacs/package2
  • ~/Projects/emacs/package3

  • ...到 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")

    最佳答案

    (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 Lisp : How to add a folder and all its first level sub-folders to the load-path,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/221365/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com