diff --git a/lisp/ol.el b/lisp/ol.el index 1a6a84447..d8a9b92ad 100644 --- a/lisp/ol.el +++ b/lisp/ol.el @@ -2040,8 +2040,11 @@ non-interactively, don't allow to edit the default description." (setq link (substring link 0 -1)))) (setq link (with-current-buffer origbuf (org-link--try-special-completion link))))) + (when-let ((window (get-buffer-window "*Org Links*" t))) + (quit-window 'kill window)) (set-window-configuration wcf) - (kill-buffer "*Org Links*")) + (when (get-buffer "*Org Links*") + (kill-buffer "*Org Links*"))) (setq entry (assoc link org-stored-links)) (or entry (push link org-link--insert-history)) (setq desc (or desc (nth 1 entry))))) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index fcf6eff71..638f483a1 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -3312,7 +3312,7 @@ s Search for keywords S Like s, but only TODO entries ((equal c ?q) (user-error "Abort")) (t (user-error "Invalid key %c" c)))) ;; Close *Agenda Commands* window. - (quit-window)))))) + (quit-window 'kill)))))) (defun org-agenda-fit-window-to-buffer () "Fit the window to the buffer size." diff --git a/lisp/org-attach.el b/lisp/org-attach.el index c2b2e1fb2..8a1b59761 100644 --- a/lisp/org-attach.el +++ b/lisp/org-attach.el @@ -350,13 +350,16 @@ Shows a list of commands and prompts for another key to execute a command." "\n")))) (goto-char (point-min))) (org-fit-window-to-buffer (get-buffer-window "*Org Attach*")) - (let ((msg (format "Select command: [%s]" - (concat (mapcar #'caar org-attach-commands))))) - (message msg) - (while (and (setq c (read-char-exclusive)) - (memq c '(?\C-n ?\C-p ?\C-v ?\M-v))) - (org-scroll c t))) - (and (get-buffer "*Org Attach*") (kill-buffer "*Org Attach*")))) + (unwind-protect + (let ((msg (format "Select command: [%s]" + (concat (mapcar #'caar org-attach-commands))))) + (message msg) + (while (and (setq c (read-char-exclusive)) + (memq c '(?\C-n ?\C-p ?\C-v ?\M-v))) + (org-scroll c t))) + (when-let ((window (get-buffer-window "*Org Attach*" t))) + (quit-window 'kill window)) + (and (get-buffer "*Org Attach*") (kill-buffer "*Org Attach*"))))) (let ((command (cl-some (lambda (entry) (and (memq c (nth 0 entry)) (nth 1 entry))) org-attach-commands))) diff --git a/lisp/org-clock.el b/lisp/org-clock.el index 63c496778..65a54579a 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -695,8 +695,11 @@ there is no recent clock to choose from." ;; `fit-window-to-buffer' (fit-window-to-buffer nil nil (if (< chl 10) chl (+ 5 chl))) (message (or prompt "Select task for clocking:")) - (setq cursor-type nil rpl (read-char-exclusive)) - (kill-buffer) + (unwind-protect (setq cursor-type nil rpl (read-char-exclusive)) + (when-let ((window (get-buffer-window "*Clock Task Select*" t))) + (quit-window 'kill window)) + (when (get-buffer "*Clock Task Select*") + (kill-buffer "*Clock Task Select*"))) (cond ((eq rpl ?q) nil) ((eq rpl ?x) nil) diff --git a/lisp/org-goto.el b/lisp/org-goto.el index c1b3a3c0b..94b709fc6 100644 --- a/lisp/org-goto.el +++ b/lisp/org-goto.el @@ -238,8 +238,10 @@ position or nil." (let (org-special-ctrl-a/e) (org-beginning-of-line)) (message "Select location and press RET") (use-local-map org-goto-map) - (recursive-edit))) - (kill-buffer "*org-goto*") + (unwind-protect (recursive-edit) + (when-let ((window (get-buffer-window "*Org Help*" t))) + (quit-window 'kill window))))) + (when (get-buffer "*org-goto*") (kill-buffer "*org-goto*")) (cons org-goto-selected-point org-goto-exit-command))) ;;;###autoload diff --git a/lisp/org-macs.el b/lisp/org-macs.el index c0332e068..1254ddb54 100644 --- a/lisp/org-macs.el +++ b/lisp/org-macs.el @@ -572,8 +572,10 @@ is selected, only the bare key is returned." ;; selection prefix. ((assoc current specials) (throw 'exit current)) (t (error "No entry available"))))))) - (quit-window) - (when buffer (kill-buffer buffer)))))) + (when buffer + (when-let ((window (get-buffer-window buffer t))) + (quit-window 'kill window)) + (kill-buffer buffer)))))) ;;; List manipulation diff --git a/lisp/org-table.el b/lisp/org-table.el index bd8d59f45..535d1b44c 100644 --- a/lisp/org-table.el +++ b/lisp/org-table.el @@ -3369,7 +3369,10 @@ Parameters get priority." (titles '((column . "# Column Formulas\n") (field . "# Field and Range Formulas\n") (named . "# Named Field Formulas\n")))) - (switch-to-buffer-other-window "*Edit Formulas*") + (let ((pop-up-frames nil)) + ;; We explicitly prohibit creating edit buffer in a new frame + ;; - such configuration is not supported. + (switch-to-buffer-other-window "*Edit Formulas*")) (erase-buffer) ;; Keep global-font-lock-mode from turning on font-lock-mode (let ((font-lock-global-modes '(not fundamental-mode))) @@ -3690,7 +3693,9 @@ With prefix ARG, apply the new formulas to the table." (org-table-store-formulas eql) (set-marker pos nil) (set-marker source nil) - (kill-buffer "*Edit Formulas*") + (when-let ((window (get-buffer-window "*Edit Formulas*" t))) + (quit-window 'kill window)) + (when (get-buffer "*Edit Formulas*") (kill-buffer "*Edit Formulas*")) (if arg (org-table-recalculate 'all) (message "New formulas installed - press C-u C-c C-c to apply.")))) diff --git a/lisp/org.el b/lisp/org.el index d9d4290e9..1e5e1621d 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -8788,6 +8788,8 @@ there is one, return it." (org-fit-window-to-buffer (get-buffer-window "*Select Link*")) (message "Select link to open, RET to open all:") (unwind-protect (setq c (read-char-exclusive)) + (and (get-buffer-window "*Select Link*" t) + (quit-window 'kill (get-buffer-window "*Select Link*" t))) (and (get-buffer "*Select Link*") (kill-buffer "*Select Link*"))))) (when (equal c ?q) (user-error "Abort")) (if (equal c ?\C-m) diff --git a/lisp/ox.el b/lisp/ox.el index 95d046bbb..ce0d3a1cb 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -7135,6 +7135,8 @@ asynchronous export stack." (and org-export-in-background 'async)) nil org-export-dispatch-use-expert-ui))) + (and (get-buffer-window "*Org Export Dispatcher*" t) + (quit-window 'kill (get-buffer-window "*Org Export Dispatcher*" t))) (and (get-buffer "*Org Export Dispatcher*") (kill-buffer "*Org Export Dispatcher*")))))) (action (car input))