@@ -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