diff options
| -rw-r--r-- | lisp/org/org-crypt.el | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/lisp/org/org-crypt.el b/lisp/org/org-crypt.el index 6dfa2ee15e1..eda11a2c819 100644 --- a/lisp/org/org-crypt.el +++ b/lisp/org/org-crypt.el | |||
| @@ -1,7 +1,6 @@ | |||
| 1 | ;;; org-crypt.el --- Public key encryption for org-mode entries | 1 | ;;; org-crypt.el --- Public key encryption for org-mode entries |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 2009 Peter Jones <pjones@pmade.com> | 3 | ;; Copyright (C) 2007, 2009 Free Software Foundation, Inc. |
| 4 | ;; Copyright (C) 2007 John Wiegley <johnw@gnu.org> | ||
| 5 | 4 | ||
| 6 | ;; Emacs Lisp Archive Entry | 5 | ;; Emacs Lisp Archive Entry |
| 7 | ;; Filename: org-crypt.el | 6 | ;; Filename: org-crypt.el |
| @@ -95,7 +94,7 @@ heading. This can also be overridden in the CRYPTKEY property." | |||
| 95 | "Returns the encryption key for the current heading." | 94 | "Returns the encryption key for the current heading." |
| 96 | (save-excursion | 95 | (save-excursion |
| 97 | (org-back-to-heading t) | 96 | (org-back-to-heading t) |
| 98 | (or (org-entry-get nil "CRYPTKEY" 'selective) | 97 | (or (org-entry-get nil "CRYPTKEY" 'selective) |
| 99 | org-crypt-key | 98 | org-crypt-key |
| 100 | (and (boundp 'epa-file-encrypt-to) epa-file-encrypt-to) | 99 | (and (boundp 'epa-file-encrypt-to) epa-file-encrypt-to) |
| 101 | (error "No crypt key set")))) | 100 | (error "No crypt key set")))) |
| @@ -117,7 +116,7 @@ heading. This can also be overridden in the CRYPTKEY property." | |||
| 117 | (org-back-over-empty-lines) | 116 | (org-back-over-empty-lines) |
| 118 | (setq end (point) | 117 | (setq end (point) |
| 119 | encrypted-text | 118 | encrypted-text |
| 120 | (epg-encrypt-string | 119 | (epg-encrypt-string |
| 121 | epg-context | 120 | epg-context |
| 122 | (buffer-substring-no-properties beg end) | 121 | (buffer-substring-no-properties beg end) |
| 123 | (epg-list-keys epg-context crypt-key))) | 122 | (epg-list-keys epg-context crypt-key))) |
| @@ -137,12 +136,12 @@ heading. This can also be overridden in the CRYPTKEY property." | |||
| 137 | (forward-line) | 136 | (forward-line) |
| 138 | (when (looking-at "-----BEGIN PGP MESSAGE-----") | 137 | (when (looking-at "-----BEGIN PGP MESSAGE-----") |
| 139 | (let* ((beg (point)) | 138 | (let* ((beg (point)) |
| 140 | (end (save-excursion | 139 | (end (save-excursion |
| 141 | (search-forward "-----END PGP MESSAGE-----") | 140 | (search-forward "-----END PGP MESSAGE-----") |
| 142 | (forward-line) | 141 | (forward-line) |
| 143 | (point))) | 142 | (point))) |
| 144 | (epg-context (epg-make-context nil t t)) | 143 | (epg-context (epg-make-context nil t t)) |
| 145 | (decrypted-text | 144 | (decrypted-text |
| 146 | (decode-coding-string | 145 | (decode-coding-string |
| 147 | (epg-decrypt-string | 146 | (epg-decrypt-string |
| 148 | epg-context | 147 | epg-context |
| @@ -160,17 +159,17 @@ heading. This can also be overridden in the CRYPTKEY property." | |||
| 160 | 159 | ||
| 161 | (defun org-decrypt-entries () | 160 | (defun org-decrypt-entries () |
| 162 | (interactive) | 161 | (interactive) |
| 163 | (org-scan-tags | 162 | (org-scan-tags |
| 164 | 'org-decrypt-entry | 163 | 'org-decrypt-entry |
| 165 | (cdr (org-make-tags-matcher org-crypt-tag-matcher)))) | 164 | (cdr (org-make-tags-matcher org-crypt-tag-matcher)))) |
| 166 | 165 | ||
| 167 | (defun org-crypt-use-before-save-magic () | 166 | (defun org-crypt-use-before-save-magic () |
| 168 | "Adds a hook that will automatically encrypt entries before a | 167 | "Adds a hook that will automatically encrypt entries before a |
| 169 | file is saved to disk." | 168 | file is saved to disk." |
| 170 | (add-hook | 169 | (add-hook |
| 171 | 'org-mode-hook | 170 | 'org-mode-hook |
| 172 | (lambda () (add-hook 'before-save-hook 'org-encrypt-entries nil t)))) | 171 | (lambda () (add-hook 'before-save-hook 'org-encrypt-entries nil t)))) |
| 173 | 172 | ||
| 174 | (provide 'org-crypt) | 173 | (provide 'org-crypt) |
| 175 | 174 | ||
| 176 | ;; arch-tag: 8202ed2c-221e-4001-9e4b-54674a7e846e | 175 | ;; arch-tag: 8202ed2c-221e-4001-9e4b-54674a7e846e |