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: Stefan Monnier
Subject: Re: Wrapping code in a try/except
Date: Wed, 08 Dec 2010 15:34:35 -0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

> It would be nice sometimes to be able to wrap multiple lines
> istruction1();
> istruction2();

> in something like

> try {
>     istruction1();
>     istruction2();
> } except ...

Don't know about yasnippet, but with skeletons, you'd do:

(define-skeleton my-try-except
  "Insert a try..except template."
  nil
  \n "try {" > \n _ \n "} except ..." > \n)

And then you just select the lines you want to wrap and
do M-x my-try-except RET.
You'll probably also want to make this command more easily accessible,
e.g. by adding it to your abbrevs or some key binding.


        Stefan


reply via email to

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