From 089903a29936f00d76fd7bf082603c2dff242a5c Mon Sep 17 00:00:00 2001 From: Achim Gratz Date: Thu, 20 Dec 2012 10:18:02 +0100 Subject: [PATCH] org-compat: new macro org-suppress-popups MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * lisp/org-compat.el (org-suppress-popups): New wrapper macro, let-binds the correct variables to suppress popup windows depending on Emacs version. * lisp/org.el (org-get-location, org-switch-to-buffer-other-window): Use the wrapper `org-suppress-popupsĀ“ to let-bind variables that are version-dependent. --- lisp/org-compat.el | 7 +++++ lisp/org.el | 86 ++++++++++++++++++++++++++---------------------------- 2 files changed, 48 insertions(+), 45 deletions(-) diff --git a/lisp/org-compat.el b/lisp/org-compat.el index 1f330b1..e8983f0 100644 --- a/lisp/org-compat.el +++ b/lisp/org-compat.el @@ -375,6 +375,13 @@ (defun org-float-time (&optional time) (unless (fboundp 'user-error) (defalias 'user-error 'error)) +(defmacro org-suppress-popups (&rest body) + (if (org-version-check "24.2.50" "" :predicate) + `(let (pop-up-frames display-buffer-alist) + ,@body) + `(let (pop-up-frames special-display-buffer-names special-display-regexps special-display-function) + ,@body))) + (if (fboundp 'string-match-p) (defalias 'org-string-match-p 'string-match-p) (defun org-string-match-p (regexp string &optional start) diff --git a/lisp/org.el b/lisp/org.el index e93356c..67fb8ed 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -6982,48 +6982,45 @@ (defun org-get-location (buf help) "Let the user select a location in the Org-mode buffer BUF. This function uses a recursive edit. It returns the selected position or nil." - (let ((isearch-mode-map org-goto-local-auto-isearch-map) - (isearch-hide-immediately nil) - (isearch-search-fun-function - (lambda () 'org-goto-local-search-headings)) - (org-goto-selected-point org-goto-exit-command) - (pop-up-frames nil) - (special-display-buffer-names nil) - (special-display-regexps nil) - (special-display-function nil)) - (save-excursion - (save-window-excursion - (delete-other-windows) - (and (get-buffer "*org-goto*") (kill-buffer "*org-goto*")) - (org-pop-to-buffer-same-window - (condition-case nil - (make-indirect-buffer (current-buffer) "*org-goto*") - (error (make-indirect-buffer (current-buffer) "*org-goto*")))) - (with-output-to-temp-buffer "*Help*" - (princ help)) - (org-fit-window-to-buffer (get-buffer-window "*Help*")) - (setq buffer-read-only nil) - (let ((org-startup-truncated t) - (org-startup-folded nil) - (org-startup-align-all-tables nil)) - (org-mode) - (org-overview)) - (setq buffer-read-only t) - (if (and (boundp 'org-goto-start-pos) - (integer-or-marker-p org-goto-start-pos)) - (let ((org-show-hierarchy-above t) - (org-show-siblings t) - (org-show-following-heading t)) - (goto-char org-goto-start-pos) - (and (outline-invisible-p) (org-show-context))) - (goto-char (point-min))) - (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*") - (cons org-goto-selected-point org-goto-exit-command))) + (org-suppress-popups + (let ((isearch-mode-map org-goto-local-auto-isearch-map) + (isearch-hide-immediately nil) + (isearch-search-fun-function + (lambda () 'org-goto-local-search-headings)) + (org-goto-selected-point org-goto-exit-command)) + (save-excursion + (save-window-excursion + (delete-other-windows) + (and (get-buffer "*org-goto*") (kill-buffer "*org-goto*")) + (org-pop-to-buffer-same-window + (condition-case nil + (make-indirect-buffer (current-buffer) "*org-goto*") + (error (make-indirect-buffer (current-buffer) "*org-goto*")))) + (with-output-to-temp-buffer "*Help*" + (princ help)) + (org-fit-window-to-buffer (get-buffer-window "*Help*")) + (setq buffer-read-only nil) + (let ((org-startup-truncated t) + (org-startup-folded nil) + (org-startup-align-all-tables nil)) + (org-mode) + (org-overview)) + (setq buffer-read-only t) + (if (and (boundp 'org-goto-start-pos) + (integer-or-marker-p org-goto-start-pos)) + (let ((org-show-hierarchy-above t) + (org-show-siblings t) + (org-show-following-heading t)) + (goto-char org-goto-start-pos) + (and (outline-invisible-p) (org-show-context))) + (goto-char (point-min))) + (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*") + (cons org-goto-selected-point org-goto-exit-command)))) (defvar org-goto-local-auto-isearch-map (make-sparse-keymap)) (set-keymap-parent org-goto-local-auto-isearch-map isearch-mode-map) @@ -20967,9 +20964,8 @@ (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. 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))) + (org-suppress-popups + (apply 'switch-to-buffer-other-window args))) (defun org-combine-plists (&rest plists) "Create a single property list from all plists in PLISTS. -- 1.8.0.1