Open goranmoomin opened 5 years ago
(defun +javascript-rjsx-electric-gt-a (n)
(when (and (looking-back "<>")
(looking-at-p "/>"))
(save-excursion (insert "<"))))
(advice-add #'rjsx-electric-gt :after #'+javascript-rjsx-electric-gt-a)
I think this advice is probably faster (not that yours is slow, I just spotted some optimisations):
(defun +rjsx-electric-gt-fragment-a (n)
(if (or (/= n 1) (not (and (eq (char-before) ?<) (eq (char-after) ?/)))) 't
(insert ?> ?<)
(backward-char)))
(advice-add #'rjsx-electric-gt :before-while #'+rjsx-electric-gt-fragment-a)
It uses all low level functions defined in C, and it will also completely skip rjsx-electric-gt
if it can.
When using rjsx-mode, I really love the electricity feature of the
>
key. I have found that, when inserting blank tags (a.k.a fragments), the electric>
doesn't work, which makes inserting fragments very tedious. I would like if the electric>
works for blank tags too.