Skip to content

Commit 9ca18d1

Browse files
committed
Change emacs-macros code style a little bit
1 parent 795e11e commit 9ca18d1

File tree

2 files changed

+17
-25
lines changed

2 files changed

+17
-25
lines changed

emacs-macros/src/func.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,30 +173,30 @@ impl LispFunc {
173173
None => TokenStream2::new(),
174174
Some(user_ptr) => match user_ptr {
175175
UserPtr::RefCell => quote_spanned! {self.output_span=>
176-
let result = ::std::boxed::Box::new(::std::cell::RefCell::new(result));
176+
let output = ::std::boxed::Box::new(::std::cell::RefCell::new(output));
177177
},
178178
UserPtr::RwLock => quote_spanned! {self.output_span=>
179-
let result = ::std::boxed::Box::new(::std::sync::RwLock::new(result));
179+
let output = ::std::boxed::Box::new(::std::sync::RwLock::new(output));
180180
},
181181
UserPtr::Mutex => quote_spanned! {self.output_span=>
182-
let result = ::std::boxed::Box::new(::std::sync::Mutex::new(result));
182+
let output = ::std::boxed::Box::new(::std::sync::Mutex::new(output));
183183
},
184184
UserPtr::Direct => quote_spanned! {self.output_span=>
185-
let result = ::std::boxed::Box::new(result);
185+
let output = ::std::boxed::Box::new(output);
186186
},
187187
},
188188
};
189-
// XXX: result can be (), but we can't easily know when.
189+
// XXX: output can be (), but we can't easily know when.
190190
let into_lisp = quote_spanned! {self.output_span=>
191191
#[allow(clippy::unit_arg)]
192-
::emacs::IntoLisp::into_lisp(result, env)
192+
::emacs::IntoLisp::into_lisp(output, env)
193193
};
194194
let inner = &self.def.ident;
195195
let wrapper = self.wrapper_ident();
196196
quote! {
197197
fn #wrapper(env: &::emacs::CallEnv) -> ::emacs::Result<::emacs::Value<'_>> {
198198
#bindings
199-
let result = #inner(#args)?;
199+
let output = #inner(#args)?;
200200
#maybe_embed
201201
#into_lisp
202202
}

emacs-macros/src/module.rs

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -109,31 +109,23 @@ impl Module {
109109
}
110110

111111
pub fn gen_init(&self) -> TokenStream2 {
112-
let env = quote!(env);
113112
let init = Self::init_ident();
114-
let feature = quote!(feature);
115113
let separator = &self.opts.separator;
116114
let hook = &self.def.ident;
117115
let init_fns = util::init_fns_path();
118116
let prefix = util::prefix_path();
119117
let mod_in_name = util::mod_in_name_path();
120118
let crate_mod_in_name = &self.opts.mod_in_name;
121-
let set_feature = match &self.opts.name {
122-
Name::Crate => quote! {
123-
let #feature = ::emacs::globals::lisp_pkg(module_path!());
124-
},
119+
let feature = match &self.opts.name {
120+
Name::Crate => quote!(::emacs::globals::lisp_pkg(module_path!())),
121+
Name::Str(name) => quote!(#name.to_owned()),
125122
Name::Fn => {
126123
let name = util::lisp_name(hook);
127-
quote! {
128-
let #feature = #name.to_owned();
129-
}
124+
quote!(#name.to_owned())
130125
}
131-
Name::Str(name) => quote! {
132-
let #feature = #name.to_owned();
133-
},
134126
};
135127
let defun_prefix = match &self.opts.defun_prefix {
136-
None => quote!(#feature.clone()),
128+
None => quote!(feature.clone()),
137129
Some(defun_prefix) => quote!(#defun_prefix.to_owned()),
138130
};
139131
let set_prefix = quote! {
@@ -151,19 +143,19 @@ impl Module {
151143
let funcs = #init_fns.try_lock()
152144
.expect("Failed to acquire a read lock on map of initializers");
153145
for (name, func) in funcs.iter() {
154-
func(#env)?
146+
func(env)?
155147
}
156148
}
157149
};
158150
quote! {
159151
#[allow(non_snake_case)]
160-
fn #init(#env: &::emacs::Env) -> ::emacs::Result<::emacs::Value<'_>> {
161-
#set_feature
152+
fn #init(env: &::emacs::Env) -> ::emacs::Result<::emacs::Value<'_>> {
153+
let feature = #feature;
162154
#set_prefix
163155
#configure_mod_in_name
164156
#export_lisp_funcs
165-
#hook(#env)?;
166-
#env.provide(&#feature)
157+
#hook(env)?;
158+
env.provide(&feature)
167159
}
168160
}
169161
}

0 commit comments

Comments
 (0)