[英]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.