optimize startup
[dot-emacs] / misc-disabled.el
index 59a88510bfca3fd0d771e9dabc7e1ee9ebb63907..2804aa639e505495b120ad1d107bc0a89e85491d 100644 (file)
 
 ;; give us a shell to start instead of scratch
 ;;(setq initial-buffer-choice (lambda () (new-shell)))
+
+
+;;; smartparens
+;; the melpa git version had a catastrophic bug I reported.
+;; downgraded to marmalade version and everything is working fine.
+(require 'smartparens-config)
+
+(defun gp/sp/pair-on-newline-and-indent (id action context)
+  "Open a new brace or bracket expression, with relevant newlines and indent. "
+  (save-excursion
+    (newline)
+    (indent-according-to-mode))
+  (indent-according-to-mode))
+
+;; when opening a pair, and then inserting a newline, push the closing pair to another newline
+(sp-pair "{" nil :post-handlers
+         '(:add ((lambda (id action context)
+                   (gp/sp/pair-on-newline-and-indent id action context)) (kbd "RET"))))
+(sp-pair "[" nil :post-handlers
+         '(:add ((lambda (id action context)
+                   (gp/sp/pair-on-newline-and-indent id action context)) (kbd "RET"))))
+
+
+;; in my version, this is not a pairing.
+;; not sure if it is in a future version since I reverted to marmalade
+;; Don't need c-comments in strings -- they frustrate filename globs
+;; (sp-pair "/*" nil :unless '(sp-in-string-p))
+
+;; Don't need quotes to pair next to words
+(sp-pair "\"" nil :unless '(sp-point-before-word-p sp-point-after-word-p))
+(sp-pair "'" nil :unless '(sp-point-before-word-p sp-point-after-word-p))
+
+
+;; todo, testout these mode specific settings from graphene.
+;; Ruby-specific pairs and handlers
+
+(eval-after-load "ruby"
+  '(require 'smartparens-ruby))
+
+;; Markdown
+(sp-local-pair '(markdown-mode gfm-mode) "*" "*"
+               :unless '(sp-in-string-p)
+               :actions '(insert wrap))
+
+;; Except in HTML
+(sp-local-pair 'html-mode "\"" nil :unless '(:rem sp-point-after-word-p))