Wolfmans Howlings

A programmers Blog about Ruby, Rails and a few other issues

Epsilon Programmers Editor

Posted by Jim Morris Sun, 01 Oct 2006 00:20:00 GMT

I use Lugarus excellent Epsilon Editor for most of my programming editing needs, on Win32 and Linux.

(An exception is for Java programming where I use Eclipse).

I have spent some time writing extensions to Epsilon to handle Ruby and Rails programming, inspired mostly by Textmate on Mac/OSX, and Eclipse for Java. I tried using the Eclipse for Ruby, but I was very disappointed, also the developers have made some design decisions I can't live with (like no auto indent after opening braces etc).

I have tried Komodo Pro as described here.

OK the Epsilon editor is not free, it costs about $250 ($99 for an upgrade) which includes all platforms, and the license lets you use it on your Laptop and Desktop, in fact you can use any version of Epsilon on up to four computers you own. The result is a professional, solid, stable Editor, that is what you get when you pay for something. (This editor has been around at least 20 years, which is when I started using it on DOS!). In addition to running as an X Windows program and a console program on windows and Linux it also runs on Mac OS X, FreeBSD, OS/2 and DOS.

The Editor is an Emacs clone out of the box, it also has CUA and Brief emulations (well key bindings). The best feature IMHO is the fact you get most of the source code for the editor which is written in its own c-like language called eel. This makes it much easier to write extensions and customizations for the editor if you are familiar with C. (I never could wrap my brain around Lisp which is why I don't use GNU Emacs). It also runs in console mode as well as windows mode, which is useful if you have to login via ssh etc to edit files.

Seeing how every programmer has their own ideas of what an editor should do and its look and feel, easy customization is crucial.

The extensions I have written for Epsilon are all freely available, as are extensions written by other users. (Various language modes, template extensions, SCM extensions etc).

In the past I wrote a java help extension that tried to do context sensitive help, this worked OK but not as well as Eclipse.

Recently I wrote a bunch of extensions for Ruby and Rails, thanks to the ruby mode extension written by Timothy Byrd (available on Lugaru's download page) I was able to get syntax highlighting and formatting already done. I added some simple help extensions, a snippet facility (ala Textmate), and some convenience actions for Rails development. I also extended Timothy's ruby mode extension with something that completes the #{} when # is typed in a string. (I first saw this in Textmate and hated it, but it grew on me, until I had to have it on Linux). I have avoided the temptation to also do the automatic closing of { ( " etc that you find in Textmate because I still hate those, but they are easy to do using the same technique I used for #{}.

I've also added the ability to run the current buffer through the ruby interpreter and show the results in a pop up window, also to run a specific unit test if the file is a Ruby test case.

The key strokes any command uses is easily modified, as well as the colors used for syntax highlighting.

The version of ruby_mode.e on Lugarus site does not currently have the latest changes I have made, so it can be downloaded from the link below...

The other extensions can also be downloaded from my site...

These can be installed by copying them to your ~/.epsilon folder, and adding a load line to your einit.ecm file, see the comments in the source file. The snippets should be un-tarred into the ~/.epsilon folder. The README explains how to load them.

eg add this to your einit.ecm file:

(load-eel-from-path "ruby_mode.e" 2)
(load-eel-from-path "rubyhelp.e" 2)
(load-eel-from-path "snippets.e" 2)
(load-eel-from-path "rename_in_place.e" 2)

Also here are the color codes I use for ruby_mode, these are designed by Timothy: (Change the window-black to whatever color set you are using)

&window-black color class for ruby-brace: [0x725CEB on 0x0]
&window-black color class for ruby-class: [0xD9D240 on 0x0]
&window-black color class for ruby-comment: [0xC0C0C0 on 0x0]
&window-black color class for ruby-global: [0xFFB737 on 0x0]
&window-black color class for ruby-keyword: [0xFF8000 on 0x0]
&window-black color class for ruby-number: [0xFF9090 on 0x0]
&window-black color class for ruby-punctuation: yellow on black
&window-black color class for ruby-regexp: [0x007FFF on 0x0]
&window-black color class for ruby-shell-cmd: [0x8FFF2F on 0x0]
&window-black color class for ruby-shell-subst: [0x8FFF8F on 0x0]
&window-black color class for ruby-str-subst: [0xFFC0C8 on 0x0]
&window-black color class for ruby-string: cyan on black
&window-black color class for ruby-perl-var: red on black

Although you can browse for files that epsilon has currently open and switch between these buffers, the method is fairly crude by todays standards of tabbed windows etc, so I wrote a little graphical helper called project_browser.rb that uses the fox window toolkit. It just shows a tree of the directory it was given on the command line, and if you click on any of the files they open in the epsilon window. This is a lot like the project browser windows you find in Textmate, Eclipse and others. You need to install fox version 1.4 and the fox14 gem too to use this. It also allows you to exclude files and directories from display in the tree, by putting a YAML file called .proj_exclude.yaml in the project directory, I'll document this further if there is any interest in it (Leave a comment if you are interested). It allows multiple project directories to be open and shows them in tabs at the top. I'm also working on integrating subversion into it. It could also be adapted to work with virtually any editor that allows files to be sent to the editor by a separate process.

project browser

Posted in , ,  | Tags , , , ,  | no comments | no trackbacks

Getting f-spot to upload to flickr on KUbuntu

Posted by Jim Morris Mon, 28 Aug 2006 03:29:00 GMT

f-spot is a good photo importer and organizer, but it is a gnome application. When I installed it on KUbuntu, which uses KDE, using aptitude install f-spot it worked ok, except I got the following error when I tried to send my photos to flickr.

GLib.GException: There is no default action associated with this location

After some Googling I found this solution...

> gconftool-2 --set --type=string /desktop/gnome/url-handlers/http/command '/opt/firefox/firefox %s'

my Firefox is in /opt/firefox, so you may have to change that path, or even point to a different browser.

Make sure gconftool-2 is installed (it was on mine after installing a bunch of gnome apps).

It sets the default browser, and after this I was able to upload to flickr.

Posted in  | Tags , ,  | no comments | no trackbacks

Switching to KUbuntu from Redhat 9

Posted by Jim Morris Mon, 03 Jul 2006 20:07:00 GMT

OK it was time I upgraded my main development workstation from a highly modified Redhat 9 to something more up to date that actually gets security updates and has a good package manager.

I have been using Ubuntu for my servers for some time, and like the package management, but I am used to KDE now and don't really want to switch to Gnome on my workstation. So I decided to try to upgrade to KUbuntu.

Upgrading the actual Redhat 9 seemed a bad move, so I bought a new 400GB drive (the Seagate ST3400633A, as its quiet and Fry's had it in sale for $118). The plan was to do a fresh install of KUbuntu onto that then copy over the stuff I need. After about 2 years of installing stuff and upgrading the kernel manually on the Redhat 9, this was going to be quite a task.

First up Dual monitors.

Unlike Windows and Mac OSX this doesn't "just work". On my RH9 system, I had the proprietary ATI driver fglrx, running an old XFree86 Version 4.3.0 server, and was only able to get two KDE desktops side by side but completely separate, this was OK, but part of the upgrade I wanted to be able to drag windows across monitors just like on Windows and OSX. My Video card was an ATI with a DVI and VGA connector which can both be ised at the same time.

After Googling it turned out some people found this easy and some hard, I finally got it to work, by installing the fglrx using aptitude install, getting the aticonfig to set up dual monitors, then telling KDE I had dual monitors. Seems you need to do both, oh and you need to actually power cycle between the changes to xorg.conf. Initially if I did not do the KDE setup step I got two screens but the cursor and windows were stuck on the first screen and KDE would not let the cursor or windows into the second screen. What seems to have happened is the latter step added the option "Xinerama", even though everything I read said the fglrx drivers didn't need that option. (BTW it seemed to work on the standard Gnome version of Ubuntu without telling Gnome anything).

So following:

> sudo aticonfig --initial --dtop=horizontal

I ran the System/Setup selected the monitor panel and set it to dual screen. then rebooted.

Ending up with this xorg.conf...

Section "ServerLayout"
  Identifier "Default Layout"
  screen 0 "Primary Screen" 0 0
  screen 1 "screen1" rightof "Primary Screen"
  InputDevice "Mouse0" "CorePointer"
  InputDevice "Keyboard0" "CoreKeyboard"
  InputDevice "DevInputMice" "AlwaysCore"
EndSection

Section "Files"

  # path to defoma fonts
  FontPath "/usr/share/X11/fonts/misc"
  FontPath "/usr/share/X11/fonts/cyrillic"
  FontPath "/usr/share/X11/fonts/100dpi/:unscaled"
  FontPath "/usr/share/X11/fonts/75dpi/:unscaled"
  FontPath "/usr/share/X11/fonts/Type1"
  FontPath "/usr/share/X11/fonts/100dpi"
  FontPath "/usr/share/X11/fonts/75dpi"
  FontPath "/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType"
EndSection

Section "Module"
  Load "i2c"
  Load "bitmap"
  Load "ddc"
  Load "extmod"
  Load "freetype"
  Load "int10"
  Load "type1"
  Load "vbe"
  load "glx"
  load "dbe"
  load "v4l"
EndSection

Section "InputDevice"
  Identifier "Keyboard0"
  Driver "kbd"
  option "XkbModel" "pc105"
  option "XkbLayout" "us"
  option "XkbRules" "xorg"
EndSection

Section "InputDevice"
  Identifier "Mouse0"
  Driver "mouse"
  option "Device" "/dev/input/mice"
  option "Protocol" "IMPS/2"
  option "Emulate3Buttons" "no"
  option "ZAxisMapping" "4 5"
EndSection

Section "InputDevice"
  Identifier "DevInputMice"
  Driver "mouse"
  option "Protocol" "IMPS/2"
  option "Device" "/dev/input/mice"
  option "ZAxisMapping" "4 5"
  option "Emulate3Buttons" "no"
EndSection

Section "Monitor"
  identifier "primarymonitor"
  vendorname "NEC"
  modelname "NEC MultiSync LCD1860NX (Analog)"
  HorizSync 31.0-82.0
  VertRefresh 55.0-85.0
  modeline  "1280x1024@60" 108.0 1280 1328 1440 1688 1024 1025 1028 1066 +hsync +vsync
  gamma 1.0
EndSection

Section "Device"
  identifier "Ati Radeon 9800 Pro 0"
  boardname "ati"
  busid "PCI:1:0:0"
  driver "fglrx"
  screen 0
EndSection

Section "Screen"
  Identifier "Primary Screen"
  Device "Ati Radeon 9800 Pro 0"
  Monitor "primarymonitor"
  DefaultDepth 24
  SubSection "Display"
    depth 24
    modes "1280x1024@60"
  EndSubSection
EndSection

Section "DRI"
  Mode 0666
EndSection

Section "device" #
  identifier "device1"
  boardname "ati"
  busid "PCI:1:0:0"
  driver "fglrx"
  screen 1
EndSection

Section "screen" #
  identifier "screen1"
  device "device1"
  defaultdepth 24
  monitor "monitor1"
  SubSection "Display"
    depth 24
    modes "1280x1024@60"
  EndSubSection
EndSection

Section "monitor" #
  identifier "monitor1"
  vendorname "Plug 'n' Play"
  modelname "Plug 'n' Play"
  modeline  "1280x1024@60" 108.0 1280 1328 1440 1688 1024 1025 1028 1066 +hsync +vsync
  gamma 1.0
EndSection

Section "ServerFlags"
  option "Xinerama" "true"
EndSection

I had to hand edit the file to delete the duplicate monitor and screen definitions that were in there.

Installing Ruby, Gems and fxruby

I installed Ruby using the package manager, its just a matter of making sure you select everything you need. The biggest problem I had was getting fxruby working (1.4.6 version). I installed fox1.4 from the package manager then loaded the fxruby gem using gem install. However none of my ruby progs using fox14 would work, they reported they couldn't load fox14. After much installing and uninstalling, the result was I found a bug in the fxruby gem install, the Makefile calls make clean after building the fox14.so, and happily deletes it after building it.. Duh!! I need to report that to the fxruby maintainer, it burnt about 2 hours of my time. What I did to fix it was simply...

> cd /usr/lib/ruby/gems/1.8/gems/fxruby-1.4.6/ext/fox14
> make

Update, according to the maintainer this is a bug in the latest release of gems 0.9.0

(BTW I wish Debian/Ubuntu put ruby in /usr/local where it belongs!)

Thunderbird setup

I simply copied the .thunderbird directory over to my new home, and everything seemed to work ok, except clicking on links in my email no longer worked. I had to edit my ~/.thunderbird/XXXXXXXXXXXX.default/prefs.js file and add the following...

user_pref("network.protocol-handler.app.ftp", "/opt/firefox/firefox");
user_pref("network.protocol-handler.app.http", "/opt/firefox/firefox");

Where XXXXXXXXX will be different on your machine, and also the path to firefox.

Also I copied my ~/.mozilla folder and firefox got al my bookmarks etc from before.

Firefox setup

Clicking on mailto links didn't work, this was fixed by adding this line

user_pref("network.protocol-handler.app.mailto","/opt/bin//thunderbird");

to the user.js file (create a new one if it doesn't exist) that is found in ~/.mozilla/firefox/default.xxx

Of course the .xxx will be different on your system as will the path of thunderbird.

Keyboard Mapping

I like to map my caps lock key to the Win key, so I can use it to switch windows and desktops etc, I use a Unicomp Linux keboard, as it has a nice feel, with loud clicky keys, and the control key is where it is supposed to be, next to the A key, so it doesn't have a Win key, but the caps lock key is generally useless, so I use that.

It turns out that the Dapper version of KDE does not use the ~/.Xmodmap file as it is supposed to, so you need to manually run

> xmodmap ~/.Xmodmap

One way that has been suggested to automate this is to put that command in the ~/.kde/Autostart, so that is what I did, I called the file mapwinkey, set chmod +x, put xmodmap $HOME/.Xmodmap in it, and put the shell script in the Autostart directory.

More to come as I do it...

Migrating KDE settings

CPU/HW monitoring

Migrating applications

Posted in  | Tags , , , , ,  | no comments | no trackbacks

Older posts: 1 ... 3 4 5