FFAP and Ruby in Emacs

If you want to use FFAP (find-file-at-point) in ruby-mode you can add this to your .emacs (defvar ruby-program-name "ruby") (defun ruby-module-path(module) (shell-command-to-string (concat ruby-program-name " -e " "\"ret='()';$LOAD_PATH.each{|p| " "x=p+'/'+ARGV[0].gsub('.rb', '')+'.rb';" "ret=File.expand_path(x)" "if(File.exist?(x))};printf ret\" " module))) (eval-after-load "ffap" '(push '(ruby-mode . ruby-module-path) ffap-alist)) When you do ffap (i bind it to C-x f) near a require ‘PP’ for example it will find it in your ruby path.

4 May 2008 · 1 min

Emacs config

To anyone interested my extensive Emacs configuration is available here : http://code.google.com/p/chmouel/source And here is the usual screen shot :

7 September 2007 · 1 min

Always search before coding

This is a annoying, even if it take 5mn to code thing like that : (defun my-dired-rm-rf() "Rm -rf directories" (interactive) (let ((sel (selected-window))) (dolist (curFile (dired-get-marked-files)) (if (yes-or-no-p (concat "Do you want to remove \"" (file-name-nondirectory curFile) "\" ? ")) (progn (shell-command (concat "rm -rvf " curFile) "*Removing Directories*") (kill-buffer "*Removing Directories*") (select-window sel) (revert-buffer) ) )) )) you discover after a litlle while that if you have did a lilt bit of searching before, you will have discovered a variable call `dired-recursive-deletes` that would do the thing in a much better way.

11 February 2007 · 1 min

Emacs nighly cvs snapshot with xft on Ubuntu Edgy

I wanted to try the latest cvs snapshot with XFT support, since i did not want to screw up more my workstation i have used packages instead of make install blindy. Basically i have a script called ./build.sh #!/bin/bash set -e d=$(date '+%Y%m%d') debpatch=20061218-1 mkdir -p cvs pushd cvs >/dev/null && { cvs -Q -z3 -d:pserver:[email protected]:/sources/emacs co -r emacs-unicode-2 emacs } && popd >/dev/null mkdir -p build [[ -d build/emacs-${d} ]] && rm -rf build/emacs-${d} cp -al cvs/emacs build/emacs-${d} zcat patches/emacs-snapshot_${debpatch}.diff.gz|patch -p1 -d build/emacs-${d} cat patches/with-font.patch|patch --silent -p1 -d build/emacs-${d} pushd build/emacs-${d} >/dev/null && { chmod +x debian/rules dch -v "1:${d}-1" "New snapshot." dch "Build with xft." fakeroot dpkg-buildpackage -b } && popd >/dev/null in patches/with-font.patch i have : ...

21 January 2007 · 2 min

Rename bunch of file via regexp

To rename bunch of files via regexp i was using before a homegrown python script call rename-regexp.py{#p38} to change bunch of files with a regexp. But since then i discovered wdired which is pretty fantastic to use that from emacs. With the extended ``query-replace-regexp`` from Emacs22 stuff are much easier to rename.

7 January 2007 · 1 min

My first webpage

Classic my first webpage is still on the web that was back in 98 and that was about Emacs :) http://membres.lycos.fr/crblinux/html/xemacs.html It is in french thought.

30 December 2006 · 1 min

Xterm like Control-L in Eshell

If you want to emulate Control-L in Eshell (the Emacs Shell) like in Xterm, you can use this : (defun eshell-show-minimum-output () (interactive) (goto-char (eshell-beginning-of-output)) (set-window-start (selected-window) (save-excursion (goto-char (point-max)) (line-beginning-position))) (eshell-end-of-output)) And add a key bind to it in your custom hook : (local-set-key "\C-l" 'eshell-show-minimum-output)</p> <p>

28 December 2006 · 1 min

Cheetah Mode for Emacs

Here is a simple html derived mode for Cheetah templates files. The font-locking regexp can be improved thought but that’s a start. (define-derived-mode cheetah-mode html-mode "Cheetah" (make-face 'cheetah-variable-face) (font-lock-add-keywords nil '( ("\\(#\\(from\\|else\\|include\\|set\\|import\\|for\\|if\\|end\\)+\\)\\>" 1 font-lock-type-face) ("\\(#\\(from\\|for\\|end\\)\\).*\\<\\(for\\|import\\|if\\|in\\)\\>" 3 font-lock-type-face) ("\\(\\$\\(?:\\sw\\|}\\|{\\|\\s_\\)+\\)" 1 font-lock-variable-name-face)) ) (font-lock-mode 1) ) (setq auto-mode-alist (cons '( "\\.tmpl\\'" . cheetah-mode ) auto-mode-alist ))

31 July 2006 · 1 min

Access Gajim within Emacs

Here is some function to launch a gajim window from Emacs : (defvar gajim-remote "/usr/bin/gajim-remote") (defvar gajim-user-list ()) (defun my-gajim-get-list() (save-excursion (with-temp-buffer (call-process gajim-remote nil t nil "list_contacts") (goto-char (point-min)) (while (re-search-forward "^jid[ ]*:[ ]*\\(.*\\)$" (point-max) t ) (setq gajim-user-list (append gajim-user-list (list (match-string-no-properties 1))))))) gajim-user-list) (defun my-gajim-talk() (interactive) (let* ((ff (if (not gajim-user-list)(my-gajim-get-list) gajim-user-list)) (answer (completing-read "Jabber: " (mapcar (lambda (tt)(list tt)) ff)))) (message answer) (start-process "*GAJIM*" nil gajim-remote "open_chat" answer) ) ) (global-set-key '[(control x)(j)] 'my-gajim-talk) If Emacs had a dbus support that would have been cool.

31 July 2006 · 1 min