2017-06-09 00:19:44 +02:00
|
|
|
|
;;; core-ui.el -*- lexical-binding: t; -*-
|
2015-06-15 09:05:52 +02:00
|
|
|
|
|
2017-06-28 16:18:22 +02:00
|
|
|
|
(defvar doom-theme nil
|
|
|
|
|
"A symbol representing the color theme to load.")
|
|
|
|
|
|
2017-07-04 19:53:39 +02:00
|
|
|
|
(defvar doom-font nil
|
2017-12-08 22:40:31 -05:00
|
|
|
|
"The default font to use. Expects a `font-spec'.")
|
2017-06-28 16:18:22 +02:00
|
|
|
|
|
2017-07-04 19:52:21 +02:00
|
|
|
|
(defvar doom-big-font nil
|
2017-12-08 22:40:31 -05:00
|
|
|
|
"The default large font to use when `doom-big-font-mode' is enabled. Expects a
|
|
|
|
|
`font-spec'.")
|
2017-07-04 19:52:21 +02:00
|
|
|
|
|
2017-07-04 19:53:39 +02:00
|
|
|
|
(defvar doom-variable-pitch-font nil
|
2017-12-08 22:40:31 -05:00
|
|
|
|
"The default font to use for variable-pitch text. Expects a `font-spec'.")
|
2017-06-28 16:18:22 +02:00
|
|
|
|
|
2017-07-04 19:53:39 +02:00
|
|
|
|
(defvar doom-unicode-font nil
|
2017-12-08 22:40:31 -05:00
|
|
|
|
"Fallback font for unicode glyphs. Is ignored if :feature unicode is active.
|
|
|
|
|
Expects a `font-spec'.")
|
2017-06-28 16:18:22 +02:00
|
|
|
|
|
|
|
|
|
(defvar doom-major-mode-names
|
|
|
|
|
'((sh-mode . "sh")
|
|
|
|
|
(emacs-lisp-mode . "Elisp"))
|
|
|
|
|
"An alist mapping major modes symbols to strings (or functions that will
|
|
|
|
|
return a string). This changes the 'long' name of a major-mode, allowing for
|
|
|
|
|
shorter major mode name in the mode-line. See `doom|set-mode-name'.")
|
|
|
|
|
|
2018-05-24 22:03:17 +02:00
|
|
|
|
;;
|
2017-06-28 16:18:22 +02:00
|
|
|
|
(defvar doom-init-ui-hook nil
|
2018-05-11 00:08:50 +02:00
|
|
|
|
"List of hooks to run when the UI has been initialized.")
|
|
|
|
|
|
2017-02-19 18:11:28 -05:00
|
|
|
|
(setq-default
|
2018-03-27 19:18:26 -04:00
|
|
|
|
ansi-color-for-comint-mode t
|
2017-02-19 18:11:28 -05:00
|
|
|
|
bidi-display-reordering nil ; disable bidirectional text for tiny performance boost
|
|
|
|
|
blink-matching-paren nil ; don't blink--too distracting
|
2018-02-18 02:59:11 -05:00
|
|
|
|
compilation-always-kill t ; kill compilation process before starting another
|
|
|
|
|
compilation-ask-about-save nil ; save all buffers on `compile'
|
|
|
|
|
compilation-scroll-output 'first-error
|
|
|
|
|
confirm-nonexistent-file-or-buffer t
|
2018-08-20 23:56:56 +02:00
|
|
|
|
confirm-kill-emacs #'doom-quit-p ; custom confirmation when killing Emacs
|
|
|
|
|
cursor-in-non-selected-windows nil ; hide cursors in other windows
|
2018-05-24 21:20:39 +02:00
|
|
|
|
custom-theme-directory (expand-file-name "themes/" doom-private-dir)
|
2017-07-18 22:07:13 +02:00
|
|
|
|
display-line-numbers-width 3
|
2018-02-18 02:59:11 -05:00
|
|
|
|
enable-recursive-minibuffers nil
|
2017-02-19 18:11:28 -05:00
|
|
|
|
frame-inhibit-implied-resize t
|
|
|
|
|
;; remove continuation arrow on right fringe
|
2018-06-23 16:48:58 +02:00
|
|
|
|
fringe-indicator-alist
|
|
|
|
|
(delq (assq 'continuation fringe-indicator-alist)
|
|
|
|
|
fringe-indicator-alist)
|
2017-03-03 12:22:06 +01:00
|
|
|
|
highlight-nonselected-windows nil
|
2017-02-19 18:11:28 -05:00
|
|
|
|
image-animate-loop t
|
|
|
|
|
indicate-buffer-boundaries nil
|
|
|
|
|
indicate-empty-lines nil
|
2018-05-11 20:17:21 +02:00
|
|
|
|
inhibit-compacting-font-caches t
|
2017-02-19 18:11:28 -05:00
|
|
|
|
max-mini-window-height 0.3
|
2017-06-05 00:47:56 +02:00
|
|
|
|
mode-line-default-help-echo nil ; disable mode-line mouseovers
|
|
|
|
|
mouse-yank-at-point t ; middle-click paste at point, not at click
|
|
|
|
|
resize-mini-windows 'grow-only ; Minibuffer resizing
|
|
|
|
|
show-help-function nil ; hide :help-echo text
|
2017-07-02 16:55:39 +02:00
|
|
|
|
split-width-threshold 160 ; favor horizontal splits
|
2017-05-14 09:44:22 +02:00
|
|
|
|
uniquify-buffer-name-style 'forward
|
2017-06-05 00:47:56 +02:00
|
|
|
|
use-dialog-box nil ; always avoid GUI
|
2017-02-19 18:11:28 -05:00
|
|
|
|
visible-cursor nil
|
2017-03-09 00:47:35 -05:00
|
|
|
|
x-stretch-cursor nil
|
2017-05-16 22:21:55 +02:00
|
|
|
|
;; `pos-tip' defaults
|
|
|
|
|
pos-tip-internal-border-width 6
|
|
|
|
|
pos-tip-border-width 1
|
2017-02-19 18:11:28 -05:00
|
|
|
|
;; no beeping or blinking please
|
2017-04-17 02:17:10 -04:00
|
|
|
|
ring-bell-function #'ignore
|
2018-05-10 23:19:03 +02:00
|
|
|
|
visible-bell nil
|
|
|
|
|
;; don't resize emacs in steps, it looks weird
|
|
|
|
|
window-resize-pixelwise t
|
|
|
|
|
frame-resize-pixelwise t)
|
2017-01-28 02:03:35 -05:00
|
|
|
|
|
2017-04-17 02:17:10 -04:00
|
|
|
|
(fset #'yes-or-no-p #'y-or-n-p) ; y/n instead of yes/no
|
2017-01-28 02:03:35 -05:00
|
|
|
|
|
2018-08-21 02:52:08 +02:00
|
|
|
|
|
2016-03-03 15:04:14 -05:00
|
|
|
|
;;
|
|
|
|
|
;; Plugins
|
|
|
|
|
;;
|
|
|
|
|
|
2018-05-24 23:41:40 +02:00
|
|
|
|
;; `avy'
|
|
|
|
|
(setq avy-all-windows nil
|
|
|
|
|
avy-background t)
|
2018-05-17 15:29:29 +02:00
|
|
|
|
|
2018-05-24 23:41:40 +02:00
|
|
|
|
;; `all-the-icons'
|
2017-06-09 00:19:44 +02:00
|
|
|
|
(def-package! all-the-icons
|
|
|
|
|
:commands (all-the-icons-octicon all-the-icons-faicon all-the-icons-fileicon
|
2018-08-28 13:36:44 +02:00
|
|
|
|
all-the-icons-wicon all-the-icons-material all-the-icons-alltheicon)
|
2017-06-09 00:19:44 +02:00
|
|
|
|
:init
|
|
|
|
|
(defun doom*disable-all-the-icons-in-tty (orig-fn &rest args)
|
|
|
|
|
(when (display-graphic-p)
|
|
|
|
|
(apply orig-fn args)))
|
2018-08-28 13:36:44 +02:00
|
|
|
|
:config
|
2017-06-09 00:19:44 +02:00
|
|
|
|
;; all-the-icons doesn't work in the terminal, so we "disable" it.
|
2017-12-29 01:46:20 -05:00
|
|
|
|
(dolist (fn '(all-the-icons-octicon all-the-icons-material
|
|
|
|
|
all-the-icons-faicon all-the-icons-fileicon
|
|
|
|
|
all-the-icons-wicon all-the-icons-alltheicon))
|
|
|
|
|
(advice-add fn :around #'doom*disable-all-the-icons-in-tty)))
|
2017-06-09 00:19:44 +02:00
|
|
|
|
|
2018-05-24 23:41:40 +02:00
|
|
|
|
;; `hide-mode-line-mode'
|
|
|
|
|
(add-hook 'completion-list-mode-hook #'hide-mode-line-mode)
|
2018-06-17 13:11:33 +02:00
|
|
|
|
(add-hook 'Man-mode-hook #'hide-mode-line-mode)
|
2018-05-24 23:41:40 +02:00
|
|
|
|
|
2018-08-17 13:03:59 +02:00
|
|
|
|
;; `highlight-numbers' -- better number literal fontification in code
|
|
|
|
|
(def-package! highlight-numbers
|
|
|
|
|
:hook (prog-mode . highlight-numbers-mode)
|
2018-09-02 15:15:58 +02:00
|
|
|
|
:config (setq highlight-numbers-generic-regexp "\\_<[[:digit:]]+\\(?:\\.[0-9]*\\)?\\_>"))
|
2018-07-29 16:51:06 +02:00
|
|
|
|
|
2018-08-05 22:09:46 +02:00
|
|
|
|
;; `highlight-escape-sequences'
|
|
|
|
|
(def-package! highlight-escape-sequences
|
2018-08-16 15:17:07 +02:00
|
|
|
|
:hook ((prog-mode conf-mode) . highlight-escape-sequences-mode))
|
2018-08-05 22:09:46 +02:00
|
|
|
|
|
2018-05-24 23:41:40 +02:00
|
|
|
|
;; `rainbow-delimiters' Helps us distinguish stacked delimiter pairs. Especially
|
|
|
|
|
;; in parentheses-drunk languages like Lisp.
|
|
|
|
|
(def-package! rainbow-delimiters
|
|
|
|
|
:hook (lisp-mode . rainbow-delimiters-mode)
|
|
|
|
|
:config (setq rainbow-delimiters-max-face-count 3))
|
|
|
|
|
|
|
|
|
|
;; `restart-emacs'
|
|
|
|
|
(setq restart-emacs--args (list "--restore"))
|
|
|
|
|
|
|
|
|
|
;; `visual-fill-column' For a distractions-free-like UI, that dynamically
|
|
|
|
|
;; resizes margins and can center a buffer.
|
|
|
|
|
(setq visual-fill-column-center-text t
|
|
|
|
|
visual-fill-column-width
|
|
|
|
|
;; take Emacs 26 line numbers into account
|
|
|
|
|
(+ (if (boundp 'display-line-numbers) 6 0)
|
|
|
|
|
fill-column))
|
2017-01-16 23:15:48 -05:00
|
|
|
|
|
2018-08-26 16:38:35 +02:00
|
|
|
|
(defun doom*hide-undefined-which-key-binds (bindings)
|
|
|
|
|
(cl-loop for bind in bindings
|
|
|
|
|
if (or (member (cdr bind) '("Prefix Command" "??"))
|
|
|
|
|
(fboundp (intern (cdr bind))))
|
|
|
|
|
collect bind))
|
|
|
|
|
(advice-add #'which-key--get-current-bindings :filter-return #'doom*hide-undefined-which-key-binds)
|
|
|
|
|
(advice-add #'which-key--get-keymap-bindings :filter-return #'doom*hide-undefined-which-key-binds)
|
|
|
|
|
|
2018-03-02 17:40:51 -05:00
|
|
|
|
|
2018-05-24 23:41:40 +02:00
|
|
|
|
;;
|
|
|
|
|
;; Built-in packages
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
;; show typed keystrokes in minibuffer
|
|
|
|
|
(defun doom|enable-ui-keystrokes () (setq echo-keystrokes 0.02))
|
|
|
|
|
(defun doom|disable-ui-keystrokes () (setq echo-keystrokes 0))
|
|
|
|
|
(doom|enable-ui-keystrokes)
|
|
|
|
|
;; ...but hide them while isearch is active
|
|
|
|
|
(add-hook 'isearch-mode-hook #'doom|disable-ui-keystrokes)
|
|
|
|
|
(add-hook 'isearch-mode-end-hook #'doom|enable-ui-keystrokes)
|
2017-01-16 23:15:48 -05:00
|
|
|
|
|
2017-07-18 22:12:50 +02:00
|
|
|
|
;; Highlights the current line
|
2017-02-23 00:06:12 -05:00
|
|
|
|
(def-package! hl-line ; built-in
|
2017-12-08 22:33:12 -05:00
|
|
|
|
:hook ((prog-mode text-mode conf-mode) . hl-line-mode)
|
2017-02-19 18:11:28 -05:00
|
|
|
|
:config
|
2017-06-05 00:47:56 +02:00
|
|
|
|
;; I don't need hl-line showing in other windows. This also offers a small
|
|
|
|
|
;; speed boost when buffer is displayed in multiple windows.
|
2016-06-08 14:43:40 -04:00
|
|
|
|
(setq hl-line-sticky-flag nil
|
2017-05-14 00:19:45 +02:00
|
|
|
|
global-hl-line-sticky-flag nil)
|
|
|
|
|
|
2017-12-11 13:46:09 -05:00
|
|
|
|
;; On Emacs 26+, when point is on the last line, hl-line highlights bleed into
|
|
|
|
|
;; the rest of the window after eob. This is the fix.
|
2018-08-31 23:38:54 +02:00
|
|
|
|
(unless (get 'display-line-numbers 'nlinum)
|
2017-12-11 13:46:09 -05:00
|
|
|
|
(defun doom--line-range ()
|
|
|
|
|
(cons (line-beginning-position)
|
2017-12-11 15:23:42 -05:00
|
|
|
|
(cond ((save-excursion
|
|
|
|
|
(goto-char (line-end-position))
|
|
|
|
|
(and (eobp) (not (bolp))))
|
|
|
|
|
(1- (line-end-position)))
|
|
|
|
|
((or (eobp) (save-excursion (forward-line) (eobp)))
|
|
|
|
|
(line-end-position))
|
2018-07-09 15:33:31 +02:00
|
|
|
|
((line-beginning-position 2)))))
|
2017-12-11 13:46:09 -05:00
|
|
|
|
(setq hl-line-range-function #'doom--line-range))
|
|
|
|
|
|
2018-08-31 23:38:54 +02:00
|
|
|
|
;; Disable `hl-line' in evil-visual mode (temporarily). `hl-line' can make the
|
|
|
|
|
;; selection region harder to see while in evil visual mode.
|
2017-05-14 00:19:45 +02:00
|
|
|
|
(after! evil
|
2017-11-30 20:22:51 -05:00
|
|
|
|
(defvar-local doom-buffer-hl-line-mode nil)
|
|
|
|
|
(defun doom|disable-hl-line ()
|
|
|
|
|
(when hl-line-mode
|
|
|
|
|
(setq doom-buffer-hl-line-mode t)
|
|
|
|
|
(hl-line-mode -1)))
|
|
|
|
|
(defun doom|enable-hl-line-maybe ()
|
|
|
|
|
(if doom-buffer-hl-line-mode (hl-line-mode +1)))
|
2017-07-18 22:12:50 +02:00
|
|
|
|
(add-hook 'evil-visual-state-entry-hook #'doom|disable-hl-line)
|
2017-11-30 20:22:51 -05:00
|
|
|
|
(add-hook 'evil-visual-state-exit-hook #'doom|enable-hl-line-maybe)))
|
2016-05-01 01:05:25 -04:00
|
|
|
|
|
2018-01-03 13:54:51 -05:00
|
|
|
|
;; undo/redo changes to Emacs' window layout
|
2018-05-14 18:40:35 +02:00
|
|
|
|
(def-package! winner
|
2018-07-02 23:29:53 +02:00
|
|
|
|
:after-call doom-exit-window-hook
|
2018-05-14 18:40:35 +02:00
|
|
|
|
:preface (defvar winner-dont-bind-my-keys t) ; I'll bind keys myself
|
|
|
|
|
:config (winner-mode +1))
|
2018-01-03 13:54:51 -05:00
|
|
|
|
|
|
|
|
|
;; highlight matching delimiters
|
2018-05-14 18:40:35 +02:00
|
|
|
|
(def-package! paren
|
2018-07-02 23:29:53 +02:00
|
|
|
|
:after-call (after-find-file doom-exit-buffer-hook)
|
2018-07-06 12:48:41 +02:00
|
|
|
|
:init
|
2018-07-06 01:06:13 +02:00
|
|
|
|
(defun doom|disable-show-paren-mode ()
|
|
|
|
|
"Turn off `show-paren-mode' buffer-locally."
|
|
|
|
|
(set (make-local-variable 'show-paren-mode) nil))
|
2018-07-06 12:48:41 +02:00
|
|
|
|
:config
|
2018-05-14 18:40:35 +02:00
|
|
|
|
(setq show-paren-delay 0.1
|
|
|
|
|
show-paren-highlight-openparen t
|
|
|
|
|
show-paren-when-point-inside-paren t)
|
|
|
|
|
(show-paren-mode +1))
|
2018-01-03 13:54:51 -05:00
|
|
|
|
|
|
|
|
|
;; The native border "consumes" a pixel of the fringe on righter-most splits,
|
|
|
|
|
;; `window-divider' does not. Available since Emacs 25.1.
|
|
|
|
|
(setq-default window-divider-default-places t
|
2018-01-29 17:09:09 -05:00
|
|
|
|
window-divider-default-bottom-width 1
|
2018-01-03 13:54:51 -05:00
|
|
|
|
window-divider-default-right-width 1)
|
|
|
|
|
(add-hook 'doom-init-ui-hook #'window-divider-mode)
|
|
|
|
|
|
2018-02-01 19:49:37 -05:00
|
|
|
|
;; remove prompt if the file is opened in other clients
|
|
|
|
|
(defun server-remove-kill-buffer-hook ()
|
2018-05-14 20:55:55 +02:00
|
|
|
|
(remove-hook 'kill-buffer-query-functions #'server-kill-buffer-query-function))
|
|
|
|
|
(add-hook 'server-visit-hook #'server-remove-kill-buffer-hook)
|
2018-02-01 19:49:37 -05:00
|
|
|
|
|
2018-07-29 18:26:20 +02:00
|
|
|
|
;; `whitespace-mode' (built-in)
|
2018-05-08 23:21:17 +02:00
|
|
|
|
(setq whitespace-line-column nil
|
|
|
|
|
whitespace-style
|
|
|
|
|
'(face indentation tabs tab-mark spaces space-mark newline newline-mark
|
|
|
|
|
trailing lines-tail)
|
|
|
|
|
whitespace-display-mappings
|
|
|
|
|
'((tab-mark ?\t [?› ?\t])
|
|
|
|
|
(newline-mark ?\n [?¬ ?\n])
|
|
|
|
|
(space-mark ?\ [?·] [?.])))
|
|
|
|
|
|
2018-08-31 23:38:54 +02:00
|
|
|
|
(defun doom|highlight-non-default-indentation ()
|
|
|
|
|
"Highlight whitespace that doesn't match your `indent-tabs-mode' setting."
|
2018-06-06 19:23:27 +02:00
|
|
|
|
(unless (or (bound-and-true-p global-whitespace-mode)
|
|
|
|
|
(bound-and-true-p whitespace-mode)
|
|
|
|
|
(eq indent-tabs-mode (default-value 'indent-tabs-mode))
|
2018-05-28 15:50:11 +02:00
|
|
|
|
(eq major-mode 'fundamental-mode)
|
2018-05-26 03:09:53 +02:00
|
|
|
|
(derived-mode-p 'special-mode))
|
2018-05-08 23:21:17 +02:00
|
|
|
|
(require 'whitespace)
|
|
|
|
|
(set (make-local-variable 'whitespace-style)
|
|
|
|
|
(if (or (bound-and-true-p whitespace-mode)
|
|
|
|
|
(bound-and-true-p whitespace-newline-mode))
|
|
|
|
|
(cl-union (if indent-tabs-mode '(tabs tab-mark) '(spaces space-mark))
|
|
|
|
|
whitespace-style)
|
|
|
|
|
`(face ,@(if indent-tabs-mode '(tabs tab-mark) '(spaces space-mark))
|
|
|
|
|
trailing-lines tail)))
|
|
|
|
|
(whitespace-mode +1)))
|
|
|
|
|
|
2018-01-03 13:54:51 -05:00
|
|
|
|
|
2017-07-18 22:07:13 +02:00
|
|
|
|
;;
|
|
|
|
|
;; Line numbers
|
|
|
|
|
;;
|
|
|
|
|
|
2018-08-21 02:54:28 +02:00
|
|
|
|
;; Emacs 26+ has native line number support, and will ignore nlinum. This is for
|
|
|
|
|
;; Emacs 25 users:
|
|
|
|
|
(defun doom|enable-line-numbers () (display-line-numbers-mode +1))
|
|
|
|
|
(defun doom|disable-line-numbers () (display-line-numbers-mode -1))
|
|
|
|
|
|
2017-12-10 14:50:43 -05:00
|
|
|
|
;; Line number column. A faster (or equivalent, in the worst case) line number
|
|
|
|
|
;; plugin than `linum-mode'.
|
|
|
|
|
(def-package! nlinum
|
2018-08-21 04:10:18 +02:00
|
|
|
|
:when (get 'display-line-numbers 'nlinum)
|
2017-12-10 14:50:43 -05:00
|
|
|
|
:commands nlinum-mode
|
|
|
|
|
:init
|
|
|
|
|
(defvar doom-line-number-lpad 4
|
|
|
|
|
"How much padding to place before line numbers.")
|
|
|
|
|
(defvar doom-line-number-rpad 1
|
|
|
|
|
"How much padding to place after line numbers.")
|
|
|
|
|
(defvar doom-line-number-pad-char 32
|
|
|
|
|
"Character to use for padding line numbers.
|
2017-07-18 22:07:13 +02:00
|
|
|
|
|
|
|
|
|
By default, this is a space character. If you use `whitespace-mode' with
|
|
|
|
|
`space-mark', the whitespace in line numbers will be affected (this can look
|
|
|
|
|
ugly). In this case, you can change this to ?\u2002, which is a unicode
|
|
|
|
|
character that looks like a space that `whitespace-mode' won't affect.")
|
2017-12-10 14:50:43 -05:00
|
|
|
|
:config
|
|
|
|
|
(setq nlinum-highlight-current-line t)
|
2017-07-18 22:07:13 +02:00
|
|
|
|
|
2017-12-10 14:50:43 -05:00
|
|
|
|
;; Fix lingering hl-line overlays (caused by nlinum)
|
|
|
|
|
(add-hook! 'hl-line-mode-hook
|
|
|
|
|
(remove-overlays (point-min) (point-max) 'face 'hl-line))
|
2017-07-18 22:07:13 +02:00
|
|
|
|
|
2017-12-10 14:50:43 -05:00
|
|
|
|
(defun doom-nlinum-format-fn (line _width)
|
|
|
|
|
"A more customizable `nlinum-format-function'. See `doom-line-number-lpad',
|
2017-07-18 22:07:13 +02:00
|
|
|
|
`doom-line-number-rpad' and `doom-line-number-pad-char'. Allows a fix for
|
|
|
|
|
`whitespace-mode' space-marks appearing inside the line number."
|
2017-12-10 14:50:43 -05:00
|
|
|
|
(let ((str (number-to-string line)))
|
|
|
|
|
(setq str (concat (make-string (max 0 (- doom-line-number-lpad (length str)))
|
|
|
|
|
doom-line-number-pad-char)
|
|
|
|
|
str
|
|
|
|
|
(make-string doom-line-number-rpad doom-line-number-pad-char)))
|
|
|
|
|
(put-text-property 0 (length str) 'face
|
|
|
|
|
(if (and nlinum-highlight-current-line
|
|
|
|
|
(= line nlinum--current-line))
|
|
|
|
|
'nlinum-current-line
|
|
|
|
|
'linum)
|
|
|
|
|
str)
|
|
|
|
|
str))
|
|
|
|
|
(setq nlinum-format-function #'doom-nlinum-format-fn)
|
|
|
|
|
|
|
|
|
|
(defun doom|init-nlinum-width ()
|
|
|
|
|
"Calculate line number column width beforehand (optimization)."
|
|
|
|
|
(setq nlinum--width
|
|
|
|
|
(length (save-excursion (goto-char (point-max))
|
|
|
|
|
(format-mode-line "%l")))))
|
|
|
|
|
(add-hook 'nlinum-mode-hook #'doom|init-nlinum-width))
|
|
|
|
|
|
|
|
|
|
;; Fixes disappearing line numbers in nlinum and other quirks
|
|
|
|
|
(def-package! nlinum-hl
|
2018-08-21 04:10:18 +02:00
|
|
|
|
:when (get 'display-line-numbers 'nlinum)
|
2017-12-10 14:50:43 -05:00
|
|
|
|
:after nlinum
|
|
|
|
|
:config
|
|
|
|
|
;; With `markdown-fontify-code-blocks-natively' enabled in `markdown-mode',
|
|
|
|
|
;; line numbers tend to vanish next to code blocks.
|
|
|
|
|
(advice-add #'markdown-fontify-code-block-natively
|
|
|
|
|
:after #'nlinum-hl-do-markdown-fontify-region)
|
|
|
|
|
;; When using `web-mode's code-folding an entire range of line numbers will
|
|
|
|
|
;; vanish in the affected area.
|
|
|
|
|
(advice-add #'web-mode-fold-or-unfold :after #'nlinum-hl-do-generic-flush)
|
|
|
|
|
;; Changing fonts can leave nlinum line numbers in their original size; this
|
|
|
|
|
;; forces them to resize.
|
|
|
|
|
(advice-add #'set-frame-font :after #'nlinum-hl-flush-all-windows))
|
|
|
|
|
|
|
|
|
|
(def-package! nlinum-relative
|
2018-08-21 04:10:18 +02:00
|
|
|
|
:when (get 'display-line-numbers 'nlinum)
|
2018-01-30 14:05:39 -05:00
|
|
|
|
:commands (nlinum-relative-mode nlinum-relative-on nlinum-relative-off)
|
2018-01-30 01:18:18 -05:00
|
|
|
|
:config
|
|
|
|
|
(setq nlinum-format " %d ")
|
2018-05-11 00:08:50 +02:00
|
|
|
|
(add-hook 'evil-mode #'nlinum-relative-setup-evil))
|
2017-07-18 22:07:13 +02:00
|
|
|
|
|
|
|
|
|
|
2017-02-11 06:02:46 -05:00
|
|
|
|
;;
|
2018-01-03 13:54:51 -05:00
|
|
|
|
;; Theme & font
|
2017-02-11 06:02:46 -05:00
|
|
|
|
;;
|
|
|
|
|
|
2018-06-14 13:57:03 +02:00
|
|
|
|
(defvar doom-last-window-system
|
|
|
|
|
(if (daemonp) 'daemon initial-window-system)
|
2018-03-30 00:08:25 -04:00
|
|
|
|
"The `window-system' of the last frame. If this doesn't match the current
|
|
|
|
|
frame's window-system, the theme will be reloaded.")
|
|
|
|
|
|
|
|
|
|
(defun doom|init-fonts ()
|
2018-02-02 16:56:34 -05:00
|
|
|
|
"Initialize fonts."
|
2018-07-03 03:38:18 +02:00
|
|
|
|
(condition-case e
|
2018-06-16 00:37:50 +02:00
|
|
|
|
(custom-set-faces
|
|
|
|
|
(when (fontp doom-font)
|
|
|
|
|
(let ((xlfd (font-xlfd-name doom-font)))
|
2018-06-23 16:48:58 +02:00
|
|
|
|
(add-to-list 'default-frame-alist (cons 'font xlfd))
|
2018-06-16 00:37:50 +02:00
|
|
|
|
`(fixed-pitch ((t (:font ,xlfd))))))
|
|
|
|
|
(when (fontp doom-variable-pitch-font)
|
|
|
|
|
`(variable-pitch ((t (:font ,(font-xlfd-name doom-variable-pitch-font))))))
|
|
|
|
|
;; Fallback to `doom-unicode-font' for Unicode characters
|
|
|
|
|
(when (fontp doom-unicode-font)
|
2018-09-03 13:14:59 +02:00
|
|
|
|
(set-fontset-font t 'unicode doom-unicode-font nil 'append)
|
2018-06-16 00:37:50 +02:00
|
|
|
|
nil))
|
2018-07-03 03:38:18 +02:00
|
|
|
|
((debug error)
|
|
|
|
|
(if (string-prefix-p "Font not available: " (error-message-string e))
|
2018-03-22 19:32:00 -04:00
|
|
|
|
(lwarn 'doom-ui :warning
|
|
|
|
|
"Could not find the '%s' font on your system, falling back to system font"
|
2018-07-03 03:38:18 +02:00
|
|
|
|
(font-get (caddr e) :family))
|
2018-03-22 19:32:00 -04:00
|
|
|
|
(lwarn 'doom-ui :error
|
|
|
|
|
"Unexpected error while initializing fonts: %s"
|
2018-07-03 03:38:18 +02:00
|
|
|
|
(error-message-string e))))))
|
2017-02-11 06:02:46 -05:00
|
|
|
|
|
2018-03-22 19:26:07 -04:00
|
|
|
|
(defun doom|init-theme ()
|
|
|
|
|
"Set the theme and load the font, in that order."
|
2018-07-25 18:28:33 +02:00
|
|
|
|
(when (and doom-theme (not (memq doom-theme custom-enabled-themes)))
|
2018-03-30 00:08:25 -04:00
|
|
|
|
(load-theme doom-theme t)))
|
2018-03-22 19:26:07 -04:00
|
|
|
|
|
2018-01-03 13:54:51 -05:00
|
|
|
|
;; Getting themes to remain consistent across GUI Emacs, terminal Emacs and
|
2018-02-02 16:56:34 -05:00
|
|
|
|
;; daemon Emacs is hairy. `doom|init-theme' sorts out the initial GUI frame.
|
2018-02-03 17:57:41 -05:00
|
|
|
|
;; Attaching `doom|init-theme-in-frame' to `after-make-frame-functions' sorts
|
|
|
|
|
;; out daemon and emacsclient frames.
|
2018-01-03 13:54:51 -05:00
|
|
|
|
;;
|
2018-02-02 16:56:34 -05:00
|
|
|
|
;; There will still be issues with simultaneous gui and terminal (emacsclient)
|
2018-06-17 21:35:58 +02:00
|
|
|
|
;; frames, however. There's always `doom/reload-theme' if you need it!
|
2018-07-30 13:53:36 +02:00
|
|
|
|
(defun doom|reload-theme-in-frame-maybe (frame)
|
2018-01-30 21:19:53 -05:00
|
|
|
|
"Reloads the theme in new daemon or tty frames."
|
2018-09-02 17:18:31 +02:00
|
|
|
|
(when (and doom-theme
|
|
|
|
|
(framep frame)
|
2018-06-14 13:57:03 +02:00
|
|
|
|
(not (eq doom-last-window-system (framep-on-display frame))))
|
2018-02-03 17:57:41 -05:00
|
|
|
|
(with-selected-frame frame
|
2018-07-30 13:53:36 +02:00
|
|
|
|
(load-theme doom-theme t))
|
2018-07-25 18:29:04 +02:00
|
|
|
|
(setq doom-last-window-system (framep-on-display frame))))
|
|
|
|
|
|
|
|
|
|
(defun doom|reload-theme-maybe (_frame)
|
|
|
|
|
"Reloads the theme after closing the last frame of a type."
|
2018-07-30 13:53:36 +02:00
|
|
|
|
(unless (cl-find doom-last-window-system (frame-list) :key #'framep-on-display)
|
2018-07-25 18:29:04 +02:00
|
|
|
|
(setq doom-last-window-system nil)
|
|
|
|
|
(doom|reload-theme-in-frame (selected-frame))))
|
2018-03-30 00:08:25 -04:00
|
|
|
|
|
|
|
|
|
;; fonts
|
|
|
|
|
(add-hook 'doom-init-ui-hook #'doom|init-fonts)
|
|
|
|
|
;; themes
|
2018-04-04 07:40:39 -04:00
|
|
|
|
(add-hook 'doom-init-ui-hook #'doom|init-theme)
|
2018-07-25 18:29:04 +02:00
|
|
|
|
(add-hook 'after-make-frame-functions #'doom|reload-theme-in-frame-maybe)
|
|
|
|
|
(add-hook 'after-delete-frame-functions #'doom|reload-theme-maybe)
|
2017-02-11 06:02:46 -05:00
|
|
|
|
|
2017-04-25 18:25:54 -04:00
|
|
|
|
|
2018-01-03 13:54:51 -05:00
|
|
|
|
;;
|
|
|
|
|
;; Bootstrap
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
;; simple name in frame title
|
2018-02-01 20:42:16 -05:00
|
|
|
|
(setq frame-title-format '("%b – Doom Emacs"))
|
2018-08-31 23:38:54 +02:00
|
|
|
|
|
2018-01-03 13:54:51 -05:00
|
|
|
|
;; draw me like one of your French editors
|
|
|
|
|
(tooltip-mode -1) ; relegate tooltips to echo area only
|
2018-08-31 23:38:54 +02:00
|
|
|
|
|
2018-01-03 13:54:51 -05:00
|
|
|
|
;; a good indicator that Emacs isn't frozen
|
|
|
|
|
(add-hook 'doom-init-ui-hook #'blink-cursor-mode)
|
2018-08-31 23:38:54 +02:00
|
|
|
|
|
2018-01-03 13:54:51 -05:00
|
|
|
|
;; line numbers in most modes
|
2018-08-21 02:54:28 +02:00
|
|
|
|
(add-hook! (prog-mode text-mode conf-mode) #'display-line-numbers-mode)
|
2018-01-03 13:54:51 -05:00
|
|
|
|
|
2018-08-31 23:38:54 +02:00
|
|
|
|
;; Make `next-buffer', `other-buffer', etc. ignore unreal buffers.
|
|
|
|
|
(add-to-list 'default-frame-alist (cons 'buffer-predicate #'doom-buffer-frame-predicate))
|
|
|
|
|
|
|
|
|
|
;; Prevent the glimpse of un-styled Emacs by setting these early.
|
|
|
|
|
(add-to-list 'default-frame-alist '(tool-bar-lines 0))
|
|
|
|
|
(add-to-list 'default-frame-alist '(menu-bar-lines 0))
|
|
|
|
|
(add-to-list 'default-frame-alist '(vertical-scroll-bars))
|
|
|
|
|
|
|
|
|
|
;; prompts the user for confirmation when deleting a non-empty frame
|
|
|
|
|
(global-set-key [remap delete-frame] #'doom/delete-frame)
|
2018-08-11 00:33:23 +02:00
|
|
|
|
|
2018-05-17 17:28:44 +02:00
|
|
|
|
(defun doom|no-fringes-in-minibuffer (&rest _)
|
2018-01-03 13:54:51 -05:00
|
|
|
|
"Disable fringes in the minibuffer window."
|
|
|
|
|
(set-window-fringes (minibuffer-window) 0 0 nil))
|
2018-05-17 17:28:44 +02:00
|
|
|
|
(add-hook! '(doom-init-ui-hook minibuffer-setup-hook window-configuration-change-hook)
|
2018-01-03 13:54:51 -05:00
|
|
|
|
#'doom|no-fringes-in-minibuffer)
|
|
|
|
|
|
|
|
|
|
(defun doom|set-mode-name ()
|
|
|
|
|
"Set the major mode's `mode-name', as dictated by `doom-major-mode-names'."
|
|
|
|
|
(when-let* ((name (cdr (assq major-mode doom-major-mode-names))))
|
|
|
|
|
(setq mode-name
|
|
|
|
|
(cond ((functionp name) (funcall name))
|
|
|
|
|
((stringp name) name)
|
2018-06-07 02:49:32 +02:00
|
|
|
|
((error "'%s' isn't a valid name for %s" name major-mode))))))
|
2018-01-03 13:54:51 -05:00
|
|
|
|
|
2018-08-31 23:38:54 +02:00
|
|
|
|
(defun doom|protect-visible-buffer ()
|
|
|
|
|
"Don't kill the current buffer if it is visible in another window (bury it
|
|
|
|
|
instead). Meant for `kill-buffer-query-functions'."
|
|
|
|
|
(not (and (delq (selected-window) (get-buffer-window-list nil nil t))
|
|
|
|
|
(not (member (substring (buffer-name) 0 1) '(" " "*"))))))
|
|
|
|
|
|
|
|
|
|
(defun doom|protect-fallback-buffer ()
|
|
|
|
|
"Don't kill the scratch buffer. Meant for `kill-buffer-query-functions'."
|
|
|
|
|
(not (eq (current-buffer) (doom-fallback-buffer))))
|
2018-01-03 13:54:51 -05:00
|
|
|
|
|
|
|
|
|
(defun doom|init-ui ()
|
|
|
|
|
"Initialize Doom's user interface by applying all its advice and hooks."
|
2018-08-21 02:52:08 +02:00
|
|
|
|
(add-to-list 'kill-buffer-query-functions #'doom|protect-fallback-buffer nil #'eq)
|
2018-08-31 23:38:54 +02:00
|
|
|
|
(add-to-list 'kill-buffer-query-functions #'doom|protect-visible-buffer nil #'eq)
|
2018-01-03 13:54:51 -05:00
|
|
|
|
(add-hook 'after-change-major-mode-hook #'doom|set-mode-name)
|
2018-08-31 23:38:54 +02:00
|
|
|
|
(add-hook 'after-change-major-mode-hook #'doom|highlight-non-default-indentation)
|
2018-08-21 02:52:08 +02:00
|
|
|
|
(add-hook 'compilation-filter-hook #'doom|apply-ansi-color-to-compilation-buffer)
|
2018-01-03 13:54:51 -05:00
|
|
|
|
;;
|
2018-06-18 14:47:36 +02:00
|
|
|
|
(run-hook-wrapped 'doom-init-ui-hook #'doom-try-run-hook))
|
2018-08-21 04:27:14 +02:00
|
|
|
|
(add-hook 'emacs-startup-hook #'doom|init-ui)
|
2017-02-11 06:02:46 -05:00
|
|
|
|
|
2018-08-31 23:38:54 +02:00
|
|
|
|
|
|
|
|
|
;;
|
|
|
|
|
;; Fixes/hacks
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
;; doesn't exist in terminal Emacs; we define it to prevent errors
|
|
|
|
|
(unless (fboundp 'define-fringe-bitmap)
|
|
|
|
|
(defun define-fringe-bitmap (&rest _)))
|
|
|
|
|
|
|
|
|
|
(defun doom*disable-old-themes-first (orig-fn &rest args)
|
|
|
|
|
(mapc #'disable-theme custom-enabled-themes)
|
|
|
|
|
(apply orig-fn args)
|
|
|
|
|
(when (fboundp 'powerline-reset)
|
|
|
|
|
(powerline-reset)))
|
|
|
|
|
(advice-add #'load-theme :around #'doom*disable-old-themes-first)
|
|
|
|
|
|
|
|
|
|
(defun doom|disable-whitespace-mode-in-childframes (frame)
|
|
|
|
|
(when (frame-parameter frame 'parent-frame)
|
|
|
|
|
(with-selected-frame frame
|
|
|
|
|
(setq-local whitespace-style nil)
|
|
|
|
|
frame)))
|
2018-09-01 16:30:17 +02:00
|
|
|
|
(add-hook 'after-make-frame-functions #'doom|disable-whitespace-mode-in-childframes)
|
2018-08-31 23:38:54 +02:00
|
|
|
|
|
|
|
|
|
;; Disruptive motion errors take over the minibuffer while we're typing there;
|
|
|
|
|
;; prevent this from happening.
|
|
|
|
|
(defun doom*silence-motion-errors (orig-fn &rest args)
|
|
|
|
|
(if (not (minibufferp))
|
|
|
|
|
(apply orig-fn args)
|
|
|
|
|
(ignore-errors (apply orig-fn args))
|
|
|
|
|
(when (<= (point) (minibuffer-prompt-end))
|
|
|
|
|
(goto-char (minibuffer-prompt-end)))))
|
|
|
|
|
(advice-add #'left-char :around #'doom*silence-motion-errors)
|
|
|
|
|
(advice-add #'right-char :around #'doom*silence-motion-errors)
|
|
|
|
|
(advice-add #'delete-backward-char :around #'doom*silence-motion-errors)
|
|
|
|
|
(advice-add #'backward-kill-sentence :around #'doom*silence-motion-errors)
|
|
|
|
|
|
|
|
|
|
(defun doom*no-fringes-in-which-key-buffer (&rest _)
|
|
|
|
|
(doom|no-fringes-in-minibuffer)
|
|
|
|
|
(set-window-fringes (get-buffer-window which-key--buffer) 0 0 nil))
|
|
|
|
|
(advice-add 'which-key--show-buffer-side-window :after #'doom*no-fringes-in-which-key-buffer)
|
|
|
|
|
|
|
|
|
|
;; Switch to `doom-fallback-buffer' if on last real buffer
|
|
|
|
|
(advice-add #'kill-this-buffer :around #'doom*switch-to-fallback-buffer-maybe)
|
|
|
|
|
|
2015-06-04 18:23:21 -04:00
|
|
|
|
(provide 'core-ui)
|
|
|
|
|
;;; core-ui.el ends here
|