emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Magnus Henoch <magnus.henoch@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH] Use save-excursion in org-map-dblocks
Date: Tue, 23 Mar 2010 17:37:30 +0000	[thread overview]
Message-ID: <841vfbszvp.fsf@linux-b2a3.site> (raw)

[-- Attachment #1: Type: text/plain, Size: 317 bytes --]

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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org.el-org-map-dblocks-Use-save-excursion.patch --]
[-- Type: text/x-patch, Size: 1361 bytes --]

From 8fa75fb5174f93cc6990b605901891c2191c64f0 Mon Sep 17 00:00:00 2001
From: Magnus Henoch <magnus.henoch@gmail.com>
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


[-- Attachment #3: Type: text/plain, Size: 19 bytes --]


-- 
Magnus Henoch

[-- Attachment #4: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

             reply	other threads:[~2010-03-23 17:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-23 17:37 Magnus Henoch [this message]
2010-03-24 11:16 ` [PATCH] Use save-excursion in org-map-dblocks Carsten Dominik
2010-03-24 13:47   ` Magnus Henoch
2010-03-24 21:27     ` Carsten Dominik
2010-03-24 22:03       ` Magnus Henoch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=841vfbszvp.fsf@linux-b2a3.site \
    --to=magnus.henoch@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).