orgweb/articles/emacs.org

3.4 KiB

Emacs

General Emacs Tips

Tips might be the wrong word here, but the way I use Emacs has resulted into looking at some things that others might not think of or see.

Emacs Init File

Your Emacs init file can be any of the following:

  • $HOME/.emacs
  • $HOME/.emacs.el
  • $HOME/.emacs.d/init.el

I personally use $HOME/.emacs.d/init.el because that way I can keep everything Emacs related in a single directory ($HOME/.emacs.d).

Displaying time

I've seriously minimized the use of my window manager's task bar. It only shows which tags there are, some important daemons' status (running or not) and whether or not I have mail. This makes it difficult to tell time when I need it. That why it's useful to see what time it is in Emacs, since that is on 99.99% of the time I'm behind my computer, and it's very easy:

  (display-time-mode t)

That is all. When you have that in your /ryuslash/orgweb/src/commit/879aef7f899a164f40604bfcecd7820e959b11df/articles/Emacs%20Init%20File, you will always have the time in your modeline.

Automatically compile startup files

I know that for 99% of the things you might have in your having a compiled init files won't make much of a difference, but still I like having my init files compiled. This gets messy when you share your init files across multiple PCs and the source files become newer than the compiled ones.

To fix this I've put only a very little bit of code in my actual /ryuslash/orgweb/src/commit/879aef7f899a164f40604bfcecd7820e959b11df/articles/Emacs%20Init%20File:

  (require 'bytecomp)

  (defvar startup-files
    (directory-files "~/.emacs.d/startup/" t "^[^.].*\\.el$")
    "A list of the files that should be loaded during startup.")

  (while startup-files
    (let ((filename (car startup-files))
          (byte-compile-warnings nil))
      (if (not (eq (byte-recompile-file filename nil 0) nil))
          (load (substring filename 0 -3))))
    (setq startup-files (cdr startup-files)))

It gets all the files in the $HOME/.emacs.d/startup/ directory that end with .el. It loops through all these files and compiles them, and then loads them. I use byte-recompile-file instead of byte-recompile-directory because the directory one didn't work quite right. It doesn't recompile anything if the source file is still up to date, so it only slows down when you have a lot of new files in the startup directory. It also disables warnings so that you're not bothered by them during startup.

Emacs as…

There are many things Emacs1 is useful for, not just coding and writing, but certainly very much for these uses as well.

… An IDE…

Emacs features many modes for a lot of different languages.