summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.org67
1 files changed, 50 insertions, 17 deletions
diff --git a/config.org b/config.org
index bbf2457..130aee5 100644
--- a/config.org
+++ b/config.org
@@ -853,19 +853,46 @@ it directly during startup rather than creating it on demand.
(calendar-gregorian-from-absolute
(time-to-days (or time (current-time)))))
+ (defun ss/journal-year-heading (&optional time)
+ "Return the journal year heading text for TIME."
+ (format-time-string "%Y" (or time (current-time))))
+
+ (defun ss/journal-day-heading (&optional time)
+ "Return the journal day heading text for TIME."
+ (format-time-string "%Y-%m-%d %A" (or time (current-time))))
+
+ (defun ss/journal-find-or-create-heading (level heading)
+ "Move to HEADING at LEVEL, creating it when missing."
+ (goto-char (point-min))
+ (if (re-search-forward
+ (format "^%s %s$"
+ (make-string level ?*)
+ (regexp-quote heading))
+ nil t)
+ (goto-char (match-beginning 0))
+ (goto-char (point-max))
+ (unless (bolp)
+ (insert "\n"))
+ (insert (make-string level ?*) " " heading "\n")
+ (forward-line -1))
+ (org-back-to-heading t))
+
(defun ss/journal-goto-date (&optional time create)
"Move to TIME's journal date heading.
When CREATE is non-nil, create the datetree entry when missing."
(goto-char (point-min))
(if create
- (progn
- (require 'org-datetree)
- (org-datetree-find-date-create (ss/journal-calendar-date time))
- (org-back-to-heading t)
+ (let ((year-heading (ss/journal-year-heading time))
+ (day-heading (ss/journal-day-heading time)))
+ (ss/journal-find-or-create-heading 1 year-heading)
+ (save-restriction
+ (org-narrow-to-subtree)
+ (ss/journal-find-or-create-heading 2 day-heading))
t)
(when (re-search-forward
- (format "^\\*+ %s\\b"
- (format-time-string "%Y-%m-%d" (or time (current-time))))
+ (format "^\\*\\* %s$"
+ (regexp-quote
+ (ss/journal-day-heading (or time (current-time)))))
nil t)
(goto-char (match-beginning 0))
t)))
@@ -874,15 +901,16 @@ When CREATE is non-nil, create the datetree entry when missing."
"Ensure the standard section headings exist under the current journal day."
(org-back-to-heading t)
(let ((section-level (1+ (org-outline-level))))
- (save-restriction
- (org-narrow-to-subtree)
- (dolist (section ss/journal-section-headings)
- (goto-char (point-min))
- (unless (org-find-exact-headline-in-buffer section)
- (goto-char (point-max))
- (unless (bolp)
- (insert "\n"))
- (insert (make-string section-level ?*) " " section "\n"))))))
+ (save-excursion
+ (save-restriction
+ (org-narrow-to-subtree)
+ (dolist (section ss/journal-section-headings)
+ (goto-char (point-min))
+ (unless (org-find-exact-headline-in-buffer section)
+ (goto-char (point-max))
+ (unless (bolp)
+ (insert "\n"))
+ (insert (make-string section-level ?*) " " section "\n")))))))
(defun ss/journal-goto-section (section &optional time)
"Move to SECTION beneath TIME's journal date, creating structure as needed."
@@ -912,6 +940,10 @@ When CREATE is non-nil, create the datetree entry when missing."
(widen)
(ss/journal-goto-section section (ss/journal-capture-time)))
+ (defun ss/journal-meeting-heading ()
+ "Return the default heading for a journal meeting entry."
+ (format-time-string "%H:%M " (ss/journal-capture-time)))
+
(defun ss/refresh-org-agenda-files (&rest _)
"Refresh `org-agenda-files' from the journal and PARA directories.
Ignore any arguments passed by advice wrappers."
@@ -966,7 +998,8 @@ When CREATE is non-nil, create the datetree entry when missing."
("C-c n R" . ss/people-report-by-relationship))
:config
(setq org-directory ss/org-directory
- org-hide-emphasis-markers t)
+ org-hide-emphasis-markers t
+ org-agenda-search-headline-for-time t)
(add-hook 'org-mode-hook
(lambda ()
(setq-local org-hide-emphasis-markers t)
@@ -1001,7 +1034,7 @@ structured card file rather than turning into another capture target.
"* %?")
("jm" "Meeting" entry
(function (lambda () (ss/journal-capture-target "Meetings")))
- "* %<%H:%M> meeting %?")
+ "* %(ss/journal-meeting-heading)%?\n<%<%Y-%m-%d>>")
("n" "Denote")
("nn" "Generic" plain
(file denote-last-path)