org-crypt-decrypt-entry: Apply initial visibility upon decryption
* lisp/org-crypt.el: Call `org-cycle-set-startup-visibility' on the decrypted entries. Still re-fold if the decrypted entry has been inside an existing fold. * lisp/org-cycle.el (org-cycle-set-visibility-according-to-property): Respect narrowing. * etc/ORG-NEWS (=org-crypt.el= now applies initial visibility settings to decrypted entries): Announce the change. This patch solves a slight annoyance when the freshly decrypted entry is fully unfolded, including all the property drawers. It will make more sense to make the folding state follow initial visibility settings, including VISIBILITY properties.
This commit is contained in:
parent
9d06e7bf80
commit
fe74a3ed2d
|
@ -222,6 +222,10 @@ execution completes. The new ~:async~ header allows users to continue
|
||||||
editing with Emacs while a ~:session~ block executes.
|
editing with Emacs while a ~:session~ block executes.
|
||||||
|
|
||||||
** Miscellaneous
|
** Miscellaneous
|
||||||
|
*** =org-crypt.el= now applies initial visibility settings to decrypted entries
|
||||||
|
|
||||||
|
Previously, all the text was unfolded unconditionally, including property drawers.
|
||||||
|
|
||||||
*** Blank lines after removed objects are not retained during export
|
*** Blank lines after removed objects are not retained during export
|
||||||
|
|
||||||
When certain objects in Org document are to be excluded from export,
|
When certain objects in Org document are to be excluded from export,
|
||||||
|
|
|
@ -81,6 +81,7 @@
|
||||||
(declare-function org-previous-visible-heading "org" (arg))
|
(declare-function org-previous-visible-heading "org" (arg))
|
||||||
(declare-function org-scan-tags "org" (action matcher todo-only &optional start-level))
|
(declare-function org-scan-tags "org" (action matcher todo-only &optional start-level))
|
||||||
(declare-function org-set-property "org" (property value))
|
(declare-function org-set-property "org" (property value))
|
||||||
|
(declare-function org-cycle-set-startup-visibility "org-cycle" ())
|
||||||
|
|
||||||
(defgroup org-crypt nil
|
(defgroup org-crypt nil
|
||||||
"Org Crypt."
|
"Org Crypt."
|
||||||
|
@ -269,10 +270,12 @@ Assume `epg-context' is set."
|
||||||
(decrypted-text
|
(decrypted-text
|
||||||
(decode-coding-string
|
(decode-coding-string
|
||||||
(epg-decrypt-string epg-context encrypted-text)
|
(epg-decrypt-string epg-context encrypted-text)
|
||||||
'utf-8)))
|
'utf-8))
|
||||||
|
origin-marker)
|
||||||
;; Delete region starting just before point, because the
|
;; Delete region starting just before point, because the
|
||||||
;; outline property starts at the \n of the heading.
|
;; outline property starts at the \n of the heading.
|
||||||
(delete-region (1- (point)) end)
|
(delete-region (1- (point)) end)
|
||||||
|
(setq origin-marker (point-marker))
|
||||||
;; Store a checksum of the decrypted and the encrypted text
|
;; Store a checksum of the decrypted and the encrypted text
|
||||||
;; value. This allows reusing the same encrypted text if the
|
;; value. This allows reusing the same encrypted text if the
|
||||||
;; text does not change, and therefore avoid a re-encryption
|
;; text does not change, and therefore avoid a re-encryption
|
||||||
|
@ -282,6 +285,12 @@ Assume `epg-context' is set."
|
||||||
'org-crypt-checksum (sha1 decrypted-text)
|
'org-crypt-checksum (sha1 decrypted-text)
|
||||||
'org-crypt-key (org-crypt-key-for-heading)
|
'org-crypt-key (org-crypt-key-for-heading)
|
||||||
'org-crypt-text encrypted-text))
|
'org-crypt-text encrypted-text))
|
||||||
|
;; Apply initial visibility.
|
||||||
|
(save-restriction
|
||||||
|
(narrow-to-region origin-marker (point))
|
||||||
|
(set-marker origin-marker nil)
|
||||||
|
(org-cycle-set-startup-visibility))
|
||||||
|
;; ... but keep the previous folded state.
|
||||||
(when folded-heading
|
(when folded-heading
|
||||||
(goto-char folded-heading)
|
(goto-char folded-heading)
|
||||||
(org-fold-subtree t))
|
(org-fold-subtree t))
|
||||||
|
|
|
@ -638,20 +638,21 @@ With a numeric prefix, show all headlines up to that level."
|
||||||
"Switch subtree visibility according to VISIBILITY property."
|
"Switch subtree visibility according to VISIBILITY property."
|
||||||
(interactive)
|
(interactive)
|
||||||
(let ((regexp (org-re-property "VISIBILITY")))
|
(let ((regexp (org-re-property "VISIBILITY")))
|
||||||
(org-with-point-at 1
|
(save-excursion
|
||||||
|
(goto-char (point-min))
|
||||||
(while (re-search-forward regexp nil t)
|
(while (re-search-forward regexp nil t)
|
||||||
(let ((state (match-string 3)))
|
(let ((state (match-string 3)))
|
||||||
(if (not (org-at-property-p)) (outline-next-heading)
|
(if (not (org-at-property-p)) (outline-next-heading)
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(org-back-to-heading t)
|
(org-back-to-heading t)
|
||||||
(org-fold-subtree t)
|
(org-fold-subtree t)
|
||||||
(pcase state
|
(pcase state
|
||||||
("folded"
|
("folded"
|
||||||
(org-fold-subtree t))
|
(org-fold-subtree t))
|
||||||
("children"
|
("children"
|
||||||
(org-fold-show-hidden-entry)
|
(org-fold-show-hidden-entry)
|
||||||
(org-fold-show-children))
|
(org-fold-show-children))
|
||||||
("content"
|
("content"
|
||||||
;; Newline before heading will be outside the
|
;; Newline before heading will be outside the
|
||||||
;; narrowing. Make sure that it is revealed.
|
;; narrowing. Make sure that it is revealed.
|
||||||
(org-fold-heading nil)
|
(org-fold-heading nil)
|
||||||
|
@ -659,9 +660,9 @@ With a numeric prefix, show all headlines up to that level."
|
||||||
(save-restriction
|
(save-restriction
|
||||||
(org-narrow-to-subtree)
|
(org-narrow-to-subtree)
|
||||||
(org-cycle-content))))
|
(org-cycle-content))))
|
||||||
((or "all" "showall")
|
((or "all" "showall")
|
||||||
(org-fold-show-subtree))
|
(org-fold-show-subtree))
|
||||||
(_ nil)))
|
(_ nil)))
|
||||||
(org-end-of-subtree t)))))))
|
(org-end-of-subtree t)))))))
|
||||||
|
|
||||||
(defun org-cycle-overview ()
|
(defun org-cycle-overview ()
|
||||||
|
|
Loading…
Reference in New Issue