Compare todo-type on headlines.
All checks were successful
rust-test Build rust-test has succeeded
rust-build Build rust-build has succeeded

This commit is contained in:
Tom Alexander
2023-09-06 12:39:03 -04:00
parent 7c471ab32e
commit 12cbb89861
4 changed files with 54 additions and 11 deletions

View File

@@ -60,6 +60,7 @@ use crate::types::TableCell;
use crate::types::TableRow;
use crate::types::Target;
use crate::types::Timestamp;
use crate::types::TodoKeywordType;
use crate::types::Underline;
use crate::types::Verbatim;
use crate::types::VerseBlock;
@@ -510,9 +511,9 @@ fn compare_heading<'s>(
.map(Token::as_atom)
.map_or(Ok(None), |r| r.map(Some))?
.unwrap_or("nil");
match (todo_keyword, rust.todo_keyword, unquote(todo_keyword)) {
match (todo_keyword, &rust.todo_keyword, unquote(todo_keyword)) {
("nil", None, _) => {}
(_, Some(rust_todo), Ok(emacs_todo)) if emacs_todo == rust_todo => {}
(_, Some((_rust_todo_type, rust_todo)), Ok(emacs_todo)) if emacs_todo == *rust_todo => {}
(emacs_todo, rust_todo, _) => {
this_status = DiffStatus::Bad;
message = Some(format!(
@@ -521,6 +522,24 @@ fn compare_heading<'s>(
));
}
};
// Compare todo-type
let todo_type = get_property(emacs, ":todo-type")?
.map(Token::as_atom)
.map_or(Ok(None), |r| r.map(Some))?
.unwrap_or("nil");
// todo-type is an unquoted string either todo, done, or nil
match (todo_type, &rust.todo_keyword) {
("nil", None) => {}
("todo", Some((TodoKeywordType::Todo, _))) => {}
("done", Some((TodoKeywordType::Done, _))) => {}
(emacs_todo, rust_todo) => {
this_status = DiffStatus::Bad;
message = Some(format!(
"(emacs != rust) {:?} != {:?}",
emacs_todo, rust_todo
));
}
};
// Compare title
let title = get_property(emacs, ":title")?.ok_or("Missing :title attribute.")?;
@@ -532,7 +551,7 @@ fn compare_heading<'s>(
.collect::<Result<Vec<_>, _>>()?;
child_status.push(artificial_diff_scope("title".to_owned(), title_status)?);
// TODO: Compare todo-type, priority, :footnote-section-p, :archivedp, :commentedp
// TODO: Compare priority, :footnote-section-p, :archivedp, :commentedp
// Compare section
let section_status = children