comparison src/fns.c @ 18531:35a263e545b3

(Fy_or_n_p, Fyes_or_no_p): Obey use_dialog_box. (use_dialog_box): New variable, controls whether to use dialog boxes. (syms_of_fns): Set up Lisp variable. (concat): Use XCONS rather than Fcar, Fcdr--for known cons. (Fassq, assq_no_quit, Fassoc, Frassq, Frassoc, Fdelq): Likewise. (Fdelete, Fplist_get, mapcar1, Fmember, Fmemq): Likewise.
author Richard M. Stallman <rms@gnu.org>
date Wed, 02 Jul 1997 06:23:21 +0000
parents 618cc7b75c06
children 614b916ff5bf
comparison
equal deleted inserted replaced
18530:94c18a43de33 18531:35a263e545b3
37 #include "window.h" 37 #include "window.h"
38 38
39 #ifndef NULL 39 #ifndef NULL
40 #define NULL (void *)0 40 #define NULL (void *)0
41 #endif 41 #endif
42
43 /* Nonzero enables use of dialog boxes for questions
44 asked by mouse commands. */
45 int use_dialog_box;
42 46
43 extern Lisp_Object Flookup_key (); 47 extern Lisp_Object Flookup_key ();
44 48
45 extern int minibuffer_auto_raise; 49 extern int minibuffer_auto_raise;
46 extern Lisp_Object minibuf_window; 50 extern Lisp_Object minibuf_window;
468 472
469 /* Fetch next element of `this' arg into `elt', or break if 473 /* Fetch next element of `this' arg into `elt', or break if
470 `this' is exhausted. */ 474 `this' is exhausted. */
471 if (NILP (this)) break; 475 if (NILP (this)) break;
472 if (CONSP (this)) 476 if (CONSP (this))
473 elt = Fcar (this), this = Fcdr (this); 477 elt = XCONS (this)->car, this = XCONS (this)->cdr;
474 else 478 else
475 { 479 {
476 if (thisindex >= thisleni) break; 480 if (thisindex >= thisleni) break;
477 if (STRINGP (this)) 481 if (STRINGP (this))
478 XSETFASTINT (elt, XSTRING (this)->data[thisindex++]); 482 XSETFASTINT (elt, XSTRING (this)->data[thisindex++]);
655 (elt, list) 659 (elt, list)
656 register Lisp_Object elt; 660 register Lisp_Object elt;
657 Lisp_Object list; 661 Lisp_Object list;
658 { 662 {
659 register Lisp_Object tail; 663 register Lisp_Object tail;
660 for (tail = list; !NILP (tail); tail = Fcdr (tail)) 664 for (tail = list; !NILP (tail); tail = XCONS (tail)->cdr)
661 { 665 {
662 register Lisp_Object tem; 666 register Lisp_Object tem;
663 tem = Fcar (tail); 667 tem = Fcar (tail);
664 if (! NILP (Fequal (elt, tem))) 668 if (! NILP (Fequal (elt, tem)))
665 return tail; 669 return tail;
674 (elt, list) 678 (elt, list)
675 register Lisp_Object elt; 679 register Lisp_Object elt;
676 Lisp_Object list; 680 Lisp_Object list;
677 { 681 {
678 register Lisp_Object tail; 682 register Lisp_Object tail;
679 for (tail = list; !NILP (tail); tail = Fcdr (tail)) 683 for (tail = list; !NILP (tail); tail = XCONS (tail)->cdr)
680 { 684 {
681 register Lisp_Object tem; 685 register Lisp_Object tem;
682 tem = Fcar (tail); 686 tem = Fcar (tail);
683 if (EQ (elt, tem)) return tail; 687 if (EQ (elt, tem)) return tail;
684 QUIT; 688 QUIT;
693 (key, list) 697 (key, list)
694 register Lisp_Object key; 698 register Lisp_Object key;
695 Lisp_Object list; 699 Lisp_Object list;
696 { 700 {
697 register Lisp_Object tail; 701 register Lisp_Object tail;
698 for (tail = list; !NILP (tail); tail = Fcdr (tail)) 702 for (tail = list; !NILP (tail); tail = XCONS (tail)->cdr)
699 { 703 {
700 register Lisp_Object elt, tem; 704 register Lisp_Object elt, tem;
701 elt = Fcar (tail); 705 elt = Fcar (tail);
702 if (!CONSP (elt)) continue; 706 if (!CONSP (elt)) continue;
703 tem = Fcar (elt); 707 tem = XCONS (elt)->car;
704 if (EQ (key, tem)) return elt; 708 if (EQ (key, tem)) return elt;
705 QUIT; 709 QUIT;
706 } 710 }
707 return Qnil; 711 return Qnil;
708 } 712 }
714 assq_no_quit (key, list) 718 assq_no_quit (key, list)
715 register Lisp_Object key; 719 register Lisp_Object key;
716 Lisp_Object list; 720 Lisp_Object list;
717 { 721 {
718 register Lisp_Object tail; 722 register Lisp_Object tail;
719 for (tail = list; CONSP (tail); tail = Fcdr (tail)) 723 for (tail = list; CONSP (tail); tail = XCONS (tail)->cdr)
720 { 724 {
721 register Lisp_Object elt, tem; 725 register Lisp_Object elt, tem;
722 elt = Fcar (tail); 726 elt = Fcar (tail);
723 if (!CONSP (elt)) continue; 727 if (!CONSP (elt)) continue;
724 tem = Fcar (elt); 728 tem = XCONS (elt)->car;
725 if (EQ (key, tem)) return elt; 729 if (EQ (key, tem)) return elt;
726 } 730 }
727 return Qnil; 731 return Qnil;
728 } 732 }
729 733
733 (key, list) 737 (key, list)
734 register Lisp_Object key; 738 register Lisp_Object key;
735 Lisp_Object list; 739 Lisp_Object list;
736 { 740 {
737 register Lisp_Object tail; 741 register Lisp_Object tail;
738 for (tail = list; !NILP (tail); tail = Fcdr (tail)) 742 for (tail = list; !NILP (tail); tail = XCONS (tail)->cdr)
739 { 743 {
740 register Lisp_Object elt, tem; 744 register Lisp_Object elt, tem;
741 elt = Fcar (tail); 745 elt = Fcar (tail);
742 if (!CONSP (elt)) continue; 746 if (!CONSP (elt)) continue;
743 tem = Fequal (Fcar (elt), key); 747 tem = Fequal (XCONS (elt)->car, key);
744 if (!NILP (tem)) return elt; 748 if (!NILP (tem)) return elt;
745 QUIT; 749 QUIT;
746 } 750 }
747 return Qnil; 751 return Qnil;
748 } 752 }
753 (key, list) 757 (key, list)
754 register Lisp_Object key; 758 register Lisp_Object key;
755 Lisp_Object list; 759 Lisp_Object list;
756 { 760 {
757 register Lisp_Object tail; 761 register Lisp_Object tail;
758 for (tail = list; !NILP (tail); tail = Fcdr (tail)) 762 for (tail = list; !NILP (tail); tail = XCONS (tail)->cdr)
759 { 763 {
760 register Lisp_Object elt, tem; 764 register Lisp_Object elt, tem;
761 elt = Fcar (tail); 765 elt = Fcar (tail);
762 if (!CONSP (elt)) continue; 766 if (!CONSP (elt)) continue;
763 tem = Fcdr (elt); 767 tem = XCONS (elt)->cdr;
764 if (EQ (key, tem)) return elt; 768 if (EQ (key, tem)) return elt;
765 QUIT; 769 QUIT;
766 } 770 }
767 return Qnil; 771 return Qnil;
768 } 772 }
773 (key, list) 777 (key, list)
774 register Lisp_Object key; 778 register Lisp_Object key;
775 Lisp_Object list; 779 Lisp_Object list;
776 { 780 {
777 register Lisp_Object tail; 781 register Lisp_Object tail;
778 for (tail = list; !NILP (tail); tail = Fcdr (tail)) 782 for (tail = list; !NILP (tail); tail = XCONS (tail)->cdr)
779 { 783 {
780 register Lisp_Object elt, tem; 784 register Lisp_Object elt, tem;
781 elt = Fcar (tail); 785 elt = Fcar (tail);
782 if (!CONSP (elt)) continue; 786 if (!CONSP (elt)) continue;
783 tem = Fequal (Fcdr (elt), key); 787 tem = Fequal (XCONS (elt)->cdr, key);
784 if (!NILP (tem)) return elt; 788 if (!NILP (tem)) return elt;
785 QUIT; 789 QUIT;
786 } 790 }
787 return Qnil; 791 return Qnil;
788 } 792 }
806 { 810 {
807 tem = Fcar (tail); 811 tem = Fcar (tail);
808 if (EQ (elt, tem)) 812 if (EQ (elt, tem))
809 { 813 {
810 if (NILP (prev)) 814 if (NILP (prev))
811 list = Fcdr (tail); 815 list = XCONS (tail)->cdr;
812 else 816 else
813 Fsetcdr (prev, Fcdr (tail)); 817 Fsetcdr (prev, XCONS (tail)->cdr);
814 } 818 }
815 else 819 else
816 prev = tail; 820 prev = tail;
817 tail = Fcdr (tail); 821 tail = XCONS (tail)->cdr;
818 QUIT; 822 QUIT;
819 } 823 }
820 return list; 824 return list;
821 } 825 }
822 826
840 { 844 {
841 tem = Fcar (tail); 845 tem = Fcar (tail);
842 if (! NILP (Fequal (elt, tem))) 846 if (! NILP (Fequal (elt, tem)))
843 { 847 {
844 if (NILP (prev)) 848 if (NILP (prev))
845 list = Fcdr (tail); 849 list = XCONS (tail)->cdr;
846 else 850 else
847 Fsetcdr (prev, Fcdr (tail)); 851 Fsetcdr (prev, XCONS (tail)->cdr);
848 } 852 }
849 else 853 else
850 prev = tail; 854 prev = tail;
851 tail = Fcdr (tail); 855 tail = XCONS (tail)->cdr;
852 QUIT; 856 QUIT;
853 } 857 }
854 return list; 858 return list;
855 } 859 }
856 860
994 (plist, prop) 998 (plist, prop)
995 Lisp_Object plist; 999 Lisp_Object plist;
996 register Lisp_Object prop; 1000 register Lisp_Object prop;
997 { 1001 {
998 register Lisp_Object tail; 1002 register Lisp_Object tail;
999 for (tail = plist; !NILP (tail); tail = Fcdr (Fcdr (tail))) 1003 for (tail = plist; !NILP (tail); tail = Fcdr (XCONS (tail)->cdr))
1000 { 1004 {
1001 register Lisp_Object tem; 1005 register Lisp_Object tem;
1002 tem = Fcar (tail); 1006 tem = Fcar (tail);
1003 if (EQ (prop, tem)) 1007 if (EQ (prop, tem))
1004 return Fcar (Fcdr (tail)); 1008 return Fcar (XCONS (tail)->cdr);
1005 } 1009 }
1006 return Qnil; 1010 return Qnil;
1007 } 1011 }
1008 1012
1009 DEFUN ("get", Fget, Sget, 2, 2, 0, 1013 DEFUN ("get", Fget, Sget, 2, 2, 0,
1619 { 1623 {
1620 tail = seq; 1624 tail = seq;
1621 for (i = 0; i < leni; i++) 1625 for (i = 0; i < leni; i++)
1622 { 1626 {
1623 vals[i] = call1 (fn, Fcar (tail)); 1627 vals[i] = call1 (fn, Fcar (tail));
1624 tail = Fcdr (tail); 1628 tail = XCONS (tail)->cdr;
1625 } 1629 }
1626 } 1630 }
1627 1631
1628 UNGCPRO; 1632 UNGCPRO;
1629 } 1633 }
1712 { 1716 {
1713 1717
1714 1718
1715 #ifdef HAVE_MENUS 1719 #ifdef HAVE_MENUS
1716 if ((NILP (last_nonmenu_event) || CONSP (last_nonmenu_event)) 1720 if ((NILP (last_nonmenu_event) || CONSP (last_nonmenu_event))
1721 && use_dialog_box
1717 && have_menus_p ()) 1722 && have_menus_p ())
1718 { 1723 {
1719 Lisp_Object pane, menu; 1724 Lisp_Object pane, menu;
1720 redisplay_preserve_echo_area (); 1725 redisplay_preserve_echo_area ();
1721 pane = Fcons (Fcons (build_string ("Yes"), Qt), 1726 pane = Fcons (Fcons (build_string ("Yes"), Qt),
1830 1835
1831 CHECK_STRING (prompt, 0); 1836 CHECK_STRING (prompt, 0);
1832 1837
1833 #ifdef HAVE_MENUS 1838 #ifdef HAVE_MENUS
1834 if ((NILP (last_nonmenu_event) || CONSP (last_nonmenu_event)) 1839 if ((NILP (last_nonmenu_event) || CONSP (last_nonmenu_event))
1840 && use_dialog_box
1835 && have_menus_p ()) 1841 && have_menus_p ())
1836 { 1842 {
1837 Lisp_Object pane, menu, obj; 1843 Lisp_Object pane, menu, obj;
1838 redisplay_preserve_echo_area (); 1844 redisplay_preserve_echo_area ();
1839 pane = Fcons (Fcons (build_string ("Yes"), Qt), 1845 pane = Fcons (Fcons (build_string ("Yes"), Qt),
1982 1988
1983 DEFVAR_LISP ("features", &Vfeatures, 1989 DEFVAR_LISP ("features", &Vfeatures,
1984 "A list of symbols which are the features of the executing emacs.\n\ 1990 "A list of symbols which are the features of the executing emacs.\n\
1985 Used by `featurep' and `require', and altered by `provide'."); 1991 Used by `featurep' and `require', and altered by `provide'.");
1986 Vfeatures = Qnil; 1992 Vfeatures = Qnil;
1993
1994 DEFVAR_BOOL ("use-dialog-box", &use_dialog_box,
1995 "*Non-nil means mouse commands use dialog boxes to ask questions.\n\
1996 This applies to y-or-n and yes-or-no questions asked by commands
1997 invoked by mouse clicks and mouse menu items.");
1998 use_dialog_box = 1;
1987 1999
1988 defsubr (&Sidentity); 2000 defsubr (&Sidentity);
1989 defsubr (&Srandom); 2001 defsubr (&Srandom);
1990 defsubr (&Slength); 2002 defsubr (&Slength);
1991 defsubr (&Ssafe_length); 2003 defsubr (&Ssafe_length);