From 1b4d14717024055c662c97ad7d2fc1abcb0a998e Mon Sep 17 00:00:00 2001 From: Amr Gharbeia Date: Mon, 4 May 2026 12:04:56 -0400 Subject: [PATCH] fix: archivist-create-note handler-case structure (C/T bugs) - handler-case had (log-message ...) and t as malformed clauses instead of return value - This caused the error clause to fall outside handler-case, making c undefined - Wrapped success path in progn: write-file + log-message + return t - Error clause (error (c) ...) now properly inside handler-case - Both bugs fixed by same structural change --- lisp/system-archivist.lisp | 35 ++++++++++++++++++----------------- org/system-archivist.org | 35 ++++++++++++++++++----------------- 2 files changed, 36 insertions(+), 34 deletions(-) diff --git a/lisp/system-archivist.lisp b/lisp/system-archivist.lisp index f9479fe..137f4d6 100644 --- a/lisp/system-archivist.lisp +++ b/lisp/system-archivist.lisp @@ -115,23 +115,24 @@ Returns T if note was created, nil if it already exists." (when (uiop:file-exists-p filepath) (return-from archivist-create-note nil)) (handler-case - (uiop:with-output-file (s filepath :if-exists :nil) - (format s "#+TITLE: ~a~%" title) - (format s "#+FILETAGS: :atomic:note:~:[~;~{~a~^:~}~]~%" tags tags) - (format s "~%* ~a~%" title) - (format s ":PROPERTIES:~%") - (format s ":CREATED: ~a~%" (org-id-generate)) - (format s ":SOURCE: ~a~%" source-basename) - (format s ":END:~%") - (format s "~%~a~%" content) - (format s "~%* Backlinks~%") - (format s "- Source: [[file:~a][~a]]~%" source-basename - (file-namestring source-filepath))) - (log-message "ARCHIVIST: Created note ~a" (namestring filepath)) - t) - (error (c) - (log-message "ARCHIVIST: Failed to create note ~a: ~a" filepath c) - nil))) + (progn + (uiop:with-output-file (s filepath :if-exists :nil) + (format s "#+TITLE: ~a~%" title) + (format s "#+FILETAGS: :atomic:note:~:[~;~{~a~^:~}~]~%" tags tags) + (format s "~%* ~a~%" title) + (format s ":PROPERTIES:~%") + (format s ":CREATED: ~a~%" (org-id-generate)) + (format s ":SOURCE: ~a~%" source-basename) + (format s ":END:~%") + (format s "~%~a~%" content) + (format s "~%* Backlinks~%") + (format s "- Source: [[file:~a][~a]]~%" source-basename + (file-namestring source-filepath))) + (log-message "ARCHIVIST: Created note ~a" (namestring filepath)) + t) + (error (c) + (log-message "ARCHIVIST: Failed to create note ~a: ~a" filepath c) + nil)))) (defun archivist-gardener-scan () "Scans the Memex for broken file links and orphaned memory objects. diff --git a/org/system-archivist.org b/org/system-archivist.org index ed01fc5..ef357a9 100644 --- a/org/system-archivist.org +++ b/org/system-archivist.org @@ -167,23 +167,24 @@ Returns T if note was created, nil if it already exists." (when (uiop:file-exists-p filepath) (return-from archivist-create-note nil)) (handler-case - (uiop:with-output-file (s filepath :if-exists :nil) - (format s "#+TITLE: ~a~%" title) - (format s "#+FILETAGS: :atomic:note:~:[~;~{~a~^:~}~]~%" tags tags) - (format s "~%* ~a~%" title) - (format s ":PROPERTIES:~%") - (format s ":CREATED: ~a~%" (org-id-generate)) - (format s ":SOURCE: ~a~%" source-basename) - (format s ":END:~%") - (format s "~%~a~%" content) - (format s "~%* Backlinks~%") - (format s "- Source: [[file:~a][~a]]~%" source-basename - (file-namestring source-filepath))) - (log-message "ARCHIVIST: Created note ~a" (namestring filepath)) - t) - (error (c) - (log-message "ARCHIVIST: Failed to create note ~a: ~a" filepath c) - nil))) + (progn + (uiop:with-output-file (s filepath :if-exists :nil) + (format s "#+TITLE: ~a~%" title) + (format s "#+FILETAGS: :atomic:note:~:[~;~{~a~^:~}~]~%" tags tags) + (format s "~%* ~a~%" title) + (format s ":PROPERTIES:~%") + (format s ":CREATED: ~a~%" (org-id-generate)) + (format s ":SOURCE: ~a~%" source-basename) + (format s ":END:~%") + (format s "~%~a~%" content) + (format s "~%* Backlinks~%") + (format s "- Source: [[file:~a][~a]]~%" source-basename + (file-namestring source-filepath))) + (log-message "ARCHIVIST: Created note ~a" (namestring filepath)) + t) + (error (c) + (log-message "ARCHIVIST: Failed to create note ~a: ~a" filepath c) + nil)))) #+end_src #+end_src