Customized my EMacs today

This is going to be my first blog post from within EMacs. Finally, I can escape the web interface of
wordpress.com and use good old EMacs bindings instead, if this
works. I did a good lot of customization to my .emacs today and here’s
what it looks like now (minus the bit that weblogger added):


;; General stuff
(setq inhibit-startup-message t)
(setq make-backup-files nil)
(setq load-path (cons '"/home/akarsh/emacs" load-path))
(setq transient-mark-mode t)
(setq curdir (expand-file-name "."))

;; Make sure color displays properly in shells within EMacs
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)

;; We want 256 color support!
(load "~/emacs/screen-256color.el")

;; Use my favourite color theme
(require 'color-theme)
(load "~/emacs/color-theme-rlx.el")
(setq color-theme-is-global t)
(color-theme-rlx)

;; Get a quick shell when required
(fset 'pull-shell-out
"\C-[xshell\C-m\C-xb\C-m\C-u-60\C-x3\C-xo\C-xb*shell*\C-mexport COLUMNS=60\C-m")
(global-set-key "\C-t" 'pull-shell-out)

;; Auto fill for E Mail.
(add-hook 'text-mode-hook
'(lambda () (auto-fill-mode nil)
(abbrev-mode t)))
(add-hook 'server-switch-hook
'(lambda () (progn
(auto-fill-mode 1)
(my-mutt-settings))))
(defun my-mutt-settings ()
(if (and
(> (length (buffer-file-name)) 8)
(equal "/tmp/mutt" (substring (buffer-file-name) 0 9)))
(progn
(mail-mode)
(mail-text)
(cd curdir))))

;; C++ / C / ObjC mode specifics
(defun setup-ebrowse-bindings ()
;; Faster bindings for frequently used stuff
(define-key c-mode-base-map (kbd "C-c C-f") 'ebrowse-tags-find-definition)
(define-key c-mode-base-map (kbd "C-c C-F") 'ebrowse-tags-find-declaration)
(define-key c-mode-base-map (kbd "C-c -") 'ebrowse-back-in-position-stack)
(define-key c-mode-base-map (kbd "C-c +") 'ebrowse-forward-in-position-stack)
(define-key c-mode-base-map (kbd "C-c =") 'ebrowse-forward-in-position-stack)
(define-key c-mode-base-map (kbd "C-c p") 'ebrowse-electric-position-menu)
(define-key c-mode-base-map (kbd "C-c f") 'ebrowse-tags-find-definition-other-window)
(define-key c-mode-base-map (kbd "C-c F") 'ebrowse-tags-find-declaration-other-window)

;; Get a C++ Tree on the side when required
(fset 'pull-c++-tree-out
"\C-u-60\C-x3\C-xo\C-x\C-f\C-a\C-kBROWSE\C-m")
(define-key c-mode-base-map (kbd "C-c t") 'pull-c++-tree-out)
)

(defun my-c-mode-common-setup ()
(setq c-basic-offset 4) ;; We want to stick to KStars' indentation standards
(setq indent-tabs-mode nil) ;; No TABs for indentation, please!
(setq compile-command "makefromemacs") ;; Change compile command
(define-key c-mode-base-map (kbd "C-c c") 'compile) ;; Bind C-c c to (compile)
(setup-ebrowse-bindings) ;; Set up EBrowse bindings
)

(add-hook 'c-mode-common-hook 'my-c-mode-common-setup)

;; Iswitchb is much nicer for inter-buffer navigation.
(cond ((fboundp 'iswitchb-mode) ; GNU Emacs 21
(iswitchb-mode 1))
((fboundp 'iswitchb-default-keybindings) ; Old-style activation
(iswitchb-default-keybindings))
(t nil)) ; Oh well.
(global-set-key [(control x) (control b)] 'iswitchb-buffer)
(global-set-key [(control x) (f)] 'find-file)

I configured a whole bunch of things – ebrowse
being one of them. Now I can quickly go to the definition of any
function – that’s something that is going to increase my productivity
significantly.

Another thing I did was to bind a whole bunch of keys to complicated
tasks. For instance, I mapped C-t to pull out a small (60 column long)
terminal from the side of the current window, because that appeals to
me a lot more.

It’s so much more easier to blog from EMacs, that (hoping that this
works), I’ll be blogging more frequently!

Advertisements