Kill current buffer. Switch to next buffer if previous command was switching
authorOleksandr Gavenko <gavenkoa@gmail.com>
Fri, 11 Apr 2014 12:02:49 +0300
changeset 1135 b6dcbd747884
parent 1134 d91fa7f7033a
child 1136 26996dddc80f
Kill current buffer. Switch to next buffer if previous command was switching to next buffer or this command itself allowing sequential closing of uninteresting buffers."
.emacs-my
--- a/.emacs-my	Thu Apr 10 18:14:08 2014 +0300
+++ b/.emacs-my	Fri Apr 11 12:02:49 2014 +0300
@@ -813,7 +813,16 @@
 (global-set-key [?\C-x right] 'next-buffer)
 (global-set-key [?\C-x left]  'previous-buffer)
 (global-set-key (kbd "C-x C-k") 'kill-this-buffer)
-(global-set-key [?\C-x deletechar] 'kill-this-buffer)
+(defun my-kill-this-buffer-maybe-switch-to-next ()
+  "Kill current buffer. Switch to next buffer if previous command
+was switching to next buffer or this command itself allowing
+sequential closing of uninteresting buffers."
+  (interactive)
+  (let ( (cmd last-command) )
+    (kill-this-buffer)
+    (when (memq cmd (list 'next-buffer this-command))
+      (next-buffer))))
+(global-set-key [?\C-x deletechar] 'my-kill-this-buffer-maybe-switch-to-next)
 (global-set-key [?\C-x up] '(lambda ()
                               (interactive)
                               (other-window -1)))