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
This commit is contained in:
@@ -115,23 +115,24 @@ Returns T if note was created, nil if it already exists."
|
|||||||
(when (uiop:file-exists-p filepath)
|
(when (uiop:file-exists-p filepath)
|
||||||
(return-from archivist-create-note nil))
|
(return-from archivist-create-note nil))
|
||||||
(handler-case
|
(handler-case
|
||||||
(uiop:with-output-file (s filepath :if-exists :nil)
|
(progn
|
||||||
(format s "#+TITLE: ~a~%" title)
|
(uiop:with-output-file (s filepath :if-exists :nil)
|
||||||
(format s "#+FILETAGS: :atomic:note:~:[~;~{~a~^:~}~]~%" tags tags)
|
(format s "#+TITLE: ~a~%" title)
|
||||||
(format s "~%* ~a~%" title)
|
(format s "#+FILETAGS: :atomic:note:~:[~;~{~a~^:~}~]~%" tags tags)
|
||||||
(format s ":PROPERTIES:~%")
|
(format s "~%* ~a~%" title)
|
||||||
(format s ":CREATED: ~a~%" (org-id-generate))
|
(format s ":PROPERTIES:~%")
|
||||||
(format s ":SOURCE: ~a~%" source-basename)
|
(format s ":CREATED: ~a~%" (org-id-generate))
|
||||||
(format s ":END:~%")
|
(format s ":SOURCE: ~a~%" source-basename)
|
||||||
(format s "~%~a~%" content)
|
(format s ":END:~%")
|
||||||
(format s "~%* Backlinks~%")
|
(format s "~%~a~%" content)
|
||||||
(format s "- Source: [[file:~a][~a]]~%" source-basename
|
(format s "~%* Backlinks~%")
|
||||||
(file-namestring source-filepath)))
|
(format s "- Source: [[file:~a][~a]]~%" source-basename
|
||||||
(log-message "ARCHIVIST: Created note ~a" (namestring filepath))
|
(file-namestring source-filepath)))
|
||||||
t)
|
(log-message "ARCHIVIST: Created note ~a" (namestring filepath))
|
||||||
(error (c)
|
t)
|
||||||
(log-message "ARCHIVIST: Failed to create note ~a: ~a" filepath c)
|
(error (c)
|
||||||
nil)))
|
(log-message "ARCHIVIST: Failed to create note ~a: ~a" filepath c)
|
||||||
|
nil))))
|
||||||
|
|
||||||
(defun archivist-gardener-scan ()
|
(defun archivist-gardener-scan ()
|
||||||
"Scans the Memex for broken file links and orphaned memory objects.
|
"Scans the Memex for broken file links and orphaned memory objects.
|
||||||
|
|||||||
@@ -167,23 +167,24 @@ Returns T if note was created, nil if it already exists."
|
|||||||
(when (uiop:file-exists-p filepath)
|
(when (uiop:file-exists-p filepath)
|
||||||
(return-from archivist-create-note nil))
|
(return-from archivist-create-note nil))
|
||||||
(handler-case
|
(handler-case
|
||||||
(uiop:with-output-file (s filepath :if-exists :nil)
|
(progn
|
||||||
(format s "#+TITLE: ~a~%" title)
|
(uiop:with-output-file (s filepath :if-exists :nil)
|
||||||
(format s "#+FILETAGS: :atomic:note:~:[~;~{~a~^:~}~]~%" tags tags)
|
(format s "#+TITLE: ~a~%" title)
|
||||||
(format s "~%* ~a~%" title)
|
(format s "#+FILETAGS: :atomic:note:~:[~;~{~a~^:~}~]~%" tags tags)
|
||||||
(format s ":PROPERTIES:~%")
|
(format s "~%* ~a~%" title)
|
||||||
(format s ":CREATED: ~a~%" (org-id-generate))
|
(format s ":PROPERTIES:~%")
|
||||||
(format s ":SOURCE: ~a~%" source-basename)
|
(format s ":CREATED: ~a~%" (org-id-generate))
|
||||||
(format s ":END:~%")
|
(format s ":SOURCE: ~a~%" source-basename)
|
||||||
(format s "~%~a~%" content)
|
(format s ":END:~%")
|
||||||
(format s "~%* Backlinks~%")
|
(format s "~%~a~%" content)
|
||||||
(format s "- Source: [[file:~a][~a]]~%" source-basename
|
(format s "~%* Backlinks~%")
|
||||||
(file-namestring source-filepath)))
|
(format s "- Source: [[file:~a][~a]]~%" source-basename
|
||||||
(log-message "ARCHIVIST: Created note ~a" (namestring filepath))
|
(file-namestring source-filepath)))
|
||||||
t)
|
(log-message "ARCHIVIST: Created note ~a" (namestring filepath))
|
||||||
(error (c)
|
t)
|
||||||
(log-message "ARCHIVIST: Failed to create note ~a: ~a" filepath c)
|
(error (c)
|
||||||
nil)))
|
(log-message "ARCHIVIST: Failed to create note ~a: ~a" filepath c)
|
||||||
|
nil))))
|
||||||
#+end_src
|
#+end_src
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user