General refactors & reformatting across the board

This commit is contained in:
Henrik Lissner 2020-05-15 01:44:53 -04:00
parent 4e28b48a3a
commit ea18c83c0a
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
19 changed files with 123 additions and 110 deletions

View file

@ -115,7 +115,8 @@ selection of all minor-modes, active or not."
(require 'org)
(let* ((default-directory doom-docs-dir)
(org-agenda-files (mapcar #'expand-file-name (doom-enlist files)))
(depth (if (integerp depth) depth)))
(depth (if (integerp depth) depth))
(org-inhibit-startup t))
(message "Loading search results...")
(unwind-protect
(delq
@ -218,7 +219,7 @@ selection of all minor-modes, active or not."
:prompt "Search documentation for: "))
;;;###autoload
(defun doom/help-news-search (&optional initial-input)
(defun doom/help-search-news (&optional initial-input)
"Search headlines in Doom's newsletters."
(interactive)
(doom-completing-read-org-headings

View file

@ -137,8 +137,7 @@
"This disables the company-box scrollbar, because:
https://github.com/sebastiencs/company-box/issues/44"
:around #'company-box--update-scrollbar
(cl-letf (((symbol-function #'display-buffer-in-side-window)
(symbol-function #'ignore)))
(letf! ((#'display-buffer-in-side-window #'ignore))
(apply orig-fn args))))

View file

@ -178,7 +178,7 @@ If ARG (universal argument), open selection in other-window."
(user-error "%S doesn't support wgrep" caller)))))
;;;###autoload
(defun +ivy-yas-prompt (prompt choices &optional display-fn)
(defun +ivy-yas-prompt-fn (prompt choices &optional display-fn)
(yas-completing-prompt prompt choices display-fn #'ivy-completing-read))
;;;###autoload

View file

@ -88,7 +88,7 @@ results buffer.")
(setq +ivy--origin nil)))
(after! yasnippet
(add-hook 'yas-prompt-functions #'+ivy-yas-prompt))
(add-hook 'yas-prompt-functions #'+ivy-yas-prompt-fn))
(defadvice! +ivy--inhibit-completion-in-region-a (orig-fn &rest args)
"`ivy-completion-in-region' struggles with completing certain
@ -114,12 +114,12 @@ evil-ex-specific constructs, so we disable it solely in evil-ex."
(cadr (plist-get ivy-rich-display-transformers-list
'ivy-switch-buffer))))
;; Include variable value in `counsel-describe-variable'
;; Enahnce the appearance of a couple counsel commands
(plist-put! ivy-rich-display-transformers-list
'counsel-describe-variable
'(:columns
((counsel-describe-variable-transformer (:width 40)) ; the original transformer
(+ivy-rich-describe-variable-transformer (:width 50))
(+ivy-rich-describe-variable-transformer (:width 50)) ; display variable value
(ivy-rich-counsel-variable-docstring (:face font-lock-doc-face))))
'counsel-M-x
'(:columns
@ -139,10 +139,9 @@ evil-ex-specific constructs, so we disable it solely in evil-ex."
;; Highlight buffers differently based on whether they're in the same project
;; as the current project or not.
(let* ((plist (plist-get ivy-rich-display-transformers-list 'ivy-switch-buffer))
(switch-buffer-alist (assq 'ivy-rich-candidate (plist-get plist :columns))))
(when switch-buffer-alist
(setcar switch-buffer-alist '+ivy-rich-buffer-name)))
(when-let* ((plist (plist-get ivy-rich-display-transformers-list 'ivy-switch-buffer))
(switch-buffer-alist (assq 'ivy-rich-candidate (plist-get plist :columns))))
(setcar switch-buffer-alist '+ivy-rich-buffer-name))
(ivy-rich-mode +1))
@ -264,7 +263,8 @@ evil-ex-specific constructs, so we disable it solely in evil-ex."
(cl-destructuring-bind (find-program . args)
(cond ((executable-find doom-projectile-fd-binary)
(append (list doom-projectile-fd-binary
"--color=never" "-E" ".git" "--type" "file" "--type" "symlink" "--follow")
"--color=never" "-E" ".git"
"--type" "file" "--type" "symlink" "--follow")
(if IS-WINDOWS '("--path-separator=/"))))
((executable-find "rg")
(append (list "rg" "--files" "--follow" "--color=never" "--hidden" "--no-messages")
@ -282,8 +282,8 @@ evil-ex-specific constructs, so we disable it solely in evil-ex."
(let ((offset (if (member find-program (list "rg" doom-projectile-fd-binary)) 0 2))
files)
(while (< (point) (point-max))
(push (buffer-substring
(+ offset (line-beginning-position)) (line-end-position)) files)
(push (buffer-substring (+ offset (line-beginning-position)) (line-end-position))
files)
(forward-line 1))
(nreverse files)))))))

View file

@ -353,7 +353,7 @@ Continues comments if executed from a commented line. Consults
"dL" #'doom/help-search-loaded-files
"dm" #'doom/help-modules
"dn" #'doom/help-news
"dN" #'doom/help-news-search
"dN" #'doom/help-search-news
"dpc" #'doom/help-package-config
"dpd" #'doom/goto-private-packages-file
"dph" #'doom/help-package-homepage

View file

@ -1,13 +1,10 @@
;;; editor/evil/config.el -*- lexical-binding: t; -*-
;; I'm a vimmer at heart. Its modal philosophy suits me better, and this module
;; strives to make Emacs a much better vim than vim was.
(defvar +evil-repeat-keys (cons ";" ",")
"The keys to use for universal repeating motions.
This is a cons cell whose CAR is the key for repeating a motion forward, and
whose CDR is for repeating backward. They should both be kbd-able strings.")
whose CDR is for repeating backward. They should both be `kbd'-able strings.")
(defvar +evil-want-o/O-to-continue-comments t
"If non-nil, the o/O keys will continue comment lines if the point is on a
@ -137,8 +134,8 @@ directives. By default, this only recognizes C directives.")
(and (>= char ?2) (<= char ?9)))
;; REVIEW Fix #2493: dir-locals cannot target fundamental-mode when evil-mode
;; is active. See https://github.com/hlissner/doom-emacs/issues/2493.
;; Revert this if this is ever fixed upstream.
;; is active. See hlissner/doom-emacs#2493. Revert this if
;; emacs-evil/evil#1268 is resolved upstream.
(defadvice! +evil--fix-local-vars-a (&rest _)
:before #'turn-on-evil-mode
(when (eq major-mode 'fundamental-mode)
@ -227,12 +224,12 @@ directives. By default, this only recognizes C directives.")
(use-package! evil-embrace
:commands embrace-add-pair embrace-add-pair-regexp
:hook (LaTeX-mode . embrace-LaTeX-mode-hook)
:hook (LaTeX-mode . +evil-embrace-latex-mode-hook-h)
:hook (org-mode . embrace-org-mode-hook)
:hook (ruby-mode . embrace-ruby-mode-hook)
:hook (emacs-lisp-mode . embrace-emacs-lisp-mode-hook)
:hook ((lisp-mode emacs-lisp-mode clojure-mode racket-mode hy-mode)
. +evil-embrace-lisp-mode-hook-h)
:hook ((org-mode LaTeX-mode) . +evil-embrace-latex-mode-hook-h)
:hook ((c++-mode rustic-mode csharp-mode java-mode swift-mode typescript-mode)
. +evil-embrace-angle-bracket-modes-hook-h)
:init
@ -369,14 +366,12 @@ directives. By default, this only recognizes C directives.")
(defmacro set-repeater! (command next-func prev-func)
"Makes ; and , the universal repeat-keys in evil-mode.
To change these keys see `+evil-repeat-keys'."
(let ((fn-sym (intern (format "+evil/repeat-%s" (doom-unquote command)))))
`(progn
(defun ,fn-sym (&rest _)
(when +evil-repeat-keys
(evil-define-key* 'motion 'local
(kbd (car +evil-repeat-keys)) #',next-func
(kbd (cdr +evil-repeat-keys)) #',prev-func)))
(advice-add #',command :after-while #',fn-sym))))
`(defadvice! ,(intern (format "+evil--repeat-%s-a" (doom-unquote command))) (&rest _)
:after-while #',command
(when +evil-repeat-keys
(evil-define-key* 'motion 'local
(kbd (car +evil-repeat-keys)) #',next-func
(kbd (cdr +evil-repeat-keys)) #',prev-func))))
;; n/N
(set-repeater! evil-ex-search-next evil-ex-search-next evil-ex-search-previous)

View file

@ -1,5 +1,7 @@
;;; editor/evil/init.el -*- lexical-binding: t; -*-
(defvar evil-collection-key-blacklist)
;; We load evil-collection ourselves for these reasons:
;;
;; 1. To truly lazy load it. Some of its modules, like

View file

@ -40,7 +40,7 @@
This is because there's no guarantee the remote system has GNU ls, which is the
only variant that supports --group-directories-first."
(when (file-remote-p default-directory)
(setq-local dired-actual-switches "-ahl")))))
(setq-local dired-actual-switches (car args))))))
;; Don't complain about this command being disabled when we use it
(put 'dired-find-alternate-file 'disabled nil)

View file

@ -42,16 +42,16 @@
(when (featurep! :ui workspaces)
(define-ibuffer-filter workspace-buffers
"Filter for workspace buffers"
(:reader
(+workspace-get (read-string "workspace name: ")) :description "workspace")
(:reader (+workspace-get (read-string "workspace name: "))
:description "workspace")
(memq buf (+workspace-buffer-list qualifier)))
(defun +ibuffer/workspace (workspace-name)
(defun +ibuffer-workspace (workspace-name)
"Open an ibuffer window for a workspace"
(ibuffer nil (format "%s buffers" workspace-name)
(list (cons 'workspace-buffers (+workspace-get workspace-name)))))
(defun +ibuffer-current-workspace ()
(defun +ibuffer/open-for-current-workspace ()
"Open an ibuffer window for the current workspace"
(interactive)
(+ibuffer/workspace (+workspace-current-name))))

View file

@ -46,11 +46,15 @@ exist, and `org-link' otherwise."
"Intepret LINK as an image file path and return its data."
(setq
link (expand-file-name
link
(pcase protocol
("download" (or org-download-image-dir org-attach-id-dir default-directory))
("attachment" org-attach-id-dir)
(_ default-directory))))
link (pcase protocol
("download"
(or (if (require 'org-download nil t) org-download-image-dir)
(if (require 'org-attach) org-attach-id-dir)
default-directory))
("attachment"
(require 'org-attach)
org-attach-id-dir)
(_ default-directory))))
(when (and (file-exists-p link)
(image-type-from-file-name link))
(with-temp-buffer

View file

@ -141,7 +141,7 @@ current file). Only scans first 2048 bytes of the document."
;;; Commands
;;;###autoload
(defun +org/dwim-at-point ()
(defun +org/dwim-at-point (&optional arg)
"Do-what-I-mean at point.
If on a:
@ -158,7 +158,7 @@ If on a:
- latex fragment: toggle it.
- link: follow it
- otherwise, refresh all inline images in current tree."
(interactive)
(interactive "P")
(let* ((context (org-element-context))
(type (org-element-type context)))
;; skip over unimportant contexts
@ -206,7 +206,7 @@ If on a:
(`table-cell
(org-table-blank-field)
(org-table-recalculate)
(org-table-recalculate arg)
(when (and (string-empty-p (string-trim (org-table-get-field)))
(bound-and-true-p evil-local-mode))
(evil-change-state 'insert)))
@ -215,13 +215,13 @@ If on a:
(org-babel-lob-execute-maybe))
(`statistics-cookie
(save-excursion (org-update-statistics-cookies nil)))
(save-excursion (org-update-statistics-cookies arg)))
((or `src-block `inline-src-block)
(org-babel-execute-src-block))
(org-babel-execute-src-block arg))
((or `latex-fragment `latex-environment)
(org-latex-preview))
(org-latex-preview arg))
(`link
(let* ((lineage (org-element-lineage context '(link) t))
@ -229,7 +229,7 @@ If on a:
(if (or (equal (org-element-property :type lineage) "img")
(and path (image-type-from-file-name path)))
(+org--refresh-inline-images-in-subtree)
(org-open-at-point))))
(org-open-at-point arg))))
((guard (org-element-property :checkbox (org-element-lineage context '(item) t)))
(let ((match (and (org-at-item-checkbox-p) (match-string 1))))
@ -238,7 +238,7 @@ If on a:
(_
(if (or (org-in-regexp org-ts-regexp-both nil t)
(org-in-regexp org-tsr-regexp-both nil t)
(org-in-regexp org-any-link-re nil t))
(org-in-regexp org-link-any-re nil t))
(call-interactively #'org-open-at-point)
(+org--refresh-inline-images-in-subtree))))))

View file

@ -160,7 +160,7 @@ This forces it to read the background before rendering."
("HOLD" . +org-todo-onhold)
("PROJ" . +org-todo-project)))
(defadvice! +org-display-link-in-eldoc-a (&rest args)
(defadvice! +org-display-link-in-eldoc-a (&rest _)
"Display full link in minibuffer when cursor/mouse is over it."
:before-until #'org-eldoc-documentation-function
(when-let (link (org-element-property :raw-link (org-element-context)))
@ -196,10 +196,10 @@ This forces it to read the background before rendering."
;; I prefer C-c C-c over C-c ' (more consistent)
(define-key org-src-mode-map (kbd "C-c C-c") #'org-edit-src-exit)
(defadvice! +org-fix-newline-and-indent-in-src-blocks-a ()
(defadvice! +org-fix-newline-and-indent-in-src-blocks-a (&optional indent _arg _interactive)
"Mimic `newline-and-indent' in src blocks w/ lang-appropriate indentation."
:after #'org-return-indent
(when (org-in-src-block-p t)
:after #'org-return
(when (and indent (org-in-src-block-p t))
(org-babel-do-in-edit-buffer
(call-interactively #'indent-for-tab-command))))
@ -916,8 +916,8 @@ compelling reason, so..."
:ni "C-S-k" #'org-shiftup
:ni "C-S-j" #'org-shiftdown
;; more intuitive RET keybinds
:i [return] #'org-return-indent
:i "RET" #'org-return-indent
:i [return] (λ! (org-return t))
:i "RET" (λ! (org-return t))
:n [return] #'+org/dwim-at-point
:n "RET" #'+org/dwim-at-point
;; more vim-esque org motion keys (not covered by evil-org-mode)

View file

@ -41,19 +41,19 @@
(defadvice! +org-present--narrow-to-subtree-a (orig-fn &rest args)
"Narrow to the target subtree when you start the presentation."
:around #'org-tree-slide--display-tree-with-narrow
(letf! ((defun org-narrow-to-subtree ()
(save-excursion
(save-match-data
(org-with-limited-levels
(narrow-to-region
(progn
(when (org-before-first-heading-p)
(org-next-visible-heading 1))
(ignore-errors (org-up-heading-all 99))
(forward-line 1)
(point))
(progn (org-end-of-subtree t t)
(when (and (org-at-heading-p) (not (eobp)))
(backward-char 1))
(point))))))))
(letf! (defun org-narrow-to-subtree ()
(save-excursion
(save-match-data
(org-with-limited-levels
(narrow-to-region
(progn
(when (org-before-first-heading-p)
(org-next-visible-heading 1))
(ignore-errors (org-up-heading-all 99))
(forward-line 1)
(point))
(progn (org-end-of-subtree t t)
(when (and (org-at-heading-p) (not (eobp)))
(backward-char 1))
(point)))))))
(apply orig-fn args))))

View file

@ -5,7 +5,7 @@
"This module requires (:tools lsp)")
(if (not (executable-find "python"))
(error! "Python isn't installed.")
(error! "Couldn't find python in your PATH")
(unless (featurep! +lsp)
(unless (zerop (shell-command "python -c 'import setuptools'"))
(warn! "setuptools wasn't detected, which anaconda-mode requires"))))

View file

@ -183,9 +183,10 @@ You should use `set-eshell-alias!' to change this.")
:hook (eshell-mode . fish-completion-mode)
:init (setq fish-completion-fallback-on-bash-p t)
:config
;; HACK Even with `fish-completion-fallback-on-bash-p' non-nil, fish must be
;; installed for bash completion to work. How frustrating. This way we
;; can at least get bash completion whether or not fish is present.
;; HACK Even with `fish-completion-fallback-on-bash-p' non-nil,
;; `fish-completion--list-completions-with-desc' will throw an error if
;; fish isn't installed (and so, will fail to fall back to bash), so we
;; advise it to fail silently.
(defadvice! +eshell--fallback-to-bash-a (&rest _)
:before-until #'fish-completion--list-completions-with-desc
(unless (executable-find "fish") "")))

View file

@ -28,9 +28,8 @@
(if IS-MAC
(package! osx-dictionary :pin "1b79ff64c72485cb078db9ab7ee3256b11a99f4b")
(package! define-word :pin "08c71b1ff4fd07bf0c78d1fcf77efeaafc8f7443")
;; HACK Fix #2945: the main package is broken (see
;; SavchenkoValeriy/emacs-powerthesaurus). We use this fork until it is
;; merged.
;; HACK Fix #2945: the main package is broken due to
;; SavchenkoValeriy/emacs-powerthesaurus#11
(package! powerthesaurus
:recipe (:host github :repo "maxchaos/emacs-powerthesaurus" :branch "pt-api-change")
:pin "4a834782a394f2dc70fc02d68b6962b44d87f0cf")

View file

@ -1,10 +1,22 @@
;;; tools/magit/autoload.el -*- lexical-binding: t; -*-
;; HACK Magit complains loudly when it can't determine its own version, which is
;; the case when magit is built through straight. The warning is harmless,
;; however, so we just need it to shut up.
;; HACK Magit complains loudly (but harmlessly) when it can't determine its own
;; version (in the case of a sparse clone).
;;;###autoload
(advice-add #'magit-version :override #'ignore)
(defadvice! +magit--ignore-version-a (&optional print-dest)
:override #'magit-version
(when print-dest
(defvar magit-git-debug)
(princ (format "Magit (unknown), Git %s, Emacs %s, %s"
(or (let ((magit-git-debug
(lambda (err)
(display-warning '(magit git) err :error))))
(magit-git-version t))
"(unknown)")
emacs-version
system-type)
print-dest))
nil)
;;;###autoload
(defun +magit-display-buffer-fn (buffer)

View file

@ -65,29 +65,30 @@
(setq-hook! 'pdf-view-mode-hook evil-normal-state-cursor (list nil))
;; Install epdfinfo binary if needed, blocking until it is finished
(require 'pdf-tools)
(unless (file-executable-p pdf-info-epdfinfo-program)
(let ((wconf (current-window-configuration)))
(pdf-tools-install)
(message "Building epdfinfo, this will take a moment...")
;; HACK We reset all `pdf-view-mode' buffers to fundamental mode so that
;; `pdf-tools-install' has a chance to reinitialize them as
;; `pdf-view-mode' buffers. This is necessary because
;; `pdf-tools-install' won't do this to buffers that are already in
;; pdf-view-mode.
(dolist (buffer (doom-buffers-in-mode 'pdf-view-mode))
(with-current-buffer buffer (fundamental-mode)))
(while compilation-in-progress
;; Block until `pdf-tools-install' is done
(redisplay)
(sleep-for 1))
;; HACK If pdf-tools was loaded by you opening a pdf file, once
;; `pdf-tools-install' completes, `pdf-view-mode' will throw an error
;; because the compilation buffer is focused, not the pdf buffer.
;; Therefore, it is imperative that the window config is restored.
(when (file-executable-p pdf-info-epdfinfo-program)
(set-window-configuration wconf))))
(when doom-interactive-mode
(require 'pdf-tools)
(unless (file-executable-p pdf-info-epdfinfo-program)
(let ((wconf (current-window-configuration)))
(pdf-tools-install)
(message "Building epdfinfo, this will take a moment...")
;; HACK We reset all `pdf-view-mode' buffers to fundamental mode so that
;; `pdf-tools-install' has a chance to reinitialize them as
;; `pdf-view-mode' buffers. This is necessary because
;; `pdf-tools-install' won't do this to buffers that are already in
;; pdf-view-mode.
(dolist (buffer (doom-buffers-in-mode 'pdf-view-mode))
(with-current-buffer buffer (fundamental-mode)))
(while compilation-in-progress
;; Block until `pdf-tools-install' is done
(redisplay)
(sleep-for 1))
;; HACK If pdf-tools was loaded by you opening a pdf file, once
;; `pdf-tools-install' completes, `pdf-view-mode' will throw an error
;; because the compilation buffer is focused, not the pdf buffer.
;; Therefore, it is imperative that the window config is restored.
(when (file-executable-p pdf-info-epdfinfo-program)
(set-window-configuration wconf))))
;; Sets up `pdf-tools-enable-minor-modes', `pdf-occur-global-minor-mode' and
;; `pdf-virtual-global-minor-mode'.
(pdf-tools-install-noverify))
;; Sets up `pdf-tools-enable-minor-modes', `pdf-occur-global-minor-mode' and
;; `pdf-virtual-global-minor-mode'.
(pdf-tools-install-noverify)))

View file

@ -2,7 +2,7 @@
(use-package! evil-goggles
:when (featurep! :editor evil)
:after-call pre-command-hook
:hook (doom-first-input . evil-goggles-mode)
:init
(setq evil-goggles-duration 0.1
evil-goggles-pulse nil ; too slow
@ -23,13 +23,12 @@
'(+eval:region
:face evil-goggles-yank-face
:switch evil-goggles-enable-yank
:advice evil-goggles--generic-async-advice))
(evil-goggles-mode +1))
:advice evil-goggles--generic-async-advice)))
(use-package! volatile-highlights
:unless (featurep! :editor evil)
:after-call pre-command-hook
:hook (doom-first-input . volatile-highlights-mode)
:config
(after! undo-fu
(vhl/define-extension 'undo-fu 'undo-fu-only-undo 'undo-fu-only-redo)