emacs save and kill buffer for (neo)mutt
- Date: Fri, 12 Apr 2019 18:04:45 +0200
- From: Pétùr <peturvilj@xxxxxxxxx>
- Subject: emacs save and kill buffer for (neo)mutt
I use neomutt with emacs.
I would like to quickly save and kill a buffer in emacs. This is to
avoid typing C-x C-s and, then, C-x C-c when sending an email. I want
one shortcut to save and kill the buffer and be back quickly in mutt to
send the email.
I tried the following inside my .emacs (binded to C-q). It works but
kill also the window when inside a terminal. I am not going back to mutt
after writing inside emacs (-nw) and C-q. How can I fix that?
;; Kill the current buffer immediatly, saving it if needed.
(defvar kill-save-buffer-delete-windows t
"*Delete windows when `kill-save-buffer' is used.
If this is non-nil, then `kill-save-buffer' will also delete the corresponding
windows. This is inverted by `kill-save-buffer' when called with a prefix.")
(defun kill-save-buffer (arg)
"Save the current buffer (if needed) and then kill it.
Also, delete its windows according to `kill-save-buffer-delete-windows'.
A prefix argument ARG reverses this behavior."
(let ((del kill-save-buffer-delete-windows))
(when arg (setq del (not del)))
(when (and (buffer-file-name) (not (file-directory-p (buffer-file-name))))
(let ((buf (current-buffer)))
(when del (delete-windows-on buf))
(global-set-key (kbd "C-q") 'kill-save-buffer)