File: menubar-items.el

package info (click to toggle)
xemacs21 21.4.24-8
  • links: PTS
  • area: main
  • in suites: buster
  • size: 33,604 kB
  • sloc: ansic: 243,821; lisp: 94,071; cpp: 5,726; sh: 4,406; perl: 1,096; cs: 775; makefile: 761; python: 279; asm: 248; lex: 119; yacc: 95; sed: 22; csh: 9
file content (2141 lines) | stat: -rw-r--r-- 77,399 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
;;; menubar-items.el --- Menubar and popup-menu content for XEmacs.

;; Copyright (C) 1991-1995, 1997-1998 Free Software Foundation, Inc.
;; Copyright (C) 1995 Tinker Systems and INS Engineering Corp.
;; Copyright (C) 1995 Sun Microsystems.
;; Copyright (C) 1995, 1996, 2000 Ben Wing.
;; Copyright (C) 1997 MORIOKA Tomohiko.

;; Maintainer: XEmacs Development Team
;; Keywords: frames, extensions, internal, dumped

;; This file is part of XEmacs.

;; XEmacs is free software; you can redistribute it and/or modify it
;; under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.

;; XEmacs is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
;; General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with Xmacs; see the file COPYING.  If not, write to the
;; Free Software Foundation, 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.

;;; Authorship:

;; Created c. 1991 for Lucid Emacs.  Originally called x-menubar.el.
;;   Contained four menus -- File, Edit, Buffers, Help.
;;   Dynamic menu changes possible only through activate-menubar-hook.
;;   Also contained menu manipulation funs, e.g. find-menu-item, add-menu.
;; Options menu added for 19.9 by Jamie Zawinski, late 1993.
;; Major reorganization c. 1994 by Ben Wing; added many items and moved
;;   some items to two new menus, Apps and Tools. (for 19.10?)
;; Generic menubar functions moved to new file, menubar.el, by Ben Wing,
;;   1995, for 19.12; also, creation of current buffers menu options,
;;   and buffers menu changed from purely most-recent to sorted alphabetical,
;;   by mode.  Also added mode-popup-menu support.
;; New API (add-submenu, add-menu-button) and menu filter support added
;;   late summer 1995 by Stig, for 19.13.  Also popup-menubar-menu.
;; Renamed to menubar-items.el c. 1998, with MS Win support.
;; Options menu rewritten to use custom c. 1999 by ? (Jan Vroonhof?).
;; Major reorganization Mar. 2000 by Ben Wing; added many items and changed
;;   top-level menus to File, Edit, View, Cmds, Tools, Options, Buffers.
;; Accelerator spec functionality added Mar. 2000 by Ben Wing.

;;; Commentary:

;; This file is dumped with XEmacs (when window system and menubar support is
;; compiled in).

;;; Code:

(defun Menubar-items-truncate-history (list count label-length)
  "Truncate a history LIST to first COUNT items.
Return a list of (label value) lists with labels truncated to last
LABEL-LENGTH characters of value."
  (mapcar #'(lambda (x)
	      (if (<= (length x) label-length)
                  (list x x)
                (list
                 (concat "..." (substring x (- label-length))) x)))
	  (if (<= (length list) count)
	      list
	    (butlast list (- (length list) count)))))

(defun submenu-generate-accelerator-spec (list &optional omit-chars-list)
  "Add auto-generated accelerator specifications to a submenu.
This can be used to add accelerators to the return value of a menu filter
function.  It correctly ignores unselectable items.  It will destructively
modify the list passed to it.  If an item already has an auto-generated
accelerator spec, this will be removed before the new one is added, making
this function idempotent.

If OMIT-CHARS-LIST is given, it should be a list of lowercase characters,
which will not be used as accelerators."
  (let ((n 0))
    (dolist (item list list)
      (cond
       ((vectorp item)
	(setq n (1+ n))
	(aset item 0
	      (concat
	       (menu-item-generate-accelerator-spec n omit-chars-list)
	       (menu-item-strip-accelerator-spec (aref item 0)))))
       ((consp item)
	(setq n (1+ n))
	(setcar item
		(concat
		 (menu-item-generate-accelerator-spec n omit-chars-list)
		 (menu-item-strip-accelerator-spec (car item)))))))))

(defun menu-item-strip-accelerator-spec (item)
  "Strip an auto-generated accelerator spec off of ITEM.
ITEM should be a string.  This removes specs added by
`menu-item-generate-accelerator-spec' and `submenu-generate-accelerator-spec'."
  (if (string-match "%_. " item)
      (substring item 4)
    item))

(defun menu-item-generate-accelerator-spec (n &optional omit-chars-list)
  "Return an accelerator specification for use with auto-generated menus.
This should be concat'd onto the beginning of each menu line.  The spec
allows the Nth line to be selected by the number N.  '0' is used for the
10th line, and 'a' through 'z' are used for the following 26 lines.

If OMIT-CHARS-LIST is given, it should be a list of lowercase characters,
which will not be used as accelerators."
  (cond ((< n 10) (concat "%_" (int-to-string n) " "))
	((= n 10) "%_0 ")
	((<= n 36)
	 (setq n (- n 10))
	 (let ((m 0))
	   (while (> n 0)
	     (setq m (1+ m))
	     (while (memq (int-to-char (+ m (- (char-to-int ?a) 1)))
			  omit-chars-list)
	       (setq m (1+ m)))
	     (setq n (1- n)))
	   (if (<= m 26)
	       (concat
		"%_"
		(char-to-string (int-to-char (+ m (- (char-to-int ?a) 1))))
		" ")
	     "")))
	(t "")))

(defcustom menu-max-items 25
  "*Maximum number of items in generated menus.
If number of entries in such a menu is larger than this value, split menu
into submenus of nearly equal length (see `menu-submenu-max-items').  If
nil, never split menu into submenus."
  :group 'menu
  :type '(choice (const :tag "no submenus" nil)
		 (integer)))

(defcustom menu-submenu-max-items 20
  "*Maximum number of items in submenus when splitting menus.
We split large menus into submenus of this many items, and then balance
them out as much as possible (otherwise the last submenu may have very few
items)."
  :group 'menu
  :type 'integer)

(defcustom menu-submenu-name-format "%-12.12s ... %.12s"
  "*Format specification of the submenu name when splitting menus.
Used by `menu-split-long-menu' if the number of entries in a menu is
larger than `menu-menu-max-items'.
This string should contain one %s for the name of the first entry and
one %s for the name of the last entry in the submenu.
If the value is a function, it should return the submenu name.  The
function is be called with two arguments, the names of the first and
the last entry in the menu."
  :group 'menu
  :type '(choice (string :tag "Format string")
		 (function)))

(defun menu-split-long-menu (menu)
  "Split MENU according to `menu-max-items' and add accelerator specs.

You should normally use the idiom

\(menu-split-long-menu (menu-sort-menu menu))

See also `menu-sort-menu'."
  (let ((len (length menu)))
    (if (or (null menu-max-items)
	    (<= len menu-max-items))
	(submenu-generate-accelerator-spec menu)
      (let* ((outer (/ (+ len (1- menu-submenu-max-items))
		       menu-submenu-max-items))
	     (inner (/ (+ len (1- outer)) outer))
	     (result nil))
	(while menu
	  (let ((sub nil)
		(from (car menu)))
	    (dotimes (foo (min inner len))
	      (setq sub  (cons (car menu) sub)
		    menu (cdr menu)))
	    (setq len (- len inner))
	    (let ((to (car sub)))
	      (setq sub (nreverse sub))
	      (setq result
		    (cons (cons (if (stringp menu-submenu-name-format)
				    (format menu-submenu-name-format
					    (menu-item-strip-accelerator-spec
					     (aref from 0))
					    (menu-item-strip-accelerator-spec
					     (aref to 0)))
				  (funcall menu-submenu-name-format
					   (menu-item-strip-accelerator-spec
					    (aref from 0))
					   (menu-item-strip-accelerator-spec
					    (aref to 0))))
				(submenu-generate-accelerator-spec sub))
			  result)))))
	(submenu-generate-accelerator-spec (nreverse result))))))

(defun menu-sort-menu (menu)
  "Sort MENU alphabetically.

You should normally use the idiom

\(menu-split-long-menu (menu-sort-menu menu))

See also `menu-split-long-menu'."
  (sort menu
	#'(lambda (a b) (string-lessp (aref a 0) (aref b 0)))))

(defun menu-item-search ()
  "Bring up a search dialog if possible and desired, else do interactive search"
  (interactive)
  (if (should-use-dialog-box-p)
      (make-search-dialog)
    (isearch-forward)))

(defconst default-menubar
; (purecopy-menubar ;purespace is dead
   ;; note backquote.
   `(
     ("%_File"
      ["%_Open..." find-file]
      ["Open in Other %_Window..." find-file-other-window]
      ["Open in New %_Frame..." find-file-other-frame]
      ["%_Hex Edit File..." hexl-find-file
       :active (fboundp 'hexl-find-file)]
      ["%_Insert File..." insert-file]
      ["%_View File..." view-file]
      "------"
      ["%_Save" save-buffer
       :active (buffer-modified-p)
       :suffix (if put-buffer-names-in-file-menu (buffer-name) "")]
      ["Save %_As..." write-file]
      ["Save So%_me Buffers" save-some-buffers]
      "-----"
      ,@(if (valid-specifier-tag-p 'msprinter)
	  '(["Page Set%_up..." generic-page-setup]))
      ["%_Print" generic-print-buffer
       :active (or (valid-specifier-tag-p 'msprinter)
		   (and (not (eq system-type 'windows-nt))
			(fboundp 'lpr-region)))
       :suffix (if (region-active-p) "Selection..."
		 (if put-buffer-names-in-file-menu (concat (buffer-name) "...")
		   "..."))]
      ,@(unless (valid-specifier-tag-p 'msprinter)
	  '(["Prett%_y-Print" ps-print-buffer-with-faces
	     :active (fboundp 'ps-print-buffer-with-faces)
	     :suffix (if put-buffer-names-in-file-menu (buffer-name) "")]))
      "-----"
      ["%_Revert Buffer" revert-buffer
       :active (or buffer-file-name revert-buffer-function)
       :suffix (if put-buffer-names-in-file-menu (buffer-name) "")]
      ["Re%_cover File..." recover-file]
      ["Recover S%_ession..." recover-session]
      "-----"
      ["E%_xit XEmacs" save-buffers-kill-emacs]
      )

     ("%_Edit"
      ["%_Undo" advertised-undo
       :active (and (not (eq buffer-undo-list t))
		    (or buffer-undo-list pending-undo-list))
       :suffix (if (or (eq last-command 'undo)
		       (eq last-command 'advertised-undo))
		   "More" "")]
      ["%_Redo" redo
       :included (fboundp 'redo)
       :active (not (or (eq buffer-undo-list t)
			(eq last-buffer-undo-list nil)
			(not (or (eq last-buffer-undo-list buffer-undo-list)
				 (and (null (car-safe buffer-undo-list))
				      (eq last-buffer-undo-list
					  (cdr-safe buffer-undo-list)))))
			(or (eq buffer-undo-list pending-undo-list)
			    (eq (cdr buffer-undo-list) pending-undo-list))))
       :suffix (if (eq last-command 'redo) "More" "")]
      "----"
      ["Cu%_t" kill-primary-selection
       :active (selection-owner-p)]
      ["%_Copy" copy-primary-selection
       :active (selection-owner-p)]
      ["%_Paste" yank-clipboard-selection
       :active (selection-exists-p 'CLIPBOARD)]
      ["%_Delete" delete-primary-selection
       :active (selection-owner-p)]
      "----"
      ["Select %_All" mark-whole-buffer]
      ["Select Pa%_ge" mark-page]
      "----"
      ["%_Find..." menu-item-search]
      ["R%_eplace..." query-replace]
      ["Replace (Rege%_xp)..." query-replace-regexp]
      ["%_List Matching Lines..." list-matching-lines]
      ,@(when (featurep 'mule)
	 '("----"
	   ("%_Multilingual (\"Mule\")"
	    ("%_Describe Language Support")
	    ("%_Set Language Environment")
	    "--"
	    ["T%_oggle Input Method" toggle-input-method]
	    ["Select %_Input Method" set-input-method]
	    ["D%_escribe Input Method" describe-input-method]
	    "--"
	    ["Describe Current %_Coding Systems"
	     describe-current-coding-system]
	    ["Set Coding System of %_Buffer File..."
	     set-buffer-file-coding-system]
	    ;; not implemented yet
	    ["Set Coding System of %_Terminal..."
	     set-terminal-coding-system :active nil]
	    ;; not implemented yet
	    ["Set Coding System of %_Keyboard..."
	     set-keyboard-coding-system :active nil]
	    ["Set Coding System of %_Process..."
	     set-buffer-process-coding-system
	     :active (get-buffer-process (current-buffer))]
	    "--"
	    ["Show Cha%_racter Table" view-charset-by-menu]
	    ;; not implemented yet
	    ["Show Dia%_gnosis for MULE" mule-diag :active nil]
	    ["Show \"%_hello\" in Many Languages" view-hello-file]))
	 )
      )

     ("%_View"
      ["%_New Frame" make-frame]
      ["Frame on Other Displa%_y..." make-frame-on-display
       :active (fboundp 'make-frame-on-display)]
      ["%_Delete Frame" delete-frame
       :active (not (eq (next-frame (selected-frame) 'nomini 'window-system)
			(selected-frame)))]
      "-----"
      ["%_Split Window" split-window-vertically]
      ["S%_plit Window (Side by Side)" split-window-horizontally]
      ["%_Un-Split (Keep This)" delete-other-windows
       :active (not (one-window-p t))]
      ["Un-Split (Keep %_Others)" delete-window
       :active (not (one-window-p t))]
      "----"
      ("N%_arrow"
       ["%_Narrow to Region" narrow-to-region :active (region-exists-p)]
       ["Narrow to %_Page" narrow-to-page]
       ["Narrow to %_Defun" narrow-to-defun]
      "----"
       ["%_Widen" widen :active (or (/= (point-min) 1)
				    (/= (point-max) (1+ (buffer-size))))]
       )
      "----"
      ["Show Message %_Log" show-message-log]
      "----"
      ["%_Goto Line..." goto-line]
      ["%_What Line" what-line]
      ("%_Bookmarks"
       :filter bookmark-menu-filter)
      "----"
      ["%_Jump to Previous Mark" (set-mark-command t)
       :active (mark t)]
      )

     ("C%_mds"
      ["Repeat %_Last Complex Command..." repeat-complex-command]
      ["E%_valuate Lisp Expression..." eval-expression]
      ["Execute %_Named Command..." execute-extended-command]
      "----"
      ["Start %_Macro Recording" start-kbd-macro
       :included (not defining-kbd-macro)]
      ["End %_Macro Recording" end-kbd-macro
       :included defining-kbd-macro]
      ["E%_xecute Last Macro" call-last-kbd-macro
       :active last-kbd-macro]
      ("%_Other Macro"
       ["%_Append to Last Macro" (start-kbd-macro t)
	:active (and (not defining-kbd-macro) last-kbd-macro)]
       ["%_Query User During Macro" kbd-macro-query
	:active defining-kbd-macro]
       ["Enter %_Recursive Edit During Macro" (kbd-macro-query t)
	:active defining-kbd-macro]
       "---"
       ["E%_xecute Last Macro on Region Lines"
	:active (and last-kbd-macro (region-exists-p))]
       "---"
       ["%_Name Last Macro..." name-last-kbd-macro
	:active last-kbd-macro]
       ["Assign Last Macro to %_Key..." assign-last-kbd-macro-to-key
	:active (and last-kbd-macro
		     (fboundp 'assign-last-kbd-macro-to-key))]
       "---"
       ["%_Edit Macro..." edit-kbd-macro]
       ["Edit %_Last Macro" edit-last-kbd-macro
	:active last-kbd-macro]
       "---"
       ["%_Insert Named Macro into Buffer..." insert-kbd-macro]
       ["Read Macro from Re%_gion" read-kbd-macro
	:active (region-exists-p)]
       )
      "----"
      ("%_Abbrev"
       ["D%_ynamic Abbrev Expand" dabbrev-expand]
       ["Dynamic Abbrev %_Complete" dabbrev-completion]
       ["Dynamic Abbrev Complete in %_All Buffers" (dabbrev-completion 16)]
       "----"
       "----"
       ["%_Define Global Abbrev for " add-global-abbrev
	:suffix	(abbrev-string-to-be-defined nil)
	:active abbrev-mode]
       ["Define %_Mode-Specific Abbrev for " add-mode-abbrev
	:suffix	(abbrev-string-to-be-defined nil)
	:active abbrev-mode]
       ["Define Global Ex%_pansion for " inverse-add-global-abbrev
	:suffix	(inverse-abbrev-string-to-be-defined 1)
	:active abbrev-mode]
       ["Define Mode-Specific Expa%_nsion for " inverse-add-mode-abbrev
	:suffix	(inverse-abbrev-string-to-be-defined 1)
	:active abbrev-mode]
       "---"
       ["E%_xpand Abbrev" expand-abbrev]
       ["Expand Abbrevs in Re%_gion" expand-region-abbrevs
	:active (region-exists-p)]
       ["%_Unexpand Last Abbrev" unexpand-abbrev
	:active (and (stringp last-abbrev-text)
		     (> last-abbrev-location 0))]
       "---"
       ["%_Kill All Abbrevs" kill-all-abbrevs]
       ["%_Insert All Abbrevs into Buffer" insert-abbrevs]
       ["%_List Abbrevs" list-abbrevs]
       "---"
       ["%_Edit Abbrevs" edit-abbrevs]
       ["%_Redefine Abbrevs from Buffer" edit-abbrevs-redefine
	:active (eq major-mode 'edit-abbrevs-mode)]
       "---"
       ["%_Save Abbrevs As..." write-abbrev-file]
       ["L%_oad Abbrevs..." read-abbrev-file]
       )
      ("%_Register"
       ["%_Copy to Register..." copy-to-register :active (region-exists-p)]
       ["%_Paste Register..." insert-register]
       "---"
       ["%_Save Point to Register" point-to-register]
       ["%_Jump to Register"  register-to-point]
       )
      ("R%_ectangles"
       ["%_Kill Rectangle" kill-rectangle]
       ["%_Yank Rectangle" yank-rectangle]
       ["Rectangle %_to Register" copy-rectangle-to-register]
       ["Rectangle %_from Register" insert-register]
       ["%_Clear Rectangle" clear-rectangle]
       ["%_Open Rectangle" open-rectangle]
       ["%_Prefix Rectangle..." string-rectangle]
       ["Rectangle %_Mousing"
	(customize-set-variable	'mouse-track-rectangle-p
				(not mouse-track-rectangle-p))
	:style toggle :selected mouse-track-rectangle-p]
       )
      ("%_Sort"
       ["%_Lines in Region" sort-lines :active (region-exists-p)]
       ["%_Paragraphs in Region" sort-paragraphs :active (region-exists-p)]
       ["P%_ages in Region" sort-pages :active (region-exists-p)]
       ["%_Columns in Region" sort-columns :active (region-exists-p)]
       ["%_Regexp..." sort-regexp-fields :active (region-exists-p)]
       )
      ("%_Change Case"
       ["%_Upcase Region" upcase-region :active (region-exists-p)]
       ["%_Downcase Region" downcase-region :active (region-exists-p)]
       ["%_Capitalize Region" capitalize-region :active (region-exists-p)]
       ["%_Title-Case Region" capitalize-region-as-title
	:active (region-exists-p)]
       )
      ("Ce%_nter"
       ["%_Line" center-line]
       ["%_Paragraph" center-paragraph]
       ["%_Region" center-region :active (region-exists-p)]
       )
      ("%_Indent"
       ["%_As Previous Line" indent-relative]
       ["%_To Column..." indent-to-column]
       "---"
       ["%_Region" indent-region :active (region-exists-p)]
       ["%_Balanced Expression" indent-sexp]
       ["%_C Expression" indent-c-exp]
       )
      ("S%_pell-Check"
       ["%_Buffer" ispell-buffer
	:active (fboundp 'ispell-buffer)]
       "---"
       ["%_Word" ispell-word]
       ["%_Complete Word" ispell-complete-word]
       ["%_Region" ispell-region]
       )
      )

     ("%_Tools"
      ("%_Packages"
       ("%_Set Download Site"
	("%_Official Releases"
	 :filter (lambda (&rest junk)
		   (menu-split-long-menu
		    (submenu-generate-accelerator-spec
		     (package-ui-download-menu)))))
	("%_Pre-Releases"
	 :filter (lambda (&rest junk)
		   (menu-split-long-menu
		    (submenu-generate-accelerator-spec
		     (package-ui-pre-release-download-menu)))))
	("%_Site Releases"
	 :filter (lambda (&rest junk)
		   (menu-split-long-menu
		    (submenu-generate-accelerator-spec
		     (package-ui-site-release-download-menu))))))
       "--:shadowEtchedIn"
       ["%_Update Package Index" package-get-update-base]
       ["%_List and Install" pui-list-packages]
       ["U%_pdate Installed Packages" package-get-update-all]
       ["%_Help" (Info-goto-node "(xemacs)Packages")])
      ("%_Internet"
       ["Read Mail %_1 (VM)..." vm
	:active (fboundp 'vm)]
       ["Read Mail %_2 (MH)..." (mh-rmail t)
	:active (fboundp 'mh-rmail)]
       ["Send %_Mail..." compose-mail
	:active (fboundp 'compose-mail)]
       ["Usenet %_News" gnus
	:active (fboundp 'gnus)]
       ["Browse the %_Web" w3
	:active (fboundp 'w3)])
      "---"
      ("%_Grep"
       :filter
       (lambda (menu)
	 (if (or (not (boundp 'grep-history)) (null grep-history))
	     menu
	   (let ((items
		  (submenu-generate-accelerator-spec
                   (mapcar #'(lambda (label-value)
			       (vector (first label-value)
				       (list 'grep (second label-value))))
			   (Menubar-items-truncate-history
                            grep-history 10 50)))))
	     (append menu '("---") items))))
       ["%_Grep..." grep :active (fboundp 'grep)]
       ["%_Kill Grep" kill-compilation
	:active (and (fboundp 'kill-compilation)
		     (fboundp 'compilation-find-buffer)
		     (let ((buffer (condition-case nil
				       (compilation-find-buffer)
				     (error nil))))
		       (and buffer (get-buffer-process buffer))))]
       "---"
       ["Grep %_All Files in Current Directory..."
	(progn
	  (require 'compile)
	  (let ((grep-command
		 (cons (concat grep-command " *")
		       (length grep-command))))
	    (call-interactively 'grep)))
	:active (fboundp 'grep)]
       ["Grep %_C and C Header Files in Current Directory..."
	(progn
	  (require 'compile)
	  (let ((grep-command
		 (cons (concat grep-command " *.[chCH]"
					; i wanted to also use *.cc and *.hh.
					; see long comment below under Perl.
			       )
		       (length grep-command))))
	    (call-interactively 'grep)))
	:active (fboundp 'grep)]
       ["Grep C Hea%_der Files in Current Directory..."
	(progn
	  (require 'compile)
	  (let ((grep-command
		 (cons (concat grep-command " *.[hH]"
					; i wanted to also use *.hh.
					; see long comment below under Perl.
			       )
		       (length grep-command))))
	    (call-interactively 'grep)))
	:active (fboundp 'grep)]
       ["Grep %_E-Lisp Files in Current Directory..."
	(progn
	  (require 'compile)
	  (let ((grep-command
		 (cons (concat grep-command " *.el")
		       (length grep-command))))
	    (call-interactively 'grep)))
	:active (fboundp 'grep)]
       ["Grep %_Perl Files in Current Directory..."
	(progn
	  (require 'compile)
	  (let ((grep-command
		 (cons (concat grep-command " *.pl"
					; i wanted to use this:
					; " *.pl *.pm *.am"
					; but grep complains if it can't
					; match anything in a glob, and
					; that screws other things up.
					; perhaps we need to first scan
					; each separate glob in the directory
					; to see if there are any files in
					; that glob, and if not, omit it.
			       )
		       (length grep-command))))
	    (call-interactively 'grep)))
	:active (fboundp 'grep)]
       ["Grep %_HTML Files in Current Directory..."
	(progn
	  (require 'compile)
	  (let ((grep-command
		 (cons (concat grep-command " *.*htm*")
		       (length grep-command))))
	    (call-interactively 'grep)))
	:active (fboundp 'grep)]
       "---"
       ["%_Next Match" next-error
	:active (and (fboundp 'compilation-errors-exist-p)
		     (compilation-errors-exist-p))]
       ["Pre%_vious Match" previous-error
	:active (and (fboundp 'compilation-errors-exist-p)
		     (compilation-errors-exist-p))]
       ["%_First Match" first-error
	:active (and (fboundp 'compilation-errors-exist-p)
		     (compilation-errors-exist-p))]
       ["G%_oto Match" compile-goto-error
	:active (and (fboundp 'compilation-errors-exist-p)
		     (compilation-errors-exist-p))]
       "---"
       ["%_Set Grep Command..."
	(progn
	  (require 'compile)
	  (customize-set-variable
	   'grep-command
	   (read-shell-command "Default Grep Command: " grep-command)))
	:active (fboundp 'grep)
	]
       )
      ("%_Compile"
       :filter
       (lambda (menu)
	 (if (or (not (boundp 'compile-history)) (null compile-history))
	     menu
	   (let ((items
		  (submenu-generate-accelerator-spec
		   (mapcar #'(lambda (label-value)
			       (vector (first label-value)
				       (list 'compile (second label-value))))
			   (Menubar-items-truncate-history
                            compile-history 10 50)))))
	     (append menu '("---") items))))
       ["%_Compile..." compile :active (fboundp 'compile)]
       ["%_Repeat Compilation" recompile :active (fboundp 'recompile)]
       ["%_Kill Compilation" kill-compilation
	:active (and (fboundp 'kill-compilation)
		     (fboundp 'compilation-find-buffer)
		     (let ((buffer (condition-case nil
				       (compilation-find-buffer)
				     (error nil))))
		       (and buffer (get-buffer-process buffer))))]
       "---"
       ["%_Next Error" next-error
	:active (and (fboundp 'compilation-errors-exist-p)
		     (compilation-errors-exist-p))]
       ["Pre%_vious Error" previous-error
	:active (and (fboundp 'compilation-errors-exist-p)
		     (compilation-errors-exist-p))]
       ["%_First Error" first-error
	:active (and (fboundp 'compilation-errors-exist-p)
		     (compilation-errors-exist-p))]
       ["G%_oto Error" compile-goto-error
	:active (and (fboundp 'compilation-errors-exist-p)
		     (compilation-errors-exist-p))]
       )
      ("%_Debug"
       ["%_GDB..." gdb
	:active (fboundp 'gdb)]
       ["%_DBX..." dbx
	:active (fboundp 'dbx)])
      ("%_Shell"
       ["%_Shell" shell
	:active (fboundp 'shell)]
       ["S%_hell Command..." shell-command
	:active (fboundp 'shell-command)]
       ["Shell Command on %_Region..." shell-command-on-region
       :active (and (fboundp 'shell-command-on-region) (region-exists-p))])

      ("%_Tags"
       ["%_Find Tag..." find-tag]
       ["Find %_Other Window..." find-tag-other-window]
       ["%_Next Tag..." (find-tag nil)]
       ["N%_ext Other Window..." (find-tag-other-window nil)]
       ["Next %_File" next-file]
       "-----"
       ["Tags %_Search..." tags-search]
       ["Tags %_Replace..." tags-query-replace]
       ["%_Continue Search/Replace" tags-loop-continue]
       "-----"
       ["%_Pop stack" pop-tag-mark]
       ["%_Apropos..." tags-apropos]
       "-----"
       ["%_Set Tags Table File..." visit-tags-table]
       )

      "----"

      ("Ca%_lendar"
       ["%_3-Month Calendar" calendar
	:active (fboundp 'calendar)]
       ["%_Diary" diary
	:active (fboundp 'diary)]
       ["%_Holidays" holidays
	:active (fboundp 'holidays)]
       ;; we're all pagans at heart ...
       ["%_Phases of the Moon" phases-of-moon
	:active (fboundp 'phases-of-moon)]
       ["%_Sunrise/Sunset" sunrise-sunset
	:active (fboundp 'sunrise-sunset)])

      ("Ga%_mes"
       ["%_Mine Game" xmine
	:active (fboundp 'xmine)]
       ["%_Tetris" tetris
	:active (fboundp 'tetris)]
       ["%_Sokoban" sokoban
	:active (fboundp 'sokoban)]
       ["Quote from %_Zippy" yow
	:active (fboundp 'yow)]
       ["%_Psychoanalyst" doctor
	:active (fboundp 'doctor)]
       ["Ps%_ychoanalyze Zippy!" psychoanalyze-pinhead
	:active (fboundp 'psychoanalyze-pinhead)]
       ["%_Random Flames" flame
	:active (fboundp 'flame)]
       ["%_Dunnet (Adventure)" dunnet
	:active (fboundp 'dunnet)]
       ["Towers of %_Hanoi" hanoi
	:active (fboundp 'hanoi)]
       ["Game of %_Life" life
	:active (fboundp 'life)]
       ["M%_ultiplication Puzzle" mpuz
	:active (fboundp 'mpuz)])

      "----"
      )

     ("%_Options"
      ("%_Advanced (Customize)"
       ("%_Emacs" :filter (lambda (&rest junk)
			    (cdr (custom-menu-create 'emacs))))
       ["%_Group..." customize-group]
       ["%_Variable..." customize-variable]
       ["%_Face..." customize-face]
       ["%_Saved..." customize-saved]
       ["Se%_t..." customize-customized]
       ["%_Apropos..." customize-apropos]
       ["%_Browse..." customize-browse])
      "---"
      ("%_Editing"
       ["This Buffer %_Read Only" (toggle-read-only)
	:style toggle :selected buffer-read-only]
       ["%_Yank/Kill Interact With Clipboard"
	(if (eq interprogram-cut-function 'own-clipboard)
	    (progn
	      (customize-set-variable 'interprogram-cut-function nil)
	      (customize-set-variable 'interprogram-paste-function nil))
	  (customize-set-variable 'interprogram-cut-function 'own-clipboard)
	  (customize-set-variable 'interprogram-paste-function 'get-clipboard))
	:style toggle
	:selected (eq interprogram-cut-function 'own-clipboard)]
       ["%_Overstrike"
	(progn
	  (setq overwrite-mode (if overwrite-mode nil 'overwrite-mode-textual))
	  (customize-set-variable 'overwrite-mode overwrite-mode))
	:style toggle :selected overwrite-mode]
       ["%_Abbrev Mode"
	(customize-set-variable 'abbrev-mode
				(not (default-value 'abbrev-mode)))
	:style toggle
	:selected (default-value 'abbrev-mode)]
       ["Active Re%_gions"
	(customize-set-variable 'zmacs-regions (not zmacs-regions))
	:style toggle :selected zmacs-regions]
       "---"
       ["%_Case Sensitive Search"
	(customize-set-variable 'case-fold-search
				(setq case-fold-search (not case-fold-search)))
	:style toggle :selected (not case-fold-search)]
       ["Case %_Matching Replace"
	(customize-set-variable 'case-replace (not case-replace))
	:style toggle :selected case-replace]
       "---"
       ("%_Newline at End of File..."
	["%_Don't Require"
	 (customize-set-variable 'require-final-newline nil)
	 :style radio :selected (not require-final-newline)]
	["%_Require"
	 (customize-set-variable 'require-final-newline t)
	 :style radio :selected (eq require-final-newline t)]
	["%_Ask"
	 (customize-set-variable 'require-final-newline 'ask)
	 :style radio :selected (and require-final-newline
				     (not (eq require-final-newline t)))])
       ["Add Newline When Moving Past %_End"
	(customize-set-variable 'next-line-add-newlines
				(not next-line-add-newlines))
	:style toggle :selected next-line-add-newlines])
      ("%_Keyboard and Mouse"
       ["%_Delete Key Deletes Selection"
	(customize-set-variable 'pending-delete-mode (not pending-delete-mode))
	:style toggle
	:selected (and (boundp 'pending-delete-mode) pending-delete-mode)
	:active (boundp 'pending-delete-mode)]
       ["`%_kill-line' Kills Whole Line at %_Beg"
	 (customize-set-variable 'kill-whole-line (not kill-whole-line))
	 :style toggle
	 :selected kill-whole-line]
       ["Size for %_Block-Movement Commands..."
	(customize-set-variable 'block-movement-size
				(read-number "Block Movement Size: "
					      t block-movement-size))]
       ["%_VI Emulation"
	(progn
	  (toggle-viper-mode)
	  (customize-set-variable 'viper-mode viper-mode))
	:style toggle :selected (and (boundp 'viper-mode) viper-mode)
	:active (fboundp 'toggle-viper-mode)]
       "----"
       ["S%_hifted Motion Keys Select Region"
	 (customize-set-variable 'shifted-motion-keys-select-region
				 (not shifted-motion-keys-select-region))
	 :style toggle
	 :selected shifted-motion-keys-select-region]
       ["%_After Shifted Motion, Unshifted Motion Keys Deselect"
	 (customize-set-variable 'unshifted-motion-keys-deselect-region
				 (not unshifted-motion-keys-deselect-region))
	 :style toggle
	 :selected unshifted-motion-keys-deselect-region]
       "----"
       ["%_Set Key..." global-set-key]
       ["%_Unset Key..." global-unset-key]
       "---"
       ["%_Mouse Paste at Text Cursor (not Clicked Location)"
	(customize-set-variable 'mouse-yank-at-point (not mouse-yank-at-point))
	:style toggle :selected mouse-yank-at-point]
       "---"
       ["%_Teach Extended Commands"
	(customize-set-variable 'teach-extended-commands-p
				(not teach-extended-commands-p))
	:style toggle :selected teach-extended-commands-p]
       )
      ("%_Printing"
       ["Set Printer %_Name for Generic Print Support..."
	(customize-set-variable
	 'printer-name
	 (read-string "Set printer name: " printer-name))]
       "---"
       ["Command-Line %_Switches for `lpr'/`lp'..."
	;; better to directly open a customization buffer, since the value
	;; must be a list of strings, which is somewhat complex to prompt for.
	(customize-variable 'lpr-switches)
	(boundp 'lpr-switches)]
       ("%_Pretty-Print Paper Size"
	["%_Letter"
	 (customize-set-variable 'ps-paper-type 'letter)
	 :style radio
	 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'letter))
	 :active (boundp 'ps-paper-type)]
	["Lette%_r-Small"
	 (customize-set-variable 'ps-paper-type 'letter-small)
	 :style radio
	 :selected (and (boundp 'ps-paper-type)
			(eq ps-paper-type 'letter-small))
	 :active (boundp 'ps-paper-type)]
	["Le%_gal"
	 (customize-set-variable 'ps-paper-type 'legal)
	 :style radio
	 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'legal))
	 :active (boundp 'ps-paper-type)]
	["%_Statement"
	 (customize-set-variable 'ps-paper-type 'statement)
	 :style radio
	 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'statement))
	 :active (boundp 'ps-paper-type)]
	["%_Executive"
	 (customize-set-variable 'ps-paper-type 'executive)
	 :style radio
	 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'executive))
	 :active (boundp 'ps-paper-type)]
	["%_Tabloid"
	 (customize-set-variable 'ps-paper-type 'tabloid)
	 :style radio
	 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'tabloid))
	 :active (boundp 'ps-paper-type)]
	["Le%_dger"
	 (customize-set-variable 'ps-paper-type 'ledger)
	 :style radio
	 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'ledger))
	 :active (boundp 'ps-paper-type)]
	["A%_3"
	 (customize-set-variable 'ps-paper-type 'a3)
	 :style radio
	 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'a3))
	 :active (boundp 'ps-paper-type)]
	["%_A4"
	 (customize-set-variable 'ps-paper-type 'a4)
	 :style radio
	 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'a4))
	 :active (boundp 'ps-paper-type)]
	["A4s%_mall"
	 (customize-set-variable 'ps-paper-type 'a4small)
	 :style radio
	 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'a4small))
	 :active (boundp 'ps-paper-type)]
	["B%_4"
	 (customize-set-variable 'ps-paper-type 'b4)
	 :style radio
	 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'b4))
	 :active (boundp 'ps-paper-type)]
	["%_B5"
	 (customize-set-variable 'ps-paper-type 'b5)
	 :style radio
	 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'b5))
	 :active (boundp 'ps-paper-type)]
	)
       ["%_Color Printing"
	(cond (ps-print-color-p
	       (customize-set-variable 'ps-print-color-p nil)
	       ;; I'm wondering whether all this muck is useful.
	       (and (boundp 'original-face-background)
		    original-face-background
		    (set-face-background 'default original-face-background)))
	      (t
	       (customize-set-variable 'ps-print-color-p t)
	       (setq original-face-background
		     (face-background-instance 'default))
	       (set-face-background 'default "white")))
	:style toggle
	:selected (and (boundp 'ps-print-color-p) ps-print-color-p)
	:active (boundp 'ps-print-color-p)])
      ("%_Internet"
       ("%_Compose Mail With"
	["Default Emacs Mailer"
	 (customize-set-variable 'mail-user-agent 'sendmail-user-agent)
	 :style radio
	 :selected (eq mail-user-agent 'sendmail-user-agent)]
	["MH"
	 (customize-set-variable 'mail-user-agent 'mh-e-user-agent)
	 :style radio
	 :selected (eq mail-user-agent 'mh-e-user-agent)
	 :active (get 'mh-e-user-agent 'composefunc)]
	["GNUS"
	 (customize-set-variable 'mail-user-agent 'message-user-agent)
	 :style radio
	 :selected (eq mail-user-agent 'message-user-agent)
	 :active (get 'message-user-agent 'composefunc)]
	)
       ["Set My %_Email Address..."
	(customize-set-variable
	 'user-mail-address
	 (read-string "Set email address: " user-mail-address))]
       ["Set %_Machine Email Name..."
	(customize-set-variable
	 'mail-host-address
	 (read-string "Set machine email name: " mail-host-address))]
       ["Set %_SMTP Server..."
	(progn
	  (require 'smtpmail)
	  (customize-set-variable
	   'smtpmail-smtp-server
	   (read-string "Set SMTP server: " smtpmail-smtp-server)))
	:active (and (boundp 'send-mail-function)
		     (eq send-mail-function 'smtpmail-send-it))]
       ["SMTP %_Debug Info"
	(progn
	  (require 'smtpmail)
	  (customize-set-variable 'smtpmail-debug-info
				  (not smtpmail-debug-info)))
	:style toggle
	:selected (and (boundp 'smtpmail-debug-info) smtpmail-debug-info)
	:active (and (boundp 'send-mail-function)
		     (eq send-mail-function 'smtpmail-send-it))]
       "---"
       ("%_Open URLs With"
	["%_Emacs-W3"
	 (customize-set-variable 'browse-url-browser-function 'browse-url-w3)
	 :style radio
	 :selected (and (boundp 'browse-url-browser-function)
			(eq browse-url-browser-function 'browse-url-w3))
	 :active (and (boundp 'browse-url-browser-function)
		      (fboundp 'browse-url-w3)
		      (fboundp 'w3-fetch))]
        ["Emacs-%_W3 (gnudoit)"
         (customize-set-variable 'browse-url-browser-function 'browse-url-w3-gnudoit)
         :style radio
         :selected (and (boundp 'browse-url-browser-function)
                        (eq browse-url-browser-function
                            'browse-url-w3-gnudoit))
	 :active (and (boundp 'browse-url-browser-function)
		      (fboundp 'browse-url-w3-gnudoit))]
	["%_Netscape"
	 (customize-set-variable 'browse-url-browser-function
				 'browse-url-netscape)
	 :style radio
	 :selected (and (boundp 'browse-url-browser-function)
			(eq browse-url-browser-function 'browse-url-netscape))
	 :active (and (boundp 'browse-url-browser-function)
		      (fboundp 'browse-url-netscape))]
	["%_Mosaic"
	 (customize-set-variable 'browse-url-browser-function
				 'browse-url-mosaic)
	 :style radio
	 :selected (and (boundp 'browse-url-browser-function)
			(eq browse-url-browser-function 'browse-url-mosaic))
	 :active (and (boundp 'browse-url-browser-function)
		      (fboundp 'browse-url-mosaic))]
	["Mosaic (%_CCI)"
	 (customize-set-variable 'browse-url-browser-function 'browse-url-cci)
	 :style radio
	 :selected (and (boundp 'browse-url-browser-function)
			(eq browse-url-browser-function 'browse-url-cci))
	 :active (and (boundp 'browse-url-browser-function)
		      (fboundp 'browse-url-cci))]
	["%_IXI Mosaic"
	 (customize-set-variable 'browse-url-browser-function
				 'browse-url-iximosaic)
	 :style radio
	 :selected (and (boundp 'browse-url-browser-function)
			(eq browse-url-browser-function 'browse-url-iximosaic))
	 :active (and (boundp 'browse-url-browser-function)
		      (fboundp 'browse-url-iximosaic))]
	["%_Lynx (xterm)"
	 (customize-set-variable 'browse-url-browser-function
				 'browse-url-lynx-xterm)
	 :style radio
	 :selected (and (boundp 'browse-url-browser-function)
			(eq browse-url-browser-function 'browse-url-lynx-xterm))
	 :active (and (boundp 'browse-url-browser-function)
		      (fboundp 'browse-url-lynx-xterm))]
	["L%_ynx (xemacs)"
	 (customize-set-variable 'browse-url-browser-function
				 'browse-url-lynx-emacs)
	 :style radio
	 :selected (and (boundp 'browse-url-browser-function)
			(eq browse-url-browser-function 'browse-url-lynx-emacs))
	 :active (and (boundp 'browse-url-browser-function)
		      (fboundp 'browse-url-lynx-emacs))]
	["%_Grail"
	 (customize-set-variable 'browse-url-browser-function
				 'browse-url-grail)
	 :style radio
	 :selected (and (boundp 'browse-url-browser-function)
			(eq browse-url-browser-function 'browse-url-grail))
	 :active (and (boundp 'browse-url-browser-function)
		      (fboundp 'browse-url-grail))]
	["%_KDE"
	 (customize-set-variable 'browse-url-browser-function
				 'browse-url-kde)
	 :style radio
	 :selected (and (boundp 'browse-url-browser-function)
			(eq browse-url-browser-function 'browse-url-kde))
	 :active (and (boundp 'browse-url-browser-function)
		      (fboundp 'browse-url-kde))]
	["Mo%_zilla"
	 (customize-set-variable 'browse-url-browser-function
				 'browse-url-mozilla)
	 :style radio
	 :selected (and (boundp 'browse-url-browser-function)
			(eq browse-url-browser-function 'browse-url-mozilla))
	 :active (and (boundp 'browse-url-browser-function)
		      (fboundp 'browse-url-mozilla))]
	["G%_aleon"
	 (customize-set-variable 'browse-url-browser-function
				 'browse-url-galeon)
	 :style radio
	 :selected (and (boundp 'browse-url-browser-function)
			(eq browse-url-browser-function 'browse-url-galeon))
	 :active (and (boundp 'browse-url-browser-function)
		      (fboundp 'browse-url-galeon))]
	["%_Opera"
	 (customize-set-variable 'browse-url-browser-function
				 'browse-url-opera)
	 :style radio
	 :selected (and (boundp 'browse-url-browser-function)
			(eq browse-url-browser-function 'browse-url-opera))
	 :active (and (boundp 'browse-url-browser-function)
		      (fboundp 'browse-url-opera))]
	["%_MMM"
	 (customize-set-variable 'browse-url-browser-function
				 'browse-url-mmm)
	 :style radio
	 :selected (and (boundp 'browse-url-browser-function)
			(eq browse-url-browser-function 'browse-url-mmm))
	 :active (and (boundp 'browse-url-browser-function)
		      (fboundp 'browse-url-mmm))]
	["MS-Windows Default %_Browser"
	 (customize-set-variable 'browse-url-browser-function
				 'browse-url-default-windows-browser)
	 :style radio
	 :selected (and (boundp 'browse-url-browser-function)
			(eq browse-url-browser-function
                            'browse-url-default-windows-browser))
	 :active (and (boundp 'browse-url-browser-function)
		      (fboundp 'mswindows-shell-execute)
		      (fboundp 'browse-url-default-windows-browser))]
	["G%_eneric Browser"
	 (customize-set-variable 'browse-url-browser-function
				 'browse-url-generic)
	 :style radio
	 :selected (and (boundp 'browse-url-browser-function)
			(eq browse-url-browser-function 'browse-url-generic))
	 :active (and (boundp 'browse-url-browser-function)
		      (boundp 'browse-url-generic-program)
		      browse-url-generic-program
		      (fboundp 'browse-url-generic))]
	))
      ("%_Troubleshooting"
       ["%_Debug on Error"
	(customize-set-variable 'debug-on-error (not debug-on-error))
	:style toggle :selected debug-on-error]
       ["Debug on %_Quit"
	(customize-set-variable 'debug-on-quit (not debug-on-quit))
	:style toggle :selected debug-on-quit]
       ["Debug on S%_ignal"
	(customize-set-variable 'debug-on-signal (not debug-on-signal))
	:style toggle :selected debug-on-signal]
       ["%_Stack Trace on Error"
	(customize-set-variable 'stack-trace-on-error
				(not stack-trace-on-error))
	:style toggle :selected stack-trace-on-error]
       ["Stack Trace on Si%_gnal"
	(customize-set-variable 'stack-trace-on-signal
				(not stack-trace-on-signal))
	:style toggle :selected stack-trace-on-signal]
       )
      "-----"
      ("%_Display"
       ,@(if (featurep 'scrollbar)
	     '(["%_Scrollbars"
		(customize-set-variable 'scrollbars-visible-p
					(not scrollbars-visible-p))
		:style toggle
		:selected scrollbars-visible-p]))
       ["%_Wrap Long Lines"
	(progn;; becomes buffer-local
	  (setq truncate-lines (not truncate-lines))
	  (customize-set-variable 'truncate-lines truncate-lines))
	:style toggle
	:selected (not truncate-lines)]
       "----"
       ["%_3D Modeline"
	(customize-set-variable 'modeline-3d-p
				(not modeline-3d-p))
	:style toggle
	:selected modeline-3d-p]
       ("Modeline %_Horizontal Scrolling"
	["%_None"
	 (customize-set-variable 'modeline-scrolling-method nil)
	 :style radio
	 :selected (not modeline-scrolling-method)]
	["As %_Text"
	 (customize-set-variable 'modeline-scrolling-method t)
	 :style radio
	 :selected (eq modeline-scrolling-method t)]
	["As %_Scrollbar"
	 (customize-set-variable 'modeline-scrolling-method 'scrollbar)
	 :style radio
	 :selected (eq modeline-scrolling-method 'scrollbar)]
	)
       ,@(if (featurep 'toolbar)
	     '("---"
	       ["%_Toolbars Visible"
		(customize-set-variable 'toolbar-visible-p
					(not toolbar-visible-p))
		:style toggle
		:selected toolbar-visible-p]
	       ["Toolbars Ca%_ptioned"
		(customize-set-variable 'toolbar-captioned-p
					(not toolbar-captioned-p))
		:style toggle
		:active toolbar-visible-p
		:selected toolbar-captioned-p]
	       ("Default Toolba%_r Location"
		["%_Top"
		 (customize-set-variable 'default-toolbar-position 'top)
		 :style radio
		 :active toolbar-visible-p
		 :selected (eq default-toolbar-position 'top)]
		["%_Bottom"
		 (customize-set-variable 'default-toolbar-position 'bottom)
		 :style radio
		 :active toolbar-visible-p
		 :selected (eq default-toolbar-position 'bottom)]
		["%_Left"
		 (customize-set-variable 'default-toolbar-position 'left)
		 :style radio
		 :active toolbar-visible-p
		 :selected (eq default-toolbar-position 'left)]
		["%_Right"
		 (customize-set-variable 'default-toolbar-position 'right)
		 :style radio
		 :active toolbar-visible-p
		 :selected (eq default-toolbar-position 'right)]
		)
	       ))
       ,@(if (featurep 'gutter)
	     '("---"
	       ["B%_uffers Tab Visible"
		(customize-set-variable 'gutter-buffers-tab-visible-p
					(not gutter-buffers-tab-visible-p))
		:style toggle
		:selected gutter-buffers-tab-visible-p]
	       ("Default %_Gutter Location"
		["%_Top"
		 (customize-set-variable 'default-gutter-position 'top)
		 :style radio
		 :selected (eq default-gutter-position 'top)]
		["%_Bottom"
		 (customize-set-variable 'default-gutter-position 'bottom)
		 :style radio
		 :selected (eq default-gutter-position 'bottom)]
		["%_Left"
		 (customize-set-variable 'default-gutter-position 'left)
		 :style radio
		 :selected (eq default-gutter-position 'left)]
		["%_Right"
		 (customize-set-variable 'default-gutter-position 'right)
		 :style radio
		 :selected (eq default-gutter-position 'right)]
		)
	       ))
       "-----"
       ["%_Blinking Cursor"
	(customize-set-variable 'blink-cursor-mode (not blink-cursor-mode))
	:style toggle
	:selected (and (boundp 'blink-cursor-mode) blink-cursor-mode)
	:active (boundp 'blink-cursor-mode)]
       ["Bl%_ock Cursor"
	(progn
	  (customize-set-variable 'bar-cursor nil)
	  (force-cursor-redisplay))
	:style radio
	:selected (null bar-cursor)]
       ["Bar Cursor (%_1 Pixel)"
	(progn
	  (customize-set-variable 'bar-cursor t)
	  (force-cursor-redisplay))
	:style radio
	:selected (eq bar-cursor t)]
       ["Bar Cursor (%_2 Pixels)"
	(progn
	  (customize-set-variable 'bar-cursor 2)
	  (force-cursor-redisplay))
	:style radio
	:selected (and bar-cursor (not (eq bar-cursor t)))]
       "----"
       ("Pa%_ren Highlighting"
       ["%_None"
	(customize-set-variable 'paren-mode nil)
	:style radio
	:selected (and (boundp 'paren-mode) (not paren-mode))
	:active (boundp 'paren-mode)]
       ["%_Blinking Paren"
	(customize-set-variable 'paren-mode 'blink-paren)
	:style radio
	:selected (and (boundp 'paren-mode) (eq paren-mode 'blink-paren))
	:active (boundp 'paren-mode)]
       ["%_Steady Paren"
	(customize-set-variable 'paren-mode 'paren)
	:style radio
	:selected (and (boundp 'paren-mode) (eq paren-mode 'paren))
	:active (boundp 'paren-mode)]
       ["%_Expression"
	(customize-set-variable 'paren-mode 'sexp)
	:style radio
	:selected (and (boundp 'paren-mode) (eq paren-mode 'sexp))
	:active (boundp 'paren-mode)]
       ;;	 ["Nes%_ted Shading"
       ;;	  (customize-set-variable 'paren-mode 'nested)
       ;;	  :style radio
       ;;	  :selected (and (boundp 'paren-mode) (eq paren-mode 'nested))
       ;;	  :active (boundp 'paren-mode)]
       )
       "------"
       ["%_Line Numbers"
	(progn
	  (customize-set-variable 'line-number-mode (not line-number-mode))
	  (redraw-modeline))
	:style toggle :selected line-number-mode]
       ["%_Column Numbers"
	(progn
	  (customize-set-variable 'column-number-mode
				  (not column-number-mode))
	  (redraw-modeline))
	:style toggle :selected column-number-mode]

       ("\"Other %_Window\" Location"
	["%_Always in Same Frame"
	 (customize-set-variable
	  'get-frame-for-buffer-default-instance-limit nil)
	 :style radio
	 :selected (null get-frame-for-buffer-default-instance-limit)]
	["Other Frame (%_2 Frames Max)"
	 (customize-set-variable 'get-frame-for-buffer-default-instance-limit
				 2)
	 :style radio
	 :selected (eq 2 get-frame-for-buffer-default-instance-limit)]
	["Other Frame (%_3 Frames Max)"
	 (customize-set-variable 'get-frame-for-buffer-default-instance-limit
				 3)
	 :style radio
	 :selected (eq 3 get-frame-for-buffer-default-instance-limit)]
	["Other Frame (%_4 Frames Max)"
	 (customize-set-variable 'get-frame-for-buffer-default-instance-limit
				 4)
	 :style radio
	 :selected (eq 4 get-frame-for-buffer-default-instance-limit)]
	["Other Frame (%_5 Frames Max)"
	 (customize-set-variable 'get-frame-for-buffer-default-instance-limit
				 5)
	 :style radio
	 :selected (eq 5 get-frame-for-buffer-default-instance-limit)]
	["Always Create %_New Frame"
	 (customize-set-variable 'get-frame-for-buffer-default-instance-limit
				 0)
	 :style radio
	 :selected (eq 0 get-frame-for-buffer-default-instance-limit)]
	"-----"
	["%_Temp Buffers Always in Same Frame"
	 (customize-set-variable 'temp-buffer-show-function
				 'show-temp-buffer-in-current-frame)
	 :style radio
	 :selected (eq temp-buffer-show-function
		       'show-temp-buffer-in-current-frame)]
	["Temp Buffers %_Like Other Buffers"
	 (customize-set-variable 'temp-buffer-show-function nil)
	 :style radio
	 :selected (null temp-buffer-show-function)]
	"-----"
	["%_Make Current Frame Gnuserv Target"
	 (customize-set-variable 'gnuserv-frame (if (eq gnuserv-frame t) nil
						  t))
	 :style toggle
	 :selected (and (boundp 'gnuserv-frame) (eq gnuserv-frame t))
	 :active (boundp 'gnuserv-frame)]
	)
       )
      ("%_Menubars"
       ["%_Frame-Local Font Menu"
	(customize-set-variable 'font-menu-this-frame-only-p
				(not font-menu-this-frame-only-p))
	:style toggle
	:selected (and (boundp 'font-menu-this-frame-only-p)
		       font-menu-this-frame-only-p)]
       ["%_Alt/Meta Selects Menu Items"
	(if (eq menu-accelerator-enabled 'menu-force)
	    (customize-set-variable 'menu-accelerator-enabled nil)
	  (customize-set-variable 'menu-accelerator-enabled 'menu-force))
	:style toggle
	:selected (eq menu-accelerator-enabled 'menu-force)]
       "----"
       ["Buffers Menu %_Length..."
	(customize-set-variable
	 'buffers-menu-max-size
	 ;; would it be better to open a customization buffer ?
	 (let ((val
		(read-number
		 "Enter number of buffers to display (or 0 for unlimited): ")))
	   (if (eq val 0) nil val)))]
       ["%_Multi-Operation Buffers Sub-Menus"
	(customize-set-variable 'complex-buffers-menu-p
				(not complex-buffers-menu-p))
	:style toggle
	:selected complex-buffers-menu-p]
       ["S%_ubmenus for Buffer Groups"
	(customize-set-variable 'buffers-menu-submenus-for-groups-p
				(not buffers-menu-submenus-for-groups-p))
	:style toggle
	:selected buffers-menu-submenus-for-groups-p]
       ["%_Verbose Buffer Menu Entries"
	(if (eq buffers-menu-format-buffer-line-function
		'slow-format-buffers-menu-line)
	    (customize-set-variable 'buffers-menu-format-buffer-line-function
				    'format-buffers-menu-line)
	  (customize-set-variable 'buffers-menu-format-buffer-line-function
				  'slow-format-buffers-menu-line))
	:style toggle
	:selected (eq buffers-menu-format-buffer-line-function
		      'slow-format-buffers-menu-line)]
       ("Buffers Menu %_Sorting"
	["%_Most Recently Used"
	 (progn
	   (customize-set-variable 'buffers-menu-sort-function nil)
	   (customize-set-variable 'buffers-menu-grouping-function nil))
	 :style radio
	 :selected (null buffers-menu-sort-function)]
	["%_Alphabetically"
	 (progn
	   (customize-set-variable 'buffers-menu-sort-function
				   'sort-buffers-menu-alphabetically)
	   (customize-set-variable 'buffers-menu-grouping-function nil))
	 :style radio
	 :selected (eq 'sort-buffers-menu-alphabetically
		       buffers-menu-sort-function)]
	["%_By Major Mode, Then Alphabetically"
	 (progn
	   (customize-set-variable
	    'buffers-menu-sort-function
	    'sort-buffers-menu-by-mode-then-alphabetically)
	   (customize-set-variable
	    'buffers-menu-grouping-function
	    'group-buffers-menu-by-mode-then-alphabetically))
	 :style radio
	 :selected (eq 'sort-buffers-menu-by-mode-then-alphabetically
		       buffers-menu-sort-function)])
       "---"
       ["%_Ignore Scaled Fonts"
	(customize-set-variable 'font-menu-ignore-scaled-fonts
				(not font-menu-ignore-scaled-fonts))
	:style toggle
	:selected (and (boundp 'font-menu-ignore-scaled-fonts)
		       font-menu-ignore-scaled-fonts)]
       )
      ("S%_yntax Highlighting"
       ["%_In This Buffer"
	(progn;; becomes buffer local
	  (font-lock-mode)
	  (customize-set-variable 'font-lock-mode font-lock-mode))
	:style toggle
	:selected (and (boundp 'font-lock-mode) font-lock-mode)
	:active (boundp 'font-lock-mode)]
       ["%_Automatic"
	(customize-set-variable 'font-lock-auto-fontify
				(not font-lock-auto-fontify))
	:style toggle
	:selected (and (boundp 'font-lock-auto-fontify) font-lock-auto-fontify)
	:active (fboundp 'font-lock-mode)]
       "-----"
       ["Force %_Rehighlight in this Buffer"
	(customize-set-variable 'font-lock-auto-fontify
				(not font-lock-auto-fontify))
	:style toggle
	:selected (and (boundp 'font-lock-auto-fontify) font-lock-auto-fontify)
	:active (fboundp 'font-lock-mode)]
       "-----"
       ["%_Fonts"
	(progn
	  (require 'font-lock)
	  (font-lock-use-default-fonts)
	  (customize-set-variable 'font-lock-use-fonts t)
	  (customize-set-variable 'font-lock-use-colors nil)
	  (font-lock-mode 1))
	:style radio
	:selected (and (boundp 'font-lock-use-fonts) font-lock-use-fonts)
	:active (fboundp 'font-lock-mode)]
       ["%_Colors"
	(progn
	  (require 'font-lock)
	  (font-lock-use-default-colors)
	  (customize-set-variable 'font-lock-use-colors t)
	  (customize-set-variable 'font-lock-use-fonts nil)
	  (font-lock-mode 1))
	:style radio
	:selected (and (boundp 'font-lock-use-colors) font-lock-use-colors)
	:active (boundp 'font-lock-mode)]
       "-----"
       ["%_1 Least"
	(progn
	  (require 'font-lock)
	  (if (or (and (not (integerp font-lock-maximum-decoration))
		       (not (eq t font-lock-maximum-decoration)))
		  (and (integerp font-lock-maximum-decoration)
		       (<= font-lock-maximum-decoration 0)))
	      nil
	    (customize-set-variable 'font-lock-maximum-decoration nil)
	    (font-lock-recompute-variables)))
	:style radio
	:active (fboundp 'font-lock-mode)
	:selected (and (boundp 'font-lock-maximum-decoration)
		       (or (and (not (integerp font-lock-maximum-decoration))
				(not (eq t font-lock-maximum-decoration)))
			   (and (integerp font-lock-maximum-decoration)
				(<= font-lock-maximum-decoration 0))))]
       ["%_2 More"
	(progn
	  (require 'font-lock)
	  (if (and (integerp font-lock-maximum-decoration)
		   (= 1 font-lock-maximum-decoration))
	      nil
	    (customize-set-variable 'font-lock-maximum-decoration 1)
	    (font-lock-recompute-variables)))
	:style radio
	:active (fboundp 'font-lock-mode)
	:selected (and (boundp 'font-lock-maximum-decoration)
		       (integerp font-lock-maximum-decoration)
		       (= 1 font-lock-maximum-decoration))]
       ["%_3 Even More"
	(progn
	  (require 'font-lock)
	  (if (and (integerp font-lock-maximum-decoration)
		   (= 2 font-lock-maximum-decoration))
	      nil
	    (customize-set-variable 'font-lock-maximum-decoration 2)
	    (font-lock-recompute-variables)))
	:style radio
	:active (fboundp 'font-lock-mode)
	:selected (and (boundp 'font-lock-maximum-decoration)
		       (integerp font-lock-maximum-decoration)
		       (= 2 font-lock-maximum-decoration))]
       ["%_4 Most"
	(progn
	  (require 'font-lock)
	  (if (or (eq font-lock-maximum-decoration t)
		  (and (integerp font-lock-maximum-decoration)
		       (>= font-lock-maximum-decoration 3)))
	      nil
	    (customize-set-variable 'font-lock-maximum-decoration t)
	    (font-lock-recompute-variables)))
	:style radio
	:active (fboundp 'font-lock-mode)
	:selected (and (boundp 'font-lock-maximum-decoration)
		       (or (eq font-lock-maximum-decoration t)
			   (and (integerp font-lock-maximum-decoration)
				(>= font-lock-maximum-decoration 3))))]
       "-----"
       ["Lazy %_Lock"
	(progn;; becomes buffer local
	  (lazy-lock-mode)
	  (customize-set-variable 'lazy-lock-mode lazy-lock-mode)
	  ;; this shouldn't be necessary so there has to
	  ;; be a redisplay bug lurking somewhere (or
	  ;; possibly another event handler bug)
	  (redraw-modeline))
	:active (and (boundp 'font-lock-mode) (boundp 'lazy-lock-mode)
		     font-lock-mode)
	:style toggle
	:selected (and (boundp 'lazy-lock-mode) lazy-lock-mode)]
       ["Lazy %_Shot"
	(progn;; becomes buffer local
	  (lazy-shot-mode)
	  (customize-set-variable 'lazy-shot-mode lazy-shot-mode)
	  ;; this shouldn't be necessary so there has to
	  ;; be a redisplay bug lurking somewhere (or
	  ;; possibly another event handler bug)
	  (redraw-modeline))
	:active (and (boundp 'font-lock-mode) (boundp 'lazy-shot-mode)
		     font-lock-mode)
	:style toggle
	:selected (and (boundp 'lazy-shot-mode) lazy-shot-mode)]
       ["Cac%_hing"
	(progn;; becomes buffer local
	  (fast-lock-mode)
	  (customize-set-variable 'fast-lock-mode fast-lock-mode)
	  ;; this shouldn't be necessary so there has to
	  ;; be a redisplay bug lurking somewhere (or
	  ;; possibly another event handler bug)
	  (redraw-modeline))
	:active (and (boundp 'font-lock-mode) (boundp 'fast-lock-mode)
		     font-lock-mode)
	:style toggle
	:selected (and (boundp 'fast-lock-mode) fast-lock-mode)]
       )
      ("%_Font" :filter font-menu-family-constructor)
      ("Font Si%_ze" :filter font-menu-size-constructor)
      ;;      ("Font Weig%_ht" :filter font-menu-weight-constructor)
      ["Edit Fa%_ces..." (customize-face nil)]
      "-----"
      ["Edit I%_nit File"
       ;; #### there should be something that holds the name that the init
       ;; file should be created as, when it's not present.
       (progn (find-file (or user-init-file "~/.xemacs/init.el"))
	      (or (eq major-mode 'emacs-lisp-mode)
		  (emacs-lisp-mode)))]
      ["%_Save Options to Custom File" customize-save-customized]
      )

     ("%_Buffers"
      :filter buffers-menu-filter
      ["Go To %_Previous Buffer" switch-to-other-buffer]
      ["Go To %_Buffer..." switch-to-buffer]
      "----"
      ["%_List All Buffers" list-buffers]
      ["%_Delete Buffer" kill-this-buffer
       :suffix (if put-buffer-names-in-file-menu (buffer-name) "")]
      "----"
      )

     nil	; the partition: menus after this are flushright

     ("%_Help"
      ["%_About XEmacs..." about-xemacs]
      "-----"
      ["What's %_New in XEmacs" view-emacs-news]
      ["%_Obtaining XEmacs" describe-distribution]
      "-----"
      ("%_Info (Online Docs)"
       ["%_Info Contents" info]
       ["Lookup %_Key Binding..." Info-goto-emacs-key-command-node]
       ["Lookup %_Command..." Info-goto-emacs-command-node]
       ["Lookup %_Function..." Info-elisp-ref]
       ["Lookup %_Topic..." Info-query])
      ("XEmacs %_FAQ"
       ["%_FAQ (local)" xemacs-local-faq]
       ["FAQ via %_WWW" xemacs-www-faq
	:active (fboundp 'browse-url)]
       ["%_Home Page" xemacs-www-page
	:active (fboundp 'browse-url)])
      ("%_Tutorials"
       :filter tutorials-menu-filter)
      ("%_Samples"
       ["Sample %_init.el"
	(find-file (locate-data-file "sample.init.el"))
	:active (locate-data-file "sample.init.el")]
       ["Sample .%_gtkrc"
	(find-file (locate-data-file "sample.gtkrc"))
	:included (featurep 'gtk)
	:active (locate-data-file "sample.gtkrc")]
       ["Sample .%_Xdefaults"
	(find-file (locate-data-file "sample.Xdefaults"))
	:included (featurep 'x)
	:active (locate-data-file "sample.Xdefaults")]
       ["Sample %_enriched"
	(find-file (locate-data-file "enriched.doc"))
	:active (locate-data-file "enriched.doc")])
      ("%_Commands & Keys"
       ["%_Mode" describe-mode]
       ["%_Apropos..." hyper-apropos]
       ["Apropos %_Docs..." apropos-documentation]
       "-----"
       ["%_Key..." describe-key]
       ["%_Bindings" describe-bindings]
       ["%_Mouse Bindings" describe-pointer]
       ["%_Recent Keys" view-lossage]
       "-----"
       ["%_Function..." describe-function]
       ["%_Variable..." describe-variable]
       ["%_Locate Command..." where-is])
      "-----"
      ["%_Recent Messages" view-lossage]
      ("%_Misc"
       ["%_Current Installation Info" describe-installation
	:active (boundp 'Installation-string)]
       ["%_No Warranty" describe-no-warranty]
       ["XEmacs %_License" describe-copying]
       ["Find %_Packages" finder-by-keyword]
       ["View %_Splash Screen" xemacs-splash-buffer]
       ["%_Unix Manual..." manual-entry])
      ["Send %_Bug Report..." report-xemacs-bug
       :active (fboundp 'report-xemacs-bug)])))


(defun maybe-add-init-button ()
  "Don't call this.
Adds `Load .emacs' button to menubar when starting up with -q."
  (when (and (not load-user-init-file-p)
	     (file-exists-p (expand-file-name ".emacs" "~")))
    (add-menu-button
     nil
     ["%_Load .emacs"
      (progn
	(mapc #'(lambda (buf)
		 (with-current-buffer buf
		   (delete-menu-item '("Load .emacs"))))
	      (buffer-list))
	(load-user-init-file))
      ]
     "Help")))

(add-hook 'before-init-hook 'maybe-add-init-button)


;;; The File menu

(defvar put-buffer-names-in-file-menu t)


;;; The Bookmarks menu

(defun bookmark-menu-filter (&rest ignore)
  (declare (special bookmark-alist))
  (let ((definedp (and (boundp 'bookmark-alist)
		       bookmark-alist
		       t)))
    `(,(if definedp
	   '("%_Jump to Bookmark"
	     :filter (lambda (&rest junk)
		       (submenu-generate-accelerator-spec
			(mapcar #'(lambda (bmk)
				    `[,bmk (bookmark-jump ',bmk)])
				(bookmark-all-names)))))
	 ["%_Jump to Bookmark" nil nil])
      ["Set %_Bookmark" bookmark-set
       :active (fboundp 'bookmark-set)]
      "---"
      ["Insert %_Contents" bookmark-menu-insert
       :active (fboundp 'bookmark-menu-insert)]
      ["Insert L%_ocation" bookmark-menu-locate
       :active (fboundp 'bookmark-menu-locate)]
      "---"
      ["%_Rename Bookmark" bookmark-menu-rename
       :active (fboundp 'bookmark-menu-rename)]
      ,(if definedp
	   '("%_Delete Bookmark"
	     :filter (lambda (&rest junk)
		       (submenu-generate-accelerator-spec
			(mapcar #'(lambda (bmk)
				    `[,bmk (bookmark-delete ',bmk)])
				(bookmark-all-names)))))
	 ["%_Delete Bookmark" nil nil])
      ["%_Edit Bookmark List" bookmark-bmenu-list	,definedp]
      "---"
      ["%_Save Bookmarks"        bookmark-save		,definedp]
      ["Save Bookmarks %_As..."  bookmark-write		,definedp]
      ["%_Load a Bookmark File" bookmark-load
       :active (fboundp 'bookmark-load)])))

;;; The Buffers menu

(defgroup buffers-menu nil
  "Customization of `Buffers' menu."
  :group 'menu)

(defvar buffers-menu-omit-chars-list '(?b ?p ?l ?d))

(defcustom buffers-menu-max-size 25
  "*Maximum number of entries which may appear on the \"Buffers\" menu.
If this is 10, then only the ten most-recently-selected buffers will be
shown.  If this is nil, then all buffers will be shown.  Setting this to
a large number or nil will slow down menu responsiveness."
  :type '(choice (const :tag "Show all" nil)
		 (integer 10))
  :group 'buffers-menu)

(defcustom complex-buffers-menu-p nil
  "*If non-nil, the buffers menu will contain several commands.
Commands will be presented as submenus of each buffer line.  If this
is false, then there will be only one command: select that buffer."
  :type 'boolean
  :group 'buffers-menu)

(defcustom buffers-menu-submenus-for-groups-p nil
  "*If non-nil, the buffers menu will contain one submenu per group of buffers.
The grouping function is specified in `buffers-menu-grouping-function'.
If this is an integer, do not build submenus if the number of buffers
is not larger than this value."
  :type '(choice (const :tag "No Subgroups" nil)
		 (integer :tag "Max. submenus" 10)
		 (sexp :format "%t\n" :tag "Allow Subgroups" :value t))
  :group 'buffers-menu)

(defcustom buffers-menu-switch-to-buffer-function 'switch-to-buffer
  "*The function to call to select a buffer from the buffers menu.
`switch-to-buffer' is a good choice, as is `pop-to-buffer'."
  :type '(radio (function-item switch-to-buffer)
		(function-item pop-to-buffer)
		(function :tag "Other"))
  :group 'buffers-menu)

(defcustom buffers-menu-omit-function 'buffers-menu-omit-invisible-buffers
  "*If non-nil, a function specifying the buffers to omit from the buffers menu.
This is passed a buffer and should return non-nil if the buffer should be
omitted.  The default value `buffers-menu-omit-invisible-buffers' omits
buffers that are normally considered \"invisible\" (those whose name
begins with a space)."
  :type '(choice (const :tag "None" nil)
		 function)
  :group 'buffers-menu)

(defcustom buffers-menu-format-buffer-line-function 'format-buffers-menu-line
  "*The function to call to return a string to represent a buffer in
the buffers menu.  The function is passed a buffer and a number
(starting with 1) indicating which buffer line in the menu is being
processed and should return a string containing an accelerator
spec. (Check out `menu-item-generate-accelerator-spec' as a convenient
way of generating the accelerator specs.) The default value
`format-buffers-menu-line' just returns the name of the buffer and
uses the number as the accelerator.  Also check out
`slow-format-buffers-menu-line' which returns a whole bunch of info
about a buffer.

Note: Gross Compatibility Hack: Older versions of this function prototype
only expected one argument, not two.  We deal gracefully with such
functions by simply calling them with one argument and leaving out the
line number.  However, this may go away at any time, so make sure to
update all of your functions of this type."
  :type 'function
  :group 'buffers-menu)

(defcustom buffers-menu-sort-function
  'sort-buffers-menu-by-mode-then-alphabetically
  "*If non-nil, a function to sort the list of buffers in the buffers menu.
It will be passed two arguments (two buffers to compare) and should return
t if the first is \"less\" than the second.  One possible value is
`sort-buffers-menu-alphabetically'; another is
`sort-buffers-menu-by-mode-then-alphabetically'."
  :type '(choice (const :tag "None" nil)
		 function)
  :group 'buffers-menu)

(defcustom buffers-menu-grouping-function
  'group-buffers-menu-by-mode-then-alphabetically
  "*If non-nil, a function to group buffers in the buffers menu together.
It will be passed two arguments, successive members of the sorted buffers
list after being passed through `buffers-menu-sort-function'.  It should
return non-nil if the second buffer begins a new group.  The return value
should be the name of the old group, which may be used in hierarchical
buffers menus.  The last invocation of the function contains nil as the
second argument, so that the name of the last group can be determined.

The sensible values of this function are dependent on the value specified
for `buffers-menu-sort-function'."
  :type '(choice (const :tag "None" nil)
		 function)
  :group 'buffers-menu)

(defun sort-buffers-menu-alphabetically (buf1 buf2)
  "For use as a value of `buffers-menu-sort-function'.
Sorts the buffers in alphabetical order by name, but puts buffers beginning
with a star at the end of the list."
  (let* ((nam1 (buffer-name buf1))
	 (nam2 (buffer-name buf2))
	 (inv1p (not (null (string-match "\\` " nam1))))
	 (inv2p (not (null (string-match "\\` " nam2))))
	 (star1p (not (null (string-match "\\`*" nam1))))
	 (star2p (not (null (string-match "\\`*" nam2)))))
    (cond ((not (eq inv1p inv2p))
	   (not inv1p))
	  ((not (eq star1p star2p))
	   (not star1p))
	  (t
	   (string-lessp nam1 nam2)))))

(defun sort-buffers-menu-by-mode-then-alphabetically (buf1 buf2)
  "For use as a value of `buffers-menu-sort-function'.
Sorts first by major mode and then alphabetically by name, but puts buffers
beginning with a star at the end of the list."
  (let* ((nam1 (buffer-name buf1))
	 (nam2 (buffer-name buf2))
	 (inv1p (not (null (string-match "\\` " nam1))))
	 (inv2p (not (null (string-match "\\` " nam2))))
	 (star1p (not (null (string-match "\\`*" nam1))))
	 (star2p (not (null (string-match "\\`*" nam2))))
	 (mode1 (symbol-value-in-buffer 'major-mode buf1))
	 (mode2 (symbol-value-in-buffer 'major-mode buf2)))
    (cond ((not (eq inv1p inv2p))
	   (not inv1p))
	  ((not (eq star1p star2p))
	   (not star1p))
	  ((and star1p star2p (string-lessp nam1 nam2)))
	  ((string-lessp mode1 mode2)
	   t)
	  ((string-lessp mode2 mode1)
	   nil)
	  (t
	   (string-lessp nam1 nam2)))))

;; this version is too slow on some machines.
;; (vintage 1990, that is)
(defun slow-format-buffers-menu-line (buffer n)
  "For use as a value of `buffers-menu-format-buffer-line-function'.
This returns a string containing a bunch of info about the buffer."
  (concat (menu-item-generate-accelerator-spec n buffers-menu-omit-chars-list)
	  (format "%s%s %-19s %6s %-15s %s"
		  (if (buffer-modified-p buffer) "*" " ")
		  (if (symbol-value-in-buffer 'buffer-read-only buffer)
		      "%" " ")
		  (buffer-name buffer)
		  (buffer-size buffer)
		  (symbol-value-in-buffer 'mode-name buffer)
		  (or (buffer-file-name buffer) ""))))

(defun format-buffers-menu-line (buffer n)
  "For use as a value of `buffers-menu-format-buffer-line-function'.
This just returns the buffer's name."
  (concat (menu-item-generate-accelerator-spec n buffers-menu-omit-chars-list)
	  (buffer-name buffer)))

(defun group-buffers-menu-by-mode-then-alphabetically (buf1 buf2)
  "For use as a value of `buffers-menu-grouping-function'.
This groups buffers by major mode.  It only really makes sense if
`buffers-menu-sorting-function' is
`sort-buffers-menu-by-mode-then-alphabetically'."
  (cond ((string-match "\\`*" (buffer-name buf1))
	 (and (null buf2) "*Misc*"))
	((or (null buf2)
	     (string-match "\\`*" (buffer-name buf2))
	     (not (eq (symbol-value-in-buffer 'major-mode buf1)
		      (symbol-value-in-buffer 'major-mode buf2))))
	 (symbol-value-in-buffer 'mode-name buf1))
	(t nil)))

(defun buffer-menu-save-buffer (buffer)
  (save-excursion
    (set-buffer buffer)
    (save-buffer)))

(defun buffer-menu-write-file (buffer)
  (save-excursion
    (set-buffer buffer)
    (write-file (read-file-name
		 (format "Write %s to file: "
			 (buffer-name (current-buffer)))))))

(defsubst build-buffers-menu-internal (buffers)
  (let (name line (n 0))
    (mapcar
     #'(lambda (buffer)
	 (if (eq buffer t)
	     "---"
	   (setq n (1+ n))
	   (setq line
		 ; #### a truly Kyle-friendly hack.
		 (let ((fn buffers-menu-format-buffer-line-function))
		   (if (= (function-max-args fn) 1)
		       (funcall fn buffer)
		     (funcall fn buffer n))))
	   (if complex-buffers-menu-p
	       (delq nil
		     (list line
			   (vector "S%_witch to Buffer"
				   (list buffers-menu-switch-to-buffer-function
					 (setq name (buffer-name buffer)))
				   t)
			   (if (eq buffers-menu-switch-to-buffer-function
				   'switch-to-buffer)
			       (vector "Switch to Buffer, Other %_Frame"
				       (list 'switch-to-buffer-other-frame
					     (setq name (buffer-name buffer)))
				       t)
			     nil)
			   (if (and (buffer-modified-p buffer)
				    (buffer-file-name buffer))
			       (vector "%_Save Buffer"
				       (list 'buffer-menu-save-buffer name) t)
			     ["%_Save Buffer" nil nil]
			     )
			   (vector "Save %_As..."
				   (list 'buffer-menu-write-file name) t)
			   (vector "%_Delete Buffer" (list 'kill-buffer name)
				   t)))
	     ;; #### We don't want buffer names to be translated,
	     ;; #### so we put the buffer name in the suffix.
	     ;; #### Also, avoid losing with non-ASCII buffer names.
	     ;; #### We still lose, however, if complex-buffers-menu-p. --mrb
	     (vector ""
		     (list buffers-menu-switch-to-buffer-function
			   (buffer-name buffer))
		     t line))))
     buffers)))

(defun buffers-menu-filter (menu)
  "This is the menu filter for the top-level buffers \"Buffers\" menu.
It dynamically creates a list of buffers to use as the contents of the menu.
Only the most-recently-used few buffers will be listed on the menu, for
efficiency reasons.  You can control how many buffers will be shown by
setting `buffers-menu-max-size'.  You can control the text of the menu
items by redefining the function `format-buffers-menu-line'."
  (let ((buffers (delete-if buffers-menu-omit-function (buffer-list))))
    (and (integerp buffers-menu-max-size)
	 (> buffers-menu-max-size 1)
	 (> (length buffers) buffers-menu-max-size)
	 ;; shorten list of buffers (not with submenus!)
	 (not (and buffers-menu-grouping-function
		   buffers-menu-submenus-for-groups-p))
	 (setcdr (nthcdr buffers-menu-max-size buffers) nil))
    (if buffers-menu-sort-function
	(setq buffers (sort buffers buffers-menu-sort-function)))
    (if (and buffers-menu-grouping-function
	     buffers-menu-submenus-for-groups-p
	     (or (not (integerp buffers-menu-submenus-for-groups-p))
		 (> (length buffers) buffers-menu-submenus-for-groups-p)))
	(let (groups groupnames current-group)
	  (mapl
	   #'(lambda (sublist)
	       (let ((groupname (funcall buffers-menu-grouping-function
					 (car sublist) (cadr sublist))))
		 (setq current-group (cons (car sublist) current-group))
		 (if groupname
		     (progn
		       (setq groups (cons (nreverse current-group)
					  groups))
		       (setq groupnames (cons groupname groupnames))
		       (setq current-group nil)))))
	   buffers)
	  (setq buffers
		(mapcar*
		 #'(lambda (groupname group)
		     (cons groupname (build-buffers-menu-internal group)))
		 (nreverse groupnames)
		 (nreverse groups))))
      (if buffers-menu-grouping-function
	  (progn
	    (setq buffers
		  (mapcon
		   #'(lambda (sublist)
		       (cond ((funcall buffers-menu-grouping-function
				       (car sublist) (cadr sublist))
			      (list (car sublist) t))
			     (t (list (car sublist)))))
		   buffers))
	    ;; remove a trailing separator.
	    (and (>= (length buffers) 2)
		 (let ((lastcdr (nthcdr (- (length buffers) 2) buffers)))
		   (if (eq t (cadr lastcdr))
		       (setcdr lastcdr nil))))))
      (setq buffers (build-buffers-menu-internal buffers)))
    (append menu buffers)
    ))

(defun language-environment-menu-filter (menu)
  "This is the menu filter for the \"Language Environment\" submenu."
  (declare (special language-environment-list))
  (let ((n 0))
    (mapcar (lambda (env-sym)
	      (setq n (1+ n))
	      `[ ,(concat (menu-item-generate-accelerator-spec n)
			  (capitalize (symbol-name env-sym)))
		 (set-language-environment ',env-sym)])
	    language-environment-list)))


;;; The Options menu

;; We'll keep those variables here for a while, in order to provide a
;; function for porting the old options file that a user may own to Custom.

(defvar options-save-faces nil
  "*Non-nil value means save-options will save information about faces.
A nil value means save-options will not save face information.
Set this non-nil only if you use M-x edit-faces to change face
settings.  If you use M-x customize-face or the \"Browse Faces...\"
menu entry, you will see a button in the Customize Face buffer that you
can use to permanently save your face changes.

M-x edit-faces is deprecated.  Support for it and this variable will
be discontinued in a future release.")

(defvar save-options-init-file nil
  "File into which to save forms to load the options file (nil for .emacs).
Normally this is nil, which means save into your .emacs file (the value
of `user-init-file'.")

(defvar save-options-file ".xemacs-options"
  "File to save options into.
This file is loaded from your .emacs file.
If this is a relative filename, it is put into the same directory as your
.emacs file.")



;;; The Help menu

(defun tutorials-menu-filter (menu-items)
  (declare (special language-info-alist
		    current-language-environment
		    tutorial-supported-languages))
  (append
   (if (featurep 'mule)
       (if (assq 'tutorial
		 (assoc current-language-environment language-info-alist))
	   `([,(concat "%_Default (" current-language-environment ")")
	      help-with-tutorial]))
     '(["%_English" help-with-tutorial]))
   (submenu-generate-accelerator-spec
    (if (featurep 'mule)
	;; Mule tutorials.
	(mapcan #'(lambda (lang)
		    (let ((tut (assq 'tutorial lang)))
		      (and tut
			   (not (string= (car lang) "ASCII"))
			   ;; skip current language, since we already
			   ;; included it first
			   (not (string= (car lang)
					 current-language-environment))
			   `([,(car lang)
			      (help-with-tutorial nil ,(cdr tut))]))))
		language-info-alist)
      ;; Non mule tutorials.
      (mapcar #'(lambda (lang)
		  `[,(car lang)
		    (help-with-tutorial ,(format "TUTORIAL.%s"
						 (cadr lang)))])
	      tutorial-supported-languages)))))

(set-menubar default-menubar)


;;; Popup menus.

(defconst default-popup-menu
  '("XEmacs Commands"
    ["%_Undo" advertised-undo
     :active (and (not (eq buffer-undo-list t))
		  (or buffer-undo-list pending-undo-list))
     :suffix (if (or (eq last-command 'undo)
		     (eq last-command 'advertised-undo))
		 "More" "")]
    ["Cu%_t" kill-primary-selection
     :active (selection-owner-p)]
    ["%_Copy" copy-primary-selection
     :active (selection-owner-p)]
    ["%_Paste" yank-clipboard-selection
     :active (selection-exists-p 'CLIPBOARD)]
    ["%_Delete" delete-primary-selection
     :active (selection-owner-p)]
    "-----"
    ["Select %_Block" mark-paragraph]
    ["Sp%_lit Window" split-window-vertically]
    ["U%_nsplit Window" delete-other-windows]
    ))

;; In an effort to avoid massive menu clutter, this mostly worthless menu is
;; superseded by any local popup menu...
(setq-default mode-popup-menu default-popup-menu)


;; misc

(defun xemacs-splash-buffer ()
  "Redisplay XEmacs splash screen in a buffer."
  (interactive)
  (let ((buffer (get-buffer-create "*Splash*"))
	tmout)
    (set-buffer buffer)
    (setq buffer-read-only t)
    (erase-buffer buffer)
    (setq tmout (display-splash-frame))
    (when tmout
      (make-local-hook 'kill-buffer-hook)
      (add-hook 'kill-buffer-hook
		`(lambda ()
		   (disable-timeout ,tmout))
		nil t))
    (pop-to-buffer buffer)
    (delete-other-windows)))


;;; backwards compatibility
(provide 'x-menubar)
(provide 'menubar-items)

;;; menubar-items.el ends here.