diff options
| author | Stefan Monnier | 2010-09-13 16:40:48 +0200 |
|---|---|---|
| committer | Stefan Monnier | 2010-09-13 16:40:48 +0200 |
| commit | cc390e46c7ba95b76ea133d98fd386214cd01709 (patch) | |
| tree | ead4400d22bd07214b782ff7e46e79d473fac419 /src/fns.c | |
| parent | c566235d981eba73c88bbff00b6a1d88360b6e9f (diff) | |
| parent | c5fe4acb5fb456d6e8e147d8bc7981ce56c5c03d (diff) | |
| download | emacs-cc390e46c7ba95b76ea133d98fd386214cd01709.tar.gz emacs-cc390e46c7ba95b76ea133d98fd386214cd01709.zip | |
Merge from trunk
Diffstat (limited to 'src/fns.c')
| -rw-r--r-- | src/fns.c | 149 |
1 files changed, 4 insertions, 145 deletions
| @@ -2447,146 +2447,6 @@ SEQUENCE may be a list, a vector, a bool-vector, or a string. */) | |||
| 2447 | return sequence; | 2447 | return sequence; |
| 2448 | } | 2448 | } |
| 2449 | 2449 | ||
| 2450 | /* Anything that calls this function must protect from GC! */ | ||
| 2451 | |||
| 2452 | DEFUN ("y-or-n-p", Fy_or_n_p, Sy_or_n_p, 1, 1, 0, | ||
| 2453 | doc: /* Ask user a "y or n" question. Return t if answer is "y". | ||
| 2454 | Takes one argument, which is the string to display to ask the question. | ||
| 2455 | It should end in a space; `y-or-n-p' adds `(y or n) ' to it. | ||
| 2456 | No confirmation of the answer is requested; a single character is enough. | ||
| 2457 | Also accepts Space to mean yes, or Delete to mean no. \(Actually, it uses | ||
| 2458 | the bindings in `query-replace-map'; see the documentation of that variable | ||
| 2459 | for more information. In this case, the useful bindings are `act', `skip', | ||
| 2460 | `recenter', and `quit'.\) | ||
| 2461 | |||
| 2462 | Under a windowing system a dialog box will be used if `last-nonmenu-event' | ||
| 2463 | is nil and `use-dialog-box' is non-nil. */) | ||
| 2464 | (Lisp_Object prompt) | ||
| 2465 | { | ||
| 2466 | register Lisp_Object obj, key, def, map; | ||
| 2467 | register int answer; | ||
| 2468 | Lisp_Object xprompt; | ||
| 2469 | Lisp_Object args[2]; | ||
| 2470 | struct gcpro gcpro1, gcpro2; | ||
| 2471 | int count = SPECPDL_INDEX (); | ||
| 2472 | |||
| 2473 | specbind (Qcursor_in_echo_area, Qt); | ||
| 2474 | |||
| 2475 | map = Fsymbol_value (intern ("query-replace-map")); | ||
| 2476 | |||
| 2477 | CHECK_STRING (prompt); | ||
| 2478 | xprompt = prompt; | ||
| 2479 | GCPRO2 (prompt, xprompt); | ||
| 2480 | |||
| 2481 | #ifdef HAVE_WINDOW_SYSTEM | ||
| 2482 | if (display_hourglass_p) | ||
| 2483 | cancel_hourglass (); | ||
| 2484 | #endif | ||
| 2485 | |||
| 2486 | while (1) | ||
| 2487 | { | ||
| 2488 | |||
| 2489 | #ifdef HAVE_MENUS | ||
| 2490 | if (FRAME_WINDOW_P (SELECTED_FRAME ()) | ||
| 2491 | && (NILP (last_nonmenu_event) || CONSP (last_nonmenu_event)) | ||
| 2492 | && use_dialog_box | ||
| 2493 | && have_menus_p ()) | ||
| 2494 | { | ||
| 2495 | Lisp_Object pane, menu; | ||
| 2496 | redisplay_preserve_echo_area (3); | ||
| 2497 | pane = Fcons (Fcons (build_string ("Yes"), Qt), | ||
| 2498 | Fcons (Fcons (build_string ("No"), Qnil), | ||
| 2499 | Qnil)); | ||
| 2500 | menu = Fcons (prompt, pane); | ||
| 2501 | obj = Fx_popup_dialog (Qt, menu, Qnil); | ||
| 2502 | answer = !NILP (obj); | ||
| 2503 | break; | ||
| 2504 | } | ||
| 2505 | #endif /* HAVE_MENUS */ | ||
| 2506 | cursor_in_echo_area = 1; | ||
| 2507 | choose_minibuf_frame (); | ||
| 2508 | |||
| 2509 | { | ||
| 2510 | Lisp_Object pargs[3]; | ||
| 2511 | |||
| 2512 | /* Colorize prompt according to `minibuffer-prompt' face. */ | ||
| 2513 | pargs[0] = build_string ("%s(y or n) "); | ||
| 2514 | pargs[1] = intern ("face"); | ||
| 2515 | pargs[2] = intern ("minibuffer-prompt"); | ||
| 2516 | args[0] = Fpropertize (3, pargs); | ||
| 2517 | args[1] = xprompt; | ||
| 2518 | Fmessage (2, args); | ||
| 2519 | } | ||
| 2520 | |||
| 2521 | if (minibuffer_auto_raise) | ||
| 2522 | { | ||
| 2523 | Lisp_Object mini_frame; | ||
| 2524 | |||
| 2525 | mini_frame = WINDOW_FRAME (XWINDOW (minibuf_window)); | ||
| 2526 | |||
| 2527 | Fraise_frame (mini_frame); | ||
| 2528 | } | ||
| 2529 | |||
| 2530 | temporarily_switch_to_single_kboard (SELECTED_FRAME ()); | ||
| 2531 | obj = read_filtered_event (1, 0, 0, 0, Qnil); | ||
| 2532 | cursor_in_echo_area = 0; | ||
| 2533 | /* If we need to quit, quit with cursor_in_echo_area = 0. */ | ||
| 2534 | QUIT; | ||
| 2535 | |||
| 2536 | key = Fmake_vector (make_number (1), obj); | ||
| 2537 | def = Flookup_key (map, key, Qt); | ||
| 2538 | |||
| 2539 | if (EQ (def, intern ("skip"))) | ||
| 2540 | { | ||
| 2541 | answer = 0; | ||
| 2542 | break; | ||
| 2543 | } | ||
| 2544 | else if (EQ (def, intern ("act"))) | ||
| 2545 | { | ||
| 2546 | answer = 1; | ||
| 2547 | break; | ||
| 2548 | } | ||
| 2549 | else if (EQ (def, intern ("recenter"))) | ||
| 2550 | { | ||
| 2551 | Frecenter (Qnil); | ||
| 2552 | xprompt = prompt; | ||
| 2553 | continue; | ||
| 2554 | } | ||
| 2555 | else if (EQ (def, intern ("quit"))) | ||
| 2556 | Vquit_flag = Qt; | ||
| 2557 | /* We want to exit this command for exit-prefix, | ||
| 2558 | and this is the only way to do it. */ | ||
| 2559 | else if (EQ (def, intern ("exit-prefix"))) | ||
| 2560 | Vquit_flag = Qt; | ||
| 2561 | |||
| 2562 | QUIT; | ||
| 2563 | |||
| 2564 | /* If we don't clear this, then the next call to read_char will | ||
| 2565 | return quit_char again, and we'll enter an infinite loop. */ | ||
| 2566 | Vquit_flag = Qnil; | ||
| 2567 | |||
| 2568 | Fding (Qnil); | ||
| 2569 | Fdiscard_input (); | ||
| 2570 | if (EQ (xprompt, prompt)) | ||
| 2571 | { | ||
| 2572 | args[0] = build_string ("Please answer y or n. "); | ||
| 2573 | args[1] = prompt; | ||
| 2574 | xprompt = Fconcat (2, args); | ||
| 2575 | } | ||
| 2576 | } | ||
| 2577 | UNGCPRO; | ||
| 2578 | |||
| 2579 | if (! noninteractive) | ||
| 2580 | { | ||
| 2581 | cursor_in_echo_area = -1; | ||
| 2582 | message_with_string (answer ? "%s(y or n) y" : "%s(y or n) n", | ||
| 2583 | xprompt, 0); | ||
| 2584 | } | ||
| 2585 | |||
| 2586 | unbind_to (count, Qnil); | ||
| 2587 | return answer ? Qt : Qnil; | ||
| 2588 | } | ||
| 2589 | |||
| 2590 | /* This is how C code calls `yes-or-no-p' and allows the user | 2450 | /* This is how C code calls `yes-or-no-p' and allows the user |
| 2591 | to redefined it. | 2451 | to redefined it. |
| 2592 | 2452 | ||
| @@ -4422,13 +4282,13 @@ keys. Default is `eql'. Predefined are the tests `eq', `eql', and | |||
| 4422 | Default is 65. | 4282 | Default is 65. |
| 4423 | 4283 | ||
| 4424 | :rehash-size REHASH-SIZE - Indicates how to expand the table when it | 4284 | :rehash-size REHASH-SIZE - Indicates how to expand the table when it |
| 4425 | fills up. If REHASH-SIZE is an integer, add that many space. If it | 4285 | fills up. If REHASH-SIZE is an integer, increase the size by that |
| 4426 | is a float, it must be > 1.0, and the new size is computed by | 4286 | amount. If it is a float, it must be > 1.0, and the new size is the |
| 4427 | multiplying the old size with that factor. Default is 1.5. | 4287 | old size multiplied by that factor. Default is 1.5. |
| 4428 | 4288 | ||
| 4429 | :rehash-threshold THRESHOLD -- THRESHOLD must a float > 0, and <= 1.0. | 4289 | :rehash-threshold THRESHOLD -- THRESHOLD must a float > 0, and <= 1.0. |
| 4430 | Resize the hash table when the ratio (number of entries / table size) | 4290 | Resize the hash table when the ratio (number of entries / table size) |
| 4431 | is greater or equal than THRESHOLD. Default is 0.8. | 4291 | is greater than or equal to THRESHOLD. Default is 0.8. |
| 4432 | 4292 | ||
| 4433 | :weakness WEAK -- WEAK must be one of nil, t, `key', `value', | 4293 | :weakness WEAK -- WEAK must be one of nil, t, `key', `value', |
| 4434 | `key-or-value', or `key-and-value'. If WEAK is not nil, the table | 4294 | `key-or-value', or `key-and-value'. If WEAK is not nil, the table |
| @@ -5061,7 +4921,6 @@ this variable. */); | |||
| 5061 | defsubr (&Smapcar); | 4921 | defsubr (&Smapcar); |
| 5062 | defsubr (&Smapc); | 4922 | defsubr (&Smapc); |
| 5063 | defsubr (&Smapconcat); | 4923 | defsubr (&Smapconcat); |
| 5064 | defsubr (&Sy_or_n_p); | ||
| 5065 | defsubr (&Syes_or_no_p); | 4924 | defsubr (&Syes_or_no_p); |
| 5066 | defsubr (&Sload_average); | 4925 | defsubr (&Sload_average); |
| 5067 | defsubr (&Sfeaturep); | 4926 | defsubr (&Sfeaturep); |