General minor refactor

This commit is contained in:
Henrik Lissner 2017-07-18 22:12:50 +02:00
parent f2d8681ef4
commit e6658b7d8e
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
4 changed files with 32 additions and 40 deletions

View file

@ -154,7 +154,7 @@ local value, whether or not it's permanent-local. Therefore, we cycle
(setq show-paren-delay 0.1 (setq show-paren-delay 0.1
show-paren-highlight-openparen t show-paren-highlight-openparen t
show-paren-when-point-inside-paren t) show-paren-when-point-inside-paren t)
(add-hook 'doom-init-hook #'show-paren-mode) (add-hook 'doom-init-ui-hook #'show-paren-mode)
;;; More reliable inter-window border ;;; More reliable inter-window border
;; The native border "consumes" a pixel of the fringe on righter-most splits, ;; The native border "consumes" a pixel of the fringe on righter-most splits,
@ -162,7 +162,7 @@ local value, whether or not it's permanent-local. Therefore, we cycle
(setq-default window-divider-default-places t (setq-default window-divider-default-places t
window-divider-default-bottom-width 0 window-divider-default-bottom-width 0
window-divider-default-right-width 1) window-divider-default-right-width 1)
(add-hook 'doom-init-hook #'window-divider-mode) (add-hook 'doom-init-ui-hook #'window-divider-mode)
;; like diminish, but for major-modes. [pedantry intensifies] ;; like diminish, but for major-modes. [pedantry intensifies]
(defun doom|set-mode-name () (defun doom|set-mode-name ()
@ -212,7 +212,7 @@ local value, whether or not it's permanent-local. Therefore, we cycle
(run-with-timer 0.1 nil #'doom|init-ui)))) (run-with-timer 0.1 nil #'doom|init-ui))))
;; register UI init hooks ;; register UI init hooks
(add-hook 'doom-init-hook #'doom|init-ui) (add-hook 'doom-post-init-hook #'doom|init-ui)
(add-hook! 'after-make-frame-functions #'(doom|init-ui doom|reload-ui-in-daemon)) (add-hook! 'after-make-frame-functions #'(doom|init-ui doom|reload-ui-in-daemon))
@ -275,16 +275,15 @@ local value, whether or not it's permanent-local. Therefore, we cycle
:config :config
(setq hs-hide-comments-when-hiding-all nil)) (setq hs-hide-comments-when-hiding-all nil))
;; Show uninterrupted indentation markers with some whitespace voodoo.
(def-package! highlight-indentation (def-package! highlight-indentation
:commands (highlight-indentation-mode highlight-indentation-current-column-mode)) :commands (highlight-indentation-mode highlight-indentation-current-column-mode))
;; For modes that don't adequately highlight numbers ;; For modes with sub-par number fontification
(def-package! highlight-numbers :commands highlight-numbers-mode) (def-package! highlight-numbers :commands highlight-numbers-mode)
;; Line highlighting ;; Highlights the current line
(def-package! hl-line ; built-in (def-package! hl-line ; built-in
:init (add-hook! (linum-mode nlinum-mode) #'hl-line-mode) :init (add-hook! (prog-mode text-mode conf-mode) #'hl-line-mode)
:config :config
;; I don't need hl-line showing in other windows. This also offers a small ;; I don't need hl-line showing in other windows. This also offers a small
;; speed boost when buffer is displayed in multiple windows. ;; speed boost when buffer is displayed in multiple windows.
@ -294,9 +293,9 @@ local value, whether or not it's permanent-local. Therefore, we cycle
(after! evil (after! evil
;; Disable `hl-line' in evil-visual mode (temporarily). `hl-line' can make ;; Disable `hl-line' in evil-visual mode (temporarily). `hl-line' can make
;; the selection region harder to see while in evil visual mode. ;; the selection region harder to see while in evil visual mode.
(defun doom|turn-off-hl-line () (hl-line-mode -1)) (defun doom|disable-hl-line () (hl-line-mode -1))
(add-hook 'evil-visual-state-entry-hook #'doom|turn-off-hl-line) (add-hook 'evil-visual-state-entry-hook #'doom|disable-hl-line)
(add-hook 'evil-visual-state-exit-hook #'hl-line-mode))) (add-hook 'evil-visual-state-exit-hook #'hl-line-mode)))
;; Helps us distinguish stacked delimiter pairs. Especially in parentheses-drunk ;; Helps us distinguish stacked delimiter pairs. Especially in parentheses-drunk
@ -309,7 +308,7 @@ local value, whether or not it's permanent-local. Therefore, we cycle
;; indicators for empty lines past EOF ;; indicators for empty lines past EOF
(def-package! vi-tilde-fringe (def-package! vi-tilde-fringe
:commands global-vi-tilde-fringe-mode :commands global-vi-tilde-fringe-mode
:init (add-hook 'doom-init-hook #'global-vi-tilde-fringe-mode)) :init (add-hook 'doom-init-ui-hook #'global-vi-tilde-fringe-mode))
;; For a distractions-free-like UI, that dynamically resizes margets and can ;; For a distractions-free-like UI, that dynamically resizes margets and can
;; center a buffer. ;; center a buffer.
@ -355,8 +354,7 @@ See `doom-line-numbers-style' to control the style of line numbers to display."
"Disable the display of line numbers." "Disable the display of line numbers."
(doom|enable-line-numbers -1)) (doom|enable-line-numbers -1))
(add-hook! (prog-mode text-mode conf-mode) (add-hook! (prog-mode text-mode conf-mode) #'doom|enable-line-numbers)
#'(doom|enable-line-numbers hl-line-mode))
;; Emacs 26+ has native line number support. ;; Emacs 26+ has native line number support.
(unless (boundp 'display-line-numbers) (unless (boundp 'display-line-numbers)
@ -492,12 +490,11 @@ error if it doesn't exist."
(defun doom-set-modeline (key &optional default) (defun doom-set-modeline (key &optional default)
"Set the modeline format. Does nothing if the modeline KEY doesn't exist. If "Set the modeline format. Does nothing if the modeline KEY doesn't exist. If
DEFAULT is non-nil, set the default mode-line for all buffers." DEFAULT is non-nil, set the default mode-line for all buffers."
(let ((modeline (doom-modeline key))) (when-let (modeline (doom-modeline key))
(when modeline (setf (if default
(setf (if default (default-value 'mode-line-format)
(default-value 'mode-line-format) (buffer-local-value 'mode-line-format (current-buffer)))
(buffer-local-value 'mode-line-format (current-buffer))) modeline)))
modeline))))
(provide 'core-ui) (provide 'core-ui)
;;; core-ui.el ends here ;;; core-ui.el ends here

View file

@ -1,6 +1,6 @@
;;; private/hlissner/config.el -*- lexical-binding: t; -*- ;;; private/hlissner/config.el -*- lexical-binding: t; -*-
(when (featurep 'evil) (when (featurep! :feature evil)
(load! +bindings) ; my key bindings (load! +bindings) ; my key bindings
(load! +commands)) ; my custom ex commands (load! +commands)) ; my custom ex commands
@ -41,8 +41,7 @@
(after! yasnippet (after! yasnippet
(setq yas-snippet-dirs (setq yas-snippet-dirs
(append (list '+hlissner-snippets-dir) (append (list '+hlissner-snippets-dir)
(delete 'yas-installed-snippets-dir (delq 'yas-installed-snippets-dir yas-snippet-dirs))))
yas-snippet-dirs))))
;; app/irc ;; app/irc

View file

@ -118,7 +118,8 @@ whose dimensions may not be fully initialized by the time this is run."
(let ((old-pwd (or dir default-directory))) (let ((old-pwd (or dir default-directory)))
(with-current-buffer (doom-fallback-buffer) (with-current-buffer (doom-fallback-buffer)
(with-silent-modifications (with-silent-modifications
(+doom-dashboard-mode) (unless (eq major-mode '+doom-dashboard-mode)
(+doom-dashboard-mode))
(erase-buffer) (erase-buffer)
(setq default-directory old-pwd) (setq default-directory old-pwd)
(let ((+doom-dashboard--width (window-width)) (let ((+doom-dashboard--width (window-width))
@ -177,30 +178,26 @@ whose dimensions may not be fully initialized by the time this is run."
(file-exists-p (expand-file-name persp-auto-save-fname persp-save-dir))))) (file-exists-p (expand-file-name persp-auto-save-fname persp-save-dir)))))
(mapc (lambda (btn) (mapc (lambda (btn)
(when btn (when btn
(let ((label (car btn)) (cl-destructuring-bind (label icon fn) btn
(icon (nth 1 btn))
(fn (nth 2 btn)))
(insert (insert
(with-temp-buffer (with-temp-buffer
(insert-text-button (insert-text-button
(concat (all-the-icons-octicon (concat (all-the-icons-octicon icon :face 'font-lock-keyword-face)
icon
:face 'font-lock-keyword-face)
(propertize (concat " " label) 'face 'font-lock-keyword-face)) (propertize (concat " " label) 'face 'font-lock-keyword-face))
'action fn 'action `(lambda (_) ,fn)
'follow-link t) 'follow-link t)
(+doom-dashboard-center (1- +doom-dashboard--width) (buffer-string)))) (+doom-dashboard-center (1- +doom-dashboard--width) (buffer-string)))
(insert "\n\n")))) "\n\n"))))
`(("Homepage" "mark-github" `(("Homepage" "mark-github"
(lambda (_) (browse-url "https://github.com/hlissner/.emacs.d"))) (browse-url "https://github.com/hlissner/.emacs.d"))
,(when last-session-p ,(when last-session-p
'("Reload last session" "history" '("Reload last session" "history"
(lambda (_) (+workspace/load-session)))) (lambda (_) (+workspace/load-session))))
("Recently opened files" "file-text" ("Recently opened files" "file-text"
(lambda (_) (call-interactively (command-remapping 'recentf)))) (call-interactively (command-remapping 'recentf)))
("Recent opened projects" "briefcase" ("Recent opened projects" "briefcase"
(lambda (_) (call-interactively (command-remapping 'projectile-switch-project)))) (call-interactively (command-remapping 'projectile-switch-project)))
("Jump to bookmark" "bookmark" ("Jump to bookmark" "bookmark"
(lambda (_) (call-interactively (command-remapping 'bookmark-jump)))) (call-interactively (command-remapping 'bookmark-jump)))
("Edit emacs.d" "tools" ("Edit emacs.d" "tools"
(lambda (_) (find-file (expand-file-name "init.el" doom-emacs-dir)))))))) (find-file (expand-file-name "init.el" doom-emacs-dir)))))))

View file

@ -17,10 +17,10 @@
(add-hook 'doom-pre-reload-theme-hook #'+doom|reload-theme) (add-hook 'doom-pre-reload-theme-hook #'+doom|reload-theme)
;; blink mode-line on errors ;; blink mode-line on errors
(add-hook 'doom-post-init-hook #'doom-themes-visual-bell-config) (add-hook 'doom-init-ui-hook #'doom-themes-visual-bell-config)
;; Add file icons to doom-neotree ;; Add file icons to doom-neotree
(add-hook 'doom-post-init-hook #'doom-themes-neotree-config) (add-hook 'doom-init-ui-hook #'doom-themes-neotree-config)
(setq doom-neotree-enable-variable-pitch t (setq doom-neotree-enable-variable-pitch t
doom-neotree-file-icons 'simple doom-neotree-file-icons 'simple
doom-neotree-line-spacing 2) doom-neotree-line-spacing 2)
@ -44,8 +44,7 @@
;; Prevent color glitches when reloading either DOOM or the theme ;; Prevent color glitches when reloading either DOOM or the theme
(defun +doom|reset-solaire-mode (&rest _) (solaire-mode-reset)) (defun +doom|reset-solaire-mode (&rest _) (solaire-mode-reset))
(advice-add #'load-theme :after #'+doom|reset-solaire-mode) (advice-add #'load-theme :after #'+doom|reset-solaire-mode)
(add-hook 'doom-reload-hook #'solaire-mode-reset) (add-hook! '(doom-init-ui-hook doom-reload-hook) #'solaire-mode-reset)
(add-hook 'doom-init-ui-hook #'solaire-mode-reset)
;; Extra modes to activate doom-buffer-mode in ;; Extra modes to activate doom-buffer-mode in
(add-hook! (gist-mode (add-hook! (gist-mode