From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: John Mastro Newsgroups: gmane.emacs.help Subject: Re: How to delete the parens around a sexp? Date: Tue, 22 Sep 2015 19:15:24 -0700 Message-ID: References: <87vbb23nrn.fsf@mbork.pl> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1442974640 24272 80.91.229.3 (23 Sep 2015 02:17:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 23 Sep 2015 02:17:20 +0000 (UTC) To: Help Gnu Emacs mailing list Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Sep 23 04:17:20 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZeZcV-0002Es-Nh for geh-help-gnu-emacs@m.gmane.org; Wed, 23 Sep 2015 04:17:19 +0200 Original-Received: from localhost ([::1]:44485 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeZcV-0001em-1T for geh-help-gnu-emacs@m.gmane.org; Tue, 22 Sep 2015 22:17:19 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35829) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeZb0-0008LJ-Le for help-gnu-emacs@gnu.org; Tue, 22 Sep 2015 22:15:47 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeZaz-0005YI-7F for help-gnu-emacs@gnu.org; Tue, 22 Sep 2015 22:15:46 -0400 Original-Received: from mail-ob0-x231.google.com ([2607:f8b0:4003:c01::231]:35112) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeZaz-0005Uf-1A for help-gnu-emacs@gnu.org; Tue, 22 Sep 2015 22:15:45 -0400 Original-Received: by obbzf10 with SMTP id zf10so22895790obb.2 for ; Tue, 22 Sep 2015 19:15:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=f2fIJldqKkmjzrnf0HJy6sZd7W5IHLF2kJJWbYOdS34=; b=KRNYT+mmcJiuCGwdKS+TLpc7XWlLB2A92y1zJwcO0wYg+uzthW24L96f8cnqbwA9ZL 32oM43KO0Bdbda9dCvLfV4INOAeP8+rn0mDNuwyxnQSflwKaLhjLrRWCcARNgVqDI+Aj 3YpTfo2Nrof8S8qkWaLgR8/+GQ+7n3mG8D5GLapW8ksdFqddvPST/zpok0Q4U+XA2FZs +jP8d6CAG9mf4lfXEPlU8dmXCAQL88I677wFOjI4OJgMfXITdZhF5DM/UV2MJk7j7f2g Cqv7Rb1xhm8BdO2O45MlehQrmE1UeSP6EGUPiZT+YztwfJn+ABVxsZGrPz1YHjBbHV4a ojEg== X-Received: by 10.182.245.197 with SMTP id xq5mr6938003obc.3.1442974544025; Tue, 22 Sep 2015 19:15:44 -0700 (PDT) Original-Received: by 10.76.45.8 with HTTP; Tue, 22 Sep 2015 19:15:24 -0700 (PDT) In-Reply-To: <87vbb23nrn.fsf@mbork.pl> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4003:c01::231 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 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-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:107302 Archived-At: > I'd like to transform this: > > -!-(some gibberish) > > into this: > > -!-some gibberish > > I assume there's no function in Elisp for that, and it's trivial to > write one, but I just wanted to make sure before I code it. raise-sexp > doesn't work, since it gobbles "gibberish" in the above example unless > given a prefix argument, and if you replace "some gibberish" with an > actual sentence, counting words manually is no fun. > > (Note: before anyone tells me how such a transformation doesn't make > sense: I need it for writing in a natural language.) As someone else noted, `sp-unwrap-sexp' (part of the `smartparens' package) does this. Smartparens is great for bringing some of the joy of Paredit to non-Lisps [1] so I'd recommend checking it out anyway. However, if you don't want to depend on a third-party package, something along these lines might help get you started: (defun unwrap-next-sexp () (interactive) (let ((close (progn (forward-sexp 1) (point))) (open (progn (forward-sexp -1) (point)))) (goto-char close) (delete-char -1) (goto-char open) (delete-char 1))) [1] I still prefer Paredit when working with Lisps but plenty of reasonable people use Smartparens everywhere. -- john