ambevar-dotfiles/.emacs.d/init.el

150 lines
6.1 KiB
EmacsLisp
Raw Normal View History

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Emacs config
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2014-03-08 11:48:35 +01:00
;; Global variables.
(defvar my-keys-minor-mode-map (make-keymap)
"Keymap for my-keys-minor-mode. See its docstring for more
details.")
(define-minor-mode my-keys-minor-mode
"A minor mode so that all bindings assingned on the
my-keys-minor-mode-map override undesired major modes
bindings. We use a minor mode to override global keys. This is
also rather useful to list all personal global bindings: just
rgrep `my-keys-minor-mode-map' over `~/.emacs.d'.
Example: to assign some-function to C-i, use
(define-key my-keys-minor-mode-map (kbd \"C-i\") 'some-function)"
t " my-keys" 'my-keys-minor-mode-map)
(add-hook 'minibuffer-setup-hook (lambda () (my-keys-minor-mode 0) ) )
2013-07-03 14:04:51 +02:00
(defvar emacs-cache-folder "~/.cache/emacs/"
"Cache folder is everything we do not want to track along with
the configuration files.")
2013-06-16 14:27:14 +02:00
(if (not (file-directory-p emacs-cache-folder))
2013-06-12 22:56:30 +02:00
(make-directory emacs-cache-folder t))
2014-02-12 17:37:43 +01:00
;; Load config easily.
(add-to-list 'load-path "~/.emacs.d")
2013-06-12 23:40:20 +02:00
;; Local plugin folder for quick install. All files in this folder will be
2014-03-08 11:48:35 +01:00
;; accessible to Emacs config. This is done to separate the versioned config
;; files from the external packages. For instance you can put package.el in
;; there for Emacs <24.
(add-to-list 'load-path "~/.emacs.d/local")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Load main config
2014-03-08 11:48:35 +01:00
(require 'functions nil t)
(require 'main nil t)
(require 'theme nil t)
(require 'personal nil t)
2014-02-12 17:48:29 +01:00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Vanilla modes
;; Major modes
2014-03-20 13:53:57 +01:00
(add-hook 'awk-mode-hook (lambda () (require 'mode-awk)))
(add-hook 'c++-mode-hook (lambda () (require 'mode-cc)))
(add-hook 'c-mode-hook (lambda () (require 'mode-cc)))
(add-hook 'latex-mode-hook (lambda () (require 'mode-latex)))
(add-hook 'makefile-mode-hook (lambda () (require 'mode-makefile)))
(add-hook 'perl-mode-hook (lambda () (require 'mode-perl)))
(add-hook 'python-mode-hook (lambda () (require 'mode-python)))
(add-hook 'sh-mode-hook (lambda () (require 'mode-sh)))
(add-hook 'tex-mode-hook (lambda () (require 'mode-tex)))
(add-hook 'texinfo-mode-hook (lambda () (require 'mode-texinfo)))
;; Minor modes
(add-hook 'dired-mode-hook (lambda () (require 'mode-dired)))
(add-hook 'ediff-mode-hook (lambda () (require 'mode-ediff)))
(add-hook 'eshell-mode-hook (lambda () (require 'mode-eshell)))
(add-hook 'gud-mode-hook (lambda () (require 'mode-gud)))
(add-hook 'octave-mode-hook (lambda () (require 'mode-octave)))
(add-hook 'org-mode-hook (lambda () (require 'mode-org)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Third-party modes
2014-03-08 11:48:35 +01:00
(when (require 'package nil t)
(add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/"))
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/"))
2014-03-22 12:16:20 +01:00
(setq package-user-dir (concat emacs-cache-folder "elpa"))
2014-03-08 11:48:35 +01:00
(package-initialize))
2014-03-08 15:58:29 +01:00
(load-external "\\.l\\'" 'flex-mode nil 'c-mode)
(load-external "\\.yy?\\'" 'bison-mode nil 'c-mode)
(load-external "\\.vert\\'\\|\\.frag\\'\\|\\.glsl\\'" 'glsl-mode nil 'c-mode)
(load-external "\\.go\\'" 'go-mode)
(load-external "\\.dot\\'" 'graphviz-dot-mode)
(add-hook 'graphviz-dot-mode-hook (lambda () (require 'mode-dot)))
2014-03-08 15:58:29 +01:00
(load-external "\\.lua\\'" 'lua-mode nil 'sh-mode)
2014-03-25 09:23:12 +01:00
(add-hook 'lua-mode-hook (lambda () (require 'mode-lua)))
2014-03-08 15:58:29 +01:00
(load-external "\\.md\\'\\|\\.markdown\\'" 'markdown-mode)
;; If we need more option, add it to a dedicated file.
(add-hook 'markdown-mode-hook (lambda () (set (make-local-variable 'paragraph-start) "
")))
2014-03-10 10:37:43 +01:00
(load-external "\\.wiki\\'" 'mediawiki 'mediawiki-mode)
(add-hook 'mediawiki-mode-hook (lambda () (require 'mode-mediawiki)))
;; .po support. This mode has no hooks.
2014-03-08 15:58:29 +01:00
(load-external "\\.po\\'\\|\\.po\\." 'po-mode)
(when (fboundp 'po-find-file-coding-system)
(modify-coding-system-alist 'file "\\.po\\'\\|\\.po\\." 'po-find-file-coding-system))
2014-02-22 19:13:39 +01:00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2014-02-23 18:07:42 +01:00
;; Third-party tools
(autoload 'guess-style-set-variable "guess-style" nil t)
(autoload 'guess-style-guess-variable "guess-style")
(autoload 'guess-style-guess-all "guess-style" nil t)
(setq guess-style-info-mode 1)
(add-hook 'prog-mode-hook (lambda () (ignore-errors (guess-style-guess-all))))
2014-02-22 19:13:39 +01:00
2014-02-22 19:18:13 +01:00
(autoload 'pdf-view "tool-pdf" nil t)
(autoload 'pdf-compress "tool-pdf" nil t)
(autoload 'itranslate "tool-itranslate" nil t)
(autoload 'itranslate-lines "tool-itranslate" nil t)
2014-02-24 14:28:05 +01:00
(autoload 'itranslate-region "tool-itranslate" nil t)
2014-02-23 18:07:42 +01:00
2014-03-08 11:48:35 +01:00
(when (require 'multiple-cursors nil t)
(setq mc/list-file (concat emacs-cache-folder "mc-lists.el"))
;; Load the file at the new location.
(load mc/list-file t)
(global-unset-key (kbd "C-<down-mouse-1>"))
(define-key my-keys-minor-mode-map (kbd "C-<mouse-1>") 'mc/add-cursor-on-click)
(define-key my-keys-minor-mode-map (kbd "C-x M-r") 'mc/edit-lines)
(define-key my-keys-minor-mode-map (kbd "C-x M-m") 'mc/mark-more-like-this-extended)
(define-key my-keys-minor-mode-map (kbd "C-x M-l") 'mc/mark-all-like-this-dwim))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; We need to put it at the end to make sure it doesn't get overriden by other
;; minor modes.
(my-keys-minor-mode 1)
;; Local hook. You can use it to set system specific variables, such as the
;; external web browser or pdf viewer. You can also backport feature for old
;; Emacs. For instance:
; (setq pdf-viewer "evince")
; (setq pdf-viewer-args nil)
; (mapcar
; (lambda (mode-hook)
; (add-hook mode-hook (lambda () (run-hooks 'prog-mode-hook))))
; '(asm-mode-hook awk-mode-hook c++-mode-hook c-mode-hook
; emacs-lisp-mode-hook lisp-mode-hook lua-mode-hook
; makefile-mode-hook octave-mode-hook perl-mode-hook
; python-mode-hook scheme-mode-hook sh-mode-hook))
2014-03-12 10:36:37 +01:00
(load "local" t t)
;; End of file
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;