aboutsummaryrefslogtreecommitdiffstats
path: root/elpa/evil-20220503.1314/evil-vars.el
blob: 3b1635e48941aef17a5bd59b193f9427caabff36 (plain) (blame)
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
;;; evil-vars.el --- Settings and variables -*- lexical-binding: t -*-

;; Author: Vegard Øye <vegard_oye at hotmail.com>
;; Maintainer: Vegard Øye <vegard_oye at hotmail.com>

;; Version: 1.15.0

;;
;; This file is NOT part of GNU Emacs.

;;; License:

;; This file is part of Evil.
;;
;; Evil is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; Evil is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with Evil.  If not, see <http://www.gnu.org/licenses/>.

;;; Code:

(declare-function evil-add-command-properties "evil-common"
                  (command &rest properties))
(declare-function evil-update-insert-state-bindings "evil-maps"
                  (&optional _option-name remove force))

;;; Hooks

(defvar evil-after-load-hook nil
  "Functions to be run when loading of Evil is finished.
This hook can be used the execute some initialization routines
when Evil is completely loaded.")

(defcustom evil-goto-definition-functions
  '(evil-goto-definition-imenu
    evil-goto-definition-semantic
    evil-goto-definition-xref
    evil-goto-definition-search)
  "List of functions run until success by `evil-goto-definition'."
  :type 'hook
  :group 'evil)

;;; Initialization

(defvar evil-pending-custom-initialize nil
  "A list of pending initializations for custom variables.
Each element is a triple (FUNC VAR VALUE). When Evil is
completely loaded then the functions (funcall FUNC VAR VALUE) is
called for each element. FUNC should be a function suitable for
the :initialize property of `defcustom'.")

(defun evil-custom-initialize-pending-reset (var value)
  "Add a pending customization with `custom-initialize-reset'."
  (push (list 'custom-initialize-reset var value)
        evil-pending-custom-initialize))

(defun evil-run-pending-custom-initialize ()
  "Executes the pending initializations.
See `evil-pending-custom-initialize'."
  (dolist (init evil-pending-custom-initialize)
    (apply (car init) (cdr init)))
  (remove-hook 'evil-after-load-hook 'evil-run-pending-custom-initialize))
(add-hook 'evil-after-load-hook 'evil-run-pending-custom-initialize)

;;; Setters

(defun evil-set-toggle-key (key)
  "Set `evil-toggle-key' to KEY.
KEY must be readable by `read-kbd-macro'."
  (let ((old-key (read-kbd-macro
                  (if (boundp 'evil-toggle-key)
                      evil-toggle-key
                    "C-z")))
        (key (read-kbd-macro key)))
    (with-no-warnings
      (dolist (pair '((evil-motion-state-map evil-emacs-state)
                      (evil-insert-state-map evil-emacs-state)
                      (evil-emacs-state-map evil-exit-emacs-state)))
        (when (boundp (car pair))
          (let ((map (symbol-value (car pair)))
                (fun (cadr pair)))
            (when (keymapp map)
              (define-key map key fun)
              (define-key map old-key nil))))))))

(defun evil-set-custom-state-maps (var pending-var key _make newlist)
  "Changes the list of special keymaps.
VAR         is the variable containing the list of keymaps.
PENDING-VAR is the variable containing the list of the currently pending
            keymaps.
KEY         the special symbol to be stored in the keymaps.
MAKE        the creation function of the special keymaps.
NEWLIST     the list of new special keymaps."
  (set-default pending-var newlist)
  (when (default-boundp var)
    (dolist (map (default-value var))
      (when (and (boundp (car map))
                 (keymapp (default-value (car map))))
        (define-key (default-value (car map)) (vector key) nil))))
  (set-default var newlist)
  (evil-update-pending-maps))

(defun evil-update-pending-maps (&optional _file)
  "Tries to set pending special keymaps.
This function should be called from an `after-load-functions'
hook."
  (let ((maps '((evil-make-overriding-map . evil-pending-overriding-maps)
                (evil-make-intercept-map . evil-pending-intercept-maps))))
    (while maps
      (let* ((map (pop maps))
             (make (car map))
             (pending-var (cdr map))
             (pending (symbol-value pending-var))
             newlist)
        (while pending
          (let* ((map (pop pending))
                 (kmap (and (boundp (car map))
                            (keymapp (symbol-value (car map)))
                            (symbol-value (car map))))
                 (state (cdr map)))
            (if kmap
                (funcall make kmap state)
              (push map newlist))))
        (set-default pending-var newlist)))))

(defun evil-set-visual-newline-commands (var value)
  "Set the value of `evil-visual-newline-commands'.
Setting this variable changes the properties of the appropriate
commands."
  (with-no-warnings
    (when (default-boundp var)
      (dolist (cmd (default-value var))
        (evil-set-command-property cmd :exclude-newline nil)))
    (set-default var value)
    (dolist (cmd (default-value var))
      (evil-set-command-property cmd :exclude-newline t))))

(defun evil-set-custom-motions (var values)
  "Sets the list of motion commands."
  (with-no-warnings
    (when (default-boundp var)
      (dolist (motion (default-value var))
        (evil-add-command-properties motion :keep-visual nil :repeat nil)))
    (set-default var values)
    (mapc #'evil-declare-motion (default-value var))))

;;; Customization group

(defgroup evil nil
  "Extensible vi layer."
  :group 'emulations
  :prefix 'evil-)

(defcustom evil-auto-indent t
  "\\<evil-normal-state-map>
Whether to auto-indent when opening lines with \\[evil-open-below] \
and \\[evil-open-above]."
  :type  'boolean
  :group 'evil)
(make-variable-buffer-local 'evil-auto-indent)

(defcustom evil-shift-width 4
  "\\<evil-normal-state-map>
The number of columns by which a line is shifted.
This applies to the shifting operators \\[evil-shift-right] and \
\\[evil-shift-left]."
  :type 'integer
  :group 'evil)
(make-variable-buffer-local 'evil-shift-width)

(defcustom evil-shift-round t
  "\\<evil-normal-state-map>
Whether shifting rounds to the nearest multiple.
If non-nil, \\[evil-shift-right] and \\[evil-shift-left] adjust line
indentation to the nearest multiple of `evil-shift-width'."
  :type 'boolean
  :group 'evil)
(make-variable-buffer-local 'evil-shift-round)

(defcustom evil-indent-convert-tabs t
  "\\<evil-normal-state-map>
If non-nil, the \\[evil-indent] operator converts between leading tabs and spaces.
Whether tabs are converted to spaces or vice versa depends on the
value of `indent-tabs-mode'."
  :type 'boolean
  :group 'evil)

(defcustom evil-default-cursor t
  "The default cursor.
May be a cursor type as per `cursor-type', a color string as passed
to `set-cursor-color', a zero-argument function for changing the
cursor, or a list of the above."
  :type '(set symbol (cons symbol symbol) string function)
  :group 'evil)

(defvar evil-force-cursor nil
  "Overwrite the current states default cursor.")

(defcustom evil-start-of-line nil
  "Analogue of vim's `startofline'.
If nil, preserve column when making relevant movements of the cursor.
Otherwise, move the cursor to the start of the line."
  :type 'boolean
  :group 'evil)

(defcustom evil-repeat-move-cursor t
  "\\<evil-normal-state-map>
Whether repeating commands with \\[evil-repeat] may move the cursor.
If nil, the original cursor position is preserved, even if the command
normally would have moved the cursor."
  :type 'boolean
  :group 'evil)

(defcustom evil-cross-lines nil
  "\\<evil-motion-state-map>
Whether horizontal motions may move to other lines.  If non-nil,
certain motions that conventionally operate in a single line may move
the cursor to other lines.  Otherwise, they are restricted to the
current line.  This applies to \\[evil-backward-char], \
\\[evil-forward-char], \\[evil-find-char], \
\\[evil-find-char-backward], \\[evil-find-char-to], \
\\[evil-find-char-to-backward], \
\\<evil-normal-state-map>\\[evil-invert-char]."
  :type 'boolean
  :group 'evil)

(defcustom evil-backspace-join-lines t
  "Whether backward delete in insert state may join lines."
  :type 'boolean
  :group 'evil)

(defcustom evil-move-cursor-back t
  "Whether the cursor is moved backwards when exiting insert state.
If non-nil, the cursor moves \"backwards\" when exiting insert state,
so that it ends up on the character to the left.  Otherwise it remains
in place, on the character to the right."
  :type 'boolean
  :group 'evil)

(defcustom evil-move-beyond-eol nil
  "Whether the cursor can move past the end of the line.
If non-nil, the cursor is allowed to move one character past the
end of the line, as in Emacs."
  :type 'boolean
  :group 'evil)

(defcustom evil-respect-visual-line-mode nil
  "\\<evil-motion-state-map>
Whether movement commands respect `visual-line-mode'.
If non-nil, `visual-line-mode' is generally respected when it is
on.  In this case, motions such as \\[evil-next-line] and
\\[evil-previous-line] navigate by visual lines (on the screen) rather
than \"physical\" lines (defined by newline characters).  If nil,
the setting of `visual-line-mode' is ignored.

This variable must be set before Evil is loaded."
  :type 'boolean
  :group 'evil)

(defcustom evil-repeat-find-to-skip-next t
  "Whether a repeat of t or T should skip an adjacent character."
  :type 'boolean
  :group 'evil)

(defcustom evil-kbd-macro-suppress-motion-error nil
  "\\<evil-motion-state-map>
Whether left/right motions signal errors in keyboard macros.
This variable only affects beginning-of-line or end-of-line errors
regarding the motions \\[evil-backward-char] and \\[evil-forward-char]
respectively.  This may be desired since such errors cause macro
definition or execution to be terminated.  There are four
possibilities:

- `record': errors are suppressed when recording macros, but not when
  replaying them.
- `replay': errors are suppressed when replaying macros, but not when
  recording them.
- `t': errors are suppressed in both cases.
- `nil': errors are never suppressed."
  :type '(radio (const :tag "No" :value nil)
                (const :tag "Record" :value record)
                (const :tag "Replay" :value replay)
                (const :tag "Both" :value t))
  :group 'evil)

(defcustom evil-track-eol t
  "\\<evil-motion-state-map>
Whether \\[evil-end-of-line] \"sticks\" the cursor to the end of the line.
If non-nil, vertical motions after \\[evil-end-of-line] maintain the cursor at the
end of the line, even if the target line is longer.  This is analogous
to `track-eol', but respects Evil's interpretation of end-of-line."
  :type 'boolean
  :group 'evil)

(defcustom evil-mode-line-format 'before
  "The position of the state tag in the mode line.
If set to `before' or `after', the tag is placed at the beginning
or the end of the mode-line, respectively.  If nil, there is no
tag.  Otherwise it should be a cons cell (WHERE . WHICH), where
WHERE is either `before' or `after', and WHICH is a symbol in
`mode-line-format'.  The tag is then placed before or after that
symbol, respectively."
  :type '(radio :value 'before
                (const before)
                (const after)
                (cons :tag "Next to symbol"
                      (choice :value after
                              (const before)
                              (const after))
                      symbol))
  :group 'evil)

(defcustom evil-mouse-word 'evil-word
  "The thing-at-point symbol for double click selection.
The double-click starts visual state in a special word selection
mode. This symbol is used to determine the words to be
selected. Possible values are `evil-word' or `evil-WORD'."
  :type 'symbol
  :group 'evil)

(defcustom evil-bigword "^ \t\r\n"
  "The set of characters to be interpreted as WORD boundaries.
This is enclosed with square brackets and used as a regular
expression.  By default, whitespace characters are considered
WORD boundaries."
  :type 'string
  :group 'evil)
(make-variable-buffer-local 'evil-bigword)

(defcustom evil-want-fine-undo nil
  "Whether actions are undone in several steps.
There are two possible choices: nil (\"no\") means that all
changes made during insert state, including a possible delete
after a change operation, are collected in a single undo step.
Non-nil (\"yes\") means that undo steps are determined according
to Emacs heuristics, and no attempt is made to aggregate changes.

For backward compatibility purposes, the value `fine' is
interpreted as `nil'.  This option was removed because it did not
work consistently."
  :type '(radio (const :tag "No" :value nil)
                (const :tag "Fine (obsolete)" :value fine)
                (const :tag "Yes" :value t))
  :group 'evil)

(defcustom evil-regexp-search t
  "\\<evil-motion-state-map>
Whether to use regular expressions for searching in \
\\[evil-search-forward] and \\[evil-search-backward]."
  :type  'boolean
  :group 'evil)

(defcustom evil-search-wrap t
  "\\<evil-motion-state-map>
Whether search with \\[evil-search-forward] and \
\\[evil-search-backward] wraps around the buffer.
If this is non-nil, search stops at the buffer boundaries."
  :type  'boolean
  :group 'evil)

(defcustom evil-flash-delay 2
  "\\<evil-motion-state-map>
Time in seconds to flash search matches after \\[evil-search-next] and \
\\[evil-search-previous]."
  :type  'number
  :group 'evil)

(defcustom evil-auto-balance-windows t
  "If non-nil window creation and deletion trigger rebalancing."
  :type 'boolean
  :group 'evil)

(defcustom evil-split-window-below nil
  "If non-nil split windows are created below."
  :type 'boolean
  :group 'evil)

(defcustom evil-vsplit-window-right nil
  "If non-nil vertically split windows with are created to the right."
  :type 'boolean
  :group 'evil)

(defcustom evil-esc-delay 0.01
  "The time, in seconds, to wait for another key after escape.
If no further event arrives during this time, the event is
translated to `ESC'.  Otherwise, it is translated according to
`input-decode-map'.  This does not apply in Emacs state, and may
also be inhibited by setting `evil-inhibit-esc'."
  :type 'number
  :group 'evil)

(defvar evil-esc-mode nil
  "Non-nil if `evil-esc-mode' is enabled.")

(defvar evil-esc-map nil
  "Original ESC prefix map in `input-decode-map'.
Used by `evil-esc-mode'.")

(defvar evil-inhibit-esc nil
  "If non-nil, the \\e event will never be translated to 'escape.")

(defcustom evil-intercept-esc 'always
  "Whether Evil should intercept the escape key.
In the terminal, escape and a meta key sequence both generate the
same event.  In order to distingush these, Evil uses
`input-decode-map'.  It is not necessary to do this in a graphical
Emacs session.  However, if you prefer to use `C-[' as escape (which
is identical to the terminal escape key code), this interception must
also happen in graphical Emacs sessions.  Set this variable to
`always', t (only in the terminal) or nil (never intercept)."
  :type '(radio (const :tag "Never" :value nil)
                (const :tag "In terminal only" :value t)
                (const :tag "Always" :value always))
  :group 'evil)

(defcustom evil-show-paren-range 0
  "The minimal distance between point and a parenthesis
which causes the parenthesis to be highlighted."
  :type 'integer
  :group 'evil)

(defcustom evil-ex-hl-update-delay 0.02
  "Time in seconds of idle before updating search highlighting.
Setting this to a period shorter than that of keyboard's repeat
rate allows highlights to update while scrolling."
  :type 'number
  :group 'evil)

(defcustom evil-highlight-closing-paren-at-point-states
  '(not emacs insert replace)
  "The states in which the closing parenthesis at point should be highlighted.
All states listed here highlight the closing parenthesis at
point (which is Vim's default behavior).  All others highlight the
parenthesis before point (which is Emacs default behavior). If
this list contains the symbol `not' then its meaning is inverted,
i.e. all states listed here highlight the closing parenthesis
before point."
  :type '(repeat symbol)
  :group 'evil)

(defcustom evil-kill-on-visual-paste t
  "Whether pasting in visual state adds the replaced text to the
kill ring, making it the default for the next paste. The default,
replicates the default Vim behavior."
  :type 'boolean
  :group 'evil)

(defcustom evil-want-C-i-jump t
  "Whether `C-i' jumps forward in the jump list (like Vim).
Otherwise, `C-i' inserts a tab character."
  :type 'boolean
  :group 'evil
  :set #'(lambda (sym value)
           (set-default sym value)
           (when (boundp 'evil-motion-state-map)
             (cond
              ((and (not value)
                    (eq (lookup-key evil-motion-state-map (kbd "C-i"))
                        'evil-jump-forward))
               (define-key evil-motion-state-map (kbd "C-i") nil))
              ((and value
                    (not (lookup-key evil-motion-state-map (kbd "C-i"))))
               (define-key evil-motion-state-map (kbd "C-i") 'evil-jump-forward))))))

(defcustom evil-want-C-u-scroll nil
  "Whether `C-u' scrolls up (like Vim).
Otherwise, `C-u' applies a prefix argument.  The binding of
`C-u' mirrors Emacs behaviour by default due to the relative
ubiquity of prefix arguments."
  :type 'boolean
  :group 'evil
  :set #'(lambda (sym value)
           (set-default sym value)
           (when (boundp 'evil-motion-state-map)
             (cond
              ((and (not value)
                    (eq (lookup-key evil-motion-state-map (kbd "C-u"))
                        'evil-scroll-up))
               (define-key evil-motion-state-map (kbd "C-u") nil))
              ((and value
                    (not (lookup-key evil-motion-state-map (kbd "C-u"))))
               (define-key evil-motion-state-map (kbd "C-u") 'evil-scroll-up))))))

(defcustom evil-want-C-d-scroll t
  "Whether `C-d' scrolls down (like Vim)."
  :type 'boolean
  :group 'evil
  :set #'(lambda (sym value)
           (set-default sym value)
           (when (boundp 'evil-motion-state-map)
             (cond
              ((and (not value)
                    (eq (lookup-key evil-motion-state-map (kbd "C-d"))
                        'evil-scroll-down))
               (define-key evil-motion-state-map (kbd "C-d") nil))
              ((and value
                    (not (lookup-key evil-motion-state-map (kbd "C-d"))))
               (define-key evil-motion-state-map (kbd "C-d") 'evil-scroll-down))))))

(defcustom evil-want-C-u-delete nil
  "Whether `C-u' deletes back to indentation in insert state.
Otherwise, `C-u' applies a prefix argument.  The binding of
`C-u' mirrors Emacs behaviour by default due to the relative
ubiquity of prefix arguments."
  :type 'boolean
  :group 'evil
  :set #'(lambda (sym value)
           (set-default sym value)
           (when (and (boundp 'evil-insert-state-map)
                      (boundp 'evil-replace-state-map))
             (cond
              ((and (not value)
                    (eq (lookup-key evil-insert-state-map (kbd "C-u"))
                        'evil-delete-back-to-indentation))
               (define-key evil-insert-state-map (kbd "C-u") nil)
               (define-key evil-replace-state-map (kbd "C-u") nil))
              ((and value
                    (not (lookup-key evil-insert-state-map (kbd "C-u"))))
               (define-key evil-insert-state-map (kbd "C-u") 'evil-delete-back-to-indentation)
               (define-key evil-replace-state-map (kbd "C-u") 'evil-delete-back-to-indentation))))))

(defcustom evil-want-C-w-delete t
  "Whether `C-w' deletes a word in Insert state."
  :type 'boolean
  :group 'evil
  :set #'(lambda (sym value)
           (set-default sym value)
           (when (and (boundp 'evil-insert-state-map)
                      (boundp 'evil-replace-state-map))
             (cond
              ((and (not value)
                    (eq (lookup-key evil-insert-state-map (kbd "C-w"))
                        'evil-delete-backward-word))
               (define-key evil-insert-state-map (kbd "C-w") 'evil-window-map)
               (define-key evil-replace-state-map (kbd "C-w") 'evil-window-map))
              ((and value
                    (eq (lookup-key evil-insert-state-map (kbd "C-w"))
                        'evil-window-map))
               (define-key evil-insert-state-map (kbd "C-w") 'evil-delete-backward-word)
               (define-key evil-replace-state-map (kbd "C-w") 'evil-delete-backward-word))))))

(defcustom evil-want-C-h-delete nil
  "Whether `C-h' deletes a char in Insert state."
  :type 'boolean
  :group 'evil
  :set #'(lambda (sym value)
           (set-default sym value)
           (when (and (boundp 'evil-insert-state-map)
                      (boundp 'evil-replace-state-map))
             (cond
              ((and (not value)
                    (eq (lookup-key evil-insert-state-map (kbd "C-h"))
                        'evil-delete-backward-char-and-join))
               (define-key evil-insert-state-map (kbd "C-h") nil)
               (define-key evil-replace-state-map (kbd "C-h") nil))
              ((and value
                    (not (lookup-key evil-insert-state-map (kbd "C-h"))))
               (define-key evil-insert-state-map (kbd "C-h") 'evil-delete-backward-char-and-join)
               (define-key evil-replace-state-map (kbd "C-h") 'evil-replace-backspace))))))

(defcustom evil-want-C-g-bindings nil
  "Whether `C-g' postfix can be used in bindings."
  :type 'boolean
  :group 'evil)

(defcustom evil-want-C-w-in-emacs-state nil
  "Whether `C-w' prefixes windows commands in Emacs state."
  :type 'boolean
  :group 'evil
  :set #'(lambda (sym value)
           (set-default sym value)
           (when (boundp 'evil-emacs-state-map)
             (cond
              ((and (not value)
                    (eq (lookup-key evil-emacs-state-map (kbd "C-w"))
                        'evil-window-map))
               (define-key evil-emacs-state-map (kbd "C-w") nil))
              ((and value
                    (not (lookup-key evil-emacs-state-map (kbd "C-w"))))
               (define-key evil-emacs-state-map (kbd "C-w") 'evil-window-map))))))

(defcustom evil-want-change-word-to-end t
  "Whether `cw' behaves like `ce'."
  :type 'boolean
  :group 'evil)

(defcustom evil-want-Y-yank-to-eol nil
  "Whether `Y' yanks to the end of the line.
The default behavior is to yank the whole line, like Vim."
  :group 'evil
  :type 'boolean
  :initialize #'evil-custom-initialize-pending-reset
  :set #'(lambda (sym value)
           (set-default sym value)
           (evil-add-command-properties
            'evil-yank-line
            :motion (if value
                        'evil-end-of-line-or-visual-line
                      'evil-line-or-visual-line))))

(defcustom evil-disable-insert-state-bindings nil
  "Whether insert state bindings should be used.
Bindings for escape, delete and `evil-toggle-key' are always
available. If this is non-nil, default Emacs bindings are by and
large accessible in insert state."
  :group 'evil
  :type 'boolean
  :initialize #'evil-custom-initialize-pending-reset
  :set #'(lambda (sym value)
           (set-default sym value)
           (evil-update-insert-state-bindings sym value)))

(defcustom evil-echo-state t
  "Whether to signal the current state in the echo area."
  :type 'boolean
  :group 'evil)

(defcustom evil-complete-all-buffers t
  "\\<evil-insert-state-map>
Whether completion looks for matches in all buffers.
This applies to \\[evil-complete-next] and \\[evil-complete-previous] \
in insert state."
  :type 'boolean
  :group 'evil)

(defcustom evil-search-wrap-ring-bell nil
  "Whether to ring the bell when search wraps around the buffer."
  :type  'boolean
  :group 'evil)

(defvar dabbrev-search-these-buffers-only)
(defvar dabbrev-case-distinction)
(defcustom evil-complete-next-func
  #'(lambda (arg)
      (require 'dabbrev)
      (let ((dabbrev-search-these-buffers-only
             (unless evil-complete-all-buffers
               (list (current-buffer))))
            dabbrev-case-distinction)
        (condition-case nil
            (if (eq last-command this-command)
                (dabbrev-expand nil)
              (dabbrev-expand (- (abs (or arg 1)))))
          (error (dabbrev-expand nil)))))
  "Completion function used by \
\\<evil-insert-state-map>\\[evil-complete-next]."
  :type 'function
  :group 'evil)

(defcustom evil-complete-previous-func
  #'(lambda (arg)
      (require 'dabbrev)
      (let ((dabbrev-search-these-buffers-only
             (unless evil-complete-all-buffers
               (list (current-buffer))))
            dabbrev-case-distinction)
        (dabbrev-expand arg)))
  "Completion function used by \
\\<evil-insert-state-map>\\[evil-complete-previous]."
  :type 'function
  :group 'evil)

(defcustom evil-complete-next-minibuffer-func 'minibuffer-complete
  "Minibuffer completion function used by \
\\<evil-insert-state-map>\\[evil-complete-next]."
  :type 'function
  :group 'evil)

(defcustom evil-complete-previous-minibuffer-func 'minibuffer-complete
  "Minibuffer completion function used by \
\\<evil-insert-state-map>\\[evil-complete-previous]."
  :type 'function
  :group 'evil)

(defcustom evil-complete-next-line-func
  #'(lambda (arg)
      (let ((hippie-expand-try-functions-list
             '(try-expand-line
               try-expand-line-all-buffers)))
        (hippie-expand arg)))
  "Minibuffer completion function used by \
\\<evil-insert-state-map>\\[evil-complete-next-line]."
  :type 'function
  :group 'evil)

(defcustom evil-complete-previous-line-func
  evil-complete-next-line-func
  "Minibuffer completion function used by \
\\<evil-insert-state-map>\\[evil-complete-previous-line]."
  :type 'function
  :group 'evil)

(defcustom evil-lookup-func #'woman
  "Lookup function used by \
\"\\<evil-motion-state-map>\\[evil-lookup]\"."
  :type 'function
  :group 'evil)

(defcustom evil-toggle-key "C-z"
  "The key used to change to and from Emacs state.
Must be readable by `read-kbd-macro'. For example: \"C-z\"."
  :type 'string
  :group 'evil
  :set #'(lambda (sym value)
           (evil-set-toggle-key value)
           (set-default sym value)))

(defcustom evil-default-state 'normal
  "The default Evil state.
This is the state a buffer starts in when it is not otherwise
configured (see `evil-set-initial-state' and
`evil-buffer-regexps').  The value may be one of `normal',
`insert', `visual', `replace', `operator', `motion' and `emacs'."
  :type  'symbol
  :group 'evil)

(defcustom evil-buffer-regexps
  '(("^ \\*load\\*" . nil))
  "Regular expressions determining the initial state for a buffer.
Entries have the form (REGEXP . STATE), where REGEXP is a regular
expression matching the buffer's name and STATE is one of `normal',
`insert', `visual', `replace', `operator', `motion', `emacs' and
`nil'.  If STATE is `nil', Evil is disabled in the buffer."
  :type '(alist :key-type string :value-type symbol)
  :group 'evil)

(defcustom evil-emacs-state-modes
  '(5x5-mode
    archive-mode
    bbdb-mode
    biblio-selection-mode
    blackbox-mode
    bookmark-bmenu-mode
    bookmark-edit-annotation-mode
    browse-kill-ring-mode
    bs-mode
    bubbles-mode
    bzr-annotate-mode
    calc-mode
    cfw:calendar-mode
    completion-list-mode
    Custom-mode
    custom-theme-choose-mode
    debugger-mode
    delicious-search-mode
    desktop-menu-blist-mode
    desktop-menu-mode
    doc-view-mode
    dun-mode
    dvc-bookmarks-mode
    dvc-diff-mode
    dvc-info-buffer-mode
    dvc-log-buffer-mode
    dvc-revlist-mode
    dvc-revlog-mode
    dvc-status-mode
    dvc-tips-mode
    ediff-mode
    ediff-meta-mode
    efs-mode
    Electric-buffer-menu-mode
    emms-browser-mode
    emms-mark-mode
    emms-metaplaylist-mode
    emms-playlist-mode
    ess-help-mode
    etags-select-mode
    fj-mode
    gc-issues-mode
    gdb-breakpoints-mode
    gdb-disassembly-mode
    gdb-frames-mode
    gdb-locals-mode
    gdb-memory-mode
    gdb-registers-mode
    gdb-threads-mode
    gist-list-mode
    git-rebase-mode
    gnus-article-mode
    gnus-browse-mode
    gnus-group-mode
    gnus-server-mode
    gnus-summary-mode
    gomoku-mode
    google-maps-static-mode
    ibuffer-mode
    jde-javadoc-checker-report-mode
    magit-cherry-mode
    magit-diff-mode
    magit-log-mode
    magit-log-select-mode
    magit-popup-mode
    magit-popup-sequence-mode
    magit-process-mode
    magit-reflog-mode
    magit-refs-mode
    magit-revision-mode
    magit-stash-mode
    magit-stashes-mode
    magit-status-mode
    mh-folder-mode
    monky-mode
    mpuz-mode
    mu4e-main-mode
    mu4e-headers-mode
    mu4e-view-mode
    notmuch-hello-mode
    notmuch-search-mode
    notmuch-show-mode
    notmuch-tree-mode
    occur-mode
    org-agenda-mode
    package-menu-mode
    pdf-outline-buffer-mode
    pdf-view-mode
    proced-mode
    rcirc-mode
    rebase-mode
    recentf-dialog-mode
    reftex-select-bib-mode
    reftex-select-label-mode
    reftex-toc-mode
    sldb-mode
    slime-inspector-mode
    slime-thread-control-mode
    slime-xref-mode
    snake-mode
    solitaire-mode
    sr-buttons-mode
    sr-mode
    sr-tree-mode
    sr-virtual-mode
    tar-mode
    tetris-mode
    tla-annotate-mode
    tla-archive-list-mode
    tla-bconfig-mode
    tla-bookmarks-mode
    tla-branch-list-mode
    tla-browse-mode
    tla-category-list-mode
    tla-changelog-mode
    tla-follow-symlinks-mode
    tla-inventory-file-mode
    tla-inventory-mode
    tla-lint-mode
    tla-logs-mode
    tla-revision-list-mode
    tla-revlog-mode
    tla-tree-lint-mode
    tla-version-list-mode
    twittering-mode
    urlview-mode
    vc-annotate-mode
    vc-dir-mode
    vc-git-log-view-mode
    vc-hg-log-view-mode
    vc-svn-log-view-mode
    vm-mode
    vm-summary-mode
    w3m-mode
    wab-compilation-mode
    xgit-annotate-mode
    xgit-changelog-mode
    xgit-diff-mode
    xgit-revlog-mode
    xhg-annotate-mode
    xhg-log-mode
    xhg-mode
    xhg-mq-mode
    xhg-mq-sub-mode
    xhg-status-extra-mode)
  "Modes that should come up in Emacs state."
  :type  '(repeat symbol)
  :group 'evil)

(defcustom evil-insert-state-modes
  '(comint-mode
    erc-mode
    eshell-mode
    geiser-repl-mode
    gud-mode
    inferior-apl-mode
    inferior-caml-mode
    inferior-emacs-lisp-mode
    inferior-j-mode
    inferior-python-mode
    inferior-scheme-mode
    inferior-sml-mode
    internal-ange-ftp-mode
    haskell-interactive-mode
    prolog-inferior-mode
    reb-mode
    shell-mode
    slime-repl-mode
    term-mode
    utop-mode
    wdired-mode)
  "Modes that should come up in Insert state."
  :type  '(repeat symbol)
  :group 'evil)

(defcustom evil-motion-state-modes
  '(apropos-mode
    Buffer-menu-mode
    calendar-mode
    color-theme-mode
    command-history-mode
    compilation-mode
    dictionary-mode
    ert-results-mode
    help-mode
    Info-mode
    Man-mode
    speedbar-mode
    undo-tree-visualizer-mode
    woman-mode)
  "Modes that should come up in Motion state."
  :type  '(repeat symbol)
  :group 'evil)

(defvar evil-pending-overriding-maps nil
  "An alist of pending overriding maps.")

(defvar evil-pending-intercept-maps nil
  "An alist of pending intercept maps.")

(defcustom evil-overriding-maps '()
  "Keymaps that should override Evil maps.
Entries have the form (MAP-VAR . STATE), where MAP-VAR is
a keymap variable and STATE is the state whose bindings
should be overridden. If STATE is nil, all states are
overridden."
  :type '(alist :key-type symbol :value-type symbol)
  :group 'evil
  :set #'(lambda (var values)
           (set-default var values)
           (evil-set-custom-state-maps 'evil-overriding-maps
                                       'evil-pending-overriding-maps
                                       'override-state
                                       'evil-make-overriding-map
                                       values))
  :initialize 'evil-custom-initialize-pending-reset)

(add-hook 'after-load-functions #'evil-update-pending-maps)

(defcustom evil-intercept-maps
  '((edebug-mode-map . nil))
  "Keymaps that should intercept Evil maps.
Entries have the form (MAP-VAR . STATE), where MAP-VAR is
a keymap variable and STATE is the state whose bindings
should be intercepted. If STATE is nil, all states are
intercepted."
  :type '(alist :key-type symbol :value-type symbol)
  :group 'evil
  :set #'(lambda (var values)
           (set-default var values)
           (evil-set-custom-state-maps 'evil-intercept-maps
                                       'evil-pending-intercept-maps
                                       'intercept-state
                                       'evil-make-intercept-map
                                       values))
  :initialize 'evil-custom-initialize-pending-reset)

(defcustom evil-motions
  '(back-to-indentation
    backward-char
    backward-list
    backward-paragraph
    backward-sentence
    backward-sexp
    backward-up-list
    backward-word
    beginning-of-buffer
    beginning-of-defun
    beginning-of-line
    beginning-of-visual-line
    c-beginning-of-defun
    c-end-of-defun
    diff-file-next
    diff-file-prev
    diff-hunk-next
    diff-hunk-prev
    down-list
    end-of-buffer
    end-of-defun
    end-of-line
    end-of-visual-line
    exchange-point-and-mark
    forward-char
    forward-list
    forward-paragraph
    forward-sentence
    forward-sexp
    forward-word
    goto-last-change
    ibuffer-backward-line
    ibuffer-forward-line
    isearch-abort
    isearch-cancel
    isearch-complete
    isearch-del-char
    isearch-delete-char
    isearch-edit-string
    isearch-exit
    isearch-highlight-regexp
    isearch-occur
    isearch-other-control-char
    isearch-other-meta-char
    isearch-printing-char
    isearch-query-replace
    isearch-query-replace-regexp
    isearch-quote-char
    isearch-repeat-backward
    isearch-repeat-forward
    isearch-ring-advance
    isearch-ring-retreat
    isearch-toggle-case-fold
    isearch-toggle-input-method
    isearch-toggle-regexp
    isearch-toggle-specified-input-method
    isearch-toggle-word
    isearch-yank-char
    isearch-yank-kill
    isearch-yank-line
    isearch-yank-word-or-char
    keyboard-quit
    left-char
    left-word
    mouse-drag-region
    mouse-save-then-kill
    mouse-set-point
    mouse-set-region
    mwheel-scroll
    move-beginning-of-line
    move-end-of-line
    next-error
    next-line
    paredit-backward
    paredit-backward-down
    paredit-backward-up
    paredit-forward
    paredit-forward-down
    paredit-forward-up
    pop-global-mark
    pop-tag-mark
    pop-to-mark-command
    previous-error
    previous-line
    right-char
    right-word
    scroll-down
    scroll-down-command
    scroll-up
    scroll-up-command
    sgml-skip-tag-backward
    sgml-skip-tag-forward
    up-list)
  "Non-Evil commands to initialize to motions."
  :type  '(repeat symbol)
  :group 'evil
  :set 'evil-set-custom-motions
  :initialize 'evil-custom-initialize-pending-reset)

(defcustom evil-visual-newline-commands
  '(LaTeX-section
    TeX-font)
  "Commands excluding the trailing newline of a Visual Line selection.
These commands work better without this newline."
  :type  '(repeat symbol)
  :group 'evil
  :set 'evil-set-visual-newline-commands
  :initialize 'evil-custom-initialize-pending-reset)

(defcustom evil-want-visual-char-semi-exclusive nil
  "DEPRECATED.  Will be removed in a future version.
Prefer to set `evil-v$-excludes-newline' to non-nil.

Visual character selection to beginning/end of line is exclusive.
If non nil then an inclusive visual character selection which
ends at the beginning or end of a line is turned into an
exclusive selection. Thus if the selected (inclusive) range ends
at the beginning of a line it is changed to not include the first
character of that line, and if the selected range ends at the end
of a line it is changed to not include the newline character of
that line."
  :type 'boolean
  :group 'evil)
(make-obsolete-variable
 evil-want-visual-char-semi-exclusive
 "Semi-exclusivity prevents selecting text + 1st char of next line,
without having to introduce new niche functionality.
Prefer to set `evil-v$-excludes-newline' to non-nil."
 "1.15.0")

(defcustom evil-v$-excludes-newline nil
  "If non-nil, `evil-end-of-line' does not move as far as to include
the `\n' char at eol. This makes `v$' consistent with `$' used as a
motion (e.g. `v$y' is consistent with `y$' in normal state)."
  :type 'boolean
  :group 'evil)

(defcustom evil-text-object-change-visual-type t
  "Text objects change the current visual state type.
If non-nil then a text-object changes the type of the visual state to
its default selection type (e.g. a word object always changes to
charwise visual state). Otherwise the current visual state type is
preserved."
  :type 'boolean
  :group 'evil)

(defgroup evil-cjk nil
  "CJK support"
  :prefix "evil-cjk-"
  :group 'evil)

(defcustom evil-cjk-emacs-word-boundary nil
  "Determine word boundary exactly the same way as Emacs does."
  :type 'boolean
  :group 'evil-cjk)

(defcustom evil-cjk-word-separating-categories
  '(;; Kanji
    (?C . ?H) (?C . ?K) (?C . ?k) (?C . ?A) (?C . ?G)
    ;; Hiragana
    (?H . ?C) (?H . ?K) (?H . ?k) (?H . ?A) (?H . ?G)
    ;; Katakana
    (?K . ?C) (?K . ?H) (?K . ?k) (?K . ?A) (?K . ?G)
    ;; half-width Katakana
    (?k . ?C) (?k . ?H) (?k . ?K) ; (?k . ?A) (?k . ?G)
    ;; full-width alphanumeric
    (?A . ?C) (?A . ?H) (?A . ?K) ; (?A . ?k) (?A . ?G)
    ;; full-width Greek
    (?G . ?C) (?G . ?H) (?G . ?K) ; (?G . ?k) (?G . ?A)
    )
  "List of pair (cons) of categories to determine word boundary
used in `evil-cjk-word-boundary-p'. See the documentation of
`word-separating-categories'. Use `describe-categories' to see
the list of categories."
  :type '(alist :key-type (choice character (const nil))
                :value-type (choice character (const nil)))
  :group 'evil-cjk)

(defcustom evil-cjk-word-combining-categories
  '(;; default value in word-combining-categories
    (nil . ?^) (?^ . nil)
    ;; Roman
    (?r . ?k) (?r . ?A) (?r . ?G)
    ;; half-width Katakana
    (?k . ?r) (?k . ?A) (?k . ?G)
    ;; full-width alphanumeric
    (?A . ?r) (?A . ?k) (?A . ?G)
    ;; full-width Greek
    (?G . ?r) (?G . ?k) (?G . ?A)
    )
  "List of pair (cons) of categories to determine word boundary
used in `evil-cjk-word-boundary-p'. See the documentation of
`word-combining-categories'. Use `describe-categories' to see the
list of categories."
  :type '(alist :key-type (choice character (const nil))
                :value-type (choice character (const nil)))
  :group 'evil-cjk)

(defcustom evil-ex-complete-emacs-commands 'in-turn
  "TAB-completion for Emacs commands in ex command line.
This variable determines when Emacs commands are considered for
completion, always, never, or only if no Evil ex command is
available for completion."
  :group 'evil
  :type '(radio (const :tag "Only if no ex-command." :value in-turn)
                (const :tag "Never" :value nil)
                (const :tag "Always" :value t)))

(defface evil-ex-commands '(( nil
                              :underline t
                              :slant italic))
  "Face for the Evil command in completion in ex mode."
  :group 'evil)

(defface evil-ex-info '(( ((supports :slant))
                          :slant italic
                          :foreground "red"))
  "Face for the info message in ex mode."
  :group 'evil)

(defcustom evil-ex-visual-char-range nil
  "Type of default ex range in visual char state.
If non-nil the default range when starting an ex command from
character visual state is `<,`> otherwise it is '<,'>. In the
first case the ex command will be passed a region covering only
the visual selection. In the second case the passed region will
be extended to contain full lines."
  :group 'evil
  :type 'boolean)

;; Searching
(defcustom evil-symbol-word-search nil
  "If nil then * and # search for words otherwise for symbols."
  :group 'evil
  :type 'boolean)
(make-variable-buffer-local 'evil-symbol-word-search)

(defcustom evil-magic t
  "Meaning which characters in a pattern are magic.
The meaning of those values is the same as in Vim. Note that it
only has influence if the Evil search module is chosen in
`evil-search-module'."
  :group 'evil
  :type '(radio (const :tag "Very magic." :value very-magic)
                (const :tag "Magic" :value t)
                (const :tag "Nomagic" :value nil)
                (const :tag "Very nomagic" :value very-nomagic)))

(defcustom evil-ex-search-vim-style-regexp nil
  "If non-nil Vim-style backslash codes are supported in search patterns.
See `evil-transform-vim-style-regexp' for the supported backslash
codes.  Note that this only affects the search command if
`evil-search-module' is set to 'evil-search. The isearch module
always uses plain Emacs regular expressions."
  :type 'boolean
  :group 'evil)

(defcustom evil-ex-interactive-search-highlight 'all-windows
  "Determine in which windows the interactive highlighting should be shown."
  :type '(radio (const :tag "All windows." all-windows)
                (const :tag "Selected window." selected-window)
                (const :tag "Disable highlighting." nil))
  :group 'evil)

(defcustom evil-ex-search-persistent-highlight t
  "If non-nil matches remain highlighted when the search ends."
  :type 'boolean
  :group 'evil)

(defcustom evil-ex-search-case 'smart
  "The case behaviour of the search command.
Smart case means that the pattern is case sensitive if and only
if it contains an upper case letter, otherwise it is case
insensitive."
  :type '(radio (const :tag "Case sensitive." sensitive)
                (const :tag "Case insensitive." insensitive)
                (const :tag "Smart case." smart))
  :group 'evil)

(defcustom evil-ex-substitute-case nil
  "The case behaviour of the search command.
Smart case means that the pattern is case sensitive if and only
if it contains an upper case letter, otherwise it is case
insensitive. If nil then the setting of `evil-ex-search-case' is
used."
  :type '(radio (const :tag "Same as interactive search." nil)
                (const :tag "Case sensitive." sensitive)
                (const :tag "Case insensitive." insensitive)
                (const :tag "Smart case." smart))
  :group 'evil)

(defcustom evil-ex-search-interactive t
  "If t search is interactive."
  :type 'boolean
  :group 'evil)

(defcustom evil-ex-search-incremental t
  "If t, use incremental search. Note that this only affects the
search command if `evil-search-module' is set to 'evil-search."
  :type 'boolean
  :group 'evil)

(defcustom evil-ex-search-highlight-all t
  "If t and interactive search is enabled, all matches are
highlighted."
  :type 'boolean
  :group 'evil)

(defcustom evil-ex-substitute-highlight-all t
  "If t all matches for the substitute pattern are highlighted."
  :type 'boolean
  :group 'evil)

(defcustom evil-ex-substitute-interactive-replace t
  "If t and substitute patterns are highlighted,
the replacement is shown interactively."
  :type 'boolean
  :group 'evil)

(defcustom evil-ex-substitute-global nil
  "If non-nil substitute patterns are global by default.
Usually (if this variable is nil) a substitution works only on
the first match of a pattern in a line unless the 'g' flag is
given, in which case the substitution happens on all matches in a
line. If this option is non-nil, this behaviour is reversed: the
substitution works on all matches unless the 'g' pattern is
specified, then is works only on the first match."
  :type  'boolean
  :group 'evil)

(defface evil-ex-search '((t :inherit isearch))
  "Face for interactive search."
  :group 'evil)

(defface evil-ex-lazy-highlight '((t :inherit lazy-highlight))
  "Face for highlighting all matches in interactive search."
  :group 'evil)

(defface evil-ex-substitute-matches '((t :inherit lazy-highlight))
  "Face for interactive substitute matches."
  :group 'evil)

(defface evil-ex-substitute-replacement '((((supports :underline))
                                           :underline t
                                           :foreground "red"))
  "Face for interactive replacement text."
  :group 'evil)

(defcustom evil-command-window-height 8
  "Height (in lines) of the command line window.
Set to 0 to use the default height for `split-window'."
  :type 'integer
  :group 'evil)

(defcustom evil-display-shell-error-in-message nil
  "Show error output of a shell command in the error buffer.
If this variable is non-nil the error output of a shell command
goes to the messages buffer instead of being mixed with the
regular output. This happens only if the exit status of the
command is non-zero."
  :type 'boolean
  :group 'evil)

(defcustom evil-want-abbrev-expand-on-insert-exit t
  "If non-nil abbrevs will be expanded when leaving insert state
like in Vim, if `abbrev-mode' is on."
  :type 'boolean
  :group 'evil)

;;; Variables

(defmacro evil-define-local-var (symbol &optional initvalue docstring)
  "Define SYMBOL as permanent buffer local variable, and return SYMBOL.
The parameters are the same as for `defvar', but the variable
SYMBOL is made permanent buffer local."
  (declare (indent defun)
           (doc-string 3)
           (debug (symbolp &optional form stringp)))
  `(progn
     (defvar ,symbol ,initvalue ,docstring)
     (make-variable-buffer-local ',symbol)
     (put ',symbol 'permanent-local t)))

(evil-define-local-var evil-scroll-count 0
  "Holds last used prefix for `evil-scroll-up'
and `evil-scroll-down'.
Determines how many lines should be scrolled.
Default value is 0 - scroll half the screen.")

(evil-define-local-var evil-state nil
  "The current Evil state.
To change the state, use `evil-change-state'
or call the state function (e.g., `evil-normal-state').")

;; these may be used inside `evil-define-state'
(evil-define-local-var evil-next-state nil
  "The Evil state being switched to.")

(evil-define-local-var evil-previous-state-alist nil
  "For Each evil state the Evil state being switched from.")

(evil-define-local-var evil-previous-state nil
  "The Evil state being switched from.")

(defvar evil-execute-in-emacs-state-buffer nil
  "The buffer of the latest `evil-execute-in-emacs-state'.
When this command is being executed the current buffer is stored
in this variable. This is necessary in case the Emacs-command to
be called changes the current buffer.")

(evil-define-local-var evil-mode-line-tag nil
  "Mode-Line indicator for the current state.")
(put 'evil-mode-line-tag 'risky-local-variable t)

(defvar evil-global-keymaps-alist nil
  "Association list of keymap variables.
Entries have the form (MODE . KEYMAP), where KEYMAP
is the variable containing the keymap for MODE.")

(defvar evil-local-keymaps-alist nil
  "Association list of keymap variables that must be
reinitialized in each buffer. Entries have the form
\(MODE . KEYMAP), where KEYMAP is the variable containing
the keymap for MODE.")

(defvar evil-minor-mode-keymaps-alist nil
  "Association list of Evil states to minor-mode keymap alists.
Entries have the form (STATE . MODE-MAP-ALIST), where
MODE-MAP-ALIST is an alist taking the form of
`minor-mode-map-alist'.")

(defvar evil-state-properties nil
  "Specifications made by `evil-define-state'.
Entries have the form (STATE . PLIST), where PLIST is a property
list specifying various aspects of the state. To access a property,
use `evil-state-property'.")

(evil-define-local-var evil-mode-map-alist nil
  "Association list of keymaps to use for Evil modes.
Elements have the form (MODE . KEYMAP), with the first keymaps
having higher priority.")

(defvar evil-command-properties nil
  "Specifications made by `evil-define-command'.")

(defvar evil-change-commands '(evil-change)
  "Commands that wrap or replace `evil-change'.
This list exists to apply an inconsistency with vim's change command
to commands that wrap or redefine it. See emacs-evil/evil#916.")

(defvar evil-transient-vars '(cua-mode transient-mark-mode select-active-regions)
  "List of variables pertaining to Transient Mark mode.")

(defvar evil-transient-vals nil
  "Association list of old values for Transient Mark mode variables.
Entries have the form (VARIABLE VALUE LOCAL), where LOCAL is
whether the variable was previously buffer-local.")

(evil-define-local-var evil-no-display nil
  "If non-nil, various Evil displays are inhibited.
Use the macro `evil-without-display' to set this variable.")

(defvar evil-type-properties nil
  "Specifications made by `evil-define-type'.
Entries have the form (TYPE . PLIST), where PLIST is a property
list specifying functions for handling the type: expanding it,
describing it, etc.")

(defvar evil-interactive-alist nil
  "Association list of Evil-specific interactive codes.")

(evil-define-local-var evil-motion-marker nil
  "Marker for storing the starting position of a motion.")

(evil-define-local-var evil-this-type nil
  "Current motion type.")

(evil-define-local-var evil-this-type-modified nil
  "Non-nil iff current motion type has been modified by the user.
If the type has been modified, this variable contains the new
type.")

(evil-define-local-var evil-this-register nil
  "Current register.")

(defvar evil-last-=-register-input nil
  "Most recent input from the `=' register. A string.")

(defvar evil-this-macro nil
  "Current macro register.")

(evil-define-local-var evil-this-operator nil
  "Current operator.")

(evil-define-local-var evil-this-motion nil
  "Current motion.")

(evil-define-local-var evil-this-motion-count nil
  "Current motion count.")

(defvar evil-last-register nil
  "The last executed register.")

(defvar evil-inhibit-operator nil
  "Inhibit current operator.
If an operator calls a motion and the motion sets this variable
to t, the operator code is not executed.")

(defvar evil-inhibit-operator-value nil
  "This variable is used to transfer the value
of `evil-inhibit-operator' from one local scope to another.")

;; used by `evil-define-operator'
(defvar evil-operator-range-beginning nil
  "Beginning of `evil-operator-range'.")

(defvar evil-operator-range-end nil
  "End of `evil-operator-range'.")

(defvar evil-operator-range-type nil
  "Type of `evil-operator-range'.")

(defvar evil-operator-range-motion nil
  "Motion of `evil-operator-range'.")

(defvar evil-operator-start-col nil
  "Used to restore column (where possible) after an operator has moved it.")

(defvar evil-restriction-stack nil
  "List of previous restrictions.
Using `evil-with-restriction' stores the previous values of
`point-min' and `point-max' as a pair in this list.")

(evil-define-local-var evil-markers-alist
  '((?\( . evil-backward-sentence-begin)
    (?\) . evil-forward-sentence-begin)
    (?{ . evil-backward-paragraph)
    (?} . evil-forward-paragraph)
    (?' . evil-jump-backward-swap)
    (?` . evil-jump-backward-swap)
    (?< . evil-visual-beginning)
    (?> . evil-visual-goto-end)
    (?. . (lambda ()
            (let (last-command)
              (goto-last-change nil)))))
  "Association list for markers.
Entries have the form (CHAR . DATA), where CHAR is the marker's
name and DATA is either a marker object as returned by `make-marker',
a variable, a movement function, or a cons cell (STRING NUMBER),
where STRING is a file path and NUMBER is a buffer position.
The global value of this variable holds markers available from
every buffer, while the buffer-local value holds markers available
only in the current buffer.")

(defconst evil-suppress-map (make-keymap)
  "Full keymap disabling default bindings to `self-insert-command'.")
(suppress-keymap evil-suppress-map t)

(defvar evil-read-key-map (make-sparse-keymap)
  "Keymap active during `evil-read-key'.
This keymap can be used to bind some commands during the
execution of `evil-read-key' which is usually used to read a
character argument for some commands, e.g. `evil-replace'.")

;; TODO: customize size of ring
(defvar evil-repeat-ring (make-ring 10)
  "A ring of repeat-informations to repeat the last command.")

(defvar evil-repeat-types
  '((t . evil-repeat-keystrokes)
    (change . evil-repeat-changes)
    (motion . evil-repeat-motion)
    (insert-at-point . evil-repeat-insert-at-point)
    (ignore . nil))
  "An alist of defined repeat-types.")

(defvar evil-recording-repeat nil
  "Whether we are recording a repeat.")

(defvar evil-recording-current-command nil
  "Whether we are recording the current command for repeat.")

(defvar evil-repeat-changes nil
  "Accumulated buffer changes for changed-based commands.")

(defvar evil-repeat-info nil
  "Information accumulated during current repeat.")

(defvar evil-repeat-buffer nil
  "The buffer in which the repeat started.
If the buffer is changed, the repeat is cancelled.")

(defvar evil-repeat-pos nil
  "The position of point at the beginning of an change-tracking
  editing command.")

(defvar evil-repeat-keys nil
  "The keys that invoked the current command.")

(defvar evil-last-repeat nil
  "Information about the latest repeat command.
This is a list of three elements (POINT COUNT UNDO-POINTER),
where POINT is the position of point before the latest repeat,
COUNT the count-argument of the latest repeat command and
UNDO-POINTER the head of the undo-list before the last command
has been repeated.")

(defvar evil-repeat-count nil
  "The explicit count when repeating a command.")

(defvar evil-maybe-remove-spaces nil
  "Flag to determine if newly inserted spaces should be removed.
See the function `evil-maybe-remove-spaces'.")

(evil-define-local-var evil-insert-count nil
  "The explicit count passed to an command starting Insert state.")

(evil-define-local-var evil-insert-vcount nil
  "The information about the number of following lines the
insertion should be repeated. This is list (LINE COLUMN COUNT)
where LINE is the line-number where the original insertion
started and COLUMN is either a number or function determining the
column where the repeated insertions should take place. COUNT is
number of repeats (including the original insertion).")

(defvar evil-insert-skip-empty-lines nil
  "Non-nil of the current insertion should not take place on
  lines at which the insertion point is behind the end of the
  line.")

(evil-define-local-var evil-insert-lines nil
  "Non-nil if the current insertion command is a line-insertion
command o or O.")

(evil-define-local-var evil-insert-repeat-info nil
  "Repeat information accumulated during an insertion.")

(evil-define-local-var evil-replace-alist nil
  "Association list of characters overwritten in Replace state.
The format is (POS . CHAR).")

(evil-define-local-var evil-echo-area-message nil
  "Previous value of `current-message'.")

(defvar evil-write-echo-area nil
  "If set to t inside `evil-save-echo-area', then the echo area
is not restored.")

(defvar evil-last-find nil
  "A pair (FUNCTION . CHAR) describing the lastest character
  search command.")

(defvar evil-last-paste nil
  "Information about the latest paste.
This should be a list (CMD COUNT POINT BEG END FIRSTVISUAL) where
CMD is the last paste-command (`evil-paste-before',
`evil-paste-after' or `evil-visual-paste'), COUNT is the repeat
count of the paste, POINT is the position of point before the
paste, BEG end END are the region of the inserted
text. FIRSTVISUAL is t if and only if the previous command was
the first visual paste (i.e. before any paste-pop).")

(evil-define-local-var evil-last-undo-entry nil
  "Information about the latest undo entry in the buffer.
This should be a pair (OBJ . CONS) where OBJ is the entry as an
object, and CONS is a copy of the entry.")

(evil-define-local-var evil-current-insertion nil
  "Information about the latest insertion in insert state.
This should be a pair (BEG . END) that describes the
buffer-region of the newly inserted text.")

(defvar evil-last-insertion nil
  "The last piece of inserted text.")

(defvar evil-last-small-deletion nil
  "The last piece of deleted text.
The text should be less than a line.")

(defvar evil-was-yanked-without-register t
  "Whether text being saved to the numbered-register ring was
not deleted and not yanked to a specific register.")

(defvar evil-paste-count nil
  "The count argument of the current paste command.")

(defvar evil-temporary-undo nil
  "When undo is disabled in current buffer.
Certain commands depending on undo use this variable
instead of `buffer-undo-list'.")

(evil-define-local-var evil-undo-list-pointer nil
  "Everything up to this mark is united in the undo-list.")

(defvar evil-in-single-undo nil
  "Set to non-nil if the current undo steps are connected.")

(defvar evil-flash-timer nil
  "Timer for flashing search results.")

(defvar evil-search-prompt nil
  "String to use for search prompt.")

(defvar evil-search-forward-history nil
  "History of forward searches.")

(defvar evil-search-backward-history nil
  "History of backward searches.")

(defvar evil-inner-text-objects-map (make-sparse-keymap)
  "Keymap for inner text objects.")

(defvar evil-outer-text-objects-map (make-sparse-keymap)
  "Keymap for outer text objects.")

(defvar evil-window-map (make-sparse-keymap)
  "Keymap for window-related commands.")

(evil-define-local-var evil-input-method nil
  "Input method used in Insert state and Emacs state.")

;;; Visual state

(evil-define-local-var evil-visual-beginning nil
  "The beginning of the Visual selection, a marker.")

(evil-define-local-var evil-visual-end nil
  "The end of the Visual selection, a marker.")

(evil-define-local-var evil-visual-point nil
  "The position of point in Visual state, a marker.")

(evil-define-local-var evil-visual-previous-point nil
  "The position of point before Visual state, a marker.")

(evil-define-local-var evil-visual-mark nil
  "The position of mark in Visual state, a marker.")

(evil-define-local-var evil-visual-previous-mark nil
  "The position of mark before Visual state, a marker.")

(evil-define-local-var evil-visual-selection nil
  "The kind of Visual selection.
This is a selection as defined by `evil-define-visual-selection'.")

;; we could infer the direction by comparing `evil-visual-mark'
;; and `evil-visual-point', but destructive operations may
;; displace the markers
(evil-define-local-var evil-visual-direction 0
  "Whether point follows mark in Visual state.
Negative if point precedes mark, otherwise positive.
See also the function `evil-visual-direction'.")

(evil-define-local-var evil-visual-properties nil
  "Property list of miscellaneous Visual properties.")

(evil-define-local-var evil-visual-region-expanded nil
  "Whether the region matches the Visual selection.
That is, whether the positions of point and mark have been
expanded to coincide with the selection's boundaries.
This makes the selection available to functions acting
on Emacs' region.")

(evil-define-local-var evil-visual-overlay nil
  "Overlay for highlighting the Visual selection.
Not used for blockwise selections, in which case
see `evil-visual-block-overlays'.")

(evil-define-local-var evil-visual-block-overlays nil
  "Overlays for Visual Block selection, one for each line.
They are reused to minimize flicker.")

(defvar evil-visual-alist nil
  "Association list of Visual selection functions.
Elements have the form (NAME . FUNCTION).")

(evil-define-local-var evil-visual-x-select-timer nil
  "Timer for updating the X selection in visual state.")

(defvar evil-visual-x-select-timeout 0.1
  "Time in seconds for the update of the X selection.")

(declare-function origami-open-all-nodes "ext:origami.el")
(declare-function origami-close-all-nodes "ext:origami.el")
(declare-function origami-toggle-node "ext:origami.el")
(declare-function origami-open-node "ext:origami.el")
(declare-function origami-open-node-recursively "ext:origami.el")
(declare-function origami-close-node "ext:origami.el")

(defvar evil-fold-list
  `(((vdiff-mode)
     :open-all   vdiff-open-all-folds
     :close-all  vdiff-close-all-folds
     :toggle     ,(lambda () (call-interactively 'vdiff-toggle-fold))
     :open       ,(lambda () (call-interactively 'vdiff-open-fold))
     :open-rec   ,(lambda () (call-interactively 'vdiff-open-fold))
     :close      ,(lambda () (call-interactively 'vdiff-close-fold)))
    ((vdiff-3way-mode)
     :open-all   vdiff-open-all-folds
     :close-all  vdiff-close-all-folds
     :toggle     ,(lambda () (call-interactively 'vdiff-toggle-fold))
     :open       ,(lambda () (call-interactively 'vdiff-open-fold))
     :open-rec   ,(lambda () (call-interactively 'vdiff-open-fold))
     :close      ,(lambda () (call-interactively 'vdiff-close-fold)))
    ((hs-minor-mode)
     :open-all   hs-show-all
     :close-all  hs-hide-all
     :toggle     hs-toggle-hiding
     :open       hs-show-block
     :open-rec   nil
     :close      hs-hide-block)
    ((hide-ifdef-mode)
     :open-all   show-ifdefs
     :close-all  hide-ifdefs
     :toggle     nil
     :open       show-ifdef-block
     :open-rec   nil
     :close      hide-ifdef-block)
    ((outline-mode
      outline-minor-mode
      org-mode
      markdown-mode)
     :open-all   show-all
     :close-all  ,(lambda ()
                    (with-no-warnings (hide-sublevels 1)))
     :toggle     outline-toggle-children
     :open       ,(lambda ()
                    (with-no-warnings
                      (show-entry)
                      (show-children)))
     :open-rec   show-subtree
     :close      hide-subtree)
    ((origami-mode)
     :open-all   ,(lambda () (origami-open-all-nodes (current-buffer)))
     :close-all  ,(lambda () (origami-close-all-nodes (current-buffer)))
     :toggle     ,(lambda () (origami-toggle-node (current-buffer) (point)))
     :open       ,(lambda () (origami-open-node (current-buffer) (point)))
     :open-rec   ,(lambda () (origami-open-node-recursively (current-buffer) (point)))
     :close      ,(lambda () (origami-close-node (current-buffer) (point)))))
  "Actions to be performed for various folding operations.

The value should be a list of fold handlers, were a fold handler has
the format:

  ((MODES) PROPERTIES)

MODES acts as a predicate, containing the symbols of all major or
minor modes for which the handler should match.  For example:

  '((outline-minor-mode org-mode) ...)

would match for either outline-minor-mode or org-mode, even though the
former is a minor mode and the latter is a major.

PROPERTIES specifies possible folding actions and the functions to be
applied in the event of a match on one (or more) of the MODES; the
supported properties are:

  - `:open-all'
    Open all folds.
  - `:close-all'
    Close all folds.
  - `:toggle'
    Toggle the display of the fold at point.
  - `:open'
    Open the fold at point.
  - `:open-rec'
    Open the fold at point recursively.
  - `:close'
    Close the fold at point.

Each value must be a function.  A value of `nil' will cause the action
to be ignored for that respective handler.  For example:

  `((org-mode)
     :close-all  nil
     :open       ,(lambda ()
                    (show-entry)
                    (show-children))
     :close      hide-subtree)

would ignore `:close-all' actions and invoke the provided functions on
`:open' or `:close'.")

;;; Ex

(defvar evil-ex-map (make-sparse-keymap)
  "Keymap for Ex.
Key sequences bound in this map are immediately executed.")

(defvar evil-ex-completion-map (make-sparse-keymap)
  "Completion keymap for Ex.")

(defvar evil-ex-initial-input nil
  "Additional initial content of the ex command line.
This content of this variable is appended to the ex command line
if ex is started interactively.")

(defvar evil-ex-shell-argument-initialized nil
  "This variable is set to t if shell command completion has been initialized.
See `evil-ex-init-shell-argument-completion'.")

(defvar evil-ex-commands nil
  "Association list of command bindings and functions.")

(defvar evil-ex-history nil
  "History of Ex commands.")

(defvar evil-ex-current-buffer nil
  "The buffer from which Ex was started.")

(defvar evil-ex-expression nil
  "The evaluation tree.")

(defvar evil-ex-tree nil
  "The syntax tree.")

(defvar evil-ex-command nil
  "The current Ex command.")

(defvar evil-ex-previous-command nil
  "The previously executed Ex command.")

(defvar evil-ex-cmd nil
  "The current Ex command string.")

(defvar evil-ex-point nil
  "The position of `point' when the ex command has been called.")

(defvar evil-ex-range nil
  "The current range of the Ex command.")

(defvar evil-ex-bang nil
  "The \"!\" argument of the current Ex command.")

(defvar evil-ex-argument nil
  "The current argument of the Ex command.")

(defvar evil-ex-argument-handler nil
  "The argument handler for the current Ex command.")

(defvar evil-ex-argument-types nil
  "Association list of argument handlers.")

(defvar evil-previous-shell-command nil
  "The last shell command.")

;; Eval
(defvar evil-eval-history nil
  "History of eval input, from the `=' register.")

(defvar evil-eval-map (make-sparse-keymap)
  "Keymap for eval input.")

;; Searching
(defvar evil-ex-search-history nil
  "The history for the search command.")

(defvar evil-ex-search-direction nil
  "The direction of the current search, either 'forward or 'backward.")

(defvar evil-ex-search-count nil
  "The count if the current search.")

(defvar evil-ex-search-start-point nil
  "The point where the search started.")

(defvar evil-ex-search-overlay nil
  "The overlay for the current search result.")

(defvar evil-ex-search-pattern nil
  "The last search pattern.")

(defvar evil-ex-search-offset nil
  "The last search offset.")

(defvar evil-ex-search-match-beg nil
  "The beginning position of the last match.")

(defvar evil-ex-search-match-end nil
  "The end position of the last match.")

(defvar evil-ex-substitute-pattern nil
  "The last substitute pattern.")

(defvar evil-ex-substitute-replacement nil
  "The last substitute replacement.")

(defvar evil-ex-substitute-flags nil
  "The last substitute flags.")

(defvar evil-ex-substitute-current-replacement nil
  "The actual replacement.")

(defvar evil-ex-last-was-search nil
  "Non-nil if the previous was a search.
Otherwise the previous command is assumed as substitute.")

;;; Command line window

(defvar evil-command-window-current-buffer nil
  "The buffer from which the command line window was called.")

(evil-define-local-var evil-command-window-execute-fn nil
  "The command to execute when exiting the command line window.")

(evil-define-local-var evil-command-window-cmd-key nil
  "The key for the command that opened the command line window (:, /, or ?).")

;; The lazy-highlighting framework.
(evil-define-local-var evil-ex-active-highlights-alist nil
  "An alist of currently active highlights.")

(evil-define-local-var evil-ex-hl-update-timer nil
  "Time used for updating highlights.")

(defvar evil-ex-search-keymap (make-sparse-keymap)
  "Keymap used in ex-search-mode.")
(define-key evil-ex-search-keymap [escape] 'abort-recursive-edit)
(set-keymap-parent evil-ex-search-keymap minibuffer-local-map)

(defcustom evil-want-empty-ex-last-command t
  "Whether to default to evil-ex-previous-command at empty ex prompt."
  :type 'boolean
  :group 'evil)

(defconst evil-version
  (eval-when-compile
    (with-temp-buffer
      (let ((dir (file-name-directory (or load-file-name
                                          byte-compile-current-file))))
        ;; git repository
        (if (and (file-exists-p (concat dir "/.git"))
                 (ignore-errors
                   (zerop (call-process "git" nil '(t nil) nil
                                        "rev-parse"
                                        "--short" "HEAD"))))
            (progn
              (goto-char (point-min))
              (concat "evil-git-"
                      (buffer-substring (point-min)
                                        (line-end-position))))
          ;; no repo, use plain version
          "1.15.0"))))
  "The current version of Evil")

(defcustom evil-want-integration t
  "Whether to load evil-integration.el.
This variable must be set before Evil is loaded."
  :type 'boolean
  :group 'evil)

(defcustom evil-want-keybinding t
  "Whether to load evil-keybindings.el.

This loads a set of keybindings for evil in other modes as well as
setting the initial evil state in those modes.

This variable must be set before evil is loaded."
  :type 'boolean
  :group 'evil)

(defcustom evil-want-minibuffer nil
  "Whether to enable Evil in minibuffer(s)."
  :type 'boolean
  :group 'evil
  :set #'(lambda (sym value)
           (set-default sym value)
           (if value
               (add-hook 'minibuffer-setup-hook 'evil-initialize)
             (remove-hook 'minibuffer-setup-hook 'evil-initialize))))

(defun evil--redo-placeholder (_count)
  (user-error "Customize `evil-undo-system' for redo functionality."))

(defvar evil-undo-function 'undo
  "Function to be used by `evil-undo'.
Customized via `evil-undo-system'.")

(defvar evil-redo-function 'evil--redo-placeholder
  "Function to be used by 'evil-redo'.
Customized via `evil-undo-system'.")

(defun evil-set-undo-system (system)
  "Set `evil-undo-function' and `evil-redo-function` by SYSTEM."
  (cond
   ((not system)
    (setq evil-undo-function 'undo
          evil-redo-function 'evil--redo-placeholder))
   ((eq system 'undo-redo)
    (setq evil-undo-function 'undo-only
          evil-redo-function 'undo-redo))
   ((eq system 'undo-tree)
    (setq evil-undo-function 'undo-tree-undo
          evil-redo-function 'undo-tree-redo))
   ((eq system 'undo-fu)
    (setq evil-undo-function 'undo-fu-only-undo
          evil-redo-function 'undo-fu-only-redo))
   (t
    (error "Unknown undo system %s" system))))

(defcustom evil-undo-system nil
  "Undo system Evil should use.  If equal to `undo-tree' or
`undo-fu', those packages must be installed.  If equal to
`undo-tree', `undo-tree-mode' must also be activated.  If equal
to `undo-redo', Evil uses commands natively available in Emacs 28."
  :type '(choice (const :tag "Vanilla undo" nil)
                 (const undo-redo)
                 (const undo-tree)
                 (const undo-fu))
  :group 'evil
  :set #'(lambda (sym value)
           (evil-set-undo-system value)
           (set-default sym value)))

(defcustom evil-visual-update-x-selection-p t
  "Whether to update the X PRIMARY selection with the current visual region automatically."
  :type  'boolean
  :group 'evil)

(defun evil-version ()
  (interactive)
  (message "Evil version %s" evil-version))

(provide 'evil-vars)

;;; evil-vars.el ends here