aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/mu4e-org-contacts-integration.el7
-rw-r--r--modules/org-roam-config.el22
-rw-r--r--modules/org-webclipper.el31
3 files changed, 44 insertions, 16 deletions
diff --git a/modules/mu4e-org-contacts-integration.el b/modules/mu4e-org-contacts-integration.el
index 8ffdccd2..68f83dd2 100644
--- a/modules/mu4e-org-contacts-integration.el
+++ b/modules/mu4e-org-contacts-integration.el
@@ -13,6 +13,13 @@
(require 'mu4e nil t)
(require 'org-contacts nil t)
+;; Cross-module symbols this file references. Declared so byte-compile in
+;; isolation doesn't warn about free variables / undefined functions; the
+;; actual definitions live where named.
+(eval-when-compile (defvar contacts-file)) ; user-constants.el
+(declare-function cj/get-all-contact-emails ; org-contacts-config.el
+ "org-contacts-config" ())
+
;; ---------------------- Completion at Point Function -------------------------
(defun cj/org-contacts-completion-at-point ()
diff --git a/modules/org-roam-config.el b/modules/org-roam-config.el
index d0851ee4..306c7fe2 100644
--- a/modules/org-roam-config.el
+++ b/modules/org-roam-config.el
@@ -77,14 +77,26 @@
(global-set-key (kbd "C-c n d") org-roam-dailies-map)
(org-roam-db-autosync-mode))
-;; Move closed tasks to today's journal when marked done
+;; Move closed tasks to today's journal when marked done.
+
+(defun cj/--org-roam-should-copy-completed-task-p ()
+ "Return non-nil when the current org-state change should copy to today's journal.
+Skips:
+- Fileless buffers (org-capture, indirect buffers, temp Org buffers)
+- The gcal.org buffer (synced from Google Calendar)
+- State changes that didn't actually enter a done state
+- State changes where the previous state was already done (avoid re-copy)"
+ (let ((file (buffer-file-name)))
+ (and file
+ (bound-and-true-p org-state)
+ (member org-state org-done-keywords)
+ (not (member org-last-state org-done-keywords))
+ (not (string= file (expand-file-name gcal-file))))))
+
(with-eval-after-load 'org
(add-to-list 'org-after-todo-state-change-hook
(lambda ()
- (when (and (member org-state org-done-keywords)
- (not (member org-last-state org-done-keywords))
- ;; Don't run for gcal.org - it's synced from Google Calendar
- (not (string= (buffer-file-name) (expand-file-name gcal-file))))
+ (when (cj/--org-roam-should-copy-completed-task-p)
(cj/org-roam-copy-todo-to-today)))))
;; ------------------------- Org Roam Insert Immediate -------------------------
diff --git a/modules/org-webclipper.el b/modules/org-webclipper.el
index be4c1cb6..cf4cdbf0 100644
--- a/modules/org-webclipper.el
+++ b/modules/org-webclipper.el
@@ -68,12 +68,12 @@
(require 'org-web-tools)
(require 'user-constants) ;; for webclipped-file
- ;; Register the org-protocol handler
- (add-to-list 'org-protocol-protocol-alist
- '("webclip"
- :protocol "webclip"
- :function cj/org-protocol-webclip
- :kill-client t))
+ ;; The org-protocol handler registration lives in the
+ ;; `with-eval-after-load 'org-protocol' block at the bottom of
+ ;; this module -- that's the more robust home (it survives
+ ;; org-protocol being loaded before or after this module). Two
+ ;; registration sites would silently drift if the alist entry
+ ;; shape ever changes.
;; Add capture templates if not already present
(unless (assoc "W" org-capture-templates)
@@ -119,14 +119,23 @@ Returns the processed content as a string with:
(defun cj/org-protocol-webclip (info)
"Process org-protocol webclip requests.
-INFO is a plist containing :url and :title from the org-protocol call."
+INFO is a plist containing :url and :title from the org-protocol call.
+Signals `user-error' when :url is missing, nil, empty, or non-string -- an
+unexpected plist shape used to silently set the globals to nil and fail
+downstream inside the capture handler with confusing messages."
(cj/webclipper-ensure-initialized)
(let ((url (plist-get info :url))
(title (plist-get info :title)))
- (when url
- ;; Store the URL and title for the capture template to use
- (setq cj/webclip-current-url url
- cj/webclip-current-title (or title "Untitled")))
+ (unless (and (stringp url) (not (string-empty-p url)))
+ (user-error
+ "org-protocol webclip: expected non-empty :url string, got %S" url))
+ (when (and title (not (stringp title)))
+ (user-error
+ "org-protocol webclip: :title must be a string when provided, got %S"
+ title))
+ ;; Store the URL and title for the capture template to use
+ (setq cj/webclip-current-url url
+ cj/webclip-current-title (or title "Untitled"))
;; Trigger the capture
(org-capture nil "W")
nil)) ; Return nil to indicate we handled it