(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 "
") (if (my-html-list-item-to-close) (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 "