在Emacs中,当您尝试杀死临时缓冲区(也称为“临时缓冲区”)之前,可以通过以下方法收到警告:
kill-buffer
命令并在其前面添加confirm-kill-processes
前缀。这将在杀死缓冲区之前询问您是否确定。(defun confirm-kill-buffer-with-prompt (buffer)
(let ((process (get-buffer-process buffer)))
(if (and process (process-query-on-exit-flag process))
(yes-or-no-p (format "Really kill buffer %s? " buffer))
t)))
(advice-add 'kill-buffer :before 'confirm-kill-buffer-with-prompt)
kill-buffer-query-functions
钩子,它允许您在杀死缓冲区之前执行任何操作。(defun confirm-kill-buffer-with-prompt (buffer)
(let ((process (get-buffer-process buffer)))
(if (and process (process-query-on-exit-flag process))
(yes-or-no-p (format "Really kill buffer %s? " buffer))
t)))
(add-hook 'kill-buffer-query-functions 'confirm-kill-buffer-with-prompt)
这两种方法都会在杀死临时缓冲区之前询问您是否确定。如果您选择继续杀死缓冲区,那么缓冲区将被杀死。如果您选择取消,那么缓冲区将保持打开状态。
领取专属 10元无门槛券
手把手带您无忧上云