加载自动加载文件

时间:2018-01-23 17:00:49

标签: emacs autoload

我有一个名为“myloaddefs.el”的文件函数。它下面有神奇的咒语和形式,就像下面的那样。

;;;###autoload
(defun an-awesome-function '()
   (interactive)
  "A descriptive comment." t)

;;; other descriptive comments and forms...

它的完整路径为~/.emacs.d/core/myloaddefs.el。 我还有一个自动加载文件,其完整路径为~/.emacs.d/.local/autoloads.el。我将其路径存储在变量my-autoload-file

在致电update-file-autoloads之前,my-autoload-file只有空注释;;(确保它为非空以避免错误)。正如我在下面调用update-file-autoloads返回nil。当我检查my-autoload-file它确实更新了自动装载时。加载'my-autoload-file returns t`也似乎成功了。

(update-file-autoloads (concat my-core-dir "myloaddefs.el") t my-autoload-file) ; => nil
(load-file my-autoload-file) ; => t

然而,在使用M-x an-awesome-function调用自动加载的交互式函数后,我得到"Cannot open load file: no such file or directory" "../core/myautoloads"。这让我很困惑,因为目录和文件确实存在。这可能有什么问题?

1 个答案:

答案 0 :(得分:0)

The path to your autoload file needs to be on your load path since you are using relative paths to load the libraries (eg. ../core/autoloads). I would use expand-file-name anywhere you are creating a path instead of building them using concat.

Try (push (expand-file-name ".local" "~") load-path) prior to calling an-awesome-function (whose definition is incorrect).