Function: org-store-log-note
org-store-log-note is a byte-compiled function defined in org.el.gz.
Signature
(org-store-log-note)
Documentation
Finish taking a log note, and insert it to where it belongs.
Source Code
;; Defined in /usr/src/emacs/lisp/org/org.el.gz
(defvar org-note-abort nil) ; dynamically scoped
(defun org-store-log-note ()
"Finish taking a log note, and insert it to where it belongs."
(let ((txt (prog1 (buffer-string)
(kill-buffer)))
(note (cdr (assq org-log-note-purpose org-log-note-headings)))
lines)
(while (string-match "\\`# .*\n[ \t\n]*" txt)
(setq txt (replace-match "" t t txt)))
(when (string-match "\\s-+\\'" txt)
(setq txt (replace-match "" t t txt)))
(setq lines (and (not (equal "" txt)) (org-split-string txt "\n")))
(when (org-string-nw-p note)
(setq note
(org-replace-escapes
note
(list (cons "%u" (user-login-name))
(cons "%U" user-full-name)
(cons "%t" (format-time-string
(org-time-stamp-format 'long 'inactive)
org-log-note-effective-time))
(cons "%T" (format-time-string
(org-time-stamp-format 'long nil)
org-log-note-effective-time))
(cons "%d" (format-time-string
(org-time-stamp-format nil 'inactive)
org-log-note-effective-time))
(cons "%D" (format-time-string
(org-time-stamp-format nil nil)
org-log-note-effective-time))
(cons "%s" (cond
((not org-log-note-state) "")
((string-match-p org-ts-regexp
org-log-note-state)
(format "\"[%s]\""
(substring org-log-note-state 1 -1)))
(t (format "\"%s\"" org-log-note-state))))
(cons "%S"
(cond
((not org-log-note-previous-state) "")
((string-match-p org-ts-regexp
org-log-note-previous-state)
(format "\"[%s]\""
(substring
org-log-note-previous-state 1 -1)))
(t (format "\"%s\""
org-log-note-previous-state)))))))
(when lines (setq note (concat note " \\\\")))
(push note lines))
(when (and lines (not org-note-abort))
(with-current-buffer (marker-buffer org-log-note-marker)
(org-fold-core-ignore-modifications
(org-with-wide-buffer
;; Find location for the new note.
(goto-char org-log-note-marker)
(set-marker org-log-note-marker nil)
;; Note associated to a clock is to be located right after
;; the clock. Do not move point.
(unless (eq org-log-note-purpose 'clock-out)
(goto-char (org-log-beginning t)))
;; Make sure point is at the beginning of an empty line.
(cond ((not (bolp)) (let ((inhibit-read-only t)) (insert-and-inherit "\n")))
((looking-at "[ \t]*\\S-") (save-excursion (insert-and-inherit "\n"))))
;; In an existing list, add a new item at the top level.
;; Otherwise, indent line like a regular one.
(let ((itemp (org-in-item-p)))
(if itemp
(indent-line-to
(let ((struct (save-excursion
(goto-char itemp) (org-list-struct))))
(org-list-get-ind (org-list-get-top-point struct) struct)))
(org-indent-line)))
(insert-and-inherit (org-list-bullet-string "-") (pop lines))
(let ((ind (org-list-item-body-column (line-beginning-position))))
(dolist (line lines)
(insert-and-inherit "\n")
(unless (string-empty-p line)
(indent-line-to ind)
(insert-and-inherit line))))
(message "Note stored")
(org-back-to-heading t))))))
;; Don't add undo information when called from `org-agenda-todo'.
(set-window-configuration org-log-note-window-configuration)
(with-current-buffer (marker-buffer org-log-note-return-to)
(goto-char org-log-note-return-to))
(move-marker org-log-note-return-to nil)
(when org-log-post-message (message "%s" org-log-post-message)))