Popular recipes by Eric Promislow http://code.activestate.com/recipes/users/4166930/2011-02-03T23:47:41-08:00ActiveState Code RecipesA Komodo macro for duplicating the current file in Komodo 6 (JavaScript) 2011-02-03T23:47:41-08:00Eric Promislowhttp://code.activestate.com/recipes/users/4166930/http://code.activestate.com/recipes/577562-a-komodo-macro-for-duplicating-the-current-file-in/ <p style="color: grey"> JavaScript recipe 577562 by <a href="/recipes/users/4166930/">Eric Promislow</a> (<a href="/recipes/tags/copy/">copy</a>, <a href="/recipes/tags/files/">files</a>). </p> <p>The project/file API changed significantly moving from Komodo 5 to 6. Specifically, the project manager and file manager have been split into two separate modules.</p> <p>Here's some code to duplicate the current file, using Komodo 6. Note that it uses an internal function - I've made a note that the function has been effectively published, and needs to preserve its current interface.</p> Get the Name of the Current Method (JavaScript) 2011-01-03T20:49:58-08:00Eric Promislowhttp://code.activestate.com/recipes/users/4166930/http://code.activestate.com/recipes/577532-get-the-name-of-the-current-method/ <p style="color: grey"> JavaScript recipe 577532 by <a href="/recipes/users/4166930/">Eric Promislow</a> (<a href="/recipes/tags/codeintel/">codeintel</a>, <a href="/recipes/tags/komodo/">komodo</a>, <a href="/recipes/tags/sections/">sections</a>). </p> <p>Here's a snippet for Komodo JavaScript macros that gives the name of the current method</p> Convert XML files to structurally equivalent garbage (Python) 2010-12-15T18:57:42-08:00Eric Promislowhttp://code.activestate.com/recipes/users/4166930/http://code.activestate.com/recipes/577501-convert-xml-files-to-structurally-equivalent-garba/ <p style="color: grey"> Python recipe 577501 by <a href="/recipes/users/4166930/">Eric Promislow</a> (<a href="/recipes/tags/randomization/">randomization</a>, <a href="/recipes/tags/shrouding/">shrouding</a>, <a href="/recipes/tags/xml/">xml</a>). </p> <p>You've found a bug in an application that reads XML files. You'd prefer not to share your data, though, but you'd really like to help the vendor fix the bug. This program maintains the document's structure, but it randonly converts each word into random gibberish, replacing vowels with vowels, consonants with consonants, and digits with digits. It also interns each element and attribute name, so all instances of "foo" as an element or attribute name would show up as, say, "xeu", but instances of "foo" in character data would be mapped to a different string each time.</p> A Template for Crash-Resistant Toggle-Macros (JavaScript) 2010-10-07T00:51:42-07:00Eric Promislowhttp://code.activestate.com/recipes/users/4166930/http://code.activestate.com/recipes/577418-a-template-for-crash-resistant-toggle-macros/ <p style="color: grey"> JavaScript recipe 577418 by <a href="/recipes/users/4166930/">Eric Promislow</a> (<a href="/recipes/tags/komodo/">komodo</a>, <a href="/recipes/tags/macro/">macro</a>, <a href="/recipes/tags/snippet/">snippet</a>, <a href="/recipes/tags/template/">template</a>). </p> <p>If you've followed my postings here lately (<a href="http://code.activestate.com/recipes/users/4166930/" rel="nofollow">http://code.activestate.com/recipes/users/4166930/</a>), you'll see that I've been playing with what I call "toggle macros", macros that toggle a state on and off, with different behaviors for each state. Unfortunately I found that it was easy to get Komodo to crash on shutdown. Meanwhile I wanted to build a framework to make it easier to build these.</p> <p>This recipe accomplishes both. It looks like putting a listener on a view object can trigger this crash, but so can storing a method on a view object, even with a unique name. So while I wanted to use the "view.view_closing" event, I can't, and I notice no other core Komodo code is. The template instead uses a global hash, ko.extensions.togglers, to store the code objects. And now I'm not getting a crash.</p> Revisiting "Revenge of the auto-wrap": Another toggle-macro (JavaScript) 2010-10-04T23:51:41-07:00Eric Promislowhttp://code.activestate.com/recipes/users/4166930/http://code.activestate.com/recipes/577417-revisiting-revenge-of-the-auto-wrap-another-toggle/ <p style="color: grey"> JavaScript recipe 577417 by <a href="/recipes/users/4166930/">Eric Promislow</a> (<a href="/recipes/tags/autowrap/">autowrap</a>, <a href="/recipes/tags/javascript/">javascript</a>, <a href="/recipes/tags/komodo/">komodo</a>, <a href="/recipes/tags/togglemacro/">togglemacro</a>). Revision 2. </p> <p>Komodo doesn't automatically wrap lines when they reach a certain length, which is a good trait to have in a code editor. However, for those times where you're editing non-code, it can be helpful to have newlines inserted automatically. Troy Topnik addressed this problem a couple of years ago, in his post <a href="http://www.activestate.com/blog/2008/11/revenge-auto-wrap-type-type-type-ding" rel="nofollow">http://www.activestate.com/blog/2008/11/revenge-auto-wrap-type-type-type-ding</a> . As Komodo 6 heads out the door, I've been writing blog posts, and found this feature useful. But his solution used two macros. I put my coding hat back on, and reimplemented it as a "toggle macro".</p> Implementing Vertical Editing in Komodo 6 (JavaScript) 2010-09-29T19:09:35-07:00Eric Promislowhttp://code.activestate.com/recipes/users/4166930/http://code.activestate.com/recipes/577406-implementing-vertical-editing-in-komodo-6/ <p style="color: grey"> JavaScript recipe 577406 by <a href="/recipes/users/4166930/">Eric Promislow</a> (<a href="/recipes/tags/columns/">columns</a>, <a href="/recipes/tags/komodo/">komodo</a>, <a href="/recipes/tags/verticalediting/">verticalediting</a>). Revision 4. </p> <p>When editing a group of similar lines, it's very convenient to be able to press down-arrow and move to the same starting column position on the next line. (See an example at <a href="http://community.activestate.com/forum/vertical-editing" rel="nofollow">http://community.activestate.com/forum/vertical-editing</a> ).</p> <p>This code is for a Komodo 6 macro -- possibly the only tweak necessary to make it work on Komodo 5 is by commenting out the "macro.save()" code, but I haven't tested it. The discussion below will talk about how to use it. </p> Komodo: avoid tab-buildup with a find-alternate-file macro (JavaScript) 2010-09-28T18:16:42-07:00Eric Promislowhttp://code.activestate.com/recipes/users/4166930/http://code.activestate.com/recipes/577412-komodo-avoid-tab-buildup-with-a-find-alternate-fil/ <p style="color: grey"> JavaScript recipe 577412 by <a href="/recipes/users/4166930/">Eric Promislow</a> (<a href="/recipes/tags/find_alternate_file/">find_alternate_file</a>, <a href="/recipes/tags/komodo/">komodo</a>). </p> <p>In Emacs I used to use find-alternate-file all the time to replace the current buffer with a different one, usually one in the same directory. Komodo doesn't provide an off-the-shelf way to do this, and if you can't be bothered to close buffers when you no longer need them, you'll soon suffer from the dreaded tab buildup problem, up there with the heartbreak of browser tab overload. But it's easy to write a macro to avoid this. </p> Komodo JS Macro - delete marked lines (JavaScript) 2010-08-30T17:32:24-07:00Eric Promislowhttp://code.activestate.com/recipes/users/4166930/http://code.activestate.com/recipes/577378-komodo-js-macro-delete-marked-lines/ <p style="color: grey"> JavaScript recipe 577378 by <a href="/recipes/users/4166930/">Eric Promislow</a> (<a href="/recipes/tags/bookmarks/">bookmarks</a>, <a href="/recipes/tags/editor/">editor</a>, <a href="/recipes/tags/javascript/">javascript</a>, <a href="/recipes/tags/komodo/">komodo</a>). </p> <p>You can set bookmarks in Komodo, for ease ni revisiting certain lines. This recipe lets you delete all the marked lines in the current buffer. This code is undoable, but the markers are gone for good. They aren't restored by Scintilla, and having Komodo restore them would be a pain.</p> A Komodo macro for duplicating the current file (Komodo 5 only!) (JavaScript) 2011-02-03T23:45:02-08:00Eric Promislowhttp://code.activestate.com/recipes/users/4166930/http://code.activestate.com/recipes/577085-a-komodo-macro-for-duplicating-the-current-file-ko/ <p style="color: grey"> JavaScript recipe 577085 by <a href="/recipes/users/4166930/">Eric Promislow</a> (<a href="/recipes/tags/javascript/">javascript</a>, <a href="/recipes/tags/komodo/">komodo</a>). </p> <p>Komodo projects look like file managers, but don't always offer the same functionality directly. Here's a macro that makes a copy of the current selected file in a project. To use it, create a new macro in the Komodo toolbox, copy this code, paste it in the macro, and save it. Then you can select a file, double-click the macro icon (or assign it to a keybinding), and Komodo will create a copy of the file called "Copy of &lt;basename&gt;.&lt;extension&gt;".</p> Komodo JS Macro - move current line up one (JavaScript) 2010-03-10T12:24:43-08:00Eric Promislowhttp://code.activestate.com/recipes/users/4166930/http://code.activestate.com/recipes/577100-komodo-js-macro-move-current-line-up-one/ <p style="color: grey"> JavaScript recipe 577100 by <a href="/recipes/users/4166930/">Eric Promislow</a> (<a href="/recipes/tags/javascript/">javascript</a>, <a href="/recipes/tags/komodo/">komodo</a>). </p> <p>This Komodo macro moves the line containing the caret (cursor) up one line, and then puts the caret at the start of that line in its new position. Put the macro in your toolbox, and bind it to Ctrl-Shift-UpArrow (unused in the default Komodo keybinding set) to get the same functionality as in some other popular editors).</p> Komodo JS Macro - move current line down one (JavaScript) 2010-03-10T12:25:06-08:00Eric Promislowhttp://code.activestate.com/recipes/users/4166930/http://code.activestate.com/recipes/577101-komodo-js-macro-move-current-line-down-one/ <p style="color: grey"> JavaScript recipe 577101 by <a href="/recipes/users/4166930/">Eric Promislow</a> (<a href="/recipes/tags/javascript/">javascript</a>, <a href="/recipes/tags/komodo/">komodo</a>). </p> <p>This Komodo macro moves the line containing the caret (cursor) down one line, and then puts the caret at the start of that line in its new position. Put the macro in your toolbox, and bind it to Ctrl-Shift-DownpArrow (unused in the default Komodo keybinding set) to get the same functionality as in some other popular editors).</p>