[OS X Emacs] Re: delete parantheses pair
Marc Shapiro -- at work
marc.shapiro at acm.org
Wed Feb 9 15:34:08 EST 2011
>
> Message: 1
> Date: Tue, 08 Feb 2011 21:40:26 -0800
> From: David Rogoff <cs80 at therogoffs.com>
> Subject: Re: [OS X Emacs] delete parantheses pair
> To: Emacs on Mac OS X Mailing List <macosx-emacs at email.esm.psu.edu>
> Message-ID: <4D5228CA.10102 at therogoffs.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
>
>>
>> I want to code a function or a macro that would delete a pair of
>> delimiters (but not what is inside) and optionally the adjoined word
>>
>> so this
>>
>> { abcdefgh }.sth
>>
>> would become
>>
>> abcdefgh
>>
>> but as soon as I delete one of the delimiters I cannot move to the other
>> as it is no longer balanced.. how can I do this ?
>>
>> maybe there is already sth similar implemented ??
Here is a solution for you. I just implemented deleting the parentheses. Deleting the adjoined word is left as an exercise for the reader.
(defun delete-balanced-parentheses ()
(interactive)
(cond ((looking-at "\\s(")
(save-excursion
(let ((open-paren (point)))
(forward-sexp)
(delete-char -1)
(goto-char open-paren)
(delete-char 1))))
(t
(error "Not looking at open parenthesis")
)))
Just in case this gets mangled during transmission, the string on the third line is: backslash backslash lowercase_s open_parenthesis
Marc
More information about the MacOSX-Emacs
mailing list