emacs-orgmode
[Top][All Lists]
Advanced

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

[Orgmode] [PATCH] Use save-excursion in org-map-dblocks


From: Magnus Henoch
Subject: [Orgmode] [PATCH] Use save-excursion in org-map-dblocks
Date: Tue, 23 Mar 2010 17:37:30 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

This patch has been sitting in my tree for a while...  It's a fix to
org-map-dblocks, to make it use save-excursion instead of remembering
position values.  I need this since I have a dblock function that
asynchronously updates dblocks from HTTP responses, and some dblocks
ended up getting updated twice or thrice.

>From 8fa75fb5174f93cc6990b605901891c2191c64f0 Mon Sep 17 00:00:00 2001
From: Magnus Henoch <address@hidden>
Date: Wed, 21 Oct 2009 12:37:32 +0100
Subject: [PATCH] * org.el (org-map-dblocks): Use save-excursion.

---
 lisp/org.el |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 7b2e95b..249aad4 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -9306,16 +9306,15 @@ the property list including an extra property :name 
with the block name."
 (defun org-map-dblocks (&optional command)
   "Apply COMMAND to all dynamic blocks in the current buffer.
 If COMMAND is not given, use `org-update-dblock'."
-  (let ((cmd (or command 'org-update-dblock))
-       pos)
+  (let ((cmd (or command 'org-update-dblock)))
     (save-excursion
       (goto-char (point-min))
       (while (re-search-forward org-dblock-start-re nil t)
-       (goto-char (setq pos (match-beginning 0)))
-       (condition-case nil
-           (funcall cmd)
-         (error (message "Error during update of dynamic block")))
-       (goto-char pos)
+       (goto-char (match-beginning 0))
+        (save-excursion
+          (condition-case nil
+              (funcall cmd)
+            (error (message "Error during update of dynamic block"))))
        (unless (re-search-forward org-dblock-end-re nil t)
          (error "Dynamic block not terminated"))))))
 
-- 
1.6.4.4

-- 
Magnus Henoch

reply via email to

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