Backup of .emacs



(global-set-key "%" 'match-paren)
(defun match-paren (arg)
   "Go to the matching paren if on a paren; otherwise insert %."
     (interactive "p")
     (cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1))
         ((looking-at "\\s\)") (forward-char 1) (backward-list 1))
         (t (self-insert-command (or arg 1)))))

(defun my-linux-c-mode ()
   "C mode with adjusted defaults for use with the linux kernel."
   (c-set-style "linux"))

(add-hook 'c-mode-hook 'my-linux-c-mode)

(server-start)

(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.
   '(show-paren-mode t)
   '(transient-mark-mode 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.
)

Update: 05/23/2013

Over the last six years I have made many more changes to the .emacs file. Latest update for backup!

;; ================
;; General settings
;; ================

;; Display the time
(setq display-time-day-and-date t
      display-time-24hr-format t)
(display-time)

;; Inhibit startup splash screen
(setq inhibit-startup-message t)

;; enable row and column numner mode
(setq line-number-mode t)
(setq column-number-mode t)

;; Disable automatic backups
(setq backup-inhibited t)

;; show trailing whitespace
(setq-default show-trailing-whitespace t)

;; enable global clipboard to copy, paste into emacs
(setq x-select-enable-clipboard t)
(setq interprogram-paste-function 'x-cut-buffer-or-selection-value)

;; Disable tool-bar-mode and other custom changes!
(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.
 '(comint-scroll-show-maximum-output nil)
 '(ediff-merge-split-window-function (quote split-window-vertically))
 '(ediff-split-window-function (quote split-window-vertically))
 '(tool-bar-mode nil)
 '(delete-selection-mode t))

;; Start the server for emacsclient -n to work
(server-start)

(set-background-color "black")
(set-foreground-color "DarkOliveGreen3")
(set-cursor-color "green yellow")

;; full screen mode using [F11]
(defun toggle-fullscreen (&optional f)
  (interactive)
  (let ((current-value (frame-parameter nil 'fullscreen)))
    (set-frame-parameter nil 'fullscreen
             (if (equal 'fullboth current-value)
                 (if (boundp 'old-fullscreen) old-fullscreen nil)
               (progn (setq old-fullscreen current-value)
                  'fullboth)))))
(global-set-key [f11] 'toggle-fullscreen)


;;
;; Map M-_ to delete trailing whitespace
;;
(define-key global-map (kbd "M-_") 'delete-trailing-whitespace)


;; Make new frames fullscreen by default. Note: this hook doesn't do
;; anything to the initial frame if it's in your .emacs, since that file is
;; read _after_ the initial frame is created.
;; NOTE: This is screwing up the emacsclient connections for new frames!

;; (add-hook 'after-make-frame-functions 'toggle-fullscreen)

;; Set c-x p as previous-multiframe-window
(global-set-key (kbd "C-x p") 'previous-multiframe-window)

;; Set a 10pt font
(set-face-attribute 'default nil :height 100)

;; Disable upcase-region
(put 'upcase-region 'disabled nil)

;; Kill process without query!
(add-hook 'comint-exec-hook
      (lambda ()
        (process-kill-without-query (get-buffer-process (current-buffer)))))

;; ====================
;; Programming settings
;; ====================




;; highlight text beyond 80 characters!  Love this one!!
(setq whitespace-style '(trailing lines-tail space-before-tab
                                  indentation space-after-tab)
      whitespace-line-column 80)
(global-whitespace-mode 1)


;; Paren mode
(show-paren-mode 1)

;; Use vim style parenthesis matching
(global-set-key "%" 'match-paren)
(defun match-paren (arg)
  "Go to the matching paren if on a paren; otherwise insert %."
  (interactive "p")
  (cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1))
    ((looking-at "\\s\)") (forward-char 1) (backward-list 1))
    (t (self-insert-command (or arg 1)))))

;; Insert spaces instead of tabs
(setq-default indent-tabs-mode nil)

;; Use TABs on Makefile mode
(defun my-makefile-mode-hook()
  (setq indent-tabs-mode t))
(add-hook 'makefile-mode-hook 'my-makefile-mode-hook)

;; Custom C\C++ style at work!
(c-add-style "my-style"
             '("bsd"
               (c-basic-offset . 2)
               (c-offsets-alist . (
                                   (topmost-intro . 0)
                                   (substatement . +)
                                   (substatement-open . 0)
                                   (case-label . +)
                                   (access-label . -)
                                   (inclass . +)
                                   (inline-open . 0)))))


;; Use my-style for C and C++ modes. Also enable hungry state to
;; eat out any trailing whitespace
(defun my-c++-mode-hook ()
  (c-set-style "my-style")
  (auto-fill mode)
  (c-toggle-hungry-state 1))

(defun my-c-mode-hook ()
  (c-set-style "my-style")

  (auto-fill mode)
  (c-toggle-hungry-state 1))


(add-hook 'c++-mode-hook 'my-c++-mode-hook)
(add-hook 'c-mode-hook   'my-c-mode-hook)

;; set gtags-mode by default for C and C++ modes
(add-hook 'c-mode-hook
          '(lambda ()
             (gtags-mode t)
             ))

(add-hook 'c++-mode-hook
          '(lambda ()
             (gtags-mode t)
             ))

;; Use C++-mode to edit *.h files (not C-mode)
(add-to-list 'auto-mode-alist '("\\.h\\'" . c++-mode))

;; Use my-style indentation for MDL files
(setq auto-mode-alist (cons '("\\.mdl\\'" . c-mode) auto-mode-alist))