Emacs creeps up on me

I have used vim for years—since I started coding PHP. (Sometimes I preferred the Zend Studio editor because nothing does a better job of cross-linking in PHP projects. Unfortunately, almost anything could do a better job of memory management. As WordPress grew, the Zend editor became too slow to be usable. Too bad. I miss it.) Now that I am writing some Erlang, I am learning to use emacs.

The credit for this switch belongs entirely to the lovely erlang-mode. (I tried TextMate’s erlang mode but I couldn’t get past TextMate’s strange navigation keys, etc. I wish there were standard navigation keys in OS X. Too bad. I’ve heard TextMate is great.) The emacs erlang-mode helps me write beautiful code. Now that I’m also learning to use emacs in php-mode I rarely become disoriented and type “:w” to save a file. (I don’t miss vim.)

Not everything about emacs is perfect. It doesn’t understand my Mac’s right-delete key. Left-delete (backspace) won’t delete a tab; it converts it the tab spaces and deletes one of them so that I have to hit backspace many times to delete a single tab. And in php-mode, the indentation rules are far more complex than the WordPress coding standards; I just want tabs in php-mode.

Even though I have these problems, you have to hand it to emacs for being customizable. It took a couple of hours to find all the solutions, but I solved all of the above problems above by adding these lines to my .emacs file:

;; Map OS X Terminal SSH delete key
(global-set-key (read-kbd-macro "ESC [ 3 ~") 'delete-char)

;; Backspace should delete, not convert tabs to spaces
(setq c-backspace-function 'backward-delete-char)

;; In PHP, never indent; always insert TAB.
(require 'php-mode)
(defun my-php-mode-hook ()
  (local-set-key (kbd "TAB") 'self-insert-command))
(add-hook 'php-mode-hook 'my-php-mode-hook)

This works for me even though I understand less than half of it. There is so much to learn.

This entry was posted in Adhesive, Wobble. Bookmark the permalink. Follow any comments here with the RSS feed for this post.

One Response to Emacs creeps up on me

  1. Oz says:

    You may also find variable “backward-delete-char-untabify-method” useful. Try

    M-x customize-variable RET backward-delete-char-untabify-method RET

    (RET = Enter in Emacs speak.)

    Also, you don’t need to do “(require ‘php-mode)” when you define and set a hook function. It loads php-mode file but it’s not necessary at Emacs load time; it just slows down your Emacs startup. The hook function will be executed after you enter the php-mode.

    Yes, with open-ended systems like Emacs there is always much to learn. It’s never “ready” because it’s so open for user’s customization.

Leave a Reply

Your email is never published nor shared.

You may use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Anti-Spam Quiz: