从源码进入compilation-mode之后怎么回到源码的编辑模式?
你是执行了 M-xcompile
吗?
我是加了个退出函数设置,编译完成后,光标会跳到 compilation-mode
的 buffer,方便直接按 q 就退出了。
(use-package compile
:bind ([f6] . recompile)
:config
(setq-default compilation-scroll-output 'first-error)
(setq compilation-finish-functions
(lambda (buffer &optional args)
(select-window (get-buffer-window buffer)))))
以下设置在编译无错的情况下自动隐藏compilation buffer
;; hide the compilation buffer automatically is not a good idea.
;; if compiling command is a unit test command
;; It's better let user decide when to hide something
(defvar my-do-bury-compilation-buffer t
"Hide compilation buffer if compile successfully.")
(defun my-compilation-finish-hide-buffer-on-success (buffer str)
"Bury BUFFER whose name marches STR.
This function can be re-used by other major modes after compilation."
(cond
;;there were errors
((string-match "exited abnormally" str)
(message "There IS compilation errors, press C-x ` to visit!"))
;;no errors, make the compilation window go away in 0.5 seconds
(t
(when (and my-do-bury-compilation-buffer
(buffer-name buffer)
(string-match "*compilation*" (buffer-name buffer)))
;; @see http://emacswiki.org/emacs/ModeCompile#toc2
(bury-buffer "*compilation*")
(winner-undo)
(message "NO compilation error.")))))
;; @see http://xugx2007.blogspot.com.au/2007/06/benjamin-rutts-emacs-c-development-tips.html
(setq compilation-finish-functions
'(my-compilation-finish-hide-buffer-on-success))
4 个赞
多谢大佬指点,你这个设置好,比较人性化,少按很多的 q
收藏了。
其实是compilation-mode, major mode. 从源文件进入mode之后就再也回不到编辑模式了。 q会退出到一个当前目录的Dired mode,选择之前的源文件之后再次回到compilation-mode。
你提供的信息太少了,不清楚你的具体问题是什么。
可能是你的配置做了定制,才会这样。你试试 emacs -q
启动,然后去编译看看。