(global-font-lock-mode 1)
(show-paren-mode)
;(server-start)

(let ((site-gentoo-el "/usr/share/emacs/site-lisp/site-gentoo.el"))
  (if (file-exists-p site-gentoo-el)
      (load-file site-gentoo-el)))

(setq inferior-lisp-program "/usr/bin/sbcl")
(if (fboundp 'slime-setup) (slime-setup))

(setq user-full-name "Gabriel Ebner"
      user-mail-address "ge@gabrielebner.at"

      mail-host-address
      (concat
       (let (o)
	 (setq o (shell-command-to-string
		  "hostname"))
	 (substring o 0 (- (length o) 1)))
       ".gabrielebner.at"))

(autoload 'run-haskell "inf-haskell"
  "Start an inferior haskell buffer." t)
(setq haskell-program-name "ghci")

(setq py-indent-offset 2)

(setq browse-url-browser-function #'browse-url-firefox)

(defun perltidy ()
  "Run perltidy on current buffer."
  (interactive)

  (mark-whole-buffer)
  (shell-command-on-region
   (region-beginning)
   (region-end)
   "perltidy -q"
   0 0 nil))

(defun ebuild-mode ()
  "Mode for ebuilds and eclasses."
  (interactive)

  (shell-script-mode)
  (sh-set-shell "bash")
  (make-local-variable 'tab-width)
  (setq tab-width 4))

(setq auto-mode-alist
 (cons '("\\.ebuild\\'" . ebuild-mode)
       (cons '("\\.eclass\\'" . ebuild-mode)
	     auto-mode-alist)))

; Agda mode
(let ((agda-dir "/home/gebner/build/Agda2/src/full/Interaction/emacs-mode/"))
  (if (file-exists-p agda-dir)
    (progn
      (add-to-list 'load-path agda-dir)
      (autoload 'agda2-mode "agda2-mode" "Agda2 mode." t)
      (add-to-list 'auto-mode-alist '("\\.l?agda$" . agda2-mode))
      (modify-coding-system-alist 'file "\\.l?agda$" 'utf-8))))