Skip to content
kevinfis edited this page Sep 21, 2023 · 4 revisions

Paredit is very useful to handle parenthsis, in the same time, lots functions need to be bound. Thanks Hydra, let it can be integrate just one place. this hydra function tests in resolution 2560x1440, and use a lot unicode char to decorate, so you need to change char if you lack some font or install supposed font(𝘯𝘰𝘵𝘰 𝘧𝘰𝘯𝘵). here is Screenshoot: hydra-paredit-3

(defhydra hydra-paredit (:color pink )
"
    𝑀ove 𝐶𝑢𝑟𝑠𝑜𝑟┃ :				     𝑊𝑟𝑎𝑝⎛⎠ 、 𝐵arf 、 𝑆lurp :
      In():  ˲_i9_˱›  ⃓↑⎛⬎┃ )   ˲_i0_˱› (  ┃⬐⎞↑⃓           ˲_8_˱›f·barf▻  ⃰ ↓▁⎛ַ↑ ) ⃰        ˲_9_˱› ⃰ ┃⎛wrap⎠ ⃰        ˲_0_˱› ⃰ ( ַ↑⎠▁⮯ ⃰  ◅back·barf
  										     ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
      Out():  ˲_o9_˱›  ↓┃⎛↑⃓ )    ˲_o0_˱› ( ⃓↑⎞↓┃            ˲_p_˱›f·slurp▻  ⃰ ַ↑⎛⮯▁ ⃰  				 ˲_\\_˱› ⃰ ▁⮮⎠ַ↑ ⃰  ◅back·slur
   ───────────────────────────────────────────────
    𝐿eave() :  pre› ↓┃( ˲_M-[_˱⇠⃓   ⃓⇢ ˲_M-[_˱ )┃↓ ‹next
   ──────────────────────────────────────────────────🮢    ˲_[_˱›  ┃[sym]       ˲_,_˱ ›  ┃<sym>       ˲_{_˱ ›  ⎨sym⎬
                                _k_˱›  ⃰ kill ⎛𝑠𝑦𝑚⎠ ⃰   🮡─────────────────────────────────────────────────────────────────────────────────────
      ˲_s_˱›  ⃰ select⎛𝑠𝑦𝑚⎠ ⃰     ˲_m_˱›  ⃰ mark ⎛𝑠𝑦𝑚⎠ ⃰      ˲_u_˱ ›  ⎛̲̲Remove⎠̲̲     ˲_j_˱ › ( ₎ Join ₍ )     ˲_/_˱ › apart ▻  ( )_/_( )
   ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       ˲_C-q_˱ , ˲_q_˱ › quit   𝐻𝑦𝑑𝑟𝑎 — ⸨ 𝑷𝒂𝒓𝒆𝒅𝒊𝒕 ⸩
"
  ("q" nil)
  ("C-q" nil)
  ("C-g" nil)
  ("p" paredit-backward-barf-sexp)
  ("\\" paredit-forward-barf-sexp)

  ("r" paredit-splice-sexp)
  ("u" paredit-splice-sexp)
  ("k" kill-sexp)
  ("m" mark-sexp)
  ("c" paredit-copy-as-kill)
  ("j" paredit-join-sexps)
  ("/" paredit-split-sexp)

  ("o9" paredit-backward-up)
  ("o0" paredit-forward-up)
  ("i9" paredit-backward-down)
  ("i0" paredit-forward-down)
  (";" paredit-backward)
  ("'" paredit-forward)
  ("M-[" paredit-backward)
  ("M-]" paredit-forward)

  ("8" paredit-backward-slurp-sexp)
  ("9" paredit-wrap-round)
  ("0" paredit-forward-slurp-sexp)
  ("," paredit-wrap-angled)
  ("[" paredit-wrap-square)
  ("{" paredit-wrap-curly)

  ;; ("]" paredit-close-square)
  ;; ("." paredit-close-angled)  ;; ?
  ;; ("}" paredit-close-curly)
  ("s" (lambda () (interactive)
           (if (eq mark-active 1)
               (progn
                 (deactivate-mark)
                 (let ((re (region-end)))
                   (paredit-forward-up)
                   (setq re (point))
                   (backward-char)
                   (paredit-backward-up)
                   (set-mark re)
                   ))  ;; this function is similar to 'expand-region'
             (progn
               (let ((re))
                 (paredit-forward-up)
                 (setq re (point))
                 (backward-char)
                 (paredit-backward-up)
                 (set-mark re)
                 )
               )
             )
           ))
)
(define-key dired-mode-map "M-9" 'hydra-paredit/body)
Clone this wiki locally