Browse Source

Clean up when aborting capture template selection

* lisp/org.el (org-switch-to-buffer-other-window): Return the buffer.

Patch by Sebastian Rose.
Carsten Dominik 15 years ago
parent
commit
bbfca4a0e4
2 changed files with 10 additions and 9 deletions
  1. 8 8
      lisp/org-mks.el
  2. 2 1
      lisp/org.el

+ 8 - 8
lisp/org-mks.el

@@ -48,15 +48,13 @@ under this key will be shown and offered for selection.
 
 TITLE will be placed over the selection in the temporary buffer,
 PROMPT will be used when prompting for a key.  SPECIAL is an alist with
-also (\"key\" \"description\") entries.  When they are selected, 
-
-
-"
+also (\"key\" \"description\") entries.  When one of these is selection,
+only the bare key is returned."
   (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 (inhibit-quit t))
     (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
@@ -104,7 +102,9 @@ also (\"key\" \"description\") entries.  When they are selected,
 	    (message "Invalid key `%s'" pressed) (sit-for 1)
 	    (message prompt)
 	    (setq pressed (char-to-string (read-char-exclusive))))
-	  (if (equal pressed "\C-g") (error "Abort"))
+	  (when (equal pressed "\C-g")
+	    (kill-buffer buffer)
+	    (error "Abort"))
 	  (when (and (not (assoc pressed table))
 		     (not (member pressed des-keys))
 		     (assoc pressed specials))
@@ -121,7 +121,7 @@ also (\"key\" \"description\") entries.  When they are selected,
 			   nil))
 		       table))
 	  (setq table (remove nil table)))))
-    (kill-buffer "*Org Select*")
+    (when buffer (kill-buffer buffer))
     rtn))
 
 (provide 'org-mks)

+ 2 - 1
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)))