help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to delete the parens around a sexp?


From: Joost Kremers
Subject: Re: How to delete the parens around a sexp?
Date: 22 Sep 2015 08:28:57 GMT
User-agent: slrn/pre1.0.0-18 (Linux)

Marcin Borkowski 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.)

Using the smartparens package, sp-splice-sexp-killing-backwards does
that. Consider the following examples (where | indicates point):

(insert (|format "Some string")) ==> (insert |format "Some string")

(insert |(format "Some string")) ==> |(format "Some string")

paredit (and I assume lispy) have similar commands, but they only work
in Lisp modes. smartparens handles any kind of delimiters, also quotes
etc. and can work in non-Lisp modes as well. For example, I can do the
transformations above in the buffer I'm writing this message in, which
has `message-mode` as its major mode. And I use it sometimes to
transform footnotes in LaTeX into normal text.


-- 
Joost Kremers                                   joostkremers@fastmail.fm
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]