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 […]

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) […]

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)

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\\)\\).*\\” 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 ))

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)) […]