diff --git a/org.el b/org.el index d33d0ad..dd48e1d 100644 --- a/org.el +++ b/org.el @@ -14893,30 +14893,36 @@ The auto-repeater uses this.") (defun org-add-log-note (&optional purpose) "Pop up a window for taking a note, and add this note later at point." (remove-hook 'post-command-hook 'org-add-log-note) - (setq org-log-note-window-configuration (current-window-configuration)) - (delete-other-windows) - (move-marker org-log-note-return-to (point)) - (switch-to-buffer (marker-buffer org-log-note-marker)) - (goto-char org-log-note-marker) - (org-switch-to-buffer-other-window "*Org Note*") - (erase-buffer) - (let ((org-inhibit-startup t)) (org-mode)) - (insert (format "# Insert note for %s. + (catch 'exit + (when (string-match + "%!" (cdr (assq org-log-note-purpose org-log-note-headings))) + ;; The note should be construed and filled silently + (org-store-log-note t) + (throw 'exit t)) + (setq org-log-note-window-configuration (current-window-configuration)) + (delete-other-windows) + (move-marker org-log-note-return-to (point)) + (switch-to-buffer (marker-buffer org-log-note-marker)) + (goto-char org-log-note-marker) + (org-switch-to-buffer-other-window "*Org Note*") + (erase-buffer) + (let ((org-inhibit-startup t)) (org-mode)) + (insert (format "# Insert note for %s. # Finish with C-c C-c, or cancel with C-c C-k.\n\n" - (cond - ((eq org-log-note-purpose 'clock-out) "stopped clock") - ((eq org-log-note-purpose 'done) "closed todo item") - ((eq org-log-note-purpose 'state) - (format "state change to \"%s\"" org-log-note-state)) - (t (error "This should not happen"))))) - (org-set-local 'org-finish-function 'org-store-log-note)) - -(defun org-store-log-note () + (cond + ((eq org-log-note-purpose 'clock-out) "stopped clock") + ((eq org-log-note-purpose 'done) "closed todo item") + ((eq org-log-note-purpose 'state) + (format "state change to \"%s\"" org-log-note-state)) + (t (error "This should not happen"))))) + (org-set-local 'org-finish-function 'org-store-log-note))) + +(defun org-store-log-note (&optional auto-note) "Finish taking a log note, and insert it to where it belongs." - (let ((txt (buffer-string)) + (let ((txt (if auto-note "" (buffer-string))) (note (cdr (assq org-log-note-purpose org-log-note-headings))) lines ind) - (kill-buffer (current-buffer)) + (unless auto-note (kill-buffer (current-buffer))) (while (string-match "\\`#.*\n[ \t\n]*" txt) (setq txt (replace-match "" t t txt))) (if (string-match "\\s-+\\'" txt) @@ -14933,7 +14939,8 @@ The auto-repeater uses this.") (current-time))) (cons "%s" (if org-log-note-state (concat "\"" org-log-note-state "\"") - ""))))) + "")) + (cons "%!" "")))) (if lines (setq note (concat note " \\\\"))) (push note lines)) (when (or current-prefix-arg org-note-abort) (setq lines nil)) @@ -14953,10 +14960,11 @@ The auto-repeater uses this.") (setq ind (concat (match-string 0) " ")) (end-of-line 1) (while lines (insert "\n" ind (pop lines))))))) - (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) + (unless auto-note + (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)) (and org-log-post-message (message "%s" org-log-post-message))) ;; FIXME: what else would be useful?