From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Marcin Borkowski Newsgroups: gmane.emacs.help Subject: Re: Remove sexp without deleting contents Date: Mon, 01 Oct 2018 09:22:59 +0200 Message-ID: <875zym167g.fsf@mbork.pl> References: <20180929223111.GA24326@mail.akwebsoft.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1538378582 8880 195.159.176.226 (1 Oct 2018 07:23:02 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 1 Oct 2018 07:23:02 +0000 (UTC) User-Agent: mu4e 1.1.0; emacs 27.0.50 Cc: Emacs To: Tim Johnson Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Oct 01 09:22:58 2018 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g6sXg-0002Ah-Gt for geh-help-gnu-emacs@m.gmane.org; Mon, 01 Oct 2018 09:22:56 +0200 Original-Received: from localhost ([::1]:59837 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6sZn-0003VK-6s for geh-help-gnu-emacs@m.gmane.org; Mon, 01 Oct 2018 03:25:07 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38440) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6sZH-0003VC-Tu for Help-gnu-emacs@gnu.org; Mon, 01 Oct 2018 03:24:36 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g6sZC-00050z-TX for Help-gnu-emacs@gnu.org; Mon, 01 Oct 2018 03:24:35 -0400 Original-Received: from mail.mojserwer.eu ([195.110.48.8]:35598) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6sZB-0004tI-2N for Help-gnu-emacs@gnu.org; Mon, 01 Oct 2018 03:24:29 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by mail.mojserwer.eu (Postfix) with ESMTP id 76471E69B5; Mon, 1 Oct 2018 09:24:21 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mail.mojserwer.eu Original-Received: from mail.mojserwer.eu ([127.0.0.1]) by localhost (mail.mojserwer.eu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id piYZls_lmoIg; Mon, 1 Oct 2018 09:24:17 +0200 (CEST) Original-Received: from localhost (83.25.56.122.ipv4.supernova.orange.pl [83.25.56.122]) by mail.mojserwer.eu (Postfix) with ESMTPSA id F3F60E6844; Mon, 1 Oct 2018 09:24:16 +0200 (CEST) In-reply-to: <20180929223111.GA24326@mail.akwebsoft.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 195.110.48.8 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:118084 Archived-At: http://oremacs.com/lispy/ Hth, On 2018-09-30, at 00:31, Tim Johnson 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