Browse Source

Make `org-reveal' also decrypt encrypted entries

Thanks to Richard Riley for triggering this change.
Carsten Dominik 10 years ago
parent
commit
7ef096f397
3 changed files with 28 additions and 0 deletions
  1. 8 0
      lisp/ChangeLog
  2. 5 0
      lisp/org-crypt.el
  3. 15 0
      lisp/org.el

+ 8 - 0
lisp/ChangeLog

@@ -1,9 +1,17 @@
 2010-03-21  Carsten Dominik  <carsten.dominik@gmail.com>
 
+	* org-crypt.el (org-reveal-start-hook): Add a decryption function
+	to this hook.
+	(org-decrypt-entries, org-encrypt-entries, org-decrypt-entry): Add
+	docstrings.
+
 	* org.el (org-point-at-end-of-empty-headline)
 	(org-level-increment, org-get-previous-line-level): New function.
 	(org-cycle-level): Rewritten to be independent of when this
 	function is called.
+	(org-in-regexps-block-p): New function.
+	(org-reveal-start-hook): New hook.
+	(org-reveal): Run new hook.
 
 2010-03-19  Carsten Dominik  <carsten.dominik@gmail.com>
 

+ 5 - 0
lisp/org-crypt.el

@@ -129,6 +129,7 @@ heading.  This can also be overridden in the CRYPTKEY property."
         nil))))
 
 (defun org-decrypt-entry ()
+  "Decrypt the content of the current headline."
   (interactive)
   (require 'epg)
   (save-excursion
@@ -152,12 +153,14 @@ heading.  This can also be overridden in the CRYPTKEY property."
         nil))))
 
 (defun org-encrypt-entries ()
+  "Encrypt all top-level entries in the current buffer."
   (interactive)
   (org-scan-tags
    'org-encrypt-entry
    (cdr (org-make-tags-matcher org-crypt-tag-matcher))))
 
 (defun org-decrypt-entries ()
+  "Decrypt all entries in the current buffer."
   (interactive)
   (org-scan-tags 
    'org-decrypt-entry
@@ -169,6 +172,8 @@ file is saved to disk."
   (add-hook 
    'org-mode-hook 
    (lambda () (add-hook 'before-save-hook 'org-encrypt-entries nil t))))
+
+(add-hook 'org-reveal-start-hook 'org-decrypt-entry)
   
 (provide 'org-crypt)
 

+ 15 - 0
lisp/org.el

@@ -11282,6 +11282,9 @@ How much context is shown depends upon the variables
 	    (org-flag-heading nil)
 	    (when siblings-p (org-show-siblings))))))))
 
+(defvar org-reveal-start-hook nil
+  "Hook run before revealing a location.")
+
 (defun org-reveal (&optional siblings)
   "Show current entry, hierarchy above it, and the following headline.
 This can be used to show a consistent set of context around locations
@@ -11294,6 +11297,7 @@ look like when opened with hierarchical calls to `org-cycle'.
 With double optional argument `C-u C-u', go to the parent and show the
 entire tree."
   (interactive "P")
+  (run-hooks 'org-reveal-start-hook)
   (let ((org-show-hierarchy-above t)
 	(org-show-following-heading t)
 	(org-show-siblings (if siblings t org-show-siblings)))
@@ -17078,6 +17082,17 @@ really on, so that the block visually is on the match."
 	      (throw 'exit t)))
 	nil))))
 
+(defun org-in-regexps-block-p (start-re end-re)
+  "Returns t if the current point is between matches of START-RE and END-RE.
+This will also return to if point is on one of the two matches."
+  (interactive)
+  (let ((p (point)))
+    (save-excursion
+      (and (or (org-at-regexp-p start-re)
+	       (re-search-backward start-re nil t))
+	   (re-search-forward end-re nil t)
+	   (>= (point) p)))))
+
 (defun org-occur-in-agenda-files (regexp &optional nlines)
   "Call `multi-occur' with buffers for all agenda files."
   (interactive "sOrg-files matching: \np")