about summary refs log tree commit diff stats
path: root/.emacs.d/lisp
diff options
context:
space:
mode:
authorDavid Morgan <djm_uk@protonmail.com>2021-10-12 06:39:58 +0100
committerDavid Morgan <djm_uk@protonmail.com>2021-10-12 06:39:58 +0100
commit97f62b0a68db5f4278fb925d27b01972981b5667 (patch)
treeef4de68e3e2e256b9d0035a7e16cb76e1966654d /.emacs.d/lisp
parent4d593f4fa05905aa31591238f14f19bc1d034d28 (diff)
downloaddotfiles-97f62b0a68db5f4278fb925d27b01972981b5667.tar.gz
Add paredit splice sexp wrapper and move sp function to correct place
Diffstat (limited to '.emacs.d/lisp')
-rw-r--r--.emacs.d/lisp/init-paredit.el21
-rw-r--r--.emacs.d/lisp/init-smartparens.el11
2 files changed, 25 insertions, 7 deletions
diff --git a/.emacs.d/lisp/init-paredit.el b/.emacs.d/lisp/init-paredit.el
index 2c873f1..24cd176 100644
--- a/.emacs.d/lisp/init-paredit.el
+++ b/.emacs.d/lisp/init-paredit.el
@@ -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 ()
diff --git a/.emacs.d/lisp/init-smartparens.el b/.emacs.d/lisp/init-smartparens.el
index 9e8632e..fa8c122 100644
--- a/.emacs.d/lisp/init-smartparens.el
+++ b/.emacs.d/lisp/init-smartparens.el
@@ -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