Emacs 使用当前缓冲区';M-x编译中的s文件名

Emacs 使用当前缓冲区';M-x编译中的s文件名,emacs,Emacs,我希望emacs使用当前缓冲区的文件名作为传递给M-x compile的命令的一部分。例如,如果我正在编辑~/foo.rb,我希望M-x compile执行ruby~/foo.rb 我尝试将编译命令设置为(列出“ruby”缓冲区文件名),但显然不能在这里传递s表达式 一,。阅读函数的文档 C-hfcompileRET 现在我们已经找到了我们要找的东西,让我们 2. … 阅读变量的文档… C-hvcompile命令RET 3. … 最后根据您的需要调整示例 当然,如果有一个 Rakefile+1教

我希望emacs使用当前缓冲区的文件名作为传递给
M-x compile
的命令的一部分。例如,如果我正在编辑~/foo.rb,我希望
M-x compile
执行
ruby~/foo.rb

我尝试将
编译命令设置为
(列出“ruby”缓冲区文件名)
,但显然不能在这里传递s表达式

一,。阅读函数的文档 C-hf
compile
RET

现在我们已经找到了我们要找的东西,让我们

2. … 阅读变量的文档… C-hv
compile命令
RET

3. … 最后根据您的需要调整示例 当然,如果有一个
Rakefile

+1教人钓鱼!从现在开始,我将使用此过程。我希望您不必求助于smart-compile就可以这样做。您需要在shell中引用文件名:
(concat“ruby”(shell quote参数缓冲区文件名))
compile is an interactive autoloaded compiled Lisp function in
`compile.el'.
[snip]
Interactively, prompts for the command if `compilation-read-command' is
non-nil; otherwise uses `compile-command'.  With prefix arg, always prompts.
Additionally, with universal prefix arg, compilation buffer will be in
comint mode, i.e. interactive.
compile-command is a variable defined in `compile.el'.
Its value is "make -k "
[snip]
Sometimes it is useful for files to supply local values for this variable.
You might also use mode hooks to specify it in certain modes, like this:

    (add-hook 'c-mode-hook
       (lambda ()
     (unless (or (file-exists-p "makefile")
             (file-exists-p "Makefile"))
       (set (make-local-variable 'compile-command)
        (concat "make -k "
            (file-name-sans-extension buffer-file-name))))))
(add-hook 'ruby-mode-hook
          (lambda ()
            (set (make-local-variable 'compile-command)
                 (concat "ruby " buffer-file-name))))