~ battlemidget /.emacs

; tips
; c-x left/right arrow for switching tabs

;; loadpath
(setq load-path (cons (expand-file-name "~/.el") load-path))

; Who needs these whatever-bars anyway?

;(tool-bar-mode -1)
;(menu-bar-mode -1)
;(scroll-bar-mode -1)

; Toggles the font-lock feature so that emacs
; highligths my texts.

(global-font-lock-mode t)

; Share the clipboard with X

(setq x-select-enable-clipboard t)

; Show column number on the status line

(column-number-mode t)

; Lets emacs uncompress .gz files before opening them

(auto-compression-mode 1)

; The proper TeX/LaTeX printing command for my system

(setq tex-dvi-print-command "dvips -f * | lpr")

; Preview TeX/LaTeX output with xdvi and telling it to
; watch the file for changes every 3 seconds

(setq tex-dvi-view-command "xdvi -watchfile 3 -expertmode 0")

; Set the papersize to a4

(setq ps-paper-type 'a4small)

; I use UTF-8

(set-keyboard-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-default-font "Monospace:pixelsize=14")

;; quit message
(fset 'yes-or-no-p 'y-or-n-p)

(setq delete-auto-save-files t)                ; no "#" files after a save
(setq auto-save-list-file-prefix nil)        ; don't record sessions

;; When saving files, set execute permission if #! is in first line.
(add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p)

;; set the fill column
(setq-default fill-column 72)

;; turn on auto fill in all lmodes
(setq auto-fill-mode 1)

;; add automagic python load
;;(autoload 'python-mode "python-mode" "Python Mode." t)

;; Scroll 1 line
(progn (setq scroll-step 1)
       (setq scroll-preserve-screen-position t)
       (setq scroll-conservatively 9999))

;; No new lines at the end
(setq next-line-add-newlines nil)

;; Do not use tabs!
(setq-default indent-tabs-mode nil)

;; delete \b at line ends before saving a file
(add-hook 'write-file-hooks 'delete-trailing-whitespace)

(setq inhibit-startup-message t)

;; Shhhh!
(setq visible-bell t)

;; To use emacs client
(server-start)

;; compilation
;; Autocompilation
(defun autocompile()
  "compile itself if ~/.emacs"
  (interactive)
  (if (string= (buffer-file-name) (concat default-directory ".emacs"))
      (byte-compile-file (buffer-file-name))))

;;;;;;;;;
;; python

(mapc (lambda (hook)
        (add-hook hook (lambda ()
                         (setq show-trailing-whitespace t))))
      '(python-mode-hook))

;(autoload 'py-complete-init "py-complete")
;(add-hook 'python-mode-hook 'py-complete-init)

;; end of python
;;;;;;;;;;;;;;;;

;; undo
(global-set-key (kbd "C-z") 'undo)

;; go to line
(global-set-key (kbd "C-M-g") 'goto-line)

(global-set-key (kbd "C-x C-r") 'query-replace-regexp)

;;;;;;;;;;
;; General

;; ibuffer
(require 'ibuffer)
(global-set-key (kbd "C-x C-b") 'ibuffer)

;; filladapt
(setq-default filladapt-mode t)

;; don't ask when changing case
(put 'downcase-region 'disabled nil)
(put 'upcase-region   'disabled nil)

;; overwrite mode is not disabled
(put 'overwrite-mode 'disabled nil)

(setq
  ;; don't show annoing startup msg
  inhibit-startup-message t
  ;; NO annoing backups
  make-backup-files nil
  ;; follow symlinks and don't ask
  vc-follow-symlinks t
  ;; see what you type
  echo-keystrokes 0.01
  ;; text scrolling
  scroll-conservatively 50
  scroll-preserve-screen-position 't
  scroll-margin 10
  ;; Insert space/slash after completion
  comint-completion-addsuffix t
  ;; number of chars in line
  fill-column 72
  ;; delete line in one stage
  kill-whole-line t
  ;; default mode
  default-major-mode 'text-mode
  ;; meaning are the same as the name :)
  delete-key-deletes-forward t
  ;; next-line don't add new lines
  next-line-add-newlines nil
  ;; Scroll by one line at a time
  scroll-step 1
  ;; don't add new lines when scrolling down
  next-line-add-newlines nil
  ;; make sure file ends with NEWLINE
  require-final-newline t
  ;; delete excess backup versions
  delete-old-versions t
  ;; setting the default tabulation
  default-tab-width 4
  ;; paste at cursor NOT at mouse pointer position
  mouse-yank-at-point t
  ;; apropos works better but slower
  apropos-do-all t
  ;; display time in the modeline
  display-time-24hr-format t
  display-time-day-and-date t
  ;; calendar customizing
  european-calendar-style t
  calendar-week-start-day 1
  ;; autosave every 512 keyboard inputs
  auto-save-interval 512
  ;; limit the number of newest versions
  kept-new-versions 5
  ;; limit the number of oldest versions
  kept-old-versions 5
  auto-save-list-file-prefix "~/.emacs.d/backups/save-"
  ;; don't beep
;  visible-bell t
  cursor-in-non-selected-windows nil
  ;; dired settings
  dired-recursive-copies t
  dired-recursive-deletes t
)

;; save position in files
(setq-default save-place t)

;; extensions

(require 'color-theme)
(color-theme-initialize)
(color-theme-charcoal-black)