diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 8b5079f6f..ae44e5ab8 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -3,6 +3,9 @@ * org.el (org-read-date-history): New variable. (org-read-date): Use new history variable. (org-toggle-heading): Fix bug when used before first headline. + (org-store-log-note): Remove drawer if empty while note is + aborted. + (org-remove-empty-drawer-at): New function. * org-exp.el (org-export-as-ascii): Improve export of plain lists. diff --git a/lisp/org.el b/lisp/org.el index ccf692399..85a7a4195 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -9563,7 +9563,12 @@ EXTRA is additional text that will be inserted into the notes buffer." "\"\""))))) (if lines (setq note (concat note " \\\\"))) (push note lines)) - (when (or current-prefix-arg org-note-abort) (setq lines nil)) + (when (or current-prefix-arg org-note-abort) + (when org-log-into-drawer + (org-remove-empty-drawer-at + (if (stringp org-log-into-drawer) org-log-into-drawer "LOGBOOK") + org-log-note-marker)) + (setq lines nil)) (when lines (save-excursion (set-buffer (marker-buffer org-log-note-marker)) @@ -9588,6 +9593,18 @@ EXTRA is additional text that will be inserted into the notes buffer." (move-marker org-log-note-return-to nil) (and org-log-post-message (message "%s" org-log-post-message))) +(defun org-remove-empty-drawer-at (drawer pos) + "Remove an emptyr DARWER drawer at position POS. +POS may also be a marker." + (with-current-buffer (if (markerp pos) (marker-buffer pos) (current-buffer)) + (save-excursion + (save-restriction + (widen) + (goto-char pos) + (if (org-in-regexp + (concat "^[ \t]*:" drawer ":[ \t]*\n[ \t]*:END:[ \t]*\n?") 2) + (replace-match "")))))) + (defun org-sparse-tree (&optional arg) "Create a sparse tree, prompt for the details. This command can create sparse trees. You first need to select the type