Explorar o código

org-crypt.el (org-at-encrypted-entry-p): Fix bug when the check happens before the first headline

* org-crypt.el (org-at-encrypted-entry-p): Fix bug when
the check happens before the first headline.
Bastien Guerry %!s(int64=12) %!d(string=hai) anos
pai
achega
8fbf78d185
Modificáronse 1 ficheiros con 5 adicións e 4 borrados
  1. 5 4
      lisp/org-crypt.el

+ 5 - 4
lisp/org-crypt.el

@@ -254,10 +254,11 @@ See `org-crypt-disable-auto-save'."
 
 (defun org-at-encrypted-entry-p ()
   "Is the current entry encrypted?"
-  (save-excursion
-    (org-back-to-heading t)
-    (search-forward "-----BEGIN PGP MESSAGE-----"
-		    (save-excursion (org-end-of-subtree t)) t)))
+  (unless (org-before-first-heading-p)
+    (save-excursion
+      (org-back-to-heading t)
+      (search-forward "-----BEGIN PGP MESSAGE-----"
+		      (save-excursion (org-end-of-subtree t)) t))))
 
 (defun org-crypt-use-before-save-magic ()
   "Add a hook to automatically encrypt entries before a file is saved to disk."