<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>Alex's Adventures on the Infobahn - javascript</title><link href="https://www.bennee.com/~alex/" rel="alternate"></link><link href="https://www.bennee.com/~alex/blog/tag/javascript/feed" rel="self"></link><id>https://www.bennee.com/~alex/</id><updated>2011-11-06T20:25:00+00:00</updated><subtitle>the wanderings of a supposed digital native</subtitle><entry><title>Edit with Emacs v1.10 released</title><link href="https://www.bennee.com/~alex/blog/2011/11/06/edit-with-emacs-v1-10-released/" rel="alternate"></link><published>2011-11-06T20:25:00+00:00</published><updated>2011-11-06T20:25:00+00:00</updated><author><name>alex</name></author><id>tag:www.bennee.com,2011-11-06:/~alex/blog/2011/11/06/edit-with-emacs-v1-10-released/</id><summary type="html">&lt;p&gt;I received a bunch of feedback and patches from my last announcement but I think all the outstanding bugs are now squashed. The edit-server.el has seen some love to make it more idiomatically correct for elisp. The main change is new code to handle editable DIV tags beloved of …&lt;/p&gt;</summary><content type="html">&lt;p&gt;I received a bunch of feedback and patches from my last announcement but I think all the outstanding bugs are now squashed. The edit-server.el has seen some love to make it more idiomatically correct for elisp. The main change is new code to handle editable DIV tags beloved of such sites as Google+ (which you are welcome to &lt;a class="reference external" href="https://plus.google.com/u/0/110732415405459842150/posts"&gt;follow me on&lt;/a&gt;, maybe I should have an elisp circle?).&lt;/p&gt;
&lt;p&gt;A big cosmetic change is a brand new settings page which looks less like a web-form from the early 90's and more like part of Chrome. Alas I can take no credit for this but can thank Frank Kohlhepp's &lt;a class="reference external" href="https://github.com/frankkohlhepp/fancy-settings"&gt;fancy-settings&lt;/a&gt; library. In fact a lot of the credit should go to third party libraries like &lt;a class="reference external" href="http://jquery.com/"&gt;jQuery&lt;/a&gt; and of course the growing list of contributors who have submitted code for merging.&lt;/p&gt;
&lt;p&gt;So the final changelog for 1.10 is:&lt;/p&gt;
&lt;p&gt;Extension&lt;/p&gt;
&lt;div class="line-block"&gt;
&lt;div class="line"&gt;* Ignore textareas marked as read only&lt;/div&gt;
&lt;div class="line"&gt;* Don't tag areas that are not visible&lt;/div&gt;
&lt;div class="line"&gt;* General clean-up to use jQuery to find elements&lt;/div&gt;
&lt;div class="line"&gt;* Explicit CSS for edit button to override page settings&lt;/div&gt;
&lt;div class="line"&gt;* Handle editable DIV blocks (e.g. Google+)&lt;/div&gt;
&lt;div class="line"&gt;* Optimise the finding of text areas for highly dynamic pages&lt;/div&gt;
&lt;div class="line"&gt;* Revamp the settings page with &amp;quot;Fancy Settings&amp;quot;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;edit-server.el&lt;/p&gt;
&lt;div class="line-block"&gt;
&lt;div class="line"&gt;* Allow customisation of edit-server-default-major-mode&lt;/div&gt;
&lt;div class="line"&gt;* Allow edit mode to be set by matched URL&lt;/div&gt;
&lt;div class="line"&gt;* Tweak detection of MacOS X Emacsen&lt;/div&gt;
&lt;div class="line"&gt;* Change behaviour of C-x C-s to save to kill-ring&lt;/div&gt;
&lt;div class="line"&gt;* Persist the buffer-local variables beyond mode changes&lt;/div&gt;
&lt;div class="line"&gt;* Setup keymap within defvar&lt;/div&gt;
&lt;div class="line"&gt;* Clean-ups to code to be more idiomatic.&lt;/div&gt;
&lt;/div&gt;
</content><category term="geek"></category><category term="chrome"></category><category term="chromium"></category><category term="edit with emacs"></category><category term="emacs"></category><category term="javascript"></category><category term="jquery"></category></entry><entry><title>Edit with Emacs v1.8</title><link href="https://www.bennee.com/~alex/blog/2010/08/19/edit-with-emacs-v1-8/" rel="alternate"></link><published>2010-08-19T11:10:00+01:00</published><updated>2010-08-19T11:10:00+01:00</updated><author><name>alex</name></author><id>tag:www.bennee.com,2010-08-19:/~alex/blog/2010/08/19/edit-with-emacs-v1-8/</id><summary type="html">&lt;p&gt;After a relatively quiet period a number of patches have flowed my way so I thought it was worth pushing out a new version. Perhaps the most &amp;quot;important&amp;quot; feature is the edit box flashing and fading from yellow after being updated (like &lt;a class="reference external" href="http://trac.gerf.org/itsalltext"&gt;It's All Text&lt;/a&gt;). It wasn't that hard to …&lt;/p&gt;</summary><content type="html">&lt;p&gt;After a relatively quiet period a number of patches have flowed my way so I thought it was worth pushing out a new version. Perhaps the most &amp;quot;important&amp;quot; feature is the edit box flashing and fading from yellow after being updated (like &lt;a class="reference external" href="http://trac.gerf.org/itsalltext"&gt;It's All Text&lt;/a&gt;). It wasn't that hard to do given &lt;a class="reference external" href="http://jquery.com/"&gt;jQuery&lt;/a&gt; and the &lt;a class="reference external" href="http://plugins.jquery.com/project/color"&gt;colour animation plugin&lt;/a&gt; do all the heavy lifting.&lt;/p&gt;
&lt;p&gt;We've added a new hook to the edit-server for pre-edit customisation. If anyone has some nice examples of using the various hooks it would great if you could add examples at the &lt;a class="reference external" href="http://www.emacswiki.org/emacs/Edit_with_Emacs"&gt;emacs wiki&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;As ever the extension can be found at the &lt;a class="reference external" href="https://chrome.google.com/extensions/detail/ljobjlafonikaiipfkggjbhkghgicgoh"&gt;Chrome Extensions site&lt;/a&gt;. Development versions are hosted at &lt;a class="reference external" href="http://github.com/stsquad/emacs_chrome"&gt;github&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Full Change Log&lt;/p&gt;
&lt;p&gt;v1.8&lt;/p&gt;
&lt;p&gt;Extension&lt;/p&gt;
&lt;div class="line-block"&gt;
&lt;div class="line"&gt;* Added option to enable/disable visual edit boxes&lt;/div&gt;
&lt;div class="line"&gt;* Improved feedback as editable elements come in and out of focus&lt;/div&gt;
&lt;div class="line"&gt;* Updated text box will now fade from yellow after an update&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;edit-server.el&lt;/p&gt;
&lt;p&gt;* Added edit-server-start-hook for additional customisation when edit starts&lt;/p&gt;
</content><category term="geek"></category><category term="chrome"></category><category term="chromium"></category><category term="development"></category><category term="elisp"></category><category term="emacs"></category><category term="extension"></category><category term="javascript"></category></entry><entry><title>Update on Emacs Chrome</title><link href="https://www.bennee.com/~alex/blog/2009/12/21/update-on-emacs-chrome/" rel="alternate"></link><published>2009-12-21T13:49:00+00:00</published><updated>2009-12-21T13:49:00+00:00</updated><author><name>alex</name></author><id>tag:www.bennee.com,2009-12-21:/~alex/blog/2009/12/21/update-on-emacs-chrome/</id><summary type="html">&lt;p&gt;In my spare time I've been mostly bashing away at trying to implement an edit server for the Emacs Chrome extension in Emacs Lisp. It's taking longer than I hoped mainly as it's the first time I've ever tried to use the Emacs Lisp Debugger and it's fairly alien compared …&lt;/p&gt;</summary><content type="html">&lt;p&gt;In my spare time I've been mostly bashing away at trying to implement an edit server for the Emacs Chrome extension in Emacs Lisp. It's taking longer than I hoped mainly as it's the first time I've ever tried to use the Emacs Lisp Debugger and it's fairly alien compared to the usual functional GDB's of the world which I'm used to. The &lt;a class="reference external" href="http://github.com/stsquad/emacs_chrome/blob/master/servers/edit_server.el"&gt;current version&lt;/a&gt; should be pushing canned response back to every edit request but for some reason it's not working. Once the basics are working the rest is just cleanup :-)&lt;/p&gt;
&lt;p&gt;In the meantime I've pushed a few additional updates to the repo. The first makes the extension usable on multiple tabs by passing the &amp;quot;port&amp;quot; back to the XmlHttp handler. You would think being an Emacs user I'd be used to the &lt;a class="reference external" href="http://en.wikipedia.org/wiki/First-class_function"&gt;first class function&lt;/a&gt; paradigm by now but it's not something I really get a chance to use much in the day job. I'm not sure if:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
function contentTalking(port)
{
    port.onMessage.addListener(function(msg, port) {
        handleContentMessages(msg,port);
    });
}
&lt;/pre&gt;
&lt;p&gt;is the correct way way to pass parameters from the local function's scope to the listener function's scope but I'm not sure how else you'd do it. Certainly the pattern of declaring functions in-line seems to be very common in the world of Javascript (as well as Emacs Lisp via the &lt;em&gt;lambda ()&lt;/em&gt; directive). If you look at the earlier &lt;a class="reference external" href="http://github.com/stsquad/emacs_chrome/commit/a642737b39f38f36507485588ad22b4dabd6eaf2"&gt;version of the code&lt;/a&gt; you'll see my C habits come through, after all it's just a pointer :-).&lt;/p&gt;
&lt;p&gt;I've also tweaked the pycl.py edit server code to handle running on Python 2.5 as my work box is running a fairly old Hardy Heron. Anyway the latest results of my hacking can, as always be seen &lt;a class="reference external" href="http://github.com/stsquad/emacs_chrome"&gt;on github&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;EDIT TO ADD&lt;/strong&gt;: Well that seems to be working now. I was getting confused in my use of car/cdr which is probably a result of too much &lt;a class="reference external" href="http://en.wikipedia.org/wiki/Forth_(programming_language)"&gt;Forth&lt;/a&gt; when I was younger. They are not equivalent to grabbing the first and next bits off the stack. Specifically cdr returns a list, so you had better munge it to what you want if it's not a list.&lt;/p&gt;
</content><category term="geek"></category><category term="chrome"></category><category term="chromium"></category><category term="emacs"></category><category term="javascript"></category></entry><entry><title>End to End Connectivity</title><link href="https://www.bennee.com/~alex/blog/2009/12/16/end-to-end-connectivity/" rel="alternate"></link><published>2009-12-16T23:22:00+00:00</published><updated>2009-12-16T23:22:00+00:00</updated><author><name>alex</name></author><id>tag:www.bennee.com,2009-12-16:/~alex/blog/2009/12/16/end-to-end-connectivity/</id><summary type="html">&lt;p&gt;We had a slight degree of excitement this evening when we got home. All the power was out and the refrigerating appliances were slowing defrosting. Due to the randomness of the breakers tripping we thought it was the boiler. As it happened it was a earth-neutral leakage that was causing …&lt;/p&gt;</summary><content type="html">&lt;p&gt;We had a slight degree of excitement this evening when we got home. All the power was out and the refrigerating appliances were slowing defrosting. Due to the randomness of the breakers tripping we thought it was the boiler. As it happened it was a earth-neutral leakage that was causing the craziness. Once that was all sorted out I sacked off doing the washing-up to do a little more tweaking.&lt;/p&gt;
&lt;p&gt;I'm almost there with the &lt;a class="reference external" href="http://github.com/stsquad/emacs_chrome"&gt;Chromium extension&lt;/a&gt;. I based it on the work done by &lt;a class="reference external" href="http://www.thegibson.org/blog/archives/689"&gt;David Hilley&lt;/a&gt; and basically further hacked it about to make it work more like &lt;a class="reference external" href="http://trac.gerf.org/itsalltext"&gt;It's All Text&lt;/a&gt; on Firefox. I'm still using David's Python 2.6 shim layer to handle the edit requests until I can get around to implementing an elisp one for Emacs. Don't let my intention to do write one stop any readers from doing so in the meantime should you wish :-).&lt;/p&gt;
&lt;p&gt;It works if you stick to one page, currently it gets confused if you have multiple pages open which have sent edit requests. This is because the xmlcomms.js function which handles farming out the edit requests has a single reply_port parameter which will point to the port of the last page to connect to the master extension. I'll need to come up with a slightly neater solution but I'm fairly crusty on Javascript.&lt;/p&gt;
&lt;p&gt;Hopefully I'll get around to packaging it up properly in the next few days. In the meantime you can run it from a git checkout by pointing the Extensions page at it via &amp;quot;Load Unpacked Extension&amp;quot;.&lt;/p&gt;
&lt;p&gt;Still it's my first Chromium extension so I feel quite proud of myself :-)&lt;/p&gt;
</content><category term="general"></category><category term="chromium"></category><category term="emacs"></category><category term="extensions"></category><category term="house"></category><category term="javascript"></category></entry><entry><title>Chrome and Emacsclient</title><link href="https://www.bennee.com/~alex/blog/2009/12/12/chrome-and-emacsclient/" rel="alternate"></link><published>2009-12-12T13:24:00+00:00</published><updated>2009-12-12T13:24:00+00:00</updated><author><name>alex</name></author><id>tag:www.bennee.com,2009-12-12:/~alex/blog/2009/12/12/chrome-and-emacsclient/</id><summary type="html">&lt;p&gt;I had a number of things planned to do today, one of which was to go pick up some parcels that the local delivery service failed to do. However some workmen started digging up the road opposite my house. As the un-controlled single lane alternating between inbound and outbound traffic …&lt;/p&gt;</summary><content type="html">&lt;p&gt;I had a number of things planned to do today, one of which was to go pick up some parcels that the local delivery service failed to do. However some workmen started digging up the road opposite my house. As the un-controlled single lane alternating between inbound and outbound traffic is right outside my drive I decided I couldn't face the horror and stayed in to tinker.&lt;/p&gt;
&lt;p&gt;I've switched my default browser settings to Chromium on all my machines. It's just so much faster to launch and get around. I've sacrificed the security of NoScript but I'm less worried about Flash on my netbook now as each tab kills any CPU sucking plugins when deleted. The only major problem left is finding an alternative to It's All Text so I don't have to fire up Firefox every time I post something to the web (like this blog entry).&lt;/p&gt;
&lt;p&gt;I decided to have a look into what was involved in getting a Chrome extension running that can call an external editor. I checked the group before I started and stumbled on Dave Hilley's &lt;a class="reference external" href="http://www.thegibson.org/blog/archives/689"&gt;rough cut solution&lt;/a&gt;. It's almost exactly what I need so I've started toying with it.&lt;/p&gt;
&lt;p&gt;Due to the way Chrome works it doesn't seem possible to spawn additional processes from Chrome itself (unless you want to use the NSAPI sledgehammer). Dave's solution is a simple server script that the Chrome extension can make calls to using XMLHttpRequest's. The server is written in Python but my first thought is there is no reason why the local &lt;em&gt;emacs --daemon&lt;/em&gt; couldn't terminate the calls directly. Certainly the &lt;a class="reference external" href="http://www.emacswiki.org/emacs-se/EmacsEchoServer"&gt;example echo server&lt;/a&gt; on the Emacs Wiki doesn't look too complicated to hack up.&lt;/p&gt;
&lt;p&gt;The other thing that could be improved is the detection of text areas. Currently the Javascript just searches the DOM for text areas and selects the first one as a candidate for editing. I'm fairly sure it would be possible to detect either which text area currently has focus or do something more akin to It's All Text and wrap unique &amp;lt;div&amp;gt;'s around each text area and have a edit content button.&lt;/p&gt;
&lt;p&gt;Unfortunately I seem to be having trouble getting the Chrome side to work. Trying to set breakpoints in the extension scripts keeps causing the extension to &amp;quot;crash&amp;quot; so it's hard to follow the sequence and tweak it. I also have to wrap my mind around Chrome's distinction between &amp;quot;content&amp;quot; and extension scripts. Still at least it's something to work from. Of course if anyone else wants to jump in with ideas (or even better a pointer to a better piece of emacs server code for handling XMLHttpRequests) then don't let my stumbling hack attempts hold you back :-)&lt;/p&gt;
</content><category term="geek"></category><category term="chrome"></category><category term="editor"></category><category term="emacs"></category><category term="extensions"></category><category term="javascript"></category></entry></feed>