From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: [ANN] org-crypt version 0.2 Date: Thu, 2 Apr 2009 09:52:25 +0200 Message-ID: References: Mime-Version: 1.0 (Apple Message framework v930.3) Content-Type: multipart/mixed; boundary="===============0686475012==" Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LpHiz-0004lc-OF for emacs-orgmode@gnu.org; Thu, 02 Apr 2009 03:52:33 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LpHiv-0004kD-PC for emacs-orgmode@gnu.org; Thu, 02 Apr 2009 03:52:33 -0400 Received: from [199.232.76.173] (port=37217 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LpHiv-0004k8-Ju for emacs-orgmode@gnu.org; Thu, 02 Apr 2009 03:52:29 -0400 Received: from mail-ew0-f160.google.com ([209.85.219.160]:61184) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LpHiv-00059v-24 for emacs-orgmode@gnu.org; Thu, 02 Apr 2009 03:52:29 -0400 Received: by mail-ew0-f160.google.com with SMTP id 4so426602ewy.42 for ; Thu, 02 Apr 2009 00:52:28 -0700 (PDT) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Peter Jones Cc: emacs-orgmode@gnu.org --===============0686475012== Content-Type: multipart/alternative; boundary=Apple-Mail-1-506024003 --Apple-Mail-1-506024003 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit 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 () --Apple-Mail-1-506024003 Content-Type: text/html; charset=US-ASCII Content-Transfer-Encoding: quoted-printable

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 = ()

= --Apple-Mail-1-506024003-- --===============0686475012== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Remember: use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --===============0686475012==--