Take autopair into account when newline-and-indent'ing
This commit is contained in:
parent
ba1b91bc40
commit
606d4c41a0
2 changed files with 11 additions and 10 deletions
|
@ -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
|
"Inserts a tab character (or spaces x tab-width). Checks if the
|
||||||
auto-complete window is open."
|
auto-complete window is open."
|
||||||
(interactive)
|
(interactive)
|
||||||
(when (not (ac-menu-live-p))
|
(let ((indent-mode indent-tabs-mode))
|
||||||
(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 ()
|
(defun my.newline-and-indent ()
|
||||||
"Newline and indent; if in a comment, auto-comment and properly
|
"Newline and indent; if in a comment, auto-comment and properly
|
||||||
indent the next line."
|
indent the next line."
|
||||||
(interactive)
|
(interactive)
|
||||||
(let ((in-comment (evil-in-comment-p)))
|
(when (not (ac-menu-live-p))
|
||||||
(if in-comment
|
(let ((in-comment (evil-in-comment-p)))
|
||||||
(indent-new-comment-line)
|
(if in-comment
|
||||||
(evil-ret-and-indent))))
|
(indent-new-comment-line)
|
||||||
|
(progn (autopair-newline) (indent-according-to-mode))))))
|
||||||
|
|
||||||
(defun my.minibuffer-quit ()
|
(defun my.minibuffer-quit ()
|
||||||
"Abort recursive edit. In Delete Selection mode, if the mark is
|
"Abort recursive edit. In Delete Selection mode, if the mark is
|
||||||
|
|
|
@ -145,14 +145,15 @@
|
||||||
"_" 'er/contract-region)
|
"_" 'er/contract-region)
|
||||||
|
|
||||||
|
|
||||||
|
(define-key evil-motion-state-map (kbd "RET") 'evil-ret-and-indent)
|
||||||
(imap my-mode-map
|
(imap my-mode-map
|
||||||
;; Join lines from insert mode
|
;; Join lines from insert mode
|
||||||
(kbd "<M-kp-delete>") 'evil-join
|
(kbd "<M-kp-delete>") 'evil-join
|
||||||
|
|
||||||
;; Newline magic
|
;; Newline magic
|
||||||
(kbd "<return>") 'my.newline-and-indent
|
[remap autopair-newline] 'my.newline-and-indent
|
||||||
(kbd "<C-return>") 'evil-ret-and-indent
|
(kbd "<C-return>") 'evil-ret-and-indent
|
||||||
(kbd "<M-return>") (kbd "<return> DEL") ; newline and dedent
|
(kbd "<M-return>") (kbd "<return> DEL") ; newline and dedent
|
||||||
|
|
||||||
;; Textmate-esque indent shift left/right
|
;; Textmate-esque indent shift left/right
|
||||||
(kbd "s-[") (kbd "C-o m l C-o I DEL C-o ` l")
|
(kbd "s-[") (kbd "C-o m l C-o I DEL C-o ` l")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue