<n...@aleblanc.cotse.net> writes:

>
> Just discovered a bug in my previously posted function. It doesn't work
> too well if you have lower level subtrees tagged for encryption.

I also forgot to mention that you need to have pgg pre-loaded.
This will ensure that:

(defun my-func-org-toggle-encryption (rcpts passphrase)
  (interactive (list (split-string (read-string "Recipients (default is none): 
") "[ \t,]+")
                     (pgg-read-passphrase "GnuPG passphrase: ")))
  (require 'pgg)
  (show-all)
  (org-map-entries '(let (start end teststring)
                      (org-outline-level)
                      (next-line)
                      (org-beginning-of-line)
                      (setq start (point))
                      (setq teststring (buffer-substring start (+ start 27)))
                      (outline-get-next-sibling)
                      (if (not (equal (point) (point-max)))
                          (previous-line))
                      (org-end-of-line)
                      (setq end (point))
                      (if (equal teststring "-----BEGIN PGP MESSAGE-----")
                          (if (pgg-decrypt-region start end passphrase)
                              (pgg-display-output-buffer start end t)
                            (message "Can't decrypt region!"))
                        (if (equal rcpts '(""))
                            (pgg-encrypt-symmetric-region start end passphrase)
                          (pgg-encrypt-region start end rcpts nil passphrase))
                        (pgg-display-output-buffer start end t)))
                   "+ENCRYPT"))



-- 
aleblanc



_______________________________________________
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

Reply via email to