From b385270d7bf3c4ca9b91a7c6367d4b644b4c75c3 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Tue, 10 Oct 2023 15:54:44 -0400 Subject: [PATCH] Implement a function to get the additional properties on a headline. --- src/compare/diff.rs | 4 ++++ src/types/document.rs | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/compare/diff.rs b/src/compare/diff.rs index 911d192..c01128c 100644 --- a/src/compare/diff.rs +++ b/src/compare/diff.rs @@ -542,6 +542,10 @@ fn new_compare_heading<'b, 's>( let mut child_status = Vec::new(); let mut message = None; + let additional_property_names = rust + .get_additional_properties() + .map(|node_property| EmacsField::Required(node_property.property_name)); + // TODO: This needs to support additional properties from the property drawer compare_children( diff --git a/src/types/document.rs b/src/types/document.rs index e3aa933..3437586 100644 --- a/src/types/document.rs +++ b/src/types/document.rs @@ -2,6 +2,7 @@ use std::path::PathBuf; use super::Element; use super::GetStandardProperties; +use super::NodeProperty; use super::Object; use super::StandardProperties; use super::Timestamp; @@ -90,4 +91,23 @@ impl<'s> Heading<'s> { .collect(); title_source } + + pub fn get_additional_properties(&self) -> impl Iterator> { + let foo = self + .children + .iter() + .take(1) + .filter_map(|c| match c { + DocumentElement::Section(section) => Some(section), + _ => None, + }) + .flat_map(|section| section.children.iter()) + .take(1) + .filter_map(|element| match element { + Element::PropertyDrawer(property_drawer) => Some(property_drawer), + _ => None, + }) + .flat_map(|property_drawer| property_drawer.children.iter()); + foo + } }