Refactor/reformat core-ui

+ Move minibuffer fringe disabler to ui/doom
+ Disable blink-cursor-mode (too distracting, causes other issues e.g.
  #892)
This commit is contained in:
Henrik Lissner 2018-09-18 15:16:22 -04:00
parent 895df84f8b
commit 0c39e73a1e
3 changed files with 48 additions and 44 deletions

View file

@ -60,11 +60,6 @@ If any hook returns non-nil, all hooks after it are ignored.")
(set-face-attribute 'which-key-local-map-description-face nil :weight 'bold) (set-face-attribute 'which-key-local-map-description-face nil :weight 'bold)
(which-key-setup-side-window-bottom) (which-key-setup-side-window-bottom)
(setq-hook! 'which-key-init-buffer-hook line-spacing 3) (setq-hook! 'which-key-init-buffer-hook line-spacing 3)
(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)
(which-key-mode +1)) (which-key-mode +1))

View file

@ -134,19 +134,6 @@ Expects a `font-spec'.")
;; ;;
;; Built-in packages ;; Built-in packages
;; Handle ansi codes in compilation buffer
(add-hook 'compilation-filter-hook #'doom|apply-ansi-color-to-compilation-buffer)
;; 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)
(def-package! hl-line ; built-in (def-package! hl-line ; built-in
;; Highlights the current line ;; Highlights the current line
:hook ((prog-mode text-mode conf-mode) . hl-line-mode) :hook ((prog-mode text-mode conf-mode) . hl-line-mode)
@ -224,23 +211,6 @@ Expects a `font-spec'.")
(newline-mark ?\n [ ?\n]) (newline-mark ?\n [ ?\n])
(space-mark ?\ [] [?.]))) (space-mark ?\ [] [?.])))
(defun doom|highlight-non-default-indentation ()
"Highlight whitespace that doesn't match your `indent-tabs-mode' setting."
(unless (or (bound-and-true-p global-whitespace-mode)
(bound-and-true-p whitespace-mode)
(eq indent-tabs-mode (default-value 'indent-tabs-mode))
(eq major-mode 'fundamental-mode)
(derived-mode-p 'special-mode))
(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)))
;; ;;
;; Line numbers ;; Line numbers
@ -396,10 +366,24 @@ frame's window-system, the theme will be reloaded.")
;; simple name in frame title ;; simple name in frame title
(setq frame-title-format '("%b Doom Emacs")) (setq frame-title-format '("%b Doom Emacs"))
;; relegate tooltips to echo area only ;; relegate tooltips to echo area only
(if (boundp 'tooltip-mode) (tooltip-mode -1)) (if (boundp 'tooltip-mode) (tooltip-mode -1))
;; a good indicator that Emacs isn't frozen
(add-hook 'doom-init-ui-hook #'blink-cursor-mode) ;; enabled by default; no thanks, too distracting
(blink-cursor-mode -1)
;; Handle ansi codes in compilation buffer
(add-hook 'compilation-filter-hook #'doom|apply-ansi-color-to-compilation-buffer)
;; 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)
;; Make `next-buffer', `other-buffer', etc. ignore unreal buffers. ;; Make `next-buffer', `other-buffer', etc. ignore unreal buffers.
(add-to-list 'default-frame-alist '(buffer-predicate . doom-buffer-frame-predicate)) (add-to-list 'default-frame-alist '(buffer-predicate . doom-buffer-frame-predicate))
;; Prevent the glimpse of un-styled Emacs by setting these early. ;; Prevent the glimpse of un-styled Emacs by setting these early.
@ -409,12 +393,6 @@ frame's window-system, the theme will be reloaded.")
;; prompts the user for confirmation when deleting a non-empty frame ;; prompts the user for confirmation when deleting a non-empty frame
(global-set-key [remap delete-frame] #'doom/delete-frame) (global-set-key [remap delete-frame] #'doom/delete-frame)
(defun doom|no-fringes-in-minibuffer (&rest _)
"Disable fringes in the minibuffer window."
(set-window-fringes (minibuffer-window) 0 0 nil))
(add-hook! '(doom-init-ui-hook minibuffer-setup-hook window-configuration-change-hook)
#'doom|no-fringes-in-minibuffer)
(defun doom|protect-visible-buffer () (defun doom|protect-visible-buffer ()
"Don't kill the current buffer if it is visible in another window (bury it "Don't kill the current buffer if it is visible in another window (bury it
instead). Meant for `kill-buffer-query-functions'." instead). Meant for `kill-buffer-query-functions'."
@ -425,6 +403,23 @@ instead). Meant for `kill-buffer-query-functions'."
"Don't kill the scratch buffer. Meant for `kill-buffer-query-functions'." "Don't kill the scratch buffer. Meant for `kill-buffer-query-functions'."
(not (eq (current-buffer) (doom-fallback-buffer)))) (not (eq (current-buffer) (doom-fallback-buffer))))
(defun doom|highlight-non-default-indentation ()
"Highlight whitespace that doesn't match your `indent-tabs-mode' setting."
(unless (or (bound-and-true-p global-whitespace-mode)
(bound-and-true-p whitespace-mode)
(eq indent-tabs-mode (default-value 'indent-tabs-mode))
(eq major-mode 'fundamental-mode)
(derived-mode-p 'special-mode))
(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)))
(defun doom|init-ui () (defun doom|init-ui ()
"Initialize Doom's user interface by applying all its advice and hooks." "Initialize Doom's user interface by applying all its advice and hooks."
(add-to-list 'kill-buffer-query-functions #'doom|protect-fallback-buffer nil #'eq) (add-to-list 'kill-buffer-query-functions #'doom|protect-fallback-buffer nil #'eq)

View file

@ -58,5 +58,19 @@
#'solaire-mode-reset) #'solaire-mode-reset)
;; org-capture takes an org buffer and narrows it. The result is erroneously ;; org-capture takes an org buffer and narrows it. The result is erroneously
;; considered an unreal buffer, so solaire-mode must be restored. ;; considered an unreal buffer, so solaire-mode must be restored.
(add-hook 'org-capture-mode-hook #'turn-on-solaire-mode)) (add-hook 'org-capture-mode-hook #'turn-on-solaire-mode)
;; Because fringes can't be given a buffer-local face, they can look odd, so
;; we remove them in the minibuffer and which-key popups (they serve no
;; purpose there anyway).
(defun +doom|disable-fringes-in-minibuffer (&rest _)
(set-window-fringes (minibuffer-window) 0 0 nil))
(add-hook 'solaire-mode-hook #'+doom|disable-fringes-in-minibuffer)
(defun doom*no-fringes-in-which-key-buffer (&rest _)
(+doom|disable-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)
(add-hook! '(minibuffer-setup-hook window-configuration-change-hook)
#'+doom|disable-fringes-in-minibuffer))