Pistos (owner)

Revisions

gist: 142412 Download_button fork
public
Description:
Diff of Diakonos from 0.8.10 to 0.8.11
Public Clone URL: git://gist.github.com/142412.git
Embed All Files: show embed
Diff #
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
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
diff --git a/CHANGELOG b/CHANGELOG
index 335e9b9..de6228d 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,8 +1,22 @@
 Diakonos Changelog
 ------------------
 
+0.8.11
+
+Contributors: Pistos, dominikh
+
+- Added join_lines_upward (Alt-Shift-J).
+- Added one-key selection in buffer list.
+- Added support for single line indentation.
+- Added extension system.
+- Added surround_selection and related functions.
+- Added "about" page.
+- Various bug fixes and refactorings.
+
 0.8.10
 
+Contributors: Pistos, dominikh
+
 - Ruby version 1.9+ now required. (Ruby 1.8 support dropped)
 - Added go_to_char (Alt-N).
 - Added go_to_char_previous (Alt-P).
@@ -23,6 +37,8 @@ Diakonos Changelog
 
 0.8.9
 
+Contributors: Pistos, Decklin Foster
+
 - Put interaction timer only on first stale session prompt, not any after that.
 - Changed all function names from camelCase to snake_case.
 - Added --help-dir switch to installer.
@@ -31,7 +47,6 @@ Diakonos Changelog
 - Fixed a line number display bug.
 - X windows pasting handled much better now.
 - Numerous internal refactorings and reorganizations.
-- Accepted patches from Decklin Foster.
 
 0.8.8
 
diff --git a/LICENSE b/LICENSE
new file mode 120000
index 0000000..97ea633
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1 @@
+LICENCE
\ No newline at end of file
diff --git a/README b/README
index 094da0e..6a2b021 100644
--- a/README
+++ b/README
@@ -1,9 +1,6 @@
-Diakonos
+= Diakonos
 
-========
-
-REQUIREMENTS
-============
+== REQUIREMENTS
 
 - Ruby 1.9+
 
@@ -11,8 +8,7 @@ Diakonos is built to run on Linux, but may run under other flavours of UNIX.
 It is known NOT to work under Windows (unless using Cygwin).
 
 
-DOWNLOAD
-========
+== DOWNLOAD
 
 The latest stable tarballs can be acquired from
 
@@ -23,8 +19,7 @@ The latest development code can be obtained from github:
   git clone git://github.com/Pistos/diakonos.git
 
 
-INSTALLATION
-============
+== INSTALLATION
 
 ruby install.rb --help
 ruby install.rb [installation parameters]
@@ -34,14 +29,12 @@ places like /usr . However, Diakonos runs perfectly well in userspace, such
 as under ~/usr .
 
 
-UNINSTALLATION
-==============
+== UNINSTALLATION
 
   diakonos --uninstall
 
 
-USAGE
-=====
+== USAGE
 
 Run with any of these:
 
@@ -61,8 +54,9 @@ use the interactive help system.
 
 The source code repository is at http://github.com/Pistos/diakonos/tree/master .
 
