* Remove sexp without deleting contents
@ 2018-09-29 22:31 Tim Johnson
2018-09-30 1:54 ` Eric Abrahamsen
2018-10-01 7:22 ` Marcin Borkowski
0 siblings, 2 replies; 4+ messages in thread
From: Tim Johnson @ 2018-09-29 22:31 UTC (permalink / raw)
To: Emacs
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?
thanks.
--
Tim Johnson
http://www.tj49.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Remove sexp without deleting contents
2018-09-29 22:31 Remove sexp without deleting contents Tim Johnson
@ 2018-09-30 1:54 ` Eric Abrahamsen
2018-09-30 15:14 ` Tim Johnson
2018-10-01 7:22 ` Marcin Borkowski
1 sibling, 1 reply; 4+ messages in thread
From: Eric Abrahamsen @ 2018-09-30 1:54 UTC (permalink / raw)
To: help-gnu-emacs
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,
Eric
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Remove sexp without deleting contents
2018-09-30 1:54 ` Eric Abrahamsen
@ 2018-09-30 15:14 ` Tim Johnson
0 siblings, 0 replies; 4+ messages in thread
From: Tim Johnson @ 2018-09-30 15:14 UTC (permalink / raw)
To: help-gnu-emacs
* 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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Remove sexp without deleting contents
2018-09-29 22:31 Remove sexp without deleting contents Tim Johnson
2018-09-30 1:54 ` Eric Abrahamsen
@ 2018-10-01 7:22 ` Marcin Borkowski
1 sibling, 0 replies; 4+ messages in thread
From: Marcin Borkowski @ 2018-10-01 7:22 UTC (permalink / raw)
To: Tim Johnson; +Cc: Emacs
http://oremacs.com/lispy/
Hth,
On 2018-09-30, at 00:31, Tim Johnson <tim@akwebsoft.com> wrote:
> 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?
>
> thanks.
--
Marcin Borkowski
http://mbork.pl
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-10-01 7:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-29 22:31 Remove sexp without deleting contents Tim Johnson
2018-09-30 1:54 ` Eric Abrahamsen
2018-09-30 15:14 ` Tim Johnson
2018-10-01 7:22 ` Marcin Borkowski
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.