Simplify sexp wrapping code

This commit is contained in:
Bozhidar Batsov 2013-12-07 09:14:44 +02:00
parent 150ac9e510
commit 8217618525
3 changed files with 12 additions and 6 deletions

View file

@ -564,5 +564,11 @@ This follows freedesktop standards, should work in X servers."
(t (error "Unknown shell")))))
(find-file-other-window (expand-file-name shell-init-file (getenv "HOME")))))
(defun prelude-wrap-with (s)
"Create a wrapper function for smartparens using S."
`(lambda (&optional arg)
(interactive "P")
(sp-wrap-with-pair ,s)))
(provide 'prelude-core)
;;; prelude-core.el ends here

View file

@ -110,10 +110,10 @@ Will only occur if prelude-whitespace is also enabled."
(show-smartparens-global-mode +1)
(define-key prog-mode-map (kbd "M-(") (lambda (&optional arg) (interactive "P") (sp-wrap-with-pair "(")))
(define-key prog-mode-map (kbd "M-(") (prelude-wrap-with "("))
;; FIXME: pick terminal friendly binding
;; (define-key prog-mode-map (kbd "M-[") (lambda (&optional arg) (interactive "P") (sp-wrap-with-pair "[")))
(define-key prog-mode-map (kbd "M-\"") (lambda (&optional arg) (interactive "P") (sp-wrap-with-pair "\"")))
;; (define-key prog-mode-map (kbd "M-[") (prelude-wrap-with "["))
(define-key prog-mode-map (kbd "M-\"") (prelude-wrap-with "\""))
;; disable annoying blink-matching-paren
(setq blink-matching-paren nil)

View file

@ -39,10 +39,10 @@
(define-key read-expression-map (kbd "TAB") 'lisp-complete-symbol)
;; wrap keybindings
(define-key lisp-mode-shared-map (kbd "M-(") (lambda (&optional arg) (interactive "P") (sp-wrap-with-pair "(")))
(define-key lisp-mode-shared-map (kbd "M-(") (prelude-wrap-with "("))
;; FIXME: Pick terminal-friendly binding.
;;(define-key lisp-mode-shared-map (kbd "M-[") (lambda (&optional arg) (interactive "P") (sp-wrap-with-pair "[")))
(define-key lisp-mode-shared-map (kbd "M-\"") (lambda (&optional arg) (interactive "P") (sp-wrap-with-pair "\"")))
;;(define-key lisp-mode-shared-map (kbd "M-[") (prelude-wrap-with "["))
(define-key lisp-mode-shared-map (kbd "M-\"") (prelude-wrap-with "\""))
;; a great lisp coding hook
(defun prelude-lisp-coding-defaults ()