tag:blogger.com,1999:blog-99100792024-03-07T20:26:14.489+01:00MuuBlogMuuBlog - All things MuuMathias Dahlhttp://www.blogger.com/profile/14367336365716371033noreply@blogger.comBlogger90125tag:blogger.com,1999:blog-9910079.post-19727319656517954052018-01-23T16:24:00.000+01:002018-01-23T21:19:08.800+01:00Make a copy of saved files to another directory<br />
For various reasons I needed to sync files between one folder to another as soon as a certain file was saved in the first folder. I was wondering if Emacs could do this for me, and of course it could :)<br />
<br />
Basically, what I am using below is Emacs' `after-save-hook' together with a list of regular expressions matching files to be "synced" and the target folder to copy the files to. Each time I save a file, the list of regexps will be checked and if there is a match, the file will also be copied to the defined target directory. Neat!<br />
<br />
It works very well so I thought of sharing it in this way. Also, it was a long time since I wrote a blog post here... :)<br />
<br />
Put the following code in your .emacs or init.el file and then customize after-save-file-sync-regexps.<br />
<br />
Enjoy!<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;">;; The Code</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">(defcustom after-save-file-sync-regexps nil</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> "A list of cons cells consisting of two strings. The `car' of</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">each cons cell is the regular expression matching the file(s)</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">that should be copied, and the `cdr' is the target directory."</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> :group 'files</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> :type '(repeat (cons string string)))</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">(defcustom after-save-file-sync-ask-if-overwrite nil</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> "Ask the user before overwriting the destination file.</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">When set to a non-`nil' value, the user will be asked. When</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">`nil', the file will be copied without asking"</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> :group 'files</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> :type 'boolean)</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">(defun after-save-file-sync ()</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> "Sync the current file if it matches one of the regexps.</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">This function will match each regexp in</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">`after-save-file-sync-regexps' against the current file name. If</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">there is a match, the current file will be copied to the</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">configured target directory.</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">If the file already exist target directory, the option</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">`after-save-file-sync-ask-if-overwrite' will control if the file</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">should be written automatically or if the user should be</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">presented with a question.</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">In theory, the same file can be copied to multiple target</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">directories, by configuring multiple regexps that match the same</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">file."</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"> (dolist (file-regexp after-save-file-sync-regexps)</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> (when (string-match (car file-regexp) (buffer-file-name))</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> (let ((directory (file-name-as-directory (cdr file-regexp))))</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> (copy-file (buffer-file-name) directory (if after-save-file-sync-ask-if-overwrite 1 t))</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> (message "Copied file to %s" directory)))))</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">(add-hook 'after-save-hook 'after-save-file-sync)</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">;; The End</span><br />
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
Mathias Dahlhttp://www.blogger.com/profile/14367336365716371033noreply@blogger.com1tag:blogger.com,1999:blog-9910079.post-56387456844701618142016-09-12T23:35:00.000+02:002016-09-12T23:35:03.422+02:00barebones.el - the most basic .emacs file I useToday I decided to write a little bit of documentation for my most basic version of .emacs or init.el that I use. It gets me up to 80% or so of full productivity for basic text editing on a new installation.<br />
<div>
<br /></div>
<div>
It can be found here:</div>
<div>
<br /></div>
<div>
<a href="https://github.com/mathiasdahl/dotemacs">https://github.com/mathiasdahl/dotemacs</a> (download the barebones.el file)</div>
<div>
<br /></div>
<div>
Perhaps someone else will find it useful, as it is or as a simple start for their own Emacs customizations.</div>
<div>
<br /></div>
<div>
Enjoy!</div>
<div>
<br /></div>
Mathias Dahlhttp://www.blogger.com/profile/14367336365716371033noreply@blogger.com0tag:blogger.com,1999:blog-9910079.post-40803597679451628822016-01-04T23:33:00.000+01:002020-07-07T12:52:07.658+02:00Making the JD-Xi mobile by replacing the AC adapter with a USB-battery<h3>
Intro</h3>
<br />
Before Christmas I bought myself a gift, namely a <a href="http://www.roland.com/products/jd-xi/">Roland JD-Xi synthesizer</a>. It looks like this:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://cdn.roland.com/assets/images/products/gallery/jd-xi_top_gal.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="135" src="https://cdn.roland.com/assets/images/products/gallery/jd-xi_top_gal.jpg" width="320" /></a></div>
<br />
<br />
It is my first real synthesizer (I've got some simpler keyboards before) and it's really nice.<br />
<br />
<h3>
The Problem</h3>
<br />
There is one thing that annoys be however and it is the fact that you cannot power it by batteries (I tend to want to use it in different rooms in our apartment, and I have to carry along the AC adapter all the time). The guy at the store tried to explain to me that this was indeed a real synth ("it's not a toy", kind of thing) and those did not get to be powered by batteries, No Sir. Turns out that there are several smaller synths that can be powered by batteries as well as an AC adapter. Oh well...<br />
<br />
<h3>
A solution?</h3>
<br />
At Christmas, I got <a href="http://www.kjell.com/se/sortiment/el/batterier/laddningsbara-batterier/powerpack/linocell-powerbank-2200-mah-svart-p94622">this</a> "USB-battery" (known also as a "powerbank" and many other names):<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://www.kjell.com/se/image/Product_237929sv/full/1" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="200" src="https://www.kjell.com/se/image/Product_237929sv/full/1" width="200" /></a></div>
Looking at the specs of the battery I realized it was very close to what the JD-Xi needed. The AC adapter for the synth delivers around 5.8 V and the manual says the synth uses at most 1000 mA (1 A) of current. The battery spec says it can deliver that, for 5 V (which means the current will be a bit higher since the voltage is lower). I discussed this with a couple of electronically savvy friends and decided I would try and make myself a cable that would take the power from the USB A socket in the battery and "convert" (well...) that to the needed DC plug.<br />
<br />
But let's back up a bit... First I thought I should buy one of these things. I searched eBay and found that <a href="http://www.ebay.com/itm/USB-Male-To-5-5x2-1mm-Plug-DC-Power-Supply-Socket-Extension-Cable-Cord-/281889572330?hash=item41a1ed85ea:g:svEAAOSwYaFWch2E">there is indeed a cable that does <b>almost</b> what I want</a>:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://i.ebayimg.com/images/g/9p0AAOSw5IJWch18/s-l500.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://i.ebayimg.com/images/g/9p0AAOSw5IJWch18/s-l500.jpg" width="320" /></a></div>
<br />
The "only" problem with it is that the poles are wrong on the DC plug side. The adapter from Roland has the <b>+ on the outside</b> and <b>- on the inside</b>, but these thingies has it the other way around as you can see above (you can see it at the top of the insert in the image). Since I do not want to fry my new and shiny synth I had to find another solution. So, I found <a href="http://www.ebay.com/itm/5-5X2-1mm-to-5-5X2-1mm-DC-Power-Plug-tip-Adapter-Converter-Reverse-polarity-/201485015842?hash=item2ee9715b22:m:mKKH62Aa23Z11B0evlSB2BA">this</a> polarity changer:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://i894.photobucket.com/albums/ac150/xinyanwei15/Cable/21-25.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="141" src="https://i894.photobucket.com/albums/ac150/xinyanwei15/Cable/21-25.jpg" width="320" /></a></div>
<br />
<br />
Nice!<br />
<br />
Now... I could order this from eBay and wait the four weeks it takes for the stuff to arrive to Sweden, or... I could make my own cable! (with no need for the extra polarity changer/switcher). And this is exactly what I did today. By the way, if *you*, on the other hand, are happy with that solution, or even happen to find a USB-cable with the right polarity, perhaps you don't need to continue reading :) For others, read on below...<br />
<br />
<h3>
</h3>
<h3>
What you will need</h3>
<div>
<br /></div>
<h4>
</h4>
<h4>
Male DC plug 5.5 x 2.1 mm</h4>
<br />
On eBay <a href="http://www.ebay.com/itm/10Pcs-5-5x2-1mm-Male-Solder-DC-Power-Barrel-Tip-Plug-Jack-Connector-/311497932262?hash=item4886b93de6:g:8fQAAOSwnipWX6YN">I could not find any auction for buying only one</a> but probably your local electronics store will sell you one like these:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://i.ebayimg.com/images/g/8fQAAOSwnipWX6YN/s-l1600.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://i.ebayimg.com/images/g/8fQAAOSwnipWX6YN/s-l1600.jpg" width="320" /></a></div>
Now, be careful here! It should be <b><span style="color: #38761d; font-size: large;">5.5 x 2.1</span><span style="color: red; font-size: large;"> </span></b>mm, <span style="color: red;">NOT 5.5 x 2.5</span>. OK? For some reason, and probably because manufacturers want to lock us in to buy their adapters, there is a gazillion (well...) different plug sizes and with different polarities. Make sure you get the correct one.<br />
<br />
<h4>
</h4>
<h4>
An old USB cable with at least one USB type A male plug (that we will maim)</h4>
<br />
Well, it does not <b>have</b> to be old of course, you can buy a new (cheap) one, You could also buy only the male USB A plug and solder a cable onto that, but I found it more convenient to use an existing one. That way, I only needed to solder the cable in one of the ends.<br />
<br />
The USB type A male plug is this quite big and flat USB plug that we all know and love:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://upload.wikimedia.org/wikipedia/en/thumb/b/bb/Type_A_USB_Connecter_alt.jpg/1006px-Type_A_USB_Connecter_alt.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="244" src="https://upload.wikimedia.org/wikipedia/en/thumb/b/bb/Type_A_USB_Connecter_alt.jpg/1006px-Type_A_USB_Connecter_alt.jpg" width="320" /></a></div>
<br />
The pins in this plug are defined like this:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKyvsX4Xwul1P7gDnJL7WJbTb141K5siKbmxQrqhMlc2-Co2uSxK78JKUXkqqDKzWmX0fLH-ZzqmBHtcvhi7l0cBEUEzZ5qylag1sMjRmFWi2RCt-VTPWIDOe-7SdDaJsz_wio5w/s1600/usb.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="247" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKyvsX4Xwul1P7gDnJL7WJbTb141K5siKbmxQrqhMlc2-Co2uSxK78JKUXkqqDKzWmX0fLH-ZzqmBHtcvhi7l0cBEUEzZ5qylag1sMjRmFWi2RCt-VTPWIDOe-7SdDaJsz_wio5w/s320/usb.png" width="320" /></a></div>
<br />
As you can see above, the power is on pin 1 and 4. 2 and 3 carry the signals.<br />
<br />
<h4>
</h4>
<h4>
Soldering iron, pliers and a voltage meter</h4>
<br />
I will not describe for you how to solder, how to cut wires etc. If you don't know this probably you should buy the stuff from eBay I mentioned above :) I have included some "safety" tips below though, for critical steps.<br />
<br />
<h3>
</h3>
<h3>
What to do</h3>
<br />
First, cut the USB cable to a length that suits you. Think about how you will use it, if you want to keep the battery at the side of the synth or attach it to it in some way (adhesive velcro strips should work nicely for a very mobile approach).<br />
<br />
Carefully strip the outer shell of the end of the cable that you just cut, to reveal the four inner wires/cores of the cable.<br />
<br />
Now you need to strip the inner wires as well. If you are lucky like I was, they are correctly colored (red for +5 V, black for ground/-). To be sure you should check the voltage of the wires to find the two ones that delivers the current (the other two are signal wires). So, if you have a black and red one, strip those first and use the volt meter to check if they are the correct ones (it should say there is around 5 or -5 V, depending on how you measure it), when the plug is inserted into your USB-battery. Make sure none of the small stripped wires touch each other once the plug is inserted in the battery!<br />
<br />
When you know what two wires deliver the current you must also know which is + and which is -. I do it like this: normally the volt meter has one red wire for + and a black for -. Make sure the wires are in the correct place in the volt meter. Then, when you get 5 V (not -5) when you measure the voltage of the USB wires, you know the + one is the one that the red volt meter wire is touching. Make a note of which wire it is.<br />
<br />
Now that you have identified the two USB wires that carry the power, you need to solder them to the DC plug. Before you solder them, put on the outer "shell" of the plug on the cable first (always irritating to notice this afterwards). Make sure you solder the + wire such that it is connected to the outside of the DC plug and that the - wire is connected to the inside/middle. Also make sure the two wires to not touch. If you have a good volt meter you can either use the beep function, if it has one, or use the resistance/Ohm metering to make sure there is no connection between the plus and minus wires (when the cable is not connected in either end).<br />
<br />
I tried to take a photo of my plug:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhyL9g6cahcUs54BVoWqZrj_JZoMqk-Vg0vaYyNT51S_e2XlBzSdW3CjHD6FQgxFi2cyfTCLK7UjkpMgy7C_yXNHBIZeV4yXr4ierq7S8QCq1I9GFKeu2degtkP7mQXZKofAIXN3w/s1600/plug.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="163" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhyL9g6cahcUs54BVoWqZrj_JZoMqk-Vg0vaYyNT51S_e2XlBzSdW3CjHD6FQgxFi2cyfTCLK7UjkpMgy7C_yXNHBIZeV4yXr4ierq7S8QCq1I9GFKeu2degtkP7mQXZKofAIXN3w/s320/plug.png" width="320" /></a></div>
<br />
<br />
Here is the final cable:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSZOTF6c4pL_5HnaI7UExli65FUZStltu1XPa9ZveLgcTEZkjqGOTzbaocqHMgGh8VN_eG7ZcN3Qg3igqJNtBu2qjtbmtwn6hC4jyqkK0VX1wuRsgxACfVbNk26C1x8m5j7vCJ7g/s1600/cable.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="246" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSZOTF6c4pL_5HnaI7UExli65FUZStltu1XPa9ZveLgcTEZkjqGOTzbaocqHMgGh8VN_eG7ZcN3Qg3igqJNtBu2qjtbmtwn6hC4jyqkK0VX1wuRsgxACfVbNk26C1x8m5j7vCJ7g/s320/cable.png" width="320" /></a></div>
<br />
<br />
Now, before you try it out, try to measure that there is indeed a connection between pin 1 and 4 and the inner and outer part of the plug, and that there is no connection where it should not be. When you have tried this, you can input the USB plug into your battery. If nothing smells bad or blows up, probably you did it right :) Now measure with your volt meter if there is 5 V between the inner and outer part of the DC plug. If it is, it is time to try it in the synth - yay!<br />
<br />
For me, it looked like this, this evening:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyIHFTtWyIbM1pB-euc_Ft7qKwIcu-3ZQwmKID97LwXGn7XUwLOQlbwinBbLagXKIH_hLc5lGbRrFza-Tnh4Z_LXzWMXk90zk0tzBE5BPo03aBTFMWZ12RaGDaFGZljwNm2v5iRA/s1600/works.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="154" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyIHFTtWyIbM1pB-euc_Ft7qKwIcu-3ZQwmKID97LwXGn7XUwLOQlbwinBbLagXKIH_hLc5lGbRrFza-Tnh4Z_LXzWMXk90zk0tzBE5BPo03aBTFMWZ12RaGDaFGZljwNm2v5iRA/s320/works.png" width="320" /></a></div>
<br />
Just above the synth you can see my USB-battery happily powering along - hurray! :)<br />
<br />
<h3>
Trivia</h3>
<br />
Before I actually built the final cable I did a lot of measuring of how much current the synth use when powered by the AC adapter. The specs says it should use 1000 mA but it turns out that I could not get it to use more than 0.7 A / 700 mA (for me, it used 0.64 A when turned on and idle and went up to 0.66 A for most of the included demo programs). This means we are probably quite safe since the USB-battery specs say it can deliver 1 A / 1000 mA (since the voltage is lower it HAS to be able to deliver more than 700 mA). When I measured I only had headphones attached to the synth.<br />
<br />
The actual voltage of my AC adapter is 5.8 V.<br />
<br />
<h3>
Disclaimer</h3>
<br />
Since I'm no electronics expert I don't know how this solution will work in the long term, so I cannot make any promises of how stable and safe this hack is. But I feel it should be quite safe.<br />
<br />
<br />
<h3>
Update 2016-01-06</h3>
<div>
<br /></div>
<div>
After trying the small battery out for two days it looks like I get around 2 hours of play using the small 2200 mAh battery. Quite okay in my view. You can buy bigger ones with 5000, 10000 or even 50000 mAh if you need. There are even solar powered ones if you want to be totally off the grid :)</div>
<div>
<br /></div>
<div>
<br />
<h3>
Update 2016-01-17</h3>
<br />
Been using this hack for some weeks now and it works great. Today I even filed away the AC adapter, to be forgotten in a drawer... :) I also did something I planned from the beginning and attached the battery on the back using some Velcro tape:<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjel32yHoTbF-3F9O72H0fvOqxTNQteSZ9A5YorN0xQsuqkuHyUfF-i0s4CYt-gPqm8DCAX6LsYqJhgxEOEZBSdJ8A-DIUZgNH1fcQHkcx39ftTV2_KsuawGYYTiGmA85bz9NyOMA/s1600/jdxibatterymodbackside.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="131" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjel32yHoTbF-3F9O72H0fvOqxTNQteSZ9A5YorN0xQsuqkuHyUfF-i0s4CYt-gPqm8DCAX6LsYqJhgxEOEZBSdJ8A-DIUZgNH1fcQHkcx39ftTV2_KsuawGYYTiGmA85bz9NyOMA/s320/jdxibatterymodbackside.jpg" width="320" /></a></div>
<br />
<br />
Quite neat, and very portable. Being as small as it is, the synth is now very easy to move around the apartment. I just need to have a pair of headphones with me. I can remove the battery and charge it or I can simply plug in a normal micro USB charger to the battery where the synth happens to be right now. To conclude this update I'm very happy with this simple hack and I really feel that the lack of battery operation is not a problem anymore.<br />
<br />
<h3>
Update 2018-03-10</h3>
</div>
<div>
<br />
So, for those who has not read the comments below, I want to highlight here that this hack has some problems powering the JD-Xi when playing some analog tones. See comment below for more details.<br />
<br />
<h3>
Update 2020-07-07</h3>
<br />
For the benefits of others I want to share another solution that I found:<br />
<br />
<a href="http://myvolts.com/product/46110/Power_Supply_and_Chargers/Ripcord_USB_to_5.7V_DC_power_cable_compatible_with_the_Roland_JD-Xi_Synth">http://myvolts.com/product/46110/Power_Supply_and_Chargers/Ripcord_USB_to_5.7V_DC_power_cable_compatible_with_the_Roland_JD-Xi_Synth</a><br />
<br />
If that works, it should be an almost ideal solution. I have tried doing my own such "cable" using both step up (boost) and step down (buck) converters, but I have not had much luck. I think the quality of the converters I have got hold of is not the best as the amount of current increases. In theory it should work though and I hope the makers of the cable I linked to above have made their homework and have a solution that works.<br />
<br />
So, yeah...</div>
<div>
<br /></div>
<div>
Also see the discussion here:</div>
<div>
<br /></div>
<div>
<a href="https://forums.rolandclan.com/viewtopic.php?f=58&t=51406">https://forums.rolandclan.com/viewtopic.php?f=58&t=51406</a></div>
<div>
<br /></div>
Mathias Dahlhttp://www.blogger.com/profile/14367336365716371033noreply@blogger.com0tag:blogger.com,1999:blog-9910079.post-36907866083391472322015-12-22T18:14:00.000+01:002015-12-22T18:14:15.367+01:00Evil Mode hack for a colorful mode line<b>Intro</b><br />
<br />
After trying out Spacemacs for about a week (and failing - too much old configuration to "convert") I am trying out Evil Mode by itself. It goes forward, slowly, step by step.
<br />
<br />
One thing I have been a bit annoyed with was how the different states are visualized. Being a Evil/Vim newbie I want to see, clearly, in which state/mode I am in.
<br />
<br />
Today I decided to do something about it and here is how my Emacs looks now:
<br />
<br />
<b>Normal state</b><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUAzVjTbEXDrcf8QsmZwl429Jl8gUq5dM1_vdsj1tPXyQuad5k6PUCfslPrBA2T5TmYU0GBLWYDK3_MT9T0xBasLxUtIebPOS4S_vSm9CMggro8Bh_IOygi-4yXm1F-fE5rQvXgg/s1600/2015-12-22+18_06_17-Program+Manager.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="41" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUAzVjTbEXDrcf8QsmZwl429Jl8gUq5dM1_vdsj1tPXyQuad5k6PUCfslPrBA2T5TmYU0GBLWYDK3_MT9T0xBasLxUtIebPOS4S_vSm9CMggro8Bh_IOygi-4yXm1F-fE5rQvXgg/s400/2015-12-22+18_06_17-Program+Manager.png" width="400" /></a></div>
<br />
<b>Insert state</b><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgizGXkkGNSqbDcuqtxsjkojcMO1UgcTjra9TzarM0nJvtzit22LFAo83ekSXXk05tycN562sF3G3MKrE2DgsczcAnlMmcHj6hDxpwtjt6c8efKLaZVVC_tbKA54KqBo1jOJxJEjw/s1600/2015-12-22+18_06_34-Program+Manager.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgizGXkkGNSqbDcuqtxsjkojcMO1UgcTjra9TzarM0nJvtzit22LFAo83ekSXXk05tycN562sF3G3MKrE2DgsczcAnlMmcHj6hDxpwtjt6c8efKLaZVVC_tbKA54KqBo1jOJxJEjw/s400/2015-12-22+18_06_34-Program+Manager.png" /></a></div>
<b><br /></b>
<b>Emacs state</b><br />
<b><br /></b>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWfzNdSFdB0SC676yEDwSAuhpGEzf8tfmGvYc7Kw9QrNcKDDnwhzXiMC8h5k24A6qlipzUztBv7DroeaptteaFJcfUpZel6kJzB6Zvc07iIqzhPmWsdADrgNVg7Bh_8OkiCbrQVw/s1600/2015-12-22+18_07_03-Program+Manager.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="42" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWfzNdSFdB0SC676yEDwSAuhpGEzf8tfmGvYc7Kw9QrNcKDDnwhzXiMC8h5k24A6qlipzUztBv7DroeaptteaFJcfUpZel6kJzB6Zvc07iIqzhPmWsdADrgNVg7Bh_8OkiCbrQVw/s400/2015-12-22+18_07_03-Program+Manager.png" width="400" /></a></div>
<b><br /></b>
<b><br /></b>
<b>How it was done</b><br />
<br />
I could not find any good entry points for customizing the mode line with respect to the Evil Mode states, but I found the function (evil-generate-mode-line-tag) that generates the part of the mode line that comes from Evil Mode. I simply made a copy of it and changed it to add also a face attribute to the mode line, and let the face be different depending on the mode.
<br />
<br />
<b>The code</b><br />
<b><br /></b>
Copy the code below and save it in a file called my-evil-hacks.el.<br />
<script src="https://gist.github.com/mathiasdahl/dcb1bcfa2f747d19fff1.js"></script>
<br />
After this you need to make sure to load this file after you have loaded Evil mode for the first time. One way to achieve this is to put the following snippet in your .emacs or init.el file:<br />
<pre>(with-eval-after-load "evil"
(load "my-evil-hacks"))
</pre>
Enjoy!
Mathias Dahlhttp://www.blogger.com/profile/14367336365716371033noreply@blogger.com0tag:blogger.com,1999:blog-9910079.post-66841205207406389542015-08-21T13:47:00.001+02:002015-08-21T13:47:30.451+02:00Something I should have done a long time ago...This is something I should have done a long time ago, to make window creation and manipulation easier in Emacs:<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">(global-set-key (kbd "C-1") 'delete-other-windows)</span><br />
<span style="font-family: Courier New, Courier, monospace;">(global-set-key (kbd "C-2") 'split-window-below)</span><br />
<span style="font-family: Courier New, Courier, monospace;">(global-set-key (kbd "C-3") 'split-window-right)</span><br />
<span style="font-family: Courier New, Courier, monospace;">(global-set-key (kbd "C-0") 'delete-window)</span><br />
<br />
It gives the window manipulating commands I use the most nicer key bindings; just by keeping the Ctrl key pressed and typing away (crazily) on the keys 2 and 3 you can create master pieces of window configurations :)<br />
<br />
I could do this since I realized I seldom or never use these shortcuts to enter a numeric argument. If I need to, I can use a slightly longer key sequence like C-u 1 or M-1 which I have kept (for now...).<br />
<div>
<br /></div>
Perhaps this post will inspire someone else to do the same.<br />
<br />Mathias Dahlhttp://www.blogger.com/profile/14367336365716371033noreply@blogger.com0tag:blogger.com,1999:blog-9910079.post-30400495129913212552015-07-18T18:12:00.001+02:002015-07-18T18:12:18.188+02:00Evaluating elisp expressions from a web page with a custom URI scheme<h2>
Intro</h2>
<br />
Very boring title, eh? :) Well, this is kinda neat...<br />
<br />
Some of you might already know that you can install a custom URI scheme handler in most operating system. Today I did an experiment with that together with Emacs and it turned out quite nicely. I did<br />
this in Windows but it should work in GNU/Linux and OS X as well.<br />
<h2>
<br /></h2>
<h2>
So, what is an URI scheme?</h2>
<br />
Briefly explained, the <a href="https://en.wikipedia.org/wiki/URI_scheme" target="_blank">URI scheme</a> is the "http" part in URLs that we all use everyday. Other examples are "ftp" and "file". The most common ones are handled by your web browser but you can also have another program on your computer handle a certain URI scheme. You can register your own URI schemes as well and in this post we will experiment with a new URI scheme that we name "emacs", for evaluating expressions/executing commands in Emacs.<br />
<h2>
<br /></h2>
<h2>
A warning</h2>
<br />
If you decide to do this, you should be very careful, since it could be a big security risk. Either you let the warning from your web browser always be there to warn you (it can be supressed easily, for a<br />
better user experience) or you register a secret URI scheme (like "myverysecretemacsurischeme") that no one else knows about. Otherwise, bad people can do very nasty things with your computer...<br />
<br />
Okay, with that aside, let's go!<br />
<h2>
<br /></h2>
<h2>
Step 1 - Registering a new URI scheme</h2>
<br />
In Windows you register a new URI scheme in the Windows registry (where else...). Basically you have to create the following key/folder structure under the HKEY_CLASSES_ROOT hive:<br />
<br />
<span style="font-family: Courier New, Courier, monospace;"><name of URI scheme handler></span><br />
<span style="font-family: Courier New, Courier, monospace;"> shell</span><br />
<span style="font-family: Courier New, Courier, monospace;"> open</span><br />
<span style="font-family: Courier New, Courier, monospace;"> command</span><br />
<br />
Lastly, the "command" key's Default value (right hand side) should have the path to the program handling the request, and %1 should be there to, to send in the parameters from the URL to the program.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
If you dare, you can save the following snippet of text as something.reg on your PC, and double click that file. It will add an URI scheme handler for the "emacs" scheme for you. You have to change the path to the program afterwards:<br />
<br />
<blockquote class="tr_bq">
<span style="font-family: Courier New, Courier, monospace;">Windows Registry Editor Version 5.00</span><span style="font-family: Courier New, Courier, monospace;"><br /></span><span style="font-family: Courier New, Courier, monospace;">[HKEY_CLASSES_ROOT\emacs]</span><span style="font-family: Courier New, Courier, monospace;">"URL Protocol"=""</span><span style="font-family: Courier New, Courier, monospace;"><br /></span><span style="font-family: Courier New, Courier, monospace;">[HKEY_CLASSES_ROOT\emacs\shell]</span><span style="font-family: Courier New, Courier, monospace;"><br /></span><span style="font-family: Courier New, Courier, monospace;">[HKEY_CLASSES_ROOT\emacs\shell\open]</span><span style="font-family: Courier New, Courier, monospace;"><br /></span><span style="font-family: Courier New, Courier, monospace;">[HKEY_CLASSES_ROOT\emacs\shell\open\command]</span><span style="font-family: Courier New, Courier, monospace;">@="f:\\Dropbox\\home\\dat\\doc\\src\\bat\\emacsschemehandler.cmd \"%1\""</span></blockquote>
<h2>
<br /></h2>
<h2>
Step 2 - A script to handle the new URI scheme</h2>
<br />
To handle the new URI scheme I created a small cmd file that processes the arguments a bit and then starts emacsclient. It looks like this:<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">REM f:\Dropbox\home\dat\doc\src\bat\emacsschemehandler.cmd</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">@echo off</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">REM Pick up all arguments to the script (in case there are spaces)</span><br />
<span style="font-family: Courier New, Courier, monospace;">set emacscommand=%*</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">REM Stript away the part we don't need...</span><br />
<span style="font-family: Courier New, Courier, monospace;">set emacscommand=%emacscommand:emacs:=%</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">REM Start emacsclient</span><br />
<span style="font-family: Courier New, Courier, monospace;">f:\Dropbox\home\pgm\emacs-24.3\bin\emacsclient -n -e %emacscommand%</span><br />
<br />
Save the script above as a .cmd file on your computer and update the registry to reflect the path to the .cmd file on your system. Also update the path to where your emacsclient is.<br />
<br />
The script is, as can be seen, very simple and basically it just trims off part of the argument from the web browser that we do not need and use the rest as an argument to emacsclient. If you decide to use<br />
another name than "emacs" for your own experiments, make sure to update "emacs:" above to whatever name you picked (plus a colon).<br />
<h2>
<br /></h2>
<h2>
Step 3 - Testing it from a web page</h2>
<br />
Now you only need a web page with some links to try it out. I have provided a couple of links below that you can try right now, if you decided to use the "emacs" URI scheme, that is. The code for the links looks like this (if you do not trust me, view the source code for this blog post):<br />
<blockquote class="tr_bq">
<span style="font-family: Courier New, Courier, monospace;"><a href='emacs:(message """Hello, Emacs!""")'>Hello, Emacs!</a> </span><span style="font-family: Courier New, Courier, monospace;"><a href="emacs:(calendar)">Open Calendar</a></span><span style="font-family: Courier New, Courier, monospace;"><a href="emacs:(info-emacs-manual)">Open the Emacs manual</a></span></blockquote>
Here are the links:<br />
<br />
<a href="emacs:(message """Hello, Emacs!""")">Hello, Emacs!</a><br />
<a href="emacs:(calendar)">Open Calendar</a><br />
<a href="emacs:(info-emacs-manual)">Open the Emacs manual</a><br />
<br />
The triple double quotes in the first example are needed in order to send strings from the cmd file to emacsclient. That is why I used single quotes around the href value, which I normally don't like.<br />
<br />
Now, what do you wait for, try it! Go go go! :)<br />
<h2>
<br /></h2>
<h2>
So, what can this be used for?</h2>
<br />
Well, not sure. For me it was mostly a nice experiment, but I can see some uses for people who work a lot in Emacs but also a lot in a web browser and where they need some kind of interaction between<br />
those. Perhaps something nice can be done together with Org mode and documentation of code, where you view the documentation in a browser but let the user try out code in Emacs, or just jump to a particular section in the Org mode document there. I guess the possibilities are endless, as with most things Emacs... :)<br />
<br />
Hope you enjoyed it!<br />
<br />
C'ya!<br />
<div>
<br /></div>
Mathias Dahlhttp://www.blogger.com/profile/14367336365716371033noreply@blogger.com0tag:blogger.com,1999:blog-9910079.post-2827813101016716392014-10-28T22:38:00.001+01:002014-10-28T22:38:20.882+01:00Cake. Can have. Eat too.A while ago, a friend of mine shared <a href="https://medium.com/p/433852f4b4d1">this</a> informative article about why <a href="https://atom.io/">Atom </a>(a new text editor by the Github team, it seems) cannot replace Vim. The author talks about the very useful composability property of Vi(m) and ends his article with this (do read the complete article though, especially if you are quite new to Vi(m)):<br />
<blockquote class="tr_bq">
<i>A new, shiny, modern editor could one-up Vim by fixing some (or hopefully all) of these issues. But before an editor can replace Vim, it needs to learn everything that 1976 has to teach — not just the lesson of Emacs, but also the lesson of vi.</i></blockquote>
Well, it might not be very "shiny", and "modern" is, I guess, very subjective, but there is already an editor that both have awesome extensibility and, optionally, strict modal behaviour with a "command" mode.<br />
<br />
Which editor it is? <a href="http://www.gnu.org/software/emacs/tour/">Emacs</a>, of course. Just fire up viper-mode, or pick one of the more modern Vi(m) emulation packages like Evil (<a href="http://www.emacswiki.org/emacs/CategoryEmulation">here</a> is a list of different emulation modes for Emacs) and you can now have your cake and eat it too.<br />
<br />
Mmm. Cake.<br />
<br />Mathias Dahlhttp://www.blogger.com/profile/14367336365716371033noreply@blogger.com0tag:blogger.com,1999:blog-9910079.post-10217086492276200852014-10-28T22:36:00.002+01:002014-10-28T22:36:33.800+01:00Keyboard activated favorites menu using "simple menu items"Some time back I wanted to create a keyboard activated menu with one-key access to some favorite commands that I did not want to give one-key bindings in the global keymap and for which I do not want to type the names on the M-x prompt. I was going to write my own command to read the key for the favorite command. However, it turns out Emacs already had more or less what I wanted in the form of <a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Simple-Menu-Items.html">simple menu items</a>.<br />
<br />
I chose to use the "apps" key (on keyboards with two Windows keys, it's the key to the right of the right Windows key, with a little menu symbol on it) since I did not use that for anything in Emacs.<br />
<br />
Here is how to try this little hack out (FYI the key/command combinations below are just examples and not the actual keys and commands I wanted to use):<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">(defvar my-favorties-map (make-sparse-keymap "Favorites"))</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">(define-key global-map (kbd "<apps>") my-favorties-map)</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">(define-key my-favorties-map (kbd "f") </span><br />
<span style="font-family: Courier New, Courier, monospace;"> (cons "Find file"</span><br />
<span style="font-family: Courier New, Courier, monospace;"> 'find-file))</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">(define-key my-favorties-map (kbd "s")</span><br />
<span style="font-family: Courier New, Courier, monospace;"> (cons "Save current buffer"</span><br />
<span style="font-family: Courier New, Courier, monospace;"> 'save-buffer))</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">(define-key my-favorties-map (kbd "i")</span><br />
<span style="font-family: Courier New, Courier, monospace;"> (cons "Kill buffer"</span><br />
<span style="font-family: Courier New, Courier, monospace;"> 'kill-buffer))</span><br />
<br />
After evaluating the above, when typing the "apps" key, the following "menu" will be displayed in the echo minibuffer:<br />
<br />
<span style="font-family: Courier New, Courier, monospace;"> Favorites: i = Kill buffer, Save current buffer, Find file</span><br />
<br />
It does what I want, although it is a little bit peculiar in how it decides for what bindings it will show <span style="font-family: Courier New, Courier, monospace;">X = Command</span> for, and not. Seems that if the name of the menu item/command begins with the same letter/key that is bound to the command, it will not show it.<br />
<br />
So, there it is, an instant little text based menu for executing favorite commands.<br />
<br />
Enjoy!<br />
<div>
<br /></div>
Mathias Dahlhttp://www.blogger.com/profile/14367336365716371033noreply@blogger.com0tag:blogger.com,1999:blog-9910079.post-73044219650950688032014-01-31T19:06:00.002+01:002014-03-15T09:39:54.444+01:00My Emacs launcher makes me happyYeah, just wanted to say that.<br />
<br />
Okay, maybe I should elaborate "a little" (...) Some time ago (more than four years I see now...) I got the idea to combine the power of Emacs and the excellent Emacs package Anything (as it was called then, now Helm) plus a keyboard shortcut into my own <a href="http://en.wikipedia.org/wiki/Comparison_of_desktop_application_launchers">launcher</a>. Before that I had created a couple of simple ones on my own: <a href="http://pyqe.mathiasdahl.se/">PyQe</a>, which I used at home, under Ubuntu (but should in theory work on Windows since it uses basic Python stuff), and another one at work called Quick Execute, which is a small VB hack that turned out to be used by one of my colleagues more than me.<br />
<br />
Anyway...<br />
<br />
So, Emacs, yes! After some fiddling with the necessary elisp needed and dark (but brittle) voodoo magic configuring a bash script that send keystrokes using some tool I cannot remember the name of now, <a href="http://www.emacswiki.org/emacs/AnythingLauncher">Anything Launcher</a> was born. It turned out to be a big hit, to me at least (I don't know about anyone in the universe using it, although there were a few comment in the EmacsWiki page early on.)<br />
<br />
More than four years later I still use it, several times per hour. What do I do with it? Anything! (of course...) I open important web bookmarks with it, I start programs, I open commonly used folders, I start searches in our intranet at work, I find bugs, cases and Jira issues with it and today I added a small hack to create alarms using the Windows scheduler in the background. And everything I do with it is under total control by me. Not only can I "start" predefined list of "things" (bookmarks etc as mentioned earlier), I can interact with it to give arguments to the "commands" in it.<br />
<br />
Just as a more detailed example, if I want to open a bug in our in-house bug tracker, I launch the "Bug Search with prompt" command. It asks me for the bug id and opens the web based bug tracker with the correct bug selected. But, and here comes something that is probably not so easy to do in other configurable launchers (not as easily or quickly I would guess, I am very productive in elisp), it also looks at the clipboard and if it finds something like looks like a bug id, it suggests that as the default input. So, when I get some bug id in some e-mail, I copy that text, open my Emacs launcher (which is what I actually call it on my PC) using a keyboard shortcut, type "bu" to match the bug search command, and then press enter. I then press enter again to accept the bug id it found on the clip board (I could probably make it open the bug directly without me pressing enter, but I like to verify that it is in fact a bug id it found on the clipboard).<br />
<br />
That type of command (written in elisp, of course, with all the powers that gives me) turns out to be a quite common pattern, so I have similar commands for cases (connected to bugs), Jira issues and other things where I can "guess" what stuff is placed on the clipboard. And, again, since I have full control and access to an implementation of the world most powerful programming language (Lisp, in case you missed that), I of course implement a command to create these commands. Just as an example on how it could look, here is that exact "bug search" command, from the control file to the launcher:<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">("Bug Search with prompt" . ("http://urltobugtracker<supersecretinternalurl>?BUG_ID=%s" "Bug ID" "\\w\\([0-9]+\\)\\w"))</supersecretinternalurl></span><br />
<div>
<br /></div>
<div>
That's it! If I want a similar command for some other web site I just give it another URL (with %s as the placeholder for the input I enter), a prompt for me to understand what to do and the last string up there as regexp for matching stuff on clipboard. Bang! I have a new command that lets me open stuff fast.</div>
<div>
<br /></div>
<div>
The control file, by the way, is actually a normal Lisp list, which the launcher then just "reads". The launcher accepts certain type of "commands", from simple strings that are just started like commands in Windows, to lambda expressions which can do everything that Emacs can do, and Emacs can do A LOT together with external tools. The command above, which begins with a command name and contains as the CDR a list with something that looks like an URL, and some more strings, is also a command that the launcher is programmed to support, since it is such a common command type for me.</div>
<div>
<br /></div>
Since people like screenshots, here is just an example on how it could look while trying to launch something matching the string "ra":<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjN9mzO16Se5Cymigec3RW1hcjf0-QQ7zILdbo-LqwnYoI7R2Uuv_klpzlGZCiuFbgONVnEKTk5Zg3FwrxbeDsB1KmVnP1YuLIMdyHRffFDLClyIKLNZ9EPV32kAQleoreHOUDE0A/s1600/emacslauncherscreenshotwindows.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjN9mzO16Se5Cymigec3RW1hcjf0-QQ7zILdbo-LqwnYoI7R2Uuv_klpzlGZCiuFbgONVnEKTk5Zg3FwrxbeDsB1KmVnP1YuLIMdyHRffFDLClyIKLNZ9EPV32kAQleoreHOUDE0A/s1600/emacslauncherscreenshotwindows.png" height="231" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><span style="font-size: small;">(please don't make fun of the colours, they can be changed easily but I happen to like them)</span></td></tr>
</tbody></table>
So, if you also want to reach launcher nirvana, and just happen to have Emacs lying around, have a look at my <a href="http://www.emacswiki.org/emacs/AnythingLauncher">Anything Launcher</a> page at EmacsWiki. The information there is a bit old and there are no instructions for Windows, but if there is enough interest (comments here or on the wiki, or by sending me an e-mail or twitter thing or whatever) I might take the time to write down my exact current setup.<br />
<br />
Oh, and yes. Some people might ask why I am not simply living inside Emacs all day long and starting things from there. Well, that is not far from the truth either, but sometimes I have to leave the safe haven of Emacs and use other scary programs which people (yet) have not integrated in Emacs and which I don't have the time and effort to integrate myself. So, I need it to be something I can start quickly when I am not inside Emacs (where I, of course, also use Anything to find files and buffers).<br />
<div>
<br />
<div>
Happy launching!</div>
</div>
<div>
<br />
<br /></div>
Mathias Dahlhttp://www.blogger.com/profile/14367336365716371033noreply@blogger.com0tag:blogger.com,1999:blog-9910079.post-38810696287661083352014-01-15T18:26:00.003+01:002014-01-16T10:03:20.812+01:00An alternative to the Navigator Filter in IFS Enterprise ExplorerMany know about the Navigator Filter in IFS Enterprise Explorer. It’s the little “(…)” thingy (shortcut key Ctrl+Shift+F) at the top of the IFS Applications navigator. It is a great way to quickly find and open some form.<br />
<br />
Fewer seems to know about (or use anyway) the similar search functionality available in the Home form of IEE in IFS Applications 8 (which, to boot, is in focus when you start IFS Enterprise Explorer). To me, that feature has one big advantage over the Navigator Filter: it finds the form I want to open and lets me open it as easily as with the navigator filter but it does not filter the navigator. Instead it just opens up the right place in the navigator, keeping all other navigator nodes visible.<br />
<br />
For me this is a big win because, most of the time, after having opened the form I wanted, I want to open other forms in the same part of the navigator, but those are often not seen because of the filter (yes, you can clear the filter but that takes more clicks and/or typing). With the search in the home form you get the best of both worlds. …If you really don’t want to filter the navigator items, that is… ;)<br />
<br />
It also has another interesting feature in that the searches are part of the navigation history. This means that if you first used it to search for “doc rev” to find some form, and later use it to find some other form, the first search is still in the navigation history (use the navigation arrows at the top of the screen or Alt+left and Alt+right to navigate).<br />
<br />
To use the search in the Home form properly using the keyboard, press Alt+Home first to get to the home form and focus the search field, then type what you want to search for, and lastly press the Tab key to move focus to the matching entries. There you can use the arrow keys and enter to open the form or folder you like. So, it’s the same number of keystrokes as with the navigator filter, if you are into that kind of thing ;)<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhC4CMnv5inQKnLx2mUiUDjhLLttElQR4Pp0UBOqyGrXUZdlTNvUCaycNF35VHgko457ne67msflabl_74LtAJW8hRhbwuT_4hLpq0Zc_5LCYjNf5qhSHgpP57VxWGZKTuQI2d-CQ/s1600/homescreen.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhC4CMnv5inQKnLx2mUiUDjhLLttElQR4Pp0UBOqyGrXUZdlTNvUCaycNF35VHgko457ne67msflabl_74LtAJW8hRhbwuT_4hLpq0Zc_5LCYjNf5qhSHgpP57VxWGZKTuQI2d-CQ/s400/homescreen.png" height="177" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Search feature in the Home form</td></tr>
</tbody></table>
<br />
I use this much more often than the Navigator Filter. The next time you are about to click the Navigator Filter, try clicking the Home icon instead (or us the shortcut key). Maybe you will like it too?<br />
<br />
Happy searching!<br />
<br />Mathias Dahlhttp://www.blogger.com/profile/14367336365716371033noreply@blogger.com1tag:blogger.com,1999:blog-9910079.post-15019584206137270162013-11-29T23:55:00.001+01:002014-01-15T18:10:23.487+01:00Gäddfil<h2>
Åh så roligt!</h2>
<div>
Skulle skriva en inköpslista nu ikväll och stavade fel när jag skulle skriva gräddfil. Åh så roligt! Jag var bara tvungen att visualisera det.</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEX044ophS-cPe43WLtzj0oPTVr-xSEhMxjAIVEI9XtKBw7pTBQGnr3WrbPSKfzw3F85pf2Vv1cgyaxLAKBMnP-6pIezTd4pS57X1SKFQO_I06mOpwizxroTSELNciNcCRh6sxmQ/s1600/g%C3%A4ddfil.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEX044ophS-cPe43WLtzj0oPTVr-xSEhMxjAIVEI9XtKBw7pTBQGnr3WrbPSKfzw3F85pf2Vv1cgyaxLAKBMnP-6pIezTd4pS57X1SKFQO_I06mOpwizxroTSELNciNcCRh6sxmQ/s1600/g%C3%A4ddfil.png" /></a></div>
<div>
<br /></div>
<div>
Så, nu vet ni hur det skulle se ut med äkta 12-procentig gäddfil i kyldisken.</div>
<div>
<br /></div>
Mathias Dahlhttp://www.blogger.com/profile/14367336365716371033noreply@blogger.com0tag:blogger.com,1999:blog-9910079.post-53529411238546548502013-04-13T23:45:00.001+02:002013-04-13T23:45:25.113+02:00Bookmarklet to open a Youtube video in a new windowSometimes I want to work in some other window while watching a Youtube video. This little <a href="http://en.wikipedia.org/wiki/Bookmarklet">bookmarklet</a> opens a new window/tab with the particular Youtube video on the current page, without any fluff around the video.<br />
<br />
To install it, just drag <a href="javascript:var url=document.location.href;if(url.match('http.?://(www.)?youtube|youtu\.be')){yid=url.split(/v\/|v=|youtu\.be\//)[1].split(/[?&]/)[0];window.open("http://www.youtube.com/v/" + yid + "&hl=en&fs=1");}else{alert("Could not find video ID")}">this link</a> to your bookmarks toolbar, or copy the link and make a new bookmark and paste the link content there. Here is the actual link content:<br />
<br />
<pre>javascript:var url=document.location.href;if(url.match('http.?://(www.)?youtube|youtu\.be')){yid=url.split(/v\/|v=|youtu\.be\//)[1].split(/[?&]/)[0];window.open("http://www.youtube.com/v/" + yid + "&hl=en&fs=1");}else{alert("Could not find video ID")}
</pre>
<br />
(you must include the "javascript:" part)
<br />
<br />
To use it, just click the bookmark when you have a Youtube page opened.<br />
<br />
Enjoy!<br />
<br />Mathias Dahlhttp://www.blogger.com/profile/14367336365716371033noreply@blogger.com0tag:blogger.com,1999:blog-9910079.post-73717913134337252712012-06-27T15:51:00.002+02:002012-06-27T15:51:50.598+02:00Using Emacs and ediff as an external diff toolAt work we have a program where one can configure an external diff tool to diff source code changes. Since I am used to work with ediff in Emacs I wanted to use it from that program as well. I ended up making a wrapper cmd file for it and thought I should share it in case someone else wants to solve the same problem.<br />
<br />
Here is the script:<br />
<br />
<br />
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">@echo off</span><br />
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">REM c:\batfiles\ediff.cmd</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: x-small;">set file1=%1</span><br />
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">set file2=%2</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: x-small;">REM Must convert the backslashes to slashes, otherwise they will be</span><br />
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">REM interpreted as escape characters in the elisp strings. One can</span><br />
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">REM also replace each backlslash with two backslashes to solve the</span><br />
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">REM problem, but I like slashes better. Looks less messy.</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: x-small;">set file1=%file1:\=/%</span><br />
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">set file2=%file2:\=/%</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: x-small;">%PATHTOEMACS%\bin\emacsclientw.exe -n -e "(ediff-files ""%file1%"" ""%file2%"")"</span><br />
<br />
Replace %PATHTOEMACS% above with the real path to where you have installed Emacs. After that <span style="background-color: white;">it's just a matter of selecting this cmd script as the diff tool.</span><br />
<br />
Enjoy!<br />
<br />Mathias Dahlhttp://www.blogger.com/profile/14367336365716371033noreply@blogger.com0tag:blogger.com,1999:blog-9910079.post-64360558835740580612012-05-09T21:19:00.002+02:002012-05-09T21:22:31.307+02:00Världens enklaste mobiltelefonställ?MacGyver - släng dig i väggen!<br />
<br />
När jag stog och diskade ikväll ville jag lyssna på ett TED talk och ställde som vanligt upp telefonen mot ett glas i köksskåpet. Dunk! Skåpshyllan var för hal och telefonen gled bara ned och la sig på rygg. Provade igen. Dunk. Hmm... Det är inte första gången jag gör detta och det är samma visa varje gång. Jag började tänka att jag nog borde köpa ett sånt där bean bag-ställ, eller liknande...<br />
<br />
Men så - Eureka! Vad kan man annars använda för att göra hala saker mindre hala? Gummi... Hmm...<br />
<br />
Gummiband!<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg50SFyoWrYrmke4U6aHH4UT1H8ES5O99uzQ_VFgl-YYj79urIFlhSSNhxPOfmBkeDLQR0jQpms7UtxQD-0SOsts6Uh2pc9wDsc8wfkWFXlTv8kA2dt1c5VHV4Jz_Y25WhYFo_Vtg/s1600/IMG_7995.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="186" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg50SFyoWrYrmke4U6aHH4UT1H8ES5O99uzQ_VFgl-YYj79urIFlhSSNhxPOfmBkeDLQR0jQpms7UtxQD-0SOsts6Uh2pc9wDsc8wfkWFXlTv8kA2dt1c5VHV4Jz_Y25WhYFo_Vtg/s320/IMG_7995.JPG" width="320" /></a></div>
<br />
Funkar hur bra som helst när man har något annat att luta telefonen mot men där underlaget är lite för halt. Och vem har inte ett gummiband eller två med sig i fickan, om inte annat för att göra något trolleritrick.Mathias Dahlhttp://www.blogger.com/profile/14367336365716371033noreply@blogger.com0tag:blogger.com,1999:blog-9910079.post-62324217978458699342012-03-25T08:48:00.003+02:002012-03-25T08:53:41.515+02:00Vad är en smidig deg?Jag blir vansinnig! Eller ja, nästan i alla fall... I varenda recept på bröd jag läst står det att man skall arbeta degen smidig eller knåda degen smidig eller arbeta till en smidig deg (skrev lite olika varianter på uttrycken här så att de som har samma undringar som jag skall hitta denna sida). <div><br /></div><div>Det står dock aldrig vad "en smidig deg" är. Troligen är detta något så allmänt känt att man aldrig förklarar vad det är, och var man inte tillräckligt uppmärksam på hemkunskapen verkar det som att man får skylla sig själv...<div><br /></div><div>Nu tror jag att jag vet vad det är i alla fall. Degen är smidig när den precis släpper från bunken, dvs när den gått från att vara superklibbig till klibbig till hanterbar. Då har du fått en smidig deg.</div><div><br /></div><div>Så, nu vet ni det.</div><div><br /></div></div>Mathias Dahlhttp://www.blogger.com/profile/14367336365716371033noreply@blogger.com1tag:blogger.com,1999:blog-9910079.post-56536395619546128552010-11-04T10:27:00.005+01:002010-11-04T13:17:59.043+01:00Går det att baka bröd med gammal torrjäst?Ja, det är frågan. Jag skulle precis till att baka lite goda grahamsbullar till en fika med en kompis i kväll och var ganska säker på att jag hade torrjäst hemma. Det var bara ett litet problem: den var gammal. Bäst före-datum är juli 2010 och nu är vi inne i november. Skulle det fungera? Så. Klart. Gott mos, som vi säger här nere.Mathias Dahlhttp://www.blogger.com/profile/14367336365716371033noreply@blogger.com0tag:blogger.com,1999:blog-9910079.post-2131288223098397832010-10-20T23:42:00.010+02:002010-10-21T00:08:00.223+02:00Slight change of default Ubuntu 10.10 themeTonight I got sick of one tiny detail in the default Ubuntu theme.<br /><br />First some background: I use the task panel a lot not only to select another application but also to minimize the task/application currently in focus. I do this because I think it is easier (and it *is* easier, read up on Fitt's Law for more details) to click the quite large task icon then it is to click the minimize button of the current window.<br /><br />Now, the problem is that in the current default theme (at least I think it is the default, it is dark brow/grey with some purple stuff here and there and orange icons) you cannot easily and quickly see which of the tasks in the task panel is the selected one, if any. If you look carefully you will of course see it, but the difference in look/color is not much from the unselected ones. So I thought maybe I could figure out how to change it.<br /><br />I was prepared for a long journey but just a few "locate" and "find" I was able to correctly guess what images that are used, and they are placed under<span class="Apple-style-span" > /usr/share/themes/Ambiance/gtk-2.0/apps/img</span>. The image in question is panel-button-active.png. I used sudo, chgrp and chmod to grant myself write access to that image (could have done the editing using sudo as well but I rather like to use my normal user) and then using The Gimp I simply filled the image with a new color that matched one of the purple ones already in use. I then had to force a reload of the panel and it was easy: $ gnome-panel --replace (you don't need to use sudo here). Voila! My new image is now used for the active task and it is much easier to see which task is active. Granted, it's not as nice looking but for me it is worth more to see it clearly.<br /><br />After that change I discovered that I also wanted to change the hover image so that the purple image was not replaced by a brown/grey one. That one is named panel-button-hover.png and I used the same process as above to change that.<br /><br />I have included the two changed images in this post in case you want to try it out too.<br /><br />Enjoy!<br /><br />panel-button-active.png:<br /><br /><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9zYWXWzAffvGgL1QkjsrmJsHijeNUtffk3G2oXm9kijB8jifkLQM_Z8uGoJVVGLsT249dbL-1utvCF4CI9nY_Pv_ABVG-Ox9GAoEdFnCgwNFOWMDmubgDdbJ5ib6Zayt2Kr8htA/s320/panel-button-active.png" style="cursor:pointer; cursor:hand;width: 185px; height: 24px;" border="0" alt="" id="BLOGGER_PHOTO_ID_5530251480592419522" /><br /><br />panel-button-hover.png:<br /><br /><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhR9NUDSITinPOVLm5QJiGZ14-tGqnwjs7z2IRHp5oprk2wQa9s8s2tf4g-saq2RyLEDFUfA7IONo9vUILtSMMxFpq3quLg5ofcLvsSRVOZIv7jbt7a2JRF7fQ8z876xspnL6cblA/s320/panel-button-hover.png" style="cursor:pointer; cursor:hand;width: 185px; height: 24px;" border="0" alt="" id="BLOGGER_PHOTO_ID_5530251921912344450" />Mathias Dahlhttp://www.blogger.com/profile/14367336365716371033noreply@blogger.com0tag:blogger.com,1999:blog-9910079.post-66200643561157836692010-06-27T07:33:00.001+02:002010-06-27T07:34:29.026+02:00KotänkbartNytt ord: kotänkbart - sånt som kor går och funderar på.Mathias Dahlhttp://www.blogger.com/profile/14367336365716371033noreply@blogger.com0tag:blogger.com,1999:blog-9910079.post-23930586980110919742010-06-26T23:31:00.003+02:002010-06-26T23:40:32.674+02:00List of Sony Ericsson Xperia X10 Mini hardware sensorsI tried to find a list of all hardware sensors that the SonyEricsson Xperia X10 Mini has and could not find any information about it, so I delved down into the Android Javadoc and wrote a small program to list them all. I am posting the list here in case someone else might have use for it. <br /><br />First comes the name/ID/model and then the maker:<br /><br />AK8973 Orientation - Asahi Kasei Corp.<br />AK8973 Orientation Raw - Asahi Kasei Corp.<br />AK8973 Magnetic - Asahi Kasei Corp.<br />AK8973 Temperature - Asahi Kasei Corp.<br />BMA150 accelerometer - Bosch Sensortec GmbH<br />APDS9700 Proximity - SEMC<br />MSM Lightsensor - SEMC<br /><br />The question is now what exactly can be done with them? For example, for what do I use the magnetic sensor? I downloaded a compass program but that seemed to only use the GPS.<br /><br />Anyway, enjoy!Mathias Dahlhttp://www.blogger.com/profile/14367336365716371033noreply@blogger.com1tag:blogger.com,1999:blog-9910079.post-85595027768409937272009-10-01T17:46:00.008+02:002009-10-01T18:21:44.627+02:00Bash completion for playing movieSometimes I play movies (mostly tv series) on my Ubuntu installation. The movie player I have got used to the most, and which can handle pretty much everything I throw at it, is mplayer.<br /><br />I mainly use mplayer from the command line (I have GUIs for it installed too but don't use them much) and about a week ago I got tired of having to cd to my movie folder to play movies, or to type long path names, each time I wanted to watch a movie. I knew that bash has programmable completion so I set out to see how I could use that to get tab completion for all my movies regardless of where I am in the file system.<br /><br />Getting it to work was a small adventure, let me tell you that. I started by looking under /etc/bash_completion and borrowed some snippets from there but soon I needed help so I went over to the gnu.bash.bug newsgroup <a href="http://groups.google.com/group/gnu.bash.bug/browse_thread/thread/b099c6e674991c6d#">and started a new thread</a>.<br /><br />It took a while to understand how it all fits together. Bash is very competent and the manual has a lot of details but in my opinion it is very terse and does not explain things in more detail that is really really necessary. If you don't grok everything about all the expansion and completion facilities it can be hard to dive in and get something like this working.<br /><br />Anyway, with a lot of help I finally got it to work, and really well I must say. The main issues I had had to do with how to handle space and other metacharacters in file names, quoting/escaping them the correct way etc, and how to handle movie files in subfolders.<br /><br />The solution concists of two parts: the programmable completion, consisting of one bash function and an accompanying call to the complete command, and a small bash script to start mplayer.<br /><br />The bash function is responsible for finding all movie files and match them against the current user input. The work horse is the find program, for finding the movie files, in combination with grep, to filter the matches (it can theoretically be done using find only but then the solution does not become exactly how I want it).<br /><br />The bash script is more or less just a wrapper around the mplayer program but it also prepends the movie folder path to the argument sent in. You will understand later.<br /><br />Here is the bash function:<br /><pre>_mm() {<br /> local cur files<br /> COMPREPLY=()<br /> cur="${COMP_WORDS[COMP_CWORD]}"<br /><br /> if [ "$1" == "substring" ]; then<br /> pattern="${cur}"<br /> else<br /> pattern="^${cur}"<br /> fi<br /><br /> files=$(find /home/mathias/Videos/movies/ -iname "*.avi" -type f -printf "%P\n" | grep -i "$pattern" | while read file; do<br /> printf "%q\n" "$file"<br /> done)<br /> local IFS=$'\n'<br /> COMPREPLY=(${files})<br />}<br /><br />_ms() {<br /> _mm "substring"<br />}</pre><br />It's not very complicated once you get it working but the devil are in the details so I should comment it anyway:<br /><br />First we set up some local variables. <br /><br />Next we make sure the magic COMPREPLY array is made empty before we fill it with values used for the completion.<br /><br />After that we need to get hold of the currently entered text on the command line, if any, and place this into the cur variable.<br /><br />Next up is an if statement that will build the pattern to look for. This is not strictly needed but I wanted to be able to have one command that did prefix matching and one for substring matching, i.e. matching the beginning or anywhere in file names, respectively.<br /><br />The pattern is finally used in the call to grep which filters all files found by find. I made it simple and only pick out avi files, since all my movies are in avi format. The P in the format string makes find skip printing the leading part of the path (otherwise that would be part of all completion candidates). The last part of the pipe is for shell quoting/escaping spaces and other shell metacharacters.<br /><br />In the files variable all matching file names are separated by a newline so before we let the shell split it into array elements to be placed in COMPREPLY we must change the IFS field separator to a newline.<br /><br />The last line in the function puts the completion candidates in COMPREPLY from where bash then reads it when the user asks to complete filenames. <br /><br />The helper function _ms is used to get a substring matching version of the completion.<br /><br />Next comes the calls to the complete command which is what activates the completion for various commands. The -F parameter says to get the completion candodates by calling a function and the _mm is the name of the function. The last parameter is the command name for which we want to add the completion:<br /><pre>complete -F _mm mp<br />complete -F _mm mm<br />complete -F _ms ms</pre><br />Both the mp and ms commands are just symlinks to the main script, mm. They are only needed to control the two variants of completion (substring and prefix). I put both the functions and calls to complete in a file called ~/bin/bash_completion, together with other completion stuff, and source this file from my ~/.bashrc, like so:<br /><pre>. ~/bin/bash_completion</pre> The mm command, a bash script which I also put in my ~/bin folder, is very simple and looks like this:<br /><pre>#!/bin/bash<br />mplayer "/home/mathias/Videos/movies/$1"</pre> The reason we prefix the filename with the root movie folder is that the completion function is made not to include it, for ease of typing.<br /><br />Okay, I hope this can be as useful to others as it is to me. The technique, of course, could be applied to any similar needs you might have.<br /><br />If you like, check out the discussion I started over at gnu.bash.bug, <br /><a href="http://groups.google.com/group/gnu.bash.bug/browse_thread/thread/b099c6e674991c6d#">it contains a lot more details which made this hack of mine end up the way it did</a><br /><br />Happy completing!Mathias Dahlhttp://www.blogger.com/profile/14367336365716371033noreply@blogger.com0tag:blogger.com,1999:blog-9910079.post-41691320193545660402009-03-13T13:18:00.001+01:002009-03-13T13:18:07.699+01:00Dagens Klibb<div xmlns="http://www.w3.org/1999/xhtml"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0jcsErh4dg0YImFCudBE37c9eajx5K5VKz1QJV5PLnqluukJZKx4NcAFKg-cEdj5IdhzmG9rRf9btt4nt5nqBxPRFbc2YedjtA38rucCnAw0f9jH5aYzJ7nkoPfsy4USYgG7uJQ/s1600-h/image-upload-18-787208.jpg"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0jcsErh4dg0YImFCudBE37c9eajx5K5VKz1QJV5PLnqluukJZKx4NcAFKg-cEdj5IdhzmG9rRf9btt4nt5nqBxPRFbc2YedjtA38rucCnAw0f9jH5aYzJ7nkoPfsy4USYgG7uJQ/s320/image-upload-18-787208.jpg"/></a><br /><span>Vad är detta tro?</span><br /></div>Mathias Dahlhttp://www.blogger.com/profile/14367336365716371033noreply@blogger.com0tag:blogger.com,1999:blog-9910079.post-36776395986103064812009-03-04T14:03:00.001+01:002009-03-04T14:03:16.118+01:00Mölndals brantaste backe<div xmlns="http://www.w3.org/1999/xhtml"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizLWmYod4TL4uxO-0_jjh3xgnIIIEtcHIbrJiw118J-TsyD2jREVyXsHs0Zl9oZKntImEn6X4tSqvDKk7JkvjX1XCHoWoV0qgcFuKpAnFAPZaMEEB-dKEqEI0kOaWS3st5rmdXlw/s1600-h/image-upload-173-795678.jpg"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizLWmYod4TL4uxO-0_jjh3xgnIIIEtcHIbrJiw118J-TsyD2jREVyXsHs0Zl9oZKntImEn6X4tSqvDKk7JkvjX1XCHoWoV0qgcFuKpAnFAPZaMEEB-dKEqEI0kOaWS3st5rmdXlw/s320/image-upload-173-795678.jpg"/></a><br /><span>Uppför den här backen går jag med Emil en gång i veckan. Den är tuff, MINST 90 grader lutning, vilket både Wallén och Anders kan intyga. -- MaDa</span><br /></div>Mathias Dahlhttp://www.blogger.com/profile/14367336365716371033noreply@blogger.com0tag:blogger.com,1999:blog-9910079.post-61307381546970892042009-02-08T09:42:00.003+01:002009-02-09T00:09:09.677+01:00Snor<div xmlns="http://www.w3.org/1999/xhtml"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilCRdYm56tjJ80ah1mzqtAvqhikWx_tRt0HW2S-WRpq2UXUakqdJkqIY55rPwjMb04OMy_Ze_XOsyLeapqCRgjDcK1cpV0iBivmq-rLN4I9b6aJRZHzqQo4RsGuAf26Tv8ewCMfg/s1600-h/image-upload-148-752647.jpg"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilCRdYm56tjJ80ah1mzqtAvqhikWx_tRt0HW2S-WRpq2UXUakqdJkqIY55rPwjMb04OMy_Ze_XOsyLeapqCRgjDcK1cpV0iBivmq-rLN4I9b6aJRZHzqQo4RsGuAf26Tv8ewCMfg/s320/image-upload-148-752647.jpg"/></a><br /><span>Emilsnor och slem på tröjan...</span><br /></div>Mathias Dahlhttp://www.blogger.com/profile/14367336365716371033noreply@blogger.com0tag:blogger.com,1999:blog-9910079.post-22662589412819760262009-01-29T15:35:00.002+01:002009-02-09T00:51:30.828+01:00Gröna blad<div xmlns="http://www.w3.org/1999/xhtml"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCwKCBEisWdaTDmsVY0V6LYMainA3lzCxHHzAQ_u1sMbUL8pEQuZkpcR9eJLLHQrJb6jE7P2d-THA0GKHS-UDqXz94nHUy8rbHpXz2PsqBbywy1q8b4XrZuXlkB8M8RBmAorebIg/s1600-h/image-upload-72-749165.jpg"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCwKCBEisWdaTDmsVY0V6LYMainA3lzCxHHzAQ_u1sMbUL8pEQuZkpcR9eJLLHQrJb6jE7P2d-THA0GKHS-UDqXz94nHUy8rbHpXz2PsqBbywy1q8b4XrZuXlkB8M8RBmAorebIg/s320/image-upload-72-749165.jpg"/></a><br /><span>Ute i skogen i dag hittade jag och Emil en buske med alldeles gröna fina blad. Nu undrar jag: vad är det för en buske och varför har bladen klarat sig?</span><br /></div>Mathias Dahlhttp://www.blogger.com/profile/14367336365716371033noreply@blogger.com0tag:blogger.com,1999:blog-9910079.post-73681321688190118022009-01-10T14:16:00.003+01:002009-01-10T14:34:34.326+01:00Creating multiple shells in EmacsSometimes you want to have more than one shell going in Emacs. If you have tried that you know it does not work like you would have expected - you end up in the current shell buffer instead of getting a new one. So I created this small hack:<br /><br /><pre><br />(defun new-shell (name)<br /> "Start a shell with name NAME, or a generated name if empty.<br />Returns the name of the new shell."<br /> (interactive "sName: ")<br /> (let ((shell-name <br /> (if (not (string= "" name))<br /> (concat "*shell*<" name ">")<br /> (generate-new-buffer-name "*shell*"))))<br /> (shell shell-name)<br /> shell-name))<br /></pre><br /><br />It prompts for a name for a new shell buffer. If none is given it will generate one for you. Naming shell buffers can be useful when you are doing a certain kind of work in a certain buffer and want to switch to that buffer easily using parts of the name.<br /><br />Enjoy!Mathias Dahlhttp://www.blogger.com/profile/14367336365716371033noreply@blogger.com0