diff options
author | Carsten Dominik <carsten.dominik@gmail.com> | 2010-04-14 09:42:50 +0200 |
---|---|---|
committer | Carsten Dominik <carsten.dominik@gmail.com> | 2010-04-14 09:42:50 +0200 |
commit | 2339c5afa7e814e2735d80769d87c1a3fd6d4949 (patch) | |
tree | 94de745edca033762d7b797242c3abc6762a9c1a | |
parent | 9cfebf084266267d0c78bbd9097b16c0cd8fbae3 (diff) | |
download | org-mode-2339c5afa7e814e2735d80769d87c1a3fd6d4949.tar.gz |
Fix bug in mapping entries
Patch by Peter Jones, following a bug report by Xiao-Jong Jin, who wrote:
> If you have the follow org file
>
> * test crypt :crypt:
> ** subheading 1
> text 1
> ** subheading 2
> text 2
>
> with setup as
>
> (require 'org-crypt)
> (setq org-tags-exclude-from-inheritance '("crypt"))
> (setq org-crypt-key "CBC0714E") ; my key
>
> On calling org-encrypt-entry on the first head line, only
> subheading 1 get encrypted, subheading 2 remains plain text.
> But, if you add an empty line or some text under the first
> heading, both subheading 1 and 2 are encrypted.
-rwxr-xr-x | lisp/ChangeLog | 4 | ||||
-rw-r--r-- | lisp/org-crypt.el | 45 |
2 files changed, 27 insertions, 22 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a4aba13..dc38e08 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,7 @@ +2010-04-14 Carsten Dominik <carsten.dominik@gmail.com> + + * org-crypt.el (org-encrypt-entry): Improve mapping behavior. + 2010-04-13 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-align-all-tags): New command. diff --git a/lisp/org-crypt.el b/lisp/org-crypt.el index 819da83..5ca4e3a 100644 --- a/lisp/org-crypt.el +++ b/lisp/org-crypt.el @@ -105,28 +105,29 @@ heading. This can also be overridden in the CRYPTKEY property." (require 'epg) (save-excursion (org-back-to-heading t) - (forward-line) - (when (not (looking-at "-----BEGIN PGP MESSAGE-----")) - (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) - (org-end-of-subtree t t) - (org-back-over-empty-lines) - (setq end (point) - encrypted-text - (epg-encrypt-string - epg-context - (buffer-substring-no-properties beg end) - (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)))) + (let ((start-heading (point))) + (forward-line) + (when (not (looking-at "-----BEGIN PGP MESSAGE-----")) + (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) + (goto-char start-heading) + (org-end-of-subtree t t) + (org-back-over-empty-lines) + (setq end (point) + encrypted-text + (epg-encrypt-string + epg-context + (buffer-substring-no-properties beg end) + (epg-list-keys epg-context crypt-key))) + (delete-region beg end) + (insert encrypted-text) + (when folded + (goto-char start-heading) + (hide-subtree)) + nil))))) (defun org-decrypt-entry () "Decrypt the content of the current headline." |