comparison src/minibuf.c @ 10086:77b5eb8fc9e3

(Fminibuffer_complete_and_exit): Catch errors in do_completion. (complete_and_exit_1, complete_and_exit_2): New subroutines.
author Richard M. Stallman <rms@gnu.org>
date Mon, 28 Nov 1994 20:31:00 +0000
parents 133888d97e98
children 6a4f5fc9d3f9
comparison
equal deleted inserted replaced
10085:f7b9813ea757 10086:77b5eb8fc9e3
1235 break; 1235 break;
1236 } 1236 }
1237 1237
1238 return Qt; 1238 return Qt;
1239 } 1239 }
1240
1241 /* Subroutines of Fminibuffer_complete_and_exit. */
1242
1243 /* This one is called by internal_condition_case to do the real work. */
1244
1245 Lisp_Object
1246 complete_and_exit_1 ()
1247 {
1248 return make_number (do_completion ());
1249 }
1250
1251 /* This one is called by internal_condition_case if an error happens.
1252 Pretend the current value is an exact match. */
1253
1254 Lisp_Object
1255 complete_and_exit_2 (ignore)
1256 Lisp_Object ignore;
1257 {
1258 return make_number (1);
1259 }
1240 1260
1241 DEFUN ("minibuffer-complete-and-exit", Fminibuffer_complete_and_exit, 1261 DEFUN ("minibuffer-complete-and-exit", Fminibuffer_complete_and_exit,
1242 Sminibuffer_complete_and_exit, 0, 0, "", 1262 Sminibuffer_complete_and_exit, 0, 0, "",
1243 "If the minibuffer contents is a valid completion then exit.\n\ 1263 "If the minibuffer contents is a valid completion then exit.\n\
1244 Otherwise try to complete it. If completion leads to a valid completion,\n\ 1264 Otherwise try to complete it. If completion leads to a valid completion,\n\
1245 a repetition of this command will exit.") 1265 a repetition of this command will exit.")
1246 () 1266 ()
1247 { 1267 {
1248 register int i; 1268 register int i;
1269 Lisp_Object val;
1249 1270
1250 /* Allow user to specify null string */ 1271 /* Allow user to specify null string */
1251 if (BEGV == ZV) 1272 if (BEGV == ZV)
1252 goto exit; 1273 goto exit;
1253 1274
1254 if (!NILP (test_completion (Fbuffer_string ()))) 1275 if (!NILP (test_completion (Fbuffer_string ())))
1255 goto exit; 1276 goto exit;
1256 1277
1257 i = do_completion (); 1278 /* Call do_completion, but ignore errors. */
1279 val = internal_condition_case (complete_and_exit_1, Qerror,
1280 complete_and_exit_2);
1281
1282 i = XFASTINT (val);
1258 switch (i) 1283 switch (i)
1259 { 1284 {
1260 case 1: 1285 case 1:
1261 case 3: 1286 case 3:
1262 goto exit; 1287 goto exit;