diff options
Diffstat (limited to 'lisp/org-crypt.el')
-rw-r--r-- | lisp/org-crypt.el | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lisp/org-crypt.el b/lisp/org-crypt.el index 1039996..3c431e4 100644 --- a/lisp/org-crypt.el +++ b/lisp/org-crypt.el @@ -1,5 +1,5 @@ ;;; org-crypt.el --- Public Key Encryption for Org Entries -*- lexical-binding: t; -*- -;; Copyright (C) 2007-2016 Free Software Foundation, Inc. +;; Copyright (C) 2007-2017 Free Software Foundation, Inc. ;; Emacs Lisp Archive Entry ;; Filename: org-crypt.el @@ -176,14 +176,18 @@ See `org-crypt-disable-auto-save'." (let ((start-heading (point))) (org-end-of-meta-data) (unless (looking-at-p "-----BEGIN PGP MESSAGE-----") - (let ((folded (outline-invisible-p)) + (let ((folded (org-invisible-p)) (crypt-key (org-crypt-key-for-heading)) (beg (point))) (goto-char start-heading) (org-end-of-subtree t t) (org-back-over-empty-lines) (let ((contents (delete-and-extract-region beg (point)))) - (insert (org-encrypt-string contents crypt-key))) + (condition-case err + (insert (org-encrypt-string contents crypt-key)) + ;; If encryption failed, make sure to insert back entry + ;; contents in the buffer. + (error (insert contents) (error (nth 1 err))))) (when folded (goto-char start-heading) (outline-hide-subtree)) @@ -200,7 +204,7 @@ See `org-crypt-disable-auto-save'." (heading-was-invisible-p (save-excursion (outline-end-of-heading) - (outline-invisible-p)))) + (org-invisible-p)))) (org-end-of-meta-data) (when (looking-at "-----BEGIN PGP MESSAGE-----") (org-crypt-check-auto-save) |