(message "Loading .emacs.el") (set-language-environment 'utf-8) (set-terminal-coding-system 'utf-8) (set-keyboard-coding-system 'utf-8) ;; disable backup files (setq make-backup-files nil) ;; enable emacsclient (server-start) ;; Customize file (setq custom-file (expand-file-name "~/.emacs-customize.el")) (load custom-file) ;; Syntax highlighting (show-paren-mode t) ;; Configure modeline (line-number-mode t) (column-number-mode t) (display-time-mode -1) ;; Appearence (menu-bar-mode -1) (tool-bar-mode -1) (scroll-bar-mode -1) ;; Compilation options (setq-default compilation-read-command t compilation-ask-about-save nil compilation-window-height 6 ) ;; C++ mode (add-to-list 'auto-mode-alist '("\\.tpp$" . c++-mode)) ;; Filename completion anywhere (autoload 'comint-dynamic-complete-filename "comint" "" t) ;; iswitch : Changes the behavior of change buffer (iswitchb-mode) ;; Indent with spaces (setq-default indent-tabs-mode nil) (setq c-basic-offset 2) ;; Flyspell-mode (setq ispell-silently-savep t) (add-hook 'latex-mode-hook 'flyspell-mode) (add-hook 'LaTeX-mode-hook 'flyspell-mode) ;; Ediff in single window (setq ediff-window-setup-function 'ediff-setup-windows-plain) (setq ediff-split-window-function 'split-window-horizontally) ;; No truncate line (setq truncate-partial-width-windows nil) ;; Mode auto-fill (setq fill-column 88) (setq longlines-wrap-follows-window-size t) ;; remove trailing whitespaces when saving. (add-hook 'write-file-hooks 'delete-trailing-whitespace) ;; non-ascii extensions (setq completion-ignored-extensions '(".o" "~" ".bin" ".aux" ".ps" ".pdf")) ;; enable functions (put 'downcase-region 'disabled nil) (put 'upcase-region 'disabled nil) ;; visible beep (setq visible-bell t) ;; new functions (defun yank-pop-backward () (interactive) (yank-pop -1) ) (defun my-mark-line () (let ((beg (point))) (if (= 0 (current-column)) (forward-line 1) (end-of-line)) (push-mark) (goto-char beg))) (defun my-mark () (if (not mark-active) (my-mark-line))) (defun my-comment-region-or-line () (interactive) (my-mark) (comment-region (point) (mark))) (defun my-uncomment-region-or-line () (interactive) (my-mark) (uncomment-region (point) (mark))) (define-skeleton my-latex-em-skel "Latex emphase" nil "{\\em " _ "}") (defun my-latex-em () (interactive) (if mark-active (my-latex-em-skel) (insert "{\\em "))) (define-skeleton my-latex-tt-skel "Latex tt" nil "{\\tt " _ "}") (defun my-latex-tt () (interactive) (if mark-active (my-latex-tt-skel) (insert "{\\tt "))) (define-skeleton my-latex-bf-skel "Latex tt" nil "{\\bf " _ "}") (defun my-latex-tt () (interactive) (if mark-active (my-latex-tt-skel) (insert "{\\bf "))) (defun my-eol-to-space (beginning end) (interactive "r") (replace-string "\n" " " nil beginning end)) (defun goto-longline (line) (interactive "nGoto line: ") (beginning-of-buffer) (while (and (> line 1) (search-forward "\n")) (when (get-text-property (match-beginning 0) 'hard) (setq line (- line 1))))) (defun my-html-line () (interactive) (insert "
") (newline) (indent-for-tab-command)) (defun my-html-paragraph-to-close () (let ((context (save-excursion (sgml-get-context)))) (if context (string= (sgml-tag-name (car (last context))) "p")))) (defun my-html-list-item-to-close () (let ((context (save-excursion (sgml-get-context)))) (if context (string= (sgml-tag-name (car (last context))) "li")))) (defun my-html-paragraph () (interactive) (if (my-html-paragraph-to-close) (insert "

\n

") (if (my-html-list-item-to-close) (insert "\n

  • ") (insert "\n

    "))) (indent-for-tab-command)) (defun my-kill-word-or-tag () (interactive) (if (string= "tag" (car (sgml-lexical-context))) (sgml-delete-tag 1) (kill-word 1))) (defun my-browse-buffer () (interactive) (save-buffer) (shell-command (concat "$BROWSER file://" buffer-file-name))) (defun my-toggle-menu-and-scrollbar () "Toggles both menu-bar-mode and scroll-bar-mode" (interactive) (if menu-bar-mode (progn (menu-bar-mode -1) (tool-bar-mode -1) (scroll-bar-mode -1)) (progn (menu-bar-mode 1) (tool-bar-mode 1) (scroll-bar-mode 1)))) (defun my-goto-tag () (interactive) (if (= 0 (current-column)) (find-tag "" t) (find-tag (find-tag-default) ))) (defun my-goto-tag-other-window () (interactive) (if (= 0 (current-column)) (find-tag-other-window "" t) (find-tag-other-window (find-tag-default) ))) (message "Loading Bindings") (cua-mode t) (global-set-key (kbd "C-S-a") 'mark-whole-buffer) ;; should be C-a but ... (global-set-key (kbd "C-b") 'iswitchb-buffer) (global-set-key (kbd "C-S-b") '(lambda () (interactive) (iswitchb-buffer-other-window) (other-window -1))) (global-set-key (kbd "") 'list-buffers) (global-set-key (kbd "C-f") 'isearch-forward) (global-set-key (kbd "C-/") 'my-comment-region-or-line) (global-set-key (kbd "C-\\") 'my-uncomment-region-or-line) (global-set-key (kbd "C-j") 'fill-paragraph) (global-set-key (kbd "C-l") 'goto-line) (global-set-key (kbd "C-S-l") 'recenter) (global-set-key (kbd "C-o") 'find-file) (global-set-key (kbd "C-S-o") 'find-file-other-window) (global-set-key (kbd "C-q") 'save-buffers-kill-emacs) (global-set-key (kbd "C-r") 'query-replace) (global-set-key (kbd "C-s") 'save-buffer) (global-set-key (kbd "C-S-s") 'save-some-buffers) (global-set-key (kbd "M-s") 'write-file) (global-set-key (kbd "C-w") 'kill-buffer) (global-set-key (kbd "C-M-e") 'insert-euro-symbol) (global-set-key (kbd "C-?") 'help-command) (global-set-key (kbd "C-%") 'transpose-chars) (global-set-key (kbd "C-§") 'my-eol-to-space) (global-set-key (kbd "") 'other-window) (global-set-key (kbd "") '(lambda () (interactive) (other-window -1))) (global-set-key (kbd "") '(lambda () (interactive) (other-window -1))) (global-set-key (kbd "") 'revert-buffer) (global-set-key (kbd "") 'flyspell-buffer) (global-set-key (kbd "") 'flyspell-mode) (global-set-key (kbd "") 'compile) (global-set-key (kbd "") 'recompile) (global-set-key (kbd "") 'next-error) (global-set-key (kbd "") 'previous-error) (global-set-key (kbd "") 'my-toggle-menu-and-scrollbar) (global-set-key (kbd "") 'pop-tag-mark) (global-set-key (kbd "") 'my-goto-tag) (global-set-key (kbd "") 'my-goto-tag-other-window) (global-set-key (kbd "") 'find-tag) (global-set-key (kbd "") 'comint-dynamic-complete-filename) (global-set-key (kbd "") 'comint-dynamic-complete-filename) (global-set-key (kbd "") 'comint-dynamic-complete-filename) (global-set-key (kbd "C-_") 'split-window-vertically) (global-set-key (kbd "C-|") 'split-window-horizontally) (global-set-key (kbd "M-SPC") 'dabbrev-expand) (global-set-key (kbd "M-e") 'ediff-buffers) ;; FLY-SPELL (add-hook 'flyspell-mode-hook '(lambda () (local-set-key (kbd "C-k") 'flyspell-auto-correct-previous-word) )) ;; LATEX (add-hook 'latex-mode-hook '(lambda () (local-set-key (kbd "M-s") 'write-file) (local-set-key (kbd "S-SPC") "~") (local-set-key (kbd "C-(") 'latex-insert-block) (local-set-key (kbd "C-)") 'latex-close-block) (local-set-key (kbd "C-'") 'my-latex-em) (local-set-key (kbd "C-%") 'my-latex-tt) (local-set-key (kbd "C-*") 'my-latex-bf) ; (longlines-mode t) (local-set-key (kbd "C-l") 'goto-longline) )) (add-hook 'server-visit-hook '(lambda () (local-set-key (kbd "C-w") 'server-edit) )) ;; HTML (add-hook 'php-mode-user-hook '(lambda () (local-set-key (kbd "M-m") 'html-mode) )) (add-hook 'html-mode-hook '(lambda () (local-set-key (kbd "M-m") 'php-mode) (local-set-key (kbd "M-s") 'write-file) (local-set-key (kbd "M-TAB") 'sgml-tags-invisible) (local-set-key (kbd "C-S-v") 'my-browse-buffer) (local-set-key (kbd "S-SPC") " ") (local-set-key (kbd "C-<") "« ") (local-set-key (kbd "C->") " »") (local-set-key (kbd "C-(") 'sgml-tag) (local-set-key (kbd "C-)") 'sgml-close-tag) (local-set-key (kbd "") 'my-html-line) (local-set-key (kbd "") 'my-html-paragraph) (local-set-key (kbd "C-1") 'html-headline-1) (local-set-key (kbd "C-2") 'html-headline-2) (local-set-key (kbd "C-3") 'html-headline-3) (local-set-key (kbd "C-4") 'html-headline-4) (local-set-key (kbd "C-5") 'html-headline-5) (local-set-key (kbd "C-6") 'html-headline-6) (local-set-key (kbd "C-é") 'sgml-name-8bit-mode) (local-set-key (kbd "") 'my-kill-word-or-tag) (local-set-key (kbd "") 'sgml-skip-tag-backward) (local-set-key (kbd "") 'sgml-skip-tag-forward) (local-set-key (kbd "C-&") 'sgml-name-char) (local-set-key (kbd "C-? SPC") 'sgml-tag-help) (local-set-key [tab] 'indent-for-tab-command) (local-set-key (kbd "C-i") 'html-image) (local-set-key (kbd "C-n") 'html-name-anchor) (local-set-key (kbd "C-h") 'html-href-anchor) (local-set-key (kbd "C-#") 'html-ordered-list) (local-set-key (kbd "C-*") 'html-unordered-list) )) (set-language-environment 'utf-8) (set-terminal-coding-system 'utf-8) (set-keyboard-coding-system 'utf-8)