aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStefan Monnier2010-09-12 16:35:37 +0200
committerStefan Monnier2010-09-12 16:35:37 +0200
commit5616cc54c5d2f39259d5530c2e4419c4f35356eb (patch)
tree246fcb7e4278217bf91333d9fd885220e7b6d4e0 /src
parent94c7243ba432a96be1541253013669b18eed713e (diff)
downloademacs-5616cc54c5d2f39259d5530c2e4419c4f35356eb.tar.gz
emacs-5616cc54c5d2f39259d5530c2e4419c4f35356eb.zip
* lisp/subr.el (y-or-n-p): New function, moved from src/fns.c. Use read-key.
* src/fns.c (Fy_or_n_p): Move to lisp/subr.el. (syms_of_fns): Don't defsubr Sy_or_n_p. * src/lisp.h: Don't declare Fy_or_n_p. * src/fileio.c (barf_or_query_if_file_exists): Fy_or_n_p -> y-or-n-p.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog13
-rw-r--r--src/fileio.c2
-rw-r--r--src/fns.c141
-rw-r--r--src/lisp.h1
4 files changed, 11 insertions, 146 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 9578130afd5..c866258c6fe 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,10 @@
12010-09-12 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * fns.c (Fy_or_n_p): Move to lisp/subr.el.
4 (syms_of_fns): Don't defsubr Sy_or_n_p.
5 * lisp.h: Don't declare Fy_or_n_p.
6 * fileio.c (barf_or_query_if_file_exists): Fy_or_n_p -> y-or-n-p.
7
12010-09-09 Lars Magne Ingebrigtsen <larsi@gnus.org> 82010-09-09 Lars Magne Ingebrigtsen <larsi@gnus.org>
2 9
3 * xml.c (Fxml_parse_buffer): New function to parse XML files. 10 * xml.c (Fxml_parse_buffer): New function to parse XML files.
@@ -70,8 +77,8 @@
70 characters. 77 characters.
71 78
72 * term.c (encode_terminal_code): Fix the previous change. 79 * term.c (encode_terminal_code): Fix the previous change.
73 (produce_glyphs): Don't set it->char_to_display here. Don't 80 (produce_glyphs): Don't set it->char_to_display here.
74 handle unibyte-display-via-language-environment here. 81 Don't handle unibyte-display-via-language-environment here.
75 (produce_special_glyphs): Set temp_it.char_to_display before 82 (produce_special_glyphs): Set temp_it.char_to_display before
76 calling produce_glyphs. 83 calling produce_glyphs.
77 84
@@ -114,7 +121,7 @@
1142010-08-29 Kenichi Handa <handa@m17n.org> 1212010-08-29 Kenichi Handa <handa@m17n.org>
115 122
116 * term.c (encode_terminal_code): Encode byte chars to the 123 * term.c (encode_terminal_code): Encode byte chars to the
117 correspnding bytes. 124 corresponding bytes.
118 125
1192010-08-29 Jan Djärv <jan.h.d@swipnet.se> 1262010-08-29 Jan Djärv <jan.h.d@swipnet.se>
120 127
diff --git a/src/fileio.c b/src/fileio.c
index a04cd4e76f5..3d08e881e8f 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -1842,7 +1842,7 @@ barf_or_query_if_file_exists (Lisp_Object absname, const unsigned char *querystr
1842 tem = format2 ("File %s already exists; %s anyway? ", 1842 tem = format2 ("File %s already exists; %s anyway? ",
1843 absname, build_string (querystring)); 1843 absname, build_string (querystring));
1844 if (quick) 1844 if (quick)
1845 tem = Fy_or_n_p (tem); 1845 tem = call1 (intern ("y-or-n-p"), tem);
1846 else 1846 else
1847 tem = do_yes_or_no_p (tem); 1847 tem = do_yes_or_no_p (tem);
1848 UNGCPRO; 1848 UNGCPRO;
diff --git a/src/fns.c b/src/fns.c
index 12d13186ce7..19590a2140d 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -2444,146 +2444,6 @@ SEQUENCE may be a list, a vector, a bool-vector, or a string. */)
2444 return sequence; 2444 return sequence;
2445} 2445}
2446 2446
2447/* Anything that calls this function must protect from GC! */
2448
2449DEFUN ("y-or-n-p", Fy_or_n_p, Sy_or_n_p, 1, 1, 0,
2450 doc: /* Ask user a "y or n" question. Return t if answer is "y".
2451Takes one argument, which is the string to display to ask the question.
2452It should end in a space; `y-or-n-p' adds `(y or n) ' to it.
2453No confirmation of the answer is requested; a single character is enough.
2454Also accepts Space to mean yes, or Delete to mean no. \(Actually, it uses
2455the bindings in `query-replace-map'; see the documentation of that variable
2456for more information. In this case, the useful bindings are `act', `skip',
2457`recenter', and `quit'.\)
2458
2459Under a windowing system a dialog box will be used if `last-nonmenu-event'
2460is nil and `use-dialog-box' is non-nil. */)
2461 (Lisp_Object prompt)
2462{
2463 register Lisp_Object obj, key, def, map;
2464 register int answer;
2465 Lisp_Object xprompt;
2466 Lisp_Object args[2];
2467 struct gcpro gcpro1, gcpro2;
2468 int count = SPECPDL_INDEX ();
2469
2470 specbind (Qcursor_in_echo_area, Qt);
2471
2472 map = Fsymbol_value (intern ("query-replace-map"));
2473
2474 CHECK_STRING (prompt);
2475 xprompt = prompt;
2476 GCPRO2 (prompt, xprompt);
2477
2478#ifdef HAVE_WINDOW_SYSTEM
2479 if (display_hourglass_p)
2480 cancel_hourglass ();
2481#endif
2482
2483 while (1)
2484 {
2485
2486#ifdef HAVE_MENUS
2487 if (FRAME_WINDOW_P (SELECTED_FRAME ())
2488 && (NILP (last_nonmenu_event) || CONSP (last_nonmenu_event))
2489 && use_dialog_box
2490 && have_menus_p ())
2491 {
2492 Lisp_Object pane, menu;
2493 redisplay_preserve_echo_area (3);
2494 pane = Fcons (Fcons (build_string ("Yes"), Qt),
2495 Fcons (Fcons (build_string ("No"), Qnil),
2496 Qnil));
2497 menu = Fcons (prompt, pane);
2498 obj = Fx_popup_dialog (Qt, menu, Qnil);
2499 answer = !NILP (obj);
2500 break;
2501 }
2502#endif /* HAVE_MENUS */
2503 cursor_in_echo_area = 1;
2504 choose_minibuf_frame ();
2505
2506 {
2507 Lisp_Object pargs[3];
2508
2509 /* Colorize prompt according to `minibuffer-prompt' face. */
2510 pargs[0] = build_string ("%s(y or n) ");
2511 pargs[1] = intern ("face");
2512 pargs[2] = intern ("minibuffer-prompt");
2513 args[0] = Fpropertize (3, pargs);
2514 args[1] = xprompt;
2515 Fmessage (2, args);
2516 }
2517
2518 if (minibuffer_auto_raise)
2519 {
2520 Lisp_Object mini_frame;
2521
2522 mini_frame = WINDOW_FRAME (XWINDOW (minibuf_window));
2523
2524 Fraise_frame (mini_frame);
2525 }
2526
2527 temporarily_switch_to_single_kboard (SELECTED_FRAME ());
2528 obj = read_filtered_event (1, 0, 0, 0, Qnil);
2529 cursor_in_echo_area = 0;
2530 /* If we need to quit, quit with cursor_in_echo_area = 0. */
2531 QUIT;
2532
2533 key = Fmake_vector (make_number (1), obj);
2534 def = Flookup_key (map, key, Qt);
2535
2536 if (EQ (def, intern ("skip")))
2537 {
2538 answer = 0;
2539 break;
2540 }
2541 else if (EQ (def, intern ("act")))
2542 {
2543 answer = 1;
2544 break;
2545 }
2546 else if (EQ (def, intern ("recenter")))
2547 {
2548 Frecenter (Qnil);
2549 xprompt = prompt;
2550 continue;
2551 }
2552 else if (EQ (def, intern ("quit")))
2553 Vquit_flag = Qt;
2554 /* We want to exit this command for exit-prefix,
2555 and this is the only way to do it. */
2556 else if (EQ (def, intern ("exit-prefix")))
2557 Vquit_flag = Qt;
2558
2559 QUIT;
2560
2561 /* If we don't clear this, then the next call to read_char will
2562 return quit_char again, and we'll enter an infinite loop. */
2563 Vquit_flag = Qnil;
2564
2565 Fding (Qnil);
2566 Fdiscard_input ();
2567 if (EQ (xprompt, prompt))
2568 {
2569 args[0] = build_string ("Please answer y or n. ");
2570 args[1] = prompt;
2571 xprompt = Fconcat (2, args);
2572 }
2573 }
2574 UNGCPRO;
2575
2576 if (! noninteractive)
2577 {
2578 cursor_in_echo_area = -1;
2579 message_with_string (answer ? "%s(y or n) y" : "%s(y or n) n",
2580 xprompt, 0);
2581 }
2582
2583 unbind_to (count, Qnil);
2584 return answer ? Qt : Qnil;
2585}
2586
2587/* This is how C code calls `yes-or-no-p' and allows the user 2447/* This is how C code calls `yes-or-no-p' and allows the user
2588 to redefined it. 2448 to redefined it.
2589 2449
@@ -5058,7 +4918,6 @@ this variable. */);
5058 defsubr (&Smapcar); 4918 defsubr (&Smapcar);
5059 defsubr (&Smapc); 4919 defsubr (&Smapc);
5060 defsubr (&Smapconcat); 4920 defsubr (&Smapconcat);
5061 defsubr (&Sy_or_n_p);
5062 defsubr (&Syes_or_no_p); 4921 defsubr (&Syes_or_no_p);
5063 defsubr (&Sload_average); 4922 defsubr (&Sload_average);
5064 defsubr (&Sfeaturep); 4923 defsubr (&Sfeaturep);
diff --git a/src/lisp.h b/src/lisp.h
index fc9198a5ff7..781261d9779 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -2516,7 +2516,6 @@ EXFUN (Ffillarray, 2);
2516EXFUN (Fnconc, MANY); 2516EXFUN (Fnconc, MANY);
2517EXFUN (Fmapcar, 2); 2517EXFUN (Fmapcar, 2);
2518EXFUN (Fmapconcat, 3); 2518EXFUN (Fmapconcat, 3);
2519EXFUN (Fy_or_n_p, 1);
2520extern Lisp_Object do_yes_or_no_p (Lisp_Object); 2519extern Lisp_Object do_yes_or_no_p (Lisp_Object);
2521EXFUN (Frequire, 3); 2520EXFUN (Frequire, 3);
2522EXFUN (Fprovide, 2); 2521EXFUN (Fprovide, 2);