【问题标题】:Emacs update-file-autoloads failingEmacs 更新文件自动加载失败
【发布时间】:2023-03-18 02:15:01
【问题描述】:

我正在尝试将 emacs 设置为我的 GO IDE,方法是遵循此 tutorial 和此 code 。当我必须让 emacs 生成文件时,我遇到了问题

在 Emacs 中,运行 M-x update-file-autoloads,将它指向 go-mode.el 文件并告诉它生成一个 go-mode-load.el 文件。

当我输入文件路径(位置~/.emacs.d/go-mode/go-mode.el)时出现此错误

Opening output file: no such file or directory, /build/buildd/emacs23-23.3+1/debian/build-x/lisp/loaddefs.el

我在这个文件上做了一个locate,看到我确实有它,但不是在上面指定的路径

$ locate loaddefs.el
/usr/share/emacs/23.3/lisp/loaddefs.el
...

如果我不得不猜测,我会说某种路径问题。我必须在某处设置路径变量吗?

我通过apt-get install emacs23安装了emacs

我使用的是 Ubuntu 12.04

谢谢

编辑

我正在执行的获取错误的过程。

  1. M-x update-file-autoloads回车

  2. Update autoloads for file: ~/.emacs.d/go-mode/go-mode.el 回车

Opening output file: no such file or directory, /build/buildd/emacs23-23.3+1/debian/build-x/lisp/loaddefs.el

【问题讨论】:

  • 你如何调用更新文件自动加载?看起来您正在尝试将自动加载写入 /build/.... 中的文件。您需要做的是编写一个新的自动加载文件,而不是更新或覆盖现有文件。当我运行 M-x update-file-autoloads 并将其指向一个文件时,它会询问我要将结果写入何处。这不会发生在你身上吗?
  • 不,我没有被要求写结果。只是Update autoloads for file: 提示然后是错误
  • go-mode.el 中是否有 `generated-autoload-file' 的本地定义?

标签: emacs


【解决方案1】:

我遇到了同样的问题,终于让它工作了。打开您的暂存缓冲区(或任何其他空文件)并输入以下两行

(setq generated-autoload-file "~/.emacs.d/go-mode/go-mode-load.el")
(update-file-autoloads "~/.emacs.d/go-mode/go-mode.el")

然后通过将光标放在每行的 then 来评估这两行并输入 C-x C-e 以评估光标之前的行。对两条线都这样做。然后确保打开 go-mode-load.el 并保存缓冲区 - 显然 emacs 默认不这样做。

完成此操作后,您可以继续按照http://www.honnef.co/posts/2013/03/writing_go_in_emacs/ 的说明进行操作

免责声明:我确信有更好的方法可以做到这一点,而 lisp 专家会对我的回答大吃一惊。我不知道 lisp 以及如何在 emacs 中使用 lisp。我只是做了一个明智的猜测:-)

【讨论】:

    【解决方案2】:

    最近在尝试在我的树莓派上设置 go-mode.el 时遇到了这个问题。幸运的是,我已经在我的 Mac 上成功生成了一个 go-mode-load.el 文件,并且能够查看它。

    在那里我看到了这条评论:

    ;; To update this file, evaluate the following form
    ;;   (let ((generated-autoload-file buffer-file-name)) (update-file-autoloads "go-mode.el"))
    

    所以我cd'ed 进入我下载go-mode.el 的目录,然后touched 一个名为go-mode-load.el 的新文件,在 emacs 中打开它,粘贴在那行代码,用C-x C-e 它就像一个魅力。

    编辑

    在我将这些行添加到末尾之前,无法使生成的文件正常工作。在撰写本文时,我还没有花时间弄清楚为什么需要它们,但添加它们可以解决问题:

    (provide 'go-mode-load)
    ;; Local Variables:
    ;; version-control: never
    ;; no-byte-compile: t
    ;; no-update-autoloads: t
    ;; coding: utf-8
    ;; End:
    ;;; go-mode-load.el ends here
    

    【讨论】:

      【解决方案3】:

      (不是答案,但需要格式化) go-mode.el 中是否有“生成的自动加载文件”的本地定义?如果是这样,它会写在那里,所以你需要删除该行。


      ;;更新文件自动加载文档

      update-file-autoloads 是一个交互式编译的 Lisp 函数 `autoload.el'。

      (update-file-autoloads FILE &optional SAVE-AFTER OUTFILE)

      更新 FILE 的自动加载。 如果前缀 arg SAVE-AFTER 不为零,也保存缓冲区。

      如果 FILE 绑定 generated-autoload-file' as a file-local variable, autoloads are written into that file. Otherwise, the autoloads file is determined by OUTFILE. If called interactively, prompt for OUTFILE; if called from Lisp with OUTFILE nil, use the existing value ofgenerated-autoload-file'。

      如果没有自动加载cookie,则返回FILE,否则为零。

      【讨论】:

        【解决方案4】:

        查看go-mode-el GitHub webpage 中的实际安装说明。似乎有一些未反映在教程中的更改。

        尝试使用 ELPA 或按照手册说明操作:

        (add-to-list 'load-path "/place/where/you/put/it/")
        (require 'go-mode-autoloads)
        

        【讨论】:

          猜你喜欢
          • 2011-08-11
          • 1970-01-01
          • 2013-01-27
          • 2011-11-24
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2012-04-12
          相关资源
          最近更新 更多