28 April 2008

Notes on Emacs

I'm giving Emacs a serious chance, so here are a few notes, mainly for personal future use.

  • auto-indent an entire file:
    (defun iwb ()
    "indent whole buffer"
    (indent-region (point-min) (point-max) nil)
    (untabify (point-min) (point-max)))
  • find .emacs on Windows: C-x C-f ~/.emacs (I know, it's banal, but...)
  • set tab size to my favourite default (3):
    (setq-default tab-width 3)
    (setq-default c-basic-offset 3)
  • php-mode: haven't quite understood how to activate it yet. I get syntax highlighting for everything BUT php. D'oh. UPDATE: ahh, you have to byte-compile it yourself. What a lazy environment for a dynamic language! Anyway, thanks to this blog post, I now know how to do it: M-x byte-compile-file (and then point to php-mode.el)
    UPDATE: Oh, and you have to use the 1.2 version with emacs 21 and lower.
  • (UPDATE) To maximize it at startup, two options:
    • Easy one: in the registry (HKCU\Software\GNU\Emacs, which you have to create), set a String property called "Emacs.Fullscreen" with value "fullboth". Unfortunately this is calculated from the very bottom of the screen, so if you have the taskbar set to "always on top" and no "auto-hide" (like me), you will end up with the taskbar covering the minibuffer.
    • better one: do
      M-x : (frame-width)
      and write down the number that comes up (e.g. 155), then repeat with (frame-height). Then (in the same key as above) set a String property "Emacs.Geometry" set to these value, e.g. 155x59. If you have the same taskbar issue as above, reduce the second parameter until it's ok (I had to reduce it by 3).

Why Emacs? I'm doing a "good deed" which involves php, and since I have to churn out loads of useless "$" and "->" and brackets, maybe it's time I learn a proper power-tool for text editing.

No comments: