Compare commits
No commits in common. "0654b676f7442001e390b18ac7e0d703c6d7dd2e" and "be483110ef01a2b05fb09692032b85e5d11c7d9d" have entirely different histories.
0654b676f7
...
be483110ef
@ -1,2 +0,0 @@
|
|||||||
# This should be a malformed timestamp according to the current org-mode documentation but it is accepted anyway (with no repeater).
|
|
||||||
<1970-01-01 Thu ++y>
|
|
@ -719,58 +719,9 @@ fn compare_heading<'b, 's>(
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compare scheduled
|
// TODO: Compare :pre-blank :scheduled :closed
|
||||||
let scheduled = get_property(emacs, ":scheduled")?;
|
//
|
||||||
match (scheduled, &rust.scheduled) {
|
// :scheduled and :closed seem to only appear when the headline has a planning
|
||||||
(None, None) => {}
|
|
||||||
(None, Some(_)) | (Some(_), None) => {
|
|
||||||
this_status = DiffStatus::Bad;
|
|
||||||
message = Some(format!(
|
|
||||||
"Scheduled mismatch (emacs != rust) {:?} != {:?}",
|
|
||||||
scheduled, rust.scheduled
|
|
||||||
));
|
|
||||||
}
|
|
||||||
(Some(emacs_child), Some(rust_child)) => {
|
|
||||||
let result = compare_ast_node(source, emacs_child, rust_child.into())?;
|
|
||||||
child_status.push(artificial_diff_scope("scheduled", vec![result])?);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Compare deadline
|
|
||||||
let deadline = get_property(emacs, ":deadline")?;
|
|
||||||
match (deadline, &rust.deadline) {
|
|
||||||
(None, None) => {}
|
|
||||||
(None, Some(_)) | (Some(_), None) => {
|
|
||||||
this_status = DiffStatus::Bad;
|
|
||||||
message = Some(format!(
|
|
||||||
"Deadline mismatch (emacs != rust) {:?} != {:?}",
|
|
||||||
deadline, rust.deadline
|
|
||||||
));
|
|
||||||
}
|
|
||||||
(Some(emacs_child), Some(rust_child)) => {
|
|
||||||
let result = compare_ast_node(source, emacs_child, rust_child.into())?;
|
|
||||||
child_status.push(artificial_diff_scope("deadline", vec![result])?);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Compare closed
|
|
||||||
let closed = get_property(emacs, ":closed")?;
|
|
||||||
match (closed, &rust.closed) {
|
|
||||||
(None, None) => {}
|
|
||||||
(None, Some(_)) | (Some(_), None) => {
|
|
||||||
this_status = DiffStatus::Bad;
|
|
||||||
message = Some(format!(
|
|
||||||
"Closed mismatch (emacs != rust) {:?} != {:?}",
|
|
||||||
closed, rust.closed
|
|
||||||
));
|
|
||||||
}
|
|
||||||
(Some(emacs_child), Some(rust_child)) => {
|
|
||||||
let result = compare_ast_node(source, emacs_child, rust_child.into())?;
|
|
||||||
child_status.push(artificial_diff_scope("closed", vec![result])?);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Compare :pre-blank
|
|
||||||
|
|
||||||
// Compare section
|
// Compare section
|
||||||
let section_status = children
|
let section_status = children
|
||||||
@ -1451,70 +1402,20 @@ fn compare_diary_sexp<'b, 's>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn compare_planning<'b, 's>(
|
fn compare_planning<'b, 's>(
|
||||||
source: &'s str,
|
_source: &'s str,
|
||||||
emacs: &'b Token<'s>,
|
emacs: &'b Token<'s>,
|
||||||
rust: &'b Planning<'s>,
|
rust: &'b Planning<'s>,
|
||||||
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
||||||
let mut child_status = Vec::new();
|
let this_status = DiffStatus::Good;
|
||||||
let mut this_status = DiffStatus::Good;
|
let message = None;
|
||||||
let mut message = None;
|
|
||||||
|
|
||||||
// Compare scheduled
|
// TODO: Compare :closed :deadline :scheduled
|
||||||
let scheduled = get_property(emacs, ":scheduled")?;
|
|
||||||
match (scheduled, &rust.scheduled) {
|
|
||||||
(None, None) => {}
|
|
||||||
(None, Some(_)) | (Some(_), None) => {
|
|
||||||
this_status = DiffStatus::Bad;
|
|
||||||
message = Some(format!(
|
|
||||||
"Scheduled mismatch (emacs != rust) {:?} != {:?}",
|
|
||||||
scheduled, rust.scheduled
|
|
||||||
));
|
|
||||||
}
|
|
||||||
(Some(emacs_child), Some(rust_child)) => {
|
|
||||||
let result = compare_ast_node(source, emacs_child, rust_child.into())?;
|
|
||||||
child_status.push(artificial_diff_scope("scheduled", vec![result])?);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Compare deadline
|
|
||||||
let deadline = get_property(emacs, ":deadline")?;
|
|
||||||
match (deadline, &rust.deadline) {
|
|
||||||
(None, None) => {}
|
|
||||||
(None, Some(_)) | (Some(_), None) => {
|
|
||||||
this_status = DiffStatus::Bad;
|
|
||||||
message = Some(format!(
|
|
||||||
"Deadline mismatch (emacs != rust) {:?} != {:?}",
|
|
||||||
deadline, rust.deadline
|
|
||||||
));
|
|
||||||
}
|
|
||||||
(Some(emacs_child), Some(rust_child)) => {
|
|
||||||
let result = compare_ast_node(source, emacs_child, rust_child.into())?;
|
|
||||||
child_status.push(artificial_diff_scope("deadline", vec![result])?);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Compare closed
|
|
||||||
let closed = get_property(emacs, ":closed")?;
|
|
||||||
match (closed, &rust.closed) {
|
|
||||||
(None, None) => {}
|
|
||||||
(None, Some(_)) | (Some(_), None) => {
|
|
||||||
this_status = DiffStatus::Bad;
|
|
||||||
message = Some(format!(
|
|
||||||
"Closed mismatch (emacs != rust) {:?} != {:?}",
|
|
||||||
closed, rust.closed
|
|
||||||
));
|
|
||||||
}
|
|
||||||
(Some(emacs_child), Some(rust_child)) => {
|
|
||||||
let result = compare_ast_node(source, emacs_child, rust_child.into())?;
|
|
||||||
child_status.push(artificial_diff_scope("closed", vec![result])?);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(DiffResult {
|
Ok(DiffResult {
|
||||||
status: this_status,
|
status: this_status,
|
||||||
name: rust.get_elisp_name(),
|
name: rust.get_elisp_name(),
|
||||||
message,
|
message,
|
||||||
children: child_status,
|
children: Vec::new(),
|
||||||
rust_source: rust.get_source(),
|
rust_source: rust.get_source(),
|
||||||
emacs_token: emacs,
|
emacs_token: emacs,
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,6 @@ use crate::error::Res;
|
|||||||
use crate::parser::object_parser::standard_set_object;
|
use crate::parser::object_parser::standard_set_object;
|
||||||
use crate::parser::util::blank_line;
|
use crate::parser::util::blank_line;
|
||||||
use crate::types::DocumentElement;
|
use crate::types::DocumentElement;
|
||||||
use crate::types::Element;
|
|
||||||
use crate::types::Heading;
|
use crate::types::Heading;
|
||||||
use crate::types::HeadlineLevel;
|
use crate::types::HeadlineLevel;
|
||||||
use crate::types::Object;
|
use crate::types::Object;
|
||||||
@ -56,9 +55,6 @@ fn _heading<'b, 'g, 'r, 's>(
|
|||||||
input: OrgSource<'s>,
|
input: OrgSource<'s>,
|
||||||
parent_star_count: HeadlineLevel,
|
parent_star_count: HeadlineLevel,
|
||||||
) -> Res<OrgSource<'s>, Heading<'s>> {
|
) -> Res<OrgSource<'s>, Heading<'s>> {
|
||||||
let mut scheduled = None;
|
|
||||||
let mut deadline = None;
|
|
||||||
let mut closed = None;
|
|
||||||
not(|i| context.check_exit_matcher(i))(input)?;
|
not(|i| context.check_exit_matcher(i))(input)?;
|
||||||
let (remaining, pre_headline) = headline(context, input, parent_star_count)?;
|
let (remaining, pre_headline) = headline(context, input, parent_star_count)?;
|
||||||
let section_matcher = parser_with_context!(section)(context);
|
let section_matcher = parser_with_context!(section)(context);
|
||||||
@ -69,14 +65,6 @@ fn _heading<'b, 'g, 'r, 's>(
|
|||||||
let (remaining, mut children) =
|
let (remaining, mut children) =
|
||||||
many0(map(heading_matcher, DocumentElement::Heading))(remaining)?;
|
many0(map(heading_matcher, DocumentElement::Heading))(remaining)?;
|
||||||
if let Some(section) = maybe_section {
|
if let Some(section) = maybe_section {
|
||||||
// If the section has a planning then the timestamp values are copied to the heading.
|
|
||||||
if let DocumentElement::Section(inner_section) = §ion {
|
|
||||||
if let Some(Element::Planning(planning)) = inner_section.children.first() {
|
|
||||||
scheduled = planning.scheduled.clone();
|
|
||||||
deadline = planning.deadline.clone();
|
|
||||||
closed = planning.closed.clone();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
children.insert(0, section);
|
children.insert(0, section);
|
||||||
}
|
}
|
||||||
let remaining = if children.is_empty() {
|
let remaining = if children.is_empty() {
|
||||||
@ -106,9 +94,6 @@ fn _heading<'b, 'g, 'r, 's>(
|
|||||||
is_comment: pre_headline.comment.is_some(),
|
is_comment: pre_headline.comment.is_some(),
|
||||||
is_archived,
|
is_archived,
|
||||||
is_footnote_section: pre_headline.is_footnote_section,
|
is_footnote_section: pre_headline.is_footnote_section,
|
||||||
scheduled,
|
|
||||||
deadline,
|
|
||||||
closed,
|
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ use nom::bytes::complete::tag;
|
|||||||
use nom::bytes::complete::tag_no_case;
|
use nom::bytes::complete::tag_no_case;
|
||||||
use nom::character::complete::space0;
|
use nom::character::complete::space0;
|
||||||
use nom::character::complete::space1;
|
use nom::character::complete::space1;
|
||||||
use nom::combinator::map;
|
|
||||||
use nom::multi::many1;
|
use nom::multi::many1;
|
||||||
use nom::sequence::tuple;
|
use nom::sequence::tuple;
|
||||||
|
|
||||||
@ -17,7 +16,6 @@ use crate::error::Res;
|
|||||||
use crate::parser::util::get_consumed;
|
use crate::parser::util::get_consumed;
|
||||||
use crate::parser::util::start_of_line;
|
use crate::parser::util::start_of_line;
|
||||||
use crate::types::Planning;
|
use crate::types::Planning;
|
||||||
use crate::types::Timestamp;
|
|
||||||
|
|
||||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub(crate) fn planning<'b, 'g, 'r, 's>(
|
pub(crate) fn planning<'b, 'g, 'r, 's>(
|
||||||
@ -26,7 +24,7 @@ pub(crate) fn planning<'b, 'g, 'r, 's>(
|
|||||||
) -> Res<OrgSource<'s>, Planning<'s>> {
|
) -> Res<OrgSource<'s>, Planning<'s>> {
|
||||||
start_of_line(input)?;
|
start_of_line(input)?;
|
||||||
let (remaining, _leading_whitespace) = space0(input)?;
|
let (remaining, _leading_whitespace) = space0(input)?;
|
||||||
let (remaining, planning_parameters) =
|
let (remaining, _planning_parameters) =
|
||||||
many1(parser_with_context!(planning_parameter)(context))(remaining)?;
|
many1(parser_with_context!(planning_parameter)(context))(remaining)?;
|
||||||
let (remaining, _trailing_ws) = tuple((space0, org_line_ending))(remaining)?;
|
let (remaining, _trailing_ws) = tuple((space0, org_line_ending))(remaining)?;
|
||||||
|
|
||||||
@ -34,54 +32,26 @@ pub(crate) fn planning<'b, 'g, 'r, 's>(
|
|||||||
maybe_consume_trailing_whitespace_if_not_exiting(context, remaining)?;
|
maybe_consume_trailing_whitespace_if_not_exiting(context, remaining)?;
|
||||||
let source = get_consumed(input, remaining);
|
let source = get_consumed(input, remaining);
|
||||||
|
|
||||||
let mut scheduled = None;
|
|
||||||
let mut deadline = None;
|
|
||||||
let mut closed = None;
|
|
||||||
|
|
||||||
for (timestamp_type, timestamp) in planning_parameters.into_iter() {
|
|
||||||
match timestamp_type {
|
|
||||||
PlanningTimestampType::Scheduled => {
|
|
||||||
scheduled = Some(timestamp);
|
|
||||||
}
|
|
||||||
PlanningTimestampType::Deadline => {
|
|
||||||
deadline = Some(timestamp);
|
|
||||||
}
|
|
||||||
PlanningTimestampType::Closed => {
|
|
||||||
closed = Some(timestamp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok((
|
Ok((
|
||||||
remaining,
|
remaining,
|
||||||
Planning {
|
Planning {
|
||||||
source: source.into(),
|
source: source.into(),
|
||||||
scheduled,
|
|
||||||
deadline,
|
|
||||||
closed,
|
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
enum PlanningTimestampType {
|
|
||||||
Scheduled,
|
|
||||||
Deadline,
|
|
||||||
Closed,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn planning_parameter<'b, 'g, 'r, 's>(
|
fn planning_parameter<'b, 'g, 'r, 's>(
|
||||||
context: RefContext<'b, 'g, 'r, 's>,
|
context: RefContext<'b, 'g, 'r, 's>,
|
||||||
input: OrgSource<'s>,
|
input: OrgSource<'s>,
|
||||||
) -> Res<OrgSource<'s>, (PlanningTimestampType, Timestamp<'s>)> {
|
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||||
let (remaining, planning_type) = alt((
|
let (remaining, _planning_type) = alt((
|
||||||
map(tag_no_case("DEADLINE"), |_| PlanningTimestampType::Deadline),
|
tag_no_case("DEADLINE"),
|
||||||
map(tag_no_case("SCHEDULED"), |_| {
|
tag_no_case("SCHEDULED"),
|
||||||
PlanningTimestampType::Scheduled
|
tag_no_case("CLOSED"),
|
||||||
}),
|
|
||||||
map(tag_no_case("CLOSED"), |_| PlanningTimestampType::Closed),
|
|
||||||
))(input)?;
|
))(input)?;
|
||||||
let (remaining, _gap) = tuple((tag(":"), space1))(remaining)?;
|
let (remaining, _gap) = tuple((tag(":"), space1))(remaining)?;
|
||||||
let (remaining, timestamp) = timestamp(context, remaining)?;
|
let (remaining, _timestamp) = timestamp(context, remaining)?;
|
||||||
Ok((remaining, (planning_type, timestamp)))
|
let source = get_consumed(input, remaining);
|
||||||
|
Ok((remaining, source))
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ use super::Element;
|
|||||||
use super::GetStandardProperties;
|
use super::GetStandardProperties;
|
||||||
use super::Object;
|
use super::Object;
|
||||||
use super::StandardProperties;
|
use super::StandardProperties;
|
||||||
use super::Timestamp;
|
|
||||||
|
|
||||||
pub type PriorityCookie = u8;
|
pub type PriorityCookie = u8;
|
||||||
pub type HeadlineLevel = u16;
|
pub type HeadlineLevel = u16;
|
||||||
@ -30,9 +29,6 @@ pub struct Heading<'s> {
|
|||||||
pub is_comment: bool,
|
pub is_comment: bool,
|
||||||
pub is_archived: bool,
|
pub is_archived: bool,
|
||||||
pub is_footnote_section: bool,
|
pub is_footnote_section: bool,
|
||||||
pub scheduled: Option<Timestamp<'s>>,
|
|
||||||
pub deadline: Option<Timestamp<'s>>,
|
|
||||||
pub closed: Option<Timestamp<'s>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
use super::object::Object;
|
use super::object::Object;
|
||||||
use super::PlainText;
|
use super::PlainText;
|
||||||
use super::StandardProperties;
|
use super::StandardProperties;
|
||||||
use super::Timestamp;
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Paragraph<'s> {
|
pub struct Paragraph<'s> {
|
||||||
@ -73,9 +72,6 @@ pub struct DiarySexp<'s> {
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Planning<'s> {
|
pub struct Planning<'s> {
|
||||||
pub source: &'s str,
|
pub source: &'s str,
|
||||||
pub scheduled: Option<Timestamp<'s>>,
|
|
||||||
pub deadline: Option<Timestamp<'s>>,
|
|
||||||
pub closed: Option<Timestamp<'s>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -182,7 +182,7 @@ pub struct Superscript<'s> {
|
|||||||
pub source: &'s str,
|
pub source: &'s str,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Clone)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub struct Timestamp<'s> {
|
pub struct Timestamp<'s> {
|
||||||
pub source: &'s str,
|
pub source: &'s str,
|
||||||
pub timestamp_type: TimestampType,
|
pub timestamp_type: TimestampType,
|
||||||
@ -195,7 +195,7 @@ pub struct Timestamp<'s> {
|
|||||||
pub warning_delay: Option<WarningDelay>,
|
pub warning_delay: Option<WarningDelay>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Clone)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub enum TimestampType {
|
pub enum TimestampType {
|
||||||
Diary,
|
Diary,
|
||||||
Active,
|
Active,
|
||||||
@ -204,7 +204,7 @@ pub enum TimestampType {
|
|||||||
InactiveRange,
|
InactiveRange,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Clone)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub enum TimestampRangeType {
|
pub enum TimestampRangeType {
|
||||||
None,
|
None,
|
||||||
DateRange,
|
DateRange,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user