[OS X Emacs] "with-current-buffer" issues

David Reitter david.reitter at gmail.com
Thu Jun 24 22:57:48 EDT 2010


On Jun 24, 2010, at 9:01 PM, James Harkins wrote:

> On 6/25/10 5:21 AM, David Reitter wrote:
>> I think I figured out what the problem is, and the patch below should address this.
>> Could you try it out?
>>   
> 
> Hmm... I'm on aquamacs 1.9, can't find that bit in one-buffer-one-frame.el.

Ah, so we need to fix that in the 1.x series as well.  The patch is below.  Please let me know if it works well.

> But, usually I have several buffers in the same frame so, is one-buffer-one-frame relevant?

Yes, one-buffer-one-frame.el, apart from providing this mode, does much of Aquamacs' frame handling.

- David

--
http://aquamacs.org -- Aquamacs: Emacs on Mac OS X
http://aquamacs.org/donate -- Could we help you? Return the favor and support the Aquamacs Project!



diff --git a/aquamacs/src/site-lisp/one-buffer-one-frame.el b/aquamacs/src/site-lisp/one-buffer-one-frame.el
index d1b7a80..95a3bcb 100644
--- a/aquamacs/src/site-lisp/one-buffer-one-frame.el
+++ b/aquamacs/src/site-lisp/one-buffer-one-frame.el
@@ -629,16 +629,18 @@ even if it's the only visible frame."
       (delete-window-if-created-for-buffer)))
 
 (defun aquamacs-delete-frame (&optional frame)
-  (condition-case nil 
-      (delete-frame (or frame (selected-frame)))
-    (error   
-     (let ((f (or frame (selected-frame))))
-       (run-hook-with-args 'delete-frame-functions f)
-       (make-frame-invisible f t)
-       ;; select messages to it gets any input
-       (if (find-all-frames-internal (get-buffer "*Messages*"))
-	   (select-frame (car (find-all-frames-internal 
-			       (get-buffer "*Messages*"))))))))) 
+  (with-current-buffer (current-buffer) ; delete-frame changes current buffer
+    ;; current buffer must be preserved (e.g., for other kill-buffer-hook functions)
+    (condition-case nil 
+	(delete-frame (or frame (selected-frame)))
+      (error   
+       (let ((f (or frame (selected-frame))))
+	 (run-hook-with-args 'delete-frame-functions f)
+	 (make-frame-invisible f t)
+	 ;; select messages to it gets any input
+	 (if (find-all-frames-internal (get-buffer "*Messages*"))
+	     (select-frame (car (find-all-frames-internal 
+				 (get-buffer "*Messages*"))))))))))
 
 ;; delete window when buffer is killed
 ;; but only do so if aquamacs opened a new frame&window for





More information about the MacOSX-Emacs mailing list