My .emacs file

;; Filename: .emacs
;; Description: My .emacs

;; Author: Leonardo de Paula Rosa Piga
;; Copyright (C) 2008, Leonardo de Paula Rosa Piga, all rights reserved.
;; Created: Mon May  5 22:16:00 BRT 2008
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)

;; any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING.  If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth

;; Floor, Boston, MA 02110-1301, USA.
;;; Code:
  ;; custom-set-variables was added by Custom -- don't edit or cut/paste it!
  ;; Your init file should contain only one such instance.

 '(auto-compression-mode t nil (jka-compr))
 '(case-fold-search t)

 '(current-language-environment "UTF-8")
 '(default-input-method "rfc1345")
 '(global-font-lock-mode t nil (font-lock))

 '(show-paren-mode t nil (paren))
 '(transient-mark-mode t))

  ;; custom-set-faces was added by Custom -- don't edit or cut/paste it!
  ;; Your init file should contain only one such instance.

(setq inhibit-startup-message t)

(setq initial-scratch-message nil)
;Adjust the backspace, delete keys
; Ctrl-Left and Ctrl-Right

  (normal-erase-is-backspace-mode 1))
 (t ; If it is in text mode
  (global-set-key "\M-[1;5C"    'forward-word)      ; Ctrl+right   => forward word

  (global-set-key "\M-[1;5D"    'backward-word))    ; Ctrl+left    => backward word


;Show columns numbers
(setq column-number-mode t)

;Highlight lines

(setq transient-mark-mode t)

; Wheel mouse
(defun up-slightly () (interactive) (scroll-up 7))

(defun down-slightly () (interactive) (scroll-down 7))
(global-set-key [mouse-4] 'down-slightly)

(global-set-key [mouse-5] 'up-slightly)

(defun up-one () (interactive) (scroll-up 1))

(defun down-one () (interactive) (scroll-down 1))
(global-set-key [S-mouse-4] 'down-one)

(global-set-key [S-mouse-5] 'up-one)

(defun up-a-lot () (interactive) (scroll-up))

(defun down-a-lot () (interactive) (scroll-down))
(global-set-key [C-mouse-4] 'down-a-lot)

(global-set-key [C-mouse-5] 'up-a-lot)

; Adjust problems when in window mode

  (setq x-select-enable-clipboard t)
  (setq interprogram-paste-function 'x-cut-buffer-or-selection-value))


; Put backup files in one common place
;; redefining the make-backup-file-name function in order to get
;; backup files in ~/.backups/ rather than scattered around all over
;; the filesystem. Note that you must have a directory ~/.backups/
;; made.  This function looks first to see if that folder exists.  If

;; it does not the standard backup copy is made.

(defvar backup-file-dir (concat "~/.emacs-" (user-login-name)))
(make-directory backup-file-dir t)

(defun make-backup-file-name (file-name)
  "Create the non-numeric backup file name for `file-name'."
  (require 'dired)

  (if (file-exists-p backup-file-dir)
      (concat (expand-file-name (concat backup-file-dir "/"))

              (replace-regexp-in-string "/" "!" file-name))
    (concat file-name "~")))

   backup-directory-alist (list (cons "." backup-file-dir)))

;; redefining the make-auto-save-file-name function in order to get
;; autosave files sent to a single directory.  Note that this function
;; looks first to determine if you have a ~/.autosaves/ directory.  If
;; you do not it proceeds with the standard auto-save procedure.
(defun make-auto-save-file-name ()
  "Return file name to use for auto-saves of current buffer.."

  (if buffer-file-name
      (if (file-exists-p backup-file-dir) 
          (concat (expand-file-name (concat backup-file-dir "/")) "#"

                  (replace-regexp-in-string "/" "!" buffer-file-name)

          (file-name-directory buffer-file-name)
          (file-name-nondirectory buffer-file-name)

     (concat "#%" (buffer-name) "#"))))

; Customized Keys
(global-set-key "\C-cl" 'goto-line)
(global-set-key "\C-cc" 'compare-windows)

(global-set-key "\C-cr" 'revert-buffer)
(global-set-key "\C-ct" 'toggle-truncate-lines)

(global-set-key "\C-l" 'delete-region)

;(global-set-key "\'-c" "�")
; Back window function
(defun back-window () (interactive) (other-window -1))

(global-set-key "\C-co" 'back-window)

(setq frame-title-format (list "%b-" user-login-name "@" system-name))

; Enabling HideShow
(load-library "hideshow")
(add-hook 'vhdl-mode-hook 'hs-minor-mode)
(add-hook 'c-mode-hook 'hs-minor-mode)

(add-hook 'c++-mode-hook 'hs-minor-mode)
(add-hook 'java-mode-hook 'hs-minor-mode)
(add-hook 'perl-mode-hook 'hs-minor-mode)
(add-hook 'emacs-lisp-mode-hook 'hs-minor-mode)
(add-hook 'LaTeX-mode-hook  'hs-minor-mode)

;;HideShow shortcuts
;;C-c @ C-h    Hide the current block (hs-hide-block).
;;C-c @ C-s    Show the current block (hs-show-block).
;;C-c @ C-c    Either hide or show the current block (hs-toggle-hiding).
;;S-Mouse-2    Either hide or show the block you click on 
;;             (hs-mouse-toggle-hiding).
;;C-c @ C-M-h    Hide all top-level blocks (hs-hide-all).
;;C-c @ C-M-s    Show everything in the buffer (hs-show-all).
;;C-c @ C-l    Hide all blocks n levels below this block (hs-hide-level).

; Enable Cscope
;(setq cscope-do-not-update-database t)
;(load-file "/usr/share/emacs/site-lisp/xcscope.el")
;(require 'xcscope)