Last active
August 29, 2015 14:07
-
-
Save bozakov/9ac93626fbd913f39430 to your computer and use it in GitHub Desktop.
My .emacs file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; installed modules: deft smooth-scrolling auto-complete elpy | |
;; nice modules: git-timemachine, smartparens, org-bullets-mode, exec-path-from-shell | |
;; set the default frame parameters | |
(setq initial-frame-alist '((width . 100) | |
(tool-bar-lines . 0) | |
(vertical-scroll-bars . nil) | |
(internal-border-width . 0))) | |
(setq default-frame-alist '((tool-bar-lines . 0) | |
(vertical-scroll-bars . nil) | |
(width . 100) (height . 40) | |
(internal-border-width . 0))) | |
;(setq backup-directory-alist `(("." . "~/.backup"))) | |
(load-theme 'dichromacy t) | |
(setq-default left-margin-width 1 right-margin-width 1) ; set margin widths | |
(electric-indent-mode 1) ; auto indent on newline | |
(electric-pair-mode 1) ; auto-insert/close bracket pairs | |
(setq show-paren-delay 1) | |
(show-paren-mode 1) ; highlight parenthesis pairs | |
; (show-smartparens-global-mode +1) ; requires smartparens | |
(set-face-background 'show-paren-match-face "#fff5e6") | |
(setq show-paren-style 'expression) ; highlight text between parens | |
(setq sentence-end-double-space nil) ; single space after periods | |
(setq tab-width 4) ; length of tab is 4 SPC | |
(setq-default case-fold-search t) ; search is case sensitive | |
(setq-default indent-tabs-mode nil) ; use spaces instead of tabs | |
(setq python-indent 4) ; also specifically for python | |
(setq default-major-mode 'text-mode) | |
(setq vc-handled-backends nil) ; disable version control bloat (use magit!) | |
(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. | |
'(TeX-PDF-mode t) | |
'(TeX-source-correlate-start-server nil) | |
'(column-number-mode t) | |
'(cua-mode 1 nil (cua-base)) | |
'(delete-selection-mode 1) | |
'(elpy-modules | |
(quote | |
(elpy-module-company elpy-module-eldoc elpy-module-flymake elpy-module-highlight-indentation elpy-module-yasnippet elpy-module-sane-defaults))) | |
'(fill-column 80) | |
'(fringe-mode (quote (0 . 0)) nil (fringe)) | |
'(global-auto-complete-mode t) | |
'(inhibit-startup-screen t) | |
'(initial-scratch-message nil) | |
'(ns-function-modifier (quote none)) | |
'(org-hide-emphasis-markers t) | |
'(org-pretty-entities t) | |
'(org-startup-folded nil) | |
'(prefer-coding-system (quote utf-8)) | |
'(preview-default-option-list (quote ("graphics"))) | |
'(ring-bell-function (quote ignore) t) | |
'(scroll-bar-mode nil) | |
'(setq mac-function-modifier) | |
'(suggest-key-bindings t) | |
'(tool-bar-mode nil) | |
'(truncate-lines t)) | |
;; allow Emacs to transfer data to the clipboard manager | |
(setq x-select-enable-clipboard-manager 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. | |
'(mode-line ((t (:foreground "#f9f9f9" :background "#bdbdbd" :box nil)))) | |
'(mode-line-inactive ((t (:foreground "#f9f9f9" :background "#666666" :box nil))))) | |
(set-face-attribute 'fringe nil :background nil :foreground "#bdbdbd") | |
(global-hl-line-mode t) ; highlight cursor line | |
(set-face-background 'hl-line "#f3f3f3") | |
(set-face-foreground 'highlight nil) ; keep syntax highlighting in the current line: | |
(set-face-attribute 'vertical-border nil :foreground "#bdbdbd") ; vertical window border | |
;; (set-frame-parameter nil 'alpha 90) ; Make the window 90% opaque | |
(fset 'yes-or-no-p 'y-or-n-p) ; yes or no prompts accept short y or n | |
(setq use-dialog-box nil) ; perform yes-or-no prompts using the echo area | |
;; add MELPA and Marmalade community repos | |
;; to refresh the package contents: M-x package-refresh-contents [RET] | |
(setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/") | |
("marmalade" . "http://marmalade-repo.org/packages/") | |
("melpa" . "http://melpa.milkbox.net/packages/") | |
("elpy" . "http://jorgenschaefer.github.io/packages/"))) | |
;; basic initialization, (require) non-ELPA packages, etc. | |
(setq package-enable-at-startup nil) | |
(package-initialize) | |
;; (require) your ELPA packages, configure them as normal below | |
;; move point from window to window using M-arrow keys | |
(when (fboundp 'windmove-default-keybindings) | |
(windmove-default-keybindings 'meta)) | |
(setq smooth-scroll-margin 5) ; requires smooth-scrolling | |
(setq mouse-wheel-scroll-amount '(1 ((shift) . 5) )) ; 1 lines per step | |
(setq mouse-wheel-follow-mouse t) | |
(setq mouse-wheel-progressive-speed t) ; accelerate scrolling | |
(setq ispell-program-name "aspell") | |
(setq ispell-list-command "list") | |
(setq ispell-dictionary "english") ; set default ispell dictionary | |
;(setq compilation-scroll-output 'first-error) ; compilation output first-error | |
;; setup files ending in ".m" to open in matlab-mode | |
(add-to-list 'auto-mode-alist '("\\.m\\'" . matlab-mode)) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; Latex | |
;(add-hook 'visual-line-mode-hook (lambda () (set-fringe-mode '(0 . 3)))) | |
;;(setq outline-minor-mode-prefix "C-c C-q") | |
;(setq TeX-parse-self t) | |
(setq TeX-master nil) | |
(setq TeX-source-correlate-method 'synctex) | |
(setq reftex-toc-split-windows-horizontally t) | |
(setq reftex-plug-into-AUCTeX t) | |
(setq reftex-ref-macro-prompt nil) ; disable "select a reference format" prompt | |
(setq visual-line-fringe-indicators '(nil right-curly-arrow)) | |
(add-hook 'LaTeX-mode-hook (lambda () | |
(add-to-list 'LaTeX-fold-macro-spec-list '("{1}" ("ac" "acs" ))) | |
(add-to-list 'LaTeX-fold-macro-spec-list '("{1}s" ("acp" "acsp" "acl"))) | |
(TeX-fold-mode t) | |
(TeX-source-correlate-mode t) | |
(outline-minor-mode t) | |
(reftex-mode t) | |
(writer-buffer) | |
(add-hook 'find-file-hook 'TeX-fold-buffer t t))) ; fold buffer when a tex file is loaded | |
;; fix TeX-error: Error occured after last TeX file closed: -file-line-error | |
;; also add some other options | |
(setq LaTeX-command-style '(("" "%(PDF)%(latex) -file-line-error -shell-escape -synctex=1 %S%(PDFout)"))) | |
;; fix lstlisting syntax coloring in latex-mode | |
(setq LaTeX-verbatim-environments-local '("Verbatim" "lstlisting")) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; deft/notational velocity: http://jblevins.org/projects/deft/ | |
(require 'cl) ; deft needs this for searching | |
(global-set-key [f8] 'deft) | |
(setq deft-directory "~/Documents/Notes") | |
(setq deft-text-mode 'markdown-mode) | |
(setq deft-use-filename-as-title t) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; Python | |
;;(add-hook 'python-mode-hook 'elpy-enable) ;; enable elpy | |
(elpy-enable) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; org-mode | |
(add-hook 'org-mode-hook 'visual-line-mode) ; do not truncate lines use soft line wrapping | |
(add-hook 'org-mode-hook 'flyspell-mode) | |
(add-hook 'org-mode-hook 'org-indent-mode) | |
(add-hook 'org-mode-hook 'org-bullets-mode) | |
;org key bindings clash with windmove-default-keybindings | |
(eval-after-load "org" | |
'(progn | |
;(define-key org-mode-map (kbd "<M-S-right>") 'org-shiftmetaright) | |
; remove keybinding | |
(define-key org-mode-map (kbd "<M-up>") nil) | |
(define-key org-mode-map (kbd "<M-down>") nil) | |
(define-key org-mode-map (kbd "<M-right>") nil) | |
(define-key org-mode-map (kbd "<M-left>") nil) | |
(define-key org-mode-map (kbd "<M-s-up>") 'org-metaup) | |
(define-key org-mode-map (kbd "<M-s-down>") 'org-metadown) | |
(define-key org-mode-map (kbd "<M-s-left>") 'org-metaleft) | |
(define-key org-mode-map (kbd "<M-s-right>") 'org-metaright))) | |
;(setq whitespace-style '(face lines-tail)) | |
(setq whitespace-line-column 80) ;; limit line length | |
(add-hook 'whitespace-mode-hook (lambda () | |
(set-face-background | |
'whitespace-line "#f0f0f0"))) | |
;; check OS type | |
(cond | |
;;;; Microsoft Windows;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
((string-equal system-type "windows-nt") | |
) | |
;;;; Mac OSX ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
((string-equal system-type "darwin") | |
;; OSX map the the left alt key with META and the right alt key with ALT | |
(setq mac-option-key-is-meta t) | |
(setq mac-right-option-modifier nil) | |
(exec-path-from-shell-initialize) ; load shell environmant variables | |
(global-set-key (kbd "s-w") 'kill-this-buffer) | |
(global-set-key (kbd "s-^") 'other-frame) | |
(global-unset-key (kbd "s-q")) ;; don't quit on cmd-q | |
;; AUCTeX from homebrew | |
(add-to-list 'load-path "/usr/local/share/emacs/site-lisp") | |
(require 'tex-site) | |
(load "auctex.el" nil t t) | |
(load "preview-latex.el" nil t t) | |
(add-to-list 'default-frame-alist '(font . "Menlo-12")) ; default font | |
(setq buffer-face-mode-face '(:family "Cousine" :height 130)) | |
(set-face-attribute 'variable-pitch nil :family "Helvetica") | |
;; use Skim as default pdf viewer Skim's displayline is used for | |
;; forward search (from .tex to .pdf) option -b highlights the | |
;; current line; option -g opens Skim in the background | |
(setq TeX-view-program-selection '((output-pdf "Skim"))) | |
(setq TeX-view-program-list | |
'(("Skim" "/Applications/Skim.app/Contents/SharedSupport/displayline -b %n %o %b") | |
("Preview" "open -a Preview.app %o"))) | |
) | |
;;;; Linux ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
((string-equal system-type "gnu/linux") | |
;; configure synonyms/thesaurus | |
;;(setq synonyms-file "~/.emacs.d/mthesaur.txt") | |
;;(setq synonyms-cache-file "~/.emacs.d/mthesaur.cache") | |
;;(require 'synonyms) | |
(thesaurus-set-bhl-api-key-from-file "~/.emacs.d/BigHugeLabs.key") | |
(setq TeX-view-program-list '(("Evince" "evince --page-index=%(outpage) %o") | |
("xdg" "xdg-open"))) | |
(setq TeX-view-program-selection '((output-pdf "Evince"))) | |
(add-to-list 'default-frame-alist '(font . "DejaVu Sans Mono-10")) | |
(setq buffer-face-mode-face '(:family "Liberation Mono" :height 130)) | |
(set-face-attribute 'variable-pitch nil :family "Sans Serif") | |
(eval-after-load "ispell" | |
'(add-to-list 'ispell-local-dictionary-alist | |
'("deutsch8" "[a-zA-ZäöüßÄÖÜ]" "[^a-zA-ZäöüßÄÖÜ]" "[']" t | |
("-C" "-d" "de_DE-neu.multi") | |
"~latin1" iso-8859-1))) | |
) | |
) | |
;; enable fancy mode line https://github.com/milkypostman/powerline | |
;; (powerline-default-theme) | |
;; kill the current visible buffer without confirmation | |
(global-set-key (kbd "C-x k") 'kill-this-buffer) | |
(global-set-key (kbd "s-+") 'text-scale-increase) ;; increase font size | |
(global-set-key (kbd "s--") 'text-scale-decrease) | |
;; switch buffers with cmd+alt arrows | |
(global-set-key (kbd "s-<right>") 'next-buffer) | |
(global-set-key (kbd "s-<left>") 'previous-buffer) | |
(global-set-key (kbd "s-<down>") 'buffer-menu) | |
(global-set-key (kbd "s-<up>") 'buffer-menu) | |
;; see: describe-bindings for configured bindings | |
(global-set-key (kbd "M-S-q") 'unfill-paragraph) | |
(global-set-key (kbd "C-c SPC") 'just-one-space) | |
(add-hook 'LaTeX-mode-hook 'LaTeX-mode-bindings) | |
(add-hook 'visual-line-mode-hook 'visual-line-mode-fun) | |
(defun LaTeX-mode-bindings () | |
"add custom keys for LaTeX-mode" | |
(local-set-key (kbd "<S-s-mouse-1>") 'TeX-view) | |
(local-set-key (kbd "M-S-q") 'TeX-fold-clearout-paragraph)) | |
(defun visual-line-mode-fun () | |
"add functions and custom keys for visual-line-mode" | |
(local-set-key (kbd "M-q") 'unfill-and-fold)) | |
(defun writer-buffer () | |
"enter a distraction free writer mode" | |
(interactive) | |
(buffer-width 80) | |
(buffer-face-mode t) ; or (variable-pitch-mode t) | |
(flyspell-mode t) ; enable check as you type | |
(visual-line-mode t)) | |
(defun unfill-and-fold () | |
(interactive) | |
(unfill-paragraph) | |
(TeX-fold-paragraph) | |
) | |
(defun flyspell-mode-bindings () | |
"add custom keys for flyspell-mode" | |
(interactive) | |
(local-set-key (kbd "<f9>") 'thesaurus-choose-synonym-and-replace) | |
(local-set-key (kbd "<f10>") 'auto-correct-word) | |
(local-set-key (kbd "S-<f10>") 'ispell-word) | |
(local-set-key (kbd "C-S-<f10>") 'ispell-buffer)) | |
(add-hook 'flyspell-mode-hook 'flyspell-mode-bindings) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
(defun count-words (start end) | |
"Print number of words and characters in the region." | |
(interactive "r") | |
(save-excursion | |
(save-restriction | |
(narrow-to-region start end) | |
(goto-char (point-min)) | |
(message "selection contains %d words and %d characters" | |
(count-matches "\\sw+") | |
(count-matches "\\S-"))))) | |
(defalias 'word-count 'count-words) | |
(defun auto-correct-word () | |
"auto correct current word and move to the next one" | |
(interactive) | |
(let ((p (point))) | |
(flyspell-auto-correct-word) | |
(goto-char p) | |
(forward-word))) | |
(defun unfill-paragraph () | |
"takes a multi-line paragraph and makes it into a single line of text." | |
(interactive) | |
(let ((fill-column (point-max))) | |
(fill-paragraph nil))) | |
(defun buffer-margins (&optional left right) | |
"enable margins on current buffer" | |
(interactive "nleft margin: \nnright margin: ") | |
(unless left (setq left 10)) | |
(unless right (setq right 10)) | |
(set-window-margins nil left right)) | |
(defun buffer-width (&optional w) | |
"set margins on current buffer so that is has width w" | |
(interactive "nbuffer width: ") | |
(unless w (setq w 80)) | |
(let ((lr (- (window-total-width) w)) (tw (window-total-width))) | |
(setq left-margin-width (max (/ lr 2) 0) | |
right-margin-width (max (- (- tw (/ lr 2)) w) 0)) | |
;; set new widths. | |
(set-window-buffer nil (current-buffer)))) | |
;; starts the Emacs server | |
;;(require 'server) | |
;;(unless (server-running-p) (server-start)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment