Rewrote/improved core initfiles
This commit is contained in:
parent
8fa05453eb
commit
f484556a8d
8 changed files with 345 additions and 151 deletions
21
init.el
21
init.el
|
@ -1,10 +1,12 @@
|
||||||
;;;; core.el - Emacs for the jaded Vimmer
|
;;
|
||||||
|
;; [Emacs for the jaded vimmer]
|
||||||
;;
|
;;
|
||||||
;; Author: Henrik Lissner <henrik@lissner>
|
;; Author: Henrik Lissner <henrik@lissner>
|
||||||
;; URL: https://github.com/hlissner/emacs.d
|
;; URL: https://github.com/hlissner/emacs.d
|
||||||
;;
|
;;
|
||||||
;; These settings set up a very vim-like experience, with some of emacs goodness
|
;; These settings set up a very vim-like experience, with some of emacs goodness
|
||||||
;; squeezed in between the cracks.
|
;; squeezed in between the cracks.
|
||||||
|
;;
|
||||||
|
|
||||||
(cd "~") ; Default directory, instead of /
|
(cd "~") ; Default directory, instead of /
|
||||||
(setq load-prefer-newer t) ; Always load newest byte code
|
(setq load-prefer-newer t) ; Always load newest byte code
|
||||||
|
@ -36,8 +38,8 @@
|
||||||
core-packages ; package init & management
|
core-packages ; package init & management
|
||||||
core-ui ; Look and behavior of the emacs UI
|
core-ui ; Look and behavior of the emacs UI
|
||||||
core-editor ; Text/code editor settings and behavior
|
core-editor ; Text/code editor settings and behavior
|
||||||
core-project ; Project navigation settings & packages
|
|
||||||
core-osx ; OSX-specific settings & functions
|
core-osx ; OSX-specific settings & functions
|
||||||
|
core-project ; Project navigation settings & packages
|
||||||
core-keymaps ; Global & local keybindings for all modes
|
core-keymaps ; Global & local keybindings for all modes
|
||||||
|
|
||||||
;; Editor essentials
|
;; Editor essentials
|
||||||
|
@ -51,10 +53,11 @@
|
||||||
|
|
||||||
;;;; Modes ;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;; Modes ;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
; (associate-mode '(".rb" "RakeFile") 'ruby-mode)
|
(associate-mode 'ruby-mode '(".rb" "RakeFile"))
|
||||||
; (associate-mode '(".md" ".markdown") 'markdown-mode)
|
(associate-mode 'markdown-mode '(".md" ".markdown"))
|
||||||
; (associate-mode ".lua" 'lua-mode)
|
(associate-mode 'scss-mode ".scss")
|
||||||
; (associate-mode ".scss" 'scss-mode)
|
;; (associate-mode 'lua-mode ".lua")
|
||||||
; (associate-mode ".yml" 'yaml-mode)
|
;; (associate-mode 'yaml-mode ".yml")
|
||||||
; (associate-mode '(".js" ".json") 'js2-mode)
|
;; (associate-mode 'js2-mode '(".js" ".json"))
|
||||||
; (associate-mode ".py" 'python-mode)
|
;; (associate-mode 'python-mode ".py")
|
||||||
|
;; (associate-mode 'web-mode '(".html" ".htm" ".phtml" ".tpl" ".tpl.php" ".erb"))
|
||||||
|
|
|
@ -10,35 +10,34 @@
|
||||||
evil-exchange ; exchanging two text objects (gx/gX)
|
evil-exchange ; exchanging two text objects (gx/gX)
|
||||||
evil-space ; mimics ; and , for f, F, t, T w/ space
|
evil-space ; mimics ; and , for f, F, t, T w/ space
|
||||||
evil-visualstar ; visual-based * and #
|
evil-visualstar ; visual-based * and #
|
||||||
|
|
||||||
evil-ex-registers ; paste from registers in ex commands
|
evil-ex-registers ; paste from registers in ex commands
|
||||||
|
|
||||||
auto-complete ; self-explanity
|
auto-complete ; self-explanity
|
||||||
auto-complete-config ; its default config
|
auto-complete-config ; its default config
|
||||||
fuzzy ; fuzzy search engine for auto-complete
|
fuzzy ; fuzzy search engine for auto-complete
|
||||||
|
|
||||||
autopair ; delimiter auto-closing
|
autopair ; delimiter auto-closing
|
||||||
yasnippet
|
yasnippet ; snippets: expand with tab
|
||||||
rainbow-delimiters ; colored matching parenthesis
|
rainbow-delimiters ; colored matching parenthesis
|
||||||
rainbow-mode ; highlight color codes
|
rainbow-mode ; highlight color codes
|
||||||
highlight-indentation ; visual indentation guides
|
highlight-indentation ; visual indentation guides
|
||||||
|
|
||||||
diminish ; shrinks/removes modeline elements
|
diminish ; shrinks/removes modeline elements
|
||||||
saveplace ; restore cursor position on buffer load
|
saveplace ; restore cursor position on buffer load
|
||||||
volatile-highlights ; temporarily highlight changes on undo/yank
|
volatile-highlights ; temporarily highlight changes on undo/yank
|
||||||
anzu ; display current + total matches searching
|
anzu ; display current + total matches searching
|
||||||
smex ; less M-x cruft
|
smex ; less M-x cruft
|
||||||
|
|
||||||
rotate-text ; like vim-switch
|
rotate-text ; like vim-switch
|
||||||
uniquify ; unique buffer names for identical filenames
|
uniquify ; unique buffer names for identical filenames
|
||||||
recentf ; access to list of recent files
|
recentf ; access to list of recent files
|
||||||
|
key-chord ; for mapping key chords in insert mode
|
||||||
ediff
|
ediff
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|
||||||
;;;; Editor behavior ;;;;;;;;;;;;;;;;
|
;;;; Editor behavior ;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
(smex-initialize)
|
;;;#key-chord
|
||||||
|
(key-chord-mode 1)
|
||||||
|
(setq key-chord-two-keys-delay 0.5)
|
||||||
|
|
||||||
(electric-indent-mode +1)
|
(electric-indent-mode +1)
|
||||||
(global-hl-line-mode +1) ; highlight the line
|
(global-hl-line-mode +1) ; highlight the line
|
||||||
(setq blink-matching-paren nil) ; disable blink-matching-paren
|
(setq blink-matching-paren nil) ; disable blink-matching-paren
|
||||||
|
@ -51,7 +50,7 @@
|
||||||
(setq-default truncate-lines t)
|
(setq-default truncate-lines t)
|
||||||
(setq truncate-partial-width-windows nil)
|
(setq truncate-partial-width-windows nil)
|
||||||
|
|
||||||
;; Line numbers & rainbow delimiters in all code-related major modes
|
;; Prettify code-related major modes
|
||||||
(add-hook 'prog-mode-hook 'linum-on)
|
(add-hook 'prog-mode-hook 'linum-on)
|
||||||
(add-hook 'prog-mode-hook 'rainbow-delimiters-mode)
|
(add-hook 'prog-mode-hook 'rainbow-delimiters-mode)
|
||||||
(add-hook 'prog-mode-hook #'highlight-indentation-mode)
|
(add-hook 'prog-mode-hook #'highlight-indentation-mode)
|
||||||
|
@ -59,46 +58,62 @@
|
||||||
;; Remove trailing whitespace
|
;; Remove trailing whitespace
|
||||||
(add-hook 'before-save-hook 'delete-trailing-whitespace)
|
(add-hook 'before-save-hook 'delete-trailing-whitespace)
|
||||||
|
|
||||||
;; Dynamic linum with +1 padding
|
;;;#smex
|
||||||
(defadvice linum-update-window (around linum-dynamic activate)
|
(smex-initialize)
|
||||||
(let* ((w (length (number-to-string (count-lines (point-min) (point-max)))))
|
;; Hook up smex to auto-update, rather than update on every run
|
||||||
(linum-format (concat "%" (number-to-string (+ w 1)) "d "))) ad-do-it))
|
(defun smex-update-after-load (unused)
|
||||||
|
(when (boundp 'smex-cache) (smex-update)))
|
||||||
|
(add-hook 'after-load-functions 'smex-update-after-load)
|
||||||
|
|
||||||
|
|
||||||
;;;; Init plugins ;;;;;;;;;;;;;;;;;;;
|
;;;; Init plugins ;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
;;;#evil
|
||||||
|
(setq evil-want-C-i-jump t)
|
||||||
|
(setq evil-want-C-u-scroll t)
|
||||||
|
|
||||||
(global-evil-leader-mode)
|
(global-evil-leader-mode)
|
||||||
(global-evil-matchit-mode 1)
|
(global-evil-matchit-mode 1)
|
||||||
(global-evil-surround-mode 1)
|
(global-evil-surround-mode 1)
|
||||||
|
|
||||||
(evil-exchange-install)
|
(evil-exchange-install)
|
||||||
|
|
||||||
(evil-space-setup "t" ";" ",")
|
(evil-space-setup "t" ";" ",")
|
||||||
(evil-space-setup "f" ";" ",")
|
(evil-space-setup "f" ";" ",")
|
||||||
(evil-space-setup "T" "," ";")
|
(evil-space-setup "T" "," ";")
|
||||||
(evil-space-setup "F" "," ";")
|
(evil-space-setup "F" "," ";")
|
||||||
|
(evil-define-operator evil-destroy (beg end type register yank-handler)
|
||||||
|
(evil-delete beg end type ?_ yank-handler))
|
||||||
|
|
||||||
(yas-global-mode -1)
|
;; Enable registers in ex-mode
|
||||||
|
(define-key evil-ex-completion-map (kbd "C-r") #'evil-ex-paste-from-register)
|
||||||
|
|
||||||
;;#autopair
|
|
||||||
|
;;;#autopair
|
||||||
(autopair-global-mode)
|
(autopair-global-mode)
|
||||||
(diminish 'autopair-mode)
|
(diminish 'autopair-mode)
|
||||||
|
|
||||||
;;#anzu
|
|
||||||
|
;;;#anzu
|
||||||
(global-anzu-mode)
|
(global-anzu-mode)
|
||||||
(diminish 'anzu-mode)
|
(diminish 'anzu-mode)
|
||||||
|
|
||||||
;;#ediff
|
|
||||||
|
;;;#ediff
|
||||||
(setq ediff-window-setup-function 'ediff-setup-windows-plain)
|
(setq ediff-window-setup-function 'ediff-setup-windows-plain)
|
||||||
|
|
||||||
;;#volatile-highlights
|
|
||||||
|
;;;#volatile-highlights
|
||||||
(volatile-highlights-mode t)
|
(volatile-highlights-mode t)
|
||||||
(diminish 'volatile-highlights-mode)
|
(diminish 'volatile-highlights-mode)
|
||||||
|
|
||||||
;;#saveplace
|
|
||||||
|
;;;#saveplace
|
||||||
(setq-default save-place t)
|
(setq-default save-place t)
|
||||||
(setq save-place-file (expand-file-name "saveplace" my-tmp-dir))
|
(setq save-place-file (expand-file-name "saveplace" my-tmp-dir))
|
||||||
|
|
||||||
;;#savehist
|
|
||||||
|
;;;#savehist
|
||||||
(setq savehist-additional-variables
|
(setq savehist-additional-variables
|
||||||
;; search entries
|
;; search entries
|
||||||
'(search ring regexp-search-ring)
|
'(search ring regexp-search-ring)
|
||||||
|
@ -108,20 +123,28 @@
|
||||||
savehist-file (expand-file-name "savehist" my-tmp-dir))
|
savehist-file (expand-file-name "savehist" my-tmp-dir))
|
||||||
(savehist-mode 1)
|
(savehist-mode 1)
|
||||||
|
|
||||||
;;#diminish
|
|
||||||
; (diminish 'whole-line-or-region-mode)
|
;;;#diminish
|
||||||
(diminish 'undo-tree-mode)
|
(diminish 'undo-tree-mode)
|
||||||
(diminish 'highlight-indentation-mode)
|
(diminish 'highlight-indentation-mode)
|
||||||
|
|
||||||
;;#uniquify
|
|
||||||
|
|
||||||
|
;;;#uniquify
|
||||||
(setq uniquify-buffer-name-style 'forward)
|
(setq uniquify-buffer-name-style 'forward)
|
||||||
(setq uniquify-separator "/")
|
(setq uniquify-separator "/")
|
||||||
(setq uniquify-after-kill-buffer-p t) ; rename after killing uniquified
|
(setq uniquify-after-kill-buffer-p t) ; rename after killing uniquified
|
||||||
(setq uniquify-ignore-buffers-re "^\\*") ; don't muck with special buffers
|
(setq uniquify-ignore-buffers-re "^\\*") ; don't muck with special buffers
|
||||||
|
|
||||||
;;#recentf
|
|
||||||
|
;;;#recentf
|
||||||
(recentf-mode 1)
|
(recentf-mode 1)
|
||||||
(setq recentf-max-menu-items 50)
|
(setq recentf-max-menu-items 25)
|
||||||
|
|
||||||
|
|
||||||
|
;;;#yasnippet
|
||||||
|
(yas-global-mode -1)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;;;; Auto-completion ;;;;;;;;;;;;;;
|
;;;; Auto-completion ;;;;;;;;;;;;;;
|
||||||
|
@ -139,6 +162,38 @@
|
||||||
(add-to-list 'ac-sources 'ac-source-filename)
|
(add-to-list 'ac-sources 'ac-source-filename)
|
||||||
(add-to-list 'ac-sources 'ac-source-files-in-current-dir))
|
(add-to-list 'ac-sources 'ac-source-files-in-current-dir))
|
||||||
|
|
||||||
|
;; Tell ido not to care about case
|
||||||
|
(setq completion-ignore-case t)
|
||||||
|
|
||||||
|
;;; Filters ido-matches setting acronynm matches in front of the results
|
||||||
|
(defadvice ido-set-matches-1 (after ido-smex-acronym-matches activate)
|
||||||
|
(if (and (fboundp 'smex-already-running) (smex-already-running)
|
||||||
|
(> (length ido-text) 1))
|
||||||
|
(let ((regex (concat "^" (mapconcat 'char-to-string ido-text "[^-]*-")))
|
||||||
|
(acronym-matches (list))
|
||||||
|
(remove-regexes '("-menu-")))
|
||||||
|
;; Creating the list of the results to be set as first
|
||||||
|
(dolist (item items)
|
||||||
|
(if (string-match (concat regex "[^-]*$") item) ;; strict match
|
||||||
|
(add-to-list 'acronym-matches item)
|
||||||
|
(if (string-match regex item) ;; appending relaxed match
|
||||||
|
(add-to-list 'acronym-matches item t))))
|
||||||
|
|
||||||
|
;; Filtering ad-return-value
|
||||||
|
(dolist (to_remove remove-regexes)
|
||||||
|
(setq ad-return-value
|
||||||
|
(delete-if (lambda (item)
|
||||||
|
(string-match to_remove item))
|
||||||
|
ad-return-value)))
|
||||||
|
|
||||||
|
;; Creating resulting list
|
||||||
|
(setq ad-return-value
|
||||||
|
(append acronym-matches
|
||||||
|
ad-return-value))
|
||||||
|
|
||||||
|
(delete-dups ad-return-value)
|
||||||
|
(reverse ad-return-value))))
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
(provide 'core-editor)
|
(provide 'core-editor)
|
||||||
|
|
|
@ -1,29 +1,25 @@
|
||||||
(require-package 'key-chord)
|
|
||||||
(key-chord-mode 1)
|
|
||||||
(setq key-chord-two-keys-delay 0.5)
|
|
||||||
|
|
||||||
;; Global keymaps ;;;;;;;;;;;;;;;
|
;; Global keymaps ;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
(gmap (kbd "C-x C-p") 'package-list-packages)
|
|
||||||
(gmap (kbd "M-x") 'smex)
|
(gmap (kbd "M-x") 'smex)
|
||||||
(gmap (kbd "M-X") 'smex-major-mode-commands)
|
(gmap (kbd "M-X") 'smex-major-mode-commands)
|
||||||
|
(gmap (kbd "C-x C-p") 'package-list-packages)
|
||||||
|
|
||||||
(if (is-osx) (progn
|
(if (is-osx) (progn
|
||||||
(gmap (kbd "s-+") 'text-scale-increase)
|
(gmap (kbd "s-+") 'text-scale-increase)
|
||||||
(gmap (kbd "s--") 'text-scale-decrease)
|
(gmap (kbd "s--") 'text-scale-decrease)
|
||||||
|
|
||||||
(map (kbd "C-c o") 'send-to-finder)
|
(map (kbd "C-c o") 'send-dir-to-finder)
|
||||||
(map (kbd "C-c u") 'send-to-transmit)
|
(map (kbd "C-c u") 'send-to-transmit)
|
||||||
(map (kbd "C-c l") 'send-to-launchbar)
|
(map (kbd "C-c l") 'send-to-launchbar)
|
||||||
(map (kbd "C-c L") 'send-dir-to-launchbar)
|
(map (kbd "C-c L") 'send-dir-to-launchbar)
|
||||||
(emap 'normal (kbd "C-c e") 'eval-buffer)
|
|
||||||
(emap 'visual (kbd "C-c e") 'eval-region)
|
;; Evaluating elisp
|
||||||
|
(nmap (kbd "C-c x") 'eval-buffer)
|
||||||
|
(vmap (kbd "C-c x") 'eval-region)
|
||||||
))
|
))
|
||||||
|
|
||||||
(map (kbd "C-c t") (lambda() (interactive) (eshell t)))
|
(map (kbd "C-c t") (lambda() (interactive) (eshell t))) ; open in terminal
|
||||||
(map (kbd "C-c g") 'magit-status)
|
(map (kbd "C-c g") 'magit-status)
|
||||||
(map (kbd "<C-tab>") 'evil-numbers/inc-at-pt)
|
|
||||||
(map (kbd "<S-C-tab>") 'evil-numbers/dec-at-pt)
|
|
||||||
|
|
||||||
(map (kbd "s-o") 'ido-find-file)
|
(map (kbd "s-o") 'ido-find-file)
|
||||||
(map (kbd "s-p") 'projectile-switch-project)
|
(map (kbd "s-p") 'projectile-switch-project)
|
||||||
|
@ -31,98 +27,188 @@
|
||||||
(map (kbd "s-F") 'projectile-ag)
|
(map (kbd "s-F") 'projectile-ag)
|
||||||
(map (kbd "s-R") 'projectile-recentf)
|
(map (kbd "s-R") 'projectile-recentf)
|
||||||
|
|
||||||
(define-key evil-ex-completion-map (kbd "C-r") #'evil-ex-paste-from-register)
|
|
||||||
|
|
||||||
|
|
||||||
;; Local keymaps ;;;;;;;;;;;;;;;;
|
;; Local keymaps ;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
(evil-leader/set-leader ",")
|
(evil-leader/set-leader ",")
|
||||||
(evil-leader/set-key
|
(evil-leader/set-key
|
||||||
"e" 'my-conf-edit
|
"e" 'ido-find-file
|
||||||
"E" 'my-conf-find
|
"E" 'my-init
|
||||||
"/" 'imenu
|
"p" 'projectile-switch-project
|
||||||
"\\" 'toggle-speedbar
|
"f" 'projectile-find-file
|
||||||
";" 'helm-imenu
|
"F" 'projectile-ag
|
||||||
"," 'ido-switch-buffer
|
"r" 'projectile-recentf
|
||||||
"=" 'align-regexp)
|
"M" 'open-major-mode-conf
|
||||||
|
"g" 'magit-status
|
||||||
|
"/" 'imenu
|
||||||
|
"\\" 'toggle-speedbar
|
||||||
|
";" 'helm-imenu
|
||||||
|
"," 'ido-switch-buffer
|
||||||
|
"=" 'align-regexp
|
||||||
|
"x" 'kill-this-buffer
|
||||||
|
"X" 'kill-buffer-and-window
|
||||||
|
)
|
||||||
|
|
||||||
(nmap ";" 'exil-ex)
|
(nmap
|
||||||
|
";" 'evil-ex
|
||||||
|
|
||||||
|
; Moving rows rather than lines (in case of wrapping)
|
||||||
|
"j" 'evil-next-visual-line'
|
||||||
|
"k" 'evil-previous-visual-line
|
||||||
|
|
||||||
|
"X" 'evil-destroy ; Delete without yanking
|
||||||
|
"Y" 'copy-to-end-of-line ; nnoremap Y y$
|
||||||
|
"zz" 'kill-this-buffer ; Close buffer
|
||||||
|
|
||||||
|
"]b" 'previous-buffer
|
||||||
|
"[b" 'next-buffer
|
||||||
|
|
||||||
|
; winner-mode: window layout undo/redo (see init-core.el)
|
||||||
|
(kbd "C-w u") 'winner-undo
|
||||||
|
(kbd "C-w C-r") 'winner-redo
|
||||||
|
|
||||||
|
; Increment/decrement number under cursor
|
||||||
|
(kbd "<C-tab>") 'evil-numbers/inc-at-pt
|
||||||
|
(kbd "<S-C-tab>") 'evil-numbers/dec-at-pt
|
||||||
|
|
||||||
|
; Map split navigation with arrow keys
|
||||||
|
(kbd "<up>") 'windmove-up
|
||||||
|
(kbd "<down>") 'windmove-down
|
||||||
|
(kbd "<left>") 'windmove-left
|
||||||
|
(kbd "<right>") 'windmove-right
|
||||||
|
)
|
||||||
|
|
||||||
|
(vmap
|
||||||
|
; vnoremap < <gv
|
||||||
|
"<" (lambda ()
|
||||||
|
(interactive)
|
||||||
|
(evil-shift-left (region-beginning) (region-end))
|
||||||
|
(evil-normal-state)
|
||||||
|
(evil-visual-restore))
|
||||||
|
; vnoremap > >gv
|
||||||
|
">" (lambda ()
|
||||||
|
(interactive)
|
||||||
|
(evil-shift-right (region-beginning) (region-end))
|
||||||
|
(evil-normal-state)
|
||||||
|
(evil-visual-restore))
|
||||||
|
)
|
||||||
|
|
||||||
|
(imap
|
||||||
|
; Auto-completion
|
||||||
|
(kbd "C-SPC") 'ac-fuzzy-complete
|
||||||
|
(kbd "C-S-SPC") 'ac-quick-help
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Commenting lines
|
||||||
|
(nmap "gcc" 'evilnc-comment-or-uncomment-lines)
|
||||||
|
(vmap "gc" 'evilnc-comment-or-uncomment-lines)
|
||||||
|
|
||||||
|
;; Rotate-text (see elisp/rotate-text.el)
|
||||||
|
(nmap (kbd "RET") 'rotate-word-at-point)
|
||||||
|
(vmap (kbd "RET") 'rotate-region)
|
||||||
|
|
||||||
|
;; Enable TAB to do matchit
|
||||||
|
(evil-define-key 'normal evil-matchit-mode-map (kbd "TAB") 'evilmi-jump-items)
|
||||||
|
|
||||||
;; Easy escape from insert mode
|
;; Easy escape from insert mode
|
||||||
(ichmap "jj" 'evil-normal-state)
|
(ichmap "jj" 'evil-normal-state)
|
||||||
|
|
||||||
;; Moving rows rather than lines (in case of wrapping)
|
|
||||||
(nmap "j" 'evil-next-visual-line)
|
|
||||||
(nmap "k" 'evil-previous-visual-line)
|
|
||||||
|
|
||||||
;; Commenting lines
|
;;;; Org-Mode ;;;;;;;;;;;;;;;;;;;
|
||||||
(nmap "gcc" 'evilnc-comment-or-uncomment-lines)
|
|
||||||
(vmap "gc" 'evilnc-comment-or-uncomment-lines)
|
|
||||||
|
|
||||||
;; Enable TAB to do matchit (won't work in visual)
|
(evil-define-key 'normal evil-org-mode-map
|
||||||
(evil-define-key 'normal evil-matchit-mode-map (kbd "TAB") 'evilmi-jump-items)
|
"gh" 'outline-up-heading
|
||||||
|
"gj" (if (fboundp 'org-forward-same-level) ;to be backward compatible with older org version
|
||||||
|
'org-forward-same-level
|
||||||
|
'org-forward-heading-same-level)
|
||||||
|
"gk" (if (fboundp 'org-backward-same-level)
|
||||||
|
'org-backward-same-level
|
||||||
|
'org-backward-heading-same-level)
|
||||||
|
"gl" 'outline-next-visible-heading
|
||||||
|
"t" 'org-todo
|
||||||
|
"T" '(lambda () (interactive) (evil-org-eol-call (lambda() (org-insert-todo-heading nil))))
|
||||||
|
"H" 'org-beginning-of-line
|
||||||
|
"L" 'org-end-of-line
|
||||||
|
";t" 'org-show-todo-tree
|
||||||
|
"o" '(lambda () (interactive) (evil-org-eol-call 'always-insert-item))
|
||||||
|
"O" '(lambda () (interactive) (evil-org-eol-call 'org-insert-heading))
|
||||||
|
"$" 'org-end-of-line
|
||||||
|
"^" 'org-beginning-of-line
|
||||||
|
"<" 'org-metaleft
|
||||||
|
">" 'org-metaright
|
||||||
|
";a" 'org-agenda
|
||||||
|
"-" 'org-cycle-list-bullet
|
||||||
|
(kbd "TAB") 'org-cycle)
|
||||||
|
|
||||||
;; Delete without yanking
|
;; normal & insert state shortcuts.
|
||||||
(evil-define-operator evil-destroy (beg end type register yank-handler)
|
(mapc (lambda (state)
|
||||||
(evil-delete beg end type ?_ yank-handler))
|
(evil-define-key state evil-org-mode-map
|
||||||
(nmap "X" 'evil-destroy)
|
(kbd "M-l") 'org-metaright
|
||||||
(nmap "Y" 'copy-to-end-of-line) ; nnoremap Y y$
|
(kbd "M-h") 'org-metaleft
|
||||||
(nmap "zz" 'kill-this-buffer) ; Close buffer
|
(kbd "M-k") 'org-metaup
|
||||||
|
(kbd "M-j") 'org-metadown
|
||||||
;; vnoremap < <gv
|
(kbd "M-L") 'org-shiftmetaright
|
||||||
;; vnoremap > >gv
|
(kbd "M-H") 'org-shiftmetaleft
|
||||||
(vmap (kbd "<")
|
(kbd "M-K") 'org-shiftmetaup
|
||||||
(lambda ()
|
(kbd "M-J") 'org-shiftmetadown
|
||||||
(interactive)
|
(kbd "M-o") '(lambda () (interactive)
|
||||||
(evil-shift-left (region-beginning) (region-end))
|
(evil-org-eol-call
|
||||||
(evil-normal-state)
|
'(lambda()
|
||||||
(evil-visual-restore)))
|
(org-insert-heading)
|
||||||
(vmap (kbd ">")
|
(org-metaright))))
|
||||||
(lambda ()
|
(kbd "M-t") '(lambda () (interactive)
|
||||||
(interactive)
|
(evil-org-eol-call
|
||||||
(evil-shift-right (region-beginning) (region-end))
|
'(lambda()
|
||||||
(evil-normal-state)
|
(org-insert-todo-heading nil)
|
||||||
(evil-visual-restore)))
|
(org-metaright))))
|
||||||
|
))
|
||||||
;; Sets fn-delete to be right-delete
|
'(normal insert))
|
||||||
(imap (kbd "<kp-delete>") 'evil-delete-char)
|
|
||||||
|
|
||||||
;; Buffer navigation
|
|
||||||
(nmap "[b" 'previous-buffer)
|
|
||||||
(nmap "]b" 'next-buffer)
|
|
||||||
|
|
||||||
;; winner-mode: window layout undo/redo (see init-core.el)
|
|
||||||
(nmap (kbd "C-w u") 'winner-undo)
|
|
||||||
(nmap (kbd "C-w C-r") 'winner-redo)
|
|
||||||
|
|
||||||
;; Make ESC quit all the things
|
|
||||||
(nmap [escape] 'keyboard-quit)
|
|
||||||
(vmap [escape] 'keyboard-quit)
|
|
||||||
(define-key minibuffer-local-map [escape] 'minibuffer-quit)
|
|
||||||
(define-key minibuffer-local-ns-map [escape] 'minibuffer-quit)
|
|
||||||
(define-key minibuffer-local-completion-map [escape] 'minibuffer-quit)
|
|
||||||
(define-key minibuffer-local-must-match-map [escape] 'minibuffer-quit)
|
|
||||||
(define-key minibuffer-local-isearch-map [escape] 'minibuffer-quit)
|
|
||||||
(global-set-key [escape] 'evil-exit-emacs-state)
|
|
||||||
|
|
||||||
;; Restore bash-esque C-w/C-a/C-e in insert mode and the minibuffer
|
|
||||||
(dolist (x (list minibuffer-local-map evil-insert-state-map))
|
|
||||||
(define-key x (kbd "C-w") 'backward-kill-word)
|
|
||||||
(define-key x (kbd "C-a") 'move-beginning-of-line)
|
|
||||||
(define-key x (kbd "C-e") 'move-end-of-line)
|
|
||||||
(define-key x (kbd "C-u") 'backward-kill-line))
|
|
||||||
|
|
||||||
;; Auto-completion
|
|
||||||
(imap (kbd "C-SPC") 'ac-fuzzy-complete)
|
|
||||||
(imap (kbd "C-S-SPC") 'ac-quick-help)
|
|
||||||
|
|
||||||
;; see elisp/rotate-text.el
|
|
||||||
(nmap (kbd "RET") 'rotate-word-at-point)
|
|
||||||
(vmap (kbd "RET") 'rotate-region)
|
|
||||||
|
|
||||||
|
|
||||||
;;;; Ex Commands ;;;;;;;;;;;;;;;;
|
;;;; Ex Commands ;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
(cmap "e[dit]" 'ido-find-file)
|
; (cmap "e[dit]" 'find-file)
|
||||||
|
(cmap "git" 'magit-status)
|
||||||
|
|
||||||
|
|
||||||
|
;;;; Keymap fixes ;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
;; Make ESC quit all the things
|
||||||
|
(nmap [escape] 'keyboard-quit)
|
||||||
|
(vmap [escape] 'keyboard-quit)
|
||||||
|
(mapc (lambda (map)
|
||||||
|
(define-key map [escape] 'minibuffer-quit))
|
||||||
|
(list
|
||||||
|
minibuffer-local-map
|
||||||
|
minibuffer-local-ns-map
|
||||||
|
minibuffer-local-completion-map
|
||||||
|
minibuffer-local-must-match-map
|
||||||
|
minibuffer-local-isearch-map))
|
||||||
|
(global-set-key [escape] 'evil-exit-emacs-state)
|
||||||
|
;; Close help window with escape
|
||||||
|
(define-key global-map [escape] 'quit-window)
|
||||||
|
(define-key ag-mode-map [escape] 'quit-window)
|
||||||
|
|
||||||
|
;; Restore bash-esque C-w/C-a/C-e in insert mode and the minibuffer
|
||||||
|
(mapc (lambda (map)
|
||||||
|
(define-key map (kbd "C-w") 'backward-kill-word)
|
||||||
|
(define-key map (kbd "C-a") 'move-beginning-of-line)
|
||||||
|
(define-key map (kbd "C-e") 'move-end-of-line)
|
||||||
|
(define-key map (kbd "C-u") 'backward-kill-line))
|
||||||
|
(list minibuffer-local-map evil-insert-state-map))
|
||||||
|
|
||||||
|
(add-hook 'ido-setup-hook '(lambda ()
|
||||||
|
;; take that "Text is read-only" and stick it where emacs don't shine!
|
||||||
|
(define-key ido-completion-map (kbd "<backspace>") 'ido-delete-backward-updir)
|
||||||
|
(define-key ido-completion-map "\C-n" 'ido-next-match)
|
||||||
|
(define-key ido-completion-map "\C-f" 'ido-next-match)
|
||||||
|
(define-key ido-completion-map "\C-p" 'ido-prev-match)
|
||||||
|
(define-key ido-completion-map "\C-b" 'ido-prev-match)
|
||||||
|
|
||||||
|
;; Auto-complete on tab/space (why is it called ido-exit-minibuffer?)
|
||||||
|
(define-key ido-completion-map " " 'ido-exit-minibuffer)
|
||||||
|
;; TAB, by default, inserts a literal \t ಠ_ಠ
|
||||||
|
(define-key ido-completion-map (kbd "TAB") 'ido-exit-minibuffer)))
|
||||||
|
|
||||||
|
;;
|
||||||
(provide 'core-keymaps)
|
(provide 'core-keymaps)
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
(if (is-osx) (progn
|
(if (is-osx) (progn
|
||||||
|
|
||||||
;; Ignore .DS_Store files with ido mode
|
;; Ignore .DS_Store files with ido mode
|
||||||
(add-to-list 'ido-ignore-files "\\.DS_Store")
|
(add-to-list 'completion-ignored-extensions ".DS_Store")
|
||||||
|
|
||||||
(if window-system (progn
|
(if window-system (progn
|
||||||
(setq ns-use-native-fullscreen nil)
|
(setq ns-use-native-fullscreen nil)
|
||||||
|
@ -45,6 +45,9 @@
|
||||||
(imap (kbd "<s-left>") 'move-beginning-of-line)
|
(imap (kbd "<s-left>") 'move-beginning-of-line)
|
||||||
(imap (kbd "<s-right>") 'move-end-of-line)
|
(imap (kbd "<s-right>") 'move-end-of-line)
|
||||||
(imap (kbd "<s-backspace>") 'backward-kill-line)
|
(imap (kbd "<s-backspace>") 'backward-kill-line)
|
||||||
|
|
||||||
|
;; Fixes delete
|
||||||
|
(imap (kbd "<kp-delete>") 'delete-char)
|
||||||
)
|
)
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|
|
@ -43,18 +43,18 @@
|
||||||
;; package for it.
|
;; package for it.
|
||||||
;;
|
;;
|
||||||
;; TODO: Rewrite this
|
;; TODO: Rewrite this
|
||||||
(defun associate-mode (ext mode)
|
(defun associate-mode (mode ext &optional env-pkg)
|
||||||
(let* ((mode_name (symbol-name mode))
|
(let* ((mode_name (symbol-name mode))
|
||||||
(env_mode_name (concat "env-" mode_name ".el"))
|
(env_mode_name (major-mode-module-name))
|
||||||
(mode_path (expand-file-name env_mode_name my-modules-dir)))
|
(mode_path (major-mode-module-path)))
|
||||||
|
|
||||||
(condition-case nil
|
(condition-case nil (init-package mode t) (error nil))
|
||||||
(init-package mode t)
|
|
||||||
(error nil))
|
|
||||||
|
|
||||||
(autoload mode mode_name)
|
(autoload mode mode_name)
|
||||||
(if (file-exists-p mode_path)
|
(if env-pkg
|
||||||
(autoload mode env_mode_name)))
|
(require-package env-pkg)
|
||||||
|
(if (file-exists-p mode_path) (require-package (intern env_mode_name)))
|
||||||
|
))
|
||||||
|
|
||||||
(if (typep ext 'list)
|
(if (typep ext 'list)
|
||||||
(dolist (e ext)
|
(dolist (e ext)
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
(require-packages
|
(require-packages
|
||||||
'(ido-ubiquitous ; enhances ido-everywhere
|
'(ido-ubiquitous ; enhances ido-everywhere
|
||||||
projectile ; project search (like ctrlp)
|
projectile ; project search (like ctrlp)
|
||||||
helm ; augments search of, well, anything
|
helm ; augments search of, well, anything
|
||||||
grizzl ; better searching engine for projectile
|
grizzl ; better searching engine for projectile
|
||||||
ag ; the_silver_searcher support
|
ag ; the_silver_searcher support
|
||||||
sr-speedbar ; Speedbar, w/o the separate frame
|
sr-speedbar ; speedbar, w/o the separate frame
|
||||||
flx-ido ; Enhances ido's flex matching
|
flx-ido ; enhances ido's flex matching
|
||||||
|
ido-vertical-mode ; vertical listing for ido completion
|
||||||
))
|
))
|
||||||
|
|
||||||
;;#dired
|
;;#dired
|
||||||
|
@ -31,6 +32,7 @@
|
||||||
(set-keymap-parent ido-buffer-completion-map ido-common-completion-map)
|
(set-keymap-parent ido-buffer-completion-map ido-common-completion-map)
|
||||||
|
|
||||||
(ido-mode 1)
|
(ido-mode 1)
|
||||||
|
(ido-vertical-mode 1)
|
||||||
(ido-everywhere 1)
|
(ido-everywhere 1)
|
||||||
(flx-ido-mode 1)
|
(flx-ido-mode 1)
|
||||||
(setq ido-use-faces nil
|
(setq ido-use-faces nil
|
||||||
|
@ -42,6 +44,15 @@
|
||||||
ido-enable-tramp-completion t
|
ido-enable-tramp-completion t
|
||||||
ido-enable-last-directory-history t)
|
ido-enable-last-directory-history t)
|
||||||
|
|
||||||
|
(defadvice completion--file-name-table (after ignoring-backups-f-n-completion activate)
|
||||||
|
"Filter out results when they match `completion-ignored-extensions'."
|
||||||
|
(let ((res ad-return-value))
|
||||||
|
(if (and (listp res)
|
||||||
|
(stringp (car res))
|
||||||
|
(cdr res)) ; length > 1, don't ignore sole match
|
||||||
|
(setq ad-return-value
|
||||||
|
(completion-pcm--filename-try-filter res)))))
|
||||||
|
|
||||||
;;#projectile
|
;;#projectile
|
||||||
(setq projectile-completion-system 'grizzl
|
(setq projectile-completion-system 'grizzl
|
||||||
projectile-enable-caching t)
|
projectile-enable-caching t)
|
||||||
|
|
|
@ -20,6 +20,11 @@
|
||||||
(if (fboundp 'fringe-mode)
|
(if (fboundp 'fringe-mode)
|
||||||
(fringe-mode 4))
|
(fringe-mode 4))
|
||||||
|
|
||||||
|
;; Dynamic linum with +1 padding
|
||||||
|
(defadvice linum-update-window (around linum-dynamic activate)
|
||||||
|
(let* ((w (length (number-to-string (count-lines (point-min) (point-max)))))
|
||||||
|
(linum-format (concat "%" (number-to-string (+ w 1)) "d "))) ad-do-it))
|
||||||
|
|
||||||
|
|
||||||
;;;; GUI Settings ;;;;;;;;;;;;;;;;;;;;;
|
;;;; GUI Settings ;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
|
51
init/core.el
51
init/core.el
|
@ -1,6 +1,7 @@
|
||||||
(require 'cl)
|
(require 'cl)
|
||||||
|
|
||||||
;; Emacs under-the-hood
|
;; Emacs under-the-hood
|
||||||
|
(setq redisplay-dont-pause t)
|
||||||
(prefer-coding-system 'utf-8)
|
(prefer-coding-system 'utf-8)
|
||||||
(setq-default gc-cons-threshold 50000000) ; avoid garbage collection (default is only 400k)
|
(setq-default gc-cons-threshold 50000000) ; avoid garbage collection (default is only 400k)
|
||||||
(setq make-backup-files nil) ; Don't want any backup files
|
(setq make-backup-files nil) ; Don't want any backup files
|
||||||
|
@ -18,6 +19,11 @@
|
||||||
(when (fboundp 'winner-mode) (winner-mode 1))
|
(when (fboundp 'winner-mode) (winner-mode 1))
|
||||||
(setq linum-delay t)
|
(setq linum-delay t)
|
||||||
|
|
||||||
|
(defadvice save-buffers-kill-emacs (around no-query-kill-emacs activate)
|
||||||
|
"Prevent annoying \"Active processes exist\" query when you quit Emacs."
|
||||||
|
(flet ((process-list ())) ad-do-it))
|
||||||
|
|
||||||
|
|
||||||
;;;; My personal minor mode ;;;;;;;;
|
;;;; My personal minor mode ;;;;;;;;
|
||||||
|
|
||||||
(defvar my-mode-map (make-sparse-keymap))
|
(defvar my-mode-map (make-sparse-keymap))
|
||||||
|
@ -37,14 +43,24 @@
|
||||||
(abort-recursive-edit)))
|
(abort-recursive-edit)))
|
||||||
|
|
||||||
;; File navigation defuns
|
;; File navigation defuns
|
||||||
(defun my-conf-edit ()
|
(defun my-init ()
|
||||||
(interactive)
|
(interactive)
|
||||||
(find-file (expand-file-name "init.el" my-dir)))
|
(find-file (expand-file-name "init.el" my-dir)))
|
||||||
|
|
||||||
(defun my-conf-find ()
|
(defun my-init-find ()
|
||||||
(interactive)
|
(interactive)
|
||||||
(projectile-find-file-in-directory my-dir))
|
(projectile-find-file-in-directory my-dir))
|
||||||
|
|
||||||
|
;; Open the modules/env-{major-mode-name}.el file
|
||||||
|
(defun open-major-mode-conf ()
|
||||||
|
(interactive)
|
||||||
|
(let ((path (major-mode-module-path)))
|
||||||
|
(if (file-exists-p path)
|
||||||
|
(find-file path)
|
||||||
|
(progn
|
||||||
|
(find-file path)
|
||||||
|
(message (concat "Mode (" (major-mode-name) ") doesn't have a module! Creating it..."))))))
|
||||||
|
|
||||||
;;
|
;;
|
||||||
(defun copy-to-end-of-line ()
|
(defun copy-to-end-of-line ()
|
||||||
(interactive)
|
(interactive)
|
||||||
|
@ -59,22 +75,37 @@
|
||||||
(sr-speedbar-toggle)
|
(sr-speedbar-toggle)
|
||||||
(sr-speedbar-refresh-turn-off))
|
(sr-speedbar-refresh-turn-off))
|
||||||
|
|
||||||
|
(defun major-mode-name ()
|
||||||
|
(symbol-name major-mode))
|
||||||
|
(defun major-mode-module-name ()
|
||||||
|
(concat "env-" (major-mode-name)))
|
||||||
|
(defun major-mode-module-path ()
|
||||||
|
(expand-file-name (concat (major-mode-module-name) ".el") my-modules-dir))
|
||||||
|
|
||||||
|
|
||||||
;;;; Macros ;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;; Macros ;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
;; Vimmish keymapping shortcuts
|
;; Vimmish keymapping shortcuts
|
||||||
(defmacro gmap (key command) `(global-set-key ,key ,command))
|
(defmacro nmap (&rest body)
|
||||||
(defmacro nmap (key command) `(define-key evil-normal-state-map ,key ,command))
|
`(evil-define-key 'normal my-mode-map ,@body))
|
||||||
(defmacro vmap (key command) `(define-key evil-visual-state-map ,key ,command))
|
(defmacro vmap (&rest body)
|
||||||
(defmacro imap (key command) `(define-key evil-insert-state-map ,key ,command))
|
`(evil-define-key 'visual my-mode-map ,@body))
|
||||||
(defmacro ichmap (key command) `(key-chord-define evil-insert-state-map ,key ,command))
|
(defmacro imap (&rest body)
|
||||||
(defmacro cmap (ex function) `(evil-ex-define-cmd ,ex ,function))
|
`(evil-define-key 'insert my-mode-map ,@body))
|
||||||
|
|
||||||
|
;; Global mapping
|
||||||
|
(defmacro gmap (key command)
|
||||||
|
`(global-set-key ,key ,command))
|
||||||
|
;; insert-mode key-chord mapping
|
||||||
|
(defmacro ichmap (key command)
|
||||||
|
`(key-chord-define evil-insert-state-map ,key ,command))
|
||||||
|
;; defines ex commands
|
||||||
|
(defmacro cmap (ex function)
|
||||||
|
`(evil-ex-define-cmd ,ex ,function))
|
||||||
|
|
||||||
;; This one's unique for my own special mappings
|
;; This one's unique for my own special mappings
|
||||||
(defmacro map (key command)
|
(defmacro map (key command)
|
||||||
`(define-key my-mode-map ,key ,command))
|
`(define-key my-mode-map ,key ,command))
|
||||||
(defmacro emap (mode key command)
|
|
||||||
`(evil-define-key ,mode my-mode-map ,key ,command))
|
|
||||||
|
|
||||||
(defmacro is-osx () '(eq system-type 'darwin))
|
(defmacro is-osx () '(eq system-type 'darwin))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue