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

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

Re: Wrapping code in a try/except


From: Andrea Crotti
Subject: Re: Wrapping code in a try/except
Date: Fri, 19 Nov 2010 15:39:09 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (darwin)

Andreas Röhler <address@hidden> writes:

> Hi Andrea,
>
> if its just about editing and that simple as shown
> M-x query-replace-regexp
>
> should do all you need.
>
> Maybe narrow the buffer to region before.
>
>
> Andreas
>
> --
> https://code.launchpad.net/~a-roehler/python-mode/python-mode-components
> https://code.launchpad.net/s-x-emacs-werkstatt/

Well I watend to use yasnippet so here it is ;):
--8<---------------cut here---------------start------------->8---
# -*- mode: snippet -*-
# name: tryw
# key: tryw
# contributor: Andrea Crotti
# --
try {
    `(or yas/selected-text (car kill-ring))`
} catch ${1:type} {

}
--8<---------------cut here---------------end--------------->8---

this is even nicer, because it uses the selected text or the last killed
string if nothing is found.

Of course is a bit intrusive so another "normal" snippet is also needed.
And another problem is that the indentation is not correct.
Or better it is correct inside the try/catch but it's not automatically
indented in the rest of the C++ code...




reply via email to

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