diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/callint.c | 62 |
1 files changed, 43 insertions, 19 deletions
diff --git a/src/callint.c b/src/callint.c index c02ea33a7bd..5368ba84cf7 100644 --- a/src/callint.c +++ b/src/callint.c | |||
| @@ -47,6 +47,11 @@ static Lisp_Object preserved_fns; | |||
| 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 |
| @@ -197,7 +202,6 @@ Otherwise, this is done only if an arg is read using the minibuffer.") | |||
| 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; |
| @@ -413,13 +417,26 @@ Otherwise, this is done only if an arg is read using the minibuffer.") | |||
| 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]; |
| @@ -430,17 +447,17 @@ Otherwise, this is done only if an arg is read using the minibuffer.") | |||
| 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]; |
| @@ -448,7 +465,7 @@ Otherwise, this is done only if an arg is read using the minibuffer.") | |||
| 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]; |
| @@ -463,28 +480,30 @@ Otherwise, this is done only if an arg is read using the minibuffer.") | |||
| 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; |
| @@ -518,7 +537,7 @@ Otherwise, this is done only if an arg is read using the minibuffer.") | |||
| 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; |
| @@ -549,11 +568,12 @@ Otherwise, this is done only if an arg is read using the minibuffer.") | |||
| 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); |
| @@ -561,17 +581,17 @@ Otherwise, this is done only if an arg is read using the minibuffer.") | |||
| 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 | ||
| @@ -687,6 +707,10 @@ syms_of_callint () | |||
| 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\ |