Pārlūkot izejas kodu

org.el (org-end-of-meta-data): Allow to skip only standard drawers

* lisp/org.el (org-end-of-meta-data): Allow to skip only standard
drawers, i.e. properties and logbook drawers.

* lisp/org-crypt.el (org-at-encrypted-entry-p)
(org-encrypt-entry): Use `org-end-of-meta-data' so that standard
drawers are all skipped, including logbook drawers.

Reported-by: Nicolas Goaziou <mail@nicolasgoaziou.fr>
See https://orgmode.org/list/87d02qgj6u.fsf@nicolasgoaziou.fr
and https://debbugs.gnu.org/cgi/bugreport.cgi?bug=43094 for the reason
of the previous fix c93983613d.
Bastien Guerry 4 gadi atpakaļ
vecāks
revīzija
755367f362
2 mainītis faili ar 25 papildinājumiem un 11 dzēšanām
  1. 2 2
      lisp/org-crypt.el
  2. 23 9
      lisp/org.el

+ 2 - 2
lisp/org-crypt.el

@@ -145,7 +145,7 @@ and END are buffer positions delimiting the encrypted area."
   (org-with-wide-buffer
    (unless (org-before-first-heading-p)
      (org-back-to-heading t)
-     (org-end-of-meta-data t)
+     (org-end-of-meta-data 'standard)
      (let ((case-fold-search nil)
 	   (banner-start (rx (seq bol
 				  (zero-or-more (any "\t "))
@@ -215,7 +215,7 @@ Assume `epg-context' is set."
      (let ((start-heading (point))
 	   (crypt-key (org-crypt-key-for-heading))
 	   (folded? (org-invisible-p (line-beginning-position))))
-       (org-end-of-meta-data t)
+       (org-end-of-meta-data 'standard)
        (let ((beg (point))
 	     (folded-heading
 	      (and folded?

+ 23 - 9
lisp/org.el

@@ -20495,26 +20495,40 @@ If there is no such heading, return nil."
 
 (defun org-end-of-meta-data (&optional full)
   "Skip planning line and properties drawer in current entry.
-When optional argument FULL is non-nil, also skip empty lines,
-clocking lines and regular drawers at the beginning of the
-entry."
+
+When optional argument FULL is t, also skip planning information,
+clocking lines and any kind of drawer.
+
+When FULL is non-nil but not t, skip planning information,
+clocking lines and only non-regular drawers, i.e. properties and
+logbook drawers."
   (org-back-to-heading t)
   (forward-line)
+  ;; Skip planning information.
   (when (looking-at-p org-planning-line-re) (forward-line))
+  ;; Skip property drawer.
   (when (looking-at org-property-drawer-re)
     (goto-char (match-end 0))
     (forward-line))
+  ;; When FULL is not nil, skip more.
   (when (and full (not (org-at-heading-p)))
     (catch 'exit
       (let ((end (save-excursion (outline-next-heading) (point)))
 	    (re (concat "[ \t]*$" "\\|" org-clock-line-re)))
 	(while (not (eobp))
-	  (cond ((looking-at-p org-drawer-regexp)
-		 (if (re-search-forward "^[ \t]*:END:[ \t]*$" end t)
-		     (forward-line)
-		   (throw 'exit t)))
-		((looking-at-p re) (forward-line))
-		(t (throw 'exit t))))))))
+	  (cond ;; Skip clock lines.
+	   ((looking-at-p re) (forward-line))
+	   ;; Skip logbook drawer.
+	   ((looking-at-p org-logbook-drawer-re)
+	    (if (re-search-forward "^[ \t]*:END:[ \t]*$" end t)
+		(forward-line)
+	      (throw 'exit t)))
+	   ;; When FULL is t, skip regular drawer too.
+	   ((and (eq full t) (looking-at-p org-drawer-regexp))
+	    (if (re-search-forward "^[ \t]*:END:[ \t]*$" end t)
+		(forward-line)
+	      (throw 'exit t)))
+	   (t (throw 'exit t))))))))
 
 (defun org--line-fully-invisible-p ()
   "Return non-nil if the current line is fully invisible."