changeset 105865:131bccfc4f5d

* org.el (org-version, org-get-refile-targets, org-refile) (org-store-log-note, org-diary-to-ical-string) (org-speedbar-set-agenda-restriction): * org-publish.el (org-publish-find-title): * org-plot.el (org-plot/gnuplot): * org-mouse.el (org-mouse-do-remotely): * org-mobile.el (org-mobile-move-capture): * org-mac-message.el (org-mac-message-insert-flagged): * org-latex.el (org-replace-region-by-latex): * org-docbook.el (org-replace-region-by-docbook): * org-clock.el (org-clock-out, org-clock-cancel): * org-bibtex.el (org-execute-file-search-in-bibtex): Use with-current-buffer.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Thu, 05 Nov 2009 21:00:31 +0000
parents c6d77597d0f2
children 3367f0022cf2
files lisp/org/ChangeLog lisp/org/org-bibtex.el lisp/org/org-clock.el lisp/org/org-docbook.el lisp/org/org-latex.el lisp/org/org-mac-message.el lisp/org/org-mobile.el lisp/org/org-mouse.el lisp/org/org-plot.el lisp/org/org-publish.el lisp/org/org.el
diffstat 11 files changed, 38 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/org/ChangeLog	Thu Nov 05 20:54:34 2009 +0000
+++ b/lisp/org/ChangeLog	Thu Nov 05 21:00:31 2009 +0000
@@ -1,3 +1,19 @@
+2009-11-05  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* org.el (org-version, org-get-refile-targets, org-refile)
+	(org-store-log-note, org-diary-to-ical-string)
+	(org-speedbar-set-agenda-restriction):
+	* org-publish.el (org-publish-find-title):
+	* org-plot.el (org-plot/gnuplot):
+	* org-mouse.el (org-mouse-do-remotely):
+	* org-mobile.el (org-mobile-move-capture):
+	* org-mac-message.el (org-mac-message-insert-flagged):
+	* org-latex.el (org-replace-region-by-latex):
+	* org-docbook.el (org-replace-region-by-docbook):
+	* org-clock.el (org-clock-out, org-clock-cancel):
+	* org-bibtex.el (org-execute-file-search-in-bibtex):
+	Use with-current-buffer.
+
 2009-10-04  Juanma Barranquero  <lekktu@gmail.com>
 
 	* org.el (org-directory, org-map-entries):
--- a/lisp/org/org-bibtex.el	Thu Nov 05 20:54:34 2009 +0000
+++ b/lisp/org/org-bibtex.el	Thu Nov 05 21:00:31 2009 +0000
@@ -188,8 +188,9 @@
 	(let ((b (current-buffer)) (p (point)))
 	  ;; Restore the window configuration because we just use the web link
 	  (set-window-configuration org-window-config-before-follow-link)
-	  (save-excursion (set-buffer b) (goto-char p)
-	    (bibtex-url)))
+	  (with-current-buffer b
+            (goto-char p)
+            (bibtex-url)))
       (recenter 0))  ; Move entry start to beginning of window
   ;; return t to indicate that the search is done.
     t))
