General cleanup + refactor

This commit is contained in:
Henrik Lissner 2016-05-01 01:05:25 -04:00
parent 13f6c06ac5
commit 25c9b90000
4 changed files with 64 additions and 86 deletions

View file

@ -110,11 +110,10 @@ enable multiple minor modes for the same regexp.")
;; ;;
;; Modes 'n hooks ;; Modes, hooks 'n hacks
;; ;;
(associate! makefile-gmake-mode :match "/Makefile$") (associate! makefile-gmake-mode :match "/Makefile$")
(add-hook! special-mode (setq truncate-lines nil)) (add-hook! special-mode (setq truncate-lines nil))
(defadvice delete-trailing-whitespace (defadvice delete-trailing-whitespace
@ -137,7 +136,7 @@ enable multiple minor modes for the same regexp.")
(fundamental-mode) (fundamental-mode)
(visual-line-mode))) (visual-line-mode)))
;; Smarter electric-indent ;; Smarter electric-indent (see `def-electric!')
(electric-indent-mode -1) ; on by default (electric-indent-mode -1) ; on by default
(defvar narf-electric-indent-p nil) (defvar narf-electric-indent-p nil)
(defvar-local narf-electric-indent-words '()) (defvar-local narf-electric-indent-words '())
@ -179,6 +178,12 @@ enable multiple minor modes for the same regexp.")
:config (setq avy-all-windows nil :config (setq avy-all-windows nil
avy-background t)) avy-background t))
(use-package dumb-jump
:commands (dumb-jump-go dumb-jump-quick-look dumb-jump-back)
:config
(setq dumb-jump-default-project narf-emacs-dir)
(dumb-jump-mode +1))
(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 (define-key popup-menu-keymap [escape] 'keyboard-quit)) :config (define-key popup-menu-keymap [escape] 'keyboard-quit))
@ -186,23 +191,8 @@ enable multiple minor modes for the same regexp.")
(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))
(use-package dumb-jump
:commands (dumb-jump-go dumb-jump-quick-look dumb-jump-back)
:config
(setq dumb-jump-default-project narf-emacs-dir)
(dumb-jump-mode +1))
(use-package goto-last-change :commands goto-last-change) (use-package goto-last-change :commands goto-last-change)
(use-package miniedit
:commands minibuffer-edit
:init
(map! :map (minibuffer-local-map
minibuffer-local-ns-map
minibuffer-local-completion-map
minibuffer-local-must-match-map)
"\M-\C-e" 'miniedit))
(use-package help-fns+ ; Improved help commands (use-package help-fns+ ; Improved help commands
:commands (describe-buffer describe-command describe-file :commands (describe-buffer describe-command describe-file
describe-keymap describe-option describe-option-of-type)) describe-keymap describe-option describe-option-of-type))
@ -248,6 +238,15 @@ enable multiple minor modes for the same regexp.")
:n "SPC" 'imenu-list-display-entry :n "SPC" 'imenu-list-display-entry
:n [tab] 'hs-toggle-hiding)) :n [tab] 'hs-toggle-hiding))
(use-package miniedit
:commands minibuffer-edit
:init
(map! :map (minibuffer-local-map
minibuffer-local-ns-map
minibuffer-local-completion-map
minibuffer-local-must-match-map)
"\M-\C-e" 'miniedit))
(use-package re-builder (use-package re-builder
:commands (re-builder reb-mode-buffer-p) :commands (re-builder reb-mode-buffer-p)
:init :init
@ -304,8 +303,6 @@ enable multiple minor modes for the same regexp.")
(sp-local-pair 'css-mode "/*" "*/" :post-handlers '(("[d-3]||\n[i]" "RET") ("| " "SPC"))) (sp-local-pair 'css-mode "/*" "*/" :post-handlers '(("[d-3]||\n[i]" "RET") ("| " "SPC")))
(sp-local-pair '(sh-mode markdown-mode) "`" "`" :unless '(sp-point-before-word-p sp-point-before-same-p)) (sp-local-pair '(sh-mode markdown-mode) "`" "`" :unless '(sp-point-before-word-p sp-point-before-same-p))
;; Markup languages
(sp-with-modes '(xml-mode nxml-mode php-mode) (sp-with-modes '(xml-mode nxml-mode php-mode)
(sp-local-pair "<!--" "-->" :post-handlers '(("| " "SPC"))))) (sp-local-pair "<!--" "-->" :post-handlers '(("| " "SPC")))))

View file

@ -1,10 +1,10 @@
;;; core-popup.el --- taming stray windows ;;; core-popup.el --- taming stray windows
;; The following is a whole slew of hackery to get Emacs to treat 'pop-up' windows in a ;; I use a slew of hackery to get Emacs to treat 'pop-up' windows in a sane and "modern"
;; sane and "modern" way (whatever that means). It goes through great lengths to tame ;; way (whatever that means). It goes through great lengths to tame helm, flycheck, help
;; helm, flycheck, help buffers--*even* the beast that is org-mode. ;; buffers--*even* the beast that is org-mode.
;; ;;
;; Be warned, any of this may break as their respective packages update! ;; Be warned, an update could break any of this.
(use-package shackle (use-package shackle
:config :config
@ -16,9 +16,9 @@
("\\`\\*\\(debug:\\)haskell\\*\\'" :regexp t :align below :size 20) ("\\`\\*\\(debug:\\)haskell\\*\\'" :regexp t :align below :size 20)
;; Plugins ;; Plugins
("*helm bookmarks*" :align below :size 7 :select t)
("\\` ?\\*[hH]elm.*?\\*\\'" :regexp t :align below :size 20 :select t) ("\\` ?\\*[hH]elm.*?\\*\\'" :regexp t :align below :size 20 :select t)
(" ?\\*Flycheck.+\\*" :regexp t :align below :size 15 :noselect t) (" ?\\*Flycheck.+\\*" :regexp t :align below :size 15 :noselect t)
("*helm bookmarks*" :align below :size 7 :select t)
(" *NeoTree*" :align left :select t) (" *NeoTree*" :align left :select t)
("*evil-registers*" :align below :size 0.3) ("*evil-registers*" :align below :size 0.3)
("*quickrun*" :align below :size 10) ("*quickrun*" :align below :size 10)

View file

@ -26,11 +26,11 @@
jit-lock-stealth-verbose nil jit-lock-stealth-verbose nil
;; Disable bidirectional text support for slight performance bonus ;; Disable bidirectional text support for slight performance bonus
bidi-display-reordering nil bidi-display-reordering nil
;; Minibuffer resizing ;; Minibuffer resizing
resize-mini-windows 'grow-only resize-mini-windows 'grow-only
max-mini-window-height 0.3 max-mini-window-height 0.3
;; Remove arrow on the right fringe when wrapped ;; Remove arrow on the right fringe when wrapped
fringe-indicator-alist (delq (assoc 'continuation fringe-indicator-alist) fringe-indicator-alist (delq (assoc 'continuation fringe-indicator-alist)
@ -54,23 +54,18 @@
(menu-bar-mode -1) (menu-bar-mode -1)
(scroll-bar-mode -1) ; no scrollbar (scroll-bar-mode -1) ; no scrollbar
(tool-bar-mode -1) ; no toolbar (tool-bar-mode -1) ; no toolbar
;; full filename in frame title ;; full filename in frame title
(setq frame-title-format '(buffer-file-name "%f" ("%b"))) (setq frame-title-format '(buffer-file-name "%f" ("%b")))
;; set fonts ;; set fonts
(set-frame-font (setq narf-current-font narf-default-font) t) (set-frame-font (setq narf-current-font narf-default-font) t)
(set-face-attribute 'default t :font narf-current-font) (set-face-attribute 'default t :font narf-current-font)
;; standardize fringe width ;; standardize fringe width
(fringe-mode narf-fringe-size) (fringe-mode narf-fringe-size)
;; Show tilde in margin on empty lines ;; Show tilde in margin on empty lines
(define-fringe-bitmap 'tilde [64 168 16] nil nil 'center) (define-fringe-bitmap 'tilde [64 168 16] nil nil 'center)
(setcdr (assq 'empty-line fringe-indicator-alist) 'tilde) (setcdr (assq 'empty-line fringe-indicator-alist) 'tilde)
(set-fringe-bitmap-face 'tilde 'font-lock-comment-face) (set-fringe-bitmap-face 'tilde 'font-lock-comment-face)
;; Brighter minibuffer when active + no fringe in minibuffer
;; Brighter minibuffer when active
(defface narf-minibuffer-active '((t (:inherit mode-line))) (defface narf-minibuffer-active '((t (:inherit mode-line)))
"Face for active minibuffer") "Face for active minibuffer")
(add-hook! minibuffer-setup (add-hook! minibuffer-setup
@ -94,30 +89,10 @@
(when (and (> emacs-major-version 24) (featurep 'eldoc)) (when (and (> emacs-major-version 24) (featurep 'eldoc))
(global-eldoc-mode -1)) (global-eldoc-mode -1))
;; line highlighting
(add-hook! (prog-mode markdown-mode) 'hl-line-mode)
;; Disable line highlight in visual mode
(defvar narf--hl-line-mode nil)
(make-variable-buffer-local 'narf--hl-line-mode)
(defun narf|hl-line-on () (if narf--hl-line-mode (hl-line-mode +1)))
(defun narf|hl-line-off () (if narf--hl-line-mode (hl-line-mode -1)))
(add-hook! hl-line-mode (if hl-line-mode (setq narf--hl-line-mode t)))
(add-hook 'evil-visual-state-entry-hook 'narf|hl-line-off)
(add-hook 'evil-visual-state-exit-hook 'narf|hl-line-on)
;; Hide modeline in help windows
(add-hook 'help-mode-hook 'narf|hide-mode-line)
;; Highlight TODO/FIXME/NOTE tags ;; Highlight TODO/FIXME/NOTE tags
(defface narf-todo-face '((t (:inherit font-lock-warning-face))) (defface narf-todo-face '((t (:inherit font-lock-warning-face))) "Face for TODOs")
"Face for TODOs") (defface narf-fixme-face '((t (:inherit font-lock-warning-face))) "Face for FIXMEs")
(defface narf-fixme-face '((t (:inherit font-lock-warning-face))) (defface narf-note-face '((t (:inherit font-lock-warning-face))) "Face for NOTEs")
"Face for FIXMEs")
(defface narf-note-face '((t (:inherit font-lock-warning-face)))
"Face for NOTEs")
(add-hook! (prog-mode emacs-lisp-mode) (add-hook! (prog-mode emacs-lisp-mode)
(font-lock-add-keywords (font-lock-add-keywords
nil '(("\\<\\(TODO\\((.+)\\)?:?\\)" 1 'narf-todo-face prepend) nil '(("\\<\\(TODO\\((.+)\\)?:?\\)" 1 'narf-todo-face prepend)
@ -136,6 +111,20 @@
;; Plugins ;; Plugins
;; ;;
(use-package hl-line
:init
(add-hook! (prog-mode markdown-mode) 'hl-line-mode) ; line highlighting
:config
(defvar-local narf--hl-line-mode nil)
(defun narf|hl-line-on () (if narf--hl-line-mode (hl-line-mode +1)))
(defun narf|hl-line-off () (if narf--hl-line-mode (hl-line-mode -1)))
(add-hook! hl-line-mode (if hl-line-mode (setq narf--hl-line-mode t)))
;; Disable line highlight in visual mode
(add-hook 'evil-visual-state-entry-hook 'narf|hl-line-off)
(add-hook 'evil-visual-state-exit-hook 'narf|hl-line-on))
(use-package visual-fill-column :defer t (use-package visual-fill-column :defer t
:config :config
(setq-default visual-fill-column-center-text nil (setq-default visual-fill-column-center-text nil
@ -278,10 +267,9 @@
(spaceline-define-segment *vc (spaceline-define-segment *vc
"Version control info" "Version control info"
(powerline-raw (concat (replace-regexp-in-string
(concat (replace-regexp-in-string (format "^ %s" (vc-backend buffer-file-name))
(format "^ %s" (vc-backend buffer-file-name)) "" vc-mode))
"" vc-mode)))
:when (and active vc-mode) :when (and active vc-mode)
:face other-face :face other-face
:tight-right t) :tight-right t)
@ -344,29 +332,26 @@ anzu to be enabled."
" ... ")) " ... "))
:when (and (evil-ex-p) (evil-ex-hl-active-p 'evil-ex-substitute)) :when (and (evil-ex-p) (evil-ex-hl-active-p 'evil-ex-substitute))
:tight t :tight t
:face (if active 'mode-line-count-face 'mode-line-inactive) :face (if active 'mode-line-count-face 'mode-line-inactive))
:skip-alternate t)
(spaceline-define-segment *macro-recording (spaceline-define-segment *macro-recording
"Show when recording macro" "Show when recording macro"
(format " %s ▶ " (char-to-string evil-this-macro)) (format " %s ▶ " (char-to-string evil-this-macro))
:when (and active defining-kbd-macro) :when (and active defining-kbd-macro)
:face highlight-face :face highlight-face
:tight t :tight t)
:skip-alternate t)
(spaceline-define-segment *buffer-encoding-abbrev (spaceline-define-segment *buffer-encoding-abbrev
"The line ending convention used in the buffer." "The line ending convention used in the buffer."
(symbol-name buffer-file-coding-system) (format "%s" buffer-file-coding-system)
:when (not (string-match-p "\\(utf-8\\|undecided\\)" :when (not (string-match-p "\\(utf-8\\|undecided\\)"
(symbol-name buffer-file-coding-system)))) (symbol-name buffer-file-coding-system))))
(spaceline-define-segment *major-mode (spaceline-define-segment *major-mode
(powerline-raw (concat
(concat (and (featurep 'face-remap) (/= text-scale-mode-amount 0) (format "(%+d) " text-scale-mode-amount))
(and (featurep 'face-remap) (/= text-scale-mode-amount 0) (format "(%+d) " text-scale-mode-amount)) (if (stringp mode-name) mode-name (car mode-name))
(if (stringp mode-name) mode-name (car mode-name)) (if (stringp mode-line-process) mode-line-process))
(if (stringp mode-line-process) mode-line-process)))
:tight-right t) :tight-right t)
(defun narf--col-at-pos (pos) (defun narf--col-at-pos (pos)
@ -398,11 +383,10 @@ Supports both Emacs and Evil cursor conventions."
;; flycheck ;; flycheck
(defun narf--flycheck-count (state) (defun narf--flycheck-count (state)
"Return flycheck information for the given error type STATE." "Return flycheck information for the given error type STATE."
(let* ((counts (flycheck-count-errors flycheck-current-errors)) (when (flycheck-has-current-errors-p state)
(errorp (flycheck-has-current-errors-p state)) (if (eq 'running flycheck-last-status-change)
(running (eq 'running flycheck-last-status-change)) "?"
(err (cdr (assq state counts)))) (cdr-safe (assq state (flycheck-count-errors flycheck-current-errors))))))
(when errorp (if running "?" err))))
(defface spaceline-flycheck-error (defface spaceline-flycheck-error
'((t (:foreground "#FC5C94" :distant-foreground "#A20C41"))) '((t (:foreground "#FC5C94" :distant-foreground "#A20C41")))

View file

@ -46,20 +46,17 @@
(defun narf/evil-surround-escaped () (defun narf/evil-surround-escaped ()
"Escaped surround characters." "Escaped surround characters."
(let* ((char (string (read-char "\\"))) (let* ((char (string (read-char "\\")))
(pair (cond ((string-match-p "[]})[{(]" char) (pair (acond ((cdr-safe (assoc (string-to-char char) evil-surround-pairs-alist))
(let ((-pair (cdr (assoc (string-to-char char) evil-surround-pairs-alist)))) `(,(car it) . ,(cdr it)))
`(,(car -pair) . ,(cdr -pair)))) (t `(,char . ,char))))
(t (text (if (sp-point-in-string) "\\\\%s" "\\%s")))
`(,char . ,char)))) (cons (format text (car pair))
(format (if (sp-point-in-string) "\\\\%s" "\\%s"))) (format text (cdr pair)))))
(cons (format format (car pair))
(format format (cdr pair)))))
;;;###autoload ;;;###autoload
(defun narf/evil-surround-latex () (defun narf/evil-surround-latex ()
"LaTeX commands" "LaTeX commands"
(let* ((command (read-string "\\"))) (cons (format "\\%s{" (read-string "\\")) "}"))
(cons (format "\\%s{" command) "}")))
;;;###autoload (autoload 'narf/evil-macro-on-all-lines "defuns-evil" nil t) ;;;###autoload (autoload 'narf/evil-macro-on-all-lines "defuns-evil" nil t)
(evil-define-operator narf/evil-macro-on-all-lines (beg end &optional macro) (evil-define-operator narf/evil-macro-on-all-lines (beg end &optional macro)