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: Tue, 23 Nov 2010 15:32:46 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (darwin)

Andrea Crotti <address@hidden> writes:
>
> puff that'a a lot of code ;)
> You would be right about yasnippet, if it wasn't that there are
> variables like
>
> yas/selected-text, and wrap-region.
> This for example works perfectly when I use the kill-ring.
> When I use the selected text it just doesn't indent after, maybe the
> hook is a bit buggy.
> I'll try to update and see if anything changes, but actually I would
> prefer it a lot...
>
> try {
>     `(or yas/selected-text (car kill-ring))`
> } catch ${1:Exception} {
>
> }

I updated an tried again, actually the solution using

(defun my-whole-indent ()
         (indent-region (point-min)(point-max)))
         
(add-hook 'yas/after-exit-snippet-hook 'my-whole-indent)

is almost perfect, the only problem is that for some reasons after
exiting the first snippet, EVERY key I press triggers the exit snippet,
so emacs keeps reindenting the buffer all the time.

It doesn't make much sense to me, I thought it was my configuration but
also with 
Emacs -Q and only the minimal loaded it's the same...
Also using a timer of course can be fine, maybe even better




reply via email to

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