all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Tim Johnson <tim@akwebsoft.com>
To: Emacs <Help-gnu-emacs@gnu.org>
Subject: Remove sexp without deleting contents
Date: Sat, 29 Sep 2018 14:31:11 -0800	[thread overview]
Message-ID: <20180929223111.GA24326@mail.akwebsoft.com> (raw)

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



             reply	other threads:[~2018-09-29 22:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-29 22:31 Tim Johnson [this message]
2018-09-30  1:54 ` Remove sexp without deleting contents Eric Abrahamsen
2018-09-30 15:14   ` Tim Johnson
2018-10-01  7:22 ` Marcin Borkowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180929223111.GA24326@mail.akwebsoft.com \
    --to=tim@akwebsoft.com \
    --cc=Help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.