Clean up; refactor

This commit is contained in:
Henrik Lissner 2015-10-28 03:31:51 -04:00
parent d87817725f
commit ee0930c11a
9 changed files with 97 additions and 89 deletions

View file

@ -34,13 +34,15 @@
(add-to-list 'company-transformers 'company-sort-by-occurrence) (add-to-list 'company-transformers 'company-sort-by-occurrence)
(setq-default company-backends (append '(company-keywords) company-backends)) (setq-default company-backends (append '(company-keywords) company-backends))
(after! yasnippet (after! yasnippet
(setq-default company-backends (append '(company-capf company-yasnippet) company-backends))) (setq-default company-backends
(append '(company-capf company-yasnippet) company-backends)))
(define-company-backend! nxml-mode (nxml yasnippet)) (define-company-backend! nxml-mode (nxml yasnippet))
(define-company-backend! emacs-lisp-mode (elisp yasnippet)) (define-company-backend! emacs-lisp-mode (elisp yasnippet))
;; (use-package company-dict :defer t) ;; (use-package company-dict :defer t)
;; (setq-default company-backends (append '(company-dict company-keywords) company-backends)) ;; (setq-default company-backends
;; (append '(company-dict company-keywords) company-backends))
;; Rewrite evil-complete to use company-dabbrev ;; Rewrite evil-complete to use company-dabbrev
(setq company-dabbrev-code-other-buffers t (setq company-dabbrev-code-other-buffers t

View file

@ -1,4 +1,6 @@
(eval-when-compile (require 'cl-lib)) (eval-when-compile
(require 'cl-lib)
(require 'dash))
;; Backwards compatible `with-eval-after-load' ;; Backwards compatible `with-eval-after-load'
(unless (fboundp 'with-eval-after-load) (unless (fboundp 'with-eval-after-load)
@ -161,7 +163,7 @@ Examples:
(if (assoc letter state-map) (if (assoc letter state-map)
(add-to-list 'states (cdr (assoc letter state-map))) (add-to-list 'states (cdr (assoc letter state-map)))
(user-error "Invalid mode prefix %s in key %s" letter key))) (user-error "Invalid mode prefix %s in key %s" letter key)))
(s-split "" (substring (symbol-name key) 1) t)) (split-string (substring (symbol-name key) 1) "" t))
(unless states (unless states
(user-error "Unrecognized keyword %s" key)) nil))) (user-error "Unrecognized keyword %s" key)) nil)))

View file

@ -15,6 +15,7 @@
scroll-margin 0 scroll-margin 0
scroll-conservatively 101 scroll-conservatively 101
scroll-preserve-screen-position t scroll-preserve-screen-position t
shift-select-mode nil shift-select-mode nil
tabify-regexp "^\t* [ \t]+" tabify-regexp "^\t* [ \t]+"
whitespace-style '(face tabs tab-mark newline newline-mark) whitespace-style '(face tabs tab-mark newline newline-mark)
@ -22,8 +23,7 @@
'((tab-mark ?\t [?> ?\t]) '((tab-mark ?\t [?> ?\t])
(newline-mark 10 [36 10])) (newline-mark 10 [36 10]))
truncate-lines t ; do not soft-wrap lines truncate-lines t ; do not soft-wrap lines
truncate-partial-width-windows nil truncate-partial-width-windows nil)
jit-lock-stealth-time 1)
;; Automatic minor modes ;;;;;;;;;;; ;; Automatic minor modes ;;;;;;;;;;;
@ -92,7 +92,7 @@ enable multiple minor modes for the same regexp.")
;; (global-whitespace-mode 1) ; Show whitespace ;; (global-whitespace-mode 1) ; Show whitespace
(global-font-lock-mode t) ; Enable syntax highlighting for older emacs (global-font-lock-mode t) ; Enable syntax highlighting for older emacs
(global-auto-revert-mode 1) ; revert buffers for changed files ;; (global-auto-revert-mode -1); revert buffers for changed files
(electric-indent-mode -1) (electric-indent-mode -1)
;; window config undo/redo ;; window config undo/redo
@ -110,11 +110,10 @@ enable multiple minor modes for the same regexp.")
(defalias 'redo #'undo-tree-redo) (defalias 'redo #'undo-tree-redo)
(defalias 'undo #'undo-tree-undo) (defalias 'undo #'undo-tree-undo)
;; Shut up undo-tree's constant complaining: http://youtu.be/Z6woIRLnbmE ;; Shut up undo-tree's constant complaining: http://youtu.be/Z6woIRLnbmE
;; (defadvice undo-tree-load-history-hook (around undo-tree-load-history-shut-up activate) (defadvice undo-tree-load-history-hook (around undo-tree-load-history-shut-up activate)
;; (shut-up! ad-do-it)) (shut-up! ad-do-it))
;; (defadvice undo-tree-save-history-hook (around undo-tree-save-history-shut-up activate) (defadvice undo-tree-save-history-hook (around undo-tree-save-history-shut-up activate)
;; (shut-up! ad-do-it)) (shut-up! ad-do-it)))
)
(use-package avy (use-package avy
:commands (avy-goto-char-2 avy-goto-line) :commands (avy-goto-char-2 avy-goto-line)
@ -129,7 +128,7 @@ enable multiple minor modes for the same regexp.")
(use-package emr (use-package emr
:commands (emr-initialize emr-show-refactor-menu emr-declare-command) :commands (emr-initialize emr-show-refactor-menu emr-declare-command)
:config (bind! :map popup-menu-keymap [escape] 'keyboard-quit)) :config (define-key popup-menu-keymap [escape] 'keyboard-quit))
(use-package expand-region (use-package expand-region
:commands (er/expand-region er/contract-region er/mark-symbol er/mark-word)) :commands (er/expand-region er/contract-region er/mark-symbol er/mark-word))
@ -150,7 +149,7 @@ enable multiple minor modes for the same regexp.")
:config :config
(setq sp-autowrap-region nil ; let evil-surround handle this (setq sp-autowrap-region nil ; let evil-surround handle this
sp-highlight-pair-overlay nil sp-highlight-pair-overlay nil
sp-autoescape-string-quote nil sp-cancel-autoskip-on-backward-movement t
sp-show-pair-delay 0) sp-show-pair-delay 0)
(smartparens-global-mode 1) (smartparens-global-mode 1)
@ -202,5 +201,19 @@ enable multiple minor modes for the same regexp.")
(when (boundp 'smex-cache) (smex-update))) (when (boundp 'smex-cache) (smex-update)))
(add-hook 'after-load-functions 'smex-update-after-load)) (add-hook 'after-load-functions 'smex-update-after-load))
(use-package help-fns+ ; Improved help commands
:commands (describe-buffer describe-command describe-file
describe-keymap describe-option describe-option-of-type))
(use-package saveplace
:defer t
:config (setq save-place-file (concat narf-temp-dir "saveplace"))
:init
;; Save cursor location across sessions. Only save for files that exist.
(add-hook! find-file
(when (file-exists-p (buffer-file-name))
(require 'saveplace)
(setq save-place t))))
(provide 'core-editor) (provide 'core-editor)
;;; core-editor.el ends here ;;; core-editor.el ends here

View file

@ -39,7 +39,7 @@
(evil-mode 1) (evil-mode 1)
(evil-select-search-module 'evil-search-module 'evil-search) (evil-select-search-module 'evil-search-module 'evil-search)
(bind! :map evil-command-window-mode-map :n [escape] 'kill-buffer-and-window) (evil-define-key 'normal evil-command-window-mode-map [escape] 'kill-buffer-and-window)
;; modes to map to different default states ;; modes to map to different default states
(dolist (mode-map '((cider-repl-mode . emacs) (dolist (mode-map '((cider-repl-mode . emacs)
@ -51,9 +51,11 @@
(evil-set-initial-state `,(car mode-map) `,(cdr mode-map))) (evil-set-initial-state `,(car mode-map) `,(cdr mode-map)))
(progn ; evil hacks (progn ; evil hacks
(defadvice evil-force-normal-state (before evil-esc-quit activate) (defadvice evil-force-normal-state (after evil-esc-quit activate)
(ignore-errors (ignore-errors
(popwin:close-popup-window) ; close popups, if any (when (popwin:popup-window-live-p)
(popwin:close-popup-window))
; close popups, if any
(evil-ex-nohighlight) (evil-ex-nohighlight)
;; Exit minibuffer if alive ;; Exit minibuffer if alive
(if (minibuffer-window-active-p (minibuffer-window)) (if (minibuffer-window-active-p (minibuffer-window))
@ -72,9 +74,10 @@
;; Hide keystroke display while isearch is active ;; Hide keystroke display while isearch is active
(add-hook! isearch-mode (setq echo-keystrokes 0)) (add-hook! isearch-mode (setq echo-keystrokes 0))
(add-hook! isearch-mode-end (setq echo-keystrokes 0.02)) (add-hook! isearch-mode-end (setq echo-keystrokes 0.02))
(bind! :map evil-ex-search-keymap (let ((map evil-ex-search-keymap))
"C-w" 'evil-delete-backward-word (define-key map (kbd "C-w") 'evil-delete-backward-word)
"C-u" 'evil-delete-whole-line))) (define-key map (kbd "C-u") 'evil-delete-whole-line))
;; Repeat motions with SPC/S-SPC ;; Repeat motions with SPC/S-SPC
(defmacro narf-space-setup! (command next-func prev-func) (defmacro narf-space-setup! (command next-func prev-func)
`(defadvice ,command `(defadvice ,command
@ -133,28 +136,29 @@
:functions (iedit-current-occurrence-string iedit-restrict-region) :functions (iedit-current-occurrence-string iedit-restrict-region)
:commands (evil-iedit-state evil-iedit-state/iedit-mode) :commands (evil-iedit-state evil-iedit-state/iedit-mode)
:config :config
(bind! :v "SPC" 'narf:iedit-restrict-to-region (define-key evil-visual-state-map (kbd "SPC") 'narf:iedit-restrict-to-region)
(:map evil-iedit-state-map (let ((map evil-iedit-state-map))
;; Don't interfere with evil-snipe ;; Don't interfere with evil-snipe
"s" nil (define-key map "s" nil)
"S" nil (define-key map "S" nil)
"V" 'evil-visual-line
"C" 'evil-iedit-state/substitute ; instead of s/S (define-key map (kbd "V") 'evil-visual-line)
"za" 'iedit-toggle-unmatched-lines-visible))) (define-key map (kbd "C") 'evil-iedit-state/substitute) ; instead of s/S
(define-key map (kbd "za") 'iedit-toggle-unmatched-lines-visible)))
(use-package evil-indent-textobject (use-package evil-indent-textobject
:commands (evil-indent-i-indent :commands (evil-indent-i-indent
evil-indent-a-indent evil-indent-a-indent
evil-indent-a-indent-lines) evil-indent-a-indent-lines)
:init :init
(bind! :map evil-inner-text-objects-map (let ((map evil-inner-text-objects-map))
"i" 'evil-indent-i-indent (define-key map "i" 'evil-indent-i-indent)
"i" 'evil-indent-a-indent (define-key map "i" 'evil-indent-a-indent)
"I" 'evil-indent-a-indent-lines)) (define-key map "I" 'evil-indent-a-indent-lines)))
(use-package evil-jumper (use-package evil-jumper
:init :init
(setq evil-jumper-file (! (concat narf-temp-dir "jumplist")) (setq evil-jumper-file (concat narf-temp-dir "jumplist")
evil-jumper-auto-center t evil-jumper-auto-center t
evil-jumper-auto-save-interval 3600)) evil-jumper-auto-save-interval 3600))

View file

@ -197,7 +197,7 @@
(use-package helm-semantic :commands helm-semantic-or-imenu) (use-package helm-semantic :commands helm-semantic-or-imenu)
(use-package helm-elisp :commands helm-apropos) (use-package helm-elisp :commands helm-apropos)
(use-package helm-command :commands helm-M-x) (use-package helm-command :commands helm-M-x)
(use-package helm-descbinds :command helm-descbinds) (use-package helm-descbinds :commands helm-descbinds)
(provide 'core-helm) (provide 'core-helm)
;;; core-helm.el ends here ;;; core-helm.el ends here

View file

@ -2,7 +2,7 @@
;; see lib/ui-defuns.el ;; see lib/ui-defuns.el
(when window-system (when window-system
(fringe-mode '(2 . 3)) (fringe-mode '(3 . 3))
(set-frame-font narf-default-font) (set-frame-font narf-default-font)
(setq frame-title-format '(buffer-file-name "%f" ("%b"))) (setq frame-title-format '(buffer-file-name "%f" ("%b")))
(setq initial-frame-alist '((width . 120) (height . 80)))) (setq initial-frame-alist '((width . 120) (height . 80))))
@ -88,7 +88,9 @@
("^\\*[Hh]elm.*?\\*\\'" :regexp t :position bottom :height 15) ("^\\*[Hh]elm.*?\\*\\'" :regexp t :position bottom :height 15)
("*eshell*" :position left :width 80 :stick t :dedicated t) ("*eshell*" :position left :width 80 :stick t :dedicated t)
("*Apropos*" :position bottom :height 40 :stick t :dedicated t) ("*Apropos*" :position bottom :height 40 :stick t :dedicated t)
("*Backtrace*" :position bottom :height 15 :stick t))) ("*Backtrace*" :position bottom :height 15 :stick t)
("^\\*Org-Babel.*\\*$" :regexp t :position bottom :height 15)
))
(popwin-mode 1)) (popwin-mode 1))
(use-package volatile-highlights (use-package volatile-highlights
@ -108,6 +110,7 @@
(volatile-highlights-mode t)) (volatile-highlights-mode t))
(use-package nlinum (use-package nlinum
:commands nlinum-mode
:preface :preface
(defvar narf--hl-nlinum-overlay nil) (defvar narf--hl-nlinum-overlay nil)
(defvar narf--hl-nlinum-line nil) (defvar narf--hl-nlinum-line nil)
@ -147,8 +150,9 @@
(point-at-bol))) (point-at-bol)))
(peol (1+ pbol))) (peol (1+ pbol)))
;; Handle EOF case ;; Handle EOF case
(when (>= peol (point-max)) (let ((max (point-max)))
(setq peol (point-max))) (when (>= peol max)
(setq peol max)))
(jit-lock-fontify-now pbol peol) (jit-lock-fontify-now pbol peol)
(let* ((overlays (overlays-in pbol peol)) (let* ((overlays (overlays-in pbol peol))
(ov (-first (lambda (item) (overlay-get item 'nlinum)) overlays))) (ov (-first (lambda (item) (overlay-get item 'nlinum)) overlays)))

View file

@ -42,9 +42,9 @@
;; Disable all backups (that's what git/dropbox are for) ;; Disable all backups (that's what git/dropbox are for)
bookmark-save-flag t bookmark-save-flag t
bookmark-default-file (! (concat narf-temp-dir "bookmarks")) bookmark-default-file (concat narf-temp-dir "bookmarks")
auto-save-default nil auto-save-default nil
auto-save-list-file-name (! (concat narf-temp-dir "autosave")) auto-save-list-file-name (concat narf-temp-dir "autosave")
;; In case I want to reactivate backup files ;; In case I want to reactivate backup files
make-backup-files nil make-backup-files nil
@ -84,62 +84,44 @@
(make-directory path t))))) (make-directory path t)))))
;; Save history across sessions ;; Save history across sessions
(use-package savehist (require 'savehist)
:config (setq savehist-file (concat narf-temp-dir "savehist")
(setq savehist-file (concat narf-temp-dir "savehist")
savehist-save-minibuffer-history t savehist-save-minibuffer-history t
savehist-additional-variables savehist-additional-variables
'(kill-ring search-ring regexp-search-ring)) '(kill-ring search-ring regexp-search-ring))
(savehist-mode 1) (savehist-mode 1)
;; text properties severely bloat the history so delete them (courtesy of PythonNut) ;; text properties severely bloat the history so delete them (courtesy of PythonNut)
(defun unpropertize-savehist () (defun unpropertize-savehist ()
(mapc (lambda (list) (mapc (lambda (list)
(with-demoted-errors (with-demoted-errors
(when (boundp list) (when (boundp list)
(set list (mapcar #'substring-no-properties (eval list)))))) (set list (mapcar #'substring-no-properties (eval list))))))
'(kill-ring '(kill-ring minibuffer-history helm-grep-history helm-ff-history file-name-history
minibuffer-history read-expression-history extended-command-history evil-ex-history)))
helm-grep-history (add-hook 'kill-emacs-hook #'unpropertize-savehist)
helm-ff-history (add-hook 'savehist-save-hook #'unpropertize-savehist)
file-name-history
read-expression-history
extended-command-history
evil-ex-history)))
(add-hook 'kill-emacs-hook #'unpropertize-savehist)
(add-hook 'savehist-save-hook #'unpropertize-savehist))
(use-package recentf (require 'recentf)
:config (setq recentf-save-file (concat narf-temp-dir "recentf")
(setq recentf-save-file (concat narf-temp-dir "recentf")
recentf-exclude '("/tmp/" "/ssh:" "\\.?ido\\.last$" "\\.revive$" "/TAGS$" recentf-exclude '("/tmp/" "/ssh:" "\\.?ido\\.last$" "\\.revive$" "/TAGS$"
"emacs\\.d/private/cache/.+" "emacs\\.d/workgroups/.+$" "wg-default" "emacs\\.d/private/cache/.+" "emacs\\.d/workgroups/.+$" "wg-default"
"/company-statistics-cache.el$") "/company-statistics-cache.el$")
recentf-max-menu-items 0 recentf-max-menu-items 0
recentf-max-saved-items 250 recentf-max-saved-items 250
recentf-auto-cleanup 600) recentf-auto-cleanup 600)
(recentf-mode 1)) (recentf-mode 1)
(use-package saveplace ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
:defer t
:config (setq save-place-file (concat narf-temp-dir "saveplace"))
:init
;; Save cursor location across sessions. Only save for files that exist.
(add-hook! find-file
(if (file-exists-p (buffer-file-name))
(require 'saveplace)
(setq save-place t))))
(use-package help-fns+ ; Improved help commands
:commands (describe-buffer describe-command describe-file
describe-keymap describe-option describe-option-of-type))
(defun narf-init () (defun narf-init ()
(defadvice save-buffers-kill-emacs (around no-query-kill-emacs activate) (defadvice save-buffers-kill-emacs (around no-query-kill-emacs activate)
"Prevent annoying \"Active processes exist\" query when you quit Emacs." "Prevent annoying \"Active processes exist\" query when you quit Emacs."
(flet ((process-list ())) ad-do-it)) (cl-flet ((process-list ())) ad-do-it))
(defun display-startup-echo-area-message () (defun display-startup-echo-area-message ()
(message ">>> Loaded in %s" (emacs-init-time))) (message ">>> Loaded in %s" (emacs-init-time)))
(require 'server) (require 'server)
(unless (server-running-p) (unless (server-running-p)
(server-start))) (server-start)))

View file

@ -3,7 +3,8 @@
(use-package csharp-mode (use-package csharp-mode
:functions (csharp-log) :functions (csharp-log)
:mode "\\.cs$" :mode "\\.cs$"
:init (add-hook! csharp-mode 'flycheck-mode)) :init (add-hook! csharp-mode 'flycheck-mode)
:config (require 'omnisharp))
;; unity shaders ;; unity shaders
(use-package shader-mode :mode "\\.shader$") (use-package shader-mode :mode "\\.shader$")

View file

@ -5,7 +5,7 @@
:defer t :defer t
:init :init
(evil-set-initial-state 'eshell-mode 'normal) (evil-set-initial-state 'eshell-mode 'normal)
(setq eshell-directory-name (! (concat narf-temp-dir "eshell")) (setq eshell-directory-name (concat narf-temp-dir "eshell")
eshell-scroll-to-bottom-on-input 'all eshell-scroll-to-bottom-on-input 'all
eshell-buffer-shorthand t eshell-buffer-shorthand t