Commit 0605883e91cf

Vincent Demeester <vincent@sbr.pm>
2026-01-16 17:00:12
fix(emacs): improve journelly capture UX and positioning
Refine journelly capture behavior based on testing and user feedback: Capture UX improvements: - Remove :unnarrowed to show only entry instead of full file - Add timestamp format for appending (- HH:MM :: content) - Remove manual "J" Claude session capture (automated use only) - Remove C-c j J keybinding for manual Claude sessions Positioning fixes: - Fix capture target to reliably append at true end of entry - Replace unreliable forward-line -1 logic with proper blank line skipping - Entries now appear in chronological order, not randomly in middle - Add trailing newline in journelly-claude-session function Register updates: - Update ?j register to point to Journelly.org (was old journal file) - Remove duplicate register setup from journelly.el (init.el is canonical) Benefits: - Better focus: narrowed view shows only the entry being edited - Consistent timestamps: all appended entries get HH:MM format - Reliable ordering: new entries always append at the end - Clearer intent: Claude sessions are for automation, not manual entry Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent e61d755
Changed files (2)
dots
.config
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))