;; Default font and font-size (set-face-attribute 'default nil :family "Consolas" :height 100 :weight 'normal :width 'normal) (setq line-spacing '0.25) ;; Set text centered and wrapped (setq visual-fill-column-width 120) (setq visual-fill-column-center-text t) ;; Give a little bit of whitespace around the edges of emacs. Delete this line if you ;; don't care for it. (set-frame-parameter nil 'internal-border-width 10) (require 'package) (push '("marmalade" . "http://marmalade-repo.org/packages/") package-archives ) (push '("melpa" . "http://melpa.milkbox.net/packages/") package-archives) (package-initialize) (setq tab-width 2) ; or any other preferred value (defvaralias 'c-basic-offset 'tab-width) (defvaralias 'cperl-indent-level 'tab-width) (setq-default tab-width 2) (require 'key-chord) (key-chord-mode 1) ; disable Paredit mode (add-hook 'clojure-mode-hook (lambda () (paredit-mode nil))) ;; Kill some keybindings that we don't need, because we are EVIL! (global-unset-key (kbd "M-d")) ;; kill the emacs version of dw (global-unset-key (kbd "M-h")) ;; kill the emacs version of mark paragraph? ;; These customizations change the way emacs looks and disable/enable ;; some user interface elements. Some useful customizations are ;; commented out, and begin with the line "CUSTOMIZE". These are more ;; a matter of preference and may require some fiddling to match your ;; preferences ;; Turn off the menu bar at the top of each frame because it's distracting (menu-bar-mode -1) ;; Show line numbers (global-linum-mode) ;; You can uncomment this to remove the graphical toolbar at the top. After ;; awhile, you won't need the toolbar. ;; (when (fboundp 'tool-bar-mode) ;; (tool-bar-mode -1)) (require 'paren) (setq show-paren-style 'parenthesis) (show-paren-mode +1) ;; Don't show native OS scroll bars for buffers because they're redundant (when (fboundp 'scroll-bar-mode) (scroll-bar-mode -1)) ;; Color Themes ;; Read http://batsov.com/articles/2012/02/19/color-theming-in-emacs-reloaded/ ;; for a great explanation of emacs color themes. ;; https://www.gnu.org/software/emacs/manual/html_node/emacs/Custom-Themes.html ;; for a more technical explanation. (add-to-list 'custom-theme-load-path "~/.emacs.d/themes") (add-to-list 'load-path "~/.emacs.d/themes") ;; (load-theme 'tomorrow-night-bright t) ;; (load-theme 'subatomic t) ;; (load-theme 'monokai t) ;; (load-theme 'zenburn t) ;; (load-theme 'paper t) ;; (load-theme 'material-light t) ;; (load-theme 'material t) (load-theme 'leuven t) ;; (load-theme 'spacegray t) ;; Fontify the whole line for headings (with a background color). Works well with Leuven theme (setq org-fontify-whole-heading-line t) (require 'org) (require 'evil-org) (require 'evil-leader) ;; An override for this function to make inserting headings work ;; a bit better. Makes O respect heading content. (defun shellhead/smart-org-insert () "Creates a new heading if currently in a heading, creates a new list item if in a list, or creates a newline if neither." (interactive) (cond ((org-at-heading-p) (org-insert-heading-respect-content) (evil-insert-state)) ((org-at-item-p) (org-insert-item)))) (defun evil-org-eol-call (fun) "Go to end of line and call provided function. FUN function callback" (end-of-visible-line) (funcall fun) (evil-append nil) ) ;; You need this line or else your cursor stays black, which is horrible for the dark themes: ;; http://stackoverflow.com/questions/9900232/changing-color-themes-emacs-24-order-matters?rq=1 (setq evil-default-cursor t) ;; (global-visual-line-mode 1) ;; (global-visual-fill-column-mode) (defun org-tree-open-in-right-frame () (interactive) (org-tree-to-indirect-buffer) (windmove-right)) (add-hook 'org-mode-hook (lambda () ;; TODO: set fringe/gutter mode and theme by mode, no fringe and white them for ORG files ;; fringe and black theme for code (fringe-mode 0) ;; (set-frame-parameter (window-frame) 'background-mode 'dark) ;; (enable-theme 'leuven) (visual-fill-column-mode) (define-key evil-normal-state-local-map [S-return] (quote org-tree-open-in-right-frame)) (define-key evil-normal-state-local-map [return] (quote org-tree-to-indirect-buffer)) (local-set-key [3 25] 'org-copy-subtree))) ;; 24 25 is ctrl-c ctrl-y ;; This hides the bullets/asterisks in Org mode ;; Comment out if you want them back (defun hide-org-bullets () (font-lock-add-keywords 'org-mode `(("\\(?:^\\(?1:\\*+\\)[[:blank:]]\\)" (0 (progn (compose-region (match-beginning 1) (match-end 1) (pcase (length (match-string 1)) (1 ?\u2219) (2 ?\u2022) (3 ?\u25c9) (_ ?\u25CB))) nil)))))) (hide-org-bullets) (setq org-startup-indented t) (setq evil-want-C-u-scroll t) (require 'evil) (evil-mode t) (key-chord-define evil-insert-state-map "jk" 'evil-normal-state) (key-chord-define evil-insert-state-map "kj" 'evil-normal-state) (define-key evil-normal-state-map (kbd "\C-p") nil) (define-key evil-normal-state-map (kbd "\C-u") 'evil-scroll-up) (define-key evil-normal-state-map (kbd "q") nil) (define-key evil-normal-state-map (kbd "") nil) (define-key evil-normal-state-map (kbd ",") nil) (define-key evil-motion-state-map (kbd "") nil) (define-key evil-normal-state-map (kbd "C-h") 'evil-window-left) ;; (define-key evil-normal-state-map (kbd "C-j") 'evil-window-down) (define-key evil-normal-state-map (kbd "C-k") 'evil-window-up) (define-key evil-normal-state-map (kbd "C-l") 'evil-window-right) (define-key evil-insert-state-map (kbd "C-h") 'evil-window-left) ;; (define-key evil-insert-state-map (kbd "C-j") 'evil-window-down) (define-key evil-insert-state-map (kbd "C-k") 'evil-window-up) (define-key evil-insert-state-map (kbd "C-l") 'evil-window-right) ;;Make evil-mode up/down operate in screen lines instead of logical lines (define-key evil-normal-state-map (kbd "j") 'evil-next-visual-line) (define-key evil-normal-state-map (kbd "k") 'evil-previous-visual-line) (define-key evil-visual-state-map (kbd "j") 'evil-next-visual-line) (define-key evil-visual-state-map (kbd "k") 'evil-previous-visual-line) ;; turn off evil mode for the repl (add-to-list 'evil-emacs-state-modes 'REPL) (evil-leader/set-leader "") (global-evil-leader-mode) (evil-leader/set-key "f" 'helm-find-files "b" 'helm-mini "w" 'persp-switch "-" 'text-scale-decrease "+" 'text-scale-increase "d" 'neotree-toggle "x" 'helm-M-x "r" 'helm-M-x "k" 'kill-buffer) ;; leader maps for org mode (evil-leader/set-key-for-mode 'org-mode "t" 'org-show-todo-tree "a" 'org-agenda "c" 'org-archive-subtree "l" 'evil-org-open-links "o" 'org-open-at-point "e" 'show-branches ) ;; Uncomment the lines below by removing semicolons and play with the ;; values in order to set the width (in characters wide) and height ;; (in lines high) Emacs will have whenever you start it ;; (setq initial-frame-alist '((top . 0) (left . 0) (width . 177) (height . 53))) (add-to-list 'default-frame-alist '(fullscreen . maximized)) ;; These settings relate to how emacs interacts with your operating system (setq ;; makes killing/yanking interact with the clipboard x-select-enable-clipboard t ;; I'm actually not sure what this does but it's recommended? x-select-enable-primary t ;; Save clipboard strings into kill ring before replacing them. ;; When one selects something in another program to paste it into Emacs, ;; but kills something in Emacs before actually pasting it, ;; this selection is gone unless this variable is non-nil save-interprogram-paste-before-kill t ;; Shows all options when running apropos. For more info, ;; https://www.gnu.org/software/emacs/manual/html_node/emacs/Apropos.html apropos-do-all t ;; Mouse yank commands yank at point instead of at click. mouse-yank-at-point t) ;; No cursor blinking, it's distracting (blink-cursor-mode nil) ;; full path in title bar (setq-default frame-title-format "%b (%f)") ;; don't pop up font menu (global-set-key (kbd "s-t") '(lambda () (interactive))) ;; no bell (setq ring-bell-function 'ignore) ;; Open these files on start ;; (find-file "C:/Writing/main.org") (require 'helm) (require 'helm-config) ;; The default "C-x c" is quite close to "C-x C-c", which quits Emacs. ;; Changed to "C-c h". Note: We must set "C-c h" globally, because we ;; cannot change `helm-command-prefix-key' once `helm-config' is loaded. (global-set-key (kbd "C-c h") 'helm-command-prefix) (global-unset-key (kbd "C-x c")) (global-set-key (kbd "M-x") 'helm-M-x) ;; increase and decrease text size (global-set-key (kbd "C-=") 'text-scale-increase) (global-set-key (kbd "C--") 'text-scale-decrease) ;; First, Control-S is an ASCII control character -- ^s and ^S are the same character. ;; Keys are something different from characters, however, and if you are using Emacs with a window manager then you can distinguish the keys C-s and C-S-s. The latter is Control-Shift-s. ;; The problem you are hitting is that if you do not explicitly bind the shifted version of a letter key, then the shifted letter key uses the binding of the unshifted key. This is a "feature". ;; So you need to bind both C-s and C-S-s. (global-unset-key (kbd "C-s")) (global-unset-key (kbd "C-S-s")) (global-set-key (kbd "C-s") 'save-buffer) (global-set-key (kbd "C-S-s") 'another-command) (setq helm-buffers-fuzzy-matching t helm-recentf-fuzzy-match t) (setq recentf-max-menu-items 1000) (define-key helm-map (kbd "") 'helm-execute-persistent-action) ; rebind tab to run persistent action (define-key helm-map (kbd "C-i") 'helm-execute-persistent-action) ; make TAB work in terminal (define-key helm-map (kbd "C-z") 'helm-select-action) ; list actions using C-z (setq helm-split-window-in-side-p t ; open helm buffer inside current window, not occupy whole other window helm-move-to-line-cycle-in-source t ; move to end or beginning of source when reaching top or bottom of source. helm-ff-search-library-in-sexp t ; search for library in `require' and `declare-function' sexp. helm-scroll-amount 8 ; scroll 8 lines other window using M-/M- helm-ff-file-name-history-use-recentf t) (helm-mode 1) (require 'neotree) (global-set-key [f8] 'neotree-toggle) (add-hook 'neotree-mode-hook (lambda () (define-key evil-normal-state-local-map (kbd "TAB") 'neotree-enter) (define-key evil-normal-state-local-map (kbd "SPC") 'neotree-enter) (define-key evil-normal-state-local-map (kbd "q") 'neotree-hide) (define-key evil-normal-state-local-map (kbd "RET") 'neotree-enter))) ;; make Evil's sentence navigation closer to Vim's (setf sentence-end-double-space nil) ;; This speeds up emacs loading files, TODO: but maybe we need it? (remove-hook 'find-file-hooks 'vc-find-file-hook) (setq-default word-wrap t) (defun replace-smart-quotes (beg end) "Replace 'smart quotes' in buffer or region with ascii quotes." (interactive "r") (format-replace-strings '(("\x201C" . "\"") ("\x201D" . "\"") ("\x2018" . "'") ("\x2019" . "'")) nil beg end)) ;;;;; Theme ;;;;; ;; Cycle through this set of themes (setq my-themes '(leuven spacegray)) (setq my-cur-theme nil) ;; automatically disable current theme before load-theme (defadvice load-theme (before theme-dont-propagate activate) (mapcar #'disable-theme custom-enabled-themes)) (defun switch-to-org-theme () "Cycle through a list of themes, my-themes" (interactive) (when my-cur-theme (disable-theme my-cur-theme) (setq my-themes (append my-themes (list my-cur-theme)))) (setq my-cur-theme (pop my-themes)) (load-theme my-cur-theme t)) ;; (defun switch-to-dev-theme () ;; Bind this to C-t ;; (global-set-key (kbd "C-9") 'cycle-my-theme) (defun redisplay-command () (interactive) (redisplay)) (global-set-key [f6] #'redisplay-command)