Feeds:
Posts
Comments

Archive for March, 2009

This post started as a quick note (mainly to myself) about a handy sub-feature within emacs find. Since reading through the documentation, I need to mention a few other sub-features too.

As I’ve probably mentioned before, I use both vim and emacs. One great feature of vim is that if you press # or * it searches for the word that your cursor is over. # or * choose a backwards or forwards search respectively.

There is a similar convenience when using emacs search in that if you enter search using C-s then C-w chooses the word you are looking at. I always forget about this feature and my google-fu is never good enough to find it again. Fortunately I recently came across it again when I was looking at the documentation for C-s (isearch-forward) using C-h k C-s.

It turns out that isearch is implemented by a minor mode (logically enough when you think about it) that adds a whole bunch of useful keys, including C-w we mentioned earlier. Other notable features are:

  • C-M-w delete last character in search string
  • M-r toggle regular-expression mode
  • M-e edit search string

And to replace search strings there are:

  • M-% query-replace and
  • C-M-% query-replace-regexp

Read Full Post »

Does anyone else have this problem? You’ve made some changes to one of your start-up emacs files. Then you fire up a new instance of emacs to check if your new feature works. However, none of your changes seem to have made a difference. So you spend some time looking into what you did wrong. And finally you realise – Emacs loads compiled emacs-lisp code in preference to uncompiled code, even when the uncompiled code is newer.

True story – this has happened to me more than a couple of times. The fifth second time I decided to fix it. I’ve come up with a solution that I’m fairly happy with: Emacs is started from a script called run_emacs.sh that runs another script called compile.sh (I’ve done it this way so I can run compile.sh independently).

#!/bin/sh

$HOME/emacs-files/compile.sh
emacs $*

compile.sh calls batch-byte-compile-if-not-done.

#!/bin/sh

cd $HOME/emacs-files

emacs --batch \
      --eval "(add-to-list 'load-path (expand-file-name \"~/emacs-files\"))" \
      --eval "(add-to-list 'load-path (expand-file-name \"~/emacs-files/org-xxx\"))" \
      --eval "(batch-byte-compile-if-not-done)" *.el

And last but not least I alias emacs to run_emacs.sh.

$ alias emacs='$HOME/emacs-files/run_emacs.sh'

Read Full Post »

Bill has some useful tips on how to get back to where you were with exchange-point-and-mark (C-x C-x) and pop-global-mark (C-x C-SPC).

Nicolas Lara wrote about converting fontlocked emacs buffers to html using htmlize. As htmlize uses css classes rather than inline styles it uses a snippet from Ruslan’s blog. htmlize-region-for-paste can also convert the css classes to inline styles although it isn’t an interactive function. Doesn’t everyone write their blog posts using muse (with htmlize) which already does this and more?

Amongst other great posts (!), I should also point out my own posts on solving mathematical problems using calc mode and on mapping aliases to dired directories.

emacs-fu wrote a post on querying emacs itself to find out how it does stuff. Steve Yegge mentioned the help functions in his effective emacs post – Item 8: Learn the most important help functions.

Ryan McGuire wrote about using autocomplete.el with python. dabbrev-expand (M-/) is built into emacs and provides dumb but very useful autocompletion. However, autocomplete.el looks a lot prettier.

Joseph Miklojcik wrote a macro to define functions which switch to certain buffers and back again.

Read Full Post »

« Newer Posts

Follow

Get every new post delivered to your Inbox.