diff --git a/core/core-editor.el b/core/core-editor.el index 58538cbec..2f0137e1c 100644 --- a/core/core-editor.el +++ b/core/core-editor.el @@ -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$") - (add-hook! special-mode (setq truncate-lines nil)) (defadvice delete-trailing-whitespace @@ -137,7 +136,7 @@ enable multiple minor modes for the same regexp.") (fundamental-mode) (visual-line-mode))) -;; Smarter electric-indent +;; Smarter electric-indent (see `def-electric!') (electric-indent-mode -1) ; on by default (defvar narf-electric-indent-p nil) (defvar-local narf-electric-indent-words '()) @@ -179,6 +178,12 @@ enable multiple minor modes for the same regexp.") :config (setq avy-all-windows nil 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 :commands (emr-initialize emr-show-refactor-menu emr-declare-command) :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 :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 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 :commands (describe-buffer describe-command describe-file 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 [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 :commands (re-builder reb-mode-buffer-p) :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 '(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-local-pair "" :post-handlers '(("| " "SPC"))))) diff --git a/core/core-popup.el b/core/core-popup.el index 6cf36af18..e4d55ff4d 100644 --- a/core/core-popup.el +++ b/core/core-popup.el @@ -1,10 +1,10 @@ ;;; core-popup.el --- taming stray windows -;; The following is a whole slew of hackery to get Emacs to treat 'pop-up' windows in a -;; sane and "modern" way (whatever that means). It goes through great lengths to tame -;; helm, flycheck, help buffers--*even* the beast that is org-mode. +;; I use a slew of hackery to get Emacs to treat 'pop-up' windows in a sane and "modern" +;; way (whatever that means). It goes through great lengths to tame helm, flycheck, help +;; 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 :config @@ -16,9 +16,9 @@ ("\\`\\*\\(debug:\\)haskell\\*\\'" :regexp t :align below :size 20) ;; Plugins - ("*helm bookmarks*" :align below :size 7 :select t) ("\\` ?\\*[hH]elm.*?\\*\\'" :regexp t :align below :size 20 :select t) (" ?\\*Flycheck.+\\*" :regexp t :align below :size 15 :noselect t) + ("*helm bookmarks*" :align below :size 7 :select t) (" *NeoTree*" :align left :select t) ("*evil-registers*" :align below :size 0.3) ("*quickrun*" :align below :size 10) diff --git a/core/core-ui.el b/core/core-ui.el index 660397101..19115afa6 100644 --- a/core/core-ui.el +++ b/core/core-ui.el @@ -26,11 +26,11 @@ jit-lock-stealth-verbose nil ;; Disable bidirectional text support for slight performance bonus - bidi-display-reordering nil + bidi-display-reordering nil ;; Minibuffer resizing - resize-mini-windows 'grow-only - max-mini-window-height 0.3 + 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) @@ -54,23 +54,18 @@ (menu-bar-mode -1) (scroll-bar-mode -1) ; no scrollbar (tool-bar-mode -1) ; no toolbar - ;; full filename in frame title (setq frame-title-format '(buffer-file-name "%f" ("%b"))) - ;; set fonts (set-frame-font (setq narf-current-font narf-default-font) t) (set-face-attribute 'default t :font narf-current-font) - ;; standardize fringe width (fringe-mode narf-fringe-size) - ;; Show tilde in margin on empty lines (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 + ;; Brighter minibuffer when active + no fringe in minibuffer (defface narf-minibuffer-active '((t (:inherit mode-line))) "Face for active minibuffer") (add-hook! minibuffer-setup @@ -94,30 +89,10 @@ (when (and (> emacs-major-version 24) (featurep 'eldoc)) (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 -(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") +(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") (add-hook! (prog-mode emacs-lisp-mode) (font-lock-add-keywords nil '(("\\<\\(TODO\\((.+)\\)?:?\\)" 1 'narf-todo-face prepend) @@ -136,6 +111,20 @@ ;; 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 :config (setq-default visual-fill-column-center-text nil @@ -278,10 +267,9 @@ (spaceline-define-segment *vc "Version control info" - (powerline-raw - (concat (replace-regexp-in-string - (format "^ %s" (vc-backend buffer-file-name)) - "" vc-mode))) + (concat (replace-regexp-in-string + (format "^ %s" (vc-backend buffer-file-name)) + "" vc-mode)) :when (and active vc-mode) :face other-face :tight-right t) @@ -344,29 +332,26 @@ anzu to be enabled." " ... ")) :when (and (evil-ex-p) (evil-ex-hl-active-p 'evil-ex-substitute)) :tight t - :face (if active 'mode-line-count-face 'mode-line-inactive) - :skip-alternate t) + :face (if active 'mode-line-count-face 'mode-line-inactive)) (spaceline-define-segment *macro-recording "Show when recording macro" (format " %s ▶ " (char-to-string evil-this-macro)) :when (and active defining-kbd-macro) :face highlight-face - :tight t - :skip-alternate t) + :tight t) (spaceline-define-segment *buffer-encoding-abbrev "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\\)" (symbol-name buffer-file-coding-system)))) (spaceline-define-segment *major-mode - (powerline-raw - (concat - (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-line-process) mode-line-process))) + (concat + (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-line-process) mode-line-process)) :tight-right t) (defun narf--col-at-pos (pos) @@ -398,11 +383,10 @@ Supports both Emacs and Evil cursor conventions." ;; flycheck (defun narf--flycheck-count (state) "Return flycheck information for the given error type STATE." - (let* ((counts (flycheck-count-errors flycheck-current-errors)) - (errorp (flycheck-has-current-errors-p state)) - (running (eq 'running flycheck-last-status-change)) - (err (cdr (assq state counts)))) - (when errorp (if running "?" err)))) + (when (flycheck-has-current-errors-p state) + (if (eq 'running flycheck-last-status-change) + "?" + (cdr-safe (assq state (flycheck-count-errors flycheck-current-errors)))))) (defface spaceline-flycheck-error '((t (:foreground "#FC5C94" :distant-foreground "#A20C41"))) diff --git a/core/defuns/defuns-evil.el b/core/defuns/defuns-evil.el index 94c334e7a..4bd88fc2c 100644 --- a/core/defuns/defuns-evil.el +++ b/core/defuns/defuns-evil.el @@ -46,20 +46,17 @@ (defun narf/evil-surround-escaped () "Escaped surround characters." (let* ((char (string (read-char "\\"))) - (pair (cond ((string-match-p "[]})[{(]" char) - (let ((-pair (cdr (assoc (string-to-char char) evil-surround-pairs-alist)))) - `(,(car -pair) . ,(cdr -pair)))) - (t - `(,char . ,char)))) - (format (if (sp-point-in-string) "\\\\%s" "\\%s"))) - (cons (format format (car pair)) - (format format (cdr pair))))) + (pair (acond ((cdr-safe (assoc (string-to-char char) evil-surround-pairs-alist)) + `(,(car it) . ,(cdr it))) + (t `(,char . ,char)))) + (text (if (sp-point-in-string) "\\\\%s" "\\%s"))) + (cons (format text (car pair)) + (format text (cdr pair))))) ;;;###autoload (defun narf/evil-surround-latex () "LaTeX commands" - (let* ((command (read-string "\\"))) - (cons (format "\\%s{" command) "}"))) + (cons (format "\\%s{" (read-string "\\")) "}")) ;;;###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)