【问题标题】:How do I fix a "Wrong Type Argument: listp," error when trying to access remote file using tramp?尝试使用 tramp 访问远程文件时,如何修复“错误类型参数:listp”错误?
【发布时间】:2014-01-05 23:30:54
【问题描述】:

我无法以通常的方式访问远程文件:

C-x C-f [server]:[path][file]

并抛出此错误: Wrong Type Argument: listp, [[server]:[path][file]

我什至不确定如何进一步调试。

感谢任何帮助。

编辑:

尝试调试时的输出:

Debugger entered: nil
(progn (debug) (ido-mode t) (progn (ad-add-advice (quote completing-read) (quote (foo nil
 t  (advice lambda nil (if (boundp ...) ad-do-it (setq ad-return-value ...))))) (quote 
around) (quote nil)) (ad-activate (quote completing-read) nil) (quote completing-read)) (define-key global-map [(meta 120)] (function (lambda nil (interactive) (call-interactively
(intern (ido-completing-read "M-x " (all-completions "" obarray ...))))))))
(if (fboundp (quote ido-mode)) (progn (debug) (ido-mode t) (progn (ad-add-advice (quote
completing-read) (quote (foo nil t (advice lambda nil (if ... ad-do-it ...)))) (quote
around) (quote nil)) (ad-activate (quote completing-read) nil) (quote completing-read)) 
(define-key global-map [(meta 120)] (function (lambda nil (interactive) (call-
interactively (intern (ido-completing-read "M-x " ...))))))))
eval-buffer()  ; Reading at buffer position 16103
call-interactively(eval-buffer)
(lambda nil (interactive) (call-interactively (intern (ido-completing-read "M-x " (all-
completions "" obarray (quote commandp))))))()
call-interactively((lambda nil (interactive) (call-interactively (intern (ido-completing- 
read "M-x " (all-completions "" obarray (quote commandp)))))) nil nil)

recursive-edit()
debug(debug)
implement-debug-on-entry()
*  ido-find-file()
call-interactively(ido-find-file nil nil)

这来自我的 init.el:

(require 'ido)
(if (fboundp 'ido-mode)
(progn
  (debug)
  (ido-mode t)
  (defadvice completing-read
    (around foo activate)
    (if (boundp 'ido-cur-list)
        ad-do-it
      (setq ad-return-value
            (ido-completing-read
             prompt
             (all-completions "" collection predicate)
             nil require-match initial-input hist def))))
  (define-key global-map [(meta ?x)]
    (lambda ()
      (interactive)
      (call-interactively
       (intern
        (ido-completing-read "M-x " (all-completions "" obarray 'commandp))))))))

【问题讨论】:

    标签: macos emacs elisp emacs24 tramp


    【解决方案1】:

    检查C-x C-f 绑定的命令(使用C-h k)。是标准绑定find-file吗? (听起来不像。)

    如果没有,请检查其interactive 规范。该命令期望接收一个列表作为参数,而是接收(看起来像)一个字符串。

    这是find-fileinteractive 规范:

    (interactive
     (find-file-read-args "Find file: " (confirm-nonexistent-file-or-buffer)))
    

    如果您的C-x C-f 命令的interactive 规范(例如这个命令)有一个非字符串作为其参数,那么您可以使用M-x debug-on-entry THE-FUNCTION,其中THE-FUNCTION 是为参数调用的函数(@ 987654332@,在 find-file 的情况下),或者包装该参数以便调用调试器:

    (progn (debug) (WHATEVER-WAS-THERE-BEFORE))
    

    无论哪种方式,调试器都会打开读取文件名的交互部分,您可以通过调试器查看问题所在。

    但也许你可以通过检查代码——interactive 规范找出问题所在。你的命令的参数(不管它是什么)应该是一个列表,但它是一个字符串。

    我会先看看本地文件名会发生什么。您是否也因此遇到错误?

    我注意到的另一件事是,错误报告了一个额外的[,在您输入的内容前面。这也应该提供一个线索。你认为它在读的不是它读到的。

    【讨论】:

    • 哎呀,我在复制和粘贴后按回车键,然后在编辑中时间用完了...让我再试一次...您好 Drew,感谢您非常快速和详细的回复。 C-x C-f 在启用 ido 时运行命令 ido-find-file。您认为我在哪里可以找到 interactive 规范?它内置在 emacs 中,但我不确定在哪里查看。
    • ido-find-file 在文件ido.el 中。它的interactive 规范只是(interactive):它不需要任何参数。粗略看一下您的调试输出表明您正在使用的东西已经建议completing-read(和 AFAICT,Ido 不这样做)。我建议您从那里开始:在您的代码或加载的代码中查找completing-readdefadvice。尝试从emacs -Q 开始重现问题,即没有初始化文件——只添加你需要的初始化文件来重现问题。
    • 您好 Drew,再次感谢您抽出宝贵时间回复。我似乎没有 ido.el 作为我的 emacs 版本的内置功能。我的 init.el 包含您所说的代码,并且一直都有,所以我不确定为什么我现在才遇到这个问题。当我删除除(需要'ido)行之外的所有内容时,我失去了流浪汉功能。不知道这会不会是ido和yasn-p的冲突?
    • 很难相信没有 Lisp 源代码的 Emacs。它应该与产品一起交付(毕竟这是 GNU)。无论如何,如果您不这样做,就很难提供帮助。如果您怀疑 yasn-p,请尝试不使用它,看看是否有帮助。尝试递归地对 init 文件进行二等分,以将其缩小到导致问题的代码。
    猜你喜欢
    • 1970-01-01
    • 2017-08-23
    • 2018-08-02
    • 1970-01-01
    • 2021-04-26
    • 2020-07-29
    • 2016-05-08
    相关资源
    最近更新 更多