On 2013-03-08, Sanel Zukan <[email protected]> wrote:
Hi all,
I'm just curious how do you guys handle this case? I often have screen split with a couple of buffers and when I delete one of them, split got messed up.
Vim have one cool trick for this: ':bp|bd #' and evil will only execute ':bp' part. Is it hard to add similar feature (this looks to me like piping the commands) or Emacs has something better under the belt?
The simplest approach is probably (evil-ex-define-cmd "bd[elete]" 'kill-buffer) i.e. the same C-x k. A little bit more sophisticated is (evil-define-command evil-delete-buffer-keep-windows (buffer &optional bang) (interactive "<b><!>") (with-current-buffer (or buffer (current-buffer)) (when bang (set-buffer-modified-p nil) (dolist (process (process-list)) (when (eq (process-buffer process) (current-buffer)) (set-process-query-on-exit-flag process nil)))) (if (and (fboundp 'server-edit) (boundp 'server-buffer-clients) server-buffer-clients) (server-edit) (kill-buffer nil)))) (evil-ex-define-cmd "bd[elete]" 'evil-delete-buffer-keep-windows) This function is exactly the same as `evil-delete-buffer` with the code that closes the windows deleted. Maybe we could add another parameter that determines whether the windows should be closed and defaults to some customization option. Frank