Emacs Color Themes, CTags, CEDET, ECB and other Customizations


I’ve now found a color theme I like by way of the color theme browser.

I chose gray30 with two minor changes for far, click the image above to check out what my setup currently looks like. The reason I chose gray30 is that it seems geared towards Lisp coding. It has a dark background with lighter text but the parenthesises are darker than the other code which makes them almost invisible. For me this is a plus as I can read the code without them (any Pythonista can testify that that is by no means a mean feat), white spaces are information.

Let’s check the pertinent section of henrik.el:

(add-to-list 'load-path "~/.emacs.d/henrik/color-theme-6.6.0")
(require 'color-theme)
(eval-after-load "color-theme"
(eval-after-load "color-theme" '(color-theme-gray30))
(set-face-attribute 'default nil :height 60)
(setq font-lock-builtin-face '((t (:foreground "LightSkyBlue"))))

The two last lines here are the minor changes I mentioned above, the first one sets the font size and the second one removes underlining of keywords, something I found to be annoying with gray30.

The following turns on line numbers in the buffers and enables full screen when F11 is pressed:

(global-linum-mode 1)
(setq column-number-mode t)

(defun switch-full-screen ()
  (shell-command "wmctrl -r :ACTIVE: -btoggle,fullscreen"))

(global-set-key [f11] 'switch-full-screen)

To get the full screen stuff to work an apt-get install wmctrl is required too.

I also like the Emacs Code Browser (ECB), here are the lines:

(load-file "/home/henrik/.emacs.d/henrik/cedet/common/cedet.el")

(add-to-list 'load-path "~/.emacs.d/henrik/ecb-2.40")
(require 'ecb)
(setq ecb-tree-buffer-style 'ascii-guides)
(global-set-key (kbd "C-p") 'ecb-activate)

(setq my-projects '("/opt/clojure/phive" "/opt/picolisp/projects/db-server"))
(setq tags-table-list my-projects)
(setq ecb-source-path my-projects)
(global-set-key (kbd "C-<tab>") 'complete-tag)

I’m using CEDET 1.0 and ECB 2.40 here.

The three last lines require some more discussion, they tell Emacs where my tags files are so I don’t have to load them manually later. C-TAB will start code completion with the help of the tags, I had to remap the default M-TAB as that will switch windows in my WM.

M-. will jump to a definition, here TAB can be used to cycle alternatives.

Your mileage will vary when it comes to generating the tag files. Start with apt-get install ctags.

Going to the project root of my Clojure project and doing

ctags-exuberant -e -R --langmap=Lisp:+.clj --languages=-JavaScript

took care of that. But PicoLisp was harder. There I first had to add this in ~/henrik/.ctags:

--regex-picolisp=/^\(de[ \t]*([^ \t]+)/\1/d,definition/
--regex-picolisp=/^\(dm[ \t]*([^ \t]+)/\1/d,definition/
--regex-picolisp=/^\(class[ \t]*([^ \t]+)/\1/d,definition/

Then it was just enough to do ctags-exuberant -e -R --languages=picolisp in my PicoLisp project.

I’m pretty happy with the functionality so far, I have two gripes though:

1.) The tags lookup / completion will use both my tags files without any regard to which type of major-mode and/or file type I’m working with. This needs to get smarter as I don’t want Clojure functions to appear when I want completion in a PicoLisp file for instance.

2.) There is no completion of basic language constructs, or being able to jump to the documentation, this is what I will take a look at in the next part of this series.

Related Posts

Tags: , , , , ,