[OS X Emacs] "with-current-buffer" issues
david.reitter at gmail.com
Thu Jun 24 17:21:56 EDT 2010
On Jun 24, 2010, at 2:28 AM, James Harkins wrote:
> The problem is when a buffer gets killed. There's a hook to close the document:
> (defun sclang-document-kill-buffer-hook-function ()
> (sclang-close-document (current-buffer)))
> I'm observing that the main body of sclang-close-document is running every time a buffer is killed, even if the buffer should not be associated with a sclang-document. The result is that Document objects are being closed in the sclang interpreter even though their buffers still exist in Emacs.
I think I figured out what the problem is, and the patch below should address this.
Could you try it out?
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 5413bb5..d4987e1 100644
@@ -672,7 +672,9 @@ even if it's the only visible frame."
;; do not delete the last visible frame if there are others hidden:
;; doing so prevents Aquamacs from receiving keyboard input (NS problem?)
- (progn (delete-frame (or frame (selected-frame)))
+ (progn (with-current-buffer (current-buffer) ; delete-frame changes current buffer
+ ;; current buffer must be preserved (e.g., for other kill-buffer-hook functions)
+ (delete-frame (or frame (selected-frame))))
(unless (visible-frame-list) ;; delete-frame may succeed if iconified frames are around
@@ -695,8 +697,7 @@ even if it's the only visible frame."
(select-window (frame-first-window hf))
(switch-to-buffer hb 'norecord)
(make-frame-visible hf) ; HACK: must do this first, presumably to convince NS to make it key.
- (make-frame-invisible hf t)))))
+ (make-frame-invisible hf t)))))))))
(defun aquamacs-handle-frame-iconified (&optional frame)
More information about the MacOSX-Emacs