From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.help Subject: Re: Wrapping code in a try/except Date: Thu, 04 Nov 2010 15:17:24 -0400 Organization: A noiseless patient Spider Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1291885341 5789 80.91.229.12 (9 Dec 2010 09:02:21 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 9 Dec 2010 09:02:21 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Dec 09 10:02:16 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PQcOF-0000it-O9 for geh-help-gnu-emacs@m.gmane.org; Thu, 09 Dec 2010 10:02:16 +0100 Original-Received: from localhost ([127.0.0.1]:42003 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PQcOD-0008EE-NM for geh-help-gnu-emacs@m.gmane.org; Thu, 09 Dec 2010 04:02:13 -0500 Original-Path: usenet.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!news-1.dfn.de!news.dfn.de!newsfeed.straub-nv.de!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 25 Injection-Info: mx01.eternal-september.org; posting-host="OAfpAm0G9JJH6a5hJkeKQw"; logging-data="21042"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+WhyZe/bUcbZ6xbi/4ukGL" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) Cancel-Lock: sha1:IpjlHbroidT2nisGH2SnDuRyYMw= sha1:XzHivnn4SEkZG1mQus2Cbwivse4= Original-Xref: usenet.stanford.edu gnu.emacs.help:182210 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:76897 Archived-At: > 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