~codygman/emacs-config

emacs-config/emacs-config.org -rw-r--r-- 124.0 KiB
20cfdbb5 — Cody Goodman open org-attach directories in emacs (ex. RET on headings) 1 year, 5 months ago
                                                                                
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
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
#+title: Emacs configuration
#+description: An org-babel based emacs configuration
#+language: en
#+property: header-args :results silent
* workflow
** what this is and what it means
*** what is listed is not necessarily what I do in practice
*** instead I've listed the best ways I know of doing a common task with my current config or
*** additionally each section has a current and future changes section to constantly improve workflow(s)
** org mode
*** current
**** general usage
***** Open daily agenda for today with =SPC o d=
***** Capture from anywhere with =SPC c c= and do so using =helm-org-capture-templates=
***** finding any random org heading: =SPC o r= (org rifle)
***** starting on a task not in agenda: open an org file with =C-c [= if none opened and =SPC o r C-z <ind> SPC 2 , c i , t t i=
***** starting on a task in agenda: navigate to, =RET , c i , t t i SPC u , s b SPC 1 SPC w m=
**** navigating org headings
***** go to parent: =g h=
***** get context "why am I doing this?": =helm-org-parent-headings=
***** go up heading: ={=
***** go down heading: =}=
***** go to parent heading: =}=
***** go to subheading(expanded): =j=
***** go to subheading(collapsed): =TAB j=
**** agenda
***** rescheduling headings preserving time:  B D
****** see [[*install and configure org][install and configure org]]
***** clock in:  =i=
***** clock out: =o=
***** clock cancel: =x=
***** schedule:  =s=
***** todo: =t=
***** forward day: =f=
***** backward day: =b=
***** current day: =.=
***** logging mode: =l=
***** set priority: =,=
***** kill agenda item: =C-k=
*** future changes
**** no general org mode changes proposed yet
**** general usage
***** TODO start task not in agenda: =SPC o r C-z <start>=
***** TODO start task in agenda: maybe =gi= (clocks in, marks in progress, opens in indirect buffer, maximizes
**** agenda
***** probably defaults of evil-collection
** working in projects
*** current
**** navigation
***** prefer finding things via filenames with =SPC p p=
***** prefer finding things with =SPC f f C-z <git> RET <query> RET= :bad:timeSink:
***** go to definition
****** uses evil-goto-definition
***** when in sourcetree with duplicate filenames, knowing which one you are at consists of =SPC f f= and seeing current directory
***** find file in another branch: =SPC SPC <mff>= for =magit-find-file=
**** magit
***** stage hunks of file: =SPC g s= then =s= on hunks you want staged
***** stage all changes in a file: =SPC g s ] ] s=
***** commit and stage all changes done in repo: =SPC g s c c y <commit message> C-c C-c=
*** future changes
**** navigation
***** [[file:~/org/org.org::*prefer finding things via rg for project with =SPC p g= set to =projectile-rg=][prefer finding things via rg for project with =SPC p g= set to =projectile-rg=]]
***** TODO go to definition preferring smarter jumps first
****** goal: Try to use lsp go-to-definition to get exactly where you want and fall-through to less precise methods quickly
****** goal: this should all happen in less than 1 second every time even if just falling back to ripgrep
****** TODO should use smart-jump and prefer lsp-* engines for 500ms
****** TODO next it should prefer tag sources if they exist
****** TODO finally it should use dumb-jump configured to *only use ripgrep*
***** TODO default persistent action of =SPC p p= should be =magit-status= instead of =projectile-find-files=
****** alternatively projectile-find-files could become smarter and add entries for recently changed git files
******* clicking on one of those that doesn't exist in current working tree would switch branches with magit
******* these entries would also need the current branch
***** TODO when in sourcetree with duplicate filenames, knowing which one you are at consists of looking at the buffer that contains parent directory name
**** magit
***** TODO stage all changes in a file: =, g f s=
***** TODO commit and stage all changes done in repo: =, g S c c y <commit message> , ,= (not sure about this one)
** literate programming
*** current
**** yasnippet is used for common tasks like (note: roughly ordered by use)
***** TODO sh
#+begin_src org
  ,#+begin_src shell :results verbatim
  ,#+end_src
#+end_src
***** TODO hs
#+begin_src org
  ,#+begin_src haskell
  ,#+end_src
#+end_src
***** TODO ex.
#+begin_src org
  ,#+begin_example
  << contents of copy buffer >>
  ,#+end_example
#+end_src
**** a custom ob-sh-evaluate is used to allow logging long running processes like servers output to a file without blocking emacs
*** future changes
**** yasnippet is used for common tasks like (note: roughly ordered by use)
***** sh
****** snippet expands to
#+begin_src org
  ,#+begin_src shell
  ,#+end_src
