On Mon, Nov 13, 2023 at 1:41 AM Dmitry Gutov <dmitry@gutov.dev> wrote:
>
> On 13/11/2023 03:16, João Távora wrote:
> > On Mon, Nov 13, 2023 at 1:05 AM Dmitry Gutov <dmitry@gutov.dev> wrote:
> >>
> >> On 13/11/2023 03:03, João Távora wrote:
> >
> >> electric-pair-mode is necessary but not sufficient.
> >>
> >> I'm the structured editing kind of guy. With all the accompanying
> >> slurping and barfing.
> >
> > I slurp.  I barf.  C-M-k,f,b,u mostly works.  I have an extract-list
> > function too.
>
> Perhaps I missed the addition of the slurping and barfing commands to
> elec-pair? Sexp navigation works indeed.

At least i didn't add anything.  I just said that I use sexp stuff 
for doing those structural operations.  Along with the command
after my sig, which I've had for almost 20 years.

> > But I would love that paredit.el would just supply the slurp/barf
> > commands separate from the broken (IMHO) auto-pairing logic that I'm
> > not interested in.
>
> But I like this one which keeps the code paired and makes sure C-k
> doesn't kill too much.

electric-pair-mode keeps the code paired.  I like C-k killing 
whole lines, even in lisp.  I hate those harnesses, I just put
add a thumb on the alt key when I need to work with sexps.

Of course to each his own.  Doesn't seem you need e-p-m at all.

João

(defun joaot/extract-list-or-region (arg)
  "Take the list after the point and remove the surrounding list.  With
argument ARG do it that many times."
  (interactive "p")
  (let* ((start (if mark-active
                    (region-beginning)
                  (point)))
         (end (if mark-active
                  (region-end)
                (save-excursion
                  (forward-sexp)
                  (point))))
         (extracted (buffer-substring start end))
         (stop nil))
    (backward-up-list (or arg 1))
    (progn
      (delete-region start end)
      (condition-case err
          (kill-region (point)
                       (save-excursion
                         (forward-sexp)
                         (point)))
        (error (goto-char start)
               (insert extracted)
               (message "ooops....")
               (setq stop t)))
      (unless stop
        (indent-region
         (point)
         (progn
           (save-excursion
             (insert extracted)
             (point))))))))