Thursday, February 7, 2008

Adding themes to emacs

U can add cool themes with a single command in ubuntu..

aptitude install emacs-goodies-el

Themes are installed...

Now start emacs and try

M-x color-theme-select

U will get menu list of themes.Select one from the list by pressing RET.

U have a new theme for Ur emacs....

The theme will stay only for that session of emacs...

If U want the theme to stay across sessions...add this code to the .emacs file
in the home directory.U should have .themesettings and .curTheme file in ur home
director(I was not having .themesettings I had to create it for this tweak)

(require ‘color-theme)
(setq theme-load-from-file t)
(defun my-onload()
(setq filename (concat (expand-file-name "~") "/.themesettings"))
(if (file-exists-p filename)
(progn
(load-file filename)
(if (equalp theme-load-from-file t)
(progn
(setq filename
(concat (expand-file-name "~") "/.curTheme"))
(if (file-exists-p filename)
(progn
(message "selecting theme from .curTheme")
(load-file filename)
(color-theme-install (my-color-theme))
)))
(funcall theme-default)
))
(message "selecting theme from color-theme-standard")
(color-theme-install(color-theme-standard)
)))

(defun my-kill-saves()
(if (equalp theme-load-from-file t)
(progn
(color-theme-print)
(write-file (concat (expand-file-name "~") "/.curTheme"))
)))

(add-hook 'after-init-hook 'my-onload)
(add-hook 'kill-emacs-hook 'my-kill-saves)


Now the selected theme will stay if we restart emacs.

No comments:

Post a Comment