Created
January 30, 2013 18:33
-
-
Save Fuco1/4675510 to your computer and use it in GitHub Desktop.
Default SP config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; predicates... I'm not sure yet how to call it. I don't want the | |
;; -p suffix, because that's used internally and there migth be | |
;; some clashes. I think sp-pred- is a good indicator, at least | |
;; for the built-in stuff. | |
(defun sp-pred-in-string (id action context) | |
"Return t if point is inside string or comment, nil otherwise." | |
(eq context :string)) | |
(defun sp-pred-in-code (id action context) | |
"Return t if point is inside code, nil otherwise." | |
(eq context :code)) | |
(defun sp-pred-point-after-word (id action context) | |
"Return t if point is after a word, nil otherwise. This | |
predicate is only tested on :insert action." | |
(when (eq action :insert) | |
(save-excursion | |
(backward-char 1) | |
(looking-back "\\sw\\|\\s_")))) | |
;;;;;;;;;;;;;;;;; default settings | |
;; do not autoinsert ' pair if the point is preceeded by word. This | |
;; will handle the situation when ' is used as a contraction symbol in | |
;; natural language. | |
(sp-pair "'" nil :unless '(sp-pred-point-after-word)) | |
;; emacs is lisp hacking enviroment, so we set up some most common | |
;; lisp modes too | |
(sp-with-modes '( | |
emacs-lisp-mode | |
inferior-emacs-lisp-mode | |
lisp-interaction-mode | |
scheme-mode | |
common-lisp-mode | |
) | |
;; disable ', it's the quote character! | |
(sp-local-pair "'" nil :actions nil) | |
;; also only use the pseudo-quote inside strings where it serve as | |
;; hyperlink. | |
(sp-local-pair "`" nil :when '(sp-pred-in-string))) | |
;; NOTE: Normally, `sp-local-pair' accepts list of modes (or a single | |
;; mode) as a first argument. The macro `sp-with-modes' adds this | |
;; automatically. If you want to call sp-local-pair outside this | |
;; macro, you MUST supply the major mode argument. | |
;; markdown based modes | |
(sp-with-modes '( | |
markdown-mode | |
gfm-mode | |
rst-mode | |
) | |
;; overload the `' pair with ``, which is used for inline | |
;; code in markdown | |
(sp-local-pair "`" "`")) | |
;; LaTeX modes | |
(sp-with-modes '( | |
tex-mode | |
plain-tex-mode | |
latex-mode | |
) | |
;; math modes, yay. The :actions are provided automatically if | |
;; these pairs do not have global definition. | |
(sp-local-pair "$" "$") | |
(sp-local-pair "\\[" "\\]")) | |
(provide 'smartparens-config) | |
;;; smartparens-config.el ends here |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment