emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Julien Danjou <julien@danjou.info>
To: emacs-orgmode@gnu.org
Cc: Julien Danjou <julien@danjou.info>
Subject: [PATCH] org-macs: store evaluated version of pom
Date: Fri, 25 Feb 2011 14:30:33 +0100	[thread overview]
Message-ID: <1298640633-17072-1-git-send-email-julien@danjou.info> (raw)

* 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 <julien@danjou.info>
---
 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	other threads:[~2011-02-25 13:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-25 13:30 Julien Danjou [this message]
2011-02-26 17:25 ` [PATCH] org-macs: store evaluated version of pom Bastien
2011-02-26 18:15   ` Julien Danjou
2011-02-27 11:46     ` Bastien

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=1298640633-17072-1-git-send-email-julien@danjou.info \
    --to=julien@danjou.info \
    --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).