Clean up + refactor

This commit is contained in:
Henrik Lissner
2016-03-03 15:04:14 -05:00
parent 7e282841ba
commit 9571acd3e9
18 changed files with 136 additions and 102 deletions

View File

@@ -1,5 +1,4 @@
;;; core-completion.el --- auto completion backend (Company-mode)
;; see lib/company-macros.el
(use-package company
:commands (global-company-mode company-complete company-complete-common company-dict
@@ -25,20 +24,19 @@
company-quickhelp-delay nil)
:config
(require 'company-statistics)
(use-package company-statistics)
;; NOTE: pos-tip.el in Emacs 25+ does not work
(require 'company-quickhelp)
(company-quickhelp-mode +1)
;; Rewrites evil-complete to use company-dabbrev
(setq evil-complete-next-func 'narf/company-evil-complete-next
evil-complete-previous-func 'narf/company-evil-complete-previous)
(use-package company-quickhelp :config (company-quickhelp-mode +1))
(use-package company-dict :defer t
:config
(setq company-dict-dir (concat narf-private-dir "dict")))
;; Rewrites evil-complete to use company-dabbrev
(setq evil-complete-next-func 'narf/company-evil-complete-next
evil-complete-previous-func 'narf/company-evil-complete-previous)
(add-to-list 'company-transformers 'company-sort-by-occurrence)
(setq-default company-backends (append '(company-keywords) company-backends))

View File

@@ -1,12 +1,11 @@
;;; core-editor.el
;; see lib/editor-defuns.el
;;;; Editor behavior ;;;;;;;;;;;;;;;;
(setq-default
;; spaces instead of tabs
indent-tabs-mode nil
tab-always-indent t
tab-width 4
require-final-newline t
delete-trailing-lines nil
fill-column 90
@@ -21,11 +20,10 @@
scroll-margin 0
scroll-conservatively 1001
scroll-preserve-screen-position t
hscroll-step 1
hscroll-margin 1
shift-select-mode t
shift-select-mode t
tabify-regexp "^\t* [ \t]+"
whitespace-style '(face tabs tab-mark trailing newline indentation newline-mark)
whitespace-display-mappings
@@ -40,7 +38,9 @@
(save-place-mode +1))
;; Automatic minor modes ;;;;;;;;;;;
;;
;; Automatic minor modes
;;
(defvar narf-auto-minor-mode-alist '()
"Alist of filename patterns vs corresponding minor mode functions, see
@@ -67,7 +67,9 @@ enable multiple minor modes for the same regexp.")
(add-hook! find-file 'narf|enable-minor-mode-maybe)
;; Modes 'n hooks ;;;;;;;;;;;;;;;;;;;
;;
;; Modes 'n hooks
;;
(associate! applescript-mode :match "\\.applescript$")
(associate! emacs-lisp-mode :match "\\(/Cask\\|\\.\\(el\\|gz\\)\\)$")
@@ -100,8 +102,7 @@ enable multiple minor modes for the same regexp.")
(fundamental-mode)
(visual-line-mode)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; (global-whitespace-mode 1) ; Show whitespace
;; (global-font-lock-mode t) ; Enable syntax highlighting for older emacs
(electric-indent-mode -1) ; on by default
@@ -113,7 +114,10 @@ enable multiple minor modes for the same regexp.")
(add-hook! after-init
(setq winner-boring-buffers narf-ignore-buffers))
;; Extra modes ;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Extra modes
;;
(use-package vimrc-mode :mode ("/\\.?g?vimrc$" "\\.vim$" "/\\.vim/rc/.+$"))
;; Data formats
@@ -126,7 +130,10 @@ enable multiple minor modes for the same regexp.")
(define-docset! dockerfile-mode "docker")
(define-builder! dockerfile-mode dockerfile-build-buffer "Dockerfile"))
;; Plugins ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Plugins
;;
(use-package avy
:commands (avy-goto-char-2 avy-goto-line)

View File

@@ -1,5 +1,4 @@
;;; core-evil.el --- the root of all evil
;; see lib/evil-defuns.el
(use-package evil
:init

View File

@@ -1,10 +1,10 @@
;;; core-file-templates.el --- file templates
;;; core-file-templates.el
(use-package autoinsert
:defer t
:init
(setq auto-insert-query nil ; Don't prompt before insertion
auto-insert-alist '())
(setq auto-insert-query nil ; Don't prompt before insertion
auto-insert-alist '()) ; Tabula rasa
:config
(auto-insert-mode 1)

View File

@@ -1,5 +1,4 @@
;;; core-flycheck.el --- check yourself before you shrek yourself
;; Related to: lib/defuns-flycheck.el
(use-package flycheck
:commands (flycheck-mode flycheck-list-errors flycheck-buffer)

View File

@@ -23,14 +23,14 @@
;; Don't override evil-ex's completion
helm-mode-handle-completion-in-region nil
helm-candidate-number-limit 50
helm-candidate-number-limit 40
helm-bookmark-show-location t)
:config
(require 'helm-files)
(mapc (lambda (r) (add-to-list 'helm-boring-file-regexp-list r))
(list "\\.projects$" "\\.DS_Store$"))
(list "\\.projects$" "\\.DS_Store$" "\\.cask"))
(map! (:map helm-generic-files-map
"ESC" 'helm-keyboard-quit)
@@ -98,6 +98,7 @@
projectile-project-root-files narf-project-root-files)
(add-to-list 'projectile-globally-ignored-files "ido.last")
(add-to-list 'projectile-globally-ignored-directories ".cask")
(add-to-list 'projectile-globally-ignored-directories "assets")
(add-to-list 'projectile-globally-ignored-directories ".export")
(add-to-list 'projectile-globally-ignored-directories ".attach")
@@ -143,7 +144,6 @@
helm-swoop-pre-input-function (lambda () "")))
(use-package helm-describe-modes :defer t)
;; (use-package helm-c-yasnippet :commands helm-yas-visit-snippet-file)
(use-package helm-semantic :commands helm-semantic-or-imenu)
(use-package helm-elisp :commands helm-apropos)
(use-package helm-command :commands helm-M-x)

View File

@@ -1,6 +1,9 @@
;;; core-project.el --- all your (basic) project navigational needs
;;; Dired
;;
;; Dired
;;
;; Always copy/delete recursively
(setq dired-recursive-copies (quote always))
(setq dired-recursive-deletes (quote top))
@@ -32,8 +35,7 @@
(make-directory parent-directory t))))
(add-to-list 'find-file-not-found-functions #'narf|create-non-existent-directory)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
(use-package ido
:defines (flx-ido-mode ido-ubiquitous-debug-mode ido-context-switch-command ido-temp-list)
:functions (ido-to-end)
@@ -73,6 +75,7 @@
(add-hook! (ido-make-file-list ido-make-dir-list) 'narf*ido-sort-mtime)
(add-hook! ido-setup 'narf|ido-setup-home-keybind))
;;
(use-package neotree
:commands (neotree-show
neotree-hide

View File

@@ -1,5 +1,4 @@
;;; core-sessions.el
;; see lib/workgroup-defuns.el
;; I use workgroups to accomplish two things:
;; 1. Vim-like tab emulation (type :tabs to see a list of tabs -- maybe I'll add some

View File

@@ -1,5 +1,4 @@
;;; core-ui.el --- interface settings
;; see lib/ui-defuns.el
(setq-default
blink-matching-paren nil
@@ -10,69 +9,78 @@
;; switching.
cursor-in-non-selected-windows nil
highlight-nonselected-windows nil
hl-line-sticky-flag nil ; only highlight in one window
;; Custom mode-line solves duplicate buffer names
uniquify-buffer-name-style nil
uniquify-buffer-name-style nil ; my mode-line does this for me
visible-bell nil ; silence of the bells
use-dialog-box nil ; always avoid GUI
redisplay-dont-pause t
indicate-buffer-boundaries nil
indicate-buffer-boundaries t
indicate-empty-lines t
fringes-outside-margins t
hl-line-sticky-flag nil ; only highlight in one window
idle-update-delay 1
idle-update-delay 2 ; update a little less often
split-width-threshold nil ; favor horizontal splits
show-help-function nil ; hide :help-echo text
;; Disable bidirectional text support for slight performance bonus
bidi-display-reordering nil
;; Minibuffer resizing
resize-mini-windows 'grow-only
max-mini-window-height 0.3
;; Remove arrow on the right fringe when wrapped
fringe-indicator-alist (delq (assoc 'continuation fringe-indicator-alist)
fringe-indicator-alist))
(defface narf-minibuffer-active '((t (:inherit mode-line))) "Face for active minibuffer")
(defvar narf-fringe-size 6)
(if window-system
(progn
(fringe-mode narf-fringe-size)
(setq frame-title-format '(buffer-file-name "%f" ("%b")))
(blink-cursor-mode 1) ; blink cursor
(tooltip-mode -1) ; show tooltips in echo area
(narf/load-font narf-default-font)
(set-face-attribute 'default t :font narf-default-font)
;; Set up minibuffer and fringe
(defface narf-minibuffer-active '((t (:inherit mode-line)))
"Face for active minibuffer")
(define-fringe-bitmap 'tilde [64 168 16] nil nil 'center)
(setcdr (assq 'empty-line fringe-indicator-alist) 'tilde)
(set-fringe-bitmap-face 'tilde 'font-lock-comment-face)
(if (not window-system)
(menu-bar-mode -1)
;; Set fonts
(narf/load-font narf-default-font)
(set-face-attribute 'default t :font narf-default-font)
(set-window-fringes (minibuffer-window) 0 0 nil)
(defun narf|minibuffer-setup ()
(set-window-fringes (selected-window) 0 0 nil)
(make-local-variable 'face-remapping-alist)
(add-to-list 'face-remapping-alist '(default narf-minibuffer-active)))
(add-hook! minibuffer-setup 'narf|minibuffer-setup))
(menu-bar-mode -1))
;; Setup fringe
(fringe-mode narf-fringe-size)
(setq frame-title-format '(buffer-file-name "%f" ("%b")))
(set-window-fringes (minibuffer-window) 0 0 nil)
;; Tilde empty-line indicator
(define-fringe-bitmap 'tilde [64 168 16] nil nil 'center)
(setcdr (assq 'empty-line fringe-indicator-alist) 'tilde)
(set-fringe-bitmap-face 'tilde 'font-lock-comment-face)
;; Brighter minibuffer when active
(defun narf|minibuffer-setup ()
(set-window-fringes (selected-window) 0 0 nil)
(make-local-variable 'face-remapping-alist)
(add-to-list 'face-remapping-alist '(default narf-minibuffer-active)))
(add-hook! minibuffer-setup 'narf|minibuffer-setup))
;; Fix display of certain unicode characters
(mapc (lambda (x)
(set-fontset-font "fontset-default" `(,x . ,x)
(font-spec :name "DejaVu Sans") nil 'prepend))
'(?☑ ?☐ ?✍ ?⚠ ?★))
(mapc (lambda (x)
(set-fontset-font "fontset-default" `(,x . ,x)
(font-spec :name "DejaVu Sans" :size 10) nil))
'(?➊ ?➋ ?➌ ?➍ ?➎ ?❻ ?➐ ?➑ ?➒ ?➓ ))
(mapc (lambda (x)
(set-fontset-font "fontset-default" `(,x . ,x)
(font-spec :name "FontAwesome" :size 13) nil))
'(? ? ? ? ? ? ? ? ?))
(mapc (lambda (set)
(let ((font (car set))
(chars (cadr set))
(size (caddr set)))
(mapc (lambda (x) (set-fontset-font
"fontset-default" `(,x . ,x)
(font-spec :name font :size size) nil 'prepend))
chars)))
'(("DejaVu Sans" (?☑ ?☐ ?✍ ?⚠ ?★
?➊ ?➋ ?➌ ?➍ ?➎ ?❻ ?➐ ?➑ ?➒ ?➓))
;; File attachment symbols (for org-mode)
("FontAwesome" (? ? ? ? ? ? ? ? ?) 13)
;; Math symbols
("Hack" (?× ?∙ ?⌉ ?⌈ ?⌊ ?⌋
?∩ ? ?⊆ ?⊂ ?⊄ ?⊇ ?⊃ ?⊅
?⇒ ?⇐ ?⇔ ?↔ ?→ ?≡ ?∴ ?∵ ?⊕ ?∀ ?∃ ?∄ ?∈ ?∉
? ?∧ ))))
(blink-cursor-mode 1) ; do blink cursor
(tooltip-mode -1) ; show tooltips in echo area
;; on by default in Emacs 25
(when (and (featurep 'eldoc) (>= emacs-major-version 25))
(global-eldoc-mode -1))
@@ -91,10 +99,10 @@
(add-hook! evil-visual-state-entry 'narf|hl-line-off)
(add-hook! evil-visual-state-exit 'narf|hl-line-on)
;; Hide modeline in help windows ;;;;;;;
;; Hide modeline in help windows
(add-hook! help-mode (setq-local mode-line-format nil))
;; Highlight TODO/FIXME/NOTE tags ;;;;;;
;; Highlight TODO/FIXME/NOTE tags
(defface narf-todo-face '((t (:inherit font-lock-warning-face))) "Face for TODOs")
(defface narf-fixme-face '((t (:inherit font-lock-warning-face))) "Face for FIXMEs")
(defface narf-note-face '((t (:inherit font-lock-warning-face))) "Face for NOTEs")
@@ -103,11 +111,15 @@
("\\<\\(FIXME\\((.+)\\)?:?\\)" 1 'narf-fixme-face prepend)
("\\<\\(NOTE\\((.+)\\)?:?\\)" 1 'narf-note-face prepend))))
;; Fade out when unfocused ;;;;;;;;;;;;;
;; Fade out when unfocused
(add-hook! focus-in (set-frame-parameter nil 'alpha 100))
(add-hook! focus-out (set-frame-parameter nil 'alpha 75))
;; Plugins ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Plugins
;;
(use-package visual-fill-column :defer t)
(use-package yascroll

View File

@@ -8,7 +8,10 @@
(defvar narf-leader-prefix "," "Prefix key for <leader> maps")
(defvar narf-localleader-prefix "\\" "Prefix key for <localleader> maps")
;; Buffers/Files ;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Buffers/Files
;;
(defvar narf-unreal-buffers '("^ ?\\*.+\\*"
image-mode
@@ -56,5 +59,12 @@ gets killed.")
"A list of files that count as 'project files', which determine whether a
folder is the root of a project or not.")
;;
;; Fringe/margins
;;
(defvar narf-fringe-size 6 "Default width to use for the fringes.")
(provide 'core-vars)
;;; core-vars.el ends here

View File

@@ -1,6 +1,4 @@
;;; core-yasnippet.el --- For the lazy typist
;; see lib/yasnippet-defuns.el
;; see lib/yasnippet-macros.el
(use-package yasnippet
:mode ("emacs\\.d/private/\\(snippets\\|templates\\)/.+$" . snippet-mode)

View File

@@ -11,16 +11,10 @@
;; narf.... Custom prefix commands
;; ...! Macro
;;
;; You will find all autoloaded function in {core,modules}/defuns/defuns-*.el
;;
;;;
;; Ask for confirmation on exit only if there are real buffers left
(when window-system
(setq confirm-kill-emacs
(lambda (_)
(if (narf/get-real-buffers)
(y-or-n-p ">> Gee, I dunno Brain... Are you sure?")
t))))
(setq-default
ad-redefinition-action 'accept ; silence the advised function warnings
echo-keystrokes 0.02 ; show me what I type
@@ -62,7 +56,7 @@
undo-tree-auto-save-history t
undo-tree-history-directory-alist `(("." . ,(concat narf-temp-dir "undo/"))))
;;; UTF-8 please
;; UTF-8 please
(setq locale-coding-system 'utf-8) ; pretty
(set-terminal-coding-system 'utf-8) ; pretty
(set-keyboard-coding-system 'utf-8) ; pretty
@@ -70,8 +64,18 @@
(prefer-coding-system 'utf-8) ; with sugar on top
(fset 'yes-or-no-p 'y-or-n-p) ; y/n instead of yes/no
;; Ask for confirmation on exit only if there are real buffers left
(when window-system
(setq confirm-kill-emacs
(lambda (_)
(if (narf/get-real-buffers)
(y-or-n-p ">> Gee, I dunno Brain... Are you sure?")
t))))
;; Bootstrap ;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Bootstrap
;;
(autoload 'use-package "use-package" "" nil 'macro)
(require 'dash)
@@ -136,22 +140,20 @@
async-wait
async-inject-variables))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
(require (cond (IS-MAC 'core-os-osx)
(IS-LINUX 'core-os-linux)
(IS-WINDOWS 'core-os-win32)))
;; Set this up at the end to allow errors to prevent it.
;;
;; Allow errors to stop this from happening
(add-hook! after-init
(defadvice save-buffers-kill-emacs (around no-query-kill-emacs activate)
"Prevent annoying \"Active processes exist\" query when you quit Emacs."
(cl-flet ((process-list ())) ad-do-it)))
(defun display-startup-echo-area-message ()
(after! workgroups2
(message "%sLoaded in %s" (narf/tab-display t t) (emacs-init-time))))
(require 'server)
(unless (server-running-p)
(server-start))

View File

@@ -17,7 +17,7 @@
(neotree-find))))
;;;###autoload
(defun narf|neotree-close-on-window-change ()
(defun narf|neotree-close-on-window-change (&rest _)
"Close neotree to prevent ensuing mindow buggery."
(unless (and (neo-global--window-exists-p)
(eq (current-buffer) (neo-global--get-buffer)))

View File

@@ -5,7 +5,7 @@
(defmacro add-yas-minor-mode! (mode)
"Register minor MODES in yasnippet."
`(after! yasnippet
(when (boundp 'yas-extra-modes)
(when (boundp 'yas--extra-modes)
(add-hook ',(intern (concat (symbol-name (cadr mode)) "-hook"))
(lambda ()
(if (symbol-value ,mode)