comparison src/callint.c @ 13142:297a0e21501a

(callint_message, callint_message_size): New vars. (syms_of_callint): Set up new vars. (Fcall_interactively): Keep the prompt in the heap.
author Richard M. Stallman <rms@gnu.org>
date Sat, 07 Oct 1995 21:54:29 +0000
parents 5f8972720e72
children 99457b67e20c
comparison
equal deleted inserted replaced
13141:4a4d1d8e89e5 13142:297a0e21501a
45 static Lisp_Object preserved_fns; 45 static Lisp_Object preserved_fns;
46 46
47 /* Marker used within call-interactively to refer to point. */ 47 /* Marker used within call-interactively to refer to point. */
48 static Lisp_Object point_marker; 48 static Lisp_Object point_marker;
49 49
50 /* Buffer for the prompt text used in Fcall_interactively. */
51 static char *callint_message;
52
53 /* Allocated length of that buffer. */
54 static int callint_message_size;
50 55
51 /* This comment supplies the doc string for interactive, 56 /* This comment supplies the doc string for interactive,
52 for make-docfile to see. We cannot put this in the real DEFUN 57 for make-docfile to see. We cannot put this in the real DEFUN
53 due to limits in the Unix cpp. 58 due to limits in the Unix cpp.
54 59
195 recorded as a call to the function named callint_argfuns[varies[i]]. */ 200 recorded as a call to the function named callint_argfuns[varies[i]]. */
196 int *varies; 201 int *varies;
197 202
198 register int i, j; 203 register int i, j;
199 int count, foo; 204 int count, foo;
200 char prompt[100];
201 char prompt1[100]; 205 char prompt1[100];
202 char *tem1; 206 char *tem1;
203 int arg_from_tty = 0; 207 int arg_from_tty = 0;
204 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 208 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
205 209
411 argstrings[j] 415 argstrings[j]
412 = EQ (visargs[j], Qnil) 416 = EQ (visargs[j], Qnil)
413 ? (unsigned char *) "" 417 ? (unsigned char *) ""
414 : XSTRING (visargs[j])->data; 418 : XSTRING (visargs[j])->data;
415 419
416 doprnt (prompt, sizeof prompt, prompt1, (char *)0, 420 /* Process the format-string in prompt1, putting the output
417 j - 1, argstrings + 1); 421 into callint_message. Make callint_message bigger if necessary.
422 We don't use a buffer on the stack, because the contents
423 need to stay stable for a while. */
424 while (1)
425 {
426 int nchars = doprnt (callint_message, callint_message_size,
427 prompt1, (char *)0,
428 j - 1, argstrings + 1);
429 if (nchars < callint_message_size)
430 break;
431 callint_message_size *= 2;
432 callint_message
433 = (char *) xrealloc (callint_message, callint_message_size);
434 }
418 435
419 switch (*tem) 436 switch (*tem)
420 { 437 {
421 case 'a': /* Symbol defined as a function */ 438 case 'a': /* Symbol defined as a function */
422 visargs[i] = Fcompleting_read (build_string (prompt), 439 visargs[i] = Fcompleting_read (build_string (callint_message),
423 Vobarray, Qfboundp, Qt, Qnil, Qnil); 440 Vobarray, Qfboundp, Qt, Qnil, Qnil);
424 /* Passing args[i] directly stimulates compiler bug */ 441 /* Passing args[i] directly stimulates compiler bug */
425 teml = visargs[i]; 442 teml = visargs[i];
426 args[i] = Fintern (teml, Qnil); 443 args[i] = Fintern (teml, Qnil);
427 break; 444 break;
428 445
429 case 'b': /* Name of existing buffer */ 446 case 'b': /* Name of existing buffer */
430 args[i] = Fcurrent_buffer (); 447 args[i] = Fcurrent_buffer ();
431 if (EQ (selected_window, minibuf_window)) 448 if (EQ (selected_window, minibuf_window))
432 args[i] = Fother_buffer (args[i], Qnil); 449 args[i] = Fother_buffer (args[i], Qnil);
433 args[i] = Fread_buffer (build_string (prompt), args[i], Qt); 450 args[i] = Fread_buffer (build_string (callint_message), args[i], Qt);
434 break; 451 break;
435 452
436 case 'B': /* Name of buffer, possibly nonexistent */ 453 case 'B': /* Name of buffer, possibly nonexistent */
437 args[i] = Fread_buffer (build_string (prompt), 454 args[i] = Fread_buffer (build_string (callint_message),
438 Fother_buffer (Fcurrent_buffer (), Qnil), 455 Fother_buffer (Fcurrent_buffer (), Qnil),
439 Qnil); 456 Qnil);
440 break; 457 break;
441 458
442 case 'c': /* Character */ 459 case 'c': /* Character */
443 message1 (prompt); 460 message1 (callint_message);
444 args[i] = Fread_char (); 461 args[i] = Fread_char ();
445 /* Passing args[i] directly stimulates compiler bug */ 462 /* Passing args[i] directly stimulates compiler bug */
446 teml = args[i]; 463 teml = args[i];
447 visargs[i] = Fchar_to_string (teml); 464 visargs[i] = Fchar_to_string (teml);
448 break; 465 break;
449 466
450 case 'C': /* Command: symbol with interactive function */ 467 case 'C': /* Command: symbol with interactive function */
451 visargs[i] = Fcompleting_read (build_string (prompt), 468 visargs[i] = Fcompleting_read (build_string (callint_message),
452 Vobarray, Qcommandp, Qt, Qnil, Qnil); 469 Vobarray, Qcommandp, Qt, Qnil, Qnil);
453 /* Passing args[i] directly stimulates compiler bug */ 470 /* Passing args[i] directly stimulates compiler bug */
454 teml = visargs[i]; 471 teml = visargs[i];
455 args[i] = Fintern (teml, Qnil); 472 args[i] = Fintern (teml, Qnil);
456 break; 473 break;
461 /* visargs[i] = Qnil; */ 478 /* visargs[i] = Qnil; */
462 varies[i] = 1; 479 varies[i] = 1;
463 break; 480 break;
464 481
465 case 'D': /* Directory name. */ 482 case 'D': /* Directory name. */
466 args[i] = Fread_file_name (build_string (prompt), Qnil, 483 args[i] = Fread_file_name (build_string (callint_message), Qnil,
467 current_buffer->directory, Qlambda, Qnil); 484 current_buffer->directory, Qlambda, Qnil);
468 break; 485 break;
469 486
470 case 'f': /* Existing file name. */ 487 case 'f': /* Existing file name. */
471 args[i] = Fread_file_name (build_string (prompt), 488 args[i] = Fread_file_name (build_string (callint_message),
472 Qnil, Qnil, Qlambda, Qnil); 489 Qnil, Qnil, Qlambda, Qnil);
473 break; 490 break;
474 491
475 case 'F': /* Possibly nonexistent file name. */ 492 case 'F': /* Possibly nonexistent file name. */
476 args[i] = Fread_file_name (build_string (prompt), 493 args[i] = Fread_file_name (build_string (callint_message),
477 Qnil, Qnil, Qnil, Qnil); 494 Qnil, Qnil, Qnil, Qnil);
478 break; 495 break;
479 496
480 case 'k': /* Key sequence. */ 497 case 'k': /* Key sequence. */
481 args[i] = Fread_key_sequence (build_string (prompt), Qnil, Qnil, Qnil); 498 args[i] = Fread_key_sequence (build_string (callint_message),
499 Qnil, Qnil, Qnil);
482 teml = args[i]; 500 teml = args[i];
483 visargs[i] = Fkey_description (teml); 501 visargs[i] = Fkey_description (teml);
484 break; 502 break;
485 503
486 case 'K': /* Key sequence to be defined. */ 504 case 'K': /* Key sequence to be defined. */
487 args[i] = Fread_key_sequence (build_string (prompt), Qnil, Qt, Qnil); 505 args[i] = Fread_key_sequence (build_string (callint_message),
506 Qnil, Qt, Qnil);
488 teml = args[i]; 507 teml = args[i];
489 visargs[i] = Fkey_description (teml); 508 visargs[i] = Fkey_description (teml);
490 break; 509 break;
491 510
492 case 'e': /* The invoking event. */ 511 case 'e': /* The invoking event. */
516 case 'N': /* Prefix arg, else number from minibuffer */ 535 case 'N': /* Prefix arg, else number from minibuffer */
517 if (!NILP (prefix_arg)) 536 if (!NILP (prefix_arg))
518 goto have_prefix_arg; 537 goto have_prefix_arg;
519 case 'n': /* Read number from minibuffer. */ 538 case 'n': /* Read number from minibuffer. */
520 do 539 do
521 args[i] = Fread_minibuffer (build_string (prompt), Qnil); 540 args[i] = Fread_minibuffer (build_string (callint_message), Qnil);
522 while (! NUMBERP (args[i])); 541 while (! NUMBERP (args[i]));
523 visargs[i] = last_minibuf_string; 542 visargs[i] = last_minibuf_string;
524 break; 543 break;
525 544
526 case 'P': /* Prefix arg in raw form. Does no I/O. */ 545 case 'P': /* Prefix arg in raw form. Does no I/O. */
547 args[++i] = point > foo ? point_marker : current_buffer->mark; 566 args[++i] = point > foo ? point_marker : current_buffer->mark;
548 varies[i] = 4; 567 varies[i] = 4;
549 break; 568 break;
550 569
551 case 's': /* String read via minibuffer. */ 570 case 's': /* String read via minibuffer. */
552 args[i] = Fread_string (build_string (prompt), Qnil, Qnil); 571 args[i] = Fread_string (build_string (callint_message), Qnil, Qnil);
553 break; 572 break;
554 573
555 case 'S': /* Any symbol. */ 574 case 'S': /* Any symbol. */
556 visargs[i] = Fread_string (build_string (prompt), Qnil, Qnil); 575 visargs[i] = Fread_string (build_string (callint_message),
576 Qnil, Qnil);
557 /* Passing args[i] directly stimulates compiler bug */ 577 /* Passing args[i] directly stimulates compiler bug */
558 teml = visargs[i]; 578 teml = visargs[i];
559 args[i] = Fintern (teml, Qnil); 579 args[i] = Fintern (teml, Qnil);
560 break; 580 break;
561 581
562 case 'v': /* Variable name: symbol that is 582 case 'v': /* Variable name: symbol that is
563 user-variable-p. */ 583 user-variable-p. */
564 args[i] = Fread_variable (build_string (prompt)); 584 args[i] = Fread_variable (build_string (callint_message));
565 visargs[i] = last_minibuf_string; 585 visargs[i] = last_minibuf_string;
566 break; 586 break;
567 587
568 case 'x': /* Lisp expression read but not evaluated */ 588 case 'x': /* Lisp expression read but not evaluated */
569 args[i] = Fread_minibuffer (build_string (prompt), Qnil); 589 args[i] = Fread_minibuffer (build_string (callint_message), Qnil);
570 visargs[i] = last_minibuf_string; 590 visargs[i] = last_minibuf_string;
571 break; 591 break;
572 592
573 case 'X': /* Lisp expression read and evaluated */ 593 case 'X': /* Lisp expression read and evaluated */
574 args[i] = Feval_minibuffer (build_string (prompt), Qnil); 594 args[i] = Feval_minibuffer (build_string (callint_message), Qnil);
575 visargs[i] = last_minibuf_string; 595 visargs[i] = last_minibuf_string;
576 break; 596 break;
577 597
578 /* We have a case for `+' so we get an error 598 /* We have a case for `+' so we get an error
579 if anyone tries to define one here. */ 599 if anyone tries to define one here. */
685 staticpro (&Qenable_recursive_minibuffers); 705 staticpro (&Qenable_recursive_minibuffers);
686 706
687 Qmouse_leave_buffer_hook = intern ("mouse-leave-buffer-hook"); 707 Qmouse_leave_buffer_hook = intern ("mouse-leave-buffer-hook");
688 staticpro (&Qmouse_leave_buffer_hook); 708 staticpro (&Qmouse_leave_buffer_hook);
689 709
710 callint_message_size = 100;
711 callint_message = (char *) xmalloc (callint_message_size);
712
713
690 DEFVAR_KBOARD ("prefix-arg", Vprefix_arg, 714 DEFVAR_KBOARD ("prefix-arg", Vprefix_arg,
691 "The value of the prefix argument for the next editing command.\n\ 715 "The value of the prefix argument for the next editing command.\n\
692 It may be a number, or the symbol `-' for just a minus sign as arg,\n\ 716 It may be a number, or the symbol `-' for just a minus sign as arg,\n\
693 or a list whose car is a number for just one or more C-U's\n\ 717 or a list whose car is a number for just one or more C-U's\n\
694 or nil if no argument has been specified.\n\ 718 or nil if no argument has been specified.\n\