[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Insert debug statement with repeated string? ELSE, perhaps?
From: |
Mathias Dahl |
Subject: |
Re: Insert debug statement with repeated string? ELSE, perhaps? |
Date: |
Mon, 14 Feb 2005 08:46:22 +0100 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/21.3.50 (windows-nt) |
jjl@pobox.com (John J. Lee) writes:
> I'd like to be able to insert debug statements that contain a repeated
> string, for example:
>
> jjl.debug('fooBar %r' % fooBar)
>
> without typing the string 'fooBar' twice, and with not too many
> keystrokes: ie without fiddling around with cursor positioning, C-y,
> etc. (well, actually p or P rather than C-y for me, since I'm using
> viper).
I would use a keyboard macro for doing that, or put together
a simple elisp snippet if this is something I would use
often, like this:
(defun insert-debug-string (dbg-str)
(interactive "sString to debug: ")
(insert (format "jjl.debugs('%s %%r' %% %s )" dbg-str dbg-str)))
execute this with M-x insert-debug-string, or bind a key to
it.
There are probably hundreds of ways of doing this in Emacs,
for example using abbrevs or code skeletons, but if the
above works, it works... :)
/Mathias