diff options
author | Bastien Guerry <bastien.guerry@data.gouv.fr> | 2020-09-13 18:36:15 +0200 |
---|---|---|
committer | Bastien Guerry <bastien.guerry@data.gouv.fr> | 2020-09-13 18:36:15 +0200 |
commit | 755367f3624093ca3344953d8b045a5eaf0a95f6 (patch) | |
tree | 88afed9a407c3a3aadc96b5a38499d5405278a0f | |
parent | 8efec3d4cd4a4b3fe7cf46801449444b541fa287 (diff) | |
download | org-mode-755367f3624093ca3344953d8b045a5eaf0a95f6.tar.gz |
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.
-rw-r--r-- | lisp/org-crypt.el | 4 | ||||
-rw-r--r-- | lisp/org.el | 32 |
2 files changed, 25 insertions, 11 deletions
diff --git a/lisp/org-crypt.el b/lisp/org-crypt.el index 671d978..187560c 100644 --- a/lisp/org-crypt.el +++ b/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? diff --git a/lisp/org.el b/lisp/org.el index 5fb01b5..6e2de0d 100644 --- a/lisp/org.el +++ b/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." |