Skip to content

Commit

Permalink
Remove spurious println! when compling #[defun]
Browse files Browse the repository at this point in the history
  • Loading branch information
ubolonton committed Jul 24, 2019
1 parent 71132b4 commit af6c816
Showing 1 changed file with 11 additions and 20 deletions.
31 changes: 11 additions & 20 deletions emacs-macros/src/func.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,6 @@ impl FromMeta for UserPtr {
}
}

impl Arg {
fn lisp_name(&self) -> Option<String> {
match self {
Arg::Env { .. } => None,
Arg::Val { name: None, .. } => Some("_".to_owned()),
Arg::Val { name: Some(ident), ..} => {
Some(util::lisp_name(ident).to_uppercase())
}
}
}
}

impl LispFunc {
pub fn parse(attr_args: AttributeArgs, fn_item: ItemFn) -> Result<Self, TokenStream2> {
let opts: FuncOpts = match FuncOpts::from_list(&attr_args) {
Expand Down Expand Up @@ -329,12 +317,8 @@ fn check_signature(decl: &FnDecl) -> Result<(Vec<Arg>, Range<usize>, Span), Toke
_ => Access::Owned,
};
let name = match &capt.pat {
Pat::Ident(pat_ident) => {
Some(pat_ident.ident.clone())
}
Pat::Wild(_) => {
None
}
Pat::Ident(pat_ident) => Some(pat_ident.ident.clone()),
Pat::Wild(_) => None,
_ => {
report(errors, &capt.pat, "Expected identifier");
continue;
Expand Down Expand Up @@ -381,13 +365,20 @@ fn is_env(ty: &syn::Type) -> bool {
}
}

fn lisp_name(arg: &Arg) -> Option<String> {
match arg {
Arg::Env { .. } => None,
Arg::Val { name: None, .. } => Some("_".to_owned()),
Arg::Val { name: Some(ident), .. } => Some(util::lisp_name(ident).to_uppercase()),
}
}

fn lisp_signature(args: &[Arg]) -> String {
let mut sig = "(fn".to_owned();
for arg in args.iter().flat_map(|a| a.lisp_name()) {
for arg in args.iter().flat_map(lisp_name) {
sig.push_str(" ");
sig.push_str(&arg);
}
sig.push_str(")");
println!("{}", sig);
sig
}

0 comments on commit af6c816

Please sign in to comment.