在这段代码中使用with-editor-mode进行类似于org里的C-c C-c或C-c C-k功能

(switch-to-buffer "*KiteAB Emacs*")
(setq kiteab/git-commit-concat (concat
                                kiteab/git-commit-type
                                "("
                                kiteab/git-commit-files
                                "): "
                                kiteab/git-commit-content))
(insert kiteab/git-commit-concat)
(setq kiteab/git-commit-ctn (read-from-minibuffer "[KiteAB Emacs] This is the current mmit content. Insert or cancel? "))
(if (string= kiteab/git-commit-ctn "y")
    (progn
      (kill-current-buffer)
      (insert kiteab/git-commit-concat))
  (kill-current-buffer))

代码写得烂 勿喷

(setq kiteab/git-commit-ctn (read-from-minibuffer "[KiteAB Emacs] This is the current mmit content. Insert or cancel? "))
(if (string= kiteab/git-commit-ctn "y")
    (progn
      (kill-current-buffer)
      (insert kiteab/git-commit-concat))
  (kill-current-buffer))

有个东西叫y-or-n-p,还有个yes-or-no-p

这个也不错 不过还是更想要with-editor的那种体验:laughing: 因为可能要编辑buffer里的文本(虽然C-x o也能切出去编辑

(insert kiteab/git-commit-concat)
(setq kiteab/git-commit-ctn (y-or-n-p "[KiteAB Emacs] This is the current commit content. sert or cancel? "))
(if kiteab/git-commit-ctn
    (progn
      (kill-current-buffer)
      (insert kiteab/git-commit-concat))
  (kill-current-buffer))

改成了这样

(defvar kiteab-commit-map
  (let ((map (make-sparse-keymap)))
    (define-key map (kbd "C-c C-c") 'kiteab-commit-finish)
    (define-key map (kbd "C-c C-k") 'kiteab-commit-abort)
    map))

(defun kiteab-commit-finish ()
  (interactive)
  (message "finished")
  ;; kill buffers
  )

(defun kiteab-commit-abort ()
  (interactive)
  (message "aborted")
  ;; kill buffers
  )

(defun kiteab-commit-edit ()
  (interactive)
  ;; new buffer
  (use-local-map kiteab-commit-map)
  ;; ...
  )

定义一个 map 然后使用就行,供参考

有点麻烦 不过可以用