From 15d864a500d90c9dc2e16d888e93343528ec3941 Mon Sep 17 00:00:00 2001 From: Tyler Smith Date: Thu, 31 Dec 2020 23:48:20 -0500 Subject: [PATCH] (feat): add useful warning message to org-roam-dailies-find-next-note (#1365) If the user creates a new daily via `org-roam-dailies-find-today`, they will get a new buffer that hasn't yet been saved to disk. If they then try to navigate to the previous daily via `org-roam-dailies-find-previous-note`, they will get the error: `Wrong type argument: number-or-marker-p, nil` This is because the value of the local variable `position` is set only if the current buffer exists as a file in the dailies directory. It doesn't until the user explicitly saves it. That's not a big problem, but the solution is not obvious from the error message. I added a check that will provide the user with a more informative error message, so they know how to fix the issue: "Can't find current note file - have you saved it yet?" --- org-roam-dailies.el | 2 ++ 1 file changed, 2 insertions(+) diff --git a/org-roam-dailies.el b/org-roam-dailies.el index b03d491..cfc1e8b 100644 --- a/org-roam-dailies.el +++ b/org-roam-dailies.el @@ -301,6 +301,8 @@ negative, find note N days in the past." (string= (buffer-file-name (buffer-base-buffer)) candidate)) dailies)) note) + (unless position + (user-error "Can't find current note file - have you saved it yet?")) (pcase n ((pred (natnump)) (when (eq position (- (length dailies) 1))