[OS X Emacs] Re: delete parantheses pair

Marinos K marinos at agxivatein.com
Thu Feb 10 04:20:29 EST 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

thx Marc !

it seems pretty elegant..

m

On 09/02/2011 10:34 ?.?., Marc Shapiro -- at work wrote:
>>
>> 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
> 
> 
> 
> 
> 
> 
> 
> _____________________________________________________________
> MacOSX-Emacs mailing list
> MacOSX-Emacs at email.esm.psu.edu
> http://email.esm.psu.edu/mailman/listinfo/macosx-emacs
> List Archives: http://dir.gmane.org/gmane.emacs.macintosh.osx
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJNU63PAAoJEHtg0hV818BQ5B0IAMAAPm8QNhoHkfx6ka3jXpzC
iMlDiM5ivRGEfbZQr/WmNDGGwhF0/qrGVu/wqYj/OzAmzK9tX5XaSbQh751FDb6J
/BFyX/YMhjE5/xp1nSWN/ktcAjIMqcQ5hSipEypgt7oyUdLLGV/yWavlngQmhdNL
IIWnGEyUDIfqYeKKkFJdxLNd4XNsx6ZYDHOAV7BpnHdzSvrXWVS9AhPKx8vsZurT
fqln5nyb6Aj1eVLLaGKOKTBtmWdXI+rN55US2SBuuG3utKAq7qg0BbeT44x94wHq
ybimX7oCxs8c8ee69rwkOorWoxtvDfA5IpXAXT1mL6AaayOm+fid3qpybzLCRK0=
=TgY9
-----END PGP SIGNATURE-----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0x7CD7C050.asc
Type: application/pgp-keys
Size: 4258 bytes
Desc: not available
URL: <http://email.esm.psu.edu/pipermail/macosx-emacs/attachments/20110210/3668354a/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0x7CD7C050.asc.sig
Type: application/octet-stream
Size: 287 bytes
Desc: not available
URL: <http://email.esm.psu.edu/pipermail/macosx-emacs/attachments/20110210/3668354a/attachment.obj>


More information about the MacOSX-Emacs mailing list