;; Red Hat Linux default .emacs initialization file

;; Set up the keyboard so the delete key on both the regular keyboard
;; and the keypad delete the character under the cursor and to the right
;; under X, instead of the default, backspace behavior.
(setq default-major-mode 'text-mode)
(setq text-mode-hook 'turn-on-auto-fill)

(global-set-key [delete] 'delete-char)
(global-set-key [kp-delete] 'delete-char)

;;CUSTOMIZATION BLOCK
(setq line-number-mode t)

(global-set-key "\C-cg" 'goto-line)

(custom-set-variables
  ;; custom-set-variables was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 '(case-fold-search t)
 '(current-language-environment "English")
 '(desktop-enable t t (desktop))
 '(exec-path (quote ("/usr/bin" "/bin" "/usr/sbin" "/sbin" "/Applications/Emacs.app/Contents/MacOS/libexec" "/Applications/Emacs.app/Contents/MacOS/bin" "/sw/bin")))
 '(global-font-lock-mode t nil (font-lock))
 '(pop-up-frames t))
(custom-set-faces
  ;; custom-set-faces was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 )

;;TEX BLOCK
(require 'tex-site)
(setq-default TeX-master nil) ; Query for master file.
(add-hook 'LaTeX-mode-hook 'flyspell-mode)
(server-start)
(add-hook 'LaTeX-mode-hook 'LaTeX-math-mode)

;;Enable Skim for reading pdf latex
(add-hook 'TeX-mode-hook
    (lambda ()
      (add-to-list 'TeX-output-view-style
	     '("^pdf$" "."
	       "/Applications/Skim.app/Contents/SharedSupport/displayline %n %o %b")))
)
;Use PDF mode by default
(setq-default TeX-PDF-mode t)



;IDO completion
(setq ido-save-directory-list-file "~/ido.history")
(ido-mode t)
(ido-everywhere t)
(setq ido-max-work-file-list 40)
(setq ido-enable-flex-matching t)
(add-hook 'ido-define-mode-map-hook 'ido-my-keys)
(defun ido-my-keys ()
  (define-key ido-mode-map "\t" 'ido-complete)
					;tab is better for completion lists
					;(define-key ido-mode-map (kbd "tab")
					; 'ido-complete)
  (define-key ido-mode-map "\C-t" 'ido-toggle-regexp) ; same as in isearch
  (define-key ido-mode-map "\C-d" 'ido-enter-dired)) ; cool

;;Tabbar customization:
(dolist (func '(tabbar-mode tabbar-forward-tab tabbar-forward-group tabbar-backward-tab tabbar-backward-group))
      (autoload func "tabbar" "Tabs at the top of buffers and easy control-tab navigation"))
     
    (defmacro defun-prefix-alt (name on-no-prefix on-prefix &optional do-always)
      `(defun ,name (arg)
         (interactive "P")
         ,do-always
         (if (equal nil arg)
             ,on-no-prefix
           ,on-prefix)))
     
    (defun-prefix-alt shk-tabbar-next (tabbar-forward-tab) (tabbar-forward-group) (tabbar-mode 1))
    (defun-prefix-alt shk-tabbar-prev (tabbar-backward-tab) (tabbar-backward-group) (tabbar-mode 1))
     
    (global-set-key [(control tab)] 'shk-tabbar-next)
    (global-set-key [(control shift tab)] 'shk-tabbar-prev)

