Fix `org-log-beginning' on empty entries
* lisp/org.el (org-log-beginning): Check for the need to insert a drawer in all cases. Suggested-by: Eric Abrahamsen <eric@ericabrahamsen.net> <http://permalink.gmane.org/gmane.emacs.orgmode/93538>
This commit is contained in:
parent
685e4b733a
commit
442216871a
58
lisp/org.el
58
lisp/org.el
|
@ -13630,35 +13630,35 @@ narrowing."
|
||||||
(when (looking-at org-property-drawer-re)
|
(when (looking-at org-property-drawer-re)
|
||||||
(goto-char (match-end 0))
|
(goto-char (match-end 0))
|
||||||
(forward-line))
|
(forward-line))
|
||||||
(if (org-at-heading-p) (point)
|
(let ((end (if (org-at-heading-p) (point)
|
||||||
(let ((end (save-excursion (outline-next-heading) (point)))
|
(save-excursion (outline-next-heading) (point))))
|
||||||
(drawer (org-log-into-drawer)))
|
(drawer (org-log-into-drawer)))
|
||||||
(cond
|
(cond
|
||||||
(drawer
|
(drawer
|
||||||
(let ((regexp (concat "^[ \t]*:" (regexp-quote drawer) ":[ \t]*$"))
|
(let ((regexp (concat "^[ \t]*:" (regexp-quote drawer) ":[ \t]*$"))
|
||||||
(case-fold-search t))
|
(case-fold-search t))
|
||||||
(catch 'exit
|
(catch 'exit
|
||||||
;; Try to find existing drawer.
|
;; Try to find existing drawer.
|
||||||
(while (re-search-forward regexp end t)
|
(while (re-search-forward regexp end t)
|
||||||
(let ((element (org-element-at-point)))
|
(let ((element (org-element-at-point)))
|
||||||
(when (eq (org-element-type element) 'drawer)
|
(when (eq (org-element-type element) 'drawer)
|
||||||
(let ((cend (org-element-property :contents-end element)))
|
(let ((cend (org-element-property :contents-end element)))
|
||||||
(when (and (not org-log-states-order-reversed) cend)
|
(when (and (not org-log-states-order-reversed) cend)
|
||||||
(goto-char cend)))
|
(goto-char cend)))
|
||||||
(throw 'exit nil))))
|
(throw 'exit nil))))
|
||||||
;; No drawer found. Create one, if permitted.
|
;; No drawer found. Create one, if permitted.
|
||||||
(when create
|
(when create
|
||||||
(unless (bolp) (insert "\n"))
|
(unless (bolp) (insert "\n"))
|
||||||
(let ((beg (point)))
|
(let ((beg (point)))
|
||||||
(insert ":" drawer ":\n:END:\n")
|
(insert ":" drawer ":\n:END:\n")
|
||||||
(org-indent-region beg (point)))
|
(org-indent-region beg (point)))
|
||||||
(end-of-line -1)))))
|
(end-of-line -1)))))
|
||||||
(org-log-state-notes-insert-after-drawers
|
(org-log-state-notes-insert-after-drawers
|
||||||
(while (and (looking-at org-drawer-regexp)
|
(while (and (looking-at org-drawer-regexp)
|
||||||
(progn (goto-char (match-end 0))
|
(progn (goto-char (match-end 0))
|
||||||
(re-search-forward org-property-end-re end t)))
|
(re-search-forward org-property-end-re end t)))
|
||||||
(forward-line)))))
|
(forward-line)))))
|
||||||
(if (bolp) (point) (line-beginning-position 2)))))
|
(if (bolp) (point) (line-beginning-position 2))))
|
||||||
|
|
||||||
(defun org-add-log-setup (&optional purpose state prev-state findpos how extra)
|
(defun org-add-log-setup (&optional purpose state prev-state findpos how extra)
|
||||||
"Set up the post command hook to take a note.
|
"Set up the post command hook to take a note.
|
||||||
|
|
Loading…
Reference in New Issue