help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Remove sexp without deleting contents


From: Tim Johnson
Subject: Re: Remove sexp without deleting contents
Date: Sun, 30 Sep 2018 07:14:17 -0800
User-agent: Mutt/1.10.0 (2018-05-17)

* Eric Abrahamsen <eric@ericabrahamsen.net> [180929 18:07]:
> Tim Johnson <tim@akwebsoft.com> writes:
> 
> > This poses a rather trivial question, but I'm betting on some
> > seredipity from responses.
> >
> > Suppose I want to remove an extraneous sexp. The following code
> > is simplistic:
> > (defun tj-toggle-menu-visible ()
> >   "Toggle visibility of menu bar and switches to tmm-style menus"
> >   (interactive)
> >   (if tj-menu-visible
> >       (progn
> >         (setq tj-menu-visible nil)
> >         (menu-bar-mode -1)
> >         (setq tj-is-windows nil))
> >     (progn
> >       (setq tj-menu-visible t)
> >       (menu-bar-mode 1)
> >       (setq tj-is-windows window-system))))
> >
> > ;; Suppose I want to remove the second `progn form, but not the
> > enclosed sequences. In this simple block of code of code it's pretty
> > hard to screw up: just delete/kill the line with "(progn" and any
> > right parens from the last line. In a more complex example I might
> > delete a parens whose absence could introduce unexpected and
> > problematic side effects.
> >
> > Is there function that might (effectively) simultaneously remove the
> > beginning of sexp and the matching closing paren, leaving inner
> > contents intact?
> 
> I would guess a majority of people who do a lot of lisp/elisp editing
> use the paredit package (in the repos). Maybe not a majority, who knows,
> but it's really useful. It lets you edit lisp code "logically": by atoms
> and sexps, rather than character-by-character. In paredit, the command
> `paredit-splice-sexp-killing-backward' would do what you want, it's
> bound to M-<up>.
> 
> HTH,
  That's the one I'm looking for, I'm sure. Will install. Thank you.
  cheers
-- 
Tim Johnson
http://www.tj49.com



reply via email to

[Prev in Thread] Current Thread [Next in Thread]