mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-08-26 12:32:53 +00:00
Notes: Remove empty drawer if note is aborted.
When a note is taken, the new drawer is created before the note is taken. Now the drawer is removed again if the note gets aborted and if the drawer is empty.
This commit is contained in:
parent
e56c7097f4
commit
3d2e1c0f04
|
@ -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.
|
||||
|
||||
|
|
19
lisp/org.el
19
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
|
||||
|
|
Loading…
Reference in a new issue