[英]Correct Way to Exit emacsclient When Set as the Git Editor
我想在 git 中使用 emacsclient 作为我的编辑器,即我的.gitconfig
中的core.editor
设置。 在我的.gitconfig
中,我有:
...
[core]
editor = /usr/local/bin/emacsclient --tty
...
当我执行git commit --amend
或git commit
之类的操作时,我按预期进入了 emacs(client),但是当我尝试使用Cx Cc
退出时,我收到消息:
Don’t kill this buffer #<buffer COMMIT_EDITMSG>. Instead cancel using C-c C-k
按照上面的建议取消会导致来自 git 的明显错误:
error: There was a problem with the editor '/usr/local/bin/emacsclient --tty'.
Please supply the message using either -m or -F option.
我发现的是,使用Cx #
类作品,我的更改就在那里。 但是,下次我运行类似git commit --amend
的命令时,我在 emacsclient 中收到消息:
Revert buffer from file /[CONTAINING FOLDER]/.git/COMMIT_EDITMSG? (yes or no)
所以我猜这不是正确的退出方式。 我也试过Cx k
,但这似乎没有保存任何东西。
看起来缓冲区正在使用(其中一种变体) git-commit
模式。
要接受提交消息,请使用Cc Cc (control+c 两次)
https://github.com/magit/magit/blob/main/lisp/git-commit.el有这样的评论:
;; 通过使用 `with-editor' package 这个 package 提供;; 完成编辑 session 的两种方式。无论哪种情况,文件;; 已保存,但 Emacseditor 的退出代码不同。 ;; ;; 抄送 抄送 编辑成功 session 返回;; 退出代码为 0。Git 然后使用创建提交;; 它在文件中找到的消息。 ;; ;; Cc Ck 通过返回 exit 中止编辑 session;; 代码 1. Git 然后中止提交。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.