Commits

Anonymous committed 7c493ee

Add hyper bindings, remap delete operations

Comments (0)

Files changed (1)

files/smartparens.el

 (define-key sp-keymap (kbd "M-F") 'sp-forward-symbol)
 (define-key sp-keymap (kbd "M-B") 'sp-backward-symbol)
 
+(define-key sp-keymap [remap delete-char] 'sp-delete-char)
+(define-key sp-keymap [remap backward-delete-char-untabify] 'sp-backward-delete-char)
+(define-key sp-keymap [remap kill-word] 'sp-kill-word)
+(define-key sp-keymap [remap backward-kill-word] 'sp-backward-kill-word)
+
+(bind-key "H-t" 'sp-prefix-tag-object sp-keymap)
+(bind-key "H-p" 'sp-prefix-pair-object sp-keymap)
+(bind-key "H-y" 'sp-prefix-symbol-object sp-keymap)
+(bind-key "H-h" 'sp-highlight-current-sexp sp-keymap)
+(bind-key "H-e" 'sp-prefix-save-excursion sp-keymap)
+(bind-key "H-s c" 'sp-convolute-sexp sp-keymap)
+(bind-key "H-s a" 'sp-absorb-sexp sp-keymap)
+(bind-key "H-s e" 'sp-emit-sexp sp-keymap)
+(bind-key "H-s p" 'sp-add-to-previous-sexp sp-keymap)
+(bind-key "H-s n" 'sp-add-to-next-sexp sp-keymap)
+(bind-key "H-s j" 'sp-join-sexp sp-keymap)
+(bind-key "H-s s" 'sp-split-sexp sp-keymap)
+(bind-key "H-s r" 'sp-rewrap-sexp sp-keymap)
+(defvar hyp-s-x-map)
+(define-prefix-command 'hyp-s-x-map)
+(bind-key "H-s x" hyp-s-x-map sp-keymap)
+(bind-key "H-s x x" 'sp-extract-before-sexp sp-keymap)
+(bind-key "H-s x a" 'sp-extract-after-sexp sp-keymap)
+(bind-key "H-s x s" 'sp-swap-enclosing-sexp sp-keymap)
+
 ;;;;;;;;;;;;;;;;;;
 ;; pair management
 
 ;;; markdown-mode
 (sp-with-modes '(markdown-mode gfm-mode rst-mode)
   (sp-local-pair "*" "*" :bind "C-*")
+  (sp-local-pair "_" "_" :bind "C-_")
   (sp-local-tag "2" "**" "**")
   (sp-local-tag "s" "```scheme" "```")
   (sp-local-tag "<"  "<_>" "</_>" :transform 'sp-match-sgml-tags))
 (sp-with-modes '(tex-mode plain-tex-mode latex-mode)
   (sp-local-tag "i" "\"<" "\">"))
 
-;;; html-mode
-(sp-with-modes '(html-mode sgml-mode)
-  (sp-local-pair "<" ">"))
-
 ;;; lisp modes
 (sp-with-modes sp--lisp-modes
   (sp-local-pair "(" nil :bind "C-("))
+
+;;; haskell mode
+(sp-local-pair 'haskell-mode "'" nil :unless '(my-after-symbol-p))
+
+(defun my-after-symbol-p (_id action _context)
+  (when (eq action 'insert)
+    (save-excursion
+      (backward-char 1)
+      (looking-back "\\sw\\|\\s_\\|\\s'"))))
+
+(sp-local-pair 'emacs-lisp-mode "(" nil :post-handlers '(my-add-space-after-sexp-insertion))
+
+(defun my-add-space-after-sexp-insertion (id action _context)
+  (when (eq action 'insert)
+    (save-excursion
+      (forward-char (length (plist-get (sp-get-pair id) :close)))
+      (when (or (eq (char-syntax (following-char)) ?w)
+                (looking-at (sp--get-opening-regexp)))
+        (insert " ")))))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.