Take autopair into account when newline-and-indent'ing

This commit is contained in:
Henrik Lissner 2014-09-05 19:22:34 -04:00
parent ba1b91bc40
commit 606d4c41a0
2 changed files with 11 additions and 10 deletions

View file

@ -65,18 +65,18 @@ spaces on either side of the point if so. Resorts to
"Inserts a tab character (or spaces x tab-width). Checks if the
auto-complete window is open."
(interactive)
(when (not (ac-menu-live-p))
(let ((indent-mode indent-tabs-mode))
(insert (if indent-mode "\t" (make-string tab-width ? ))))))
(insert (if indent-mode "\t" (make-string tab-width ? )))))
(defun my.newline-and-indent ()
"Newline and indent; if in a comment, auto-comment and properly
indent the next line."
(interactive)
(when (not (ac-menu-live-p))
(let ((in-comment (evil-in-comment-p)))
(if in-comment
(indent-new-comment-line)
(evil-ret-and-indent))))
(progn (autopair-newline) (indent-according-to-mode))))))
(defun my.minibuffer-quit ()
"Abort recursive edit. In Delete Selection mode, if the mark is

View file

@ -145,12 +145,13 @@
"_" 'er/contract-region)
(define-key evil-motion-state-map (kbd "RET") 'evil-ret-and-indent)
(imap my-mode-map
;; Join lines from insert mode
(kbd "<M-kp-delete>") 'evil-join
;; Newline magic
(kbd "<return>") 'my.newline-and-indent
[remap autopair-newline] 'my.newline-and-indent
(kbd "<C-return>") 'evil-ret-and-indent
(kbd "<M-return>") (kbd "<return> DEL") ; newline and dedent