Skip to content

Commit 570330c

Browse files
committed
Add keyword pairs for ocaml
1 parent b8c6847 commit 570330c

1 file changed

Lines changed: 53 additions & 2 deletions

File tree

smartparens-ml.el

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
;; Author: Ta Quang Trung <taquangtrungvn@gmail.com>
77
;; Matus Goljer <matus.goljer@gmail.com>
8+
;; Louis Roché <louis@louisroche.net>
89
;; Maintainer: Matus Goljer <matus.goljer@gmail.com>
910
;; Created: 14 July 2016
1011
;; Keywords: smartparens, ML, ocaml, reason
@@ -50,8 +51,58 @@
5051
(require 'smartparens)
5152

5253
;;; Local pairs for ML-family languages
53-
(sp-with-modes '(tuareg-mode fsharp-mode) (sp-local-pair "(*" "*)" ))
54-
(sp-with-modes '(reason-mode) (sp-local-pair "/*" "*/" ))
54+
55+
(sp-with-modes '(fsharp-mode)
56+
(sp-local-pair "(*" "*)" ))
57+
58+
;; all the keywords pairs are expanded only if followed by "SPC"
59+
;; event. This will reduce false positives like 'dIFficult' to
60+
;; trigger.
61+
(sp-with-modes '(tuareg-mode)
62+
;; Disable ` because it is used in polymorphic variants
63+
(sp-local-pair "`" nil :actions nil)
64+
(sp-local-pair "(*" "*)" )
65+
(sp-local-pair "if" "then"
66+
:when '(("SPC"))
67+
:unless '(sp-in-comment-p sp-in-string-p)
68+
:post-handlers '(sp-latex-insert-spaces-inside-pair))
69+
(sp-local-pair "while" "done"
70+
:when '(("SPC"))
71+
:unless '(sp-in-comment-p sp-in-string-p)
72+
:post-handlers '(sp-latex-insert-spaces-inside-pair))
73+
(sp-local-pair "for" "done"
74+
:when '(("SPC"))
75+
:unless '(sp-in-comment-p sp-in-string-p)
76+
:post-handlers '(sp-latex-insert-spaces-inside-pair))
77+
(sp-local-pair "begin" "end"
78+
:when '(("SPC"))
79+
:unless '(sp-in-comment-p sp-in-string-p)
80+
:post-handlers '(sp-latex-insert-spaces-inside-pair))
81+
(sp-local-pair "struct" "end"
82+
:when '(("SPC"))
83+
:unless '(sp-in-comment-p sp-in-string-p)
84+
:post-handlers '(sp-latex-insert-spaces-inside-pair))
85+
(sp-local-pair "sig" "end"
86+
:when '(("SPC"))
87+
:unless '(sp-in-comment-p sp-in-string-p)
88+
:post-handlers '(sp-latex-insert-spaces-inside-pair))
89+
(sp-local-pair "object" "end"
90+
:when '(("SPC"))
91+
:unless '(sp-in-comment-p sp-in-string-p)
92+
:post-handlers '(sp-latex-insert-spaces-inside-pair))
93+
(sp-local-pair "match" "with"
94+
:when '(("SPC"))
95+
:unless '(sp-in-comment-p sp-in-string-p)
96+
:post-handlers '(sp-latex-insert-spaces-inside-pair))
97+
(sp-local-pair "try" "with"
98+
:when '(("SPC"))
99+
:unless '(sp-in-comment-p sp-in-string-p)
100+
:post-handlers '(sp-latex-insert-spaces-inside-pair)))
101+
102+
(sp-with-modes '(reason-mode)
103+
;; Disable ` because it is used in polymorphic variants
104+
(sp-local-pair "`" nil :actions nil)
105+
(sp-local-pair "/*" "*/" ))
55106

56107
(provide 'smartparens-ml)
57108
;;; smartparens-ml.el ends here

0 commit comments

Comments
 (0)