Refactor initfiles

This commit is contained in:
Henrik Lissner 2014-07-22 23:24:02 -04:00
parent f66f741804
commit 8c9c7f3bde
13 changed files with 72 additions and 59 deletions

1
ac-dict/global Normal file
View file

@ -0,0 +1 @@
henrik@lissner.net

2
ac-dict/js-mode Normal file
View file

@ -0,0 +1,2 @@
JSON.stringify
JSON.parse

7
ac-dict/js2-mode Normal file
View file

@ -0,0 +1,7 @@
JSON
JSON.stringify
JSON.parse
LaunchBar
include
HTTP
File

View file

@ -30,7 +30,7 @@
;; Font & color scheme ;; Font & color scheme
(load-theme 'brin t) (load-theme 'brin t)
(defvar my-font "Ubuntu Mono-15") (defvar my-font "Inconsolata-14")
;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;
;; Bootstrap ;; Bootstrap
@ -69,7 +69,7 @@
(associate-mode 'markdown-mode '("\\.md\\'" "\\.markdown\\'" "/README")) (associate-mode 'markdown-mode '("\\.md\\'" "\\.markdown\\'" "/README"))
(associate-mode 'scss-mode '("\\.scss\\'")) (associate-mode 'scss-mode '("\\.scss\\'"))
(associate-mode 'org-mode '("\\.org\\'" "\\.gtd\\'") t) (associate-mode 'org-mode '("\\.org\\'" "\\.gtd\\'") t)
(associate-mode 'js-mode '("\\.js\\'") t) (associate-mode 'js-mode '("\\.js\\'") t)
(associate-mode 'json-mode '("\\.json\\'" "\\.jshintrc\\'")) (associate-mode 'json-mode '("\\.json\\'" "\\.jshintrc\\'"))
(associate-mode 'web-mode '("\\.\\(p\\)?htm\\(l\\)?\\'" "\\.tpl\\(\\.php\\)?\\'" "\\.erb\\'")) (associate-mode 'web-mode '("\\.\\(p\\)?htm\\(l\\)?\\'" "\\.tpl\\(\\.php\\)?\\'" "\\.erb\\'"))
(associate-mode 'lua-mode '("\\.lua\\'")) (associate-mode 'lua-mode '("\\.lua\\'"))

View file

