Compare priority, archived, and commented in headlines.
This commit is contained in:
parent
c7c0deed74
commit
93d3d9471f
@ -45,6 +45,7 @@ use crate::types::PlainList;
|
|||||||
use crate::types::PlainListItem;
|
use crate::types::PlainListItem;
|
||||||
use crate::types::PlainText;
|
use crate::types::PlainText;
|
||||||
use crate::types::Planning;
|
use crate::types::Planning;
|
||||||
|
use crate::types::PriorityCookie;
|
||||||
use crate::types::PropertyDrawer;
|
use crate::types::PropertyDrawer;
|
||||||
use crate::types::RadioLink;
|
use crate::types::RadioLink;
|
||||||
use crate::types::RadioTarget;
|
use crate::types::RadioTarget;
|
||||||
@ -553,7 +554,57 @@ fn compare_heading<'s>(
|
|||||||
.collect::<Result<Vec<_>, _>>()?;
|
.collect::<Result<Vec<_>, _>>()?;
|
||||||
child_status.push(artificial_diff_scope("title".to_owned(), title_status)?);
|
child_status.push(artificial_diff_scope("title".to_owned(), title_status)?);
|
||||||
|
|
||||||
// TODO: Compare priority, :footnote-section-p, :archivedp, :commentedp
|
// Compare priority
|
||||||
|
let priority = get_property(emacs, ":priority")?;
|
||||||
|
match (priority, rust.priority_cookie) {
|
||||||
|
(None, None) => {}
|
||||||
|
(None, Some(_)) | (Some(_), None) => {
|
||||||
|
this_status = DiffStatus::Bad;
|
||||||
|
message = Some(format!(
|
||||||
|
"Priority cookie mismatch (emacs != rust) {:?} != {:?}",
|
||||||
|
priority, rust.priority_cookie
|
||||||
|
));
|
||||||
|
}
|
||||||
|
(Some(emacs_priority_cookie), Some(rust_priority_cookie)) => {
|
||||||
|
let emacs_priority_cookie =
|
||||||
|
emacs_priority_cookie.as_atom()?.parse::<PriorityCookie>()?;
|
||||||
|
if emacs_priority_cookie != rust_priority_cookie {
|
||||||
|
this_status = DiffStatus::Bad;
|
||||||
|
message = Some(format!(
|
||||||
|
"Priority cookie mismatch (emacs != rust) {:?} != {:?}",
|
||||||
|
emacs_priority_cookie, rust_priority_cookie
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compare archived
|
||||||
|
let archived = get_property(emacs, ":archivedp")?;
|
||||||
|
match (archived, rust.is_archived) {
|
||||||
|
(None, true) | (Some(_), false) => {
|
||||||
|
this_status = DiffStatus::Bad;
|
||||||
|
message = Some(format!(
|
||||||
|
"archived mismatch (emacs != rust) {:?} != {:?}",
|
||||||
|
archived, rust.is_archived
|
||||||
|
));
|
||||||
|
}
|
||||||
|
(None, false) | (Some(_), true) => {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compare commented
|
||||||
|
let commented = get_property(emacs, ":commentedp")?;
|
||||||
|
match (commented, rust.is_comment) {
|
||||||
|
(None, true) | (Some(_), false) => {
|
||||||
|
this_status = DiffStatus::Bad;
|
||||||
|
message = Some(format!(
|
||||||
|
"commented mismatch (emacs != rust) {:?} != {:?}",
|
||||||
|
commented, rust.is_comment
|
||||||
|
));
|
||||||
|
}
|
||||||
|
(None, false) | (Some(_), true) => {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Compare :footnote-section-p
|
||||||
|
|
||||||
// Compare section
|
// Compare section
|
||||||
let section_status = children
|
let section_status = children
|
||||||
|
@ -141,6 +141,11 @@ fn maybe_token_to_usize(
|
|||||||
.map_or(Ok(None), |r| r.map(Some))?)
|
.map_or(Ok(None), |r| r.map(Some))?)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get a named property from the emacs token.
|
||||||
|
///
|
||||||
|
/// Returns Ok(None) if value is nil.
|
||||||
|
///
|
||||||
|
/// Returns error if the attribute is not specified on the token at all.
|
||||||
pub fn get_property<'s, 'x>(
|
pub fn get_property<'s, 'x>(
|
||||||
emacs: &'s Token<'s>,
|
emacs: &'s Token<'s>,
|
||||||
key: &'x str,
|
key: &'x str,
|
||||||
|
Loading…
Reference in New Issue
Block a user