`C-c c' brings up the template selection.  If you press `C-g' to quit
capturing, the buffer is not deleted.  Instead the old window
configuration is restored and the buffer is the second on the buffer
stack.  `C-x b' switches to the selection buffer again surprisingly.


The appended patch fixes this issue.  Carsten: this patch depends on the
currently undocumented return value of
`org-switch-to-buffer-other-window' (the newly created buffer).  I'd
suggest to either document it (see the second patch) or alter the patch:

   (setq buffer (get-buffer "*Org Select*"))


diff --git a/lisp/org-mks.el b/lisp/org-mks.el
index abf5e79..6700fa2 100644
--- a/lisp/org-mks.el
+++ b/lisp/org-mks.el
@@ -54,9 +54,10 @@ also (\"key\" \"description\") entries.  When they are selected,
 "
   (setq prompt (or prompt "Select: "))
   (let (tbl orig-table dkey ddesc des-keys allowed-keys
-	    current prefix rtn re pressed)
+	    current prefix rtn re pressed buffer)
+    (unwind-protect
     (save-window-excursion
-      (org-switch-to-buffer-other-window "*Org Select*")
+      (setq buffer (org-switch-to-buffer-other-window "*Org Select*"))
       (setq orig-table table)
       (catch 'exit
 	(while t
@@ -121,7 +122,7 @@ also (\"key\" \"description\") entries.  When they are selected,
 			   nil))
 		       table))
 	  (setq table (remove nil table)))))
-    (kill-buffer "*Org Select*")
+    (when buffer (kill-buffer "*Org Select*")))
     rtn))
 
 (provide 'org-mks)
diff --git a/lisp/org.el b/lisp/org.el
index 7bb4f45..517f782 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -18143,7 +18143,8 @@ return nil."
 
 (defun org-switch-to-buffer-other-window (&rest args)
   "Switch to buffer in a second window on the current frame.
-In particular, do not allow pop-up frames."
+In particular, do not allow pop-up frames.
+Returns the newly created buffer."
   (let (pop-up-frames special-display-buffer-names special-display-regexps
 		      special-display-function)
     (apply 'switch-to-buffer-other-window args)))

Best wishes

  Sebastian


_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

Reply via email to