@@ -161,9 +161,9 @@ expand({Unquote, Meta, [_]}, _S, E) when Unquote == unquote; Unquote == unquote_
161
161
file_error (Meta , E , ? MODULE , {unquote_outside_quote , Unquote });
162
162
163
163
expand ({quote , Meta , [Opts ]}, S , E ) when is_list (Opts ) ->
164
- case lists :keyfind (do , 1 , Opts ) of
165
- {do , Do } ->
166
- expand ({quote , Meta , [lists : keydelete ( do , 1 , Opts ) , [{do , Do }]]}, S , E );
164
+ case lists :keytake (do , 1 , Opts ) of
165
+ {value , { do , Do }, DoOpts } ->
166
+ expand ({quote , Meta , [DoOpts , [{do , Do }]]}, S , E );
167
167
false ->
168
168
file_error (Meta , E , ? MODULE , {missing_option , 'quote' , [do ]})
169
169
end ;
@@ -178,8 +178,20 @@ expand({quote, Meta, [Opts, Do]}, S, E) when is_list(Do) ->
178
178
false -> file_error (Meta , E , ? MODULE , {missing_option , 'quote' , [do ]})
179
179
end ,
180
180
181
- ValidOpts = [context , location , line , file , unquote , bind_quoted , generated ],
182
- {EOpts , ST , ET } = expand_opts (Meta , quote , ValidOpts , Opts , S , E ),
181
+ {Binding , DefaultUnquote , ToExpandOpts } =
182
+ case is_list (Opts ) andalso lists :keytake (bind_quoted , 1 , Opts ) of
183
+ {value , {bind_quoted , BQ }, BQOpts } ->
184
+ case is_list (BQ ) andalso
185
+ lists :all (fun ({Key , _ }) when is_atom (Key ) -> true ; (_ ) -> false end , BQ ) of
186
+ true -> {BQ , false , BQOpts };
187
+ false -> file_error (Meta , E , ? MODULE , {invalid_bind_quoted_for_quote , BQ })
188
+ end ;
189
+ false ->
190
+ {[], true , Opts }
191
+ end ,
192
+
193
+ ValidKeys = [context , location , line , file , unquote , bind_quoted , generated ],
194
+ {EOpts , ST , ET } = expand_opts (Meta , quote , ValidKeys , ToExpandOpts , S , E ),
183
195
184
196
Context = proplists :get_value (context , EOpts , case ? key (E , module ) of
185
197
nil -> 'Elixir' ;
@@ -193,28 +205,12 @@ expand({quote, Meta, [Opts, Do]}, S, E) when is_list(Do) ->
193
205
{proplists :get_value (file , EOpts , nil ), proplists :get_value (line , EOpts , false )}
194
206
end ,
195
207
196
- {Binding , DefaultUnquote } = case lists :keyfind (bind_quoted , 1 , EOpts ) of
197
- {bind_quoted , BQ } ->
198
- case is_list (BQ ) andalso
199
- lists :all (fun ({Key , _ }) when is_atom (Key ) -> true ; (_ ) -> false end , BQ ) of
200
- true -> {BQ , false };
201
- false -> file_error (Meta , E , ? MODULE , {invalid_bind_quoted_for_quote , BQ })
202
- end ;
203
- false ->
204
- {[], true }
205
- end ,
206
-
207
208
Unquote = proplists :get_value (unquote , EOpts , DefaultUnquote ),
208
209
Generated = proplists :get_value (generated , EOpts , false ),
209
210
210
- {Q , EBinding , Prelude } = elixir_quote :build (Meta , Line , File , Context , Unquote , Generated , Binding , ET ),
211
- Quoted = elixir_quote :quote (Exprs , Q , Prelude ),
212
- {EQuoted , ES , EQ } = expand (Quoted , ST , ET ),
213
-
214
- case EBinding of
215
- [] -> {EQuoted , ES , EQ };
216
- _ -> {{'{}' , [], ['__block__' , [], EBinding ++ [EQuoted ]]}, ES , EQ }
217
- end ;
211
+ {Q , Prelude } = elixir_quote :build (Meta , Line , File , Context , Unquote , Generated , ET ),
212
+ Quoted = elixir_quote :quote (Meta , Exprs , Binding , Q , Prelude ),
213
+ expand (Quoted , ST , ET );
218
214
219
215
expand ({quote , Meta , [_ , _ ]}, _S , E ) ->
220
216
file_error (Meta , E , ? MODULE , {invalid_args , 'quote' });
0 commit comments