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)
(setq-default company-backends (append '(company-keywords) company-backends))
(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! emacs-lisp-mode (elisp yasnippet))
;; (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
(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'
(unless (fboundp 'with-eval-after-load)
@ -161,7 +163,7 @@ Examples:
(if (assoc letter state-map)
(add-to-list 'states (cdr (assoc letter state-map)))
(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
(user-error "Unrecognized keyword %s" key)) nil)))

View file

@ -15,6 +15,7 @@
scroll-margin 0
scroll-conservatively 101
scroll-preserve-screen-position t
shift-select-mode nil
tabify-regexp "^\t* [ \t]+"
whitespace-style '(face tabs tab-mark newline newline-mark)
@ -22,8 +23,7 @@
'((tab-mark ?\t [?> ?\t])
(newline-mark 10 [36 10]))
truncate-lines t ; do not soft-wrap lines
truncate-partial-width-windows nil
jit-lock-stealth-time 1)
truncate-partial-width-windows nil)
;; Automatic minor modes ;;;;;;;;;;;
@ -92,7 +92,7 @@ enable multiple minor modes for the same regexp.")
;; (global-whitespace-mode 1) ; Show whitespace
(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)
;; window config undo/redo
@ -110,11 +110,10 @@ enable multiple minor modes for the same regexp.")
(defalias 'redo #'undo-tree-redo)
(defalias 'undo #'undo-tree-undo)
;; 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)
;; (shut-up! ad-do-it))
;; (defadvice undo-tree-save-history-hook (around undo-tree-save-history-shut-up activate)
;; (shut-up! ad-do-it))
)
(defadvice undo-tree-load-history-hook (around undo-tree-load-history-shut-up activate)
(shut-up! ad-do-it))
(defadvice undo-tree-save-history-hook (around undo-tree-save-history-shut-up activate)
(shut-up! ad-do-it)))
(use-package avy
:commands (avy-goto-char-2 avy-goto-line)
@ -129,7 +128,7 @@ enable multiple minor modes for the same regexp.")
(use-package emr
: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
: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
(setq sp-autowrap-region nil ; let evil-surround handle this
sp-highlight-pair-overlay nil
sp-autoescape-string-quote nil
sp-cancel-autoskip-on-backward-movement t
sp-show-pair-delay 0)
(smartparens-global-mode 1)
@ -202,5 +201,19 @@ enable multiple minor modes for the same regexp.")
(when (boundp 'smex-cache) (smex-update)))
(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)
;;; core-editor.el ends here

View file

@ -39,7 +39,7 @@
(evil-mode 1)
(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
(dolist (mode-map '((cider-repl-mode . emacs)
@ -51,9 +51,11 @@
(evil-set-initial-state `,(car mode-map) `,(cdr mode-map)))
(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
(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)
;; Exit minibuffer if alive
(if (minibuffer-window-active-p (minibuffer-window))
@ -72,9 +74,10 @@
;; Hide keystroke display while isearch is active
(add-hook! isearch-mode (setq echo-keystrokes 0))
(add-hook! isearch-mode-end (setq echo-keystrokes 0.02))
(bind! :map evil-ex-search-keymap
"C-w" 'evil-delete-backward-word
"C-u" 'evil-delete-whole-line)))
(let ((map evil-ex-search-keymap))
(define-key map (kbd "C-w") 'evil-delete-backward-word)
(define-key map (kbd "C-u") 'evil-delete-whole-line))
;; Repeat motions with SPC/S-SPC
(defmacro narf-space-setup! (command next-func prev-func)
`(defadvice ,command
@ -133,28 +136,29 @@
:functions (iedit-current-occurrence-string iedit-restrict-region)
:commands (evil-iedit-state evil-iedit-state/iedit-mode)
:config
(bind! :v "SPC" 'narf:iedit-restrict-to-region
(:map evil-iedit-state-map
(define-key evil-visual-state-map (kbd "SPC") 'narf:iedit-restrict-to-region)
(let ((map evil-iedit-state-map))
;; Don't interfere with evil-snipe
"s" nil
"S" nil
"V" 'evil-visual-line
"C" 'evil-iedit-state/substitute ; instead of s/S
"za" 'iedit-toggle-unmatched-lines-visible)))
(define-key map "s" nil)
(define-key map "S" nil)
(define-key map (kbd "V") 'evil-visual-line)
(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
:commands (evil-indent-i-indent
evil-indent-a-indent
evil-indent-a-indent-lines)
:init
(bind! :map evil-inner-text-objects-map
"i" 'evil-indent-i-indent
"i" 'evil-indent-a-indent
"I" 'evil-indent-a-indent-lines))
(let ((map evil-inner-text-objects-map))
(define-key map "i" 'evil-indent-i-indent)
(define-key map "i" 'evil-indent-a-indent)
(define-key map "I" 'evil-indent-a-indent-lines)))
(use-package evil-jumper
: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-save-interval 3600))

View file

@ -197,7 +197,7 @@
(use-package helm-semantic :commands helm-semantic-or-imenu)
(use-package helm-elisp :commands helm-apropos)
(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)
;;; core-helm.el ends here

View file

@ -2,7 +2,7 @@
;; see lib/ui-defuns.el
(when window-system
(fringe-mode '(2 . 3))
(fringe-mode '(3 . 3))
(set-frame-font narf-default-font)
(setq frame-title-format '(buffer-file-name "%f" ("%b")))
(setq initial-frame-alist '((width . 120) (height . 80))))
@ -88,7 +88,9 @@
("^\\*[Hh]elm.*?\\*\\'" :regexp t :position bottom :height 15)
("*eshell*" :position left :width 80 :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))
(use-package volatile-highlights
@ -108,6 +110,7 @@
(volatile-highlights-mode t))
(use-package nlinum
:commands nlinum-mode
:preface
(defvar narf--hl-nlinum-overlay nil)
(defvar narf--hl-nlinum-line nil)
@ -147,8 +150,9 @@
(point-at-bol)))
(peol (1+ pbol)))
;; Handle EOF case
(when (>= peol (point-max))
(setq peol (point-max)))
(let ((max (point-max)))
(when (>= peol max)
(setq peol max)))
(jit-lock-fontify-now pbol peol)
(let* ((overlays (overlays-in pbol peol))
(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)
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-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
make-backup-files nil
@ -84,62 +84,44 @@
(make-directory path t)))))
;; Save history across sessions
(use-package savehist
:config
(setq savehist-file (concat narf-temp-dir "savehist")
(require 'savehist)
(setq savehist-file (concat narf-temp-dir "savehist")
savehist-save-minibuffer-history t
savehist-additional-variables
'(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)
(defun unpropertize-savehist ()
;; text properties severely bloat the history so delete them (courtesy of PythonNut)
(defun unpropertize-savehist ()
(mapc (lambda (list)
(with-demoted-errors
(when (boundp list)
(set list (mapcar #'substring-no-properties (eval list))))))
'(kill-ring
minibuffer-history
helm-grep-history
helm-ff-history
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))
'(kill-ring minibuffer-history helm-grep-history helm-ff-history 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
:config
(setq recentf-save-file (concat narf-temp-dir "recentf")
(require 'recentf)
(setq recentf-save-file (concat narf-temp-dir "recentf")
recentf-exclude '("/tmp/" "/ssh:" "\\.?ido\\.last$" "\\.revive$" "/TAGS$"
"emacs\\.d/private/cache/.+" "emacs\\.d/workgroups/.+$" "wg-default"
"/company-statistics-cache.el$")
recentf-max-menu-items 0
recentf-max-saved-items 250
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 ()
(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))
(cl-flet ((process-list ())) ad-do-it))
(defun display-startup-echo-area-message ()
(message ">>> Loaded in %s" (emacs-init-time)))
(require 'server)
(unless (server-running-p)
(server-start)))

View file

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

View file

@ -5,7 +5,7 @@
:defer t
:init
(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-buffer-shorthand t