代码之家  ›  专栏  ›  技术社区  ›  Hatshepsut

使用命令行参数使用region调用子流程

  •  0
  • Hatshepsut  · 技术社区  · 7 年前

    我想使用 command 作为的论点 python -c [command] 。此外,如果使用前缀参数调用函数,我想将结果插入当前缓冲区。

    以下是我尝试过的:

    (defun abcdef/python-region (prefix command &optional b e)
      "Call python with `command' and send region on stdin. 
      Insert result if prefix present."
      (interactive "Psr")
      (call-process-region b e "python" prefix t "-c" command))
    

    当我尝试与交互调用它时 M-x abcdef/python-region 我明白了 Wrong type argument: stringp, t


    相关问题 here

    1 回复  |  直到 7 年前
        1
  •  1
  •   phils    7 年前

    我不太明白你是如何得到那个特定错误的,但是你的 interactive 表单没有提供您需要的参数。

    应该是这样的:

    (interactive "P\nsCommand: \nr")
    

    通常interactive的参数是包含代码的字符串 字母后跟提示(可选)。(有些代码字母没有 使用I/O获取参数,不要使用提示。)通过几个 命令的参数,连接各个字符串, 用换行符分隔。

    - C-h公司 F 互动的