Archive for the ‘Emacs’ category

Emacs Tip #2: ido-mode

January 2, 2008

In Emacs if you want to open a file you would type C-x C-f and the Find File would appear in the mini buffer like thisido-1.png

Following this you have to type the name of the file you want to open. Since the general Unix and Emacs policy is to type as little as possible, there is a package available in standard Emacs which will make your life a lot easier.

The package is called ido-mode and can be enabled by the following steps.

  1. Type M-x customize-variable <RET> ido-mode <RET>ido-2.png
  2. Move the cursor to the Value Menu and hit returnido-3.png
  3. Select 2 from the options and move the cursor over to “Save for Future Sessions” and hit return. This will persist the changes in your ~/.emacs file.
  4. ido-4.png

  5. Now go back and try to open a file. You will see that all the available files in that directory are listed in the mini buffer.ido-5.png
  6. To select cgi-bin, all you need is type the letters cg and hit return.
  7. You can use ido-mode while switching buffers as well. Type C-x C-b and you will see all the buffers listed and you can jump to any of them by typing few characters in the name and hitting return.ido-7.png

Emacs Tip #1: Paranthesis matching

December 18, 2007

Emacs has so many ways to match the paranthesis in your code. There is the paren-mode and there are many other hacks. They are all fine, I like the way how vi does it. In vi, you place your cursor on a paranthesis and press % key and it will jump to the matching paranthesis.

To enable this feature, put the following code in your ~/.emacs file and restart.

(global-set-key "%" 'match-paren)
(defun match-paren (arg)
"Go to the matching parenthesis if on parenthesis otherwise insert %."
(interactive "p")
(cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1))
((looking-at "\\s\)") (forward-char 1) (backward-list 1))
(t (self-insert-command (or arg 1)))))

Emacs 23 with XFont

December 18, 2007

Emacs 23 Screen Shot

That is a screen shot of my Emacs running on Gusty Gibbon. The Emacs version is 23 and it has XFont enabled. This is not an offical release and is based on the code in cvs, but Alexandre Vassalotti has simplified the installation that with a few commands you can have it running on your Ubuntu.

The step by step instructions are available here: Pretty Emacs Reloaded.

After following the instruction, I got this error which was solved by a few more commands.