ソースを参照

Fix (a lot of) compiler warnings.

Also introduce `org-pop-to-buffer-same-window' as a compatibility
function for Emacs =>24.1.
Bastien Guerry 13 年 前
コミット
5c53026d32

+ 3 - 3
contrib/lisp/org-drill.el

@@ -621,7 +621,7 @@ situation use `org-part-of-drill-entry-p'."
 
 
 (defun org-drill-goto-entry (marker)
-  (switch-to-buffer (marker-buffer marker))
+  (org-pop-to-buffer-same-window (marker-buffer marker))
   (goto-char marker))
 
 
@@ -2602,7 +2602,7 @@ the tag 'imported'."
           (unless path
             (setq path (org-get-outline-path)))
           (org-copy-subtree)
-          (switch-to-buffer dest)
+          (org-pop-to-buffer-same-window dest)
           (setq m
                 (condition-case nil
                     (org-find-olp path t)
@@ -2684,7 +2684,7 @@ copy them across."
                        scheduled-time (org-get-scheduled-time (point)))
                  (save-excursion
                    ;; go to matching entry in destination buffer
-                   (switch-to-buffer (marker-buffer marker))
+                   (org-pop-to-buffer-same-window (marker-buffer marker))
                    (goto-char marker)
                    (org-drill-strip-entry-data)
                    (unless (zerop total-repeats)

+ 1 - 1
contrib/lisp/org-eshell.el

@@ -42,7 +42,7 @@
          (eshell-buffer-name (car buffer-and-command))
          (command (cadr buffer-and-command)))
      (if (get-buffer eshell-buffer-name)
-       (switch-to-buffer eshell-buffer-name)
+       (org-pop-to-buffer-same-window eshell-buffer-name)
        (eshell))
      (end-of-buffer)
      (eshell-kill-input)

+ 1 - 1
contrib/lisp/org-mac-iCal.el

@@ -126,7 +126,7 @@ the the Emacs diary"
   (setq usedCalendarsFiles (directory-files "~/Library/Calendars" 1 ".*ics$"))
   (omi-delete-ics-file usedCalendarsFiles)
 
-  (switch-to-buffer currentBuffer))
+  (org-pop-to-buffer-same-window currentBuffer))
 
 (defun omi-concat-leopard-ics (list)
   "Leopard stores each iCal.app event in a separate ics file.

+ 2 - 2
contrib/lisp/org-screen.el

@@ -96,8 +96,8 @@ is copied from ansi-term method."
   (let ((screen-buffer-name (org-screen-buffer-name name)))
     (if (member screen-buffer-name
                 (mapcar 'buffer-name (buffer-list)))
-        (switch-to-buffer screen-buffer-name)
-      (switch-to-buffer (org-screen-helper name "-dr")))))
+        (org-pop-to-buffer-same-window screen-buffer-name)
+      (org-pop-to-buffer-same-window (org-screen-helper name "-dr")))))
 
 (if org-link-abbrev-alist
     (add-to-list 'org-link-abbrev-alist

+ 5 - 5
contrib/lisp/org-toc.el

@@ -220,7 +220,7 @@ specified, then make `org-toc-recenter' use this value."
       (progn (setq org-toc-base-buffer (current-buffer))
 	     (setq org-toc-odd-levels-only org-odd-levels-only))
     (if (eq major-mode 'org-toc-mode)
-	(switch-to-buffer org-toc-base-buffer)
+	(org-pop-to-buffer-same-window org-toc-base-buffer)
       (error "Not in an Org buffer")))
   ;; create the new window display
   (let ((pos (or position
@@ -342,13 +342,13 @@ If DELETE is non-nil, delete other windows when in the Org buffer."
   "Toggle columns view in the Org buffer from Org TOC."
   (interactive)
   (let ((indirect-buffer (current-buffer)))
-    (switch-to-buffer org-toc-base-buffer)
+    (org-pop-to-buffer-same-window org-toc-base-buffer)
     (if (not org-toc-columns-shown)
 	(progn (org-columns)
 	       (setq org-toc-columns-shown t))
       (progn (org-columns-remove-overlays)
 	     (setq org-toc-columns-shown nil)))
-    (switch-to-buffer indirect-buffer)))
+    (org-pop-to-buffer-same-window indirect-buffer)))
 
 (defun org-toc-info ()
   "Show properties of current subtree in the echo-area."
@@ -356,7 +356,7 @@ If DELETE is non-nil, delete other windows when in the Org buffer."
   (let ((pos (point))
 	(indirect-buffer (current-buffer))
 	props prop msg)
-    (switch-to-buffer org-toc-base-buffer)
+    (org-pop-to-buffer-same-window org-toc-base-buffer)
     (goto-char pos)
     (setq props (org-entry-properties))
     (while (setq prop (pop props))
@@ -369,7 +369,7 @@ If DELETE is non-nil, delete other windows when in the Org buffer."
 	  (setq p (concat p ":"))
 	  (add-text-properties 0 (length p) '(face org-special-keyword) p)
 	  (setq msg (concat msg p " " v "  ")))))
-    (switch-to-buffer indirect-buffer)
+    (org-pop-to-buffer-same-window indirect-buffer)
     (message msg)))
 
 ;;; Store and restore TOC configuration:

+ 2 - 2
contrib/lisp/org-velocity.el

@@ -279,7 +279,7 @@ If there is no last heading, return nil."
          (org-velocity-edit-entry ',heading)
        (progn
          (message "%s" ,(org-velocity-heading-name heading))
-         (switch-to-buffer (marker-buffer
+         (org-pop-to-buffer-same-window (marker-buffer
                             ,(org-velocity-heading-marker heading)))
          (goto-char (marker-position
                      ,(org-velocity-heading-marker heading)))))))
@@ -681,7 +681,7 @@ Use method specified by `org-velocity-search-method'."
 		   (read-string prompt))))
            (remove-hook 'post-command-hook
                         'org-velocity-display-for-incremental))))
-    (if (bufferp res) (switch-to-buffer res) res)))
+    (if (bufferp res) (org-pop-to-buffer-same-window res) res)))
 
 (defun org-velocity-read (arg &optional search)
   "Read a search string SEARCH for Org-Velocity interface.

+ 1 - 1
contrib/lisp/org-wikinodes.el

@@ -155,7 +155,7 @@ setting of `org-wikinodes-create-targets'."
        ((stringp create)
 	;; Make new node in another file
 	(org-mark-ring-push (point))
-	(switch-to-buffer (find-file-noselect create))
+	(org-pop-to-buffer-same-window (find-file-noselect create))
 	(goto-char (point-max))
 	(or (bolp) (newline))
 	(insert "\n* " target "\n")

+ 1 - 1
contrib/lisp/org-xhtml.el

@@ -943,7 +943,7 @@ that uses these same face definitions."
 	(when (and (symbolp f) (or (not i) (not (listp i))))
 	  (insert (org-add-props (copy-sequence "1") nil 'face f))))
       (htmlize-region (point-min) (point-max))))
-  (switch-to-buffer "*html*")
+  (org-pop-to-buffer-same-window "*html*")
   (goto-char (point-min))
   (if (re-search-forward "<style" nil t)
       (delete-region (point-min) (match-beginning 0)))

+ 1 - 1
contrib/lisp/test-org-export-preproc.el

@@ -33,7 +33,7 @@
 		  (plist-get export-plist :archived-trees-export)
 		  :add-text (plist-get opt-plist :text)))))
     (save-excursion
-      (switch-to-buffer "*preproc-temp*")
+      (org-pop-to-buffer-same-window "*preproc-temp*")
       (point-max)
       (insert string))))
 

+ 3 - 1
lisp/ob-ref.el

@@ -60,6 +60,8 @@
 (declare-function org-narrow-to-subtree "org" ())
 (declare-function org-id-find-id-in-file "org-id" (id file &optional markerp))
 (declare-function org-show-context "org" (&optional key))
+(declare-function org-pop-to-buffer-same-window 
+		  "org-compat" (&optional buffer-or-name norecord label))
 
 (defvar org-babel-ref-split-regexp
   "[ \f\t\n\r\v]*\\(.+?\\)[ \f\t\n\r\v]*=[ \f\t\n\r\v]*\\(.+\\)[ \f\t\n\r\v]*")
@@ -93,7 +95,7 @@ the variable."
 	       (m (when file (org-id-find-id-in-file id file 'marker))))
 	  (when (and file m)
 	    (message "file:%S" file)
-	    (switch-to-buffer (marker-buffer m))
+	    (org-pop-to-buffer-same-window (marker-buffer m))
 	    (goto-char m)
 	    (move-marker m nil)
 	    (org-show-context)

+ 6 - 3
lisp/org-agenda.el

@@ -61,6 +61,9 @@
 (declare-function org-is-habit-p "org-habit" (&optional pom))
 (declare-function org-habit-parse-todo "org-habit" (&optional pom))
 (declare-function org-habit-get-priority "org-habit" (habit &optional moment))
+(declare-function org-pop-to-buffer-same-window "org-compat" 
+		  (&optional buffer-or-name norecord label))
+
 (defvar calendar-mode-map)
 (defvar org-clock-current-task) ; defined in org-clock.el
 (defvar org-mobile-force-id-on-agenda-items) ; defined in org-mobile.el
@@ -3071,7 +3074,7 @@ the global options and expect it to be applied to the entire view.")
        (awin (select-window awin))
        ((not (setq org-pre-agenda-window-conf (current-window-configuration))))
        ((equal org-agenda-window-setup 'current-window)
-	(switch-to-buffer abuf))
+	(org-pop-to-buffer-same-window abuf))
        ((equal org-agenda-window-setup 'other-window)
 	(org-switch-to-buffer-other-window abuf))
        ((equal org-agenda-window-setup 'other-frame)
@@ -3082,7 +3085,7 @@ the global options and expect it to be applied to the entire view.")
       ;; additional test in case agenda is invoked from within agenda
       ;; buffer via elisp link
       (unless (equal (current-buffer) abuf)
-	(switch-to-buffer abuf)))
+	(org-pop-to-buffer-same-window abuf)))
     (setq buffer-read-only nil)
     (let ((inhibit-read-only t)) (erase-buffer))
     (org-agenda-mode)
@@ -6973,7 +6976,7 @@ at the text of the entry itself."
 		       (org-agenda-error)))
 	   (buffer (marker-buffer marker))
 	   (pos (marker-position marker)))
-      (switch-to-buffer buffer)
+      (org-pop-to-buffer-same-window buffer)
       (and delete-other-windows (delete-other-windows))
       (widen)
       (goto-char pos)

+ 5 - 2
lisp/org-capture.el

@@ -57,6 +57,9 @@
 		  (date &optional keep-restriction))
 (declare-function org-table-get-specials "org-table" ())
 (declare-function org-table-goto-line "org-table" (N))
+(declare-function org-pop-to-buffer-same-window "org-compat" 
+		  (&optional buffer-or-name norecord label))
+
 (defvar org-remember-default-headline)
 (defvar org-remember-templates)
 (defvar org-table-hlines)
@@ -1193,7 +1196,7 @@ The user is queried for the template."
       (error "No capture template selected"))
     (org-capture-set-plist entry)
     (org-capture-set-target-location)
-    (switch-to-buffer (org-capture-get :buffer))
+    (org-pop-to-buffer-same-window (org-capture-get :buffer))
     (goto-char (org-capture-get :pos))))
 
 (defun org-capture-get-indirect-buffer (&optional buffer prefix)
@@ -1303,7 +1306,7 @@ The template may still contain \"%?\" for cursor positioning."
 	    (sit-for 1))
     (save-window-excursion
       (delete-other-windows)
-      (switch-to-buffer (get-buffer-create "*Capture*"))
+      (org-pop-to-buffer-same-window (get-buffer-create "*Capture*"))
       (erase-buffer)
       (insert template)
       (goto-char (point-min))

+ 2 - 1
lisp/org-clock.el

@@ -37,6 +37,7 @@
 
 (declare-function calendar-absolute-from-iso "cal-iso" (&optional date))
 (declare-function notifications-notify "notifications" (&rest params))
+(declare-function org-pop-to-buffer-same-window "org-compat" (&optional buffer-or-name norecord label))
 (defvar org-time-stamp-formats)
 (defvar org-ts-what)
 
@@ -1498,7 +1499,7 @@ With prefix arg SELECT, offer recently clocked tasks for selection."
 	      (setq recent t)
 	      (car org-clock-history))
 	     (t (error "No active or recent clock task")))))
-    (switch-to-buffer (marker-buffer m))
+    (org-pop-to-buffer-same-window (marker-buffer m))
     (if (or (< m (point-min)) (> m (point-max))) (widen))
     (goto-char m)
     (org-show-entry)

+ 9 - 0
lisp/org-compat.el

@@ -433,6 +433,15 @@ With two arguments, return floor and remainder of their quotient."
   (let ((q (floor x y)))
     (list q (- x (if y (* y q) q)))))
 
+;; `pop-to-buffer-same-window' has been introduced with Emacs 24.1.
+(defun org-pop-to-buffer-same-window
+  (&optional buffer-or-name norecord label)
+  "Pop to buffer specified by BUFFER-OR-NAME in the selected window."
+  (if (fboundp 'pop-to-buffer-same-window)
+      (funcall
+       'pop-to-buffer-same-window buffer-or-name norecord label)
+    (funcall 'switch-to-buffer buffer-or-name norecord)))
+
 (provide 'org-compat)
 
 ;; arch-tag: a0a0579f-e68c-4bdf-9e55-93768b846bbe

+ 3 - 1
lisp/org-ctags.el

@@ -140,6 +140,8 @@
 
 (require 'org)
 
+(declare-function org-pop-to-buffer-same-window "org-compat" (&optional buffer-or-name norecord label))
+
 (defgroup org-ctags nil
   "Options concerning use of ctags within org mode."
   :tag "Org-Ctags"
@@ -385,7 +387,7 @@ the new file."
     (cond
      ((get-buffer (concat name ".org"))
       ;; Buffer is already open
-      (switch-to-buffer (get-buffer (concat name ".org"))))
+      (org-pop-to-buffer-same-window (get-buffer (concat name ".org"))))
      ((file-exists-p filename)
       ;; File exists but is not open --> open it
       (message "Opening existing org file `%S'..."

+ 10 - 7
lisp/org-exp.el

@@ -48,6 +48,9 @@
 (declare-function org-inlinetask-remove-END-maybe "org-inlinetask" ())
 (declare-function org-table-cookie-line-p "org-table" (line))
 (declare-function org-table-colgroup-line-p "org-table" (line))
+(declare-function org-pop-to-buffer-same-window "org-compat" 
+		  (&optional buffer-or-name norecord label))
+
 (autoload 'org-export-generic "org-export-generic" "Export using the generic exporter" t)
 
 (autoload 'org-export-as-odt "org-odt"
@@ -1633,9 +1636,9 @@ from the buffer."
 
 (defun org-export-protect-quoted-subtrees ()
   "Mark quoted subtrees with the protection property."
-  (let ((re-quote (concat "^\\*+[ \t]+" org-quote-string "\\>")))
+  (let ((org-re-quote (concat "^\\*+[ \t]+" org-quote-string "\\>")))
     (goto-char (point-min))
-    (while (re-search-forward re-quote nil t)
+    (while (re-search-forward org-re-quote nil t)
       (goto-char (match-beginning 0))
       (end-of-line 1)
       (add-text-properties (point) (org-end-of-subtree t)
@@ -1934,9 +1937,9 @@ table line.  If it is a link, add it to the line containing the link."
       (goto-char (match-beginning 0))
       (delete-region (point) (org-end-of-subtree t)))))
 
-(defun org-export-handle-comments (commentsp)
+(defun org-export-handle-comments (org-commentsp)
   "Remove comments, or convert to backend-specific format.
-COMMENTSP can be a format string for publishing comments.
+ORG-COMMENTSP can be a format string for publishing comments.
 When it is nil, all comments will be removed."
   (let ((re "^\\(#\\|[ \t]*#\\+ \\)\\(.*\n?\\)")
 	pos)
@@ -1946,12 +1949,12 @@ When it is nil, all comments will be removed."
       (setq pos (match-beginning 0))
       (if (get-text-property pos 'org-protected)
 	  (goto-char (1+ pos))
-	(if (and commentsp
+	(if (and org-commentsp
 		 (not (equal (char-before (match-end 1)) ?+)))
 	    (progn (add-text-properties
 		    (match-beginning 0) (match-end 0) '(org-protected t))
 		   (replace-match (org-add-props
-				      (format commentsp (match-string 2))
+				      (format org-commentsp (match-string 2))
 				      nil 'org-protected t)
 				  t t))
 	  (goto-char (1+ pos))
@@ -2967,7 +2970,7 @@ directory."
 	 (region (buffer-string))
          str-ret)
     (save-excursion
-      (switch-to-buffer buffer)
+      (org-pop-to-buffer-same-window buffer)
       (erase-buffer)
       (insert region)
       (let ((org-inhibit-startup t)) (org-mode))

+ 1 - 1
lisp/org-feed.el

@@ -436,7 +436,7 @@ it can be a list structured like an entry in `org-feed-alist'."
   (if (stringp feed) (setq feed (assoc feed org-feed-alist)))
   (unless feed
     (error "No such feed in `org-feed-alist"))
-  (switch-to-buffer
+  (org-pop-to-buffer-same-window
    (org-feed-update feed 'retrieve-only))
   (goto-char (point-min)))
 

+ 2 - 0
lisp/org-footnote.el

@@ -55,6 +55,8 @@
 (declare-function org-fill-paragraph "org" (&optional justify))
 (declare-function org-export-preprocess-string "org-exp"
 		  (string &rest parameters))
+
+(defvar org-outline-regexp-bol) ; defined in org.el
 (defvar org-odd-levels-only) ;; defined in org.el
 (defvar org-bracket-link-regexp) ; defined in org.el
 (defvar message-signature-separator) ;; defined in message.el

+ 3 - 1
lisp/org-html.el

@@ -35,6 +35,8 @@
 
 (declare-function org-id-find-id-file "org-id" (id))
 (declare-function htmlize-region "ext:htmlize" (beg end))
+(declare-function org-pop-to-buffer-same-window 
+		  "org-compat" (&optional buffer-or-name norecord label))
 
 (defgroup org-export-html nil
   "Options specific for HTML export of Org-mode files."
@@ -2244,7 +2246,7 @@ that uses these same face definitions."
 	(when (and (symbolp f) (or (not i) (not (listp i))))
 	  (insert (org-add-props (copy-sequence "1") nil 'face f))))
       (htmlize-region (point-min) (point-max))))
-  (switch-to-buffer "*html*")
+  (org-pop-to-buffer-same-window "*html*")
   (goto-char (point-min))
   (if (re-search-forward "<style" nil t)
       (delete-region (point-min) (match-beginning 0)))

+ 3 - 1
lisp/org-id.el

@@ -74,6 +74,8 @@
 (require 'org)
 
 (declare-function message-make-fqdn "message" ())
+(declare-function org-pop-to-buffer-same-window 
+		  "org-compat" (&optional buffer-or-name norecord label))
 
 ;;; Customization
 
@@ -253,7 +255,7 @@ Move the cursor to that entry in that buffer."
   (let ((m (org-id-find id 'marker)))
     (unless m
       (error "Cannot find entry with ID \"%s\"" id))
-    (switch-to-buffer (marker-buffer m))
+    (org-pop-to-buffer-same-window (marker-buffer m))
     (goto-char m)
     (move-marker m nil)
     (org-show-context)))

+ 5 - 3
lisp/org-irc.el

@@ -60,6 +60,8 @@
 (declare-function erc-server-buffer "erc" ())
 (declare-function erc-get-server-nickname-list "erc" ())
 (declare-function erc-cmd-JOIN "erc" (channel &optional key))
+(declare-function org-pop-to-buffer-same-window 
+		  "org-compat" (&optional buffer-or-name norecord label))
 
 (defvar org-irc-client 'erc
   "The IRC client to act on.")
@@ -232,7 +234,7 @@ default."
 				      (throw 'found x))))))
 		(if chan-buf
 		    (progn
-		      (switch-to-buffer chan-buf)
+		      (org-pop-to-buffer-same-window chan-buf)
 		      ;; if we got a nick, and they're in the chan,
 		      ;; then start a chat with them
 		      (let ((nick (pop link)))
@@ -243,9 +245,9 @@ default."
 				(insert (concat nick ": ")))
 			      (error "%s not found in %s" nick chan-name)))))
 		    (progn
-		      (switch-to-buffer server-buffer)
+		      (org-pop-to-buffer-same-window server-buffer)
 		      (erc-cmd-JOIN chan-name))))
-	      (switch-to-buffer server-buffer)))
+	      (org-pop-to-buffer-same-window server-buffer)))
 	;; no server match, make new connection
 	(erc-select :server server :port port))))
 

+ 2 - 2
lisp/org-latex.el

@@ -75,8 +75,8 @@
 	  org-closed-string"\\)")
   "Regexp matching special time planning keywords plus the time after it.")
 
-(defvar re-quote)  ; dynamically scoped from org.el
-(defvar commentsp) ; dynamically scoped from org.el
+(defvar org-re-quote)  ; dynamically scoped from org.el
+(defvar org-commentsp) ; dynamically scoped from org.el
 
 ;;; User variables:
 

+ 1 - 1
lisp/org-list.el

@@ -76,7 +76,7 @@
 
 ;;; Code:
 
-(eval-when-compile
+(eval-when-compile 
   (require 'cl))
 (require 'org-macs)
 (require 'org-compat)

+ 1 - 0
lisp/org-macs.el

@@ -350,6 +350,7 @@ point nowhere."
   `(let* ((org-outline-regexp (org-get-limited-outline-regexp)))
      ,@body))
 
+(defvar org-outline-regexp) ; defined in org.el
 (defvar org-odd-levels-only) ; defined in org.el
 (defvar org-inlinetask-min-level) ; defined in org-inlinetask.el
 (defun org-get-limited-outline-regexp ()

+ 4 - 1
lisp/org-mobile.el

@@ -38,6 +38,9 @@
 
 (eval-when-compile (require 'cl))
 
+(declare-function org-pop-to-buffer-same-window 
+		  "org-compat" (&optional buffer-or-name norecord label))
+
 (defgroup org-mobile nil
   "Options concerning support for a viewer/editor on a mobile device."
   :tag "Org Mobile"
@@ -909,7 +912,7 @@ If BEG and END are given, only do this in that region."
 				   (buffer-file-name (current-buffer))))))
 		(error (setq org-mobile-error msg))))
 	    (when org-mobile-error
-	      (switch-to-buffer (marker-buffer marker))
+	      (org-pop-to-buffer-same-window (marker-buffer marker))
 	      (goto-char marker)
 	      (incf cnt-error)
 	      (insert (if (stringp (nth 1 org-mobile-error))

+ 4 - 2
lisp/org-publish.el

@@ -368,6 +368,8 @@ This is a compatibility function for Emacsen without `delete-dups'."
 
 (declare-function org-publish-delete-dups "org-publish" (list))
 (declare-function find-lisp-find-files "find-lisp" (directory regexp))
+(declare-function org-pop-to-buffer-same-window 
+		  "org-compat" (&optional buffer-or-name norecord label))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Getting project information out of org-publish-project-alist
@@ -559,7 +561,7 @@ PUB-DIR is the publishing directory."
     (make-directory pub-dir t))
   (let ((visiting (find-buffer-visiting filename)))
     (save-excursion
-      (switch-to-buffer (or visiting (find-file filename)))
+      (org-pop-to-buffer-same-window (or visiting (find-file filename)))
       (let* ((plist (cons :buffer-will-be-killed (cons t plist)))
 	     (init-buf (current-buffer))
 	     (init-point (point))
@@ -860,7 +862,7 @@ system's modification time.
 It returns time in `current-time' format."
   (let ((visiting (find-buffer-visiting file)))
     (save-excursion
-      (switch-to-buffer (or visiting (find-file-noselect file nil t)))
+      (org-pop-to-buffer-same-window (or visiting (find-file-noselect file nil t)))
       (let* ((plist (org-infile-export-plist))
 	     (date (plist-get plist :date)))
 	(unless visiting

+ 5 - 1
lisp/org-remember.el

@@ -34,12 +34,16 @@
 (eval-when-compile
   (require 'cl))
 (require 'org)
+(require 'org-compat)
 (require 'org-datetree)
 
 (declare-function remember-mode "remember" ())
 (declare-function remember "remember" (&optional initial))
 (declare-function remember-buffer-desc "remember" ())
 (declare-function remember-finalize "remember" ())
+(declare-function org-pop-to-buffer-same-window 
+		  "org-compat" (&optional buffer-or-name norecord label))
+
 (defvar remember-save-after-remembering)
 (defvar remember-register)
 (defvar remember-buffer)
@@ -785,7 +789,7 @@ The user is queried for the template."
       (setq heading org-remember-default-headline))
     (setq visiting (org-find-base-buffer-visiting file))
     (if (not visiting) (find-file-noselect file))
-    (switch-to-buffer (or visiting (get-file-buffer file)))
+    (org-pop-to-buffer-same-window (or visiting (get-file-buffer file)))
     (widen)
     (goto-char (point-min))
     (if (re-search-forward

+ 7 - 5
lisp/org-src.el

@@ -43,6 +43,8 @@
 (declare-function org-at-table.el-p "org" ())
 (declare-function org-get-indentation "org" (&optional line))
 (declare-function org-switch-to-buffer-other-window "org" (&rest args))
+(declare-function org-pop-to-buffer-same-window 
+		  "org-compat" (&optional buffer-or-name norecord label))
 
 (defcustom org-edit-src-region-extra nil
   "Additional regexps to identify regions for editing with `org-edit-src-code'.
@@ -340,7 +342,7 @@ buffer."
 (defun org-src-switch-to-buffer (buffer context)
   (case org-src-window-setup
     ('current-window
-     (switch-to-buffer buffer))
+     (org-pop-to-buffer-same-window buffer))
     ('other-window
      (switch-to-buffer-other-window buffer))
     ('other-frame
@@ -351,7 +353,7 @@ buffer."
 	  (delete-frame frame)))
        ('save
 	(kill-buffer (current-buffer))
-	(switch-to-buffer buffer))
+	(org-pop-to-buffer-same-window buffer))
        (t
 	(switch-to-buffer-other-frame buffer))))
     ('reorganize-frame
@@ -363,7 +365,7 @@ buffer."
     (t
      (message "Invalid value %s for org-src-window-setup"
 	      (symbol-name org-src-window-setup))
-     (switch-to-buffer buffer))))
+     (org-pop-to-buffer-same-window buffer))))
 
 (defun org-src-construct-edit-buffer-name (org-buffer-name lang)
   "Construct the buffer name for a source editing buffer."
@@ -423,7 +425,7 @@ the fragment in the Org-mode buffer."
 	    begline (save-excursion (goto-char beg) (org-current-line)))
       (if (and (setq buffer (org-edit-src-find-buffer beg end))
 	       (y-or-n-p "Return to existing edit buffer? [n] will revert changes: "))
-	  (switch-to-buffer buffer)
+	  (org-pop-to-buffer-same-window buffer)
 	(when buffer
 	  (with-current-buffer buffer
 	    (if (boundp 'org-edit-src-overlay)
@@ -443,7 +445,7 @@ the fragment in the Org-mode buffer."
 			   (define-key map [mouse-1] 'org-edit-src-continue)
 			   map))
 	(overlay-put ovl :read-only "Leave me alone")
-	(switch-to-buffer buffer)
+	(org-pop-to-buffer-same-window buffer)
 	(insert code)
 	(remove-text-properties (point-min) (point-max)
 				'(display nil invisible nil intangible nil))

+ 17 - 13
lisp/org.el

@@ -106,6 +106,10 @@
 (declare-function org-inlinetask-at-task-p "org-inlinetask" ())
 (declare-function org-inlinetask-outline-regexp "org-inlinetask" ())
 (declare-function org-inlinetask-toggle-visibility "org-inlinetask" ())
+(declare-function org-pop-to-buffer-same-window "org-compat" (&optional buffer-or-name norecord label))
+(declare-function org-at-clock-log-p "org-clock" ())
+(declare-function org-clock-timestamps-up "org-clock" ())
+(declare-function org-clock-timestamps-down "org-clock" ())
 
 ;; babel
 (require 'ob)
@@ -6657,7 +6661,7 @@ or nil."
       (save-window-excursion
 	(delete-other-windows)
 	(and (get-buffer "*org-goto*") (kill-buffer "*org-goto*"))
-	(switch-to-buffer
+	(org-pop-to-buffer-same-window
 	 (condition-case nil
 	     (make-indirect-buffer (current-buffer) "*org-goto*")
 	   (error (make-indirect-buffer (current-buffer) "*org-goto*"))))
@@ -6795,7 +6799,7 @@ frame is not changed."
 	  (and arg (eq org-indirect-buffer-display 'dedicated-frame)))
       (select-frame (make-frame))
       (delete-other-windows)
-      (switch-to-buffer ibuf)
+      (org-pop-to-buffer-same-window ibuf)
       (org-set-frame-title heading))
      ((eq org-indirect-buffer-display 'dedicated-frame)
       (raise-frame
@@ -6804,10 +6808,10 @@ frame is not changed."
 			      org-indirect-dedicated-frame)
 			 (setq org-indirect-dedicated-frame (make-frame)))))
       (delete-other-windows)
-      (switch-to-buffer ibuf)
+      (org-pop-to-buffer-same-window ibuf)
       (org-set-frame-title (concat "Indirect: " heading)))
      ((eq org-indirect-buffer-display 'current-window)
-      (switch-to-buffer ibuf))
+      (org-pop-to-buffer-same-window ibuf))
      ((eq org-indirect-buffer-display 'other-window)
       (pop-to-buffer ibuf))
      (t (error "Invalid value")))
@@ -9830,7 +9834,7 @@ onto the ring."
       (setq p org-mark-ring))
     (setq org-mark-ring-last-goto p)
     (setq m (car p))
-    (switch-to-buffer (marker-buffer m))
+    (org-pop-to-buffer-same-window (marker-buffer m))
     (goto-char m)
     (if (or (outline-invisible-p) (org-invisible-p2)) (org-show-context 'mark-goto))))
 
@@ -10425,7 +10429,7 @@ prefix argument (`C-u C-u C-u C-c C-w')."
 			 (find-file-noselect file)))
 	  (if goto
 	      (progn
-		(switch-to-buffer nbuf)
+		(org-pop-to-buffer-same-window nbuf)
 		(goto-char pos)
 		(org-show-context 'org-goto))
 	    (if regionp
@@ -11989,7 +11993,7 @@ EXTRA is additional text that will be inserted into the notes buffer."
   (setq org-log-note-window-configuration (current-window-configuration))
   (delete-other-windows)
   (move-marker org-log-note-return-to (point))
-  (switch-to-buffer (marker-buffer org-log-note-marker))
+  (org-pop-to-buffer-same-window (marker-buffer org-log-note-marker))
   (goto-char org-log-note-marker)
   (org-switch-to-buffer-other-window "*Org Note*")
   (erase-buffer)
@@ -14129,6 +14133,7 @@ This is computed according to `org-property-set-functions-alist'."
 	cur
       val)))
 
+(defvar org-last-set-property nil)
 (defun org-read-property-name ()
   "Read a property name."
   (let* ((completion-ignore-case t)
@@ -14155,7 +14160,6 @@ This is computed according to `org-property-set-functions-alist'."
 			      keys)))
 	  property))))
 
-(defvar org-last-set-property nil)
 (defun org-set-property (property value)
   "In the current entry, set PROPERTY to VALUE.
 When called interactively, this will prompt for a property name, offering
@@ -15804,7 +15808,7 @@ changes from another.  I believe the procedure must be like this:
        (lambda (b)
 	 (when (and (with-current-buffer b (org-mode-p))
 		    (with-current-buffer b buffer-file-name))
-	   (switch-to-buffer b)
+	   (org-pop-to-buffer-same-window b)
 	   (revert-buffer t 'no-confirm)))
        (buffer-list))
       (when (and (featurep 'org-id) org-id-track-globally)
@@ -15828,7 +15832,7 @@ Set `org-completion-use-ido' to make it use ido instead."
 	(org-completion-use-ido org-completion-use-ido))
     (unless (or org-completion-use-ido org-completion-use-iswitchb)
       (setq org-completion-use-iswitchb t))
-    (switch-to-buffer
+    (org-pop-to-buffer-same-window
      (org-icompleting-read "Org buffer: "
 			   (mapcar 'list (mapcar 'buffer-name blist))
 			   nil t))))
@@ -15995,7 +15999,7 @@ If the current buffer does not, find the first agenda file."
 	      (find-file (car files))
 	      (throw 'exit t))))
       (find-file (car fs)))
-    (if (buffer-base-buffer) (switch-to-buffer (buffer-base-buffer)))))
+    (if (buffer-base-buffer) (org-pop-to-buffer-same-window (buffer-base-buffer)))))
 
 (defun org-agenda-file-to-front (&optional to-end)
   "Move/add the current file to the top of the agenda file list.
@@ -18396,7 +18400,7 @@ information about your Org-mode version and configuration."
      (org-version)
      (let (list)
        (save-window-excursion
-	 (switch-to-buffer (get-buffer-create "*Warn about privacy*"))
+	 (org-pop-to-buffer-same-window (get-buffer-create "*Warn about privacy*"))
 	 (delete-other-windows)
 	 (erase-buffer)
 	 (insert "You are about to submit a bug report to the Org-mode mailing list.
@@ -18593,7 +18597,7 @@ With prefix arg UNCOMPILED, load the uncompiled versions."
   (if (and marker (marker-buffer marker)
 	   (buffer-live-p (marker-buffer marker)))
       (progn
-	(switch-to-buffer (marker-buffer marker))
+	(org-pop-to-buffer-same-window (marker-buffer marker))
 	(if (or (> marker (point-max)) (< marker (point-min)))
 	    (widen))
 	(goto-char marker)