Quickly diff the changes made in the current buffer with its file

Update (23rd Jan 2010): Separated the key-assignment and function definition. A simple function to quickly do a diff of the current buffer contents with its underlying file. Very useful if the file has been changed outside (e.g., a log file). ;; Diff the current buffer with the file contents (defun my-diff-current-buffer-with-disk () "Compare the current buffer with it's disk file." (interactive) (diff-buffer-with-file (current-buffer))) (global-set-key (kbd "C-c w") 'my-diff-current-buffer-with-disk)

January 19, 2010 · 1 min

Importing contacts from OSX Addressbook to Emacs BBDB

A major aspect of using Emacs is that it is more than a text editor - it is more of an application platform - some would call it an Operating System - that allows a host of applications to run within the same context and session - and vastly enrich the user experience. This is in fact a primary reason why many Emacs users spend their entire computer interaction via Emacs. ...

August 16, 2009 · 7 min

Tips for using emacsclient using Emacs 23.1 daemon mode

In an earlier post I had listed the server-mode mechanism to allow client/server editing using Emacs. However, this require some setup and also an active Emacs session. With the latest version of Emacs (23.1), a new mechanism to invoke Emacs in a server mode has been introduced. Basically, emacs can be invoked with the –daemon option from the shell command line: $ emacs --daemon This will run emacs in the background as a daemon which will be listening in to emacsclient connections. To actually start a edit session, use emacsclient from the command line as before with the file name as a parameter. ...

August 12, 2009 · 1 min

Tips for using emacsclient and server-mode on OSX

Emacs is a great editor, but has one setback - it is slow to startup if you have loads of packages to load. On my G4 iBook, it takes around 45 seconds before Emacs becomes usable (OK - I use lots of packages). However, Emacs is not meant to be restarted every so often. The canonical usage is to start Emacs once, invoke the server mode (see EmacsClient) and then use the emacsclient from the command line to invoke the editor instance when needed. I.e., the classic client/server model for editing! ...

August 11, 2009 · 3 min

Setting the PATH variable from within Emacs

A Small function to set the PATH variable from within Emacs. You can define the function and the path definitions in your .emacs file: Very useful for OS X, where the default path is set by plists. ;; Define a function to setup additional path (defun my-add-path (path-element) "Add the specified path element to the Emacs PATH" (interactive "DEnter directory to be added to path: ") (if (file-directory-p path-element) (setenv "PATH" (concat (expand-file-name path-element) path-separator (getenv "PATH"))))) and use it as: ...

August 10, 2009 · 1 min

Emulate a three button Mouse in Emacs on a single button Mac trackpad/mouse

Traditionally, mice on Macs have had just one button (including the iBook/Powerbook trackpads) - even through Mac OS (including OS X) can accept 2 or 3 button input without any problems. Emacs on the other hand maps quite a few functions to the second and third chords of the mice. If you want to emulate a three button mouse in Emacs on OS X, a simple customization option will do the trick. ...

August 9, 2009 · 1 min

Using M-` from switching Emacs Frames on OSX

The standard Emacs key-binding for moving to the other frame (‘other-frame’) is C-x 5 o. That’s quite a few key-strokes, and also does not match with the standard OS X key-mapping for switching windows, which is Command-`. On OS X, the Command key maps to Meta in Emacs. However, this is easy to fix. Put the following code-fragment into your .emacs file: (define-key icicle-mode-map [?\M-`] nil) # Only needed if you use Icicles (global-set-key [?\M-`] 'other-frame) # This sets the key binding Note that by default M-` invokes ‘tmm-menubar’ which can also be accessed via [F10]. Also, you do not need the first line (to undefine the key binding in Icicles) if you do not use that package.

August 9, 2009 · 1 min

Use the Capslock as a Control key on OSX for Emacs

This is an absolute must, unless you like contorting your fingers and risk RSI. It is also an easy thing to do on OS X. You need to bring up the System preferences → Keyboard & Mouse and then click the “Modifier Keys” to remap the Capslock to Control. This is available on OS X 10.4 and later versions.

August 8, 2009 · 1 min

Using OSX Spotlight from within Emacs

Emacs comes with a ‘locate’ command that uses the locate system command to find files within your system. On OS X, it is easier to use Spotlight, which is trivial to enable in Emacs. In your .emacs file, add the following code: (setq locate-command "mdfind") Now try: M-x locate <enter your search here> Your search results will be displayed in a new Window.

August 8, 2009 · 1 min

Emacs 23 is finally released!

Hurray! The latest version of the Emacs Operating system … erm text editor has been released today. The new version is at 23.1 and has a lot of goodies packed. The three features I am looking forward to the most are: Native transparency Easy sizing of the font display via C-x C-+ and C-x C– Full unicode support!! The third one is going to be most useful in the long run - with an easy ability to use the editor for texts in my native language and script. MULE was a workable option - but clunky compared to the solution in this release. ...

July 31, 2009 · 1 min