Read the odd startup option from org-mode files.
This commit is contained in:
@@ -1,13 +1,17 @@
|
||||
use nom::branch::alt;
|
||||
use nom::bytes::complete::is_not;
|
||||
use nom::bytes::complete::tag_no_case;
|
||||
use nom::character::complete::anychar;
|
||||
use nom::character::complete::space1;
|
||||
use nom::combinator::map;
|
||||
use nom::multi::many0;
|
||||
use nom::multi::many_till;
|
||||
use nom::multi::separated_list0;
|
||||
|
||||
use super::keyword::filtered_keyword;
|
||||
use super::keyword_todo::todo_keywords;
|
||||
use super::OrgSource;
|
||||
use crate::context::HeadlineLevelFilter;
|
||||
use crate::error::Res;
|
||||
use crate::types::Keyword;
|
||||
use crate::GlobalSettings;
|
||||
@@ -50,6 +54,7 @@ pub(crate) fn apply_in_buffer_settings<'g, 's, 'sf>(
|
||||
) -> Result<GlobalSettings<'g, 's>, String> {
|
||||
let mut new_settings = original_settings.clone();
|
||||
|
||||
// Todo Keywords
|
||||
for kw in keywords.iter().filter(|kw| {
|
||||
kw.key.eq_ignore_ascii_case("todo")
|
||||
|| kw.key.eq_ignore_ascii_case("seq_todo")
|
||||
@@ -65,5 +70,18 @@ pub(crate) fn apply_in_buffer_settings<'g, 's, 'sf>(
|
||||
.extend(complete_words.into_iter().map(str::to_string));
|
||||
}
|
||||
|
||||
// Startup settings
|
||||
for kw in keywords
|
||||
.iter()
|
||||
.filter(|kw| kw.key.eq_ignore_ascii_case("startup"))
|
||||
{
|
||||
let (_remaining, settings) =
|
||||
separated_list0(space1::<&str, nom::error::Error<_>>, is_not(" \t"))(kw.value)
|
||||
.map_err(|err: nom::Err<_>| err.to_string())?;
|
||||
if settings.contains(&"odd") {
|
||||
new_settings.odd_levels_only = HeadlineLevelFilter::Odd;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(new_settings)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user