From: Marcin Borkowski <mbork@mbork.pl>
To: John Mastro <john.b.mastro@gmail.com>
Cc: Help Gnu Emacs mailing list <help-gnu-emacs@gnu.org>
Subject: Re: How to delete the parens around a sexp?
Date: Mon, 19 Oct 2015 08:04:01 +0200 [thread overview]
Message-ID: <8737x7fl7y.fsf@mbork.pl> (raw)
In-Reply-To: <CAOj2CQTXAyF_Kp+=q-XAHtjvRrbt2zspCTiZBQFCQZkoiVwoLg@mail.gmail.com>
On 2015-09-23, at 04:15, John Mastro <john.b.mastro@gmail.com> wrote:
>> 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.
Last time I did, it didn't work in my use-case. Not that it doesn't
work; it is just not smart enough for me;-). Consider this LaTeX code:
\left\{ ... \bigl\langle ... ( ... ] ... \bigr\rangle ... \right.
(The dot after \right is part of the code.)
> 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)))
Nice, better than delete-pair.
> [1] I still prefer Paredit when working with Lisps but plenty of
> reasonable people use Smartparens everywhere.
I didn't try paredit, but - as I wrote a minute ago - Lispy might be
even better due to its cool reuse of self-inserting commands in contexts
they don't make sense anyway.
Regards,
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University
next prev parent reply other threads:[~2015-10-19 6:04 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-22 7:40 How to delete the parens around a sexp? Marcin Borkowski
2015-09-22 10:11 ` Nicolas Richard
2015-09-22 11:30 ` Edward Knyshov
2015-09-22 11:45 ` Rasmus
2015-09-22 11:54 ` Andreas Röhler
2015-09-23 0:49 ` Emanuel Berg
2015-09-23 0:58 ` Emanuel Berg
2015-09-23 2:15 ` John Mastro
2015-09-23 3:06 ` Emanuel Berg
2015-10-19 6:04 ` Marcin Borkowski [this message]
2015-10-21 11:23 ` Oleh Krehel
2015-10-18 22:12 ` Thien-Thi Nguyen
2015-10-19 5:59 ` Marcin Borkowski
[not found] ` <mailman.588.1445207663.7904.help-gnu-emacs@gnu.org>
2015-10-19 0:49 ` Pascal J. Bourguignon
2015-10-19 5:59 ` Marcin Borkowski
[not found] <mailman.1573.1442907653.19560.help-gnu-emacs@gnu.org>
2015-09-22 8:28 ` Joost Kremers
2015-09-22 8:38 ` Marco Wahl
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8737x7fl7y.fsf@mbork.pl \
--to=mbork@mbork.pl \
--cc=help-gnu-emacs@gnu.org \
--cc=john.b.mastro@gmail.com \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).