General, minor reformatting across the board

And an offering of blood to our great lord Byte Compiler-sama.
This commit is contained in:
Henrik Lissner 2019-07-21 23:31:42 +02:00
parent 3595ff62ee
commit 060ede0e2e
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
30 changed files with 125 additions and 112 deletions

View file

@ -69,7 +69,7 @@
(setenv "YES" "1")
(message "Auto-yes mode on"))))
(or (file-directory-p emacs-dir)
(unless (file-directory-p emacs-dir)
(error "%s does not exist" emacs-dir))
;; Bootstrap Doom
@ -82,8 +82,8 @@
(member (car args) '("help" "h")))
(usage))
((not args)
(message "No command detected, aborting!\n\nRun %s help for documentation."
(file-name-nondirectory load-file-name)))
(print! (error "No command detected.\n"))
(usage))
((let ((default-directory emacs-dir))
(setq argv nil
noninteractive 'doom)

View file

@ -50,7 +50,7 @@ Runs `doom-reload-hook' afterwards."
(message "Finished!"))
;;;###autoload
(defun doom/reload-autoloads (&optional force-p)
(defun doom/reload-autoloads (&optional _force-p)
"Reload only `doom-autoload-file' and `doom-package-autoload-file'.
This is much faster and safer than `doom/reload', but not as comprehensive. This
@ -60,6 +60,7 @@ not reload your private config.
It is useful to only pull in changes performed by 'doom refresh' on the command
line."
(interactive "P")
;; TODO regenerate autoloads
(doom-initialize-autoloads doom-autoload-file)
(doom-initialize-autoloads doom-package-autoload-file))

View file

@ -43,7 +43,7 @@ ready to be pasted in a bug report on github."
(elc-files . ,(length (doom-files-in `(,@doom-modules-dirs
,doom-core-dir
,doom-private-dir)
:type 'files :match "\\.elc$" :sort nil)))
:type 'files :match "\\.elc$")))
(modules ,@(or (cl-loop with cat = nil
for key being the hash-keys of doom-modules
if (or (not cat) (not (eq cat (car key))))

View file

@ -53,7 +53,7 @@
;;
;; Commands
;;; Commands
;;;###autoload
(defun doom/delete-this-file (&optional path force-p)

View file

@ -184,13 +184,11 @@ transformative logic."
(defmacro format! (message &rest args)
"An alternative to `format' that understands (color ...) and converts them
into faces or ANSI codes depending on the type of sesssion we're in."
(declare (debug t))
`(doom--format (format ,@(doom--format-apply `(,message ,@args)))))
;;;###autoload
(defmacro print-group! (&rest body)
"Indents any `print!' or `format!' output within BODY."
(declare (debug t))
`(let ((doom-format-indent (+ 2 doom-format-indent)))
,@body))
@ -206,7 +204,6 @@ Can be colored using (color ...) blocks:
(print! (green \"Great %s!\") \"success\")
Uses faces in interactive sessions and ANSI codes otherwise."
(declare (debug t))
`(doom--format-print (format! ,message ,@args)))
;;;###autoload
@ -214,18 +211,15 @@ Uses faces in interactive sessions and ANSI codes otherwise."
"Like `insert'; the last argument must be format arguments for MESSAGE.
\(fn MESSAGE... ARGS)"
(declare (debug t))
`(insert (format! (concat ,message ,@(butlast args))
,@(car (last args)))))
;;;###autoload
(defmacro error! (message &rest args)
"Like `error', but with the power of `format!'."
(declare (debug t))
`(error (format! ,message ,@args)))
;;;###autoload
(defmacro user-error! (message &rest args)
"Like `user-error', but with the power of `format!'."
(declare (debug t))
`(user-error (format! ,message ,@args)))

View file

@ -121,6 +121,7 @@ selection of all minor-modes, active or not."
;;
;;; Documentation commands
(defvar org-agenda-files)
(defun doom--org-headings (files &optional depth include-files)
"TODO"
(require 'org)
@ -155,6 +156,7 @@ selection of all minor-modes, active or not."
(mapc #'kill-buffer org-agenda-new-buffers)
(setq org-agenda-new-buffers nil))))
(defvar ivy-sort-functions-alist)
;;;###autoload
(defun doom-completing-read-org-headings (prompt files &optional depth include-files initial-input)
"TODO"
@ -197,8 +199,7 @@ selection of all minor-modes, active or not."
"Find in News: "
(nreverse (doom-files-in (expand-file-name "news" doom-docs-dir)
:match "/[0-9]"
:relative-to doom-docs-dir
:sort t))
:relative-to doom-docs-dir))
nil t initial-input))
;;;###autoload

View file

@ -262,8 +262,7 @@ ones."
(doom-files-in doom-modules-dir
:depth 2
:full t
:match "/packages\\.el$"
:sort nil))
:match "/packages\\.el$"))
(cl-loop for key being the hash-keys of doom-modules
for path = (doom-module-path (car key) (cdr key) "packages.el")
for doom--current-module = key

View file

@ -1,5 +1,11 @@
;;; core/autoload/sessions.el -*- lexical-binding: t; -*-
(defvar desktop-base-file-name)
(defvar desktop-dirname)
(defvar desktop-restore-eager)
(defvar desktop-file-modtime)
;;
;;; Helpers

View file

@ -186,9 +186,10 @@ Respects `require-final-newline'."
(setq indent-tabs-mode (not indent-tabs-mode))
(message "Indent style changed to %s" (if indent-tabs-mode "tabs" "spaces")))
(defvar editorconfig-lisp-use-default-indent)
;;;###autoload
(defun doom/set-indent-width (width)
"Change the indentation width of the current buffer."
"Change the indentation size to WIDTH of the current buffer."
(interactive
(list (if (integerp current-prefix-arg)
current-prefix-arg

View file

@ -185,9 +185,9 @@ module. This does not include your byte-compiled, third party packages.'"
with success = nil
for path
in (append (doom-glob doom-emacs-dir "*.elc")
(doom-files-in doom-private-dir :match "\\.elc$" :depth 1 :sort nil)
(doom-files-in doom-core-dir :match "\\.elc$" :sort nil)
(doom-files-in doom-modules-dirs :match "\\.elc$" :depth 4 :sort nil))
(doom-files-in doom-private-dir :match "\\.elc$" :depth 1)
(doom-files-in doom-core-dir :match "\\.elc$")
(doom-files-in doom-modules-dirs :match "\\.elc$" :depth 4))
if (file-exists-p path)
do (delete-file path)
and do (print! (success "Deleted %s") (relpath path))

View file

@ -101,7 +101,7 @@ successfully sets indent_style/indent_size.")
(def-package! recentf
;; Keep track of recently opened files
:defer-incrementally (easymenu tree-widget timer)
:defer-incrementally easymenu tree-widget timer
:after-call after-find-file
:commands recentf-open-files
:config
@ -143,7 +143,7 @@ successfully sets indent_style/indent_size.")
(def-package! savehist
;; persist variables across sessions
:defer-incrementally (custom)
:defer-incrementally custom
:after-call post-command-hook
:config
(setq savehist-file (concat doom-cache-dir "savehist")
@ -163,7 +163,7 @@ successfully sets indent_style/indent_size.")
(def-package! saveplace
;; persistent point location in buffers
:after-call (after-find-file dired-initial-position-hook)
:after-call after-find-file dired-initial-position-hook
:config
(setq save-place-file (concat doom-cache-dir "saveplace")
save-place-forget-unreadable-files t
@ -177,7 +177,7 @@ successfully sets indent_style/indent_size.")
(def-package! server
:when (display-graphic-p)
:after-call (pre-command-hook after-find-file focus-out-hook)
:after-call pre-command-hook after-find-file focus-out-hook
:init
(when-let (name (getenv "EMACS_SERVER_NAME"))
(setq server-name name))
@ -190,7 +190,7 @@ successfully sets indent_style/indent_size.")
;;; Packages
(def-package! better-jumper
:after-call (pre-command-hook)
:after-call pre-command-hook
:init
(global-set-key [remap evil-jump-forward] #'better-jumper-jump-forward)
(global-set-key [remap evil-jump-backward] #'better-jumper-jump-backward)
@ -312,8 +312,8 @@ successfully sets indent_style/indent_size.")
(def-package! smartparens
;; Auto-close delimiters and blocks as you type. It's more powerful than that,
;; but that is all Doom uses it for.
:after-call (doom-switch-buffer-hook after-find-file)
:commands (sp-pair sp-local-pair sp-with-modes sp-point-in-comment sp-point-in-string)
:after-call doom-switch-buffer-hook after-find-file
:commands sp-pair sp-local-pair sp-with-modes sp-point-in-comment sp-point-in-string
:config
(require 'smartparens-config)
(setq sp-highlight-pair-overlay nil
@ -345,13 +345,13 @@ successfully sets indent_style/indent_size.")
(def-package! so-long
:after-call (after-find-file)
:after-call after-find-file
:config (global-so-long-mode +1))
(def-package! undo-tree
;; Branching & persistent undo
:after-call (doom-switch-buffer-hook after-find-file)
:after-call doom-switch-buffer-hook after-find-file
:config
(setq undo-tree-auto-save-history nil ; disable because unstable
;; undo-in-region is known to cause undo history corruption, which can
@ -378,11 +378,10 @@ successfully sets indent_style/indent_size.")
(def-package! ws-butler
;; a less intrusive `delete-trailing-whitespaces' on save
:after-call (after-find-file)
:after-call after-find-file
:config
(setq ws-butler-global-exempt-modes
(append ws-butler-global-exempt-modes
'(special-mode comint-mode term-mode eshell-mode)))
(appendq! ws-butler-global-exempt-modes
'(special-mode comint-mode term-mode eshell-mode))
(ws-butler-global-mode))
(provide 'core-editor)

View file

@ -74,7 +74,7 @@ If any hook returns non-nil, all hooks after it are ignored.")
;;; General + leader/localleader keys
(use-package general
:config
:init
;; Convenience aliases
(defalias 'define-key! #'general-def)
(defalias 'unmap! #'general-unbind))

View file

@ -193,7 +193,6 @@ at the values with which this function was called."
&key
filter
map
sort ; TODO Allow a function for custom sorting?
(full t)
(follow-symlinks t)
(type 'files)

View file

@ -22,7 +22,7 @@ Emacs.")
;;; Packages
(def-package! projectile
:after-call (after-find-file dired-before-readin-hook minibuffer-setup-hook)
:after-call after-find-file dired-before-readin-hook minibuffer-setup-hook
:commands (projectile-project-root
projectile-project-name
projectile-project-p
@ -149,7 +149,7 @@ the command instead."
;;
;; Project-based minor modes
;;; Project-based minor modes
(defvar doom-project-hook nil
"Hook run when a project is enabled. The name of the project's mode and its

View file

@ -418,14 +418,14 @@ treat Emacs as a non-application window."
(def-package! winner
;; undo/redo changes to Emacs' window layout
:after-call (after-find-file doom-switch-window-hook)
:after-call after-find-file doom-switch-window-hook
:preface (defvar winner-dont-bind-my-keys t)
:config (winner-mode +1)) ; I'll bind keys myself
(def-package! paren
;; highlight matching delimiters
:after-call (after-find-file doom-switch-buffer-hook)
:after-call after-find-file doom-switch-buffer-hook
:config
(setq show-paren-delay 0.1
show-paren-highlight-openparen t
@ -448,8 +448,12 @@ treat Emacs as a non-application window."
;;; Third party packages
(def-package! all-the-icons
:commands (all-the-icons-octicon all-the-icons-faicon all-the-icons-fileicon
all-the-icons-wicon all-the-icons-material all-the-icons-alltheicon)
:commands (all-the-icons-octicon
all-the-icons-faicon
all-the-icons-fileicon
all-the-icons-wicon
all-the-icons-material
all-the-icons-alltheicon)
:init
(def-advice! doom--disable-all-the-icons-in-tty-a (orig-fn &rest args)
"all-the-icons doesn't work in the terminal, so we \"disable\" them."

View file

@ -500,6 +500,9 @@ to least)."
load-path doom--initial-load-path
process-environment doom--initial-process-environment)
(require 'core-lib)
(require 'core-modules)
;; `doom-autoload-file' tells Emacs where to load all its functions from.
;; This includes everything in core/autoload/*.el and autoload files in
;; enabled modules.
@ -530,26 +533,24 @@ to least)."
;; Load shell environment
(when (and (not noninteractive)
(file-exists-p doom-env-file))
(doom-load-env-vars doom-env-file)))
;; In case we want to use package.el's API
(with-eval-after-load 'package
(require 'core-packages))
;; Or straight interactively
(with-eval-after-load 'straight
(require 'core-packages)
(doom-initialize-packages)))
(doom-load-env-vars doom-env-file))))
;;
;;; Bootstrap Doom
(add-to-list 'load-path doom-core-dir)
(require 'core-lib)
(require 'core-modules)
(if noninteractive (require 'core-cli))
(doom-initialize noninteractive)
(unless noninteractive
;; In case we want to use package.el's API
(with-eval-after-load 'package
(require 'core-packages))
;; Or straight interactively
(with-eval-after-load 'straight
(require 'core-packages)
(doom-initialize-packages))
(if noninteractive
(require 'core-cli)
(add-hook 'window-setup-hook #'doom-display-benchmark-h)
(require 'core-keybinds)
(require 'core-ui)

View file

@ -1,4 +1,6 @@
;;; init.test.el -- for automated unit tests -*- lexical-binding: t; -*-
;;; init.test.el -*- lexical-binding: t; -*-
;; An init.el for our unit test suites. Do not use this!
(doom! :completion
company

View file

@ -1,8 +1,8 @@
;;; completion/company/config.el -*- lexical-binding: t; -*-
(def-package! company
:commands (company-complete-common company-manual-begin company-grab-line)
:after-call (evil-insert-state-entry-hook evil-emacs-state-entry-hook)
:commands company-complete-common company-manual-begin company-grab-line
:after-call evil-insert-state-entry-hook evil-emacs-state-entry-hook
:init
(setq company-minimum-prefix-length 2
company-tooltip-limit 14
@ -37,7 +37,6 @@
(def-package! company-tng
:when (featurep! +tng)
:defer 2
:after-call post-self-insert-hook
:config
(add-to-list 'company-frontends 'company-tng-frontend)

View file

@ -324,5 +324,5 @@ evil-ex-specific constructs, so we disable it solely in evil-ex."
(prescient-persist-mode +1))
;; Used by `counsel-M-x'
(setq amx-save-file (concat doom-cache-dir "amx-items"))
;;;###package amx
(setq amx-save-file (concat doom-cache-dir "amx-items")) ; used by `counsel-M-x'

View file

@ -44,7 +44,7 @@
(user-error "Must be called from a file-visiting buffer"))
(let* ((directory (file-name-directory buffer-file-name))
(filename (file-name-nondirectory buffer-file-name))
(files (doom-files-in directory :depth 0 :sort t :match "/[^._][^/]*$"))
(files (doom-files-in directory :depth 0 :match "/[^._][^/]*$"))
(index (cl-position filename files :test #'string=)))
(when (null index)
(user-error "Couldn't find this file in current directory"))

View file

@ -184,7 +184,7 @@ directives. By default, this only recognizes C directives.")
(def-package! evil-easymotion
:commands (evilem-create evilem-default-keybindings)
:commands evilem-create evilem-default-keybindings
:config
;; Use evil-search backend, instead of isearch
(evilem-make-motion evilem-motion-search-next #'evil-ex-search-next
@ -199,7 +199,7 @@ directives. By default, this only recognizes C directives.")
(def-package! evil-embrace
:commands (embrace-add-pair embrace-add-pair-regexp)
:commands embrace-add-pair embrace-add-pair-regexp
:hook (LaTeX-mode . embrace-LaTeX-mode-hook)
:hook (org-mode . embrace-org-mode-hook)
:hook ((ruby-mode enh-ruby-mode) . embrace-ruby-mode-hook)
@ -246,8 +246,8 @@ directives. By default, this only recognizes C directives.")
(def-package! evil-escape
:commands (evil-escape)
:after-call (evil-normal-state-exit-hook)
:commands evil-escape
:after-call evil-normal-state-exit-hook
:init
(setq evil-escape-excluded-states '(normal visual multiedit emacs motion)
evil-escape-excluded-major-modes '(neotree-mode treemacs-mode vterm-mode)
@ -272,8 +272,10 @@ directives. By default, this only recognizes C directives.")
(def-package! evil-snipe
:commands (evil-snipe-mode evil-snipe-override-mode
evil-snipe-local-mode evil-snipe-override-local-mode)
:commands (evil-snipe-mode
evil-snipe-override-mode
evil-snipe-local-mode
evil-snipe-override-local-mode)
:after-call pre-command-hook
:init
(setq evil-snipe-smart-case t
@ -306,7 +308,7 @@ directives. By default, this only recognizes C directives.")
;;
;; Text object plugins
;;; Text object plugins
(def-package! exato
:commands (evil-outer-xml-attr evil-inner-xml-attr))
:commands evil-outer-xml-attr evil-inner-xml-attr)

View file

@ -10,7 +10,7 @@
;;
;; Third-party plugins
;;; Third-party plugins
;; `csv-mode'
(map! :after csv-mode
@ -37,5 +37,3 @@
(def-project-mode! +data-vagrant-mode
:files ("Vagrantfile"))

View file

@ -71,6 +71,13 @@ library/userland functions"
(throw 'matcher t)))))))
nil))
;; `+emacs-lisp-highlight-vars-and-faces' is a potentially expensive function
;; and should be byte-compiled, no matter what, to ensure it runs as fast as
;; possible:
(unless (byte-code-function-p (symbol-function '+emacs-lisp-highlight-vars-and-faces))
(with-no-warnings
(byte-compile #'+emacs-lisp-highlight-vars-and-faces)))
;;;###autoload
(defun +emacs-lisp-lookup-documentation (thing)
"Lookup THING with `helpful-variable' if it's a variable, `helpful-callable'
@ -79,13 +86,6 @@ if it's callable, `apropos' otherwise."
(doom/describe-symbol thing)
(call-interactively #'doom/describe-symbol)))
;; `+emacs-lisp-highlight-vars-and-faces' is a potentially expensive function
;; and should be byte-compiled, no matter what, to ensure it runs as fast as
;; possible:
(when (not (byte-code-function-p (symbol-function '+emacs-lisp-highlight-vars-and-faces)))
(with-no-warnings
(byte-compile #'+emacs-lisp-highlight-vars-and-faces)))
;;
;;; Commands

View file

@ -34,9 +34,6 @@ This marks a foldable marker for `outline-minor-mode' in elisp buffers.")
("add-hook" "remove-hook")
("add-hook!" "remove-hook!")))
;; TODO
(put 'add-hook 'lisp-indent-function 'defun)
(setq-hook! 'emacs-lisp-mode-hook
tab-width 2
;; shorter name in modeline
@ -72,7 +69,7 @@ This marks a foldable marker for `outline-minor-mode' in elisp buffers.")
;; `emacs-lisp' checker's verbosity.
(add-hook 'flycheck-mode-hook #'+emacs-lisp-reduce-flycheck-errors-in-emacs-config-h)
;; Special fontification for elisp
;; Special syntax highlighting for elisp...
(font-lock-add-keywords
'emacs-lisp-mode
(append `(;; custom Doom cookies

View file

@ -36,8 +36,9 @@
:interpreter "node"
:commands js2-line-break
:config
(setq js2-skip-preprocessor-directives t
js-chain-indent t
(setq js-chain-indent t
;; Don't mishighlight shebang lines
js2-skip-preprocessor-directives t
;; let flycheck handle this
js2-mode-show-parse-errors nil
js2-mode-show-strict-warnings nil

View file

@ -270,14 +270,16 @@ Some commands of interest:
+ `+org-attach/file'
+ `+org-attach/url'
+ `+org-attach/sync'"
(setq org-attach-directory (expand-file-name org-attach-directory org-directory))
(setq org-attach-directory (doom-dir org-directory org-attach-directory))
;; A shorter link to attachments
(add-to-list 'org-link-abbrev-alist (cons "attach" (abbreviate-file-name org-attach-directory)))
(add-to-list 'org-link-abbrev-alist
(cons "attach"
(abbreviate-file-name org-attach-directory)))
(org-link-set-parameters
"attach"
:follow (lambda (link) (find-file (expand-file-name link org-attach-directory)))
:follow (lambda (link) (find-file (doom-path org-attach-directory link)))
:complete (lambda (&optional _arg)
(+org--relpath (+org-link-read-file "attach" org-attach-directory)
org-attach-directory))
@ -571,8 +573,8 @@ between the two."
"e" #'org-table-edit-formulas
"=" #'org-table-eval-formulas)))
;; Fixes #1483: this messy hack fixes `org-agenda' or `evil-org-agenda'
;; overriding SPC, breaking the localleader. TODO Improve me!
;; HACK Fixes #1483: this messy hack fixes `org-agenda' or `evil-org-agenda'
;; overriding SPC, breaking the localleader
(define-minor-mode org-agenda-localleader-mode "TODO"
:keymap (make-sparse-keymap))
(add-hook 'org-agenda-mode-hook #'org-agenda-localleader-mode)

View file

@ -4,10 +4,12 @@
(def-package! org-download
:commands (org-download-dnd org-download-dnd-base64)
:init
;; Add these manually so that org-download is lazy-loaded...
(add-to-list 'dnd-protocol-alist '("^\\(https?\\|ftp\\|file\\|nfs\\):" . +org-dragndrop-download-dnd))
(add-to-list 'dnd-protocol-alist '("^data:" . org-download-dnd-base64))
;; HACK We add these manually so that org-download is truly lazy-loaded
(appendq!
dnd-protocol-alist
'("^\\(?:https?\\|ftp\\|file\\|nfs\\):"
. +org-dragndrop-download-dnd)
'("^data:" . org-download-dnd-base64))
(advice-add #'org-download-enable :override #'ignore)
:config
(setq org-download-image-dir org-attach-directory

View file

@ -61,13 +61,14 @@ character.")
"HTML encode/decode TEXT. Based on Xah's replace HTML named entities function
@ http://ergoemacs.org/emacs/elisp_replace_html_entities_command.html"
(interactive "<!><r>")
(seq-doseq (rep +web-entities-list)
(mapc (lambda (rep)
(let ((from (elt rep (if decode-p 0 1)))
(to (elt rep (if decode-p 1 0)))
case-fold-search)
(when (and (not (equal from " "))
(string-match-p (regexp-quote from) text))
(setq text (replace-regexp-in-string (regexp-quote from) to text t t)))))
+web-entities-list)
text)
(defun +web--entities-region (beg end &optional decode-p)
@ -75,14 +76,15 @@ character.")
function @ http://ergoemacs.org/emacs/elisp_replace_html_entities_command.html"
(save-restriction
(narrow-to-region beg end)
(seq-doseq (rep +web-entities-list)
(mapc (lambda (rep)
(let ((from (elt rep (if decode-p 0 1)))
(to (elt rep (if decode-p 1 0)))
case-fold-search)
(unless (equal from " ")
(goto-char (point-min))
(while (search-forward from nil t)
(replace-match to 'FIXEDCASE 'LITERAL)))))))
(replace-match to 'FIXEDCASE 'LITERAL)))))
+web-entities-list)))
;;;###autoload
(defun +web-encode-entities (text)

View file

@ -5,6 +5,7 @@
lsp-keep-workspace-alive nil
lsp-groovy-server-install-dir (concat doom-etc-dir "groovy-langserver/"))
(after! lsp-mode
(set-lookup-handlers! 'lsp-mode :async t
:documentation 'lsp-describe-thing-at-point

View file

@ -106,8 +106,10 @@ ensure it is built when we actually use Forge."
(def-package! magit-todos
:after magit
:config
(setq magit-todos-keyword-suffix "\\(?:([^)]+)\\)?:?")
(setq magit-todos-keyword-suffix "\\(?:([^)]+)\\)?:?") ; make colon optional
(define-key magit-todos-section-map "j" nil)
;; Warns that jT isn't bound. Well, yeah, you don't need to tell me, that was
;; on purpose ya goose.
(advice-add #'magit-todos-mode :around #'doom-shut-up-a)
(magit-todos-mode +1))