emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [Orgmode] [ANN] org-crypt version 0.2


From: Carsten Dominik
Subject: Re: [Orgmode] [ANN] org-crypt version 0.2
Date: Thu, 2 Apr 2009 09:52:25 +0200


Hi Peter,

this looks really nice.  I very much like the idea using a property
to set an encryption key.

On Apr 2, 2009, at 5:19 AM, Peter Jones wrote:
Carsten: after encrypting a folded headline, the new contents of the
heading won't be folded, but the headline will still appear to be
folded.  For example:

* Before...
* After...-------BEGIN PGP MESSAGE---------
lkafjd;alkfjd;alfjd;ljf
and so on....

Please point me in the right direction for resolving this.  Thank you.

Below is a patch which will fix this.  Basically you need to
go back and fix the visibility of the entry, because you are
inserting in a location that confuses the invisibility code.
Instead of trying to get the insertion right, it is much better
to reset it for the entire tree.

The patch also does one other thing:

It makes encryption cover the entire subtree of an entry
with tag :crypt:, not just the text up to first child.
I believe this is more consistent with the structure or
Org-mode files.  Would you agree?

- Carsten

--- org-crypt.el.orig 2009-04-02 08:35:24.000000000 +0200
+++ org-crypt.el 2009-04-02 08:46:59.000000000 +0200
@@ -101,12 +101,16 @@
   (save-excursion
     (org-back-to-heading t)
     (forward-line)
-    (let ((epg-context (epg-make-context nil t t))
+    (let ((folded (org-invisible-p))
+  (epg-context (epg-make-context nil t t))
           (crypt-key (org-crypt-key-for-heading))
           (beg (point))
           end encrypted-text)
       (when (and (not (looking-at "-----BEGIN PGP MESSAGE-----"))
-                 (or (outline-next-heading) (bolp)))
+ (progn
+   (org-end-of-subtree t t)
+   (org-back-over-empty-lines)
+   t))
         (setq end (point)
               encrypted-text
               (epg-encrypt-string 
@@ -115,6 +119,10 @@
                (epg-list-keys epg-context crypt-key)))
         (delete-region beg end)
         (insert encrypted-text)
+ (when folded
+  (save-excursion
+    (org-back-to-heading t)
+    (hide-subtree)))
         nil))))
 
 (defun org-decrypt-entry ()


reply via email to

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