-Send comments, feedback and tech support requests to
-irc.freenode.net:6667#mathetes or http://linis.purepistos.net .
+Send comments, feedback and tech support requests to the #mathetes channel on
+the FreeNode IRC network ( http://webchat.freenode.net/?channels=mathetes ),
+or http://linis.purepistos.net .
 
 Pistos
 http://purepistos.net/diakonos
diff --git a/diakonos.conf b/diakonos.conf
index 78d075c..0c18453 100644
--- a/diakonos.conf
+++ b/diakonos.conf
@@ -116,7 +116,7 @@ fuzzy_file_find false
 
 # Use "% syntax" as placeholders
 # e.g. %d for decimal integers, %s for strings
-status.left -- %s %s%s%s%s -- (%s) --%s
+status.left -- %s %s%s%s%s -- (%s) --
 status.right - %s Buf %d of %d --- L%3d/%3d C%2d --
 # The string to use to fill in the space between the left and right sides
 # of the status line.
@@ -127,8 +127,7 @@ status.unnamed_str (unnamed file)
 status.read_only_str (read-only)
 # status.vars: any subset of:
 # line row num_lines col filename modified type buffer_number num_buffers selecting selection_mode session_name read_only
-status.vars filename modified read_only selecting selection_mode type @git_branch session_name buffer_number num_buffers row num_lines col
-#status.vars filename modified read_only selecting selection_mode type @git_branch buffer_number num_buffers row num_lines col
+status.vars filename modified read_only selecting selection_mode type session_name buffer_number num_buffers row num_lines col
 status.format inverse
 
 # ---------------------------------------------------------------------
@@ -285,7 +284,8 @@ key keycode353 unindent
 #key tab insertSpaces 4
 #key tab insertTab
 key ctrl+t insertTab
-key alt+j joinLines
+key alt+j join_lines
+key esc J join_lines_upward
 
 key f1 help
 key esc O P help
@@ -294,8 +294,8 @@ key esc [ [ A help
 key f13 help
 key esc O 2 P help
 key esc O 1 ; 2 P help
-key f11 loadConfiguration
-key esc [ 2 3 ~ loadConfiguration
+key f11 about
+key esc [ 2 3 ~ about
 key f12 openFile "~/.diakonos/diakonos.conf"
 key esc [ 2 4 ~ openFile "~/.diakonos/diakonos.conf"
 # Option-F12 in OSX
@@ -410,7 +410,6 @@ key esc [ 1 ; 2 evaluate
 key ctrl+alt+c shell "ruby -c $f"
 #key f10 spawn "firefox --display=:0 http://apidock.com/ruby/$i"
 #key f10 spawn "DISPLAY=:0 opera --remote 'openURL(http://www.ruby-doc.org/core-1.9/classes/$i.html,new-page)' 2>&1 > /dev/null"
-key f9 shell "cd $d; git diff --ignore-space-change -- $f", 'git.diff'
 
 # To use the following:
 # 1) Copy to the clipboard some Ruby code which operates on stdin text and outputs to stdout.
@@ -479,6 +478,21 @@ lang.all.tokens.conflict_theirs ^>>>>>>>.*
 lang.all.tokens.conflict_theirs.format 15 bold
 lang.all.tokens.conflict_separator ^=======$
 lang.all.tokens.conflict_separator.format 9 bold
+# lang.all.tokens.trailing_whitespace (\s+$)
+# lang.all.tokens.trailing_whitespace.format 9
+lang.all.surround.pair "(" "( " " )"
+lang.all.surround.pair ")" "(" ")"
+lang.all.surround.pair "{" "{ " " }"
+lang.all.surround.pair "}" "{" "}"
+lang.all.surround.pair "[" "[ " " ]"
+lang.all.surround.pair "]" "[" "]"
+lang.all.surround.pair "<" "< " " >"
+lang.all.surround.pair ">" "<" ">"
+lang.all.surround.pair "'" "'" "'"
+lang.all.surround.pair "\"" "\"" "\""
+lang.all.surround.pair "/*" "/*" "*/"
+
+
 
 # Inherited by several languages
 
@@ -528,6 +542,7 @@ lang.dhf.indent.auto true
 lang.dhf.indent.roundup true
 lang.dhf.wrap_margin 80
 
+
 # XML
 
 lang.xml.filemask \.(xml|xsl|rdl|aiml)$
@@ -581,6 +596,8 @@ lang.xml_comment.indent.size 2
 lang.xml_comment.indent.auto true
 lang.xml_comment.indent.roundup true
 #lang.xml_comment.indent.using_tabs true
+lang.xml.surround.pair "<!--" "<!-- " " -->"
+lang.xml.surround.pair "/^<(.+?)>$/" "<\1>" "</\1>"
 
 lang.html.filemask \.([rx]?html?|php|asp|erb)$
 lang.html.format.default white
@@ -649,6 +666,8 @@ lang.html_comment.indent.size 4
 lang.html_comment.indent.auto true
 lang.html_comment.indent.roundup true
 #lang.html_comment.indent.using_tabs true
+lang.html.surround.pair "<!--" "<!-- " " -->"
+lang.html.surround.pair "/^<(.+?)>$/" "<\1>" "</\1>"
 
 # CSS
 
@@ -761,6 +780,7 @@ lang.ruby.indent.ignore ^\s*$
 lang.ruby.context.ignore ^=(begin|end)$
 lang.ruby.column_delimiters =>?|:|,
 
+
 # PHP
 
 lang.php.filemask \.php\d?$
@@ -851,6 +871,7 @@ lang.perl.indent.ignore ^\s*$
 lang.perl.context.ignore ^(.+:|\s*\{?)$
 lang.perl.column_delimiters =>?|:|,
 
+
 # Python
 
 lang.python.filemask \.py$
@@ -949,6 +970,7 @@ lang.c.indent.size 4
 lang.c.indent.auto true
 lang.c.indent.roundup false
 #lang.c.indent.using_tabs true
+lang.c.indent.indenters_next_line (if\s*\(.+?\)\s*[^{]?$)
 lang.c.indent.indenters (case|[{\[(]$)
 lang.c.indent.unindenters (case|^\s+[\]})])
 lang.c.indent.preventers (\".+?[^\\]\")|('.+?[^\\]')|(\/\/.*)
@@ -1114,7 +1136,6 @@ lang.diff.tokens.diff_command (^diff .+$)
 lang.diff.tokens.diff_command.format 13 bold
 
 lang.yaml.filemask (?:\.ya?ml)$
-lang.yaml.bangmask ^---(?:.[^/]|$)
 lang.yaml.format.default white bold
 lang.yaml.format.selection inverse
 lang.yaml.format.found yellow inverse
@@ -1357,7 +1378,6 @@ lang.haskell.indent.ignore ^\s*$
 # lang.haskell.context.ignore ^=(begin|end)$
 lang.haskell.column_delimiters =>?|:|,
 
-
 # Custom configuration files can be included.
 # If a setting is specified again, it overrides the previous setting given
 # higher up in the configuration file(s).
diff --git a/diakonos.gemspec b/diakonos.gemspec
index 1bd2c18..481f5fd 100755
--- a/diakonos.gemspec
+++ b/diakonos.gemspec
@@ -4,7 +4,7 @@ require 'rubygems'
 
 spec = Gem::Specification.new do |s|
     s.name = 'diakonos'
- s.version = '0.8.10'
+ s.version = '0.8.11'
     s.summary = 'A usable console-based text editor.'
     s.description = 'Diakonos is a customizable, usable console-based text editor.'
     s.homepage = 'http://purepistos.net/diakonos'
@@ -24,11 +24,11 @@ Dear RubyGems administrator:
 As of version 0.8.8, Diakonos is no longer installed via RubyGems. You may
 find that a Diakonos package is already available for your operating system's
 package manager. There are packages for: Ubuntu, Debian, Gentoo, Arch Linux,
-Slackware, and Sourcemage.
+Slackware, Sourcemage, and possibly more.
 
 If there is no package for your system, you can install Diakonos manually:
 
-- Uninstall any previously installed diakonos gems
+- Uninstall any previously installed diakonos gems (including this one)
 - Acquire a tarball from http://purepistos.net/diakonos
 - Unpack the tarball
 - ruby install.rb --help
diff --git a/extensions/dk-hello-world/hello-world.conf b/extensions/dk-hello-world/hello-world.conf
new file mode 100644
index 0000000..4333a74
--- /dev/null
+++ b/extensions/dk-hello-world/hello-world.conf
@@ -0,0 +1 @@
+key f23 hello_world
diff --git a/extensions/dk-hello-world/hello-world.rb b/extensions/dk-hello-world/hello-world.rb
new file mode 100644
index 0000000..d966ebc
--- /dev/null
+++ b/extensions/dk-hello-world/hello-world.rb
@@ -0,0 +1,9 @@
+module Diakonos
+ module Functions
+
+ def hello_world
+ @current_buffer.paste "Hello, world!"
+ end
+
+ end
+end
\ No newline at end of file
diff --git a/extensions/dk-hello-world/info.yaml b/extensions/dk-hello-world/info.yaml
new file mode 100644
index 0000000..63f7673
--- /dev/null
+++ b/extensions/dk-hello-world/info.yaml
@@ -0,0 +1,31 @@
+name: Hello World
+description: An example of a Diakonos extension
+author:
+ name: Pistos
+ email: somebody@example.com
+ uri: http://blog.purepistos.net
+version: 1.0.0
+uris:
+ homepage: http://github.com/Pistos/diakonos/tree/master/extensions/dk-hello-world
+ repository: git://github.com/Pistos/diakonos.git
+licence: MIT
+requirements:
+ diakonos:
+ minimum: 0.8.11
+ tested:
+ - 0.8.11
+ gems:
+ # - gemname:
+ # minimum: 1.0.0
+ # tested:
+ # - 1.0.0
+ # - 1.1.0
+ # - gemname:
+ # minimum: 1.0.0
+ # tested:
+ # - 1.0.0
+ # - 1.1.0
+notes: >
+ This extension adds a hello_world function to Diakonos.
+
+ Pressing Shift-F11 will activate the function.
diff --git a/help/config.dhf b/help/config.dhf
index d0a806e..4a1a46b 100644
--- a/help/config.dhf
+++ b/help/config.dhf
@@ -42,9 +42,11 @@ include ~/.diakonos/extra.conf
 
 If a setting is specified again (whether in the same file, or an included
 file), it overrides the previous setting given higher up in the configuration
-file(s). Note that editing and saving custom configuration files will not
-cause the changes to be automatically loaded like they are with the default
-configuration file. To reload all configuration files, press <F11>.
+file(s). Note that editing and saving custom configuration files which reside
+outside of ~/.diakonos will not cause the changes to be automatically loaded
+like they are with configuration files in ~/.diakonos. To reload all
+configuration files, quit and restart Diakonos, or press <Shift-F2> and type
+"load_configuration".
 
 ## Configuration inheritance
 
diff --git a/help/extensions.dhf b/help/extensions.dhf
new file mode 100644
index 0000000..f4f659d
--- /dev/null
+++ b/help/extensions.dhf
@@ -0,0 +1,124 @@
+# Extending Diakonos
+
+Diakonos has a simple but powerful extension system. Extensions are written in
+Ruby (http://www.ruby-lang.org).
+
+
+## Installing and Uninstalling Extensions
+
+### Unpack/Clone
+
+Extensions are installed in ~/.diakonos/extensions/. Each extension should
+have its own subdirectory under there. Extension tarballs or repository clones
+should be unpacked or cloned under there.
+
+### Load
+
+Once an extension is installed into ~/.diakonos/extensions/, you activate it
+by adding a command to your configuration:
+
+ load_extension name_of_the_extension
+
+Diakonos will load extensions at startup, and will reload extensions whenever
+the Diakonos configuration is updated.
+
+### Unload
+
+To deactivate an extension, simply remove (or comment out) all load_extension
+directives from your configuration which load the extension.
+
+### Uninstall
+
+Extensions can be removed cleanly by deleting the extension's subdirectory out
+of ~/.diakonos/extensions/.
+
+
+## Extension Format
+
+### Directory Structure
+
+A Diakonos extension consists of a directory (or directory tree) of files:
+
+ info.yaml
+ *.conf
+ *.rb
+
+The simplest extension will have nothing but an info.yaml file. This "empty"
+extension will do nothing useful, though, of course.
+
+Diakonos will parse and load all configuration files (*.conf) in the root of
+the extension's directory. All Ruby files (*.rb) found in the extension's
+directory, or any subdirectory underneath it, are loaded and executed at
+startup, and on configuration change. Typically, an extension will only have
+one configuration file, but it may have any number of Ruby files.
+
+### Information File
+
+To be valid, an extension must have a properly-formatted info.yaml file. As
+the filename suggests, info.yaml is a YAML file. It consists of several keys,
+and a few arrays, described below.
+
+The diakonos key is required. It is strongly recommended to have name, uris
+and version keys. The other keys are optional.
+
+name: (recommended) The name of the extension.
+
+description: (optional) A brief, one-line description of the extension.
+
+author: (optional) Several subkeys provide information about the extension's author.
+ name: The author's name or nickname.
+ email: The author's email address.
+ uri: A URI associated with the author. This might be a homepage, or a blog.
+
+version: (recommended) The version of the extension.
+
+uris: (recommended)
+ homepage: The website giving more information about the extension.
+ repository: The URI of the extension's source code repository. This should
+ be a URI that can be used with version control software, and so might
+ begin with "svn://" or "git://".
+
+licence: (optional) The licence of the extension's source code.
+
+requirements: (required) Several subkeys tell diakonos about what versions of
+ things the extension works with.
+ diakonos: (required) Several subkeys tell Diakonos about what versions of
+ Diakonos the extension works with.
+ minimum: The minimum version of Diakonos required for the extension to
+ function properly.
+ tested: A list of Diakonos versions which the extension is known to run
+ under.
+ gems: (optional) If the extension needs any gems to function, they should be
+ listed here, with their minimum and tested versions given.
+
+notes: (optional) Longer text describing the extension, its capabilities and
+ its usage. For multiple paragraphs, use the YAML syntax "notes: >", and
+ indent the paragraphs to the same level.
+
+
+## Extension Code
+
+Extension code is any valid Ruby code. See http://purepistos.net/diakonos/rdoc/
+for source code documentation for Diakonos, and
+http://github.com/Pistos/diakonos/tree/master/extensions/dk-hello-world for an
+example of an extension.
+
+To have code execute on keypress, define a method in the Diakonos::Functions
+module. All methods in Diakonos::Functions are exposed to the keying system,
+any method name can be referred to by the key directive in configuration files.
+
+Methods of Diakonos::Functions are run within the context of the main
+::Diakonos::Diakonos object. In this context, you get access to all of the
+instance variables. Some variables of note:
+
+ @current_buffer
+ @diakonos_home String containing the user's Diakonos dir (usually ~/.diakonos)
+ @buffers A BufferHash holding all the open buffers
+ @status_vars
+ @settings A Hash containing all settings from all configuration files
+
+When not within a method of Diakonos::Functions, main ::Diakonos::Diakonos
+object can be referred to by using the global variable $diakonos.
+
+
+Tags: script scripts scripting program programming language ruby extend extension extensions plugin plug-in plugins plug-ins addon addons add-on add-ons package packages format layout structure load loading unload unloading activate deactivate activating deactivating install installing installation
diff --git a/help/scripting.dhf b/help/scripting.dhf
index bb4a3df..d4fada6 100644
--- a/help/scripting.dhf
+++ b/help/scripting.dhf
@@ -28,7 +28,7 @@ Press <F7> to iterate over each line of selected text. You will be prompted
 for Ruby code which will act as the body of a Ruby block which uses the
 variable "line" and evaluates to a String. For example:
 
- line.strip.squeeze( ' ' )
+ line.strip.squeeze( ' ' )
 
 will strip off whitespace from the beginning and end of each line and then
 collapse all consecutive sequences of spaces into single spaces.
@@ -40,12 +40,12 @@ will be prompted for Ruby code which operates on the array variable "lines".
 For example:
 
   lines.find_all { |l| /foo/ === l }
-
+
 will replace the selected lines with the lines that match the regular expression
 /foo/.
 
   lines.sort
-
+
 will sort the selected lines.
 
 ## Startup Scripts
@@ -61,6 +61,8 @@ to initiate a search on startup:
 
   diakonos -e 'find "down", CASE_SENSITIVE, "search expression"' filename
 
+See also the documentation on extensions.
+
 ## Hooks
 
 Diakonos provides a means for you to execute arbitrary Ruby code when certain
diff --git a/help/support.dhf b/help/support.dhf
index f7ec347..fabf86f 100644
--- a/help/support.dhf
+++ b/help/support.dhf
@@ -2,9 +2,9 @@
 
 You can chat about Diakonos in the #mathetes channel of the FreeNode IRC
 network. If you don't have an IRC client, or don't know what IRC is, you can
-direct your web browser to
+direct your web browser to
 
- http://mibbit.com/?server=irc.freenode.net&channel=%23mathetes
+ http://webchat.freenode.net/?channels=mathetes
 
 Go to the IRC channel for technical support, or to give feedback and commentary
 about Diakonos. It's the place go for bug reports, feature requests and tech
diff --git a/help/welcome.dhf b/help/welcome.dhf
index 9056ae2..f2a6496 100644
--- a/help/welcome.dhf
+++ b/help/welcome.dhf
@@ -7,7 +7,7 @@ I have crafted Diakonos with ease of use in mind, so I hope you find it the
 most easy-to-use console text editor available for Linux. If you have any
 suggestions, questions or comments, please share your thoughts in the #mathetes
 channel of the FreeNode IRC network
-( http://mibbit.com/?server=irc.freenode.net&channel=%23mathetes ).
+( http://webchat.freenode.net/?channels=mathetes ).
 
 ## Getting Started
 
@@ -30,4 +30,4 @@ save your change.
 
 
 
-Tags: diakonos welcome intro introduction getting started starting new newb newbie remove message
\ No newline at end of file
+Tags: diakonos welcome intro introduction getting started starting new newb newbie remove message
diff --git a/lib/diakonos.rb b/lib/diakonos.rb
index 8aecbdb..98613ce 100755
--- a/lib/diakonos.rb
+++ b/lib/diakonos.rb
@@ -34,6 +34,9 @@ require 'diakonos/sized-array'
 
 require 'diakonos/version'
 require 'diakonos/installation'
+
+require 'diakonos/about'
+require 'diakonos/buffer-management'
 require 'diakonos/config'
 require 'diakonos/functions'
 require 'diakonos/functions/basics'
@@ -53,14 +56,13 @@ require 'diakonos/functions-deprecated'
 require 'diakonos/help'
 require 'diakonos/display'
 require 'diakonos/display/format'
-require 'diakonos/interaction'
+require 'diakonos/grep'
 require 'diakonos/hooks'
+require 'diakonos/interaction'
 require 'diakonos/keying'
 require 'diakonos/logging'
 require 'diakonos/list'
-require 'diakonos/buffer-management'
 require 'diakonos/sessions'
-require 'diakonos/grep'
 
 require 'diakonos/text-mark'
 require 'diakonos/bookmark'
@@ -79,6 +81,8 @@ require 'diakonos/buffer/undo'
 require 'diakonos/clipboard'
 require 'diakonos/clipboard-klipper'
 require 'diakonos/clipboard-xclip'
+require 'diakonos/extension'
+require 'diakonos/extension-set'
 require 'diakonos/readline'
 
 require 'diakonos/vendor/fuzzy_file_finder'
@@ -110,7 +114,7 @@ module Diakonos
   class Diakonos
 
     attr_reader :diakonos_home, :script_dir, :clipboard,
- :list_filename, :hooks, :indenters, :unindenters, :closers,
+ :list_filename, :hooks, :indenters, :indenters_next_line, :unindenters, :closers,
       :last_commands, :there_was_non_movement, :do_display, :testing
 
     include ::Diakonos::Functions
@@ -120,6 +124,7 @@ module Diakonos
       mkdir @diakonos_home
       @script_dir = "#{@diakonos_home}/scripts"
       mkdir @script_dir
+ @extensions = ExtensionSet.new( File.join( @diakonos_home, 'extensions' ) )
       initialize_session
 
       @files = Array.new
@@ -129,11 +134,12 @@ module Diakonos
 
       init_help
 
- @debug = File.new( "#{@diakonos_home}/debug.log", 'w' )
- @list_filename = @diakonos_home + '/listing.txt'
- @diff_filename = @diakonos_home + '/text.diff'
- @help_filename = "#{@help_dir}/about-help.dhf"
- @error_filename = "#{@diakonos_home}/diakonos.err"
+ @debug = File.new( File.join( @diakonos_home, 'debug.log' ), 'w' )
+ @list_filename = File.join( @diakonos_home, 'listing.txt' )
+ @diff_filename = File.join( @diakonos_home, 'text.diff' )
+ @help_filename = File.join( @help_dir, 'about-help.dhf' )
+ @error_filename = File.join( @diakonos_home, 'diakonos.err' )
+ @about_filename = File.join( @diakonos_home, 'about.dhf' )
 
       @win_main = nil
       @win_context = nil
@@ -284,7 +290,9 @@ module Diakonos
       session_buffers = session_startup
       session_buffer_number = @session[ 'current_buffer' ] || 1
 
- Dir[ "#{@script_dir}/*" ].each do |script|
+ scripts = @extensions.scripts + Dir[ "#{@script_dir}/*" ]
+ debug_log "scripts: #{scripts.inspect}"
+ scripts.each do |script|
         begin
           require script
         rescue Exception => e
@@ -297,6 +305,7 @@ module Diakonos
           )
         end
       end
+
       @hooks.each do |hook_name, hook|
         hook.sort { |a,b| a[ :priority ] <=> b[ :priority ] }
       end
diff --git a/lib/diakonos/about.rb b/lib/diakonos/about.rb
new file mode 100644
index 0000000..97ebca9
--- /dev/null
+++ b/lib/diakonos/about.rb
@@ -0,0 +1,55 @@
+module Diakonos
+ class Diakonos
+
+ def about_write
+ File.open( @about_filename, "w" ) do |f|
+ inst = ::Diakonos::INSTALL_SETTINGS
+
+ ext_loaded = @extensions.loaded_extensions.sort_by { |e|
+ e.name.downcase
+ }.map { |e|
+ %{
+### #{e.name} #{e.version}
+#{e.description}
+ }.strip
+ }.join( "\n\n" )
+
+ ext_not_loaded = @extensions.not_loaded_extensions.sort.map { |e|
+ "### #{e} (NOT LOADED)"
+ }.join( "\n" )
+
+ f.puts %{
+# About Diakonos
+
+Licence: MIT Licence
+Copyright: Copyright (c) 2004-#{ Time.now.year } Pistos
+
+## Version
+
+Version: #{ ::Diakonos::VERSION }
+Code Date: #{ ::Diakonos::LAST_MODIFIED }
+Install Time: #{ File.mtime( File.join( inst[ :lib_dir ], 'diakonos', 'installation.rb' ) ) }
+
+## Paths
+
+Home dir: #{ @diakonos_home }
+
+### Installation
+
+Prefix: #{ inst[ :prefix ] }
+Executable dir: #{ inst[ :bin_dir ] }
+Help dir: #{ inst[ :help_dir ] }
+System config dir: #{ inst[ :conf_dir ] }
+System library dir: #{ inst[ :lib_dir ] }
+
+## Extensions
+
+#{ ext_loaded }
+
+#{ ext_not_loaded }
+ }.strip
+ end
+ end
+
+ end
+end
\ No newline at end of file
diff --git a/lib/diakonos/buffer.rb b/lib/diakonos/buffer.rb
index 034a987..e7d3401 100644
--- a/lib/diakonos/buffer.rb
+++ b/lib/diakonos/buffer.rb
@@ -122,10 +122,12 @@ module Diakonos
     def set_language( language )
       @settings = @diakonos.settings
       @language = language
+ @surround_pairs = @diakonos.surround_pairs[ 'all' ].merge( @diakonos.surround_pairs[ @language ] || Hash.new )
       @token_regexps = @diakonos.token_regexps[ 'all' ].merge( @diakonos.token_regexps[ @language ] || Hash.new )
       @close_token_regexps = @diakonos.close_token_regexps[ 'all' ].merge( @diakonos.close_token_regexps[ @language ] || Hash.new )
       @token_formats = @diakonos.token_formats[ 'all' ].merge( @diakonos.token_formats[ @language ] || Hash.new )
       @indenters = @diakonos.indenters[ @language ]
+ @indenters_next_line = @diakonos.indenters_next_line[ @language ]
       @unindenters = @diakonos.unindenters[ @language ]
       @preventers = @settings[ "lang.#{@language}.indent.preventers" ]
       @closers = @diakonos.closers[ @language ] || Hash.new
@@ -191,9 +193,52 @@ module Diakonos
       set_modified
     end
 
+ def surround( text, parenthesis )
+ pattern, pair = @surround_pairs.select { |r, p| parenthesis =~ r }.to_a[ 0 ]
+
+ if pair.nil?
+ $diakonos.set_iline "No matching parentheses pair found."
+ nil
+ else
+ pair.map! do |paren|
+ parenthesis.gsub( pattern, paren )
+ end
+ pair[ 0 ] + text.join( "\n" ) + pair[ 1 ]
+ end
+ end
+
+ def join_lines_upward( row = @last_row, strip = DONT_STRIP_LINE )
+ return false if row == 0
+
+ take_snapshot
+
+ line = @lines.delete_at( row )
+ old_line = @lines[ row-1 ]
+
+ new_x_pos = old_line.length
+
+ if strip
+ line.strip!
+
+ # Only prepend a space if the line above isn't empty.
+ if ! old_line.strip.empty?
+ line = ' ' + line
+ new_x_pos += 1
+ end
+ end
+
+ @lines[ row-1 ] << line
+
+ cursor_to( row-1, new_x_pos )
+
+ set_modified
+ end
+
     def join_lines( row = @last_row, strip = DONT_STRIP_LINE )
       take_snapshot( TYPING )
       next_line = @lines.delete_at( row + 1 )
+ return false if next_line.nil?
+
       if strip
         next_line = ' ' + next_line.strip
       end
@@ -503,17 +548,26 @@ module Diakonos
     end
 
     def word_under_cursor
- word = nil
+ pos = word_under_cursor_pos
+ return if pos.nil?
+
+ col1 = pos[ 0 ][ 1 ]
+ col2 = pos[ 1 ][ 1 ]
+ @lines[ @last_row ][ col1..col2 ]
+ end
 
+ def word_under_cursor_pos
       @lines[ @last_row ].scan( WORD_REGEXP ) do |match_text|
         last_match = Regexp.last_match
- if last_match.begin( 0 ) <= @last_col and @last_col < last_match.end( 0 )
- word = match_text
- break
+ if last_match.begin( 0 ) <= @last_col && @last_col < last_match.end( 0 )
+ return [
+ [ @last_row, last_match.begin( 0 ) ],
+ [ @last_row, last_match.end( 0 ) - 1 ],
+ ]
         end
       end
 
- word
+ nil
     end
 
     def word_before_cursor
@@ -529,6 +583,49 @@ module Diakonos
 
       word
     end
+ # TODO word_before_cursor_pos
+
+ # Returns an array of lines of the current paragraph.
+ def paragraph_under_cursor
+ ( first, _ ), ( last, _ ) = paragraph_under_cursor_pos
+ @lines[ first..last ]
+ end
+
+ # Returns the coordinates of the first and last line of the current
+ # paragraph.
+ def paragraph_under_cursor_pos
+ if @lines[ @last_row ] =~ /^\s*$/
+ return [
+ [ @last_row, 0 ],
+ [ @last_row, @lines[ @last_row ].length - 1 ]
+ ]
+ end
+
+ upper_boundary = 0
+ lower_boundary = @lines.size - 1
+
+ @last_row.downto( 0 ) do |i|
+ line = @lines[ i ]
+ if line =~ /^\s*$/
+ upper_boundary = i + 1
+ break
+ end
+ end
+
+ @last_row.upto( @lines.size - 1 ) do |i|
+ line = @lines[ i ]
+ if line =~ /^\s*$/
+ lower_boundary = i - 1
+ break
+ end
+ end
+
+ [
+ [ upper_boundary, 0 ],
+ [ lower_boundary, @lines[ lower_boundary ].length - 1 ]
+ ]
+ end
+ # TODO paragraph_before_cursor(_pos)?
 
     def words( filter_regexp = nil )
       w = @lines.join( ' ' ).scan( WORD_REGEXP )
diff --git a/lib/diakonos/buffer/indentation.rb b/lib/diakonos/buffer/indentation.rb
index 4c072f0..6030b8a 100644
--- a/lib/diakonos/buffer/indentation.rb
+++ b/lib/diakonos/buffer/indentation.rb
@@ -6,8 +6,7 @@ module Diakonos
       delta = 0
       line = @lines[ row ]
       for i in 0...col
- # One comparison for Ruby 1.9, the other for 1.8.
- if line[ i ] == "\t" || line[ i ] == TAB
+ if line[ i ] == "\t"
           delta += ( @tab_size - ( (i+delta) % @tab_size ) ) - 1
         end
       end
@@ -87,6 +86,10 @@ module Diakonos
           level = 0
         else
           prev_line = @lines[ row - i ]
+ second_prev_line = ''
+ if ! ( ( row - i - i ) < 0 )
+ second_prev_line = @lines[ row - i - 1 ]
+ end
           level = indentation_level( row - i )
 
           line = @lines[ row ]
@@ -96,14 +99,18 @@ module Diakonos
           end
 
           indenter_index = ( prev_line =~ @indenters )
- if indenter_index
+
+ if prev_line =~ @indenters_next_line
+ level += 1
+ elsif indenter_index
             level += 1
             unindenter_index = (prev_line =~ @unindenters)
             if unindenter_index and unindenter_index != indenter_index
               level += -1
             end
           end
- if line =~ @unindenters
+
+ if line =~ @unindenters || second_prev_line =~ @indenters_next_line
             level += -1
           end
         end
@@ -124,4 +131,4 @@ module Diakonos
 
   end
 
-end
\ No newline at end of file
+end
diff --git a/lib/diakonos/config.rb b/lib/diakonos/config.rb
index c591c16..5b8385b 100644
--- a/lib/diakonos/config.rb
+++ b/lib/diakonos/config.rb
@@ -11,7 +11,7 @@ module Diakonos
   EOL_ALT_LAST_CHAR = 3
 
   class Diakonos
- attr_reader :token_regexps, :close_token_regexps, :token_formats, :diakonos_conf, :column_markers
+ attr_reader :token_regexps, :close_token_regexps, :token_formats, :diakonos_conf, :column_markers, :surround_pairs
 
     def fetch_conf( location = "v#{VERSION}" )
       require 'open-uri'
@@ -87,10 +87,12 @@ module Diakonos
       @token_formats = Hash.new { |h,k| h[ k ] = Hash.new }
       @column_markers = Hash.new { |h,k| h[ k ] = Hash.new }
       @indenters = Hash.new
+ @indenters_next_line = Hash.new
       @unindenters = Hash.new
       @filemasks = Hash.new
       @bangmasks = Hash.new
       @closers = Hash.new
+ @surround_pairs = Hash.new { |h,k| h[ k ] = Hash.new}
 
       @settings = Hash.new
       @setting_strings = Hash.new
@@ -168,6 +170,28 @@ module Diakonos
         case command
         when "include"
           parse_configuration_file File.expand_path( arg )
+ when 'load_extension'
+ @extensions.load( arg ).each do |conf_file|
+ parse_configuration_file conf_file
+ end
+ when /^lang\.(.+?)\.surround\.pair$/
+ language = $1
+
+ args = arg.split( /"\s+"/ )
+ args.map! do |s|
+ s.gsub( /(?<!\\)"/, '' ).gsub( /\\"/, '"' )
+ end
+
+ pair_key = args.shift
+
+ if pair_key =~ /^\/.+\/$/
+ pair_key = Regexp.new( pair_key[ 1..-2 ] )
+ else
+ pair_key = Regexp.new( "^#{Regexp.escape(pair_key)}$" )
+ end
+
+ pair_parens = args
+ @surround_pairs[ language ][ pair_key ] = pair_parens
         when "key"
           if arg
             if / / === arg
@@ -221,6 +245,13 @@ module Diakonos
           else
             @indenters[ $1 ] = Regexp.new arg
           end
+ when /^lang\.(.+?)\.indent\.indenters_next_line(\.case_insensitive)?$/
+ case_insensitive = ( $2 != nil )
+ if case_insensitive
+ @indenters_next_line[ $1 ] = Regexp.new( arg, Regexp::IGNORECASE )
+ else
+ @indenters_next_line[ $1 ] = Regexp.new arg
+ end
         when /^lang\.(.+?)\.indent\.unindenters(\.case_insensitive)?$/
           case_insensitive = ( $2 != nil )
           if case_insensitive
diff --git a/lib/diakonos/core-ext/hash.rb b/lib/diakonos/core-ext/hash.rb
index 82cbbd8..5ff51b5 100644
--- a/lib/diakonos/core-ext/hash.rb
+++ b/lib/diakonos/core-ext/hash.rb
@@ -98,11 +98,5 @@ class Hash
     end
   end
 
- # Implement Ruby 1.9's Hash#key for Ruby 1.8
- if ! method_defined?( :key )
- def key( *args )
- index( *args )
- end
- end
 end
 
diff --git a/lib/diakonos/core-ext/string.rb b/lib/diakonos/core-ext/string.rb
index 8415399..04ee7d2 100644
--- a/lib/diakonos/core-ext/string.rb
+++ b/lib/diakonos/core-ext/string.rb
@@ -1,4 +1,5 @@
 class String
+
     def to_b
       case downcase
       when "true", "t", "1", "yes", "y", "on", "+"
@@ -117,11 +118,5 @@ class String
       [ i, match_text ]
     end
 
- # Backport of Ruby 1.9's String#ord into Ruby 1.8
- if ! method_defined?( :ord )
- def ord
- self[ 0 ]
- end
- end
 end
 
diff --git a/lib/diakonos/extension-set.rb b/lib/diakonos/extension-set.rb
new file mode 100644
index 0000000..79cc7fc
--- /dev/null
+++ b/lib/diakonos/extension-set.rb
@@ -0,0 +1,54 @@
+module Diakonos
+
+ class ExtensionSet
+
+ def initialize( root_dir )
+ @extensions = Hash.new
+ @root_dir = File.expand_path( root_dir )
+ end
+
+ def scripts
+ @extensions.values.find_all { |e| e }.map { |e| e.scripts }.flatten
+ end
+
+ def parse_version( s )
+ if s
+ s.split( '.' ).map { |part| part.to_i }.extend( Comparable )
+ end
+ end
+
+ def load( dir )
+ @extensions[ dir ] = false
+
+ confs_to_parse = []
+ ext_dir = File.join( @root_dir, dir )
+ info = YAML.load_file( File.join( ext_dir, 'info.yaml' ) )
+
+ if info[ 'requirements' ] && info[ 'requirements' ][ 'diakonos' ]
+ this_version = parse_version( ::Diakonos::VERSION )
+ min_version = parse_version( info[ 'requirements' ][ 'diakonos' ][ 'minimum' ] )
+ if min_version && this_version >= min_version
+ extension = Extension.new( ext_dir )
+ @extensions[ dir ] = extension
+ confs_to_parse += extension.confs
+ end
+ end
+
+ confs_to_parse
+ end
+
+ def loaded?( ext_dir )
+ @extensions[ ext_dir ]
+ end
+
+ def loaded_extensions
+ @extensions.values.find_all { |e| e }
+ end
+
+ def not_loaded_extensions
+ @extensions.keys.find_all { |e| ! loaded?( e ) }
+ end
+
+ end
+
+end
\ No newline at end of file
diff --git a/lib/diakonos/extension.rb b/lib/diakonos/extension.rb
new file mode 100644
index 0000000..33f592b
--- /dev/null
+++ b/lib/diakonos/extension.rb
@@ -0,0 +1,34 @@
+module Diakonos
+
+ class Extension
+
+ attr_reader :dir, :scripts, :confs
+
+ def initialize( dir )
+ @scripts = []
+ @confs = []
+ @dir = File.basename( dir )
+ @info = YAML.load_file( File.join( dir, 'info.yaml' ) )
+
+ Dir[ File.join( dir, '**', '*.rb' ) ].each do |ext_file|
+ @scripts << ext_file
+ end
+
+ Dir[ File.join( dir, "*.conf" ) ].each do |conf_file|
+ @confs << conf_file
+ end
+ end
+
+ def []( key )
+ @info[ key ]
+ end
+
+ [ 'name', 'description', 'version' ].each do |m|
+ define_method( m ) do
+ @info[ m ]
+ end
+ end
+
+ end
+
+end
\ No newline at end of file
diff --git a/lib/diakonos/functions.rb b/lib/diakonos/functions.rb
index a1df1e5..0e95297 100644
--- a/lib/diakonos/functions.rb
+++ b/lib/diakonos/functions.rb
@@ -1,6 +1,14 @@
 module Diakonos
   module Functions
 
+ # Shows the About page, which gives information on Diakonos.
+ def about
+ about_write
+ open_file @about_filename
+ end
+
+ # Deletes characters up to, but not including, a given character.
+ # Also puts the deleted text into the clipboard.
     def delete_to( char = nil )
       if char.nil?
         set_iline "Type character to delete to..."
@@ -17,6 +25,10 @@ module Diakonos
       end
     end
 
+ # Deletes characters between, but not including, a given pair of
+ # characters. Also puts the deleted text into the clipboard.
+ # Brace characters are intelligently matched with their opposite-side
+ # counterparts if the left-side brace is given (e.g. '[').
     def delete_to_and_from( char = nil )
       if char.nil?
         set_iline "Type character to delete to and from..."
@@ -33,6 +45,7 @@ module Diakonos
       end
     end
 
+ # Evaluates (executes) Ruby code.
     def evaluate( code_ = nil )
       if code_.nil?
         if @current_buffer.changing_selection
@@ -40,9 +53,9 @@ module Diakonos
         end
         code = get_user_input(
           "Ruby code: ",
- @rlh_general,
- selected_text || "",
- ::Diakonos::Functions.public_instance_methods.map { |m| m.to_s }
+ history: @rlh_general,
+ initial_text: selected_text || "",
+ completion_array: ::Diakonos::Functions.public_instance_methods.map { |m| m.to_s }
         )
       else
         code = code_
@@ -65,6 +78,7 @@ module Diakonos
       end
     end
 
+ # Starts the interactive help system.
     def help( prefill = '' )
       if ! File.exist?( @help_dir ) || Dir[ "#{@help_dir}/*" ].size == 0
         set_iline 'There are no help files installed.'
@@ -76,9 +90,9 @@ module Diakonos
 
       selected = get_user_input(
         "Search terms: ",
- @rlh_help,
- prefill,
- @help_tags
+ history: @rlh_help,
+ initial_text: prefill,
+ completion_array: @help_tags
       ) { |input|
         next if input.length < 3 and input[ 0..0 ] != '/'
 
@@ -136,9 +150,10 @@ module Diakonos
       end
     end
 
+ # Loads Ruby code from file using Kernel#load.
     def load_script( name_ = nil )
       if name_.nil?
- name = get_user_input( "File to load as script: ", @rlh_files )
+ name = get_user_input( "File to load as script: ", history: @rlh_files )
       else
         name = name_
       end
@@ -198,6 +213,7 @@ module Diakonos
       set_iline "Type any chain of keystrokes or key chords, then press Enter..."
     end
 
+ # Quits Diakonos (gracefully).
     def quit
       @quitting = true
       to_all = nil
@@ -229,6 +245,7 @@ module Diakonos
       refresh_all
     end
 
+ # Starts or stops macro recording.
     def toggle_macro_recording( name = nil )
       if @macro_history
         stop_recording_macro
@@ -237,10 +254,12 @@ module Diakonos
       end
     end
 
+ # Undoes the latest change made to the current_buffer.
     def undo( buffer = @current_buffer )
       buffer.undo
     end
 
+ # Redoes the latest change undone on the current_buffer.
     def unundo( buffer = @current_buffer )
       buffer.unundo
     end
diff --git a/lib/diakonos/functions/basics.rb b/lib/diakonos/functions/basics.rb
index d0870ac..a2d4755 100644
--- a/lib/diakonos/functions/basics.rb
+++ b/lib/diakonos/functions/basics.rb
@@ -15,10 +15,12 @@ module Diakonos
       @current_buffer.delete_selection
     end
 
+ # Calls Buffer#delete on the current_buffer.
     def delete
       @current_buffer.delete
     end
 
+ # Deletes the current line and adds it to the clipboard.
     def delete_line
       removed_text = @current_buffer.delete_line
       @clipboard.add_clip( [ removed_text, "" ] ) if removed_text
diff --git a/lib/diakonos/functions/buffers.rb b/lib/diakonos/functions/buffers.rb
index ecf7f85..2099f1b 100644
--- a/lib/diakonos/functions/buffers.rb
+++ b/lib/diakonos/functions/buffers.rb
@@ -101,11 +101,18 @@ module Diakonos
     end
 
     def list_buffers
+ bullets = ('0'..'9').to_a + ('a'..'z').to_a
       with_list_file do |f|
- f.puts @buffers.keys.map { |name| "#{name}\n" }.sort
+ @buffers.keys.sort.each_with_index do |name, index|
+ bullet = bullets[ index ]
+ if bullet
+ bullet << ' '
+ end
+ f.puts "#{bullet}#{name}"
+ end
       end
       open_list_buffer
- filename = get_user_input( "Switch to buffer: " )
+ filename = get_user_input( "Switch to buffer: ", numbered_completion: true )
       buffer = @buffers[ filename ]
       if buffer
         switch_to buffer
@@ -237,7 +244,12 @@ module Diakonos
           open_list_buffer
         }
       end
- file = get_user_input( "Filename: ", @rlh_files, prefill, &finder_block )
+ file = get_user_input(
+ "Filename: ",
+ history: @rlh_files,
+ initial_text: prefill,
+ &finder_block
+ )
 
       if file
         open_file file
@@ -247,7 +259,7 @@ module Diakonos
     end
 
     def open_matching_files( regexp = nil, search_root = nil )
- regexp ||= get_user_input( "Regexp: ", @rlh_search )
+ regexp ||= get_user_input( "Regexp: ", history: @rlh_search )
       return if regexp.nil?
 
       if @current_buffer.current_line =~ %r{\w*/[/\w.]+}
@@ -255,7 +267,7 @@ module Diakonos
       else
         prefill = File.expand_path( File.dirname( @current_buffer.name ) ) + "/"
       end
- search_root ||= get_user_input( "Search within: ", @rlh_files, prefill )
+ search_root ||= get_user_input( "Search within: ", history: @rlh_files, initial_text: prefill )
       return if search_root.nil?
 
       files = `egrep -rl '#{regexp.gsub( /'/, "'\\\\''" )}' #{search_root}/*`.split( /\n/ )
@@ -309,9 +321,9 @@ module Diakonos
     def save_file_as
       if @current_buffer && @current_buffer.name
         path = File.expand_path( File.dirname( @current_buffer.name ) ) + "/"
- file = get_user_input( "Filename: ", @rlh_files, path )
+ file = get_user_input( "Filename: ", history: @rlh_files, initial_text: path )
       else
- file = get_user_input( "Filename: ", @rlh_files )
+ file = get_user_input( "Filename: ", history: @rlh_files )
       end
       if file
         old_name = @current_buffer.name
@@ -383,4 +395,4 @@ module Diakonos
     end
 
   end
-end
\ No newline at end of file
+end
diff --git a/lib/diakonos/functions/cursor.rb b/lib/diakonos/functions/cursor.rb
index 62326a0..c290d28 100644
--- a/lib/diakonos/functions/cursor.rb
+++ b/lib/diakonos/functions/cursor.rb
@@ -1,7 +1,7 @@
 module Diakonos
   module Functions
 
- # Returns true iff the cursor changed positions
+ # @return [true,false] true iff the cursor changed positions
     def cursor_down
       @current_buffer.cursor_to(
         @current_buffer.last_row + 1,
@@ -12,7 +12,7 @@ module Diakonos
       )
     end
 
- # Returns true iff the cursor changed positions
+ # @return [true,false] true iff the cursor changed positions
     def cursor_left( stopped_typing = Buffer::STOPPED_TYPING )
       @current_buffer.cursor_to(
         @current_buffer.last_row,
@@ -31,7 +31,7 @@ module Diakonos
       )
     end
 
- # Returns true iff the cursor changed positions
+ # @return [true,false] true iff the cursor changed positions
     def cursor_up
       @current_buffer.cursor_to(
         @current_buffer.last_row - 1,
@@ -42,35 +42,40 @@ module Diakonos
       )
     end
 
+ # Moves the cursor to the beginning of the current buffer.
     def cursor_bof
       @current_buffer.cursor_to( 0, 0, Buffer::DO_DISPLAY )
     end
 
+ # Moves the cursor to the beginning of the current line.
     def cursor_bol
       @current_buffer.cursor_to_bol
     end
 
+ # Moves the cursor to the end of the current line.
     def cursor_eol
       @current_buffer.cursor_to_eol
     end
 
+ # Moves the cursor to the end of the current buffer.
     def cursor_eof
       @current_buffer.cursor_to_eof
     end
 
- # Top of view
+ # Moves the cursor to the top of the viewport of the current buffer.
     def cursor_tov
       @current_buffer.cursor_to_tov
     end
 
- # Bottom of view
+ # Moves the cursor to the bottom of the viewport of the current buffer.
     def cursor_bov
       @current_buffer.cursor_to_bov
     end
 
+ # Pops the cursor stack of the current buffer.
     def cursor_return( dir_str = "backward" )
       stack_pointer, stack_size = @current_buffer.cursor_return( direction_of( dir_str, :backward ) )
- set_iline( "Location: #{stack_pointer+1}/#{stack_size}" )
+ set_iline "Location: #{stack_pointer+1}/#{stack_size}"
     end
 
     def go_block_outer
@@ -86,6 +91,7 @@ module Diakonos
       @current_buffer.go_block_previous
     end
 
+ # Moves the cursor to the next occurrence of the given character.
     def go_to_char( char = nil )
       char ||= get_char( "Type character to go to..." )
 
@@ -97,6 +103,7 @@ module Diakonos
       end
     end
 
+ # Moves the cursor to the closest previous occurrence of the given character.
     def go_to_char_previous( char = nil )
       char ||= get_char( "Type character to go to..." )
 
diff --git a/lib/diakonos/functions/grepping.rb b/lib/diakonos/functions/grepping.rb
index 8dfbd63..4ebcb51 100644
--- a/lib/diakonos/functions/grepping.rb
+++ b/lib/diakonos/functions/grepping.rb
@@ -15,7 +15,13 @@ module Diakonos
 
     def grep_dir( regexp_source = nil, dir = nil )
       if dir.nil?
- dir = get_user_input( "Grep directory: ", @rlh_files, @session[ 'dir' ], nil, DONT_COMPLETE, :accept_dirs )
+ dir = get_user_input(
+ "Grep directory: ",
+ history: @rlh_files,
+ initial_text: @session[ 'dir' ],
+ do_complete: DONT_COMPLETE,
+ on_dirs: :accept_dirs
+ )
         return if dir.nil?
       end
       dir = File.expand_path( dir )
@@ -28,8 +34,8 @@ module Diakonos
 
       selected = get_user_input(
         "Grep regexp: ",
- @rlh_search,
- regexp_source || selected_text || ""
+ history: @rlh_search,
+ initial_text: regexp_source || selected_text || ""
       ) { |input|
         next if input.length < 2
         escaped_input = input.gsub( /'/ ) { "\\047" }
diff --git a/lib/diakonos/functions/search.rb b/lib/diakonos/functions/search.rb
index 3125128..fd3de64 100644
--- a/lib/diakonos/functions/search.rb
+++ b/lib/diakonos/functions/search.rb
@@ -30,7 +30,7 @@ module Diakonos
       end
 
       if replacement == ASK_REPLACEMENT
- replacement = get_user_input( "Replace with: ", @rlh_search )
+ replacement = get_user_input( "Replace with: ", history: @rlh_search )
       end
 
       if exception_thrown and not quiet
@@ -59,8 +59,8 @@ module Diakonos
 
         regexp_source = get_user_input(
           "Search regexp: ",
- @rlh_search,
- ( selected_text or "" )
+ history: @rlh_search,
+ initial_text: selected_text || ""
         ) { |input|
           if input.length > 1
             find_ direction, case_sensitive, input, nil, starting_row, starting_col, QUIET
@@ -97,7 +97,11 @@ module Diakonos
         if @current_buffer.changing_selection
           selected_text = @current_buffer.copy_selection[ 0 ]
         end
- search_term = get_user_input( "Search for: ", @rlh_search, ( selected_text or "" ) )
+ search_term = get_user_input(
+ "Search for: ",
+ history: @rlh_search,
+ initial_text: selected_text || ""
+ )
       else
         search_term = search_term_
       end
diff --git a/lib/diakonos/functions/sessions.rb b/lib/diakonos/functions/sessions.rb
index 97e528e..1f85537 100644
--- a/lib/diakonos/functions/sessions.rb
+++ b/lib/diakonos/functions/sessions.rb
@@ -28,7 +28,12 @@ module Diakonos
 
     def load_session( session_id = nil )
       if session_id.nil?
- session_id = get_user_input( "Session: ", @rlh_sessions, @session_dir, nil, DO_COMPLETE )
+ session_id = get_user_input(
+ "Session: ",
+ history: @rlh_sessions,
+ initial_text: @session_dir,
+ do_complete: DO_COMPLETE
+ )
       end
       return if session_id.nil? or session_id.empty?
 
@@ -59,7 +64,13 @@ module Diakonos
     end
 
     def set_session_dir
- path = get_user_input( "Session directory: ", @rlh_files, @session[ 'dir' ], nil, DONT_COMPLETE, :accept_dirs )
+ path = get_user_input(
+ "Session directory: ",
+ history: @rlh_files,
+ initial_text: @session[ 'dir' ],
+ do_complete: DONT_COMPLETE,
+ on_dirs: :accept_dirs
+ )
       if path
         @session[ 'dir' ] = File.expand_path( path )
         save_session
diff --git a/lib/diakonos/functions/shell.rb b/lib/diakonos/functions/shell.rb
index 353180d..68f8940 100644
--- a/lib/diakonos/functions/shell.rb
+++ b/lib/diakonos/functions/shell.rb
@@ -20,7 +20,11 @@ module Diakonos
 
       # Get user input, sub it in
       if retval =~ /\$i/
- user_input = get_user_input( "Argument: ", @rlh_shell, @current_buffer.selected_string )
+ user_input = get_user_input(
+ "Argument: ",
+ history: @rlh_shell,
+ initial_text: @current_buffer.selected_string
+ )
         retval.gsub!( /\$i/, user_input )
       end
 
@@ -52,7 +56,7 @@ module Diakonos
     end
 
     def shell( command_ = nil, result_filename = 'shell-result.txt' )
- command = command_ || get_user_input( "Command: ", @rlh_shell )
+ command = command_ || get_user_input( "Command: ", history: @rlh_shell )
 
       return if command.nil?
 
@@ -112,7 +116,7 @@ module Diakonos
     end
 
     def execute( command_ = nil )
- command = command_ || get_user_input( "Command: ", @rlh_shell )
+ command = command_ || get_user_input( "Command: ", history: @rlh_shell )
 
       return if command.nil?
 
@@ -134,7 +138,7 @@ module Diakonos
     end
 
     def paste_shell_result( command_ = nil )
- command = command_ || get_user_input( "Command: ", @rlh_shell )
+ command = command_ || get_user_input( "Command: ", history: @rlh_shell )
 
       return if command.nil?
 
@@ -155,7 +159,7 @@ module Diakonos
     end
 
     def spawn( command_ = nil )
- command = command_ || get_user_input( "Command: ", @rlh_shell )
+ command = command_ || get_user_input( "Command: ", history: @rlh_shell )
 
       return if command.nil?
 
diff --git a/lib/diakonos/functions/tags.rb b/lib/diakonos/functions/tags.rb
index 18a8237..3772a02 100644
--- a/lib/diakonos/functions/tags.rb
+++ b/lib/diakonos/functions/tags.rb
@@ -10,7 +10,12 @@ module Diakonos
         if @current_buffer.changing_selection
           selected_text = @current_buffer.copy_selection[ 0 ]
         end
- tag_name = get_user_input( "Tag name: ", @rlh_general, ( selected_text or "" ), @tags.keys )
+ tag_name = get_user_input(
+ "Tag name: ",
+ history: @rlh_general,
+ initial_text: selected_text || "",
+ completion_array: @tags.keys
+ )
       else
         tag_name = tag_
       end
diff --git a/lib/diakonos/functions/text-manipulation.rb b/lib/diakonos/functions/text-manipulation.rb
index ed4bef4..5ccaecc 100644
--- a/lib/diakonos/functions/text-manipulation.rb
+++ b/lib/diakonos/functions/text-manipulation.rb
@@ -13,8 +13,8 @@ module Diakonos
       if delimiter.nil?
         delimiter = get_user_input(
           "Column delimiter (regexp): ",
- @rlh_general,
- @settings[ "lang.#{@current_buffer.original_language}.column_delimiters" ] || ''
+ history: @rlh_general,
+ initial_text: @settings[ "lang.#{@current_buffer.original_language}.column_delimiters" ] || ''
         )
       end
       if delimiter && num_spaces_padding
@@ -75,12 +75,20 @@ module Diakonos
       end
     end
 
+ def join_lines_upward
+ @current_buffer.join_lines_upward( @current_buffer.current_row, Buffer::STRIP_LINE )
+ end
+
     def join_lines
       @current_buffer.join_lines( @current_buffer.current_row, Buffer::STRIP_LINE )
     end
 
     def operate_on_string(
- ruby_code = get_user_input( 'Ruby code: ', @rlh_general, 'str.' )
+ ruby_code = get_user_input(
+ 'Ruby code: ',
+ history: @rlh_general,
+ initial_text: 'str.'
+ )
     )
       if ruby_code
         str = @current_buffer.selected_string
@@ -91,7 +99,11 @@ module Diakonos
     end
 
     def operate_on_lines(
- ruby_code = get_user_input( 'Ruby code: ', @rlh_general, 'lines.collect { |l| l }' )
+ ruby_code = get_user_input(
+ 'Ruby code: ',
+ history: @rlh_general,
+ initial_text: 'lines.collect { |l| l }'
+ )
     )
       if ruby_code
         lines = @current_buffer.selected_text
@@ -110,7 +122,11 @@ module Diakonos
     end
 
     def operate_on_each_line(
- ruby_code = get_user_input( 'Ruby code: ', @rlh_general, 'line.' )
+ ruby_code = get_user_input(
+ 'Ruby code: ',
+ history: @rlh_general,
+ initial_text: 'line.'
+ )
     )
       if ruby_code
         lines = @current_buffer.selected_text
@@ -128,6 +144,48 @@ module Diakonos
       end
     end
 
+ def surround_line( envelope = nil )
+ envelope ||= get_user_input( 'Surround with: ' )
+ return if envelope.nil?
+ @current_buffer.select_current_line
+ surround_selection envelope
+ end
+
+ def surround_paragraph( envelope = nil )
+ envelope ||= get_user_input( 'Surround with: ' )
+ return if envelope.nil?
+
+ ( first, _ ), ( last, length ) = @current_buffer.paragraph_under_cursor_pos
+ @current_buffer.set_selection( first, 0, last, length+1 )
+ surround_selection envelope
+ end
+
+ def surround_selection( parenthesis = nil )
+ if ! @current_buffer.selecting?
+ set_iline "Nothing selected."
+ return
+ end
+
+ parenthesis ||= get_user_input( "Parenthesis: " )
+ if parenthesis
+ text = @current_buffer.surround( @current_buffer.selected_text, parenthesis )
+ if text
+ @current_buffer.paste text
+ end
+ end
+ end
+
+ def surround_word( envelope = nil )
+ envelope ||= get_user_input( 'Surround with: ' )
+ return if envelope.nil?
+
+ ( start_row, start_col ), ( end_row, end_col ) = @current_buffer.word_under_cursor_pos
+ if start_row && start_col && end_row && end_col
+ @current_buffer.set_selection( start_row, start_col, end_row, end_col+1 )
+ surround_selection envelope
+ end
+ end
+
     def uncomment
       @current_buffer.uncomment
     end
@@ -137,4 +195,4 @@ module Diakonos
     end
 
   end
-end
\ No newline at end of file
+end
diff --git a/lib/diakonos/grep.rb b/lib/diakonos/grep.rb
index 4634aa9..8afbc24 100644
--- a/lib/diakonos/grep.rb
+++ b/lib/diakonos/grep.rb
@@ -61,8 +61,8 @@ module Diakonos
 
       selected = get_user_input(
         "Grep regexp: ",
- @rlh_search,
- regexp_source || selected_text || ""
+ history: @rlh_search,
+ initial_text: regexp_source || selected_text || ""
       ) { |input|
         next if input.length < 2
         actually_grep input, *buffers
diff --git a/lib/diakonos/interaction.rb b/lib/diakonos/interaction.rb
index ae26721..27d45cd 100644
--- a/lib/diakonos/interaction.rb
+++ b/lib/diakonos/interaction.rb
@@ -37,11 +37,16 @@ module Diakonos
 
   class Diakonos
     # completion_array is the array of strings that tab completion can use
- def get_user_input( prompt, history = @rlh_general, initial_text = "", completion_array = nil, do_complete = DONT_COMPLETE, on_dirs = :go_into_dirs, &block )
+ # @param options :initial_text, :completion_array, :history, :do_complete, :on_dirs
+ def get_user_input( prompt, options = {}, &block )
+ options[ :history ] ||= @rlh_general
+ options[ :initial_text ] ||= ""
+ options[ :do_complete ] ||= DONT_COMPLETE
+ options[ :on_dirs ] ||= :go_into_dirs
       if @playing_macro
         retval = @macro_input_history.shift
       else
- retval = Readline.new( self, @win_interaction, prompt, initial_text, completion_array, history, do_complete, on_dirs, &block ).readline
+ retval = Readline.new( self, @win_interaction, prompt, options, &block ).readline
         if @macro_history
           @macro_input_history.push retval
         end
diff --git a/lib/diakonos/list.rb b/lib/diakonos/list.rb
index 519991c..3d51f82 100644
--- a/lib/diakonos/list.rb
+++ b/lib/diakonos/list.rb
@@ -1,6 +1,7 @@
 module Diakonos
 
   class Diakonos
+ attr_reader :list_buffer
 
     def open_list_buffer
       @list_buffer = open_file( @list_filename )
@@ -55,4 +56,4 @@ module Diakonos
 
   end
 
-end
\ No newline at end of file
+end
diff --git a/lib/diakonos/readline.rb b/lib/diakonos/readline.rb
index abf85aa..5f946d6 100644
--- a/lib/diakonos/readline.rb
+++ b/lib/diakonos/readline.rb
@@ -4,22 +4,26 @@ module Diakonos
 
     # completion_array is the array of strings that tab completion can use
     # The block returns true if a refresh is needed?
- def initialize( diakonos, window, prompt, initial_text = "", completion_array = nil, history = [], do_complete = Diakonos::DONT_COMPLETE, on_dirs = :go_into_dirs, &block )
+ # @param options :initial_text, :completion_array, :history, :do_complete, :on_dirs
+ def initialize( diakonos, window, prompt, options = {}, &block )
       @diakonos = diakonos
       @window = window
       @prompt = prompt
       pos = redraw_prompt
       @window.setpos( 0, pos )
- @initial_text = initial_text || ''
- @completion_array = completion_array
+ @initial_text = options[ :initial_text ] || ''
+ @completion_array = options[ :completion_array ]
       @list_filename = @diakonos.list_filename
 
- @history = history
- @history << initial_text
+ @history = options[ :history ] || []
+ @history << @initial_text
       @history_index = @history.length - 1
 
- @do_complete = do_complete
- @on_dirs = on_dirs
+ @do_complete = options[ :do_complete ] || ::Diakonos::DONT_COMPLETE
+ @on_dirs = options[ :on_dirs ] || :go_into_dirs
+
+ # TODO think of better name
+ @numbered_completion = options [ :numbered_completion ]
 
       @block = block
     end
@@ -35,6 +39,13 @@ module Diakonos
       end
     end
 
+ def set_input( input = '' )
+ if @numbered_completion && input =~ /^\w /
+ input = input[ 3..-1 ]
+ end
+ @input = input
+ end
+
     # Returns nil on cancel.
     def readline
       @input = @initial_text.dup
@@ -59,7 +70,7 @@ module Diakonos
         when Curses::KEY_DC
           if @input_cursor < @input.length
             @window.delch
- @input = @input[ 0...@input_cursor ] + @input[ (@input_cursor + 1)..-1 ]
+ set_input( @input[ 0...@input_cursor ] + @input[ (@input_cursor + 1)..-1 ] )
             call_block
           end
         when BACKSPACE, CTRL_H
@@ -71,7 +82,7 @@ module Diakonos
             # Curses::KEY_DC
             if @input_cursor < @input.length
               @window.delch
- @input = @input[ 0...@input_cursor ] + @input[ (@input_cursor + 1)..-1 ]
+ set_input( @input[ 0...@input_cursor ] + @input[ (@input_cursor + 1)..-1 ] )
               call_block
             end
           end
@@ -107,14 +118,14 @@ module Diakonos
           @diakonos.page_down
           line = @diakonos.select_list_item
           if line
- @input = line
+ set_input line
             cursor_write_input
           end
         when Curses::KEY_PPAGE
           @diakonos.page_up
           line = @diakonos.select_list_item
           if line
- @input = line
+ set_input line
             cursor_write_input
           end
         when Curses::KEY_UP
@@ -122,7 +133,7 @@ module Diakonos
             if @diakonos.list_item_selected?
               @diakonos.previous_list_item
             end
- @input = @diakonos.select_list_item
+ set_input @diakonos.select_list_item
           elsif @history_index > 0
             @history[ @history_index ] = @input
             @history_index -= 1
@@ -134,7 +145,7 @@ module Diakonos
             if @diakonos.list_item_selected?
               @diakonos.next_list_item
             end
- @input = @diakonos.select_list_item
+ set_input @diakonos.select_list_item
           elsif @history_index < @history.length - 1
             @history[ @history_index ] = @input
             @history_index += 1
@@ -161,16 +172,33 @@ module Diakonos
           cursor_write_input
         else
           if c > 31 && c < 255 && c != BACKSPACE
- if @input_cursor == @input.length
- @input << c
- @window.addch c
+ if @numbered_completion
+ if(
+ @diakonos.showing_list? &&
+ ( (48..57).include?( c ) || (97..122).include?( c ) )
+ )
+ line = @diakonos.list_buffer.to_a.select { |l|
+ l =~ /^#{c.chr} /
+ }[ 0 ]
+
+ if line
+ set_input line
+ cursor_write_input
+ break
+ end
+ end
             else
- @input = @input[ 0...@input_cursor ] + c.chr + @input[ @input_cursor..-1 ]
- @window.setpos( @window.cury, @window.curx + 1 )
- redraw_input
+ if @input_cursor == @input.length
+ @input << c
+ @window.addch c
+ else
+ @input = @input[ 0...@input_cursor ] + c.chr + @input[ @input_cursor..-1 ]
+ @window.setpos( @window.cury, @window.curx + 1 )
+ redraw_input
+ end
+ @input_cursor += 1
+ call_block
             end
- @input_cursor += 1
- call_block
           else
             @diakonos.log "Other input: #{c}"
           end
@@ -244,8 +272,6 @@ module Diakonos
             f.print match
             if FileTest.directory?( match )
               f.print '/'
- else
- @diakonos.log "'#{match}' is not a directory"
             end
             f.puts
 
@@ -281,4 +307,4 @@ module Diakonos
 
   end
 
-end
\ No newline at end of file
+end
diff --git a/lib/diakonos/version.rb b/lib/diakonos/version.rb
index 9571c4d..b87f92b 100644
--- a/lib/diakonos/version.rb
+++ b/lib/diakonos/version.rb
@@ -1,4 +1,4 @@
 module Diakonos
- VERSION = '0.8.10'
- LAST_MODIFIED = 'June 17, 2009'
+ VERSION = '0.8.11'
+ LAST_MODIFIED = 'June 30, 2009'
 end
\ No newline at end of file
diff --git a/osx.conf b/osx.conf
deleted file mode 100644
index aeb8244..0000000
--- a/osx.conf
+++ /dev/null
@@ -1,62 +0,0 @@
-# Additional configuration for OSX
-# --------------------------------
-
-# Linux Alt --> OSX Option
-
-key keycode195 keycode165 columnize
-# key keycode226 keycode136 keycode171
-key keycode195 keycode167 close_code
-key keycode226 keycode136 keycode130 shell "diff -U 5 -w -b $k $s", "clipboard.diff"
-# Option-E doesn't do anything
-key keycode198 keycode146 find "down", CASE_SENSITIVE
-key keycode194 keycode169 grep
-# key keycode203 keycode153
-# Option-I doesn't do anything
-key keycode226 keycode136 keycode134 joinLines
-key keycode203 keycode154 printKeychain
-# key keycode194 keycode172
-key keycode194 keycode181 toggleMacroRecording
-# Option-N doesn't do anything
-key keycode195 keycode184 open_matching_files
-key keycode207 keycode128 scrollUp
-# key keycode197 keycode147
-key keycode194 keycode174 searchAndReplace CASE_SENSITIVE
-# key keycode195 keycode159
-key keycode226 keycode128 keycode160 goToTag
-# Option-U doesn't do anything
-# key keycode226 keycode136 keycode154
-key keycode226 keycode136 keycode145 wrap_paragraph
-# key keycode226 keycode137 keycode136
-# Option-Y doesn't do anything
-# key keycode206 keycode169
-
-
-# Linux Alt-Shift --> OSX Option-Shift
-
-# key keycode195 keycode133
-# key keycode196 keycode177
-key keycode195 keycode135 toggleSessionSetting 'context.visible', DO_REDRAW
-# key keycode195 keycode142
-# key keycode194 keycode180
-# key keycode195 keycode143
-key keycode203 keycode157 grep_buffers
-# key keycode195 keycode147
-key keycode203 keycode134 unindent
-# key keycode195 keycode148
-key keycode239 keycode163 keycode191 print_mapped_function
-key keycode195 keycode146 toggleSessionSetting 'view.line_numbers', DO_REDRAW
-key keycode195 keycode130 keycode196 keycode177 selection_mode_block
-key keycode195 keycode130 keycode203 keycode156 selection_mode_normal
-key keycode203 keycode156 scrollDown
-# key keycode195 keycode152
-# key keycode226 keycode136 keycode143
-# key keycode197 keycode146
-# key keycode226 keycode128 keycode176
-key keycode195 keycode141 saveFileAs
-key keycode203 keycode135 setBufferType
-key keycode194 keycode168 removeSelection
-# key keycode226 keycode151 keycode138
-key keycode226 keycode128 keycode158 toggleSessionSetting 'view.wrap.visual', DO_REDRAW
-# key keycode203 keycode155
-# key keycode195 keycode129
-# key keycode194 keycode184
diff --git a/scripts/git-branch.rb b/scripts/git-branch.rb
deleted file mode 100644
index f550d68..0000000
--- a/scripts/git-branch.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-git_proc = Proc.new do |buffer|
- if buffer and buffer.name
- dir = File.dirname( File.expand_path( buffer.name ) )
- else
- dir = '.'
- end
-
- if File.exist? dir
- branch = Dir.chdir( dir ){ `git symbolic-ref HEAD 2>/dev/null`[ /[^\/\n]+$/ ] }
- $diakonos.set_status_variable(
- '@git_branch',
- branch ? " git:#{branch} " : nil
- )
- end
-end
-
-$diakonos.register_proc( git_proc, :after_open )
-$diakonos.register_proc( git_proc, :after_buffer_switch )
diff --git a/spec/buffer.rb b/spec/buffer.rb
index 1aac062..085903b 100644
--- a/spec/buffer.rb
+++ b/spec/buffer.rb
@@ -1,10 +1,19 @@
 require 'spec/preparation'
 
+def check_word_at( row, col, expected_word )
+ @b.cursor_to row, col
+ @b.word_under_cursor.should.equal expected_word
+end
+
+def check_paragraph_at( row, col, expected_paragraph )
+ @b.cursor_to row, col
+ @b.paragraph_under_cursor.should.equal expected_paragraph
+end
+
 describe 'A Diakonos::Buffer' do
 
   before do
     @b = Diakonos::Buffer.new( $diakonos, SAMPLE_FILE, SAMPLE_FILE )
- @b.cursor_to( 0, 0 )
   end
 
   it 'can provide selected text' do
@@ -128,6 +137,28 @@ describe 'A Diakonos::Buffer' do
     indent_rows
     @b.save_copy TEMP_FILE
     File.read( TEMP_FILE ).should.equal File.read( SAMPLE_FILE )
+
+ # -------
+
+ @b = Diakonos::Buffer.new( $diakonos, SAMPLE_FILE_C, SAMPLE_FILE_C )
+
+ indent_rows 0, 14
+ @b.save_copy TEMP_FILE_C
+ File.read( TEMP_FILE_C ).should.equal File.read( SAMPLE_FILE_C )
+
+ @b.cursor_to( 3, 0 )
+ @b.insert_string " "
+ @b.cursor_to( 10, 0 )
+ @b.insert_string " "
+ @b.cursor_to( 12, 0 )
+ @b.insert_string " "
+
+ @b.save_copy TEMP_FILE_C
+ File.read( TEMP_FILE_C ).should.not.equal File.read( SAMPLE_FILE_C )
+
+ indent_rows 0, 14
+ @b.save_copy TEMP_FILE_C
+ File.read( TEMP_FILE_C ).should.equal File.read( SAMPLE_FILE_C )
   end
 
   it 'can paste an Array of Strings' do
@@ -144,4 +175,64 @@ describe 'A Diakonos::Buffer' do
     @b.to_a.should.equal original_lines[ 1..-1 ]
   end
 
+ it 'knows the word under the cursor' do
+ check_word_at 0, 16, 'ruby'
+ check_word_at 2, 0, nil
+ check_word_at 2, 2, 'This'
+ check_word_at 2, 3, 'This'
+ check_word_at 2, 4, 'This'
+ check_word_at 2, 5, 'This'
+ check_word_at 2, 6, nil
+ check_word_at 2, 45, 'tests'
+ check_word_at 2, 46, nil
+ check_word_at 2, 47, nil
+ check_word_at 3, 0, nil
+ check_word_at 5, 14, nil
+ check_word_at 5, 15, 'x'
+ check_word_at 5, 16, nil
+ check_word_at 14, 4, 'y'
+ check_word_at 14, 5, nil
+ check_word_at 14, 6, 'inspect'
+ check_word_at 21, 0, nil
+ check_word_at 22, 8, nil
+ check_word_at 22, 9, nil
+ check_word_at 26, 39, 'EOF'
+ check_word_at 26, 40, nil
+ end
+
+ it 'knows the paragraph under the cursor' do
+ check_paragraph_at 0, 0, [
+ '#!/usr/bin/env ruby',
+ ]
+ check_paragraph_at 2, 0, [
+ '# This is only a sample file used in the tests.',
+ ]
+ check_paragraph_at 4, 0, [
+ 'class Sample',
+ ' attr_reader :x, :y',
+ ]
+ check_paragraph_at 7, 0, [
+ ' def initialize',
+ ' @x = 1',
+ ' @y = 2',
+ ' end',
+ ]
+ check_paragraph_at 14, 7, [
+ ' def inspection',
+ ' x.inspect',
+ ' y.inspect',
+ ' end',
+ 'end',
+ ]
+ check_paragraph_at 22, 7, [
+ '{',
+ ' :just => :a,',
+ ' :test => :hash,',
+ '}',
+ ]
+ check_paragraph_at 26, 12, [
+ '# Comment at end, with no newline at EOF',
+ ]
+ end
+
 end
\ No newline at end of file
diff --git a/spec/functions/clipboard.rb b/spec/functions/clipboard.rb
index 0a4ae14..e413ae5 100644
--- a/spec/functions/clipboard.rb
+++ b/spec/functions/clipboard.rb
@@ -40,7 +40,7 @@ describe 'A Diakonos user can' do
     ]
 
     lines = @b.to_a
- lines.size.should.equal 23
+ lines.size.should.equal 24
     lines[ 0..2 ].should.equal [
       '',
       'class Sample',
@@ -55,7 +55,7 @@ describe 'A Diakonos user can' do
     @d.paste
 
     lines = @b.to_a
- lines.size.should.equal 29
+ lines.size.should.equal 30
     lines[ 0..8 ].should.equal [
       '#!/usr/bin/env ruby',
       '',
diff --git a/spec/functions/cursor.rb b/spec/functions/cursor.rb
index 053232c..2c2fc51 100644
--- a/spec/functions/cursor.rb
+++ b/spec/functions/cursor.rb
@@ -37,7 +37,7 @@ describe 'A Diakonos user can' do
 
   it 'move the cursor to the end of a file' do
     @d.cursor_eof
- cursor_should_be_at 25,0
+ cursor_should_be_at 26,40
   end
 
   it 'move the cursor to the beginning of a file' do
@@ -64,7 +64,7 @@ describe 'A Diakonos user can' do
 
   it 'move the cursor to the closest previous occurrence of a character' do
     @d.cursor_eof
- cursor_should_be_at 25,0
+ cursor_should_be_at 26,40
     @d.go_to_char_previous '.'
     cursor_should_be_at 19,1
     @d.go_to_char_previous 'e'
diff --git a/spec/functions/selection.rb b/spec/functions/selection.rb
index 8ee798d..56ebd83 100644
--- a/spec/functions/selection.rb
+++ b/spec/functions/selection.rb
@@ -42,8 +42,8 @@ describe 'A Diakonos user can' do
     s = @b.selection_mark
     s.start_row.should.equal 0
     s.start_col.should.equal 0
- s.end_row.should.equal 25
- s.end_col.should.equal 0
+ s.end_row.should.equal 26
+ s.end_col.should.equal 40
   end
 
   it 'delete the selection' do
diff --git a/spec/functions/text-manipulation.rb b/spec/functions/text-manipulation.rb
index 17ef4e7..a23cb66 100644
--- a/spec/functions/text-manipulation.rb
+++ b/spec/functions/text-manipulation.rb
@@ -116,7 +116,7 @@ describe 'A Diakonos user can' do
     @b.cursor_to 22,2
     @d.delete_to_and_from '{'
     lines = @b.to_a
- lines.size.should.equal 23
+ lines.size.should.equal 24
     lines[ 21..22 ].should.equal [
       '{}',
       '',
@@ -156,6 +156,7 @@ describe 'A Diakonos user can' do
       ':test => :hash,',
       '}',
       '',
+ '# Comment at end, with no newline at EOF',
     ]
 
     @d.set_buffer_type 'ruby'
@@ -188,6 +189,7 @@ describe 'A Diakonos user can' do
       ' :test => :hash,',
       '}',
       '',
+ '# Comment at end, with no newline at EOF',
     ]
   end
 
@@ -206,4 +208,36 @@ describe 'A Diakonos user can' do
     ]
   end
 
+ it 'surround selections with parentheses' do
+ @b.set_selection 4, 6, 4, 12
+ @d.surround_selection '('
+ @b[ 4 ].should.equal 'class ( Sample )'
+ @d.undo
+
+ @b.set_selection 4, 0, 4, 12
+ @d.surround_selection '('
+ @b[ 4 ].should.equal '( class Sample )'
+ @d.undo
+
+ @b.set_selection 4, 0, 5, 20
+ @d.surround_selection '('
+ @b[ 4..5 ].should.equal [
+ '( class Sample',
+ ' attr_reader :x, :y )'
+ ]
+ @d.undo
+
+ @b.set_type 'html'
+
+ @b.set_selection 7, 2, 7, 5
+ @d.surround_selection '<!--'
+ @b[ 7 ].should.equal ' <!-- def --> initialize'
+ @d.undo
+
+ @b.set_selection 7, 2, 7, 5
+ @d.surround_selection '<span>'
+ @b[ 7 ].should.equal ' <span>def</span> initialize'
+ @d.undo
+ end
+
 end
diff --git a/spec/preparation.rb b/spec/preparation.rb
index 9012a5c..c22c579 100644
--- a/spec/preparation.rb
+++ b/spec/preparation.rb
@@ -13,12 +13,18 @@ end
 if ! Object.const_defined? 'SAMPLE_FILE'
   SAMPLE_FILE = File.join( TEST_DIR, '/sample-file.rb' )
 end
+if ! Object.const_defined? 'SAMPLE_FILE_C'
+ SAMPLE_FILE_C = File.join( TEST_DIR, '/sample-file.c' )
+end
 if ! Object.const_defined? 'BRACKET_FILE'
   BRACKET_FILE = File.join( TEST_DIR, '/bracket-file.rb' )
 end
 if ! Object.const_defined? 'TEMP_FILE'
   TEMP_FILE = File.join( TEST_DIR, '/temp-file.rb' )
 end
+if ! Object.const_defined? 'TEMP_FILE_C'
+ TEMP_FILE_C = File.join( TEST_DIR, '/temp-file.c' )
+end
 
 def cursor_should_be_at( row, col )
   @b.current_row.should.equal row
diff --git a/spec/test-files/sample-file.c b/spec/test-files/sample-file.c
new file mode 100644
index 0000000..2810af9
--- /dev/null
+++ b/spec/test-files/sample-file.c
@@ -0,0 +1,16 @@
+#include <stdio.h>
+
+int main() {
+ printf( "Hello World!\n" );
+
+ if( condition ) {
+ f();
+ }
+
+ if( condition )
+ g();
+
+ h();
+
+ return 0;
+}
diff --git a/spec/test-files/sample-file.rb b/spec/test-files/sample-file.rb
index c8b6eba..aa38fd5 100644
--- a/spec/test-files/sample-file.rb
+++ b/spec/test-files/sample-file.rb
@@ -23,3 +23,5 @@ s.inspection
   :just => :a,
   :test => :hash,
 }
+
+# Comment at end, with no newline at EOF
\ No newline at end of file
diff --git a/spec/test-files/temp-file.c b/spec/test-files/temp-file.c
new file mode 100644
index 0000000..2810af9
--- /dev/null
+++ b/spec/test-files/temp-file.c
@@ -0,0 +1,16 @@
+#include <stdio.h>
+
+int main() {
+ printf( "Hello World!\n" );
+
+ if( condition ) {
+ f();
+ }
+
+ if( condition )
+ g();
+
+ h();
+
+ return 0;
+}