【问题标题】:How emacs take present file as argument to a function automatically?emacs 如何自动将当前文件作为函数的参数?
【发布时间】:2018-04-06 10:06:59
【问题描述】:

我正在制作自己的 shell 命令。当我按下回车键时自动将当前文件作为函数参数的命令是什么(就像 .vimrc 文件中的 % 一样。基本上我希望交互命令应该在我调用时不传递任何参数作为文件名时自动调用函数并自动将当前文件作为命令的输入。

【问题讨论】:

    标签: shell emacs


    【解决方案1】:

    根据我对您问题的理解,您可能正在寻找 interactive 的变体,该变体具有产生参数的 lisp 形式:

    (defun echo-current-buffer-filename (f)
      (interactive (list (buffer-file-name)))
      (message "Current buffer filename is %s" f))
    

    有关更多信息,请参阅https://www.gnu.org/software/emacs/manual/html_node/elisp/Using-Interactive.html 上的interactive 函数文档。

    【讨论】:

      猜你喜欢
      • 2015-07-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-14
      • 1970-01-01
      相关资源
      最近更新 更多