3283d2538ae8a589820b2c6682db3dd4118780bb
[dotfiles.git] / emacs / emacs_lite.el
1 ;; -*- emacs-lisp -*-
2
3 ;; Author: Olivier Tetard <olivier.tetard@miskin.fr>
4 ;; URL : http://www.miskin.be/
5
6 ;; This file is free software; you can redistribute it and/or modify it
7 ;; under the terms of the GNU General Public License as published by the
8 ;; Free Software Foundation; either version 2, or (at your option) any
9 ;; later version.
10
11 ;; This file is distributed in the hope that it will be useful, but
12 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 ;; General Public License for more details.
15
16 ;; You should have received a copy of the GNU General Public License
17 ;; along with GNU Emacs; see the file COPYING. If not, write to the Free
18 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 ;; 02111-1307, USA.
20
21 ;; Inspiré par les fichiers de :
22 ;;   * Julien Danjou (julien.danjou.org)
23 ;;   * Mark Triggs (http://grapevine.net.au/)
24
25 ;; ,----
26 ;; | Extensions et paths
27 ;; `----
28
29 (push (expand-file-name "~/.elisp") load-path)
30
31 (require 'color-theme)
32 (require 'ido)
33
34 ;; ,----
35 ;; | Couleurs et apparence
36 ;; `----
37
38 (if window-system
39     (color-theme-resolve)
40   (color-theme-dark-laptop))
41
42 (set-face-background 'default "black")
43
44 (if window-system
45     (progn 
46       (tool-bar-mode nil)
47       (tooltip-mode nil)
48       (scroll-bar-mode t)))
49
50 ;; Plus de couleurs pour font-lock-mode (inutile avec Emacs22)
51 (setq font-lock-mode-maximum-decoration t)
52 (setq font-lock-use-default-fonts t)
53 (setq font-lock-use-default-colors t)
54 (setq transient-mark-mode 't)
55
56 ;; Active la coloration syntaxique par defaut (inutile avec Emacs22)
57 (if (fboundp 'global-font-lock-mode)
58     (global-font-lock-mode t))
59
60 ;; ,----
61 ;; | Comportement
62 ;; `----
63
64 (ido-mode t)                            ; Utilisation du mode ido
65 (setq auto-save-interval 1200)          ; Autosave
66 (setq scroll-step 2)                    ; On se decale de 2 lignes quand on change de page
67 (delete-selection-mode t)               ; On peut supprimer une selection
68 (fset 'yes-or-no-p 'y-or-n-p)           ; yes == y
69 (show-paren-mode t)                     ; On affiche les parentheses liées
70 (setq display-time-24hr-format t)       ; Heure au format 24h
71 (display-time)                          ; On affiche l'heure dans la barre
72 (setq visible-bell t)                   ; On desactive les beeps
73
74 ;; Quand vous recevez un fichier .txt d'une machine dos/windows il est
75 ;; très énervant de voir les ^M a chaque fin de ligne, utiliser M-x
76 ;; dos-unix pour vous en débarrasser. (J. Danjou)
77 (defun dos-unix ()
78   (interactive)
79   (goto-char (point-min))
80   (while (search-forward "\r" nil t) (replace-match "")))
81
82 ;; Ouverture des fichiers compresses (J. Danjou) (inutile avec Emacs22)
83 (autoload 'jka-compr-installed-p "jka-compr")
84 (if (not (jka-compr-installed-p)) (auto-compression-mode))
85
86 ;; Auto fill mode
87 (set default-major-mode 'text-mode)
88 (add-hook 'text-mode-hook 'turn-on-auto-fill)
89
90 ;; On utilise Mozilla Firefox
91 (defun browse-url-firefox-new-tab (url &optional new-window)
92   "Open URL in a new tab in Firefox."
93   ;; (interactive (browse-url-interactive-arg "URL: "))
94   (let ((cmd (shell-command-to-string
95               (concat "mozilla-firefox -a firefox -remote 'openURL("
96                       url ",new-tab)' > /dev/null"))))
97     (unless (string= "" cmd)
98       (message "Starting Firefox...")
99       (start-process (concat "firefox " url) nil "/bin/sh" "-c"
100                      (concat "mozilla-firefox " url "|| true"))
101       (message "Starting Firefox...done"))))
102
103 (setq browse-url-browser-function 'browse-url-firefox-new-tab)
104
105 ;; ,--------------
106 ;; | Les racourcis
107 ;; `--------------
108
109 (global-set-key "\C-cg" 'goto-line)     ; Avec Emacs22, M-g g fait la même chose
110 (global-set-key "\C-cp" 'ps-print-buffer-with-faces)
111
112 ;; ,----
113 ;; | Configuration pour les différants modes
114 ;; `----
115
116 ;; Ispell/Aspell
117 (setq ispell-program-name "aspell")
118 (setq ispell-dictionary "french")
119
120 ;; Pour JDE (Bug dans la sid)
121 (setq global-senator-minor-mode t)
122
123 ;; Pour TEX
124 (setq tex-dvi-view-command "evince")
125 (setq LaTeX-verbatim-environments (quote ("verbatim" "verbatim*" "lstlisting")))
126 (add-hook 'LaTeX-mode-hook 'turn-on-reftex)
127
128 ;; Pour dired
129 (setq find-file-run-dired t)
130 (setq dired-listing-switches "-l")
131 (setq dired-recursive-deletes 'top)
132
133 ;; Pour perl-mode
134 (defalias 'perl-mode 'cperl-mode)
135
136 ;; Indentation
137 (setq-default indent-tabs-mode nil)
138
139 ;; Toujours avoir nouvelle ligne en fin de fichier
140 (setq require-final-newline t)