在emacs中,编译过程非常安静,这就是为什么我决定使其更快,更方便的原因,而我仅得到这个程序(代码字符串)不能自我更新的问题,即{{1 }}(在首次启动后),保持不变,并且无需干预就不会更改,因此我决定添加compile-command
,但由于对Lisp的无知阻止了我,结果失败了。
问题:如何使我的功能正常运行,以便在每个新的ALT-M上都单击defin
。
我试图做的事情
compile-command
初始版本:
(defun x-recompile (compile-command)
(setq compile-command '(concat "/usr/local/Cellar/gcc/8.3.0/bin/gcc-8 -O2 -Wall -o "
(if (file-name-sans-extension buffer-file-name)
(shell-quote-argument
(file-name-sans-extension buffer-file-name)))
" "
(if buffer-file-name
(shell-quote-argument (buffer-file-name))))))
(define-key global-map "\eM" 'compile)
(define-key global-map "\em" 'x-recompile)
答案 0 :(得分:2)
我认为最简单的方法是使用模式挂钩:
(add-hook 'c-mode-hook
(lambda ()
(set (make-local-variable 'compile-command)
(concat "/usr/local/Cellar/gcc/8.3.0/bin/gcc-8 -O2 -Wall -o "
(if (file-name-sans-extension buffer-file-name)
(shell-quote-argument
(file-name-sans-extension buffer-file-name)))
" "
(if buffer-file-name
(shell-quote-argument (buffer-file-name)))))))
这将在您访问文件时设置compile-command
,然后compile
和recompile
将正常工作。
.emacs
compile
绑定到的任何内容