Carsten Dominik wrote:
>Hi Thierry,

>I cannot easily see why org-decrypt-entry is being called, and if it
>is being called in
>the remember buffer or where?

>Anyway, most of us are moving to org-capture, so I would be more
>inclined to look into this if this is still an issue in
>org-capture....

Looks like this is not a problem of org-remember.  After archiving
DONE items (C-u C-c C-x C-s) I get a similar error:

,----
| Debugger entered--Lisp error: (error "Before first headline at position 1 in 
buffer projects.org")
|   signal(error ("Before first headline at position 1 in buffer projects.org"))
|   error("Before first headline at position %d in buffer %s" 1 #<buffer 
projects.org>)
|   byte-code("\300\301`p#\207" [error "Before first headline at position %d in 
buffer %s"] 4)
|   org-back-to-heading(t)
|   org-decrypt-entry()
|   run-hooks(org-reveal-start-hook)
|   org-reveal()
|   org-advertized-archive-subtree((4))
|   call-interactively(org-advertized-archive-subtree nil nil)
`----

Attached patch fixes this by modifying `org-decrypt-entry' to silently
do nothing if point is before first heading.

HTH
 -- David
--
OpenPGP... 0x99ADB83B5A4478E6
Jabber.... dmj...@jabber.org
Email..... dm...@ictsoc.de
From aab3300517e3f3bd6a2807713bfc964bb7c3d8c5 Mon Sep 17 00:00:00 2001
From: David Maus <dm...@ictsoc.de>
Date: Fri, 16 Jul 2010 17:23:31 +0200
Subject: [PATCH] Don't throw error when not inside a subtree

* org-crypt.el (org-decrypt-entry): Don't throw error when not inside
a subtree.
---
 lisp/org-crypt.el |   39 ++++++++++++++++++++-------------------
 1 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/lisp/org-crypt.el b/lisp/org-crypt.el
index 6411171..8b25213 100644
--- a/lisp/org-crypt.el
+++ b/lisp/org-crypt.el
@@ -137,25 +137,26 @@ This setting can also be overridden in the CRYPTKEY 
property."
   "Decrypt the content of the current headline."
   (interactive)
   (require 'epg)
-  (save-excursion
-    (org-back-to-heading t)
-    (forward-line)
-    (when (looking-at "-----BEGIN PGP MESSAGE-----")
-      (let* ((beg (point))
-             (end (save-excursion
-                    (search-forward "-----END PGP MESSAGE-----")
-                    (forward-line)
-                    (point)))
-             (epg-context (epg-make-context nil t t))
-             (decrypted-text
-             (decode-coding-string
-              (epg-decrypt-string
-               epg-context
-               (buffer-substring-no-properties beg end))
-              'utf-8)))
-        (delete-region beg end)
-        (insert decrypted-text)
-        nil))))
+  (unless (org-before-first-heading-p)
+    (save-excursion
+      (org-back-to-heading t)
+      (forward-line)
+      (when (looking-at "-----BEGIN PGP MESSAGE-----")
+       (let* ((beg (point))
+              (end (save-excursion
+                     (search-forward "-----END PGP MESSAGE-----")
+                     (forward-line)
+                     (point)))
+              (epg-context (epg-make-context nil t t))
+              (decrypted-text
+               (decode-coding-string
+                (epg-decrypt-string
+                 epg-context
+                 (buffer-substring-no-properties beg end))
+                'utf-8)))
+         (delete-region beg end)
+         (insert decrypted-text)
+         nil)))))
 
 (defun org-encrypt-entries ()
   "Encrypt all top-level entries in the current buffer."
-- 
1.7.1

Attachment: pgpuaNCmliNzw.pgp
Description: PGP signature

_______________________________________________
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 via email to