@ -35,13 +35,12 @@
;;;; Editor behavior ;;;;;;;;;;;;;;;; ;;;; Editor behavior ;;;;;;;;;;;;;;;;
(setq initial-scratch-buffer nil) ; empty scratch buffer (setq initial-scratch-buffer nil) ; empty scratch buffer
(associate-mode 'text-mode '("\\`\\*Messages\\*\\'") t)
(electric-indent-mode +1) ; auto-indent on RET (electric-indent-mode +1) ; auto-indent on RET
(global-hl-line-mode +1) ; highlight the line (global-hl-line-mode +1) ; highlight the line
(setq-default (setq-default
tab-width 4 ; set tab width to 4 for all buffers tab-width 4 ; set tab width to 4 for all buffers
indent-tabs-mode t ; use tabs, not spaces indent-tabs-mode nil ; use tabs, not spaces
tab-always-indent nil) tab-always-indent nil)
;; do not soft-wrap lines ;; do not soft-wrap lines
@ -129,6 +128,5 @@
(add-to-list 'recentf-exclude "\\.revive\\'") (add-to-list 'recentf-exclude "\\.revive\\'")
(setq recentf-auto-cleanup 'never) (setq recentf-auto-cleanup 'never)
;; ;;
(provide 'core-editor) (provide 'core-editor)

View file

@ -20,6 +20,7 @@
(when window-system (when window-system
(gmap (kbd "s-+") 'text-scale-increase) (gmap (kbd "s-+") 'text-scale-increase)
(gmap (kbd "s--") 'text-scale-decrease) (gmap (kbd "s--") 'text-scale-decrease)
(gmap (kbd "s-<f12>") 'toggle-frame-fullscreen)
(gmap (kbd "s-/") 'evilnc-comment-or-uncomment-lines) (gmap (kbd "s-/") 'evilnc-comment-or-uncomment-lines)
(gmap (kbd "s-w") 'kill-buffer-and-window) (gmap (kbd "s-w") 'kill-buffer-and-window)
@ -119,6 +120,12 @@
(evil-visual-restore)) (evil-visual-restore))
) )
(imap
(kbd "s-j") 'evil-join
(kbd "M-SPC") 'expand-space
(kbd "<C-return>") 'indent-new-comment-line
)
;; Commenting lines ;; Commenting lines
(nmap "gcc" 'evilnc-comment-or-uncomment-lines) (nmap "gcc" 'evilnc-comment-or-uncomment-lines)
(vmap "gc" 'evilnc-comment-or-uncomment-lines) (vmap "gc" 'evilnc-comment-or-uncomment-lines)
@ -126,9 +133,6 @@
;; Rotate-text (see elisp/rotate-text.el) ;; Rotate-text (see elisp/rotate-text.el)
(nmap "!" 'rotate-word-at-point) (nmap "!" 'rotate-word-at-point)
(vmap "!" 'rotate-region) (vmap "!" 'rotate-region)
;; (imap (kbd "RET") 'comment-indent-new-line)
;; Disable return for auto-completion, since tab does the trick
(imap (kbd "<C-return>") 'indent-new-comment-line)
;; Enable TAB to do matchit ;; Enable TAB to do matchit
(evil-define-key 'normal evil-matchit-mode-map (kbd "TAB") 'evilmi-jump-items) (evil-define-key 'normal evil-matchit-mode-map (kbd "TAB") 'evilmi-jump-items)
@ -189,15 +193,12 @@
;;;; Ex Commands ;;;;;;;;;;;;;;;; ;;;; Ex Commands ;;;;;;;;;;;;;;;;
;; (cmap "e[dit]" 'find-file) (cmap "retab" 'indent-region) ; TODO: Implement proper retab defun
;; (cmap "n[ew]" ') (cmap "msg" 'view-echo-area-messages)
(cmap "retab" 'indent-region)
;;;; Keymap fixes ;;;;;;;;;;;;;;; ;;;; Keymap fixes ;;;;;;;;;;;;;;;
(imap (kbd "s-j") '(lambda() (interactive) (evil-join-line) (evil-indent-line)))
;; Make ESC quit all the things ;; Make ESC quit all the things
(nmap [escape] 'keyboard-quit) (nmap [escape] 'keyboard-quit)
(vmap [escape] 'keyboard-quit) (vmap [escape] 'keyboard-quit)
@ -213,13 +214,12 @@
;; Close help window with escape ;; Close help window with escape
(define-key global-map [escape] 'quit-window) (define-key global-map [escape] 'quit-window)
;; Restore bash-esque C-w/C-a/C-e in insert mode and the minibuffer ;; Restore bash-esque keymaps in insert mode and the minibuffer
(mapc (lambda (map) (mapc (lambda (map)
;; (define-key map (kbd "C-w") 'evil-delete-backward-word)
(define-key map (kbd "C-a") 'move-beginning-of-line) (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-e") 'move-end-of-line)
(define-key map (kbd "C-u") 'backward-kill-line)) (define-key map (kbd "C-u") 'backward-kill-line))
(list minibuffer-local-map evil-insert-state-map)) (list minibuffer-local-map minibuffer-local-ns-map evil-insert-state-map))
(define-key evil-insert-state-map (kbd "C-w") 'backward-kill-word) (define-key evil-insert-state-map (kbd "C-w") 'backward-kill-word)
(define-key minibuffer-local-map (kbd "C-w") 'ido-delete-backward-word-updir) (define-key minibuffer-local-map (kbd "C-w") 'ido-delete-backward-word-updir)

View file

@ -14,15 +14,10 @@
(add-hook 'before-make-frame-hook (add-hook 'before-make-frame-hook
(lambda() (setq x-select-enable-clipboard t))) (lambda() (setq x-select-enable-clipboard t)))
;; TODO: Make server-friendly ;; Curse you Lion-esque fullscreen mode!
(when window-system (setq ns-use-native-fullscreen nil)
;; Curse you Lion-esque fullscreen mode! ;; Don't open files from the workspace in a new frame
(setq ns-use-native-fullscreen nil) (setq ns-pop-up-frames nil)
(gmap (kbd "s-<f12>") 'toggle-frame-fullscreen)
;; Don't open files from the workspace in a new frame
(setq ns-pop-up-frames nil)
)
;; Send current file to OSX apps ;; Send current file to OSX apps
(defun open-file-with (path &optional appName) (defun open-file-with (path &optional appName)

View file

@ -22,38 +22,35 @@
;; Check if a package is installed; if load is t, load it too. ;; Check if a package is installed; if load is t, load it too.
;; Works for packages bundled with emacs too! ;; Works for packages bundled with emacs too!
(defun require-package (package &optional dont_load) (defun require-package (package)
(message "=> require-package(%s)" package)
(unless (require package nil 'noerror) (unless (require package nil 'noerror)
(init-package package dont_load)))
;; List version of require-package
(defun require-packages (packages &optional dont_load)
(dolist (pkg packages) (require-package pkg dont_load)))
;; Install the package if it isn't already, and require it, unless
;; told others.
(defun init-package (package &optional dont_load)
(unless (package-installed-p package) (unless (package-installed-p package)
(unless (assoc package package-archive-contents) (unless (assoc package package-archive-contents)
(package-refresh-contents)) (package-refresh-contents))
(package-install package)) (package-install package)))
(if (not dont_load) (require package))) (require package))
;; List version of require-package
(defun require-packages (packages)
(mapc 'require-package packages))
;; Associate an extension with a mode, and install the necessary ;; Associate an extension with a mode, and install the necessary
;; package(s) for it. Also look for a modules/env-*.el modefile for ;; package(s) for it. Also look for a modules/env-*.el modefile for
;; extra configuration. ;; extra configuration.
(defun associate-mode (mode ext &optional only-load-env) (defun associate-mode (mode ext &optional only-load-env)
(let* ((mode_name (symbol-name mode)) (let* ((mode-name (symbol-name mode))
(env_mode_name (concat "env-" mode_name)) (env-mode-name (concat "env-" mode-name))
(mode_path (expand-file-name (concat env_mode_name ".el") my-modules-dir))) (mode-path (expand-file-name (concat env-mode-name ".el") my-modules-dir)))
(unless only-load-env (autoload mode mode_name)) (message "=> Init %s" mode-name)
(if (file-exists-p mode_path) ;; (unless only-load-env (autoload mode mode-name))
(eval-after-load mode (unless only-load-env (require-package mode))
`(require (intern ,env_mode_name))) (when (file-exists-p mode-path)
;; (autoload mode env_mode_name) (message "=> Loaded %s" env-mode-name)
;; (require-package (intern env_mode_name)) (require (intern env-mode-name))
)) )
)
(if (typep ext 'list) (if (typep ext 'list)
(dolist (e ext) (dolist (e ext)

View file

@ -48,6 +48,8 @@
ido-enable-tramp-completion t ido-enable-tramp-completion t
ido-enable-last-directory-history t) ido-enable-last-directory-history t)
;; (add-to-list 'ido-ubiquitous-default-function-overrides '(disable exact "evil-ex"))
;;; Filters ido-matches setting acronynm matches in front of the results ;;; Filters ido-matches setting acronynm matches in front of the results
(defadvice ido-set-matches-1 (after ido-smex-acronym-matches activate) (defadvice ido-set-matches-1 (after ido-smex-acronym-matches activate)
(if (and (fboundp 'smex-already-running) (smex-already-running) (if (and (fboundp 'smex-already-running) (smex-already-running)

View file

@ -1,5 +1,6 @@
(require-packages (require-packages
'(uniquify ; unique buffer names for identical filenames '(
;; uniquify ; unique buffer names for identical filenames
diminish ; shrinks/removes modeline elements diminish ; shrinks/removes modeline elements
)) ))
@ -24,23 +25,24 @@
(let* ((w (length (number-to-string (count-lines (point-min) (point-max))))) (let* ((w (length (number-to-string (count-lines (point-min) (point-max)))))
(linum-format (concat "%" (number-to-string (+ w 1)) "d" (if window-system "" " ")))) ad-do-it)) (linum-format (concat "%" (number-to-string (+ w 1)) "d" (if window-system "" " ")))) ad-do-it))
;;;#uniquify ;; Show full path in window title
(setq uniquify-buffer-name-style 'forward) (setq frame-title-format
(setq uniquify-separator "/") '(:eval (if (buffer-file-name) (abbreviate-file-name (buffer-file-name)) "%b")))
(setq uniquify-after-kill-buffer-p t) ; rename after killing uniquified
(setq uniquify-ignore-buffers-re "^\\*") ; don't muck with special buffers
;;;#uniquify
;; (setq uniquify-buffer-name-style 'forward)
;; (setq uniquify-separator "/")
;; (setq uniquify-after-kill-buffer-p t) ; rename after killing uniquified
;; (setq uniquify-ignore-buffers-re "^\\*") ; don't muck with special buffers
;; Modeline settings ;; Modeline settings
;; TODO: Customize modeline ;; TODO: Customize modeline!
;;;; GUI Settings ;;;;;;;;;;;;;;;;;;;;; ;;;; GUI Settings ;;;;;;;;;;;;;;;;;;;;;
(add-to-list 'default-frame-alist `(font . ,my-font)) (add-to-list 'default-frame-alist `(font . ,my-font))
(add-to-list 'default-frame-alist '(width . 100))
(add-to-list 'default-frame-alist '(height . 75))
(add-to-list 'default-frame-alist '(alpha 98 95)) ; *slightly* transparent window (add-to-list 'default-frame-alist '(alpha 98 95)) ; *slightly* transparent window
;; Use system clipboard ;; Use system clipboard

View file

@ -103,6 +103,14 @@
(interactive) (interactive)
(evil-delete (point-at-bol) (point))) (evil-delete (point-at-bol) (point)))
(defun expand-space ()
(interactive)
(save-excursion (insert " ")))
(defun expand-backspace ()
(interactive)
(save-excursion (delete-char 1))
(delete-backward-char 1))
(defun toggle-sidebar () (defun toggle-sidebar ()
(interactive) (interactive)
(project-explorer-open)) (project-explorer-open))

View file

@ -1,7 +1,6 @@
(require-packages (require-packages
'(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
)) ))
;; (setq ac-auto-show-menu nil ; Suggestions box must be invoked manually (see core-keymaps.el) ;; (setq ac-auto-show-menu nil ; Suggestions box must be invoked manually (see core-keymaps.el)
@ -17,9 +16,12 @@
(ac-flyspell-workaround) ; Compatibility with flyspell/make (ac-flyspell-workaround) ; Compatibility with flyspell/make
(diminish 'auto-complete-mode) ; Hide mode-line entry (diminish 'auto-complete-mode) ; Hide mode-line entry
(add-to-list 'ac-dictionary-files "~/.emacs.d/ac-dict/global")
(add-to-list 'ac-dictionary-directories "~/.emacs.d/ac-dict")
;; Use more vim-like keymappings ;; Use more vim-like keymappings
(evil-define-key 'insert ac-mode-map (kbd "C-SPC") 'auto-complete) (evil-define-key 'insert ac-mode-map (kbd "C-SPC") 'auto-complete)
(evil-define-key 'insert ac-mode-map (kbd "C-S-SPC") 'auto-fuzzy-complete) (evil-define-key 'insert ac-mode-map (kbd "C-S-SPC") 'ac-fuzzy-complete)
(define-key ac-completing-map (kbd "<tab>") 'ac-next) (define-key ac-completing-map (kbd "<tab>") 'ac-next)
(define-key ac-completing-map (kbd "S-<tab>") 'ac-previous) (define-key ac-completing-map (kbd "S-<tab>") 'ac-previous)
(define-key ac-completing-map (kbd "<F1>") 'ac-quick-help) (define-key ac-completing-map (kbd "<F1>") 'ac-quick-help)

View file

@ -15,7 +15,6 @@
(require-package 'yasnippet) (require-package 'yasnippet)
;;;#yasnippet ;;;#yasnippet
;; (yas-global-mode t)
(associate-mode 'snippet-mode '("emacs.+/snippets/") t) (associate-mode 'snippet-mode '("emacs.+/snippets/") t)
(add-hook 'prog-mode-hook (add-hook 'prog-mode-hook
'(lambda () '(lambda ()