From 433463af16f5a6f5b62fec29ad3f25682a72132d Mon Sep 17 00:00:00 2001 From: asok Date: Mon, 18 May 2015 15:53:05 +0200 Subject: [PATCH] Add variable `peep-dired-cleanup-eagerly` Closes #4 --- peep-dired.el | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/peep-dired.el b/peep-dired.el index 39ca959..1349ecf 100644 --- a/peep-dired.el +++ b/peep-dired.el @@ -51,6 +51,11 @@ :group 'peep-dired :type 'boolean) +(defcustom peep-dired-cleanup-eagerly nil + "Cleanup opened buffers upon `peep-dired-next-file' & `peep-dired-prev-file'" + :group 'peep-dired + :type 'boolean) + (defcustom peep-dired-enable-on-directories t "When t it will enable the mode when visiting directories" :group 'peep-dired @@ -59,12 +64,16 @@ (defun peep-dired-next-file () (interactive) (dired-next-line 1) - (peep-dired-display-file-other-window)) + (peep-dired-display-file-other-window) + (when peep-dired-cleanup-eagerly + (peep-dired-cleanup))) (defun peep-dired-prev-file () (interactive) (dired-previous-line 1) - (peep-dired-display-file-other-window)) + (peep-dired-display-file-other-window) + (when peep-dired-cleanup-eagerly + (peep-dired-cleanup))) (defun peep-dired-kill-buffers-without-window () "Will kill all peep buffers that are not displayed in any window" @@ -102,6 +111,10 @@ (interactive) (scroll-other-window '-)) +(defun peep-dired-cleanup () + (mapc 'kill-buffer-if-not-modified peep-dired-peeped-buffers) + (setq peep-dired-peeped-buffers ())) + (defun peep-dired-disable () (let ((current-point (point))) (jump-to-register :peep_dired_before)