emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Orgmode] [PATCH] org-macs: store evaluated version of pom


From: Julien Danjou
Subject: [Orgmode] [PATCH] org-macs: store evaluated version of pom
Date: Fri, 25 Feb 2011 14:30:33 +0100

* lisp/org-macs.el (org-with-point-at): Store evaluated version of pom. This
fixes a potential bug when using (org-with-point-at (func) …), where (func)
would be evaluated multiple times, therefore might return different results
if a marker was returned and different each time.

Signed-off-by: Julien Danjou <address@hidden>
---
 lisp/org-macs.el |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/lisp/org-macs.el b/lisp/org-macs.el
index 9c161e3..2090ca7 100644
--- a/lisp/org-macs.el
+++ b/lisp/org-macs.el
@@ -134,11 +134,12 @@ We use a macro so that the test can happen at compilation 
time."
 
 (defmacro org-with-point-at (pom &rest body)
   "Move to buffer and point of point-or-marker POM for the duration of BODY."
-  `(save-excursion
-     (if (markerp ,pom) (set-buffer (marker-buffer ,pom)))
+  `(let ((pom ,pom))
      (save-excursion
-       (goto-char (or ,pom (point)))
-       ,@body)))
+       (if (markerp pom) (set-buffer (marker-buffer pom)))
+       (save-excursion
+        (goto-char (or pom (point)))
+        ,@body))))
 (put 'org-with-point-at 'lisp-indent-function 1)
 
 (defmacro org-no-warnings (&rest body)
-- 
1.7.4.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]