diff --git a/org_mode_samples/object/regular_link/code_ref_link.org b/org_mode_samples/object/regular_link/code_ref_link.org index 6b924e69..9ab0ddc1 100644 --- a/org_mode_samples/object/regular_link/code_ref_link.org +++ b/org_mode_samples/object/regular_link/code_ref_link.org @@ -10,3 +10,4 @@ rem)]] # These become fuzzy [[(foo) ]] [[ (foo)]] +[[(foo)::3]] diff --git a/org_mode_samples/object/regular_link/custom_id_link.org b/org_mode_samples/object/regular_link/custom_id_link.org index a721579e..875dd859 100644 --- a/org_mode_samples/object/regular_link/custom_id_link.org +++ b/org_mode_samples/object/regular_link/custom_id_link.org @@ -2,3 +2,5 @@ [[#fo o]] + +[[#foo::3]] diff --git a/org_mode_samples/object/regular_link/file_link.org b/org_mode_samples/object/regular_link/file_link.org index 2364f57b..58f62047 100644 --- a/org_mode_samples/object/regular_link/file_link.org +++ b/org_mode_samples/object/regular_link/file_link.org @@ -2,3 +2,15 @@ [[file:simp le.org]] + +[[file:simple.org::3]] +[[file:simple.org::foo]] +[[file:simple.org::#foo]] +[[file:simple.org::foo bar]] +[[file:simple.org::foo +bar]] +[[file:simple.org::foo +bar]] +[[file:simple.org::foo + bar]] +[[file:simple.org::foo::bar]] diff --git a/org_mode_samples/object/regular_link/fuzzy_link.org b/org_mode_samples/object/regular_link/fuzzy_link.org index 64fffaa9..17ebd7a3 100644 --- a/org_mode_samples/object/regular_link/fuzzy_link.org +++ b/org_mode_samples/object/regular_link/fuzzy_link.org @@ -2,3 +2,5 @@ [[eli sp.org]] + +[[elisp.org::3]] diff --git a/org_mode_samples/object/regular_link/id_link.org b/org_mode_samples/object/regular_link/id_link.org index 65bf4c5e..45f13946 100644 --- a/org_mode_samples/object/regular_link/id_link.org +++ b/org_mode_samples/object/regular_link/id_link.org @@ -2,3 +2,5 @@ [[id:83986bdf-987c-465d -8851-44cb4c02a86c]] + +[[id:83986bdf-987c-465d-8851-44cb4c02a86c::foo]] diff --git a/org_mode_samples/object/regular_link/protocol_link.org b/org_mode_samples/object/regular_link/protocol_link.org index bd9bbad1..610e30ce 100644 --- a/org_mode_samples/object/regular_link/protocol_link.org +++ b/org_mode_samples/object/regular_link/protocol_link.org @@ -2,3 +2,5 @@ [[shell:fo o]] + +[[shell:foo::3]] diff --git a/src/compare/diff.rs b/src/compare/diff.rs index 5178e906..de112352 100644 --- a/src/compare/diff.rs +++ b/src/compare/diff.rs @@ -2805,8 +2805,8 @@ fn compare_regular_link<'b, 's>( ), ( EmacsField::Required(":search-option"), - compare_identity, - compare_property_always_nil + |r| r.search_option, + compare_property_quoted_string ) )? { this_status = new_status; diff --git a/src/parser/regular_link.rs b/src/parser/regular_link.rs index dcf99a26..3788fa8f 100644 --- a/src/parser/regular_link.rs +++ b/src/parser/regular_link.rs @@ -6,7 +6,9 @@ use nom::bytes::complete::take_until; use nom::character::complete::anychar; use nom::combinator::consumed; use nom::combinator::eof; +use nom::combinator::map; use nom::combinator::map_parser; +use nom::combinator::opt; use nom::combinator::peek; use nom::combinator::recognize; use nom::combinator::rest; @@ -58,6 +60,7 @@ fn regular_link_without_description<'b, 'g, 'r, 's>( link_type: path.link_type, path: path.path, raw_link: path.raw_link, + search_option: path.search_option, }, )) } @@ -82,6 +85,7 @@ fn regular_link_with_description<'b, 'g, 'r, 's>( link_type: path.link_type, path: path.path, raw_link: path.raw_link, + search_option: path.search_option, }, )) } @@ -90,6 +94,7 @@ struct PathReg<'s> { link_type: LinkType<'s>, path: &'s str, raw_link: &'s str, + search_option: Option<&'s str>, } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] @@ -123,13 +128,20 @@ fn parse_path_reg<'s>(input: OrgSource<'s>) -> Res, PathReg<'s>> { } fn file_path_reg<'s>(input: OrgSource<'s>) -> Res, PathReg<'s>> { - let (remaining, (raw_link, (_, path))) = consumed(tuple((tag("file:"), rest)))(input)?; + let (remaining, (raw_link, (_, path, search_option))) = consumed(tuple(( + tag("file:"), + recognize(many_till(anychar, alt((peek(tag("::")), eof)))), + opt(map(tuple((tag("::"), rest)), |(_, search_option)| { + search_option + })), + )))(input)?; Ok(( remaining, PathReg { link_type: LinkType::File, path: path.into(), raw_link: raw_link.into(), + search_option: search_option.map(Into::<&str>::into), }, )) } @@ -142,6 +154,7 @@ fn id_path_reg<'s>(input: OrgSource<'s>) -> Res, PathReg<'s>> { link_type: LinkType::Id, path: path.into(), raw_link: raw_link.into(), + search_option: None, }, )) } @@ -154,6 +167,7 @@ fn custom_id_path_reg<'s>(input: OrgSource<'s>) -> Res, PathReg<'s link_type: LinkType::CustomId, path: path.into(), raw_link: raw_link.into(), + search_option: None, }, )) } @@ -170,6 +184,7 @@ fn code_ref_path_reg<'s>(input: OrgSource<'s>) -> Res, PathReg<'s> link_type: LinkType::CodeRef, path: path.into(), raw_link: raw_link.into(), + search_option: None, }, )) } @@ -183,6 +198,7 @@ fn protocol_path_reg<'s>(input: OrgSource<'s>) -> Res, PathReg<'s> link_type: LinkType::Protocol(protocol.into()), path: path.into(), raw_link: raw_link.into(), + search_option: None, }, )) } @@ -195,6 +211,7 @@ fn fuzzy_path_reg<'s>(input: OrgSource<'s>) -> Res, PathReg<'s>> { link_type: LinkType::Fuzzy, path: body.into(), raw_link: body.into(), + search_option: None, }, )) } diff --git a/src/types/object.rs b/src/types/object.rs index f4831116..fb964291 100644 --- a/src/types/object.rs +++ b/src/types/object.rs @@ -80,6 +80,7 @@ pub struct RegularLink<'s> { pub link_type: LinkType<'s>, pub path: &'s str, pub raw_link: &'s str, + pub search_option: Option<&'s str>, } #[derive(Debug, PartialEq)]