Function: org-decrypt-entry

org-decrypt-entry is an autoloaded, interactive and byte-compiled function defined in org-crypt.el.gz.

Signature

(org-decrypt-entry)

Documentation

Decrypt the content of the current headline.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-crypt.el.gz
;;;###autoload
(defun org-decrypt-entry ()
  "Decrypt the content of the current headline."
  (interactive)
  (pcase (org-at-encrypted-entry-p)
    (`(,beg . ,end)
     (require 'epg)
     (setq-local epg-context (epg-make-context nil t t))
     (org-with-point-at beg
       (org-crypt-check-auto-save)
       (let* ((folded-heading
	       (and (org-invisible-p)
		    (save-excursion
		      (org-previous-visible-heading 1)
		      (point))))
	      (encrypted-text (org-crypt--encrypted-text beg end))
	      (decrypted-text
	       (decode-coding-string
		(epg-decrypt-string epg-context encrypted-text)
		'utf-8)))
	 ;; Delete region starting just before point, because the
	 ;; outline property starts at the \n of the heading.
	 (delete-region (1- (point)) end)
	 ;; Store a checksum of the decrypted and the encrypted text
	 ;; value.  This allows reusing the same encrypted text if the
	 ;; text does not change, and therefore avoid a re-encryption
	 ;; process.
	 (insert "\n"
		 (propertize decrypted-text
			     'org-crypt-checksum (sha1 decrypted-text)
			     'org-crypt-key (org-crypt-key-for-heading)
			     'org-crypt-text encrypted-text))
	 (when folded-heading
	   (goto-char folded-heading)
	   (org-fold-subtree t))
	 nil)))
    (_ nil)))