Commit 0605883e91cf
Changed files (2)
dots
.config
emacs
site-lisp
dots/.config/emacs/site-lisp/journelly.el
@@ -11,19 +11,22 @@
;; Smart capture system for Journelly.org journal entries.
;;
;; Features:
-;; - Create-or-append behavior: first entry creates, subsequent append
+;; - Create-or-append behavior: first entry creates, subsequent append with timestamps
;; - Automatic location and weather via IP geolocation
;; - Separate entries for regular journal and Claude sessions
;; - Full org-capture integration
;;
;; Entry formats:
;; - Regular: * [YYYY-MM-DD Day HH:MM] @ hostname in Location
+;; - HH:MM :: entry content (appended entries)
;; - Claude: * [YYYY-MM-DD Day HH:MM] @ Claude session
+;; - HH:MM :: session summary (automated only)
;;
;; Usage:
;; (require 'journelly)
-;; ;; Use org-capture: C-c o c then 'j' or 'J'
+;; ;; Use org-capture: C-c o c then 'j' for journal
;; ;; Or quick functions: M-x journelly-quick-entry
+;; ;; Claude sessions: programmatic only via journelly-claude-session
;;; Code:
@@ -67,12 +70,6 @@ Returns the position of the entry if found, nil otherwise."
(format "^\\* \\[%s.*@ Claude session" today) nil t)
(line-beginning-position)))))
-(defun journelly--get-entry-end ()
- "Get the end position of current org entry (before next heading)."
- (save-excursion
- (org-end-of-subtree t)
- (point)))
-
(defun journelly--goto-insert-position ()
"Navigate to the correct insert position for new journal entries.
Goes after the file header but before existing entries."
@@ -129,11 +126,14 @@ Creates new entry if today's doesn't exist, or appends to existing."
;; Entry exists - go to end to append
(progn
(goto-char entry-pos)
- (goto-char (journelly--get-entry-end))
- ;; Move back one line to insert before the blank line
- (forward-line -1)
+ (org-end-of-subtree t)
+ ;; Skip back over any trailing blank lines
+ (while (and (not (bobp))
+ (looking-back "^[ \t]*\n" (line-beginning-position 0)))
+ (forward-line -1))
+ ;; Now at the last non-blank line of content
(end-of-line)
- (insert "\n\n")
+ (insert "\n")
(point))
;; Entry doesn't exist - create new one
(journelly--goto-insert-position)
@@ -150,11 +150,14 @@ Creates new entry if today's Claude session doesn't exist, or appends."
;; Entry exists - go to end to append
(progn
(goto-char entry-pos)
- (goto-char (journelly--get-entry-end))
- ;; Move back one line to insert before the blank line
- (forward-line -1)
+ (org-end-of-subtree t)
+ ;; Skip back over any trailing blank lines
+ (while (and (not (bobp))
+ (looking-back "^[ \t]*\n" (line-beginning-position 0)))
+ (forward-line -1))
+ ;; Now at the last non-blank line of content
(end-of-line)
- (insert "\n\n")
+ (insert "\n")
(point))
;; Entry doesn't exist - create new one
(journelly--goto-insert-position)
@@ -185,7 +188,7 @@ Creates entry if it doesn't exist, or appends to existing entry."
(with-current-buffer (find-file-noselect org-journelly-file)
(save-excursion
(journelly-claude-capture-target)
- (insert (format "- %s :: %s" timestamp summary)))
+ (insert (format "- %s :: %s\n" timestamp summary)))
(save-buffer))
(message "Claude session logged")))
@@ -211,22 +214,12 @@ Call this after org-capture is loaded and org-journelly-file is defined."
(seq-remove (lambda (x) (member (car x) '("j" "J")))
org-capture-templates))
- ;; Smart default journal entry (creates or appends)
+ ;; Smart default journal entry (creates or appends with timestamp)
(add-to-list 'org-capture-templates
`("j" "๐ Journal entry" plain
(file+function ,org-journelly-file journelly-capture-target)
- "%?"
- :empty-lines 0
- :unnarrowed t)
- t)
-
- ;; Claude session entry (creates or appends)
- (add-to-list 'org-capture-templates
- `("J" "๐ค Claude session" plain
- (file+function ,org-journelly-file journelly-claude-capture-target)
"- %(format-time-string \"%H:%M\") :: %?"
- :empty-lines 0
- :unnarrowed t)
+ :empty-lines 0)
t))
;;; Keybindings
@@ -234,7 +227,6 @@ Call this after org-capture is loaded and org-journelly-file is defined."
(defun journelly-setup-keybindings ()
"Setup keybindings for Journelly functions."
(global-set-key (kbd "C-c j j") 'journelly-quick-entry)
- (global-set-key (kbd "C-c j J") 'journelly-claude-session)
(global-set-key (kbd "C-c j o") 'journelly-open))
;;; Auto-setup
@@ -246,11 +238,6 @@ Call this after org-capture is loaded and org-journelly-file is defined."
(with-eval-after-load 'org-capture
(journelly-setup-capture-templates))
-;; Setup register for quick access
-(with-eval-after-load 'emacs
- (when (boundp 'org-journelly-file)
- (set-register ?j `(file . ,org-journelly-file))))
-
(provide 'journelly)
;;; journelly.el ends here
dots/.config/emacs/init.el
@@ -42,7 +42,7 @@ It is shared with iOS and replace the deprecated `org-journal-file' below.")
(set-register ?i `(file . ,org-inbox-file))
(set-register ?t `(file . ,org-todos-file))
(set-register ?c `(file . ,org-calendar-file))
-(set-register ?j `(file . ,org-journal-file))
+(set-register ?j `(file . ,org-journelly-file))
(set-register ?o `(file . ,org-directory))
(set-register ?n `(file . ,org-notes-directory))
(set-register ?P `(file . ,org-people-dir))