Make an argument for the line number switch optional.

This commit is contained in:
Tom Alexander 2023-10-04 11:46:02 -04:00
parent 03028889bd
commit 1503054994
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
2 changed files with 11 additions and 6 deletions

View File

@ -0,0 +1,3 @@
#+BEGIN_SRC elisp -n -r -l "((%s))"
foo
#+END_SRC

View File

@ -342,9 +342,10 @@ fn example_switches<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, ExampleSwitc
(SwitchState::Normal, "-n") => SwitchState::NewLineNumber, (SwitchState::Normal, "-n") => SwitchState::NewLineNumber,
(SwitchState::Normal, "+n") => SwitchState::ContinuedLineNumber, (SwitchState::Normal, "+n") => SwitchState::ContinuedLineNumber,
(SwitchState::NewLineNumber, _) => { (SwitchState::NewLineNumber, _) => {
let val = word let val = match word.parse::<LineNumber>() {
.parse::<LineNumber>() Ok(val) => val,
.expect("TODO: I should be able to return CustomError from nom parsers."); Err(_) => 1,
};
if val < 0 { if val < 0 {
number_lines = Some(SwitchNumberLines::New(0)); number_lines = Some(SwitchNumberLines::New(0));
} else { } else {
@ -354,9 +355,10 @@ fn example_switches<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, ExampleSwitc
SwitchState::Normal SwitchState::Normal
} }
(SwitchState::ContinuedLineNumber, _) => { (SwitchState::ContinuedLineNumber, _) => {
let val = word let val = match word.parse::<LineNumber>() {
.parse::<LineNumber>() Ok(val) => val,
.expect("TODO: I should be able to return CustomError from nom parsers."); Err(_) => 1,
};
if val < 0 { if val < 0 {
number_lines = Some(SwitchNumberLines::Continued(0)); number_lines = Some(SwitchNumberLines::Continued(0));
} else { } else {