#+end_src
****** pretty sure I want to remove verbatim so I can use named source blocks more
****** at least if I figure out how to streamline the process better
* Core-ish things that need to happen first
** init file to write to ~/.emacs.d/init.el before bootstrap
#+begin_src elisp :tangle ~/.emacs.d/init.el :eval no
    ;; add MELPA package server
    (require 'package)
  (setq package-enable-at-startup nil)
    (setq package-archives '(("org"   . "http://orgmode.org/elpa/")
                             ("gnu"   . "http://elpa.gnu.org/packages/")
                             ("melpa" . "https://melpa.org/packages/")))
    (unless package-archive-contents
      (package-refresh-contents))

    (package-initialize)
  (message "package initialize finished")

    ;; straight.el setup
    (defvar bootstrap-version)
    (let ((bootstrap-file
           (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
          (bootstrap-version 5))
      (unless (file-exists-p bootstrap-file)
        (with-current-buffer
            (url-retrieve-synchronously
             "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
             'silent 'inhibit-cookies)
          (goto-char (point-max))
          (eval-print-last-sexp)))
      (load bootstrap-file nil 'nomessage))



    ;; if not yet installed, install package use-package
    ;; (unless (package-installed-p 'use-package)
    ;;   (package-install 'use-package))

    ;; load org package and our emacs-config.org file
    ;; BEGIN hacky install org mode
    (require 'subr-x)
    (straight-use-package 'git)

    (defun org-git-version ()
      "The Git version of org-mode.
    Inserted by installing org-mode or when a release is made."
      (require 'git)
      (let ((git-repo (expand-file-name
                       "straight/repos/org/" user-emacs-directory)))
        (string-trim
         (git-run "describe"
                  "--match=release\*"
                  "--abbrev=6"
                  "HEAD"))))

    (defun org-release ()
      "The release version of org-mode.
    Inserted by installing org-mode or when a release is made."
      (require 'git)
      (let ((git-repo (expand-file-name
                       "straight/repos/org/" user-emacs-directory)))
        (string-trim
         (string-remove-prefix
          "release_"
          (git-run "describe"
                   "--match=release\*"
                   "--abbrev=0"
                   "HEAD")))))

    (provide 'org-version)

    (straight-use-package 'org-plus-contrib) ; or org-plus-contrib if desired
    ;; END hacky install org mode
    (org-babel-load-file "~/.emacs.d/emacs-config.org")
#+end_src
** changes to vanilla emacs
#+begin_src emacs-lisp
    ;; Package configs
    ;; (require 'package)
    (require 'cl)
    ;; (package-initialize)

    (display-time)
    (blink-cursor-mode 0)
    (fset 'yes-or-no-p 'y-or-n-p)
    (setq ring-bell-function 'ignore)
    ;; don't stop in instrumented forms unless there is a breakpoint
    ;; enables things working normally even after instrumenting but allowing you to stop somewhere specific w/ a breakpoint
    ;; eh need to revisit this and see if it's what I actually want
    (setq edebug-initial-mode 'go)

    ;; org mode large files super slow without doing this
    (setq-default bidi-paragraph-direction nil)
    ;; make things I copy in my OS be pushed into the emacs kill-ring searchable by helm-show-kill-ring
    (setq save-interprogram-paste-before-kill t)

    ;; fix term mode stuff
    (eval-after-load "term"
      '(progn
         ;; Fix forward/backward word when (term-in-char-mode).
         (define-key term-raw-map (kbd "<M-left>")
           (lambda () (interactive) (term-send-raw-string "\eb")))
         (define-key term-raw-map (kbd "<M-left>")
           (lambda () (interactive) (term-send-raw-string "\eb")))
         (define-key term-raw-map (kbd "<C-right>")
           (lambda () (interactive) (term-send-raw-string "\ef")))
         (define-key term-raw-map (kbd "<M-right>")
           (lambda () (interactive) (term-send-raw-string "\ef")))
         ;; Disable killing and yanking in char mode (term-raw-map).
         (mapc
          (lambda (func)
            (eval `(define-key term-raw-map [remap ,func]
                     (lambda () (interactive) (ding)))))
          '(backward-kill-paragraph
            backward-kill-sentence backward-kill-sexp backward-kill-word
            bookmark-kill-line kill-backward-chars kill-backward-up-list
            kill-forward-chars kill-line kill-paragraph kill-rectangle
            kill-region kill-sentence kill-sexp kill-visual-line
            kill-whole-line kill-word subword-backward-kill subword-kill
            yank yank-pop yank-rectangle))))

    (if (display-graphic-p)
        (progn
          (scroll-bar-mode -1)
          (tool-bar-mode   -1)
          (tooltip-mode    -1)
          (menu-bar-mode   -1))
      (message "in terminal"))

    ;; used with helm-mark-ring
    (setq mark-ring-max 1000)

    ;; gpg stuff
    (setq epg-gpg-program "gpg2")
    (setf epa-pinentry-mode 'loopback) ;; necessary for this to work with osx/emacs

    ;; enable winner-mode
    (when (fboundp 'winner-mode)
      (winner-mode 1))

    (global-auto-revert-mode)
    ;; Also auto refresh dired, but be quiet about it
    (setq global-auto-revert-non-file-buffers t)
    (setq auto-revert-verbose nil)

    (add-to-list 'default-frame-alist '(width . 80))
    ;; always follow symlinks and DONT PROMPT ME
    (setq vc-follow-symlinks t)

    ;; Other configs
  (setq backup-by-copying t      ; don't clobber symlinks
        backup-directory-alist '(("." . "~/.emacs-saves/"))    ; don't litter my fs tree
        delete-old-versions t
        kept-new-versions 6
        kept-old-versions 2
        version-control t)       ; use versioned backups
  (setq auto-save-file-name-transforms
        `((".*" "~/.emacs-saves/" t)))

    ;; Splash Screen
    (setq inhibit-startup-screen t)
    (setq initial-scratch-message nil)

    ;; Show matching parens
    (setq show-paren-delay 0)
    (show-paren-mode  1)

    ;; make sure windows always split vertically (hopefully I actually want this)
    ;; I definitely don't want it with split width threshold 0
    ;; (setq split-height-threshold nil
    ;;       split-width-threshold 0)

  ;; never have trailing whitespace again
  ;; TODO put on idle timer instead of before-save-hook
  ;; (add-hook 'before-save-hook 'delete-trailing-whitespace)
#+end_src
** emacs on mobile
*** modify HOME so files are where expected on mobile
#+begin_src emacs-lisp
  ;; *NOTE* must be at bottom or breaks other loading processes somehow
  ;; if we are in termux for android devices set HOME to sdcard
  ;; because that's where my org folder will be
  (when (file-exists-p "/data/data/com.termux/files/usr/bin/termux-info")
    (message "**NOTE** detected termux... automatically setting HOME for emacs")
    (setenv "HOME" "/data/data/com.termux/files/home/storage/shared"))
#+end_src
*** don't use symlinks with straight because of permission errors
#+begin_src emacs-lisp
  (when (file-exists-p "/data/data/com.termux/files/usr/bin/termux-info")
    (setq straight-use-symlinks nil))
#+end_src
** use straight package manager
#+begin_src emacs-lisp
  (setq straight-use-package-by-default t)
  (straight-use-package 'use-package)
#+end_src
** highlight our lines by default
#+begin_src emacs-lisp
(global-hl-line-mode +1)
#+end_src
** make the modeline nicer
*** the actual modeline
#+begin_src emacs-lisp
    ;; (defun shackra/task-clocked-time ()
    ;;   "Return a string with the clocked time and effort, if any"
    ;;   (interactive)
    ;;   (if (and org-mode-line-string (> (length org-mode-line-string) 3))
    ;;       (let* ((clocked-time (org-clock-get-clocked-time))
    ;;              (h (floor clocked-time 60))
    ;;              (m (- clocked-time (* 60 h)))
    ;;              (work-done-str (org-minutes-to-clocksum-string m))
    ;;              (heading-length-or-forty (if (< 40 (length org-clock-heading)) 40 (length org-clock-heading)))
    ;;              (org-clock-heading-substring (substring org-clock-heading 0 heading-length-or-forty))
    ;;              (maybe-add-ellipses-to-heading (if (< 40 (length org-clock-heading))  (format "%s..." org-clock-heading-substring) org-clock-heading-substring))
    ;;              ;; TODO only add elllipses if string longer than 40
    ;;              (clock-heading-summarized maybe-add-ellipses-to-heading )
    ;;              )
    ;;         (if org-clock-effort
    ;;             (let* ((effort-in-minutes
    ;;                     (org-duration-string-to-minutes org-clock-effort))
    ;;                    (effort-h (floor effort-in-minutes 60))
    ;;                    (effort-m (- effort-in-minutes (* effort-h 60)))
    ;;                    (effort-str (org-minutes-to-clocksum-string effort-m)))
    ;;               (format " [%s/%s (%s)]  " work-done-str effort-str clock-heading-summarized))
    ;;           (format " [%s (%s)]   " work-done-str clock-heading-summarized)))
    ;;     ""))

  (with-eval-after-load 'subr-x
    (setq-default mode-line-buffer-identification
                  '(:eval (format-mode-line (propertized-buffer-identification (or (when-let* ((buffer-file-truename buffer-file-truename)
                                                                                               (prj (cdr-safe (project-current)))
                                                                                               (prj-parent (file-name-directory (directory-file-name (expand-file-name prj)))))
                                                                                     (concat (file-relative-name (file-name-directory buffer-file-truename) prj-parent) (file-name-nondirectory buffer-file-truename)))
                                                                                   "%b"))))))

    (setq-default mode-line-format
                  (list
                   " " mode-line-modified
                   ;; day and time
                   '(:eval (propertize (format-time-string "  %b %d %R ")
                                       'face 'font-lock-builtin-face))

                   ;; '(:eval (propertize (substring vc-mode 5)
                   ;;                     'face 'font-lock-comment-face))

                   ;; line and column
                   ;; " (" ;; '%02' to set to 2 chars at least; prevents flickering
                   mode-line-buffer-identification
                   ;; (propertize "%02l" 'face 'font-lock-keyword-face) ","
                   ;; (propertize "%02c" 'face 'font-lock-keyword-face)
                   ;; ") "

                 ;; '(:eval (propertize (shackra/task-clocked-time)
                 ;;                     'face 'font-lock-builtin-face))

                   ;; '(:eval (propertize (shackra/task-clocked-time)
                   ;;                     'face 'font-lock-builtin-face))
                   ;; '(:eval (propertize (substring org-mode-line-string 1)
                   ;;                     'face 'font-lock-builtin-face))

                   ;; spaces to align right
                   ;; '(:eval (propertize
                   ;;          " " 'display
                   ;;          `((space :align-to (- (+ right right-fringe right-margin)
                   ;;                                ,(+ 3 (string-width mode-name)))))))

                   ;; the current major mode
                   (propertize " %m " 'face 'font-lock-string-face)
                   ;;minor-mode-alist
                   ;;  (propertize minor-mode-list 'face 'font-lock-string-face)
                   ))
#+end_src
*** some hooks to keep info accurate
#+begin_src emacs-lisp
  (add-hook 'org-clock-in-hook
            '(lambda ()
               (force-mode-line-update)))
  (add-hook 'org-clock-cancel-hook
            '(lambda ()
               (setq org-mode-line-string nil)
               (force-mode-line-update)))
  (add-hook 'org-clock-out-hook
            '(lambda ()
               (setq org-mode-line-string nil)
               (force-mode-line-update)))
#+end_src
* Ensure critical environment specific files exist
** load bash profile (most for env vars)
#+begin_src emacs-lisp
  (use-package exec-path-from-shell
    :init (setq exec-path-from-shell-variables '("PATH" "MANPATH" "EMACSFOR"))
    :config
    (exec-path-from-shell-initialize))
#+end_src
** Ensure work.el exists and we can load it
*** why?
**** lots of work specific snippets, authinfo, etc needs to be loaded for emacs for work tot be loaded as we expect it
*** try loading it
#+begin_src emacs-lisp
  (pcase (getenv "EMACSFOR")
    ("WORK" (load (expand-file-name "work.el" "~")))
    ("PERSONAL" (load (expand-file-name "personal.el" "~")))
    (_ (error "Please set the EMACSFOR variable to WORK or PERSONAL")))
#+end_src
** ensure personal.el and personal org files are added above
* Setup keybindings with general
#+begin_src emacs-lisp
  (use-package general
    :init
    (defun my-day-org-agenda ()
      (interactive)
      (let ((org-agenda-span 'day))
        (org-agenda nil "a")
        (progn (switch-to-buffer "*Org Agenda*") (delete-other-windows))
        ))
    :config
    (general-evil-setup)
    (general-imap "j"
      (general-key-dispatch 'self-insert-command
        :timeout 0.25
        ;; TODO make this work so jf writes the file when I enter normal mode
        ;; "j" '(my-write-then-normal-state)
        "f" 'evil-normal-state))

    ;; TODO review if this is good or not
    (general-nmap "/" 'evil-search-forward) ;; TODO can we modify this so that the search is done by rg?
    ;; TODO upgrade to helm-rg-this-file

    ;; TODO do we just want to use alphappas https://github.com/alphapapa/helm-swish/blob/master/helm-swish.el ???
    ;; https://github.com/cosmicexplorer/helm-rg/issues/12
    ;; (general-nmap "/" 'helm-ag-this-file) ;; doesn't have swoop like functionality

    (general-unbind 'org-agenda-mode-map
      "SPC")

    ;; (general-create-definer my-leader-def2
    ;;     :prefix "SPC")

    (general-create-definer my-leader-def
      :prefix "C")

    ;; (my-leader-def
    ;;   :states '(normal visual emacs motion)
    ;;   :prefix "SPC"
    ;;   :keymaps 'override
    ;;   "u"   '(evil-scroll-up :which-key "evil scroll up"))


    (my-leader-def
      :states '(normal visual emacs motion)
      :prefix "SPC"
      :keymaps 'override
      :non-normal-prefix "M-SPC"
      "u"   '(universal-argument :which-key "universal-argument")
      "pg"   '(helm-projectile-rg :which-key "ripgrep")
      "<tab>" '(switch-to-prev-buffer :which-key "previous buffer")
      "SPC" '(helm-M-x :which-key "M-x")
      "tf" '(spacemacs/toggle-frame-fullscreen-non-native :which-key "Full Screen")
      "pf"  '(helm-projectile-find-file :which-key "find files")
      "jc"  '(avy-goto-char :which-key "Jump To Char")
      "jj"  '(avy-goto-char-timer :which-key "Jump To Char")
      "ji"  '(avy-goto-char-in-line :which-key "Jump To Char In Line")
      "jl"  '(avy-goto-line :which-key "Jump To line")
      "pp"  '(helm-projectile-switch-project :which-key "switch project")
      "pb"  '(helm-projectile-switch-to-buffer :which-key "switch buffer")
      "pr"  '(helm-show-kill-ring :which-key "show kill ring")
      ;; applications (TODO maybe consider making =ao= variants of org again here)
      "ad"  '(dired :which-key "open dired")
      "iu" '(my/org-web-tools-insert-link-for-url :which-key "insert link for url in clipboard")
      "oo"  '(org-agenda :which-key "open org agenda") ;; previously aoo
      "od"  '(my-day-org-agenda :which-key "open todays org agenda")
      "oa"  '(org-agenda-list :which-key "open org agenda list") ;; previously aoa
      "ol"  '(org-store-link :which-key "store org link") ;; previously aol
      "os"  '(org-mru-clock-in :which-key "clock into recently clocked task") ;; previously aorr
      "or"  '(helm-org-rifle :which-key "helm org rifle") ;; previously aorr
      ;; "oh"  '(org-recent-headings :which-key "org recent headings")
      ;; rifle current buffer
      ;; rifle directories
      ;; rifle files

      ;; c
      "cc"  '(helm-org-capture-templates :which-key "org-capture")

      ;; E (ediff)
      "Eb"  '(ediff-buffers :which-key "ediff buffers")
      ;; magit
      "gb" '(magit-blame :which-key "magit blame")
      "gf" '(magit-find-file :which-key "magit find-file")
      "gg" '(helm-do-grep-ag :which-key "helm ag (rg)")
      "gl" '(magit-log-buffer-file :which-key "magit log file")
      "gs" '(magit-status :which-key "magit status")
      "gt" '(magit-log-trace-definition :which-key "magit trace definition")
      "hg" '(helm-mark-ring :which-mode "helm mark ring (where was I?)")
      "hr" '(helm-resume :which-mode "helm resume")
      ;; help
      "hdm" '(describe-mode :which-mode "describe mode")
      ;; TODO might need to move these into helpful use-package :config
      "hdk" '(helpful-key :which-key "describe key")
      "hdv" '(helpful-variable :which-key "describe variable")
      "hdf" '(helpful-callable :which-key "describe function")
      "hdd" '(helm-apropos :which-key "apropos at point")
      ;; Buffers
      "bb"  '(helm-mini :which-key "buffers list")
      ;; "bs"  '(my-switch-to-scratch-buffer :which-key "scratch buffer")
      ;; "bs"  '((switch-to-buffer "*scratch*") :which-key "scratch buffer")
      "bd"  '(spacemacs/kill-this-buffer :which-key "kill-this-buffer")
      ;; Search
      "sS"  '(helm-swoop :which-key "helm-swoop")
      "ss"  '(spacemacs/helm-swoop-region-or-symbol :which-key "helm-swoop-region-or-symbol")
      ;; Window
      ;; TODO install winum (https://github.com/deb0ch/emacs-winum) and use emacs keybindings
      ;; so I can navigate with SPC N

      ;; TODO whats difference between windmove and evil-windowmove????
      ;; "wl"  '(windmove-right :which-key "move right")
      ;; "wm"  '(toggle-maximize-buffer :which-key "maximize buffer")
      ;; "wd"  '(delete-window :which-key "delete window")
      ;; "wh"  '(windmove-left :which-key "move left")
      ;; "wk"  '(windmove-up :which-key "move up")
      ;; "wj"  '(windmove-down :which-key "move bottom")
      "wl"  '(evil-window-move-far-right :which-key "move right")
      "wm"  '(toggle-maximize-buffer :which-key "maximize buffer")
      "wu"  '(winner-undo :which-key "winner undo")
      "wr"  '(winner-redo :which-key "winner redo")
      "wd"  '(delete-window :which-key "delete window")
      "wh"  '(evil-window-move-far-left :which-key "move left")
      "wk"  '(evil-window-move-very-top :which-key "move up")
      "wj"  '(evil-window-move-very-bottom :which-key "move bottom")

      "w/"  '(split-window-right :which-key "split right")
      "0" '(winum-select-window-0 :which-key "window 0")
      "1" '(winum-select-window-1 :which-key "window 1")
      "2" '(winum-select-window-2 :which-key "window 2")
      "3" '(winum-select-window-3 :which-key "window 3")
      "4" '(winum-select-window-4 :which-key "window 4")
      "5" '(winum-select-window-5 :which-key "window 5")
      "6" '(winum-select-window-6 :which-key "window 6")
      "7" '(winum-select-window-7 :which-key "window 7")
      "8" '(winum-select-window-8 :which-key "window 8")
      "9" '(winum-select-window-8 :which-key "window 9")
      "w-"  '(split-window-below :which-key "split bottom")
      "wx"  '(delete-window :which-key "delete window")
      "l"  '(tab-bar-select-tab :which-key "switch perspective")
      "qz"  '(delete-frame :which-key "delete frame")
      "qq"  '(save-buffers-kill-emacs :which-key "quit")
      ;; NeoTree
      "ft"  '(neotree-toggle :which-key "toggle neotree")
      ;; find files
      "ff"  '(helm-find-files :which-key "find files")
      ;; Others
      "at"  '(shell :which-key "open terminal")
      "ae"  '(eshell :which-key "open eshell")
      "cl" '(comment-line :which-key "comment line")
      "fed" '(find-dotfile :which-key "go to init.el")
      "tl" '(toggle-truncate-lines :which-key "truncate lines")
      ;; ehh not sure about this but okay
      "tw" '(whitespace-mode :which-key "show whitespace")
      ;; global org
      "ocj"  '(org-clock-goto :which-key "jump to current clock")
      "ocl"  '(org-clock-in-last :which-key "clock in last task")
      "o$"   '(my/org-refile-to-archive-datetree :which-key "archive to done.org datetree")

      ;; org refiling (takes top-level because i'll use it lots I think)
      "r"  '(org-refile :which-key "refile an org task")
      )
    (general-define-key
     "M-x" 'helm-M-x)
    ;; TODO are these the right modes???
    (general-evil-define-key '(normal visual) emacs-lisp-mode-map
      :prefix ","
      "ef" 'eval-defun :which-key "eval defun"
      "eb" 'eval-buffer :which-key "eval buffer"
      "er" 'eval-region :which-key "eval region")

    ;; TODO are these the right modes???
    (general-evil-define-key '(normal motion override visual) org-babel-map
      :prefix ","
      "x" 'emacs-version
      ;; "bt" 'org-babel-tangle :which-key "bable tangle" ;; that doesn't work
      "," 'org-ctrl-c-ctrl-c :which-key "execute babel block")


    (general-evil-define-key '(normal motion override) org-src-mode-map
      :prefix ","
      "," 'org-edit-special ;; doesn't work
      )

      (general-evil-define-key 'normal org-mode-map
        "RET" 'org-open-at-point :which-key "org open at point")

      (defun codygman/org-ctrl-c-and-go-to-result ()
        (org-ctrl-c-ctrl-c)
        (goto-char (org-babel-where-is-src-block-result)))

      (defun codygman/pad-then-insert-link ()
        ;; TODO this is too naieve and messes up modifying links (see heading I think I made)
        (interactive)
        (evil-insert 1)
        (insert "  ")
        (evil-normal-state)
        (call-interactively 'org-insert-link))

      (use-package org-download
        :after cl
        :config
        (setq org-image-actual-width nil) ;; think necessary for 500 to take effect
        (setq org-download-image-org-width 400)
        (setq org-download-annotate-function 'ignore)
        (setq org-download-annotate-function (lambda (_link) ""))

        (setq org-download-screenshot-method
              (case system-type (gnu/linux "import %s") (darwin "screencapture -i %s")))
        (setq-default org-download-image-dir "~/org/images/screenshots/")
        (add-hook 'dired-mode-hook 'org-download-enable))

      (general-evil-define-key 'normal org-mode-map
        :prefix ","
        "ds" 'org-schedule :which-key "schedule"
        "dd" 'org-deadline :which-key "schedule"

        "ci" 'org-clock-in :which-key "clock in"
        "co" 'org-clock-out :which-key "clock out"
        "cc" 'org-clock-cancel :which-key "clock cancel"
        "tt" 'org-todo :which-key "org todo"
        ;; "C-c C-c" 'codygman/org-ctrl-c-and-go-to-result :which-key "execute code block and go to result"

        "ts" 'org-download-screenshot :which-key "org download screenshot"

        ;; insert
        "iB" 'org-insert-structure-template :which-key "insert org block"
        "ib" 'insert-previous-src-block-below :which-key "insert previous org src block"
        "tc" 'org-table-create :which-key "org table create"
        "it" 'air-org-set-tags :which-key "org set tags"
        "is" 'my-org-insert-subheading :which-key "org insert subheading"
        "ic" 'yas-insert-snippet :which-key "insert yasnippet code"
        "iS" 'my-org-insert-subheading-then-normal :which-key "org insert subhead then normal"
        "il" 'codygman/pad-then-insert-link :which-key "org insert link"
        "ip" 'org-set-property :which-key "org set property"
        "ie" 'org-set-effort :which-key "org set effort"

        "sh" 'org-promote-subtree :which-key "promote subtree-left"
        "sj" 'org-move-subtree-down :which-key "subtree-down"
        "sk" 'org-move-subtree-up :which-key "subtree-up"
        "sl" 'org-demote-subtree :which-key "demote subtree-right"
        "sn" 'org-narrow-to-subtree :which-key "org narrow"
        "sN" 'widen :which-key "org widen"
        "sa" '(org-archive-subtree :which-key "org archive")
        "se" '(org-babel-execute-subtree :which-key "org babel execute subtree ")
        "sb" 'org-tree-to-indirect-buffer :which-key "org tree to indirect buffer"
        "sr"  '(org-refile :which-key "org refile")
        "#" 'org-update-statistics-cookies :which-key "org-update-statistics-cookies")

      (general-evil-define-key '(normal override motion) org-agenda-mode-map
        "D" 'org-agenda-day-view :which-key "day view"
        "L" 'org-agenda-log-mode :which-key "org agenda log mode"))
#+end_src
* Theme
:PROPERTIES:
:ID:       d8dd34aa-e42b-4269-a087-83348b380b26
:END:
#+begin_src emacs-lisp
  ;; (use-package doom-themes
  ;; :if (not window-system)
  ;; :config
  ;; (setq frame-background-mode 'dark)
  ;; (load-theme 'doom-one t)
  ;; )

  (use-package solarized-theme ;; doom-themes
    :defer t
    :if window-system
    :init
    (defun codygman/solarized-theme-modifications (&rest args)
      (set-cursor-color "#b58900")
      )
    (advice-add 'load-theme :after 'codygman/solarized-theme-modifications)
    ;; variable pitch prettier fonts for org mode, see: https://zzamboni.org/post/beautifying-org-mode-in-emacs/
    (set-face-attribute 'default nil :family "Source Code Pro" :height 160 :width 'normal)
    (set-face-attribute 'fixed-pitch nil :family "Source Code Pro" :height 140 :width 'normal)
    (set-face-attribute 'variable-pitch nil :family "Source Sans Pro" :height 160 :weight 'medium)
    (set-face-attribute 'org-table nil :inherit 'fixed-pitch) ;; here or org?
    ;; all org blocks should be fixed-width NOTE: For source-blocks ‘org-src-block-faces’ takes precedence.
    (set-face-attribute 'org-block nil :inherit 'fixed-pitch)
    (load-theme 'solarized-dark t)
    :config
    (defun set-buffer-variable-pitch()
      (interactive)
      (variable-pitch-mode t)
      (setq line-spacing 3)
      )
    :hook ((eww-mode . set-buffer-variable-pitch) ;; not sure this one works
           (org-mode . set-buffer-variable-pitch)
           (Info-mode . set-buffer-variable-pitch)
           (markdown-mode . set-buffer-variable-pitch)
           )
    )
#+end_src
* Package install and configuration
** dashboard
:PROPERTIES:
:ID:       e6559479-4ac3-4ac0-87d5-ffbf9e826bc0
:END:
#+begin_src emacs-lisp
    (use-package dashboard
      :config
      (setq dashboard-startup-banner nil)
      (defun dashboard-insert-custom (list-size)
        (insert "Custom text"))
      (setq dashboard-items '())
      (add-to-list 'dashboard-item-generators  '(custom . dashboard-insert-custom))
      (add-to-list 'dashboard-items '(custom) t)
      (dashboard-setup-startup-hook)
      ;; elisp is sadly not performant enough for this
      (remove-hook 'window-size-change-functions 'dashboard-resize-on-hook)
  )
#+end_src
** fast-scroll
#+begin_src emacs-lisp
(straight-use-package
   '(fast-scroll :type git :host github :repo "ahungry/fast-scroll"))
(use-package fast-scroll
    :ensure nil
    :config
    (fast-scroll-mode)
    )
#+end_src
** dired
#+begin_src emacs-lisp
  ;; (use-package dired
  ;;   :ensure nil
  ;;   :defer t
  ;;   :config
  (eval-after-load 'dired
    (setq
     dired-listing-switches "-lath"
     dired-dwim-target t
     )
    )
#+end_src
#+begin_src emacs-lisp
    (defun ora-ediff-files ()
      (interactive)
      (let ((files (dired-get-marked-files))
            (wnd (current-window-configuration)))
        (if (<= (length files) 2)
            (let ((file1 (car files))
                  (file2 (if (cdr files)
                             (cadr files)
                           (read-file-name
                            "file: "
                            (dired-dwim-target-directory)))))
              (if (file-newer-than-file-p file1 file2)
                  (ediff-files file2 file1)
                (ediff-files file1 file2))
              (add-hook 'ediff-after-quit-hook-internal
                        (lambda ()
                          (setq ediff-after-quit-hook-internal nil)
                          (set-window-configuration wnd))))
          (error "no more than 2 files should be marked"))))

    ;; (define-key dired-mode-map "e" 'ora-ediff-files) ;; TODO this doesn't work in evil-collection!
    ;; TODO should rebind = to make it evil way
#+end_src
** evil
*** install and configure
#+begin_src emacs-lisp
  (use-package evil
    :init
    (setq evil-want-keybinding nil)
(when (file-exists-p "/data/data/com.termux/files/usr/bin/termux-info")
    (message "**NOTE** detected termux... disabling evil C-i jump")
    (setq evil-want-C-i-jump nil)
    )
    (setq evil-want-C-u-scroll t)
    ;; make * over a symbol look for other instances
    (setq evil-symbol-word-search t)
    :config
    (evil-set-initial-state 'org-agenda-mode 'normal)
    (evil-mode 1))
#+end_src
*** org-evil
#+begin_src emacs-lisp
  (use-package org-evil :after (evil org)
    :config
    (progn
      (add-hook 'org-mode-hook 'org-evil-mode))
(with-eval-after-load 'evil-maps
  (define-key evil-motion-state-map (kbd "SPC") nil)
  (define-key evil-motion-state-map (kbd "RET") nil)
  (define-key evil-motion-state-map (kbd "TAB") nil))
)
#+end_src
*** evil magit
#+begin_src emacs-lisp
(use-package evil-magit :after (evil magit))
#+end_src
*** evil-collection
#+begin_src emacs-lisp
  (use-package evil-collection
    :after evil
    :init
    (setq evil-collection-outline-bind-tab-p nil)
    :config
    (evil-collection-init))
#+end_src
** gnuplot
#+begin_src emacs-lisp
  (use-package gnuplot)
#+end_src
** org
*** org is installed in [[file:init.el::(straight-use-package%20'org-plus-contrib)%20;%20or%20org-plus-contrib%20if%20desired][init.el]]
**** so that we can use newest org version to tangle config
**** that will hopefully be faster ;)
*** install and configure org
:PROPERTIES:
:ID:       2b9462d8-1dc7-4bda-a2b3-4bbd4757f437
:END:
#+begin_src emacs-lisp
  (use-package org
    :straight org-plus-contrib
    :after 'ob-restclient
    :init
    (set-face-attribute 'org-table nil :inherit 'fixed-pitch)
    (setq org-modules '(org-habit org-id org-protocol org-timer)
          org-id-link-to-org-use-id 'create-if-interactive)
    ;; org font setup
    (custom-set-faces
     ;; custom-set-faces was added by Custom.
     ;; If you edit it by hand, you could mess it up, so be careful.
     ;; Your init file should contain only one such instance.
     ;; If there is more than one, they won't work right.
     '(org-level-1 ((t (:inherit variable-pitch :foreground "violet" :height 1.3))))
     '(org-tag ((t (:weight thin :foreground "#586e75"))))
     '(org-special-keyword ((t (:weight thin :foreground "#586e75"))))
     )

    ;; end org font setup
    (setq org-startup-with-inline-images t)
    (setq org-hide-emphasis-markers t)
    (setq org-file-apps '((auto-mode . emacs)
                          (directory . emacs)
                          ("\\.log\\'" . emacs)
                          ("\\.mm\\'" . default)
                          ("\\.x?html?\\'" . firefox) ;; doesn't work?
                          ("\\.pdf\\'" . default)))
    ;; makes org tags searches indicate heading hierarchy by indenting with dots
    (setq org-tags-match-list-sublevels 'indented)
    (setq org-modules (add-to-list 'org-modules 'org-habit))
    (org-babel-do-load-languages
     'org-babel-load-languages
     '(
       (haskell . t)
       (ledger . t)
       (gnuplot . t)
       ;; (dot . t)
       (js . t)
       (shell . t)
       ;; (mongo . t) ;; TODO put mongo back
       (restclient . t)
       (sqlite . t)
       (sql . t)))

    (with-eval-after-load 'evil
      (defun my-org-insert-subheading (arg)
        "Insert a new subheading and demote it.
                          Works for outline headings and for plain lists alike."
        (interactive "P")
        (evil-end-of-line) ;; go to end of line first
        (evil-append-line 1)
        (insert " ")
        (org-insert-subheading 1))
      )
    (defun my/org-capture-place-entry ()
      "Place the template as a new Org entry."
      (let ((template (org-capture-get :template))
            (reversed? (org-capture-get :prepend))
            (exact-position (org-capture-get :exact-position))
            (insert-here? (org-capture-get :insert-here))
            (level 1))
        (org-capture-verify-tree template)
        (when exact-position (goto-char exact-position))
        (cond
         ;; Force insertion at point.
         ((org-capture-get :insert-here) nil)
         ;; Insert as a child of the current entry.
         ((org-capture-get :target-entry-p)
          (setq level (org-get-valid-level
                       (if (org-at-heading-p) (org-outline-level) 1)
                       1))
          (if reversed? (outline-next-heading) (org-end-of-subtree t t)))
         ;; Insert as a top-level entry at the beginning of the file.
         (reversed?
          (goto-char (point-min))
          (unless (org-at-heading-p) (outline-next-heading)))
         ;; Otherwise, insert as a top-level entry at the end of the file.
         (t (goto-char (point-max))))
        (let ((origin (point)))
          (unless (bolp) (insert "\n"))
          (org-capture-empty-lines-before)
          (let ((beg (point)))
            (save-restriction
              (when insert-here? (narrow-to-region beg beg))
              (org-paste-subtree level template 'for-yank))
            (org-capture-position-for-last-stored beg)
            (let ((end (point)))
              (org-capture-empty-lines-after)
              (unless (org-at-heading-p) (outline-next-heading))
              (org-capture-mark-kill-region origin (point))
              (if (org-capture-get :clock-in) (insert "\n"))
              (org-capture-narrow beg end)
              (when (or (search-backward "%?" beg t)
                        (search-forward "%?" end t))
                (replace-match "")))))))
    ;; remove trailing whitespace after clocking in
    (defun my/org-capture (&optional goto keys)
      "Capture something.
  \\<org-capture-mode-map>
  This will let you select a template from `org-capture-templates', and
  then file the newly captured information.  The text is immediately
  inserted at the target location, and an indirect buffer is shown where
  you can edit it.  Pressing `\\[org-capture-finalize]' brings you back to the \
  previous
  state of Emacs, so that you can continue your work.

  When called interactively with a `\\[universal-argument]' prefix argument \
  GOTO, don't
  capture anything, just go to the file/headline where the selected
  template stores its notes.

  With a `\\[universal-argument] \\[universal-argument]' prefix argument, go to \
  the last note stored.

  When called with a `C-0' (zero) prefix, insert a template at point.

  When called with a `C-1' (one) prefix, force prompting for a date when
  a datetree entry is made.

  ELisp programs can set KEYS to a string associated with a template
  in `org-capture-templates'.  In this case, interactive selection
  will be bypassed.

  If `org-capture-use-agenda-date' is non-nil, capturing from the
  agenda will use the date at point as the default date.  Then, a
  `C-1' prefix will tell the capture process to use the HH:MM time
  of the day at point (if any) or the current HH:MM time."
      (interactive "P")
      (when (and org-capture-use-agenda-date
                 (eq major-mode 'org-agenda-mode))
        (setq org-overriding-default-time
              (org-get-cursor-date (equal goto 1))))
      (cond
       ((equal goto '(4)) (org-capture-goto-target))
       ((equal goto '(16)) (org-capture-goto-last-stored))
       (t
        (let* ((orig-buf (current-buffer))
               (annotation (if (and (boundp 'org-capture-link-is-already-stored)
                                    org-capture-link-is-already-stored)
                               (plist-get org-store-link-plist :annotation)
                             (ignore-errors (org-store-link nil))))
               (entry (or org-capture-entry (org-capture-select-template keys)))
               initial)
          (setq initial (or org-capture-initial
                            (and (org-region-active-p)
                                 (buffer-substring (point) (mark)))))
          (when (stringp initial)
            (remove-text-properties 0 (length initial) '(read-only t) initial))
          (when (stringp annotation)
            (remove-text-properties 0 (length annotation)
                                    '(read-only t) annotation))
          (cond
           ((equal entry "C")
            (customize-variable 'org-capture-templates))
           ((equal entry "q")
            (user-error "Abort"))
           (t
            (org-capture-set-plist entry)
            (org-capture-get-template)
            (org-capture-put :original-buffer orig-buf
                             :original-file (or (buffer-file-name orig-buf)
                                                (and (featurep 'dired)
                                                     (car (rassq orig-buf
                                                                 dired-buffers))))
                             :original-file-nondirectory
                             (and (buffer-file-name orig-buf)
                                  (file-name-nondirectory
                                   (buffer-file-name orig-buf)))
                             :annotation annotation
                             :initial initial
                             :return-to-wconf (current-window-configuration)
                             :default-time (or org-overriding-default-time
                                               (org-current-time)))
            (org-capture-set-target-location (and (equal goto 0) 'here))
            (condition-case error
                (org-capture-put :template (org-capture-fill-template))
              ((error quit)
               (if (get-buffer "*Capture*") (kill-buffer "*Capture*"))
               (error "Capture abort: %s" (error-message-string error))))

            (setq org-capture-clock-keep (org-capture-get :clock-keep))
            (condition-case error
                (org-capture-place-template
                 (eq (car (org-capture-get :target)) 'function))
              ((error quit)
               (when (and (buffer-base-buffer (current-buffer))
                          (string-prefix-p "CAPTURE-" (buffer-name)))
                 (kill-buffer (current-buffer)))
               (set-window-configuration (org-capture-get :return-to-wconf))
               (error "Capture template `%s': %s"
                      (org-capture-get :key)
                      (error-message-string error))))
            (when (and (derived-mode-p 'org-mode) (org-capture-get :clock-in))
              (condition-case nil
                  (progn
                    (when (org-clock-is-active)
                      (org-capture-put :interrupted-clock
                                       (copy-marker org-clock-marker)))
                    (org-clock-in)
                    (save-excursion (if (org-capture-get :clock-in)
                                        (progn (goto-char (point-max)) (join-line))))
                    (setq-local org-capture-clock-was-started t))
                (error "Could not start the clock in this capture buffer")))
            (when (org-capture-get :immediate-finish)
              (org-capture-finalize))))))))

    (advice-add 'org-capture-place-entry :override #'my/org-capture-place-entry)
    (advice-add 'org-capture :override #'my/org-capture)

    (defun my/clock-in-when-status-in-progress ()
      (when (and (string= org-state "IN-PROGRESS")
                 (not (string= org-last-state "IN-PROGRESS"))) (org-clock-in)))

    (add-hook 'org-after-todo-state-change-hook
              'my/clock-in-when-status-in-progress)

    (defun codygman/org-heading-clocked-in-p ()
      (if (org-clocking-p)
          (save-excursion
            (org-back-to-heading t)
            (and (or (equal (marker-buffer org-clock-hd-marker)
                            (current-buffer))
                     ;; TODO what about indirect buffers?
                     (string-match-p (format "%s" (marker-buffer org-clock-hd-marker))
                                     (format "CAPTURE-%s" (current-buffer))))
                 (= (marker-position org-clock-hd-marker)
                    (point))
                 (equal (substring-no-properties org-clock-current-task) (nth 4 (org-heading-components)))))))

    (defconst clock-out-states '("TODO" "DELEGATED" "SOMEDAY" "WAITING" "DONE" "CANCELLED"))
    (defun my/maybe-clock-out-when-status-moved ()
      (when  (and (and (member org-state clock-out-states)
                       (not (member org-last-state clock-out-states)))
                  (codygman/org-heading-clocked-in-p)) (org-clock-out)))

    (add-hook 'org-after-todo-state-change-hook
              'my/maybe-clock-out-when-status-moved)

    (defun my/maybe-change-status-in-progress-when-clocking-in ()
      (let ((todo-state
             (save-excursion
               (org-back-to-heading t)
               (org-entry-get nil "TODO")
               )))
        (when (not (string= todo-state "IN-PROGRESS"))
          (org-todo "IN-PROGRESS"))))

    (add-hook 'org-clock-in-hook
              'my/maybe-change-status-in-progress-when-clocking-in)

    (defun maybe-move-past-in-progress-status (&rest args)
      (ignore-errors (when (bound-and-true-p org-capture-mode)
                       (re-search-forward "PROGRESS")
                       (re-search-forward " "))))

    (advice-add 'org-clock-in :after #'maybe-move-past-in-progress-status)

    (defun my/maybe-change-status-todo-clocking-out ()
      (let ((todo-state
             (save-excursion
               (org-back-to-heading t)
               (org-entry-get nil "TODO")
               )))
        (when (not (member todo-state clock-out-states))
          (org-todo "TODO"))))

    (add-hook 'org-clock-out-hook
              'my/maybe-change-status-todo-clocking-out)
    )

  (use-package org-agenda
      :straight org-plus-contrib
      :config
      (setq org-agenda-bulk-custom-functions
            `((?D (lambda () (call-interactively 'org-agenda-date-later)))
              ,@org-agenda-bulk-custom-functions)))
#+end_src
*** my custom org functions
#+begin_src emacs-lisp
  (defun my/org-agenda-mark-habits ()
    "Mark all habits in current agenda for graph display.

         This function enforces `my/org-habit-show-graphs-everywhere' by
         marking all habits in the current agenda as such.  When run just
         before `org-agenda-finalize' (such as by advice; unfortunately,
         `org-agenda-finalize-hook' is run too late), this has the effect
         of displaying consistency graphs for these habits.

         When `my/org-habit-show-graphs-everywhere' is nil, this function
         has no effect.

  https://emacs.stackexchange.com/a/17328/16972
  "
    (when (and my/org-habit-show-graphs-everywhere
               (not (get-text-property (point) 'org-series)))
      (let ((cursor (point))
            item data)
        (while (setq cursor (next-single-property-change cursor 'org-marker))
          (setq item (get-text-property cursor 'org-marker))
          (when (and item (org-is-habit-p item))
            (with-current-buffer (marker-buffer item)
              (setq data (org-habit-parse-todo item)))
            (put-text-property cursor
                               (next-single-property-change cursor 'org-marker)
                               'org-habit-p data))))))

  (setq my/org-habit-show-graphs-everywhere t)
  (setq org-habit-show-habits-only-for-today t)
#+end_src
*** my org overrides
#+begin_src emacs-lisp
    (with-eval-after-load "ob-shell"

      (defun my-pass-it-on-filter (filePath proc str)
        "Process each line produced by PROC in STR."
        (interactive)
        (when (buffer-live-p (process-buffer proc))
          (with-current-buffer (process-buffer proc)
            (insert str)
            (goto-char (point-min))
            (while (progn (skip-chars-forward "^\n")
                          (not (eobp)))
              (ignore-errors
                (let ((result (delete-and-extract-region (point-min) (point))))
                  (delete-char 1)
                  ;; (message (format "writing result '%s' w/newline to %s" result filePath))
                  (when (not (file-exists-p filePath))
                    (write-region "" nil filePath))
                  (write-region (concat result "\n") nil filePath 'append)
                  result))))))

      (defun get-parent-heading-title ()
        (ignore-errors
          (save-excursion
            (org-evil-motion-up-heading)
            (org-element-property :title (org-element-at-point)))))

      (defun get-grandparent-heading-title ()
        (ignore-errors
          (save-excursion
            (org-evil-motion-up-heading)
            (org-evil-motion-up-heading)
            (org-element-property :title (org-element-at-point)))))

      (defun get-great-grandparent-heading-title ()
        (ignore-errors
          (save-excursion
            (org-evil-motion-up-heading)
            (org-evil-motion-up-heading)
            (org-evil-motion-up-heading)
            (org-element-property :title (org-element-at-point)))))

      (defun cleanup-dir-name (dir)
        (replace-regexp-in-string " " "-" dir))

      (defun my-create-non-existent-directory ()
        (let ((parent-directory (file-name-directory buffer-file-name)))
          (when (not (file-exists-p parent-directory))
            (make-directory parent-directory t))))

      (defun generate-automatic-log-name ()
        ;; TODO make this take the parent org element and use its heading text in this log name
        (let* ((time-with-millis (format-time-string "%H.%M.%S.%3N"))
               (year-month-day (format-time-string "%Y-%m-%d"))
               (parent-element-title (get-parent-heading-title))
               (grandparent-element-title (get-grandparent-heading-title))
               (great-grandparent-element-title (get-great-grandparent-heading-title))
               (descriptive-string (if (> 20 (length parent-element-title)) (format "%s_%s" grandparent-element-title parent-element-title) parent-element-title))
               (descriptive-string-2 (if (> 20 (length descriptive-string)) (format "%s_%s" great-grandparent-element-title descriptive-string) descriptive-string))
               (descriptive-string-safe (cleanup-dir-name descriptive-string-2))
               (file-path (format "/Users/codygman/console/%s/%s.%s.%s.log" year-month-day descriptive-string-safe year-month-day time-with-millis))
               (directory-path (file-name-directory file-path)))
          ;; create directory if it doesn't exist
          (when (not (file-exists-p directory-path))
            (make-directory directory-path t))
          ;; use log extension since I know those links will open in emacs
          file-path))

  (defun org-babel-kill-session ()
        "Kill session for current code block."
        (interactive)
        (unless (org-in-src-block-p)
          (error "You must be in a src-block to run this command"))
        (save-window-excursion
          (org-babel-switch-to-session)
          (kill-buffer)))
  )

      (defun directory-to-write-progress (params)
        ;; if params has :log then autogenerate based on date, time, and immediate parent heading text
        (cond
         ((assq :autolog params)
          (message "autolog present, generating automatic log path and populating :file")
          (generate-automatic-log-name))
         ((cdr (assq :file params))
          (message "no autolog just returning :file specified")
          (cdr (assq :file params)))
         (t
          (message "no :file or :autolog returning nil")
          nil)))

      (defun src-block-in-session-p (&optional name)
        "Return if src-block is in a session of NAME.
          NAME may be nil for unnamed sessions."
        (let* ((info (org-babel-get-src-block-info))
               (lang (nth 0 info))
               (body (nth 1 info))
               (params (nth 2 info))
               (session (cdr (assoc :session params))))

          (cond
           ;; unnamed session, both name and session are nil
           ((and (null session)
                 (null name))
            t)
           ;; Matching name and session
           ((and
             (stringp name)
             (stringp session)
             (string= name session))
            t)
           ;; no match
           (t nil))))

      (defun org-babel-kill-session ()
        "Kill session for current code block."
        (interactive)
        (unless (org-in-src-block-p)
          (error "You must be in a src-block to run this command"))
        (save-window-excursion
          (org-babel-switch-to-session)
          (kill-buffer)))


      (defun org-babel-restart-session-to-point (&optional arg)
        "Restart session up to the src-block in the current point.
          Goes to beginning of buffer and executes each code block with
          `org-babel-execute-src-block' that has the same language and
          session as the current block. ARG has same meaning as in
          `org-babel-execute-src-block'."
        (interactive "P")
        (unless (org-in-src-block-p)
          (error "You must be in a src-block to run this command"))
        (let* ((current-point (point-marker))
               (info (org-babel-get-src-block-info))
               (lang (nth 0 info))
               (params (nth 2 info))
               (session (cdr (assoc :session params))))
          (save-excursion
            (goto-char (point-min))
            (while (re-search-forward org-babel-src-block-regexp nil t)
              ;; goto start of block
              (goto-char (match-beginning 0))
              (let* ((this-info (org-babel-get-src-block-info))
                     (this-lang (nth 0 this-info))
                     (this-params (nth 2 this-info))
                     (this-session (cdr (assoc :session this-params))))
                (when
                    (and
                     (< (point) (marker-position current-point))
                     (string= lang this-lang)
                     (src-block-in-session-p session))
                  (org-babel-execute-src-block arg)))
              ;; move forward so we can find the next block
              (forward-line)))))

      (defun org-babel-sh-evaluate (session body &optional params stdin cmdline)
        "Pass BODY to the Shell process in BUFFER.
          If RESULT-TYPE equals `output' then return a list of the outputs
          of the statements in BODY, if RESULT-TYPE equals `value' then
          return the value of the last statement in BODY."
        (let* ((shebang (cdr (assq :shebang params)))
               (results
                (cond
                 ((or stdin cmdline)	       ; external shell script w/STDIN
                  ;; (map-put params :file file-to-write-progress) ;; TODO htis should happen in one place
                  (let ((script-file (org-babel-temp-file "sh-script-"))
                        (stdin-file (org-babel-temp-file "sh-stdin-"))
                        (padline (not (string= "no" (cdr (assq :padline params))))))
                    (with-temp-file script-file
                      (when shebang (insert shebang "\n"))
                      (when padline (insert "\n"))
                      (insert body))
                    (set-file-modes script-file #o755)
                    (with-temp-file stdin-file (insert (or stdin "")))
                    (with-temp-buffer
                      (call-process-shell-command
                       (concat (if shebang script-file
                                 (format "%s %s" shell-file-name script-file))
                               (and cmdline (concat " " cmdline)))
                       stdin-file
                       (current-buffer))
                      (buffer-string))))
                 (session			; session evaluation
                  ;; (map-put params :file file-to-write-progress) ;; TODO htis should happen in one place
                  (mapconcat
                   #'org-babel-sh-strip-weird-long-prompt
                   (mapcar
                    #'org-trim
                    (butlast
                     (org-babel-comint-with-output
                         (session org-babel-sh-eoe-output t body)
                       (dolist (line (append (split-string (org-trim body) "\n")
                                             (list org-babel-sh-eoe-indicator)))
                         (insert line)
                         (comint-send-input nil t)
                         (while (save-excursion
                                  (goto-char comint-last-input-end)
                                  (not (re-search-forward
                                        comint-prompt-regexp nil t)))
                           (accept-process-output
                            (get-buffer-process (current-buffer))))))
                     2))
                   "\n"))
                 ;; External shell script, with or without a predefined
                 ;; shebang.
                 ((org-string-nw-p shebang)
                  ;; (map-put params :file file-to-write-progress) ;; TODO htis should happen in one place

                  (let ((script-file (org-babel-temp-file "sh-script-"))
                        (padline (not (equal "no" (cdr (assq :padline params))))))
                    (with-temp-file script-file
                      (insert shebang "\n")
                      (when padline (insert "\n"))
                      (insert body))
                    (set-file-modes script-file #o755)
                    (org-babel-eval script-file "")))
                 (t
                  (when (cdr (assq :file params))
                    (message "file was found making process")
                    (make-process :name (format "proc-%s-%s" (file-name-nondirectory (cdr (assq :file params))) (md5 body))
                                  :buffer (format "buf-%s-%s" (file-name-nondirectory (cdr (assq :file params))) (md5 body))
                                  :command (list "sh" "-c" (org-trim body))
                                  :connection-type 'pipe
                                  :filter (apply-partially 'my-pass-it-on-filter (cdr (assq :file params)))))
                  (unless (cdr (assq :file params))
                    (org-babel-eval shell-file-name (org-trim body)))))))
          (unless (cdr (assq :file params)) ;; don't do this if :file exists
            (when results
              (let ((result-params (cdr (assq :result-params params))))
                (org-babel-result-cond result-params
                  results
                  (let ((tmp-file (org-babel-temp-file "sh-")))
                    (with-temp-file tmp-file (insert results))
                    (org-babel-import-elisp-from-file tmp-file))))))))

      (defun org-babel-execute:shell (body params)
        "Execute a block of Shell commands with Babel.
          This function is called by `org-babel-execute-src-block'."
        (when (assq :autolog params)
          (map-put params :file (generate-automatic-log-name)))
        (let* ((session (org-babel-sh-initiate-session
                         (cdr (assq :session params))))
               (stdin (let ((stdin (cdr (assq :stdin params))))
                        (when stdin (org-babel-sh-var-to-string
                                     (org-babel-ref-resolve stdin)))))
               (cmdline (cdr (assq :cmdline params)))
               (full-body (org-babel-expand-body:generic
                           body params (org-babel-variable-assignments:shell params))))
          (org-babel-reassemble-table
           (org-babel-sh-evaluate session full-body params stdin cmdline)
           (org-babel-pick-name
            (cdr (assq :colname-names params)) (cdr (assq :colnames params)))
           (org-babel-pick-name
            (cdr (assq :rowname-names params)) (cdr (assq :rownames params))))))


    (with-eval-after-load 'org

      ;; (setq org-clock-persist-file "~/org/org-clock-save.el")
      (setq org-clock-history-length 25)
      (setq org-image-actual-width '(500))
      (setq org-cycle-separator-lines 1)
      (setq org-reverse-note-order t)

      (setq org-use-fast-tag-selection nil)
      (setq org-startup-align-all-tables t)
      (setq org-startup-indented t)
      ;; org-agenda-files are set in ~/personal.el
      ;; (setq org-modules (add-to-list 'org-modules 'org-habit))
      (add-to-list 'org-modules 'org-habit)
      (add-to-list 'org-modules 'org-tempo)

      (setq org-log-done t)
      (setq org-habit-graph-column 100)
      (setq org-html-validation-link nil)

      ;; (setq org-use-fast-todo-selection t)
      ;; use *all tags* in *all agenda files* instead of just that buffers
      (setq org-complete-tags-always-offer-all-agenda-tags t)
      (setq org-todo-keywords
            '((sequence "TODO(t)" "NEXT(n)" "IN-PROGRESS(i)" "WAITING(w@/!)" "SOMEDAY(s)" "DELEGATED(x@!)" "|" "DONE(d)" "CANCELLED(c@/!)")))

      (setq org-archive-location "~/org/archive/%s::datetree/* Finished Tasks")

          ;;;;;; Fix Helm org tag completion
      ;; From Anders Johansson <https://groups.google.com/d/msg/emacs-helm/tA6cn6TUdRY/G1S3TIdzBwAJ>

      ;; This works great!  He posted it on 3 Mar 2016, on a thread that was
      ;; started in Oct 2013.  He also posted this message on 2 Apr 2014,
      ;; maybe an earlier attempt at a solution:
      ;; <http://article.gmane.org/gmane.emacs.orgmode/84495> I've just
      ;; tidied it up a bit and adjusted the prompt.


      (with-eval-after-load 'helm
        ;; (add-to-list 'helm-completing-read-handlers-alist '(org-capture . aj/org-completing-read-tags))
        ;; (add-to-list 'helm-completing-read-handlers-alist '(org-set-tags . aj/org-completing-read-tags)))

        (defun aj/org-completing-read-tags (prompt coll pred req initial hist def inh)
          (if (not (string= "Tags: " prompt))
              ;; Not a tags prompt.  Use normal completion by calling
              ;; `org-icompleting-read' again without this function in
              ;; `helm-completing-read-handlers-alist'
              (let ((helm-completing-read-handlers-alist (rassq-delete-all
                                                          'aj/org-completing-read-tags
                                                          helm-completing-read-handlers-alist)))
                (org-icompleting-read prompt coll pred req initial hist def inh))
            ;; Tags prompt
            (let* ((initial (and (stringp initial)
                                 (not (string= initial ""))
                                 initial))
                   (curr (when initial
                           (org-split-string initial ":")))
                   (table (org-uniquify
                           (mapcar 'car org-last-tags-completion-table)))
                   (table (if curr
                              ;; Remove current tags from list
                              (cl-delete-if (lambda (x)
                                              (member x curr))
                                            table)
                            table))
                   (prompt (if initial
                               (concat "Tags " initial)
                             prompt)))
              (concat initial (mapconcat 'identity
                                         (nreverse (aj/helm-completing-read-multiple
                                                    prompt table pred nil nil hist def
                                                    t "Org tags" "*Helm org tags*" ":"))
                                         ":")))))

        (defun aj/helm-completing-read-multiple (prompt choices
                                                        &optional predicate require-match initial-input hist def
                                                        inherit-input-method name buffer sentinel)
          "Read multiple items with `helm-completing-read-default-1'. Reading stops
          when the user enters SENTINEL. By default, SENTINEL is
          \"*done*\". SENTINEL is disambiguated with clashing completions
          by appending _ to SENTINEL until it becomes unique. So if there
          are multiple values that look like SENTINEL, the one with the
          most _ at the end is the actual sentinel value. See
          documentation for `ido-completing-read' for details on the
          other parameters."
          (let ((sentinel (or sentinel "*done*"))
                this-choice res done-reading)
            ;; Uniquify the SENTINEL value
            (while (cl-find sentinel choices)
              (setq sentinel (concat sentinel "_")))
            (setq choices (cons sentinel choices))
            ;; Read choices
            (while (not done-reading)
              (setq this-choice (helm-completing-read-default-1 prompt choices
                                                                predicate require-match initial-input hist def
                                                                inherit-input-method name buffer nil t))
              (if (equal this-choice sentinel)
                  (setq done-reading t)
                (setq res (cons this-choice res))
                (setq prompt (concat prompt this-choice ":"))))
            res))

        (setq org-confirm-babel-evaluate nil)
        (setq org-babel-default-header-args:sh
              '((:prologue . "exec 2>&1") (:epilogue . ":"))) ;; TODO is there a way to add default header args here?)
            (setq org-babel-default-header-args:shell
                  '((:prologue . "exec 2>&1") (:epilogue . ":")))
            (setq org-babel-default-header-args '((:session . "none")
                                                  (:results . "replace")
                                                  (:exports . "both")
                                                  (:cache . "no")
                                                  (:noweb . "no")
                                                  (:hlines . "no")
                                                  (:tangle . "no")))


            (setq org-tags-column -50)
            (add-hook 'org-capture-mode-hook 'evil-insert-state)
            ;; todo set these back to ~/ after I vet the new vanilla emacs install


            ;; resume clocks after closing emacs
            (setq org-clock-persist t)
            ;; (org-clock-persistence-insinuate)
            (setq org-log-into-drawer t)
            ;; updated to use a depth of 3 in combination with showing the full outlinepath
            (setq org-refile-targets
                  '((org-agenda-files . (:maxlevel . 2))))
            (setq org-outline-path-complete-in-steps nil)         ; Refile in a single go
            (setq org-refile-use-outline-path t)                  ; Show full paths for refiling

            ;; refile to archive datetree done.org
            (defun my/org-read-datetree-date (d) "Parse a time string D and return a date to pass to the datetree functions." (let ((dtmp (nthcdr 3 (parse-time-string d)))) (list (cadr dtmp) (car dtmp) (caddr dtmp))))

            (defun my/org-refile-to-archive-datetree (&optional bfn)
              "Refile an entry to a datetree under an archive."
              (interactive)
              (require 'org-datetree)
              (let* ((bfn (or bfn (find-file-noselect (expand-file-name "~/org/done.org"))))
                     (datetree-date (my/org-read-datetree-date (org-read-date t nil)))
                     (tags-to-preserve-on-refile (seq-filter (lambda (tag) (not (string= "refile" tag))) (org-get-tags))))
                  (message (format "%s" tags-to-preserve-on-refile))
                  (org-set-tags-to tags-to-preserve-on-refile)

                  (org-refile nil nil (list nil (buffer-file-name bfn) nil
                                          (with-current-buffer bfn
                                            (save-excursion
                                              (org-datetree-find-date-create datetree-date)
                                              (point))))))
              (setq this-command 'my/org-refile-to-journal))

            ;; fix helm org tag completionsj
            (defun air--org-swap-tags (tags)
              "Replace any tags on the current headline with TAGS.

          The assumption is that TAGS will be a string conforming to Org Mode's
          tag format specifications, or nil to remove all tags."
              (let ((old-tags (org-get-tags-string))
                    (tags (if tags
                              (concat " " tags)
                            "")))
                  (save-excursion
                  (beginning-of-line)
                  (re-search-forward
                   (concat "[ \t]*" (regexp-quote old-tags) "[ \t]*$")
                   (line-end-position) t)
                  (replace-match tags)
                  (org-set-tags tags))))

            (defun air-org-set-tags (tag)
              "Add TAG if it is not in the list of tags, remove it otherwise.

          TAG is chosen interactively from the global tags completion table."
              (interactive
               (list (let ((org-last-tags-completion-table
                            (if (derived-mode-p 'org-mode)
                                  (org-uniquify
                                   (delq nil (append (org-get-buffer-tags)
                                                   (org-global-tags-completion-table))))
                              (org-global-tags-completion-table))))
                       (org-icompleting-read
                          "Tag: " 'org-tags-completion-function nil nil nil
                          'org-tags-history))))
              (let* ((cur-list (org-get-tags nil t))
                     (new-tags (mapconcat 'identity
                                          (if (member tag cur-list)
                                              (delete tag cur-list)
                                            (append cur-list (list tag)))
                                          ":"))
                     (new (if (> (length new-tags) 1) (concat " :" new-tags ":")
                            nil)))
                  (air--org-swap-tags new)))

            (setq org-structure-template-alist '(("e" . "src elisp")
                                                   ("E" . "example")
                                                   ("h" . "src haskell")
                                                   ("s" . "src shell :file (generate-automatic-log-name) :results verbatim")
                                                   ("S" . "src")))

            ;; setup org EasyTemplates

            ;; TODO update EasyTemplates
            ;; (add-to-list 'org-structure-template-alist
            ;; 	       '("s" . "shell"))
            ;; (add-to-list 'org-structure-template-alist
            ;; 	       '("E" "#+BEGIN_SRC elisp\n ?\n#+END_SRC "))
            ;; (add-to-list 'org-structure-template-alist
            ;; 	       '("s" "#+BEGIN_SRC shell :results verbatim\n ?\n#+END_SRC "))
            ;; (add-to-list 'org-structure-template-alist
            ;; 	       '("S" "#+BEGIN_SRC ?\n\n#+END_SRC "))
            ;; (add-to-list 'org-structure-template-alist
            ;; 	       '("m" "#+BEGIN_SRC mongo\n ?\n#+END_SRC "))
            ;; (add-to-list 'org-structure-template-alist
            ;; 	       '("j" "#+BEGIN_SRC json\n ?\n#+END_SRC "))
            ;; (add-to-list 'org-structure-template-alist
            ;; 	       '("h" "#+BEGIN_SRC haskell\n ?\n#+END_SRC "))
            ;; ;; org archiving advise to preserve structure
            (defadvice org-archive-subtree (around fix-hierarchy activate)
              (let* ((fix-archive-p (and (not current-prefix-arg)
                                           (not (use-region-p))))
                     (afile (org-extract-archive-file (org-get-local-archive-location)))
                     (buffer (or (find-buffer-visiting afile) (find-file-noselect afile))))
                  ad-do-it
                  (when fix-archive-p
                  (with-current-buffer buffer
                    (goto-char (point-max))
                    (while (org-up-heading-safe))
                    (let* ((olpath (org-entry-get (point) "ARCHIVE_OLPATH"))
                           (path (and olpath (split-string olpath "/")))
                           (level 1)
                           tree-text)
                      (when olpath
                          (org-mark-subtree)
                          (setq tree-text (buffer-substring (region-beginning) (region-end)))
                          (let (this-command) (org-cut-subtree))
                          (goto-char (point-min))
                          (save-restriction
                          (widen)
                          (-each path
                            (lambda (heading)
                              (if (re-search-forward
                                   (rx-to-string
                                    `(: bol (repeat ,level "*") (1+ " ") ,heading)) nil t)
                                  (org-narrow-to-subtree)
                                  (goto-char (point-max))
                                  (unless (looking-at "^")
                                  (insert "\n"))
                                  (insert (make-string level ?*)
                                          " "
                                          heading
                                          "\n"))
                              (cl-incf level)))
                          (widen)
                          (org-end-of-subtree t t)
                          (org-paste-subtree level tree-text))))))))

            ;; org columns
            ;; %10Time_Spent{:}
            ;; (setq org-columns-default-format "%25ITEM %TODO %3PRIORITY %10Time_Estimate{:} %CLOCKSUM %CLOCKSUM_T %TAGS")
            (setq org-columns-default-format "%75ITEM %10Effort{:} %CLOCKSUM %TODO %TAGS")

            ;; org reveal settings
            (setq Org-Reveal-root "/Users/codygman/Downloads/reveal.js-3.6.0/js/reveal.js")
            (setq Org-Reveal-title-slide nil)



            ;; end org stuff)

            (with-eval-after-load 'org-habit
              (advice-add #'org-agenda-finalize :before #'my/org-agenda-mark-habits))

            (defun air-org-skip-subtree-if-priority (priority)
              "Skip an agenda subtree if it has a priority of PRIORITY.

              PRIORITY may be one of the characters ?A, ?B, or ?C."
              (let ((subtree-end (save-excursion (org-end-of-subtree t)))
                    (pri-value (* 1000 (- org-lowest-priority priority)))
                    (pri-current (org-get-priority (thing-at-point 'line t))))
                (if (= pri-value pri-current)
                    subtree-end
                  nil)))

            (eval-after-load 'org
              (setq org-hide-leading-stars t))
            ;; (with-eval-after-load "ob-restclient"
            ;;   (defun restclient-http-parse-current-and-do (func &rest args) ;
            ;;     (save-excursion
            ;;       (goto-char (restclient-current-min))
            ;;       (when (re-search-forward restclient-method-url-regexp (point-max) t)
            ;; 	(let ((method (match-string-no-properties 1))
            ;; 	      (url (match-string-no-properties 2))
            ;; 	      (vars (restclient-find-vars-before-point))
            ;; 	      (headers '()))
            ;; 	  (forward-line)
            ;; 	  (while (cond
            ;; 		  ((and (looking-at restclient-header-regexp) (not (looking-at restclient-empty-line-regexp)))
            ;; 		   (setq headers (cons (restclient-replace-all-in-header vars (restclient-make-header)) headers)))
            ;; 		  ((looking-at restclient-use-var-regexp)
            ;; 		   (setq headers (append headers (restclient-parse-headers (restclient-replace-all-in-string vars (match-string 1)))))))
            ;; 	    (forward-line))
            ;; 	  (when (looking-at restclient-empty-line-regexp)
            ;; 	    (forward-line))
            ;; 	  (let* ((cmax (restclient-current-max))
            ;; 		 (entity (restclient-parse-body (buffer-substring (min (point) cmax) cmax) vars))
            ;; 		 (url (restclient-replace-all-in-string vars (string-trim url))))
            ;; 	    (apply func method url headers entity args))))))
            ;;   )

            ;; put creation date in todos
            ;; (defun my/log-todo-creation-date (&rest ignore)
            ;;   ;; TODO make this create inactive timestamps
            ;;   "Log TODO creation time in the property drawer under the key 'CREATED'."
            ;;   (when (and (org-get-todo-state)
            ;;              (not (org-entry-get nil "CREATED")))
            ;;     (org-entry-put nil "CREATED" (format-time-string (cdr org-time-stamp-formats)))))

            ;; (advice-add 'org-insert-todo-heading-respect-content :after #'my/log-todo-creation-date)
            ;; (advice-add 'org-insert-todo-subheading :after #'my/log-todo-creation-date)
            ;; (add-hook 'org-evil-heading-
            ;;          #'(lambda()
            ;;                (save-excursion
            ;;                     (org-back-to-heading)
            ;;                     (my/log-todo-creation-date))))
            ;; (add-hook 'org-insert-heading-hook ;; not sure if this one works
            ;;          #'(lambda()
            ;;                (save-excursion
            ;;                     (org-back-to-heading)
            ;;                     (my/log-todo-creation-date))))

            ;; (add-hook 'org-capture-before-finalize-hook
            ;;          #'(lambda()
            ;;                (save-excursion
            ;;                     (org-back-to-heading)
            ;;                     (my/log-todo-creation-date))))

            (defvar my/org-habit-show-graphs-everywhere nil
              "If non-nil, show habit graphs in all types of agenda buffers.

             Normally, habits display consistency graphs only in
             \"agenda\"-type agenda buffers, not in other types of agenda
             buffers.  Set this variable to any non-nil variable to show
             consistency graphs in all Org mode agendas.
      https://emacs.stackexchange.com/a/17328/16972
      ")

            ;; found these custom org-agenda with general from https://gist.github.com/amirrajan/301e74dc844a4c9ffc3830dc4268f177
            (eval-after-load 'org-agenda
              ;; (add-function :before 'org-agenda-refile '(lambda () (org-toggle-tag 'refile)))

              ;; (advice-add 'org-agenda-refile :after '(lambda () (org-toggle-tag 'refile)))
              ;; (advice-add #'org-read-property-value :before #'des/org-property-store-previous-val)
              ;; (advice-add #'org-agenda-refile :after '(lambda () (org-toggle-tag 'refile)))
              (general-evil-define-key 'normal org-agenda-mode-map
                (kbd "<RET>") 'org-agenda-switch-to
                (kbd "\t") 'org-agenda-goto

                "q" 'org-agenda-quit
                "$" 'org-agenda-archive
                "r" 'org-agenda-redo
                "gr" 'org-agenda-refile ;; not allowed in tags type agenda buffers? wutt
                "S" 'org-save-all-org-buffers
                "gj" 'org-agenda-goto-date
                "gJ" 'org-agenda-clock-goto
                "m" 'org-agenda-bulk-mark
                "B" 'org-agenda-bulk-action
                "go" 'org-agenda-open-link
                "s" 'org-agenda-schedule
                "d" 'org-agenda-deadline
                "+" 'org-agenda-priority-up
                "," 'org-agenda-priority
                "-" 'org-agenda-priority-down
                "y" 'org-agenda-todo-yesterday
                "n" 'org-agenda-add-note
                "t" 'org-agenda-todo
                ":" 'org-agenda-set-tags
                ";" 'org-timer-set-timer
                "I" 'helm-org-task-file-headings ;; broken... what is it even ;; artifact of https://gist.github.com/amirrajan/301e74dc844a4c9ffc3830dc4268f177
                "i" 'org-agenda-clock-in
                "o" 'org-agenda-clock-out
                "u" 'org-agenda-bulk-unmark
                "X" 'org-agenda-exit
                "j"  'org-agenda-next-line
                "k"  'org-agenda-previous-line
                "vt" 'org-agenda-toggle-time-grid
                "va" 'org-agenda-archives-mode
                "vw" 'org-agenda-week-view
                "vl" 'org-agenda-log-mode
                "vd" 'org-agenda-day-view
                "vc" 'org-agenda-show-clocking-issues
                "g/" 'org-agenda-filter-by-tag
                "O" 'delete-other-windows
                "gh" 'org-agenda-holiday
                "gv" 'org-agenda-view-mode-dispatch
                "f" 'org-agenda-later
                "b" 'org-agenda-earlier
                "c" 'helm-org-capture-templates
                "e" 'org-agenda-set-effort
                "n" nil  ; evil-search-next
                "{" 'org-agenda-manipulate-query-add-re
                "}" 'org-agenda-manipulate-query-subtract-re
                "A" 'org-agenda-toggle-archive-tag
                "." 'org-agenda-goto-today
                "0" 'evil-digit-argument-or-evil-beginning-of-line
                "<" 'org-agenda-filter-by-category
                ">" 'org-agenda-date-prompt
                "F" 'org-agenda-follow-mode
                "H" 'org-agenda-holidays
                "J" 'org-agenda-next-date-line
                "K" 'org-agenda-previous-date-line
                "L" 'org-agenda-recenter
                "P" 'org-agenda-show-priority
                "R" 'org-agenda-clockreport-mode
                "Z" 'org-agenda-sunrise-sunset
                "T" 'org-agenda-show-tags
                "x" 'org-agenda-clock-cancel
                "[" 'org-agenda-manipulate-query-add
                "g\\" 'org-agenda-filter-by-tag-refine
                "]" 'org-agenda-manipulate-query-subtract))))
#+end_src

#+results:
: 1
*** my custom org functions
#+begin_src emacs-lisp
  (defun my/org-agenda-mark-habits ()
    "Mark all habits in current agenda for graph display.

         This function enforces `my/org-habit-show-graphs-everywhere' by
         marking all habits in the current agenda as such.  When run just
         before `org-agenda-finalize' (such as by advice; unfortunately,
         `org-agenda-finalize-hook' is run too late), this has the effect
         of displaying consistency graphs for these habits.

         When `my/org-habit-show-graphs-everywhere' is nil, this function
         has no effect.

  https://emacs.stackexchange.com/a/17328/16972
  "
    (when (and my/org-habit-show-graphs-everywhere
               (not (get-text-property (point) 'org-series)))
      (let ((cursor (point))
            item data)
        (while (setq cursor (next-single-property-change cursor 'org-marker))
          (setq item (get-text-property cursor 'org-marker))
          (when (and item (org-is-habit-p item))
            (with-current-buffer (marker-buffer item)
              (setq data (org-habit-parse-todo item)))
            (put-text-property cursor
                               (next-single-property-change cursor 'org-marker)
                               'org-habit-p data))))))

  (setq my/org-habit-show-graphs-everywhere t)
  (setq org-habit-show-habits-only-for-today t)
#+end_src
*** sorted org packages
**** orgit
***** use: org links to magit buffers
***** install
#+begin_src emacs-lisp
  (straight-use-package 'orgit)
    (use-package orgit
      ;; Automatically copy orgit link to last commit after commit
      :hook (git-commit-post-finish . orgit-store-after-commit)
      :config
      (defun orgit-store-after-commit ()
        "Store orgit-link for latest commit after commit message editor is finished."
        (let* ((repo (abbreviate-file-name default-directory))
               (rev (magit-git-string "rev-parse" "HEAD"))
               (link (format "orgit-rev:%s::%s" repo rev))
               (summary (substring-no-properties (magit-format-rev-summary rev)))
               (desc (format "%s (%s)" summary repo)))
          (push (list link desc) org-stored-links))))
#+end_src
**** org wild notifier
***** why?
****** notifications that popup and remind me when calendar items come up
***** code
#+begin_src emacs-lisp
  (use-package alert
    )
  (straight-use-package
   '(org-wild-notifier :type git :host github :repo "akhramov/org-wild-notifier.el" :branch "fix/25-emacs-lags"))

  (use-package async
    :config
    (autoload 'dired-async-mode "dired-async.el" nil t)
    (dired-async-mode 1)
    )

  (use-package org-wild-notifier
    :ensure nil
    :config
    (org-wild-notifier-mode)
    )
#+end_src
*** unsorted org packages
#+begin_src emacs-lisp
  (use-package org-web-tools
    :config
    (defun my/org-web-tools-insert-link-for-url (url)
      ;; uses evil-paste-after instead of insert
      (interactive (list (org-web-tools--get-first-url)))
      (evil-append-line 0)
      (insert " ")
      (insert (org-web-tools--org-link-for-url url))
      (evil-normal-state)
      )
    )
  (use-package org-edna
    :after org
    :config
    (org-edna-load))
  (use-package org-mru-clock
    :general
    :after org
    :config
    (setq org-mru-clock-how-many 100
          org-mru-clock-keep-formatting t
          org-mru-clock-completing-read #'helm-comp-read))
  (use-package ob-mongo
    :defer t)
  (use-package org-bullets
    :init
    ;; (setq org-bullets-bullet-list '("◉" "◎" "✸" "○" "►" "◇"))
    ;; (setq org-bullets-bullet-list '("◉" "○" "✸" "✿"))
    (setq org-bullets-bullet-list '("◉" "◎" "○" "►" "◇"))
    :config
    (add-hook 'org-mode-hook (lambda () (org-bullets-mode 1))))
#+end_src
** helm
*** install and configure
#+begin_src emacs-lisp
  ;; Helm
  (use-package helm
    :init
    (setq helm-M-x-fuzzy-match t
          helm-mode-fuzzy-match t
          helm-buffers-fuzzy-matching t
          ;; NOTE just leaving at default of 60 so that helm works same even when not fullscreen
          ;; you can just press C-[ in a helm buffer to show full filenames
          ;; helm-buffer-max-length 100
          helm-recentf-fuzzy-match t
          helm-locate-fuzzy-match t
          helm-semantic-fuzzy-match t
          helm-imenu-fuzzy-match t
          helm-completion-in-region-fuzzy-match t
          helm-candidate-number-list 80
          helm-split-window-in-side-p t
          helm-move-to-line-cycle-in-source t
          helm-echo-input-in-header-line t
          helm-autoresize-max-height 0
          helm-autoresize-min-height 20
          helm-grep-ag-command "rg --color=always --smart-case --no-heading --line-number %s %s %s"
          helm-always-two-windows t)
    (when (file-exists-p "/data/data/com.termux/files/usr/bin/termux-info")
      (setq helm-split-window-default-side 'right))
    ;; helm pretty frame
    (setq helm-display-function 'helm-display-buffer-in-own-frame
          helm-display-buffer-reuse-frame nil
          helm-use-undecorated-frame-option t)
    :config
    (use-package helm-flx)
    (use-package helm-fuzzier)
    (use-package helm-rg)
    (helm-mode 1)
    (helm-flx-mode 1)
    (helm-fuzzier-mode 1)
    :bind (:map helm-map
                ("<tab>" . helm-execute-persistent-action)
                ("C-h" . helm-find-files-up-one-level)
                ("<backtab>" . helm-find-files-up-one-level)
                ("C-z" . helm-select-action)))
#+end_src
*** helm-org
**** code
#+begin_src emacs-lisp
  (use-package helm-org
    :init
    (setq org-capture-templates
          '(
            ("t" "Todo" entry (file+headline "~/bsab/misc.org" "Misc")
             "* TODO %?  :refile:
  :PROPERTIES:
  :WILD_NOTIFIER_NOTIFY_BEFORE: 15 5 3 1
  :CREATED: %U
  :END:"
             :prepend t
             :clock-in t
             :clock-resume t
             )
            ("T" "Todo (today)" entry (file+headline "~/bsab/misc.org" "Misc")
             "* TODO %<%Y-%m-%d> %?  :refile:
  :PROPERTIES:
  :WILD_NOTIFIER_NOTIFY_BEFORE: 15 5 3 1
  :CREATED: %U
  :END:"
             :prepend t
             :clock-in t
             :clock-resume t
             )
            ))
    :after (helm org))
#+end_src
**** why?
***** helm-org-capture-templates
*** helm-org-rifle
#+begin_src emacs-lisp
  (use-package helm-org-rifle
    :after (helm org))
#+end_src
*** org-recent-headings
#+begin_src emacs-lisp
;;(use-package org-recent-headings
;;  :config (org-recent-headings-mode))
#+end_src
*** helm company
#+begin_src emacs-lisp
  ;; (use-package helm-company
#+end_src
*** helm ag
#+begin_src emacs-lisp
  (use-package helm-ag :defer t)
#+end_src
*** helm swoop
#+begin_src emacs-lisp
  (defun spacemacs/helm-swoop-region-or-symbol ()
    "Call `helm-swoop' with default input."
    (interactive)
    (let ((helm-swoop-pre-input-function
           (lambda ()
             (if (region-active-p)
                 (buffer-substring-no-properties (region-beginning)
                                                 (region-end))
               (let ((thing (thing-at-point 'symbol t)))
                 (if thing thing ""))))))
      (call-interactively 'helm-swoop)))
  (use-package helm-swoop
    :init
    (setq helm-swoop-split-with-multiple-windows t
          helm-swoop-split-direction 'split-window-vertically
          helm-swoop-speed-or-color t
          helm-swoop-split-window-function 'helm-default-display-buffer
          helm-swoop-pre-input-function (lambda () "")))
#+end_src
*** helm google
#+begin_src emacs-lisp
  (straight-use-package
   '(helm-google :type git :repo "https://framagit.org/steckerhalter/helm-google.git"))
#+end_src
** wgrep
#+begin_src emacs-lisp
(use-package wgrep)
#+end_src
** projectile
*** install and configure
#+begin_src emacs-lisp
  (use-package projectile
    :defer t
    :init
    (setq projectile-require-project-root nil)
    :config
    (projectile-mode 1))
#+end_src
*** helm-projectile
#+begin_src emacs-lisp
  (use-package helm-projectile
    :defer t
    :init
    (setq helm-projectile-fuzzy-match t)
    :config
    (helm-projectile-on))
#+end_src
** tramp
*** add support for ssh into docker containers
#+begin_src emacs-lisp
  (use-package docker-tramp
    :defer t)
#+end_src
** which key

#+begin_src emacs-lisp
  (use-package which-key
    :init
    (setq which-key-separator " ")
    (setq which-key-prefix-prefix "+")
    :config
    (which-key-mode))
#+end_src
** avy

#+begin_src emacs-lisp
  (use-package avy
    :config
    (avy-setup-default))
#+end_src
** flycheck
#+begin_src emacs-lisp
  (use-package flycheck
    :defer t)
#+end_src
** company autocomplete
#+begin_src emacs-lisp
  ;; (use-package company
  ;;   :init
  ;;   (setq company-minimum-prefix-length 3)
  ;;   (setq company-auto-complete nil)
  ;;   (setq company-idle-delay 0)
  ;;   (setq company-require-match 'never)
  ;;   (setq company-frontends
  ;;         '(company-pseudo-tooltip-unless-just-one-frontend
  ;;           company-preview-frontend
  ;;           company-echo-metadata-frontend))
  ;;   (setq tab-always-indent 'complete)
  ;;   (defvar completion-at-point-functions-saved nil)
  ;;   :config
  ;;   (global-company-mode 1)
  ;;   (define-key company-active-map (kbd "TAB") 'company-complete-common-or-cycle)
  ;;   (define-key company-active-map (kbd "<tab>") 'company-complete-common-or-cycle)
  ;;   (define-key company-active-map (kbd "S-TAB") 'company-select-previous)
  ;;   (define-key company-active-map (kbd "<backtab>") 'company-select-previous)
  ;;   (define-key company-mode-map [remap indent-for-tab-command] 'company-indent-for-tab-command)

  ;;   (defun company-indent-for-tab-command (&optional arg)
  ;;     (interactive "P")
  ;;     (let ((completion-at-point-functions-saved completion-at-point-functions)
  ;;           (completion-at-point-functions '(company-complete-common-wrapper)))
  ;;       (indent-for-tab-command arg)))

  ;;   (defun company-complete-common-wrapper ()
  ;;     (let ((completion-at-point-functions completion-at-point-functions-saved))
  ;;       (company-complete-common))))
  ;; (setq company-backends (mapcar #'company-mode/backend-with-yas company-backends))
  ;; )
#+end_src
** powerline
#+begin_src emacs-lisp
  ;; Powerline
  ;; (use-package spaceline
  ;;   :init
  ;;   (setq powerline-default-separator 'slant)
  ;;   :config
  ;;   (spaceline-emacs-theme)
  ;;   (spaceline-toggle-minor-modes-off)
  ;;   (spaceline-toggle-buffer-size-off)
  ;;   (spaceline-toggle-evil-state-on))
#+end_src
** elisp demos
#+begin_src emacs-lisp

  (straight-use-package
   '(elisp-demos :type git :host github :repo "xuchunyang/elisp-demos" :files ("elisp-demos.org" :defaults)))
  (use-package elisp-demos
    :defer t
    :after helpful
    :config
    (advice-add 'helpful-update :after #'elisp-demos-advice-helpful-update))
#+end_src
** winum
#+begin_src emacs-lisp
  ;; Winum
  (use-package winum
    :defer t
    :init (winum-mode))
#+end_src
** install all the icons
#+begin_src emacs-lisp
  (use-package all-the-icons)
#+end_src
** magit
#+begin_src emacs-lisp
  (defmacro after-evil (&rest body)
    `(eval-after-load "evil"
       (lambda ()
         ,@body)))

  (use-package magit
    :defer t
    :commands (magit-toplevel magit-status magit-blame magit-log)
    :config
    (setq magit-display-buffer-function 'magit-display-buffer-same-window-except-diff-v1)
    (after-evil
     (evil-define-key 'normal magit-log-mode-map
       (kbd "`") 'magit-process-buffer
       (kbd "~") 'magit-diff-default-context
       (kbd "0") 'evil-digit-argument-or-evil-beginning-of-line
       (kbd "$") 'evil-end-of-line)
     (evil-define-key 'normal magit-status-mode-map
       (kbd "q") 'quit-window
       (kbd "`") 'magit-process-buffer
       (kbd "~") 'magit-diff-default-context
       (kbd "0") 'evil-digit-argument-or-evil-beginning-of-line
       (kbd "$") 'evil-end-of-line
       (kbd "Q") 'delete-window)
     (evil-define-key 'normal magit-repolist-mode-map
       (kbd "q") 'quit-window
       (kbd "Q") 'delete-window
       (kbd "RET") 'magit-repolist-status
       (kbd "gr") 'magit-list-repositories)))
#+end_src
** magit-popup
#+begin_src emacs-lisp
  ;; (use-package magit-popup
  ;;   :demand t ; make sure it is loaded
  ;;   )
#+end_src
** magithub (disabled)
#+begin_src emacs-lisp
  ;; (straight-use-package 'ghub)
  ;; (use-package magithub
  ;;   :straight t
  ;;   :after magit magit-popup
  ;;   :config
  ;;   (magithub-feature-autoinject t)
  ;;   (setq magithub-clone-default-directory "~/github"))
#+end_src
** lsp
*** lsp mode
#+begin_src emacs-lisp
    ;; LSP -- bookmark for 2018-11-20
    (use-package lsp-mode
      :init
      (add-hook 'prog-major-mode #'lsp-prog-major-mode-enable)
      ;; (add-hook 'haskell-mode-hook #'lsp-haskell-enable)
  )

      (use-package lsp-ui
        :init
        (add-hook 'lsp-mode-hook 'lsp-ui-mode))

      ;; (use-package lsp-haskell
      ;;   :init
      ;;   (setq lsp-haskell-process-path-hie "/Users/codygman/.local/bin/hie-wrapper")
      ;;   )
#+end_src
*** lsp ui
*** lsp haskell
** real-auto-save mode
*** description
Automatically save your all your files at regular intervals.
*** I tried using this for everything before, but for haskell files brittany can take a second and make things laggy or there is a jarring disconnect.
*** Also this messes up the undo buffer IIRC
*** It's utility is higher with org files where I want to avoid sync conflicts esp on mobile
*** install
#+begin_src emacs-lisp
  (use-package real-auto-save :hook (org-mode . real-auto-save-mode))
#+end_src
** restclient
#+begin_src emacs-lisp
  (straight-use-package 'restclient)
  (use-package restclient)
#+end_src
** ob-restclient
#+begin_src emacs-lisp
  (straight-use-package 'ob-restclient)
  (use-package ob-restclient :after 'restclient)
#+end_src
** ob-async
#+begin_src emacs-lisp
  (use-package ob-async :after org)
#+end_src
** golden ratio mode
#+begin_src emacs-lisp
  (use-package golden-ratio
    :defer t
    :config
    (golden-ratio-mode 1))
#+end_src
** helpful
#+begin_src emacs-lisp
  (use-package helpful
    :config
    (global-set-key (kbd "C-h f") #'helpful-callable)
    (global-set-key (kbd "C-h v") #'helpful-variable)
    (global-set-key (kbd "C-h k") #'helpful-key)
    (advice-add 'helpful-update :after #'elisp-demos-advice-helpful-update))
#+end_src
** eacl
#+begin_src emacs-lisp
  (straight-use-package
   '(eacl :type git :host github :repo "redguardtoo/eacl" :files ("*.el" :defaults)))

  (use-package eacl)
#+end_src
** yasnippet
#+begin_src emacs-lisp
  (use-package yasnippet
    :config
    (yas-global-mode t)
    (yas-reload-all))
#+end_src
** alert
#+begin_src emacs-lisp
  (use-package alert
    :defer t
    :init
    (case system-type (gnu/linux
                         (progn (message "setting alert style to libnotify") (setq alert-default-style 'libnotify)))
            (darwin (progn (message "setting alert style to osx-notifier") (setq alert-default-style 'osx-notifier)))))
#+end_src
** markdown mode
#+begin_src emacs-lisp
  (use-package markdown-mode
    :defer t
    :commands (markdown-mode gfm-mode)
    :mode (("README\\.md\\'" . gfm-mode)
           ("\\.md\\'" . markdown-mode)
           ("\\.markdown\\'" . markdown-mode))
    :init (setq markdown-command "multimarkdown"))
#+end_src
** sx (stack exchange)
#+begin_src emacs-lisp
  (use-package sx
    :defer t
    :config
    (bind-keys :prefix "C-c s"
               :prefix-map my-sx-map
               :prefix-docstring "Global keymap for SX."
               ("q" . sx-tab-all-questions)
               ("i" . sx-inbox)
               ("o" . sx-open-link)
               ("u" . sx-tab-unanswered-my-tags)
               ("a" . sx-ask)
               ("s" . sx-search)))
#+end_src
* Programming language modes
** Work Haskell
*** haskell-mode
#+begin_src emacs-lisp
    (use-package haskell-mode
      :if (string-equal (getenv "EMACSFOR") "WORK")
      :defer t
      :mode "\\.hs\\'"
      :commands haskell-mode
      :init
      (message "work haskell-mode loading")
      (setq haskell-stylish-on-save nil)
      (setq haskell-mode-stylish-haskell-path "brittany")
      (setq haskell-mode-stylish-haskell-arguments "--config-file /Users/codygman/ITProTV/smurf/nucleus/brittany.yaml")
      ;; (add-hook 'haskell-mode-hook '(lambda () (ghc-init) (hare-init)))
      (add-hook 'haskell-mode-hook 'display-line-numbers-mode)
      (add-hook 'haskell-mode-hook 'haskell-indentation-mode)
      :config
      (defun haskell-indentation-indent-region (_start _end)
        "This function does nothing.

  It is better to do nothing to indent region in Haskell than to
  break the semantics of indentation.  This function is used for
  `indent-region-function' because the default is to call
  `indent-line-function' on every line from START to END and that
  also produces catastrophic results.

  Someday we will have indent region that preserves semantics and
  fixes up only indentation."
        (haskell-indentation-indent-rigidly (region-beginning) (region-end) haskell-indentation-layout-offset))
      (defun haskell-evil-open-above ()
        (interactive)
        (evil-digit-argument-or-evil-beginning-of-line)
        (haskell-indentation-newline-and-indent)
        (evil-previous-line)
        (haskell-indentation-indent-line)
        (evil-append-line nil))

      (defun haskell-evil-open-below ()
        (interactive)
        (evil-append-line nil)
        (haskell-indentation-newline-and-indent))

      (evil-define-key 'normal haskell-mode-map "o" 'haskell-evil-open-below)
      )

    (with-eval-after-load "haskell-mode"
      (defun haskell-mode-stylish-buffer ()
        "Apply stylish-haskell to the current buffer.

        Use `haskell-mode-stylish-haskell-path' to know where to find
        stylish-haskell executable. This function tries to preserve
        cursor position and markers by using
        `haskell-mode-buffer-apply-command'."
        (interactive)
        (haskell-mode-buffer-apply-command haskell-mode-stylish-haskell-path haskell-mode-stylish-haskell-arguments))

      (defun haskell-mode-buffer-apply-command (cmd args)
        "Execute shell command CMD with current buffer as input and output.
        Use buffer as input and replace the whole buffer with the
        output.  If CMD fails the buffer remains unchanged."
        (set-buffer-modified-p t)
        (let* ((out-file (make-temp-file "stylish-output"))
               (err-file (make-temp-file "stylish-error")))
          (unwind-protect
              (let* ((_errcode
                      (call-process-region (point-min) (point-max) cmd haskell-mode-stylish-haskell-arguments
                                           `((:file ,out-file) ,err-file)
                                           nil))
                     (err-file-empty-p
                      (equal 0 (nth 7 (file-attributes err-file))))
                     (out-file-empty-p
                      (equal 0 (nth 7 (file-attributes out-file)))))
                (if err-file-empty-p
                    (if out-file-empty-p
                        (message "Error: %s produced no output and no error information, leaving buffer alone" cmd)
                      ;; Command successful, insert file with replacement to preserve
                      ;; markers.
                      (insert-file-contents out-file nil nil nil t))
                  (progn
                    ;; non-null stderr, command must have failed
                    (with-current-buffer
                        (get-buffer-create "*haskell-mode*")
                      (insert-file-contents err-file)
                      (buffer-string))
                    (message "Error: %s ended with errors, leaving buffer alone, see *haskell-mode* buffer for stderr" cmd)
                    (with-temp-buffer
                      (insert-file-contents err-file)
                      ;; use (warning-minimum-level :debug) to see this
                      (display-warning cmd
                                       (buffer-substring-no-properties (point-min) (point-max))
                                       :debug)))))
            (ignore-errors
              (delete-file err-file))
            (ignore-errors
              (delete-file out-file)))))
  )
#+end_src
*** lsp-haskell
#+begin_src emacs-lisp
  (when (string-equal (getenv "EMACSFOR") "WORK")
  (use-package lsp-haskell
    :init
    (setq lsp-haskell-process-path-hie "/Users/codygman/.local/bin/hie-wrapper"))
  )
#+end_src
*** flycheck haskell
#+begin_src emacs-lisp
  (when (string-equal (getenv "EMACSFOR") "WORK")
    (straight-use-package 'use-package)

    (straight-use-package
     '(flycheck-haskell
       :type git
       :files (:defaults "*.hs")
       :host github
       :repo "flycheck/flycheck-haskell"
       ;; :init (add-hook 'haskell-mode-hook #'flycheck-haskell-setup)
  )
  )
    )
#+end_src
*** haskell-mode eval after config
#+begin_src emacs-lisp :eval no
  (when (string-equal (getenv "EMACSFOR") "WORK")

    (setq haskell-process-args-stack-ghci '("--ghci-options=-ferror-spans -w"))
    ;; (setq haskell-stylish-on-save t)
    (setq haskell-mode-stylish-haskell-path "brittany")
    (setq haskell-mode-stylish-haskell-arguments "--config-file /Users/codygman/ITProTV/smurf/nucleus/brittany.yaml")

    (with-eval-after-load "haskell-mode"
      (defun haskell-mode-stylish-buffer ()
        "Apply stylish-haskell to the current buffer.

    Use `haskell-mode-stylish-haskell-path' to know where to find
    stylish-haskell executable. This function tries to preserve
    cursor position and markers by using
    `haskell-mode-buffer-apply-command'."
        (interactive)
        (haskell-mode-buffer-apply-command haskell-mode-stylish-haskell-path haskell-mode-stylish-haskell-arguments))

      (defun haskell-mode-buffer-apply-command (cmd args)
        "Execute shell command CMD with current buffer as input and output.
    Use buffer as input and replace the whole buffer with the
    output.  If CMD fails the buffer remains unchanged."
        (set-buffer-modified-p t)
        (let* ((out-file (make-temp-file "stylish-output"))
               (err-file (make-temp-file "stylish-error")))
          (unwind-protect
              (let* ((_errcode
                      (call-process-region (point-min) (point-max) cmd haskell-mode-stylish-haskell-arguments
                                           `((:file ,out-file) ,err-file)
                                           nil))
                     (err-file-empty-p
                      (equal 0 (nth 7 (file-attributes err-file))))
                     (out-file-empty-p
                      (equal 0 (nth 7 (file-attributes out-file)))))
                (if err-file-empty-p
                    (if out-file-empty-p
                        (message "Error: %s produced no output and no error information, leaving buffer alone" cmd)
                      ;; Command successful, insert file with replacement to preserve
                      ;; markers.
                      (insert-file-contents out-file nil nil nil t))
                  (progn
                    ;; non-null stderr, command must have failed
                    (with-current-buffer
                        (get-buffer-create "*haskell-mode*")
                      (insert-file-contents err-file)
                      (buffer-string))
                    (message "Error: %s ended with errors, leaving buffer alone, see *haskell-mode* buffer for stderr" cmd)
                    (with-temp-buffer
                      (insert-file-contents err-file)
                      ;; use (warning-minimum-level :debug) to see this
                      (display-warning cmd
                                       (buffer-substring-no-properties (point-min) (point-max))
                                       :debug)))))
            (ignore-errors
              (delete-file err-file))
            (ignore-errors
              (delete-file out-file))))))
  )
#+end_src
** Personal Haskell
#+begin_src emacs-lisp
  (use-package direnv
    :if (string-equal (getenv "EMACSFOR") "PERSONAL")
    :config
    (direnv-mode))
  (use-package haskell-mode
    :mode ("\\.hs" . haskell-mode)
    :if (string-equal (getenv "EMACSFOR") "PERSONAL")
    :after (direnv)
    :init
    (message "personal haskell-mode loading")
    (add-hook 'haskell-mode-hook 'interactive-haskell-mode)
    (add-hook 'haskell-mode-hook 'haskell-indentation-mode)
    (add-hook 'haskell-mode-hook (lambda () (direnv-update-environment) (dante-mode)))
    (use-package dante
      :after (haskell-mode)
      :commands 'dante-mode
      :if (string-equal (getenv "EMACSFOR") "PERSONAL")
      :config
      (make-variable-buffer-local 'dante-target)
      (setq dante-methods '(new-build stack bare-cabal bare-ghci))
      (setq dante-load-flags
            '("+c" "-fno-diagnostics-show-caret" "-Wwarn=missing-home-modules" "-ferror-spans" "-fdiagnostics-color=never")))
    )
#+end_src
** other languages
#+begin_src emacs-lisp
  (use-package elm-mode
    :defer t)

  (use-package web-mode
    :defer t
    :mode (("\\.js\\'" . web-mode)
           ("\\.jsx\\'" . web-mode)
           ("\\.ts\\'" . web-mode)
           ("\\.tsx\\'" . web-mode)
           ("\\.html\\'" . web-mode)
           ("\\.vue\\'" . web-mode)
           ("\\.json\\'" . web-mode))
    :interpreter ("node" . web-mode)
    :commands web-mode
    :config
    (setq-default web-mode-code-indent-offset 2)
    (setq-default web-mode-markup-indent-offset 2)
    (setq-default web-mode-enable-auto-pairing nil)
    (setq-default web-mode-enable-auto-indentation nil)
    (setq-default web-mode-enable-auto-quoting nil)

    (add-hook 'web-mode-hook
              (lambda ()
                (setq indent-tabs-mode nil)
                (when
                    (or
                     (string-equal "jsx" (file-name-extension buffer-file-name))
                     (string-equal "js" (file-name-extension buffer-file-name)))
                  (if (flycheck-may-use-checker 'javascript-eslint)
                      (progn
                        (my/use-eslint-from-node-modules)
                        (flycheck-select-checker 'javascript-eslint)
                        (flycheck-mode))))))
    (add-hook 'web-mode-hook
              (lambda ()
                (when
                    (string-equal "json" (file-name-extension buffer-file-name))
                  (progn
                    (flycheck-select-checker 'web-mode-python-json)
                    (flycheck-mode)))))
    (add-hook 'web-mode-hook
              (lambda ()
                (when
                    (or
                     (string-equal "tsx" (file-name-extension buffer-file-name))
                     (string-equal "ts" (file-name-extension buffer-file-name)))
                  (setup-tide-mode)))))

  ;; JavaScript
  ;;(use-package js2-mode
  ;;  :init
  ;;  (add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode)))
  ;;(use-package tern)

    ;;;; Rust
  ;;(use-package rust-mode
  ;;  :init
  ;;  (add-to-list 'auto-mode-alist '("\\.rs\\'" . rust-mode)))
  ;;
  ;;(use-package lsp-rust
  ;;  :init
  ;;  (setq lsp-rust-rls-command '("rustup" "run" "nightly" "rls"))
  ;;  (add-hook 'rust-mode-hook #'lsp-rust-enable)
  ;;  (add-hook 'rust-mode-hook #'flycheck-mode))
  ;;
  ;; ;; Typescript
  ;;(use-package typescript-mode
  ;;  :init
  ;;  (add-to-list 'auto-mode-alist '("\\.ts\\'" . typescript-mode)))
  ;;
  ;;(use-package tide
  ;;  :after (typescript-mode company flycheck)
  ;;  :hook ((typescript-mode . tide-setup)
  ;;         (typescript-mode . tide-hl-identifier-mode)))
  ;;
#+end_src
* Load secret elisp things
#+begin_src emacs-lisp
  (load "~/.emacs.d/private/custom.el" t 'noerror)
#+end_src
* Misc rest of config
:PROPERTIES:
:ID:       90b463e7-8d7b-458b-93fb-ea6806f0e5bb
:END:
#+begin_src emacs-lisp
  (use-package nix-mode)

  (use-package org-edna
    :after org
    :config
    (org-edna-load))

  (defun find-dotfile ()
    "Edit the `dotfile', in the current window."
    (interactive)
    (find-file-existing (concat user-emacs-directory "emacs-config.org")))

  ;; Some term enhancement
  (defadvice term-sentinel (around my-advice-term-sentinel (proc msg))
    (if (memq (process-status proc) '(signal exit))
        (let ((buffer (process-buffer proc)))
          ad-do-it
          (kill-buffer buffer))
      ad-do-it))
  (ad-activate 'term-sentinel)

  (defadvice ansi-term (before force-bash)
    (interactive (list "/bin/zsh")))
  (ad-activate 'ansi-term)



  ;; ediff
  (setq ediff-window-setup-function 'ediff-setup-windows-plain)
  (setq ediff-split-window-function 'split-window-horizontally)

  ;; Keybinding for term mode
  (add-hook 'term-mode
            (lambda () (global-set-key (kbd "s-v") 'term-paste)))



  ;; (use-package real-auto-save
  ;;   :diminish (real-auto-save-mode)
  ;;   :config
  ;;   (setq real-auto-save-interval 10) ;; in seconds
  ;;   (add-hook 'org-mode-hook 'real-auto-save-mode)
  ;;   (add-hook 'prog-mode-hook 'real-auto-save-mode))

  (defun shk-yas/helm-prompt (prompt choices &optional display-fn)
    "Use helm to select a snippet. Put this into `yas-prompt-functions.'"
    (interactive)
    (setq display-fn (or display-fn 'identity))
    (if (require 'helm-config)
        (let (tmpsource cands result rmap)
          (setq cands (mapcar (lambda (x) (funcall display-fn x)) choices))
          (setq rmap (mapcar (lambda (x) (cons (funcall display-fn x) x)) choices))
          (setq tmpsource
                (list
                 (cons 'name prompt)
                 (cons 'candidates cands)
                 '(action . (("Expand" . (lambda (selection) selection))))))
          (setq result (helm-other-buffer '(tmpsource) "*helm-select-yasnippet"))
          (if (null result)
              (signal 'quit "user quit!")
            (cdr (assoc result rmap))))
      nil))

  (straight-use-package 'origami)
  (use-package origami
      :general (:keymaps 'org-super-agenda-header-map
                         "TAB" #'origami-toggle-node)
      :config


      (defvar ap/org-super-agenda-auto-show-groups
        '("3 Things I'm Doing Today No Matter What" "Schedule" "Today"))
      (defvar ap/org-super-agenda-auto-show-groups
        '("Schedule" ))

      (defun ap/org-super-agenda-origami-fold-default ()
        "Fold certain groups by default in Org Super Agenda buffer."
        (forward-line 3)
        (cl-loop do (origami-forward-toggle-node (current-buffer) (point))
                 while (origami-forward-fold-same-level (current-buffer) (point)))
        (--each ap/org-super-agenda-auto-show-groups
          (goto-char (point-min))
          (when (re-search-forward (rx-to-string `(seq bol " " ,it)) nil t)
            (origami-show-node (current-buffer) (point)))))

      :hook ((org-agenda-mode . origami-mode)
             (org-agenda-finalize . ap/org-super-agenda-origami-fold-default)))

  (use-package org-super-agenda
    :after '(org)
    :init
    (require 'org-habit)
    (setq org-super-agenda-groups
          '((:log t)  ; Automatically named "Log"
            (:name "3 Things I'm Doing Today No Matter What"
                     :and (
                           :tag ("3ThingsToday")
                           ;; :pred (lambda (item) (string-equal (get-text-property 0 'level item) "  "))
                           :scheduled today))

            (:name "Keystone Habits"
             :tag ("keystone"))

            (:name "Schedule"
             :discard (:tag ("habit"))
             :time-grid t)

            (:name "Next to do"
                   :todo "NEXT"
                   :order 1)

            (:name "Today"
                   :scheduled today)

            (:name "Due today"
                   :deadline today)

            (:name "Overdue"
                   :deadline past)

            (:name "Due soon"
                   :deadline future)

            (:name "All Habits"
                   :habit)

            (:name "Unimportant"
                   :todo ("SOMEDAY" "MAYBE" "CHECK" "TO-READ" "TO-WATCH")
                   :order 100)

            (:name "Waiting..."
                   :todo "WAITING"
                   :order 98)

            (:name "Scheduled earlier"
                   :scheduled past)))

    :hook ((org-agenda-mode . org-super-agenda-mode) (org-agenda-mode . origami-mode))
    :config
    (setq org-super-agenda-header-map (make-sparse-keymap))
    (general-define-key :keymaps 'org-super-agenda-header-map
                         "<tab>" #'origami-toggle-node
                        "q" 'org-agenda-quit))

  (use-package org-ql
    :after '(org)
    :straight
    (org-ql
     :type git
     :host github
     :repo "alphapapa/org-ql"))
  ;; allow copying both to buffer in ediff
  (defun ediff-copy-both-to-C ()
    (interactive)
    (ediff-copy-diff ediff-current-difference nil 'C nil
                     (concat
                      (ediff-get-region-contents ediff-current-difference 'A ediff-control-buffer)
                      (ediff-get-region-contents ediff-current-difference 'B ediff-control-buffer))))
  (defun add-d-to-ediff-mode-map () (define-key ediff-mode-map "d" 'ediff-copy-both-to-C))
  (add-hook 'ediff-keymap-setup-hook 'add-d-to-ediff-mode-map)

  ;; TODO this might be a little faster? - spacemacs/toggle-fullscreen ()
  (defun spacemacs/toggle-frame-fullscreen-non-native ()
    "Toggle full screen non-natively. Uses the `fullboth' frame paramerter
               rather than `fullscreen'. Useful to fullscreen on OSX w/o animations."
    (interactive)
    (modify-frame-parameters
     nil
     `((maximized
        . ,(unless (memq (frame-parameter nil 'fullscreen) '(fullscreen fullboth))
             (frame-parameter nil 'fullscreen)))
       (fullscreen
        . ,(if (memq (frame-parameter nil 'fullscreen) '(fullscreen fullboth))
               (if (eq (frame-parameter nil 'maximized) 'maximized)
                   'maximized)
             'fullboth)))))


  (use-package ledger-mode :defer t)

  ;; our own implementation of kill-this-buffer from menu-bar.el
  (defun spacemacs/kill-this-buffer (&optional arg)
    "Kill the current buffer.
            If the universal prefix argument is used then kill also the window."
    (interactive "P")
    (if (window-minibuffer-p)
        (abort-recursive-edit)
      (if (equal '(4) arg)
          (kill-buffer-and-window)
        (kill-buffer))))

  (defun my-switch-to-scratch-buffer ()
    (switch-to-buffer (get-buffer-create "*scratch*")))

  (defun toggle-maximize-buffer () "Maximize buffer"
         (interactive)
         (if (= 1 (length (window-list)))
             (jump-to-register '_)
           (progn
             (window-configuration-to-register '_)
             (delete-other-windows))))

  (defun my-write-then-normal-state ()
    (evil-normal-state))

   (custom-set-variables
    ;; custom-set-variables was added by Custom.
    ;; If you edit it by hand, you could mess it up, so be careful.
    ;; Your init file should contain only one such instance.
    ;; If there is more than one, they won't work right.
    '(custom-safe-themes
      (quote
       ("f8067b7d0dbffb29a79e0843797efabdf5e1cf326639874d8b407e9b034136a4" "97965ccdac20cae22c5658c282544892959dc541af3e9ef8857dbf22eb70e82b" "9129c2759b8ba8e8396fe92535449de3e7ba61fd34569a488dd64e80f5041c9f" default))))
#+end_src
* load up org mode daily agenda by default
#+begin_src emacs-lisp
  ;; fullscreen, org-agenda-list, and delete other windows
   ;; (spacemacs/toggle-frame-fullscreen-non-native)
   ;; (my-day-org-agenda)
   ;; (add-to-list 'initial-frame-alist '(fullscreen . maximized)) ;; only maximized... but only reliable way I could get it to do it ;; this is not necessary in xmonad... maybe it was in windows?
#+end_src
* archive of commented out code
#+begin_src emacs-lisp


  ;; TODO is it necessary to do a straight-use-package followed by a use-package block to configure?




  ;; give us more room with helm buffer names
  ;; NOTE just leaving at default of 60 so that helm works same even when not fullscreen
  ;; you can just press C-[ in a helm buffer to show full filenames
  ;; (setq helm-buffer-max-length 100)






  ;; desktop+ that works with indirect buffers
  ;; (straight-use-package
  ;;  '(desktop+ :type git :host github :repo "ffevotte/desktop-plus"))

  ;; ;; ;; persp-mode (like winum but w file persistence)
  ;; (straight-use-package
  ;;  '(el-patch :type git :host github :repo "Bad-ptr/persp-mode.el"))

  ;; (add-hook 'after-init-hook #'(lambda () (persp-mode 1)))
  ;; make indirect buffers work with persp-mode
  ;; (with-eval-after-load "persp-mode"
  ;;   (defvar persp-indirrect-buffers-to-restore nil)

  ;;   (persp-def-buffer-save/load
  ;;    :tag-symbol 'def-indirect-buffer
  ;;    :predicate #'buffer-base-buffer
  ;;    :save-function
  ;;     #'(lambda (buf tag vars)
  ;;         (list tag (buffer-name buf) vars
  ;;               (buffer-name (buffer-base-buffer))))
  ;;     :load-function
  ;;     #'(lambda (savelist &rest _rest)
  ;;         (destructuring-bind
  ;;             (buf-name vars base-buf-name &rest _rest) (cdr savelist)
  ;;           (push (cons buf-name base-buf-name)
  ;;                 persp-indirrect-buffers-to-restore)
  ;;           nil)))

  ;;   (add-hook 'persp-after-load-state-functions
  ;;             #'(lambda (&rest _args)
  ;;                 (dolist (ibc persp-indirrect-buffers-to-restore)
  ;;                   (let* ((nbn (car ibc))
  ;;                          (bbn (cdr ibc))
  ;;                          (bb (get-buffer bbn)))
  ;;                     (when bb
  ;;                       (when (get-buffer nbn)
  ;;                         (setq nbn (generate-new-buffer-name nbn)))
  ;;                       (make-indirect-buffer bb nbn t))))
  ;;                 (setq persp-indirrect-buffers-to-restore nil))))

  ;; weird error
  ;; Error (use-package): org-pomodoro/:catch: Invalid read syntax: ")"
  ;; (use-package org-pomodoro



  ;; (use-package intero
  ;;   :config (intero-global-mode 1) ;; set Intero 'on'
  ;;   )
  ;; ;; (use-package perspective
  ;;   :init (persp-mode))





  ;; not sure if this works
  ;; (use-package hare
  ;;    )
  ;; doesn't seem to

  ;; hare readme recommends this
  ;; (add-to-list 'load-path "~/.emacs.d/HaRe/elisp")
  ;; (require 'hare)
  ;; (autoload 'hare-init "hare" nil t)

  					; Company mode



  ;; (use-package floobits)

  ;; WORKING haskell-mode stuff - 2018-11-20
  ;; (require 'haskell-interactive-mode)
  ;; (require 'haskell-process)
  ;; (add-hook 'haskell-mode-hook 'interactive-haskell-mode)

  ;; (use-package company-lsp
  ;;   :init
  ;;   (push 'company-lsp company-backends))

  ;;;;;;;;;;;;;;;;;;;;;;;
  ;; Language Supports ;;
  ;;;;;;;;;;;;;;;;;;;;;;;


  ;; (defun my-non-fullscreen ()
  ;;   (interactive)
  ;;   (if (fboundp 'w32-send-sys-command)
  ;; 	  ;; WM_SYSCOMMAND restore #xf120
  ;; 	  (w32-send-sys-command 61728)
  ;; 	(progn (set-frame-parameter nil 'width 82)
  ;; 		   (set-frame-parameter nil 'fullscreen 'fullheight))))

  ;; (defun my-fullscreen ()
  ;;   (interactive)
  ;;   (if (fboundp 'w32-send-sys-command)
  ;; 	  ;; WM_SYSCOMMAND maximaze #xf030
  ;; 	  (w32-send-sys-command 61488)
  ;; 	(set-frame-parameter nil 'fullscreen 'fullboth)))

  ;; (defun my-toggle-fullscreen ()
  ;;   (interactive)
  ;;   (setq my-fullscreen-p (not my-fullscreen-p))
  ;;   (if my-fullscreen-p
  ;; 	  (my-non-fullscreen)
  ;; 	(my-fullscreen)))

  ;; fullscreen, org-agenda-list, and delete other windows
  ;; (spacemacs/toggle-frame-fullscreen-non-native)
  ;; (org-agenda nil "c")
  ;; (progn (switch-to-buffer "*Org Agenda*") (delete-other-windows))
  ;; (add-to-list 'initial-frame-alist '(fullscreen . maximized)) ;; only maximized... but only reliable way I could get it to do it

  ;; custom function definitions I may need to move to top
  ;; (defun org-clock-save ()
  ;;   "Persist various clock-related data to disk.
  ;; The details of what will be saved are regulated by the variable
  ;; `org-clock-persist'."
  ;;   (when (and org-clock-persist
  ;; 	     (or org-clock-loaded
  ;; 		 org-clock-has-been-used
  ;; 		 (not (file-exists-p org-clock-persist-file))))
  ;;     (with-temp-file org-clock-persist-file
  ;;       (insert (format ";; %s - %s at %s\n"
  ;; 		      (file-name-nondirectory org-clock-persist-file)
  ;; 		      (system-name)
  ;; 		      (format-time-string (org-time-stamp-format t))))
  ;;       ;; Store clock to be resumed.
  ;;       (when (and (memq org-clock-persist '(t clock))
  ;; 		 (let ((b (org-base-buffer (org-clocking-buffer))))
  ;; 		   (and (buffer-live-p b)
  ;; 			(buffer-file-name b)
  ;; 			(or (not org-clock-persist-query-save)
  ;; 			    (y-or-n-p (format "Save current clock (%s) "
  ;; 					      org-clock-heading))))))
  ;; 	(insert
  ;; 	 (format "(setq org-clock-stored-resume-clock '(%S . %d))\n"
  ;; 		 (buffer-file-name (org-base-buffer (org-clocking-buffer)))
  ;; 		 (marker-position org-clock-marker))))
  ;;       ;; Store clocked task history.  Tasks are stored reversed to
  ;;       ;; make reading simpler.
  ;;       (when (and (memq org-clock-persist '(t history))
  ;; 		 org-clock-history)
  ;; 	(insert
  ;; 	 (replace-regexp-in-string "/home/cody/" "~/" (format "(setq org-clock-stored-history '(%s))\n"
  ;; 							      (mapconcat
  ;; 							       (lambda (m)
  ;; 								 (let ((b (org-base-buffer (marker-buffer m))))
  ;; 								   (when (and (buffer-live-p b)
  ;; 									      (buffer-file-name b))
  ;; 								     (format "(%S . %d)"
  ;; 									     (buffer-file-name b)
  ;; 									     (marker-position m)))))
  ;; 							       (reverse org-clock-history)
  ;; 							       " "))))))))

  ;; ~/.emacs.d/private/custom.el contains customizations per machine/for work/play/personal based on machine
  ;; examples
  ;; - org capture templates
  ;; - org agenda custom commands
  ;; - experimental sutff

  ;; haskell










  ;; Projectile


  ;; Helm Projectile


  ;; All The Icons


  ;; NeoTree
  ;;(use-package neotree
  ;;  :init
  ;;  (setq neo-theme (if (display-graphic-p) 'icons 'arrow)))

  ;; Which Key

  ;; (use-package keychain-environment
  ;;     :config (keychain-refresh-environment))




  ;; todo refactor this shouldn't be necessary here

  ;; (use-package yasnippet-snippets
  ;;   :defer t
  ;;   :after yasnippet
  ;;   :config
  ;;   (yas-reload-all))




  ;; Apparently the company-yasnippet backend shadows all backends that
  ;; come after it. To work around this we assign yasnippet to a different
  ;; keybind since actual source completion is vital.
  ;;(use-package company-yasnippet
  ;;  ;; :bind ("C-M-y" . company-yasnippet)
  ;;  :after (yasnippet)
  ;;  )
#+end_src
* sanity checks that emacs will probably work right
** make sure user has set org-agenda-files either in work or personal
#+begin_src emacs-lisp
  (if (eq nil org-agenda-files)
      (pcase (getenv "EMACSFOR")
        ("WORK" (error (format "Make sure to set org-agenda-files in: %s" (expand-file-name "work.el" "~"))))
        ("PERSONAL" (error (format "Make sure to set org-agenda-files in: %s" (expand-file-name "personal.el" "~"))))
        (_ (error "Please set the EMACSFOR variable to WORK or PERSONAL")))
    )
#+end_src