--- a/lisp/org/org-clock.el	Thu Nov 05 20:54:34 2009 +0000
+++ b/lisp/org/org-clock.el	Thu Nov 05 21:00:31 2009 +0000
@@ -752,8 +752,7 @@
     (if (not (marker-buffer org-clock-marker))
 	(if fail-quietly (throw 'exit t) (error "No active clock")))
     (let (ts te s h m remove)
-      (save-excursion
-	(set-buffer (marker-buffer org-clock-marker))
+      (with-current-buffer (marker-buffer org-clock-marker)
 	(save-restriction
 	  (widen)
 	  (goto-char org-clock-marker)
@@ -814,8 +813,7 @@
   (interactive)
   (if (not (marker-buffer org-clock-marker))
       (error "No active clock"))
-  (save-excursion
-    (set-buffer (marker-buffer org-clock-marker))
+  (with-current-buffer (marker-buffer org-clock-marker)
     (goto-char org-clock-marker)
     (delete-region (1- (point-at-bol)) (point-at-eol)))
   (move-marker 'org-clock-marker nil)
--- a/lisp/org/org-docbook.el	Thu Nov 05 20:54:34 2009 +0000
+++ b/lisp/org/org-docbook.el	Thu Nov 05 21:00:31 2009 +0000
@@ -285,8 +285,7 @@
 			 beg end t 'string))
 	(setq reg (buffer-substring beg end)
 	      buf (get-buffer-create "*Org tmp*"))
-	(save-excursion
-	  (set-buffer buf)
+	(with-current-buffer buf
 	  (erase-buffer)
 	  (insert reg)
 	  (org-mode)
--- a/lisp/org/org-latex.el	Thu Nov 05 20:54:34 2009 +0000
+++ b/lisp/org/org-latex.el	Thu Nov 05 21:00:31 2009 +0000
@@ -451,8 +451,7 @@
 		       beg end t 'string))
 	(setq reg (buffer-substring beg end)
 	      buf (get-buffer-create "*Org tmp*"))
-	(save-excursion
-	  (set-buffer buf)
+	(with-current-buffer buf
 	  (erase-buffer)
 	  (insert reg)
 	  (org-mode)
--- a/lisp/org/org-mac-message.el	Thu Nov 05 20:54:34 2009 +0000
+++ b/lisp/org/org-mac-message.el	Thu Nov 05 21:00:31 2009 +0000
@@ -193,8 +193,7 @@
 level.  If heading doesn't exist, create it at point-max.  Insert
 list of message:// links to flagged mail after heading."
   (interactive "bBuffer in which to insert links: \nsHeading after which to insert links: ")
-  (save-excursion
-    (set-buffer org-buffer)
+  (with-current-buffer org-buffer
     (goto-char (point-min))
     (let ((isearch-forward t)
 	  (message-re "\\[\\[\\(message:\\)\\([^]]+\\)\\]\\(\\[\\([^]]+\\)\\]\\)?\\]"))
--- a/lisp/org/org-mobile.el	Thu Nov 05 20:54:34 2009 +0000
+++ b/lisp/org/org-mobile.el	Thu Nov 05 21:00:31 2009 +0000
@@ -391,8 +391,7 @@
 					   org-mobile-directory)))
 	(insertion-point (make-marker))
 	not-empty content)
-    (save-excursion
-      (set-buffer capture-buffer)
+    (with-current-buffer capture-buffer
       (setq content (buffer-string))
       (setq not-empty (string-match "\\S-" content))
       (when not-empty
--- a/lisp/org/org-mouse.el	Thu Nov 05 20:54:34 2009 +0000
+++ b/lisp/org/org-mouse.el	Thu Nov 05 21:00:31 2009 +0000
@@ -1042,8 +1042,7 @@
 	   (org-mouse-direct nil)
 	   (org-mouse-main-buffer (current-buffer)))
       (when (eq (with-current-buffer buffer major-mode) 'org-mode)
-	(let ((endmarker (save-excursion
-			  (set-buffer buffer)
+	(let ((endmarker (with-current-buffer buffer
 			  (outline-end-of-subtree)
 			  (forward-char 1)
 			  (copy-marker (point)))))
--- a/lisp/org/org-plot.el	Thu Nov 05 20:54:34 2009 +0000
+++ b/lisp/org/org-plot.el	Thu Nov 05 21:00:31 2009 +0000
@@ -279,8 +279,8 @@
   (save-window-excursion
     (delete-other-windows)
     (when (get-buffer "*gnuplot*") ;; reset *gnuplot* if it already running
-      (save-excursion
-	(set-buffer "*gnuplot*") (goto-char (point-max))
+      (with-current-buffer "*gnuplot*"
+        (goto-char (point-max))
 	(gnuplot-delchar-or-maybe-eof nil)))
     (org-plot/goto-nearest-table)
     ;; set default options
--- a/lisp/org/org-publish.el	Thu Nov 05 20:54:34 2009 +0000
+++ b/lisp/org/org-publish.el	Thu Nov 05 21:00:31 2009 +0000
@@ -607,8 +607,7 @@
   (let* ((visiting (find-buffer-visiting file))
 	 (buffer (or visiting (find-file-noselect file)))
 	 title)
-    (save-excursion
-      (set-buffer buffer)
+    (with-current-buffer buffer
       (let* ((opt-plist (org-combine-plists (org-default-export-plist)
 					    (org-infile-export-plist))))
 	(setq title
--- a/lisp/org/org.el	Thu Nov 05 20:54:34 2009 +0000
+++ b/lisp/org/org.el	Thu Nov 05 21:00:31 2009 +0000
@@ -110,8 +110,7 @@
 	(let ((pwd (substring (pwd) 10)))
 	  (cd dir)
 	  (if (eql 0 (shell-command "git describe --abbrev=4 HEAD"))
-	      (save-excursion
-		(set-buffer "*Shell Command Output*")
+	      (with-current-buffer "*Shell Command Output*"
 		(goto-char (point-min))
 		(re-search-forward "[^\n]+")
 		(setq git-version (match-string 0))
@@ -8674,8 +8673,8 @@
 			       "\\}[ \t]")))
 	 (t (error "Bad refiling target description %s" desc)))
 	(while (setq f (pop files))
-	  (save-excursion
-	    (set-buffer (if (bufferp f) f (org-get-agenda-file-buffer f)))
+	  (with-current-buffer
+              (if (bufferp f) f (org-get-agenda-file-buffer f))
 	    (if (bufferp f) (setq f (buffer-file-name (buffer-base-buffer f))))
 	    (setq f (expand-file-name f))
 	    (if (eq org-refile-use-outline-path 'file)
@@ -8823,9 +8822,8 @@
 		(org-kill-new (buffer-substring region-start region-end))
 		(org-save-markers-in-region region-start region-end))
 	    (org-copy-subtree 1 nil t))
-	  (save-excursion
-	    (set-buffer (setq nbuf (or (find-buffer-visiting file)
-				       (find-file-noselect file))))
+	  (with-current-buffer (setq nbuf (or (find-buffer-visiting file)
+                                              (find-file-noselect file)))
 	    (setq reversed (org-notes-order-reversed-p))
 	    (save-excursion
 	      (save-restriction
@@ -10431,8 +10429,7 @@
 	 org-log-note-marker))
       (setq lines nil))
     (when lines
-      (save-excursion
-	(set-buffer (marker-buffer org-log-note-marker))
+      (with-current-buffer (marker-buffer org-log-note-marker)
 	(save-excursion
 	  (goto-char org-log-note-marker)
 	  (move-marker org-log-note-marker nil)
@@ -13284,8 +13281,7 @@
 	 (tmpfile (make-temp-name
 		   (expand-file-name "orgics" tmpdir)))
 	 buf rtn b e)
-    (save-excursion
-      (set-buffer frombuf)
+    (with-current-buffer frombuf
       (icalendar-export-region (point-min) (point-max) tmpfile)
       (setq buf (find-buffer-visiting tmpfile))
       (set-buffer buf)
@@ -17193,6 +17189,7 @@
 				 'org-imenu t))
       (setq m (get-text-property p 'org-imenu-marker))
       (save-excursion
+        ;; FIXME: Shouldn't set-buffer be done before save-restriction?  --Stef
 	(save-restriction
 	  (set-buffer (marker-buffer m))
 	  (goto-char m)
@@ -17207,6 +17204,7 @@
 	    txt (buffer-substring-no-properties (or tp (point-min))
 						(or np (point-max))))
       (save-excursion
+        ;; FIXME: Shouldn't set-buffer be done before save-restriction?  --Stef
 	(save-restriction
 	  (set-buffer (find-file-noselect
 		       (let ((default-directory dir))