dotfiles/.emacs.d/init.el
michener ee165a5f86 Add tabbar properly
git-svn-id: http://photonzero.com/dotfiles/trunk@84 23f722f6-122a-0410-8cef-c75bd312dd78
2011-03-23 08:43:50 +00:00

140 lines
4.6 KiB
EmacsLisp

(if (< emacs-major-version 23)
(defun characterp (obj)
(and (char-or-string-p obj) (not (stringp obj)))))
(add-to-list 'load-path "~/.emacs.d")
(add-to-list 'load-path "~/.emacs.d/auto-complete")
(add-to-list 'load-path "~/.emacs.d/icicles")
(add-to-list 'load-path "~/.emacs.d/tabbar")
(fset 'yes-or-no-p 'y-or-n-p)
(require 'icicles)
(icy-mode 1)
; Requires
(require 'vimpulse)
(require 'color-theme)
(require 'color-theme-autoloads)
(require 'tabbar)
;(require 'highlight-symbol)
(require 'auto-complete-config)
;; Hack to get *Messages* in viper-mode.
;; ;; (must be done after loading viper)
;; ;; Futzing with fundamental-mode doesn't seem to help.
(save-excursion
(set-buffer "*Messages*")
(viper-change-state-to-vi))
(add-to-list 'ac-dictionary-directories "~/.emacs.d/auto-complete/dict")
(ac-config-default)
(setq ac-dwim t)
(setq ac-expand-on-auto-complete nil)
(setq ac-use-fuzzy t)
(setq viper-search-wrap-around t)
(setq viper-no-multiple-ESC t)
(setq viper-translate-all-ESC-keysequences nil)
(setq viper-always t)
(setq viper-vi-style-in-minibuffer nil)
;(define-key ac-completing-map "\t" 'ac-fuzzy-complete)
;(define-key ac-completing-map "\r" nil)
(define-key ac-completing-map (kbd "<escape>") 'ac-stop)
; This is the other Vim-mode. Maybe should delete this..
;
;(add-to-list 'load-path "~/.emacs.d/vim-mode")
;(require 'vim)
;(vim-mode 1)
; Tabbar settings (Simple groups)
(defun tabbar-buffer-groups ()
"Return the list of group names the current buffer belongs to.
This function is a custom function for tabbar-mode's tabbar-buffer-groups.
This function group all buffers into 3 groups:
Those Dired, those user buffer, and those emacs buffer.
Emacs buffer are those starting with “*”."
(list
(cond
((string-equal "*" (substring (buffer-name) 0 1))
"Emacs Buffer"
)
((eq major-mode 'dired-mode)
"Dired"
)
(t
"User Buffer"
)
))) ;; from Xah Lee
(setq tabbar-buffer-groups-function 'tabbar-buffer-groups)
(tabbar-mode)
(add-to-list 'ex-token-alist '("ls" (list-buffers)))
(add-to-list 'ex-token-alist '("mx" (icicle-execute-extended-command)))
(vimpulse-map "gn" 'tabbar-forward-tab)
(vimpulse-map "gp" 'tabbar-backward-tab)
(vimpulse-map "gw" 'vimpulse-search-forward-for-symbol-at-point)
(vimpulse-map "gK" 'kill-buffer-and-window)
(vimpulse-map "gc" 'kill-buffer-and-window)
;(define-key viper-insert-global-user-map "\C-d" 'delete-char))
(add-hook 'window-setup-hook 'delete-other-windows)
; Basic frame defaults
(let ((background-color "#2F2F2F")
(foreground-color "LightGrey")
(fname "Inconsolata-18")
(fheight 45)
(fwidth 115))
(set-default-font fname)
(add-to-list 'default-frame-alist (cons 'font fname))
; (set-background-color background-color)
; (add-to-list 'default-frame-alist (cons 'background-color background-color))
; (set-foreground-color foreground-color)
(add-to-list 'default-frame-alist (cons 'foreground-color foreground-color))
(add-to-list 'default-frame-alist (cons 'height fheight))
(add-to-list 'default-frame-alist (cons 'width fwidth))
)
(custom-set-variables '(inhibit-startup-screen t))
(custom-set-faces)
; Run color-theme
(color-theme-initialize)
(color-theme-barak)
(color-theme-barak-extras)
(defadvice viper-maybe-checkout (around viper-svn-checkin-fix activate)
"Advise viper-maybe-checkout to ignore svn files."
(let ((file (expand-file-name (buffer-file-name buf))))
(when (and (featurep 'vc-hooks)
(not (memq (vc-backend file) '(nil SVN))))
ad-do-it)))
;; add a buffer modification state indicator in the tab label,
;; and place a space around the label to make it looks less crowd
(defadvice tabbar-buffer-tab-label (after fixup_tab_label_space_and_flag activate)
(setq ad-return-value
(if (and (buffer-modified-p (tabbar-tab-value tab))
(buffer-file-name (tabbar-tab-value tab)))
(concat " " (concat ad-return-value "+ "))
(concat " " (concat ad-return-value " ")))))
;; called each time the modification state of the buffer changed
(defun ztl-modification-state-change ()
(tabbar-set-template tabbar-current-tabset nil)
(tabbar-display-update))
;; first-change-hook is called BEFORE the change is made
(defun ztl-on-buffer-modification ()
(set-buffer-modified-p t)
(ztl-modification-state-change))
(defun ztl-on-buffer-demodification ()
(set-buffer-modified-p nil)
(ztl-modification-state-change))
(add-hook 'after-save-hook 'ztl-modification-state-change)
;; this doesn't work for revert, I don't know
(add-hook 'after-revert-hook 'ztl-on-buffer-demodification)
(add-hook 'first-change-hook 'ztl-on-buffer-modification)