Resurrect `org-log-note-marker'

* lisp/org.el (org-log-note-buffer): Remove variable.
(org-log-note-marker): New variable.
(org-log-note-effective-time): Fix docstring.
(org-add-log-setup):
(org-add-log-note):
(org-store-log-note): Use new variable.

Unlike to previous variable, this one stores the location of the entry
where the note is going to be inserted, not necessarily the location of
the note, which is computed later.
This commit is contained in:
Nicolas Goaziou 2016-01-07 23:33:27 +01:00
parent f56caace8a
commit 910418282a
1 changed files with 10 additions and 7 deletions

View File

@ -13561,7 +13561,8 @@ WHAT entry will also be removed."
(unless (eolp) (insert " ")) (unless (eolp) (insert " "))
ts)))))) ts))))))
(defvar org-log-note-buffer nil) (defvar org-log-note-marker (make-marker)
"Marker pointing at the entry where the note is to be inserted.")
(defvar org-log-note-purpose nil) (defvar org-log-note-purpose nil)
(defvar org-log-note-state nil) (defvar org-log-note-state nil)
(defvar org-log-note-previous-state nil) (defvar org-log-note-previous-state nil)
@ -13570,8 +13571,7 @@ WHAT entry will also be removed."
(defvar org-log-note-return-to (make-marker)) (defvar org-log-note-return-to (make-marker))
(defvar org-log-note-effective-time nil (defvar org-log-note-effective-time nil
"Remembered current time so that dynamically scoped "Remembered current time so that dynamically scoped
`org-extend-today-until' affects tha timestamps in state change `org-extend-today-until' affects timestamps in state change log")
log")
(defvar org-log-post-message nil (defvar org-log-post-message nil
"Message to be displayed after a log note has been stored. "Message to be displayed after a log note has been stored.
@ -13628,8 +13628,8 @@ narrowing."
If this is about to TODO state change, the new state is expected in STATE. If this is about to TODO state change, the new state is expected in STATE.
HOW is an indicator what kind of note should be created. HOW is an indicator what kind of note should be created.
EXTRA is additional text that will be inserted into the notes buffer." EXTRA is additional text that will be inserted into the notes buffer."
(setq org-log-note-buffer (current-buffer) (move-marker org-log-note-marker (point))
org-log-note-purpose purpose (setq org-log-note-purpose purpose
org-log-note-state state org-log-note-state state
org-log-note-previous-state prev-state org-log-note-previous-state prev-state
org-log-note-how how org-log-note-how how
@ -13666,7 +13666,8 @@ EXTRA is additional text that will be inserted into the notes buffer."
(setq org-log-note-window-configuration (current-window-configuration)) (setq org-log-note-window-configuration (current-window-configuration))
(delete-other-windows) (delete-other-windows)
(move-marker org-log-note-return-to (point)) (move-marker org-log-note-return-to (point))
(org-pop-to-buffer-same-window org-log-note-buffer) (org-pop-to-buffer-same-window (marker-buffer org-log-note-marker))
(goto-char org-log-note-marker)
(org-switch-to-buffer-other-window "*Org Note*") (org-switch-to-buffer-other-window "*Org Note*")
(erase-buffer) (erase-buffer)
(if (memq org-log-note-how '(time state)) (if (memq org-log-note-how '(time state))
@ -13748,9 +13749,11 @@ EXTRA is additional text that will be inserted into the notes buffer."
(when lines (setq note (concat note " \\\\"))) (when lines (setq note (concat note " \\\\")))
(push note lines)) (push note lines))
(when (and lines (not (or current-prefix-arg org-note-abort))) (when (and lines (not (or current-prefix-arg org-note-abort)))
(with-current-buffer org-log-note-buffer (with-current-buffer (marker-buffer org-log-note-marker)
(org-with-wide-buffer (org-with-wide-buffer
;; Find location for the new note. ;; Find location for the new note.
(goto-char org-log-note-marker)
(set-marker org-log-note-marker nil)
(goto-char (org-log-beginning t)) (goto-char (org-log-beginning t))
;; Make sure point is at the beginning of an empty line. ;; Make sure point is at the beginning of an empty line.
(cond ((not (bolp)) (let ((inhibit-read-only t)) (insert "\n"))) (cond ((not (bolp)) (let ((inhibit-read-only t)) (insert "\n")))