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