编辑过程在emacs中非常静音,这就是为什么我决定让它变得更快更方便,我只遇到这个程序(代码串)不能自我更新的问题,即compile-command
(首次启动后)保持不变,如果没有干预就不会改变,我决定加上defin
,但我对lisp的无知阻止了我,结果不成功。
问题:如何使我的功能正常工作,以便每个新的ALT-M点击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)
初始版本:
(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" 'recompile)
我认为最简单的方法是使用模式钩子:
(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
的任何东西