Add paredit splice sexp wrapper and move sp function to correct place

This commit is contained in:
David Morgan 2021-10-12 06:39:58 +01:00
parent 4d593f4fa0
commit 97f62b0a68
2 changed files with 25 additions and 7 deletions

View File

@ -25,6 +25,7 @@
("C-c M-<" . paredit-smart-wrap-angled)
([remap paredit-wrap-round] . paredit-smart-wrap-round)
([remap paredit-meta-doublequote] . paredit-smart-metadouble-quote)
([remap paredit-splice-sexp] . paredit-smart-splice-sexp)
("M-W" . paredit-copy-as-kill))
:config
(defmacro define-paredit-smart-wrap (name)
@ -46,10 +47,6 @@ Falls back to smartparens in comments and strings.")
(define-paredit-smart-wrap "square")
(define-paredit-smart-wrap "angled")
(defun sp-wrap-double-quotation-marks ()
(interactive)
(sp-wrap-with-pair "\""))
;; paredit-meta-doublequote is not like the wrap functions (but can act as one)
(defun paredit-smart-metadouble-quote (&optional n)
"Move to the end of the string.
@ -65,6 +62,22 @@ Falls back to smartparens in comments."
(beginning-of-thing 'symbol))
(paredit-meta-doublequote n)))
(defmacro define-paredit-smart-sexp (name)
`(defun ,(intern (concat "paredit-smart-" name "-sexp"))
(&optional argument)
,(concat "Wrap the following S-expression, from the beginning of the current symbol.
See `paredit-wrap-sexp' for more details.
Falls back to smartparens in comments and strings.")
(interactive "P")
(if (or (paredit-in-string-p)
(paredit-in-comment-p)
(paredit-in-char-p))
(,(intern (concat "sp-" name "-sexp")))
(beginning-of-thing 'symbol)
(,(intern (concat "paredit-" name "-sexp")) argument))))
(define-paredit-smart-sexp "splice")
:init
;; From emacswiki - extreme barfage & slurpage
(defun paredit-barf-all-the-way-backward ()

View File

@ -10,6 +10,9 @@
(sp-hybrid-kill-entire-symbol t)
(sp-hybrid-kill-excessive-whitespace t)
:config
(defun sp-wrap-double-quotation-marks ()
(interactive)
(sp-wrap-with-pair "\""))
;; https://github.com/syl20bnr/spacemacs/blob/develop/layers/+spacemacs/spacemacs-editing/funcs.el (spacemacs/smart-closing-parenthesis)
;; TODO can make things unbalanced
(defun sp-close-round ()
@ -41,9 +44,11 @@
(require 'smartparens-config)
(sp-use-paredit-bindings)
(unbind-key "M-?" 'smartparens-mode-map)
(bind-key "C-M-?" 'sp-convolute-sexp 'smartparens-mode-map)
;; :bind (:map smartparens-mode-map (")" . sp-close-round))
)
:commands sp-local-pair
:bind (:map smartparens-mode-map
("C-M-?" . sp-convolute-sexp)
;; (")" . sp-close-round)
("M-\"" . sp-wrap-double-quotation-marks)))
(provide 'init-smartparens)
;;; init-smartparens.el ends here