-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathauto-pair.el
27 lines (25 loc) · 1.04 KB
/
auto-pair.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
;(setq c-tab-always-indent t)
;; 当光标在行尾上下移动的时候,始终保持在行尾。
;(setq track-eol t)
;;;###autoload
(defun my-auto-pair ()
(interactive)
(make-local-variable 'skeleton-pair-alist)
(setq skeleton-pair-alist '(
;; (?` _ "'")
(?\( _ ")")
(?\[ _ "]")
(?\" _ "\"")
(?{ \n > _ \n ?} >)
))
(setq skeleton-pair t)
(define-key-s 1 '("(" "{" "\"" "[") 'skeleton-pair-insert-maybe))
(defadvice skeleton-pair-insert-maybe (around condition activate)
(let ((skeleton-pair-alist skeleton-pair-alist)
(c-before
(lambda(x)(save-excursion
(skip-chars-backward " \t")
(eq (char-before (point)) x)))))
(if (and (eq last-command-event 123)(funcall c-before 61))
(setq skeleton-pair-alist '((?\{ _ "}"))))
ad-do-it))