use electric-indent-mode and electric-pair-mode