From ee85e40655c3825188e0e7774bc566c464c60626 Mon Sep 17 00:00:00 2001 From: Amr Gharbeia Date: Sun, 19 Apr 2026 16:03:33 -0400 Subject: [PATCH] fix(memory): Implement missing list-objects-with-attribute --- literate/memory.org | 12 ++++++++++++ src/memory.lisp | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/literate/memory.org b/literate/memory.org index cde6417..5ffb879 100644 --- a/literate/memory.org +++ b/literate/memory.org @@ -160,6 +160,18 @@ Basic functions for retrieving objects by ID or type. "Returns a list of all objects matching a specific Org element type." (let ((results nil)) (maphash (lambda (id obj) (declare (ignore id)) (when (eq (org-object-type obj) type) (push obj results))) *memory*) + results)) +(defun list-objects-with-attribute (attr-name value) + "Returns a list of all objects where ATTR-NAME matches VALUE." + (let ((results nil)) + (maphash (lambda (id obj) + (declare (ignore id)) + (let ((attrs (org-object-attributes obj))) + (when (equal (getf attrs attr-name) value) + (push obj results)))) + *memory*) + results)) + results)) #+end_src diff --git a/src/memory.lisp b/src/memory.lisp index 7c4144e..5fa3df5 100644 --- a/src/memory.lisp +++ b/src/memory.lisp @@ -92,6 +92,18 @@ (let ((results nil)) (maphash (lambda (id obj) (declare (ignore id)) (when (eq (org-object-type obj) type) (push obj results))) *memory*) results)) +(defun list-objects-with-attribute (attr-name value) + "Returns a list of all objects where ATTR-NAME matches VALUE." + (let ((results nil)) + (maphash (lambda (id obj) + (declare (ignore id)) + (let ((attrs (org-object-attributes obj))) + (when (equal (getf attrs attr-name) value) + (push obj results)))) + *memory*) + results)) + + results)) (defun find-headline-missing-id (ast) "Traverses an AST to find headlines that lack an :ID: property."