Posts

Showing posts with the label Emacs

Installing Emacs 24.3.1

Earlier I blogged about a little hurdle that I ran into when I was trying to install Emacs 24.1. Since Emacs 24.3.1 was released recently, I thought I would give it a spin. After downloading the source code , I unzipped the source code and ran configure command. I got a similar error that I was getting before. checking for libXaw... configure: error: No X toolkit could be found. If you are sure you want Emacs compiled without an X toolkit, pass --with-x-toolkit=no to configure. Otherwise, install the development libraries for the toolkit that you want to use (e.g. Gtk+) and re-run configure. I am trying to install Emacs on Mint 14. So to satisfy all the dependencies, I installed the missing packages. sudo apt-get update sudo apt-get install libgtk2.0-dev libtiff4-dev libgif-dev libpng12-dev libxpm-dev libncurses-dev libjpeg-dev libjpeg8-dev libjpeg-turbo8-dev After installing the dependencies, the usual three step process worked fine. ./configure ...

Using dirtrack-mode inside shell mode

I usually try to automate the things that I repeatedly perform. One the things that I recently automated was: Create a directory with a prefix and today's date or time as suffix. Chdir to the most recently created directory. The source code for these utility functions is given below: When I use these utility functions inside the Emacs' shell-mode, the shell-mode was unable to keep track of the current directory. The issue is that I am changing directories without making use of the cd command. Then came the dirtrack-mode for the rescue. The idea is very simple: you specify the regular expression where the path appears in your shell prompt. The dirtrack-mode figures out the rest of the stuff. Now my .emacs file contains the following two lines: Thats it. Works like a charm. Please note that you might have to modify the regular expression to match where the full path appears in your prompt.

Elisp utility to open SQLplus from a remote host

If you are in a situation when you have to login to an intermediate or jump host to open SQLplus session to your database, here is a utility that you can make use of. You can store this utility in your .emacs file. Then the utility can be invoked interactively from inside Emacs, by typing "Alt-x open-remote-sqlplus-session-interactive". With autocmpletion, you can specify the session alias that you would like to open. To make the best use of the utility, you need to specify the list of jump hosts and the SQLplus connection strings in the "alias-to-jumphosts-alist" variable. If you need to run any custom commands immediately after opening SQLplus session (in addition to commands in your login.sql or glogin.sql files), you can add these commands in list-of-sqlplus-setup-commands. I find this utility to be a tremendous time saver. Hope you also find it the same way. Here is the utility as a gist:

Installing Emacs 24.1

I was excited to see the announcement that Emacs 24.1 has been released .  I wanted to install and try. There were a few glitches that I faced during the installation. I thought it might be useful for someone who might be hitting the same blocks. Once I downloaded the source code and verified the signature , I unzipped the Emacs 24.1 source code. The first "configure" run gave the following error: configure: error: You seem to be running X, but no X development libraries were found. You should install the relevant development files for X and for the toolkit you want, such as Gtk+, Lesstif or Motif. Also make sure you have development files for image handling, i.e. tiff, gif, jpeg, png and xpm. If you are sure you want Emacs compiled without X window support, pass --without-x to configure. To address this error I had to do the following: sudo apt-get install libgtk2.0-dev libtiff4-dev libgif-dev libjpeg62-dev libpng12-dev libxpm-dev Then when I attempted to ru...

Loading Lisp file from URL in Emacs

On a given day, I have to login and work from multiple Linux boxes. One thing I find annoying is that every time I make a change to my .emacs file, I have to copy the changes to all the hosts. There are multiple ways to circumvent this issue. One way I find useful is to maintain my custom file as a gist in github (or any where you can host your .emacs file) and use the following code snippet in the .emacs to load the file from the URL. (with-temp-buffer   (shell-command "curl -Ls https://gist.github.com/raw/372f5e3e8aca632d9b82/hello-world.el" (current-buffer))   (eval-buffer)) Let me explain what this code snippet does: It creates a temporary buffer. With the temporary buffer as the current buffer, it fetches the contents of the URL into the current buffer. It evaluates the current buffer. Remove the temporary buffer. If the sample code above works for you, if you eval the "(hello-world)", it will say "hello world" in the mini buffe...

Fastest way to switch between buffers in Emacs

In any given Emacs session, I have at least 5 buffers open. One of the pains of using C-x b to switch between buffers is that after typing every few characters, you have to type tab to perform completion. It is a waste of time. iswitchb is a much more efficient alternative to the default switch-to-buffer that is invoked while you type C-x b. It is time saving in two ways: (1) there is no need to type tab for completion and (2) you can give any part of the buffer name in the minibuffer prompt and jump to that buffer. To enable this mode, add the following line in your .emacs file. (iswitchb-mode 1)  Thats it. You are ready to rock-n-roll. More info at:  http://www.emacswiki.org/emacs/IswitchBuffers .

Font face customization in Emacs - an easy way

I usually edit source code using Emacs running inside a PuTTY session. One of the struggles I often run into is how to customize different elements I see on the screen. For e.g. the prompt in the shell-mode, previously executed command line, shell input, etc. While I googled around a bit, I came across this incredibly useful key binding: C-u C-x = . It runs the command "what-cursor-position". Here is how you can use this: You position the cursor on the element you would like to customize, and type C-u C-x =. You will be presented with the properties of the character at point, including links to customize the character. I find this extremely useful and hope sharing this information will help others as well. Credit:  http://stackoverflow.com/questions/1242352/get-font-face-under-cursor-in-emacs

Good tutorials on Emacs Lisp

There are two pages that I would highly recommend to get started with Emacs Lisp. Xah Lee's tutorial on Emacs Lisp . Steve Yegge's Emergency Elisp . Of course you should always have the Emacs Lisp reference manual handy.

Customizing colors in comint package in Emacs

The default foreground of prompt (gdb, shell, etc.) in the comint package in Emacs is blue. If you are working in PuTTY, the default background is black. Imagine blue on black background. Looks nasty! You can customize the color of the prompt by using the comint-highlight-prompt variable. For e.g. I am using yellow foreground in my system. Here is how I have customized it by adding these lines in my ~/.emacs : (copy-face 'default 'comint-highlight-prompt) (set-face-foreground 'comint-highlight-prompt "yellow") In short, the first lines creates a font-face variable by copying the default face and the second line changes the foreground value of that font-face variable to "yellow". Scott A. Kuhl's .emacs file helped me a lot in understanding how to customize this. Thanks to him.