Here is a patch that remove one temp buffer.

it can also be found here: 
http://github.com/vanicat/magit/tree/t/less-tmp-buffer

-- 
Rémi Vanicat
>From ba0705cf9fc0ba93f31968234498fd61835ed068 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9mi=20Vanicat?= <[email protected]>
Date: Sun, 13 Jun 2010 15:16:28 +0200
Subject: [PATCH] We don't need the magit-tmp buffer to stay between its used.

This first rename the buffer to a hidden buffer, and also remove it
after it have been used.
---
 magit.el |   22 ++++++++++++++--------
 1 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/magit.el b/magit.el
index 9717636..49454ad 100644
--- a/magit.el
+++ b/magit.el
@@ -2156,26 +2156,32 @@ in the corresponding directories."
 	  (forward-line))
 	target))))
 
+(defvar magit-tmp-buffer-name " *magit-tmp*")
+
+(defmacro with-magit-tmp-buffer (var &rest body)
+  (declare (indent 1)
+	   (debug (symbolp &rest form)))
+  `(let ((,var (generate-new-buffer magit-tmp-buffer-name)))
+     (unwind-protect
+	  (progn ,@body)
+       (kill-buffer ,var))))
+
 (defun magit-apply-diff-item (diff &rest args)
   (when (zerop magit-diff-context-lines)
     (setq args (cons "--unidiff-zero" args)))
-  (let ((tmp (get-buffer-create "*magit-tmp*")))
-    (with-current-buffer tmp
-      (erase-buffer))
-    (magit-insert-diff-item-patch diff "*magit-tmp*")
+  (with-magit-tmp-buffer tmp
+    (magit-insert-diff-item-patch diff tmp)
     (apply #'magit-run-git-with-input tmp
 	   "apply" (append args (list "-")))))
 
 (defun magit-apply-hunk-item* (hunk reverse &rest args)
   (when (zerop magit-diff-context-lines)
     (setq args (cons "--unidiff-zero" args)))
-  (let ((tmp (get-buffer-create "*magit-tmp*")))
-    (with-current-buffer tmp
-      (erase-buffer))
+  (with-magit-tmp-buffer tmp
     (if (magit-use-region-p)
 	(magit-insert-hunk-item-region-patch
 	 hunk reverse (region-beginning) (region-end) tmp)
-      (magit-insert-hunk-item-patch hunk tmp))
+	(magit-insert-hunk-item-patch hunk tmp))
     (apply #'magit-run-git-with-input tmp
 	   "apply" (append args (list "-")))))
 
-- 
1.7.1

Reply via email to