dotfiles

Linux and macOS dotfiles
git clone https://github.com/michaelneuper/dotfiles.git
README | Files | Log | Refs

commit 64abe11c53efc361aa843afe487701e5b9842959
parent 9591dbdb3edf056f8d0504609d25e383c87390e8
Author: michaelneuper <michael@michaelneuper.com>
Date:   Sun,  8 Jun 2025 18:08:23 +0200

remove emacs

Diffstat:
D.config/emacs/.dir-locals.el | 3---
D.config/emacs/.doomrc | 51---------------------------------------------------
D.config/emacs/.github/CODEOWNERS | 165-------------------------------------------------------------------------------
D.config/emacs/.github/ISSUE_TEMPLATE/bug_report.yml | 115-------------------------------------------------------------------------------
D.config/emacs/.github/ISSUE_TEMPLATE/config.yml | 14--------------
D.config/emacs/.github/workflows/add-to-project.yml | 8--------
D.config/emacs/.github/workflows/lint-commits.yml | 5-----
D.config/emacs/.github/workflows/triage.yml | 7-------
D.config/emacs/.gitignore | 53-----------------------------------------------------
D.config/emacs/LICENSE | 22----------------------
D.config/emacs/README.md | 249-------------------------------------------------------------------------------
D.config/emacs/bin/doom | 327-------------------------------------------------------------------------------
D.config/emacs/bin/doom.cmd | 25-------------------------
D.config/emacs/bin/doomscript | 87-------------------------------------------------------------------------------
D.config/emacs/bin/org-capture | 43-------------------------------------------
D.config/emacs/bin/org-tangle | 159-------------------------------------------------------------------------------
D.config/emacs/docs/appendix.org | 207-------------------------------------------------------------------------------
D.config/emacs/docs/contributing.org | 171-------------------------------------------------------------------------------
D.config/emacs/docs/examples.org | 1014-------------------------------------------------------------------------------
D.config/emacs/docs/faq.org | 983-------------------------------------------------------------------------------
D.config/emacs/docs/getting_started.org | 1677-------------------------------------------------------------------------------
D.config/emacs/docs/index.org | 106-------------------------------------------------------------------------------
D.config/emacs/docs/modules.org | 224-------------------------------------------------------------------------------
D.config/emacs/early-init.el | 142-------------------------------------------------------------------------------
D.config/emacs/lisp/cli/ci.el | 458-------------------------------------------------------------------------------
D.config/emacs/lisp/cli/compile.el | 214-------------------------------------------------------------------------------
D.config/emacs/lisp/cli/doctor.el | 297-------------------------------------------------------------------------------
D.config/emacs/lisp/cli/env.el | 148-------------------------------------------------------------------------------
D.config/emacs/lisp/cli/help.el | 466-------------------------------------------------------------------------------
D.config/emacs/lisp/cli/info.el | 34----------------------------------
D.config/emacs/lisp/cli/install.el | 138-------------------------------------------------------------------------------
D.config/emacs/lisp/cli/make.el | 91-------------------------------------------------------------------------------
D.config/emacs/lisp/cli/make/completions.el | 142-------------------------------------------------------------------------------
D.config/emacs/lisp/cli/meta.el | 482-------------------------------------------------------------------------------
D.config/emacs/lisp/cli/packages.el | 825-------------------------------------------------------------------------------
D.config/emacs/lisp/cli/profiles.el | 83-------------------------------------------------------------------------------
D.config/emacs/lisp/cli/run.el | 119-------------------------------------------------------------------------------
D.config/emacs/lisp/cli/sync.el | 81-------------------------------------------------------------------------------
D.config/emacs/lisp/cli/test.el | 48------------------------------------------------
D.config/emacs/lisp/cli/upgrade.el | 165-------------------------------------------------------------------------------
D.config/emacs/lisp/doom-cli.el | 2012-------------------------------------------------------------------------------
D.config/emacs/lisp/doom-editor.el | 732-------------------------------------------------------------------------------
D.config/emacs/lisp/doom-keybinds.el | 472-------------------------------------------------------------------------------
D.config/emacs/lisp/doom-lib.el | 988-------------------------------------------------------------------------------
D.config/emacs/lisp/doom-modules.el | 501-------------------------------------------------------------------------------
D.config/emacs/lisp/doom-packages.el | 647-------------------------------------------------------------------------------
D.config/emacs/lisp/doom-profiles.el | 458-------------------------------------------------------------------------------
D.config/emacs/lisp/doom-projects.el | 315-------------------------------------------------------------------------------
D.config/emacs/lisp/doom-start.el | 415-------------------------------------------------------------------------------
D.config/emacs/lisp/doom-ui.el | 651-------------------------------------------------------------------------------
D.config/emacs/lisp/doom.el | 706-------------------------------------------------------------------------------
D.config/emacs/lisp/init.el | 16----------------
D.config/emacs/lisp/lib/autoloads.el | 199-------------------------------------------------------------------------------
D.config/emacs/lisp/lib/buffers.el | 393-------------------------------------------------------------------------------
D.config/emacs/lisp/lib/config.el | 137-------------------------------------------------------------------------------
D.config/emacs/lisp/lib/debug.el | 444-------------------------------------------------------------------------------
D.config/emacs/lisp/lib/docs.el | 543-------------------------------------------------------------------------------
D.config/emacs/lisp/lib/files.el | 521-------------------------------------------------------------------------------
D.config/emacs/lisp/lib/fonts.el | 180-------------------------------------------------------------------------------
D.config/emacs/lisp/lib/git.el | 16----------------
D.config/emacs/lisp/lib/help.el | 736-------------------------------------------------------------------------------
D.config/emacs/lisp/lib/packages.el | 316-------------------------------------------------------------------------------
D.config/emacs/lisp/lib/plist.el | 66------------------------------------------------------------------
D.config/emacs/lisp/lib/print.el | 501-------------------------------------------------------------------------------
D.config/emacs/lisp/lib/process.el | 47-----------------------------------------------
D.config/emacs/lisp/lib/projects.el | 180-------------------------------------------------------------------------------
D.config/emacs/lisp/lib/sandbox.el | 186-------------------------------------------------------------------------------
D.config/emacs/lisp/lib/scratch.el | 199-------------------------------------------------------------------------------
D.config/emacs/lisp/lib/sessions.el | 152-------------------------------------------------------------------------------
D.config/emacs/lisp/lib/store.el | 155-------------------------------------------------------------------------------
D.config/emacs/lisp/lib/system.el | 113-------------------------------------------------------------------------------
D.config/emacs/lisp/lib/text.el | 350-------------------------------------------------------------------------------
D.config/emacs/lisp/lib/themes.el | 109-------------------------------------------------------------------------------
D.config/emacs/lisp/lib/ui.el | 246-------------------------------------------------------------------------------
D.config/emacs/lisp/packages.el | 51---------------------------------------------------
D.config/emacs/modules/.gitignore | 19-------------------
D.config/emacs/modules/LICENSE | 22----------------------
D.config/emacs/modules/README.org | 1492-------------------------------------------------------------------------------
D.config/emacs/modules/app/README.org | 11-----------
D.config/emacs/modules/app/calendar/README.org | 78------------------------------------------------------------------------------
D.config/emacs/modules/app/calendar/autoload.el | 69---------------------------------------------------------------------
D.config/emacs/modules/app/calendar/config.el | 94-------------------------------------------------------------------------------
D.config/emacs/modules/app/calendar/packages.el | 8--------
D.config/emacs/modules/app/emms/README.org | 74--------------------------------------------------------------------------
D.config/emacs/modules/app/emms/autoload.el | 30------------------------------
D.config/emacs/modules/app/emms/config.el | 18------------------
D.config/emacs/modules/app/emms/packages.el | 4----
D.config/emacs/modules/app/everywhere/README.org | 72------------------------------------------------------------------------
D.config/emacs/modules/app/everywhere/cli.el | 5-----
D.config/emacs/modules/app/everywhere/config.el | 47-----------------------------------------------
D.config/emacs/modules/app/everywhere/doctor.el | 12------------
D.config/emacs/modules/app/everywhere/packages.el | 4----
D.config/emacs/modules/app/irc/README.org | 173-------------------------------------------------------------------------------
D.config/emacs/modules/app/irc/autoload/irc.el | 112-------------------------------------------------------------------------------
D.config/emacs/modules/app/irc/autoload/ivy.el | 30------------------------------
D.config/emacs/modules/app/irc/autoload/settings.el | 18------------------
D.config/emacs/modules/app/irc/autoload/vertico.el | 23-----------------------
D.config/emacs/modules/app/irc/config.el | 258-------------------------------------------------------------------------------
D.config/emacs/modules/app/irc/packages.el | 5-----
D.config/emacs/modules/app/rss/README.org | 132-------------------------------------------------------------------------------
D.config/emacs/modules/app/rss/autoload.el | 152-------------------------------------------------------------------------------
D.config/emacs/modules/app/rss/config.el | 89-------------------------------------------------------------------------------
D.config/emacs/modules/app/rss/packages.el | 7-------
D.config/emacs/modules/app/twitter/README.org | 101-------------------------------------------------------------------------------
D.config/emacs/modules/app/twitter/autoload.el | 104-------------------------------------------------------------------------------
D.config/emacs/modules/app/twitter/config.el | 76----------------------------------------------------------------------------
D.config/emacs/modules/app/twitter/packages.el | 5-----
D.config/emacs/modules/checkers/README.org | 9---------
D.config/emacs/modules/checkers/grammar/README.org | 76----------------------------------------------------------------------------
D.config/emacs/modules/checkers/grammar/config.el | 40----------------------------------------
D.config/emacs/modules/checkers/grammar/packages.el | 5-----
D.config/emacs/modules/checkers/spell/README.org | 235-------------------------------------------------------------------------------
D.config/emacs/modules/checkers/spell/autoload/+flyspell.el | 86-------------------------------------------------------------------------------
D.config/emacs/modules/checkers/spell/autoload/+spell-fu.el | 116-------------------------------------------------------------------------------
D.config/emacs/modules/checkers/spell/config.el | 249-------------------------------------------------------------------------------
D.config/emacs/modules/checkers/spell/doctor.el | 10----------
D.config/emacs/modules/checkers/spell/packages.el | 13-------------
D.config/emacs/modules/checkers/syntax/README.org | 83-------------------------------------------------------------------------------
D.config/emacs/modules/checkers/syntax/autoload.el | 25-------------------------
D.config/emacs/modules/checkers/syntax/config.el | 83-------------------------------------------------------------------------------
D.config/emacs/modules/checkers/syntax/packages.el | 9---------
D.config/emacs/modules/completion/README.org | 18------------------
D.config/emacs/modules/completion/company/README.org | 146-------------------------------------------------------------------------------
D.config/emacs/modules/completion/company/autoload.el | 172-------------------------------------------------------------------------------
D.config/emacs/modules/completion/company/config.el | 186-------------------------------------------------------------------------------
D.config/emacs/modules/completion/company/packages.el | 7-------
D.config/emacs/modules/completion/company/test/test-company.el | 75---------------------------------------------------------------------------
D.config/emacs/modules/completion/helm/README.org | 206-------------------------------------------------------------------------------
D.config/emacs/modules/completion/helm/autoload/evil.el | 42------------------------------------------
D.config/emacs/modules/completion/helm/autoload/helm.el | 100-------------------------------------------------------------------------------
D.config/emacs/modules/completion/helm/config.el | 201-------------------------------------------------------------------------------
D.config/emacs/modules/completion/helm/packages.el | 20--------------------
D.config/emacs/modules/completion/ido/README.org | 56--------------------------------------------------------
D.config/emacs/modules/completion/ido/config.el | 62--------------------------------------------------------------
D.config/emacs/modules/completion/ido/packages.el | 8--------
D.config/emacs/modules/completion/ivy/README.org | 190-------------------------------------------------------------------------------
D.config/emacs/modules/completion/ivy/autoload/evil.el | 14--------------
D.config/emacs/modules/completion/ivy/autoload/hydras.el | 32--------------------------------
D.config/emacs/modules/completion/ivy/autoload/ivy.el | 384-------------------------------------------------------------------------------
D.config/emacs/modules/completion/ivy/autoload/posframe.el | 16----------------
D.config/emacs/modules/completion/ivy/config.el | 416-------------------------------------------------------------------------------
D.config/emacs/modules/completion/ivy/doctor.el | 3---
D.config/emacs/modules/completion/ivy/packages.el | 24------------------------
D.config/emacs/modules/completion/vertico/README.org | 306-------------------------------------------------------------------------------
D.config/emacs/modules/completion/vertico/autoload/evil.el | 14--------------
D.config/emacs/modules/completion/vertico/autoload/magit.el | 8--------
D.config/emacs/modules/completion/vertico/autoload/vertico.el | 261-------------------------------------------------------------------------------
D.config/emacs/modules/completion/vertico/autoload/workspaces.el | 93-------------------------------------------------------------------------------
D.config/emacs/modules/completion/vertico/config.el | 321-------------------------------------------------------------------------------
D.config/emacs/modules/completion/vertico/doctor.el | 12------------
D.config/emacs/modules/completion/vertico/packages.el | 28----------------------------
D.config/emacs/modules/config/README.org | 10----------
D.config/emacs/modules/config/default/+emacs-bindings.el | 637-------------------------------------------------------------------------------
D.config/emacs/modules/config/default/+emacs.el | 26--------------------------
D.config/emacs/modules/config/default/+evil-bindings.el | 772-------------------------------------------------------------------------------
D.config/emacs/modules/config/default/+evil.el | 21---------------------
D.config/emacs/modules/config/default/README.org | 71-----------------------------------------------------------------------
D.config/emacs/modules/config/default/autoload/default.el | 72------------------------------------------------------------------------
D.config/emacs/modules/config/default/autoload/deferred.el | 20--------------------
D.config/emacs/modules/config/default/autoload/files.el | 67-------------------------------------------------------------------
D.config/emacs/modules/config/default/autoload/search.el | 146-------------------------------------------------------------------------------
D.config/emacs/modules/config/default/autoload/text.el | 175-------------------------------------------------------------------------------
D.config/emacs/modules/config/default/config.el | 497-------------------------------------------------------------------------------
D.config/emacs/modules/config/default/packages.el | 9---------
D.config/emacs/modules/config/literate/README.org | 124-------------------------------------------------------------------------------
D.config/emacs/modules/config/literate/autoload.el | 147-------------------------------------------------------------------------------
D.config/emacs/modules/config/literate/cli.el | 19-------------------
D.config/emacs/modules/config/use-package/init.el | 195-------------------------------------------------------------------------------
D.config/emacs/modules/config/use-package/packages.el | 4----
D.config/emacs/modules/editor/README.org | 9---------
D.config/emacs/modules/editor/evil/+commands.el | 108-------------------------------------------------------------------------------
D.config/emacs/modules/editor/evil/README.org | 245-------------------------------------------------------------------------------
D.config/emacs/modules/editor/evil/autoload/advice.el | 233-------------------------------------------------------------------------------
D.config/emacs/modules/editor/evil/autoload/embrace.el | 40----------------------------------------
D.config/emacs/modules/editor/evil/autoload/evil.el | 185-------------------------------------------------------------------------------
D.config/emacs/modules/editor/evil/autoload/ex.el | 192-------------------------------------------------------------------------------
D.config/emacs/modules/editor/evil/autoload/files.el | 31-------------------------------
D.config/emacs/modules/editor/evil/autoload/textobjects.el | 68--------------------------------------------------------------------
D.config/emacs/modules/editor/evil/autoload/unimpaired.el | 200-------------------------------------------------------------------------------
D.config/emacs/modules/editor/evil/config.el | 633-------------------------------------------------------------------------------
D.config/emacs/modules/editor/evil/init.el | 350-------------------------------------------------------------------------------
D.config/emacs/modules/editor/evil/packages.el | 38--------------------------------------
D.config/emacs/modules/editor/evil/test/test-evil.el | 69---------------------------------------------------------------------
D.config/emacs/modules/editor/file-templates/README.org | 96-------------------------------------------------------------------------------
D.config/emacs/modules/editor/file-templates/autoload.el | 160-------------------------------------------------------------------------------
D.config/emacs/modules/editor/file-templates/config.el | 167-------------------------------------------------------------------------------
D.config/emacs/modules/editor/file-templates/packages.el | 4----
D.config/emacs/modules/editor/file-templates/templates/.editorconfig | 7-------
D.config/emacs/modules/editor/file-templates/templates/android-mode/__build.gradle | 49-------------------------------------------------
D.config/emacs/modules/editor/file-templates/templates/c++-mode/__cpp | 7-------
D.config/emacs/modules/editor/file-templates/templates/c++-mode/__hpp | 10----------
D.config/emacs/modules/editor/file-templates/templates/c++-mode/__main.cpp | 13-------------
D.config/emacs/modules/editor/file-templates/templates/c++-mode/__winmain.cpp | 12------------
D.config/emacs/modules/editor/file-templates/templates/c-mode/__c | 7-------
D.config/emacs/modules/editor/file-templates/templates/c-mode/__h | 10----------
D.config/emacs/modules/editor/file-templates/templates/direnv-envrc-mode/__envrc | 16----------------
D.config/emacs/modules/editor/file-templates/templates/dockerfile-mode/__ | 5-----
D.config/emacs/modules/editor/file-templates/templates/emacs-ert-mode/__ | 4----
D.config/emacs/modules/editor/file-templates/templates/emacs-lisp-mode/__doom-doctor | 3---
D.config/emacs/modules/editor/file-templates/templates/emacs-lisp-mode/__doom-module | 3---
D.config/emacs/modules/editor/file-templates/templates/emacs-lisp-mode/__doom-packages | 4----
D.config/emacs/modules/editor/file-templates/templates/emacs-lisp-mode/__doom-test | 5-----
D.config/emacs/modules/editor/file-templates/templates/emacs-lisp-mode/__doomrc | 8--------
D.config/emacs/modules/editor/file-templates/templates/emacs-lisp-mode/__package | 25-------------------------
D.config/emacs/modules/editor/file-templates/templates/fish-mode/__ | 3---
D.config/emacs/modules/editor/file-templates/templates/gitignore-mode/__ | 68--------------------------------------------------------------------
D.config/emacs/modules/editor/file-templates/templates/go-mode/__.go | 8--------
D.config/emacs/modules/editor/file-templates/templates/go-mode/__main.go | 10----------
D.config/emacs/modules/editor/file-templates/templates/java-mode/__annotation-type | 10----------
D.config/emacs/modules/editor/file-templates/templates/java-mode/__class | 9---------
D.config/emacs/modules/editor/file-templates/templates/java-mode/__enum | 10----------
D.config/emacs/modules/editor/file-templates/templates/java-mode/__interface | 10----------
D.config/emacs/modules/editor/file-templates/templates/java-mode/__main | 11-----------
D.config/emacs/modules/editor/file-templates/templates/java-mode/__record | 9---------
D.config/emacs/modules/editor/file-templates/templates/js-mode/__ | 3---
D.config/emacs/modules/editor/file-templates/templates/js-mode/__gulpfile.js | 5-----
D.config/emacs/modules/editor/file-templates/templates/js-mode/__node | 3---
D.config/emacs/modules/editor/file-templates/templates/js-mode/__webpack.config.js | 21---------------------
D.config/emacs/modules/editor/file-templates/templates/json-mode/__bower.json | 15---------------
D.config/emacs/modules/editor/file-templates/templates/json-mode/__package.json | 14--------------
D.config/emacs/modules/editor/file-templates/templates/love-mode/__conf.lua | 40----------------------------------------
D.config/emacs/modules/editor/file-templates/templates/love-mode/__main.lua | 0
D.config/emacs/modules/editor/file-templates/templates/makefile-gmake-mode/__ | 9---------
D.config/emacs/modules/editor/file-templates/templates/makefile-gmake-mode/__cpp | 47-----------------------------------------------
D.config/emacs/modules/editor/file-templates/templates/markdown-mode/__ | 7-------
D.config/emacs/modules/editor/file-templates/templates/markdown-mode/__jekyll-post | 7-------
D.config/emacs/modules/editor/file-templates/templates/nix-mode/__ | 10----------
D.config/emacs/modules/editor/file-templates/templates/nix-mode/__shell.nix | 10----------
D.config/emacs/modules/editor/file-templates/templates/nose-mode/__ | 0
D.config/emacs/modules/editor/file-templates/templates/nxml-mode/__ | 3---
D.config/emacs/modules/editor/file-templates/templates/org-mode/__ | 21---------------------
D.config/emacs/modules/editor/file-templates/templates/org-mode/__contact.org | 17-----------------
D.config/emacs/modules/editor/file-templates/templates/org-mode/__doom-category-readme | 14--------------
D.config/emacs/modules/editor/file-templates/templates/org-mode/__doom-docs | 11-----------
D.config/emacs/modules/editor/file-templates/templates/org-mode/__doom-readme | 198-------------------------------------------------------------------------------
D.config/emacs/modules/editor/file-templates/templates/org-mode/__invoice.org | 22----------------------
D.config/emacs/modules/editor/file-templates/templates/org-mode/__project.org | 9---------
D.config/emacs/modules/editor/file-templates/templates/php-mode/__ | 3---
D.config/emacs/modules/editor/file-templates/templates/php-mode/__.class.php | 7-------
D.config/emacs/modules/editor/file-templates/templates/python-mode/__ | 6------
D.config/emacs/modules/editor/file-templates/templates/python-mode/__setup.py | 0
D.config/emacs/modules/editor/file-templates/templates/rspec-mode/__ | 4----
D.config/emacs/modules/editor/file-templates/templates/rspec-mode/__.rspec | 3---
D.config/emacs/modules/editor/file-templates/templates/rspec-mode/__helper | 10----------
D.config/emacs/modules/editor/file-templates/templates/ruby-mode/__ | 3---
D.config/emacs/modules/editor/file-templates/templates/ruby-mode/__.gemspec | 0
D.config/emacs/modules/editor/file-templates/templates/ruby-mode/__Gemfile | 3---
D.config/emacs/modules/editor/file-templates/templates/ruby-mode/__Rakefile | 17-----------------
D.config/emacs/modules/editor/file-templates/templates/ruby-mode/__module | 13-------------
D.config/emacs/modules/editor/file-templates/templates/rust-mode/__Cargo.toml | 5-----
D.config/emacs/modules/editor/file-templates/templates/rust-mode/__main.rs | 3---
D.config/emacs/modules/editor/file-templates/templates/scss-mode/__ | 0
D.config/emacs/modules/editor/file-templates/templates/scss-mode/__master.scss | 0
D.config/emacs/modules/editor/file-templates/templates/scss-mode/__normalize.scss | 0
D.config/emacs/modules/editor/file-templates/templates/sh-mode/__ | 3---
D.config/emacs/modules/editor/file-templates/templates/sh-mode/__zunit | 5-----
D.config/emacs/modules/editor/file-templates/templates/slim-mode/__ | 17-----------------
D.config/emacs/modules/editor/file-templates/templates/snippet-mode/__ | 8--------
D.config/emacs/modules/editor/file-templates/templates/solidity-mode/__sol | 13-------------
D.config/emacs/modules/editor/file-templates/templates/text-mode/__license | 6------
D.config/emacs/modules/editor/file-templates/templates/text-mode/__license-apache | 208-------------------------------------------------------------------------------
D.config/emacs/modules/editor/file-templates/templates/text-mode/__license-apache-bp | 21---------------------
D.config/emacs/modules/editor/file-templates/templates/text-mode/__license-bsd2 | 29-----------------------------
D.config/emacs/modules/editor/file-templates/templates/text-mode/__license-bsd3 | 33---------------------------------
D.config/emacs/modules/editor/file-templates/templates/text-mode/__license-gpl3 | 681-------------------------------------------------------------------------------
D.config/emacs/modules/editor/file-templates/templates/text-mode/__license-gpl3-bp | 23-----------------------
D.config/emacs/modules/editor/file-templates/templates/text-mode/__license-lgpl3 | 172-------------------------------------------------------------------------------
D.config/emacs/modules/editor/file-templates/templates/text-mode/__license-mit | 29-----------------------------
D.config/emacs/modules/editor/file-templates/templates/text-mode/__license-mozilla | 381-------------------------------------------------------------------------------
D.config/emacs/modules/editor/file-templates/templates/text-mode/__license-mozilla-bp | 11-----------
D.config/emacs/modules/editor/file-templates/templates/text-mode/__license-unlicense | 31-------------------------------
D.config/emacs/modules/editor/file-templates/templates/web-mode/__.html | 25-------------------------
D.config/emacs/modules/editor/file-templates/templates/web-mode/__jekyll-layout.html | 0
D.config/emacs/modules/editor/file-templates/templates/yaml-mode/__docker-compose.yml | 15---------------
D.config/emacs/modules/editor/fold/README.org | 69---------------------------------------------------------------------
D.config/emacs/modules/editor/fold/autoload/fold.el | 188-------------------------------------------------------------------------------
D.config/emacs/modules/editor/fold/autoload/hideshow.el | 83-------------------------------------------------------------------------------
D.config/emacs/modules/editor/fold/config.el | 100-------------------------------------------------------------------------------
D.config/emacs/modules/editor/fold/packages.el | 11-----------
D.config/emacs/modules/editor/format/README.org | 180-------------------------------------------------------------------------------
D.config/emacs/modules/editor/format/autoload/evil.el | 8--------
D.config/emacs/modules/editor/format/autoload/format.el | 293-------------------------------------------------------------------------------
D.config/emacs/modules/editor/format/autoload/settings.el | 203-------------------------------------------------------------------------------
D.config/emacs/modules/editor/format/config.el | 89-------------------------------------------------------------------------------
D.config/emacs/modules/editor/format/packages.el | 4----
D.config/emacs/modules/editor/format/test/test-format.el | 103-------------------------------------------------------------------------------
D.config/emacs/modules/editor/god/README.org | 55-------------------------------------------------------
D.config/emacs/modules/editor/god/autoload.el | 43-------------------------------------------
D.config/emacs/modules/editor/god/config.el | 10----------
D.config/emacs/modules/editor/god/doctor.el | 8--------
D.config/emacs/modules/editor/god/packages.el | 4----
D.config/emacs/modules/editor/lispy/README.org | 85-------------------------------------------------------------------------------
D.config/emacs/modules/editor/lispy/config.el | 52----------------------------------------------------
D.config/emacs/modules/editor/lispy/packages.el | 6------
D.config/emacs/modules/editor/multiple-cursors/README.org | 78------------------------------------------------------------------------------
D.config/emacs/modules/editor/multiple-cursors/autoload/evil-mc.el | 131-------------------------------------------------------------------------------
D.config/emacs/modules/editor/multiple-cursors/config.el | 225-------------------------------------------------------------------------------
D.config/emacs/modules/editor/multiple-cursors/packages.el | 9---------
D.config/emacs/modules/editor/objed/README.org | 60------------------------------------------------------------
D.config/emacs/modules/editor/objed/config.el | 27---------------------------
D.config/emacs/modules/editor/objed/packages.el | 4----
D.config/emacs/modules/editor/parinfer/README.org | 57---------------------------------------------------------
D.config/emacs/modules/editor/parinfer/config.el | 24------------------------
D.config/emacs/modules/editor/parinfer/doctor.el | 7-------
D.config/emacs/modules/editor/parinfer/packages.el | 4----
D.config/emacs/modules/editor/rotate-text/README.org | 77-----------------------------------------------------------------------------
D.config/emacs/modules/editor/rotate-text/autoload.el | 21---------------------
D.config/emacs/modules/editor/rotate-text/packages.el | 7-------
D.config/emacs/modules/editor/snippets/README.org | 66------------------------------------------------------------------
D.config/emacs/modules/editor/snippets/autoload/settings.el | 10----------
D.config/emacs/modules/editor/snippets/autoload/snippets.el | 328-------------------------------------------------------------------------------
D.config/emacs/modules/editor/snippets/config.el | 134-------------------------------------------------------------------------------
D.config/emacs/modules/editor/snippets/packages.el | 10----------
D.config/emacs/modules/editor/word-wrap/README.org | 120-------------------------------------------------------------------------------
D.config/emacs/modules/editor/word-wrap/autoload.el | 107-------------------------------------------------------------------------------
D.config/emacs/modules/editor/word-wrap/config.el | 42------------------------------------------
D.config/emacs/modules/editor/word-wrap/packages.el | 5-----
D.config/emacs/modules/emacs/README.org | 9---------
D.config/emacs/modules/emacs/dired/README.org | 74--------------------------------------------------------------------------
D.config/emacs/modules/emacs/dired/autoload.el | 15---------------
D.config/emacs/modules/emacs/dired/config.el | 247-------------------------------------------------------------------------------
D.config/emacs/modules/emacs/dired/doctor.el | 4----
D.config/emacs/modules/emacs/dired/packages.el | 14--------------
D.config/emacs/modules/emacs/electric/README.org | 54------------------------------------------------------
D.config/emacs/modules/emacs/electric/autoload.el | 26--------------------------
D.config/emacs/modules/emacs/electric/config.el | 18------------------
D.config/emacs/modules/emacs/ibuffer/README.org | 57---------------------------------------------------------
D.config/emacs/modules/emacs/ibuffer/autoload/workspaces.el | 34----------------------------------
D.config/emacs/modules/emacs/ibuffer/config.el | 80-------------------------------------------------------------------------------
D.config/emacs/modules/emacs/ibuffer/packages.el | 5-----
D.config/emacs/modules/emacs/undo/README.org | 84-------------------------------------------------------------------------------
D.config/emacs/modules/emacs/undo/config.el | 102-------------------------------------------------------------------------------
D.config/emacs/modules/emacs/undo/packages.el | 9---------
D.config/emacs/modules/emacs/vc/README.org | 60------------------------------------------------------------
D.config/emacs/modules/emacs/vc/autoload/bug-reference-backport.el | 100-------------------------------------------------------------------------------
D.config/emacs/modules/emacs/vc/autoload/hydra.el | 44--------------------------------------------
D.config/emacs/modules/emacs/vc/autoload/vc.el | 71-----------------------------------------------------------------------
D.config/emacs/modules/emacs/vc/config.el | 146-------------------------------------------------------------------------------
D.config/emacs/modules/emacs/vc/packages.el | 14--------------
D.config/emacs/modules/email/README.org | 9---------
D.config/emacs/modules/email/mu4e/README.org | 316-------------------------------------------------------------------------------
D.config/emacs/modules/email/mu4e/autoload/advice.el | 132-------------------------------------------------------------------------------
D.config/emacs/modules/email/mu4e/autoload/email.el | 389-------------------------------------------------------------------------------
D.config/emacs/modules/email/mu4e/autoload/evil.el | 21---------------------
D.config/emacs/modules/email/mu4e/autoload/mu-lock.el | 96-------------------------------------------------------------------------------
D.config/emacs/modules/email/mu4e/config.el | 753-------------------------------------------------------------------------------
D.config/emacs/modules/email/mu4e/doctor.el | 15---------------
D.config/emacs/modules/email/mu4e/packages.el | 7-------
D.config/emacs/modules/email/notmuch/README.org | 207-------------------------------------------------------------------------------
D.config/emacs/modules/email/notmuch/autoload.el | 164-------------------------------------------------------------------------------
D.config/emacs/modules/email/notmuch/config.el | 129-------------------------------------------------------------------------------
D.config/emacs/modules/email/notmuch/packages.el | 31-------------------------------
D.config/emacs/modules/email/wanderlust/README.org | 54------------------------------------------------------
D.config/emacs/modules/email/wanderlust/autoload.el | 4----
D.config/emacs/modules/email/wanderlust/config.el | 82-------------------------------------------------------------------------------
D.config/emacs/modules/email/wanderlust/packages.el | 11-----------
D.config/emacs/modules/input/README.org | 10----------
D.config/emacs/modules/input/bidi/README.org | 149-------------------------------------------------------------------------------
D.config/emacs/modules/input/bidi/config.el | 93-------------------------------------------------------------------------------
D.config/emacs/modules/input/chinese/README.org | 78------------------------------------------------------------------------------
D.config/emacs/modules/input/chinese/config.el | 88-------------------------------------------------------------------------------
D.config/emacs/modules/input/chinese/packages.el | 15---------------
D.config/emacs/modules/input/japanese/README.org | 55-------------------------------------------------------
D.config/emacs/modules/input/japanese/config.el | 57---------------------------------------------------------
D.config/emacs/modules/input/japanese/doctor.el | 5-----
D.config/emacs/modules/input/japanese/packages.el | 7-------
D.config/emacs/modules/input/layout/+azerty.el | 81-------------------------------------------------------------------------------
D.config/emacs/modules/input/layout/+bepo.el | 295-------------------------------------------------------------------------------
D.config/emacs/modules/input/layout/README.org | 155-------------------------------------------------------------------------------
D.config/emacs/modules/input/layout/autoload/bepo.el | 416-------------------------------------------------------------------------------
D.config/emacs/modules/input/layout/config.el | 8--------
D.config/emacs/modules/lang/README.org | 10----------
D.config/emacs/modules/lang/agda/README.org | 56--------------------------------------------------------
D.config/emacs/modules/lang/agda/config.el | 47-----------------------------------------------
D.config/emacs/modules/lang/agda/doctor.el | 5-----
D.config/emacs/modules/lang/agda/packages.el | 16----------------
D.config/emacs/modules/lang/beancount/README.org | 57---------------------------------------------------------
D.config/emacs/modules/lang/beancount/autoload.el | 180-------------------------------------------------------------------------------
D.config/emacs/modules/lang/beancount/config.el | 37-------------------------------------
D.config/emacs/modules/lang/beancount/packages.el | 7-------
D.config/emacs/modules/lang/cc/README.org | 278-------------------------------------------------------------------------------
D.config/emacs/modules/lang/cc/autoload.el | 330-------------------------------------------------------------------------------
D.config/emacs/modules/lang/cc/config.el | 311-------------------------------------------------------------------------------
D.config/emacs/modules/lang/cc/doctor.el | 28----------------------------
D.config/emacs/modules/lang/cc/packages.el | 34----------------------------------
D.config/emacs/modules/lang/clojure/README.org | 163-------------------------------------------------------------------------------
D.config/emacs/modules/lang/clojure/autoload.el | 44--------------------------------------------
D.config/emacs/modules/lang/clojure/config.el | 289------------------------------------------------------------------------------
D.config/emacs/modules/lang/clojure/doctor.el | 7-------
D.config/emacs/modules/lang/clojure/packages.el | 25-------------------------
D.config/emacs/modules/lang/common-lisp/README.org | 79-------------------------------------------------------------------------------
D.config/emacs/modules/lang/common-lisp/autoload/common-lisp.el | 81-------------------------------------------------------------------------------
D.config/emacs/modules/lang/common-lisp/config.el | 166-------------------------------------------------------------------------------
D.config/emacs/modules/lang/common-lisp/doctor.el | 7-------
D.config/emacs/modules/lang/common-lisp/packages.el | 6------
D.config/emacs/modules/lang/coq/README.org | 53-----------------------------------------------------
D.config/emacs/modules/lang/coq/config.el | 91-------------------------------------------------------------------------------
D.config/emacs/modules/lang/coq/packages.el | 5-----
D.config/emacs/modules/lang/crystal/README.org | 65-----------------------------------------------------------------
D.config/emacs/modules/lang/crystal/config.el | 30------------------------------
D.config/emacs/modules/lang/crystal/doctor.el | 5-----
D.config/emacs/modules/lang/crystal/packages.el | 8--------
D.config/emacs/modules/lang/csharp/README.org | 77-----------------------------------------------------------------------------
D.config/emacs/modules/lang/csharp/autoload.el | 15---------------
D.config/emacs/modules/lang/csharp/config.el | 83-------------------------------------------------------------------------------
D.config/emacs/modules/lang/csharp/doctor.el | 11-----------
D.config/emacs/modules/lang/csharp/packages.el | 15---------------
D.config/emacs/modules/lang/dart/README.org | 138-------------------------------------------------------------------------------
D.config/emacs/modules/lang/dart/config.el | 69---------------------------------------------------------------------
D.config/emacs/modules/lang/dart/doctor.el | 8--------
D.config/emacs/modules/lang/dart/packages.el | 11-----------
D.config/emacs/modules/lang/data/README.org | 49-------------------------------------------------
D.config/emacs/modules/lang/data/config.el | 23-----------------------
D.config/emacs/modules/lang/data/packages.el | 4----
D.config/emacs/modules/lang/dhall/README.org | 53-----------------------------------------------------
D.config/emacs/modules/lang/dhall/config.el | 12------------
D.config/emacs/modules/lang/dhall/packages.el | 4----
D.config/emacs/modules/lang/elixir/README.org | 103-------------------------------------------------------------------------------
D.config/emacs/modules/lang/elixir/config.el | 71-----------------------------------------------------------------------
D.config/emacs/modules/lang/elixir/doctor.el | 6------
D.config/emacs/modules/lang/elixir/packages.el | 8--------
D.config/emacs/modules/lang/elm/README.org | 60------------------------------------------------------------
D.config/emacs/modules/lang/elm/autoload.el | 29-----------------------------
D.config/emacs/modules/lang/elm/config.el | 32--------------------------------
D.config/emacs/modules/lang/elm/doctor.el | 5-----
D.config/emacs/modules/lang/elm/packages.el | 6------
D.config/emacs/modules/lang/emacs-lisp/README.org | 73-------------------------------------------------------------------------
D.config/emacs/modules/lang/emacs-lisp/autoload.el | 620-------------------------------------------------------------------------------
D.config/emacs/modules/lang/emacs-lisp/config.el | 242-------------------------------------------------------------------------------
D.config/emacs/modules/lang/emacs-lisp/packages.el | 19-------------------
D.config/emacs/modules/lang/erlang/README.org | 63---------------------------------------------------------------
D.config/emacs/modules/lang/erlang/config.el | 12------------
D.config/emacs/modules/lang/erlang/doctor.el | 6------
D.config/emacs/modules/lang/erlang/packages.el | 4----
D.config/emacs/modules/lang/ess/README.org | 107-------------------------------------------------------------------------------
D.config/emacs/modules/lang/ess/autoload.el | 15---------------
D.config/emacs/modules/lang/ess/config.el | 109-------------------------------------------------------------------------------
D.config/emacs/modules/lang/ess/packages.el | 15---------------
D.config/emacs/modules/lang/factor/README.org | 57---------------------------------------------------------
D.config/emacs/modules/lang/factor/config.el | 77-----------------------------------------------------------------------------
D.config/emacs/modules/lang/factor/packages.el | 4----
D.config/emacs/modules/lang/faust/README.org | 69---------------------------------------------------------------------
D.config/emacs/modules/lang/faust/autoload.el | 13-------------
D.config/emacs/modules/lang/faust/config.el | 25-------------------------
D.config/emacs/modules/lang/faust/doctor.el | 5-----
D.config/emacs/modules/lang/faust/packages.el | 4----
D.config/emacs/modules/lang/fortran/README.org | 119-------------------------------------------------------------------------------
D.config/emacs/modules/lang/fortran/autoload.el | 117-------------------------------------------------------------------------------
D.config/emacs/modules/lang/fortran/config.el | 85-------------------------------------------------------------------------------
D.config/emacs/modules/lang/fortran/doctor.el | 23-----------------------
D.config/emacs/modules/lang/fsharp/README.org | 70----------------------------------------------------------------------
D.config/emacs/modules/lang/fsharp/config.el | 21---------------------
D.config/emacs/modules/lang/fsharp/doctor.el | 5-----
D.config/emacs/modules/lang/fsharp/packages.el | 4----
D.config/emacs/modules/lang/fstar/README.org | 73-------------------------------------------------------------------------
D.config/emacs/modules/lang/fstar/config.el | 55-------------------------------------------------------
D.config/emacs/modules/lang/fstar/packages.el | 4----
D.config/emacs/modules/lang/gdscript/README.org | 78------------------------------------------------------------------------------
D.config/emacs/modules/lang/gdscript/config.el | 42------------------------------------------
D.config/emacs/modules/lang/gdscript/packages.el | 4----
D.config/emacs/modules/lang/go/README.org | 141-------------------------------------------------------------------------------
D.config/emacs/modules/lang/go/autoload.el | 84-------------------------------------------------------------------------------
D.config/emacs/modules/lang/go/config.el | 82-------------------------------------------------------------------------------
D.config/emacs/modules/lang/go/doctor.el | 32--------------------------------
D.config/emacs/modules/lang/go/packages.el | 15---------------
D.config/emacs/modules/lang/graphql/README.org | 123-------------------------------------------------------------------------------
D.config/emacs/modules/lang/graphql/autoload.el | 14--------------
D.config/emacs/modules/lang/graphql/config.el | 38--------------------------------------
D.config/emacs/modules/lang/graphql/packages.el | 9---------
D.config/emacs/modules/lang/haskell/README.org | 95-------------------------------------------------------------------------------
D.config/emacs/modules/lang/haskell/autoload.el | 29-----------------------------
D.config/emacs/modules/lang/haskell/config.el | 58----------------------------------------------------------
D.config/emacs/modules/lang/haskell/doctor.el | 27---------------------------
D.config/emacs/modules/lang/haskell/packages.el | 8--------
D.config/emacs/modules/lang/hy/README.org | 49-------------------------------------------------
D.config/emacs/modules/lang/hy/config.el | 8--------
D.config/emacs/modules/lang/hy/packages.el | 4----
D.config/emacs/modules/lang/idris/README.org | 54------------------------------------------------------
D.config/emacs/modules/lang/idris/config.el | 20--------------------
D.config/emacs/modules/lang/idris/packages.el | 4----
D.config/emacs/modules/lang/java/+eclim.el | 50--------------------------------------------------
D.config/emacs/modules/lang/java/+lsp.el | 26--------------------------
D.config/emacs/modules/lang/java/+meghanada.el | 38--------------------------------------
D.config/emacs/modules/lang/java/README.org | 170-------------------------------------------------------------------------------
D.config/emacs/modules/lang/java/autoload/java.el | 87-------------------------------------------------------------------------------
D.config/emacs/modules/lang/java/autoload/lsp.el | 22----------------------
D.config/emacs/modules/lang/java/config.el | 54------------------------------------------------------
D.config/emacs/modules/lang/java/doctor.el | 17-----------------
D.config/emacs/modules/lang/java/packages.el | 17-----------------
D.config/emacs/modules/lang/javascript/README.org | 163-------------------------------------------------------------------------------
D.config/emacs/modules/lang/javascript/autoload.el | 129-------------------------------------------------------------------------------
D.config/emacs/modules/lang/javascript/config.el | 329-------------------------------------------------------------------------------
D.config/emacs/modules/lang/javascript/doctor.el | 10----------
D.config/emacs/modules/lang/javascript/packages.el | 19-------------------
D.config/emacs/modules/lang/json/README.org | 56--------------------------------------------------------
D.config/emacs/modules/lang/json/config.el | 35-----------------------------------
D.config/emacs/modules/lang/json/doctor.el | 9---------
D.config/emacs/modules/lang/json/packages.el | 7-------
D.config/emacs/modules/lang/julia/README.org | 130-------------------------------------------------------------------------------
D.config/emacs/modules/lang/julia/autoload.el | 21---------------------
D.config/emacs/modules/lang/julia/config.el | 98-------------------------------------------------------------------------------
D.config/emacs/modules/lang/julia/doctor.el | 23-----------------------
D.config/emacs/modules/lang/julia/packages.el | 10----------
D.config/emacs/modules/lang/kotlin/README.org | 54------------------------------------------------------
D.config/emacs/modules/lang/kotlin/autoload.el | 15---------------
D.config/emacs/modules/lang/kotlin/config.el | 19-------------------
D.config/emacs/modules/lang/kotlin/doctor.el | 8--------
D.config/emacs/modules/lang/kotlin/packages.el | 7-------
D.config/emacs/modules/lang/latex/+fontification.el | 88-------------------------------------------------------------------------------
D.config/emacs/modules/lang/latex/+ref.el | 42------------------------------------------
D.config/emacs/modules/lang/latex/+viewers.el | 67-------------------------------------------------------------------
D.config/emacs/modules/lang/latex/README.org | 155-------------------------------------------------------------------------------
D.config/emacs/modules/lang/latex/autoload.el | 67-------------------------------------------------------------------
D.config/emacs/modules/lang/latex/config.el | 278-------------------------------------------------------------------------------
D.config/emacs/modules/lang/latex/packages.el | 26--------------------------
D.config/emacs/modules/lang/lean/README.org | 54------------------------------------------------------
D.config/emacs/modules/lang/lean/config.el | 36------------------------------------
D.config/emacs/modules/lang/lean/packages.el | 7-------
D.config/emacs/modules/lang/ledger/README.org | 73-------------------------------------------------------------------------
D.config/emacs/modules/lang/ledger/config.el | 88-------------------------------------------------------------------------------
D.config/emacs/modules/lang/ledger/doctor.el | 4----
D.config/emacs/modules/lang/ledger/packages.el | 10----------
D.config/emacs/modules/lang/lua/README.org | 105-------------------------------------------------------------------------------
D.config/emacs/modules/lang/lua/autoload/lua.el | 51---------------------------------------------------
D.config/emacs/modules/lang/lua/autoload/moonscript.el | 16----------------
D.config/emacs/modules/lang/lua/config.el | 96-------------------------------------------------------------------------------
D.config/emacs/modules/lang/lua/packages.el | 17-----------------
D.config/emacs/modules/lang/markdown/README.org | 173-------------------------------------------------------------------------------
D.config/emacs/modules/lang/markdown/autoload.el | 107-------------------------------------------------------------------------------
D.config/emacs/modules/lang/markdown/config.el | 150-------------------------------------------------------------------------------
D.config/emacs/modules/lang/markdown/doctor.el | 22----------------------
D.config/emacs/modules/lang/markdown/packages.el | 14--------------
D.config/emacs/modules/lang/nim/README.org | 73-------------------------------------------------------------------------
D.config/emacs/modules/lang/nim/config.el | 39---------------------------------------
D.config/emacs/modules/lang/nim/doctor.el | 9---------
D.config/emacs/modules/lang/nim/packages.el | 9---------
D.config/emacs/modules/lang/nix/README.org | 81-------------------------------------------------------------------------------
D.config/emacs/modules/lang/nix/autoload.el | 80-------------------------------------------------------------------------------
D.config/emacs/modules/lang/nix/config.el | 53-----------------------------------------------------
D.config/emacs/modules/lang/nix/doctor.el | 12------------
D.config/emacs/modules/lang/nix/packages.el | 11-----------
D.config/emacs/modules/lang/ocaml/README.org | 114-------------------------------------------------------------------------------
D.config/emacs/modules/lang/ocaml/autoload.el | 11-----------
D.config/emacs/modules/lang/ocaml/config.el | 125-------------------------------------------------------------------------------
D.config/emacs/modules/lang/ocaml/doctor.el | 28----------------------------
D.config/emacs/modules/lang/ocaml/packages.el | 25-------------------------
D.config/emacs/modules/lang/org/README.org | 307-------------------------------------------------------------------------------
D.config/emacs/modules/lang/org/autoload/contrib-ipython.el | 152-------------------------------------------------------------------------------
D.config/emacs/modules/lang/org/autoload/contrib-present.el | 87-------------------------------------------------------------------------------
D.config/emacs/modules/lang/org/autoload/contrib-roam2.el | 131-------------------------------------------------------------------------------
D.config/emacs/modules/lang/org/autoload/org-attach.el | 59-----------------------------------------------------------
D.config/emacs/modules/lang/org/autoload/org-avy.el | 20--------------------
D.config/emacs/modules/lang/org/autoload/org-babel.el | 91-------------------------------------------------------------------------------
D.config/emacs/modules/lang/org/autoload/org-capture.el | 163-------------------------------------------------------------------------------
D.config/emacs/modules/lang/org/autoload/org-export.el | 53-----------------------------------------------------
D.config/emacs/modules/lang/org/autoload/org-link.el | 456-------------------------------------------------------------------------------
D.config/emacs/modules/lang/org/autoload/org-refile.el | 101-------------------------------------------------------------------------------
D.config/emacs/modules/lang/org/autoload/org-tables.el | 96-------------------------------------------------------------------------------
D.config/emacs/modules/lang/org/autoload/org.el | 520-------------------------------------------------------------------------------
D.config/emacs/modules/lang/org/config.el | 1459-------------------------------------------------------------------------------
D.config/emacs/modules/lang/org/contrib/brain.el | 42------------------------------------------
D.config/emacs/modules/lang/org/contrib/dragndrop.el | 88-------------------------------------------------------------------------------
D.config/emacs/modules/lang/org/contrib/ipython.el | 41-----------------------------------------
D.config/emacs/modules/lang/org/contrib/journal.el | 72------------------------------------------------------------------------
D.config/emacs/modules/lang/org/contrib/jupyter.el | 40----------------------------------------
D.config/emacs/modules/lang/org/contrib/noter.el | 14--------------
D.config/emacs/modules/lang/org/contrib/pomodoro.el | 17-----------------
D.config/emacs/modules/lang/org/contrib/present.el | 68--------------------------------------------------------------------
D.config/emacs/modules/lang/org/contrib/pretty.el | 28----------------------------
D.config/emacs/modules/lang/org/contrib/roam.el | 96-------------------------------------------------------------------------------
D.config/emacs/modules/lang/org/contrib/roam2.el | 207-------------------------------------------------------------------------------
D.config/emacs/modules/lang/org/doctor.el | 32--------------------------------
D.config/emacs/modules/lang/org/packages.el | 167-------------------------------------------------------------------------------
D.config/emacs/modules/lang/org/test/test-org.el | 133-------------------------------------------------------------------------------
D.config/emacs/modules/lang/php/README.org | 256-------------------------------------------------------------------------------
D.config/emacs/modules/lang/php/autoload.el | 26--------------------------
D.config/emacs/modules/lang/php/config.el | 181-------------------------------------------------------------------------------
D.config/emacs/modules/lang/php/doctor.el | 10----------
D.config/emacs/modules/lang/php/packages.el | 27---------------------------
D.config/emacs/modules/lang/plantuml/README.org | 51---------------------------------------------------
D.config/emacs/modules/lang/plantuml/autoload.el | 63---------------------------------------------------------------
D.config/emacs/modules/lang/plantuml/config.el | 29-----------------------------
D.config/emacs/modules/lang/plantuml/doctor.el | 13-------------
D.config/emacs/modules/lang/plantuml/packages.el | 8--------
D.config/emacs/modules/lang/purescript/README.org | 55-------------------------------------------------------
D.config/emacs/modules/lang/purescript/config.el | 38--------------------------------------
D.config/emacs/modules/lang/purescript/packages.el | 6------
D.config/emacs/modules/lang/python/README.org | 155-------------------------------------------------------------------------------
D.config/emacs/modules/lang/python/autoload/compat-28.1.el | 94-------------------------------------------------------------------------------
D.config/emacs/modules/lang/python/autoload/conda.el | 17-----------------
D.config/emacs/modules/lang/python/autoload/pyenv.el | 30------------------------------
D.config/emacs/modules/lang/python/autoload/python.el | 74--------------------------------------------------------------------------
D.config/emacs/modules/lang/python/config.el | 350-------------------------------------------------------------------------------
D.config/emacs/modules/lang/python/doctor.el | 57---------------------------------------------------------
D.config/emacs/modules/lang/python/packages.el | 39---------------------------------------
D.config/emacs/modules/lang/qt/README.org | 53-----------------------------------------------------
D.config/emacs/modules/lang/qt/autoload.el | 4----
D.config/emacs/modules/lang/qt/packages.el | 5-----
D.config/emacs/modules/lang/racket/README.org | 88-------------------------------------------------------------------------------
D.config/emacs/modules/lang/racket/autoload.el | 30------------------------------
D.config/emacs/modules/lang/racket/config.el | 93-------------------------------------------------------------------------------
D.config/emacs/modules/lang/racket/doctor.el | 11-----------
D.config/emacs/modules/lang/racket/packages.el | 4----
D.config/emacs/modules/lang/raku/README.org | 50--------------------------------------------------
D.config/emacs/modules/lang/raku/config.el | 13-------------
D.config/emacs/modules/lang/raku/packages.el | 9---------
D.config/emacs/modules/lang/rest/README.org | 71-----------------------------------------------------------------------
D.config/emacs/modules/lang/rest/autoload.el | 28----------------------------
D.config/emacs/modules/lang/rest/config.el | 46----------------------------------------------
D.config/emacs/modules/lang/rest/packages.el | 10----------
D.config/emacs/modules/lang/rst/README.org | 49-------------------------------------------------
D.config/emacs/modules/lang/rst/config.el | 18------------------
D.config/emacs/modules/lang/rst/packages.el | 4----
D.config/emacs/modules/lang/ruby/README.org | 121-------------------------------------------------------------------------------
D.config/emacs/modules/lang/ruby/autoload.el | 15---------------
D.config/emacs/modules/lang/ruby/config.el | 200-------------------------------------------------------------------------------
D.config/emacs/modules/lang/ruby/doctor.el | 20--------------------
D.config/emacs/modules/lang/ruby/packages.el | 36------------------------------------
D.config/emacs/modules/lang/rust/README.org | 121-------------------------------------------------------------------------------
D.config/emacs/modules/lang/rust/autoload.el | 19-------------------
D.config/emacs/modules/lang/rust/config.el | 78------------------------------------------------------------------------------
D.config/emacs/modules/lang/rust/doctor.el | 33---------------------------------
D.config/emacs/modules/lang/rust/packages.el | 4----
D.config/emacs/modules/lang/scala/README.org | 123-------------------------------------------------------------------------------
D.config/emacs/modules/lang/scala/autoload.el | 54------------------------------------------------------
D.config/emacs/modules/lang/scala/config.el | 55-------------------------------------------------------
D.config/emacs/modules/lang/scala/doctor.el | 13-------------
D.config/emacs/modules/lang/scala/packages.el | 8--------
D.config/emacs/modules/lang/scheme/README.org | 81-------------------------------------------------------------------------------
D.config/emacs/modules/lang/scheme/autoload.el | 73-------------------------------------------------------------------------
D.config/emacs/modules/lang/scheme/config.el | 85-------------------------------------------------------------------------------
D.config/emacs/modules/lang/scheme/packages.el | 32--------------------------------
D.config/emacs/modules/lang/sh/README.org | 72------------------------------------------------------------------------
D.config/emacs/modules/lang/sh/autoload.el | 53-----------------------------------------------------
D.config/emacs/modules/lang/sh/config.el | 98-------------------------------------------------------------------------------
D.config/emacs/modules/lang/sh/doctor.el | 13-------------
D.config/emacs/modules/lang/sh/packages.el | 11-----------
D.config/emacs/modules/lang/sml/README.org | 50--------------------------------------------------
D.config/emacs/modules/lang/sml/config.el | 29-----------------------------
D.config/emacs/modules/lang/sml/packages.el | 8--------
D.config/emacs/modules/lang/solidity/README.org | 77-----------------------------------------------------------------------------
D.config/emacs/modules/lang/solidity/config.el | 22----------------------
D.config/emacs/modules/lang/solidity/doctor.el | 8--------
D.config/emacs/modules/lang/solidity/packages.el | 8--------
D.config/emacs/modules/lang/swift/README.org | 61-------------------------------------------------------------
D.config/emacs/modules/lang/swift/config.el | 36------------------------------------
D.config/emacs/modules/lang/swift/doctor.el | 5-----
D.config/emacs/modules/lang/swift/packages.el | 11-----------
D.config/emacs/modules/lang/terra/README.org | 52----------------------------------------------------
D.config/emacs/modules/lang/terra/autoload.el | 8--------
D.config/emacs/modules/lang/terra/config.el | 11-----------
D.config/emacs/modules/lang/terra/packages.el | 9---------
D.config/emacs/modules/lang/web/+css.el | 82-------------------------------------------------------------------------------
D.config/emacs/modules/lang/web/+html.el | 174-------------------------------------------------------------------------------
D.config/emacs/modules/lang/web/README.org | 74--------------------------------------------------------------------------
D.config/emacs/modules/lang/web/autoload/css.el | 105-------------------------------------------------------------------------------
D.config/emacs/modules/lang/web/autoload/evil.el | 26--------------------------
D.config/emacs/modules/lang/web/autoload/html.el | 135-------------------------------------------------------------------------------
D.config/emacs/modules/lang/web/config.el | 57---------------------------------------------------------
D.config/emacs/modules/lang/web/doctor.el | 18------------------
D.config/emacs/modules/lang/web/packages.el | 24------------------------
D.config/emacs/modules/lang/web/test/test-web.el | 92-------------------------------------------------------------------------------
D.config/emacs/modules/lang/yaml/README.org | 54------------------------------------------------------
D.config/emacs/modules/lang/yaml/config.el | 11-----------
D.config/emacs/modules/lang/yaml/packages.el | 4----
D.config/emacs/modules/lang/zig/README.org | 87-------------------------------------------------------------------------------
D.config/emacs/modules/lang/zig/config.el | 35-----------------------------------
D.config/emacs/modules/lang/zig/doctor.el | 17-----------------
D.config/emacs/modules/lang/zig/packages.el | 4----
D.config/emacs/modules/os/README.org | 10----------
D.config/emacs/modules/os/macos/README.org | 66------------------------------------------------------------------
D.config/emacs/modules/os/macos/autoload.el | 73-------------------------------------------------------------------------
D.config/emacs/modules/os/macos/config.el | 53-----------------------------------------------------
D.config/emacs/modules/os/macos/packages.el | 5-----
D.config/emacs/modules/os/tty/README.org | 80-------------------------------------------------------------------------------
D.config/emacs/modules/os/tty/config.el | 44--------------------------------------------
D.config/emacs/modules/os/tty/packages.el | 13-------------
D.config/emacs/modules/source.el | 7-------
D.config/emacs/modules/term/README.org | 15---------------
D.config/emacs/modules/term/eshell/README.org | 75---------------------------------------------------------------------------
D.config/emacs/modules/term/eshell/autoload/backport.el | 145-------------------------------------------------------------------------------
D.config/emacs/modules/term/eshell/autoload/commands.el | 30------------------------------
D.config/emacs/modules/term/eshell/autoload/company.el | 60------------------------------------------------------------
D.config/emacs/modules/term/eshell/autoload/eshell.el | 324-------------------------------------------------------------------------------
D.config/emacs/modules/term/eshell/autoload/evil.el | 34----------------------------------
D.config/emacs/modules/term/eshell/autoload/prompts.el | 39---------------------------------------
D.config/emacs/modules/term/eshell/autoload/settings.el | 26--------------------------
D.config/emacs/modules/term/eshell/config.el | 205-------------------------------------------------------------------------------
D.config/emacs/modules/term/eshell/packages.el | 13-------------
D.config/emacs/modules/term/shell/README.org | 60------------------------------------------------------------
D.config/emacs/modules/term/shell/autoload.el | 105-------------------------------------------------------------------------------
D.config/emacs/modules/term/shell/config.el | 5-----
D.config/emacs/modules/term/shell/packages.el | 4----
D.config/emacs/modules/term/term/README.org | 49-------------------------------------------------
D.config/emacs/modules/term/term/autoload.el | 47-----------------------------------------------
D.config/emacs/modules/term/term/config.el | 15---------------
D.config/emacs/modules/term/term/packages.el | 5-----
D.config/emacs/modules/term/vterm/README.org | 166-------------------------------------------------------------------------------
D.config/emacs/modules/term/vterm/autoload.el | 76----------------------------------------------------------------------------
D.config/emacs/modules/term/vterm/config.el | 31-------------------------------
D.config/emacs/modules/term/vterm/doctor.el | 10----------
D.config/emacs/modules/term/vterm/packages.el | 6------
D.config/emacs/modules/tools/README.org | 9---------
D.config/emacs/modules/tools/ansible/README.org | 53-----------------------------------------------------
D.config/emacs/modules/tools/ansible/config.el | 35-----------------------------------
D.config/emacs/modules/tools/ansible/doctor.el | 5-----
D.config/emacs/modules/tools/ansible/packages.el | 10----------
D.config/emacs/modules/tools/biblio/README.org | 141-------------------------------------------------------------------------------
D.config/emacs/modules/tools/biblio/config.el | 61-------------------------------------------------------------
D.config/emacs/modules/tools/biblio/packages.el | 17-----------------
D.config/emacs/modules/tools/debugger/README.org | 217-------------------------------------------------------------------------------
D.config/emacs/modules/tools/debugger/autoload/debugger.el | 134-------------------------------------------------------------------------------
D.config/emacs/modules/tools/debugger/autoload/evil.el | 34----------------------------------
D.config/emacs/modules/tools/debugger/config.el | 160-------------------------------------------------------------------------------
D.config/emacs/modules/tools/debugger/doctor.el | 4----
D.config/emacs/modules/tools/debugger/packages.el | 10----------
D.config/emacs/modules/tools/direnv/README.org | 96-------------------------------------------------------------------------------
D.config/emacs/modules/tools/direnv/config.el | 41-----------------------------------------
D.config/emacs/modules/tools/direnv/doctor.el | 4----
D.config/emacs/modules/tools/direnv/packages.el | 4----
D.config/emacs/modules/tools/docker/README.org | 148-------------------------------------------------------------------------------
D.config/emacs/modules/tools/docker/config.el | 7-------
D.config/emacs/modules/tools/docker/packages.el | 8--------
D.config/emacs/modules/tools/editorconfig/README.org | 87-------------------------------------------------------------------------------
D.config/emacs/modules/tools/editorconfig/autoload.el | 7-------
D.config/emacs/modules/tools/editorconfig/config.el | 53-----------------------------------------------------
D.config/emacs/modules/tools/editorconfig/doctor.el | 5-----
D.config/emacs/modules/tools/editorconfig/packages.el | 6------
D.config/emacs/modules/tools/ein/README.org | 53-----------------------------------------------------
D.config/emacs/modules/tools/ein/config.el | 16----------------
D.config/emacs/modules/tools/ein/packages.el | 4----
D.config/emacs/modules/tools/ein/test/test-ein.el | 23-----------------------
D.config/emacs/modules/tools/eval/README.org | 134-------------------------------------------------------------------------------
D.config/emacs/modules/tools/eval/autoload/eval.el | 172-------------------------------------------------------------------------------
D.config/emacs/modules/tools/eval/autoload/evil.el | 23-----------------------
D.config/emacs/modules/tools/eval/autoload/repl.el | 181-------------------------------------------------------------------------------
D.config/emacs/modules/tools/eval/autoload/settings.el | 76----------------------------------------------------------------------------
D.config/emacs/modules/tools/eval/config.el | 101-------------------------------------------------------------------------------
D.config/emacs/modules/tools/eval/packages.el | 6------
D.config/emacs/modules/tools/gist/README.org | 55-------------------------------------------------------
D.config/emacs/modules/tools/gist/autoload/evil.el | 19-------------------
D.config/emacs/modules/tools/gist/config.el | 31-------------------------------
D.config/emacs/modules/tools/gist/packages.el | 4----
D.config/emacs/modules/tools/lookup/README.org | 254-------------------------------------------------------------------------------
D.config/emacs/modules/tools/lookup/autoload/docsets.el | 132-------------------------------------------------------------------------------
D.config/emacs/modules/tools/lookup/autoload/evil.el | 22----------------------
D.config/emacs/modules/tools/lookup/autoload/lookup.el | 441-------------------------------------------------------------------------------
D.config/emacs/modules/tools/lookup/autoload/online.el | 95-------------------------------------------------------------------------------
D.config/emacs/modules/tools/lookup/autoload/xwidget.el | 19-------------------
D.config/emacs/modules/tools/lookup/config.el | 228-------------------------------------------------------------------------------
D.config/emacs/modules/tools/lookup/doctor.el | 5-----
D.config/emacs/modules/tools/lookup/packages.el | 34----------------------------------
D.config/emacs/modules/tools/lsp/+eglot.el | 58----------------------------------------------------------
D.config/emacs/modules/tools/lsp/+lsp.el | 192-------------------------------------------------------------------------------
D.config/emacs/modules/tools/lsp/README.org | 155-------------------------------------------------------------------------------
D.config/emacs/modules/tools/lsp/autoload/common.el | 10----------
D.config/emacs/modules/tools/lsp/autoload/eglot.el | 39---------------------------------------
D.config/emacs/modules/tools/lsp/autoload/lsp-mode.el | 75---------------------------------------------------------------------------
D.config/emacs/modules/tools/lsp/config.el | 47-----------------------------------------------
D.config/emacs/modules/tools/lsp/doctor.el | 9---------
D.config/emacs/modules/tools/lsp/packages.el | 18------------------
D.config/emacs/modules/tools/magit/README.org | 99-------------------------------------------------------------------------------
D.config/emacs/modules/tools/magit/autoload.el | 161-------------------------------------------------------------------------------
D.config/emacs/modules/tools/magit/config.el | 293-------------------------------------------------------------------------------
D.config/emacs/modules/tools/magit/packages.el | 14--------------
D.config/emacs/modules/tools/make/README.org | 53-----------------------------------------------------
D.config/emacs/modules/tools/make/autoload.el | 25-------------------------
D.config/emacs/modules/tools/make/packages.el | 4----
D.config/emacs/modules/tools/pass/README.org | 64----------------------------------------------------------------
D.config/emacs/modules/tools/pass/autoload/consult.el | 21---------------------
D.config/emacs/modules/tools/pass/autoload/ivy.el | 21---------------------
D.config/emacs/modules/tools/pass/autoload/pass.el | 67-------------------------------------------------------------------
D.config/emacs/modules/tools/pass/config.el | 33---------------------------------
D.config/emacs/modules/tools/pass/packages.el | 11-----------
D.config/emacs/modules/tools/pass/test/test-pass.el | 41-----------------------------------------
D.config/emacs/modules/tools/pdf/README.org | 119-------------------------------------------------------------------------------
D.config/emacs/modules/tools/pdf/config.el | 96-------------------------------------------------------------------------------
D.config/emacs/modules/tools/pdf/packages.el | 5-----
D.config/emacs/modules/tools/prodigy/README.org | 50--------------------------------------------------
D.config/emacs/modules/tools/prodigy/autoload.el | 34----------------------------------
D.config/emacs/modules/tools/prodigy/config.el | 19-------------------
D.config/emacs/modules/tools/prodigy/packages.el | 4----
D.config/emacs/modules/tools/rgb/README.org | 61-------------------------------------------------------------
D.config/emacs/modules/tools/rgb/autoload.el | 14--------------
D.config/emacs/modules/tools/rgb/packages.el | 5-----
D.config/emacs/modules/tools/taskrunner/README.org | 61-------------------------------------------------------------
D.config/emacs/modules/tools/taskrunner/autoload.el | 9---------
D.config/emacs/modules/tools/taskrunner/config.el | 14--------------
D.config/emacs/modules/tools/taskrunner/packages.el | 14--------------
D.config/emacs/modules/tools/terraform/README.org | 79-------------------------------------------------------------------------------
D.config/emacs/modules/tools/terraform/config.el | 24------------------------
D.config/emacs/modules/tools/terraform/doctor.el | 4----
D.config/emacs/modules/tools/terraform/packages.el | 6------
D.config/emacs/modules/tools/tmux/README.org | 49-------------------------------------------------
D.config/emacs/modules/tools/tmux/autoload/evil.el | 17-----------------
D.config/emacs/modules/tools/tmux/autoload/tmux.el | 146-------------------------------------------------------------------------------
D.config/emacs/modules/tools/tree-sitter/README.org | 163-------------------------------------------------------------------------------
D.config/emacs/modules/tools/tree-sitter/autoload.el | 41-----------------------------------------
D.config/emacs/modules/tools/tree-sitter/config.el | 77-----------------------------------------------------------------------------
D.config/emacs/modules/tools/tree-sitter/doctor.el | 4----
D.config/emacs/modules/tools/tree-sitter/packages.el | 10----------
D.config/emacs/modules/tools/upload/README.org | 79-------------------------------------------------------------------------------
D.config/emacs/modules/tools/upload/config.el | 52----------------------------------------------------
D.config/emacs/modules/tools/upload/packages.el | 4----
D.config/emacs/modules/ui/README.org | 10----------
D.config/emacs/modules/ui/deft/README.org | 75---------------------------------------------------------------------------
D.config/emacs/modules/ui/deft/config.el | 46----------------------------------------------
D.config/emacs/modules/ui/deft/packages.el | 4----
D.config/emacs/modules/ui/doom-dashboard/README.org | 117-------------------------------------------------------------------------------
D.config/emacs/modules/ui/doom-dashboard/autoload.el | 28----------------------------
D.config/emacs/modules/ui/doom-dashboard/config.el | 526-------------------------------------------------------------------------------
D.config/emacs/modules/ui/doom-dashboard/test/test-doom-dashboard.el | 40----------------------------------------
D.config/emacs/modules/ui/doom-quit/README.org | 68--------------------------------------------------------------------
D.config/emacs/modules/ui/doom-quit/config.el | 40----------------------------------------
D.config/emacs/modules/ui/doom/README.org | 115-------------------------------------------------------------------------------
D.config/emacs/modules/ui/doom/config.el | 24------------------------
D.config/emacs/modules/ui/doom/packages.el | 5-----
D.config/emacs/modules/ui/emoji/README.org | 67-------------------------------------------------------------------
D.config/emacs/modules/ui/emoji/config.el | 12------------
D.config/emacs/modules/ui/emoji/packages.el | 4----
D.config/emacs/modules/ui/hl-todo/README.org | 87-------------------------------------------------------------------------------
D.config/emacs/modules/ui/hl-todo/config.el | 51---------------------------------------------------
D.config/emacs/modules/ui/hl-todo/packages.el | 4----
D.config/emacs/modules/ui/hydra/README.org | 62--------------------------------------------------------------
D.config/emacs/modules/ui/hydra/autoload/windows.el | 49-------------------------------------------------
D.config/emacs/modules/ui/hydra/config.el | 15---------------
D.config/emacs/modules/ui/hydra/packages.el | 4----
D.config/emacs/modules/ui/indent-guides/README.org | 49-------------------------------------------------
D.config/emacs/modules/ui/indent-guides/config.el | 20--------------------
D.config/emacs/modules/ui/indent-guides/packages.el | 4----
D.config/emacs/modules/ui/ligatures/+fira.el | 123-------------------------------------------------------------------------------
D.config/emacs/modules/ui/ligatures/+hasklig.el | 62--------------------------------------------------------------
D.config/emacs/modules/ui/ligatures/+iosevka.el | 244-------------------------------------------------------------------------------
D.config/emacs/modules/ui/ligatures/+pragmata-pro.el | 259-------------------------------------------------------------------------------
D.config/emacs/modules/ui/ligatures/README.org | 238-------------------------------------------------------------------------------
D.config/emacs/modules/ui/ligatures/autoload/install.el | 58----------------------------------------------------------
D.config/emacs/modules/ui/ligatures/autoload/ligatures.el | 50--------------------------------------------------
D.config/emacs/modules/ui/ligatures/config.el | 220-------------------------------------------------------------------------------
D.config/emacs/modules/ui/minimap/README.org | 59-----------------------------------------------------------
D.config/emacs/modules/ui/minimap/config.el | 10----------
D.config/emacs/modules/ui/minimap/packages.el | 4----
D.config/emacs/modules/ui/modeline/+light.el | 613-------------------------------------------------------------------------------
D.config/emacs/modules/ui/modeline/README.org | 200-------------------------------------------------------------------------------
D.config/emacs/modules/ui/modeline/autoload.el | 36------------------------------------
D.config/emacs/modules/ui/modeline/config.el | 85-------------------------------------------------------------------------------
D.config/emacs/modules/ui/modeline/packages.el | 8--------
D.config/emacs/modules/ui/nav-flash/README.org | 63---------------------------------------------------------------
D.config/emacs/modules/ui/nav-flash/autoload.el | 48------------------------------------------------
D.config/emacs/modules/ui/nav-flash/config.el | 43-------------------------------------------
D.config/emacs/modules/ui/nav-flash/packages.el | 4----
D.config/emacs/modules/ui/neotree/README.org | 57---------------------------------------------------------
D.config/emacs/modules/ui/neotree/autoload.el | 70----------------------------------------------------------------------
D.config/emacs/modules/ui/neotree/config.el | 73-------------------------------------------------------------------------
D.config/emacs/modules/ui/neotree/packages.el | 4----
D.config/emacs/modules/ui/ophints/README.org | 56--------------------------------------------------------
D.config/emacs/modules/ui/ophints/config.el | 73-------------------------------------------------------------------------
D.config/emacs/modules/ui/ophints/packages.el | 6------
D.config/emacs/modules/ui/popup/+hacks.el | 411-------------------------------------------------------------------------------
D.config/emacs/modules/ui/popup/README.org | 160-------------------------------------------------------------------------------
D.config/emacs/modules/ui/popup/autoload/popup.el | 614-------------------------------------------------------------------------------
D.config/emacs/modules/ui/popup/autoload/settings.el | 190-------------------------------------------------------------------------------
D.config/emacs/modules/ui/popup/config.el | 181-------------------------------------------------------------------------------
D.config/emacs/modules/ui/popup/test/test-popup.el | 212-------------------------------------------------------------------------------
D.config/emacs/modules/ui/tabs/README.org | 49-------------------------------------------------
D.config/emacs/modules/ui/tabs/autoload.el | 18------------------
D.config/emacs/modules/ui/tabs/config.el | 26--------------------------
D.config/emacs/modules/ui/tabs/packages.el | 4----
D.config/emacs/modules/ui/treemacs/README.org | 87-------------------------------------------------------------------------------
D.config/emacs/modules/ui/treemacs/autoload.el | 17-----------------
D.config/emacs/modules/ui/treemacs/config.el | 78------------------------------------------------------------------------------
D.config/emacs/modules/ui/treemacs/doctor.el | 5-----
D.config/emacs/modules/ui/treemacs/packages.el | 14--------------
D.config/emacs/modules/ui/unicode/README.org | 119-------------------------------------------------------------------------------
D.config/emacs/modules/ui/unicode/autoload.el | 25-------------------------
D.config/emacs/modules/ui/unicode/packages.el | 4----
D.config/emacs/modules/ui/vc-gutter/README.org | 84-------------------------------------------------------------------------------
D.config/emacs/modules/ui/vc-gutter/autoload/diff-hl.el | 11-----------
D.config/emacs/modules/ui/vc-gutter/autoload/git-gutter.el | 11-----------
D.config/emacs/modules/ui/vc-gutter/config.el | 220-------------------------------------------------------------------------------
D.config/emacs/modules/ui/vc-gutter/packages.el | 6------
D.config/emacs/modules/ui/vi-tilde-fringe/README.org | 60------------------------------------------------------------
D.config/emacs/modules/ui/vi-tilde-fringe/autoload.el | 5-----
D.config/emacs/modules/ui/vi-tilde-fringe/packages.el | 4----
D.config/emacs/modules/ui/window-select/README.org | 90-------------------------------------------------------------------------------
D.config/emacs/modules/ui/window-select/config.el | 42------------------------------------------
D.config/emacs/modules/ui/window-select/packages.el | 9---------
D.config/emacs/modules/ui/workspaces/README.org | 125-------------------------------------------------------------------------------
D.config/emacs/modules/ui/workspaces/autoload/evil.el | 39---------------------------------------
D.config/emacs/modules/ui/workspaces/autoload/ivy.el | 17-----------------
D.config/emacs/modules/ui/workspaces/autoload/workspaces.el | 612-------------------------------------------------------------------------------
D.config/emacs/modules/ui/workspaces/config.el | 295-------------------------------------------------------------------------------
D.config/emacs/modules/ui/workspaces/packages.el | 4----
D.config/emacs/modules/ui/workspaces/test/test-workspaces.el | 124-------------------------------------------------------------------------------
D.config/emacs/modules/ui/zen/README.org | 81-------------------------------------------------------------------------------
D.config/emacs/modules/ui/zen/autoload.el | 29-----------------------------
D.config/emacs/modules/ui/zen/config.el | 76----------------------------------------------------------------------------
D.config/emacs/modules/ui/zen/packages.el | 5-----
D.config/emacs/profiles/README.org | 154-------------------------------------------------------------------------------
D.config/emacs/profiles/load.28.elc | 0
D.config/emacs/profiles/load.el | 15---------------
D.config/emacs/profiles/safe-mode/init.el | 1-
D.config/emacs/shell.nix | 101-------------------------------------------------------------------------------
D.config/emacs/templates/BUG_REPORT | 29-----------------------------
D.config/emacs/templates/QUICKSTART_INTRO | 19-------------------
D.config/emacs/templates/VANILLA_SANDBOX | 12------------
D.config/emacs/templates/config.example.el | 76----------------------------------------------------------------------------
D.config/emacs/templates/init.example.el | 194-------------------------------------------------------------------------------
D.config/emacs/templates/packages.example.el | 50--------------------------------------------------
908 files changed, 0 insertions(+), 85558 deletions(-)

diff --git a/.config/emacs/.dir-locals.el b/.config/emacs/.dir-locals.el @@ -1,3 +0,0 @@ -((nil (git-commit-major-mode . git-commit-elisp-text-mode) - (fill-column . 80)) - (org-mode (mode . doom-docs-org))) diff --git a/.config/emacs/.doomrc b/.config/emacs/.doomrc @@ -1,51 +0,0 @@ -;;; .doomrc --- doom runtime config -*- mode: emacs-lisp; lexical-binding: t; -*- -;;; Commentary: -;;; Code: -(require 'doom) ; be silent, byte-compiler - -(after! doom-cli-ci - ;;; Commit linter types - (add-to-list 'doom-ci-commit-types 'module) - (add-to-list 'doom-ci-commit-scopeless-types 'module) - - ;;; Commit linter scopes - (add-to-list 'doom-ci-commit-scopes "cli") - (add-to-list 'doom-ci-commit-scopes "lib") - (add-to-list 'doom-ci-commit-scopes "docs") - (add-to-list 'doom-ci-commit-scopes '(docs "install" ci-check-docs-scope)) - (add-to-list 'doom-ci-commit-scopes #'ci-check-module-scope) - ;; DEPRECATED Will be removed once modules live in their own repo - (add-to-list 'doom-ci-commit-scopes '(release "modules"))) - -(after! doom-cli-make - ;;; Codeowners - (dolist (path (doom-module-load-path (list doom-modules-dir))) - ;; I will be the default owner for everything in the repo unless a later - ;; match takes precedence. - (add-to-list 'doom-make-codeowners "# The default owner(s) unless another takes precedence") - (add-to-list 'doom-make-codeowners '("*" . "@doomemacs/maintainers")) - ;; Module maintainers (see https://git.doomemacs.org/teams) - (save-match-data - (add-to-list 'doom-make-codeowners "# Module maintainers") - (when (string-match "/modules/\\([^/]+\\)/\\([^/]+\\)/$" path) - (push (cons (substring (match-string 0 path) 1) - (format "@doomemacs/%s-%s" - (match-string 1 path) - (match-string 2 path))) - doom-make-codeowners))))) - -;;; Helpers -(defun ci-check-module-scope (scope _plist) - "Only allow :CATEGORY or MODULE scopes if they actually exist." - (doom-glob (dir!) "modules" (if (string-prefix-p ":" scope) - (format "%s" (substring scope 1)) - (format "*/%s" scope)))) - -(defun ci-check-docs-scope (scope _plist) - "Allow any filename in docs/* as a scope for docs commits." - (member - scope (doom-files-in (doom-path (dir!) "../docs") - :match "\\.org$" - :map #'file-name-base))) - -;;; .doomrc ends here diff --git a/.config/emacs/.github/CODEOWNERS b/.config/emacs/.github/CODEOWNERS @@ -1,164 +0,0 @@ -# -*- mode: conf -*- -# Each line is a file pattern followed by one or more owners. -# This file was generated by 'doom make codeowners', do not edit it by hand. - -# The default owner(s) unless another takes precedence -* @doomemacs/maintainers - -# Module maintainers -modules/app/calendar/ @doomemacs/app-calendar -modules/app/emms/ @doomemacs/app-emms -modules/app/everywhere/ @doomemacs/app-everywhere -modules/app/irc/ @doomemacs/app-irc -modules/app/rss/ @doomemacs/app-rss -modules/app/twitter/ @doomemacs/app-twitter -modules/checkers/grammar/ @doomemacs/checkers-grammar -modules/checkers/spell/ @doomemacs/checkers-spell -modules/checkers/syntax/ @doomemacs/checkers-syntax -modules/completion/company/ @doomemacs/completion-company -modules/completion/helm/ @doomemacs/completion-helm -modules/completion/ido/ @doomemacs/completion-ido -modules/completion/ivy/ @doomemacs/completion-ivy -modules/completion/vertico/ @doomemacs/completion-vertico -modules/config/default/ @doomemacs/config-default -modules/config/literate/ @doomemacs/config-literate -modules/editor/evil/ @doomemacs/editor-evil -modules/editor/file-templates/ @doomemacs/editor-file-templates -modules/editor/fold/ @doomemacs/editor-fold -modules/editor/format/ @doomemacs/editor-format -modules/editor/god/ @doomemacs/editor-god -modules/editor/lispy/ @doomemacs/editor-lispy -modules/editor/multiple-cursors/ @doomemacs/editor-multiple-cursors -modules/editor/objed/ @doomemacs/editor-objed -modules/editor/parinfer/ @doomemacs/editor-parinfer -modules/editor/rotate-text/ @doomemacs/editor-rotate-text -modules/editor/snippets/ @doomemacs/editor-snippets -modules/editor/word-wrap/ @doomemacs/editor-word-wrap -modules/emacs/dired/ @doomemacs/emacs-dired -modules/emacs/electric/ @doomemacs/emacs-electric -modules/emacs/ibuffer/ @doomemacs/emacs-ibuffer -modules/emacs/tramp/ @doomemacs/emacs-tramp -modules/emacs/undo/ @doomemacs/emacs-undo -modules/emacs/vc/ @doomemacs/emacs-vc -modules/email/mu4e/ @doomemacs/email-mu4e -modules/email/notmuch/ @doomemacs/email-notmuch -modules/email/wanderlust/ @doomemacs/email-wanderlust -modules/input/bidi/ @doomemacs/input-bidi -modules/input/chinese/ @doomemacs/input-chinese -modules/input/japanese/ @doomemacs/input-japanese -modules/input/layout/ @doomemacs/input-layout -modules/lang/agda/ @doomemacs/lang-agda -modules/lang/beancount/ @doomemacs/lang-beancount -modules/lang/cc/ @doomemacs/lang-cc -modules/lang/clojure/ @doomemacs/lang-clojure -modules/lang/common-lisp/ @doomemacs/lang-common-lisp -modules/lang/coq/ @doomemacs/lang-coq -modules/lang/crystal/ @doomemacs/lang-crystal -modules/lang/csharp/ @doomemacs/lang-csharp -modules/lang/dart/ @doomemacs/lang-dart -modules/lang/data/ @doomemacs/lang-data -modules/lang/dhall/ @doomemacs/lang-dhall -modules/lang/elixir/ @doomemacs/lang-elixir -modules/lang/elm/ @doomemacs/lang-elm -modules/lang/emacs-lisp/ @doomemacs/lang-emacs-lisp -modules/lang/erlang/ @doomemacs/lang-erlang -modules/lang/ess/ @doomemacs/lang-ess -modules/lang/factor/ @doomemacs/lang-factor -modules/lang/faust/ @doomemacs/lang-faust -modules/lang/fortran/ @doomemacs/lang-fortran -modules/lang/fsharp/ @doomemacs/lang-fsharp -modules/lang/fstar/ @doomemacs/lang-fstar -modules/lang/gdscript/ @doomemacs/lang-gdscript -modules/lang/go/ @doomemacs/lang-go -modules/lang/graphql/ @doomemacs/lang-graphql -modules/lang/haskell/ @doomemacs/lang-haskell -modules/lang/hy/ @doomemacs/lang-hy -modules/lang/idris/ @doomemacs/lang-idris -modules/lang/java/ @doomemacs/lang-java -modules/lang/javascript/ @doomemacs/lang-javascript -modules/lang/json/ @doomemacs/lang-json -modules/lang/julia/ @doomemacs/lang-julia -modules/lang/kotlin/ @doomemacs/lang-kotlin -modules/lang/latex/ @doomemacs/lang-latex -modules/lang/lean/ @doomemacs/lang-lean -modules/lang/ledger/ @doomemacs/lang-ledger -modules/lang/lua/ @doomemacs/lang-lua -modules/lang/markdown/ @doomemacs/lang-markdown -modules/lang/nim/ @doomemacs/lang-nim -modules/lang/nix/ @doomemacs/lang-nix -modules/lang/ocaml/ @doomemacs/lang-ocaml -modules/lang/org/ @doomemacs/lang-org -modules/lang/php/ @doomemacs/lang-php -modules/lang/plantuml/ @doomemacs/lang-plantuml -modules/lang/purescript/ @doomemacs/lang-purescript -modules/lang/python/ @doomemacs/lang-python -modules/lang/qt/ @doomemacs/lang-qt -modules/lang/racket/ @doomemacs/lang-racket -modules/lang/raku/ @doomemacs/lang-raku -modules/lang/rest/ @doomemacs/lang-rest -modules/lang/rst/ @doomemacs/lang-rst -modules/lang/ruby/ @doomemacs/lang-ruby -modules/lang/rust/ @doomemacs/lang-rust -modules/lang/scala/ @doomemacs/lang-scala -modules/lang/scheme/ @doomemacs/lang-scheme -modules/lang/sh/ @doomemacs/lang-sh -modules/lang/sml/ @doomemacs/lang-sml -modules/lang/solidity/ @doomemacs/lang-solidity -modules/lang/swift/ @doomemacs/lang-swift -modules/lang/terra/ @doomemacs/lang-terra -modules/lang/web/ @doomemacs/lang-web -modules/lang/yaml/ @doomemacs/lang-yaml -modules/lang/zig/ @doomemacs/lang-zig -modules/os/macos/ @doomemacs/os-macos -modules/os/tty/ @doomemacs/os-tty -modules/term/eshell/ @doomemacs/term-eshell -modules/term/shell/ @doomemacs/term-shell -modules/term/term/ @doomemacs/term-term -modules/term/vterm/ @doomemacs/term-vterm -modules/tools/ansible/ @doomemacs/tools-ansible -modules/tools/biblio/ @doomemacs/tools-biblio -modules/tools/debugger/ @doomemacs/tools-debugger -modules/tools/direnv/ @doomemacs/tools-direnv -modules/tools/docker/ @doomemacs/tools-docker -modules/tools/editorconfig/ @doomemacs/tools-editorconfig -modules/tools/ein/ @doomemacs/tools-ein -modules/tools/eval/ @doomemacs/tools-eval -modules/tools/gist/ @doomemacs/tools-gist -modules/tools/lookup/ @doomemacs/tools-lookup -modules/tools/lsp/ @doomemacs/tools-lsp -modules/tools/magit/ @doomemacs/tools-magit -modules/tools/make/ @doomemacs/tools-make -modules/tools/pass/ @doomemacs/tools-pass -modules/tools/pdf/ @doomemacs/tools-pdf -modules/tools/prodigy/ @doomemacs/tools-prodigy -modules/tools/rgb/ @doomemacs/tools-rgb -modules/tools/taskrunner/ @doomemacs/tools-taskrunner -modules/tools/terraform/ @doomemacs/tools-terraform -modules/tools/tmux/ @doomemacs/tools-tmux -modules/tools/tree-sitter/ @doomemacs/tools-tree-sitter -modules/tools/upload/ @doomemacs/tools-upload -modules/ui/deft/ @doomemacs/ui-deft -modules/ui/doom/ @doomemacs/ui-doom -modules/ui/doom-dashboard/ @doomemacs/ui-doom-dashboard -modules/ui/doom-quit/ @doomemacs/ui-doom-quit -modules/ui/emoji/ @doomemacs/ui-emoji -modules/ui/hl-todo/ @doomemacs/ui-hl-todo -modules/ui/hydra/ @doomemacs/ui-hydra -modules/ui/indent-guides/ @doomemacs/ui-indent-guides -modules/ui/ligatures/ @doomemacs/ui-ligatures -modules/ui/minimap/ @doomemacs/ui-minimap -modules/ui/modeline/ @doomemacs/ui-modeline -modules/ui/nav-flash/ @doomemacs/ui-nav-flash -modules/ui/neotree/ @doomemacs/ui-neotree -modules/ui/ophints/ @doomemacs/ui-ophints -modules/ui/popup/ @doomemacs/ui-popup -modules/ui/tabs/ @doomemacs/ui-tabs -modules/ui/treemacs/ @doomemacs/ui-treemacs -modules/ui/unicode/ @doomemacs/ui-unicode -modules/ui/vc-gutter/ @doomemacs/ui-vc-gutter -modules/ui/vi-tilde-fringe/ @doomemacs/ui-vi-tilde-fringe -modules/ui/window-select/ @doomemacs/ui-window-select -modules/ui/workspaces/ @doomemacs/ui-workspaces -modules/ui/zen/ @doomemacs/ui-zen - -# End of CODEOWNERS -\ No newline at end of file diff --git a/.config/emacs/.github/ISSUE_TEMPLATE/bug_report.yml b/.config/emacs/.github/ISSUE_TEMPLATE/bug_report.yml @@ -1,115 +0,0 @@ ---- -name: 📝 Bug Report -description: Report something that isn't working as intended -labels: ["is:bug", "needs-triage"] -body: -- type: markdown - attributes: - value: | - > :warning: Our issue tracker is only for bug reports, not feature requests, or general user support. Submit those to [our Discourse](https://discourse.doomemacs.org) or [our Discord server](https://doomemacs.org/discord) instead. - - **Before you fill out this bug report,** please ensure that you've exhausted all other options. Emacs' complexity tends to swamp us with false positive and vague issues. We desperately need your help to meet us halfway by following this checklist: -- type: checkboxes - attributes: - label: "I confirm that..." - options: - - label: > - I have searched the [issue - tracker](https://github.com/doomemacs/doomemacs/issues), - [documentation](https://docs.doomemacs.org), - [FAQ](https://docs.doomemacs.org/-/faq), - [Discourse](https://discourse.doomemacs.org), and - [Google](https://google.com), in case this issue has already been - reported/resolved. - required: true - - label: > - I have read "[How to Debug - Issues](https://doomemacs.org/d/how2debug)", and will use it to - provide as much information about this issue as possible. - required: true - - label: > - The issue can be reproduced on the **latest** available commit of - Doom. - required: true - - label: > - The issue can be reproduced on a stable release of Emacs, such as 27 - or 28. *(Doom does not support development builds like 29+ or any - version ending in .50 or .9x)* - required: true -- type: markdown - attributes: - value: "-----" -- type: textarea - attributes: - label: Expected behavior - description: A concise description of what you expected to happen. - placeholder: When I do X, it should do Y. - validations: - required: true -- type: textarea - attributes: - label: Current behavior - description: | - A concise description of what you're experiencing. Try to include: - - - A [backtrace](https://doomemacs.org/d/how2backtrace) for **each** error message. - - Any recent errors/warnings in the \*Messages\* buffer (`C-h e` to open it). - - Screenshots and gifs. - - Descriptions that are more helpful than "X does not work" or similar. - - Any attempts you made to resolve the issue yourself, and their result. - placeholder: | - When I do X, it does Z instead, which throws an error. Here is the backtrace: - - ``` - Debugger entered--Lisp error: (error "Beep Boop") - error("Beep Boop") - pp-eval-expression((error "Beep Boop")) - \#<subr funcall-interactively>(pp-eval-expression (error "Beep Boop")) - apply(#<subr funcall-interactively> (pp-eval-expression (error "Beep Boop"))) - funcall-interactively(pp-eval-expression (error "Beep Boop")) - ``` - validations: - required: true -- type: markdown - attributes: - value: | - > :warning: Take the time to properly format code and text dumps with [code fences](https://docs.github.com/en/github/writing-on-github/creating-and-highlighting-code-blocks), or use a [pastebin](https://pastebin.com) (or similar) service. -- type: textarea - attributes: - label: Steps to reproduce - description: > - Walk us through a minimal test case. Please spell out any keybinds (and - what commands they invoke), and assume the reader knows little about Doom - and/or Emacs. - placeholder: | - 1. Open Emacs - 2. `M-x doom/info` and be prompted to visit pastebin.com - 3. Press `y` to open pastebin.com in browser - 4. Paste the contents of my clipboard into text box - 5. Click "Create New Paste" - validations: - required: true -- type: input - id: doominfo - attributes: - label: System Information - description: | - Upload the contents of `M-x doom/info` or `$ ~/.config/emacs/bin/doom info` to [pastebin](https://pastebin.com), [gist](https://gist.github.com), or a similar service, then paste the link to it here. - placeholder: https://pastebin.com/fakeurl - validations: - required: true -- type: markdown - attributes: - value: | - > :warning: Please don't paste your doom-info directly into this box, and **please don't omit it**. If it's unavailable, **explain why in the textbox or another field above!** -- type: markdown - attributes: - value: | - - ----- - - Please take the time to ensure that your report is well-formatted and formulated, and all error messages include [a backtrace](https://doomemacs.org/d/how2backtrace). Issues that are **unactionable**, **vague**, and/or **inadequately researched** (or otherwise unhelpful to posterity) will see heavy delays or be automatically closed (possibly deleted). - - If you aren't sure that it makes the cut, submit it to [our Discord](https://doomemacs.org/discord) or [Discourse](https://discourse.doomemacs.org) instead. - - :heart: **Thank you for taking the time to file this bug report!** diff --git a/.config/emacs/.github/ISSUE_TEMPLATE/config.yml b/.config/emacs/.github/ISSUE_TEMPLATE/config.yml @@ -1,14 +0,0 @@ -blank_issues_enabled: false -contact_links: - - name: Official Documentation - url: https://github.com/doomemacs/doomemacs/blob/master/docs/index.org - about: "Walks you through how to use, abuse, or confuse Doom Emacs. Also available from within Doom: `M-x doom/help`" - - name: Visit our Discourse - url: https://discourse.doomemacs.org - about: "A repository of official learning resources and discussion forum for Emacs and Doom" - - name: Visit our Discord - url: https://doomemacs.org/discord - about: "A place to chat, get to know the community, and get help quick" - - name: See third-party resources - url: https://discourse.doomemacs.org/c/guides/resources - about: "A curated collection of non-official resources to help you learn Emacs and Doom" diff --git a/.config/emacs/.github/workflows/add-to-project.yml b/.config/emacs/.github/workflows/add-to-project.yml @@ -1,8 +0,0 @@ -name: Add issues to project -on: - issues: - types: [opened] -jobs: - add-to-project: - uses: doomemacs/ci/.github/workflows/add-to-project.yml@legacy - secrets: inherit diff --git a/.config/emacs/.github/workflows/lint-commits.yml b/.config/emacs/.github/workflows/lint-commits.yml @@ -1,5 +0,0 @@ -name: Lint commits -on: [push, pull_request] -jobs: - lint-commits: - uses: doomemacs/ci/.github/workflows/lint-commits.yml@legacy diff --git a/.config/emacs/.github/workflows/triage.yml b/.config/emacs/.github/workflows/triage.yml @@ -1,7 +0,0 @@ -name: Mark stale issues and lock closed threads -on: - schedule: - - cron: '0 */12 * * *' # twice, daily -jobs: - triage: - use: doomemacs/ci/.github/workflows/triage.yml@legacy diff --git a/.config/emacs/.gitignore b/.config/emacs/.gitignore @@ -1,53 +0,0 @@ -# machine generated doom profiles or metadata -/profiles/*.el -/.local*/ - -# possible user config files -/profiles.el -/init.el -/config.el -/packages.el - -# generated by elisp packages in sub-directories -*~ -*.*~ -\#* -.\#* -*.cache* -*.log -*.elc -*.eln -*.lib -*.fas -*.dat -*.eld -*.rel -*_archive -*_flymake.* -.dap-breakpoints -.emacs.desktop -.emacs.desktop.lock -.org-id-locations -.projectile -.tern-port -.yas-compiled-snippets.el -flycheck_*.el - -# generated by elisp packages at root -/.local/ -/.cask/ -/auto/ -/auto-save-list/ -/cask/ -/ede-projects.el -/eln-cache/ -/elpa/ -/eshell/ -/network-security.data -/places -/semanticdb -/server/ -/smex-items -/tramp -/transient/ -/var/ diff --git a/.config/emacs/LICENSE b/.config/emacs/LICENSE @@ -1,22 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2014-2022 Henrik Lissner. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/.config/emacs/README.md b/.config/emacs/README.md @@ -1,249 +0,0 @@ -<div align="center"> - -# Doom Emacs - -[Install](#install) • [Documentation] • [FAQ] • [Screenshots] • [Contribute](#contribute) - -![Made with Doom Emacs](https://img.shields.io/github/tag/doomemacs/doomemacs.svg?style=flat-square&label=release&color=58839b) -![Supports Emacs 27.1 - 28.1](https://img.shields.io/badge/Supports-Emacs_27.1--28.1-blueviolet.svg?style=flat-square&logo=GNU%20Emacs&logoColor=white) -![Latest commit](https://img.shields.io/github/last-commit/doomemacs/doomemacs/master?style=flat-square) -![Build status: master](https://img.shields.io/github/workflow/status/doomemacs/doomemacs/CI/master?style=flat-square) -[![Discord Server](https://img.shields.io/discord/406534637242810369?color=738adb&label=Discord&logo=discord&logoColor=white&style=flat-square)][Discord] -[![Discourse server](https://img.shields.io/discourse/users?server=https%3A%2F%2Fdiscourse.doomemacs.org&logo=discourse&label=Discourse&style=flat-square&color=9cf)][Discourse] - -![Doom Emacs Screenshot](https://raw.githubusercontent.com/doomemacs/doomemacs/screenshots/main.png) - -</div> - ---- - -### Table of Contents -- [Introduction](#introduction) -- [Features](#features) -- [Prerequisites](#prerequisites) -- [Install](#install) -- [Roadmap](#roadmap) -- [Getting help](#getting-help) -- [Contribute](#contribute) - - -# Introduction -<a href="http://ultravioletbat.deviantart.com/art/Yay-Evil-111710573"> - <img src="https://raw.githubusercontent.com/doomemacs/doomemacs/screenshots/cacochan.png" align="right" /> -</a> - -> It is a story as old as time. A stubborn, shell-dwelling, and melodramatic -> vimmer—envious of the features of modern text editors—spirals into -> despair before he succumbs to the [dark side][evil-mode]. This is his config. - -Doom is a configuration framework for [GNU Emacs] tailored for Emacs bankruptcy -veterans who want less framework in their frameworks, a modicum of stability -(and reproducibility) from their package manager, and the performance of a hand -rolled config (or better). It can be a foundation for your own config or a -resource for Emacs enthusiasts to learn more about our favorite operating -system. - -Its design is guided by these mantras: - -+ **Gotta go fast.** Startup and run-time performance are priorities. Doom goes - beyond by modifying packages to be snappier and load lazier. -+ **Close to metal.** There's less between you and vanilla Emacs by design. - That's less to grok and less to work around when you tinker. Internals ought - to be written as if reading them were part of Doom's UX, and it is! -+ **Opinionated, but not stubborn.** Doom is about reasonable defaults and - curated opinions, but use as little or as much of it as you like. -+ **Your system, your rules.** You know better. At least, Doom hopes so! It - won't *automatically* install system dependencies (and will force plugins not - to either). Rely on `doom doctor` to tell you what's missing. -+ **Nix/Guix is a great idea!** The Emacs ecosystem is temperamental. Things - break and they break often. Disaster recovery should be a priority! Doom's - package management should be declarative and your private config reproducible, - and comes with a means to roll back releases and updates (still a WIP). - -Check out [the FAQ][FAQ] for answers to common questions about the project. - - -# Features -- Minimalistic good looks inspired by modern editors. -- Curated and sane defaults for many packages, (major) OSes, and Emacs itself. -- A modular organizational structure for separating concerns in your config. -- A standard library designed to simplify your elisp bike shedding. -- A declarative [package management system][package-management] (powered by - [straight.el]) with a command line interface. Install packages from anywhere, - not just (M)ELPA, and pin them to any commit. -- Optional vim emulation powered by [evil-mode], including ports of popular vim - plugins like [vim-sneak], [vim-easymotion], [vim-unimpaired] and - [more][ported-vim-plugins]! -- Opt-in LSP integration for many languages, using [lsp-mode] or [eglot] -- Support for *many* programming languages. Includes syntax highlighting, - linters/checker integration, inline code evaluation, code completion (where - possible), REPLs, documentation lookups, snippets, and more! -- Support for *many* tools, like docker, pass, ansible, terraform, and more. -- A Spacemacs-esque [keybinding scheme][bindings], centered around leader - and localleader prefix keys (<kbd>SPC</kbd> and <kbd>SPC</kbd><kbd>m</kbd> for - evil users, <kbd>C-c</kbd> and <kbd>C-c l</kbd> for vanilla users). -- A rule-based [popup manager][popup-system] to control how temporary buffers - are displayed (and disposed of). -- Per-file indentation style detection and [editorconfig] integration. Let - someone else argue about tabs vs **_spaces_**. -- Project-management tools and framework-specific minor modes with their own - snippets libraries. -- Project search (and replace) utilities, powered by [ripgrep] and [ivy] or - [helm]. -- Isolated and persistent workspaces (also substitutes for vim tabs). -- Support for Chinese and Japanese input systems. -- Save a snapshot of your shell environment to a file for Emacs to load at - startup. No more struggling to get Emacs to inherit your `PATH`, among other - things. - - -# Prerequisites -+ Git 2.23+ -+ Emacs 27.1+ (*28.1 is recommended*, or [native-comp](https://www.emacswiki.org/emacs/GccEmacs). **29+ is not supported**). -+ [ripgrep] 11.0+ -+ GNU `find` -+ *OPTIONAL:* [fd] 7.3.0+ (improves file indexing performance for some commands) - -Doom is comprised of [~150 optional modules][Modules], some of which may have -additional dependencies. [Visit their documentation][Modules] or run `bin/doom -doctor` to check for any that you may have missed. - - -# Install -``` sh -git clone --depth 1 https://github.com/doomemacs/doomemacs ~/.config/emacs -~/.config/emacs/bin/doom install -``` - -Then [read our Getting Started guide][getting-started] to be walked through -installing, configuring and maintaining Doom Emacs. - -It's a good idea to add `~/.config/emacs/bin` to your `PATH`! Other `bin/doom` -commands you should know about: - -+ `doom sync` to synchronize your private config with Doom by installing missing - packages, removing orphaned packages, and regenerating caches. Run this - whenever you modify your private `init.el` or `packages.el`, or install/remove - an Emacs package through your OS package manager (e.g. mu4e or agda). -+ `doom upgrade` to update Doom to the latest release & all installed packages. -+ `doom doctor` to diagnose common issues with your system and config. -+ `doom env` to dump a snapshot of your shell environment to a file that Doom - will load at startup. This allows Emacs to inherit your `PATH`, among other - things. -+ `doom build` to recompile all installed packages (use this if you up/downgrade - Emacs). - - -# Roadmap -Doom is an active and ongoing project. To make that development more -transparent, its roadmap (and other concerns) are published across three github -project boards and a newsletter: - -+ [Development Roadmap](https://discourse.doomemacs.org/t/development-roadmap/42): - roughly outlines our goals between release milestones and their progress. -+ [Plugins under review](https://github.com/orgs/doomemacs/projects/5): - lists plugins we are watching and considering for inclusion, and what their - status for inclusion is. Please consult this list before requesting new - packages/features. -+ [Upstream bugs](https://github.com/orgs/doomemacs/projects/7): lists - issues that originate from elsewhere, and whether or not we have local - workarounds or temporary fixes for them. -+ ~~Doom's newsletter~~ (not finished) will contain changelogs in between - releases. - - -# Getting help -Emacs is no journey of a mere thousand miles. You _will_ run into problems and -mysterious errors. When you do, here are some places you can look for help: - -+ [Our documentation][documentation] covers many use cases. - + [The Configuration section][configuration] covers how to configure Doom and - its packages. - + [The Package Management section][package-management] covers how to install - and disable packages. - + [This section][bin/doom] explains the `bin/doom` script's most important - commands. - + [This section][common-mistakes] lists some common configuration mistakes new - users make, when migrating a config from another distro or their own. - + [This answer][change-theme] shows you how to add your own themes to your - private config. - + [This answer][change-font] shows you how to change the default font. - + Your issue may be documented in the [FAQ]. -+ With Emacs built-in help system documentation is a keystroke away: - + For functions: <kbd>SPC h f</kbd> or <kbd>C-h f</kbd> - + For variables: <kbd>SPC h v</kbd> or <kbd>C-h v</kbd> - + For a keybind: <kbd>SPC h k</kbd> or <kbd>C-h k</kbd> - + To search available keybinds: <kbd>SPC h b b</kbd> or <kbd>C-h b b</kbd> -+ Run `bin/doom doctor` to detect common issues with your development - environment and private config. -+ Check out the [FAQ] or [Discourse FAQs][discourse-faq], in case your question - has already been answered. -+ Search [Doom's issue tracker](https://github.com/doomemacs/doomemacs/issues) in case your issue was already - reported. -+ Hop on [our Discord server][discord]; it's active and friendly! Keep an eye on - the #announcements channel, where I announce breaking updates and releases. - - -# Contribute -[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) -[![Elisp styleguide](https://img.shields.io/badge/elisp-style%20guide-purple?style=flat-square)](https://github.com/bbatsov/emacs-lisp-style-guide) -[![Donate on liberapay](https://img.shields.io/badge/liberapay-donate-1.svg?style=flat-square&logo=liberapay&color=blue)][liberapay] -[![Donate on paypal](https://img.shields.io/badge/paypal-donate-1?style=flat-square&logo=paypal&color=blue)][paypal] - -Doom is a labor of love and incurable madness, but I'm only one guy. Doom -wouldn't be where it is today without your help. I welcome contributions of any -kind! - -+ I :heart: pull requests and bug reports (see the [Contributing - Guidelines][contribute])! -+ Don't hesitate to [tell me my Elisp-fu - sucks](https://github.com/doomemacs/doomemacs/issues/new), but please tell me - why. -+ Hop on [our Discord server][Discord] and say hi! Help others, hang out or talk - to me about Emacs, gamedev, programming, physics, pixel art, anime, gaming -- - anything you like. Nourish this lonely soul. -+ If you'd like to support my work financially, buy me a drink through - [liberapay] or [paypal]. My work contends with studies, adventures in indie - gamedev and freelance work. Donations help me allocate more time to my Emacs - and OSS capers. - - -[contribute]: docs/contributing.org -[discord]: https://discord.gg/qvGgnVx -[discourse]: https://discourse.doomemacs.org -[discourse-faq]: https://discourse.doomemacs.org/tag/faq -[documentation]: docs/index.org -[faq]: https://github.com/hlissner/doom-emacs/blob/master/docs/faq.org -[getting-started]: docs/getting_started.org -[install]: docs/getting_started.org#install -[backtrace]: docs/getting_started.org#how-to-extract-a-backtrace-from-an-error -[configuration]: docs/getting_started.org#configuring-doom -[package-management]: docs/getting_started.org#package-management -[bin/doom]: docs/getting_started.org#the-bindoom-utility -[common-mistakes]: docs/getting_started.org#common-mistakes-when-configuring-doom-emacs -[change-theme]: docs/faq.org#how-do-i-change-the-theme -[change-font]: docs/faq.org#how-do-i-change-the-fonts -[modules]: docs/modules.org -[popup-system]: modules/ui/popup/README.org -[screenshots]: https://github.com/doomemacs/doomemacs/tree/screenshots#emacsd-screenshots - -[bindings]: modules/config/default/+evil-bindings.el -[editorconfig]: http://editorconfig.org/ -[evil-mode]: https://github.com/emacs-evil/evil -[fd]: https://github.com/sharkdp/fd -[gnu emacs]: https://www.gnu.org/software/emacs/ -[helm]: https://github.com/emacs-helm/helm -[ivy]: https://github.com/abo-abo/swiper -[lsp-mode]: https://github.com/emacs-lsp/lsp-mode -[eglot]: https://github.com/joaotavora/eglot -[nix]: https://nixos.org -[ported-vim-plugins]: modules/editor/evil/README.org#ported-vim-plugins -[ripgrep]: https://github.com/BurntSushi/ripgrep -[straight.el]: https://github.com/radian-software/straight.el -[vim-easymotion]: https://github.com/easymotion/vim-easymotion -[vim-lion]: https://github.com/tommcdo/vim-lion -[vim-sneak]: https://github.com/justinmk/vim-sneak -[vim-unimpaired]: https://github.com/tpope/vim-unimpaired - -[liberapay]: https://liberapay.com/hlissner/donate -[paypal]: https://paypal.me/henriklissner/10 diff --git a/.config/emacs/bin/doom b/.config/emacs/bin/doom @@ -1,327 +0,0 @@ -#!/usr/bin/env sh -:; # -*- mode: emacs-lisp; lexical-binding: t -*- -:; case "$EMACS" in *term*) EMACS=emacs ;; *) EMACS="${EMACS:-emacs}" ;; esac -:; emacs="$EMACS ${DEBUG:+--debug-init} -q --no-site-file --batch" -:; tmpdir=`$emacs --eval '(princ (temporary-file-directory))' 2>/dev/null` -:; [ -z "$tmpdir" ] && { >&2 echo "Error: failed to run Emacs with command '$EMACS'"; >&2 echo; >&2 echo "Are you sure Emacs is installed and in your \$PATH?"; exit 1; } -:; export __DOOMPID="${__DOOMPID:-$$}" -:; export __DOOMSTEP="${__DOOMSTEP:-0}" -:; export __DOOMGEOM="${__DOOMGEOM:-`tput cols 2>/dev/null`x`tput lines 2>/dev/null`}" -:; export __DOOMGPIPE=${__DOOMGPIPE:-$__DOOMPIPE} -:; export __DOOMPIPE=; [ -t 0 ] || __DOOMPIPE="${__DOOMPIPE}0"; [ -t 1 ] || __DOOMPIPE="${__DOOMPIPE}1" -:; $emacs --load "$0" -- "$@" || exit=$? -:; [ "${exit:-0}" -eq 254 ] && { sh "${tmpdir}/doom.${__DOOMPID}.${__DOOMSTEP}.sh" "$0" "$@" && true; exit="$?"; } -:; exit $exit - -;; This magical mess of a shebang is necessary for any script that relies on -;; Doom's CLI framework, because Emacs' tty libraries and capabilities are too -;; immature (borderline non-existent) at the time of writing (28.1). This -;; shebang sets out to accomplish these three goals: -;; -;; 1. To produce a more helpful error if Emacs isn't installed or broken. It -;; must do so without assuming whether $EMACS is a shell command (e.g. 'snap -;; run emacs') or an absolute path (to an emacs executable). I've avoided -;; 'command -v $EMACS' for this reason. -;; -;; 2. To allow this Emacs session to "exit into" a child process (since Elisp -;; lacks an analogue for exec system calls) by calling an auto-generated and -;; self-destructing "exit script" if the parent Emacs process exits with code -;; 254. It takes care to prevent nested child instances from clobbering the -;; exit script. -;; -;; 3. To expose some information about the terminal and session: -;; - $__DOOMGEOM holds the dimensions of the terminal (W . H). -;; - $__DOOMPIPE indicates whether the script has been piped (in and/or out). -;; - $__DOOMGPIPE indicates whether one of this process' parent has been -;; piped to/from. -;; - $__DOOMPID is a unique identifier for the parent script, so -;; child processes can identify which persistent data files (like logs) it -;; has access to. -;; - $__DOOMSTEP counts how many levels deep we are in the dream (appending -;; this to the exit script's filename avoids child processes clobbering the -;; same exit script and causing read errors). -;; - $TMPDIR (or $TEMP and $TMP on Windows) aren't guaranteed to have values, -;; and mktemp isn't available on all systems, but you know what is? Emacs! -;; So I use it to print `temporary-file-directory'. And it seconds as a -;; quick sanity check for Emacs' existence (for goal #1). -;; -;; Other weird facts about this shebang line: -;; -;; - The :; hack exploits properties of : and ; in shell scripting and elisp to -;; allow shell script and elisp to coexist in the same file without either's -;; interpreter throwing foreign syntax errors: -;; -;; - In elisp, ":" is a valid keyword symbol literal; it evaluates to itself -;; and has no side-effect. -;; - In the shell, ":" is a valid command that does nothing and ignores its -;; arguments. -;; - In elisp, ";" begins a comment. I.e. the interpreter ignores everything -;; after it. -;; - In the shell, ";" is a command separator. -;; -;; Put together, plus a strategically placed exit call, the shell will read -;; one part of this file and ignore the rest, while the elisp interpreter will -;; do the opposite. -;; - I intentionally avoid loading site files, so lisp/doom-cli.el can load them -;; by hand later. There, I can suppress and deal with unhelpful warnings (e.g. -;; "package cl is deprecated"), "Loading X...DONE" spam, and any other -;; disasterous side-effects. -;; -;; But be careful not to use -Q! It implies --no-site-lisp, which omits the -;; site-lisp directory from `load-path'. -;; - POSIX-compliancy is paramount: there's no guarantee what /bin/sh will be -;; symlinked to in the esoteric OSes/distros Emacs users use. -;; - The user may have a noexec flag set on /tmp, so pass the exit script to -;; /bin/sh rather than executing them directly. - -;; In CLI sessions, prefer correctness over performance. -(setq load-prefer-newer t) - -;; Doom's core sets up everything we need; including `doom-*-dir' variables, -;; universal defaults, and autoloads for doom-*-initialize functions. -(condition-case e - (let* ((bin-dir (file-name-directory (file-truename load-file-name))) - (init-file (expand-file-name "../early-init.el" bin-dir))) - (or (and (load init-file nil 'nomessage 'nosuffix) - (featurep 'doom)) - (user-error "Failed to load Doom from %s" init-file))) - ;; Prevent ugly backtraces for trivial errors - (user-error (message "Error: %s" (cadr e)) - (kill-emacs 2))) - -;; UX: Abort if the user is using 'doom' as root, unless ~/.config/emacs is -;; owned by root, in which case we assume the user genuinely wants root to be -;; their primary user account for Emacs. -(when (equal 0 (user-real-uid)) - (unless (equal 0 (file-attribute-user-id (file-attributes doom-emacs-dir))) - (message - (concat - "Error: this script was executed as root, which is likely not what you want.\n" - "It will cause file permissions errors later, when you run Doom as another\n" - "user.\n\n" - "If this really *is* what you want, then change the owner of your Emacs\n" - "config to root:\n\n" - ;; TODO Add cmd.exe/powershell commands - " chown root:root -R " (abbreviate-file-name doom-emacs-dir) "\n\n" - "Aborting...")) - (kill-emacs 2))) - - -;; -;;; Entry point - -(defcli! doom (&args _command) - "A command line interface to Doom Emacs. - -Includes package management, diagnostics, unit tests, and byte-compilation. - -This tool also makes it trivial to launch Emacs out of a different folder or -with a different private module. - -ENVIRONMENT VARIABLES: - `$EMACS' - The Emacs executable or command to use for any Emacs operations in this or - other Doom CLI shell scripts (default: first emacs found in `$PATH'). - - `$EMACSDIR' - The location of your Doom Emacs installation (defaults to ~/.config/emacs or - ~/.emacs.d; whichever is found first). This is *not* your private Doom - configuration. The `--emacsdir' option also sets this variable. - - `$DOOMDIR' - The location of your private configuration for Doom Emacs (defaults to - ~/.config/doom or ~/.doom.d; whichever it finds first). This is *not* the - place you've cloned doomemacs/doomemacs to. The `--doomdir' option also sets - this variable. - - `$DOOMPAGER' - The pager to invoke for large output (default: \"less +g\"). The `--pager' - option also sets this variable. - - `$DOOMPROFILE' - Which Doom profile to activate (default: \"_@0\"). The `--profile' option - also sets this variable. - - `$DOOMPROFILELOADFILE' - Doom generates a profile loader script on 'doom sync' or 'doom profiles - sync'. By default, this file is written to and loaded from - $EMACSDIR/profiles/load.el. Set this envvar to change that. Note that this - envvar must be in scope for both interactive and non-interactive sessions - for it to be effective. This is especially useful for folks on Nix/Guix, who - have deployed Doom to a read-only directory. - - Note: this file *must* end with a .el extension. It will be byte-compiled - after it is generated. - - `$DOOMPROFILELOADPATH' - A colon-delimited (semi-colon on Windows) list of profile config files or - directories under which Doom will search for implicit profiles. See - `var:doom-profile-load-path' for its default value. - -EXIT CODES: - 0 Successful run - 1 General internal error - 2 Error with Emacs/Doom install or execution context - 3 Unrecognized user input error - 4 Command not found, or is incorrect/deprecated - 5 Invalid, missing, or extra options/arguments - 6-49 Reserved for Doom - 50-200 Reserved for custom user codes - 254 Successful run (but then execute `doom-cli-restart-script') - 255 Uncaught internal errors - -SEE ALSO: - https://doomemacs.org Homepage - https://docs.doomemacs.org Official documentation - https://discourse.doomemacs.org Discourse (discussion & support forum) - https://doomemacs.org/discord Discord chat server - https://doomemacs.org/roadmap Development roadmap - https://git.doomemacs.org Shortcut to Github org - https://git.doomemacs.org/todo Global issue tracker" - :partial t) - -(defcli! :before - ((force? ("-!" "--force") "Suppress prompts by auto-accepting their consequences") - (debug? ("-D" "--debug") "Enable debug output") - (verbose? ("-v" "--verbose") "Enable verbose output") - (doomdir ("--doomdir" dir) "Use Doom config living in `DIR' (e.g. ~/.doom.d)") - (emacsdir ("--emacsdir" dir) "Use Doom install living in `DIR' (e.g. ~/.emacs.d)") - (pager ("--pager" cmd) "Pager command to use for large output") - (profile ("--profile" name) "Use profile named NAME") - (bench? ("--benchmark") "Always display the benchmark") - &flags - (color? ("--color") "Whether or not to show ANSI color codes") - &multiple - (loads ("-L" "--load" "--strict-load" file) "Load elisp `FILE' before executing `COMMAND'") - (evals ("-E" "--eval" form) "Evaluate `FORM' before executing commands") - &input input - &context context - &args _) - "OPTIONS: - -E, -eval - Can be used multiple times. - - -L, --load, --strict-load - Can be used multiple times to load multiple files. Both -L and --load will - silently fail on missing files, but --strict-load won't. - - Warning: files loaded this way load too late to define new commands. To - define commands, do so from `$DOOMDIR'/cli.el, `$DOOMDIR'/init.el, or a - .doomrc file in the current project tree." - (when bench? - (setq doom-cli-benchmark-threshold 'always)) - (unless init-file-debug ; debug-mode implies verbose - (when verbose? - (setq doom-print-minimum-level 'info))) - (when color? - (setq doom-print-backend (if (eq color? :yes) 'ansi))) - (when pager - (setq doom-cli-pager pager)) - (when force? - (setf (doom-cli-context-suppress-prompts-p context) t)) - ;; For these settings to take full effect, the script must be restarted: - (when (or debug? - profile - emacsdir - doomdir) - (let (omit) - (when debug? - (setenv "DEBUG" "1") - (setq init-file-debug t) - (push "--debug" omit)) - (when profile - (setenv "DOOMPROFILE" profile) - (push "--profile=" omit)) - (when emacsdir - (setenv "EMACSDIR" emacsdir) - (push "--emacsdir=" omit)) - (when doomdir - (setenv "DOOMDIR" doomdir) - (push "--doomdir=" omit)) - (exit! :restart :omit omit))) - ;; Load extra files and forms, as per given options. - (dolist (file loads) - (load (doom-path (cdr file)) - (not (equal (car file) "--strict-load")) - (not init-file-debug) t)) - (dolist (form evals) - (eval (read (cdr form)) t))) - - -;; -;;; Load user config + commands - -;; Load $DOOMDIR/init.el, to read the user's `doom!' block and give users an -;; opportunity to customize the CLI environment, if they like. Otherwise, they -;; can do so in .doomrc or .doomproject. -(load! doom-module-init-file doom-user-dir t) - -;; There are a lot of CLIs, and some have expensive initialization, so best we -;; load them lazily. -(defcli-group! - :prefix 'doom - ;; Import this for implicit 'X help' commands for your script: - (defcli-alias! ((help h)) (:root :help)) - ;; And suggest its use when errors occur. - (add-to-list 'doom-help-commands "%p h[elp] %c") - - (defcli-group! "Config Management" - :docs "Commands for maintaining your Doom Emacs configuration." - (defcli-autoload! ((sync s))) - (defcli-autoload! ((profiles profile))) - (defcli-autoload! ((upgrade up))) - (defcli-autoload! (env)) - (defcli-autoload! ((build b purge p rollback)) "packages") - (defcli-autoload! ((install i))) - (defcli-autoload! ((compile c))) - (defcli-autoload! (clean) "compile") - - ;; TODO Post-3.0 commands - ;; (load! "gc" dir) - ;; (load! "module" dir) - ;; (load! "nuke" dir) - ;; (load! "package" dir) - ;; (load! "profile" dir) - ;; (defcli-obsolete! ((compile c)) (sync "--compile") "v3.0.0") - ;; (defcli-obsolete! ((build b)) (sync "--rebuild") "v3.0.0") - ) - - (defcli-group! "Diagnostics" - :docs "Commands for troubleshooting and debugging Doom." - (defcli-autoload! ((doctor doc))) - (defcli-autoload! (info)) - (defcli-alias! ((version v)) (:root :version))) - - (defcli-group! "Development" - :docs "Commands for developing or launching Doom." - (defcli-autoload! (ci)) - (defcli-autoload! (make)) - (defcli-autoload! (run)) - - ;; FIXME Test framework - ;; (load! "test" dir) - ) - - (let ((cli-file "cli.el")) - (defcli-group! "Module commands" - (doom-context-with 'modules - (dolist (key (doom-module-list)) - (when-let (path (doom-module-locate-path (car key) (cdr key) cli-file)) - (defcli-group! :prefix (if (cdr key) (format "+%s" (cdr key))) - (doom-load (file-name-sans-extension path)))))))) - - ;; Allow per-project Doom settings in .doom files. - (let (doomrc) - (cond - ((setq doomrc (getenv "DOOMRC")) - (load! doomrc default-directory)) - ((setq doomrc (locate-dominating-file default-directory ".doomrc")) - (load! ".doomrc" doomrc))))) - - -;; -;;; Let 'er rip - -(run! "doom" (cdr (member "--" argv))) - -;;; doom ends here, unless... diff --git a/.config/emacs/bin/doom.cmd b/.config/emacs/bin/doom.cmd @@ -1,25 +0,0 @@ -:: Forward the ./doom script to Emacs - -@ECHO OFF -SETLOCAL ENABLEDELAYEDEXPANSION - -PUSHD "%~dp0" >NUL - -SET args= -SET command=%1 - -:LOOP -SHIFT /1 -IF NOT [%1]==[] ( - SET args=%args% %1 - GOTO :LOOP -) - -IF [%command%]==[run] ( - start runemacs -Q %args% -l ..\init.el -f "doom-run-all-startup-hooks-h" -) ELSE ( - emacs --quick --script .\doom -- %* -) - -POPD >NUL -ECHO ON diff --git a/.config/emacs/bin/doomscript b/.config/emacs/bin/doomscript @@ -1,87 +0,0 @@ -#!/usr/bin/env sh -# This is a shebang interpreter for launching Emacs Lisp scripts with Doom's CLI -# framework preloaded, plus any environment variables it needs. Use it like so: -# -# #!/usr/bin/env doomscript -# (print! "Hello world!") -# -# For this to work (and to avoid an absolute path in your shebang line), this -# file must be in your $PATH: -# -# export PATH="$HOME/.config/emacs/bin:$PATH" -# -# This isn't used for bin/doom because of this $PATH/absolute path requirement -# (and using $BASH_SOURCE to locate it would reduce its POSIX compliance), but -# this should be less of an issue for folks writing their own doomscripts. - -if [ "$#" -eq 0 ]; then - >&2 echo "Error: missing required file argument" - exit 1 -fi - -case "$EMACS" in - *term*) EMACS=emacs ;; # in {ansi-,v}term - *) EMACS="${EMACS:-emacs}" ;; -esac - -# Careful not to use -Q! It implies --no-site-lisp, which omits the site-lisp -# directory from `load-path', which would prevent Doom from manually loading the -# site files later. These are important on some systems or deployment methods -# (like Snap or NixOS). -emacs="$EMACS -q --no-site-file --batch" - -# $TMPDIR (or $TEMP and $TMP on Windows) aren't guaranteed to have values, and -# mktemp isn't available on all systems, but you know what is? Emacs! So I rely -# on it to provide TMPDIR. And can second as a quick existence check for Emacs. -TMPDIR="${TMPDIR:-$($emacs --eval '(princ (temporary-file-directory))' 2>/dev/null)}" -if [ -z "$TMPDIR" ]; then - >&2 echo "Error: failed to run Emacs with command '$EMACS'" - >&2 echo - >&2 echo "Are you sure Emacs is installed and in your \$PATH?" - exit 1 -fi - -# Doom respects $EMACSDIR to tell it where Doom lives. If it fails, then this is -# either isn't bash, or it's a posix shell being directly sourced with sh, which -# is unsupported. -export EMACSDIR="${EMACSDIR:-$(CDPATH='' cd -- "$(dirname -- "${BASH_SOURCE:-$0}")/.." && pwd)}" -if [ ! -f "$EMACSDIR/early-init.el" ]; then - >&2 echo "Error: cannot load $EMACSDIR/early-init.el." - >&2 echo - >&2 echo "Either the file doesn't exist (indicating a broken or missing Doom install)" - >&2 echo "or that doomscript is being source directly (which is unsupported)." - >&2 echo - >&2 echo "Set \$EMACSDIR to the path of an existing Doom installation." - exit 1 -fi -# Some state that Doom's CLI framework needs to know about the terminal. Read -# the comments at the top of bin/doom for explanations. -export __DOOMPID="${__DOOMPID:-$$}" -export __DOOMSTEP="${__DOOMSTEP:-0}" -export __DOOMGEOM="${__DOOMGEOM:-$(tput cols 2>/dev/null)x$(tput lines 2>/dev/null)}" -export __DOOMGPIPE="${__DOOMGPIPE:-$__DOOMPIPE}" -export __DOOMPIPE= -[ -t 0 ] || __DOOMPIPE="${__DOOMPIPE}0" -[ -t 1 ] || __DOOMPIPE="${__DOOMPIPE}1" - -# Now we're ready to execute the given script. $EMACSDIR/early-init.el is Doom's -# universal bootstrapper (and will only load the bare minimum), so it must be -# loaded first. -script="$1" -shift -$emacs --load "$EMACSDIR/early-init" \ - --load "$script" \ - -- "$@" -exit=$? - -# To simulate execve syscalls, Doom generates a temporary exit-script if a -# Doomscript returns a 254 exit code. -if [ "${exit:-0}" -eq 254 ]; then - # The user may have a noexec flag set on /tmp, so the exit-script should be - # passed to /bin/sh rather than executed directly. - sh "${TMPDIR}/doom.${__DOOMPID}.${__DOOMSTEP}.sh" "$0" "$@" - exit="$?" -fi -exit $exit - -# doomscript ends here... Unless? diff --git a/.config/emacs/bin/org-capture b/.config/emacs/bin/org-capture @@ -1,43 +0,0 @@ -#!/usr/bin/env sh - -# Open an org-capture popup frame from the shell. This opens a temporary emacs -# daemon if emacs isn't already running. -# -# Usage: org-capture [-k KEY] [MESSAGE] -# Examples: -# org-capture -k n "To the mind that is still, the whole universe surrenders." - -set -e - -cleanup() { - emacsclient --eval '(let (kill-emacs-hook) (kill-emacs))' -} - -# If emacs isn't running, we start a temporary daemon, solely for this window. -if ! emacsclient --suppress-output --eval nil 2>/dev/null; then - echo "No Emacs daemon/server is available! Starting one..." - emacs --daemon - trap cleanup EXIT INT TERM -fi - -# org-capture key mapped to argument flags -# keys=$(emacsclient -e "(+org-capture-available-keys)" | cut -d '"' -f2) -while getopts "hk:" opt; do - key="\"$OPTARG\"" - break -done -shift $((OPTIND-1)) - -# use remaining args, else read from stdin if passed a single dash -str="$*" -case "$str" in - -) str=$(cat) ;; -esac - -# Fix incompatible terminals that cause odd 'not a valid terminal' errors -[ "$TERM" = "alacritty" ] && export TERM=xterm-256color - -# Non-daemon servers flicker a lot if frames are created from terminal, so we do -# it internally instead. -emacsclient -a "" \ - -e "(+org-capture/open-frame \"$str\" ${key:-nil})" diff --git a/.config/emacs/bin/org-tangle b/.config/emacs/bin/org-tangle @@ -1,159 +0,0 @@ -#!/usr/bin/env sh -":"; exec emacs --quick --script "$0" -- "$@" # -*- mode: emacs-lisp; lexical-binding: t; -*- -;;; bin/org-tangle - -;; Tangles source blocks from org files. Also expands #+INCLUDE directives, -;; unlike vanilla `ob-tangle'. Debug/info messages are directed to stderr and -;; can be ignored. -;; -;; -l/--lang LANG -;; Only include blocks in the specified language (e.g. emacs-lisp). -;; -a/--all -;; Tangle all blocks by default (unless it has :tangle nil set or a -;; :notangle: tag) -;; -t/--tag TAG -;; --and TAG -;; --or TAG -;; Only include blocks in trees that have these tags. Combine multiple --and -;; and --or's, or just use --tag (implicit --and). -;; -p/--print -;; Prints tangled code to stdout instead of to files -;; -;; Usage: org-tangle [[-l|--lang] LANG] some-file.org another.org -;; Examples: -;; org-tangle -l sh modules/some/module/README.org > install_module.sh -;; org-tangle -l sh modules/lang/go/README.org | sh -;; org-tangle --and tagA --and tagB my/literate/config.org - -(require 'cl-lib) -(require 'ox) -(require 'ob-tangle) - -(defun usage () - (with-temp-buffer - (insert (format "%s %s [OPTIONS] [TARGETS...]\n" - "Usage:" - (file-name-nondirectory load-file-name)) - "\n" - "A command line interface for tangling org-mode files. TARGETS can be\n" - "files or folders (which are searched for org files recursively).\n" - "\n" - "This is useful for literate configs that rely on command line\n" - "workflows to build it.\n" - "\n" - "Example:\n" - " org-tangle some-file.org\n" - " org-tangle literate/config/\n" - " org-tangle -p -l sh scripts.org > do_something.sh\n" - " org-tangle -p -l python -t tagA -t tagB file.org | python\n" - "\n" - "Options:\n" - " -a --all\t\tTangle all blocks by default\n" - " -l --lang LANG\tOnly tangle blocks written in LANG\n" - " -p --print\t\tPrint tangled output to stdout than to files\n" - " -t --tag TAG\n" - " --and TAG\n" - " --or TAG\n" - " Lets you tangle org blocks by tag. You may have more than one\n" - " of these options.\n") - (princ (buffer-string)))) - -(defun *org-babel-tangle (fn &rest args) - "Don't write tangled blocks to files, print them to stdout." - (cl-letf (((symbol-function 'write-region) - (lambda (start end filename &optional append visit lockname mustbenew) - (princ (buffer-string))))) - (apply fn args))) - -(defun *org-babel-tangle-collect-blocks (&optional language tangle-file) - "Like `org-babel-tangle-collect-blocks', but will ignore blocks that are in -trees with the :notangle: tag." - (let ((counter 0) last-heading-pos blocks) - (org-babel-map-src-blocks (buffer-file-name) - (let ((current-heading-pos - (org-with-wide-buffer - (org-with-limited-levels (outline-previous-heading))))) - (if (eq last-heading-pos current-heading-pos) (cl-incf counter) - (setq counter 1) - (setq last-heading-pos current-heading-pos))) - (unless (org-in-commented-heading-p) - (require 'org) - (let* ((tags (org-get-tags-at)) - (info (org-babel-get-src-block-info 'light)) - (src-lang (nth 0 info)) - (src-tfile (cdr (assq :tangle (nth 2 info))))) - (cond ((member "notangle" tags)) - - ((and (or or-tags and-tags) - (or (not and-tags) - (let ((a (cl-intersection and-tags tags :test #'string=)) - (b and-tags)) - (not (or (cl-set-difference a b :test #'equal) - (cl-set-difference b a :test #'equal))))) - (or (not or-tags) - (cl-intersection or-tags tags :test #'string=)) - t)) - - ((or (not (or all-blocks src-tfile)) - (string= src-tfile "no") ; tangle blocks by default - (and tangle-file (not (equal tangle-file src-tfile))) - (and language (not (string= language src-lang))))) - - ;; Add the spec for this block to blocks under its language. - ((let ((by-lang (assoc src-lang blocks)) - (block (org-babel-tangle-single-block counter))) - (if by-lang - (setcdr by-lang (cons block (cdr by-lang))) - (push (cons src-lang (list block)) blocks)))))))) - ;; Ensure blocks are in the correct order. - (mapcar (lambda (b) (cons (car b) (nreverse (cdr b)))) blocks))) -(advice-add #'org-babel-tangle-collect-blocks - :override #'*org-babel-tangle-collect-blocks) - -(defvar all-blocks nil) -(defvar and-tags nil) -(defvar or-tags nil) -(let (lang srcs and-tags or-tags) - (pop argv) - (while argv - (let ((arg (pop argv))) - (pcase arg - ((or "-h" "--help") - (usage) - (error "")) - ((or "-a" "--all") - (setq all-blocks t)) - ((or "-l" "--lang") - (setq lang (pop argv))) - ((or "-p" "--print") - (advice-add #'org-babel-tangle :around #'*org-babel-tangle)) - ((or "-t" "--tag" "--and") - (push (pop argv) and-tags)) - ("--or" - (push (pop argv) or-tags)) - ((guard (string-match-p "^--lang=" arg)) - (setq lang (cadr (split-string arg "=" t t)))) - ((guard (file-directory-p arg)) - (setq srcs - (append (directory-files-recursively arg "\\.org$") - srcs))) - ((guard (file-exists-p arg)) - (push arg srcs)) - (_ (error "Unknown option or file: %s" arg))))) - - (dolist (file srcs) - (let ((backup (make-temp-file (file-name-base file) nil ".backup.org"))) - (unwind-protect - ;; Prevent slow hooks from interfering - (let (org-mode-hook org-confirm-babel-evaluate) - ;; We do the ol' switcheroo because `org-babel-tangle' writes - ;; changes to the current file, which would be imposing on the user. - (copy-file file backup t) - (with-current-buffer (find-file-noselect file) - ;; Tangling doesn't expand #+INCLUDE directives, so we do it - ;; ourselves, since includes are so useful for literate configs! - (org-export-expand-include-keyword) - (org-babel-tangle nil nil lang))) - (ignore-errors (copy-file backup file t)) - (ignore-errors (delete-file backup))))) - (kill-emacs 0)) diff --git a/.config/emacs/docs/appendix.org b/.config/emacs/docs/appendix.org @@ -1,207 +0,0 @@ -:PROPERTIES: -:ID: ca20678f-0f1a-4462-a599-da03f0e16330 -:END: -#+title: Appendix -#+subtitle: A glossary of (Doom) Emacs terms, acronyms, & concepts -#+startup: nonum show2levels* - -* Glossary -** General :category: -- Calendar Version, Calendar Versioning :: See https://calver.org. -- Semantic Version, Semantic Versioning :: See https://semver.org. - -** Vim/Evil :category: -- leader key :: TODO -- localleader key :: TODO - -** Environment Variables :category: -- $DOOMDIR :: The location of the user's private configuration for Doom Emacs; - usually found in =~/.config/doom= or =~/.doom.d=. - -- $EMACSDIR :: The location of your Emacs initfile. This is where Doom users - will have cloned Doom's core to (=~/.config/emacs= or =~/.emacs.d=). - -** Doom Emacs :category: -- Doom module :: A toggle-able collection of configuration, packages, and - functions, made for Doom Emacs. - -** Emacs :category: -- ELPA :: Emacs-Lisp Package Archive. Used either to refer to the - GNU package repository or to all ELPA repositories as an ecosystem (e.g. - MELPA, Marmalade, etc). -- MELPA :: ELPA -- GNU ELPA :: ELPA - -*** Configurations :category: -- Emacs bankruptcy :: To reset your Emacs configuration from scratch, usually - because the old one has gotten too messy or complicated, and working backwards - would be too much hassle. - -- Emacs framework :: A foundation for your own Emacs Lisp projects, offering - tools to make it easier to build on top of it. - -- Starter kit :: A library of preconfiguration for Emacs, intended to spare you - the time and effort of configuring Emacs yourself. - -*** User Interface :category: -- Emacs buffer :: A [[https://www.gnu.org/software/emacs/manual/html_node/elisp/Buffers.html#Buffers][buffer]] is a space in Emacs memory containing text to be edited. - Buffers are used to hold the contents of files that are being edited or - opened; there may also be buffers that are not visiting files they display - other information like Dired that shows the content of a directory. Each - buffer, including the current buffer, may or may not be displayed in any - windows. - -- Echo area :: The [[https://www.gnu.org/software/emacs/manual/html_node/elisp/The-Echo-Area.html#The-Echo-Area][echo area]] is the last line of the frame. Unless the - minibuffer is active, this is the zone that shows all the messages Emacs sends - to the user - - #+begin_quote - The *echo area* is used for displaying error messages (see [[https://www.gnu.org/software/emacs/manual/html_node/elisp/Errors.html#Errors][Errors]]), for - messages made with the `message` primitive, and for echoing keystrokes. It is - not the same as the minibuffer, despite the fact that the minibuffer appears - (when active) in the same place on the screen as the echo area. - #+end_quote - -- Emacs frame :: What the rest of the world calls windows. [[https://www.gnu.org/software/emacs/manual/html_node/elisp/Frames.html][Source]]. - -- Emacs fringe :: On graphical displays, Emacs draws [[https://www.gnu.org/software/emacs/manual/html_node/elisp/Fringes.html][fringes]] next to each window: thin - vertical strips down the sides which can display bitmaps indicating - truncation, continuation, horizontal scrolling, and so on. - -- Header line :: The [[https://www.gnu.org/software/emacs/manual/html_node/elisp/Header-Lines.html][header line]] is like a modeline (extra information line - about Emacs current state), that is displayed at the top of each window - instead of the bottom of them. - - Notable examples include N. Rougier displaying filename [[https://github.com/rougier/elegant-emacs][in the header line]], - and LSP-mode powered context information ([[https://emacs-lsp.github.io/lsp-mode/page/main-features/#breadcrumb-on-headerline]["breadcrumbs"]]) - - #+begin_quote - A window can have a *header line* at the top, just as it can have a mode line - at the bottom. The header line feature works just like the mode line - feature[…] - #+end_quote - -- Display margins :: A buffer can have blank areas called [[https://emacsdocs.org/docs/elisp/Display-Margins][display margins]] on the - left and on the right. Ordinary text never appears in these areas, but you can - put things into the display margins using the `display` property. - - Margins tend to be a lot larger than fringes, as margins are at least as wide - as characters that you'd want to display there. It is almost always disabled: - relevant information can be almost always also be shown in fringes, and - fringes take way less screen real estate. - -- Minibuffer :: The [[https://emacsdocs.org/docs/emacs/Minibuffer][minibuffer]] is the buffer that takes over the last line of - your Emacs frame whenever Emacs prompts you (the user) for input. - - #+begin_quote - A *minibuffer* is a special buffer that Emacs commands use to read arguments - more complicated than the single numeric prefix argument. These arguments - include file names, buffer names, and command names (as in <kbd>M-x</kbd>). - The minibuffer is displayed on the bottom line of the frame, in the same place - as the echo area (see [[https://emacsdocs.org/docs/elisp/The-Echo-Area][The Echo Area]]), but only while it is in use for reading - an argument. - #+end_quote - -- The Mode line :: The Emacs [[https://emacsdocs.org/docs/emacs/Mode-Line][mode line]] is the status bar displayed under each - Emacs window. It's what vimmers know as the status line. - - #+begin_quote - Each Emacs window (aside from minibuffer windows) typically has a mode line at - the bottom, which displays status information about the buffer displayed in - the window. The mode line contains information about the buffer, such as its - name, associated file, depth of recursive editing, and major and minor modes. - #+end_quote - -- Emacs window :: A [[https://emacsdocs.org/docs/elisp/Windows][window]] is an area of the screen that is used to display a - buffer (see Emacs buffer). - -*** Editing :category: -- Kill :: Cut (in the Cut/Copy/Paste sense) - - #+begin_quote - *Kill functions* delete text like the deletion functions, but save it so that - the user can reinsert it by *yanking* . Most of these functions have ‘kill-' - in their name. […] Killed text is saved for later yanking in the *kill ring*. - #+end_quote - -- Major mode :: A [[https://emacsdocs.org/docs/emacs/Major-Modes][major mode]] is akin to file types/modes to vimmers/others. They - specialize Emacs for editing or interacting with particular kinds of text. - Each buffer has exactly one major mode at a time. - -- Minor mode :: A [[https://emacsdocs.org/docs/emacs/Minor-Modes][minor mode]] provides optional features that users may enable or - disable independently of the choice of major mode. Minor modes can be enabled - individually or in combination. - - Most minor modes implement features that are independent of the major mode, - and can thus be used with most major modes. For example, Auto Fill mode works - with any major mode that permits text insertion. - -- Yank :: Paste (contrary to vim). The most common pitfall to avoid when coming - from Vim, is that in Emacs, yanking_ is _pasting_. - - #+begin_quote - Yanking means inserting text from the kill ring - #+end_quote - -*** Emacs Lisp :category: -- Alist :: An [[https://emacsdocs.org/docs/elisp/Association-Lists][association list]] is one of the main datatype used in Emacs Lisp. - It's a list of key-value cons cells (essentially tuples). - -- Association list :: Alist - -- Interactive command :: https://emacsdocs.org/docs/elisp/Defining-Commands - -- Doc string :: Short for [[https://emacsdocs.org/docs/elisp/Function-Documentation][documentation string]] is information that is embedded - in a variable or function. Their docstring can be read when looking up - functions with [[kbd:][C-h f]] or variables with [[kbd:][C-h v]]. - -*** Keybinds :category: -- Universal argument :: See - https://emacsdocs.org/docs/elisp/Prefix-Command-Arguments. This is a special - key you use to modify the command you invoke directly afterwards. - - For example, if you take a command called ~delete-stuff~, bound to [[kbd:][C-c d]] that - tells you it will "delete the current line, or delete the whole buffer if - prefix argument is set"; then - - - [[kbd:][C-c d]] will delete a line - - [[kbd:][M-x delete-stuff RET]] will delete a line - - [[kbd:][C-u C-c d]] will delete the whole buffer - - [[kbd:][C-u M-x delete-stuff RET]] will delete the whole buffer. - - The goal of the universal/prefix argument is to get a slightly different - behaviour for known commands. - - #+begin_quote - 📌 Doom users with evil enabled will find the universal argument on [[kbd:][SPC u]] - instead than [[kbd:][C-u]]. - #+end_quote - -- Prefix argument :: Universal argument - -- Prefix key :: A "prefix" is a key that begins a key sequence. For instance, - the key sequence [[kbd:][C-x C-k b]] is comprised of three distinct input events. Both - [[kbd:][C-x]] and [[kbd:][C-x C-k]] can be considered prefixes. - - Prefix keys allow to store and move keybindings in groups. For example by - default all [[doom-package:lsp-mode]] commands are under ~SPC c l ...~, but if you want to - change that prefix to ~SPC L ...~ for all [[doom-package:lsp-mode]] commands, it is a one liner - in your configuration; you do _not_ have to rebind each command manually to - its new ~SPC L ...~ variant. - -** Repositories :category: -- doomemacs/core :: https://git.doomemacs.org/core -- doomemacs/modules :: https://git.doomemacs.org/modules -- doomemacs/contrib-modules :: https://git.doomemacs.org/contrib-modules -- doomemacs/themes :: https://git.doomemacs.org/themes -- doomemacs/snippets :: https://git.doomemacs.org/snippets - -* Acronyms -- CD :: Continuous Delivery -- CI :: Continuous Integration -- CLI :: Command-Line Interface -- PR :: (Github) Pull Request -- PRed :: PR -- YMMV :: Your mileage may vary - -* Text Substitutions diff --git a/.config/emacs/docs/contributing.org b/.config/emacs/docs/contributing.org @@ -1,171 +0,0 @@ -#+TITLE: Contributing -#+STARTUP: nofold - -Doom Emacs is an active and ongoing project, maintained mostly by a single -person, but includes the efforts of 200 contributors and growing. There is no -shortage of things that need doing; bugs that need stomping, features that need -implementing, and documentation that needs documenting. If Doom's been useful to -you, convert some caffiene into code; it'd be a huge help! - -You are welcome to [[https://discord.gg/qvGgnVx][join us on our Discord server]], otherwise read on to learn how -to contribute to our fine corner of the interwebs. - -* Table of Contents :TOC_3: -- [[#where-can-i-help][Where can I help?]] -- [[#reporting-issues][Reporting issues]] - - [[#acquire-a-backtrace-from-errors][Acquire a backtrace from errors]] - - [[#create-a-step-by-step-reproduction-guide][Create a step-by-step reproduction guide]] - - [[#include-information-about-your-doom-install][Include information about your Doom install]] - - [[#debugging-crashes-with-gdb][Debugging crashes with gdb]] -- [[#suggesting-features-keybinds-andor-enhancements][Suggesting features, keybinds and/or enhancements]] -- [[#contributing-code][Contributing code]] - - [[#conventions][Conventions]] - - [[#code-style][Code style]] - - [[#naming-conventions][Naming conventions]] - - [[#commits--prs][Commits & PRs]] - - [[#keybind-conventions][Keybind conventions]] - - [[#your-first-code-contribution][Your first code contribution]] - - [[#submitting-pull-requests][Submitting pull requests]] - - [[#contributing-to-doom-core][Contributing to Doom core]] - - [[#contributing-to-an-existing-module][Contributing to an existing module]] - - [[#contributing-a-new-module][Contributing a new module]] -- [[#contributing-documentation][Contributing documentation]] - - [[#contributing-to-dooms-manual][Contributing to Doom's manual]] - - [[#contributing-module-documentation][Contributing module documentation]] -- [[#help-keep-packages-up-to-date][Help keep packages up-to-date!]] -- [[#other-ways-to-support-doom-emacs][Other ways to support Doom Emacs]] -- [[#special-thanks][Special thanks]] - -* Where can I help? -+ Our [[https://github.com/hlissner/doom-emacs/issues][issue tracker]] has many issues. If you find one that you have an answer to, - it would be a huge help! -+ Look for issues tagged [[https://github.com/hlissner/doom-emacs/labels/good%20first%20issue][good first issue]]. These were judged to have a low - barrier of entry. -+ Look for issues tagged [[https://github.com/hlissner/doom-emacs/labels/help%20wanted][help wanted]]. These tend to be a little (or a lot) - harder, and are issues outside my own expertise. -+ If you've encountered a bug, [[https://github.com/hlissner/doom-emacs/issues/new/choose][file a bug report]]. -+ The [[https://github.com/hlissner/doom-emacs/projects/3][development roadmap board]] is a rough timeline of what is being worked on - and when. It will give you an idea of what will change and where you can - redirect your efforts. -+ The [[https://github.com/hlissner/doom-emacs/projects/2][plugins under review board]] lists third party plugins being considered (or - rejected) for inclusion in Doom Emacs. Approved and unclaimed packages are - open for you to implement yourself. -+ The [[https://github.com/hlissner/doom-emacs/projects/5][upstream bugs board]] lists known issues that have external causes, but - affect Doom. If you're feeling adventurous (or are better acquainted with the - cause) perhaps you can address them at the source. - -* TODO Reporting issues -You've found a problem and you're ready to fire off that bug report. Hold up! -Before you do that, [[file:getting_started.org::*Troubleshoot][have a look at our Troubleshooting guide]]. If none of these -suggestions pan out, /then/ it is time to file a bug report. - -An effective bug report is informative. Please try to provide: - -+ A backtrace of all mentioned errors. -+ A step-by-step reproduction of the issue. -+ Information about your Doom config and system environment. -+ Screenshots/casts of the issue (if possible). - -This section will show you how to collect this information. - -** Acquire a backtrace from errors -See "[[file:getting_started.org::*How to extract a backtrace from an error][How to extract a backtrace from an error]]" in the [[file:getting_started.org][Getting Started]] guide. - -** TODO Create a step-by-step reproduction guide - -** TODO Include information about your Doom install - -** TODO Debugging crashes with gdb - -* TODO Suggesting features, keybinds and/or enhancements - -* TODO Contributing code -There's much to be done around here! We need bugfixes, new features, and -documentation. If you'd like to convert some caffeine into Emacs Lisp, here are -a few considerations before starting that PR: - -** TODO Conventions -*** TODO Code style -Doom conforms to [[https://github.com/bbatsov/emacs-lisp-style-guide][@bbatsov's emacs-lisp style guide]] with the following -exceptions: - -+ Use ~mapc~ instead of ~seq-do~. -+ No hanging parentheses -+ We use =DEPRECATED= to indicate code that will eventually be removed. - -*** Naming conventions -Doom has a number of naming conventions that it uses in addition to the standard -lisp conventions. Third party packages may use their own conventions as well. - -**** Lisp Naming Conventions -The lisp conventions are simple. Symbols follow ~NAMESPACE-SYMBOLNAME~ for -public variables/functions (e.g. ~bookmark-default-file~ or -~electric-indent-mode~) and ~NAMESPACE--SYMBOLNAME~ for private ones (e.g. -~byte-compile--lexical-environment~ and ~yas--tables~). - -~NAMESPACE~ is usually the name of the containing file or package. E.g. the -~company~ plugin prefixes all its variables/functions with ~company-~. - -**** Doom Naming Conventions -+ ~doom/NAME~ or ~+MODULE/NAME~ :: Denotes a public command designed to be used - interactively, via =M-x= or a keybinding. e.g. ~doom/info~, ~+popup/other~, - ~+ivy/rg~. -+ ~doom:NAME~ :: A public evil operator, motion or command. e.g. ~+evil:align~, - ~+ivy:rg~. -+ ~doom-[-]NAME-h~ or ~+MODULE-[-]NAME-h~ :: A non-interactive function meant to - be used (exclusively) as a hook. e.g. ~+cc-fontify-constants-h~, - ~+flycheck-buffer-h~. -+ ~doom-[-]NAME-a~ or ~+MODULE-[-]NAME-a~ :: Functions designed to be used as - advice for other functions. e.g. ~doom-set-jump-a~, - ~doom--fix-broken-smie-modes-a~, ~+org--babel-lazy-load-library-a~ -+ ~doom-[-]NAME-fn~ or ~+MODULE-[-]NAME-fn~ :: Indicates an [[https://en.wikipedia.org/wiki/Strategy_pattern][strategy]] function. A - good rule of thumb for what makes a strategy function is: is it - interchangeable? Can it be replaced with another function with a matching - signature? e.g. ~+lookup-dumb-jump-backend-fn~, ~+magit-display-buffer-fn~, - ~+workspaces-set-project-action-fn~ -+ ~abc!~ :: A public Doom "autodef" function or macro. An autodef should always - be defined, even if its containing module is disabled (i.e. they will not - throw a void-function error). The purpose of this is to avoid peppering module - configs with conditionals or `after!` blocks before using their APIs. They - should noop if their module is disabled, and should be zero-cost in the case - their module is disabled. - - Autodefs usually serve to configure Doom or a module. e.g. ~after!~, - ~set-company-backends!~, ~set-evil-initial-state!~ - -*** TODO Commits & PRs -- Target the correct branch: - - =rewrite-docs= for changes to =*.org= files. - - =master= for everything else. - - /Never/ =develop=. It's EOL. -- Consult [[https://gist.github.com/hlissner/bb6365626d825aeaf5e857b1c03c9837][our do-not-PR list]] for things we won't accept pull requests for. - -*** TODO Keybind conventions - -** TODO Your first code contribution - -** TODO Submitting pull requests - -** TODO Contributing to Doom core - -** TODO Contributing to an existing module - -** TODO Contributing a new module - -* TODO Contributing documentation -Doom Emacs' documentation is an ongoing effort. If you have suggestions, -improvements, tutorials and/or articles to submit, don't hesitate to get in -contact via our [[https://discord.gg/bcZ6P3y][Discord server]] or [[mailto:henrik@lissner.net][email]]. I appreciate any help I can get! - -** TODO Contributing to Doom's manual - -** TODO Contributing module documentation - -* TODO Help keep packages up-to-date! -Doom pins all its packages to reduce the likelihood of upstream breakage leaking -into Doom Emacs. However, we may miss when a package releases hotfixes for -critical issues. Let us know or PR a bump to our pinned packages. - -* TODO Other ways to support Doom Emacs - -* TODO Special thanks diff --git a/.config/emacs/docs/examples.org b/.config/emacs/docs/examples.org @@ -1,1014 +0,0 @@ -:PROPERTIES: -:ID: e103c1bc-be8e-4451-8e43-a93d9e35e692 -:END: -#+title: Examples -#+subtitle: Samples of Emacs/Doom dotfiles, concepts, and sub-projects -#+property: header-args:elisp :results pp - -* Introduction -Examples speak louder than technical explanations, so this file exists to house -examples of Doom's (and Emacs') concepts, libraries, dotfiles, and more, for -your own reference. They are divided into Emacs-specific and Doom-specific -examples; where the former can also be useful to users who don't use Doom. - -Some of Doom's components will read this file to generate documentation for you, -for example: - -- Doom's [[doom-module:][:lang emacs-lisp]] module installs the [[doom-package:elisp-demos]] package. This displays - usage examples alongside documentation in [[doom-package:help]] and [[doom-package:helpful]] buffers (produced - by =describe-*= and =helpful-*= commands; e.g. [[kbd:][<help> h f]]). Doom has extended - this package to search this file as well. -- [[id:1b8b8fa9-6233-4ed8-95c7-f46f8e4e2592][Some Doom's CLI commands]] will emit documentation informed by Doom's org files, - including this file. - -If you're interested in adding to this document, read [[id:9ac0c15c-29e7-43f8-8926-5f0edb1098f0][the documentation section]] -of our contributing guide first. - -* TODO Emacs -This section is dedicated to examples of concepts and libraries that can benefit -all Emacs users, whether or not they use Doom. - -** TODO Emacs Lisp :demos: -**** file-name-with-extension -:PROPERTIES: -:added: 28.1 -:END: -#+begin_src emacs-lisp -(file-name-with-extension "some/file.cpp" "h") -#+end_src - -#+RESULTS: -: some/file.h - -**** file-name-concat -:PROPERTIES: -:added: 28.1 -:END: -#+begin_src emacs-lisp -(file-name-concat user-emacs-directory "lisp" "file.el") -#+end_src - -#+begin_src emacs-lisp -(file-name-concat "foo" "bar" "baz") -#+end_src - -#+RESULTS: -: foo/bar/baz - -** TODO Templates -*** TODO Emacs package -*** TODO Dynamic module - -* TODO Doom Emacs -This section is dedicated to examples of concepts and libraries only relevant to -Doom and its users. These are intended to be demonstrations, not substitutes for -documentation. - -** TODO Emacs Lisp :demos: -*** doom-lib -**** add-hook! -:PROPERTIES: -:added: 3.0.0-pre -:END: -#+begin_src emacs-lisp -;; With only one hook and one function, this is identical to `add-hook'. In that -;; case, use that instead. -(add-hook! 'some-mode-hook #'enable-something) - -;; Adding many-to-many functions to hooks -(add-hook! some-mode #'enable-something #'and-another) -(add-hook! some-mode '(enable-something and-another)) -(add-hook! '(one-mode-hook second-mode-hook) #'enable-something) -(add-hook! (one-mode second-mode) #'enable-something) - -;; Appending and local hooks -(add-hook! (one-mode second-mode) :append #'enable-something) -(add-hook! (one-mode second-mode) :local #'enable-something) - -;; With arbitrary forms -(add-hook! (one-mode second-mode) (setq v 5) (setq a 2)) -(add-hook! (one-mode second-mode) :append :local (setq v 5) (setq a 2)) - -;; Inline named hook functions -(add-hook! '(one-mode-hook second-mode-hook) - (defun do-something () - ...) - (defun do-another-thing () - ...)) -#+end_src - -**** TODO add-transient-hook! -:PROPERTIES: -:added: 3.0.0-pre -:END: -**** after! -:PROPERTIES: -:added: 3.0.0-pre -:END: -#+begin_src emacs-lisp :eval no -;;; `after!' will take: - -;; An unquoted package symbol (the name of a package) -(after! helm ...) - -;; An unquoted list of package symbols (i.e. BODY is evaluated once both magit -;; and git-gutter have loaded) -(after! (magit git-gutter) ...) - -;; An unquoted, nested list of compound package lists, using any combination of -;; :or/:any and :and/:all -(after! (:or package-a package-b ...) ...) -(after! (:and package-a package-b ...) ...) -(after! (:and package-a (:or package-b package-c) ...) ...) -;; (Without :or/:any/:and/:all, :and/:all are implied.) - -;; A common mistake is to pass it the names of major or minor modes, e.g. -(after! rustic-mode ...) -(after! python-mode ...) -;; But the code in them will never run! rustic-mode is in the `rustic' package -;; and python-mode is in the `python' package. This is what you want: -(after! rustic ...) -(after! python ...) -#+end_src -**** appendq! -:PROPERTIES: -:added: 3.0.0-pre -:END: -#+begin_src emacs-lisp -(let ((x '(a b c))) - (appendq! x '(c d e)) - x) -#+end_src - -#+RESULTS: -: (a b c c d e) - -#+begin_src emacs-lisp -(let ((x '(a b c)) - (y '(c d e)) - (z '(f g))) - (appendq! x y z '(h)) - x) -#+end_src - -#+RESULTS: -: (a b c c d e f g h) - -**** custom-set-faces! -:PROPERTIES: -:added: 3.0.0-pre -:END: -#+begin_src emacs-lisp :eval no -(custom-set-faces! - '(outline-1 :weight normal) - '(outline-2 :weight normal) - '(outline-3 :weight normal) - '(outline-4 :weight normal) - '(outline-5 :weight normal) - '(outline-6 :weight normal) - '(default :background "red" :weight bold) - '(region :background "red" :weight bold)) - -(custom-set-faces! - '((outline-1 outline-2 outline-3 outline-4 outline-5 outline-6) - :weight normal) - '((default region) - :background "red" :weight bold)) - -(let ((red-bg-faces '(default region))) - (custom-set-faces! - `(,(cl-loop for i from 0 to 6 collect (intern (format "outline-%d" i))) - :weight normal) - `(,red-bg-faces - :background "red" :weight bold))) - -;; You may utilise `doom-themes's theme API to fetch or tweak colors from their -;; palettes. No need to wait until the theme or package is loaded. e.g. -(custom-set-faces! - `(outline-1 :foreground ,(doom-color 'red)) - `(outline-2 :background ,(doom-color 'blue))) -#+end_src - -**** custom-theme-set-faces! -:PROPERTIES: -:added: 3.0.0-pre -:END: -#+begin_src emacs-lisp :eval no -(custom-theme-set-faces! 'doom-one - '(outline-1 :weight normal) - '(outline-2 :weight normal) - '(outline-3 :weight normal) - '(outline-4 :weight normal) - '(outline-5 :weight normal) - '(outline-6 :weight normal) - '(default :background "red" :weight bold) - '(region :background "red" :weight bold)) - -(custom-theme-set-faces! '(doom-one-theme doom-one-light-theme) - '((outline-1 outline-2 outline-3 outline-4 outline-5 outline-6) - :weight normal) - '((default region) - :background "red" :weight bold)) - -(let ((red-bg-faces '(default region))) - (custom-theme-set-faces! '(doom-one-theme doom-one-light-theme) - `(,(cl-loop for i from 0 to 6 collect (intern (format "outline-%d" i))) - :weight normal) - `(,red-bg-faces - :background "red" :weight bold))) - -;; You may utilise `doom-themes's theme API to fetch or tweak colors from their -;; palettes. No need to wait until the theme or package is loaded. e.g. -(custom-theme-set-faces! 'doom-one - `(outline-1 :foreground ,(doom-color 'red)) - `(outline-2 :background ,(doom-color 'blue))) -#+end_src - -**** TODO defer-feature! -:PROPERTIES: -:added: 3.0.0-pre -:END: -**** TODO defer-until! -:PROPERTIES: -:added: 3.0.0-pre -:END: -**** disable-packages! -:PROPERTIES: -:added: 3.0.0-pre -:END: -#+begin_src emacs-lisp :eval no -;; Disable packages enabled by DOOM -(disable-packages! some-package second-package) -#+end_src - -**** file-exists-p! -:PROPERTIES: -:added: 3.0.0-pre -:END: -#+begin_src emacs-lisp -(file-exists-p! "init.el" doom-emacs-dir) -#+end_src - -#+RESULTS: -: /home/hlissner/.emacs.d/init.el - -#+begin_src emacs-lisp -(file-exists-p! (and (or "doesnotexist" "init.el") - "LICENSE") - doom-emacs-dir) -#+end_src - -#+RESULTS: -: /home/hlissner/.emacs.d/LICENSE - -**** cmd! -:PROPERTIES: -:added: 3.0.0-pre -:END: -#+begin_src emacs-lisp :eval no -(map! "C-j" (cmd! (newline) (indent-according-to-mode))) -#+end_src - -**** cmd!! -:PROPERTIES: -:added: 3.0.0-pre -:END: -When ~newline~ is passed a numerical prefix argument (=C-u 5 M-x newline=), it -inserts N newlines. We can use ~cmd!!~ to easily create a keybinds that bakes in -the prefix arg into the command call: - -#+begin_src emacs-lisp :eval no -(map! "C-j" (cmd!! #'newline 5)) -#+end_src - -Or to create aliases for functions that behave differently: - -#+begin_src emacs-lisp :eval no -(fset 'insert-5-newlines (cmd!! #'newline 5)) - -;; The equivalent of C-u M-x org-global-cycle, which resets the org document to -;; its startup visibility settings. -(fset 'org-reset-global-visibility (cmd!! #'org-global-cycle '(4)) -#+end_src - -**** cmds! -:PROPERTIES: -:added: 3.0.0-pre -:END: -#+begin_src emacs-lisp :eval no -(map! :i [tab] (cmds! (and (modulep! :editor snippets) - (bound-and-true-p yas-minor-mode) - (yas-maybe-expand-abbrev-key-filter 'yas-expand)) - #'yas-expand - (modulep! :completion company +tng) - #'company-indent-or-complete-common) - :m [tab] (cmds! (and (bound-and-true-p yas-minor-mode) - (evil-visual-state-p) - (or (eq evil-visual-selection 'line) - (not (memq (char-after) (list ?\( ?\[ ?\{ ?\} ?\] ?\)))))) - #'yas-insert-snippet - (and (modulep! :editor fold) - (save-excursion (end-of-line) (invisible-p (point)))) - #'+fold/toggle - (fboundp 'evil-jump-item) - #'evil-jump-item)) -#+end_src - -**** kbd! -:PROPERTIES: -:added: 3.0.0-pre -:END: -#+begin_src emacs-lisp :eval no -(map! "," (kbd! "SPC") - ";" (kbd! ":")) -#+end_src - -**** lambda! -#+begin_src emacs-lisp -(mapcar (lambda! ((&key foo bar baz)) - (list foo bar baz)) - '((:foo 10 :bar 25) - (:baz hello :boop nil) - (:bar 42))) -#+end_src - -**** fn! -#+begin_src emacs-lisp -(mapcar (fn! (symbol-name %)) '(hello world)) -#+end_src - -#+begin_src emacs-lisp -(seq-sort (fn! (string-lessp (symbol-name %1) - (symbol-name %2))) - '(bonzo foo bar buddy doomguy baz zombies)) -#+end_src - -#+begin_src emacs-lisp -(format "You passed %d arguments to this function" - (funcall (fn! (length %*)) :foo :bar :baz "hello" 123 t)) -#+end_src - -**** load! -:PROPERTIES: -:added: 3.0.0-pre -:END: -#+begin_src emacs-lisp :eval no -;;; Lets say we're in ~/.doom.d/config.el -(load! "lisp/module") ; loads ~/.doom.d/lisp/module.el -(load! "somefile" doom-emacs-dir) ; loads ~/.emacs.d/somefile.el -(load! "anotherfile" doom-user-dir) ; loads ~/.doom.d/anotherfile.el - -;; If you don't want a `load!' call to throw an error if the file doesn't exist: -(load! "~/.maynotexist" nil t) -#+end_src - -**** map! -:PROPERTIES: -:added: 3.0.0-pre -:END: -#+begin_src emacs-lisp :eval no -(map! :map magit-mode-map - :m "C-r" 'do-something ; C-r in motion state - :nv "q" 'magit-mode-quit-window ; q in normal+visual states - "C-x C-r" 'a-global-keybind - :g "C-x C-r" 'another-global-keybind ; same as above - - (:when IS-MAC - :n "M-s" 'some-fn - :i "M-o" (cmd! (message "Hi")))) - -(map! (:when (modulep! :completion company) ; Conditional loading - :i "C-@" #'+company/complete - (:prefix "C-x" ; Use a prefix key - :i "C-l" #'+company/whole-lines))) - -(map! (:when (modulep! :lang latex) ; local conditional - (:map LaTeX-mode-map - :localleader ; Use local leader - :desc "View" "v" #'TeX-view)) ; Add which-key description - :leader ; Use leader key from now on - :desc "Eval expression" ";" #'eval-expression) -#+end_src - -These are side-by-side comparisons, showing how to bind keys with and without -~map!~: - -#+begin_src emacs-lisp :eval no -;; bind a global key -(global-set-key (kbd "C-x y") #'do-something) -(map! "C-x y" #'do-something) - -;; bind a key on a keymap -(define-key emacs-lisp-mode-map (kbd "C-c p") #'do-something) -(map! :map emacs-lisp-mode-map "C-c p" #'do-something) - -;; unbind a key defined elsewhere -(define-key lua-mode-map (kbd "SPC m b") nil) -(map! :map lua-mode-map "SPC m b" nil) - -;; bind multiple keys -(global-set-key (kbd "C-x x") #'do-something) -(global-set-key (kbd "C-x y") #'do-something-else) -(global-set-key (kbd "C-x z") #'do-another-thing) -(map! "C-x x" #'do-something - "C-x y" #'do-something-else - "C-x z" #'do-another-thing) - -;; bind global keys in normal mode -(evil-define-key* 'normal 'global - (kbd "C-x x") #'do-something - (kbd "C-x y") #'do-something-else - (kbd "C-x z") #'do-another-thing) -(map! :n "C-x x" #'do-something - :n "C-x y" #'do-something-else - :n "C-x z" #'do-another-thing) - -;; or on a deferred keymap -(evil-define-key 'normal emacs-lisp-mode-map - (kbd "C-x x") #'do-something - (kbd "C-x y") #'do-something-else - (kbd "C-x z") #'do-another-thing) -(map! :map emacs-lisp-mode-map - :n "C-x x" #'do-something - :n "C-x y" #'do-something-else - :n "C-x z" #'do-another-thing) - -;; or multiple maps -(dolist (map (list emacs-lisp-mode go-mode-map ivy-minibuffer-map)) - (evil-define-key '(normal insert) map - "a" #'a - "b" #'b - "c" #'c)) -(map! :map (emacs-lisp-mode go-mode-map ivy-minibuffer-map) - :ni "a" #'a - :ni "b" #'b - :ni "c" #'c) - -;; or in multiple states (order of states doesn't matter) -(evil-define-key* '(normal visual) emacs-lisp-mode-map (kbd "C-x x") #'do-something) -(evil-define-key* 'insert emacs-lisp-mode-map (kbd "C-x x") #'do-something-else) -(evil-define-key* '(visual normal insert emacs) emacs-lisp-mode-map (kbd "C-x z") #'do-another-thing) -(map! :map emacs-lisp-mode - :nv "C-x x" #'do-something ; normal+visual - :i "C-x y" #'do-something-else ; insert - :vnie "C-x z" #'do-another-thing) ; visual+normal+insert+emacs - -;; You can nest map! calls: -(evil-define-key* '(normal visual) emacs-lisp-mode-map (kbd "C-x x") #'do-something) -(evil-define-key* 'normal go-lisp-mode-map (kbd "C-x x") #'do-something-else) -(map! (:map emacs-lisp-mode :nv "C-x x" #'do-something) - (:map go-lisp-mode :n "C-x x" #'do-something-else)) -#+end_src - -**** pushnew! -:PROPERTIES: -:added: 3.0.0-pre -:END: -#+begin_src emacs-lisp -(let ((list '(a b c))) - (pushnew! list 'c 'd 'e) - list) -#+end_src - -#+RESULTS: -: (e d a b c) - -**** prependq! -:PROPERTIES: -:added: 3.0.0-pre -:END: -#+begin_src emacs-lisp -(let ((x '(a b c))) - (prependq! x '(c d e)) - x) -#+end_src - -#+RESULTS: -: (c d e a b c) - -#+begin_src emacs-lisp -(let ((x '(a b c)) - (y '(c d e)) - (z '(f g))) - (prependq! x y z '(h)) - x) -#+end_src - -#+RESULTS: -: (c d e f g h a b c) - -**** quiet! -:PROPERTIES: -:added: 3.0.0-pre -:END: -#+begin_src emacs-lisp :eval no -;; Enters recentf-mode without extra output -(quiet! (recentf-mode +1)) -#+end_src -**** remove-hook! -:PROPERTIES: -:added: 3.0.0-pre -:END: -#+begin_src emacs-lisp :eval no -;; With only one hook and one function, this is identical to `remove-hook'. In -;; that case, use that instead. -(remove-hook! 'some-mode-hook #'enable-something) - -;; Removing N functions from M hooks -(remove-hook! some-mode #'enable-something #'and-another) -(remove-hook! some-mode #'(enable-something and-another)) -(remove-hook! '(one-mode-hook second-mode-hook) #'enable-something) -(remove-hook! (one-mode second-mode) #'enable-something) - -;; Removing buffer-local hooks -(remove-hook! (one-mode second-mode) :local #'enable-something) - -;; Removing arbitrary forms (must be exactly the same as the definition) -(remove-hook! (one-mode second-mode) (setq v 5) (setq a 2)) -#+end_src -**** setq! -:PROPERTIES: -:added: 3.0.0-pre -:END: -#+begin_src emacs-lisp -;; Each of these have a setter associated with them, which must be triggered in -;; order for their new values to have an effect. -(setq! evil-want-Y-yank-to-eol nil - evil-want-C-u-scroll nil - evil-want-C-d-scroll nil) -#+end_src -**** setq-hook! -:PROPERTIES: -:added: 3.0.0-pre -:END: -#+begin_src emacs-lisp :eval no -;; Set multiple variables after a hook -(setq-hook! 'markdown-mode-hook - line-spacing 2 - fill-column 80) - -;; Set variables after multiple hooks -(setq-hook! '(eshell-mode-hook term-mode-hook) - hscroll-margin 0) -#+end_src - -**** unsetq-hook! -:PROPERTIES: -:added: 3.0.0-pre -:END: -#+begin_src emacs-lisp :eval no -(unsetq-hook! 'markdown-mode-hook line-spacing) - -;; Removes the following variable hook -(setq-hook! 'markdown-mode-hook line-spacing 2) - -;; Removing N variables from M hooks -(unsetq-hook! some-mode enable-something and-another) -(unsetq-hook! some-mode (enable-something and-another)) -(unsetq-hook! '(one-mode-hook second-mode-hook) enable-something) -(unsetq-hook! (one-mode second-mode) enable-something) -#+end_src -**** versionp! -:PROPERTIES: -:added: 3.0.0-pre -:END: -#+begin_src emacs-lisp -(versionp! "25.3" > "27.1") -#+end_src - -#+RESULTS: -: nil - -#+begin_src emacs-lisp -(versionp! "28.0" <= emacs-version <= "28.1") -#+end_src - -#+RESULTS: -: t - -*** doom-modules -**** doom! -:PROPERTIES: -:added: 3.0.0-pre -:END: -#+begin_src emacs-lisp :eval no -(doom! :completion - company - ivy - ;;helm - - :tools - (:if IS-MAC macos) - docker - lsp - - :lang - (cc +lsp) - (:cond ((string= system-name "work-pc") - python - rust - web) - ((string= system-name "writing-pc") - (org +dragndrop) - ruby)) - (:if IS-LINUX - (web +lsp) - web) - - :config - literate - (default +bindings +smartparens)) -#+end_src - -**** use-package! -:PROPERTIES: -:added: 3.0.0-pre -:END: -#+begin_src emacs-lisp :eval no -;; Use after-call to load package before hook -(use-package! projectile - :after-call (pre-command-hook after-find-file dired-before-readin-hook)) - -;; defer recentf packages one by one -(use-package! recentf - :defer-incrementally easymenu tree-widget timer - :after-call after-find-file) - -;; This is equivalent to :defer-incrementally (abc) -(use-package! abc - :defer-incrementally t) -#+end_src - -**** package! -:PROPERTIES: -:added: 3.0.0-pre -:END: -#+begin_src emacs-lisp :eval no -;; To install a package that can be found on ELPA or any of the sources -;; specified in `straight-recipe-repositories': -(package! evil) -(package! js2-mode) -(package! rainbow-delimiters) - -;; To disable a package included with Doom (which will no-op all its `after!' -;; and `use-package!' blocks): -(package! evil :disable t) -(package! rainbow-delimiters :disable t) - -;; To install a package from a github repo -(package! so-long :recipe (:host github :repo "hlissner/emacs-so-long")) - -;; If a package is particularly big and comes with submodules you don't need, -;; you can tell the package manager not to clone the repo recursively: -(package! ansible :recipe (:nonrecursive t)) - -;; To pin a package to a specific commit: -(package! evil :pin "e7bc39de2f9") -;; ...or branch: -(package! evil :recipe (:branch "stable")) -;; To unpin a pinned package: -(package! evil :pin nil) - -;; If you share your config between two computers, and don't want bin/doom -;; refresh to delete packages used only on one system, use :ignore -(package! evil :ignore (not (equal system-name "my-desktop"))) -#+end_src - -*** doom-cli -**** TODO defcli! -**** TODO defcli-alias! -**** TODO defcli-obsolete! -**** TODO defcli-stub! -**** TODO defcli-autoload! -**** TODO defcli-group! -**** TODO exit! -**** TODO call! -**** TODO run! -**** TODO sh! -**** TODO sh!! -**** TODO git! -**** TODO def-cli-context-get -**** TODO def-cli-context-put -**** TODO def-cli-context-find-option -**** TODO def-cli-call -**** TODO def-cli-exit -**** TODO def-cli-load -**** TODO def-cli-load-all -**** TODO doom-cli-find -**** TODO doom-cli-get -**** TODO doom-cli-prop -**** TODO doom-cli-subcommands -**** TODO doom-cli-aliases -*** TODO lib/files.el -**** TODO doom-path -**** TODO doom-glob -**** TODO doom-dir -**** TODO doom-files-in -**** TODO doom-file-cookie-p -**** TODO file-exists-p! -**** TODO doom-file-size -**** TODO doom-file-line-count -**** TODO doom-directory-size -**** TODO doom-file-read -**** TODO doom-file-write -**** TODO with-file-contents! - -** TODO Configuration files -*** =profiles.el= -:PROPERTIES: -:ID: f9bce7da-d155-4727-9b6f-b566b5b8d824 -:END: -This file can live in any of: - -- =$DOOMDIR/profiles.el= -- =$EMACSDIR/profiles.el= -- =~/.config/doom-profiles.el= -- =~/.doom-profiles.el= - -Here is an exhaustive example of all its syntax and capabilities: -#+begin_src emacs-lisp -;; -*- mode: emacs-lisp; -*- -((profile1 - ;; The permitted formats of each entry: - (var . value) - ("envvar" . value) - (var :directive values...) - - ;; `user-emacs-directory' is often the first variable you want to set, so - ;; Emacs knows where this profile lives. If you don't, it'll use the config - ;; living in the default locations (~/.config/emacs or ~/.emacs.d). - (user-emacs-directory . "~/another/emacs/config/") - ;; If this is a Doom config, you'll also want to set `doom-user-dir', which - ;; defaults to ~/.config/doom or ~/.doom.d: - (doom-user-dir . "~/another/doom/config/") - ;; If a CAR is a string, it is assumed you want to set an environment - ;; variable. (Side-note: setting DOOMDIR will be unnecessary if you're setting - ;; `doom-user-dir' above). - ("DOOMDIR" . "~/another/doom/config/") - - ;; Doom profiles support a number of special directives. They are: - ;; - ;; (VAR :path SEGMENTS...) -- set VAR to an exapnded path built from SEGMENTS, - ;; relative to `user-emacs-directory', unless an absolute path is in SEGMENTS. - (doom-cache-dir :path doom-user-dir ".local/cache") - (doom-data-dir :path doom-user-dir ".local/data") - (doom-state-dir :path doom-user-dir ".local/state") - ;; (VAR :plist VALUE) -- use VALUE as a literal plist; ignoring any profile - ;; directives that may be in it. - (some-plist :plist (:foo bar :baz womp)) - ;; (VAR :eval FORMS...) -- use to evaluate arbitrary elisp forms. Note that - ;; his runs early in early-init.el. It's wise to assume no APIs are available - ;; or loaded, only the previous bindings in this profile. - (doom-theme :eval (if (equal (system-name) "foo") 'doom-one 'doom-dracula)) - ;; Though discouraged, you may evaluate forms without a binding by using `_'. - ;; You really should be doing this in the profile though... - (_ :eval (message "Hello world!")) - (_ :eval (with-eval-after-load 'company (setq-default company-idle-delay 2.0))) - ;; (VAR :prepend FORMS...) or (VAR :append FORMS...) -- prepend or append the - ;; evaluated result of each form in FORMS to VAR (a list). If VAR is undefined - ;; at startup, it will be deferred until the variable is available. - (load-path :prepend (expand-file-name "packages/" doom-user-dir)) - (load-path :prepend (expand-file-name "lisp/" doom-user-dir)) - (load-path :append (expand-file-name "fallback/" doom-user-dir)) - (exec-path :prepend (expand-file-name "bin/" doom-user-dir)) - (auto-mode-alist :prepend '("\\.el\\'" . lisp-mode))) - - (profile2 - ...) - - (profile3 - ...)) -#+end_src - -*** =.doomprofile= -:PROPERTIES: -:ID: ac37ac6f-6082-4c34-b98c-962bc1e528c9 -:END: -This file takes after the second level of =profiles.el='s format (see a more -complete example in [[id:f9bce7da-d155-4727-9b6f-b566b5b8d824][the previous section]]). For example: - -#+begin_src emacs-lisp -;;; -*- mode: emacs-lisp -*- -;; A .doomprofile can be placed under an implicit profile. Same rules as -;; .doom-profiles.el, but one level deeper. - -((var . value) - ("envvar" . value) - (var :directive values...)) -#+end_src - -*** TODO =.doomrc= -*** TODO =.doomproject= -*** TODO =.doommodule= -** TODO Templates -*** TODO User configuration -*** TODO Module -*** TODO Project -*** TODO Theme -*** TODO Command-line interface -**** Unix utilities, rewritten as Doom scripts -To show off the syntax and capabilities of Doom's CLI framework, here are some -popular scripts ported to doomscripts for reference. They will all operate under -these assumptions: - -1. The script lives somewhere in your =$PATH=, -2. =$EMACSDIR/bin/doomscript= lives in your =$PATH=. -3. The script is executable, -4. The script's filename matches the first argument of ~run!~ (by convention, - not a requirement), - -***** ~mkdir~ -#+begin_src emacs-lisp :eval no -#!/usr/bin/env doomscript - -(defcli! mkdir - ((mode ("-m" "--mode" mode)) - (parents? ("-p" "--parents")) - (verbose? ("-v" "--verbose")) - &args directories) - "Create the DIRECTORIES, if do not already exist. - -Mandatory arguments to long options are mandatory for short options too. - -OPTIONS: - -m, --mode - set file mode (as in chmod), not a=rwx - umask. - -p, --parents - no error if existing, make parent directories as needed, with their file - modes unaffected by any `-m' option. - -v, --verbose - print a message for each created directory - -AUTHOR: - Original program by David MacKenzie. Doomscript port by Henrik Lissner. - -SEE ALSO: - `mkdir(2)` - - Full documentation <https://www.gnu.org/software/coreutils/mkdir> - or available locally via: info '(coreutils) mkdir invocation' - - Packaged by https://nixos.org - Copyright © 2022 Free Software Foundation, Inc. - License GPLv3+: GNU GPL version 3 or later <https://gnu.org/li‐ - censes/gpl.html>. - This is free software: you are free to change and redistribute it. - There is NO WARRANTY, to the extent permitted by law." - (dolist (dir directories) - (unless (file-directory-p dir) - (make-directory dir parents?) - (when mode - (set-file-modes dir mode)) - (when verbose? - (print! "mkdir: created directory '%s'" dir))))) -#+end_src - -****** Notes -- Docstrings for Doom CLIs recognize indented sections with a capitalized - heading followed by a colon (like ~SEE ALSO:~, ~OPTIONS:~, etc). They will be - appended to the --help output for this command. ~OPTIONS~ and ~ARGUMENTS~ are - special, in that they decorate pre-existing documentation for referenced - options/arguments. - -- The options were documented in the CLI's docstring, instead of inline like so: - - #+begin_src emacs-lisp - ((mode ("-m" "--mode" mode) "set file modes (as in chmod), not a=rwx - umask.") - (parents? ("-p" "--parents") "no error if existing, make parent directories as needed, with their file modes unaffected by any `-m' option.") - (verbose? ("-v" "--verbose") "print a message for each created directory") - &args directories) - #+end_src - - Either is acceptable, but for long docs like this, it's better suited to the - docstring. If both were present, Doom's help docs would have concatenated them - (separated by two newlines). - -- The ~mode~ option takes one argument, a chmod mask. I indicate this with - ~"`MODE'"~. This is a special syntax for highlighting arguments in the help - docs of this command. If I had used a symbol, instead (one of the predefined - types in [[var:][doom-cli-argument-value-types]]), I would've gotten free type-checking - and error handling, but there is no predefined type for chmod masks (yet), so - I'd have to do my own checks: - - #+begin_src emacs-lisp :eval no - (defcli! mkdir - ((mode ("-m" "--mode" "`MODE'")) - (parents? ("-p" "--parents")) - (verbose? ("-v" "--verbose")) - &args directories) - (unless (string-match-p "^[0-9]\\{3,4\\}$" mode) - (user-error "Invalid mode: %s" mode)) - (setq mode (string-to-number mode 8)) - (dolist (dir directories) - (unless (file-directory-p dir) - (make-directory dir parents?) - (when mode - (set-file-modes dir mode)) - (when verbose? - (print! "mkdir: created directory '%s'" dir))))) - #+end_src - - That said, set-file-modes will throw its own type error, but it likely won't - be as user friendly. - -***** TODO ~say~ -#+begin_src emacs-lisp :eval no -#!/usr/bin/env doomscript - -(defcli! say - ((name ("--speaker" name) "Who is speaking?") - &args args) - "This command repeats what you say to it. - -It serves as an example of the bare minimum you need to write a Doom-based CLI. -Naturally, it could be more useful; it could process more complex options and -arguments, call other Doom CLIs, read/write data from files or over networks -- -but that can wait for more complicated examples. - -ARGUMENTS: - ARGS - The message to be repeated back at you. - -OPTIONS: - --speaker - If not specified, it is assumed that Emacs is speaking." - (print! "%s says: %S" - (or name "Emacs") - (string-join args " "))) - -(run! "say" (cdr (member "--" argv))) -#+end_src - -#+begin_src bash :eval no -$ say hello world -Emacs says: "Hello world" -$ say --speaker Henrik "I've doomed us all" -Henrik says: "I've doomed us all" -$ say --help -TODO -#+end_src - -***** emacs -This isn't useful, but it should hopefully demonstrate the full spectrum of -Doom's CLI, by reimplementing a subset of ~emacs~'s options and arguments (and -none of its documentation). It will simply forward them to the real program -afterwards. - -Since I don't want to override the real ~emacs~ in the ~$PATH~, I'll just call -it ~demacs~: - -#+begin_src emacs-lisp :eval no -#!/usr/bin/env doomscript - -(defcli! demacs - ((cd ("--chdir" dir)) - (quick? ("-Q" "--quick")) - (no-init? ("-q" "--no-init-file")) - (no-slisp? ("-nsl" "--no-site-lisp")) - (no-sfile? ("--no-site-file")) - (initdir ("--init-directory" dir)) - (batch? ("--batch")) - (batch (("-l" "--load" (file) ...)) - (("-e" "--eval" (form) ...)) - (("-f" "--funcall" (fn) ...)) - (("-L" "--directory" (dir) ...)) - (("--kill"))) - (script ("--script" (file))) - &args (args (file linecol))) - "Demacs is a thin wrapper around Emacs, made to demo of Doom's CLI Framework. - -Since documentation isn't the focus of this example, this is all you'll get!" - (cond (script (load script)) - (batch? - (dolist (do batch) - (pcase do - (`(,(or "-l" "--load") . ,file) (load file)) - (`(,(or "-e" "--eval") . ,form) (eval (read form) t)) - (`(,(or "-f" "--funcall") . ,fn) (funcall (read fn))) - (`("--kill" . t) (kill-emacs 0))))) - ((exit! :then (cons "emacs" - (append (if quick '("-Q")) - (if no-init? '("-q")) - (if no-slisp? '("-nsl")) - (if no-sfile? '("--no-site-file")) - (if initdir `("--init-directory" ,initdir)) - args)))))) -#+end_src - -****** Notes -There's a lot of (intentional) redundancy here, for posterity. A *much* simpler -(and more reliable) version of this command would've looked like this: - -#+begin_src emacs-lisp -(defcli! demacs (&rest args) - (exit! :then (cons "emacs" args))) -#+end_src - -But that wouldn't demonstrate enough. Though, it wouldn't forward ~--version~ or -~--help~ either. - -** TODO Use cases -*** TODO Note-taking -*** TODO Game development -*** TODO Web development -*** TODO Emacs as your terminal diff --git a/.config/emacs/docs/faq.org b/.config/emacs/docs/faq.org @@ -1,983 +0,0 @@ -:PROPERTIES: -:ID: 5fa8967a-532f-4e0c-8ae8-25cd802bf9a9 -:END: -#+title: Frequently Asked Questions -#+subtitle: Answers to common issues and questions -#+startup: nonum show2levels* - -* General -:PROPERTIES: -:ID: 3c17177d-8ba9-4d1a-a279-b6dea21c8a9a -:END: -This section is for general questions about the Doom Emacs project and its -author. - -** Is Emacs (or Doom) for me? -:PROPERTIES: -:ID: 6f325ee8-228a-4b05-8ce9-4a997948d46a -:END: -These four sections of [[id:a3bf32ae-8218-48c1-a7d9-a6fd61e5734a][our user manual]] answer this question: - -- [[id:fba3642f-b01e-405b-80ac-2900df22e978][Why Emacs?]] -- [[id:e3172459-abcb-45cb-9135-9692f320a836][Why /not/ Emacs?]] -- [[id:46d2058d-249e-45a7-a7a2-58bade48df65][Why Doom?]] -- [[id:da317a3c-1672-40e2-85d5-b4246482af2c][Why /not/ Doom?]] - -** How does Doom compare to <insert starter kit>? -I've compiled comparisons to several starter kits in [[id:f2186c7b-9f48-4b0b-ac0b-d891b5b1e1b3][our migration guide]]. - -** Is Doom a fork of another starter kit? -No. I started Doom from scratch in 2013 to learn Emacs and Emacs Lisp, and to -write a private config for myself. Starter kits were brought to my attention -later, when early Doom users vocally compared them. - -That's not to say I've taken no inspiration from them since. Doom's earliest -file structure was inspired by Prelude's, until it was replaced with a module -system. Other concepts (like [[kbd:][SPC]] as a leader key) came from Spacemacs or were -PRed from migrating users, and were accepted because they seemed sensible. - -More similarities (and differences) will no doubt emerge as our userbase grows -and more starter kits appear. - -** Doom claims to be an Emacs framework, not a starter kit. What's the difference? -I don't claim to own these terms, but I use them to distinguish [[https://git.doomemacs.org/core][Doom's core]] (a -framework) from [[https://git.doomemacs.org/modules][Doom's module library]] (a starter kit). - -My premise is: starter kits and Emacs frameworks have different goals. Where -starter kits help you avoid work by doing it for you, an Emacs framework helps -you /do/ that work yourself, but more effectively (by providing extra tools, -APIs, or organizational systems for writing/debugging). Of course, there will be -some crossover. - -** Who maintains Doom Emacs? -My name is [[https://github.com/hlissner][Henrik]], I'm this project's author and its sole maintainer, for the -moment. I plan to onboard co-maintainers once the project has: - -- Proper technical documentation for users, contributors, and - maintainers. Many important organizational questions haven't been formally - answered or committed to paper: such as our versioning scheme, git - conventions, community policies, and code/documentation style guides. Even - Doom's goals aren't formally stated anywhere. -- More unit, integration, and package tests. Total coverage isn't required (or - desired), but Emacs issues are complex and esoteric, so /some/ measure of - automated sanity checks (and protocols for merges and releases) are needed to - spare future maintainers a stroll through a minefield. -- Resolved its stability, performance, and standardization issues that plague - its CLI. Issues too esoteric for me to unleash onto unsuspecting - co-maintainers in good conscience. I could live with them when Doom was my - private config, but that is no longer the case. It needs to be rewritten. - -Most of these issues will be resolved in the final 3.0.0 release. - -I am looking for [[id:29d9a145-8f2e-4d22-b4d0-de8a2c72698d][module maintainers]] though! - -** Why is the project called "Doom"? -As a kid in the Cretaceous period (1999), the [[https://github.com/id-Software/DOOM][source code]] of idsoftware's -classic Doom was my first exposure to programming. Totally clueless about C and -compilers, all I could do was peek at it from time to time and hope I'd absorb -its secrets if I stared hard enough. It didn't work, but it sure jump-started by -gamedev addiction. - -So "Doom Emacs" was what you got when you combined childhood, demon-carnage -nostalgia, [[https://www.youtube.com/user/n4sco][terrible]] [[https://github.com/hlissner/emacs-solaire-mode][naming]] [[https://github.com/hlissner/vim-forrestgump][sense]], and the sneaking suspicion that Emacs is the -unwritten tenth circle Dante censored for humanity's protection. - -I've doomed us all. - -** Why does Doom use straight.el and not package.el? -=package.el= simply doesn't cut it. Its flaws become apparent the more packages -you manage, the more complex your config becomes, and how often those packages -see updates: - -- No disaster recovery :: - When things go wrong, we don't always have time to deal with it. Or we need to - wait for upstream to deploy a fix. While we wait, we still have work to do, - but now what? Emacs is broken! =package.el= doesn't give you any options to - roll back, so you /have/ to deal with it, and now. Or hope your old config was - backed up. - - Though Doom doesn't have a 'doom rollback' command (yet), the ability to - quickly checkout an old commit of a problematic package (or Doom itself), - without the overhead of forking and/or maintaining a local copy, is priceless. -- Rolling release or bust :: - =package.el= installs the latest version of every package, or none at all. - There's no rollback, no pinning to a stable ref, and no git history to peek - into. It offers little reproducibility; wiping/losing/copying your config - becomes a gamble if you aren't constantly backing up your packages (then - recompiling them if you're up/downgrading Emacs). - - =melpa-stable= was well intentioned, but it offers no guarantees or standards - on how/when maintainers tag their projects. I'd rather the user decide for - themselves, because they're the ones in the trenches. -- Can't install packages from superior sources :: - Often, a crucial fix sits in a pull request somewhere for too long, a package - becomes outdated through official channels, or a superior fork springs up - somewhere other than an ELPA. =package.el= cannot reach those sources. -- Slow at startup (by default) :: - Initializing =package.el= can be expensive, depending on the number (and - complexity) of installed packages -- especially for batch scripts. - ~package-quickstart~ helps, up to a point, but Doom's package manager can do - better with the assumptions available to its monolithic ecosystem. All without - imposing =straight.el= or =package.el= on your runtime environments. - -Package management needs to be easier, because Emacs is hard enough already. -Doom fills these gaps with =straight.el='s help, and beyond. - -Granted, you /can/ get most of the above with a little Git know-how, but it -stops being convenient as you reach package 5 or 15, your tenacity permitting. - -** Why is startup time important? Why not use the daemon? -It isn't, but it gets a disproportional amount of attention because it's the -first thing Doom's users notice. Doom is perfectly compatible with the daemon -and I don't intend to discourage its use. If I had to say something about it, -it's that I'm unhappy that a daemon is needed at all to get sane startup times -out of Emacs. - -It's left to the user to know or care about optimal load paths, and to implement -them, but that's a lot to ask when the problem domain is so vast, esoteric, and -a moving target (with a high cost-to-benefit). Who has the time to inspect, much -less fix, all their packages? And maintain that effort across Emacs or package -updates? It's easier to use the daemon, so people do. - -That said, there's no one to blame for that. I consider Doom's effort, the -daemon, even native compilation (though all excellent endeavors) stop-gap -measures for a deeper, underlying issue in Emacs that needs smarter people than -I to address. - -Rather than startup time, runtime performance is a bigger priority, though the -two rarely stray far from each other. - -** Where do I follow the development of the project? -:PROPERTIES: -:ID: 4af14dad-5b74-43a7-8c9a-153227eed4a9 -:END: -Our development resources are listed [[id:a20e3feb-f1e4-4bd3-92a9-6dfb17bcb24b][in our manual]]. - -** Where do I report issues, request features, or get user support? -Check out [[id:2f277e96-654d-406f-8797-b9a7d2ccc218][our community resources]] for a complete list of communities and -platforms. I'd recommend [[https://discourse.doomemacs.org/get-help][our Discourse]]. - -** I don't like Discord. Can Doom move to IRC/Telegram/Matrix/other? -This is requested *a lot*--and not always so kindly. We have [[https://discourse.doomemacs.org][a Discourse]] and -[[https://discourse.doomemacs.org/t/a-matrix-space-for-doom-emacs/2664/12][there are plans for a Matrix space]], but that's as many platforms as I have -bandwidth for. Please do not ask me to reconsider. - -** How do I add a question to the FAQ? -:PROPERTIES: -:ID: aa28b732-0512-49ed-a47b-f20586c0f051 -:END: -There is no submission process for FAQs. Our community leaders select them from -our Discord, Discourse, and Github communities (sometimes elsewhere) based on -frequency (actual or anticipated). Ask your questions there. If they make the -cut they will naturally find their way here. - -* How do I... -:PROPERTIES: -:ID: 9c81ab2a-7da9-4b8e-9f90-d4ebff8bebbb -:END: -For common how-to and configuration questions from Doom users. You'll find more -[[https://discourse.doomemacs.org/tags/faq][on our Discourse]]. - -** Find out what version of Doom am I running? -Use ~M-x doom/info~ or ~$ doom info~ to produce detailed information about your -installation and environment. - -Alternatively, ~M-x doom/version~ or ~$ doom version~ will only list the -versions of installed Doom components. - -The installed version of Doom core is also displayed in the Doom dashboard's -mode-line. - -** Turn (Doom) Emacs into a <insert language here> IDE with LSP? -:PROPERTIES: -:ID: 4cec77b2-bb1c-4b35-8ad1-d6dd9fcc1dbb -:END: -This is frequently asked: how to transform Doom Emacs into an IDE for some -programming language. In almost all cases, it's recommended that you enable -Doom's LSP support and install a supported LSP client. - -This provides code completion, lookup {definition,references,documentation} -functionality, and syntax checking, all in one: - -1. Enable Doom's [[doom-module::tools lsp]] module. ([[id:01cffea4-3329-45e2-a892-95a384ab2338][How do I enable modules?]]) -2. Enable the ~+lsp~ flag on the ~:lang~ module corresponding to the language - you want LSP support for. E.g. For python, enable [[doom-module::lang python +lsp]]. For - rust, enable [[doom-module::lang rust +lsp]]. ([[id:01cffea4-3329-45e2-a892-95a384ab2338][How do I enable module flags?]]) -3. Install [[https://emacs-lsp.github.io/lsp-mode/page/languages/][a supported LSP client]] on your system using your OS package manager - OR from within Emacs using ~M-x lsp-install-server~ (warning: not all servers - can be installed this way). -4. Run ~$ doom sync~ on the command line. -5. Restart Emacs. -6. (Optional) If Emacs fails to find your LSP server, you may need to run ~$ - doom env~ to regenerate your envvar file (which contains your =$PATH=, which - tells Emacs where to find programs on your system). - -*** Potential issues -1. Some language modules lack LSP support (either because it doesn't exist or - I'm not aware of it -- let me know!). If you're certain a language is - supported by [[doom-package:lsp-mode]], simply adding [[fn:lsp!]] to that major mode's hook will be - enough to enable it: - - #+begin_src elisp - ;; Remember to replace MAJOR-MODE with the major mode that powers the language. - ;; E.g. `ruby-mode-local-vars-hook' or `python-mode-local-vars-hook' - (add-hook 'MAJOR-MODE-local-vars-hook #'lsp! 'append) - - ;; For Elisp gurus: Doom provides MAJOR-MODE-local-vars-hook, and we use it - ;; instead of MAJOR-MODE-hook because it runs later in the mode's startup - ;; process (giving other functionality or packages -- like direnv -- time to - ;; configure the LSP client). - #+end_src - -2. Some languages have alternatives that are superior to the LSP offerings (such - as Cider for Clojure or Sly for Common Lisp). - -When in doubt, check that language module's documentation! Look up a module's -documentation with [[kbd:][<help> d m]] (or ~M-x doom/help-modules~). - -** Change my fonts -Doom exposes a couple variables for setting fonts. They are: - -- [[var:doom-font]]: the primary font for Emacs to use. -- [[var:doom-variable-pitch-font]]: used for non-monospace fonts (e.g. when using - variable-pitch-mode or mixed-pitch-mode). Popular for text modes, like Org or - Markdown. -- [[var:doom-unicode-font]]: used for rendering unicode glyphs. This is ~Symbola~ by - default. It is ignored if the [[doom-module::ui unicode]] module is enabled. -- [[var:doom-serif-font]]: the sans-serif font to use wherever the [[face:fixed-pitch-serif]] - face is used. -- [[var:doom-big-font]]: the large font to use when [[fn:doom-big-font-mode]] is active. - -Each of these variables accept one of: - -- A font-spec object: ~(font-spec :family "FontName" :size 12.0 :weight 'light)~ -- An xft font string: - - Short form: ~"JetBrainsMono-12"~ - - Long form: ~"Terminus (TTF):pixelsize=12:antialias=off"~ -- An XLFD string: ~"-*-Fira Code-regular-normal-normal-*-11-*-*-*-*-*-*-*"~ - -For example: -#+begin_src emacs-lisp -;; in $DOOMDIR/config.el -(setq doom-font (font-spec :family "JetBrainsMono" :size 12 :weight 'light) - doom-variable-pitch-font (font-spec :family "DejaVu Sans" :size 13) - doom-unicode-font (font-spec :family "Symbola") - doom-big-font (font-spec :family "JetBrainsMono" :size 24)) -#+end_src - -#+begin_quote - 🚧 If you or Emacs can't find your font, use ~M-x describe-font~ to look them - up, or run ~$ fc-list~ to see all the available fonts on your system. *Font - issues are /rarely/ Doom issues!* -#+end_quote - -*** To change fonts on the fly: -1. Select your ~setq~ statements, -2. Evaluate them with ~M-x eval-region~ (evil users can use the [[kbd:][gr]] operator to - evaluate regions of elisp, non-evil users can use [[kbd:][C-x C-e]]), -3. Then reload the fonts: ~M-x doom/reload-font~. - -Your changes should take effect immediately. - -** Change, customize, or make themes? -- To change themes, add ~(setq doom-theme 'name-of-theme)~ to - =$DOOMDIR/config.el=. -- To switch themes on-the-fly, type [[kbd:][<help> t]] or ~M-x load-theme~. -- To customize or write themes, see our guide on [[https://discourse.doomemacs.org/t/how-to-switch-customize-or-write-themes/37][the Discourse]]. - -** Properly update Doom? -You can update Doom one of two ways: - -1. The correct way: by running ~$ doom upgrade~ in the shell and restarting - Emacs. -2. The manual way (if ~doom upgrade~ is broken for some reason): - - #+begin_src bash - $ cd ~/.emacs.d - $ git pull # pull the latest version of Doom's source - $ doom sync -u # update Doom's packages and 'doom sync' - #+end_src - -This may change in the future, so ~$ doom upgrade~ will always be the safest -option. That said, ~$ doom help upgrade~ will always document the correct -procedure for manual updates if you need it. - -** Bind my own keys (or change existing ones)? -Emacs provides a couple functions to bind keys: - -- ~define-key KEYMAP KEY DEF~ -- ~global-set-key KEY DEF~ -- ~local-set-key KEY DEF~ -- ~evil-define-key STATES KEYMAP KEY DEF &rest ...~ - -However, Doom provides a more general ~map!~ macro, to conveniently wrap up the -above four into a more succinct syntax. Comprehensive examples of ~map!~'s usage -can be found in its documentation (keyboard shortcut: [[kbd:][<help> f map\!]]). - -There are also live examples =map!='s usage in -=config/default/+evil-bindings.el=. - -Unfortunately, binding keys in Emacs can be a complicated affair. A more -detailed guide on keys, keymaps, and keymap precedence can be found [[https://discourse.doomemacs.org/t/how-to-re-bind-keys/56][on our -Discourse]]. - -** Change or alias the leader or localleader key? -This is documented in more detail in our user manual: - -- [[id:76df34eb-142c-4280-85e7-b231d8adafc5][How to change your leader keys]] -- [[id:58741e77-c44b-4292-b9c9-5eb7da36fa21][How to bind new keys under the leader prefix]] -- [[id:8e0d2c05-6028-4e68-a50d-b81851f3f258][How to bind aliases for your leader / localleader prefix]] - -** Change the style of (or disable) line-numbers? -Doom uses the [[doom-package:display-line-numbers]] package, which is included with Emacs 26+. - -*** To disable line numbers entirely -#+begin_src emacs-lisp -;;; in $DOOMDIR/config.el -(setq display-line-numbers-type nil) -;; or -(remove-hook! '(prog-mode-hook text-mode-hook conf-mode-hook) - #'display-line-numbers-mode) -#+end_src - -*** To switch to relative line numbers -To change the style of line numbers, change the value of the -~display-line-numbers-type~ variable. It accepts the following values: -#+begin_example -t normal line numbers -'relative relative line numbers -'visual relative line numbers in screen space -nil no line numbers -#+end_example - -For example: -#+begin_src emacs-lisp -;;; add to $DOOMDIR/config.el -(setq display-line-numbers-type 'relative) -#+end_src - -You'll find more precise documentation on the variable through [[kbd:][<help> v -display-line-numbers-type]] ([[kbd:][<help>]] is [[kbd:][SPC h]] for [[doom-package:evil]] users, [[kbd:][C-h]] otherwise). - -*** To cycle through different styles of line numbers -Use ~M-x doom/toggle-line-numbers~ (bound to [[kbd:][<leader> t l]] by default) to cycle -through the available line number styles in the current buffer. - -E.g. ~normal -> relative -> visual -> disabled -> normal~ - -** Disable Evil (vim emulation)? -By disabling the [[doom-module::editor evil]] module ([[id:01cffea4-3329-45e2-a892-95a384ab2338][how to toggle modules]]). - -Read the "[[id:f3925da6-5f0b-4d11-aa08-7bb58bea1982][Removing evil-mode]]" section in the module's documentation for precise -instructions. - -** Know when to run ~$ doom sync~? -:PROPERTIES: -:ID: 594d2505-d3cb-4061-ab76-06e7c8a4e0b8 -:END: -As a rule of thumb, run ~$ doom sync~ whenever you: - -- Update Doom with ~$ git pull~ instead of ~$ doom upgrade~, -- Change your ~doom!~ block in =$DOOMDIR/init.el=, -- Change =autoload.el= or =autoload/*.el= files in any module (or =$DOOMDIR=), -- Change the =packages.el= file in any module (or =$DOOMDIR=). -- Install an Emacs package or dependency outside of Emacs (i.e. through your OS - package manager). - -If anything is misbehaving, it's a good idea to run ~$ doom sync~ first, to rule -out any issues with missing packages or autoloads. - -This command is never needed for changes to =$DOOMDIR/config.el=. - -** Suppress confirmation prompts when executing a doom command? -~-!~ or ~--force~ are the universal "suppress all prompts" switch for most -=doom= commands. - -** Copy or sync my config to another system? -*Short answer:* it is safe to sync =$DOOMDIR= across systems, but not -=$EMACSDIR=. Once moved, use ~$ doom sync && doom build~ to ensure everything is -set up correctly. - -*Long answer:* packages can contain baked-in absolute paths and non-portable -byte-code. It is never a good idea to mirror it across multiple systems, unless -they are all the same (same OS, same version of Emacs, same paths). Most issues -should be solved by running ~$ doom sync && doom build~ on the other end, once -moved. - -** Start over, in case something went terribly wrong? -Delete =$EMACSDIR/.local/straight= and run ~$ doom sync~. - -** Restore the s and S keys to their default vim behavior ([[doom-ref:][#1307]]) -[[kbd:][s]] and [[kbd:][S]] have been intentionally replaced with the [[doom-package:evil-snipe]] plugin, which -provides 2-character versions of the f/F/t/T motion keys, ala [[https://github.com/goldfeld/vim-seek][vim-seek]] or -[[https://github.com/justinmk/vim-sneak][vim-sneak]]. - -These keys were changed because they are redundant with [[kbd:][cl]] and [[kbd:][cc]] respectively -(and the new behavior was deemed more useful). - -If you still want to restore the old behavior, simply disable evil-snipe-mode: -#+begin_src emacs-lisp -;; in $DOOMDIR/config.el -(remove-hook 'doom-first-input-hook #'evil-snipe-mode) -#+end_src - -* Common issues -:PROPERTIES: -:ID: 9adcf3a0-add2-4135-b918-e1d7f406c80d -:END: -For problems that come up especially often. You'll find more [[https://discourse.doomemacs.org][on our Discourse]] -and [[https://github.com/doomemacs/doomemacs/issues][Github issue tracker]]. Consult [[id:14040b81-3dd3-422e-abce-245f4c03d1b4][our troubleshooting guide]] for help debugging -issues. - -** Doom and/or Emacs is slow -:PROPERTIES: -:ID: 643acc75-9717-4739-9c52-3947491e827e -:END: -The answer changes from version to version (of Emacs), and is often updated with -new information, so [[https://discourse.doomemacs.org/t/why-is-emacs-doom-slow/83][this is answered on Discourse]] instead. - -** Doom starts up with a vanilla splash screen -The most common cause for this is a =~/.emacs= file. If it exists, Emacs will -read this file instead of the =~/.emacs.d= directory, ignoring Doom altogether. - -If this isn't the case, run ~$ doom doctor~. It can detect a variety of common -issues and may offer you clues. - -** I see a scratch buffer at startup instead of the dashboard -The common explanations for this are: - -- Emacs can't find your private doom config (in =~/.doom.d= or - =~/.config/doom=). Make sure only one of these two folders exist, and that it - has an =init.el= file with a ~doom!~ block. Running ~$ doom install~ will - create these files and directories for you. - -- An error occurred while starting up Doom. Use [[kbd:][C-h e]] to inspect Emacs' log. - Search it for errors or warnings. If you find one, [[id:aa116c29-b7d5-488a-860f-bdb22c1f4e8e][producing a backtrace]] from - the error can shed more light on it (and will be required if you ask the - community for help debugging it). - -- You have disabled the [[doom-module::ui doom-dashboard]] module. Read about - [[id:5e267107-81fa-45b4-8ff3-26d4b98e508e][what Doom modules are]] and [[id:01cffea4-3329-45e2-a892-95a384ab2338][how to - toggle them]]. - -If you're still stuck, run ~$ doom doctor~. It can detect a variety of common -issues and may give you some clues as to what is wrong. - -** Doom fails to find executables (or inherit my shell's =$PATH=) -The three most common causes for =$PATH= issues in Doom are: - -1. Your shell configuration doesn't configure =$PATH= correctly. Run ~$ which - <PROGRAM>~ in your shell. If it doesn't emit the path you expect (or any path - at all) then you need to modify you shell config to do so correctly. -2. Your app launcher (rofi, albert, docky, dmenu, sxhkd, etc) is launching Emacs - with the wrong shell, either because it defaults to a different shell from - the one you actively use or the app launcher itself inherits the wrong - environment because it is being launched from the wrong shell. -3. You're a Mac user launching Emacs from an =Emacs.app= file. MacOS launches - these apps from an isolated environment. - -As long as your shell is properly configured, there is a simple solution to -issues #1 and #3: generate an envvar file by running ~$ doom env~. This scrapes -your shell environment into a file that is loaded when Doom Emacs starts up. Run -~$ doom help env~ for details on how this works. - -For issue #2, you'll need to investigate your launcher. There are too many -launchers write a walkthrough for, you'll have better luck asking about it on -[[https://doomemacs.org/discord][our Discord]] or [[https://discourse.doomemacs.org][Discourse]]. - -** Changes to my config aren't taking effect -1. Make sure you don't have both =~/.doom.d= and =~/.config/doom= directories. - Doom will ignore the first if the second exists. -2. Remember to run ~$ doom sync~ after making [[id:594d2505-d3cb-4061-ab76-06e7c8a4e0b8][certain changes]] to your config. - Run ~$ doom help sync~ to know exactly when you should use it. -3. If you are reconfiguring a package, make sure you've deferred your settings - until the package loads with the ~after!~ macro: - - #+begin_src emacs-lisp - (after! magit - (setq magit-repository-directories '(("~/projects" . 2)) - magit-save-repository-buffers nil)) - #+end_src - - There are two exceptions to this rule: - #+begin_src emacs-lisp - ;; Setting file/directory variables don't (and shouldn't be) deferred. e.g. - (setq org-directory "~/org") - - ;; Don't defer setting variables whose documentation explicitly say they must - ;; be set *before* the package is loaded. e.g. - (setq evil-respect-visual-line-mode t) - #+end_src - -If none of these solve your issue, try ~$ doom doctor~. It will detect a variety -of common issues, and may give you some clues as to what is wrong. Otherwise, -consult [[id:2f277e96-654d-406f-8797-b9a7d2ccc218][the community]]. - -** Doom crashes and/or freezes -Here are a few common causes for random crashes: - -- Some fonts cause Emacs to crash when they lack support for a particular glyph - (typically symbols). Try changing your font by changing ~doom-font~ or - ~doom-unicode-font~. - -- Ligatures can cause Emacs to crash. Try a different [[doom-module::ui ligatures +fira][ligature font]] or disable - the [[doom-module::ui ligatures]] module altogether. - -- On some systems (particularly MacOS), manipulating the fringes or window - margins can cause Emacs to crash. This is most prominent in Doom's Dashboard - (which uses the margins to center its contents), in org-mode buffers (which - uses ~org-indent-mode~ to create virtual indentation), or Magit (whose fringes - are adjusted on the fly). - - There is currently no known fix for this, as it can't be reliably reproduced. - Your best bet is to reinstall/rebuild Emacs or disable the errant - plugins/modules. - - E.g. To disable ~org-indent-mode~: - #+begin_src emacs-lisp - ;; in $DOOMDIR/config.el - (after! org - (setq org-startup-indented nil)) - #+end_src - - Or disable the [[doom-module::ui doom-dashboard]] and [[doom-module::tools magit]] modules (see [[doom-ref:][#1170]]). - -If these don't help, check our troubleshooting guides for [[id:f88eaf35-97c4-48de-85ef-2d53f8615d4a][hard crashes]] or -[[id:0b744192-c648-452d-ba62-1b4c76dc3aee][freezes/hangs]]. - -** TRAMP connections hang forever when connecting -You'll find solutions [[https://www.emacswiki.org/emacs/TrampMode#toc7][on the emacswiki]]. - -** Why do I see ugly indentation highlights for tabs? -[[https://github.com/doomemacs/doomemacs/blob/4eeb3c7a19c324f5a7839a2e3edb03fc87d23034/core/core-ui.el#L97-L116][Doom highlights non-standard indentation]]. i.e. Indentation that doesn't match -the indent style you've set for that file. Spaces are Doom's default style for -most languages (excluding languages where tabs are the norm, like Go). - -There are a couple ways to address this: - -1. Fix your indentation! If it's highlighted, you have tabs when you should have - spaces (or spaces when you should be using tabs). - - Two easy commands for that: - - ~M-x tabify~ - - ~M-x untabify~ - -2. Change ~indent-tabs-mode~ (~nil~ = spaces, ~t~ = tabs) in - =$DOOMDIR/config.el=: - - #+begin_src emacs-lisp - ;; use tab indentation everywhere - (setq-default indent-tabs-mode t) - - ;; or only in certain modes - (setq-hook! 'sh-mode-hook indent-tabs-mode t) ; shell scripts - (setq-hook! '(c-mode-hook c++-mode-hook) indent-tabs-mode t) ; C/C++ - #+end_src - -3. Use [[https://editorconfig.org/][editorconfig]] to configure code style on a per-project basis. If you - enable Doom's [[doom-module::tools editorconfig]] module, Doom will recognize - =.editorconfigrc= files. - -4. Or trust in [[doom-package:dtrt-indent]]; a plugin Doom uses to analyze and detect indentation - when you open a file (that isn't in a project with an editorconfig file). - This isn't foolproof, and won't work for files that have no content in them, - but it can help in one-off scenarios. - -** "The directory =~/.emacs.d/server= is unsafe" error at startup (Windows only) -If you're getting this error you must reset the owner of -=C:\Users\USERNAME\.emacs.d= to your own account: - -1. Right-click the =~/.emacs.d/server= directory in Windows Explorer, -2. Click Properties, -3. Select the "Security" tab, -4. Click the "Advanced" button, -5. Select the "Owner" tab, -6. Change the owner to your account name. - -([[https://stackoverflow.com/questions/885793/emacs-error-when-calling-server-start][source]]) - -** My new keybinds don't work -Emacs has a complex and hierarchical keybinding system. If a global keybind -doesn't take effect, it's likely that another keymap is in effect with higher -priority than the global keymap. For example, non-evil users may have tried -something like this, to rebind [[kbd:][C-left]] and [[kbd:][C-right]]: -#+begin_src emacs-lisp -(map! "<C-left>" #'something - "<C-right>" #'something) -#+end_src - -Just to find that the rebinding had no effect (i.e. [[kbd:][C-h k C-left]] reports that -it's still bound to ~sp-backward-slurp-sexp~). That's because these keys are -bound in ~smartparens-mode-map~. They need to be unbound for your global -keybinds to work: -#+begin_src emacs-lisp -(map! :after smartparens - :map smartparens-mode-map - [C-right] nil - [C-left] nil) -#+end_src - -#+begin_quote - 📌 I use [C-left] because it is easier to type than "<C-left>", but they are - equivalent; two different ways to refer to the same key. -#+end_quote -** Recursive load error on startup -If you see an error like: -#+begin_example -Error: error ("Recursive load" - "/Applications/Emacs.app/Contents/Resources/lisp/jka-compr.el.gz" - "/Applications/Emacs.app/Contents/Resources/lisp/jka-compr.el.gz" - "/Applications/Emacs.app/Contents/Resources/lisp/jka-compr.el.gz" - "/Applications/Emacs.app/Contents/Resources/lisp/jka-compr.el.gz" - "/Applications/Emacs.app/Contents/Resources/lisp/jka-compr.el.gz" - "/Applications/Emacs.app/Contents/Resources/lisp/obsolete/cl.el.gz") -#+end_example - -Then these are the three most common explanations: - -- *GNU* =tar= and/or =gzip= are not installed on your system. - - #+begin_quote - 🚧 *Warning macOS and *BSD distro users:* you likely have BSD variants of - =tar= and =gzip= installed by default. Emacs requires the GNU variants! - #+end_quote - -- =tar= and/or =gzip= aren't in your =$PATH=, somehow. Once you've corrected - your shell config, run ~$ doom env~ to regenerate your envvar file (containing - the =$PATH= Doom will see), then restart Emacs. - -- *(macOS users only)* You've installed Emacs from one of the sources I - recommend you avoid. For example, emacsformacosx.com. Our user manual outlines - where you should acquire Emacs from. - -If none of the above help, then [[id:3f3ea085-dbba-4d28-a56f-852f386249c1][file a bug report]]. - -* Contributors -:PROPERTIES: -:ID: 1afe59e5-0c67-4b70-a5b6-e7978ccf4220 -:END: -For folks who want to report bugs and submit pull requests. - -** How can I contribute to the project? -Our contributor's manual covers [[id:94f1eee7-eb2d-4d03-9881-7e36fbd82e4f][a bunch of ways you can help or support the -project]]. - -** How do I get my pull request processed ASAP? -:PROPERTIES: -:ID: 1223f94f-7c3f-4870-8a58-b94e8d7cbbb3 -:END: -The project does not have a dedicated support team -- only one overworked -[[doom-user:hlissner][meatball]] and a handful of busy volunteers -- so there may be delays processing -your PR. Sometimes this is unavoidable, but there are some measures you can take -to mitigate these delays: - -- Ensure there are no open PRs that tackle the same issue. If yours is intended - to replace an existing one, please mention it. -- Include an explanation: why the PR is necessary, what it fixes, any gotchas I - should be aware of, and issues it affects. -- Be acquainted with our [[id:46442b23-a7ae-44ba-afdb-b7ba8bb76b6e][git commit conventions]]. Good commit etiquette is - required. Do not be afraid to rebase or force-push to tidy up your PR, once it - is ready for review. -- Adhere to our [[id:b3d85a53-a544-44e5-9353-06e413bd7f30][code]], [[id:9bb17259-0b07-45a8-ae7a-fc5e0b16244e][documentation]], and [[id:cc55968b-f430-45e4-9e05-4c6187871b9d][keybind]] conventions, where applicable. -- Ensure you've targeted the =master= branch. -- Keep your PR focused. It shouldn't do too much in too many places, if that can - be avoided. -- If your PR introduces new tools, dependencies, or packages, I'm going to test - them. It takes time to research them, acquire them, learn how to use them, and - finally test them in the context of your PR. You can speed this up by - including steps to set up an MVE with some mock inputs and expected results. - - Extra points if you supply a =shell.nix= or =Dockerfile= to do so (if - applicable). - -** My PR was approved but not merged, what gives? -I approve PRs in bulk, often days before merging them. This is done to: - -- Allow me to merge them when I have time to respond to regressions they may - cause. -- Give me a second chance to catch issues, -- Give the submitter extra time to correct mistakes, -- Give users a change to test it themselves, - -If your PR was approved, you only have to wait for Henrik to get off his -glorious Canadian behind and merge it. If it's been a week or so with no -progress, feel free to ping him in-thread or [[https://doomemacs.org/discord][on Discord]] (in the #contributing -channel). - -** Why was my issue deleted or tagged "delete me"? -:PROPERTIES: -:ID: 33641f29-7ed5-4a8c-a494-98ff1693349b -:END: -Due to the sheer complexity of Emacs, our issue tracker receives many -false-positive, redundant, vague, or "support request"-type issues. This is a -problem because they pollute our search results, make it difficult for users and -maintainers to track real issues, and cost much effort to process; taking away -time from real issues or project development. - -Since Doom's "support team" only consists of one overworked maintainer and a -handful of busy volunteers, we have to be strict; we don't have the capacity to -chase issues that aren't *actionable*, *immediately reproducible*, or *cannot be -investigated within a reasonable amount of time* (which includes issues that are -poorly researched, vague, or open-ended). - -Posts that fall into these categories will be immediately closed, tagged for -deletion, and given a brief explanation why, including instructions to overturn -or contest the ruling if I've made a mistake. - -Some examples: -- Performance issues without a clear, verifiable, or reproducible cause. -- Behavior that can't be reproduced in [[id:04f91253-a92a-4125-a576-44de226582bb][vanilla Doom]]. -- Behavior that can be reproduced in vanilla Emacs. -- An open-ended request to improve something without concrete goals. -- An issue that consists solely of "X doesn't work" and little else. -- An issue that omits important information, like steps to reproduce or system - information. -- A post asking how to configure or use Emacs to achieve some effect (our issue - tracker is for bug reports, not support; ask on [[https://doomemacs.org/discord][Discord]] or [[https://discourse.doomemacs.org][Discourse]] instead). -- A convoluted and unfocused issue that present multiple issues in one. -- A rude user that won't meet us half way and/or expects us to do all the work - for them. - -To ensure your issue makes the cut, please consult "[[id:1223f94f-7c3f-4870-8a58-b94e8d7cbbb3][How do I ensure my issue -gets processed ASAP?]]" above. - -** How do I create and maintain a PR branch for Doom Emacs? -[[id:40f24cd4-8108-411d-bdcd-0a2ef945b1e3][Our contributing guide offers a few techniques]]. - -* Sponsors -:PROPERTIES: -:ID: 739da458-feb0-42c3-abbc-11cbe3aaa273 -:END: -For the generous folks who want to sponsor the project and its author. - -** How do I sponsor the project? -:PROPERTIES: -:ID: 0b737d2b-c13b-4562-9274-015bc226a53f -:END: -Consider becoming my [[https://github.com/sponsors/hlissner][Github sponsor]]. If you're not a fan of Github sponsorship, -my page lists a couple alternatives. - -If you do decide to sponsor me, thank you for your support! It is a big help, -and directly translates to more hours on my Doom, Emacs-related, or open-source -capers. - -** How do I claim my tier rewards? -Once you have sponsored, you'll receive an automated email telling you how, but -in case you didn't: email me at contact@henrik.io or DM me on Discord -(@Henrik#0666) with *your github username* and (optionally) *Discourse -username*, and I'll help sort you out! - -** Are there other ways to support the project or get sponsorship perks? -:PROPERTIES: -:ID: 29d9a145-8f2e-4d22-b4d0-de8a2c72698d -:END: -Yes! By becoming a module maintainer, community moderator, or regular you get -the same perks as sponsors [[https://github.com/sponsors/hlissner][on the 25/mo tier]]. Here's what they do: - -- *Module maintainers* look after one or more Doom modules. They become my - consultants for that module(s)' ecosystem, packages, and implementation, and - issues about them. Some Emacs Lisp expertise is helpful, but it's more - important that you are knowledgeable about your chosen module's ecosystem. -- *Moderators* look after our Github, Discord, and/or Discourse communities. - They keep our issue tracker, github projects, and repos organized, and they - keep the peace by warning/banning bad actors. They're held to a higher - standard, however, as they represent us. -- *Regulars* are pillars of our community; they're folks that frequent our - Discord and/or Discourse, are active, helpful, and friendly. This is the only - role you can't apply for, but we keep a eye out for folks to give it to! - -If code, documentation, or bug reports are more your thing, visit [[id:eb67a668-20ac-43ec-880b-883b6949ca76][our -contributing manual]] for ideas. - -** What is the difference between "first shake" and "first priority"? -Some of my Sponsor tier rewards offer "first shake" or "first priority" on open -issues/feature requests. To explain what these mean: - -- Issues that get *first shake* get triaged and investigated before other - issues, and if it can be resolved in one sitting, I will. -- Issues that get *first priority* get entirely resolved before I move on to - anything else. - -That said, the exception to these rules are issues that are extraordinarily -difficult, outside my expertise, or depend on other development efforts to -resolve. - -Folks that depend on Doom for their work or businesses would benefit from -getting first priority, to ensure their issues are resolved ASAP. Or check out -[[https://github.com/sponsors/hlissner?frequency=one-time&sponsor=hlissner][my one-time tiers]] to hire me for dedicated support. - -** I have a question, comment, or complaint about sponsorships... -Feel free to DM me (Henrik#0666) on [[https://doomemacs.org/discord][Discord]], ask on [[https://discourse.doomemacs.org][Discourse]], or email me at -contact@henrik.io. - -* Technical -:PROPERTIES: -:ID: 8b6f6bd0-da2f-4744-95b2-843a6fd283b6 -:END: -For questions regarding Doom's code design, defaults, or conventions. - -** Why does Doom sharp-quote function symbols? -~#'symbol~ is short for ~(function symbol)~, the same way ~'symbol~ is short for -~(quote symbol)~. - -I use it to indicate to the byte-compiler (or human readers) that a symbol will -be treated as a function rather than literal data. - -However, at runtime, the sharp-quote serves no functional purpose like it does -in other lisps. ~(funcall 'some-function)~ will function identically to -~(funcall #'some-function)~. The sole difference is at compile-time: the -byte-compiler performs additional checks on function symbols and will warn if a -function isn't known to be defined where it's used. - -There's more about quoting [[https://emacsdocs.org/docs/elisp/Quoting][in the Emacs manual]]. - -** TODO How does Doom Emacs start up so quickly? -#+begin_quote - 🔨 *This post is a work in progress!* However, there's a post on our Discourse - that outlines [[https://discourse.doomemacs.org/t/how-does-doom-start-up-so-quickly/163/1][some of our older techniques]]. -#+end_quote - -** TODO How does Doom Emacs improve runtime performance? -#+begin_quote - 🔨 *This post is a work in progress!* -#+end_quote - -** Why does Doom not use dash, f, s, or similar libraries? -=subr-x=, =seq=, =map=, =pcase=, and =cl-lib= are all built into Emacs and, -since Emacs 27.1 (the minimum version Doom supports), have made Dash and co -(mostly) redundant. One of Doom's goals is to prefer native functionality where -possible or trivial. That said, many third-party packages depend on them, so -chances are they are already installed on your system. - -** Why does Doom discourage the use of ~M-x customize~? -=Customize= exists so that you don't need to be a Lisp programmer to configure -Emacs. It's helpful to beginners (with both configuration and discovery), but I -think it should only serve as a stopgap until you are comfortable writing and -navigating Emacs Lisp, then abandoned. Here's why: - -- The way it applies its settings (through theme variables) defies conventional - load order, which is troublesome to support in middleware like Doom (or user - configuration) when lazy loading is involved. - -- I don't see many instances in the wild where this load-order quirk is - accommodated. I think this is because those writing/offering that code are - Lisp programmers, who don't use =Customize= and may not be exposed to its - quirks, but for beginners this is frustration waiting to happen. - -- =Customize= works flawlessly if it is the sole source of truth for your Emacs - configuration, but /all/ Emacs configs eventually take on Lisp. At this point - you acquire a second source of truth that =Customize= is happy to (quietly) - override. - -- Without its /unparalleled/ extensibility, I believe Emacs isn't particularly - interesting or effective software. And =Customize= exposes only a superficial - portion of that extensibility. Learning Lisp is inevitable if you want to deal - with issues or tweak where =Customize= can't, and Doom wants to help you face - Lisp, rather than work around it. Otherwise, you may be happier using modern, - better polished, and less-DIY competitors. - -- =Customize='s commands are safe for read-only use (e.g. to browse/search - settings), but I'm not convinced it can be compete with Emacs' - self-documentating facilities. For example, its library of ~describe-*~ - commands already set the bar pretty high. - -All that said, I take no steps to disable or cripple =Customize= in Doom -(besides a warning here and there, and hiding it in some menus where it is known -to cause issues). If used sparingly, you may not even run into these issues. - -** Why no =expand-region= for evil users (by default)? -I believe [[doom-package:expand-region]] is redundant with and less precise than evil's text -objects and motions. - -- There's a text object for every "step" of expansion that expand-region - provides (and more). - - To select the word at point = [[kbd:][v i w]] - - symbol at point = [[kbd:][v i o]] - - line at point = [[kbd:][V]] - - the block at point (by indentation) = [[kbd:][v i i]] - - the block at point (by braces) = [[kbd:][v i b]] - - sentence at point = [[kbd:][v i s]] - - paragraph = [[kbd:][v i p]] - - etc. -- Selection expansion can be emulated by using text objects consecutively: [[kbd:][v i w]] - to select a word, followed by [[kbd:][i o]] to expand to a symbol, then [[kbd:][i b]] expands to - the surrounding brackets/parentheses, etc. There is no reverse of this - however; you'd have to restart visual mode. - -The [[doom-package:expand-region]] way dictates you start at some point and expand/contract until -you have what you want selected. The vim/evil way would rather you select -exactly what you want from the get go. In the rare event a text object fails -you, a combination of [[kbd:][o]] (swaps your cursor between the two ends of the region) -and motion keys can adjust the ends of your selection. - -#+begin_quote - 📌 There are also text objects for xml tags ([[kbd:][x]]), C-style function arguments - ([[kbd:][a]]), angle brackets, and single/double quotes. -#+end_quote - -This is certainly more to remember compared to a pair of expand and contract -commands, but text objects (and motions) are the bread and butter of vim's modal -editing paradigm. Vimmers will feel right at home. To everyone else: mastering -them will have a far-reaching effect on your effectiveness in vim environments. -I highly recommend putting in the time to learn them. - -That said, if you aren't convinced, it is trivial to install [[doom-package:expand-region]] and -binds keys to it yourself: -#+begin_src emacs-lisp -;;; in $DOOMDIR/packages.el -(package! expand-region) - -;;; in $DOOMDIR/config.el -(map! :nv "C-=" #'er/contract-region - :nv "C-+" #'er/expand-region) -#+end_src - -** Why ~doom env~ instead of ~exec-path-from-shell~? -For some context: there are scenarios where Emacs launches in an isolated -environment where it cannot see your =$PATH= or other needed environment -variables. This affects macOS users (all =Emacs.app= bundles launch Emacs in an -isolated environment), Linux users who misconfigure their launchers to use the -wrong shell, or Windows users who may have no shell environment at all. - -[[doom-package:exec-path-from-shell]] was written to mitigate this, by polling the shell at -startup for those environment variables. ~$ doom env~ was written as more -reliable (and slightly faster) substitute. Here's why it's better: - -1. [[doom-package:exec-path-from-shell]] must spawn (at least) one process at startup to scrape - your shell environment. This can be slow depending on the user's shell - configuration and may fail on non-standard shells (like =fish=). A single - program (like =pyenv= or =nvm=) or config framework (like =oh-my-zsh=) could - all our startup optimizations in one fell swoop. - -2. [[doom-package:exec-path-from-shell]] takes a whitelist approach and captures only =$PATH= and - =$MANPATH= by default. You must be proactive in order to capture all the - envvars relevant to your development environment and tools. - - ~$ doom env~ takes the blacklist approach and captures all of your shell - environment. This front loads the debugging process, which is nicer than - dealing with it later, while you're getting work done. - -That said, if you still want [[var:exec-path-from-shell]], it is trivial to install -yourself: -#+begin_src emacs-lisp -;;; in $DOOMDIR/packages.el -(package! exec-path-from-shell) - -;;; in $DOOMDIR/config.el -(require 'exec-path-from-shell) -(when (display-graphic-p) - (exec-path-from-shell-initialize)) -#+end_src - -** Why =ws-butler= over =whitespace-cleanup= or =delete-trailing-whitespace=? -I believe [[doom-package:ws-butler]] is less imposing on teammates/project maintainers; it only -cleans up whitespace on the lines you've touched. - -You know the story: a PR with 99 whitespace adjustments around a one-line -contribution. Why? Because they added [[fn:delete-trailing-whitespace]] (or -[[fn:whitespace-cleanup]]) to [[var:before-save-hook]], which mutates entire buffers. - -Automated processes that mutate entire files (or worse, whole projects) should -be deliberately invoked, and by someone privvy to the consequences, rather than -automated. =ws-butler= achieves that balance by only cleaning whitespace on -lines that you have modified since opening the file. diff --git a/.config/emacs/docs/getting_started.org b/.config/emacs/docs/getting_started.org @@ -1,1677 +0,0 @@ -#+TITLE: Getting Started Guide -#+STARTUP: nofold - -GNU Emacs is one grand ol' adventure, let alone Doom Emacs. Before you start -you'll need to set up Emacs, Doom, and its packages, then learn how to take care -of your new puppy/operating system. This guide will walk you through installing, -using, configuring and troubleshooting all of these things, to smooth you into -your Emacs journey. - -This guide will gloss over many technicalities so you can get up and running as -soon as possible. A more technical user manual is in the works for aspiring -contributors who want a deeper understanding of how Doom Emacs works. - -#+begin_quote -If you feel like we've missed something, [[https://discord.gg/qvGgnVx][join us on our Discord server]] and let -us know! -#+end_quote - -* Table of Contents :TOC_4: -- [[#install][Install]] - - [[#emacs--dependencies][Emacs & dependencies]] - - [[#on-linux][On Linux]] - - [[#ubuntu][Ubuntu]] - - [[#fedora][Fedora]] - - [[#arch-linux][Arch Linux]] - - [[#nixos][NixOS]] - - [[#opensuse][openSUSE]] - - [[#gentoo-linux][Gentoo Linux]] - - [[#on-macos][On macOS]] - - [[#with-homebrew][With Homebrew]] - - [[#with-macports][With MacPorts]] - - [[#on-windows][On Windows]] - - [[#with-chocolatey--scoop][With chocolatey / scoop]] - - [[#with-a-precompiled-binary--git-bash][With a precompiled binary + Git Bash]] - - [[#with-wsl--ubuntu-1804-lts][With WSL + Ubuntu 18.04 LTS]] - - [[#doom-emacs][Doom Emacs]] - - [[#the-bindoom-utility][The ~bin/doom~ utility]] - - [[#install-doom-manually][Install Doom Manually]] - - [[#install-doom-alongside-other-configs-with-chemacs2][Install Doom alongside other configs (with Chemacs2)]] - - [[#externalsystem-dependencies][External/system dependencies]] -- [[#update--rollback][Update & Rollback]] - - [[#rollback][Rollback]] - - [[#updowngrading-emacs][Up/Downgrading Emacs]] -- [[#migrate][Migrate]] - - [[#from-vanilla-emacs][From vanilla Emacs]] - - [[#from-spacemacs][From Spacemacs]] -- [[#configure][Configure]] - - [[#modules][Modules]] - - [[#package-management][Package management]] - - [[#installing-packages][Installing packages]] - - [[#installing-packages-from-external-sources][Installing packages from external sources]] - - [[#pinning-packages-to-specific-commits][Pinning packages to specific commits]] - - [[#disabling-packages][Disabling packages]] - - [[#changing-a-recipe-for-an-included-package][Changing a recipe for an included package]] - - [[#usingloading-local-packages][Using/loading local packages]] - - [[#configuring-doom][Configuring Doom]] - - [[#configuring-packages][Configuring packages]] - - [[#reloading-your-config][Reloading your config]] - - [[#binding-keys][Binding keys]] - - [[#writing-your-own-modules][Writing your own modules]] - - [[#file-structure][File structure]] - - [[#initel][=init.el=]] - - [[#configel][=config.el=]] - - [[#packagesel][=packages.el=]] - - [[#autoloadel-or-autoloadel][=autoload/*.el= OR =autoload.el=]] - - [[#doctorel][=doctor.el=]] - - [[#cliel][=cli.el=]] - - [[#testtest-el][=test/**/test-*.el=]] - - [[#additional-files][Additional files]] - - [[#load-order][Load order]] - - [[#flags][Flags]] - - [[#doom-cookies][Doom cookies]] - - [[#if][~;;;###if~]] - - [[#package][~;;;###package~]] - - [[#autodef][~;;;###autodef~]] - - [[#common-mistakes-when-configuring-doom-emacs][Common mistakes when configuring Doom Emacs]] - - [[#packages-are-eagerly-loaded][Packages are eagerly loaded]] - - [[#manual-package-management][Manual package management]] - - [[#using-org-babel-do-load-languages-to-load-your-babel-packages][Using ~org-babel-do-load-languages~ to load your babel packages]] - - [[#using-delete-trailing-whitespaces-or-whitespace-cleanup-to-manage-leftover-whitespace][Using ~delete-trailing-whitespaces~ or ~whitespace-cleanup~ to manage leftover whitespace]] -- [[#troubleshoot][Troubleshoot]] - - [[#looking-up-documentation-and-state-from-within-emacs][Looking up documentation and state from within Emacs]] - - [[#variables-functions-faces-etc][Variables, functions, faces, etc.]] - - [[#for-doom-modules-packages-autodefs-etc][For Doom Modules, packages, autodefs, etc.]] - - [[#how-to-extract-a-backtrace-from-an-error][How to extract a backtrace from an error]] - - [[#enabling-debug-on-error][Enabling ~debug-on-error~]] - - [[#a-backtrace-from-bindoom][A backtrace from ~bin/doom~]] - - [[#evaluating-elisp-on-the-fly][Evaluating Elisp on-the-fly]] - - [[#how-to-determine-the-origin-of-a-bug][How to determine the origin of a bug]] - - [[#testing-in-dooms-sandbox][Testing in Doom's sandbox]] - - [[#opening-the-sandbox][Opening the sandbox]] - - [[#launching-the-sandbox][Launching the sandbox]] - - [[#testing-packages-in-the-sandbox][Testing packages in the sandbox]] - - [[#bisecting-your-private-config][Bisecting your private config]] - - [[#bisecting-doom-emacs][Bisecting Doom Emacs]] - -* Install -This is what you'll have installed by the end of this section: - -- Git 2.23+ -- Emacs 27.1+ *(27.2 is recommended, or [[https://www.emacswiki.org/emacs/GccEmacs][native-comp]])* -- [[https://github.com/BurntSushi/ripgrep][ripgrep]] 11.0+ -- GNU Find -- (Optional) [[https://github.com/sharkdp/fd][fd]] 7.3.0+ (known as ~fd-find~ on Debian, Ubuntu & derivatives) -- - improves performance for many file indexing commands - -These packages ought to be available through the package managers of your -operating system; i.e. homebrew & macports on macOS, scoop/chocolatey on -Windows, or pacman/aptitude/etc on the various Linux distributions. - -** Emacs & dependencies -*** On Linux -Installation instructions for Emacs 27.1+ are listed below for many popular -Linux distributions. In the unusual case that 27.1 or newer is unavailable on -your system, you'll have to [[https://www.gnu.org/software/emacs/manual/html_node/efaq/Installing-Emacs.html][build it from source]] instead. - -**** Ubuntu -Emacs 27.x is not available through Ubuntu's package manager out-of-the-box, but -is available through a PPA: - -#+BEGIN_SRC bash -add-apt-repository ppa:kelleyk/emacs -apt-get update -apt-get install emacs27 -#+END_SRC - -Or through snap: - -#+BEGIN_SRC bash -snap install emacs --classic -#+END_SRC - -In some cases, you may need to delete old version of emacs and it's dependencies first, before installing emacs27: -#+BEGIN_SRC bash -sudo apt remove emacs -sudo apt autoremove -#+END_SRC - -***** Other dependencies -Then install Doom's other dependencies: -#+BEGIN_SRC bash -apt-get install ripgrep fd-find - -# On 18.04 or older, ripgrep and fd-find won't be available in -# official repos. You'll need to install them another way, e.g. -sudo dpkg -i fd_8.2.1_amd64.deb # adapt version number and architecture -sudo dpkg -i fd_8.2.1_amd64.deb # adapt version number and architecture -#+END_SRC - -**** Fedora -#+BEGIN_SRC bash -# required dependencies -dnf install emacs git ripgrep -# optional dependencies -dnf install fd-find # is 'fd' in Fedora <28 -#+END_SRC - -**** Arch Linux -#+BEGIN_SRC bash -# required dependencies -pacman -S git emacs ripgrep -# optional dependencies -pacman -S fd -#+END_SRC - -The above installs Emacs 27 (at the time of writing). - -**** NixOS -On NixOS Emacs 27.2 can be installed via ~nix-env -Ai nixos.emacs~, or -permanently with the following added to ~etc/nixos/configuration.nix~: - -#+BEGIN_SRC nix -environment.systemPackages = with pkgs; [ - # required dependencies - git - emacs # Emacs 27.2 - ripgrep - # optional dependencies - coreutils # basic GNU utilities - fd - clang -]; -#+END_SRC - -Installing Emacs 28+ will require [[https://github.com/nix-community/emacs-overlay/issues][nix-community/emacs-overlay]]: -#+BEGIN_SRC nix -nixpkgs.overlays = [ - (import (builtins.fetchTarball https://github.com/nix-community/emacs-overlay/archive/master.tar.gz)) -]; - -environment.systemPackages = [ - pkgs.emacsGcc # Installs Emacs 28 + native-comp -]; -#+END_SRC - -**** openSUSE -***** Emacs 27.1 -Emacs can be installed from the [[https://software.opensuse.org/download.html?project=editors&package=emacs][package list]], or manually via zypper. - -For example, to install on openSUSE Leap 15.1 (requires root): -#+BEGIN_SRC bash -zypper addrepo https://download.opensuse.org/repositories/editors/openSUSE_Leap_15.1/editors.repo -zypper refresh -zypper install emacs -#+END_SRC - -If you already have an older version of Emacs installed, you will be prompted to -install the update candidate (Emacs 27.1). - -***** ripgrep -Download ripgrep 11.0.2 from [[https://software.opensuse.org/download/package?package=ripgrep&project=openSUSE%3AFactory][the package list]] or installed manually (requires -root). -#+BEGIN_SRC bash -zypper addrepo https://download.opensuse.org/repositories/openSUSE:Factory/standard/openSUSE:Factory.repo -zypper refresh -zypper install ripgrep -#+END_SRC - -Only ripgrep 0.8.1 is officially available on Leap 15.1 and 15.2, so you will -need to install Rust to build ripgrep from source. Rust can be downloaded [[https://software.opensuse.org/package/rust][from -the package list]] or installed manually via zypper (requires root), e.g. -#+BEGIN_SRC bash -zypper addrepo https://download.opensuse.org/repositories/openSUSE:Leap:15.1:Update/standard/openSUSE:Leap:15.1:Update.repo -zypper refresh -zypper install rust -#+END_SRC - -See the [[https://github.com/BurntSushi/ripgrep#building][ripgrep documentation]] for instructions on building from source. - -**** Gentoo Linux -Everything you need is in Gentoo's official =::gentoo= repository. - -***** Emacs -To use Emacs graphically, enable the =gui= USE flag. And enable the =xft= USE flag to render fonts correctly (see -[[https://github.com/hlissner/doom-emacs/issues/4876][issue #4876]]) -#+begin_src sh -echo "app-editors/emacs gui xft" >> /etc/portage/package.use/emacs -#+end_src - -To install the latest unmasked version compatible with Doom: -#+begin_src sh -emerge '>=app-editors/emacs-27.0' -#+end_src - -Or, for GCCEmacs/Native Compilation, use the live ebuild for version 28.0 with the =jit= USE flag: - -Unmask the desired ebuild by adding the following to =package.accept_keywords=: -#+begin_src -=app-editors/emacs-28.0.9999 ** -#+end_src - -Add the =jit= USE flag to =package.use=: -#+begin_src -=app-editors/emacs-28.0.9999 jit -#+end_src - -And emerge: -#+begin_src sh -emerge =app-editors/emacs-28.0.9999 -#+end_src - -***** Other Dependencies -#+begin_src sh -# required -emerge '>=dev-vcs/git-2.23' '>=sys-apps/ripgrep-11.0' sys-apps/findutils -# optional -emerge '>=sys-apps/fd-7.3.0' -#+end_src - -*** On macOS -MacOS users have many options for installing Emacs, but not all of them are well -suited to Doom. Before we get to that you'll need either the Homebrew or -MacPorts package manager installed (you only need one): - -+ [[http://brew.sh/][How to install Homebrew]] -+ [[https://www.macports.org/install.php][How to install MacPorts]] - -**** With Homebrew -First, Doom's dependencies: -#+BEGIN_SRC bash -# required dependencies -brew install git ripgrep -# optional dependencies -brew install coreutils fd -# Installs clang -xcode-select --install -#+END_SRC - -For Emacs itself, these three formulas are the best options, ordered from most -to least recommended for Doom (based on compatibility). - -- [[https://bitbucket.org/mituharu/emacs-mac/overview][emacs-mac]]. It offers good integration - with macOS, native emojis and better childframe support. - #+BEGIN_SRC bash - brew tap railwaycat/emacsmacport - brew install emacs-mac --with-modules - ln -s /usr/local/opt/emacs-mac/Emacs.app /Applications/Emacs.app - #+END_SRC - -- [[https://github.com/d12frosted/homebrew-emacs-plus][emacs-plus]]. Some users have - experienced [flashing artifacts when scrolling](https://github.com/d12frosted/homebrew-emacs-plus/issues/314): - #+BEGIN_SRC bash - brew tap d12frosted/emacs-plus - brew install emacs-plus - ln -s /usr/local/opt/emacs-plus/Emacs.app /Applications/Emacs.app - #+END_SRC - -- [[https://formulae.brew.sh/formula/emacs][emacs]] is another acceptable option, **but does not provide a Emacs.app**: - #+BEGIN_SRC bash - brew install emacs - #+END_SRC - -***** Where *not* to install Emacs from -These builds/forks have known compatibility issues with Doom and are *very -likely* to cause issues later on. They are not recommended: - -+ emacsformacosx.com -+ ~brew cask install emacs~ (installs from emacsformacosx.com) -+ AquaMacs -+ XEmacs - -**** With MacPorts -There are four ports (at time of writing) available through MacPorts, and they -are all acceptable options: - -+ [[https://ports.macports.org/port/emacs/summary][emacs]] (27.2) and [[https://ports.macports.org/port/emacs-devel/summary][emacs-devel]] (28) -- Installs terminal-only Emacs -+ [[https://ports.macports.org/port/emacs-app/summary][emacs-app]] (27.2), [[https://ports.macports.org/port/emacs-app-devel/summary][emacs-app-devel]] (28) -- Installs GUI Emacs -+ [[https://ports.macports.org/port/emacs-mac-app/summary][emacs-mac-app]] (27.2) -- the [[https://bitbucket.org/mituharu/emacs-mac][Mitsuharu Yamamoto mac port]] - -Some of these ports do not add an =emacs= binary to your ~PATH~, which is -necessary for Doom's installation process. You'll have to do so yourself by -adding this to your shell config: - -#+BEGIN_SRC sh -# Add this to ~/.zshrc or ~/.bash_profile -export PATH="/Applications/MacPorts/Emacs.app/Contents/MacOS:$PATH" -#+END_SRC - -Or by replacing ~/usr/local/bin/emacs~ with a shim script containing: -#+BEGIN_SRC -#!/bin/sh -/Applications/MacPorts/Emacs.app/Contents/MacOS/Emacs "$@" -#+END_SRC - -*** On Windows -#+begin_quote -*WARNING:* Emacs on Windows is much slower than its Linux or macOS counterparts. -There are some suggestions on how to speed it up later in this section. -#+end_quote - -There are three methods for installing Emacs 27.x on Windows, each with their -pros and cons: - -+ With chocolatey/scoop -+ With a precompiled binary + Git Bash -+ With WSL2 + Ubuntu - -If you don't know which to choose, I highly recommend WSL; it produces the -fastest and most stable environment of the three, but has the most complex -installation process. - -Before moving on to installing Emacs et co, a few steps to prepare Windows for -Emacs are necessary: - -1. Create a ~HOME~ [[https://mywindowshub.com/how-to-edit-system-environment-variables-for-a-user-in-windows-10/][system environment variable]]. - - Set it to =C:\Users\USERNAME\=, otherwise Emacs will treat - =C:\Users\USERNAME\AppData\Roaming= as your ~HOME~, which will cause issues - later. - -2. Add =C:\Users\USERNAME\.emacs.d\bin= to your ~PATH~. - - This way, you don't have to type all of =C:\Users\USERNAME\.emacs.d\bin\doom= - every time you need to run this script (and you'll need to, often). - - #+begin_quote - A pre-existing PATH variable should already exist among your system - variables. It contains a string of file paths separated by colons; - ~pathA:pathB:pathC~. Prepend the path to bin/doom to that string, like so: - ~C:\Users\username\.emacs.d\bin:pathA:pathB:pathC~ - #+end_quote - -3. Restart your system so your new values for ~HOME~ and ~PATH~ take effect. - -Now we're ready to move on! - -**** With [[https://chocolatey.org/][chocolatey]] / scoop -[[https://chocolatey.org/][Chocolatey]] is a package manager for Windows, and is the simplest way to install -Emacs and Doom's dependencies: -#+BEGIN_SRC sh -choco install git emacs ripgrep -# Optional dependencies -choco install fd llvm -#+END_SRC - -Scoop will work too, but because Emacs is a GUI application you'll need to -enable the 'extras' Scoop bucket: -#+BEGIN_SRC sh -scoop bucket add extras -scoop install git emacs ripgrep -# Optional dependencies -scoop install fd llvm -#+END_SRC - -**** With a precompiled binary + Git Bash -(Credit goes to @earvingad and [[https://earvingad.github.io/posts/doom_emacs_windows/][his fantastic tutorial]] for informing this guide) - -1. Download and install Git from https://git-scm.com/download/win -2. Download and extract Emacs, ripgrep and fd where you want them, but in - different folders: - - Emacs 27.2 from http://ftp.wayne.edu/gnu/emacs/windows/emacs-27/ - - Ripgrep from https://github.com/BurntSushi/ripgrep/releases - - (optional) fd from https://github.com/sharkdp/fd/releases -3. Add the three folders from step 2 to your ~PATH~ - - Go to Control panel -> User Accounts -> Change my environment variables. - - Click "New", type HOME and set your C:\Users\USERNAME and OK. - - Select "Path", click "edit", prepend =C:\path\to\the\emacs\bin:= to it and - click OK. - - Select "Path", click "edit", prepend =C:\path\to\the\ripgrep:= to it and - click OK. - - Select "Path", click "edit", prepend =C:\path\to\the\fd:= to it and click - OK. - - Click Ok. - -And done! Keep git-bash.exe open, you'll need it for the rest of this guide. - -#+begin_quote -*IMPORTANT:* you'll need to open git-bash.exe whenever you want to run a -bin/doom command. -#+end_quote - -**** With WSL + Ubuntu 18.04 LTS -(Credit goes to @lunias and [[https://ethanaa.com/blog/switching-to-doom-emacs/#installing-on-windows-10 -][his fantastic tutorial]] for informing this guide) - -1. Install Powershell as admin (Windows key + x) with: - #+BEGIN_SRC - Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux - #+END_SRC -2. Restart your Computer -3. Download and install Ubuntu 18.04 L>TS from the Microsoft Store -4. Launch Ubuntu 18.04 LTS -5. Update and upgrade Ubuntu - #+BEGIN_SRC - sudo apt update && sudo apt upgrade - #+END_SRC -6. Then install Emacs: - #+BEGIN_SRC sh - sudo add-apt-repository ppa:kelleyk/emacs - sudo apt update - sudo apt install emacs27 - #+END_SRC -7. Then Doom's dependencies: - #+BEGIN_SRC sh - # required dependencies - sudo apt-get install git ripgrep - # optional dependencies - sudo apt-get install fd-find - #+END_SRC - -And done! Keep Ubuntu open, you'll need it for the rest of this guide. - -** Doom Emacs -With Emacs and Doom's dependencies installed, next is to install Doom Emacs -itself: - -#+BEGIN_SRC bash -git clone https://github.com/hlissner/doom-emacs ~/.emacs.d -~/.emacs.d/bin/doom install -#+END_SRC - -=doom install= will set up your =DOOMDIR= at =~/.doom.d= (if it doesn't already -exist) and will work you through the first-time setup of Doom Emacs. Carefully -follow any instructions it puts out. - -If this is your first time, you should run ~doom doctor~. This will diagnose -common issues with your system or config. - -#+BEGIN_QUOTE -If you'd like a more technical break down of ~doom install~, it's been -translated into shell commands below, in the "Install Doom Manually" section. -#+END_QUOTE - -*** The ~bin/doom~ utility -This utility is your new best friend. It won't spot you a beer, but it'll -shoulder much of the work associated with managing and maintaining your Doom -Emacs configuration, and then some. Not least of which is installation of and -updating Doom and your installed packages. - -It exposes a variety of commands. ~bin/doom help~ will list them all, but here -is a summary of the most important ones: - -+ ~doom sync~: This synchronizes your config with Doom Emacs. It ensures that - needed packages are installed, orphaned packages are removed and necessary - metadata correctly generated. Run this whenever you modify your ~doom!~ block - or =packages.el= file. You'll need ~doom sync -u~ if you override the recipe - of package installed by another module. -+ ~doom upgrade~: Updates Doom Emacs (if available) and all its packages. -+ ~doom env~: (Re)generates an "envvar file", which is a snapshot of your - shell environment that Doom loads at startup. If your app launcher or OS - launches Emacs in the wrong environment you will need this. **This is required - for GUI Emacs users on MacOS.** -+ ~doom doctor~: If Doom misbehaves, the doc will diagnose common issues with - your installation, system and environment. -+ ~doom purge~: Over time, the repositories for Doom's plugins will accumulate. - Run this command from time to time to delete old, orphaned packages, and with - the ~-g~ switch to compact existing package repos. - -Use ~doom help~ to see an overview of the available commands that =doom= -provides, and ~doom help COMMAND~ to display documentation for a particular -~COMMAND~. - -#+begin_quote -I recommend you add =~/.emacs.d/bin= to your ~PATH~ so you can call =doom= -directly and from anywhere. Accomplish this by adding this to your .bashrc or -.zshrc file: ~export PATH="$HOME/.emacs.d/bin:$PATH"~ -#+end_quote - -*** Install Doom Manually -If you'd rather install Doom yourself, instead of rely on the magic of =doom -install=, here is its equivalent in bash shell commands (assuming -=hlissner/doom-emacs= has been cloned to =~/.emacs.d=): - -#+BEGIN_SRC bash -# So we don't have to write ~/.emacs.d/bin/doom every time -PATH="$HOME/.emacs.d/bin:$PATH" - -# Create a directory for our private config -mkdir ~/.doom.d # or ~/.config/doom - -# The init.example.el file contains an example doom! call, which tells Doom what -# modules to load and in what order. -cp ~/.emacs.d/init.example.el ~/.doom.d/init.el -cp ~/.emacs.d/core/templates/config.example.el ~/.doom.d/config.el -cp ~/.emacs.d/core/templates/packages.example.el ~/.doom.d/packages.el - -# You might want to edit ~/.doom.d/init.el here and make sure you only have the -# modules you want enabled. - -# Then synchronize Doom with your config: -doom sync - -# If you know Emacs won't be launched from your shell environment (e.g. you're -# on macOS or use an app launcher that doesn't launch programs with the correct -# shell) then create an envvar file to ensure Doom correctly inherits your shell -# environment. -# -# If you don't know whether you need this or not, there's no harm in doing it -# anyway. `doom install` will have prompted you to generate one. If you -# responded no, you can generate it later with the following command: -doom env - -# Lastly, install the icon fonts Doom uses: -emacs --batch -f all-the-icons-install-fonts -# On Windows, `all-the-icons-install-fonts` will only download the fonts, you'll -# have to install them by hand afterwards! -#+END_SRC - -To understand the purpose of the =~/.doom.d= directory and =~/.doom.d/init.el= -file, see the [[#configure][Configure]] section further below. - -*** Install Doom alongside other configs (with Chemacs2) -[[https://github.com/plexus/chemacs2][Chemacs2]] is a bootloader for Emacs. It allows you to switch between multiple -Emacs configurations. Here is a quick guide for setting it up with Doom Emacs as -the default config: - -1. First, install Doom somewhere: - #+BEGIN_SRC sh :eval no - git clone https://github.com/hlissner/doom-emacs ~/doom-emacs - ~/doom-emacs/bin/doom install - #+END_SRC - -2. Move aside any existing config and install Chemacs2 as your new =~/.emacs.d=: - #+BEGIN_SRC bash :eval no - [ -f ~/.emacs ] && mv ~/.emacs ~/.emacs.bak - [ -d ~/.emacs.d ] && mv ~/.emacs.d ~/.emacs.legacy - git clone https://github.com/plexus/chemacs2.git ~/.emacs.d - #+END_SRC - -3. Create =~/.emacs-profiles.el= with a list of your Emacs profiles. This file - is structured like a =.dir-locals.el= file. Here is an example with Doom (as - the default), Spacemacs, and Prelude: - #+BEGIN_SRC emacs-lisp :eval no - (("default" . ((user-emacs-directory . "~/doom-emacs"))) - ("legacy" . ((user-emacs-directory . "~/.emacs.legacy"))) - ("spacemacs" . ((user-emacs-directory . "~/spacemacs")))) - #+END_SRC - -To start Emacs with a specific config, use the =--with-profile= option: - -#+BEGIN_SRC bash -emacs --with-profile spacemacs -#+END_SRC - -If no profile is specified, the =default= profile is used. - -** External/system dependencies -Doom is comprised of approximately 160 modules which provide its features, -language support and integration with external tools. Many of these have -external dependencies that you must install yourself. You'll find what a module -needs and how to install them in that module's README.org file or by running -~bin/doom doctor~. - -The [[file:modules.org][Module Index]] lists all Doom's available modules, with links to their -documentation. Documentation is a work-in-progrees; some modules may not have -README.org files yet! - -#+begin_quote -Use ~M-x doom/help-modules~ (bound to =SPC h d m= or =C-h d m=) to jump to a -module's documentation from within Doom, otherwise, place your cursor on a -module in your ~doom!~ block (in =~/.doom.d/init.el=) and press =K= to jump to -its documentation (or =gd= to jump to its source code). =C-c g k= and =C-c g d= -for non-evil users, respectively. -#+end_quote - -* Update & Rollback -Doom is an active project and many of its 300+ packages are in active -development as well. It is wise to occasionally update: -#+BEGIN_SRC bash -doom upgrade # or 'doom up' -#+END_SRC - -If you want to update Doom manually, ~doom upgrade~ is equivalent to: -#+BEGIN_SRC bash -cd ~/.emacs.d -git pull # updates Doom -doom clean # Ensure your config isn't byte-compiled -doom sync # synchronizes your config with Doom Emacs -doom update # updates installed packages -#+END_SRC - -To upgrade only your packages (and not Doom itself): - -#+BEGIN_SRC bash -doom upgrade --packages -#+END_SRC - -#+begin_quote -To minimize issues while upgrading, avoid modifying Doom's source files in -=~/.emacs.d=. All your customization should be kept in your =DOOMDIR= (e.g. -=~/.doom.d=). Read the [[#Configure][Configure]] section for more on configuring Doom. -#+end_quote - -** TODO Rollback -The =bin/doom= script doesn't currently offer rollback support for Doom or its -packages (yet). - -** Up/Downgrading Emacs -*You may encounter errors after up/downgrading Emacs.* Run ~doom sync~ on the -command line after changing the installed version of Emacs. If you've changed -the major version (e.g. 27 -> 28 or vice versa) run ~doom build~ too. - -+ ~doom sync~ will re-index any built-in/site loaddef files. This is especially - necessary if paths to built-in libraries have changed. -+ ~doom build~ will recompile all your installed packages, which is necessary - because Emacs bytecode not generally forward compatible across major releases - (e.g. 27 -> 28). Alternatively, reinstall all your packages by deleting - =~/.emacs.d/.local=, then run ~doom sync~. - -* TODO Migrate -If you're here from another Emacs distribution (or your own), here are a few -things to be aware of while you convert your old config to Doom: - -+ Doom does not use =package.el= to manage its packages, but ~use-package~ does! - You will see errors if you have ~:ensure ...~ properties in your ~use-package~ - blocks. Remove these and, instead, add ~package!~ declarations to - =~/.doom.d/packages.el= to install your packages. - - See [[#package-management]["Package Management"]], further in this guide. - -(This section is incomplete) - -** TODO From vanilla Emacs -#+begin_quote -Have you migrated from your own config? Help me flesh out this section by -letting me know what kind of hurdles you faced in doing so. You'll find me [[https://discord.gg/qvGgnVx][on -our Discord server]]. -#+end_quote - -** TODO From Spacemacs -#+begin_quote -Have you migrated from Spacemacs? Help me flesh out this section by letting me -know what kind of hurdles you faced in doing so. You'll find me [[https://discord.gg/qvGgnVx][on our Discord -server]]. -#+end_quote - -* Configure -You can configure Doom by tweaking the files found in your =DOOMDIR=. Doom -expects this directory to be found in one of: - -1. =~/.config/doom= (respects ~$XDG_CONFIG_HOME~) -2. or =~/.doom.d= - -This directory is referred to as your =DOOMDIR=. Only one of these directories -should exist (Doom will only recognize one). - -#+begin_quote -Change the =DOOMDIR= environment variable to change where Doom looks for this -directory. Symlinks will work as well. -#+end_quote - -When you ran ~doom install~, it deployed a simple Doom configuration to your -=DOOMDIR=, comprised of these three files: - -+ init.el :: Where you'll find your ~doom!~ block, which controls what Doom - modules are enabled and in what order they will be loaded. - - This file is evaluated early when Emacs is starting up; before any other - module has loaded. You generally shouldn't add code to this file unless you're - targeting Doom's CLI or something that needs to be configured very early in - the startup process. -+ config.el :: Here is where 99.99% of your private configuration should go. - Anything in here is evaluated /after/ all other modules have loaded, when - starting up Emacs. -+ packages.el :: Package management is done from this file; where you'll declare - what packages to install and where from. - -#+begin_quote -Note: do not use ~M-x customize~ or the customize API in general. Doom is -designed to be configured programmatically from your config.el, which can -conflict with Customize's way of modifying variables. - -If you're concerned about ~defcustom~ setters, Doom has a ~setq!~ macro that -will trigger them. -#+end_quote - -** Modules -Doom consists of around 160 modules and growing. A Doom module is a bundle of -packages, configuration and commands, organized into a unit that can be toggled -easily by tweaking your ~doom!~ block (found in =$DOOMDIR/init.el=). - -#+begin_quote -If =$DOOMDIR/init.el= doesn't exist, you haven't run ~doom install~ yet. See [[#install][the -"Install" section]] above. -#+end_quote - -Your ~doom!~ block should look something like this: - -#+BEGIN_SRC emacs-lisp -;; To comment something out, you insert at least one semicolon before it and the -;; Emacs Lisp interpreter will ignore everything until the end of the line. -(doom! :lang - python ; this module is not commented, therefore enabled - ;;javascript ; this module is commented out, therefore disabled - ;;lua ; this module is disabled - ruby ; this module is enabled - php) ; this module is enabled -#+END_SRC - -It controls what modules are enabled and in what order they are loaded. Some -modules have *optional features* that can be enabled by passing them flags, -denoted by a plus prefix: - -#+BEGIN_SRC emacs-lisp -(doom! :completion - (company +childframe) - :lang - (csharp +unity) - (org +brain +dragndrop +gnuplot +hugo +jupyter) - (sh +fish)) -#+END_SRC - -Different modules support different flags. You'll find a comprehensive list of -available modules and their supported flags in [[file:modules.org][Module Index]]. Flags that a -module does not recognize will be silently ignored. - -#+begin_quote -*IMPORTANT:* any changes to your ~doom!~ block won't take effect until you run - ~doom sync~ on the command line. -#+end_quote - -#+begin_quote -~doom doctor~ will detect issues with your ~doom!~ block, such as duplicate or -misspelled modules and flags. -#+end_quote - -** Package management -**Doom Emacs does not use package.el** (the package manager built into Emacs). -Instead, it uses its own declarative package manager built on top of -[[https://github.com/raxod502/straight.el][straight.el]]. - -Packages are declared in ~packages.el~ files. You'll find one in your =DOOMDIR= -and in many of Doom's modules. Read on to learn how to use this system to -install your own packages. - -#+begin_quote -*WARNING:* Do not install packages directly (with ~M-x package-install~ or ~M-x -straight-use-package~). Without an accompanying ~package!~ declaration somewhere -these packages will be forgotten when you restart Emacs and uninstalled the next -time you run ~doom sync~ or ~doom purge~. -#+end_quote - -#+begin_quote -*WARNING:* If you're here from another Emacs distro (or vanilla Emacs), be wary -of the ~:ensure~ property in ~use-package~ blocks, because it will attempt (and -fail) to install packages through package.el. Tutorials will recommend you -install packages this way too! -#+end_quote - -*** Installing packages -To install a package, add a ~package!~ declaration for it to -=DOOMDIR/packages.el=: -#+BEGIN_SRC emacs-lisp -;; Install a package named "example" from ELPA, MELPA, or Emacsmirror -(package! example) -#+END_SRC - -If a package could not be found in any known repo you will get an error like: - -#+begin_quote -Could not find package X in recipe repositories: (org-elpa melpa gnu-elpa-mirror -emacsmirror-mirror) -#+end_quote - -The most likely cause for this is either: - -- You've misspelled the package's name. -- Or the package really doesn't exist on ELPA, MELPA, or EmacsMirror and you'll - need to [[*Installing packages from external sources][specify a recipe for it]]. - -~package!~ will return non-nil if the package is cleared for install and hasn't -been disabled elsewhere. Use this fact to chain package dependencies together. -e.g. -#+BEGIN_SRC elisp -(when (package! example) - (package! plugin-that-example-depends-on)) -#+END_SRC - -#+begin_quote -*IMPORTANT:* New packages won't be installed until you run ~doom sync~. -#+end_quote - -*** Installing packages from external sources -To install a package straight from an external source (like github, gitlab, -etc), you'll need to specify a [[https://github.com/raxod502/straight.el#the-recipe-format][MELPA-style straight recipe]]: - -Here are a few examples: -#+BEGIN_SRC elisp -;; Install it directly from a github repository. For this to work, the package -;; must have an appropriate PACKAGENAME.el file which must contain at least a -;; Package-Version or Version line in its header. -(package! example - :recipe (:host github :repo "username/my-example-fork")) - -;; If the source files for a package are in a subdirectory in said repo, use -;; `:files' to target them. -(package! example :recipe - (:host github - :repo "username/my-example-fork" - :files ("*.el" "src/lisp/*.el"))) - -;; To grab a particular branch or tag: -(package! example :recipe - (:host gitlab - :repo "username/my-example-fork" - :branch "develop")) - -;; If a package has a default recipe on MELPA or emacsmirror, you may omit -;; keywords and the recipe will inherit the rest of the recipe from their -;; original. -(package! example :recipe (:branch "develop")) - -;; If the repo pulls in many unneeded submodules, you can disable recursive cloning -(package! example :recipe (:nonrecursive t)) - -;; A package can be installed straight from a git repo by setting :host to nil: -(package! example - :recipe (:host nil :repo "https://some/git/repo")) -#+END_SRC - -The specification for the ~package!~ macro's ~:recipe~ is laid out [[https://github.com/raxod502/straight.el#the-recipe-format][in -Straight.el's README]]. - -#+begin_quote -*IMPORTANT:* Run ~bin/doom sync~ whenever you modify packages.el files to -ensure your changes take effect. -#+end_quote - -*** Pinning packages to specific commits -All of Doom's packages are pinned by default. A pinned package is a package -locked to a specific commit, like so: -#+BEGIN_SRC elisp -(package! evil :pin "e00626d9fd") -#+END_SRC - -To unpin a package, use the ~unpin!~ macro: -#+BEGIN_SRC elisp -(unpin! evil) - -;; It can be used to unpin multiple packages at once -(unpin! evil helm org-mode) - -;; Or to unpin all packages in modules -(unpin! (:lang python ruby rust) (:tools docker)) - -;; Or to unpin an entire category of modules -(unpin! :completion :lang :tools) - -;; This will work too, if you prefer the syntax, but it provides no concise -;; syntax for unpinning multiple packages: -(package! helm :pin nil) -#+END_SRC - -Though it is *highly* discouraged, you may unpin all packages and make Doom -Emacs rolling release: -#+BEGIN_SRC elisp -(unpin! t) -#+END_SRC - -#+begin_quote -Unpinning all packages is discouraged because Doom's modules are designed -against the pinned versions of its packages. More volatile packages (like -lsp-mode, ein and org) change rapidly, and are likely to cause breakages if -unpinned. - -Instead, it's a better to selectively unpin packages, or repin them to the exact -commit you want. -#+end_quote - -*** Disabling packages -The ~package!~ macro possesses a ~:disable~ property: -#+BEGIN_SRC emacs-lisp -(package! irony :disable t) -(package! rtags :disable t) -#+END_SRC - -Once a package is disabled, ~use-package!~ and ~after!~ blocks for it will be -ignored, and the package is removed the next time you run ~bin/doom sync~. Use -this to disable Doom's packages that you don't want or need. - -There is also the ~disable-packages!~ macro for conveniently disabling multiple -packages: -#+BEGIN_SRC elisp -(disable-packages! irony rtags) -#+END_SRC - -#+begin_quote -*IMPORTANT:* Run ~bin/doom sync~ whenever you modify packages.el files to -ensure your changes take effect. -#+end_quote - -*** Changing a recipe for an included package -If a Doom module installs package X from one place, but you'd like to install it -from another (say, a superior fork), add a ~package!~ declaration for it in your -=DOOMDIR/packages.el=. Your private declarations always have precedence over -modules (even your own). -#+BEGIN_SRC elisp -;; in modules/editor/evil/packages.el -(package! evil) ; installs from MELPA - -;; in DOOMDIR/packages.el -(package! evil :recipe (:host github :repo "username/my-evil-fork")) -#+END_SRC - -To install a package only if a built-in package doesn't exist, use ~:built-in -'prefer~: -#+BEGIN_SRC elisp -(package! so-long :built-in 'prefer) -#+END_SRC - -#+begin_quote -*IMPORTANT:* Remember to run ~doom sync -u~ after changing recipes for existing -packages. At the time of writing, ~doom sync~ alone will not pick up on recipe -changes. -#+end_quote - -*** Using/loading local packages -Say you are developing an Emacs package locally and want to "install" it for -live testing. To do this specify a ~:local-repo~ in that package's recipe: -#+BEGIN_SRC elisp -(package! my-package - :recipe (:local-repo "/path/to/my/package")) - -;; Relative paths are expanded to ~/.emacs.d/.local/straight/repos/{local-repo} -;; or ~/.doom.d/{local-repo} -- the first that is found. -(package! my-package - :recipe (:local-repo "my/package")) ; looks for ~/.doom.d/my/package/my-package.el - -(package! my-package - :recipe (:local-repo "/path/to/my/package" - - ;; By default, the package manager grabs all *.el files at the root - ;; of the project and nothing else. To include other files, or - ;; accommodate unconventional project structures, specify what :files - ;; you want: - :files ("*.el" "src/lisp/*.el") - - ;; With this you can avoid having to run 'doom sync' every time you - ;; change the package. - :build (:not compile))) -#+END_SRC - -Alternatively, add the package's location to Emacs' ~load-path~. Do this if you -don't need/care for autoload cookies or byte-compilation: -#+BEGIN_SRC elisp -;; Doom has modified `use-package's `:load-path' to expand relative paths from -;; your DOOMDIR. e.g. ~/.doom.d/lisp/package -(use-package my-package - :load-path "lisp/package") - -;; or - -(add-load-path! "lisp/package") -#+END_SRC - -#+begin_quote -*IMPORTANT:* Remember to run ~doom sync~ to rebuild your package after you've -changed it, and to re-index any autoloads in it. -#+end_quote - -** Configuring Doom -*** Configuring packages -If your configuration needs are simple, the ~use-package!~, ~after!~, -~add-hook!~ and ~setq-hook!~ macros are your bread and butter. - -#+BEGIN_SRC emacs-lisp -;;; ~/.doom.d/config.el (example) -(setq doom-font (font-spec :family "Fira Mono" :size 12)) - -;; Takes a feature symbol or a library name (string) -(after! evil - (setq evil-magic nil)) - -;; Takes a major-mode, a quoted hook function or a list of either -(add-hook! python-mode - (setq python-shell-interpreter "bpython")) - -;; These are equivalent -(setq-hook! 'python-mode-hook python-indent-offset 2) -(setq-hook! python-mode python-indent-offset 2) - -(use-package! hl-todo - ;; if you omit :defer, :hook, :commands, or :after, then the package is loaded - ;; immediately. By using :hook here, the `hl-todo` package won't be loaded - ;; until prog-mode-hook is triggered (by activating a major mode derived from - ;; it, e.g. python-mode) - :hook (prog-mode . hl-todo-mode) - :init - ;; code here will run immediately - :config - ;; code here will run after the package is loaded - (setq hl-todo-highlight-punctuation ":")) -#+END_SRC - -For more flexibility, the ~use-package-hook!~ is another option, but should be -considered a last resort (because there is usually a better way). It allows you -to disable, append/prepend to and/or overwrite Doom's ~use-package!~ blocks. -These are powered by ~use-package~'s inject-hooks under the hood. - -~use-package-hook!~ *must be used before that package's ~use-package!~ block*. -Therefore it must be used from your private init.el file. - -#+BEGIN_SRC emacs-lisp -;;; ~/.doom.d/init.el (example) -;; If a :pre-init / :pre-config hook returns nil, it overwrites that package's -;; original :init / :config block. Exploit this to overwrite Doom's config. -(use-package-hook! doom-themes - :pre-config - (setq doom-neotree-file-icons t) - nil) - -;; ...otherwise, make sure they always return non-nil! -(use-package-hook! evil - :pre-init - (setq evil-magic nil) - t) - -;; `use-package-hook' also has :post-init and :post-config hooks -#+END_SRC - -*** Reloading your config -You may find it helpful to have your changes take effect immediately. For things -that don't require a complete restart of Doom Emacs (like changing your enabled -modules or installed packages), you can evaluate Emacs Lisp code on-the-fly. - -+ Evil users can use the =gr= operator to evaluate a segment of code. The return - value is displayed in the minibuffer or in a popup (if the result is large - enough to warrant one). - - =gr= works for most languages, but using it on Elisp is a special case; it's - executed within your current session of Emacs. You can use this to modify - Emacs' state on the fly. -+ Non-evil users can use =C-x C-e= to run ~eval-last-sexp~, as well as ~M-x - +eval/buffer-or-region~ (on =SPC c e=). -+ Another option is to open a scratch buffer with =SPC x=, change its major mode - (~M-x emacs-lisp-mode~), and use the above keys to evaluate your code. -+ An ielm REPL is available by pressing =SPC o r= - (~+eval/open-repl-other-window~). -+ There's also =M-:= or =SPC ;=, which invokes ~eval-expression~, which you can - use to run elisp code inline. - -While all this is helpful for reconfiguring your running Emacs session, it can -also be helpful for debugging. - -*** TODO Binding keys -+ define-key -+ global-set-key -+ map! -+ undefine-key! -+ define-key! - -** Writing your own modules -To create your own module you need only create a directory for it in -=~/.doom.d/modules/abc/xyz=, then add =:abc xyz= to your ~doom!~ block in -=~/.doom.d/init.el= to enable it. - -#+begin_quote -In this example, =:abc= is called the category and =xyz= is the name of the -module. Doom refers to modules in one of two formats: =:abc xyz= and =abc/xyz=. -#+end_quote - -If a private module possesses the same name as a built-in Doom module (say, -=:lang org=), it replaces the built-in module. Use this fact to rewrite modules -you don't agree with. - -Of course, an empty module isn't terribly useful, but it goes to show that nothing in a module is required. The typical module will have: - -+ A =packages.el= to declare all the packages it will install, -+ A =config.el= to configure and load those packages, -+ And, sometimes, an =autoload.el= to store that module's functions, to be - loaded when they are used. - -These are a few exceptional examples of a well-rounded module: -+ [[file:../modules/completion/company/README.org][:completion company]] - -The remainder of this guide will go over the technical details of a Doom module. - -*** File structure -Doom recognizes a handful of special file names, none of which are required for -a module to function. They are: - -#+begin_example -category/ - module/ - test/*.el - autoload/*.el - autoload.el - init.el - cli.el - config.el - packages.el - doctor.el -#+end_example - -**** =init.el= -This file is loaded early, before anything else, but after Doom core is loaded. -It is loaded in both interactive and non-interactive sessions (it's the only -file, besides =cli.el= that is loaded when the =bin/doom= starts up). - -Do: -+ Configure Emacs or perform setup/teardown operations that must be set early; - before other modules are (or this module is) loaded. -+ Reconfigure packages defined in Doom modules with ~use-package-hook!~ (as a - last resort, when ~after!~ and hooks aren't enough). -+ Configure behavior of =bin/doom= in a way that must also apply in - interactive sessions. - -Don't: -+ Configure packages with ~use-package!~ or ~after!~ from here -+ Preform expensive or error-prone operations; these files are evaluated - whenever =bin/doom= is used; a fatal error in this file can make Doom - unbootable (but not irreversibly). -+ Define new =bin/doom= commands here. That's what =cli.el= is for. - -**** =config.el= -The heart of every module. Code in this file should expect dependencies (in -=packages.el=) to be installed and available. Use it to load and configure its -packages. - -Do: -+ Use ~after!~ or ~use-package!~ to configure packages. - #+BEGIN_SRC emacs-lisp - ;; from modules/completion/company/config.el - (use-package! company ; `use-package!' is a thin wrapper around `use-package' - ; it is required that you use this in Doom's modules, - ; but not required to be used in your private config. - :commands (company-mode global-company-mode company-complete - company-complete-common company-manual-begin company-grab-line) - :config - (setq company-idle-delay nil - company-tooltip-limit 10 - company-dabbrev-downcase nil - company-dabbrev-ignore-case nil) - [...]) - #+END_SRC -+ Lazy load packages with ~use-package~'s ~:defer~ property. -+ Use the ~featurep!~ macro to make some configuration conditional based on the - state of another module or the presence of a flag. - -Don't: -+ Use ~package!~ -+ Install packages with =package.el= or ~use-package~'s ~:ensure~ property. Doom - has its own package manager. That's what =packages.el= is for. - -**** =packages.el= -This file is where package declarations belong. It's also a good place to look -if you want to see what packages a module manages (and where they are installed -from). - -Do: -+ Declare packages with the ~package!~ macro -+ Disable single packages with ~package!~'s ~:disable~ property or multiple - packages with the ~disable-packages!~ macro. -+ Use the ~featurep!~ macro to make packages conditional based on the state of - another module or the presence of a flag. - -Don't: -+ Configure packages here (definitely no ~use-package!~ or ~after!~ in here!). - This file is read in an isolated environment and will have no lasting effect. - The only exception is configuration targeting =straight.el=. -+ Perform expensive calculations. These files are read often and sometimes - multiple times. -+ Produce any side-effects, for the same reason. - -#+begin_quote -The "[[#package-management][Package Management]]" section goes over the ~package!~ macro and how to deal -with packages. -#+end_quote - -**** =autoload/*.el= OR =autoload.el= -These files are where you'll store functions that shouldn't be loaded until -they're needed and logic that should be autoloaded (evaluated very, very early -at startup). - -This is all made possible thanks to these autoload cookie: ~;;;###autoload~. -Placing this on top of a lisp form will do one of two things: - -1. Add a ~autoload~ call to Doom's autoload file (found in - =~/.emacs.d/.local/autoloads.el=, which is read very early in the startup - process). -2. Or copy that lisp form to Doom's autoload file verbatim (usually the case for - anything other than ~def*~ forms, like ~defun~ or ~defmacro~). - -Doom's autoload file is generated by scanning these files when you execute ~doom -sync~. - -For example: -#+BEGIN_SRC emacs-lisp -;; from modules/lang/org/autoload/org.el -;;;###autoload -(defun +org/toggle-checkbox () - (interactive) - [...]) - -;; from modules/lang/org/autoload/evil.el -;;;###autoload (autoload '+org:attach "lang/org/autoload/evil" nil t) -(evil-define-command +org:attach (&optional uri) - (interactive "<a>") - [...]) -#+END_SRC - -**** =doctor.el= -When you execute ~doom doctor~, this file defines a series of tests for the -module. These should perform sanity checks on the environment, such as: - -+ Check if the module's dependencies are satisfied, -+ Warn if any of the enabled flags are incompatible, -+ Check if the system has any issues that may interfere with the operation of - this module. - -Use the ~warn!~, ~error!~ and ~explain!~ macros to communicate issues to the -user and, ideally, explain how to fix them. - -For example, the ~:lang cc~ module's doctor checks to see if the irony server is -installed: -#+BEGIN_SRC emacs-lisp -;; from lang/cc/doctor.el -(require 'irony) -(unless (file-directory-p irony-server-install-prefix) - (warn! "Irony server isn't installed. Run M-x irony-install-server")) -#+END_SRC - -**** TODO =cli.el= -This file is read when =bin/doom= starts up. Use it to define your own CLI -commands or reconfigure existing ones. - -**** TODO =test/**/test-*.el= -Doom's unit tests go here. More information on them to come... - -**** Additional files -Any files beyond the ones I have already named are not given special treatment. -They must be loaded manually to be loaded at all. In this way modules can be -organized in any way you wish. Still, there is one convention that has emerged -in Doom's community that you may choose to adopt: extra files in the root of the -module are prefixed with a plus, e.g. =+extra.el=. There is no syntactical or -functional significance to this convention. - -These can be loaded with the ~load!~ macro, which will load an elisp file -relative to the file it's used from. e.g. - -#+BEGIN_SRC emacs-lisp -;; Omitting the file extension allows Emacs to load the byte-compiled version, -;; if it is available: -(load! "+git") ; loads ./+git.el -#+END_SRC - -This can be useful for splitting up your configuration into multiple files, -saving you the hassle of creating multiple modules. - -*** Load order -A module's files have a precise load-order, which differs slightly depending on -what kind of session it is. Doom has three types of sessions: - -+ Interactive session :: the typical session you open when you intend to use - Emacs (e.g. for text editing). This loads the most, because you will likely be - using a lot of it. -+ Batch session :: this is a non-interactive session, loaded when you execute - Emacs commands on the command line with no UI, e.g. ~emacs --batch --eval - '(message "Hello world")'~. - - The expectation for these sessions is that it should quickly spin up, run the - command then quit, therefore very little is loaded in this session. -+ CLI session :: this is the same as a batch session /except/ it is what starts - up when you run any =bin/doom= command. - -With that out of the way, here is the load order of Doom's most important files: - -| File | Interactive | Batch | CLI | -|---------------------------------------------+-------------+-------+-----| -| ~/.emacs.d/early-init.el (Emacs 27+ only) | yes | no | no | -| ~/.emacs.d/init.el | yes | no | no | -| $DOOMDIR/init.el | yes | yes | yes | -| {~/.emacs.d,$DOOMDIR}/modules/*/*/init.el | yes | yes | yes | -| $DOOMDIR/cli.el | no | no | yes | -| {~/.emacs.d,$DOOMDIR}/modules/*/*/cli.el | no | no | yes | -| {~/.emacs.d,$DOOMDIR}/modules/*/*/config.el | yes | no | no | -| $DOOMDIR/config.el | yes | no | no | - -*** Flags -A module's flag is an arbitrary symbol. By convention, these symbols are -prefixed with a ~+~ or a ~-~ to denote the addition or removal of a feature, -respectively. There is no functional significance to this notation. - -A module may choose to interpret flags however it wishes, and can be tested for -using the ~featurep!~ macro: - -#+BEGIN_SRC elisp -;; Has the current module been enabled with the +my-feature flag? -(when (featurep! +my-feature) ...) - -;; It can be used to check the presence of flags in other modules: -(when (featurep! :lang python +lsp) ...) -#+END_SRC - -Use this fact to make aspects of a module conditional. e.g. Prevent company -plugins from loading if the =:completion company= module isn't enabled. - -*** Doom cookies -Autoload cookies were mentioned [[*=autoload/*.el= OR =autoload.el=][earlier]]. A couple more exist that are specific -to Doom Emacs. This section will go over what they do and how to use them. - -**** ~;;;###if~ -Any file in a module can have a ~;;;###if FORM~ cookie at or near the top of the -file (must be within the first 256 bytes of the file). =FORM= is evaluated to -determine whether or not to include this file for autoloads scanning (on ~doom -sync~) or byte-compilation (on ~doom compile~). - -i.e. if =FORM= returns ~nil~, Doom will neither index its ~;;;###autoload~ -cookies nor byte-compile the file. - -Use this to prevent errors that would occur if certain conditions aren't met. -For example, say =file.el= is using a certain function that won't be available -if the containing module wasn't enabled with a particular flag. We could safe -guard against this with: -#+BEGIN_SRC emacs-lisp -;;;###if (featurep! +particular-flag) -#+END_SRC - -This will prevent errors at compile time or if/when that file is loaded. - -Another example, this time contingent on =so-long= *not* being present: -#+BEGIN_SRC emacs-lisp -;;;###if (not (locate-library "so-long")) -#+END_SRC - -#+begin_quote -Keep in mind that =FORM= runs in a limited, non-interactive sub-session. I don't -recommend doing anything expensive or especially complicated in them. -#+end_quote - -**** ~;;;###package~ -This cookie exists solely to assist the ~doom/help-packages~ command. This -command shows you documentation about packages in the Emacs ecosystem, including -the ones that are installed. It also lists a) all the modules that install said -package and b) all the places it is configured. - -It accomplishes A by scanning for at ~package!~ declarations for that package, -but it accomplishes B by scanning for: - -+ ~after!~ calls -+ ~use-package!~ or ~use-package~ calls -+ and ~;;;###package X~ cookies, where X is the name of the package - -Use it to let ~doom/help-packages~ know where to find config for packages where -no ~after!~ or ~use-package!~ call is involved. - -**** ~;;;###autodef~ -An autodef is a special kind of autoloaded function (or macro) which Doom -guarantees will /always/ be defined, whether or not its containing module is -enabled (but will no-op if it is disabled). - -#+begin_quote -If the containing module is disabled the definition is replaced with a macro -that does not process its arguments, so it is a zero-cost abstraction. -#+end_quote - -You can browse the available autodefs in your current session with ~M-x -doom/help-autodefs~ (=SPC h d u= or =C-h d u=). - -An autodef cookie is used in exactly the same way as the autoload cookie: -#+BEGIN_SRC elisp -;;;###autodef -(defun set-something! (value) - ...) -#+END_SRC - -An example would be the ~set-company-backend!~ function that the =:completion -company= module exposes. It lets you register company completion backends with -certain major modes. For instance: -#+BEGIN_SRC emacs-lisp -(set-company-backend! 'python-mode '(company-anaconda)) -#+END_SRC - -And if =:completion company= is disabled, this call and its arguments are left -unprocessed and ignored. - -** Common mistakes when configuring Doom Emacs -Having helped many users configure Doom, I've spotted a few recurring oversights -that I will list here, in the hopes that it will help you avoid the same -mistakes: - -*** Packages are eagerly loaded -Using ~use-package!~ without a deferring keyword (one of: ~:defer :after -:commands :defer-incrementally :after-call~) will load the package immediately. -This causes other packages to be pulled in and loaded, which will compromise -many of Doom's startup optimizations. - -This is usually by accident. Choosing which keyword to use depends on the -needs of the package, so there is no simple answer to this. - -*** Manual package management -A lot of Emacs documentation and help will contain advice to install packages -with package.el's API (e.g. ~package-install~) or with use-package's ~:ensure~ -keyword). You are free to do this, if it is your preference, but otherwise, Doom -has its own package management system. - -Migrating ~use-package~ code to Doom is usually a case of removing the ~:ensure~ -keyword and adding a ~(package! PACKAGENAME)~ to =~/.doom.d/packages.el= (and -running ~doom sync~ to sync your config). - -*** Using ~org-babel-do-load-languages~ to load your babel packages -You don't need ~org-babel-do-load-languages~. Doom lazy loads babel packages -based on the language name in ~#+BEGIN_SRC~ blocks needed. As long as the babel -plugin is installed and the plugin is named after its language (e.g. -~#+BEGIN_SRC rust~ will load ~ob-rust~), you don't need to do anything else. - -There may be some special cases, however. Doom tries to handle a couple of them -(e.g. with ob-jupyter, ob-ipython and ob-async). If you are experiencing errors -while trying to use a certain language in org src blocks, check out the [[file:../modules/lang/org/README.org][:lang -org module documentation]] for details on how to add support for it. - -*** Using ~delete-trailing-whitespaces~ or ~whitespace-cleanup~ to manage leftover whitespace -#+BEGIN_SRC elisp -(add-hook 'after-save-hook #'delete-trailing-whitespace) -;; or -(add-hook 'after-save-hook #'whitespace-cleanup) -#+END_SRC - -These two lines are a common sight in Emacs configs, but they are unnecessary -for Doom Emacs. We already use the more sophisticated =ws-butler= to manage -extraneous whitespace. However, you might have the impression that it isn't -working. That's because =ws-butler= works in two unusual ways, meant to be less -imposing than its alternatives: - -1. It only cleans up trailing whitespace /on lines that you've touched/ (but - always strips newlines at EOF). - - Why do this? Because I believe file-wide reformatting should be a deliberate - act (and not blindly automated). If it is necessary, chances are you're - working on somebody else's project -- or with other people, but here, large - scale whitespace changes could cause problems or simply be rude. We don't - endorse PRs that are 1% contribution and 99% whitespace! - - However, if it's truly deliberate, ~M-x delete-trailing-whitespaces~ and ~M-x - whitespace-cleanup~ are available to be called =deliberately=, instead. - -2. =ws-butler= replaces trailing whitespace and newlines with *virtual* - whitespace. This is whitespace that only exists in the Emacs buffer, but - isn't actually written to the file. - - Why do this? Because you might have wanted to use that space for something in - your current editing session, and it would be inconvenient for the editor to - delete it before you got to it. - - If you use it, it's there. If you don't, it isn't written to the file. - -* Troubleshoot -When problems arise, you should be prepared to collect information in order to -solve them, or for the bug report you're about to write. Both Emacs and Doom -provide tools to make this easier. Here are a few things you can try, first: - -+ Investigate the =*Messages*= log for warnings or error messages. This log can - be opened with =SPC h e=, =C-h e= or =M-x view-echo-area-messages=. - -+ Look up errors/warnings [[file:faq.org::Common Issues][on the FAQ]] and [[https://github.com/hlissner/doom-emacs/issues][Doom's issue tracker]]. It is possible - that a solution for your issue already exists. The FAQ can be searched from - inside Doom with =SPC h d f= (or =C-h d f= for non-evil users). - -+ Run ~bin/doom doctor~ on the command line to diagnose common issues with your - environment and config. It will suggest solutions for them as well. - -+ ~bin/doom clean~ will ensure the problem isn't stale bytecode in your private - config or Doom core. If you haven't used ~bin/doom compile~, there's no need - to do this. - -+ ~bin/doom sync~ will ensure the problem isn't missing packages or outdated - autoloads files - -+ ~bin/doom build~ will ensure the problem isn't stale package bytecode or - broken symlinks. - -+ ~bin/doom update~ will ensure that your packages are up-to-date, eliminating - issues that originate from upstream. - -+ If you happen to know what module(s) are relevant to your issue, check their - documentation (press =<leader> h d m= to jump to a module's documentation). Your - issue may be documented. - -+ If possible, see if the issue can be reproduced in vanilla Emacs (Emacs - without Doom) and/or vanilla Doom (Doom without your private config). [[#testing-in-dooms-sandbox][Doom's - sandbox can help you check]]. - -+ Ask for help on [[https://discord.gg/qvGgnVx][our Discord server]]. It is the quickest way to get help, - sometimes straight from Doom's maintainer, who is very active there. - -If none of these things have helped you, then it's time to open a bug report. -See "[[file:contributing.org::*Reporting issues][Reporting Issues]]" in the [[file:contributing.org][contributing guidelines]] on how to file an -effective bug report. - -** Looking up documentation and state from within Emacs -... - -*** Variables, functions, faces, etc. -Emacs is a Lisp interpreter whose state you can access on-the-fly with tools -provided to you by Emacs itself. They're available on the =SPC h= prefix by -default. Use them to debug your sessions. - -Here are some of the more important ones: - -+ ~describe-variable~ (=SPC h v=) -+ ~describe-function~ (=SPC h f=) -+ ~describe-face~ (=SPC h F=) -+ ~describe-bindings~ (=SPC h b=) -+ ~describe-key~ (=SPC h k=) -+ ~describe-char~ (=SPC h '=) -+ ~find-library~ (=SPC h P=) - -You can also evaluate code with ~eval-expression~ (=M-;= or =SPC ;=). - -*** TODO For Doom Modules, packages, autodefs, etc. -+ ~doom/open-news~ (=SPC h n=) :: - ... -+ ~doom/help~ (=SPC h d h=) :: - Open the index of Doom's manual. -+ ~doom/help-modules~ (=SPC h d m=) :: - Jumps to a module's documentation. -+ ~doom/help-autodefs~ (=SPC h u=) :: - Jumps to the documentation for an autodef function/macro. These are special - functions that are always defined, whether or not their containing modules - are enabled. -+ ~doom/help-packages~ (=SPC h p=) :: - Look up packages that are installed, by whom (what modules) and where jump - to all the places it is being configured. -+ ~doom/info~ :: - ... - -** How to extract a backtrace from an error -If you encounter an error while using Doom Emacs, you're probably about to head -off and file a bug report (or request help on [[https://discord.gg/qvGgnVx][our Discord server]]). Before you -do, please generate a backtrace to include with it. - -To do so you must enable ~debug-on-error~ then recreate the error. - -*** Enabling ~debug-on-error~ -There are three ways to enable ~debug-on-error~: - -1. Start Emacs with ~emacs --debug-init~. Use this for errors that occur at - startup. -2. Evil users can press =SPC h d d= and non-evil users can press =C-h d d=. -3. If the above don't work, there's always: ~M-x toggle-debug-on-error~ - -Now that ~debug-on-error~ is on, recreate the error. A window should pop up with -a backtrace. - -*** A backtrace from ~bin/doom~ -If the error you've encountered is emitted from ~bin/doom~, you can re-run the -same command with the ~-d~ or ~--debug~ switches to force it to emit a backtrace -when an error occurs. The ~DEBUG~ environment variable will work to. - -#+BEGIN_SRC sh -doom -d sync -doom --debug install -DEBUG=1 doom update -#+END_SRC - -#+BEGIN_QUOTE -Note: switch order is important. ~-d~ / ~--debug~ /must/ come right after ~doom~ -and before the subcommand. This will be fixed eventually. -#+END_QUOTE - -** Evaluating Elisp on-the-fly -Often, you may find it helpful for debugging to evaluate some Emacs Lisp. Here -are couple things you can do: - -+ Use =M-:= (bound to ~eval-expression~), -+ =SPC x= will open a scratch buffer. ~M-x emacs-lisp-mode~ will change it to - the appropriate major mode, then use ~+eval:region~ (=gr=) and ~+eval/buffer~ - (=gR=) to evaluate code, - -** How to determine the origin of a bug -** Testing in Doom's sandbox -"The sandbox" is one of Doom Emacs' features; it is a test bed for running elisp -in a fresh instance of Emacs with varying amounts of Doom loaded (none at all, -all of it, or somewhere in between). This can be helpful for isolating bugs to -determine who you should report a bug to. - -If you can recreate a bug in vanilla Emacs then it should be reported to the -developers of the relevant packages or, perhaps, the Emacs devs themselves. - -Otherwise, it is best to bring it up on the Doom Emacs issue list, rather than -confusing and inundating the Emacs community with Doom-specific issues. - -*** Opening the sandbox -There are three common ways to access the sandbox: - -+ =SPC h E= (for evil users) -+ =C-h E= (for non-evil users) -+ ~M-x doom/sandbox~ - -Doing any of the above will pop up a ~*doom:sandbox*~ window. What you enter -into this buffer will be executed in the new instance of Emacs when you decide -to launch it. - -*** Launching the sandbox -You have four options when it comes to launching the sandbox: - -- =C-c C-c= :: This launches "vanilla Emacs". Vanilla means nothing is loaded; - purely Emacs and nothing else. If you can reproduce an error here, then the - issue likely lies in the plugin(s) you are testing or in Emacs itself. -- =C-c C-d= :: This launches "vanilla Doom", which is vanilla Emacs plus Doom's - core. This does not load your private config, nor any of Doom's (or your) - modules. -- =C-c C-p= :: This launches "vanilla Doom+". That is, Doom core plus the - modules that you have specified in the ~doom!~ block of your private config - (in =~/.doom.d/init.el=). This *does not* load your private config, however. -- =C-c C-f= :: This launches "full Doom". It loads Doom's core, your enabled - modules, and your private config. This instance should be identical to the - instance you launched it from. - -#+BEGIN_QUOTE -All new instances will inherit your ~load-path~ so you can access any packages -you have installed. -#+END_QUOTE -*** Testing packages in the sandbox -Instances of Emacs launched from the sandbox have inherited your ~load-path~. -This means you can load packages -- even in Vanilla Emacs -- without worrying -about installing or setting them up. Just ~(require PACKAGE)~ and launch the -sandbox. e.g. - -#+BEGIN_SRC elisp -(require 'magit) -(find-file "~/some/file/in/a/repo") -(call-interactively #'magit-status) -#+END_SRC - -** TODO Bisecting your private config -** TODO Bisecting Doom Emacs diff --git a/.config/emacs/docs/index.org b/.config/emacs/docs/index.org @@ -1,106 +0,0 @@ -#+TITLE: Doom Emacs Documentation -#+STARTUP: nofold - -Doom is a configuration framework for [[https://www.gnu.org/software/emacs/][GNU Emacs 26.3+]] tailored for Emacs -bankruptcy veterans who want less framework in their frameworks and the -performance of a hand rolled config (or better). It can be a foundation for your -own config or a resource for Emacs enthusiasts to learn more about our favorite -OS. - -Doom is an opinionated collection of reasonable (and optional) defaults with a -focus on performance (both runtime and startup) and on abstraction-light, -readable code design, so that there is less between you and Emacs. - -#+begin_quote -The documentation is designed to be viewed within Doom Emacs. Access it by -pressing =SPC h d h= (or =C-h d h= for non-evil users), or search it with =SPC h -d s= (or =C-h d s=). -#+end_quote - -* Table of Contents :TOC: -- [[#release-notes][Release Notes]] -- [[#documentation][Documentation]] - - [[#getting-started][Getting Started]] - - [[#frequently-asked-questions][Frequently Asked Questions]] - - [[#contributing][Contributing]] - - [[#workflow-tips-tricks--tutorials][Workflow Tips, Tricks & Tutorials]] - - [[#module-appendix][Module Appendix]] -- [[#community-resources][Community Resources]] - - [[#asking-for-help][Asking for help]] - - [[#project-roadmap][Project roadmap]] - - [[#tutorials--guides][Tutorials & guides]] - - [[#projects-that-supportcomplement-doom][Projects that support/complement Doom]] - - [[#similar-projects][Similar projects]] - -* TODO Release Notes - -* Documentation -** [[file:getting_started.org][Getting Started]] -- [[file:getting_started.org::*Install][Install]] -- [[file:getting_started.org::*Update & Rollback][Update & Rollback]] -- [[file:getting_started.org::*Configure][Configure]] -- [[file:getting_started.org::*Migrate][Migrate]] -- [[file:getting_started.org::*Troubleshoot][Troubleshoot]] - -** [[file:faq.org][Frequently Asked Questions]] -- [[file:faq.org::*General][General]] -- [[file:faq.org::*Configuration][Configuration]] -- [[file:faq.org::*Package Management][Package Management]] -- [[file:faq.org::*Defaults][Defaults]] -- [[file:faq.org::Common Issues][Common Issues]] -- [[file:faq.org::Contributing][Contributing]] - -** TODO [[file:contributing.org][Contributing]] -- [[file:contributing.org::*Where can I help?][Where to get help?]] -- Reporting issues -- Suggesting features, keybinds and enhancements -- Contributing code or documentation -- Other ways to support Doom Emacs -- Special thanks - -** TODO [[file:workflow.org][Workflow Tips, Tricks & Tutorials]] - -** [[file:modules.org][Module Appendix]] - -* Community Resources -** Asking for help -- [[https://discord.gg/qvGgnVx][Our Discord server]] -- [[https://github.com/hlissner/doom-emacs/issues][Our issue tracker]] - -** Project roadmap -- [[https://github.com/hlissner/doom-emacs/projects/3][Development roadmap]] - A timeline outlining what's being worked on and when it - is expected to be done. -- [[https://github.com/hlissner/doom-emacs/projects/2][Plugins under review]] - A sitrep on third party plugins that we've considered, - rejected, or awaiting integration into Doom. -- [[https://github.com/hlissner/doom-emacs/projects/5][Upstream bugs]] - Tracks issues originating from plugins and external programs - that Doom relies on. - -** Tutorials & guides -+ *Doom Emacs* - - (videos) [[https://www.youtube.com/playlist?list=PLyy8KUDC8P7X6YkegqrnEnymzMWCNB4bN][Doom Emacs Tutorials]] by [[https://www.youtube.com/channel/UCVls1GmFKf6WlTraIb_IaJg][DistroTube]] - - (videos) [[https://www.youtube.com/playlist?list=PLhXZp00uXBk4np17N39WvB80zgxlZfVwj][DoomCasts]] by @zaiste - - [[https://noelwelsh.com/posts/doom-emacs][Noel's crash course on Doom Emacs]] - - [[https://medium.com/@aria_39488/getting-started-with-doom-emacs-a-great-transition-from-vim-to-emacs-9bab8e0d8458][Getting Started with Doom Emacs -- a great transition from Vim to Emacs]] - - [[https://medium.com/@aria_39488/the-niceties-of-evil-in-doom-emacs-cabb46a9446b][The Niceties of evil in Doom Emacs]] - - (video) [[https://www.youtube.com/watch?v=GK3fij-D1G8][Org-mode, literate programming in (Doom) Emacs]] -+ *Emacs & Emacs Lisp* - - [[https://www.gnu.org/software/emacs/manual/html_node/elisp/index.html][The Official Emacs manual]] - - A variety of Emacs resources - https://github.com/ema2159/awesome-emacs - - Quick crash courses on Emacs Lisp's syntax for programmers: - - https://learnxinyminutes.com/docs/elisp/ - - http://steve-yegge.blogspot.com/2008/01/emergency-elisp.html - - Workflows for customizing Emacs and its packages (and its C/C++ modes): - - https://david.rothlis.net/emacs/customize_c.html - - *Tools in Emacs* - - [[https://www.emacswiki.org/emacs/Calc_Tutorials_by_Andrew_Hyatt][How to use M-x calc]] -+ *Vim & Evil* - - [[https://gist.github.com/dmsul/8bb08c686b70d5a68da0e2cb81cd857f][A crash course on modal editing and Ex commands]] - -** Projects that support/complement Doom -+ [[https://github.com/plexus/chemacs][plexus/chemacs]] -+ [[https://github.com/r-darwish/topgrade][r-darwish/topgrade]] - -** Similar projects -+ [[https://github.com/purcell/emacs.d][purcell/emacs.d]] -+ [[https://github.com/seagle0128/.emacs.d][seagle0128/.emacs.d]] -+ [[https://github.com/syl20bnr/spacemacs][syl20bnr/spacemacs]] diff --git a/.config/emacs/docs/modules.org b/.config/emacs/docs/modules.org @@ -1,224 +0,0 @@ -#+TITLE: Module Index -#+STARTUP: nofold - -Functionality in Doom is divided into collections of code called modules (à la -Spacemacs' layers). A module is a bundle of packages, configuration and -commands, organized into a unit that can be enabled or disabled by adding or -removing them from your ~doom!~ block in =$DOOMDIR/init.el=. - -* Table of Contents :TOC: -- [[#app][:app]] -- [[#checkers][:checkers]] -- [[#completion][:completion]] -- [[#config][:config]] -- [[#editor][:editor]] -- [[#emacs][:emacs]] -- [[#email][:email]] -- [[#input][:input]] -- [[#lang][:lang]] -- [[#os][:os]] -- [[#term][:term]] -- [[#tools][:tools]] -- [[#ui][:ui]] - -* :app -Application modules are complex and opinionated modules that transform Emacs -toward a specific purpose. They may have additional dependencies and *should be -loaded last*, before =:config= modules. - -+ [[file:../modules/app/calendar/README.org][calendar]] - TODO -+ [[file:../modules/app/emms/README.org][emms]] - TODO -+ [[file:../modules/app/everywhere/README.org][everywhere]] - TODO -+ [[file:../modules/app/irc/README.org][irc]] - how neckbeards socialize -+ [[file:../modules/app/rss/README.org][rss]] =+org= - an RSS client in Emacs -+ [[file:../modules/app/twitter/README.org][twitter]] - A twitter client for Emacs - -* :checkers -+ syntax =+childframe= - Live error/warning highlights -+ [[file:../modules/checkers/spell/README.org][spell]] =+aspell +flyspell +enchant +everywhere +hunspell= - Spell checking -+ [[file:../modules/checkers/grammar/README.org][grammar]] - TODO - -* :completion -Modules that provide new interfaces or frameworks for completion, including code -completion. - -+ [[file:../modules/completion/company/README.org][company]] =+childframe +tng= - The ultimate code completion backend -+ helm =+fuzzy +childframe= - *Another* search engine for love and life -+ ido - The /other/ *other* search engine for love and life -+ [[file:../modules/completion/ivy/README.org][ivy]] =+fuzzy +prescient +childframe +icons= - /The/ search engine for love and life -+ [[file:../modules/completion/vertico/README.org][vertico]] =+icons= - The search engine of the future - -* :config -Modules that configure Emacs one way or another, or focus on making it easier -for you to customize it yourself. It is best to load these last. - -+ [[file:../modules/config/literate/README.org][literate]] - For users with literate configs. This will tangle+compile a - config.org in your ~doom-private-dir~ when it changes. -+ [[file:../modules/config/default/README.org][default]] =+bindings +smartparens= - The default module sets reasonable defaults - for Emacs. It also provides a Spacemacs-inspired keybinding scheme and a - smartparens config. Use it as a reference for your own modules. - -* :editor -Modules that affect and augment your ability to manipulate or insert text. - -+ [[file:../modules/editor/evil/README.org][evil]] =+everywhere= - transforms Emacs into Vim -+ [[file:../modules/editor/file-templates/README.org][file-templates]] - Auto-inserted templates in blank new files -+ [[file:../modules/editor/fold/README.org][fold]] - universal code folding -+ format =+onsave= - TODO -+ god - TODO -+ [[file:../modules/editor/lispy/README.org][lispy]] - TODO -+ multiple-cursors - TODO -+ [[file:../modules/editor/objed/README.org][objed]] =+manual= - TODO -+ [[file:../modules/editor/parinfer/README.org][parinfer]] - TODO -+ rotate-text - TODO -+ [[file:../modules/editor/snippets/README.org][snippets]] - Snippet expansion for lazy typists -+ [[file:../modules/editor/word-wrap/README.org][word-wrap]] - soft wrapping with language-aware indent - -* :emacs -Modules that reconfigure or augment packages or features built into Emacs. - -+ [[file:../modules/emacs/dired/README.org][dired]] =+ranger +icons= - TODO -+ electric - TODO -+ [[file:../modules/emacs/ibuffer/README.org][ibuffer]] =+icons= - TODO -+ [[file:../modules/emacs/undo/README.org][undo]] =+tree= - A smarter, more intuitive & persistent undo history -+ [[file:../modules/emacs/vc/README.org][vc]] - TODO - -* :email -+ [[file:../modules/email/mu4e/README.org][mu4e]] =+org +gmail= - TODO -+ [[file:../modules/email/notmuch/README.org][notmuch]] - TODO -+ wanderlust =+gmail= - TODO - -* :input -+ [[file:../modules/input/chinese/README.org][chinese]] - TODO -+ [[file:../modules/input/japanese/README.org][japanese]] - TODO -+ [[file:../modules/input/layout/README.org][layout]] =+azerty +bepo= - TODO - -* :lang -Modules that bring support for a language or group of languages to Emacs. - -+ [[file:../modules/lang/agda/README.org][agda]] =+local= - TODO -+ [[file:../modules/lang/beancount/README.org][beancount]] =+lsp= - TODO -+ [[file:../modules/lang/cc/README.org][cc]] =+lsp= - TODO -+ [[file:../modules/lang/clojure/README.org][clojure]] =+lsp= - TODO -+ common-lisp - TODO -+ [[file:../modules/lang/coq/README.org][coq]] - TODO -+ [[file:../modules/lang/crystal/README.org][crystal]] - TODO -+ [[file:../modules/lang/csharp/README.org][csharp]] =+lsp +unity= - TODO -+ [[file:../modules/lang/dart/README.org][dart]] =+lsp +flutter= -+ data - TODO -+ [[file:../modules/lang/elixir/README.org][elixir]] =+lsp= - TODO -+ elm =+lsp= - TODO -+ [[file:../modules/lang/emacs-lisp/README.org][emacs-lisp]] - TODO -+ [[file:../modules/lang/erlang/README.org][erlang]] =+lsp= - TODO -+ [[file:../modules/lang/ess/README.org][ess]] =+lsp= - TODO -+ [[file:../modules/lang/factor/README.org][factor]] - TODO -+ [[file:../modules/lang/faust/README.org][faust]] - TODO -+ [[file:../modules/lang/fsharp/README.org][fsharp]] =+lsp= - TODO -+ [[file:../modules/lang/fstar/README.org][fstar]] - F* support -+ [[file:../modules/lang/gdscript/README.org][gdscript]] =+lsp= - TODO -+ [[file:../modules/lang/go/README.org][go]] =+lsp= - TODO -+ [[file:../modules/lang/haskell/README.org][haskell]] =+lsp= - TODO -+ hy - TODO -+ [[file:../modules/lang/idris/README.org][idris]] - TODO -+ java =+meghanada +eclim +lsp= - TODO -+ [[file:../modules/lang/javascript/README.org][javascript]] =+lsp= - JavaScript, TypeScript, and CoffeeScript support -+ [[file:../modules/lang/json/README.org][json]] =+lsp= - TODO -+ [[file:../modules/lang/julia/README.org][julia]] =+lsp= - TODO -+ [[file:../modules/lang/kotlin/README.org][kotlin]] =+lsp= - TODO -+ [[file:../modules/lang/latex/README.org][latex]] =+latexmk +cdlatex +fold +lsp= - TODO -+ lean - TODO -+ [[file:../modules/lang/ledger/README.org][ledger]] - TODO -+ [[file:../modules/lang/lua/README.org][lua]] =+fennel +moonscript= - TODO -+ [[file:../modules/lang/markdown/README.org][markdown]] =+grip= - TODO -+ [[file:../modules/lang/nim/README.org][nim]] - TODO -+ [[file:../modules/lang/nix/README.org][nix]] - TODO -+ [[file:../modules/lang/ocaml/README.org][ocaml]] =+lsp= - TODO -+ [[file:../modules/lang/org/README.org][org]] =+brain +dragndrop +gnuplot +hugo +ipython +journal +jupyter +noter +pandoc +pomodoro +present +pretty +roam= - TODO -+ [[file:../modules/lang/php/README.org][php]] =+hack +lsp= - TODO -+ plantuml - TODO -+ purescript =+lsp= - TODO -+ [[file:../modules/lang/python/README.org][python]] =+cython +lsp +pyright +pyenv +conda +poetry= - TODO -+ qt - TODO -+ [[file:../modules/lang/racket/README.org][racket]] =+lsp +xp= - TODO -+ [[file:../modules/lang/raku/README.org][raku]] - TODO -+ [[file:../modules/lang/rest/README.org][rest]] - TODO -+ rst - TODO -+ [[file:../modules/lang/ruby/README.org][ruby]] =+lsp +rvm +rbenv +rails +chruby= -+ [[file:../modules/lang/rust/README.org][rust]] =+lsp= - TODO -+ [[file:../modules/lang/scala/README.org][scala]] =+lsp= - TODO -+ [[file:../modules/lang/scheme/README.org][scheme]] =+chez +chibi +chicken +gambit +gauche +guile +kawa +mit +racket= - TODO -+ [[file:../modules/lang/sh/README.org][sh]] =+fish +lsp +powershell= - TODO -+ [[file:../modules/lang/sml/README.org][sml]] - TODO -+ [[file:../modules/lang/solidity/README.org][solidity]] - TODO -+ swift =+lsp= - TODO -+ terra - TODO -+ web =+lsp= - HTML and CSS (SCSS/SASS/LESS/Stylus) support. -+ [[file:../modules/lang/yaml/README.org][yaml]] =+lsp= - TODO -+ [[file:../modules/lang/zig/README.org][zig]] =+lsp= - Zig support. - - -* :os -Modules to improve integration into your OS, system, or devices. - -+ [[file:../modules/os/macos/README.org][macos]] - Improve Emacs' compatibility with macOS -+ [[file:../modules/os/tty/README.org][tty]] =+osc= - Improves the terminal Emacs experience. - -* :term -Modules that offer terminal emulation. - -+ [[file:../modules/term/eshell/README.org][eshell]] - TODO -+ shell - TODO -+ term - TODO -+ [[file:../modules/term/vterm/README.org][vterm]] - TODO - -* :tools -Small modules that give Emacs access to external tools & services. - -+ ansible - TODO -+ debugger =+lsp= - A (nigh-)universal debugger in Emacs -+ [[file:../modules/tools/direnv/README.org][direnv]] - TODO -+ [[file:../modules/tools/docker/README.org][docker]] =+lsp= - TODO -+ [[file:../modules/tools/editorconfig/README.org][editorconfig]] - TODO -+ [[file:../modules/tools/ein/README.org][ein]] - TODO -+ [[file:../modules/tools/eval/README.org][eval]] =+overlay= - REPL & code evaluation support for a variety of languages -+ gist - TODO -+ [[file:../modules/tools/lookup/README.org][lookup]] =+dictionary +docsets +offline= - Universal jump-to & documentation lookup - backend -+ [[file:../modules/tools/lsp/README.org][lsp]] =+peek +eglot= - Installation and configuration of language server protocol client (lsp-mode or eglot) -+ [[file:../modules/tools/magit/README.org][magit]] =+forge= - TODO -+ make - TODO -+ [[file:../modules/tools/pass/README.org][pass]] =+auth= - TODO -+ [[file:../modules/tools/pdf/README.org][pdf]] - TODO -+ prodigy - TODO -+ [[file:../modules/tools/rgb/README.org][rgb]] - TODO -+ [[file:../modules/tools/taskrunner/README.org][taskrunner]] - TODO -+ [[file:../modules/tools/terraform/README.org][terraform]] - TODO -+ tmux - TODO -+ [[file:../modules/tools/upload/README.org][upload]] - TODO - -* :ui -Aesthetic modules that affect the Emacs interface or user experience. - -+ [[file:../modules/ui/deft/README.org][deft]] - TODO -+ [[file:../modules/ui/doom/README.org][doom]] - TODO -+ [[file:../modules/ui/doom-dashboard/README.org][doom-dashboard]] - TODO -+ [[file:../modules/ui/doom-quit/README.org][doom-quit]] - TODO -+ [[file:../modules/ui/emoji/README.org][emoji]] =+ascii +github +unicode= - Adds emoji support to Emacs -+ [[file:../modules/ui/hl-todo/README.org][hl-todo]] - TODO -+ [[file:../modules/ui/hydra/README.org][hydra]] - TODO -+ indent-guides - TODO -+ [[file:../modules/ui/ligatures/README.org][ligatures]] =+extra +fira +hasklig +iosevka +pragmata-pro= - Ligature support for Emacs -+ [[file:../modules/ui/minimap/README.org][minimap]] - TODO -+ [[file:../modules/ui/modeline/README.org][modeline]] =+light= - TODO -+ [[file:../modules/ui/nav-flash/README.org][nav-flash]] - TODO -+ [[file:../modules/ui/neotree/README.org][neotree]] - TODO -+ [[file:../modules/ui/ophints/README.org][ophints]] - TODO -+ [[file:../modules/ui/popup/README.org][popup]] =+all +defaults= - Makes temporary/disposable windows less intrusive -+ [[file:../modules/ui/tabs/README.org][tabs]] - TODO -+ [[file:../modules/ui/treemacs/README.org][treemacs]] - =+lsp= - A tree layout file explorer for Emacs -+ [[file:../modules/ui/unicode/README.org][unicode]] - TODO -+ vc-gutter - TODO -+ vi-tilde-fringe - TODO -+ [[file:../modules/ui/window-select/README.org][window-select]] =+switch-window +numbers= - TODO -+ [[file:../modules/ui/workspaces/README.org][workspaces]] - Isolated workspaces -+ [[file:../modules/ui/zen/README.org][zen]] - Distraction-free coding (or writing) diff --git a/.config/emacs/early-init.el b/.config/emacs/early-init.el @@ -1,142 +0,0 @@ -;;; early-init.el --- Doom's universal bootstrapper -*- lexical-binding: t -*- -;;; Commentary: -;; -;; This file, in summary: -;; - Determines where `user-emacs-directory' is by: -;; - Processing `--init-directory DIR' (backported from Emacs 29), -;; - Processing `--profile NAME' (see -;; `https://docs.doomemacs.org/-/developers' or docs/developers.org), -;; - Or assume that it's the directory this file lives in. -;; - Loads Doom as efficiently as possible, with only the essential startup -;; optimizations, and prepares it for interactive or non-interactive sessions. -;; - If Doom isn't present, then we assume that Doom is being used as a -;; bootloader and the user wants to load a non-Doom config, so we undo all our -;; global side-effects, load `user-emacs-directory'/early-init.el, and carry -;; on as normal (without Doom). -;; - Do all this without breaking compatibility with Chemacs. -;; -;; early-init.el was introduced in Emacs 27.1. It is loaded before init.el, -;; before Emacs initializes its UI or package.el, and before site files are -;; loaded. This is great place for startup optimizing, because only here can you -;; *prevent* things from loading, rather than turn them off after-the-fact. -;; -;; Doom uses this file as its "universal bootstrapper" for both interactive and -;; non-interactive sessions. That means: no matter what environment you want -;; Doom in, load this file first. -;; -;;; Code: - -;; PERF: Garbage collection is a big contributor to startup times. This fends it -;; off, but will be reset later by `gcmh-mode'. Not resetting it later will -;; cause stuttering/freezes. -(setq gc-cons-threshold most-positive-fixnum) - -;; PERF: Don't use precious startup time checking mtime on elisp bytecode. -;; Ensuring correctness is 'doom sync's job, not the interactive session's. -;; Still, stale byte-code will cause *heavy* losses in startup efficiency. -(setq load-prefer-newer noninteractive) - -;; UX: Respect DEBUG envvar as an alternative to --debug-init, and to make are -;; startup sufficiently verbose from this point on. -(when (getenv-internal "DEBUG") - (setq init-file-debug t - debug-on-error t)) - - -;; -;;; Bootstrap - -(or - ;; PERF: `file-name-handler-alist' is consulted often. Unsetting it offers a - ;; notable saving in startup time. This let-binding is just a stopgap though, - ;; a more complete version of this optimization can be found in lisp/doom.el. - (let (file-name-handler-alist) - (let* (;; FIX: Unset `command-line-args' in noninteractive sessions, to - ;; ensure upstream switches aren't misinterpreted. - (command-line-args (unless noninteractive command-line-args)) - ;; I avoid using `command-switch-alist' to process --profile (and - ;; --init-directory) because it is processed too late to change - ;; `user-emacs-directory' in time. - (profile (or (cadr (member "--profile" command-line-args)) - (getenv-internal "DOOMPROFILE")))) - (if (null profile) - ;; REVIEW: Backported from Emacs 29. Remove when 28 support is dropped. - (let ((init-dir (or (cadr (member "--init-directory" command-line-args)) - (getenv-internal "EMACSDIR")))) - (if (null init-dir) - ;; FIX: If we've been loaded directly (via 'emacs -batch -l - ;; early-init.el') or by a doomscript (like bin/doom), and Doom - ;; is in a non-standard location (and/or Chemacs is used), then - ;; `user-emacs-directory' will be wrong. - (when noninteractive - (setq user-emacs-directory - (file-name-directory (file-truename load-file-name)))) - ;; FIX: To prevent "invalid option" errors later. - (push (cons "--init-directory" (lambda (_) (pop argv))) command-switch-alist) - (setq user-emacs-directory (expand-file-name init-dir)))) - ;; FIX: Discard the switch to prevent "invalid option" errors later. - (push (cons "--profile" (lambda (_) (pop argv))) command-switch-alist) - ;; Running 'doom sync' or 'doom profile sync' (re)generates a light - ;; profile loader in $EMACSDIR/profiles/load.el (or - ;; $DOOMPROFILELOADFILE), after reading `doom-profile-load-path'. This - ;; loader requires `$DOOMPROFILE' be set to function. - (setenv "DOOMPROFILE" profile) - (or (load (expand-file-name - (format (let ((lfile (getenv-internal "DOOMPROFILELOADFILE"))) - (if lfile - (concat (string-remove-suffix ".el" lfile) - ".%d.elc") - "profiles/load.%d.elc")) - emacs-major-version) - user-emacs-directory) - 'noerror (not init-file-debug) 'nosuffix) - (user-error "Profiles not initialized yet; run 'doom sync' first")))) - - ;; PERF: When `load'ing or `require'ing files, each permutation of - ;; `load-suffixes' and `load-file-rep-suffixes' (then `load-suffixes' + - ;; `load-file-rep-suffixes') is used to locate the file. Each permutation - ;; is a file op, which is normally very fast, but they can add up over the - ;; hundreds/thousands of files Emacs needs to load. - ;; - ;; To reduce that burden -- and since Doom doesn't load any dynamic modules - ;; -- I remove `.so' from `load-suffixes' and pass the `must-suffix' arg to - ;; `load'. See the docs of `load' for details. - (if (let ((load-suffixes '(".elc" ".el"))) - ;; I avoid `load's NOERROR argument because other, legitimate errors - ;; (like permission or IO errors) should not be suppressed or - ;; interpreted as "this is not a Doom config". - (condition-case _ - ;; Load the heart of Doom Emacs. - (load (expand-file-name "lisp/doom" user-emacs-directory) - nil (not init-file-debug) nil 'must-suffix) - ;; Failing that, assume that we're loading a non-Doom config. - (file-missing - ;; HACK: `startup--load-user-init-file' resolves $EMACSDIR from a - ;; lexically bound `startup-init-directory', which means changes - ;; to `user-emacs-directory' won't be respected when loading - ;; $EMACSDIR/init.el, so I force it to: - (define-advice startup--load-user-init-file (:filter-args (args) reroute-to-profile) - (list (lambda () (expand-file-name "init.el" user-emacs-directory)) - nil (nth 2 args))) - ;; Set `user-init-file' for the `load' call further below, and do so - ;; here while our `file-name-handler-alist' optimization is still - ;; effective (benefits `expand-file-name'). BTW: Emacs resets - ;; `user-init-file' and `early-init-file' after this file is loaded. - (setq user-init-file (expand-file-name "early-init" user-emacs-directory)) - ;; COMPAT: I make no assumptions about the config we're going to - ;; load, so undo this file's global side-effects. - (setq load-prefer-newer t) - ;; PERF: But make an exception for `gc-cons-threshold', which I - ;; think all Emacs users and configs will benefit from. Still, - ;; setting it to `most-positive-fixnum' is dangerous if downstream - ;; does not reset it later to something reasonable, so I use 16mb - ;; as a best fit guess. It's better than Emacs' 80kb default. - (setq gc-cons-threshold (* 16 1024 1024)) - nil))) - ;; ...But if Doom loaded then continue as normal. - (doom-require (if noninteractive 'doom-cli 'doom-start)))) - - ;; Then continue on to the config/profile we want to load. - (load user-init-file 'noerror (not init-file-debug) nil 'must-suffix)) - -;;; early-init.el ends here diff --git a/.config/emacs/lisp/cli/ci.el b/.config/emacs/lisp/cli/ci.el @@ -1,458 +0,0 @@ -;;; lisp/cli/ci.el -*- lexical-binding: t; -*- - -;; -;;; Variables - -(defvar doom-ci-commit-trailer-keys - '(("Fix" ref hash url) - ("Ref" ref hash url) - ("Close" ref) - ("Revert" ref hash) - ("Amend" ref hash) - ("Co-authored-by" name) - ("Signed-off-by" name)) - "An alist of valid trailer keys and their accepted value types. - -Accapted value types can be one or more of ref, hash, url, username, or name.") - -(defvar doom-ci-commit-trailer-types - '((ref . "^\\(https?://[^ ]+\\|[^/]+/[^/]+\\)?#[0-9]+$") - (hash . "^\\(https?://[^ ]+\\|[^/]+/[^/]+@\\)?[a-z0-9]\\{12\\}$") - (url . "^https?://") - (name . "^[a-zA-Z0-9-_ \\.']+<[^@]+@[^.]+\\.[^>]+>$") - (username . "^@[^a-zA-Z0-9_-]+$")) - "An alist of valid trailer keys and their accepted value types. - -Accapted value types can be one or more of ref, hash, url, username, or name.") - -(defvar doom-ci-commit-types - '(bump dev docs feat fix merge nit perf refactor release revert test tweak) - "A list of valid commit types.") - -(defvar doom-ci-commit-scopeless-types '(bump merge release revert) - "A list of commit types whose scopes should be passed in its BODY. - - Don't: \"bump(SCOPE): ...\" - Do: \"bump: SCOPE\"") - -(defvar doom-ci-commit-scopes '("ci" doom-ci-enforce-scopeless-types) - "A list of valid commit scopes as strings, predicate functions, or lists. - -These are checked against each item in the comma-delimited scope field of the -current commit's message. E.g. 'fix(foo,bar,baz): ...' => foo, bar and baz - -Each element of this list can be one of: - -- A string, compared literally against the scope's name. -- A function predicate, taking two arguments (a scope as a symbol, and a plist - containing information about the current commit--see `doom-ci-commit-scopes' - for more about its structure). These predicates should: - - Return non-nil to immediately pass a scope. - - Throw a `user-error' to immediately fail the scope. - - Return nil to continue with the checks in this list. -- A list, denoting type-specific scopes. Its CAR is the type as a symbol, and - its CDR is a nested list of scopes as strings/predicates. E.g. - - '(docs \"faq\" \"install\" check-docs)") - -(defvar doom-ci-commit-rules - ;; TODO Extract into named functions - (list (lambda! (&key subject) - "If a fixup/squash commit, don't lint this commit" - (when (string-match "^\\(\\(?:fixup\\|squash\\)!\\|FIXUP\\|WIP\\) " subject) - (skip! (format "Found %S commit, skipping commit" (match-string 1 subject))))) - - (lambda! (&key type subject) - "Test SUBJECT length" - (let ((len (length subject))) - (cond ((memq type '(bump revert))) - ((<= len 10) - (fail! "Subject is too short (<10) and should be more descriptive")) - ((<= len 20) - (warn! "Subject is short (<20); are you sure it's descriptive enough?")) - ((> len 72) - (fail! "Subject is %d characters, above the 72 maximum" - len)) - ((> len 50) - (warn! "Subject is %d characters; <=50 is ideal" - len))))) - - (lambda! (&key type) - "Ensure commit has valid type" - (or (memq type doom-ci-commit-types) - (if type - (fail! "Invalid commit type: %s" type) - (fail! "Commit has no detectable type")))) - - (lambda! (&key summary) - "Ensure commit has a summary" - (when (or (not (stringp summary)) - (string-blank-p summary)) - (fail! "Commit has no summary"))) - - (lambda! (&key type summary subject) - "Ensure summary isn't needlessly capitalized" - (and (stringp summary) - (string-match-p "^[A-Z][^-A-Z.]" summary) - (fail! "%S in summary should not be capitalized" - (car (split-string summary " "))))) - - (lambda! (&rest plist &key type scopes) - "Ensure scopes are valid" - (dolist (scope scopes) - (condition-case e - (letf! (defun* check-rule (rule) - (or (and (stringp rule) - (string= rule scope)) - (and (functionp rule) - (funcall rule scope plist)) - (and (listp rule) - (eq type (car rule)) - (seq-find #'check-rule (cdr rule))))) - (or (seq-find #'check-rule doom-ci-commit-scopes) - (fail! "Invalid scope: %s" scope))) - (user-error (fail! "%s" (error-message-string e)))))) - - (lambda! (&key scopes) - "Esnure scopes are sorted correctly" - (unless (equal scopes (sort (copy-sequence scopes) #'string-lessp)) - (fail! "Scopes are not in lexicographical order"))) - - (lambda! (&key type body) - "Enforce 72 character line width for BODY" - (catch 'result - (with-temp-buffer - (save-excursion (insert body)) - (while (re-search-forward "^[^\n]\\{73,\\}" nil t) - (save-excursion - (or - ;; Long bump lines are acceptable - (let ((bump-re "\\(https?://.+\\|[^/]+\\)/[^/]+@[a-z0-9]\\{12\\}")) - (re-search-backward (format "^%s -> %s$" bump-re bump-re) nil t)) - ;; Long URLs are acceptable - (re-search-backward "https?://[^ ]+\\{73,\\}" nil t) - ;; Lines that start with # or whitespace are comment or - ;; code blocks. - (re-search-backward "^\\(?:#\\| +\\)" nil t) - (throw 'result (fail! "Line(s) in commit body exceed 72 characters")))))))) - - (lambda! (&key bang body type) - "Ensure ! is accompanied by a 'BREAKING CHANGE:' in BODY" - (if bang - (cond ((not (string-match-p "^BREAKING CHANGE:" body)) - (fail! "'!' present in commit type, but missing 'BREAKING CHANGE:' in body")) - ((not (string-match-p "^BREAKING CHANGE: .+" body)) - (fail! "'BREAKING CHANGE:' present in commit body, but missing explanation"))) - (when (string-match-p "^BREAKING CHANGE:" body) - (fail! "'BREAKING CHANGE:' present in body, but missing '!' after %S" - type)))) - - (lambda! (&key type body) - "Ensure bump commits have package ref lines" - (and (eq type 'bump) - (let ((bump-re "\\(?:https?://.+\\|[^/]+\\)/[^/]+@\\([a-z0-9]+\\)")) - (not (string-match-p (concat "^" bump-re " -> " bump-re "$") - body))) - (fail! "Bump commit is missing commit hash diffs"))) - - (lambda! (&key body) - "Ensure commit hashes in bump lines are 12 characters long" - (with-temp-buffer - (insert body) - (let ((bump-re "\\<\\(?:https?://[^@]+\\|[^/]+\\)/[^/]+@\\([a-z0-9]+\\)") - refs) - (while (re-search-backward bump-re nil t) - (when (/= (length (match-string 1)) 12) - (push (match-string 0) refs))) - (when refs - (fail! "%d commit hash(s) not 12 characters long: %s" - (length refs) (string-join (nreverse refs) ", ")))))) - - ;; TODO Add bump validations for revert: type. - (lambda! (&key body trailers) - "Validate commit trailers." - (let* ((keys (mapcar #'car doom-ci-commit-trailer-keys)) - (key-re (regexp-opt keys t)) - (lines - ;; Scan BODY because invalid trailers won't be in TRAILERS. - (save-match-data - (and (string-match "\n\\(\n[a-zA-Z][a-zA-Z-]*:? [^ ][^\n]+\\)+\n+\\'" body) - (split-string (match-string 0 body) "\n" t))))) - (dolist (line lines) - (unless (string-match-p (concat "^" key-re ":? [^ ]") line) - (fail! "Found %S, expected one of: %s" - (truncate-string-to-width (string-trim line) 16 nil nil "…") - (string-join keys ", "))) - (when (and (string-match "^[^a-zA-Z-]+:? \\(.+\\)$" line) - (string-match-p " " (match-string 1 line))) - (fail! "%S has multiple references, but should only have one per line" - (truncate-string-to-width (string-trim line) 20 nil nil "…"))) - (when (or (string-match (concat "^" key-re "\\(?:e?[sd]\\|ing\\)? [^ ]") line) - (string-match (concat "^\\([a-zA-Z-]+\\) [^ \n]+$") line)) - (fail! "%S missing colon after %S" - (truncate-string-to-width (string-trim line) 16 nil nil "…") - (match-string 1 line)))) - (pcase-dolist (`(,key . ,value) trailers) - (if (and (not (memq 'name (cdr (assoc key doom-ci-commit-trailer-keys)))) - (string-match-p " " value)) - (fail! "Found %S, but only one value allowed per trailer" - (truncate-string-to-width (concat key ": " value) 20 nil nil "…")) - (when-let (allowed-types (cdr (assoc key doom-ci-commit-trailer-keys))) - (or (cl-loop for type in allowed-types - if (cdr (assq type doom-ci-commit-trailer-types)) - if (string-match-p it value) - return t) - (fail! "%S expects one of %s, but got %S" - key allowed-types value))))))) - - ;; TODO Check that bump/revert SUBJECT list: 1) valid modules and 2) - ;; modules whose files are actually being touched. - - ;; TODO Ensure your diff corraborates your SCOPE - - ) - "A list of validator functions to run against a commit. - -Each function is N-arity and is passed a plist with the following keys: - - :bang - (Boolean) If `t', the commit is declared to contain a breaking change. - e.g. 'refactor!: this commit breaks everything' - :body - (String) Contains the whole BODY of a commit message, excluding the - TRAILERS. - :scopes - (List<Symbol>) Contains a list of scopes, as symbols. e.g. with - 'feat(org,lsp): so on and so forth', this contains '(org lsp). - :subject - (String) Contains the whole first line of a commit message. - :summary - (String) Contains the summary following the type and scopes. e.g. In - 'feat(org): fix X, Y, and Z' the summary is 'fix X, Y, and Z. - :trailers - (Map<String, String>) Contains an alist of 'KEY: VALUE' trailers, i.e. All - Fix, Ref, Close, Revert, etc lines with a valid value. This will be empty if - the formatting of a commit's trailers is invalid. - :type - (Symbol) The type of commit this is. E.g. `feat', `fix', `bump', etc. - -Each function should call `fail!' or `warn!' one or more times, or `skip!' -(immediately returns). Each of these lexical functions take the same arguments -as `format'. - -Note: warnings are not considered failures.") - - -;; -;;; Commands - -;;; doom ci -(defcli! ci (&args _) - "Commands that automate development processes." - :partial t) - -;; TODO Move to 'doom install --git-hooks' -(defcli! (ci deploy-hooks) ((force ("--force"))) - "TODO" - (let* ((repo-path (sh! "git" "rev-parse" "--show-toplevel")) - (repo-path (if (zerop (car repo-path)) - (cdr repo-path) - (user-error "Cannot locate a git repo in %s" - (file-relative-name default-directory)))) - (submodule-p (string-empty-p (cdr (sh! "git" "rev-parse" "show-superproject-working-tree")))) - (config-hooks-path (cdr (sh! "git" "config" "core.hooksPath"))) - (hooks-path (cdr (sh! "git" "rev-parse" "--git-path" "hooks")))) - (unless (string-empty-p config-hooks-path) - (or force - (y-or-n-p - (format (concat "Detected non-standard core.hookPath: %S\n\n" - "Install Doom's commit-msg and pre-push git hooks anyway?") - hooks-path)) - (user-error "Aborted"))) - (make-directory hooks-path 'parents) - (print-group! - (dolist (hook '("commit-msg" "pre-push")) - (let* ((hook (doom-path hooks-path hook)) - (overwrite-p (file-exists-p hook))) - (with-temp-file hook - (insert "#!/usr/bin/env sh\n" - (doom-path doom-emacs-dir "bin/doom") - " --no-color ci hook " (file-name-base hook) - " \"$@\"")) - (set-file-modes hook #o700) - (print! (success "%s %s") - (if overwrite-p "Overwrote" "Created") - (path hook))))))) - -;; TODO Move to 'doom lint commits' -(defcli! (ci lint-commits) (from &optional to) - "TODO" - (with-temp-buffer - (insert - (cdr (doom-call-process - "git" "log" - (format "%s...%s" from (or to (concat from "~1")))))) - (doom-ci--lint - (let (commits) - (while (re-search-backward "^commit \\([a-z0-9]\\{40\\}\\)" nil t) - (push (cons (match-string 1) - (replace-regexp-in-string - "^ " "" - (save-excursion - (buffer-substring-no-properties - (search-forward "\n\n") - (if (re-search-forward "\ncommit \\([a-z0-9]\\{40\\}\\)" nil t) - (match-beginning 0) - (point-max)))))) - commits)) - commits)))) - -;; TODO Move to 'doom lint hook:commit-msg' -(defcli! (ci hook commit-msg) (file) - "Run git commit-msg hook. - -Lints the current commit message." - (with-temp-buffer - (insert-file-contents file) - (doom-ci--lint - `(("CURRENT" . - ,(buffer-substring - (point-min) - (if (re-search-forward "^# Please enter the commit message" nil t) - (match-beginning 0) - (point-max)))))))) - -;; TODO Move to 'doom lint hook:pre-push' -(defcli! (ci hook pre-push) (remote url) - "Run git pre-push hook. - -Prevents pushing if there are unrebased or WIP commits." - (with-temp-buffer - (let ((z40 (make-string 40 ?0)) - line error) - (while (setq line (ignore-errors (read-from-minibuffer ""))) - (catch 'continue - (seq-let (local-ref local-sha remote-ref remote-sha) - (split-string line " ") - ;; TODO Extract this branch detection to a variable - (unless (or (string-match-p "^refs/heads/\\(master\\|main\\)$" remote-ref) - (equal local-sha z40)) - (throw 'continue t)) - (print-group! - (mapc (lambda (commit) - (seq-let (hash msg) (split-string commit "\t") - (setq error t) - (print! (item "%S commit in %s" - (car (split-string msg " ")) - (substring hash 0 12))))) - (split-string - (cdr (doom-call-process - "git" "rev-list" - "--grep" (concat "^" (regexp-opt '("WIP" "squash!" "fixup!" "FIXUP") t) " ") - "--format=%H\t%s" - (if (equal remote-sha z40) - local-sha - (format "%s..%s" remote-sha local-sha)))) - "\n" t)) - (when error - (print! (error "Aborting push due to unrebased WIP, squash!, or fixup! commits")) - (exit! 1))))))))) - - -;; -;;; Helpers - -(cl-defun doom-ci-enforce-scopeless-types (scope (&key type scopes summary &allow-other-keys)) - "Complain about scoped commit types that shouldn't be scoped." - (when (memq type doom-ci-commit-scopeless-types) - (user-error "Scopes for %s commits should go after the colon, not before" - type))) - - -(defun doom-ci--parse-commit (commit-msg) - (with-temp-buffer - (save-excursion (insert commit-msg)) - (append - (let ((end - (save-excursion - (if (re-search-forward "\n\\(\n[a-zA-Z-]+: [^ ][^\n]+\\)+\n*\\'" nil t) - (1+ (match-beginning 0)) - (point-max))))) - `(:subject ,(buffer-substring (point-min) (line-end-position)) - :body ,(string-trim-right (buffer-substring (line-beginning-position 3) end)) - :trailers ,(save-match-data - (cl-loop with footer = (buffer-substring end (point-max)) - for line in (split-string footer "\n" t) - if (string-match "^\\([a-zA-Z-]+\\): \\(.+\\)$" line) - collect (cons (match-string 1 line) (match-string 2 line)))))) - (save-match-data - (when (looking-at "^\\([a-zA-Z0-9_-]+\\)\\(!?\\)\\(?:(\\([^)]+\\))\\)?: \\([^\n]+\\)") - `(:type ,(intern (match-string 1)) - :bang ,(equal (match-string 2) "!") - :summary ,(match-string 4) - :scopes ,(ignore-errors (split-string (match-string 3) ","))))) - (save-excursion - (let ((bump-re "\\(\\(?:https?://.+\\|[^/ \n]+\\)/[^/ \n]+@[a-z0-9]\\{12\\}\\)") - bumps) - (while (re-search-forward (format "^\\s-*\\<%s -> %s\\>" bump-re bump-re) nil t) - (cond ((rassoc (match-string 1) bumps) - (setcdr (rassoc (match-string 1) bumps) (match-string 2))) - ((assoc (match-string 2) bumps) - (setcar (assoc (match-string 2) bumps) (match-string 1))) - ((setf (alist-get (match-string 1) bumps nil nil #'equal) - (match-string 2))))) - `(:bumps ,(cl-sort (delete-dups bumps) #'string-lessp :key #'car))))))) - -(defun doom-ci--parse-bumps (from end) - (with-temp-buffer - (save-excursion - (insert - (cdr (doom-call-process "git" "log" "--format=full" "--grep=\\(bump\\|revert\\):" - (format "%s...%s" from end))))) - (save-match-data - (let (packages) - (while (let ((bump-re "\\(\\(?:https?://.+\\|[^/ ]+\\)/[^/ ]+@[a-z0-9]\\{12\\}\\)")) - (re-search-forward (format "^\\s-*\\<%s -> %s\\>" bump-re bump-re) nil t)) - (cond ((rassoc (match-string 1) packages) - (setcdr (rassoc (match-string 1) packages) (match-string 2))) - ((assoc (match-string 2) packages) - (setcar (assoc (match-string 2) packages) (match-string 1))) - ((setf (alist-get (match-string 1) packages nil nil #'equal) - (match-string 2))))) - (cl-sort (delete-dups packages) #'string-lessp :key #'car))))) - -(defun doom-ci--lint (commits) - (let ((warnings 0) - (failures 0)) - (print! (start "Linting %d commits" (length commits))) - (print-group! - (pcase-dolist (`(,ref . ,commitmsg) commits) - (let* ((commit (doom-ci--parse-commit commitmsg)) - (shortref (substring ref 0 7)) - (subject (plist-get commit :subject))) - (cl-block 'linter - (letf! ((defun skip! (reason &rest args) - (print! (warn "Skipped because: %s") (apply #'format reason args)) - (cl-return-from 'linter)) - (defun warn! (reason &rest args) - (cl-incf warnings) - (print! (warn "%s") (apply #'format reason args))) - (defun fail! (reason &rest args) - (cl-incf failures) - (print! (error "%s") (apply #'format reason args)))) - (print! (start "%s %s") shortref subject) - (print-group! - (mapc (doom-rpartial #'apply commit) - doom-ci-commit-rules))))))) - (let ((issues (+ warnings failures))) - (if (= issues 0) - (print! (success "There were no issues!")) - (if (> warnings 0) (print! (warn "Warnings: %d" warnings))) - (if (> failures 0) (print! (warn "Failures: %d" failures))) - (print! "\nSee https://discourse.doomemacs.org/git-conventions") - (unless (zerop failures) - (exit! 1))) - t))) - -(provide 'doom-cli-ci) -;;; ci.el ends here diff --git a/.config/emacs/lisp/cli/compile.el b/.config/emacs/lisp/cli/compile.el @@ -1,214 +0,0 @@ -;;; lisp/cli/commands/byte-compile.el -*- lexical-binding: t; -*- - -;; -;;; Variables - -;; None yet! - - -;; -;;; Commands - -(defcli! ((compile c)) - ((recompile-p ("-r" "--recompile")) - (core-p ("-c" "--core")) - (private-p ("-p" "--private")) - (verbose-p ("-v" "--verbose"))) - "Byte-compiles your config or selected modules. - - compile [TARGETS...] - compile :core :user lang/python - compile feature lang - -Accepts :core and :user as special arguments, which target Doom's core files -and your private config files, respectively. To recompile your packages, use -'doom build' instead." - (doom-cli-compile - (if (or core-p private-p) - (append (if core-p (doom-glob doom-emacs-dir "init.el")) - (if core-p (list doom-core-dir)) - (if private-p (list doom-user-dir))) - (or (y-or-n-p - (concat "WARNING: Changes made to your config after compiling it won't take effect until\n" - "this command is rerun or you run 'doom clean'! It will also make error backtraces\n" - "much more difficult to decipher.\n\n" - "If you intend to use it anyway, remember this or it will come back to bite you!\n\n" - "Continue anyway?")) - (user-error "Aborted")) - (append (doom-glob doom-emacs-dir "init.el") - (list doom-core-dir) - (seq-filter - ;; Only compile Doom's modules - (doom-rpartial #'file-in-directory-p doom-emacs-dir) - ;; Omit `doom-user-dir', which is always first - (doom-module-load-path)))) - recompile-p - verbose-p)) - -(defcli! clean () - "Delete all *.elc files." - (doom-compile-clean)) - - -;; -;;; Helpers - -(cl-defun doom-cli-compile (&optional targets recompile-p verbose-p) - "Byte compiles your emacs configuration. - -init.el is always byte-compiled by this. - -If TARGETS is specified, as a list of direcotries - -If MODULES is specified (a list of module strings, e.g. \"lang/php\"), those are -byte-compiled. Otherwise, all enabled modules are byte-compiled, including Doom -core. It always ignores unit tests and files with `no-byte-compile' enabled. - -WARNING: byte-compilation yields marginal gains and makes debugging new issues -difficult. It is recommended you don't use it unless you understand the -reprecussions. - -Use `doom-compile-clean' or `make clean' to reverse -byte-compilation. - -If RECOMPILE-P is non-nil, only recompile out-of-date files." - (let* ((default-directory doom-emacs-dir) - (targets (nreverse (delete-dups targets))) - ;; In case it is changed during compile-time - (auto-mode-alist auto-mode-alist) - kill-emacs-hook kill-buffer-query-functions) - - (let ((after-load-functions - (if (null targets) - after-load-functions - ;; Assemble el files we want to compile, and preserve in the order - ;; they are loaded in, so we don't run into any scary catch-22s - ;; while byte-compiling, like missing macros. - (cons (let ((target-dirs (seq-filter #'file-directory-p targets))) - (lambda (path) - (and (not (doom-compile--ignore-file-p path)) - (seq-find (doom-partial #'file-in-directory-p path) - target-dirs) - (cl-pushnew path targets)))) - after-load-functions)))) - (doom-log "Reloading Doom in preparation for byte-compilation") - ;; But first we must be sure that Doom and your private config have been - ;; fully loaded. Which usually aren't so in an noninteractive session. - (let ((load-prefer-newer t)) - (require 'doom-start))) - - (if (null targets) - (print! (item "No targets to %scompile" (if recompile-p "re" ""))) - (print! (start "%scompiling your config...") - (if recompile-p "Re" "Byte-")) - - (dolist (dir - (cl-remove-if-not #'file-directory-p targets) - (setq targets (cl-remove-if #'file-directory-p targets))) - (prependq! targets - (doom-files-in - dir :match "\\.el" :filter #'doom-compile--ignore-file-p))) - - (print-group! - (require 'use-package) - (condition-case-unless-debug e - (let* ((total-ok 0) - (total-fail 0) - (total-noop 0) - (byte-compile-verbose nil) - (byte-compile-warnings '(not free-vars unresolved noruntime lexical make-local)) - (byte-compile-dynamic-docstrings t) - (use-package-compute-statistics nil) - (use-package-defaults use-package-defaults) - (use-package-expand-minimally t) - (targets (delete-dups targets)) - (modules (seq-group-by #'doom-module-from-path targets)) - (total-files (length targets)) - (total-modules (length modules)) - (i 0) - last-module) - ;; Prevent packages from being loaded at compile time if they - ;; don't meet their own predicates. - (push (list :no-require t - (lambda (_name args) - (or (when-let (pred (or (plist-get args :if) - (plist-get args :when))) - (not (eval pred t))) - (when-let (pred (plist-get args :unless)) - (eval pred t))))) - use-package-defaults) - (dolist (module-files modules) - (cl-incf i) - (dolist (target (cdr module-files)) - (let ((elc-file (byte-compile-dest-file target))) - (cl-incf - (if (and recompile-p (not (file-newer-than-file-p target elc-file))) - total-noop - (pcase (if (not (doom-file-cookie-p target "if" t)) - 'no-byte-compile - (unless (equal last-module (car module-files)) - (print! (success "(% 3d/%d) Compiling %s") - i total-modules - (if-let (m (caar module-files)) - (format "%s %s module..." m (cdar module-files)) - (format "%d stand alone elisp files..." - (length (cdr module-files)))) - (caar module-files) (cdar module-files)) - (setq last-module (car module-files))) - (if verbose-p - (byte-compile-file target) - (quiet! (byte-compile-file target)))) - (`no-byte-compile - (doom-log "(% 3d/%d) Ignored %s" i total-modules target) - total-noop) - (`nil - (print! (error "(% 3d/%d) Failed to compile %s") - i total-modules (relpath target)) - total-fail) - (_ total-ok))))))) - (print! (class (if (= total-fail 0) 'success 'warn) - "%s %d/%d file(s) (%d ignored)") - (if recompile-p "Recompiled" "Byte-compiled") - total-ok total-files - total-noop) - (= total-fail 0)) - ((debug error) - (print! (error "There were breaking errors.\n\n%s") - "Reverting changes...") - (signal 'doom-error (list 'byte-compile e)))))))) - -(defun doom-compile--ignore-file-p (path) - (let ((filename (file-name-nondirectory path))) - (or (not (equal (file-name-extension path) "el")) - (member filename (list doom-module-packages-file "doctor.el")) - (string-prefix-p "." filename) - (string-prefix-p "test-" filename) - (string-prefix-p "flycheck_" filename) - (string-suffix-p ".example.el" filename)))) - -(defun doom-compile-clean () - "Delete all the compiled elc files in your Emacs configuration and private -module. This does not include your byte-compiled, third party packages.'" - (require 'doom-modules) - (print! (start "Cleaning .elc files")) - (print-group! - (cl-loop with default-directory = doom-emacs-dir - with success = 0 - with esc = (if init-file-debug "" "\033[1A") - for path - in (append (doom-glob doom-emacs-dir "*.elc") - (doom-files-in doom-user-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 "\033[KDeleted %s%s") (relpath path) esc) - and do (cl-incf success) - finally do - (print! (if (> success 0) - (success "\033[K%d elc files deleted" success) - (item "\033[KNo elc files to clean")))) - t)) - -(provide 'doom-cli-compile) -;;; compile.el ends here diff --git a/.config/emacs/lisp/cli/doctor.el b/.config/emacs/lisp/cli/doctor.el @@ -1,297 +0,0 @@ -;;; lisp/cli/doctor.el --- userland heuristics and Emacs diagnostics -*- lexical-binding: t; -*- -;;; Commentary: -;;; Code: - -(defvar doom-doctor--warnings ()) -(defvar doom-doctor--errors ()) - - -;; -;;; DSL - -(defun elc-check-dir (dir) - (dolist (file (directory-files-recursively dir "\\.elc$")) - (when (file-newer-than-file-p (concat (file-name-sans-extension file) ".el") - file) - (warn! "%s is out-of-date" (abbreviate-file-name file))))) - -(defmacro assert! (condition message &rest args) - `(unless ,condition - (error! ,message ,@args))) - -(defmacro error! (&rest args) - `(progn (unless inhibit-message (print! (error ,@args))) - (push (format! (error ,@args)) doom-doctor--errors))) - -(defmacro warn! (&rest args) - `(progn (unless inhibit-message (print! (warn ,@args))) - (push (format! (warn ,@args)) doom-doctor--warnings))) - -(defmacro success! (&rest args) - `(print! (green ,@args))) - -(defmacro section! (&rest args) - `(print! (bold (blue ,@args)))) - -(defmacro explain! (&rest args) - `(print-group! (print! (p ,@args)))) - - -;; -;;; CLI commands - -(defcli! ((doctor doc)) () - "Diagnoses common issues on your system. - -The Doom doctor is essentially one big, self-contained elisp shell script that -uses a series of simple heuristics to diagnose common issues on your system. -Issues that could intefere with Doom Emacs. - -Doom modules may optionally have a doctor.el file to run their own heuristics -in." - :benchmark nil - (print! "The doctor will see you now...\n") - - (print! (start "Checking your Emacs version...")) - (print-group! - (cond ((or (> emacs-major-version 28) - (string-match-p ".\\(50\\|9[0-9]\\)$" emacs-version)) - (warn! "Detected a development version of Emacs (%s)" emacs-version) - (if (> emacs-major-version 28) - (explain! "This is the bleeding edge of Emacs. Doom does not support it because Emacs " - "HEAD is in an especially unstable period of its development. If you've found " - "a stable commit, great! But be cautious about updating too eagerly!\n") - (explain! "A .50 or .9x appended to the version string indicates that this is a version of " - "Emacs in between stable releases. These are not well supported.\n")) - (explain! "Because development builds are prone to random breakage, there will be a greater " - "burden on you to investigate and deal with issues. Please make extra sure that " - "your issue is reproducible in 28.1 before reporting them to Doom's issue tracker!\n" - "\n" - "If this doesn't phase you, read the \"Why does Doom not support Emacs HEAD\" QnA " - "in Doom's FAQ. It offers some advice for debugging and surviving issues on the " - "bleeding edge. Failing that, 28.1 is highly recommended and will always be " - "Doom's best supported version of Emacs.")) - ((= emacs-major-version 27) - (warn! "Emacs 27 is supported, but consider upgrading to 28.1") - (explain! "Emacs 28.1 is better supported, faster, and more stable. Plus, Doom will drop " - "27.x support sometime mid-2022.")))) - - (print! (start "Checking for Doom's prerequisites...")) - (print-group! - (if (not (executable-find "git")) - (error! "Couldn't find git on your machine! Doom's package manager won't work.") - (save-match-data - (let* ((version - (cdr (doom-call-process "git" "version"))) - (version - (and (string-match "git version \\([0-9]+\\(?:\\.[0-9]+\\)\\{2\\}\\)" version) - (match-string 1 version)))) - (if version - (when (version< version "2.23") - (error! "Git %s detected! Doom requires git 2.23 or newer!" - version)) - (warn! "Cannot determine Git version. Doom requires git 2.23 or newer!"))))) - - (unless (executable-find "rg") - (error! "Couldn't find the `rg' binary; this a hard dependecy for Doom, file searches may not work at all"))) - - (print! (start "Checking for Emacs config conflicts...")) - (when (file-exists-p "~/.emacs") - (warn! "Detected an ~/.emacs file, which may prevent Doom from loading") - (explain! "If Emacs finds an ~/.emacs file, it will ignore ~/.emacs.d, where Doom is " - "typically installed. If you're seeing a vanilla Emacs splash screen, this " - "may explain why. If you use Chemacs, you may ignore this warning.")) - - (print! (start "Checking for great Emacs features...")) - (unless (functionp 'json-serialize) - (warn! "Emacs was not built with native JSON support") - (explain! "Users will see a substantial performance gain by building Emacs with " - "jansson support (i.e. a native JSON library), particularly LSP users. " - "You must install a prebuilt Emacs binary with this included, or compile " - "Emacs with the --with-json option.")) - (unless (featurep 'native-compile) - (warn! "Emacs was not built with native compilation support") - (explain! "Users will see a substantial performance gain by building Emacs with " - "native compilation support, availible in emacs 28+." - "You must install a prebuilt Emacs binary with this included, or compile " - "Emacs with the --with-native-compilation option.")) - - (print! (start "Checking for private config conflicts...")) - (let* ((xdg-dir (concat (or (getenv "XDG_CONFIG_HOME") - "~/.config") - "/doom/")) - (doom-dir (or (getenv "DOOMDIR") - "~/.doom.d/")) - (dir (if (file-directory-p xdg-dir) - xdg-dir - doom-dir))) - (when (file-equal-p dir doom-emacs-dir) - (print! (error "Doom was cloned to %S, not ~/.emacs.d or ~/.config/emacs" - (path dir))) - (explain! "Doom's source and your private Doom config have to live in separate directories. " - "Putting them in the same directory (without changing the DOOMDIR environment " - "variable) will cause errors on startup.")) - (when (and (not (file-equal-p xdg-dir doom-dir)) - (file-directory-p xdg-dir) - (file-directory-p doom-dir)) - (print! (warn "Detected two private configs, in %s and %s") - (abbreviate-file-name xdg-dir) - doom-dir) - (explain! "The second directory will be ignored, as it has lower precedence."))) - - (print! (start "Checking for stale elc files...")) - (elc-check-dir doom-core-dir) - (elc-check-dir doom-modules-dir) - (elc-check-dir (doom-path doom-local-dir "straight" straight-build-dir)) - - (print! (start "Checking for problematic git global settings...")) - (if (executable-find "git") - (when (zerop (car (doom-call-process "git" "config" "--global" "--get-regexp" "^url\\.git://github\\.com"))) - (warn! "Detected insteadOf rules in your global gitconfig.") - (explain! "Doom's package manager heavily relies on git. In particular, many of its packages " - "are hosted on github. Rewrite rules like these will break it:\n\n" - " [url \"git://github.com\"]\n" - " insteadOf = https://github.com\n\n" - "Please remove them from your gitconfig or use a conditional includeIf rule to " - "only apply your rewrites to specific repositories. See " - "'https://git-scm.com/docs/git-config#_includes' for more information.")) - (error! "Couldn't find the `git' binary; this a hard dependecy for Doom!")) - - (print! (start "Checking Doom Emacs...")) - (condition-case-unless-debug ex - (print-group! - (require 'doom-start) - - (print! (success "Initialized Doom Emacs %s") doom-version) - (print! - (if (hash-table-p doom-modules) - (success "Detected %d modules" (hash-table-count doom-modules)) - (warn "Failed to load any modules. Do you have an private init.el?"))) - - (print! (success "Detected %d packages") (length doom-packages)) - - (print! (start "Checking Doom core for irregularities...")) - (print-group! - ;; Check for oversized problem files in cache that may cause unusual/tremendous - ;; delays or freezing. This shouldn't happen often. - (dolist (file (list "savehist" "projectile.cache")) - (when-let (size (ignore-errors (doom-file-size file doom-cache-dir))) - (when (> size 1048576) ; larger than 1mb - (warn! "%s is too large (%.02fmb). This may cause freezes or odd startup delays" - file (/ size 1024 1024.0)) - (explain! "Consider deleting it from your system (manually)")))) - - (unless (ignore-errors (executable-find doom-projectile-fd-binary)) - (warn! "Couldn't find the `fd' binary; project file searches will be slightly slower")) - - (require 'projectile) - (when (projectile-project-root "~") - (warn! "Your $HOME is recognized as a project root") - (explain! "Emacs will assume $HOME is the root of any project living under $HOME. If this isn't\n" - "desired, you will need to remove \".git\" from `projectile-project-root-files-bottom-up'\n" - "(a variable), e.g.\n\n" - " (after! projectile\n" - " (setq projectile-project-root-files-bottom-up\n" - " (remove \".git\" projectile-project-root-files-bottom-up)))")) - - ;; There should only be one - (when (and (file-equal-p doom-user-dir "~/.config/doom") - (file-directory-p "~/.doom.d")) - (print! (warn "Both %S and '~/.doom.d' exist on your system") - (path doom-user-dir)) - (explain! "Doom will only load one of these (~/.config/doom takes precedence). Possessing\n" - "both is rarely intentional; you should one or the other.")) - - ;; Check for fonts - (if (not (executable-find "fc-list")) - (warn! "Warning: unable to detect fonts because fontconfig isn't installed") - ;; all-the-icons fonts - (when (and (pcase system-type - (`gnu/linux (concat (or (getenv "XDG_DATA_HOME") - "~/.local/share") - "/fonts/")) - (`darwin "~/Library/Fonts/")) - (require 'all-the-icons nil t)) - (with-temp-buffer - (let ((errors 0)) - (cl-destructuring-bind (status . output) - (doom-call-process "fc-list" "" "file") - (if (not (zerop status)) - (print! (error "There was an error running `fc-list'. Is fontconfig installed correctly?")) - (insert (cdr (doom-call-process "fc-list" "" "file"))) - (dolist (font all-the-icons-font-names) - (if (save-excursion (re-search-backward font nil t)) - (success! "Found font %s" font) - (print! (warn "Warning: couldn't find %S font") font))) - (when (> errors 0) - (explain! "Some all-the-icons fonts were missing.\n\n" - "You can install them by running `M-x all-the-icons-install-fonts' within Emacs.\n" - "This could also mean you've installed them in non-standard locations, in which " - "case feel free to ignore this warning."))))))))) - - (print! (start "Checking for stale elc files in your DOOMDIR...")) - (when (file-directory-p doom-user-dir) - (print-group! - (elc-check-dir doom-user-dir))) - - (when doom-modules - (print! (start "Checking your enabled modules...")) - (advice-add #'require :around #'doom-shut-up-a) - (pcase-dolist (`(,group . ,name) (doom-module-list)) - (doom-context-with 'doctor - (let (doom-local-errors - doom-local-warnings) - (let (doom-doctor--errors - doom-doctor--warnings) - (condition-case-unless-debug ex - (doom-module-context-with (cons group name) - (let ((doctor-file (doom-module-expand-path group name "doctor.el")) - (packages-file (doom-module-expand-path group name doom-module-packages-file))) - (when packages-file - (cl-loop with doom-output-indent = 6 - for name in (doom-context-with 'packages - (let* (doom-packages - doom-disabled-packages) - (load packages-file 'noerror 'nomessage) - (mapcar #'car doom-packages))) - unless (or (doom-package-get name :disable) - (eval (doom-package-get name :ignore)) - (plist-member (doom-package-get name :recipe) :local-repo) - (locate-library (symbol-name name)) - (doom-package-built-in-p name) - (doom-package-installed-p name)) - do (print! (error "Missing emacs package: %S") name))) - (when doctor-file - (let ((inhibit-message t)) - (load doctor-file 'noerror 'nomessage))))) - (file-missing (error! "%s" (error-message-string ex))) - (error (error! "Syntax error: %s" ex))) - (when (or doom-doctor--errors doom-doctor--warnings) - (print-group! - (print! (start (bold "%s %s")) group name) - (print! "%s" (string-join (append doom-doctor--errors doom-doctor--warnings) "\n"))) - (setq doom-local-errors doom-doctor--errors - doom-local-warnings doom-doctor--warnings))) - (appendq! doom-doctor--errors doom-local-errors) - (appendq! doom-doctor--warnings doom-local-warnings)))))) - (error - (warn! "Attempt to load DOOM failed\n %s\n" - (or (cdr-safe ex) (car ex))) - (setq doom-modules nil))) - - ;; Final report - (terpri) - (dolist (msg (list (list doom-doctor--warnings "warning" 'yellow) - (list doom-doctor--errors "error" 'red))) - (when (car msg) - (print! (color (nth 2 msg) - (if (cdar msg) - "There are %d %ss!" - "There is %d %s!") - (length (car msg)) (nth 1 msg))))) - (unless (or doom-doctor--errors doom-doctor--warnings) - (success! "Everything seems fine, happy Emacs'ing!")) - (exit! :pager? "+G")) - -(provide 'doom-cli-doctor) -;;; doctor.el ends here diff --git a/.config/emacs/lisp/cli/env.el b/.config/emacs/lisp/cli/env.el @@ -1,148 +0,0 @@ -;;; lisp/cli/env.el --- envvar file generator -*- lexical-binding: t; -*- -;;; Commentary: -;;; Code: - -;; -;;; Variables - -;; (defvar doom-env-file -;; (doom-path doom-profile-dir -;; doom-profile-init-dir-name -;; "10-init-env.el") -;; "The location of your envvar file, generated by `doom env`. - -;; This file contains environment variables scraped from your shell environment, -;; which is loaded at startup (if it exists). This is helpful if Emacs can't -;; \(easily) be launched from the correct shell session (particularly for MacOS -;; users).") - -(defvar doom-env-deny - '(;; Unix/shell state that shouldn't be persisted - "^HOME$" "^\\(OLD\\)?PWD$" "^SHLVL$" "^PS1$" "^R?PROMPT$" "^TERM\\(CAP\\)?$" - "^USER$" "^GIT_CONFIG" "^INSIDE_EMACS$" - ;; X server, Wayland, or services' env that shouldn't be persisted - "^DISPLAY$" "^WAYLAND_DISPLAY" "^DBUS_SESSION_BUS_ADDRESS$" "^XAUTHORITY$" - ;; Windows+WSL envvars that shouldn't be persisted - "^WSL_INTEROP$" - ;; XDG variables that are best not persisted. - "^XDG_CURRENT_DESKTOP$" "^XDG_RUNTIME_DIR$" - "^XDG_\\(VTNR\\|SEAT\\|SESSION_\\(TYPE\\|CLASS\\)\\)" - ;; Socket envvars, like I3SOCK, GREETD_SOCK, SEATD_SOCK, SWAYSOCK, etc. - "SOCK$" - ;; ssh and gpg variables that could quickly become stale if persisted. - "^SSH_\\(AUTH_SOCK\\|AGENT_PID\\)$" "^\\(SSH\\|GPG\\)_TTY$" - "^GPG_AGENT_INFO$" - ;; Internal Doom envvars - "^DEBUG$" "^INSECURE$" "^\\(EMACS\\|DOOM\\)DIR$" "^DOOMPROFILE$" "^__") - "Environment variables to omit from envvar files. - -Each string is a regexp, matched against variable names to omit from -`doom-env-file'.") - -(defvar doom-env-allow '() - "Environment variables to include in envvar files. - -This overrules `doom-env-deny'. Each string is a regexp, matched against -variable names to omit from `doom-env-file'.") - - -;; -;;; Commands - -(defcli! env - ((allow-only ("--allow-all")) - (deny-only ("--deny-all")) - (output-file ("-o" path) "Write envvar file to non-standard PATH.") - ;; TODO (refresh? ("-r" "--refresh")) - &multiple - (rules ("-a" "--allow" "-d" "--deny" regexp) "Allow/deny envvars that match REGEXP")) - "(Re)generates envvars file from your shell environment. - -The envvars file is created by scraping the current shell environment into -newline-delimited KEY=VALUE pairs. Typically by running '$SHELL -ic env' (or -'$SHELL -c set' on windows). Doom loads this file at startup (if it exists) to -ensure Emacs mirrors your shell environment (particularly to ensure PATH and -SHELL are correctly set). - -This is useful in cases where you cannot guarantee that Emacs (or the daemon) -will be launched from the correct environment (e.g. on MacOS or through certain -app launchers on Linux). - -This file is automatically regenerated when you run this command or 'doom sync'. -However, 'doom sync' will only regenerate this file if it exists. - -Why this over exec-path-from-shell? - - 1. `exec-path-from-shell' spawns (at least) one process at startup to scrape - your shell environment. This can be arbitrarily slow depending on the - user's shell configuration. A single program (like pyenv or nvm) or config - framework (like oh-my-zsh) could undo all of Doom's startup optimizations - in one fell swoop. - - 2. `exec-path-from-shell' only scrapes some state from your shell. You have to - be proactive in order to get it to capture all the envvars relevant to your - development environment. - - I'd rather it inherit your shell environment /correctly/ (and /completely/) - or not at all. It frontloads the debugging process rather than hiding it - until you least want to deal with it." - (let ((env-file (doom-path (or output-file doom-env-file)))) - (with-temp-file env-file - (setq-local coding-system-for-write 'utf-8-unix) - (print! (start "%s envvars file") - (if (file-exists-p env-file) - "Regenerating" - "Generating")) - (print-group! - (goto-char (point-min)) - (insert - ";; -*- mode: lisp-interaction; coding: utf-8-unix; -*-\n" - ";; ---------------------------------------------------------------------------\n" - ";; This file was auto-generated by `doom env'. It contains a list of environment\n" - ";; variables scraped from your default shell (based on your settings for \n" - ";; `doom-env-allow' and `doom-env-deny').\n" - ";;\n" - (if (file-equal-p env-file doom-env-file) - (concat ";; It is NOT safe to edit this file. Changes will be overwritten next time you\n" - ";; run 'doom sync'. To create a safe-to-edit envvar file use:\n;;\n" - ";; doom env -o ~/.doom.d/myenv\n;;\n" - ";; And load it with (doom-load-envvars-file \"~/.doom.d/myenv\").\n") - (concat ";; This file is safe to edit by hand, but needs to be loaded manually with:\n;;\n" - ";; (doom-load-envvars-file \"path/to/this/file\")\n;;\n" - ";; Use 'doom env -o path/to/this/file' to regenerate it.")) - "\n") - ;; We assume that this noninteractive session was spawned from the user's - ;; interactive shell, so simply dump `process-environment' to a file. - ;; - ;; This should be well-formatted, in case humans want to hand-modify it. - (let* ((denylist (remq nil (append (if deny-only '(".")) (list allow-only) doom-env-deny))) - (allowlist (remq nil (append (if allow-only '(".")) (list deny-only) doom-env-allow)))) - (dolist (rule rules) - (push (cdr rule) (if (member (car rule) '("-a" "--allow")) - allowlist - denylist))) - (insert "(") - (dolist (env (get 'process-environment 'initial-value)) - (catch 'skip - (let* ((var (car (split-string env "="))) - (pred (doom-rpartial #'string-match-p var))) - (when (seq-find pred denylist) - (if (seq-find pred allowlist) - (doom-log "cli:env: allow %s" var) - (doom-log "cli:env: deny %s" var) - (throw 'skip t))) - (insert (prin1-to-string env) "\n ")))) - (insert ")")) - (print! (success "Generated %s") (path env-file)) - t)))) - -(defcli! (env (clear c)) () - "Deletes the default envvar file." - (let ((env-file (abbreviate-file-name doom-env-file))) - (unless (file-exists-p env-file) - (user-error "No envvar file to delete: %s" env-file)) - (delete-file env-file) - (print! (success "Deleted %s") (path env-file)))) - -(provide 'doom-cli-env) -;;; env.el ends here diff --git a/.config/emacs/lisp/cli/help.el b/.config/emacs/lisp/cli/help.el @@ -1,466 +0,0 @@ -;;; lisp/cli/help.el -*- lexical-binding: t; -*- -;;; Commentary: -;; -;; This file defines special commands that the Doom CLI will invoke when a -;; command is passed with -?, --help, or --version. They can also be aliased to -;; a sub-command to make more of its capabilities accessible to users, with: -;; -;; (defcli-alias! (myscript (help h)) (:help)) -;; -;; You can define your own command-specific help handlers, e.g. -;; -;; (defcli! (:help myscript subcommand) () ...) -;; -;; And it will be invoked instead of the generic one. -;; -;;; Code: - -;; -;;; Variables - -(defvar doom-help-commands '("%p %c {-?,--help}") - "A list of help commands recognized for the running script. - -Recognizes %p (for the prefix) and %c (for the active command).") - - -;; -;;; Commands - -(defcli! (:root :help) - ((localonly? ("-g" "--no-global") "Hide global options") - (manpage? ("--manpage") "Generate in manpage format") - (commands? ("--commands") "List all known commands") - &multiple - (sections ("--synopsis" "--subcommands" "--similar" "--envvars" - "--postamble") - "Show only the specified sections.") - &context context - &args command) - "Show documentation for a Doom CLI command. - -OPTIONS: - --synopsis, --subcommands, --similar, --envvars, --postamble - TODO" - (doom-cli-load-all) - (when (doom-cli-context-error context) - (terpri)) - (let* ((command (cons (doom-cli-context-prefix context) command)) - (cli (doom-cli-get command t)) - (rcli (doom-cli-get cli)) - (fallbackcli (cl-loop with targets = (doom-cli--command-expand (butlast command) t) - for cmd in (cons command targets) - if (doom-cli-get cmd t) - return it))) - (cond (commands? - (let ((cli (or cli (doom-cli-get (doom-cli-context-prefix context))))) - (print! "Commands under '%s':\n%s" - (doom-cli-command-string cli) - (indent (doom-cli-help--render-commands - (or (doom-cli-subcommands cli) - (user-error "No commands found")) - :prefix (doom-cli-command cli) - :inline? t - :docs? t))))) - ((null sections) - (if (null cli) - (signal 'doom-cli-command-not-found-error command) - (doom-cli-help--print cli context manpage? localonly?) - (exit! :pager?))) - ((dolist (section sections) - (unless (equal section (car sections)) (terpri)) - (pcase section - ("--synopsis" - (print! "%s" (doom-cli-help--render-synopsis - (doom-cli-help--synopsis cli) - "Usage: "))) - ("--subcommands" - (print! "%s\n%s" (bold "Available commands:") - (indent (doom-cli-help--render-commands - (doom-cli-subcommands rcli 1) - :prefix command - :grouped? t - :docs? t) - doom-print-indent-increment))) - ("--similar" - (unless command - (user-error "No command specified")) - (let ((similar (doom-cli-help-similar-commands command 0.4))) - (print! "Similar commands:") - (if (not similar) - (print! (indent (warn "Can't find any!"))) - (dolist (command (seq-take similar 10)) - (print! (indent (item "(%d%%) %s")) - (* (car command) 100) - (doom-cli-command-string (cdr command))))))) - ("--envvars" - (let* ((key "ENVIRONMENT VARIABLES") - (clis (if command (doom-cli-find command) (hash-table-values doom-cli--table))) - (clis (seq-remove #'doom-cli-alias clis)) - (clis (seq-filter (fn! (cdr (assoc key (doom-cli-docs %)))) clis)) - (clis (seq-group-by #'doom-cli-command clis))) - (print! "List of environment variables for %s:\n" command) - (if (null clis) - (print! (indent "None!")) - (dolist (group clis) - (print! (bold "%s%s:" - (doom-cli-command-string (car group)) - (if (doom-cli-fn (doom-cli-get (car group))) - "" " *"))) - (dolist (cli (cdr group)) - (print! (indent "%s") (markup (cdr (assoc key (doom-cli-docs cli)))))))))) - ("--postamble" - (print! "See %s for documentation." - (join (cl-loop with spec = - `((?p . ,(doom-cli-context-prefix context)) - (?c . ,(doom-cli-command-string (cdr (doom-cli-command (or cli fallbackcli)))))) - for cmd in doom-help-commands - for formatted = (trim (format-spec cmd spec)) - collect (replace-regexp-in-string - " +" " " (format "'%s'" formatted))) - " or "))))))))) - -(defcli! (:root :version) - ((simple? ("--simple")) - &context context) - "Show installed versions of Doom, Doom modules, and Emacs." - (doom/version) - (unless simple? - (terpri) - (with-temp-buffer - (insert-file-contents (doom-path doom-emacs-dir "LICENSE")) - (re-search-forward "^Copyright (c) ") - (print! "%s\n" (trim (thing-at-point 'line t))) - (print! (p "Doom Emacs uses the MIT license and is provided without warranty " - "of any kind. You may redistribute and modify copies if " - "given proper attribution. See the LICENSE file for details."))))) - - -;; -;;; Helpers - -(defun doom-cli-help (cli) - "Return an alist of documentation summarizing CLI (a `doom-cli')." - (let* ((rcli (doom-cli-get cli)) - (docs (doom-cli-docs rcli))) - `((command . ,(doom-cli-command-string cli)) - (summary . ,(or (cdr (assoc "SUMMARY" docs)) "TODO")) - (description . ,(or (cdr (assoc "MAIN" docs)) "TODO")) - (synopsis . ,(doom-cli-help--synopsis cli)) - (arguments . ,(doom-cli-help--arguments rcli)) - (options . ,(doom-cli-help--options rcli)) - (commands . ,(doom-cli-subcommands cli 1)) - (sections . ,(seq-filter #'cdr (cddr docs)))))) - -(defun doom-cli-help-similar-commands (command &optional maxscore) - "Return N commands that are similar to COMMAND." - (seq-take-while - (fn! (>= (car %) (or maxscore 0.0))) - (seq-sort-by - #'car #'> - (cl-loop with prefix = (seq-find #'doom-cli-get (nreverse (doom-cli--command-expand command t))) - with input = (doom-cli-command-string (cdr (doom-cli--command command t))) - for command in (hash-table-keys doom-cli--table) - if (doom-cli-fn (doom-cli-get command)) - if (equal prefix (seq-take command (length prefix))) - collect (cons (doom-cli-help--similarity - input (doom-cli-command-string (cdr command))) - command))))) - -(defun doom-cli-help--similarity (s1 s2) - ;; Ratcliff-Obershelp similarity - (let* ((s1 (downcase s1)) - (s2 (downcase s2)) - (s1len (length s1)) - (s2len (length s2))) - (if (or (zerop s1len) - (zerop s2len)) - 0.0 - (/ (let ((i 0) (j 0) (score 0) jlast) - (while (< i s1len) - (unless jlast (setq jlast j)) - (if (and (< j s2len) - (= (aref s1 i) (aref s2 j))) - (progn (cl-incf score) - (cl-incf i) - (cl-incf j)) - (setq m 0) - (cl-incf j) - (when (>= j s2len) - (setq j (or jlast j) - jlast nil) - (cl-incf i)))) - (* 2.0 score)) - (+ (length s1) - (length s2)))))) - -;;; Help: printers -;; TODO Parameterize optional args with `cl-defun' -(defun doom-cli-help--print (cli context &optional manpage? noglobal?) - "Write CLI's documentation in a manpage-esque format to stdout." - (let-alist (doom-cli-help cli) - (let* ((alist - `(,@(if manpage? - `((nil . ,(let* ((title (cadr (member "--load" command-line-args))) - (width (floor (/ (- (doom-cli-context-width context) - (length title)) - 2.0)))) - ;; FIXME Who am I fooling? - (format (format "%%-%ds%%s%%%ds" width width) - "DOOM(1)" title "DOOM(1)"))) - ("NAME" . ,(concat .command " - " .summary)) - ("SYNOPSIS" . ,(doom-cli-help--render-synopsis .synopsis nil t)) - ("DESCRIPTION" . ,.description)) - `((nil . ,(doom-cli-help--render-synopsis .synopsis "Usage: ")) - (nil . ,(string-join (seq-remove #'string-empty-p (list .summary .description)) - "\n\n")))) - ("ARGUMENTS" . ,(doom-cli-help--render-arguments .arguments)) - ("COMMANDS" - . ,(doom-cli-help--render-commands - .commands :prefix (doom-cli-command cli) :grouped? t :docs? t)) - ("OPTIONS" - . ,(doom-cli-help--render-options - (if (or (not (doom-cli-fn cli)) noglobal?) - `(,(assq 'local .options)) - .options) - cli)))) - (command (doom-cli-command cli))) - (letf! (defun printsection (section) - (print! "%s\n" - (if (null section) - (dark "TODO") - (markup - (format-spec - section `((?p . ,(car command)) - (?c . ,(doom-cli-command-string (cdr command)))) - 'ignore))))) - (pcase-dolist (`(,label . ,contents) alist) - (when (and contents (not (string-blank-p contents))) - (when label - (print! (bold "%s%s") label (if manpage? "" ":"))) - (print-group! :if label (printsection contents)))) - (pcase-dolist (`(,label . ,contents) .sections) - (when (and contents (not (assoc label alist))) - (print! (bold "%s:") label) - (print-group! (printsection contents)))))))) - -;;; Help: synopsis -(defun doom-cli-help--synopsis (cli &optional all-options?) - (let* ((rcli (doom-cli-get cli)) - (opts (doom-cli-help--options rcli)) - (opts (mapcar #'car (if all-options? (mapcan #'cdr opts) (alist-get 'local opts)))) - (opts (cl-loop for opt in opts - for args = (cdar opt) - for switches = (mapcar #'car opt) - for multi? = (member "..." args) - if args - collect (format (if multi? "[%s %s]..." "[%s %s]") - (string-join switches "|") - (string-join (remove "..." args) "|")) - else collect (format "[%s]" (string-join switches "|")))) - (args (doom-cli-arguments rcli)) - (subcommands? (doom-cli-subcommands rcli 1 :predicate? t))) - `((command . ,(doom-cli-command cli)) - (options ,@opts) - (required ,@(mapcar (fn! (upcase (format "`%s'" %))) (if subcommands? '(command) (alist-get '&required args)))) - (optional ,@(mapcar (fn! (upcase (format "[`%s']" %)))(alist-get '&optional args))) - (rest ,@(mapcar (fn! (upcase (format "[`%s'...]" %))) (if subcommands? '(args) (alist-get '&args args))))))) - -(defun doom-cli-help--render-synopsis (synopsis &optional prefix) - (let-alist synopsis - (let ((doom-print-indent 0) - (prefix (or prefix "")) - (command (doom-cli-command-string .command))) - (string-trim-right - (format! "%s\n\n" - (fill (concat (bold prefix) - (format "%s " command) - (markup - (join (append .options - (and .options - (or .required - .optional - .rest) - (list (dark "[--]"))) - .required - .optional - .rest)))) - 80 (1+ (length (concat prefix command))))))))) - -;;; Help: arguments -(defun doom-cli-help--arguments (cli &optional all?) - (doom-cli-help--parse-docs (doom-cli-find cli t) "ARGUMENTS")) - -(defun doom-cli-help--render-arguments (arguments) - (mapconcat (lambda (arg) - (format! "%-20s\n%s" - (underscore (car arg)) - (indent (if (equal (cdr arg) "TODO") - (dark (cdr arg)) - (cdr arg)) - doom-print-indent-increment))) - arguments - "\n")) - -;;; Help: commands -(cl-defun doom-cli-help--render-commands (commands &key prefix grouped? docs? (inline? t)) - (with-temp-buffer - (let* ((doom-print-indent 0) - (commands (seq-group-by (fn! (if grouped? (doom-cli-prop (doom-cli-get % t) :group))) - (nreverse commands))) - (toplevel (assq nil commands)) - (rest (remove toplevel commands)) - (drop (if prefix (length prefix) 0)) - (minwidth - (apply - #'max (or (cl-loop for cmd in (apply #'append (mapcar #'cdr commands)) - for cmd = (seq-drop cmd drop) - collect (length (doom-cli-command-string cmd))) - (list 15)))) - (ellipsis (doom-print--style 'dark " […]")) - (ellipsislen (- (length ellipsis) (if (eq doom-print-backend 'ansi) 2 4)))) - (dolist (group (cons toplevel rest)) - (let ((label (if (car-safe group) (cdr commands)))) - (when label - (insert! ((bold "%s:") (car group)) "\n")) - (print-group! :if label - (dolist (command (cdr group)) - (let* ((cli (doom-cli-get command t)) - (rcli (doom-cli-get command)) - (summary (doom-cli-short-docs rcli)) - (subcommands? (doom-cli-subcommands cli 1 :predicate? t))) - (insert! ((format "%%-%ds%%s%%s" - (+ (- minwidth doom-print-indent) - doom-print-indent-increment - (if subcommands? ellipsislen 0))) - (concat (doom-cli-command-string (seq-drop command drop)) - (if subcommands? ellipsis)) - (if inline? " " "\n") - (indent (if (and (doom-cli-alias cli) - (not (doom-cli-type rcli))) - (dark "-> %s" (doom-cli-command-string cli)) - (when docs? - (if summary (markup summary) (dark "TODO")))))) - "\n"))) - (when (cdr rest) - (insert "\n"))))) - (string-trim-right (buffer-string))))) - -;;; Help: options -(defun doom-cli-help--options (cli &optional noformatting?) - "Return an alist summarizing CLI's options. - -The alist's CAR are lists of formatted switches plus their arguments, e.g. -'((\"`--foo'\" \"`BAR'\") ...). Their CDR is their formatted documentation." - (let* ((docs (doom-cli-help--parse-docs (doom-cli-find cli t) "OPTIONS")) - (docs (mapcar (fn! (cons (split-string (car %) ", ") - (cdr %))) - docs)) - (strfmt (if noformatting? "%s" "`%s'")) - local-options - global-options - seen) - (dolist (neighbor (nreverse (doom-cli-find cli))) - (dolist (option (doom-cli-options neighbor)) - (when-let* ((switches (cl-loop for sw in (doom-cli-option-switches option) - if (and (doom-cli-option-flag-p option) - (string-prefix-p "--" sw)) - collect (format "--[no-]%s" (substring sw 2)) - else collect sw)) - (switches (seq-difference switches seen))) - (dolist (switch switches) (push switch seen)) - (push (cons (cl-loop for switch in switches - if (doom-cli-option-arguments option) - collect (cons (format strfmt switch) - (append (doom-cli-help--parse-args it noformatting?) - (when (doom-cli-option-multiple-p option) - (list "...")))) - else collect (list (format strfmt switch))) - (string-join - (or (delq - nil (cons (when-let (docs (doom-cli-option-docs option)) - (concat docs ".")) - (cl-loop for (flags . docs) in docs - unless (equal (seq-difference flags switches) flags) - collect docs))) - '("TODO")) - "\n\n")) - (if (equal (doom-cli-command neighbor) - (doom-cli-command cli)) - local-options - global-options))))) - `((local . ,(nreverse local-options)) - (global . ,(nreverse global-options))))) - -(defun doom-cli-help--render-options (options &optional cli) - (let ((doom-print-indent 0) - (local (assq 'local options)) - (global (assq 'global options))) - (when (or (cdr local) (cdr global)) - (letf! (defun printopts (opts) - (pcase-dolist (`(,switches . ,docs) (cdr opts)) - (let (multiple?) - (insert! - ("%s%s\n%s" - (mapconcat - (fn! (when (member "..." (cdr %)) - (setq multiple? t)) - (string-trim-right - (format "%s %s" - (doom-print--cli-markup (car %)) - (doom-print--cli-markup - (string-join (remove "..." (cdr %)) "|"))))) - switches - ", ") - (if multiple? ", ..." "") - (indent (fill (markup docs)) doom-print-indent-increment)) - "\n\n")))) - (with-temp-buffer - (if (null (cdr local)) - (insert (if global "This command has no local options.\n" "") "\n") - (printopts local)) - (when (cdr global) - (insert! ((bold "Global options:\n"))) - (print-group! (printopts global))) - (string-trim-right (buffer-string))))))) - -;;; Help: internal -(defun doom-cli-help--parse-args (args &optional noformatting?) - (cl-loop for arg in args - if (listp arg) - collect (string-join (doom-cli-help--parse-args arg noformatting?) "|") - else if (symbolp arg) - collect (format (if noformatting? "%s" "`%s'") (upcase (symbol-name arg))) - else collect arg)) - -(defun doom-cli-help--parse-docs (cli-list section-name) - (cl-check-type section-name string) - (let (alist) - (dolist (cli cli-list (nreverse alist)) - (when-let (section (cdr (assoc section-name (doom-cli-docs cli)))) - (with-temp-buffer - (save-excursion (insert section)) - (let ((lead (current-indentation)) - (buffer (current-buffer))) - (while (not (eobp)) - (let ((heading (string-trim (buffer-substring (point-at-bol) (point-at-eol)))) - (beg (point-at-bol 2)) - end) - (forward-line 1) - (while (and (not (eobp)) - (/= (current-indentation) lead) - (forward-line 1))) - (setf (alist-get heading alist nil nil #'equal) - (string-join - (delq - nil (list (alist-get heading alist nil nil #'equal) - (let ((end (point))) - (with-temp-buffer - (insert-buffer-substring buffer beg end) - (goto-char (point-min)) - (indent-rigidly (point-min) (point-max) (- (current-indentation))) - (string-trim-right (buffer-string)))))) - "\n\n")))))))))) - -(provide 'doom-cli-help) -;;; help.el ends here diff --git a/.config/emacs/lisp/cli/info.el b/.config/emacs/lisp/cli/info.el @@ -1,34 +0,0 @@ -;;; lisp/cli/info.el --- information about your Doom install -*- lexical-binding: t; -*- -;;; Commentary: -;;; Code: - -;; -;;; Variables - -;; None yet! - - -;; -;;; Commands - -(defcli! info - ((format ("--lisp" "--json") "What format to dump info into") - &context context) - "Print detailed information about your config for bug reports." - (with-temp-buffer - (pcase format - ("--json" - (require 'json) - (insert (json-encode (doom-info))) - (json-pretty-print-buffer)) - ("--lisp" - (pp (doom-info))) - (_ - (insert (doom-info-string - (if (doom-cli-context-pipe-p context :out t) - 72 - (doom-cli-context-width context)))))) - (print! "%s" (string-trim-right (buffer-string))))) - -(provide 'doom-cli-info) -;;; info.el ends here diff --git a/.config/emacs/lisp/cli/install.el b/.config/emacs/lisp/cli/install.el @@ -1,138 +0,0 @@ -;;; lisp/cli/install.el --- Doom Emacs install wizard -*- lexical-binding: t; -*- -;;; Commentary: -;;; Code: - -(load! "packages") - - -;; -;;; Variables - -;; None yet! - - -;; -;;; Commands - -(defcli! ((install i)) - (&flags - (config? ("--config" :yes) "Create `$DOOMDIR' or dummy files therein?") - (envfile? ("--env" :yes) "(Re)generate an envvars file? (see `$ doom help env`)") - (install? ("--install" :yes) "Auto-install packages?") - (fonts? ("--fonts" :yes) "Install (or prompt to install) all-the-icons fonts?") - (hooks? ("--hooks" :yes) "Deploy Doom's git hooks to itself?") - &context context) - "Installs and sets up Doom Emacs for the first time. - -This command does the following: - - 1. Creates `$DOOMDIR' at ~/.config/doom (if it or ~/.doom.d doesn't exist), - 2. Copies ~/.config/emacs/templates/init.example.el to `$DOOMDIR'/init.el (if - it doesn't exist), - 3. Creates dummy files for `$DOOMDIR'/{config,packages}.el, - 4. Prompts you to generate an envvar file (same as `$ doom env`), - 5. Installs any dependencies of enabled modules (specified by `$DOOMDIR'/init.el), - 6. And prompts to install all-the-icons' fonts - -This command is idempotent and safe to reuse. - -Change `$DOOMDIR' with the `--doomdir' option, e.g. - - ``` - $ doom --doomdir /other/doom/config install - ```" - (print! (green "Installing Doom Emacs!\n")) - (let ((default-directory doom-emacs-dir) - (yes? (doom-cli-context-suppress-prompts-p context))) - ;; Create `doom-user-dir' - (if (eq config? :no) - (print! (warn "Not copying private config template, as requested")) - ;; Create DOOMDIR in ~/.config/doom if ~/.config/emacs exists. - (when (and (not (file-directory-p doom-user-dir)) - (not (getenv "DOOMDIR"))) - (let ((xdg-config-dir (or (getenv "XDG_CONFIG_HOME") "~/.config"))) - (when (file-in-directory-p doom-emacs-dir xdg-config-dir) - (setq doom-user-dir (expand-file-name "doom/" xdg-config-dir))))) - - (if (file-directory-p doom-user-dir) - (print! (item "Skipping %s (already exists)") (relpath doom-user-dir)) - (make-directory doom-user-dir 'parents) - (print! (success "Created %s") (relpath doom-user-dir))) - - ;; Create init.el, config.el & packages.el - (print-group! - (mapc (lambda (file) - (cl-destructuring-bind (filename . template) file - (if (file-exists-p! filename doom-user-dir) - (print! (item "Skipping %s (already exists)") - (path filename)) - (print! (item "Creating %s%s") (relpath doom-user-dir) filename) - (with-temp-file (doom-path doom-user-dir filename) - (insert-file-contents template)) - (print! (success "Done!"))))) - (let ((template-dir (doom-path doom-emacs-dir "templates"))) - `((,doom-module-init-file - . ,(file-name-with-extension (doom-path template-dir doom-module-init-file) - ".example.el")) - (,doom-module-config-file - . ,(file-name-with-extension (doom-path template-dir doom-module-config-file) - ".example.el")) - (,doom-module-packages-file - . ,(file-name-with-extension (doom-path template-dir doom-module-packages-file) - ".example.el"))))))) - - ;; In case no init.el was present the first time it was loaded. - (doom-load (doom-path doom-user-dir doom-module-init-file) t) - - ;; Ask if user would like an envvar file generated - (if (eq envfile? :no) - (print! (warn "Not generating envvars file, as requested")) - (if (file-exists-p doom-env-file) - (print! (item "Envvar file already exists, skipping")) - (when (or yes? (y-or-n-p "Generate an envvar file? (see `doom help env` for details)")) - (call! '(env))))) - - ;; Install Doom packages - (if (eq install? :no) - (print! (warn "Not installing plugins, as requested")) - (print! "Installing plugins") - (doom-packages-install)) - - (print! "Regenerating autoloads files") - (doom-profile-generate) - - (if (eq hooks? :no) - (print! (warn "Not deploying commit-msg and pre-push git hooks, as requested")) - (print! "Deploying commit-msg and pre-push git hooks") - (print-group! - (condition-case e - (call! `(ci deploy-hooks ,@(if yes? '("--force")))) - ('user-error - (print! (warn "%s") (error-message-string e)))))) - - (cond ((eq fonts? :no)) - (IS-WINDOWS - (print! (warn "Doom cannot install all-the-icons' fonts on Windows!\n")) - (print-group! - (print! - (concat "You'll have to do so manually:\n\n" - " 1. Launch Doom Emacs\n" - " 2. Execute 'M-x all-the-icons-install-fonts' to download the fonts\n" - " 3. Open the download location in windows explorer\n" - " 4. Open each font file to install them")))) - ((or yes? (y-or-n-p "Download and install all-the-icon's fonts?")) - (require 'all-the-icons) - (let ((window-system (cond (IS-MAC 'ns) - (IS-LINUX 'x)))) - (all-the-icons-install-fonts 'yes)))) - - (when (file-exists-p "~/.emacs") - (print! (warn "A ~/.emacs file was detected. This conflicts with Doom and should be deleted!"))) - - (print! (success "\nFinished! Doom is ready to go!\n")) - (with-temp-buffer - (insert-file-contents (doom-path doom-emacs-dir "templates/QUICKSTART_INTRO")) - (print! "%s" (buffer-string))))) - -(provide 'doom-cli-install) -;;; install.el ends here diff --git a/.config/emacs/lisp/cli/make.el b/.config/emacs/lisp/cli/make.el @@ -1,91 +0,0 @@ -;;; lisp/cli/make.el --- file generation commands -*- lexical-binding: t; -*- -;;; Commentary: -;;; Code: - -(load! "make/completions") -;; (load! "make/docs") -;; (load! "make/manpage") - - -;; -;;; Variables - -(defvar doom-make-codeowners-file ".github/CODEOWNERS" - "Where to write the CODEOWNERS file, relative to the repo's toplevel.") - -(defvar doom-make-codeowners () - "An alist of codeowners for this project. - -Each entry can either be a string (inserted verbatim, surrounded by newlines) or -a pair of strings (in a cons cell) consisting of: (GLOB . CODEOWNERS). - -The contents of this variable are inserted in reverse.") - - -;; -;;; Commands - -(defcli! make () - "(Re)Generate project files and boilerplate." - :partial t) - -(defcli! (make codeowners) - ((outfile ("-o" "--file" (file stdout)) "Where to write the codeowners file") - (dryrun? ("--dryrun"))) - "Generate (or update) a CODEOWNERS file. - -By default, this means $GIT_WORK_TREE/.github/CODEOWNERS. This will throw an -error if not run in a Git repo. - -OPTIONS: - -o, --file - Pass this option a dash to print the codeowners file to stdout." - (when dryrun? - (setq outfile "-") - (print! (warn "Running dry run; will only print to stdout:"))) - (with-temp-buffer - (let ((codeowners-file - (cond ((equal outfile "-") nil) - (outfile (expand-file-name outfile)) - ((file-name-concat (doom-git-toplevel) doom-make-codeowners-file))))) - (insert "# -*- mode: conf -*-\n" - "# Each line is a file pattern followed by one or more owners.\n" - "# This file was generated by 'doom make codeowners', do not edit it by hand.\n") - (dolist (entry (nreverse doom-make-codeowners)) - (if (stringp entry) - (insert "\n" entry "\n") - (insert (car entry) " " (cdr entry) "\n"))) - (insert "\n# End of CODEOWNERS") - (setq indent-tabs-mode nil) ; align w/ spaces, not tabs - (align-regexp (point-min) (point-max) "/\\(\\s-+\\)@" 1) - (if (null codeowners-file) - (print! "%s" (buffer-string)) - (print! (start "%s codeowners file at: %s") - (if (file-exists-p codeowners-file) - "Regenerated" - "Generated") - (relpath codeowners-file)) - (write-region (buffer-string) nil codeowners-file))))) - -;; TODO Finish me -(defcli-stub! (make changelog)) - - - -;; -;;; Helpers - -(defmacro doom-make--with-file (file &rest body) - (declare (indent 1)) - `(let ((inhibit-read-only t)) - (with-current-buffer - (or (get-file-buffer ,file) - (find-file-noselect ,file)) - (save-excursion - (goto-char (point-min)) - ,@body - (when (buffer-modified-p) - (save-buffer)))))) - -(provide 'doom-cli-make) -;;; make.el ends here diff --git a/.config/emacs/lisp/cli/make/completions.el b/.config/emacs/lisp/cli/make/completions.el @@ -1,142 +0,0 @@ -;;; lisp/cli/make/completions.el --- generate shell completion scripts -*- lexical-binding: t; -*- -;;; Commentary: -;;; Code: - -;; -;;; Variables - -;; (defvar doom-make-completions-zsh-spec -;; '(("FILE" . "_files")) -;; "TODO") - - -;; -;;; Commands - -(defcli! (make completions) - ((shell ("--zsh" "--bash") "Generate a particular flavor of completion files (defaults to $SHELL)") - ;; TODO (outfile ("-o" "--outfile" file)) - &context context &args args) - "Generate completion scripts for a Doom-CLI script." - ;; (unless outfile - ;; (user-error "No destination file specified")) - (let ((shell (or shell (file-name-base (getenv "SHELL")))) - ;; TODO Allow this command to read other Doom binscripts, which will - ;; dump their `doom-cli--table' if __DOOMDUMP is set. - ;; (table (read (letenv! (("__DOOMDUMP" "1")) (apply #'sh! script-file args)))) - ) - (print! - "%s" (pcase (string-remove-prefix "--" shell) - ("zsh" (doom-make-completions-zsh context nil)) - ("bash" (doom-make-completions-bash context nil)) - (_ (user-error "No support for %S shell at this time" shell)))))) - - -;; -;;; ZSH Helpers - -;; TODO Write to OUTFILE when specified -(defun doom-make-completions-zsh (context _outfile) - (let* ((cli (doom-cli-get context)) - (prefix (doom-cli-context-prefix context)) - (options (doom-cli-help--options cli t)) - (commands (doom-cli-subcommands (list prefix)))) - (with-temp-buffer - (insert "#compdef " (doom-cli-context-prefix context) "\n\n" - "_globalargs=(\n ") - (doom-make-completions--zsh-insert-options - (append '(((("--help") ("-?")) . "Show help documentation") - ((("--version")) . "Show version information")) - (alist-get 'global options)) - "\n ") - (insert "\n)\n\n") - (doom-make-completions--zsh-insert-command '("doom")) - (mapc #'doom-make-completions--zsh-insert-command commands) - ;; (insert "\n\n_doom") - (buffer-string)) - ;; (set-file-modes outfile #o755) - ;; outfile - )) - -(defun doom-make-completions--zsh-insert-options (options &optional cr) - ;; FIXME Refactor, generalize, and parameterize this mess - (dolist (option options) - (let* ((switches (cl-loop for (sw . args) in (car option) - if (string-prefix-p "--[no-]" sw) - collect (cons (concat "--" (string-remove-prefix "--[no-]" sw)) args) - and collect (cons (concat "--no-" (string-remove-prefix "--[no-]" sw)) args) - else collect (cons sw args))) - (args (remove "..." (cdr (car switches)))) - (argspec (cl-loop for arg in args - concat - (format ":%s:%s" - (replace-regexp-in-string - ":" ";" (shell-quote-argument arg)) - (or (plist-get (cdr (assoc (intern-soft (downcase (car args))) - doom-cli-option-arg-types)) - :zshcomp) - "")))) - (multiple? (member "..." (cdr (car switches))))) - (insert (format "%s%s%s" - (if multiple? - "\\*" - (format "'(%s)'" (mapconcat #'car switches " "))) - (if (cdr switches) - (format - "{%s}" (combine-and-quote-strings - (cl-loop for (sw . _) in switches - if (and args (string-prefix-p "--" sw)) - collect (concat (shell-quote-argument sw) "=") - else collect (shell-quote-argument sw)) - ",")) - (format "%s%s" (caar switches) - (if (and args (string-prefix-p "--" (caar switches))) - "=" ""))) - (format "'[%s]%s'" - (replace-regexp-in-string "'" "''" (cdr option)) - (or argspec ""))) - (or cr "\n"))))) - -(defun doom-make-completions--zsh-insert-command (command) - (let* ((commandstr (doom-cli-command-string command)) - (options (alist-get 'local (doom-cli-help--options (doom-cli-get command) t))) - (subcommands (doom-cli-subcommands command 1))) - (insert "_" (replace-regexp-in-string "[- ]" "_" commandstr) "() {\n" - " local line state\n" - " _arguments -s -S -C \"${_globalargs[@]}\" \\\n ") - (doom-make-completions--zsh-insert-options options " \\\n ") - (insert "\"1: :->cmds\" \"*::arg:->args\"\n" - " case $state in\n" - " cmds)\n" - " _values \"" commandstr "\" \\\n " - (string-join - (cl-loop for command in subcommands - unless (string-prefix-p ":" (car command)) - collect (format "'%s[%s]' " - (car (last command)) - (or (doom-cli-short-docs (doom-cli-get command)) - "TODO"))) - " \\\n ") - "\n ;;\n" - " args)\n" - " case $line[1] in\n " - (string-join - (cl-loop for command in subcommands - unless (string-prefix-p ":" (car command)) - collect (format "%s) _%s ;; " - (car (last command)) - (replace-regexp-in-string "[- ]" "_" (doom-cli-command-string command)))) - "\n ") - "\n esac\n" - " ;;\n" - " esac\n" - "}\n"))) - - -;; -;;; Bash helpers - -(defun doom-make-completions-bash (context _outfile) - (user-error "Bash completion exporter hasn't been implemented yet!")) - -;;; completions.el ends here diff --git a/.config/emacs/lisp/cli/meta.el b/.config/emacs/lisp/cli/meta.el @@ -1,482 +0,0 @@ -;;; lisp/cli/meta.el -*- lexical-binding: t; -*- -;;; Commentary: -;; -;; This file defines special commands that the Doom CLI will invoke when a -;; command is passed with -?, --help, or --version. They can also be aliased to -;; a sub-command to make more of its capabilities accessible to users, with: -;; -;; (defcli-alias! (myscript (help h)) (:help)) -;; -;; You can define your own command-specific help handlers, e.g. -;; -;; (defcli! (:help myscript subcommand) () ...) -;; -;; And it will be invoked instead of the generic one. -;; -;;; Code: - -;; -;;; Variables - -(defvar doom-help-commands '("%p %c {-?,--help}") - "A list of help commands recognized for the running script. - -Recognizes %p (for the prefix) and %c (for the active command).") - - -;; -;;; Commands - -;; When __DOOMDUMP is set, doomscripts trigger this special handler. -(defcli! (:root :dump) - ((pretty? ("--pretty") "Pretty print output") - &context context - &args commands) - "Dump metadata to stdout for other commands to read." - (let* ((prefix (doom-cli-context-prefix context)) - (command (cons prefix commands))) - (funcall (if pretty? #'pp #'prin1) - (cond ((equal commands '("-")) (hash-table-values doom-cli--table)) - (commands (doom-cli-find command)) - ((doom-cli-find (list prefix))))) - (terpri) - ;; Kill manually so we don't save output to logs. - (let (kill-emacs) (kill-emacs 0)))) - -(defcli! (:root :help) - ((localonly? ("-g" "--no-global") "Hide global options") - (manpage? ("--manpage") "Generate in manpage format") - (commands? ("--commands") "List all known commands") - &multiple - (sections ("--synopsis" "--subcommands" "--similar" "--envvars" - "--postamble") - "Show only the specified sections.") - &context context - &args command) - "Show documentation for a Doom CLI command. - -OPTIONS: - --synopsis, --subcommands, --similar, --envvars, --postamble - TODO" - (doom-cli-load-all) - (when (doom-cli-context-error context) - (terpri)) - (let* ((command (cons (doom-cli-context-prefix context) command)) - (cli (doom-cli-get command t)) - (rcli (doom-cli-get cli)) - (fallbackcli (cl-loop with targets = (doom-cli--command-expand (butlast command) t) - for cmd in (cons command targets) - if (doom-cli-get cmd t) - return it))) - (cond (commands? - (let ((cli (or cli (doom-cli-get (doom-cli-context-prefix context))))) - (print! "Commands under '%s':\n%s" - (doom-cli-command-string cli) - (indent (doom-cli-help--render-commands - (or (doom-cli-subcommands cli) - (user-error "No commands found")) - :prefix (doom-cli-command cli) - :inline? t - :docs? t))))) - ((null sections) - (if (null cli) - (signal 'doom-cli-command-not-found-error command) - (doom-cli-help--print cli context manpage? localonly?) - (exit! :pager?))) - ((dolist (section sections) - (unless (equal section (car sections)) (terpri)) - (pcase section - ("--synopsis" - (print! "%s" (doom-cli-help--render-synopsis - (doom-cli-help--synopsis cli) - "Usage: "))) - ("--subcommands" - (print! "%s\n%s" (bold "Available commands:") - (indent (doom-cli-help--render-commands - (doom-cli-subcommands rcli 1) - :prefix command - :grouped? t - :docs? t) - doom-print-indent-increment))) - ("--similar" - (unless command - (user-error "No command specified")) - (let ((similar (doom-cli-help-similar-commands command 0.4))) - (print! "Similar commands:") - (if (not similar) - (print! (indent (warn "Can't find any!"))) - (dolist (command (seq-take similar 10)) - (print! (indent (item "(%d%%) %s")) - (* (car command) 100) - (doom-cli-command-string (cdr command))))))) - ("--envvars" - (let* ((key "ENVIRONMENT VARIABLES") - (clis (if command (doom-cli-find command) (hash-table-values doom-cli--table))) - (clis (seq-remove #'doom-cli-alias clis)) - (clis (seq-filter (fn! (cdr (assoc key (doom-cli-docs %)))) clis)) - (clis (seq-group-by #'doom-cli-command clis))) - (print! "List of environment variables for %s:\n" command) - (if (null clis) - (print! (indent "None!")) - (dolist (group clis) - (print! (bold "%s%s:" - (doom-cli-command-string (car group)) - (if (doom-cli-fn (doom-cli-get (car group))) - "" " *"))) - (dolist (cli (cdr group)) - (print! (indent "%s") (markup (cdr (assoc key (doom-cli-docs cli)))))))))) - ("--postamble" - (print! "See %s for documentation." - (join (cl-loop with spec = - `((?p . ,(doom-cli-context-prefix context)) - (?c . ,(doom-cli-command-string (cdr (doom-cli-command (or cli fallbackcli)))))) - for cmd in doom-help-commands - for formatted = (trim (format-spec cmd spec)) - collect (replace-regexp-in-string - " +" " " (format "'%s'" formatted))) - " or "))))))))) - -(defcli! (:root :version) - ((simple? ("--simple")) - &context context) - "Show installed versions of Doom, Doom modules, and Emacs." - (doom/version) - (unless simple? - (terpri) - (with-temp-buffer - (insert-file-contents (doom-path doom-emacs-dir "LICENSE")) - (re-search-forward "^Copyright (c) ") - (print! "%s\n" (trim (thing-at-point 'line t))) - (print! (p "Doom Emacs uses the MIT license and is provided without warranty " - "of any kind. You may redistribute and modify copies if " - "given proper attribution. See the LICENSE file for details."))))) - - -;; -;;; Helpers - -(defun doom-cli-help (cli) - "Return an alist of documentation summarizing CLI (a `doom-cli')." - (let* ((rcli (doom-cli-get cli)) - (docs (doom-cli-docs rcli))) - `((command . ,(doom-cli-command-string cli)) - (summary . ,(or (cdr (assoc "SUMMARY" docs)) "TODO")) - (description . ,(or (cdr (assoc "MAIN" docs)) "TODO")) - (synopsis . ,(doom-cli-help--synopsis cli)) - (arguments . ,(doom-cli-help--arguments rcli)) - (options . ,(doom-cli-help--options rcli)) - (commands . ,(doom-cli-subcommands cli 1)) - (sections . ,(seq-filter #'cdr (cddr docs)))))) - -(defun doom-cli-help-similar-commands (command &optional maxscore) - "Return N commands that are similar to COMMAND." - (seq-take-while - (fn! (>= (car %) (or maxscore 0.0))) - (seq-sort-by - #'car #'> - (cl-loop with prefix = (seq-find #'doom-cli-get (nreverse (doom-cli--command-expand command t))) - with input = (doom-cli-command-string (cdr (doom-cli--command command t))) - for command in (hash-table-keys doom-cli--table) - if (doom-cli-fn (doom-cli-get command)) - if (equal prefix (seq-take command (length prefix))) - collect (cons (doom-cli-help--similarity - input (doom-cli-command-string (cdr command))) - command))))) - -(defun doom-cli-help--similarity (s1 s2) - ;; Ratcliff-Obershelp similarity - (let* ((s1 (downcase s1)) - (s2 (downcase s2)) - (s1len (length s1)) - (s2len (length s2))) - (if (or (zerop s1len) - (zerop s2len)) - 0.0 - (/ (let ((i 0) (j 0) (score 0) jlast) - (while (< i s1len) - (unless jlast (setq jlast j)) - (if (and (< j s2len) - (= (aref s1 i) (aref s2 j))) - (progn (cl-incf score) - (cl-incf i) - (cl-incf j)) - (setq m 0) - (cl-incf j) - (when (>= j s2len) - (setq j (or jlast j) - jlast nil) - (cl-incf i)))) - (* 2.0 score)) - (+ (length s1) - (length s2)))))) - -;;; Help: printers -;; TODO Parameterize optional args with `cl-defun' -(defun doom-cli-help--print (cli context &optional manpage? noglobal?) - "Write CLI's documentation in a manpage-esque format to stdout." - (let-alist (doom-cli-help cli) - (let* ((alist - `(,@(if manpage? - `((nil . ,(let* ((title (cadr (member "--load" command-line-args))) - (width (floor (/ (- (doom-cli-context-width context) - (length title)) - 2.0)))) - ;; FIXME Who am I fooling? - (format (format "%%-%ds%%s%%%ds" width width) - "DOOM(1)" title "DOOM(1)"))) - ("NAME" . ,(concat .command " - " .summary)) - ("SYNOPSIS" . ,(doom-cli-help--render-synopsis .synopsis nil t)) - ("DESCRIPTION" . ,.description)) - `((nil . ,(doom-cli-help--render-synopsis .synopsis "Usage: ")) - (nil . ,(string-join (seq-remove #'string-empty-p (list .summary .description)) - "\n\n")))) - ("ARGUMENTS" . ,(doom-cli-help--render-arguments .arguments)) - ("COMMANDS" - . ,(doom-cli-help--render-commands - .commands :prefix (doom-cli-command cli) :grouped? t :docs? t)) - ("OPTIONS" - . ,(doom-cli-help--render-options - (if (or (not (doom-cli-fn cli)) noglobal?) - `(,(assq 'local .options)) - .options) - cli)))) - (command (doom-cli-command cli))) - (letf! (defun printsection (section) - (print! "%s\n" - (if (null section) - (dark "TODO") - (markup - (format-spec - section `((?p . ,(car command)) - (?c . ,(doom-cli-command-string (cdr command)))) - 'ignore))))) - (pcase-dolist (`(,label . ,contents) alist) - (when (and contents (not (string-blank-p contents))) - (when label - (print! (bold "%s%s") label (if manpage? "" ":"))) - (print-group! :if label (printsection contents)))) - (pcase-dolist (`(,label . ,contents) .sections) - (when (and contents (not (assoc label alist))) - (print! (bold "%s:") label) - (print-group! (printsection contents)))))))) - -;;; Help: synopsis -(defun doom-cli-help--synopsis (cli &optional all-options?) - (let* ((rcli (doom-cli-get cli)) - (opts (doom-cli-help--options rcli)) - (opts (mapcar #'car (if all-options? (mapcan #'cdr opts) (alist-get 'local opts)))) - (opts (cl-loop for opt in opts - for args = (cdar opt) - for switches = (mapcar #'car opt) - for multi? = (member "..." args) - if args - collect (format (if multi? "[%s %s]..." "[%s %s]") - (string-join switches "|") - (string-join (remove "..." args) "|")) - else collect (format "[%s]" (string-join switches "|")))) - (args (doom-cli-arguments rcli)) - (subcommands? (doom-cli-subcommands rcli 1 :predicate? t))) - `((command . ,(doom-cli-command cli)) - (options ,@opts) - (required ,@(mapcar (fn! (upcase (format "`%s'" %))) (if subcommands? '(command) (alist-get '&required args)))) - (optional ,@(mapcar (fn! (upcase (format "[`%s']" %)))(alist-get '&optional args))) - (rest ,@(mapcar (fn! (upcase (format "[`%s'...]" %))) (if subcommands? '(args) (alist-get '&args args))))))) - -(defun doom-cli-help--render-synopsis (synopsis &optional prefix) - (let-alist synopsis - (let ((doom-print-indent 0) - (prefix (or prefix "")) - (command (doom-cli-command-string .command))) - (string-trim-right - (format! "%s\n\n" - (fill (concat (bold prefix) - (format "%s " command) - (markup - (join (append .options - (and .options - (or .required - .optional - .rest) - (list (dark "[--]"))) - .required - .optional - .rest)))) - 80 (1+ (length (concat prefix command))))))))) - -;;; Help: arguments -(defun doom-cli-help--arguments (cli &optional all?) - (doom-cli-help--parse-docs (doom-cli-find cli t) "ARGUMENTS")) - -(defun doom-cli-help--render-arguments (arguments) - (mapconcat (lambda (arg) - (format! "%-20s\n%s" - (underscore (car arg)) - (indent (if (equal (cdr arg) "TODO") - (dark (cdr arg)) - (cdr arg)) - doom-print-indent-increment))) - arguments - "\n")) - -;;; Help: commands -(cl-defun doom-cli-help--render-commands (commands &key prefix grouped? docs? (inline? t)) - (with-temp-buffer - (let* ((doom-print-indent 0) - (commands (seq-group-by (fn! (if grouped? (doom-cli-prop (doom-cli-get % t) :group))) - (nreverse commands))) - (toplevel (assq nil commands)) - (rest (remove toplevel commands)) - (drop (if prefix (length prefix) 0)) - (minwidth - (apply - #'max (or (cl-loop for cmd in (apply #'append (mapcar #'cdr commands)) - for cmd = (seq-drop cmd drop) - collect (length (doom-cli-command-string cmd))) - (list 15)))) - (ellipsis (doom-print--style 'dark " […]")) - (ellipsislen (- (length ellipsis) (if (eq doom-print-backend 'ansi) 2 4)))) - (dolist (group (cons toplevel rest)) - (let ((label (if (car-safe group) (cdr commands)))) - (when label - (insert! ((bold "%s:") (car group)) "\n")) - (print-group! :if label - (dolist (command (cdr group)) - (let* ((cli (doom-cli-get command t)) - (rcli (doom-cli-get command)) - (summary (doom-cli-short-docs rcli)) - (subcommands? (doom-cli-subcommands cli 1 :predicate? t))) - (insert! ((format "%%-%ds%%s%%s" - (+ (- minwidth doom-print-indent) - doom-print-indent-increment - (if subcommands? ellipsislen 0))) - (concat (doom-cli-command-string (seq-drop command drop)) - (if subcommands? ellipsis)) - (if inline? " " "\n") - (indent (if (and (doom-cli-alias cli) - (not (doom-cli-type rcli))) - (dark "-> %s" (doom-cli-command-string cli)) - (when docs? - (if summary (markup summary) (dark "TODO")))))) - "\n"))) - (when (cdr rest) - (insert "\n"))))) - (string-trim-right (buffer-string))))) - -;;; Help: options -(defun doom-cli-help--options (cli &optional noformatting?) - "Return an alist summarizing CLI's options. - -The alist's CAR are lists of formatted switches plus their arguments, e.g. -'((\"`--foo'\" \"`BAR'\") ...). Their CDR is their formatted documentation." - (let* ((docs (doom-cli-help--parse-docs (doom-cli-find cli t) "OPTIONS")) - (docs (mapcar (fn! (cons (split-string (car %) ", ") - (cdr %))) - docs)) - (strfmt (if noformatting? "%s" "`%s'")) - local-options - global-options - seen) - (dolist (neighbor (nreverse (doom-cli-find cli))) - (dolist (option (doom-cli-options neighbor)) - (when-let* ((switches (cl-loop for sw in (doom-cli-option-switches option) - if (and (doom-cli-option-flag-p option) - (string-prefix-p "--" sw)) - collect (format "--[no-]%s" (substring sw 2)) - else collect sw)) - (switches (seq-difference switches seen))) - (dolist (switch switches) (push switch seen)) - (push (cons (cl-loop for switch in switches - if (doom-cli-option-arguments option) - collect (cons (format strfmt switch) - (append (doom-cli-help--parse-args it noformatting?) - (when (doom-cli-option-multiple-p option) - (list "...")))) - else collect (list (format strfmt switch))) - (string-join - (or (delq - nil (cons (when-let (docs (doom-cli-option-docs option)) - (concat docs ".")) - (cl-loop for (flags . docs) in docs - unless (equal (seq-difference flags switches) flags) - collect docs))) - '("TODO")) - "\n\n")) - (if (equal (doom-cli-command neighbor) - (doom-cli-command cli)) - local-options - global-options))))) - `((local . ,(nreverse local-options)) - (global . ,(nreverse global-options))))) - -(defun doom-cli-help--render-options (options &optional cli) - (let ((doom-print-indent 0) - (local (assq 'local options)) - (global (assq 'global options))) - (when (or (cdr local) (cdr global)) - (letf! (defun printopts (opts) - (pcase-dolist (`(,switches . ,docs) (cdr opts)) - (let (multiple?) - (insert! - ("%s%s\n%s" - (mapconcat - (fn! (when (member "..." (cdr %)) - (setq multiple? t)) - (string-trim-right - (format "%s %s" - (doom-print--cli-markup (car %)) - (doom-print--cli-markup - (string-join (remove "..." (cdr %)) "|"))))) - switches - ", ") - (if multiple? ", ..." "") - (indent (fill (markup docs)) doom-print-indent-increment)) - "\n\n")))) - (with-temp-buffer - (if (null (cdr local)) - (insert (if global "This command has no local options.\n" "") "\n") - (printopts local)) - (when (cdr global) - (insert! ((bold "Global options:\n"))) - (print-group! (printopts global))) - (string-trim-right (buffer-string))))))) - -;;; Help: internal -(defun doom-cli-help--parse-args (args &optional noformatting?) - (cl-loop for arg in args - if (listp arg) - collect (string-join (doom-cli-help--parse-args arg noformatting?) "|") - else if (symbolp arg) - collect (format (if noformatting? "%s" "`%s'") (upcase (symbol-name arg))) - else collect arg)) - -(defun doom-cli-help--parse-docs (cli-list section-name) - (cl-check-type section-name string) - (let (alist) - (dolist (cli cli-list (nreverse alist)) - (when-let (section (cdr (assoc section-name (doom-cli-docs cli)))) - (with-temp-buffer - (save-excursion (insert section)) - (let ((lead (current-indentation)) - (buffer (current-buffer))) - (while (not (eobp)) - (let ((heading (string-trim (buffer-substring (point-at-bol) (point-at-eol)))) - (beg (point-at-bol 2)) - end) - (forward-line 1) - (while (and (not (eobp)) - (/= (current-indentation) lead) - (forward-line 1))) - (setf (alist-get heading alist nil nil #'equal) - (string-join - (delq - nil (list (alist-get heading alist nil nil #'equal) - (let ((end (point))) - (with-temp-buffer - (insert-buffer-substring buffer beg end) - (goto-char (point-min)) - (indent-rigidly (point-min) (point-max) (- (current-indentation))) - (string-trim-right (buffer-string)))))) - "\n\n")))))))))) - -(provide 'doom-cli-meta) -;;; meta.el ends here diff --git a/.config/emacs/lisp/cli/packages.el b/.config/emacs/lisp/cli/packages.el @@ -1,825 +0,0 @@ -;;; lisp/cli/packages.el --- package management commands -*- lexical-binding: t; -*- -;;; Commentary: -;;; Code: - -(require 'comp nil t) - -;; -;;; Variables - -;; None yet! - - -;; -;;; Commands - -(defcli! (:before (build b purge p)) (&context context) - (require 'comp nil t) - (doom-initialize-core-packages)) - -;; DEPRECATED Replace with "doom sync --rebuild" -(defcli! ((build b)) - ((rebuild-p ("-r") "Only rebuild packages that need rebuilding") - (jobs ("-j" "--jobs" num) "How many CPUs to use for native compilation")) - "Byte-compiles & symlinks installed packages. - -This ensures that all needed files are symlinked from their package repo and -their elisp files are byte-compiled. This is especially necessary if you upgrade -Emacs (as byte-code is generally not forward-compatible)." - :benchmark t - (when jobs - (setq native-comp-async-jobs-number (truncate jobs))) - (when (doom-packages-build (not rebuild-p)) - (doom-profile-generate)) - t) - -;; TODO Rename to "doom gc" and move to its own file -(defcli! ((purge p)) - ((nobuilds-p ("-b" "--no-builds") "Don't purge unneeded (built) packages") - (noelpa-p ("-p" "--no-elpa") "Don't purge ELPA packages") - (norepos-p ("-r" "--no-repos") "Don't purge unused straight repos") - (noeln-p ("-e" "--no-eln") "Don't purge old ELN bytecode") - (noregraft-p ("-g" "--no-regraft") "Regraft git repos (ie. compact them)")) - "Deletes orphaned packages & repos, and compacts them. - -Purges all installed ELPA packages (as they are considered temporary). Purges -all orphaned package repos and builds. If -g/--regraft is supplied, the git -repos among them will be regrafted and compacted to ensure they are as small as -possible. - -It is a good idea to occasionally run this doom purge -g to ensure your package -list remains lean." - :benchmark t - (straight-check-all) - (when (doom-packages-purge - (not noelpa-p) - (not norepos-p) - (not nobuilds-p) - (not noregraft-p) - (not noeln-p)) - (doom-profile-generate)) - t) - -(defcli-stub! rollback) ; TODO Implement me post-3.0 - - -;; -;;; Library - -;; FIXME Enforce naming conventions for all functions below - -(defun doom-packages--same-commit-p (abbrev-ref ref) - (and (stringp abbrev-ref) - (stringp ref) - (string-match-p (concat "^" (regexp-quote abbrev-ref)) - ref))) - -(defun doom-packages--abbrev-commit (commit &optional full) - (if full commit (substring commit 0 7))) - -(defun doom-packages--commit-log-between (start-ref end-ref) - (straight--process-with-result - (straight--process-run - "git" "log" "--oneline" "--no-merges" - end-ref (concat "^" (regexp-quote start-ref))) - (if success - (string-trim-right (or stdout "")) - (format "ERROR: Couldn't collect commit list because: %s" stderr)))) - -(defmacro doom-packages--straight-with (form &rest body) - (declare (indent 1)) - `(let-alist - (let* ((buffer (straight--process-buffer)) - (start (with-current-buffer buffer (point-max))) - (retval ,form) - (output (with-current-buffer buffer (buffer-substring start (point-max))))) - (save-match-data - (list (cons 'it retval) - (cons 'stdout (substring-no-properties output)) - (cons 'success (if (string-match "\n+\\[Return code: \\([0-9-]+\\)\\]\n+" output) - (string-to-number (match-string 1 output)))) - (cons 'output (string-trim output - "^\\(\\$ [^\n]+\n\\)*\n+" - "\n+\\[Return code: [0-9-]+\\]\n+"))))) - ,@body)) - -(defun doom-packages--barf-if-incomplete () - (let ((straight-safe-mode t)) - (condition-case _ (straight-check-all) - (error (user-error "Package state is incomplete. Run 'doom sync' first"))))) - -(defmacro doom-packages--with-recipes (recipes binds &rest body) - (declare (indent 2)) - (let ((recipe-var (make-symbol "recipe")) - (recipes-var (make-symbol "recipes"))) - `(let* ((,recipes-var ,recipes) - (built ()) - (straight-use-package-pre-build-functions - (cons (lambda (pkg &rest _) (cl-pushnew pkg built :test #'equal)) - straight-use-package-pre-build-functions))) - (dolist (,recipe-var ,recipes-var (nreverse built)) - (cl-block nil - (straight--with-plist (append (list :recipe ,recipe-var) ,recipe-var) - ,(ensure-list binds) - ,@body)))))) - -(defvar doom-packages--cli-updated-recipes nil) -(defun doom-packages--cli-recipes-update () - "Updates straight and recipe repos." - (unless doom-packages--cli-updated-recipes - (straight--make-build-cache-available) - (print! (start "Updating recipe repos...")) - (print-group! - (doom-packages--with-recipes - (delq - nil (mapcar (doom-rpartial #'gethash straight--repo-cache) - (mapcar #'symbol-name straight-recipe-repositories))) - (recipe package type local-repo) - (let ((esc (unless init-file-debug "\033[1A")) - (ref (straight-vc-get-commit type local-repo)) - newref output) - (print! (start "\033[KUpdating recipes for %s...%s") package esc) - (doom-packages--straight-with (straight-vc-fetch-from-remote recipe) - (when .it - (setq output .output) - (straight-merge-package package) - (unless (equal ref (setq newref (straight-vc-get-commit type local-repo))) - (print! (success "\033[K%s updated (%s -> %s)") - package - (doom-packages--abbrev-commit ref) - (doom-packages--abbrev-commit newref)) - (unless (string-empty-p output) - (print-group! (print! (item "%s" output)))))))))) - (setq straight--recipe-lookup-cache (make-hash-table :test #'eq) - doom-packages--cli-updated-recipes t))) - -(defvar doom-packages--eln-output-expected nil) - -(defvar doom-packages--eln-output-path (car (bound-and-true-p native-comp-eln-load-path))) - -(defun doom-packages--eln-file-name (file) - "Return the short .eln file name corresponding to `file'." - (file-name-concat - comp-native-version-dir - (file-name-nondirectory - (comp-el-to-eln-filename file)))) - -(defun doom-packages--eln-output-file (eln-name) - "Return the expected .eln file corresponding to `eln-name'." - (file-name-concat doom-packages--eln-output-path eln-name)) - -(defun doom-packages--eln-error-file (eln-name) - "Return the expected .error file corresponding to `eln-name'." - (file-name-concat doom-packages--eln-output-path eln-name ".error")) - -(defun doom-packages--find-eln-file (eln-name) - "Find `eln-name' on the `native-comp-eln-load-path'." - (cl-some (fn! (file-exists-p! eln-name %)) - native-comp-eln-load-path)) - -(defun doom-packages--elc-file-outdated-p (file) - "Check whether the corresponding .elc for `file' is outdated." - (let ((elc-file (byte-compile-dest-file file))) - ;; NOTE Ignore missing elc files, they could be missing due to - ;; `no-byte-compile'. Rebuilding unnecessarily is expensive. - (when (and (file-exists-p elc-file) - (file-newer-than-file-p file elc-file)) - (doom-log "packages:elc: %s is newer than %s" file elc-file) - t))) - -(defun doom-packages--eln-file-outdated-p (file) - "Check whether the corresponding .eln for `file' is outdated." - (when (file-exists-p file) - (let* ((eln-name (doom-packages--eln-file-name file)) - (eln-file (doom-packages--find-eln-file eln-name)) - (error-file (doom-packages--eln-error-file eln-name))) - (cond (eln-file - (when (file-newer-than-file-p file eln-file) - (doom-log "packages:eln: %s is newer than %s" file eln-file) - t)) - ((file-exists-p error-file) - (when (file-newer-than-file-p file error-file) - (doom-log "packages:eln: %s is newer than %s" file error-file) - t)))))) - -(defun doom-packages--native-compile-done-h (file) - "Callback fired when an item has finished async compilation." - (when file - (let* ((eln-name (doom-packages--eln-file-name file)) - (eln-file (doom-packages--eln-output-file eln-name)) - (error-file (doom-packages--eln-error-file eln-name))) - (if (file-exists-p eln-file) - (doom-log "packages:nativecomp: Compiled %s" eln-file) - (let ((error-dir (file-name-directory error-file))) - (if (not (file-writable-p error-dir)) - (doom-log "packages:nativecomp: failed to write %s" error-file) - (make-directory error-dir 'parents) - (write-region "" nil error-file) - (doom-log "packages:nativecomp: wrote %s" error-file))))))) - -(defun doom-packages--wait-for-native-compile-jobs () - "Wait for all pending async native compilation jobs." - (cl-loop with previous = 0 - with timeout = 30 - with timer = 0 - for pending = (+ (length comp-files-queue) (comp-async-runnings)) - while (not (zerop pending)) - if (/= previous pending) do - (print! (start "\033[KNatively compiling %d files...\033[1A" pending)) - (setq previous pending - timer 0) - else do - (let ((inhibit-message t)) - (if (> timer timeout) - (cl-loop for file-name being each hash-key of comp-async-compilations - for prc = (gethash file-name comp-async-compilations) - unless (process-live-p prc) - do (setq timer 0) - and do (print! (warn "Native compilation of %S timed out" (path file-name))) - and return (kill-process prc)) - (cl-incf timer 0.1)) - (sleep-for 0.1)))) - -(defun doom-packages--write-missing-eln-errors () - "Write .error files for any expected .eln files that are missing." - (when (featurep 'native-compile) - (cl-loop for file in doom-packages--eln-output-expected - for eln-name = (doom-packages--eln-file-name file) - for eln-file = (doom-packages--eln-output-file eln-name) - for error-file = (doom-packages--eln-error-file eln-name) - for error-dir = (file-name-directory error-file) - unless (or (file-exists-p eln-file) - (file-newer-than-file-p error-file file) - (not (file-writable-p error-dir))) - do (make-directory error-dir 'parents) - (write-region "" nil error-file) - (doom-log "Wrote %s" error-file)) - (setq doom-packages--eln-output-expected nil))) - -(defun doom-packages--compile-site-files () - "Queue async compilation for all non-doom Elisp files." - (when (featurep 'native-compile) - (cl-loop with paths = (cl-loop for path in load-path - unless (file-in-directory-p path doom-local-dir) - collect path) - for file in (doom-files-in paths :match "\\.el\\(?:\\.gz\\)?$") - if (and (file-exists-p (byte-compile-dest-file file)) - (not (doom-packages--find-eln-file (doom-packages--eln-file-name file))) - (not (cl-some (fn! (string-match-p % file)) - native-comp-deferred-compilation-deny-list))) do - (doom-log "Compiling %s" file) - (native-compile-async file)))) - -(defun doom-packages-install () - "Installs missing packages. - -This function will install any primary package (i.e. a package with a `package!' -declaration) or dependency thereof that hasn't already been." - (doom-initialize-packages) - (print! (start "Installing packages...")) - (let ((pinned (doom-package-pinned-list))) - (print-group! - (add-hook 'native-comp-async-cu-done-functions #'doom-packages--native-compile-done-h) - (if-let (built - (doom-packages--with-recipes (doom-package-recipe-list) - (recipe package type local-repo) - (unless (file-directory-p (straight--repos-dir local-repo)) - (doom-packages--cli-recipes-update)) - (condition-case-unless-debug e - (let ((straight-use-package-pre-build-functions - (cons (lambda (pkg &rest _) - (when-let (commit (cdr (assoc pkg pinned))) - (print! (item "Checked out %s: %s") pkg commit))) - straight-use-package-pre-build-functions))) - (straight-use-package (intern package)) - ;; HACK Line encoding issues can plague repos with dirty - ;; worktree prompts when updating packages or "Local - ;; variables entry is missing the suffix" errors when - ;; installing them (see hlissner/doom-emacs#2637), so - ;; have git handle conversion by force. - (when (and IS-WINDOWS (stringp local-repo)) - (let ((default-directory (straight--repos-dir local-repo))) - (when (file-in-directory-p default-directory straight-base-dir) - (straight--process-run "git" "config" "core.autocrlf" "true"))))) - (error - (signal 'doom-package-error (list package e)))))) - (progn - (when (featurep 'native-compile) - (doom-packages--compile-site-files) - (doom-packages--wait-for-native-compile-jobs) - (doom-packages--write-missing-eln-errors)) - (print! (success "\033[KInstalled %d packages") (length built))) - (print! (item "No packages need to be installed")) - nil)))) - - -(defun doom-packages-build (&optional force-p) - "(Re)build all packages." - (doom-initialize-packages) - (print! (start "(Re)building %spackages...") (if force-p "all " "")) - (print-group! - (let ((straight-check-for-modifications - (when (file-directory-p (straight--modified-dir)) - '(find-when-checking))) - (straight--allow-find - (and straight-check-for-modifications - (executable-find straight-find-executable) - t)) - (straight--packages-not-to-rebuild - (or straight--packages-not-to-rebuild (make-hash-table :test #'equal))) - (straight--packages-to-rebuild - (or (if force-p :all straight--packages-to-rebuild) - (make-hash-table :test #'equal))) - (recipes (doom-package-recipe-list))) - (add-hook 'native-comp-async-cu-done-functions #'doom-packages--native-compile-done-h) - (unless force-p - (straight--make-build-cache-available)) - (if-let (built - (doom-packages--with-recipes recipes (package local-repo recipe) - (unless force-p - ;; Ensure packages with outdated files/bytecode are rebuilt - (let* ((build-dir (straight--build-dir package)) - (repo-dir (straight--repos-dir local-repo)) - (build (if (plist-member recipe :build) - (plist-get recipe :build) - t)) - (want-byte-compile - (or (eq build t) - (memq 'compile build))) - (want-native-compile - (or (eq build t) - (memq 'native-compile build)))) - (and (eq (car-safe build) :not) - (setq want-byte-compile (not want-byte-compile) - want-native-compile (not want-native-compile))) - (unless (featurep 'native-compile) - (setq want-native-compile nil)) - (and (or want-byte-compile want-native-compile) - (or (file-newer-than-file-p repo-dir build-dir) - (file-exists-p (straight--modified-dir (or local-repo package))) - (cl-loop with outdated = nil - for file in (doom-files-in build-dir :match "\\.el$" :full t) - if (or (if want-byte-compile (doom-packages--elc-file-outdated-p file)) - (if want-native-compile (doom-packages--eln-file-outdated-p file))) - do (setq outdated t) - (when want-native-compile - (push file doom-packages--eln-output-expected)) - finally return outdated)) - (puthash package t straight--packages-to-rebuild)))) - (straight-use-package (intern package)))) - (progn - (when (featurep 'native-compile) - (doom-packages--compile-site-files) - (doom-packages--wait-for-native-compile-jobs) - (doom-packages--write-missing-eln-errors)) - ;; HACK Every time you save a file in a package that straight tracks, - ;; it is recorded in ~/.emacs.d/.local/straight/modified/. - ;; Typically, straight will clean these up after rebuilding, but - ;; Doom's use-case circumnavigates that, leaving these files - ;; there and causing a rebuild of those packages each time `doom - ;; sync' or similar is run, so we clean it up ourselves: - (delete-directory (straight--modified-dir) 'recursive) - (print! (success "\033[KRebuilt %d package(s)") (length built))) - (print! (item "No packages need rebuilding")) - nil)))) - - - -(defun doom-packages-update () - "Updates packages." - (doom-initialize-packages) - (doom-packages--barf-if-incomplete) - (doom-packages--cli-recipes-update) - (let* ((repo-dir (straight--repos-dir)) - (pinned (doom-package-pinned-list)) - (recipes (doom-package-recipe-list)) - (packages-to-rebuild (make-hash-table :test 'equal)) - (repos-to-rebuild (make-hash-table :test 'equal)) - (total (length recipes)) - (esc (unless init-file-debug "\033[1A")) - (i 0) - errors) - (print! (start "Updating packages (this may take a while)...")) - (doom-packages--with-recipes recipes (recipe package type local-repo) - (cl-incf i) - (print-group! - (unless (straight--repository-is-available-p recipe) - (print! (error "(%d/%d) Couldn't find local repo for %s") i total package) - (cl-return)) - (when (gethash local-repo repos-to-rebuild) - (puthash package t packages-to-rebuild) - (print! (success "(%d/%d) %s was updated indirectly (with %s)") i total package local-repo) - (cl-return)) - (let ((default-directory (straight--repos-dir local-repo))) - (unless (file-in-directory-p default-directory repo-dir) - (print! (warn "(%d/%d) Skipping %s because it is local") i total package) - (cl-return)) - (when (eq type 'git) - (unless (file-exists-p ".git") - (error "%S is not a valid repository" package))) - (condition-case-unless-debug e - (let ((ref (straight-vc-get-commit type local-repo)) - (target-ref - (cdr (or (assoc local-repo pinned) - (assoc package pinned)))) - commits - output) - (or (cond - ((not (stringp target-ref)) - (print! (start "\033[K(%d/%d) Fetching %s...%s") i total package esc) - (doom-packages--straight-with (straight-vc-fetch-from-remote recipe) - (when .it - (straight-merge-package package) - ;; (condition-case e - ;; (straight-merge-package package) - ;; (wrong-type-argument - ;; (if (not (equal (cdr e) '(arrayp nil))) - ;; (signal (car e) (cdr e)) - ;; (delete-directory (straight--build-dir local-repo) t) - ;; (straight-use-package (intern package))))) - (setq target-ref (straight-vc-get-commit type local-repo)) - (setq output (doom-packages--commit-log-between ref target-ref) - commits (length (split-string output "\n" t))) - (or (not (doom-packages--same-commit-p target-ref ref)) - (cl-return))))) - - ((doom-packages--same-commit-p target-ref ref) - (print! (item "\033[K(%d/%d) %s is up-to-date...%s") i total package esc) - (cl-return)) - - ((if (straight-vc-commit-present-p recipe target-ref) - (print! (start "\033[K(%d/%d) Checking out %s (%s)...%s") - i total package (doom-packages--abbrev-commit target-ref) esc) - (print! (start "\033[K(%d/%d) Fetching %s...%s") i total package esc) - (and (straight-vc-fetch-from-remote recipe) - (straight-vc-commit-present-p recipe target-ref))) - (straight-vc-check-out-commit recipe target-ref) - (or (not (eq type 'git)) - (setq output (doom-packages--commit-log-between ref target-ref) - commits (length (split-string output "\n" t)))) - (doom-packages--same-commit-p target-ref (straight-vc-get-commit type local-repo))) - - ((print! (start "\033[K(%d/%d) Re-cloning %s...") i total local-repo esc) - (let ((repo (straight--repos-dir local-repo)) - (straight-vc-git-default-clone-depth 'full)) - (delete-directory repo 'recursive) - (print-group! - (straight-use-package (intern package) nil 'no-build)) - (prog1 (file-directory-p repo) - (or (not (eq type 'git)) - (setq output (doom-packages--commit-log-between ref target-ref) - commits (length (split-string output "\n" t)))))))) - (progn - (print! (warn "\033[K(%d/%d) Failed to fetch %s") - i total local-repo) - (unless (string-empty-p output) - (print-group! (print! (item "%s" output)))) - (cl-return))) - (puthash local-repo t repos-to-rebuild) - ;; HACK: Rebuild all packages that depend on PACKAGE after - ;; updating it. This ensures their bytecode don't contain stale - ;; references to symbols in silent dependencies. - ;; TODO: Allow `package!' to control this. - ;; TODO: Add cache+optimization step for this rebuild table. - (letf! ((dependents (straight-dependents package)) - (n 0) - (defun* add-to-rebuild (tree) - (cond ((null tree) nil) - ((stringp tree) - (unless (gethash tree packages-to-rebuild) - (cl-incf n 1) - (puthash tree t packages-to-rebuild))) - ((listp tree) - (add-to-rebuild (car tree)) - (add-to-rebuild (cdr tree)))))) - (add-to-rebuild dependents) - (puthash package t packages-to-rebuild) - (print! (success "\033[K(%d/%d) %s: %s -> %s%s%s") - i total local-repo - (doom-packages--abbrev-commit ref) - (doom-packages--abbrev-commit target-ref) - (if (and (integerp commits) (> commits 0)) - (format " [%d commit(s)]" commits) - "") - (if (> n 0) - (format " (w/ %d dependents)" n) - ""))) - (unless (string-empty-p output) - (let ((lines (split-string output "\n"))) - (setq output - (if (> (length lines) 20) - (concat (string-join (cl-subseq (butlast lines 1) 0 20) "\n") - "\n[...]") - output))) - (print-group! (print! "%s" (indent output 2))))) - (user-error - (signal 'user-error (error-message-string e))) - (error - (signal 'doom-package-error (list package e))))))) - (print-group! - (princ "\033[K") - (if (hash-table-empty-p packages-to-rebuild) - (ignore (print! (success "All %d packages are up-to-date") total)) - (straight--transaction-finalize) - (let ((default-directory (straight--build-dir))) - (mapc (doom-rpartial #'delete-directory 'recursive) - (hash-table-keys packages-to-rebuild))) - (print! (success "Updated %d package(s)") - (hash-table-count packages-to-rebuild)) - (doom-packages-build) - t)))) - - -;;; PURGE (for the emperor) -(defun doom-packages--purge-build (build) - (let ((build-dir (straight--build-dir build))) - (delete-directory build-dir 'recursive) - (if (file-directory-p build-dir) - (ignore (print! (error "Failed to purg build/%s" build))) - (print! (success "Purged build/%s" build)) - t))) - -(defun doom-packages--purge-builds (builds) - (if (not builds) - (prog1 0 - (print! (item "No builds to purge"))) - (print! (start "Purging straight builds..." (length builds))) - (print-group! - (length - (delq nil (mapcar #'doom-packages--purge-build builds)))))) - -(cl-defun doom-packages--regraft-repo (repo) - (unless repo - (error "No repo specified for regrafting")) - (let ((default-directory (straight--repos-dir repo))) - (unless (file-directory-p ".git") - (print! (warn "\033[Krepos/%s is not a git repo, skipping" repo)) - (cl-return)) - (unless (file-in-directory-p default-directory straight-base-dir) - (print! (warn "\033[KSkipping repos/%s because it is local" repo)) - (cl-return)) - (let ((before-size (doom-directory-size default-directory))) - (doom-call-process "git" "reset" "--hard") - (doom-call-process "git" "clean" "-ffd") - (if (not (zerop (car (doom-call-process "git" "replace" "--graft" "HEAD")))) - (print! (item "\033[Krepos/%s is already compact\033[1A" repo)) - (doom-call-process "git" "reflog" "expire" "--expire=all" "--all") - (doom-call-process "git" "gc" "--prune=now") - (let ((after-size (doom-directory-size default-directory))) - (if (equal after-size before-size) - (print! (success "\033[Krepos/%s cannot be compacted further" repo)) - (print! (success "\033[KRegrafted repos/%s (from %0.1fKB to %0.1fKB)") - repo before-size after-size))))) - t)) - -(defun doom-packages--regraft-repos (repos) - (if (not repos) - (prog1 0 - (print! (item "No repos to regraft"))) - (print! (start "Regrafting %d repos..." (length repos))) - (let ((before-size (doom-directory-size (straight--repos-dir)))) - (print-group! - (prog1 (delq nil (mapcar #'doom-packages--regraft-repo repos)) - (princ "\033[K") - (let ((after-size (doom-directory-size (straight--repos-dir)))) - (print! (success "Finished regrafting. Size before: %0.1fKB and after: %0.1fKB (%0.1fKB)") - before-size after-size - (- after-size before-size)))))))) - -(defun doom-packages--purge-repo (repo) - (let ((repo-dir (straight--repos-dir repo))) - (when (file-directory-p repo-dir) - (delete-directory repo-dir 'recursive) - (delete-file (straight--modified-file repo)) - (if (file-directory-p repo-dir) - (ignore (print! (error "Failed to purge repos/%s" repo))) - (print! (success "Purged repos/%s" repo)) - t)))) - -(defun doom-packages--purge-repos (repos) - (if (not repos) - (prog1 0 - (print! (item "No repos to purge"))) - (print! (start "Purging straight repositories...")) - (print-group! - (length - (delq nil (mapcar #'doom-packages--purge-repo repos)))))) - -(defun doom-packages--purge-elpa () - (require 'doom-packages) - (let ((dirs (doom-files-in package-user-dir :type t :depth 0))) - (if (not dirs) - (prog1 0 - (print! (item "No ELPA packages to purge"))) - (print! (start "Purging ELPA packages...")) - (dolist (path dirs (length dirs)) - (condition-case e - (print-group! - (if (file-directory-p path) - (delete-directory path 'recursive) - (delete-file path)) - (print! (success "Deleted %s") (filename path))) - (error - (print! (error "Failed to delete %s because: %s") - (filename path) - e))))))) - -(defun doom-packages--purge-eln () - (if-let (dirs - (cl-delete (expand-file-name comp-native-version-dir doom-packages--eln-output-path) - (directory-files doom-packages--eln-output-path t "^[^.]" t) - :test #'file-equal-p)) - (progn - (print! (start "Purging old native bytecode...")) - (print-group! - (dolist (dir dirs) - (print! (item "Deleting %S") (relpath dir doom-packages--eln-output-path)) - (delete-directory dir 'recursive)) - (print! (success "Purged %d directory(ies)" (length dirs)))) - (length dirs)) - (print! (item "No ELN directories to purge")) - 0)) - -(defun doom-packages-purge (&optional elpa-p builds-p repos-p regraft-repos-p eln-p) - "Auto-removes orphaned packages and repos. - -An orphaned package is a package that isn't a primary package (i.e. doesn't have -a `package!' declaration) or isn't depended on by another primary package. - -If BUILDS-P, include straight package builds. -If REPOS-P, include straight repos. -If ELPA-P, include packages installed with package.el (M-x package-install)." - (doom-initialize-packages) - (doom-packages--barf-if-incomplete) - (print! (start "Purging orphaned packages (for the emperor)...")) - (cl-destructuring-bind (&optional builds-to-purge repos-to-purge repos-to-regraft) - (let ((rdirs - (and (or repos-p regraft-repos-p) - (straight--directory-files (straight--repos-dir) nil nil 'sort)))) - (list (when builds-p - (let ((default-directory (straight--build-dir))) - (seq-filter #'file-directory-p - (seq-remove (doom-rpartial #'gethash straight--profile-cache) - (straight--directory-files default-directory nil nil 'sort))))) - (when repos-p - (seq-remove (doom-rpartial #'straight--checkhash straight--repo-cache) - rdirs)) - (when regraft-repos-p - (seq-filter (doom-rpartial #'straight--checkhash straight--repo-cache) - rdirs)))) - (print-group! - (delq - nil (list - (if (not builds-p) - (ignore (print! (item "Skipping builds"))) - (and (/= 0 (doom-packages--purge-builds builds-to-purge)) - (quiet! (straight-prune-build-cache)))) - (if (not elpa-p) - (ignore (print! (item "Skipping elpa packages"))) - (/= 0 (doom-packages--purge-elpa))) - (if (not repos-p) - (ignore (print! (item "Skipping repos"))) - (/= 0 (doom-packages--purge-repos repos-to-purge))) - (if (not regraft-repos-p) - (ignore (print! (item "Skipping regrafting"))) - (doom-packages--regraft-repos repos-to-regraft)) - (when (featurep 'native-compile) - (if (not eln-p) - (ignore (print! (item "Skipping native bytecode"))) - (doom-packages--purge-eln)))))))) - - -;; -;;; Hacks - -;; Straight was designed primarily for interactive use, in an interactive Emacs -;; session, but Doom does its package management in the terminal. Some things -;; must be modified get straight to behave and improve its UX for our users. - -(defvar doom-cli--straight-auto-options - '(("has diverged from" - . "^Reset [^ ]+ to branch") - ("but recipe specifies a URL of" - . "Delete remote \"[^\"]+\", re-create it with correct URL") - ("has a merge conflict:" - . "^Abort merge$") - ("has a dirty worktree:" - . "^Discard changes$") - ("^In repository \"[^\"]+\", [^ ]+ (on branch \"main\") is ahead of default branch \"master\"" - . "^Checkout branch \"master\"") - ("^In repository \"[^\"]+\", [^ ]+ (on branch \"[^\"]+\") is ahead of default branch \"[^\"]+\"" - . "^Checkout branch \"") - ("^In repository " - . "^Reset branch \\|^Delete remote [^,]+, re-create it with correct URL\\|^Checkout \"main\"")) - "A list of regexps, mapped to regexps. - -Their CAR is tested against the prompt, and CDR is tested against the presented -option, and is used by `straight-vc-git--popup-raw' to select which option to -recommend. - -It may not be obvious to users what they should do for some straight prompts, -so Doom will recommend the one that reverts a package back to its (or target) -original state.") - -;; HACK Remove dired & magit options from prompt, since they're inaccessible in -;; noninteractive sessions. -(advice-add #'straight-vc-git--popup-raw :override #'straight--popup-raw) - -;; HACK Replace GUI popup prompts (which hang indefinitely in tty Emacs) with -;; simple prompts. -(defadvice! doom-cli--straight-fallback-to-y-or-n-prompt-a (fn &optional prompt noprompt?) - :around #'straight-are-you-sure - (or noprompt? - (if noninteractive - (y-or-n-p (format! "%s" (or prompt ""))) - (funcall fn prompt)))) - -(defun doom-cli--straight-recommended-option-p (prompt option) - (cl-loop for (prompt-re . opt-re) in doom-cli--straight-auto-options - if (string-match-p prompt-re prompt) - return (string-match-p opt-re option))) - -(defadvice! doom-cli--straight-no-compute-prefixes-a (fn &rest args) - :around #'straight--build-autoloads - (let (autoload-compute-prefixes) - (apply fn args))) - -(defadvice! doom-cli--straight-fallback-to-tty-prompt-a (fn prompt actions) - "Modifies straight to prompt on the terminal when in noninteractive sessions." - :around #'straight--popup-raw - (if (bound-and-true-p async-in-child-emacs) - (error "Straight prompt: %s" prompt) - (let ((doom-cli--straight-auto-options doom-cli--straight-auto-options)) - ;; We can't intercept C-g, so no point displaying any options for this key - ;; when C-c is the proper way to abort batch Emacs. - (delq! "C-g" actions 'assoc) - ;; HACK: These are associated with opening dired or magit, which isn't - ;; possible in tty Emacs, so... - (delq! "e" actions 'assoc) - (delq! "g" actions 'assoc) - (if (doom-cli-context-suppress-prompts-p doom-cli--context) - (cl-loop for (_key desc func) in actions - when desc - when (doom-cli--straight-recommended-option-p prompt desc) - return (funcall func)) - (print! (start "%s") (red prompt)) - (print-group! - (terpri) - (let (recommended options) - (print-group! - (print! " 1) Abort") - (cl-loop for (_key desc func) in actions - when desc - do (push func options) - and do - (print! "%2s) %s" (1+ (length options)) - (if (doom-cli--straight-recommended-option-p prompt desc) - (progn - (setq doom-cli--straight-auto-options nil - recommended (length options)) - (green (concat desc " (Choose this if unsure)"))) - desc)))) - (terpri) - (let* ((options - (cons (lambda () - (let ((doom-output-indent 0)) - (terpri) - (print! (warn "Aborted"))) - (doom-cli--exit 1)) - (nreverse options))) - (prompt - (format! "How to proceed? (%s%s) " - (mapconcat #'number-to-string - (number-sequence 1 (length options)) - ", ") - (if (not recommended) "" - (format "; don't know? Pick %d" (1+ recommended))))) - answer fn) - (while (null (nth (setq answer (1- (read-number prompt))) options)) - (print! (warn "%s is not a valid answer, try again.") answer)) - (funcall (nth answer options))))))))) - -(setq straight-arrow " > ") -(defadvice! doom-cli--straight-respect-print-indent-a (string &rest objects) - "Same as `message' (which see for STRING and OBJECTS) normally. -However, in batch mode, print to stdout instead of stderr." - :override #'straight--output - (let ((msg (apply #'format string objects))) - (save-match-data - (when (string-match (format "^%s\\(.+\\)$" (regexp-quote straight-arrow)) msg) - (setq msg (match-string 1 msg)))) - (and (string-match-p "^\\(Cloning\\|\\(Reb\\|B\\)uilding\\) " msg) - (not (string-suffix-p "...done" msg)) - (doom-print (concat "> " msg) :format t)))) - -(defadvice! doom-cli--straight-ignore-gitconfig-a (fn &rest args) - "Prevent user and system git configuration from interfering with git calls." - :around #'straight--process-call - (letenv! (("GIT_CONFIG" nil) - ("GIT_CONFIG_NOSYSTEM" "1") - ("GIT_CONFIG_GLOBAL" (or (getenv "DOOMGITCONFIG") - "/dev/null"))) - (apply fn args))) - -(provide 'doom-cli-packages) -;;; packages.el ends here diff --git a/.config/emacs/lisp/cli/profiles.el b/.config/emacs/lisp/cli/profiles.el @@ -1,83 +0,0 @@ -;;; lisp/cli/profiles.el -*- lexical-binding: t; -*- -;;; Commentary: -;;; Code: - -;; -;;; Variables - -(defvar doom-cli-known-profiles-file - (file-name-concat doom-cache-dir (format "profiles.%s.el" (or (car doom-profile) "@"))) - ;; REVIEW: Use `doom-profile-data-dir' in v3 - ;; (file-name-concat doom-profile-data-dir "known-profiles.el") - "TODO") - - -;; -;;; doom profile ... - -(defcli-stub! ((profile pf)) ()) - -(defcli-stub! (profile hash) ()) - -(defcli-stub! (profile new) ()) - -(defcli-stub! (profile archive) ()) - -(defcli-stub! (profile (remove rm)) ()) - -(defcli-stub! (profile (rename mv)) ()) - -(defcli-stub! (profile nuke) ()) - - -;; -;;; doom profiles ... - -(defcli! (profiles sync) ((reload? ("--reload"))) - "Synchronize your profiles with Doom." - :benchmark t - (let* ((old-profiles (doom-profiles-read doom-cli-known-profiles-file)) - (new-profiles (doom-profiles-autodetect)) - (load-file doom-profile-load-file) - (version (doom-file-read load-file :by 'read :noerror t)) - (recreate? (or (not reload?) (doom-profiles-outdated-p)))) - (unless (file-exists-p load-file) - (print! (warn "No profile loader found. Generating one...")) - (print-group! (print! (start "Regenerating it..."))) - (setq recreate? t)) - (unless (equal (or version doom-version) doom-version) - (print! (warn "Detected version mismatch in profile loader (%s != %s)" - version doom-version)) - (print! (start "Generating profile manifest...")) - (setq recreate? t)) - (print-group! - (if (not recreate?) - (doom-log "Profiles are up-to-date!") - (let* ((pred (lambda (a b) (eq (car a) (car b)))) - (added (seq-difference new-profiles old-profiles pred)) - (removed (seq-difference old-profiles new-profiles pred)) - (changed (cl-loop for profile in (seq-intersection new-profiles old-profiles pred) - unless (equal (cdr profile) - (alist-get (car profile) old-profiles)) - collect profile))) - (when (or added removed changed recreate?) - (print! (start "Synchronizing %d known profile%s...") - (length new-profiles) - (if (/= (length new-profiles) 1) "s" "")) - (print-group! - (dolist (p added) (print! (item "Added %S") (car p))) - (dolist (p removed) (print! (item "Removed %S") (car p))) - (dolist (p changed) (print! (item "Changed %S") (car p))) - (doom-file-write doom-cli-known-profiles-file (list new-profiles) :mode #o600) - (doom-profiles-save new-profiles load-file) - (print! (success "Regenerated profile loader: %s") - (path load-file))))))))) - - -;; -;;; Helpers - - - -(provide 'doom-cli-profiles) -;;; profiles.el ends here diff --git a/.config/emacs/lisp/cli/run.el b/.config/emacs/lisp/cli/run.el @@ -1,119 +0,0 @@ -;;; lisp/cli/run.el --- launching Emacs in a sandbox -*- lexical-binding: t; -*- -;;; Commentary: -;;; Code: - -;; -;;; Variables - -;; None yet! - - -;; -;;; Commands - -(defcli! run - (;; TODO Implement sandbox functionality post-3.0 - ;; (daemon? ("--daemon")) - ;; (window-type ("--gui" "--tty")) - ;; (version ("--with-emacs" version)) - ;; (doomversion ("--with-doom" version)) - ;; (profile ("--profile" name)) - (repl? ("--repl") "Launch an elisp REPL") - ;; &multiple - ;; (calls ("-f" "--funcall" fn)) - ;; (loads ("-l" "--load" file)) - ;; (evals ( "--eval" form)) - &context context - &input input - &rest args) - "Launch Doom Emacs or an Emacs sandbox - -Opens from bin/doom's parent directory. - -Keep in mind there is some overhead opening Doom this way. For the best -performance, it is best to run Doom out of ~/.config/emacs or ~/.emacs.d." - :benchmark nil - ;; TODO Implement sandbox functionality post-3.0 - ;; (when version - ;; (unless (executable-find "nix-shell") - ;; (user-error "--emacs option is not supported without nix")) - ;; ...) - (if repl? - (if input - ;; Evaluate piped-in text directly, if given. - (eval (read input) t) - (doom-run-repl context)) - (let* ((tempdir (doom-path (temporary-file-directory) "doom.run")) - (tempemacsdir (doom-path tempdir ".emacs.d"))) - (delete-directory tempdir t) ; start from scratch - (make-directory tempemacsdir t) - ;; HACK: So that Emacs doesn't lose track of local state, like user fonts, - ;; configs, or binscripts, we symlink these to the sandbox. - ;; REVIEW: Use `--init-directory' when we drop 29 support OR when Doom is - ;; in bootloader mode. - (dolist (dir (list (or (getenv "XDG_DATA_HOME") "~/.local/share") - (or (getenv "XDG_BIN_HOME") "~/.local/bin") - (or (getenv "XDG_CONFIG_HOME") "~/.config") - (or (getenv "XDG_CACHE_HOME") "~/.cache"))) - (let* ((xdg-dir (doom-path dir)) - (target (doom-path tempdir (file-relative-name xdg-dir "~")))) - (when (file-directory-p xdg-dir) - (unless (file-symlink-p target) - (make-directory (file-name-directory target) t) - (make-symbolic-link xdg-dir target))))) - (with-temp-file (doom-path tempemacsdir "early-init.el") - (prin1 `(progn - (setenv "HOME" ,(getenv "HOME")) - (setenv "EMACSDIR" ,doom-emacs-dir) - (setenv "DOOMDIR" ,doom-user-dir) - (setenv "DOOMPROFILE" ,(getenv "DOOMPROFILE")) - (setq early-init-file ,(doom-path doom-emacs-dir "early-init.el")) - (load early-init-file nil (not ,init-file-debug) 'nosuffix)) - (current-buffer))) - (exit! (format "HOME=%S %s %s" - tempdir - invocation-name - (combine-and-quote-strings args)))))) - - -;; -;;; Helpers - -(defun doom-run-repl (context) - "Launch a rudimentary Elisp REPL." - ;; I wrote this for fun; not with any serious intention of adding a - ;; fully-fledged REPL to the Doom CLI. Still, I occasionally need to check - ;; something, and once this has nix integration and can sandbox Emacs versions - ;; separately, it may be useful for quick tests and demos. - (let (form) - (while (setq form (read-from-minibuffer "(elisp) $ ")) - (when (member form '(":quit" ":q")) - (print! "\nGoodbye!") - (exit! 0)) - (let (debug-on-error) - (condition-case e - (print! "%S" (eval (read form) t)) - (error - (let* ((n 0) - (frame (backtrace-frame n)) - (frame-list nil) - (in-program-stack t)) - (while frame - (when in-program-stack - (push (cdr frame) frame-list)) - ;; (when (eq (elt frame 1) 'doom-run-repl) - ;; (setq in-program-stack t)) - (when (eq (elt frame 1) 'doom-run-repl) - (setq in-program-stack nil)) - (setq n (1+ n) - frame (backtrace-frame n))) - (let* ((depth doom-cli-backtrace-depth) - (print-escape-newlines t)) - (print! (error "There was an unexpected error")) - (print-group! - (print! "%s %s" (bold "Message:") (error-message-string e)) - (print! "%s %S" (bold "Details:") (cdr e)))))))) - (terpri)))) - -(provide 'doom-cli-run) -;;; run.el ends here diff --git a/.config/emacs/lisp/cli/sync.el b/.config/emacs/lisp/cli/sync.el @@ -1,81 +0,0 @@ -;;; lisp/cli/sync.el --- synchronize config command -*- lexical-binding: t; -*- -;;; Commentary: -;;; Code: - -(load! "packages") - - -;; -;;; Variables - -(defvar doom-after-sync-hook () - "Hooks run after 'doom sync' synchronizes the user's config with Doom.") - -(defvar doom-before-sync-hook () - "Hooks run before 'doom sync' synchronizes the user's config with Doom.") - - -;; -;;; Commands - -(defcli-alias! (:before (sync s)) (:before build)) - -(defcli! ((sync s)) - ((noenvvar? ("-e") "Don't regenerate the envvar file") - (noelc? ("-c") "Don't recompile config") - (update? ("-u") "Update installed packages after syncing") - (purge? ("-p") "Purge orphaned package repos & regraft them") - (jobs ("-j" "--jobs" num) "How many CPUs to use for native compilation")) - "Synchronize your config with Doom Emacs. - -This is the equivalent of running autoremove, install, autoloads, then -recompile. Run this whenever you: - - 1. Modify your `doom!' block, - 2. Add or remove `package!' blocks to your config, - 3. Add or remove autoloaded functions in module autoloaded files. - 4. Update Doom outside of Doom (e.g. with git) - -It will ensure that unneeded packages are removed, all needed packages are -installed, autoloads files are up-to-date and no byte-compiled files have gone -stale. - -OPTIONS: - -j, --jobs - Defaults to the maximum number of threads (or 1, if your CPU's threadcount - can't be determined)." - :benchmark t - (when (doom-profiles-bootloadable-p) - (call! '(profiles sync "--reload"))) - (run-hooks 'doom-before-sync-hook) - (add-hook 'kill-emacs-hook #'doom-sync--abort-warning-h) - (when jobs - (setq native-comp-async-jobs-number (truncate jobs))) - (print! (start "Synchronizing %S profile..." ) - (or (car doom-profile) "default")) - (unwind-protect - (print-group! - (when (and (not noenvvar?) - (file-exists-p doom-env-file)) - (call! '(env))) - (doom-packages-install) - (doom-packages-build) - (when update? - (doom-packages-update)) - (doom-packages-purge purge? purge? purge? purge? purge?) - (when (doom-profile-generate) - (print! (item "Restart Emacs or use 'M-x doom/reload' for changes to take effect")) - (run-hooks 'doom-after-sync-hook)) - t) - (remove-hook 'kill-emacs-hook #'doom-sync--abort-warning-h))) - - -;; -;;; Helpers - -(defun doom-sync--abort-warning-h () - (print! (warn "Script was abruptly aborted, leaving Doom in an incomplete state!")) - (print! (item "Run 'doom sync' to repair it."))) - -(provide 'doom-cli-sync) -;;; sync.el ends here diff --git a/.config/emacs/lisp/cli/test.el b/.config/emacs/lisp/cli/test.el @@ -1,48 +0,0 @@ -;;; lisp/cli/test.el -*- lexical-binding: t; -*- -;;; Commentary: -;; -;; The heart of Doom's test DSL and framework. Powered by either ERT or -;; Buttercup, this extends testing frameworks to allow for isolated execution -;; contexts on several levels, a more sophisticated CLI for tests, and -;; integration with Doom's profiles system so testing environments can be -;; generated on-the-fly. -;; -;;; Code: - -;; -;;; Variables - -;; TODO Implement me -(defvar doom-test-backend 'ert - "One of `ert' or `buttercup'.") - -;; TODO Implement me -(defvar doom-test-isolation-level nil - "Determines the testing strategy for tests. - -Should be one of: - - nil -- Run all tests in the same session. - file -- Run each test file in isolated sessions. - group -- Run each group of tests in isolated sessions. - t -- Run each individual test in isolated sessions (very slow).") - - -;; -;;; Commands - -;; FIXME Will be fixed in v3.1 -(defcli-stub! test - ((backend ("--ert" "--buttercup")) - (jobs ("-j" "--jobs" int)) - &rest targets) - "Run Doom unit tests.") - - -;; -;;; Helpers - -;; Nothing here yet - -(provide 'doom-cli-test) -;;; test.el ends here diff --git a/.config/emacs/lisp/cli/upgrade.el b/.config/emacs/lisp/cli/upgrade.el @@ -1,165 +0,0 @@ -;;; lisp/cli/upgrade.el -*- lexical-binding: t; -*- -;;; Commentary: -;;; Code: - -(load! "packages") -(load! "compile") - - -;; -;;; Variables - -(defvar doom-upgrade-url "https://github.com/doomemacs/doomemacs" - "The git repo url for Doom Emacs.") - -(defvar doom-upgrade-remote "_upgrade" - "The name to use as our staging remote.") - - -;; -;;; Commands - -(defcli! ((upgrade up)) - ((packages? ("-p" "--packages") "Only upgrade packages, not Doom") - (jobs ("-j" "--jobs" num) "How many CPUs to use for native compilation") - &context context) - "Updates Doom and packages. - -This requires that ~/.emacs.d is a git repo, and is the equivalent of the -following shell commands: - - cd ~/.emacs.d - git pull --rebase - doom clean - doom sync -u" - (let* ((force? (doom-cli-context-suppress-prompts-p context)) - (sync-cmd (append '("sync" "-u") (if jobs `("-j" ,num))))) - (cond - (packages? - ;; HACK It's messy to use straight to upgrade straight, due to the - ;; potential for backwards incompatibility, so we staticly check if - ;; Doom's `package!' declaration for straight has changed. If it has, - ;; delete straight so 'doom sync' will install the new version for us. - ;; - ;; Clumsy, but a better solution is in the works. - (let ((recipe (doom-cli-context-get context 'straight-recipe))) - (when (and recipe (not (equal recipe (doom-upgrade--get-straight-recipe)))) - (print! (item "Preparing straight for an update")) - (delete-directory (doom-path straight-base-dir "straight/repos/straight.el") - 'recursive))) - (call! sync-cmd) - (print! (success "Finished upgrading Doom Emacs"))) - - ((doom-cli-upgrade context force? force?) - ;; Reload Doom's CLI & libraries, in case there were any upstream changes. - ;; Major changes will still break, however - (print! (item "Reloading Doom Emacs")) - (exit! "doom" "upgrade" "-p" - (if force? "--force") - (if jobs (format "--jobs=%d" jobs)))) - - ((print! "Doom is up-to-date!") - (call! sync-cmd))))) - - -;; -;;; Helpers - -(defun doom-cli-upgrade (context &optional auto-accept-p force-p) - "Upgrade Doom to the latest version non-destructively." - (let ((default-directory doom-emacs-dir) - process-file-side-effects) - (print! (start "Preparing to upgrade Doom Emacs and its packages...")) - - (let* (;; git name-rev may return BRANCH~X for detached HEADs and fully - ;; qualified refs in some other cases, so an effort to strip out all - ;; but the branch name is necessary. git symbolic-ref (or - ;; `vc-git--symbolic-ref') won't work; it can't deal with submodules. - (branch (replace-regexp-in-string - "^\\(?:[^/]+/[^/]+/\\)?\\(.+\\)\\(?:~[0-9]+\\)?$" "\\1" - (cdr (sh! "git" "name-rev" "--name-only" "HEAD")))) - (target-remote (format "%s_%s" doom-upgrade-remote branch))) - (unless branch - (error (if (file-exists-p! ".git" doom-emacs-dir) - "Couldn't find Doom's .git directory. Was Doom cloned properly?" - "Couldn't detect what branch you're on. Is Doom detached?"))) - - ;; We assume that a dirty .emacs.d is intentional and abort - (when-let (dirty (doom-upgrade--working-tree-dirty-p default-directory)) - (if (not force-p) - (user-error "%s\n\n%s\n\n %s" - (format "Refusing to upgrade because %S has been modified." - (abbreviate-file-name doom-emacs-dir)) - "Either stash/undo your changes or run 'doom upgrade --force' to discard local changes." - (string-join dirty "\n")) - (print! (item "You have local modifications in Doom's source. Discarding them...")) - (sh! "git" "reset" "--hard" (format "origin/%s" branch)) - (sh! "git" "clean" "-ffd"))) - - (sh! "git" "remote" "remove" doom-upgrade-remote) - (unwind-protect - (let (result) - (or (zerop (car (sh! "git" "remote" "add" doom-upgrade-remote doom-upgrade-url))) - (error "Failed to add %s to remotes" doom-upgrade-remote)) - (or (zerop (car (setq result (sh! "git" "fetch" "--force" "--tags" doom-upgrade-remote (format "%s:%s" branch target-remote))))) - (error "Failed to fetch from upstream")) - - (let ((this-rev (cdr (sh! "git" "rev-parse" "HEAD"))) - (new-rev (cdr (sh! "git" "rev-parse" target-remote)))) - (cond - ((and (null this-rev) - (null new-rev)) - (error "Failed to get revisions for %s" target-remote)) - - ((equal this-rev new-rev) - (print! (success "Doom is already up-to-date!")) - nil) - - ((print! (item "A new version of Doom Emacs is available!\n\n Old revision: %s (%s)\n New revision: %s (%s)\n" - (substring this-rev 0 10) - (cdr (sh! "git" "log" "-1" "--format=%cr" "HEAD")) - (substring new-rev 0 10) - (cdr (sh! "git" "log" "-1" "--format=%cr" target-remote)))) - (let ((diff-url - (format "%s/compare/%s...%s" - doom-upgrade-url - this-rev - new-rev))) - (print! "Link to diff: %s" diff-url) - (when (and (not auto-accept-p) - (y-or-n-p "View the comparison diff in your browser?")) - (print! (item "Opened github in your browser.")) - (browse-url diff-url))) - - (if (not (or auto-accept-p - (y-or-n-p "Proceed with upgrade?"))) - (ignore (print! (error "Aborted"))) - (print! (start "Upgrading Doom Emacs...")) - (print-group! - (doom-compile-clean) - (doom-cli-context-put context 'straight-recipe (doom-upgrade--get-straight-recipe)) - (or (and (zerop (car (sh! "git" "reset" "--hard" target-remote))) - (equal (cdr (sh! "git" "rev-parse" "HEAD")) new-rev)) - (error "Failed to check out %s" (substring new-rev 0 10))))))))) - (ignore-errors - (sh! "git" "branch" "-D" target-remote) - (sh! "git" "remote" "remove" doom-upgrade-remote)))))) - -(defun doom-upgrade--working-tree-dirty-p (dir) - (cl-destructuring-bind (success . stdout) - (doom-call-process "git" "status" "--porcelain" "-uno") - (if (= 0 success) - (split-string stdout "\n" t) - (error "Failed to check working tree in %s" dir)))) - -(defun doom-upgrade--get-straight-recipe () - (with-temp-buffer - (insert-file-contents (doom-path doom-core-dir doom-module-packages-file)) - (when (re-search-forward "(package! straight" nil t) - (goto-char (match-beginning 0)) - (let ((sexp (sexp-at-point))) - (plist-put sexp :recipe - (eval (plist-get sexp :recipe) - t)))))) - -;;; upgrade.el ends here diff --git a/.config/emacs/lisp/doom-cli.el b/.config/emacs/lisp/doom-cli.el @@ -1,2012 +0,0 @@ -;;; lisp/doom-cli.el --- API+DSL for Doom's CLI framework -*- lexical-binding: t; -*- -;;; Commentary: -;; -;; The heart of Doom's CLI framework. This is safe to load in interactive -;; sessions (for API access and syntax highlighting), but much of the API -;; expects a noninteractive session, so take care when testing code! -;; -;;; Code: - -(when noninteractive - ;; PERF: Deferring the GC in non-interactive sessions isn't as important, but - ;; still yields a notable benefit. Still, avoid setting it to high here, as - ;; runaway memory usage is a real risk in longer sessions. - (setq gc-cons-threshold 134217728 ; 128mb - ;; Backported from 29 (see emacs-mirror/emacs@73a384a98698) - gc-cons-percentage 1.0) - - ;; REVIEW: Remove these later. The endpoints should be responsibile for - ;; ensuring they exist. For now, they exist to quell file errors. - (mapc (doom-rpartial #'make-directory 'parents) - (list doom-local-dir - doom-data-dir - doom-cache-dir - doom-state-dir)) - - ;; HACK: Load `cl' and site files manually to prevent polluting logs and - ;; stdout with deprecation and/or file load messages. - (let ((inhibit-message (not init-file-debug))) - (require 'cl nil t) - (unless site-run-file - (let ((site-run-file "site-start") - (tail load-path) - (lispdir (expand-file-name "../lisp" data-directory)) - dir) - (while tail - (setq dir (car tail)) - (let ((default-directory dir)) - (load (expand-file-name "subdirs.el") t inhibit-message t)) - (unless (string-prefix-p lispdir dir) - (let ((default-directory dir)) - (load (expand-file-name "leim-list.el") t inhibit-message t))) - (setq tail (cdr tail))) - (load site-run-file t inhibit-message)))) - - (setq-default - ;; PERF: Don't generate superfluous files when writing temp buffers. - make-backup-files nil - ;; COMPAT: Stop user configuration from interfering with package management. - enable-dir-local-variables nil - ;; PERF: Reduce ambiguity, embrace specificity, enjoy predictability. - case-fold-search nil - ;; UX: Don't clog the user's trash with our CLI refuse. - delete-by-moving-to-trash nil) - - ;; Load just the... bear necessities~ - (require 'seq) - (require 'map) - - ;; Load and set up our debugger first, so backtraces can be made more - ;; presentable and logged to file. - (doom-require 'doom-lib 'debug) - (if init-file-debug (doom-debug-mode +1)) - - ;; Then load the rest of Doom's libs eagerly, since autoloads may not be - ;; generated/loaded yet. - (doom-require 'doom-lib 'process) - (doom-require 'doom-lib 'system) - (doom-require 'doom-lib 'git) - (doom-require 'doom-lib 'plist) - (doom-require 'doom-lib 'files) - (doom-require 'doom-lib 'print) - (doom-require 'doom-lib 'autoloads) - - ;; Ensure straight and core packages are ready to go for CLI commands. - (require 'doom-modules) - (require 'doom-packages) - (require 'doom-profiles) - ;; Last minute initialization at the end of loading this file. - (with-eval-after-load 'doom-cli - (doom-run-hooks 'doom-before-init-hook))) - - -;; -;;; Variables - -(defgroup doom-cli nil - "Doom's command-line interface framework." - :link '(url-link "https://doomemacs.org/cli") - :group 'doom) - -(defvar doom-cli-load-path - (let ((paths (split-string (or (getenv "DOOMPATH") "") path-separator))) - (if (member "" paths) - (cl-substitute (doom-path (dir!) "cli/") "" paths :test #'equal) - paths)) - "A list of paths to search for autoloaded Doom CLIs. - -It is prefilled by the DOOMPATH envvar (a colon-separated list on Linux/macOS, -semicolon otherwise). Empty entries in DOOMPATH are replaced with the -$EMACSDIR/cli/.") - -;;; CLI definition variables -(defvar doom-cli-argument-types - '(&args - &cli - &context - &flags - &multiple - &optional - &rest - &required - &input - &whole) - "A list of auxiliary keywords allowed in `defcli!'s arglist. - -See `defcli!' for documentation on them.") - -(defvar doom-cli-option-types - '((&flag . &flags) - (&multi . &multiple)) - "An alist of auxiliary keywords permitted in option specs in `defcli!'. - -They serve as shorter, inline aliases for `doom-cli-argument-types'. - -See `defcli!' for documentation on them.") - -(defvar doom-cli-option-generators - '((&flags . doom-cli--make-option-flag) - (&multiple . doom-cli--make-option-multi) - (&required . doom-cli--make-option-generic) - (&optional . doom-cli--make-option-generic)) - "An alist of `doom-cli-option' factories for argument types. - -Types that - -See argument types in `doom-cli-argument-types', and `defcli!' for usage.") - -(defvar doom-cli-option-arg-types - `((dir :test file-directory-p - :read expand-file-name - :error "Not a valid path to an existing directory" - :zshcomp "_dirs") - (file :test file-exists-p - :read expand-file-name - :error "Not a valid path to an existing file" - :zshcomp "_files") - (stdout :test ,(lambda (str) (equal str "-")) - :read identity - :error "Not a dash to signal stdout" - :zshcomp "(-)") - (path :read expand-file-name :zshcomp "_files") - (form :read read) - (regexp :test ,(lambda (str) (always (string-match-p str "")))) - (int :test "^[0-9]+$" - :read string-to-number - :error "Not an integer") - (num :test "^[0-9]+\\(\\.[0-9]+\\)?$" - :read string-to-number - :error "Not a valid number or float") - (float :test "^[0-9]+\\(\\.[0-9]+\\)$" - :read string-to-number - :error "Not a float") - (bool :test "^y\\(?:es\\)?\\|no?\\|on\\|off\\|t\\(?:rue\\)?\\|false\\|[01]\\|$" - :read ,(lambda (x) - (pcase x - ((or "y" "yes" "t" "true" "1" "on") :yes) - ((or "n" "no" "nil" "false" "0" "off") :no))) - :error "Not a valid boolean, should be blank or one of: yes, no, y, n, true, false, on, off" - :zshcomp "(y n yes no true false on off 1 0)") - (date :test ,(lambda (str) - (let ((ts (parse-time-string str))) - (and (decoded-time-day ts) - (decoded-time-month ts) - (decoded-time-year ts)))) - :read parse-time-string - :error "Not a valid date (try YYYY-MM-DD or a date produced by `date')") - (time :test ,(lambda (str) - (let ((ts (parse-time-string str))) - (and (decoded-time-hour ts) - (decoded-time-minute ts) - (decoded-time-second ts)))) - :read parse-time-string - :error "Not a valid date (try YYYY-MM-DD or a date produced by `date')") - (duration :test ,(lambda (str) - (not (cl-loop for d in (split-string-and-unquote str " ") - unless (string-match-p "^[0-9]+[hmsdMY]$" d) - return t))) - :read ,(doom-rpartial #'split-string-and-unquote " ") - :error "Not a valid duration (e.g. 5h 20m 40s 2Y 1M)") - (size :test "^[0-9]+[kmgt]?b$" - :read ,(lambda (str) - (save-match-data - (and (string-match "^\\([0-9]+\\(?:\\.[0-9]+\\)\\)\\([kmgt]?b\\)$" str) - (* (string-to-number (match-string 1 str)) - (or (cdr (assoc (match-string 2 str) - '(("kb" . 1000) - ("mb" . 1000000) - ("gb" . 1000000000) - ("tb" . 1000000000000)))) - 1))))) - :error "Not a valid filesize (e.g. 5mb 10.4kb 2gb 1.4tb)")) - "A list of implicit option argument datatypes and their rules. - -Recognizies the following properies: - - :test FN - Predicate function to determine if a value is valid. - :read FN - A transformer that converts the string argument to a desired format. - :error STR - The message to display if a value fails :test.") - -;;; Post-script settings -(defvar doom-cli-exit-commands - '(;; (:editor . doom-cli--exit-editor) - ;; (:emacs . doom-cli--exit-emacs) - (:pager . doom-cli--exit-pager) - (:pager? . doom-cli--exit-pager-maybe) - (:restart . doom-cli--exit-restart)) - "An alist of commands that `doom-cli--exit' recognizes.") - -(defvar doom-cli-pager (getenv "DOOMPAGER") - "The PAGER command to use. - -If nil, falls back to less.") - -(defvar doom-cli-pager-ratio 1.0 - "If output exceeds TTY height times this ratio, the pager is invoked. - -Only applies if (exit! :pager) or (exit! :pager?) are called.") - -;;; Logger settings -(defvar doom-cli-log-file-format (expand-file-name "logs/cli.%s.%s.%s" doom-state-dir) - "Where to write any output/log file to. - -Must have two arguments, one for session id and the other for log type.") - -(defvar doom-cli-log-retain 12 - "Number of each log type to retain.") - -(defvar doom-cli-log-backtrace-depth 12 - "How many frames of the backtrace to display in stdout.") - -(defvar doom-cli-log-straight-error-lines 16 - "How many lines of straight.el errors to display in stdout.") - -(defvar doom-cli-log-benchmark-threshold 5 - "How much execution time (in seconds) before benchmark is shown. - -If set to nil, only display benchmark if a CLI explicitly requested with a -non-nil :benchmark property. -If set to `always', show the benchmark no matter what.") - -;;; Internal variables -(defvar doom-cli--context nil) -(defvar doom-cli--exit-code 255) -(defvar doom-cli--group-plist nil) -(defvar doom-cli--table (make-hash-table :test 'equal)) - - -;; -;;; Custom hooks - -(defcustom doom-cli-create-context-functions () - "A hook executed once a new context has been generated. - -Called by `doom-cli-context-parse' and `doom-cli-context-restore', once a -`doom-cli-context' is fully populated and ready to be executed (but before it -has). - -Hooks are run with one argument: the newly created context." - :type 'hook - :group 'doom-cli) - -(defcustom doom-cli-before-run-functions () - "Hooks run before `run!' executes the command. - -Runs with a single argument: the active context (a `doom-cli-context' struct)." - :type 'hook - :group 'doom-cli) - -(defcustom doom-cli-after-run-functions () - "Hooks run after `run!' has executed the command. - -Runs with two arguments: the active context (a `doom-cli-context' struct) and -the return value of the executed CLI." - :type 'hook - :group 'doom-cli) - - -;; -;;; Errors - -(define-error 'doom-cli-error "There was an unexpected error" 'doom-error) -(define-error 'doom-cli-definition-error "Invalid CLI definition" 'doom-cli-error) -(define-error 'doom-cli-autoload-error "Failed to autoload deferred command" 'doom-cli-error) -(define-error 'doom-cli-invalid-prefix-error "Prefix has no defined commands" 'doom-cli-error) -(define-error 'doom-cli-command-not-found-error "Could not find that command" 'doom-cli-error) -(define-error 'doom-cli-wrong-number-of-arguments-error "Wrong number of CLI arguments" 'doom-cli-error) -(define-error 'doom-cli-unrecognized-option-error "Not a recognized option" 'doom-cli-error) -(define-error 'doom-cli-invalid-option-error "Invalid option value" 'doom-cli-error) - - -;; -;;; `doom-cli' - -(cl-defstruct doom-cli - "An executable CLI command." - (command nil :read-only t) - type - docs - autoload - alias - options - arguments - plist - fn) - -(defun doom-cli-execute (cli bindings) - "Execute CLI with BINDINGS (an alist). - -BINDINGS is an alist of (SYMBOL . VALUE) to bind lexically during CLI's -execution. Can be generated from a `doom-cli-context' with -`doom-cli--bindings'." - (doom-log "execute: %s %s" (doom-cli-key cli) bindings) - (funcall (doom-cli-fn cli) cli bindings)) - -(defun doom-cli-key (cli) - "Return CLI's (type . command), used as a table key or unique identifier." - (let ((command (doom-cli-command cli))) - (if-let (type (doom-cli-type cli)) - (cons type command) - command))) - -(defun doom-cli-command-normalize (command &optional plist) - "Ensure that COMMAND is properly formatted. - -This means that all non-keywords are strings, any prefixes provided by PLIST are -prepended, and the keyword is in front." - (let* ((command (ensure-list command)) - (prefix (plist-get plist :prefix)) - (prefix (if prefix (doom-cli-command-normalize - prefix (append `(:prefix nil) plist)))) - (command (append prefix command)) - (type (cl-find-if #'keywordp (remq :root command) :from-end t)) - (command (seq-subseq - command (or (cl-position :root command :from-end t) - 0)))) - (when (or command prefix) - (cl-loop with map = (fn! (if (or (stringp %) (keywordp %)) % (prin1-to-string %))) - for c in (delq nil (cons type (seq-remove #'keywordp command))) - if (listp c) - collect (mapcar map c) - else collect (funcall map c))))) - -(defun doom-cli-command-string (command) - "Return a joined string representation of normalized COMMAND. - -COMMAND should either be a command list (e.g. '(doom foo bar)) or a `doom-cli' -struct." - (mapconcat (doom-partial #'format "%s") - (doom-cli--command command) - " ")) - -(defun doom-cli-get (command &optional noresolve? noload?) - "Return CLI at COMMAND. - -Will autoload COMMAND if it was deferred with `defcli-autoload!'. - -If NORESOLVE?, don't follow aliases." - (when-let* ((command (doom-cli--command command)) - (cli (gethash command doom-cli--table)) - (cli (if noload? cli (doom-cli-load cli)))) - (if noresolve? - cli - (let (path) - (while (setq path (ignore-errors (doom-cli-alias cli))) - (setq cli (doom-cli-get path t noload?))) - (unless cli - (signal 'doom-cli-command-not-found-error (or path command))) - cli)))) - -(defun doom-cli-path (cli &optional noload?) - "Return a list of `doom-cli's encountered while following CLI's aliases. - -If NOLOAD? is non-nil, don't autoload deferred CLIs (see `doom-cli-get')." - (when cli - (cons - cli (let (alias paths) - (while (setq alias (ignore-errors (doom-cli-alias cli))) - (and (setq cli (doom-cli-get alias t noload?)) - (push cli paths))) - (nreverse paths))))) - -(defun doom-cli-find (command &optional nopartials?) - "Find all CLIs assocated with COMMAND, including partials. - -COMMAND can be a command path (list of strings), a `doom-cli' struct, or a -`doom-cli-context' struct. - -Returned in the order they will execute. Includes pseudo CLIs." - (let* ((command (doom-cli--command command)) - (paths (nreverse (doom-cli--command-expand command t))) - results clis) - (push '(:after) results) - (dolist (path paths) - (push (cons :after path) results)) - (push command results) - (dolist (path (nreverse paths)) - (push (cons :before path) results)) - (push '(:before) results) - (dolist (result results (nreverse clis)) - (when-let ((cli (doom-cli-get result t)) - ((or (not nopartials?) - (doom-cli-type cli)))) - (cl-pushnew cli clis - :test #'equal - :key #'doom-cli-key))))) - -(defun doom-cli-prop (cli prop &optional null-value) - "Returns a PROPerty of CLI's plist, or NULL-VALUE if it doesn't exist." - (let ((plist (doom-cli-plist cli))) - (if (plist-member plist prop) - (plist-get plist prop) - null-value))) - -(cl-defun doom-cli-subcommands (command &optional (depth 9999) &key tree? all? predicate?) - "Return a list of subcommands, DEPTH levels deep, below COMMAND. - - If DEPTH is non-nil, list *all* subcommands, recursively. Otherwise it expects -an integer. - If TREE?, return commands in a tree structure. - If ALL?, include hidden commands (like aliases)." - (when (or (null depth) (> depth 0)) - (catch :predicate - (let* ((command (doom-cli--command command t)) - (prefixlen (length command)) - results) - (dolist (cli (hash-table-values doom-cli--table)) - (let ((clicmd (doom-cli-command cli))) - (when (and (not (doom-cli-type cli)) - (= (length clicmd) (1+ prefixlen)) - (equal command (seq-take clicmd prefixlen)) - (or all? (not (doom-cli-prop cli :hide)))) - (when predicate? - (throw :predicate t)) - (let* ((car (if tree? (car (last clicmd)) clicmd)) - (cdr (doom-cli-subcommands - clicmd (if depth (1- depth)) - :tree? tree? - :all? all?))) - (if tree? - (push (if cdr (cons car cdr) car) results) - (cl-callf nconc results (cons car cdr))))))) - (if tree? - (nreverse results) - results))))) - -(defun doom-cli-aliases (cli) - "Return all known `doom-cli's that are aliased to CLI. - -This cannot see autoloaded CLIs. Use `doom-cli-load' or `doom-cli-load-all' -to reach them." - (cl-loop with cli = (doom-cli-get cli) - with key = (doom-cli-key cli) - for rcli in (hash-table-values doom-cli--table) - if (equal key (doom-cli-key rcli)) - collect cli)) - -(defun doom-cli-short-docs (cli) - "Return the first line of CLI's documentation. - -Return nil if CLI (a `doom-cli') has no explicit documentation." - (ignore-errors (cdr (assoc "SUMMARY" (doom-cli-docs cli))))) - -(defun doom-cli--bindings (cli context &optional seen) - "Return a CLI with a value alist in a cons cell." - (let* ((optspec (doom-cli-options cli)) - (argspec (doom-cli-arguments cli)) - alist) - ;; Ensure all symbols are defined - (dolist (opt optspec) - (setf (alist-get (doom-cli-option-symbol opt) alist) - (doom-cli-option-default opt))) - (dolist (syms argspec) - (dolist (sym (cdr syms)) - (setf (alist-get sym alist) nil))) - ;; Populate options - (let ((options (doom-cli-context-options context))) - (dolist (opt optspec) - (when-let (option (cl-loop for flag in (doom-cli-option-switches opt) - if (cdr (assoc flag options)) - return (cons flag it))) - (unless (member (car option) seen) - (setf (alist-get (doom-cli-option-symbol opt) alist) - (cdr option)) - (push (car option) seen))))) - ;; Populate arguments - (let* ((arglist (doom-cli-context-arguments context)) - (rest (copy-sequence (map-elt arglist (doom-cli-command cli)))) - (args (copy-sequence (alist-get t arglist))) - (argc (length args)) - (required (alist-get '&required argspec)) - (optional (alist-get '&optional argspec)) - (spec (append required optional)) - (min (length required)) - (max (if (or (assq '&args argspec) - (assq '&rest argspec)) - most-positive-fixnum - (length spec)))) - (when (or (< argc min) - (> argc max)) - (signal 'doom-cli-wrong-number-of-arguments-error - (list (doom-cli-key cli) nil args min max))) - (dolist (sym spec) - (setf (alist-get sym alist) (if args (pop args)))) - (dolist (type `((&args . ,args) - (&cli . ,cli) - (&context . ,context) - (&input - . ,(if (doom-cli-context-pipe-p context :in t) - (with-current-buffer (doom-cli-context-stdin context) - (buffer-string)))) - (&rest . ,rest) - (&whole . ,(doom-cli-context-whole context)))) - (when-let (var (car (alist-get (car type) argspec))) - (setf (alist-get var alist) (cdr type))))) - alist)) - -(defun doom-cli--command (target &optional notype?) - "Fetch the normalized command from TARGET. - -If NOTYPE? is non-nil, omit any leading keywords from the command. - -TARGET can be a `doom-cli', `doom-cli-context', or a command list." - (cond ((doom-cli-p target) - (if notype? - (doom-cli-command target) - (doom-cli-key target))) - ((doom-cli-context-p target) - (doom-cli-context-command target)) - ((and target (not (listp target))) - (signal 'wrong-type-argument - (list '(doom-cli-p doom-cli-context-p listp) target))) - ((let ((target (doom-cli-command-normalize target))) - (if (and notype? (keywordp (car target))) - (cdr target) - target))))) - -(defun doom-cli--command-expand (commandspec &optional recursive?) - "Expand COMMANDSPEC into a list of commands. - -If RECURSIVE, includes breadcrumbs leading up to COMMANDSPEC." - (funcall (if recursive? - #'identity - (fn! (cl-loop with cmdlen = (length (car %)) - for command in % - while (= (length command) cmdlen) - collect command))) - (seq-reduce (lambda (init next) - (nconc (cl-loop with firstlen = (length (car init)) - for seg in (ensure-list next) - nconc - (cl-loop for command in init - while (= (length command) firstlen) - collect (append command (list seg)))) - init)) - (cdr commandspec) - `(,@(mapcar #'list (ensure-list (car commandspec))))))) - -(defun doom-cli--parse-docs (docs) - (when (and (stringp docs) - (not (equal docs "TODO"))) - (let ((re "^\\([A-Z0-9 _-]+\\):\n") sections) - (with-temp-buffer - (save-excursion - (insert "__DOOMDOCS__:\n") - (insert docs)) - (while (re-search-forward re nil t) - (push (cons (match-string 1) - (let ((buffer (current-buffer)) - (beg (match-end 0)) - (end (save-excursion - (if (re-search-forward re nil t) - (1- (match-beginning 0)) - (point-max))))) - (with-temp-buffer - (insert-buffer-substring buffer beg end) - (goto-char (point-min)) - (indent-rigidly (point-min) (point-max) (- (skip-chars-forward " "))) - (string-trim-right (buffer-string))))) - sections))) - (let ((lines (split-string (cdr (assoc "__DOOMDOCS__" sections)) "\n")) - (sections (assoc-delete-all "__DOOMDOCS__" sections))) - `(("SUMMARY" . ,(car lines)) - ("MAIN" . ,(string-trim (string-join (cdr lines) "\n"))) - ,@(nreverse sections)))))) - - -;; -;;; `doom-cli-option' - -(cl-defstruct doom-cli-option - "A switch specification dictating the characteristics of a recognized option." - (symbol nil :read-only t) - docs - multiple-p - flag-p - switches - arguments - default) - -(defun doom-cli-option-validate (option &rest values) - "Test if OPTION will accept VALUES, and conforms them if necessary. - -OPTION is a `doom-cli-option' struct. VALUES can be any arbitrary values. -Returns VALUES once mapped through their respective reader (as dictated by -`doom-cli-option-arg-types'). - -Throws `doom-cli-invalid-option-error' for illegal values." - (let ((args (doom-cli-option-arguments option)) - (values (copy-sequence values))) - (dotimes (i (length args) values) - (let ((value (nth i values)) - (types (ensure-list (nth i args))) - errors) - (catch 'done - (dolist (type types) - ;; REVIEW Use pcase-let + map.el when 27.x support is dropped - (cl-destructuring-bind (&key test read error &allow-other-keys) - (if (or (symbolp type) - (and (stringp type) - (string-match-p "^[A-Z0-9-_]+$" type))) - (cdr (assq (if (symbolp type) type (intern (downcase type))) - doom-cli-option-arg-types)) - (list 'str :test #'stringp)) - (condition-case-unless-debug e - (or (and (or (null test) - (if (stringp test) - (and (string-match-p test value) t) - (funcall test value))) - (or (null read) - (setf (nth i values) (funcall read value))) - (throw 'done t)) - (push error errors)) - ((invalid-regexp invalid-read-syntax) - (push (error-message-string e) errors))))) - (signal 'doom-cli-invalid-option-error - (list types option value errors))))))) - -(defun doom-cli--read-option-switches (optspec) - (delq - nil (cl-loop for spec in optspec - if (and (stringp spec) - (string-match-p "^-\\(?:-[a-zA-Z0-9]\\|[^-]$\\)" spec)) - collect spec))) - -(defun doom-cli--read-option-args (argspec) - (delq - nil (cl-loop for spec in argspec - if (or (and (stringp spec) - (not (string-match-p "^-\\(?:-[a-zA-Z0-9]\\|[^-]$\\)" spec))) - (keywordp spec) - (symbolp spec) - (listp spec)) - collect spec))) - -(defun doom-cli--make-option-generic (symbol spec &optional docs) - (make-doom-cli-option - :symbol symbol - :docs docs - :switches (doom-cli--read-option-switches spec) - :arguments (doom-cli--read-option-args spec))) - -(defun doom-cli--make-option-flag (symbol spec &optional docs) - (let ((switches (doom-cli--read-option-switches spec)) - (args (doom-cli--read-option-args spec))) - (when (and args - (not (or (memq :yes args) - (memq :no args)))) - (signal 'doom-cli-definition-error - (list "Argument type %s cannot accept arguments for: %s" - '&flag (mapconcat #'symbol-name spec ", ")))) - (make-doom-cli-option - :symbol symbol - :docs docs - :flag-p t - :switches switches - :default (car args)))) - -(defun doom-cli--make-option-multi (symbol spec &optional docs) - (make-doom-cli-option - :symbol symbol - :docs docs - :multiple-p t - :switches (doom-cli--read-option-switches spec) - :arguments (doom-cli--read-option-args spec))) - - -;; -;;; `doom-cli-context' - -(cl-defstruct doom-cli-context - "A CLI context, containing all state pertinent to the current session." - (init-time before-init-time) ; When this context was created - ;; A session-specific ID of the current context (defaults to number - (pid (if-let (pid (getenv "__DOOMPID")) - (string-to-number pid) - (emacs-pid))) - ;; Number of Emacs processes this context has been processed through - (step (if-let (step (getenv "__DOOMSTEP")) - (string-to-number step) - -1)) - ;; The geometry of the terminal window. - (geometry (save-match-data - (when-let* ((geom (getenv "__DOOMGEOM")) - ((string-match "^\\([0-9]+\\)x\\([0-9]+\\)$" geom))) - (cons (string-to-number (match-string 1 geom)) - (string-to-number (match-string 2 geom)))))) - ;; Whether the script is being piped into or out of - (pipes (cl-loop for (env . scope) in `((,(getenv "__DOOMGPIPE") . global) - (,(getenv "__DOOMPIPE") . local)) - if (stringp env) - for pipes = (string-to-list env) - nconc `(,@(if (memq ?0 pipes) `((:in . ,scope))) - ,@(if (memq ?1 pipes) `((:out . ,scope))))) - :skip t) - ;; If non-nil, suppress prompts and auto-accept their consequences. - suppress-prompts-p - (prefix "@") ; The basename of the script creating this context - meta-p ; Whether or not this is a help/meta request - error ; - (command nil :skip t) ; The full command that led to this context - (path nil :skip t) ; Breadcrumb list of resolved commands so far - (whole nil :skip t) ; Unfiltered and unprocessed list of arguments - (options nil :skip t) ; An alist of (flags . value) - (arguments nil :skip t) ; An alist of non-subcommand arguments, by command - (stdin (generate-new-buffer " *doom-cli stdin*") :type buffer) ; buffer containing anything piped into this session - (stdout (generate-new-buffer " *doom-cli stdout*") :type buffer) ; buffer containing user-visible output - (stderr (generate-new-buffer " *doom-cli stderr*") :type buffer) ; buffer containing all output, including debug output - ;; An alist of persistent and arbitrary elisp state - (state nil :type alist)) - -(defun doom-cli-context-execute (context) - "Execute a given CONTEXT. - -Use `doom-cli-context-parse' or `doom-cli-context-restore' to produce a valid, -executable context." - (let* ((command (doom-cli-context-command context)) - (cli (doom-cli-get command t)) - (prefix (doom-cli-context-prefix context))) - (doom-log "context-execute: %s" - (mapconcat #'doom-cli-command-string - (delq nil (list (car (doom-cli-context-path context)) command)) - " -> ")) - (cond ((null (or command (doom-cli-get (list prefix) t))) - (signal 'doom-cli-invalid-prefix-error (list prefix))) - - ((doom-cli-context-meta-p context) - (pcase (doom-cli-context-meta-p context) - ("--version" - (doom-cli-call `(:version ,@(cdr command)) context) - t) - ((or "-?" "--help") - (doom-cli-call `(:help ,@(cdr command)) context) - t) - (_ (error "In meta mode with no destination!")))) - - ((not (and cli (doom-cli-fn (doom-cli-get cli)))) - (signal 'doom-cli-command-not-found-error - (append command (alist-get t (doom-cli-context-arguments context))))) - - ((let ((seen '(t)) - runners) - (dolist (cli (doom-cli-find command (doom-cli-type cli))) - (push (cons (doom-cli-get cli) - (doom-cli--bindings cli context seen)) - runners)) - (pcase-dolist (`(,cli . ,bindings) (nreverse runners)) - (doom-cli-execute cli bindings)) - context))))) - -(defun doom-cli-context-restore (file context) - "Restore the last restarted context from FILE into CONTEXT." - (when (and (stringp file) - (file-exists-p file)) - (when-let (old-context (with-temp-buffer - (insert-file-contents file) - (read (current-buffer)))) - (unless (doom-cli-context-p old-context) - (error "An invalid context was restored from file: %s" file)) - (unless (equal (doom-cli-context-prefix context) - (doom-cli-context-prefix old-context)) - (error "Restored context belongs to another script: %s" - (doom-cli-context-prefix old-context))) - (pcase-dolist (`(,slot ,_ . ,plist) - (cdr (cl-struct-slot-info 'doom-cli-context))) - (unless (plist-get plist :skip) - (let* ((idx (cl-struct-slot-offset 'doom-cli-context slot)) - (old-value (aref old-context idx))) - (aset context idx - (pcase (plist-get plist :type) - (`alist - (dolist (entry old-value (aref context idx)) - (setf (alist-get (car entry) (aref context idx)) (cdr entry)))) - (`buffer - (with-current-buffer (aref context idx) - (insert old-value) - (current-buffer))) - (_ old-value)))))) - (run-hook-with-args 'doom-cli-create-context-functions context) - (delete-file file) - (doom-log "context-restore: %s" (doom-cli-context-pid context)))) - context) - -(defun doom-cli-context-parse (args context) - "Parse ARGS and update CONTEXT to reflect it." - (let* ((case-fold-search t) - (args (delq nil (copy-sequence args))) - (arguments) - rest? - arg) - (while args - (setq arg (pop args)) - (save-match-data - (cond - ((equal arg "--") - (doom-log "context-parse: found arg separator" arg) - (setq arguments (cdr args) - args nil)) - - ((and (stringp arg) - (string-match "^\\(-\\([^-]\\{2,\\}\\)\\)" arg)) - (let ((chars (split-string (match-string 2 arg) "" t))) - (dolist (ch (nreverse chars)) - (push (concat "-" ch) args)))) - - ((and (stringp arg) - (or (string-match "^\\(--\\w[a-z0-9-_]+\\)\\(?:=\\(.*\\)\\)?$" arg) - (string-match "^\\(-[^-]\\)$" arg))) - (doom-log "context-parse: found switch %S" arg) - (catch :skip - (let* ((fullflag (match-string 1 arg)) - (normflag (if (string-prefix-p "--no-" fullflag) - (concat "--" (substring fullflag 5)) - fullflag)) - (option (or (doom-cli-context-find-option context normflag) - (when (member fullflag '("-?" "--help" "--version")) - (doom-log "context-parse: found help switch %S" arg) - (setf (doom-cli-context-meta-p context) fullflag) - (throw :skip t)) - (when rest? - (push arg arguments) - (throw :skip t)) - (signal 'doom-cli-unrecognized-option-error - (list fullflag)))) - (explicit-arg (match-string 2 arg)) - (arity (length (doom-cli-option-arguments option))) - (key (if (doom-cli-option-multiple-p option) - (car (doom-cli-option-switches option)) - normflag))) - (doom-cli-context-put - context key - (let ((value (seq-take args arity))) - (when explicit-arg - (push explicit-arg value)) - (when (/= (length value) arity) - (signal 'doom-cli-wrong-number-of-arguments-error - (list (doom-cli--command context) - fullflag value arity arity))) - (setq args (seq-drop args arity) - value (apply #'doom-cli-option-validate option value)) - (cond ((doom-cli-option-flag-p option) - (if (string-prefix-p "--no-" fullflag) :no :yes)) - ((doom-cli-option-multiple-p option) - (append (doom-cli-context-get context key) - (if (doom-cli-option-arguments option) - (cl-loop for v in value - collect (cons fullflag v)) - (list fullflag)))) - ((= arity 1) (car value)) - ((> arity 1) value) - (fullflag))))))) - - ((when-let* - (((null arguments)) - ((not rest?)) - (command (append (doom-cli-context-command context) (list arg))) - (cli (doom-cli-get command t)) - (rcli (doom-cli-get command)) - (key (doom-cli-key rcli))) - (doom-log "context-parse: found command %s" command) - ;; Show warnings depending on CLI plists - (when (doom-cli-alias cli) - (dolist (pcli (doom-cli-path cli)) - (doom-log "context-parse: path += %s" (doom-cli-key pcli)) - (push (doom-cli-key pcli) (doom-cli-context-path context)))) - ;; Collect &rest for this command - (setf (doom-cli-context-command context) key - (map-elt (doom-cli-context-arguments context) - (doom-cli-command rcli)) - (copy-sequence args)) - ;; Initialize options associated with this command to a nil value; - ;; this simplifies existence validation later. - (dolist (cli (doom-cli-find key)) - (dolist (option (doom-cli-options cli)) - (dolist (switch (doom-cli-option-switches option)) - (unless (assoc switch (doom-cli-context-options context)) - (setf (map-elt (doom-cli-context-options context) switch) - nil))))) - ;; If this command uses &rest, stop processing commands from this - ;; point on and pass the rest (of the unprocessed arguments) to it. - (when (and (doom-cli-fn rcli) - (alist-get '&rest (doom-cli-arguments rcli))) - (setq rest? t)) - t)) - - ((push arg arguments) - (doom-log "context-parse: found arg %S" arg))))) - - (setf (alist-get t (doom-cli-context-arguments context)) - (append (alist-get t (doom-cli-context-arguments context)) - (nreverse arguments))) - (run-hook-with-args 'doom-cli-create-context-functions context) - context)) - -(defun doom-cli-context-get (context key &optional null-value) - "Fetch KEY from CONTEXT's options or state. - -Context objects are essentially persistent storage, and may contain arbitrary -state tied to switches (\"--foo\" or \"-x\") or arbitrary symbols (state). - -If KEY is a string, fetch KEY from context's OPTIONS (by switch). -If KEY is a symbol, fetch KEY from context's STATE. -Return NULL-VALUE if KEY does not exist." - (if-let (value - (if (stringp key) - (assoc key (doom-cli-context-options context)) - (assq key (doom-cli-context-state context)))) - (cdr value) - null-value)) - -(defun doom-cli-context-put (context key val) - "Set KEY in CONTEXT's options or state to VAL. - -Context objects contain persistent storage, and may contain arbitrary state tied -to switches (\"--foo\" or \"-x\") or arbitrary symbols (state). Use this to -register data into CONTEXT. - -If KEY is a string, set the value of a switch named KEY to VAL. -If KEY is a symbol, set the value of the context's STATE to VAL." - (setf (alist-get - key (if (stringp key) - (doom-cli-context-options context) - (doom-cli-context-state context)) - nil nil #'equal) - val)) - -(defun doom-cli-context-find-option (context switch) - "Return a `doom-cli-option' belonging to SWITCH in CONTEXT, if available. - -Returns nil if SWITCH isn't a valid option in CONTEXT or none of the associated -`doom-cli's have a `doom-cli-option' associated with SWITCH." - (when (assoc switch (doom-cli-context-options context)) - (cl-loop with command = (doom-cli-context-command context) - for cli in (doom-cli-find command) - if (seq-find (lambda (opt) - (let ((switches (doom-cli-option-switches opt))) - (or (member switch switches) - (and (doom-cli-option-flag-p opt) - (string-prefix-p "--no-" switch))))) - (doom-cli-options cli)) - return it))) - -(defun doom-cli-context-width (context) - "Return the width (in character units) of CONTEXT's original terminal." - (or (car (doom-cli-context-geometry context)) - 80)) - -(defun doom-cli-context-height (context) - "Return the height (in character units) of CONTEXT's original terminal." - (or (cdr (doom-cli-context-geometry context)) - 40)) - -(defun doom-cli-context-pipe-p (context type &optional global?) - "Return non-nil if TYPE is an active pipe in the local CONTEXT. - -TYPE can be one of `:in' (receiving input on stdin) or `:out' (output is piped -to another process), or any of `local-in', `local-out', `global-in', or -`global-out'. - -If GLOBAL? is non-nil, if TYPE is `:in' or `:out', the global context (the pipes -active in the super-session, rather than the local Emacs instance) will be -considered as well." - (let ((pipes (doom-cli-context-pipes context))) - (and (if global? - (assq type pipes) - (member (cons type 'local) pipes)) - t))) - -(defun doom-cli-context-sid (context &optional nodate?) - "Return a unique session identifier for CONTEXT." - (if nodate? - (doom-cli-context-pid context) - (format (format-time-string - "%y%m%d%H%M%S.%%s" (doom-cli-context-init-time context)) - (doom-cli-context-pid context)))) - - -;; -;;; Output management - -(defun doom-cli-debugger (type data &optional context) - "Print a more presentable backtrace to terminal and write it to file." - ;; HACK Works around a heuristic in eval.c for detecting errors in the - ;; debugger, which executes this handler again on subsequent calls. Taken - ;; from `ert--run-test-debugger'. - (cl-incf num-nonmacro-input-events) - (let* ((inhibit-read-only nil) - (inhibit-message nil) - (inhibit-redisplay nil) - (inhibit-trace t) - (executing-kbd-macro nil) - (load-read-function #'read) - (backtrace (doom-backtrace)) - (context (or context (make-doom-cli-context))) - (straight-error - (and (bound-and-true-p straight-process-buffer) - (or (member straight-process-buffer data) - (string-match-p (regexp-quote straight-process-buffer) - (error-message-string data))) - (with-current-buffer (straight--process-buffer) - (split-string (buffer-string) "\n" t)))) - (error-file (doom-cli--output-file 'error context))) - (cond - (straight-error - (print! (error "The package manager threw an error")) - (print! (error "Last %d lines of straight's error log:") - doom-cli-log-straight-error-lines) - (print-group! - (print! - "%s" (string-join - (seq-subseq straight-error - (max 0 (- (length straight-error) - doom-cli-log-straight-error-lines)) - (length straight-error)) - "\n"))) - (print! (warn "Wrote extended straight log to %s") - (path (let ((coding-system-for-write 'utf-8-auto)) - (with-temp-file error-file - (insert-buffer-substring (straight--process-buffer))) - (set-file-modes error-file #o600) - error-file)))) - ((eq type 'error) - (let* ((generic? (eq (car data) 'error)) - (doom-cli-log-backtrace-depth doom-cli-log-backtrace-depth) - (print-escape-newlines t)) - (if (doom-cli-context-p context) - (print! (error "There was an unexpected runtime error")) - (print! (bold (error "There was a fatal initialization error")))) - (print-group! - (print! "%s %s" (bold "Message:") - (if generic? - (error-message-string data) - (get (car data) 'error-message))) - (unless generic? - (print! "%s %s" (bold "Details:") - (let* ((print-level 4) - (print-circle t) - (print-escape-newlines t)) - (prin1-to-string (cdr data))))) - (when backtrace - (print! (bold "Backtrace:")) - (print-group! - (dolist (frame (seq-take backtrace doom-cli-log-backtrace-depth)) - (print! "%s" (truncate (prin1-to-string - (cons (backtrace-frame-fun frame) - (backtrace-frame-args frame))) - (- (doom-cli-context-width context) - doom-print-indent - 1) - "...")))) - (when-let (backtrace-file (doom-backtrace-write-to-file backtrace error-file)) - (print! (warn "Wrote extended backtrace to %s") - (path backtrace-file)))))))) - (exit! 255))) - -(defmacro doom-cli-redirect-output (context &rest body) - "Redirect output from BODY to the appropriate log buffers in CONTEXT." - (declare (indent 1)) - (let ((contextsym (make-symbol "doomctxt"))) - `(let* ((,contextsym ,context) - ;; Emit more user-friendly backtraces - (debugger (doom-rpartial #'doom-cli-debugger ,contextsym)) - (debug-on-error t)) - (with-output-to! `((>= notice ,(doom-cli-context-stdout ,contextsym)) - (t . ,(doom-cli-context-stderr ,contextsym))) - ,@body)))) - -(defun doom-cli--output-file (type context) - "Return a log file path for TYPE and CONTEXT. - -See `doom-cli-log-file-format' for details." - (format doom-cli-log-file-format - (doom-cli-context-prefix context) - (doom-cli-context-sid context) - type)) - -(defun doom-cli--output-write-logs-h (context) - "Write all log buffers to their appropriate files." - (when (/= doom-cli--exit-code 254) - ;; Delete the last `doom-cli-log-retain' logs - (mapc #'delete-file - (let ((prefix (doom-cli-context-prefix context))) - (append (butlast (doom-glob (format doom-cli-log-file-format prefix "*" "log")) - doom-cli-log-retain) - (butlast (doom-glob (format doom-cli-log-file-format prefix "*" "error")) - doom-cli-log-retain)))) - ;; Then write the log file, if necessary - (let* ((buffer (doom-cli-context-stderr context)) - (file (doom-cli--output-file "log" context))) - (when (> (buffer-size buffer) 0) - (make-directory (file-name-directory file) t) - (with-temp-file file - (insert-buffer-substring buffer) - (ansi-color-filter-region (point-min) (point-max))) - (set-file-modes file #o600))))) - -(defun doom-cli--output-benchmark-h (context) - "Write this session's benchmark to stdout or stderr, depending. - -Will also output it to stdout if requested (CLI sets :benchmark to t) or the -command takes >5s to run. If :benchmark is explicitly set to nil (or -`doom-cli-log-benchmark-threshold' is nil), under no condition should a -benchmark be shown." - (doom-cli-redirect-output context - (doom-log "%s (GCs: %d, elapsed: %.6fs)" - (if (= doom-cli--exit-code 254) "Restarted" "Finished") - gcs-done gc-elapsed) - (when-let* ((init-time (doom-cli-context-init-time context)) - (cli (doom-cli-get context)) - (duration (float-time (time-subtract (current-time) init-time))) - (hours (/ (truncate duration) 60 60)) - (minutes (- (/ (truncate duration) 60) (* hours 60))) - (seconds (- duration (* hours 60 60) (* minutes 60)))) - (when (and (/= doom-cli--exit-code 254) - (or (eq (doom-cli-prop cli :benchmark) t) - (eq doom-cli-log-benchmark-threshold 'always) - (and (eq (doom-cli-prop cli :benchmark :null) :null) - (not (doom-cli-context-pipe-p context 'out t)) - (> duration (or doom-cli-log-benchmark-threshold - most-positive-fixnum))))) - (print! (success "Finished in %s") - (join (list (unless (zerop hours) (format "%dh" hours)) - (unless (zerop minutes) (format "%dm" minutes)) - (format (if (> duration 60) "%ds" "%.5fs") - seconds)))))))) - - -;; -;;; Session management - -(defun doom-cli-call (args context &optional error) - "Process ARGS (list of string shell arguments) with CONTEXT as the basis. - -If ERROR is provided, store the error in CONTEXT, in case a later CLI wants to -read/use it (e.g. like a :help CLI)." - (let ((oldcommand (doom-cli-context-command context))) - (if oldcommand - (doom-log "call: %s -> %s" oldcommand args) - (doom-log "call: %s" oldcommand args)) - (when error - (setf (doom-cli-context-error context) error)) - (setf (doom-cli-context-command context) nil - (doom-cli-context-arguments context) nil - (doom-cli-context-meta-p context) nil) - (doom-cli-context-execute - (doom-cli-context-parse args (or context doom-cli--context))))) - -(defun doom-cli--restart (args context) - "Restart the current CLI session. - -If CONTEXT is non-nil, this is written to file and restored in the next Doom -session. - -This is done by writing a temporary shell script, which is executed after this -session ends (see the shebang lines of this file). It's done this way because -Emacs' batch library lacks an implementation of the exec system call." - (cl-check-type context doom-cli-context) - (when (= (doom-cli-context-step context) -1) - (error "__DOOMSTEP envvar missing; extended `exit!' functionality will not work")) - (let* ((pid (doom-cli-context-pid context)) - (step (doom-cli-context-step context)) - (context-file (format (doom-path temporary-file-directory "doom.%s.%s.context") pid step)) - (script-file (format (doom-path temporary-file-directory "doom.%s.%s.sh") pid step)) - (command (if (listp args) (combine-and-quote-strings (remq nil args)) args)) - (persistent-files - (combine-and-quote-strings (delq nil (list script-file context-file)))) - (persisted-env - (save-match-data - (cl-loop with initial-env = (get 'process-environment 'initial-value) - for env in (seq-difference process-environment initial-env) - if (string-match "^\\([a-zA-Z0-9_][^=]+\\)=\\(.+\\)$" env) - collect (format "%s=%s" - (match-string 1 env) - (shell-quote-argument (match-string 2 env))))))) - (cl-incf (doom-cli-context-step context)) - (with-file-modes #o600 - (doom-log "restart: writing context to %s" context-file) - (doom-file-write - context-file (let ((newcontext (copy-doom-cli-context context)) - (print-level nil) - (print-length nil) - (print-circle nil) - (print-escape-newlines t)) - ;; REVIEW: Use `print-unreadable-function' when 28 support - ;; is dropped. - (letf! (defmacro convert-buffer (fn) - `(setf (,fn newcontext) (with-current-buffer (,fn context) - (buffer-string)))) - (convert-buffer doom-cli-context-stdin) - (convert-buffer doom-cli-context-stdout) - (convert-buffer doom-cli-context-stderr)) - newcontext)) - (doom-log "restart: writing post-script to %s" script-file) - (doom-file-write - script-file `("#!/usr/bin/env sh\n" - "trap _doomcleanup EXIT\n" - "_doomcleanup() {\n rm -f " ,persistent-files "\n}\n" - "_doomrun() {\n " ,command "\n}\n" - ,(string-join persisted-env " \\\n") - ,(cl-loop for (envvar . val) - in `(("DOOMPROFILE" . ,(ignore-errors (doom-profile->id doom-profile))) - ("EMACSDIR" . ,doom-emacs-dir) - ("DOOMDIR" . ,doom-user-dir) - ("DEBUG" . ,(if init-file-debug "1")) - ("__DOOMSTEP" . ,(number-to-string (doom-cli-context-step context))) - ("__DOOMCONTEXT" . ,context-file)) - if val - concat (format "%s=%s \\\n" envvar (shell-quote-argument val))) - ,(format "PATH=\"%s%s$PATH\" \\\n" - (doom-path doom-emacs-dir "bin") - path-separator) - "_doomrun \"$@\"\n"))) - (doom-log "_doomrun: %s %s" (string-join persisted-env " ") command) - (doom-log "_doomcleanup: %s" persistent-files) - ;; Error code 254 is special: it indicates to the caller that the - ;; post-script should be executed after this session ends. It's up to - ;; `doom-cli-run's caller to enforce this (see bin/doom's shebang for a - ;; comprehensive example). - (doom-cli--exit 254 context))) - -(defun doom-cli--exit (args context) - "Accepts one of the following: - - (CONTEXT [ARGS...]) - TODO - (STRING [ARGS...]) - TODO - (:restart [ARGS...]) - TODO - (:pager [FILE...]) - TODO - (:pager? [FILE...]) - TODO - (INT) - TODO" - (let ((command (or (car-safe args) args)) - (args (if (car-safe args) (cdr-safe args)))) - (pcase command - ;; If an integer, treat it as an exit code. - ((pred (integerp)) - (setq doom-cli--exit-code command) - (kill-emacs command)) - - ;; Otherwise, run a command verbatim. - ((pred (stringp)) - (doom-cli--restart (format "%s %s" command (combine-and-quote-strings args)) - context)) - - ;; Same with buffers. - ((pred (bufferp)) - (doom-cli--restart (with-current-buffer command (buffer-string)) - context)) - - ;; If a context is given, restart the current session with the new context. - ((pred (doom-cli-context-p)) - (doom-cli--exit-restart args command)) - - ;; Run a custom action, defined in `doom-cli-exit-commands'. - ((pred (keywordp)) - (if-let (fn (alist-get command doom-cli-exit-commands)) - (funcall fn args context) - (error "Invalid exit command: %s" command))) - - ;; Any other value is invalid. - (_ (error "Invalid exit code or command: %s" command))))) - -(defun doom-cli--exit-restart (args context) - "Restart the session, verbatim (persisting CONTEXT). - -ARGS are addiitonal arguments to pass to the sub-process (in addition to the -ones passed to this one). It may contain :omit -- all arguments after this will -be removed from the argument list. They may specify number of arguments in the -format: - - --foo=4 omits --foo plus four following arguments - --foo=1 omits --foo plus one following argument - --foo= equivalent to --foo=1 - --foo=* omits --foo plus all following arguments - -Arguments don't have to be switches either." - (let ((pred (fn! (not (keywordp %)))) - (args (append (doom-cli-context-whole context) - (flatten-list args)))) - (let ((argv (seq-take-while pred args)) - (omit (mapcar (fn! (seq-let (arg n) (split-string % "=") - (cons - arg (cond ((not (stringp n)) 0) - ((string-empty-p n) 1) - ((equal n "*") -1) - ((string-to-number n)))))) - (seq-take-while pred (cdr (memq :omit args))))) - newargs) - (when omit - (while argv - (let ((arg (pop argv))) - (if-let (n (cdr (assoc arg omit))) - (if (= n -1) - (setq argv nil) - (dotimes (i n) (pop argv))) - (push arg newargs))))) - (doom-cli--exit (cons "$1" (or (nreverse newargs) argv)) - context)))) - -(defun doom-cli--exit-pager (args context) - "Invoke pager on output unconditionally. - -ARGS are options passed to less. If DOOMPAGER is set, ARGS are ignored." - (let ((pager (or doom-cli-pager (getenv "DOOMPAGER")))) - (cond ((null (or pager (executable-find "less"))) - (user-error "No pager set or available") - (doom-cli--exit 1 context)) - - ((or (doom-cli-context-pipe-p context :out t) - (equal pager "")) - (doom-cli--exit 0 context)) - - ((let ((tmpfile (doom-cli--output-file 'output context)) - (coding-system-for-write 'utf-8-auto)) - (make-directory (file-name-directory tmpfile) t) - (with-temp-file tmpfile - (insert-buffer-substring (doom-cli-context-stdout context))) - (set-file-modes tmpfile #o600) - (doom-cli--restart - (format "%s <%s; rm -f%s %s" - (or pager - (format "less %s" - (combine-and-quote-strings - (append (if doom-print-backend '("-r")) ; process ANSI codes - (or (delq nil args) '("+g")))))) - (shell-quote-argument tmpfile) - (if init-file-debug "v" "") - (shell-quote-argument tmpfile)) - context)))))) - -(defun doom-cli--exit-pager-maybe (args context) - "Invoke pager if stdout is longer than TTY height * `doom-cli-pager-ratio'. - -ARGS are options passed to less. If DOOMPAGER is set, ARGS are ignored." - (doom-cli--exit - (let ((threshold (ceiling (* (doom-cli-context-height context) - doom-cli-pager-ratio)))) - (if (>= (let ((stdout (doom-cli-context-stdout context))) - (if (fboundp 'buffer-line-statistics) - (car (buffer-line-statistics stdout)) - (with-current-buffer stdout - (count-lines (point-min) (point-max))))) - threshold) - (cons :pager args) - 0)) - context)) - -;; (defun doom-cli--exit-editor (args context)) ; TODO Launch $EDITOR - -;; (defun doom-cli--exit-emacs (args context)) ; TODO Launch Emacs subsession - - - -;; -;;; Migration paths - -;; (defvar doom-cli-context-restore-functions -;; '(doom-cli-context--restore-legacy-fn) -;; "A list of functions intended to unserialize `doom-cli-context'. - -;; They all take one argument, the raw data saved to $__DOOMCONTEXT. Each function -;; must return the version string corresponding to the version of Doom they have -;; transformed it for.") - -;; (defun doom-cli-context-restore (file context) -;; "Restore the last restarted context from FILE into CONTEXT." -;; (when (and (stringp file) -;; (file-exists-p file)) -;; (when-let* ((data (with-temp-buffer -;; (insert-file-contents file) -;; (read (current-buffer)))) -;; (version (if (stringp (car data)) (car data) "0")) -;; (old-context (if (string (car data)) (cdr data) data)) -;; (new-context (make-doom-cli-context)) -;; (struct-info (cl-loop for (slot _initval . plist) in (cdr (cl-struct-slot-info 'doom-cli-context)) -;; collect (cons (cl-struct-slot-offset 'doom-cli-context slot) -;; (cons slot plist))))) - -;; ;; (let ((version (if (stringp (car data)) (car data) "0")) -;; ;; (data (if (string (car data)) (cdr data) data)) -;; ;; (newcontext (make-doom-cli-context))) -;; ;; (dolist (fn doom-cli-context-restore-functions) -;; ;; (setq newcontext (funcall fn newcontext data version)))) - -;; (unless (doom-cli-context-p old-context) -;; (error "An invalid context was restored from file: %s" file)) -;; (unless (equal (doom-cli-context-prefix context) -;; (doom-cli-context-prefix old-context)) -;; (error "Restored context belongs to another script: %s" -;; (doom-cli-context-prefix old-context))) -;; (pcase-dolist (`(,slot ,_ . ,plist) -;; (cdr (cl-struct-slot-info 'doom-cli-context))) -;; (unless (plist-get plist :skip) -;; (let* ((idx (cl-struct-slot-offset 'doom-cli-context slot)) -;; (old-value (aref old-context idx))) -;; (aset context idx -;; (pcase (plist-get plist :type) -;; (`alist -;; (dolist (entry old-value (aref context idx)) -;; (setf (alist-get (car entry) (aref context idx)) (cdr entry)))) -;; (`buffer -;; (with-current-buffer (aref context idx) -;; (insert old-value) -;; (current-buffer))) -;; (_ old-value)))))) -;; (run-hook-with-args 'doom-cli-create-context-functions context) -;; (delete-file file) -;; (doom-log "Restored context: %s" (doom-cli-context-pid context)) -;; context))) - -;; (defun doom-cli-context--restore-legacy-fn (data old-version) -;; "Update `doom-cli-context' from <3.0.0 to 3.0.0." -;; (when (or (equal old-version "3.0.0-dev") -;; (string-match-p "^2\\.0\\." old-version)) - -;; "3.0.0")) - -;; (defun doom-cli-context--restore-3.1.0-fn (data old-version)) - - -;; -;;; Misc - -(defun doom-cli-load (cli) - "If CLI is autoloaded, load it, otherwise return it unchanged." - (or (when-let* ((path (doom-cli-autoload cli)) - (path (locate-file-internal path doom-cli-load-path load-suffixes))) - (doom-log "load: autoload %s" path) - (let ((doom-cli--group-plist (doom-cli-plist cli))) - (doom-load path)) - (let* ((key (doom-cli-key cli)) - (cli (gethash key doom-cli--table))) - (when (doom-cli-autoload cli) - (signal 'doom-cli-autoload-error (list (doom-cli-command cli) path))) - cli)) - cli)) - -(defun doom-cli-load-all () - "Immediately load all autoloaded CLIs." - (dolist (key (hash-table-keys doom-cli--table)) - (doom-cli-load (gethash key doom-cli--table)))) - - -;; -;;; DSL - -(defmacro defcli! (commandspec arglist &rest body) - "Defines a CLI command. - -COMMANDSPEC is the specification for the command that will trigger this CLI. It -can either be a symbol or list of symbols (or nested symbols). Nested lists are -treated as a list of aliases for the command. For example: - - (defcli! doom () ...) ; invoked on 'doom' - (defcli! (doom foo) () ...) ; invoked on 'doom foo' - (defcli! (doom (foo bar)) () ...) ; invoked on 'doom foo' or 'doom bar' - -COMMANDSPEC may be prefixed with any of these special keywords: - - :root ... - This command will ignore any :prefix set by a parent `defcli-group!'. - :before ... - This command will run before the specified command(s). - :after ... - This command will run after the specified command(s). - :version - A special handler, executed when 'X --version' is called. Define your own, - if you don't want it spewing Doom's version information. - :help COMMAND... - A special handler, executed when help documentation is requested for a - command. E.g. 'doom help foo' or 'doom foo --help' will call (:help foo). - You can define your own global :help handler, or one for a specific command. - :dump COMMAND... - A special handler, executed when the __DOOMDUMP environment variable is set. - You can define one for a specific COMMAND, or omit it to redefine the - catch-all :dump handler. - - The default implementation (living in lisp/doom-cli.el) will either: - - a) Dump to stdout a list of `doom-cli' structs for the commands and pseudo - commands that would've been executed had __DOOMDUMP not been set. - b) Or, given only \"-\" as an argument, dump all of `doom-cli--table' to - stdout. This table contains all known `doom-cli's (after loading - autoloaded ones). - -To interpolate values into COMMANDSPEC (e.g. to dynamically generate commands), -use the comma operator: - - (let ((somevar 'bfg)) - (defcli! (doom ,somevar) ...)) - -DOCSTRING is a string description; its first line should be a short summary -(under 60 characters) of what the command does. It will be used in the cramped -command listings served by help commands. The rest of DOCSTRING lines should be -no longer than 80 columns, and should go into greater detail. This documentation -may use `quoting' to appropriately highlight ARGUMENTS, --options, or $ENVVARS. - -DOCSTRING may also contain sections denoted by a capitalized header ending with -a colon and newline, and its contents indented by 2 spaces. These will be -appended to the end of the help documentation for that command. These three -sections are special: - - ARGUMENTS: - Use this to specify longer-form documentation for arguments. They are - prepended to the documentation for commands. If pseudo CLIs specify their - own ARGUMENTS sections, they are joined with that of the root command's CLI - as well. E.g. ':before doom sync's ARGUMENTS will be prepended to 'doom - sync's. - OPTIONS: - Use this to specify longer-form documentation for options. They are appended - to the auto-generated section of the same name. Only the option needs to be - specified for its lookup behavior to work. See bin/doom's `doom' command as - an example. - EXAMPLES: - To list example uses of the containing script. These are appended to - SYNOPSIS in generated manpages, but treated as a normal section otherwise - (i.e. appended to 'doom help's output). - -DOCSTRING may use any of these format specifications: - - %p The running script's prefix. E.g. for 'doom ci deploy-hooks' the - prefix is 'doom'. - %c The parent command minus the prefix. E.g. for 'doom ci deploy-hooks', - the command is 'ci deploy-hooks'. - -ARGLIST is a specification for options and arguments that is accepted by this -command. Arguments are represented by either a symbol or a cons cell where -(SYMBOL . DOCUMENTATION), and option specifications are lists in the following -formats: - - ([TYPE] VAR (FLAGSPEC... [ARGSPEC...]) [DESCRIPTION]) - - TYPE - Optional. One of &flag or &multi (which correspond to &flags and &multiple, - respectively, and are used for specifying a type inline, if desired). - VAR - Is the symbol to bind that option's value to. - FLAGSPEC - A list of switches or sub-lists thereof. Each switch is a string, e.g. - \"--foo\" \"-b\" \"--baz\". - - Nested lists will be treated as logical groups of switches in documentation. - E.g. for - - With (\"--foo\" \"--bar\" [ARGSPEC...]) you get: - - --foo, --bar - [Documentation] - - With ((\"--foo\") (\"--bar\") [ARGSPEC...]) you get: - - --foo - --bar - [Documentation] - - Use this to logically group options that have many, but semantically - distinct switches. - ARGSPEC - A list of arguments or sub-lists thereof. Each argument is either a string - or symbol. - - If a string, they are used verbatim as the argument's documentation. Use - this to document more complex specifications, like \"[user@]host[:port]\". - Use reference `quotes' to highlight arguments appropriately. No input - validation is performed on these arguments. - - If a symbol, this is equivalent to (upcase (format \"`%s'\" SYMBOL)), but - its arguments will also be implicitly validated against - `doom-cli-option-arg-types'. - - A nested list indicates that an argument accepts multiple types, and are - implicitly joined into \"`ARG1'|`ARG2'|...\". Input validation is performed - on symbols only. - - WARNING: If this option is a &flag, the option must not accept arguments. - Instead, use ARGSPEC to specify a single, default value (one of `:yes' or - `:no'). - DESCRIPTION - A one-line description of the option. Use reference `quotes' to - appropriately highlight arguments, options, and envvars. A syntax exists for - adding long-form option documentation from the CLI's docstring. See - DOCSTRING above. - -ARGLIST may be segmented with the following auxiliary keywords: - - &args ARG - The rest of the literal arguments are stored in ARG. - &cli ARG - The called `doom-cli' struct is bound to ARG. - &context ARG - The active `doom-cli-context' struct is bound to ARG. - &flags OPTION... - An option '--foo' declared after &flags will implicitly include a - '--no-foo', and will appear as \"--[no-]foo\" in 'doom help' docs. - &multiple OPTION... - Options specified after &multiple may be passed to the command multiple - times. Its symbol will be bound to a list of cons cells containing (FLAG . - VALUE). - &optional ARG... - Indicates that the (literal) arguments after it are optional. - &input ARG - ARG will be bound to the input piped in from stdin, as a string, or nil if - unavailable. If you want access to the original buffer, use - (doom-cli-context-stdin context) instead. - &rest ARG - All switches and arguments, unprocessed, after this command. If given, any - unrecognized switches will not throw an error. This will also prevent - subcommands beneath this command from being recognized. Use with care! - - Any non-option arguments before &optional, &rest, or &args are required. - -BODY is a list of arbitrary elisp forms that will be executed when this command -is called. BODY may begin with a plist to set metadata about it. The recognized -properties: - - :alias (CMD...) - Designates this command is an alias to CMD, which is a command specification - identical to COMMANDSPEC. - :benchmark BOOL - If non-nil, display a benchmark after the command finishes. - :disable BOOL - If non-nil, the command will not be defined. - :docs STRING - An alternative to DOCSTRING for defining documentation for this command. - :group (STR...) - A breadcrumb of group names to file this command under. They will be - organized by category in the CLI documentation (available through SCRIPT - {--help,-?,help}). - :hide BOOL - If non-nil, don't display this command in the help menu or in {ba,z}sh - completion (though it will still be callable). - :partial BOOL - If non-nil, this command is treated as partial, an intermediary command - intended as a stepping stone toward a non-partial command. E.g. were you to - define (doom foo bar), two \"partial\" commands are implicitly created: - \"doom\" and \"doom foo\". When called directly, partials will list its - subcommands and complain that a subcommand is rqeuired, rather than display - an 'unknown command' error. - :prefix (STR...) - A command path to prepend to the command name. This is more useful as part - of `defcli-group!'s inheritance. - -The BODY of commands with a non-nil :alias, :disable, or :partial will be -ignored. - -\(fn COMMANDSPEC ARGLIST [DOCSTRING] &rest BODY...)" - (declare (indent 2) (doc-string 3)) - (let ((docstring (if (stringp (car body)) (pop body))) - (plist (cl-loop for (key val) on body by #'cddr - while (keywordp key) - collect (pop body) - collect (pop body))) - options arguments bindings) - (let ((type '&required)) - (dolist (arg arglist) - (cond ((listp arg) - (let* ((inline-type (cdr (assq (car arg) doom-cli-option-types))) - (type (or inline-type type)) - (args (if inline-type (cdr arg) arg))) - (push (apply (or (alist-get type doom-cli-option-generators) - (signal 'doom-cli-definition-error - (cons "Invalid option type" type))) - args) - options) - (push (car args) bindings))) - ((memq arg doom-cli-argument-types) - (setq type arg)) - ((string-prefix-p "&" (symbol-name arg)) - (signal 'doom-cli-definition-error (cons "Invalid argument specifier" arg))) - ((push arg bindings) - (push arg (alist-get type arguments)))))) - (dolist (arg arguments) - (setcdr arg (nreverse (cdr arg)))) - `(let (;; Define function early to prevent overcapturing - (fn ,(let ((clisym (make-symbol "cli")) - (alistsym (make-symbol "alist"))) - `(lambda (,clisym ,alistsym) - (let ,(cl-loop for arg in (nreverse bindings) - unless (string-prefix-p "_" (symbol-name arg)) - collect `(,arg (cdr (assq ',arg ,alistsym)))) - ,@body))))) - ;; `cl-destructuring-bind's will validate keywords, so I don't have to - (cl-destructuring-bind - (&whole plist &key - alias autoload _benchmark docs disable hide _group partial - _prefix) - (append (list ,@plist) doom-cli--group-plist) - (unless disable - (let* ((command (doom-cli-command-normalize (backquote ,commandspec) plist)) - (type (if (keywordp (car command)) (pop command))) - (commands (doom-cli--command-expand command t)) - (target (pop commands))) - (dolist (prop '(:autoload :alias :partial :hide)) - (cl-remf plist prop)) - (puthash (delq nil (cons type target)) - (make-doom-cli - :command target - :type type - :docs (doom-cli--parse-docs (or ',docstring docs)) - :arguments ',arguments - :options ',(nreverse options) - :autoload autoload - :alias (if alias (doom-cli-command-normalize alias plist)) - :plist (append plist (list :hide (and (or hide type) t))) - :fn (unless (or partial autoload) fn)) - doom-cli--table) - (let ((docs (doom-cli--parse-docs docs))) - (dolist (alias (cl-loop for c in commands - while (= (length c) (length target)) - collect (pop commands))) - (puthash (delq nil (cons type alias)) - (make-doom-cli - :command alias - :type type - :docs docs - :autoload autoload - :alias (unless autoload (delq nil (cons type target))) - :plist (append plist '(:hide t))) - doom-cli--table)) - (dolist (partial commands) - (let ((cli (gethash partial doom-cli--table))) - (when (or (null cli) (doom-cli-autoload cli)) - (puthash (delq nil (cons type partial)) - (make-doom-cli - :command partial - :type type - :docs docs - :plist (list :group (plist-get plist :group))) - doom-cli--table))))) - target)))))) - -(defmacro defcli-alias! (commandspec target &rest plist) - "Define a CLI alias for TARGET at COMMANDSPEC. - -See `defcli!' for information about COMMANDSPEC. -TARGET is not a command specification, and should be a command list." - `(defcli! ,commandspec () :alias ',target ,@plist)) - -(defmacro defcli-obsolete! (commandspec target when) - "Define an obsolete CLI COMMANDSPEC that refers users to NEW-COMMAND. - -See `defcli!' for information about COMMANDSPEC. -TARGET is simply a command list. -WHEN specifies what version this command was rendered obsolete." - `(let ((ncommand (doom-cli-command-normalize (backquote ,target) doom-cli--group-plist))) - (defcli! ,commandspec (&context context &cli cli &rest args) - :docs (format "An obsolete alias for '%s'." (doom-cli-command-string ncommand)) - :hide t - (print! (warn "'%s' was deprecated in %s") - (doom-cli-command-string cli) - ,when) - (print! (warn "It will eventually be removed; use '%s' instead.") - (doom-cli-command-string ncommand)) - (call! ',target args)))) - -(defmacro defcli-stub! (commandspec &optional _argspec &rest body) - "Define a stub CLI, which will throw an error if invoked. - -Use this to define commands that will eventually be implemented, but haven't -yet. They won't be included in command listings (by help documentation)." - (declare (indent 2) (doc-string 3)) - `(defcli! ,commandspec (&rest _) - ,(concat "THIS COMMAND IS A STUB AND HAS NOT BEEN IMPLEMENTED YET." - (if (stringp (car body)) (concat "\n\n" (pop body)))) - :hide t - (user-error "Command not implemented yet"))) - -(defmacro defcli-autoload! (commandspec &optional path &rest plist) - "Defer loading of PATHS until PREFIX is called." - `(let* ((doom-cli--group-plist (append (list ,@plist) doom-cli--group-plist)) - (commandspec (doom-cli-command-normalize ',commandspec)) - (commands (doom-cli--command-expand commandspec)) - (path (or ,path - (when-let* ((cmd (car commands)) - (last (car (last cmd))) - (last (if (listp last) (car last) last))) - (format "%s" last)) - (error "Failed to deduce autoload path for: %s" spec))) - (cli (doom-cli-get (car commands) nil t))) - (when (or (null cli) - (doom-cli-autoload cli)) - (defcli! ,commandspec () :autoload path)))) - -(defmacro defcli-group! (&rest body) - "Declare common properties for any CLI commands defined in BODY." - (when (stringp (car body)) - (push :group body)) - `(let ((doom-cli--group-plist (copy-sequence doom-cli--group-plist))) - ,@(let (forms) - (while (keywordp (car body)) - (let ((key (pop body)) - (val (pop body))) - (push `(cl-callf plist-put doom-cli--group-plist - ,key ,(if (eq key :prefix) - `(append (plist-get doom-cli--group-plist ,key) - (ensure-list ,val)) - val)) - forms))) - (nreverse forms)) - ,@body)) - -(defun exit! (&rest args) - "Exits the current CLI session. - -With ARGS, you may specify a shell command or action (see -`doom-cli-exit-commands') to execute after this Emacs process has ended. For -example: - - (exit! \"$@\") or (exit! :restart) - This reruns the current command with the same arguments. - (exit! \"$@ -h -c\") - This reruns the current command with two new switches. - (exit! :restart \"-c\" :omit \"--foo=2\" \"--bar\") - This reruns the current command with one new switch (-c) and two switches - removed (--foo plus two arguments and --bar). - (exit! \"emacs -nw FILE\") - Opens Emacs on FILE - (exit! \"emacs\" \"-nw\" \"FILE\") - Opens Emacs on FILE, but each argument is escaped (and nils are ignored). - (exit! t) or (exit! nil) - A safe way to simply abort back to the shell with exit code 0 - (exit! 42) - Abort to shell with an explicit exit code. - (exit! context) - Restarts the current session, but with context (a `doom-cli-context' struct). - (exit! :pager [FILES...]) - Invoke $DOOMPAGER (or less) on the output of this session. If ARGS are given, launch the pager on those - (exit! :pager? [FILES...]) - Same as :pager, but does so only if output is longer than the terminal is - tall. - -See `doom-cli--restart' for implementation details." - (doom-cli--exit (flatten-list args) doom-cli--context)) - -(defun call! (&rest command) - "A convenience wrapper around `doom-cli-call'. - -Implicitly resolves COMMAND relative to the running CLI, and uses the active -context (so you don't have to pass a context)." - (doom-cli-call (doom-cli-command-normalize - (flatten-list command) - `(:prefix - ,(doom-cli-context-prefix doom-cli--context) - ,@(doom-cli-context-command doom-cli--context))) - doom-cli--context)) - -(defun run! (prefix &rest args) - "Parse and execute ARGS. - -This is the entry point for any shell script that rely on Doom's CLI framework. -It should be called once, at top-level, and never again (use `doom-cli-call' for -nested calls instead). - -PREFIX is the name (string) of the top-level shell script (i.e. $0). All -commands that belong to this shell session should use PREFIX as the first -segment in their command paths. - -ARGS is a list of string arguments to execute. - -See bin/doom's shebang for an example of what state needs to be initialized for -Doom's CLI framework. In a nutshell, Doom is expecting the following environment -variables to be set: - - __DOOMGEOM The dimensions of the current terminal (W . H) - __DOOMPIPE Must contain 0 if script is being piped into, 1 if piping it out - __DOOMGPIPE Like __DOOMPIPE, but is the pipe state of the super process - __DOOMPID A unique ID for this session and its exit script processes - __DOOMSTEP How many layers deep this session has gotten - -The script should also execute ${temporary-file-directory}/doom.sh if Emacs -exits with code 254. This script is auto-generated as needed, to simulate exec -syscalls. See `doom-cli--restart' for technical details. - -Once done, this function kills Emacs gracefully and writes output to log files -(stdout to `doom-cli--output-file', stderr to `doom-cli-debug-file', and any -errors to `doom-cli-error-file')." - (when doom-cli--context - (error "Cannot nest `run!' calls")) - (doom-run-hooks 'doom-after-init-hook) - (doom-context-with 'cli - (let* ((args (flatten-list args)) - (context (make-doom-cli-context :prefix prefix :whole args)) - (doom-cli--context context) - (write-logs-fn (doom-partial #'doom-cli--output-write-logs-h context)) - (show-benchmark-fn (doom-partial #'doom-cli--output-benchmark-h context))) - ;; Clone output to stdout/stderr buffers for logging. - (doom-cli-redirect-output context - (doom-log "run!: %s %s" prefix (combine-and-quote-strings args)) - (add-hook 'kill-emacs-hook show-benchmark-fn 94) - (add-hook 'kill-emacs-hook write-logs-fn 95) - (when (doom-cli-context-pipe-p context :out t) - (setq doom-print-backend nil)) - (when (doom-cli-context-pipe-p context :in) - (with-current-buffer (doom-cli-context-stdin context) - (while (if-let (in (ignore-errors (read-from-minibuffer ""))) - (insert in "\n") - (ignore-errors (delete-char -1)))))) - (doom-cli--exit - (condition-case e - (let* ((args (cons (if (getenv "__DOOMDUMP") :dump prefix) args)) - (context (doom-cli-context-restore (getenv "__DOOMCONTEXT") context)) - (context (doom-cli-context-parse args context))) - (run-hook-with-args 'doom-cli-before-run-functions context) - (let ((result (doom-cli-context-execute context))) - (run-hook-with-args 'doom-cli-after-run-functions context result)) - 0) - (doom-cli-wrong-number-of-arguments-error - (pcase-let ((`(,command ,flag ,args ,min ,max) (cdr e))) - (print! (red "Error: %S expected %s argument%s, but got %d") - (or flag (doom-cli-command-string - (if (keywordp (car command)) - command - (cdr command)))) - (if (or (= min max) - (= max most-positive-fixnum)) - min - (format "%d-%d" min max)) - (if (or (= min 0) (> min 1)) "s" "") - (length args)) - (doom-cli-call `(:help "--synopsis" "--postamble" ,@(cdr (doom-cli--command context))) context e)) - 5) - (doom-cli-unrecognized-option-error - (print! (red "Error: unknown option %s") (cadr e)) - (doom-cli-call `(:help "--synopsis" "--postamble" ,@(cdr (doom-cli--command context))) context e) - 5) - (doom-cli-invalid-option-error - (pcase-let ((`(,types ,option ,value ,errors) (cdr e))) - (print! (red "Error: %s received invalid value %S") - (string-join (doom-cli-option-switches option) "/") - value) - (print! (bold "\nValidation errors:")) - (dolist (err errors) (print! (item "%s." (fill err))))) - (doom-cli-call `(:help "--postamble" ,@(cdr (doom-cli--command context))) context e) - 5) - (doom-cli-command-not-found-error - (let* ((command (cdr e)) - (cli (doom-cli-get command))) - (cond ((null cli) - (print! (red "Error: unrecognized command '%s'") - (doom-cli-command-string (or (cdr command) command))) - (doom-cli-call `(:help "--similar" "--postamble" ,@(cdr command)) context e)) - ((null (doom-cli-fn cli)) - (print! (red "Error: a subcommand is required")) - (doom-cli-call `(:help "--subcommands" "--postamble" ,@(cdr command)) context e)))) - 4) - (doom-cli-invalid-prefix-error - (let ((prefix (cadr e))) - (print! (red "Error: `run!' called with invalid prefix %S") prefix) - (if-let (suggested (cl-loop for cli being the hash-value of doom-cli--table - unless (doom-cli-type cli) - return (car (doom-cli-command cli)))) - (print! "Did you mean %S?" suggested) - (print! "There are no commands defined under %S." prefix))) - 4) - (user-error - (print! (red "Error: %s") (cadr e)) - (print! "\nAborting...") - 3)) - context))))) - -(defalias 'sh! #'doom-call-process) - -(defalias 'sh!! #'doom-exec-process) - -;; TODO Make `git!' into a more sophisticated wrapper around git -(defalias 'git! (doom-partial #'straight--process-run "git")) - - - -;; -;;; Predefined CLIs - -(load! "cli/meta") ; :help, :version, and :dump - -(provide 'doom-cli) -;;; doom-cli.el ends here diff --git a/.config/emacs/lisp/doom-editor.el b/.config/emacs/lisp/doom-editor.el @@ -1,732 +0,0 @@ -;;; doom-editor.el --- defaults for text editing in Doom -*- lexical-binding: t; -*- -;;; Commentary: -;;; Code: - -(defvar doom-detect-indentation-excluded-modes - '(fundamental-mode pascal-mode so-long-mode doom-docs-org-mode) - "A list of major modes in which indentation should be automatically -detected.") - -(defvar-local doom-inhibit-indent-detection nil - "A buffer-local flag that indicates whether `dtrt-indent' should try to detect -indentation settings or not. This should be set by editorconfig if it -successfully sets indent_style/indent_size.") - -(defvar doom-inhibit-large-file-detection nil - "If non-nil, inhibit large/long file detection when opening files.") - -(defvar doom-large-file-p nil) -(put 'doom-large-file-p 'permanent-local t) - -(defvar doom-large-file-size-alist '(("." . 1.0)) - "An alist mapping regexps (like `auto-mode-alist') to filesize thresholds. - -If a file is opened and discovered to be larger than the threshold, Doom -performs emergency optimizations to prevent Emacs from hanging, crashing or -becoming unusably slow. - -These thresholds are in MB, and is used by `doom--optimize-for-large-files-a'.") - -(defvar doom-large-file-excluded-modes - '(so-long-mode special-mode archive-mode tar-mode jka-compr - git-commit-mode image-mode doc-view-mode doc-view-mode-maybe - ebrowse-tree-mode pdf-view-mode tags-table-mode) - "Major modes that `doom-check-large-file-h' will ignore.") - - -;; -;;; File handling - -(defadvice! doom--prepare-for-large-files-a (size _ filename &rest _) - "Sets `doom-large-file-p' if the file is considered large. - -Uses `doom-large-file-size-alist' to determine when a file is too large. When -`doom-large-file-p' is set, other plugins can detect this and reduce their -runtime costs (or disable themselves) to ensure the buffer is as fast as -possible." - :before #'abort-if-file-too-large - (and (numberp size) - (null doom-inhibit-large-file-detection) - (ignore-errors - (> size - (* 1024 1024 - (assoc-default filename doom-large-file-size-alist - #'string-match-p)))) - (setq-local doom-large-file-p size))) - -(add-hook! 'find-file-hook - (defun doom-optimize-for-large-files-h () - "Trigger `so-long-minor-mode' if the file is large." - (when (and doom-large-file-p buffer-file-name) - (if (or doom-inhibit-large-file-detection - (memq major-mode doom-large-file-excluded-modes)) - (kill-local-variable 'doom-large-file-p) - (when (fboundp 'so-long-minor-mode) ; in case the user disabled it - (so-long-minor-mode +1)) - (message "Large file detected! Cutting a few corners to improve performance..."))))) - - -;; Resolve symlinks when opening files, so that any operations are conducted -;; from the file's true directory (like `find-file'). -(setq find-file-visit-truename t - vc-follow-symlinks t) - -;; Disable the warning "X and Y are the same file". It's fine to ignore this -;; warning as it will redirect you to the existing buffer anyway. -(setq find-file-suppress-same-file-warnings t) - -;; Create missing directories when we open a file that doesn't exist under a -;; directory tree that may not exist. -(add-hook! 'find-file-not-found-functions - (defun doom-create-missing-directories-h () - "Automatically create missing directories when creating new files." - (unless (file-remote-p buffer-file-name) - (let ((parent-directory (file-name-directory buffer-file-name))) - (and (not (file-directory-p parent-directory)) - (y-or-n-p (format "Directory `%s' does not exist! Create it?" - parent-directory)) - (progn (make-directory parent-directory 'parents) - t)))))) - -;; Don't generate backups or lockfiles. While auto-save maintains a copy so long -;; as a buffer is unsaved, backups create copies once, when the file is first -;; written, and never again until it is killed and reopened. This is better -;; suited to version control, and I don't want world-readable copies of -;; potentially sensitive material floating around our filesystem. -(setq create-lockfiles nil - make-backup-files nil - ;; But in case the user does enable it, some sensible defaults: - version-control t ; number each backup file - backup-by-copying t ; instead of renaming current file (clobbers links) - delete-old-versions t ; clean up after itself - kept-old-versions 5 - kept-new-versions 5 - backup-directory-alist (list (cons "." (concat doom-cache-dir "backup/"))) - tramp-backup-directory-alist backup-directory-alist) - -;; But turn on auto-save, so we have a fallback in case of crashes or lost data. -;; Use `recover-file' or `recover-session' to recover them. -(setq auto-save-default t - ;; Don't auto-disable auto-save after deleting big chunks. This defeats - ;; the purpose of a failsafe. This adds the risk of losing the data we - ;; just deleted, but I believe that's VCS's jurisdiction, not ours. - auto-save-include-big-deletions t - ;; Keep it out of `doom-emacs-dir' or the local directory. - auto-save-list-file-prefix (concat doom-cache-dir "autosave/") - tramp-auto-save-directory (concat doom-cache-dir "tramp-autosave/") - auto-save-file-name-transforms - (list (list "\\`/[^/]*:\\([^/]*/\\)*\\([^/]*\\)\\'" - ;; Prefix tramp autosaves to prevent conflicts with local ones - (concat auto-save-list-file-prefix "tramp-\\2") t) - (list ".*" auto-save-list-file-prefix t))) - -(add-hook! 'after-save-hook - (defun doom-guess-mode-h () - "Guess major mode when saving a file in `fundamental-mode'. - -Likely, something has changed since the buffer was opened. e.g. A shebang line -or file path may exist now." - (when (eq major-mode 'fundamental-mode) - (let ((buffer (or (buffer-base-buffer) (current-buffer)))) - (and (buffer-file-name buffer) - (eq buffer (window-buffer (selected-window))) ; only visible buffers - (set-auto-mode)))))) - -(defadvice! doom--shut-up-autosave-a (fn &rest args) - "If a file has autosaved data, `after-find-file' will pause for 1 second to -tell you about it. Very annoying. This prevents that." - :around #'after-find-file - (letf! ((#'sit-for #'ignore)) - (apply fn args))) - -;; HACK Emacs generates long file paths for its auto-save files; long = -;; `auto-save-list-file-prefix' + `buffer-file-name'. If too long, the -;; filesystem will murder your family. To appease it, I compress -;; `buffer-file-name' to a stable 40 characters. -;; TODO PR this upstream; should be a universal issue! -(defadvice! doom-make-hashed-auto-save-file-name-a (fn) - "Compress the auto-save file name so paths don't get too long." - :around #'make-auto-save-file-name - (let ((buffer-file-name - (if (or - ;; Don't do anything for non-file-visiting buffers. Names - ;; generated for those are short enough already. - (null buffer-file-name) - ;; If an alternate handler exists for this path, bow out. Most of - ;; them end up calling `make-auto-save-file-name' again anyway, so - ;; we still achieve this advice's ultimate goal. - (find-file-name-handler buffer-file-name - 'make-auto-save-file-name)) - buffer-file-name - (sha1 buffer-file-name)))) - (funcall fn))) - -;; HACK ...does the same for Emacs backup files, but also packages that use -;; `make-backup-file-name-1' directly (like undo-tree). -(defadvice! doom-make-hashed-backup-file-name-a (fn file) - "A few places use the backup file name so paths don't get too long." - :around #'make-backup-file-name-1 - (let ((alist backup-directory-alist) - backup-directory) - (while alist - (let ((elt (car alist))) - (if (string-match (car elt) file) - (setq backup-directory (cdr elt) - alist nil) - (setq alist (cdr alist))))) - (let ((file (funcall fn file))) - (if (or (null backup-directory) - (not (file-name-absolute-p backup-directory))) - file - (expand-file-name (sha1 (file-name-nondirectory file)) - (file-name-directory file)))))) - - -;; -;;; Formatting - -;; Favor spaces over tabs. Pls dun h8, but I think spaces (and 4 of them) is a -;; more consistent default than 8-space tabs. It can be changed on a per-mode -;; basis anyway (and is, where tabs are the canonical style, like go-mode). -(setq-default indent-tabs-mode nil - tab-width 4) - -;; Only indent the line when at BOL or in a line's indentation. Anywhere else, -;; insert literal indentation. -(setq-default tab-always-indent nil) - -;; Make `tabify' and `untabify' only affect indentation. Not tabs/spaces in the -;; middle of a line. -(setq tabify-regexp "^\t* [ \t]+") - -;; An archaic default in the age of widescreen 4k displays? I disagree. We still -;; frequently split our terminals and editor frames, or have them side-by-side, -;; using up more of that newly available horizontal real-estate. -(setq-default fill-column 80) - -;; Continue wrapped words at whitespace, rather than in the middle of a word. -(setq-default word-wrap t) -;; ...but don't do any wrapping by default. It's expensive. Enable -;; `visual-line-mode' if you want soft line-wrapping. `auto-fill-mode' for hard -;; line-wrapping. -(setq-default truncate-lines t) -;; If enabled (and `truncate-lines' was disabled), soft wrapping no longer -;; occurs when that window is less than `truncate-partial-width-windows' -;; characters wide. We don't need this, and it's extra work for Emacs otherwise, -;; so off it goes. -(setq truncate-partial-width-windows nil) - -;; This was a widespread practice in the days of typewriters. I actually prefer -;; it when writing prose with monospace fonts, but it is obsolete otherwise. -(setq sentence-end-double-space nil) - -;; The POSIX standard defines a line is "a sequence of zero or more non-newline -;; characters followed by a terminating newline", so files should end in a -;; newline. Windows doesn't respect this (because it's Windows), but we should, -;; since programmers' tools tend to be POSIX compliant (and no big deal if not). -(setq require-final-newline t) - -;; Default to soft line-wrapping in text modes. It is more sensibile for text -;; modes, even if hard wrapping is more performant. -(add-hook 'text-mode-hook #'visual-line-mode) - - -;; -;;; Clipboard / kill-ring - -;; Cull duplicates in the kill ring to reduce bloat and make the kill ring -;; easier to peruse (with `counsel-yank-pop' or `helm-show-kill-ring'. -(setq kill-do-not-save-duplicates t) - - -;; -;;; Extra file extensions to support - -(nconc - auto-mode-alist - '(("/LICENSE\\'" . text-mode) - ("\\.log\\'" . text-mode) - ("rc\\'" . conf-mode) - ("\\.\\(?:hex\\|nes\\)\\'" . hexl-mode))) - - -;; -;;; Built-in plugins - -(use-package! autorevert - ;; revert buffers when their files/state have changed - :hook (focus-in . doom-auto-revert-buffers-h) - :hook (after-save . doom-auto-revert-buffers-h) - :hook (doom-switch-buffer . doom-auto-revert-buffer-h) - :hook (doom-switch-window . doom-auto-revert-buffer-h) - :config - (setq auto-revert-verbose t ; let us know when it happens - auto-revert-use-notify nil - auto-revert-stop-on-user-input nil - ;; Only prompts for confirmation when buffer is unsaved. - revert-without-query (list ".")) - - ;; `auto-revert-mode' and `global-auto-revert-mode' would, normally, abuse the - ;; heck out of file watchers _or_ aggressively poll your buffer list every X - ;; seconds. Too many watchers can grind Emacs to a halt if you preform - ;; expensive or batch processes on files outside of Emacs (e.g. their mtime - ;; changes), and polling your buffer list is terribly inefficient as your - ;; buffer list grows into the hundreds. - ;; - ;; Doom does this lazily instead. i.e. All visible buffers are reverted - ;; immediately when a) a file is saved or b) Emacs is refocused (after using - ;; another app). Meanwhile, buried buffers are reverted only when they are - ;; switched to. This way, Emacs only ever has to operate on, at minimum, a - ;; single buffer and, at maximum, ~10 buffers (after all, when do you ever - ;; have more than 10 windows in any single frame?). - (defun doom-auto-revert-buffer-h () - "Auto revert current buffer, if necessary." - (unless (or auto-revert-mode (active-minibuffer-window)) - (let ((auto-revert-mode t)) - (auto-revert-handler)))) - - (defun doom-auto-revert-buffers-h () - "Auto revert stale buffers in visible windows, if necessary." - (dolist (buf (doom-visible-buffers)) - (with-current-buffer buf - (doom-auto-revert-buffer-h))))) - - -;;;###package bookmark -(setq bookmark-default-file (concat doom-data-dir "bookmarks")) - - -(use-package! recentf - ;; Keep track of recently opened files - :defer-incrementally easymenu tree-widget timer - :hook (doom-first-file . recentf-mode) - :commands recentf-open-files - :custom (recentf-save-file (concat doom-cache-dir "recentf")) - :config - (setq recentf-auto-cleanup nil ; Don't. We'll auto-cleanup on shutdown - recentf-max-saved-items 200) ; default is 20 - - (defun doom--recentf-file-truename-fn (file) - (if (or (not (file-remote-p file)) - (equal "sudo" (file-remote-p file 'method))) - (abbreviate-file-name (file-truename (tramp-file-name-localname file))) - file)) - - ;; REVIEW: Use this in lieu of `doom--recentf-file-truename-fn' when we drop - ;; 28 support. See emacs-mirror/emacs@32906819addd. - ;; (setq recentf-show-abbreviated t) - - ;; Anything in runtime folders - (add-to-list 'recentf-exclude - (concat "^" (regexp-quote (or (getenv "XDG_RUNTIME_DIR") - "/run")))) - - ;; Resolve symlinks, strip out the /sudo:X@ prefix in local tramp paths, and - ;; abbreviate $HOME -> ~ in filepaths (more portable, more readable, & saves - ;; space) - (add-to-list 'recentf-filename-handlers #'doom--recentf-file-truename-fn) - - ;; Text properties inflate the size of recentf's files, and there is - ;; no purpose in persisting them (Must be first in the list!) - (add-to-list 'recentf-filename-handlers #'substring-no-properties) - - (add-hook! '(doom-switch-window-hook write-file-functions) - (defun doom--recentf-touch-buffer-h () - "Bump file in recent file list when it is switched or written to." - (when buffer-file-name - (recentf-add-file buffer-file-name)) - ;; Return nil for `write-file-functions' - nil)) - - (add-hook! 'dired-mode-hook - (defun doom--recentf-add-dired-directory-h () - "Add dired directories to recentf file list." - (recentf-add-file default-directory))) - - ;; The most sensible time to clean up your recent files list is when you quit - ;; Emacs (unless this is a long-running daemon session). - (setq recentf-auto-cleanup (if (daemonp) 300)) - (add-hook 'kill-emacs-hook #'recentf-cleanup) - - ;; Otherwise `load-file' calls in `recentf-load-list' pollute *Messages* - (advice-add #'recentf-load-list :around #'doom-shut-up-a)) - - -(use-package! savehist - ;; persist variables across sessions - :defer-incrementally custom - :hook (doom-first-input . savehist-mode) - :custom (savehist-file (concat doom-cache-dir "savehist")) - :config - (setq savehist-save-minibuffer-history t - savehist-autosave-interval nil ; save on kill only - savehist-additional-variables - '(kill-ring ; persist clipboard - register-alist ; persist macros - mark-ring global-mark-ring ; persist marks - search-ring regexp-search-ring)) ; persist searches - (add-hook! 'savehist-save-hook - (defun doom-savehist-unpropertize-variables-h () - "Remove text properties from `kill-ring' to reduce savehist cache size." - (setq kill-ring - (mapcar #'substring-no-properties - (cl-remove-if-not #'stringp kill-ring)) - register-alist - (cl-loop for (reg . item) in register-alist - if (stringp item) - collect (cons reg (substring-no-properties item)) - else collect (cons reg item)))) - (defun doom-savehist-remove-unprintable-registers-h () - "Remove unwriteable registers (e.g. containing window configurations). -Otherwise, `savehist' would discard `register-alist' entirely if we don't omit -the unwritable tidbits." - ;; Save new value in the temp buffer savehist is running - ;; `savehist-save-hook' in. We don't want to actually remove the - ;; unserializable registers in the current session! - (setq-local register-alist - (cl-remove-if-not #'savehist-printable register-alist))))) - - -(use-package! saveplace - ;; persistent point location in buffers - :hook (doom-first-file . save-place-mode) - :custom (save-place-file (concat doom-cache-dir "saveplace")) - :config - (defadvice! doom--recenter-on-load-saveplace-a (&rest _) - "Recenter on cursor when loading a saved place." - :after-while #'save-place-find-file-hook - (if buffer-file-name (ignore-errors (recenter)))) - - (defadvice! doom--inhibit-saveplace-in-long-files-a (fn &rest args) - :around #'save-place-to-alist - (unless doom-large-file-p - (apply fn args))) - - (defadvice! doom--dont-prettify-saveplace-cache-a (fn) - "`save-place-alist-to-file' uses `pp' to prettify the contents of its cache. -`pp' can be expensive for longer lists, and there's no reason to prettify cache -files, so this replace calls to `pp' with the much faster `prin1'." - :around #'save-place-alist-to-file - (letf! ((#'pp #'prin1)) (funcall fn)))) - - -(use-package! server - :when (display-graphic-p) - :after-call doom-first-input-hook doom-first-file-hook focus-out-hook - :defer 1 - :config - (when-let (name (getenv "EMACS_SERVER_NAME")) - (setq server-name name)) - (unless (server-running-p) - (server-start))) - - -(after! tramp - (setq remote-file-name-inhibit-cache 60 - tramp-completion-reread-directory-timeout 60 - tramp-verbose 1 - vc-ignore-dir-regexp (format "%s\\|%s\\|%s" - vc-ignore-dir-regexp - tramp-file-name-regexp - "[/\\\\]node_modules"))) - - -;; -;;; Packages - -(use-package! better-jumper - :hook (doom-first-input . better-jumper-mode) - :commands doom-set-jump-a doom-set-jump-maybe-a doom-set-jump-h - :preface - ;; REVIEW Suppress byte-compiler warning spawning a *Compile-Log* buffer at - ;; startup. This can be removed once gilbertw1/better-jumper#2 is merged. - (defvar better-jumper-local-mode nil) - :init - (global-set-key [remap evil-jump-forward] #'better-jumper-jump-forward) - (global-set-key [remap evil-jump-backward] #'better-jumper-jump-backward) - (global-set-key [remap xref-pop-marker-stack] #'better-jumper-jump-backward) - (global-set-key [remap xref-go-back] #'better-jumper-jump-backward) - (global-set-key [remap xref-go-forward] #'better-jumper-jump-forward) - :config - (defun doom-set-jump-a (fn &rest args) - "Set a jump point and ensure fn doesn't set any new jump points." - (better-jumper-set-jump (if (markerp (car args)) (car args))) - (let ((evil--jumps-jumping t) - (better-jumper--jumping t)) - (apply fn args))) - - (defun doom-set-jump-maybe-a (fn &rest args) - "Set a jump point if fn actually moves the point." - (let ((origin (point-marker)) - (result - (let* ((evil--jumps-jumping t) - (better-jumper--jumping t)) - (apply fn args))) - (dest (point-marker))) - (unless (equal origin dest) - (with-current-buffer (marker-buffer origin) - (better-jumper-set-jump - (if (markerp (car args)) - (car args) - origin)))) - (set-marker origin nil) - (set-marker dest nil) - result)) - - (defun doom-set-jump-h () - "Run `better-jumper-set-jump' but return nil, for short-circuiting hooks." - (better-jumper-set-jump) - nil) - - ;; Creates a jump point before killing a buffer. This allows you to undo - ;; killing a buffer easily (only works with file buffers though; it's not - ;; possible to resurrect special buffers). - ;; - ;; I'm not advising `kill-buffer' because I only want this to affect - ;; interactively killed buffers. - (advice-add #'kill-current-buffer :around #'doom-set-jump-a) - - ;; Create a jump point before jumping with imenu. - (advice-add #'imenu :around #'doom-set-jump-a)) - - -(use-package! dtrt-indent - ;; Automatic detection of indent settings - :unless noninteractive - ;; I'm not using `global-dtrt-indent-mode' because it has hard-coded and rigid - ;; major mode checks, so I implement it in `doom-detect-indentation-h'. - :hook ((change-major-mode-after-body read-only-mode) . doom-detect-indentation-h) - :config - (defun doom-detect-indentation-h () - (unless (or (not after-init-time) - doom-inhibit-indent-detection - doom-large-file-p - (memq major-mode doom-detect-indentation-excluded-modes) - (member (substring (buffer-name) 0 1) '(" " "*"))) - ;; Don't display messages in the echo area, but still log them - (let ((inhibit-message (not init-file-debug))) - (dtrt-indent-mode +1)))) - - ;; Enable dtrt-indent even in smie modes so that it can update `tab-width', - ;; `standard-indent' and `evil-shift-width' there as well. - (setq dtrt-indent-run-after-smie t) - ;; Reduced from the default of 5000 for slightly faster analysis - (setq dtrt-indent-max-lines 2000) - - ;; always keep tab-width up-to-date - (push '(t tab-width) dtrt-indent-hook-generic-mapping-list) - - (defvar dtrt-indent-run-after-smie) - (defadvice! doom--fix-broken-smie-modes-a (fn &optional arg) - "Some smie modes throw errors when trying to guess their indentation, like -`nim-mode'. This prevents them from leaving Emacs in a broken state." - :around #'dtrt-indent-mode - (let ((dtrt-indent-run-after-smie dtrt-indent-run-after-smie)) - (letf! ((defun symbol-config--guess (beg end) - (funcall symbol-config--guess beg (min end 10000))) - (defun smie-config-guess () - (condition-case e (funcall smie-config-guess) - (error (setq dtrt-indent-run-after-smie t) - (message "[WARNING] Indent detection: %s" - (error-message-string e)) - (message ""))))) ; warn silently - (funcall fn arg))))) - -(use-package! helpful - ;; a better *help* buffer - :commands helpful--read-symbol - :hook (helpful-mode . visual-line-mode) - :init - ;; Make `apropos' et co search more extensively. They're more useful this way. - (setq apropos-do-all t) - - (global-set-key [remap describe-function] #'helpful-callable) - (global-set-key [remap describe-command] #'helpful-command) - (global-set-key [remap describe-variable] #'helpful-variable) - (global-set-key [remap describe-key] #'helpful-key) - (global-set-key [remap describe-symbol] #'helpful-symbol) - - (defun doom-use-helpful-a (fn &rest args) - "Force FN to use helpful instead of the old describe-* commands." - (letf! ((#'describe-function #'helpful-function) - (#'describe-variable #'helpful-variable)) - (apply fn args))) - - (after! apropos - ;; patch apropos buttons to call helpful instead of help - (dolist (fun-bt '(apropos-function apropos-macro apropos-command)) - (button-type-put - fun-bt 'action - (lambda (button) - (helpful-callable (button-get button 'apropos-symbol))))) - (dolist (var-bt '(apropos-variable apropos-user-option)) - (button-type-put - var-bt 'action - (lambda (button) - (helpful-variable (button-get button 'apropos-symbol)))))) - - (when (> emacs-major-version 28) - ;; REVIEW This should be reported upstream to Emacs. - (defadvice! doom--find-function-search-for-symbol-save-excursion-a (fn &rest args) - "Suppress cursor movement by `find-function-search-for-symbol'. - -Addresses an unwanted side-effect in `find-function-search-for-symbol' on Emacs -29 where the cursor is moved to a variable's definition if it's defined in the -current buffer." - :around #'find-function-search-for-symbol - (let (buf pos) - (letf! (defun find-library-name (library) - (let ((filename (funcall find-library-name library))) - (with-current-buffer (find-file-noselect filename) - (setq buf (current-buffer) - pos (point))) - filename)) - (prog1 (apply fn args) - (when (buffer-live-p buf) - (with-current-buffer buf (goto-char pos))))))))) - - -;;;###package imenu -(add-hook 'imenu-after-jump-hook #'recenter) - - -(use-package! smartparens - ;; Auto-close delimiters and blocks as you type. It's more powerful than that, - ;; but that is all Doom uses it for. - :hook (doom-first-buffer . smartparens-global-mode) - :commands sp-pair sp-local-pair sp-with-modes sp-point-in-comment sp-point-in-string - :config - (add-to-list 'doom-point-in-string-functions 'sp-point-in-string) - (add-to-list 'doom-point-in-comment-functions 'sp-point-in-comment) - ;; smartparens recognizes `slime-mrepl-mode', but not `sly-mrepl-mode', so... - (add-to-list 'sp-lisp-modes 'sly-mrepl-mode) - ;; Load default smartparens rules for various languages - (require 'smartparens-config) - ;; Overlays are too distracting and not terribly helpful. show-parens does - ;; this for us already (and is faster), so... - (setq sp-highlight-pair-overlay nil - sp-highlight-wrap-overlay nil - sp-highlight-wrap-tag-overlay nil) - (with-eval-after-load 'evil - ;; But if someone does want overlays enabled, evil users will be stricken - ;; with an off-by-one issue where smartparens assumes you're outside the - ;; pair when you're really at the last character in insert mode. We must - ;; correct this vile injustice. - (setq sp-show-pair-from-inside t) - ;; ...and stay highlighted until we've truly escaped the pair! - (setq sp-cancel-autoskip-on-backward-movement nil) - ;; Smartparens conditional binds a key to C-g when sp overlays are active - ;; (even if they're invisible). This disruptively changes the behavior of - ;; C-g in insert mode, requiring two presses of the key to exit insert mode. - ;; I don't see the point of this keybind, so... - (setq sp-pair-overlay-keymap (make-sparse-keymap))) - - ;; The default is 100, because smartparen's scans are relatively expensive - ;; (especially with large pair lists for some modes), we reduce it, as a - ;; better compromise between performance and accuracy. - (setq sp-max-prefix-length 25) - ;; No pair has any business being longer than 4 characters; if they must, set - ;; it buffer-locally. It's less work for smartparens. - (setq sp-max-pair-length 4) - - ;; Silence some harmless but annoying echo-area spam - (dolist (key '(:unmatched-expression :no-matching-tag)) - (setf (alist-get key sp-message-alist) nil)) - - (add-hook! 'eval-expression-minibuffer-setup-hook - (defun doom-init-smartparens-in-eval-expression-h () - "Enable `smartparens-mode' in the minibuffer for `eval-expression'. -This includes everything that calls `read--expression', e.g. -`edebug-eval-expression' Only enable it if -`smartparens-global-mode' is on." - (when smartparens-global-mode (smartparens-mode +1)))) - (add-hook! 'minibuffer-setup-hook - (defun doom-init-smartparens-in-minibuffer-maybe-h () - "Enable `smartparens' for non-`eval-expression' commands. -Only enable `smartparens-mode' if `smartparens-global-mode' is -on." - (when (and smartparens-global-mode (memq this-command '(evil-ex))) - (smartparens-mode +1)))) - - ;; You're likely writing lisp in the minibuffer, therefore, disable these - ;; quote pairs, which lisps doesn't use for strings: - (sp-local-pair '(minibuffer-mode minibuffer-inactive-mode) "'" nil :actions nil) - (sp-local-pair '(minibuffer-mode minibuffer-inactive-mode) "`" nil :actions nil) - - ;; Smartparens breaks evil-mode's replace state - (defvar doom-buffer-smartparens-mode nil) - (add-hook! 'evil-replace-state-exit-hook - (defun doom-enable-smartparens-mode-maybe-h () - (when doom-buffer-smartparens-mode - (turn-on-smartparens-mode) - (kill-local-variable 'doom-buffer-smartparens-mode)))) - (add-hook! 'evil-replace-state-entry-hook - (defun doom-disable-smartparens-mode-maybe-h () - (when smartparens-mode - (setq-local doom-buffer-smartparens-mode t) - (turn-off-smartparens-mode))))) - - -(use-package! so-long - :hook (doom-first-file . global-so-long-mode) - :config - ;; Emacs 29 introduced faster long-line detection, so they can afford a much - ;; larger `so-long-threshold' and its default `so-long-predicate'. - (if (fboundp 'buffer-line-statistics) - (unless (featurep 'native-compile) - (setq so-long-threshold 5000)) - ;; reduce false positives w/ larger threshold - (setq so-long-threshold 400) - - (defun doom-buffer-has-long-lines-p () - (unless (bound-and-true-p visual-line-mode) - (let ((so-long-skip-leading-comments - ;; HACK Fix #2183: `so-long-detected-long-line-p' calls - ;; `comment-forward' which tries to use comment syntax, which - ;; throws an error if comment state isn't initialized, leading - ;; to a wrong-type-argument: stringp error. - ;; DEPRECATED Fixed in Emacs 28. - (bound-and-true-p comment-use-syntax))) - (so-long-detected-long-line-p)))) - (setq so-long-predicate #'doom-buffer-has-long-lines-p)) - ;; Don't disable syntax highlighting and line numbers, or make the buffer - ;; read-only, in `so-long-minor-mode', so we can have a basic editing - ;; experience in them, at least. It will remain off in `so-long-mode', - ;; however, because long files have a far bigger impact on Emacs performance. - (delq! 'font-lock-mode so-long-minor-modes) - (delq! 'display-line-numbers-mode so-long-minor-modes) - (delq! 'buffer-read-only so-long-variable-overrides 'assq) - ;; ...but at least reduce the level of syntax highlighting - (add-to-list 'so-long-variable-overrides '(font-lock-maximum-decoration . 1)) - ;; ...and insist that save-place not operate in large/long files - (add-to-list 'so-long-variable-overrides '(save-place-alist . nil)) - ;; But disable everything else that may be unnecessary/expensive for large or - ;; wide buffers. - (appendq! so-long-minor-modes - '(spell-fu-mode - eldoc-mode - highlight-numbers-mode - better-jumper-local-mode - ws-butler-mode - auto-composition-mode - undo-tree-mode - highlight-indent-guides-mode - hl-fill-column-mode - ;; These are redundant on Emacs 29+ - flycheck-mode - smartparens-mode - smartparens-strict-mode))) - - -(use-package! ws-butler - ;; a less intrusive `delete-trailing-whitespaces' on save - :hook (doom-first-buffer . ws-butler-global-mode) - :config - ;; ws-butler normally preserves whitespace in the buffer (but strips it from - ;; the written file). While sometimes convenient, this behavior is not - ;; intuitive. To the average user it looks like whitespace cleanup is failing, - ;; which causes folks to redundantly install their own. - (setq ws-butler-keep-whitespace-before-point nil)) - -(provide 'doom-editor) -;;; doom-editor.el ends here diff --git a/.config/emacs/lisp/doom-keybinds.el b/.config/emacs/lisp/doom-keybinds.el @@ -1,472 +0,0 @@ -;;; doom-keybinds.el --- defaults for Doom's keybinds -*- lexical-binding: t; -*- -;;; Commentary: -;; -;; A centralized keybinds system, integrated with `which-key' to preview -;; available keybindings. All built into one powerful macro: `map!'. If evil is -;; never loaded, then evil bindings set with `map!' are ignored (i.e. omitted -;; entirely for performance reasons). -;; -;;; Code: - -(defvar doom-leader-key "SPC" - "The leader prefix key for Evil users.") - -(defvar doom-leader-alt-key "M-SPC" - "An alternative leader prefix key, used for Insert and Emacs states, and for -non-evil users.") - -(defvar doom-localleader-key "SPC m" - "The localleader prefix key, for major-mode specific commands.") - -(defvar doom-localleader-alt-key "M-SPC m" - "The localleader prefix key, for major-mode specific commands. Used for Insert -and Emacs states, and for non-evil users.") - -(defvar doom-leader-map (make-sparse-keymap) - "An overriding keymap for <leader> keys.") - - -;; -;;; Global keybind settings - -(cond - (IS-MAC - ;; mac-* variables are used by the special emacs-mac build of Emacs by - ;; Yamamoto Mitsuharu, while other builds use ns-*. - (setq mac-command-modifier 'super - ns-command-modifier 'super - mac-option-modifier 'meta - ns-option-modifier 'meta - ;; Free up the right option for character composition - mac-right-option-modifier 'none - ns-right-option-modifier 'none)) - (IS-WINDOWS - (setq w32-lwindow-modifier 'super - w32-rwindow-modifier 'super))) - -;; HACK: Emacs cannot distinguish between C-i from TAB. This is largely a -;; byproduct of its history in the terminal, which can't distinguish them -;; either, however, when GUIs came about Emacs greated separate input events -;; for more contentious keys like TAB and RET. Therefore [return] != RET, -;; [tab] != TAB, and [backspace] != DEL. -;; -;; In the same vein, this keybind adds a [C-i] event, so users can bind to it. -;; Otherwise, it falls back to regular C-i keybinds. -(define-key key-translation-map [?\C-i] - (cmd! (if (let ((keys (this-single-command-raw-keys))) - (and keys - (not (cl-position 'tab keys)) - (not (cl-position 'kp-tab keys)) - (display-graphic-p) - ;; Fall back if no <C-i> keybind can be found, otherwise - ;; we've broken all pre-existing C-i keybinds. - (let ((key - (doom-lookup-key - (vconcat (cl-subseq keys 0 -1) [C-i])))) - (not (or (numberp key) (null key)))))) - [C-i] [?\C-i]))) - - -;; -;;; Universal, non-nuclear escape - -;; `keyboard-quit' is too much of a nuclear option. I wanted an ESC/C-g to -;; do-what-I-mean. It serves four purposes (in order): -;; -;; 1. Quit active states; e.g. highlights, searches, snippets, iedit, -;; multiple-cursors, recording macros, etc. -;; 2. Close popup windows remotely (if it is allowed to) -;; 3. Refresh buffer indicators, like git-gutter and flycheck -;; 4. Or fall back to `keyboard-quit' -;; -;; And it should do these things incrementally, rather than all at once. And it -;; shouldn't interfere with recording macros or the minibuffer. This may require -;; you press ESC/C-g two or three times on some occasions to reach -;; `keyboard-quit', but this is much more intuitive. - -(defvar doom-escape-hook nil - "A hook run when C-g is pressed (or ESC in normal mode, for evil users). - -More specifically, when `doom/escape' is pressed. If any hook returns non-nil, -all hooks after it are ignored.") - -(defun doom/escape (&optional interactive) - "Run `doom-escape-hook'." - (interactive (list 'interactive)) - (cond ((minibuffer-window-active-p (minibuffer-window)) - ;; quit the minibuffer if open. - (when interactive - (setq this-command 'abort-recursive-edit)) - (abort-recursive-edit)) - ;; Run all escape hooks. If any returns non-nil, then stop there. - ((run-hook-with-args-until-success 'doom-escape-hook)) - ;; don't abort macros - ((or defining-kbd-macro executing-kbd-macro) nil) - ;; Back to the default - ((unwind-protect (keyboard-quit) - (when interactive - (setq this-command 'keyboard-quit)))))) - -(global-set-key [remap keyboard-quit] #'doom/escape) - -(with-eval-after-load 'eldoc - (eldoc-add-command 'doom/escape)) - - -;; -;;; General + leader/localleader keys - -(require 'general) -;; Convenience aliases -(defalias 'define-key! #'general-def) -(defalias 'undefine-key! #'general-unbind) -;; Prevent "X starts with non-prefix key Y" errors except at startup. -(add-hook 'doom-after-modules-init-hook #'general-auto-unbind-keys) - -;; HACK: `map!' uses this instead of `define-leader-key!' because it consumes -;; 20-30% more startup time, so we reimplement it ourselves. -(defmacro doom--define-leader-key (&rest keys) - (let (prefix forms wkforms) - (while keys - (let ((key (pop keys)) - (def (pop keys))) - (if (keywordp key) - (when (memq key '(:prefix :infix)) - (setq prefix def)) - (when prefix - (setq key `(general--concat t ,prefix ,key))) - (let* ((udef (cdr-safe (doom-unquote def))) - (bdef (if (general--extended-def-p udef) - (general--extract-def (general--normalize-extended-def udef)) - def))) - (unless (eq bdef :ignore) - (push `(define-key doom-leader-map (general--kbd ,key) - ,bdef) - forms)) - (when-let (desc (cadr (memq :which-key udef))) - (prependq! - wkforms `((which-key-add-key-based-replacements - (general--concat t doom-leader-alt-key ,key) - ,desc) - (which-key-add-key-based-replacements - (general--concat t doom-leader-key ,key) - ,desc)))))))) - (macroexp-progn - (append (and wkforms `((after! which-key ,@(nreverse wkforms)))) - (nreverse forms))))) - -(defmacro define-leader-key! (&rest args) - "Define <leader> keys. - -Uses `general-define-key' under the hood, but does not support :states, -:wk-full-keys or :keymaps. Use `map!' for a more convenient interface. - -See `doom-leader-key' and `doom-leader-alt-key' to change the leader prefix." - `(general-define-key - :states nil - :wk-full-keys nil - :keymaps 'doom-leader-map - ,@args)) - -(defmacro define-localleader-key! (&rest args) - "Define <localleader> key. - -Uses `general-define-key' under the hood, but does not support :major-modes, -:states, :prefix or :non-normal-prefix. Use `map!' for a more convenient -interface. - -See `doom-localleader-key' and `doom-localleader-alt-key' to change the -localleader prefix." - (if (modulep! :editor evil) - ;; :non-normal-prefix doesn't apply to non-evil sessions (only evil's - ;; emacs state) - `(general-define-key - :states '(normal visual motion emacs insert) - :major-modes t - :prefix doom-localleader-key - :non-normal-prefix doom-localleader-alt-key - ,@args) - `(general-define-key - :major-modes t - :prefix doom-localleader-alt-key - ,@args))) - -;; PERF: We use a prefix commands instead of general's -;; :prefix/:non-normal-prefix properties because general is incredibly slow -;; binding keys en mass with them in conjunction with :states -- an effective -;; doubling of Doom's startup time! -(define-prefix-command 'doom/leader 'doom-leader-map) -(define-key doom-leader-map [override-state] 'all) - -;; Bind `doom-leader-key' and `doom-leader-alt-key' as late as possible to give -;; the user a chance to modify them. -(add-hook! 'doom-after-init-hook - (defun doom-init-leader-keys-h () - "Bind `doom-leader-key' and `doom-leader-alt-key'." - (let ((map general-override-mode-map)) - (if (not (featurep 'evil)) - (progn - (cond ((equal doom-leader-alt-key "C-c") - (set-keymap-parent doom-leader-map mode-specific-map)) - ((equal doom-leader-alt-key "C-x") - (set-keymap-parent doom-leader-map ctl-x-map))) - (define-key map (kbd doom-leader-alt-key) 'doom/leader)) - (evil-define-key* '(normal visual motion) map (kbd doom-leader-key) 'doom/leader) - (evil-define-key* '(emacs insert) map (kbd doom-leader-alt-key) 'doom/leader)) - (general-override-mode +1)))) - - -;; -;;; Packages - -(use-package! which-key - :hook (doom-first-input . which-key-mode) - :init - (setq which-key-sort-order #'which-key-key-order-alpha - which-key-sort-uppercase-first nil - which-key-add-column-padding 1 - which-key-max-display-columns nil - which-key-min-display-lines 6 - which-key-side-window-slot -10) - :config - (put 'which-key-replacement-alist 'initial-value which-key-replacement-alist) - (add-hook! 'doom-before-reload-hook - (defun doom-reset-which-key-replacements-h () - (setq which-key-replacement-alist (get 'which-key-replacement-alist 'initial-value)))) - ;; general improvements to which-key readability - (which-key-setup-side-window-bottom) - (setq-hook! 'which-key-init-buffer-hook line-spacing 3) - - (which-key-add-key-based-replacements doom-leader-key "<leader>") - (which-key-add-key-based-replacements doom-localleader-key "<localleader>")) - - -;; -;;; `map!' macro - -(defvar doom-evil-state-alist - '((?n . normal) - (?v . visual) - (?i . insert) - (?e . emacs) - (?o . operator) - (?m . motion) - (?r . replace) - (?g . global)) - "A list of cons cells that map a letter to a evil state symbol.") - -(defun doom--map-keyword-to-states (keyword) - "Convert a KEYWORD into a list of evil state symbols. - -For example, :nvi will map to (list 'normal 'visual 'insert). See -`doom-evil-state-alist' to customize this." - (cl-loop for l across (doom-keyword-name keyword) - if (assq l doom-evil-state-alist) collect (cdr it) - else do (error "not a valid state: %s" l))) - - -;; specials -(defvar doom--map-forms nil) -(defvar doom--map-fn nil) -(defvar doom--map-batch-forms nil) -(defvar doom--map-state '(:dummy t)) -(defvar doom--map-parent-state nil) -(defvar doom--map-evil-p nil) -(after! evil (setq doom--map-evil-p t)) - -(defun doom--map-process (rest) - (let ((doom--map-fn doom--map-fn) - doom--map-state - doom--map-forms - desc) - (while rest - (let ((key (pop rest))) - (cond ((listp key) - (doom--map-nested nil key)) - - ((keywordp key) - (pcase key - (:leader - (doom--map-commit) - (setq doom--map-fn 'doom--define-leader-key)) - (:localleader - (doom--map-commit) - (setq doom--map-fn 'define-localleader-key!)) - (:after - (doom--map-nested (list 'after! (pop rest)) rest) - (setq rest nil)) - (:desc - (setq desc (pop rest))) - (:map - (doom--map-set :keymaps `(quote ,(ensure-list (pop rest))))) - (:mode - (push (cl-loop for m in (ensure-list (pop rest)) - collect (intern (concat (symbol-name m) "-map"))) - rest) - (push :map rest)) - ((or :when :unless) - (doom--map-nested (list (intern (doom-keyword-name key)) (pop rest)) rest) - (setq rest nil)) - (:prefix-map - (cl-destructuring-bind (prefix . desc) - (let ((arg (pop rest))) - (if (consp arg) arg (list arg))) - (let ((keymap (intern (format "doom-leader-%s-map" desc)))) - (setq rest - (append (list :desc desc prefix keymap - :prefix prefix) - rest)) - (push `(defvar ,keymap (make-sparse-keymap)) - doom--map-forms)))) - (:prefix - (cl-destructuring-bind (prefix . desc) - (let ((arg (pop rest))) - (if (consp arg) arg (list arg))) - (doom--map-set (if doom--map-fn :infix :prefix) - prefix) - (when (stringp desc) - (setq rest (append (list :desc desc "" nil) rest))))) - (:textobj - (let* ((key (pop rest)) - (inner (pop rest)) - (outer (pop rest))) - (push `(map! (:map evil-inner-text-objects-map ,key ,inner) - (:map evil-outer-text-objects-map ,key ,outer)) - doom--map-forms))) - (_ - (condition-case _ - (doom--map-def (pop rest) (pop rest) - (doom--map-keyword-to-states key) - desc) - (error - (error "Not a valid `map!' property: %s" key))) - (setq desc nil)))) - - ((doom--map-def key (pop rest) nil desc) - (setq desc nil))))) - - (doom--map-commit) - (macroexp-progn (nreverse (delq nil doom--map-forms))))) - -(defun doom--map-append-keys (prop) - (let ((a (plist-get doom--map-parent-state prop)) - (b (plist-get doom--map-state prop))) - (if (and a b) - `(general--concat t ,a ,b) - (or a b)))) - -(defun doom--map-nested (wrapper rest) - (doom--map-commit) - (let ((doom--map-parent-state (doom--map-state))) - (push (if wrapper - (append wrapper (list (doom--map-process rest))) - (doom--map-process rest)) - doom--map-forms))) - -(defun doom--map-set (prop &optional value) - (unless (equal (plist-get doom--map-state prop) value) - (doom--map-commit)) - (setq doom--map-state (plist-put doom--map-state prop value))) - -(defun doom--map-def (key def &optional states desc) - (when (or (memq 'global states) - (null states)) - (setq states (cons 'nil (delq 'global states)))) - (when desc - (let (unquoted) - (cond ((and (listp def) - (keywordp (car-safe (setq unquoted (doom-unquote def))))) - (setq def (list 'quote (plist-put unquoted :which-key desc)))) - ((setq def (cons 'list - (if (and (equal key "") - (null def)) - `(:ignore t :which-key ,desc) - (plist-put (general--normalize-extended-def def) - :which-key desc)))))))) - (dolist (state states) - (push (list key def) - (alist-get state doom--map-batch-forms))) - t) - -(defun doom--map-commit () - (when doom--map-batch-forms - (cl-loop with attrs = (doom--map-state) - for (state . defs) in doom--map-batch-forms - if (or doom--map-evil-p (not state)) - collect `(,(or doom--map-fn 'general-define-key) - ,@(if state `(:states ',state)) ,@attrs - ,@(mapcan #'identity (nreverse defs))) - into forms - finally do (push (macroexp-progn forms) doom--map-forms)) - (setq doom--map-batch-forms nil))) - -(defun doom--map-state () - (let ((plist - (append (list :prefix (doom--map-append-keys :prefix) - :infix (doom--map-append-keys :infix) - :keymaps - (append (plist-get doom--map-parent-state :keymaps) - (plist-get doom--map-state :keymaps))) - doom--map-state - nil)) - newplist) - (while plist - (let ((key (pop plist)) - (val (pop plist))) - (when (and val (not (plist-member newplist key))) - (push val newplist) - (push key newplist)))) - newplist)) - -;; -(defmacro map! (&rest rest) - "A convenience macro for defining keybinds, powered by `general'. - -If evil isn't loaded, evil-specific bindings are ignored. - -Properties - :leader [...] an alias for (:prefix doom-leader-key ...) - :localleader [...] bind to localleader; requires a keymap - :mode [MODE(s)] [...] inner keybinds are applied to major MODE(s) - :map [KEYMAP(s)] [...] inner keybinds are applied to KEYMAP(S) - :prefix [PREFIX] [...] set keybind prefix for following keys. PREFIX - can be a cons cell: (PREFIX . DESCRIPTION) - :prefix-map [PREFIX] [...] same as :prefix, but defines a prefix keymap - where the following keys will be bound. DO NOT - USE THIS IN YOUR PRIVATE CONFIG. - :after [FEATURE] [...] apply keybinds when [FEATURE] loads - :textobj KEY INNER-FN OUTER-FN define a text object keybind pair - :when [CONDITION] [...] - :unless [CONDITION] [...] - - Any of the above properties may be nested, so that they only apply to a - certain group of keybinds. - -States - :n normal - :v visual - :i insert - :e emacs - :o operator - :m motion - :r replace - :g global (binds the key without evil `current-global-map') - - These can be combined in any order, e.g. :nvi will apply to normal, visual and - insert mode. The state resets after the following key=>def pair. If states are - omitted the keybind will be global (no emacs state; this is different from - evil's Emacs state and will work in the absence of `evil-mode'). - - These must be placed right before the key string. - - Do - (map! :leader :desc \"Description\" :n \"C-c\" #'dosomething) - Don't - (map! :n :leader :desc \"Description\" \"C-c\" #'dosomething) - (map! :leader :n :desc \"Description\" \"C-c\" #'dosomething)" - (when (or (bound-and-true-p byte-compile-current-file) - (not noninteractive)) - (doom--map-process rest))) - -(provide 'doom-keybinds) -;;; doom-keybinds.el ends here diff --git a/.config/emacs/lisp/doom-lib.el b/.config/emacs/lisp/doom-lib.el @@ -1,988 +0,0 @@ -;;; doom-lib.el --- Doom's core standard library -*- lexical-binding: t; -*- -;;; Commentary: -;;; Code: - -;;; Custom error types -(define-error 'doom-error "An unexpected Doom error") -(define-error 'doom-nosync-error "Doom hasn't been initialized yet; did you remember to run 'doom sync' in the shell?" 'doom-error) -(define-error 'doom-core-error "Unexpected error in Doom's core" 'doom-error) -(define-error 'doom-hook-error "Error in a Doom startup hook" 'doom-error) -(define-error 'doom-autoload-error "Error in Doom's autoloads file" 'doom-error) -(define-error 'doom-user-error "Error caused by user's config or system" 'doom-error) -(define-error 'doom-module-error "Error in a Doom module" 'doom-error) -(define-error 'doom-package-error "Error with packages" 'doom-error) -(define-error 'doom-profile-error "Error while processing profiles" 'doom-error) - - -;; -;;; Logging - -(defvar doom-inhibit-log (not (or noninteractive init-file-debug)) - "If non-nil, suppress `doom-log' output.") - -(defun doom--log (text &rest args) - (let ((inhibit-message (not init-file-debug)) - (absolute? (string-prefix-p ":" text))) - (apply #'message - (propertize (concat "* %.06f:%s" (if (not absolute?) ":") text) - 'face 'font-lock-doc-face) - (float-time (time-subtract (current-time) before-init-time)) - (mapconcat - (lambda (x) (format "%s" x)) - (unless absolute? - (append (cons '* (remq t (reverse doom-context))) - (if (bound-and-true-p doom-module-context) - (let ((key (doom-module-context-key))) - (delq nil (list (car key) (cdr key))))))) - ":") - args))) - -(defmacro doom-log (message &rest args) - "Log a message in *Messages*. - -Does not emit the message in the echo area. This is a macro instead of a -function to prevent the potentially expensive evaluation of its arguments when -debug mode is off. Return non-nil." - (declare (debug t)) - `(unless doom-inhibit-log (doom--log ,message ,@args))) - - -;; -;;; Helpers - -(defun doom--resolve-hook-forms (hooks) - "Converts a list of modes into a list of hook symbols. - -If a mode is quoted, it is left as is. If the entire HOOKS list is quoted, the -list is returned as-is." - (declare (pure t) (side-effect-free t)) - (let ((hook-list (ensure-list (doom-unquote hooks)))) - (if (eq (car-safe hooks) 'quote) - hook-list - (cl-loop for hook in hook-list - if (eq (car-safe hook) 'quote) - collect (cadr hook) - else collect (intern (format "%s-hook" (symbol-name hook))))))) - -(defun doom--setq-hook-fns (hooks rest &optional singles) - (unless (or singles (= 0 (% (length rest) 2))) - (signal 'wrong-number-of-arguments (list #'evenp (length rest)))) - (cl-loop with vars = (let ((args rest) - vars) - (while args - (push (if singles - (list (pop args)) - (cons (pop args) (pop args))) - vars)) - (nreverse vars)) - for hook in (doom--resolve-hook-forms hooks) - for mode = (string-remove-suffix "-hook" (symbol-name hook)) - append - (cl-loop for (var . val) in vars - collect - (list var val hook - (intern (format "doom--setq-%s-for-%s-h" - var mode)))))) - - -;; -;;; Public library - -(define-obsolete-function-alias 'doom-enlist 'ensure-list "v3.0.0") - -(defun doom-unquote (exp) - "Return EXP unquoted." - (declare (pure t) (side-effect-free t)) - (while (memq (car-safe exp) '(quote function)) - (setq exp (cadr exp))) - exp) - -(defun doom-keyword-intern (str) - "Converts STR (a string) into a keyword (`keywordp')." - (declare (pure t) (side-effect-free t)) - (cl-check-type str string) - (intern (concat ":" str))) - -(defun doom-keyword-name (keyword) - "Returns the string name of KEYWORD (`keywordp') minus the leading colon." - (declare (pure t) (side-effect-free t)) - (cl-check-type keyword keyword) - (substring (symbol-name keyword) 1)) - -(defalias 'doom-partial #'apply-partially) - -(defun doom-rpartial (fn &rest args) - "Return a partial application of FUN to right-hand ARGS. - -ARGS is a list of the last N arguments to pass to FUN. The result is a new -function which does the same as FUN, except that the last N arguments are fixed -at the values with which this function was called." - (declare (side-effect-free t)) - (lambda (&rest pre-args) - (apply fn (append pre-args args)))) - -(defun doom-lookup-key (keys &rest keymaps) - "Like `lookup-key', but search active keymaps if KEYMAP is omitted." - (if keymaps - (cl-some (doom-rpartial #'lookup-key keys) keymaps) - (cl-loop for keymap - in (append (cl-loop for alist in emulation-mode-map-alists - append (mapcar #'cdr - (if (symbolp alist) - (if (boundp alist) (symbol-value alist)) - alist))) - (list (current-local-map)) - (mapcar #'cdr minor-mode-overriding-map-alist) - (mapcar #'cdr minor-mode-map-alist) - (list (current-global-map))) - if (keymapp keymap) - if (lookup-key keymap keys) - return it))) - -(defun doom-load (path &optional noerror) - "Load PATH and handle any Doom errors that arise from it. - -If NOERROR, don't throw an error if PATH doesn't exist." - (doom-log "load: %s %s" (abbreviate-file-name path) noerror) - (condition-case-unless-debug e - (load path noerror 'nomessage) - (doom-error - (signal (car e) (cdr e))) - (error - (setq path (locate-file path load-path (get-load-suffixes))) - (signal (cond ((not (and path (featurep 'doom))) - 'error) - ((file-in-directory-p path (expand-file-name "cli" doom-core-dir)) - 'doom-cli-error) - ((file-in-directory-p path doom-core-dir) - 'doom-core-error) - ((file-in-directory-p path doom-user-dir) - 'doom-user-error) - ((file-in-directory-p path doom-profile-dir) - 'doom-profile-error) - ((file-in-directory-p path doom-modules-dir) - 'doom-module-error) - ('doom-error)) - (list path e))))) - -(defun doom-require (feature &optional filename noerror) - "Like `require', but handles and enhances Doom errors. - -Can also load Doom's subfeatures, e.g. (doom-require 'doom-lib 'files)" - (let ((subfeature (if (symbolp filename) filename))) - (or (featurep feature subfeature) - (doom-load - (if subfeature - (file-name-concat doom-core-dir - (string-remove-prefix "doom-" (symbol-name feature)) - (symbol-name filename)) - (symbol-name feature)) - noerror)))) - -(defun doom-load-envvars-file (file &optional noerror) - "Read and set envvars from FILE. -If NOERROR is non-nil, don't throw an error if the file doesn't exist or is -unreadable. Returns the names of envvars that were changed." - (if (null (file-exists-p file)) - (unless noerror - (signal 'file-error (list "No envvar file exists" file))) - (with-temp-buffer - (insert-file-contents file) - (when-let (env (read (current-buffer))) - (let ((tz (getenv-internal "TZ"))) - (setq-default - process-environment - (append env (default-value 'process-environment)) - exec-path - (append (split-string (getenv "PATH") path-separator t) - (list exec-directory)) - shell-file-name - (or (getenv "SHELL") - (default-value 'shell-file-name))) - (when-let (newtz (getenv-internal "TZ")) - (unless (equal tz newtz) - (set-time-zone-rule newtz)))) - env)))) - -(defvar doom--hook nil) -(defun doom-run-hook (hook) - "Run HOOK (a hook function) with better error handling. -Meant to be used with `run-hook-wrapped'." - (doom-log "hook:%s: run %s" (or doom--hook '*) hook) - (condition-case-unless-debug e - (funcall hook) - (error - (signal 'doom-hook-error (list hook e)))) - ;; return nil so `run-hook-wrapped' won't short circuit - nil) - -(defun doom-run-hooks (&rest hooks) - "Run HOOKS (a list of hook variable symbols) with better error handling. -Is used as advice to replace `run-hooks'." - (dolist (hook hooks) - (condition-case-unless-debug e - (let ((doom--hook hook)) - (run-hook-wrapped hook #'doom-run-hook)) - (doom-hook-error - (unless debug-on-error - (lwarn hook :error "Error running hook %S because: %s" - (if (symbolp (cadr e)) - (symbol-name (cadr e)) - (cadr e)) - (caddr e))) - (signal 'doom-hook-error (cons hook (cdr e))))))) - -(defun doom-run-hook-on (hook-var trigger-hooks) - "Configure HOOK-VAR to be invoked exactly once when any of the TRIGGER-HOOKS -are invoked *after* Emacs has initialized (to reduce false positives). Once -HOOK-VAR is triggered, it is reset to nil. - -HOOK-VAR is a quoted hook. -TRIGGER-HOOK is a list of quoted hooks and/or sharp-quoted functions." - (dolist (hook trigger-hooks) - (let ((fn (make-symbol (format "chain-%s-to-%s-h" hook-var hook))) - running?) - (fset - fn (lambda (&rest _) - ;; Only trigger this after Emacs has initialized. - (when (and after-init-time - (not running?) - (or (daemonp) - ;; In some cases, hooks may be lexically unset to - ;; inhibit them during expensive batch operations on - ;; buffers (such as when processing buffers - ;; internally). In these cases we should assume this - ;; hook wasn't invoked interactively. - (and (boundp hook) - (symbol-value hook)))) - (setq running? t) ; prevent infinite recursion - (doom-run-hooks hook-var) - (set hook-var nil)))) - (cond ((daemonp) - ;; In a daemon session we don't need all these lazy loading - ;; shenanigans. Just load everything immediately. - (add-hook 'after-init-hook fn 'append)) - ((eq hook 'find-file-hook) - ;; Advise `after-find-file' instead of using `find-file-hook' - ;; because the latter is triggered too late (after the file has - ;; opened and modes are all set up). - (advice-add 'after-find-file :before fn '((depth . -101)))) - ((add-hook hook fn -101))) - fn))) - -(defun doom-compile-functions (&rest fns) - "Queue FNS to be byte/natively-compiled after a brief delay." - (with-memoization (get 'doom-compile-function 'timer) - (run-with-idle-timer - 1.5 t (fn! (when-let (fn (pop fns)) - (doom-log "compile-functions: %s" fn) - (or (if (featurep 'native-compile) - (or (subr-native-elisp-p (indirect-function fn)) - (ignore-errors (native-compile fn)))) - (byte-code-function-p fn) - (let (byte-compile-warnings) - (byte-compile fn)))) - (unless fns - (cancel-timer (get 'doom-compile-function 'timer)) - (put 'doom-compile-function 'timer nil)))))) - - -;; -;;; Sugars - -(defmacro file! () - "Return the file of the file this macro was called." - (or - ;; REVIEW: Use `macroexp-file-name' once 27 support is dropped. - (let ((file (car (last current-load-list)))) - (if (stringp file) file)) - (bound-and-true-p byte-compile-current-file) - load-file-name - buffer-file-name ; for `eval' - (error "file!: cannot deduce the current file path"))) - -(defmacro dir! () - "Return the directory of the file this macro was called." - (let (file-name-handler-alist) - (file-name-directory (macroexpand '(file!))))) - -;; REVIEW Should I deprecate this? The macro's name is so long... -(defalias 'letenv! 'with-environment-variables) - -(defmacro letf! (bindings &rest body) - "Temporarily rebind function, macros, and advice in BODY. - -Intended as syntax sugar for `cl-letf', `cl-labels', `cl-macrolet', and -temporary advice. - -BINDINGS is either: - - A list of, or a single, `defun', `defun*', `defmacro', or `defadvice' forms. - A list of (PLACE VALUE) bindings as `cl-letf*' would accept. - -TYPE is one of: - - `defun' (uses `cl-letf') - `defun*' (uses `cl-labels'; allows recursive references), - `defmacro' (uses `cl-macrolet') - `defadvice' (uses `defadvice!' before BODY, then `undefadvice!' after) - -NAME, ARGLIST, and BODY are the same as `defun', `defun*', `defmacro', and -`defadvice!', respectively. - -\(fn ((TYPE NAME ARGLIST &rest BODY) ...) BODY...)" - (declare (indent defun)) - (setq body (macroexp-progn body)) - (when (memq (car bindings) '(defun defun* defmacro defadvice)) - (setq bindings (list bindings))) - (dolist (binding (reverse bindings) body) - (let ((type (car binding)) - (rest (cdr binding))) - (setq - body (pcase type - (`defmacro `(cl-macrolet ((,@rest)) ,body)) - (`defadvice `(progn (defadvice! ,@rest) - (unwind-protect ,body (undefadvice! ,@rest)))) - ((or `defun `defun*) - `(cl-letf ((,(car rest) (symbol-function #',(car rest)))) - (ignore ,(car rest)) - ,(if (eq type 'defun*) - `(cl-labels ((,@rest)) ,body) - `(cl-letf (((symbol-function #',(car rest)) - (lambda! ,(cadr rest) ,@(cddr rest)))) - ,body)))) - (_ - (when (eq (car-safe type) 'function) - (setq type (list 'symbol-function type))) - (list 'cl-letf (list (cons type rest)) body))))))) - -(defmacro quiet! (&rest forms) - "Run FORMS without generating any output. - -This silences calls to `message', `load', `write-region' and anything that -writes to `standard-output'. In interactive sessions this inhibits output to the -echo-area, but not to *Messages*." - `(if init-file-debug - (progn ,@forms) - ,(if noninteractive - `(letf! ((standard-output (lambda (&rest _))) - (defun message (&rest _)) - (defun load (file &optional noerror nomessage nosuffix must-suffix) - (funcall load file noerror t nosuffix must-suffix)) - (defun write-region (start end filename &optional append visit lockname mustbenew) - (unless visit (setq visit 'no-message)) - (funcall write-region start end filename append visit lockname mustbenew))) - ,@forms) - `(let ((inhibit-message t) - (save-silently t)) - (prog1 ,@forms (message "")))))) - -(defmacro eval-if! (cond then &rest body) - "Expands to THEN if COND is non-nil, to BODY otherwise. -COND is checked at compile/expansion time, allowing BODY to be omitted entirely -when the elisp is byte-compiled. Use this for forms that contain expensive -macros that could safely be removed at compile time." - (declare (indent 2)) - (if (eval cond) - then - (macroexp-progn body))) - -(defmacro eval-when! (cond &rest body) - "Expands to BODY if CONDITION is non-nil at compile/expansion time. -See `eval-if!' for details on this macro's purpose." - (declare (indent 1)) - (when (eval cond) - (macroexp-progn body))) - -(defmacro versionp! (v1 comp v2 &rest comps) - "Perform compound version checks. - -Compares V1 and V2 with COMP (a math comparison operator: <, <=, =, /=, >=, >). -Can chain these comparisons by adding more (COMPn Vn) pairs afterwards. - -\(fn V1 COMP V2 [COMPn Vn]...)" - (let ((forms t)) - (push v2 comps) - (push comp comps) - `(let ((v2 (version-to-list ,v1))) - ,(progn - (cl-loop for (v op) on (nreverse comps) by #'cddr - for not? = (not (memq op '(> >= /=))) - for fn = (or (get 'versionp! op) - (error "Invalid comparator %s" op)) - for form = `(,fn v1 v2) - do (if not? (setq form `(not ,form))) - do (setq v1 'v2 - v2 `(version-to-list ,v) - forms `(let ((v1 ,v1) - (v2 ,v2)) - (and (not ,form) ,forms)))) - forms)))) -;; PERF: Store in symbol plist for ultra-fast lookups at this scale. -(setplist 'versionp! '(> version-list-< - >= version-list-<= - < version-list-< - <= version-list-<= - = version-list-= - /= version-list-=)) - -;;; Closure factories -(defmacro lambda! (arglist &rest body) - "Returns (cl-function (lambda ARGLIST BODY...)) -The closure is wrapped in `cl-function', meaning ARGLIST will accept anything -`cl-defun' will. Implicitly adds `&allow-other-keys' if `&key' is present in -ARGLIST." - (declare (indent defun) (doc-string 1) (pure t) (side-effect-free t)) - `(cl-function - (lambda - ,(letf! (defun* allow-other-keys (args) - (mapcar - (lambda (arg) - (cond ((nlistp (cdr-safe arg)) arg) - ((listp arg) (allow-other-keys arg)) - (arg))) - (if (and (memq '&key args) - (not (memq '&allow-other-keys args))) - (if (memq '&aux args) - (let (newargs arg) - (while args - (setq arg (pop args)) - (when (eq arg '&aux) - (push '&allow-other-keys newargs)) - (push arg newargs)) - (nreverse newargs)) - (append args (list '&allow-other-keys))) - args))) - (allow-other-keys arglist)) - ,@body))) - -(setplist 'doom--fn-crawl '(%2 2 %3 3 %4 4 %5 5 %6 6 %7 7 %8 8 %9 9)) -(defun doom--fn-crawl (data args) - (cond ((symbolp data) - (when-let - (pos (cond ((eq data '%*) 0) - ((memq data '(% %1)) 1) - ((get 'doom--fn-crawl data)))) - (when (and (= pos 1) - (aref args 1) - (not (eq data (aref args 1)))) - (error "%% and %%1 are mutually exclusive")) - (aset args pos data))) - ((and (not (eq (car-safe data) 'fn!)) - (or (listp data) - (vectorp data))) - (let ((len (length data)) - (i 0)) - (while (< i len) - (doom--fn-crawl (elt data i) args) - (cl-incf i)))))) - -(defmacro fn! (&rest args) - "Return an lambda with implicit, positional arguments. - -The function's arguments are determined recursively from ARGS. Each symbol from -`%1' through `%9' that appears in ARGS is treated as a positional argument. -Missing arguments are named `_%N', which keeps the byte-compiler quiet. `%' is -a shorthand for `%1'; only one of these can appear in ARGS. `%*' represents -extra `&rest' arguments. - -Instead of: - - (lambda (a _ c &rest d) - (if a c (cadr d))) - -you can use this macro and write: - - (fn! (if %1 %3 (cadr %*))) - -which expands to: - - (lambda (%1 _%2 %3 &rest %*) - (if %1 %3 (cadr %*))) - -This macro was adapted from llama.el (see https://git.sr.ht/~tarsius/llama), -minus font-locking and the outer function call, plus some minor optimizations." - `(lambda ,(let ((argv (make-vector 10 nil))) - (doom--fn-crawl args argv) - `(,@(let ((i (1- (length argv))) - (n -1) - sym arglist) - (while (> i 0) - (setq sym (aref argv i)) - (unless (and (= n -1) (null sym)) - (cl-incf n) - (push (or sym (intern (format "_%%%d" i))) - arglist)) - (cl-decf i)) - arglist) - ,@(and (aref argv 0) '(&rest %*)))) - ,@args)) - -(defmacro cmd! (&rest body) - "Returns (lambda () (interactive) ,@body) -A factory for quickly producing interaction commands, particularly for keybinds -or aliases." - (declare (doc-string 1) (pure t) (side-effect-free t)) - `(lambda (&rest _) (interactive) ,@body)) - -(defmacro cmd!! (command &optional prefix-arg &rest args) - "Returns a closure that interactively calls COMMAND with ARGS and PREFIX-ARG. -Like `cmd!', but allows you to change `current-prefix-arg' or pass arguments to -COMMAND. This macro is meant to be used as a target for keybinds (e.g. with -`define-key' or `map!')." - (declare (doc-string 1) (pure t) (side-effect-free t)) - `(lambda (arg &rest _) (interactive "P") - (let ((current-prefix-arg (or ,prefix-arg arg))) - (,(if args - #'funcall-interactively - #'call-interactively) - ,command ,@args)))) - -(defmacro cmds! (&rest branches) - "Returns a dispatcher that runs the a command in BRANCHES. -Meant to be used as a target for keybinds (e.g. with `define-key' or `map!'). - -BRANCHES is a flat list of CONDITION COMMAND pairs. CONDITION is a lisp form -that is evaluated when (and each time) the dispatcher is invoked. If it returns -non-nil, COMMAND is invoked, otherwise it falls through to the next pair. - -The last element of BRANCHES can be a COMMANd with no CONDITION. This acts as -the fallback if all other conditions fail. - -Otherwise, Emacs will fall through the keybind and search the next keymap for a -keybind (as if this keybind never existed). - -See `general-key-dispatch' for what other arguments it accepts in BRANCHES." - (declare (doc-string 1)) - (let ((docstring (if (stringp (car branches)) (pop branches) "")) - fallback) - (when (cl-oddp (length branches)) - (setq fallback (car (last branches)) - branches (butlast branches))) - (let ((defs (cl-loop for (key value) on branches by 'cddr - unless (keywordp key) - collect (list key value)))) - `'(menu-item - ,(or docstring "") nil - :filter (lambda (&optional _) - (let (it) - (cond ,@(mapcar (lambda (pred-def) - `((setq it ,(car pred-def)) - ,(cadr pred-def))) - defs) - (t ,fallback)))))))) - -(defalias 'kbd! #'general-simulate-key) - -;; For backwards compatibility -(defalias 'λ! #'cmd!) -(defalias 'λ!! #'cmd!!) - - -;;; Mutation -(defmacro appendq! (sym &rest lists) - "Append LISTS to SYM in place." - `(setq ,sym (append ,sym ,@lists))) - -(defmacro setq! (&rest settings) - "A more sensible `setopt' for setting customizable variables. - -This can be used as a drop-in replacement for `setq' and *should* be used -instead of `setopt'. Unlike `setq', this triggers custom setters on variables. -Unlike `setopt', this won't needlessly pull in dependencies." - (macroexp-progn - (cl-loop for (var val) on settings by 'cddr - collect `(funcall (or (get ',var 'custom-set) #'set-default-toplevel-value) - ',var ,val)))) - -(defmacro delq! (elt list &optional fetcher) - "`delq' ELT from LIST in-place. - -If FETCHER is a function, ELT is used as the key in LIST (an alist)." - `(setq ,list (delq ,(if fetcher - `(funcall ,fetcher ,elt ,list) - elt) - ,list))) - -(defmacro pushnew! (place &rest values) - "Push VALUES sequentially into PLACE, if they aren't already present. -This is a variadic `cl-pushnew'." - (let ((var (make-symbol "result"))) - `(dolist (,var (list ,@values) (with-no-warnings ,place)) - (cl-pushnew ,var ,place :test #'equal)))) - -(defmacro prependq! (sym &rest lists) - "Prepend LISTS to SYM in place." - `(setq ,sym (append ,@lists ,sym))) - - -;;; Loading -(defmacro add-load-path! (&rest dirs) - "Add DIRS to `load-path', relative to the current file. -The current file is the file from which `add-to-load-path!' is used." - `(let ((default-directory (dir!)) - file-name-handler-alist) - (dolist (dir (list ,@dirs)) - (cl-pushnew (expand-file-name dir) load-path :test #'string=)))) - -(defmacro after! (package &rest body) - "Evaluate BODY after PACKAGE have loaded. - -PACKAGE is a symbol (or list of them) referring to Emacs features (aka -packages). PACKAGE may use :or/:any and :and/:all operators. The precise format -is: - -- An unquoted package symbol (the name of a package) - (after! helm BODY...) -- An unquoted, nested list of compound package lists, using any combination of - :or/:any and :and/:all - (after! (:or package-a package-b ...) BODY...) - (after! (:and package-a package-b ...) BODY...) - (after! (:and package-a (:or package-b package-c) ...) BODY...) -- An unquoted list of package symbols (i.e. BODY is evaluated once both magit - and git-gutter have loaded) - (after! (magit git-gutter) BODY...) - If :or/:any/:and/:all are omitted, :and/:all are implied. - -This emulates `eval-after-load' with a few key differences: - -1. No-ops for package that are disabled by the user (via `package!') or not - installed yet. -2. Supports compound package statements (see :or/:any and :and/:all above). - -Since the contents of these blocks will never by byte-compiled, avoid putting -things you want byte-compiled in them! Like function/macro definitions." - (declare (indent defun) (debug t)) - (if (symbolp package) - (unless (memq package (bound-and-true-p doom-disabled-packages)) - (list (if (or (not (bound-and-true-p byte-compile-current-file)) - (require package nil 'noerror)) - #'progn - #'with-no-warnings) - `(with-eval-after-load ',package ,@body))) - (let ((p (car package))) - (cond ((memq p '(:or :any)) - (macroexp-progn - (cl-loop for next in (cdr package) - collect `(after! ,next ,@body)))) - ((memq p '(:and :all)) - (dolist (next (reverse (cdr package)) (car body)) - (setq body `((after! ,next ,@body))))) - (`(after! (:and ,@package) ,@body)))))) - -(defmacro load! (filename &optional path noerror) - "Load a file relative to the current executing file (`load-file-name'). - -FILENAME is either a file path string or a form that should evaluate to such a -string at run time. PATH is where to look for the file (a string representing a -directory path). If omitted, the lookup is relative to either `load-file-name', -`byte-compile-current-file' or `buffer-file-name' (checked in that order). - -If NOERROR is non-nil, don't throw an error if the file doesn't exist." - `(doom-load - (file-name-concat ,(or path `(dir!)) ,filename) - ,noerror)) - -(defmacro defer-until! (condition &rest body) - "Run BODY when CONDITION is true (checks on `after-load-functions'). Meant to -serve as a predicated alternative to `after!'." - (declare (indent defun) (debug t)) - `(if ,condition - (progn ,@body) - ,(let ((fn (intern (format "doom--delay-form-%s-h" (sxhash (cons condition body)))))) - `(progn - (fset ',fn (lambda (&rest args) - (when ,(or condition t) - (remove-hook 'after-load-functions #',fn) - (unintern ',fn nil) - (ignore args) - ,@body))) - (put ',fn 'permanent-local-hook t) - (add-hook 'after-load-functions #',fn))))) - -(defmacro defer-feature! (feature &rest fns) - "Pretend FEATURE hasn't been loaded yet, until FEATURE-hook or FNS run. - -Some packages (like `elisp-mode' and `lisp-mode') are loaded immediately at -startup, which will prematurely trigger `after!' (and `with-eval-after-load') -blocks. To get around this we make Emacs believe FEATURE hasn't been loaded yet, -then wait until FEATURE-hook (or any of FNS, if FNS are provided) is triggered -to reverse this and trigger `after!' blocks at a more reasonable time." - (let ((advice-fn (intern (format "doom--defer-feature-%s-a" feature))) - (fns (or fns (list feature)))) - `(progn - (delq! ',feature features) - (defadvice! ,advice-fn (&rest _) - :before ',fns - ;; Some plugins (like yasnippet) will invoke a fn early to parse - ;; code, which would prematurely trigger this. In those cases, well - ;; behaved plugins will use `delay-mode-hooks', which we can check for: - (unless delay-mode-hooks - ;; ...Otherwise, announce to the world this package has been loaded, - ;; so `after!' handlers can react. - (provide ',feature) - (dolist (fn ',fns) - (advice-remove fn #',advice-fn))))))) - - -;;; Hooks -(defmacro add-transient-hook! (hook-or-function &rest forms) - "Attaches a self-removing function to HOOK-OR-FUNCTION. - -FORMS are evaluated once, when that function/hook is first invoked, then never -again. - -HOOK-OR-FUNCTION can be a quoted hook or a sharp-quoted function (which will be -advised)." - (declare (indent 1)) - (let ((append? (if (eq (car forms) :after) (pop forms))) - (fn (gensym "doom-transient-hook"))) - `(let ((sym ,hook-or-function)) - (defun ,fn (&rest _) - ,(format "Transient hook for %S" (doom-unquote hook-or-function)) - ,@forms - (let ((sym ,hook-or-function)) - (cond ((functionp sym) (advice-remove sym #',fn)) - ((symbolp sym) (remove-hook sym #',fn)))) - (unintern ',fn nil)) - (cond ((functionp sym) - (advice-add ,hook-or-function ,(if append? :after :before) #',fn)) - ((symbolp sym) - (put ',fn 'permanent-local-hook t) - (add-hook sym #',fn ,append?)))))) - -(defmacro add-hook! (hooks &rest rest) - "A convenience macro for adding N functions to M hooks. - -This macro accepts, in order: - - 1. The mode(s) or hook(s) to add to. This is either an unquoted mode, an - unquoted list of modes, a quoted hook variable or a quoted list of hook - variables. - 2. Optional properties :local, :append, and/or :depth [N], which will make the - hook buffer-local or append to the list of hooks (respectively), - 3. The function(s) to be added: this can be a quoted function, a quoted list - thereof, a list of `defun' or `cl-defun' forms, or arbitrary forms (will - implicitly be wrapped in a lambda). - -\(fn HOOKS [:append :local [:depth N]] FUNCTIONS-OR-FORMS...)" - (declare (indent (lambda (indent-point state) - (goto-char indent-point) - (when (looking-at-p "\\s-*(") - (lisp-indent-defform state indent-point)))) - (debug t)) - (let* ((hook-forms (doom--resolve-hook-forms hooks)) - (func-forms ()) - (defn-forms ()) - append-p local-p remove-p depth) - (while (keywordp (car rest)) - (pcase (pop rest) - (:append (setq append-p t)) - (:depth (setq depth (pop rest))) - (:local (setq local-p t)) - (:remove (setq remove-p t)))) - (while rest - (let* ((next (pop rest)) - (first (car-safe next))) - (push (cond ((memq first '(function nil)) - next) - ((eq first 'quote) - (let ((quoted (cadr next))) - (if (atom quoted) - next - (when (cdr quoted) - (setq rest (cons (list first (cdr quoted)) rest))) - (list first (car quoted))))) - ((memq first '(defun cl-defun)) - (push next defn-forms) - (list 'function (cadr next))) - ((prog1 `(lambda (&rest _) ,@(cons next rest)) - (setq rest nil)))) - func-forms))) - `(progn - ,@defn-forms - (dolist (hook (nreverse ',hook-forms)) - (dolist (func (list ,@func-forms)) - ,(if remove-p - `(remove-hook hook func ,local-p) - `(add-hook hook func ,(or depth append-p) ,local-p))))))) - -(defmacro remove-hook! (hooks &rest rest) - "A convenience macro for removing N functions from M hooks. - -Takes the same arguments as `add-hook!'. - -If N and M = 1, there's no benefit to using this macro over `remove-hook'. - -\(fn HOOKS [:append :local] FUNCTIONS)" - (declare (indent defun) (debug t)) - `(add-hook! ,hooks :remove ,@rest)) - -(defmacro setq-hook! (hooks &rest var-vals) - "Sets buffer-local variables on HOOKS. - -\(fn HOOKS &rest [SYM VAL]...)" - (declare (indent 1)) - (macroexp-progn - (cl-loop for (var val hook fn) in (doom--setq-hook-fns hooks var-vals) - collect `(defun ,fn (&rest _) - ,(format "%s = %s" var (pp-to-string val)) - (setq-local ,var ,val)) - collect `(add-hook ',hook #',fn -90)))) - -(defmacro unsetq-hook! (hooks &rest vars) - "Unbind setq hooks on HOOKS for VARS. - -\(fn HOOKS &rest [SYM VAL]...)" - (declare (indent 1)) - (macroexp-progn - (cl-loop for (_var _val hook fn) - in (doom--setq-hook-fns hooks vars 'singles) - collect `(remove-hook ',hook #',fn)))) - - -;;; Definers -(defmacro defadvice! (symbol arglist &optional docstring &rest body) - "Define an advice called SYMBOL and add it to PLACES. - -ARGLIST is as in `defun'. WHERE is a keyword as passed to `advice-add', and -PLACE is the function to which to add the advice, like in `advice-add'. -DOCSTRING and BODY are as in `defun'. - -\(fn SYMBOL ARGLIST &optional DOCSTRING &rest [WHERE PLACES...] BODY\)" - (declare (doc-string 3) (indent defun)) - (unless (stringp docstring) - (push docstring body) - (setq docstring nil)) - (let (where-alist) - (while (keywordp (car body)) - (push `(cons ,(pop body) (ensure-list ,(pop body))) - where-alist)) - `(progn - (defun ,symbol ,arglist ,docstring ,@body) - (dolist (targets (list ,@(nreverse where-alist))) - (dolist (target (cdr targets)) - (advice-add target (car targets) #',symbol)))))) - -(defmacro undefadvice! (symbol _arglist &optional docstring &rest body) - "Undefine an advice called SYMBOL. - -This has the same signature as `defadvice!' an exists as an easy undefiner when -testing advice (when combined with `rotate-text'). - -\(fn SYMBOL ARGLIST &optional DOCSTRING &rest [WHERE PLACES...] BODY\)" - (declare (doc-string 3) (indent defun)) - (let (where-alist) - (unless (stringp docstring) - (push docstring body)) - (while (keywordp (car body)) - (push `(cons ,(pop body) (ensure-list ,(pop body))) - where-alist)) - `(dolist (targets (list ,@(nreverse where-alist))) - (dolist (target (cdr targets)) - (advice-remove target #',symbol))))) - -(defmacro defbackport! (type symbol &rest body) - "Backport a function/macro/alias from later versions of Emacs." - (declare (indent defun) (doc-string 4)) - (unless (fboundp (doom-unquote symbol)) - `(,type ,symbol ,@body))) - - -;; -;;; Backports - -;; `format-spec' wasn't autoloaded until 28.1 -(defbackport! autoload 'format-spec "format-spec") - -;; Introduced in Emacs 28.1 -(defbackport! defun ensure-list (object) - "Return OBJECT as a list. -If OBJECT is already a list, return OBJECT itself. If it's -not a list, return a one-element list containing OBJECT." - (declare (pure t) (side-effect-free t)) - (if (listp object) object (list object))) - -;; Introduced in Emacs 28.1 -(defbackport! defun always (&rest _args) - "Do nothing and return t. -This function accepts any number of ARGUMENTS, but ignores them. -Also see `ignore'." - t) - -;; Introduced in Emacs 28.1 -(defbackport! defun file-name-concat (directory &rest components) - "Append COMPONENTS to DIRECTORY and return the resulting string. - -Elements in COMPONENTS must be a string or nil. -DIRECTORY or the non-final elements in COMPONENTS may or may not end -with a slash -- if they don't end with a slash, a slash will be -inserted before contatenating." - (mapconcat - #'identity - (cl-loop for str in (cons directory components) - if (and str (/= 0 (length str)) - (if (string-suffix-p "/" str) - (substring str 0 -1) - str)) - collect it) - "/")) - -;; Introduced in Emacs 28.1 -(defbackport! defmacro with-environment-variables (variables &rest body) - "Set VARIABLES in the environment and execute BODY. -VARIABLES is a list of variable settings of the form (VAR VALUE), -where VAR is the name of the variable (a string) and VALUE -is its value (also a string). - -The previous values will be be restored upon exit." - (declare (indent 1) (debug (sexp body))) - (unless (consp variables) - (error "Invalid VARIABLES: %s" variables)) - `(let ((process-environment (copy-sequence process-environment))) - ,@(cl-loop for var in variables - collect `(setenv ,(car var) ,(cadr var))) - ,@body)) - -;; Introduced in Emacs 28.1 -(defbackport! defun file-name-with-extension (filename extension) - "Return FILENAME modified to have the specified EXTENSION. -The extension (in a file name) is the part that begins with the last \".\". -This function removes any existing extension from FILENAME, and then -appends EXTENSION to it. - -EXTENSION may include the leading dot; if it doesn't, this function -will provide it. - -It is an error if FILENAME or EXTENSION is empty, or if FILENAME -is in the form of a directory name according to `directory-name-p'. - -See also `file-name-sans-extension'." - (let ((extn (string-trim-left extension "[.]"))) - (cond ((string-empty-p filename) - (error "Empty filename")) - ((string-empty-p extn) - (error "Malformed extension: %s" extension)) - ((directory-name-p filename) - (error "Filename is a directory: %s" filename)) - ((concat (file-name-sans-extension filename) "." extn))))) - -;; Introduced in Emacs 29+ -(defbackport! defmacro with-memoization (place &rest code) - "Return the value of CODE and stash it in PLACE. -If PLACE's value is non-nil, then don't bother evaluating CODE -and return the value found in PLACE instead." - (declare (indent 1) (debug (gv-place body))) - (gv-letplace (getter setter) place - `(or ,getter - ,(macroexp-let2 nil val (macroexp-progn code) - `(progn - ,(funcall setter val) - ,val))))) - -;; Introduced in Emacs 29+ (emacs-mirror/emacs@f117b5df4dc6) -(defbackport! defalias 'bol #'line-beginning-position) -(defbackport! defalias 'eol #'line-end-position) - -(provide 'doom-lib) -;;; doom-lib.el ends here diff --git a/.config/emacs/lisp/doom-modules.el b/.config/emacs/lisp/doom-modules.el @@ -1,501 +0,0 @@ -;;; doom-modules.el --- module & package management system -*- lexical-binding: t; -*- -;;; Commentary: -;;; Code: - -;; -;;; Variables - -(defvar doom-modules (make-hash-table :test 'equal) - "A hash table of enabled modules. Set by `doom-initialize-modules'.") - -(defvar doom-modules-dirs - (list (expand-file-name "modules/" doom-user-dir) - doom-modules-dir) - "A list of module root directories. Order determines priority.") - -;;; Module file variables -(defvar doom-module-init-file "init.el" - "The filename for module early initialization config files. - -Init files are loaded early, just after Doom core, and before modules' config -files. They are always loaded, even in non-interactive sessions, and before -`doom-before-modules-init-hook'. Related to `doom-module-config-file'.") - -(defvar doom-module-config-file "config.el" - "The filename for module configuration files. - -Config files are loaded later, and almost always in interactive sessions. These -run before `doom-after-modules-config-hook' and after `doom-module-init-file'.") - -(defvar doom-module-packages-file "packages.el" - "The filename for the package configuration file. - -Package files are read whenever Doom's package manager wants a manifest of all -desired packages. They are rarely read in interactive sessions (unless the user -uses a straight or package.el command directly).") - -(defvar doom-module-metadata-file ".doommodule" - "The filename for a module's metadata file. - -NOT IMPLEMENTED YET. This file contains a module's metadata: their version, -maintainers, checks, features, submodules, debug information, etc. And are used -to locate modules in the user's file tree.") - -(defconst doom-obsolete-modules - '((:feature (version-control (:emacs vc) (:ui vc-gutter)) - (spellcheck (:checkers spell)) - (syntax-checker (:checkers syntax)) - (evil (:editor evil)) - (snippets (:editor snippets)) - (file-templates (:editor file-templates)) - (workspaces (:ui workspaces)) - (eval (:tools eval)) - (lookup (:tools lookup)) - (debugger (:tools debugger))) - (:tools (rotate-text (:editor rotate-text)) - (vterm (:term vterm)) - (password-store (:tools pass)) - (flycheck (:checkers syntax)) - (flyspell (:checkers spell)) - (macos (:os macos))) - (:emacs (electric-indent (:emacs electric)) - (hideshow (:editor fold)) - (eshell (:term eshell)) - (term (:term term))) - (:ui (doom-modeline (:ui modeline)) - (fci (:ui fill-column)) - (evil-goggles (:ui ophints)) - (tabbar (:ui tabs)) - (pretty-code (:ui ligatures))) - (:app (email (:email mu4e)) - (notmuch (:email notmuch))) - (:lang (perl (:lang raku)))) - "A tree alist that maps deprecated modules to their replacement(s). - -Each entry is a three-level tree. For example: - - (:feature (version-control (:emacs vc) (:ui vc-gutter)) - (spellcheck (:checkers spell)) - (syntax-checker (:tools flycheck))) - -This marks :feature version-control, :feature spellcheck and :feature -syntax-checker modules obsolete. e.g. If :feature version-control is found in -your `doom!' block, a warning is emitted before replacing it with :emacs vc and -:ui vc-gutter.") - -(defvar doom-inhibit-module-warnings (not noninteractive) - "If non-nil, don't emit deprecated or missing module warnings at startup.") - -;;; Custom hooks -(defcustom doom-before-modules-init-hook nil - "Hooks run before module init.el files are loaded." - :group 'doom - :type 'hook) - -(defcustom doom-after-modules-init-hook nil - "Hooks run after module init.el files are loaded." - :group 'doom - :type 'hook) - -(defcustom doom-before-modules-config-hook nil - "Hooks run before module config.el files are loaded." - :group 'doom - :type 'hook) - -(defcustom doom-after-modules-config-hook nil - "Hooks run after module config.el files are loaded (but before the user's)." - :group 'doom - :type 'hook) - - -;; -;;; `doom-module-context' - -(defvar doom--empty-module-context [nil nil nil nil nil nil nil]) - -(eval-and-compile - (setplist 'doom-module-context '(index 0 initdepth 1 configdepth 2 - group 3 name 4 flags 5 features 6))) -(defvar doom-module-context doom--empty-module-context - "A vector describing the module associated it with the active context. - -Contains the following: [INDEX INITDEPTH CONFIGDEPTH :GROUP MODULE FLAGS FEATURES] - -Do not directly set this variable, only let-bind it.") - -;; DEPRECATED: Remove this when byte-compilation is introduced to Doom core. -(defmacro doom-module--context-field (field) (get 'doom-module-context field)) - -(defun doom-module-context-get (field &optional context) - "Return the FIELD of CONTEXT. - -FIELD should be one of `index', `initdepth', `configdepth', `group', `name', -`flags', or `features'. CONTEXT should be a `doom-module-context' vector. If -omitted, defaults to `doom-module-context'." - (aref (or context doom-module-context) (get 'doom-module-context field))) - -(defun doom-module-context (group &optional name) - "Create a `doom-module-context' from a module by GROUP and NAME. - -If NAME is omitted, GROUP is treated as a module key cons cell: (GROUP . NAME)." - (declare (side-effect-free t)) - (let ((key (if name (cons group name) group))) - (or (get (or (car-safe key) key) - (cdr-safe key)) - doom--empty-module-context))) - -(defun doom-module-context-key (&optional context) - "Return the module of the active `doom-module-context' as a module key." - (declare (side-effect-free t)) - (let ((context (or context doom-module-context))) - (cons (aref context (doom-module--context-field group)) - (aref context (doom-module--context-field name))))) - -(defmacro doom-module-context-with (module-key &rest body) - "Evaluate BODY with `doom-module-context' informed by MODULE-KEY." - (declare (indent 1)) - `(let ((doom-module-context (doom-module-context ,module-key))) - (doom-log ":context:module: =%s" doom-module-context) - ,@body)) - - -;; -;;; Module API - -(defun doom-module-p (category module &optional flag) - "Returns t if CATEGORY MODULE is enabled (ie. present in `doom-modules')." - (declare (pure t) (side-effect-free t)) - (when-let (plist (gethash (cons category module) doom-modules)) - (or (null flag) - (and (memq flag (plist-get plist :flags)) - t)))) - -(defun doom-module-depth (category module &optional initdepth?) - "Return the depth of CATEGORY MODULE. - -If INITDEPTH? is non-nil, use the CAR if a module was given two depths (see -`doom-module-set')." - (if-let (depth (doom-module-get category module :depth)) - (or (if initdepth? - (car-safe depth) - (cdr-safe depth)) - depth) - 0)) - -(defun doom-module-get (category module &optional property) - "Returns the plist for CATEGORY MODULE. Gets PROPERTY, specifically, if set." - (declare (pure t) (side-effect-free t)) - (when-let (plist (gethash (cons category module) doom-modules)) - (if property - (plist-get plist property) - plist))) - -(defun doom-module-put (category module &rest plist) - "Set a PROPERTY for CATEGORY MODULE to VALUE. PLIST should be additional pairs -of PROPERTY and VALUEs. - -\(fn CATEGORY MODULE PROPERTY VALUE &rest [PROPERTY VALUE [...]])" - (puthash (cons category module) - (if-let (old-plist (doom-module-get category module)) - (if (null plist) - old-plist - (when (cl-oddp (length plist)) - (signal 'wrong-number-of-arguments (list (length plist)))) - (while plist - (plist-put old-plist (pop plist) (pop plist))) - old-plist) - plist) - doom-modules)) - -(defun doom-module-set (category module &rest plist) - "Enables a module by adding it to `doom-modules'. - -CATEGORY is a keyword, module is a symbol, PLIST is a plist that accepts the -following properties: - - :path STRING - Path to the directory where this module lives. - :depth INT|(INITDEPTH . CONFIGDEPTH) - Determines module load order. If a cons cell, INITDEPTH determines the load - order of the module's init.el, while CONFIGDEPTH determines the same for all - other config files (config.el, packages.el, doctor.el, etc). - :flags (SYMBOL...) - A list of activated flags for this module. - :features (SYMBOL...) - A list of active features, determined from module's metadata. NOT - IMPLEMENTED YET. - -If PLIST consists of a single nil, the module is purged from memory instead." - (if (car plist) - (let* ((depth (ensure-list (or (plist-get plist :depth) 0))) - (idepth (or (cdr depth) (car depth))) - (cdepth (car depth)) - (idx (hash-table-count doom-modules))) - ;; PERF: Doom caches module index, flags, and features in symbol plists - ;; for fast lookups in `modulep!' and elsewhere. plists are lighter - ;; and faster than hash tables for datasets this size, and this - ;; information is looked up *very* often. The structure of this cache - ;; should match `doom-module-context's. - (put category module - (vector idx idepth cdepth - category module - (plist-get plist :flags) - (plist-get plist :features))) - ;; The hash table will always been Doom's formal storage for - ;; modules. - (puthash (cons category module) plist doom-modules)) - (remhash (cons category module) doom-modules) - (cl-remf (symbol-plist category) module))) - -(defun doom-module-list (&optional paths-or-all initorder?) - "Return a list of (:group . name) module keys in order of their :depth. - -PATHS-OR-ALL can either be a non-nil value or a list of directories. If given a -list of directories, return a list of module keys for all modules present -underneath it. If non-nil, return the same, but search `doom-modules-dirs' -(includes :core and :user). Modules that are enabled are sorted first by their -:depth, followed by disabled modules in lexicographical order (unless a :depth -is specified in their .doommodule). - -If INITORDER? is non-nil, sort modules by their initdepth, rather than their -configdepth. See `doom-module-set' for details." - (sort (if paths-or-all - (delete-dups - (append (seq-remove #'cdr (doom-module-list nil initorder?)) - (doom-files-in (if (listp paths-or-all) - paths-or-all - doom-modules-dirs) - :map #'doom-module-from-path - :type 'dirs - :mindepth 1 - :depth 1))) - (hash-table-keys doom-modules)) - (let ((idx (if initorder? 1 2))) - (lambda! ((groupa . namea) (groupb . nameb)) - (let ((a (get groupa namea)) - (b (get groupb nameb))) - (or (null b) - (and - a (let ((adepth (aref a idx)) - (bdepth (aref b idx))) - (if (= adepth bdepth) - (< (aref a 0) (aref b 0)) - (< adepth bdepth)))))))))) - -(defun doom-module-expand-path (category module &optional file) - "Expands a path to FILE relative to CATEGORY and MODULE. - -CATEGORY is a keyword. MODULE is a symbol. FILE is an optional string path. -If the category isn't enabled this returns nil. For finding disabled modules use -`doom-module-locate-path'." - (when-let (path (doom-module-get category module :path)) - (if file - (file-name-concat path file) - path))) - -(defun doom-module-locate-path (category &optional module file) - "Searches `doom-modules-dirs' to find the path to a module. - -CATEGORY is a keyword (e.g. :lang) and MODULE is a symbol (e.g. 'python). FILE -is a string that will be appended to the resulting path. If no path exists, this -returns nil, otherwise an absolute path." - (let (file-name-handler-alist) - (if-let (path (doom-module-expand-path category module file)) - (if (or (null file) - (file-exists-p path)) - path) - (let* ((category (doom-keyword-name category)) - (module (if module (symbol-name module))) - (path (file-name-concat category module file))) - (if file - ;; PERF: locate-file-internal is a little faster for finding files, - ;; but its interface for finding directories is clumsy. - (locate-file-internal path doom-modules-dirs '("" ".elc" ".el")) - (cl-loop for default-directory in doom-modules-dirs - if (file-exists-p path) - return (expand-file-name path))))))) - -(defun doom-module-locate-paths (module-list file) - "Return all existing paths to FILE under each module in MODULE-LIST. - -MODULE-LIST is a list of cons cells (GROUP . NAME). See `doom-module-list' for -an example." - (cl-loop with file = (file-name-sans-extension file) - for (group . name) in module-list - if (doom-module-locate-path group name file) - collect it)) - -(defun doom-module-from-path (path &optional enabled-only) - "Returns a cons cell (CATEGORY . MODULE) derived from PATH (a file path). -If ENABLED-ONLY, return nil if the containing module isn't enabled." - (let* ((file-name-handler-alist nil) - (path (expand-file-name path))) - (save-match-data - (cond ((string-match "/modules/\\([^/]+\\)/\\([^/]+\\)\\(?:/.*\\)?$" path) - (when-let* ((category (doom-keyword-intern (match-string 1 path))) - (module (intern (match-string 2 path)))) - (and (or (null enabled-only) - (doom-module-p category module)) - (cons category module)))) - ((file-in-directory-p path doom-core-dir) - (cons :core nil)) - ((file-in-directory-p path doom-user-dir) - (cons :user nil)))))) - -(defun doom-module-load-path (&optional module-dirs) - "Return a list of file paths to activated modules. - -The list is in no particular order and its file paths are absolute. If -MODULE-DIRS is non-nil, include all modules (even disabled ones) available in -those directories." - (declare (pure t) (side-effect-free t)) - (cl-loop for (cat . mod) in (doom-module-list module-dirs) - collect (doom-module-locate-path cat mod))) - -(defun doom-module-mplist-map (fn mplist) - "Apply FN to each module in MPLIST." - (let ((mplist (copy-sequence mplist)) - (inhibit-message doom-inhibit-module-warnings) - obsolete - results - category m) - (while mplist - (setq m (pop mplist)) - (cond ((keywordp m) - (setq category m - obsolete (assq m doom-obsolete-modules))) - ((null category) - (error "No module category specified for %s" m)) - ((and (listp m) (keywordp (car m))) - (pcase (car m) - (:cond - (cl-loop for (cond . mods) in (cdr m) - if (eval cond t) - return (prependq! mplist mods))) - (:if (if (eval (cadr m) t) - (push (caddr m) mplist) - (prependq! mplist (cdddr m)))) - (test (if (xor (eval (cadr m) t) - (eq test :unless)) - (prependq! mplist (cddr m)))))) - ((catch 'doom-modules - (let* ((module (if (listp m) (car m) m)) - (flags (if (listp m) (cdr m)))) - (when-let (new (assq module obsolete)) - (let ((newkeys (cdr new))) - (if (null newkeys) - (print! (warn "%s module was removed")) - (if (cdr newkeys) - (print! (warn "%s module was removed and split into the %s modules") - (list category module) - (mapconcat #'prin1-to-string newkeys ", ")) - (print! (warn "%s module was moved to %s") - (list category module) - (car newkeys))) - (push category mplist) - (dolist (key newkeys) - (push (if flags - (nconc (cdr key) flags) - (cdr key)) - mplist) - (push (car key) mplist)) - (throw 'doom-modules t)))) - (push (funcall fn category module :flags (if (listp m) (cdr m))) - results)))))) - (when noninteractive - (setq doom-inhibit-module-warnings t)) - (nreverse results))) - - -;; -;;; Module config macros - -(put :if 'lisp-indent-function 2) -(put :when 'lisp-indent-function 'defun) -(put :unless 'lisp-indent-function 'defun) - -(defmacro doom! (&rest modules) - "Bootstraps DOOM Emacs and its modules. - -If the first item in MODULES doesn't satisfy `keywordp', MODULES is evaluated, -otherwise, MODULES is a multiple-property list (a plist where each key can have -multiple, linear values). - -The bootstrap process involves making sure the essential directories exist, core -packages are installed, `doom-autoloads-file' is loaded, `doom-packages-file' -cache exists (and is loaded) and, finally, loads your private init.el (which -should contain your `doom!' block). - -Module load order is determined by your `doom!' block. See `doom-modules-dirs' -for a list of all recognized module trees. Order defines precedence (from most -to least)." - `(when noninteractive - (doom-module-mplist-map - (lambda (category module &rest plist) - (let ((path (doom-module-locate-path category module))) - (unless path - (print! (warn "Failed to locate a '%s %s' module") category module)) - (apply #'doom-module-set category module - :path path - plist))) - ,@(if (keywordp (car modules)) - (list (list 'quote modules)) - modules)) - doom-modules)) - -;; DEPRECATED Remove in 3.0 -(define-obsolete-function-alias 'featurep! 'modulep! "3.0.0") - -(defmacro modulep! (category &optional module flag) - "Return t if :CATEGORY MODULE (and +FLAGS) are enabled. - -If FLAG is provided, returns t if CATEGORY MODULE has FLAG enabled. - - (modulep! :config default +flag) - -CATEGORY and MODULE may be omitted when this macro is used from a Doom module's -source (except your DOOMDIR, which is a special module). Like so: - - (modulep! +flag) - -For more about modules and flags, see `doom!'." - ;; PERF: This macro bypasses the module API to spare startup their runtime - ;; cost, as `modulep!' gets called *a lot* during startup. In the future, - ;; Doom will byte-compile its core files. At that time, we can use it again. - (and (cond (flag (memq flag (aref (or (get category module) doom--empty-module-context) - (doom-module--context-field flags)))) - (module (get category module)) - ((aref doom-module-context 0) - (memq category (aref doom-module-context - (doom-module--context-field flags)))) - ((let ((file - ;; This must be expanded at the call site, not in - ;; `modulep!'s definition, to get the file we want. - (macroexpand '(file!)))) - (if-let (module (doom-module-from-path file)) - (memq category (aref (or (get (car module) (cdr module)) - doom--empty-module-context) - (doom-module--context-field flags))) - (error "(modulep! %s %s %s) couldn't figure out what module it was called from (in %s)" - category module flag file))))) - t)) - - -;; -;;; Defaults - -;; Register Doom's two virtual module categories, representing Doom's core and -;; the user's config; which are always enabled. -(doom-module-set :core nil :path doom-core-dir :depth -110) -(doom-module-set :user nil :path doom-user-dir :depth '(-105 . 105)) - -;; DEPRECATED: I intend to phase out our internal usage of `use-package' and -;; move it to a :config use-package module. The macro is far too complex and -;; magical for our needs, but until this move is done, ':config use-package' -;; will remain a hardcoded module for backwards compatibility. -(doom-module-set :config 'use-package - :path (doom-module-locate-path :config 'use-package) - :depth -111) - -(provide 'doom-modules) -;;; doom-modules.el ends here diff --git a/.config/emacs/lisp/doom-packages.el b/.config/emacs/lisp/doom-packages.el @@ -1,647 +0,0 @@ -;;; lisp/doom-packages.el -*- lexical-binding: t; -*- -;;; Commentary: -;; -;; Emacs package management is opinionated, and so is Doom. Doom uses `straight' -;; to create a declarative, lazy-loaded, and (nominally) reproducible package -;; management system. We use `straight' over `package' because the latter is -;; tempermental. ELPA sources suffer downtime occasionally and often fail to -;; build packages when GNU Tar is unavailable (e.g. MacOS users start with BSD -;; tar). Known gnutls errors plague the current stable release of Emacs (26.x) -;; which bork TLS handshakes with ELPA repos (mainly gnu.elpa.org). See -;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3434. -;; -;; What's worse, you can only get the latest version of packages through ELPA. -;; In an ecosystem that is constantly changing, this is more frustrating than -;; convenient. Straight (and Doom) can do rolling release, but it is opt-in. -;; -;; Interacting with this package management system is done through Doom's -;; bin/doom script. Find out more about it by running 'doom help' (I highly -;; recommend you add the script to your PATH). Here are some highlights: -;; -;; - `doom install`: a wizard that guides you through setting up Doom and your -;; private config for the first time. -;; - `doom sync`: your go-to command for making sure Doom is in optimal -;; condition. It ensures all unneeded packages are removed, all needed ones -;; are installed, and all metadata associated with them is generated. -;; - `doom upgrade`: upgrades Doom Emacs and your packages to the latest -;; versions. There's also 'bin/doom sync -u' for updating only your packages. -;; -;; How this works is: the system reads packages.el files located in each -;; activated module, your private config (`doom-user-dir'), and one in -;; `doom-core-dir'. These contain `package!' declarations that tell DOOM what -;; packages to install and where from. -;; -;; All that said, you can still use package.el's commands, but 'doom sync' will -;; purge ELPA packages. -;; -;;; Code: - -(defvar doom-packages () - "A list of enabled packages. Each element is a sublist, whose CAR is the -package's name as a symbol, and whose CDR is the plist supplied to its -`package!' declaration. Set by `doom-initialize-packages'.") - -(defvar doom-disabled-packages () - "A list of packages that should be ignored by `use-package!' and `after!'.") - -(defvar doom-packages-file "packages" - "The basename of packages file for modules. - -Package files are read whenever Doom's package manager wants a manifest of all -desired packages. They are rarely read in interactive sessions (unless the user -uses a straight or package.el command directly).") - - -;; -;;; package.el - -;; Ensure that, if we do need package.el, it is configured correctly. You really -;; shouldn't be using it, but it may be convenient for quickly testing packages. -(setq package-enable-at-startup nil - package-user-dir (concat doom-local-dir "elpa/") - package-gnupghome-dir (expand-file-name "gpg" package-user-dir)) - -(after! package - (let ((s (if gnutls-verify-error "s" ""))) - (prependq! package-archives - ;; I omit Marmalade because its packages are manually submitted - ;; rather than pulled, and so often out of date. - `(("melpa" . ,(format "http%s://melpa.org/packages/" s)) - ("org" . ,(format "http%s://orgmode.org/elpa/" s)))))) - -;; Refresh package.el the first time you call `package-install', so it can still -;; be used (e.g. to temporarily test packages). Remember to run 'doom sync' to -;; purge them; they can conflict with packages installed via straight! -(add-transient-hook! 'package-install (package-refresh-contents)) - - -;; -;;; Straight - -(setq straight-base-dir (file-truename doom-local-dir) - straight-repository-branch "develop" - ;; Since byte-code is rarely compatible across different versions of - ;; Emacs, it's best we build them in separate directories, per emacs - ;; version. - straight-build-dir (format "build-%s" emacs-version) - straight-cache-autoloads nil ; we already do this, and better. - ;; Doom doesn't encourage you to modify packages in place. Disabling this - ;; makes 'doom sync' instant (once everything set up), which is much nicer - ;; UX than the several seconds modification checks. - straight-check-for-modifications nil - ;; We handle package.el ourselves (and a little more comprehensively) - straight-enable-package-integration nil - ;; Before switching to straight, `doom-local-dir' would average out at - ;; around 100mb with half Doom's modules at ~230 packages. Afterwards, at - ;; around 1gb. With shallow cloning, that is reduced to ~400mb. This has - ;; no affect on packages that are pinned, however (run 'doom purge' to - ;; compact those after-the-fact). Some packages break when shallow cloned - ;; (like magit and org), but we'll deal with that elsewhere. - straight-vc-git-default-clone-depth '(1 single-branch)) - -(with-eval-after-load 'straight - ;; HACK: Doom relies on deferred compilation, which spares the user 20-50min - ;; of compilation at install time, but subjects them to ~50% CPU activity - ;; when starting Emacs for the first time. To complete this, straight.el - ;; needs to be told not to do native-compilation, but it won't obey - ;; `straight-disable-native-compile'. - ;; - ;; It *will* obey `straight--native-comp-available', though. Trouble is: - ;; it's a constant; it resets itself when straight is loaded, so it must be - ;; changed afterwards. - (setq straight--native-comp-available nil) - ;; `let-alist' is built into Emacs 26 and onwards - (add-to-list 'straight-built-in-pseudo-packages 'let-alist)) - -(defadvice! doom--read-pinned-packages-a (fn &rest args) - "Read `:pin's in `doom-packages' on top of straight's lockfiles." - :around #'straight--lockfile-read-all - (append (apply fn args) ; lockfiles still take priority - (doom-package-pinned-list))) - -;; HACK: This fixes an issue present in recent builds of Emacs 29. See -;; emacs-mirror/emacs@0d383b592c2f. Straight.el uses `loaddefs-generate' if it -;; is available, which activates `emacs-lisp-mode' to read autoloads files, -;; but does so without suppressing its hooks. Some packages (like overseer) -;; add hooks to `emacs-lisp-mode-hook' in their autoloads, and once triggered, -;; they will try to load their dependencies (like dash or pkg-info), causing -;; file errors. -;; REVIEW: Report this upstream. -(defadvice! doom--fix-loaddefs-generate--parse-file-a (fn &rest args) - :around #'loaddefs-generate--parse-file - (let (emacs-lisp-mode-hook) - (apply fn args))) - - -;; -;;; native-comp - -(when (featurep 'native-compile) - (after! comp - ;; HACK Disable native-compilation for some troublesome packages - (mapc (doom-partial #'add-to-list 'native-comp-deferred-compilation-deny-list) - (list "/emacs-jupyter.*\\.el\\'" - "/evil-collection-vterm\\.el\\'" - "/vterm\\.el\\'" - "/with-editor\\.el\\'")))) - - -;; -;;; Bootstrappers - -(defun doom--ensure-straight (recipe pin) - (letenv! (("GIT_CONFIG" nil) - ("GIT_CONFIG_NOSYSTEM" "1") - ("GIT_CONFIG_GLOBAL" (or (getenv "DOOMGITCONFIG") - "/dev/null"))) - (let ((repo-dir (doom-path straight-base-dir "straight/repos/straight.el")) - (repo-url (concat "http" (if gnutls-verify-error "s") - "://github.com/" - (or (plist-get recipe :repo) "radian-software/straight.el"))) - (branch (or (plist-get recipe :branch) straight-repository-branch)) - (call (if init-file-debug - (lambda (&rest args) - (print! "%s" (cdr (apply #'doom-call-process args)))) - (lambda (&rest args) - (apply #'doom-call-process args))))) - (unless (file-directory-p repo-dir) - (save-match-data - (unless (executable-find "git") - (user-error "Git isn't present on your system. Cannot proceed.")) - (let* ((version (cdr (doom-call-process "git" "version"))) - (version - (and (string-match "\\_<[0-9]+\\.[0-9]+\\(\\.[0-9]+\\)\\_>" version) - (match-string 0 version)))) - (if version - (when (version< version "2.23") - (user-error "Git %s detected! Doom requires git 2.23 or newer!" - version))))) - (print! (start "Installing straight...")) - (print-group! - (cl-destructuring-bind (depth . options) - (ensure-list straight-vc-git-default-clone-depth) - (let ((branch-switch (if (memq 'single-branch options) - "--single-branch" - "--no-single-branch"))) - (cond - ((eq 'full depth) - (funcall call "git" "clone" "--origin" "origin" - branch-switch repo-url repo-dir)) - ((integerp depth) - (if (null pin) - (progn - (when (file-directory-p repo-dir) - (delete-directory repo-dir 'recursive)) - (funcall call "git" "clone" "--origin" "origin" repo-url - "--no-checkout" repo-dir - "--depth" (number-to-string depth) - branch-switch - "--no-tags" - "--branch" straight-repository-branch)) - (make-directory repo-dir 'recursive) - (let ((default-directory repo-dir)) - (funcall call "git" "init") - (funcall call "git" "branch" "-m" straight-repository-branch) - (funcall call "git" "remote" "add" "origin" repo-url - "--master" straight-repository-branch) - (funcall call "git" "fetch" "origin" pin - "--depth" (number-to-string depth) - "--no-tags") - (funcall call "git" "reset" "--hard" pin))))))))) - (require 'straight (concat repo-dir "/straight.el")) - (doom-log "Initializing recipes") - (mapc #'straight-use-recipes - '((org-elpa :local-repo nil) - (melpa :type git :host github - :repo "melpa/melpa" - :build nil) - (nongnu-elpa :type git - :repo "https://git.savannah.gnu.org/git/emacs/nongnu.git" - :local-repo "nongnu-elpa" - :build nil) - (gnu-elpa-mirror :type git :host github - :repo "emacs-straight/gnu-elpa-mirror" - :build nil) - (el-get :type git :host github - :repo "dimitri/el-get" - :build nil) - (emacsmirror-mirror :type git :host github - :repo "emacs-straight/emacsmirror-mirror" - :build nil)))))) - -(defun doom--ensure-core-packages (packages) - (doom-log "Installing core packages") - (dolist (package packages) - (let* ((name (car package)) - (repo (symbol-name name))) - (when-let (recipe (plist-get (cdr package) :recipe)) - (straight-override-recipe (cons name recipe)) - (when-let (local-repo (plist-get recipe :local-repo)) - (setq repo local-repo))) - (print-group! - ;; Only clone the package, don't build them. Straight hasn't been fully - ;; configured by this point. - (straight-use-package name nil t)) - ;; In case the package hasn't been built yet. - (or (member (directory-file-name (straight--build-dir (symbol-name name))) - load-path) - (add-to-list 'load-path (directory-file-name (straight--repos-dir repo))))))) - -(defun doom-initialize-core-packages (&optional force-p) - "Ensure `straight' is installed and was compiled with this version of Emacs." - (when (or force-p (null (bound-and-true-p straight-recipe-repositories))) - (doom-log "Initializing straight") - (let ((packages (doom-package-list '((:core))))) - (cl-destructuring-bind (&key recipe pin &allow-other-keys) - (alist-get 'straight packages) - (doom--ensure-straight recipe pin)) - (doom--ensure-core-packages - (seq-filter (fn! (eq (plist-get % :type) 'core)) - packages))))) - -(defun doom-initialize-packages (&optional force-p) - "Process all packages, essential and otherwise, if they haven't already been. - -If FORCE-P is non-nil, do it anyway. - -This ensures `doom-packages' is populated and `straight' recipes are properly -processed." - (doom-initialize-core-packages force-p) - (when (or force-p (not (bound-and-true-p package--initialized))) - (doom-log "Initializing package.el") - (require 'package) - (package-initialize) - (unless package--initialized - (error "Failed to initialize package.el"))) - (when (or force-p (null doom-packages)) - (doom-log "Initializing straight.el") - (setq doom-disabled-packages nil - doom-packages (doom-package-list)) - (let (packages) - (dolist (package doom-packages) - (cl-destructuring-bind - (name &key recipe disable ignore &allow-other-keys) package - (if ignore - (straight-override-recipe (cons name '(:type built-in))) - (if disable - (cl-pushnew name doom-disabled-packages) - (when recipe - (straight-override-recipe (cons name recipe))) - (appendq! packages (cons name (straight--get-dependencies name))))))) - (dolist (package (cl-delete-duplicates packages :test #'equal)) - (straight-register-package package) - (let ((name (symbol-name package))) - (add-to-list 'load-path (directory-file-name (straight--build-dir name))) - (straight--load-package-autoloads name)))))) - - -;; -;;; Package management API - -(defun doom-package-get (package &optional prop nil-value) - "Returns PACKAGE's `package!' recipe from `doom-packages'." - (let ((plist (cdr (assq package doom-packages)))) - (if prop - (if (plist-member plist prop) - (plist-get plist prop) - nil-value) - plist))) - -(defun doom-package-set (package prop value) - "Set PROPERTY in PACKAGE's recipe to VALUE." - (setf (alist-get package doom-packages) - (plist-put (alist-get package doom-packages) - prop value))) - -(defun doom-package-recipe (package &optional prop nil-value) - "Returns the `straight' recipe PACKAGE was registered with." - (let* ((recipe (straight-recipes-retrieve package)) - (plist (doom-plist-merge - (plist-get (alist-get package doom-packages) :recipe) - (cdr (if (memq (car recipe) '(quote \`)) - (eval recipe t) - recipe))))) - (if prop - (if (plist-member plist prop) - (plist-get plist prop) - nil-value) - plist))) - -(defun doom-package-recipe-repo (package) - "Resolve and return PACKAGE's (symbol) local-repo property." - (if-let* ((recipe (copy-sequence (doom-package-recipe package))) - (recipe (if (and (not (plist-member recipe :type)) - (memq (plist-get recipe :host) '(github gitlab bitbucket))) - (plist-put recipe :type 'git) - recipe)) - (repo (if-let (local-repo (plist-get recipe :local-repo)) - (directory-file-name local-repo) - (ignore-errors (straight-vc-local-repo-name recipe))))) - repo - (symbol-name package))) - -(defun doom-package-build-recipe (package &optional prop nil-value) - "Returns the `straight' recipe PACKAGE was installed with." - (let ((plist (nth 2 (gethash (symbol-name package) straight--build-cache)))) - (if prop - (if (plist-member plist prop) - (plist-get plist prop) - nil-value) - plist))) - -(defun doom-package-dependencies (package &optional recursive noerror) - "Return a list of dependencies for a package. - -If RECURSIVE is `tree', return a tree of dependencies. -If RECURSIVE is nil, only return PACKAGE's immediate dependencies. -If NOERROR, return nil in case of error." - (cl-check-type package symbol) - (let ((deps (straight-dependencies (symbol-name package)))) - (pcase recursive - (`tree deps) - (`t (flatten-list deps)) - (`nil (cl-remove-if #'listp deps))))) - -(defun doom-package-depending-on (package &optional noerror) - "Return a list of packages that depend on PACKAGE. - -If PACKAGE (a symbol) isn't installed, throw an error, unless NOERROR is -non-nil." - (cl-check-type package symbol) - ;; can't get dependencies for built-in packages - (unless (or (doom-package-build-recipe package) - noerror) - (error "Couldn't find %s, is it installed?" package)) - (straight-dependents (symbol-name package))) - -;;; Predicate functions -(defun doom-package-built-in-p (package) - "Return non-nil if PACKAGE (a symbol) is built-in." - (eq (doom-package-build-recipe package :type) - 'built-in)) - -(defun doom-package-installed-p (package) - "Return non-nil if PACKAGE (a symbol) is installed." - (file-directory-p (straight--build-dir (symbol-name package)))) - -(defun doom-package-is-type-p (package type) - "TODO" - (memq type (ensure-list (doom-package-get package :type)))) - -(defun doom-package-in-module-p (package category &optional module) - "Return non-nil if PACKAGE was installed by the user's private config." - (when-let (modules (doom-package-get package :modules)) - (or (and (not module) (assq :user modules)) - (member (cons category module) modules)))) - -(defun doom-package-backend (package) - "Return 'straight, 'builtin, 'elpa or 'other, depending on how PACKAGE is -installed." - (cond ((gethash (symbol-name package) straight--build-cache) - 'straight) - ((or (doom-package-built-in-p package) - (assq package package--builtins)) - 'builtin) - ((assq package package-alist) - 'elpa) - ((locate-library (symbol-name package)) - 'other))) - - -;;; Package getters -(defun doom-packages--read (file &optional noeval noerror) - (condition-case-unless-debug e - (with-temp-buffer ; prevent buffer-local state from propagating - (if (not noeval) - (load file noerror 'nomessage 'nosuffix) - (when (file-exists-p file) - (insert-file-contents file) - (with-syntax-table emacs-lisp-mode-syntax-table - ;; Scrape `package!' blocks from FILE for a comprehensive listing of - ;; packages used by this module. - (while (search-forward "(package!" nil t) - (let ((ppss (save-excursion (syntax-ppss)))) - ;; Don't collect packages in comments or strings - (unless (or (nth 3 ppss) - (nth 4 ppss)) - (goto-char (match-beginning 0)) - (cl-destructuring-bind (_ name . plist) - (read (current-buffer)) - (push (cons - name (plist-put - plist :modules - (list (doom-module-context-key)))) - doom-packages))))))))) - (user-error - (user-error (error-message-string e))) - (error - (signal 'doom-package-error - (list (doom-module-context-key) - file e))))) - -(defun doom-package-list (&optional module-list) - "Retrieve a list of explicitly declared packages from MODULE-LIST. - -If MODULE-LIST is omitted, read enabled module list in configdepth order (see -`doom-module-set'). Otherwise, MODULE-LIST may be any symbol (or t) to mean read -all modules in `doom-modules-dir', including :core and :user. MODULE-LIST may -also be a list of module keys." - (let ((module-list (cond ((null module-list) (doom-module-list)) - ((symbolp module-list) (doom-module-list 'all)) - (module-list))) - (packages-file doom-module-packages-file) - doom-disabled-packages - doom-packages) - (letf! (defun read-packages (key) - (doom-module-context-with key - (when-let (file (doom-module-locate-path - (car key) (cdr key) doom-module-packages-file)) - (doom-packages--read file nil 'noerror)))) - (doom-context-with 'packages - (let ((user? (assq :user module-list))) - (when user? - ;; We load the private packages file twice to populate - ;; `doom-disabled-packages' disabled packages are seen ASAP... - (let (doom-packages) - (read-packages (cons :user nil)))) - (mapc #'read-packages module-list) - ;; ...Then again to ensure privately overriden packages are properly - ;; overwritten. - (if user? (read-packages (cons :user nil))) - (nreverse doom-packages)))))) - -(defun doom-package-pinned-list () - "Return an alist mapping package names (strings) to pinned commits (strings)." - (let (alist) - (dolist (package doom-packages alist) - (cl-destructuring-bind (name &key disable ignore pin unpin &allow-other-keys) - package - (when (and (not ignore) - (not disable) - (or pin unpin)) - (setf (alist-get (file-name-nondirectory (doom-package-recipe-repo name)) - alist nil 'remove #'equal) - (unless unpin pin))))))) - -(defun doom-package-recipe-list () - "Return straight recipes for non-builtin packages with a local-repo." - (let (recipes) - (dolist (recipe (hash-table-values straight--recipe-cache)) - (cl-destructuring-bind (&key local-repo type &allow-other-keys) - recipe - (unless (or (null local-repo) - (eq type 'built-in)) - (push recipe recipes)))) - (nreverse recipes))) - - -;; -;;; Module package macros - -(cl-defmacro package! - (name &rest plist &key built-in recipe ignore _type _pin _disable) - "Declares a package and how to install it (if applicable). - -This macro is declarative and does not load nor install packages. It is used to -populate `doom-packages' with metadata about the packages Doom needs to keep -track of. - -Only use this macro in a module's packages.el file. - -Accepts the following properties: - - :type core|local|built-in|virtual - Specifies what kind of package this is. Can be a symbol or a list thereof. - `core' = this is a protected package and cannot be disabled! - `local' = this package is being modified in-place. This package's repo is - unshallowed and will be skipped when you update packages. - `built-in' = this package is already built-in (otherwise, will be - installed) - `virtual' = this package is not tracked by Doom's package manager. It won't - be installed or uninstalled. Use this to pin 2nd order dependencies. - :recipe RECIPE - Specifies a straight.el recipe to allow you to acquire packages from external - sources. See https://github.com/radian-software/straight.el#the-recipe-format - for details on this recipe. - :disable BOOL - Do not install or update this package AND disable all of its `use-package!' - and `after!' blocks. - :ignore FORM - Do not install this package. - :pin STR|nil - Pin this package to commit hash STR. Setting this to nil will unpin this - package if previously pinned. - :built-in BOOL|'prefer - Same as :ignore if the package is a built-in Emacs package. This is more to - inform help commands like `doom/help-packages' that this is a built-in - package. If set to 'prefer, the package will not be installed if it is - already provided by Emacs. - -Returns t if package is successfully registered, and nil if it was disabled -elsewhere." - (declare (indent defun)) - (when (and recipe (keywordp (car-safe recipe))) - (cl-callf plist-put plist :recipe `(quote ,recipe))) - ;; :built-in t is basically an alias for :ignore (locate-library NAME) - (when built-in - (when (and (not ignore) - (equal built-in '(quote prefer))) - (setq built-in `(locate-library ,(symbol-name name) nil (get 'load-path 'initial-value)))) - (cl-callf map-delete plist :built-in) - (cl-callf plist-put plist :ignore built-in)) - `(let* ((name ',name) - (plist (cdr (assq name doom-packages))) - (dir (dir!)) - (module (doom-module-from-path dir))) - (unless (doom-context-p 'packages) - (signal 'doom-module-error - (list module "package! can only be used in packages.el files"))) - ;; Record what module this declaration was found in - (let ((module-list (plist-get plist :modules))) - (unless (member module module-list) - (cl-callf plist-put plist :modules - (append module-list - (list module) - (when (file-in-directory-p dir doom-user-dir) - '((:user . modules))) - nil)))) - ;; Merge given plist with pre-existing one - (cl-loop for (key value) on (list ,@plist) by 'cddr - when value - do (cl-callf plist-put plist key value)) - ;; Some basic key validation; throws an error on invalid properties - (condition-case e - (when-let (recipe (plist-get plist :recipe)) - (cl-destructuring-bind - (&key local-repo _files _flavor _build _pre-build _post-build - _includes _type _repo _host _branch _protocol _remote - _nonrecursive _fork _depth _source _inherit) - recipe - ;; Expand :local-repo from current directory - (when local-repo - (cl-callf plist-put plist :recipe - (plist-put recipe :local-repo - (let ((local-path (expand-file-name local-repo dir))) - (if (file-directory-p local-path) - local-path - local-repo))))))) - (error - (signal 'doom-package-error - (cons ,(symbol-name name) - (error-message-string e))))) - ;; These are the only side-effects of this macro! - (setf (alist-get name doom-packages) plist) - (if (plist-get plist :disable) - (add-to-list 'doom-disabled-packages name) - (with-no-warnings - (cons name plist))))) - -(defmacro disable-packages! (&rest packages) - "A convenience macro for disabling packages in bulk. -Only use this macro in a module's (or your private) packages.el file." - (macroexp-progn - (mapcar (lambda (p) `(package! ,p :disable t)) - packages))) - -(defmacro unpin! (&rest targets) - "Unpin packages in TARGETS. - -This unpins packages, so that 'doom upgrade' downloads their latest version. It -can be used one of five ways: - -- To disable pinning wholesale: (unpin! t) -- To unpin individual packages: (unpin! packageA packageB ...) -- To unpin all packages in a group of modules: (unpin! :lang :tools ...) -- To unpin packages in individual modules: - (unpin! (:lang python javascript) (:tools docker)) - -Or any combination of the above. - -This macro should only be used from the user's private packages.el. No module -should use it!" - (if (memq t targets) - `(mapc (doom-rpartial #'doom-package-set :unpin t) - (mapcar #'car doom-packages)) - (macroexp-progn - (mapcar - (lambda (target) - (when target - `(doom-package-set ',target :unpin t))) - (cl-loop for target in targets - if (or (keywordp target) (listp target)) - append - (cl-loop with (category . modules) = (ensure-list target) - for (name . plist) in doom-packages - for pkg-modules = (plist-get plist :modules) - if (and (assq category pkg-modules) - (or (null modules) - (cl-loop for module in modules - if (member (cons category module) pkg-modules) - return t)) - name) - collect it) - else if (symbolp target) - collect target))))) - -(provide 'doom-packages) -;;; doom-packages.el ends here diff --git a/.config/emacs/lisp/doom-profiles.el b/.config/emacs/lisp/doom-profiles.el @@ -1,458 +0,0 @@ -;;; lisp/doom-profiles.el -*- lexical-binding: t; -*- -;;; Commentary: -;;; Code: -(eval-when-compile (require 'doom)) ; be silent, o'byte-compiler - - -;; -;;; Variables - -;;; File/directory variables -(defvar doom-profiles-generated-dir doom-data-dir - "Where generated profiles are kept. - -Profile directories are in the format {data-profiles-dir}/$NAME/@/$VERSION, for -example: '~/.local/share/doom/_/@/0/'") - -(defvar doom-profile-load-path - (if-let (path (getenv-internal "DOOMPROFILELOADPATH")) - (mapcar #'expand-file-name (split-string-and-unquote path path-separator)) - (list (file-name-concat doom-user-dir "profiles.el") - (file-name-concat doom-emacs-dir "profiles.el") - (expand-file-name "doom-profiles.el" (or (getenv "XDG_CONFIG_HOME") "~/.config")) - (expand-file-name "~/.doom-profiles.el") - (file-name-concat doom-user-dir "profiles") - (file-name-concat doom-emacs-dir "profiles"))) - "A list of profile config files or directories that house implicit profiles. - -`doom-profiles-initialize' loads and merges all profiles defined in the above -files/directories, then writes a profile load script to -`doom-profile-load-file'. - -Can be changed externally by setting $DOOMPROFILELOADPATH to a colon-delimited -list of paths or profile config files (semi-colon delimited on Windows).") - -(defvar doom-profile-load-file - (if-let (loader (getenv-internal "DOOMPROFILELOADFILE")) - (expand-file-name loader doom-emacs-dir) - (file-name-concat doom-emacs-dir (format "profiles/load.el" emacs-major-version))) - "Where Doom writes its interactive profile loader script. - -Can be changed externally by setting $DOOMPROFILELOADFILE.") - -(defvar doom-profile-init-file-name (format "init.%d.el" emacs-major-version) - "TODO") - -(defvar doom-profile-init-dir-name (format "init.%d.d" emacs-major-version) - "The subdirectory of `doom-profile-dir'") - -(defvar doom-profiles-config-file-name ".doomprofile" - "TODO") - -;;; Profile storage variables -(defvar doom-profile-generators - '(("05-init-vars.auto.el" . doom-profile--generate-init-vars) - ("80-loaddefs.auto.el" . doom-profile--generate-doom-autoloads) - ("90-loaddefs-packages.auto.el" . doom-profile--generate-package-autoloads) - ("95-load-modules.auto.el" . doom-profile--generate-load-modules)) - "An alist mapping file names to generator functions. - -The file will be generated in `doom-profile-dir'/`doom-profile-init-dir-name', -and later combined into `doom-profile-dir'/`doom-profile-init-file-name' in -lexicographical order. These partials are left behind in case the use wants to -load them directly (for whatever use), or for commands to use (e.g. -`doom/reload-autoloads' loads any file with a NN-loaddefs[-.] prefix to -accomplish its namesake). - -Files with an .auto.el suffix will be automatically deleted whenever the profile -is regenerated. Users (or Doom CLIs, like `doom env') may add their own -generators to this list, or to `doom-profile-dir'/`doom-profile-init-dir-name', -and they will be included in the profile init file next time `doom sync' is -run.") - -(defvar doom--profiles ()) - -(defconst doom-profile-default (cons "_" "0")) - - -;; -;;; Helpers - -(defun doom-profiles-bootloadable-p () - "Return non-nil if `doom-emacs-dir' can be a bootloader." - (with-memoization (get 'doom 'bootloader) - (or (file-equal-p doom-emacs-dir "~/.config/emacs") - (file-equal-p doom-emacs-dir "~/.emacs.d")))) - -(defun doom-profiles-read (&rest paths) - "TODO" - (let (profiles) - (dolist (path (delq nil (flatten-list paths))) - (cond - ((file-directory-p path) - (setq path (file-truename path)) - (dolist (subdir (doom-files-in path :depth 0 :match "/[^.][^/]+$" :type 'dirs :map #'file-name-base)) - (if (equal subdir (car doom-profile-default)) - (signal 'doom-profile-error (list (file-name-concat path subdir) "Implicit profile has invalid name")) - (unless (string-prefix-p "_" subdir) - (cl-pushnew - (cons (intern subdir) - (let* ((val (abbreviate-file-name (file-name-as-directory subdir))) - (val (if (file-name-absolute-p val) - `(,val) - `(,(abbreviate-file-name path) ,val)))) - (cons `(user-emacs-directory :path ,@val) - (if-let (profile-file (file-exists-p! doom-profiles-config-file-name path)) - (car (doom-file-read profile-file :by 'read*)) - (when (file-exists-p (doom-path path subdir "lisp/doom.el")) - '((doom-user-dir :path ,@val))))))) - profiles - :test #'eq - :key #'car))))) - ((file-exists-p path) - (dolist (profile (car (doom-file-read path :by 'read*))) - (if (eq (symbol-name (car profile)) (car doom-profile-default)) - (signal 'doom-profile-error (list path "Profile has invalid name: _")) - (unless (string-prefix-p "_" (symbol-name (car profile))) - (cl-pushnew profile profiles - :test #'eq - :key #'car))))))) - (nreverse profiles))) - -(defun doom-profiles-autodetect (&optional _internal?) - "Return all known profiles as a nested alist. - -This reads all profile configs and directories in `doom-profile-load-path', then -caches them in `doom--profiles'. If RELOAD? is non-nil, refresh the cache." - (doom-profiles-read doom-profile-load-path - ;; TODO: Add in v3 - ;; (if internal? doom-profiles-generated-dir) - )) - -(defun doom-profiles-outdated-p () - "Return non-nil if files in `doom-profile-load-file' are outdated." - (cl-loop for path in doom-profile-load-path - when (string-suffix-p path ".el") - if (or (not (file-exists-p doom-profile-load-file)) - (file-newer-than-file-p path doom-profile-load-file) - (not (equal (doom-file-read doom-profile-load-file :by 'read) - doom-version))) - return t)) - -(defun doom-profile<-id (id) - "Return a (NAME . VERSION) profile cons cell from an id string NAME@VERSION." - (save-match-data - (if (string-match "^\\([^@]+\\)@\\(.+\\)$" id) - (cons (match-string 1 id) - (match-string 2 id)) - (cons id (cdr doom-profile-default))))) - -(defun doom-profile->id (profile) - "Return a NAME@VERSION id string from profile cons cell (NAME . VERSION)." - (cl-check-type profile cons) - (format "%s@%s" (car profile) (cdr profile))) - -;; TODO (defun doom-profile--read (profile) -;; (doom-profile-create )) - -;; TODO (defun doom-profile-initialize (profile-name &optional ref) -;; ) - -(defun doom-profiles-save (profiles &optional file) - "Generate a profile bootstrapper for Doom to load at startup." - (unless file - (setq file doom-profile-load-file)) - (doom-file-write - file (let ((profilesym (make-symbol "profile")) - (deferredsym (make-symbol "deferred-vars"))) - `(";; -*- lexical-binding: t; tab-width: 8; -*-\n" - ";; Updated: " ,(format-time-string "%Y-%m-%d %H:%M:%S") "\n" - ";; Generated by 'doom profiles sync' or 'doom sync'.\n" - ";; DO NOT EDIT THIS BY HAND!\n" - ,(format "%S" doom-version) - (pcase (intern (getenv-internal "DOOMPROFILE")) - ,@(cl-loop - for (profile-name . bindings) in profiles - for deferred? - = (seq-find (fn! (and (memq (car-safe (cdr %)) '(:prepend :prepend? :append :append?)) - (not (stringp (car-safe %))))) - bindings) - collect - `(',profile-name - (let ,(if deferred? '(--deferred-vars--)) - ,@(cl-loop - for (var . val) in bindings - collect - (pcase (car-safe val) - (:path - `(,(if (stringp var) 'setenv 'setq) - ,var ,(cl-loop with form = `(expand-file-name ,(cadr val) user-emacs-directory) - for dir in (cddr val) - do (setq form `(expand-file-name ,dir ,form)) - finally return form))) - (:eval - (if (eq var '_) - (macroexp-progn (cdr val)) - `(,(if (stringp var) 'setenv 'setq) - ,var ,(macroexp-progn (cdr val))))) - (:plist - `(,(if (stringp var) 'setenv 'setq) - ,var ',(if (stringp var) - (prin1-to-string (cadr val)) - (cadr val)))) - ((or :prepend :prepend?) - (if (stringp var) - `(setenv ,var (concat ,val (getenv ,var))) - (setq deferred? t) - `(push (cons ',var - (lambda () - (dolist (item (list ,@(cdr val))) - ,(if (eq (car val) :append?) - `(add-to-list ',var item) - `(push item ,var))))) - --deferred-vars--))) - ((or :append :append?) - (if (stringp var) - `(setenv ,var (concat (getenv ,var) ,val)) - (setq deferred? t) - `(push (cons ',var - (lambda () - (dolist (item (list ,@(cdr val))) - ,(if (eq (car val) :append?) - `(add-to-list ',var item 'append) - `(set ',var (append ,var (list item))))))) - --deferred-vars--))) - (_ `(,(if (stringp var) 'setenv 'setq) ,var ',val)))) - ,@(when deferred? - `((defun --doom-profile-set-deferred-vars-- (_) - (dolist (var --deferred-vars--) - (when (boundp (car var)) - (funcall (cdr var)) - (setq --deferred-vars-- (delete var --deferred-vars--)))) - (unless --deferred-vars-- - (remove-hook 'after-load-functions #'--doom-profile-set-deferred-vars--) - (unintern '--doom-profile-set-deferred-vars-- obarray))) - (add-hook 'after-load-functions #'--doom-profile-set-deferred-vars--) - (--doom-profile-set-deferred-vars-- nil))))))) - ;; `user-emacs-directory' requires that it end in a directory - ;; separator, but users may forget this in their profile configs. - (setq user-emacs-directory (file-name-as-directory user-emacs-directory)))) - :mode #o600 - :printfn #'pp) - (print-group! - (or (let ((byte-compile-warnings (if init-file-debug byte-compile-warnings)) - (byte-compile-dest-file-function - (lambda (_) (format "%s.%d.elc" (file-name-sans-extension file) emacs-major-version)))) - (byte-compile-file file)) - ;; Do it again? So the errors/warnings are visible? - ;; (let ((byte-compile-warnings t)) - ;; (byte-compile-file file)) - (signal 'doom-profile-error (list file "Failed to byte-compile bootstrap file"))))) - -(defun doom-profile-p (profile-name) - "Return t if PROFILE-NAME is a valid and existing profile." - (when (stringp profile-name) - (setq profile-name (intern profile-name))) - (and (assq profile-name (doom-profiles)) - t)) - -(defun doom-profile-get (profile-name &optional property null-value) - "Return PROFILE-NAME's PROFILE, otherwise its PROPERTY, otherwise NULL-VALUE." - (when (stringp profile-name) - (setq profile-name (intern profile-name))) - (if-let (profile (assq profile-name (doom-profiles))) - (if property - (if-let (propval (assq property (cdr profile))) - (cdr propval) - null-value) - profile) - null-value)) - -(defun doom-profile-emacs-dir (profile-name) - "Return the `user-emacs-directory' for PROFILE-NAME. - -If the profile doesn't specify one, fall back to `doom-emacs-dir'." - (doom-profile-get profile-name 'user-emacs-directory doom-emacs-dir)) - -(defun doom-profile-init-file (&optional profile-id version) - "Return the init file for PROFILE-ID at VERSION. - -Defaults to the profile at `doom-profile-default'." - (cl-destructuring-bind (profile . version) - (if (and (stringp profile-id) (null version)) - (doom-profile<-id profile-id) - (cl-check-type profile-id (or null string)) - (cl-check-type version (or null string)) - (cons (or profile-id ;; (car doom-profile-default) - ) - (or version ;; (cdr doom-profile-default) - ))) - (file-name-concat doom-data-dir - profile "@" version - (format doom-profile-init-file-name emacs-major-version)))) - - -;; -;;; Data structures - -;; TODO - - -;; -;;; API - -;; TODO (defun doom-profile-create (name)) - -;; TODO (defun doom-profile-hash (profile)) - -;; TODO (defmacro with-profile! (profile &rest body)) - - -;; -;;; Generators - -(defun doom-profile-generate (&optional _profile regenerate-only?) - "Generate profile init files." - (doom-initialize-packages) - (let* ((default-directory doom-profile-dir) - (init-dir doom-profile-init-dir-name) - (init-file doom-profile-init-file-name)) - (print! (start "(Re)building profile in %s/...") (dirname doom-profile-dir)) - (condition-case-unless-debug e - (with-file-modes #o750 - (print-group! - (make-directory init-dir t) - (print! (start "Deleting old init files...")) - (print-group! :level 'info - (cl-loop for file in (cons init-file (doom-glob "*.elc")) - if (file-exists-p file) - do (print! (item "Deleting %s...") file) - and do (delete-file file))) - (let ((auto-files (doom-glob init-dir "*.auto.el"))) - (print! (start "Generating %d init files...") (length doom-profile-generators)) - (print-group! :level 'info - (dolist (file auto-files) - (print! (item "Deleting %s...") file) - (delete-file file)) - (pcase-dolist (`(,file . ,fn) doom-profile-generators) - (let ((file (doom-path init-dir file))) - (doom-log "Building %s..." file) - (doom-file-write file (funcall fn)))))) - (with-file! init-file - (insert ";; -*- coding: utf-8; lexical-binding: t; -*-\n" - ";; This file was autogenerated; do not edit it by hand!\n") - ;; Doom needs to be synced/rebuilt if either Doom or Emacs has been - ;; up/downgraded. This is because byte-code isn't backwards - ;; compatible, and many packages (including Doom), make in absolute - ;; paths into their caches that need to be refreshed. - (prin1 `(unless (equal doom-version ,doom-version) - (error ,(concat - "The installed version of Doom (%s) has changed (to %s) since last " - "'doom sync'. Run 'doom sync' to bring Doom up to speed") - ,doom-version doom-version)) - (current-buffer)) - (dolist (file (doom-glob init-dir "*.el")) - (print-group! :level 'info - (print! (start "Reading %s...") file)) - (doom-file-read file :by 'insert))) - (print! (start "Byte-compiling %s...") (relpath init-file)) - (print-group! - (let ((byte-compile-warnings (if init-file-debug '(suspicious make-local callargs)))) - (byte-compile-file init-file))) - (print! (success "Built %s") (byte-compile-dest-file init-file)))) - (error (delete-file init-file) - (delete-file (byte-compile-dest-file init-file)) - (signal 'doom-autoload-error (list init-file e)))))) - -(defun doom-profile--generate-init-vars () - ;; FIX: Make sure this only runs at startup to protect us Emacs' interpreter - ;; re-evaluating this file when lazy-loading dynamic docstrings from the - ;; byte-compiled init file. - `((when (doom-context-p 'init) - ,@(cl-loop for var in doom-autoloads-cached-vars - if (boundp var) - collect `(set-default ',var ',(symbol-value var))) - ,@(cl-loop with v = (version-to-list doom-version) - with ref = (doom-call-process "git" "-C" (doom-path doom-emacs-dir) "rev-parse" "HEAD") - with branch = (doom-call-process "git" "-C" (doom-path doom-emacs-dir) "branch" "--show-current") - for (var . val) - in `((major . ,(nth 0 v)) - (minor . ,(nth 1 v)) - (build . ,(nth 2 v)) - (tag . ,(ignore-errors (cadr (split-string doom-version "-" t)))) - (ref . ,(if (zerop (car ref)) (cdr ref))) - (branch . ,(if (zerop (car branch)) (cdr branch)))) - collect `(put 'doom-version ',var ',val))))) - -(defun doom-profile--generate-load-modules () - (let* ((init-modules-list (doom-module-list nil t)) - (config-modules-list (doom-module-list)) - (pre-init-modules - (seq-filter (fn! (<= (doom-module-depth (car %) (cdr %) t) -100)) - (remove '(:user) init-modules-list))) - (init-modules - (seq-filter (fn! (<= 0 (doom-module-depth (car %) (cdr %) t) 100)) - init-modules-list)) - (config-modules - (seq-filter (fn! (<= 0 (doom-module-depth (car %) (cdr %)) 100)) - config-modules-list)) - (post-config-modules - (seq-filter (fn! (>= (doom-module-depth (car %) (cdr %)) 100)) - config-modules-list)) - (init-file doom-module-init-file) - (config-file doom-module-config-file)) - (letf! ((defun module-loader (group name file &optional noerror) - (doom-module-context-with (cons group name) - `(let ((doom-module-context ,doom-module-context)) - (doom-load ,(abbreviate-file-name (file-name-sans-extension file)))))) - (defun module-list-loader (modules file &optional noerror) - (cl-loop for (cat . mod) in modules - if (doom-module-locate-path cat mod file) - collect (module-loader cat mod it noerror)))) - ;; FIX: Same as above (see `doom-profile--generate-init-vars'). - `((if (or (doom-context-p 'init) - (doom-context-p 'reload)) - (doom-context-with 'modules - (set 'doom-modules ',doom-modules) - (set 'doom-disabled-packages ',doom-disabled-packages) - ;; Cache module state and flags in symbol plists for quick lookup by - ;; `modulep!' later. - ,@(cl-loop - for (category . modules) in (seq-group-by #'car config-modules-list) - collect - `(setplist ',category - (quote ,(cl-loop for (_ . module) in modules - nconc `(,module ,(get category module)))))) - (let ((old-custom-file custom-file)) - ,@(module-list-loader pre-init-modules init-file) - (doom-run-hooks 'doom-before-modules-init-hook) - ,@(module-list-loader init-modules init-file) - (doom-run-hooks 'doom-after-modules-init-hook) - (doom-run-hooks 'doom-before-modules-config-hook) - ,@(module-list-loader config-modules config-file) - (doom-run-hooks 'doom-after-modules-config-hook) - ,@(module-list-loader post-config-modules config-file t) - (when (eq custom-file old-custom-file) - (doom-load custom-file 'noerror))))))))) - -(defun doom-profile--generate-doom-autoloads () - (doom-autoloads--scan - (append (doom-glob doom-core-dir "lib/*.el") - (cl-loop for dir - in (append (doom-module-load-path doom-modules-dirs) - (list doom-user-dir)) - if (doom-glob dir "autoload.el") collect (car it) - if (doom-glob dir "autoload/*.el") append it) - (mapcan #'doom-glob doom-autoloads-files)) - nil)) - -(defun doom-profile--generate-package-autoloads () - (doom-autoloads--scan - (mapcar #'straight--autoloads-file - (seq-difference (hash-table-keys straight--build-cache) - doom-autoloads-excluded-packages)) - doom-autoloads-excluded-files - 'literal)) - -(provide 'doom-profiles) -;;; doom-profiles.el ends here diff --git a/.config/emacs/lisp/doom-projects.el b/.config/emacs/lisp/doom-projects.el @@ -1,315 +0,0 @@ -;;; doom-projects.el --- defaults for project management in Doom -*- lexical-binding: t; -*- -;;; Commentary: -;;; Code: - -(defvar doom-projectile-cache-limit 10000 - "If any project cache surpasses this many files it is purged when quitting -Emacs.") - -(defvar doom-projectile-cache-blacklist '("~" "/tmp" "/") - "Directories that should never be cached.") - -(defvar doom-projectile-cache-purge-non-projects nil - "If non-nil, non-projects are purged from the cache on `kill-emacs-hook'.") - -(defvar doom-projectile-fd-binary - (cl-find-if #'executable-find (list "fdfind" "fd")) - "The filename of the `fd' executable. On some distros it's 'fdfind' (ubuntu, -debian, and derivatives). On most it's 'fd'.") - -(defvar doom-projects--fd-version nil) - - -;; -;;; Packages - -(use-package! projectile - :commands (projectile-project-root - projectile-project-name - projectile-project-p - projectile-locate-dominating-file - projectile-relevant-known-projects) - :init - (setq projectile-cache-file (concat doom-cache-dir "projectile.cache") - ;; Auto-discovery is slow to do by default. Better to update the list - ;; when you need to (`projectile-discover-projects-in-search-path'). - projectile-auto-discover nil - projectile-enable-caching (not noninteractive) - projectile-globally-ignored-files '(".DS_Store" "TAGS") - projectile-globally-ignored-file-suffixes '(".elc" ".pyc" ".o") - projectile-kill-buffers-filter 'kill-only-files - projectile-known-projects-file (concat doom-cache-dir "projectile.projects") - projectile-ignored-projects '("~/") - projectile-ignored-project-function #'doom-project-ignored-p) - - (global-set-key [remap evil-jump-to-tag] #'projectile-find-tag) - (global-set-key [remap find-tag] #'projectile-find-tag) - - :config - ;; HACK: Projectile cleans up the known projects list at startup. If this list - ;; contains tramp paths, the `file-remote-p' calls will pull in tramp via - ;; its `file-name-handler-alist' entry, which is expensive. Since Doom - ;; already cleans up the project list on kill-emacs-hook, it's simplest to - ;; inhibit this cleanup process at startup (see bbatsov/projectile#1649). - (letf! ((#'projectile--cleanup-known-projects #'ignore)) - (projectile-mode +1)) - ;; HACK: Auto-discovery and cleanup on `projectile-mode' is slow and - ;; premature. Let's try to defer it until it's needed. - (add-transient-hook! 'projectile-relevant-known-projects - (projectile--cleanup-known-projects) - (when projectile-auto-discover - (projectile-discover-projects-in-search-path))) - - ;; Projectile runs four functions to determine the root (in this order): - ;; - ;; + `projectile-root-local' -> checks the `projectile-project-root' variable - ;; for an explicit path. - ;; + `projectile-root-bottom-up' -> searches from / to your current directory - ;; for the paths listed in `projectile-project-root-files-bottom-up'. This - ;; includes .git and .project - ;; + `projectile-root-top-down' -> searches from the current directory down to - ;; / the paths listed in `projectile-root-files', like package.json, - ;; setup.py, or Cargo.toml - ;; + `projectile-root-top-down-recurring' -> searches from the current - ;; directory down to / for a directory that has one of - ;; `projectile-project-root-files-top-down-recurring' but doesn't have a - ;; parent directory with the same file. - ;; - ;; In the interest of performance, we reduce the number of project root marker - ;; files/directories projectile searches for when resolving the project root. - (setq projectile-project-root-files-bottom-up - (append '(".projectile" ; projectile's root marker - ".project" ; doom project marker - ".git") ; Git VCS root dir - (when (executable-find "hg") - '(".hg")) ; Mercurial VCS root dir - (when (executable-find "bzr") - '(".bzr"))) ; Bazaar VCS root dir - ;; This will be filled by other modules. We build this list manually so - ;; projectile doesn't perform so many file checks every time it resolves - ;; a project's root -- particularly when a file has no project. - projectile-project-root-files '() - projectile-project-root-files-top-down-recurring '("Makefile")) - - (push (abbreviate-file-name doom-local-dir) projectile-globally-ignored-directories) - - ;; Per-project compilation buffers - (setq compilation-buffer-name-function #'projectile-compilation-buffer-name - compilation-save-buffers-predicate #'projectile-current-project-buffer-p) - - ;; Support the more generic .project files as an alternative to .projectile - (defadvice! doom--projectile-dirconfig-file-a () - :override #'projectile-dirconfig-file - (cond ((file-exists-p! (or ".projectile" ".project") (projectile-project-root))) - ((expand-file-name ".project" (projectile-project-root))))) - - ;; Disable commands that won't work, as is, and that Doom already provides a - ;; better alternative for. - (put 'projectile-ag 'disabled "Use +default/search-project instead") - (put 'projectile-ripgrep 'disabled "Use +default/search-project instead") - (put 'projectile-grep 'disabled "Use +default/search-project instead") - - ;; Treat current directory in dired as a "file in a project" and track it - (add-hook 'dired-before-readin-hook #'projectile-track-known-projects-find-file-hook) - - ;; Accidentally indexing big directories like $HOME or / will massively bloat - ;; projectile's cache (into the hundreds of MBs). This purges those entries - ;; when exiting Emacs to prevent slowdowns/freezing when cache files are - ;; loaded or written to. - (add-hook! 'kill-emacs-hook - (defun doom-cleanup-project-cache-h () - "Purge projectile cache entries that: - -a) have too many files (see `doom-projectile-cache-limit'), -b) represent blacklisted directories that are too big, change too often or are - private. (see `doom-projectile-cache-blacklist'), -c) are not valid projectile projects." - (when (and (bound-and-true-p projectile-projects-cache) - projectile-enable-caching) - (setq projectile-known-projects - (cl-remove-if #'projectile-ignored-project-p - projectile-known-projects)) - (projectile-cleanup-known-projects) - (cl-loop with blacklist = (mapcar #'file-truename doom-projectile-cache-blacklist) - for proot in (hash-table-keys projectile-projects-cache) - if (or (not (stringp proot)) - (string-empty-p proot) - (>= (length (gethash proot projectile-projects-cache)) - doom-projectile-cache-limit) - (member (substring proot 0 -1) blacklist) - (and doom-projectile-cache-purge-non-projects - (not (doom-project-p proot))) - (projectile-ignored-project-p proot)) - do (doom-log "Removed %S from projectile cache" proot) - and do (remhash proot projectile-projects-cache) - and do (remhash proot projectile-projects-cache-time) - and do (remhash proot projectile-project-type-cache)) - (projectile-serialize-cache)))) - - ;; Some MSYS utilities auto expanded the `/' path separator, so we need to prevent it. - (when IS-WINDOWS - (setenv "MSYS_NO_PATHCONV" "1") ; Fix path in Git Bash - (setenv "MSYS2_ARG_CONV_EXCL" "--path-separator")) ; Fix path in MSYS2 - - ;; HACK Don't rely on VCS-specific commands to generate our file lists. That's - ;; 7 commands to maintain, versus the more generic, reliable and - ;; performant `fd' or `ripgrep'. - (defadvice! doom--only-use-generic-command-a (fn vcs) - "Only use `projectile-generic-command' for indexing project files. -And if it's a function, evaluate it." - :around #'projectile-get-ext-command - (if (and (functionp projectile-generic-command) - (not (file-remote-p default-directory))) - (funcall projectile-generic-command vcs) - (let ((projectile-git-submodule-command - (get 'projectile-git-submodule-command 'initial-value))) - (funcall fn vcs)))) - - ;; `projectile-generic-command' doesn't typically support a function, but my - ;; `doom--only-use-generic-command-a' advice allows this. I do it this way so - ;; that projectile can adapt to remote systems (over TRAMP), rather then look - ;; for fd/ripgrep on the remote system simply because it exists on the host. - ;; It's faster too. - (put 'projectile-git-submodule-command 'initial-value projectile-git-submodule-command) - (setq projectile-git-submodule-command nil - projectile-indexing-method 'hybrid - projectile-generic-command - (lambda (_) - ;; If fd exists, use it for git and generic projects. fd is a rust - ;; program that is significantly faster than git ls-files or find, and - ;; it respects .gitignore. This is recommended in the projectile docs. - (cond - ((when-let* - ((bin (if (ignore-errors (file-remote-p default-directory nil t)) - (cl-find-if (doom-rpartial #'executable-find t) - (list "fdfind" "fd")) - doom-projectile-fd-binary)) - ;; REVIEW Temporary fix for #6618. Improve me later. - (version (with-memoization doom-projects--fd-version - (cadr (split-string (cdr (doom-call-process bin "--version")) - " " t)))) - ((ignore-errors (version-to-list version)))) - (concat (format "%s . -0 -H --color=never --type file --type symlink --follow --exclude .git %s" - bin (if (version< version "8.3.0") - "" "--strip-cwd-prefix")) - (if IS-WINDOWS " --path-separator=/")))) - ;; Otherwise, resort to ripgrep, which is also faster than find - ((executable-find "rg" t) - (concat "rg -0 --files --follow --color=never --hidden -g!.git" - (if IS-WINDOWS " --path-separator=/"))) - ("find . -type f -print0")))) - - (defadvice! doom--projectile-default-generic-command-a (fn &rest args) - "If projectile can't tell what kind of project you're in, it issues an error -when using many of projectile's command, e.g. `projectile-compile-command', -`projectile-run-project', `projectile-test-project', and -`projectile-configure-project', for instance. - -This suppresses the error so these commands will still run, but prompt you for -the command instead." - :around #'projectile-default-generic-command - (ignore-errors (apply fn args)))) - - -;; -;;; 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 -state are passed in.") - -(cl-defmacro def-project-mode! (name &key - modes - files - when - match - add-hooks - on-load - on-enter - on-exit) - "Define a project minor mode named NAME and where/how it is activated. - -Project modes allow you to configure 'sub-modes' for major-modes that are -specific to a folder, project structure, framework or whatever arbitrary context -you define. These project modes can have their own settings, keymaps, hooks, -snippets, etc. - -This creates NAME-hook and NAME-map as well. - -PLIST may contain any of these properties, which are all checked to see if NAME -should be activated. If they are *all* true, NAME is activated. - - :modes MODES -- if buffers are derived from MODES (one or a list of symbols). - - :files FILES -- if project contains FILES; takes a string or a form comprised - of nested (and ...) and/or (or ...) forms. Each path is relative to the - project root, however, if prefixed with a '.' or '..', it is relative to the - current buffer. - - :match REGEXP -- if file name matches REGEXP - - :when PREDICATE -- if PREDICATE returns true (can be a form or the symbol of a - function) - - :add-hooks HOOKS -- HOOKS is a list of hooks to add this mode's hook. - - :on-load FORM -- FORM to run the first time this project mode is enabled. - - :on-enter FORM -- FORM is run each time the mode is activated. - - :on-exit FORM -- FORM is run each time the mode is disabled. - -Relevant: `doom-project-hook'." - (declare (indent 1)) - (let ((init-var (intern (format "%s-init" name)))) - (macroexp-progn - (append - (when on-load - `((defvar ,init-var nil))) - `((define-minor-mode ,name - "A project minor mode generated by `def-project-mode!'." - :init-value nil - :lighter "" - :keymap (make-sparse-keymap) - (if (not ,name) - ,on-exit - (run-hook-with-args 'doom-project-hook ',name ,name) - ,(when on-load - `(unless ,init-var - ,on-load - (setq ,init-var t))) - ,on-enter)) - (dolist (hook ,add-hooks) - (add-hook ',(intern (format "%s-hook" name)) hook))) - (cond ((or files modes when) - (cl-check-type files (or null list string)) - (let ((fn - `(lambda () - (and (not (bound-and-true-p ,name)) - (and buffer-file-name (not (file-remote-p buffer-file-name nil t))) - ,(or (null match) - `(if buffer-file-name (string-match-p ,match buffer-file-name))) - ,(or (null files) - ;; Wrap this in `eval' to prevent eager expansion - ;; of `project-file-exists-p!' from pulling in - ;; autoloaded files prematurely. - `(eval - '(project-file-exists-p! - ,(if (stringp (car files)) (cons 'and files) files)))) - ,(or when t) - (,name 1))))) - (if modes - `((dolist (mode ,modes) - (let ((hook-name - (intern (format "doom--enable-%s%s-h" ',name - (if (eq mode t) "" (format "-in-%s" mode)))))) - (fset hook-name #',fn) - (if (eq mode t) - (add-to-list 'auto-minor-mode-magic-alist (cons hook-name #',name)) - (add-hook (intern (format "%s-hook" mode)) hook-name))))) - `((add-hook 'change-major-mode-after-body-hook #',fn))))) - (match - `((add-to-list 'auto-minor-mode-alist (cons ,match #',name))))))))) - -(provide 'doom-projects) -;;; doom-projects.el ends here diff --git a/.config/emacs/lisp/doom-start.el b/.config/emacs/lisp/doom-start.el @@ -1,415 +0,0 @@ -;;; lisp/doom-start.el --- bootstraps interactive sessions -*- lexical-binding: t; -*- -;;; Commentary: -;;; Code: - -;; -;;; Custom hooks - -(defcustom doom-first-input-hook () - "Transient hooks run before the first user input." - :type 'hook - :local 'permanent-local - :group 'doom) - -(defcustom doom-first-file-hook () - "Transient hooks run before the first interactively opened file." - :type 'hook - :local 'permanent-local - :group 'doom) - -(defcustom doom-first-buffer-hook () - "Transient hooks run before the first interactively opened buffer." - :type 'hook - :local 'permanent-local - :group 'doom) - - -;; -;;; Reasonable defaults for interactive sessions - -;;; Runtime optimizations -;; PERF: A second, case-insensitive pass over `auto-mode-alist' is time wasted. -(setq auto-mode-case-fold nil) - -;; PERF: Disable bidirectional text scanning for a modest performance boost. -;; I've set this to `nil' in the past, but the `bidi-display-reordering's docs -;; say that is an undefined state and suggest this to be just as good: -(setq-default bidi-display-reordering 'left-to-right - bidi-paragraph-direction 'left-to-right) - -;; PERF: Disabling BPA makes redisplay faster, but might produce incorrect -;; reordering of bidirectional text with embedded parentheses (and other -;; bracket characters whose 'paired-bracket' Unicode property is non-nil). -(setq bidi-inhibit-bpa t) ; Emacs 27+ only - -;; Reduce rendering/line scan work for Emacs by not rendering cursors or regions -;; in non-focused windows. -(setq-default cursor-in-non-selected-windows nil) -(setq highlight-nonselected-windows nil) - -;; More performant rapid scrolling over unfontified regions. May cause brief -;; spells of inaccurate syntax highlighting right after scrolling, which should -;; quickly self-correct. -(setq fast-but-imprecise-scrolling t) - -;; Don't ping things that look like domain names. -(setq ffap-machine-p-known 'reject) - -;; Emacs "updates" its ui more often than it needs to, so slow it down slightly -(setq idle-update-delay 1.0) ; default is 0.5 - -;; Font compacting can be terribly expensive, especially for rendering icon -;; fonts on Windows. Whether disabling it has a notable affect on Linux and Mac -;; hasn't been determined, but do it anyway, just in case. This increases memory -;; usage, however! -(setq inhibit-compacting-font-caches t) - -;; PGTK builds only: this timeout adds latency to frame operations, like -;; `make-frame-invisible', which are frequently called without a guard because -;; it's inexpensive in non-PGTK builds. Lowering the timeout from the default -;; 0.1 should make childframes and packages that manipulate them (like `lsp-ui', -;; `company-box', and `posframe') feel much snappier. See emacs-lsp/lsp-ui#613. -(eval-when! (boundp 'pgtk-wait-for-event-timeout) - (setq pgtk-wait-for-event-timeout 0.001)) - -;; Increase how much is read from processes in a single chunk (default is 4kb). -;; This is further increased elsewhere, where needed (like our LSP module). -(setq read-process-output-max (* 64 1024)) ; 64kb - -;; Introduced in Emacs HEAD (b2f8c9f), this inhibits fontification while -;; receiving input, which should help a little with scrolling performance. -(setq redisplay-skip-fontification-on-input t) - -;; Performance on Windows is considerably worse than elsewhere. We'll need -;; everything we can get. -(eval-when! (boundp 'w32-get-true-file-attributes) - (setq w32-get-true-file-attributes nil ; decrease file IO workload - w32-pipe-read-delay 0 ; faster IPC - w32-pipe-buffer-size (* 64 1024))) ; read more at a time (was 4K) - -;; The GC introduces annoying pauses and stuttering into our Emacs experience, -;; so we use `gcmh' to stave off the GC while we're using Emacs, and provoke it -;; when it's idle. However, if the idle delay is too long, we run the risk of -;; runaway memory usage in busy sessions. If it's too low, then we may as well -;; not be using gcmh at all. -(setq gcmh-idle-delay 'auto ; default is 15s - gcmh-auto-idle-delay-factor 10 - gcmh-high-cons-threshold (* 16 1024 1024)) ; 16mb -(add-hook 'doom-first-buffer-hook #'gcmh-mode) - - -;;; Disable UI elements early -;; PERF,UI: Doom strives to be keyboard-centric, so I consider these UI elements -;; clutter. Initializing them also costs a morsel of startup time. Whats more, -;; the menu bar exposes functionality that Doom doesn't endorse. Perhaps one -;; day Doom will support these, but today is not that day. -;; -;; HACK: I intentionally avoid calling `menu-bar-mode', `tool-bar-mode', and -;; `scroll-bar-mode' because they do extra work to manipulate frame variables -;; that isn't necessary this early in the startup process. -(push '(menu-bar-lines . 0) default-frame-alist) -(push '(tool-bar-lines . 0) default-frame-alist) -(push '(vertical-scroll-bars) default-frame-alist) -;; And set these to nil so users don't have to toggle the modes twice to -;; reactivate them. -(setq menu-bar-mode nil - tool-bar-mode nil - scroll-bar-mode nil) -;; FIX: On MacOS, disabling the menu bar makes MacOS treat Emacs as a -;; non-application window -- which means it doesn't automatically capture -;; focus when it is started, among other things, so enable the menu-bar for -;; GUI frames, but keep it disabled in terminal frames because there it -;; activates an ugly, in-frame menu bar. -(eval-when! IS-MAC - (add-hook! '(window-setup-hook after-make-frame-functions) - (defun doom-restore-menu-bar-in-gui-frames-h (&optional frame) - (when-let (frame (or frame (selected-frame))) - (when (display-graphic-p frame) - (set-frame-parameter frame 'menu-bar-lines 1)))))) - - -;;; Encodings -;; Contrary to what many Emacs users have in their configs, you don't need more -;; than this to make UTF-8 the default coding system: -(set-language-environment "UTF-8") -;; ...but `set-language-environment' also sets `default-input-method', which is -;; a step too opinionated. -(setq default-input-method nil) -;; ...And the clipboard on Windows could be in a wider encoding (UTF-16), so -;; leave Emacs to its own devices. -(eval-when! IS-WINDOWS - (setq selection-coding-system 'utf-8)) - - -;;; Support for more file extensions -;; Add support for additional file extensions. -(dolist (entry '(("/\\.doom\\(?:rc\\|project\\|module\\|profile\\)\\'" . emacs-lisp-mode) - ("/LICENSE\\'" . text-mode) - ("\\.log\\'" . text-mode) - ("rc\\'" . conf-mode) - ("\\.\\(?:hex\\|nes\\)\\'" . hexl-mode))) - (push entry auto-mode-alist)) - - -;; -;;; MODE-local-vars-hook - -;; File+dir local variables are initialized after the major mode and its hooks -;; have run. If you want hook functions to be aware of these customizations, add -;; them to MODE-local-vars-hook instead. -(defvar doom-inhibit-local-var-hooks nil) - -(defun doom-run-local-var-hooks-h () - "Run MODE-local-vars-hook after local variables are initialized." - (unless (or doom-inhibit-local-var-hooks delay-mode-hooks) - (setq-local doom-inhibit-local-var-hooks t) - (doom-run-hooks (intern-soft (format "%s-local-vars-hook" major-mode))))) - -;; If the user has disabled `enable-local-variables', then -;; `hack-local-variables-hook' is never triggered, so we trigger it at the end -;; of `after-change-major-mode-hook': -(defun doom-run-local-var-hooks-maybe-h () - "Run `doom-run-local-var-hooks-h' if `enable-local-variables' is disabled." - (unless enable-local-variables - (doom-run-local-var-hooks-h))) - - -;; -;;; Incremental lazy-loading - -(defvar doom-incremental-packages '(t) - "A list of packages to load incrementally after startup. Any large packages -here may cause noticeable pauses, so it's recommended you break them up into -sub-packages. For example, `org' is comprised of many packages, and can be -broken up into: - - (doom-load-packages-incrementally - '(calendar find-func format-spec org-macs org-compat - org-faces org-entities org-list org-pcomplete org-src - org-footnote org-macro ob org org-clock org-agenda - org-capture)) - -This is already done by the lang/org module, however. - -If you want to disable incremental loading altogether, either remove -`doom-load-packages-incrementally-h' from `emacs-startup-hook' or set -`doom-incremental-first-idle-timer' to nil. Incremental loading does not occur -in daemon sessions (they are loaded immediately at startup).") - -(defvar doom-incremental-first-idle-timer (if (daemonp) 0 2.0) - "How long (in idle seconds) until incremental loading starts. - -Set this to nil to disable incremental loading. -Set this to 0 to load all incrementally deferred packages immediately at -`emacs-startup-hook'.") - -(defvar doom-incremental-idle-timer 0.75 - "How long (in idle seconds) in between incrementally loading packages.") - -(defun doom-load-packages-incrementally (packages &optional now) - "Registers PACKAGES to be loaded incrementally. - -If NOW is non-nil, load PACKAGES incrementally, in `doom-incremental-idle-timer' -intervals." - (let ((gc-cons-threshold most-positive-fixnum)) - (if (not now) - (cl-callf append doom-incremental-packages packages) - (while packages - (let ((req (pop packages)) - idle-time) - (if (featurep req) - (doom-log "start:iloader: Already loaded %s (%d left)" req (length packages)) - (condition-case-unless-debug e - (and - (or (null (setq idle-time (current-idle-time))) - (< (float-time idle-time) doom-incremental-first-idle-timer) - (not - (while-no-input - (doom-log "start:iloader: Loading %s (%d left)" req (length packages)) - ;; If `default-directory' doesn't exist or is - ;; unreadable, Emacs throws file errors. - (let ((default-directory doom-emacs-dir) - (inhibit-message t) - (file-name-handler-alist - (list (rassq 'jka-compr-handler file-name-handler-alist)))) - (require req nil t) - t)))) - (push req packages)) - (error - (message "Error: failed to incrementally load %S because: %s" req e) - (setq packages nil))) - (if (null packages) - (doom-log "start:iloader: Finished!") - (run-at-time (if idle-time - doom-incremental-idle-timer - doom-incremental-first-idle-timer) - nil #'doom-load-packages-incrementally - packages t) - (setq packages nil)))))))) - -(defun doom-load-packages-incrementally-h () - "Begin incrementally loading packages in `doom-incremental-packages'. - -If this is a daemon session, load them all immediately instead." - (when (numberp doom-incremental-first-idle-timer) - (if (zerop doom-incremental-first-idle-timer) - (mapc #'require (cdr doom-incremental-packages)) - (run-with-idle-timer doom-incremental-first-idle-timer - nil #'doom-load-packages-incrementally - (cdr doom-incremental-packages) t)))) - - -;; -;;; Benchmark - -(defun doom-display-benchmark-h (&optional return-p) - "Display a benchmark including number of packages and modules loaded. - -If RETURN-P, return the message as a string instead of displaying it." - (funcall (if return-p #'format #'message) - "Doom loaded %d packages across %d modules in %.03fs" - (- (length load-path) (length (get 'load-path 'initial-value))) - (hash-table-count doom-modules) - doom-init-time)) - - -;; -;;; Let 'er rip! - -;;; Load core modules and set up their autoloads -(require 'doom-modules) -(autoload 'doom-initialize-packages "doom-packages") -;; TODO (autoload 'doom-profiles-initialize "doom-profiles") -;; TODO (autoload 'doom-packages-initialize "doom-packages") - -;; UX: There's a chance the user will later use package.el or straight in this -;; interactive session. If they do, make sure they're properly initialized -;; when they do. -(with-eval-after-load 'package (require 'doom-packages)) -(with-eval-after-load 'straight (doom-initialize-packages)) - -;; A last ditch opportunity to undo dodgy optimizations or do extra -;; configuration before the session is complicated by user config and packages. -(doom-run-hooks 'doom-before-init-hook) - -;;; Load envvar file -;; 'doom env' generates an envvar file. This is a snapshot of your shell -;; environment, which Doom loads here. This is helpful in scenarios where Emacs -;; is launched from an environment detached from the user's shell environment. -(when (and (or initial-window-system - (daemonp)) - doom-env-file) - (doom-load-envvars-file doom-env-file 'noerror)) - -;;; Last minute setup -(add-hook 'doom-after-init-hook #'doom-load-packages-incrementally-h 100) -(add-hook 'doom-after-init-hook #'doom-display-benchmark-h 110) -(doom-run-hook-on 'doom-first-buffer-hook '(find-file-hook doom-switch-buffer-hook)) -(doom-run-hook-on 'doom-first-file-hook '(find-file-hook dired-initial-position-hook)) -(doom-run-hook-on 'doom-first-input-hook '(pre-command-hook)) -;; PERF: Activate these later, otherwise they'll fire for every buffer created -;; between now and the end of startup. -(add-hook! 'after-init-hook - (defun doom-init-local-var-hooks-h () - ;; These fire `MAJOR-MODE-local-vars-hook' hooks, which is a Doomism. See - ;; the `MODE-local-vars-hook' section above. - (add-hook 'after-change-major-mode-hook #'doom-run-local-var-hooks-h 100) - (add-hook 'hack-local-variables-hook #'doom-run-local-var-hooks-h))) - -;;; Load $DOOMDIR/init.el early -;; TODO: Catch errors -(load! (string-remove-suffix ".el" doom-module-init-file) doom-user-dir t) - -;;; Load the rest of $DOOMDIR + modules if noninteractive -;; If the user is loading this file from a batch script, let's assume they want -;; to load their userland config as well. -(when noninteractive - (doom-require 'doom-profiles) - (let ((init-file (doom-profile-init-file))) - (unless (file-exists-p init-file) - (user-error "Profile init file hasn't been generated. Did you forgot to run 'doom sync'?")) - (let (kill-emacs-query-functions - kill-emacs-hook) - ;; Loads modules, then $DOOMDIR/config.el - (doom-load init-file 'noerror) - (doom-initialize-packages)))) - -;;; Entry point -;; HACK: This advice hijacks Emacs' initfile loader to accomplish the following: -;; -;; 1. Load the profile init file directory (generated on `doom sync`) -;; 2. Ignore initfiles we don't care about (like $EMACSDIR/init.el, ~/.emacs, -;; and ~/_emacs) -- and spare us the IO of searching for them, and allows -;; savvy hackers to use $EMACSDIR as their $DOOMDIR, if they wanted. -;; 3. Cut down on unnecessary logic in Emacs' bootstrapper. -;; 4. Offer a more user-friendly error state/screen, especially for errors -;; emitted from Doom's core or the user's config. -(define-advice startup--load-user-init-file (:override (&rest _) init-doom 100) - (let ((debug-on-error-from-init-file nil) - (debug-on-error-should-be-set nil) - (debug-on-error-initial (if (eq init-file-debug t) 'startup init-file-debug)) - ;; The init file might contain byte-code with embedded NULs, which can - ;; cause problems when read back, so disable nul byte detection. (Bug - ;; #52554) - (inhibit-null-byte-detection t)) - (let ((debug-on-error debug-on-error-initial)) - (condition-case-unless-debug error - (when init-file-user - (let ((init-file-name - ;; This dynamically generated init file stores a lot of - ;; precomputed information, such as module and package - ;; autoloads, and values for expensive variables like - ;; `doom-modules', `doom-disabled-packages', `load-path', - ;; `auto-mode-alist', and `Info-directory-list'. etc. - ;; Compiling them in one place is a big reduction in startup - ;; time, and by keeping a history of them, you get a snapshot - ;; of your config in time. - (file-name-concat - doom-profile-dir (format "init.%d.elc" emacs-major-version)))) - ;; If `user-init-file' is t, then `load' will store the name of - ;; the next file it loads into `user-init-file'. - (setq user-init-file t) - (when init-file-name - (load init-file-name 'noerror 'nomessage 'nosuffix)) - ;; If it's still `t', then it failed to load the profile initfile. - ;; This likely means the user has forgotten to run `doom sync'! - (when (eq user-init-file t) - (signal 'doom-nosync-error (list init-file-name))) - ;; If we loaded a compiled file, set `user-init-file' to the - ;; source version if that exists. - (setq user-init-file - (concat (string-remove-suffix ".elc" user-init-file) - ".el")))) - ;; TODO: Add safe-mode profile. - ;; (error - ;; ;; HACK: This is not really this variable's intended purpose, but it - ;; ;; doesn't mind what value its set to, only that its non-nil, so I'm - ;; ;; exploiting its dynamic scope to pass the error to the profile. - ;; (setq init-file-had-error error) - ;; (load (file-name-concat doom-emacs-dir "profiles" "safe-mode" "init.el") - ;; nil 'nomessage 'nosuffix)) - (error - (display-warning - 'initialization - (format-message "\ -An error occurred while loading `%s':\n\n%s%s%s\n\n\ -To ensure normal operation, you should investigate and remove the -cause of the error in your initialization file. Start Emacs with -the `--debug-init' option to view a complete error backtrace." - user-init-file - (get (car error) 'error-message) - (if (cdr error) ": " "") - (mapconcat (lambda (s) (prin1-to-string s t)) - (cdr error) ", ")) - :warning) - (setq init-file-had-error t))) - ;; If we can tell that the init file altered debug-on-error, arrange to - ;; preserve the value that it set up. - (or (eq debug-on-error debug-on-error-initial) - (setq debug-on-error-should-be-set t - debug-on-error-from-init-file debug-on-error))) - (when debug-on-error-should-be-set - (setq debug-on-error debug-on-error-from-init-file)))) - -(provide 'doom-start) -;;; doom-start.el ends here diff --git a/.config/emacs/lisp/doom-ui.el b/.config/emacs/lisp/doom-ui.el @@ -1,651 +0,0 @@ -;;; doom-ui.el --- defaults for Doom's aesthetics -*- lexical-binding: t; -*- -;;; Commentary: -;;; Code; - -;; -;;; Variables - -(defvar doom-theme nil - "A symbol representing the Emacs theme to load at startup. - -Set to `nil' to load no theme at all. This variable is changed by -`load-theme'.") - -(defvar doom-font nil - "The default font to use. -Must be a `font-spec', a font object, an XFT font string, or an XLFD string. - -This affects the `default' and `fixed-pitch' faces. - -Examples: - (setq doom-font (font-spec :family \"Fira Mono\" :size 12)) - (setq doom-font \"Terminus (TTF):pixelsize=12:antialias=off\") - (setq doom-font \"Fira Code-14\")") - -(defvar doom-variable-pitch-font nil - "The default font to use for variable-pitch text. -Must be a `font-spec', a font object, an XFT font string, or an XLFD string. See -`doom-font' for examples. - -An omitted font size means to inherit `doom-font''s size.") - -(defvar doom-serif-font nil - "The default font to use for the `fixed-pitch-serif' face. -Must be a `font-spec', a font object, an XFT font string, or an XLFD string. See -`doom-font' for examples. - -An omitted font size means to inherit `doom-font''s size.") - -(defvar doom-unicode-font nil - "Fallback font for Unicode glyphs. -Must be a `font-spec', a font object, an XFT font string, or an XLFD string. See -`doom-font' for examples. - -The defaults on macOS and Linux are Apple Color Emoji and Symbola, respectively. - -WARNING: if you specify a size for this font it will hard-lock any usage of this -font to that size. It's rarely a good idea to do so!") - -(defvar doom-emoji-fallback-font-families - '("Apple Color Emoji" - "Segoe UI Emoji" - "Noto Color Emoji" - "Noto Emoji") - "A list of fallback font families to use for emojis.") - -(defvar doom-symbol-fallback-font-families - '("Segoe UI Symbol" - "Apple Symbols") - "A list of fallback font families for general symbol glyphs.") - - -;; -;;; Custom hooks - -(defvar doom-init-ui-hook nil - "List of hooks to run when the UI has been initialized.") - -(defvar doom-load-theme-hook nil - "Hook run after the theme is loaded with `load-theme' or reloaded with -`doom/reload-theme'.") - -(defvar doom-switch-buffer-hook nil - "A list of hooks run after changing the current buffer.") - -(defvar doom-switch-window-hook nil - "A list of hooks run after changing the focused windows.") - -(defvar doom-switch-frame-hook nil - "A list of hooks run after changing the focused frame.") - -(defun doom-run-switch-buffer-hooks-h (&optional _) - (let ((gc-cons-threshold most-positive-fixnum) - (inhibit-redisplay t)) - (run-hooks 'doom-switch-buffer-hook))) - -(defvar doom--last-frame nil) -(defun doom-run-switch-window-or-frame-hooks-h (&optional _) - (let ((gc-cons-threshold most-positive-fixnum) - (inhibit-redisplay t)) - (unless (equal (old-selected-frame) (selected-frame)) - (run-hooks 'doom-switch-frame-hook)) - (unless (or (minibufferp) - (equal (old-selected-window) (minibuffer-window))) - (run-hooks 'doom-switch-window-hook)))) - -(defun doom-protect-fallback-buffer-h () - "Don't kill the scratch buffer. Meant for `kill-buffer-query-functions'." - (not (eq (current-buffer) (doom-fallback-buffer)))) - -(defun doom-highlight-non-default-indentation-h () - "Highlight whitespace at odds with `indent-tabs-mode'. -That is, highlight tabs if `indent-tabs-mode' is `nil', and highlight spaces at -the beginnings of lines if `indent-tabs-mode' is `t'. The purpose is to make -incorrect indentation in the current buffer obvious to you. - -Does nothing if `whitespace-mode' or `global-whitespace-mode' is already active -or if the current buffer is read-only or not file-visiting." - (unless (or (eq major-mode 'fundamental-mode) - (bound-and-true-p global-whitespace-mode) - (null buffer-file-name)) - (require 'whitespace) - (set (make-local-variable 'whitespace-style) - (cl-union (if indent-tabs-mode - '(indentation) - '(tabs tab-mark)) - (when whitespace-mode - (remq 'face whitespace-active-style)))) - (cl-pushnew 'face whitespace-style) ; must be first - (whitespace-mode +1))) - - -;; -;;; General UX - -;; A simple confirmation prompt when killing Emacs. But only prompt when there -;; are real buffers open. -(setq confirm-kill-emacs #'doom-quit-p) -;; Prompt for confirmation when deleting a non-empty frame; a last line of -;; defense against accidental loss of work. -(global-set-key [remap delete-frame] #'doom/delete-frame-with-prompt) - -;; Don't prompt for confirmation when we create a new file or buffer (assume the -;; user knows what they're doing). -(setq confirm-nonexistent-file-or-buffer nil) - -(setq uniquify-buffer-name-style 'forward - ;; no beeping or blinking please - ring-bell-function #'ignore - visible-bell nil) - -;; middle-click paste at point, not at click -(setq mouse-yank-at-point t) - -;; Larger column width for function name in profiler reports -(after! profiler - (setf (caar profiler-report-cpu-line-format) 80 - (caar profiler-report-memory-line-format) 80)) - - -;; -;;; Scrolling - -(setq hscroll-margin 2 - hscroll-step 1 - ;; Emacs spends too much effort recentering the screen if you scroll the - ;; cursor more than N lines past window edges (where N is the settings of - ;; `scroll-conservatively'). This is especially slow in larger files - ;; during large-scale scrolling commands. If kept over 100, the window is - ;; never automatically recentered. - scroll-conservatively 101 - scroll-margin 0 - scroll-preserve-screen-position t - ;; Reduce cursor lag by a tiny bit by not auto-adjusting `window-vscroll' - ;; for tall lines. - auto-window-vscroll nil - ;; mouse - mouse-wheel-scroll-amount '(2 ((shift) . hscroll)) - mouse-wheel-scroll-amount-horizontal 2) - - -;; -;;; Cursor - -;; The blinking cursor is distracting, but also interferes with cursor settings -;; in some minor modes that try to change it buffer-locally (like treemacs) and -;; can cause freezing for folks (esp on macOS) with customized & color cursors. -(blink-cursor-mode -1) - -;; Don't blink the paren matching the one at point, it's too distracting. -(setq blink-matching-paren nil) - -;; Don't stretch the cursor to fit wide characters, it is disorienting, -;; especially for tabs. -(setq x-stretch-cursor nil) - - -;; -;;; Buffers - -(defadvice! doom--switch-to-fallback-buffer-maybe-a (&rest _) - "Switch to `doom-fallback-buffer' if on last real buffer. - -Advice for `kill-current-buffer'. If in a dedicated window, delete it. If there -are no real buffers left OR if all remaining buffers are visible in other -windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original -`kill-current-buffer'." - :before-until #'kill-current-buffer - (let ((buf (current-buffer))) - (cond ((window-dedicated-p) - (delete-window) - t) - ((eq buf (doom-fallback-buffer)) - (message "Can't kill the fallback buffer.") - t) - ((doom-real-buffer-p buf) - (let ((visible-p (delq (selected-window) (get-buffer-window-list buf nil t)))) - (unless visible-p - (when (and (buffer-modified-p buf) - (not (y-or-n-p - (format "Buffer %s is modified; kill anyway?" - buf)))) - (user-error "Aborted"))) - (let ((inhibit-redisplay t) - buffer-list-update-hook) - (when (or ;; if there aren't more real buffers than visible buffers, - ;; then there are no real, non-visible buffers left. - (not (cl-set-difference (doom-real-buffer-list) - (doom-visible-buffers))) - ;; if we end up back where we start (or previous-buffer - ;; returns nil), we have nowhere left to go - (memq (switch-to-prev-buffer nil t) (list buf 'nil))) - (switch-to-buffer (doom-fallback-buffer))) - (unless visible-p - (with-current-buffer buf - (restore-buffer-modified-p nil)) - (kill-buffer buf))) - (run-hooks 'buffer-list-update-hook) - t))))) - - -;; -;;; Fringes - -;; Reduce the clutter in the fringes; we'd like to reserve that space for more -;; useful information, like git-gutter and flycheck. -(setq indicate-buffer-boundaries nil - indicate-empty-lines nil) - - -;; -;;; Windows/frames - -;; A simple frame title -(setq frame-title-format '("%b – Doom Emacs") - icon-title-format frame-title-format) - -;; Don't resize the frames in steps; it looks weird, especially in tiling window -;; managers, where it can leave unseemly gaps. -(setq frame-resize-pixelwise t) - -;; But do not resize windows pixelwise, this can cause crashes in some cases -;; when resizing too many windows at once or rapidly. -(setq window-resize-pixelwise nil) - -;; UX: GUIs are inconsistent across systems, desktop environments, and themes, -;; and don't match the look of Emacs. They also impose inconsistent shortcut -;; key paradigms. I'd rather Emacs be responsible for prompting. -(setq use-dialog-box nil) -(when (bound-and-true-p tooltip-mode) - (tooltip-mode -1)) - -;; FIX: The native border "consumes" a pixel of the fringe on righter-most -;; splits, `window-divider' does not. Available since Emacs 25.1. -(setq window-divider-default-places t - window-divider-default-bottom-width 1 - window-divider-default-right-width 1) -(add-hook 'doom-init-ui-hook #'window-divider-mode) - -;; UX: Favor vertical splits over horizontal ones. Monitors are trending toward -;; wide, rather than tall. -(setq split-width-threshold 160 - split-height-threshold nil) - - -;; -;;; Minibuffer - -;; Allow for minibuffer-ception. Sometimes we need another minibuffer command -;; while we're in the minibuffer. -(setq enable-recursive-minibuffers t) - -;; Show current key-sequence in minibuffer ala 'set showcmd' in vim. Any -;; feedback after typing is better UX than no feedback at all. -(setq echo-keystrokes 0.02) - -;; Expand the minibuffer to fit multi-line text displayed in the echo-area. This -;; doesn't look too great with direnv, however... -(setq resize-mini-windows 'grow-only) - -;; Typing yes/no is obnoxious when y/n will do -(if (boundp 'use-short-answers) - (setq use-short-answers t) - ;; DEPRECATED: Remove when we drop 27.x support - (advice-add #'yes-or-no-p :override #'y-or-n-p)) - -;; Try to keep the cursor out of the read-only portions of the minibuffer. -(setq minibuffer-prompt-properties '(read-only t intangible t cursor-intangible t face minibuffer-prompt)) -(add-hook 'minibuffer-setup-hook #'cursor-intangible-mode) - - -;; -;;; Built-in packages - -;;;###package ansi-color -(setq ansi-color-for-comint-mode t) - - -(after! comint - (setq comint-prompt-read-only t - comint-buffer-maximum-size 2048)) ; double the default - - -(after! compile - (setq 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) - ;; Handle ansi codes in compilation buffer - ;; DEPRECATED Use `ansi-color-compilation-filter' when dropping 27.x support - (add-hook 'compilation-filter-hook #'doom-apply-ansi-color-to-compilation-buffer-h) - ;; Automatically truncate compilation buffers so they don't accumulate too - ;; much data and bog down the rest of Emacs. - (autoload 'comint-truncate-buffer "comint" nil t) - (add-hook 'compilation-filter-hook #'comint-truncate-buffer)) - - -(after! ediff - (setq ediff-diff-options "-w" ; turn off whitespace checking - ediff-split-window-function #'split-window-horizontally - ediff-window-setup-function #'ediff-setup-windows-plain) - - (defvar doom--ediff-saved-wconf nil) - ;; Restore window config after quitting ediff - (add-hook! 'ediff-before-setup-hook - (defun doom-ediff-save-wconf-h () - (setq doom--ediff-saved-wconf (current-window-configuration)))) - (add-hook! '(ediff-quit-hook ediff-suspend-hook) :append - (defun doom-ediff-restore-wconf-h () - (when (window-configuration-p doom--ediff-saved-wconf) - (set-window-configuration doom--ediff-saved-wconf))))) - - -(use-package! hl-line - ;; Highlights the current line - :hook (doom-first-buffer . global-hl-line-mode) - :init - (defvar global-hl-line-modes - '(prog-mode text-mode conf-mode special-mode - org-agenda-mode dired-mode) - "What modes to enable `hl-line-mode' in.") - :config - ;; HACK I reimplement `global-hl-line-mode' so we can white/blacklist modes in - ;; `global-hl-line-modes' _and_ so we can use `global-hl-line-mode', - ;; which users expect to control hl-line in Emacs. - (define-globalized-minor-mode global-hl-line-mode hl-line-mode - (lambda () - (and (cond (hl-line-mode nil) - ((null global-hl-line-modes) nil) - ((eq global-hl-line-modes t)) - ((eq (car global-hl-line-modes) 'not) - (not (derived-mode-p global-hl-line-modes))) - ((apply #'derived-mode-p global-hl-line-modes))) - (hl-line-mode +1)))) - - ;; Temporarily disable `hl-line' when selection is active, since it doesn't - ;; serve much purpose when the selection is so much more visible. - (defvar doom--hl-line-mode nil) - - (add-hook! 'hl-line-mode-hook - (defun doom-truly-disable-hl-line-h () - (unless hl-line-mode - (setq-local doom--hl-line-mode nil)))) - - (add-hook! '(evil-visual-state-entry-hook activate-mark-hook) - (defun doom-disable-hl-line-h () - (when hl-line-mode - (hl-line-mode -1) - (setq-local doom--hl-line-mode t)))) - - (add-hook! '(evil-visual-state-exit-hook deactivate-mark-hook) - (defun doom-enable-hl-line-maybe-h () - (when doom--hl-line-mode - (hl-line-mode +1))))) - - -(use-package! winner - ;; undo/redo changes to Emacs' window layout - :preface (defvar winner-dont-bind-my-keys t) ; I'll bind keys myself - :hook (doom-first-buffer . winner-mode) - :config - (appendq! winner-boring-buffers - '("*Compile-Log*" "*inferior-lisp*" "*Fuzzy Completions*" - "*Apropos*" "*Help*" "*cvs*" "*Buffer List*" "*Ibuffer*" - "*esh command on file*"))) - - -(use-package! paren - ;; highlight matching delimiters - :hook (doom-first-buffer . show-paren-mode) - :config - (setq show-paren-delay 0.1 - show-paren-highlight-openparen t - show-paren-when-point-inside-paren t - show-paren-when-point-in-periphery t)) - - -;;;###package whitespace -(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 ?\ [?·] [?.]))) - - -;; -;;; Third party packages - -(use-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) - :preface - (add-hook! 'after-setting-font-hook - (defun doom-init-all-the-icons-fonts-h () - (when (fboundp 'set-fontset-font) - (dolist (font (list "Weather Icons" - "github-octicons" - "FontAwesome" - "all-the-icons" - "file-icons" - "Material Icons")) - (set-fontset-font t 'unicode font nil 'append))))) - :config - (cond ((daemonp) - (defadvice! doom--disable-all-the-icons-in-tty-a (fn &rest args) - "Return a blank string in tty Emacs, which doesn't support multiple fonts." - :around '(all-the-icons-octicon all-the-icons-material - all-the-icons-faicon all-the-icons-fileicon - all-the-icons-wicon all-the-icons-alltheicon) - (if (or (not after-init-time) (display-multi-font-p)) - (apply fn args) - ""))) - ((not (display-graphic-p)) - (defadvice! doom--disable-all-the-icons-in-tty-a (&rest _) - "Return a blank string for tty users." - :override '(all-the-icons-octicon all-the-icons-material - all-the-icons-faicon all-the-icons-fileicon - all-the-icons-wicon all-the-icons-alltheicon) - "")))) - -;; Hide the mode line in completion popups and MAN pages because they serve -;; little purpose there, and is better hidden. -;;;###package hide-mode-line-mode -(add-hook! '(completion-list-mode-hook Man-mode-hook) - #'hide-mode-line-mode) - -;; Many major modes do no highlighting of number literals, so we do it for them -(use-package! highlight-numbers - :hook ((prog-mode conf-mode) . highlight-numbers-mode) - :config (setq highlight-numbers-generic-regexp "\\_<[[:digit:]]+\\(?:\\.[0-9]*\\)?\\_>")) - -;;;###package image -(setq image-animate-loop t) - -;;;###package rainbow-delimiters -;; Helps us distinguish stacked delimiter pairs, especially in parentheses-drunk -;; languages like Lisp. I reduce it from it's default of 9 to reduce the -;; complexity of the font-lock keyword and hopefully buy us a few ms of -;; performance. -(setq rainbow-delimiters-max-face-count 4) - - -;; -;;; Line numbers - -;; Explicitly define a width to reduce the cost of on-the-fly computation -(setq-default display-line-numbers-width 3) - -;; Show absolute line numbers for narrowed regions to make it easier to tell the -;; buffer is narrowed, and where you are, exactly. -(setq-default display-line-numbers-widen t) - -;; Enable line numbers in most text-editing modes. We avoid -;; `global-display-line-numbers-mode' because there are many special and -;; temporary modes where we don't need/want them. -(add-hook! '(prog-mode-hook text-mode-hook conf-mode-hook) - #'display-line-numbers-mode) - -;; Fix #2742: cursor is off by 4 characters in `artist-mode' -;; REVIEW Reported upstream https://debbugs.gnu.org/cgi/bugreport.cgi?bug=43811 -;; DEPRECATED Fixed in Emacs 28; remove when we drop 27 support -(unless (> emacs-major-version 27) - (add-hook 'artist-mode-hook #'doom-disable-line-numbers-h)) - - -;; -;;; Theme & font - -;; User themes should live in $DOOMDIR/themes, not ~/.emacs.d -(setq custom-theme-directory (concat doom-user-dir "themes/")) - -;; Third party themes add themselves to `custom-theme-load-path', but the themes -;; living in $DOOMDIR/themes should always have priority. -(setq custom-theme-load-path - (cons 'custom-theme-directory - (delq 'custom-theme-directory custom-theme-load-path))) - -(defun doom--make-font-specs (face font) - (let* ((base-specs (cadr (assq 'user (get face 'theme-face)))) - (base-specs (or base-specs '((t nil)))) - (attrs '(:family :foundry :slant :weight :height :width)) - (new-specs nil)) - (dolist (spec base-specs) - ;; Each SPEC has the form (DISPLAY ATTRIBUTE-PLIST) - (let ((display (car spec)) - (plist (copy-tree (nth 1 spec)))) - ;; Alter only DISPLAY conditions matching this frame. - (when (or (memq display '(t default)) - (face-spec-set-match-display display this-frame)) - (dolist (attr attrs) - (setq plist (plist-put plist attr (face-attribute face attr))))) - (push (list display plist) new-specs))) - (nreverse new-specs))) - -(defun doom-init-fonts-h (&optional reload) - "Loads `doom-font'." - (dolist (map `((default . ,doom-font) - (fixed-pitch . ,doom-font) - (fixed-pitch-serif . ,doom-serif-font) - (variable-pitch . ,doom-variable-pitch-font))) - (when-let* ((face (car map)) - (font (cdr map))) - (dolist (frame (frame-list)) - (when (display-multi-font-p frame) - (set-face-attribute face frame - :width 'normal :weight 'normal - :slant 'normal :font font))) - (let ((new-specs (doom--make-font-specs face font))) - ;; Don't save to `customized-face' so it's omitted from `custom-file' - ;;(put face 'customized-face new-specs) - (custom-push-theme 'theme-face face 'user 'set new-specs) - (put face 'face-modified nil)))) - (when (fboundp 'set-fontset-font) - (let ((fn (doom-rpartial #'member (font-family-list)))) - (when-let (font (cl-find-if fn doom-symbol-fallback-font-families)) - (set-fontset-font t 'symbol font)) - (when-let (font (cl-find-if fn doom-emoji-fallback-font-families)) - (set-fontset-font t 'unicode font)) - (when doom-unicode-font - (set-fontset-font t 'unicode doom-unicode-font)))) - ;; Users should inject their own font logic in `after-setting-font-hook' - (run-hooks 'after-setting-font-hook)) - -(defun doom-init-theme-h (&rest _) - "Load the theme specified by `doom-theme' in FRAME." - (when (and doom-theme (not (custom-theme-enabled-p doom-theme))) - (load-theme doom-theme t))) - -(defadvice! doom--load-theme-a (fn theme &optional no-confirm no-enable) - "Record `doom-theme', disable old themes, and trigger `doom-load-theme-hook'." - :around #'load-theme - ;; Run `load-theme' from an estranged buffer, where we can ensure that - ;; buffer-local face remaps (by `mixed-pitch-mode', for instance) won't - ;; interfere with recalculating faces in new themes. - (with-temp-buffer - (let ((last-themes (copy-sequence custom-enabled-themes))) - ;; Disable previous themes so there are no conflicts. If you truly want - ;; multiple themes enabled, then use `enable-theme' instead. - (mapc #'disable-theme custom-enabled-themes) - (prog1 (funcall fn theme no-confirm no-enable) - (when (and (not no-enable) (custom-theme-enabled-p theme)) - (setq doom-theme theme) - (put 'doom-theme 'previous-themes (or last-themes 'none)) - ;; DEPRECATED Hook into `enable-theme-functions' when we target 29 - (doom-run-hooks 'doom-load-theme-hook)))))) - - -;; -;;; Bootstrap - -(defun doom-init-ui-h (&optional _) - "Initialize Doom's user interface by applying all its advice and hooks. - -These should be done as late as possible, as to avoid/minimize prematurely -triggering hooks during startup." - (doom-run-hooks 'doom-init-ui-hook) - - (add-hook 'kill-buffer-query-functions #'doom-protect-fallback-buffer-h) - (add-hook 'after-change-major-mode-hook #'doom-highlight-non-default-indentation-h 'append) - - ;; Make `next-buffer', `other-buffer', etc. ignore unreal buffers. - (push '(buffer-predicate . doom-buffer-frame-predicate) default-frame-alist) - - ;; Initialize `doom-switch-window-hook' and `doom-switch-frame-hook' - (add-hook 'window-selection-change-functions #'doom-run-switch-window-or-frame-hooks-h) - ;; Initialize `doom-switch-buffer-hook' - (add-hook 'window-buffer-change-functions #'doom-run-switch-buffer-hooks-h) - ;; `window-buffer-change-functions' doesn't trigger for files visited via the server. - (add-hook 'server-visit-hook #'doom-run-switch-buffer-hooks-h)) - -;; Apply fonts and theme -(let ((hook (if (daemonp) - 'server-after-make-frame-hook - 'after-init-hook))) - (add-hook hook #'doom-init-fonts-h -100) - (add-hook hook #'doom-init-theme-h -90)) - -;; PERF: Init UI late, but not too late. Its impact on startup time seems to -;; vary wildly depending on exact placement. `window-setup-hook' appears to be -;; the sweet spot. -(add-hook 'window-setup-hook #'doom-init-ui-h -100) - - -;; -;;; Fixes/hacks - -;; Doom doesn't support `customize' and it never will. It's a clumsy interface -;; that sets variables at a time where it can be easily and unpredictably -;; overwritten. Configure things from your $DOOMDIR instead. -(dolist (sym '(customize-option customize-browse customize-group customize-face - customize-rogue customize-saved customize-apropos - customize-changed customize-unsaved customize-variable - customize-set-value customize-customized customize-set-variable - customize-apropos-faces customize-save-variable - customize-apropos-groups customize-apropos-options - customize-changed-options customize-save-customized)) - (put sym 'disabled "Doom doesn't support `customize', configure Emacs from $DOOMDIR/config.el instead")) -(put 'customize-themes 'disabled "Set `doom-theme' or use `load-theme' in $DOOMDIR/config.el instead") - -;; These two functions don't exist in terminal Emacs, but some Emacs packages -;; (internal and external) use it anyway, leading to void-function errors. I -;; define a no-op substitute to suppress them. -(unless (fboundp 'define-fringe-bitmap) - (fset 'define-fringe-bitmap #'ignore)) -(unless (fboundp 'set-fontset-font) - (fset 'set-fontset-font #'ignore)) - -(after! whitespace - (defun doom-is-childframes-p () - "`whitespace-mode' inundates child frames with whitespace markers, so -disable it to fix all that visual noise." - (null (frame-parameter nil 'parent-frame))) - (add-function :before-while whitespace-enable-predicate #'doom-is-childframes-p)) - -(provide 'doom-ui) -;;; doom-ui.el ends here diff --git a/.config/emacs/lisp/doom.el b/.config/emacs/lisp/doom.el @@ -1,706 +0,0 @@ -;;; doom.el --- the heart of the beast -*- lexical-binding: t; -*- -;; -;; Author: Henrik Lissner <contact@henrik.io> -;; URL: https://github.com/doomemacs/doomemacs -;; -;; ================= =============== =============== ======== ======== -;; \\ . . . . . . .\\ //. . . . . . .\\ //. . . . . . .\\ \\. . .\\// . . // -;; ||. . ._____. . .|| ||. . ._____. . .|| ||. . ._____. . .|| || . . .\/ . . .|| -;; || . .|| ||. . || || . .|| ||. . || || . .|| ||. . || ||. . . . . . . || -;; ||. . || || . .|| ||. . || || . .|| ||. . || || . .|| || . | . . . . .|| -;; || . .|| ||. _-|| ||-_ .|| ||. . || || . .|| ||. _-|| ||-_.|\ . . . . || -;; ||. . || ||-' || || `-|| || . .|| ||. . || ||-' || || `|\_ . .|. .|| -;; || . _|| || || || || ||_ . || || . _|| || || || |\ `-_/| . || -;; ||_-' || .|/ || || \|. || `-_|| ||_-' || .|/ || || | \ / |-_.|| -;; || ||_-' || || `-_|| || || ||_-' || || | \ / | `|| -;; || `' || || `' || || `' || || | \ / | || -;; || .===' `===. .==='.`===. .===' /==. | \/ | || -;; || .==' \_|-_ `===. .===' _|_ `===. .===' _-|/ `== \/ | || -;; || .==' _-' `-_ `=' _-' `-_ `=' _-' `-_ /| \/ | || -;; || .==' _-' '-__\._-' '-_./__-' `' |. /| | || -;; ||.==' _-' `' | /==.|| -;; ==' _-' \/ `== -;; \ _-' `-_ / -;; `'' ``' -;; -;; These demons are not part of GNU Emacs. -;; -;;; Commentary: -;; -;; This is Doom's heart, where I define all its major constants and variables, -;; set its saner global defaults, then prepare Emacs to bootstrap Doom. -;; -;; The overall load order of Doom is as follows: -;; -;; > $EMACSDIR/early-init.el -;; > $EMACSDIR/lisp/doom.el -;; - $EMACSDIR/lisp/doom-lib.el -;; > $EMACSDIR/lisp/doom-start.el -;; - hook: `doom-before-init-hook' -;; - $DOOMDIR/init.el -;; - hook: `before-init-hook' -;; > $XDG_DATA_HOME/doom/$PROFILE/@/$VERSION/init.el (replaces $EMACSDIR/init.el) -;; - $EMACSDIR/doom-{keybinds,ui,projects,editor}.el -;; - hook: `doom-before-modules-init-hook' -;; - {$DOOMDIR,$EMACSDIR}/modules/*/*/init.el -;; - hook: `doom-after-modules-init-hook' -;; - hook: `doom-before-modules-config-hook' -;; - {$DOOMDIR,$EMACSDIR}/modules/*/*/config.el -;; - hook: `doom-after-modules-config-hook' -;; - $DOOMDIR/config.el -;; - `custom-file' or $DOOMDIR/custom.el -;; - hook: `after-init-hook' -;; - hook: `emacs-startup-hook' -;; - hook: `window-setup-hook' -;; - hook: `doom-init-ui-hook' -;; - hook: `doom-after-init-hook' -;; > After startup is complete: -;; - On first input: `doom-first-input-hook' -;; - On first switched-to buffer: `doom-first-buffer-hook' -;; - On first opened file: `doom-first-file-hook' -;; -;; This is Doom's heart, where I define all its major constants and variables, -;; set only its sanest global defaults, employ its hackiest (and least -;; offensive) optimizations, and load the minimum for all Doom sessions. -;; -;;; Code: -(eval-when-compile (require 'subr-x)) - -;;; Version checks -(eval-and-compile ; Check version at both compile and runtime. - ;; Doom's minimum supported version of Emacs is 27.1. Its my goal to support - ;; one major version below the stable release, for about a year or until - ;; stable is ubiquitous (or at least easily accessible) across Linux distros. - (when (< emacs-major-version 27) - (user-error - (concat - "Detected Emacs " emacs-version ", but Doom requires 27.1 or newer (28.1 is\n\n" - "recommended). The current Emacs executable in use is:\n\n " (car command-line-args) - "\n\nA guide for installing a newer version of Emacs can be found at:\n\n " - (format "https://docs.doomemacs.org/-/install/%s" - (cond ((eq system-type 'darwin) "on-macos") - ((memq system-type '(cygwin windows-nt ms-dos)) "on-windows") - ("on-linux"))) - "\n\n" - (if noninteractive - (concat "Alternatively, either update your $PATH environment variable to include the\n" - "path of the desired Emacs executable OR alter the $EMACS environment variable\n" - "to specify the exact path or command needed to invoke Emacs." - (when-let ((script (cadr (member "--load" command-line-args))) - (command (file-name-nondirectory script))) - (concat " For example:\n\n" - " $ EMACS=/path/to/valid/emacs " command " ...\n" - " $ EMACS=\"/Applications/Emacs.app/Contents/MacOS/Emacs\" " command " ...\n" - " $ EMACS=\"snap run emacs\" " command " ...")) - "\n\nAborting...") - (concat "If you believe this error is a mistake, run 'doom doctor' on the command line\n" - "to diagnose common issues with your config and system.")))))) - -;; Doom needs to be synced/rebuilt if either Doom or Emacs has been -;; up/downgraded. This is because byte-code isn't backwards compatible, and many -;; packages (including Doom), make in absolute paths into their caches that need -;; to be refreshed. -(let ((old-version (eval-when-compile emacs-version))) - (unless (equal emacs-version old-version) - (user-error (concat "Doom was compiled with Emacs %s, but was loaded with %s. Run 'doom sync' to" - "recompile it.") - emacs-version old-version))) - -;;; Custom features -;; Since `system-configuration-features's docs state not to rely on it to test -;; for features, let's give users an easier way to detect them. -(if (bound-and-true-p module-file-suffix) - (push 'dynamic-modules features)) -(if (fboundp #'json-parse-string) - (push 'jansson features)) -;; `native-compile' exists whether or not it is functional (e.g. libgcc is -;; available or not). This seems silly, so pretend it doesn't exist if it -;; isn't available. -(if (featurep 'native-compile) - (if (not (native-comp-available-p)) - (delq 'native-compile features))) - -;;; Global constants -;; DEPRECATED remove in v3 -(defconst IS-MAC (eq system-type 'darwin)) -(defconst IS-LINUX (memq system-type '(gnu gnu/linux gnu/kfreebsd berkeley-unix))) -(defconst IS-WINDOWS (memq system-type '(cygwin windows-nt ms-dos))) -(defconst IS-BSD (memq system-type '(darwin berkeley-unix gnu/kfreebsd))) -(defconst EMACS28+ (> emacs-major-version 27)) -(defconst EMACS29+ (> emacs-major-version 28)) -(defconst MODULES (featurep 'dynamic-modules)) -(defconst NATIVECOMP (featurep 'native-compile)) - -(make-obsolete-variable 'EMACS28+ "Use (>= emacs-major-version 28) instead" "3.0.0") -(make-obsolete-variable 'EMACS29+ "Use (>= emacs-major-version 29) instead" "3.0.0") -(make-obsolete-variable 'MODULES "Use (featurep 'dynamic-modules) instead" "3.0.0") -(make-obsolete-variable 'NATIVECOMP "Use (featurep 'native-compile) instead" "3.0.0") - -;;; Fix $HOME on Windows -;; $HOME isn't normally defined on Windows, but many unix tools expect it. -(when IS-WINDOWS - (when-let (realhome - (and (null (getenv-internal "HOME")) - (getenv "USERPROFILE"))) - (setenv "HOME" realhome) - (setq abbreviated-home-dir nil))) - -;;; Load Doom's stdlib -(add-to-list 'load-path (file-name-directory load-file-name)) -(require 'doom-lib) - - -;; -;;; Core globals - -(defgroup doom nil - "An Emacs framework for the stubborn martian hacker." - :link '(url-link "https://doomemacs.org")) - -(defconst doom-version "3.0.0-pre" - "Current version of Doom Emacs core.") - -;; DEPRECATED: Remove these when the modules are moved out of core. -(defconst doom-modules-version "23.03.0-pre" - "Current version of Doom Emacs.") - -(defvar doom-init-time nil - "The time it took, in seconds, for Doom Emacs to initialize.") - -(defconst doom-profile - (if-let (profile (getenv-internal "DOOMPROFILE")) - (save-match-data - (if (string-match "^\\([^@]+\\)@\\(.+\\)$" profile) - (cons (match-string 1 profile) - (match-string 2 profile)) - (cons profile "0"))) - ;; TODO Restore this in 3.0 - ;; (cons "_" "0") - ) - "The active profile as a cons cell (NAME . VERSION).") - -;;; Data directory variables -(defvar doom-emacs-dir user-emacs-directory - "The path to the currently loaded .emacs.d directory. Must end with a slash.") - -(defconst doom-core-dir (file-name-directory load-file-name) - "The root directory of Doom's core files. Must end with a slash.") - -(defvar doom-modules-dir (expand-file-name "modules/" doom-emacs-dir) - "The root directory for Doom's modules. Must end with a slash.") - -(define-obsolete-variable-alias 'doom-private-dir 'doom-user-dir "3.0.0") -(defvar doom-user-dir - (expand-file-name - (if-let (doomdir (getenv-internal "DOOMDIR")) - (file-name-as-directory doomdir) - (or (let ((xdgdir - (file-name-concat - (or (getenv-internal "XDG_CONFIG_HOME") - "~/.config") - "doom/"))) - (if (file-directory-p xdgdir) xdgdir)) - "~/.doom.d/"))) - "Where your private configuration is placed. - -Defaults to ~/.config/doom, ~/.doom.d or the value of the DOOMDIR envvar; -whichever is found first. Must end in a slash.") - -;; DEPRECATED: .local will be removed entirely in 3.0 -(defvar doom-local-dir - (if-let (localdir (getenv-internal "DOOMLOCALDIR")) - (expand-file-name (file-name-as-directory localdir)) - (expand-file-name ".local/" doom-emacs-dir)) - "Root directory for local storage. - -Use this as a storage location for this system's installation of Doom Emacs. - -These files should not be shared across systems. By default, it is used by -`doom-data-dir' and `doom-cache-dir'. Must end with a slash.") - -(define-obsolete-variable-alias 'doom-etc-dir 'doom-data-dir "3.0.0") -(defvar doom-data-dir - (if doom-profile - (if IS-WINDOWS - (expand-file-name "doomemacs/data/" (getenv-internal "APPDATA")) - (expand-file-name "doom/" (or (getenv-internal "XDG_DATA_HOME") "~/.local/share"))) - ;; DEPRECATED: .local will be removed entirely in 3.0 - (file-name-concat doom-local-dir "etc/")) - "Where Doom stores its global data files. - -Data files contain shared and long-lived data that Doom, Emacs, and their -packages require to function correctly or at all. Deleting them by hand will -cause breakage, and require user intervention (e.g. a 'doom sync' or 'doom env') -to restore. - -Use this for: server binaries, package source, pulled module libraries, -generated files for profiles, profiles themselves, autoloads/loaddefs, etc. - -For profile-local data files, use `doom-profile-data-dir' instead.") - -(defvar doom-cache-dir - (if doom-profile - (if IS-WINDOWS - (expand-file-name "doomemacs/cache/" (getenv-internal "APPDATA")) - (expand-file-name "doom/" (or (getenv-internal "XDG_CACHE_HOME") "~/.cache"))) - ;; DEPRECATED: .local will be removed entirely in 3.0 - (file-name-concat doom-local-dir "cache/")) - "Where Doom stores its global cache files. - -Cache files represent non-essential data that shouldn't be problematic when -deleted (besides, perhaps, a one-time performance hit), lack portability (and so -shouldn't be copied to other systems/configs), and are regenerated when needed, -without user input (e.g. a 'doom sync'). - -Some examples: images/data caches, elisp bytecode, natively compiled elisp, -session files, ELPA archives, authinfo files, org-persist, etc. - -For profile-local cache files, use `doom-profile-cache-dir' instead.") - -(defvar doom-state-dir - (if doom-profile - (if IS-WINDOWS - (expand-file-name "doomemacs/state/" (getenv-internal "APPDATA")) - (expand-file-name "doom/" (or (getenv-internal "XDG_STATE_HOME") "~/.local/state"))) - ;; DEPRECATED: .local will be removed entirely in 3.0 - (file-name-concat doom-local-dir "state/")) - "Where Doom stores its global state files. - -State files contain non-essential, unportable, but persistent data which, if -lost won't cause breakage, but may be inconvenient as they cannot be -automatically regenerated or restored. For example, a recently-opened file list -is not essential, but losing it means losing this record, and restoring it -requires revisiting all those files. - -Use this for: history, logs, user-saved data, autosaves/backup files, known -projects, recent files, bookmarks. - -For profile-local state files, use `doom-profile-state-dir' instead.") - -;;; Profile file/directory variables -(defvar doom-profile-cache-dir - (file-name-concat doom-cache-dir (car doom-profile)) - "For profile-local cache files under `doom-cache-dir'.") - -(defvar doom-profile-data-dir - (file-name-concat doom-data-dir (car doom-profile)) - "For profile-local data files under `doom-data-dir'.") - -(defvar doom-profile-state-dir - (file-name-concat doom-state-dir (car doom-profile)) - "For profile-local state files under `doom-state-dir'.") - -(defconst doom-profile-dir - (file-name-concat doom-profile-data-dir "@" (cdr doom-profile)) - "Where generated files for the active profile are kept.") - -;; DEPRECATED: Will be moved to cli/env -(defconst doom-env-file - (file-name-concat (if doom-profile - doom-profile-dir - doom-local-dir) - "env") - "The location of your envvar file, generated by `doom env`. - -This file contains environment variables scraped from your shell environment, -which is loaded at startup (if it exists). This is helpful if Emacs can't -\(easily) be launched from the correct shell session (particularly for MacOS -users).") - - -;; -;;; Startup optimizations - -;; Here are Doom's hackiest (and least offensive) startup optimizations. They -;; exploit implementation details and unintended side-effects, and will change -;; often between major Emacs releases. However, I disable them if this is a -;; daemon session (where startup time matters less). -;; -;; Most of these have been tested on Linux and on fairly fast machines (with -;; SSDs), so your mileage may vary depending on your hardware. -(unless (daemonp) - ;; PERF: `file-name-handler-alist' is consulted on each call to `require', - ;; `load', or various file/io functions (like `expand-file-name' or - ;; `file-remote-p'). You get a noteable boost to startup time by unsetting - ;; or simplifying its value. - (let ((old-value (default-toplevel-value 'file-name-handler-alist))) - (setq file-name-handler-alist - ;; HACK: If the bundled elisp for this Emacs install isn't - ;; byte-compiled (but is compressed), then leave the gzip file - ;; handler there so Emacs won't forget how to read read them. - ;; - ;; calc-loaddefs.el is our heuristic for this because it is built-in - ;; to all supported versions of Emacs, and calc.el explicitly loads - ;; it uncompiled. This ensures that the only other, possible - ;; fallback would be calc-loaddefs.el.gz. - (if (eval-when-compile - (locate-file-internal "calc-loaddefs.el" load-path)) - nil - (list (rassq 'jka-compr-handler old-value)))) - ;; Make sure the new value survives any current let-binding. - (set-default-toplevel-value 'file-name-handler-alist file-name-handler-alist) - ;; Remember it so it can be reset where needed. - (put 'file-name-handler-alist 'initial-value old-value) - ;; COMPAT: ...but restore `file-name-handler-alist' later, because it is - ;; needed for handling encrypted or compressed files, among other things. - (add-hook! 'emacs-startup-hook :depth 101 - (defun doom--reset-file-handler-alist-h () - (setq file-name-handler-alist - ;; Merge instead of overwrite because there may have been changes to - ;; `file-name-handler-alist' since startup we want to preserve. - (delete-dups (append file-name-handler-alist old-value)))))) - - (unless noninteractive - ;; PERF: Resizing the Emacs frame (to accommodate fonts that are smaller or - ;; larger than the system font) appears to impact startup time - ;; dramatically. The larger the delta in font size, the greater the delay. - ;; Even trivial deltas can yield a ~1000ms loss, though it varies wildly - ;; depending on font size. - (setq frame-inhibit-implied-resize t) - - ;; PERF,UX: Reduce *Message* noise at startup. An empty scratch buffer (or - ;; the dashboard) is more than enough, and faster to display. - (setq inhibit-startup-screen t - inhibit-startup-echo-area-message user-login-name) - ;; PERF,UX: Remove "For information about GNU Emacs..." message at startup. - ;; It's redundant with our dashboard and incurs a premature redraw. - (advice-add #'display-startup-echo-area-message :override #'ignore) - ;; PERF: Suppress the vanilla startup screen completely. We've disabled it - ;; with `inhibit-startup-screen', but it would still initialize anyway. - ;; This involves some file IO and/or bitmap work (depending on the frame - ;; type) that we can no-op for a free 50-100ms boost in startup time. - (advice-add #'display-startup-screen :override #'ignore) - - ;; PERF: Shave seconds off startup time by starting the scratch buffer in - ;; `fundamental-mode', rather than, say, `org-mode' or `text-mode', which - ;; pull in a ton of packages. `doom/open-scratch-buffer' provides a better - ;; scratch buffer anyway. - (setq initial-major-mode 'fundamental-mode - initial-scratch-message nil) - - (unless initial-window-system - ;; PERF: Inexplicably, `tty-run-terminal-initialization' can sometimes - ;; take 2-3s when starting up Emacs in the terminal. Whatever slows it - ;; down at startup doesn't appear to affect it if it's called a little - ;; later in the startup process, so that's what I do. - ;; REVIEW: This optimization is not well understood. Investigate it! - (define-advice tty-run-terminal-initialization (:override (&rest _) defer) - (advice-remove #'tty-run-terminal-initialization #'tty-run-terminal-initialization@defer) - (add-hook 'window-setup-hook - (doom-partial #'tty-run-terminal-initialization - (selected-frame) nil t)))) - - (unless init-file-debug - ;; PERF,UX: Site files tend to use `load-file', which emits "Loading X..." - ;; messages in the echo area. Writing to the echo-area triggers a - ;; redisplay, which can be expensive during startup. This may also cause - ;; an flash of white when creating the first frame. - (define-advice load-file (:override (file) silence) - (load file nil 'nomessage)) - ;; COMPAT: But undo our `load-file' advice later, as to limit the scope of - ;; any edge cases it could induce. - (define-advice startup--load-user-init-file (:before (&rest _) undo-silence) - (advice-remove #'load-file #'load-file@silence)) - - ;; PERF: `load-suffixes' and `load-file-rep-suffixes' are consulted on each - ;; `require' and `load'. Doom won't load any dmodules this early, so omit - ;; .so for a small startup boost. This is later restored in doom-start. - (put 'load-suffixes 'initial-value (default-toplevel-value 'load-suffixes)) - (put 'load-file-rep-suffixes 'initial-value (default-toplevel-value 'load-file-rep-suffixes)) - (set-default-toplevel-value 'load-suffixes '(".elc" ".el")) - (set-default-toplevel-value 'load-file-rep-suffixes '("")) - ;; COMPAT: Undo any problematic startup optimizations; from this point, I make - ;; no assumptions about what might be loaded in userland. - (add-hook! 'doom-before-init-hook - (defun doom--reset-load-suffixes-h () - (setq load-suffixes (get 'load-suffixes 'initial-value) - load-file-rep-suffixes (get 'load-file-rep-suffixes 'initial-value)))) - - ;; PERF: Doom uses `defcustom' to indicate variables that users are expected - ;; to reconfigure. Trouble is it fires off initializers meant to - ;; accommodate any user attempts to configure them before they were - ;; defined. This is unnecessary before $DOOMDIR/init.el is loaded, so I - ;; disable them until it is. - (setq custom-dont-initialize t) - (add-hook! 'doom-before-init-hook - (defun doom--reset-custom-dont-initialize-h () - (setq custom-dont-initialize nil))) - - ;; PERF: The mode-line procs a couple dozen times during startup. This is - ;; normally quite fast, but disabling the default mode-line and reducing the - ;; update delay timer seems to stave off ~30-50ms. - (put 'mode-line-format 'initial-value (default-toplevel-value 'mode-line-format)) - (setq-default mode-line-format nil) - (dolist (buf (buffer-list)) - (with-current-buffer buf (setq mode-line-format nil))) - ;; PERF,UX: Premature redisplays can substantially affect startup times and - ;; produce ugly flashes of unstyled Emacs. - (setq-default inhibit-redisplay t - inhibit-message t) - ;; COMPAT: Then reset it with advice, because `startup--load-user-init-file' - ;; will never be interrupted by errors. And if these settings are left - ;; set, Emacs could appear frozen or garbled. - (defun doom--reset-inhibited-vars-h () - (setq-default inhibit-redisplay nil - ;; Inhibiting `message' only prevents redraws and - inhibit-message nil) - (redraw-frame)) - (add-hook 'after-init-hook #'doom--reset-inhibited-vars-h) - (define-advice startup--load-user-init-file (:after (&rest _) undo-inhibit-vars) - (when init-file-had-error - (doom--reset-inhibited-vars-h)) - (unless (default-toplevel-value 'mode-line-format) - (setq-default mode-line-format (get 'mode-line-format 'initial-value)))) - - ;; PERF: Doom disables the UI elements by default, so that there's less for - ;; the frame to initialize. However, the toolbar is still populated - ;; regardless, so I lazy load it until tool-bar-mode is actually used. - (advice-add #'tool-bar-setup :override #'ignore) - (define-advice startup--load-user-init-file (:before (&rest _) defer-tool-bar-setup) - (advice-remove #'tool-bar-setup #'ignore) - (add-transient-hook! 'tool-bar-mode (tool-bar-setup))) - - ;; PERF: Unset a non-trivial list of command line options that aren't - ;; relevant to our current OS, but `command-line-1' still processes. - (unless IS-MAC - (setq command-line-ns-option-alist nil)) - (unless (memq initial-window-system '(x pgtk)) - (setq command-line-x-option-alist nil))))) - - -;; -;;; `doom-context' - -(defvar doom-context '(t) - "A list of symbols identifying all active Doom execution contexts. - -This should never be directly changed, only let-bound, and should never be -empty. Each context describes what phase Doom is in, and may respond to. - -All valid contexts: - cli -- while executing a Doom CLI - compile -- while byte-compilation is in progress - eval -- during inline evaluation of elisp - init -- while doom is formally starting up for the first time, after its - core libraries are loaded, but before user config is. - modules -- while loading modules and their files - sandbox -- This session was launched from Doom's sandbox. - packages -- when packagedefs are being read - reload -- while reloading doom") -(put 'doom-context 'valid-values '(cli compile eval init modules packages reload doctor sandbox)) -(put 'doom-context 'risky-local-variable t) - -(defun doom-context--check (context) - (let ((valid (get 'doom-context 'valid-values))) - (unless (memq context valid) - (signal 'doom-context-error - (list context "Unrecognized context" valid))))) - -(defun doom-context-p (context) - "Return t if CONTEXT is active (i.e. in `doom-context')." - (if (memq context doom-context) t)) - -(defun doom-context-push (context) - "Add CONTEXT to `doom-context', if it isn't already. - -Return non-nil if successful. Throws an error if CONTEXT is invalid." - (unless (memq context doom-context) - (doom-context--check context) - (doom-log ":context: +%s %s" context doom-context) - (push context doom-context))) - -(defun doom-context-pop (context &optional strict?) - "Remove CONTEXT from `doom-context'. - -Return non-nil if successful. If STRICT? is non-nil, throw an error if CONTEXT -wasn't active when this was called." - (if (not (doom-context-p context)) - (when strict? - (signal 'doom-context-error - (list doom-context "Attempt to pop missing context" context))) - (doom-log ":context: -%s %s" context doom-context) - (setq doom-context (delq context doom-context)))) - -(defmacro doom-context-with (contexts &rest body) - "Evaluate BODY with CONTEXT added to `doom-context'." - (declare (indent 1)) - `(let ((doom-context doom-context)) - (dolist (context (ensure-list ,contexts)) - (doom-context-push context)) - ,@body)) - - -;; -;;; Reasonable, global defaults - -;;; Don't litter `doom-emacs-dir'/$HOME -;; HACK: I change `user-emacs-directory' because many packages (even built-in -;; ones) abuse it to build paths for storage/cache files (instead of correctly -;; using `locate-user-emacs-file'). This change ensures that said data files -;; are never saved to the root of your emacs directory *and* saves us the -;; trouble of setting a million directory/file variables. But it may throw off -;; anyone (or any package) that uses it to search for your Emacs initfiles. -(setq user-emacs-directory doom-profile-cache-dir) - -;; ...However, this may surprise packages (and users) that read -;; `user-emacs-directory' expecting to find the location of your Emacs config, -;; such as server.el! -(setq server-auth-dir (file-name-concat doom-emacs-dir "server/")) - -;; Packages with file/dir settings that don't use `user-emacs-directory' or -;; `locate-user-emacs-file' to initialize will need to set explicitly, to stop -;; them from littering in ~/.emacs.d/. -(setq desktop-dirname (file-name-concat doom-profile-state-dir "desktop") - pcache-directory (file-name-concat doom-profile-cache-dir "pcache/")) - -;; Allow the user to store custom.el-saved settings and themes in their Doom -;; config (e.g. ~/.doom.d/). -(setq custom-file (file-name-concat doom-user-dir "custom.el")) - -;; By default, Emacs stores `authinfo' in $HOME and in plain-text. Let's not do -;; that, mkay? This file stores usernames, passwords, and other treasures for -;; the aspiring malicious third party. You'll need a GPG setup though. -(setq auth-sources (list (file-name-concat doom-profile-state-dir "authinfo.gpg") - "~/.authinfo.gpg")) - -(define-advice en/disable-command (:around (fn &rest args) write-to-data-dir) - "Save safe-local-variables to `custom-file' instead of `user-init-file'. - -Otherwise, `en/disable-command' (in novice.el.gz) is hardcoded to write them to -`user-init-file')." - (let ((user-init-file custom-file)) - (apply fn args))) - -;;; Native compilation support (see http://akrl.sdf.org/gccemacs.html) -(when (boundp 'native-comp-eln-load-path) - ;; Don't store eln files in ~/.emacs.d/eln-cache (where they can easily be - ;; deleted by 'doom upgrade'). - ;; REVIEW Use `startup-redirect-eln-cache' when 28 support is dropped - (add-to-list 'native-comp-eln-load-path (expand-file-name "eln/" doom-profile-cache-dir)) - - ;; UX: Suppress compiler warnings and don't inundate users with their popups. - ;; They are rarely more than warnings, so are safe to ignore. - (setq native-comp-async-report-warnings-errors init-file-debug - native-comp-warning-on-missing-source init-file-debug) - - ;; HACK: native-comp-deferred-compilation-deny-list is replaced in later - ;; versions of Emacs 29, and with no deprecation warning. I alias them to - ;; ensure backwards compatibility for packages downstream that may have not - ;; caught up yet. I avoid marking it obsolete because obsolete warnings are - ;; unimportant to end-users. It's the package devs that should be informed. - (unless (boundp 'native-comp-deferred-compilation-deny-list) - (defvaralias 'native-comp-deferred-compilation-deny-list 'native-comp-jit-compilation-deny-list)) - - ;; UX: By default, native-comp uses 100% of half your cores. If you're - ;; expecting this this should be no issue, but the sudden (and silent) spike - ;; of CPU and memory utilization can alarm folks, overheat laptops, or - ;; overwhelm less performant systems. - (define-advice comp-effective-async-max-jobs (:before (&rest _) set-default-cpus) - "Default to 1/4 of cores in interactive sessions and all of them otherwise." - (and (null comp-num-cpus) - (zerop native-comp-async-jobs-number) - (setq comp-num-cpus - (max 1 (/ (num-processors) (if noninteractive 1 4))))))) - -;;; Suppress package.el -;; Since Emacs 27, package initialization occurs before `user-init-file' is -;; loaded, but after `early-init-file'. Doom handles package initialization, so -;; we must prevent Emacs from doing it again. -(setq package-enable-at-startup nil) - -;;; Reduce unnecessary/unactionable warnings/logs -;; Disable warnings from the legacy advice API. They aren't actionable or -;; useful, and often come from third party packages. -(setq ad-redefinition-action 'accept) - -;; Ignore warnings about "existing variables being aliased". Otherwise the user -;; gets very intrusive popup warnings about our (intentional) uses of -;; defvaralias, which are done because ensuring aliases are created before -;; packages are loaded is an unneeded and unhelpful maintenance burden. Emacs -;; still aliases them fine regardless. -(setq warning-suppress-types '((defvaralias))) - -;; Reduce debug output unless we've asked for it. -(setq debug-on-error init-file-debug - jka-compr-verbose init-file-debug) - -;;; Stricter security defaults -;; Emacs is essentially one huge security vulnerability, what with all the -;; dependencies it pulls in from all corners of the globe. Let's try to be a -;; *little* more discerning. -(setq gnutls-verify-error noninteractive - gnutls-algorithm-priority - (when (boundp 'libgnutls-version) - (concat "SECURE128:+SECURE192:-VERS-ALL" - (if (and (not IS-WINDOWS) - (>= libgnutls-version 30605)) - ":+VERS-TLS1.3") - ":+VERS-TLS1.2")) - ;; `gnutls-min-prime-bits' is set based on recommendations from - ;; https://www.keylength.com/en/4/ - gnutls-min-prime-bits 3072 - tls-checktrust gnutls-verify-error - ;; Emacs is built with gnutls.el by default, so `tls-program' won't - ;; typically be used, but in the odd case that it does, we ensure a more - ;; secure default for it (falling back to `openssl' if absolutely - ;; necessary). See https://redd.it/8sykl1 for details. - tls-program '("openssl s_client -connect %h:%p -CAfile %t -nbio -no_ssl3 -no_tls1 -no_tls1_1 -ign_eof" - "gnutls-cli -p %p --dh-bits=3072 --ocsp --x509cafile=%t \ ---strict-tofu --priority='SECURE192:+SECURE128:-VERS-ALL:+VERS-TLS1.2:+VERS-TLS1.3' %h" - ;; compatibility fallbacks - "gnutls-cli -p %p %h")) - - -;; -;;; Custom hooks - -(defcustom doom-before-init-hook () - "A hook run after Doom's core has initialized; before user configuration. - -This is triggered right before $DOOMDIR/init.el is loaded, in the context of -early-init.el. Use this for configuration at the latest opportunity before the -session becomes unpredictably complicated by user config, packages, etc. This -runs in both interactive and non-interactive contexts, so guard hooks -appropriately against `noninteractive' or the `cli' context (see -`doom-context'). - -In contrast, `before-init-hook' is run just after $DOOMDIR/init.el is loaded, -but long before your modules and $DOOMDIR/config.el are loaded." - :group 'doom - :type 'hook) - -(defcustom doom-after-init-hook () - "A hook run once Doom's core and modules, and the user's config are loaded. - -This triggers at the absolutel atest point in the eager startup process, and -runs in both interactive and non-interactive sessions, so guard hooks -appropriately against `noninteractive' or the `cli' context." - :group 'doom - :type 'hook) - - -;; -;;; Last minute initialization - -(add-hook! 'doom-before-init-hook :depth -105 - (defun doom--begin-init-h () - "Begin the startup process." - (when (doom-context-push 'init) - ;; Remember these variables' initial values, so we can safely reset them at - ;; a later time, or consult them without fear of contamination. - (dolist (var '(exec-path load-path process-environment)) - (put var 'initial-value (default-toplevel-value var)))))) - -(add-hook! 'doom-after-init-hook :depth 105 - (defun doom--end-init-h () - "Set `doom-init-time'." - (when (doom-context-pop 'init) - (setq doom-init-time (float-time (time-subtract (current-time) before-init-time)))))) - -(unless noninteractive - ;; This is the absolute latest a hook can run in Emacs' startup process. - (define-advice command-line-1 (:after (&rest _) run-after-init-hook) - (doom-run-hooks 'doom-after-init-hook))) - -(provide 'doom) -;;; doom.el ends here diff --git a/.config/emacs/lisp/init.el b/.config/emacs/lisp/init.el @@ -1,16 +0,0 @@ -;;; lisp/init.el -*- lexical-binding: t; -*- -;;; Commentary: -;; -;; :core is now treated like a normal module, and this is its (temporary) init -;; file, which will be removed once we've resolved our `use-package' dependency -;; (which will soon be moved to its own module), then these will be returned to -;; the profile init file. -;; -;;; Code: - -(doom-require 'doom-keybinds) -(doom-require 'doom-ui) -(doom-require 'doom-projects) -(doom-require 'doom-editor) - -;;; init.el ends here diff --git a/.config/emacs/lisp/lib/autoloads.el b/.config/emacs/lisp/lib/autoloads.el @@ -1,199 +0,0 @@ -;;; lisp/lib/autoloads.el -*- lexical-binding: t; -*- -;;; Commentary: -;;; Code: - -(defvar doom-autoloads-excluded-packages () - "Which packages to exclude from Doom's autoloads files. - -Use this for packages with problematic autoloads; e.g. they autoload too much or -hoist buggy forms into autoloads.") - -(defvar doom-autoloads-excluded-files () - "List of regexps whose matching files won't be indexed for autoloads.") - -(defvar doom-autoloads-cached-vars - '(load-path - auto-mode-alist - interpreter-mode-alist - magic-mode-alist - magic-fallback-mode-alist - Info-directory-list) - "A list of variables to be cached in `doom-autoloads-file'.") - -(defvar doom-autoloads-files () - "A list of additional files or file globs to scan for autoloads.") - - -;; -;;; Library - -(defun doom-autoloads--write (file &rest forms) - (make-directory (file-name-directory file) 'parents) - (condition-case-unless-debug e - (with-temp-file file - (setq-local coding-system-for-write 'utf-8) - (let ((standard-output (current-buffer)) - (print-quoted t) - (print-level nil) - (print-length nil)) - (insert ";; -*- lexical-binding: t; coding: utf-8; no-native-compile: t -*-\n" - ";; This file is autogenerated by 'doom sync', DO NOT EDIT IT!!\n") - (dolist (form (delq nil forms)) - (mapc #'prin1 form)) - t)) - (error (delete-file file) - (signal 'doom-autoload-error (list file e))))) - -(defun doom-autoloads--compile-file (file) - (condition-case-unless-debug e - (let ((byte-compile-warnings (if init-file-debug byte-compile-warnings))) - (and (byte-compile-file file) - (load (byte-compile-dest-file file) nil t))) - (error - (delete-file (byte-compile-dest-file file)) - (signal 'doom-autoload-error (list file e))))) - -(defun doom-autoloads--cleanup-form (form &optional expand) - (let ((func (car-safe form))) - (cond ((memq func '(provide custom-autoload register-definition-prefixes)) - nil) - ((and (eq func 'add-to-list) - (memq (doom-unquote (cadr form)) - doom-autoloads-cached-vars)) - nil) - ((not (eq func 'autoload)) - form) - ((and expand (not (file-name-absolute-p (nth 2 form)))) - (defvar doom--autoloads-path-cache nil) - (setf (nth 2 form) - (let ((path (nth 2 form))) - (or (cdr (assoc path doom--autoloads-path-cache)) - (when-let* ((libpath (locate-library path)) - (libpath (file-name-sans-extension libpath)) - (libpath (abbreviate-file-name libpath))) - (push (cons path libpath) doom--autoloads-path-cache) - libpath) - path))) - form) - (form)))) - -(defun doom-autoloads--scan-autodefs (file buffer module &optional module-enabled-p) - (with-temp-buffer - (insert-file-contents file) - (while (re-search-forward "^;;;###autodef *\\([^\n]+\\)?\n" nil t) - (let* ((standard-output buffer) - (form (read (current-buffer))) - (altform (match-string 1)) - (definer (car-safe form)) - (symbol (doom-unquote (cadr form)))) - (cond ((and (not module-enabled-p) altform) - (print (read altform))) - ((memq definer '(defun defmacro cl-defun cl-defmacro)) - (print - (if module-enabled-p - (make-autoload form (abbreviate-file-name file)) - (seq-let (_ _ arglist &rest body) form - (if altform - (read altform) - (append - (list (pcase definer - (`defun 'defmacro) - (`cl-defun `cl-defmacro) - (_ type)) - symbol arglist - (format "THIS FUNCTION DOES NOTHING BECAUSE %s IS DISABLED\n\n%s" - module (if (stringp (car body)) - (pop body) - "No documentation."))) - (cl-loop for arg in arglist - if (symbolp arg) - if (not (keywordp arg)) - if (not (memq arg cl--lambda-list-keywords)) - collect arg into syms - else if (listp arg) - collect (car arg) into syms - finally return (if syms `((ignore ,@syms))))))))) - (print `(put ',symbol 'doom-module ',module))) - ((eq definer 'defalias) - (seq-let (_ _ target docstring) form - (unless module-enabled-p - (setq target #'ignore - docstring - (format "THIS FUNCTION DOES NOTHING BECAUSE %s IS DISABLED\n\n%s" - module docstring))) - (print `(put ',symbol 'doom-module ',module)) - (print `(defalias ',symbol #',(doom-unquote target) ,docstring)))) - (module-enabled-p (print form))))))) - -(defvar autoload-timestamps) -(defvar generated-autoload-load-name) -(defun doom-autoloads--scan-file (file) - (let* (;; Prevent `autoload-find-file' from firing file hooks, e.g. adding - ;; to recentf. - find-file-hook - write-file-functions - ;; Prevent a possible source of crashes when there's a syntax error in - ;; the autoloads file. - debug-on-error - ;; Non-nil interferes with autoload generation in Emacs < 29. See - ;; radian-software/straight.el#904. - (left-margin 0) - ;; The following bindings are in `package-generate-autoloads'. - ;; Presumably for a good reason, so I just copied them. - (backup-inhibited t) - (version-control 'never) - case-fold-search ; reduce magic - autoload-timestamps ; reduce noise in generated files - autoload-compute-prefixes - ;; So `autoload-generate-file-autoloads' knows where to write it - (target-buffer (current-buffer)) - (module (doom-module-from-path file)) - (generated-autoload-load-name (abbreviate-file-name (file-name-sans-extension file))) - (module-enabled-p (and (doom-module-p (car module) (cdr module)) - (doom-file-cookie-p file "if" t)))) - (save-excursion - (when module-enabled-p - (quiet! (autoload-generate-file-autoloads file target-buffer))) - (doom-autoloads--scan-autodefs - file target-buffer module module-enabled-p)))) - -(defun doom-autoloads--scan (files &optional exclude literal) - "Scan and return all autoloaded forms in FILES. - -Autoloads will be generated from autoload cookies in FILES (except those that -match one of the regexps in EXCLUDE -- a list of strings). If LITERAL is -non-nil, treat FILES as pre-generated autoload files instead." - (require 'autoload) - (let (autoloads) - (dolist (file files (nreverse (delq nil autoloads))) - (when (and (not (seq-find (doom-rpartial #'string-match-p file) exclude)) - (file-readable-p file)) - (doom-log "loaddefs:scan: %s" file) - (setq file (file-truename file)) - (with-temp-buffer - (if literal - (insert-file-contents file) - (doom-autoloads--scan-file file)) - (save-excursion - (while (re-search-forward "\\_<load-file-name\\_>" nil t) - ;; `load-file-name' is meaningless in a concatenated - ;; mega-autoloads file, but also essential in isolation, so we - ;; replace references to it with the file they came from. - (let ((ppss (save-excursion (syntax-ppss)))) - (or (nth 3 ppss) - (nth 4 ppss) - (replace-match (prin1-to-string (abbreviate-file-name file)) t t))))) - (let ((load-file-name file) - (load-path - (append (list doom-user-dir) - doom-modules-dirs - load-path))) - (condition-case _ - (while t - (push (doom-autoloads--cleanup-form (read (current-buffer)) - (not literal)) - autoloads)) - (end-of-file)))))))) - -(provide 'doom-lib '(autoloads)) -;;; autoloads.el end here diff --git a/.config/emacs/lisp/lib/buffers.el b/.config/emacs/lisp/lib/buffers.el @@ -1,393 +0,0 @@ -;;; lisp/lib/buffers.el -*- lexical-binding: t; -*- - -;;;###autoload -(defvar doom-real-buffer-functions - '(doom-dired-buffer-p) - "A list of predicate functions run to determine if a buffer is real, unlike -`doom-unreal-buffer-functions'. They are passed one argument: the buffer to be -tested. - -Should any of its function returns non-nil, the rest of the functions are -ignored and the buffer is considered real. - -See `doom-real-buffer-p' for more information.") - -;;;###autoload -(defvar doom-unreal-buffer-functions - '(minibufferp doom-special-buffer-p doom-non-file-visiting-buffer-p) - "A list of predicate functions run to determine if a buffer is *not* real, -unlike `doom-real-buffer-functions'. They are passed one argument: the buffer to -be tested. - -Should any of these functions return non-nil, the rest of the functions are -ignored and the buffer is considered unreal. - -See `doom-real-buffer-p' for more information.") - -;;;###autoload -(defvar-local doom-real-buffer-p nil - "If non-nil, this buffer should be considered real no matter what. See -`doom-real-buffer-p' for more information.") - -;;;###autoload -(defvar doom-fallback-buffer-name "*scratch*" - "The name of the buffer to fall back to if no other buffers exist (will create -it if it doesn't exist).") - - -;; -;;; Functions - -;;;###autoload -(defun doom-buffer-frame-predicate (buf) - "To be used as the default frame buffer-predicate parameter. Returns nil if -BUF should be skipped over by functions like `next-buffer' and `other-buffer'." - (or (doom-real-buffer-p buf) - (eq buf (doom-fallback-buffer)))) - -;;;###autoload -(defun doom-fallback-buffer () - "Returns the fallback buffer, creating it if necessary. By default this is the -scratch buffer. See `doom-fallback-buffer-name' to change this." - (let (buffer-list-update-hook) - (get-buffer-create doom-fallback-buffer-name))) - -;;;###autoload -(defalias 'doom-buffer-list #'buffer-list) - -;;;###autoload -(defun doom-project-buffer-list (&optional project) - "Return a list of buffers belonging to the specified PROJECT. - -If PROJECT is nil, default to the current project. - -If no project is active, return all buffers." - (let ((buffers (doom-buffer-list))) - (if-let* ((project-root - (if project (expand-file-name project) - (doom-project-root)))) - (cl-loop for buf in buffers - if (projectile-project-buffer-p buf project-root) - collect buf) - buffers))) - -;;;###autoload -(defun doom-open-projects () - "Return a list of projects with open buffers." - (cl-loop with projects = (make-hash-table :test 'equal :size 8) - for buffer in (doom-buffer-list) - if (buffer-live-p buffer) - if (doom-real-buffer-p buffer) - if (with-current-buffer buffer (doom-project-root)) - do (puthash (abbreviate-file-name it) t projects) - finally return (hash-table-keys projects))) - -;;;###autoload -(defun doom-dired-buffer-p (buf) - "Returns non-nil if BUF is a dired buffer." - (provided-mode-derived-p (buffer-local-value 'major-mode buf) - 'dired-mode)) - -;;;###autoload -(defun doom-special-buffer-p (buf) - "Returns non-nil if BUF's name starts and ends with an *." - (equal (substring (buffer-name buf) 0 1) "*")) - -;;;###autoload -(defun doom-temp-buffer-p (buf) - "Returns non-nil if BUF is temporary." - (equal (substring (buffer-name buf) 0 1) " ")) - -;;;###autoload -(defun doom-visible-buffer-p (buf) - "Return non-nil if BUF is visible." - (get-buffer-window buf)) - -;;;###autoload -(defun doom-buried-buffer-p (buf) - "Return non-nil if BUF is not visible." - (not (doom-visible-buffer-p buf))) - -;;;###autoload -(defun doom-non-file-visiting-buffer-p (buf) - "Returns non-nil if BUF does not have a value for `buffer-file-name'." - (not (buffer-file-name buf))) - -;;;###autoload -(defun doom-real-buffer-list (&optional buffer-list) - "Return a list of buffers that satisfy `doom-real-buffer-p'." - (cl-remove-if-not #'doom-real-buffer-p (or buffer-list (doom-buffer-list)))) - -;;;###autoload -(defun doom-real-buffer-p (buffer-or-name) - "Returns t if BUFFER-OR-NAME is a 'real' buffer. - -A real buffer is a useful buffer; a first class citizen in Doom. Real ones -should get special treatment, because we will be spending most of our time in -them. Unreal ones should be low-profile and easy to cast aside, so we can focus -on real ones. - -The exact criteria for a real buffer is: - - 1. A non-nil value for the buffer-local value of the `doom-real-buffer-p' - variable OR - 2. Any function in `doom-real-buffer-functions' returns non-nil OR - 3. None of the functions in `doom-unreal-buffer-functions' must return - non-nil. - -If BUFFER-OR-NAME is omitted or nil, the current buffer is tested." - (or (bufferp buffer-or-name) - (stringp buffer-or-name) - (signal 'wrong-type-argument (list '(bufferp stringp) buffer-or-name))) - (when-let (buf (get-buffer buffer-or-name)) - (when-let (basebuf (buffer-base-buffer buf)) - (setq buf basebuf)) - (and (buffer-live-p buf) - (not (doom-temp-buffer-p buf)) - (or (buffer-local-value 'doom-real-buffer-p buf) - (run-hook-with-args-until-success 'doom-real-buffer-functions buf) - (not (run-hook-with-args-until-success 'doom-unreal-buffer-functions buf)))))) - -;;;###autoload -(defun doom-unreal-buffer-p (buffer-or-name) - "Return t if BUFFER-OR-NAME is an 'unreal' buffer. - -See `doom-real-buffer-p' for details on what that means." - (not (doom-real-buffer-p buffer-or-name))) - -;;;###autoload -(defun doom-buffers-in-mode (modes &optional buffer-list derived-p) - "Return a list of buffers whose `major-mode' is `eq' to MODE(S). - -If DERIVED-P, test with `derived-mode-p', otherwise use `eq'." - (let ((modes (ensure-list modes))) - (cl-remove-if-not (if derived-p - (lambda (buf) - (apply #'provided-mode-derived-p - (buffer-local-value 'major-mode buf) - modes)) - (lambda (buf) - (memq (buffer-local-value 'major-mode buf) modes))) - (or buffer-list (doom-buffer-list))))) - -;;;###autoload -(defun doom-visible-windows (&optional window-list) - "Return a list of the visible, non-popup (dedicated) windows." - (cl-loop for window in (or window-list (window-list)) - when (or (window-parameter window 'visible) - (not (window-dedicated-p window))) - collect window)) - -;;;###autoload -(defun doom-visible-buffers (&optional buffer-list) - "Return a list of visible buffers (i.e. not buried)." - (let ((buffers (delete-dups (mapcar #'window-buffer (window-list))))) - (if buffer-list - (cl-delete-if (lambda (b) (memq b buffer-list)) - buffers) - (delete-dups buffers)))) - -;;;###autoload -(defun doom-buried-buffers (&optional buffer-list) - "Get a list of buffers that are buried." - (cl-remove-if #'get-buffer-window (or buffer-list (doom-buffer-list)))) - -;;;###autoload -(defun doom-matching-buffers (pattern &optional buffer-list) - "Get a list of all buffers that match the regex PATTERN." - (cl-loop for buf in (or buffer-list (doom-buffer-list)) - when (string-match-p pattern (buffer-name buf)) - collect buf)) - -;;;###autoload -(defun doom-set-buffer-real (buffer flag) - "Forcibly mark BUFFER as FLAG (non-nil = real). - -See `doom-real-buffer-p' for an explanation for real buffers." - (with-current-buffer buffer - (setq doom-real-buffer-p flag))) - -;;;###autoload -(defun doom-kill-buffer-and-windows (buffer) - "Kill the buffer and delete all the windows it's displayed in." - (dolist (window (get-buffer-window-list buffer)) - (unless (one-window-p t) - (delete-window window))) - (kill-buffer buffer)) - -;;;###autoload -(defun doom-fixup-windows (windows) - "Ensure that each of WINDOWS is showing a real buffer or the fallback buffer." - (dolist (window windows) - (with-selected-window window - (when (doom-unreal-buffer-p (window-buffer)) - (previous-buffer) - (when (doom-unreal-buffer-p (window-buffer)) - (switch-to-buffer (doom-fallback-buffer))))))) - -;;;###autoload -(defun doom-kill-buffer-fixup-windows (buffer) - "Kill the BUFFER and ensure all the windows it was displayed in have switched -to a real buffer or the fallback buffer." - (let ((windows (get-buffer-window-list buffer))) - (kill-buffer buffer) - (doom-fixup-windows (cl-remove-if-not #'window-live-p windows)))) - -;;;###autoload -(defun doom-kill-buffers-fixup-windows (buffers) - "Kill the BUFFERS and ensure all the windows they were displayed in have -switched to a real buffer or the fallback buffer." - (let ((seen-windows (make-hash-table :test 'eq :size 8))) - (dolist (buffer buffers) - (let ((windows (get-buffer-window-list buffer))) - (kill-buffer buffer) - (dolist (window (cl-remove-if-not #'window-live-p windows)) - (puthash window t seen-windows)))) - (doom-fixup-windows (hash-table-keys seen-windows)))) - -;;;###autoload -(defun doom-kill-matching-buffers (pattern &optional buffer-list) - "Kill all buffers (in current workspace OR in BUFFER-LIST) that match the -regex PATTERN. Returns the number of killed buffers." - (let ((buffers (doom-matching-buffers pattern buffer-list))) - (dolist (buf buffers (length buffers)) - (kill-buffer buf)))) - - -;; -;; Hooks - -;;;###autoload -(defun doom-mark-buffer-as-real-h () - "Hook function that marks the current buffer as real. - -See `doom-real-buffer-p' for an explanation for real buffers." - (doom-set-buffer-real (current-buffer) t)) - - -;; -;; Interactive commands - -;;;###autoload -(defun doom/save-and-kill-buffer () - "Save the current buffer to file, then kill it." - (interactive) - (save-buffer) - (kill-current-buffer)) - -;;;###autoload -(defun doom/kill-this-buffer-in-all-windows (buffer &optional dont-save) - "Kill BUFFER globally and ensure all windows previously showing this buffer -have switched to a real buffer or the fallback buffer. - -If DONT-SAVE, don't prompt to save modified buffers (discarding their changes)." - (interactive - (list (current-buffer) current-prefix-arg)) - (cl-assert (bufferp buffer) t) - (when (and (buffer-modified-p buffer) dont-save) - (with-current-buffer buffer - (set-buffer-modified-p nil))) - (doom-kill-buffer-fixup-windows buffer)) - - -(defun doom--message-or-count (interactive message count) - (if interactive - (message message count) - count)) - -;;;###autoload -(defun doom/kill-all-buffers (&optional buffer-list interactive) - "Kill all buffers and closes their windows. - -If the prefix arg is passed, doesn't close windows and only kill buffers that -belong to the current project." - (interactive - (list (if current-prefix-arg - (doom-project-buffer-list) - (doom-buffer-list)) - t)) - (if (null buffer-list) - (message "No buffers to kill") - (save-some-buffers) - (delete-other-windows) - (when (memq (current-buffer) buffer-list) - (switch-to-buffer (doom-fallback-buffer))) - (mapc #'kill-buffer buffer-list) - (doom--message-or-count - interactive "Killed %d buffers" - (- (length buffer-list) - (length (cl-remove-if-not #'buffer-live-p buffer-list)))))) - -;;;###autoload -(defun doom/kill-other-buffers (&optional buffer-list interactive) - "Kill all other buffers (besides the current one). - -If the prefix arg is passed, kill only buffers that belong to the current -project." - (interactive - (list (delq (current-buffer) - (if current-prefix-arg - (doom-project-buffer-list) - (doom-buffer-list))) - t)) - (mapc #'doom-kill-buffer-and-windows buffer-list) - (doom--message-or-count - interactive "Killed %d other buffers" - (- (length buffer-list) - (length (cl-remove-if-not #'buffer-live-p buffer-list))))) - -;;;###autoload -(defun doom/kill-matching-buffers (pattern &optional buffer-list interactive) - "Kill buffers that match PATTERN in BUFFER-LIST. - -If the prefix arg is passed, only kill matching buffers in the current project." - (interactive - (list (read-regexp "Buffer pattern: ") - (if current-prefix-arg - (doom-project-buffer-list) - (doom-buffer-list)) - t)) - (doom-kill-matching-buffers pattern buffer-list) - (when interactive - (message "Killed %d buffer(s)" - (- (length buffer-list) - (length (cl-remove-if-not #'buffer-live-p buffer-list)))))) - -;;;###autoload -(defun doom/kill-buried-buffers (&optional buffer-list interactive) - "Kill buffers that are buried. - -If PROJECT-P (universal argument), only kill buried buffers belonging to the -current project." - (interactive - (list (doom-buried-buffers - (if current-prefix-arg (doom-project-buffer-list))) - t)) - (mapc #'kill-buffer buffer-list) - (doom--message-or-count - interactive "Killed %d buried buffers" - (- (length buffer-list) - (length (cl-remove-if-not #'buffer-live-p buffer-list))))) - -;;;###autoload -(defun doom/kill-project-buffers (project &optional interactive) - "Kill buffers for the specified PROJECT." - (interactive - (list (if-let (open-projects (doom-open-projects)) - (completing-read - "Kill buffers for project: " open-projects - nil t nil nil - (if-let* ((project-root (doom-project-root)) - (project-root (abbreviate-file-name project-root)) - ((member project-root open-projects))) - project-root)) - (message "No projects are open!") - nil) - t)) - (when project - (let ((buffer-list (doom-project-buffer-list project))) - (doom-kill-buffers-fixup-windows buffer-list) - (doom--message-or-count - interactive "Killed %d project buffers" - (- (length buffer-list) - (length (cl-remove-if-not #'buffer-live-p buffer-list))))))) diff --git a/.config/emacs/lisp/lib/config.el b/.config/emacs/lisp/lib/config.el @@ -1,137 +0,0 @@ -;;; lisp/lib/config.el -*- lexical-binding: t; -*- - -(defvar doom-bin-dir (expand-file-name "bin/" doom-emacs-dir)) -(defvar doom-bin (expand-file-name "doom" doom-bin-dir)) - -;;;###autoload -(defvar doom-after-reload-hook nil - "A list of hooks to run after `doom/reload' has reloaded Doom.") - -;;;###autoload -(defvar doom-before-reload-hook nil - "A list of hooks to run before `doom/reload' has reloaded Doom.") - -;;;###autoload -(defun doom/open-private-config () - "Browse your `doom-user-dir'." - (interactive) - (unless (file-directory-p doom-user-dir) - (make-directory doom-user-dir t)) - (doom-project-browse doom-user-dir)) - -;;;###autoload -(defun doom/find-file-in-private-config () - "Search for a file in `doom-user-dir'." - (interactive) - (doom-project-find-file doom-user-dir)) - -;;;###autoload -(defun doom/goto-private-init-file () - "Open your private init.el file. -And jumps to your `doom!' block." - (interactive) - (find-file (expand-file-name doom-module-init-file doom-user-dir)) - (goto-char - (or (save-excursion - (goto-char (point-min)) - (search-forward "(doom!" nil t)) - (point)))) - -;;;###autoload -(defun doom/goto-private-config-file () - "Open your private config.el file." - (interactive) - (find-file (expand-file-name doom-module-config-file doom-user-dir))) - -;;;###autoload -(defun doom/goto-private-packages-file () - "Open your private packages.el file." - (interactive) - (find-file (expand-file-name doom-module-packages-file doom-user-dir))) - - -;; -;;; Managements - -(defmacro doom--if-compile (command on-success &optional on-failure) - (declare (indent 2)) - `(let ((default-directory doom-emacs-dir)) - (with-current-buffer (compile ,command t) - (let ((w (get-buffer-window (current-buffer)))) - (select-window w) - (add-hook - 'compilation-finish-functions - (lambda (_buf status) - (if (equal status "finished\n") - (progn - (delete-window w) - ,on-success) - ,on-failure)) - nil 'local))))) - -;;;###autoload -(defun doom/reload () - "Reloads your private config. - -This is experimental! It will try to do as `bin/doom sync' does, but from within -this Emacs session. i.e. it reload autoloads files (if necessary), reloads your -package list, and lastly, reloads your private config.el. - -Runs `doom-after-reload-hook' afterwards." - (interactive) - (mapc #'require (cdr doom-incremental-packages)) - (doom--if-compile (format "%S sync -e" doom-bin) - (doom-context-with '(reload modules) - (doom-run-hooks 'doom-before-reload-hook) - (doom-load (file-name-concat doom-user-dir doom-module-init-file) t) - (with-demoted-errors "PRIVATE CONFIG ERROR: %s" - (general-auto-unbind-keys) - (unwind-protect - (startup--load-user-init-file nil) - (general-auto-unbind-keys t))) - (doom-run-hooks 'doom-after-reload-hook) - (message "Config successfully reloaded!")) - (user-error "Failed to reload your config"))) - -;;;###autoload -(defun doom/reload-autoloads () - "Reload only the autoloads of the current profile. - -This is much faster and safer than `doom/reload', but not as comprehensive. This -reloads your package and module visibility, but does not install new packages or -remove orphaned ones. It also doesn't reload your private config. - -It is useful to only pull in changes performed by 'doom sync' on the command -line." - (interactive) - (require 'doom-profiles) - ;; TODO: Make this more robust - (doom-context-with 'reload - (dolist (file (mapcar #'car doom-profile-generators)) - (when (string-match-p "/[0-9]+-loaddefs[.-]" file) - (load (doom-path doom-profile-dir doom-profile-init-dir-name file) - 'noerror))))) - -;;;###autoload -(defun doom/reload-env () - "Reloads your envvar file. - -DOES NOT REGENERATE IT. You must run 'doom env' in your shell OUTSIDE of Emacs. -Doing so from within Emacs will taint your shell environment. - -An envvar file contains a snapshot of your shell environment, which can be -imported into Emacs." - (interactive) - (doom-context-with 'reload - (let ((default-directory doom-emacs-dir)) - (with-temp-buffer - (doom-load-envvars-file doom-env-file) - (message "Reloaded %S" (abbreviate-file-name doom-env-file)))))) - -;;;###autoload -(defun doom/upgrade () - "Run 'doom upgrade' then prompt to restart Emacs." - (interactive) - (doom--if-compile (format "%S upgrade --force" doom-bin) - (when (y-or-n-p "You must restart Emacs for the upgrade to take effect.\n\nRestart Emacs?") - (doom/restart-and-restore)))) diff --git a/.config/emacs/lisp/lib/debug.el b/.config/emacs/lisp/lib/debug.el @@ -1,444 +0,0 @@ -;;; lisp/lib/debug.el -*- lexical-binding: t; -*- -;;; Commentary: -;;; Code: - -;; -;;; Doom's debug mode - -;;;###autoload -(defvar doom-debug-variables - `(;; Doom variables - (doom-print-minimum-level . debug) - (doom-inhibit-log . nil) - - ;; Emacs variables - async-debug - debug-on-error - gcmh-verbose - init-file-debug - jka-compr-verbose - (message-log-max . 16384) - (native-comp-async-report-warnings-errors . silent) - (native-comp-warning-on-missing-source . t) - url-debug - use-package-verbose - (warning-suppress-types . nil)) - "A list of variable to toggle on `doom-debug-mode'. - -Each entry can be a variable symbol or a cons cell whose CAR is the variable -symbol and CDR is the value to set it to when `doom-debug-mode' is activated.") - -(defvar doom-debug--unbound-vars nil) - -(defun doom-debug--watch-vars-h (&rest _) - (when-let (vars (copy-sequence doom-debug--unbound-vars)) - (setq doom-debug--unbound-vars nil) - (mapc #'doom-debug--set-var vars))) - -(defun doom-debug--set-var (spec) - (cond ((listp spec) - (pcase-let ((`(,var . ,val) spec)) - (if (boundp var) - (set-default - var (if (not doom-debug-mode) - (prog1 (get var 'initial-value) - (put var 'initial-value nil)) - (doom-log "debug:vars: %s = %S" var (default-toplevel-value var)) - (put var 'initial-value (default-toplevel-value var)) - val)) - (add-to-list 'doom-debug--unbound-vars spec)))) - ((boundp spec) - (doom-log "debug:vars: %s = %S" spec doom-debug-mode) - (set-default-toplevel-value spec doom-debug-mode)) - ((add-to-list 'doom-debug--unbound-vars (cons spec t))))) - -;;;###autoload -(define-minor-mode doom-debug-mode - "Toggle `debug-on-error' and `init-file-debug' for verbose logging." - :global t - (let ((enabled doom-debug-mode)) - (doom-log "debug: enabled!") - (mapc #'doom-debug--set-var doom-debug-variables) - (when (called-interactively-p 'any) - (when (fboundp 'explain-pause-mode) - (explain-pause-mode (if enabled +1 -1)))) - ;; Watch for changes in `doom-debug-variables', or when packages load (and - ;; potentially define one of `doom-debug-variables'), in case some of them - ;; aren't defined when `doom-debug-mode' is first loaded. - (cond (enabled - (unless noninteractive - (message "Debug mode enabled! (Run 'M-x view-echo-area-messages' to open the log buffer)")) - ;; Produce more helpful (and visible) error messages from errors - ;; emitted from hooks (particularly mode hooks), that usually go - ;; unnoticed otherwise. - (advice-add #'run-hooks :override #'doom-run-hooks) - ;; Add time stamps to lines in *Messages* - (advice-add #'message :before #'doom--timestamped-message-a) - ;; The constant debug output from GC is mostly unhelpful. I still - ;; want it logged to *Messages*, just out of the echo area. - (advice-add #'gcmh-idle-garbage-collect :around #'doom-debug-shut-up-a) - (add-variable-watcher 'doom-debug-variables #'doom-debug--watch-vars-h) - (add-hook 'after-load-functions #'doom-debug--watch-vars-h)) - (t - (advice-remove #'run-hooks #'doom-run-hooks) - (advice-remove #'message #'doom--timestamped-message-a) - (advice-remove #'gcmh-idle-garbage-collect #'doom-debug-shut-up-a) - (remove-variable-watcher 'doom-debug-variables #'doom-debug--watch-vars-h) - (remove-hook 'after-load-functions #'doom-debug--watch-vars-h) - (doom-log "debug: disabled") - (message "Debug mode disabled!"))))) - -(defun doom-debug-shut-up-a (fn &rest args) - "Suppress output from FN, even in debug mode." - (let (init-file-debug) - (apply #'doom-shut-up-a fn args))) - - -;; -;;; Custom debugger - -;; HACK: I advise `debug' instead of changing `debugger' to hide the debugger -;; itself from the backtrace. Doing it manually would require reimplementing -;; most of `debug', which is a lot of unnecessary work, when I only want to -;; decorate the original one slightly. -(defadvice! doom-debugger-a (fn &rest args) - :around #'debug - ;; Without `doom-debug-mode', be as vanilla as possible. - (if (not doom-debug-mode) - (apply fn args) - ;; Work around Emacs's heuristic (in eval.c) for detecting errors in the - ;; debugger, which would run this handler again on subsequent calls. Taken - ;; from `ert--run-test-debugger'. - (if (and noninteractive (fboundp 'doom-cli-debugger)) - (apply #'doom-cli-debugger args) - ;; TODO: Write backtraces to file - ;; TODO: Write backtrace to a buffer in case recursive error interupts the - ;; debugger (happens more often than it should). - (apply fn args)))) - -(autoload 'backtrace-get-frames "backtrace") -;;;###autoload -(defun doom-backtrace () - "Return a stack trace as a list of `backtrace-frame' objects." - ;; (let* ((n 0) - ;; (frame (backtrace-frame n)) - ;; (frame-list nil) - ;; (in-program-stack nil)) - ;; (while frame - ;; (when in-program-stack - ;; (push (cdr frame) frame-list)) - ;; (when (eq (elt frame 1) debugger) - ;; (setq in-program-stack t)) - ;; ;; (when (and (eq (elt frame 1) 'doom-cli-execute) - ;; ;; (eq (elt frame 2) :doom)) - ;; ;; (setq in-program-stack nil)) - ;; (setq n (1+ n) - ;; frame (backtrace-frame n))) - ;; (nreverse frame-list)) - (cdr (backtrace-get-frames debugger))) - -(defun doom-backtrace-write-to-file (backtrace file) - "Write BACKTRACE to FILE with appropriate boilerplate." - (make-directory (file-name-directory file) t) - (let ((doom-print-indent 0)) - (with-temp-file file - (insert ";; -*- lisp-interaction -*-\n") - (insert ";; vim: set ft=lisp:\n") - (insert (format ";; command=%S\n" command-line-args)) - (insert (format ";; date=%S\n\n" (format-time-string "%Y-%m-%d %H-%M-%S" before-init-time))) - (insert ";;;; ENVIRONMENT\n" (with-output-to-string (doom/version)) "\n") - (let ((standard-output (current-buffer)) - (print-quoted t) - (print-escape-newlines t) - (print-escape-control-characters t) - (print-symbols-bare t) - (print-level nil) - (print-circle nil) - (n -1)) - (mapc (lambda (frame) - (princ (format ";;;; %d\n" (cl-incf n))) - (pp (list (cons (backtrace-frame-fun frame) - (backtrace-frame-args frame)) - (backtrace-frame-locals frame))) - (terpri)) - backtrace)) - file))) - - -;; -;;; Time-stamped *Message* logs - -(defun doom--timestamped-message-a (format-string &rest _args) - "Advice to run before `message' that prepends a timestamp to each message. - -Activate this advice with: -(advice-add 'message :before 'doom--timestamped-message-a)" - (when (and (stringp format-string) - message-log-max ; if nil, logging is disabled - (not (equal format-string "%s%s")) - (not (equal format-string "\n"))) - (with-current-buffer "*Messages*" - (let ((timestamp (format-time-string "[%F %T] " (current-time))) - (deactivate-mark nil)) - (with-silent-modifications - (goto-char (point-max)) - (if (not (bolp)) - (newline)) - (insert timestamp)))) - (let ((window (get-buffer-window "*Messages*"))) - (when (and window (not (equal (selected-window) window))) - (with-current-buffer "*Messages*" - (goto-char (point-max)) - (set-window-point window (point-max))))))) - - -;; -;;; Hooks - -;;;###autoload -(defun doom-run-all-startup-hooks-h () - "Run all startup Emacs hooks. Meant to be executed after starting Emacs with --q or -Q, for example: - - emacs -Q -l init.el -f doom-run-all-startup-hooks-h" - (setq after-init-time (current-time)) - (let ((inhibit-startup-hooks nil)) - (doom-run-hooks 'after-init-hook - 'delayed-warnings-hook - 'emacs-startup-hook - 'tty-setup-hook - 'window-setup-hook))) - - -;; -;;; Helpers - -(defsubst doom--collect-forms-in (file form) - (when (file-readable-p file) - (let (forms) - (with-temp-buffer - (insert-file-contents file) - (with-syntax-table emacs-lisp-mode-syntax-table - (while (re-search-forward (format "(%s " (regexp-quote form)) nil t) - (let ((ppss (syntax-ppss))) - (unless (or (nth 4 ppss) - (nth 3 ppss)) - (save-excursion - (goto-char (match-beginning 0)) - (push (sexp-at-point) forms)))))) - (nreverse forms))))) - -;;;###autoload -(defun doom-info () - "Returns diagnostic information about the current Emacs session in markdown, -ready to be pasted in a bug report on github." - (require 'vc-git) - (require 'doom-packages) - (let ((default-directory doom-emacs-dir)) - (letf! ((defun sh (&rest args) (cdr (apply #'doom-call-process args))) - (defun cat (file &optional limit) - (with-temp-buffer - (insert-file-contents file nil 0 limit) - (buffer-string))) - (defun abbrev-path (path) - (replace-regexp-in-string - (regexp-opt (list (user-login-name)) 'words) "$USER" - (abbreviate-file-name path))) - (defun symlink-path (file) - (format "%s%s" (abbrev-path file) - (if (file-symlink-p file) - (concat " -> " (abbrev-path (file-truename file))) - "")))) - `((generated . ,(format-time-string "%b %d, %Y %H:%M:%S")) - (system . ,(delq - nil (list (doom-system-distro-version) - (when (executable-find "uname") - (sh "uname" "-msr")) - (window-system)))) - (emacs . ,(delq - nil (list emacs-version - (bound-and-true-p emacs-repository-branch) - (and (stringp emacs-repository-version) - (substring emacs-repository-version 0 9)) - (symlink-path doom-emacs-dir)))) - (doom . ,(list doom-version - (if doom-profile - (format "PROFILE=%s@%s" - (car doom-profile) - (cdr doom-profile)) - "PROFILE=_@0") - (if (file-exists-p! ".git" doom-emacs-dir) - (sh "git" "log" "-1" "--format=%D %h %ci") - "[no repo]") - (symlink-path doom-user-dir))) - (shell . ,(abbrev-path shell-file-name)) - (features . ,system-configuration-features) - (traits - . ,(mapcar - #'symbol-name - (delq - nil (list (cond (noninteractive 'batch) - ((display-graphic-p) 'gui) - ('tty)) - (if (daemonp) 'daemon) - (if (and (require 'server) - (server-running-p)) - 'server-running) - (if (boundp 'chemacs-version) - (intern (format "chemacs-%s" chemacs-version))) - (if (file-exists-p doom-env-file) - 'envvar-file) - (if (featurep 'exec-path-from-shell) - 'exec-path-from-shell) - (if (file-symlink-p doom-emacs-dir) - 'symlinked-emacsdir) - (if (file-symlink-p doom-user-dir) - 'symlinked-doomdir) - (if (and (stringp custom-file) (file-exists-p custom-file)) - 'custom-file) - (if (doom-files-in doom-user-dir :type 'files :match "\\.elc$") - 'compiled-user-config) - (if (doom-files-in doom-core-dir :type 'files :match "\\.elc$") - 'compiled-core) - (if (doom-files-in doom-modules-dirs :type 'files :match "\\.elc$") - 'compiled-modules))))) - (custom - ,@(when (and (stringp custom-file) - (file-exists-p custom-file)) - (cl-loop for (type var _) in (get 'user 'theme-settings) - if (eq type 'theme-value) - collect var))) - (modules - ,@(or (cl-loop with lastcat = nil - for (cat . mod) in (seq-filter #'cdr (doom-module-list)) - if (or (not lastcat) - (not (eq lastcat cat))) - do (setq lastcat cat) - and collect lastcat - collect - (let* ((flags (doom-module-get lastcat mod :flags)) - (path (doom-module-get lastcat mod :path)) - (module - (append - (cond ((null path) - (list '&nopath)) - ((not (file-in-directory-p path doom-modules-dir)) - (list '&user))) - (if flags - `(,mod ,@flags) - (list mod))))) - (if (= (length module) 1) - (car module) - module))) - '("n/a"))) - (packages - ,@(condition-case e - (mapcar - #'cdr (doom--collect-forms-in - (doom-path doom-user-dir doom-module-packages-file) - "package!")) - (error (format "<%S>" e)))) - (unpin - ,@(condition-case e - (mapcan #'identity - (mapcar - #'cdr (doom--collect-forms-in - (doom-path doom-user-dir doom-module-packages-file) - "unpin!"))) - (error (list (format "<%S>" e))))) - (elpa - ,@(condition-case e - (progn - (unless (bound-and-true-p package--initialized) - (package-initialize)) - (cl-loop for (name . _) in package-alist - collect (format "%s" name))) - (error (format "<%S>" e)))))))) - -;;;###autoload -(defun doom-info-string (&optional width nocolor) - "Return the `doom-info' as a compact string. - -FILL-COLUMN determines the column at which lines will be broken." - (with-temp-buffer - (let ((doom-print-backend (unless nocolor doom-print-backend)) - (doom-print-indent 0)) - (dolist (spec (cl-remove-if-not #'cdr (doom-info)) (buffer-string)) - ;; FIXME Refactor this horrible cludge, either here or in `format!' - (insert! ((bold "%-10s ") (symbol-name (car spec))) - ("%s\n" - (string-trim-left - (indent - (fill - (if (listp (cdr spec)) - (mapconcat (doom-partial #'format "%s") - (cdr spec) - " ") - (cdr spec)) - (- (or width 80) 11)) - 11)))))))) - - -;; -;;; Commands - -;;;###autoload -(defun doom/version () - "Display the running version of Doom core, module sources, and Emacs." - (interactive) - (print! "%s\n%s\n%s" - (format "%-13s v%-15s %s" - "GNU Emacs" - emacs-version - emacs-repository-version) - (format "%-13s v%-15s %s" - "Doom core" - doom-version - (or (cdr (doom-call-process - "git" "-C" (expand-file-name doom-emacs-dir) - "log" "-1" "--format=%D %h %ci")) - "n/a")) - ;; NOTE This is a placeholder. Our modules will be moved to its own - ;; repo eventually, and Doom core will later be capable of managing - ;; them like package sources. - (format "%-13s v%-15s %s" - "Doom modules" - doom-modules-version - (or (cdr (doom-call-process - "git" "-C" (expand-file-name doom-modules-dir) - "log" "-1" "--format=%D %h %ci")) - "n/a")))) - -;;;###autoload -(defun doom/info () - "Collects some debug information about your Emacs session, formats it and -copies it to your clipboard, ready to be pasted into bug reports!" - (interactive) - (let ((buffer (get-buffer-create "*doom info*"))) - (with-current-buffer buffer - (setq buffer-read-only t) - (with-silent-modifications - (erase-buffer) - (insert (doom-info-string 86))) - (pop-to-buffer buffer) - (kill-new (buffer-string)) - (when (y-or-n-p "Your doom-info was copied to the clipboard.\n\nOpen pastebin.com?") - (browse-url "https://pastebin.com"))))) - - -;; -;;; Profiling - -(defvar doom--profiler nil) -;;;###autoload -(defun doom/toggle-profiler () - "Toggle the Emacs profiler. Run it again to see the profiling report." - (interactive) - (if (not doom--profiler) - (profiler-start 'cpu+mem) - (profiler-report) - (profiler-stop)) - (setq doom--profiler (not doom--profiler))) - -(provide 'doom-lib '(debug)) -;;; debug.el ends here diff --git a/.config/emacs/lisp/lib/docs.el b/.config/emacs/lisp/lib/docs.el @@ -1,543 +0,0 @@ -;;; core/lib/docs.el -- a reader mode for Doom's Org docs -*- lexical-binding: t; -*- -;;; Commentary: -;; -;; This file defines `doom-docs-org-mode', a major mode derived from org-mode, -;; intended to make Doom's documentation more readable, insert virtual -;; navigation in the header, prettify org buffers (hiding syntax and special -;; tags), and defines special link types. -;; -;; This mode isn't only for Doom's docs, but also for docs found in other Doom -;; projects, like doomemacs/themes, doomemacs/snippets, and more. Most of its -;; variables can be customized in its root .dir-locals.el. -;; -;;; Code: - -;;;###autoload -(defvar doom-docs-dir (file-name-concat doom-emacs-dir "docs/") - "Where Doom's documentation files are stored. Must end with a slash.") - -(defvar doom-docs-header-specs - '(("/docs/index\\.org$" - (:label "FAQ" - :icon "question_answer" - :link "doom-faq:" - :help-echo "Open the FAQ document")) - (("/docs/[^/]+\\.org$" "/modules/README\\.org$") - (:label "Back to index" - :icon "arrow_back" - :link ("doom-index" . "") - :help-echo "Navigate to the root index")) - ("/modules/[^/]+/README\\.org$" - (:label "Back to module index" - :icon "arrow_back" - :link "doom-module-index:")) - ("/modules/[^/]+/[^/]+/README\\.org$" - (:label "Back to module index" - :icon "arrow_back" - :link "doom-module-index:") - (:label "History" - :icon "history" - :icon-face font-lock-variable-name-face - :link (lambda () - (cl-destructuring-bind (category . module) (doom-module-from-path (buffer-file-name)) - (format "doom-module-history:%s/%s" (doom-keyword-name category) module))) - :help-echo "View the module history" - :align right) - (:label "Issues" - :icon "error_outline" - :icon-face error - :link (lambda () - (cl-destructuring-bind (category . module) (doom-module-from-path (buffer-file-name)) - (format "doom-module-issues::%s %s" category module))) - :align right)) - (t - (:label "Suggest edits" - :icon "edit" - :icon-face warning - :link "doom-suggest-edit" - :align right) - (:label "Help" - :icon "help_outline" - :icon-face font-lock-function-name-face - :link (lambda () - (let ((title (cadar (org-collect-keywords '("TITLE"))))) - (cond ((equal title "Changelog") "doom-help-changelog:") - ((string-prefix-p ":" title) "doom-help-modules:") - (t "doom-help:")))) - :align right)))) - -(defun doom-docs--make-header () - "Create a header string for the current buffer." - (let* ((applicable-specs - (cl-loop for (condition . specs) in doom-docs-header-specs - when (if (symbolp condition) - (symbol-value condition) - (seq-some (doom-rpartial #'string-match-p (buffer-file-name)) - (ensure-list condition))) - append specs)) - (left-specs - (cl-remove-if-not - (lambda (s) (memq (plist-get s :align) '(nil left))) - applicable-specs)) - (right-specs - (cl-remove-if-not - (lambda (s) (eq (plist-get s :align) 'right)) - applicable-specs)) - (left-string - (mapconcat #'doom-docs--make-header-link left-specs " ")) - (right-string - (mapconcat #'doom-docs--make-header-link right-specs " "))) - (if (string-empty-p right-string) - (concat " " left-string) - (concat " " left-string - (make-string (max (- (window-width) - (length left-string) - (length right-string) - 4) - 1) - ?\s) - right-string)))) - -(defun doom-docs--make-header-link (spec) - "Create a header link according to SPEC." - (let ((icon (and (plist-get spec :icon) - (funcall (or (plist-get spec :icon-function) - #'all-the-icons-material) - (plist-get spec :icon)))) - (label (pcase (plist-get spec :label) - ((and (pred functionp) lab) - (funcall lab)) - ((and (pred stringp) lab) - lab))) - (link (pcase (plist-get spec :link) - ((and (pred functionp) link) - (funcall link)) - ((and (pred stringp) link) - link)))) - (propertize - (concat - (and icon - (propertize icon 'face - (cadr (or (plist-member spec :icon-face) - (plist-member spec :face))))) - (and icon label " ") - (and label - (propertize label 'face (cadr (or (plist-get spec :face) - '(nil link)))))) - 'doom-docs-link link - 'keymap doom-docs--header-link-keymap - 'help-echo (or (plist-get spec :help-echo) - (format "LINK: %s" link)) - 'mouse-face 'highlight))) - -(setq doom-docs--header-link-keymap - (let ((km (make-sparse-keymap))) - (define-key km [header-line mouse-2] 'doom-docs--open-header-link) - (define-key km [mouse-2] 'doom-docs--open-header-link) - (define-key km [follow-link] 'mouse-face) - km)) - -(defun doom-docs--open-header-link (ev) - "Open the header link which is the target of the event EV." - (interactive "e") - (let* ((string-and-pos (posn-string (event-start ev))) - (docs-buf (window-buffer (posn-window (event-start ev)))) - (link (get-pos-property (cdr string-and-pos) - 'doom-docs-link - (car string-and-pos))) - (parent-link-abbrevs - (buffer-local-value 'org-link-abbrev-alist-local docs-buf))) - (with-temp-buffer - (setq buffer-file-name (buffer-file-name docs-buf)) - (let ((org-inhibit-startup t)) - (org-mode)) - (setq-local org-link-abbrev-alist-local parent-link-abbrevs) - (insert "[[" link "]]") - (set-buffer-modified-p nil) - (org-link-open (org-element-context))))) - -;; DEPRECATED Will be renamed once docs "framework" is generalized -(defvar doom-docs-link-alist - '(("doom-tag" . "https://github.com/hlissner/doom-emacs/releases/tag/%s") - ("doom-contrib-core" . "id:9ac0c15c-29e7-43f8-8926-5f0edb1098f0") - ("doom-contrib-docs" . "id:31f5a61d-d505-4ee8-9adb-97678250f4e2") - ("doom-contrib-maintainer" . "id:e71e9595-a297-4c49-bd11-f238329372db") - ("doom-contrib-module" . "id:b461a050-8702-4e63-9995-c2ef3a78f35d") - ("doom-faq" . "id:5fa8967a-532f-4e0c-8ae8-25cd802bf9a9") - ("doom-help" . "id:9bb17259-0b07-45a8-ae7a-fc5e0b16244e") - ("doom-help-changelog" . "id:7c56cc08-b54b-4f4b-b106-a76e2650addd") - ("doom-help-modules" . "id:1ee0b650-f09b-4454-8690-cc145aadef6e") - ("doom-index" . "id:3051d3b6-83e2-4afa-b8fe-1956c62ec096") - ("doom-module-index" . "id:12d2de30-c569-4b8e-bbc7-85dd5ccc4afa") - ("doom-module-issues" . "https://github.com/doomemacs/doomemacs/labels/%s") - ("doom-module-history" . "https://github.com/doomemacs/doomemacs/commits/master/modules/%s") - ("doom-report" . "https://github.com/doomemacs/doomemacs/issues/new/choose") - ("doom-suggest-edit" . "id:31f5a61d-d505-4ee8-9adb-97678250f4e2") - ("doom-suggest-faq" . "id:aa28b732-0512-49ed-a47b-f20586c0f051") - ("github" . "https://github.com/%s") - - ;; TODO Implement later, once docs are generalized - ;; ("github-release" . (lambda (link) - ;; (format "%s/releases/tag/%s" - ;; doom-docs-this-repo - ;; link))) - ;; ("github-label" . (lambda (link) - ;; (format "%s/labels/%s" - ;; doom-docs-this-repo - ;; link))) - ;; ("github-commits" . (lambda (link) - ;; (format "%s/commits/%s/modules/%s" - ;; doom-docs-this-repo - ;; "master" - ;; link))"github-repo:/commits/%b/modules/%%s") - ;; ("github-report" . "github-repo:/issues/new/choose") - )) - - -;; -;;; `doom-docs-mode' - -(defun doom-docs--display-menu-h () - "Toggle virtual menu line at top of buffer." - (setq header-line-format - (and buffer-read-only - (doom-docs--make-header))) - (add-hook 'window-state-change-hook #'doom-docs--display-menu-h nil t)) - -(defun doom-docs--hide-meta-h () - "Hide all meta or comment lines." - (org-with-wide-buffer - (goto-char (point-min)) - (save-match-data - (let ((case-fold-search t)) - (while (re-search-forward "^[ \t]*\\#" nil t) - (unless (org-in-src-block-p t) - (catch 'abort - (org-fold-core-region - (line-beginning-position) - (cond ((looking-at "+\\(?:title\\|subtitle\\): +") - (match-end 0)) - ((looking-at "+\\(?:created\\|since\\|author\\|email\\|date\\): +") - (throw 'abort nil)) - ((or (eq (char-after) ?\s) - (looking-at "+\\(begin\\|end\\)_comment")) - (line-beginning-position 2)) - ((looking-at "+\\(?:begin\\|end\\)_\\([^ \n]+\\)") - (line-end-position)) - ((line-beginning-position 2))) - doom-docs-mode 'doom-doc-hidden)))))))) - -(defun doom-docs--hide-drawers-h () - "Hide all property drawers." - (let (pt) - (org-with-wide-buffer - (goto-char (point-min)) - (when (looking-at-p org-drawer-regexp) - (setq pt (org-element-property :end (org-element-at-point)))) - (while (re-search-forward org-drawer-regexp nil t) - (when-let ((el (org-element-at-point)) - (beg (max (point-min) (1- (org-element-property :begin el)))) - (end (org-element-property :end el)) - ((memq (org-element-type el) '(drawer property-drawer)))) - (when (org-current-level) - (cl-decf end)) - (org-fold-core-region beg end doom-docs-mode 'doom-doc-hidden) - (when doom-docs-mode - (org-fold-core-region beg end nil 'org-hide-drawer))))) - ;; FIX: If the cursor remains within a newly folded region, that folk will - ;; come undone, so we move it. - (if pt (goto-char pt)))) - -(defun doom-docs--hide-tags-h () - "Hide tags in org headings." - (org-with-wide-buffer - (goto-char (point-min)) - (while (re-search-forward org-heading-regexp nil t) - (when-let (tags (org-get-tags nil t)) - (when (or (member "noorg" tags) - (member "unfold" tags)) - ;; prevent `org-ellipsis' around hidden regions - (org-show-entry)) - (if (member "noorg" tags) - (org-fold-core-region (line-end-position 0) - (save-excursion - (org-end-of-subtree t) - (forward-line 1) - (if (and (bolp) (eolp)) - (line-beginning-position) - (line-end-position 0))) - doom-docs-mode 'doom-doc-hidden) - (org-fold-core-region (save-excursion - (goto-char (line-beginning-position)) - (re-search-forward " +:[^ ]" (line-end-position)) - (match-beginning 0)) - (line-end-position) - doom-docs-mode 'doom-doc-hidden)))))) - -(defun doom-docs--hide-stars-h () - "Update invisible property to VISIBILITY for markers in the current buffer." - (org-with-wide-buffer - (goto-char (point-min)) - (with-silent-modifications - (while (re-search-forward "^\\(\\*[ \t]\\|\\*\\*+\\)" nil t) - (org-fold-core-region (match-beginning 0) - (match-end 0) - doom-docs-mode - 'doom-doc-hidden))))) - -(defvar doom-docs--babel-cache nil) -(defun doom-docs--hide-src-blocks-h () - "Hide babel blocks (and/or their results) depending on their :exports arg." - (org-with-wide-buffer - (let ((inhibit-read-only t)) - (goto-char (point-min)) - (make-local-variable 'doom-docs--babel-cache) - (while (re-search-forward org-babel-src-block-regexp nil t) - (let* ((beg (match-beginning 0)) - (end (save-excursion (goto-char (match-end 0)) - (skip-chars-forward "\n") - (point))) - (exports - (save-excursion - (goto-char beg) - (and (re-search-forward " :exports \\([^ \n]+\\)" (line-end-position) t) - (match-string-no-properties 1)))) - (results (org-babel-where-is-src-block-result))) - (save-excursion - (when (and (if (stringp exports) - (member exports '("results" "both")) - org-export-use-babel) - (not results) - doom-docs-mode) - (cl-pushnew beg doom-docs--babel-cache) - (quiet! (org-babel-execute-src-block)) - (setq results (org-babel-where-is-src-block-result)) - (org-element-cache-refresh beg) - (restore-buffer-modified-p nil))) - (save-excursion - (when results - (when (member exports '("code" "both" "t")) - (setq beg results)) - (when (member exports '("none" "code")) - (setq end (progn (goto-char results) - (goto-char (org-babel-result-end)) - (skip-chars-forward "\n") - (point)))))) - (unless (member exports '(nil "both" "code" "t")) - (org-fold-core-region beg end doom-docs-mode 'doom-doc-hidden)))) - (unless doom-docs-mode - (save-excursion - (dolist (pos doom-docs--babel-cache) - (goto-char pos) - (org-babel-remove-result) - (org-element-cache-refresh pos)) - (kill-local-variable 'doom-docs--babel-cache) - (restore-buffer-modified-p nil)))))) - -(defvar doom-docs--macro-cache nil) -(defun doom-docs--expand-macros-h () - "Expand {{{macros}}} with their value." - (org-with-wide-buffer - (goto-char (point-min)) - (make-local-variable 'doom-docs--macro-cache) - (while (re-search-forward "{{{[^}]+}}}" nil t) - (with-silent-modifications - (if doom-docs-mode - (when-let* ((element (org-element-context)) - (key (org-element-property :key element)) - (cachekey (org-element-property :value element)) - (template (cdr (assoc-string key org-macro-templates t)))) - (let ((value (or (cdr (assoc-string cachekey doom-docs--macro-cache)) - (setf (alist-get cachekey doom-docs--macro-cache nil nil 'equal) - (org-macro-expand element org-macro-templates))))) - (add-text-properties (match-beginning 0) - (match-end 0) - `(display ,value)))) - (remove-text-properties (match-beginning 0) - (match-end 0) - '(display)))) - (org-element-cache-refresh (point))))) - -(defvar doom-docs-mode-alist - '((flyspell-mode . -1) - (spell-fu-mode . -1) - (visual-line-mode . -1) - (mixed-pitch-mode . -1) - (variable-pitch-mode . -1)) - "An alist of minor modes to activate or deactivate in `doom-docs-mode'. - -The CAR is the minor mode symbol, and CDR should be either +1 or -1, -depending.") - -(defvar doom-docs--initial-values nil) -(defvar doom-docs--cookies nil) -;;;###autoload -(define-minor-mode doom-docs-mode - "Hides metadata, tags, & drawers and activates all org-mode pretiffications. -This primes `org-mode' for reading." - :lighter " Doom Docs" - :after-hook (org-restart-font-lock) - (unless (derived-mode-p 'org-mode) - (user-error "Not an org mode buffer")) - (org-fold-add-folding-spec - 'doom-doc-hidden '(:visible nil - :ellipsis nil - :isearch-ignore t)) - (mapc (lambda (sym) - (if doom-docs-mode - (set (make-local-variable sym) t) - (kill-local-variable sym))) - `(org-pretty-entities - org-hide-emphasis-markers - org-hide-macro-markers)) - (when doom-docs-mode - (make-local-variable 'doom-docs--initial-values)) - (mapc (lambda! ((face . plist)) - (if doom-docs-mode - (push (apply #'face-remap-add-relative face plist) doom-docs--cookies) - (mapc #'face-remap-remove-relative doom-docs--cookies))) - '((org-document-title :weight bold :height 1.4) - (org-document-info :weight normal :height 1.15))) - (mapc (lambda! ((mode . state)) - (if doom-docs-mode - (if (and (boundp mode) (symbol-value mode)) - (unless (> state 0) - (setf (alist-get mode doom-docs--initial-values) t) - (funcall mode -1)) - (unless (< state 0) - (setf (alist-get mode doom-docs--initial-values) nil) - (funcall mode +1))) - (when-let (old-val (assq mode doom-docs--initial-values)) - (funcall mode (if old-val +1 -1))))) - doom-docs-mode-alist) - (unless doom-docs-mode - (kill-local-variable 'doom-docs--initial-values))) - -(add-hook! 'doom-docs-mode-hook - #'doom-docs--display-menu-h - #'doom-docs--hide-meta-h - #'doom-docs--hide-tags-h - #'doom-docs--hide-drawers-h - ;; #'doom-docs--hide-stars-h - #'doom-docs--expand-macros-h - #'doom-docs--hide-src-blocks-h) - -(defun doom-docs--toggle-read-only-h () - (doom-docs-mode (if buffer-read-only +1 -1))) - - -(defvar doom-docs--id-locations nil) -(defvar doom-docs--id-files nil) -;;;###autoload -(defun doom/reload-docs (&optional force) - "Reload the ID locations in Doom's documentation and open docs buffers." - (interactive (list 'interactive)) - (with-temp-buffer - (let ((org-id-locations-file - (doom-path (file-truename doom-cache-dir) "doom-docs-org-ids")) - (org-id-track-globally t) - org-agenda-files - org-id-extra-files - org-id-files - org-id-locations - org-id-extra-files - (org-inhibit-startup t) - org-mode-hook) - (if force - (org-id-update-id-locations - (doom-files-in (list doom-docs-dir doom-modules-dir) - :match "/[^.].+\\.org$")) - (org-id-locations-load)) - (setq doom-docs--id-files org-id-files - doom-docs--id-locations org-id-locations))) - (dolist (buf (doom-buffers-in-mode 'doom-docs-org-mode)) - (with-current-buffer buf - (setq-local org-id-files doom-docs--id-files - org-id-locations doom-docs--id-locations)))) - - -;; -;;; `doom-docs-org-mode' - -;;;###autoload -(defun doom-docs-generate-id (&optional force?) - "Generate an ID for a `doom-docs-org-mode' buffer." - (let ((org-id-link-to-org-use-id t) - (org-id-method 'uuid) - (org-id-track-globally t) - (org-id-locations-file (doom-path doom-cache-dir "doom-docs-org-ids")) - (org-id-locations doom-docs--id-locations) - (org-id-files doom-docs--id-files)) - (doom/reload-docs) - (let ((id (org-id-new))) - (org-id-add-location - id (buffer-file-name (buffer-base-buffer))) - id))) - -;;;###autoload -(define-derived-mode doom-docs-org-mode org-mode "Doom Docs" - "A derivative of `org-mode' for Doom's documentation files. - -Keeps track of its own IDs in `doom-docs-dir' and toggles `doom-docs-mode' when -`read-only-mode' is activated." - :after-hook (visual-line-mode -1) - (let ((gc-cons-threshold most-positive-fixnum) - (gc-cons-percentage 1.0)) - (require 'org-id) - (require 'ob) - (setq-local org-id-link-to-org-use-id t - org-id-method 'uuid - org-id-track-globally t - org-id-locations-file (doom-path doom-cache-dir "doom-docs-org-ids") - org-id-locations doom-docs--id-locations - org-id-files doom-docs--id-files - org-num-max-level 3 - org-footnote-define-inline nil - org-footnote-auto-label t - org-footnote-auto-adjust t - org-footnote-section nil - wgrep-change-readonly-file t - org-link-abbrev-alist-local (append org-link-abbrev-alist-local doom-docs-link-alist) - org-babel-default-header-args - (append '((:eval . "no") (:tangle . "no")) - org-babel-default-header-args) - save-place-ignore-files-regexp ".") - (unless org-inhibit-startup - (doom/reload-docs) - (unless (local-variable-p 'org-startup-with-inline-images) - (setq org-display-remote-inline-images 'cache) - (org-display-inline-images)) - (unless (local-variable-p 'org-startup-indented) - (org-indent-mode +1)) - (unless (local-variable-p 'org-startup-numerated) - (when (bound-and-true-p org-num-mode) - (org-num-mode -1)) - (org-num-mode +1)) - (unless (local-variable-p 'org-startup-folded) - (let ((org-startup-folded 'content) - org-cycle-hide-drawer-startup) - (org-set-startup-visibility)))) - (add-hook 'read-only-mode-hook #'doom-docs--toggle-read-only-h nil 'local))) - -(defun doom-docs-init-glossary-h () - "Activates `org-glossary-mode', if it's available." - (when (require 'org-glossary nil t) - (setq-local org-glossary-global-terms (doom-glob doom-docs-dir "appendix.org")) - (org-glossary-mode +1))) -(add-hook 'doom-docs-org-mode-hook #'doom-docs-init-glossary-h) - -;;;###autoload -(defun doom-docs-read-only-h () - "Activate `read-only-mode' if the current file exists and is non-empty." - ;; The rationale: if it's empty or non-existant, you want to write an org - ;; file, not read it. - (let ((file-name (buffer-file-name (buffer-base-buffer)))) - (when (and file-name - (> (buffer-size) 0) - (not (string-prefix-p "." (file-name-base file-name))) - (file-exists-p file-name)) - (read-only-mode +1)))) - -(add-hook 'doom-docs-org-mode-hook #'doom-docs-read-only-h) - -;;; docs.el ends here diff --git a/.config/emacs/lisp/lib/files.el b/.config/emacs/lisp/lib/files.el @@ -1,521 +0,0 @@ -;;; lisp/lib/files.el -*- lexical-binding: t; -*- -;;; Commentary: -;;; Code: - -(defun doom-files--build-checks (spec &optional directory) - "Converts a simple nested series of or/and forms into a series of -`file-exists-p' checks. - -For example - - (doom-files--build-checks - '(or A (and B C)) - \"~\") - -Returns (not precisely, but effectively): - - '(let* ((_directory \"~\") - (A (expand-file-name A _directory)) - (B (expand-file-name B _directory)) - (C (expand-file-name C _directory))) - (or (and (file-exists-p A) A) - (and (if (file-exists-p B) B) - (if (file-exists-p C) C)))) - -This is used by `file-exists-p!' and `project-file-exists-p!'." - (declare (pure t) (side-effect-free t)) - (if (and (listp spec) - (memq (car spec) '(or and))) - (cons (car spec) - (cl-loop for it in (cdr spec) - collect (doom-files--build-checks it directory))) - (let ((filevar (make-symbol "file"))) - `(let ((,filevar ,spec)) - (and (stringp ,filevar) - ,(if directory - `(let ((default-directory ,directory)) - (file-exists-p ,filevar)) - `(file-exists-p ,filevar)) - ,filevar))))) - -;;;###autoload -(defun doom-path (&rest segments) - "Return an path expanded after concatenating SEGMENTS with path separators. - -Ignores `nil' elements in SEGMENTS, and is intended as a fast compromise between -`expand-file-name' (slow, but accurate), `file-name-concat' (fast, but -inaccurate)." - ;; PERF: An empty `file-name-handler-alist' = faster `expand-file-name'. - (let (file-name-handler-alist) - (expand-file-name - ;; PERF: avoid the overhead of `apply' in the trivial case. This function - ;; is used a lot, so every bit counts. - (if (cdr segments) - (apply #'file-name-concat segments) - (car segments))))) - -;;;###autoload -(defun doom-glob (&rest segments) - "Return file list matching the glob created by joining SEGMENTS. - -The returned file paths will be relative to `default-directory', unless SEGMENTS -concatenate into an absolute path. - -Returns nil if no matches exist. -Ignores `nil' elements in SEGMENTS. -If the glob ends in a slash, only returns matching directories." - (declare (side-effect-free t)) - (let* (case-fold-search - file-name-handler-alist - (path (apply #'file-name-concat segments))) - (if (string-suffix-p "/" path) - (cl-delete-if-not #'file-directory-p (file-expand-wildcards (substring path 0 -1))) - (file-expand-wildcards path)))) - -;;;###autoload -(define-obsolete-function-alias 'doom-dir 'doom-path "3.0.0") - -;;;###autoload -(cl-defun doom-files-in - (paths &rest rest - &key - filter - map - (full t) - (follow-symlinks t) - (type 'files) - (relative-to (unless full default-directory)) - (depth 99999) - (mindepth 0) - (match "/[^._][^/]+")) - "Return a list of files/directories in PATHS (one string or a list of them). - -FILTER is a function or symbol that takes one argument (the path). If it returns -non-nil, the entry will be excluded. - -MAP is a function or symbol which will be used to transform each entry in the -results. - -TYPE determines what kind of path will be included in the results. This can be t -(files and folders), 'files or 'dirs. - -By default, this function returns paths relative to PATH-OR-PATHS if it is a -single path. If it a list of paths, this function returns absolute paths. -Otherwise, by setting RELATIVE-TO to a path, the results will be transformed to -be relative to it. - -The search recurses up to DEPTH and no further. DEPTH is an integer. - -MATCH is a string regexp. Only entries that match it will be included." - (let (result) - (dolist (file (mapcan (doom-rpartial #'doom-glob "*") (ensure-list paths))) - (cond ((file-directory-p file) - (appendq! - result - (and (memq type '(t dirs)) - (string-match-p match file) - (not (and filter (funcall filter file))) - (not (and (file-symlink-p file) - (not follow-symlinks))) - (<= mindepth 0) - (list (if relative-to - (file-relative-name file relative-to) - file))) - (and (>= depth 1) - (apply #'doom-files-in file - (append (list :mindepth (1- mindepth) - :depth (1- depth) - :relative-to relative-to - :map nil) - rest))))) - ((and (memq type '(t files)) - (string-match-p match file) - (not (and filter (funcall filter file))) - (<= mindepth 0)) - (push (if relative-to - (file-relative-name file relative-to) - file) - result)))) - (if map - (mapcar map result) - result))) - -;;;###autoload -(defun doom-file-cookie-p (file &optional cookie null-value) - "Returns the evaluated result of FORM in a ;;;###COOKIE FORM at the top of -FILE. - -If COOKIE doesn't exist, or cookie isn't within the first 256 bytes of FILE, -return NULL-VALUE." - (unless (file-exists-p file) - (signal 'file-missing file)) - (unless (file-readable-p file) - (error "%S is unreadable" file)) - (with-temp-buffer - (insert-file-contents file nil 0 256) - (if (re-search-forward (format "^;;;###%s " (regexp-quote (or cookie "if"))) - nil t) - (doom-module-context-with (doom-module-from-path file) - (let ((load-file-name file)) - (eval (sexp-at-point) t))) - null-value))) - -;;;###autoload -(defmacro file-exists-p! (files &optional directory) - "Returns non-nil if the FILES in DIRECTORY all exist. - -DIRECTORY is a path; defaults to `default-directory'. - -Returns the last file found to meet the rules set by FILES, which can be a -single file or nested compound statement of `and' and `or' statements." - `(let ((p ,(doom-files--build-checks files directory))) - (and p (expand-file-name p ,directory)))) - -;;;###autoload -(defun doom-file-size (file &optional dir) - "Returns the size of FILE (in DIR) in bytes." - (let ((file (expand-file-name file dir))) - (unless (file-exists-p file) - (error "Couldn't find file %S" file)) - (unless (file-readable-p file) - (error "File %S is unreadable; can't acquire its filesize" - file)) - (nth 7 (file-attributes file)))) - -(defvar w32-get-true-file-attributes) -;;;###autoload -(defun doom-directory-size (dir) - "Returns the size of FILE (in DIR) in kilobytes." - (unless (file-directory-p dir) - (error "Directory %S does not exist" dir)) - (if (executable-find "du") - (/ (string-to-number (cdr (doom-call-process "du" "-sb" dir))) - 1024.0) - ;; REVIEW This is slow and terribly inaccurate, but it's something - (let ((w32-get-true-file-attributes t) - (file-name-handler-alist dir) - (max-lisp-eval-depth 5000) - (sum 0.0)) - (dolist (attrs (directory-files-and-attributes dir nil nil t) sum) - (unless (member (car attrs) '("." "..")) - (cl-incf - sum (if (eq (nth 1 attrs) t) ; is directory - (doom-directory-size (expand-file-name (car attrs) dir)) - (/ (nth 8 attrs) 1024.0)))))))) - - -;; -;;; File read/write - -(defmacro doom--with-prepared-file-buffer (file coding mode &rest body) - "Create a temp buffer and prepare it for file IO in BODY." - (declare (indent 3)) - (let ((nmask (make-symbol "new-mask")) - (omask (make-symbol "old-mask"))) - `(let* ((,nmask ,mode) - (,omask (if ,nmask (default-file-modes)))) - (unwind-protect - (with-temp-buffer - (if ,nmask (set-default-file-modes ,nmask)) - (let* ((buffer-file-name (doom-path ,file)) - (coding-system-for-read (or ,coding 'binary)) - (coding-system-for-write (or coding-system-for-write coding-system-for-read 'binary))) - (unless (eq coding-system-for-read 'binary) - (set-buffer-multibyte nil) - (setq-local buffer-file-coding-system 'binary)) - ,@body)) - (if ,nmask (set-default-file-modes ,omask)))))) - -;;;###autoload -(cl-defun doom-file-read - (file &key - (by 'buffer-string) - (coding (or coding-system-for-read 'utf-8)) - noerror - beg end) - "Read FILE and return its contents. - -Set BY to change how its contents are consumed. It accepts any function, to be -called with no arguments and expected to return the contents as any arbitrary -data. By default, BY is set to `buffer-string'. Otherwise, BY recognizes these -special values: - -'insert -- insert FILE's contents into the current buffer before point. -'read -- read the first form in FILE and return it as a single S-exp. -'read* -- read all forms in FILE and return it as a list of S-exps. -'(read . N) -- read the first N (an integer) S-exps in FILE. - -CODING dictates the encoding of the buffer. This defaults to `utf-8'. - -If NOERROR is non-nil, don't throw an error if FILE doesn't exist. This will -still throw an error if FILE is unreadable, however. - -If BEG and/or END are integers, only that region will be read from FILE." - (when (or (not noerror) - (file-exists-p file)) - (let ((old-buffer (current-buffer))) - (doom--with-prepared-file-buffer file coding nil - (if (not (eq coding-system-for-read 'binary)) - (insert-file-contents buffer-file-name nil beg end) - (insert-file-contents-literally buffer-file-name nil beg end)) - (pcase by - ('insert - (if (fboundp 'insert-into-buffer) - (insert-into-buffer old-buffer) - ;; DEPRECATED: Remove fallback when 27.x support is dropped. - (let ((input (buffer-substring-no-properties (point-min) (point-max)))) - (with-current-buffer old-buffer - (insert input)))) - t) - ('buffer-string - (buffer-substring-no-properties (point-min) (point-max))) - ('read - (condition-case _ (read (current-buffer)) (end-of-file))) - ('(read . ,i) - (let (forms) - (condition-case _ - (dotimes (_ i) (push (read (current-buffer)) forms)) - (end-of-file)) - (nreverse forms))) - ('read* - (let (forms) - (condition-case _ - (while t (push (read (current-buffer)) forms)) - (end-of-file)) - (nreverse forms))) - (fn (funcall fn))))))) - -;;;###autoload -(cl-defun doom-file-write - (file contents - &key - append - (coding 'utf-8) ; default: `utf-8' - mode ; default: `default-file-modes' (#o755) - (mkdir 'parents) - (insertfn #'insert) - (printfn #'prin1)) - "Write CONTENTS (a string or list of forms) to FILE (a string path). - -If CONTENTS is list of forms. Any literal strings in the list are inserted -verbatim, as text followed by a newline, with `insert'. Sexps are inserted with -`prin1'. BY is the function to use to emit - -MODE dictates the permissions of the file. If FILE already exists, its -permissions will be changed. - -CODING dictates the encoding to read/write with (see `coding-system-for-write'). -If set to nil, `binary' is used. - -APPEND dictates where CONTENTS will be written. If neither is set, -the file will be overwritten. If both are, the contents will be written to both -ends. Set either APPEND or PREPEND to `noerror' to silently ignore read errors." - (doom--with-prepared-file-buffer file coding mode - (let ((contents (ensure-list contents)) - datum) - (while (setq datum (pop contents)) - (cond ((stringp datum) - (funcall - insertfn (if (or (string-suffix-p "\n" datum) - (stringp (cadr contents))) - datum - (concat datum "\n")))) - ((bufferp datum) - (insert-buffer-substring datum)) - ((let ((standard-output (current-buffer)) - (print-quoted t) - (print-level nil) - (print-length nil)) - (funcall printfn datum)))))) - (let (write-region-annotate-functions - write-region-post-annotation-function) - (when mkdir - (make-directory (file-name-directory buffer-file-name) - (eq mkdir 'parents))) - (write-region nil nil buffer-file-name append :silent)) - buffer-file-name)) - -;;;###autoload -(defmacro with-file-contents! (file &rest body) - "Create a temporary buffer with FILE's contents and execute BODY in it. - -The point is at the beginning of the buffer afterwards. - -A convenience macro to express the common `with-temp-buffer' + -`insert-file-contents' idiom more succinctly, enforce `utf-8', and perform some -optimizations for `binary' IO." - (declare (indent 1)) - `(doom--with-prepared-file-buffer ,file (or coding-system-for-read 'utf-8) nil - (doom-file-read buffer-file-name :by 'insert :coding coding-system-for-read) - (goto-char (point-min)) - ,@body)) - -;;;###autoload -(defmacro with-file! (file &rest body) - "Evaluate BODY in a temp buffer, then write its contents to FILE. - -Unlike `with-temp-file', this uses the `utf-8' encoding by default and performs -some optimizations for `binary' IO." - (declare (indent 1)) - `(doom--with-prepared-file-buffer ,file (or coding-system-for-read 'utf-8) nil - (prog1 (progn ,@body) - (doom-file-write buffer-file-name (current-buffer) - :coding (or coding-system-for-write 'utf-8))))) - - -;; -;;; Helpers - -(defun doom-files--update-refs (&rest files) - "Ensure FILES are updated in `recentf', `magit' and `save-place'." - (let (toplevels) - (dolist (file files) - (when (featurep 'vc) - (vc-file-clearprops file) - (when-let (buffer (get-file-buffer file)) - (with-current-buffer buffer - (vc-refresh-state)))) - (when (featurep 'magit) - (when-let (default-directory (magit-toplevel (file-name-directory file))) - (cl-pushnew default-directory toplevels))) - (unless (file-readable-p file) - (when (bound-and-true-p recentf-mode) - (recentf-remove-if-non-kept file)) - (when (and (bound-and-true-p projectile-mode) - (doom-project-p) - (projectile-file-cached-p file (doom-project-root))) - (projectile-purge-file-from-cache file)))) - (dolist (default-directory toplevels) - (magit-refresh)) - (when (bound-and-true-p save-place-mode) - (save-place-forget-unreadable-files)))) - - -;; -;;; Commands - -;;;###autoload -(defun doom/delete-this-file (&optional path force-p) - "Delete PATH, kill its buffers and expunge it from vc/magit cache. - -If PATH is not specified, default to the current buffer's file. - -If FORCE-P, delete without confirmation." - (interactive - (list (buffer-file-name (buffer-base-buffer)) - current-prefix-arg)) - (let* ((path (or path (buffer-file-name (buffer-base-buffer)))) - (short-path (and path (abbreviate-file-name path)))) - (unless path - (user-error "Buffer is not visiting any file")) - (unless (file-exists-p path) - (error "File doesn't exist: %s" path)) - (unless (or force-p (y-or-n-p (format "Really delete %S?" short-path))) - (user-error "Aborted")) - (let ((buf (current-buffer))) - (unwind-protect - (progn (delete-file path t) t) - (if (file-exists-p path) - (error "Failed to delete %S" short-path) - ;; Ensures that windows displaying this buffer will be switched to - ;; real buffers (`doom-real-buffer-p') - (doom/kill-this-buffer-in-all-windows buf t) - (doom-files--update-refs path) - (message "Deleted %S" short-path)))))) - -;;;###autoload -(defun doom/copy-this-file (new-path &optional force-p) - "Copy current buffer's file to NEW-PATH then open NEW-PATH. - -If FORCE-P, overwrite the destination file if it exists, without confirmation." - (interactive - (list (read-file-name "Copy file to: ") - current-prefix-arg)) - (unless (and buffer-file-name (file-exists-p buffer-file-name)) - (user-error "Buffer is not visiting any file")) - (let ((old-path (buffer-file-name (buffer-base-buffer))) - (new-path (expand-file-name new-path))) - (make-directory (file-name-directory new-path) 't) - (copy-file old-path new-path (or force-p 1)) - (find-file new-path) - (doom-files--update-refs old-path new-path) - (message "File copied to %S" (abbreviate-file-name new-path)))) - -;;;###autoload -(defun doom/move-this-file (new-path &optional force-p) - "Move current buffer's file to NEW-PATH. - -If FORCE-P, overwrite the destination file if it exists, without confirmation." - (interactive - (list (read-file-name "Move file to: ") - current-prefix-arg)) - (unless (and buffer-file-name (file-exists-p buffer-file-name)) - (user-error "Buffer is not visiting any file")) - (let ((old-path (buffer-file-name (buffer-base-buffer))) - (new-path (expand-file-name new-path))) - (when (directory-name-p new-path) - (setq new-path (concat new-path (file-name-nondirectory old-path)))) - (make-directory (file-name-directory new-path) 't) - (rename-file old-path new-path (or force-p 1)) - (set-visited-file-name new-path t t) - (doom-files--update-refs old-path new-path) - (message "File moved to %S" (abbreviate-file-name new-path)))) - -(defun doom--sudo-file-path (file) - (let ((host (or (file-remote-p file 'host) "localhost"))) - (concat "/" (when (file-remote-p file) - (concat (file-remote-p file 'method) ":" - (if-let (user (file-remote-p file 'user)) - (concat user "@" host) - host) - "|")) - "sudo:root@" host - ":" (or (file-remote-p file 'localname) - file)))) - -;;;###autoload -(defun doom/sudo-find-file (file) - "Open FILE as root." - (interactive "FOpen file as root: ") - (find-file (doom--sudo-file-path file))) - -;;;###autoload -(defun doom/sudo-this-file () - "Open the current file as root." - (interactive) - (find-file - (doom--sudo-file-path - (or buffer-file-name - (when (or (derived-mode-p 'dired-mode) - (derived-mode-p 'wdired-mode)) - default-directory))))) - -;;;###autoload -(defun doom/sudo-save-buffer () - "Save this file as root." - (interactive) - (let ((file (doom--sudo-file-path buffer-file-name))) - (if-let (buffer (find-file-noselect file)) - (let ((origin (current-buffer))) - (copy-to-buffer buffer (point-min) (point-max)) - (unwind-protect - (with-current-buffer buffer - (save-buffer)) - (unless (eq origin buffer) - (kill-buffer buffer)) - (with-current-buffer origin - (revert-buffer t t)))) - (user-error "Unable to open %S" file)))) - -;;;###autoload -(defun doom/remove-recent-file (file) - "Remove FILE from your recently-opened-files list." - (interactive - (list (completing-read "Remove recent file: " recentf-list - nil t))) - (setq recentf-list (delete file recentf-list)) - (recentf-save-list) - (message "Removed %S from `recentf-list'" (abbreviate-file-name file))) - -(provide 'doom-lib '(files)) -;;; files.el ends here diff --git a/.config/emacs/lisp/lib/fonts.el b/.config/emacs/lisp/lib/fonts.el @@ -1,180 +0,0 @@ -;;; lisp/lib/fonts.el -*- lexical-binding: t; -*- - -;;;###autoload -(defvar doom-font-increment 2 - "How many steps to increase the font size each time `doom/increase-font-size' -or `doom/decrease-font-size' are invoked.") - -;;;###autoload -(defvar doom-big-font nil - "The font to use for `doom-big-font-mode'. -If nil, `doom-font' will be used, scaled up by `doom-big-font-increment'. See -`doom-font' for details on acceptable values for this variable.") - -;;;###autoload -(defvar doom-big-font-increment 4 - "How many steps to increase the font size (with `doom-font' as the base) when -`doom-big-font-mode' is enabled and `doom-big-font' is nil.") - - -;; -;;; Library - -;;;###autoload -(defun doom-normalize-font (font) - "Return FONT as a normalized font spec. - -The font will be normalized (i.e. :weight, :slant, and :width will set to -'normal if not specified) before it is converted. - -FONT can be a `font-spec', a font object, an XFT font string, or an XLFD font -string." - (cl-check-type font (or font string vector)) - (when (and (stringp font) - (string-prefix-p "-" font)) - (setq font (x-decompose-font-name font))) - (let* ((font - (cond ((stringp font) - (dolist (prop '("weight" "slant" "width") (aref (font-info font) 0)) - (unless (string-match-p (format ":%s=" prop) font) - (setq font (concat font ":" prop "=normal"))))) - ((fontp font) - (dolist (prop '(:weight :slant :width) (font-xlfd-name font)) - (unless (font-get font prop) - (font-put font prop 'normal)))) - ((vectorp font) - (dolist (i '(1 2 3) (x-compose-font-name font)) - (unless (aref font i) - (aset font i "normal")))))) - (font (x-resolve-font-name font)) - (font (font-spec :name font))) - (unless (font-get font :size) - (font-put font :size - (font-get (font-spec :name (face-font 'default)) - :size))) - font)) - -;;;###autoload -(defun doom-adjust-font-size (increment &optional fixed-size-p font-alist) - "Increase size of font in FRAME by INCREMENT. - -If FIXED-SIZE-P is non-nil, treat INCREMENT as a font size, rather than a -scaling factor. - -FONT-ALIST is an alist give temporary values to certain Doom font variables, -like `doom-font' or `doom-variable-pitch-font'. e.g. - - `((doom-font . ,(font-spec :family \"Sans Serif\" :size 12))) - -Doesn't work in terminal Emacs." - (unless (display-multi-font-p) - (user-error "Cannot resize fonts in terminal Emacs")) - (condition-case-unless-debug e - (let (changed) - (dolist (sym '((doom-font . default) - (doom-serif-font . fixed-pitch-serif) - (doom-variable-pitch-font . variable-pitch)) - (when changed - (doom-init-fonts-h 'reload) - t)) - (cl-destructuring-bind (var . face) sym - (if (null increment) - (when (get var 'initial-value) - (set var (get var 'initial-value)) - (put var 'initial-value nil) - (setq changed t)) - (let* ((original-font (or (symbol-value var) - (face-font face t) - (with-temp-buffer (face-font face)))) - (font (doom-normalize-font original-font)) - (dfont - (or (if-let* ((remap-font (alist-get var font-alist)) - (remap-xlfd (doom-normalize-font remap-font))) - remap-xlfd - (purecopy font)) - (error "Could not decompose %s font" var)))) - (let* ((step (if fixed-size-p 0 (* increment doom-font-increment))) - (orig-size (font-get font :size)) - (new-size (if fixed-size-p increment (+ orig-size step)))) - (cond ((<= new-size 0) - (error "`%s' font is too small to be resized (%d)" var new-size)) - ((= orig-size new-size) - (user-error "Could not resize `%s' for some reason" var)) - ((setq changed t) - (unless (get var 'initial-value) - (put var 'initial-value original-font)) - (font-put dfont :size new-size) - (set var dfont))))))))) - (error - (ignore-errors (doom-adjust-font-size nil)) - (signal (car e) (cdr e))))) - -;;;###autoload -(defun doom-font-exists-p (font) - "Return non-nil if FONT exists on this system." - (declare (pure t) (side-effect-free t)) - (ignore-errors (find-font (doom-normalize-font font)))) - - -;; -;;; Commands - -;;;###autoload -(defun doom/reload-font () - "Reload your fonts, if they're set. -See `doom-init-fonts-h'." - (interactive) - (doom-init-fonts-h 'reload)) - -;;;###autoload -(defun doom/increase-font-size (count &optional increment) - "Enlargens the font size across the current and child frames." - (interactive "p") - (doom-adjust-font-size (* count (or increment doom-font-increment)))) - -;;;###autoload -(defun doom/decrease-font-size (count &optional increment) - "Shrinks the font size across the current and child frames." - (interactive "p") - (doom-adjust-font-size (* (- count) (or increment doom-font-increment)))) - -;;;###autoload -(defun doom/reset-font-size () - "Reset font size and `text-scale'. - -Assuming it has been adjusted via `doom/increase-font-size' and -`doom/decrease-font-size', or `text-scale-*' commands." - (interactive) - (let (success) - (when (and (boundp 'text-scale-mode-amount) - (/= text-scale-mode-amount 0)) - (text-scale-set 0) - (setq success t)) - (cond (doom-big-font-mode - (message "Disabling `doom-big-font-mode'") - (doom-big-font-mode -1) - (setq success t)) - ((doom-adjust-font-size nil) - (setq success t))) - (unless success - (user-error "The font hasn't been resized")))) - -;;;###autoload -(define-minor-mode doom-big-font-mode - "Globally resizes your fonts for streams, screen-sharing or presentations. - -Uses `doom-big-font' if its set, otherwise uses `doom-font' (falling back to -your system font). - -Also resizees `doom-variable-pitch-font' and `doom-serif-font'." - :init-value nil - :lighter " BIG" - :global t - (if doom-big-font - ;; Use `doom-big-font' in lieu of `doom-font' - (doom-adjust-font-size - (when doom-big-font-mode - (font-get (doom-normalize-font doom-big-font) :size)) - t `((doom-font . ,doom-big-font))) - ;; Resize the current font - (doom-adjust-font-size (if doom-big-font-mode doom-big-font-increment)))) diff --git a/.config/emacs/lisp/lib/git.el b/.config/emacs/lisp/lib/git.el @@ -1,16 +0,0 @@ -;;; lisp/lib/git.el -*- lexical-binding: t; -*- -;;; Commentary: -;;; Code: - -;;;###autoload -(defun doom-git-toplevel (&rest segments) - "Return the path to the current repo's root." - (cl-destructuring-bind (code . output) - (doom-call-process "git" "rev-parse" "--show-toplevel") - (if (zerop code) - (apply #'file-name-concat output segments) - ;; TODO throw stderr as error - (user-error "Not in a git repo: %s" default-directory)))) - -(provide 'doom-lib '(git)) -;;; git.el ends here diff --git a/.config/emacs/lisp/lib/help.el b/.config/emacs/lisp/lib/help.el @@ -1,736 +0,0 @@ -;;; lisp/lib/help.el -*- lexical-binding: t; -*- - -(defvar doom--help-major-mode-module-alist - '((dockerfile-mode :tools docker) - (agda2-mode :lang agda) - (c-mode :lang cc) - (c++-mode :lang cc) - (objc++-mode :lang cc) - (crystal-mode :lang crystal) - (lisp-mode :lang common-lisp) - (csharp-mode :lang csharp) - (clojure-mode :lang clojure) - (clojurescript-mode :lang clojure) - (json-mode :lang json) - (yaml-mode :lang yaml) - (csv-mode :lang data) - (erlang-mode :lang erlang) - (elixir-mode :lang elixir) - (elm-mode :lang elm) - (emacs-lisp-mode :lang emacs-lisp) - (ess-r-mode :lang ess) - (ess-julia-mode :lang ess) - (go-mode :lang go) - (haskell-mode :lang haskell) - (hy-mode :lang hy) - (idris-mode :lang idris) - (java-mode :lang java) - (js2-mode :lang javascript) - (rjsx-mode :lang javascript) - (typescript-mode :lang javascript) - (typescript-tsx-mode :lang javascript) - (coffee-mode :lang javascript) - (julia-mode :lang julia) - (kotlin-mode :lang kotlin) - (latex-mode :lang latex) - (LaTeX-mode :lang latex) - (ledger-mode :lang ledger) - (lua-mode :lang lua) - (moonscript-mode :lang lua) - (markdown-mode :lang markdown) - (gfm-mode :lang markdown) - (nim-mode :lang nim) - (nix-mode :lang nix) - (tuareg-mode :lang ocaml) - (org-mode :lang org) - (raku-mode :lang raku) - (php-mode :lang php) - (hack-mode :lang php) - (plantuml-mode :lang plantuml) - (purescript-mode :lang purescript) - (python-mode :lang python) - (restclient-mode :lang rest) - (ruby-mode :lang ruby) - (rust-mode :lang rust) - (rustic-mode :lang rust) - (scala-mode :lang scala) - (scheme-mode :lang scheme) - (sh-mode :lang sh) - (swift-mode :lang swift) - (web-mode :lang web) - (css-mode :lang web) - (scss-mode :lang web) - (sass-mode :lang web) - (less-css-mode :lang web) - (stylus-mode :lang web) - (terra-mode :lang terra)) - "An alist mapping major modes to Doom modules. - -This is used by `doom/help-modules' to auto-select the module corresponding to -the current major-modea.") - - -;; -;;; Helpers - -;;;###autoload -(defun doom-active-minor-modes () - "Return a list of active minor-mode symbols." - (cl-loop for mode in minor-mode-list - if (and (boundp mode) (symbol-value mode)) - collect mode)) - - -;; -;;; Custom describe commands - -;;;###autoload (defalias 'doom/describe-autodefs #'doom/help-autodefs) -;;;###autoload (defalias 'doom/describe-module #'doom/help-modules) -;;;###autoload (defalias 'doom/describe-package #'doom/help-packages) - -;;;###autoload -(defun doom/describe-active-minor-mode (mode) - "Get information on an active minor mode. Use `describe-minor-mode' for a -selection of all minor-modes, active or not." - (interactive - (list (completing-read "Describe active mode: " (doom-active-minor-modes)))) - (let ((symbol - (cond ((stringp mode) (intern mode)) - ((symbolp mode) mode) - ((error "Expected a symbol/string, got a %s" (type-of mode)))))) - (if (fboundp symbol) - (helpful-function symbol) - (helpful-variable symbol)))) - - -;; -;;; Documentation commands - -(defvar org-agenda-files) -(cl-defun doom--org-headings (files &key depth mindepth include-files &allow-other-keys) - "TODO" - (require 'org) - (let* ((default-directory doom-docs-dir) - (org-agenda-files (mapcar #'expand-file-name (ensure-list files))) - (depth (if (integerp depth) depth)) - (mindepth (if (integerp mindepth) mindepth)) - (org-inhibit-startup t)) - (message "Loading search results...") - (unwind-protect - (delq - nil - (org-map-entries - (lambda () - (cl-destructuring-bind (level _reduced-level _todo _priority text tags) - (org-heading-components) - (when (and (or (null depth) - (<= level depth)) - (or (null mindepth) - (>= level mindepth)) - (or (null tags) - (not (string-match-p ":TOC" tags)))) - (let ((path (org-get-outline-path)) - (title (org-collect-keywords '("TITLE") '("TITLE")))) - (list (string-join - (list (string-join - (append (when include-files - (list (or (cdr (assoc "TITLE" title)) - (file-relative-name (buffer-file-name))))) - path - (when text - (list (replace-regexp-in-string org-link-any-re "\\4" text)))) - " > ") - tags) - " ") - (buffer-file-name) - (point)))))) - t 'agenda)) - (mapc #'kill-buffer org-agenda-new-buffers) - (setq org-agenda-new-buffers nil)))) - -(defvar ivy-sort-functions-alist) -;;;###autoload -(cl-defun doom-completing-read-org-headings - (prompt files &rest plist &key depth mindepth include-files initial-input extra-candidates action) - "TODO" - (let ((alist - (append (apply #'doom--org-headings files plist) - extra-candidates)) - ivy-sort-functions-alist) - (if-let (result (completing-read prompt alist nil nil initial-input)) - (cl-destructuring-bind (file &optional location) - (cdr (assoc result alist)) - (if action - (funcall action file location) - (find-file file) - (cond ((functionp location) - (funcall location)) - (location - (goto-char location))) - (ignore-errors - (when (outline-invisible-p) - (save-excursion - (outline-previous-visible-heading 1) - (org-show-subtree)))))) - (user-error "Aborted")))) - -;;;###autoload -(defun doom/homepage () - "Open the doom emacs homepage in the browser." - (interactive) - (browse-url "https://doomemacs.org")) - -;;;###autoload -(defun doom/issue-tracker () - "Open Doom Emacs' global issue tracker on Discourse." - (interactive) - (browse-url "https://git.doomemacs.org/todo")) - -;;;###autoload -(defun doom/report-bug () - "Open the browser on our Discourse. - -If called when a backtrace buffer is present, it and the output of `doom-info' -will be automatically appended to the result." - (interactive) - (browse-url "https://git.doomemacs.org/core/issues/new?labels=1.+bug%2C2.+status%3Aunread&template=bug_report.yml")) - -;;;###autoload -(defun doom/discourse () - "Open Doom Emacs' issue tracker on Discourse." - (interactive) - (browse-url "https://discourse.doomemacs.org")) - -;;;###autoload -(defun doom/help () - "Open Doom's user manual." - (interactive) - (find-file (expand-file-name "index.org" doom-docs-dir))) - -;;;###autoload -(defun doom/help-search-headings (&optional initial-input) - "Search Doom's documentation and jump to a headline." - (interactive) - (doom-completing-read-org-headings - "Find in Doom help: " - (list "getting_started.org" - "contributing.org" - "troubleshooting.org" - "tutorials.org" - "faq.org") - :depth 3 - :include-files t - :initial-input initial-input - :extra-candidates - (mapcar (lambda (x) - (setcar x (concat "Doom Modules > " (car x))) - x) - (doom--help-modules-list)))) - -;;;###autoload -(defun doom/help-search (&optional initial-input) - "Perform a text search on all of Doom's documentation." - (interactive) - (funcall (cond ((fboundp '+ivy-file-search) - #'+ivy-file-search) - ((fboundp '+helm-file-search) - #'+helm-file-search) - ((fboundp '+vertico-file-search) - #'+vertico-file-search) - ((rgrep - (read-regexp - "Search for" (or initial-input 'grep-tag-default) - 'grep-regexp-history) - "*.org" doom-emacs-dir) - #'ignore)) - :query initial-input - :args '("-t" "org") - :in doom-emacs-dir - :prompt "Search documentation for: ")) - -;;;###autoload -(defun doom/help-search-news (&optional initial-input) - "Search headlines in Doom's newsletters." - (interactive) - (doom-completing-read-org-headings - "Find in News: " - (nreverse (doom-files-in (expand-file-name "news" doom-docs-dir) - :match "/[0-9]" - :relative-to doom-docs-dir)) - :include-files t - :initial-input initial-input)) - -;;;###autoload -(defun doom/help-faq (&optional initial-input) - "Search Doom's FAQ and jump to a question." - (interactive) - (doom-completing-read-org-headings - "Find in FAQ: " (list "faq.org") - :depth 2 - :initial-input initial-input)) - -;;;###autoload -(defun doom/help-news () - "Open a Doom newsletter. -The latest newsletter will be selected by default." - (interactive) - (let* ((default-directory (expand-file-name "news/" doom-docs-dir)) - (news-files (doom-files-in default-directory))) - (find-file - (read-file-name (format "Open Doom newsletter (current: v%s): " - doom-version) - default-directory - (if (member doom-version news-files) - doom-version - (concat (mapconcat #'number-to-string - (nbutlast (version-to-list doom-version) 1) - ".") - ".x")) - t doom-version)))) - -;;;###autoload -(defun doom/help-autodefs (autodef) - "Open documentation for an autodef. - -An autodef is a Doom concept. It is a function or macro that is always defined, -whether or not its containing module is disabled (in which case it will safely -no-op without evaluating its arguments). This syntactic sugar lets you use them -without needing to check if they are available." - (interactive - (let* ((settings - (cl-loop with case-fold-search = nil - for sym being the symbols of obarray - for sym-name = (symbol-name sym) - if (and (or (functionp sym) - (macrop sym)) - (string-match-p "[a-z]!$" sym-name)) - collect sym)) - (sym (symbol-at-point)) - (autodef - (completing-read - "Describe setter: " - ;; TODO Could be cleaner (refactor me!) - (cl-loop with maxwidth = (apply #'max (mapcar #'length (mapcar #'symbol-name settings))) - for def in (sort settings #'string-lessp) - if (get def 'doom-module) - collect - (format (format "%%-%ds%%s" (+ maxwidth 4)) - def (propertize (format "%s %s" (car it) (cdr it)) - 'face 'font-lock-comment-face)) - else if (and (string-match-p "^set-.+!$" (symbol-name def)) - (symbol-file def) - (file-in-directory-p (symbol-file def) doom-core-dir)) - collect - (format (format "%%-%ds%%s" (+ maxwidth 4)) - def (propertize (format "lisp/%s.el" (file-name-sans-extension (file-relative-name (symbol-file def) doom-core-dir))) - 'face 'font-lock-comment-face))) - nil t - (when (and (symbolp sym) - (string-match-p "!$" (symbol-name sym))) - (symbol-name sym))))) - (list (and autodef (car (split-string autodef " ")))))) - (or (stringp autodef) - (functionp autodef) - (signal 'wrong-type-argument (list '(stringp functionp) autodef))) - (let ((fn (if (functionp autodef) - autodef - (intern-soft autodef)))) - (or (fboundp fn) - (error "'%s' is not a valid DOOM autodef" autodef)) - (if (fboundp 'helpful-callable) - (helpful-callable fn) - (describe-function fn)))) - -(defun doom--help-modules-list () - (cl-loop for (cat . mod) in (doom-module-list 'all) - for readme-path = (or (doom-module-locate-path cat mod "README.org") - (doom-module-locate-path cat mod)) - for format = (if mod (format "%s %s" cat mod) (format "%s" cat)) - if (doom-module-p cat mod) - collect (list format readme-path) - else if (and cat mod) - collect (list (propertize format 'face 'font-lock-comment-face) - readme-path))) - -(defun doom--help-current-module-str () - (cond ((save-excursion - (require 'smartparens) - (ignore-errors - (sp-beginning-of-sexp) - (unless (eq (char-after) ?\() - (backward-char)) - (let ((sexp (sexp-at-point))) - ;; DEPRECATED `featurep!' - (when (memq (car-safe sexp) '(featurep! modulep! require!)) - (format "%s %s" (nth 1 sexp) (nth 2 sexp))))))) - ((when buffer-file-name - (when-let (mod (doom-module-from-path buffer-file-name)) - (unless (memq (car mod) '(:core :user)) - (format "%s %s" (car mod) (cdr mod)))))) - ((when-let (mod (cdr (assq major-mode doom--help-major-mode-module-alist))) - (format "%s %s" - (symbol-name (car mod)) - (symbol-name (cadr mod))))))) - -;;;###autoload -(defun doom/help-modules (category module &optional visit-dir) - "Open the documentation for a Doom module. - -CATEGORY is a keyword and MODULE is a symbol. e.g. :editor and 'evil. - -If VISIT-DIR is non-nil, visit the module's directory rather than its -documentation. - -Automatically selects a) the module at point (in private init files), b) the -module derived from a `modulep!' or `require!' call, c) the module that the -current file is in, or d) the module associated with the current major mode (see -`doom--help-major-mode-module-alist')." - (interactive - (nconc - (mapcar #'intern - (split-string - (completing-read "Describe module: " - (doom--help-modules-list) - nil t nil nil - (doom--help-current-module-str)) - " " t)) - (list current-prefix-arg))) - (cl-check-type category symbol) - (cl-check-type module symbol) - (cl-destructuring-bind (module-string path) - (or (assoc (format "%s %s" category module) (doom--help-modules-list)) - (user-error "'%s %s' is not a valid module" category module)) - (setq module-string (substring-no-properties module-string)) - (unless (file-readable-p path) - (error "Can't find or read %S module at %S" module-string path)) - (cond ((not (file-directory-p path)) - (if visit-dir - (doom-project-browse (file-name-directory path)) - (find-file path))) - (visit-dir - (doom-project-browse path)) - ((y-or-n-p (format "The %S module has no README file. Explore its directory?" - module-string)) - (doom-project-browse (file-name-directory path))) - ((user-error "Aborted module lookup"))))) - -;;;###autoload -(defun doom/help-custom-variable (var) - "Look up documentation for a custom variable. - -Unlike `helpful-variable', which casts a wider net that includes internal -variables, this only lists variables that exist to be customized (defined with -`defcustom')." - (interactive - (list (helpful--read-symbol - "Custom variable: " - (helpful--variable-at-point) - (lambda (sym) - (and (helpful--variable-p sym) - (custom-variable-p sym) - ;; Exclude minor mode state variables, which aren't meant to be - ;; modified directly, but through their associated function. - (not (or (and (string-suffix-p "-mode" (symbol-name sym)) - (fboundp sym)) - (eq (get sym 'custom-set) 'custom-set-minor-mode)))))))) - (helpful-variable var)) - - -;; -;;; `doom/help-packages' - -(defun doom--help-insert-button (label &optional uri line) - "Helper function to insert a button at point. - -The button will have the text LABEL. If URI is given, the button will open it, -otherwise the LABEL will be used. If the uri to open is a url it will be opened -in a browser. If LINE is given (and the uri to open is not a url), then the file -will open with point on that line." - (let ((uri (or uri label))) - (insert-text-button - label - 'face 'link - 'follow-link t - 'action - (if (string-match-p "^https?://" uri) - (lambda (_) (browse-url uri)) - (unless (file-exists-p uri) - (error "Path does not exist: %S" uri)) - (lambda (_) - (when (window-dedicated-p) - (other-window 1)) - (find-file uri) - (when line - (goto-char (point-min)) - (forward-line (1- line)) - (recenter))))))) - -(defun doom--help-package-configs (package) - (let ((default-directory doom-emacs-dir)) - ;; TODO Use ripgrep instead - (split-string - (cdr (doom-call-process - "git" "grep" "--no-break" "--no-heading" "--line-number" - (format "%s %s\\($\\| \\)" - "\\(^;;;###package\\|(after!\\|(use-package!\\)" - package) - ":(exclude)*.org")) - "\n" t))) - -(defvar doom--help-packages-list nil) -;;;###autoload -(defun doom/help-packages (package) - "Like `describe-package', but for packages installed by Doom modules. - -Only shows installed packages. Includes information about where packages are -defined and configured. - -If prefix arg is present, refresh the cache." - (interactive - (let ((guess (or (function-called-at-point) - (symbol-at-point)))) - (require 'finder-inf nil t) - (require 'package) - (require 'straight) - (let ((packages - (if (and doom--help-packages-list (null current-prefix-arg)) - doom--help-packages-list - (message "Generating packages list for the first time...") - (redisplay) - (setq doom--help-packages-list - (delete-dups - (append (mapcar #'car package-alist) - (mapcar #'car package--builtins) - (mapcar #'intern - (hash-table-keys straight--build-cache)) - (mapcar #'car (doom-package-list 'all)) - nil)))))) - (unless (memq guess packages) - (setq guess nil)) - (list - (intern - (completing-read (format "Describe Doom package (%s): " - (concat (when guess - (format "default '%s', " guess)) - (format "total %d" (length packages)))) - packages nil t nil nil - (when guess (symbol-name guess)))))))) - ;; TODO Refactor me. - (require 'doom-packages) - (doom-initialize-packages) - (help-setup-xref (list #'doom/help-packages package) - (called-interactively-p 'interactive)) - (with-help-window (help-buffer) - (with-current-buffer standard-output - (when (or (package-desc-p package) - (and (symbolp package) - (or (assq package package-alist) - (assq package package--builtins)))) - (describe-package-1 package)) - (let ((indent (make-string 13 ? ))) - (goto-char (point-min)) - (if (re-search-forward " Status: .*$" nil t) - (insert "\n") - (search-forward "\n\n" nil t)) - - (package--print-help-section "Package") - (insert (symbol-name package) "\n") - - (package--print-help-section "Source") - (pcase (doom-package-backend package) - (`straight - (insert "Straight\n") - (package--print-help-section "Pinned") - (insert (if-let (pin (plist-get (cdr (assq package doom-packages)) :pin)) - pin - "unpinned") - "\n") - - (package--print-help-section "Build") - (let ((default-directory (straight--repos-dir (symbol-name package)))) - (if (file-exists-p default-directory) - (insert (cdr (doom-call-process "git" "log" "-1" "--format=%D %h %ci"))) - (insert "n/a"))) - (insert "\n" indent) - - (package--print-help-section "Build location") - (let ((build-dir (straight--build-dir (symbol-name package)))) - (if (file-exists-p build-dir) - (doom--help-insert-button (abbreviate-file-name build-dir)) - (insert "n/a"))) - (insert "\n" indent) - - (package--print-help-section "Repo location") - (let* ((local-repo (doom-package-recipe-repo package)) - (repo-dir (straight--repos-dir local-repo))) - (if (file-exists-p repo-dir) - (doom--help-insert-button (abbreviate-file-name repo-dir)) - (insert "n/a")) - (insert "\n")) - - (let ((recipe (doom-package-build-recipe package))) - (package--print-help-section "Recipe") - (insert - (replace-regexp-in-string "\n" (concat "\n" indent) - (pp-to-string recipe)))) - - (package--print-help-section "Homepage") - (doom--help-insert-button (doom-package-homepage package))) - - (`elpa (insert "[M]ELPA ") - (doom--help-insert-button (doom-package-homepage package)) - (package--print-help-section "Location") - (doom--help-insert-button - (abbreviate-file-name - (file-name-directory - (locate-library (symbol-name package)))))) - (`builtin (insert "Built-in\n") - (package--print-help-section "Location") - (doom--help-insert-button - (abbreviate-file-name - (file-name-directory - (locate-library (symbol-name package)))))) - (`other (doom--help-insert-button - (abbreviate-file-name - (or (symbol-file package) - (locate-library (symbol-name package)))))) - (_ (insert "Not installed"))) - (insert "\n") - - (when-let - (modules - (if (gethash (symbol-name package) straight--build-cache) - (doom-package-get package :modules) - (plist-get (cdr (assq package (doom-package-list 'all))) - :modules))) - (package--print-help-section "Modules") - (insert "Declared by the following Doom modules:\n") - (dolist (m modules) - (let* ((module-path (pcase (car m) - (:core doom-core-dir) - (:user doom-user-dir) - (category - (doom-module-locate-path category - (cdr m))))) - (readme-path (expand-file-name "README.org" module-path))) - (insert indent) - (doom--help-insert-button - (format "%s %s" (car m) (or (cdr m) "")) - module-path) - (insert " (") - (if (file-exists-p readme-path) - (doom--help-insert-button "readme" readme-path) - (insert "no readme")) - (insert ")\n")))) - - (package--print-help-section "Configs") - (if-let ((configs (doom--help-package-configs package))) - (progn - (insert "This package is configured in the following locations:") - (dolist (location configs) - (insert "\n" indent) - (cl-destructuring-bind (file line _match &rest) - (split-string location ":") - (doom--help-insert-button location - (expand-file-name file doom-emacs-dir) - (string-to-number line))))) - (insert "This package is not configured anywhere")) - (goto-char (point-min)))))) - -(defvar doom--package-cache nil) -(defun doom--package-list (&optional prompt) - (let* ((guess (or (function-called-at-point) - (symbol-at-point)))) - (require 'finder-inf nil t) - (unless package--initialized - (package-initialize t)) - (let ((packages (or doom--package-cache - (progn - (message "Reading packages...") - (cl-delete-duplicates - (append (mapcar 'car package-alist) - (mapcar 'car package--builtins) - (mapcar 'car package-archive-contents))))))) - (setq doom--package-cache packages) - (unless (memq guess packages) - (setq guess nil)) - (intern (completing-read (or prompt - (if guess - (format "Select package to search for (default %s): " - guess) - "Describe package: ")) - packages nil t nil nil - (if guess (symbol-name guess))))))) - -;;;###autoload -(defun doom/help-package-config (package) - "Jump to any `use-package!', `after!' or ;;;###package block for PACKAGE. - -This only searches `doom-emacs-dir' (typically ~/.emacs.d) and does not include -config blocks in your private config." - (interactive (list (doom--package-list "Find package config: "))) - (cl-destructuring-bind (file line _match) - (split-string - (completing-read - "Jump to config: " - (or (doom--help-package-configs package) - (user-error "This package isn't configured by you or Doom"))) - ":") - (find-file (expand-file-name file doom-emacs-dir)) - (goto-char (point-min)) - (forward-line (1- line)) - (recenter))) - -;;;###autoload -(defalias 'doom/help-package-homepage #'straight-visit-package-website) - -(defun doom--help-search-prompt (prompt) - (let ((query (doom-thing-at-point-or-region))) - (if (featurep 'counsel) - query - (read-string prompt query 'git-grep query)))) - -(defvar counsel-rg-base-command) -(defun doom--help-search (dirs query prompt) - ;; REVIEW Replace with deadgrep - (unless (executable-find "rg") - (user-error "Can't find ripgrep on your system")) - (cond ((fboundp 'consult--grep) - (consult--grep prompt #'consult--ripgrep-make-builder (cons data-directory dirs) query)) - ((fboundp 'counsel-rg) - (let ((counsel-rg-base-command - (if (stringp counsel-rg-base-command) - (format counsel-rg-base-command - (concat "%s " (mapconcat #'shell-quote-argument dirs " "))) - (append counsel-rg-base-command dirs)))) - (counsel-rg query nil "-Lz" (concat prompt ": ")))) - ;; () TODO Helm support? - ((grep-find - (string-join - (append (list "rg" "-L" "--search-zip" "--no-heading" "--color=never" - (shell-quote-argument query)) - (mapcar #'shell-quote-argument dirs)) - " "))))) - -;;;###autoload -(defun doom/help-search-load-path (query) - "Perform a text search on your `load-path'. -Uses the symbol at point or the current selection, if available." - (interactive - (list (doom--help-search-prompt "Search load-path: "))) - (doom--help-search (cl-remove-if-not #'file-directory-p load-path) - query "Search load-path: ")) - -;;;###autoload -(defun doom/help-search-loaded-files (query) - "Perform a text search on your `load-path'. -Uses the symbol at point or the current selection, if available." - (interactive - (list (doom--help-search-prompt "Search loaded files: "))) - (doom--help-search - (cl-loop for (file . _) in (cl-remove-if-not #'stringp load-history :key #'car) - for filebase = (file-name-sans-extension file) - if (file-exists-p! (or (format "%s.el.gz" filebase) - (format "%s.el" filebase))) - collect it) - query "Search loaded files: ")) diff --git a/.config/emacs/lisp/lib/packages.el b/.config/emacs/lisp/lib/packages.el @@ -1,316 +0,0 @@ -;;; lisp/lib/packages.el -*- lexical-binding: t; -*- - -;;;###autoload -(defun doom/reload-packages () - "Reload `doom-packages', `package' and `quelpa'." - (interactive) - ;; HACK straight.el must be loaded for this to work - (message "Reloading packages") - (doom-initialize-packages t) - (message "Reloading packages...DONE")) - - -;; -;;; Bump commands - -(defun doom--package-merge-recipes (package plist) - (require 'straight) - (doom-plist-merge - (plist-get plist :recipe) - (if-let (recipe (straight-recipes-retrieve package)) - (cdr (if (memq (car recipe) '(quote \`)) - (eval recipe t) - recipe)) - (let ((recipe (plist-get (cdr (assq package doom-packages)) - :recipe))) - (if (keywordp (car recipe)) - recipe - (cdr recipe)))))) - -(defun doom--package-to-bump-string (package plist) - "Return a PACKAGE and its PLIST in 'username/repo@commit' format." - (format "%s@%s" - (plist-get (doom--package-merge-recipes package plist) :repo) - (substring-no-properties (plist-get plist :pin) 0 12))) - -(defun doom--package-at-point (&optional point) - "Return the package and plist from the (package! PACKAGE PLIST...) at point." - (save-match-data - (save-excursion - (and point (goto-char point)) - (while (and (or (atom (sexp-at-point)) - (doom-point-in-string-or-comment-p)) - (search-backward "(" nil t))) - (when (eq (car-safe (sexp-at-point)) 'package!) - (cl-destructuring-bind (beg . end) - (bounds-of-thing-at-point 'sexp) - (let* ((doom-packages nil) - (buffer-file-name - (or buffer-file-name - (bound-and-true-p org-src-source-file-name))) - (package - (doom-context-with 'packages - (doom-module-context-with (doom-module-from-path buffer-file-name) - (eval (sexp-at-point) t))))) - (list :beg beg - :end end - :package (car package) - :plist (cdr package)))))))) - -;;;###autoload -(defun doom/bumpify-package-at-point () - "Convert `package!' call at point to a bump string." - (interactive) - (cl-destructuring-bind (&key package plist beg end) - (doom--package-at-point) - (when-let (str (doom--package-to-bump-string package plist)) - (goto-char beg) - (delete-region beg end) - (insert str)))) - -;;;###autoload -(defun doom/bumpify-packages-in-buffer () - "Convert all `package!' calls in buffer into bump strings." - (interactive) - (save-excursion - (goto-char (point-min)) - (while (search-forward "(package!" nil t) - (unless (doom-point-in-string-or-comment-p) - (doom/bumpify-package-at-point))))) - -;;;###autoload -(defun doom/bump-package-at-point (&optional select) - "Inserts or updates a `:pin' for the `package!' statement at point. -Grabs the latest commit id of the package using 'git'." - (interactive "P") - (doom-initialize-packages) - (cl-destructuring-bind (&key package plist beg end) - (or (doom--package-at-point) - (user-error "Not on a `package!' call")) - (let* ((recipe (doom--package-merge-recipes package plist)) - (branch (plist-get recipe :branch)) - (oldid (or (plist-get plist :pin) - (doom-package-get package :pin))) - (url (straight-vc-git--destructure recipe (upstream-repo upstream-host) - (straight-vc-git--encode-url upstream-repo upstream-host))) - (id (or (when url - (cdr (doom-call-process - "git" "ls-remote" url - (unless select branch)))) - (user-error "Couldn't find a recipe for %s" package))) - (id (car (split-string - (if select - (completing-read "Commit: " (split-string id "\n" t)) - id))))) - (when (and oldid - (plist-member plist :pin) - (equal oldid id)) - (user-error "%s: no update necessary" package)) - (save-excursion - (if (re-search-forward ":pin +\"\\([^\"]+\\)\"" end t) - (replace-match id t t nil 1) - (goto-char (1- end)) - (insert " :pin " (prin1-to-string id)))) - (cond ((not oldid) - (message "%s: → %s" package (substring id 0 10))) - ((< (length oldid) (length id)) - (message "%s: extended to %s..." package id)) - ((message "%s: %s → %s" - package - (substring oldid 0 10) - (substring id 0 10))))))) - -;;;###autoload -(defun doom/bump-packages-in-buffer (&optional select) - "Inserts or updates a `:pin' to all `package!' statements in current buffer. -If SELECT (prefix arg) is non-nil, prompt you to choose a specific commit for -each package." - (interactive "P") - (save-excursion - (goto-char (point-min)) - (doom-initialize-packages) - (let (packages) - (while (search-forward "(package! " nil t) - (unless (let ((ppss (syntax-ppss))) - (or (nth 4 ppss) - (nth 3 ppss) - (save-excursion - (and (goto-char (match-beginning 0)) - (not (plist-member (sexp-at-point) :pin)))))) - (condition-case e - (push (doom/bump-package-at-point select) packages) - (user-error (message "%s" (error-message-string e)))))) - (if packages - (message "Updated %d packages\n- %s" (length packages) (string-join packages "\n- ")) - (message "No packages to update"))))) - -;;;###autoload -(defun doom/bump-module (category &optional module select) - "Bump packages in CATEGORY MODULE. -If SELECT (prefix arg) is non-nil, prompt you to choose a specific commit for -each package." - (interactive - (let* ((module (completing-read - "Bump module: " - (let ((modules (doom-module-list 'all))) - (mapcar (lambda (m) - (if (listp m) - (format "%s %s" (car m) (cdr m)) - (format "%s" m))) - (append (delete-dups (mapcar #'car modules)) - modules))) - nil t nil nil)) - (module (split-string module " " t))) - (list (intern (car module)) - (ignore-errors (intern (cadr module))) - current-prefix-arg))) - (mapc (lambda! ((cat . mod)) - (if-let (packages-file (doom-module-locate-path cat mod doom-module-packages-file)) - (with-current-buffer - (or (get-file-buffer packages-file) - (find-file-noselect packages-file)) - (doom/bump-packages-in-buffer select) - (save-buffer)) - (message "Module %s has no packages.el file" (cons cat mod)))) - (if module - (list (cons category module)) - (cl-remove-if-not (lambda (m) (eq (car m) category)) - (doom-module-list 'all))))) - -;;;###autoload -(defun doom/bump-package (package) - "Bump PACKAGE in all modules that install it." - (interactive - (list (intern (completing-read "Bump package: " - (mapcar #'car (doom-package-list 'all)))))) - (let* ((packages (doom-package-list 'all)) - (modules (plist-get (alist-get package packages) :modules))) - (unless modules - (user-error "This package isn't installed by any Doom module")) - (dolist (module modules) - (when (doom-module-locate-path (car module) (cdr module) doom-module-packages-file) - (doom/bump-module (car module) (cdr module)))))) - - -;; -;;; Bump commits - -;;;###autoload -(defun doom/bumpify-diff (&optional interactive) - "Copy user/repo@hash -> user/repo@hash's of changed packages to clipboard. - -Must be run from a magit diff buffer." - (interactive (list 'interactive)) - (save-window-excursion - (magit-diff-staged) - (unless (eq major-mode 'magit-diff-mode) - (user-error "Not in a magit diff buffer")) - (goto-char (point-min)) - (letf! (defun read-package () - (let* ((file (magit-file-at-point)) - (visited? (if file (get-file-buffer file)))) - (save-window-excursion - (call-interactively #'magit-diff-visit-file) - (unwind-protect - (and (or (looking-at-p "(package!") - (re-search-forward "(package! " (line-end-position) t) - (re-search-backward "(package! " nil t)) - (let* ((buffer-file-name file) - (plist (doom--package-at-point))) - (cons (plist-get plist :package) - plist))) - (unless visited? - (kill-current-buffer)))))) - (let (targets - before - after - lines - errors) - (save-excursion - (while (re-search-forward "^modified +\\(.+\\)$" nil t) - (cl-pushnew (doom-module-from-path (match-string 1)) targets - :test #'equal))) - (save-excursion - (while (re-search-forward "^-" nil t) - (cl-pushnew (read-package) before :test #'equal))) - (save-excursion - (while (re-search-forward "^+" nil t) - (cl-pushnew (read-package) after :test #'equal))) - (unless (= (length before) (length after)) - (user-error "Uneven number of packages being bumped")) - (dolist (p1 before) - (cl-destructuring-bind (package &key plist _beg _end &allow-other-keys) p1 - (let ((p2 (cdr (assq package after)))) - (if (null p2) - (push package errors) - (let ((bstr1 (doom--package-to-bump-string package plist)) - (bstr2 (doom--package-to-bump-string package (plist-get p2 :plist)))) - (cl-pushnew (format "%s -> %s" bstr1 bstr2) lines :test #'equal)))))) - (if (null lines) - (user-error "No bumps to bumpify") - (prog1 (funcall (if interactive #'kill-new #'identity) - (format "bump: %s\n\n%s" - (mapconcat (lambda (x) - (mapconcat #'symbol-name x " ")) - (cl-loop with alist = () - for (category . module) in (reverse targets) - do (setf (alist-get category alist) - (append (alist-get category alist) (list module))) - finally return alist) - " ") - (string-join (sort (reverse lines) #'string-lessp) - "\n"))) - (when interactive - (message "Copied to clipboard")))))))) - -;;;###autoload -(defun doom/commit-bumps () - "Create a pre-filled magit commit for currently bumped packages." - (interactive) - (magit-commit-create - (list "-e" "-m" (doom/bumpify-diff)))) - - -;; -;;; Package metadata - -;;;###autoload -(defun doom-package-homepage (package) - "Return the url to PACKAGE's homepage (usually a repo)." - (doom-initialize-packages) - (or (get package 'homepage) - (put package 'homepage - (cond ((when-let (location (locate-library (symbol-name package))) - (with-temp-buffer - (if (string-match-p "\\.gz$" location) - (jka-compr-insert-file-contents location) - (insert-file-contents (concat (file-name-sans-extension location) ".el") - nil 0 4096)) - (let ((case-fold-search t)) - (when (re-search-forward " \\(?:URL\\|homepage\\|Website\\): \\(http[^\n]+\\)\n" nil t) - (match-string-no-properties 1)))))) - ((when-let ((recipe (straight-recipes-retrieve package))) - (straight--with-plist (straight--convert-recipe recipe) - (host repo) - (pcase host - (`github (format "https://github.com/%s" repo)) - (`gitlab (format "https://gitlab.com/%s" repo)) - (`bitbucket (format "https://bitbucket.com/%s" (plist-get plist :repo))) - (`git repo) - (_ nil))))) - ((or package-archive-contents - (progn (package-refresh-contents) - package-archive-contents)) - (pcase (ignore-errors (package-desc-archive (cadr (assq package package-archive-contents)))) - (`nil nil) - ("org" "https://orgmode.org") - ((or "melpa" "melpa-mirror") - (format "https://melpa.org/#/%s" package)) - ("gnu" - (format "https://elpa.gnu.org/packages/%s.html" package)) - (archive - (if-let (src (cdr (assoc package package-archives))) - (format "%s" src) - (user-error "%S isn't installed through any known source (%s)" - package archive))))) - ((user-error "Can't get homepage for %S package" package)))))) diff --git a/.config/emacs/lisp/lib/plist.el b/.config/emacs/lisp/lib/plist.el @@ -1,66 +0,0 @@ -;;; lisp/lib/plist.el -*- lexical-binding: t; -*- -;;; Commentary: -;;; Code: - -;; -;;; Macros - -;;; DEPRECATED In favor of `cl-callf' -;;;###autoload -(defmacro plist-put! (plist &rest rest) - "Set each PROP VALUE pair in REST to PLIST in-place." - `(cl-loop for (prop value) - on (list ,@rest) by #'cddr - do ,(if (symbolp plist) - `(setq ,plist (plist-put ,plist prop value)) - `(plist-put ,plist prop value)))) - - -;; -;;; Library - -;;;###autoload -(defun doom-plist-get (plist prop &optional nil-value) - "Return PROP in PLIST, if it exists. Otherwise NIL-VALUE." - (if-let (val (plist-member plist prop)) - (cadr val) - nil-value)) - -;;;###autoload -(defun doom-plist-merge (from-plist to-plist) - "Non-destructively merge FROM-PLIST onto TO-PLIST" - (let ((plist (copy-sequence from-plist))) - (while plist - (cl-callf plist-put to-plist (pop plist) (pop plist))) - to-plist)) - -;;;###autoload -(defun doom-plist-delete-nil (plist) - "Delete `nil' properties from a copy of PLIST." - (let (p) - (while plist - (if (car plist) - (cl-callf plist-put p (car plist) (nth 1 plist))) - (setq plist (cddr plist))) - p)) - -;;;###autoload -(defun doom-plist-keys (plist) - "Return the keys in PLIST." - (let (keys) - (while plist - (push (car plist) keys) - (setq plist (cddr plist))) - keys)) - -;;;###autoload -(defun doom-plist-values (plist) - "Return the values in PLIST." - (let (keys) - (while plist - (push (cadr plist) keys) - (setq plist (cddr plist))) - keys)) - -(provide 'doom-lib '(plist)) -;;; plist.el ends here diff --git a/.config/emacs/lisp/lib/print.el b/.config/emacs/lisp/lib/print.el @@ -1,501 +0,0 @@ -;;; lisp/lib/print.el -*- lexical-binding: t; -*- -;;; Commentary -;; -;; This is Doom's output library, for controlling what does and doesn't get -;; logged, and provides a simple DSL for formatting output. It's mainly to -;; serve the noninteractive use-case, as `message' is more than good enough in -;; interactive sessions, but `print!' and `doom-log' are safe to use as a -;; drop-in replacement. -;; -;;; Code: -(eval-when-compile (require 'doom)) ; be silent, o'byte-compiler -(require 'ansi-color) - - -;; -;;; Variables - -(defvar doom-print-ansi-alist - '(;; fx - (bold . 1) - (dark . 2) - (italic . 3) - (underscore . 4) - (blink . 5) - (rapid . 6) - (contrary . 7) - (concealed . 8) - (strike . 9) - ;; fg - (black . 30) - (red . 31) - (green . 32) - (yellow . 33) - (blue . 34) - (magenta . 35) - (cyan . 36) - (white . 37) - ;; bg - (on-black . 40) - (on-red . 41) - (on-green . 42) - (on-yellow . 43) - (on-blue . 44) - (on-magenta . 45) - (on-cyan . 46) - (on-white . 47)) - "An alist of fg/bg/fx names mapped to ansi codes. - -This serves as the cipher for converting (COLOR ...) function calls in `print!' -and `format!' into colored output, where COLOR is any car of this list (or -`doom-print-class-alist').") - -(defvar doom-print-class-alist - `((buffer . doom-print--buffer) - (color . doom-print--style) - (class . doom-print--class) - (indent . doom-print--indent) - (fill . doom-print--fill) - (join . doom-print--join) - (org . doom-print--org) - (markup . doom-print--cli-markup) - (trim . string-trim) - (rtrim . string-trim-right) - (ltrim . string-trim-left) - (p . doom-print--paragraph) - (truncate . doom-print--truncate) - (success . (lambda (str &rest args) - (apply #'doom-print--style 'green - (doom-print--indent str "✓ ") - args))) - (warn . (lambda (str &rest args) - (apply #'doom-print--style 'yellow - (doom-print--indent str "! ") - args))) - (error . (lambda (str &rest args) - (apply #'doom-print--style 'red - (doom-print--indent str "x ") - args))) - (item . (lambda (str &rest args) - (doom-print--indent - (if args (apply #'format str args) str) - "- "))) - (start . (lambda (str &rest args) - (doom-print--indent - (if args (apply #'format str args) str) - "> "))) - (path . abbreviate-file-name) - (symbol . symbol-name) - (relpath . (lambda (str &optional dir) - (if (or (not str) - (not (stringp str)) - (string-blank-p str)) - str - (let ((dir (or dir (file-truename default-directory))) - (str (file-truename str))) - (if (file-in-directory-p str dir) - (file-relative-name str dir) - (abbreviate-file-name str)))))) - (filename . file-name-nondirectory) - (dirname . (lambda (path) - (unless (file-directory-p path) - (setq path (file-name-directory path))) - (directory-file-name path)))) - "An alist of text classes that map to transformation functions. - -Any of these classes can be called like functions from within `format!' and -`print!' calls, which will transform their input.") - -(defvar doom-print-indent 0 - "Level to rigidly indent text returned by `format!' and `print!'.") - -(defvar doom-print-indent-increment 2 - "Steps in which to increment `doom-print-indent' for consecutive levels.") - -(defvar doom-print-backend (if noninteractive 'ansi 'text-properties) - "Whether to print colors/styles with ANSI codes or with text properties. - -Accepts `ansi' and `text-properties'. `nil' means don't render styles at all.") - -(defvar doom-print-level 'notice - "The current, default logging level.") - -(defvar doom-print-minimum-level 'notice - "The minimum logging level for a message to be output.") - -;; Record print levels in these symbols for easy, quasi-read-only access later. -(let ((levels '(debug ; the system is thinking out loud - info ; less details about important progress - notice ; important details about important progress - warning ; a dismissable issue that may have reprecussions later - error))) ; something has gone terribly wrong - (dotimes (i (length levels)) - (put (nth i levels) 'print-level i))) - - -;; -;;; Library - -;;;###autoload -(cl-defun doom-print - (output &key - (format nil) - (level doom-print-level) - (newline t) - (stream standard-output)) - "Print OUTPUT to stdout. - -Unlike `message', this: -- Respects the value of `standard-output'. -- Indents according to `doom-print-indent' (if FORMAT is non-nil). -- Prints to stdout instead of stderr in batch mode. -- Recognizes more terminal escape codes (only in batch mode). -- No-ops if OUTPUT is nil or an empty/blank string. - -Returns OUTPUT." - (cl-check-type output (or null string)) - (when (and (stringp output) - (or (eq level t) - (if (listp level) - (memq doom-print-minimum-level level) - (>= (get level 'print-level) - (get doom-print-minimum-level 'print-level))))) - (when format - (setq output (doom-print--format "%s" output))) - (princ output stream) - (if newline (terpri stream)) - output)) - -;;;###autoload -(defmacro format! (message &rest args) - "An alternative to `format' that understands `print!'s style syntax." - `(doom-print--format ,@(doom-print--apply `(,message ,@args)))) - -;;;###autoload -(defmacro print-group! (&rest body) - "Indents any `print!' or `format!' output within BODY." - (declare (indent defun)) - (cl-destructuring-bind (&key if indent level verbose title - ;; TODO: Implement these - _benchmark) - (cl-loop for (key val) on body by #'cddr - while (keywordp key) - collect (pop body) - collect (pop body)) - (if verbose (setq level ''info)) - `(progn - ,@(if title `((print! (start ,title)))) - (let ((doom-print-level (or ,level doom-print-level)) - (doom-print-indent - (+ (if ,(or if t) (or ,indent doom-print-indent-increment) 0) - doom-print-indent))) - ,@body)))) - -;;;###autoload -(defmacro print! (message &rest args) - "Prints MESSAGE, formatted with ARGS, to stdout. - -Returns non-nil if the message is a non-empty string. - -Can be colored using (color ...) blocks: - - (print! \"Hello %s\" (bold (blue \"How are you?\"))) - (print! \"Hello %s\" (red \"World\")) - (print! (green \"Great %s!\") \"success\") - -Uses faces in interactive sessions and ANSI codes otherwise." - `(doom-print (format! ,message ,@args))) - -;;;###autoload -(defmacro insert! (&rest args) - "Like `insert', but with the power of `format!'. - -Each argument in ARGS can be a list, as if they were arguments to `format!': -\(MESSAGE [ARGS...]). - -\(fn &rest (MESSAGE . ARGS)...)" - `(insert ,@(cl-loop for arg in args - if (listp arg) - collect `(format! ,@arg) - else collect arg))) - -(defvar doom-print--output-depth 0) -;;;###autoload -(defmacro with-output-to! (streamspec &rest body) - "Capture all output within BODY according to STREAMSPEC. - -STREAMSPEC is a list of log specifications, indicating where to write output -based on the print level of the message. For example: - - `((>= notice ,(get-buffer-create \"*stdout*\")) - (= error ,(get-buffer-create \"*errors*\")) - (t . ,(get-buffer-create \"*debug*\")))" - (declare (indent 1)) - (let ((sym (make-symbol "streamspec"))) - `(letf! ((,sym ,streamspec) - (standard-output (doom-print--redirect-standard-output ,sym t)) - (#'message (doom-print--redirect-message ,sym (if noninteractive 'debug 'notice))) - (doom-print--output-depth (1+ doom-print--output-depth))) - ,@body))) - - -;; -;;; Helpers - -(defun doom-print--redirect-streams (streamspec level) - (if (or (eq streamspec t) - (bufferp streamspec) - (functionp streamspec) - (markerp streamspec)) - (list (cons t streamspec)) - (cl-loop for (car . spec) in streamspec - if (eq car t) - collect (cons t spec) - else - collect (cons (or (eq level t) - (doom-partial - car - (get level 'print-level) - (get (car spec) 'print-level))) - (cadr spec))))) - -(defun doom-print--redirect-standard-output (streamspec level) - (let ((old standard-output) - (streams (doom-print--redirect-streams streamspec level))) - (lambda (ch) - (let ((str (char-to-string ch))) - (dolist (stream streams) - (when (or (eq (car stream) t) - (funcall (car stream))) - (doom-print str :newline nil :stream (cdr stream)))) - (doom-print str :newline nil :stream t :level level))))) - -(defun doom-print--redirect-message (streamspec level) - (let ((old (symbol-function #'message)) - (streams (doom-print--redirect-streams streamspec level))) - (lambda (message &rest args) - (when message - (let ((output (apply #'doom-print--format message args))) - (if (<= doom-print--output-depth 1) - (doom-print output :level level :stream t) - (let ((doom-print--output-depth (1- doom-print--output-depth))) - (funcall old "%s" output))) - (dolist (stream streams) - (when (or (eq (car stream) t) - (funcall (car stream))) - (doom-print output :stream (cdr stream))))) - message)))) - -;;;###autoload -(defun doom-print--format (message &rest args) - (if (or (null message) (string-blank-p message)) - "" - (concat (make-string doom-print-indent 32) - (replace-regexp-in-string - "\n" (concat "\n" (make-string doom-print-indent 32)) - (if args (apply #'format message args) message) - t t)))) - -;;;###autoload -(defun doom-print--indent (text &optional prefix) - "Indent TEXT by WIDTH spaces. If ARGS, format TEXT with them." - (with-temp-buffer - (let ((width - (cond ((null prefix) - doom-print-indent-increment) - ((integerp prefix) - prefix) - ((length (ansi-color-filter-apply (format "%s" prefix))))))) - (insert (format "%s" (or text ""))) - (indent-rigidly (point-min) (point-max) width) - (when (stringp prefix) - (goto-char (point-min)) - (delete-char width) - (insert prefix)) - (buffer-string)))) - -;;;###autoload -(defun doom-print--fill (message &optional column indent) - "Ensure MSG is split into lines no longer than `fill-column'." - (with-temp-buffer - (let* ((fill-column (or column fill-column)) - (col 0) - (indent (or indent 0)) - (fill-prefix (make-string indent ?\s))) - (save-excursion - (insert (format "%s" (or message "")))) - ;; HACK This monkey patches `fill-region' to not count ANSI codes as - ;; legitimate characters, when calculating per-line `fill-column'. - (letf! (defun current-fill-column () - (let ((target (funcall current-fill-column))) - (save-excursion - (goto-char (line-beginning-position)) - (let ((n 0) - (c 0)) - (while (and (not (eolp)) (<= n target)) - (save-match-data - (if (looking-at ansi-color-control-seq-regexp) - (let ((len (length (match-string 0)))) - (cl-incf c len) - (forward-char len)) - (cl-incf n 1) - (forward-char 1)))) - (+ target c (length fill-prefix)))))) - (fill-region (point-min) (point-max) nil t)) - (buffer-string)))) - -;;;###autoload -(defun doom-print--paragraph (&rest lines) - "TODO" - (doom-print--fill (apply #'concat lines))) - -;;;###autoload -(defun doom-print--join (sequence &optional separator) - "Ensure SEQUENCE is joined with SEPARATOR. - -`nil' and empty strings in SEQUENCE are omitted." - (mapconcat (doom-partial #'format "%s") - (seq-remove (fn! (or (null %) - (and (stringp %) - (string-empty-p %)))) - sequence) - (or separator " "))) - -;;;###autoload -(defun doom-print--truncate (text &optional col ellipsis) - "Replaces basic org markup with ansi/text-properties." - (truncate-string-to-width (or text "") (or col (- fill-column doom-print-indent)) - nil nil (or ellipsis "..."))) - -;;;###autoload -(defun doom-print--buffer (buffer &optional beg end) - "Replaces basic org markup with ansi/text-properties." - (if (and (bufferp buffer) (buffer-live-p buffer)) - (with-current-buffer buffer - (if (or beg end) - (buffer-substring (or beg (point-min)) - (or end (point-max))) - (buffer-string))) - "")) - -;;;###autoload -(defun doom-print--cli-markup (text) - "Replace `...', `...`, and ```...``` quotes in TEXT with CLI formatting. - -- `$ENVVAR' = bolded -- `--switch' = bolded -- `ARG' = underlined -- `symbol' = highlighted in blue -- `arbitrary code` = highlighted in blue -- ``` - Arbitrary multiline code gets highlighted in blue too. - ```" - (if (not text) "" - (let ((case-fold-search nil)) - ;; TODO Syntax highlighting? - (replace-regexp-in-string - " *```\n\\(.+?\\)\n *```" (doom-print--style 'blue "%s" "\\1") - (replace-regexp-in-string - "`\\$ \\([^`\n]+?\\)`" (format "`%s`" (doom-print--style 'blue "%s" "\\1")) - (replace-regexp-in-string - "`\\([^ \n]+?\\)'" - (let ((styles '(("^\\$" . envvar) - ("^--?" . option) - ("^[A-Z][A-Z0-9-_]*$" . arg) - ("." . symbol)))) - (lambda (match) - (let ((text (match-string 1 match))) - (pcase (assoc-default text styles #'string-match-p) - (`arg (doom-print--style 'underscore "%s" text)) - (`envvar (doom-print--style 'bold "%s" text)) - (`option (doom-print--style 'bold "%s" text)) - (_ (format "`%s'" (doom-print--style 'blue "%s" text))))))) - text t) - t) - t)))) - -;;;###autoload -(defun doom-print--org (text) - "Replaces basic Org markup with ansi/text-properties. - -All emphasis markers need to be preceded by a backslash." - (let* ((inhibit-modification-hooks t) - (styles '((?* . bold) - (?_ . underscore) - (?/ . italic) - (?= . magenta) - (?+ . strike) - (?~ . blue))) - (fences (regexp-quote (mapconcat #'char-to-string (mapcar #'car styles) "")))) - (with-temp-buffer - (save-excursion (insert text)) - (while (re-search-forward (format "\\([%s]\\)" fences) nil t) - (unless (= (char-before (match-beginning 0)) ?\\) - (let* ((beg (match-beginning 0)) - (ibeg (point)) - (fence (match-string 1)) - (fence-re (regexp-quote fence))) - (when (re-search-forward (format "[^\\]%s" fence-re) (line-end-position 2) t) - (let ((end (point)) - (iend (1- (point)))) - (let ((text (buffer-substring ibeg iend))) - (when-let (style (cdr (assq (string-to-char fence) styles))) - (goto-char beg) - (delete-region beg end) - (insert (doom-print--style style "%s" text))))) - (goto-char beg))))) - (buffer-string)))) - -;;;###autoload -(defun doom-print--style (style format &rest args) - "Apply STYLE to formatted MESSAGE with ARGS. - -STYLE is a symbol that correlates to `doom-print-ansi-alist'. - -In a noninteractive session, this wraps the result in ansi color codes. -Otherwise, it maps colors to a term-color-* face." - (let* ((code (cdr (assq style doom-print-ansi-alist))) - (format (format "%s" (or format ""))) - (message (if args (apply #'format format args) format))) - (unless code - (error "Invalid print style: %s" style)) - (pcase doom-print-backend - (`ansi - (format "\e[0%dm%s\e[%dm" code message 0)) - (`text-properties - (ansi-color-apply message)) - (_ message)))) - -;;;###autoload -(defun doom-print--class (class format &rest args) - "Apply CLASS to formatted format with ARGS. - -CLASS is derived from `doom-print-class-alist', and can contain any arbitrary, -transformative logic." - (let (fn) - (cond ((setq fn (cdr (assq class doom-print-class-alist))) - (if (functionp fn) - (apply fn format args) - (error "%s does not have a function" class))) - (args (apply #'format format args)) - (format)))) - -(defun doom-print--apply (forms &optional sub) - "Replace color-name functions with calls to `doom-print--style'." - (cond ((null forms) nil) - ((listp forms) - (append (cond ((not (symbolp (car forms))) - (list (doom-print--apply (car forms)))) - (sub - (list (car forms))) - ((assq (car forms) doom-print-ansi-alist) - `(doom-print--style ',(car forms))) - ((assq (car forms) doom-print-class-alist) - `(doom-print--class ',(car forms))) - ((list (car forms)))) - (doom-print--apply (cdr forms) t) - nil)) - (forms))) - -(provide 'doom-lib '(print)) -;;; print.el ends here diff --git a/.config/emacs/lisp/lib/process.el b/.config/emacs/lisp/lib/process.el @@ -1,47 +0,0 @@ -;;; lisp/lib/process.el -*- lexical-binding: t; -*- -;;; Commentary: -;;; Code: - -;;;###autoload -(defun doom-call-process (command &rest args) - "Execute COMMAND with ARGS synchronously. - -Returns (STATUS . OUTPUT) when it is done, where STATUS is the returned error -code of the process and OUTPUT is its stdout output." - (with-temp-buffer - (cons (or (apply #'call-process command nil t nil (remq nil args)) - -1) - (string-trim (buffer-string))))) - -;;;###autoload -(defun doom-exec-process (command &rest args) - "Execute COMMAND with ARGS synchronously. - -Unlike `doom-call-process', this pipes output to `standard-output' on the fly to -simulate 'exec' in the shell, so batch scripts could run external programs -synchronously without sacrificing their output. - -Warning: freezes indefinitely on any stdin prompt." - ;; FIXME Is there any way to handle prompts? - (with-temp-buffer - (cons (let ((process - (make-process :name "doom-sh" - :buffer (current-buffer) - :command (cons command (remq nil args)) - :connection-type 'pipe)) - done-p) - (set-process-filter - process (lambda (_process output) - (princ output (current-buffer)) - (princ (doom-print--format output)))) - (set-process-sentinel - process (lambda (process _event) - (when (memq (process-status process) '(exit stop)) - (setq done-p t)))) - (while (not done-p) - (sit-for 0.1)) - (process-exit-status process)) - (string-trim (buffer-string))))) - -(provide 'doom-lib '(process)) -;;; process.el ends here diff --git a/.config/emacs/lisp/lib/projects.el b/.config/emacs/lisp/lib/projects.el @@ -1,180 +0,0 @@ -;;; lisp/lib/projects.el -*- lexical-binding: t; -*- - -;; HACK We forward declare these variables because they are let-bound in a -;; number of places with no guarantee that they've been defined yet (i.e. -;; that `projectile' is loaded). If a variable is defined with `defvar' -;; while it is lexically bound, you get "Defining as dynamic an already -;; lexical var" errors in Emacs 28+). -;;;###autoload (defvar projectile-project-root nil) -;;;###autoload (defvar projectile-enable-caching (not noninteractive)) -;;;###autoload (defvar projectile-require-project-root 'prompt) - -;;;###autodef -(cl-defun set-project-type! (name &key predicate compile run test configure dir) - "Add a project type to `projectile-project-type'." - (declare (indent 1)) - (after! projectile - (add-to-list 'projectile-project-types - (list name - 'marker-files predicate - 'compilation-dir dir - 'configure-command configure - 'compile-command compile - 'test-command test - 'run-command run)))) - - -;; -;;; Macros - -;;;###autoload -(defmacro project-file-exists-p! (files) - "Checks if the project has the specified FILES. -Paths are relative to the project root, unless they start with ./ or ../ (in -which case they're relative to `default-directory'). If they start with a slash, -they are absolute." - `(file-exists-p! ,files (doom-project-root))) - - -;; -;;; Commands - -;;;###autoload -(defun doom/find-file-in-other-project (project-root) - "Performs `projectile-find-file' in a known project of your choosing." - (interactive - (list - (completing-read "Find file in project: " (projectile-relevant-known-projects)))) - (unless (file-directory-p project-root) - (error "Project directory '%s' doesn't exist" project-root)) - (doom-project-find-file project-root)) - -;;;###autoload -(defun doom/browse-in-other-project (project-root) - "Performs `find-file' in a known project of your choosing." - (interactive - (list - (completing-read "Browse in project: " (projectile-relevant-known-projects)))) - (unless (file-directory-p project-root) - (error "Project directory '%s' doesn't exist" project-root)) - (doom-project-browse project-root)) - -;;;###autoload -(defun doom/browse-in-emacsd () - "Browse files from `doom-emacs-dir'." - (interactive) (doom-project-browse doom-emacs-dir)) - -;;;###autoload -(defun doom/find-file-in-emacsd () - "Find a file under `doom-emacs-dir', recursively." - (interactive) (doom-project-find-file doom-emacs-dir)) - -;;;###autoload -(defun doom/add-directory-as-project (dir) - "Register an arbitrary directory as a project. - -Unlike `projectile-add-known-project', if DIR isn't a valid project, a .project -file will be created within it so that it will always be treated as one. This -command will throw an error if a parent of DIR is a valid project (which would -mask DIR)." - (interactive "D") - (let ((short-dir (abbreviate-file-name dir))) - (unless (file-equal-p (doom-project-root dir) dir) - (with-temp-file (doom-path dir ".project"))) - (let ((proj-dir (doom-project-root dir))) - (unless (file-equal-p proj-dir dir) - (user-error "Can't add %S as a project, because %S is already a project" - short-dir (abbreviate-file-name proj-dir))) - (message "%S was not a project; adding .project file to it" - short-dir (abbreviate-file-name proj-dir)) - (projectile-add-known-project dir)))) - - -;; -;;; Library - -;;;###autoload -(defun doom-project-p (&optional dir) - "Return t if DIR (defaults to `default-directory') is a valid project." - (and (doom-project-root dir) - t)) - -;;;###autoload -(defun doom-project-root (&optional dir) - "Return the project root of DIR (defaults to `default-directory'). -Returns nil if not in a project." - (let ((projectile-project-root - (unless dir (bound-and-true-p projectile-project-root))) - projectile-require-project-root) - (projectile-project-root dir))) - -;;;###autoload -(defun doom-project-name (&optional dir) - "Return the name of the current project. - -Returns '-' if not in a valid project." - (if-let (project-root (or (doom-project-root dir) - (if dir (expand-file-name dir)))) - (funcall projectile-project-name-function project-root) - "-")) - -;;;###autoload -(defun doom-project-expand (name &optional dir) - "Expand NAME to project root." - (expand-file-name name (doom-project-root dir))) - -;;;###autoload -(defun doom-project-find-file (dir) - "Jump to a file in DIR (searched recursively). - -If DIR is not a project, it will be indexed (but not cached)." - (unless (file-directory-p dir) - (error "Directory %S does not exist" dir)) - (unless (file-readable-p dir) - (error "Directory %S isn't readable" dir)) - (let* ((default-directory (file-truename dir)) - (projectile-project-root (doom-project-root dir)) - (projectile-enable-caching projectile-enable-caching)) - (cond ((and projectile-project-root (file-equal-p projectile-project-root default-directory)) - (unless (doom-project-p default-directory) - ;; Disable caching if this is not a real project; caching - ;; non-projects easily has the potential to inflate the projectile - ;; cache beyond reason. - (setq projectile-enable-caching nil)) - (call-interactively - ;; Intentionally avoid `helm-projectile-find-file', because it runs - ;; asynchronously, and thus doesn't see the lexical - ;; `default-directory' - (if (doom-module-p :completion 'ivy) - #'counsel-projectile-find-file - #'projectile-find-file))) - ((and (bound-and-true-p vertico-mode) - (fboundp '+vertico/find-file-in)) - (+vertico/find-file-in default-directory)) - ((and (bound-and-true-p ivy-mode) - (fboundp 'counsel-file-jump)) - (call-interactively #'counsel-file-jump)) - ((project-current nil dir) - (project-find-file-in nil nil dir)) - ((and (bound-and-true-p helm-mode) - (fboundp 'helm-find-files)) - (call-interactively #'helm-find-files)) - ((call-interactively #'find-file))))) - -;;;###autoload -(defun doom-project-browse (dir) - "Traverse a file structure starting linearly from DIR." - (let ((default-directory (file-truename (expand-file-name dir)))) - (call-interactively - (cond ((doom-module-p :completion 'ivy) - #'counsel-find-file) - ((doom-module-p :completion 'helm) - #'helm-find-files) - (#'find-file))))) - -;;;###autoload -(defun doom-project-ignored-p (project-root) - "Return non-nil if temporary file or a straight package." - (unless (file-remote-p project-root) - (or (file-in-directory-p project-root temporary-file-directory) - (file-in-directory-p project-root doom-local-dir)))) diff --git a/.config/emacs/lisp/lib/sandbox.el b/.config/emacs/lisp/lib/sandbox.el @@ -1,186 +0,0 @@ -;;; lisp/lib/sandbox.el -*- lexical-binding: t; -*- - -(defvar doom-sandbox-buffer-name "*doom:sandbox*" - "Name of the Doom sandbox buffer.") - -(defvar doom-sandbox-dir - (expand-file-name "doom-sandbox" (temporary-file-directory)) - "TODO") - -(defvar doom-sandbox-preamble - ";; Welcome to the sandbox! -;; -;; This is a test bed for running Emacs Lisp in another instance of Emacs that -;; has varying amounts of Doom loaded: -;; -;; - vanilla Emacs (nothing loaded) \\[doom--run-vanilla-emacs] -;; - vanilla Doom (only Doom core) \\[doom--run-vanilla-doom] -;; - Doom + modules - your private config \\[doom--run-vanilla-doom+] -;; - Doom + modules + your private config \\[doom--run-full-doom] -;; -;; This is done without sacrificing access to installed packages. Use the sandbox -;; to reproduce bugs and determine if Doom is to blame.\n\n" - "TODO") - -(defun doom--sandbox-launch (args forms) - (require 'package) - (require 'restart-emacs) - (let* ((sandbox-file (expand-file-name "init.el" doom-sandbox-dir)) - (args (append args (list "-l" sandbox-file)))) - (delete-directory doom-sandbox-dir 'recursive) - (make-directory doom-sandbox-dir 'parents) - (with-temp-file sandbox-file - (prin1 forms (current-buffer))) - (condition-case-unless-debug e - (cond ((display-graphic-p) - (if (memq system-type '(windows-nt ms-dos)) - (restart-emacs--start-gui-on-windows args) - (restart-emacs--start-gui-using-sh args))) - ((memq system-type '(windows-nt ms-dos)) - (user-error "Cannot start another Emacs from Windows shell.")) - ((suspend-emacs - (format "%s %s -nw; fg" - (shell-quote-argument (restart-emacs--get-emacs-binary)) - (mapconcat #'shell-quote-argument args " "))))) - (error - (delete-directory doom-sandbox-dir 'recursive) - (signal (car e) (cdr e)))))) - - -(defun doom--sandbox-run (&optional mode) - "TODO" - (doom--sandbox-launch - (unless (eq mode 'doom) '("-Q")) - (let ((forms - (read (format "(progn\n%s\n)" - (buffer-substring-no-properties - (point-min) - (point-max)))))) - (if (eq mode 'doom) - forms - `(progn - ;; doom variables - (setq init-file-debug t - doom-emacs-dir ,doom-emacs-dir - doom-cache-dir ,(expand-file-name "cache/" doom-sandbox-dir) - doom-data-dir ,(expand-file-name "data/" doom-sandbox-dir)) - (defun doom--write-to-etc-dir-a (fn &rest args) - (let ((user-emacs-directory doom-data-dir)) - (apply fn args))) - (advice-add #'locate-user-emacs-file :around #'doom--write-to-etc-dir-a) - ;; emacs essential variables - (setq before-init-time (current-time) - after-init-time nil - init-file-debug init-file-debug - noninteractive nil - process-environment (get 'process-environment 'initial-value) - exec-path (get 'exec-path 'initial-value) - load-path ',load-path - user-init-file load-file-name) - ;; package.el - (setq package--init-file-ensured t - package-user-dir ,package-user-dir - package-archives ',package-archives) - ;; (add-hook 'kill-emacs-hook - ;; (lambda () - ;; (delete-file user-init-file) - ;; (when (file-equal-p user-emacs-directory ,doom-sandbox-dir) - ;; (delete-directory user-emacs-directory 'recursive)))) - (with-eval-after-load 'undo-tree - ;; HACK `undo-tree' sometimes throws errors because - ;; `buffer-undo-tree' isn't correctly initialized. - (setq-default buffer-undo-tree (make-undo-tree))) - ;; Then launch as much about Emacs as we can - (defun --run-- () ,forms) - ,(pcase mode - (`doom - '(--run--)) - (`vanilla-doom+ ; Doom core + modules - private config - `(progn - (load-file ,(expand-file-name "doom.el" doom-core-dir)) - (setq doom-modules-dirs (list doom-modules-dir)) - (let ((doom-init-modules-p t)) - (doom-initialize) - (doom-initialize-core-modules)) - (setq doom-modules ',doom-modules) - (maphash (lambda (key plist) - (doom-module-put - (car key) (cdr key) - :path (doom-module-locate-path (car key) (cdr key)))) - doom-modules) - (--run--) - (doom-run-hooks 'doom-before-modules-init-hook) - (maphash (doom-module-loader doom-module-init-file) doom-modules) - (doom-run-hooks 'doom-after-modules-init-hook) - (doom-run-hooks 'doom-before-modules-config-hook) - (maphash (doom-module-loader doom-module-config-file) doom-modules) - (doom-run-hooks 'doom-after-modules-config-hook))) - (`vanilla-doom ; only Doom core - `(progn - (load-file ,(expand-file-name "doom.el" doom-core-dir)) - (let ((doom-init-modules-p t)) - (doom-initialize) - (doom-initialize-core-modules)) - (--run--))) - (`vanilla ; nothing loaded - `(progn - (if (boundp 'comp-deferred-compilation) - ;; REVIEW Remove me after a month - (setq comp-deferred-compilation nil - comp-deferred-compilation-deny-list ',(bound-and-true-p native-comp-async-env-modifier-form) - comp-async-env-modifier-form ',(bound-and-true-p native-comp-async-env-modifier-form) - comp-eln-load-path ',(bound-and-true-p native-comp-eln-load-path)) - (setq native-comp-deferred-compilation nil - native-comp-deferred-compilation-deny-list ',(bound-and-true-p native-comp-async-env-modifier-form) - native-comp-async-env-modifier-form ',(bound-and-true-p native-comp-async-env-modifier-form) - native-comp-eln-load-path ',(bound-and-true-p native-comp-eln-load-path))) - (package-initialize t) - (--run--)))) - ;; Then rerun Emacs' startup hooks to simulate a fresh Emacs session, - ;; because they've already fired. - (fset 'doom-run-hook #',(symbol-function #'doom-run-hook)) - (fset 'doom-run-hooks #',(symbol-function #'doom-run-hooks)) - (fset 'doom-run-all-startup-hooks-h #',(symbol-function #'doom-run-all-startup-hooks-h)) - (doom-run-all-startup-hooks-h)))))) - -(fset 'doom--run-vanilla-emacs (cmd! (doom--sandbox-run 'vanilla))) -(fset 'doom--run-vanilla-doom (cmd! (doom--sandbox-run 'vanilla-doom))) -(fset 'doom--run-vanilla-doom+ (cmd! (doom--sandbox-run 'vanilla-doom+))) -(fset 'doom--run-full-doom (cmd! (doom--sandbox-run 'doom))) - -(defvar doom-sandbox-emacs-lisp-mode-map - (let ((map (make-sparse-keymap))) - (define-key map (kbd "C-c C-c") #'doom--run-vanilla-emacs) - (define-key map (kbd "C-c C-d") #'doom--run-vanilla-doom) - (define-key map (kbd "C-c C-p") #'doom--run-vanilla-doom+) - (define-key map (kbd "C-c C-f") #'doom--run-full-doom) - (define-key map (kbd "C-c C-k") #'kill-current-buffer) - map)) - -(define-derived-mode doom-sandbox-emacs-lisp-mode emacs-lisp-mode "Sandbox Elisp" - "TODO") - -;;;###autoload -(defun doom/sandbox () - "Open the Emacs Lisp sandbox. - -This is a test bed for running Emacs Lisp in another instance of Emacs with -varying amounts of Doom loaded, including: - - a) vanilla Emacs (nothing loaded), - b) vanilla Doom (only Doom core), - c) Doom + modules - your private config or - c) Doom + modules + your private config (a complete Doom session) - -This is done without sacrificing access to installed packages. Use the sandbox -to reproduce bugs and determine if Doom is to blame." - (interactive) - (pop-to-buffer - (with-current-buffer (get-buffer-create doom-sandbox-buffer-name) - (doom-sandbox-emacs-lisp-mode) - (setq-local default-directory doom-emacs-dir) - (and (buffer-live-p (get-buffer doom-sandbox-buffer-name)) - (= (buffer-size) 0) - (insert (substitute-command-keys doom-sandbox-preamble))) - (goto-char (point-max)) - (current-buffer)))) diff --git a/.config/emacs/lisp/lib/scratch.el b/.config/emacs/lisp/lib/scratch.el @@ -1,199 +0,0 @@ -;;; lisp/lib/scratch.el -*- lexical-binding: t; -*- - -(defvar doom-scratch-default-file "__default" - "The default file name for a project-less scratch buffer. - -Will be saved in `doom-scratch-dir'.") - -(defvar doom-scratch-dir (concat doom-data-dir "scratch") - "Where to save persistent scratch buffers.") - -(defvar doom-scratch-initial-major-mode nil - "What major mode to start fresh scratch buffers in. - -Scratch buffers preserve their last major mode, however, so this only affects -the first, fresh scratch buffer you create. This accepts: - - t Inherits the major mode of the last buffer you had selected. - nil Uses `fundamental-mode' - MAJOR-MODE Any major mode symbol") - -(defvar doom-scratch-buffers nil - "A list of active scratch buffers.") - -(defvar doom-scratch-current-project nil - "The name of the project associated with the current scratch buffer.") -(put 'doom-scratch-current-project 'permanent-local t) - -(defvar doom-scratch-buffer-hook () - "The hooks to run after a scratch buffer is created.") - - -(defun doom--load-persistent-scratch-buffer (project-name) - (setq-local doom-scratch-current-project - (or project-name - doom-scratch-default-file)) - (let ((smart-scratch-file - (expand-file-name (concat doom-scratch-current-project ".el") - doom-scratch-dir))) - (make-directory doom-scratch-dir t) - (when (file-readable-p smart-scratch-file) - (message "Reading %s" smart-scratch-file) - (cl-destructuring-bind (content point mode) - (with-temp-buffer - (save-excursion (insert-file-contents smart-scratch-file)) - (read (current-buffer))) - (erase-buffer) - (funcall mode) - (insert content) - (goto-char point) - t)))) - -;;;###autoload -(defun doom-scratch-buffer (&optional dont-restore-p mode directory project-name) - "Return a scratchpad buffer in major MODE." - (let* ((buffer-name (if project-name - (format "*doom:scratch (%s)*" project-name) - "*doom:scratch*")) - (buffer (get-buffer buffer-name))) - (with-current-buffer - (or buffer (get-buffer-create buffer-name)) - (setq default-directory directory) - (setq-local so-long--inhibited t) - (if dont-restore-p - (erase-buffer) - (unless buffer - (doom--load-persistent-scratch-buffer project-name) - (when (and (eq major-mode 'fundamental-mode) - (functionp mode)) - (funcall mode)))) - (cl-pushnew (current-buffer) doom-scratch-buffers) - (add-transient-hook! 'doom-switch-buffer-hook (doom-persist-scratch-buffers-h)) - (add-transient-hook! 'doom-switch-window-hook (doom-persist-scratch-buffers-h)) - (add-hook 'kill-buffer-hook #'doom-persist-scratch-buffer-h nil 'local) - (run-hooks 'doom-scratch-buffer-created-hook) - (current-buffer)))) - - -;; -;;; Persistent scratch buffer - -;;;###autoload -(defun doom-persist-scratch-buffer-h () - "Save the current buffer to `doom-scratch-dir'." - (let ((content (buffer-substring-no-properties (point-min) (point-max))) - (point (point)) - (mode major-mode)) - (with-temp-file - (expand-file-name (concat (or doom-scratch-current-project - doom-scratch-default-file) - ".el") - doom-scratch-dir) - (prin1 (list content - point - mode) - (current-buffer))))) - -;;;###autoload -(defun doom-persist-scratch-buffers-h () - "Save all scratch buffers to `doom-scratch-dir'." - (setq doom-scratch-buffers - (cl-delete-if-not #'buffer-live-p doom-scratch-buffers)) - (dolist (buffer doom-scratch-buffers) - (with-current-buffer buffer - (doom-persist-scratch-buffer-h)))) - -;;;###autoload -(defun doom-persist-scratch-buffers-after-switch-h () - "Kill scratch buffers when they are no longer visible, saving them to disk." - (unless (cl-some #'get-buffer-window doom-scratch-buffers) - (mapc #'kill-buffer doom-scratch-buffers) - (remove-hook 'doom-switch-buffer-hook #'doom-persist-scratch-buffers-after-switch-h))) - -;;;###autoload -(unless noninteractive - (add-hook 'kill-emacs-hook #'doom-persist-scratch-buffers-h)) - - -;; -;;; Commands - -(defvar projectile-enable-caching) -;;;###autoload -(defun doom/open-scratch-buffer (&optional arg project-p same-window-p) - "Pop up a persistent scratch buffer. - -If passed the prefix ARG, do not restore the last scratch buffer. -If PROJECT-P is non-nil, open a persistent scratch buffer associated with the - current project." - (interactive "P") - (let (projectile-enable-caching) - (funcall - (if same-window-p - #'switch-to-buffer - #'pop-to-buffer) - (doom-scratch-buffer - arg - (cond ((eq doom-scratch-initial-major-mode t) - (unless (or buffer-read-only - (derived-mode-p 'special-mode) - (string-match-p "^ ?\\*" (buffer-name))) - major-mode)) - ((null doom-scratch-initial-major-mode) - nil) - ((symbolp doom-scratch-initial-major-mode) - doom-scratch-initial-major-mode)) - default-directory - (when project-p - (doom-project-name)))))) - -;;;###autoload -(defun doom/switch-to-scratch-buffer (&optional arg project-p) - "Like `doom/open-scratch-buffer', but switches to it in the current window. - -If passed the prefix ARG, do not restore the last scratch buffer." - (interactive "P") - (doom/open-scratch-buffer arg project-p 'same-window)) - -;;;###autoload -(defun doom/open-project-scratch-buffer (&optional arg same-window-p) - "Opens the (persistent) project scratch buffer in a popup. - -If passed the prefix ARG, do not restore the last scratch buffer." - (interactive "P") - (doom/open-scratch-buffer arg 'project same-window-p)) - -;;;###autoload -(defun doom/switch-to-project-scratch-buffer (&optional arg) - "Like `doom/open-project-scratch-buffer', but switches to it in the current -window. - -If passed the prefix ARG, do not restore the last scratch buffer." - (interactive "P") - (doom/open-project-scratch-buffer arg 'same-window)) - -;;;###autoload -(defun doom/revert-scratch-buffer () - "Revert scratch buffer to last persistent state." - (interactive) - (unless (string-match-p "^\\*doom:scratch" (buffer-name)) - (user-error "Not in a scratch buffer")) - (when (doom--load-persistent-scratch-buffer doom-scratch-current-project) - (message "Reloaded scratch buffer"))) - -;;;###autoload -(defun doom/delete-persistent-scratch-file (&optional arg) - "Deletes a scratch buffer file in `doom-scratch-dir'. - -If prefix ARG, delete all persistent scratches." - (interactive) - (if arg - (progn - (delete-directory doom-scratch-dir t) - (message "Cleared %S" (abbreviate-file-name doom-scratch-dir))) - (make-directory doom-scratch-dir t) - (let ((file (read-file-name "Delete scratch file > " doom-scratch-dir "scratch"))) - (if (not (file-exists-p file)) - (message "%S does not exist" (abbreviate-file-name file)) - (delete-file file) - (message "Successfully deleted %S" (abbreviate-file-name file)))))) diff --git a/.config/emacs/lisp/lib/sessions.el b/.config/emacs/lisp/lib/sessions.el @@ -1,152 +0,0 @@ -;;; lisp/lib/sessions.el -*- lexical-binding: t; -*- - -(defvar desktop-base-file-name) -(defvar desktop-dirname) -(defvar desktop-restore-eager) -(defvar desktop-file-modtime) - - -;; -;;; Helpers - -;;;###autoload -(defun doom-session-file (&optional name) - "TODO" - (cond ((require 'persp-mode nil t) - (expand-file-name (or name persp-auto-save-fname) persp-save-dir)) - ((require 'desktop nil t) - (if name - (expand-file-name name (file-name-directory (desktop-full-file-name))) - (desktop-full-file-name))) - ((error "No session backend available")))) - -;;;###autoload -(defun doom-save-session (&optional file) - "TODO" - (setq file (expand-file-name (or file (doom-session-file)))) - (cond ((require 'persp-mode nil t) - (unless persp-mode (persp-mode +1)) - (setq persp-auto-save-opt 0) - (persp-save-state-to-file file)) - ((and (require 'frameset nil t) - (require 'restart-emacs nil t)) - (let ((frameset-filter-alist (append '((client . restart-emacs--record-tty-file)) - frameset-filter-alist)) - (desktop-base-file-name (file-name-nondirectory file)) - (desktop-dirname (file-name-directory file)) - (desktop-restore-eager t) - desktop-file-modtime) - (make-directory desktop-dirname t) - ;; Prevents confirmation prompts - (let ((desktop-file-modtime (nth 5 (file-attributes (desktop-full-file-name))))) - (desktop-save desktop-dirname t)))) - ((error "No session backend to save session with")))) - -;;;###autoload -(defun doom-load-session (&optional file) - "TODO" - (setq file (expand-file-name (or file (doom-session-file)))) - (message "Attempting to load %s" file) - (cond ((not (file-readable-p file)) - (message "No session file at %S to read from" file)) - ((require 'persp-mode nil t) - (unless persp-mode - (persp-mode +1)) - (let ((allowed (persp-list-persp-names-in-file file))) - (cl-loop for name being the hash-keys of *persp-hash* - unless (member name allowed) - do (persp-kill name)) - (persp-load-state-from-file file))) - ((and (require 'frameset nil t) - (require 'restart-emacs nil t)) - (restart-emacs--restore-frames-using-desktop file)) - ((error "No session backend to load session with")))) - - -;; -;;; Commands - -;;;###autoload -(defun doom/quickload-session () - "TODO" - (interactive) - (message "Restoring session...") - (doom-load-session) - (message "Session restored. Welcome back.")) - -;;;###autoload -(defun doom/quicksave-session () - "TODO" - (interactive) - (message "Saving session") - (doom-save-session) - (message "Saving session...DONE")) - -;;;###autoload -(defun doom/load-session (file) - "TODO" - (interactive - (let ((session-file (doom-session-file))) - (list (or (read-file-name "Session to restore: " - (file-name-directory session-file) - (file-name-nondirectory session-file) - t) - (user-error "No session selected. Aborting"))))) - (unless file - (error "No session file selected")) - (message "Loading '%s' session" file) - (doom-load-session file) - (message "Session restored. Welcome back.")) - -;;;###autoload -(defun doom/save-session (file) - "TODO" - (interactive - (let ((session-file (doom-session-file))) - (list (or (read-file-name "Save session to: " - (file-name-directory session-file) - (file-name-nondirectory session-file)) - (user-error "No session selected. Aborting"))))) - (unless file - (error "No session file selected")) - (message "Saving '%s' session" file) - (doom-save-session file)) - -;;;###autoload -(defun doom/restart () - "Restart Emacs (and the daemon, if active). - -Unlike `doom/restart-and-restore', does not restart the current session." - (interactive) - (require 'restart-emacs) - (restart-emacs)) - -;;;###autoload -(defun doom/restart-and-restore (&optional debug) - "Restart Emacs (and the daemon, if active). - -If DEBUG (the prefix arg) is given, start the new instance with the --debug -switch." - (interactive "P") - (require 'restart-emacs) - (doom/quicksave-session) - (save-some-buffers nil t) - (letf! ((#'save-buffers-kill-emacs #'kill-emacs) - (confirm-kill-emacs) - (tmpfile (make-temp-file "post-load"))) - ;; HACK `restart-emacs' does not properly escape arguments on Windows (in - ;; `restart-emacs--daemon-on-windows' and - ;; `restart-emacs--start-gui-on-windows'), so don't give it complex - ;; arguments at all. Should be fixed upstream, but restart-emacs seems to - ;; be unmaintained. - (with-temp-file tmpfile - (print `(progn - (when (boundp 'doom-version) - (add-hook 'window-setup-hook #'doom-load-session 100)) - (delete-file ,tmpfile)) - (current-buffer))) - (restart-emacs - (append (if debug (list "--debug-init")) - (when (boundp 'chemacs-current-emacs-profile) - (list "--with-profile" chemacs-current-emacs-profile)) - (list "-l" tmpfile))))) diff --git a/.config/emacs/lisp/lib/store.el b/.config/emacs/lisp/lib/store.el @@ -1,155 +0,0 @@ -;;; lisp/lib/cache.el -*- lexical-binding: t; -*- - -;; This little library abstracts the process of writing arbitrary elisp values -;; to a 2-tiered file store (in `doom-store-dir'/`doom-store-location'). - -(defvar doom-store-dir (concat doom-data-dir "store/") - "Directory to look for and store data accessed through this API.") - -(defvar doom-store-persist-alist () - "An alist of alists, containing lists of variables for the doom cache library -to persist across Emacs sessions.") - -(defvar doom-store-location "default" - "The default location for cache files. This symbol is translated into a file -name under `pcache-directory' (by default a subdirectory under -`doom-store-dir'). One file may contain multiple cache entries.") - -(defvar doom--store-table (make-hash-table :test 'equal)) - -(defun doom-save-persistent-store-h () - "Hook to persist `doom-store's storage when Emacs is killed." - (let (locations) - ;; Persist `doom-store-persist-alist' - (dolist (alist (butlast doom-store-persist-alist 1)) - (cl-loop with location = (car alist) - for var in (cdr alist) - do (doom-store-put var (symbol-value var) nil location 'noflush) - and do (cl-pushnew location locations :test #'equal))) - ;; Clean up expired entries, - (dolist (location (doom-files-in doom-store-dir :relative-to doom-store-dir)) - (maphash (lambda (key val) - (when (doom--store-expired-p key val) - (cl-pushnew location locations :test #'equal) - (doom--store-rem key location 'noflush))) - (doom--store-init location))) - (mapc #'doom--store-flush locations))) -(add-hook 'kill-emacs-hook #'doom-save-persistent-store-h) - - -;; -;;; Library - -;;;###autoload -(defun doom-store-persist (location variables) - "Persist VARIABLES (list of symbols) in LOCATION (symbol). -This populates these variables with cached values, if one exists, and saves them -to file when Emacs quits. This cannot persist buffer-local variables." - (cl-check-type location string) - (dolist (var variables) - (when (doom-store-member-p var location) - (set var (doom-store-get var location)))) - (setf (alist-get location doom-store-persist-alist) - (append variables (alist-get location doom-store-persist-alist)))) - -;;;###autoload -(defun doom-store-desist (location &optional variables) - "Unregisters VARIABLES (list of symbols) in LOCATION (symbol). -Variables to persist are recorded in `doom-store-persist-alist'. Does not affect -the actual variables themselves or their values." - (cl-check-type location string) - (if variables - (setf (alist-get location doom-store-persist-alist) - (cl-set-difference (cdr (assq location doom-store-persist-alist)) - variables)) - (delq! location doom-store-persist-alist 'assoc))) - -(defun doom--store-init (&optional location) - (cl-check-type location (or null string)) - (let ((location (or location doom-store-location))) - (or (gethash location doom--store-table) - (let* ((file-name-handler-alist nil) - (location-path (expand-file-name location doom-store-dir))) - (if (file-exists-p location-path) - (puthash location - (with-temp-buffer - (set-buffer-multibyte nil) - (setq buffer-file-coding-system 'binary) - (insert-file-contents-literally location-path) - (read (current-buffer))) - doom--store-table) - (puthash location (make-hash-table :test 'equal) - doom--store-table)))))) - -(defun doom--store-expired-p (key data) - (let ((ttl (car data))) - (cond ((functionp ttl) - (not (funcall ttl key data))) - ((consp ttl) - (time-less-p ttl (current-time)))))) - -(defun doom--store-flush (location) - "Write `doom--store-table' to `doom-store-dir'." - (let ((file-name-handler-alist nil) - (coding-system-for-write 'binary) - (write-region-annotate-functions nil) - (write-region-post-annotation-function nil)) - (let* ((location (or location doom-store-location)) - (data (doom--store-init location))) - (make-directory doom-store-dir 'parents) - (with-temp-file (expand-file-name location doom-store-dir) - (prin1 data (current-buffer))) - data))) - - -;;;###autoload -(defun doom-store-get (key &optional location default-value noflush) - "Retrieve KEY from LOCATION (defaults to `doom-store-location'). -If it doesn't exist or has expired, DEFAULT_VALUE is returned." - (let ((data (gethash key (doom--store-init location) default-value))) - (if (not (or (eq data default-value) - (doom--store-expired-p key data))) - (cdr data) - (doom-store-rem key location noflush) - default-value))) - -;;;###autoload -(defun doom-store-put (key value &optional ttl location noflush) - "Set KEY to VALUE in the store at LOCATION. -KEY can be any lisp object that is comparable with `equal'. TTL is the duration -(in seconds) after which this cache entry expires; if nil, no cache expiration. -LOCATION is the super-key to store this cache item under. It defaults to -`doom-store-location'." - (cl-check-type ttl (or null integer function)) - (puthash key (cons (if (integerp ttl) - (time-add (current-time) ttl) - ttl) - value) - (doom--store-init location)) - (unless noflush - (doom--store-flush location))) - -;;;###autoload -(defun doom-store-rem (key &optional location noflush) - "Clear a cache LOCATION (defaults to `doom-store-location')." - (remhash key (doom--store-init location)) - (unless noflush - (doom--store-flush location))) - -;;;###autoload -(defun doom-store-member-p (key &optional location) - "Return t if KEY in LOCATION exists. -LOCATION defaults to `doom-store-location'." - (let ((nil-value (format "--nilvalue%s--" (current-time)))) - (not (equal (doom-store-get key location nil-value) - nil-value)))) - -;;;###autoload -(defun doom-store-clear (&optional location) - "Clear the store at LOCATION (defaults to `doom-store-location')." - (let* ((location (or location doom-store-location)) - (path (expand-file-name location doom-store-dir))) - (remhash location doom--store-table) - (when (file-exists-p path) - (delete-file path) - t))) diff --git a/.config/emacs/lisp/lib/system.el b/.config/emacs/lisp/lib/system.el @@ -1,113 +0,0 @@ -;;; lisp/lib/system.el -*- lexical-binding: t; -*- - -;;;###autoload -(defun doom-system-distro () - "Return a symbol representing the installed distro." - (with-memoization (get 'doom-system-distro 'cached-value) - (cond (IS-WINDOWS 'windows) - (IS-MAC 'macos) - ((ignore-errors - (with-file-contents! "/etc/os-release" - (when (re-search-forward "^ID=\"?\\([^\"\n]+\\)\"?" nil t) - (intern (downcase (match-string 1))))))) - ;; A few redundancies in case os-release fails us - ((file-exists-p "/etc/debian_version") - 'debian) - ((executable-find "nixos-version") - 'nixos) - ((and (or (file-exists-p "/etc/config.scm") - (file-directory-p "/run/current-system")) - (executable-find "guix")) - 'guix) - ('linux)))) - -;;;###autoload -(defun doom-system-distro-version () - "Return a distro name and version string." - (letf! (defun sh (&rest args) (cdr (apply #'doom-call-process args))) - (let ((distro (doom-system-distro))) - (cond - ((eq distro 'windows) - (format "Windows %s" "Unknown")) ; TODO - ((eq distro 'macos) - (format "MacOS %s" (sh "sw_vers" "-productVersion"))) - ((executable-find "lsb_release") - (sh "lsb_release" "-s" "-d")) - ((executable-find "nixos-version") - (format "NixOS %s" (sh "nixos-version"))) - ((ignore-errors - (with-file-contents! "/etc/os-release" - (when (re-search-forward "^PRETTY_NAME=\"?\\([^\"\n]+\\)\"?" nil t) - (match-string 1))))) - ((when-let (files (doom-glob "/etc/*-release")) - (truncate-string-to-width - (replace-regexp-in-string - "\n" " " (doom-file-read (car files) :end 73) nil t) - 64 nil nil "..."))) - ((concat "Unknown " (sh "uname" "-v"))))))) - -;;;###autoload -(defun doom-system-distro-icon () - "Display icon for the installed distro." - (with-memoization (get 'doom-system-distro-icon 'cached-value) - (propertize - (pcase (doom-system-distro) - (`windows (all-the-icons-faicon "windows")) - (`macos (all-the-icons-faicon "apple")) - (`arch "\uF303") - (`debian "\uF306") - (`raspbian "\uF315") - (`ubuntu "\uF31b") - (`elementary "\uF309") - (`fedora "\uF30a") - (`coreos "\uF305") - (`gentoo "\uF30d") - (`mageia "\uF310") - (`centos "\uF304") - ((or `opensuse `tumbleweed) "\uF314") - (`sabayon "\uF317") - (`slackware "\uF319") - (`linuxmint "\uF30e") - (`alpine "\uF300") - (`aosc "\uF301") - (`nixos "\uF313") - (`devuan "\uF307") - (`manjaro "\uF312") - ((or `void `artix) "\uF17c") - (_ (all-the-icons-faicon "linux"))) - 'face '(:height 1) - 'display '(raise 0)))) - -;;;###autoload -(defun doom-system-cpus () - "Return the max number of processing units on this system. -Tries to be portable. Returns 1 if cannot be determined." - (with-memoization (get 'doom-system-cpus 'cached-value) - (if (fboundp 'num-processors) - (num-processors) ; added in Emacs 28.1 - (let ((cpus - (cond ((fboundp 'w32-get-nproc) - (w32-get-nproc)) - ((getenv "NUMBER_OF_PROCESSORS")) - ((executable-find "nproc") - (doom-call-process "nproc")) - ((executable-find "sysctl") - (doom-call-process "sysctl" "-n" "hw.ncpu"))))) - (max - 1 (or (cl-typecase cpus - (integer cpus) - (string - (condition-case _ - (string-to-number cpus) - (wrong-type-argument - (user-error "NUMBER_OF_PROCESSORS contains an invalid value: %S" - cpus)))) - (cons - (if (zerop (car cpus)) - (string-to-number (cdr cpus)) - (user-error "Failed to look up number of processors, because:\n\n%s" - (cdr cpus))))) - 1)))))) - -(provide 'doom-lib '(system)) -;;; system.el ends here diff --git a/.config/emacs/lisp/lib/text.el b/.config/emacs/lisp/lib/text.el @@ -1,350 +0,0 @@ -;;; lisp/lib/text.el -*- lexical-binding: t; -*- - -;;;###autoload -(defvar doom-point-in-comment-functions () - "List of functions to run to determine if point is in a comment. - -Each function takes one argument: the position of the point. Stops on the first -function to return non-nil. Used by `doom-point-in-comment-p'.") - -;;;###autoload -(defvar doom-point-in-string-functions () - "List of functions to run to determine if point is in a string. - -Each function takes one argument: the position of the point. Stops on the first -function to return non-nil. Used by `doom-point-in-string-p'.") - -;;;###autoload -(defun doom-surrounded-p (pair &optional inline balanced) - "Returns t if point is surrounded by a brace delimiter: {[( - -If INLINE is non-nil, only returns t if braces are on the same line, and -whitespace is balanced on either side of the cursor. - -If INLINE is nil, returns t if the opening and closing braces are on adjacent -lines, above and below, with only whitespace in between." - (when pair - (let ((beg (plist-get pair :beg)) - (end (plist-get pair :end)) - (pt (point))) - (when (and (> pt beg) (< pt end)) - (when-let* ((cl (plist-get pair :cl)) - (op (plist-get pair :op))) - (and (not (string= op "")) - (not (string= cl "")) - (let ((nbeg (+ (length op) beg)) - (nend (- end (length cl)))) - (let ((content (buffer-substring-no-properties nbeg nend))) - (and (string-match-p (format "[ %s]*" (if inline "" "\n")) content) - (or (not balanced) - (= (- pt nbeg) (- nend pt)))))))))))) - -;;;###autoload -(defun doom-point-in-comment-p (&optional pos) - "Return non-nil if POS is in a comment. -POS defaults to the current position." - (let ((pos (or pos (point)))) - (if doom-point-in-comment-functions - (run-hook-with-args-until-success 'doom-point-in-comment-functions pos) - (nth 4 (syntax-ppss pos))))) - -;;;###autoload -(defun doom-point-in-string-p (&optional pos) - "Return non-nil if POS is in a string." - ;; REVIEW Should we cache `syntax-ppss'? - (let ((pos (or pos (point)))) - (if doom-point-in-string-functions - (run-hook-with-args-until-success 'doom-point-in-string-functions pos) - (nth 3 (syntax-ppss pos))))) - -;;;###autoload -(defun doom-point-in-string-or-comment-p (&optional pos) - "Return non-nil if POS is in a string or comment." - (or (doom-point-in-string-p pos) - (doom-point-in-comment-p pos))) - -;;;###autoload -(defun doom-region-active-p () - "Return non-nil if selection is active. -Detects evil visual mode as well." - (declare (side-effect-free t)) - (or (use-region-p) - (and (bound-and-true-p evil-local-mode) - (evil-visual-state-p)))) - -;;;###autoload -(defun doom-region-beginning () - "Return beginning position of selection. -Uses `evil-visual-beginning' if available." - (declare (side-effect-free t)) - (or (and (bound-and-true-p evil-local-mode) - (markerp evil-visual-beginning) - (marker-position evil-visual-beginning)) - (region-beginning))) - -;;;###autoload -(defun doom-region-end () - "Return end position of selection. -Uses `evil-visual-end' if available." - (declare (side-effect-free t)) - (if (bound-and-true-p evil-local-mode) - evil-visual-end - (region-end))) - -;;;###autoload -(defun doom-thing-at-point-or-region (&optional thing prompt) - "Grab the current selection, THING at point, or xref identifier at point. - -Returns THING if it is a string. Otherwise, if nothing is found at point and -PROMPT is non-nil, prompt for a string (if PROMPT is a string it'll be used as -the prompting string). Returns nil if all else fails. - -NOTE: Don't use THING for grabbing symbol-at-point. The xref fallback is smarter -in some cases." - (declare (side-effect-free t)) - (cond ((stringp thing) - thing) - ((doom-region-active-p) - (buffer-substring-no-properties - (doom-region-beginning) - (doom-region-end))) - (thing - (thing-at-point thing t)) - ((require 'xref nil t) - ;; Eglot, nox (a fork of eglot), and elpy implementations for - ;; `xref-backend-identifier-at-point' betray the documented purpose of - ;; the interface. Eglot/nox return a hardcoded string and elpy prepends - ;; the line number to the symbol. - (if (memq (xref-find-backend) '(eglot elpy nox)) - (thing-at-point 'symbol t) - ;; A little smarter than using `symbol-at-point', though in most - ;; cases, xref ends up using `symbol-at-point' anyway. - (xref-backend-identifier-at-point (xref-find-backend)))) - (prompt - (read-string (if (stringp prompt) prompt ""))))) - - -;; -;;; Commands - -(defun doom--bol-bot-eot-eol (&optional pos) - (save-mark-and-excursion - (when pos - (goto-char pos)) - (let* ((bol (if visual-line-mode - (save-excursion - (beginning-of-visual-line) - (point)) - (line-beginning-position))) - (bot (save-excursion - (goto-char bol) - (skip-chars-forward " \t\r") - (point))) - (eol (if visual-line-mode - (save-excursion (end-of-visual-line) (point)) - (line-end-position))) - (eot (or (save-excursion - (if (not comment-use-syntax) - (progn - (goto-char bol) - (when (re-search-forward comment-start-skip eol t) - (or (match-end 1) (match-beginning 0)))) - (goto-char eol) - (while (and (doom-point-in-comment-p) - (> (point) bol)) - (backward-char)) - (skip-chars-backward " " bol) - (or (eq (char-after) 32) - (eolp) - (bolp) - (forward-char)) - (point))) - eol))) - (list bol bot eot eol)))) - -(defvar doom--last-backward-pt nil) -;;;###autoload -(defun doom/backward-to-bol-or-indent (&optional point) - "Jump between the indentation column (first non-whitespace character) and the -beginning of the line. The opposite of -`doom/forward-to-last-non-comment-or-eol'." - (interactive "^d") - (let ((pt (or point (point)))) - (cl-destructuring-bind (bol bot _eot _eol) - (doom--bol-bot-eot-eol pt) - (cond ((> pt bot) - (goto-char bot)) - ((= pt bol) - (or (and doom--last-backward-pt - (= (line-number-at-pos doom--last-backward-pt) - (line-number-at-pos pt))) - (setq doom--last-backward-pt nil)) - (goto-char (or doom--last-backward-pt bot)) - (setq doom--last-backward-pt nil)) - ((<= pt bot) - (setq doom--last-backward-pt pt) - (goto-char bol)))))) - -(defvar doom--last-forward-pt nil) -;;;###autoload -(defun doom/forward-to-last-non-comment-or-eol (&optional point) - "Jumps between the last non-blank, non-comment character in the line and the -true end of the line. The opposite of `doom/backward-to-bol-or-indent'." - (interactive "^d") - (let ((pt (or point (point)))) - (cl-destructuring-bind (_bol _bot eot eol) - (doom--bol-bot-eot-eol pt) - (cond ((< pt eot) - (goto-char eot)) - ((= pt eol) - (goto-char (or doom--last-forward-pt eot)) - (setq doom--last-forward-pt nil)) - ((>= pt eot) - (setq doom--last-backward-pt pt) - (goto-char eol)))))) - -;;;###autoload -(defun doom/backward-kill-to-bol-and-indent () - "Kill line to the first non-blank character. If invoked again afterwards, kill -line to beginning of line. Same as `evil-delete-back-to-indentation'." - (interactive) - (let ((empty-line-p (save-excursion (beginning-of-line) - (looking-at-p "[ \t]*$")))) - (funcall (if (fboundp 'evil-delete) - #'evil-delete - #'delete-region) - (point-at-bol) (point)) - (unless empty-line-p - (indent-according-to-mode)))) - -;;;###autoload -(defun doom/delete-backward-word (arg) - "Like `backward-kill-word', but doesn't affect the kill-ring." - (interactive "p") - (let ((kill-ring nil) (kill-ring-yank-pointer nil)) - (ignore-errors (backward-kill-word arg)))) - -;;;###autoload -(defun doom/dumb-indent () - "Inserts a tab character (or spaces x tab-width)." - (interactive) - (if indent-tabs-mode - (insert "\t") - (let* ((movement (% (current-column) tab-width)) - (spaces (if (= 0 movement) tab-width (- tab-width movement)))) - (insert (make-string spaces ? ))))) - -;;;###autoload -(defun doom/dumb-dedent () - "Dedents the current line." - (interactive) - (if indent-tabs-mode - (call-interactively #'backward-delete-char) - (unless (bolp) - (save-excursion - (when (> (current-column) (current-indentation)) - (back-to-indentation)) - (let ((movement (% (current-column) tab-width))) - (delete-char - (- (if (= 0 movement) - tab-width - (- tab-width movement))))))))) - -;;;###autoload -(defun doom/retab (arg &optional beg end) - "Converts tabs-to-spaces or spaces-to-tabs within BEG and END (defaults to -buffer start and end, to make indentation consistent. Which it does depends on -the value of `indent-tab-mode'. - -If ARG (universal argument) is non-nil, retab the current buffer using the -opposite indentation style." - (interactive "P\nr") - (unless (and beg end) - (setq beg (point-min) - end (point-max))) - (let ((indent-tabs-mode (if arg (not indent-tabs-mode) indent-tabs-mode))) - (if indent-tabs-mode - (tabify beg end) - (untabify beg end)))) - -;;;###autoload -(defun doom/delete-trailing-newlines () - "Trim trailing newlines. - -Respects `require-final-newline'." - (interactive) - (save-excursion - (goto-char (point-max)) - (delete-blank-lines))) - -;;;###autoload -(defun doom/dos2unix () - "Convert the current buffer to a Unix file encoding." - (interactive) - (set-buffer-file-coding-system 'undecided-unix nil)) - -;;;###autoload -(defun doom/unix2dos () - "Convert the current buffer to a DOS file encoding." - (interactive) - (set-buffer-file-coding-system 'undecided-dos nil)) - -;;;###autoload -(defun doom/toggle-indent-style () - "Switch between tabs and spaces indentation style in the current buffer." - (interactive) - (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 size to WIDTH of the current buffer. - -The effectiveness of this command is significantly improved if you have -editorconfig or dtrt-indent installed." - (interactive - (list (if (integerp current-prefix-arg) - current-prefix-arg - (read-number "New indent size: ")))) - (setq tab-width width) - (setq-local standard-indent width) - (when (boundp 'evil-shift-width) - (setq evil-shift-width width)) - (cond ((require 'editorconfig nil t) - (let (editorconfig-lisp-use-default-indent) - (editorconfig-set-indentation nil width))) - ((require 'dtrt-indent nil t) - (when-let (vars (nth 2 (assq major-mode dtrt-indent-hook-mapping-list))) - (dolist (var (ensure-list vars)) - (doom-log "Updated %s = %d" var width) - (set var width))))) - (message "Changed indentation to %d" width)) - - -;; -;;; Hooks - -;;;###autoload -(defun doom-enable-delete-trailing-whitespace-h () - "Enables the automatic deletion of trailing whitespaces upon file save. - -i.e. enables `ws-butler-mode' in the current buffer." - (ws-butler-mode +1)) - -;;;###autoload -(defun doom-disable-delete-trailing-whitespace-h () - "Disables the automatic deletion of trailing whitespaces upon file save. - -i.e. disables `ws-butler-mode' in the current buffer." - (ws-butler-mode -1)) - -;;;###autoload -(defun doom-enable-show-trailing-whitespace-h () - "Enable `show-trailing-whitespace' in the current buffer." - (setq-local show-trailing-whitespace t)) - -;;;###autoload -(defun doom-disable-show-trailing-whitespace-h () - "Disable `show-trailing-whitespace' in the current buffer." - (setq-local show-trailing-whitespace nil)) diff --git a/.config/emacs/lisp/lib/themes.el b/.config/emacs/lisp/lib/themes.el @@ -1,109 +0,0 @@ -;;; lisp/lib/themes.el -*- lexical-binding: t; -*- - -;;;###autoload -(defconst doom-customize-theme-hook nil) - -(add-hook! 'doom-load-theme-hook - (defun doom-apply-customized-faces-h () - "Run `doom-customize-theme-hook'." - (run-hooks 'doom-customize-theme-hook))) - -(defun doom--custom-theme-set-face (spec) - (cond ((listp (car spec)) - (cl-loop for face in (car spec) - collect - (car (doom--custom-theme-set-face (cons face (cdr spec)))))) - ((keywordp (cadr spec)) - `((,(car spec) ((t ,(cdr spec)))))) - (`((,(car spec) ,(cdr spec)))))) - -;;;###autoload -(defmacro custom-theme-set-faces! (theme &rest specs) - "Apply a list of face SPECS as user customizations for THEME. - -THEME can be a single symbol or list thereof. If nil, apply these settings to -all themes. It will apply to all themes once they are loaded." - (declare (indent defun)) - (let ((fn (gensym "doom--customize-themes-h-"))) - `(progn - (defun ,fn () - (let (custom--inhibit-theme-enable) - (dolist (theme (ensure-list (or ,theme 'user))) - (when (or (eq theme 'user) - (custom-theme-enabled-p theme)) - (apply #'custom-theme-set-faces theme - (mapcan #'doom--custom-theme-set-face - (list ,@specs))))))) - ;; Apply the changes immediately if the user is using the default theme - ;; or the theme has already loaded. This allows you to evaluate these - ;; macros on the fly and customize your faces iteratively. - (when (or (get 'doom-theme 'previous-themes) - (null doom-theme)) - (funcall #',fn)) - ;; FIXME Prevent clobbering this on-the-fly - (add-hook 'doom-customize-theme-hook #',fn 100)))) - -;;;###autoload -(defmacro custom-set-faces! (&rest specs) - "Apply a list of face SPECS as user customizations. - -This is a convenience macro alternative to `custom-set-face' which allows for a -simplified face format, and takes care of load order issues, so you can use -doom-themes' API without worry." - (declare (indent defun)) - `(custom-theme-set-faces! 'user ,@specs)) - -;;;###autoload -(defun doom/reload-theme () - "Reload the current Emacs theme." - (interactive) - (unless doom-theme - (user-error "No theme is active")) - (let ((themes (copy-sequence custom-enabled-themes))) - (mapc #'disable-theme custom-enabled-themes) - (let (doom-load-theme-hook) - (mapc #'enable-theme (reverse themes))) - (doom-run-hooks 'doom-load-theme-hook) - (doom/reload-font) - (message "%s %s" - (propertize - (format "Reloaded %d theme%s:" - (length themes) - (if (cdr themes) "s" "")) - 'face 'bold) - (mapconcat #'prin1-to-string themes ", ")))) - - -;; -;;; Helpers - -;;;###autoload -(defun doom-theme-face-attribute (theme face attribute &optional recursive) - "Read a FACE's ATTRIBUTE for a loaded THEME. - -This is different from `face-attribute', which reads the attribute of an active -face for the current theme, but an active theme can change (or fail to load) in -non-interactive or frame-less sessions." - (let* ((spec - (cl-loop for (type f _ spec) in (get theme 'theme-settings) - if (and (eq type 'theme-face) (eq face f)) - return spec)) - (spec - (letf! ((defun window-system (_frame) 'x) - (defun display-color-cells (_frame) 257) - (defun frame-parameter (frame parameter) - (pcase parameter - (`display-type 'color) - (`background-mode 'dark) - (_ (funcall frame-parameter frame parameter)))) - (#'display-supports-face-attributes-p #'always)) - (face-spec-choose spec))) - (inherit (if recursive (plist-get spec :inherit))) - (value (if (plist-member spec attribute) - (plist-get spec attribute) - 'unspecified))) - (when (and inherit (not (eq inherit 'unspecified))) - (letf! (defun face-attribute (face attribute &optional _frame inherit) - (doom-theme-face-attribute theme face attribute inherit)) - (setq value (face-attribute-merged-with attribute value inherit)))) - value)) diff --git a/.config/emacs/lisp/lib/ui.el b/.config/emacs/lisp/lib/ui.el @@ -1,246 +0,0 @@ -;;; lisp/lib/ui.el -*- lexical-binding: t; -*- - -;; -;;; Public library - -;;;###autoload -(defun doom-resize-window (window new-size &optional horizontal force-p) - "Resize a window to NEW-SIZE. If HORIZONTAL, do it width-wise. -If FORCE-P is omitted when `window-size-fixed' is non-nil, resizing will fail." - (with-selected-window (or window (selected-window)) - (let ((window-size-fixed (unless force-p window-size-fixed))) - (enlarge-window (- new-size (if horizontal (window-width) (window-height))) - horizontal)))) - -;;;###autoload -(defun doom-quit-p (&optional prompt) - "Prompt the user for confirmation when killing Emacs. - -Returns t if it is safe to kill this session. Does not prompt if no real buffers -are open." - (or (not (ignore-errors (doom-real-buffer-list))) - (yes-or-no-p (format "%s" (or prompt "Really quit Emacs?"))) - (ignore (message "Aborted")))) - - -;; -;;; Advice - -;;;###autoload -(defun doom-recenter-a (&rest _) - "Generic advice for recentering window (typically :after other functions)." - (recenter)) - -;;;###autoload -(defun doom-preserve-window-position-a (fn &rest args) - "Generic advice for preserving cursor position on screen after scrolling." - (let ((row (cdr (posn-col-row (posn-at-point))))) - (prog1 (apply fn args) - (save-excursion - (let ((target-row (- (line-number-at-pos) row))) - (unless (< target-row 0) - (evil-scroll-line-to-top target-row))))))) - -;;;###autoload -(defun doom-shut-up-a (fn &rest args) - "Generic advisor for silencing noisy functions. - -In interactive Emacs, this just inhibits messages from appearing in the -minibuffer. They are still logged to *Messages*. - -In tty Emacs, messages are suppressed completely." - (quiet! (apply fn args))) - - -;; -;;; Hooks - -;;;###autoload -(defun doom-apply-ansi-color-to-compilation-buffer-h () - "Applies ansi codes to the compilation buffers. Meant for -`compilation-filter-hook'." - (with-silent-modifications - (ansi-color-apply-on-region compilation-filter-start (point)))) - -;;;###autoload -(defun doom-disable-show-paren-mode-h () - "Turn off `show-paren-mode' buffer-locally." - (setq-local show-paren-mode nil)) - -;;;###autoload -(defun doom-enable-line-numbers-h () - (display-line-numbers-mode +1)) - -;;;###autoload -(defun doom-disable-line-numbers-h () - (display-line-numbers-mode -1)) - - -;; -;;; Commands - -;;;###autoload -(defun doom/toggle-line-numbers () - "Toggle line numbers. - -Cycles through regular, relative and no line numbers. The order depends on what -`display-line-numbers-type' is set to. If you're using Emacs 26+, and -visual-line-mode is on, this skips relative and uses visual instead. - -See `display-line-numbers' for what these values mean." - (interactive) - (defvar doom--line-number-style display-line-numbers-type) - (let* ((styles `(t ,(if visual-line-mode 'visual 'relative) nil)) - (order (cons display-line-numbers-type (remq display-line-numbers-type styles))) - (queue (memq doom--line-number-style order)) - (next (if (= (length queue) 1) - (car order) - (car (cdr queue))))) - (setq doom--line-number-style next) - (setq display-line-numbers next) - (message "Switched to %s line numbers" - (pcase next - (`t "normal") - (`nil "disabled") - (_ (symbol-name next)))))) - -;;;###autoload -(defun doom/delete-frame-with-prompt () - "Delete the current frame, but ask for confirmation if it isn't empty." - (interactive) - (if (cdr (frame-list)) - (when (doom-quit-p "Close frame?") - (delete-frame)) - (save-buffers-kill-emacs))) - - -(defun doom--enlargened-forget-last-wconf-h () - (set-frame-parameter nil 'doom--maximize-last-wconf nil) - (set-frame-parameter nil 'doom--enlargen-last-wconf nil) - (remove-hook 'doom-switch-window-hook #'doom--enlargened-forget-last-wconf-h)) - -;;;###autoload -(defun doom/window-maximize-buffer (&optional arg) - "Close other windows to focus on this one. -Use `winner-undo' to undo this. Alternatively, use `doom/window-enlargen'." - (interactive "P") - (when (and (bound-and-true-p +popup-mode) - (+popup-window-p)) - (+popup/raise (selected-window))) - (delete-other-windows)) - -;;;###autoload -(defun doom/window-enlargen (&optional arg) - "Enlargen the current window (i.e. shrinks others) so you can focus on it. -Use `winner-undo' to undo this. Alternatively, use -`doom/window-maximize-buffer'." - (interactive "P") - (let* ((window (selected-window)) - (dedicated-p (window-dedicated-p window)) - (preserved-p (window-parameter window 'window-preserved-size)) - (ignore-window-parameters t) - (window-resize-pixelwise nil) - (frame-resize-pixelwise nil)) - (unwind-protect - (progn - (when dedicated-p - (set-window-dedicated-p window nil)) - (when preserved-p - (set-window-parameter window 'window-preserved-size nil)) - (maximize-window window)) - (set-window-dedicated-p window dedicated-p) - (when preserved-p - (set-window-parameter window 'window-preserved-size preserved-p))))) - -;;;###autoload -(defun doom/window-maximize-horizontally () - "Delete all windows to the left and right of the current window." - (interactive) - (require 'windmove) - (save-excursion - (while (ignore-errors (windmove-left)) (delete-window)) - (while (ignore-errors (windmove-right)) (delete-window)))) - -;;;###autoload -(defun doom/window-maximize-vertically () - "Delete all windows above and below the current window." - (interactive) - (require 'windmove) - (save-excursion - (while (ignore-errors (windmove-up)) (delete-window)) - (while (ignore-errors (windmove-down)) (delete-window)))) - -;;;###autoload -(defun doom/set-frame-opacity (opacity) - "Interactively change the current frame's opacity. - -OPACITY is an integer between 0 to 100, inclusive." - (interactive - (list (read-number "Opacity (0-100): " - (or (frame-parameter nil 'alpha) - 100)))) - (set-frame-parameter nil 'alpha opacity)) - -(defvar doom--narrowed-base-buffer nil) -;;;###autoload -(defun doom/narrow-buffer-indirectly (beg end) - "Restrict editing in this buffer to the current region, indirectly. - -This recursively creates indirect clones of the current buffer so that the -narrowing doesn't affect other windows displaying the same buffer. Call -`doom/widen-indirectly-narrowed-buffer' to undo it (incrementally). - -Inspired from http://demonastery.org/2013/04/emacs-evil-narrow-region/" - (interactive - (list (or (bound-and-true-p evil-visual-beginning) (region-beginning)) - (or (bound-and-true-p evil-visual-end) (region-end)))) - (unless (region-active-p) - (setq beg (line-beginning-position) - end (line-end-position))) - (deactivate-mark) - (let ((orig-buffer (current-buffer))) - (with-current-buffer (switch-to-buffer (clone-indirect-buffer nil nil)) - (narrow-to-region beg end) - (setq-local doom--narrowed-base-buffer orig-buffer)))) - -;;;###autoload -(defun doom/widen-indirectly-narrowed-buffer (&optional arg) - "Widens narrowed buffers. - -This command will incrementally kill indirect buffers (under the assumption they -were created by `doom/narrow-buffer-indirectly') and switch to their base -buffer. - -If ARG, then kill all indirect buffers, return the base buffer and widen it. - -If the current buffer is not an indirect buffer, it is `widen'ed." - (interactive "P") - (unless (buffer-narrowed-p) - (user-error "Buffer isn't narrowed")) - (let ((orig-buffer (current-buffer)) - (base-buffer doom--narrowed-base-buffer)) - (cond ((or (not base-buffer) - (not (buffer-live-p base-buffer))) - (widen)) - (arg - (let ((buffer orig-buffer) - (buffers-to-kill (list orig-buffer))) - (while (setq buffer (buffer-local-value 'doom--narrowed-base-buffer buffer)) - (push buffer buffers-to-kill)) - (switch-to-buffer (buffer-base-buffer)) - (mapc #'kill-buffer (remove (current-buffer) buffers-to-kill)))) - ((switch-to-buffer base-buffer) - (kill-buffer orig-buffer))))) - -;;;###autoload -(defun doom/toggle-narrow-buffer (beg end) - "Narrow the buffer to BEG END. If narrowed, widen it." - (interactive - (list (or (bound-and-true-p evil-visual-beginning) (region-beginning)) - (or (bound-and-true-p evil-visual-end) (region-end)))) - (if (buffer-narrowed-p) - (widen) - (unless (region-active-p) - (setq beg (line-beginning-position) - end (line-end-position))) - (narrow-to-region beg end))) diff --git a/.config/emacs/lisp/packages.el b/.config/emacs/lisp/packages.el @@ -1,51 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lisp/packages.el - -;; doom.el -(package! auto-minor-mode :pin "17cfa1b54800fdef2975c0c0531dad34846a5065") -(package! gcmh :pin "0089f9c3a6d4e9a310d0791cf6fa8f35642ecfd9") -(package! explain-pause-mode - :recipe (:host github - :repo "lastquestion/explain-pause-mode") - :pin "2356c8c3639cbeeb9751744dbe737267849b4b51") - -;; doom-packages.el -(package! straight - :type 'core - :recipe `(:host github - :repo "radian-software/straight.el" - :branch ,straight-repository-branch - :local-repo "straight.el" - :files ("straight*.el")) - :pin "56a8b6c8a46fb78655d512402ad7840d85167225") - -;; doom-ui.el -(package! all-the-icons :pin "51bf77da1ebc3c199dfc11f54c0dce67559f5f40") -(package! hide-mode-line :pin "bc5d293576c5e08c29e694078b96a5ed85631942") -(package! highlight-numbers :pin "8b4744c7f46c72b1d3d599d4fb75ef8183dee307") -(package! rainbow-delimiters :pin "a32b39bdfe6c61c322c37226d66e1b6d4f107ed0") -(package! restart-emacs :pin "1607da2bc657fe05ae01f7fdf26f716eafead02c") - -;; doom-editor.el -(package! better-jumper :pin "47622213783ece37d5337dc28d33b530540fc319") -(package! dtrt-indent :pin "d4fd1b4977eb0d534844fddf01c3c51c70c57205") -(package! helpful :pin "94c25337b2de2f9da60914a7c0c6cca9584c0231") -(package! pcre2el :pin "38c6f80c787da547287db96b495e5b695ca0b4b8") -(package! smartparens :pin "7afd647395018a26633673ed92ce7a9cb3ccb8f2") -(package! ws-butler - ;; Use my fork of ws-butler, which has a few choice improvements and - ;; optimizations (the original has been abandoned). - :recipe (:host github :repo "hlissner/ws-butler") - :pin "572a10c11b6cb88293de48acbb59a059d36f9ba5") - -;; doom-projects.el -(package! projectile :pin "e18ad4d6111eb9e975ccce028baf5e4bb786bfcf") -(package! project :pin "e086bdc7c515f8bfc22598d473ba888ba7683f0c") - -;; doom-keybinds.el -(package! general :pin "9651024e7f40a8ac5c3f31f8675d3ebe2b667344") -(package! which-key :pin "8093644032854b1cdf3245ce4e3c7b6673f741bf") - -(package! compat - :recipe (:host github :repo "emacs-compat/compat") - :pin "7775c3185764337b8a78c3005aab4a11aa80dfe8") diff --git a/.config/emacs/modules/.gitignore b/.config/emacs/modules/.gitignore @@ -1,19 +0,0 @@ -.DS_Store -.idea -*.log -tmp/ -*~ -*.*~ -\#* -.\#* -*.cache* -*.log -test/.local*/ -test/result - -# compiled files -*.elc -*.lib -*.fas -*.dat -*.eld diff --git a/.config/emacs/modules/LICENSE b/.config/emacs/modules/LICENSE @@ -1,22 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2021 Henrik Lissner - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/.config/emacs/modules/README.org b/.config/emacs/modules/README.org @@ -1,1492 +0,0 @@ -:PROPERTIES: -:ID: 12d2de30-c569-4b8e-bbc7-85dd5ccc4afa -:END: -#+title: Official modules -#+subtitle: Doom Emacs' official module repository -#+startup: nonum - -* Description :unfold: -This is a repository of official modules for [[https://github.com/doomemacs/core][Doom Emacs]]. They are more closely -looked after by Doom's author. If a module you want isn't here, check our -sibling repository for community-maintained modules: [[https://github.com/doomemacs/contrib-modules][doomemacs/contrib-modules]], -which also serves as a staging ground for new modules. - -#+begin_quote - 📌 Technical documentation on the anatomy of Doom modules can be found in [[id:72d8e438-a224-421a-b6a9-43d7dcebe0bb][the - official developer's manual]]. -#+end_quote - -** Maintainers -- @hlissner - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -This module repository is included with Doom Emacs (for now). No additional -setup is needed to add them. However, [[id:01cffea4-3329-45e2-a892-95a384ab2338][the modules themselves can be toggled in -your ~doom!~ block.]] - -Remember to check their documentation (listed and linked below) for additional -setup instructions. - -* Module list (150) :unfold: -# Do not edit this list by hand; run 'doom make-index path/to/modules' -** [[doom-module::app][:app]] (6) :unfold: -Application modules are complex and opinionated modules that transform Emacs -toward a specific purpose. They may have additional dependencies and *should be -loaded last* (but before [[doom-module::config]] modules). - -*** [[doom-module::app calendar][calendar]]: - -: Watch your missed deadlines in real time - -This module adds a calendar view for Emacs, with org and google calendar sync -support. - -*** [[doom-module::app emms][emms]]: - -: A media player for music no one's heard of - -This module enables Emacs to be used as a music player. It uses [[https://www.musicpd.org/][mpd]] as a backend -server and [[https://musicpd.org/clients/mpc/][mpc]] to update your music database. - -*** [[doom-module::app everywhere][everywhere]]: - -: *leave* Emacs!? You must be joking - -This module adds system-wide popup Emacs windows for quick edits. - -*** [[doom-module::app irc][irc]]: - -: How neckbeards socialize - -This module turns Emacs into an IRC client, capable of OS notifications. - -*** [[doom-module::app rss][rss]]: [[doom-module::app rss +org][+org]] -: An RSS reader that Google can't shut down - -Read RSS feeds in the comfort of Emacs. - -*** [[doom-module::app twitter][twitter]]: - -: Be superficial in plain text - -Enjoy twitter from emacs. - -- View various timelines side by side, e.g. user's timeline, home, etc. -- Post new tweets -- Send direct messages -- Retweet -- Follow and un-follow users -- Favorite tweets - - -** [[doom-module::checkers][:checkers]] (3) :unfold: -For modules dedicated to linting plain text (primarily code and prose). - -*** [[doom-module::checkers grammar][grammar]]: - -: Tasing grammar mistake every you make - -This module adds grammar checking to Emacs to aid your writing by combining -[[doom-package:lang-tool]] and [[doom-package:writegood-mode]]. - -*** [[doom-module::checkers spell][spell]]: [[doom-module::checkers spell +aspell][+aspell]] [[doom-module::checkers spell +enchant][+enchant]] [[doom-module::checkers spell +everywhere][+everywhere]] [[doom-module::checkers spell +flyspell][+flyspell]] [[doom-module::checkers spell +hunspell][+hunspell]] -: Tasing you for misspelling mispelling - -This modules provides spellchecking powered by =aspell=, =hunspell= or -=enchant=. - -Spellcheck is automatically loaded in many ~text-mode~ derivatives, which -includes ~org-mode~, ~markdown-mode~, the Git Commit buffer (from magit), -~mu4e-compose-mode~, and others. - -- Spell checking and correction using =aspell=, =hunspell= or =enchant=. -- Ignores source code inside org or markdown files. -- Lazily spellchecking recent changes only when idle. -- Choosing suggestions using completion interfaces ([[doom-package:ivy]] or [[doom-package:helm]]). - -*** [[doom-module::checkers syntax][syntax]]: [[doom-module::checkers syntax +childframe][+childframe]] -: Tasing you for every semicolon you forget - -This module provides syntax checking and error highlighting, powered by -[[doom-package:flycheck]]. - - -** [[doom-module::completion][:completion]] (5) :unfold: -These modules provide interfaces and frameworks completion, including code -completion. - -*** [[doom-module::completion company][company]]: [[doom-module::completion company +childframe][+childframe]] [[doom-module::completion company +tng][+tng]] -: The ultimate code completion backend - -This module provides code completion, powered by [[https://github.com/company-mode/company-mode][company-mode]]. Many of Doom's -[[doom-module::lang]] modules require it for "intellisense" functionality. - -https://assets.doomemacs.org/completion/company/overlay.png - -*** [[doom-module::completion helm][helm]]: [[doom-module::completion helm +childframe][+childframe]] [[doom-module::completion helm +fuzzy][+fuzzy]] [[doom-module::completion helm +icons][+icons]] -: A tank for hunting a house fly - -This module provides Helm integration for a variety of Emacs commands, as well -as a unified interface for project search and replace, powered by [[https://github.com/BurntSushi/ripgrep][Ripgrep]]. - -*** [[doom-module::completion ido][ido]]: - -: A foil for other search engines - -Interactive DO things. The completion engine that is /mostly/ built-into Emacs. - -*** [[doom-module::completion ivy][ivy]]: [[doom-module::completion ivy +childframe][+childframe]] [[doom-module::completion ivy +fuzzy][+fuzzy]] [[doom-module::completion ivy +icons][+icons]] [[doom-module::completion ivy +prescient][+prescient]] -: Yesterday's lightest search engine - -This module provides Ivy integration for a variety of Emacs commands, as well as -a unified interface for project search and replace, powered by [[https://github.com/BurntSushi/ripgrep/][ripgrep]]. - -#+begin_quote -I prefer ivy over ido for its flexibility. I prefer ivy over helm because it's -lighter, simpler and faster in many cases. -#+end_quote - -*** [[doom-module::completion vertico][vertico]]: [[doom-module::completion vertico +icons][+icons]] -: Tomorrow's search engine - -This module enhances the Emacs search and completion experience, and also -provides a united interface for project search and replace, powered by [[https://github.com/BurntSushi/ripgrep/][ripgrep]]. - -It does this with several modular packages focused on enhancing the built-in -~completing-read~ interface, rather than replacing it with a parallel ecosystem -like [[doom-package:ivy]] and [[doom-package:helm]] do. The primary packages are: - -- Vertico, which provides the vertical completion user interface -- Consult, which provides a suite of useful commands using ~completing-read~ -- Embark, which provides a set of minibuffer actions -- Marginalia, which provides annotations to completion candidates -- Orderless, which provides better filtering methods - - -** [[doom-module::config][:config]] (2) :unfold: -Modules in this category provide sane defaults or improve your ability to -configure Emacs. It is best to load these last. - -*** [[doom-module::config default][default]]: [[doom-module::config default +bindings][+bindings]] [[doom-module::config default +smartparens][+smartparens]] -: Reasonable defaults for reasonable people - -This module provides a set of reasonable defaults, including: - -- A Spacemacs-inspired keybinding scheme -- A configuration for (almost) universally repeating searches with [[kbd:][;]] and [[kbd:][,]] -- A [[doom-package:smartparens]] configuration for smart completion of certain delimiters, like - ~/* */~ command blocks in C-languages, ~<?php ?>~ tags in PHP, or ~def end~ in - Ruby/Crystal/etc. - -*** [[doom-module::config literate][literate]]: - -: Disguise your config as poor documentation - -This module enables support for a literate config. - -A literate config consists of a =$DOOMDIR/config.org=. All src blocks within are -tangled =$DOOMDIR/config.el=, by default, when ~$ doom sync~ is executed. - - -** [[doom-module::editor][:editor]] (12) :unfold: -For modules concerned with the insertion and editing of text. Amen. - -*** [[doom-module::editor evil][evil]]: [[doom-module::editor evil +everywhere][+everywhere]] -: The text editor Emacs was missing - -This holy module brings the Vim editing model to Emacs. - -*** [[doom-module::editor file-templates][file-templates]]: - -: Fill the void in your empty files - -This module adds file templates for blank files, powered by [[doom-package:yasnippet]]. - -*** [[doom-module::editor fold][fold]]: - -: What you can't see won't hurt you - -This module marries [[doom-package:hideshow]], [[doom-package:vimish-fold]], and ~outline-minor-mode~ to bring you -marker, indent and syntax-based code folding for as many languages as possible. - -*** [[doom-module::editor format][format]]: [[doom-module::editor format +onsave][+onsave]] -: Standardize your ugly code - -This module integrates code formatters into Emacs. Here are some of the -formatters that it currently supports: - -#+begin_quote -asmfmt, black, brittany, cabal-fmt, clang-format, cmake-format, dartfmt, dfmt, -dhall format, dockfmt, elm-format, emacs, fish_indent, fprettify, gleam format, -gofmt, iStyle, jsonnetfmt, ktlint, latexindent, ledger-mode, lua-fmt, mix -format, nixfmt, node-cljfmt, ocp-indent, perltidy, prettier, purty, rufo, -rustfmt, scalafmt, script shfmt, snakefmt, sqlformat, styler, swiftformat, tidy -#+end_quote - -*** [[doom-module::editor god][god]]: - -: IDDQD - -Adds [[doom-package:god-mode]] support to Doom Emacs, allowing for entering commands without -modifier keys, similar to Vim's modality, separating command mode and insert -mode. - -*** [[doom-module::editor lispy][lispy]]: - -: Vim for lisp, for people who don't like vim - -This module adds a keybind scheme for navigating and editing S-expressions in -Lisps; including S-exp awareness for Evil users. This affects the following -languages: - -- Common Lisp -- Emacs Lisp -- Scheme -- Racket -- [[http://docs.hylang.org/en/stable/][Hy]] -- [[http://lfe.io/][LFE]] -- Clojure -- [[https://fennel-lang.org][Fennel]] - -*** [[doom-module::editor multiple-cursors][multiple-cursors]]: - -: Make all your mistakes at once - -This module adds a multiple cursors implementation to Emacs (two, if you use -evil) that loosely take after multi-cursors in Atom or Sublime Text. - -*** [[doom-module::editor objed][objed]]: [[doom-module::editor objed +manual][+manual]] -: Text object editing for the innocent - -This modules adds [[doom-package:objed]], a global minor-mode for navigating and manipulating -text objects. It combines the ideas of ~versor-mode~ and other editors like Vim -or Kakoune and tries to align them with regular Emacs conventions. - -[[https://github.com/clemera/objed][See the objed project README]] for information on keybinds and usage. - -*** [[doom-module::editor parinfer][parinfer]]: - -: For lispers that like Python more (i.e. nobody) - -Parinfer is a minor mode that aids the writing of Lisp code. It automatically -infers parenthesis matching and indentation alignment, keeping your code -balanced and beautiful. - -*** [[doom-module::editor rotate-text][rotate-text]]: - -: The only back'n'forth nerds will ever know - -This module adds text rotation to Doom Emacs. I.e. The ability to cycle through -keywords or text patterns at point, like ~true~ and ~false~, or ~public~, -~protected~, and ~private~ (in ~c++-mode~). - -*** [[doom-module::editor snippets][snippets]]: - -: My elves type so I don't have to - -This module adds snippet expansions to Emacs, powered by [[doom-package:yasnippet]]. - -*** [[doom-module::editor word-wrap][word-wrap]]: - -: Soft-wrapping with language-aware indent - -This module adds a minor-mode [[fn:+word-wrap-mode]], which intelligently wraps long -lines in the buffer without modifying the buffer content. - - -** [[doom-module::emacs][:emacs]] (6) :unfold: -Modules in this category augment and extend the built-in features of Emacs. - -*** [[doom-module::emacs dired][dired]]: [[doom-module::emacs dired +icons][+icons]] [[doom-module::emacs dired +ranger][+ranger]] -: Making dired pretty [functional] - -This module provides reasonable defaults and augmentations for dired. - -*** [[doom-module::emacs electric][electric]]: - -: Shocking keyword-based electric-indent - -This module augments the built-in [[doom-package:electric]] package with keyword-based -indentation (as opposed to character-based). - -*** [[doom-module::emacs ibuffer][ibuffer]]: [[doom-module::emacs ibuffer +icons][+icons]] -: Edit me like one of your French buffers - -This module augments the built-in [[doom-package:ibuffer]] package. - -- Adds project-based grouping of buffers -- Support for file-type icons -- Uses human-readable file-size - -*** tramp: - -/(No description)/ - -*** [[doom-module::emacs undo][undo]]: [[doom-module::emacs undo +tree][+tree]] -: Persistent, smarter undo for your inevitable mistakes - -This module augments Emacs' built-in undo system to be more intuitive and to -persist across Emacs sessions. - -*** [[doom-module::emacs vc][vc]]: - -: Be the difference you want to see in the fringe - -This module augments Emacs builtin version control support and provides better -integration with =git=. - - -** [[doom-module::email][:email]] (3) :unfold: -Modules that turn Emacs in an email client. - -*** [[doom-module::email mu4e][mu4e]]: [[doom-module::email mu4e +gmail][+gmail]] [[doom-module::email mu4e +org][+org]] -: The great filter Hanson hadn't anticipated - -This module makes Emacs an email client, using [[https://www.djcbsoftware.nl/code/mu/mu4e.html][mu4e]]. - -- Tidied mu4e headers view, with flags from [[doom-package:all-the-icons]]. -- Consistent coloring of reply depths (across compose and gnus modes). -- Prettified =mu4e:main= view. -- Cooperative locking of the =mu= process. Another Emacs instance may request - access, or grab the lock when it's available. -- [[doom-package:org-msg]] integration with [[doom-module:+org]], which can be toggled per-message, with revamped - style and an accent color. -- Gmail integrations with the [[doom-module:+gmail]] flag. -- Email notifications with [[doom-package:mu4e-alert]], and (on Linux) a customised notification - style. - -#+begin_quote - 💡 I want to live in Emacs, but as we all know, living is incomplete without - email. So I prayed to the text editor gods and they (I) answered. - Emacs+evil's editing combined with org-mode for writing emails? /Yes - please./ - - It uses ~mu4e~ to read my email, but depends on ~offlineimap~ (to sync my - email via IMAP) and ~mu~ (to index my mail into a format ~mu4e~ can - understand). -#+end_quote - -*** [[doom-module::email notmuch][notmuch]]: [[doom-module::email notmuch +afew][+afew]] [[doom-module::email notmuch +org][+org]] -: Closest Emacs will ever be to multi-threaded - -This module turns Emacs into an email client using [[doom-package:notmuch]]. - -*** [[doom-module::email wanderlust][wanderlust]]: [[doom-module::email wanderlust +gmail][+gmail]] -: To boldly go where no mail has gone before - -#+begin_quote - 🔨 This module has no description. [[doom-contrib-module:][Write one?]] -#+end_quote - - -** [[doom-module::input][:input]] (3) :unfold: -Modules in this category extend Emacs support for additional keyboard layouts -and input methods for non-English languages. - -*** [[doom-module::input chinese][chinese]]: - -: Spend your 3 hours a week in Emacs - -This module adds support for traditional Chinese script by introducing two input -methods: Pinyin and Wubi. - -*** [[doom-module::input japanese][japanese]]: - -: Ah, a man of culture - -This module adds support for Japanese script. - -*** [[doom-module::input layout][layout]]: [[doom-module::input layout +azerty][+azerty]] [[doom-module::input layout +bepo][+bepo]] -: auie,ctsrnm is the superior home row - -This module provides barebones support for using Doom with non-qwerty keyboard -layouts. - - -** [[doom-module::lang][:lang]] (60) :unfold: -These modules specialize in integration particular languages and their -ecosystems into (Doom) Emacs. - -*** [[doom-module::lang agda][agda]]: - -: Types of types of types of types... - -This module adds support for the [[http://wiki.portal.chalmers.se/agda/pmwiki.php][agda]] programming language. The Emacs support -exists directly in the agda repository, but not in melpa. - -*** [[doom-module::lang beancount][beancount]]: [[doom-module::lang beancount +lsp][+lsp]] -: Mind the GAAP - -This module adds support for [[https://beancount.github.io/][Beancount]] to Emacs. Beancount, like ledger, lets -you [[https://plaintextaccounting.org/][manage your money in plain text]]. - -*** [[doom-module::lang cc][cc]]: [[doom-module::lang cc +lsp][+lsp]] -: C > C++ == 1 - -This module adds support for the C-family of languages: C, C++, and Objective-C. - -- Code completion (~company-irony~) -- eldoc support (~irony-eldoc~) -- Syntax-checking (~flycheck-irony~) -- Code navigation (~rtags~) -- File Templates ([[../../editor/file-templates/templates/c-mode][c-mode]], [[../../editor/file-templates/templates/c++-mode][c++-mode]]) -- Snippets ([[https://github.com/hlissner/doom-snippets/tree/master/cc-mode][cc-mode]], [[https://github.com/hlissner/doom-snippets/tree/master/c-mode][c-mode]], [[https://github.com/hlissner/doom-snippets/tree/master/c++-mode][c++-mode]]) -- Several improvements to C++11 indentation and syntax highlighting. - -*** [[doom-module::lang clojure][clojure]]: [[doom-module::lang clojure +lsp][+lsp]] -: Java with a lisp - -This module adds support for the Clojure(Script) language. - -- Interactive development environment (~cider~): REPL, compilation, debugging, - running tests, definitions & documentation lookup, code completion, and much - more -- Refactoring (~clj-refactor~) -- Linting (~clj-kondo~), requires ~:checkers syntax~ -- LSP support (~clojure-lsp~) - -*** [[doom-module::lang common-lisp][common-lisp]]: - -: If you've seen one lisp, you've seen them all - -This module provides support for [[https://lisp-lang.org/][Common Lisp]] and the [[doom-package:Sly]] development -environment. Common Lisp is not a single language but a specification, with many -competing compiler implementations. By default, [[http://www.sbcl.org/][Steel Bank Common Lisp]] (SBCL) is -assumed to be installed, but this can be configured. - -Common Lisp benefits from a mature specification and rich standard library. -Thanks to its powerful REPL and debugger, it boasts an "interactive programming" -style often unseen in other languages. Compiled Common Lisp programs are trusted -to run unmodified for a long time. - -*** [[doom-module::lang coq][coq]]: - -: Proofs as programs - -This module adds [[https://coq.inria.fr][coq]] support, powered by [[https://proofgeneral.github.io][Proof General]]. - -- Code completion ([[https://github.com/cpitclaudel/company-coq][company-coq]]) -- [[https://github.com/hlissner/doom-snippets/tree/master/coq-mode][Snippets]] - -*** [[doom-module::lang crystal][crystal]]: - -: Ruby at the speed of C - -This modules adds [[https://crystal-lang.org/][crystal]] support. - -- Syntax-checking (~flycheck~) -- REPL (~inf-crystal~) - -*** [[doom-module::lang csharp][csharp]]: [[doom-module::lang csharp +dotnet][+dotnet]] [[doom-module::lang csharp +lsp][+lsp]] [[doom-module::lang csharp +unity][+unity]] -: Unity, .NET, and Mono shenanigans - -This module adds C# support to Emacs, powered by Omnisharp (directly or through -LSP). - -*** [[doom-module::lang dart][dart]]: [[doom-module::lang dart +flutter][+flutter]] [[doom-module::lang dart +lsp][+lsp]] -: Paint ui and not much else - -[[https://dart.dev/][Dart]] is a client-optimized language by Google for fast apps on any platform. It -is fast and optimized for UI, famous for the [[https://flutter.io/][Flutter]] framework, also made by -Google. Both Flutter and Dart are free and open-source. - -This module wraps ~dart-mode~, with [[https://microsoft.github.io/language-server-protocol/][LSP]] features like code completion for -=.dart= files, syntax highlighting, debugging, closing labels, etc. - -*** [[doom-module::lang data][data]]: - -: A dumping ground for data formats - -This module adds Emacs support for CSV and XML files. - -*** [[doom-module::lang dhall][dhall]]: - -: Config as code - -This module adds [[https://dhall-lang.org/][Dhall]] language support to Emacs. - -Dhall is a programmable configuration language that you can think of as: JSON + -functions + types + imports. - -*** [[doom-module::lang elixir][elixir]]: [[doom-module::lang elixir +lsp][+lsp]] -: Erlang done right - -This module provides support for [[https://elixir-lang.org/][Elixir programming language]] via [[doom-package:alchemist]] or -[[https://github.com/elixir-lsp/elixir-ls/][elixir-ls]]. - -*** [[doom-module::lang elm][elm]]: [[doom-module::lang elm +lsp][+lsp]] -: Care for a cup of TEA? - -This module adds [[https://elm-lang.org/][Elm]] support to Doom Emacs. - -*** [[doom-module::lang emacs-lisp][emacs-lisp]]: - -: A parsel-tongue for the oldest serpent - -This module extends support for Emacs Lisp in Doom Emacs. - -- Macro expansion -- Go-to-definitions or references functionality -- Syntax highlighting for defined and quoted symbols -- Replaces the built-in help with the more powerful [[doom-package:helpful]] -- Adds function example uses to documentation - -*** [[doom-module::lang erlang][erlang]]: [[doom-module::lang erlang +lsp][+lsp]] -: An elegant language for a more civilized age - -This module provides support [[https://www.erlang.org/][Erlang programming language]]. Support for the -[[https://github.com/erlang/sourcer][sourcer]] language server is optional. - -Includes: -- Code completion ([[doom-module:+lsp]], [[doom-module::completion company]], & [[doom-module::completion ivy]]) -- Syntax checking ([[doom-module::checkers syntax]]) - -*** [[doom-module::lang ess][ess]]: [[doom-module::lang ess +stan][+stan]] -: 73.6% of all statistics are made up - -This module adds support for various statistics languages, including R, S-Plus, -SAS, Julia and Stata. - -*** [[doom-module::lang factor][factor]]: - -: ... - -This module adds support to the [[https://github.com/factor/factor][factor]] programming language and its associated -[[doom-package:fuel]] emacs plugin. - -*** [[doom-module::lang faust][faust]]: - -: DSP, but you can keep your soul - -Add support to [[https://faust.grame.fr/][Faust language]] inside emacs. - -- Faust code syntax highlighting and indentation -- Project-based (inter-linked Faust files) -- Build/compile with output window -- Graphic diagrams generation and visualization in the (default) browser -- Browse generated C++ code inside Emacs -- Inter-linked files/buffers : - - From "component" to Faust file - - From "include" to Faust library file -- From error to file:line number -- From function name to online documentation -- Fully configurable (build type/target/architecture/toolkit, keyboard - shortcuts, etc.) -- Automatic keyword completion (if Auto-Complete is installed) -- Automatic objets (functions, operators, etc.) template insertion with default - sensible values (if [[doom-module::editor snippets]] is enabled) -- Modeline indicator of the state of the code - -*** [[doom-module::lang fsharp][fsharp]]: [[doom-module::lang fsharp +lsp][+lsp]] -: ML stands for Microsoft's Language - -This module adds [[https://fsharp.org/][F#]] support to Doom Emacs. - -*** [[doom-module::lang fstar][fstar]]: - -: (Dependent) types and (monadic) effects and Z3 - -This module adds [[https://fstar-lang.org/][F*]] support, powered by [[https://github.com/FStarLang/fstar-mode.el][fstar-mode.el]]. - -- Syntax highlighting -- Interactively process F* files one definition at a time -- Query the running F* process to look up definitions, documentation, and - theorems - -*** [[doom-module::lang gdscript][gdscript]]: [[doom-module::lang gdscript +lsp][+lsp]] -: the language you waited for - -This module adds support for GDScript, the scripting language of the [[http://godotengine.org/][Godot]] game -engine, to Doom Emacs, powered by [[https://github.com/GDQuest/emacs-gdscript-mode][gdscript-mode]]. - -*** [[doom-module::lang go][go]]: [[doom-module::lang go +lsp][+lsp]] -: The hipster dialect - -This module adds [[https://golang.org][Go]] support, with optional (but recommended) LSP support via -[[https://github.com/golang/tools/blob/master/gopls/README.md][gopls]]. - -- Code completion (~gocode~) -- Documentation lookup (~godoc~) -- Eldoc support (~go-eldoc~) -- REPL (~gore~) -- Syntax-checking (~flycheck~) -- Auto-formatting on save (~gofmt~) (requires [[doom-module::editor format +onsave]]) -- Code navigation & refactoring (~go-guru~) -- [[../../editor/file-templates/templates/go-mode][File templates]] -- [[https://github.com/hlissner/doom-snippets/tree/master/go-mode][Snippets]] -- Generate testing code (~go-gen-test~) -- Code checking (~flycheck-golangci-lint~) - -*** [[doom-module::lang haskell][haskell]]: [[doom-module::lang haskell +lsp][+lsp]] -: A language that's lazier than I am - -This module adds Haskell support to Doom Emacs. - -*** [[doom-module::lang hy][hy]]: - -: Lisp is better than ugly - -/(No description yet)/ - -*** [[doom-module::lang idris][idris]]: - -: A language you can depend on - -This module adds rudimentary [[https://www.idris-lang.org/][Idris]] support to Doom Emacs. - -*** [[doom-module::lang java][java]]: [[doom-module::lang java +lsp][+lsp]] [[doom-module::lang java +meghanada][+meghanada]] -: The poster child for carpal tunnel syndrome - -This module adds [[https://www.java.com][Java]] support to Doom Emacs, including ~android-mode~ and -~groovy-mode~. - -*** [[doom-module::lang javascript][javascript]]: [[doom-module::lang javascript +lsp][+lsp]] -: all(hope(abandon(ye(who(enter(here)))))) - -This module adds [[https://www.javascript.com/][JavaScript]] and [[https://www.typescriptlang.org/][TypeScript]] support to Doom Emacs. - -- Code completion ([[doom-package:tide]]) -- REPL support ([[doom-package:nodejs-repl]]) -- Refactoring commands ([[doom-package:js2-refactor]]) -- Syntax checking ([[doom-package:flycheck]]) -- Browser code injection with [[doom-package:skewer-mode]] -- Coffeescript & JSX support -- Jump-to-definitions and references support ([[doom-package:xref]]) - -*** [[doom-module::lang json][json]]: [[doom-module::lang json +lsp][+lsp]] -: At least it ain't XML - -This module adds [[https://www.json.org/json-en.html][JSON]] support to Doom Emacs. - -*** [[doom-module::lang julia][julia]]: [[doom-module::lang julia +lsp][+lsp]] -: A better, faster MATLAB - -This module adds support for [[https://julialang.org/][the Julia language]] to Doom Emacs. - -- Syntax highlighting and latex symbols from [[doom-package:julia-mode]] -- REPL integration from [[doom-package:julia-repl]] -- Code completion and syntax checking, requires [[doom-module::tools lsp]] and [[doom-module:+lsp]] - -*** [[doom-module::lang kotlin][kotlin]]: [[doom-module::lang kotlin +lsp][+lsp]] -: A Java(Script) that won't depress you - -This module adds [[https://kotlinlang.org/][Kotlin]] support to Doom Emacs. - -*** [[doom-module::lang latex][latex]]: [[doom-module::lang latex +cdlatex][+cdlatex]] [[doom-module::lang latex +fold][+fold]] [[doom-module::lang latex +latexmk][+latexmk]] [[doom-module::lang latex +lsp][+lsp]] -: Writing papers in Emacs has never been so fun - -Provide a helping hand when working with LaTeX documents. - -- Sane defaults -- Fontification of many popular commands -- Pretty indentation of wrapped lines using the [[doom-package:adaptive-wrap]] package -- Spell checking with [[doom-package:flycheck]] -- Change PDF viewer to Okular or [[doom-package:latex-preview-pane]] -- Bibtex editor -- Autocompletion using [[doom-package:company-mode]] -- Compile your =.tex= code only once using LatexMk - -*** [[doom-module::lang lean][lean]]: - -: For folks with too much to prove - -This module adds support for the [[https://leanprover.github.io/about/][Lean programming language]] to Doom Emacs. - -*** [[doom-module::lang ledger][ledger]]: - -: Be audit you can be - -This module adds support for [[https://www.ledger-cli.org/][ledger]] files. Ledger is a command line double-entry -accounting system that works with simple text files holding transactions in the -following format: -#+begin_src ledger -2015/10/12 Exxon - Expenses:Auto:Gas $10.00 - Liabilities:MasterCard $-10.00 -#+end_src - -This modules enables the following features: -- Syntax and indentation support for ledger files -- Add, edit, and delete transactions -- Generate reports -- Schedule transactions -- Sort transactions -- Display statistics about transactions -- Display balance up to a point - -*** [[doom-module::lang lua][lua]]: [[doom-module::lang lua +fennel][+fennel]] [[doom-module::lang lua +lsp][+lsp]] [[doom-module::lang lua +moonscript][+moonscript]] -: One-based indices? one-based indices - -This module adds Lua support to Doom Emacs. - -- REPL -- Love2D specific functions -- Moonscript support -- Fennel support - -*** [[doom-module::lang markdown][markdown]]: [[doom-module::lang markdown +grip][+grip]] -: Write docs for people to ignore - -This module provides Markdown support for Emacs. - -#+begin_quote -Markdown is a text-to-HTML conversion tool for web writers. Markdown allows you -to write using an easy-to-read, easy-to-write plain text format, then convert it -to structurally valid XHTML (or HTML). - -Thus, “Markdown” is two things: (1) a plain text formatting syntax; and (2) a -software tool, written in Perl, that converts the plain text formatting to HTML. -See the Syntax page for details pertaining to Markdown's formatting syntax. You -can try it out, right now, using the online Dingus. - -The overriding design goal for Markdown's formatting syntax is to make it as -readable as possible. The idea is that a Markdown-formatted document should be -publishable as-is, as plain text, without looking like it's been marked up with -tags or formatting instructions. While Markdown's syntax has been influenced by -several existing text-to-HTML filters, the single biggest source of inspiration -for Markdown's syntax is the format of plain text email. -- John Gruber -#+end_quote - -*** [[doom-module::lang nim][nim]]: - -: Python + lisp at the speed of C - -This module adds [[https://nim-lang.org][Nim]] support to Doom Emacs. - -- Code completion ([[doom-package:nimsuggest]] + [[doom-package:company]]) -- Syntax checking ([[doom-package:nimsuggest]] + [[doom-package:flycheck]]) -- Org babel support ([[doom-package:ob-nim]]) - -*** [[doom-module::lang nix][nix]]: - -: I hereby declare "nix geht mehr!" - -This module adds support for the Nix language to Doom Emacs, along with tools -for managing [[https://nixos.org/][Nix(OS)]]. - -Includes: -- Syntax highlighting -- Completion through [[doom-package:company]] and/or [[doom-package:helm]] -- Nix option lookup -- Formatting (~nixfmt~) - -*** [[doom-module::lang ocaml][ocaml]]: [[doom-module::lang ocaml +lsp][+lsp]] -: An objective camel - -This module adds [[https://ocaml.org/][OCaml]] support to Doom Emacs, powered by [[doom-package:tuareg-mode]]. - -- Code completion, documentation look-up, code navigation and refactoring - ([[doom-package:merlin]]) -- Type, documentation and function argument display on idle ([[doom-package:merlin-eldoc]]) -- REPL ([[doom-package:utop]]) -- Syntax-checking ([[doom-package:merlin]] with [[doom-package:flycheck-ocaml]]) -- Auto-indentation ([[doom-package:ocp-indent]]) -- Code formatting ([[doom-package:ocamlformat]]) -- Dune file format ([[doom-package:dune]]) - -*** [[doom-module::lang org][org]]: [[doom-module::lang org +brain][+brain]] [[doom-module::lang org +dragndrop][+dragndrop]] [[doom-module::lang org +gnuplot][+gnuplot]] [[doom-module::lang org +hugo][+hugo]] [[doom-module::lang org +ipython][+ipython]] [[doom-module::lang org +journal][+journal]] [[doom-module::lang org +jupyter][+jupyter]] [[doom-module::lang org +noter][+noter]] [[doom-module::lang org +pandoc][+pandoc]] [[doom-module::lang org +pomodoro][+pomodoro]] [[doom-module::lang org +present][+present]] [[doom-module::lang org +pretty][+pretty]] [[doom-module::lang org +roam][+roam]] [[doom-module::lang org +roam2][+roam2]] -: Organize your plain life in plain text - -This module adds org-mode support to Doom Emacs, along with a number of -adjustments, extensions and reasonable defaults to make it more performant and -intuitive out of the box: - -- A custom, centralized attachment system that stores files in one place, rather - than in the same directory as the input file(s) (only applies to attachments - from files in/under ~org-directory~). -- Executable code blocks with support for a variety of languages and tools - (depending on what :lang modules are enabled). -- Supports an external org-capture workflow through the =bin/org-capture= shell - script and ~+org-capture/open-frame~. -- A configuration for using org-mode for slide-show presentations or exporting - org files to reveal.js slideshows. -- Drag-and-drop support for images (with inline preview) and media files (drops - a file icon and a short link) (requires [[doom-module:+dragndrop]] flag). -- Integration with pandoc, ipython, jupyter, reveal.js, beamer, and others - (requires flags). -- Export-to-clipboard functionality, for copying text into formatted html, - markdown or rich text to the clipboard (see ~+org/export-to-clipboard~ and - ~+org/export-to-clipboard-as-rich-text~). - -#+begin_quote -Org is a system for writing plain text notes with syntax highlighting, code -execution, task scheduling, agenda management, and many more. The whole idea is -that you can write notes and mix them with references to things like articles, -images, and example code combined with the output of that code after it is -executed. - -https://www.mfoot.com/blog/2015/11/22/literate-emacs-configuration-with-org-mode/ -#+end_quote - -*** [[doom-module::lang php][php]]: [[doom-module::lang php +hack][+hack]] [[doom-module::lang php +lsp][+lsp]] -: Perl's insecure younger brother - -This module adds support for PHP 5.3+ (including PHP7) to Doom Emacs. - -- ctags-based code completion (~company-php~ and ~phpctags~) -- eldoc support (~ac-php~ and ~php-extras~) -- REPL (~php-boris~) -- Code refactoring commands (~php-refactor-mode~) -- Unit-test commands (~phpunit~) -- Support for ~laravel~ and ~composer~ projects (with project-specific snippets) -- [[../../editor/file-templates/templates/php-mode][File templates]] -- [[https://github.com/hlissner/doom-snippets/tree/master/php-mode][Snippets]] - -#+begin_quote - 💡 PHP was the first programming language I got paid to code in, back in the - Cretaceous period (2003). My sincerest apologies go out to all the - programmers who inherited my earliest PHP work. I know you're out there, - writhing in your straitjackets. - - Save a programmer today. Stop a friend from choosing PHP as their first - language. -#+end_quote - -*** [[doom-module::lang plantuml][plantuml]]: - -: Diagrams to confuse people more - -This module adds plantuml support to Emacs; allowing you to generate diagrams -from plain text. - -*** [[doom-module::lang purescript][purescript]]: [[doom-module::lang purescript +lsp][+lsp]] -: Javascript, but functional - -This module adds [[https://www.purescript.org/][Purescript]] support to Doom Emacs. - -*** [[doom-module::lang python][python]]: [[doom-module::lang python +conda][+conda]] [[doom-module::lang python +cython][+cython]] [[doom-module::lang python +lsp][+lsp]] [[doom-module::lang python +poetry][+poetry]] [[doom-module::lang python +pyenv][+pyenv]] [[doom-module::lang python +pyright][+pyright]] -: Beautiful is better than ugly - -This module adds [[https://www.python.org/][Python]] support to Doom Emacs. - -- Syntax checking ([[doom-package:flycheck]]) -- Snippets -- Run tests ([[doom-package:nose]], [[doom-package:pytest]]) -- Auto-format (with ~black~, requires [[doom-module::editor format]]) -- LSP integration (=mspyls=, =pyls=, or =pyright=) - -*** [[doom-module::lang qt][qt]]: - -: The cutest GUI framework ever - -This module provides language functionality for [[https://qt.io][Qt]] specific files. - -- Syntax highlighting for [[https:://en.wikipedia.org/wiki/QML][qml]] files -- Syntax highlighting for =.pro= and =.pri= files used by [[https://doc.qt.io/qt-5/qmake-project-files.html][qmake]] - -*** [[doom-module::lang racket][racket]]: [[doom-module::lang racket +lsp][+lsp]] [[doom-module::lang racket +xp][+xp]] -: The DSL for DSLs - -This module adds support for the [[https://www.racket-lang.org/][Racket programming language]] to Doom Emacs. - -*** [[doom-module::lang raku][raku]]: - -: The artist formerly known as perl6 - -This module adds support for the [[https://www.raku.org/][Raku programming language]] to Doom Emacs. - -*** [[doom-module::lang rest][rest]]: - -: Emacs as a REST client - -This module turns Emacs into a [[https://en.wikipedia.org/wiki/Representational_state_transfer][REST]] client. - -- Code-completion (~company-restclient~) -- Code evaluation -- Imenu support for ~restclient-mode~ -- org-mode: babel support (~ob-restclient~) - -#+begin_quote - 💡 ~restclient-mode~ is tremendously useful for automated or quick testing REST - APIs. My workflow is to open an ~org-mode~ buffer, create a restclient - source block and hack away. ~restclient-mode~ and ~company-restclient~ power - this arcane wizardry. -#+end_quote - -*** [[doom-module::lang rst][rst]]: - -: ReST in peace - -This module adds [[https://docutils.sourceforge.io/rst.html][ReStructured Text]] support to Doom Emacs. - -*** [[doom-module::lang ruby][ruby]]: [[doom-module::lang ruby +chruby][+chruby]] [[doom-module::lang ruby +lsp][+lsp]] [[doom-module::lang ruby +rails][+rails]] [[doom-module::lang ruby +rbenv][+rbenv]] [[doom-module::lang ruby +rvm][+rvm]] -: 1.step {|i| p "Ruby is #{i.even? ? 'love' : 'life'}"} - -This module add Ruby and optional Ruby on Rails support to Emacs. - -- Code completion ([[doom-package:robe]]) -- Syntax checking ([[doom-package:flycheck]]) -- Jump-to-definitions ([[doom-package:robe]]) -- Bundler -- Rubocop integration ([[doom-package:flycheck]]) - -*** [[doom-module::lang rust][rust]]: [[doom-module::lang rust +lsp][+lsp]] -: Fe2O3.unwrap().unwrap().unwrap().unwrap() - -This module adds support for the Rust language and integration for its tools, -e.g. ~cargo~. - -- Code completion ([[doom-package:racer]] or an LSP server) -- Syntax checking ([[doom-package:flycheck]]) -- LSP support (for rust-analyzer and rls) ([[doom-package:rustic]]) -- Snippets - -*** [[doom-module::lang scala][scala]]: [[doom-module::lang scala +lsp][+lsp]] -: Java, but good - -This module adds [[https://www.scala-lang.org][scala]] and [[https://www.scala-sbt.org/][sbt]] support to Doom Emacs. - -Through the power of [[https://scalameta.org/metals/docs/editors/overview.html][Metals]] (LSP) this module offers: -- Goto Definition -- Completions -- Hover -- Paremeter Hints -- Find References -- Run/Debug -- Find Implementations -- Rename Symbol -- Code Actions -- Document Symbols -- Formatting -- Folding -- Organize Imports - -*** [[doom-module::lang scheme][scheme]]: [[doom-module::lang scheme +chez][+chez]] [[doom-module::lang scheme +chibi][+chibi]] [[doom-module::lang scheme +chicken][+chicken]] [[doom-module::lang scheme +gambit][+gambit]] [[doom-module::lang scheme +gauche][+gauche]] [[doom-module::lang scheme +guile][+guile]] [[doom-module::lang scheme +kawa][+kawa]] [[doom-module::lang scheme +mit][+mit]] [[doom-module::lang scheme +racket][+racket]] -: A fully conniving family of lisps - -This module provides support for the Scheme family of Lisp languages, powered by -[[https://www.nongnu.org/geiser/geiser_1.html#introduction][geiser]]. - -*** [[doom-module::lang sh][sh]]: [[doom-module::lang sh +fish][+fish]] [[doom-module::lang sh +lsp][+lsp]] [[doom-module::lang sh +powershell][+powershell]] -: She sells {ba,z,fi}sh shells on the C xor - -This module adds support for shell scripting languages (including Powershell and -Fish script) to Doom Emacs. - -- Code completion ([[doom-package:company-shell]]) -- Syntax Checking ([[doom-package:flycheck]]) - -*** [[doom-module::lang sml][sml]]: - -: ... - -THis module adds [[https://smlfamily.github.io/][SML (Standard ML) programming language]] support to Doom Emacs. - -*** [[doom-module::lang solidity][solidity]]: - -: Do you need a blockchain? No. - -This module adds [[https://github.com/ethereum/solidity][Solidity]] support to Doom Emacs. - -- Syntax-checking ([[doom-package:flycheck]]) -- Code completion ([[doom-package:company-solidity]]) -- Gas estimation (~C-c C-g~) - -*** [[doom-module::lang swift][swift]]: [[doom-module::lang swift +lsp][+lsp]] -: We asked for emoji variables? - -This module adds support for the [[https://developer.apple.com/swift/][Swift programming language]] to Doom Emacs. - -*** [[doom-module::lang terra][terra]]: - -: Earth and Moon in alignment for performance. - -/(No description)/ - -*** [[doom-module::lang web][web]]: [[doom-module::lang web +lsp][+lsp]] -: The tubes - -This module adds support for various web languages, including HTML5, CSS, -SASS/SCSS, Pug/Jade/Slim, and HAML, as well as various web frameworks, like -ReactJS, Wordpress, Jekyll, Phaser, AngularJS, Djano, and more. - -*** [[doom-module::lang yaml][yaml]]: [[doom-module::lang yaml +lsp][+lsp]] -: JSON, but readable - -This module provides support for the [[https://yaml.org/][YAML file format]] to Doom Emacs. - -*** [[doom-module::lang zig][zig]]: [[doom-module::lang zig +lsp][+lsp]] -: C, but simpler - -This module adds [[https://ziglang.org/][Zig]] support, with optional (but recommended) LSP support via -[[https://github.com/zigtools/zls][zls]]. - -- Syntax highlighting -- Syntax-checking ([[doom-package:flycheck]]) -- Code completion and LSP integration (~zls~) - - -** [[doom-module::os][:os]] (2) :unfold: -Modules in this category are designed to improve compatibility with certain -operating systems or OS features (like the shell). - -*** [[doom-module::os macos][macos]]: - -: Compatibility for our favorite walled garden - -This module provides extra functionality for macOS. - -*** [[doom-module::os tty][tty]]: [[doom-module::os tty +osc][+osc]] -: Make TTY Emacs suck less - -This module configures Emacs for use in the terminal, by providing: - -- System clipboard integration (through an external clipboard program or OSC-52 - escape codes in supported terminals). -- Cursor-shape changing across evil states (requires a terminal that supports - it). -- Mouse support in the terminal. - - -** [[doom-module::term][:term]] (4) :unfold: -What's an operating system without a terminal? The modules in this category -bring varying degrees of terminal emulation into Emacs. - -If you can't decide which to choose, I recommend [[doom-package:vterm]] or [[doom-package:eshell]]. [[doom-module::term vterm]] -offers that best terminal emulation available but requires a few extra steps to -get going. [[doom-module::term eshell]] works everywhere that Emacs runs, even Windows, and -provides a shell entirely implemented in Emacs Lisp. - -*** [[doom-module::term eshell][eshell]]: - -: The elisp shell that works everywhere - -This module provides additional features for the built-in [[https://www.gnu.org/software/emacs/manual/html_mono/eshell.html][Emacs Shell]] - -The Emacs Shell or [[doom-package:eshell]] is a shell-like command interpreter implemented in -Emacs Lisp. It is an alternative to traditional shells such as =bash=, =zsh=, -=fish=, etc. that is built into Emacs and entirely cross-platform. - -*** [[doom-module::term shell][shell]]: - -: A REPL for your shell - -Provides a REPL for your shell. - -#+begin_quote - 💡 =shell= is more REPL than terminal emulator. You can edit your command line - like you would any ordinary text in Emacs -- something you can't do in [[doom-package:term]] - (without ~term-line-mode~, which can be unstable) or [[doom-package:vterm]]. - - Due to =shell='s simplicity, you're less likely to encounter edge cases - (e.g. against your shell config), but it's also the least capable. TUI - programs like =htop= or =vim= won't work in shell directly, but will be - launched in a =term= buffer -- which handles them reasonably well. -#+end_quote - -*** [[doom-module::term term][term]]: - -: It's terminal - -/(No description)/ - -*** [[doom-module::term vterm][vterm]]: - -: As good as terminal emulation gets in Emacs - -This module provides a terminal emulator powered by libvterm. It is still in -alpha and requires a component be compiled (=vterm-module.so=). - -#+begin_quote - 💡 [[doom-package:vterm]] is as good as terminal emulation gets in Emacs (at the time of - writing) and the most performant, as it is implemented in C. However, it - requires extra steps to set up: - - - Emacs must be built with dynamic modules support, - - and =vterm-module.so= must be compiled, which depends on =libvterm=, - =cmake=, and =libtool-bin=. - - [[doom-package:vterm]] will try to automatically build =vterm-module.so= when you first open - it, but this will fail on Windows, NixOS and Guix out of the box. Install - instructions for nix/guix can be found in the [[doom-module::term vterm]] module's - documentation. There is no way to install vterm on Windows that I'm aware of - (but perhaps with WSL?). -#+end_quote - - -** [[doom-module::tools][:tools]] (21) :unfold: -Modules that integrate external tools into Emacs. - -*** [[doom-module::tools ansible][ansible]]: - -: Allow silly people to focus on silly things - -/(No description)/ - -*** biblio: - -/(No description)/ - -*** [[doom-module::tools debugger][debugger]]: [[doom-module::tools debugger +lsp][+lsp]] -: Step through code to help you add bugs - -Introduces a code debugger to Emacs, powered by [[doom-package:realgud]] or [[doom-package:dap-mode]] (LSP). - -This document will help you to configure [[doom-package:dap-mode]] [[https://emacs-lsp.github.io/dap-mode/page/configuration/#native-debug-gdblldb][Native Debug(GDB/LLDB)]] as -there is still not *enough* documentation for it. - -*** [[doom-module::tools direnv][direnv]]: - -: Save (or destroy) the environment at your leisure - -This module integrates direnv into Emacs. - -#+begin_quote - 📌 direnv is an environment switcher for the shell. It knows how to hook into - bash, zsh, tcsh, fish shell and elvish to load or unload environment - variables depending on the current directory. This allows project-specific - environment variables without cluttering the ~/.profile file. - - Before each prompt, direnv checks for the existence of a ".envrc" file in - the current and parent directories. If the file exists (and is authorized), - it is loaded into a bash sub-shell and all exported variables are then - captured by direnv and then made available to the current shell. -#+end_quote - -*** [[doom-module::tools docker][docker]]: [[doom-module::tools docker +lsp][+lsp]] -: Yo dawg, I heard you like OSes, so I… - -This module allows you to manipulate Docker images, containers, and more from -Emacs. - -Provides a major ~dockerfile-mode~ to edit =Dockerfiles=. Additional convenience -functions allow images to be built easily. - -[[doom-package:docker-tramp]] offers [[https://www.gnu.org/software/tramp/][TRAMP]] support for Docker containers. - -*** [[doom-module::tools editorconfig][editorconfig]]: - -: Let someone else argue tabs and spaces - -This module integrates [[https://editorconfig.org/][EditorConfig]] into Emacs, allowing users to dictate code -style on a per-project basis with an =.editorconfig= file ([[https://editorconfig-specification.readthedocs.io/][formal -specification]]). - -*** [[doom-module::tools ein][ein]]: - -: Tame Jupyter notebooks with emacs - -Adds [[https://jupyter.org/][Jupyter]] notebook integration into Emacs. - -*** [[doom-module::tools eval][eval]]: [[doom-module::tools eval +overlay][+overlay]] -: Run code, run (also, repls) - -This modules adds inline code evaluation support to Emacs and a universal -interface for opening and interacting with REPLs. - -*** [[doom-module::tools gist][gist]]: - -: A pastebin for Githubsters - -Adds the ability to manage, pull from, or push to your [[https://gist.github.com][Gists]] from within Emacs. - -*** [[doom-module::tools lookup][lookup]]: [[doom-module::tools lookup +dictionary][+dictionary]] [[doom-module::tools lookup +docsets][+docsets]] [[doom-module::tools lookup +offline][+offline]] -: Navigate your labyrinthine code and docs - -This module adds code navigation and documentation lookup tools to help you -quickly look up definitions, references, documentation, dictionary definitions -or synonyms. - -- Jump-to-definition and find-references implementations that just work. -- Powerful xref integration for languages that support it. -- Search online providers like [[https://devdocs.io][devdocs.io]], [[https://stackoverflow.com][stackoverflow]], [[https://google.com][google]], [[https://duckduckgo.com][duckduckgo]], or - [[https://youtube.com][youtube]] (duckduckgo and google have live suggestions). -- Integration with [[https://github.com/Kapeli/feeds][Dash.app docsets]]. -- Support for online (and offline) dictionaries and thesauruses. - -*** [[doom-module::tools lsp][lsp]]: [[doom-module::tools lsp +eglot][+eglot]] [[doom-module::tools lsp +peek][+peek]] -: M-x vscode - -This module integrates [[https://langserver.org/][language servers]] into Doom Emacs. They provide features -you'd expect from IDEs, like code completion, realtime linting, language-aware -[[doom-package:imenu]]/[[doom-package:xref]] integration, jump-to-definition/references support, and more. - -As of this writing, this is the state of LSP support in Doom Emacs: - -| Module | Major modes | Default language server | -|------------------+---------------------------------------------------------+---------------------------------------------------------------| -| [[doom-module::lang cc]] | c-mode, c++-mode, objc-mode | ccls, clangd | -| [[doom-module::lang clojure]] | clojure-mode | clojure-lsp | -| [[doom-module::lang csharp]] | csharp-mode | omnisharp | -| [[doom-module::lang elixir]] | elixir-mode | elixir-ls | -| [[doom-module::lang fsharp]] | fsharp-mode | Mono, .NET core | -| [[doom-module::lang go]] | go-mode | go-langserver | -| [[doom-module::lang haskell]] | haskell-mode | haskell-language-server | -| [[doom-module::lang java]] | java-mode | lsp-java | -| [[doom-module::lang javascript]] | js2-mode, rjsx-mode, typescript-mode | ts-ls, deno-ls | -| [[doom-module::lang julia]] | julia-mode | LanguageServer.jl | -| [[doom-module::lang ocaml]] | tuareg-mode | ocaml-language-server | -| [[doom-module::lang php]] | php-mode | php-language-server | -| [[doom-module::lang purescript]] | purescript-mode | purescript-language-server | -| [[doom-module::lang python]] | python-mode | lsp-python-ms | -| [[doom-module::lang ruby]] | ruby-mode | solargraph | -| [[doom-module::lang rust]] | rust-mode | rls | -| [[doom-module::lang scala]] | scala-mode | metals | -| [[doom-module::lang sh]] | sh-mode | bash-language-server | -| [[doom-module::lang swift]] | swift-mode | sourcekit | -| [[doom-module::lang web]] | web-mode, css-mode, scss-mode, sass-mode, less-css-mode | vscode-css-languageserver-bin, vscode-html-languageserver-bin | -| [[doom-module::lang zig]] | zig-mode | zls | - -*** [[doom-module::tools magit][magit]]: [[doom-module::tools magit +forge][+forge]] -: Wield git like a wizard - -This module provides Magit, an interface to the Git version control system. - -*** [[doom-module::tools make][make]]: - -: The discount build system - -This module adds commands for executing Makefile targets. - -*** [[doom-module::tools pass][pass]]: [[doom-module::tools pass +auth][+auth]] -: A password manager for nerds - -This module provides an Emacs interface to [[https://www.passwordstore.org/][Pass]]. - -*** [[doom-module::tools pdf][pdf]]: - -: Emacs, your next PDF reader - -This module improves support for reading and interacting with PDF files in -Emacs. - -It uses [[doom-package:pdf-tools]], which is a replacement for the built-in ~doc-view-mode~ for -PDF files. The key difference being pages are not pre-rendered, but instead -rendered on-demand and stored in memory; a much faster approach, especially for -larger PDFs. - -Displaying PDF files is just one function of [[doom-package:pdf-tools]]. See [[https://github.com/politza/pdf-tools][its project website]] -for details and videos. - -*** [[doom-module::tools prodigy][prodigy]]: - -: No sweatshop is complete without child processes - -This module provides an interface for managing external services from within -Emacs. - -*** [[doom-module::tools rgb][rgb]]: - -: Creating color strings - -Highlights color hex values and names with the color itself, and provides tools -to easily modify color values or formats. - -*** [[doom-module::tools taskrunner][taskrunner]]: - -: Taskrunner for all your projects - -This module integrates [[doom-package:taskrunner]] into Doom Emacs, which scraps runnable tasks -from build systems like make, gradle, npm and the like. - -*** [[doom-module::tools terraform][terraform]]: - -: Infrastructure as code - -This module adds support for working with [[https://www.terraform.io][Terraform]] files within Emacs. This -includes syntax highlighting, intelligent code completion, and the ability to -run Terraform commands directly from Emacs. - -*** [[doom-module::tools tmux][tmux]]: - -: From one multiplexer to another - -This module provides an API for talking to Tmux sessions. - -*** [[doom-module::tools upload][upload]]: - -: Map local directories to remotes via ssh/ftp - -Uses ~ssh-deploy~ to map a local folder to a remote one. - -From the [[https://github.com/cjohansson/emacs-ssh-deploy/blob/master/README.md][ssh-deploy README]]: -#+begin_quote -The ssh-deploy plug-in for Emacs makes it possible to effortlessly deploy local files and directories to remote hosts via Tramp (including but not limited to SSH, SFTP, FTP). It tries to provide functions that can be easily used by custom scripts. - -The idea for this plug-in was to mimic the behavior of PhpStorm deployment functionality. -#+end_quote - - -** [[doom-module::ui][:ui]] (23) :unfold: -For modules concerned with changing Emacs' appearance or providing interfaces -for its features, like sidebars, tabs, or fonts. - -*** [[doom-module::ui deft][deft]]: - -: Notational velocity for Emacs - -[[https://jblevins.org/projects/deft/][Deft]] is a major mode for creating, browsing, and filtering notes written in -plain text formats, such as org-mode, markdown, and LaTeX. It enables you to -quickly jot down thoughts and easily retrieve them later. - -*** [[doom-module::ui doom][doom]]: - -: Make Doom fabulous again - -This module gives Doom its signature look: powered by the [[doom-package:doom-themes][doom-one]] theme -(loosely inspired by [[https://github.com/atom/one-dark-syntax][Atom's One Dark theme]]) and [[doom-package:solaire-mode]]. Includes: - -- A custom folded-region indicator for [[doom-package:hideshow]]. -- "Thin bar" fringe bitmaps for [[doom-package:git-gutter-fringe]]. -- File-visiting buffers are slightly brighter (thanks to [[doom-package:solaire-mode]]). - -*** [[doom-module::ui doom-dashboard][doom-dashboard]]: - -: Welcome to your doom - -This module adds a minimalistic, Atom-inspired dashboard to Emacs. - -Besides eye candy, the dashboard serves two other purposes: - -1. To improve Doom's startup times (the dashboard is lighter than the scratch - buffer in many cases). - -2. And to preserve the "last open directory" you were in. Occasionally, I kill - the last buffer in my project and I end up who-knows-where (in the working - directory of another buffer/project). It can take some work to find my way - back to where I was. Not with the Dashboard. - - Since the dashboard cannot be killed, and it remembers the working directory - of the last open buffer, ~M-x find-file~ will work from the directory I - expect. - -*** [[doom-module::ui doom-quit][doom-quit]]: - -: One does not simply quit Emacs - -A silly module that throws cute confirmation prompts at you when you exit Emacs, -like DOOM (the game) did. Some quotes are from the classic games, others are -random, nerdy references that no decent human being has any business -recognizing. - -*** [[doom-module::ui emoji][emoji]]: [[doom-module::ui emoji +ascii][+ascii]] [[doom-module::ui emoji +github][+github]] [[doom-module::ui emoji +unicode][+unicode]] -: 💩 - -This module gives Emacs the ability to display and insert emojis (ASCII, Github -style, or unicode styles), as well as convert certain text patterns (e.g. -=:smile:=) into emojis. - -*** [[doom-module::ui hl-todo][hl-todo]]: - -: TODO FIXME NOTE DEPRECATED HACK REVIEW - -This module adds syntax highlighting for various tags in code comments, such as -=TODO=, =FIXME=, and =NOTE=, among others. - -*** [[doom-module::ui hydra][hydra]]: - -: Discount modality for mythological beast hunters - -This module adds hydra to Doom Emacs, as well as a few custom built hydras to -start with: - -- A hydra to control windows ~+hydra/window-nav/body~. -- A hydra to control text zoom level ~+hydra/text-zoom/body~. - -*** [[doom-module::ui indent-guides][indent-guides]]: - -: Line up them indent columns - -/(No description)/ - -*** [[doom-module::ui ligatures][ligatures]]: [[doom-module::ui ligatures +extra][+extra]] [[doom-module::ui ligatures +fira][+fira]] [[doom-module::ui ligatures +hasklig][+hasklig]] [[doom-module::ui ligatures +iosevka][+iosevka]] [[doom-module::ui ligatures +pragmata-pro][+pragmata-pro]] -: Distract folks from your code - -This module enables ligatures and arbitrary symbol substitutions with -~mac-auto-operator-composition-mode~ (on supported macOS systems) or composition -tables (harfbuzz on Emacs 28), falling back on ~prettify-symbols-mode~ -otherwise. - -*** [[doom-module::ui minimap][minimap]]: - -: A map for lost programmers - -This module displays a minimap of the buffer in a sidebar, similar to the -feature found in many other editors. - -*** [[doom-module::ui modeline][modeline]]: [[doom-module::ui modeline +light][+light]] -: Snazzy, Atom-inspired modeline, plus API - -This module provides an Atom-inspired, minimalistic modeline for Doom Emacs, -powered by the [[doom-package:doom-modeline]] package (where you can find screenshots). - -*** [[doom-module::ui nav-flash][nav-flash]]: - -: Blink after big motions - -This module flashes the line around the cursor after any significant motion, to -make it easy to follow after big operations. - -#+begin_quote - 💡 Tremendously helpful on large, 1600p+ or 4K displays. -#+end_quote - -*** [[doom-module::ui neotree][neotree]]: - -: NERDTree for evil nerds - -This module brings a side panel for browsing project files, inspired by vim's -NERDTree. - -#+begin_quote - 💡 Sure, there's [[doom-package:dired]] and [[doom-package:projectile]], but sometimes I'd like a bird's eye view - of a project. -#+end_quote - -*** [[doom-module::ui ophints][ophints]]: - -: An indicator for “what did I just do?” - -This module provides op-hints (operation hinting), i.e. visual feedback for -certain operations. It highlights regions of text that the last operation (like -yank) acted on. - -Uses [[doom-package:evil-goggles]] for evil users and [[doom-package:volatile-highlights]] otherwise. - -*** [[doom-module::ui popup][popup]]: [[doom-module::ui popup +all][+all]] [[doom-module::ui popup +defaults][+defaults]] -: Tame sudden yet inevitable temporary windows - -This module provides a customizable popup window management system. - -Not all windows are created equally. Some are less important. Some I want gone -once they have served their purpose, like code output or a help buffer. Others I -want to stick around, like a scratch buffer or org-capture popup. - -More than that, popups ought to be the second class citizens of my editor; -spawned off to the side, discarded with the push of a button (e.g. [[kbd:][ESC]] or [[kbd:][C-g]]), -and easily restored if I want to see them again. Of course, this system should -clean up after itself and kill off buffers I mark as transient. - -*** [[doom-module::ui tabs][tabs]]: - -: Keep tabs on your buffers, literally - -This module adds an Atom-esque tab bar to the Emacs UI. - -*** [[doom-module::ui treemacs][treemacs]]: [[doom-module::ui treemacs +lsp][+lsp]] -: A sidebar for all the things - -[[doom-package:treemacs][Treemacs]] is a file and project explorer similar to NeoTree or vim's NerdTree, -but largely inspired by the Project Explorer in Eclipse. It shows the file -system outlines of your projects in a simple tree layout allowing quick -navigation and exploration, while also possessing basic file management -utilities. It includes: - -- Integration with Git (if [[doom-module::tools magit]] is enabled) -- Integration with Evil (if [[doom-module::editor evil +everywhere]] is enabled) -- Workspace awareness (if [[doom-module::ui workspaces]] is enabled) - -*** [[doom-module::ui unicode][unicode]]: - -: Extended unicode support for various languages - -This module extends Doom's ability to display non-English unicode. It is -primarily useful for non-English Emacs users, for whom Doom's built-in unicode -support in insufficient. - -This module relies on the [[https://github.com/rolandwalker/unicode-fonts][unicode-fonts]] package. It tries to setup the default -emacs fontset to cover as many unicode glyphs as possible by scanning all -available glyphs from all available fonts. - -When this module is enabled: -- Emacs will prefer to use the ~doom-unicode-font~ font to display non-latin - glyphs if it provides coverage for them. -- The first time you run Emacs a unicode cache will be generated -- this will - take a while! -- The cache will be regenerated every time Emacs is made aware of new fonts or - you change the font configuration e.g. by modifying ~doom-unicode-font~. -- The cache will be stored and should not be regenerated unless font-related - configuration or the versions of relevant packages changes. - -*** [[doom-module::ui vc-gutter][vc-gutter]]: - -: Get your diff out of the gutter - -This module displays a diff of the current file (against HEAD) in the fringe. -Supports Git, Svn, Hg, and Bzr. - -*** [[doom-module::ui vi-tilde-fringe][vi-tilde-fringe]]: - -: Fringe tildes beyond EOB - -Displays a tilde(~) in the left fringe to indicate an empty line, similar to Vi. - -*** [[doom-module::ui window-select][window-select]]: [[doom-module::ui window-select +numbers][+numbers]] [[doom-module::ui window-select +switch-window][+switch-window]] -: Visually switch windows - -This module provides several methods for selecting windows without the use of -the mouse or spatial navigation (e.g. [[kbd:][C-w {h,j,k,l}]]). - -The command ~other-window~ is remapped to either [[doom-package:switch-window]] or [[doom-package:ace-window]], -depending on which backend you've enabled. It is bound to [[kbd:][C-x o]] (and [[kbd:][C-w C-w]] for -evil users). - -It also provides numbered windows and selection with the [[doom-package:winum]] package, if -desired. Evil users can jump to window N in [[kbd:][C-w <N>]] (where N is a number between -0 and 9). Non evil users have [[kbd:][C-x w <N>]] instead. - -*** [[doom-module::ui workspaces][workspaces]]: - -: Tab emulation, persistence, & separate workspaces - -This module adds support for workspaces, powered by [[doom-package:persp-mode]], as well as a API -for manipulating them. - -#+begin_quote - 💡 There are many ways to use workspaces. I spawn a workspace per task. Say I'm - working in the main workspace, when I realize there is a bug in another part - of my project. I open a new workspace and deal with it in there. In the - meantime, I need to check my email, so mu4e gets its own workspace. - - Once I've completed the task, I close the workspace and return to main. -#+end_quote - -*** [[doom-module::ui zen][zen]]: - -: Distraction-free mode for the eternally distracted - -This module provides two minor modes that make Emacs into a more comfortable -writing or coding environment. Folks familiar with "distraction-free" or "zen" -modes from other editors -- or [[doom-package:olivetti]], [[doom-package:sublimity]], and [[doom-package:tabula-rasa]] (Emacs -plugins) -- will feel right at home. - -These modes are: -- ~mixed-pitch-mode~ :: - Which renders (most) text in a variable pitch font (see - ~doom-variable-pitch-font~). Unlike ~variable-pitch-mode~, this will not - affect segments of text that are intended to remain in a fixed pitch font, - such as code blocks or ASCII tables. -- ~writeroom-mode~ :: - Our all-in-one "zen" mode that will: - 1. Center the current buffer. - 2. Remove superfluous UI elements (like the modeline). - 3. Activate ~mixed-pitch-mode~. - 4. Scale up the buffer's text slightly (see ~+zen-text-scale~). - 5. And make the window's borders slightly thicker (see - ~+zen-window-divider-size~). - - diff --git a/.config/emacs/modules/app/README.org b/.config/emacs/modules/app/README.org @@ -1,11 +0,0 @@ -#+title: :app -#+created: February 19, 2017 -#+since: 21.12.0 - -* Description -Application modules are complex and opinionated modules that transform Emacs -toward a specific purpose. They may have additional dependencies and *should be -loaded last* (but before [[doom-module::config]] modules). - -* Frequently asked questions -/This category has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] diff --git a/.config/emacs/modules/app/calendar/README.org b/.config/emacs/modules/app/calendar/README.org @@ -1,78 +0,0 @@ -#+title: :app calendar -#+subtitle: Watch your missed deadlines in real time -#+created: January 13, 2018 -#+since: 21.12.0 (#355) - -* Description :unfold: -This module adds a calendar view for Emacs, with org and google calendar sync -support. - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:calfw]] -- [[doom-package:calfw-org]] -- [[doom-package:org-gcal]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires: -- A Google Calendar account. -- [[https://github.com/kidd/org-gcal.el#installation][An OAuth client ID]], for syncing said account with [[doom-package:org-gcal]]. - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** Changing calendar sources -By defining your own calendar commands, you can control what sources to pull -calendar data from: -#+begin_src emacs-lisp -(defun my-open-calendar () - (interactive) - (cfw:open-calendar-buffer - :contents-sources - (list - (cfw:org-create-source "Green") ; org-agenda source - (cfw:org-create-file-source "cal" "/path/to/cal.org" "Cyan") ; other org source - (cfw:howm-create-source "Blue") ; howm source - (cfw:cal-create-source "Orange") ; diary source - (cfw:ical-create-source "Moon" "~/moon.ics" "Gray") ; ICS source1 - (cfw:ical-create-source "gcal" "https://..../basic.ics" "IndianRed") ; google calendar ICS - ))) -#+end_src - -The [[https://github.com/kiwanami/emacs-calfw][kiwanami/emacs-calfw]] project readme contains more examples. - -** Synchronizing Org and Google Calendar -The [[https://github.com/kidd/org-gcal.el][kidd/org-gcal.el]] project README contains more detailed instructions on how -to link your calendar with Google calendars. - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/app/calendar/autoload.el b/.config/emacs/modules/app/calendar/autoload.el @@ -1,69 +0,0 @@ -;;; app/calendar/autoload.el -*- lexical-binding: t; -*- - -(defvar +calendar--wconf nil) -(defvar +calendar-workspace-name "*calendar*" - "Name of the workspace created by `=calendar', dedicated to calfw.") - -(defun +calendar--init () - (if-let (win (cl-find-if (lambda (b) (string-match-p "^\\*cfw:" (buffer-name b))) - (doom-visible-windows) - :key #'window-buffer)) - (select-window win) - (call-interactively +calendar-open-function))) - -;;;###autoload -(defun =calendar () - "Activate (or switch to) `calendar' in its workspace." - (interactive) - (if (modulep! :ui workspaces) - (progn - (+workspace-switch +calendar-workspace-name t) - (unless (memq (buffer-local-value 'major-mode - (window-buffer (selected-window))) - '(cfw:details-mode - cfw:calendar-mode)) - (doom/switch-to-scratch-buffer) - (+calendar--init)) - (+workspace/display)) - (setq +calendar--wconf (current-window-configuration)) - (delete-other-windows) - (switch-to-buffer (doom-fallback-buffer)) - (+calendar--init))) - -;;;###autoload -(defun +calendar/quit () - "TODO" - (interactive) - (if (modulep! :ui workspaces) - (when (+workspace-exists-p +calendar-workspace-name) - (+workspace/delete +calendar-workspace-name)) - (when (window-configuration-p +calendar--wconf) - (set-window-configuration +calendar--wconf)) - (setq +calendar--wconf nil)) - (doom-kill-matching-buffers "^\\*cfw[:-]")) - -;;;###autoload -(defun +calendar/open-calendar () - "TODO" - (interactive) - (cfw:open-calendar-buffer - ;; :custom-map cfw:my-cal-map - :contents-sources - (list - (cfw:org-create-source (face-foreground 'default)) ; orgmode source - ))) - -;;;###autoload -(defun +calendar-cfw:render-button-a (title command &optional state) - "render-button - TITLE - COMMAND - STATE" - (let ((text (concat " " title " ")) - (keymap (make-sparse-keymap))) - (cfw:rt text (if state 'cfw:face-toolbar-button-on - 'cfw:face-toolbar-button-off)) - (define-key keymap [mouse-1] command) - (cfw:tp text 'keymap keymap) - (cfw:tp text 'mouse-face 'highlight) - text)) diff --git a/.config/emacs/modules/app/calendar/config.el b/.config/emacs/modules/app/calendar/config.el @@ -1,94 +0,0 @@ -;;; app/calendar/config.el -*- lexical-binding: t; -*- - -(defvar +calendar-open-function #'+calendar/open-calendar - "TODO") - - -;; -;; Packages - -(use-package! calfw - :commands cfw:open-calendar-buffer - :config - ;; better frame for calendar - (setq cfw:face-item-separator-color nil - cfw:render-line-breaker 'cfw:render-line-breaker-none - cfw:fchar-junction ?╋ - cfw:fchar-vertical-line ?┃ - cfw:fchar-horizontal-line ?━ - cfw:fchar-left-junction ?┣ - cfw:fchar-right-junction ?┫ - cfw:fchar-top-junction ?┯ - cfw:fchar-top-left-corner ?┏ - cfw:fchar-top-right-corner ?┓) - - (set-popup-rule! "^\\*cfw:details" :quit t :ttl 0 :select t :size 0.4) - - (define-key cfw:calendar-mode-map "q" #'+calendar/quit) - (when (modulep! :editor evil +everywhere) - (set-evil-initial-state! '(cfw:calendar-mode cfw:details-mode) 'motion) - (add-hook! (cfw:calendar-mode cfw:details-mode) #'evil-normalize-keymaps) - (map! (:map cfw:calendar-mode-map - :m "q" #'+calendar/quit - :m "SPC" #'cfw:show-details-command - :m "RET" #'cfw:show-details-command - :m "TAB" #'cfw:navi-prev-item-command - :m [tab] #'cfw:navi-prev-item-command - :m [backtab] #'cfw:navi-next-item-command - :m "$" #'cfw:navi-goto-week-end-command - :m "." #'cfw:navi-goto-today-command - :m "<" #'cfw:navi-previous-month-command - :m ">" #'cfw:navi-next-month-command - :m "C-h" #'cfw:navi-previous-month-command - :m "C-l" #'cfw:navi-next-month-command - :m "D" #'cfw:change-view-day - :m "M" #'cfw:change-view-month - :m "T" #'cfw:change-view-two-weeks - :m "W" #'cfw:change-view-week - :m "^" #'cfw:navi-goto-week-begin-command - :m "gr" #'cfw:refresh-calendar-buffer - :m "h" #'cfw:navi-previous-day-command - :m "H" #'cfw:navi-goto-first-date-command - :m "j" #'cfw:navi-next-week-command - :m "k" #'cfw:navi-previous-week-command - :m "l" #'cfw:navi-next-day-command - :m "L" #'cfw:navi-goto-last-date-command - :m "t" #'cfw:navi-goto-today-command) - (:map cfw:details-mode-map - :m "SPC" #'cfw:details-kill-buffer-command - :m "RET" #'cfw:details-kill-buffer-command - :m "TAB" #'cfw:details-navi-prev-item-command - :m [tab] #'cfw:details-navi-prev-item-command - :m [backtab] #'cfw:details-navi-next-item-command - :m "q" #'cfw:details-kill-buffer-command - :m "C-h" #'cfw:details-navi-prev-command - :m "C-l" #'cfw:details-navi-next-command - :m "C-k" #'cfw:details-navi-prev-item-command - :m "C-j" #'cfw:details-navi-next-item-command))) - - (add-hook 'cfw:calendar-mode-hook #'doom-mark-buffer-as-real-h) - (add-hook 'cfw:calendar-mode-hook #'hide-mode-line-mode) - - (advice-add #'cfw:render-button :override #'+calendar-cfw:render-button-a)) - - -(use-package! calfw-org - :commands (cfw:open-org-calendar - cfw:org-create-source - cfw:org-create-file-source - cfw:open-org-calendar-withkevin)) - - -(use-package! calfw-cal - :commands (cfw:cal-create-source)) - - -(use-package! calfw-ical - :commands (cfw:ical-create-source)) - - -(use-package! org-gcal - :defer t - :init - (defvar org-gcal-dir (concat doom-cache-dir "org-gcal/")) - (defvar org-gcal-token-file (concat org-gcal-dir "token.gpg"))) diff --git a/.config/emacs/modules/app/calendar/packages.el b/.config/emacs/modules/app/calendar/packages.el @@ -1,8 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; app/calendar/packages.el - -(package! calfw :pin "03abce97620a4a7f7ec5f911e669da9031ab9088") -(package! calfw-org :pin "03abce97620a4a7f7ec5f911e669da9031ab9088") -(package! calfw-cal :pin "03abce97620a4a7f7ec5f911e669da9031ab9088") -(package! calfw-ical :pin "03abce97620a4a7f7ec5f911e669da9031ab9088") -(package! org-gcal :pin "9bb3720525ad1c45823abab8ce910dd1225e7dcd") diff --git a/.config/emacs/modules/app/emms/README.org b/.config/emacs/modules/app/emms/README.org @@ -1,74 +0,0 @@ -#+title: :app emms -#+subtitle: A media player for music no one's heard of -#+created: March 06, 2021 -#+since: 21.12.0 (#3581) - -* Description :unfold: -This module enables Emacs to be used as a music player. It uses [[https://www.musicpd.org/][mpd]] as a backend -server and [[https://musicpd.org/clients/mpc/][mpc]] to update your music database. - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:emms]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires: -- [[https://mpd.readthedocs.io/en/stable/user.html#installation][mpd]] (and a running mpd server) -- [[https://www.musicpd.org/clients/mpc/][mpc]] - -These should be available through your OS package manager. - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** Keybinds -- [[kbd:][<localleader> l]] Toggles whether or not the player repeats the playlist. -- [[kbd:][<localleader> m]] Mixes the playlist. -- [[kbd:][<localleader> i]] Insert specific song -- [[kbd:][<localleader> s]] Save the current playlist to a file -- [[kbd:][<localleader> p]] Insert playlist save into current playlist -- [[kbd:][g a]] Sort the browser by artists -- [[kbd:][g b]] Sort the browser by genre -- [[kbd:][X]] Stops the player -- [[kbd:][x]] pauses the player -- [[kbd:][D]] in the playlist window removes that item -- [[kbd:][C]] clears the playlist -- [[kbd:][>]] move five seconds forward in the current track -- [[kbd:][<]] Opposite five back -- [[kbd:][RET]] In browser adds the artist's songs to the playlist, in the playlist starts - playlist. - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -[[doom-report:][Report an issue?]] - -** New music files not showing up in database -Try [[kbd:][M-x +emms/mpd-restart-music-daemon]] then restart emacs. - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/app/emms/autoload.el b/.config/emacs/modules/app/emms/autoload.el @@ -1,30 +0,0 @@ -;;; app/emms/autoload.el -*- lexical-binding: t; -*- - -;;;###autoload -(defun +emms/mpd-start-music-daemon () - (interactive) - (start-process "mpd" nil "mpd") - (+emms/mpc-update-database) - (emms-player-mpd-connect) - (emms-cache-set-from-mpd-all) - (message "MPD Started!")) - -;;;###autoload -(defun +emms/mpd-kill-music-daemon () - (interactive) - (emms-stop) - (call-process "mpd" nil nil nil "--kill") - (message "MPD Killed!")) - -;;;###autoload -(defun +emms/mpc-update-database () - (interactive) - (call-process "mpc" nil nil nil "update") - (message "MPD Database Updated!")) - -;;;###autoload -(defun +emms/mpd-restart-music-daemon () - (interactive) - (+emms/mpd-kill-music-daemon) - (+emms/mpd-start-music-daemon) - (message "MPD Restarted!")) diff --git a/.config/emacs/modules/app/emms/config.el b/.config/emacs/modules/app/emms/config.el @@ -1,18 +0,0 @@ -;;; app/emms/config.el -*- lexical-binding: t; -*- - -(use-package! emms - :defer t - :init - (setq emms-directory (concat doom-data-dir "emms") - emms-cache-file (concat doom-cache-dir "emms")) - :config - (emms-all) - (emms-default-players) - (map! :map emms-playlist-mode-map - :localleader - "l" #'emms-toggle-repeat-playlist - "p" #'emms-insert-playlist - "i" #'emms-insert-file - "t" #'emms-toggle-repeat-track - "s" #'emms-playlist-save - "m" #'emms-shuffle)) diff --git a/.config/emacs/modules/app/emms/packages.el b/.config/emacs/modules/app/emms/packages.el @@ -1,4 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; app/emms/packages.el - -(package! emms :pin "43c61412492229eb641fe572c89c826d8fcf64d9") diff --git a/.config/emacs/modules/app/everywhere/README.org b/.config/emacs/modules/app/everywhere/README.org @@ -1,72 +0,0 @@ -#+title: :app everywhere -#+subtitle: *leave* Emacs!? You must be joking -#+created: February 07, 2021 -#+since: 21.12.0 (#4630) - -* Description :unfold: -This module adds system-wide popup Emacs windows for quick edits. - -** Maintainers -- [[doom-user:][@tecosaur]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:emacs-everywhere]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires: -- *On Linux:* (these should be available through your OS package manager) - - =xclip= - - =xdotool= - - =xprop= - - =xwininfo= -- *On MacOS:* that Emacs is allowed to "control your computer" under *System - Preferences > Accessibility*. - -* Usage -To use this, invoke the =emacs-everywhere= executable. This can be done in two -ways: -- ~$ emacsclient --eval "(emacs-everywhere)"~ -- ~$ doom +everywhere~ - -It is recommended that you add a keybinding for this. - -From here, you can edit away to your hearts content in the created frame, then -return to the original window and paste the content with [[kbd:][C-c C-c]] or [[kbd:][SPC q f]]. To -exit without pasting, use [[kbd:][C-c C-k]]. - -* Configuration -[[doom-package:emacs-everywhere]] likes to guess if you triggered it from an application which -supports markdown. Configure ~emacs-everywhere-markdown-windows~ and -~emacs-everywhere-markdown-apps~ to improve how accurate this is on your system. - -By default, when markdown is detected, ~markdown-mode~ is used. It is possible -to instead use pandoc to convert the content to Org (and export to markdown when -closing the frame) by setting ~emacs-everywhere-major-mode-function~ to -~#'org-mode~. - -Most other behavior is implemented as hooks on ~emacs-everywhere-init-hooks~. - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/app/everywhere/cli.el b/.config/emacs/modules/app/everywhere/cli.el @@ -1,5 +0,0 @@ -;;; app/everywhere/cli.el -*- lexical-binding: t; -*- - -(defcli! () () - "Spawn an emacsclient window for quick edits." - (exit! "emacsclient --eval '(emacs-everywhere)'")) diff --git a/.config/emacs/modules/app/everywhere/config.el b/.config/emacs/modules/app/everywhere/config.el @@ -1,47 +0,0 @@ -;;; app/everywhere/config.el -*- lexical-binding: t; -*- - -(use-package! emacs-everywhere - ;; Entry points into this package are autoloaded; i.e. the `emacs-everywhere' - ;; function, meant to be called directly via emacsclient. See this module's - ;; readme for details. - :defer t - :config - (set-yas-minor-mode! 'emacs-everywhere-mode) - - ;; HACK Inhibit MAJOR-MODE-local-vars-hook in emacs-everywhere buffers, - ;; because Doom commonly starts servers and other extraneous services on - ;; this hook, which will rarely work well in emacs-everywhere's temporary - ;; buffers anyway. - (setq-hook! 'emacs-everywhere-init-hooks doom-inhibit-local-var-hooks t) - - (after! doom-modeline - (doom-modeline-def-segment emacs-everywhere - (concat - (doom-modeline-spc) - (when (emacs-everywhere-markdown-p) - (concat - (all-the-icons-octicon "markdown" :face 'all-the-icons-green :v-adjust 0.02) - (doom-modeline-spc))) - (propertize (emacs-everywhere-app-class emacs-everywhere-current-app) - 'face 'doom-modeline-project-dir) - (doom-modeline-spc) - (propertize (truncate-string-to-width - (emacs-everywhere-app-title emacs-everywhere-current-app) - 45 nil nil "…") - 'face 'doom-modeline-buffer-minor-mode))) - (doom-modeline-def-modeline 'emacs-everywhere - '(bar modals emacs-everywhere buffer-position - word-count parrot selection-info) - '(input-method major-mode checker - #(" " 0 1 ; "Exit to app" icon + a little padding - (rear-nonsticky t - display (raise -0.25) - face (:inherit doom-modeline-emphasis :family "Material Icons" :height 1.1) - help-echo "This is an Emacs Everywhere window")))) - (add-hook! 'emacs-everywhere-mode-hook - (defun +everywhere-set-modeline () - (doom-modeline-set-modeline 'emacs-everywhere)))) - (add-hook! 'emacs-everywhere-init-hooks - (defun +everywhere-clear-persp-info-h () - (when (bound-and-true-p persp-mode) - (setq persp-emacsclient-init-frame-behaviour-override nil))))) diff --git a/.config/emacs/modules/app/everywhere/doctor.el b/.config/emacs/modules/app/everywhere/doctor.el @@ -1,12 +0,0 @@ -;;; app/everywhere/doctor.el -*- lexical-binding: t; -*- - -(when IS-WINDOWS - (error! "emacs-everywhere package does not support windows.")) - -(when IS-LINUX - (let (unmet-deps) - (dolist (dep '("xclip" "xdotool" "xprop" "xwininfo")) - (unless (executable-find dep) - (push dep unmet-deps))) - (when unmet-deps - (error! "Unmet dependencies: %s" (string-join unmet-deps ", "))))) diff --git a/.config/emacs/modules/app/everywhere/packages.el b/.config/emacs/modules/app/everywhere/packages.el @@ -1,4 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; app/everywhere/packages.el - -(package! emacs-everywhere :pin "b461c4b42093abc42e5ec0f73cb7021c2915cea8") diff --git a/.config/emacs/modules/app/irc/README.org b/.config/emacs/modules/app/irc/README.org @@ -1,173 +0,0 @@ -#+title: :app irc -#+subtitle: How neckbeards socialize -#+created: June 11, 2017 -#+since: 2.0.3 - -* Description :unfold: -This module turns Emacs into an IRC client, capable of OS notifications. - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:circe]] -- [[doom-package:circe-notifications]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires: -- [[https://www.gnutls.org/][GnuTLS]], for secure IRC connections to work. - -This should be available through your OS package manager. - -** macOS -#+begin_src sh -brew install gnutls -#+end_src - -** Debian / Ubuntu -#+begin_src sh -apt install gnutls-bin -#+end_src - -** Arch Linux -#+begin_src sh -pacman -S gnutls -#+end_src -** NixOS -#+begin_src nix -environment.systemPackages = [ pkgs.gnutls ]; -#+end_src - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -To connect to IRC use ~M-x =irc~. - -When in a circe buffer these keybindings will be available: -| command | key | description | -|-----------------------------+-----------------+----------------------------------------------| -| ~+irc/tracking-next-buffer~ | [[kbd:][<localleader> a]] | Switch to the next active buffer | -| ~circe-command-JOIN~ | [[kbd:][<localleader> j]] | Join a channel | -| ~+irc/send-message~ | [[kbd:][<localleader> m]] | Send a private message | -| ~circe-command-NAMES~ | [[kbd:][<localleader> n]] | List the names of the current channel | -| ~circe-command-PART~ | [[kbd:][<localleader> p]] | Part the current channel | -| ~+irc/quit~ | [[kbd:][<localleader> Q]] | Kill the current circe session and workgroup | -| ~circe-reconnect~ | [[kbd:][<localleader> R]] | Reconnect the current server | - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -Use ~set-irc-server! SERVER PLIST~ to configure IRC servers. Its second argument -(a plist) takes the same arguments as ~circe-network-options~: -#+begin_src emacs-lisp -;; if you omit =:host=, ~SERVER~ will be used instead. -(after! circe - (set-irc-server! "irc.libera.chat" - `(:tls t - :port 6697 - :nick "doom" - :sasl-username "myusername" - :sasl-password "mypassword" - :channels ("#emacs")))) -#+end_src - -However, *it is a obviously a bad idea to store your password in plaintext,* so -here are ways to avoid that: - -** TODO Pass: the unix password manager -#+begin_quote - 🔨 /This section is outdated and needs to be rewritten./ [[doom-contrib-module:][Rewrite it?]] -#+end_quote - -[[https://www.passwordstore.org/][Pass]] is my tool of choice. I use it to manage my passwords. If you activate the -[[doom-module::tools pass]] module you get an elisp API through which to access your password -store. - -~set-irc-server!~ accepts a plist can use functions instead of strings. -~+pass-get-user~ and ~+pass-get-secret~ can help here: -#+begin_src emacs-lisp -(set-irc-server! "irc.libera.chat" - `(:tls t - :port 6697 - :nick "doom" - :sasl-username ,(+pass-get-user "irc/libera.chat") - :sasl-password ,(+pass-get-secret "irc/libera.chat") - :channels ("#emacs"))) -#+end_src - -But wait, there's more! This stores your password in a public variable which -could be accessed or appear in backtraces. Not good! So we go a step further: -#+begin_src emacs-lisp -(set-irc-server! "irc.libera.chat" - `(:tls t - :port 6697 - :nick "doom" - :sasl-username ,(+pass-get-user "irc/libera.chat") - :sasl-password (lambda (&rest _) (+pass-get-secret "irc/libera.chat")) - :channels ("#emacs"))) -#+end_src - -And you're good to go! - -Note that ~+pass-get-user~ tries to find your username by looking for the fields -listed in ~+pass-user-fields~ (by default =login=, =user==, =username== and -=email=)=). An example configuration looks like - -#+begin_example -mysecretpassword -username: myusername -#+end_example - -** Emacs' auth-source API -~auth-source~ is built into Emacs. As suggested [[https://github.com/jorgenschaefer/circe/wiki/Configuration#safer-password-management][in the circe wiki]], you can store -(and retrieve) encrypted passwords with it. -#+begin_src emacs-lisp -(setq auth-sources '("~/.authinfo.gpg")) - -(defun my-fetch-password (&rest params) - (require 'auth-source) - (let ((match (car (apply #'auth-source-search params)))) - (if match - (let ((secret (plist-get match :secret))) - (if (functionp secret) - (funcall secret) - secret)) - (error "Password not found for %S" params)))) - -(defun my-nickserv-password (server) - (my-fetch-password :user "forcer" :host "irc.libera.chat")) - -(set-irc-server! "irc.libera.chat" - '(:tls t - :port 6697 - :nick "doom" - :sasl-password my-nickserver-password - :channels ("#emacs"))) -#+end_src - -* TODO Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/app/irc/autoload/irc.el b/.config/emacs/modules/app/irc/autoload/irc.el @@ -1,112 +0,0 @@ -;;; app/irc/autoload/email.el -*- lexical-binding: t; -*- - -(defvar +irc--workspace-name "*IRC*") - -(defun +irc-setup-wconf (&optional inhibit-workspace) - (when (and (modulep! :ui workspaces) - (not inhibit-workspace)) - (+workspace-switch +irc--workspace-name 'auto-create)) - (let ((buffers (doom-buffers-in-mode 'circe-mode nil t))) - (if (not (member (window-buffer) buffers)) - (if buffers - (ignore (switch-to-buffer (car buffers))) - (require 'circe) - (delete-other-windows) - (switch-to-buffer (doom-fallback-buffer)) - t)))) - -;;;###autoload -(defun =irc (&optional inhibit-workspace) - "Connect to IRC and auto-connect to all registered networks. - -If INHIBIT-WORKSPACE (the universal argument) is non-nil, don't spawn a new -workspace for it." - (interactive "P") - (+irc-setup-wconf inhibit-workspace) - (cond ((doom-buffers-in-mode 'circe-mode (doom-buffer-list) t) - (message "Circe buffers are already open")) - (circe-network-options - (mapc #'circe (mapcar #'car circe-network-options))) - ((call-interactively #'circe)))) - -;;;###autoload -(defun +irc/connect (&optional inhibit-workspace) - "Connect to a specific registered server. - -If INHIBIT-WORKSPACE (the universal argument) is non-nil, don't spawn a new -workspace for it." - (interactive "P") - (and (+irc-setup-wconf inhibit-workspace) - (call-interactively #'circe))) - -;;;###autoload -(defun +irc/send-message (who what) - "Send WHO a message containing WHAT." - (interactive "sWho: \nsWhat: ") - (circe-command-MSG who what)) - -;;;###autoload -(defun +irc/quit () - "Kill current circe session and workgroup." - (interactive) - (unless (y-or-n-p "Really kill IRC session?") - (user-error "Aborted")) - (let (circe-channel-killed-confirmation - circe-server-killed-confirmation) - (when +irc--defer-timer - (cancel-timer +irc--defer-timer)) - (disable-circe-notifications) - (mapc #'kill-buffer (doom-buffers-in-mode 'circe-mode (buffer-list) t)) - (when (modulep! :ui workspaces) - (when (equal (+workspace-current-name) +irc--workspace-name) - (+workspace/delete +irc--workspace-name))))) - -;;;###autoload -(defun +irc/jump-to-channel (&optional this-server) - "Jump to an open channel or server buffer. If THIS-SERVER (universal -argument) is non-nil only show channels in current server." - (interactive "P") - (call-interactively - (cond ((modulep! :completion ivy) #'+irc/ivy-jump-to-channel) - ((modulep! :completion vertico) #'+irc/vertico-jump-to-channel) - ((user-error "No jump-to-channel backend is enabled. Enable vertico or ivy!"))))) - -;;;###autoload -(defun +irc--circe-all-buffers () - (cl-loop with servers = (circe-server-buffers) - for server in servers - collect server - nconc - (with-current-buffer server - (cl-loop for buf in (circe-server-chat-buffers) - collect buf)))) - -;;;###autoload -(defun +irc/tracking-next-buffer () - "Disables switching to an unread buffer unless in the irc workspace." - (interactive) - (when (derived-mode-p 'circe-mode) - (tracking-next-buffer))) - - -;; -;;; Hooks/fns - -;;;###autoload -(defun +circe-buffer-p (buf) - "Return non-nil if BUF is a `circe-mode' buffer." - (with-current-buffer buf - (derived-mode-p 'circe-mode))) - -;;;###autoload -(defun +irc--add-circe-buffer-to-persp-h () - (when (and (bound-and-true-p persp-mode) - (+workspace-exists-p +irc--workspace-name)) - (let ((persp (get-current-persp)) - (buf (current-buffer))) - ;; Add a new circe buffer to irc workspace when we're in another workspace - (unless (eq (safe-persp-name persp) +irc--workspace-name) - ;; Add new circe buffers to the persp containing circe buffers - (persp-add-buffer buf (persp-get-by-name +irc--workspace-name)) - ;; Remove new buffer from accidental workspace - (persp-remove-buffer buf persp))))) diff --git a/.config/emacs/modules/app/irc/autoload/ivy.el b/.config/emacs/modules/app/irc/autoload/ivy.el @@ -1,30 +0,0 @@ -;;; app/irc/autoload/ivy.el -*- lexical-binding: t; -*- -;;;###if (modulep! :completion ivy) - -;;;###autoload -(defun +irc/ivy-jump-to-channel (&optional this-server) - "Jump to an open channel or server buffer with ivy. If THIS-SERVER (universal -argument) is non-nil only show channels in current server." - (interactive "P") - (if (not (circe-server-buffers)) - (message "No circe buffers available") - (when (and this-server (not circe-server-buffer)) - (setq this-server nil)) - (ivy-read (format "Jump to%s: " (if this-server (format " (%s)" (buffer-name circe-server-buffer)) "")) - (cl-loop with servers = (if this-server (list circe-server-buffer) (circe-server-buffers)) - with current-buffer = (current-buffer) - for server in servers - collect (buffer-name server) - nconc - (with-current-buffer server - (cl-loop for buf in (circe-server-chat-buffers) - unless (eq buf current-buffer) - collect (format " %s" (buffer-name buf))))) - :action #'+irc--ivy-switch-to-buffer-action - :preselect (buffer-name (current-buffer)) - :keymap ivy-switch-buffer-map - :caller '+irc/ivy-jump-to-channel))) - -(defun +irc--ivy-switch-to-buffer-action (buffer) - (when (stringp buffer) - (ivy--switch-buffer-action (string-trim-left buffer)))) diff --git a/.config/emacs/modules/app/irc/autoload/settings.el b/.config/emacs/modules/app/irc/autoload/settings.el @@ -1,18 +0,0 @@ -;;; app/irc/autoload/settings.el -*- lexical-binding: t; -*- - -;;;###autodef -(defun set-irc-server! (server plist) - "Registers an irc SERVER for circe. - -SERVER can either be a name for the network (in which case you must specify a -:host), or it may be the hostname itself, in which case it will be used as the -:host. - -See `circe-network-options' for details." - (declare (indent 1)) - (after! circe - (unless (plist-member plist :host) - (cl-callf plist-put plist :host server)) - (setf (alist-get server circe-network-options - nil nil #'equal) - plist))) diff --git a/.config/emacs/modules/app/irc/autoload/vertico.el b/.config/emacs/modules/app/irc/autoload/vertico.el @@ -1,23 +0,0 @@ -;;; app/irc/autoload/vertico.el -*- lexical-binding: t; -*- -;;;###if (modulep! :completion vertico) - -;;;###autoload -(defun +irc/vertico-jump-to-channel () - "Jump to an open channel or server buffer with vertico." - (interactive) - (require 'consult) - (consult--multi (list (plist-put (copy-sequence +irc--consult-circe-source) - :hidden nil)) - :narrow nil - :require-match t - :prompt "Jump to:" - :sort nil)) - -;;;###autoload -(defvar +irc--consult-circe-source - `(:name "circe" - :hidden t - :narrow ?c - :category buffer - :state ,#'consult--buffer-state - :items ,(lambda () (mapcar #'buffer-name (+irc--circe-all-buffers))))) diff --git a/.config/emacs/modules/app/irc/config.el b/.config/emacs/modules/app/irc/config.el @@ -1,258 +0,0 @@ -;;; app/irc/config.el -*- lexical-binding: t; -*- - -(defvar +irc-left-padding 13 - "By how much spaces the left hand side of the line should be padded. -Below a value of 12 this may result in uneven alignment between the various -types of messages.") - -(defvar +irc-truncate-nick-char ?… - "Character to displayed when nick > `+irc-left-padding' in length.") - -(defvar +irc-scroll-to-bottom-on-commands - '(self-insert-command yank hilit-yank) - "If these commands are called pre prompt the buffer will scroll to `point-max'.") - -(defvar +irc-disconnect-hook nil - "Runs each hook when circe noticies the connection has been disconnected. -Useful for scenarios where an instant reconnect will not be successful.") - -(defvar +irc-bot-list '("fsbot" "rudybot") - "Nicks listed have `circe-fool-face' applied and will not be tracked.") - -(defvar +irc-time-stamp-format "%H:%M" - "The format of time stamps. - -See `format-time-string' for a full description of available -formatting directives. ") - -(defvar +irc-notifications-watch-strings nil - "A list of strings which can trigger a notification. You don't need to put -your nick here. - -See `circe-notifications-watch-strings'.") - -(defvar +irc-defer-notifications nil - "How long to defer enabling notifications, in seconds (e.g. 5min = 300). -Useful for ZNC users who want to avoid the deluge of notifications during buffer -playback.") - -(defvar +irc--defer-timer nil) - -(defsubst +irc--pad (left right) - (format (format "%%%ds | %%s" +irc-left-padding) - (concat "*** " left) right)) - - -;; -;; Packages - -(use-package! circe - :commands circe circe-server-buffers - :config - (setq circe-default-quit-message nil - circe-default-part-message nil - circe-use-cycle-completion t - circe-reduce-lurker-spam t - - circe-format-say (format "{nick:+%ss} │ {body}" +irc-left-padding) - circe-format-self-say circe-format-say - circe-format-action (format "{nick:+%ss} * {body}" +irc-left-padding) - circe-format-self-action circe-format-action - circe-format-server-notice - (let ((left "-Server-")) (concat (make-string (- +irc-left-padding (length left)) ? ) - (concat left " _ {body}"))) - circe-format-notice (format "{nick:%ss} _ {body}" +irc-left-padding) - circe-format-server-topic - (+irc--pad "Topic" "{userhost}: {topic-diff}") - circe-format-server-join-in-channel - (+irc--pad "Join" "{nick} ({userinfo}) joined {channel}") - circe-format-server-join - (+irc--pad "Join" "{nick} ({userinfo})") - circe-format-server-part - (+irc--pad "Part" "{nick} ({userhost}) left {channel}: {reason}") - circe-format-server-quit - (+irc--pad "Quit" "{nick} ({userhost}) left IRC: {reason}]") - circe-format-server-quit-channel - (+irc--pad "Quit" "{nick} ({userhost}) left {channel}: {reason}]") - circe-format-server-rejoin - (+irc--pad "Re-join" "{nick} ({userhost}), left {departuredelta} ago") - circe-format-server-netmerge - (+irc--pad "Netmerge" "{split}, split {ago} ago (Use /WL to see who's still missing)") - circe-format-server-nick-change - (+irc--pad "Nick" "{old-nick} ({userhost}) is now known as {new-nick}") - circe-format-server-nick-change-self - (+irc--pad "Nick" "You are now known as {new-nick} ({old-nick})") - circe-format-server-nick-change-self - (+irc--pad "Nick" "{old-nick} ({userhost}) is now known as {new-nick}") - circe-format-server-mode-change - (+irc--pad "Mode" "{change} on {target} by {setter} ({userhost})") - circe-format-server-lurker-activity - (+irc--pad "Lurk" "{nick} joined {joindelta} ago")) - - (add-hook 'doom-real-buffer-functions #'+circe-buffer-p) - (add-hook 'circe-channel-mode-hook #'turn-on-visual-line-mode) - (add-hook 'circe-mode-hook #'+irc--add-circe-buffer-to-persp-h) - (add-hook 'circe-mode-hook #'turn-off-smartparens-mode) - - ;; HACK Fix #1862: circe hangs on TLS connections when using OpenSSL versions - ;; > 1.1.0, where tls.el does not correctly determine the end of the info - ;; block. This fixes proposed in jorgenschaefer/circe#340 - (setq-hook! 'circe-mode-hook - tls-end-of-info - (concat "\\(" - ;; `openssl s_client' regexp. See ssl/ssl_txt.c lines 219-220. - ;; According to apps/s_client.c line 1515 `---' is always the last - ;; line that is printed by s_client before the real data. - "^ Verify return code: .+\n\\(\\|^ Extended master secret: .+\n\\)\\(\\|^ Max Early Data: .+\n\\)---\n\\|" - ;; `gnutls' regexp. See src/cli.c lines 721-. - "^- Simple Client Mode:\n" - "\\(\n\\|" ; ignore blank lines - ;; According to GnuTLS v2.1.5 src/cli.c lines 640-650 and 705-715 in - ;; `main' the handshake will start after this message. If the - ;; handshake fails, the programs will abort. - "^\\*\\*\\* Starting TLS handshake\n\\)*" - "\\)")) - - (defadvice! +irc--circe-run-disconnect-hook-a (&rest _) - "Runs `+irc-disconnect-hook' after circe disconnects." - :after #'circe--irc-conn-disconnected - (run-hooks '+irc-disconnect-hook)) - - (add-hook! 'lui-pre-output-hook - (defun +irc-circe-truncate-nicks-h () - "Truncate long nicknames in chat output non-destructively." - (when-let (beg (text-property-any (point-min) (point-max) 'lui-format-argument 'nick)) - (goto-char beg) - (let ((end (next-single-property-change beg 'lui-format-argument)) - (nick (plist-get (plist-get (text-properties-at beg) 'lui-keywords) - :nick))) - (when (> (length nick) +irc-left-padding) - (compose-region (+ beg +irc-left-padding -1) end - +irc-truncate-nick-char)))))) - - (add-hook! 'circe-message-option-functions - (defun +irc-circe-message-option-bot-h (nick &rest ignored) - "Fontify known bots and mark them to not be tracked." - (when (member nick +irc-bot-list) - '((text-properties . (face circe-fool-face lui-do-not-track t)))))) - - ;; Let `+irc/quit' and `circe' handle buffer cleanup - (define-key circe-mode-map [remap kill-buffer] #'bury-buffer) - ;; Fail gracefully if not in a circe buffer - (global-set-key [remap tracking-next-buffer] #'+irc/tracking-next-buffer) - - (when (modulep! :completion vertico) - (after! consult - (add-to-list 'consult-buffer-sources '+irc--consult-circe-source 'append))) - - (map! :localleader - (:map circe-mode-map - "a" #'tracking-next-buffer - "j" #'circe-command-JOIN - "m" #'+irc/send-message - "p" #'circe-command-PART - "Q" #'+irc/quit - "R" #'circe-reconnect - "c" #'+irc/jump-to-channel) - (:map circe-channel-mode-map - "n" #'circe-command-NAMES))) - - -(use-package! circe-color-nicks - :hook (circe-channel-mode . enable-circe-color-nicks) - :config - (setq circe-color-nicks-min-constrast-ratio 4.5 - circe-color-nicks-everywhere t)) - - -(use-package! circe-new-day-notifier - :after circe - :config - (enable-circe-new-day-notifier) - (setq circe-new-day-notifier-format-message - (+irc--pad "Day" "Date changed [{day}]"))) - - -(use-package! circe-notifications - :commands enable-circe-notifications - :init - (add-hook! 'circe-server-connected-hook - (defun +irc-init-circe-notifications-h () - (if (numberp +irc-defer-notifications) - (setq +irc--defer-timer - (run-at-time +irc-defer-notifications nil - #'enable-circe-notifications)) - (enable-circe-notifications)))) - :config - (setq circe-notifications-watch-strings +irc-notifications-watch-strings - circe-notifications-emacs-focused nil - circe-notifications-alert-style - (cond (IS-MAC 'osx-notifier) - (IS-LINUX 'libnotify) - (circe-notifications-alert-style)))) - - -(use-package! lui - :commands lui-mode - :config - (define-key lui-mode-map "\C-u" #'lui-kill-to-beginning-of-line) - (setq lui-fill-type nil) - - (when (modulep! :checkers spell) - (setq lui-flyspell-p t)) - - (after! evil - (defun +irc-evil-insert-h () - "Ensure entering insert mode will put us at the prompt, unless editing -after prompt marker." - (when (> (marker-position lui-input-marker) (point)) - (goto-char (point-max)))) - - (add-hook! 'lui-mode-hook - (add-hook 'evil-insert-state-entry-hook #'+irc-evil-insert-h - nil 'local)) - - (mapc (lambda (cmd) (push cmd +irc-scroll-to-bottom-on-commands)) - '(evil-paste-after evil-paste-before evil-open-above evil-open-below))) - - - (defun +irc-preinput-scroll-to-bottom-h () - "Go to the end of the buffer in all windows showing it. -Courtesy of esh-mode.el" - (when (memq this-command +irc-scroll-to-bottom-on-commands) - (let* ((selected (selected-window)) - (current (current-buffer))) - (when (> (marker-position lui-input-marker) (point)) - (walk-windows - (function - (lambda (window) - (when (eq (window-buffer window) current) - (select-window window) - (goto-char (point-max)) - (select-window selected)))) - nil t))))) - - (add-hook! 'lui-mode-hook - (add-hook 'pre-command-hook #'+irc-preinput-scroll-to-bottom-h nil t)) - - ;; enable a horizontal line marking the last read message - (add-hook 'lui-mode-hook #'enable-lui-track-bar) - - (add-hook! 'lui-mode-hook - (defun +irc-init-lui-margins-h () - (setq lui-time-stamp-position 'right-margin - lui-time-stamp-format +irc-time-stamp-format - right-margin-width (length (format-time-string lui-time-stamp-format)))) - (defun +irc-init-lui-wrapping-a () - (setq fringes-outside-margins t - word-wrap t - wrap-prefix (make-string (+ +irc-left-padding 3) ? ))))) - - -(use-package! lui-logging - :after lui - :config (enable-lui-logging)) - - -(use-package! lui-autopaste - :hook (circe-channel-mode . enable-lui-autopaste)) diff --git a/.config/emacs/modules/app/irc/packages.el b/.config/emacs/modules/app/irc/packages.el @@ -1,5 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; app/irc/packages.el - -(package! circe :pin "57fe189d7c0b98b9b1b5a59767cea1c7e2c22b13") -(package! circe-notifications :pin "291149ac12877bbd062da993479d3533a26862b0") diff --git a/.config/emacs/modules/app/rss/README.org b/.config/emacs/modules/app/rss/README.org @@ -1,132 +0,0 @@ -#+title: :app rss -#+subtitle: An RSS reader that Google can't shut down -#+created: May 12, 2020 -#+since: 2.0.9 - -* Description :unfold: -Read RSS feeds in the comfort of Emacs. - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +org :: - Enable [[doom-package:elfeed-org]], so you can configure your feeds with an org file - (={org-directory}/elfeed.org=) rather than Elisp. - -** Packages -- [[doom-package:elfeed]] -- [[doom-package:elfeed-goodies]] -- [[doom-package:elfeed-org]] if [[doom-module:+org]] - -** Hacks -- By default ~elfeed-search-filter~ is set to ~@2-weeks-ago~ and makes the last - 2 weeks of entries visible. This needs to be set after elfeed has loaded like - so in your =$DOOMDIR/config.el=: - #+begin_src emacs-lisp - (after! elfeed - (setq elfeed-search-filter "@1-month-ago +unread")) - #+end_src - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -- As there isn't currently binding for ~elfeed-update~ you can run it with ~M-x - elfeed-update~ - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** Without +org -When you don't want to use org mode to manage your elfeed feeds you can put your -subscriptions in =$DOOMDIR/config.el=: -#+begin_src emacs-lisp -(setq elfeed-feeds - '("https://this-week-in-rust.org/rss.xml" - "http://feeds.bbci.co.uk/news/rss.xml")) -#+end_src - -** With +org -When using ~+org~ flag then configuration is easier. You can use ~org-mode~ to -configure feeds to follow: -#+begin_src org -,* root :elfeed: -,** Programming :programming: -,*** [[https://this-week-in-rust.org/rss.xml][This Week in Rust]] :rust: -,** News :news: -,*** Top news :tops: -,**** http://feeds.bbci.co.uk/news/rss.xml -#+end_src -- Root of ~elfeed-org~ needs to have ~:elfeed:~ tag. This is where ~elfeed-org~ - starts to read. -- You can have subheaders as in example ~:programming:~, and ~elfeed-org~ - applies that tag to all subheader feeds, in example it adds it to ~This Week - in Rust~. -- You can "name" feeds as you please with ~org-mode~ ~org-insert-link~ ([[kbd:][C-c C-l]]) - and put name as you want into ~description~. -- If you don't want to use ~org-directory/elfeed.org~ file you can specify it - with ~(setq rmh-elfeed-org-files '("path/to/your/elfeed/file.org))~ - -** Keybindings -+ General - | Key | Mode | Description | - |-------+--------------------+------------------------| - | [[kbd:][S-RET]] | elfeed-search-mode | Open link into browser | - | [[kbd:][RET]] | elfeed-search-mode | Open item | - | [[kbd:][s]] | elfeed-search-mode | Filter | - | [[kbd:][C-j]] | elfeed-show-mode | Move to next item | - | [[kbd:][C-k]] | elfeed-show-mode | Move to previous item | - -+ If ~:editor evil +everywhere~ - | Key | Description | - |-----+-----------------------------| - | [[kbd:][q]] | elfeed-kill-buffer | - | [[kbd:][r]] | elfeed-search-update--force | - | [[kbd:][g c]] | Copy link of current entry | - -** News filtering -+ Time filtering - + ~@2-days-ago~ Past two days - + ~@2-weeks-ago~ Past two weeks - + ~@2-years-ago~ Past two years - + ~@2020-06-19~ To show specific day - + ~@2020-06-19--2020-03-10~ Span of time -+ Tag filtering - + Include ~+news~ - + Exclude ~-rust~ - + Both ~+news -rust~ -+ String filtering, this is case insensitive - + Include - + ~DOOM~ - + ~Linu[sx]~ Search for both ~Linus~ and ~Linux~ - + Exclude ~!something~ - -** Automatically updating feed when opening elfeed -Hook ~elfeed-update~ to ~elfeed-search-mode-hook~: -#+begin_src emacs-lisp -(add-hook 'elfeed-search-mode-hook #'elfeed-update) -#+end_src - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/app/rss/autoload.el b/.config/emacs/modules/app/rss/autoload.el @@ -1,152 +0,0 @@ -;;; app/rss/autoload.el -*- lexical-binding: t; -*- - -(defvar +rss--wconf nil) - -;;;###autoload -(defun =rss () - "Activate (or switch to) `elfeed' in its workspace." - (interactive) - (if (modulep! :ui workspaces) - (progn - (+workspace-switch +rss-workspace-name t) - (unless (memq (buffer-local-value 'major-mode - (window-buffer - (selected-window))) - '(elfeed-show-mode - elfeed-search-mode)) - (doom/switch-to-scratch-buffer) - (elfeed)) - (+workspace/display)) - (setq +rss--wconf (current-window-configuration)) - (delete-other-windows) - (switch-to-buffer (doom-fallback-buffer)) - (elfeed))) - -;;;###autoload -(defun +rss/delete-pane () - "Delete the *elfeed-entry* split pane." - (interactive) - (let* ((buf (get-buffer "*elfeed-entry*")) - (window (get-buffer-window buf))) - (delete-window window) - (when (buffer-live-p buf) - (kill-buffer buf)))) - -;;;###autoload -(defun +rss/open (entry) - "Display the currently selected item in a buffer." - (interactive (list (elfeed-search-selected :ignore-region))) - (when (elfeed-entry-p entry) - (elfeed-untag entry 'unread) - (elfeed-search-update-entry entry) - (elfeed-show-entry entry))) - -;;;###autoload -(defun +rss/next () - "Show the next item in the elfeed-search buffer." - (interactive) - (funcall elfeed-show-entry-delete) - (with-current-buffer (elfeed-search-buffer) - (forward-line) - (call-interactively '+rss/open))) - -;;;###autoload -(defun +rss/previous () - "Show the previous item in the elfeed-search buffer." - (interactive) - (funcall elfeed-show-entry-delete) - (with-current-buffer (elfeed-search-buffer) - (forward-line -1) - (call-interactively '+rss/open))) - -;;;###autoload -(defun +rss/copy-link () - "Copy current link to clipboard." - (interactive) - (let ((link (elfeed-entry-link elfeed-show-entry))) - (when link - (kill-new link) - (message "Copied %s to clipboard" link)))) -;; -;; Hooks - -;;;###autoload -(defun +rss-elfeed-wrap-h () - "Enhances an elfeed entry's readability by wrapping it to a width of -`fill-column'." - (let ((inhibit-read-only t) - (inhibit-modification-hooks t)) - (setq-local truncate-lines nil) - (setq-local shr-use-fonts nil) - (setq-local shr-width 85) - (set-buffer-modified-p nil))) - -(defun +rss--cleanup-on-kill-h () - "Run `elfeed-db-compact'. See `+rss-cleanup-h'." - ;; `delete-file-projectile-remove-from-cache' slows down `elfeed-db-compact' - ;; tremendously, so we disable the projectile cache: - (let (projectile-enable-caching) - (elfeed-db-compact))) - -;;;###autoload -(defun +rss-cleanup-h () - "Clean up after an elfeed session. Kills all elfeed and elfeed-org files." - (interactive) - (add-hook 'kill-emacs-hook #'+rss--cleanup-on-kill-h) - (let ((buf (previous-buffer))) - (when (or (null buf) (not (doom-real-buffer-p buf))) - (switch-to-buffer (doom-fallback-buffer)))) - (let ((search-buffers (doom-buffers-in-mode 'elfeed-search-mode)) - (show-buffers (doom-buffers-in-mode 'elfeed-show-mode)) - kill-buffer-query-functions) - (dolist (file (bound-and-true-p rmh-elfeed-org-files)) - (when-let (buf (get-file-buffer (expand-file-name file org-directory))) - (kill-buffer buf))) - (dolist (b search-buffers) - (with-current-buffer b - (remove-hook 'kill-buffer-hook #'+rss-cleanup-h :local) - (kill-buffer b))) - (mapc #'kill-buffer show-buffers)) - (if (and (modulep! :ui workspaces) - (+workspace-exists-p +rss-workspace-name)) - (+workspace/delete +rss-workspace-name) - (when (window-configuration-p +rss--wconf) - (set-window-configuration +rss--wconf)) - (setq +rss--wconf nil) - (previous-buffer))) - - -;; -;; Functions - -;;;###autoload -(defun +rss-dead-feeds (&optional years) - "Return a list of feeds that haven't posted anything in YEARS." - (let* ((years (or years 1.0)) - (living-feeds (make-hash-table :test 'equal)) - (seconds (* years 365.0 24 60 60)) - (threshold (- (float-time) seconds))) - (with-elfeed-db-visit (entry feed) - (let ((date (elfeed-entry-date entry))) - (when (> date threshold) - (setf (gethash (elfeed-feed-url feed) living-feeds) t)))) - (cl-loop for url in (elfeed-feed-list) - unless (gethash url living-feeds) - collect url))) - -;;;###autoload -(defun +rss-put-sliced-image-fn (spec alt &optional flags) - "TODO" - (letf! (defun insert-image (image &optional alt _area _slice) - (let ((height (cdr (image-size image t)))) - (insert-sliced-image image alt nil (max 1 (/ height 20.0)) 1))) - (shr-put-image spec alt flags))) - -;;;###autoload -(defun +rss-render-image-tag-without-underline-fn (dom &optional url) - "TODO" - (let ((start (point))) - (shr-tag-img dom url) - ;; And remove underlines in case images are links, otherwise we get an - ;; underline beneath every slice. - (put-text-property start (point) 'face '(:underline nil)))) diff --git a/.config/emacs/modules/app/rss/config.el b/.config/emacs/modules/app/rss/config.el @@ -1,89 +0,0 @@ -;;; app/rss/config.el -*- lexical-binding: t; -*- - -;; This is an opinionated workflow that turns Emacs into an RSS reader, inspired -;; by apps Reeder and Readkit. It can be invoked via `=rss'. Otherwise, if you -;; don't care for the UI you can invoke elfeed directly with `elfeed'. - -(defvar +rss-split-direction 'below - "What direction to pop up the entry buffer in elfeed.") - -(defvar +rss-enable-sliced-images t - "Automatically slice images shown in elfeed-show-mode buffers, making them -easier to scroll through.") - -(defvar +rss-workspace-name "*rss*" - "Name of the workspace that contains the elfeed buffer.") - -;; -;; Packages - -(use-package! elfeed - :commands elfeed - :init - (setq elfeed-db-directory (concat doom-local-dir "elfeed/db/") - elfeed-enclosure-default-dir (concat doom-local-dir "elfeed/enclosures/")) - :config - (setq elfeed-search-filter "@2-week-ago " - elfeed-show-entry-switch #'pop-to-buffer - elfeed-show-entry-delete #'+rss/delete-pane - shr-max-image-proportion 0.8) - - (set-popup-rule! "^\\*elfeed-entry" - :size 0.75 :actions '(display-buffer-below-selected) - :select t :quit nil :ttl t) - - (make-directory elfeed-db-directory t) - - ;; Ensure elfeed buffers are treated as real - (add-hook! 'doom-real-buffer-functions - (defun +rss-buffer-p (buf) - (string-match-p "^\\*elfeed" (buffer-name buf)))) - - ;; Enhance readability of a post - (add-hook 'elfeed-show-mode-hook #'+rss-elfeed-wrap-h) - (add-hook! 'elfeed-search-mode-hook - (add-hook 'kill-buffer-hook #'+rss-cleanup-h nil 'local)) - - ;; Large images are annoying to scroll through, because scrolling follows the - ;; cursor, so we force shr to insert images in slices. - (when +rss-enable-sliced-images - (setq-hook! 'elfeed-show-mode-hook - shr-put-image-function #'+rss-put-sliced-image-fn - shr-external-rendering-functions '((img . +rss-render-image-tag-without-underline-fn)))) - - ;; Keybindings - (after! elfeed-show - (define-key! elfeed-show-mode-map - [remap next-buffer] #'+rss/next - [remap previous-buffer] #'+rss/previous)) - (when (modulep! :editor evil +everywhere) - (evil-define-key 'normal elfeed-search-mode-map - "q" #'elfeed-kill-buffer - "r" #'elfeed-search-update--force - (kbd "M-RET") #'elfeed-search-browse-url) - (map! :map elfeed-show-mode-map - :n "gc" nil - :n "gc" #'+rss/copy-link))) - - - -(use-package! elfeed-org - :when (modulep! +org) - :after elfeed - :preface - (setq rmh-elfeed-org-files (list "elfeed.org")) - :config - (elfeed-org) - (defadvice! +rss-skip-missing-org-files-a (&rest _) - :before '(elfeed rmh-elfeed-org-mark-feed-ignore elfeed-org-export-opml) - (unless (file-name-absolute-p (car rmh-elfeed-org-files)) - (let* ((default-directory org-directory) - (files (mapcar #'expand-file-name rmh-elfeed-org-files))) - (dolist (file (cl-remove-if #'file-exists-p files)) - (message "elfeed-org: ignoring %S because it can't be read" file)) - (setq rmh-elfeed-org-files (cl-remove-if-not #'file-exists-p files)))))) - -(use-package! elfeed-goodies - :after elfeed - :config - (elfeed-goodies/setup)) diff --git a/.config/emacs/modules/app/rss/packages.el b/.config/emacs/modules/app/rss/packages.el @@ -1,7 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; app/rss/packages.el - -(package! elfeed :pin "162d7d545ed41c27967d108c04aa31f5a61c8e16") -(package! elfeed-goodies :pin "544ef42ead011d960a0ad1c1d34df5d222461a6b") -(when (modulep! +org) - (package! elfeed-org :pin "3242ec0519800a58f20480c8a6e3b3337d137084")) diff --git a/.config/emacs/modules/app/twitter/README.org b/.config/emacs/modules/app/twitter/README.org @@ -1,101 +0,0 @@ -#+title: :app twitter -#+subtitle: Be superficial in plain text -#+created: October 11, 2019 -#+since: 2.0.0 - -* Description :unfold: -Enjoy twitter from emacs. - -- View various timelines side by side, e.g. user's timeline, home, etc. -- Post new tweets -- Send direct messages -- Retweet -- Follow and un-follow users -- Favorite tweets - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:avy]] -- [[doom-package:twittering-mode]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires: -- One of the following (for SSL connections; required by Twitter's API): - - [[http://curl.haxx.se/][cURL]] - - [[http://www.gnu.org/software/wget/][GNU Wget]] - - [[http://www.openssl.org/][OpenSSL]] - - [[http://www.gnu.org/software/gnutls/][GnuTLS]] -- [[http://www.gnupg.org/][GnuPG]], for encrypting the OAuth token, stored locally. -- [[http://www.gzip.org/][gzip]], for compressing retrieved profile pictures, -- [[http://www.imagemagick.org/][ImageMagick]], for displaying and resizing profile pictures. - - Build Emacs with ImageMagick support using the ~--with-imagemagick~ flag ([[https://git.savannah.gnu.org/cgit/emacs.git/tree/INSTALL][how - to build Emacs from source]]). - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** Commands & Keybindings -Here is a list of available commands and their default keybindings (defined in -[[./config.el][config.el]]): -| command | key / ex command | description | -|---------------------+------------------+-------------------------------------------------------------| -| ~+twitter/quit~ | [[kbd:][q]] | Close current window | -| ~+twitter/quit-all~ | [[kbd:][Q]] | Close all twitter windows and buffers, and delete workspace | - -And when [[doom-module::editor evil +everywhere]] is active: -| command | key / ex command | description | -|--------------------------------------------------+------------------+------------------------------------------------------------------| -| ~twittering-favorite~ | [[kbd:][f]] | Favorite/Like a tweet | -| ~twittering-unfavorite~ | [[kbd:][F]] | Un-favorite/Un-like a tweet | -| ~twittering-follow~ | [[kbd:][C-f]] | Follow user | -| ~twittering-unfollow~ | [[kbd:][C-F]] | Un-follow user | -| ~twittering-delete-status~ | [[kbd:][d]] | Delete a tweet | -| ~twittering-retweet~ | [[kbd:][r]] | Retweet | -| ~twittering-toggle-or-retrieve-replied-statuses~ | [[kbd:][R]] | Toggle or retrieve replies | -| ~twittering-update-status-interactive~ | [[kbd:][o]] | Update tweets | -| ~+twitter/ace-link~ | [[kbd:][O]] | Open some visible link from a ~twittering-mode~ buffer using ace | -| ~twittering-search~ | [[kbd:][/]] | Search | -| ~twittering-goto-next-status~ | [[kbd:][J]] | Go to next tweet | -| ~twittering-goto-previous-status~ | [[kbd:][K]] | Go to previous tweet | -| ~twittering-goto-first-status~ | [[kbd:][gg]] | Go to first tweet | -| ~twittering-goto-last-status~ | [[kbd:][G]] | Go to last tweet | -| ~twittering-goto-next-status-of-user~ | [[kbd:][gj]] | Go to next tweet of user | -| ~twittering-goto-previous-status-of-user)))~ | [[kbd:][gk]] | Go to previous tweet of user | - -* Troubleshooting -[[doom-report:][Report an issue?]] - -** ~twittering-mode~ overrides the [[kbd:][SPC]] key -Currently ~twittering-mode~ binds [[kbd:][SPC]], breaking its functionality as a leader -key for evil users. To work around this issue you may use [[kbd:][M-SPC]] instead. - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote - diff --git a/.config/emacs/modules/app/twitter/autoload.el b/.config/emacs/modules/app/twitter/autoload.el @@ -1,104 +0,0 @@ -;;; app/twitter/autoload.el -*- lexical-binding: t; -*- - -(defvar +twitter-workspace-name "*Twitter*" - "The name to use for the twitter workspace.") - -;;;###autoload -(defun +twitter-display-buffer-fn (buf) - "A replacement display-buffer command for `twittering-pop-to-buffer-function' -that works with the ui/popup module." - (let ((win (selected-window))) - (display-buffer buf) - ;; This is required because the new window generated by `pop-to-buffer' - ;; may hide the region following the current position. - (twittering-ensure-whole-of-status-is-visible win))) - -;;;###autoload -(defun +twitter-buffer-p (buf) - "Return non-nil if BUF is a `twittering-mode' buffer." - (eq 'twittering-mode (buffer-local-value 'major-mode buf))) - - -;; -;; Commands - -(defvar +twitter--old-wconf nil) -;;;###autoload -(defun =twitter (arg) - "Opens a workspace dedicated to `twittering-mode'." - (interactive "P") - (condition-case _ - (progn - (if (and (not arg) (modulep! :ui workspaces)) - (+workspace/new +twitter-workspace-name) - (setq +twitter--old-wconf (current-window-configuration)) - (delete-other-windows) - (switch-to-buffer (doom-fallback-buffer))) - (call-interactively #'twit) - (unless (get-buffer (car twittering-initial-timeline-spec-string)) - (error "Failed to open twitter")) - (switch-to-buffer (car twittering-initial-timeline-spec-string)) - (dolist (name (cdr twittering-initial-timeline-spec-string)) - (split-window-horizontally) - (switch-to-buffer name)) - (balance-windows) - (call-interactively #'+twitter/rerender-all)) - ('error (+twitter/quit-all)))) - -;;;###autoload -(defun +twitter/quit () - "Close the current `twitter-mode' buffer." - (interactive) - (when (eq major-mode 'twittering-mode) - (twittering-kill-buffer) - (cond ((one-window-p) (+twitter/quit-all)) - ((modulep! :ui workspaces) - (+workspace/close-window-or-workspace)) - ((delete-window))))) - -;;;###autoload -(defun +twitter/quit-all () - "Close all open `twitter-mode' buffers and the associated workspace, if any." - (interactive) - (when (modulep! :ui workspaces) - (+workspace/delete +twitter-workspace-name)) - (when +twitter--old-wconf - (set-window-configuration +twitter--old-wconf) - (setq +twitter--old-wconf nil)) - (dolist (buf (doom-buffers-in-mode 'twittering-mode (buffer-list) t)) - (twittering-kill-buffer buf))) - -;;;###autoload -(defun +twitter/rerender-all () - "Rerender all `twittering-mode' buffers." - (interactive) - (dolist (buf (doom-buffers-in-mode 'twittering-mode (buffer-list) t)) - (with-current-buffer buf - (twittering-rerender-timeline-all buf) - (setq-local line-spacing 0.2) - (goto-char (point-min))))) - -;;;###autoload -(defun +twitter/ace-link () - "Open a visible link, username or hashtag in a `twittering-mode' buffer." - (interactive) - (require 'avy) - ;; REVIEW Is this necessary anymore with `link-hint' - (let ((pt (avy-with +twitter/ace-link - (avy--process - (+twitter--collect-links) - (avy--style-fn avy-style))))) - (when (number-or-marker-p pt) - (goto-char pt) - (let ((uri (get-text-property (point) 'uri))) - (if uri (browse-url uri)))))) - -(defun +twitter--collect-links () - (let ((end (window-end)) - points) - (save-excursion - (goto-char (window-start)) - (while (and (< (point) end) - (ignore-errors (twittering-goto-next-thing) t)) - (push (point) points)) - (nreverse points)))) diff --git a/.config/emacs/modules/app/twitter/config.el b/.config/emacs/modules/app/twitter/config.el @@ -1,76 +0,0 @@ -;;; app/twitter/config.el -*- lexical-binding: t; -*- - -(use-package! twittering-mode - :commands twit - :config - (setq twittering-private-info-file - (expand-file-name "twittering-mode.gpg" doom-data-dir) - twittering-use-master-password t - twittering-request-confirmation-on-posting t - ;; twittering-icon-mode t - ;; twittering-use-icon-storage t - ;; twittering-icon-storage-file (concat doom-cache-dir "twittering-mode-icons.gz") - ;; twittering-convert-fix-size 12 - twittering-timeline-header "" - twittering-timeline-footer "" - twittering-edit-skeleton 'inherit-any - twittering-status-format "%FACE[font-lock-function-name-face]{ @%s} %FACE[italic]{%@} %FACE[error]{%FIELD-IF-NONZERO[❤ %d]{favorite_count}} %FACE[warning]{%FIELD-IF-NONZERO[↺ %d]{retweet_count}} -%FOLD[ ]{%FILL{%t}%QT{ -%FOLD[ ]{%FACE[font-lock-function-name-face]{@%s}\t%FACE[shadow]{%@} -%FOLD[ ]{%FILL{%t}} -}}} - -%FACE[twitter-divider]{ } -" - ;; twittering-timeline-spec-alias '() - twittering-initial-timeline-spec-string - '(":home" ":mentions" ":direct_messages")) - - (set-popup-rule! "^\\*twittering-edit" :size 15 :ttl nil :quit nil :select t) - - (defface twitter-divider - '((((background dark)) (:underline (:color "#141519"))) - (((background light)) (:underline (:color "#d3d3d3")))) - "The vertical divider between tweets." - :group 'twittering-mode) - - (add-hook 'doom-real-buffer-functions #'+twitter-buffer-p) - (when (modulep! :ui popup) - (setq twittering-pop-to-buffer-function #'+twitter-display-buffer-fn)) - - ;; Custom header-line for twitter buffers - (add-hook! 'twittering-mode-hook - (defun +twitter-switch-mode-and-header-line-h () - (setq header-line-format mode-line-format - mode-line-format nil))) - - ;; `epa--decode-coding-string' isn't defined in later versions of Emacs 27 - (unless (fboundp 'epa--decode-coding-string) - (defalias 'epa--decode-coding-string #'decode-coding-string)) - - (define-key! twittering-mode-map - "q" #'+twitter/quit - "Q" #'+twitter/quit-all - [remap twittering-kill-buffer] #'+twitter/quit - [remap delete-window] #'+twitter/quit - [remap +workspace/close-window-or-workspace] #'+twitter/quit) - (when (modulep! :editor evil +everywhere) - (define-key! twittering-mode-map - [remap evil-window-delete] #'+twitter/quit - "f" #'twittering-favorite - "F" #'twittering-unfavorite - "\C-f" #'twittering-follow - "\C-F" #'twittering-unfollow - "d" #'twittering-delete-status - "r" #'twittering-retweet - "R" #'twittering-toggle-or-retrieve-replied-statuses - "o" #'twittering-update-status-interactive - "O" #'+twitter/ace-link - "/" #'twittering-search - "J" #'twittering-goto-next-status - "K" #'twittering-goto-previous-status - "g" nil - "gg" #'twittering-goto-first-status - "G" #'twittering-goto-last-status - "gj" #'twittering-goto-next-status-of-user - "gk" #'twittering-goto-previous-status-of-user))) diff --git a/.config/emacs/modules/app/twitter/packages.el b/.config/emacs/modules/app/twitter/packages.el @@ -1,5 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; app/twitter/packages.el - -(package! twittering-mode :pin "114891e8fdb4f06b1326a6cf795e49c205cf9e29") -(package! avy :pin "955c8dedd68c74f3cf692c1249513f048518c4c9") diff --git a/.config/emacs/modules/checkers/README.org b/.config/emacs/modules/checkers/README.org @@ -1,9 +0,0 @@ -#+title: :checkers -#+created: August 01, 2021 -#+since: 21.12.0 - -* Description -For modules dedicated to linting plain text (primarily code and prose). - -* Frequently asked questions -/This category has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] diff --git a/.config/emacs/modules/checkers/grammar/README.org b/.config/emacs/modules/checkers/grammar/README.org @@ -1,76 +0,0 @@ -#+title: :checkers grammar -#+subtitle: Tasing grammar mistake every you make -#+created: January 09, 2020 -#+since: 21.12.0 - -* Description :unfold: -This module adds grammar checking to Emacs to aid your writing by combining -[[doom-package:lang-tool]] and [[doom-package:writegood-mode]]. - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:langtool]] -- [[doom-package:writegood-mode]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires [[https://languagetool.org/][LanguageTool]] (which requires =Java 1.8+=). - -It is available from either https://languagetool.org/ or your OS's package -manager. E.g. -- macOS: ~$ brew install languagetool~ -- Arch Linux: ~$ pacman -S languagetool~ -- NixOS: [[https://search.nixos.org/packages?show=languagetool&from=0&size=50&sort=relevance&type=packages&query=languagetool][nixpkgs.languagetool]] - -This module tries to guess the location of =languagetool-commandline.jar=. If -you get a warning that Doom ~couldn't find languagetool-commandline.jar~, you -will need to set ~langtool-language-tool-jar~ to its location. - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** Language Tool -[[https://www.languagetool.org/][Language Tool]] is a polyglot proofreader service that checks for grammar and -stylistic issues in your writing. This requires Java 1.8+. - -#+begin_quote - 🚧 This requires Java 1.8+ -#+end_quote - -*** Commands -- ~M-x langtool-check~ -- ~M-x langtool-correct-buffer~ - -** writegood-mode -This minor mode highlights weasel words, duplication and passive voice. - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/checkers/grammar/config.el b/.config/emacs/modules/checkers/grammar/config.el @@ -1,40 +0,0 @@ -;;; checkers/grammar/config.el -*- lexical-binding: t; -*- - -(use-package! langtool - :commands (langtool-check - langtool-check-done - langtool-show-message-at-point - langtool-correct-buffer) - :init (setq langtool-default-language "en-US") - :config - (unless (or langtool-bin - langtool-language-tool-jar - langtool-java-classpath) - (cond ((setq langtool-bin - (or (executable-find "languagetool-commandline") - (executable-find "languagetool")))) ; for nixpkgs.languagetool - (IS-MAC - (cond - ;; is user using home brew? - ((file-directory-p "/usr/local/Cellar/languagetool") - (setq langtool-language-tool-jar - (locate-file "libexec/languagetool-commandline.jar" - (doom-files-in "/usr/local/Cellar/languagetool" - :type 'dirs - :depth 2)))) - ;; macports compatibility - ((file-directory-p "/opt/local/share/java/LanguageTool") - (setq langtool-java-classpath "/opt/local/share/java/LanguageTool/*")))) - (IS-LINUX - (setq langtool-java-classpath "/usr/share/languagetool:/usr/share/java/languagetool/*"))))) - - -;; Detects weasel words, passive voice and duplicates. Proselint would be a -;; better choice. -(use-package! writegood-mode - :hook (org-mode markdown-mode rst-mode asciidoc-mode latex-mode LaTeX-mode) - :config - (map! :localleader - :map writegood-mode-map - "g" #'writegood-grade-level - "r" #'writegood-reading-ease)) diff --git a/.config/emacs/modules/checkers/grammar/packages.el b/.config/emacs/modules/checkers/grammar/packages.el @@ -1,5 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; checkers/grammar/packages.el - -(package! langtool :pin "8276eccc5587bc12fd205ee58a7a982f0a136e41") -(package! writegood-mode :pin "ed42d918d98826ad88928b7af9f2597502afc6b0") diff --git a/.config/emacs/modules/checkers/spell/README.org b/.config/emacs/modules/checkers/spell/README.org @@ -1,235 +0,0 @@ -#+title: :checkers spell -#+subtitle: Tasing you for misspelling mispelling -#+created: February 20, 2017 -#+since: 2.0.0 - -* Description :unfold: -This modules provides spellchecking powered by =aspell=, =hunspell= or -=enchant=. - -Spellcheck is automatically loaded in many ~text-mode~ derivatives, which -includes ~org-mode~, ~markdown-mode~, the Git Commit buffer (from magit), -~mu4e-compose-mode~, and others. - -- Spell checking and correction using =aspell=, =hunspell= or =enchant=. -- Ignores source code inside org or markdown files. -- Lazily spellchecking recent changes only when idle. -- Choosing suggestions using completion interfaces ([[doom-package:ivy]] or [[doom-package:helm]]). - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +aspell :: - Use =aspell= as a backend for correcting words. -- +enchant :: - Use =enchant-2= as a backend for correcting words. -- +everywhere :: - Spell check in programming modes as well (in comments only). -- +flyspell :: - Use [[doom-package:flyspell]] instead of [[doom-package:spell-fu]]. It's significantly slower, but supports - multiple languages and dictionaries. -- +hunspell :: - Use =hunspell= as a backend for correcting words. - -** Packages -- if [[doom-module:+flyspell]] - - [[doom-package:flyspell-correct]] - - [[doom-package:flyspell-correct-ivy]] if [[doom-module::completion ivy]] - - [[doom-package:flyspell-correct-helm]] if [[doom-module::completion helm]] - - [[doom-package:flyspell-correct-popup]] unless [[doom-module::completion ivy]], [[doom-module::completion helm]], or - [[doom-module::completion vertico]] - - [[doom-package:flyspell-lazy]] -- else - - [[doom-package:spell-fu]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires one of =aspell=, =hunspell= or =enchant-2= installed on -your system and in your =$PATH=. They also need dictionaries for your -language(s). - -#+begin_quote - 🚧 If you *are not* using [[doom-module:+flyspell]], you will need =aspell= (and a dictionary) - installed whether or not you have [[doom-module:+hunspell]] or [[doom-module:+enchant]] enabled. This is - because [[doom-package:spell-fu]] does not support generating the word list with anything - other than =aspell= yet. -#+end_quote - -** Aspell -- Ubuntu: ~$ apt-get install aspell aspell-en~ -- macOS: ~$ brew install aspell~ -- Arch Linux: ~$ pacman -S aspell aspell-en~ -- NixOS: - #+begin_src nix - { - environment.systemPackages = with pkgs; [ - (aspellWithDicts (dicts: with dicts; [ en en-computers en-science ])) - ]; - } - #+end_src - -** Hunspell -- Ubuntu: ~$ apt-get install hunspell~ -- macOS: ~$ brew install hunspell~ -- Arch Linux: ~$ pacman -S hunspell~ -- NixOS: - #+begin_src nix - { - environment.systemPackages = with pkgs; [ - hunspell - ]; - } - #+end_src - -** Enchant -- Ubuntu: ~$ apt-get install enchant-2~ -- macOS: ~$ brew install enchant~ -- Arch Linux: ~$ pacman -S enchant~ -- NixOS: - #+begin_src nix - { - environment.systemPackages = with pkgs; [ - enchant - ]; - } - #+end_src - - Enchant is just a wrapper for other spelling libraries and you will need to - have at least one of the supported backends installed as well. - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -When using [[doom-module:+everywhere]], spell checking is performed for as many major modes as -possible, and not only ~text-mode~ derivatives. e.g. in comments for programming -major modes. - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -Dictionary is set by ~ispell-dictionary~ variable. Can be changed locally with -the function ~ispell-change-dictionary~. - -** Changing how quickly spelling is checked after changes -*** Spell-fu users -Adjust ~spell-fu-idle-delay~ to change how long Emacs waits to spellcheck after -recent changes: -#+begin_src emacs-lisp -(after! spell-fu - (setq spell-fu-idle-delay 0.5)) ; default is 0.25 -#+end_src - -*** Flyspell users -Lazy spellcheck is provided by [[doom-package:flyspell-lazy]] package. - -~flyspell-lazy-idle-seconds~ sets how many idle seconds until spellchecking -recent changes (default as 1), while ~flyspell-lazy-window-idle-seconds~ sets -how many seconds until the whole window is spellchecked (default as 3): -#+begin_src emacs-lisp -(after! flyspell - (setq flyspell-lazy-idle-seconds 2)) -#+end_src - -** Reducing false positives by disabling spelling on certain faces -*** Spell-fu users -Users can exclude what faces to preform spellchecking on by adjusting -~+spell-excluded-faces-alist~ in a buffer-local hook: -#+begin_src emacs-lisp -(setf (alist-get 'markdown-mode +spell-excluded-faces-alist) - '(markdown-code-face - markdown-reference-face - markdown-link-face - markdown-url-face - markdown-markup-face - markdown-html-attr-value-face - markdown-html-attr-name-face - markdown-html-tag-name-face)) -#+end_src - -*** Flyspell users -Flyspell will run a series of predicate functions to determine if a word should -be spell checked. You can add your own with ~set-flyspell-predicate!~: -#+begin_src emacs-lisp -(set-flyspell-predicate! '(markdown-mode gfm-mode) - #'+markdown-flyspell-word-p) -#+end_src - -Flyspell predicates take no arguments and must return a boolean to determine if -the word at point should be spell checked. For example: -#+begin_src emacs-lisp -(defun +markdown-flyspell-word-p () - "Return t if point is on a word that should be spell checked. - -Return nil if on a link url, markup, html, or references." - (let ((faces (ensure-list (get-text-property (point) 'face)))) - (or (and (memq 'font-lock-comment-face faces) - (memq 'markdown-code-face faces)) - (not (cl-loop with unsafe-faces = '(markdown-reference-face - markdown-url-face - markdown-markup-face - markdown-comment-face - markdown-html-attr-name-face - markdown-html-attr-value-face - markdown-html-tag-name-face - markdown-code-face) - for face in faces - if (memq face unsafe-faces) - return t))))) -#+end_src - -** Adding or removing words to your personal dictionary -Use ~M-x +spell/add-word~ and ~M-x +spell/remove-word~ to whitelist words that -you know are not misspellings. For evil users these are bound to [[kbd:][zg]] and [[kbd:][zw]], -respectively. [[doom-module:+flyspell]] users can also add/remove words from the -[[doom-package:flyspell-correct]] popup interface (there will be extra options on the list of -corrections for "save word to dictionary"). - -* Troubleshooting -[[doom-report:][Report an issue?]] - -** spell-fu highlights every single word -[[doom-package:spell-fu]] caches its word list. If it was activated before your dictionaries were -installed, it will generate an empty word list, causing it to highlight all -words as incorrect. Delete its cache files in =$EMACSDIR/.local/etc/spell-fu/= -to fix this. - -** Cannot add [word] to any active dictionary -*** Aspell -If ~M-x +spell/add-word~ results in the above error this mean that the -personal dictionary file was not created for some reason. This can be -fixed by creating the required file manually. Note: the personal dictionary -is defined by ~ispell-personal-dictionary~, you may need to check it first -with ~M-x describe-variable~. -#+begin_example shell -mkdir -p ~/.emacs.d/.local/etc/ispell -echo personal_ws-1.1 en 0 > ~/.emacs.d/.local/etc/ispell/.pws -#+end_example - -Where ~personal_ws-1.1 en 0~ is the required header format for the personal -dictionary file. ~en~ is the language you're writing in and have a dict -installed and ~0~ is the number of added words in the dictionary. If you are -planning of updating the file with the list of words, update the number -accordingly. - -After the file is created, restart emacs and adding words should work. - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/checkers/spell/autoload/+flyspell.el b/.config/emacs/modules/checkers/spell/autoload/+flyspell.el @@ -1,86 +0,0 @@ -;;; checkers/spell/autoload/+flyspell.el -*- lexical-binding: t; -*- -;;;###if (modulep! +flyspell) - -;;;###autodef -(defalias 'flyspell-mode! #'flyspell-mode) - -(defvar +spell--flyspell-predicate-alist nil - "TODO") - -;;;###autodef -(defun set-flyspell-predicate! (modes predicate) - "TODO" - (declare (indent defun)) - (dolist (mode (ensure-list modes) +spell--flyspell-predicate-alist) - (add-to-list '+spell--flyspell-predicate-alist (cons mode predicate)))) - -;;;###autoload -(defun +spell-init-flyspell-predicate-h () - "TODO" - (when-let (pred (assq major-mode +spell--flyspell-predicate-alist)) - (setq-local flyspell-generic-check-word-predicate (cdr pred)))) - -;;;###autoload -(defun +spell-correction-at-point-p (&optional point) - "TODO" - (cl-loop for ov in (overlays-at (or point (point))) - if (overlay-get ov 'flyspell-overlay) - return t)) - -;;;###autoload -(defun +spell/add-word (word &optional scope) - "Add WORD to your personal dictionary, within SCOPE. - -SCOPE can be `buffer' or `session' to exclude words only from the current buffer -or session. Otherwise, the addition is permanent." - (interactive - (list (progn (require 'flyspell) - (car (flyspell-get-word))) - (cond ((equal current-prefix-arg '(16)) - 'session) - ((equal current-prefix-arg '(4)) - 'buffer)))) - (require 'flyspell) - (cond - ((null scope) - (ispell-send-string (concat "*" word "\n")) - (ispell-send-string "#\n") - (flyspell-unhighlight-at (point)) - (setq ispell-pdict-modified-p '(t))) - ((memq scope '(buffer session)) - (ispell-send-string (concat "@" word "\n")) - (add-to-list 'ispell-buffer-session-localwords word) - (or ispell-buffer-local-name ; session localwords might conflict - (setq ispell-buffer-local-name (buffer-name))) - (flyspell-unhighlight-at (point)) - (if (null ispell-pdict-modified-p) - (setq ispell-pdict-modified-p - (list ispell-pdict-modified-p))) - (if (eq scope 'buffer) - (ispell-add-per-file-word-list word)))) - (ispell-pdict-save t)) - -;;;###autoload -(defun +spell/remove-word (word &optional _scope) - "Remove WORD from your personal dictionary." - (interactive) - (user-error "Not supported yet with +flyspell")) - -;;;###autoload -(defun +spell/next-error () - "Jump to next flyspell error." - (interactive) - (call-interactively - (if (featurep 'evil) - #'evil-next-flyspell-error - #'flyspell-goto-next-error))) - -;;;###autoload -(defun +spell/previous-error () - "Jump to previous flyspell error." - (interactive) - (call-interactively - (if (featurep 'evil) - #'evil-prev-flyspell-error - ;; TODO Implement this - (user-error "Not supported")))) diff --git a/.config/emacs/modules/checkers/spell/autoload/+spell-fu.el b/.config/emacs/modules/checkers/spell/autoload/+spell-fu.el @@ -1,116 +0,0 @@ -;;; checkers/spell/autoload/+spell-fu.el -*- lexical-binding: t; -*- -;;;###if (not (modulep! +flyspell)) - -(defun +spell--correct (replace poss word orig-pt start end) - (cond ((eq replace 'ignore) - (goto-char orig-pt) - nil) - ((eq replace 'save) - (goto-char orig-pt) - (ispell-send-string (concat "*" word "\n")) - (ispell-send-string "#\n") - (setq ispell-pdict-modified-p '(t))) - ((or (eq replace 'buffer) (eq replace 'session)) - (ispell-send-string (concat "@" word "\n")) - (add-to-list 'ispell-buffer-session-localwords word) - (or ispell-buffer-local-name ; session localwords might conflict - (setq ispell-buffer-local-name (buffer-name))) - (if (null ispell-pdict-modified-p) - (setq ispell-pdict-modified-p - (list ispell-pdict-modified-p))) - (goto-char orig-pt) - (if (eq replace 'buffer) - (ispell-add-per-file-word-list word))) - (replace - (let ((new-word (if (atom replace) - replace - (car replace))) - (orig-pt (+ (- (length word) (- end start)) - orig-pt))) - (unless (equal new-word (car poss)) - (delete-region start end) - (goto-char start) - (insert new-word)))) - ((goto-char orig-pt) - nil))) - -(defun +spell-correct-ivy-fn (candidates word) - (ivy-read (format "Corrections for %S: " word) candidates)) - -(defun +spell-correct-helm-fn (candidates word) - (helm :sources (helm-build-sync-source - "Ispell" - :candidates candidates) - :prompt (format "Corrections for %S: " word))) - -(defun +spell-correct-generic-fn (candidates word) - (completing-read (format "Corrections for %S: " word) candidates)) - -;;;###autoload -(defun +spell/correct () - "Correct spelling of word at point." - (interactive) - ;; spell-fu fails to initialize correctly if it can't find aspell or a similar - ;; program. We want to signal the error, not tell the user that every word is - ;; spelled correctly. - (unless (;; This is what spell-fu uses to check for the aspell executable - or (and ispell-really-aspell ispell-program-name) - (executable-find "aspell")) - (user-error "Aspell is required for spell checking")) - - (ispell-set-spellchecker-params) - (save-current-buffer - (ispell-accept-buffer-local-defs)) - (if (not (or (modulep! :completion ivy) - (modulep! :completion helm) - (modulep! :completion vertico))) - (call-interactively #'ispell-word) - (cl-destructuring-bind (start . end) - (or (bounds-of-thing-at-point 'word) - (user-error "No word at point")) - (let ((word (thing-at-point 'word t)) - (orig-pt (point)) - poss ispell-filter) - (ispell-send-string "%\n") - (ispell-send-string (concat "^" word "\n")) - (while (progn (accept-process-output ispell-process) - (not (string= "" (car ispell-filter))))) - ;; Remove leading empty element - (setq ispell-filter (cdr ispell-filter)) - ;; ispell process should return something after word is sent. Tag word as - ;; valid (i.e., skip) otherwise - (unless ispell-filter - (setq ispell-filter '(*))) - (when (consp ispell-filter) - (setq poss (ispell-parse-output (car ispell-filter)))) - (cond - ((or (eq poss t) (stringp poss)) - ;; don't correct word - (message "%s is correct" (funcall ispell-format-word-function word)) - t) - ((null poss) - ;; ispell error - (error "Ispell: error in Ispell process")) - (t - ;; The word is incorrect, we have to propose a replacement. - (setq res (funcall +spell-correct-interface (nth 2 poss) word)) - ;; Some interfaces actually eat 'C-g' so it's impossible to stop rapid - ;; mode. So when interface returns nil we treat it as a stop. - (unless res (setq res (cons 'break word))) - (cond - ((stringp res) - (+spell--correct res poss word orig-pt start end)) - ((let ((cmd (car res)) - (wrd (cdr res))) - (unless (or (eq cmd 'skip) - (eq cmd 'break) - (eq cmd 'stop)) - (+spell--correct cmd poss wrd orig-pt start end) - (unless (string-equal wrd word) - (+spell--correct wrd poss word orig-pt start end)))))) - (ispell-pdict-save t))))))) - -;;;###autoload (defalias '+spell/add-word #'spell-fu-word-add) -;;;###autoload (defalias '+spell/remove-word #'spell-fu-word-remove) -;;;###autoload (defalias '+spell/next-error #'spell-fu-goto-next-error) -;;;###autoload (defalias '+spell/previous-error #'spell-fu-goto-previous-error) diff --git a/.config/emacs/modules/checkers/spell/config.el b/.config/emacs/modules/checkers/spell/config.el @@ -1,249 +0,0 @@ -;;; checkers/spell/config.el -*- lexical-binding: t; -*- - -;; -;;; Ispell - -;; `elisp-mode' is loaded at startup. In order to lazy load its config we need -;; to pretend it isn't loaded -(delq! 'ispell features) - -(global-set-key [remap ispell-word] #'+spell/correct) - -(after! ispell - ;; Don't spellcheck org blocks - (pushnew! ispell-skip-region-alist - '(":\\(PROPERTIES\\|LOGBOOK\\):" . ":END:") - '("#\\+BEGIN_SRC" . "#\\+END_SRC") - '("#\\+BEGIN_EXAMPLE" . "#\\+END_EXAMPLE")) - - ;; Enable either aspell, hunspell or enchant. - ;; If no module flags are given, enable either aspell, hunspell or enchant - ;; if their binary is found. - ;; If one of the flags `+aspell', `+hunspell' or `+enchant' is given, - ;; only enable that spell checker. - (pcase (cond ((modulep! +aspell) 'aspell) - ((modulep! +hunspell) 'hunspell) - ((modulep! +enchant) 'enchant) - ((executable-find "aspell") 'aspell) - ((executable-find "hunspell") 'hunspell) - ((executable-find "enchant-2") 'enchant)) - (`aspell - (setq ispell-program-name "aspell" - ispell-extra-args '("--sug-mode=ultra" - "--run-together")) - - (unless ispell-aspell-dict-dir - (setq ispell-aspell-dict-dir - (ispell-get-aspell-config-value "dict-dir"))) - (unless ispell-aspell-data-dir - (setq ispell-aspell-data-dir - (ispell-get-aspell-config-value "data-dir"))) - (unless ispell-personal-dictionary - (setq ispell-personal-dictionary - (expand-file-name (concat "ispell/" ispell-dictionary ".pws") - doom-data-dir))) - - (add-hook! 'text-mode-hook - (defun +spell-remove-run-together-switch-for-aspell-h () - (setq-local ispell-extra-args (remove "--run-together" ispell-extra-args)))) - - (defun +spell-init-ispell-extra-args-a (orig-fun &rest args) - :around '(ispell-word flyspell-auto-correct-word) - (let ((ispell-extra-args (remove "--run-together" ispell-extra-args))) - (ispell-kill-ispell t) - (apply orig-fun args) - (ispell-kill-ispell t)))) - - (`hunspell - (setq ispell-program-name "hunspell")) - - (`enchant - (setq ispell-program-name "enchant-2")) - - (_ (doom-log "Spell checker not found. Either install `aspell', `hunspell' or `enchant'")))) - - -;; -;;; Implementations - -(eval-if! (not (modulep! +flyspell)) - - (use-package! spell-fu - :when (executable-find "aspell") - :hook (text-mode . spell-fu-mode) - :general ([remap ispell-word] #'+spell/correct) - :preface - (defvar +spell-correct-interface - (cond ((modulep! :completion ivy) - #'+spell-correct-ivy-fn) - ((modulep! :completion helm) - #'+spell-correct-helm-fn) - (#'+spell-correct-generic-fn)) - "Function to use to display corrections.") - - :init - (defvar +spell-excluded-faces-alist - '((markdown-mode - . (markdown-code-face - markdown-html-attr-name-face - markdown-html-attr-value-face - markdown-html-tag-name-face - markdown-inline-code-face - markdown-link-face - markdown-markup-face - markdown-plain-url-face - markdown-reference-face - markdown-url-face)) - (org-mode - . (org-block - org-block-begin-line - org-block-end-line - org-cite - org-cite-key - org-code - org-date - org-footnote - org-formula - org-inline-src-block - org-latex-and-related - org-link - org-meta-line - org-property-value - org-ref-cite-face - org-special-keyword - org-tag - org-todo - org-todo-keyword-done - org-todo-keyword-habt - org-todo-keyword-kill - org-todo-keyword-outd - org-todo-keyword-todo - org-todo-keyword-wait - org-verbatim)) - (latex-mode - . (font-latex-math-face - font-latex-sedate-face - font-lock-function-name-face - font-lock-keyword-face - font-lock-variable-name-face))) - "Faces in certain major modes that spell-fu will not spellcheck.") - - (setq spell-fu-directory (concat doom-data-dir "spell-fu")) - (when (modulep! +everywhere) - (add-hook! '(yaml-mode-hook - conf-mode-hook - prog-mode-hook) - #'spell-fu-mode)) - :config - ;; TODO PR this fix upstream! - (defadvice! +spell--fix-face-detection-a (fn &rest args) - "`spell-fu--faces-at-point' uses face detection that won't penetrary -overlays (like `hl-line'). This makes `spell-fu-faces-exclude' demonstrably less -useful when it'll still spellcheck excluded faces on any line that `hl-line' is -displayed on, even momentarily." - :around #'spell-fu--faces-at-point - (letf! (defun get-char-property (pos prop &optional obj) - (or (plist-get (text-properties-at pos) prop) - (funcall get-char-property pos prop obj))) - (apply fn args))) - - (defadvice! +spell--create-word-dict-a (_word words-file _action) - "Prevent `spell-fu--word-add-or-remove' from throwing non-existant -directory errors when writing a personal dictionary file (by creating the -directory first)." - :before #'spell-fu--word-add-or-remove - (unless (file-exists-p words-file) - (make-directory (file-name-directory words-file) t) - (with-temp-file words-file - (insert (format "personal_ws-1.1 %s 0\n" ispell-dictionary))))) - - (add-hook! 'spell-fu-mode-hook - (defun +spell-init-excluded-faces-h () - "Set `spell-fu-faces-exclude' according to `+spell-excluded-faces-alist'." - (when-let (excluded (cdr (cl-find-if #'derived-mode-p +spell-excluded-faces-alist :key #'car))) - (setq-local spell-fu-faces-exclude excluded)))) - - ;; TODO custom `spell-fu-check-range' function to reduce false positives - ;; more intelligently, or modify `spell-fu-word-regexp' to include - ;; non-latin charactersets. - ) - - (use-package! flyspell ; built-in - :defer t - :preface - ;; `flyspell' is loaded at startup. In order to lazy load its config we need - ;; to pretend it isn't loaded. - (defer-feature! flyspell flyspell-mode flyspell-prog-mode) - :init - (add-hook! '(org-mode-hook - markdown-mode-hook - TeX-mode-hook - rst-mode-hook - mu4e-compose-mode-hook - message-mode-hook - git-commit-mode-hook) - #'flyspell-mode) - - (when (modulep! +everywhere) - (add-hook! '(yaml-mode-hook - conf-mode-hook - prog-mode-hook) - #'flyspell-prog-mode)) - - :config - (provide 'ispell) ; forcibly load ispell configs - - (setq flyspell-issue-welcome-flag nil - ;; Significantly speeds up flyspell, which would otherwise print - ;; messages for every word when checking the entire buffer - flyspell-issue-message-flag nil) - - (add-hook! 'flyspell-mode-hook - (defun +spell-inhibit-duplicate-detection-maybe-h () - "Don't mark duplicates when style/grammar linters are present. -e.g. proselint and langtool." - (and (or (and (bound-and-true-p flycheck-mode) - (executable-find "proselint")) - (featurep 'langtool)) - (setq-local flyspell-mark-duplications-flag nil)))) - - ;; Ensure mode-local predicates declared with `set-flyspell-predicate!' are - ;; used in their respective major modes. - (add-hook 'flyspell-mode-hook #'+spell-init-flyspell-predicate-h) - - (let ((flyspell-correct - (cmds! (and (not mark-active) - (not (and (bound-and-true-p evil-local-mode) - (or (evil-insert-state-p) - (evil-emacs-state-p)))) - (memq 'flyspell-incorrect (face-at-point nil t))) - #'flyspell-correct-at-point))) - (map! :map flyspell-mouse-map - "RET" flyspell-correct - [return] flyspell-correct - [mouse-1] #'flyspell-correct-at-point))) - - - (use-package! flyspell-correct - :commands flyspell-correct-previous - :general ([remap ispell-word] #'flyspell-correct-at-point) - :config - (cond ((and (modulep! :completion helm) - (require 'flyspell-correct-helm nil t))) - ((and (modulep! :completion ivy) - (require 'flyspell-correct-ivy nil t))) - ((modulep! :completion vertico)) ; vertico doesn't need any extra configuration - ((require 'flyspell-correct-popup nil t) ; only use popup if no compatible completion UI is enabled - (setq flyspell-popup-correct-delay 0.8) - (define-key popup-menu-keymap [escape] #'keyboard-quit)))) - - - (use-package! flyspell-lazy - :after flyspell - :config - (setq flyspell-lazy-idle-seconds 1 - flyspell-lazy-window-idle-seconds 3) - ;; Fix #3357: flyspell-lazy inhibits flyspell entirely in message-mode - ;; derivatives (e.g. for notmuch users). - (setq-hook! 'message-mode-hook flyspell-lazy-disallow-buffers nil) - (flyspell-lazy-mode +1))) diff --git a/.config/emacs/modules/checkers/spell/doctor.el b/.config/emacs/modules/checkers/spell/doctor.el @@ -1,10 +0,0 @@ -;;; checkers/spell/doctor.el -*- lexical-binding: t; -*- - -(when (or (not (modulep! +flyspell)) - (modulep! +aspell)) - (unless (executable-find "aspell") - (warn! "Couldn't find aspell executable; spell checker will not work"))) - -(when (modulep! +hunspell) - (unless (executable-find "hunspell") - (warn! "Couldn't find hunspell executable; spell checker will not work"))) diff --git a/.config/emacs/modules/checkers/spell/packages.el b/.config/emacs/modules/checkers/spell/packages.el @@ -1,13 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; checkers/spell/packages.el - -(if (not (modulep! +flyspell)) - (package! spell-fu :pin "aed6e87aa31013534b7a6cbedb26e4f29ccea735") - (package! flyspell-correct :pin "7d7b6b01188bd28e20a13736ac9f36c3367bd16e") - (cond ((modulep! :completion ivy) - (package! flyspell-correct-ivy)) - ((modulep! :completion helm) - (package! flyspell-correct-helm)) - ((not (modulep! :completion vertico)) - (package! flyspell-correct-popup))) - (package! flyspell-lazy :pin "0fc5996bcee20b46cbd227ae948d343c3bef7339")) diff --git a/.config/emacs/modules/checkers/syntax/README.org b/.config/emacs/modules/checkers/syntax/README.org @@ -1,83 +0,0 @@ -#+title: :checkers syntax -#+subtitle: Tasing you for every semicolon you forget -#+created: February 20, 2017 -#+since: 2.0.0 - -* Description :unfold: -This module provides syntax checking and error highlighting, powered by -[[doom-package:flycheck]]. - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +childframe :: - Display errors/warnings in a [[https://www.gnu.org/software/emacs/manual/html_node/elisp/Child-Frames.html][child frame]] rather than an overlay or tooltip. - *Requires GUI Emacs.* - -** Packages -- [[doom-package:flycheck]] -- [[doom-package:flycheck-popup-tip]] -- [[doom-package:flycheck-posframe]] if [[doom-module:+childframe]] - -** Hacks -- If ~lsp-ui-mode~ is active, most of the aesthetic functionality of this module - is turned off, as they show the same information. - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module has no direct requirements, but some languages may have their own -requirements to fulfill before you get syntax checking in them (and some -languages may lack syntax checking support altogether). Run ~$ doom doctor~ to -find out if you're missing any dependencies. - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -Most of flycheck's features are under [[kbd:][C-c !]], regardless of whether evil mode is -used. - -| Keybind | Description | -|---------+-----------------------------| -| [[kbd:][C-c ! ?]] | Describe Checker | -| [[kbd:][C-c ! c]] | Check syntax in buffer | -| [[kbd:][C-c ! l]] | List errors | -| [[kbd:][C-c ! n]] | Next Error | -| [[kbd:][C-c ! p]] | Previous error | -| [[kbd:][C-c ! C]] | Clear all errors in buffer | -| [[kbd:][C-c ! e]] | Explain error at point | -| [[kbd:][C-c ! h]] | Display all errors at point | - -Evil Specific: -| Keybind | Description | -|---------+-----------------| -| [[kbd:][SPC t f]] | Toggle Flycheck | -| [[kbd:][SPC c x]] | List errors | -| [[kbd:][] e]] | Next error | -| [[kbd:][[ e]] | Prevous error | - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -[[doom-report:][Report an issue?]] - -- Use ~M-x flycheck-verify-setup~ to determine what checkers are available in a - buffer and whether they're active or not (and why). - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/checkers/syntax/autoload.el b/.config/emacs/modules/checkers/syntax/autoload.el @@ -1,25 +0,0 @@ -;;; checkers/syntax/autoload.el -*- lexical-binding: t; -*- - -;;;###autodef -(defun set-next-checker! (mode checker next &optional append) - "TODO" - (let ((fn (intern (format "+syntax--init-checkers-for-%s-h" mode)))) - (fset fn - (lambda () - (if (not (bound-and-true-p flycheck-mode)) - (add-hook 'flycheck-mode-hook fn 'append 'local) - (flycheck-add-next-checker checker next append) - (remove-hook 'flycheck-mode-hook fn 'local)))) - (add-hook (intern (format "%s-hook" mode)) fn))) - -;;;###autoload -(defun +syntax-init-popups-h () - "Activate `flycheck-posframe-mode' if available and in GUI Emacs. -Activate `flycheck-popup-tip-mode' otherwise. -Do nothing if `lsp-ui-mode' is active and `lsp-ui-sideline-enable' is non-nil." - (unless (and (bound-and-true-p lsp-ui-mode) - lsp-ui-sideline-enable) - (if (and (fboundp 'flycheck-posframe-mode) - (display-graphic-p)) - (flycheck-posframe-mode +1) - (flycheck-popup-tip-mode +1)))) diff --git a/.config/emacs/modules/checkers/syntax/config.el b/.config/emacs/modules/checkers/syntax/config.el @@ -1,83 +0,0 @@ -;;; checkers/syntax/config.el -*- lexical-binding: t; -*- - -;; -;;; Flycheck - -(use-package! flycheck - :commands flycheck-list-errors flycheck-buffer - :hook (doom-first-buffer . global-flycheck-mode) - :config - (setq flycheck-emacs-lisp-load-path 'inherit) - - ;; Rerunning checks on every newline is a mote excessive. - (delq 'new-line flycheck-check-syntax-automatically) - ;; And don't recheck on idle as often - (setq flycheck-idle-change-delay 1.0) - - ;; For the above functionality, check syntax in a buffer that you switched to - ;; only briefly. This allows "refreshing" the syntax check state for several - ;; buffers quickly after e.g. changing a config file. - (setq flycheck-buffer-switch-check-intermediate-buffers t) - - ;; Display errors a little quicker (default is 0.9s) - (setq flycheck-display-errors-delay 0.25) - - ;; Don't commandeer input focus if the error message pops up (happens when - ;; tooltips and childframes are disabled). - (set-popup-rules! - '(("^\\*Flycheck error messages\\*" :select nil) - ("^\\*Flycheck errors\\*" :size 0.25))) - - (add-hook! 'doom-escape-hook :append - (defun +syntax-check-buffer-h () - "Flycheck buffer on ESC in normal mode." - (when flycheck-mode - (ignore-errors (flycheck-buffer)) - nil))) - - (map! :map flycheck-error-list-mode-map - :n "C-n" #'flycheck-error-list-next-error - :n "C-p" #'flycheck-error-list-previous-error - :n "j" #'flycheck-error-list-next-error - :n "k" #'flycheck-error-list-previous-error - :n "RET" #'flycheck-error-list-goto-error - :n [return] #'flycheck-error-list-goto-error)) - - -(use-package! flycheck-popup-tip - :commands flycheck-popup-tip-show-popup flycheck-popup-tip-delete-popup - :hook (flycheck-mode . +syntax-init-popups-h) - :config - (setq flycheck-popup-tip-error-prefix "X ") - (after! evil - ;; Don't display popups while in insert or replace mode, as it can affect - ;; the cursor's position or cause disruptive input delays. - (add-hook! '(evil-insert-state-entry-hook evil-replace-state-entry-hook) - #'flycheck-popup-tip-delete-popup) - (defadvice! +syntax--disable-flycheck-popup-tip-maybe-a (&rest _) - :before-while #'flycheck-popup-tip-show-popup - (if evil-local-mode - (eq evil-state 'normal) - (not (bound-and-true-p company-backend)))))) - - -(use-package! flycheck-posframe - :when (modulep! +childframe) - :hook (flycheck-mode . +syntax-init-popups-h) - :config - (setq flycheck-posframe-warning-prefix "! " - flycheck-posframe-info-prefix "··· " - flycheck-posframe-error-prefix "X ") - (after! company - ;; Don't display popups if company is open - (add-hook 'flycheck-posframe-inhibit-functions #'company--active-p)) - (after! evil - ;; Don't display popups while in insert or replace mode, as it can affect - ;; the cursor's position or cause disruptive input delays. - (add-hook! 'flycheck-posframe-inhibit-functions - #'evil-insert-state-p - #'evil-replace-state-p))) - - -;; -;;; TODO Flymake diff --git a/.config/emacs/modules/checkers/syntax/packages.el b/.config/emacs/modules/checkers/syntax/packages.el @@ -1,9 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; checkers/syntax/packages.el - -(package! flycheck :pin "784f184cdd9f9cb4e3dbb997c09d93e954142842") -(package! flycheck-popup-tip :pin "ef86aad907f27ca076859d8d9416f4f7727619c6") -(when (modulep! +childframe) - (package! flycheck-posframe :pin "8f60c9bf124ab9597d681504a73fdf116a0bde12")) - -;; TODO flymake? diff --git a/.config/emacs/modules/completion/README.org b/.config/emacs/modules/completion/README.org @@ -1,18 +0,0 @@ -#+title: :completion -#+created: July 29, 2021 -#+since: 21.12.0 - -* Description -These modules provide interfaces and frameworks completion, including code -completion. - -* Frequently asked questions -** Should I choose Ivy, Helm, Vertico, or Ido? -:PROPERTIES: -:ID: 4f36ae11-1da8-4624-9c30-46b764e849fc -:END: -Vertico is Doom's default and comes highly recommended of the four. It is the -fastest, best integrated in Doom's ecosystem, and its module is the most -actively maintained of the four. It also has the cleanest codebase and ties into -native functionality already existing in Emacs, rather than reinventing the -wheel. diff --git a/.config/emacs/modules/completion/company/README.org b/.config/emacs/modules/completion/company/README.org @@ -1,146 +0,0 @@ -#+title: :completion company -#+subtitle: The ultimate code completion backend -#+created: February 19, 2017 -#+since: 2.0.0 - -* Description :unfold: -This module provides code completion, powered by [[https://github.com/company-mode/company-mode][company-mode]]. Many of Doom's -[[doom-module::lang]] modules require it for "intellisense" functionality. - -https://assets.doomemacs.org/completion/company/overlay.png - -** Maintainers -- [[doom-user:][@hlissner]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +childframe :: - Display completion candidates in a [[https://www.gnu.org/software/emacs/manual/html_node/elisp/Child-Frames.html][child frame]] rather than an overlay or - tooltip. *Requires GUI Emacs.* -- +tng :: - Invoke completion on [[kbd:][TAB]] instad of [[kbd:][C-SPC]]. When company is active, [[kbd:][TAB]] and - [[kbd:][S-TAB]] will navigate the completion candidates. - -** Packages -- [[doom-package:company-box]] if [[doom-module:+childframe]] -- [[doom-package:company-dict]] -- [[doom-package:company-mode]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module has no direct requirements, but some languages may have their own -requirements to fulfill before you get code completion in them (and some -languages may lack code completion support altogether). Run ~$ doom doctor~ to -find out if you're missing any dependencies. - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** Code completion -By default, completion is triggered after a short idle period or with the -[[kbd:][C-SPC]] key. While the popup is visible, the following keys are available: - -| Keybind | Description | -|---------+------------------------------------------| -| [[kbd:][C-n]] | Go to next candidate | -| [[kbd:][C-p]] | Go to previous candidate | -| [[kbd:][C-j]] | (evil) Go to next candidate | -| [[kbd:][C-k]] | (evil) Go to previous candidate | -| [[kbd:][C-h]] | Display documentation (if available) | -| [[kbd:][C-u]] | Move to previous page of candidates | -| [[kbd:][C-d]] | Move to next page of candidates | -| [[kbd:][C-s]] | Filter candidates | -| [[kbd:][C-S-s]] | Search candidates with helm/ivy | -| [[kbd:][C-SPC]] | Complete common | -| [[kbd:][TAB]] | Complete common or select next candidate | -| [[kbd:][S-TAB]] | Select previous candidate | - -** Vim-esque omni-completion prefix (C-x) -In the spirit of Vim's omni-completion, the following insert mode keybinds are -available to evil users to access specific company backends: -| Keybind | Description | -|---------+-----------------------------------| -| [[kbd:][C-x C-]]​] | Complete etags | -| [[kbd:][C-x C-f]] | Complete file path | -| [[kbd:][C-x C-k]] | Complete from dictionary/keyword | -| [[kbd:][C-x C-l]] | Complete full line | -| [[kbd:][C-x C-o]] | Invoke complete-at-point function | -| [[kbd:][C-x C-n]] | Complete next symbol at point | -| [[kbd:][C-x C-p]] | Complete previous symbol at point | -| [[kbd:][C-x C-s]] | Complete snippet | -| [[kbd:][C-x s]] | Complete spelling suggestions | - -** Searching with multiple keywords -If the =vertico= module is enabled, users can perform code completion with multiple search keywords with an ampersand =&=. -More information can be found [[https://github.com/oantolin/orderless#company][here]]. - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** Enable company backend(s) in certain modes -The ~set-company-backend!~ function exists for setting ~company-backends~ -buffer-locally in MODES, which is either a major-mode symbol, a minor-mode -symbol, or a list of either. BACKENDS are prepended to ~company-backends~ for -those modes. - -#+begin_src emacs-lisp -(after! js2-mode - (set-company-backend! 'js2-mode 'company-tide 'company-yasnippet)) - -(after! sh-script - (set-company-backend! 'sh-mode - '(company-shell :with company-yasnippet))) - -(after! cc-mode - (set-company-backend! 'c-mode - '(:separate company-irony-c-headers company-irony))) -#+end_src - -To unset the backends for a particular mode, pass ~nil~ to it: -#+begin_src emacs-lisp -(after! sh-script - (set-company-backend! 'sh-mode nil)) -#+end_src - -* Troubleshooting -[[doom-report:][Report an issue?]] - -** X-mode doesn't have code completion support or requires extra setup -There is no guarantee your language mode will have completion support. - -Some, like ~lua-mode~, don't have completion support in Emacs at all. Others may -requires additional setup to get code completion working. For instance, -~go-mode~ requires ~guru~ to be installed on your system, and ~ruby-mode~ -requires that you have a Robe server running (~M-x robe-start~). - -Check the relevant module's documentation for this kind of information. - -** No backends (or the incorrect ones) have been registered for X-mode -Doom expects every mode to have an explicit list of ~company-backends~ (and as -short a list as possible). This may mean you aren't getting all the completion -you want or any at all. - -Check the value of ~company-backends~ ([[kbd:][SPC h v company-backends]]) from that mode -to see what backends are available. Check the [[*Assigning company backend(s) to modes][Configuration section]] for details -on changing what backends are available for that mode. - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/completion/company/autoload.el b/.config/emacs/modules/completion/company/autoload.el @@ -1,172 +0,0 @@ -;;; completion/company/autoload.el -*- lexical-binding: t; -*- - -;;;###autoload -(defvar +company-backend-alist - '((text-mode (:separate company-dabbrev company-yasnippet company-ispell)) - (prog-mode company-capf company-yasnippet) - (conf-mode company-capf company-dabbrev-code company-yasnippet)) - "An alist matching modes to company backends. The backends for any mode is -built from this.") - -;;;###autodef -(defun set-company-backend! (modes &rest backends) - "Prepends BACKENDS (in order) to `company-backends' in MODES. - -MODES should be one symbol or a list of them, representing major or minor modes. -This will overwrite backends for MODES on consecutive uses. - -If the car of BACKENDS is nil, unset the backends for MODES. - -Examples: - - (set-company-backend! 'js2-mode - 'company-tide 'company-yasnippet) - - (set-company-backend! 'sh-mode - '(company-shell :with company-yasnippet)) - - (set-company-backend! '(c-mode c++-mode) - '(:separate company-irony-c-headers company-irony)) - - (set-company-backend! 'sh-mode nil) ; unsets backends for sh-mode" - (declare (indent defun)) - (dolist (mode (ensure-list modes)) - (if (null (car backends)) - (setq +company-backend-alist - (delq (assq mode +company-backend-alist) - +company-backend-alist)) - (setf (alist-get mode +company-backend-alist) - backends)))) - - -;; -;;; Library - -(defun +company--backends () - (let (backends) - (let ((mode major-mode) - (modes (list major-mode))) - (while (setq mode (get mode 'derived-mode-parent)) - (push mode modes)) - (dolist (mode modes) - (dolist (backend (append (cdr (assq mode +company-backend-alist)) - (default-value 'company-backends))) - (push backend backends))) - (delete-dups - (append (cl-loop for (mode . backends) in +company-backend-alist - if (or (eq major-mode mode) ; major modes - (and (boundp mode) - (symbol-value mode))) ; minor modes - append backends) - (nreverse backends)))))) - - -;; -;;; Hooks - -;;;###autoload -(defun +company-init-backends-h () - "Set `company-backends' for the current buffer." - (or (memq major-mode '(fundamental-mode special-mode)) - buffer-read-only - (doom-temp-buffer-p (or (buffer-base-buffer) (current-buffer))) - (setq-local company-backends (+company--backends)))) - -(put '+company-init-backends-h 'permanent-local-hook t) - - -;; -;;; Commands - -;;;###autoload -(defun +company-has-completion-p () - "Return non-nil if a completion candidate exists at point." - (when company-mode - (unless company-candidates-length - (company-manual-begin)) - (= company-candidates-length 1))) - -;;;###autoload -(defun +company/toggle-auto-completion () - "Toggle as-you-type code completion." - (interactive) - (require 'company) - (setq company-idle-delay (unless company-idle-delay 0.2)) - (message "Auto completion %s" - (if company-idle-delay "enabled" "disabled"))) - -;;;###autoload -(defun +company/complete () - "Bring up the completion popup. If only one result, complete it." - (interactive) - (require 'company) - (when (ignore-errors - (/= (point) - (cdr (bounds-of-thing-at-point 'symbol)))) - (save-excursion (insert " "))) - (when (and (company-manual-begin) - (= company-candidates-length 1)) - (company-complete-common))) - -;;;###autoload -(defun +company/dabbrev () - "Invokes `company-dabbrev-code' in prog-mode buffers and `company-dabbrev' -everywhere else." - (interactive) - (call-interactively - (if (derived-mode-p 'prog-mode) - #'company-dabbrev-code - #'company-dabbrev))) - -;;;###autoload -(defun +company/whole-lines (command &optional arg &rest ignored) - "`company-mode' completion backend that completes whole-lines, akin to vim's -C-x C-l." - (interactive (list 'interactive)) - (require 'company) - (pcase command - (`interactive (company-begin-backend '+company/whole-lines)) - (`prefix (company-grab-line "^[\t\s]*\\(.+\\)" 1)) - (`candidates - (all-completions - arg - (delete-dups - (split-string - (replace-regexp-in-string - "^[\t\s]+" "" - (concat (buffer-substring-no-properties (point-min) (line-beginning-position)) - (buffer-substring-no-properties (line-end-position) (point-max)))) - "\\(\r\n\\|[\n\r]\\)" t)))))) - -;;;###autoload -(defun +company/dict-or-keywords () - "`company-mode' completion combining `company-dict' and `company-keywords'." - (interactive) - (require 'company-dict) - (require 'company-keywords) - (let ((company-backends '((company-keywords company-dict)))) - (call-interactively #'company-complete))) - -;;;###autoload -(defun +company/dabbrev-code-previous () - "TODO" - (interactive) - (require 'company-dabbrev) - (let ((company-selection-wrap-around t)) - (call-interactively #'+company/dabbrev) - (company-select-previous-or-abort))) - -;;;###autoload -(defun +company/completing-read () - "Complete current company candidates in minibuffer. - -Uses ivy, helm, vertico, or ido, if available." - (interactive) - (cond ((modulep! :completion ivy) - (call-interactively #'counsel-company)) - ((modulep! :completion helm) - (call-interactively #'helm-company)) - ((not company-candidates) - (user-error "No company candidates available")) - ((when-let (cand (completing-read "Candidate: " company-candidates)) - (company-finish cand))))) diff --git a/.config/emacs/modules/completion/company/config.el b/.config/emacs/modules/completion/company/config.el @@ -1,186 +0,0 @@ -;;; completion/company/config.el -*- lexical-binding: t; -*- - -(use-package! company - :commands (company-complete-common - company-complete-common-or-cycle - company-manual-begin - company-grab-line) - :hook (doom-first-input . global-company-mode) - :init - (setq company-minimum-prefix-length 2 - company-tooltip-limit 14 - company-tooltip-align-annotations t - company-require-match 'never - company-global-modes - '(not erc-mode - circe-mode - message-mode - help-mode - gud-mode - vterm-mode) - company-frontends - '(company-pseudo-tooltip-frontend ; always show candidates in overlay tooltip - company-echo-metadata-frontend) ; show selected candidate docs in echo area - - ;; Buffer-local backends will be computed when loading a major mode, so - ;; only specify a global default here. - company-backends '(company-capf) - - ;; These auto-complete the current selection when - ;; `company-auto-commit-chars' is typed. This is too magical. We - ;; already have the much more explicit RET and TAB. - company-auto-commit nil - - ;; Only search the current buffer for `company-dabbrev' (a backend that - ;; suggests text your open buffers). This prevents Company from causing - ;; lag once you have a lot of buffers open. - company-dabbrev-other-buffers nil - ;; Make `company-dabbrev' fully case-sensitive, to improve UX with - ;; domain-specific words with particular casing. - company-dabbrev-ignore-case nil - company-dabbrev-downcase nil) - - (when (modulep! +tng) - (add-hook 'global-company-mode-hook #'company-tng-mode)) - - :config - (when (modulep! :editor evil) - (add-hook 'company-mode-hook #'evil-normalize-keymaps) - (add-hook! 'evil-normal-state-entry-hook - (defun +company-abort-h () - ;; HACK `company-abort' doesn't no-op if company isn't active; causing - ;; unwanted side-effects, like the suppression of messages in the - ;; echo-area. - ;; REVIEW Revisit this to refactor; shouldn't be necessary! - (when company-candidates - (company-abort)))) - ;; Allow users to switch between backends on the fly. E.g. C-x C-s followed - ;; by C-x C-n, will switch from `company-yasnippet' to - ;; `company-dabbrev-code'. - (defadvice! +company--abort-previous-a (&rest _) - :before #'company-begin-backend - (company-abort))) - - (add-hook 'after-change-major-mode-hook #'+company-init-backends-h 'append) - - - ;; NOTE Fix #1335: ensure `company-emulation-alist' is the first item of - ;; `emulation-mode-map-alists', thus higher priority than keymaps of - ;; evil-mode. We raise the priority of company-mode keymaps - ;; unconditionally even when completion is not activated. This should not - ;; cause problems, because when completion is activated, the value of - ;; `company-emulation-alist' is ((t . company-my-keymap)), when - ;; completion is not activated, the value is ((t . nil)). - (add-hook! 'evil-local-mode-hook - (when (memq 'company-emulation-alist emulation-mode-map-alists) - (company-ensure-emulation-alist))) - - ;; Fix #4355: allow eldoc to trigger after completions. - (after! eldoc - (eldoc-add-command 'company-complete-selection - 'company-complete-common - 'company-capf - 'company-abort))) - - -;; -;;; Packages - -(after! company-files - ;; Fix `company-files' completion for org file:* links - (add-to-list 'company-files--regexps "file:\\(\\(?:\\.\\{1,2\\}/\\|~/\\|/\\)[^\]\n]*\\)")) - - -(use-package! company-box - :when (modulep! +childframe) - :hook (company-mode . company-box-mode) - :config - (setq company-box-show-single-candidate t - company-box-backends-colors nil - company-box-max-candidates 50 - company-box-icons-alist 'company-box-icons-all-the-icons - ;; Move company-box-icons--elisp to the end, because it has a catch-all - ;; clause that ruins icons from other backends in elisp buffers. - company-box-icons-functions - (cons #'+company-box-icons--elisp-fn - (delq 'company-box-icons--elisp - company-box-icons-functions)) - company-box-icons-all-the-icons - (let ((all-the-icons-scale-factor 0.8)) - `((Unknown . ,(all-the-icons-material "find_in_page" :face 'all-the-icons-purple)) - (Text . ,(all-the-icons-material "text_fields" :face 'all-the-icons-green)) - (Method . ,(all-the-icons-material "functions" :face 'all-the-icons-red)) - (Function . ,(all-the-icons-material "functions" :face 'all-the-icons-red)) - (Constructor . ,(all-the-icons-material "functions" :face 'all-the-icons-red)) - (Field . ,(all-the-icons-material "functions" :face 'all-the-icons-red)) - (Variable . ,(all-the-icons-material "adjust" :face 'all-the-icons-blue)) - (Class . ,(all-the-icons-material "class" :face 'all-the-icons-red)) - (Interface . ,(all-the-icons-material "settings_input_component" :face 'all-the-icons-red)) - (Module . ,(all-the-icons-material "view_module" :face 'all-the-icons-red)) - (Property . ,(all-the-icons-material "settings" :face 'all-the-icons-red)) - (Unit . ,(all-the-icons-material "straighten" :face 'all-the-icons-red)) - (Value . ,(all-the-icons-material "filter_1" :face 'all-the-icons-red)) - (Enum . ,(all-the-icons-material "plus_one" :face 'all-the-icons-red)) - (Keyword . ,(all-the-icons-material "filter_center_focus" :face 'all-the-icons-red)) - (Snippet . ,(all-the-icons-material "short_text" :face 'all-the-icons-red)) - (Color . ,(all-the-icons-material "color_lens" :face 'all-the-icons-red)) - (File . ,(all-the-icons-material "insert_drive_file" :face 'all-the-icons-red)) - (Reference . ,(all-the-icons-material "collections_bookmark" :face 'all-the-icons-red)) - (Folder . ,(all-the-icons-material "folder" :face 'all-the-icons-red)) - (EnumMember . ,(all-the-icons-material "people" :face 'all-the-icons-red)) - (Constant . ,(all-the-icons-material "pause_circle_filled" :face 'all-the-icons-red)) - (Struct . ,(all-the-icons-material "streetview" :face 'all-the-icons-red)) - (Event . ,(all-the-icons-material "event" :face 'all-the-icons-red)) - (Operator . ,(all-the-icons-material "control_point" :face 'all-the-icons-red)) - (TypeParameter . ,(all-the-icons-material "class" :face 'all-the-icons-red)) - (Template . ,(all-the-icons-material "short_text" :face 'all-the-icons-green)) - (ElispFunction . ,(all-the-icons-material "functions" :face 'all-the-icons-red)) - (ElispVariable . ,(all-the-icons-material "check_circle" :face 'all-the-icons-blue)) - (ElispFeature . ,(all-the-icons-material "stars" :face 'all-the-icons-orange)) - (ElispFace . ,(all-the-icons-material "format_paint" :face 'all-the-icons-pink))))) - - ;; HACK Fix oversized scrollbar in some odd cases - ;; REVIEW `resize-mode' is deprecated and may stop working in the future. - ;; TODO PR me upstream? - (setq x-gtk-resize-child-frames 'resize-mode) - - ;; Disable tab-bar in company-box child frames - ;; TODO PR me upstream! - (add-to-list 'company-box-frame-parameters '(tab-bar-lines . 0)) - - ;; Don't show documentation in echo area, because company-box displays its own - ;; in a child frame. - (delq! 'company-echo-metadata-frontend company-frontends) - - (defun +company-box-icons--elisp-fn (candidate) - (when (derived-mode-p 'emacs-lisp-mode) - (let ((sym (intern candidate))) - (cond ((fboundp sym) 'ElispFunction) - ((boundp sym) 'ElispVariable) - ((featurep sym) 'ElispFeature) - ((facep sym) 'ElispFace))))) - - ;; `company-box' performs insufficient frame-live-p checks. Any command that - ;; "cleans up the session" will break company-box. - ;; TODO Fix this upstream. - (defadvice! +company-box-detect-deleted-frame-a (frame) - :filter-return #'company-box--get-frame - (if (frame-live-p frame) frame)) - (defadvice! +company-box-detect-deleted-doc-frame-a (_selection frame) - :before #'company-box-doc - (and company-box-doc-enable - (frame-local-getq company-box-doc-frame frame) - (not (frame-live-p (frame-local-getq company-box-doc-frame frame))) - (frame-local-setq company-box-doc-frame nil frame)))) - - -(use-package! company-dict - :defer t - :config - (setq company-dict-dir (expand-file-name "dicts" doom-user-dir)) - (add-hook! 'doom-project-hook - (defun +company-enable-project-dicts-h (mode &rest _) - "Enable per-project dictionaries." - (if (symbol-value mode) - (add-to-list 'company-dict-minor-mode-list mode nil #'eq) - (setq company-dict-minor-mode-list (delq mode company-dict-minor-mode-list)))))) diff --git a/.config/emacs/modules/completion/company/packages.el b/.config/emacs/modules/completion/company/packages.el @@ -1,7 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; completion/company/packages.el - -(package! company :pin "2ca3e29abf87392714bc2b26e50e1c0f4b9f4e2c") -(package! company-dict :pin "cd7b8394f6014c57897f65d335d6b2bd65dab1f4") -(when (modulep! +childframe) - (package! company-box :pin "766546b2668b5ef4eb4abbde632c9acd370c7788")) diff --git a/.config/emacs/modules/completion/company/test/test-company.el b/.config/emacs/modules/completion/company/test/test-company.el @@ -1,75 +0,0 @@ -;; -*- lexical-binding: t; no-byte-compile: t; -*- -;;; completion/company/test/test-company.el - -(describe "completion/company" - (before-all - (load! "../autoload")) - - (describe ":company-backend" - :var (a +company-backend-alist backends) - (before-each - (setq-default company-backends '(t)) - (setq +company-backend-alist nil - a (get-buffer-create "x")) - (fset 'backends - (lambda (mode) - (let ((major-mode mode)) - (+company--backends)))) - (set-buffer a) - (spy-on 'require)) - (after-each - (kill-buffer a)) - - ;; - (it "sets backends for a major mode" - (set-company-backend! 'text-mode 'a) - (expect (backends 'text-mode) :to-equal '(a t))) - - (it "sets backends for a derived-mode" - (set-company-backend! 'prog-mode 'a) - (expect (backends 'prog-mode) :to-equal '(a t)) - (expect (backends 'emacs-lisp-mode) :to-equal '(a t))) - - (it "sets multiple backends for exact major modes" - (set-company-backend! '(text-mode emacs-lisp-mode) 'a 'b) - (expect (backends 'text-mode) :to-equal (backends 'emacs-lisp-mode))) - - (it "sets cumulative backends" - (set-company-backend! 'prog-mode '(a b c)) - (set-company-backend! 'emacs-lisp-mode 'd 'e) - (expect (backends 'emacs-lisp-mode) :to-equal '(d e (a b c) t))) - - (it "sets cumulative backends with a minor mode" - (set-company-backend! 'prog-mode '(a b c)) - (set-company-backend! 'emacs-lisp-mode 'd 'e) - (set-company-backend! 'some-minor-mode 'x 'y) - (setq-local some-minor-mode t) - (expect (backends 'emacs-lisp-mode) :to-equal '(x y d e (a b c) t))) - - (it "overwrites past backends" - (set-company-backend! 'text-mode 'old 'backends) - (set-company-backend! 'text-mode 'new 'backends) - (expect (backends 'text-mode) :to-equal '(new backends t))) - - (it "unsets past backends" - (set-company-backend! 'text-mode 'old) - (set-company-backend! 'text-mode nil) - (expect (backends 'text-mode) :to-equal (default-value 'company-backends))) - - (it "unsets past parent backends" - (set-company-backend! 'prog-mode 'old) - (set-company-backend! 'emacs-lisp-mode 'child) - (set-company-backend! 'prog-mode nil) - (expect (backends 'emacs-lisp-mode) :to-equal '(child t))) - - (it "overwrites past cumulative backends" - (set-company-backend! 'prog-mode 'base) - (set-company-backend! 'emacs-lisp-mode 'old) - (set-company-backend! 'emacs-lisp-mode 'new) - (expect (backends 'emacs-lisp-mode) :to-equal '(new base t))) - - (it "overwrites past parent backends" - (set-company-backend! 'prog-mode 'base) - (set-company-backend! 'emacs-lisp-mode 'child) - (set-company-backend! 'prog-mode 'new) - (expect (backends 'emacs-lisp-mode) :to-equal '(child new t))))) diff --git a/.config/emacs/modules/completion/helm/README.org b/.config/emacs/modules/completion/helm/README.org @@ -1,206 +0,0 @@ -#+title: :completion helm -#+subtitle: A bazooka for hunting house flies -#+created: February 20, 2017 -#+since: 2.0.0 - -* Description :unfold: -This module provides Helm integration to a variety of Emacs commands, as well as -a unified interface for project search and replace, powered by [[https://github.com/BurntSushi/ripgrep][Ripgrep]]. - -For official documentation about Helm, see: -- [[https://rnchzn.github.io/helm/doc/helm-manual.html]] -- [[https://tuhdo.github.io/helm-intro.html]] - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +childframe :: - Display Helm windows in a [[https://www.gnu.org/software/emacs/manual/html_node/elisp/Child-Frames.html][child frame]] rather than an popup buffer. *Requires - GUI Emacs.* -- +fuzzy :: - Enable fuzzy completion for Helm searches. -- +icons :: - Display icons on completion results (where possible) using either - [[doom-package:all-the-icons]] or [[doom-package:treemacs]] iconsets. - -** Packages -- [[doom-package:helm]] -- [[doom-package:helm-company]] -- [[doom-package:helm-c-yasnippet]] -- [[doom-package:helm-descbinds]] -- [[doom-package:helm-describe-modes]] -- [[doom-package:helm-flx]]* if [[doom-module:+fuzzy]] -- [[doom-package:helm-icons]]* if [[doom-module:+icons]] -- [[doom-package:helm-org]]* if [[doom-module::lang org]] -- [[doom-package:helm-posframe]]* if [[doom-module:+childframe]] -- [[doom-package:helm-projectile]] -- [[doom-package:helm-rg]] -- [[doom-package:helm-swiper]] - -** TODO Hacks -#+begin_quote - 🔨 This module's hacks haven't been documented yet. [[doom-contrib-module:][Document them?]] -#+end_quote - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module has only one requirement: [[https://github.com/BurntSushi/ripgrep][Ripgrep]], which is a hard dependency of -Doom itself, so you should already have it installed. - -By enabling this module, it will enable helm-mode and remap many commands to -their helm equivalents, such as: - -- [[cmd:][find-file]] ([[kbd:][C-c C-f]] or [[kbd:][<leader> f f]]) -> [[cmd:][helm-find-files]] -- [[cmd:][execute-extended-command]] ([[kbd:][M-x]]) -> [[cmd:][helm-M-x]] -- [[cmd:][switch-to-buffer]] ([[kbd:][C-x b]] or [[kbd:][<leader> b b]]) -> [[cmd:][helm-buffers-list]] -- ...among others - -No setup is required on your part. Helm provides many commands to interface with -a variety of programs from [[https://github.com/junegunn/fzf][fzf]] to [[https://kapeli.com/dash][Dash docsets]] to [[https://www.passwordstore.org/][pass]] and /much/ more. These -programs are optional for this module, but must be installed if you intend to -use their associated Helm command or package. - -* TODO Usage -Much like [[doom-package:ivy]] and [[doom-package:vertico]], [[doom-package:helm]] is a /large/ framework. Covering -all its features is not within the scope of this module's documentation, so only -its highlights will be covered here. - -** Jump-to navigation -Similar to Ivy, this module provides an interface to navigate within a project -using [[doom-package:projectile]]: -| Keybind | Description | -|------------------+---------------------------------------------------------| -| [[kbd:][SPC p f]], [[kbd:][SPC SPC]] | Jump to file in project (~+helm/projectile-find-file~) | -| [[kbd:][SPC f f]], [[kbd:][SPC .]] | Jump to file from current directory (~helm-find-files~) | -| [[kbd:][SPC s i]] | Jump to symbol in file (~helm-semantic-or-imenu~) | - -** Project search & replace -This module also provides interactive text search and replace using [[https://github.com/BurntSushi/ripgrep][Ripgrep]]. - -*** Search -| Keybind | Description | -|---------+-----------------------------------------------------------| -| [[kbd:][SPC s p]] | Search project (~+default/search-project~) | -| [[kbd:][SPC s P]] | Search another project (~+default/search-other-project~) | -| [[kbd:][SPC s d]] | Search this directory (~+default/search-cwd~) | -| [[kbd:][SPC s D]] | Search another directory (~+default/search-other-cwd~) | - -Prefixing these keys with the universal argument ([[kbd:][SPC u]] for evil users; [[kbd:][C-u]] -otherwise) changes the behavior of these commands, instructing the underlying -search engine to include ignored files. - -This module also provides Ex Commands for evil users: -| Ex command | Description | -|------------------------+------------------------------------------------------------------| -| ~:pg[rep][!] [QUERY]~ | Search project (if ~!~, include hidden files) | -| ~:pg[rep]d[!] [QUERY]~ | Search from current directory (if ~!~, don't search recursively) | - -The optional ~!~ is equivalent to the universal argument for the previous -commands. - -*** Replace -These keybindings are available while a search is active: -| Keybind | Description | -|---------+-----------------------------------------------| -| [[kbd:][C-c C-o]] | Open a buffer with your search results | -| [[kbd:][C-c C-e]] | Open a writable buffer of your search results | -| [[kbd:][C-SPC]] | Preview the current candidate | -| [[kbd:][C-RET]] | Open the selected candidate in other-window | - -Changes to the resulting [[doom-package:wgrep]] buffer (opened by [[kbd:][C-c C-e]]) can be -committed with [[kbd:][C-c C-c]] and aborted with [[kbd:][C-c C-k]] (alternatively [[kbd:][ZZ]] and [[kbd:][ZQ]], for -evil users). - -** In-buffer searching -The [[doom-package:swiper]] package provides an interactive buffer search powered by helm. It can -be invoked with: -- [[kbd:][SPC s s]] ([[cmd:][swiper-isearch]]) -- [[kbd:][SPC s S]] ([[cmd:][swiper-isearch-thing-at-point]]) -- [[kbd:][SPC s b]] ([[cmd:][swiper]]) -- ~:sw[iper] [QUERY]~ - -A [[doom-package:wgrep]] buffer can be opened from swiper with [[kbd:][C-c C-e]]. - -** Helm integration for various completing commands -Helm also has a number of overrides for built-in functionality: - -*** General -| Keybind | Description | -|------------+---------------------------| -| [[kbd:][M-x]], [[kbd:][SPC :]] | Smarter, smex-powered M-x | -| [[kbd:][SPC ']] | Resume last ivy session | - -*** Jump to files, buffers or projects -| Keybind | Description | -|---------+----------------------------------------------------------------------| -| [[kbd:][SPC p t]] | List all TODO/FIXMEs in project | -| [[kbd:][SPC s b]] | Search the current buffer (~+default/search-buffer~) | -| [[kbd:][SPC s d]] | Search this directory (~+default/search-cwd~) | -| [[kbd:][SPC s D]] | Search another directory (~+default/search-other-cwd~) | -| [[kbd:][SPC s i]] | Search for symbol in current buffer | -| [[kbd:][SPC s p]] | Search project (~+default/search-project~) | -| [[kbd:][SPC s P]] | Search another project (~+default/search-other-project~) | -| [[kbd:][SPC s s]] | Search the current buffer (incrementally) (~+default/search-buffer~) | - -*** Search -| Keybind | Description | -|---------+----------------------------------------------------------------------| -| [[kbd:][SPC p t]] | List all TODO/FIXMEs in project | -| [[kbd:][SPC s b]] | Search the current buffer (~+default/search-buffer~) | -| [[kbd:][SPC s d]] | Search this directory (~+default/search-cwd~) | -| [[kbd:][SPC s D]] | Search another directory (~+default/search-other-cwd~) | -| [[kbd:][SPC s i]] | Search for symbol in current buffer | -| [[kbd:][SPC s p]] | Search project (~+default/search-project~) | -| [[kbd:][SPC s P]] | Search another project (~+default/search-other-project~) | -| [[kbd:][SPC s s]] | Search the current buffer (incrementally) (~+default/search-buffer~) | - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** helm-mode -This module enables helm-mode by default, which will force any functions that -call ~completing-read~, ~read-file-name~, ~completion-in-region~ and friends to -use Helm's completion interface instead. Any function listed in the -[[var:][helm-completing-read-handlers-alist]] variable will be exempt from this. - -For example, an emacs command ~foo~ in package ~bar~ that uses a completion -framework other than helm, say company, may break if handed off to Helm, so it -makes sense to exempt ~foo~ with the following: -#+begin_src emacs-lisp -;; add to $DOOMDIR/config.el -(after! helm - (add-to-list 'helm-completing-read-handlers-alist (cons #'foo nil))) -#+end_src - -** Icons -There are two icon "themes" available for this module: -[[doom-package:all-the-icons]] and [[doom-package:treemacs]]. By default, and to -maintain consistency with other icons across Doom's modules, -[[doom-package:all-the-icons]] is used. To change this: -#+begin_src emacs-lisp -;; add to $DOOMDIR/config.el -(after! helm - (setq helm-icons-provider 'treemacs)) -#+end_src - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -[[doom-suggest-faq:][Ask a question?]] - -** Helm vs Ivy vs Ido vs Vertico -See [[id:4f36ae11-1da8-4624-9c30-46b764e849fc][this answer]]. - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/completion/helm/autoload/evil.el b/.config/emacs/modules/completion/helm/autoload/evil.el @@ -1,42 +0,0 @@ -;;; completion/helm/autoload/evil.el -*- lexical-binding: t; -*- -;;;###if (modulep! :editor evil) - -;;;###autoload (autoload '+helm:project-search "completion/helm/autoload/evil" nil t) -(evil-define-command +helm:project-search (all-files-p query) - "Ex interface for `+helm/grep'" - (interactive "<!><a>") - (+helm/project-search all-files-p query)) - -;;;###autoload (autoload '+helm:project-search-from-cwd "completion/helm/autoload/evil" nil t) -(evil-define-command +helm:project-search-from-cwd (query &optional recurse-p) - "Ex interface for `+helm/grep-from-cwd'." - (interactive "<a><!>") - (+helm/project-search-from-cwd (not recurse-p) query)) - -;;;###autoload -(defun +helm--set-prompt-display (pos) - "TODO" - (let (beg state region-active m) - (with-selected-window (minibuffer-window) - (setq beg (save-excursion (vertical-motion 0 (helm-window)) (point)) - state evil-state - region-active (region-active-p) - m (mark t))) - (when region-active - (setq m (- m beg)) - ;; Increment pos to handle the space before prompt (i.e `pref'). - (put-text-property (1+ (min m pos)) (+ 2 (max m pos)) - 'face - (list :background (face-background 'region)) - header-line-format)) - (put-text-property - ;; Increment pos to handle the space before prompt (i.e `pref'). - (+ 1 pos) (+ 2 pos) - 'face - (if (eq state 'insert) - 'underline - ;; Don't just use 'cursor, this can hide the current character. - (list :inverse-video t - :foreground (face-background 'cursor) - :background (face-background 'default))) - header-line-format))) diff --git a/.config/emacs/modules/completion/helm/autoload/helm.el b/.config/emacs/modules/completion/helm/autoload/helm.el @@ -1,100 +0,0 @@ -;;; completion/helm/autoload/helm.el -*- lexical-binding: t; -*- - -;;;###autoload -(defun +helm/projectile-find-file () - "Call `helm-find-files' if called from HOME, otherwise -`helm-projectile-find-file'." - (interactive) - (call-interactively - (if (or (file-equal-p default-directory "~") - (if-let* ((proot (doom-project-root))) - (file-equal-p proot "~") - t)) - #'helm-find-files - #'helm-projectile-find-file))) - -;;;###autoload -(defun +helm/workspace-buffer-list () - "A version of `helm-buffers-list' with its buffer list restricted to the -current workspace." - (interactive) - (unless (modulep! :ui workspaces) - (user-error "This command requires the :ui workspaces module")) - (with-no-warnings - (with-persp-buffer-list nil (helm-buffers-list)))) - -;;;###autoload -(defun +helm/workspace-mini () - "A version of `helm-mini' with its buffer list restricted to the current -workspace." - (interactive) - (unless (modulep! :ui workspaces) - (user-error "This command requires the :ui workspaces module")) - (with-no-warnings - (with-persp-buffer-list nil (helm-mini)))) - - -;; -;;; Project search - -;;;###autoload -(cl-defun +helm-file-search (&key query in all-files (recursive t) _prompt args) - "Conduct a file search using ripgrep. - -:query STRING - Determines the initial input to search for. -:in PATH - Sets what directory to base the search out of. Defaults to the current - project's root. -:recursive BOOL - Whether or not to search files recursively from the base directory." - (declare (indent defun)) - (unless (executable-find "rg") - (user-error "Couldn't find ripgrep in your PATH")) - (require 'helm-rg) - (let ((this-command 'helm-rg) - (helm-rg-default-directory (or in (doom-project-root) default-directory)) - (helm-rg-default-extra-args - (delq nil (append (list (when all-files "-z -uu") - (unless recursive "--maxdepth 1") - "--hidden" "-g" "!.git") - args)))) - (setq deactivate-mark t) - (helm-rg (or query - (when (use-region-p) - (let ((beg (or (bound-and-true-p evil-visual-beginning) (region-beginning))) - (end (or (bound-and-true-p evil-visual-end) (region-end)))) - (when (> (abs (- end beg)) 1) - (buffer-substring-no-properties beg end)))) - "")))) - -;;;###autoload -(defun +helm/project-search (&optional arg initial-query directory) - "Performs a project search from the project root with ripgrep. - -ARG (universal argument), include all files, even hidden or compressed ones, in -the search." - (interactive "P") - (+helm-file-search - :query initial-query - :in directory - :all-files (and (not (null arg)) - (listp arg)))) - -;;;###autoload -(defun +helm/project-search-from-cwd (&optional arg initial-query) - "Performs a project search recursively from the current directory. - -If ARG (universal argument), include all files, even hidden or compressed ones." - (interactive "P") - (+helm-file-search - :query initial-query - :in default-directory - :all-files (and (not (null arg)) - (listp arg)))) - -;;;###autoload -(defun +helm/jump-list () - "TODO" - (interactive) - (error "not implemented yet")) diff --git a/.config/emacs/modules/completion/helm/config.el b/.config/emacs/modules/completion/helm/config.el @@ -1,201 +0,0 @@ -;;; completion/helm/config.el -*- lexical-binding: t; -*- - -;; Posframe (requires +childframe) -(defvar +helm-posframe-handler #'posframe-poshandler-frame-center - "The function that determines the location of the childframe. -It should return a cons cell representing the X and Y coordinates. See -`posframe-poshandler-frame-center' as a reference.") - -(defvar +helm-posframe-text-scale 1 - "The text-scale to use in the helm childframe. Set to nil for no scaling. -Can be negative.") - -(defvar +helm-posframe-parameters - '((internal-border-width . 8) - (width . 0.65) - (height . 0.35) - (min-width . 80) - (min-height . 16)) - "Default parameters for the helm childframe.") - -;; -;;; Packages - -(use-package! helm-mode - :hook (doom-first-input . helm-mode) - :config - ;; helm is too heavy for `find-file-at-point' - (add-to-list 'helm-completing-read-handlers-alist (cons #'find-file-at-point nil))) - - -(use-package! helm - :after helm-mode - :preface - (setq helm-candidate-number-limit 150 - ;; Remove extraineous helm UI elements - helm-display-header-line nil - helm-ff-auto-update-initial-value nil - helm-find-files-doc-header nil - ;; Default helm window sizes - helm-display-buffer-default-width nil - helm-display-buffer-default-height 0.25 - ;; When calling `helm-semantic-or-imenu', don't immediately jump to - ;; symbol at point. - helm-imenu-execute-action-at-once-if-one nil - ;; Disable special behavior for left/right, M-left/right keys. - helm-ff-lynx-style-map nil) - - (map! [remap apropos] #'helm-apropos - [remap find-library] #'helm-locate-library - [remap bookmark-jump] #'helm-bookmarks - [remap execute-extended-command] #'helm-M-x - [remap find-file] #'helm-find-files - [remap ibuffer-find-file] #'helm-find-files - [remap locate] #'helm-locate - [remap imenu] #'helm-semantic-or-imenu - [remap noop-show-kill-ring] #'helm-show-kill-ring - [remap persp-switch-to-buffer] #'+helm/workspace-mini - [remap switch-to-buffer] #'helm-buffers-list - [remap projectile-find-file] #'+helm/projectile-find-file - [remap projectile-recentf] #'helm-projectile-recentf - [remap projectile-switch-project] #'helm-projectile-switch-project - [remap projectile-switch-to-buffer] #'helm-projectile-switch-to-buffer - [remap recentf-open-files] #'helm-recentf - [remap yank-pop] #'helm-show-kill-ring) - - (when (modulep! :editor evil +everywhere) - (setq helm-default-prompt-display-function #'+helm--set-prompt-display)) - - :init - (let ((fuzzy (modulep! +fuzzy))) - (setq helm-apropos-fuzzy-match fuzzy - helm-bookmark-show-location fuzzy - helm-buffers-fuzzy-matching fuzzy - helm-ff-fuzzy-matching fuzzy - helm-file-cache-fuzzy-match fuzzy - helm-flx-for-helm-locate fuzzy - helm-imenu-fuzzy-match fuzzy - helm-lisp-fuzzy-completion fuzzy - helm-locate-fuzzy-match fuzzy - helm-projectile-fuzzy-match fuzzy - helm-recentf-fuzzy-match fuzzy - helm-semantic-fuzzy-match fuzzy) - - ;; Make sure that we have helm-multi-matching or fuzzy matching, (as - ;; prescribed by the fuzzy flag) also in the following cases: - ;; - ;; - helmized commands that use `completion-at-point' and similar functions - ;; - native commands that fall back to `completion-styles' like `helm-M-x' - ;; - ;; However, do not add helm completion styles to the front of - ;; `completion-styles', since that would be overly intrusive. E.g., it - ;; results in `company-capf' returning far to many completion candidates. - ;; Instead, append those styles so that they act as a fallback. Variable - ;; completion-styles is ignored unless helm-completion-style is customized - ;; to 'emacs. - (setq helm-completion-style 'emacs) - (add-to-list 'completion-styles (if fuzzy 'flex 'helm) t)) - - :config - (set-popup-rule! "^\\*helm" :vslot -100 :size 0.22 :ttl nil) - - ;; Hide minibuffer if `helm-echo-input-in-header-line' - (add-hook 'helm-minibuffer-set-up-hook #'helm-hide-minibuffer-maybe) - - ;; Use helpful instead of describe-* to display documentation - (dolist (fn '(helm-describe-variable helm-describe-function)) - (advice-add fn :around #'doom-use-helpful-a))) - - -(use-package! helm-posframe - :when (modulep! +childframe) - :hook (helm-mode . helm-posframe-enable) - :config - (setq helm-posframe-poshandler #'posframe-poshandler-frame-center - helm-posframe-width 0.65 - helm-posframe-height 0.35 - helm-posframe-min-width 80 - helm-posframe-min-height 16 - helm-posframe-border-width 8)) - - -(use-package! helm-flx - :when (modulep! +fuzzy) - :hook (helm-mode . helm-flx-mode)) - - -(after! helm-rg - (setq helm-rg-display-buffer-normal-method #'pop-to-buffer) - (set-popup-rule! "^helm-rg-" :ttl nil :select t :size 0.45) - (map! :map helm-rg-map - "C-c C-e" #'helm-rg--bounce) - (map! :map helm-rg--bounce-mode-map - "q" #'kill-current-buffer - "C-c C-c" (cmd! (helm-rg--bounce-dump) (kill-current-buffer)) - "C-x C-c" #'helm-rg--bounce-dump-current-file - "C-c C-k" #'kill-current-buffer)) - - -;;;###package helm-bookmark -(setq helm-bookmark-show-location t) - - -(after! helm-files - (setq helm-boring-file-regexp-list - (append (list "\\.projects$" "\\.DS_Store$") - helm-boring-file-regexp-list))) - - -(defvar helm-generic-files-map (make-sparse-keymap)) -(after! helm-locate - (when (and IS-MAC - (null helm-locate-command) - (executable-find "mdfind")) - (setq helm-locate-command "mdfind -name %s")) - (set-keymap-parent helm-generic-files-map helm-map)) - - -(use-package! helm-org - :when (modulep! :lang org) - :defer t - :init - (after! helm-mode - (pushnew! helm-completing-read-handlers-alist - '(org-capture . helm-org-completing-read-tags) - '(org-set-tags . helm-org-completing-read-tags)))) - - -;; DEPRECATED: Remove when projectile is replaced with project.el -(use-package! helm-projectile - :commands (helm-projectile-find-file - helm-projectile-recentf - helm-projectile-switch-project - helm-projectile-switch-to-buffer) - :init - (defvar helm-projectile-find-file-map (make-sparse-keymap)) - :config - (set-keymap-parent helm-projectile-find-file-map helm-map)) - - -(use-package! swiper-helm - :defer t - :config - (setq ivy-height 20 - swiper-helm-display-function - (lambda (buf &optional _resume) (pop-to-buffer buf))) - (global-set-key [remap swiper] #'swiper-helm) - (add-to-list 'swiper-font-lock-exclude #'+doom-dashboard-mode nil #'eq)) - - -(use-package! helm-descbinds - :hook (helm-mode . helm-descbinds-mode)) - - -(use-package! helm-icons - :when (modulep! +icons) - :hook (helm-mode . helm-icons-enable) - :init - (setq helm-icons-provider 'all-the-icons) - :config - (when (eq helm-icons-provider 'all-the-icons) - (setq helm-icons-mode->icon nil))) diff --git a/.config/emacs/modules/completion/helm/packages.el b/.config/emacs/modules/completion/helm/packages.el @@ -1,20 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; completion/helm/packages.el - -(package! helm :pin "dfd6403947c5cd9f32afcd6bc92a1756cc958c82") -(package! helm-company :pin "6eb5c2d730a60e394e005b47c1db018697094dde") -(package! helm-c-yasnippet :pin "e214eec8b2875d8a7cd09006dfb6a8e15e9e4079") -(package! helm-descbinds :pin "b72515982396b6e336ad7beb6767e95a80fca192") -(package! helm-describe-modes :pin "11fb36af119b784539d31c6160002de1957408aa") -(package! helm-projectile :pin "35a2111d00c0c0c9d8743280d3f1243bb217118a") -(package! helm-rg :pin "ee0a3c09da0c843715344919400ab0a0190cc9dc") -(package! swiper-helm :pin "93fb6db87bc6a5967898b5fd3286954cc72a0008") - -(when (modulep! +childframe) - (package! helm-posframe :pin "87461b52b6f3f378c63642a33f584d4a4ba28351")) -(when (modulep! +fuzzy) - (package! helm-flx :pin "5220099e695a3586dba2d59640217fe378e66310")) -(when (modulep! +icons) - (package! helm-icons :pin "8d2f5e705c8b78a390677cf242024739c932fc95")) -(when (modulep! :lang org) - (package! helm-org :pin "d67186d3a64e610c03a5f3d583488f018fb032e4")) diff --git a/.config/emacs/modules/completion/ido/README.org b/.config/emacs/modules/completion/ido/README.org @@ -1,56 +0,0 @@ -#+title: :completion ido -#+subtitle: A foil for other search engines -#+created: February 20, 2017 -#+since: 2.0.0 - -* Description :unfold: -Interactive DO things. The completion engine that is /mostly/ built-into Emacs. - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:crm-custom]] -- [[doom-package:flx-ido]] -- [[doom-package:ido-completing-read+]] -- [[doom-package:ido-sort-mtime]] -- [[doom-package:ido-vertical-mode]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* Usage -#+begin_quote -🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Configuration -#+begin_quote -🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -[[doom-suggest-faq:][Ask a question?]] - -** Helm vs Ivy vs Ido vs Vertico -See [[id:4f36ae11-1da8-4624-9c30-46b764e849fc][this answer]]. - -* Appendix -#+begin_quote -🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/completion/ido/config.el b/.config/emacs/modules/completion/ido/config.el @@ -1,62 +0,0 @@ -;;; completion/ido/config.el -*- lexical-binding: t; -*- - -(defvar ido-mode-hook nil - "List of hooks to run when `ido-mode' is activated.") - - -;; -;;; Packages - -(use-package! ido - :hook (doom-first-input . ido-mode) - :hook (ido-mode . ido-ubiquitous-mode) - :preface - ;; HACK `ido' is a really old package. It defines `ido-mode' manually and - ;; doesn't define a hook, so we define one for it, so we can use it! - (defadvice! +ido-run-hooks-a (&rest _) - :after #'ido-mode - (run-hooks 'ido-mode-hook)) - :init - (setq ido-save-directory-list-file (concat doom-cache-dir "ido.last")) - :config - (pushnew! ido-ignore-files "\\`.DS_Store$" "Icon\\?$") - (setq ido-ignore-buffers - '("\\` " "^\\*ESS\\*" "^\\*Messages\\*" "^\\*[Hh]elp" "^\\*Buffer" - "^\\*.*Completions\\*$" "^\\*Ediff" "^\\*tramp" "^\\*cvs-" "_region_" - " output\\*$" "^TAGS$" "^\*Ido") - ido-auto-merge-work-directories-length -1 - ido-confirm-unique-completion t - ido-case-fold t - ido-create-new-buffer 'always - ido-enable-flex-matching t - ido-everywhere t) - - (map! :map (ido-common-completion-map ido-file-completion-map) - "C-w" #'ido-delete-backward-word-updir - :map (ido-common-completion-map ido-file-dir-completion-map) - "C-n" #'ido-next-match - "C-p" #'ido-prev-match - [down] #'ido-next-match - [up] #'ido-prev-match - :map ido-file-completion-map - ;; Go to $HOME with ~ - "~" (cmd! (if (looking-back "/" (point-min)) - (insert "~/") - (call-interactively #'self-insert-command))))) - - -(use-package! ido-vertical-mode - :hook (ido-mode . ido-vertical-mode) - :config (setq ido-vertical-show-count t)) - - -(use-package! ido-sort-mtime - :hook (ido-mode . ido-sort-mtime-mode)) - - -(use-package! crm-custom - :hook (ido-mode . crm-custom-mode)) - - -(use-package! flx-ido - :hook (ido-mode . flx-ido-mode)) diff --git a/.config/emacs/modules/completion/ido/packages.el b/.config/emacs/modules/completion/ido/packages.el @@ -1,8 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; completion/ido/packages.el - -(package! flx-ido :pin "7b44a5abb254bbfbeca7a29336f7f4ebd8aabbf2") -(package! ido-completing-read+ :pin "49e7967ea8c0ab0a206b40d70fc19be115083fa1") -(package! ido-sort-mtime :pin "f638ff0c922af862f5211779f2311a27fde428eb") -(package! ido-vertical-mode :pin "b1659e967da0687abceca733b389ace24004fa66") -(package! crm-custom :pin "f1aaccf64306a5f99d9bf7ba815d7ea41c15518d") diff --git a/.config/emacs/modules/completion/ivy/README.org b/.config/emacs/modules/completion/ivy/README.org @@ -1,190 +0,0 @@ -#+title: :completion ivy -#+subtitle: Yesterday's lightest search engine -#+created: February 20, 2017 -#+since: 2.0.0 - -* Description :unfold: -This module provides Ivy integration for a variety of Emacs commands, as well as -a unified interface for project search and replace, powered by [[https://github.com/BurntSushi/ripgrep/][ripgrep]]. - -#+begin_quote -I prefer ivy over ido for its flexibility. I prefer ivy over helm because it's -lighter, simpler and faster in many cases. -#+end_quote - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +childframe :: - Display Ivy windows in a [[https://www.gnu.org/software/emacs/manual/html_node/elisp/Child-Frames.html][child frame]] rather than an popup buffer. *Requires - GUI Emacs.* -- +fuzzy :: - Enable fuzzy completion for Ivy searches. -- +icons :: - Enable file icons for switch-{buffer,project}/find-file commands. -- +prescient :: - Enable prescient filtering and sorting for Ivy searches. - -** Packages -- [[doom-package:all-the-icons-ivy]]* if [[doom-module:+icons]] -- [[doom-package:amx]] -- [[doom-package:counsel]] -- [[doom-package:counsel-projectile]] -- [[doom-package:flx]]* if [[doom-module:+fuzzy]] -- [[doom-package:ivy]] -- [[doom-package:ivy-hydra]] -- [[doom-package:ivy-posframe]]* if [[doom-module:+childframe]] -- [[doom-package:ivy-rich]] -- [[doom-package:prescient]]* if [[doom-module:+prescient]] -- [[doom-package:swiper]] -- [[doom-package:wgrep]] - -** Hacks -- Functions with ivy/counsel equivalents have been globally remapped (like - ~find-file~ => ~counsel-find-file~). So a keybinding to ~find-file~ will - invoke ~counsel-find-file~ instead. -- ~counsel-[arp]g~'s 3-character limit was reduced to 1 (mainly for the ex - command) - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module has only one requirement: [[https://github.com/BurntSushi/ripgrep][Ripgrep]], which is a hard dependency of -Doom itself, so you should already have it installed. - -Otherwise, Counsel (an Ivy plugin) provides many commands to interface with a -variety of programs from [[https://github.com/junegunn/fzf][fzf]] to [[https://kapeli.com/dash][Dash docsets]] to [[https://www.passwordstore.org/][pass]] and /much/ more. These -programs are optional for this module, but must be installed if you intend to -use their associated Helm command or plugin. - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -[[doom-package:ivy]] is a /large/ framework for completing things. Covering all its features is -not within the scope of this module's documentation, so only its highlights will -be covered here. - -** Jump-to navigation -Inspired by Sublime Text's jump-to-anywhere, CtrlP/Unite in Vim, and Textmate's -Command-T, this module provides similar functionality by bringing [[doom-package:projectile]] and -[[doom-package:ivy]] together. - -https://assets.doomemacs.org/completion/ivy/projectile.png - -| Keybind | Description | -|------------------+-------------------------------------| -| [[kbd:][SPC p f]], [[kbd:][SPC SPC]] | Jump to file in project | -| [[kbd:][SPC f f]], [[kbd:][SPC .]] | Jump to file from current directory | -| [[kbd:][SPC s i]] | Jump to symbol in file | - -** Project search & replace -This module provides interactive text search and replace using ripgrep. - -| Keybind | Description | -|---------+--------------------------| -| [[kbd:][SPC s p]] | Search project | -| [[kbd:][SPC s P]] | Search another project | -| [[kbd:][SPC s d]] | Search this directory | -| [[kbd:][SPC s D]] | Search another directory | - -https://assets.doomemacs.org/completion/ivy/search.png - -Prefixing these keys with the universal argument (=SPC u= for evil users; =C-u= -otherwise) changes the behavior of these commands, instructing the underlying -search engine to include ignored files. - -This module also provides Ex Commands for evil users: -| Ex command | Description | -|------------------------+------------------------------------------------------------------| -| ~:pg[rep][!] [QUERY]~ | Search project (if ~!~, include hidden files) | -| ~:pg[rep]d[!] [QUERY]~ | Search from current directory (if ~!~, don't search recursively) | - -The optional `!` is equivalent to the universal argument for the previous -commands. - ------ - -These keybindings are available while a search is active: -| Keybind | Description | -|---------+-----------------------------------------------| -| [[kbd:][C-c C-o]] | Open a buffer with your search results | -| [[kbd:][C-c C-e]] | Open a writable buffer of your search results | -| [[kbd:][C-SPC]] | Preview the current candidate | -| [[kbd:][C-RET]] | Open the selected candidate in other-window | - -Changes to the resulting wgrep buffer (opened by [[kbd:][C-c C-e]]) can be committed with -[[kbd:][C-c C-c]] and aborted with [[kbd:][C-c C-k]] (alternatively [[kbd:][ZZ]] and [[kbd:][ZQ]], for evil users). - -https://assets.doomemacs.org/completion/ivy/search-replace.png - -** In-buffer searching -The [[doom-package:swiper]] package provides an interactive buffer search powered by ivy. It -can be invoked with: - -- [[kbd:][SPC s s]] (~swiper-isearch~) -- [[kbd:][SPC s S]] (~swiper-isearch-thing-at-point~) -- [[kbd:][SPC s b]] (~swiper~) -- ~:sw[iper] [QUERY]~ - -https://assets.doomemacs.org/completion/ivy/swiper.png - -A wgrep buffer can be opened from swiper with [[kbd:][C-c C-e]]. - -** Ivy integration for various completing commands -*** General -| Keybind | Description | -|------------+---------------------------| -| [[kbd:][M-x]], [[kbd:][SPC :]] | Smarter, smex-powered M-x | -| [[kbd:][SPC ']] | Resume last ivy session | - -*** Jump to files, buffers or projects -| Keybind | Description | -|------------------+---------------------------------------| -| [[kbd:][SPC RET]] | Find bookmark | -| [[kbd:][SPC f f]], [[kbd:][SPC .]] | Browse from current directory | -| [[kbd:][SPC p f]], [[kbd:][SPC SPC]] | Find file in project | -| [[kbd:][SPC f r]] | Find recently opened file | -| [[kbd:][SPC p p]] | Open another project | -| [[kbd:][SPC b b]], [[kbd:][SPC ,]] | Switch to buffer in current workspace | -| [[kbd:][SPC b B]], [[kbd:][SPC <]] | Switch to buffer | - -*** Search -| Keybind | Description | -|---------+-------------------------------------------| -| [[kbd:][SPC p t]] | List all TODO/FIXMEs in project | -| [[kbd:][SPC s b]] | Search the current buffer | -| [[kbd:][SPC s d]] | Search this directory | -| [[kbd:][SPC s D]] | Search another directory | -| [[kbd:][SPC s i]] | Search for symbol in current buffer | -| [[kbd:][SPC s p]] | Search project | -| [[kbd:][SPC s P]] | Search another project | -| [[kbd:][SPC s s]] | Search the current buffer (incrementally) | - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** TODO Enable fuzzy/non-fuzzy search for specific commands -** TODO Change the position of the ivy childframe - -* TODO Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -[[doom-suggest-faq:][Ask a question?]] - -** Helm vs Ivy vs Ido vs Vertico -See [[id:4f36ae11-1da8-4624-9c30-46b764e849fc][this answer]]. - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/completion/ivy/autoload/evil.el b/.config/emacs/modules/completion/ivy/autoload/evil.el @@ -1,14 +0,0 @@ -;; completion/ivy/autoload/evil.el -*- lexical-binding: t; -*- -;;;###if (modulep! :editor evil) - -;;;###autoload (autoload '+ivy:project-search "completion/ivy/autoload/evil" nil t) -(evil-define-command +ivy:project-search (query &optional all-files-p) - "Ex interface for `+ivy/project-search'." - (interactive "<a><!>") - (+ivy/project-search all-files-p query)) - -;;;###autoload (autoload '+ivy:project-search-from-cwd "completion/ivy/autoload/evil" nil t) -(evil-define-command +ivy:project-search-from-cwd (query &optional recurse-p) - "Ex interface for `+ivy/project-search-from-cwd'." - (interactive "<a><!>") - (+ivy/project-search-from-cwd (not recurse-p) query)) diff --git a/.config/emacs/modules/completion/ivy/autoload/hydras.el b/.config/emacs/modules/completion/ivy/autoload/hydras.el @@ -1,32 +0,0 @@ -;;; completion/ivy/autoload/hydras.el -*- lexical-binding: t; -*- -;;;###if (modulep! :ui hydra) - -;;;###autoload -(after! ivy-hydra - (defhydra+ hydra-ivy (:hint nil :color pink) - " - Move ^^^^^^^^^^ | Call ^^^^ | Cancel^^ | Options^^ | Action _w_/_s_/_a_: %s(ivy-action-name) -----------^^^^^^^^^^-+--------------^^^^-+-------^^-+--------^^-+--------------------------------- - _g_ ^ ^ _k_ ^ ^ _u_ | _f_orward _o_ccur | _i_nsert | _c_alling: %-7s(if ivy-calling \"on\" \"off\") _C_ase-fold: %-10`ivy-case-fold-search - ^↨^ _h_ ^+^ _l_ ^↕^ | _RET_ done ^^ | _q_uit | _m_atcher: %-7s(ivy--matcher-desc) _t_runcate: %-11`truncate-lines - _G_ ^ ^ _j_ ^ ^ _d_ | _TAB_ alt-done ^^ | ^ ^ | _<_/_>_: shrink/grow -" - ;; arrows - ("l" ivy-alt-done) - ("h" ivy-backward-delete-char) - ("g" ivy-beginning-of-buffer) - ("G" ivy-end-of-buffer) - ("d" ivy-scroll-up-command) - ("u" ivy-scroll-down-command) - ("e" ivy-scroll-down-command) - ;; actions - ("q" keyboard-escape-quit :exit t) - ("<escape>" keyboard-escape-quit :exit t) - ("TAB" ivy-alt-done :exit nil) - ("RET" ivy-done :exit t) - ("C-SPC" ivy-call-and-recenter :exit nil) - ("f" ivy-call) - ("c" ivy-toggle-calling) - ("m" ivy-toggle-fuzzy) - ("t" (setq truncate-lines (not truncate-lines))) - ("o" ivy-occur :exit t))) diff --git a/.config/emacs/modules/completion/ivy/autoload/ivy.el b/.config/emacs/modules/completion/ivy/autoload/ivy.el @@ -1,384 +0,0 @@ -;;; completion/ivy/autoload/ivy.el -*- lexical-binding: t; -*- - -(defun +ivy--is-workspace-buffer-p (buffer) - (let ((buffer (car buffer))) - (when (stringp buffer) - (setq buffer (get-buffer buffer))) - (+workspace-contains-buffer-p buffer))) - -(defun +ivy--is-workspace-other-buffer-p (buffer) - (let ((buffer (car buffer))) - (when (stringp buffer) - (setq buffer (get-buffer buffer))) - (and (not (eq buffer (current-buffer))) - (+workspace-contains-buffer-p buffer)))) - -;;;###autoload -(defun +ivy-rich-buffer-name (candidate) - "Display the buffer name. - -Buffers that are considered unreal (see `doom-real-buffer-p') are dimmed with -`+ivy-buffer-unreal-face'." - (let ((b (get-buffer candidate))) - (when (null uniquify-buffer-name-style) - (setq candidate (replace-regexp-in-string "<[0-9]+>$" "" candidate))) - (cond ((ignore-errors - (file-remote-p - (buffer-local-value 'default-directory b))) - (ivy-append-face candidate 'ivy-remote)) - ((doom-unreal-buffer-p b) - (ivy-append-face candidate +ivy-buffer-unreal-face)) - ((not (buffer-file-name b)) - (ivy-append-face candidate 'ivy-subdir)) - ((buffer-modified-p b) - (ivy-append-face candidate 'ivy-modified-buffer)) - (candidate)))) - -;;;###autoload -(defun +ivy-rich-buffer-icon (candidate) - "Display the icon for CANDIDATE buffer." - ;; NOTE This is inspired by `all-the-icons-ivy-buffer-transformer', minus the - ;; buffer name and extra padding as those are handled by `ivy-rich'. - (propertize "\t" 'display - (if-let* ((buffer (get-buffer candidate)) - (mode (buffer-local-value 'major-mode buffer))) - (or - (all-the-icons-ivy--icon-for-mode mode) - (all-the-icons-ivy--icon-for-mode (get mode 'derived-mode-parent)) - (funcall - all-the-icons-ivy-family-fallback-for-buffer - all-the-icons-ivy-name-fallback-for-buffer)) - (all-the-icons-icon-for-file candidate)))) - -;;;###autoload -(defun +ivy-rich-describe-variable-transformer (cand) - "Previews the value of the variable in the minibuffer" - (let* ((sym (intern cand)) - (val (and (boundp sym) (symbol-value sym))) - (print-level 3)) - (replace-regexp-in-string - "[\n\t\^[\^M\^@\^G]" " " - (cond ((booleanp val) - (propertize (format "%s" val) 'face - (if (null val) - 'font-lock-comment-face - 'success))) - ((symbolp val) - (propertize (format "'%s" val) - 'face 'highlight-quoted-symbol)) - ((keymapp val) - (propertize "<keymap>" 'face 'font-lock-constant-face)) - ((listp val) - (prin1-to-string val)) - ((stringp val) - (propertize (format "%S" val) 'face 'font-lock-string-face)) - ((numberp val) - (propertize (format "%s" val) 'face 'highlight-numbers-number)) - ((format "%s" val))) - t))) - -;;;###autoload -(defun +ivy-format-function-line-or-arrow (cands) - "Transform CANDS into a string for minibuffer. - -If in terminal, prefix candidates with a chevron to make it more obvious which -one you're selecting, especially in themes that can't set a good background for -`ivy-current-match'. This is a combination of `ivy-format-function-line' and -`ivy-format-function-arrow'. - -In the GUI, this is the same as `ivy-format-function-line'." - (if (display-graphic-p) - (ivy-format-function-line cands) - (ivy--format-function-generic - (lambda (str) - (ivy--add-face (concat "> " str "\n") 'ivy-current-match)) - (lambda (str) - (concat " " str "\n")) - cands - ""))) - - -;; -;; Library - -(defun +ivy--switch-buffer-preview () - (let (ivy-use-virtual-buffers ivy--virtual-buffers) - (counsel--switch-buffer-update-fn))) - -(defalias '+ivy--switch-buffer-preview-all #'counsel--switch-buffer-update-fn) -(defalias '+ivy--switch-buffer-unwind #'counsel--switch-buffer-unwind) - -(defun +ivy--switch-buffer (workspace other) - (let ((current (not other)) - prompt action filter update unwind) - (cond ((and workspace current) - (setq prompt "Switch to workspace buffer: " - action #'ivy--switch-buffer-action - filter #'+ivy--is-workspace-other-buffer-p)) - (workspace - (setq prompt "Switch to workspace buffer in other window: " - action #'ivy--switch-buffer-other-window-action - filter #'+ivy--is-workspace-buffer-p)) - (current - (setq prompt "Switch to buffer: " - action #'ivy--switch-buffer-action)) - ((setq prompt "Switch to buffer in other window: " - action #'ivy--switch-buffer-other-window-action))) - (when +ivy-buffer-preview - (cond ((not (and ivy-use-virtual-buffers - (eq +ivy-buffer-preview 'everything))) - (setq update #'+ivy--switch-buffer-preview - unwind #'+ivy--switch-buffer-unwind)) - ((setq update #'+ivy--switch-buffer-preview-all - unwind #'+ivy--switch-buffer-unwind)))) - (ivy-read prompt 'internal-complete-buffer - :action action - :predicate filter - :update-fn update - :unwind unwind - :preselect (buffer-name (other-buffer (current-buffer))) - :matcher #'ivy--switch-buffer-matcher - :keymap ivy-switch-buffer-map - ;; NOTE A clever disguise, needed for virtual buffers. - :caller #'ivy-switch-buffer))) - -;;;###autoload -(defun +ivy/switch-workspace-buffer (&optional arg) - "Switch to another buffer within the current workspace. - -If ARG (universal argument), open selection in other-window." - (interactive "P") - (+ivy--switch-buffer t arg)) - -;;;###autoload -(defun +ivy/switch-workspace-buffer-other-window () - "Switch another window to a buffer within the current workspace." - (interactive) - (+ivy--switch-buffer t t)) - -;;;###autoload -(defun +ivy/switch-buffer () - "Switch to another buffer." - (interactive) - (+ivy--switch-buffer nil nil)) - -;;;###autoload -(defun +ivy/switch-buffer-other-window () - "Switch to another buffer in another window." - (interactive) - (+ivy--switch-buffer nil t)) - -;;;###autoload -(defun +ivy/woccur () - "Invoke a wgrep buffer on the current ivy results, if supported." - (interactive) - (unless (window-minibuffer-p) - (user-error "No completion session is active")) - (require 'wgrep) - (let ((caller (ivy-state-caller ivy-last))) - (if-let (occur-fn (plist-get +ivy-edit-functions caller)) - (ivy-exit-with-action - (lambda (_) (funcall occur-fn))) - (if-let (occur-fn (plist-get ivy--occurs-list caller)) - (let ((buffer (generate-new-buffer - (format "*ivy-occur%s \"%s\"*" - (if caller (concat " " (prin1-to-string caller)) "") - ivy-text)))) - (with-current-buffer buffer - (let ((inhibit-read-only t)) - (erase-buffer) - (funcall occur-fn)) - (setf (ivy-state-text ivy-last) ivy-text) - (setq ivy-occur-last ivy-last) - (setq-local ivy--directory ivy--directory)) - (ivy-exit-with-action - `(lambda (_) - (pop-to-buffer ,buffer) - (ivy-wgrep-change-to-wgrep-mode)))) - (user-error "%S doesn't support wgrep" caller))))) - -;;;###autoload -(defun +ivy-yas-prompt-fn (prompt choices &optional display-fn) - (yas-completing-prompt prompt choices display-fn #'ivy-completing-read)) - -;;;###autoload -(defun +ivy-git-grep-other-window-action (x) - "Opens the current candidate in another window." - (when (string-match "\\`\\(.*?\\):\\([0-9]+\\):\\(.*\\)\\'" x) - (select-window - (with-ivy-window - (let ((file-name (match-string-no-properties 1 x)) - (line-number (match-string-no-properties 2 x))) - (find-file-other-window (expand-file-name file-name (ivy-state-directory ivy-last))) - (goto-char (point-min)) - (forward-line (1- (string-to-number line-number))) - (re-search-forward (ivy--regex ivy-text t) (line-end-position) t) - (run-hooks 'counsel-grep-post-action-hook) - (selected-window)))))) - -;;;###autoload -(defun +ivy-confirm-delete-file (x) - (dired-delete-file x 'confirm-each-subdirectory)) - - -;; -;;; File searching - -;;;###autoload -(defun +ivy/projectile-find-file () - "A more sensible `counsel-projectile-find-file', which will revert to -`counsel-find-file' if invoked from $HOME or /, `counsel-file-jump' if invoked -from a non-project, `projectile-find-file' if in a big project (more than -`ivy-sort-max-size' files), or `counsel-projectile-find-file' otherwise. - -The point of this is to avoid Emacs locking up indexing massive file trees." - (interactive) - ;; Spoof the command so that ivy/counsel will display the (well fleshed-out) - ;; actions list for `counsel-find-file' on C-o. The actions list for the other - ;; commands aren't as well configured or are empty. - (let ((this-command 'counsel-find-file)) - (call-interactively - (cond ((or (file-equal-p default-directory "~") - (file-equal-p default-directory "/") - (when-let (proot (doom-project-root)) - (file-equal-p proot "~"))) - #'counsel-find-file) - - ((doom-project-p) - (let ((files (projectile-current-project-files))) - (if (<= (length files) ivy-sort-max-size) - #'counsel-projectile-find-file - #'projectile-find-file))) - - (#'counsel-file-jump))))) - -;;;###autoload -(cl-defun +ivy-file-search (&key query in all-files (recursive t) prompt args) - "Conduct a file search using ripgrep. - -:query STRING - Determines the initial input to search for. -:in PATH - Sets what directory to base the search out of. Defaults to the current - project's root. -:recursive BOOL - Whether or not to search files recursively from the base directory." - (declare (indent defun)) - (unless (executable-find "rg") - (user-error "Couldn't find ripgrep in your PATH")) - (require 'counsel) - (let* ((this-command 'counsel-rg) - (project-root (or (doom-project-root) default-directory)) - (directory (or in project-root)) - (args (concat (if all-files " -uu") - (unless recursive " --maxdepth 1") - " --hidden -g!.git " - (mapconcat #'shell-quote-argument args " ")))) - (setq deactivate-mark t) - (counsel-rg - (or query - (when (doom-region-active-p) - (replace-regexp-in-string - "[! |]" (lambda (substr) - (cond ((and (string= substr " ") - (not (modulep! +fuzzy))) - " ") - ((string= substr "|") - "\\\\\\\\|") - ((concat "\\\\" substr)))) - (rxt-quote-pcre (doom-thing-at-point-or-region))))) - directory args - (or prompt - (format "Search project [%s]: " - (cond ((equal directory default-directory) - "./") - ((equal directory project-root) - (projectile-project-name)) - ((file-relative-name directory project-root))) - (string-trim args)))))) - -;;;###autoload -(defun +ivy/project-search (&optional arg initial-query directory) - "Performs a live project search from the project root using ripgrep. - -If ARG (universal argument), include all files, even hidden or compressed ones, -in the search." - (interactive "P") - (+ivy-file-search :query initial-query :in directory :all-files arg)) - -;;;###autoload -(defun +ivy/project-search-from-cwd (&optional arg initial-query) - "Performs a project search recursively from the current directory. - -If ARG (universal argument), include all files, even hidden or compressed ones." - (interactive "P") - (+ivy/project-search arg initial-query default-directory)) - - -;; -;;; Wrappers around `counsel-compile' - -;;;###autoload -(defun +ivy/compile () - "Execute a compile command from the current buffer's directory." - (interactive) - ;; Fix unhelpful 'Couldn't find project root' error - (letf! (defun counsel--compile-root () - (ignore-errors - (funcall counsel--compile-root))) - (counsel-compile default-directory))) - -;;;###autoload -(defun +ivy/project-compile () - "Execute a compile command from the current project's root." - (interactive) - (counsel-compile (projectile-project-root))) - -;;;###autoload -(defun +ivy/jump-list () - "Go to an entry in evil's (or better-jumper's) jumplist." - (interactive) - ;; REVIEW Refactor me - (let (buffers) - (unwind-protect - (ivy-read "jumplist: " - (nreverse - (delete-dups - (delq - nil - (mapcar (lambda (mark) - (when mark - (cl-destructuring-bind (path pt _id) mark - (let ((buf (get-file-buffer path))) - (unless buf - (push (setq buf (find-file-noselect path t)) - buffers)) - (with-current-buffer buf - (goto-char pt) - (font-lock-fontify-region (line-beginning-position) (line-end-position)) - (cons (format "%s:%d: %s" - (buffer-name) - (line-number-at-pos) - (string-trim-right (or (thing-at-point 'line) ""))) - (point-marker))))))) - (cddr (better-jumper-jump-list-struct-ring - (better-jumper-get-jumps (better-jumper--get-current-context)))))))) - :sort nil - :require-match t - :action (lambda (cand) - (let ((mark (cdr cand))) - (delq! (marker-buffer mark) buffers) - (mapc #'kill-buffer buffers) - (setq buffers nil) - (with-current-buffer (switch-to-buffer (marker-buffer mark)) - (goto-char (marker-position mark))))) - :caller '+ivy/jump-list) - (mapc #'kill-buffer buffers)))) - -;;;###autoload -(defun +ivy/git-grep-other-window-action () - "Open the current counsel-{ag,rg,git-grep} candidate in other-window." - (interactive) - (ivy-set-action #'+ivy-git-grep-other-window-action) - (setq ivy-exit 'done) - (exit-minibuffer)) diff --git a/.config/emacs/modules/completion/ivy/autoload/posframe.el b/.config/emacs/modules/completion/ivy/autoload/posframe.el @@ -1,16 +0,0 @@ -;;; completion/ivy/autoload/posframe.el -*- lexical-binding: t; -*- -;;;###if (modulep! +childframe) - -;;;###autoload -(defun +ivy-display-at-frame-center-near-bottom-fn (str) - "TODO" - (ivy-posframe--display str #'+ivy-poshandler-frame-center-near-bottom-fn)) - -;;;###autoload -(defun +ivy-poshandler-frame-center-near-bottom-fn (info) - "TODO" - (let ((parent-frame (plist-get info :parent-frame)) - (pos (posframe-poshandler-frame-center info))) - (cons (car pos) - (truncate (/ (frame-pixel-height parent-frame) 2))))) - diff --git a/.config/emacs/modules/completion/ivy/config.el b/.config/emacs/modules/completion/ivy/config.el @@ -1,416 +0,0 @@ -;;; completion/ivy/config.el -*- lexical-binding: t; -*- - -(defvar +ivy-buffer-preview nil - "If non-nil, preview buffers while switching, à la `counsel-switch-buffer'. - -When nil, don't preview anything. -When non-nil, preview non-virtual buffers. -When 'everything, also preview virtual buffers") - -(defvar +ivy-buffer-unreal-face 'font-lock-comment-face - "The face for unreal buffers in `ivy-switch-to-buffer'.") - -(defvar +ivy-edit-functions nil - "A plist mapping ivy/counsel commands to commands that generate an editable -results buffer.") - - -;; -;;; Packages - -(use-package! ivy - :hook (doom-first-input . ivy-mode) - :init - (let ((standard-search-fn - (if (modulep! +prescient) - #'+ivy-prescient-non-fuzzy - #'ivy--regex-plus)) - (alt-search-fn - (if (modulep! +fuzzy) - #'ivy--regex-fuzzy - ;; Ignore order for non-fuzzy searches by default - #'ivy--regex-ignore-order))) - (setq ivy-re-builders-alist - `((counsel-rg . ,standard-search-fn) - (swiper . ,standard-search-fn) - (swiper-isearch . ,standard-search-fn) - (t . ,alt-search-fn)) - ivy-more-chars-alist - '((counsel-rg . 1) - (counsel-search . 2) - (t . 3)))) - - (define-key! - [remap switch-to-buffer] #'+ivy/switch-buffer - [remap switch-to-buffer-other-window] #'+ivy/switch-buffer-other-window - [remap persp-switch-to-buffer] #'+ivy/switch-workspace-buffer - [remap evil-show-jumps] #'+ivy/jump-list) - - ;; Fix #4886: otherwise our remaps are overwritten - (setq ivy-mode-map (make-sparse-keymap)) - :config - ;; The default sorter is much to slow and the default for `ivy-sort-max-size' - ;; is way too big (30,000). Turn it down so big repos affect project - ;; navigation less. - (setq ivy-sort-max-size 7500) - - ;; Counsel changes a lot of ivy's state at startup; to control for that, we - ;; need to load it as early as possible. Some packages (like `ivy-prescient') - ;; require this. - (require 'counsel nil t) - - (setq ivy-height 17 - ivy-wrap t - ivy-fixed-height-minibuffer t - ivy-read-action-function #'ivy-hydra-read-action - ivy-read-action-format-function #'ivy-read-action-format-columns - ;; don't show recent files in switch-buffer - ivy-use-virtual-buffers nil - ;; ...but if that ever changes, show their full path - ivy-virtual-abbreviate 'full - ;; don't quit minibuffer on delete-error - ivy-on-del-error-function #'ignore - ;; enable ability to select prompt (alternative to `ivy-immediate-done') - ivy-use-selectable-prompt t) - - ;; Highlight each ivy candidate including the following newline, so that it - ;; extends to the right edge of the window - (setf (alist-get 't ivy-format-functions-alist) - #'+ivy-format-function-line-or-arrow) - - ;; Integrate `ivy' with `better-jumper'; ensure a jump point is registered - ;; before jumping to new locations with ivy - (setf (alist-get 't ivy-hooks-alist) - (lambda () - (with-ivy-window - (setq +ivy--origin (point-marker))))) - - (add-hook! 'minibuffer-exit-hook - (defun +ivy--set-jump-point-maybe-h () - (when (markerp (bound-and-true-p +ivy--origin)) - (unless (equal (ignore-errors (with-ivy-window (point-marker))) - +ivy--origin) - (with-current-buffer (marker-buffer +ivy--origin) - (better-jumper-set-jump +ivy--origin))) - (set-marker +ivy--origin nil)) - (setq +ivy--origin nil))) - - (after! yasnippet - (add-hook 'yas-prompt-functions #'+ivy-yas-prompt-fn)) - - (after! ivy-hydra - ;; Ensure `ivy-dispatching-done' and `hydra-ivy/body' hydras can be - ;; exited / toggled by the same key binding they were opened - (add-to-list 'ivy-dispatching-done-hydra-exit-keys '("C-o" nil)) - (defhydra+ hydra-ivy () ("M-o" nil))) - - (define-key! ivy-minibuffer-map - [remap doom/delete-backward-word] #'ivy-backward-kill-word - "C-c C-e" #'+ivy/woccur - "C-o" #'ivy-dispatching-done - "M-o" #'hydra-ivy/body)) - - -(use-package! ivy-rich - :after ivy - :config - (setq ivy-rich-parse-remote-buffer nil) - - (when (modulep! +icons) - (cl-pushnew '(+ivy-rich-buffer-icon) - (cadr (plist-get ivy-rich-display-transformers-list - 'ivy-switch-buffer)) - :test #'equal)) - - (defun ivy-rich-bookmark-filename-or-empty (candidate) - (let ((filename (ivy-rich-bookmark-filename candidate))) - (if (not filename) "" filename))) - - ;; 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)) ; display variable value - (ivy-rich-counsel-variable-docstring (:face font-lock-doc-face)))) - 'counsel-M-x - '(:columns - ((counsel-M-x-transformer (:width 60)) - (ivy-rich-counsel-function-docstring (:face font-lock-doc-face)))) - ;; Apply switch buffer transformers to `counsel-projectile-switch-to-buffer' as well - 'counsel-projectile-switch-to-buffer - (plist-get ivy-rich-display-transformers-list 'ivy-switch-buffer) - 'counsel-bookmark - '(:columns - ((ivy-rich-candidate (:width 0.5)) - (ivy-rich-bookmark-filename-or-empty (:width 60))))) - - ;; Remove built-in coloring of buffer list; we do our own - (setq ivy-switch-buffer-faces-alist nil) - (ivy-set-display-transformer 'internal-complete-buffer nil) - - ;; Highlight buffers differently based on whether they're in the same project - ;; as the current project or not. - (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) - (ivy-rich-project-root-cache-mode +1)) - - -(use-package! all-the-icons-ivy - :when (modulep! +icons) - :after ivy - :config - ;; `all-the-icons-ivy' is incompatible with ivy-rich's switch-buffer - ;; modifications, so we disable them and merge them ourselves - (setq all-the-icons-ivy-buffer-commands nil) - - (all-the-icons-ivy-setup) - (after! counsel-projectile - (let ((all-the-icons-ivy-file-commands - '(counsel-projectile - counsel-projectile-find-file - counsel-projectile-find-dir))) - (all-the-icons-ivy-setup)))) - - -(use-package! counsel - :defer t - :init - (define-key! - [remap apropos] #'counsel-apropos - [remap bookmark-jump] #'counsel-bookmark - [remap compile] #'+ivy/compile - [remap describe-bindings] #'counsel-descbinds - [remap describe-face] #'counsel-faces - [remap describe-function] #'counsel-describe-function - [remap describe-variable] #'counsel-describe-variable - [remap describe-symbol] #'counsel-describe-symbol - [remap evil-show-registers] #'counsel-evil-registers - [remap evil-show-marks] #'counsel-mark-ring - [remap execute-extended-command] #'counsel-M-x - [remap find-file] #'counsel-find-file - [remap find-library] #'counsel-find-library - [remap imenu] #'counsel-imenu - [remap info-lookup-symbol] #'counsel-info-lookup-symbol - [remap load-theme] #'counsel-load-theme - [remap locate] #'counsel-locate - [remap org-goto] #'counsel-org-goto - [remap org-set-tags-command] #'counsel-org-tag - [remap projectile-compile-project] #'+ivy/project-compile - [remap recentf-open-files] #'counsel-recentf - [remap set-variable] #'counsel-set-variable - [remap swiper] #'counsel-grep-or-swiper - [remap insert-char] #'counsel-unicode-char - [remap yank-pop] #'counsel-yank-pop) - :config - (set-popup-rule! "^\\*ivy-occur" :size 0.35 :ttl 0 :quit nil) - - ;; HACK Fix an issue where `counsel-projectile-find-file-action' would try to - ;; open a candidate in an occur buffer relative to the wrong buffer, - ;; causing it to fail to find the file we want. - (defadvice! +ivy--run-from-ivy-directory-a (fn &rest args) - :around #'counsel-projectile-find-file-action - (let ((default-directory (ivy-state-directory ivy-last))) - (apply fn args))) - - ;; Don't use ^ as initial input. Set this here because `counsel' defines more - ;; of its own, on top of the defaults. - (setq ivy-initial-inputs-alist nil) - - ;; REVIEW Counsel allows `counsel-rg-base-command' to be a string or list. - ;; This backwards compatibility complicates things for Doom. Simpler to - ;; just force it to always be a list. - (when (stringp counsel-rg-base-command) - (setq counsel-rg-base-command (split-string counsel-rg-base-command))) - - ;; Integrate with `helpful' - (setq counsel-describe-function-function #'helpful-callable - counsel-describe-variable-function #'helpful-variable - counsel-descbinds-function #'helpful-callable) - - ;; Decorate `doom/help-custom-variable' results the same way as - ;; `counsel-describe-variable' (adds value and docstring columns). - (ivy-configure 'doom/help-custom-variable :parent 'counsel-describe-variable) - - ;; Record in jumplist when opening files via counsel-{ag,rg,pt,git-grep} - (add-hook 'counsel-grep-post-action-hook #'better-jumper-set-jump) - (add-hook 'counsel-grep-post-action-hook #'recenter) - (ivy-add-actions - 'counsel-rg ; also applies to `counsel-rg' - '(("O" +ivy-git-grep-other-window-action "open in other window"))) - - ;; Make `counsel-compile' projectile-aware (if you prefer it over - ;; `+ivy/compile' and `+ivy/project-compile') - (add-to-list 'counsel-compile-root-functions #'projectile-project-root) - (after! savehist - ;; Persist `counsel-compile' history - (add-to-list 'savehist-additional-variables 'counsel-compile-history)) - - ;; `counsel-imenu' -- no sorting for imenu. Sort it by appearance in page. - (add-to-list 'ivy-sort-functions-alist '(counsel-imenu)) - - ;; `counsel-locate' - (when IS-MAC - ;; Use spotlight on mac by default since it doesn't need any additional setup - (setq counsel-locate-cmd #'counsel-locate-cmd-mdfind)) - - ;; `swiper' - ;; Don't mess with font-locking on the dashboard; it causes breakages - (add-to-list 'swiper-font-lock-exclude #'+doom-dashboard-mode) - - ;; `counsel-find-file' - (setq counsel-find-file-ignore-regexp "\\(?:^[#.]\\)\\|\\(?:[#~]$\\)\\|\\(?:^Icon?\\)") - (dolist (fn '(counsel-rg counsel-find-file)) - (ivy-add-actions - fn '(("p" (lambda (path) (with-ivy-window (insert (file-relative-name path default-directory)))) - "insert relative path") - ("P" (lambda (path) (with-ivy-window (insert path))) - "insert absolute path") - ("l" (lambda (path) (with-ivy-window (insert (format "[[./%s]]" (file-relative-name path default-directory))))) - "insert relative org-link") - ("L" (lambda (path) (with-ivy-window (insert (format "[[%s]]" path)))) - "Insert absolute org-link")))) - - (ivy-add-actions 'counsel-file-jump (plist-get ivy--actions-list 'counsel-find-file)) - - ;; `counsel-search': use normal page for displaying results, so that we see - ;; custom ddg themes (if one is set). - (setf (nth 1 (alist-get 'ddg counsel-search-engines-alist)) - "https://duckduckgo.com/?q=") - - ;; REVIEW Move this somewhere else and perhaps generalize this so both - ;; ivy/helm users can enjoy it. - (defadvice! +ivy--counsel-file-jump-use-fd-rg-a (args) - "Change `counsel-file-jump' to use fd or ripgrep, if they are available." - :override #'counsel--find-return-list - (cl-destructuring-bind (find-program . args) - (cond ((when-let (fd (executable-find (or doom-projectile-fd-binary "fd") t)) - (append (list fd "--hidden" "--type" "file" "--type" "symlink" "--follow" "--color=never") - (cl-loop for dir in projectile-globally-ignored-directories - collect "--exclude" - collect dir) - (if IS-WINDOWS '("--path-separator=/"))))) - ((executable-find "rg" t) - (append (list "rg" "--hidden" "--files" "--follow" "--color=never" "--no-messages") - (cl-loop for dir in projectile-globally-ignored-directories - collect "--glob" - collect (concat "!" dir)) - (if IS-WINDOWS '("--path-separator=/")))) - ((cons find-program args))) - (unless (listp args) - (user-error "`counsel-file-jump-args' is a list now, please customize accordingly.")) - (counsel--call - (cons find-program args) - (lambda () - (goto-char (point-min)) - (let (files) - (while (< (point) (point-max)) - (push (buffer-substring (line-beginning-position) (line-end-position)) - files) - (forward-line 1)) - (nreverse files))))))) - - -(use-package! counsel-projectile - :defer t - :init - (define-key! - [remap projectile-find-file] #'+ivy/projectile-find-file - [remap projectile-find-dir] #'counsel-projectile-find-dir - [remap projectile-switch-to-buffer] #'counsel-projectile-switch-to-buffer - [remap projectile-grep] #'counsel-projectile-grep - [remap projectile-ag] #'counsel-projectile-ag - [remap projectile-switch-project] #'counsel-projectile-switch-project) - :config - ;; A more sensible `counsel-projectile-find-file' that reverts to - ;; `counsel-find-file' if invoked from $HOME, `counsel-file-jump' if invoked - ;; from a non-project, `projectile-find-file' if in a big project (more than - ;; `ivy-sort-max-size' files), or `counsel-projectile-find-file' otherwise. - (setf (alist-get 'projectile-find-file counsel-projectile-key-bindings) - #'+ivy/projectile-find-file) - - ;; no highlighting visited files; slows down the filtering - (ivy-set-display-transformer #'counsel-projectile-find-file nil) - - (when (modulep! +prescient) - (setq counsel-projectile-sort-files t))) - - -(use-package! wgrep - :commands wgrep-change-to-wgrep-mode - :config (setq wgrep-auto-save-buffer t)) - - -(use-package! ivy-posframe - :when (modulep! +childframe) - :hook (ivy-mode . ivy-posframe-mode) - :config - (setq ivy-fixed-height-minibuffer nil - ivy-posframe-border-width 10 - ivy-posframe-parameters - `((min-width . 90) - (min-height . ,ivy-height))) - - ;; default to posframe display function - (setf (alist-get t ivy-posframe-display-functions-alist) - #'+ivy-display-at-frame-center-near-bottom-fn) - - ;; posframe doesn't work well with async sources (the posframe will - ;; occasionally stop responding/redrawing), and causes violent resizing of the - ;; posframe. - (dolist (fn '(swiper counsel-rg counsel-grep counsel-git-grep)) - (setf (alist-get fn ivy-posframe-display-functions-alist) - #'ivy-display-function-fallback)) - - (add-hook 'doom-after-reload-hook #'posframe-delete-all)) - - -(use-package! flx - :when (modulep! +fuzzy) - :unless (modulep! +prescient) - :defer t ; is loaded by ivy - :preface (when (or (not (modulep! +fuzzy)) - (modulep! +prescient)) - (setq ivy--flx-featurep nil)) - :init (setq ivy-flx-limit 10000)) - -(use-package! ivy-avy - :after ivy) - -(use-package! ivy-prescient - :when (modulep! +prescient) - :hook (ivy-mode . ivy-prescient-mode) - :hook (ivy-prescient-mode . prescient-persist-mode) - :commands +ivy-prescient-non-fuzzy - :init - (setq prescient-filter-method - (if (modulep! +fuzzy) - '(literal regexp initialism fuzzy) - '(literal regexp initialism))) - :config - ;; REVIEW Remove when radian-software/prescient.el#102 is resolved - (add-to-list 'ivy-sort-functions-alist '(ivy-resume)) - (setq ivy-prescient-sort-commands - '(:not swiper swiper-isearch ivy-switch-buffer lsp-ivy-workspace-symbol - ivy-resume ivy--restore-session counsel-grep counsel-git-grep - counsel-rg counsel-ag counsel-ack counsel-fzf counsel-pt counsel-imenu - counsel-yank-pop counsel-recentf counsel-buffer-or-recentf - counsel-outline counsel-org-goto counsel-jq) - ivy-prescient-retain-classic-highlighting t) - (defun +ivy-prescient-non-fuzzy (str) - (let ((prescient-filter-method '(literal regexp))) - (ivy-prescient-re-builder str))) - - ;; NOTE prescient config duplicated with `company' - (setq prescient-save-file (concat doom-cache-dir "prescient-save.el"))) - - -;;;###package swiper -(setq swiper-action-recenter t) - - -;;;###package amx -(setq amx-save-file (concat doom-cache-dir "amx-items")) ; used by `counsel-M-x' diff --git a/.config/emacs/modules/completion/ivy/doctor.el b/.config/emacs/modules/completion/ivy/doctor.el @@ -1,3 +0,0 @@ -;; -*- lexical-binding: t; no-byte-compile: t; -*- -;;; completion/ivy/doctor.el - diff --git a/.config/emacs/modules/completion/ivy/packages.el b/.config/emacs/modules/completion/ivy/packages.el @@ -1,24 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; completion/ivy/packages.el - -(package! swiper :pin "b8be4913a661b557e0d3275726e36871556569d3") -(package! ivy) -(package! ivy-hydra) -(package! ivy-avy) -(package! counsel) - -(package! amx :pin "37f9c7ae55eb0331b27200fb745206fc58ceffc0") -(package! counsel-projectile :pin "40d1e1d4bb70acb00fddd6f4df9778bf2c52734b") -(package! ivy-rich :pin "600b8183ed0be8668dcc548cc2c8cb94b001363b") -(package! wgrep :pin "edf768732a56840db6879706b64c5773c316d619") - -(if (modulep! +prescient) - (package! ivy-prescient :pin "35cf5d36132c3e96db9a9e4d1902dcfa207e7baa") - (when (modulep! +fuzzy) - (package! flx :pin "7b44a5abb254bbfbeca7a29336f7f4ebd8aabbf2"))) - -(when (modulep! +childframe) - (package! ivy-posframe :pin "533a8e368fcabfd534761a5c685ce713376fa594")) - -(when (modulep! +icons) - (package! all-the-icons-ivy :pin "a70cbfa1effe36efc946a823a580cec686d5e88d")) diff --git a/.config/emacs/modules/completion/vertico/README.org b/.config/emacs/modules/completion/vertico/README.org @@ -1,306 +0,0 @@ -#+title: :completion vertico -#+subtitle: Tomorrow's search engine -#+created: July 25, 2021 -#+since: 21.12.0 (#4664) - -* Description :unfold: -This module enhances the Emacs search and completion experience, and also -provides a united interface for project search and replace, powered by [[https://github.com/BurntSushi/ripgrep/][ripgrep]]. - -It does this with several modular packages focused on enhancing the built-in -~completing-read~ interface, rather than replacing it with a parallel ecosystem -like [[doom-package:ivy]] and [[doom-package:helm]] do. The primary packages are: - -- Vertico, which provides the vertical completion user interface -- Consult, which provides a suite of useful commands using ~completing-read~ -- Embark, which provides a set of minibuffer actions -- Marginalia, which provides annotations to completion candidates -- Orderless, which provides better filtering methods - -** Maintainers -- [[doom-user:][@iyefrat]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +childframe :: - Display completion candidates in a [[https://www.gnu.org/software/emacs/manual/html_node/elisp/Child-Frames.html][child frame]] rather than an overlay or - tooltip. *Requires GUI Emacs.* - -- +icons :: - Add icons to =file= and =buffer= category completion selections. - -** Packages -- [[doom-package:all-the-icons-completion]] if [[doom-module:+icons]] -- [[doom-package:consult]] -- [[doom-package:consult-flycheck]] if [[doom-module::checkers syntax]] -- [[doom-package:embark]] -- [[doom-package:embark-consult]] -- [[doom-package:marginalia]] -- [[doom-package:orderless]] -- [[doom-package:vertico]] -- [[doom-package:vertico-posframe]] if [[doom-module:+childframe]] -- [[doom-package:wgrep]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module has only one requirement: [[https://github.com/BurntSushi/ripgrep][Ripgrep]] (built with [[https://www.pcre.org/][PCRE]] support; run ~$ -doom doctor~ to determine if your build meets this requirement), which is a hard -dependency of Doom itself, so you should already have it installed. - -Otherwise, Consult (a plugin this module installs) provides many commands to -interface with a variety of programs from [[https://github.com/junegunn/fzf][fzf]] to [[https://kapeli.com/dash][Dash docsets]] to [[https://www.passwordstore.org/][pass]] and /much/ -more. These programs are optional for this module, but must be installed if you -intend to use their associated Helm command or plugin. - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -The packages in this module modify and use the built-in ~completing-read~ -function, which is used by any function that requires completion. Due to this -the full scope of these packages is too large to cover here and you are -encouraged to go and read their excellent documentation. We will detail -Doom-specific additions: - -** Vertico keybindings -When in an active Vertico completion session, the following doom added -keybindings are available: - -| Keybind | Description | -|-------------------+----------------------------------------------------------------| -| [[kbd:][C-k]] | (evil) Go to previous candidate | -| [[kbd:][C-j]] | (evil) Go to next candidate | -| [[kbd:][C-M-k]] | (evil) Go to previous group | -| [[kbd:][C-M-j]] | (evil) Go to next group | -| [[kbd:][C-;]] or [[kbd:][<leader> a]] | Open an ~embark-act~ menu to chose a useful action | -| [[kbd:][C-c C-;]] | export the current candidate list to a buffer | -| [[kbd:][C-c C-l]] | ~embark-collect~ the current candidate list (collect verbatim) | -| [[kbd:][C-SPC]] | Preview the current candidate | - -~embark-act~ will prompt you with a =which-key= menu with useful commands on the -selected candidate or candidate list, depending on the completion category. Note -that you can press [[kbd:][C-h]] instead of choosing a command to filter through the -options with a Vertico buffer, that also has slightly more detailed descriptions -due to Marginalia annotations. - -** Jump-to navigation -This module provides an interface to navigate within a project using -[[doom-package:projectile]]: - -https://assets.doomemacs.org/completion/vertico/projectile.png - -| Keybind | Description | -|------------------+-------------------------------------| -| [[kbd:][SPC p f]], [[kbd:][SPC SPC]] | Jump to file in project | -| [[kbd:][SPC f f]], [[kbd:][SPC .]] | Jump to file from current directory | -| [[kbd:][SPC s i]] | Jump to symbol in file | - -** Project search & replace -This module provides interactive text search and replace using ripgrep. - -| Keybind | Description | -|---------+--------------------------| -| [[kbd:][<leader> s p]] | Search project | -| [[kbd:][<leader> s P]] | Search another project | -| [[kbd:][<leader> s d]] | Search this directory | -| [[kbd:][<leader> s D]] | Search another directory | - -https://assets.doomemacs.org/completion/vertico/search.png - -Prefixing these keys with the universal argument ([[kbd:][SPC u]] for evil users; [[kbd:][C-u]] -otherwise) changes the behavior of these commands, instructing the underlying -search engine to include ignored files. - -This module also provides Ex Commands for evil users: -| Ex command | Description | -|----------------------+----------------------------------------------------------------| -| ~:pg[rep][!] [QUERY]~ | Search project (if ~!~, include hidden files) | -| ~:pg[rep]d[!] [QUERY]~ | Search from current directory (if ~!~, don't search recursively) | - -The optional ~!~ is equivalent to the universal argument for the previous -commands. - ------ - -On top of the usual Vertico keybindings, search commands also offer support for -exporting the current candidate list to an editable buffer [[kbd:][C-c C-e]]. After -editing the changes can be committed with [[kbd:][C-c C-c]] and aborted with [[kbd:][C-c C-k]] -(alternatively [[kbd:][ZZ]] and [[kbd:][ZQ]], for evil users). It uses [[doom-package:wgrep]] for grep searches, -[[doom-package:wdired]] for file searches, and =occur= for buffer searches. - -https://assets.doomemacs.org/completion/vertico/search-replace.png - -** In-buffer searching -This module provides some in buffer searching bindings: - -- [[kbd:][SPC s s]] (~isearch~) -- [[kbd:][SPC s S]] (~+vertico/search-symbol-at-point~ via ~consult-line~) -- [[kbd:][SPC s b]] (~consult-line~) - -https://assets.doomemacs.org/completion/vertico/buffer-search.png - -An ~occur-edit~ buffer can be opened from ~consult-line~ with [[kbd:][C-c C-e]]. - -** Vertico integration for various completing commands -*** General -| Keybind | Description | -|------------+-----------------------------| -| [[kbd:][M-x]], [[kbd:][SPC :]] | Enhanced M-x | -| [[kbd:][SPC ']] | Resume last Vertico session | - -*** Jump to files, buffers or projects -| Keybind | Description | -|------------------+---------------------------------------| -| [[kbd:][SPC RET]] | Find bookmark | -| [[kbd:][SPC f f]], [[kbd:][SPC .]] | Browse from current directory | -| [[kbd:][SPC p f]], [[kbd:][SPC SPC]] | Find file in project | -| [[kbd:][SPC f r]] | Find recently opened file | -| [[kbd:][SPC p p]] | Open another project | -| [[kbd:][SPC b b]], [[kbd:][SPC ,]] | Switch to buffer in current workspace | -| [[kbd:][SPC b B]], [[kbd:][SPC <]] | Switch to buffer | - -[[kbd:][SPC b b]] and [[kbd:][SPC ,]] support changing the workspace you're selecting a buffer from -via [[https://github.com/minad/consult#narrowing-and-grouping][Consult narrowing]], e.g. if you're on the first workspace, you can switch to -selecting a buffer from the third workspace by typing [[kbd:][3 SPC]] into the prompt, or -the last workspace by typing [[kbd:][0 SPC]]. - -[[kbd:][SPC f f]] and [[kbd:][SPC .]] support exporting to a [[kbd:][wdired]] buffer using [[kbd:][C-c C-e]]. - -*** Search -| Keybind | Description | -|---------+-------------------------------------------| -| [[kbd:][SPC p t]] | List all TODO/FIXMEs in project | -| [[kbd:][SPC s b]] | Search the current buffer | -| [[kbd:][SPC s d]] | Search this directory | -| [[kbd:][SPC s D]] | Search another directory | -| [[kbd:][SPC s i]] | Search for symbol in current buffer | -| [[kbd:][SPC s p]] | Search project | -| [[kbd:][SPC s P]] | Search another project | -| [[kbd:][SPC s s]] | Search the current buffer (incrementally) | - -*** File Path Completion -Note that Emacs allows you to switch directories with shadow paths, for example -starting at =/foo/bar/baz=, typing =/foo/bar/baz/~/= will switch the searched -path to the home directory. For more information see ~substitute-in-file-name~ -and ~file-name-shadow-mode~. This module will erase the "shadowed" portion of -the path from the minibuffer, so in the previous example the path will be reset -to =~/=. - -** Consult -*** Multiple candidate search -This module modifies the default keybindings used in -~consult-completing-read-multiple~: -| Keybind | Description | -|---------+-------------------------------------------------------------| -| [[kbd:][TAB]] | Select or deselect current candidate | -| [[kbd:][RET]] | Enters selected candidates (also toggles current candidate) | - -*** Async search commands -:PROPERTIES: -:ID: 4ab16bf0-f9e8-4798-8632-ee7b13d2291e -:END: -Consult async commands (e.g. ~consult-ripgrep~) will have a preceding separator -character (usually ~#~) before the search input. This is known as the =perl= -splitting style. Input typed after the separator will be fed to the async -command until you type a second seperator, afterwhich the candidate list will be -filtered with Emacs instead (and can be filtered using [[doom-package:orderless]], for example). -The specific seperator character can be changed by editing it, and might be -different if the initial input already contains =#=. - -Note that grep-like async commands translate the input (between the first and -second =#=) to an Orderless-light expression: space separated inputs are all -matched in any order. If the grep backend does not support PCRE lookahead, it'll -only accept 3 space separated inputs to prevent long lookup times, and further -filtering should be done after a second =#=. - -For more information [[https://github.com/minad/consult#asynchronous-search][see here]]. - -** Marginalia -| Keybind | Description | -|---------+---------------------------------| -| [[kbd:][M-A]] | Cycle between annotation levels | - -Marginalia annotations for symbols (e.g. [[kbd:][SPC h f]] and [[kbd:][SPC h v]]) come with extra -information the nature of the symbol. For the meaning of the annotations see -~marginalia--symbol-class~. - -** Orderless filtering -When using orderless to filter through candidates, the default behaviour is for -each space separated input to match the candidate as a regular expression or -literally. - -Note that due to this style of matching, pressing tab does not expand the input -to the longest matching prefix (like shell completion), but rather uses the -first matched candidate as input. Filtering further is instead achieved by -pressing space and entering another input. In essence, when trying to match -=foobar.org=, instead of option 1., use option 2.: - -1. (BAD) Enter ~foo TAB~, completes to =foobar.=, enter ~org RET~ -2. (GOOD) Enter ~foo SPC org RET~ - -Doom has some builtin [[https://github.com/oantolin/orderless#style-dispatchers][style dispatchers]] for more fine-grained filtering, which -you can use to further specify each space separated input in the following ways: -| Input | Description | -|--------------+------------------------------------------| -| ~!foo~ | match without literal input =foo= | -| ~%foo~ or ~foo%~ | perform ~char-fold-to-regexp~ on input =foo= | -| ~`foo~ or ~foo`~ | match input =foo= as an initialism | -| ~=foo~ or ~foo=~ | match only with literal input =foo= | -| ~~foo~ or ~foo~~ | match input =foo= with fuzzy/flex matching | - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -If you want to further configure this module, here are some good places to -start: - -** Vertico - Vertico provides several [[https://github.com/minad/vertico#extensions][extentions]] that can be used to extend it's interface - -** Consult -Much of the behaviour of Consult commands can be changed with -~consult-customize~. The =vertico= module already does this, if you want to -override the module's modifications, do: -#+begin_src emacs-lisp -(setq consult--customize-alist nil) -(consult-customize ...) -#+end_src - -If you are changing the preview key (set to [[kbd:][C-SPC]]), remember to change the -binding on ~vertico-map~ as well, as the binding there gets previews to work to -an extent on non-consult commands as well. - -** Marginalia -You can add more Marginalia annotation levels and change the existing ones by -editing ~marginalia-annotator-registry~ - -** Embark -You can change the available commands in Embark for category ~$cat~ by editing -~embark-$cat-map~, and even add new categories. Note that you add categories by -defining them [[https://github.com/minad/marginalia/#adding-custom-annotators-or-classifiers][through marginalia]], and embark picks up on them. - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -[[doom-suggest-faq:][Ask a question?]] - -** Helm vs Ivy vs Ido vs Vertico -See [[id:4f36ae11-1da8-4624-9c30-46b764e849fc][this answer]]. - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/completion/vertico/autoload/evil.el b/.config/emacs/modules/completion/vertico/autoload/evil.el @@ -1,14 +0,0 @@ -;; completion/vertico/autoload/evil.el -*- lexical-binding: t; -*- -;;;###if (modulep! :editor evil) - -;;;###autoload (autoload '+vertico:project-search "completion/vertico/autoload/evil" nil t) -(evil-define-command +vertico:project-search (query &optional all-files-p) - "Ex interface for `+vertico/project-search'." - (interactive "<a><!>") - (+vertico/project-search all-files-p query)) - -;;;###autoload (autoload '+vertico:project-search-from-cwd "completion/vertico/autoload/evil" nil t) -(evil-define-command +vertico:project-search-from-cwd (query &optional recurse-p) - "Ex interface for `+vertico/project-search-from-cwd'." - (interactive "<a><!>") - (+vertico/project-search-from-cwd (not recurse-p) query)) diff --git a/.config/emacs/modules/completion/vertico/autoload/magit.el b/.config/emacs/modules/completion/vertico/autoload/magit.el @@ -1,8 +0,0 @@ -;;; completion/vertico/autoload/magit.el -*- lexical-binding: t; -*- -;;;###if (modulep! :tools magit) - -;;;###autoload -(defun +vertico/embark-magit-status (file) - "Run `magit-status` on repo containing the embark target." - (interactive "GFile: ") - (magit-status (locate-dominating-file file ".git"))) diff --git a/.config/emacs/modules/completion/vertico/autoload/vertico.el b/.config/emacs/modules/completion/vertico/autoload/vertico.el @@ -1,261 +0,0 @@ -;;; completion/vertico/autoload/vertico.el -*- lexical-binding: t; -*- - -;; To prevent "Defining as dynamic an already lexical var" from +vertico/embark-preview -;;;###autoload -(defvar embark-quit-after-action) - -;;;###autoload -(cl-defun +vertico-file-search (&key query in all-files (recursive t) prompt args) - "Conduct a file search using ripgrep. - -:query STRING - Determines the initial input to search for. -:in PATH - Sets what directory to base the search out of. Defaults to the current project's root. -:recursive BOOL - Whether or not to search files recursively from the base directory." - (declare (indent defun)) - (unless (executable-find "rg") - (user-error "Couldn't find ripgrep in your PATH")) - (require 'consult) - (setq deactivate-mark t) - (let* ((project-root (or (doom-project-root) default-directory)) - (directory (or in project-root)) - (consult-ripgrep-args - (concat "rg " - (if all-files "-uu ") - (unless recursive "--maxdepth 1 ") - "--null --line-buffered --color=never --max-columns=1000 " - "--path-separator / --smart-case --no-heading " - "--with-filename --line-number --search-zip " - "--hidden -g !.git -g !.svn -g !.hg " - (mapconcat #'shell-quote-argument args " "))) - (prompt (if (stringp prompt) (string-trim prompt) "Search")) - (query (or query - (when (doom-region-active-p) - (regexp-quote (doom-thing-at-point-or-region))))) - (consult-async-split-style consult-async-split-style) - (consult-async-split-styles-alist consult-async-split-styles-alist)) - ;; Change the split style if the initial query contains the separator. - (when query - (cl-destructuring-bind (&key type separator initial _function) - (consult--async-split-style) - (pcase type - (`separator - (replace-regexp-in-string (regexp-quote (char-to-string separator)) - (concat "\\" (char-to-string separator)) - query t t)) - (`perl - (when (string-match-p initial query) - (setf (alist-get 'perlalt consult-async-split-styles-alist) - `(:initial ,(or (cl-loop for char in (list "%" "@" "!" "&" "/" ";") - unless (string-match-p char query) - return char) - "%") - :type perl) - consult-async-split-style 'perlalt)))))) - (consult--grep prompt #'consult--ripgrep-make-builder directory query))) - -;;;###autoload -(defun +vertico/project-search (&optional arg initial-query directory) - "Performs a live project search from the project root using ripgrep. -If ARG (universal argument), include all files, even hidden or compressed ones, -in the search." - (interactive "P") - (+vertico-file-search :query initial-query :in directory :all-files arg)) - -;;;###autoload -(defun +vertico/project-search-from-cwd (&optional arg initial-query) - "Performs a live project search from the current directory. -If ARG (universal argument), include all files, even hidden or compressed ones." - (interactive "P") - (+vertico/project-search arg initial-query default-directory)) - -;;;###autoload -(defun +vertico/search-symbol-at-point () - "Performs a search in the current buffer for thing at point." - (interactive) - (consult-line (thing-at-point 'symbol))) - -;;;###autoload -(defun +vertico-embark-target-package-fn () - "Targets Doom's package! statements and returns the package name" - (when (or (derived-mode-p 'emacs-lisp-mode) (derived-mode-p 'org-mode)) - (save-excursion - (when (and (search-backward "(" nil t) - (looking-at "(\\s-*package!\\s-*\\(\\(\\sw\\|\\s_\\)+\\)\\s-*")) - (let ((pkg (match-string 1))) - (set-text-properties 0 (length pkg) nil pkg) - `(package . ,pkg)))))) - -;;;###autoload -(defun +vertico/embark-export-write () - "Export the current vertico results to a writable buffer if possible. - -Supports exporting consult-grep to wgrep, file to wdeired, and consult-location to occur-edit" - (interactive) - (require 'embark) - (require 'wgrep) - (let* ((edit-command - (pcase-let ((`(,type . ,candidates) - (run-hook-with-args-until-success 'embark-candidate-collectors))) - (pcase type - ('consult-grep #'wgrep-change-to-wgrep-mode) - ('file #'wdired-change-to-wdired-mode) - ('consult-location #'occur-edit-mode) - (x (user-error "embark category %S doesn't support writable export" x))))) - (embark-after-export-hook `(,@embark-after-export-hook ,edit-command))) - (embark-export))) - -;;;###autoload -(defun +vertico/embark-preview () - "Previews candidate in vertico buffer, unless it's a consult command" - (interactive) - (unless (bound-and-true-p consult--preview-function) - (if (fboundp 'embark-dwim) - (save-selected-window - (let (embark-quit-after-action) - (embark-dwim))) - (user-error "Embark not installed, aborting...")))) - -;;;###autoload -(defun +vertico/enter-or-preview () - "Enter directory or embark preview on current candidate." - (interactive) - (when (> 0 vertico--index) - (user-error "No vertico session is currently active")) - (if (and (let ((cand (vertico--candidate))) - (or (string-suffix-p "/" cand) - (and (vertico--remote-p cand) - (string-suffix-p ":" cand)))) - (not (equal vertico--base "")) - (eq 'file (vertico--metadata-get 'category))) - (vertico-insert) - (condition-case _ - (+vertico/embark-preview) - (user-error (vertico-directory-enter))))) - -(defvar +vertico/find-file-in--history nil) -;;;###autoload -(defun +vertico/find-file-in (&optional dir initial) - "Jump to file under DIR (recursive). -If INITIAL is non-nil, use as initial input." - (interactive) - (require 'consult) - (let* ((default-directory (or dir default-directory)) - (prompt-dir (consult--directory-prompt "Find" default-directory)) - (cmd (split-string-and-unquote +vertico-consult-fd-args " "))) - (find-file - (consult--read - (split-string (cdr (apply #'doom-call-process cmd)) "\n" t) - :prompt default-directory - :sort nil - :initial (if initial (shell-quote-argument initial)) - :add-history (thing-at-point 'filename) - :category 'file - :history '(:input +vertico/find-file-in--history))))) - -;;;###autoload -(defun +vertico/jump-list (jump) - "Go to an entry in evil's (or better-jumper's) jumplist." - (interactive - (let (buffers) - (require 'consult) - (unwind-protect - (list - (consult--read - ;; REVIEW Refactor me - (nreverse - (delete-dups - (delq - nil (mapcar - (lambda (mark) - (when mark - (cl-destructuring-bind (path pt _id) mark - (let* ((visiting (find-buffer-visiting path)) - (buf (or visiting (find-file-noselect path t))) - (dir default-directory)) - (unless visiting - (push buf buffers)) - (with-current-buffer buf - (goto-char pt) - (font-lock-fontify-region - (line-beginning-position) (line-end-position)) - (format "%s:%d: %s" - (car (cl-sort (list (abbreviate-file-name (buffer-file-name buf)) - (file-relative-name (buffer-file-name buf) dir)) - #'< :key #'length)) - (line-number-at-pos) - (string-trim-right (or (thing-at-point 'line) "")))))))) - (cddr (better-jumper-jump-list-struct-ring - (better-jumper-get-jumps (better-jumper--get-current-context)))))))) - :prompt "jumplist: " - :sort nil - :require-match t - :category 'jump-list)) - (mapc #'kill-buffer buffers)))) - (if (not (string-match "^\\([^:]+\\):\\([0-9]+\\): " jump)) - (user-error "No match") - (let ((file (match-string-no-properties 1 jump)) - (line (match-string-no-properties 2 jump))) - (find-file file) - (goto-char (point-min)) - (forward-line (string-to-number line))))) - -;;;###autoload -(defun +vertico-embark-which-key-indicator () - "An embark indicator that displays keymaps using which-key. -The which-key help message will show the type and value of the -current target followed by an ellipsis if there are further -targets." - (lambda (&optional keymap targets prefix) - (if (null keymap) - (which-key--hide-popup-ignore-command) - (which-key--show-keymap - (if (eq (plist-get (car targets) :type) 'embark-become) - "Become" - (format "Act on %s '%s'%s" - (plist-get (car targets) :type) - (embark--truncate-target (plist-get (car targets) :target)) - (if (cdr targets) "…" ""))) - (if prefix - (pcase (lookup-key keymap prefix 'accept-default) - ((and (pred keymapp) km) km) - (_ (key-binding prefix 'accept-default))) - keymap) - nil nil t (lambda (binding) - (not (string-suffix-p "-argument" (cdr binding)))))))) - -;;;###autoload -(defun +vertico--consult--fd-make-builder () - (let ((cmd (split-string-and-unquote +vertico-consult-fd-args))) - (lambda (input) - (pcase-let* ((`(,arg . ,opts) (consult--command-split input)) - (`(,re . ,hl) (funcall consult--regexp-compiler - arg 'extended t))) - (when re - (cons (append cmd - (list (consult--join-regexps re 'extended)) - opts) - hl)))))) - -(autoload #'consult--directory-prompt "consult") -;;;###autoload -(defun +vertico/consult-fd (&optional dir initial) - (interactive "P") - (if doom-projectile-fd-binary - (pcase-let* ((`(,prompt ,paths ,dir) (consult--directory-prompt "Fd" dir)) - (default-directory dir) - (builder (consult--find-make-builder paths))) - (find-file (consult--find prompt builder initial))) - (consult-find dir initial))) - -;;;###autoload -(defun +vertico-basic-remote-try-completion (string table pred point) - (and (vertico--remote-p string) - (completion-basic-try-completion string table pred point))) - -;;;###autoload -(defun +vertico-basic-remote-all-completions (string table pred point) - (and (vertico--remote-p string) - (completion-basic-all-completions string table pred point))) diff --git a/.config/emacs/modules/completion/vertico/autoload/workspaces.el b/.config/emacs/modules/completion/vertico/autoload/workspaces.el @@ -1,93 +0,0 @@ -;;; completion/vertico/autoload/workspaces.el -*- lexical-binding: t; -*- -;;;###if (modulep! :ui workspaces) - -(defun +vertico--workspace-buffer-state () - (let ((preview - ;; Only preview in current window and other window. - ;; Preview in frames and tabs is not possible since these don't get cleaned up. - (if (memq consult--buffer-display - '(switch-to-buffer switch-to-buffer-other-window)) - (let ((orig-buf (current-buffer)) - other-win - cleanup-buffers) - (lambda (action cand) - (when (eq action 'preview) - (when (and (eq consult--buffer-display #'switch-to-buffer-other-window) - (not other-win)) - (switch-to-buffer-other-window orig-buf) - (setq other-win (selected-window))) - (let ((win (or other-win (selected-window)))) - (when (window-live-p win) - (with-selected-window win - (cond - ((and cand (get-buffer cand)) - (unless (+workspace-contains-buffer-p cand) - (cl-pushnew cand cleanup-buffers)) - (switch-to-buffer cand 'norecord)) - ((buffer-live-p orig-buf) - (switch-to-buffer orig-buf 'norecord) - (mapc #'persp-remove-buffer cleanup-buffers))))))))) - #'ignore))) - (lambda (action cand) - (funcall preview action cand)))) - -(defun +vertico--workspace-generate-sources () - "Generate list of consult buffer sources for all workspaces" - (let* ((active-workspace (+workspace-current-name)) - (workspaces (+workspace-list-names)) - (key-range (append (cl-loop for i from ?1 to ?9 collect i) - (cl-loop for i from ?a to ?z collect i) - (cl-loop for i from ?A to ?Z collect i))) - (last-i (length workspaces)) - (i 0)) - (mapcar (lambda (name) - (cl-incf i) - `(:name ,name - :hidden ,(not (string= active-workspace name)) - :narrow ,(nth (1- i) key-range) - :category buffer - :state +vertico--workspace-buffer-state - :items ,(lambda () - (consult--buffer-query - :sort 'visibility - :as #'buffer-name - :predicate - (lambda (buf) - (when-let (workspace (+workspace-get name t)) - (+workspace-contains-buffer-p buf workspace))))))) - (+workspace-list-names)))) - -(autoload 'consult--multi "consult") -;;;###autoload -(defun +vertico/switch-workspace-buffer (&optional force-same-workspace) - "Switch to another buffer in the same or a specified workspace. - -Type the workspace's number (starting from 1) followed by a space to display its -buffer list. Selecting a buffer in another workspace will switch to that -workspace instead. If FORCE-SAME-WORKSPACE (the prefix arg) is non-nil, that -buffer will be opened in the current workspace instead." - (interactive "P") - (when-let (buffer (consult--multi (+vertico--workspace-generate-sources) - :require-match - (confirm-nonexistent-file-or-buffer) - :prompt (format "Switch to buffer (%s): " - (+workspace-current-name)) - :history 'consult--buffer-history - :sort nil)) - (let ((origin-workspace (plist-get (cdr buffer) :name))) - ;; Switch to the workspace the buffer belongs to, maybe - (if (or (equal origin-workspace (+workspace-current-name)) - force-same-workspace) - (funcall consult--buffer-display (car buffer)) - (+workspace-switch origin-workspace) - (message "Switched to %S workspace" origin-workspace) - (if-let (window (get-buffer-window (car buffer))) - (select-window window) - (funcall consult--buffer-display (car buffer))))))) - -;;;###autoload -(defun +vertico/embark-open-in-new-workspace (x) - "Open X (a file) in a new workspace." - (interactive) - (+workspace/new) - (find-file x)) diff --git a/.config/emacs/modules/completion/vertico/config.el b/.config/emacs/modules/completion/vertico/config.el @@ -1,321 +0,0 @@ -;;; completion/vertico/config.el -*- lexical-binding: t; -*- - -(defvar +vertico-company-completion-styles '(basic partial-completion orderless) - "Completion styles for company to use. - -The completion/vertico module uses the orderless completion style by default, -but this returns too broad a candidate set for company completion. This variable -overrides `completion-styles' during company completion sessions.") - -(defvar +vertico-consult-fd-args nil - "Shell command and arguments the vertico module uses for fd.") - -;; -;;; Packages - -(use-package! vertico - :hook (doom-first-input . vertico-mode) - :init - (defadvice! +vertico-crm-indicator-a (args) - :filter-args #'completing-read-multiple - (cons (format "[CRM%s] %s" - (replace-regexp-in-string - "\\`\\[.*?]\\*\\|\\[.*?]\\*\\'" "" - crm-separator) - (car args)) - (cdr args))) - :config - (setq vertico-resize nil - vertico-count 17 - vertico-cycle t) - (setq-default completion-in-region-function - (lambda (&rest args) - (apply (if vertico-mode - #'consult-completion-in-region - #'completion--in-region) - args))) - - (map! :when (modulep! :editor evil +everywhere) - :map vertico-map - "M-RET" #'vertico-exit-input - "C-SPC" #'+vertico/embark-preview - "C-j" #'vertico-next - "C-M-j" #'vertico-next-group - "C-k" #'vertico-previous - "C-M-k" #'vertico-previous-group - "C-h" (cmds! (eq 'file (vertico--metadata-get 'category)) #'vertico-directory-up) - "C-l" (cmds! (eq 'file (vertico--metadata-get 'category)) #'+vertico/enter-or-preview)) - - ;; Cleans up path when moving directories with shadowed paths syntax, e.g. - ;; cleans ~/foo/bar/// to /, and ~/foo/bar/~/ to ~/. - (add-hook 'rfn-eshadow-update-overlay-hook #'vertico-directory-tidy) - (add-hook 'minibuffer-setup-hook #'vertico-repeat-save) - (map! :map vertico-map "DEL" #'vertico-directory-delete-char) - - ;; These commands are problematic and automatically show the *Completions* buffer - (advice-add #'tmm-add-prompt :after #'minibuffer-hide-completions) - (defadvice! +vertico--suppress-completion-help-a (fn &rest args) - :around #'ffap-menu-ask - (letf! ((#'minibuffer-completion-help #'ignore)) - (apply fn args)))) - - -(use-package! orderless - :after-call doom-first-input-hook - :config - (defadvice! +vertico--company-capf--candidates-a (fn &rest args) - "Highlight company matches correctly, and try default completion styles before -orderless." - :around #'company-capf--candidates - (let ((orderless-match-faces [completions-common-part]) - (completion-styles +vertico-company-completion-styles)) - (apply fn args))) - - (defun +vertico-orderless-dispatch (pattern _index _total) - (cond - ;; Ensure $ works with Consult commands, which add disambiguation suffixes - ((string-suffix-p "$" pattern) - `(orderless-regexp . ,(concat (substring pattern 0 -1) "[\x200000-\x300000]*$"))) - ;; Ignore single ! - ((string= "!" pattern) `(orderless-literal . "")) - ;; Without literal - ((string-prefix-p "!" pattern) `(orderless-without-literal . ,(substring pattern 1))) - ;; Character folding - ((string-prefix-p "%" pattern) `(char-fold-to-regexp . ,(substring pattern 1))) - ((string-suffix-p "%" pattern) `(char-fold-to-regexp . ,(substring pattern 0 -1))) - ;; Initialism matching - ((string-prefix-p "`" pattern) `(orderless-initialism . ,(substring pattern 1))) - ((string-suffix-p "`" pattern) `(orderless-initialism . ,(substring pattern 0 -1))) - ;; Literal matching - ((string-prefix-p "=" pattern) `(orderless-literal . ,(substring pattern 1))) - ((string-suffix-p "=" pattern) `(orderless-literal . ,(substring pattern 0 -1))) - ;; Flex matching - ((string-prefix-p "~" pattern) `(orderless-flex . ,(substring pattern 1))) - ((string-suffix-p "~" pattern) `(orderless-flex . ,(substring pattern 0 -1))))) - (add-to-list - 'completion-styles-alist - '(+vertico-basic-remote - +vertico-basic-remote-try-completion - +vertico-basic-remote-all-completions - "Use basic completion on remote files only")) - (setq completion-styles '(orderless basic) - completion-category-defaults nil - ;; note that despite override in the name orderless can still be used in - ;; find-file etc. - completion-category-overrides '((file (styles +vertico-basic-remote orderless partial-completion))) - orderless-style-dispatchers '(+vertico-orderless-dispatch) - orderless-component-separator "[ &]") - ;; ...otherwise find-file gets different highlighting than other commands - (set-face-attribute 'completions-first-difference nil :inherit nil)) - - -(use-package! consult - :defer t - :preface - (define-key! - [remap bookmark-jump] #'consult-bookmark - [remap evil-show-marks] #'consult-mark - [remap evil-show-jumps] #'+vertico/jump-list - [remap evil-show-registers] #'consult-register - [remap goto-line] #'consult-goto-line - [remap imenu] #'consult-imenu - [remap Info-search] #'consult-info - [remap locate] #'consult-locate - [remap load-theme] #'consult-theme - [remap man] #'consult-man - [remap recentf-open-files] #'consult-recent-file - [remap switch-to-buffer] #'consult-buffer - [remap switch-to-buffer-other-window] #'consult-buffer-other-window - [remap switch-to-buffer-other-frame] #'consult-buffer-other-frame - [remap yank-pop] #'consult-yank-pop - [remap persp-switch-to-buffer] #'+vertico/switch-workspace-buffer) - :config - (defadvice! +vertico--consult-recent-file-a (&rest _args) - "`consult-recent-file' needs to have `recentf-mode' on to work correctly" - :before #'consult-recent-file - (recentf-mode +1)) - - (setq consult-project-root-function #'doom-project-root - consult-narrow-key "<" - consult-line-numbers-widen t - consult-async-min-input 2 - consult-async-refresh-delay 0.15 - consult-async-input-throttle 0.2 - consult-async-input-debounce 0.1) - (unless +vertico-consult-fd-args - (setq +vertico-consult-fd-args - (if doom-projectile-fd-binary - (format "%s --color=never -i -H -E .git --regex %s" - doom-projectile-fd-binary - (if IS-WINDOWS "--path-separator=/" "")) - consult-find-args))) - - (consult-customize - consult-ripgrep consult-git-grep consult-grep - consult-bookmark consult-recent-file - +default/search-project +default/search-other-project - +default/search-project-for-symbol-at-point - +default/search-cwd +default/search-other-cwd - +default/search-notes-for-symbol-at-point - +default/search-emacsd - consult--source-recent-file consult--source-project-recent-file consult--source-bookmark - :preview-key "C-SPC") - (consult-customize - consult-theme - :preview-key (list "C-SPC" :debounce 0.5 'any)) - (when (modulep! :lang org) - (defvar +vertico--consult-org-source - (list :name "Org Buffer" - :category 'buffer - :narrow ?o - :hidden t - :face 'consult-buffer - :history 'buffer-name-history - :state #'consult--buffer-state - :new - (lambda (name) - (with-current-buffer (get-buffer-create name) - (insert "#+title: " name "\n\n") - (org-mode) - (consult--buffer-action (current-buffer)))) - :items - (lambda () - (mapcar #'buffer-name - (if (featurep 'org) - (org-buffer-list) - (seq-filter - (lambda (x) - (eq (buffer-local-value 'major-mode x) 'org-mode)) - (buffer-list))))))) - (add-to-list 'consult-buffer-sources '+vertico--consult-org-source 'append))) - - -(use-package! consult-dir - :bind (([remap list-directory] . consult-dir) - :map vertico-map - ("C-x C-d" . consult-dir) - ("C-x C-j" . consult-dir-jump-file)) - :config - (when (modulep! :tools docker) - (defun +vertico--consult-dir-docker-hosts () - "Get a list of hosts from docker." - (when (if (>= emacs-major-version 29) - (require 'tramp-container nil t) - (setq-local docker-tramp-use-names t) - (require 'docker-tramp nil t)) - (let ((hosts) - (docker-query-fn #'docker-tramp--parse-running-containers)) - (when (>= emacs-major-version 29) - (setq docker-query-fn #'tramp-docker--completion-function)) - (dolist (cand (funcall docker-query-fn)) - (let ((user (unless (string-empty-p (car cand)) - (concat (car cand) "@"))) - (host (car (cdr cand)))) - (push (concat "/docker:" user host ":/") hosts))) - hosts))) - - (defvar +vertico--consult-dir-source-tramp-docker - `(:name "Docker" - :narrow ?d - :category file - :face consult-file - :history file-name-history - :items ,#'+vertico--consult-dir-docker-hosts) - "Docker candiadate source for `consult-dir'.") - - (add-to-list 'consult-dir-sources '+vertico--consult-dir-source-tramp-docker t)) - - (add-to-list 'consult-dir-sources 'consult-dir--source-tramp-ssh t) - (add-to-list 'consult-dir-sources 'consult-dir--source-tramp-local t)) - -(use-package! consult-flycheck - :when (modulep! :checkers syntax) - :after (consult flycheck)) - - -(use-package! embark - :defer t - :init - (setq which-key-use-C-h-commands nil - prefix-help-command #'embark-prefix-help-command) - (map! [remap describe-bindings] #'embark-bindings - "C-;" #'embark-act ; to be moved to :config default if accepted - (:map minibuffer-local-map - "C-;" #'embark-act - "C-c C-;" #'embark-export - "C-c C-l" #'embark-collect - :desc "Export to writable buffer" "C-c C-e" #'+vertico/embark-export-write) - (:leader - :desc "Actions" "a" #'embark-act)) ; to be moved to :config default if accepted - :config - (require 'consult) - - (set-popup-rule! "^\\*Embark Export:" :size 0.35 :ttl 0 :quit nil) - - (defadvice! +vertico--embark-which-key-prompt-a (fn &rest args) - "Hide the which-key indicator immediately when using the completing-read prompter." - :around #'embark-completing-read-prompter - (which-key--hide-popup-ignore-command) - (let ((embark-indicators - (remq #'embark-which-key-indicator embark-indicators))) - (apply fn args))) - (cl-nsubstitute #'+vertico-embark-which-key-indicator #'embark-mixed-indicator embark-indicators) - ;; add the package! target finder before the file target finder, - ;; so we don't get a false positive match. - (let ((pos (or (cl-position - 'embark-target-file-at-point - embark-target-finders) - (length embark-target-finders)))) - (cl-callf2 - cons - '+vertico-embark-target-package-fn - (nthcdr pos embark-target-finders))) - (defvar-keymap +vertico/embark-doom-package-map - :doc "Keymap for Embark package actions for packages installed by Doom." - :parent embark-general-map - "h" #'doom/help-packages - "b" #'doom/bump-package - "c" #'doom/help-package-config - "u" #'doom/help-package-homepage) - (setf (alist-get 'package embark-keymap-alist) #'+vertico/embark-doom-package-map) - (map! (:map embark-file-map - :desc "Open target with sudo" "s" #'doom/sudo-find-file - (:when (modulep! :tools magit) - :desc "Open magit-status of target" "g" #'+vertico/embark-magit-status) - (:when (modulep! :ui workspaces) - :desc "Open in new workspace" "TAB" #'+vertico/embark-open-in-new-workspace)))) - - -(use-package! marginalia - :hook (doom-first-input . marginalia-mode) - :init - (map! :map minibuffer-local-map - :desc "Cycle marginalia views" "M-A" #'marginalia-cycle) - :config - (when (modulep! +icons) - (add-hook 'marginalia-mode-hook #'all-the-icons-completion-marginalia-setup)) - (advice-add #'marginalia--project-root :override #'doom-project-root) - (pushnew! marginalia-command-categories - '(+default/find-file-under-here . file) - '(doom/find-file-in-emacsd . project-file) - '(doom/find-file-in-other-project . project-file) - '(doom/find-file-in-private-config . file) - '(doom/describe-active-minor-mode . minor-mode) - '(flycheck-error-list-set-filter . builtin) - '(persp-switch-to-buffer . buffer) - '(projectile-find-file . project-file) - '(projectile-recentf . project-file) - '(projectile-switch-to-buffer . buffer) - '(projectile-switch-project . project-file))) - - -(use-package! wgrep - :commands wgrep-change-to-wgrep-mode - :config (setq wgrep-auto-save-buffer t)) - - -(use-package! vertico-posframe - :when (modulep! +childframe) - :hook (vertico-mode . vertico-posframe-mode) - :config - (add-hook 'doom-after-reload-hook #'posframe-delete-all)) diff --git a/.config/emacs/modules/completion/vertico/doctor.el b/.config/emacs/modules/completion/vertico/doctor.el @@ -1,12 +0,0 @@ -;;; completion/vertico/doctor.el -*- lexical-binding: t; -*- - -(when (require 'consult nil t) - ;; FIXME: This throws an error if grep is missing. - (unless (consult--grep-lookahead-p "grep" "-P") - (warn! "The installed grep binary was not built with support for PCRE lookaheads") - (explain! "Some advanced consult filtering features will not work as a result, see the module readme.")) - - ;; TODO: Move this to core in v3.0 - (unless (consult--grep-lookahead-p "rg" "-P") - (warn! "The installed ripgrep binary was not built with support for PCRE lookaheads.") - (explain! "Some advanced consult filtering features will not work as a result, see the module readme."))) diff --git a/.config/emacs/modules/completion/vertico/packages.el b/.config/emacs/modules/completion/vertico/packages.el @@ -1,28 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; completion/vertico/packages.el - -(package! vertico - :recipe (:host github :repo "minad/vertico" - :files ("*.el" "extensions/*.el")) - :pin "b6b8420d2943e42b88e2a143da29edf76bc223b5") - -(package! orderless :pin "e6784026717a8a6a7dcd0bf31fd3414f148c542e") - -(package! consult :pin "052399ed05372464b8ed6261b3196de143a8a834") -(package! consult-dir :pin "ed8f0874d26f10f5c5b181ab9f2cf4107df8a0eb") -(when (modulep! :checkers syntax) - (package! consult-flycheck :pin "c371996c571b7139ef4d9a8db142bf37a7ee826b")) -(package! embark :pin "3ffb27a833d326ccf7e375bb9d94ebf4dc37fa77") -(package! embark-consult :pin "3ffb27a833d326ccf7e375bb9d94ebf4dc37fa77") - -(package! marginalia :pin "2633b2dee22261531f960e49106771e679102a98") - -(package! wgrep :pin "edf768732a56840db6879706b64c5773c316d619") - -(when (modulep! +icons) - (package! all-the-icons-completion :pin "b08f053cee444546ab44a05fd541f59e8bc8983b")) - -(when (modulep! +childframe) - (package! vertico-posframe - :recipe (:host github :repo "tumashu/vertico-posframe") - :pin "7da6d648ff4202a48eb6647ee7dce8d65de48779")) diff --git a/.config/emacs/modules/config/README.org b/.config/emacs/modules/config/README.org @@ -1,10 +0,0 @@ -#+title: :config -#+created: July 29, 2021 -#+since: 21.12.0 - -* Description -Modules in this category provide sane defaults or improve your ability to -configure Emacs. It is best to load these last. - -* Frequently asked questions -/This category has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] diff --git a/.config/emacs/modules/config/default/+emacs-bindings.el b/.config/emacs/modules/config/default/+emacs-bindings.el @@ -1,637 +0,0 @@ -;;; config/default/+emacs-bindings.el -*- lexical-binding: t; -*- - -;; Sensible default key bindings for non-evil users -(setq doom-leader-alt-key "C-c" - doom-localleader-alt-key "C-c l") - -;; persp-mode and projectile in different prefixes -(setq! persp-keymap-prefix (kbd "C-c w")) -(after! projectile - (define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)) - - -;; -;;; Autoloads - -(autoload 'org-capture-goto-target "org-capture" nil t) - - -;; -;;; Leader keys - -(map! :leader - :desc "Evaluate line/region" "e" #'+eval/line-or-region - - (:prefix ("l" . "<localleader>")) ; bound locally - (:prefix ("!" . "checkers")) ; bound by flycheck - - ;;; <leader> c --- code - (:prefix-map ("c" . "code") - :desc "Compile" "c" #'compile - :desc "Recompile" "C" #'recompile - :desc "Jump to definition" "d" #'+lookup/definition - :desc "Jump to references" "D" #'+lookup/references - :desc "Evaluate buffer/region" "e" #'+eval/buffer-or-region - :desc "Evaluate & replace region" "E" #'+eval/region-and-replace - :desc "Format buffer/region" "f" #'+format/region-or-buffer - :desc "Find implementations" "i" #'+lookup/implementations - :desc "Jump to documentation" "k" #'+lookup/documentation - :desc "Send to repl" "s" #'+eval/send-region-to-repl - :desc "Find type definition" "t" #'+lookup/type-definition - :desc "Delete trailing whitespace" "w" #'delete-trailing-whitespace - :desc "Delete trailing newlines" "W" #'doom/delete-trailing-newlines - :desc "List errors" "x" #'+default/diagnostics - (:when (and (modulep! :tools lsp) (not (modulep! :tools lsp +eglot))) - :desc "LSP Code actions" "a" #'lsp-execute-code-action - :desc "LSP Organize imports" "o" #'lsp-organize-imports - :desc "LSP Rename" "r" #'lsp-rename - :desc "LSP" "l" #'+default/lsp-command-map - (:when (modulep! :completion ivy) - :desc "Jump to symbol in current workspace" "j" #'lsp-ivy-workspace-symbol - :desc "Jump to symbol in any workspace" "J" #'lsp-ivy-global-workspace-symbol) - (:when (modulep! :completion helm) - :desc "Jump to symbol in current workspace" "j" #'helm-lsp-workspace-symbol - :desc "Jump to symbol in any workspace" "J" #'helm-lsp-global-workspace-symbol) - (:when (modulep! :completion vertico) - :desc "Jump to symbol in current workspace" "j" #'consult-lsp-symbols - :desc "Jump to symbol in any workspace" "J" (cmd!! #'consult-lsp-symbols 'all-workspaces)) - (:when (modulep! :ui treemacs +lsp) - :desc "Errors list" "X" #'lsp-treemacs-errors-list - :desc "Incoming call hierarchy" "y" #'lsp-treemacs-call-hierarchy - :desc "Outgoing call hierarchy" "Y" (cmd!! #'lsp-treemacs-call-hierarchy t) - :desc "References tree" "R" (cmd!! #'lsp-treemacs-references t) - :desc "Symbols" "S" #'lsp-treemacs-symbols)) - (:when (modulep! :tools lsp +eglot) - :desc "LSP Execute code action" "a" #'eglot-code-actions - :desc "LSP Rename" "r" #'eglot-rename - :desc "LSP Find declaration" "j" #'eglot-find-declaration - (:when (modulep! :completion vertico) - :desc "Jump to symbol in current workspace" "j" #'consult-eglot-symbols))) - - ;;; <leader> f --- file - (:prefix-map ("f" . "file") - (:when (modulep! :tools editorconfig) - :desc "Open project editorconfig" "c" #'editorconfig-find-current-editorconfig) - :desc "Copy this file" "C" #'doom/copy-this-file - :desc "Find directory" "d" #'dired - :desc "Delete this file" "D" #'doom/delete-this-file - :desc "Find file in emacs.d" "e" #'doom/find-file-in-emacsd - :desc "Browse emacs.d" "E" #'doom/browse-in-emacsd - :desc "Find file" "f" #'find-file - :desc "Find file from here" "F" #'+default/find-file-under-here - :desc "Locate file" "l" #'locate - :desc "Rename/move this file" "m" #'doom/move-this-file - :desc "Find file in private config" "p" #'doom/find-file-in-private-config - :desc "Browse private config" "P" #'doom/open-private-config - :desc "Recent files" "r" #'recentf-open-files - :desc "Recent project files" "R" #'projectile-recentf - :desc "Sudo this file" "u" #'doom/sudo-this-file - :desc "Sudo find file" "U" #'doom/sudo-find-file - :desc "Yank file path" "y" #'+default/yank-buffer-path - :desc "Yank file path from project" "Y" #'+default/yank-buffer-path-relative-to-project - :desc "Open scratch buffer" "x" #'doom/open-scratch-buffer - :desc "Switch to scratch buffer" "X" #'doom/switch-to-scratch-buffer) - - ;;; <leader> r --- remote - (:when (modulep! :tools upload) - (:prefix-map ("r" . "remote") - :desc "Browse remote" "b" #'ssh-deploy-browse-remote-base-handler - :desc "Browse relative" "B" #'ssh-deploy-browse-remote-handler - :desc "Download remote" "d" #'ssh-deploy-download-handler - :desc "Delete local & remote" "D" #'ssh-deploy-delete-handler - :desc "Eshell base terminal" "e" #'ssh-deploy-remote-terminal-eshell-base-handler - :desc "Eshell relative terminal" "E" #'ssh-deploy-remote-terminal-eshell-handler - :desc "Move/rename local & remote" "m" #'ssh-deploy-rename-handler - :desc "Open this file on remote" "o" #'ssh-deploy-open-remote-file-handler - :desc "Run deploy script" "s" #'ssh-deploy-run-deploy-script-handler - :desc "Upload local" "u" #'ssh-deploy-upload-handler - :desc "Upload local (force)" "U" #'ssh-deploy-upload-handler-forced - :desc "Diff local & remote" "x" #'ssh-deploy-diff-handler - :desc "Browse remote files" "." #'ssh-deploy-browse-remote-handler - :desc "Detect remote changes" ">" #'ssh-deploy-remote-changes-handler)) - - ;;; <leader> s --- search - (:prefix-map ("s" . "search") - :desc "Search project for symbol" "." #'+default/search-project-for-symbol-at-point - :desc "Search buffer" "b" - (cond ((modulep! :completion vertico) #'consult-line) - ((modulep! :completion ivy) #'swiper) - ((modulep! :completion helm) #'swiper)) - :desc "Search all open buffers" "B" - (cond ((modulep! :completion vertico) (cmd!! #'consult-line-multi 'all-buffers)) - ((modulep! :completion ivy) #'swiper-all) - ((modulep! :completion helm) #'swiper-all)) - :desc "Search current directory" "d" #'+default/search-cwd - :desc "Search other directory" "D" #'+default/search-other-cwd - :desc "Search .emacs.d" "e" #'+default/search-emacsd - :desc "Locate file" "f" #'+lookup/file - :desc "Jump to symbol" "i" #'imenu - :desc "Jump to visible link" "l" #'link-hint-open-link - :desc "Jump to link" "L" #'ffap-menu - :desc "Jump to bookmark" "m" #'bookmark-jump - :desc "Look up online" "o" #'+lookup/online - :desc "Look up online (w/ prompt)" "O" #'+lookup/online-select - :desc "Look up in local docsets" "k" #'+lookup/in-docsets - :desc "Look up in all docsets" "K" #'+lookup/in-all-docsets - :desc "Search project" "p" #'+default/search-project - :desc "Search other project" "P" #'+default/search-other-project - :desc "Search buffer" "s" #'+default/search-buffer - :desc "Search buffer for thing at point" "S" - (cond ((modulep! :completion vertico) #'+vertico/search-symbol-at-point) - ((modulep! :completion ivy) #'swiper-isearch-thing-at-point) - ((modulep! :completion helm) #'swiper-isearch-thing-at-point)) - :desc "Dictionary" "t" #'+lookup/dictionary-definition - :desc "Thesaurus" "T" #'+lookup/synonyms) - - ;;; <leader> i --- insert - (:prefix-map ("i" . "insert") - :desc "Emoji" "e" #'emojify-insert-emoji - :desc "Current file name" "f" #'+default/insert-file-path - :desc "Current file path" "F" (cmd!! #'+default/insert-file-path t) - :desc "Snippet" "s" #'yas-insert-snippet - :desc "Unicode" "u" #'insert-char - :desc "From clipboard" "y" #'+default/yank-pop) - - ;;; <leader> n --- notes - (:prefix-map ("n" . "notes") - :desc "Search notes for symbol" "." #'+default/search-notes-for-symbol-at-point - :desc "Org agenda" "a" #'org-agenda - (:when (modulep! :tools biblio) - :desc "Bibliographic notes" "b" - (cond ((modulep! :completion vertico) #'citar-open-notes) - ((modulep! :completion ivy) #'ivy-bibtex) - ((modulep! :completion helm) #'helm-bibtex))) - - :desc "Toggle last org-clock" "c" #'+org/toggle-last-clock - :desc "Cancel current org-clock" "C" #'org-clock-cancel - :desc "Open deft" "d" #'deft - (:when (modulep! :lang org +noter) - :desc "Org noter" "e" #'org-noter) - - :desc "Find file in notes" "f" #'+default/find-in-notes - :desc "Browse notes" "F" #'+default/browse-notes - :desc "Org store link" "l" #'org-store-link - :desc "Tags search" "m" #'org-tags-view - :desc "Org capture" "n" #'org-capture - :desc "Goto capture" "N" #'org-capture-goto-target - :desc "Active org-clock" "o" #'org-clock-goto - :desc "Todo list" "t" #'org-todo-list - :desc "Search notes" "s" #'+default/org-notes-search - :desc "Search org agenda headlines" "S" #'+default/org-notes-headlines - :desc "View search" "v" #'org-search-view - :desc "Org export to clipboard" "y" #'+org/export-to-clipboard - :desc "Org export to clipboard as RTF" "Y" #'+org/export-to-clipboard-as-rich-text - (:when (modulep! :lang org +journal) - (:prefix ("j" . "journal") - :desc "New Entry" "j" #'org-journal-new-entry - :desc "New Scheduled Entry" "J" #'org-journal-new-scheduled-entry - :desc "Search Forever" "s" #'org-journal-search-forever)) - (:when (modulep! :lang org +roam) - (:prefix ("r" . "roam") - :desc "Switch to buffer" "b" #'org-roam-switch-to-buffer - :desc "Org Roam Capture" "c" #'org-roam-capture - :desc "Find file" "f" #'org-roam-find-file - :desc "Show graph" "g" #'org-roam-graph - :desc "Insert" "i" #'org-roam-insert - :desc "Insert (skipping org-capture)" "I" #'org-roam-insert-immediate - :desc "Org Roam" "r" #'org-roam - :desc "Tag" "t" #'org-roam-tag-add - :desc "Un-tag" "T" #'org-roam-tag-delete - (:prefix ("d" . "by date") - :desc "Arbitrary date" "d" #'org-roam-dailies-find-date - :desc "Today" "t" #'org-roam-dailies-find-today - :desc "Tomorrow" "m" #'org-roam-dailies-find-tomorrow - :desc "Yesterday" "y" #'org-roam-dailies-find-yesterday))) - (:when (modulep! :lang org +roam2) - (:prefix ("r" . "roam") - :desc "Open random node" "a" #'org-roam-node-random - :desc "Find node" "f" #'org-roam-node-find - :desc "Find ref" "F" #'org-roam-ref-find - :desc "Show graph" "g" #'org-roam-graph - :desc "Insert node" "i" #'org-roam-node-insert - :desc "Capture to node" "n" #'org-roam-capture - :desc "Toggle roam buffer" "r" #'org-roam-buffer-toggle - :desc "Launch roam buffer" "R" #'org-roam-buffer-display-dedicated - :desc "Sync database" "s" #'org-roam-db-sync - (:prefix ("d" . "by date") - :desc "Goto previous note" "b" #'org-roam-dailies-goto-previous-note - :desc "Goto date" "d" #'org-roam-dailies-goto-date - :desc "Capture date" "D" #'org-roam-dailies-capture-date - :desc "Goto next note" "f" #'org-roam-dailies-goto-next-note - :desc "Goto tomorrow" "m" #'org-roam-dailies-goto-tomorrow - :desc "Capture tomorrow" "M" #'org-roam-dailies-capture-tomorrow - :desc "Capture today" "n" #'org-roam-dailies-capture-today - :desc "Goto today" "t" #'org-roam-dailies-goto-today - :desc "Capture today" "T" #'org-roam-dailies-capture-today - :desc "Goto yesterday" "y" #'org-roam-dailies-goto-yesterday - :desc "Capture yesterday" "Y" #'org-roam-dailies-capture-yesterday - :desc "Find directory" "-" #'org-roam-dailies-find-directory)))) - - ;;; <leader> o --- open - "o" nil ; we need to unbind it first as Org claims this prefix - (:prefix-map ("o" . "open") - :desc "Browser" "b" #'browse-url-of-file - :desc "Debugger" "d" #'+debugger/start - :desc "New frame" "f" #'make-frame - :desc "REPL" "r" #'+eval/open-repl-other-window - :desc "REPL (same window)" "R" #'+eval/open-repl-same-window - :desc "Dired" "-" #'dired-jump - (:when (modulep! :ui neotree) - :desc "Project sidebar" "p" #'+neotree/open - :desc "Find file in project sidebar" "P" #'+neotree/find-this-file) - (:when (modulep! :ui treemacs) - :desc "Project sidebar" "p" #'+treemacs/toggle - :desc "Find file in project rsidebar" "P" #'treemacs-find-file) - (:when (modulep! :term shell) - :desc "Toggle shell popup" "t" #'+shell/toggle - :desc "Open shell here" "T" #'+shell/here) - (:when (modulep! :term term) - :desc "Toggle terminal popup" "t" #'+term/toggle - :desc "Open terminal here" "T" #'+term/here) - (:when (modulep! :term vterm) - :desc "Toggle vterm popup" "t" #'+vterm/toggle - :desc "Open vterm here" "T" #'+vterm/here) - (:when (modulep! :term eshell) - :desc "Toggle eshell popup" "e" #'+eshell/toggle - :desc "Open eshell here" "E" #'+eshell/here) - (:when (modulep! :os macos) - :desc "Reveal in Finder" "o" #'+macos/reveal-in-finder - :desc "Reveal project in Finder" "O" #'+macos/reveal-project-in-finder - :desc "Send to Transmit" "u" #'+macos/send-to-transmit - :desc "Send project to Transmit" "U" #'+macos/send-project-to-transmit - :desc "Send to Launchbar" "l" #'+macos/send-to-launchbar - :desc "Send project to Launchbar" "L" #'+macos/send-project-to-launchbar - :desc "Open in iTerm" "i" #'+macos/open-in-iterm - :desc "Open in new iTerm window" "I" #'+macos/open-in-iterm-new-window) - (:when (modulep! :tools docker) - :desc "Docker" "D" #'docker) - (:when (modulep! :email mu4e) - :desc "mu4e" "m" #'=mu4e) - (:when (modulep! :email notmuch) - :desc "notmuch" "m" #'=notmuch) - (:when (modulep! :email wanderlust) - :desc "wanderlust" "m" #'=wanderlust)) - - - ;;; <leader> p --- project - (:prefix ("p" . "project") - :desc "Search project for symbol" "." #'+default/search-project-for-symbol-at-point - :desc "Find file in other project" "F" #'doom/find-file-in-other-project - :desc "Search project" "s" #'+default/search-project - :desc "List project todos" "t" #'magit-todos-list - :desc "Open project scratch buffer" "x" #'doom/open-project-scratch-buffer - :desc "Switch to project scratch buffer" "X" #'doom/switch-to-project-scratch-buffer - (:when (and (modulep! :tools taskrunner) - (or (modulep! :completion ivy) - (modulep! :completion helm))) - :desc "List project tasks" "z" #'+taskrunner/project-tasks) - ;; later expanded by projectile - (:prefix ("4" . "in other window")) - (:prefix ("5" . "in other frame"))) - - ;;; <leader> q --- quit/restart - (:prefix-map ("q" . "quit/restart") - :desc "Restart emacs server" "d" #'+default/restart-server - :desc "Delete frame" "f" #'delete-frame - :desc "Clear current frame" "F" #'doom/kill-all-buffers - :desc "Kill Emacs (and daemon)" "K" #'save-buffers-kill-emacs - :desc "Quit Emacs" "q" #'kill-emacs - :desc "Save and quit Emacs" "Q" #'save-buffers-kill-terminal - :desc "Quick save current session" "s" #'doom/quicksave-session - :desc "Restore last session" "l" #'doom/quickload-session - :desc "Save session to file" "S" #'doom/save-session - :desc "Restore session from file" "L" #'doom/load-session - :desc "Restart & restore Emacs" "r" #'doom/restart-and-restore - :desc "Restart Emacs" "R" #'doom/restart) - - ;;; <leader> & --- snippets - (:prefix-map ("&" . "snippets") - :desc "New snippet" "n" #'yas-new-snippet - :desc "Insert snippet" "i" #'yas-insert-snippet - :desc "Find global snippet" "/" #'yas-visit-snippet-file - :desc "Reload snippets" "r" #'yas-reload-all - :desc "Create Temp Template" "c" #'aya-create - :desc "Use Temp Template" "e" #'aya-expand) - - ;;; <leader> t --- toggle - (:prefix-map ("t" . "toggle") - :desc "Big mode" "b" #'doom-big-font-mode - :desc "Fill Column Indicator" "c" #'global-display-fill-column-indicator-mode - :desc "Flymake" "f" #'flymake-mode - :desc "Frame fullscreen" "F" #'toggle-frame-fullscreen - :desc "Indent style" "I" #'doom/toggle-indent-style - :desc "Line numbers" "l" #'doom/toggle-line-numbers - :desc "Visible mode" "v" #'visible-mode - :desc "Soft line wrapping" "w" #'visual-line-mode - (:when (modulep! :editor word-wrap) - :desc "Soft line wrapping" "w" #'+word-wrap-mode) - (:when (modulep! :checkers syntax) - :desc "Flycheck" "f" #'flycheck-mode) - (:when (modulep! :ui indent-guides) - :desc "Indent guides" "i" #'highlight-indent-guides-mode) - (:when (modulep! :ui minimap) - :desc "Minimap mode" "m" #'minimap-mode) - (:when (modulep! :lang org +present) - :desc "org-tree-slide mode" "p" #'org-tree-slide-mode) - :desc "Read-only mode" "r" #'read-only-mode - (:when (and (modulep! :checkers spell) (not (modulep! :checkers spell +flyspell))) - :desc "Spell checker" "s" #'spell-fu-mode) - (:when (modulep! :checkers spell +flyspell) - :desc "Spell checker" "s" #'flyspell-mode) - (:when (modulep! :lang org +pomodoro) - :desc "Pomodoro timer" "t" #'org-pomodoro) - (:when (modulep! :ui zen) - :desc "Zen mode" "z" #'+zen/toggle - :desc "Zen mode (fullscreen)" "Z" #'+zen/toggle-fullscreen)) - - ;;; <leader> v --- versioning - (:prefix-map ("v" . "versioning") - :desc "Git revert file" "R" #'vc-revert - :desc "Kill link to remote" "y" #'+vc/browse-at-remote-kill - :desc "Kill link to homepage" "Y" #'+vc/browse-at-remote-kill-homepage - (:when (modulep! :ui vc-gutter) - :desc "Git revert hunk" "r" #'+vc-gutter/revert-hunk - :desc "Git stage hunk" "s" #'+vc-gutter/stage-hunk - :desc "Git time machine" "t" #'git-timemachine-toggle - :desc "Jump to next hunk" "n" #'+vc-gutter/next-hunk - :desc "Jump to previous hunk" "p" #'+vc-gutter/previous-hunk) - (:when (modulep! :tools magit) - :desc "Magit dispatch" "/" #'magit-dispatch - :desc "Magit file dispatch" "." #'magit-file-dispatch - :desc "Forge dispatch" "'" #'forge-dispatch - :desc "Magit status" "g" #'magit-status - :desc "Magit status here" "G" #'magit-status-here - :desc "Magit file delete" "x" #'magit-file-delete - :desc "Magit blame" "B" #'magit-blame-addition - :desc "Magit clone" "C" #'magit-clone - :desc "Magit fetch" "F" #'magit-fetch - :desc "Magit buffer log" "L" #'magit-log-buffer-file - :desc "Git stage file" "S" #'magit-stage-file - :desc "Git unstage file" "U" #'magit-unstage-file - (:prefix ("f" . "find") - :desc "Find file" "f" #'magit-find-file - :desc "Find gitconfig file" "g" #'magit-find-git-config-file - :desc "Find commit" "c" #'magit-show-commit - :desc "Find issue" "i" #'forge-visit-issue - :desc "Find pull request" "p" #'forge-visit-pullreq) - (:prefix ("o" . "open in browser") - :desc "Browse file or region" "." #'+vc/browse-at-remote - :desc "Browse homepage" "h" #'+vc/browse-at-remote-homepage - :desc "Browse remote" "r" #'forge-browse-remote - :desc "Browse commit" "c" #'forge-browse-commit - :desc "Browse an issue" "i" #'forge-browse-issue - :desc "Browse a pull request" "p" #'forge-browse-pullreq - :desc "Browse issues" "I" #'forge-browse-issues - :desc "Browse pull requests" "P" #'forge-browse-pullreqs) - (:prefix ("l" . "list") - (:when (modulep! :tools gist) - :desc "List gists" "g" #'gist-list) - :desc "List repositories" "r" #'magit-list-repositories - :desc "List submodules" "s" #'magit-list-submodules - :desc "List issues" "i" #'forge-list-issues - :desc "List pull requests" "p" #'forge-list-pullreqs - :desc "List notifications" "n" #'forge-list-notifications) - (:prefix ("c" . "create") - :desc "Initialize repo" "r" #'magit-init - :desc "Clone repo" "R" #'magit-clone - :desc "Commit" "c" #'magit-commit-create - :desc "Fixup" "f" #'magit-commit-fixup - :desc "Issue" "i" #'forge-create-issue - :desc "Pull request" "p" #'forge-create-pullreq))) - - ;;; <leader> w --- workspaces/windows - (:prefix-map ("w" . "workspaces/windows") - (:when (modulep! :ui workspaces) - :desc "Display workspaces" "d" #'+workspace/display - :desc "Rename workspace" "r" #'+workspace/rename - :desc "Create workspace" "c" #'+workspace/new - :desc "Create named workspace" "C" #'+workspace/new-named - :desc "Delete workspace" "k" #'+workspace/delete - :desc "Save workspace" "S" #'+workspace/save - :desc "Switch to other workspace" "o" #'+workspace/other - :desc "Switch to left workspace" "p" #'+workspace/switch-left - :desc "Switch to right workspace" "n" #'+workspace/switch-right - :desc "Switch to" "w" #'+workspace/switch-to - :desc "Switch to workspace 1" "1" #'+workspace/switch-to-0 - :desc "Switch to workspace 2" "2" #'+workspace/switch-to-1 - :desc "Switch to workspace 3" "3" #'+workspace/switch-to-2 - :desc "Switch to workspace 4" "4" #'+workspace/switch-to-3 - :desc "Switch to workspace 5" "5" #'+workspace/switch-to-4 - :desc "Switch to workspace 6" "6" #'+workspace/switch-to-5 - :desc "Switch to workspace 7" "7" #'+workspace/switch-to-6 - :desc "Switch to workspace 8" "8" #'+workspace/switch-to-7 - :desc "Switch to workspace 9" "9" #'+workspace/switch-to-8 - :desc "Switch to last workspace" "0" #'+workspace/switch-to-final) - :desc "Autosave session" "a" #'doom/quicksave-session - :desc "Save session" "s" #'doom/save-session - :desc "Load session" "l" #'doom/load-session - :desc "Load last autosaved session" "L" #'doom/quickload-session - :desc "Undo window config" "u" #'winner-undo - :desc "Redo window config" "U" #'winner-redo) - - ;;; <leader> m --- multiple cursors - (:when (modulep! :editor multiple-cursors) - (:prefix-map ("m" . "multiple-cursors") - :desc "Edit lines" "l" #'mc/edit-lines - :desc "Mark next" "n" #'mc/mark-next-like-this - :desc "Unmark next" "N" #'mc/unmark-next-like-this - :desc "Mark previous" "p" #'mc/mark-previous-like-this - :desc "Unmark previous" "P" #'mc/unmark-previous-like-this - :desc "Mark all" "t" #'mc/mark-all-like-this - :desc "Mark all DWIM" "m" #'mc/mark-all-like-this-dwim - :desc "Edit line endings" "e" #'mc/edit-ends-of-lines - :desc "Edit line starts" "a" #'mc/edit-beginnings-of-lines - :desc "Mark tag" "s" #'mc/mark-sgml-tag-pair - :desc "Mark in defun" "d" #'mc/mark-all-like-this-in-defun - :desc "Add cursor w/mouse" "<mouse-1>" #'mc/add-cursor-on-click)) - - ;; APPs - ;;; <leader> M --- mu4e - (:when (modulep! :email mu4e) - (:prefix-map ("M" . "mu4e") - :desc "Open email app" "M" #'=mu4e - :desc "Compose email" "c" #'+mu4e/compose)) - - ;;; <leader> I --- IRC - (:when (modulep! :app irc) - (:prefix-map ("I" . "irc") - :desc "Open irc app" "I" #'=irc - :desc "Next unread buffer" "a" #'tracking-next-buffer - :desc "Quit irc" "q" #'+irc/quit - :desc "Reconnect all" "r" #'circe-reconnect-all - :desc "Send message" "s" #'+irc/send-message - (:when (modulep! :completion ivy) - :desc "Jump to channel" "j" #'+irc/ivy-jump-to-channel) - (:when (modulep! :completion vertico) - :desc "Jump to channel" "j" #'+irc/vertico-jump-to-channel))) - - ;;; <leader> T --- twitter - (:when (modulep! :app twitter) - (:prefix-map ("T" . "twitter") - :desc "Open twitter app" "T" #'=twitter - :desc "Quit twitter" "q" #'+twitter/quit - :desc "Rerender twits" "r" #'+twitter/rerender-all - :desc "Ace link" "l" #'+twitter/ace-link))) - - -;; -;;; Global & plugin keybinds - -(map! "C-'" #'imenu - - ;;; search - (:when (modulep! :completion ivy) - "C-S-s" #'swiper - "C-S-r" #'ivy-resume) - (:when (modulep! :completion helm) - "C-S-s" #'swiper-helm - "C-S-r" #'helm-resume) - (:when (modulep! :completion vertico) - "C-S-r" #'vertico-repeat) - - ;;; objed - (:when (modulep! :editor objed +manual) - "M-SPC" #'objed-activate) - - ;;; buffer management - "C-x b" #'switch-to-buffer - "C-x 4 b" #'switch-to-buffer-other-window - (:when (modulep! :ui workspaces) - "C-x b" #'persp-switch-to-buffer - "C-x B" #'switch-to-buffer - "C-x 4 B" #'switch-to-buffer-other-window - (:when (modulep! :completion ivy) - "C-x 4 b" #'+ivy/switch-workspace-buffer-other-window)) - "C-x C-b" #'ibuffer - "C-x K" #'doom/kill-this-buffer-in-all-windows - - ;;; company-mode - "C-;" #'+company/complete - (:after company - :map company-active-map - "C-o" #'company-search-kill-others - "C-n" #'company-select-next - "C-p" #'company-select-previous - "C-h" #'company-quickhelp-manual-begin - "C-S-h" #'company-show-doc-buffer - "C-s" #'company-search-candidates - "M-s" #'company-filter-candidates - [C-tab] #'company-complete-common-or-cycle - [tab] #'company-complete-common-or-cycle - [backtab] #'company-select-previous - "C-RET" (cond ((modulep! :completion vertico) #'completion-at-point) - ((modulep! :completion ivy) #'counsel-company) - ((modulep! :completion helm) #'helm-company)) - "C-<return>" (cond ((modulep! :completion vertico) #'completion-at-point) - ((modulep! :completion ivy) #'counsel-company) - ((modulep! :completion helm) #'helm-company)) - :map company-search-map - "C-n" #'company-search-repeat-forward - "C-p" #'company-search-repeat-backward - "C-s" (cmd! (company-search-abort) (company-filter-candidates))) - - ;;; ein notebooks - (:after ein:notebook-multilang - :map ein:notebook-multilang-mode-map - "C-c h" #'+ein/hydra/body) - - ;;; expand-region - "C-=" #'er/expand-region - - ;;; flycheck - (:after flycheck - :map flycheck-error-list-mode-map - "C-n" #'flycheck-error-list-next-error - "C-p" #'flycheck-error-list-previous-error - "RET" #'flycheck-error-list-goto-error) - - ;;; help and info - (:after help-mode - :map help-mode-map - "o" #'link-hint-open-link - ">" #'help-go-forward - "<" #'help-go-back - "n" #'forward-button - "p" #'backward-button) - (:after helpful - :map helpful-mode-map - "o" #'link-hint-open-link) - (:after apropos - :map apropos-mode-map - "o" #'link-hint-open-link - "n" #'forward-button - "p" #'backward-button) - (:after info - :map Info-mode-map - "o" #'link-hint-open-link) - - ;;; ivy & counsel - (:when (modulep! :completion ivy) - (:after ivy - :map ivy-minibuffer-map - "TAB" #'ivy-alt-done - "C-g" #'keyboard-escape-quit) - (:after counsel - :map counsel-ag-map - "C-SPC" #'ivy-call-and-recenter ; preview - "M-RET" #'+ivy/git-grep-other-window-action) - "C-M-y" #'counsel-yank-pop) - - ;;; neotree - (:when (modulep! :ui neotree) - "<f9>" #'+neotree/open - "<C-f9>" #'+neotree/find-this-file - (:after neotree - :map neotree-mode-map - "q" #'neotree-hide - "RET" #'neotree-enter - "SPC" #'neotree-quick-look - "v" #'neotree-enter-vertical-split - "s" #'neotree-enter-horizontal-split - "c" #'neotree-create-node - "D" #'neotree-delete-node - "g" #'neotree-refresh - "r" #'neotree-rename-node - "R" #'neotree-refresh - "h" #'+neotree/collapse-or-up - "l" #'+neotree/expand-or-open - "n" #'neotree-next-line - "p" #'neotree-previous-line - "N" #'neotree-select-next-sibling-node - "P" #'neotree-select-previous-sibling-node)) - - ;;; popups - (:when (modulep! :ui popup) - "C-x p" #'+popup/other - "C-`" #'+popup/toggle - "C-~" #'+popup/raise) - - ;;; smartparens - (:after smartparens - :map smartparens-mode-map - "C-M-a" #'sp-beginning-of-sexp - "C-M-e" #'sp-end-of-sexp - "C-M-f" #'sp-forward-sexp - "C-M-b" #'sp-backward-sexp - "C-M-n" #'sp-next-sexp - "C-M-p" #'sp-previous-sexp - "C-M-u" #'sp-up-sexp - "C-M-d" #'sp-down-sexp - "C-M-k" #'sp-kill-sexp - "C-M-t" #'sp-transpose-sexp - "C-M-<backspace>" #'sp-splice-sexp) - - ;;; treemacs - (:when (modulep! :ui treemacs) - "<f9>" #'+treemacs/toggle - "<C-f9>" #'treemacs-find-file)) - -(map! :leader - (:when (modulep! :editor fold) - (:prefix ("C-f" . "fold") - "C-d" #'vimish-fold-delete - "C-a C-d" #'vimish-fold-delete-all - "C-f" #'+fold/toggle - "C-a C-f" #'+fold/close-all - "C-u" #'+fold/open - "C-a C-u" #'+fold/open-all))) diff --git a/.config/emacs/modules/config/default/+emacs.el b/.config/emacs/modules/config/default/+emacs.el @@ -1,26 +0,0 @@ -;;; config/default/+emacs.el -*- lexical-binding: t; -*- - -(require 'projectile) ; we need its keybinds immediately - - -;; -;;; Reasonable defaults - -(setq shift-select-mode t) -(delete-selection-mode +1) - -(use-package! expand-region - :commands (er/contract-region er/mark-symbol er/mark-word) - :config - (defadvice! doom--quit-expand-region-a (&rest _) - "Properly abort an expand-region region." - :before '(evil-escape doom/escape) - (when (memq last-command '(er/expand-region er/contract-region)) - (er/contract-region 0)))) - - -;; -;;; Keybinds - -(when (modulep! +bindings) - (load! "+emacs-bindings")) diff --git a/.config/emacs/modules/config/default/+evil-bindings.el b/.config/emacs/modules/config/default/+evil-bindings.el @@ -1,772 +0,0 @@ -;;; config/default/+bindings.el -*- lexical-binding: t; -*- - -(when (modulep! :editor evil +everywhere) - ;; NOTE SPC u replaces C-u as the universal argument. - - ;; Minibuffer - (map! :map (evil-ex-completion-map evil-ex-search-keymap) - "C-a" #'evil-beginning-of-line - "C-b" #'evil-backward-char - "C-f" #'evil-forward-char - :gi "C-j" #'next-complete-history-element - :gi "C-k" #'previous-complete-history-element) - - (define-key! :keymaps +default-minibuffer-maps - [escape] #'abort-recursive-edit - "C-a" #'move-beginning-of-line - "C-r" #'evil-paste-from-register - "C-u" #'evil-delete-back-to-indentation - "C-v" #'yank - "C-w" #'doom/delete-backward-word - "C-z" (cmd! (ignore-errors (call-interactively #'undo)))) - - (define-key! :keymaps +default-minibuffer-maps - "C-j" #'next-line - "C-k" #'previous-line - "C-S-j" #'scroll-up-command - "C-S-k" #'scroll-down-command) - ;; For folks with `evil-collection-setup-minibuffer' enabled - (define-key! :states 'insert :keymaps +default-minibuffer-maps - "C-j" #'next-line - "C-k" #'previous-line) - (define-key! read-expression-map - "C-j" #'next-line-or-history-element - "C-k" #'previous-line-or-history-element)) - - -;; -;;; Global keybindings - -;; Smart tab, these will only work in GUI Emacs -(map! :i [tab] (cmds! (and (modulep! :editor snippets) - (yas-maybe-expand-abbrev-key-filter 'yas-expand)) - #'yas-expand - (and (bound-and-true-p company-mode) - (modulep! :completion company +tng)) - #'company-indent-or-complete-common) - :m [tab] (cmds! (and (modulep! :editor snippets) - (evil-visual-state-p) - (or (eq evil-visual-selection 'line) - (not (memq (char-after) (list ?\( ?\[ ?\{ ?\} ?\] ?\)))))) - #'yas-insert-snippet - (and (modulep! :editor fold) - (save-excursion (end-of-line) (invisible-p (point)))) - #'+fold/toggle - ;; Fixes #4548: without this, this tab keybind overrides - ;; mode-local ones for modes that don't have an evil - ;; keybinding scheme or users who don't have :editor (evil - ;; +everywhere) enabled. - (or (doom-lookup-key - [tab] - (list (evil-get-auxiliary-keymap (current-local-map) evil-state) - (current-local-map))) - (doom-lookup-key - (kbd "TAB") - (list (evil-get-auxiliary-keymap (current-local-map) evil-state))) - (doom-lookup-key (kbd "TAB") (list (current-local-map)))) - it - (fboundp 'evil-jump-item) - #'evil-jump-item) - - (:after help :map help-mode-map - :n "o" #'link-hint-open-link) - (:after helpful :map helpful-mode-map - :n "o" #'link-hint-open-link) - (:after info :map Info-mode-map - :n "o" #'link-hint-open-link) - (:after apropos :map apropos-mode-map - :n "o" #'link-hint-open-link - :n "TAB" #'forward-button - :n [tab] #'forward-button - :n [backtab] #'backward-button) - (:after view :map view-mode-map - [escape] #'View-quit-all) - (:after man :map Man-mode-map - :n "q" #'kill-current-buffer) - (:after geiser-doc :map geiser-doc-mode-map - :n "o" #'link-hint-open-link) - - (:unless (modulep! :input layout +bepo) - (:after (evil-org evil-easymotion) - :map evil-org-mode-map - :m "gsh" #'+org/goto-visible)) - - (:when (modulep! :editor multiple-cursors) - :prefix "gz" - :nv "d" #'evil-mc-make-and-goto-next-match - :nv "D" #'evil-mc-make-and-goto-prev-match - :nv "s" #'evil-mc-skip-and-goto-next-match - :nv "S" #'evil-mc-skip-and-goto-prev-match - :nv "c" #'evil-mc-skip-and-goto-next-cursor - :nv "C" #'evil-mc-skip-and-goto-prev-cursor - :nv "j" #'evil-mc-make-cursor-move-next-line - :nv "k" #'evil-mc-make-cursor-move-prev-line - :nv "m" #'evil-mc-make-all-cursors - :nv "n" #'evil-mc-make-and-goto-next-cursor - :nv "N" #'evil-mc-make-and-goto-last-cursor - :nv "p" #'evil-mc-make-and-goto-prev-cursor - :nv "P" #'evil-mc-make-and-goto-first-cursor - :nv "q" #'evil-mc-undo-all-cursors - :nv "t" #'+multiple-cursors/evil-mc-toggle-cursors - :nv "u" #'+multiple-cursors/evil-mc-undo-cursor - :nv "z" #'+multiple-cursors/evil-mc-toggle-cursor-here - :v "I" #'evil-mc-make-cursor-in-visual-selection-beg - :v "A" #'evil-mc-make-cursor-in-visual-selection-end) - - ;; misc - :n "C-S-f" #'toggle-frame-fullscreen - :n "C-+" #'doom/reset-font-size - ;; Buffer-local font resizing - :n "C-=" #'text-scale-increase - :n "C--" #'text-scale-decrease - ;; Frame-local font resizing - :n "M-C-=" #'doom/increase-font-size - :n "M-C--" #'doom/decrease-font-size) - - -;; -;;; Module keybinds - -;;; :completion -(map! (:when (modulep! :completion company) - :i "C-@" (cmds! (not (minibufferp)) #'company-complete-common) - :i "C-SPC" (cmds! (not (minibufferp)) #'company-complete-common) - (:after company - (:map company-active-map - "C-w" nil ; don't interfere with `evil-delete-backward-word' - "C-n" #'company-select-next - "C-p" #'company-select-previous - "C-j" #'company-select-next - "C-k" #'company-select-previous - "C-h" #'company-show-doc-buffer - "C-u" #'company-previous-page - "C-d" #'company-next-page - "C-s" #'company-filter-candidates - "C-S-s" #'+company/completing-read - "C-SPC" #'company-complete-common - "TAB" #'company-complete-common-or-cycle - [tab] #'company-complete-common-or-cycle - [backtab] #'company-select-previous - [f1] nil) - (:map company-search-map ; applies to `company-filter-map' too - "C-n" #'company-select-next-or-abort - "C-p" #'company-select-previous-or-abort - "C-j" #'company-select-next-or-abort - "C-k" #'company-select-previous-or-abort - "C-s" #'company-filter-candidates - [escape] #'company-search-abort))) - - (:when (modulep! :completion ivy) - (:after ivy - :map ivy-minibuffer-map - "C-SPC" #'ivy-call-and-recenter ; preview file - "C-l" #'ivy-alt-done - "C-v" #'yank) - (:after counsel - :map counsel-ag-map - "C-SPC" #'ivy-call-and-recenter ; preview - "C-l" #'ivy-done - [C-return] #'+ivy/git-grep-other-window-action)) - - (:when (modulep! :completion helm) - (:after helm :map helm-map - [remap next-line] #'helm-next-line - [remap previous-line] #'helm-previous-line - [left] #'left-char - [right] #'right-char - "C-S-f" #'helm-previous-page - "C-S-n" #'helm-next-source - "C-S-p" #'helm-previous-source - (:when (modulep! :editor evil +everywhere) - "C-j" #'helm-next-line - "C-k" #'helm-previous-line - "C-S-j" #'helm-next-source - "C-S-k" #'helm-previous-source) - "C-u" #'helm-delete-minibuffer-contents - "C-s" #'helm-minibuffer-history - ;; Swap TAB and C-z - "TAB" #'helm-execute-persistent-action - [tab] #'helm-execute-persistent-action - "C-z" #'helm-select-action) - (:after helm-ag :map helm-ag-map - "C--" #'+helm-do-ag-decrease-context - "C-=" #'+helm-do-ag-increase-context - [left] nil - [right] nil) - (:after helm-files :map (helm-find-files-map helm-read-file-map) - [C-return] #'helm-ff-run-switch-other-window - "C-w" #'helm-find-files-up-one-level - (:when (modulep! :editor evil +everywhere) - "C-h" #'helm-find-files-up-one-level - "C-l" #'helm-execute-persistent-action)) - (:after helm-locate :map helm-generic-files-map - [C-return] #'helm-ff-run-switch-other-window) - (:after helm-buffers :map helm-buffer-map - [C-return] #'helm-buffer-switch-other-window) - (:after helm-occur :map helm-occur-map - [C-return] #'helm-occur-run-goto-line-ow) - (:after helm-grep :map helm-grep-map - [C-return] #'helm-grep-run-other-window-action))) - - -;;; :ui -(map! (:when (modulep! :ui popup) - "C-`" #'+popup/toggle - "C-~" #'+popup/raise - "C-x p" #'+popup/other) - - (:when (modulep! :ui workspaces) - :n "C-t" #'+workspace/new - :n "C-S-t" #'+workspace/display - :g "M-1" #'+workspace/switch-to-0 - :g "M-2" #'+workspace/switch-to-1 - :g "M-3" #'+workspace/switch-to-2 - :g "M-4" #'+workspace/switch-to-3 - :g "M-5" #'+workspace/switch-to-4 - :g "M-6" #'+workspace/switch-to-5 - :g "M-7" #'+workspace/switch-to-6 - :g "M-8" #'+workspace/switch-to-7 - :g "M-9" #'+workspace/switch-to-8 - :g "M-0" #'+workspace/switch-to-final - (:when IS-MAC - :g "s-t" #'+workspace/new - :g "s-T" #'+workspace/display - :n "s-1" #'+workspace/switch-to-0 - :n "s-2" #'+workspace/switch-to-1 - :n "s-3" #'+workspace/switch-to-2 - :n "s-4" #'+workspace/switch-to-3 - :n "s-5" #'+workspace/switch-to-4 - :n "s-6" #'+workspace/switch-to-5 - :n "s-7" #'+workspace/switch-to-6 - :n "s-8" #'+workspace/switch-to-7 - :n "s-9" #'+workspace/switch-to-8 - :n "s-0" #'+workspace/switch-to-final))) - -;;; :editor -(map! (:when (modulep! :editor format) - :n "gQ" #'+format:region) - - (:when (modulep! :editor rotate-text) - :n "]r" #'rotate-text - :n "[r" #'rotate-text-backward) - - (:when (modulep! :editor multiple-cursors) - ;; evil-multiedit - :v "R" #'evil-multiedit-match-all - :n "M-d" #'evil-multiedit-match-symbol-and-next - :n "M-D" #'evil-multiedit-match-symbol-and-prev - :v "M-d" #'evil-multiedit-match-and-next - :v "M-D" #'evil-multiedit-match-and-prev - :nv "C-M-d" #'evil-multiedit-restore - (:after evil-multiedit - (:map evil-multiedit-mode-map - :nv "M-d" #'evil-multiedit-match-and-next - :nv "M-D" #'evil-multiedit-match-and-prev - [return] #'evil-multiedit-toggle-or-restrict-region))) - - (:when (modulep! :editor snippets) - ;; auto-yasnippet - :i [C-tab] #'aya-expand - :nv [C-tab] #'aya-create)) - -;;; :tools -(when (modulep! :tools eval) - (map! "M-r" #'+eval/buffer)) - - -;; -;;; <leader> - -(map! :leader - :desc "Eval expression" ";" #'pp-eval-expression - :desc "M-x" ":" #'execute-extended-command - :desc "Pop up scratch buffer" "x" #'doom/open-scratch-buffer - :desc "Org Capture" "X" #'org-capture - ;; C-u is used by evil - :desc "Universal argument" "u" #'universal-argument - :desc "window" "w" evil-window-map - :desc "help" "h" help-map - - (:when (modulep! :ui popup) - :desc "Toggle last popup" "~" #'+popup/toggle) - :desc "Find file" "." #'find-file - :desc "Switch buffer" "," #'switch-to-buffer - (:when (modulep! :ui workspaces) - :desc "Switch workspace buffer" "," #'persp-switch-to-buffer - :desc "Switch buffer" "<" #'switch-to-buffer) - :desc "Switch to last buffer" "`" #'evil-switch-to-windows-last-buffer - :desc "Resume last search" "'" - (cond ((modulep! :completion vertico) #'vertico-repeat) - ((modulep! :completion ivy) #'ivy-resume) - ((modulep! :completion helm) #'helm-resume)) - - :desc "Search for symbol in project" "*" #'+default/search-project-for-symbol-at-point - :desc "Search project" "/" #'+default/search-project - - :desc "Find file in project" "SPC" #'projectile-find-file - :desc "Jump to bookmark" "RET" #'bookmark-jump - - ;;; <leader> TAB --- workspace - (:when (modulep! :ui workspaces) - (:prefix-map ("TAB" . "workspace") - :desc "Display tab bar" "TAB" #'+workspace/display - :desc "Switch workspace" "." #'+workspace/switch-to - :desc "Switch to last workspace" "`" #'+workspace/other - :desc "New workspace" "n" #'+workspace/new - :desc "New named workspace" "N" #'+workspace/new-named - :desc "Load workspace from file" "l" #'+workspace/load - :desc "Save workspace to file" "s" #'+workspace/save - :desc "Delete session" "x" #'+workspace/kill-session - :desc "Delete this workspace" "d" #'+workspace/delete - :desc "Rename workspace" "r" #'+workspace/rename - :desc "Restore last session" "R" #'+workspace/restore-last-session - :desc "Next workspace" "]" #'+workspace/switch-right - :desc "Previous workspace" "[" #'+workspace/switch-left - :desc "Switch to 1st workspace" "1" #'+workspace/switch-to-0 - :desc "Switch to 2nd workspace" "2" #'+workspace/switch-to-1 - :desc "Switch to 3rd workspace" "3" #'+workspace/switch-to-2 - :desc "Switch to 4th workspace" "4" #'+workspace/switch-to-3 - :desc "Switch to 5th workspace" "5" #'+workspace/switch-to-4 - :desc "Switch to 6th workspace" "6" #'+workspace/switch-to-5 - :desc "Switch to 7th workspace" "7" #'+workspace/switch-to-6 - :desc "Switch to 8th workspace" "8" #'+workspace/switch-to-7 - :desc "Switch to 9th workspace" "9" #'+workspace/switch-to-8 - :desc "Switch to final workspace" "0" #'+workspace/switch-to-final)) - - ;;; <leader> b --- buffer - (:prefix-map ("b" . "buffer") - :desc "Toggle narrowing" "-" #'doom/toggle-narrow-buffer - :desc "Previous buffer" "[" #'previous-buffer - :desc "Next buffer" "]" #'next-buffer - (:when (modulep! :ui workspaces) - :desc "Switch workspace buffer" "b" #'persp-switch-to-buffer - :desc "Switch buffer" "B" #'switch-to-buffer - :desc "ibuffer workspace" "I" #'+ibuffer/open-for-current-workspace) - (:unless (modulep! :ui workspaces) - :desc "Switch buffer" "b" #'switch-to-buffer) - :desc "Clone buffer" "c" #'clone-indirect-buffer - :desc "Clone buffer other window" "C" #'clone-indirect-buffer-other-window - :desc "Kill buffer" "d" #'kill-current-buffer - :desc "ibuffer" "i" #'ibuffer - :desc "Kill buffer" "k" #'kill-current-buffer - :desc "Kill all buffers" "K" #'doom/kill-all-buffers - :desc "Switch to last buffer" "l" #'evil-switch-to-windows-last-buffer - :desc "Set bookmark" "m" #'bookmark-set - :desc "Delete bookmark" "M" #'bookmark-delete - :desc "Next buffer" "n" #'next-buffer - :desc "New empty buffer" "N" #'evil-buffer-new - :desc "Kill other buffers" "O" #'doom/kill-other-buffers - :desc "Previous buffer" "p" #'previous-buffer - :desc "Revert buffer" "r" #'revert-buffer - :desc "Rename buffer" "R" #'rename-buffer - :desc "Save buffer" "s" #'basic-save-buffer - :desc "Save all buffers" "S" #'evil-write-all - :desc "Save buffer as root" "u" #'doom/sudo-save-buffer - :desc "Pop up scratch buffer" "x" #'doom/open-scratch-buffer - :desc "Switch to scratch buffer" "X" #'doom/switch-to-scratch-buffer - :desc "Yank buffer" "y" #'+default/yank-buffer-contents - :desc "Bury buffer" "z" #'bury-buffer - :desc "Kill buried buffers" "Z" #'doom/kill-buried-buffers) - - ;;; <leader> c --- code - (:prefix-map ("c" . "code") - (:when (and (modulep! :tools lsp) (not (modulep! :tools lsp +eglot))) - :desc "LSP Execute code action" "a" #'lsp-execute-code-action - :desc "LSP Organize imports" "o" #'lsp-organize-imports - (:when (modulep! :completion ivy) - :desc "Jump to symbol in current workspace" "j" #'lsp-ivy-workspace-symbol - :desc "Jump to symbol in any workspace" "J" #'lsp-ivy-global-workspace-symbol) - (:when (modulep! :completion helm) - :desc "Jump to symbol in current workspace" "j" #'helm-lsp-workspace-symbol - :desc "Jump to symbol in any workspace" "J" #'helm-lsp-global-workspace-symbol) - (:when (modulep! :completion vertico) - :desc "Jump to symbol in current workspace" "j" #'consult-lsp-symbols - :desc "Jump to symbol in any workspace" "J" (cmd!! #'consult-lsp-symbols 'all-workspaces)) - (:when (modulep! :ui treemacs +lsp) - :desc "Errors list" "X" #'lsp-treemacs-errors-list - :desc "Incoming call hierarchy" "y" #'lsp-treemacs-call-hierarchy - :desc "Outgoing call hierarchy" "Y" (cmd!! #'lsp-treemacs-call-hierarchy t) - :desc "References tree" "R" (cmd!! #'lsp-treemacs-references t) - :desc "Symbols" "S" #'lsp-treemacs-symbols) - :desc "LSP" "l" #'+default/lsp-command-map - :desc "LSP Rename" "r" #'lsp-rename) - (:when (modulep! :tools lsp +eglot) - :desc "LSP Execute code action" "a" #'eglot-code-actions - :desc "LSP Rename" "r" #'eglot-rename - :desc "LSP Find declaration" "j" #'eglot-find-declaration - (:when (modulep! :completion vertico) - :desc "Jump to symbol in current workspace" "j" #'consult-eglot-symbols)) - :desc "Compile" "c" #'compile - :desc "Recompile" "C" #'recompile - :desc "Jump to definition" "d" #'+lookup/definition - :desc "Jump to references" "D" #'+lookup/references - :desc "Evaluate buffer/region" "e" #'+eval/buffer-or-region - :desc "Evaluate & replace region" "E" #'+eval:replace-region - :desc "Format buffer/region" "f" #'+format/region-or-buffer - :desc "Find implementations" "i" #'+lookup/implementations - :desc "Jump to documentation" "k" #'+lookup/documentation - :desc "Send to repl" "s" #'+eval/send-region-to-repl - :desc "Find type definition" "t" #'+lookup/type-definition - :desc "Delete trailing whitespace" "w" #'delete-trailing-whitespace - :desc "Delete trailing newlines" "W" #'doom/delete-trailing-newlines - :desc "List errors" "x" #'+default/diagnostics) - - ;;; <leader> f --- file - (:prefix-map ("f" . "file") - :desc "Open project editorconfig" "c" #'editorconfig-find-current-editorconfig - :desc "Copy this file" "C" #'doom/copy-this-file - :desc "Find directory" "d" #'+default/dired - :desc "Delete this file" "D" #'doom/delete-this-file - :desc "Find file in emacs.d" "e" #'doom/find-file-in-emacsd - :desc "Browse emacs.d" "E" #'doom/browse-in-emacsd - :desc "Find file" "f" #'find-file - :desc "Find file from here" "F" #'+default/find-file-under-here - :desc "Locate file" "l" #'locate - :desc "Find file in private config" "p" #'doom/find-file-in-private-config - :desc "Browse private config" "P" #'doom/open-private-config - :desc "Recent files" "r" #'recentf-open-files - :desc "Rename/move file" "R" #'doom/move-this-file - :desc "Save file" "s" #'save-buffer - :desc "Save file as..." "S" #'write-file - :desc "Sudo find file" "u" #'doom/sudo-find-file - :desc "Sudo this file" "U" #'doom/sudo-this-file - :desc "Yank file path" "y" #'+default/yank-buffer-path - :desc "Yank file path from project" "Y" #'+default/yank-buffer-path-relative-to-project) - - ;;; <leader> g --- git/version control - (:prefix-map ("g" . "git") - :desc "Revert file" "R" #'vc-revert - :desc "Copy link to remote" "y" #'+vc/browse-at-remote-kill - :desc "Copy link to homepage" "Y" #'+vc/browse-at-remote-kill-homepage - (:when (modulep! :ui hydra) - :desc "SMerge" "m" #'+vc/smerge-hydra/body) - (:when (modulep! :ui vc-gutter) - (:when (modulep! :ui hydra) - :desc "VCGutter" "." #'+vc/gutter-hydra/body) - :desc "Revert hunk at point" "r" #'+vc-gutter/revert-hunk - :desc "stage hunk at point" "s" #'+vc-gutter/stage-hunk - :desc "Git time machine" "t" #'git-timemachine-toggle - :desc "Jump to next hunk" "]" #'+vc-gutter/next-hunk - :desc "Jump to previous hunk" "[" #'+vc-gutter/previous-hunk) - (:when (modulep! :tools magit) - :desc "Magit dispatch" "/" #'magit-dispatch - :desc "Magit file dispatch" "." #'magit-file-dispatch - :desc "Forge dispatch" "'" #'forge-dispatch - :desc "Magit switch branch" "b" #'magit-branch-checkout - :desc "Magit status" "g" #'magit-status - :desc "Magit status here" "G" #'magit-status-here - :desc "Magit file delete" "D" #'magit-file-delete - :desc "Magit blame" "B" #'magit-blame-addition - :desc "Magit clone" "C" #'magit-clone - :desc "Magit fetch" "F" #'magit-fetch - :desc "Magit buffer log" "L" #'magit-log-buffer-file - :desc "Git stage file" "S" #'magit-stage-file - :desc "Git unstage file" "U" #'magit-unstage-file - (:prefix ("f" . "find") - :desc "Find file" "f" #'magit-find-file - :desc "Find gitconfig file" "g" #'magit-find-git-config-file - :desc "Find commit" "c" #'magit-show-commit - :desc "Find issue" "i" #'forge-visit-issue - :desc "Find pull request" "p" #'forge-visit-pullreq) - (:prefix ("o" . "open in browser") - :desc "Browse file or region" "o" #'+vc/browse-at-remote - :desc "Browse homepage" "h" #'+vc/browse-at-remote-homepage - :desc "Browse remote" "r" #'forge-browse-remote - :desc "Browse commit" "c" #'forge-browse-commit - :desc "Browse an issue" "i" #'forge-browse-issue - :desc "Browse a pull request" "p" #'forge-browse-pullreq - :desc "Browse issues" "I" #'forge-browse-issues - :desc "Browse pull requests" "P" #'forge-browse-pullreqs) - (:prefix ("l" . "list") - (:when (modulep! :tools gist) - :desc "List gists" "g" #'+gist:list) - :desc "List repositories" "r" #'magit-list-repositories - :desc "List submodules" "s" #'magit-list-submodules - :desc "List issues" "i" #'forge-list-issues - :desc "List pull requests" "p" #'forge-list-pullreqs - :desc "List notifications" "n" #'forge-list-notifications) - (:prefix ("c" . "create") - :desc "Initialize repo" "r" #'magit-init - :desc "Clone repo" "R" #'magit-clone - :desc "Commit" "c" #'magit-commit-create - :desc "Fixup" "f" #'magit-commit-fixup - :desc "Branch" "b" #'magit-branch-and-checkout - :desc "Issue" "i" #'forge-create-issue - :desc "Pull request" "p" #'forge-create-pullreq))) - - ;;; <leader> i --- insert - (:prefix-map ("i" . "insert") - :desc "Emoji" "e" #'emojify-insert-emoji - :desc "Current file name" "f" #'+default/insert-file-path - :desc "Current file path" "F" (cmd!! #'+default/insert-file-path t) - :desc "Evil ex path" "p" (cmd! (evil-ex "R!echo ")) - :desc "From evil register" "r" #'evil-show-registers - :desc "Snippet" "s" #'yas-insert-snippet - :desc "Unicode" "u" #'insert-char - :desc "From clipboard" "y" #'+default/yank-pop) - - ;;; <leader> n --- notes - (:prefix-map ("n" . "notes") - :desc "Search notes for symbol" "*" #'+default/search-notes-for-symbol-at-point - :desc "Org agenda" "a" #'org-agenda - (:when (modulep! :tools biblio) - :desc "Bibliographic notes" "b" - (cond ((modulep! :completion vertico) #'citar-open-notes) - ((modulep! :completion ivy) #'ivy-bibtex) - ((modulep! :completion helm) #'helm-bibtex))) - - :desc "Toggle last org-clock" "c" #'+org/toggle-last-clock - :desc "Cancel current org-clock" "C" #'org-clock-cancel - :desc "Open deft" "d" #'deft - (:when (modulep! :lang org +noter) - :desc "Org noter" "e" #'org-noter) - - :desc "Find file in notes" "f" #'+default/find-in-notes - :desc "Browse notes" "F" #'+default/browse-notes - :desc "Org store link" "l" #'org-store-link - :desc "Tags search" "m" #'org-tags-view - :desc "Org capture" "n" #'org-capture - :desc "Goto capture" "N" #'org-capture-goto-target - :desc "Active org-clock" "o" #'org-clock-goto - :desc "Todo list" "t" #'org-todo-list - :desc "Search notes" "s" #'+default/org-notes-search - :desc "Search org agenda headlines" "S" #'+default/org-notes-headlines - :desc "View search" "v" #'org-search-view - :desc "Org export to clipboard" "y" #'+org/export-to-clipboard - :desc "Org export to clipboard as RTF" "Y" #'+org/export-to-clipboard-as-rich-text - - (:when (modulep! :lang org +roam) - (:prefix ("r" . "roam") - :desc "Switch to buffer" "b" #'org-roam-switch-to-buffer - :desc "Org Roam Capture" "c" #'org-roam-capture - :desc "Find file" "f" #'org-roam-find-file - :desc "Show graph" "g" #'org-roam-graph - :desc "Insert" "i" #'org-roam-insert - :desc "Insert (skipping org-capture)" "I" #'org-roam-insert-immediate - :desc "Org Roam" "r" #'org-roam - (:prefix ("d" . "by date") - :desc "Arbitrary date" "d" #'org-roam-dailies-find-date - :desc "Today" "t" #'org-roam-dailies-find-today - :desc "Tomorrow" "m" #'org-roam-dailies-find-tomorrow - :desc "Yesterday" "y" #'org-roam-dailies-find-yesterday))) - - (:when (modulep! :lang org +roam2) - (:prefix ("r" . "roam") - :desc "Open random node" "a" #'org-roam-node-random - :desc "Find node" "f" #'org-roam-node-find - :desc "Find ref" "F" #'org-roam-ref-find - :desc "Show graph" "g" #'org-roam-graph - :desc "Insert node" "i" #'org-roam-node-insert - :desc "Capture to node" "n" #'org-roam-capture - :desc "Toggle roam buffer" "r" #'org-roam-buffer-toggle - :desc "Launch roam buffer" "R" #'org-roam-buffer-display-dedicated - :desc "Sync database" "s" #'org-roam-db-sync - (:prefix ("d" . "by date") - :desc "Goto previous note" "b" #'org-roam-dailies-goto-previous-note - :desc "Goto date" "d" #'org-roam-dailies-goto-date - :desc "Capture date" "D" #'org-roam-dailies-capture-date - :desc "Goto next note" "f" #'org-roam-dailies-goto-next-note - :desc "Goto tomorrow" "m" #'org-roam-dailies-goto-tomorrow - :desc "Capture tomorrow" "M" #'org-roam-dailies-capture-tomorrow - :desc "Capture today" "n" #'org-roam-dailies-capture-today - :desc "Goto today" "t" #'org-roam-dailies-goto-today - :desc "Capture today" "T" #'org-roam-dailies-capture-today - :desc "Goto yesterday" "y" #'org-roam-dailies-goto-yesterday - :desc "Capture yesterday" "Y" #'org-roam-dailies-capture-yesterday - :desc "Find directory" "-" #'org-roam-dailies-find-directory))) - - (:when (modulep! :lang org +journal) - (:prefix ("j" . "journal") - :desc "New Entry" "j" #'org-journal-new-entry - :desc "New Scheduled Entry" "J" #'org-journal-new-scheduled-entry - :desc "Search Forever" "s" #'org-journal-search-forever))) - - ;;; <leader> o --- open - (:prefix-map ("o" . "open") - :desc "Org agenda" "A" #'org-agenda - (:prefix ("a" . "org agenda") - :desc "Agenda" "a" #'org-agenda - :desc "Todo list" "t" #'org-todo-list - :desc "Tags search" "m" #'org-tags-view - :desc "View search" "v" #'org-search-view) - :desc "Default browser" "b" #'browse-url-of-file - :desc "Start debugger" "d" #'+debugger/start - :desc "New frame" "f" #'make-frame - :desc "Select frame" "F" #'select-frame-by-name - :desc "REPL" "r" #'+eval/open-repl-other-window - :desc "REPL (same window)" "R" #'+eval/open-repl-same-window - :desc "Dired" "-" #'dired-jump - (:when (modulep! :ui neotree) - :desc "Project sidebar" "p" #'+neotree/open - :desc "Find file in project sidebar" "P" #'+neotree/find-this-file) - (:when (modulep! :ui treemacs) - :desc "Project sidebar" "p" #'+treemacs/toggle - :desc "Find file in project sidebar" "P" #'treemacs-find-file) - (:when (modulep! :term shell) - :desc "Toggle shell popup" "t" #'+shell/toggle - :desc "Open shell here" "T" #'+shell/here) - (:when (modulep! :term term) - :desc "Toggle terminal popup" "t" #'+term/toggle - :desc "Open terminal here" "T" #'+term/here) - (:when (modulep! :term vterm) - :desc "Toggle vterm popup" "t" #'+vterm/toggle - :desc "Open vterm here" "T" #'+vterm/here) - (:when (modulep! :term eshell) - :desc "Toggle eshell popup" "e" #'+eshell/toggle - :desc "Open eshell here" "E" #'+eshell/here) - (:when (modulep! :os macos) - :desc "Reveal in Finder" "o" #'+macos/reveal-in-finder - :desc "Reveal project in Finder" "O" #'+macos/reveal-project-in-finder - :desc "Send to Transmit" "u" #'+macos/send-to-transmit - :desc "Send project to Transmit" "U" #'+macos/send-project-to-transmit - :desc "Send to Launchbar" "l" #'+macos/send-to-launchbar - :desc "Send project to Launchbar" "L" #'+macos/send-project-to-launchbar - :desc "Open in iTerm" "i" #'+macos/open-in-iterm - :desc "Open in new iTerm window" "I" #'+macos/open-in-iterm-new-window) - (:when (modulep! :tools docker) - :desc "Docker" "D" #'docker) - (:when (modulep! :email mu4e) - :desc "mu4e" "m" #'=mu4e) - (:when (modulep! :email notmuch) - :desc "notmuch" "m" #'=notmuch) - (:when (modulep! :email wanderlust) - :desc "wanderlust" "m" #'=wanderlust)) - - ;;; <leader> p --- project - (:prefix-map ("p" . "project") - :desc "Browse project" "." #'+default/browse-project - :desc "Browse other project" ">" #'doom/browse-in-other-project - :desc "Run cmd in project root" "!" #'projectile-run-shell-command-in-root - :desc "Async cmd in project root" "&" #'projectile-run-async-shell-command-in-root - :desc "Add new project" "a" #'projectile-add-known-project - :desc "Switch to project buffer" "b" #'projectile-switch-to-buffer - :desc "Compile in project" "c" #'projectile-compile-project - :desc "Repeat last command" "C" #'projectile-repeat-last-command - :desc "Remove known project" "d" #'projectile-remove-known-project - :desc "Discover projects in folder" "D" #'+default/discover-projects - :desc "Edit project .dir-locals" "e" #'projectile-edit-dir-locals - :desc "Find file in project" "f" #'projectile-find-file - :desc "Find file in other project" "F" #'doom/find-file-in-other-project - :desc "Configure project" "g" #'projectile-configure-project - :desc "Invalidate project cache" "i" #'projectile-invalidate-cache - :desc "Kill project buffers" "k" #'projectile-kill-buffers - :desc "Find other file" "o" #'projectile-find-other-file - :desc "Switch project" "p" #'projectile-switch-project - :desc "Find recent project files" "r" #'projectile-recentf - :desc "Run project" "R" #'projectile-run-project - :desc "Save project files" "s" #'projectile-save-project-buffers - :desc "List project todos" "t" #'magit-todos-list - :desc "Test project" "T" #'projectile-test-project - :desc "Pop up scratch buffer" "x" #'doom/open-project-scratch-buffer - :desc "Switch to scratch buffer" "X" #'doom/switch-to-project-scratch-buffer - (:when (and (modulep! :tools taskrunner) - (or (modulep! :completion ivy) - (modulep! :completion helm))) - :desc "List project tasks" "z" #'+taskrunner/project-tasks)) - - ;;; <leader> q --- quit/session - (:prefix-map ("q" . "quit/session") - :desc "Restart emacs server" "d" #'+default/restart-server - :desc "Delete frame" "f" #'delete-frame - :desc "Clear current frame" "F" #'doom/kill-all-buffers - :desc "Kill Emacs (and daemon)" "K" #'save-buffers-kill-emacs - :desc "Quit Emacs" "q" #'save-buffers-kill-terminal - :desc "Quit Emacs without saving" "Q" #'evil-quit-all-with-error-code - :desc "Quick save current session" "s" #'doom/quicksave-session - :desc "Restore last session" "l" #'doom/quickload-session - :desc "Save session to file" "S" #'doom/save-session - :desc "Restore session from file" "L" #'doom/load-session - :desc "Restart & restore Emacs" "r" #'doom/restart-and-restore - :desc "Restart Emacs" "R" #'doom/restart) - - ;;; <leader> r --- remote - (:when (modulep! :tools upload) - (:prefix-map ("r" . "remote") - :desc "Browse remote" "b" #'ssh-deploy-browse-remote-base-handler - :desc "Browse relative" "B" #'ssh-deploy-browse-remote-handler - :desc "Download remote" "d" #'ssh-deploy-download-handler - :desc "Delete local & remote" "D" #'ssh-deploy-delete-handler - :desc "Eshell base terminal" "e" #'ssh-deploy-remote-terminal-eshell-base-handler - :desc "Eshell relative terminal" "E" #'ssh-deploy-remote-terminal-eshell-handler - :desc "Move/rename local & remote" "m" #'ssh-deploy-rename-handler - :desc "Open this file on remote" "o" #'ssh-deploy-open-remote-file-handler - :desc "Run deploy script" "s" #'ssh-deploy-run-deploy-script-handler - :desc "Upload local" "u" #'ssh-deploy-upload-handler - :desc "Upload local (force)" "U" #'ssh-deploy-upload-handler-forced - :desc "Diff local & remote" "x" #'ssh-deploy-diff-handler - :desc "Browse remote files" "." #'ssh-deploy-browse-remote-handler - :desc "Detect remote changes" ">" #'ssh-deploy-remote-changes-handler)) - - ;;; <leader> s --- search - (:prefix-map ("s" . "search") - :desc "Search buffer" "b" - (cond ((modulep! :completion vertico) #'+default/search-buffer) - ((modulep! :completion ivy) #'swiper) - ((modulep! :completion helm) #'swiper)) - :desc "Search all open buffers" "B" - (cond ((modulep! :completion vertico) (cmd!! #'consult-line-multi 'all-buffers)) - ((modulep! :completion ivy) #'swiper-all) - ((modulep! :completion helm) #'swiper-all)) - :desc "Search current directory" "d" #'+default/search-cwd - :desc "Search other directory" "D" #'+default/search-other-cwd - :desc "Search .emacs.d" "e" #'+default/search-emacsd - :desc "Locate file" "f" #'locate - :desc "Jump to symbol" "i" #'imenu - :desc "Jump to visible link" "l" #'link-hint-open-link - :desc "Jump to link" "L" #'ffap-menu - :desc "Jump list" "j" #'evil-show-jumps - :desc "Jump to bookmark" "m" #'bookmark-jump - :desc "Look up online" "o" #'+lookup/online - :desc "Look up online (w/ prompt)" "O" #'+lookup/online-select - :desc "Look up in local docsets" "k" #'+lookup/in-docsets - :desc "Look up in all docsets" "K" #'+lookup/in-all-docsets - :desc "Search project" "p" #'+default/search-project - :desc "Search other project" "P" #'+default/search-other-project - :desc "Jump to mark" "r" #'evil-show-marks - :desc "Search buffer" "s" #'+default/search-buffer - :desc "Search buffer for thing at point" "S" - (cond ((modulep! :completion vertico) #'+vertico/search-symbol-at-point) - ((modulep! :completion ivy) #'swiper-isearch-thing-at-point) - ((modulep! :completion helm) #'swiper-isearch-thing-at-point)) - :desc "Dictionary" "t" #'+lookup/dictionary-definition - :desc "Thesaurus" "T" #'+lookup/synonyms - (:when (fboundp 'vundo) - :desc "Undo history" "u" #'vundo)) - - ;;; <leader> t --- toggle - (:prefix-map ("t" . "toggle") - :desc "Big mode" "b" #'doom-big-font-mode - :desc "Fill Column Indicator" "c" #'global-display-fill-column-indicator-mode - :desc "Flymake" "f" #'flymake-mode - (:when (modulep! :checkers syntax) - :desc "Flycheck" "f" #'flycheck-mode) - :desc "Frame fullscreen" "F" #'toggle-frame-fullscreen - :desc "Evil goggles" "g" #'evil-goggles-mode - (:when (modulep! :ui indent-guides) - :desc "Indent guides" "i" #'highlight-indent-guides-mode) - :desc "Indent style" "I" #'doom/toggle-indent-style - :desc "Line numbers" "l" #'doom/toggle-line-numbers - (:when (modulep! :ui minimap) - :desc "Minimap" "m" #'minimap-mode) - (:when (modulep! :lang org +present) - :desc "org-tree-slide mode" "p" #'org-tree-slide-mode) - :desc "Read-only mode" "r" #'read-only-mode - (:when (and (modulep! :checkers spell) (not (modulep! :checkers spell +flyspell))) - :desc "Spell checker" "s" #'spell-fu-mode) - (:when (modulep! :checkers spell +flyspell) - :desc "Spell checker" "s" #'flyspell-mode) - (:when (modulep! :lang org +pomodoro) - :desc "Pomodoro timer" "t" #'org-pomodoro) - :desc "Visible mode" "v" #'visible-mode - :desc "Soft line wrapping" "w" #'visual-line-mode - (:when (modulep! :editor word-wrap) - :desc "Soft line wrapping" "w" #'+word-wrap-mode) - (:when (modulep! :ui zen) - :desc "Zen mode" "z" #'+zen/toggle - :desc "Zen mode (fullscreen)" "Z" #'+zen/toggle-fullscreen))) - -(after! which-key - (let ((prefix-re (regexp-opt (list doom-leader-key doom-leader-alt-key)))) - (cl-pushnew `((,(format "\\`\\(?:C-w\\|%s w\\) m\\'" prefix-re)) - nil . "maximize") - which-key-replacement-alist))) diff --git a/.config/emacs/modules/config/default/+evil.el b/.config/emacs/modules/config/default/+evil.el @@ -1,21 +0,0 @@ -;;; config/default/+evil.el -*- lexical-binding: t; -*- - -(defun +default-disable-delete-selection-mode-h () - (delete-selection-mode -1)) -(add-hook 'evil-insert-state-entry-hook #'delete-selection-mode) -(add-hook 'evil-insert-state-exit-hook #'+default-disable-delete-selection-mode-h) - - -;; -;;; Keybindings - -;; This section is dedicated to "fixing" certain keys so that they behave -;; sensibly (and consistently with similar contexts). - -;; Make SPC u SPC u [...] possible (#747) -(map! :map universal-argument-map - :prefix doom-leader-key "u" #'universal-argument-more - :prefix doom-leader-alt-key "u" #'universal-argument-more) - -(when (modulep! +bindings) - (load! "+evil-bindings")) diff --git a/.config/emacs/modules/config/default/README.org b/.config/emacs/modules/config/default/README.org @@ -1,71 +0,0 @@ -#+title: :config default -#+subtitle: Reasonable defaults for reasonable people -#+created: February 14, 2018 -#+since: 2.0.9 - -* Description :unfold: -This module provides a set of reasonable defaults, including: - -- A Spacemacs-inspired keybinding scheme -- A configuration for (almost) universally repeating searches with [[kbd:][;]] and [[kbd:][,]] -- A [[doom-package:smartparens]] configuration for smart completion of certain delimiters, like - ~/* */~ command blocks in C-languages, ~<?php ?>~ tags in PHP, or ~def end~ in - Ruby/Crystal/etc. - -** Maintainers -- [[doom-user:][@hlissner]] -- [[doom-user:][@UndeadKernel]] (for vanilla keybinds) - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +bindings :: ... -- +smartparens :: ... - -** Packages -- [[doom-package:avy]] -- [[doom-package:drag-stuff]] -- [[doom-package:link-hint]] -- [[doom-package:expand-region]] unless [[doom-module::editor evil]] - -** Hacks -- ~epa-pinentry-mode~ is set to ~'loopback~, forcing gpg-agent to use the Emacs - minibuffer when prompting for your passphrase. *Only works with GPG 2.1+!* - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 /This module's appendix is incomplete./ [[doom-contrib-module:][Write more?]] -#+end_quote - -** Commands -- ~+default/browse-project~ -- ~+default/browse-templates~ -- ~+default/find-in-templates~ -- ~+default/browse-notes~ -- ~+default/find-in-notes~ -- ~+default/find-in-snippets~ diff --git a/.config/emacs/modules/config/default/autoload/default.el b/.config/emacs/modules/config/default/autoload/default.el @@ -1,72 +0,0 @@ -;; config/default/autoload/default.el -*- lexical-binding: t; -*- - -;;;###autoload -(defun +default/compile (arg) - "Runs `compile' from the root of the current project. - -If a compilation window is already open, recompile that instead. - -If ARG (universal argument), runs `compile' from the current directory." - (interactive "P") - (if (and (bound-and-true-p compilation-in-progress) - (buffer-live-p compilation-last-buffer)) - (recompile) - (call-interactively - (if arg - #'projectile-compile-project - #'compile)))) - -;;;###autoload -(defun +default/man-or-woman () - "Invoke `man' if man is installed and the platform is not MacOS, otherwise use `woman'. - -`man -k \"^\"` is very slow on MacOS, which is what `Man-completion-table' uses to -generate `completing-read' candidates." - (interactive) - (call-interactively - (if (and (not IS-MAC) (executable-find "man")) - #'man - #'woman))) - -;;;###autoload -(defun +default/new-buffer () - "TODO" - (interactive) - (if (modulep! 'evil) - (call-interactively #'evil-buffer-new) - (let ((buffer (generate-new-buffer "*new*"))) - (set-window-buffer nil buffer) - (with-current-buffer buffer - (funcall (default-value 'major-mode)))))) - -;;;###autoload -(defun +default/restart-server () - "Restart the Emacs server." - (interactive) - (server-force-delete) - (while (server-running-p) - (sleep-for 1)) - (server-start)) - -;;;###autoload -(defun +default/diagnostics (&rest arg) - "List diagnostics for the current buffer/project. -If the the vertico and lsp modules are active, list lsp diagnostics for the -current project. Otherwise list them for the current buffer" - (interactive) - (cond ((and (modulep! :completion vertico) - (modulep! :tools lsp) - (bound-and-true-p lsp-mode)) - (consult-lsp-diagnostics arg)) - ((and (modulep! :checkers syntax) - (bound-and-true-p flycheck-mode)) - (if (modulep! :completion vertico) - (consult-flycheck) - (flycheck-list-errors))) - ((bound-and-true-p flymake-mode) - (if (modulep! :completion vertico) - (consult-flymake) - (flymake-show-diagnostics-buffer))) - (t - (user-error "No diagnostics backend detected. Enable flycheck or \ -flymake, or set up lsp-mode if applicable (see :lang lsp)")))) diff --git a/.config/emacs/modules/config/default/autoload/deferred.el b/.config/emacs/modules/config/default/autoload/deferred.el @@ -1,20 +0,0 @@ -;;; config/default/autoload/deferred.el -*- lexical-binding: t; -*- - -;; TODO generalize this -;;;###autoload -(defun +default/lsp-command-map () - "Lazily invoke `lsp-command-map'." - (interactive) - (require 'lsp-mode) - (map! :leader "c l" lsp-command-map) - (dolist (leader-key (list doom-leader-key doom-leader-alt-key)) - (let ((lsp-keymap-prefix (concat leader-key " c l"))) - (lsp-enable-which-key-integration))) - (setq prefix-arg current-prefix-arg - unread-command-events - (mapcar (lambda (e) (cons t e)) - (vconcat (when (bound-and-true-p evil-this-operator) - (where-is-internal evil-this-operator - evil-normal-state-map - t)) - (this-command-keys))))) diff --git a/.config/emacs/modules/config/default/autoload/files.el b/.config/emacs/modules/config/default/autoload/files.el @@ -1,67 +0,0 @@ -;;; config/default/autoload/files.el -*- lexical-binding: t; -*- - -;;;###autoload -(defun +default/browse-project () - "Browse files from the current project's root." - (interactive) - (doom-project-browse (or (doom-project-root) default-directory))) -;; NOTE No need for find-in-project, use `projectile-find-file' - -;;;###autoload -(defun +default/browse-templates () - "Browse files from `+file-templates-dir'." - (interactive) (doom-project-browse +file-templates-dir)) -;;;###autoload -(defun +default/find-in-templates () - "Find a file under `+file-templates-dir', recursively." - (interactive) (doom-project-find-file +file-templates-dir)) - -;;;###autoload -(defun +default/browse-notes () - "Browse files from `org-directory'." - (interactive) - (unless (bound-and-true-p org-directory) - (require 'org)) - (doom-project-browse org-directory)) -;;;###autoload -(defun +default/find-in-notes () - "Find a file under `org-directory', recursively." - (interactive) - (unless (bound-and-true-p org-directory) - (require 'org)) - (doom-project-find-file org-directory)) - -;;;###autoload -(defun +default/find-file-under-here () - "Perform a recursive file search from the current directory." - (interactive) - (doom-project-find-file default-directory)) - -;;;###autoload -(defun +default/discover-projects (arg) - "Discover projects in `projectile-project-search-path'. -If prefix ARG is non-nil, prompt for the search path." - (interactive "P") - (if arg - (call-interactively #'projectile-discover-projects-in-directory) - (if (not projectile-project-search-path) - (user-error "`projectile-project-search-path' is empty; don't know where to search") - (letf! (defun projectile-add-known-project (project-root) - (unless (projectile-ignored-project-p project-root) - (funcall projectile-add-known-project project-root) - (message "Added %S to known project roots" project-root))) - (dolist (dir projectile-project-search-path) - (cl-destructuring-bind (dir . depth) (if (consp dir) dir (cons dir nil)) - (if (not (file-accessible-directory-p dir)) - (message "%S was inaccessible and couldn't be searched" dir) - (projectile-discover-projects-in-directory dir depth)))))))) - -;;;###autoload -(defun +default/dired (arg) - "Open a directory in dired. -If prefix ARG is non-nil, prompt for a known project to open in dired." - (interactive "P") - (apply #'dired - (if arg - (list (completing-read "Open dired in project: " projectile-known-projects)) - (dired-read-dir-and-switches "")))) diff --git a/.config/emacs/modules/config/default/autoload/search.el b/.config/emacs/modules/config/default/autoload/search.el @@ -1,146 +0,0 @@ -;;; config/default/autoload/search.el -*- lexical-binding: t; -*- - -;;;###autoload -(defun +default/search-cwd (&optional arg) - "Conduct a text search in files under the current folder. -If prefix ARG is set, prompt for a directory to search from." - (interactive "P") - (let ((default-directory - (if arg - (read-directory-name "Search directory: ") - default-directory))) - (call-interactively - (cond ((modulep! :completion ivy) #'+ivy/project-search-from-cwd) - ((modulep! :completion helm) #'+helm/project-search-from-cwd) - ((modulep! :completion vertico) #'+vertico/project-search-from-cwd) - (#'rgrep))))) - -;;;###autoload -(defun +default/search-other-cwd () - "Conduct a text search in another directory." - (interactive) - (+default/search-cwd 'other)) - -;;;###autoload -(defun +default/search-emacsd () - "Conduct a text search in files under `doom-emacs-dir'." - (interactive) - (let ((default-directory doom-emacs-dir)) - (call-interactively - (cond ((modulep! :completion ivy) #'+ivy/project-search-from-cwd) - ((modulep! :completion helm) #'+helm/project-search-from-cwd) - ((modulep! :completion vertico) #'+vertico/project-search-from-cwd) - (#'rgrep))))) - -;;;###autoload -(defun +default/search-buffer () - "Conduct a text search on the current buffer. - -If a selection is active and multi-line, perform a search restricted to that -region. - -If a selection is active and not multi-line, use the selection as the initial -input and search the whole buffer for it." - (interactive) - (let (start end multiline-p) - (save-restriction - (when (region-active-p) - (setq start (region-beginning) - end (region-end) - multiline-p (/= (line-number-at-pos start) - (line-number-at-pos end))) - (deactivate-mark) - (when multiline-p - (narrow-to-region start end))) - (cond ((or (modulep! :completion helm) - (modulep! :completion ivy)) - (call-interactively - (if (and start end (not multiline-p)) - #'swiper-isearch-thing-at-point - #'swiper-isearch))) - ((modulep! :completion vertico) - (if (and start end (not multiline-p)) - (consult-line - (replace-regexp-in-string - " " "\\\\ " - (rxt-quote-pcre - (buffer-substring-no-properties start end)))) - (call-interactively #'consult-line))))))) - -;;;###autoload -(defun +default/search-project (&optional arg) - "Conduct a text search in the current project root. -If prefix ARG is set, include ignored/hidden files." - (interactive "P") - (let* ((projectile-project-root nil) - (disabled-command-function nil) - (current-prefix-arg (unless (eq arg 'other) arg)) - (default-directory - (if (eq arg 'other) - (if-let (projects (projectile-relevant-known-projects)) - (completing-read "Search project: " projects nil t) - (user-error "There are no known projects")) - default-directory))) - (call-interactively - (cond ((modulep! :completion ivy) #'+ivy/project-search) - ((modulep! :completion helm) #'+helm/project-search) - ((modulep! :completion vertico) #'+vertico/project-search) - (#'projectile-ripgrep))))) - -;;;###autoload -(defun +default/search-other-project () - "Conduct a text search in a known project." - (interactive) - (+default/search-project 'other)) - -;;;###autoload -(defun +default/search-project-for-symbol-at-point (symbol dir) - "Search current project for symbol at point. -If prefix ARG is set, prompt for a known project to search from." - (interactive - (list (rxt-quote-pcre (or (doom-thing-at-point-or-region) "")) - (let ((projectile-project-root nil)) - (if current-prefix-arg - (if-let (projects (projectile-relevant-known-projects)) - (completing-read "Search project: " projects nil t) - (user-error "There are no known projects")) - (doom-project-root default-directory))))) - (cond ((modulep! :completion ivy) - (+ivy/project-search nil symbol dir)) - ((modulep! :completion helm) - (+helm/project-search nil symbol dir)) - ((modulep! :completion vertico) - (+vertico/project-search nil symbol dir)) - ((rgrep (regexp-quote symbol))))) - -;;;###autoload -(defun +default/search-notes-for-symbol-at-point (symbol) - "Conduct a text search in the current project for symbol at point. If prefix -ARG is set, prompt for a known project to search from." - (interactive - (list (rxt-quote-pcre (or (doom-thing-at-point-or-region) "")))) - (require 'org) - (+default/search-project-for-symbol-at-point - symbol org-directory)) - -;;;###autoload -(defun +default/org-notes-search (query) - "Perform a text search on `org-directory'." - (interactive - (list (if (doom-region-active-p) - (buffer-substring-no-properties - (doom-region-beginning) - (doom-region-end)) - ""))) - (require 'org) - (+default/search-project-for-symbol-at-point - query org-directory)) - -;;;###autoload -(defun +default/org-notes-headlines () - "Jump to an Org headline in `org-agenda-files'." - (interactive) - (doom-completing-read-org-headings - "Jump to org headline: " org-agenda-files - :depth 3 - :include-files t)) diff --git a/.config/emacs/modules/config/default/autoload/text.el b/.config/emacs/modules/config/default/autoload/text.el @@ -1,175 +0,0 @@ -;;; config/default/autoload/text.el -*- lexical-binding: t; -*- - -;;;###autoload -(defalias '+default/newline #'electric-indent-just-newline) - -;;;###autoload -(defun +default/newline-above () - "Insert an indented new line before the current one." - (interactive) - (if (featurep 'evil) - (call-interactively 'evil-open-above) - (beginning-of-line) - (save-excursion (newline)) - (indent-according-to-mode))) - -;;;###autoload -(defun +default/newline-below () - "Insert an indented new line after the current one." - (interactive) - (if (featurep 'evil) - (call-interactively 'evil-open-below) - (end-of-line) - (newline-and-indent))) - -;;;###autoload -(defun +default/yank-pop () - "Interactively select what text to insert from the kill ring." - (interactive) - (call-interactively - (cond ((fboundp 'consult-yank-pop) #'consult-yank-pop) ;HACK see @ymarco's comment on #5013 and TODO.org in the selecturm module. - ((fboundp 'counsel-yank-pop) #'counsel-yank-pop) - ((fboundp 'helm-show-kill-ring) #'helm-show-kill-ring) - ((error "No kill-ring search backend available. Enable ivy, helm or vertico!"))))) - -;;;###autoload -(defun +default/yank-buffer-contents () - "Copy entire buffer into kill ring." - (interactive) - (clipboard-kill-ring-save (point-min) (point-max))) - -;;;###autoload -(defun +default/yank-buffer-path (&optional root) - "Copy the current buffer's path to the kill ring." - (interactive) - (if-let (filename (or (buffer-file-name (buffer-base-buffer)) - (bound-and-true-p list-buffers-directory))) - (let ((path (abbreviate-file-name - (if root - (file-relative-name filename root) - filename)))) - (kill-new path) - (if (string= path (car kill-ring)) - (message "Copied path: %s" path) - (user-error "Couldn't copy filename in current buffer"))) - (error "Couldn't find filename in current buffer"))) - -;;;###autoload -(defun +default/yank-buffer-path-relative-to-project (&optional include-root) - "Copy the current buffer's path to the kill ring. -With non-nil prefix INCLUDE-ROOT, also include the project's root." - (interactive "P") - (+default/yank-buffer-path - (if include-root - (file-name-directory (directory-file-name (doom-project-root))) - (doom-project-root)))) - -;;;###autoload -(defun +default/insert-file-path (arg) - "Insert the file name (absolute path if prefix ARG). -If `buffer-file-name' isn't set, uses `default-directory'." - (interactive "P") - (let ((path (or buffer-file-name default-directory))) - (insert - (if arg - (abbreviate-file-name path) - (file-name-nondirectory path))))) - -;;;###autoload -(defun doom/backward-delete-whitespace-to-column () - "Delete back to the previous column of whitespace, or as much whitespace as -possible, or just one char if that's not possible." - (interactive) - (let* ((context - (if (bound-and-true-p smartparens-mode) - (ignore-errors (sp-get-thing)))) - (op (plist-get context :op)) - (cl (plist-get context :cl)) - open-len close-len current-column) - (cond ;; When in strings (sp acts weird with quotes; this is the fix) - ;; Also, skip closing delimiters - ((and op cl - (string= op cl) - (and (string= (char-to-string (or (char-before) 0)) op) - (setq open-len (length op))) - (and (string= (char-to-string (or (char-after) 0)) cl) - (setq close-len (length cl)))) - (delete-char (- open-len)) - (delete-char close-len)) - - ;; Delete up to the nearest tab column IF only whitespace between - ;; point and bol. - ((and (not indent-tabs-mode) - (> tab-width 1) - (not (bolp)) - (not (doom-point-in-string-p)) - (>= (abs (save-excursion (skip-chars-backward " \t"))) - (setq current-column (current-column)))) - (delete-char (- (1+ (% (1- current-column) tab-width))))) - - ;; Otherwise do a regular delete - ((delete-char -1))))) - -;;;###autoload -(defun +default--delete-backward-char-a (n &optional killflag) - "Same as `delete-backward-char', but preforms these additional checks: - -+ If point is surrounded by (balanced) whitespace and a brace delimiter ({} [] - ()), delete a space on either side of the cursor. -+ If point is at BOL and surrounded by braces on adjacent lines, collapse - newlines: - { - | - } => {|} -+ Otherwise, resort to `doom/backward-delete-whitespace-to-column'. -+ Resorts to `delete-char' if n > 1" - (interactive "p\nP") - (or (integerp n) - (signal 'wrong-type-argument (list 'integerp n))) - (cond ((and (use-region-p) - delete-active-region - (= n 1)) - ;; If a region is active, kill or delete it. - (if (eq delete-active-region 'kill) - (kill-region (region-beginning) (region-end) 'region) - (funcall region-extract-function 'delete-only))) - ;; In Overwrite mode, maybe untabify while deleting - ((null (or (null overwrite-mode) - (<= n 0) - (memq (char-before) '(?\t ?\n)) - (eobp) - (eq (char-after) ?\n))) - (let ((ocol (current-column))) - (delete-char (- n) killflag) - (save-excursion - (insert-char ?\s (- ocol (current-column)) nil)))) - ;; - ((= n 1) - (cond ((or (not (modulep! +smartparens)) - (not (bound-and-true-p smartparens-mode)) - (and (memq (char-before) (list ?\ ?\t)) - (save-excursion - (and (/= (skip-chars-backward " \t" (line-beginning-position)) 0) - (bolp))))) - (doom/backward-delete-whitespace-to-column)) - ((let* ((pair (ignore-errors (sp-get-thing))) - (op (plist-get pair :op)) - (cl (plist-get pair :cl)) - (beg (plist-get pair :beg)) - (end (plist-get pair :end))) - (cond ((and end beg (= end (+ beg (length op) (length cl)))) - (delete-char (- (length op)))) - ((doom-surrounded-p pair 'inline 'balanced) - (delete-char -1 killflag) - (delete-char 1) - (when (= (point) (+ (length cl) beg)) - (sp-backward-delete-char 1) - (sp-insert-pair op))) - ((and (bolp) (doom-surrounded-p pair nil 'balanced)) - (delete-region beg end) - (sp-insert-pair op) - t) - ((run-hook-with-args-until-success 'doom-delete-backward-functions)) - ((doom/backward-delete-whitespace-to-column))))))) - ;; Otherwise, do simple deletion. - ((delete-char (- n) killflag)))) diff --git a/.config/emacs/modules/config/default/config.el b/.config/emacs/modules/config/default/config.el @@ -1,497 +0,0 @@ -;;; config/default/config.el -*- lexical-binding: t; -*- - -(defvar +default-want-RET-continue-comments t - "If non-nil, RET will continue commented lines.") - -(defvar +default-minibuffer-maps - (append '(minibuffer-local-map - minibuffer-local-ns-map - minibuffer-local-completion-map - minibuffer-local-must-match-map - minibuffer-local-isearch-map - read-expression-map) - (cond ((modulep! :completion ivy) - '(ivy-minibuffer-map - ivy-switch-buffer-map)) - ((modulep! :completion helm) - '(helm-map - helm-rg-map - helm-read-file-map)))) - "A list of all the keymaps used for the minibuffer.") - - -;; -;;; Reasonable defaults - -;;;###package avy -(setq avy-all-windows nil - avy-all-windows-alt t - avy-background t - ;; the unpredictability of this (when enabled) makes it a poor default - avy-single-candidate-jump nil) - - -(after! epa - ;; With GPG 2.1+, this forces gpg-agent to use the Emacs minibuffer to prompt - ;; for the key passphrase. - (set 'epg-pinentry-mode 'loopback) - ;; Default to the first enabled and non-expired key in your keyring. - (setq-default - epa-file-encrypt-to - (or (default-value 'epa-file-encrypt-to) - (unless (string-empty-p user-full-name) - (when-let (context (ignore-errors (epg-make-context))) - (cl-loop for key in (epg-list-keys context user-full-name 'public) - for subkey = (car (epg-key-sub-key-list key)) - if (not (memq 'disabled (epg-sub-key-capability subkey))) - if (< (or (epg-sub-key-expiration-time subkey) 0) - (time-to-seconds)) - collect (epg-sub-key-fingerprint subkey)))) - user-mail-address)) - ;; And suppress prompts if epa-file-encrypt-to has a default value (without - ;; overwriting file-local values). - (defadvice! +default--dont-prompt-for-keys-a (&rest _) - :before #'epa-file-write-region - (unless (local-variable-p 'epa-file-encrypt-to) - (setq-local epa-file-encrypt-to (default-value 'epa-file-encrypt-to))))) - - -(after! woman - ;; The woman-manpath default value does not necessarily match man. If we have - ;; man available but aren't using it for performance reasons, we can extract - ;; it's manpath. - (when (executable-find "man") - (setq woman-manpath - (split-string (cdr (doom-call-process "man" "--path")) - path-separator t)))) - - -(use-package! drag-stuff - :defer t - :init - (map! "<M-up>" #'drag-stuff-up - "<M-down>" #'drag-stuff-down - "<M-left>" #'drag-stuff-left - "<M-right>" #'drag-stuff-right)) - - -;;;###package tramp -(unless IS-WINDOWS - (setq tramp-default-method "ssh")) ; faster than the default scp - - -;; -;;; Smartparens config - -(when (modulep! +smartparens) - ;; You can disable :unless predicates with (sp-pair "'" nil :unless nil) - ;; And disable :post-handlers with (sp-pair "{" nil :post-handlers nil) - ;; or specific :post-handlers with: - ;; (sp-pair "{" nil :post-handlers '(:rem ("| " "SPC"))) - (after! smartparens - ;; Smartparens' navigation feature is neat, but does not justify how - ;; expensive it is. It's also less useful for evil users. This may need to - ;; be reactivated for non-evil users though. Needs more testing! - (add-hook! 'after-change-major-mode-hook - (defun doom-disable-smartparens-navigate-skip-match-h () - (setq sp-navigate-skip-match nil - sp-navigate-consider-sgml-tags nil))) - - ;; Autopair quotes more conservatively; if I'm next to a word/before another - ;; quote, I don't want to open a new pair or it would unbalance them. - (let ((unless-list '(sp-point-before-word-p - sp-point-after-word-p - sp-point-before-same-p))) - (sp-pair "'" nil :unless unless-list) - (sp-pair "\"" nil :unless unless-list)) - - ;; Expand {|} => { | } - ;; Expand {|} => { - ;; | - ;; } - (dolist (brace '("(" "{" "[")) - (sp-pair brace nil - :post-handlers '(("||\n[i]" "RET") ("| " "SPC")) - ;; Don't autopair opening braces if before a word character or - ;; other opening brace. The rationale: it interferes with manual - ;; balancing of braces, and is odd form to have s-exps with no - ;; whitespace in between, e.g. ()()(). Insert whitespace if - ;; genuinely want to start a new form in the middle of a word. - :unless '(sp-point-before-word-p sp-point-before-same-p))) - - ;; In lisps ( should open a new form if before another parenthesis - (sp-local-pair sp-lisp-modes "(" ")" :unless '(:rem sp-point-before-same-p)) - - ;; Major-mode specific fixes - (sp-local-pair 'ruby-mode "{" "}" - :pre-handlers '(:rem sp-ruby-pre-handler) - :post-handlers '(:rem sp-ruby-post-handler)) - - ;; Don't eagerly escape Swift style string interpolation - (sp-local-pair 'swift-mode "\\(" ")" :when '(sp-in-string-p)) - - ;; Don't do square-bracket space-expansion where it doesn't make sense to - (sp-local-pair '(emacs-lisp-mode org-mode markdown-mode gfm-mode) - "[" nil :post-handlers '(:rem ("| " "SPC"))) - - ;; Reasonable default pairs for HTML-style comments - (sp-local-pair (append sp--html-modes '(markdown-mode gfm-mode)) - "<!--" "-->" - :unless '(sp-point-before-word-p sp-point-before-same-p) - :actions '(insert) :post-handlers '(("| " "SPC"))) - - ;; Disable electric keys in C modes because it interferes with smartparens - ;; and custom bindings. We'll do it ourselves (mostly). - (after! cc-mode - (setq-default c-electric-flag nil) - (dolist (key '("#" "{" "}" "/" "*" ";" "," ":" "(" ")" "\177")) - (define-key c-mode-base-map key nil)) - - ;; Smartparens and cc-mode both try to autoclose angle-brackets - ;; intelligently. The result isn't very intelligent (causes redundant - ;; characters), so just do it ourselves. - (define-key! c++-mode-map "<" nil ">" nil) - - (defun +default-cc-sp-point-is-template-p (id action context) - "Return t if point is in the right place for C++ angle-brackets." - (and (sp-in-code-p id action context) - (cond ((eq action 'insert) - (sp-point-after-word-p id action context)) - ((eq action 'autoskip) - (/= (char-before) 32))))) - - (defun +default-cc-sp-point-after-include-p (id action context) - "Return t if point is in an #include." - (and (sp-in-code-p id action context) - (save-excursion - (goto-char (line-beginning-position)) - (looking-at-p "[ ]*#include[^<]+")))) - - ;; ...and leave it to smartparens - (sp-local-pair '(c++-mode objc-mode) - "<" ">" - :when '(+default-cc-sp-point-is-template-p - +default-cc-sp-point-after-include-p) - :post-handlers '(("| " "SPC"))) - - (sp-local-pair '(c-mode c++-mode objc-mode java-mode) - "/*!" "*/" - :post-handlers '(("||\n[i]" "RET") ("[d-1]< | " "SPC")))) - - ;; Expand C-style comment blocks. - (defun +default-open-doc-comments-block (&rest _ignored) - (save-excursion - (newline) - (indent-according-to-mode))) - (sp-local-pair - '(js2-mode typescript-mode rjsx-mode rust-mode c-mode c++-mode objc-mode - csharp-mode java-mode php-mode css-mode scss-mode less-css-mode - stylus-mode scala-mode) - "/*" "*/" - :actions '(insert) - :post-handlers '(("| " "SPC") - (" | " "*") - ("|[i]\n[i]" "RET"))) - - (after! smartparens-ml - (sp-with-modes '(tuareg-mode fsharp-mode) - (sp-local-pair "(*" "*)" :actions nil) - (sp-local-pair "(*" "*" - :actions '(insert) - :post-handlers '(("| " "SPC") ("|[i]*)[d-2]" "RET"))))) - - (after! smartparens-markdown - (sp-with-modes '(markdown-mode gfm-mode) - (sp-local-pair "```" "```" :post-handlers '(:add ("||\n[i]" "RET"))) - - ;; The original rules for smartparens had an odd quirk: inserting two - ;; asterixex would replace nearby quotes with asterixes. These two rules - ;; set out to fix this. - (sp-local-pair "**" nil :actions :rem) - (sp-local-pair "*" "*" - :actions '(insert skip) - :unless '(:rem sp-point-at-bol-p) - ;; * then SPC will delete the second asterix and assume - ;; you wanted a bullet point. * followed by another * - ;; will produce an extra, assuming you wanted **|**. - :post-handlers '(("[d1]" "SPC") ("|*" "*")))) - - ;; This keybind allows * to skip over **. - (map! :map markdown-mode-map - :ig "*" (general-predicate-dispatch nil - (looking-at-p "\\*\\* *") - (cmd! (forward-char 2))))) - - ;; Removes haskell-mode trailing braces - (after! smartparens-haskell - (sp-with-modes '(haskell-mode haskell-interactive-mode) - (sp-local-pair "{-" "-}" :actions :rem) - (sp-local-pair "{-#" "#-}" :actions :rem) - (sp-local-pair "{-@" "@-}" :actions :rem) - (sp-local-pair "{-" "-") - (sp-local-pair "{-#" "#-") - (sp-local-pair "{-@" "@-"))) - - (after! smartparens-python - (sp-with-modes 'python-mode - ;; Automatically close f-strings - (sp-local-pair "f\"" "\"") - (sp-local-pair "f\"\"\"" "\"\"\"") - (sp-local-pair "f'''" "'''") - (sp-local-pair "f'" "'")) - ;; Original keybind interferes with smartparens rules - (define-key python-mode-map (kbd "DEL") nil) - ;; Interferes with the def snippet in doom-snippets - ;; TODO Fix this upstream, in doom-snippets, instead - (setq sp-python-insert-colon-in-function-definitions nil)))) - - -;; -;;; Keybinding fixes - -;; Highjacks backspace to delete up to nearest column multiple of `tab-width' at -;; a time. If you have smartparens enabled, it will also: -;; a) balance spaces inside brackets/parentheses ( | ) -> (|) -;; b) close empty multiline brace blocks in one step: -;; { -;; | -;; } -;; becomes {|} -;; c) refresh smartparens' :post-handlers, so SPC and RET expansions work even -;; after a backspace. -;; d) properly delete smartparen pairs when they are encountered, without the -;; need for strict mode. -;; e) do none of this when inside a string -(advice-add #'delete-backward-char :override #'+default--delete-backward-char-a) - -;; HACK Makes `newline-and-indent' continue comments (and more reliably). -;; Consults `doom-point-in-comment-functions' to detect a commented region -;; and uses that mode's `comment-line-break-function' to continue comments. -;; If neither exists, it will fall back to the normal behavior of -;; `newline-and-indent'. -;; -;; We use an advice here instead of a remapping because many modes define -;; and remap to their own newline-and-indent commands, and tackling all -;; those cases was judged to be more work than dealing with the edge cases -;; on a case by case basis. -(defadvice! +default--newline-indent-and-continue-comments-a (&rest _) - "A replacement for `newline-and-indent'. - -Continues comments if executed from a commented line. Consults -`doom-point-in-comment-functions' to determine if in a comment." - :before-until #'newline-and-indent - (interactive "*") - (when (and +default-want-RET-continue-comments - (doom-point-in-comment-p) - (functionp comment-line-break-function)) - (funcall comment-line-break-function nil) - t)) - -;; This section is dedicated to "fixing" certain keys so that they behave -;; sensibly (and consistently with similar contexts). - -;; Consistently use q to quit windows -(after! tabulated-list - (define-key tabulated-list-mode-map "q" #'quit-window)) - -;; OS specific fixes -(when IS-MAC - ;; Fix MacOS shift+tab - (define-key key-translation-map [S-iso-lefttab] [backtab]) - ;; Fix conventional OS keys in Emacs - (map! "s-`" #'other-frame ; fix frame-switching - ;; fix OS window/frame navigation/manipulation keys - "s-w" #'delete-window - "s-W" #'delete-frame - "s-n" #'+default/new-buffer - "s-N" #'make-frame - "s-q" (if (daemonp) #'delete-frame #'save-buffers-kill-terminal) - "C-s-f" #'toggle-frame-fullscreen - ;; Restore somewhat common navigation - "s-l" #'goto-line - ;; Restore OS undo, save, copy, & paste keys (without cua-mode, because - ;; it imposes some other functionality and overhead we don't need) - "s-f" (if (modulep! :completion vertico) #'consult-line #'swiper) - "s-z" #'undo - "s-Z" #'redo - "s-c" (if (featurep 'evil) #'evil-yank #'copy-region-as-kill) - "s-v" #'yank - "s-s" #'save-buffer - "s-x" #'execute-extended-command - :v "s-x" #'kill-region - ;; Buffer-local font scaling - "s-+" #'doom/reset-font-size - "s-=" #'doom/increase-font-size - "s--" #'doom/decrease-font-size - ;; Conventional text-editing keys & motions - "s-a" #'mark-whole-buffer - "s-/" (cmd! (save-excursion (comment-line 1))) - :n "s-/" #'evilnc-comment-or-uncomment-lines - :v "s-/" #'evilnc-comment-operator - :gi [s-backspace] #'doom/backward-kill-to-bol-and-indent - :gi [s-left] #'doom/backward-to-bol-or-indent - :gi [s-right] #'doom/forward-to-last-non-comment-or-eol - :gi [M-backspace] #'backward-kill-word - :gi [M-left] #'backward-word - :gi [M-right] #'forward-word)) - - -;; -;;; Keybind schemes - -;; Custom help keys -- these aren't under `+bindings' because they ought to be -;; universal. -(define-key! help-map - ;; new keybinds - "'" #'describe-char - "u" #'doom/help-autodefs - "E" #'doom/sandbox - "M" #'doom/describe-active-minor-mode - "O" #'+lookup/online - "T" #'doom/toggle-profiler - "V" #'doom/help-custom-variable - "W" #'+default/man-or-woman - "C-k" #'describe-key-briefly - "C-l" #'describe-language-environment - "C-m" #'info-emacs-manual - - ;; Unbind `help-for-help'. Conflicts with which-key's help command for the - ;; <leader> h prefix. It's already on ? and F1 anyway. - "C-h" nil - - ;; replacement keybinds - ;; replaces `info-emacs-manual' b/c it's on C-m now - "r" nil - "rr" #'doom/reload - "rt" #'doom/reload-theme - "rp" #'doom/reload-packages - "rf" #'doom/reload-font - "re" #'doom/reload-env - - ;; make `describe-bindings' available under the b prefix which it previously - ;; occupied. Add more binding related commands under that prefix as well - "b" nil - "bb" #'describe-bindings - "bi" #'which-key-show-minor-mode-keymap - "bm" #'which-key-show-major-mode - "bt" #'which-key-show-top-level - "bf" #'which-key-show-full-keymap - "bk" #'which-key-show-keymap - - ;; replaces `apropos-documentation' b/c `apropos' covers this - "d" nil - "db" #'doom/report-bug - "dc" #'doom/goto-private-config-file - "dC" #'doom/goto-private-init-file - "dd" #'doom-debug-mode - "df" #'doom/help-faq - "dh" #'doom/help - "dl" #'doom/help-search-load-path - "dL" #'doom/help-search-loaded-files - "dm" #'doom/help-modules - "dn" #'doom/help-news - "dN" #'doom/help-search-news - "dpc" #'doom/help-package-config - "dpd" #'doom/goto-private-packages-file - "dph" #'doom/help-package-homepage - "dpp" #'doom/help-packages - "ds" #'doom/help-search-headings - "dS" #'doom/help-search - "dt" #'doom/toggle-profiler - "du" #'doom/help-autodefs - "dv" #'doom/version - "dx" #'doom/sandbox - - ;; replaces `apropos-command' - "a" #'apropos - "A" #'apropos-documentation - ;; replaces `describe-copying' b/c not useful - "C-c" #'describe-coding-system - ;; replaces `Info-got-emacs-command-node' b/c redundant w/ `Info-goto-node' - "F" #'describe-face - ;; replaces `view-hello-file' b/c annoying - "h" nil - ;; replaces `view-emacs-news' b/c it's on C-n too - "n" #'doom/help-news - ;; replaces `help-with-tutorial', b/c it's less useful than `load-theme' - "t" #'load-theme - ;; replaces `finder-by-keyword' b/c not useful - "p" #'doom/help-packages - ;; replaces `describe-package' b/c redundant w/ `doom/help-packages' - "P" #'find-library) - -(after! which-key - (let ((prefix-re (regexp-opt (list doom-leader-key doom-leader-alt-key)))) - (cl-pushnew `((,(format "\\`\\(?:<\\(?:\\(?:f1\\|help\\)>\\)\\|C-h\\|%s h\\) d\\'" prefix-re)) - nil . "doom") - which-key-replacement-alist) - (cl-pushnew `((,(format "\\`\\(?:<\\(?:\\(?:f1\\|help\\)>\\)\\|C-h\\|%s h\\) r\\'" prefix-re)) - nil . "reload") - which-key-replacement-alist) - (cl-pushnew `((,(format "\\`\\(?:<\\(?:\\(?:f1\\|help\\)>\\)\\|C-h\\|%s h\\) b\\'" prefix-re)) - nil . "bindings") - which-key-replacement-alist))) - - -(when (modulep! +bindings) - ;; Make M-x harder to miss - (define-key! 'override - "M-x" #'execute-extended-command - "A-x" #'execute-extended-command) - - ;; A Doom convention where C-s on popups and interactive searches will invoke - ;; ivy/helm/vertico for their superior filtering. - (when-let (command (cond ((modulep! :completion ivy) - #'counsel-minibuffer-history) - ((modulep! :completion helm) - #'helm-minibuffer-history) - ((modulep! :completion vertico) - #'consult-history))) - (define-key! - :keymaps (append +default-minibuffer-maps - (when (modulep! :editor evil +everywhere) - '(evil-ex-completion-map))) - "C-s" command)) - - ;; Smarter C-a/C-e for both Emacs and Evil. C-a will jump to indentation. - ;; Pressing it again will send you to the true bol. Same goes for C-e, except - ;; it will ignore comments+trailing whitespace before jumping to eol. - (map! :gi "C-a" #'doom/backward-to-bol-or-indent - :gi "C-e" #'doom/forward-to-last-non-comment-or-eol - ;; Standardizes the behavior of modified RET to match the behavior of - ;; other editors, particularly Atom, textedit, textmate, and vscode, in - ;; which ctrl+RET will add a new "item" below the current one and - ;; cmd+RET (Mac) / meta+RET (elsewhere) will add a new, blank line below - ;; the current one. - - ;; C-<mouse-scroll-up> = text scale increase - ;; C-<mouse-scroll-down> = text scale decrease - [C-down-mouse-2] (cmd! (text-scale-set 0)) - - ;; auto-indent on newline by default - :gi [remap newline] #'newline-and-indent - ;; insert literal newline - :i "S-RET" #'+default/newline - :i [S-return] #'+default/newline - :i "C-j" #'+default/newline - - ;; Add new item below current (without splitting current line). - :gi "C-RET" #'+default/newline-below - :gn [C-return] #'+default/newline-below - ;; Add new item above current (without splitting current line) - :gi "C-S-RET" #'+default/newline-above - :gn [C-S-return] #'+default/newline-above - - (:when IS-MAC - :gn "s-RET" #'+default/newline-below - :gn [s-return] #'+default/newline-below - :gn "S-s-RET" #'+default/newline-above - :gn [S-s-return] #'+default/newline-above))) - - -;; -;;; Bootstrap configs - -(if (featurep 'evil) - (load! "+evil") - (load! "+emacs")) diff --git a/.config/emacs/modules/config/default/packages.el b/.config/emacs/modules/config/default/packages.el @@ -1,9 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; config/default/packages.el - -(package! avy :pin "955c8dedd68c74f3cf692c1249513f048518c4c9") -(package! drag-stuff :pin "6d06d846cd37c052d79acd0f372c13006aa7e7c8") -(package! link-hint :pin "1f9bb60289d87f31f92b86ed22d1f2c0a7af0222") - -(unless (modulep! :editor evil) - (package! expand-region :pin "b70feaa644310dc2d599dc277cd20a1f2b6446ac")) diff --git a/.config/emacs/modules/config/literate/README.org b/.config/emacs/modules/config/literate/README.org @@ -1,124 +0,0 @@ -#+title: :config literate -#+subtitle: Disguise your config as poor documentation -#+created: May 28, 2020 -#+since: 2.0.9 - -* Description :unfold: -This module enables support for a literate config. - -A literate config consists of a =$DOOMDIR/config.org=. All src blocks within are -tangled =$DOOMDIR/config.el=, by default, when ~$ doom sync~ is executed. - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -/This module doesn't install any packages./ - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module only requires a =$DOOMDIR/config.org=, which will be tangled into -=$DOOMDIR/config.el= when you run ~$ doom sync~. - -#+begin_quote - 🚧 *Be careful!* Enabling this module will overwrite =$DOOMDIR/config.el=! If - you are only trying out the module, *back up this file first!* -#+end_quote - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -- Automatically tangles =$DOOMDIR/config.org= to =$DOOMDIR/config.el= when - saving. See [[*Troubleshooting][Troubleshooting]] section belong on how to disable it. - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** Change the location of config.org -The ~+literate-config-file~ variable controls where to look for your config.org. -To change this it must be modified early -- in =$DOOMDIR/init.el= or -=$DOOMDIR/cli.el=. - -Source blocks needs to be in some language to be automatically tangled, for -example ~#+begin_src emacs-lisp~, but it doesn't matter what language is used. -All blocks are tangled to ~config.el~, but ~elisp~ gives correct syntax -highlighting. If you don't want to specify language in block you can also -enforce tangling by adding ~#+begin_src :tangle yes~ - -** Change where src blocks are tangled or prevent it entirely -By default, this module tangles all src emacs-lisp blocks to config.el unless -otherwise specified. - -To specify otherwise use the ~:tangle~ parameter to: -- Specify a destination other than config.el: ~:tangle packages.el~ -- Disable tangling of the block altogether with ~:tangle no~ -- Or force non-elisp src blocks to tangle somewhere - -For example: -#+begin_src org -,#+begin_src emacs-lisp :tangle no -(message "Don't tangle me") -,#+end_src - -,#+begin_src emacs-lisp :tangle packages.el -(package! my-package) -(package! other-package) -,#+end_src - -,#+begin_src sh :tangle ~/.dotfiles/bin/script.sh :tangle-mode (identity #o755) -#!/usr/bin/env bash -echo Hello world -,#+end_src - -,#+begin_src sh :tangle ~/.dotfiles/bin/script.sh :shebang "#!/usr/bin/env bash" -echo Hello world -,#+end_src -#+end_src - -You'll find more information about babel src blocks and what parameters they -support [[https://orgmode.org/manual/Working-with-Source-Code.html][in the Org manual]]. - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -[[doom-suggest-faq:][Ask a question?]] - -** How do I tangle to =$DOOMDIR/init.el=? -If your literate needs are more complex (e.g. you want to make your init.el -literate), this module won't cut it. =init.el= files in modules are loaded long -before =config.org= is tangled in the ~$ doom sync~ process. - -However, Doom comes with a [[file:../../../bin/org-tangle][bin/org-tangle]] script which can be used to tangle -arbitrary org files from the command line. Use it to create your own compilation -workflows. This is /much/ faster than using ~org-babel-load-file~ directly to -load your literate config every time Doom is started. - -** How do I disable tangle-on-save? -There are occasions where tangling on save may be undesirable. Maybe it's too -slow, produces too much noise, or happens too often (on unrelated org files in -your =$DOOMDIR=). This behavior can be disabled with: -#+begin_src emacs-lisp -;; add to $DOOMDIR/config.el -(remove-hook 'org-mode-hook #'+literate-enable-recompile-h) -#+end_src - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/config/literate/autoload.el b/.config/emacs/modules/config/literate/autoload.el @@ -1,147 +0,0 @@ -;;; config/literate/autoload.el -*- lexical-binding: t; -*- - -;;;###autoload (add-hook 'org-mode-hook #'+literate-enable-recompile-h) - -(defvar +literate-config-file (file-name-concat doom-user-dir "config.org") - "The file path of your literate config file.") - -(defvar +literate-tangle--async-proc nil) -(defvar +literate-tangle--async-proc-start-time nil) - -(defvar org-mode-hook) -(defvar org-inhibit-startup) - -(defun +literate-tangle (target dest &optional dir) - "Tangle TARGET org file to DEST." - (and (require 'ox nil t) - (require 'ob-tangle nil t) - (let* ((default-directory (or dir default-directory)) - (target (expand-file-name target)) - (dest (expand-file-name dest))) - (print! (start "Tangling your literate config...")) - (print-group! - (let (;; Do as little unnecessary work as possible in these org files. - (org-startup-indented nil) - (org-startup-folded nil) - (vc-handled-backends nil) - ;; Prevent unwanted entries in recentf, or formatters, or - ;; anything that could be on these hooks, really. Nothing else - ;; should be touching these files (particularly in interactive - ;; sessions). - (write-file-functions nil) - (before-save-hook nil) - (after-save-hook nil) - ;; Prevent infinite recursion due to recompile-on-save hooks - ;; later, and speed up `org-mode' init. - (org-mode-hook nil) - (org-inhibit-startup t) - ;; Allow evaluation of src blocks at tangle-time (would abort - ;; them otherwise). This is a security hazard, but Doom will - ;; trust that you know what you're doing! - (org-confirm-babel-evaluate nil) - ;; Say a little more - (doom-print-message-level 'info)) - (if-let (files (org-babel-tangle-file target dest)) - (always (print! (success "Done tangling %d file(s)!" (length files)))) - (print! (error "Failed to tangle any blocks from your config.")) - nil)))))) - -(defun +literate-tangle--sync () - "Tangles `+literate-config-file' if it has changed." - (or (getenv "__NOTANGLE") - (and (+literate-tangle +literate-config-file - doom-module-config-file - doom-user-dir) - (or (not noninteractive) - (exit! "__NOTANGLE=1 $@"))))) - -(defun +literate-tangle--async () - "Tangles `+literate-config-file' using an async Emacs process." - (unless (getenv "__NOTANGLE") - (when +literate-tangle--async-proc - (message "Killing outdated tangle process...") - (set-process-sentinel +literate-tangle--async-proc #'ignore) - (kill-process +literate-tangle--async-proc) - (sit-for 0.3)) ; ensure the message is seen for a bit - (setq +literate-tangle--async-proc-start-time (float-time) - +literate-tangle--async-proc - ;; See `+literate-tangle--sync' for an explanation of the (progn ...) below. - (start-process "tangle-config" - (with-current-buffer - (get-buffer-create " *tangle config*") - (erase-buffer) - (current-buffer)) - "emacs" "--batch" - "-L" (file-name-directory (locate-library "org")) - "--load" (doom-path doom-core-dir "doom") - "--load" (doom-path doom-core-dir "lib/print") - "--eval" - (prin1-to-string - `(funcall #',(symbol-function #'+literate-tangle) - ,+literate-config-file - ,doom-module-config-file - ,doom-user-dir)))) - (add-hook 'kill-emacs-hook #'+literate-tangle-check-finished-h) - (set-process-sentinel +literate-tangle--async-proc #'+literate-tangle--async-sentinel) - (run-at-time nil nil (lambda () (message "Tangling config.org"))) ; ensure shown after a save message - "Tangling config.org...")) - -(defun +literate-tangle--async-sentinel (process signal) - (cond - ((and (eq 'exit (process-status process)) - (= 0 (process-exit-status process))) - (message "Tangled config.org sucessfully (took %.1fs)" - (- (float-time) +literate-tangle--async-proc-start-time)) - (setq +literate-tangle--async-proc nil)) - ((memq (process-status process) '(exit signal)) - (pop-to-buffer (get-buffer " *tangle config*")) - (message "Failed to tangle config.org (after %.1fs)" - (- (float-time) +literate-tangle--async-proc-start-time)) - (setq +literate-tangle--async-proc nil)))) - - -;; -;;; Commands - -;;;###autoload -(defalias '+literate/reload #'doom/reload) - - -;; -;;; Hooks - -;;;###autoload -(defun +literate-tangle-h () - "Tangles `+literate-config-file' if it has changed. -This is performed with an asyncronous Emacs process, except when -`noninteractive' is nil." - (if noninteractive - (unless (+literate-tangle--sync) - (kill-emacs 3)) - (+literate-tangle--async))) - -;;;###autoload -(defun +literate-tangle-check-finished-h () - "When a tangle is still in progress, ask the user if they want to wait for it." - (when (and (process-live-p +literate-tangle--async-proc) - (yes-or-no-p "Config is currently retangling, would you please wait a few seconds?")) - (switch-to-buffer " *tangle config*") - (signal 'quit nil))) - -;;;###autoload -(defun +literate-enable-recompile-h () - "Enable literate-compiling-on-save in the current buffer." - (add-hook 'after-save-hook #'+literate-recompile-maybe-h nil 'local)) - -;;;###autoload -(defun +literate-recompile-maybe-h () - "Recompile literate config to `doom-user-dir'. - -We assume any org file in `doom-user-dir' is connected to your literate -config, and should trigger a recompile if changed." - (and (file-in-directory-p - (buffer-file-name (buffer-base-buffer)) - (file-name-directory +literate-config-file)) - (+literate-tangle-h))) - -;;; autoload.el ends here diff --git a/.config/emacs/modules/config/literate/cli.el b/.config/emacs/modules/config/literate/cli.el @@ -1,19 +0,0 @@ -;;; config/literate/cli.el -*- lexical-binding: t; -*- - -(load! "autoload") - -(defun +literate-add-installed-org-to-load-path-h () - "Use the straight-installed, not bundled Org." - (let ((straight-org-build-dir - (doom-path straight-base-dir "straight" straight-build-dir "org")) - (straight-org-repo-dir - (doom-path straight-base-dir "straight" "repos" "org"))) - (cond - ((file-exists-p straight-org-build-dir) - (add-to-list 'load-path straight-org-build-dir)) - ((file-exists-p straight-org-repo-dir) - (add-to-list 'load-path straight-org-repo-dir))))) - -;; Tangle the user's config.org before 'doom sync' runs -(add-hook 'doom-before-sync-hook #'+literate-tangle-h) -(add-hook 'doom-before-sync-hook #'+literate-add-installed-org-to-load-path-h) diff --git a/.config/emacs/modules/config/use-package/init.el b/.config/emacs/modules/config/use-package/init.el @@ -1,195 +0,0 @@ -;;; config/use-package/init.el -*- lexical-binding: t; -*- -;;; Commentary: -;; -;; In the near future, Doom will stop using `use-package' internally (in its -;; modules and core), because it's far too complex and magical for our needs. -;; However, folks who still want to use it may enable this module. However, it -;; will be enabled by default until Doom no longer depends on it. -;; -;;; Code: - -(defvar doom--deferred-packages-alist '(t)) -(autoload 'use-package "use-package-core" nil nil t) - - -;; -;;; Use-package modifications - -(setq use-package-compute-statistics init-file-debug - use-package-verbose init-file-debug - use-package-minimum-reported-time (if init-file-debug 0 0.1) - use-package-expand-minimally (not noninteractive)) - -;; A common mistake for new users is that they inadvertently install their -;; packages with package.el, by copying over old `use-package' declarations with -;; an :ensure t property. Doom doesn't use package.el, so this will throw an -;; error that will confuse beginners, so we disable `:ensure'. -(setq use-package-ensure-function - (lambda (name &rest _) - (message "Ignoring ':ensure t' in '%s' config" name))) -;; ...On the other hand, if the user has loaded `package', then we should assume -;; they know what they're doing and restore the old behavior: -(add-transient-hook! 'package-initialize - (when (eq use-package-ensure-function #'ignore) - (setq use-package-ensure-function #'use-package-ensure-elpa))) - -(with-eval-after-load 'use-package-core - ;; `use-package' adds syntax highlighting for the `use-package' macro, but - ;; Emacs 26+ already highlights macros, so it's redundant. - (font-lock-remove-keywords 'emacs-lisp-mode use-package-font-lock-keywords) - - ;; We define :minor and :magic-minor from the `auto-minor-mode' package here - ;; so we don't have to load `auto-minor-mode' so early. - (dolist (keyword '(:minor :magic-minor)) - (setq use-package-keywords - (use-package-list-insert keyword use-package-keywords :commands))) - - (defalias 'use-package-normalize/:minor #'use-package-normalize-mode) - (defun use-package-handler/:minor (name _ arg rest state) - (use-package-handle-mode name 'auto-minor-mode-alist arg rest state)) - - (defalias 'use-package-normalize/:magic-minor #'use-package-normalize-mode) - (defun use-package-handler/:magic-minor (name _ arg rest state) - (use-package-handle-mode name 'auto-minor-mode-magic-alist arg rest state)) - - ;; HACK Fix `:load-path' so it resolves relative paths to the containing file, - ;; rather than `user-emacs-directory'. This is a done as a convenience - ;; for users, wanting to specify a local directory. - (defadvice! doom--resolve-load-path-from-containg-file-a (fn label arg &optional recursed) - "Resolve :load-path from the current directory." - :around #'use-package-normalize-paths - ;; `use-package-normalize-paths' resolves paths relative to - ;; `user-emacs-directory', so we change that. - (let ((user-emacs-directory - (or (and (stringp arg) - (not (file-name-absolute-p arg)) - (ignore-errors (dir!))) - doom-emacs-dir))) - (funcall fn label arg recursed))) - - ;; Adds two keywords to `use-package' to expand its lazy-loading capabilities: - ;; - ;; :after-call SYMBOL|LIST - ;; :defer-incrementally SYMBOL|LIST|t - ;; - ;; Check out `use-package!'s documentation for more about these two. - (dolist (keyword '(:defer-incrementally :after-call)) - (push keyword use-package-deferring-keywords) - (setq use-package-keywords - (use-package-list-insert keyword use-package-keywords :after))) - - (defalias 'use-package-normalize/:defer-incrementally #'use-package-normalize-symlist) - (defun use-package-handler/:defer-incrementally (name _keyword targets rest state) - (use-package-concat - `((doom-load-packages-incrementally - ',(if (equal targets '(t)) - (list name) - (append targets (list name))))) - (use-package-process-keywords name rest state))) - - (defalias 'use-package-normalize/:after-call #'use-package-normalize-symlist) - (defun use-package-handler/:after-call (name _keyword hooks rest state) - (if (plist-get state :demand) - (use-package-process-keywords name rest state) - (let ((fn (make-symbol (format "doom--after-call-%s-h" name)))) - (use-package-concat - `((fset ',fn - (lambda (&rest _) - (doom-log "use-package: lazy loading %s from %s" ',name ',fn) - (condition-case e - ;; If `default-directory' is a directory that doesn't - ;; exist or is unreadable, Emacs throws up file-missing - ;; errors, so we set it to a directory we know exists and - ;; is readable. - (let ((default-directory doom-emacs-dir)) - (require ',name)) - ((debug error) - (message "Failed to load deferred package %s: %s" ',name e))) - (when-let (deferral-list (assq ',name doom--deferred-packages-alist)) - (dolist (hook (cdr deferral-list)) - (advice-remove hook #',fn) - (remove-hook hook #',fn)) - (delq! deferral-list doom--deferred-packages-alist) - (unintern ',fn nil))))) - (let (forms) - (dolist (hook hooks forms) - (push (if (string-match-p "-\\(?:functions\\|hook\\)$" (symbol-name hook)) - `(add-hook ',hook #',fn) - `(advice-add #',hook :before #',fn)) - forms))) - `((unless (assq ',name doom--deferred-packages-alist) - (push '(,name) doom--deferred-packages-alist)) - (nconc (assq ',name doom--deferred-packages-alist) - '(,@hooks))) - (use-package-process-keywords name rest state)))))) - - - -;; -;;; Macros - -(defvar doom-disabled-packages) -(defmacro use-package! (name &rest plist) - "Declares and configures a package. - -This is a thin wrapper around `use-package', and is ignored if the NAME package -is disabled by the user (with `package!'). - -See `use-package' to see what properties can be provided. Doom adds support for -two extra properties: - -:after-call SYMBOL|LIST - Takes a symbol or list of symbols representing functions or hook variables. - The first time any of these functions or hooks are executed, the package is - loaded. - -:defer-incrementally SYMBOL|LIST|t - Takes a symbol or list of symbols representing packages that will be loaded - incrementally at startup before this one. This is helpful for large packages - like magit or org, which load a lot of dependencies on first load. This lets - you load them piece-meal during idle periods, so that when you finally do need - the package, it'll load quicker. - - NAME is implicitly added if this property is present and non-nil. No need to - specify it. A value of `t' implies NAME." - (declare (indent 1)) - (unless (or (memq name doom-disabled-packages) - ;; At compile-time, use-package will forcibly load packages to - ;; prevent compile-time errors. However, if a Doom user has - ;; disabled packages you get file-missing package errors, so it's - ;; necessary to check for packages at compile time: - (and (bound-and-true-p byte-compile-current-file) - (not (locate-library (symbol-name name))))) - `(use-package ,name ,@plist))) - -(defmacro use-package-hook! (package when &rest body) - "Reconfigures a package's `use-package!' block. - -This macro must be used *before* PACKAGE's `use-package!' block. Often, this -means using it from your DOOMDIR/init.el. - -Under the hood, this uses use-package's `use-package-inject-hooks'. - -PACKAGE is a symbol; the package's name. -WHEN should be one of the following: - :pre-init :post-init :pre-config :post-config - -WARNINGS: -- The use of this macro is more often than not a code smell. Use it as last - resort. There is almost always a better alternative. -- If you are using this solely for :post-config, stop! `after!' is much better. -- If :pre-init or :pre-config hooks return nil, the original `use-package!''s - :init/:config block (respectively) is overwritten, so remember to have them - return non-nil (or exploit that to overwrite Doom's config)." - (declare (indent defun)) - (unless (memq when '(:pre-init :post-init :pre-config :post-config)) - (error "'%s' isn't a valid hook for use-package-hook!" when)) - `(progn - (setq use-package-inject-hooks t) - (add-hook ',(intern (format "use-package--%s--%s-hook" - package - (substring (symbol-name when) 1))) - (lambda () ,@body) - 'append))) - -;;; init.el ends here diff --git a/.config/emacs/modules/config/use-package/packages.el b/.config/emacs/modules/config/use-package/packages.el @@ -1,4 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; core/use-package/packages.el - -(package! use-package :pin "77945e002f11440eae72d8730d3de218163d551e") diff --git a/.config/emacs/modules/editor/README.org b/.config/emacs/modules/editor/README.org @@ -1,9 +0,0 @@ -#+title: :editor -#+created: July 30, 2021 -#+since: 21.12.0 - -* Description -For modules concerned with the insertion and editing of text. Amen. - -* Frequently asked questions -/This category has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] diff --git a/.config/emacs/modules/editor/evil/+commands.el b/.config/emacs/modules/editor/evil/+commands.el @@ -1,108 +0,0 @@ -;;; editor/evil/+commands.el -*- lexical-binding: t; -*- - -;; -;;; Custom commands -;; Editing -(evil-ex-define-cmd "@" #'+evil:macro-on-all-lines) ; TODO Test me -(evil-ex-define-cmd "R[ead]" #'+evil:read) -(evil-ex-define-cmd "al[ign]" #'+evil:align) -(evil-ex-define-cmd "ral[ign]" #'+evil:align-right) -(evil-ex-define-cmd "enhtml" #'+web:encode-html-entities) -(evil-ex-define-cmd "dehtml" #'+web:decode-html-entities) -(evil-ex-define-cmd "mc" #'+multiple-cursors:evil-mc) -(evil-ex-define-cmd "iedit" #'evil-multiedit-ex-match) -(evil-ex-define-cmd "na[rrow]" #'+evil:narrow-buffer) -(evil-ex-define-cmd "retab" #'+evil:retab) -(evil-ex-define-cmd "rev[erse]" #'+evil:reverse-lines) -(evil-ex-define-cmd "l[ine]diff" #'evil-quick-diff) - -;;; External resources -;; TODO (evil-ex-define-cmd "db" #'doom:db) -;; TODO (evil-ex-define-cmd "dbu[se]" #'doom:db-select) -;; TODO (evil-ex-define-cmd "go[ogle]" #'doom:google-search) -(evil-ex-define-cmd "lo[okup]" #'+lookup:online) -(evil-ex-define-cmd "dash" #'+lookup:dash) -(evil-ex-define-cmd "http" #'httpd-start) ; start http server -(evil-ex-define-cmd "repl" #'+eval:repl) ; invoke or send to repl -(evil-ex-define-cmd "h[elp]" #'+evil:help) - -;; TODO (evil-ex-define-cmd "rx" 'doom:regex) ; open re-builder -(evil-ex-define-cmd "sh[ell]" #'+eshell:run) -(evil-ex-define-cmd "pad" #'+evil:open-scratch-buffer) - -;;; GIT -(evil-ex-define-cmd "gist" #'+gist:send) ; send current buffer/region to gist -(evil-ex-define-cmd "gistl" #'+gist:list) ; list gists by user -(evil-ex-define-cmd "gbrowse" #'+vc/browse-at-remote) ; show file/region in github/gitlab -(evil-ex-define-cmd "gissues" #'forge-browse-issues) ; show github issues -(evil-ex-define-cmd "git" #'magit-status) ; open magit status window -(evil-ex-define-cmd "gstage" #'magit-stage) -(evil-ex-define-cmd "gunstage" #'magit-unstage) -(evil-ex-define-cmd "gblame" #'magit-blame) -(evil-ex-define-cmd "grevert" #'git-gutter:revert-hunk) - -;;; Dealing with buffers -(evil-ex-define-cmd "k[ill]" #'doom/kill-current-buffer) -(evil-ex-define-cmd "k[ill]all" #'+evil:kill-all-buffers) -(evil-ex-define-cmd "k[ill]m" #'+evil:kill-matching-buffers) -(evil-ex-define-cmd "k[ill]o" #'doom/kill-other-buffers) -(evil-ex-define-cmd "k[ill]b" #'doom/kill-buried-buffers) -(evil-ex-define-cmd "l[ast]" #'+popup/restore) -(evil-ex-define-cmd "messages" #'view-echo-area-messages) -(evil-ex-define-cmd "pop[up]" #'+popup/buffer) - -;;; Project navigation -(evil-ex-define-cmd "a" #'projectile-find-other-file) -(evil-ex-define-cmd "cd" #'+evil:cd) -(evil-ex-define-cmd "pwd" #'+evil:pwd) - -(evil-define-command +evil:swiper (&optional search) - "Invoke `swiper' with SEARCH, otherwise with the symbol at point." - (interactive "<a>") - (swiper-isearch search)) -(evil-ex-define-cmd "sw[iper]" #'+evil:swiper) - -(cond ((modulep! :completion ivy) - (evil-ex-define-cmd "pg[rep]" #'+ivy:project-search) - (evil-ex-define-cmd "pg[grep]d" #'+ivy:project-search-from-cwd)) - - ((modulep! :completion helm) - (evil-ex-define-cmd "pg[rep]" #'+helm:project-search) - (evil-ex-define-cmd "pg[grep]d" #'+helm:project-search-from-cwd)) - ((modulep! :completion vertico) - (evil-ex-define-cmd "pg[rep]" #'+vertico:project-search) - (evil-ex-define-cmd "pg[grep]d" #'+vertico:project-search-from-cwd))) - -;;; Project tools -(evil-ex-define-cmd "com[pile]" #'+evil:compile) -(evil-ex-define-cmd "make" #'+evil:make) -(evil-ex-define-cmd "mk" #'+evil:make) ; convenience alias -(evil-ex-define-cmd "debug" #'+debugger/start) -(evil-ex-define-cmd "er[rors]" #'+default/diagnostics) - -;;; File operations -(evil-ex-define-cmd "cp" #'+evil:copy-this-file) -(evil-ex-define-cmd "mv" #'+evil:move-this-file) -(evil-ex-define-cmd "rm" #'+evil:delete-this-file) - -;;; Sessions/tabs -(evil-ex-define-cmd "sclear" #'+workspace/kill-session) -(evil-ex-define-cmd "sl[oad]" #'doom/quickload-session) -(evil-ex-define-cmd "ss[ave]" #'doom/quicksave-session) -(evil-ex-define-cmd "tabc[lose]" #'+workspace:delete) -(evil-ex-define-cmd "tabclear" #'doom/kill-all-buffers) -(evil-ex-define-cmd "tabl[ast]" #'+workspace/switch-to-last) -(evil-ex-define-cmd "tabload" #'+workspace:load) -(evil-ex-define-cmd "tabn[ew]" #'+workspace:new) -(evil-ex-define-cmd "tabnext" #'+workspace:switch-next) -(evil-ex-define-cmd "tabprev" #'+workspace:switch-previous) -(evil-ex-define-cmd "tabr[ename]" #'+workspace:rename) -(evil-ex-define-cmd "tabs" #'+workspace/display) -(evil-ex-define-cmd "tabsave" #'+workspace:save) - -;;; Org-mode -(evil-ex-define-cmd "cap[ture]" #'org-capture) - -;;; ibuffer -(when (modulep! :emacs ibuffer) - (evil-ex-define-cmd "buffers" #'ibuffer)) diff --git a/.config/emacs/modules/editor/evil/README.org b/.config/emacs/modules/editor/evil/README.org @@ -1,245 +0,0 @@ -#+title: :editor evil -#+subtitle: The text editor Emacs was missing -#+created: April 08, 2020 -#+since: 2.0.0 - -* Description :unfold: -This holy module brings the Vim editing model to Emacs. - -** Maintainers -- [[doom-user:][@hlissner]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +everywhere :: - Enable evilified keybinds everywhere possible. Uses the [[https://github.com/emacs-evil/evil-collection][evil-collection]] plugin - as a foundation. - -** Packages -- [[doom-package:evil]] -- [[doom-package:evil-args]] -- [[doom-package:evil-collection]] if [[doom-module:+everywhere]] -- [[doom-package:evil-easymotion]] -- [[doom-package:evil-embrace]] -- [[doom-package:evil-escape]] -- [[doom-package:evil-exchange]] -- [[doom-package:evil-indent-plus]] -- [[doom-package:evil-lion]] -- [[doom-package:evil-nerd-commentary]] -- [[doom-package:evil-numbers]] -- [[doom-package:evil-quick-diff]] -- [[doom-package:evil-snipe]] -- [[doom-package:evil-surround]] -- [[doom-package:evil-textobj-anyblock]] -- [[doom-package:evil-vimish-fold]] -- [[doom-package:evil-visualstar]] -- [[doom-package:exato]] - -** Hacks -- The o/O keys will respect and continue commented lines (can be disabled by - setting ~+evil-want-o/O-to-continue-comments~ to ~nil~). -- In visual mode, [[kbd:][*]] and [[kbd:][#]] will search for the current selection instead of the - word-at-point. -- The ~:g[lobal]~ ex command has been modified to highlight matches. -- More of vim's filename modifiers are supported in ex commands (like ~:p~, - ~:p:h~ or ~:t~) than vanilla evil-mode offers. -- A custom filename modifier is available in Doom: ~:P~, which expands to the - project root (throws an error if not in a project). - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** Ported vim plugins -The following vim plugins have been ported to evil: - -| Vim Plugin | Emacs Plugin | Keybind(s) | -|-----------------------+--------------------------------+--------------------------------| -| vim-commentary | evil-nerd-commenter | omap [[kbd:][gc]] | -| vim-easymotion | evil-easymotion | omap [[kbd:][gs]] | -| vim-lion | evil-lion | omap [[kbd:][gl]] / [[kbd:][gL]] | -| vim-seek or vim-sneak | evil-snipe | mmap [[kbd:][s]] / [[kbd:][S]], omap [[kbd:][z]] / [[kbd:][Z]] & [[kbd:][x]] / [[kbd:][X]] | -| vim-surround | evil-embrace and evil-surround | vmap [[kbd:][S]], omap [[kbd:][ys]] | -| vim-unimpaired | (provided by Doom) | [[https://github.com/hlissner/doom-emacs/blob/develop/modules/editor/evil/config.el#L413-L460][see the list]] | - -This module has also ported vim-unimpaired keybinds to Emacs. - -In other modules: -- The [[doom-module::ui neotree]] & [[doom-module::ui treemacs]] modules provide a =NERDTree= equivalent. -- The [[doom-module::editor multiple-cursors]] module contains functionality equal to the - following vim plugins: - - [[doom-package:evil-multiedit]] => [[github:hlissner/vim-multiedit][vim-multiedit]] - - [[doom-package:evil-mc]] => [[https://github.com/terryma/vim-multiple-cursors][vim-multiple-cursors]] - -** Custom Text Objects -This module provides a couple extra text objects, along with the built-in ones. -For posterity, here are the built-in ones: - -- [[kbd:][w W]] words -- [[kbd:][s]] sentences -- [[kbd:][p]] paragraphs -- [[kbd:][b]] parenthesized blocks -- [[kbd:][b ( ) { } [ ] < >]] braces, parentheses and brackets -- [[kbd:][' " `]] quotes -- [[kbd:][t]] tags -- [[kbd:][o]] symbols - -And these are text objects added by this module: -- [[kbd:][a]] C-style function arguments (provided by ~evil-args~) -- [[kbd:][B]] any block delimited by braces, parentheses or brackets (provided by - ~evil-textobj-anyblock~) -- [[kbd:][c]] Comments -- [[kbd:][f]] For functions (but relies on the major mode to have sane definitions for - ~beginning-of-defun-function~ and ~end-of-defun-function~) -- [[kbd:][g]] The entire buffer -- [[kbd:][i j k]] by indentation ([[kbd:][k]] includes one line above; [[kbd:][j]] includes one line above and - below) (provided by ~evil-indent-plus~) -- [[kbd:][q]] For quotes (any kind) -- [[kbd:][u]] For URLs -- [[kbd:][x]] XML attributes (provided by ~exato~) - -** Custom Ex Commands -| Ex Command | Description | -|-----------------------+--------------------------------------------------------------------------------------| -| ~:@~ | Apply macro on selected lines | -| ~:al[ign][!] REGEXP~ | Align text to the first match of REGEXP. If BANG, align all matches on each line | -| ~:cp[!] NEWPATH~ | Copy the current file to NEWPATH | -| ~:dash QUERY~ | Look up QUERY (or the symbol at point) in dash docsets | -| ~:dehtml [INPUT]~ | HTML decode selected text / inserts result if INPUT is given | -| ~:enhtml [INPUT]~ | HTML encode selected text / inserts result if INPUT is given | -| ~:iedit REGEXP~ | Invoke iedit on all matches for REGEXP | -| ~:k[ill]all[!]~ | Kill all buffers (if BANG, affect buffer across workspaces) | -| ~:k[ill]b~ | Kill all buried buffers | -| ~:k[ill]m[!] REGEXP~ | Kill buffers whose name matches REGEXP (if BANG, affect buffers across workspaces) | -| ~:k[ill]o~ | Kill all other buffers besides the selected one | -| ~:k[ill]~ | Kill the current buffer | -| ~:lo[okup] QUERY~ | Look up QUERY on an online search engine | -| ~:mc REGEXP~ | Invoke multiple cursors on all matches for REGEXP | -| ~:mv[!] NEWPATH~ | Move the current file to NEWPATH | -| ~:na[rrow]~ | Narrow the buffer to the selection | -| ~:pad~ | Open a scratch pad for running code quickly | -| ~:ral[ign][!] REGEXP~ | Right-Align text that matches REGEXP. If BANG, align all matches on each line | -| ~:repl~ | Open a REPL and/or copy the current selection to it | -| ~:retab~ | Convert indentation to the default within the selection | -| ~:rev[erse]~ | Reverse the selected lines | -| ~:rm[!] [PATH]~ | Delete the current buffer's file and buffer | -| ~:tcd[!]~ | Send =cd X= to tmux. X = the project root if BANG, X = ~default-directory~ otherwise | - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -[[doom-report:][Report an issue?]] - -** Can't access the universal argument key ([[kbd:][C-u]]) -For maximum Vim emulation, this module commandeers the C-u key for scrolling (as -it does in Vim). The same goes for [[kbd:][C-u]] in insert mode (which deletes to BOL). In -both cases the universal argument has been moved to [[kbd:][<leader> u]]. - -To undo this, use: -#+begin_src emacs-lisp -;; add to $DOOMDIR/config.el -(setq! evil-want-C-u-scroll nil - evil-want-C-u-delete nil) -#+end_src - -** The [[kbd:][s]]/[[kbd:][S]] keys behave differently from Vim -Doom replaces the [[kbd:][s]] and [[kbd:][S]] keys with the [[doom-package:evil-snipe]] package (a port of -vim-seek/vim-sneak for 2-character versions of f/F/t/T). - -To disable evil-snipe on s/S, you can either: -1. Disable ~evil-snipe-mode~ by adding ~(remove-hook 'doom-first-input-hook - #'evil-snipe-mode)~ to =$DOOMDIR/config.el=, -2. Or disable [[doom-package:evil-snipe]] completely with ~(package! evil-snipe :disable t)~ - added to =$DOOMDIR/packages.el=, but this will also disable incremental - highlighting for the f/F/t/T motions keys. -3. Or use [[kbd:][cl]] and [[kbd:][cc]], respectively; they do the same thing. - -** The [[kbd:][Y]] key behaves differently from Vim (should yank the whole line) -Doom changes the behavior of the [[kbd:][Y]] key in normal mode to yank-to-EOL (equivalent -to [[kbd:][y$]]). This was to make it consistent with the [[kbd:][C]] and [[kbd:][D]] capital operators, and -because it was redundant with [[kbd:][yy]], which is easier to type than [[kbd:][y$]]. - -If you prefer the old behavior, it can be reversed with: -#+begin_src emacs-lisp -;; add to $DOOMDIR/config.el -(setq! evil-want-Y-yank-to-eol nil) -#+end_src - -* Frequently asked questions -[[doom-suggest-faq:][Ask a question?]] - -** How do I remove evil? -:PROPERTIES: -:ID: f3925da6-5f0b-4d11-aa08-7bb58bea1982 -:END: -1. [[id:01cffea4-3329-45e2-a892-95a384ab2338][Disable this module]]. -2. Run ~$ doom sync~ to clean up lingering dependencies and regenerate your - autoloads files. -3. [OPTIONAL] Change ~doom-leader-alt-key~ and ~doom-localleader-alt-key~. These - are bound to [[kbd:][C-c]] and [[kbd:][C-c l]] by default. - -#+begin_quote - 🚧 Ignore ~doom-leader-key~ and ~doom-localleader-key~, they don't apply to - non-evil sessions. -#+end_quote - -Evil-specific configuration and keybindings (defined with ~map!~) will be -ignored without [[doom-module::editor evil]] present (and omitted when byte-compiling). - -** Include underscores in evil word motions? -A more in-depth answer and explanation for this can be found [[https://evil.readthedocs.io/en/latest/faq.html#underscore-is-not-a-word-character][in Evil's -documentation]]. - -TL;DR If you want the underscore to be recognized as word character, you can -modify its entry in the syntax-table: -#+begin_src emacs-lisp -(modify-syntax-entry ?_ "w") -#+end_src - -This gives the underscore the word syntax-class. You can use a mode-hook to -modify the syntax-table in all buffers of some mode, e.g. -#+begin_src emacs-lisp -;; For python -(add-hook! 'python-mode-hook (modify-syntax-entry ?_ "w")) -;; For ruby -(add-hook! 'ruby-mode-hook (modify-syntax-entry ?_ "w")) -;; For Javascript -(add-hook! 'js2-mode-hook (modify-syntax-entry ?_ "w")) -#+end_src - -** How do I disable synchronization between the kill ring and system clipboard? - -In vim, operations that put or delete text (kill and yank in Emacs terminology) -act on the unnamed register by default. The unnamed register unrelated the -system clipboard. Evil uses the kill ring instead of the unnamed register. As -the kill ring is synchronized with the system clipboard by default, operations -like [[kbd:][dd]] or [[kbd:][cw]] place the killed text in the system clipboard, surprisingly so for -users who are used to the vim behavior. - -The synchronization between the system clipboard and kill ring can be disabled, -making these operations behave closer to their vim counterparts: -#+begin_src emacs-lisp -(setq select-enable-clipboard nil) -#+end_src - -Like in vim, the clipboard can still be accessed by using the [[kbd:][+]] register, e.g. -[[kbd:]["+dd]] or [[kbd:]["+cw]]. - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/editor/evil/autoload/advice.el b/.config/emacs/modules/editor/evil/autoload/advice.el @@ -1,233 +0,0 @@ -;;; editor/evil/autoload/advice.el -*- lexical-binding: t; -*- - -;;;###autoload -(defun +evil-escape-a (&rest _) - "Call `doom/escape' if `evil-force-normal-state' is called interactively." - (when (called-interactively-p 'any) - (call-interactively #'doom/escape))) - -;;;###autoload -(defun +evil-replace-filename-modifiers-a (file-name) - "Take a path and resolve any vim-like filename modifiers in it. This adds -support for most vim file modifiers, as well as: - - %:P Resolves to `doom-project-root'. - -See http://vimdoc.sourceforge.net/htmldoc/cmdline.html#filename-modifiers for -more information on modifiers." - (let ((origin-buffer (current-buffer)) - case-fold-search) - (with-temp-buffer - (let ((buffer-file-name (buffer-file-name origin-buffer))) - (save-excursion (insert file-name)) - (while (re-search-forward "\\(^\\|[^\\\\]\\)\\(\\([%#]\\)\\(:\\([PphtreS~.]\\|g?s\\)\\)*\\)" nil t) - (if (null buffer-file-name) - (replace-match (match-string 1) t t nil 2) - (let ((beg (match-beginning 2)) - (end (match-end 3)) - (path (pcase (match-string 3) - ("%" (file-relative-name buffer-file-name default-directory)) - ("#" (and (other-buffer origin-buffer) - (buffer-file-name (other-buffer origin-buffer))))))) - (save-match-data - (goto-char beg) - (while (re-search-forward ":\\([PphtreS~.]\\|g?s\\)" (+ (point) 3) t) - (let* ((modifier (match-string 1)) - (global (string-prefix-p "gs" modifier))) - (when global - (setq modifier (substring modifier 1))) - (setq end (match-end 1) - path - (pcase (and path (substring modifier 0 1)) - (`nil "") - ("p" (expand-file-name path)) - ("~" (concat "~/" (file-relative-name path "~"))) - ("." (file-relative-name path)) - ("t" (file-name-nondirectory (directory-file-name path))) - ("r" (file-name-sans-extension path)) - ("e" (file-name-extension path)) - ("S" (shell-quote-argument path)) - ("h" - (let ((parent (file-name-directory (expand-file-name path)))) - (unless (file-equal-p path parent) - (if (file-name-absolute-p path) - (directory-file-name parent) - (file-relative-name parent))))) - ("s" - (if (featurep 'evil) - (when-let (args (evil-delimited-arguments (substring modifier 1) 2)) - (let ((pattern (evil-transform-vim-style-regexp (car args))) - (replace (cadr args))) - (replace-regexp-in-string - (if global pattern (concat "\\(" pattern "\\).*\\'")) - (evil-transform-vim-style-regexp replace) path t t - (unless global 1)))) - path)) - ("P" - (let ((project-root (doom-project-root (file-name-directory (expand-file-name path))))) - (unless project-root - (user-error "Not in a project")) - (abbreviate-file-name project-root))))) - ;; strip trailing slash, if applicable - (or (string-empty-p path) - (not (equal (substring path -1) "/")) - (setq path (substring path 0 -1)))))) - (replace-match path t t nil 2)))) - (replace-regexp-in-string "\\\\\\([#%]\\)" "\\1" (buffer-string) t))))) - -(defun +evil--insert-newline (&optional above _noextranewline) - (let ((pos (save-excursion (beginning-of-line-text) (point))) - comment-auto-fill-only-comments) - (require 'smartparens) - (evil-narrow-to-field - (if above - (if (save-excursion (nth 4 (sp--syntax-ppss pos))) - (evil-save-goal-column - (setq evil-auto-indent nil) - (goto-char pos) - (let ((ws (abs (skip-chars-backward " \t")))) - ;; FIXME oh god why - (save-excursion - (if comment-line-break-function - (funcall comment-line-break-function nil) - (comment-indent-new-line)) - (when (and (derived-mode-p 'c-mode 'c++-mode 'objc-mode 'java-mode 'js2-mode) - (eq (char-after) ?/)) - (insert "*")) - (insert - (make-string (max 0 (+ ws (skip-chars-backward " \t"))) - 32))) - (insert (make-string (max 1 ws) 32)))) - (evil-move-beginning-of-line) - (insert (if use-hard-newlines hard-newline "\n")) - (forward-line -1) - (back-to-indentation)) - (evil-move-end-of-line) - (cond ((sp-point-in-comment pos) - (setq evil-auto-indent nil) - (if comment-line-break-function - (funcall comment-line-break-function nil) - (comment-indent-new-line))) - ;; TODO Find a better way to do this - ((and (eq major-mode 'haskell-mode) - (fboundp 'haskell-indentation-newline-and-indent)) - (setq evil-auto-indent nil) - (haskell-indentation-newline-and-indent)) - (t - (insert (if use-hard-newlines hard-newline "\n")) - (back-to-indentation))))))) - -;;;###autoload -(defun +evil--insert-newline-below-and-respect-comments-a (fn count) - (if (or (not +evil-want-o/O-to-continue-comments) - (not (eq this-command 'evil-open-below)) - (evil-insert-state-p) - (evil-emacs-state-p)) - (funcall fn count) - (letf! (defun evil-insert-newline-below () (+evil--insert-newline)) - (let ((evil-auto-indent evil-auto-indent)) - (funcall fn count))))) - -;;;###autoload -(defun +evil--insert-newline-above-and-respect-comments-a (fn count) - (if (or (not +evil-want-o/O-to-continue-comments) - (not (eq this-command 'evil-open-above)) - (evil-insert-state-p) - (evil-emacs-state-p)) - (funcall fn count) - (letf! (defun evil-insert-newline-above () (+evil--insert-newline 'above)) - (let ((evil-auto-indent evil-auto-indent)) - (funcall fn count))))) - -;;;###autoload (autoload '+evil-window-split-a "editor/evil/autoload/advice" nil t) -(evil-define-command +evil-window-split-a (&optional count file) - "Same as `evil-window-split', but correctly updates the window history." - :repeat nil - (interactive "P<f>") - ;; HACK This ping-ponging between the destination and source windows is to - ;; update the window focus history, so that, if you close either split - ;; afterwards you won't be sent to some random window. - (let ((origwin (selected-window)) - window-selection-change-functions) - (select-window (split-window origwin count 'below)) - (unless evil-split-window-below - (select-window origwin))) - (run-hook-with-args 'window-selection-change-functions nil) - (recenter) - (when (and (not count) evil-auto-balance-windows) - (balance-windows (window-parent))) - (if file (evil-edit file))) - -;;;###autoload (autoload '+evil-window-vsplit-a "editor/evil/autoload/advice" nil t) -(evil-define-command +evil-window-vsplit-a (&optional count file) - "Same as `evil-window-split', but correctly updates the window history." - :repeat nil - (interactive "P<f>") - ;; HACK This ping-ponging between the destination and source windows is to - ;; update the window focus history, so that, if you close either split - ;; afterwards you won't be sent to some random window. - (let ((origwin (selected-window)) - window-selection-change-functions) - (select-window (split-window origwin count 'right)) - (unless evil-vsplit-window-right - (select-window origwin))) - (run-hook-with-args 'window-selection-change-functions nil) - (recenter) - (when (and (not count) evil-auto-balance-windows) - (balance-windows (window-parent))) - (if file (evil-edit file))) - -;;;###autoload (autoload '+evil-join-a "editor/evil/autoload/advice" nil nil) -(defun +evil-join-a (fn beg end) - "Join the selected lines. - -This advice improves on `evil-join' by removing comment delimiters when joining -commented lines, without `fill-region-as-paragraph'. - -Adapted from https://github.com/emacs-evil/evil/issues/606" - (if-let* (((not (= (line-end-position) (point-max)))) - (cend (save-excursion (goto-char end) (line-end-position))) - (cbeg (save-excursion - (goto-char beg) - (and (doom-point-in-comment-p - (save-excursion - (goto-char (line-beginning-position 2)) - (skip-syntax-forward " \t") - (point))) - (or (comment-search-backward (line-beginning-position) t) - (comment-search-forward (line-end-position) t) - (and (doom-point-in-comment-p beg) - (stringp comment-continue) - (or (search-forward comment-continue (line-end-position) t) - beg))))))) - (let* ((count (count-lines beg end)) - (count (if (> count 1) (1- count) count)) - (fixup-mark (make-marker))) - (uncomment-region (line-beginning-position 2) - (save-excursion - (goto-char cend) - (line-end-position 0))) - (unwind-protect - (dotimes (_ count) - (join-line 1) - (save-match-data - (when (or (and comment-continue - (not (string-empty-p comment-continue)) - (looking-at (concat "\\(\\s-*" (regexp-quote comment-continue) "\\) "))) - (and comment-start-skip - (not (string-empty-p comment-start-skip)) - (looking-at (concat "\\(\\s-*" comment-start-skip "\\)")))) - (replace-match "" t nil nil 1) - (just-one-space)))) - (set-marker fixup-mark nil))) - ;; But revert to the default we're not in a comment, where - ;; `fill-region-as-paragraph' is too greedy. - (funcall fn beg end))) - -;;;###autoload -(defun +evil--fix-dabbrev-in-minibuffer-h () - "Make `try-expand-dabbrev' from `hippie-expand' work in minibuffer. See -`he-dabbrev-beg', so we need to redefine syntax for '/'." - (set-syntax-table (let* ((table (make-syntax-table))) - (modify-syntax-entry ?/ "." table) - table))) diff --git a/.config/emacs/modules/editor/evil/autoload/embrace.el b/.config/emacs/modules/editor/evil/autoload/embrace.el @@ -1,40 +0,0 @@ -;;; editor/evil/autoload/embrace.el -*- lexical-binding: t; -*- - -;;;###autoload -(defun +evil--embrace-get-pair (char) - (if-let* ((pair (cdr-safe (assoc (string-to-char char) evil-surround-pairs-alist)))) - pair - (if-let* ((pair (assoc-default char embrace--pairs-list))) - (if-let* ((real-pair (and (functionp (embrace-pair-struct-read-function pair)) - (funcall (embrace-pair-struct-read-function pair))))) - real-pair - (cons (embrace-pair-struct-left pair) (embrace-pair-struct-right pair))) - (cons char char)))) - -;;;###autoload -(defun +evil--embrace-escaped () - "Backslash-escaped surround character support for embrace." - (let ((char (read-char "\\"))) - (if (eq char 27) - (cons "" "") - (let* ((pair (+evil--embrace-get-pair (string char))) - (escape (if (sp-point-in-string) "\\\\" "\\")) - (escape (format "\\1%s" (regexp-quote escape)))) - (cons (replace-regexp-in-string "^\\( *\\)" escape (car pair)) - (replace-regexp-in-string "^\\( *\\)" escape (cdr pair))))))) - -;;;###autoload -(defun +evil--embrace-latex () - "LaTeX command support for embrace." - (cons (format "\\%s{" (read-string "\\")) "}")) - -;;;###autoload -(defun +evil--embrace-elisp-fn () - "Elisp function support for embrace." - (cons (format "(%s " (or (read-string "(") "")) ")")) - -;;;###autoload -(defun +evil--embrace-angle-brackets () - "Type/generic angle brackets." - (cons (format "%s<" (or (read-string "") "")) - ">")) diff --git a/.config/emacs/modules/editor/evil/autoload/evil.el b/.config/emacs/modules/editor/evil/autoload/evil.el @@ -1,185 +0,0 @@ -;; editor/evil/autoload/evil.el -*- lexical-binding: t; -*- - -;;;###autodef -(defun set-evil-initial-state! (modes state) - "Set the initialize STATE of MODES using `evil-set-initial-state'." - (declare (indent defun)) - (after! evil - (if (listp modes) - (dolist (mode (ensure-list modes)) - (evil-set-initial-state mode state)) - (evil-set-initial-state modes state)))) - - -;; -;;; Interactive commands - -;;;###autoload -(defun +evil/shift-right () - "vnoremap < <gv" - (interactive) - (call-interactively #'evil-shift-right) - (evil-normal-state) - (evil-visual-restore)) - -;;;###autoload -(defun +evil/shift-left () - "vnoremap > >gv" - (interactive) - (call-interactively #'evil-shift-left) - (evil-normal-state) - (evil-visual-restore)) - -;;;###autoload -(defun +evil/alt-paste () - "Call `evil-paste-after' but invert `evil-kill-on-visual-paste'. -By default, this replaces the selection with what's in the clipboard without -replacing its contents." - (interactive) - (let ((evil-kill-on-visual-paste (not evil-kill-on-visual-paste))) - (call-interactively #'evil-paste-after))) - -(defun +evil--window-swap (direction) - "Move current window to the next window in DIRECTION. -If there are no windows there and there is only one window, split in that -direction and place this window there. If there are no windows and this isn't -the only window, use evil-window-move-* (e.g. `evil-window-move-far-left')." - (when (window-dedicated-p) - (user-error "Cannot swap a dedicated window")) - (let* ((this-window (selected-window)) - (this-buffer (current-buffer)) - (that-window (windmove-find-other-window direction nil this-window)) - (that-buffer (window-buffer that-window))) - (when (or (minibufferp that-buffer) - (window-dedicated-p this-window)) - (setq that-buffer nil that-window nil)) - (if (not (or that-window (one-window-p t))) - (funcall (pcase direction - ('left #'evil-window-move-far-left) - ('right #'evil-window-move-far-right) - ('up #'evil-window-move-very-top) - ('down #'evil-window-move-very-bottom))) - (unless that-window - (setq that-window - (split-window this-window nil - (pcase direction - ('up 'above) - ('down 'below) - (_ direction)))) - (with-selected-window that-window - (switch-to-buffer (doom-fallback-buffer))) - (setq that-buffer (window-buffer that-window))) - (window-swap-states this-window that-window) - (select-window that-window)))) - -;;;###autoload -(defun +evil/window-move-left () - "Swap windows to the left." - (interactive) (+evil--window-swap 'left)) -;;;###autoload -(defun +evil/window-move-right () - "Swap windows to the right" - (interactive) (+evil--window-swap 'right)) -;;;###autoload -(defun +evil/window-move-up () - "Swap windows upward." - (interactive) (+evil--window-swap 'up)) -;;;###autoload -(defun +evil/window-move-down () - "Swap windows downward." - (interactive) (+evil--window-swap 'down)) - -;;;###autoload -(defun +evil/window-split-and-follow () - "Split current window horizontally, then focus new window. -If `evil-split-window-below' is non-nil, the new window isn't focused." - (interactive) - (let ((evil-split-window-below (not evil-split-window-below))) - (call-interactively #'evil-window-split))) - -;;;###autoload -(defun +evil/window-vsplit-and-follow () - "Split current window vertically, then focus new window. -If `evil-vsplit-window-right' is non-nil, the new window isn't focused." - (interactive) - (let ((evil-vsplit-window-right (not evil-vsplit-window-right))) - (call-interactively #'evil-window-vsplit))) - -;;;###autoload (autoload '+evil:apply-macro "editor/evil/autoload/evil" nil t) -(evil-define-operator +evil:apply-macro (beg end) - "Apply macro to each line." - :move-point nil - (interactive "<r>") - (let ((register (or evil-this-register (read-char))) - macro) - (cond ((or (and (eq register ?@) (eq evil-last-register ?:)) - (eq register ?:)) - (setq macro (lambda () (evil-ex-repeat nil)) - evil-last-register ?:)) - ((eq register ?@) - (unless evil-last-register - (user-error "No previously executed keyboard macro.")) - (setq macro (evil-get-register evil-last-register t))) - ((setq macro (evil-get-register register t) - evil-last-register register))) - (unless macro - (user-error "No macro recorded in %c register" register)) - (evil-change-state 'normal) - (evil-with-single-undo - (let ((lines (count-lines beg end))) - (message "Applied macro in %c register %d times" register lines) - (apply-macro-to-region-lines beg end macro) - (message "Applied macro in %c register %d times...DONE" register lines))))) - -;;;###autoload (autoload '+evil:retab "editor/evil/autoload/evil" nil t) -(evil-define-operator +evil:retab (&optional beg end) - "Wrapper around `doom/retab'." - :motion nil :move-point nil :type line - (interactive "<r>") - (doom/retab nil beg end)) - -;;;###autoload (autoload '+evil:narrow-buffer "editor/evil/autoload/evil" nil t) -(evil-define-operator +evil:narrow-buffer (beg end &optional bang) - "Narrow the buffer to region between BEG and END. - -Widens narrowed buffers first. If BANG, use indirect buffer clones instead." - :move-point nil - (interactive "<r><!>") - (if (not bang) - (if (buffer-narrowed-p) - (widen) - (narrow-to-region beg end)) - (when (buffer-narrowed-p) - (doom/widen-indirectly-narrowed-buffer t)) - (doom/narrow-buffer-indirectly beg end))) - -;;;###autoload (autoload '+evil:yank-unindented "editor/evil/autoload/evil" nil t) -(evil-define-operator +evil:yank-unindented (beg end _type _register _yank-handler) - "Saves the (reindented) characters in motion into the kill-ring." - :move-point nil - :repeat nil - (interactive "<R><x><y>") - (let ((indent (save-excursion (goto-char beg) (current-indentation))) - (text (buffer-substring beg end))) - (with-temp-buffer - (insert text) - (indent-rigidly (point-min) (point-max) (- indent)) - (evil-yank (point-min) (point-max))))) - - -;; -;;; wgrep - -;;;###autoload (autoload '+evil-delete "editor/evil/autoload/evil" nil t) -(evil-define-operator +evil-delete (beg end type register yank-handler) - "A wrapper around `evil-delete' for `wgrep' buffers that will invoke -`wgrep-mark-deletion' on lines you try to delete." - (interactive "<R><x><y>") - (condition-case _ex - (evil-delete beg end type register yank-handler) - ('text-read-only - (evil-apply-on-block - (lambda (beg _) - (goto-char beg) - (call-interactively #'wgrep-mark-deletion)) - beg (1- end) nil)))) diff --git a/.config/emacs/modules/editor/evil/autoload/ex.el b/.config/emacs/modules/editor/evil/autoload/ex.el @@ -1,192 +0,0 @@ -;;; editor/evil/autoload/ex.el -*- lexical-binding: t; -*- - -(defvar +evil--flag nil) - -(defun +evil--ex-match-init (name &optional face update-hook) - (with-current-buffer evil-ex-current-buffer - (cond - ((eq +evil--flag 'start) - (evil-ex-make-hl name - :face (or face 'evil-ex-lazy-highlight) - :update-hook (or update-hook #'evil-ex-pattern-update-ex-info)) - (setq +evil--flag 'update)) - - ((eq +evil--flag 'stop) - (evil-ex-delete-hl name))))) - -(defun +evil--ex-buffer-match (arg &optional hl-name flags beg end) - (when (and (eq +evil--flag 'update) - evil-ex-substitute-highlight-all - (not (zerop (length arg)))) - (condition-case lossage - (let* ((pattern (evil-ex-make-substitute-pattern - arg - (or flags (list)))) - (range (or (evil-copy-range evil-ex-range) - (evil-range (or beg (line-beginning-position)) - (or end (line-end-position)) - 'line - :expanded t)))) - (evil-expand-range range) - (evil-ex-hl-set-region hl-name - (max (evil-range-beginning range) (window-start)) - (min (evil-range-end range) (window-end))) - (evil-ex-hl-change hl-name pattern)) - (end-of-file - (evil-ex-pattern-update-ex-info nil "incomplete replacement")) - (user-error - (evil-ex-pattern-update-ex-info nil (format "?%s" lossage)))))) - -;;;###autoload -(defun +evil-ex-regexp-match (flag &optional arg invert) - (let ((hl-name 'evil-ex-buffer-match) - (+evil--flag flag)) - (with-selected-window (minibuffer-selected-window) - (+evil--ex-match-init hl-name) - (cl-destructuring-bind (&optional arg flags) - (evil-delimited-arguments arg 2) - (let ((evil-ex-substitute-global - (if invert - (not evil-ex-substitute-global) - evil-ex-substitute-global))) - (+evil--ex-buffer-match - arg hl-name (string-to-list flags))))))) - - -;; -;;; Ex Commands - -;;;###autoload (autoload '+evil:align "editor/evil/autoload/ex" nil t) -(evil-define-command +evil:align (beg end pattern &optional flags) - "Ex interface to `align-regexp'. - -PATTERN is a vim-style regexp. FLAGS is an optional string of characters. -Supports the following flags: - -g Repeat alignment on all matches in each line" - (interactive "<r><//>") - (align-regexp - beg end - (concat "\\(\\s-*\\)" (evil-transform-vim-style-regexp pattern)) - 1 1 (memq ?g flags))) - -;;;###autoload (autoload '+evil:align-right "editor/evil/autoload/ex" nil t) -(evil-define-command +evil:align-right (beg end pattern &optional flags) - "Ex interface to `align-regexp' that right-aligns matches. - -PATTERN is a vim-style regexp. FLAGS is an optional string of characters. -Supports the following flags: - -g Repeat alignment on all matches in each line" - (interactive "<r><//>") - (align-regexp - beg end - (concat "\\(" (evil-transform-vim-style-regexp pattern) "\\)") - -1 1 (memq ?g flags))) - -;; ;;;###autoload (autoload '+evil:sort "editor/evil/autoload/ex" nil nil) -;; (evil-define-command +evil:sort (beg end &optional pattern flags reverse) -;; (interactive "<r><//><!>")) - -;;;###autoload (autoload '+evil:open-scratch-buffer "editor/evil/autoload/ex" nil t) -(evil-define-operator +evil:open-scratch-buffer (bang) - (interactive "<!>") - (doom/open-scratch-buffer bang)) - -;;;###autoload (autoload '+evil:pwd "editor/evil/autoload/ex" nil t) -(evil-define-command +evil:pwd (bang) - "Display the current working directory. If BANG, copy it to your clipboard." - (interactive "<!>") - (if (not bang) - (pwd) - (kill-new default-directory) - (message "Copied to clipboard"))) - -;;;###autoload (autoload '+evil:make "editor/evil/autoload/ex" nil t) -(evil-define-command +evil:make (arguments &optional bang) - "Run make with ARGUMENTS. -If BANG is non-nil, open compilation output in a comint buffer. - -If BANG, then run ARGUMENTS as a full command. This command understands vim file -modifiers (like %:p:h). See `+evil-replace-filename-modifiers-a' for details." - (interactive "<sh><!>") - (let ((compile-command "make")) - (+evil:compile (if (stringp arguments) - (evil-ex-replace-special-filenames arguments) - "") - bang))) - -;;;###autoload (autoload '+evil:compile "editor/evil/autoload/ex" nil t) -(evil-define-command +evil:compile (arguments &optional bang) - "Run `compile-command' with ARGUMENTS. -If BANG is non-nil, open compilation output in a comint buffer. - -This command understands vim file modifiers (like %:p:h). See -`+evil-replace-filename-modifiers-a' for details." - (interactive "<sh><!>") - (compile (evil-ex-replace-special-filenames - (format "%s %s" - (eval compile-command) - arguments)) - bang)) - -;;;###autoload (autoload '+evil:reverse-lines "editor/evil/autoload/ex" nil t) -(evil-define-command +evil:reverse-lines (beg end) - "Reverse lines between BEG and END." - (interactive "<r>") - (reverse-region beg end)) - -;;;###autoload (autoload '+evil:cd "editor/evil/autoload/ex" nil t) -(evil-define-command +evil:cd (&optional path) - "Change `default-directory' with `cd'." - (interactive "<f>") - (let ((path (or path "~"))) - (cd path) - (message "Changed directory to '%s'" (abbreviate-file-name (expand-file-name path))))) - -;;;###autoload (autoload '+evil:kill-all-buffers "editor/evil/autoload/ex" nil t) -(evil-define-command +evil:kill-all-buffers (&optional bang) - "Kill all buffers. If BANG, kill current session too." - (interactive "<!>") - (if (and bang (fboundp '+workspace/kill-session)) - (+workspace/kill-session) - (call-interactively #'doom/kill-all-buffers))) - -;;;###autoload (autoload '+evil:kill-matching-buffers "editor/evil/autoload/ex" nil t) -(evil-define-command +evil:kill-matching-buffers (&optional bang pattern) - "Kill all buffers matching PATTERN regexp. If BANG, only match project -buffers." - (interactive "<a>") - (doom/kill-matching-buffers - pattern (if bang (doom-project-buffer-list)))) - -;;;###autoload (autoload '+evil:help "editor/evil/autoload/ex" nil t) -(evil-define-command +evil:help (&optional bang query) - "Look up documentation for QUERY. - -If QUERY is in the format of an ex command, it will map it to the underlying -function and open its documentation with `helpful-function'. Otherwise, it will -search for it with `apropos'. - -If QUERY is empty, this runs the equivalent of 'M-x apropos'. If BANG is -non-nil, a search is preformed against Doom's manual (with -`doom/help-search-headings')." - (interactive "<!><a>") - (if bang - (doom/help-search-headings query) - (save-match-data - (cond ((or (null query) (string-empty-p (string-trim query))) - (call-interactively - (or (command-remapping #'apropos) - #'apropos))) - ((string-match "^ *:\\([^ ]+\\)$" query) - (helpful-function - (evil-ex-completed-binding (match-string 1 query)))) - ((message "Searching for %S, this may take a while..." query) - (apropos query t)))))) - -;;;###autoload (autoload '+evil:read "editor/evil/autoload/ex" nil t) -(evil-define-command +evil:read (count file) - "Alternative version of `evil-read' that replaces filename modifiers in FILE." - (interactive "P<fsh>") - (evil-read count (evil-ex-replace-special-filenames file))) diff --git a/.config/emacs/modules/editor/evil/autoload/files.el b/.config/emacs/modules/editor/evil/autoload/files.el @@ -1,31 +0,0 @@ -;;; editor/evil/autoload/files.el -*- lexical-binding: t; -*- - -;;;###autoload (autoload '+evil:delete-this-file "editor/evil/autoload/files" nil t) -(evil-define-command +evil:delete-this-file (&optional filename force-p) - "Delete FILENAME (defaults to the file associated with current buffer) and -kills the buffer. If FORCE-P, force the deletion (don't ask for confirmation)." - :repeat nil - (interactive "<f><!>") - (doom/delete-this-file filename force-p)) - -;;;###autoload (autoload '+evil:move-this-file "editor/evil/autoload/files" nil t) -(evil-define-command +evil:move-this-file (new-path &optional force-p) - "Move current buffer's file to NEW-PATH. Replaces %, # and other vim-esque -filename modifiers (see `+evil*ex-replace-special-filenames'). If FORCE-P, -overwrite the destination file if it exists, without confirmation." - :repeat nil - (interactive "<f><!>") - (when (or (not new-path) (string-empty-p new-path)) - (user-error "No new path was specified")) - (doom/move-this-file new-path force-p)) - -;;;###autoload (autoload '+evil:copy-this-file "editor/evil/autoload/files" nil t) -(evil-define-command +evil:copy-this-file (new-path &optional force-p) - "Copy current buffer's file to NEW-PATH. Replaces %, # and other vim-esque -filename modifiers (see `+evil*ex-replace-special-filenames'). If FORCE-P, -overwrite the destination file if it exists, without confirmation." - :repeat nil - (interactive "<f><!>") - (when (or (not new-path) (string-empty-p new-path)) - (user-error "No new path was specified")) - (doom/copy-this-file new-path force-p)) diff --git a/.config/emacs/modules/editor/evil/autoload/textobjects.el b/.config/emacs/modules/editor/evil/autoload/textobjects.el @@ -1,68 +0,0 @@ -;;; editor/evil/autoload/textobjects.el -*- lexical-binding: t; -*- - -;;;###autoload (autoload '+evil:whole-buffer-txtobj "editor/evil/autoload/textobjects" nil nil) -(evil-define-text-object +evil:whole-buffer-txtobj (count &optional _beg _end type) - "Text object to select the whole buffer." - (evil-range (point-min) (point-max) type)) - -;;;###autoload (autoload '+evil:defun-txtobj "editor/evil/autoload/textobjects" nil nil) -(evil-define-text-object +evil:defun-txtobj (count &optional _beg _end type) - "Text object to select the top-level Lisp form or function definition at -point." - (cl-destructuring-bind (beg . end) - (bounds-of-thing-at-point 'defun) - (evil-range beg end type))) - -;;;###autoload (autoload '+evil:inner-url-txtobj "editor/evil/autoload/textobjects" nil nil) -(evil-define-text-object +evil:inner-url-txtobj (count &optional _beg _end type) - "Text object to select the inner url at point. - -This excludes the protocol and querystring." - (cl-destructuring-bind (beg . end) - (bounds-of-thing-at-point 'url) - (evil-range - (save-excursion - (goto-char beg) - (re-search-forward "://" end t)) - (save-excursion - (goto-char end) - (- (if-let (pos (re-search-backward "[?#]" beg t)) - pos - end) - (if (evil-visual-state-p) - 1 - 0))) - type))) - -;;;###autoload (autoload '+evil:outer-url-txtobj "editor/evil/autoload/textobjects" nil nil) -(evil-define-text-object +evil:outer-url-txtobj (count &optional _beg _end type) - "Text object to select the whole url at point." - (cl-destructuring-bind (beg . end) - (bounds-of-thing-at-point 'url) - (evil-range - beg (- end (if (evil-visual-state-p) 1 0)) - type))) - -;;;###autoload (autoload '+evil:inner-any-quote "editor/evil/autoload/textobjects" nil nil) -(evil-define-text-object +evil:inner-any-quote (count &optional beg end type) - "Select the closest inner quote." - (require 'evil-textobj-anyblock) - (let ((evil-textobj-anyblock-blocks - '(("'" . "'") - ("\"" . "\"") - ("`" . "`") - ("‘" . "’") - ("“" . "”")))) - (evil-textobj-anyblock--make-textobj beg end type count nil))) - -;;;###autoload (autoload '+evil:outer-any-quote "editor/evil/autoload/textobjects" nil nil) -(evil-define-text-object +evil:outer-any-quote (count &optional beg end type) - "Select the closest outer quote." - (require 'evil-textobj-anyblock) - (let ((evil-textobj-anyblock-blocks - '(("'" . "'") - ("\"" . "\"") - ("`" . "`") - ("‘" . "’") - ("“" . "”")))) - (evil-textobj-anyblock--make-textobj beg end type count t))) diff --git a/.config/emacs/modules/editor/evil/autoload/unimpaired.el b/.config/emacs/modules/editor/evil/autoload/unimpaired.el @@ -1,200 +0,0 @@ -;;; editor/evil/autoload/unimpaired.el -*- lexical-binding: t; -*- - -;; These are ported from vim-unimpaired https://github.com/tpope/vim-unimpaired -;; and bound in the :config default module (in +evil-bindings.el). - -;; -;;; Next/Previous commands - -;;;###autoload -(defun +evil/next-beginning-of-method (count) - "Jump to the beginning of the COUNT-th method/function after point." - (interactive "p") - (beginning-of-defun (- count))) - -;;;###autoload -(defun +evil/previous-beginning-of-method (count) - "Jump to the beginning of the COUNT-th method/function before point." - (interactive "p") - (beginning-of-defun count)) - -;;;###autoload -(defalias #'+evil/next-end-of-method #'end-of-defun - "Jump to the end of the COUNT-th method/function after point.") - -;;;###autoload -(defun +evil/previous-end-of-method (count) - "Jump to the end of the COUNT-th method/function before point." - (interactive "p") - (end-of-defun (- count))) - -;;;###autoload -(defun +evil/next-preproc-directive (count) - "Jump to the COUNT-th preprocessor directive after point. - -By default, this only recognizes C preproc directives. To change this see -`+evil-preprocessor-regexp'." - (interactive "p") - ;; TODO More generalized search, to support directives in other languages? - (if (re-search-forward +evil-preprocessor-regexp nil t count) - (goto-char (match-beginning 0)) - (user-error "No preprocessor directives %s point" - (if (> count 0) "after" "before")))) - -;;;###autoload -(defun +evil/previous-preproc-directive (count) - "Jump to the COUNT-th preprocessor directive before point. - -See `+evil/next-preproc-directive' for details." - (interactive "p") - (+evil/next-preproc-directive (- count))) - -;;;###autoload -(defun +evil/next-comment (count) - "Jump to the beginning of the COUNT-th commented region after point." - (interactive "p") - (let ((orig-pt (point))) - (require 'newcomment) - (dotimes (_ (abs count)) - (cond ((> count 0) - (while (and (not (eobp)) (sp-point-in-comment)) - (forward-line 1)) - (unless (comment-search-forward (point-max) 'noerror) - (goto-char orig-pt) - (user-error "No comment after point"))) - (t - (while (and (not (bobp)) (sp-point-in-comment)) - (forward-line -1)) - (unless (comment-search-backward nil 'noerror) - (goto-char orig-pt) - (user-error "No comment before point"))))))) - -;;;###autoload -(defun +evil/previous-comment (count) - "Jump to the beginning of the COUNT-th commented region before point." - (interactive "p") - (+evil/next-comment (- count))) - -;;; ] SPC / [ SPC -;;;###autoload -(defun +evil/insert-newline-below (count) - "Insert COUNT blank line(s) below current line. Does not change modes." - (interactive "p") - (dotimes (_ count) - (save-excursion (evil-insert-newline-below)))) - -;;;###autoload -(defun +evil/insert-newline-above (count) - "Insert COUNT blank line(s) above current line. Does not change modes." - (interactive "p") - (dotimes (_ count) - (save-excursion (evil-insert-newline-above)))) - -;;; ]t / [t -;;;###autoload -(defun +evil/next-frame (count) - "Focus next frame." - (interactive "p") - (dotimes (_ (abs count)) - (let ((frame (if (> count 0) (next-frame) (previous-frame)))) - (if (eq frame (selected-frame)) - (user-error "No other frame") - (select-frame-set-input-focus frame))))) - -;;;###autoload -(defun +evil/previous-frame (count) - "Focus previous frame." - (interactive "p") - (+evil/next-frame (- count))) - -;;; ]f / [f -(defun +evil--next-file (n) - (unless buffer-file-name - (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 (cl-remove-if #'file-directory-p (doom-glob (file-name-directory buffer-file-name) "[!.]*"))) - (index (cl-position filename files :test #'file-equal-p))) - (when (null index) - (user-error "Couldn't find this file in current directory")) - (let ((index (+ index n))) - (cond ((>= index (length files)) - (user-error "No files after this one")) - ((< index 0) - (user-error "No files before this one")) - ((expand-file-name (nth index files) directory)))))) - -;;;###autoload -(defun +evil/next-file (count) - "Open file following this one, alphabetically, in the same directory." - (interactive "p") - (find-file (+evil--next-file count))) - -;;;###autoload -(defun +evil/previous-file (count) - "Open file preceding this one, alphabetically, in the same directory." - (interactive "p") - (find-file (+evil--next-file (- count)))) - - -;; -;;; Encoding/Decoding - -;; NOTE For ]x / [x see :lang web -;; - `+web:encode-html-entities' -;; - `+web:decode-html-entities' - -(defun +evil--encode (beg end fn) - (save-excursion - (goto-char beg) - (let* ((end (if (eq evil-this-type 'line) (1- end) end)) - (text (buffer-substring-no-properties beg end))) - (delete-region beg end) - (insert (funcall fn text))))) - -;;; ]u / [u -;;;###autoload (autoload '+evil:url-encode "editor/evil/autoload/unimpaired" nil t) -(evil-define-operator +evil:url-encode (_count &optional beg end) - "TODO" - (interactive "<c><r>") - (+evil--encode beg end #'url-encode-url)) - -;;;###autoload (autoload '+evil:url-decode "editor/evil/autoload/unimpaired" nil t) -(evil-define-operator +evil:url-decode (_count &optional beg end) - "TODO" - (interactive "<c><r>") - (+evil--encode beg end #'url-unhex-string)) - -;;; ]y / [y -;;;###autoload (autoload '+evil:c-string-encode "editor/evil/autoload/unimpaired" nil t) -(evil-define-operator +evil:c-string-encode (_count &optional beg end) - "TODO" - (interactive "<c><r>") - (+evil--encode - beg end - (lambda (text) - (replace-regexp-in-string "[\"\\]" (lambda (ch) (concat "\\" ch)) text)))) - -;;;###autoload (autoload '+evil:c-string-decode "editor/evil/autoload/unimpaired" nil t) -(evil-define-operator +evil:c-string-decode (_count &optional beg end) - "TODO" - (interactive "<c><r>") - (+evil--encode - beg end - (lambda (text) - (replace-regexp-in-string "\\\\[\"\\]" (lambda (str) (substring str 1)) text)))) - - -;; -;;; Standalone - -;;; gp -;;;###autoload -(defun +evil/reselect-paste () - "Return to visual mode and reselect the last pasted region." - (interactive) - (cl-destructuring-bind (_ _ _ beg end &optional _) - evil-last-paste - (evil-visual-make-selection - (save-excursion (goto-char beg) (point-marker)) - end))) diff --git a/.config/emacs/modules/editor/evil/config.el b/.config/emacs/modules/editor/evil/config.el @@ -1,633 +0,0 @@ -;;; editor/evil/config.el -*- lexical-binding: t; -*- - -(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. - -Set this to `nil' to disable universal-repeating on these keys.") - -(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 -line with a linewise comment.") - -(defvar +evil-preprocessor-regexp "^\\s-*#[a-zA-Z0-9_]" - "The regexp used by `+evil/next-preproc-directive' and -`+evil/previous-preproc-directive' on ]# and [#, to jump between preprocessor -directives. By default, this only recognizes C directives.") - -;; Set these defaults before `evil'; use `defvar' so they can be changed prior -;; to loading. -(defvar evil-want-C-g-bindings t) -(defvar evil-want-C-i-jump nil) ; we do this ourselves -(defvar evil-want-C-u-scroll t) ; moved the universal arg to <leader> u -(defvar evil-want-C-u-delete t) -(defvar evil-want-C-w-delete t) -(defvar evil-want-Y-yank-to-eol t) -(defvar evil-want-abbrev-expand-on-insert-exit nil) -(defvar evil-respect-visual-line-mode nil) - -(use-package! evil - :hook (doom-after-modules-config . evil-mode) - :demand t - :preface - (setq evil-ex-search-vim-style-regexp t - evil-ex-visual-char-range t ; column range for ex commands - evil-mode-line-format 'nil - ;; more vim-like behavior - evil-symbol-word-search t - ;; if the current state is obvious from the cursor's color/shape, then - ;; we won't need superfluous indicators to do it instead. - evil-default-cursor '+evil-default-cursor-fn - evil-normal-state-cursor 'box - evil-emacs-state-cursor '(box +evil-emacs-cursor-fn) - evil-insert-state-cursor 'bar - evil-visual-state-cursor 'hollow - ;; Only do highlighting in selected window so that Emacs has less work - ;; to do highlighting them all. - evil-ex-interactive-search-highlight 'selected-window - ;; It's infuriating that innocuous "beginning of line" or "end of line" - ;; errors will abort macros, so suppress them: - evil-kbd-macro-suppress-motion-error t - evil-undo-system - (cond ((modulep! :emacs undo +tree) 'undo-tree) - ((modulep! :emacs undo) 'undo-fu) - ((> emacs-major-version 27) 'undo-redo))) - - ;; Fix #7141 - (defadvice! +evil--persist-state-a (fn &rest args) - "When changing major modes, Evil's state is lost. This advice preserves it." - :around #'set-auto-mode - (if evil-state - (evil-save-state (apply fn args)) - (apply fn args))) - - ;; Slow this down from 0.02 to prevent blocking in large or folded buffers - ;; like magit while incrementally highlighting matches. - (setq-hook! '(magit-mode-hook so-long-minor-mode-hook) - evil-ex-hl-update-delay 0.25) - - :config - (evil-select-search-module 'evil-search-module 'evil-search) - - ;; PERF: Stop copying the selection to the clipboard each time the cursor - ;; moves in visual mode. Why? Because on most non-X systems (and in terminals - ;; with clipboard plugins like xclip.el active), Emacs will spin up a new - ;; process to communicate with the clipboard for each movement. On Windows, - ;; older versions of macOS (pre-vfork), and Waylang (without pgtk), this is - ;; super expensive and can lead to freezing and/or zombie processes. - ;; - ;; UX: It also clobbers clipboard managers (see emacs-evil/evil#336). - (setq evil-visual-update-x-selection-p nil) - - ;; Start help-with-tutorial in emacs state - (advice-add #'help-with-tutorial :after (lambda (&rest _) (evil-emacs-state +1))) - - ;; Done in a hook to ensure the popup rules load as late as possible - (add-hook! 'doom-after-modules-config-hook - (defun +evil--init-popup-rules-h () - (set-popup-rules! - '(("^\\*evil-registers" :size 0.3) - ("^\\*Command Line" :size 8))))) - - ;; Change the cursor color in emacs state. We do it this roundabout way - ;; to ensure changes in theme doesn't break these colors. - (add-hook! '(doom-load-theme-hook doom-after-modules-config-hook) - (defun +evil-update-cursor-color-h () - (put 'cursor 'evil-emacs-color (face-foreground 'warning)) - (put 'cursor 'evil-normal-color (face-background 'cursor)))) - - (defun +evil-default-cursor-fn () - (evil-set-cursor-color (get 'cursor 'evil-normal-color))) - (defun +evil-emacs-cursor-fn () - (evil-set-cursor-color (get 'cursor 'evil-emacs-color))) - - ;; Ensure `evil-shift-width' always matches `tab-width'; evil does not police - ;; this itself, so we must. - (setq-hook! 'after-change-major-mode-hook evil-shift-width tab-width) - - - ;; --- keybind fixes ---------------------- - (after! wgrep - ;; A wrapper that invokes `wgrep-mark-deletion' across lines you use - ;; `evil-delete' in wgrep buffers. - (define-key wgrep-mode-map [remap evil-delete] #'+evil-delete)) - - (add-hook! 'doom-escape-hook - (defun +evil-disable-ex-highlights-h () - "Disable ex search buffer highlights." - (when (evil-ex-hl-active-p 'evil-ex-search) - (evil-ex-nohighlight) - t))) - - - ;; --- evil hacks ------------------------- - (after! eldoc - ;; Allow eldoc to trigger directly after changing modes - (eldoc-add-command 'evil-normal-state - 'evil-insert - 'evil-change - 'evil-delete - 'evil-replace)) - - (unless noninteractive - (setq save-silently t) - (add-hook! 'after-save-hook - (defun +evil-display-vimlike-save-message-h () - "Shorter, vim-esque save messages." - (message "\"%s\" %dL, %dC written" - (if buffer-file-name - (file-relative-name (file-truename buffer-file-name) (doom-project-root)) - (buffer-name)) - (count-lines (point-min) (point-max)) - (buffer-size))))) - - ;; HACK '=' moves the cursor to the beginning of selection. Disable this, - ;; since it's more disruptive than helpful. - (defadvice! +evil--dont-move-cursor-a (fn &rest args) - :around #'evil-indent - (save-excursion (apply fn args))) - - ;; REVIEW In evil, registers 2-9 are buffer-local. In vim, they're global, - ;; so... Perhaps this should be PRed upstream? - (defadvice! +evil--make-numbered-markers-global-a (char) - :after-until #'evil-global-marker-p - (and (>= char ?2) (<= char ?9))) - - ;; REVIEW Fix #2493: dir-locals cannot target fundamental-mode when evil-mode - ;; 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) - (hack-local-variables))) - - ;; HACK Invoking helpful from evil-ex throws a "No recursive edit is in - ;; progress" error because, between evil-ex and helpful, - ;; `abort-recursive-edit' gets called one time too many. - (defadvice! +evil--fix-helpful-key-in-evil-ex-a (key-sequence) - :before #'helpful-key - (when (evil-ex-p) - (run-at-time 0.1 nil #'helpful-key key-sequence) - (abort-recursive-edit))) - - ;; Make J (evil-join) remove comment delimiters when joining lines. - (advice-add #'evil-join :around #'+evil-join-a) - - ;; Prevent gw (`evil-fill') and gq (`evil-fill-and-move') from squeezing - ;; spaces. It doesn't in vim, so it shouldn't in evil. - (defadvice! +evil--no-squeeze-on-fill-a (fn &rest args) - :around '(evil-fill evil-fill-and-move) - (letf! (defun fill-region (from to &optional justify nosqueeze to-eop) - (funcall fill-region from to justify t to-eop)) - (apply fn args))) - - ;; Make ESC (from normal mode) the universal escaper. See `doom-escape-hook'. - (advice-add #'evil-force-normal-state :after #'+evil-escape-a) - - ;; monkey patch `evil-ex-replace-special-filenames' to improve support for - ;; file modifiers like %:p:h. This adds support for most of vim's modifiers, - ;; and one custom one: %:P (expand to the project root). - (advice-add #'evil-ex-replace-special-filenames :override #'+evil-replace-filename-modifiers-a) - - ;; make `try-expand-dabbrev' (from `hippie-expand') work in minibuffer - (add-hook 'minibuffer-inactive-mode-hook #'+evil--fix-dabbrev-in-minibuffer-h) - - ;; Focus and recenter new splits - (advice-add #'evil-window-split :override #'+evil-window-split-a) - (advice-add #'evil-window-vsplit :override #'+evil-window-vsplit-a) - - ;; Make o/O continue comments (see `+evil-want-o/O-to-continue-comments' to disable) - (advice-add #'evil-open-above :around #'+evil--insert-newline-above-and-respect-comments-a) - (advice-add #'evil-open-below :around #'+evil--insert-newline-below-and-respect-comments-a) - - ;; --- custom interactive codes ----------- - ;; These arg types will highlight matches in the current buffer - (evil-ex-define-argument-type regexp-match - :runner (lambda (flag &optional arg) (+evil-ex-regexp-match flag arg 'inverted))) - (evil-ex-define-argument-type regexp-global-match - :runner +evil-ex-regexp-match) - - (defun +evil--regexp-match-args (arg) - (when (evil-ex-p) - (cl-destructuring-bind (&optional arg flags) - (evil-delimited-arguments arg 2) - (list arg (string-to-list flags))))) - - ;; Other commands can make use of this - (evil-define-interactive-code "<//>" - :ex-arg regexp-match - (+evil--regexp-match-args evil-ex-argument)) - - (evil-define-interactive-code "<//!>" - :ex-arg regexp-global-match - (+evil--regexp-match-args evil-ex-argument)) - - ;; Forward declare these so that ex completion works, even if the autoloaded - ;; functions aren't loaded yet. - (evil-add-command-properties '+evil:align :ex-arg 'regexp-match) - (evil-add-command-properties '+evil:align-right :ex-arg 'regexp-match) - (evil-add-command-properties '+multiple-cursors:evil-mc :ex-arg 'regexp-global-match) - - ;; Lazy load evil ex commands - (delq! 'evil-ex features) - (add-transient-hook! 'evil-ex (provide 'evil-ex)) - (after! evil-ex (load! "+commands"))) - - -;; -;;; Packages - -(use-package! evil-easymotion - :after-call doom-first-input-hook - :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 - :bind ((evil-ex-search-highlight-all nil))) - (evilem-make-motion evilem-motion-search-previous #'evil-ex-search-previous - :bind ((evil-ex-search-highlight-all nil))) - (evilem-make-motion evilem-motion-search-word-forward #'evil-ex-search-word-forward - :bind ((evil-ex-search-highlight-all nil))) - (evilem-make-motion evilem-motion-search-word-backward #'evil-ex-search-word-backward - :bind ((evil-ex-search-highlight-all nil))) - - ;; Rebind scope of w/W/e/E/ge/gE evil-easymotion motions to the visible - ;; buffer, rather than just the current line. - (put 'visible 'bounds-of-thing-at-point (lambda () (cons (window-start) (window-end)))) - (evilem-make-motion evilem-motion-forward-word-begin #'evil-forward-word-begin :scope 'visible) - (evilem-make-motion evilem-motion-forward-WORD-begin #'evil-forward-WORD-begin :scope 'visible) - (evilem-make-motion evilem-motion-forward-word-end #'evil-forward-word-end :scope 'visible) - (evilem-make-motion evilem-motion-forward-WORD-end #'evil-forward-WORD-end :scope 'visible) - (evilem-make-motion evilem-motion-backward-word-begin #'evil-backward-word-begin :scope 'visible) - (evilem-make-motion evilem-motion-backward-WORD-begin #'evil-backward-WORD-begin :scope 'visible) - (evilem-make-motion evilem-motion-backward-word-end #'evil-backward-word-end :scope 'visible) - (evilem-make-motion evilem-motion-backward-WORD-end #'evil-backward-WORD-end :scope 'visible)) - - -(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 ((c++-mode rustic-mode csharp-mode java-mode swift-mode typescript-mode) - . +evil-embrace-angle-bracket-modes-hook-h) - :hook (scala-mode . +evil-embrace-scala-mode-hook-h) - :init - (after! evil-surround - (evil-embrace-enable-evil-surround-integration)) - - ;; HACK: This must be done ASAP, before embrace has a chance to - ;; buffer-localize `embrace--pairs-list' (which happens right after it calls - ;; `embrace--setup-defaults'), otherwise any new, global default pairs we - ;; define won't be in scope. - (defadvice! +evil--embrace-init-escaped-pairs-a (&rest args) - "Add escaped-sequence support to embrace." - :after #'embrace--setup-defaults - (embrace-add-pair-regexp ?\\ "\\[[{(]" "\\[]})]" #'+evil--embrace-escaped - (embrace-build-help "\\?" "\\?"))) - :config - (setq evil-embrace-show-help-p nil) - - (defun +evil-embrace-scala-mode-hook-h () - (embrace-add-pair ?$ "${" "}")) - - (defun +evil-embrace-latex-mode-hook-h () - (dolist (pair '((?\' . ("`" . "\'")) - (?\" . ("``" . "\'\'")))) - (delete (car pair) evil-embrace-evil-surround-keys) - ;; Avoid `embrace-add-pair' because it would overwrite the default - ;; rules, which we want for other modes - (push (cons (car pair) (make-embrace-pair-struct - :key (car pair) - :left (cadr pair) - :right (cddr pair) - :left-regexp (regexp-quote (cadr pair)) - :right-regexp (regexp-quote (cddr pair)))) - embrace--pairs-list)) - (embrace-add-pair-regexp ?l "\\[a-z]+{" "}" #'+evil--embrace-latex)) - - (defun +evil-embrace-lisp-mode-hook-h () - ;; Avoid `embrace-add-pair-regexp' because it would overwrite the default - ;; `f' rule, which we want for other modes - (push (cons ?f (make-embrace-pair-struct - :key ?f - :read-function #'+evil--embrace-elisp-fn - :left-regexp "([^ ]+ " - :right-regexp ")")) - embrace--pairs-list)) - - (defun +evil-embrace-angle-bracket-modes-hook-h () - (let ((var (make-local-variable 'evil-embrace-evil-surround-keys))) - (set var (delq ?< evil-embrace-evil-surround-keys)) - (set var (delq ?> evil-embrace-evil-surround-keys))) - (embrace-add-pair-regexp ?< "\\_<[a-z0-9-_]+<" ">" #'+evil--embrace-angle-brackets) - (embrace-add-pair ?> "<" ">"))) - - -(use-package! evil-escape - :commands evil-escape - :hook (doom-first-input . evil-escape-mode) - :init - (setq evil-escape-excluded-states '(normal visual multiedit emacs motion) - evil-escape-excluded-major-modes '(neotree-mode treemacs-mode vterm-mode) - evil-escape-key-sequence "jk" - evil-escape-delay 0.15) - (evil-define-key* '(insert replace visual operator) 'global "\C-g" #'evil-escape) - :config - ;; `evil-escape' in the minibuffer is more disruptive than helpful. That is, - ;; unless we have `evil-collection-setup-minibuffer' enabled, in which case we - ;; want the same behavior in insert mode as we do in normal buffers. - (add-hook! 'evil-escape-inhibit-functions - (defun +evil-inhibit-escape-in-minibuffer-fn () - (and (minibufferp) - (or (not (bound-and-true-p evil-collection-setup-minibuffer)) - (evil-normal-state-p)))))) - - -(use-package! evil-exchange - :commands evil-exchange - :config - (add-hook! 'doom-escape-hook - (defun +evil--escape-exchange-h () - (when evil-exchange--overlays - (evil-exchange-cancel) - t)))) - - -(use-package! evil-quick-diff - :commands (evil-quick-diff evil-quick-diff-cancel)) - - -(use-package! evil-nerd-commenter - :commands (evilnc-comment-operator - evilnc-inner-comment - evilnc-outer-commenter) - :general ([remap comment-line] #'evilnc-comment-or-uncomment-lines)) - - -(use-package! evil-snipe - :commands evil-snipe-local-mode evil-snipe-override-local-mode - :hook (doom-first-input . evil-snipe-override-mode) - :hook (doom-first-input . evil-snipe-mode) - :init - (setq evil-snipe-smart-case t - evil-snipe-scope 'line - evil-snipe-repeat-scope 'visible - evil-snipe-char-fold t)) - - -(use-package! evil-surround - :commands (global-evil-surround-mode - evil-surround-edit - evil-Surround-edit - evil-surround-region) - :config (global-evil-surround-mode 1)) - - -(use-package! evil-textobj-anyblock - :defer t - :config - (setq evil-textobj-anyblock-blocks - '(("(" . ")") - ("{" . "}") - ("\\[" . "\\]") - ("<" . ">")))) - - -(use-package! evil-traces - :after evil-ex - :config - (pushnew! evil-traces-argument-type-alist - '(+evil:align . evil-traces-global) - '(+evil:align-right . evil-traces-global)) - (evil-traces-mode)) - - -;; Allows you to use the selection for * and # -(use-package! evil-visualstar - :commands (evil-visualstar/begin-search - evil-visualstar/begin-search-forward - evil-visualstar/begin-search-backward) - :init - (evil-define-key* 'visual 'global - "*" #'evil-visualstar/begin-search-forward - "#" #'evil-visualstar/begin-search-backward)) - - -;; -;;; Text object plugins - -(use-package! exato - :commands evil-outer-xml-attr evil-inner-xml-attr) - - -;; -;;; Keybinds - -;; Keybinds that have no Emacs+evil analogues (i.e. don't exist): -;; zu{q,w} - undo last marking - -(map! :v "@" #'+evil:apply-macro - :m [C-i] #'evil-jump-forward - - ;; implement dictionary keybinds - ;; evil already defines 'z=' to `ispell-word' = correct word at point - (:when (modulep! :checkers spell) - :n "zg" #'+spell/add-word - :n "zw" #'+spell/remove-word - :m "[s" #'+spell/previous-error - :m "]s" #'+spell/next-error) - - ;; ported from vim-unimpaired - :n "] SPC" #'+evil/insert-newline-below - :n "[ SPC" #'+evil/insert-newline-above - :n "]b" #'next-buffer - :n "[b" #'previous-buffer - :n "]f" #'+evil/next-file - :n "[f" #'+evil/previous-file - :m "]u" #'+evil:url-encode - :m "[u" #'+evil:url-decode - :m "]y" #'+evil:c-string-encode - :m "[y" #'+evil:c-string-decode - (:when (modulep! :lang web) - :m "]x" #'+web:encode-html-entities - :m "[x" #'+web:decode-html-entities) - (:when (modulep! :ui vc-gutter) - :m "]d" #'+vc-gutter/next-hunk - :m "[d" #'+vc-gutter/previous-hunk) - (:when (modulep! :ui hl-todo) - :m "]t" #'hl-todo-next - :m "[t" #'hl-todo-previous) - (:when (modulep! :ui workspaces) - :n "gt" #'+workspace:switch-next - :n "gT" #'+workspace:switch-previous - :n "]w" #'+workspace/switch-right - :n "[w" #'+workspace/switch-left) - (:when (modulep! :ui tabs) - :n "gt" #'+tabs:next-or-goto - :n "gT" #'+tabs:previous-or-goto) - - ;; custom vim-unmpaired-esque keys - :m "]#" #'+evil/next-preproc-directive - :m "[#" #'+evil/previous-preproc-directive - :m "]a" #'evil-forward-arg - :m "[a" #'evil-backward-arg - :m "]c" #'+evil/next-comment - :m "[c" #'+evil/previous-comment - :m "]e" #'next-error - :m "[e" #'previous-error - :n "]F" #'+evil/next-frame - :n "[F" #'+evil/previous-frame - :m "]h" #'outline-next-visible-heading - :m "[h" #'outline-previous-visible-heading - :m "]m" #'+evil/next-beginning-of-method - :m "[m" #'+evil/previous-beginning-of-method - :m "]M" #'+evil/next-end-of-method - :m "[M" #'+evil/previous-end-of-method - :n "[o" #'+evil/insert-newline-above - :n "]o" #'+evil/insert-newline-below - :n "gp" #'+evil/reselect-paste - :v "gp" #'+evil/alt-paste - :nv "g@" #'+evil:apply-macro - :nv "gc" #'evilnc-comment-operator - :nv "gO" #'imenu - :nv "gx" #'evil-exchange - :nv "gy" #'+evil:yank-unindented - :n "g=" #'evil-numbers/inc-at-pt - :n "g-" #'evil-numbers/dec-at-pt - :v "g=" #'evil-numbers/inc-at-pt-incremental - :v "g-" #'evil-numbers/dec-at-pt-incremental - :v "g+" #'evil-numbers/inc-at-pt - (:when (modulep! :tools lookup) - :nv "K" #'+lookup/documentation - :nv "gd" #'+lookup/definition - :nv "gD" #'+lookup/references - :nv "gf" #'+lookup/file - :nv "gI" #'+lookup/implementations - :nv "gA" #'+lookup/assignments) - (:when (modulep! :tools eval) - :nv "gr" #'+eval:region - :n "gR" #'+eval/buffer - :v "gR" #'+eval:replace-region - ;; Restore these keybinds, since the blacklisted/overwritten gr/gR will - ;; undo them: - (:after helpful - :map helpful-mode-map - :n "gr" #'helpful-update) - (:after compile - :map (compilation-mode-map compilation-minor-mode-map) - :n "gr" #'recompile) - (:after dired - :map dired-mode-map - :n "gr" #'revert-buffer) - (:after notmuch - :map notmuch-common-keymap - :n "gr" #'notmuch-refresh-this-buffer - :n "gR" #'notmuch-poll-and-refresh-this-buffer) - (:after elfeed - :map elfeed-search-mode-map - :n "gr" #'elfeed-search-update--force - :n "gR" #'elfeed-search-fetch)) - - ;; custom evil keybinds - :nv "zn" #'+evil:narrow-buffer - :n "zN" #'doom/widen-indirectly-narrowed-buffer - :n "zx" #'kill-current-buffer - :n "ZX" #'doom/save-and-kill-buffer - ;; don't leave visual mode after shifting - :v "<" #'+evil/shift-left ; vnoremap < <gv - :v ">" #'+evil/shift-right ; vnoremap > >gv - - ;; window management (prefix "C-w") - (:map evil-window-map - ;; Navigation - "C-h" #'evil-window-left - "C-j" #'evil-window-down - "C-k" #'evil-window-up - "C-l" #'evil-window-right - "C-w" #'other-window - ;; Extra split commands - "S" #'+evil/window-split-and-follow - "V" #'+evil/window-vsplit-and-follow - ;; Swapping windows - "H" #'+evil/window-move-left - "J" #'+evil/window-move-down - "K" #'+evil/window-move-up - "L" #'+evil/window-move-right - "C-S-w" #'ace-swap-window - ;; Window undo/redo - (:prefix "m" - "m" #'doom/window-maximize-buffer - "v" #'doom/window-maximize-vertically - "s" #'doom/window-maximize-horizontally) - "u" #'winner-undo - "C-u" #'winner-undo - "C-r" #'winner-redo - "o" #'doom/window-enlargen - ;; Delete window - "d" #'evil-window-delete - "C-C" #'ace-delete-window - "T" #'tear-off-window) - - ;; text objects - :textobj "a" #'evil-inner-arg #'evil-outer-arg - :textobj "B" #'evil-textobj-anyblock-inner-block #'evil-textobj-anyblock-a-block - :textobj "c" #'evilnc-inner-comment #'evilnc-outer-commenter - :textobj "f" #'+evil:defun-txtobj #'+evil:defun-txtobj - :textobj "g" #'+evil:whole-buffer-txtobj #'+evil:whole-buffer-txtobj - :textobj "i" #'evil-indent-plus-i-indent #'evil-indent-plus-a-indent - :textobj "j" #'evil-indent-plus-i-indent-up-down #'evil-indent-plus-a-indent-up-down - :textobj "k" #'evil-indent-plus-i-indent-up #'evil-indent-plus-a-indent-up - :textobj "q" #'+evil:inner-any-quote #'+evil:outer-any-quote - :textobj "u" #'+evil:inner-url-txtobj #'+evil:outer-url-txtobj - :textobj "x" #'evil-inner-xml-attr #'evil-outer-xml-attr - - ;; evil-easymotion - (:after evil-easymotion - :m "gs" evilem-map - (:map evilem-map - "a" (evilem-create #'evil-forward-arg) - "A" (evilem-create #'evil-backward-arg) - "s" #'evil-avy-goto-char-2 - "SPC" (cmd! (let ((current-prefix-arg t)) (evil-avy-goto-char-timer))) - "/" #'evil-avy-goto-char-timer)) - - ;; evil-snipe - (:after evil-snipe - :map evil-snipe-parent-transient-map - "C-;" (cmd! (require 'evil-easymotion) - (call-interactively - (evilem-create #'evil-snipe-repeat - :bind ((evil-snipe-scope 'whole-buffer) - (evil-snipe-enable-highlight) - (evil-snipe-enable-incremental-highlight)))))) - - ;; evil-surround - :v "S" #'evil-surround-region - :o "s" #'evil-surround-edit - :o "S" #'evil-Surround-edit - - ;; evil-lion - :n "gl" #'evil-lion-left - :n "gL" #'evil-lion-right - :v "gl" #'evil-lion-left - :v "gL" #'evil-lion-right - - ;; Omni-completion - (:when (modulep! :completion company) - (:prefix "C-x" - :i "C-l" #'+company/whole-lines - :i "C-k" #'+company/dict-or-keywords - :i "C-f" #'company-files - :i "C-]" #'company-etags - :i "s" #'company-ispell - :i "C-s" #'company-yasnippet - :i "C-o" #'company-capf - :i "C-n" #'+company/dabbrev - :i "C-p" #'+company/dabbrev-code-previous))) diff --git a/.config/emacs/modules/editor/evil/init.el b/.config/emacs/modules/editor/evil/init.el @@ -1,350 +0,0 @@ -;;; 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 -;; evil-collection-{elisp-mode,buff-menu} are loaded immediately, because -;; Emacs loads their packages immediately, which pulls in all of -;; evil-collection (and other packages with it, sometimes). -;; 2. This ensures a predictable load order, versus lazy loading using :defer or -;; :after-call. This means users can use (after! org ...) and be sure that -;; their changes will override evil-collection's. -;; 3. Ideally, we'd do away with evil-collection entirely. It changes too often, -;; introduces breaking bugs too frequently, and I don't agree with all their -;; design choices. Regardless, it does more good than trouble, so it may be -;; here to stay. -;; 4. Adds `+evil-collection-disabled-list', to make it easier for users to -;; disable modules, and to reduce the effort required to maintain our copy of -;; `evil-collection-list' (now I can just copy it from time to time). - -(when (and (not noninteractive) - (not (doom-context-p 'reload)) - (modulep! +everywhere)) - - (setq evil-collection-company-use-tng (modulep! :completion company +tng) - ;; must be set before evil/evil-collection is loaded - evil-want-keybinding nil) - - (defvar +evil-collection-disabled-list - '(anaconda-mode - buff-menu - calc - comint - company - custom - eldoc - elisp-mode - ert - free-keys - helm - help - indent - image - kotlin-mode - outline - replace - shortdoc - simple - slime - lispy) - "A list of `evil-collection' modules to ignore. See the definition of this -variable for an explanation of the defaults (in comments). See -`evil-collection-mode-list' for a list of available options.") - - (defvar evil-collection-setup-minibuffer nil) - - ;; We do this ourselves, and better. - (defvar evil-collection-want-unimpaired-p nil) - ;; Doom binds goto-reference on gD and goto-assignments on gA ourselves - (defvar evil-collection-want-find-usages-bindings-p nil) - ;; Reduces keybind conflicts between outline-mode and org-mode (which is - ;; derived from outline-mode). - (defvar evil-collection-outline-enable-in-minor-mode-p nil) - - ;; We handle loading evil-collection ourselves - (defvar evil-collection--supported-modes nil) - - ;; This has to be defined here since evil-collection doesn't autoload its own. - ;; It must be updated whenever evil-collection updates theirs. Here's an easy - ;; way to update it: - ;; - ;; (with-current-buffer - ;; (url-retrieve-synchronously "https://raw.githubusercontent.com/emacs-evil/evil-collection/master/evil-collection.el" t t) - ;; (goto-char (point-min)) - ;; (when (re-search-forward "^(defvar evil-collection--supported-modes\n[^(]+") - ;; (let ((list (sexp-at-point))) - ;; ;; Fixes - ;; (when (assq 'pdf list) - ;; (setf (alist-get 'pdf list) '(pdf-tools))) - ;; (let ((diff (cl-set-difference evil-collection-mode-list list :test #'equal))) - ;; (list (- (length list) (length evil-collection-mode-list)) - ;; diff) - ;; (message "diff: %s" diff) - ;; (kill-new (prin1-to-string list)))))) - - (defvar evil-collection-mode-list - `(2048-game - ag - alchemist - anaconda-mode - apropos - arc-mode - atomic-chrome - auto-package-update - beginend - bluetooth - bm - bookmark - (buff-menu "buff-menu") - calc - calendar - cider - cmake-mode - color-rg - comint - company - compile - consult - corfu - crdt - (custom cus-edit) - cus-theme - daemons - dashboard - deadgrep - debbugs - debug - devdocs - dictionary - diff-hl - diff-mode - dired - dired-sidebar - disk-usage - doc-view - docker - ebib - ebuku - edbi - edebug - ediff - eglot - explain-pause-mode - elfeed - eldoc - elisp-mode - elisp-refs - elisp-slime-nav - embark - emms - ,@(if (> emacs-major-version 28) '(emoji)) - epa - ert - eshell - eval-sexp-fu - evil-mc - eww - fanyi - finder - flycheck - flymake - forge - free-keys - geiser - ggtags - git-timemachine - gited - gnus - go-mode - grep - guix - hackernews - helm - help - helpful - hg-histedit - hungry-delete - ibuffer - image - image-dired - image+ - imenu - imenu-list - (indent "indent") - indium - info - ivy - js2-mode - leetcode - lispy - log-edit - log-view - lsp-ui-imenu - lua-mode - kotlin-mode - macrostep - man - (magit magit-repos magit-submodule) - magit-section - magit-todos - markdown-mode - monky - mpc - mu4e - mu4e-conversation - neotree - newsticker - notmuch - nov - omnisharp - org - org-present - org-roam - osx-dictionary - outline - p4 - (package-menu package) - pass - (pdf pdf-tools) - popup - proced - prodigy - profiler - python - quickrun - racer - racket-describe - realgud - reftex - replace - restclient - rg - ripgrep - rjsx-mode - robe - rtags - ruby-mode - scheme - scroll-lock - selectrum - sh-script - ,@(if (> emacs-major-version 27) '(shortdoc)) - simple - simple-mpc - slime - sly - snake - so-long - speedbar - tablist - tar-mode - telega - (term term ansi-term multi-term) - tetris - thread - tide - timer-list - transmission - trashed - tuareg - typescript-mode - vc-annotate - vc-dir - vc-git - vdiff - vertico - view - vlf - vterm - vundo - w3m - wdired - wgrep - which-key - woman - xref - xwidget - yaml-mode - youtube-dl - zmusic - (ztree ztree-diff))) - - (defun +evil-collection-init (module &optional disabled-list) - "Initialize evil-collection-MODULE. - -Unlike `evil-collection-init', this respects `+evil-collection-disabled-list', -and complains if a module is loaded too early (during startup)." - (unless (memq (or (car-safe module) module) disabled-list) - (doom-log "editor:evil: loading evil-collection-%s %s" - (or (car-safe module) module) - (if after-init-time "" "(too early!)")) - (with-demoted-errors "evil-collection error: %s" - (evil-collection-init (list module))))) - - (defadvice! +evil-collection-disable-blacklist-a (fn) - :around #'evil-collection-vterm-toggle-send-escape ; allow binding to ESC - (let (evil-collection-key-blacklist) - (funcall-interactively fn))) - - ;; These modes belong to packages that Emacs always loads at startup, causing - ;; evil-collection and it's co-packages to all load immediately. We avoid this - ;; by loading them after evil-collection has first loaded... - (with-eval-after-load 'evil-collection - ;; Don't let evil-collection interfere with certain keys - (setq evil-collection-key-blacklist - (append (list doom-leader-key doom-localleader-key - doom-leader-alt-key) - evil-collection-key-blacklist - (when (modulep! :tools lookup) - '("gd" "gf" "K")) - (when (modulep! :tools eval) - '("gr" "gR")) - '("[" "]" "gz" "<escape>"))) - - (evil-define-key* 'normal process-menu-mode-map - "q" #'kill-current-buffer - "d" #'process-menu-delete-process) - - (mapc #'+evil-collection-init '(comint custom))) - - ;; ...or on first invokation of their associated major/minor modes. - (after! evil - ;; Emacs loads these two packages immediately, at startup, which needlessly - ;; convolutes load order for evil-collection-help. - (add-transient-hook! 'help-mode - (+evil-collection-init 'help)) - (add-transient-hook! 'Buffer-menu-mode - (+evil-collection-init '(buff-menu "buff-menu"))) - (add-transient-hook! 'calc-mode - (+evil-collection-init 'calc)) - (add-transient-hook! 'image-mode - (+evil-collection-init 'image)) - (add-transient-hook! 'emacs-lisp-mode - (+evil-collection-init 'elisp-mode)) - (add-transient-hook! 'occur-mode - (+evil-collection-init 'replace)) - (add-transient-hook! 'indent-rigidly - (+evil-collection-init '(indent "indent"))) - (add-transient-hook! 'minibuffer-setup-hook - (when evil-collection-setup-minibuffer - (+evil-collection-init 'minibuffer) - (evil-collection-minibuffer-insert))) - (add-transient-hook! 'process-menu-mode - (+evil-collection-init '(process-menu simple))) - (add-transient-hook! 'shortdoc-mode - (+evil-collection-init 'shortdoc)) - (add-transient-hook! 'tabulated-list-mode - (+evil-collection-init 'tabulated-list)) - (add-transient-hook! 'tab-bar-mode - (+evil-collection-init 'tab-bar)) - - ;; HACK Do this ourselves because evil-collection break's `eval-after-load' - ;; load order by loading their target plugin before applying keys. This - ;; makes it hard for end-users to overwrite these keybinds with a - ;; simple `after!' or `with-eval-after-load'. - (dolist (mode evil-collection-mode-list) - (dolist (req (or (cdr-safe mode) (list mode))) - (with-eval-after-load req - (+evil-collection-init mode +evil-collection-disabled-list)))))) diff --git a/.config/emacs/modules/editor/evil/packages.el b/.config/emacs/modules/editor/evil/packages.el @@ -1,38 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; editor/evil/packages.el - -(package! evil :pin "2ce03d412c4e93b0b89eb43d796c991806415b8a") -(package! evil-args :pin "2671071a4a57eaee7cc8c27b9e4b6fc60fd2ccd3") -(package! evil-easymotion :pin "f96c2ed38ddc07908db7c3c11bcd6285a3e8c2e9") -(package! evil-embrace :pin "7b5a539cfe7db238d860122c793a0cb2d329cc6e") -(package! evil-escape - :recipe (:host github :repo "hlissner/evil-escape") - :pin "819f1ee1cf3f69a1ae920e6004f2c0baeebbe077") -(package! evil-exchange :pin "5f0a2d41434c17c6fb02e4f744043775de1c63a2") -(package! evil-indent-plus :pin "b4dacbfdb57f474f798bfbf5026d434d549eb65c") -(package! evil-lion :pin "a55eb647422342f6b1cf867f797b060b3645d9d8") -(package! evil-nerd-commenter :pin "8c0f23d46a3927b9f83c1c2c4590be53d0b740db") -(package! evil-numbers :pin "7a1b62afc12da2b582bf84d722e7b10ca8b97065") -(package! evil-snipe :pin "c07788c35cf8cd8e652a494322fdc0643e30a89f") -(package! evil-surround :pin "f273821f575ace519066fb106ee45a5b8577475f") -(package! evil-textobj-anyblock - :recipe (:host github - :repo "willghatch/evil-textobj-anyblock" - :branch "fix-inner-block") - :pin "29280cd71a05429364cdceef2ff595ae8afade4d") -(package! evil-traces :pin "290b5323542c46af364ec485c8ec9000040acf90") -(package! evil-visualstar :pin "06c053d8f7381f91c53311b1234872ca96ced752") -(package! exato :pin "aee7af7b7a0e7551478f453d1de7d5b9cb2e06c4") -(package! evil-quick-diff - :recipe (:host github :repo "rgrinberg/evil-quick-diff") - :pin "69c883720b30a892c63bc89f49d4f0e8b8028908") - -;; -(when (modulep! +everywhere) - ;; `evil-collection-neotree' uses the `neotree-make-executor' macro, but this - ;; requires neotree be available during byte-compilation (while installing). - (when (modulep! :ui neotree) - (package! neotree) - (autoload 'neotree-make-executor "neotree" nil nil 'macro)) - - (package! evil-collection :pin "aaf3e0038e9255659fe0455729239c08498c4c0b")) diff --git a/.config/emacs/modules/editor/evil/test/test-evil.el b/.config/emacs/modules/editor/evil/test/test-evil.el @@ -1,69 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; editor/evil/test/test-evil.el - -(describe "editor/evil" - :var (resv project-root) - - (require! :editor evil) - (require 'evil) - (load! "../autoload/evil") - - (before-each - (fset 'resv #'+evil-replace-filename-modifiers-a) - (spy-on 'doom-project-root :and-call-fake (lambda () project-root))) - - ;; `evil-ex-replace-special-filenames' / `+evil-replace-filename-modifiers-a' - (describe "file modifiers" - (it "supports basic vim file modifiers" - (let ((buffer-file-name "~/.emacs.d/test/modules/feature/test-evil.el") - (default-directory "~/.emacs.d/test/modules/") - (project-root "~/.emacs.d/")) - (expect (resv "%") :to-equal "feature/test-evil.el") - (expect (resv "%:r") :to-equal "feature/test-evil") - (expect (resv "%:r.elc") :to-equal "feature/test-evil.elc") - (expect (resv "%:e") :to-equal "el") - (expect (resv "%:p") :to-equal (expand-file-name buffer-file-name)) - (expect (resv "%:h") :to-equal "feature") - (expect (resv "%:t") :to-equal "test-evil.el") - (expect (resv "%:.") :to-equal "feature/test-evil.el") - (expect (resv "%:~") :to-equal "~/.emacs.d/test/modules/feature/test-evil.el") - (expect (file-truename (resv "%:p")) - :to-equal (file-truename buffer-file-name)))) - - (it "supports nested vim file modifiers" - (let ((buffer-file-name "~/vim/src/version.c") - (default-directory "~/vim/") - (project-root "~/vim/")) - (expect (resv "%:p") :to-equal (expand-file-name "~/vim/src/version.c")) - (expect (resv "%:p:.") :to-equal "src/version.c") - (expect (resv "%:p:~") :to-equal "~/vim/src/version.c") - (expect (resv "%:h") :to-equal "src") - (expect (resv "%:p:h") :to-equal (expand-file-name "~/vim/src")) - (expect (resv "%:p:h:h") :to-equal (expand-file-name "~/vim")) - (expect (resv "%:t") :to-equal "version.c") - (expect (resv "%:p:t") :to-equal "version.c") - (expect (resv "%:r") :to-equal "src/version") - (expect (resv "%:p:r") :to-equal (expand-file-name "~/vim/src/version")) - (expect (resv "%:t:r") :to-equal "version"))) - - (it "cleans up empty file modifiers" - (let (buffer-file-name default-directory) - (expect (resv "%") :to-equal "") - (expect (resv "%:r") :to-equal "") - (expect (resv "%:e") :to-equal "") - (expect (resv "%:h") :to-equal "") - (expect (resv "%:t") :to-equal "") - (expect (resv "%:.") :to-equal "") - (expect (resv "%:~") :to-equal "") - (expect (resv "%:P") :to-equal ""))) - - (it "supports substitution modifiers" - (let ((buffer-file-name "~/.emacs.d/test/modules/feature/test-evil.el") - (default-directory "~/.emacs.d/test/modules/")) - (expect (resv "%:s?e?x?") :to-equal "fxature/test-evil.el") - (expect (resv "%:gs?e?x?") :to-equal "fxaturx/txst-xvil.xl"))) - - (it "cleans up empty substitution modifiers" - (let (buffer-file-name default-directory) - (expect (resv "%:s?e?x?") :to-equal "") - (expect (resv "%:gs?e?x?") :to-equal ""))))) diff --git a/.config/emacs/modules/editor/file-templates/README.org b/.config/emacs/modules/editor/file-templates/README.org @@ -1,96 +0,0 @@ -#+title: :editor file-templates -#+subtitle: Fill the void in your empty files -#+created: February 11, 2017 -#+since: 2.0.0 - -* Description :unfold: -This module adds file templates for blank files, powered by [[doom-package:yasnippet]]. - -** Maintainers -- [[doom-user:][@hlissner]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -/This module doesn't install any packages./ - -** Hacks -- [[doom-package:yasnippet]] - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -File templates are automatically expanded when opening empty files who match one -of the rules in the ~+file-templates-alist~ variable. - -These templates are simply yasnippet snippets, which can also be expanded by -typing their trigger and pressing [[kbd:][TAB]]. By convention, the triggers for file -templates are prefixed with two underscores ~__~ (the trigger for the default -file template of a major mode is almost always ~__~). - -** Inserting OSS licenses -A special command is available for inserting software licenses: ~M-x -+file-templates/insert-license~. - -#+begin_quote - 📌 Licenses with a ~-bp~ suffix are boilerplate templates; i.e. shorter - versions intended for comment headers in code files. -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** Adding new or changing existing file templates -New file templates can be added to -=$DOOMDIR/snippets/{major-mode}/{snippet-name}=. The yasnippet documentation -covers [[https://joaotavora.github.io/yasnippet/snippet-development.html][how to write a snippet]]. You can map a snippet to a file path, major mode, -or another arbitrary predicate using [[fn:set-file-template!]]. - -Look into its documentation with [[kbd:][<help> f set-file-template\!]]. - -** Adding new OSS licenses -Add snippet files to =$DOOMDIR/snippets/text-mode/= with the =__licenses-= -prefix and [[fn:+file-templates/insert-license]] will recognize them. E.g. -=$DOOMDIR/snippets/text-mode/__license-mit=. - -* Troubleshooting -- If a file template isn't expanding where you expect it to, run ~M-x - +file-templates/debug~. This will report to you what file template rule would - apply for the correct file. - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 /This module's appendix is incomplete./ [[doom-contrib-module:][Write more?]] -#+end_quote - -** API -- ~set-file-template! PRED &rest PLIST~ -- ~set-file-templates! &rest TEMPLATES~ - -** Commands -- ~+file-templates/insert-license~ -- ~+file-templates/debug~ - -** Variables -- ~+file-templates-dir~ -- ~+file-templates-default-trigger~ -- ~+file-templates-alist~ diff --git a/.config/emacs/modules/editor/file-templates/autoload.el b/.config/emacs/modules/editor/file-templates/autoload.el @@ -1,160 +0,0 @@ -;;; editor/file-templates/autoload.el -*- lexical-binding: t; -*- - -(defun +file-templates--set (pred plist) - (if (null (car-safe plist)) - (setq +file-templates-alist - (delq (assoc pred +file-templates-alist) - +file-templates-alist)) - (push `(,pred ,@plist) +file-templates-alist))) - -;;;###autodef -(defun set-file-template! (pred &rest plist) - "Register a file template. - -PRED can either be a regexp string or a major mode symbol. PLIST may contain -these properties: - - :when FUNCTION - Provides a secondary predicate. This function takes no arguments and is - executed from within the target buffer. If it returns nil, this rule will be - skipped over. - :trigger STRING|FUNCTION - If a string, this is the yasnippet trigger keyword used to trigger the - target snippet. - If a function, this function will be run in the context of the buffer to - insert a file template into. It is given no arguments and must insert text - into the current buffer manually. - If omitted, `+file-templates-default-trigger' is used. - :mode SYMBOL - What mode to get the yasnippet snippet from. If omitted, either PRED (if - it's a major-mode symbol) or the mode of the buffer is used. - :project BOOL - If non-nil, ignore this template if this buffer isn't in a project. - :ignore BOOL - If non-nil, don't expand any template for this file and don't test any other - file template rule against this buffer. - -\(fn PRED &key WHEN TRIGGER MODE PROJECT IGNORE)" - (declare (indent defun)) - (defer-until! (boundp '+file-templates-alist) - (+file-templates--set pred plist))) - -;;;###autodef -(defun set-file-templates! (&rest templates) - "Like `set-file-template!', but can register multiple file templates at once. - -\(fn &rest (PRED &key WHEN TRIGGER MODE PROJECT IGNORE))" - (defer-until! (boundp '+file-templates-alist) - (dolist (template templates) - (+file-templates--set (car template) (cdr template))))) - - -;; -;;; Library - -;;;###autoload -(cl-defun +file-templates--expand (pred &key project mode trigger ignore _when) - "Auto insert a yasnippet snippet into current file and enter insert mode (if -evil is loaded and enabled)." - (when (and pred (not ignore)) - (when (if project (doom-project-p) t) - (unless mode - (setq mode - (if (and (symbolp pred) (not (booleanp pred))) - pred - major-mode))) - (unless mode - (user-error "Couldn't determine mode for %s file template" pred)) - (unless trigger - (setq trigger +file-templates-default-trigger)) - (if (functionp trigger) - (funcall trigger) - (require 'yasnippet) - (unless yas-minor-mode - (yas-minor-mode-on)) - (when (and yas-minor-mode - (when-let - (template (cl-find trigger (yas--all-templates (yas--get-snippet-tables mode)) - :key #'yas--template-key :test #'equal)) - (yas-expand-snippet (yas--template-content template))) - (and (featurep 'evil) evil-local-mode) - (and yas--active-field-overlay - (overlay-buffer yas--active-field-overlay) - (overlay-get yas--active-field-overlay 'yas--field))) - (evil-initialize-state 'insert)))))) - -;;;###autoload -(defun +file-templates-get-short-path () - "Fetches a short file path for the header in Doom module templates." - (let ((path (file-truename (or buffer-file-name default-directory)))) - (save-match-data - (cond ((string-match "/modules/\\(.+\\)$" path) - (match-string 1 path)) - ((file-in-directory-p path doom-emacs-dir) - (file-relative-name path doom-emacs-dir)) - ((file-in-directory-p path doom-user-dir) - (file-relative-name path doom-user-dir)) - ((abbreviate-file-name path)))))) - -;;;###autoload -(defun +file-templates-module-for-path (&optional path) - "Generate a title for a doom module's readme at PATH." - (let ((m (doom-module-from-path (or path (buffer-file-name))))) - (if (eq (cdr m) 'README.org) - (symbol-name (car m)) - (format "%s %s" (car m) (cdr m))))) - - -;; -;;; Commands - -;;;###autoload -(defun +file-templates/insert-license () - "Insert a license file template into the current file." - (interactive) - (require 'yasnippet) - (unless (gethash 'text-mode yas--tables) - (yas-reload-all t)) - (let ((templates - (let (yas-choose-tables-first ; avoid prompts - yas-choose-keys-first) - (cl-loop for tpl in (yas--all-templates (yas--get-snippet-tables 'text-mode)) - for uuid = (yas--template-uuid tpl) - if (string-prefix-p "__license-" uuid) - collect (cons (string-remove-prefix "__license-" uuid) tpl))))) - (when-let (uuid (yas-choose-value (mapcar #'car templates))) - (yas-expand-snippet (cdr (assoc uuid templates)))))) - -;;;###autoload -(defun +file-templates/debug () - "Tests the current buffer and outputs the file template rule most appropriate -for it. This is used for testing." - (interactive) - (cl-destructuring-bind (pred &rest plist &key trigger mode &allow-other-keys) - (or (cl-find-if #'+file-template-p +file-templates-alist) - (user-error "Found no file template for this file")) - (if (or (functionp trigger) - (cl-find trigger - (yas--all-templates - (yas--get-snippet-tables - mode)) - :key #'yas--template-key :test #'equal)) - (message "Found %s" (cons pred plist)) - (message "Found rule, but can't find associated snippet: %s" (cons pred plist))))) - - -;; -;;; Trigger functions - -(defun +file-templates-insert-doom-docs-fn () - "Expand one of Doom's README templates depending." - (+file-templates--expand - t :trigger - (let ((path (file-truename (buffer-file-name)))) - (cond ((string-match-p "/modules/[^/]+/README\\.org$" path) - "__doom-category-readme") - ((string-match-p "/modules/[^/]+/[^/]+/README\\.org$" path) - "__doom-readme") - ((file-in-directory-p path doom-docs-dir) - "__doom-docs") - ("__"))))) diff --git a/.config/emacs/modules/editor/file-templates/config.el b/.config/emacs/modules/editor/file-templates/config.el @@ -1,167 +0,0 @@ -;;; editor/file-templates/config.el -*- lexical-binding: t; -*- - -(defvar +file-templates-dir - (expand-file-name "templates/" (file-name-directory load-file-name)) - "The path to a directory of yasnippet folders to use for file templates.") - -(defvar +file-templates-default-trigger "__" - "The default yasnippet trigger key (a string) for file template rules that -don't have a :trigger property in `+file-templates-alist'.") - -(defvar +file-templates-inhibit nil - "If non-nil, inhibit file template expansion.") - -(defvar +file-templates-alist - '(;; General - (gitignore-mode) - (dockerfile-mode) - ("/docker-compose\\.yml$" :mode yaml-mode) - ("/Makefile$" :mode makefile-gmake-mode) - ;; elisp - ("/\\.dir-locals\\.el$") - ("/\\.doomrc$" - :trigger "__doomrc" - :mode emacs-lisp-mode) - ("/packages\\.el$" :when +file-templates-in-emacs-dirs-p - :trigger "__doom-packages" - :mode emacs-lisp-mode) - ("/doctor\\.el$" :when +file-templates-in-emacs-dirs-p - :trigger "__doom-doctor" - :mode emacs-lisp-mode) - ("/test/.+\\.el$" :when +file-templates-in-emacs-dirs-p - :trigger "__doom-test" - :mode emacs-lisp-mode) - ("\\.el$" :when +file-templates-in-emacs-dirs-p - :trigger "__doom-module" - :mode emacs-lisp-mode) - ("-test\\.el$" :mode emacs-ert-mode) - (emacs-lisp-mode :trigger "__package") - (snippet-mode) - ;; C/C++ - ("/main\\.c\\(?:c\\|pp\\)$" :trigger "__main.cpp" :mode c++-mode) - ("/win32_\\.c\\(?:c\\|pp\\)$" :trigger "__winmain.cpp" :mode c++-mode) - ("\\.c\\(?:c\\|pp\\)$" :trigger "__cpp" :mode c++-mode) - ("\\.h\\(?:h\\|pp\\|xx\\)$" :trigger "__hpp" :mode c++-mode) - ("\\.h$" :trigger "__h" :mode c-mode) - (c-mode :trigger "__c") - ;; direnv - ("/\\.envrc$" :trigger "__envrc" :mode direnv-envrc-mode) - ;; go - ("/main\\.go$" :trigger "__main.go" :mode go-mode :project t) - (go-mode :trigger "__.go") - ;; web-mode - ("/normalize\\.scss$" :trigger "__normalize.scss" :mode scss-mode) - ("/master\\.scss$" :trigger "__master.scss" :mode scss-mode) - ("\\.html$" :trigger "__.html" :mode web-mode) - (scss-mode) - ;; java - ("/main\\.java$" :trigger "__main" :mode java-mode) - ("/build\\.gradle$" :trigger "__build.gradle" :mode android-mode) - ("/src/.+\\.java$" :mode java-mode) - ;; javascript - ("/package\\.json$" :trigger "__package.json" :mode json-mode) - ("/bower\\.json$" :trigger "__bower.json" :mode json-mode) - ("/gulpfile\\.js$" :trigger "__gulpfile.js" :mode js-mode) - ("/webpack\\.config\\.js$" :trigger "__webpack.config.js" :mode js-mode) - ;; Lua - ("/main\\.lua$" :trigger "__main.lua" :mode love-mode) - ("/conf\\.lua$" :trigger "__conf.lua" :mode love-mode) - ;; Markdown - (markdown-mode) - ;; Markdown - (nxml-mode) - ;; Nix - ("/shell\\.nix$" :trigger "__shell.nix") - (nix-mode) - ;; Org - (doom-docs-org-mode - :trigger +file-templates-insert-doom-docs-fn - :mode org-mode) - (org-journal-mode :ignore t) - (org-mode) - ;; PHP - ("\\.class\\.php$" :trigger "__.class.php" :mode php-mode) - (php-mode) - ;; Python - ;; TODO ("tests?/test_.+\\.py$" :trigger "__" :mode nose-mode) - ;; TODO ("/setup\\.py$" :trigger "__setup.py" :mode python-mode) - (python-mode) - ;; Ruby - ("/lib/.+\\.rb$" :trigger "__module" :mode ruby-mode :project t) - ("/spec_helper\\.rb$" :trigger "__helper" :mode rspec-mode :project t) - ("_spec\\.rb$" :mode rspec-mode :project t) - ("/\\.rspec$" :trigger "__.rspec" :mode rspec-mode :project t) - ("\\.gemspec$" :trigger "__.gemspec" :mode ruby-mode :project t) - ("/Gemfile$" :trigger "__Gemfile" :mode ruby-mode :project t) - ("/Rakefile$" :trigger "__Rakefile" :mode ruby-mode :project t) - (ruby-mode) - ;; Rust - ("/Cargo\\.toml$" :trigger "__Cargo.toml" :mode rust-mode) - ("/main\\.rs$" :trigger "__main.rs" :mode rust-mode) - ;; Slim - ("/\\(?:index\\|main\\)\\.slim$" :mode slim-mode) - ;; Shell scripts - ("\\.zunit$" :trigger "__zunit" :mode sh-mode) - (fish-mode) - (sh-mode) - ;; Solidity - (solidity-mode :trigger "__sol")) - "An alist of file template rules. The CAR of each rule is either a major mode -symbol or regexp string. The CDR is a plist. See `set-file-template!' for more -information.") - - -;; -;;; Library - -(defun +file-templates-in-emacs-dirs-p (file) - "Returns t if FILE is in Doom or your private directory." - (or (file-in-directory-p file doom-user-dir) - (file-in-directory-p file doom-emacs-dir))) - -(defun +file-template-p (rule) - "Return t if RULE applies to the current buffer." - (let ((pred (car rule)) - (plist (cdr rule))) - (and (or (and (symbolp pred) - (eq major-mode pred)) - (and (stringp pred) - (stringp buffer-file-name) - (string-match-p pred buffer-file-name))) - (or (not (plist-member plist :when)) - (funcall (plist-get plist :when) - buffer-file-name)) - rule))) - -(defun +file-templates-check-h () - "Check if the current buffer is a candidate for file template expansion. It -must be non-read-only, empty, and there must be a rule in -`+file-templates-alist' that applies to it." - (and (not +file-templates-inhibit) - buffer-file-name ; this buffer represents a file and - (not buffer-read-only) ; ...isn't read-only - (bobp) (eobp) ; ...is empty - (not (member (substring (buffer-name) 0 1) '("*" " "))) ; ...isn't a "special" buffer - (not (bound-and-true-p org-capture-current-plist)) ; ...isn't an org-capture buffer - (not (file-exists-p buffer-file-name)) ; ...is a new file - (not (buffer-modified-p)) ; ...hasn't been modified - (null (buffer-base-buffer)) ; ...isn't an indirect clone - (when-let (rule (cl-find-if #'+file-template-p +file-templates-alist)) - (apply #'+file-templates--expand rule)))) - - -;; -;;; Bootstrap - -(after! yasnippet - (if (modulep! :editor snippets) - (add-to-list 'yas-snippet-dirs '+file-templates-dir 'append #'eq) - (setq yas-prompt-functions (delq #'yas-dropdown-prompt yas-prompt-functions) - yas-snippet-dirs '(+file-templates-dir)) - ;; Exit snippets on ESC from normal mode - (add-hook 'doom-escape-hook #'yas-abort-snippet) - ;; Ensure file templates in `+file-templates-dir' are visible - (yas-reload-all))) - -;; -(add-hook 'doom-switch-buffer-hook #'+file-templates-check-h) diff --git a/.config/emacs/modules/editor/file-templates/packages.el b/.config/emacs/modules/editor/file-templates/packages.el @@ -1,4 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; editor/file-templates/packages.el - -(package! yasnippet :pin "5cbdbf0d2015540c59ed8ee0fcf4788effdf75b6") diff --git a/.config/emacs/modules/editor/file-templates/templates/.editorconfig b/.config/emacs/modules/editor/file-templates/templates/.editorconfig @@ -1,7 +0,0 @@ -[*] -indent_style = space -indent_size = 4 -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = false -insert_final_newline = false diff --git a/.config/emacs/modules/editor/file-templates/templates/android-mode/__build.gradle b/.config/emacs/modules/editor/file-templates/templates/android-mode/__build.gradle @@ -1,49 +0,0 @@ -# -*- mode: snippet -*- -# name: build.gradle template -# condition: (eq major-mode 'groovy-mode) -# -- -buildscript { - repositories { - mavenCentral() - } - dependencies { - classpath 'com.android.tools.build:gradle:1.2.3' - } -} - -apply plugin: 'android' - -android { - compileSdkVersion 22 - buildToolsVersion "22.0.1" - - sourceSets { - main { - manifest.srcFile 'AndroidManifest.xml' - java.srcDirs = ['java'] - resources.srcDirs = ['java'] - aidl.srcDirs = ['java'] - renderscript.srcDirs = ['java'] - res.srcDirs = ['res'] - assets.srcDirs = ['assets'] - } - - // Move the tests to tests/java, tests/res, etc... - androidTest.setRoot('../tests') - - // Move the build types to build-types/<type> - // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ... - // This moves them out of them default location under src/<type>/... which would - // conflict with src/ being used by the main source set. - // Adding new build types or product flavors should be accompanied - // by a similar customization. - debug.setRoot('build-types/debug') - release.setRoot('build-types/release') - } - - lintOptions { - abortOnError false - } -} - -$0 diff --git a/.config/emacs/modules/editor/file-templates/templates/c++-mode/__cpp b/.config/emacs/modules/editor/file-templates/templates/c++-mode/__cpp @@ -1,7 +0,0 @@ -# -*- mode: snippet -*- -# group: file templates -# contributor: Henrik Lissner -# -- -#include "`(file-name-nondirectory (file-name-sans-extension (buffer-file-name)))`.h" - -$0 diff --git a/.config/emacs/modules/editor/file-templates/templates/c++-mode/__hpp b/.config/emacs/modules/editor/file-templates/templates/c++-mode/__hpp @@ -1,10 +0,0 @@ -# -*- mode: snippet -*- -# group: file templates -# contributor: Henrik Lissner -# -- -#ifndef ${1:`(upcase (file-name-base buffer-file-name))`_H_$(upcase yas-text)} -#define $1 - -$0 - -#endif // $1 diff --git a/.config/emacs/modules/editor/file-templates/templates/c++-mode/__main.cpp b/.config/emacs/modules/editor/file-templates/templates/c++-mode/__main.cpp @@ -1,13 +0,0 @@ -# -*- mode: snippet -*- -# group: file templates -# contributor: Henrik Lissner -# -- -#include <iostream> - -using namespace std; - -int main(int argc, char *argv[]) { - $0 - - return 0; -} diff --git a/.config/emacs/modules/editor/file-templates/templates/c++-mode/__winmain.cpp b/.config/emacs/modules/editor/file-templates/templates/c++-mode/__winmain.cpp @@ -1,12 +0,0 @@ -# -*- mode: snippet -*- -# group: file templates -# contributor: Henrik Lissner -# -- -#include <Windows.h> - -int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) -{ - $0 - - return 0; -} diff --git a/.config/emacs/modules/editor/file-templates/templates/c-mode/__c b/.config/emacs/modules/editor/file-templates/templates/c-mode/__c @@ -1,7 +0,0 @@ -# -*- mode: snippet -*- -# group: file templates -# contributor: Henrik Lissner -# -- -#include "`(file-name-nondirectory (file-name-sans-extension (buffer-file-name)))`.h" - -$0 diff --git a/.config/emacs/modules/editor/file-templates/templates/c-mode/__h b/.config/emacs/modules/editor/file-templates/templates/c-mode/__h @@ -1,10 +0,0 @@ -# -*- mode: snippet -*- -# group: file templates -# contributor: Henrik Lissner -# -- -#ifndef ${1:`(upcase (file-name-base buffer-file-name))`_H_$(upcase yas-text)} -#define $1 - -$0 - -#endif // $1 diff --git a/.config/emacs/modules/editor/file-templates/templates/direnv-envrc-mode/__envrc b/.config/emacs/modules/editor/file-templates/templates/direnv-envrc-mode/__envrc @@ -1,15 +0,0 @@ -# -*- mode: snippet -*- -# group: file templates -# contributor: Henrik Lissner -# condition: (executable-find "nix-env") -# -- -if type lorri &>/dev/null; then - echo "direnv: using lorri" - eval "$(lorri direnv)" -else - # fall back to using direnv's builtin nix support - # to prevent bootstrapping problems. - use nix -fi - -`%`$0 -\ No newline at end of file diff --git a/.config/emacs/modules/editor/file-templates/templates/dockerfile-mode/__ b/.config/emacs/modules/editor/file-templates/templates/dockerfile-mode/__ @@ -1,4 +0,0 @@ -FROM ${1:phusion/baseimage:latest} -MAINTAINER ${2:`user-full-name` <`user-mail-address`>} - -$0 -\ No newline at end of file diff --git a/.config/emacs/modules/editor/file-templates/templates/emacs-ert-mode/__ b/.config/emacs/modules/editor/file-templates/templates/emacs-ert-mode/__ @@ -1,3 +0,0 @@ -;;; `(file-name-nondirectory buffer-file-name)` - -$0 -\ No newline at end of file diff --git a/.config/emacs/modules/editor/file-templates/templates/emacs-lisp-mode/__doom-doctor b/.config/emacs/modules/editor/file-templates/templates/emacs-lisp-mode/__doom-doctor @@ -1,3 +0,0 @@ -;;; `(+file-templates-get-short-path)` -*- lexical-binding: t; -*- - -$0 diff --git a/.config/emacs/modules/editor/file-templates/templates/emacs-lisp-mode/__doom-module b/.config/emacs/modules/editor/file-templates/templates/emacs-lisp-mode/__doom-module @@ -1,3 +0,0 @@ -;;; `(+file-templates-get-short-path)` -*- lexical-binding: t; -*- - -$0 diff --git a/.config/emacs/modules/editor/file-templates/templates/emacs-lisp-mode/__doom-packages b/.config/emacs/modules/editor/file-templates/templates/emacs-lisp-mode/__doom-packages @@ -1,4 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; `(+file-templates-get-short-path)` - -$0 diff --git a/.config/emacs/modules/editor/file-templates/templates/emacs-lisp-mode/__doom-test b/.config/emacs/modules/editor/file-templates/templates/emacs-lisp-mode/__doom-test @@ -1,4 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; `(+file-templates-get-short-path)` - -$0 -\ No newline at end of file diff --git a/.config/emacs/modules/editor/file-templates/templates/emacs-lisp-mode/__doomrc b/.config/emacs/modules/editor/file-templates/templates/emacs-lisp-mode/__doomrc @@ -1,8 +0,0 @@ -;;; .doomrc --- doom runtime config -*- mode: emacs-lisp; lexical-binding: t; -*- -;;; Commentary: -;;; Code: -(require 'doom) ; be silent, byte-compiler - -$0`%` - -;;; .doomrc ends here diff --git a/.config/emacs/modules/editor/file-templates/templates/emacs-lisp-mode/__package b/.config/emacs/modules/editor/file-templates/templates/emacs-lisp-mode/__package @@ -1,25 +0,0 @@ -;;; `(file-name-nondirectory buffer-file-name)`${1: --- ${2:Description}} -*- lexical-binding: t; -*- -;; -;; Copyright (C) `(format-time-string "%Y")` `user-full-name` -;; -;; Author: `user-full-name` <`user-mail-address`> -;; Maintainer: `user-full-name` <`user-mail-address`> -;; Created: `(format-time-string "%B %d, %Y")` -;; Modified: `(format-time-string "%B %d, %Y")` -;; Version: 0.0.1 -;; Keywords: `(mapconcat #'symbol-name (mapcar #'car finder-known-keywords) " ")` -;; Homepage: https://github.com/`(cl-find-if-not #'string-empty-p (list (cdr (doom-call-process "git" "config" "github.user")) user-login-name))`/`(file-name-base buffer-file-name)` -;; Package-Requires: ((emacs "24.3")) -;; -;; This file is not part of GNU Emacs. -;; -;;; Commentary: -;; -;; $2 -;; -;;; Code: - -`%`$0 - -(provide '`(file-name-base buffer-file-name)`) -;;; `(file-name-nondirectory buffer-file-name)` ends here diff --git a/.config/emacs/modules/editor/file-templates/templates/fish-mode/__ b/.config/emacs/modules/editor/file-templates/templates/fish-mode/__ @@ -1,3 +0,0 @@ -#!/usr/bin/env fish - -$0 diff --git a/.config/emacs/modules/editor/file-templates/templates/gitignore-mode/__ b/.config/emacs/modules/editor/file-templates/templates/gitignore-mode/__ @@ -1,68 +0,0 @@ -.DS_Store -.idea -*.log -tmp/ - -`(let ((type-ignore (yas-choose-value '("(none)" "python" "ruby" "java" "js" "haskell" "clojure")))) - (string-join - (cond ((string= type-ignore "python") - '("*.py[cod]" - "*.egg" - "build" - "htmlcov")) - ((string= type-ignore "ruby") - '(".ruby-version" - ".bundle" - "vendor" - "Gemfile.lock" - "coverage")) - ((string= type-ignore "java") - '("*.class" - "build")) - ((string= type-ignore "js") - '("*.tern-port" - "node_modules/" - "npm-debug.log*" - "yarn-debug.log*" - "yarn-error.log*" - "*.tsbuildinfo" - ".npm" - ".eslintcache")) - ((string= type-ignore "haskell") - '("dist" - "dist-*" - "cabal-dev" - "*.o" - "*.hi" - "*.hie" - "*.chi" - "*.chs.h" - "*.dyn_o" - "*.dyn_hi" - ".hpc" - ".hsenv" - ".cabal-sandbox/" - "cabal.sandbox.config" - "*.prof" - "*.aux" - "*.hp" - "*.eventlog" - ".stack-work/" - "cabal.project.local" - "cabal.project.local~" - ".HTF/" - ".ghc.environment.*")) - ((string= type-ignore "clojure") - '("/target" - "/classes" - "/checkouts" - "profiles.clj" - "pom.xml" - "pom.xml.asc" - "*.jar" - "*.class" - "/.lein-*" - "/.nrepl-port" - "/.prepl-port" - "/.cpcache"))) - "\n"))` diff --git a/.config/emacs/modules/editor/file-templates/templates/go-mode/__.go b/.config/emacs/modules/editor/file-templates/templates/go-mode/__.go @@ -1,7 +0,0 @@ -package ${1:main} - -import ( - "fmt" -) - -$0 -\ No newline at end of file diff --git a/.config/emacs/modules/editor/file-templates/templates/go-mode/__main.go b/.config/emacs/modules/editor/file-templates/templates/go-mode/__main.go @@ -1,9 +0,0 @@ -package ${1:main} - -import ( - "fmt" -) - -func main() { - $0 -} -\ No newline at end of file diff --git a/.config/emacs/modules/editor/file-templates/templates/java-mode/__annotation-type b/.config/emacs/modules/editor/file-templates/templates/java-mode/__annotation-type @@ -1,9 +0,0 @@ -# -*- mode: snippet -*- -# name: Java annotation type file template -# -- -package `(+java-current-package)`; - -public @interface `(+java-current-class)` -{ - $0 -} -\ No newline at end of file diff --git a/.config/emacs/modules/editor/file-templates/templates/java-mode/__class b/.config/emacs/modules/editor/file-templates/templates/java-mode/__class @@ -1,9 +0,0 @@ -# -*- mode: snippet -*- -# name: Java class file template -# -- -package `(+java-current-package)`; - -public class `(+java-current-class)` $1 -{ - $0 -} diff --git a/.config/emacs/modules/editor/file-templates/templates/java-mode/__enum b/.config/emacs/modules/editor/file-templates/templates/java-mode/__enum @@ -1,9 +0,0 @@ -# -*- mode: snippet -*- -# name: Java enum file template -# -- -package `(+java-current-package)`; - -public enum `(+java-current-class)` -{ - $0 -} -\ No newline at end of file diff --git a/.config/emacs/modules/editor/file-templates/templates/java-mode/__interface b/.config/emacs/modules/editor/file-templates/templates/java-mode/__interface @@ -1,9 +0,0 @@ -# -*- mode: snippet -*- -# name: Java interface file template -# -- -package `(+java-current-package)`; - -public interface `(+java-current-class)` -{ - $0 -} -\ No newline at end of file diff --git a/.config/emacs/modules/editor/file-templates/templates/java-mode/__main b/.config/emacs/modules/editor/file-templates/templates/java-mode/__main @@ -1,11 +0,0 @@ -# -*- mode: snippet -*- -# name: Java MAIN file template -# -- -package `(+java-current-package)`; - -public class `(+java-current-class)` $1 -{ - public static void main(String[] args) { - $0 - } -} diff --git a/.config/emacs/modules/editor/file-templates/templates/java-mode/__record b/.config/emacs/modules/editor/file-templates/templates/java-mode/__record @@ -1,8 +0,0 @@ -# -*- mode: snippet -*- -# name: Java record file template -# -- -package `(+java-current-package)`; - -public record `(+java-current-class)`($0) $1 -{ -} -\ No newline at end of file diff --git a/.config/emacs/modules/editor/file-templates/templates/js-mode/__ b/.config/emacs/modules/editor/file-templates/templates/js-mode/__ @@ -1,3 +0,0 @@ -"use strict"; - -$0 diff --git a/.config/emacs/modules/editor/file-templates/templates/js-mode/__gulpfile.js b/.config/emacs/modules/editor/file-templates/templates/js-mode/__gulpfile.js @@ -1,4 +0,0 @@ -const gulp = require('gulp'); - -// Default task -gulp.task('default', [$1]); -\ No newline at end of file diff --git a/.config/emacs/modules/editor/file-templates/templates/js-mode/__node b/.config/emacs/modules/editor/file-templates/templates/js-mode/__node @@ -1,3 +0,0 @@ -#!/usr/bin/env node - -$0 diff --git a/.config/emacs/modules/editor/file-templates/templates/js-mode/__webpack.config.js b/.config/emacs/modules/editor/file-templates/templates/js-mode/__webpack.config.js @@ -1,21 +0,0 @@ -module.exports = { - entry: [ - ${1:'./app/main.js'} - ], - output: { - path: __dirname + '/dist', - filename: "app.bundle.js" - }, - module: { - rules: [ - { - test: /\.js$/, - exclude: /node_modules/, - use: { - loader: "babel-loader" - } - } - ] - }, - // plugins: [] -}; diff --git a/.config/emacs/modules/editor/file-templates/templates/json-mode/__bower.json b/.config/emacs/modules/editor/file-templates/templates/json-mode/__bower.json @@ -1,14 +0,0 @@ -{ - "name": "${1:package-name}", - "description": "${2:description}", - "license": "MIT", - "authors": [ - "`user-full-name` <`user-mail-address`>" - ], - "main": "public/app.js", - "moduleType": [], - "homepage": "", - "dependencies": { - `%`$0 - } -} -\ No newline at end of file diff --git a/.config/emacs/modules/editor/file-templates/templates/json-mode/__package.json b/.config/emacs/modules/editor/file-templates/templates/json-mode/__package.json @@ -1,13 +0,0 @@ -{ - "name": "${1:package-name}", - "description": "${2:description}", - "version": "1.0.0", - "author": "`user-full-name` <`user-mail-address`>", - "license": "MIT", - "main": "${3:app/${4:main.js}}", - "scripts": { - $0 - }, - "dependencies": {}, - "devDependencies": {} -} -\ No newline at end of file diff --git a/.config/emacs/modules/editor/file-templates/templates/love-mode/__conf.lua b/.config/emacs/modules/editor/file-templates/templates/love-mode/__conf.lua @@ -1,40 +0,0 @@ -# -*- mode: snippet -*- -# name: love.conf -# condition: (eq major-mode 'lua-mode) -# -- -function love.conf(t) - t.identity = nil -- The name of the save directory (string) - t.version = "0.9.1" -- The LÖVE version this game was made for (string) - t.console = false -- Attach a console (boolean, Windows only) - - t.window.title = "${1:Untitled}" -- The window title (string) - t.window.icon = nil -- Filepath to an image to use as the window's icon (string) - t.window.width = 800 -- The window width (number) - t.window.height = 600 -- The window height (number) - t.window.borderless = false -- Remove all border visuals from the window (boolean) - t.window.resizable = false -- Let the window be user-resizable (boolean) - t.window.minwidth = 1 -- Minimum window width if the window is resizable (number) - t.window.minheight = 1 -- Minimum window height if the window is resizable (number) - t.window.fullscreen = false -- Enable fullscreen (boolean) - t.window.fullscreentype = "normal" -- Standard fullscreen or desktop fullscreen mode (string) - t.window.vsync = true -- Enable vertical sync (boolean) - t.window.fsaa = 0 -- The number of samples to use with multi-sampled antialiasing (number) - t.window.display = 1 -- Index of the monitor to show the window in (number) - t.window.highdpi = false -- Enable high-dpi mode for the window on a Retina display (boolean). Added in 0.9.1 - t.window.srgb = false -- Enable sRGB gamma correction when drawing to the screen (boolean). Added in 0.9.1 - - t.modules.audio = true -- Enable the audio module (boolean) - t.modules.event = true -- Enable the event module (boolean) - t.modules.graphics = true -- Enable the graphics module (boolean) - t.modules.image = true -- Enable the image module (boolean) - t.modules.joystick = true -- Enable the joystick module (boolean) - t.modules.keyboard = true -- Enable the keyboard module (boolean) - t.modules.math = true -- Enable the math module (boolean) - t.modules.mouse = true -- Enable the mouse module (boolean) - t.modules.physics = true -- Enable the physics module (boolean) - t.modules.sound = true -- Enable the sound module (boolean) - t.modules.system = true -- Enable the system module (boolean) - t.modules.timer = true -- Enable the timer module (boolean) - t.modules.window = true -- Enable the window module (boolean) - t.modules.thread = true -- Enable the thread module (boolean) -end diff --git a/.config/emacs/modules/editor/file-templates/templates/love-mode/__main.lua b/.config/emacs/modules/editor/file-templates/templates/love-mode/__main.lua diff --git a/.config/emacs/modules/editor/file-templates/templates/makefile-gmake-mode/__ b/.config/emacs/modules/editor/file-templates/templates/makefile-gmake-mode/__ @@ -1,9 +0,0 @@ -## -# ${1:Project Title} -# -# @file -# @version 0.1 - -$0 - -# end diff --git a/.config/emacs/modules/editor/file-templates/templates/makefile-gmake-mode/__cpp b/.config/emacs/modules/editor/file-templates/templates/makefile-gmake-mode/__cpp @@ -1,46 +0,0 @@ -# -*- mode: snippet -*- -# contributor: Henrik Lissner -# -- -CC = clang++ -TAGS = ctags -e -x >TAGS -FLAGS = -std=c++11 -stdlib=libc++ -Iinclude -I/usr/local/include -L/usr/local/lib -CFLAGS = -pedantic -Wall -Wextra -ggdb3 -LIBS = # ... - -DEBUG_FLAGS = -O0 -D _DEBUG -RELEASE_FLAGS = -O2 -D NDEBUG -combile -fwhole-program - -RELEASE_DIR = ./build/release -DEBUG_DIR = ./build/debug - -TARGET = ${1:appname$(replace-regexp-in-string " " "" yas-text nil t)} -HEADERS = \$(shell echo include/*.h) -SOURCES = \$(shell echo src/*.cpp) \$(shell echo src/**/*.cpp) -OBJECTS = \$(SOURCES:.cpp=.o) - -### - -all: \$(TARGET) - -debug: FLAGS += \$(DEBUG_FLAGS) -debug: \$(TARGET) - -release: FLAGS += \$(RELEASE_FLAGS) -release: \$(TARGET) - -profile: CFLAGS += -pg -profile: \$(TARGET) - -\$(TARGET): \$(OBJECTS) - \$(CC) \$(FLAGS) \$(CFLAGS) -o \$(TARGET) \$(OBJECTS) - -%.o: %.cpp - \$(CC) \$(FLAGS) \$(CFLAGS) -c -o \$@ \$< - -tags: \$(SOURCES) - \$(CTAGS) \$(SOURCES) - -clean: - -rm -f \$(OBJECTS) \$(TARGET) - -.PHONY: all profile release debug clean -\ No newline at end of file diff --git a/.config/emacs/modules/editor/file-templates/templates/markdown-mode/__ b/.config/emacs/modules/editor/file-templates/templates/markdown-mode/__ @@ -1,6 +0,0 @@ -# -*- mode: snippet -*- -# group: file templates -# -- -# ${1:Document Title} - -$0 -\ No newline at end of file diff --git a/.config/emacs/modules/editor/file-templates/templates/markdown-mode/__jekyll-post b/.config/emacs/modules/editor/file-templates/templates/markdown-mode/__jekyll-post @@ -1,7 +0,0 @@ -# -*- mode: snippet -*- -# group: file templates -# -- ---- -layout: ${1:default} ---- -$0 diff --git a/.config/emacs/modules/editor/file-templates/templates/nix-mode/__ b/.config/emacs/modules/editor/file-templates/templates/nix-mode/__ @@ -1,9 +0,0 @@ -# -*- mode: snippet -*- -# group: file templates -# contributor: Henrik Lissner -# -- -{ config, lib, pkgs, ... }: - -{ - $0 -} -\ No newline at end of file diff --git a/.config/emacs/modules/editor/file-templates/templates/nix-mode/__shell.nix b/.config/emacs/modules/editor/file-templates/templates/nix-mode/__shell.nix @@ -1,9 +0,0 @@ -{ pkgs ? import <nixpkgs> {} }: - -with pkgs; - -mkShell { - buildInputs = [ - ${0:`%`} - ]; -} -\ No newline at end of file diff --git a/.config/emacs/modules/editor/file-templates/templates/nose-mode/__ b/.config/emacs/modules/editor/file-templates/templates/nose-mode/__ diff --git a/.config/emacs/modules/editor/file-templates/templates/nxml-mode/__ b/.config/emacs/modules/editor/file-templates/templates/nxml-mode/__ @@ -1,2 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -`%`$0 -\ No newline at end of file diff --git a/.config/emacs/modules/editor/file-templates/templates/org-mode/__ b/.config/emacs/modules/editor/file-templates/templates/org-mode/__ @@ -1,20 +0,0 @@ -# -*- mode: snippet -*- -# name: Org template -# -- -#+title: ${1:` -(string-join - (mapcar #'capitalize - ;; Replace -,_... with space - (split-string - (let (case-fold-search) - ;; Seperating lower from upper: hello|World - (replace-regexp-in-string - "\\([[:lower:]]\\)\\([[:upper:]]\\)" "\\1 \\2" - ;; Separating upper from (upper and lower): HTTP|Server - (replace-regexp-in-string "\\([[:upper:]]\\)\\([[:upper:]][0-9[:lower:]]\\)" - "\\1 \\2" (file-name-base buffer-file-name)))) - "[^[:word:]0-9]+" - )) " " ) -`} - -$0 -\ No newline at end of file diff --git a/.config/emacs/modules/editor/file-templates/templates/org-mode/__contact.org b/.config/emacs/modules/editor/file-templates/templates/org-mode/__contact.org @@ -1,17 +0,0 @@ -#+title:${1:Contact Name} -#+date: `(format-time-string "%Y-%m-%d")` -#+email: ${2:email@address.com} -#+address: $3 -#+city: $4 -#+country: $5 - -${0:...} - -* Associates -+ Associate's name :: associates@email.com -* Projects [/] -** ACTIVE ... [/] -* Invoices [/] -** PENDING YYMM-0000 *1,000 USD* -* Notes -* Correspondence diff --git a/.config/emacs/modules/editor/file-templates/templates/org-mode/__doom-category-readme b/.config/emacs/modules/editor/file-templates/templates/org-mode/__doom-category-readme @@ -1,13 +0,0 @@ -# -*- mode: snippet -*- -# name: Doom category readme -# -- -:PROPERTIES: -:ID: `(doom-docs-generate-id)` -:END: -#+title: `(+file-templates-module-for-path)` -#+created: `(format-time-string "%B %d, %Y")` -#+since: `(car (split-string doom-version "-"))` -$0 -* Description -Replace this with a description of what modules in this category are for, -including any important information (like load order constraints). -\ No newline at end of file diff --git a/.config/emacs/modules/editor/file-templates/templates/org-mode/__doom-docs b/.config/emacs/modules/editor/file-templates/templates/org-mode/__doom-docs @@ -1,10 +0,0 @@ -# -*- mode: snippet -*- -# name: Doom documentation -# -- -:PROPERTIES: -:ID: `(doom-docs-generate-id)` -:END: -#+title: ${1:Title} -#+subtitle: ${2:Subtitle} - -$0 -\ No newline at end of file diff --git a/.config/emacs/modules/editor/file-templates/templates/org-mode/__doom-readme b/.config/emacs/modules/editor/file-templates/templates/org-mode/__doom-readme @@ -1,197 +0,0 @@ -# -*- mode: snippet -*- -# name: Doom module readme -# -- -:PROPERTIES: -:ID: `(doom-docs-generate-id)` -:END: -#+title: `(+file-templates-module-for-path)` -#+subtitle: <A one-line quip about this module to display in init.example.el> -#+created: `(format-time-string "%B %d, %Y")` -#+since: `(car (split-string doom-version "-"))` (#COMMIT-OR-PR-REF) - -* Description :unfold: -$0Replace this with a short (1-2 sentence) description of what this module does. -This is displayed in the module index. - -Then a longer, multiple paragraph description goes here, which should explain -the purpose of the module and the features/technology(ies) it provides. - -** Maintainers -- [[doom-user:][@github_username]] -- [[doom-user:][@github_username]] -- [[doom-user:][@github_username]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -# If a module has no maintainers and can't be casually maintained by Henrik -# alone, use: -*This module needs a maintainer.* [[doom-contrib-maintainer:][Become a maintainer?]] - -# Otherwise, use: -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -# Flags should be in alphanumerical order. -- +bar :: - A short description of what this flag does and what it might need when - enabled. -- +childframe :: - Display X in a [[https://www.gnu.org/software/emacs/manual/html_node/elisp/Child-Frames.html][child frame]] rather than an overlay or tooltip. *Requires GUI - Emacs.* -- +lsp :: - Enable LSP support for ~X-mode~. Requires [[doom-module::tools lsp]] and a - langserver (supports A, B, and C). - -# If this module has no flags, then... -/This module has no flags./ - -# If this module has flags but you can't document them now, add a TODO to the -# heading and use: -#+begin_quote - 🔨 This module has flags, but they aren't documented yet. [[doom-contrib-module:][Document them?]] -#+end_quote - -** Packages -- [[doom-package:org]] -- [[doom-package:org-contrib]] if [[doom-module:+contrib]] -- [[doom-package:org-bullets]] unless [[doom-module:+bullets]] -- if [[doom-module:+present]] - - [[doom-package:centered-window]] - - [[doom-package:org-tree-slide]] - - [[doom-package:org-re-reveal]] - -# If this module installs no packages, then... -/This module doesn't install any packages./ - -# If this module installs packages, but you can't document them now, add a TODO -# to the heading and use: -#+begin_quote - 🔨 This module installs packages, but they aren't documented yet. [[doom-contrib-module:][Document - them?]] -#+end_quote - -** Hacks -# Place a list of internal (and potentially unexpected) modifications to -# included packages: -- Fixed X which should help you do Y -- Advised Z to work harder, better, faster, stronger. -- Tricked the hobbitses into giving me the precious. - -# If there aren't any hacks, use: -/No hacks documented for this module./ - -# If this module contains hacks, but you can't document them now, add a TODO to -# the heading and use: -#+begin_quote - 🔨 This module's hacks haven't been documented yet. [[doom-contrib-module:][Document them?]] -#+end_quote - -** TODO Changelog -# Do not edit this by hand. Your commits are your changelog. Commits that -# shouldn't show up should use the 'Amend: ...' trailer (see -# https://docs.doomemacs.org/-/git-conventions for details). -# -# ALSO: Version headings should be linked to the respective heading in -# docs/changelog.org. -*** [[doom-tag:][v21.12.0]] [2021-12-30] -**** [[doom-ref:a1b2c3d4][commit SUBJECT linked to github commit]] -commit BODY -**** [[doom-ref:a1b2c3d4][commit SUBJECT linked to github commit]] -commit BODY -**** [[doom-ref:a1b2c3d4][commit SUBJECT linked to github commit]] -commit BODY - -# If no changelog is available, use: -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -# This section should describe, in-depth, how to set up this module and its -# dependencies, starting with this line: -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] -# ...Then list its external requirements, if any. -This module requires: -- ... -- ... -- ... -# And finally, go into detail about how to install them. - -# If there are no external requirements, use: -/This module has no external requirements./ - -# If there are prerequisites but you can't document them yet, add TODO to the -# heading and use: -#+begin_quote - 🔨 /No installation steps have been documented./ [[doom-contrib-module:][Document them?]] -#+end_quote - -* Usage -# Walk the user through how this module is used. - -# If this is left empty, add TODO to the heading and use: -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -# If this section has incomplete content, add TODO to the heading and use: -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -* TODO Configuration -# Walk the user through how to configure this module, including any variables it -# exposes or user-facing configuration API. - -# If this is left empty, add TODO to the heading and use: -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -# If this section has incomplete content, add TODO to the heading and use: -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -* Troubleshooting -# List common issues and any workarounds/solutions, or link to external resources. -[[doom-report:][Report an issue?]] - -** Common issue -Solution. -** Common issue -Solution. -** Common issue -Solution. - -# If this is left empty, use: -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -[[doom-suggest-faq:][Ask a question?]] - -# This is for adoption, design, or niche questions. More general -# usage/configuration matters should be covered in the sections above. -** Question -Answer -** Question -Answer -** Question -Answer - -# If no questions are available, use -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -# A glossary of important major modes, minor modes, commands, functions, faces, -# and variables that this module exposes. It doesn't have to be exhaustive and -# should omit explanation/documentation. - -# If this is left empty, add TODO to the heading and use: -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote - -# If this section has incomplete content, add TODO to the heading and use: -#+begin_quote - 🔨 /This module's appendix is incomplete./ [[doom-contrib-module:][Write more?]] -#+end_quote -\ No newline at end of file diff --git a/.config/emacs/modules/editor/file-templates/templates/org-mode/__invoice.org b/.config/emacs/modules/editor/file-templates/templates/org-mode/__invoice.org @@ -1,21 +0,0 @@ -#+title:${1:1234-5678} -#+date: `(format-time-string "%Y-%m-%d")` -#+issued: ${2:`(format-time-string "%Y-%m-%d")`} -#+paid: ${3:`(format-time-string "%Y-%m-%d")`} -#+currency: ${4:CAD|USD|DKK|GBP} -#+contact: ${5:Contact ID} -#+project: ${6:Project ID} - -| *Description* | *qty* | *rate* | *total* | -|----------------------------------------------+-----+--------+-------| -| $0 [1] | | | | -|----------------------------------------------+-----+--------+-------| -| | | | | -#+tblfm: $4=$2+$3::@>$4=vsum(@2..@-1) - -[1] ... - -* Comments -... -* Notes -** Attachments [0/0] -\ No newline at end of file diff --git a/.config/emacs/modules/editor/file-templates/templates/org-mode/__project.org b/.config/emacs/modules/editor/file-templates/templates/org-mode/__project.org @@ -1,9 +0,0 @@ -#+title:${1:Project Name} -#+date: `(format-time-string "%Y-%m-%d")` -#+contact: ${2:Contact name} - -$0 - -* Tasks [/] -* Timeframe -* Notes diff --git a/.config/emacs/modules/editor/file-templates/templates/php-mode/__ b/.config/emacs/modules/editor/file-templates/templates/php-mode/__ @@ -1,3 +0,0 @@ -<?php - -$0 diff --git a/.config/emacs/modules/editor/file-templates/templates/php-mode/__.class.php b/.config/emacs/modules/editor/file-templates/templates/php-mode/__.class.php @@ -1,7 +0,0 @@ -<?php - -class `(doom/php-class-name)`$1 { - - $0 - -} diff --git a/.config/emacs/modules/editor/file-templates/templates/python-mode/__ b/.config/emacs/modules/editor/file-templates/templates/python-mode/__ @@ -1,5 +0,0 @@ -# -*- mode: snippet -*- -# -- -#!/usr/bin/env `(file-name-nondirectory python-shell-interpreter)` - -$0 -\ No newline at end of file diff --git a/.config/emacs/modules/editor/file-templates/templates/python-mode/__setup.py b/.config/emacs/modules/editor/file-templates/templates/python-mode/__setup.py diff --git a/.config/emacs/modules/editor/file-templates/templates/rspec-mode/__ b/.config/emacs/modules/editor/file-templates/templates/rspec-mode/__ @@ -1,3 +0,0 @@ -# `(file-name-nondirectory buffer-file-name)` - -$0 -\ No newline at end of file diff --git a/.config/emacs/modules/editor/file-templates/templates/rspec-mode/__.rspec b/.config/emacs/modules/editor/file-templates/templates/rspec-mode/__.rspec @@ -1,3 +0,0 @@ ---color ---require spec_helper ---format=d diff --git a/.config/emacs/modules/editor/file-templates/templates/rspec-mode/__helper b/.config/emacs/modules/editor/file-templates/templates/rspec-mode/__helper @@ -1,9 +0,0 @@ -require 'bundler' - -$:.unshift File.expand_path('../lib', __FILE__) - -RSpec.configure do |c| - c.tty = true -end - -$0 -\ No newline at end of file diff --git a/.config/emacs/modules/editor/file-templates/templates/ruby-mode/__ b/.config/emacs/modules/editor/file-templates/templates/ruby-mode/__ @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby - -$0 diff --git a/.config/emacs/modules/editor/file-templates/templates/ruby-mode/__.gemspec b/.config/emacs/modules/editor/file-templates/templates/ruby-mode/__.gemspec diff --git a/.config/emacs/modules/editor/file-templates/templates/ruby-mode/__Gemfile b/.config/emacs/modules/editor/file-templates/templates/ruby-mode/__Gemfile @@ -1,3 +0,0 @@ -source 'https://rubygems.org' - -gem '$0' diff --git a/.config/emacs/modules/editor/file-templates/templates/ruby-mode/__Rakefile b/.config/emacs/modules/editor/file-templates/templates/ruby-mode/__Rakefile @@ -1,16 +0,0 @@ -require 'bundler/setup' -$:.unshift File.expand_path('../lib', __FILE__) - -# rake spec -require 'rspec/core/rake_task' -RSpec::Core::RakeTask.new(:spec) { |t| t.verbose = false } - -# rake console -task :console do - require 'pry' - require '${1:gem_name}' - ARGV.clear - Pry.start -end - -$0 -\ No newline at end of file diff --git a/.config/emacs/modules/editor/file-templates/templates/ruby-mode/__module b/.config/emacs/modules/editor/file-templates/templates/ruby-mode/__module @@ -1,12 +0,0 @@ -# `(progn - (setq-local pkgs (split-string (string-remove-prefix (concat (doom-project-root) "lib/") (file-name-sans-extension buffer-file-name)) "/" t)) - (setq-local pkgs-p (eq (length pkgs) 1)) - (setq-local pkg-module (replace-regexp-in-string " " "::" (capitalize (if pkgs-p (car pkgs) (string-join (butlast pkgs) " "))) nil t)) - - (concat "lib/" (file-name-nondirectory buffer-file-name)))` - -module `pkg-module` -`(when pkgs-p " VERSION='0.0.1'\n\n")``(concat " class " (if pkgs-p "<< self" (capitalize (car (last pkgs)))))` - `%`${0:# Code here} - end -end -\ No newline at end of file diff --git a/.config/emacs/modules/editor/file-templates/templates/rust-mode/__Cargo.toml b/.config/emacs/modules/editor/file-templates/templates/rust-mode/__Cargo.toml @@ -1,5 +0,0 @@ -[package] -name = "${1:Project Name}" -version = "0.0.1" -authors = [ "`user-full-name` <`user-mail-address`>" ] -$0 diff --git a/.config/emacs/modules/editor/file-templates/templates/rust-mode/__main.rs b/.config/emacs/modules/editor/file-templates/templates/rust-mode/__main.rs @@ -1,3 +0,0 @@ -fn main() { - ${0:println!("Hello, world!");} -} diff --git a/.config/emacs/modules/editor/file-templates/templates/scss-mode/__ b/.config/emacs/modules/editor/file-templates/templates/scss-mode/__ diff --git a/.config/emacs/modules/editor/file-templates/templates/scss-mode/__master.scss b/.config/emacs/modules/editor/file-templates/templates/scss-mode/__master.scss diff --git a/.config/emacs/modules/editor/file-templates/templates/scss-mode/__normalize.scss b/.config/emacs/modules/editor/file-templates/templates/scss-mode/__normalize.scss diff --git a/.config/emacs/modules/editor/file-templates/templates/sh-mode/__ b/.config/emacs/modules/editor/file-templates/templates/sh-mode/__ @@ -1,3 +0,0 @@ -#!/usr/bin/env `(format "%s" sh-shell)` - -$0 diff --git a/.config/emacs/modules/editor/file-templates/templates/sh-mode/__zunit b/.config/emacs/modules/editor/file-templates/templates/sh-mode/__zunit @@ -1,5 +0,0 @@ -#!/usr/bin/env zunit - -@test '...' { - $0 -} diff --git a/.config/emacs/modules/editor/file-templates/templates/slim-mode/__ b/.config/emacs/modules/editor/file-templates/templates/slim-mode/__ @@ -1,17 +0,0 @@ -doctype html -html(lang="en") - head - meta charset="utf-8" - meta http-equiv="x-ua-compatible" content="ie=edge" - - title ${1:Page Title} - meta name="description" content="" - meta name="viewport" content="width=device-width, initial-scale=1" - - / link rel="apple-touch-icon" href="apple-touch-icon.png" - - link rel="stylesheet" type="text/css" href="css/master.css" - - script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.min.js" - body - $0 diff --git a/.config/emacs/modules/editor/file-templates/templates/snippet-mode/__ b/.config/emacs/modules/editor/file-templates/templates/snippet-mode/__ @@ -1,8 +0,0 @@ -# -*- mode: snippet -*- -# -- -# -*- mode: snippet -*- -# name: $1 -# key: ${2:trigger-key}${3: -# condition: t} -# -- -$0 diff --git a/.config/emacs/modules/editor/file-templates/templates/solidity-mode/__sol b/.config/emacs/modules/editor/file-templates/templates/solidity-mode/__sol @@ -1,12 +0,0 @@ -# -*- mode: snippet -*- -# group: file templates -# contributor: Edmund Miller -# name: solidity template -# -- -// SPDX-License-Identifier: ${1:UNLICENSED} - -pragma solidity ${2:>=0.8.7 <0.9.0}; - -contract $3 { - $0 -} -\ No newline at end of file diff --git a/.config/emacs/modules/editor/file-templates/templates/text-mode/__license b/.config/emacs/modules/editor/file-templates/templates/text-mode/__license @@ -1,5 +0,0 @@ -# -*- mode: snippet -*- -# name: Insert a license -# type: command -# -- -(+file-templates/insert-license) -\ No newline at end of file diff --git a/.config/emacs/modules/editor/file-templates/templates/text-mode/__license-apache b/.config/emacs/modules/editor/file-templates/templates/text-mode/__license-apache @@ -1,208 +0,0 @@ -# -*- mode: snippet -*- -# name: Apache License 2.0 -# uuid: __license-apache -# group: Licenses -# contributor: https://choosealicense.com/licenses/apache-2.0/ -# expand-env: ((yas-indent-line 'fixed)) -# -- - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright `(format-time-string "%Y")` ${1:`user-full-name`} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/.config/emacs/modules/editor/file-templates/templates/text-mode/__license-apache-bp b/.config/emacs/modules/editor/file-templates/templates/text-mode/__license-apache-bp @@ -1,20 +0,0 @@ -# -*- mode: snippet -*- -# name: Apache License 2.0 (boilerplate) -# uuid: __license-apache-bp -# group: Licenses -# contributor: https://choosealicense.com/licenses/apache-2.0/ -# expand-env: ((yas-indent-line 'fixed)) -# -- -Copyright ${1:`(format-time-string "%Y")` `user-full-name`} - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -\ No newline at end of file diff --git a/.config/emacs/modules/editor/file-templates/templates/text-mode/__license-bsd2 b/.config/emacs/modules/editor/file-templates/templates/text-mode/__license-bsd2 @@ -1,29 +0,0 @@ -# -*- mode: snippet -*- -# name: 2-clause BSD License -# uuid: __license-bsd2 -# group: Licenses -# expand-env: ((yas-indent-line 'fixed)) -# -- -Copyright (c) ${1:`(format-time-string "%Y")`} ${2:`user-full-name`} -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation and/or -other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/.config/emacs/modules/editor/file-templates/templates/text-mode/__license-bsd3 b/.config/emacs/modules/editor/file-templates/templates/text-mode/__license-bsd3 @@ -1,33 +0,0 @@ -# -*- mode: snippet -*- -# name: 3-clause BSD License -# uuid: __license-bsd3 -# group: Licenses -# expand-env: ((yas-indent-line 'fixed)) -# -- -Copyright (c) ${1:`(format-time-string "%Y")`} ${2:`user-full-name`} -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation and/or -other materials provided with the distribution. - -3. Neither the name of the copyright holder nor the names of its contributors -may be used to endorse or promote products derived from this software without -specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/.config/emacs/modules/editor/file-templates/templates/text-mode/__license-gpl3 b/.config/emacs/modules/editor/file-templates/templates/text-mode/__license-gpl3 @@ -1,681 +0,0 @@ -# -*- mode: snippet -*- -# name: GNU GPL 3.0 License -# uuid: __license-gpl3 -# group: Licenses -# contributor: https://choosealicense.com/licenses/gpl-3.0/ -# expand-env: ((yas-indent-line 'fixed)) -# -- - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - ${4:<one line to give the program's name and a brief idea of what it does.>} - Copyright (C) ${1:`(format-time-string "%Y")`} ${2:`user-full-name`} - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - <program> Copyright (C) <year> <name of author> - This program comes with ABSOLUTELY NO WARRANTY; for details type \`show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type \`show c' for details. - -The hypothetical commands \`show w' and \`show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -<http://www.gnu.org/licenses/>. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -<http://www.gnu.org/philosophy/why-not-lgpl.html>. diff --git a/.config/emacs/modules/editor/file-templates/templates/text-mode/__license-gpl3-bp b/.config/emacs/modules/editor/file-templates/templates/text-mode/__license-gpl3-bp @@ -1,22 +0,0 @@ -# -*- mode: snippet -*- -# name: GNU GPL 3.0 License (boilerplate) -# uuid: __license-gpl3-bp -# group: Licenses -# contributor: https://choosealicense.com/licenses/lgpl-3.0 -# expand-env: ((yas-indent-line 'fixed)) -# -- -${1:<program name and description>} -Copyright (C) ${2:`(format-time-string "%Y")`} ${3:`user-full-name`} - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see <http://www.gnu.org/licenses/>. -\ No newline at end of file diff --git a/.config/emacs/modules/editor/file-templates/templates/text-mode/__license-lgpl3 b/.config/emacs/modules/editor/file-templates/templates/text-mode/__license-lgpl3 @@ -1,172 +0,0 @@ -# -*- mode: snippet -*- -# name: GNU LGPL v3 License -# uuid: __license-lgpl3 -# group: Licenses -# contribuer: https://choosealicense.com/licenses/lgpl-3.0/ -# expand-env: ((yas-indent-line 'fixed)) -# -- - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser General Public License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff --git a/.config/emacs/modules/editor/file-templates/templates/text-mode/__license-mit b/.config/emacs/modules/editor/file-templates/templates/text-mode/__license-mit @@ -1,29 +0,0 @@ -# -*- mode: snippet -*- -# name: MIT License -# uuid: __license-mit -# group: Licenses -# contributor: https://choosealicense.com/licenses/mit/ -# expand-env: ((yas-indent-line 'fixed)) -# -- -The MIT License (MIT) - -Copyright (c) ${1:`(format-time-string "%Y")`} ${2:`user-full-name`} - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/.config/emacs/modules/editor/file-templates/templates/text-mode/__license-mozilla b/.config/emacs/modules/editor/file-templates/templates/text-mode/__license-mozilla @@ -1,381 +0,0 @@ -# -*- mode: snippet -*- -# name: Mozilla Public License 2.0 -# uuid: __license-mozilla -# group: Licenses -# contributor: https://choosealicense.com/licenses/mpl-2.0 -# expand-env: ((yas-indent-line 'fixed)) -# -- -Mozilla Public License Version 2.0 -================================== - -1. Definitions --------------- - -1.1. "Contributor" - means each individual or legal entity that creates, contributes to - the creation of, or owns Covered Software. - -1.2. "Contributor Version" - means the combination of the Contributions of others (if any) used - by a Contributor and that particular Contributor's Contribution. - -1.3. "Contribution" - means Covered Software of a particular Contributor. - -1.4. "Covered Software" - means Source Code Form to which the initial Contributor has attached - the notice in Exhibit A, the Executable Form of such Source Code - Form, and Modifications of such Source Code Form, in each case - including portions thereof. - -1.5. "Incompatible With Secondary Licenses" - means - - (a) that the initial Contributor has attached the notice described - in Exhibit B to the Covered Software; or - - (b) that the Covered Software was made available under the terms of - version 1.1 or earlier of the License, but not also under the - terms of a Secondary License. - -1.6. "Executable Form" - means any form of the work other than Source Code Form. - -1.7. "Larger Work" - means a work that combines Covered Software with other material, in - a separate file or files, that is not Covered Software. - -1.8. "License" - means this document. - -1.9. "Licensable" - means having the right to grant, to the maximum extent possible, - whether at the time of the initial grant or subsequently, any and - all of the rights conveyed by this License. - -1.10. "Modifications" - means any of the following: - - (a) any file in Source Code Form that results from an addition to, - deletion from, or modification of the contents of Covered - Software; or - - (b) any new file in Source Code Form that contains any Covered - Software. - -1.11. "Patent Claims" of a Contributor - means any patent claim(s), including without limitation, method, - process, and apparatus claims, in any patent Licensable by such - Contributor that would be infringed, but for the grant of the - License, by the making, using, selling, offering for sale, having - made, import, or transfer of either its Contributions or its - Contributor Version. - -1.12. "Secondary License" - means either the GNU General Public License, Version 2.0, the GNU - Lesser General Public License, Version 2.1, the GNU Affero General - Public License, Version 3.0, or any later versions of those - licenses. - -1.13. "Source Code Form" - means the form of the work preferred for making modifications. - -1.14. "You" (or "Your") - means an individual or a legal entity exercising rights under this - License. For legal entities, "You" includes any entity that - controls, is controlled by, or is under common control with You. For - purposes of this definition, "control" means (a) the power, direct - or indirect, to cause the direction or management of such entity, - whether by contract or otherwise, or (b) ownership of more than - fifty percent (50%) of the outstanding shares or beneficial - ownership of such entity. - -2. License Grants and Conditions --------------------------------- - -2.1. Grants - -Each Contributor hereby grants You a world-wide, royalty-free, -non-exclusive license: - -(a) under intellectual property rights (other than patent or trademark) - Licensable by such Contributor to use, reproduce, make available, - modify, display, perform, distribute, and otherwise exploit its - Contributions, either on an unmodified basis, with Modifications, or - as part of a Larger Work; and - -(b) under Patent Claims of such Contributor to make, use, sell, offer - for sale, have made, import, and otherwise transfer either its - Contributions or its Contributor Version. - -2.2. Effective Date - -The licenses granted in Section 2.1 with respect to any Contribution -become effective for each Contribution on the date the Contributor first -distributes such Contribution. - -2.3. Limitations on Grant Scope - -The licenses granted in this Section 2 are the only rights granted under -this License. No additional rights or licenses will be implied from the -distribution or licensing of Covered Software under this License. -Notwithstanding Section 2.1(b) above, no patent license is granted by a -Contributor: - -(a) for any code that a Contributor has removed from Covered Software; - or - -(b) for infringements caused by: (i) Your and any other third party's - modifications of Covered Software, or (ii) the combination of its - Contributions with other software (except as part of its Contributor - Version); or - -(c) under Patent Claims infringed by Covered Software in the absence of - its Contributions. - -This License does not grant any rights in the trademarks, service marks, -or logos of any Contributor (except as may be necessary to comply with -the notice requirements in Section 3.4). - -2.4. Subsequent Licenses - -No Contributor makes additional grants as a result of Your choice to -distribute the Covered Software under a subsequent version of this -License (see Section 10.2) or under the terms of a Secondary License (if -permitted under the terms of Section 3.3). - -2.5. Representation - -Each Contributor represents that the Contributor believes its -Contributions are its original creation(s) or it has sufficient rights -to grant the rights to its Contributions conveyed by this License. - -2.6. Fair Use - -This License is not intended to limit any rights You have under -applicable copyright doctrines of fair use, fair dealing, or other -equivalents. - -2.7. Conditions - -Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted -in Section 2.1. - -3. Responsibilities -------------------- - -3.1. Distribution of Source Form - -All distribution of Covered Software in Source Code Form, including any -Modifications that You create or to which You contribute, must be under -the terms of this License. You must inform recipients that the Source -Code Form of the Covered Software is governed by the terms of this -License, and how they can obtain a copy of this License. You may not -attempt to alter or restrict the recipients' rights in the Source Code -Form. - -3.2. Distribution of Executable Form - -If You distribute Covered Software in Executable Form then: - -(a) such Covered Software must also be made available in Source Code - Form, as described in Section 3.1, and You must inform recipients of - the Executable Form how they can obtain a copy of such Source Code - Form by reasonable means in a timely manner, at a charge no more - than the cost of distribution to the recipient; and - -(b) You may distribute such Executable Form under the terms of this - License, or sublicense it under different terms, provided that the - license for the Executable Form does not attempt to limit or alter - the recipients' rights in the Source Code Form under this License. - -3.3. Distribution of a Larger Work - -You may create and distribute a Larger Work under terms of Your choice, -provided that You also comply with the requirements of this License for -the Covered Software. If the Larger Work is a combination of Covered -Software with a work governed by one or more Secondary Licenses, and the -Covered Software is not Incompatible With Secondary Licenses, this -License permits You to additionally distribute such Covered Software -under the terms of such Secondary License(s), so that the recipient of -the Larger Work may, at their option, further distribute the Covered -Software under the terms of either this License or such Secondary -License(s). - -3.4. Notices - -You may not remove or alter the substance of any license notices -(including copyright notices, patent notices, disclaimers of warranty, -or limitations of liability) contained within the Source Code Form of -the Covered Software, except that You may alter any license notices to -the extent required to remedy known factual inaccuracies. - -3.5. Application of Additional Terms - -You may choose to offer, and to charge a fee for, warranty, support, -indemnity or liability obligations to one or more recipients of Covered -Software. However, You may do so only on Your own behalf, and not on -behalf of any Contributor. You must make it absolutely clear that any -such warranty, support, indemnity, or liability obligation is offered by -You alone, and You hereby agree to indemnify every Contributor for any -liability incurred by such Contributor as a result of warranty, support, -indemnity or liability terms You offer. You may include additional -disclaimers of warranty and limitations of liability specific to any -jurisdiction. - -4. Inability to Comply Due to Statute or Regulation ---------------------------------------------------- - -If it is impossible for You to comply with any of the terms of this -License with respect to some or all of the Covered Software due to -statute, judicial order, or regulation then You must: (a) comply with -the terms of this License to the maximum extent possible; and (b) -describe the limitations and the code they affect. Such description must -be placed in a text file included with all distributions of the Covered -Software under this License. Except to the extent prohibited by statute -or regulation, such description must be sufficiently detailed for a -recipient of ordinary skill to be able to understand it. - -5. Termination --------------- - -5.1. The rights granted under this License will terminate automatically -if You fail to comply with any of its terms. However, if You become -compliant, then the rights granted under this License from a particular -Contributor are reinstated (a) provisionally, unless and until such -Contributor explicitly and finally terminates Your grants, and (b) on an -ongoing basis, if such Contributor fails to notify You of the -non-compliance by some reasonable means prior to 60 days after You have -come back into compliance. Moreover, Your grants from a particular -Contributor are reinstated on an ongoing basis if such Contributor -notifies You of the non-compliance by some reasonable means, this is the -first time You have received notice of non-compliance with this License -from such Contributor, and You become compliant prior to 30 days after -Your receipt of the notice. - -5.2. If You initiate litigation against any entity by asserting a patent -infringement claim (excluding declaratory judgment actions, -counter-claims, and cross-claims) alleging that a Contributor Version -directly or indirectly infringes any patent, then the rights granted to -You by any and all Contributors for the Covered Software under Section -2.1 of this License shall terminate. - -5.3. In the event of termination under Sections 5.1 or 5.2 above, all -end user license agreements (excluding distributors and resellers) which -have been validly granted by You or Your distributors under this License -prior to termination shall survive termination. - -************************************************************************ -* * -* 6. Disclaimer of Warranty * -* ------------------------- * -* * -* Covered Software is provided under this License on an "as is" * -* basis, without warranty of any kind, either expressed, implied, or * -* statutory, including, without limitation, warranties that the * -* Covered Software is free of defects, merchantable, fit for a * -* particular purpose or non-infringing. The entire risk as to the * -* quality and performance of the Covered Software is with You. * -* Should any Covered Software prove defective in any respect, You * -* (not any Contributor) assume the cost of any necessary servicing, * -* repair, or correction. This disclaimer of warranty constitutes an * -* essential part of this License. No use of any Covered Software is * -* authorized under this License except under this disclaimer. * -* * -************************************************************************ - -************************************************************************ -* * -* 7. Limitation of Liability * -* -------------------------- * -* * -* Under no circumstances and under no legal theory, whether tort * -* (including negligence), contract, or otherwise, shall any * -* Contributor, or anyone who distributes Covered Software as * -* permitted above, be liable to You for any direct, indirect, * -* special, incidental, or consequential damages of any character * -* including, without limitation, damages for lost profits, loss of * -* goodwill, work stoppage, computer failure or malfunction, or any * -* and all other commercial damages or losses, even if such party * -* shall have been informed of the possibility of such damages. This * -* limitation of liability shall not apply to liability for death or * -* personal injury resulting from such party's negligence to the * -* extent applicable law prohibits such limitation. Some * -* jurisdictions do not allow the exclusion or limitation of * -* incidental or consequential damages, so this exclusion and * -* limitation may not apply to You. * -* * -************************************************************************ - -8. Litigation -------------- - -Any litigation relating to this License may be brought only in the -courts of a jurisdiction where the defendant maintains its principal -place of business and such litigation shall be governed by laws of that -jurisdiction, without reference to its conflict-of-law provisions. -Nothing in this Section shall prevent a party's ability to bring -cross-claims or counter-claims. - -9. Miscellaneous ----------------- - -This License represents the complete agreement concerning the subject -matter hereof. If any provision of this License is held to be -unenforceable, such provision shall be reformed only to the extent -necessary to make it enforceable. Any law or regulation which provides -that the language of a contract shall be construed against the drafter -shall not be used to construe this License against a Contributor. - -10. Versions of the License ---------------------------- - -10.1. New Versions - -Mozilla Foundation is the license steward. Except as provided in Section -10.3, no one other than the license steward has the right to modify or -publish new versions of this License. Each version will be given a -distinguishing version number. - -10.2. Effect of New Versions - -You may distribute the Covered Software under the terms of the version -of the License under which You originally received the Covered Software, -or under the terms of any subsequent version published by the license -steward. - -10.3. Modified Versions - -If you create software not governed by this License, and you want to -create a new license for such software, you may create and use a -modified version of this License if you rename the license and remove -any references to the name of the license steward (except to note that -such modified license differs from this License). - -10.4. Distributing Source Code Form that is Incompatible With Secondary -Licenses - -If You choose to distribute Source Code Form that is Incompatible With -Secondary Licenses under the terms of this version of the License, the -notice described in Exhibit B of this License must be attached. - -Exhibit A - Source Code Form License Notice -------------------------------------------- - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - -If it is not possible or desirable to put the notice in a particular -file, then You may include the notice in a location (such as a LICENSE -file in a relevant directory) where a recipient would be likely to look -for such a notice. - -You may add additional accurate notices of copyright ownership. - -Exhibit B - "Incompatible With Secondary Licenses" Notice ---------------------------------------------------------- - - This Source Code Form is "Incompatible With Secondary Licenses", as - defined by the Mozilla Public License, v. 2.0. - diff --git a/.config/emacs/modules/editor/file-templates/templates/text-mode/__license-mozilla-bp b/.config/emacs/modules/editor/file-templates/templates/text-mode/__license-mozilla-bp @@ -1,10 +0,0 @@ -# -*- mode: snippet -*- -# name: Mozilla Public License 2.0 (boilerplate) -# uuid: __license-mozilla-bp -# group: Licenses -# contributor: https://choosealicense.com/licenses/mpl-2.0 -# expand-env: ((yas-indent-line 'fixed)) -# -- -This Source Code Form is subject to the terms of the Mozilla Public -License, v. 2.0. If a copy of the MPL was not distributed with this -file, You can obtain one at http://mozilla.org/MPL/2.0/. -\ No newline at end of file diff --git a/.config/emacs/modules/editor/file-templates/templates/text-mode/__license-unlicense b/.config/emacs/modules/editor/file-templates/templates/text-mode/__license-unlicense @@ -1,31 +0,0 @@ -# -*- mode: snippet -*- -# name: The Unlicense -# uuid: __license-unlicense -# group: Licenses -# contributor: https://choosealicense.com/licenses/unlicense -# expand-env: ((yas-indent-line 'fixed)) -# -- -This is free and unencumbered software released into the public domain. - -Anyone is free to copy, modify, publish, use, compile, sell, or -distribute this software, either in source code form or as a compiled -binary, for any purpose, commercial or non-commercial, and by any -means. - -In jurisdictions that recognize copyright laws, the author or authors -of this software dedicate any and all copyright interest in the -software to the public domain. We make this dedication for the benefit -of the public at large and to the detriment of our heirs and -successors. We intend this dedication to be an overt act of -relinquishment in perpetuity of all present and future rights to this -software under copyright law. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. - -For more information, please refer to <http://unlicense.org> diff --git a/.config/emacs/modules/editor/file-templates/templates/web-mode/__.html b/.config/emacs/modules/editor/file-templates/templates/web-mode/__.html @@ -1,25 +0,0 @@ -<!doctype html> -<html class="no-js" lang=""> - <head> - <meta charset="utf-8"> - <meta http-equiv="x-ua-compatible" content="ie=edge"> - <title>${1:Untitled}</title> - <meta name="description" content=""> - <meta name="viewport" content="width=device-width, initial-scale=1"> - - <link rel="apple-touch-icon" href="/apple-touch-icon.png"> - <!-- Place favicon.ico in the root directory --> - - </head> - <body> - <!--[if lt IE 8]> - <p class="browserupgrade"> - You are using an <strong>outdated</strong> browser. Please - <a href="http://browsehappy.com/">upgrade your browser</a> to improve - your experience. - </p> - <![endif]--> - - $0 - </body> -</html> diff --git a/.config/emacs/modules/editor/file-templates/templates/web-mode/__jekyll-layout.html b/.config/emacs/modules/editor/file-templates/templates/web-mode/__jekyll-layout.html diff --git a/.config/emacs/modules/editor/file-templates/templates/yaml-mode/__docker-compose.yml b/.config/emacs/modules/editor/file-templates/templates/yaml-mode/__docker-compose.yml @@ -1,15 +0,0 @@ -web: - build: . - ports: - - "8080:80" - volumes: - - ./public:/var/www - links: - - mysql - - memcache - -mysql: - image: mysql - -redis: - image: redis diff --git a/.config/emacs/modules/editor/fold/README.org b/.config/emacs/modules/editor/fold/README.org @@ -1,69 +0,0 @@ -#+title: :editor fold -#+subtitle: What you can't see won't hurt you -#+created: May 15, 2019 -#+since: 21.12.0 - -* Description :unfold: -This module marries [[doom-package:hideshow]], [[doom-package:vimish-fold]], and ~outline-minor-mode~ to bring you -marker, indent and syntax-based code folding for as many languages as possible. - -** Maintainers -- [[doom-user:][@hlissner]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:evil-vimish-fold]] -- [[doom-package:vimish-fold]] -- if [[doom-module::tools tree-sitter]] - - [[doom-package:ts-fold]] - -** TODO Hacks -#+begin_quote - 🔨 This module's hacks haven't been documented yet. [[doom-contrib-module:][Document them?]] -#+end_quote - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -Emacs keybinds when [[doom-module::editor evil +everywhere]] is disabled: -| Keybind | Description | -|--------------------+---------------------------| -| [[kbd:][C-c C-f C-f]] | Fold region | -| [[kbd:][C-c C-f C-u]] or [[kbd:][C `]] | Unfold region | -| [[kbd:][C-c C-f C-d]] | Delete folded region | -| [[kbd:][C-c C-f C-a C-f]] | Fold all regions | -| [[kbd:][C-c C-f C-a C-u]] | Unfold all regions | -| [[kbd:][C-c C-a C-d]] | Delete all folded regions | - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -- Sometimes, an unfolded region won't fold back with [[kbd:][C-c C-f C-f]]. To bypass this - bug you must delete the folded region ([[kbd:][C-c C-f C-d]]) and then fold it ([[kbd:][C-c C-f - C-f]]) again. - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/editor/fold/autoload/fold.el b/.config/emacs/modules/editor/fold/autoload/fold.el @@ -1,188 +0,0 @@ -;;; editor/fold/autoload/fold.el -*- lexical-binding: t; -*- - -;; `hideshow' is a decent code folding implementation, but it won't let you -;; create custom folds. `vimish-fold' offers custom folds, but essentially -;; ignores any other type of folding (indent or custom markers, which hideshow -;; and `outline-mode' give you). This is my effort to combine them. - -;; -;;; Helpers - -(defun +fold--ensure-hideshow-mode () - (unless (bound-and-true-p hs-minor-mode) - (hs-minor-mode +1))) - -(defun +fold--vimish-fold-p () - (and (featurep 'vimish-fold) - (cl-some #'vimish-fold--vimish-overlay-p - (overlays-at (point))))) - -(defun +fold--outline-fold-p () - (and (or (bound-and-true-p outline-minor-mode) - (derived-mode-p 'outline-mode)) - (outline-on-heading-p))) - -(defun +fold--hideshow-fold-p () - (+fold--ensure-hideshow-mode) - (save-excursion - (ignore-errors - (or (hs-looking-at-block-start-p) - (hs-find-block-beginning) - (unless (eolp) - (end-of-line) - (+fold--hideshow-fold-p)))))) - -;; NOTE: does this need more? -(defun +fold--ts-fold-p () - (and (bound-and-true-p tree-sitter-mode) - (featurep 'ts-fold))) - -(defun +fold--invisible-points (count) - (let (points) - (save-excursion - (catch 'abort - (if (< count 0) (beginning-of-line)) - (while (re-search-forward hs-block-start-regexp nil t - (if (> count 0) 1 -1)) - (unless (invisible-p (point)) - (end-of-line) - (when (hs-already-hidden-p) - (push (point) points) - (when (>= (length points) count) - (throw 'abort nil)))) - (forward-line (if (> count 0) 1 -1))))) - points)) - -(defmacro +fold-from-eol (&rest body) - "Perform action after moving to the end of the line." - `(save-excursion - (end-of-line) - ,@body)) - - -;; -;;; Commands - -;;;###autoload -(defun +fold/toggle () - "Toggle the fold at point. - -Targets `vimmish-fold', `hideshow', `ts-fold' and `outline' folds." - (interactive) - (save-excursion - (cond ((+fold--vimish-fold-p) (vimish-fold-toggle)) - ((+fold--outline-fold-p) - (cl-letf (((symbol-function #'outline-hide-subtree) - (symbol-function #'outline-hide-entry))) - (outline-toggle-children))) - ((+fold--ts-fold-p) (ts-fold-toggle)) - ((+fold--hideshow-fold-p) (+fold-from-eol (hs-toggle-hiding)))))) - -;;;###autoload -(defun +fold/open () - "Open the folded region at point. - -Targets `vimmish-fold', `hideshow', `ts-fold' and `outline' folds." - (interactive) - (save-excursion - (cond ((+fold--vimish-fold-p) (vimish-fold-unfold)) - ((+fold--outline-fold-p) - (outline-show-children) - (outline-show-entry)) - ((+fold--ts-fold-p) (ts-fold-open)) - ((+fold--hideshow-fold-p) (+fold-from-eol (hs-show-block)))))) - -;;;###autoload -(defun +fold/close () - "Close the folded region at point. - -Targets `vimmish-fold', `hideshow', `ts-fold' and `outline' folds." - (interactive) - (save-excursion - (cond ((+fold--vimish-fold-p) (vimish-fold-refold)) - ((+fold--ts-fold-p) (ts-fold-close)) - ((+fold--hideshow-fold-p) (+fold-from-eol (hs-hide-block))) - ((+fold--outline-fold-p) (outline-hide-subtree))))) - -;;;###autoload -(defun +fold/open-all (&optional level) - "Open folds at LEVEL (or all folds if LEVEL is nil)." - (interactive - (list (if current-prefix-arg (prefix-numeric-value current-prefix-arg)))) - (cond ((+fold--ts-fold-p) - (ts-fold-open-all)) - ((featurep 'vimish-fold) - (vimish-fold-unfold-all)) - ((save-excursion - (+fold--ensure-hideshow-mode) - (if (integerp level) - (progn - (outline-hide-sublevels (max 1 (1- level))) - (hs-life-goes-on - (hs-hide-level-recursive (1- level) (point-min) (point-max)))) - (hs-show-all) - (when (fboundp 'outline-show-all) - (outline-show-all))))))) - -;;;###autoload -(defun +fold/close-all (&optional level) - "Close folds at LEVEL (or all folds if LEVEL is nil)." - (interactive - (list (if current-prefix-arg (prefix-numeric-value current-prefix-arg)))) - (save-excursion - (if (+fold--ts-fold-p) - (ts-fold-close-all) - (progn - (when (featurep 'vimish-fold) - (vimish-fold-refold-all)) - (+fold--ensure-hideshow-mode) - (hs-life-goes-on - (if (integerp level) - (hs-hide-level-recursive (1- level) (point-min) (point-max)) - (hs-hide-all))))))) - -;;;###autoload -(defun +fold/next (count) - "Jump to the next vimish fold, outline heading or folded region." - (interactive "p") - (cl-loop with orig-pt = (point) - for fn - in (list (lambda () - (when (bound-and-true-p hs-block-start-regexp) - (car (+fold--invisible-points count)))) - (lambda () - (when (featurep 'vimish-fold) - (if (> count 0) - (evil-vimish-fold/next-fold count) - (evil-vimish-fold/previous-fold (- count)))) - (if (/= (point) orig-pt) (point))) - (lambda () - ;; ts-fold does not define movement functions so we need to do it ourselves - (when (+fold--ts-fold-p) - (let* ((arg-list (if (> count 0) ;; depending on direction we need to change the ranges - (list (point) (point-max)) - (list (point-min) (point)))) - (comp-fun (if (> count 0) ;; also depending on direction we need to change how we sort the list - #'< - #'>)) - (ovs (cl-remove-if-not - (lambda (ov) - (eq (overlay-get ov 'creator) 'ts-fold)) - ;; `overlays-in' does not provide a list that is sorted - ;; (in the way we need it atleast) so we need to sort it based on direction - (cl-sort (apply #'overlays-in arg-list) comp-fun :key #'overlay-start)))) - (if (and ovs (<= (abs count) (length ovs))) - (goto-char (overlay-start (nth (- (abs count) 1) ovs)))))))) - if (save-excursion (funcall fn)) - collect it into points - finally do - (if-let* ((pt (car (sort points (if (> count 0) #'< #'>))))) - (goto-char pt) - (message "No more folds %s point" (if (> count 0) "after" "before")) - (goto-char orig-pt)))) - -;;;###autoload -(defun +fold/previous (count) - "Jump to the previous vimish fold, outline heading or folded region." - (interactive "p") - (+fold/next (- count))) diff --git a/.config/emacs/modules/editor/fold/autoload/hideshow.el b/.config/emacs/modules/editor/fold/autoload/hideshow.el @@ -1,83 +0,0 @@ -;;; editor/fold/autoload/hideshow.el -*- lexical-binding: t; -*- - -(defface +fold-hideshow-folded-face - `((t (:inherit font-lock-comment-face :weight light))) - "Face to hightlight `hideshow' overlays." - :group 'doom-themes) - -;;;###autoload -(defun +fold-hideshow-haml-forward-sexp-fn (arg) - (haml-forward-sexp arg) - (move-beginning-of-line 1)) - -;;;###autoload -(defun +fold-hideshow-forward-block-by-indent-fn (_arg) - (let ((start (current-indentation))) - (forward-line) - (unless (= start (current-indentation)) - (let ((range (+fold-hideshow-indent-range))) - (goto-char (cadr range)) - (end-of-line))))) - -;;;###autoload -(defun +fold-hideshow-set-up-overlay-fn (ov) - (when (eq 'code (overlay-get ov 'hs)) - (when (featurep 'vimish-fold) - (overlay-put - ov 'before-string - (propertize "…" 'display - (list vimish-fold-indication-mode - 'empty-line - 'vimish-fold-fringe)))) - (overlay-put - ov 'display (propertize " [...] " 'face '+fold-hideshow-folded-face)))) - - -;; -;;; Indentation detection - -(defun +fold--hideshow-empty-line-p (_) - (string= "" (string-trim (thing-at-point 'line 'no-props)))) - -(defun +fold--hideshow-geq-or-empty-p (base-indent) - (or (+fold--hideshow-empty-line-p base-indent) - (>= (current-indentation) base-indent))) - -(defun +fold--hideshow-g-or-empty-p (base-indent) - (or (+fold--hideshow-empty-line-p base-indent) - (> (current-indentation) base-indent))) - -(defun +fold--hideshow-seek (start direction before skip predicate base-indent) - "Seeks forward (if direction is 1) or backward (if direction is -1) from start, until predicate -fails. If before is nil, it will return the first line where predicate fails, otherwise it returns -the last line where predicate holds." - (save-excursion - (goto-char start) - (goto-char (point-at-bol)) - (let ((bnd (if (> 0 direction) - (point-min) - (point-max))) - (pt (point))) - (when skip (forward-line direction)) - (cl-loop while (and (/= (point) bnd) (funcall predicate base-indent)) - do (progn - (when before (setq pt (point-at-bol))) - (forward-line direction) - (unless before (setq pt (point-at-bol))))) - pt))) - -(defun +fold-hideshow-indent-range (&optional point) - "Return the point at the begin and end of the text block with the same (or -greater) indentation. If `point' is supplied and non-nil it will return the -begin and end of the block surrounding point." - (save-excursion - (when point - (goto-char point)) - (let ((base-indent (current-indentation)) - (begin (point)) - (end (point))) - (setq begin (+fold--hideshow-seek begin -1 t nil #'+fold--hideshow-geq-or-empty-p base-indent) - begin (+fold--hideshow-seek begin 1 nil nil #'+fold--hideshow-g-or-empty-p base-indent) - end (+fold--hideshow-seek end 1 t nil #'+fold--hideshow-geq-or-empty-p base-indent) - end (+fold--hideshow-seek end -1 nil nil #'+fold--hideshow-empty-line-p base-indent)) - (list begin end base-indent)))) diff --git a/.config/emacs/modules/editor/fold/config.el b/.config/emacs/modules/editor/fold/config.el @@ -1,100 +0,0 @@ -;;; editor/fold/config.el -*- lexical-binding: t; -*- - -(when (modulep! :editor evil) - ;; Add vimish-fold, outline-mode & hideshow support to folding commands - (define-key! 'global - [remap evil-toggle-fold] #'+fold/toggle - [remap evil-close-fold] #'+fold/close - [remap evil-open-fold] #'+fold/open - [remap evil-open-fold-rec] #'+fold/open - [remap evil-close-folds] #'+fold/close-all - [remap evil-open-folds] #'+fold/open-all) - (after! evil - (evil-define-key* 'motion 'global - "zj" #'+fold/next - "zk" #'+fold/previous - "zf" #'evil-vimish-fold/create - "zF" #'evil-vimish-fold/create-line - "zd" #'vimish-fold-delete - "zE" #'vimish-fold-delete-all))) - - -;; -;; Packages - -(use-package! hideshow ; built-in - :commands (hs-toggle-hiding - hs-hide-block - hs-hide-level - hs-show-all - hs-hide-all) - :config - (setq hs-hide-comments-when-hiding-all nil - ;; Nicer code-folding overlays (with fringe indicators) - hs-set-up-overlay #'+fold-hideshow-set-up-overlay-fn) - - (defadvice! +fold--hideshow-ensure-mode-a (&rest _) - "Ensure `hs-minor-mode' is enabled when we need it, no sooner or later." - :before '(hs-toggle-hiding hs-hide-block hs-hide-level hs-show-all hs-hide-all) - (unless (bound-and-true-p hs-minor-mode) - (hs-minor-mode +1))) - - ;; extra folding support for more languages - (unless (assq 't hs-special-modes-alist) - (setq hs-special-modes-alist - (append - '((vimrc-mode "{{{" "}}}" "\"") - (yaml-mode "\\s-*\\_<\\(?:[^:]+\\)\\_>" - "" - "#" - +fold-hideshow-forward-block-by-indent-fn nil) - (haml-mode "[#.%]" "\n" "/" +fold-hideshow-haml-forward-sexp-fn nil) - (ruby-mode "class\\|d\\(?:ef\\|o\\)\\|module\\|[[{]" - "end\\|[]}]" - "#\\|=begin" - ruby-forward-sexp) - (matlab-mode "if\\|switch\\|case\\|otherwise\\|while\\|for\\|try\\|catch" - "end" - nil (lambda (_arg) (matlab-forward-sexp))) - (nxml-mode "<!--\\|<[^/>]*[^/]>" - "-->\\|</[^/>]*[^/]>" - "<!--" sgml-skip-tag-forward nil) - (latex-mode - ;; LaTeX-find-matching-end needs to be inside the env - ("\\\\begin{[a-zA-Z*]+}\\(\\)" 1) - "\\\\end{[a-zA-Z*]+}" - "%" - (lambda (_arg) - ;; Don't fold whole document, that's useless - (unless (save-excursion - (search-backward "\\begin{document}" - (line-beginning-position) t)) - (LaTeX-find-matching-end))) - nil)) - hs-special-modes-alist - '((t)))))) - - -(use-package! evil-vimish-fold - :when (modulep! :editor evil) - :commands (evil-vimish-fold/next-fold evil-vimish-fold/previous-fold - evil-vimish-fold/delete evil-vimish-fold/delete-all - evil-vimish-fold/create evil-vimish-fold/create-line) - :init - (setq vimish-fold-dir (concat doom-cache-dir "vimish-fold/") - vimish-fold-indication-mode 'right-fringe) - :config - (vimish-fold-global-mode +1)) - -(use-package! ts-fold - :when (modulep! :tools tree-sitter) - :after tree-sitter - :config - ;; we want to use our own face so we nullify this one to have no effect and - ;; make it more similar to hideshows - (custom-set-faces! '(ts-fold-replacement-face :foreground unspecified - :box nil - :inherit font-lock-comment-face - :weight light)) - (setq ts-fold-replacement " [...] ") - (ts-fold-mode +1)) diff --git a/.config/emacs/modules/editor/fold/packages.el b/.config/emacs/modules/editor/fold/packages.el @@ -1,11 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; editor/fold/packages.el - -(package! hideshow :built-in t) - -(package! vimish-fold :pin "a6501cbfe3db791f9ca17fd986c7202a87f3adb8") -(when (modulep! :editor evil) - (package! evil-vimish-fold :pin "b6e0e6b91b8cd047e80debef1a536d9d49eef31a")) -(when (modulep! :tools tree-sitter) - (package! ts-fold :pin "9d9e0c5cf7b5397e06571bb6bf497598dc8796a8" - :recipe (:host github :repo "emacs-tree-sitter/ts-fold"))) diff --git a/.config/emacs/modules/editor/format/README.org b/.config/emacs/modules/editor/format/README.org @@ -1,180 +0,0 @@ -#+title: :editor format -#+subtitle: Standardize your ugly code -#+created: July 26, 2020 -#+since: 21.12.0 - -#+begin_quote - 🔨 This module has been scheduled for a rewrite. Its documentation will remain - incomplete and edge cases left unpatched in the meantime. A preview of this - rewrite can be found [[https://github.com/hlissner/doom-emacs-private/tree/master/modules/editor/format][in my private config]]. -#+end_quote - -* Description :unfold: -This module integrates code formatters into Emacs. Here are some of the -formatters that it currently supports: - -#+begin_quote -asmfmt, black, brittany, cabal-fmt, clang-format, cmake-format, dartfmt, dfmt, -dhall format, dockfmt, elm-format, emacs, fish_indent, fprettify, gleam format, -gofmt, iStyle, jsonnetfmt, ktlint, latexindent, ledger-mode, lua-fmt, mix -format, nixfmt, node-cljfmt, ocp-indent, perltidy, prettier, purty, rufo, -rustfmt, scalafmt, script shfmt, snakefmt, sqlformat, styler, swiftformat, tidy -#+end_quote - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +onsave :: - Enable reformatting of a buffer when it is saved. See - [[var:+format-on-save-enabled-modes]] to control what major modes to (or not to) - format on save. - -** Packages -- [[doom-package:format-all]] - -** Hacks -- format-all has been heavily modified to suit Doom's goals for this module: - - Reformatted text is applied to the buffer by RCS patch, as to reduce its - affect on cursor position. - - Adds partial formatting, i.e. you can now reformat a subset of the buffer. - - Adds the ability to use any arbitrary formatter on the current buffer if you - pass the universal argument to [[fn:+format/buffer]] or [[fn:+format/region]] (i.e. - removes the major-mode lock on formatters). - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module has no direct requirements, but each language will need one of their -supported formatter programs in order for this to work. In their absence, -[[doom-package:format-all]] will fail silently. - -Supported formatters: -- Angular/Vue (prettier) -- Assembly (asmfmt) -- Bazel Starlark (buildifier) -- BibTeX (emacs) -- C/C++/Objective-C (clang-format) -- Cabal (cabal-fmt) -- Clojure/ClojureScript (node-cljfmt) -- CMake (cmake-format) -- Crystal (crystal tool format) -- CSS/Less/SCSS (prettier) -- D (dfmt) -- Dart (dartfmt) -- Dhall (dhall format) -- Dockerfile (dockfmt) -- Elixir (mix format) -- Elm (elm-format) -- Emacs Lisp (emacs) -- Fish Shell (fish_indent) -- Fortran 90 (fprettify) -- Gleam (gleam format) -- Go (gofmt) -- GraphQL (prettier) -- Haskell (brittany) -- HTML/XHTML/XML (tidy) -- Java (clang-format) -- JavaScript/JSON/JSX (prettier) -- Jsonnet (jsonnetfmt) -- Kotlin (ktlint) -- LaTeX (latexindent) -- Ledger (ledger-mode) -- Lua (lua-fmt) -- Markdown (prettier) -- Nix (nixfmt) -- OCaml (ocp-indent) -- Perl (perltidy) -- PHP (prettier plugin-php) -- Protocol Buffers (clang-format) -- PureScript (purty) -- Python (black) -- R (styler) -- Ruby (rufo) -- Rust (rustfmt) -- Scala (scalafmt) -- Shell script (shfmt) -- Snakemake (snakefmt) -- Solidity (prettier-plugin-solidity) -- SQL (sqlformat) -- Swift (swiftformat) -- Terraform (terraform fmt) -- TOML (prettier-plugin-toml) -- TypeScript/TSX (prettier) -- Verilog (iStyle) -- YAML (prettier) - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** Automatic reformatting when saving buffers -There are two ways to achieve this. Either through the =+onsave= flag, or by -adding ~format-all-mode~ to the hook of each major mode you want this behavior -enabled in. - -If you choose the former, what modes it applies to can be changed by modifying -~+format-on-save-enabled-modes~, which contains a list of major modes. If the -first item in the list is the symbol ~not~, the list is negated. This is its -default value: -#+begin_src emacs-lisp -(setq +format-on-save-enabled-modes - '(not emacs-lisp-mode ; elisp's mechanisms are good enough - sql-mode ; sqlformat is currently broken - tex-mode ; latexindent is broken - latex-mode)) -#+end_src - -If you want to format code when you save a buffer, but want more granular -control over which major modes this behavior is enabled in, there is an -alternative. Make sure [[doom-module:+onsave]] is disabled before you try this: -#+begin_src emacs-lisp -(add-hook 'python-mode-hook #'format-all-mode) -(add-hook 'js2-mode-hook #'format-all-mode) -#+end_src - -** Disabling the LSP formatter -If you are in a buffer with ~lsp-mode~ enabled and a server that supports -=textDocument/formatting=, it will be used instead of [[doom-package:format-all]]'s formatter. - -+ To disable this behavior universally use: ~(setq +format-with-lsp nil)~ -+ To disable this behavior in one mode: ~(setq-hook! 'python-mode-hook - +format-with-lsp nil)~ - -** TODO Defining your own formatters -See the ~set-formatter!~ function. - -** TODO Selecting a specific formatter for a particular buffer -Set the buffer-local variable ~+format-with~ to the name of the formatter to -use. e.g. -#+begin_src emacs-lisp -(setq-hook! 'python-mode-hook +format-with 'html-tidy) - -;; Or set it to `:none' to disable formatting -(setq-hook! 'python-mode-hook +format-with :none) -#+end_src - -Formatters are referred to by the name they were defined with. They can be -looked up in the ~format-all-mode-table~ hash table or in format-all's [[https://github.com/lassik/emacs-format-all-the-code/blob/master/format-all.el#L512][source -code]]. - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/editor/format/autoload/evil.el b/.config/emacs/modules/editor/format/autoload/evil.el @@ -1,8 +0,0 @@ -;;; editor/format/autoload/evil.el -*- lexical-binding: t; -*- -;;;###if (modulep! :editor evil) - -;;;###autoload (autoload '+format:region "editor/format/autoload/evil" nil t) -(evil-define-operator +format:region (beg end) - "Evil ex interface to `+format/region'." - (interactive "<r>") - (+format/region beg end)) diff --git a/.config/emacs/modules/editor/format/autoload/format.el b/.config/emacs/modules/editor/format/autoload/format.el @@ -1,293 +0,0 @@ -;;; editor/format/autoload.el -*- lexical-binding: t; -*- - -(defvar +format-region-p nil - "Is non-nil if currently reformatting a selected region, rather than the whole -buffer.") - -;;;###autoload -(autoload 'format-all--probe "format-all") - -(defun +format--delete-whole-line (&optional arg) - "Delete the current line without putting it in the `kill-ring'. -Derived from function `kill-whole-line'. ARG is defined as for that -function. - -Stolen shamelessly from go-mode" - (setq arg (or arg 1)) - (if (and (> arg 0) - (eobp) - (save-excursion (forward-visible-line 0) (eobp))) - (signal 'end-of-buffer nil)) - (if (and (< arg 0) - (bobp) - (save-excursion (end-of-visible-line) (bobp))) - (signal 'beginning-of-buffer nil)) - (cond ((zerop arg) - (delete-region (progn (forward-visible-line 0) (point)) - (progn (end-of-visible-line) (point)))) - ((< arg 0) - (delete-region (progn (end-of-visible-line) (point)) - (progn (forward-visible-line (1+ arg)) - (unless (bobp) - (backward-char)) - (point)))) - ((delete-region (progn (forward-visible-line 0) (point)) - (progn (forward-visible-line arg) (point)))))) - -;;;###autoload -(defun +format--apply-rcs-patch (patch-buffer) - "Apply an RCS-formatted diff from PATCH-BUFFER to the current buffer. - -Stolen shamelessly from go-mode" - (let ((target-buffer (current-buffer)) - ;; Relative offset between buffer line numbers and line numbers - ;; in patch. - ;; - ;; Line numbers in the patch are based on the source file, so - ;; we have to keep an offset when making changes to the - ;; buffer. - ;; - ;; Appending lines decrements the offset (possibly making it - ;; negative), deleting lines increments it. This order - ;; simplifies the forward-line invocations. - (line-offset 0) - (column (current-column))) - (save-excursion - (with-current-buffer patch-buffer - (goto-char (point-min)) - (while (not (eobp)) - (unless (looking-at "^\\([ad]\\)\\([0-9]+\\) \\([0-9]+\\)") - (error "Invalid rcs patch or internal error in +format--apply-rcs-patch")) - (forward-line) - (let ((action (match-string 1)) - (from (string-to-number (match-string 2))) - (len (string-to-number (match-string 3)))) - (cond - ((equal action "a") - (let ((start (point))) - (forward-line len) - (let ((text (buffer-substring start (point)))) - (with-current-buffer target-buffer - (cl-decf line-offset len) - (goto-char (point-min)) - (forward-line (- from len line-offset)) - (insert text))))) - ((equal action "d") - (with-current-buffer target-buffer - (goto-char (point-min)) - (forward-line (1- (- from line-offset))) - (cl-incf line-offset len) - (+format--delete-whole-line len))) - ((error "Invalid rcs patch or internal error in +format--apply-rcs-patch"))))))) - (move-to-column column))) - -(defun +format--current-indentation () - (save-excursion - (goto-char (point-min)) - (skip-chars-forward " \t\n") - (current-indentation))) - - -;; -;; Public library - -(defun +format-completing-read () - "TODO" - (require 'format-all) - (let* ((fmtlist (mapcar #'symbol-name (hash-table-keys format-all--format-table))) - (fmt (completing-read "Formatter: " fmtlist))) - (if fmt (intern fmt)))) - -;;;###autoload -(defun +format-probe-a (fn) - "Use `+format-with' instead, if it is set. -Prompts for a formatter if universal arg is set." - (cond ((or buffer-read-only (eq +format-with :none)) - (list nil nil)) - (current-prefix-arg - (list (or (+format-completing-read) - (user-error "Aborted")) - t)) - (+format-with - (list +format-with t)) - ((and +format-with-lsp - (bound-and-true-p lsp-managed-mode) - (lsp-feature? "textDocument/formatting")) - (list 'lsp nil)) - ((and +format-with-lsp - (bound-and-true-p eglot--managed-mode) - (eglot--server-capable :documentFormattingProvider)) - (list 'eglot nil)) - ((funcall fn)))) - -;;;###autoload -(defun +format-buffer-a (formatter mode-result) - "Advice that extends `format-all-buffer--with' to: - -1. Enable partial/region reformatting, while preserving leading indentation, -2. Applies changes via RCS patch, line by line, to protect buffer markers and - reduce cursor movement or window scrolling. - -See `+format/buffer' for the interactive version of this function, and -`+format-buffer-h' to use as a `before-save-hook' hook." - (cond - ((eq formatter 'lsp) - (call-interactively - (if +format-region-p #'lsp-format-region #'lsp-format-buffer))) - ((eq formatter 'eglot) - (call-interactively - (if +format-region-p #'eglot-format #'eglot-format-buffer))) - ((let ((f-function (gethash formatter format-all--format-table)) - (executable (format-all--formatter-executable formatter)) - (indent 0) - (old-line-number (line-number-at-pos)) - (old-column (current-column))) - (pcase-let* - ((`(,output ,errput) - ;; To reliably format regions, rather than the whole buffer, and - ;; `format-all' (and various formatting functions, like `gofmt') widen - ;; the buffer, we must copy the region first. - (let ((output (buffer-substring-no-properties (point-min) (point-max))) - (origin-buffer (or (buffer-base-buffer) (current-buffer))) - ;; Fixes #5133: some packages (like lsp-mode) can do a bunch - ;; of complicated stuff in these hooks. Better to not have to - ;; deal with any of them at all. - write-file-functions - before-save-hook - after-save-hook - kill-buffer-query-functions - kill-buffer-hook) - (with-temp-buffer - (with-silent-modifications - (insert output) - ;; Ensure this temp buffer seems as much like the origin - ;; buffer as possible, in case the formatter is an elisp - ;; function, like `gofmt'. - (cl-loop for (var . val) - in (cl-remove-if-not #'listp (buffer-local-variables origin-buffer)) - ;; Making enable-multibyte-characters buffer-local - ;; causes an error. - unless (eq var 'enable-multibyte-characters) - ;; Fixes #5133: don't deal with complicated hook - ;; functionality! This isn't a real buffer anyway. - unless (string-match-p (symbol-name var) "-\\(hook\\|functions\\)$") - ;; Using setq-local would quote var. - do (set (make-local-variable var) val)) - ;; Since we're piping a region of text to the formatter, remove - ;; any leading indentation to make it look like a file. - (setq indent (+format--current-indentation)) - (when (> indent 0) - (indent-rigidly (point-min) (point-max) (- indent))) - (funcall f-function executable mode-result))))) - (`,status - (cond ((null output) :error) - ((eq output t) :already-formatted) - (t :reformatted)))) - (unwind-protect - (when (eq status :reformatted) - (let ((tmpfile (make-temp-file "doom-format")) - (patchbuf (get-buffer-create " *doom format patch*")) - (coding-system-for-read coding-system-for-read) - (coding-system-for-write coding-system-for-write)) - (unless IS-WINDOWS - (setq coding-system-for-read 'utf-8 - coding-system-for-write 'utf-8)) - (unwind-protect - (progn - (with-current-buffer patchbuf - (erase-buffer)) - (with-temp-file tmpfile - (erase-buffer) - (insert output) - (when (> indent 0) - ;; restore indentation without affecting new - ;; indentation - (indent-rigidly (point-min) (point-max) - (max 0 (- indent (+format--current-indentation)))))) - (if (zerop (call-process-region (point-min) (point-max) "diff" nil patchbuf nil "-n" "-" tmpfile)) - (setq status :already-formatted) - (+format--apply-rcs-patch patchbuf) - (list output errput))) - (kill-buffer patchbuf) - (delete-file tmpfile)))) - (format-all--show-or-hide-errors errput) - (goto-char (point-min)) - (forward-line (1- old-line-number)) - (let ((line-length (- (point-at-eol) (point-at-bol)))) - (goto-char (+ (point) (min old-column line-length)))) - (run-hook-with-args 'format-all-after-format-functions formatter status) - (message (pcase status - (:error "Formatting error") - (:already-formatted "Already formatted") - (:reformatted (format "Reformatted with %s" formatter)))))))))) - - -;; -;;; Commands - -(defun +format--org-region (beg end) - "Reformat the region within BEG and END. -If nil, BEG and/or END will default to the boundaries of the src block at point." - (let ((element (org-element-at-point))) - (save-excursion - (let* ((block-beg (save-excursion - (goto-char (org-babel-where-is-src-block-head element)) - (line-beginning-position 2))) - (block-end (save-excursion - (goto-char (org-element-property :end element)) - (skip-chars-backward " \t\n") - (line-beginning-position))) - (beg (if beg (max beg block-beg) block-beg)) - (end (if end (min end block-end) block-end)) - (lang (org-element-property :language element)) - (major-mode (org-src-get-lang-mode lang))) - (if (eq major-mode 'org-mode) - (user-error "Cannot reformat an org src block in org-mode") - (+format/region beg end)))))) - -(defun +format--buffer () - (if (and (eq major-mode 'org-mode) - (org-in-src-block-p t)) - (+format--org-region (point-min) (point-max)) - (if (called-interactively-p 'any) - (format-all-buffer) - (ignore-errors (format-all-buffer))))) - -;;;###autoload -(defun +format/buffer () - "Reformat the current buffer using LSP or `format-all-buffer'." - (interactive) - (+format--buffer)) - -;;;###autoload -(defun +format/region (beg end) - "Runs the active formatter on the lines within BEG and END. - -WARNING: this may not work everywhere. It will throw errors if the region -contains a syntax error in isolation. It is mostly useful for formatting -snippets or single lines." - (interactive "rP") - (let ((+format-region-p t)) - (save-restriction - (narrow-to-region beg end) - (+format--buffer)))) - -;;;###autoload -(defun +format/region-or-buffer () - "Runs the active formatter on the selected region (or whole buffer, if nothing -is selected)." - (interactive) - (call-interactively - (if (doom-region-active-p) - #'+format/region - #'+format/buffer))) - - -;; -;; Hooks - -;;;###autoload -(defalias '+format-buffer-h #'+format/buffer - "Format the source code in the current buffer with minimal feedback. - -Meant for `before-save-hook'.") diff --git a/.config/emacs/modules/editor/format/autoload/settings.el b/.config/emacs/modules/editor/format/autoload/settings.el @@ -1,203 +0,0 @@ -;;; editor/format/autoload/settings.el -*- lexical-binding: t; -*- - -;; This must be redefined here because `format-all' only makes it available at -;; compile time. -(defconst +format-system-type - (cl-case system-type - (windows-nt 'windows) - (cygwin 'windows) - (darwin 'macos) - (gnu/linux 'linux) - (berkeley-unix - (save-match-data - (let ((case-fold-search t)) - (cond ((string-match "freebsd" system-configuration) 'freebsd) - ((string-match "openbsd" system-configuration) 'openbsd) - ((string-match "netbsd" system-configuration) 'netbsd)))))) - "Current operating system according to the format-all package.") - -(defun +format--resolve-system (choices) - "Get first choice matching `format-all-system-type' from CHOICES." - (cl-loop for choice in choices - if (atom choice) return choice - else if (eql +format-system-type (car choice)) - return (cadr choice))) - - -(defun +format--make-command (formatter &rest _) - `(format-all--buffer-thunk - (lambda (input) - (with-silent-modifications - (setq buffer-file-name ,(buffer-file-name (buffer-base-buffer)) - default-directory ,default-directory) - (delay-mode-hooks (funcall ',major-mode)) - (insert input) - (condition-case e - (progn - (doom-log "formatter (commandp) %s" #',formatter) - (call-interactively #',formatter) - (list nil "")) - (error (list t (error-message-string e)))))))) - -(defun +format--make-function (formatter &rest _) - `(progn - (doom-log "formatter (functionp) %s" #',formatter) - (format-all--buffer-thunk #',formatter))) - -(defun +format--make-shell-command (command ok-statuses error-regexp) - (+format--make-shell-command-list (split-string command " " t) - ok-statuses error-regexp)) - -(defun +format--make-shell-command-list (command-list ok-statuses error-regexp) - `(let (args) - (dolist (arg ',command-list) - (cond ((stringp arg) - (push arg args)) - ((listp arg) - (catch 'skip - (let (subargs this) - (while (setq this (pop arg)) - (cond ((not (stringp (car arg))) - (let ((val (eval (pop arg) t))) - (unless val (throw 'skip nil)) - (push (format this val) subargs))) - ((stringp this) - (push this subargs)))) - (setq args (append subargs args))))))) - (doom-log "formatter (arglist) %s" args) - (if ,(and (or ok-statuses error-regexp) t) - (apply #'format-all--buffer-hard - ',ok-statuses ,error-regexp nil - (reverse args)) - (apply #'format-all--buffer-easy (reverse args))))) - -(cl-defun +format--set (name &key function modes unset) - (declare (indent defun)) - (when (and unset (not (gethash name format-all--format-table))) - (error "'%s' formatter does not exist to be unset" name)) - (puthash name function format-all--format-table) - (dolist (mode (ensure-list modes)) - (cl-destructuring-bind (m &optional probe) - (ensure-list mode) - (if unset - (puthash m (assq-delete-all name (gethash key format-all-mode-table)) - format-all-mode-table) - (format-all--pushhash - m (cons name (if probe `(lambda () ,probe))) - format-all--mode-table))))) - -;;;###autodef -(cl-defun set-formatter! - (name formatter &key modes filter ok-statuses error-regexp) - "Define (or modify) a formatter named NAME. - -Supported keywords: :modes :filter :ok-statuses :error-regexp - -NAME is a symbol that identifies this formatter. - -FORMATTER can be a symbol referring to another formatter, a function, string or -nested list. - - If a function, it should be a formatter function that - `format-all--buffer-thunk' will accept. - If a string, it is assumed to be a shell command that the buffer's text will - be piped to (through stdin). - If a list, it should represent a shell command as a list of arguments. Each - element is either a string or list (STRING ARG) where STRING is a format - string and ARG is both a predicate and argument for STRING. If ARG is nil, - STRING will be omitted from the vector. - -MODES is a major mode, a list thereof, or a list of two-element sublists with -the structure: (MAJOR-MODE FORM). FORM is evaluated when the buffer is formatted -and its return value serves two purposes: - - 1. It is a predicate for this formatter. Assuming the MAJOR-MODE matches the - current mode, if FORM evaluates to nil, the formatter is skipped. - 2. It's return value is made available to FORMATTER if it is a function or - list of shell arguments via the `mode-result' variable. - -FILTER is a function that takes three arguments: the formatted output, any error -output and the position of the first change. This function must return these -three after making whatever changes you like to them. This might be useful if -the output contains ANSI color codes that need to be stripped out (as is the -case with elm-format). - -OK-STATUSES and ERROR-REGEXP are ignored if FORMATTER is not a shell command. - -OK-STATUSES is a list of integer exit codes that should be treated as success -codes. However, if ERROR-REGEXP is given, and the program's stderr contains that -regexp, then the formatting is considered failed even if the exit status is in -OK-STATUSES. - -Basic examples: - - (set-formatter! 'asmfmt \"asmfmt\" :modes '(asm-mode nasm-mode)) - (set-formatter! 'black \"black -q -\") - (set-formatter! 'html-tidy \"tidy -q -indent\" :modes '(html-mode web-mode)) - -Advanced examples: - - (set-formatter! - 'clang-format - '(\"clang-format\" - (\"-assume-filename=%S\" (or buffer-file-name mode-result \"\"))) - :modes - '((c-mode \".c\") - (c++-mode \".cpp\") - (java-mode \".java\") - (objc-mode \".m\") - (protobuf-mode \".proto\"))) - - (set-formatter! 'html-tidy - '(\"tidy\" \"-q\" \"-indent\" - (\"-xml\" (memq major-mode '(nxml-mode xml-mode)))) - :modes - '(html-mode - (web-mode (and (equal \"none\" web-mode-engine) - (car (member web-mode-content-type '(\"xml\" \"html\")))))) - :ok-statuses '(0 1) - :executable \"tidy\") - - (set-formatter! 'html-tidy ; overwrite predefined html-tidy formatter - '(\"tidy\" \"-q\" \"-indent\" - \"--tidy-mark\" \"no\" - \"--drop-empty-elements\" \"no\" - \"--show-body-only\" \"auto\" - (\"--indent-spaces\" \"%d\" tab-width) - (\"--indent-with-tabs\" \"%s\" (if indent-tabs-mode \"yes\" \"no\")) - (\"-xml\" (memq major-mode '(nxml-mode xml-mode)))) - :ok-statuses '(0 1))) - - (set-formatter! 'elm-format - \"elm-format --yes --stdin\" - :filter - (lambda (output errput first-diff) - (list output - (format-all--remove-ansi-color errput) - first-diff)))" - (declare (indent defun)) - (cl-check-type name symbol) - (after! format-all - (if (null formatter) - (+format--set name - :unset t - :modes modes) - (let ((fn (funcall (cond ((stringp formatter) - #'+format--make-shell-command) - ((listp formatter) - #'+format--make-shell-command-list) - ((and (commandp formatter) - (not (stringp formatter))) - #'+format--make-command) - ((functionp formatter) - #'+format--make-function)) - formatter - ok-statuses - error-regexp))) - (cl-check-type filter (or function null)) - (+format--set name - :function - `(lambda (executable mode-result) - ,(if filter `(apply #',filter ,fn) fn)) - :modes modes) - name)))) diff --git a/.config/emacs/modules/editor/format/config.el b/.config/emacs/modules/editor/format/config.el @@ -1,89 +0,0 @@ -;;; editor/format/config.el -*- lexical-binding: t; -*- - -(defvar +format-on-save-enabled-modes - '(not emacs-lisp-mode ; elisp's mechanisms are good enough - sql-mode ; sqlformat is currently broken - tex-mode ; latexindent is broken - latex-mode - org-msg-edit-mode) ; doesn't need a formatter - "A list of major modes in which to reformat the buffer upon saving. - -If this list begins with `not', then it negates the list. -If it is `t', it is enabled in all modes. -If nil, it is disabled in all modes, the same as if the +onsave flag wasn't - used at all. - -Irrelevant if you do not have the +onsave flag enabled for this module.") - -(defvar +format-preserve-indentation t - "If non-nil, the leading indentation is preserved when formatting the whole -buffer. This is particularly useful for partials. - -Indentation is always preserved when formatting regions.") - -(defvar-local +format-with nil - "Set this to explicitly use a certain formatter for the current buffer.") - -(defvar +format-with-lsp t - "If non-nil, format with LSP formatter if it's available. - -This can be set buffer-locally with `setq-hook!' to disable LSP formatting in -select buffers.") - - -;; -;;; Bootstrap - -(add-to-list 'doom-debug-variables 'format-all-debug) - -(defun +format-enable-on-save-maybe-h () - "Enable formatting on save in certain major modes. - -This is controlled by `+format-on-save-enabled-modes'." - (or (cond ((eq major-mode 'fundamental-mode)) - ((string-prefix-p " " (buffer-name))) - ((and (booleanp +format-on-save-enabled-modes) - (not +format-on-save-enabled-modes))) - ((and (listp +format-on-save-enabled-modes) - (if (eq (car +format-on-save-enabled-modes) 'not) - (memq major-mode (cdr +format-on-save-enabled-modes)) - (not (memq major-mode +format-on-save-enabled-modes))))) - ((not (require 'format-all nil t)))) - (format-all-mode +1))) - -(when (modulep! +onsave) - (add-hook 'after-change-major-mode-hook #'+format-enable-on-save-maybe-h)) - - -;; -;;; Hacks - -;; Allow a specific formatter to be used by setting `+format-with', either -;; buffer-locally or let-bound. -(advice-add #'format-all--probe :around #'+format-probe-a) - -;; Doom uses a modded `format-all-buffer', which -;; 1. Enables partial reformatting (while preserving leading indentation), -;; 2. Applies changes via RCS patch, line by line, to protect buffer markers -;; and avoid any jarring cursor+window scrolling. -(advice-add #'format-all-buffer--with :override #'+format-buffer-a) - -;; format-all-mode "helpfully" raises an error when it doesn't know how to -;; format a buffer. -(add-to-list 'debug-ignored-errors "^Don't know how to format ") - -;; Don't pop up imposing warnings about missing formatters, but still log it in -;; to *Messages*. -(defadvice! +format--all-buffer-from-hook-a (fn &rest args) - :around #'format-all-buffer--from-hook - (letf! (defun format-all-buffer--with (formatter mode-result) - (when (or (eq formatter 'lsp) - (eq formatter 'eglot) - (condition-case-unless-debug e - (format-all--formatter-executable formatter) - (error - (message "Warning: cannot reformat buffer because %S isn't installed" - (gethash formatter format-all--executable-table)) - nil))) - (funcall format-all-buffer--with formatter mode-result))) - (apply fn args))) diff --git a/.config/emacs/modules/editor/format/packages.el b/.config/emacs/modules/editor/format/packages.el @@ -1,4 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; editor/format/packages.el - -(package! format-all :pin "47d862d40a088ca089c92cd393c6dca4628f87d3") diff --git a/.config/emacs/modules/editor/format/test/test-format.el b/.config/emacs/modules/editor/format/test/test-format.el @@ -1,103 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; editor/format/test/test-format.el - -(load! "../autoload/settings") -(load! "../autoload/format") -(require! :editor format) -(require 'format-all) - -;; -(describe "editor/format" - :var (format-all--format-table - format-all--mode-table) - - (before-each - (setq format-all--format-table (make-hash-table) - format-all--mode-table (make-hash-table))) - - (describe "set-formatter!" - (before-each - (set-formatter! 'test (lambda () (interactive)))) - - (it "defines a formatter" - (set-formatter! 'new (lambda () (interactive))) - (expect (gethash 'new format-all--mode-table) :to-equal nil) - (expect (functionp (gethash 'new format-all--format-table)))) - - (it "defines a formatter with modes" - (set-formatter! 'new (lambda () (interactive)) - :modes '(a-mode (b-mode "x"))) - (expect (gethash 'a-mode format-all--mode-table) - :to-equal '((new))) - (expect (gethash 'b-mode format-all--mode-table) - :to-equal '((new . (lambda () "x"))))) - - (it "replaces a pre-existing formatter" - (let ((old-fn (gethash 'test format-all--format-table))) - (set-formatter! 'test "echo") - (expect (gethash 'test format-all--format-table) :not :to-equal old-fn))) - - (it "unsets a pre-existing formatter" - (set-formatter! 'test nil) - (expect (gethash 'test format-all--format-table) :to-be nil)) - - (it "errors when unsetting non-existent formatter" - (expect (set-formatter! 'doesnt-exist nil) :to-throw))) - - - ;; TODO - (xdescribe "hooks" - (describe "format|enable-on-save-maybe") - (describe "format|enable-on-save")) - - - ;; TODO - (xdescribe "formatting" - (before-each - (set-formatter! 'command - (lambda () - (interactive) - (let ((first-line (car (split-string (buffer-string) "\n")))) - (erase-buffer) - (insert first-line))) - :modes '(text-mode)) - (set-formatter! 'faulty-command - (lambda () - (interactive) - (error "This is a test")) - :modes '(text-mode)) - (set-formatter! 'function - (lambda (input) - (insert (car (split-string input "\n"))) - (list nil nil)) - :modes '(text-mode)) - (set-formatter! 'shellcmd "head -n 1" - :modes '(text-mode)) - (set-formatter! 'cmdlist '("head" "-n" "1") - :modes '(text-mode))) - - (describe "with an interactive command" - (it "formats a buffer" ) - (it "formats a region" ) - (it "no-ops if no change" ) - (it "doesn't modify the buffer in case of errors" ) - (it "preserves indentation" )) - - (describe "with a function" - (it "formats a buffer" ) - (it "formats a region" ) - (it "no-ops if no change" ) - (it "doesn't modify the buffer in case of errors" ) - (it "preserves indentation" )) - - (describe "with a shell command") - - (describe "with a shell command list" - (it "formats a buffer" ) - (it "formats a region" ) - (it "no-ops if no change" ) - (it "doesn't modify the buffer in case of errors" ) - (it "preserves indentation" ) - - (it "interpolates non-strings into format strings" ) - (it "conditionally appends sublisted options" )))) diff --git a/.config/emacs/modules/editor/god/README.org b/.config/emacs/modules/editor/god/README.org @@ -1,55 +0,0 @@ -#+title: :editor god -#+subtitle: IDDQD -#+created: October 13, 2021 -#+since: 21.12.0 - -#+begin_quote - 🚧 *This module is deprecated.* ~god-mode~ is EOL and no longer maintained. -#+end_quote - -* Description :unfold: -Adds [[doom-package:god-mode]] support to Doom Emacs, allowing for entering commands without -modifier keys, similar to Vim's modality, separating command mode and insert -mode. - -** Maintainers -*This module needs a maintainer.* [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:god-mode]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* Usage -#+begin_quote -🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Configuration -#+begin_quote -🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* Appendix -#+begin_quote -🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/editor/god/autoload.el b/.config/emacs/modules/editor/god/autoload.el @@ -1,43 +0,0 @@ -;;; editor/god/autoload.el -*- lexical-binding: t; -*- - -(defvar +god-read-only-mode-color "Gray" - "Cursor and bar color when `read-only-mode' is enabled.") - -(defvar +god-overwrite-mode-color "Yellow" - "Cursor and bar color when `overwrite-mode' is enabled.") - -(defvar +god-fill-overflow-color "IndianRed" - "Cursor and bar color when fill column width has been exceeded.") - -;;;###autoload -(defun +god--configure-cursor-and-modeline-h () - "Configure cursor type, cursor color and doom-modeline bar color depending on mode." - (let* ((is-fill-overflow (> (current-column) fill-column)) - (previous-cursor-color (face-background 'cursor)) - (previous-modeline-color (and (facep 'doom-modeline-bar) - (face-background 'doom-modeline-bar))) - (is-god-mode (bound-and-true-p god-local-mode)) - (next-cursor-type - (cond (buffer-read-only 'box) - ((and overwrite-mode is-god-mode) 'hollow) - ((or is-god-mode overwrite-mode) 'box) - (t 'bar))) - (next-cursor-and-modeline-color - (cond (buffer-read-only +god-read-only-mode-color) - (is-fill-overflow +god-fill-overflow-color) - (overwrite-mode +god-overwrite-mode-color) - (t previous-cursor-color)))) - (setq cursor-type next-cursor-type) - (unless (eq previous-cursor-color next-cursor-and-modeline-color) - (set-cursor-color next-cursor-and-modeline-color)) - (when (and (facep 'doom-modeline-bar) - (fboundp 'doom-modeline-refresh-bars) - (not (eq previous-modeline-color next-cursor-and-modeline-color))) - (set-face-attribute 'doom-modeline-bar nil :background next-cursor-and-modeline-color) - (doom-modeline-refresh-bars)))) - -;;;###autoload -(defun +god--toggle-on-overwrite-h () - (if (bound-and-true-p overwrite-mode) - (god-local-mode-pause) - (god-local-mode-resume))) diff --git a/.config/emacs/modules/editor/god/config.el b/.config/emacs/modules/editor/god/config.el @@ -1,10 +0,0 @@ -;;; editor/god/config.el -*- lexical-binding: t; -*- - -(use-package! god-mode - :hook (doom-after-modules-config . god-mode-all) - :config - (add-hook 'post-command-hook #'+god--configure-cursor-and-modeline-h) - (add-hook 'overwrite-mode-hook #'+god--toggle-on-overwrite-h) - - (after! which-key - (which-key-enable-god-mode-support))) diff --git a/.config/emacs/modules/editor/god/doctor.el b/.config/emacs/modules/editor/god/doctor.el @@ -1,8 +0,0 @@ -;; -*- lexical-binding: t; no-byte-compile: t; -*- -;;; editor/god/doctor.el - -(when (modulep! :editor evil) - (warn! "god-mode is not really compatible with evil")) - -(when (modulep! :editor objed) - (warn! "god-mode is not really compatible with objed")) diff --git a/.config/emacs/modules/editor/god/packages.el b/.config/emacs/modules/editor/god/packages.el @@ -1,4 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; editor/god/packages.el - -(package! god-mode :pin "607aff10a7b27a8aa0c1a15c2c39337ab17cfda7") diff --git a/.config/emacs/modules/editor/lispy/README.org b/.config/emacs/modules/editor/lispy/README.org @@ -1,85 +0,0 @@ -#+title: :editor lispy -#+subtitle: Vim for lisp, for people who don't like vim -#+created: October 27, 2018 -#+since: 2.0.0 - -* Description :unfold: -This module adds a keybind scheme for navigating and editing S-expressions in -Lisps; including S-exp awareness for Evil users. This affects the following -languages: - -- Common Lisp -- Emacs Lisp -- Scheme -- Racket -- [[http://docs.hylang.org/en/stable/][Hy]] -- [[http://lfe.io/][LFE]] -- Clojure -- [[https://fennel-lang.org][Fennel]] - -** Maintainers -*This module needs a maintainer.* [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:lispy]] -- [[doom-package:lispyville]] if [[doom-module::editor evil +everywhere]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -If [[doom-module::editor evil]] is enabled, [[doom-package:lispyville]] would also be activated for every mode -where [[doom-package:lispy]] is active. - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -The default key themes that are set are as follows: -#+begin_src emacs-lisp -'((operators normal) - c-w - (prettify insert) - (atom-movement normal visual) - slurp/barf-lispy - additional - additional-insert) -#+end_src - -To change the key themes set ~lispyville-key-theme~. Think of -~lispyville-key-theme~ as the equivalent of ~parinfer-extensions~. See -lispyville's [[https://github.com/noctuid/lispyville/blob/master/README.org][README]] for more info on the specific keybindings of each key theme -(starting [[https://github.com/noctuid/lispyville#operators-key-theme][here]]). - -* Troubleshooting -[[doom-report:][Report an issue?]] - -** Mouse wheel and =wrap=/=additional-wrap= key themes in TTY Emacs ([[https://github.com/hlissner/doom-emacs/issues/2573][#2573]]) -lispyville binds [[kbd:][M-[]] to ~lispyville-wrap-brackets~ when the =wrap= or -=additional-wrap= key themes are enabled. In terminal Emacs, this is the key -Emacs receives when you scroll with your mouse wheel. - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/editor/lispy/config.el b/.config/emacs/modules/editor/lispy/config.el @@ -1,52 +0,0 @@ -;;; editor/lispy/config.el -*- lexical-binding: t; -*- - -(use-package! lispy - :hook ((lisp-mode . lispy-mode) - (emacs-lisp-mode . lispy-mode) - (ielm-mode . lispy-mode) - (scheme-mode . lispy-mode) - (racket-mode . lispy-mode) - (hy-mode . lispy-mode) - (lfe-mode . lispy-mode) - (dune-mode . lispy-mode) - (clojure-mode . lispy-mode) - (fennel-mode . lispy-mode)) - :init - (add-hook! 'eval-expression-minibuffer-setup-hook - (defun doom-init-lispy-in-eval-expression-h () - "Enable `lispy-mode' in the minibuffer for `eval-expression'." - (lispy-mode) - ;; When `lispy-key-theme' has `parinfer', the TAB key doesn't do - ;; completion, neither (kbd "<tab>"/"TAB"/"C-i")/[tab]/"\C-i" works in - ;; terminal as tested so remapping is used as a workaround - (local-set-key (vector 'remap (lookup-key lispy-mode-map (kbd "TAB"))) #'completion-at-point))) - :config - (setq lispy-close-quotes-at-end-p t) - (add-hook 'lispy-mode-hook #'turn-off-smartparens-mode) - - (when (modulep! :lang emacs-lisp) - (setq lispy-outline - (concat - ;; `lispy-mode' requires `lispy-outline' start with ^ - (unless (string-prefix-p "^" +emacs-lisp-outline-regexp) "^") - +emacs-lisp-outline-regexp)) - (advice-add #'lispy-outline-level :override #'+emacs-lisp-outline-level))) - - -(use-package! lispyville - :when (modulep! :editor evil) - :hook (lispy-mode . lispyville-mode) - :init - (setq lispyville-key-theme - '((operators normal) - c-w - (prettify insert) - (atom-movement t) - slurp/barf-lispy - additional - additional-insert)) - :config - (lispyville-set-key-theme) - (add-hook! 'evil-escape-inhibit-functions - (defun +lispy-inhibit-evil-escape-fn () - (and lispy-mode (evil-insert-state-p))))) diff --git a/.config/emacs/modules/editor/lispy/packages.el b/.config/emacs/modules/editor/lispy/packages.el @@ -1,6 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; editor/lispyville/packages.el - -(package! lispy :pin "097dd66e662c3eee90d112d88bac5345d26e508f") -(when (modulep! :editor evil) - (package! lispyville :pin "14ee8711d58b649aeac03581d22b10ab077f06bd")) diff --git a/.config/emacs/modules/editor/multiple-cursors/README.org b/.config/emacs/modules/editor/multiple-cursors/README.org @@ -1,78 +0,0 @@ -#+title: :editor multiple-cursors -#+subtitle: Make all your mistakes at once -#+created: October 13, 2021 -#+since: 21.12.0 - -* Description :unfold: -This module adds a multiple cursors implementation to Emacs (two, if you use -evil) that loosely take after multi-cursors in Atom or Sublime Text. - -** Maintainers -- [[doom-user:][@hlissner]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- if [[doom-module::editor evil]] - - [[doom-package:evil-multiedit]] - - [[doom-package:evil-mc]] -- else - - [[doom-package:multiple-cursors]] - -** Hacks -- Attempts to smooth over [[doom-package:multiple-cursors]]' incompatibilities with [[doom-package:evil]], which - is used internally in some third party plugins. -- Attempts to smooth over [[doom-package:evil-mc]]'s incompatibilities with other packages, like - [[doom-package:lispy]]. - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** evil-mc -- The [[doom-package:evil-mc]] keys are under the [[kbd:][gz]] prefix, e.g. - - [[kbd:][gzz]] to toggle new (frozen) cursors at point. - - [[kbd:][gzt]] to toggle mirroring on and off (or switch to insert mode to activate - them). - - [[kbd:][gzA]] to place cursors at the end of each selected line. - - [[kbd:][gzI]] will place them at the beginning. -- There's also the ex command ~:mc/REGEXP/FLAGS~, for laying down cursors by - regex. - -** evil-multiedit -Designates "interactive edit" regions. Only the textual changes to them are mirrored. - -- [[kbd:][M-d]] to iedit the symbol at point. Again to iedit its next match. -- [[kbd:][M-S-d]] to do it backwards. -- [[kbd:][R]] (in visual mode) to iedit all matches of the selection at point in the - buffer. -- Or ~:iedit/REGEX~ to iedit all matches of REGEX. - -* TODO Configuration -#+begin_quote -🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* Appendix -#+begin_quote -🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/editor/multiple-cursors/autoload/evil-mc.el b/.config/emacs/modules/editor/multiple-cursors/autoload/evil-mc.el @@ -1,131 +0,0 @@ -;;; editor/multiple-cursors/autoload/evil-mc.el -*- lexical-binding: t; -*- -;;;###if (modulep! :editor evil) - -;;;###autoload -(defun +multiple-cursors/evil-mc-toggle-cursors () - "Toggle frozen state of evil-mc cursors." - (interactive) - (unless (evil-mc-has-cursors-p) - (user-error "No cursors exist to be toggled")) - (setq evil-mc-frozen (not (and (evil-mc-has-cursors-p) - evil-mc-frozen))) - (if evil-mc-frozen - (message "evil-mc paused") - (message "evil-mc resumed"))) - -;;;###autoload (autoload '+multiple-cursors/evil-mc-toggle-cursor-here "editor/multiple-cursors/autoload/evil-mc" nil t) -(evil-define-command +multiple-cursors/evil-mc-toggle-cursor-here () - "Create a cursor at point. If in visual block or line mode, then create -cursors on each line of the selection, on the column of the cursor. Otherwise -pauses cursors." - :repeat nil - :keep-visual nil - :evil-mc t - (interactive) - (cond ((and (evil-mc-has-cursors-p) - (evil-normal-state-p) - (let* ((pos (point)) - (cursor (cl-find-if (lambda (cursor) - (eq pos (evil-mc-get-cursor-start cursor))) - evil-mc-cursor-list))) - (when cursor - (evil-mc-delete-cursor cursor) - (setq evil-mc-cursor-list (delq cursor evil-mc-cursor-list)) - t)))) - - ((memq evil-this-type '(block line)) - (let ((col (evil-column)) - (line-at-pt (line-number-at-pos))) - ;; Fix off-by-one error - (when (= evil-visual-direction 1) - (cl-decf col) - (backward-char)) - (save-excursion - (evil-apply-on-block - (lambda (ibeg _) - (unless (or (= line-at-pt (line-number-at-pos ibeg)) - (invisible-p ibeg)) - (goto-char ibeg) - (move-to-column col) - (when (= (current-column) col) - (evil-mc-make-cursor-here)))) - evil-visual-beginning - (if (eq evil-this-type 'line) (1- evil-visual-end) evil-visual-end) - nil) - (evil-exit-visual-state)))) - (t - (evil-mc-pause-cursors) - ;; I assume I don't want the cursors to move yet - (evil-mc-make-cursor-here)))) - -;;;###autoload (autoload '+multiple-cursors:evil-mc "editor/multiple-cursors/autoload/evil-mc" nil t) -(evil-define-command +multiple-cursors:evil-mc (beg end type pattern &optional flags bang) - "Create mc cursors at each match of PATTERN within BEG and END. - -This leaves the cursor where the final cursor would be. If BANG, then treat -PATTERN as literal. PATTERN is a delimited regexp (the same that :g or :s uses). -FLAGS can be g and/or i; which mean the same thing they do in -`evil-ex-substitute'." - :evil-mc t - :keep-visual t - (interactive "<R><//!><!>") - (unless (and (stringp pattern) - (not (string-empty-p pattern))) - (user-error "A regexp pattern is required")) - (require 'evil-mc) - (let ((m (evil-ex-make-pattern - (if bang (regexp-quote pattern) pattern) - (cond ((memq ?i flags) 'insensitive) - ((memq ?I flags) 'sensitive) - ((not +multiple-cursors-evil-mc-ex-case) - evil-ex-search-case) - (t +multiple-cursors-evil-mc-ex-case)) - (or (and +multiple-cursors-evil-mc-ex-global - (not (memq ?g flags))) - (and (not +multiple-cursors-evil-mc-ex-global) - (memq ?g flags)))))) - (evil-mc-run-cursors-before) - (setq evil-mc-pattern (cons m (list beg end type))) - (evil-with-restriction beg end - (goto-char beg) - (while (eq (evil-ex-find-next m 'forward t) t) - (evil-mc-make-cursor-at-pos (1- (point))) - (unless (evil-ex-pattern-whole-line m) - (goto-char (line-beginning-position 2))))) - (evil-mc-goto-cursor - (if (= (evil-visual-direction) 1) - (evil-mc-find-last-cursor) - (evil-mc-find-first-cursor)) - nil) - (evil-mc-undo-cursor-at-pos (1- (point))) - (if (evil-mc-has-cursors-p) - (evil-mc-print-cursors-info "Created") - (evil-mc-message "No cursors were created")))) - -;;;###autoload (autoload '+multiple-cursors/evil-mc-undo-cursor "editor/multiple-cursors/autoload/evil-mc" nil t) -(evil-define-command +multiple-cursors/evil-mc-undo-cursor () - "Undos last cursor, or all cursors in visual region." - :repeat nil - :evil-mc t - (interactive) - (if (evil-visual-state-p) - (or (mapc (lambda (c) - (evil-mc-delete-cursor c) - (setq evil-mc-cursor-list (delq c evil-mc-cursor-list))) - (cl-remove-if-not - (lambda (pos) - (and (>= pos evil-visual-beginning) - (< pos evil-visual-end))) - evil-mc-cursor-list - :key #'evil-mc-get-cursor-start)) - (message "No cursors to undo in region")) - (evil-mc-undo-last-added-cursor))) - - -;;;###autoload (autoload '+multiple-cursors-execute-default-operator-fn "editor/multiple-cursors/autoload/evil-mc" nil t) - -(after! evil-mc - (evil-mc-define-handler +multiple-cursors-execute-default-operator-fn () - :cursor-clear region - (evil-mc-with-region-or-execute-macro region t - (funcall (evil-mc-get-command-name) region-start region-end)))) diff --git a/.config/emacs/modules/editor/multiple-cursors/config.el b/.config/emacs/modules/editor/multiple-cursors/config.el @@ -1,225 +0,0 @@ -;;; editor/multiple-cursors/config.el -*- lexical-binding: t; -*- - -(defvar +multiple-cursors-evil-mc-ex-global t - "TODO") - -(defvar +multiple-cursors-evil-mc-ex-case nil - "TODO") - - -;; -;;; Packages - -(use-package! evil-multiedit - :when (modulep! :editor evil) - :defer t) - - -(use-package! iedit - :when (modulep! :completion vertico) - :defer t - :init - ;; Fix conflict with embark. - (setq iedit-toggle-key-default nil)) - - -(use-package! evil-mc - :when (modulep! :editor evil) - :commands (evil-mc-make-cursor-here - evil-mc-make-all-cursors - evil-mc-undo-all-cursors - evil-mc-pause-cursors - evil-mc-resume-cursors - evil-mc-make-and-goto-first-cursor - evil-mc-make-and-goto-last-cursor - evil-mc-make-cursor-in-visual-selection-beg - evil-mc-make-cursor-in-visual-selection-end - evil-mc-make-cursor-move-next-line - evil-mc-make-cursor-move-prev-line - evil-mc-make-cursor-at-pos - evil-mc-has-cursors-p - evil-mc-make-and-goto-next-cursor - evil-mc-skip-and-goto-next-cursor - evil-mc-make-and-goto-prev-cursor - evil-mc-skip-and-goto-prev-cursor - evil-mc-make-and-goto-next-match - evil-mc-skip-and-goto-next-match - evil-mc-skip-and-goto-next-match - evil-mc-make-and-goto-prev-match - evil-mc-skip-and-goto-prev-match) - :init - ;; The included keybindings are too imposing and are likely to cause - ;; conflicts, so we'll set them ourselves. - (defvar evil-mc-key-map (make-sparse-keymap)) - - :config - ;; HACK evil-mc's design is bizarre. Its variables and hooks are lazy loaded - ;; rather than declared at top-level, some hooks aren't defined or - ;; documented, it's a bit initializer-function drunk, and its minor modes - ;; are intended to be perpetually active -- even when no cursors are active - ;; (causing #6021). I undo all of that here. - (evil-mc-define-vars) - (evil-mc-initialize-vars) - (add-hook 'evil-mc-before-cursors-created #'evil-mc-pause-incompatible-modes) - (add-hook 'evil-mc-before-cursors-created #'evil-mc-initialize-active-state) - (add-hook 'evil-mc-after-cursors-deleted #'evil-mc-teardown-active-state) - (add-hook 'evil-mc-after-cursors-deleted #'evil-mc-resume-incompatible-modes) - (advice-add #'evil-mc-initialize-hooks :override #'ignore) - (advice-add #'evil-mc-teardown-hooks :override #'evil-mc-initialize-vars) - (advice-add #'evil-mc-initialize-active-state :before #'turn-on-evil-mc-mode) - (advice-add #'evil-mc-teardown-active-state :after #'turn-off-evil-mc-mode) - (defadvice! +multiple-cursors--dont-reinit-vars-a (fn &rest args) - :around #'evil-mc-mode - (letf! ((#'evil-mc-initialize-vars #'ignore)) - (apply fn args))) - - ;; REVIEW This is tremendously slow on macos and windows for some reason. - (setq evil-mc-enable-bar-cursor (not (or IS-MAC - IS-WINDOWS))) - - (after! smartparens - ;; Make evil-mc cooperate with smartparens better - (let ((vars (cdr (assq :default evil-mc-cursor-variables)))) - (unless (memq (car sp--mc/cursor-specific-vars) vars) - (setcdr (assq :default evil-mc-cursor-variables) - (append vars sp--mc/cursor-specific-vars))))) - - ;; Whitelist more commands - (dolist (fn '((backward-kill-word) - (company-complete-common . evil-mc-execute-default-complete) - (doom/backward-to-bol-or-indent . evil-mc-execute-default-call) - (doom/forward-to-last-non-comment-or-eol . evil-mc-execute-default-call) - ;; :emacs undo - (undo-fu-only-undo . evil-mc-execute-default-undo) - (undo-fu-only-redo . evil-mc-execute-default-redo) - ;; :editor evil - (evil-delete-back-to-indentation . evil-mc-execute-default-call) - (evil-escape . evil-mc-execute-default-evil-normal-state) ; C-g - (evil-numbers/inc-at-pt-incremental) - (evil-numbers/dec-at-pt-incremental) - (evil-digit-argument-or-evil-beginning-of-visual-line - (:default . evil-mc-execute-default-call) - (visual . evil-mc-execute-visual-call)) - ;; :tools eval - (+eval:replace-region . +multiple-cursors-execute-default-operator-fn) - ;; :lang ess - (ess-smart-comma . evil-mc-execute-call) - ;; :lang org - (evil-org-delete . evil-mc-execute-default-evil-delete))) - (setf (alist-get (car fn) evil-mc-custom-known-commands) - (if (and (cdr fn) (listp (cdr fn))) - (cdr fn) - (list (cons :default - (or (cdr fn) - #'evil-mc-execute-default-call-with-count)))))) - - ;; HACK Allow these commands to be repeated by prefixing them with a numerical - ;; argument. See gabesoft/evil-mc#110 - (defadvice! +multiple-cursors--make-repeatable-a (fn) - :around '(evil-mc-make-and-goto-first-cursor - evil-mc-make-and-goto-last-cursor - evil-mc-make-and-goto-prev-cursor - evil-mc-make-and-goto-next-cursor - evil-mc-skip-and-goto-prev-cursor - evil-mc-skip-and-goto-next-cursor - evil-mc-make-and-goto-prev-match - evil-mc-make-and-goto-next-match - evil-mc-skip-and-goto-prev-match - evil-mc-skip-and-goto-next-match) - (dotimes (i (if (integerp current-prefix-arg) current-prefix-arg 1)) - (funcall fn))) - - ;; If we're entering insert mode, it's a good bet that we want to start using - ;; our multiple cursors - (add-hook 'evil-insert-state-entry-hook #'evil-mc-resume-cursors) - - (pushnew! evil-mc-incompatible-minor-modes - ;; evil-escape's escape key leaves behind extraneous characters - 'evil-escape-mode - ;; Lispy commands don't register on more than 1 cursor. Lispyville - ;; is fine though. - 'lispy-mode) - - (add-hook! 'doom-escape-hook - (defun +multiple-cursors-escape-multiple-cursors-h () - "Clear evil-mc cursors and restore state." - (when (evil-mc-has-cursors-p) - (evil-mc-undo-all-cursors) - (evil-mc-resume-cursors) - t))) - - ;; Forward declare these so that ex completion and evil-mc support is - ;; recognized before the autoloaded functions are loaded. - (evil-add-command-properties '+evil:align :evil-mc t) - (evil-add-command-properties '+multiple-cursors:evil-mc :evil-mc t) - - (map! :map evil-mc-key-map - :nv "g." nil - :nv "C-n" #'evil-mc-make-and-goto-next-cursor - :nv "C-S-n" #'evil-mc-make-and-goto-last-cursor - :nv "C-p" #'evil-mc-make-and-goto-prev-cursor - :nv "C-S-p" #'evil-mc-make-and-goto-first-cursor)) - - -(after! multiple-cursors-core - (setq mc/list-file (concat doom-data-dir "mc-lists.el")) - - ;; Can't use `mc/cmds-to-run-once' because mc-lists.el overwrites it - (add-to-list 'mc--default-cmds-to-run-once 'swiper-mc) - - ;; TODO multiple-cursors config for Emacs users? - - ;; mc doesn't play well with evil, this attempts to assuage some of its - ;; problems so that any plugins that depend on multiple-cursors (which I have - ;; no control over) can still use it in relative safety. - (when (modulep! :editor evil) - (evil-define-key* '(normal emacs) mc/keymap [escape] #'mc/keyboard-quit) - - (defvar +mc--compat-evil-prev-state nil) - (defvar +mc--compat-mark-was-active nil) - - (add-hook! 'multiple-cursors-mode-enabled-hook - (defun +multiple-cursors-compat-switch-to-emacs-state-h () - (when (and (bound-and-true-p evil-mode) - (not (memq evil-state '(insert emacs)))) - (setq +mc--compat-evil-prev-state evil-state) - (when (region-active-p) - (setq +mc--compat-mark-was-active t)) - (let ((mark-before (mark)) - (point-before (point))) - (evil-emacs-state 1) - (when (or +mc--compat-mark-was-active (region-active-p)) - (goto-char point-before) - (set-mark mark-before)))))) - - (add-hook! 'multiple-cursors-mode-disabled-hook - (defun +multiple-cursors-compat-back-to-previous-state-h () - (when +mc--compat-evil-prev-state - (unwind-protect - (cl-case +mc--compat-evil-prev-state - ;; For `evil-multiedit', marked occurrences aren't saved after - ;; exiting mc, so we should return to normal state anyway - ((normal visual multiedit multiedit-insert) - (evil-force-normal-state)) - (t (message "Don't know how to handle previous state: %S" - +mc--compat-evil-prev-state))) - (setq +mc--compat-evil-prev-state nil) - (setq +mc--compat-mark-was-active nil))))) - - ;; When running edit-lines, point will return (position + 1) as a result of - ;; how evil deals with regions - (defadvice! +multiple--cursors-adjust-mark-for-evil-a (&rest _) - :before #'mc/edit-lines - (when (and (bound-and-true-p evil-mode) - (not (memq evil-state '(insert emacs)))) - (if (> (point) (mark)) - (goto-char (1- (point))) - (push-mark (1- (mark)))))) - - (add-hook! 'rectangular-region-mode-hook - (defun +multiple-cursors-evil-compat-rect-switch-state-h () - (if rectangular-region-mode - (+multiple-cursors-compat-switch-to-emacs-state-h) - (setq +mc--compat-evil-prev-state nil)))) - - (defvar mc--default-cmds-to-run-once nil))) diff --git a/.config/emacs/modules/editor/multiple-cursors/packages.el b/.config/emacs/modules/editor/multiple-cursors/packages.el @@ -1,9 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; editor/multiple-cursors/packages.el - -(cond - ((modulep! :editor evil) - (package! evil-multiedit :pin "23b53bc8743fb82a8854ba907b1d277374c93a79") - (package! evil-mc :pin "63fd2fe0c213a4cc31c464d246f92931c4cb720f")) - - ((package! multiple-cursors :pin "16223efc2d6dece2d43bbccc189d7a4bab6de571"))) diff --git a/.config/emacs/modules/editor/objed/README.org b/.config/emacs/modules/editor/objed/README.org @@ -1,60 +0,0 @@ -#+title: :editor objed -#+subtitle: Text object editing for the innocent -#+created: May 30, 2019 -#+since: 21.12.0 - -* Description :unfold: -This modules adds [[doom-package:objed]], a global minor-mode for navigating and manipulating -text objects. It combines the ideas of ~versor-mode~ and other editors like Vim -or Kakoune and tries to align them with regular Emacs conventions. - -[[https://github.com/clemera/objed][See the objed project README]] for information on keybinds and usage. - -** Maintainers -*This module needs a maintainer.* [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +manual :: - Don't activate [[doom-package:objed]] at startup, automatically, leaving it to the user to call - [[fn:objed-activate]] (bound to [[kbd:][M-SPC]] if using [[doom-module::config default +bindings]]). - -** Packages -- [[doom-package:objed]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -#+begin_quote - 🚧 This module is incompatible with [[doom-module::editor evil]]. Do not enable them both at - the same time or you will get errors. -#+end_quote - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/editor/objed/config.el b/.config/emacs/modules/editor/objed/config.el @@ -1,27 +0,0 @@ -;;; editor/objed/config.el -*- lexical-binding: t; -*- - -(use-package! objed - :after-call pre-command-hook - :config - ;; Prevent undo actions from exiting edit state - (pushnew! objed-keeper-commands 'undo-fu-only-undo 'undo-fu-only-redo) - - (defvar +objed--extra-face-remaps nil) - - (defadvice! +objed--add-face-remaps-a (&rest _) - "Add extra face remaps when objed activates." - :after 'objed--init - (when (memq 'objed-hl (assq 'hl-line face-remapping-alist)) - (push (face-remap-add-relative 'solaire-hl-line-face 'objed-hl) - +objed--extra-face-remaps))) - - (defadvice! +objed--remove-face-remaps-a (&rest _) - "Remove extra face remaps when objed de-activates." - :after 'objed--reset - (unless (memq 'objed-hl (assq 'hl-line face-remapping-alist)) - (dolist (remap +objed--extra-face-remaps) - (face-remap-remove-relative remap)) - (setq +objed--extra-face-remaps nil))) - - (unless (modulep! +manual) - (objed-mode +1))) diff --git a/.config/emacs/modules/editor/objed/packages.el b/.config/emacs/modules/editor/objed/packages.el @@ -1,4 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; editor/objed/packages.el - -(package! objed :pin "70f9fb5e0aa1627b0afc7c6b3d0aea9bac70a210") diff --git a/.config/emacs/modules/editor/parinfer/README.org b/.config/emacs/modules/editor/parinfer/README.org @@ -1,57 +0,0 @@ -#+title: :editor parinfer -#+subtitle: For lispers that like Python more (i.e. nobody) -#+created: February 27, 2021 -#+since: 21.12.0 - -* Description :unfold: -Parinfer is a minor mode that aids the writing of Lisp code. It automatically -infers parenthesis matching and indentation alignment, keeping your code -balanced and beautiful. - -** Maintainers -*This module needs a maintainer.* [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:parinfer-rust-mode]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires [[https://github.com/justinbarclay/parinfer-rust-mode#parinfer-rust-library][parinfer-rust]]. - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** Keybindings -| Binding | Description | -|-----------------+-------------------------------------------| -| [[kbd:][<localleader> p]] | Toggle between different inference modes. | -| [[kbd:][<localleader> P]] | Temporarily disable parinfer. | - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/editor/parinfer/config.el b/.config/emacs/modules/editor/parinfer/config.el @@ -1,24 +0,0 @@ -;;; editor/parinfer/config.el -*- lexical-binding: t; -*- - -(use-package! parinfer-rust-mode - :when (bound-and-true-p module-file-suffix) - :hook ((emacs-lisp-mode - clojure-mode - scheme-mode - lisp-mode - racket-mode - fennel-mode - hy-mode) . parinfer-rust-mode) - :init - (setq parinfer-rust-library - (concat doom-data-dir "parinfer-rust/" - (cond (IS-MAC "parinfer-rust-darwin.so") - (IS-LINUX "parinfer-rust-linux.so") - (IS-WINDOWS "parinfer-rust-windows.dll") - (IS-BSD "libparinfer_rust.so"))) - parinfer-rust-auto-download (not IS-BSD)) - :config - (map! :map parinfer-rust-mode-map - :localleader - "p" #'parinfer-rust-switch-mode - "P" #'parinfer-rust-toggle-disable)) diff --git a/.config/emacs/modules/editor/parinfer/doctor.el b/.config/emacs/modules/editor/parinfer/doctor.el @@ -1,7 +0,0 @@ -;;; editor/parinfer/doctor.el -*- lexical-binding: t; -*- - -(unless (fboundp 'module-load) - (warn! "Your emacs wasn't built with dynamic modules support. `parinfer-rust-mode' won't work")) -(when (and (eq system-type 'berkeley-unix) - (not (file-readable-p parinfer-rust-library))) - (warn! (concat "Could not read " parinfer-rust-library ". `parinfer-rust-mode' won't work"))) diff --git a/.config/emacs/modules/editor/parinfer/packages.el b/.config/emacs/modules/editor/parinfer/packages.el @@ -1,4 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; editor/parinfer/packages.el - -(package! parinfer-rust-mode :pin "332c7f47426f0519dc5c24dda82afdb1aa8b61ee") diff --git a/.config/emacs/modules/editor/rotate-text/README.org b/.config/emacs/modules/editor/rotate-text/README.org @@ -1,77 +0,0 @@ -#+title: :editor rotate-text -#+subtitle: The only back'n'forth nerds will ever know -#+created: June 22, 2018 -#+since: 2.0.4 - -* Description :unfold: -This module adds text rotation to Doom Emacs. I.e. The ability to cycle through -keywords or text patterns at point, like ~true~ and ~false~, or ~public~, -~protected~, and ~private~ (in ~c++-mode~). - -** Maintainers -- [[doom-user:][@hlissner]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:rotate-text]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* TODO Usage -#+begin_quote -🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -For evil users: [[kbd:][[r]] and [[kbd:][]r]] will cycle back and forward (respectively) through -specified patterns for the text at point. Patterns will wrap around as you cycle -through them. - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -To enable a set of items to cycle through globally: -#+begin_src emacs-lisp -;; in $DOOMDIR/config.el -(after! rotate-text - (add-to-list 'rotate-text-words '("small" "medium" "large"))) -#+end_src - -To add a sequence to a specific mode: -#+begin_src emacs-lisp -;; in $DOOMDIR/config.el -(set-rotate-patterns! 'c++-mode - :words '(("float" "double"))) -#+end_src - -When configuring a sequence of words or symbols that should be rotated through, -it is important that all items are all lower case. The casing will be determined -by the item that initiated the rotation. For example, ~Small~ will be replaced -with ~Medium~ and ~SMALL~ will be replaced with ~MEDIUM~ using the example -described above. - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* Appendix -#+begin_quote -🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/editor/rotate-text/autoload.el b/.config/emacs/modules/editor/rotate-text/autoload.el @@ -1,21 +0,0 @@ -;;; editor/rotate-text/autoload.el -*- lexical-binding: t; -*- - -;;;###autoload -(with-eval-after-load 'rotate-text - (pushnew! rotate-text-words - '("true" "false") - '("enable" "disable"))) - -;;;###autodef -(cl-defun set-rotate-patterns! (modes &key symbols words patterns) - "Declare :symbols, :words or :patterns (all lists of strings) that -`rotate-text' will cycle through." - (declare (indent defun)) - (dolist (mode (ensure-list modes)) - (let ((fn-name (intern (format "+rotate-text-init-%s-h" mode)))) - (fset fn-name - (lambda () - (setq-local rotate-text-local-symbols symbols) - (setq-local rotate-text-local-words words) - (setq-local rotate-text-local-patterns patterns))) - (add-hook (intern (format "%s-hook" mode)) fn-name)))) diff --git a/.config/emacs/modules/editor/rotate-text/packages.el b/.config/emacs/modules/editor/rotate-text/packages.el @@ -1,7 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; editor/rotate-text/packages.el - -(package! rotate-text - :recipe (:host github - :repo "debug-ito/rotate-text.el") - :pin "48f193697db996855aee1ad2bc99b38c6646fe76") diff --git a/.config/emacs/modules/editor/snippets/README.org b/.config/emacs/modules/editor/snippets/README.org @@ -1,66 +0,0 @@ -#+title: :editor snippets -#+subtitle: My elves type so I don't have to -#+created: February 11, 2017 -#+since: 2.0.0 - -* Description :unfold: -This module adds snippet expansions to Emacs, powered by [[doom-package:yasnippet]]. - -** Maintainers -- [[doom-user:][@hlissner]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module exposes no flags./ - -** Packages -- [[doom-package:yasnippet]] -- [[doom-package:auto-yasnippet]] -- [[doom-package:doom-snippets]] - -** TODO Hacks -#+begin_quote - 🔨 This module's hacks haven't been documented yet. [[doom-contrib-module:][Document them?]] -#+end_quote - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** Disabling the built-in snippets -#+begin_src emacs-lisp -;; in $DOOMDIR/packages.el -(package! doom-snippets :ignore t) -;; If you want to replace it with yasnippet's default snippets -(package! yasnippet-snippets) -#+end_src - -** Adding custom snippets -Custom snippets should be added under =$DOOMDIR/snippets/= directory. Refer to [[http://joaotavora.github.io/yasnippet/snippet-development.html][yasnippet-documentation]] on how to write snippets. - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/editor/snippets/autoload/settings.el b/.config/emacs/modules/editor/snippets/autoload/settings.el @@ -1,10 +0,0 @@ -;;; editor/snippets/autoload/settings.el -*- lexical-binding: t; -*- - -;;;###autodef -(defun set-yas-minor-mode! (modes) - "Register minor MODES (one mode symbol or a list of them) with yasnippet so it -can have its own snippets category, if the folder exists." - (dolist (mode (ensure-list modes)) - (let ((fn (intern (format "+snippets-register-%s-h" mode)))) - (fset fn (lambda () (yas-activate-extra-mode mode))) - (add-hook (intern (format "%s-hook" mode)) fn)))) diff --git a/.config/emacs/modules/editor/snippets/autoload/snippets.el b/.config/emacs/modules/editor/snippets/autoload/snippets.el @@ -1,328 +0,0 @@ -;;; editor/snippets/autoload/snippets.el -*- lexical-binding: t; -*- - -(defun +snippets--remove-p (x y) - (and (equal (yas--template-key x) (yas--template-key y)) - (file-in-directory-p (yas--template-get-file x) doom-emacs-dir))) - -;;;###autoload -(defun +snippets-prompt-private (prompt choices &optional display-fn) - "Prioritize private snippets over built-in ones if there are multiple -choices. - -There are two groups of snippets in Doom Emacs. The built in ones (under -`doom-emacs-dir'; provided by Doom or its plugins) or your private snippets -(outside of `doom-eamcs-dir'). - -If there are multiple snippets with the same key in either camp (but not both), -you will be prompted to select one. - -If there are conflicting keys across the two camps, the built-in ones are -ignored. This makes it easy to override built-in snippets with private ones." - (when (eq this-command 'yas-expand) - (let* ((gc-cons-threshold most-positive-fixnum) - (choices (condition-case _ - (cl-remove-duplicates choices :test #'+snippets--remove-p) - (wrong-type-argument choices)))) - (if (cdr choices) - (cl-loop for fn in (cdr (memq '+snippets-prompt-private yas-prompt-functions)) - if (funcall fn prompt choices display-fn) - return it) - (car choices))))) - -(defun +snippet--ensure-dir (dir) - (unless (file-directory-p dir) - (if (y-or-n-p (format "%S doesn't exist. Create it?" (abbreviate-file-name dir))) - (make-directory dir t) - (error "%S doesn't exist" (abbreviate-file-name dir))))) - -(defun +snippet--get-template-by-uuid (uuid &optional mode) - "Look up the template by uuid in child-most to parent-most mode order. -Finds correctly active snippets from parent modes (based on Yas' logic)." - (cl-loop with mode = (or mode major-mode) - for active-mode in (yas--modes-to-activate mode) - if (gethash active-mode yas--tables) - if (gethash uuid (yas--table-uuidhash it)) - return it)) - -(defun +snippet--completing-read-uuid (prompt all-snippets &rest args) - (plist-get - (text-properties-at - 0 (apply #'completing-read prompt - (cl-loop for (_ . tpl) in (mapcan #'yas--table-templates (if all-snippets - (hash-table-values yas--tables) - (yas--get-snippet-tables))) - - for txt = (format "%-25s%-30s%s" - (yas--template-key tpl) - (yas--template-name tpl) - (abbreviate-file-name (yas--template-load-file tpl))) - collect - (progn - (set-text-properties 0 (length txt) `(uuid ,(yas--template-uuid tpl) - path ,(yas--template-load-file tpl)) - txt) - txt)) - args)) - 'uuid)) - -(defun +snippet--abort () - (interactive) - (set-buffer-modified-p nil) - (kill-current-buffer)) - -(defvar +snippet--current-snippet-uuid nil) -(defun +snippet--edit () - (interactive) - (when +snippet--current-snippet-uuid - (let ((buf (current-buffer))) - (+snippets/edit +snippet--current-snippet-uuid) - (kill-buffer buf)))) - - -;; -;;; Commands - -;;;###autoload -(defun +snippets/goto-start-of-field () - "Go to the beginning of the current field." - (interactive) - (let* ((snippet (car (yas-active-snippets))) - (active-field (yas--snippet-active-field snippet)) - (position (if (yas--field-p active-field) - (yas--field-start active-field) - -1))) - (if (= (point) position) - (move-beginning-of-line 1) - (goto-char position)))) - -;;;###autoload -(defun +snippets/goto-end-of-field () - "Go to the end of the current field." - (interactive) - (let* ((snippet (car (yas-active-snippets))) - (active-field (yas--snippet-active-field snippet)) - (position (if (yas--field-p active-field) - (yas--field-end active-field) - -1))) - (if (= (point) position) - (move-end-of-line 1) - (goto-char position)))) - -;;;###autoload -(defun +snippets/delete-backward-char (&optional field) - "Prevents Yas from interfering with backspace deletion." - (interactive) - (let ((field (or field (and (overlayp yas--active-field-overlay) - (overlay-buffer yas--active-field-overlay) - (overlay-get yas--active-field-overlay 'yas--field))))) - (unless (and (yas--field-p field) - (eq (point) (marker-position (yas--field-start field)))) - (call-interactively #'delete-backward-char)))) - -;;;###autoload -(defun +snippets/delete-forward-char-or-field (&optional field) - "Delete forward, or skip the current field if it's empty. This is to prevent -buggy behavior when <delete> is pressed in an empty field." - (interactive) - (let ((field (or field (and yas--active-field-overlay - (overlay-buffer yas--active-field-overlay) - (overlay-get yas--active-field-overlay 'yas--field))))) - (cond ((not (yas--field-p field)) - (delete-char 1)) - ((and (not (yas--field-modified-p field)) - (eq (point) (marker-position (yas--field-start field)))) - (yas--skip-and-clear field) - (yas-next-field 1)) - ((eq (point) (marker-position (yas--field-end field))) nil) - ((delete-char 1))))) - -;;;###autoload -(defun +snippets/delete-to-start-of-field (&optional field) - "Delete to start-of-field." - (interactive) - (unless field - (setq field (and (overlayp yas--active-field-overlay) - (overlay-buffer yas--active-field-overlay) - (overlay-get yas--active-field-overlay 'yas--field)))) - (when (yas--field-p field) - (let ((sof (marker-position (yas--field-start field)))) - (when (and field (> (point) sof)) - (delete-region sof (point)))))) - -;;;###autoload -(defun +snippets/find () - "Open a snippet file (in all of `yas-snippet-dirs')." - (interactive) - (let* ((dirs (doom-files-in (cl-loop for dir in yas-snippet-dirs - if (symbolp dir) - collect (symbol-value dir) - else collect dir) - :depth 0 :type 'dirs)) - (files (doom-files-in dirs :depth 0 :full t))) - (let ((template-path (completing-read "Find snippet: " (mapcar #'abbreviate-file-name files)))) - (unless (file-readable-p template-path) - (user-error "Cannot read %S" template-path)) - (find-file template-path) - (unless (file-in-directory-p template-path +snippets-dir) - (read-only-mode +1) - (setq header-line-format "This is a built-in snippet. Press C-c C-e to modify it" - +snippet--current-snippet-uuid template-uuid))))) - -;;;###autoload -(defun +snippets/find-private () - "Open a private snippet file in `+snippets-dir'." - (interactive) - (doom-project-find-file +snippets-dir)) - -;;;###autoload -(defun +snippets/find-for-current-mode (template-uuid) - "Open a snippet for this mode." - (interactive - (list - (+snippet--completing-read-uuid "Visit snippet: " current-prefix-arg))) - (if-let* ((template (+snippet--get-template-by-uuid template-uuid major-mode)) - (template-path (yas--template-load-file template))) - (progn - (unless (file-readable-p template-path) - (user-error "Cannot read %S" template-path)) - (find-file template-path) - (unless (file-in-directory-p template-path +snippets-dir) - (read-only-mode +1) - (setq header-line-format "This is a built-in snippet. Press C-c C-e to modify it" - +snippet--current-snippet-uuid template-uuid))) - (user-error "Cannot find template with UUID %S" template-uuid))) - -;;;###autoload -(defun +snippets/new () - "Create a new snippet in `+snippets-dir'." - (interactive) - (let ((default-directory - (expand-file-name (symbol-name major-mode) - +snippets-dir))) - (+snippet--ensure-dir default-directory) - (with-current-buffer (switch-to-buffer "untitled-snippet") - (snippet-mode) - (erase-buffer) - (yas-expand-snippet (concat "# -*- mode: snippet -*-\n" - "# name: $1\n" - "# uuid: $2\n" - "# key: ${3:trigger-key}${4:\n" - "# condition: t}\n" - "# --\n" - "$0")) - (when (bound-and-true-p evil-local-mode) - (evil-insert-state))))) - -;;;###autoload -(defun +snippets/new-alias (template-uuid) - "Create an alias for a snippet with uuid TEMPLATE-UUID. - -You will be prompted for a snippet to alias." - (interactive - (list - (+snippet--completing-read-uuid "Select snippet to alias: " - current-prefix-arg))) - (unless (require 'doom-snippets nil t) - (user-error "This command requires the `doom-snippets' library bundled with Doom Emacs")) - (let ((default-directory (expand-file-name (symbol-name major-mode) +snippets-dir))) - (+snippet--ensure-dir default-directory) - (with-current-buffer (switch-to-buffer "untitled-snippet") - (snippet-mode) - (erase-buffer) - (yas-expand-snippet - (concat "# -*- mode: snippet -*-\n" - "# name: $1\n" - "# key: ${2:trigger-key}${3:\n" - "# condition: t}\n" - "# type: command\n" - "# --\n" - "(%alias \"${4:" (or template-uuid "uuid") "}\")")) - (when (bound-and-true-p evil-local-mode) - (evil-insert-state))))) - -;;;###autoload -(defun +snippets/edit (template-uuid) - "Edit a snippet with uuid TEMPLATE-UUID. - -If the snippet isn't in `+snippets-dir', it will be copied there (where it will -shadow the default snippet)." - (interactive - (list - (+snippet--completing-read-uuid "Select snippet to edit: " - current-prefix-arg))) - (if-let* ((major-mode (if (eq major-mode 'snippet-mode) - (intern (file-name-base (directory-file-name default-directory))) - major-mode)) - (template (+snippet--get-template-by-uuid template-uuid major-mode)) - (template-path (yas--template-load-file template))) - (if (file-in-directory-p template-path +snippets-dir) - (find-file template-path) - (let ((buf (get-buffer-create (format "*%s*" (file-name-nondirectory template-path))))) - (with-current-buffer (switch-to-buffer buf) - (insert-file-contents template-path) - (snippet-mode) - (setq default-directory - (expand-file-name (file-name-nondirectory template-path) - (expand-file-name (symbol-name major-mode) - +snippets-dir)))))) - (user-error "Couldn't find a snippet with uuid %S" template-uuid))) - -;;;###autoload -(defun +snippets-show-hints-in-header-line-h () - (setq header-line-format - (substitute-command-keys - (concat "\\[yas-load-snippet-buffer-and-close] to finish, " - "\\[+snippet--abort] to abort, " - "\\[yas-tryout-snippet] to test it")))) - - -;; -;;; Hooks - -;;;###autoload -(defun +snippets-enable-project-modes-h (mode &rest _) - "Automatically enable snippet libraries for project minor modes defined with -`def-project-mode!'." - (if (symbol-value mode) - (yas-activate-extra-mode mode) - (yas-deactivate-extra-mode mode))) - -;;;###autoload -(defun +snippets-read-only-maybe-h () - "Enable `read-only-mode' if snippet is built-in." - (when (file-in-directory-p default-directory doom-local-dir) - (read-only-mode 1) - (message "This is a built-in snippet, enabling read only mode. Use `yas-new-snippet' to redefine snippets"))) - - -;; -;;; Advice - -;;;###autoload -(defun +snippets-expand-on-region-a (fn &optional no-condition) - "Fix off-by-one when expanding snippets on an evil visual region. - -Also strips whitespace out of selection. Also switches to insert mode. If -`evil-local-mode' isn't enabled, or we're not in visual mode, run FN as is." - (if (not (and (bound-and-true-p evil-local-mode) - (evil-visual-state-p))) - (funcall fn no-condition) - ;; Trim whitespace in selected region, so as not to introduce extra - ;; whitespace into `yas-selected-text'. - (evil-visual-select (save-excursion - (goto-char evil-visual-beginning) - (skip-chars-forward " \t") - (point)) - (save-excursion - (goto-char evil-visual-end) - (skip-chars-backward " \t") - (point)) - 'inclusive) - (letf! ((defun region-beginning () evil-visual-beginning) - (defun region-end () evil-visual-end)) - (funcall fn no-condition))) - (when (and (bound-and-true-p evil-local-mode) - (not (or (evil-emacs-state-p) - (evil-insert-state-p))) - (yas-active-snippets)) - (evil-insert-state +1))) diff --git a/.config/emacs/modules/editor/snippets/config.el b/.config/emacs/modules/editor/snippets/config.el @@ -1,134 +0,0 @@ -;;; editor/snippets/config.el -*- lexical-binding: t; -*- - -(defvar +snippets-dir (expand-file-name "snippets/" doom-user-dir) - "Directory where `yasnippet' will search for your private snippets.") - - -;; -;;; Packages - -(use-package! yasnippet - :defer-incrementally eldoc easymenu help-mode - :commands (yas-minor-mode-on - yas-expand - yas-expand-snippet - yas-lookup-snippet - yas-insert-snippet - yas-new-snippet - yas-visit-snippet-file - yas-activate-extra-mode - yas-deactivate-extra-mode - yas-maybe-expand-abbrev-key-filter) - :init - ;; Reduce default verbosity. 3 is too chatty about initializing yasnippet. 2 - ;; is just right (only shows errors). - (defvar yas-verbosity 2) - - ;; Remove default ~/.emacs.d/snippets - (defvar yas-snippet-dirs nil) - - ;; Lazy load yasnippet until it is needed - (add-transient-hook! #'company-yasnippet (require 'yasnippet)) - - :config - (add-to-list 'doom-debug-variables '(yas-verbosity . 3)) - - ;; Allow private snippets in DOOMDIR/snippets - (add-to-list 'yas-snippet-dirs '+snippets-dir) - - ;; default snippets library, if available - (add-to-list 'load-path +snippets-dir) - (require 'doom-snippets nil t) - - ;; HACK In case `+snippets-dir' and `doom-snippets-dir' are the same, or - ;; duplicates exist in `yas-snippet-dirs'. - (advice-add #'yas-snippet-dirs :filter-return #'delete-dups) - - ;; Remove GUI dropdown prompt (prefer ivy/helm) - (delq! 'yas-dropdown-prompt yas-prompt-functions) - ;; Prioritize private snippets in `+snippets-dir' over built-in ones if there - ;; are multiple choices. - (add-to-list 'yas-prompt-functions #'+snippets-prompt-private) - - ;; Register `def-project-mode!' modes with yasnippet. This enables project - ;; specific snippet libraries (e.g. for Laravel, React or Jekyll projects). - (add-hook 'doom-project-hook #'+snippets-enable-project-modes-h) - - ;; Exit snippets on ESC from normal mode - (add-hook 'doom-escape-hook #'yas-abort-snippet) - - (after! smartparens - ;; tell smartparens overlays not to interfere with yasnippet keybinds - (advice-add #'yas-expand :before #'sp-remove-active-pair-overlay)) - - ;; (Evil only) fix off-by-one issue with line-wise visual selections in - ;; `yas-insert-snippet', and switches to insert mode afterwards. - (advice-add #'yas-insert-snippet :around #'+snippets-expand-on-region-a) - - ;; Show keybind hints in snippet header-line - (add-hook 'snippet-mode-hook #'+snippets-show-hints-in-header-line-h) - ;; Enable `read-only-mode' for built-in snippets (in `doom-local-dir') - (add-hook 'snippet-mode-hook #'+snippets-read-only-maybe-h) - - (map! (:map yas-keymap - "C-e" #'+snippets/goto-end-of-field - "C-a" #'+snippets/goto-start-of-field - [M-right] #'+snippets/goto-end-of-field - [M-left] #'+snippets/goto-start-of-field - [M-backspace] #'+snippets/delete-to-start-of-field - [backspace] #'+snippets/delete-backward-char - [delete] #'+snippets/delete-forward-char-or-field - ;; Replace commands with superior alternatives - :map yas-minor-mode-map - [remap yas-new-snippet] #'+snippets/new - [remap yas-visit-snippet-file] #'+snippets/edit) - (:map snippet-mode-map - "C-c C-k" #'+snippet--abort)) - - ;; REVIEW Fix #2639: For some reason `yas--all-templates' returns duplicates - ;; of some templates. Until I figure out the real cause this fixes it. - (defadvice! +snippets--remove-duplicates-a (templates) - :filter-return #'yas--all-templates - (cl-delete-duplicates templates :test #'equal)) - - ;; HACK Smartparens will interfere with snippets expanded by `hippie-expand`, - ;; so temporarily disable smartparens during snippet expansion. - (after! hippie-exp - (defvar +snippets--smartparens-enabled-p t) - (defvar +snippets--expanding-p nil) - - ;; Is called for all snippet expansions, - (add-hook! 'yas-before-expand-snippet-hook - (defun +snippets--disable-smartparens-before-expand-h () - ;; Remember the initial smartparens state only once, when expanding a - ;; top-level snippet. - (unless +snippets--expanding-p - (setq +snippets--expanding-p t - +snippets--smartparens-enabled-p smartparens-mode)) - (when smartparens-mode - (smartparens-mode -1)))) - - ;; Is called only for the top level snippet, but not for the nested ones. - ;; Hence `+snippets--expanding-p'. - (add-hook! 'yas-after-exit-snippet-hook - (defun +snippets--restore-smartparens-after-expand-h () - (setq +snippets--expanding-p nil) - (when +snippets--smartparens-enabled-p - (smartparens-mode 1))))) - - ;; If in a daemon session, front-load this expensive work: - (yas-global-mode +1)) - - -(use-package! auto-yasnippet - :defer t - :config - (setq aya-persist-snippets-dir +snippets-dir) - (defadvice! +snippets--inhibit-yas-global-mode-a (fn &rest args) - "auto-yasnippet enables `yas-global-mode'. This is obnoxious for folks like -us who use yas-minor-mode and enable yasnippet more selectively. This advice -swaps `yas-global-mode' with `yas-minor-mode'." - :around '(aya-expand aya-open-line) - (letf! ((#'yas-global-mode #'yas-minor-mode) - (yas-global-mode yas-minor-mode)) - (apply fn args)))) diff --git a/.config/emacs/modules/editor/snippets/packages.el b/.config/emacs/modules/editor/snippets/packages.el @@ -1,10 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; editor/snippets/packages.el - -(package! yasnippet :pin "5cbdbf0d2015540c59ed8ee0fcf4788effdf75b6") -(package! auto-yasnippet :pin "6a9e406d0d7f9dfd6dff7647f358cb05a0b1637e") -(package! doom-snippets - :recipe (:host github - :repo "doomemacs/snippets" - :files (:defaults "*")) - :pin "fe4003014ae00b866f117cb193f711fd9d72fd11") diff --git a/.config/emacs/modules/editor/word-wrap/README.org b/.config/emacs/modules/editor/word-wrap/README.org @@ -1,120 +0,0 @@ -#+title: :editor word-wrap -#+subtitle: Soft-wrapping with language-aware indent -#+created: August 25, 2019 -#+since: 21.12.0 (#1709) - -* Description :unfold: -This module adds a minor-mode [[fn:+word-wrap-mode]], which intelligently wraps long -lines in the buffer without modifying the buffer content. - -** Maintainers -- [[doom-user:][@flatwhatson]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:adaptive-wrap]] -- [[doom-package:visual-fill-column]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** Activation -Word wrapping is not enabled by default. - -Wrapping can be toggled in the current buffer with ~M-x +word-wrap-mode~. The -default doom bindings bind this to [[kbd:][SPC t w]] for ~evil~ users. - -To enable wrapping in a specific mode, add it to the appropriate hook in -~$DOOMDIR/config.el~: -#+begin_src emacs-lisp -;; enable word-wrap in C/C++/ObjC/Java -(add-hook 'c-mode-common-hook #'+word-wrap-mode) -#+end_src - -To customize the behaviour in a specific mode: -#+begin_src emacs-lisp -;; use a single indent and wrap at fill-column in json-mode -(add-hook! 'json-mode-hook - (setq-local +word-wrap-extra-indent 'single - +word-wrap-fill-style 'soft) - (+word-wrap-mode +1)) -#+end_src - -To turn on word wrapping (almost) everywhere: -#+begin_src emacs-lisp -;; enable word-wrap (almost) everywhere -(+global-word-wrap-mode +1) -#+end_src - -To disable global word-wrapping in a specific mode: -#+begin_src emacs-lisp -;; disable global word-wrap in emacs-lisp-mode -(add-to-list '+word-wrap-disabled-modes 'emacs-lisp-mode) -#+end_src - -** Settings -Wrapped lines will be indented to match the preceding line. In code buffers, -lines which are not inside a string or comment will have extra indentation as -determined by ~+word-wrap-extra-indent~. The default is to increase the indent -by twice the major-mode indent. - -The ~+word-wrap-extra-indent~ variable supports the following values: -- ~double~: indent by twice the major-mode indentation -- ~single~: indent by the major-mode indentation -- a positive integer: indent by this fixed amount -- a negative integer: dedent by this fixed amount -- ~nil~: no extra indent - -Long lines are wrapped at the window margin by default, however soft-wrapping at -~fill-column~ is supported by setting ~+word-wrap-fill-style~. When set to -~auto~, if ~auto-fill-mode~ is enabled in the buffer, its behavior will not be -affected. This allows hard and soft wrapping methods to co-exist, with -hard-wrapping for new lines and soft-wrapping for existing lines. To disable -hard-wrapping entirely, set ~+word-wrap-fill-style~ to ~soft~. - -This module also includes a global minor-mode ~+global-word-wrap-mode~ to -automatically enable wrapping in most buffers. Wrapping will not be enabled in -buffers whose major mode is marked "special", or are listed in -~+word-wrap-disabled-modes~. - -The ~+word-wrap-text-modes~ variable lists modes which shouldn't have any extra -indentation, regardless of the ~+word-wrap-extra-indent~ setting. This is useful -for modes which are primarily text, such as ~text-mode~ and ~markdown-mode~. - -The ~+word-wrap-visual-modes~ variable lists modes which should only enable -~visual-line-mode~ and not provide any prefix indentation. This is useful for -modes like ~org-mode~ which handle prefix indentation themselves. - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/editor/word-wrap/autoload.el b/.config/emacs/modules/editor/word-wrap/autoload.el @@ -1,107 +0,0 @@ -;;; editor/word-wrap/autoload.el -*- lexical-binding: t; -*- - -(defvar +word-wrap--major-mode-is-visual nil) -(defvar +word-wrap--major-mode-is-text nil) -(defvar +word-wrap--enable-adaptive-wrap-mode nil) -(defvar +word-wrap--enable-visual-line-mode nil) -(defvar +word-wrap--enable-visual-fill-mode nil) -(defvar +word-wrap--disable-auto-fill-mode nil) -(defvar +word-wrap--major-mode-indent-var nil) - -(defvar adaptive-wrap-extra-indent) -(defun +word-wrap--adjust-extra-indent-a (fn beg end) - "Contextually adjust extra word-wrap indentation." - (let ((adaptive-wrap-extra-indent (+word-wrap--calc-extra-indent beg))) - (funcall fn beg end))) - -(defun +word-wrap--calc-extra-indent (p) - "Calculate extra word-wrap indentation at point." - (if (not (or +word-wrap--major-mode-is-text - (doom-point-in-string-or-comment-p p))) - (pcase +word-wrap-extra-indent - ('double - (* 2 (symbol-value +word-wrap--major-mode-indent-var))) - ('single - (symbol-value +word-wrap--major-mode-indent-var)) - ((and (pred integerp) fixed) - fixed) - (_ 0)) - 0)) - -;;;###autoload -(define-minor-mode +word-wrap-mode - "Wrap long lines in the buffer with language-aware indentation. - -This mode configures `adaptive-wrap', `visual-line-mode' and -`visual-fill-column-mode' to wrap long lines without modifying the buffer -content. This is useful when dealing with legacy code which contains -gratuitously long lines, or running emacs on your wrist-phone. - -Wrapped lines will be indented to match the preceding line. In code buffers, -lines which are not inside a string or comment will have additional indentation -according to the configuration of `+word-wrap-extra-indent'. - -Long lines will wrap at the window margin by default, or can optionally be -wrapped at `fill-column' by configuring `+word-wrap-fill-style'." - :init-value nil - (if +word-wrap-mode - (progn - (setq-local - +word-wrap--major-mode-is-visual - (memq major-mode +word-wrap-visual-modes) - +word-wrap--major-mode-is-text - (memq major-mode +word-wrap-text-modes) - +word-wrap--enable-adaptive-wrap-mode - (and (not (bound-and-true-p adaptive-wrap-prefix-mode)) - (not +word-wrap--major-mode-is-visual)) - +word-wrap--enable-visual-line-mode - (not (bound-and-true-p visual-line-mode)) - +word-wrap--enable-visual-fill-mode - (and (not (bound-and-true-p visual-fill-column-mode)) - (memq +word-wrap-fill-style '(auto soft))) - +word-wrap--disable-auto-fill-mode - (and (bound-and-true-p auto-fill-function) - (eq +word-wrap-fill-style 'soft))) - - (unless +word-wrap--major-mode-is-visual - (require 'dtrt-indent) ; for dtrt-indent--search-hook-mapping - (setq-local +word-wrap--major-mode-indent-var - (caddr (dtrt-indent--search-hook-mapping major-mode))) - - (advice-add #'adaptive-wrap-fill-context-prefix :around #'+word-wrap--adjust-extra-indent-a)) - - (when +word-wrap--enable-adaptive-wrap-mode - (adaptive-wrap-prefix-mode +1)) - (when +word-wrap--enable-visual-line-mode - (visual-line-mode +1)) - (when +word-wrap--enable-visual-fill-mode - (visual-fill-column-mode +1)) - (when +word-wrap--disable-auto-fill-mode - (auto-fill-mode -1))) - - ;; disable +word-wrap-mode - (unless +word-wrap--major-mode-is-visual - (advice-remove #'adaptive-wrap-fill-context-prefix #'+word-wrap--adjust-extra-indent-a)) - - (when +word-wrap--enable-adaptive-wrap-mode - (adaptive-wrap-prefix-mode -1)) - (when +word-wrap--enable-visual-line-mode - (visual-line-mode -1)) - (when +word-wrap--enable-visual-fill-mode - (visual-fill-column-mode -1)) - (when +word-wrap--disable-auto-fill-mode - (auto-fill-mode +1)))) - -(defun +word-wrap--enable-global-mode () - "Enable `+word-wrap-mode' for `+word-wrap-global-mode'. - -Wrapping will be automatically enabled in all modes except special modes, or -modes explicitly listed in `+word-wrap-disabled-modes'." - (unless (or (eq (get major-mode 'mode-class) 'special) - (memq major-mode +word-wrap-disabled-modes)) - (+word-wrap-mode +1))) - -;;;###autoload -(define-globalized-minor-mode +global-word-wrap-mode - +word-wrap-mode - +word-wrap--enable-global-mode) diff --git a/.config/emacs/modules/editor/word-wrap/config.el b/.config/emacs/modules/editor/word-wrap/config.el @@ -1,42 +0,0 @@ -;;; editor/word-wrap/config.el -*- lexical-binding: t; -*- - -(defvar +word-wrap-extra-indent 'double - "The amount of extra indentation for wrapped code lines. - -When 'double, indent by twice the major-mode indentation. -When 'single, indent by the major-mode indentation. -When a positive integer, indent by this fixed amount. -When a negative integer, dedent by this fixed amount. - -Otherwise no extra indentation will be used.") - -(defvar +word-wrap-fill-style nil - "How to handle `fill-column' in `+word-wrap-mode'. - -When 'auto, long lines will soft-wrap at `fill-column'. If `auto-fill-mode' is -enabled, its behaviour will not be affected. - -When 'soft, long lines will soft-wrap at `fill-column' and `auto-fill-mode' will -be forcibly disabled. - -Otherwise long lines will soft-wrap at the window margin and `auto-fill-mode' -will not be affected.") - -(defvar +word-wrap-disabled-modes - '(fundamental-mode so-long-mode) - "Major-modes where `+global-word-wrap-mode' should not enable -`+word-wrap-mode'.") - -(defvar +word-wrap-visual-modes - '(org-mode) - "Major-modes where `+word-wrap-mode' should not use -`adaptive-wrap-prefix-mode'.") - -(defvar +word-wrap-text-modes - '(text-mode markdown-mode markdown-view-mode gfm-mode gfm-view-mode rst-mode - latex-mode LaTeX-mode) - "Major-modes where `+word-wrap-mode' should not provide extra indentation.") - -(when (memq 'visual-line-mode text-mode-hook) - (remove-hook 'text-mode-hook #'visual-line-mode) - (add-hook 'text-mode-hook #'+word-wrap-mode)) diff --git a/.config/emacs/modules/editor/word-wrap/packages.el b/.config/emacs/modules/editor/word-wrap/packages.el @@ -1,5 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; editor/word-wrap/packages.el - -(package! adaptive-wrap :pin "0d5b4a07de76d87dd64333a566a8a0a845f2b9f0") -(package! visual-fill-column :pin "695a59789209c42fa08a5bce92963ee32f4455be") diff --git a/.config/emacs/modules/emacs/README.org b/.config/emacs/modules/emacs/README.org @@ -1,9 +0,0 @@ -#+title: :emacs -#+created: August 01, 2021 -#+since: 21.12.0 - -* Description -Modules in this category augment and extend the built-in features of Emacs. - -* Frequently asked questions -/This category has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] diff --git a/.config/emacs/modules/emacs/dired/README.org b/.config/emacs/modules/emacs/dired/README.org @@ -1,74 +0,0 @@ -#+title: :emacs dired -#+subtitle: Making dired pretty [functional] -#+created: February 20, 2017 -#+since: 2.0.0 - -* Description :unfold: -This module provides reasonable defaults and augmentations for dired. - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +icons :: - Enables the display of fancy icons depending on file types in dired buffers. -- +ranger :: - Enables dired to be more like [[https://github.com/ranger/ranger][ranger]]. - -** Packages -- [[doom-package:all-the-icons-dired]] if [[doom-module:+icons]] -- [[doom-package:diff-hl]] -- [[doom-package:diredfl]] -- [[doom-package:dired-rsync]] -- [[doom-package:fd-dired]] -- [[doom-package:ranger]] if [[doom-module:+ranger]] - -** TODO Hacks -#+begin_quote - 🔨 This module's hacks haven't been documented yet. [[doom-contrib-module:][Document them?]] -#+end_quote - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module has no requirements *except on BSDs* like MacOS or FreeBSD, where -=GNU ls= (aka ~gls~) is required. - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -| Keybind | Description | -|---------+----------------------------| -| [[kbd:][SPC f d]] | Find directory with dired | -| [[kbd:][q]] | Exit dired buffer | -| [[kbd:][C-c C-r]] | Run [[doom-package:dired-rsync]] | -| [[kbd:][C-c C-e]] | Rename entries with [[doom-package:wdired]] | - -Other keybindings can be found on the official [[https://www.gnu.org/software/emacs/refcards/pdf/dired-ref.pdf][Dired reference card]]. - -** Ranger -If [[doom-module:+ranger]] is enabled often a buffer will be opened in minimal ranger mode -(~deer-mode~). In this case [[kbd:][z P]] can be used to toggle between full ranger and -~deer-mode~. - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/emacs/dired/autoload.el b/.config/emacs/modules/emacs/dired/autoload.el @@ -1,15 +0,0 @@ -;;; emacs/dired/autoload.el -*- lexical-binding: t; -*- - -;;;###autoload -(defun +dired/quit-all () - "Kill all `dired-mode' buffers." - (interactive) - (mapc #'kill-buffer (doom-buffers-in-mode 'dired-mode)) - (message "Killed all dired buffers")) - -;;;###autoload -(defun +dired-enable-git-info-h () - "Enable `dired-git-info-mode' in git repos." - (and (not (file-remote-p default-directory)) - (locate-dominating-file "." ".git") - (dired-git-info-mode 1))) diff --git a/.config/emacs/modules/emacs/dired/config.el b/.config/emacs/modules/emacs/dired/config.el @@ -1,247 +0,0 @@ -;;; tools/dired/config.el -*- lexical-binding: t; -*- - -(use-package! dired - :commands dired-jump - :init - (setq dired-dwim-target t ; suggest a target for moving/copying intelligently - dired-hide-details-hide-symlink-targets nil - ;; don't prompt to revert, just do it - dired-auto-revert-buffer #'dired-buffer-stale-p - ;; Always copy/delete recursively - dired-recursive-copies 'always - dired-recursive-deletes 'top - ;; Ask whether destination dirs should get created when copying/removing files. - dired-create-destination-dirs 'ask - ;; Where to store image caches - image-dired-dir (concat doom-cache-dir "image-dired/") - image-dired-db-file (concat image-dired-dir "db.el") - image-dired-gallery-dir (concat image-dired-dir "gallery/") - image-dired-temp-image-file (concat image-dired-dir "temp-image") - image-dired-temp-rotate-image-file (concat image-dired-dir "temp-rotate-image") - ;; Screens are larger nowadays, we can afford slightly larger thumbnails - image-dired-thumb-size 150) - :config - (set-popup-rule! "^\\*image-dired" - :slot 20 :size 0.8 :select t :quit nil :ttl 0) - (set-evil-initial-state! 'image-dired-display-image-mode 'emacs) - - (let ((args (list "-ahl" "-v" "--group-directories-first"))) - (when IS-BSD - ;; Use GNU ls as `gls' from `coreutils' if available. Add `(setq - ;; dired-use-ls-dired nil)' to your config to suppress the Dired warning - ;; when not using GNU ls. - (if-let (gls (executable-find "gls")) - (setq insert-directory-program gls) - ;; BSD ls doesn't support -v or --group-directories-first - (setq args (list (car args))))) - (setq dired-listing-switches (string-join args " ")) - - (add-hook! 'dired-mode-hook - (defun +dired-disable-gnu-ls-flags-maybe-h () - "Remove extraneous switches from `dired-actual-switches' when it's -uncertain that they are supported (e.g. over TRAMP or on Windows). - -Fixes #1703: dired over TRAMP displays a blank screen. -Fixes #3939: unsortable dired entries on Windows." - (when (or (file-remote-p default-directory) - (and (boundp 'ls-lisp-use-insert-directory-program) - (not ls-lisp-use-insert-directory-program))) - (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) - - (defadvice! +dired--no-revert-in-virtual-buffers-a (&rest args) - "Don't auto-revert in dired-virtual buffers (see `dired-virtual-revert')." - :before-while #'dired-buffer-stale-p - (not (eq revert-buffer-function #'dired-virtual-revert))) - - (map! :map dired-mode-map - ;; Kill all dired buffers on q - :ng "q" #'+dired/quit-all - ;; To be consistent with ivy/helm+wgrep integration - "C-c C-e" #'wdired-change-to-wdired-mode)) - - -(use-package! dired-rsync - :general (dired-mode-map "C-c C-r" #'dired-rsync)) - - -(use-package! diredfl - :hook (dired-mode . diredfl-mode)) - - -(use-package! ranger - :when (modulep! +ranger) - :after dired - :init (setq ranger-override-dired t) - :config - (unless (file-directory-p image-dired-dir) - (make-directory image-dired-dir)) - - (set-popup-rule! "^\\*ranger" :ignore t) - - (defadvice! +dired--cleanup-header-line-a () - "Ranger fails to clean up `header-line-format' when it is closed, so..." - :before #'ranger-revert - (dolist (buffer (buffer-list)) - (when (buffer-live-p buffer) - (with-current-buffer buffer - (when (equal header-line-format '(:eval (ranger-header-line))) - (setq header-line-format nil)))))) - - (defadvice! +dired--cleanup-mouse1-bind-a () - "Ranger binds an anonymous function to mouse-1 after previewing a buffer -that prevents the user from escaping the window with the mouse. This command is -never cleaned up if the buffer already existed before ranger was initialized, so -we have to clean it up ourselves." - :after #'ranger-setup-preview - (when (window-live-p ranger-preview-window) - (with-current-buffer (window-buffer ranger-preview-window) - (local-unset-key [mouse-1])))) - - (defadvice! +dired--ranger-travel-a () - "Temporary fix for this function until ralesi/ranger.el#236 gets merged." - :override #'ranger-travel - (interactive) - (let ((prompt "Travel: ")) - (cond - ((bound-and-true-p helm-mode) - (ranger-find-file (helm-read-file-name prompt))) - ((bound-and-true-p ivy-mode) - (ivy-read prompt 'read-file-name-internal - :matcher #'counsel--find-file-matcher - :action - (lambda (x) - (with-ivy-window - (ranger-find-file (expand-file-name x default-directory)))))) - ((bound-and-true-p ido-mode) - (ranger-find-file (ido-read-file-name prompt))) - (t - (ranger-find-file (read-file-name prompt)))))) - - (setq ranger-cleanup-on-disable t - ranger-excluded-extensions '("mkv" "iso" "mp4") - ranger-deer-show-details t - ranger-max-preview-size 10 - ranger-show-literal nil - ranger-hide-cursor nil)) - - -(use-package! dirvish - :when (modulep! +dirvish) - :defer t - :init (after! dired (dirvish-override-dired-mode)) - :hook (dired-mode . dired-omit-mode) - :config - (setq dirvish-cache-dir (concat doom-cache-dir "dirvish/") - dirvish-hide-details nil - dirvish-attributes '(git-msg) - dired-omit-files (concat dired-omit-files "\\|^\\..*$")) - (when (modulep! +icons) - (push 'all-the-icons dirvish-attributes)) - (map! :map dirvish-mode-map - :n "b" #'dirvish-goto-bookmark - :n "z" #'dirvish-show-history - :n "f" #'dirvish-file-info-menu - :n "F" #'dirvish-toggle-fullscreen - :n "l" #'dired-find-file - :n "h" #'dired-up-directory - :localleader - "h" #'dired-omit-mode)) - - -(use-package! all-the-icons-dired - :when (modulep! +icons) - :unless (modulep! +dirvish) - :hook (dired-mode . all-the-icons-dired-mode) - :config - ;; HACK Fixes #1929: icons break file renaming in Emacs 27+, because the icon - ;; is considered part of the filename, so we disable icons while we're in - ;; wdired-mode. - (defvar +wdired-icons-enabled -1) - - ;; display icons with colors - (setq all-the-icons-dired-monochrome nil) - - (defadvice! +dired-disable-icons-in-wdired-mode-a (&rest _) - :before #'wdired-change-to-wdired-mode - (setq-local +wdired-icons-enabled (if all-the-icons-dired-mode 1 -1)) - (when all-the-icons-dired-mode - (all-the-icons-dired-mode -1))) - - (defadvice! +dired-restore-icons-after-wdired-mode-a (&rest _) - :after #'wdired-change-to-dired-mode - (all-the-icons-dired-mode +wdired-icons-enabled))) - - -(use-package! dired-x - :unless (modulep! +dirvish) - :unless (modulep! +ranger) - :hook (dired-mode . dired-omit-mode) - :config - (setq dired-omit-verbose nil - dired-omit-files - (concat dired-omit-files - "\\|^\\.DS_Store\\'" - "\\|^\\.project\\(?:ile\\)?\\'" - "\\|^\\.\\(?:svn\\|git\\)\\'" - "\\|^\\.ccls-cache\\'" - "\\|\\(?:\\.js\\)?\\.meta\\'" - "\\|\\.\\(?:elc\\|o\\|pyo\\|swp\\|class\\)\\'")) - ;; Disable the prompt about whether I want to kill the Dired buffer for a - ;; deleted directory. Of course I do! - (setq dired-clean-confirm-killing-deleted-buffers nil) - ;; Let OS decide how to open certain files - (when-let (cmd (cond (IS-MAC "open") - (IS-LINUX "xdg-open") - (IS-WINDOWS "start"))) - (setq dired-guess-shell-alist-user - `(("\\.\\(?:docx\\|pdf\\|djvu\\|eps\\)\\'" ,cmd) - ("\\.\\(?:jpe?g\\|png\\|gif\\|xpm\\)\\'" ,cmd) - ("\\.\\(?:xcf\\)\\'" ,cmd) - ("\\.csv\\'" ,cmd) - ("\\.tex\\'" ,cmd) - ("\\.\\(?:mp4\\|mkv\\|avi\\|flv\\|rm\\|rmvb\\|ogv\\)\\(?:\\.part\\)?\\'" ,cmd) - ("\\.\\(?:mp3\\|flac\\)\\'" ,cmd) - ("\\.html?\\'" ,cmd) - ("\\.md\\'" ,cmd)))) - (map! :map dired-mode-map - :localleader - "h" #'dired-omit-mode)) - - -(use-package! fd-dired - :when doom-projectile-fd-binary - :defer t - :init - (global-set-key [remap find-dired] #'fd-dired) - (set-popup-rule! "^\\*F\\(?:d\\|ind\\)\\*$" :ignore t)) - -(use-package! dired-aux - :defer t - :config - (setq dired-create-destination-dirs 'ask - dired-vc-rename-file t)) - -;;;###package dired-git-info -(map! :after dired - :map (dired-mode-map ranger-mode-map) - :ng ")" #'dired-git-info-mode) -(setq dgi-commit-message-format "%h %cs %s" - dgi-auto-hide-details-p nil) -(after! wdired - ;; Temporarily disable `dired-git-info-mode' when entering wdired, due to - ;; reported incompatibilities. - (defvar +dired--git-info-p nil) - (defadvice! +dired--disable-git-info-a (&rest _) - :before #'wdired-change-to-wdired-mode - (setq +dired--git-info-p (bound-and-true-p dired-git-info-mode)) - (when +dired--git-info-p - (dired-git-info-mode -1))) - (defadvice! +dired--reactivate-git-info-a (&rest _) - :after '(wdired-exit - wdired-abort-changes - wdired-finish-edit) - (when +dired--git-info-p - (dired-git-info-mode +1)))) diff --git a/.config/emacs/modules/emacs/dired/doctor.el b/.config/emacs/modules/emacs/dired/doctor.el @@ -1,4 +0,0 @@ -;;; emacs/dired/doctor.el -*- lexical-binding: t; -*- - -(when (and IS-BSD (not (executable-find "gls"))) - (warn! "Cannot find gls (GNU ls). This may cause issues with dired")) diff --git a/.config/emacs/modules/emacs/dired/packages.el b/.config/emacs/modules/emacs/dired/packages.el @@ -1,14 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; emacs/dired/packages.el - -(package! diredfl :pin "f9140b2c42151dca669003d685c9f079b2e3dc37") -(package! dired-git-info :pin "9461476a28a5fec0784260f6e318237c662c3430") -(package! dired-rsync :pin "7940d9154d0a908693999b0e1ea351a6d365c93d") -(when (modulep! +ranger) - (package! ranger :pin "2498519cb21dcd5791d240607a72a204d1761668")) -(when (modulep! +dirvish) - (package! dirvish :pin "4fe9c00894304e99aca22ae4b6b656fe94b8f927")) -(when (and (modulep! +icons) - (not (modulep! +dirvish))) - (package! all-the-icons-dired :pin "5e9b097f9950cc9f86de922b07903a4e5fefc733")) -(package! fd-dired :pin "458464771bb220b6eb87ccfd4c985c436e57dc7e") diff --git a/.config/emacs/modules/emacs/electric/README.org b/.config/emacs/modules/emacs/electric/README.org @@ -1,54 +0,0 @@ -#+title: :emacs electric -#+subtitle: Shocking keyword-based electric-indent -#+created: February 21, 2017 -#+since: 2.0.0 - -* Description :unfold: -This module augments the built-in [[doom-package:electric]] package with keyword-based -indentation (as opposed to character-based). - -** Maintainers -- [[doom-user:][@hlissner]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -/This module doesn't install any packages./ - -** TODO Hacks -#+begin_quote - 🔨 This module's hacks haven't been documented yet. [[doom-contrib-module:][Document them?]] -#+end_quote - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* TODO Usage -#+begin_quote -🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote -🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote -🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/emacs/electric/autoload.el b/.config/emacs/modules/emacs/electric/autoload.el @@ -1,26 +0,0 @@ -;;; emacs/electric/autoload.el -*- lexical-binding: t; -*- - -;;;###autodef -(defun set-electric! (modes &rest plist) - "Declare that WORDS (list of strings) or CHARS (lists of chars) should trigger -electric indentation. - -Enables `electric-indent-local-mode' in MODES. - -\(fn MODES &key WORDS CHARS)" - (declare (indent defun)) - (dolist (mode (ensure-list modes)) - (let ((hook (intern (format "%s-hook" mode))) - (fn (intern (format "+electric--init-%s-h" mode)))) - (cond ((null (car-safe plist)) - (remove-hook hook fn) - (unintern fn nil)) - ((fset - fn (lambda () - (when (eq major-mode mode) - (setq-local electric-indent-inhibit nil) - (cl-destructuring-bind (&key chars words) plist - (electric-indent-local-mode +1) - (if chars (setq-local electric-indent-chars chars)) - (if words (setq +electric-indent-words words)))))) - (add-hook hook fn)))))) diff --git a/.config/emacs/modules/emacs/electric/config.el b/.config/emacs/modules/emacs/electric/config.el @@ -1,18 +0,0 @@ -;;; emacs/electric/config.el -*- lexical-binding: t; -*- - -;; Smarter, keyword-based electric-indent - -(defvar-local +electric-indent-words '() - "The list of electric words. Typing these will trigger reindentation of the -current line.") - -;; -(after! electric - (setq-default electric-indent-chars '(?\n ?\^?)) - - (add-hook! 'electric-indent-functions - (defun +electric-indent-char-fn (_c) - (when (and (eolp) +electric-indent-words) - (save-excursion - (backward-word) - (looking-at-p (concat "\\<" (regexp-opt +electric-indent-words)))))))) diff --git a/.config/emacs/modules/emacs/ibuffer/README.org b/.config/emacs/modules/emacs/ibuffer/README.org @@ -1,57 +0,0 @@ -#+title: :emacs ibuffer -#+subtitle: Edit me like one of your French buffers -#+created: October 20, 2019 -#+since: 21.12.0 - -* Description :unfold: -This module augments the built-in [[doom-package:ibuffer]] package. - -- Adds project-based grouping of buffers -- Support for file-type icons -- Uses human-readable file-size - -** Maintainers -*This module needs a maintainer.* [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +icons :: - Enable filetype icons for buffers using [[doom-package:all-the-icons]]. - -** Packages -- [[doom-package:ibuffer-projectile]] -- [[doom-package:ibuffer-vc]] - -** TODO Hacks -#+begin_quote - 🔨 This module's hacks haven't been documented yet. [[doom-contrib-module:][Document them?]] -#+end_quote - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/emacs/ibuffer/autoload/workspaces.el b/.config/emacs/modules/emacs/ibuffer/autoload/workspaces.el @@ -1,34 +0,0 @@ -;;; emacs/ibuffer/autoload/workspaces.el -*- lexical-binding: t; -*- -;;;###if (modulep! :ui workspaces) - -;;;###autoload -(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))))) - -;;;###autoload -(defun +ibuffer/open-for-current-workspace () - "Open an ibuffer window for the current workspace" - (interactive) - (+ibuffer-workspace (+workspace-current-name))) - -;;;###autoload -(defun +ibuffer/visit-workspace-buffer (&optional select-first) - "Visit buffer, but switch to its workspace if it exists." - (interactive "P") - (let ((buf (ibuffer-current-buffer t))) - (unless (buffer-live-p buf) - (user-error "Not a valid or live buffer: %s" buf)) - (if-let (workspaces - (cl-loop for wk in (+workspace-list) - if (+workspace-contains-buffer-p buf wk) - collect wk)) - (+workspace-switch - (if (and (not select-first) (cdr workspaces)) - (or (completing-read "Select workspace: " (mapcar #'persp-name workspaces)) - (user-error "Aborted")) - (persp-name (car workspaces)))) - ;; Or add the buffer to the current workspace - (persp-add-buffer buf)) - (switch-to-buffer buf))) diff --git a/.config/emacs/modules/emacs/ibuffer/config.el b/.config/emacs/modules/emacs/ibuffer/config.el @@ -1,80 +0,0 @@ -;;; emacs/ibuffer/config.el -*- lexical-binding: t; -*- - -(after! ibuffer - (set-popup-rule! "^\\*Ibuffer\\*$" :ignore t) - - (setq ibuffer-show-empty-filter-groups nil - ibuffer-filter-group-name-face '(:inherit (success bold)) - ibuffer-formats - `((mark modified read-only locked - ,@(if (modulep! +icons) - `(;; Here you may adjust by replacing :right with :center - ;; or :left According to taste, if you want the icon - ;; further from the name - " " (icon 2 2 :left :elide) - ,(propertize " " 'display `(space :align-to 8))) - '(" ")) - (name 18 18 :left :elide) - " " (size 9 -1 :right) - " " (mode 16 16 :left :elide) - ,@(when (require 'ibuffer-vc nil t) - '(" " (vc-status 12 :left))) - " " filename-and-process) - (mark " " (name 16 -1) " " filename))) - - ;; Display buffer icons on GUI - (define-ibuffer-column icon (:name " ") - (let ((icon (if (and (buffer-file-name) - (all-the-icons-auto-mode-match?)) - (all-the-icons-icon-for-file (file-name-nondirectory (buffer-file-name)) :v-adjust -0.05) - (all-the-icons-icon-for-mode major-mode :v-adjust -0.05)))) - (if (symbolp icon) - (setq icon (all-the-icons-faicon "file-o" :face 'all-the-icons-dsilver :height 0.8 :v-adjust 0.0)) - icon))) - - ;; Redefine size column to display human readable size - (define-ibuffer-column size - (:name "Size" - :inline t - :header-mouse-map ibuffer-size-header-map) - (file-size-human-readable (buffer-size))) - - (when (modulep! :ui workspaces) - (define-ibuffer-filter workspace-buffers - "Filter for workspace buffers" - (:reader (+workspace-get (read-string "workspace name: ")) - :description "workspace") - (memq buf (+workspace-buffer-list qualifier))) - - (define-key ibuffer-mode-map [remap ibuffer-visit-buffer] #'+ibuffer/visit-workspace-buffer)) - - (when (modulep! :completion ivy) - (defadvice! +ibuffer--use-counsel-maybe-a (_file &optional _wildcards) - "Use `counsel-find-file' instead of `find-file'." - :override #'ibuffer-find-file - (interactive - (let* ((buf (ibuffer-current-buffer)) - (default-directory (if (buffer-live-p buf) - (with-current-buffer buf - default-directory) - default-directory))) - (list (counsel--find-file-1 "Find file: " nil - #'identity - 'counsel-find-file) t))) - (find-file _file _wildcards))) - - (map! :map ibuffer-mode-map :n "q" #'kill-current-buffer)) - - -(use-package! ibuffer-projectile - ;; Group ibuffer's list by project root - :hook (ibuffer . ibuffer-projectile-set-filter-groups) - :config - (setq ibuffer-projectile-prefix - (if (modulep! +icons) - (concat (all-the-icons-octicon - "file-directory" - :face ibuffer-filter-group-name-face - :v-adjust -0.05) - " ") - "Project: "))) diff --git a/.config/emacs/modules/emacs/ibuffer/packages.el b/.config/emacs/modules/emacs/ibuffer/packages.el @@ -1,5 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; emacs/ibuffer/packages.el - -(package! ibuffer-projectile :pin "ecbe482804a217b1471593f6c7a8b3d64f3cdc47") -(package! ibuffer-vc :pin "9204001d1c5ca39409485c1574fd315b0e137a92") diff --git a/.config/emacs/modules/emacs/undo/README.org b/.config/emacs/modules/emacs/undo/README.org @@ -1,84 +0,0 @@ -#+title: :emacs undo -#+subtitle: Persistent, smarter undo for your inevitable mistakes -#+created: April 14, 2020 -#+since: 21.12.0 - -* Description :unfold: -This module augments Emacs' built-in undo system to be more intuitive and to -persist across Emacs sessions. - -** Maintainers -- [[doom-user:][@hlissner]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +tree :: - Uses [[doom-package:undo-tree]] instead of [[doom-package:undo-fu]], which is a little less stable, but offers - branching undo history and a visualizer for navigating it. - -** Packages -- [[doom-package:undo-fu]] -- [[doom-package:undo-fu-session]] -- [[doom-package:undo-tree]] if [[doom-module:+tree]] -- [[doom-package:vundo]] - -** Hacks -- Both undo-fu and undo-tree have been modified to use =zstd= to compress undo - history if it is available. -- undo-tree only - - Text properties are stripped from undo history to shrink it. - - Undo-tree is too chatty about saving its history files. This has be - "silenced". i.e. It's visible in \*Messages\*, but won't appear in your - minibuffer. -- unfo-fu only - - Doom defines ~undo-fu-mode~ to make it easier to add hooks/mode-local - keybinds. - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** Disabling persistent undo history -- If you are using [[doom-module:+tree]]: - #+begin_src emacs-lisp - (after! undo-tree - (setq undo-tree-auto-save-history nil)) - #+end_src - -- If you aren't: - #+begin_src emacs-lisp - (remove-hook 'undo-fu-mode-hook #'global-undo-fu-session-mode) - #+end_src - -* Troubleshooting -[[doom-report:][Report an issue?]] - -** undo-tree -- Has been known to truncate undo history unpredictably, due to Emacs' undo - cleanup imposing linear undo limits on non-linear undo tree data. Doom already - sets ~undo-limit~, ~undo-strong-limit~, and ~undo-outer-limit~ absurdly high - to mitigate this somewhat. - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/emacs/undo/config.el b/.config/emacs/modules/emacs/undo/config.el @@ -1,102 +0,0 @@ -;;; emacs/undo/config.el -*- lexical-binding: t; -*- - -(use-package! undo-fu - :unless (modulep! +tree) - :hook (doom-first-buffer . undo-fu-mode) - :config - ;; Increase undo history limits to reduce likelihood of data loss - (setq undo-limit 400000 ; 400kb (default is 160kb) - undo-strong-limit 3000000 ; 3mb (default is 240kb) - undo-outer-limit 48000000) ; 48mb (default is 24mb) - - (define-minor-mode undo-fu-mode - "Enables `undo-fu' for the current session." - :keymap (let ((map (make-sparse-keymap))) - (define-key map [remap undo] #'undo-fu-only-undo) - (define-key map [remap redo] #'undo-fu-only-redo) - (define-key map (kbd "C-_") #'undo-fu-only-undo) - (define-key map (kbd "M-_") #'undo-fu-only-redo) - (define-key map (kbd "C-M-_") #'undo-fu-only-redo-all) - (define-key map (kbd "C-x r u") #'undo-fu-session-save) - (define-key map (kbd "C-x r U") #'undo-fu-session-recover) - map) - :init-value nil - :global t)) - - -(use-package! undo-fu-session - :unless (modulep! +tree) - :hook (undo-fu-mode . global-undo-fu-session-mode) - :custom (undo-fu-session-directory (concat doom-cache-dir "undo-fu-session/")) - :config - (setq undo-fu-session-incompatible-files '("\\.gpg$" "/COMMIT_EDITMSG\\'" "/git-rebase-todo\\'")) - - (when (executable-find "zstd") - ;; There are other algorithms available, but zstd is the fastest, and speed - ;; is our priority within Emacs - (setq undo-fu-session-compression 'zst)) - - ;; HACK Fix #4993: we've advised `make-backup-file-name-1' to produced SHA1'ed - ;; filenames to prevent file paths that are too long, so we force - ;; `undo-fu-session--make-file-name' to use it instead of its own - ;; home-grown overly-long-filename generator. - ;; TODO PR this upstream; should be a universal issue - (defadvice! +undo-fu-make-hashed-session-file-name-a (file) - :override #'undo-fu-session--make-file-name - (concat (let ((backup-directory-alist `(("." . ,undo-fu-session-directory)))) - (make-backup-file-name-1 file)) - (undo-fu-session--file-name-ext)))) - - -(use-package! vundo - :unless (modulep! +tree) - :defer t - :config - (setq vundo-glyph-alist vundo-unicode-symbols - vundo-compact-display t) - (define-key vundo-mode-map [remap doom/escape] #'vundo-quit)) - - -(use-package! undo-tree - :when (modulep! +tree) - ;; Branching & persistent undo - :hook (doom-first-buffer . global-undo-tree-mode) - :custom (undo-tree-history-directory-alist `(("." . ,(concat doom-cache-dir "undo-tree-hist/")))) - :config - (setq undo-tree-visualizer-diff t - undo-tree-auto-save-history t - undo-tree-enable-undo-in-region t - ;; Increase undo limits to avoid emacs prematurely truncating the undo - ;; history and corrupting the tree. This is larger than the undo-fu - ;; defaults because undo-tree trees consume exponentially more space, - ;; and then some when `undo-tree-enable-undo-in-region' is involved. See - ;; syl20bnr/spacemacs#12110 - undo-limit 800000 ; 800kb (default is 160kb) - undo-strong-limit 12000000 ; 12mb (default is 240kb) - undo-outer-limit 128000000) ; 128mb (default is 24mb) - - ;; Compress undo-tree history files with zstd, if available. File size isn't - ;; the (only) concern here: the file IO barrier is slow for Emacs to cross; - ;; reading a tiny file and piping it in-memory through zstd is *slightly* - ;; faster than Emacs reading the entire undo-tree file from the get go (on - ;; SSDs). Whether or not that's true in practice, we still enjoy zstd's ~80% - ;; file savings (these files add up over time and zstd is so incredibly fast). - (when (executable-find "zstd") - (defadvice! +undo--append-zst-extension-to-file-name-a (file) - :filter-return #'undo-tree-make-history-save-file-name - (concat file ".zst"))) - - ;; Strip text properties from undo-tree data to stave off bloat. File size - ;; isn't the concern here; undo cache files bloat easily, which can cause - ;; freezing, crashes, GC-induced stuttering or delays when opening files. - (defadvice! +undo--strip-text-properties-a (&rest _) - :before #'undo-list-transfer-to-tree - (dolist (item buffer-undo-list) - (and (consp item) - (stringp (car item)) - (setcar item (substring-no-properties (car item)))))) - - ;; Undo-tree is too chatty about saving its history files. This doesn't - ;; totally suppress it logging to *Messages*, it only stops it from appearing - ;; in the echo-area. - (advice-add #'undo-tree-save-history :around #'doom-shut-up-a)) diff --git a/.config/emacs/modules/emacs/undo/packages.el b/.config/emacs/modules/emacs/undo/packages.el @@ -1,9 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; emacs/undo/packages.el - -(if (modulep! +tree) - (package! undo-tree :pin "16f4121032d09ef44b3d7d02c4d02c3c2f18041f") - (package! undo-fu :pin "0e22308de8337a9291ddd589edae167d458fbe77") - (package! undo-fu-session :pin "7b3fd0647dd1fbd02101eec61440e6d44953bcd9") - (when (> emacs-major-version 27) ; unsupported in 27 - (package! vundo :pin "26c929229ae03b8d942907541f0844988b36d0ce"))) diff --git a/.config/emacs/modules/emacs/vc/README.org b/.config/emacs/modules/emacs/vc/README.org @@ -1,60 +0,0 @@ -#+title: :emacs vc -#+subtitle: Be the difference you want to see in the fringe -#+created: February 20, 2017 -#+since: 2.0.0 - -* Description :unfold: -This module augments Emacs builtin version control support and provides better -integration with =git=. - -** Maintainers -- [[doom-user:][@hlissner]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:browse-at-remote]] -- [[doom-package:git-timemachine]] -- [[doom-package:gitconfig-mode]] -- [[doom-package:gitignore-mode]] - -** Hacks -- Allow [[doom-package:browse-at-remote]] commands in [[doom-package:git-timemachine]] buffers to open that file - in your browser at the visited revision. -- [[doom-package:git-timemachine]] buffers will display revision details in the header-line, - rather than the minibuffer (easier to see). -- [[doom-package:browse-at-remote]] will fall back to the =master= branch if target is in a - detached state. - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module only requires [[https://git-scm.com/][Git]]. - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/emacs/vc/autoload/bug-reference-backport.el b/.config/emacs/modules/emacs/vc/autoload/bug-reference-backport.el @@ -1,100 +0,0 @@ -;;; emacs/vc/autoload/bug-reference-backport.el -*- lexical-binding: t; -*- -;;;###if (< emacs-major-version 28) -;; DEPRECATED Remove when Emacs 27.x support is dropped - -;; In Emacs 28, the built-in bug-reference package started consulting vc for -;; repo information (to inform its bug reference URLs). This incredibly useful -;; feature is not available in 27.x yet, so I've backported it: - -(defvar bug-reference-setup-from-vc-alist - `(;; - ;; GNU projects on savannah. - ;; - ;; Not all of them use debbugs but that doesn't really matter - ;; because the auto-setup is only performed if - ;; `bug-reference-url-format' and `bug-reference-bug-regexp' - ;; aren't set already. - ("git\\.\\(?:sv\\|savannah\\)\\.gnu\\.org:" - "\\<\\([Bb]ug ?#?\\)\\([0-9]+\\(?:#[0-9]+\\)?\\)\\>" - ,(lambda (_) "https://debbugs.gnu.org/%s")) - ;; - ;; GitHub projects. - ;; - ;; Here #17 may refer to either an issue or a pull request but - ;; visiting the issue/17 web page will automatically redirect to - ;; the pull/17 page if 17 is a PR. Explicit user/project#17 links - ;; to possibly different projects are also supported. - ("[/@]github.com[/:]\\([.A-Za-z0-9_/-]+\\)\\.git" - "\\([.A-Za-z0-9_/-]+\\)?\\(?:#\\)\\([0-9]+\\)\\>" - ,(lambda (groups) - (let ((ns-project (nth 1 groups))) - (lambda () - (concat "https://github.com/" - (or - ;; Explicit user/proj#18 link. - (match-string 1) - ns-project) - "/issues/" - (match-string 2)))))) - ;; - ;; GitLab projects. - ;; - ;; Here #18 is an issue and !17 is a merge request. Explicit - ;; namespace/project#18 or namespace/project!17 references to - ;; possibly different projects are also supported. - ("[/@]gitlab.com[/:]\\([.A-Za-z0-9_/-]+\\)\\.git" - "\\(?1:[.A-Za-z0-9_/-]+\\)?\\(?3:[#!]\\)\\(?2:[0-9]+\\)\\>" - ,(lambda (groups) - (let ((ns-project (nth 1 groups))) - (lambda () - (concat "https://gitlab.com/" - (or (match-string 1) - ns-project) - "/-/" - (if (string= (match-string 3) "#") - "issues/" - "merge_requests/") - (match-string 2))))))) - "An alist for setting up `bug-reference-mode' based on VC URL. - -Each element has the form (URL-REGEXP BUG-REGEXP URL-FORMAT-FN). - -URL-REGEXP is matched against the version control URL of the -current buffer's file. If it matches, BUG-REGEXP is set as -`bug-reference-bug-regexp'. URL-FORMAT-FN is a function of one -argument that receives a list of the groups 0 to N of matching -URL-REGEXP against the VCS URL and returns the value to be set as -`bug-reference-url-format'.") - -(defun bug-reference--maybe-setup-from-vc (url url-rx bug-rx bug-url-fmt) - (when (string-match url-rx url) - (setq-local bug-reference-bug-regexp bug-rx) - (setq-local bug-reference-url-format - (let (groups) - (dotimes (i (/ (length (match-data)) 2)) - (push (match-string i url) groups)) - (funcall bug-url-fmt (nreverse groups)))))) - -;;;###autoload -(defun bug-reference-try-setup-from-vc () - "Try setting up `bug-reference-mode' based on VC information. -Test each configuration in `bug-reference-setup-from-vc-alist' -and apply it if applicable." - (when (require 'browse-at-remote nil t) - (when-let* ((remote (car (browse-at-remote--get-remotes))) - (url (browse-at-remote--get-remote-url remote))) - (catch 'found - (dolist (config bug-reference-setup-from-vc-alist) - (and (apply #'bug-reference--maybe-setup-from-vc - url config) - (throw 'found t))))))) - -;;;###autoload -(add-hook! '(bug-reference-mode-hook - bug-reference-prog-mode-hook) - (defun +vc-init-bug-reference-from-vc-h () - (when (or bug-reference-mode - bug-reference-prog-mode) - (unless (and bug-reference-bug-regexp - bug-reference-url-format) - (bug-reference-try-setup-from-vc))))) diff --git a/.config/emacs/modules/emacs/vc/autoload/hydra.el b/.config/emacs/modules/emacs/vc/autoload/hydra.el @@ -1,44 +0,0 @@ -;;; emacs/vc/autoload/hydra.el -*- lexical-binding: t; -*- -;;;###if (modulep! :ui hydra) - -;;;###autoload (autoload '+vc/smerge-hydra/body "emacs/vc/autoload/hydra" nil t) -(defhydra +vc/smerge-hydra (:hint nil - :pre (if (not smerge-mode) (smerge-mode 1)) - ;; Disable `smerge-mode' when quitting hydra if - ;; no merge conflicts remain. - :post (smerge-auto-leave)) - " - [smerge] - Movement Keep Diff Other - ╭─────────────────────────────────────────────────────────╯ - ^_g_^ [_b_] base [_<_] upper/base [_C_] Combine - ^_C-k_^ [_u_] upper [_=_] upper/lower [_r_] resolve - ^_k_ ↑^ [_l_] lower [_>_] base/lower [_R_] remove - ^_j_ ↓^ [_a_] all [_H_] hightlight [_n_] next in project - ^_C-j_^ [_RET_] current [_E_] ediff ╭────────── - ^_G_^ │ [_q_] quit -" - ("g" (progn (goto-char (point-min)) (smerge-next))) - ("G" (progn (goto-char (point-max)) (smerge-prev))) - ("C-j" smerge-vc-next-conflict) - ("C-k" smerge-prev) - ("j" next-line) - ("k" previous-line) - ("b" smerge-keep-base) - ("u" smerge-keep-upper) - ("l" smerge-keep-lower) - ("a" smerge-keep-all) - ("RET" smerge-keep-current) - ("\C-m" smerge-keep-current) - ("<" smerge-diff-base-upper) - ("=" smerge-diff-upper-lower) - (">" smerge-diff-base-lower) - ("H" smerge-refine) - ("E" smerge-ediff) - ("C" smerge-combine-with-next) - ("r" smerge-resolve) - ("R" smerge-kill-current) - ;; Often after calling `smerge-vc-next-conflict', the cursor will land at - ;; the bottom of the window - ("n" (progn (smerge-vc-next-conflict) (recenter-top-bottom (/ (window-height) 8)))) - ("q" nil :color blue)) diff --git a/.config/emacs/modules/emacs/vc/autoload/vc.el b/.config/emacs/modules/emacs/vc/autoload/vc.el @@ -1,71 +0,0 @@ -;;; emacs/vc/autoload/vc.el -*- lexical-binding: t; -*- - -;; -;;; Helpers - -(defun +vc--remote-homepage () - (require 'browse-at-remote) - (or (let ((url (browse-at-remote--remote-ref))) - (plist-get (browse-at-remote--get-url-from-remote (car url)) :url)) - (user-error "Can't find homepage for current project"))) - -;; TODO: PR these upstream? -;;;###autoload -(defun browse-at-remote--format-region-url-as-codeberg (repo-url location filename &optional linestart lineend) - "URL formatted for codeberg." - (cond - ((and linestart lineend) - (format "%s/src/%s/%s#L%d-L%d" repo-url location filename linestart lineend)) - (linestart (format "%s/src/%s/%s#L%d" repo-url location filename linestart)) - (t (format "%s/src/%s/%s" repo-url location filename)))) - -;;;###autoload -(defun browse-at-remote--format-commit-url-as-codeberg (repo-url commithash) - "Commit URL formatted for codeberg" - (format "%s/src/commit/%s" repo-url commithash)) - - -;; -;;; Commands - -(defvar browse-at-remote-prefer-symbolic) -;;;###autoload -(defun +vc/browse-at-remote (&optional arg) - "Open URL to current file (and line if selection is active) in browser. -If prefix ARG, negate the default value of `browse-at-remote-prefer-symbolic'." - (interactive "P") - (require 'browse-at-remote) - (let ((vc-ignore-dir-regexp locate-dominating-stop-dir-regexp) - (browse-at-remote-prefer-symbolic - (if arg - (not browse-at-remote-prefer-symbolic) - browse-at-remote-prefer-symbolic))) - (browse-at-remote))) - -;;;###autoload -(defun +vc/browse-at-remote-kill (&optional arg interactive?) - "Copy URL to current file (and line if selection is active) to clipboard. -If prefix ARG, negate the default value of `browse-at-remote-prefer-symbolic'." - (interactive (list current-prefix-arg 'interactive)) - (require 'browse-at-remote) - (let ((vc-ignore-dir-regexp locate-dominating-stop-dir-regexp) - (browse-at-remote-prefer-symbolic - (if arg - (not browse-at-remote-prefer-symbolic) - browse-at-remote-prefer-symbolic))) - (browse-at-remote-kill) - (if interactive? (message "Copied to clipboard")))) - -;;;###autoload -(defun +vc/browse-at-remote-homepage () - "Open homepage for current project in browser." - (interactive) - (browse-url (+vc--remote-homepage))) - -;;;###autoload -(defun +vc/browse-at-remote-kill-homepage () - "Copy homepage URL of current project to clipboard." - (interactive) - (let ((url (+vc--remote-homepage))) - (kill-new url) - (message "Copied to clipboard: %S" url))) diff --git a/.config/emacs/modules/emacs/vc/config.el b/.config/emacs/modules/emacs/vc/config.el @@ -1,146 +0,0 @@ -;;; emacs/vc/config.el -*- lexical-binding: t; -*- - -;; Remove RCS, CVS, SCCS, SRC, and Bzr, because it's a lot less work for vc to -;; check them all (especially in TRAMP buffers), and who uses any of these in -;; 2021, amirite? -(setq-default vc-handled-backends '(SVN Git Hg)) - -(when IS-WINDOWS - (setenv "GIT_ASKPASS" "git-gui--askpass")) - -;; In case the user is using `bug-reference-mode' -(map! :when (fboundp 'bug-reference-mode) - :map bug-reference-map - "RET" (cmds! (and (bound-and-true-p evil-mode) - (evil-normal-state-p)) - #'bug-reference-push-button)) - -(after! log-view - (set-evil-initial-state! - '(log-view-mode - vc-git-log-view-mode - vc-hg-log-view-mode - vc-bzr-log-view-mode - vc-svn-log-view-mode) - 'emacs) - (map! :map log-view-mode-map - "j" #'log-view-msg-next - "k" #'log-view-msg-prev)) - - -(after! vc-annotate - (set-popup-rules! - '(("^\\*vc-diff" :select nil) ; *vc-diff* - ("^\\*vc-change" :select t))) ; *vc-change-log* - (set-evil-initial-state! 'vc-annotate-mode 'normal) - - ;; Clean up after itself - (define-key vc-annotate-mode-map [remap quit-window] #'kill-current-buffer)) - - -(after! vc-dir - (set-evil-initial-state! 'vc-dir-mode 'emacs)) - - -(after! git-timemachine - ;; Sometimes I forget `git-timemachine' is enabled in a buffer, so instead of - ;; showing revision details in the minibuffer, show them in - ;; `header-line-format', which has better visibility. - (setq git-timemachine-show-minibuffer-details t) - - ;; TODO PR this to `git-timemachine' - (defadvice! +vc-support-git-timemachine-a (fn) - "Allow `browse-at-remote' commands in git-timemachine buffers to open that -file in your browser at the visited revision." - :around #'browse-at-remote-get-url - (if git-timemachine-mode - (let* ((start-line (line-number-at-pos (min (region-beginning) (region-end)))) - (end-line (line-number-at-pos (max (region-beginning) (region-end)))) - (remote-ref (browse-at-remote--remote-ref buffer-file-name)) - (remote (car remote-ref)) - (ref (car git-timemachine-revision)) - (relname - (file-relative-name - buffer-file-name (expand-file-name (vc-git-root buffer-file-name)))) - (target-repo (browse-at-remote--get-url-from-remote remote)) - (remote-type (browse-at-remote--get-remote-type target-repo)) - (repo-url (cdr target-repo)) - (url-formatter (browse-at-remote--get-formatter 'region-url remote-type))) - (unless url-formatter - (error (format "Origin repo parsing failed: %s" repo-url))) - (funcall url-formatter repo-url ref relname - (if start-line start-line) - (if (and end-line (not (equal start-line end-line))) end-line))) - (funcall fn))) - - (defadvice! +vc-update-header-line-a (revision) - "Show revision details in the header-line, instead of the minibuffer. - -Sometimes I forget `git-timemachine' is enabled in a buffer. Putting revision -info in the `header-line-format' is a more visible indicator." - :override #'git-timemachine--show-minibuffer-details - (let* ((date-relative (nth 3 revision)) - (date-full (nth 4 revision)) - (author (if git-timemachine-show-author (concat (nth 6 revision) ": ") "")) - (sha-or-subject (if (eq git-timemachine-minibuffer-detail 'commit) (car revision) (nth 5 revision)))) - (setq header-line-format - (format "%s%s [%s (%s)]" - (propertize author 'face 'git-timemachine-minibuffer-author-face) - (propertize sha-or-subject 'face 'git-timemachine-minibuffer-detail-face) - date-full date-relative)))) - - (after! evil - ;; Rehash evil keybindings so they are recognized - (add-hook 'git-timemachine-mode-hook #'evil-normalize-keymaps)) - - (when (modulep! :tools magit) - (add-transient-hook! #'git-timemachine-blame (require 'magit-blame))) - - (map! :map git-timemachine-mode-map - :n "C-p" #'git-timemachine-show-previous-revision - :n "C-n" #'git-timemachine-show-next-revision - :n "gb" #'git-timemachine-blame - :n "gtc" #'git-timemachine-show-commit)) - - -(use-package! git-commit - :hook (doom-first-file . global-git-commit-mode) - :config - (set-yas-minor-mode! 'git-commit-mode) - - ;; Enforce git commit conventions. - ;; See https://chris.beams.io/posts/git-commit/ - (setq git-commit-summary-max-length 50 - git-commit-style-convention-checks '(overlong-summary-line non-empty-second-line)) - (setq-hook! 'git-commit-mode-hook fill-column 72) - - (add-hook! 'git-commit-setup-hook - (defun +vc-start-in-insert-state-maybe-h () - "Start git-commit-mode in insert state if in a blank commit message, -otherwise in default state." - (when (and (bound-and-true-p evil-mode) - (not (evil-emacs-state-p)) - (bobp) (eolp)) - (evil-insert-state))))) - - -(after! browse-at-remote - ;; It's more sensible that the user have more options. If they want line - ;; numbers, users can request them by making a selection first. Otherwise - ;; omitting them. - (setq browse-at-remote-add-line-number-if-no-region-selected nil) - ;; Opt to produce permanent links with `browse-at-remote' by default, - ;; using commit hashes rather than branch names. - (setq browse-at-remote-prefer-symbolic nil) - - ;; Add codeberg.org support - ;; TODO: PR this upstream? - (add-to-list 'browse-at-remote-remote-type-regexps '(:host "^codeberg\\.org$" :type "codeberg")) - - ;; HACK `browse-at-remote' produces urls with `nil' in them, when the repo is - ;; detached. This creates broken links. I think it is more sensible to - ;; fall back to master in those cases. - (defadvice! +vc--fallback-to-master-branch-a () - "Return 'master' in detached state." - :after-until #'browse-at-remote--get-local-branch - "master")) diff --git a/.config/emacs/modules/emacs/vc/packages.el b/.config/emacs/modules/emacs/vc/packages.el @@ -1,14 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; emacs/vc/packages.el - -(package! vc :built-in t) -(package! vc-annotate :built-in t) -(package! smerge-mode :built-in t) - -(package! browse-at-remote :pin "c020975a891438e278ad1855213d4f3d62c9fccb") -(package! git-commit :pin "97a95f70079b6613bf98d2306279d3e03fe51234") -(package! git-timemachine - ;; The original lives on codeberg.org; which has uptime issues. - :recipe (:host github :repo "emacsmirror/git-timemachine") - :pin "d8ffd0d7cc4ab3dd7de494c9ea36dfd99e2744fa") -(package! git-modes :pin "f0a0154bf48dd1c0c587596cf4cfd3c90f673a05") diff --git a/.config/emacs/modules/email/README.org b/.config/emacs/modules/email/README.org @@ -1,9 +0,0 @@ -#+title: :email -#+created: October 14, 2021 -#+since: 21.12.0 - -* Description -Modules that turn Emacs in an email client. - -* Frequently asked questions -/This category has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] diff --git a/.config/emacs/modules/email/mu4e/README.org b/.config/emacs/modules/email/mu4e/README.org @@ -1,316 +0,0 @@ -#+title: :email mu4e -#+subtitle: The great filter Hanson hadn't anticipated -#+created: April 08, 2017 -#+since: 2.0.3 - -* Description :unfold: -This module makes Emacs an email client, using [[https://www.djcbsoftware.nl/code/mu/mu4e.html][mu4e]]. - -- Tidied mu4e headers view, with flags from [[doom-package:all-the-icons]]. -- Consistent coloring of reply depths (across compose and gnus modes). -- Prettified =mu4e:main= view. -- Cooperative locking of the =mu= process. Another Emacs instance may request - access, or grab the lock when it's available. -- [[doom-package:org-msg]] integration with [[doom-module:+org]], which can be toggled per-message, with revamped - style and an accent color. -- Gmail integrations with the [[doom-module:+gmail]] flag. -- Email notifications with [[doom-package:mu4e-alert]], and (on Linux) a customised notification - style. - -#+begin_quote - 💡 I want to live in Emacs, but as we all know, living is incomplete without - email. So I prayed to the text editor gods and they (I) answered. - Emacs+evil's editing combined with org-mode for writing emails? /Yes - please./ - - It uses ~mu4e~ to read my email, but depends on ~offlineimap~ (to sync my - email via IMAP) and ~mu~ (to index my mail into a format ~mu4e~ can - understand). -#+end_quote - -** Maintainers -- [[doom-user:][@tecosaur]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +gmail :: - Enable gmail-specific configuration for mail ~To~ or ~From~ a gmail address, - or a maildir with ~gmail~ in the name. -- +org :: - Use [[doom-package:org-msg]] for composing email in Org, then sending a multipart text (ASCII - export) and HTML message. - -** Packages -- [[doom-package:mu4e-alert]] -- [[doom-package:org-msg]] if [[doom-module:+org]] - -** TODO Hacks -#+begin_quote - 🔨 This module's hacks haven't been documented yet. [[doom-contrib-module:][Document them?]] -#+end_quote - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires: - -- [[https://www.djcbsoftware.nl/code/mu/][mu]], to index your downloaded messages and to provide the [[https://www.djcbsoftware.nl/code/mu/mu4e.html][mu4e]] package. -- A program to sync your mail. This module comes with builtin support for [[https://isync.sourceforge.io/][mbsync]] - (recommended, default) or [[http://www.offlineimap.org/][offlineimap]] but you can sync mail in other ways too. - -#+name: Install Matrix -| Platform | Install command | Base packages | -|---------------+----------------------------+-------------------------| -| MacOS | ~$ brew install <pkgs>~ | =mu= | -| Arch | ~$ pacman -S <pkgs>~ | (AUR, ~$ yay -S~) =mu= | -| openSUSE | ~$ zypper install <pkgs>~ | =maildir-utils=, =mu4e= | -| Fedora | ~$ dnf install <pkgs>~ | =maildir-utils= | -| Debian/Ubuntu | ~$ apt-get install <pkgs>~ | =maildir-utils=, =mu4e= | - -Then install either the =isync= (=mbsync=) or =offlineimap= package. - -To send mail, mu4e uses [[https://www.gnu.org/software/emacs/manual/html_mono/smtpmail.html][smtpmail]] (an Emacs library) by default. You can also run -a local SMTP server like =sendmail= or =postfix=, or use an SMTP forwarder such -as =msmtp= (recommended). - -If you use =msmtp=: -#+begin_src emacs-lisp -;; add to $DOOMDIR/config.el -(after! mu4e - (setq sendmail-program (executable-find "msmtp") - send-mail-function #'smtpmail-send-it - message-sendmail-f-is-evil t - message-sendmail-extra-arguments '("--read-envelope-from") - message-send-mail-function #'message-send-mail-with-sendmail)) -#+end_src - -** NixOS -#+begin_src nix -environment.systemPackages = with pkgs; [ - mu - # And one of the following - isync - offlineimap -]; -#+end_src - -[[https://github.com/Emiller88/dotfiles/blob/5eaabedf1b141c80a8d32e1b496055231476f65e/modules/shell/mail.nix][An example of setting up mbsync and mu with home-manager]] - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** offlineimap -This module uses =mbsync= by default. To use =offlineimap=, change -~+mu4e-backend~: -#+begin_src emacs-lisp -(setq +mu4e-backend 'offlineimap) -#+end_src - -Next, you need to write a configuration file for =offlineimap=. Mine can be -found [[https://github.com/hlissner/dotfiles/blob/be0dce5dae8f3cbafaac0cc44269d84b4a742c46/shell/mu/][in my dotfiles repository]]. It is configured to download mail to -~\~/.mail~. I use [[https://www.passwordstore.org/][unix pass]] to securely store my login credentials. You can find -a *very* detailed configuration [[https://github.com/OfflineIMAP/offlineimap/blob/master/offlineimap.conf][here]]. - -Next you can download your email with ~$ offlineimap -o~. This may take a while, -especially if you have thousands of mails. - -You can now proceed with the [[#mu-and-mu4e][mu and mu4e]] section. - -** mbsync -The steps needed to set up =mu4e= with =mbsync= are very similar to the ones for -[[#offlineimap][offlineimap]]. - -Start with writing a =~/.mbsyncrc=. An example for Gmail can be found on -[[http://pragmaticemacs.com/emacs/migrating-from-offlineimap-to-mbsync-for-mu4e/][pragmaticemacs.com]]. A non-Gmail example is available as a gist [[https://gist.github.com/agraul/60977cc497c3aec44e10591f94f49ef0][here]]. The [[http://isync.sourceforge.net/mbsync.html][manual -page]] contains all needed information to set up your own. - -Next you can download your email with ~$ mbsync --all~. This may take a while, -but should be quicker than =offlineimap= ;). - -You can now proceed with the [[#mu-and-mu4e][mu and mu4e]] section. - -*** Faster syncing -It's possible to use IMAP IDLE to be quickly notified of updates, then use a -tailored =mbsync= command to just fetch the new changes. - -If this is of interest, this approach can be seen [[https://tecosaur.github.io/emacs-config/config.html#fetching][in @tecosaur's config]] where -[[https://gitlab.com/shackra/goimapnotify][goimapnotify]] is used for this. - -** Fetching your mail in other ways -You also have the possiblity to invoke an arbitary shell command to fetch your -mail by disabling this module's backend selection and setting the value of the -~mu4e-get-mail-command~ to the command you want to execute: -#+begin_src emacs-lisp -(setq +mu4e-backend nil) -(after! mu4e - (setq mu4e-get-mail-command "your_command")) -#+end_src - -If your command prompts you for a passphrase, you might want to change the value -of the ~mu4e~get-mail-password-regexp~ variable -(~mu4e--get-mail-password-regexp~ if =mu= *>=1.8*) such that [[doom-package:mu4e]] will recognize -the prompt and let you provide the passphrase from within Emacs. - -** mu and mu4e -You should have your email downloaded already. If you have not, you need to set -=offlineimap= or =mbsync= up before you proceed. - -Before you can use =mu4e= or the CLI program =mu=, you need to index your email -initially. How to do that differs a little depending on the version of =mu= you -use. You can check your version with ~$ mu --version~. - -For =mu= *>=1.4* you need to run two commands: -#+begin_src sh -mu init --maildir ~/.mail --my-address email@example.com -mu index -#+end_src - -=mu= *<1.4* only requires one command: -#+begin_src sh -mu index --maildir $HOME/.mail -#+end_src - -Be sure to replace =$HOME/.mail= with the directory containing your mail. - -Then configure Emacs to use your email address: -#+begin_src emacs-lisp -;; Each path is relative to the path of the maildir you passed to mu -(set-email-account! "bar.com" - '((mu4e-sent-folder . "/bar.com/Sent Mail") - (mu4e-drafts-folder . "/bar.com/Drafts") - (mu4e-trash-folder . "/bar.com/Trash") - (mu4e-refile-folder . "/bar.com/All Mail") - (smtpmail-smtp-user . "foo@bar.com") - (user-mail-address . "foo@bar.com") ;; only needed for mu < 1.4 - (mu4e-compose-signature . "---\nYours truly\nThe Baz")) - t) -#+end_src - -If you use multiple email accounts, defining them with ~set-email-account!~ will -automatically set the appropriate account context when replying to emails in -that account's maildir. ~mu4e-context-policy~ and ~mu4e-compose-context-policy~ -can be modified to change context behavior when opening mu4e and composing -email: -#+begin_src emacs-lisp -(setq mu4e-context-policy 'ask-if-none - mu4e-compose-context-policy 'always-ask) -#+end_src - -If you send mail from various email aliases for different services, -~+mu4e-personal-addresses~ can be set per-context with ~set-email-account!~. If -you are not replying to an email to or from one of the specified aliases, you -will be prompted for an alias to send from. - -*** Gmail -With the [[doom-module:+gmail]] flag, integrations are applied which account for the different -behaviour of Gmail. - -The integrations are applied to addresses with /both/ "@gmail.com" in the -account address and "gmail" in the account maildir, as well as accounts listed -in ~+mu4e-gmail-accounts~. Any domain can be specified, so G Suite accounts can -benefit from the integrations: -#+begin_src emacs-lisp -;; if "gmail" is missing from the address or maildir, the account must be listed here -(setq +mu4e-gmail-accounts '(("hlissner@gmail.com" . "/hlissner") - ("example@example.com" . "/example"))) -#+end_src - -If you only use Gmail, you can improve performance due to the way Gmail presents -messages over IMAP: -#+begin_src emacs-lisp -;; don't need to run cleanup after indexing for gmail -(setq mu4e-index-cleanup nil - ;; because gmail uses labels as folders we can use lazy check since - ;; messages don't really "move" - mu4e-index-lazy-check t) -#+end_src - -Also, note that Gmail's IMAP settings must have "When I mark a message in IMAP -as deleted: Auto-Expunge off - Wait for the client to update the server." and -"When a message is marked as deleted and expunged from the last visible IMAP -folder: Move the message to the trash" for the integrations to work as expected. - -** OrgMsg -With the [[doom-module:+org]] flag, [[doom-package:org-msg]] is installed, and ~org-msg-mode~ is enabled before -composing the first message. To disable ~org-msg-mode~ by default: -#+begin_src emacs-lisp -;; add to $DOOMDIR/config.el -(setq +mu4e-compose-org-msg-toggle-next nil) -#+end_src - -To toggle org-msg for a single message, just apply the universal argument to the -compose or reply command ([[kbd:][SPC u]] with [[doom-package:evil]], [[kbd:][C-u]] otherwise). - -The accent color that Doom uses can be customised by setting -~+org-msg-accent-color~ to a CSS color string. - -** mu4e-alert -This provides notifications through the [[https://github.com/jwiegley/alert][alert]] library. - -If you don't like this use: -#+begin_src emacs-lisp -;; add to $DOOMDIR/packages.el -(package! mu4e-alert :disable t) -#+end_src - -** Enabling automatic email fetching -By default, periodic email update is *disabled*. To enable periodic -mail retrieval/indexing, change the value of ~mu4e-update-interval~: - -#+begin_src emacs-lisp -(setq mu4e-update-interval 60) -#+end_src - -* Troubleshooting -[[doom-report:][Report an issue?]] - -** =No such file or directory, mu4e= -You will get =No such file or directory, mu4e= errors if you don't run ~$ doom -sync~ after installing =mu= through your package manager. - -Some times the the ~mu~ package does not include ~mu4e~ (*cough Ubuntu*). if -that's the case you will need to [[https://github.com/djcb/mu][install]] it and add it to your ~load-path~ you -can do that by: -#+begin_src emacs-lisp -(add-to-list 'load-path "your/path/to/mu4e") -;; if you installed it using your package manager -(add-to-list 'load-path "/usr/share/emacs/site-lisp/mu4e") -;; if you built from source -(add-to-list 'load-path "/usr/local/share/emacs/site-lisp/mu4e") -#+end_src - -If you have completely lost your install then you can use: -#+begin_src sh -find / -type d -iname '*mu4e*' -# I recommend rerouting all of the errors to /dev/null -find / -type d -iname '*mu4e*' 2> /dev/null -#+end_src - -** ~(void-function org-time-add)~ error on Gentoo -Gentoo users will see this error because [[https://gitweb.gentoo.org/repo/gentoo.git/tree/net-mail/mu/files/70mu-gentoo.el#n2][the =net-mail/mu= package eagerly loads -=mu4e= (which pulls in =org=) much too early]]; before Emacs reads =~/.emacs.d=. -So early, that it loads the built-in version of org-mode, rather than the newer -version that Doom installs. - -Later versions of the =net-mail/mu= package have [[https://gitweb.gentoo.org/repo/gentoo.git/commit/net-mail/mu?id=770e1fccb119fbce8ba6d16021a3598123f212ff][fixed this issue]], but you may -need to switch to the unstable build of =net-mail/mu= to see it. - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/email/mu4e/autoload/advice.el b/.config/emacs/modules/email/mu4e/autoload/advice.el @@ -1,132 +0,0 @@ -;;; email/mu4e/autoload/advice.el -*- lexical-binding: t; -*- - -;;;###autoload -(defun +mu4e~main-action-str-prettier-a (str &optional func-or-shortcut) - "Highlight the first occurrence of [.] in STR. -If FUNC-OR-SHORTCUT is non-nil and if it is a function, call it -when STR is clicked (using RET or mouse-2); if FUNC-OR-SHORTCUT is -a string, execute the corresponding keyboard action when it is -clicked." - (let ((newstr - (replace-regexp-in-string - "\\[\\(..?\\)\\]" - (lambda(m) - (format "%s" - (propertize (match-string 1 m) 'face 'mu4e-highlight-face))) - (replace-regexp-in-string "\t\\*" (format "\t%s" +mu4e-main-bullet) str))) - (map (make-sparse-keymap)) - (func (if (functionp func-or-shortcut) - func-or-shortcut - (if (stringp func-or-shortcut) - (lambda()(interactive) - (execute-kbd-macro func-or-shortcut)))))) - (define-key map [mouse-2] func) - (define-key map (kbd "RET") func) - (put-text-property 0 (length newstr) 'keymap map newstr) - (put-text-property (string-match "[A-Za-z].+$" newstr) - (- (length newstr) 1) 'mouse-face 'highlight newstr) - newstr)) - -;;;###autoload -(defun +mu4e~main-keyval-str-prettier-a (str) - "Replace '*' with `+mu4e-main-bullet' in STR." - (replace-regexp-in-string "\t\\*" (format "\t%s" +mu4e-main-bullet) str)) - -;; Org msg LaTeX image scaling - -;;;###autoload -(defun +org-msg-img-scale-css (img-uri) - "For a given IMG-URI, use imagemagick to find its width." - (if +org-msg-currently-exporting - (when (and (not IS-WINDOWS)) ; relies on posix path - (let ((width-call (and (executable-find "identify") - (doom-call-process "identify" "-format" "%w" - (substring img-uri 7))))) ; 7=(length "file://") - (unless width-call - (setq width-call (doom-call-process "file" (substring img-uri 7))) - (setcdr width-call (replace-regexp-in-string "^.*image data, \\([0-9]+\\).*$" "\\1" (cdr width-call))) - (setcar width-call (if (< 0 (string-to-number (cdr width-call))) 0 1))) - (when (= (car width-call) 0) - (list :width - (format "%.1fpx" - (/ (string-to-number (cdr width-call)) - (plist-get org-format-latex-options :scale))))))) - (list :style (format "transform: scale(%.3f)" - (/ 1.0 (plist-get org-format-latex-options :scale)))))) - -;;;###autoload -(defun +org-html-latex-fragment-scaled-a (latex-fragment _contents info) - "Transcode a LATEX-FRAGMENT object from Org to HTML. -CONTENTS is nil. INFO is a plist holding contextual information. - -This differs from `org-html-latex-fragment' in that it uses the LaTeX fragment -as a meaningful alt value, applies a class to indicate what sort of fragment it is -(latex-fragment-inline or latex-fragment-block), and (on Linux) scales the image to -account for the value of :scale in `org-format-latex-options'." - (let ((latex-frag (org-element-property :value latex-fragment)) - (processing-type (plist-get info :with-latex))) - (cond - ((memq processing-type '(t mathjax)) - (org-html-format-latex latex-frag 'mathjax info)) - ((eq processing-type 'html) - (org-html-format-latex latex-frag 'html info)) - ((assq processing-type org-preview-latex-process-alist) - (let ((formula-link - (org-html-format-latex latex-frag processing-type info))) - (when (and formula-link (string-match "file:\\([^]]*\\)" formula-link)) - (let* ((source (org-export-file-uri (match-string 1 formula-link))) - (attributes (append (list :alt latex-frag - :class - (concat "latex-fragment-" - (if (equal "\\(" (substring latex-frag 0 2)) - "inline" "block"))) - (when (memq processing-type '(dvipng convert)) - (+org-msg-img-scale-css source))))) - (org-html--format-image source attributes info))))) - (t latex-frag)))) - -;;;###autoload -(defun +org-html-latex-environment-scaled-a (latex-environment _contents info) - "Transcode a LATEX-ENVIRONMENT element from Org to HTML. -CONTENTS is nil. INFO is a plist holding contextual information. - -This differs from `org-html-latex-environment' in that (on Linux) it -scales the image to account for the value of :scale in `org-format-latex-options'." - (let ((processing-type (plist-get info :with-latex)) - (latex-frag (org-remove-indentation - (org-element-property :value latex-environment))) - (attributes (org-export-read-attribute :attr_html latex-environment)) - (label (and (org-element-property :name latex-environment) - (org-export-get-reference latex-environment info))) - (caption (and (org-html--latex-environment-numbered-p latex-environment) - (number-to-string - (org-export-get-ordinal - latex-environment info nil - (lambda (l _) - (and (org-html--math-environment-p l) - (org-html--latex-environment-numbered-p l)))))))) - (plist-put attributes :class "latex-environment") - (cond - ((memq processing-type '(t mathjax)) - (org-html-format-latex - (if (org-string-nw-p label) - (replace-regexp-in-string "\\`.*" - (format "\\&\n\\\\label{%s}" label) - latex-frag) - latex-frag) - 'mathjax info)) - ((assq processing-type org-preview-latex-process-alist) - (let ((formula-link - (org-html-format-latex - (org-html--unlabel-latex-environment latex-frag) - processing-type info))) - (when (and formula-link (string-match "file:\\([^]]*\\)" formula-link)) - (let ((source (org-export-file-uri (match-string 1 formula-link)))) - (org-html--wrap-latex-environment - (org-html--format-image source - (append attributes - (when (memq processing-type '(dvipng convert)) - (+org-msg-img-scale-css source))) - info) - info caption label))))) - (t (org-html--wrap-latex-environment latex-frag info caption label))))) diff --git a/.config/emacs/modules/email/mu4e/autoload/email.el b/.config/emacs/modules/email/mu4e/autoload/email.el @@ -1,389 +0,0 @@ -;;; email/mu4e/autoload/email.el -*- lexical-binding: t; -*- - -;;;###autodef -(defun set-email-account! (label letvars &optional default-p) - "Registers an email address for mu4e. The LABEL is a string. LETVARS are a -list of cons cells (VARIABLE . VALUE) -- you may want to modify: - - + `user-full-name' (used to populate the FROM field when composing mail) - + `user-mail-address' (required in mu4e < 1.4) - + `smtpmail-smtp-user' (required for sending mail from Emacs) - -OPTIONAL: - + `mu4e-sent-folder' - + `mu4e-drafts-folder' - + `mu4e-trash-folder' - + `mu4e-refile-folder' - + `mu4e-compose-signature' - + `+mu4e-personal-addresses' - -DEFAULT-P is a boolean. If non-nil, it marks that email account as the -default/fallback account." - (after! mu4e - (when (version< mu4e-mu-version "1.4") - (when-let (address (cdr (assq 'user-mail-address letvars))) - (add-to-list 'mu4e-user-mail-address-list address))) - ;; remove existing context with same label - (setq mu4e-contexts - (cl-loop for context in mu4e-contexts - unless (string= (mu4e-context-name context) label) - collect context)) - (let ((context (make-mu4e-context - :name label - :enter-func - (lambda () (mu4e-message "Switched to %s" label)) - :leave-func - (lambda () (progn (setq +mu4e-personal-addresses nil) - (mu4e-clear-caches))) - :match-func - (lambda (msg) - (when msg - (string-prefix-p (format "/%s" label) - (mu4e-message-field msg :maildir) t))) - :vars letvars))) - (add-to-list 'mu4e-contexts context (not default-p)) - context))) - - -(defvar +mu4e-workspace-name "*mu4e*" - "Name of the workspace created by `=mu4e', dedicated to mu4e.") -(defvar +mu4e--old-wconf nil) - -(add-hook 'mu4e-main-mode-hook #'+mu4e-init-h) - -;;;###autoload -(defun =mu4e (&optional background) - "Start email client." - (interactive) - (require 'mu4e) - (if (modulep! :ui workspaces) - ;; delete current workspace if empty - ;; this is useful when mu4e is in the daemon - ;; as otherwise you can accumulate empty workspaces - (progn - (unless (+workspace-buffer-list) - (+workspace-delete (+workspace-current-name))) - (+workspace-switch +mu4e-workspace-name t)) - (setq +mu4e--old-wconf (current-window-configuration)) - (delete-other-windows) - (switch-to-buffer (doom-fallback-buffer))) - ;; At this point, we're going to guess what the user wants to do. - ;; To help with this, we'll collect potentially-useful buffers. - ;; Then we'll try to jump to in order of preference: - ;; 1. A draft message buffer - ;; 2. A viewed message buffer - ;; 3. A headers buffer - ;; If none of those exist and are appropiate to jump to, - ;; `mu4e' will be called. - (let (compose-buffer view-buffer headers-buffer) - (dolist (buf (buffer-list)) - (pcase (buffer-local-value 'major-mode buf) - ((and (or 'org-msg-edit-mode 'mu4e-compose-mode) - (guard (not compose-buffer))) - (setq compose-buffer buf)) - ((and 'mu4e-view-mode (guard (not view-buffer))) - (setq view-buffer buf)) - ((and 'mu4e-headers-mode (guard (not headers-buffer))) - (setq headers-buffer buf)))) - (if (and compose-buffer (not (eq compose-buffer (current-buffer)))) - (switch-to-buffer compose-buffer) - (if (and view-buffer (not (eq view-buffer (current-buffer)))) - (switch-to-buffer view-buffer) - (if (and headers-buffer (not (eq headers-buffer (current-buffer)))) - (switch-to-buffer headers-buffer) - (mu4e background)))))) - -;;;###autoload -(defun +mu4e/compose () - "Compose a new email." - (interactive) - ;; TODO Interactively select email account - (call-interactively #'mu4e-compose-new)) - -(defun +mu4e--get-string-width (str) - "Return the width in pixels of a string in the current -window's default font. If the font is mono-spaced, this -will also be the width of all other printable characters." - (let ((window (selected-window)) - (remapping face-remapping-alist)) - (with-temp-buffer - (make-local-variable 'face-remapping-alist) - (setq face-remapping-alist remapping) - (set-window-buffer window (current-buffer)) - (insert str) - (car (window-text-pixel-size))))) - -(cl-defun +mu4e-normalised-icon (name &key set color height v-adjust) - "Convert :icon declaration to icon" - (let* ((icon-set (intern (concat "all-the-icons-" (or set "faicon")))) - (v-adjust (or v-adjust 0.02)) - (height (or height 0.8)) - (icon (if color - (apply icon-set `(,name :face ,(intern (concat "all-the-icons-" color)) :height ,height :v-adjust ,v-adjust)) - (apply icon-set `(,name :height ,height :v-adjust ,v-adjust)))) - (icon-width (+mu4e--get-string-width icon)) - (space-width (+mu4e--get-string-width " ")) - (space-factor (- 2 (/ (float icon-width) space-width)))) - (concat (propertize " " 'display `(space . (:width ,space-factor))) icon))) - -;; Set up all the fancy icons -;;;###autoload -(defun +mu4e-initialise-icons () - (setq mu4e-use-fancy-chars t - mu4e-headers-draft-mark (cons "D" (+mu4e-normalised-icon "pencil")) - mu4e-headers-flagged-mark (cons "F" (+mu4e-normalised-icon "flag")) - mu4e-headers-new-mark (cons "N" (+mu4e-normalised-icon "sync" :set "material" :height 0.8 :v-adjust -0.10)) - mu4e-headers-passed-mark (cons "P" (+mu4e-normalised-icon "arrow-right")) - mu4e-headers-replied-mark (cons "R" (+mu4e-normalised-icon "reply")) - mu4e-headers-seen-mark (cons "S" "") ;(+mu4e-normalised-icon "eye" :height 0.6 :v-adjust 0.07 :color "dsilver")) - mu4e-headers-trashed-mark (cons "T" (+mu4e-normalised-icon "trash")) - mu4e-headers-attach-mark (cons "a" (+mu4e-normalised-icon "file-text-o" :color "silver")) - mu4e-headers-encrypted-mark (cons "x" (+mu4e-normalised-icon "lock")) - mu4e-headers-signed-mark (cons "s" (+mu4e-normalised-icon "certificate" :height 0.7 :color "dpurple")) - mu4e-headers-unread-mark (cons "u" (+mu4e-normalised-icon "eye-slash" :v-adjust 0.05)) - mu4e-headers-list-mark (cons "l" (+mu4e-normalised-icon "sitemap" :set "faicon")) - mu4e-headers-personal-mark (cons "p" (+mu4e-normalised-icon "user")) - mu4e-headers-calendar-mark (cons "c" (+mu4e-normalised-icon "calendar")))) - -(defun +mu4e-colorize-str (str &optional unique herring) - "Apply a face from `+mu4e-header-colorized-faces' to STR. -If HERRING is set, it will be used to determine the face instead of STR. -Will try to make unique when non-nil UNIQUE, -a quoted symbol for a alist of current strings and faces provided." - (unless herring - (setq herring str)) - (put-text-property - 0 (length str) - 'face - (list - (if (not unique) - (+mu4e--str-color-face herring str) - (let ((unique-alist (eval unique))) - (unless (assoc herring unique-alist) - (if (> (length unique-alist) (length +mu4e-header-colorized-faces)) - (push (cons herring (+mu4e--str-color-face herring)) unique-alist) - (let ((offset 0) color color?) - (while (not color) - (setq color? (+mu4e--str-color-face herring offset)) - (if (not (rassoc color? unique-alist)) - (setq color color?) - (setq offset (1+ offset)) - (when (> offset (length +mu4e-header-colorized-faces)) - (message "Warning: +mu4e-colorize-str was called with non-unique-alist UNIQUE-alist alist.") - (setq color (+mu4e--str-color-face herring))))) - (push (cons herring color) unique-alist))) - (set unique unique-alist)) - (cdr (assoc herring unique-alist)))) - 'default) - str) - str) - -(defun +mu4e--str-color-face (str &optional offset) - "Select a face from `+mu4e-header-colorized-faces' based on -STR and any integer OFFSET." - (let* ((str-sum (apply #'+ (mapcar (lambda (c) (% c 3)) str))) - (color (nth (% (+ str-sum (if offset offset 0)) - (length +mu4e-header-colorized-faces)) - +mu4e-header-colorized-faces))) - color)) - -(defvar +org-capture-emails-file "todo.org" - "Default target for storing mu4e emails captured from within mu4e. -Requires a \"* Email\" heading be present in the file.") - -;; Adding emails to the agenda -;; Perfect for when you see an email you want to reply to -;; later, but don't want to forget about -;;;###autoload -(defun +mu4e/capture-msg-to-agenda (arg) - "Refile a message and add a entry in `+org-capture-emails-file' with a -deadline. Default deadline is today. With one prefix, deadline -is tomorrow. With two prefixes, select the deadline." - (interactive "p") - (let ((sec "^* Email") - (msg (mu4e-message-at-point))) - (when msg - ;; put the message in the agenda - (with-current-buffer (find-file-noselect - (expand-file-name +org-capture-emails-file org-directory)) - (save-excursion - ;; find header section - (goto-char (point-min)) - (when (re-search-forward sec nil t) - (let (org-M-RET-may-split-line - (lev (org-outline-level)) - (folded-p (invisible-p (point-at-eol))) - (from (plist-get msg :from))) - (when (consp (car from)) ; Occurs when using mu4e 1.8+. - (setq from (car from))) - (unless (keywordp (car from)) ; If using mu4e <= 1.6. - (setq from (list :name (or (caar from) (cdar from))))) - ;; place the subheader - (when folded-p (show-branches)) ; unfold if necessary - (org-end-of-meta-data) ; skip property drawer - (org-insert-todo-heading 1) ; insert a todo heading - (when (= (org-outline-level) lev) ; demote if necessary - (org-do-demote)) - ;; insert message and add deadline - (insert (concat " Respond to " - "[[mu4e:msgid:" - (plist-get msg :message-id) "][" - (truncate-string-to-width - (plist-get from :name) 25 nil nil t) - " - " - (truncate-string-to-width - (plist-get msg :subject) 40 nil nil t) - "]] ")) - (org-deadline nil - (cond ((= arg 1) (format-time-string "%Y-%m-%d")) - ((= arg 4) "+1d"))) - - (org-update-parent-todo-statistics) - - ;; refold as necessary - (if folded-p - (progn - (org-up-heading-safe) - (hide-subtree)) - (hide-entry)))))) - ;; refile the message and update - ;; (cond ((eq major-mode 'mu4e-view-mode) - ;; (mu4e-view-mark-for-refile)) - ;; ((eq major-mode 'mu4e-headers-mode) - ;; (mu4e-headers-mark-for-refile))) - (message "Refiled \"%s\" and added to the agenda for %s" - (truncate-string-to-width - (plist-get msg :subject) 40 nil nil t) - (cond ((= arg 1) "today") - ((= arg 4) "tomorrow") - (t "later")))))) - -;;;###autoload -(defun +mu4e/attach-files (&optional files-to-attach) - "When called in a dired buffer, ask for a message to attach the marked files to. -When called in a mu4e:compose or org-msg buffer, `read-file-name'to either -attach a file, or select a folder to open dired in and select file attachments -(using `dired-mu4e-attach-ctrl-c-ctrl-c'). - -When otherwise called, open a dired buffer and enable `dired-mu4e-attach-ctrl-c-ctrl-c'." - ;; TODO add ability to attach files (+dirs) as a single (named) archive - (interactive "p") - (+mu4e-compose-org-msg-handle-toggle (/= 1 files-to-attach)) - (pcase major-mode - ((or 'mu4e-compose-mode 'org-msg-edit-mode) - (let ((mail-buffer (current-buffer)) - (location (read-file-name "Attach: " nil nil t ""))) - (if (not (file-directory-p location)) - (pcase major-mode - ('mu4e-compose-mode - (save-excursion - (goto-char (point-max)) - (unless (eq (current-column) 0) - (insert "\n\n") - (forward-line 2)) - (mail-add-attachment location))) - ('org-msg-edit-mode (org-msg-attach-attach location))) - (split-window-sensibly) - (with-current-buffer (dired location) - (setq-local dired-mail-buffer mail-buffer) - (dired-mu4e-attach-ctrl-c-ctrl-c 1))))) - ('dired-mode - (unless (and files-to-attach (/= 1 files-to-attach)) - (setq files-to-attach - (delq nil - (mapcar - ;; don't attach directories - (lambda (f) (if (file-directory-p f) nil f)) - (nreverse (dired-map-over-marks (dired-get-filename) nil)))))) - (if (not files-to-attach) - (progn - (message "No files marked, aborting.") - (kill-buffer-and-window)) - (if-let ((mail-target-buffer (bound-and-true-p dired-mail-buffer))) - (progn (kill-buffer-and-window) - (switch-to-buffer mail-target-buffer)) - (if (and (+mu4e-current-buffers) - (y-or-n-p "Attach files to existing mail composition buffer? ")) - (progn (setf mail-target-buffer - (completing-read "Message: " (+mu4e-current-buffers))) - (kill-buffer-and-window) - (switch-to-buffer mail-target-buffer)) - (kill-buffer-and-window) - (mu4e-compose 'new))) - (mapcar - (pcase major-mode - ('mu4e-compose-mode #'mail-add-attachment) - ('org-msg-edit-mode #'org-msg-attach-attach)) - files-to-attach))) - (_ - (split-window-sensibly) - (with-current-buffer (call-interactively #'find-file) - (dired-mu4e-attach-ctrl-c-ctrl-c 1))))) - -(define-minor-mode dired-mu4e-attach-ctrl-c-ctrl-c - "Adds C-c C-c as a keybinding to attach files to a message." - :lighter "attach" - :keymap (let ((map (make-sparse-keymap))) - (define-key map (kbd "C-c C-c") '+mu4e/attach-files) - map) - (setq header-line-format - (when dired-mu4e-attach-ctrl-c-ctrl-c - (substitute-command-keys - "Mu4e attach active. `\\[+mu4e/attach-files]' to attach the marked files.")))) - -(defun +mu4e-current-buffers () - "Return a list of active message buffers." - (let (buffers) - (save-current-buffer - (dolist (buffer (buffer-list t)) - (set-buffer buffer) - (when (or (and (derived-mode-p 'message-mode) - (null message-sent-message-via)) - (eq major-mode 'org-msg-edit-mode)) - (push (buffer-name buffer) buffers)))) - (nreverse buffers))) - -;;; Hooks - -(defun +mu4e-init-h () - (add-hook 'kill-buffer-hook #'+mu4e-kill-mu4e-h nil t)) - -(defun +mu4e-kill-mu4e-h () - ;; (prolusion-mail-hide) - (cond - ((and (modulep! :ui workspaces) (+workspace-exists-p +mu4e-workspace-name)) - (+workspace/delete +mu4e-workspace-name)) - - (+mu4e--old-wconf - (set-window-configuration +mu4e--old-wconf) - (setq +mu4e--old-wconf nil)))) - -;;;###autoload -(defun +mu4e-set-from-address-h () - "If the user defines multiple `+mu4e-personal-addresses' for email aliases -within a context, set `user-mail-address' to an alias found in the 'To' or -'From' headers of the parent message if present, or prompt the user for a -preferred alias" - (when-let ((addresses (if (or mu4e-contexts +mu4e-personal-addresses) - (and (> (length +mu4e-personal-addresses) 1) - +mu4e-personal-addresses) - (mu4e-personal-addresses)))) - (setq user-mail-address - (if mu4e-compose-parent-message - (if (version<= "1.8" mu4e-mu-version) - (let ((to (mu4e-message-field mu4e-compose-parent-message :to)) - (cc (mu4e-message-field mu4e-compose-parent-message :cc)) - (from (mu4e-message-field mu4e-compose-parent-message :from))) - (or (car (cl-intersection - (mapcar (lambda (adr) (plist-get adr :email)) - (append to from cc)) - addresses - :test #'equal)) - (completing-read "From: " addresses))) - (let ((to (mapcar #'cdr (mu4e-message-field mu4e-compose-parent-message :to))) - (cc (mapcar #'cdr (mu4e-message-field mu4e-compose-parent-message :cc))) - (from (mapcar #'cdr (mu4e-message-field mu4e-compose-parent-message :from)))) - (or (car (cl-intersection (append to from cc) addresses - :test #'equal)) - (completing-read "From: " addresses)))) - (completing-read "From: " addresses))))) diff --git a/.config/emacs/modules/email/mu4e/autoload/evil.el b/.config/emacs/modules/email/mu4e/autoload/evil.el @@ -1,21 +0,0 @@ -;; email/mu4e/autoload/evil.el -*- lexical-binding: t; -*- -;;;###if (modulep! :editor evil) - -;;;###autoload -(defun +mu4e/mark (&optional beg end) - "Mark all messages within the current selection in mu4e's header view. Uses -`this-command-keys' to see what flag you mean." - (interactive) - (let* ((beg (or beg (and (region-active-p) evil-visual-beginning) (line-beginning-position))) - (end (or end (and (region-active-p) evil-visual-end) (line-end-position))) - (key (this-command-keys)) - (command - (car (cl-find-if (lambda (mark) (equal (car (plist-get (cdr mark) :char)) key)) - mu4e-marks)))) - (unless command - (error "Not a valid mark command: %s" key)) - (when (bound-and-true-p evil-mode) - (evil-normal-state)) - (goto-char beg) - (dotimes (_ (count-lines beg end)) - (mu4e-headers-mark-and-next command)))) diff --git a/.config/emacs/modules/email/mu4e/autoload/mu-lock.el b/.config/emacs/modules/email/mu4e/autoload/mu-lock.el @@ -1,96 +0,0 @@ -;;; email/mu4e/autoload/mu-lock.el -*- lexical-binding: t; -*- -(autoload 'file-notify-rm-watch "filenotify") -(autoload 'file-notify-add-watch "filenotify") - -(defvar +mu4e-lock-file (expand-file-name "mu4e_lock" temporary-file-directory) - "Location of the lock file which stores the PID of the process currenty running mu4e") -(defvar +mu4e-lock-request-file (expand-file-name "mu4e_lock_request" temporary-file-directory) - "Location of the lock file for which creating indicated that another process wants the lock to be released") - -(defvar +mu4e-lock-greedy nil - "Whether to 'grab' the `+mu4e-lock-file' if nobody else has it, i.e. start Mu4e") -(defvar +mu4e-lock-relaxed t - "Whether if someone else wants the lock (signaled via `+mu4e-lock-request-file'), we should stop Mu4e and let go of it") - -(defun +mu4e-lock-pid-info () - "Get info on the PID refered to in `+mu4e-lock-file' in the form (pid . process-attributes) - If the file or process do not exist, the lock file is deleted an nil returned." - (when (file-exists-p +mu4e-lock-file) - (let* ((coding-system-for-read 'utf-8) - (pid (string-to-number - (with-temp-buffer - (insert-file-contents +mu4e-lock-file) - (buffer-string)))) - (process (process-attributes pid))) - (if (and process (string-match-p "[Ee]macs" (alist-get 'comm process))) - (cons pid process) - (delete-file +mu4e-lock-file) nil)))) - -;;;###autoload -(defun +mu4e-lock-available (&optional strict) - "If the `+mu4e-lock-file' is available (unset or owned by this emacs) return t. -If STRICT only accept an unset lock file." - (not (when-let* ((lock-info (+mu4e-lock-pid-info)) - (pid (car lock-info))) - (when (or strict (/= (emacs-pid) pid)) t)))) - -;;;###autoload -(defun +mu4e-lock-file-delete-maybe () - "Check `+mu4e-lock-file', and delete it if this process is responsible for it." - (when (+mu4e-lock-available) - (delete-file +mu4e-lock-file) - (file-notify-rm-watch +mu4e-lock--request-watcher))) - -;;;###autoload -(defun +mu4e-lock-start (orig-fun &optional callback) - "Check `+mu4e-lock-file', and if another process is responsible for it, abort starting. -Else, write to this process' PID to the lock file" - (unless (+mu4e-lock-available) - (call-process "touch" nil nil nil +mu4e-lock-request-file) - (message "Lock file exists, requesting that it be given up") - (sleep-for 0.1) - (delete-file +mu4e-lock-request-file)) - (if (not (+mu4e-lock-available)) - (user-error "Unfortunately another Emacs is already doing stuff with Mu4e, and you can only have one at a time") - (write-region (number-to-string (emacs-pid)) nil +mu4e-lock-file) - (delete-file +mu4e-lock-request-file) - (call-process "touch" nil nil nil +mu4e-lock-request-file) - (funcall orig-fun callback) - (when +mu4e-lock--request-watcher - (file-notify-rm-watch +mu4e-lock--request-watcher)) - (file-notify-add-watch +mu4e-lock-request-file - '(change) - #'+mu4e-lock--request))) - -(defvar +mu4e-lock--file-watcher nil) -(defvar +mu4e-lock--file-just-deleted nil) -(defvar +mu4e-lock--request-watcher nil) - -(defun +mu4e-lock-add-watcher () - (setq +mu4e-lock--file-just-deleted nil) - (file-notify-rm-watch +mu4e-lock--file-watcher) - (setq +mu4e-lock--file-watcher - (file-notify-add-watch +mu4e-lock-file - '(change) - #'+mu4e-lock--file-updated))) - -(defun +mu4e-lock--request (event) - "Handle another process requesting the Mu4e lock." - (when (eq (nth 1 event) 'created) - (when +mu4e-lock-relaxed - (mu4e--stop) - (file-notify-rm-watch +mu4e-lock--file-watcher) - (file-notify-rm-watch +mu4e-lock--request-watcher) - (message "Someone else wants to use Mu4e, releasing lock") - (delete-file +mu4e-lock-file) - (run-at-time 0.2 nil #'+mu4e-lock-add-watcher)) - (delete-file +mu4e-lock-request-file))) - -(defun +mu4e-lock--file-updated (event) - (if +mu4e-lock--file-just-deleted - (+mu4e-lock-add-watcher) - (when (eq (nth 1 event) 'deleted) - (setq +mu4e-lock--file-just-deleted t) - (when (and +mu4e-lock-greedy (+mu4e-lock-available t)) - (message "Noticed Mu4e lock was available, grabbed it") - (run-at-time 0.2 nil #'mu4e))))) diff --git a/.config/emacs/modules/email/mu4e/config.el b/.config/emacs/modules/email/mu4e/config.el @@ -1,753 +0,0 @@ -;;; email/mu4e/config.el -*- lexical-binding: t; -*- - -(defvar +mu4e-backend 'mbsync - "Which backend to use. Can either be offlineimap, mbsync or nil (manual).") - -(defvar +mu4e-personal-addresses 'nil - "Alternative to mu4e-personal-addresses that can be set for each account (mu4e context).") - - -;; -;;; Packages - -(use-package! mu4e - :commands mu4e mu4e-compose-new - :init - (provide 'html2text) ; disable obsolete package - (when (or (not (or (require 'mu4e-config nil t) - (require 'mu4e-meta nil t))) - (version< mu4e-mu-version "1.4")) - (setq mu4e-maildir "~/.mail" - mu4e-user-mail-address-list nil)) - (setq mu4e-attachment-dir - (lambda (&rest _) - (expand-file-name ".attachments" (mu4e-root-maildir)))) - :config - (when (version< mu4e-mu-version "1.8") - ;; Define aliases to maintain backwards compatibility. The list of suffixes - ;; were obtained by comparing mu4e~ and mu4e-- functions in `obarray'. - (dolist (transferable-suffix - '("check-requirements" "contains-line-matching" "context-ask-user" - "context-autoswitch" "default-handler" "get-folder" "get-log-buffer" - "get-mail-process-filter" "guess-maildir" "key-val" - "longest-of-maildirs-and-bookmarks" "maildirs-with-query" - "main-action-str" "main-bookmarks" "main-maildirs" "main-menu" - "main-queue-size" "main-redraw-buffer" - "main-toggle-mail-sending-mode" "main-view" "main-view-queue" - "main-view-real" "main-view-real-1" "mark-ask-target" - "mark-check-target" "mark-clear" "mark-find-headers-buffer" - "mark-get-dyn-target" "mark-get-markpair" "mark-get-move-target" - "mark-in-context" "mark-initialize" "org-store-link-message" - "org-store-link-query" "pong-handler" "read-char-choice" - "read-patch-directory" "replace-first-line-matching" - "request-contacts-maybe" "rfc822-phrase-type" "start" "stop" - "temp-window" "update-contacts" "update-mail-and-index-real" - "update-mail-mode" "update-sentinel-func")) - (defalias (intern (concat "mu4e--" transferable-suffix)) - (intern (concat "mu4e~" transferable-suffix)) - "Alias to provide the API of mu4e 1.8 (mu4e~ ⟶ mu4e--).") - (dolist (transferable-proc-suffixes - '("add" "compose" "contacts" "eat-sexp-from-buf" "filter" - "find" "index" "kill" "mkdir" "move" "ping" "remove" - "sent" "sentinel" "start" "view")) - (defalias (intern (concat "mu4e--server-" transferable-proc-suffixes)) - (intern (concat "mu4e~proc-" transferable-proc-suffixes)) - "Alias to provide the API of mu4e 1.8 (mu4e~proc ⟶ mu4e--server).")) - (defalias 'mu4e-search-rerun #'mu4e-headers-rerun-search - "Alias to provide the API of mu4e 1.8.") - (defun mu4e (&optional background) - "If mu4e is not running yet, start it. -Then, show the main window, unless BACKGROUND (prefix-argument) -is non-nil." - (interactive "P") - (mu4e--start (and (not background) #'mu4e--main-view)))) - (setq mu4e-view-show-addresses t - mu4e-view-show-images t - mu4e-view-image-max-width 800 - mu4e-view-use-gnus t)) - - (pcase +mu4e-backend - (`mbsync - (setq mu4e-get-mail-command "mbsync -a" - mu4e-change-filenames-when-moving t)) - (`offlineimap - (setq mu4e-get-mail-command "offlineimap -o -q"))) - - (setq mu4e-update-interval nil - mu4e-sent-messages-behavior 'sent - mu4e-hide-index-messages t - ;; configuration for sending mail - message-send-mail-function #'smtpmail-send-it - smtpmail-stream-type 'starttls - message-kill-buffer-on-exit t ; close after sending - ;; start with the first (default) context; - mu4e-context-policy 'pick-first - ;; compose with the current context, or ask - mu4e-compose-context-policy 'ask-if-none - ;; use helm/ivy/vertico - mu4e-completing-read-function - (cond ((modulep! :completion ivy) #'ivy-completing-read) - ((modulep! :completion helm) #'completing-read) - ((modulep! :completion vertico) #'completing-read) - (t #'ido-completing-read)) - mu4e-attachment-dir - (concat - (if-let ((xdg-download-query (and (executable-find "xdg-user-dir") - (doom-call-process "xdg-user-dir" "DOWNLOAD"))) - (xdg-download-dir (and (= 0 (car xdg-download-query)) (cdr xdg-download-query)))) - xdg-download-dir - (expand-file-name (or (getenv "XDG_DOWNLOAD_DIR") - "Downloads") - "~")) - "/") ; a trailing / makes it easier to change directory in `read-file-name' - ;; no need to ask - mu4e-confirm-quit nil - mu4e-headers-thread-single-orphan-prefix '("─>" . "─▶") - mu4e-headers-thread-orphan-prefix '("┬>" . "┬▶ ") - mu4e-headers-thread-connection-prefix '("│ " . "│ ") - mu4e-headers-thread-first-child-prefix '("├>" . "├▶") - mu4e-headers-thread-child-prefix '("├>" . "├▶") - mu4e-headers-thread-last-child-prefix '("└>" . "╰▶") - ;; remove 'lists' column - mu4e-headers-fields - '((:account-stripe . 1) - (:human-date . 12) - (:flags . 6) ; 3 icon flags - (:from-or-to . 25) - (:subject))) - - ;; Better search symbols - (letf! ((defun make-help-button (text help-echo) - (with-temp-buffer - (insert-text-button text - 'help-echo help-echo - 'mouse-face nil) - (buffer-string))) - (defun make-help-button-cons (text1 text2 help-echo) - (cons (make-help-button text1 help-echo) - (make-help-button text2 help-echo)))) - (setq mu4e-headers-threaded-label - (make-help-button-cons "T" (concat " " (all-the-icons-octicon "git-branch" :v-adjust 0.05)) - "Thread view") - mu4e-headers-related-label - (make-help-button-cons "R" (concat " " (all-the-icons-material "link" :v-adjust -0.1)) - "Showing related emails") - mu4e-headers-full-label - (make-help-button-cons "F" (concat " " (all-the-icons-material "disc_full")) - "Search is full!"))) - - ;; set mail user agent - (setq mail-user-agent 'mu4e-user-agent - message-mail-user-agent 'mu4e-user-agent) - - ;; Set the icons only when a graphical frame has been created - (if (display-graphic-p) - (+mu4e-initialise-icons) - ;; When it's the server, wait till the first graphical frame - (add-hook! - 'server-after-make-frame-hook - (defun +mu4e-initialise-icons-hook () - (when (display-graphic-p) - (+mu4e-initialise-icons) - (remove-hook 'server-after-make-frame-hook - #'+mu4e-initialise-icons-hook))))) - - (plist-put (cdr (assoc :flags mu4e-header-info)) :shortname " Flags") ; default=Flgs - (add-to-list 'mu4e-bookmarks - '("flag:flagged" "Flagged messages" ?f) t) - - ;; TODO avoid assuming that all-the-icons is present - (defvar +mu4e-header-colorized-faces - '(all-the-icons-green - all-the-icons-lblue - all-the-icons-purple-alt - all-the-icons-blue-alt - all-the-icons-purple - all-the-icons-yellow) - "Faces to use when coloring folders and account stripes.") - - (defvar +mu4e-min-header-frame-width 120 - "Minimum reasonable with for the header view.") - - ;; Add a column to display what email account the email belongs to, - ;; and an account color stripe column - (defvar +mu4e-header--maildir-colors nil) - (setq mu4e-header-info-custom - '((:account . - (:name "Account" - :shortname "Account" - :help "which account/maildir this email belongs to" - :function - (lambda (msg) - (let ((maildir (replace-regexp-in-string - "\\`/?\\([^/]+\\)/.*\\'" "\\1" - (mu4e-message-field msg :maildir)))) - (+mu4e-colorize-str - (replace-regexp-in-string - "^gmail" - (propertize "g" 'face 'bold-italic) - maildir) - '+mu4e-header--maildir-colors - maildir))))) - (:account-stripe . - (:name "Account" - :shortname "▐" - :help "Which account/maildir this email belongs to" - :function - (lambda (msg) - (let ((account - (replace-regexp-in-string - "\\`/?\\([^/]+\\)/.*\\'" "\\1" - (mu4e-message-field msg :maildir)))) - (propertize - (+mu4e-colorize-str "▌" '+mu4e-header--maildir-colors account) - 'help-echo account))))) - (:recipnum . - (:name "Number of recipients" - :shortname " ⭷" - :help "Number of recipients for this message" - :function - (lambda (msg) - (propertize (format "%2d" - (+ (length (mu4e-message-field msg :to)) - (length (mu4e-message-field msg :cc)))) - 'face 'mu4e-footer-face)))))) - - ;; Marks usually affect the current view - (defadvice! +mu4e--refresh-current-view-a (&rest _) - :after #'mu4e-mark-execute-all (mu4e-search-rerun)) - - ;; Wrap text in messages - (setq-hook! 'mu4e-view-mode-hook truncate-lines nil) - - ;; Html mails might be better rendered in a browser - (add-to-list 'mu4e-view-actions '("View in browser" . mu4e-action-view-in-browser)) - (when (fboundp 'make-xwidget) - (add-to-list 'mu4e-view-actions '("xwidgets view" . mu4e-action-view-in-xwidget))) - - ;; Detect empty subjects, and give users an opotunity to fill something in - (defun +mu4e-check-for-subject () - "Check that a subject is present, and prompt for a subject if not." - (save-excursion - (goto-char (point-min)) - (search-forward "--text follows this line--") - (re-search-backward "^Subject:") ; this should be present no matter what - (let ((subject (string-trim (substring (thing-at-point 'line) 8)))) - (when (string-empty-p subject) - (end-of-line) - (insert (read-string "Subject (optional): ")) - (message "Sending..."))))) - - (add-hook 'message-send-hook #'+mu4e-check-for-subject) - - ;; The header view needs a certain amount of horizontal space to - ;; actually show you all the information you want to see - ;; so if the header view is entered from a narrow frame, - ;; it's probably worth trying to expand it - (defun +mu4e-widen-frame-maybe () - "Expand the mu4e-headers containing frame's width to `+mu4e-min-header-frame-width'." - (dolist (frame (frame-list)) - (when (and (string= (buffer-name (window-buffer (frame-selected-window frame))) - mu4e-headers-buffer-name) - (< (frame-width) +mu4e-min-header-frame-width)) - (set-frame-width frame +mu4e-min-header-frame-width)))) - (add-hook 'mu4e-headers-mode-hook #'+mu4e-widen-frame-maybe) - - (when (fboundp 'imagemagick-register-types) - (imagemagick-register-types)) - - (when (modulep! :ui workspaces) - (map! :map mu4e-main-mode-map - :ne "h" #'+workspace/other)) - - (map! :map mu4e-headers-mode-map - :vne "l" #'+mu4e/capture-msg-to-agenda) - - ;; Functionality otherwise obscured in mu4e 1.6 - (when (version<= "1.6" mu4e-mu-version) - (defun +mu4e-view-select-attachment () - "Use completing-read to select a single attachment. -Acts like a singular `mu4e-view-save-attachments', without the saving." - (if-let ((parts (delq nil (mapcar - (lambda (part) - (when (assoc "attachment" (cdr part)) - part)) - (mu4e~view-gather-mime-parts)))) - (files (+mu4e-part-selectors parts))) - (cdr (assoc (completing-read "Select attachment: " (mapcar #'car files)) files)) - (user-error (mu4e-format "No attached files found")))) - - (defun +mu4e-view-open-attachment () - "Select an attachment, and open it." - (interactive) - (mu4e~view-open-file - (mu4e~view-mime-part-to-temp-file (cdr (+mu4e-view-select-attachment))))) - - (defun +mu4e-view-select-mime-part-action () - "Select a MIME part, and perform an action on it." - (interactive) - (let ((labeledparts (+mu4e-part-selectors (mu4e~view-gather-mime-parts)))) - (if labeledparts - (mu4e-view-mime-part-action - (cadr (assoc (completing-read "Select part: " (mapcar #'car labeledparts)) - labeledparts))) - (user-error (mu4e-format "No parts found"))))) - - (map! :map mu4e-view-mode-map - :ne "A" #'+mu4e-view-select-mime-part-action - :ne "p" #'mu4e-view-save-attachments - :ne "o" #'+mu4e-view-open-attachment) - - (defun +mu4e-part-selectors (parts) - "Generate selection strings for PARTS." - (if parts - (let (partinfo labeledparts maxfnamelen fnamefmt maxsizelen sizefmt) - (dolist (part parts) - (push (list :index (car part) - :mimetype (if (and (string= "text/plain" (caaddr part)) - (alist-get 'charset (cdaddr part))) - (format "%s (%s)" - (caaddr part) - (alist-get 'charset (cdaddr part))) - (caaddr part)) - :type (car (nth 5 part)) - :filename (cdr (assoc 'filename (assoc "attachment" (cdr part)))) - :size (file-size-human-readable (with-current-buffer (cadr part) (buffer-size))) - :part part) - partinfo)) - (setq maxfnamelen (apply #'max 7 (mapcar (lambda (i) (length (plist-get i :filename))) partinfo)) - fnamefmt (format " %%-%ds " maxfnamelen) - maxsizelen (apply #'max (mapcar (lambda (i) (length (plist-get i :size))) partinfo)) - sizefmt (format "%%-%ds " maxsizelen)) - (dolist (pinfo partinfo) - (push (cons (concat (propertize (format "%-2s " (plist-get pinfo :index)) 'face '(bold font-lock-type-face)) - (when (featurep 'all-the-icons) - (all-the-icons-icon-for-file (or (plist-get pinfo :filename) ""))) - (format fnamefmt (or (plist-get pinfo :filename) - (propertize (plist-get pinfo :type) 'face '(italic font-lock-doc-face)))) - (format sizefmt (propertize (plist-get pinfo :size) 'face 'font-lock-builtin-face)) - (propertize (plist-get pinfo :mimetype) 'face 'font-lock-constant-face)) - (plist-get pinfo :part)) - labeledparts)) - labeledparts)))) - - (map! :localleader - :map mu4e-compose-mode-map - :desc "send and exit" "s" #'message-send-and-exit - :desc "kill buffer" "d" #'message-kill-buffer - :desc "save draft" "S" #'message-dont-send - :desc "attach" "a" #'+mu4e/attach-files) - - ;; Due to evil, none of the marking commands work when making a visual selection in - ;; the headers view of mu4e. Without overriding any evil commands we may actually - ;; want to use in and evil selection, this can be easily fixed. - (when (modulep! :editor evil) - (map! :map mu4e-headers-mode-map - :v "*" #'mu4e-headers-mark-for-something - :v "!" #'mu4e-headers-mark-for-read - :v "?" #'mu4e-headers-mark-for-unread - :v "u" #'mu4e-headers-mark-for-unmark)) - - (add-hook 'mu4e-compose-pre-hook '+mu4e-set-from-address-h) - - (defadvice! +mu4e-ensure-compose-writeable-a (&rest _) - "Ensure that compose buffers are writable. -This should already be the case yet it does not always seem to be." - :before #'mu4e-compose-new - :before #'mu4e-compose-reply - :before #'mu4e-compose-forward - :before #'mu4e-compose-resend - (read-only-mode -1)) - - (defvar +mu4e-main-bullet "⚫" - "Prefix to use instead of \" *\" in the mu4e main view. -This is enacted by `+mu4e~main-action-str-prettier-a' and -`+mu4e~main-keyval-str-prettier-a'.") - - (advice-add #'mu4e--key-val :filter-return #'+mu4e~main-keyval-str-prettier-a) - (advice-add #'mu4e--main-action-str :override #'+mu4e~main-action-str-prettier-a) - (when (modulep! :editor evil) - ;; As +mu4e~main-action-str-prettier replaces [k]ey with key q]uit should become quit - (setq evil-collection-mu4e-end-region-misc "quit")) - - ;; process lock control - (when IS-WINDOWS - (setq - +mu4e-lock-file (expand-file-name "~/AppData/Local/Temp/mu4e_lock") - +mu4e-lock-request-file (expand-file-name "~/AppData/Local/Temp/mu4e_lock_request"))) - - (add-hook 'kill-emacs-hook #'+mu4e-lock-file-delete-maybe) - (advice-add 'mu4e--start :around #'+mu4e-lock-start) - (advice-add 'mu4e-quit :after #'+mu4e-lock-file-delete-maybe)) - -(unless (modulep! +org) - (after! mu4e - (defun org-msg-mode (&optional _) - "Dummy function." - (message "Enable the +org mu4e flag to use org-msg-mode.")) - (defun +mu4e-compose-org-msg-handle-toggle (&rest _) - "Placeholder to allow for the assumtion that this function is defined. -Ignores all arguments and returns nil." - nil))) - -(use-package! org-msg - :after mu4e - :when (modulep! +org) - :config - (setq org-msg-options "html-postamble:nil H:5 num:nil ^:{} toc:nil author:nil email:nil tex:dvipng" - org-msg-startup "hidestars indent inlineimages" - org-msg-greeting-name-limit 3 - org-msg-default-alternatives '((new . (utf-8 html)) - (reply-to-text . (utf-8)) - (reply-to-html . (utf-8 html))) - org-msg-convert-citation t - ;; The default attachment matcher gives too many false positives, - ;; it's better to be more conservative. See https://regex101.com/r/EtaiSP/4. - org-msg-attached-file-reference - "see[ \t\n]\\(?:the[ \t\n]\\)?\\(?:\\w+[ \t\n]\\)\\{0,3\\}\\(?:attached\\|enclosed\\)\\|\ -(\\(?:attached\\|enclosed\\))\\|\ -\\(?:attached\\|enclosed\\)[ \t\n]\\(?:for\\|is\\)[ \t\n]") - - (defvar +org-msg-currently-exporting nil - "Helper variable to indicate whether org-msg is currently exporting the org buffer to HTML. -Usefull for affecting HTML export config.") - (defadvice! +org-msg--now-exporting-a (&rest _) - :before #'org-msg-org-to-xml - (setq +org-msg-currently-exporting t)) - (defadvice! +org-msg--not-exporting-a (&rest _) - :after #'org-msg-org-to-xml - (setq +org-msg-currently-exporting nil)) - - (advice-add #'org-html-latex-fragment :override #'+org-html-latex-fragment-scaled-a) - (advice-add #'org-html-latex-environment :override #'+org-html-latex-environment-scaled-a) - - (map! :map org-msg-edit-mode-map - :desc "attach" "C-c C-a" #'+mu4e/attach-files - :localleader - :desc "attach" "a" #'+mu4e/attach-files) - - ;; I feel like it's reasonable to expect files to be attached - ;; in the order you attach them, not the reverse. - (defadvice! +org-msg-attach-attach-in-order-a (file &rest _args) - "Link FILE into the list of attachment." - :override #'org-msg-attach-attach - (interactive (list (read-file-name "File to attach: "))) - (let ((files (org-msg-get-prop "attachment"))) - (org-msg-set-prop "attachment" (nconc files (list file))))) - - (defvar +mu4e-compose-org-msg-toggle-next t ; t to initialise org-msg - "Whether to toggle ") - (defun +mu4e-compose-org-msg-handle-toggle (toggle-p) - (when (xor toggle-p +mu4e-compose-org-msg-toggle-next) - (org-msg-mode (if org-msg-mode -1 1)) - (setq +mu4e-compose-org-msg-toggle-next - (not +mu4e-compose-org-msg-toggle-next)))) - - (defadvice! +mu4e-maybe-toggle-org-msg-a (fn &optional toggle-p) - :around #'mu4e-compose-new - :around #'mu4e-compose-reply - :around #'mu4e-compose-forward - :around #'mu4e-compose-resend - (interactive "p") - (+mu4e-compose-org-msg-handle-toggle (/= 1 (or toggle-p 0))) - (funcall fn)) - - (defadvice! +mu4e-draft-open-signature-a (fn &rest args) - "Prevent `mu4e-compose-signature' from being used with `org-msg-mode'." - :around #'mu4e-draft-open - (let ((mu4e-compose-signature (unless org-msg-mode mu4e-compose-signature))) - (apply fn args))) - - (map! :map org-msg-edit-mode-map - "TAB" #'org-msg-tab) ; only <tab> bound by default - - (defvar +org-msg-accent-color "#c01c28" - "Accent color to use in org-msg's generated CSS. -Must be set before org-msg is loaded to take effect.") - (setq org-msg-enforce-css - (let* ((font-family '(font-family . "-apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Oxygen, Ubuntu, Cantarell,\ - \"Fira Sans\", \"Droid Sans\", \"Helvetica Neue\", Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\";")) - (monospace-font '(font-family . "SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace;")) - (font-size '(font-size . "11pt")) - (font `(,font-family ,font-size)) - (line-height '(line-height . "1.2")) - (theme-color +org-msg-accent-color) - (bold '(font-weight . "bold")) - (color `(color . ,theme-color)) - (table `((margin-top . "6px") (margin-bottom . "6px") - (border-left . "none") (border-right . "none") - (border-top . "2px solid #222222") - (border-bottom . "2px solid #222222") - )) - (ftl-number `(,color ,bold (text-align . "left"))) - (inline-modes '(asl c c++ conf cpp csv diff ditaa emacs-lisp - fundamental ini json makefile man org plantuml - python sh xml)) - (inline-src `((background-color . "rgba(27,31,35,.05)") - (border-radius . "3px") - (padding . ".2em .4em") - (font-size . "90%") ,monospace-font - (margin . 0))) - (code-src - (mapcar (lambda (mode) - `(code ,(intern (concat "src src-" (symbol-name mode))) - ,inline-src)) - inline-modes)) - (base-quote '((padding-left . "5px") (margin-left . "10px") - (margin-top . "20px") (margin-bottom . "0") - (font-style . "italic") (background . "#f9f9f9"))) - (quote-palette '("#6A8FBF" "#bf8f6a" "#6abf8a" "#906abf" - "#6aaebf" "#bf736a" "#bfb66a" "#bf6a94" - "#6abf9b" "#bf6a7d" "#acbf6a" "#6a74bf")) - (quotes - (mapcar (lambda (x) - (let ((c (nth x quote-palette))) - `(div ,(intern (format "quote%d" (1+ x))) - (,@base-quote - (color . ,c) - (border-left . ,(concat "3px solid " - (org-msg-lighten c))))))) - (number-sequence 0 (1- (length quote-palette)))))) - `((del nil ((color . "grey") (border-left . "none") - (text-decoration . "line-through") (margin-bottom . "0px") - (margin-top . "10px") (line-height . "11pt"))) - (a nil (,color)) - (a reply-header ((color . "black") (text-decoration . "none"))) - (div reply-header ((padding . "3.0pt 0in 0in 0in") - (border-top . "solid #e1e1e1 1.0pt") - (margin-bottom . "20px"))) - (span underline ((text-decoration . "underline"))) - (li nil (,line-height (margin-bottom . "0px") - (margin-top . "2px") - (max-width . "47em"))) - (nil org-ul ((list-style-type . "disc"))) - (nil org-ol (,@font ,line-height (margin-bottom . "0px") - (margin-top . "0px") (margin-left . "30px") - (padding-top . "0px") (padding-left . "5px"))) - (nil signature (,@font (margin-bottom . "20px"))) - (blockquote nil ((padding . "2px 12px") (margin-left . "10px") - (margin-top . "10px") (margin-bottom . "0") - (border-left . "3px solid #ccc") - (font-style . "italic") - (background . "#f9f9f9"))) - (p blockquote ((margin . "0") (padding . "4px 0"))) - ,@quotes - (code nil (,font-size ,monospace-font (background . "#f9f9f9"))) - ,@code-src - (nil linenr ((padding-right . "1em") - (color . "black") - (background-color . "#aaaaaa"))) - (pre nil ((line-height . "1.2") - (color . ,(face-foreground 'default)) - (background-color . ,(face-background 'default)) - (margin . "4px 0px 8px 0px") - (padding . "8px 12px") - (width . "max-content") - (min-width . "50em") - (border-radius . "5px") - (font-size . "0.9em") - (font-weight . "500") - ,monospace-font)) - (div org-src-container ((margin-top . "10px"))) - (nil figure-number ,ftl-number) - (nil table-number) - (caption nil ((text-align . "left") - (background . ,theme-color) - (color . "white") - ,bold)) - (nil t-above ((caption-side . "top"))) - (nil t-bottom ((caption-side . "bottom"))) - (nil listing-number ,ftl-number) - (nil figure ,ftl-number) - (nil org-src-name ,ftl-number) - (img nil ((vertical-align . "middle") - (max-width . "100%"))) - (img latex-fragment-inline ((margin . "0 0.1em"))) - (table nil (,@table ,line-height (border-collapse . "collapse"))) - (th nil ((border . "none") (border-bottom . "1px solid #222222") - (background-color . "#EDEDED") (font-weight . "500") - (padding . "3px 10px"))) - (td nil (,@table (padding . "1px 10px") - (background-color . "#f9f9f9") (border . "none"))) - (td org-left ((text-align . "left"))) - (td org-right ((text-align . "right"))) - (td org-center ((text-align . "center"))) - (kbd nil ((border . "1px solid #d1d5da") (border-radius . "3px") - (box-shadow . "inset 0 -1px 0 #d1d5da") - (background-color . "#fafbfc") (color . "#444d56") - (font-size . "0.85em") - (padding . "1px 4px") (display . "inline-block"))) - (div outline-text-4 ((margin-left . "15px"))) - (div outline-4 ((margin-left . "10px"))) - (h4 nil ((margin-bottom . "0px") (font-size . "11pt"))) - (h3 nil ((margin-bottom . "0px") - ,color (font-size . "14pt"))) - (h2 nil ((margin-top . "20px") (margin-bottom . "20px") - ,color (font-size . "18pt"))) - (h1 nil ((margin-top . "20px") (margin-bottom . "0px") - ,color (font-size . "24pt"))) - (p nil ((text-decoration . "none") (line-height . "1.4") - (margin-top . "10px") (margin-bottom . "0px") - ,font-size (max-width . "50em"))) - (b nil ((font-weight . "500") (color . ,theme-color))) - (div nil (,@font (line-height . "12pt"))))))) - - -;; -;;; Gmail integration - -(when (modulep! +gmail) - (after! mu4e - (defvar +mu4e-gmail-accounts nil - "Gmail accounts that do not contain \"gmail\" in address and maildir. - -An alist of Gmail addresses of the format \((\"username@domain.com\" . \"account-maildir\")) -to which Gmail integrations (behind the `+gmail' flag of the `mu4e' module) should be applied. - -See `+mu4e-msg-gmail-p' and `mu4e-sent-messages-behavior'.") - - ;; don't save message to Sent Messages, Gmail/IMAP takes care of this - (setq mu4e-sent-messages-behavior - (lambda () ;; TODO make use +mu4e-msg-gmail-p - (if (or (string-match-p "@gmail.com\\'" (message-sendmail-envelope-from)) - (member (message-sendmail-envelope-from) - (mapcar #'car +mu4e-gmail-accounts))) - 'delete 'sent))) - - (defun +mu4e-msg-gmail-p (msg) - (let ((root-maildir - (replace-regexp-in-string "/.*" "" - (substring (mu4e-message-field msg :maildir) 1)))) - (or (string-match-p "gmail" root-maildir) - (member root-maildir (mapcar #'cdr +mu4e-gmail-accounts))))) - - ;; In my workflow, emails won't be moved at all. Only their flags/labels are - ;; changed. Se we redefine the trash and refile marks not to do any moving. - ;; However, the real magic happens in `+mu4e-gmail-fix-flags-h'. - ;; - ;; Gmail will handle the rest. - (defun +mu4e--mark-seen (docid _msg target) - (mu4e--server-move docid (mu4e--mark-check-target target) "+S-u-N")) - - (defvar +mu4e--last-invalid-gmail-action 0) - - (delq! 'delete mu4e-marks #'assq) - (setf (alist-get 'delete mu4e-marks) - (list - :char '("D" . "✘") - :prompt "Delete" - :show-target (lambda (_target) "delete") - :action (lambda (docid msg target) - (if (+mu4e-msg-gmail-p msg) - (progn (message "The delete operation is invalid for Gmail accounts. Trashing instead.") - (+mu4e--mark-seen docid msg target) - (when (< 2 (- (float-time) +mu4e--last-invalid-gmail-action)) - (sit-for 1)) - (setq +mu4e--last-invalid-gmail-action (float-time))) - (mu4e--server-remove docid)))) - (alist-get 'trash mu4e-marks) - (list :char '("d" . "▼") - :prompt "dtrash" - :dyn-target (lambda (_target msg) (mu4e-get-trash-folder msg)) - :action (lambda (docid msg target) - (if (+mu4e-msg-gmail-p msg) - (+mu4e--mark-seen docid msg target) - (mu4e--server-move docid (mu4e--mark-check-target target) "+T-N")))) - ;; Refile will be my "archive" function. - (alist-get 'refile mu4e-marks) - (list :char '("r" . "▼") - :prompt "rrefile" - :dyn-target (lambda (_target msg) (mu4e-get-refile-folder msg)) - :action (lambda (docid msg target) - (if (+mu4e-msg-gmail-p msg) - (+mu4e--mark-seen docid msg target) - (mu4e--server-move docid (mu4e--mark-check-target target) "-N"))) - #'+mu4e--mark-seen)) - - ;; This hook correctly modifies gmail flags on emails when they are marked. - ;; Without it, refiling (archiving), trashing, and flagging (starring) email - ;; won't properly result in the corresponding gmail action, since the marks - ;; are ineffectual otherwise. - (add-hook! 'mu4e-mark-execute-pre-hook - (defun +mu4e-gmail-fix-flags-h (mark msg) - (when (+mu4e-msg-gmail-p msg) - (pcase mark - (`trash (mu4e-action-retag-message msg "-\\Inbox,+\\Trash,-\\Draft")) - (`delete (mu4e-action-retag-message msg "-\\Inbox,+\\Trash,-\\Draft")) - (`refile (mu4e-action-retag-message msg "-\\Inbox")) - (`flag (mu4e-action-retag-message msg "+\\Starred")) - (`unflag (mu4e-action-retag-message msg "-\\Starred")))))))) - -;; -;;; Alerts - -(use-package! mu4e-alert - :after mu4e - :config - (setq doom-modeline-mu4e t) - - (mu4e-alert-enable-mode-line-display) - (mu4e-alert-enable-notifications) - - (when (version<= "1.6" mu4e-mu-version) - (defadvice! +mu4e-alert-filter-repeated-mails-fixed-a (mails) - "Filters the MAILS that have been seen already\nUses :message-id not :docid." - :override #'mu4e-alert-filter-repeated-mails - (cl-remove-if (lambda (mail) - (prog1 (and (not mu4e-alert-notify-repeated-mails) - (ht-get mu4e-alert-repeated-mails - (plist-get mail :message-id))) - (ht-set! mu4e-alert-repeated-mails - (plist-get mail :message-id) - t))) - mails))) - - (when IS-LINUX - (mu4e-alert-set-default-style 'libnotify) - - (defvar +mu4e-alert-bell-cmd '("paplay" . "/usr/share/sounds/freedesktop/stereo/message.oga") - "Cons list with command to play a sound, and the sound file to play. -Disabled when set to nil.") - - (setq mu4e-alert-email-notification-types '(subjects)) - (defun +mu4e-alert-grouped-mail-notification-formatter-with-bell (mail-group _all-mails) - "Default function to format MAIL-GROUP for notification. -ALL-MAILS are the all the unread emails" - (when +mu4e-alert-bell-cmd - (start-process "mu4e-alert-bell" nil (car +mu4e-alert-bell-cmd) (cdr +mu4e-alert-bell-cmd))) - (if (> (length mail-group) 1) - (let* ((mail-count (length mail-group)) - (first-mail (car mail-group)) - (title-prefix (format "You have %d unread emails" - mail-count)) - (field-value (mu4e-alert--get-group first-mail)) - (title-suffix (format (pcase mu4e-alert-group-by - (`:from "from %s:") - (`:to "to %s:") - (`:maildir "in %s:") - (`:priority "with %s priority:") - (`:flags "with %s flags:")) - field-value)) - (title (format "%s %s" title-prefix title-suffix))) - (list :title title - :body (s-join "\n" - (mapcar (lambda (mail) - (format "%s<b>%s</b> • %s" - (cond - ((plist-get mail :in-reply-to) "⮩ ") - ((string-match-p "\\`Fwd:" - (plist-get mail :subject)) " ⮯ ") - (t "  ")) - (truncate-string-to-width (or (caar (plist-get mail :from)) - (cdar (plist-get mail :from))) - 20 nil nil t) - (truncate-string-to-width - (replace-regexp-in-string "\\`Re: \\|\\`Fwd: " "" - (plist-get mail :subject)) - 40 nil nil t))) - mail-group)))) - (let* ((new-mail (car mail-group)) - (subject (plist-get new-mail :subject)) - (sender (caar (plist-get new-mail :from)))) - (list :title sender :body subject)))) - (setq mu4e-alert-grouped-mail-notification-formatter #'+mu4e-alert-grouped-mail-notification-formatter-with-bell))) diff --git a/.config/emacs/modules/email/mu4e/doctor.el b/.config/emacs/modules/email/mu4e/doctor.el @@ -1,15 +0,0 @@ -;;; email/mu4e/doctor.el -*- lexical-binding: t; -*- - -(unless (executable-find "mu") - (warn! "Couldn't find mu command. Mu4e requires this to work.")) - -(unless (or (executable-find "mbsync") - (executable-find "offlineimap")) - (warn! "Couldn't find mbsync or offlineimap command. \ -You may not have a way of fetching mail.")) - -(when (and (modulep! +org) - (not IS-WINDOWS)) - (unless (executable-find "identify") - (warn! "Couldn't find the identify command from imagemagick. \ -LaTeX fragment re-scaling with org-msg will not work."))) diff --git a/.config/emacs/modules/email/mu4e/packages.el b/.config/emacs/modules/email/mu4e/packages.el @@ -1,7 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; email/mu4e/packages.el - -(when (modulep! +org) - (package! org-msg :pin "7b1dfb96d558f6e5626e96d4f4a5150d55cb7eb2")) - -(package! mu4e-alert :pin "3c9af8c7994df0a1a4f0703552ea3beffb485ace") diff --git a/.config/emacs/modules/email/notmuch/README.org b/.config/emacs/modules/email/notmuch/README.org @@ -1,207 +0,0 @@ -#+title: :email notmuch -#+subtitle: Closest Emacs will ever be to multi-threaded -#+created: July 31, 2018 -#+since: 21.12.0 - -* Description :unfold: -This module turns Emacs into an email client using [[doom-package:notmuch]]. - -** Maintainers -*This module needs a maintainer.* [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +afew :: - Enable integration with [[https://github.com/afewmail/afew][afew]]. -- +org :: - Enable [[doom-package:org-mime]] for writing HTML emails using org-mode. - -** Packages -- [[doom-package:counsel-notmuch]] if [[doom-module::completion ivy]] -- [[doom-package:helm-notmuch]] if [[doom-module::completion helm]] -- [[doom-package:notmuch]] -- [[doom-package:org-mime]]* if [[doom-module:+org]] - -** TODO Hacks -#+begin_quote - 🔨 This module's hacks haven't been documented yet. [[doom-contrib-module:][Document them?]] -#+end_quote - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires: - -+ Either [[https://github.com/gauteh/lieer][gmailieer]] (default), [[https://isync.sourceforge.io/][mbsync]] or [[http://www.offlineimap.org/][offlineimap]] -- to sync mail with. -+ [[https://notmuchmail.org/][notmuch]] -- to index and tag your downloaded messages. -+ [[https://github.com/afewmail/afew][afew]] -- optionally to initially tag your downloaded messages. - -** TODO MacOS - -** Arch Linux -Run one of the following commands: -#+begin_src sh -pacman -S isync notmuch #mbsync -#+end_src -#+begin_src sh -pacman -S offlineimap notmuch -#+end_src - -See: [[https://wiki.archlinux.org/index.php/Notmuch][Arch Wiki - Notmuch]] - -** NixOS -#+begin_src nix -environment.systemPackages = with pkgs; [ - notmuch - # And one of the following - gmailieer - isync - offlineimap -]; -#+end_src - -[[https://github.com/Emiller88/dotfiles/blob/319841bd3b89e59b01d169137cceee3183aba4fc/modules/shell/mail.nix][An example of setting up mbsync and notmuch with home-manager]] - -** TODO openSUSE -** TODO Debian/Ubuntu - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -| Keymap | Command | Description | -|-----------------+--------------------+-----------------------------------------------| -| [[kbd:][<localleader> u]] | ~+notmuch/update~ | Download, sync, and index emails with notmuch | -| [[kbd:][<localleader> c]] | ~+notmuch/compose~ | Compose new email | - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** Downloading your email -To download your email you need a sync backend. Out of the box, this module -supports =Gmailier= (the default), =mbsync=, and =offlineimap= (ordered by -speed). You may define a custom one as well. The guides below will walk you -through setting them up with notmuch. - -Later, once you've set up a sync backend and downloaded your email, you must -index your email for the first time: -#+begin_src sh -notmuch new -#+end_src - -*** lieer -[[https://github.com/gauteh/lieer][Lieer]], formerly called Gmailieer, is the indexing tool used by default. To -install lieer, see the [[https://github.com/gauteh/lieer#installation][installation docs]]. - -*** offlineimap -To use [[https://www.offlineimap.org/][offlineimap]], change ~+notmuch-sync-backend~: -#+begin_src emacs-lisp -;; add to $DOOMDIR/config.el -(setq +notmuch-sync-backend 'offlineimap) -#+end_src - -Next, write a configuration file for =offlineimap=. [[https://github.com/OfflineIMAP/offlineimap/blob/master/offlineimap.conf][Here is a comprehensive -example]] and [[https://github.com/OfflineIMAP/offlineimap/blob/master/offlineimap.conf.minimal][another minimal one]]. - -As a real world example, [[https://github.com/hlissner/dotfiles/blob/5f146b6c39552c0cf38025406f5dba7389542b0a/shell/mu/.offlineimaprc][here is my old config]], where it is configured to -download mail to =$HOME/.mail=. I used [[https://www.passwordstore.org/][unix pass]] to securely store my login -credentials. - -Finally, download your email with ~$ offlineimap -o~. This may take a while, -especially if you have thousands of emails. - -*** mbsync -To use [[https://isync.sourceforge.io/][mbsync]], change ~+notmuch-sync-backend~: -#+begin_src emacs-lisp -(setq +notmuch-sync-backend 'mbsync) - -;; Use `mbsync-xdg' if your mbsync config lives in $XDG_CONFIG_HOME/isync: -(setq +notmuch-sync-backend 'mbsync-xdg) -#+end_src - -The steps needed to set up =notmuch= with =mbsync= are similar to the ones for -[[*offlineimap][offlineimap]]. - -Start with writing a =$HOME/.mbsyncrc= to store your configuration. An example -for GMAIL can be found on the [[https://wiki.archlinux.org/index.php/isync#Configuring][ArchWiki]] which will also explain how its -integration with notmuch for auto synchronization. A non-GMAIL example is -available as a gist [[https://gist.github.com/agraul/60977cc497c3aec44e10591f94f49ef0][here]]. - -Finally, download your email with ~$ mbsync --all~. This may take a while, but -will be quicker than =offlineimap=. - -*** Custom method -If you have a unique method for synchronizing your email, you can define your -own backend: -#+begin_src emacs-lisp -;; Set this to an arbitrary shell command -(setq +notmuch-sync-backend "my-notmuch-sync-cmd") -#+end_src - -** Sending mail -- [[https://notmuchmail.org/notmuch-emacs/#index6h2][notmuch docs: Sending mail]] -- [[https://notmuchmail.org/emacstips/#index11h2][notmuch docs: msmtp, message mode and multiple accounts]] -- [[https://notmuchmail.org/emacstips/#index12h2][notmuch docs: sending mail using smtpmail]] - -** Customize =*notmuch-hello*= buffer -It is possible to change the =*notmuch-hello*= buffer if you want to. -#+begin_src emacs-lisp -;; add to $DOOMDIR/config.el -(after! notmuch - (setq notmuch-show-log nil - notmuch-hello-sections `(notmuch-hello-insert-saved-searches - notmuch-hello-insert-alltags) - ;; To hide headers while composing an email - notmuch-message-headers-visible nil)) -#+end_src - -** Changing the =notmuch= landing page -You may want to forego the =*notmuch-hello*= buffer by having ~M-x =notmuch~ or -[[kbd:][<leader> o m]] take you straight to a search page. - -When using [[kbd:][<leader> o m]] the ~+notmuch-home-function~ is called. By default it -uses the ~notmuch~ function and so has the same familiar behavior of running a -vanilla install of notmuch-emacs. But, by overwriting this function you can run -a custom search as your landing page. -#+begin_src emacs-lisp -(setq +notmuch-home-function (lambda () (notmuch-search "tag:inbox"))) -#+end_src - -** Writing HTML Emails -The [[https://github.com/org-mime/org-mime][org-mime]] package provides functionality for composing emails in org-mode and -transforming them to HTML. This feature is enabled using the =+org= flag. - -Example use cases: -- To convert an email to an HTML email use ~M-x org-mime-htmlize~. -- To compose email using an org-mode editor buffer, use ~M-x - org-mime-edit-mail-in-org-mode~. - -If you'd like to make configuration changes to =org-mime=, you may do so -normally. By default the output of =org-mime-htmlize= includes section numbers, -a byline, and a table of contents. That's probably more formal than the emails -you're used to sending, so here's some example configuration that turns those -features off: -#+begin_src emacs-lisp -;; add to $DOOMDIR/config.el -(after! org-mime - (setq org-mime-export-options '(:section-numbers nil - :with-author nil - :with-toc nil))) -#+end_src - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/email/notmuch/autoload.el b/.config/emacs/modules/email/notmuch/autoload.el @@ -1,164 +0,0 @@ -;;; email/notmuch/autoload.el -*- lexical-binding: t; -*- - -(defvar +notmuch-workspace-name "*notmuch*" - "Name of the workspace created by `=notmuch', dedicated to notmuch.") - -;;;###autoload -(defun =notmuch () - "Activate (or switch to) `notmuch' in its workspace." - (interactive) - (condition-case-unless-debug e - (progn - (when (modulep! :ui workspaces) - (+workspace-switch +notmuch-workspace-name t)) - (if-let* ((win (cl-find-if (lambda (it) (string-match-p "^\\*notmuch" (buffer-name (window-buffer it)))) - (doom-visible-windows)))) - (select-window win) - (funcall +notmuch-home-function)) - (when (modulep! :ui workspaces) - (+workspace/display))) - ('error - (+notmuch/quit) - (signal (car e) (cdr e))))) - - -;; -;; Commands - -;;;###autoload -(defun +notmuch/quit () - "TODO" - (interactive) - ;; (+popup/close (get-buffer-window "*notmuch-hello*")) - (doom-kill-matching-buffers "^\\*notmuch") - (when (modulep! :ui workspaces) - (+workspace/delete +notmuch-workspace-name))) - -(defun +notmuch-get-sync-command () - "Return a shell command string to synchronize your notmuch mail with." - (let* ((afew-cmd "afew -a -t") - (sync-cmd - (pcase +notmuch-sync-backend - (`gmi - (concat "cd " +notmuch-mail-folder " && gmi sync && notmuch new")) - ((or `mbsync - `mbsync-xdg) ; DEPRECATED `mbsync-xdg' is now just `mbsync' - (format "mbsync %s -a && notmuch new" - (if-let (config-file - (doom-glob (or (getenv "XDG_CONFIG_HOME") - "~/.config") - "isync/mbsyncrc")) - (format "-c %S" (car config-file)) - ""))) - (`offlineimap - "offlineimap && notmuch new") - ((and (pred stringp) it) it) - (_ (user-error "Invalid notmuch backend specified: %S" - +notmuch-sync-backend))))) - (if (modulep! +afew) - (format "%s && %s" sync-cmd afew-cmd) - sync-cmd))) - -;;;###autoload -(defun +notmuch/update () - "Sync notmuch emails with server." - (interactive) - (let ((compilation-buffer-name-function (lambda (_) (format "*notmuch update*")))) - (with-current-buffer (compile (+notmuch-get-sync-command)) - (add-hook - 'compilation-finish-functions - (lambda (buf status) - (if (equal status "finished\n") - (progn - (delete-windows-on buf) - (bury-buffer buf) - (notmuch-refresh-all-buffers) - (message "Notmuch sync successful")) - (user-error "Failed to sync notmuch data"))) - nil - 'local)))) - -;;;###autoload -(defun +notmuch/search-delete () - (interactive) - (notmuch-search-add-tag +notmuch-delete-tags) - (notmuch-tree-next-message)) - -;;;###autoload -(defun +notmuch/tree-delete () - (interactive) - (notmuch-tree-add-tag +notmuch-delete-tags) - (notmuch-tree-next-message)) - -;;;###autoload -(defun +notmuch/show-delete () - "Mark email for deletion in notmuch-show" - (interactive) - (notmuch-show-add-tag +notmuch-delete-tags) - (notmuch-show-next-thread-show)) - -;;;###autoload -(defun +notmuch/search-spam () - (interactive) - (notmuch-search-add-tag +notmuch-spam-tags) - (notmuch-search-next-thread)) - -;;;###autoload -(defun +notmuch/tree-spam () - (interactive) - (notmuch-tree-add-tag +notmuch-spam-tags) - (notmuch-tree-next-message)) - -;;;###autoload -(defun +notmuch/compose () - "Compose new mail" - (interactive) - (notmuch-mua-mail - nil - nil - (list (cons 'From (completing-read "From: " (notmuch-user-emails)))))) - -;;;###autoload -(defun +notmuch/open-message-with-mail-app-notmuch-tree () - (interactive) - (let* ((msg-path (car (plist-get (notmuch-tree-get-message-properties) :filename))) - (temp (make-temp-file "notmuch-message-" nil ".eml"))) - (doom-call-process "cp" msg-path temp) - (start-process-shell-command "email" nil (format "xdg-open '%s'" temp)))) - -;;;###autoload -(defun +notmuch/open-message-with-mail-app-notmuch-show () - (interactive) - (let* ((msg-path (car (plist-get (notmuch-show-get-message-properties) :filename))) - (temp (make-temp-file "notmuch-message-" nil ".eml"))) - (doom-call-process "cp" msg-path temp) - (start-process-shell-command "email" nil (format "xdg-open '%s'" temp)))) - - -;;;###autoload -(defun +notmuch/show-filter-thread () - "Show the current thread with a different filter" - (interactive) - (setq notmuch-show-query-context (notmuch-read-query "Filter thread: ")) - (notmuch-show-refresh-view t)) - -;;;###autoload -(defun +notmuch-show-expand-only-unread-h () - (interactive) - (let ((unread nil) - (open (notmuch-show-get-message-ids-for-open-messages))) - (notmuch-show-mapc (lambda () - (when (member "unread" (notmuch-show-get-tags)) - (setq unread t)))) - (when unread - (let ((notmuch-show-hook (remove '+notmuch-show-expand-only-unread-h notmuch-show-hook))) - (notmuch-show-filter-thread "tag:unread"))))) - -;; -;; Advice - -;;;###autoload -(defun +notmuch-dont-confirm-on-kill-process-a (fn &rest args) - "Don't prompt for confirmation when killing notmuch sentinel." - (let (confirm-kill-processes) - (apply fn args))) diff --git a/.config/emacs/modules/email/notmuch/config.el b/.config/emacs/modules/email/notmuch/config.el @@ -1,129 +0,0 @@ -;;; email/notmuch/config.el -*- lexical-binding: t; -*- - -;; FIXME This module is a WIP! - -(defvar +notmuch-home-function #'notmuch - "Function for customizing the landing page for doom-emacs =notmuch.") - -(defvar +notmuch-sync-backend 'gmi - "Which backend to use to synchrone email. -Accepts a symbol or a shell command string. - -More specifically, this accepts one of the following symbols (see -`+notmuch-get-sync-command' definition for details): - - `gmi' Use gmailieer (https://github.com/gauteh/lieer) - `mbsync' Use isync (https://isync.sourceforge.io) - `offlineimap' Use offlineimap (https://www.offlineimap.org) - -OR a shell command string such as - - \"path/to/some/shell-script.sh\" - \"offlineimap && notmuch new && afew -n -t\" - \"mbsync %s -a && notmuch new && afew -n -t\"") - -(defvar +notmuch-mail-folder "~/.mail/account.gmail" - "Where your email folder is located (for use with gmailieer).") - -(defvar +notmuch-delete-tags '("+trash" "-inbox" "-unread") - "Tags applied to mark email for deletion. - -When replacing the +trash tag by a different tag such as -+deleted, you will need to update the notmuch-saved-searches -variable accordingly.") - -(defvar +notmuch-spam-tags '("+spam" "-inbox" "-unread") - "Tags applied to mark email as spam.") - - -;; -;;; Packages - -(use-package! notmuch - :defer t - :config - (set-company-backend! 'notmuch-message-mode - 'notmuch-company '(company-ispell company-yasnippet)) - - (set-popup-rule! "^\\*notmuch-hello" :side 'left :size 30 :ttl 0) - (set-popup-rule! "^\\*subject:" :size 0.6 :ttl 0) - - (defadvice! +notmuch-search-show-thread-a (fn &rest args) - "Give email buffers a sane name so they can be targeted via -`display-buffer-alist' (and the :ui popup module)." - :around #'notmuch-search-show-thread - (letf! (defun notmuch-show (thread-id &optional elide-toggle parent-buffer query-context buffer-name) - (funcall notmuch-show - thread-id elide-toggle parent-buffer query-context - (format "*subject:%s*" (substring buffer-name 1 -1)))) - (apply fn args))) - - (setq notmuch-fcc-dirs nil - message-kill-buffer-on-exit t - message-send-mail-function 'message-send-mail-with-sendmail - send-mail-function 'sendmail-send-it - ;; sendmail-program "/usr/local/bin/msmtp" - notmuch-search-result-format - '(("date" . "%12s ") - ("count" . "%-7s ") - ("authors" . "%-30s ") - ("subject" . "%-72s ") - ("tags" . "(%s)")) - notmuch-tag-formats - '(("unread" (propertize tag 'face 'notmuch-tag-unread))) - notmuch-saved-searches - '((:name "inbox" :query "tag:inbox not tag:trash" :key "i") - (:name "flagged" :query "tag:flagged" :key "f") - (:name "sent" :query "tag:sent" :key "s") - (:name "drafts" :query "tag:draft" :key "d")) - notmuch-archive-tags '("-inbox" "-unread")) - (setq-default notmuch-search-oldest-first nil) - - ;; only unfold unread messages in thread by default - (add-hook 'notmuch-show-hook #'+notmuch-show-expand-only-unread-h) - - (add-hook 'doom-real-buffer-functions #'notmuch-interesting-buffer) - - (advice-add #'notmuch-start-notmuch-sentinel :around #'+notmuch-dont-confirm-on-kill-process-a) - - ;; modeline doesn't have much use in these modes - (add-hook! '(notmuch-show-mode-hook - notmuch-tree-mode-hook - notmuch-search-mode-hook) - #'hide-mode-line-mode) - - (map! :localleader - :map (notmuch-hello-mode-map notmuch-search-mode-map notmuch-tree-mode-map notmuch-show-mode-map) - :desc "Compose email" "c" #'+notmuch/compose - :desc "Sync email" "u" #'+notmuch/update - :desc "Quit notmuch" "q" #'+notmuch/quit - :map notmuch-search-mode-map - :desc "Mark as deleted" "d" #'+notmuch/search-delete - :desc "Mark as spam" "s" #'+notmuch/search-spam - :map notmuch-tree-mode-map - :desc "Mark as deleted" "d" #'+notmuch/tree-delete - :desc "Mark as spam" "s" #'+notmuch/tree-spam)) - - -(use-package! org-mime - :when (modulep! +org) - :after (org notmuch) - :config (setq org-mime-library 'mml)) - - -(use-package! counsel-notmuch - :when (modulep! :completion ivy) - :commands counsel-notmuch - :after notmuch) - - -(use-package! helm-notmuch - :when (modulep! :completion helm) - :commands helm-notmuch - :after notmuch) - - -(use-package! consult-notmuch - :when (modulep! :completion vertico) - :commands consult-notmuch - :after notmuch) diff --git a/.config/emacs/modules/email/notmuch/packages.el b/.config/emacs/modules/email/notmuch/packages.el @@ -1,31 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; email/notmuch/packages.el - -(package! notmuch - :recipe (:pre-build - (with-temp-file "emacs/notmuch-version.el" - (insert-file-contents "emacs/notmuch-version.el.tmpl") - (re-search-forward "%VERSION%") - (replace-match - (format "\"%s+%s~%.7s\"" - (with-temp-buffer (insert-file-contents "version.txt") - (string-trim (buffer-string))) - (save-match-data - (let ((desc (doom-call-process "git" "describe" "--abbrev=7" "--match" "[0-9.]*"))) - (if (zerop (car desc)) - (car (last (split-string (cdr desc) "-") 2)) - "??"))) - (cdr (doom-call-process "git" "rev-parse" "HEAD"))) - t t))) - :pin "09f2ad8e853375930c63bca847f623bc722b9cc0") - -(when (modulep! +org) - (package! org-mime :pin "cc00afcf0291633324364c1c83bfe2833cfdc1bf")) -(when (modulep! :lang org) - (package! ol-notmuch :pin "ee3646627e47312a0c6ab0a5f6eba3baf8b20cb6")) -(when (modulep! :completion ivy) - (package! counsel-notmuch :pin "a4a1562935e4180c42524c51609d1283e9be0688")) -(when (modulep! :completion helm) - (package! helm-notmuch :pin "97a01497e079a7b6505987e9feba6b603bbec288")) -(when (modulep! :completion vertico) - (package! consult-notmuch :pin "d0d4129d45ccceddaeeaa3631eb42d5dd09a758b")) diff --git a/.config/emacs/modules/email/wanderlust/README.org b/.config/emacs/modules/email/wanderlust/README.org @@ -1,54 +0,0 @@ -#+title: :email wanderlust -#+subtitle: To boldly go where no mail has gone before -#+created: May 05, 2019 -#+since: 21.12.0 - -* Description :unfold: -#+begin_quote - 🔨 This module has no description. [[doom-contrib-module:][Write one?]] -#+end_quote - -** Maintainers -*This module needs a maintainer.* [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +gmail :: - Enable gmail-specific configuration for mail ~To~ or ~From~ a gmail address. - -** Packages -- [[doom-package:wanderlust]] - -** TODO Hacks -#+begin_quote - 🔨 This module's hacks haven't been documented yet. [[doom-contrib-module:][Document them?]] -#+end_quote - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* TODO Usage -#+begin_quote -🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote -🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote -🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/email/wanderlust/autoload.el b/.config/emacs/modules/email/wanderlust/autoload.el @@ -1,4 +0,0 @@ -;;; email/wanderlust/autoload.el -*- lexical-binding: t; -*- - -;;;###autoload -(defalias '=wanderlust #'wl) diff --git a/.config/emacs/modules/email/wanderlust/config.el b/.config/emacs/modules/email/wanderlust/config.el @@ -1,82 +0,0 @@ -;;; app/wanderlust/config.el -*- lexical-binding: t; -*- - -(use-package! wl - :defer t - :config - (setq mail-user-agent 'wl-user-agent - pgg-scheme 'gpg - mime-edit-split-message nil) - - (when (fboundp 'define-mail-user-agent) - (define-mail-user-agent - 'wl-user-agent - 'wl-user-agent-compose - 'wl-draft-send - 'wl-draft-kill - 'mail-send-hook)) - - (setq wl-demo nil - wl-stay-folder-window t - wl-init-file (expand-file-name "wl.el" doom-user-dir) - wl-folders-file (expand-file-name "folders.wl" doom-user-dir)) - - (setq wl-message-truncate-lines t - wl-summary-width 120 - wl-message-ignored-field-list - '(".*Received:" - ".*Path:" - ".*Id:" - "^References:" - "^Replied:" - "^Errors-To:" - "^Lines:" - "^Sender:" - ".*Host:" - "^Xref:" - "^Content-Type:" - "^Precedence:" - "^Status:" - "^X.*:" - "^MIME.*:" - "^In-Reply-To:" - "^Content-Transfer-Encoding:" - "^List-.*:") - wl-message-visible-field-list - '("^Message-Id:" - "^User-Agent:" - "^X-Mailer:" - "^X-Face:")) - - (when (modulep! +gmail) - (setq elmo-imap4-default-server "imap.gmail.com" - elmo-imap4-default-port 993 - elmo-imap4-default-authenticate-type 'clear ; CRAM-MD5 - elmo-imap4-default-user user-mail-address - elmo-imap4-default-stream-type 'ssl - elmo-imap4-set-seen-flag-explicitly t) - - (setq wl-smtp-connection-type 'starttls - wl-smtp-posting-port 587 - wl-smtp-authenticate-type "plain" - wl-smtp-posting-user user-mail-address - wl-smtp-posting-server "smtp.gmail.com" - wl-local-domain "gmail.com") - - (setq wl-default-folder "%inbox" - wl-draft-folder "%[Gmail]/Drafts" - wl-trash-folder "%[Gmail]/Trash" - wl-fcc-force-as-read t - wl-default-spec "%")) - - (setq wl-message-id-domain wl-local-domain) - - (when (modulep! :editor evil) - ;; Neither `wl-folder-mode' nor `wl-summary-mode' are correctly defined as - ;; major modes, so we cannot use `set-evil-initial-state!' here. - ;; In addition, `wl-folder-mode' won't start in `evil-emacs-state' through - ;; `evil-emacs-state-modes', and `wl-summary-mode' won't start in - ;; `evil-emacs-state' through `wl-summary-mode-hook'. - (add-hook! 'wl-folder-mode-hook #'evil-emacs-state) - (pushnew! evil-emacs-state-modes 'wl-summary-mode)) - - (add-hook 'mime-edit-mode-hook #'auto-fill-mode)) diff --git a/.config/emacs/modules/email/wanderlust/packages.el b/.config/emacs/modules/email/wanderlust/packages.el @@ -1,11 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; app/wanderlust/packages.el - -;; HACK These are wanderlust's dependencies (wanderlust depends on semi, semi -;; depends on flim, flim on apel), but they all have non-standard default -;; branches which straight cannot detect without our help. -(package! apel :recipe (:branch "apel-wl") :pin "82eb2325bd149dc57b43a9ce9402c6c6183e4052") -(package! flim :recipe (:branch "flim-1_14-wl") :pin "2cf5a7891090faca8de725b1d3743dcedf233ea2") -(package! semi :recipe (:branch "semi-1_14-wl") :pin "7d8df0ef2f483e2dc063a72099295f467e6bc2c8") - -(package! wanderlust :pin "77662986fd91cff991f502b19262227227740d52") diff --git a/.config/emacs/modules/input/README.org b/.config/emacs/modules/input/README.org @@ -1,10 +0,0 @@ -#+title: :input -#+created: May 13, 2019 -#+since: 2.0.9 - -* Description -Modules in this category extend Emacs support for additional keyboard layouts -and input methods for non-English languages. - -* Frequently asked questions -/This category has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] diff --git a/.config/emacs/modules/input/bidi/README.org b/.config/emacs/modules/input/bidi/README.org @@ -1,149 +0,0 @@ -#+title: :input bidi -#+subtitle: (tfel ot) thgir etirw uoy gnipleh -#+created: April 22, 2022 -#+since: 22.04.0 (#5526) - -* Description :unfold: -This module improves support for bidirectional text (bidi). Enable it if you -regularly write with languages that read right-to-left. As bidi support is -exceptionally user-specific, read on for additional instructions to customize it -to your needs. - -** Maintainers -- [[doom-user:][@iyefrat]] -- [[doom-user:][@ymarco]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module Flags -/This module has no flags./ - -** Packages -/This module doesn't install any packages./ - -** Hacks -/No hacks documented for this module./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* Usage -This module provides ~+bidi-mode~, a minor mode that improves the display of RTL -text by right-aligning lines that start with an RTL language, on a per-line -basis. Since exact use cases vary, turning on this mode is left to the user. - -It also provides easy font configuration for Hebrew and Arabic-derived scripts -(Arabic, Persian, Urdu, etc.) in ~+bidi-hebrew-font~ and ~+bidi-arabic-font~. -See [[Fonts]] for more information. If you use an RTL language that isn't covered by -these characters, open an issue requesting support for it. - -* Configuration -** Using ~+bidi-mode~ -~+bidi-mode~ is a local minor mode, meaning it has to be turned on a per-buffer -basis. - -If you want to have it on for all buffers, use ~+bidi-global-mode~: -#+begin_src emacs-lisp -;; in $DOOMDIR/config.el -(+bidi-global-mode 1) -#+end_src - -If you only need it for specific purposes, e.g. editing LaTeX documents, you -probably want to enable it through a hook: -#+begin_src emacs-lisp -(add-hook 'TeX-mode-hook #'+bidi-mode) -#+end_src - -This is also useful for adding specific functionality for when ~+bidi-mode~ is on. - -** Force RTL text alignment -By default, ~+bidi-mode~ will align paragraphs by the first character with -strong directionality. If you want to force all paragraphs to be aligned -right-to-left when ~+bidi-mode~ is on, add the following to your config: -#+begin_src emacs-lisp -(setq +bidi-paragraph-direction 'right-to-left) -#+end_src - -#+begin_quote - 🚧 Do not do this if you are using ~+bidi-global-mode~, it will mess up all of - the buffers in Emacs that use English, including things like the =M-x= - buffer. -#+end_quote - -** Input Methods -If bidi support is needed, it's likely that you want to easily switch between -English and your favorite RTL language. To do this without losing access to all -of the keybindings require English letters, you should use [[https://www.gnu.org/software/emacs/manual/html_node/emacs/Input-Methods.html][input methods]] to -switch languages instead of changing the system keyboard language. If you use a -non-qwerty layout, you will need extra configuration to keep the input method -consistent, see [[https://github.com/ymarco/doom-emacs-config/blob/2d655adb6a35c5cd3afcba24e76327f5444cf774/dvorak-config.el#L3-L18][here]] for an example for dvorak. - -Toggling the input method bound to [[kbd:][C-\]]. It prompts you to choose an input method -the first time you do this in a session, but you bypass this by setting the -default input method: -#+begin_src emacs-lisp -(setq default-input-method "hebrew") -#+end_src - -** Fonts -Many good English fonts lack good coverage for RTL languages, especially for -Hebrew and monospace fonts. To this end, we provide [[var:+bidi-hebrew-font]] and -[[var:+bidi-arabic-font]] as an easy way to override the default fonts, but only for -Hebrew and Arabic characters. They are set by default to =DejaVu Sans=, since it -has decent looking Hebrew and Arabic character support. - -#+begin_quote - 📌 If you are writing in an Arabic-derived script, such as Persian, Urdu, or - Pashto, you may want to change ~+bidi-arabic-font~ to one specific to your - language, especially if you want your script to be written in the Nastaliq - style. -#+end_quote - -If you use an RTL language the script of which isn't covered by the =hebrew= or -=arabic= unicode blocks, you can set a font override manually. For example: -#+begin_src emacs-lisp -(add-hook! 'after-setting-font-hook :append - (set-fontset-font t 'syriac (font-spec :family "DejaVu Sans"))) -#+end_src - -Make sure to use the correct unicode block name, see the documentation of -[[fn:set-fontset-font]] for more details. - -*** Smart Fontify -Since good bidi fonts are often not monospace (as is the default =DejaVu Sans=), -It usually looks better to have the surrounding spaces and punctuation in the -use the bidi font as well. This is the default behaviour, but you can turn this -off by setting: -#+begin_src emacs-lisp -(setq +bidi-want-smart-fontify nil) -#+end_src - -** Change Dictionary Language On Bidi Buffers -If you only use ~+bidi-mode~ in specific buffers, you might want to -automatically change the dictionary language there. For example: -#+begin_src emacs-lisp -(add-hook! '+bidi-mode-hook - (ispell-change-dictionary (if +bidi-mode "hebrew" "default"))) -#+end_src - -** Automatic input mode switching -You may want Emacs to guess when you want it to switch input methods. See [[https://github.com/ymarco/doom-emacs-config/blob/2d655adb6a35c5cd3afcba24e76327f5444cf774/hebrew-latex-config.el#L7-L21][here]] -and [[https://github.com/ymarco/doom-emacs-config/blob/2d655adb6a35c5cd3afcba24e76327f5444cf774/hebrew-latex-config.el#L99-L102][here]] for an example of how to get Emacs to switch to hebrew when entering -insert mode after a hebrew character, in LaTeX buffers. - -* Troubleshooting -[[doom-report:][Report an issue?]] - -** Nastaliq font display bug -If Emacs is having trouble properly displaying a Nastaliq font, try using one of -[[https://urdufonts.net/fonts/jameel-noori-nastaleeq-regular][these]] [[https://urdufonts.net/fonts/alvi-nastaleeq-regular][two]] fonts for [[var:+bidi-arabic-font]]. - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/input/bidi/config.el b/.config/emacs/modules/input/bidi/config.el @@ -1,93 +0,0 @@ -;;; input/bidi/config.el -*- lexical-binding: t; -*- - -(defvar +bidi-mode-map (make-sparse-keymap) - "Keymap for `+bidi-mode'.") - -(defvar +bidi-hebrew-font (font-spec :family "DejaVu Sans") - "Overriding font for hebrew script. -Must be a `font-spec', see `doom-font' for examples. - -WARNING: if you specify a size for this font it will hard-lock any usage of this -font to that size. It's rarely a good idea to do so!") - -(defface +bidi-hebrew-face `((t :font ,+bidi-hebrew-font)) "") - -(defvar +bidi-arabic-font (font-spec :family "DejaVu Sans") - "Overriding font for arabic and arabic-derived scripts. -Must be a `font-spec', see `doom-font' for examples. - -WARNING: if you specify a size for this font it will hard-lock any usage of this -font to that size. It's rarely a good idea to do so!") - -(defface +bidi-arabic-face `((t :font ,+bidi-arabic-font)) "") - -(defcustom +bidi-want-smart-fontify t - "Use bidi override fonts on surrounding space and punctuation as well. -Add `+bidi-smart-fontify-keywords' to `font-lock-keywords' on editable buffers -when `+bidi-mode' is on." - :type 'boolean) - -(defvar +bidi-smart-fontify-keywords - `((,(rx (any (#x0590 . #x05FF)) ; Hebrew - (group (one-or-more (any " " punctuation)))) - (1 '+bidi-hebrew-face t)) - (,(rx (or (any (#x0600 . #x06FF)) ; Arabic - (any (#x0750 . #x077F)) ; Arabic Supplement - (any (#x0870 . #x089F)) ; Arabic Extended-B - (any (#x08A0 . #x08FF))) ; Arabic Extended-A - (group (one-or-more (any " " punctuation)))) - (1 '+bidi-arabic-face t))) - - "`font-lock' keywords matching spaces and punctuation after RTL characters. -See the variable `font-lock-keywords' for information on the format.") - -(defcustom +bidi-paragraph-direction nil - "The value of `bidi-paragragh-direction' when `+bidi-mode' is on. -See the `bidi-paragraph-direction' for more info. - -Warning: do not change this if you are using `+bidi-global-mode'.'" - :type '(choice - (const :tag "Left to Right" left-to-right) - (const :tag "Right to Left" right-to-left) - (const :tag "Dynamic, according to paragraph text" nil))) - -;;;###autoload -(define-minor-mode +bidi-mode - "Minor mode for using bidirectional text in a buffer. - -Note that the whole buffer doesn't have to contain any -bidirectional text at all, this mode just makes bidi editing -easier." - :keymap +bidi-mode-map - (if +bidi-mode - (progn - (setq bidi-paragraph-direction +bidi-paragraph-direction ; Better paragraph alignment - bidi-paragraph-separate-re "^" ; No need for empty lines to switch alignment - bidi-paragraph-start-re "^" ; ^ - bidi-inhibit-bpa nil) ; Better bidi paren logic - (when (and +bidi-want-smart-fontify - (not buffer-read-only)) - (font-lock-add-keywords - nil - +bidi-smart-fontify-keywords - 'append) - (font-lock-flush))) - (setq bidi-paragraph-direction 'left-to-right - bidi-paragraph-separate-re nil - bidi-paragraph-start-re nil - bidi-inhibit-bpa t) - (when (and +bidi-want-smart-fontify - (not buffer-read-only)) - (font-lock-remove-keywords - nil - +bidi-smart-fontify-keywords) - (font-lock-flush)))) - -(define-globalized-minor-mode +bidi-global-mode +bidi-mode +bidi-mode) - -(add-hook! 'after-setting-font-hook - (defun +bidi-set-fonts-h () - (set-fontset-font t 'hebrew +bidi-hebrew-font) - (set-fontset-font t 'arabic +bidi-arabic-font) - (set-face-font '+bidi-arabic-face +bidi-arabic-font) - (set-face-font '+bidi-hebrew-face +bidi-hebrew-font))) diff --git a/.config/emacs/modules/input/chinese/README.org b/.config/emacs/modules/input/chinese/README.org @@ -1,78 +0,0 @@ -#+title: :input chinese -#+subtitle: Spend your 3 hours a week in Emacs -#+created: May 13, 2019 -#+since: 21.12.0 - -* Description :unfold: -This module adds support for traditional Chinese script by introducing two input -methods: Pinyin and Wubi. - -** Maintainers -*This module needs a maintainer.* [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +rime :: - Enables the [[https://rime.im/][rime]] backend for pyim. -- +childframe :: - Display pyim candidates in a [[https://www.gnu.org/software/emacs/manual/html_node/elisp/Child-Frames.html][child frame]] rather than overlay or tooltip. - -** Packages -- [[doom-package:ace-pinyin]] -- [[doom-package:chinese-wbim]] if [[doom-module:+wubi]] -- [[doom-package:evil-pinyin]] if [[doom-module::editor evil +everywhere]] -- [[doom-package:fcitx]] -- [[doom-package:liberime]] if [[doom-module:+rime]] -- [[doom-package:pangu-spacing]] -- [[doom-package:posframe]] if [[doom-module:+childframe]] -- [[doom-package:pyim]] unless [[doom-module:+wubi]] - -** Hacks -- ~org-html-paragraph~ has been modified to join consecutive Chinese lines into - a single long line without wanted spaced (when exporting org-mode to html). - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* TODO Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -#+begin_quote - 🔨 This module is missing install instructions. [[doom-contrib-module:][Write some?]] -#+end_quote - -If you want to use rime as the input method engine: -- Emacs must be built with dynamic module support, i.e. compiled with the - =--with-modules= option. -- You need =librime= installed on your system. -- You need =make=, =cmake= and a C compiler such as =gcc= so that liberime can - build =liberime-core.so=. - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** Using fcitx5 -Modify ~fcitx-remote-command~ to change the default: - -#+begin_src emacs-lisp -;; in $DOOMDIR/config.el -(setq fcitx-remote-command "fcitx5-remote") -#+end_src - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/input/chinese/config.el b/.config/emacs/modules/input/chinese/config.el @@ -1,88 +0,0 @@ -;;; input/chinese/config.el -*- lexical-binding: t; -*- - -(use-package! pyim - :after-call after-find-file pre-command-hook - :init - (setq pyim-dcache-directory (concat doom-cache-dir "pyim/")) - :config - (setq pyim-page-tooltip t - default-input-method "pyim") - - (after! evil-escape - (defun +chinese--input-method-p () - current-input-method) - (add-to-list 'evil-escape-inhibit-functions #'+chinese--input-method-p)) - - (when (modulep! +childframe) - (setq pyim-page-tooltip 'posframe)) - - ;; allow vertico/selectrum search with pinyin - (cond ((modulep! :completion vertico) - (advice-add #'orderless-regexp - :filter-return - (if (modulep! :editor evil +everywhere) - #'evil-pinyin--build-regexp-string - #'pyim-cregexp-build))) - ((modulep! :completion ivy) - (setq ivy-re-builders-alist '((t . pyim-cregexp-ivy)))))) - - -(use-package! liberime - :when (modulep! +rime) - :init - (setq liberime-auto-build t - liberime-user-data-dir (file-name-concat doom-cache-dir "rime"))) - - -(use-package! pyim-liberime - :when (modulep! +rime) - :after liberime - :config - (setq pyim-default-scheme 'rime)) - - -(use-package! pangu-spacing - :hook (text-mode . pangu-spacing-mode) - :config - ;; Always insert `real' space in org-mode. - (setq-hook! 'org-mode-hook pangu-spacing-real-insert-separtor t)) - - -(use-package! fcitx - :after evil - :config - (when (setq fcitx-remote-command - (or (executable-find "fcitx5-remote") - (executable-find "fcitx-remote"))) - (fcitx-evil-turn-on))) - - -(use-package! ace-pinyin - :after avy - :init (setq ace-pinyin-use-avy t) - :config (ace-pinyin-global-mode t)) - - -(use-package! evil-pinyin - :when (modulep! :editor evil +everywhere) - :after evil - :config - (setq-default evil-pinyin-with-search-rule 'always) - (global-evil-pinyin-mode 1)) - - -;; -;;; Hacks - -(defadvice! +chinese--org-html-paragraph-a (args) - "Join consecutive Chinese lines into a single long line without unwanted space -when exporting org-mode to html." - :filter-args #'org-html-paragraph - (cl-destructuring-bind (paragraph contents info) args - (let* ((fix-regexp "[[:multibyte:]]") - (fixed-contents - (replace-regexp-in-string - (concat "\\(" fix-regexp "\\) *\n *\\(" fix-regexp "\\)") - "\\1\\2" - contents))) - (list paragraph fixed-contents info)))) diff --git a/.config/emacs/modules/input/chinese/packages.el b/.config/emacs/modules/input/chinese/packages.el @@ -1,15 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; input/chinese/packages.el - -(package! pyim :pin "de7eff2a58d88b168e35c3c81484ea874991391c") -(package! fcitx :pin "12dc2638ddd15c8f6cfaecb20e1f428ab2bb5624") -(package! ace-pinyin :pin "47662c0b05775ba353464b44c0f1a037c85e746e") -(package! pangu-spacing :pin "2303013e5cd7852136f1429162fea0e1c8cb0221") -(when (modulep! +rime) - (package! liberime :pin "8291e22cd0990a99cb2f88ca67a9065a157f39af")) -(when (modulep! +childframe) - (package! posframe :pin "0d23bc5f7cfac00277d83ae7ba52c48685bcbc68")) -(when (modulep! :editor evil +everywhere) - (package! evil-pinyin - :recipe (:build (:not autoloads)) - :pin "3e9e501ded86f88e01a4edec5d526ab0fab879d7")) diff --git a/.config/emacs/modules/input/japanese/README.org b/.config/emacs/modules/input/japanese/README.org @@ -1,55 +0,0 @@ -#+title: :input japanese -#+subtitle: Ah, a man of culture -#+created: May 13, 2019 -#+since: 21.12.0 - -* Description :unfold: -This module adds support for Japanese script. - -** Maintainers -*This module needs a maintainer.* [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:avy-migemo]] -- [[doom-package:ddskk]] -- [[doom-package:migemo]] -- [[doom-package:pangu-spacing]] - -** Hacks -- ~org-html-paragraph~ has been modified to join consecutive Chinese lines into - a single long line without wanted spaced (when exporting org-mode to html). - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* TODO Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -- For incremental search with Migemo, one of the following is required: - - [[https://github.com/koron/cmigemo][cmigemo]] (recommended) - - or [[http://0xcc.net/migemo/][CVS Head Migemo]] - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/input/japanese/config.el b/.config/emacs/modules/input/japanese/config.el @@ -1,57 +0,0 @@ -;;; input/japanese/config.el -*- lexical-binding: t; -*- - -(use-package! migemo - :after-call after-find-file pre-command-hook - :init - (setq search-default-regexp-mode nil - migemo-options '("-q" "--emacs" "-i" "\a") - migemo-user-dictionary nil - migemo-regex-dictionary nil - migemo-coding-system 'utf-8-unix - migemo-directory (concat doom-data-dir "migemo/") - migemo-dictionary "/usr/local/share/migemo/utf-8/migemo-dict") - :config - (when (executable-find migemo-command) - (migemo-init) - - (use-package! avy-migemo - :after avy - :config (avy-migemo-mode 1)) - - (when (modulep! :completion helm) - (after! helm (helm-migemo-mode +1))))) - - -(use-package! pangu-spacing - :hook (text-mode . pangu-spacing-mode) - :init - ;; replacing `chinese-two-byte' by `japanese' - (setq pangu-spacing-chinese-before-english-regexp - "\\(?1:\\cj\\)\\(?2:[0-9A-Za-z]\\)" - pangu-spacing-chinese-after-english-regexp - "\\(?1:[0-9A-Za-z]\\)\\(?2:\\cj\\)" - ;; Always insert `real' space in text-mode including org-mode. - pangu-spacing-real-insert-separtor t)) - - -(use-package! skk - :general ("C-x j" #'skk-mode) - :config - (add-hook 'doom-escape-hook #'skk-mode-exit)) - - -;; -;;; Hacks - -(defadvice! +japanese--org-html-paragraph-a (args) - "Join consecutive Japanese lines into a single long line without unwanted space -when exporting org-mode to html." - :filter-args #'org-html-paragraph - (cl-destructuring-bind (paragraph contents info) args - (let* ((fix-regexp "[[:multibyte:]]") - (fixed-contents - (replace-regexp-in-string - (concat "\\(" fix-regexp "\\) *\n *\\(" fix-regexp "\\)") - "\\1\\2" - contents))) - (list paragraph fixed-contents info)))) diff --git a/.config/emacs/modules/input/japanese/doctor.el b/.config/emacs/modules/input/japanese/doctor.el @@ -1,5 +0,0 @@ -;;; input/japanese/doctor.el -*- lexical-binding: t; -*- - -(when (require 'migemo nil t) - (unless (executable-find migemo-command) - (warn! "Cannot find %S, migemo won't work" migemo-command))) diff --git a/.config/emacs/modules/input/japanese/packages.el b/.config/emacs/modules/input/japanese/packages.el @@ -1,7 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; input/japanese/packages.el - -(package! migemo :pin "f756cba3d5268968da361463c2e29b3a659a3de7") -(package! avy-migemo :pin "922a6dd82c0bfa316b0fbb56a9d4dd4ffa5707e7") -(package! ddskk :pin "c24a624884a3cfb0c28d6d5b9eb19e01387f0917") -(package! pangu-spacing :pin "2303013e5cd7852136f1429162fea0e1c8cb0221") diff --git a/.config/emacs/modules/input/layout/+azerty.el b/.config/emacs/modules/input/layout/+azerty.el @@ -1,81 +0,0 @@ -;;; input/layout/+azerty.el -*- lexical-binding: t; -*- - -;; NOTE: here is roughly what the translations are: -;; previous: [ -> é -;; next: ] -> è -;; ` -> ² -;; @ -> à - -(defun +layout-remap-keys-for-azerty-h () - (setq avy-keys '(?q ?s ?d ?f ?g ?h ?j ?k ?l ?m) - lispy-avy-keys '(?q ?s ?d ?f ?g ?h ?j ?k ?l ?m ?ù ?a ?z ?e ?r ?t ?y ?u ?i ?o ?p)) - (after! ace-window - (setq aw-keys '(?q ?s ?d ?f ?g ?h ?j ?k ?l ?m))) - (map! "C-z" 'evil-window-map) - (map! - :leader - :desc "Window" "z" 'evil-window-map - (:when (modulep! :ui popup) - :desc "Toggle last popup" "é" #'+popup/toggle) - :desc "Switch to last buffer" "²" #'evil-switch-to-windows-last-buffer - (:when (modulep! :ui workspaces) - (:prefix-map ("TAB" . "workspace") - :desc "Switch to last workspace" "²" #'+workspace/other - :desc "Previous workspace" "é" #'+workspace/switch-left - :desc "Next workspace" "è" #'+workspace/switch-right)) - (:prefix-map ("b" . "buffer") - :desc "Previous buffer" "é" #'previous-buffer - :desc "Next buffer" "è" #'next-buffer) - (:prefix-map ("g" . "git") - (:when (modulep! :ui vc-gutter) - :desc "Jump to previous hunk" "é" #'git-gutter:previous-hunk - :desc "Jump to next hunk" "è" #'git-gutter:next-hunk)))) - -(defun +layout-remap-evil-keys-for-azerty-h () - (map! :nv "à" #'evil-execute-macro - :nv "²" #'evil-goto-mark - (:when (modulep! :checkers spell) - :m "és" #'+spell/previous-error - :m "ès" #'+spell/next-error) - :n "è SPC" #'+evil/insert-newline-below - :n "é SPC" #'+evil/insert-newline-above - :n "èb" #'next-buffer - :n "éb" #'previous-buffer - :n "èf" #'+evil/next-file - :n "éf" #'+evil/previous-file - :m "èu" #'+evil:url-encode - :m "éu" #'+evil:url-decode - :m "èy" #'+evil:c-string-encode - :m "éy" #'+evil:c-string-decode - (:when (modulep! :ui vc-gutter) - :m "èd" #'git-gutter:next-hunk - :m "éd" #'git-gutter:previous-hunk) - (:when (modulep! :ui hl-todo) - :m "èt" #'hl-todo-next - :m "ét" #'hl-todo-previous) - (:when (modulep! :ui workspaces) - :n "èw" #'+workspace/switch-right - :n "éw" #'+workspace/switch-left) - :m "è#" #'+evil/next-preproc-directive - :m "é#" #'+evil/previous-preproc-directive - :m "èa" #'evil-forward-arg - :m "éa" #'evil-backward-arg - :m "èc" #'+evil/next-comment - :m "éc" #'+evil/previous-comment - :m "èe" #'next-error - :m "ée" #'previous-error - :n "èF" #'+evil/next-frame - :n "éF" #'+evil/previous-frame - :m "èh" #'outline-next-visible-heading - :m "éh" #'outline-previous-visible-heading - :m "èm" #'+evil/next-beginning-of-method - :m "ém" #'+evil/previous-beginning-of-method - :m "èM" #'+evil/next-end-of-method - :m "éM" #'+evil/previous-end-of-method - :n "éo" #'+evil/insert-newline-above - :n "èo" #'+evil/insert-newline-below - :nv "gà" #'+evil:apply-macro)) - -(+layout-remap-keys-for-azerty-h) -(when (modulep! :editor evil) - (+layout-remap-evil-keys-for-azerty-h)) diff --git a/.config/emacs/modules/input/layout/+bepo.el b/.config/emacs/modules/input/layout/+bepo.el @@ -1,295 +0,0 @@ -;;; input/layout/+bepo.el -*- lexical-binding: t; -*- - -(defvar +layout-bepo-cr-rotation-style 'ergodis - "Modify this variable in your $DOOMDIR/init.el -Style of binding rotation for the cr keys. -If 'ergodis, then the module maps the old 'c' bindings to 'l' and the old 'r' to 'h', as -the 'change' function is used more often and 'l' is easier to reach than 'h' in bépo. - -If 'strict, the module does a normal swap and 'c' bindings go to 'h', 'r' bindings go to 'l'. - -In all cases, 'h' functions go to 'c' and 'l' ones go to 'r' so the navigation keys still feel vim-like.") - -;; Highlight non breaking spaces as error in prog modes only -;; REVIEW `nobreak-char-display' is defined in xdisp.c; will that work in non-X -;; builds? From early observations in sway+pgtk, it does not. -(setq nobreak-char-display t) -(set-face-attribute 'nobreak-space nil :underline t) - - -;; -;;; Initializers - -;; TODO Separate each package into their own hook, so users can -;; enable/disable/add their own per-package remappings. - -(defun +layout-remap-keys-for-bepo-h () - (setq avy-keys '(?a ?u ?i ?e ?, ?c ?t ?s ?r ?n) - lispy-avy-keys '(?a ?u ?i ?e ?, ?c ?t ?s ?r ?n ?m ?b ?é ?p ?o ?è ?v ?d ?l ?j ?z)) - - ;; :ui window-select settings, ignoring +numbers flag for now - (after! ace-window - (setq aw-keys '(?a ?u ?i ?e ?, ?c ?t ?s ?r ?n))) - (after! switch-window - (setq switch-window-shortcut-style 'qwerty - switch-window-qwerty-shortcuts '("a" "u" "i" "e" "," "c" "t" "s" "r"))) - - (map! "C-é" 'evil-window-map) - (map! :leader - :desc "Window" "é" evil-window-map - (:when (modulep! :ui popup) - :desc "Toggle last popup" "#" #'+popup/toggle) - (:when (modulep! :ui workspaces) - :desc "Switch buffer" "«" #'switch-to-buffer) - :desc "Switch to last buffer" "$" #'evil-switch-to-windows-last-buffer - (:when (modulep! :ui workspaces) - (:prefix-map ("TAB" . "workspace") - :desc "Switch to last workspace" "$" #'+workspace/other - :desc "Next workspace" ")" #'+workspace/switch-right - :desc "Previous workspace" "(" #'+workspace/switch-left)) - (:prefix-map ("b" . "buffer") - :desc "Previous buffer" "(" #'previous-buffer - :desc "Next buffer" ")" #'next-buffer) - (:prefix-map ("c" . "code") - :desc "Jump to documentation" "S" #'+lookup/documentation) - (:prefix-map ("g" . "git") - (:when (modulep! :ui vc-gutter) - :desc "Jump to next hunk" ")" #'git-gutter:next-hunk - :desc "Jump to previous hunk" "(" #'git-gutter:previous-hunk)) - (:prefix-map ("p" . "project") - :desc "Browse other project" "»" #'doom/browse-in-other-project))) - -(defun +layout-remap-evil-keys-for-bepo-h () - ;; "ts" would be a little too common for an evil escape sequence - (setq evil-escape-key-sequence "gq") - (setq evil-markdown-movement-bindings '((up . "s") - (down . "t") - (left . "c") - (right . "r")) - evil-org-movement-bindings '((up . "s") - (down . "t") - (left . "c") - (right . "r"))) - (+layout-bepo-rotate-ts-bare-keymap '(read-expression-map)) - (+layout-bepo-rotate-bare-keymap '(evil-window-map) +layout-bepo-cr-rotation-style) - (+layout-bepo-rotate-evil-keymap +layout-bepo-cr-rotation-style) - ;; Remap the visual-mode-map bindings if necessary - ;; See https://github.com/emacs-evil/evil/blob/7d00c23496c25a66f90ac7a6a354b1c7f9498162/evil-integration.el#L478-L501 - ;; Using +layout-bepo-rotate-keymaps is impossible because `evil-define-minor-mode-key' doesn't - ;; provide an actual symbol to design the new keymap with, and instead stuff the keymap in - ;; an auxiliary-auxiliary `minor-mode-map-alist'-like variable. - (after! evil-integration - (when evil-respect-visual-line-mode - (map! :map visual-line-mode-map - :m "t" #'evil-next-visual-line - ;; _Not_ remapping gj and gk because they aren't remapped - ;; consistently across all Emacs. - :m "s" #'evil-previous-visual-line - :m "È" #'evil-beginning-of-visual-line - :m "gÈ" #'evil-beginning-of-line - :m "$" #'evil-end-of-visual-line - :m "g$" #'evil-end-of-line - :m "V" #'evil-visual-screen-line))) - - (map! :i "C-t" #'+default-newline - (:when (modulep! :editor multiple-cursors) - :prefix "gz" - :nv "t" #'evil-mc-make-cursor-move-next-line - :nv "s" #'evil-mc-make-cursor-move-prev-line - ;; The old toggle mapping (t) is made available both on "T" for - ;; mnemonics and "j" as a "classic" rotation - :nv "T" #'+multiple-cursors/evil-mc-toggle-cursors - :nv "j" #'+multiple-cursors/evil-mc-toggle-cursors) - (:when (modulep! :ui popup) - :n "C-$" #'+popup/toggle - :n "C-#" #'+popup/raise)) - (after! treemacs - (+layout-bepo-rotate-ts-bare-keymap '(evil-treemacs-state-map))) - (after! (:or helm ivy vertico icomplete) - (+layout-bepo-rotate-keymaps - '(minibuffer-local-map - minibuffer-local-ns-map - minibuffer-local-completion-map - minibuffer-local-must-match-map - minibuffer-local-isearch-map - read-expression-map)) - (+layout-bepo-rotate-bare-keymap - '(minibuffer-local-map - minibuffer-local-ns-map - minibuffer-local-completion-map - minibuffer-local-must-match-map - minibuffer-local-isearch-map - read-expression-map) - +layout-bepo-cr-rotation-style)) - (after! ivy - (+layout-bepo-rotate-bare-keymap '(ivy-minibuffer-map ivy-switch-buffer-map) +layout-bepo-cr-rotation-style) - (+layout-bepo-rotate-keymaps '(ivy-minibuffer-map ivy-switch-buffer-map))) - (after! swiper - (map! :map swiper-map "C-s" nil)) - (after! helm - (+layout-bepo-rotate-bare-keymap '(helm-map) +layout-bepo-cr-rotation-style) - (+layout-bepo-rotate-keymaps '(helm-map))) - (after! helm-rg - (+layout-bepo-rotate-bare-keymap '(helm-rg-map) +layout-bepo-cr-rotation-style) - (+layout-bepo-rotate-keymaps '(helm-rg-map))) - (after! helm-files - (+layout-bepo-rotate-bare-keymap '(helm-read-file-map) +layout-bepo-cr-rotation-style) - (+layout-bepo-rotate-keymaps '(helm-read-file-map))) - (after! company - (+layout-bepo-rotate-bare-keymap '(company-active-map company-search-map) +layout-bepo-cr-rotation-style)) - (after! evil-snipe - (+layout-bepo-rotate-keymaps - '(evil-snipe-local-mode-map evil-snipe-override-local-mode-map))) - (after! eshell - (add-hook 'eshell-first-time-mode-hook (lambda () (+layout-bepo-rotate-keymaps '(eshell-mode-map))) 99)) - (after! lispyville - ;; <> en direct - (general-translate-key '(normal motion) 'lispyville-mode-map - "«" "<" - "»" ">")) - (after! lsp-ui - (+layout-bepo-rotate-ts-bare-keymap '(lsp-ui-peek-mode-map))) - (after! org - (defadvice! doom-bepo--org-completing-read (&rest args) - "Completing-read with SPACE being a normal character, and C-c mapping left alone." - :override #'org-completing-read - (let ((enable-recursive-minibuffers t) - (minibuffer-local-completion-map - (copy-keymap minibuffer-local-completion-map))) - (define-key minibuffer-local-completion-map " " 'self-insert-command) - (define-key minibuffer-local-completion-map "?" 'self-insert-command) - (define-key minibuffer-local-completion-map - (cond - ((eq +layout-bepo-cr-rotation-style 'ergodis) - (kbd "C-l !")) - (t - (kbd "C-h !"))) - 'org-time-stamp-inactive) - (apply #'completing-read args))) - ;; Finalizing an Org-capture become `C-l C-c` (or `C-r C-c`) on top of `ZZ` - (+layout-bepo-rotate-bare-keymap '(org-capture-mode-map) +layout-bepo-cr-rotation-style)) - (after! (evil org evil-org) - ;; FIXME: This map! call is being interpreted before the - ;; map! call in (use-package! evil-org :config) in modules/lang/org/config.el - ;; Therefore, this map! needs to be reevaluated to have effect. - ;; Need to find a way to call the code below after the :config block - ;; in :lang org code - - ;; Direct access for "unimpaired" like improvements - (map! :map evil-org-mode-map - ;; evil-org-movement bindings having "c" and "r" means - ;; C-r gets mapped to `org-shiftright' in normal and insert state. - ;; C-c gets mapped to `org-shiftleft' in normal and insert state. - :ni "C-r" nil - :ni "C-c" nil - :ni "C-»" #'org-shiftright - :ni "C-«" #'org-shiftleft - :m ")" nil - :m "(" nil - :m "]" #'evil-org-forward-sentence - :m "[" #'evil-org-backward-sentence - :m ")h" #'org-forward-heading-same-level - :m "(h" #'org-backward-heading-same-level - :m ")l" #'org-next-link - :m "(l" #'org-previous-link - :m ")c" #'org-babel-next-src-block - :m "(c" #'org-babel-previous-src-block)) - (after! (evil org evil-org-agenda) - (+layout-bepo-rotate-bare-keymap '(org-agenda-keymap) +layout-bepo-cr-rotation-style) - (+layout-bepo-rotate-keymaps '(evil-org-agenda-mode-map))) - (after! notmuch - ;; Without this, "s" is mapped to `notmuch-search' and takes precedence over - ;; the evil command to go up one line - (map! :map notmuch-common-keymap :n "s" nil) - (map! :map notmuch-common-keymap "s" nil)) - (after! (evil info) - ;; Without this, "s" stays mapped to 'Info-search (in the "global" - ;; `Info-mode-map') and takes precedence over the evil command to go up one - ;; line (remapped in `Info-mode-normal-state-map'). Same for "t" that is - ;; `Info-top-node' in the "global" `Info-mode-map' - (map! :map Info-mode-map - "s" nil - "t" nil)) - - - ;; Start of the Magit zone - ;; - ;; The magit zone needs to be special because evil-collection and magit and - ;; this module don't fully agree on the order with which features, keymaps, - ;; overriding keymaps, and evil-collection-setup-hook are run. - ;; - ;; This is _probably_ more complex than what it needs to be, but the - ;; interactions between all packages are so hard to track that a - ;; trial-and-error approach has been used to arrive at this result. - (after! (evil magit-section) - (+layout-bepo-rotate-ts-bare-keymap - '(magit-section-mode-map))) - (after! (evil magit-log) - (+layout-bepo-rotate-keymaps - '(magit-log-read-revs-map - magit-log-mode-map - ;; NOTE: magit-cherry-mode could be moved of magit-log anyday, be - ;; careful - magit-cherry-mode-map))) - (after! (evil magit-reflog) - (+layout-bepo-rotate-keymaps - '(magit-reflog-mode-map))) - (after! (evil magit-status) - (+layout-bepo-rotate-keymaps - '(magit-status-mode-map - magit-staged-section-map - magit-unstaged-section-map - magit-untracked-section-map))) - (after! (evil magit-diff) - (+layout-bepo-rotate-keymaps - '(magit-diff-mode-map - magit-diff-section-base-map))) - (after! (evil magit-process) - (+layout-bepo-rotate-keymaps - '(magit-process-mode-map))) - (after! (evil magit-refs) - (+layout-bepo-rotate-keymaps - '(magit-refs-mode-map))) - (after! (evil magit-blob) - (+layout-bepo-rotate-keymaps - '(magit-blob-mode-map))) - (after! (evil magit) - (+layout-bepo-rotate-ts-bare-keymap - '(magit-mode-map)) - ;; Without this, "s" is mapped to `magit-delete-thing' (the old "k" for "kill") and - ;; takes precedence over the evil command to go up one line - ;; :nv doesn't work on this, needs to be the bare map. - ;; This is the output of `describe-function `magit-delete-thing' when we add :nv or :nvm - ;; Key Bindings - ;; evil-collection-magit-mode-map-backup-map <normal-state> x - ;; evil-collection-magit-mode-map-backup-map <visual-state> x - ;; evil-collection-magit-mode-map-backup-map k - ;; evil-collection-magit-mode-map-normal-state-backup-map x - ;; evil-collection-magit-mode-map-visual-state-backup-map x - ;; magit-mode-map <normal-state> x - ;; magit-mode-map <visual-state> x - ;; magit-mode-map s - ;; Same thing for t, which gets mapped to `magit-quick-status' - (map! :map magit-mode-map - "s" nil - "t" nil) - (+layout-bepo-rotate-keymaps - '(magit-mode-map))) - ;; End of the Magit zone - - - (after! evil-easymotion - ;; Use "gé" instead of default "gs" to avoid conflicts w/org-mode later - (evilem-default-keybindings "gé") - (+layout-bepo-rotate-bare-keymap '(evilem-map) +layout-bepo-cr-rotation-style))) - - -;; -;;; Bootstrap - -(+layout-remap-keys-for-bepo-h) -(when (modulep! :editor evil) - (+layout-remap-evil-keys-for-bepo-h) - (add-hook! 'evil-collection-setup-hook - (defun +layout-bepo-rotate-evil-collection-keymap (_mode mode-keymaps &rest _rest) - (+layout-bepo-rotate-keymaps mode-keymaps)))) diff --git a/.config/emacs/modules/input/layout/README.org b/.config/emacs/modules/input/layout/README.org @@ -1,155 +0,0 @@ -#+title: :input layout -#+subtitle: auie,ctsrnm is the superior home row -#+created: Jun 29, 2020 -#+since: 21.12.0 - -* Description :unfold: -This module provides barebones support for using Doom with non-qwerty keyboard -layouts. - -** Maintainers -- [[doom-user:][@gagbo]] ([[kbd:][+bepo]]) - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +azerty :: - Remap keybinds to accommodate the [[https://en.wikipedia.org/wiki/AZERTY][Azerty keyboard layout]]. -- +bepo :: - Remap keybinds to accommodate the [[https://en.wikipedia.org/wiki/B%C3%89PO][BÉPO keyboard layout]] (version 1.1, in - particular). - -** Packages -/This module doesn't install any packages./ - -** TODO Hacks -#+begin_quote - 🔨 This module's hacks haven't been documented yet. [[doom-contrib-module:][Document them?]] -#+end_quote - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** Bépo -Support for the bépo layout includes: -- Setting Avy keys to the correct home row keys -- Changing navigation keys to [[kbd:][c]], [[kbd:][t]], [[kbd:][s]], and [[kbd:][r]] - + old [[kbd:][t]] is mapped to [[kbd:][j]] - + old [[kbd:][s]] is mapped to [[kbd:][k]] (i.e. staging in the magit status buffer is done with - [[kbd:][k]]) - + See [[*Configuration][Configuration]] to see where old [[kbd:][c]] and [[kbd:][r]] functions - are remapped -- Bind [[kbd:][<>]] functions to [[kbd:][«»]] keys when possible -- Bind [[kbd:][[]]] functions to [[kbd:][()]] keys when possible (the "unimpaired-like" bindings) -- Bind [[kbd:][é]] key to [[kbd:][w]] functions when possible -- Bind [[kbd:][è]] key to useful functions when possible -- Bind [[kbd:][`~]] functions to [[kbd:][$#]] keys when possible - -*** Easymotion -If you use [[doom-package:evil-easymotion]], then all the bindings that were on [[kbd:][gs]] have been -moved to [[kbd:][gé]]. - -In short : [[kbd:][g s j]] -> [[kbd:][g é t]] (~evilem-motion-next-line~). And so on. - -*** Leaving mnemonics alone when possible -Exchanging [[kbd:][h]]/[[kbd:][j]]/[[kbd:][k]]/[[kbd:][l]] to [[kbd:][c]]/[[kbd:][t]]/[[kbd:][s]]/[[kbd:][r]] has the effect of destroying a few mnemonics: the -change operator becomes [[kbd:][l]] for example, or the window split becomes [[kbd:][SPC é k]]. - -The module tries to limit those changes to the minimum, especially in special -buffers. A concrete example is magit. - -As the =magit: project= buffer (obtained with ~M-x magit-status~) does not need -left-right navigation, keys [[kbd:][c]], [[kbd:][r]], [[kbd:][h]], and [[kbd:][l]] keep their "expected" bindings, while -[[kbd:][t]], [[kbd:][s]], [[kbd:][j]], and [[kbd:][k]] are flipped: -- checking the log from a magit buffer is still on [[kbd:][l]] -- staging a file/region has been moved to [[kbd:][k]] - -*** Possible contributions -**** Avoid [[kbd:][g]] and [[kbd:][z]] to be used too often -A nice addition in the future might be to have all the normal mode bindings that -start with [[kbd:][g]] start with [[kbd:][,]] instead to avoid the curl on these common bindings. -This is *not* implemented for the time being. - -The same thing could be done to [[kbd:][z]], potentially using [[kbd:][à]] instead. - -**** Proper minor mode -Also, implementing all those changes as a minor we could flip on and off would -help with adoption - -**** Put "word" text objects to é instead of w -"inside word" and "around word" are [[kbd:][iw]] and [[kbd:][aw]], which use the very poorly rated [[kbd:][w]] -key in the bépo layout. Finding a way to use [[kbd:][é]] or even [[kbd:][è]] more for these would be -a welcome change - -*** Org-mode -[[doom-package:evil-org]] allows to define ~evil-org-movement-bindings~ to automatically map -movement bindings on non-hjkl keys. It maps automatically keys to [[kbd:][C-c]] and [[kbd:][C-r]] in -normal and insert states though, and it's not really user friendly in Emacs to -remap those. - -Therefore, in ~org-mode~: -- ~org-shiftright~ is bound to [[kbd:][C-»]] -- ~org-shiftleft~ is bound to [[kbd:][C-«]] - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** Bépo -=+layout-bepo-cr-rotation-style= controls whether: -- =qwerty-c= functions are mapped on =bépo-l= key, and =qwerty-r= functions on - =bépo-h= key (~'ergodis~), or -- =qwerty-c= functions are mapped on =bépo-h= key, and =qwerty-r= functions on - =bépo-l= key (~'strict~) - -~'strict~ would be the logical choice but the [[kbd:][c]] functions are used more often -than the [[kbd:][r]] ones so [[https://bepo.fr/wiki/Vim#Principe][Ergodis]] advises to actually put all the [[kbd:][c]] functions on the -key that does not need a curl. - -* Troubleshooting -[[doom-report:][Report an issue?]] - -** Outstanding issues (contributions welcome) -*** Bépo -- In [[doom-package:eshell]], the key [[kbd:][c]] is still bound to ~evil-collection-eshell-evil-change~ in - normal mode. - -** How to investigate an issue ? -If a key is misbehaving, use ~M-x describe-key~ ([[kbd:][C-h k]] or [[kbd:][SPC h k]] or [[kbd:][F1 k]]) to -see the command bound to the key, and more importantly in which keymap it is -bound. - -You should ignore all ~evil-collection-*-backup-map~ keymaps, as they are -artifacts from ~evil-collection-translate-key~ and those maps are actually not -active. - -Most likely the solution is to call one of the "key rotation" functions on the -relevant keymaps. - -** How to deactivate the new bindings and go back to the old ones ? -If you are learning a new layout you might want to go back to tho old one to -"get work done". Sadly the only way is to comment out the module, run ~$ doom -sync~ and restart emacs. - -Restoring the session [[kbd:][SPC q l]] by default helps to lower the impact of the -restart. - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/input/layout/autoload/bepo.el b/.config/emacs/modules/input/layout/autoload/bepo.el @@ -1,416 +0,0 @@ -;;; input/layout/autoload/bepo.el -*- lexical-binding: t; -*- -;;;###if (modulep! +bepo) - -;;;###autoload -(defun +layout-bepo-rotate-ts-bare-keymap (keymaps) - "Rotate [jk] with [ts] in KEYMAP." - (evil-collection-translate-key nil keymaps - "t" "j" - "T" "J" - "s" "k" - "S" "K" - "j" "t" - "J" "T" - "k" "s" - "K" "S" - (kbd "C-t") (kbd "C-j") - (kbd "C-s") (kbd "C-k") - (kbd "C-j") (kbd "C-t") - (kbd "C-k") (kbd "C-s") - (kbd "M-t") (kbd "M-j") - (kbd "M-s") (kbd "M-k") - (kbd "M-j") (kbd "M-t") - (kbd "M-k") (kbd "M-s") - (kbd "C-S-t") (kbd "C-S-j") - (kbd "C-S-s") (kbd "C-S-k") - (kbd "C-S-j") (kbd "C-S-t") - (kbd "C-S-k") (kbd "C-S-s") - (kbd "M-S-t") (kbd "M-S-j") - (kbd "M-S-s") (kbd "M-S-k") - (kbd "M-S-j") (kbd "M-S-t") - (kbd "M-S-k") (kbd "M-S-s"))) - -;;;###autoload -(defun +layout-bepo-rotate-é-quotes-bare-keymap (keymaps) - "Rotate [w<>] with [é«»] in KEYMAP." - (evil-collection-translate-key nil keymaps - "é" "w" - "É" "W" - "«" "<" - "»" ">" - (kbd "C-é") (kbd "C-w") - (kbd "C-«") (kbd "C-<") - (kbd "C-»") (kbd "C->") - (kbd "M-é") (kbd "M-w") - (kbd "M-«") (kbd "M-<") - (kbd "M-»") (kbd "M->") - (kbd "C-S-é") (kbd "C-S-w") - (kbd "C-S-«") (kbd "C-S-<") - (kbd "C-S-»") (kbd "C-S->") - (kbd "M-S-é") (kbd "M-S-w") - (kbd "M-S-«") (kbd "M-S-<") - (kbd "M-S-»") (kbd "M-S->"))) - -;;;###autoload -(defun +layout-bepo-rotate-cr-bare-keymap (keymaps &optional cr-style) - "Rotate [hl] with [cr] in KEYMAP. - -If CR-STYLE is nil or 'ergodis, the old 'c' bindings will be mapped on 'l' and -the old 'r' on 'h'. - -Otherwise if CR-STYLE is 'strict, the old 'c' bindings will be mapped on 'h' and -the old 'r' on 'l'. - -Undefined behaviour in other cases, for forward compatibility." - (let ((cr-style (or cr-style +layout-bepo-cr-rotation-style))) - (evil-collection-translate-key nil keymaps - "c" "h" - "C" "H" - "r" "l" - "R" "L" - (kbd "C-c") (kbd "C-h") - (kbd "C-r") (kbd "C-l") - (kbd "M-c") (kbd "M-h") - (kbd "M-r") (kbd "M-l") - (kbd "C-S-c") (kbd "C-S-h") - (kbd "C-S-r") (kbd "C-S-l") - (kbd "M-S-c") (kbd "M-S-h") - (kbd "M-S-r") (kbd "M-S-l")) - (if (eq cr-style 'ergodis) - (evil-collection-translate-key nil keymaps - "h" "r" - "H" "R" - "l" "c" - "L" "C" - (kbd "C-h") (kbd "C-r") - (kbd "C-l") (kbd "C-c") - (kbd "M-h") (kbd "M-r") - (kbd "M-l") (kbd "M-c") - (kbd "C-S-h") (kbd "C-S-r") - (kbd "C-S-l") (kbd "C-S-c") - (kbd "M-S-h") (kbd "M-S-r") - (kbd "M-S-l") (kbd "M-S-c")) - (evil-collection-translate-key nil keymaps - "h" "c" - "H" "C" - "l" "r" - "L" "R" - (kbd "C-h") (kbd "C-c") - (kbd "C-l") (kbd "C-r") - (kbd "M-h") (kbd "M-c") - (kbd "M-l") (kbd "M-r") - (kbd "C-S-h") (kbd "C-S-c") - (kbd "C-S-l") (kbd "C-S-r") - (kbd "M-S-h") (kbd "M-S-c") - (kbd "M-S-l") (kbd "M-S-r"))))) - -;;;###autoload -(defun +layout-bepo-rotate-bare-keymap (keymaps &optional cr-style) - "Rotate [hjklw<>] with [ctsré«»] in KEYMAP. -See `+layout-bepo-cr-rotation-style' for the meaning of CR-STYLE" - (+layout-bepo-rotate-cr-bare-keymap keymaps cr-style) - (+layout-bepo-rotate-ts-bare-keymap keymaps) - (+layout-bepo-rotate-é-quotes-bare-keymap keymaps)) - -;;;###autoload -(defun +layout-bepo-rotate-evil-keymap (&optional cr-style) - "Remap evil-{normal,operator,motion,...}-state-map to be more natural with -Bépo keyboard layout. - -See `+layout-bepo-cr-rotation-style' for the meaning of CR-STYLE." - (let ((cr-style (or cr-style +layout-bepo-cr-rotation-style))) - (evil-collection-translate-key nil - '(evil-normal-state-map evil-motion-state-map evil-visual-state-map evil-operator-state-map) - "c" "h" - "C" "H" - "t" "j" - "T" "J" - "s" "k" - "S" "K" - "r" "l" - "R" "L" - "j" "t" - "J" "T" - "k" "s" - "K" "S") - (if (eq cr-style 'ergodis) - (evil-collection-translate-key nil - '(evil-normal-state-map evil-motion-state-map evil-visual-state-map evil-operator-state-map) - "h" "r" - "H" "R" - "l" "c" - "L" "C") - (evil-collection-translate-key nil - '(evil-normal-state-map evil-motion-state-map evil-visual-state-map evil-operator-state-map) - "h" "c" - "H" "C" - "l" "r" - "L" "R")) - - ;; <> as direct access - (evil-collection-translate-key nil - '(evil-normal-state-map evil-motion-state-map evil-operator-state-map) - "«" "<" - "»" ">") - - ;; " è replaces ^0 to go at BOL - (evil-collection-translate-key nil - '(evil-normal-state-map evil-motion-state-map evil-operator-state-map) - "è" "^" - "È" "0") - - ;; [W] -> [É] - ;; [C-W] -> [W] - (evil-collection-translate-key nil - '(evil-normal-state-map evil-motion-state-map evil-operator-state-map) - "é" "w" - "É" "W" - "w" (kbd "C-w")))) - -;; TODO: Use a macro to DRY +layout-bepo-rotate-{keymaps,minor-modes} - -;;;###autoload -(defun +layout-bepo-rotate-keymaps (keymaps &optional cr-style) - "Remap evil-collection keybinds in KEYMAPS for Bépo keyboard keyboard layouts. - -Remappings are done according to CR-STYLE (see -`+layout-bepo-cr-rotation-style')." - (let ((cr-style (or cr-style +layout-bepo-cr-rotation-style))) - (evil-collection-translate-key '(normal motion visual operator) keymaps - "c" "h" - "C" "H" - "t" "j" - "T" "J" - "s" "k" - "S" "K" - "r" "l" - "R" "L" - "j" "t" - "J" "T" - "k" "s" - "K" "S" - (kbd "C-c") (kbd "C-h") - (kbd "C-C") (kbd "C-H") - (kbd "C-t") (kbd "C-j") - (kbd "C-T") (kbd "C-J") - (kbd "C-s") (kbd "C-k") - (kbd "C-S") (kbd "C-K") - (kbd "C-r") (kbd "C-l") - (kbd "C-R") (kbd "C-L") - (kbd "C-j") (kbd "C-t") - (kbd "C-J") (kbd "C-T") - (kbd "C-k") (kbd "C-s") - (kbd "C-K") (kbd "C-S") - (kbd "M-c") (kbd "M-h") - (kbd "M-C") (kbd "M-H") - (kbd "M-t") (kbd "M-j") - (kbd "M-T") (kbd "M-J") - (kbd "M-s") (kbd "M-k") - (kbd "M-S") (kbd "M-K") - (kbd "M-r") (kbd "M-l") - (kbd "M-R") (kbd "M-L") - (kbd "M-j") (kbd "M-t") - (kbd "M-J") (kbd "M-T") - (kbd "M-k") (kbd "M-s") - (kbd "M-K") (kbd "M-S") - :destructive nil) - (if (eq cr-style 'ergodis) - (evil-collection-translate-key '(normal motion visual operator) keymaps - "h" "r" - "H" "R" - "l" "c" - "L" "C" - (kbd "C-h") (kbd "C-r") - (kbd "C-H") (kbd "C-R") - (kbd "C-l") (kbd "C-c") - (kbd "C-L") (kbd "C-C") - (kbd "M-h") (kbd "M-r") - (kbd "M-H") (kbd "M-R") - (kbd "M-l") (kbd "M-c") - (kbd "M-L") (kbd "M-C") - :destructive nil) - (evil-collection-translate-key '(normal motion visual operator) keymaps - "h" "c" - "H" "C" - "l" "r" - "L" "R" - (kbd "C-h") (kbd "C-c") - (kbd "C-H") (kbd "C-C") - (kbd "C-l") (kbd "C-r") - (kbd "C-L") (kbd "C-R") - (kbd "M-h") (kbd "M-c") - (kbd "M-H") (kbd "M-C") - (kbd "M-l") (kbd "M-r") - (kbd "M-L") (kbd "M-R") - :destructive nil)) - - (evil-collection-translate-key '(insert) keymaps - (kbd "M-c") (kbd "M-h") - (kbd "M-C") (kbd "M-H") - (kbd "M-t") (kbd "M-j") - (kbd "M-T") (kbd "M-J") - (kbd "M-s") (kbd "M-k") - (kbd "M-S") (kbd "M-K") - (kbd "M-r") (kbd "M-l") - (kbd "M-R") (kbd "M-L") - (kbd "M-j") (kbd "M-t") - (kbd "M-J") (kbd "M-T") - (kbd "M-k") (kbd "M-s") - (kbd "M-K") (kbd "M-S") - :destructive nil) - (if (eq cr-style 'ergodis) - (evil-collection-translate-key '(insert) keymaps - (kbd "M-h") (kbd "M-r") - (kbd "M-H") (kbd "M-R") - (kbd "M-l") (kbd "M-c") - (kbd "M-L") (kbd "M-C") - :destructive nil) - (evil-collection-translate-key '(insert) keymaps - (kbd "M-h") (kbd "M-c") - (kbd "M-H") (kbd "M-C") - (kbd "M-l") (kbd "M-r") - (kbd "M-L") (kbd "M-R") - :destructive nil)) - - ;; <> en direct - (evil-collection-translate-key '(normal motion visual operator) keymaps - "«" "<" - "»" ">" - :destructive nil) - - ;; è pour aller au début de ligne - (evil-collection-translate-key '(normal motion visual operator) keymaps - "è" "^" - "È" "0" - :destructive nil) - - ;; [W] -> [É] - ;; [C-W] -> [W] - (evil-collection-translate-key '(normal motion operator visual) keymaps - "é" "w" - "É" "W" - "w" (kbd "C-w") - :destructive nil))) - -;;;###autoload -(defun +layout-bepo-rotate-minor-modes (modes &optional cr-style) - "Remap evil-collection keybinds in MODES for Bépo keyboard keyboard layouts. - -Remappings are done according to CR-STYLE (see -`+layout-bepo-cr-rotation-style')." - (let ((cr-style (or cr-style +layout-bepo-cr-rotation-style))) - (evil-collection-translate-minor-mode-key '(normal motion visual operator) modes - "c" "h" - "C" "H" - "t" "j" - "T" "J" - "s" "k" - "S" "K" - "r" "l" - "R" "L" - "j" "t" - "J" "T" - "k" "s" - "K" "S" - (kbd "C-c") (kbd "C-h") - (kbd "C-C") (kbd "C-H") - (kbd "C-t") (kbd "C-j") - (kbd "C-T") (kbd "C-J") - (kbd "C-s") (kbd "C-k") - (kbd "C-S") (kbd "C-K") - (kbd "C-r") (kbd "C-l") - (kbd "C-R") (kbd "C-L") - (kbd "C-j") (kbd "C-t") - (kbd "C-J") (kbd "C-T") - (kbd "C-k") (kbd "C-s") - (kbd "C-K") (kbd "C-S") - (kbd "M-c") (kbd "M-h") - (kbd "M-C") (kbd "M-H") - (kbd "M-t") (kbd "M-j") - (kbd "M-T") (kbd "M-J") - (kbd "M-s") (kbd "M-k") - (kbd "M-S") (kbd "M-K") - (kbd "M-r") (kbd "M-l") - (kbd "M-R") (kbd "M-L") - (kbd "M-j") (kbd "M-t") - (kbd "M-J") (kbd "M-T") - (kbd "M-k") (kbd "M-s") - (kbd "M-K") (kbd "M-S") - :destructive nil) - (if (eq cr-style 'ergodis) - (evil-collection-translate-minor-mode-key '(normal motion visual operator) modes - "h" "r" - "H" "R" - "l" "c" - "L" "C" - (kbd "C-h") (kbd "C-r") - (kbd "C-H") (kbd "C-R") - (kbd "C-l") (kbd "C-c") - (kbd "C-L") (kbd "C-C") - (kbd "M-h") (kbd "M-r") - (kbd "M-H") (kbd "M-R") - (kbd "M-l") (kbd "M-c") - (kbd "M-L") (kbd "M-C") - :destructive nil) - (evil-collection-translate-minor-mode-key '(normal motion visual operator) modes - "h" "c" - "H" "C" - "l" "r" - "L" "R" - (kbd "C-h") (kbd "C-c") - (kbd "C-H") (kbd "C-C") - (kbd "C-l") (kbd "C-r") - (kbd "C-L") (kbd "C-R") - (kbd "M-h") (kbd "M-c") - (kbd "M-H") (kbd "M-C") - (kbd "M-l") (kbd "M-r") - (kbd "M-L") (kbd "M-R") - :destructive nil)) - - (evil-collection-translate-minor-mode-key '(insert) modes - (kbd "M-c") (kbd "M-h") - (kbd "M-C") (kbd "M-H") - (kbd "M-t") (kbd "M-j") - (kbd "M-T") (kbd "M-J") - (kbd "M-s") (kbd "M-k") - (kbd "M-S") (kbd "M-K") - (kbd "M-r") (kbd "M-l") - (kbd "M-R") (kbd "M-L") - (kbd "M-j") (kbd "M-t") - (kbd "M-J") (kbd "M-T") - (kbd "M-k") (kbd "M-s") - (kbd "M-K") (kbd "M-S") - :destructive nil) - (if (eq cr-style 'ergodis) - (evil-collection-translate-minor-mode-key '(insert) modes - (kbd "M-h") (kbd "M-r") - (kbd "M-H") (kbd "M-R") - (kbd "M-l") (kbd "M-c") - (kbd "M-L") (kbd "M-C") - :destructive nil) - (evil-collection-translate-minor-mode-key '(insert) modes - (kbd "M-h") (kbd "M-c") - (kbd "M-H") (kbd "M-C") - (kbd "M-l") (kbd "M-r") - (kbd "M-L") (kbd "M-R") - :destructive nil)) - - ;; <> en direct - (evil-collection-translate-minor-mode-key '(normal motion visual operator) modes - "«" "<" - "»" ">" - :destructive nil) - - ;; è pour aller au début de ligne - (evil-collection-translate-minor-mode-key '(normal motion visual operator) modes - "è" "^" - "È" "0" - :destructive nil) - - ;; [W] -> [É] - ;; [C-W] -> [W] - (evil-collection-translate-minor-mode-key '(normal motion operator visual) modes - "é" "w" - "É" "W" - "w" (kbd "C-w") - :destructive nil))) diff --git a/.config/emacs/modules/input/layout/config.el b/.config/emacs/modules/input/layout/config.el @@ -1,8 +0,0 @@ -;;; input/layout/config.el -*- lexical-binding: t; -*- - -(add-hook! 'doom-after-modules-config-hook - (defun +layout-init-h () - (cond ((modulep! +bepo) - (load! "+bepo")) - ((modulep! +azerty) - (load! "+azerty"))))) diff --git a/.config/emacs/modules/lang/README.org b/.config/emacs/modules/lang/README.org @@ -1,10 +0,0 @@ -#+title: :lang -#+created: August 03, 2021 -#+since: 21.12.0 - -* Description -These modules specialize in integration particular languages and their -ecosystems into (Doom) Emacs. - -* Frequently asked questions -/This category has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] diff --git a/.config/emacs/modules/lang/agda/README.org b/.config/emacs/modules/lang/agda/README.org @@ -1,56 +0,0 @@ -#+title: :lang agda -#+subtitle: Types of types of types of types... -#+created: August 21, 2018 -#+since: 21.12.0 (#821) - -* Description :unfold: -This module adds support for the [[http://wiki.portal.chalmers.se/agda/pmwiki.php][agda]] programming language. The Emacs support -exists directly in the agda repository, but not in melpa. - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +local :: - Use the =agda-mode= executable that comes with your local =agda= install. -- +tree-sitter :: - Leverages tree-sitter for better syntax highlighting and structural text - editing. Requires [[doom-module::tools tree-sitter]]. - -** Packages -- unless [[doom-module:+local]] - - [[doom-package:agda-input]] - - [[doom-package:agda2-mode]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/agda/config.el b/.config/emacs/modules/lang/agda/config.el @@ -1,47 +0,0 @@ -;;; lang/agda/config.el -*- lexical-binding: t; -*- - -(when (and (modulep! +local) - (executable-find "agda-mode")) - (add-load-path! - (file-name-directory (shell-command-to-string "agda-mode locate"))) - (unless (require 'agda2 nil t) - (message "Failed to find the `agda2' package"))) - -(after! agda2-mode - (set-lookup-handlers! 'agda2-mode - :definition #'agda2-goto-definition-keyboard) - - (when (modulep! +tree-sitter) - (set-tree-sitter-lang! 'agda2-mode 'agda) - (add-hook! '(agda-mode-local-vars-hook - agda2-mode-local-vars-hook) - :append #'tree-sitter!)) - - (map! :map agda2-mode-map - :localleader - "?" #'agda2-show-goals - "." #'agda2-goal-and-context-and-inferred - "," #'agda2-goal-and-context - "=" #'agda2-show-constraints - "SPC" #'agda2-give - "a" #'agda2-auto-maybe-all - "b" #'agda2-previous-goal - "c" #'agda2-make-case - "d" #'agda2-infer-type-maybe-toplevel - "e" #'agda2-show-context - "f" #'agda2-next-goal - "gG" #'agda2-go-back - "h" #'agda2-helper-function-type - "l" #'agda2-load - "n" #'agda2-compute-normalised-maybe-toplevel - "p" #'agda2-module-contents-maybe-toplevel - "r" #'agda2-refine - "s" #'agda2-solveAll - "t" #'agda2-goal-type - "w" #'agda2-why-in-scope-maybe-toplevel - (:prefix "x" - "c" #'agda2-compile - "d" #'agda2-remove-annotations - "h" #'agda2-display-implicit-arguments - "q" #'agda2-quit - "r" #'agda2-restart))) diff --git a/.config/emacs/modules/lang/agda/doctor.el b/.config/emacs/modules/lang/agda/doctor.el @@ -1,5 +0,0 @@ -;;; lang/agda/doctor.el -*- lexical-binding: t; -*- - -(assert! (or (not (modulep! +tree-sitter)) - (modulep! :tools tree-sitter)) - "This module requires (:tools tree-sitter)") diff --git a/.config/emacs/modules/lang/agda/packages.el b/.config/emacs/modules/lang/agda/packages.el @@ -1,16 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/agda/packages.el - -(unless (modulep! +local) - (package! agda-input - :recipe (:host github :repo "agda/agda" - :files ("src/data/emacs-mode/agda-input.el") - :nonrecursive t) - :pin "bb7603d19781e4da2dc702a5a1611fd59e5325f2") - - (package! agda2-mode - :recipe (:host github :repo "agda/agda" - :files ("src/data/emacs-mode/*.el" - (:exclude "agda-input.el")) - :nonrecursive t) - :pin "bb7603d19781e4da2dc702a5a1611fd59e5325f2")) diff --git a/.config/emacs/modules/lang/beancount/README.org b/.config/emacs/modules/lang/beancount/README.org @@ -1,57 +0,0 @@ -#+title: :lang beancount -#+subtitle: Mind the GAAP -#+created: April 13, 2021 -#+since: 21.12.0 - -* Description :unfold: -This module adds support for [[https://beancount.github.io/][Beancount]] to Emacs. Beancount, like ledger, lets -you [[https://plaintextaccounting.org/][manage your money in plain text]]. - -** Maintainers -- @hlissner - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +lsp :: - Enable LSP support for ~beancount-mode~. Requires [[doom-module::tools lsp]] and a langserver - (supports [[https://github.com/polarmutex/beancount-language-server][beancount-language-server]]). - -** Packages -- [[doom-package:beancount]] - -** Hacks -- Associates the material =attach_money= icon with =*.beancount= files in the - [[doom-package:all-the-icons]] package. - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires: -- [[https://github.com/beancount/beancount][beancount]], for generating reports -- [[https://beancount.github.io/fava/][fava]], for a web interface for your ledgers - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/beancount/autoload.el b/.config/emacs/modules/lang/beancount/autoload.el @@ -1,180 +0,0 @@ -;;; lang/beancount/autoload.el -*- lexical-binding: t; -*- - -;; -;;; Helpers - -;; Lifted from ledger -(defconst +beancount--payee-any-status-regex - "^[0-9]+[-/][-/.=0-9]+\\(\\s-+\\*\\)?\\(\\s-+(.*?)\\)?\\s-+\\(.+?\\)\\s-*\\(;\\|$\\)") - -(defun +beancount--sort-startkey () - "Return the actual date so the sort subroutine doesn't sort on the entire first line." - (buffer-substring-no-properties (point) (+ 10 (point)))) - -(defun +beancount--navigate-next-xact () - "Move point to beginning of next xact." - ;; make sure we actually move to the next xact, even if we are the beginning - ;; of one now. - (if (looking-at +beancount--payee-any-status-regex) - (forward-line)) - (if (re-search-forward +beancount--payee-any-status-regex nil t) - (goto-char (match-beginning 0)) - (goto-char (point-max)))) - -(defun +beancount--navigate-start-xact-or-directive-p () - "Return t if at the beginning of an empty or all-whitespace line." - (not (looking-at "[ \t]\\|\\(^$\\)"))) - -(defun +beancount--navigate-next-xact-or-directive () - "Move to the beginning of the next xact or directive." - (interactive) - (beginning-of-line) - (if (+beancount--navigate-start-xact-or-directive-p) ; if we are the start of an xact, move forward to the next xact - (progn - (forward-line) - (if (not (+beancount--navigate-start-xact-or-directive-p)) ; we have moved forward and are not at another xact, recurse forward - (+beancount--navigate-next-xact-or-directive))) - (while (not (or (eobp) ; we didn't start off at the beginning of an xact - (+beancount--navigate-start-xact-or-directive-p))) - (forward-line)))) - -(defun +beancount--navigate-next-xact () - "Move point to beginning of next xact." - ;; make sure we actually move to the next xact, even if we are the - ;; beginning of one now. - (if (looking-at +beancount--payee-any-status-regex) - (forward-line)) - (if (re-search-forward +beancount--payee-any-status-regex nil t) - (goto-char (match-beginning 0)) - (goto-char (point-max)))) - -(defun +beancount--navigate-beginning-of-xact () - "Move point to the beginning of the current xact." - ;; need to start at the beginning of a line in case we are in the first line of an xact already. - (beginning-of-line) - (let ((sreg (concat "^[=~[:digit:]]"))) - (unless (looking-at sreg) - (re-search-backward sreg nil t) - (beginning-of-line))) - (point)) - -(defun +beancount--navigate-end-of-xact () - "Move point to end of xact." - (+beancount--navigate-next-xact-or-directive) - (re-search-backward ".$") - (end-of-line) - (point)) - - -;; -;;; Commands - -;;;###autoload -(defun +beancount/sort-buffer (&optional reverse) - "Sort all transactions in the buffer. -If REVERSE (the prefix arg) is non-nil, sort them in reverse." - (interactive "P") - (+beancount/sort-region (point-min) (point-max) reverse)) - -;;;###autoload -(defun +beancount/sort-region (beg end &optional reverse) - "Sort the transactions inside BEG and END. -If REVERSE (the prefix arg) is non-nil, sort the transactions in reverst order." - (interactive - (list (region-beginning) - (region-end) - (and current-prefix-arg t))) - (let* ((new-beg beg) - (new-end end) - (bounds (save-excursion - (list (+beancount--navigate-beginning-of-xact) - (+beancount--navigate-end-of-xact)))) - (point-delta (- (point) (car bounds))) - (target-xact (buffer-substring (car bounds) (cadr bounds))) - (inhibit-modification-hooks t)) - (save-excursion - (save-restriction - (goto-char beg) - ;; make sure beg of region is at the beginning of a line - (beginning-of-line) - ;; make sure point is at the beginning of a xact - (unless (looking-at +beancount--payee-any-status-regex) - (+beancount--navigate-next-xact)) - (setq new-beg (point)) - (goto-char end) - (+beancount--navigate-next-xact) - ;; make sure end of region is at the beginning of next record after the - ;; region - (setq new-end (point)) - (narrow-to-region new-beg new-end) - (goto-char new-beg) - (let ((inhibit-field-text-motion t)) - (sort-subr - reverse - '+beancount--navigate-next-xact - '+beancount--navigate-end-of-xact - '+beancount--sort-startkey)))) - (goto-char (point-min)) - (re-search-forward (regexp-quote target-xact)) - (goto-char (+ (match-beginning 0) point-delta)))) - -(defvar compilation-read-command) -;;;###autoload -(defun +beancount/balance () - "Run 'bean-report bal'." - (interactive) - (let (compilation-read-command) - (beancount--run "bean-report" buffer-file-name "bal"))) - -;;;###autoload -(defun +beancount/clone-transaction () - "TODO" - (interactive) - (save-restriction - (widen) - (when-let (transaction - (completing-read - "Clone transaction: " - (string-lines (buffer-string)) - (doom-partial #'string-match-p "^[0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} [*!] ") - t)) - (goto-char (point-min)) - (re-search-forward (concat "^" (regexp-quote transaction))) - (+beancount/clone-this-transaction t)))) - -;;;###autoload -(defun +beancount/clone-this-transaction (&optional arg) - "Copy the current transaction to the bottom of the ledger. -Updates the date to today" - (interactive "P") - (if (and (not arg) (looking-at-p "^$")) - (call-interactively #'+beancount/clone-transaction) - (save-restriction - (widen) - (let ((transaction - (buffer-substring-no-properties - (save-excursion - (beancount-goto-transaction-begin) - (re-search-forward " " nil t) - (point)) - (save-excursion - (beancount-goto-transaction-end) - (point))))) - (goto-char (point-max)) - (delete-blank-lines) - (beancount-insert-date) - (insert transaction))))) - -;;;###autoload -(defun +beancount/next-transaction (&optional count) - "Jump to the start of the next COUNT-th transaction." - (interactive "p") - (dotimes (_ (or count 1)) - (beancount-goto-next-transaction))) - -;;;###autoload -(defun +beancount/previous-transaction (&optional count) - "Jump to the start of current or previous COUNT-th transaction." - (interactive "p") - (re-search-backward - beancount-transaction-regexp nil t (or count 1))) diff --git a/.config/emacs/modules/lang/beancount/config.el b/.config/emacs/modules/lang/beancount/config.el @@ -1,37 +0,0 @@ -;;; lang/beancount/config.el -*- lexical-binding: t; -*- - -(use-package! beancount - :mode ("\\.beancount\\'" . beancount-mode) - :hook (beancount-mode . outline-minor-mode) - :init - ;; REVIEW Remove once domtronn/all-the-icons.el#272 is merged - (after! all-the-icons - (add-to-list 'all-the-icons-icon-alist - '("\\.beancount\\'" all-the-icons-material "attach_money" :face all-the-icons-lblue)) - (add-to-list 'all-the-icons-mode-icon-alist - '(beancount-mode all-the-icons-material "attach_money" :face all-the-icons-lblue))) - - :config - (setq beancount-electric-currency t) - - (when (modulep! +lsp) - (add-hook 'beancount-mode-local-vars-hook #'lsp! 'append)) - - (map! :map beancount-mode-map - "TAB" (cmds! (and outline-minor-mode (outline-on-heading-p)) - #'beancount-outline-cycle - #'indent-according-to-mode) - :m "[[" #'+beancount/previous-transaction - :m "]]" #'+beancount/next-transaction - :localleader - "b" #'+beancount/balance - "c" #'beancount-check - "l" #'beancount-linked - "q" #'beancount-query - "x" #'beancount-context - (:prefix ("i" . "insert") - "c" #'+beancount/clone-transaction - "C" #'+beancount/clone-this-transaction - "a" #'beancount-insert-account - "p" #'beancount-insert-prices - "d" #'beancount-insert-date))) diff --git a/.config/emacs/modules/lang/beancount/packages.el b/.config/emacs/modules/lang/beancount/packages.el @@ -1,7 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/beancount/packages.el - -(package! beancount - :recipe (:host github - :repo "beancount/beancount-mode") - :pin "519bfd868f206ed2fc538a57cdb631c4fec3c93e") diff --git a/.config/emacs/modules/lang/cc/README.org b/.config/emacs/modules/lang/cc/README.org @@ -1,278 +0,0 @@ -#+title: :lang cc -#+subtitle: C > C++ == 1 -#+created: February 20, 2017 -#+since: 2.0.0 - -* Description :unfold: -This module adds support for the C-family of languages: C, C++, and Objective-C. - -- Code completion (~company-irony~) -- eldoc support (~irony-eldoc~) -- Syntax-checking (~flycheck-irony~) -- Code navigation (~rtags~) -- File Templates ([[../../editor/file-templates/templates/c-mode][c-mode]], [[../../editor/file-templates/templates/c++-mode][c++-mode]]) -- Snippets ([[https://github.com/hlissner/doom-snippets/tree/master/cc-mode][cc-mode]], [[https://github.com/hlissner/doom-snippets/tree/master/c-mode][c-mode]], [[https://github.com/hlissner/doom-snippets/tree/master/c++-mode][c++-mode]]) -- Several improvements to C++11 indentation and syntax highlighting. - -** Maintainers -- [[doom-user:][@hlissner]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +lsp :: - Enable LSP support for ~c-mode~, ~c++-mode~, and ~objc-mode~. Requires [[doom-module::tools - lsp]] and a langserver (supports ccls, clangd, and cquery). Replaces irony & - rtags. -- +tree-sitter :: - Leverages tree-sitter for better syntax highlighting and structural text - editing. Requires [[doom-module::tools tree-sitter]]. - -** Packages -- [[doom-package:cmake-mode]] -- [[doom-package:company-glsl]] -- [[doom-package:cuda-mode]] -- [[doom-package:demangle-mode]] -- [[doom-package:disaster]] -- [[doom-package:glsl-mode]] -- [[doom-package:modern-cpp-font-lock]] -- [[doom-package:opencl-mode]] -- if [[doom-module:+lsp]] - - [[doom-package:ccls]] if [[doom-module::tools lsp -eglot]] -- else - - [[doom-package:company-irony]] - - [[doom-package:company-irony-c-headers]] - - [[doom-package:flycheck-irony]] - - [[doom-package:helm-rtags]] if [[doom-module::completion helm]] - - [[doom-package:irony]] - - [[doom-package:irony-eldoc]] - - [[doom-package:ivy-rtags]] if [[doom-module::completion ivy]] - - [[doom-package:rtags]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module's requirements change depending on how you use it. - -- If [[doom-module:+lsp]] is enabled, you need one of *clangd v9+* or *ccls*. -- If [[doom-module:+lsp]] is *not* enabled, you need *irony-server* and *rtags*. -- Other features in this module depend on: - - (optional) glslangValidator, for GLSL completion in ~glsl-mode~ - - (optional) cmake, for code completion in ~cmake-mode~ -- You will need a C/C++ compiler, like =gcc= or =clang=. - -** LSP servers -=lsp-mode= and =eglot= support a few LSP servers, but =clangd= and =ccls= are -recommended. - -+ clangd (must be v9 or newer) :: clangd is included with =llvm= which should be - available through your OS' package manager. - - Linux: - - Debian 11 & Ubuntu 20.10: ~$ apt-get install clangd-11~ - - 20.04 LTS: [[https://pkgs.org/search/?q=clangd][clangd-10]] - - Fedora & CentOS/RHEL 8+: ~$ dnf install clang-tools-extra~ - - openSUSE: ~$ zypper install clang~ - - Arch: ~$ pacman -S clang~ - - BSDs: - - NetBSD & OpenBSD: ~$ pkg_add clang-tools-extra~ - - macOS: ~$ brew install llvm~ // 1GB+ installation! May take a while! - - Windows: use the win64 installer from [[https://releases.llvm.org/download.html][LLVM's GitHub release page]]. -+ ccls :: Available in many OS' package managers as =ccls=. Otherwise, there are - alternative install methods listed [[https://github.com/MaskRay/ccls/wiki/Install][in the project's wiki]]. -+ cmake-language-server :: available through ~pip~ on most distributions - -** irony-server -Irony powers the code completion, eldoc and syntax checking systems. - -After installing its dependencies (Clang and CMake), run ~M-x -irony-install-server~ in Emacs. - -*** macOS -Due to linking issues, macOS users must compile irony-server manually: -#+begin_src sh -brew install cmake -brew install llvm -git clone https://github.com/Sarcasm/irony-mode irony-mode -#+end_src - -#+begin_src sh -mkdir irony-mode/server/build -pushd irony-mode/server/build - -DEST="$HOME/.emacs.d/.local/etc/irony-server/" -cmake -DCMAKE_PREFIX_PATH=/usr/local/opt/llvm \ - -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=ON \ - -DCMAKE_INSTALL_PREFIX="$DEST" ../ -cmake --build . --use-stderr --config Release --target install - -install_name_tool -change @rpath/libclang.dylib \ - /usr/local/opt/llvm/lib/libclang.dylib \ - "$DEST/bin/irony-server" - -# Cleanup -popd -rm -rf irony-mode -#+end_src - -** rtags -Code navigation requires an [[https://github.com/Andersbakken/rtags][rtags]] server (~rdm~) installed. This should be -available through your OS's package manager. - -This module will auto-start ~rdm~ when you open C/C++ buffers (so long as one -isn't already running). If you prefer to run it yourself: - -#+begin_src sh -rdm & -rc -J $PROJECT_ROOT # loads PROJECT_ROOT's compile_commands.json -#+end_src - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -1. Enable this module. -2. Enable the ~+lsp~ flag for the appropriate modules you want LSP support for - (e.g. ~:lang (python +lsp)~ or ~:lang (rust +lsp)~), -3. Install the prerequisite LSP servers through your package manager or other - means. You can find a list of supported servers on [[https://github.com/emacs-lsp/lsp-mode#supported-languages][the lsp-mode project page]]. -4. Run ~$ doom sync~ on the command line and restart Emacs. - -** Eglot-specific bindings -When using [[doom-module:+lsp]] and [[doom-module::tools lsp +eglot]], [[doom-package:lsp-mode]] is replaced with [[doom-package:eglot]], and an -additional function to get inheritance type hierarchy is added: -| Binding | Description | -|----------------------------+------------------------------------------------| -| [[kbd:][<localleader> c t]] | Display inheritance type hierarchy (upwards) | -| [[kbd:][<prefix> <localleader> c t]] | Display inheritance type hierarchy (downwards) | - -* TODO Configure -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** Project compile settings -By default, a set of default compile settings are defined in -~+cc-default-compiler-options~ for C, C++ and Objective C. Irony, rtags and -flycheck will fall back to these. *This variable does nothing for LSP users.* - -For a more universal solution: both LSP servers and irony will recognize a -[[https://sarcasm.github.io/notes/dev/compilation-database.html#ninja][compilation database]] (a ~compile_commands.json~ file). There are [[https://sarcasm.github.io/notes/dev/compilation-database.html][many ways to -generate one]]. Here is an example using [[http://www.cmake.org/][CMake]] and [[https://github.com/rizsotto/Bear][bear]]: - -#+begin_src sh -# For CMake projects -cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON . -#+end_src - -#+begin_src sh -# For non-CMake projects -make clean -bear make -#+end_src - -Use ~M-x +cc/reload-compile-db~ to reload your compile db in an already-open -C/C++/ObjC buffer. - -*** Known issues with bear on macOS -MacOS' [[https://support.apple.com/en-us/HT204899][System Integrity Protection (SIP)]] might interfere with bear if ~make~ is -under ~/usr/bin/~ which results in an empty compilation database. - -From the bear [[https://github.com/rizsotto/Bear#empty-compilation-database-on-os-x-captain-or-fedora][readme]]: -#+begin_quote -Security extension/modes on different operating systems might disable library -preloads. This case Bear behaves normally, but the result compilation database -will be empty. (Please make sure it's not the case when reporting bugs.) Notable -examples for enabled security modes are: OS X 10.11 (check with csrutil status | -grep 'System Integrity Protection'), and Fedora, CentOS, RHEL (check with -sestatus | grep 'SELinux status'). - -Workaround could be to disable the security feature while running Bear. (This -might involve reboot of your computer, so might be heavy workaround.) Another -option if the build tool is not installed under certain directories. Or use -tools which are using compiler wrappers. (It injects a fake compiler which does -record the compiler invocation and calls the real compiler too.) An example for -such tool might be scan-build. The build system shall respect CC and CXX -environment variables. -#+end_quote - -A workaround might be to install ~make~ via Homebrew which puts ~gmake~ under -=/usr/local/=: -#+begin_src sh -brew install make -#+end_src -#+begin_src sh -make clean -bear gmake -#+end_src - -Additional info: -- [[https://github.com/rizsotto/Bear/issues/158][Empty compilation database with compiler in /usr/local]] -- [[https://github.com/rizsotto/Bear/issues/152][Workaround for 'Empty compilation database on OS X Captain]] - -** Configure LSP servers -Search for your combination of =(LSP client package, LSP server)=. You are using -[[doom-package:lsp-mode]] by default, [[doom-package:eglot]] if you have [[doom-module::tools lsp +eglot]] active in -=$DOOMDIR/init.el= file. - -*** LSP-mode with clangd -#+begin_src emacs-lisp -(after! lsp-clangd - (setq lsp-clients-clangd-args - '("-j=3" - "--background-index" - "--clang-tidy" - "--completion-style=detailed" - "--header-insertion=never" - "--header-insertion-decorators=0")) - (set-lsp-priority! 'clangd 2)) -#+end_src - -This will both set your clangd flags and choose =clangd= as the default LSP -server everywhere clangd can be used. - -*** LSP-mode with ccls -#+begin_src emacs-lisp -(after! ccls - (setq ccls-initialization-options '(:index (:comments 2) :completion (:detailedLabel t))) - (set-lsp-priority! 'ccls 2)) ; optional as ccls is the default in Doom -#+end_src - -This will both set your ccls flags and choose ccls as the default server. [[https://github.com/MaskRay/ccls/wiki/Customization#--initjson][CCLS -documentation]] lists available options, use =t= for ~true~, =:json-false= for -~false~, and =:json-null= for ~null~. - -*** Eglot with clangd -#+begin_src emacs-lisp -(set-eglot-client! 'cc-mode '("clangd" "-j=3" "--clang-tidy")) -#+end_src - -This will both set your clangd flags and choose clangd as the default server (if -it is the last =set-eglot-client! 'cc-mode= in your config). - -*** Eglot with ccls -#+begin_src emacs-lisp -(set-eglot-client! 'cc-mode '("ccls" "--init={\"index\": {\"threads\": 3}}")) -#+end_src - -This will both set your ccls flags and choose ccls as the default server (if it -is the last =set-eglot-client! 'cc-mode= in your config). [[https://github.com/MaskRay/ccls/wiki/Customization#--initjson][CCLS documentation]] -lists available options - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/cc/autoload.el b/.config/emacs/modules/lang/cc/autoload.el @@ -1,330 +0,0 @@ -;;; lang/cc/autoload.el -*- lexical-binding: t; -*- - -;;;###autoload -(add-to-list 'auto-mode-alist '("\\.cl\\'" . opencl-mode)) - -;; The plusses in c++-mode can be annoying to search for ivy/helm (which reads -;; queries as regexps), so we add these for convenience. -;;;###autoload (defalias 'cpp-mode 'c++-mode) -;;;###autoload (defvaralias 'cpp-mode-map 'c++-mode-map) - - -;; -;; Library - -;;;###autoload -(defun +cc-c++-lineup-inclass (langelem) - "Indent inclass lines one level further than access modifier keywords." - (and (eq major-mode 'c++-mode) - (or (assoc 'access-label c-syntactic-context) - (save-excursion - (save-match-data - (re-search-backward - "\\(?:p\\(?:ublic\\|r\\(?:otected\\|ivate\\)\\)\\)" - (c-langelem-pos langelem) t)))) - '++)) - -;;;###autoload -(defun +cc-lineup-arglist-close (langlem) - "Line up the closing brace in an arglist with the opening brace IF cursor is -preceded by the opening brace or a comma (disregarding whitespace in between)." - (when (save-excursion - (save-match-data - (skip-chars-backward " \t\n" (c-langelem-pos langelem)) - (memq (char-before) (list ?, ?\( ?\;)))) - (c-lineup-arglist langlem))) - -(defun +cc--re-search-for (regexp) - (save-excursion - (save-restriction - (save-match-data - (widen) - (goto-char (point-min)) - (re-search-forward regexp magic-mode-regexp-match-limit t))))) - -;;;###autoload -(defun +cc-c-c++-objc-mode () - "Uses heuristics to detect `c-mode', `objc-mode' or `c++-mode'. - -1. Checks if there are nearby cpp/cc/m/mm files with the same name. -2. Checks for ObjC and C++-specific keywords and libraries. -3. Falls back to `+cc-default-header-file-mode', if set. -4. Otherwise, activates `c-mode'. - -This is meant to replace `c-or-c++-mode' (introduced in Emacs 26.1), which -doesn't support specification of the fallback mode and whose heuristics are -simpler." - (let ((base (file-name-sans-extension (buffer-file-name (buffer-base-buffer))))) - (cond ((file-exists-p! (or (concat base ".cpp") - (concat base ".cc"))) - (c++-mode)) - ((or (file-exists-p! (or (concat base ".m") - (concat base ".mm"))) - (+cc--re-search-for - (concat "^[ \t\r]*\\(?:" - "@\\(?:class\\|interface\\|property\\|end\\)\\_>" - "\\|#import +<Foundation/Foundation.h>" - "\\|[-+] ([a-zA-Z0-9_]+)" - "\\)"))) - (objc-mode)) - ((+cc--re-search-for - (let ((id "[a-zA-Z0-9_]+") (ws "[ \t\r]+") (ws-maybe "[ \t\r]*")) - (concat "^" ws-maybe "\\(?:" - "using" ws "\\(?:namespace" ws "std;\\|std::\\)" - "\\|" "namespace" "\\(?:" ws id "\\)?" ws-maybe "{" - "\\|" "class" ws id ws-maybe "[:{\n]" - "\\|" "template" ws-maybe "<.*>" - "\\|" "#include" ws-maybe "<\\(?:string\\|iostream\\|map\\)>" - "\\)"))) - (c++-mode)) - ((functionp +cc-default-header-file-mode) - (funcall +cc-default-header-file-mode)) - ((c-mode))))) - -(defun +cc-resolve-include-paths () - (cl-loop with path = (or buffer-file-name default-directory) - for dir in +cc-default-include-paths - if (file-name-absolute-p dir) - collect dir - else if (projectile-locate-dominating-file path dir) - collect (expand-file-name dir it))) - - -;; -;; Commands - -;;;###autoload -(defun +cc/reload-compile-db () - "Reload the current project's JSON compilation database." - (interactive) - (unless (memq major-mode '(c-mode c++-mode objc-mode)) - (user-error "Not a C/C++/ObjC buffer")) - ;; first rtag - (when (and (featurep 'rtags) - rtags-enabled - (executable-find rtags-rc-binary-name)) - (with-temp-buffer - (message "Reloaded compile commands for rtags daemon") - (rtags-call-rc :silent t "-J" (or (doom-project-root) default-directory)))) - ;; then irony - (when (and (featurep 'irony) irony-mode) - (+cc-init-irony-compile-options-h)) - ;; Otherwise, LSP - (when (bound-and-true-p lsp-mode) - (lsp-workspace-restart)) - (when (bound-and-true-p eglot-managed-mode) - (eglot-reconnect))) - -;;;###autoload -(defun +cc/imenu () - "Invoke `rtags-imenu' if a running rdm process is available, otherwise invoke -`imenu'." - (interactive) - (call-interactively - (if (and (processp rtags-rdm-process) - (not (eq (process-status rtags-rdm-process) 'exit)) - (not (eq (process-status rtags-rdm-process) 'signal))) - #'rtags-imenu - #'imenu))) - -;; Eglot specific helper, courtesy of MaskRay -;;;###autoload -(defun +cc/eglot-ccls-show-inheritance-hierarchy (&optional derived) - "Show inheritance hierarchy for the thing at point. -If DERIVED is non-nil (interactively, with prefix argument), show -the children of class at point." - (interactive "P") - (if-let* ((res (jsonrpc-request - (eglot--current-server-or-lose) - :$ccls/inheritance - (append (eglot--TextDocumentPositionParams) - `(:derived ,(if derived t :json-false)) - '(:levels 100) '(:hierarchy t)))) - (tree (list (cons 0 res)))) - (with-help-window "*ccls inheritance*" - (with-current-buffer standard-output - (while tree - (pcase-let ((`(,depth . ,node) (pop tree))) - (cl-destructuring-bind (&key uri range) (plist-get node :location) - (insert (make-string depth ?\ ) (plist-get node :name) "\n") - (make-text-button (+ (point-at-bol 0) depth) (point-at-eol 0) - 'action (lambda (_arg) - (interactive) - (find-file (eglot--uri-to-path uri)) - (goto-char (car (eglot--range-region range))))) - (cl-loop for child across (plist-get node :children) - do (push (cons (1+ depth) child) tree))))))) - (eglot--error "Hierarchy unavailable"))) - -;;;###autoload -(defun +cc-cmake-lookup-documentation-fn (_) - "Look up the symbol at point in CMake's documentation." - (condition-case _ - (progn - (save-window-excursion (cmake-help)) - (when-let (buf (get-buffer "*CMake Help*")) - (pop-to-buffer buf) - t)) - (error nil))) - - -;; -;; Hooks - -;;;###autoload -(defun +cc-fontify-constants-h () - "Better fontification for preprocessor constants" - (when (memq major-mode '(c-mode c++-mode)) - (font-lock-add-keywords - nil '(("\\<[A-Z]*_[0-9A-Z_]+\\>" . font-lock-constant-face) - ("\\<[A-Z]\\{3,\\}\\>" . font-lock-constant-face)) - t))) - -(defvar +cc--project-includes-alist nil) -;;;###autoload -(defun +cc-init-irony-compile-options-h () - "Initialize compiler options for irony-mode. It searches for the nearest -compilation database and initailizes it, otherwise falling back on -`+cc-default-compiler-options' and `+cc-default-include-paths'. - -See https://github.com/Sarcasm/irony-mode#compilation-database for details on -compilation dbs." - (when (memq major-mode '(c-mode c++-mode objc-mode)) - (require 'irony-cdb) - (unless (irony-cdb-autosetup-compile-options) - (let ((project-root (doom-project-root)) - (include-paths (+cc-resolve-include-paths))) - (setf (alist-get project-root +cc--project-includes-alist) - include-paths) - (irony-cdb--update-compile-options - (append (delq nil (cdr-safe (assq major-mode +cc-default-compiler-options))) - (cl-loop for path in include-paths - collect (format "-I%s" path))) - project-root))))) - -;; ;;;###autoload -;; (defun +cc|init-ccls-compile-options () -;; "TODO" -;; (when (memq major-mode '(c-mode c++-mode objc-mode)) -;; (when-let (include-paths (+cc-resolve-include-paths)) -;; (let ((args (delq nil (cdr-safe (assq major-mode +cc-default-compiler-options))))) -;; (setf (alist-get (or (lsp-workspace-root) -;; (lsp--suggest-project-root) -;; (doom-project-root)) -;; +cc--project-includes-alist) -;; include-paths) -;; (setq ccls-initialization-options -;; `(:clang (:extraArgs -;; [,@(cl-loop for path in include-paths -;; collect (format "-I%s" path))]))))))) - -;;;###autoload -(defun +cc-init-ffap-integration-h () - "Takes the local project include paths and registers them with ffap. -This way, `find-file-at-point' (and `+lookup/file') will know where to find most -header files." - (when-let (project-root (or (bound-and-true-p irony--working-directory) - (and (featurep 'lsp) - (or (lsp-workspace-root) - (doom-project-root))))) - (require 'ffap) - (make-local-variable 'ffap-c-path) - (make-local-variable 'ffap-c++-path) - (cl-loop for dir in (or (cdr (assoc project-root +cc--project-includes-alist)) - (+cc-resolve-include-paths)) - do (add-to-list (pcase major-mode - (`c-mode 'ffap-c-path) - (`c++-mode 'ffap-c++-path)) - (expand-file-name dir project-root))))) - - -;; -;;; CCLS specific helpers - -;; ccls-show-vars ccls-show-base ccls-show-derived ccls-show-members have a -;; parameter while others are interactive. -;; -;; (+cc/ccls-show-base 1) direct bases -;; (+cc/ccls-show-derived 1) direct derived -;; (+cc/ccls-show-member 2) => 2 (Type) => nested classes / types in a namespace -;; (+cc/ccls-show-member 3) => 3 (Func) => member functions / functions in a namespace -;; (+cc/ccls-show-member 0) => member variables / variables in a namespace -;; (+cc/ccls-show-vars 1) => field -;; (+cc/ccls-show-vars 2) => local variable -;; (+cc/ccls-show-vars 3) => field or local variable. 3 = 1 | 2 -;; (+cc/ccls-show-vars 4) => parameter - -;;;###autoload -(defun +cc/ccls-show-callee () - "Show callees of symbol under point." - (interactive) - (lsp-ui-peek-find-custom "$ccls/call" '(:callee t))) - -;;;###autoload -(defun +cc/ccls-show-caller () - "Show callers of symbol under point." - (interactive) - (lsp-ui-peek-find-custom "$ccls/call")) - -;;;###autoload -(defun +cc/ccls-show-vars (kind) - "Show variables of type KIND as symbol under point. - 1 -> field - 2 -> local variable - 3 -> field or local variables. 3 = 1 | 2. - 4 -> parameter" - (lsp-ui-peek-find-custom "$ccls/vars" `(:kind ,kind))) - -;;;###autoload -(defun +cc/ccls-show-base (levels) - "Show bases of class under point up to LEVELS levels (1 for direct bases)." - (lsp-ui-peek-find-custom "$ccls/inheritance" `(:levels ,levels))) - -;;;###autoload -(defun +cc/ccls-show-derived (levels) - "Show derived classes from class under point down to LEVELS levels (1 for direct derived)." - (lsp-ui-peek-find-custom "$ccls/inheritance" `(:levels ,levels :derived t))) - -;;;###autoload -(defun +cc/ccls-show-member (kind) - "Show member elements of kind KIND for class/namespace under point. - 0 -> member variables/ variables in a namespace - 2 -> nested classes / types in a namespace - 3 -> member functions / functions in a namespace" - (lsp-ui-peek-find-custom "$ccls/member" `(:kind ,kind))) - -;; The meaning of :role corresponds to https://github.com/maskray/ccls/blob/master/src/symbol.h -;;;###autoload -(defun +cc/ccls-show-references-address () - "References w/ Role::Address bit (e.g. variables explicitly being taken addresses)" - (interactive) - (lsp-ui-peek-find-custom "textDocument/references" - (plist-put (lsp--text-document-position-params) :role 128))) - -;;;###autoload -(defun +cc/ccls-show-references-macro () - "References w/ Role::Dynamic bit (macro expansions)" - (interactive) - (lsp-ui-peek-find-custom "textDocument/references" - (plist-put (lsp--text-document-position-params) :role 64))) - -;;;###autoload -(defun +cc/ccls-show-references-not-call () - "References w/o Role::Call bit (e.g. where functions are taken addresses)" - (interactive) - (lsp-ui-peek-find-custom "textDocument/references" - (plist-put (lsp--text-document-position-params) :excludeRole 32))) - -;;;###autoload -(defun +cc/ccls-show-references-read () - "References w/ Role::Read" - (interactive) - (lsp-ui-peek-find-custom "textDocument/references" - (plist-put (lsp--text-document-position-params) :role 8))) - -;;;###autoload -(defun +cc/ccls-show-references-write () - "References w/ Role::Write" - (interactive) - (lsp-ui-peek-find-custom "textDocument/references" - (plist-put (lsp--text-document-position-params) :role 16))) diff --git a/.config/emacs/modules/lang/cc/config.el b/.config/emacs/modules/lang/cc/config.el @@ -1,311 +0,0 @@ -;;; lang/cc/config.el --- c, c++, and obj-c -*- lexical-binding: t; -*- - -(defvar +cc-default-include-paths - (list "include" - "includes") - "A list of default relative paths which will be searched for up from the -current file, to be passed to irony as extra header search paths. Paths can be -absolute. This is ignored if your project has a compilation database. - -This is ignored by ccls.") - -(defvar +cc-default-header-file-mode 'c-mode - "Fallback major mode for .h files if all other heuristics fail (in -`+cc-c-c++-objc-mode').") - -(defvar +cc-default-compiler-options - `((c-mode . nil) - (c++-mode - . ,(list "-std=c++1z" ; use C++17 draft by default - (when IS-MAC - ;; NOTE beware: you'll get abi-inconsistencies when passing - ;; std-objects to libraries linked with libstdc++ (e.g. if you - ;; use boost which wasn't compiled with libc++) - "-stdlib=libc++"))) - (objc-mode . nil)) - "A list of default compiler options for the C family. These are ignored if a -compilation database is present in the project. - -This is ignored by ccls.") - - -;; -;;; Packages - -(use-package! cc-mode - :mode ("\\.mm\\'" . objc-mode) - ;; Use `c-mode'/`c++-mode'/`objc-mode' depending on heuristics - :mode ("\\.h\\'" . +cc-c-c++-objc-mode) - ;; Ensure find-file-at-point recognize system libraries in C modes. It must be - ;; set up before the likes of irony/lsp are initialized. Also, we use - ;; local-vars hooks to ensure these only run in their respective major modes, - ;; and not their derived modes. - :hook ((c-mode-local-vars c++-mode-local-vars objc-mode-local-vars) . +cc-init-ffap-integration-h) - ;;; Improve fontification in C/C++ (also see `modern-cpp-font-lock') - :hook (c-mode-common . rainbow-delimiters-mode) - :hook ((c-mode c++-mode) . +cc-fontify-constants-h) - :config - (set-docsets! 'c-mode "C") - (set-docsets! 'c++-mode "C++" "Boost") - (set-electric! '(c-mode c++-mode objc-mode java-mode) :chars '(?\n ?\} ?\{)) - (set-rotate-patterns! 'c++-mode - :symbols '(("public" "protected" "private") - ("class" "struct"))) - (set-ligatures! '(c-mode c++-mode) - ;; Functional - ;; :def "void " - ;; Types - :null "nullptr" - :true "true" :false "false" - :int "int" :float "float" - :str "std::string" - :bool "bool" - ;; Flow - :not "!" - :and "&&" :or "||" - :for "for" - :return "return" - :yield "#require") - - (when (modulep! +tree-sitter) - (add-hook! '(c-mode-local-vars-hook - c++-mode-local-vars-hook) - :append #'tree-sitter!)) - - ;; HACK Suppress 'Args out of range' error in when multiple modifications are - ;; performed at once in a `c++-mode' buffer, e.g. with `iedit' or - ;; multiple cursors. - (undefadvice! +cc--suppress-silly-errors-a (fn &rest args) - :around #'c-after-change-mark-abnormal-strings - (ignore-errors (apply fn args))) - - ;; Custom style, based off of linux - (setq c-basic-offset tab-width - c-backspace-function #'delete-backward-char) - - (c-add-style - "doom" '((c-comment-only-line-offset . 0) - (c-hanging-braces-alist (brace-list-open) - (brace-entry-open) - (substatement-open after) - (block-close . c-snug-do-while) - (arglist-cont-nonempty)) - (c-cleanup-list brace-else-brace) - (c-offsets-alist - (knr-argdecl-intro . 0) - (substatement-open . 0) - (substatement-label . 0) - (statement-cont . +) - (case-label . +) - ;; align args with open brace OR don't indent at all (if open - ;; brace is at eolp and close brace is after arg with no trailing - ;; comma) - (brace-list-intro . 0) - (brace-list-close . -) - (arglist-intro . +) - (arglist-close +cc-lineup-arglist-close 0) - ;; don't over-indent lambda blocks - (inline-open . 0) - (inlambda . 0) - ;; indent access keywords +1 level, and properties beneath them - ;; another level - (access-label . -) - (inclass +cc-c++-lineup-inclass +) - (label . 0)))) - - (when (listp c-default-style) - (setf (alist-get 'other c-default-style) "doom")) - - (after! ffap - (add-to-list 'ffap-alist '(c-mode . ffap-c-mode)))) - - -(use-package! modern-cpp-font-lock - :hook (c++-mode . modern-c++-font-lock-mode)) - - -(use-package! irony - :unless (modulep! +lsp) - :commands irony-install-server - ;; Initialize compilation database, if present. Otherwise, fall back on - ;; `+cc-default-compiler-options'. - :hook (irony-mode . +cc-init-irony-compile-options-h) - ;; Only initialize `irony-mode' if the server is available. Otherwise fail - ;; quietly and gracefully. - :hook ((c-mode-local-vars c++-mode-local-vars objc-mode-local-vars) . +cc-init-irony-mode-maybe-h) - :preface (setq irony-server-install-prefix (concat doom-data-dir "irony-server/")) - :config - (defun +cc-init-irony-mode-maybe-h () - (if (file-directory-p irony-server-install-prefix) - (irony-mode +1) - (message "Irony server isn't installed"))) - - (setq irony-cdb-search-directory-list '("." "build" "build-conda")) - - (use-package! irony-eldoc - :hook (irony-mode . irony-eldoc)) - - (use-package! flycheck-irony - :when (modulep! :checkers syntax) - :config (flycheck-irony-setup)) - - (use-package! company-irony - :when (modulep! :completion company) - :init (set-company-backend! 'irony-mode '(:separate company-irony-c-headers company-irony)) - :config (require 'company-irony-c-headers))) - - -;; -;; Major modes - -(after! cmake-mode - (set-docsets! 'cmake-mode "CMake") - (set-popup-rule! "^\\*CMake Help\\*" :size 0.4 :ttl t) - (set-lookup-handlers! 'cmake-mode - :documentation '+cc-cmake-lookup-documentation-fn)) - - -(use-package! company-cmake ; for `cmake-mode' - :when (modulep! :completion company) - :after cmake-mode - :config (set-company-backend! 'cmake-mode 'company-cmake)) - - -(use-package! demangle-mode - :hook llvm-mode) - - -(use-package! company-glsl ; for `glsl-mode' - :when (modulep! :completion company) - :after glsl-mode - :config (set-company-backend! 'glsl-mode 'company-glsl)) - - -;; -;; Rtags Support - -(use-package! rtags - :unless (modulep! +lsp) - ;; Only initialize rtags-mode if rtags and rdm are available. - :hook ((c-mode-local-vars c++-mode-local-vars objc-mode-local-vars) . +cc-init-rtags-maybe-h) - :preface (setq rtags-install-path (concat doom-data-dir "rtags/")) - :config - (defun +cc-init-rtags-maybe-h () - "Start an rtags server in c-mode and c++-mode buffers. -If rtags or rdm aren't available, fail silently instead of throwing a breaking error." - (and (require 'rtags nil t) - (rtags-executable-find rtags-rdm-binary-name) - (rtags-start-process-unless-running))) - - (setq rtags-autostart-diagnostics t - rtags-use-bookmarks nil - rtags-completions-enabled nil - rtags-display-result-backend - (cond ((modulep! :completion ivy) 'ivy) - ((modulep! :completion helm) 'helm) - ('default)) - ;; These executables are named rtags-* on debian - rtags-rc-binary-name - (or (cl-find-if #'executable-find (list rtags-rc-binary-name "rtags-rc")) - rtags-rc-binary-name) - rtags-rdm-binary-name - (or (cl-find-if #'executable-find (list rtags-rdm-binary-name "rtags-rdm")) - rtags-rdm-binary-name) - ;; If not using ivy or helm to view results, use a pop-up window rather - ;; than displaying it in the current window... - rtags-results-buffer-other-window t - ;; ...and don't auto-jump to first match before making a selection. - rtags-jump-to-first-match nil) - - (set-lookup-handlers! '(c-mode c++-mode) - :definition #'rtags-find-symbol-at-point - :references #'rtags-find-references-at-point) - - ;; Use rtags-imenu instead of imenu/counsel-imenu - (define-key! (c-mode-map c++-mode-map) [remap imenu] #'+cc/imenu) - - ;; Ensure rtags cleans up after itself properly when exiting Emacs, rather - ;; than display a jarring confirmation prompt for killing it. - (add-hook! 'kill-emacs-hook (ignore-errors (rtags-cancel-process))) - - (add-hook 'rtags-jump-hook #'better-jumper-set-jump) - (add-hook 'rtags-after-find-file-hook #'recenter)) - - -;; -;; LSP - -(when (modulep! +lsp) - (add-hook! '(c-mode-local-vars-hook - c++-mode-local-vars-hook - objc-mode-local-vars-hook - cmake-mode-local-vars-hook) - :append #'lsp!) - - (map! :after ccls - :map (c-mode-map c++-mode-map) - :n "C-h" (cmd! (ccls-navigate "U")) - :n "C-j" (cmd! (ccls-navigate "R")) - :n "C-k" (cmd! (ccls-navigate "L")) - :n "C-l" (cmd! (ccls-navigate "D")) - (:localleader - :desc "Preprocess file" "lp" #'ccls-preprocess-file - :desc "Reload cache & CCLS" "lf" #'ccls-reload) - (:after lsp-ui-peek - (:localleader - :desc "Callers list" "c" #'+cc/ccls-show-caller - :desc "Callees list" "C" #'+cc/ccls-show-callee - :desc "References (address)" "a" #'+cc/ccls-show-references-address - :desc "References (not call)" "f" #'+cc/ccls-show-references-not-call - :desc "References (Macro)" "m" #'+cc/ccls-show-references-macro - :desc "References (Read)" "r" #'+cc/ccls-show-references-read - :desc "References (Write)" "w" #'+cc/ccls-show-references-write))) - - (when (modulep! :tools lsp +eglot) - ;; Map eglot specific helper - (map! :localleader - :after cc-mode - :map c++-mode-map - :desc "Show type inheritance hierarchy" "ct" #'+cc/eglot-ccls-inheritance-hierarchy) - - ;; NOTE : This setting is untested yet - (after! eglot - (when IS-MAC - (add-to-list 'eglot-workspace-configuration - `((:ccls . ((:clang . ,(list :extraArgs ["-isystem/Library/Developer/CommandLineTools/usr/include/c++/v1" - "-isystem/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include" - "-isystem/usr/local/include"] - :resourceDir (cdr (doom-call-process "clang" "-print-resource-dir")))))))))))) - -(use-package! ccls - :when (modulep! +lsp) - :unless (modulep! :tools lsp +eglot) - :defer t - :init - (defvar ccls-sem-highlight-method 'font-lock) - (after! projectile - (add-to-list 'projectile-globally-ignored-directories "^.ccls-cache$") - (add-to-list 'projectile-project-root-files-bottom-up ".ccls-root") - (add-to-list 'projectile-project-root-files-top-down-recurring "compile_commands.json")) - ;; Avoid using `:after' because it ties the :config below to when `lsp-mode' - ;; loads, rather than `ccls' loads. - (after! lsp-mode (require 'ccls)) - :config - (set-evil-initial-state! 'ccls-tree-mode 'emacs) - ;; Disable `ccls-sem-highlight-method' if `lsp-enable-semantic-highlighting' - ;; is nil. Otherwise, it appears ccls bypasses it. - (setq-hook! 'lsp-configure-hook - ccls-sem-highlight-method (if lsp-enable-semantic-highlighting - ccls-sem-highlight-method)) - (when (or IS-MAC - IS-LINUX) - (setq ccls-initialization-options - `(:index (:trackDependency 1 - :threads ,(max 1 (/ (doom-system-cpus) 2)))))) - (when IS-MAC - (setq ccls-initialization-options - (append ccls-initialization-options - `(:clang ,(list :extraArgs ["-isystem/Library/Developer/CommandLineTools/usr/include/c++/v1" - "-isystem/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include" - "-isystem/usr/local/include"] - :resourceDir (cdr (doom-call-process "clang" "-print-resource-dir")))))))) diff --git a/.config/emacs/modules/lang/cc/doctor.el b/.config/emacs/modules/lang/cc/doctor.el @@ -1,28 +0,0 @@ -;; -*- lexical-binding: t; no-byte-compile: t; -*- -;;; lang/cc/doctor.el - -(assert! (or (not (modulep! +lsp)) - (modulep! :tools lsp)) - "This module requires (:tools lsp)") - -(assert! (or (not (modulep! +tree-sitter)) - (modulep! :tools tree-sitter)) - "This module requires (:tools tree-sitter)") - -(when (require 'rtags nil t) - ;; rtags - (when-let (bins (cl-remove-if #'rtags-executable-find - (list rtags-rdm-binary-name - rtags-rc-binary-name))) - (warn! "Couldn't find the rtag client and/or server programs %s. Disabling rtags support" - bins))) - -;; irony server -(when (require 'irony nil t) - (unless (file-directory-p irony-server-install-prefix) - (warn! "Irony server isn't installed. Run M-x irony-install-server"))) - -(when (modulep! :completion company) - ;; glslangValidator - (unless (executable-find "glslangValidator") - (warn! "Couldn't find glslangValidator. GLSL code completion is disabled"))) diff --git a/.config/emacs/modules/lang/cc/packages.el b/.config/emacs/modules/lang/cc/packages.el @@ -1,34 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/cc/packages.el - -(package! cmake-mode - :recipe (:host github :repo "emacsmirror/cmake-mode" :files (:defaults "*")) - :pin "6ce56331445ad7ef79a11d5a3163364a883067c2") -(package! cuda-mode :pin "7f593518fd135fc6af994024bcb47986dfa502d2") -(package! demangle-mode :pin "04f545adab066708d6151f13da65aaf519f8ac4e") -(package! disaster :pin "0c13bd244cc43773af81e52ce73a55f199d58a61") -(package! modern-cpp-font-lock :pin "43c6b68ff58fccdf9deef11674a172e4eaa8455c") -(package! opencl-mode :pin "15091eff92c33ee0d1ece40eb99299ef79fee92d") - -(when (package! glsl-mode :pin "9b2e5f28e489a1f73c4aed734105618ac0dc0c43") - (when (modulep! :completion company) - (package! company-glsl - :recipe (:host github :repo "Kaali/company-glsl") - :pin "404cd0694ab34971f9c01eb22126cd2e7d3f9dc4"))) - -(if (modulep! +lsp) - (unless (modulep! :tools lsp +eglot) - ;; ccls package is necessary only for lsp-mode. - (package! ccls :pin "29d231590fad39b4d658d9262859e60669edb9b0")) - (when (package! irony :pin "870d1576fb279bb93f776a71e65f45283c423a9e") - (package! irony-eldoc :pin "73e79a89fad982a2ba072f2fcc1b4e41f0aa2978") - (when (modulep! :checkers syntax) - (package! flycheck-irony :pin "42dbecd4a865cabeb301193bb4d660e26ae3befe")) - (when (modulep! :completion company) - (package! company-irony :pin "b44711dfce445610c1ffaec4951c6ff3882b216a") - (package! company-irony-c-headers :pin "72c386aeb079fb261d9ec02e39211272f76bbd97"))) - (when (package! rtags :pin "9e442e5b30b6e9bbd3eb3bbc59db33177f15d730") - (when (modulep! :completion ivy) - (package! ivy-rtags)) - (when (modulep! :completion helm) - (package! helm-rtags)))) diff --git a/.config/emacs/modules/lang/clojure/README.org b/.config/emacs/modules/lang/clojure/README.org @@ -1,163 +0,0 @@ -#+title: :lang clojure -#+subtitle: Java with a lisp -#+created: May 30, 2017 -#+since: 2.0.3 - -* Description :unfold: -This module adds support for the Clojure(Script) language. - -- Interactive development environment (~cider~): REPL, compilation, debugging, - running tests, definitions & documentation lookup, code completion, and much - more -- Refactoring (~clj-refactor~) -- Linting (~clj-kondo~), requires [[doom-module::checkers syntax]] -- LSP support (~clojure-lsp~), required [[doom-module:+lsp]] - -** Maintainers -- [[doom-user:][@elken]] - -** Module flags -- +lsp :: - Enable LSP support for ~clojure-mode~ (alongside Cider). Requires [[doom-module::tools lsp]] - and a langserver (supports [[https://clojure-lsp.io/][clojure-lsp]]). -- +tree-sitter :: - Leverages tree-sitter for better syntax highlighting and structural text - editing. Requires [[doom-module::tools tree-sitter]]. - -** Packages -- [[doom-package:cider]] -- [[doom-package:clj-refactor]] -- [[doom-package:flycheck-clj-kondo]] if [[doom-module::checkers syntax]] - -** Hacks -- Error messages emitted from CIDER are piped into the REPL buffer when it is - first opened, to make them easier to notice. -- Disabled the help banner when opening the cider REPL. - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires: -- [[https://clojure.org/][clojure]] -- [[https://github.com/borkdude/clj-kondo][clj-kondo]], for linting code (if [[doom-module::checkers syntax]]) -- [[https://clojure-lsp.github.io/clojure-lsp/][clojure-lsp]], for LSP support (if [[doom-module:+lsp]]) -- [[https://github.com/babashka/neil][neil]] for the ability to add packages to your Clojure project from Emacs -- [[https://github.com/borkdude/jet][jet]] for jet integration - -* Usage - -Below is a listing of the various keybinds provided by the module. - -** REPL management -For the most part, general usage should fall into: - -- Open a Clojure project -- Open/connect to a REPL - -As such, these bindings are most likely to be used. - -| Keybind | Command | -|-----------------------------+----------------------------------------------------| -| [[kbd:][<localleader> ']] | ~cider-jack-in-clj~ | -| [[kbd:][<localleader> c]] | ~cider-connect-clj~ | -| [[kbd:][<localleader> C]] | ~cider-connect-cljs~ | -| [[kbd:][<localleader> m "]] | ~cider-jack-in-cljs~ | -| [[kbd:][<localleader> r R]] | ~cider-restart~ | -| [[kbd:][<localleader> r q]] | ~cider-quit~ | -| [[kbd:][<localleader> r B]] | ~+clojure/cider-switch-to-repl-buffer-and-switch-ns~ | -| [[kbd:][<localleader> r L]] | ~cider-load-buffer-and-switch-to-repl-buffer~ | -| [[kbd:][<localleader> r b]] | ~cider-switch-to-repl-buffer~ | -| [[kbd:][<localleader> r c]] | ~cider-find-and-clear-repl-output~ | -| [[kbd:][<localleader> r l]] | ~cider-load-buffer~ | -| [[kbd:][<localleader> r n]] | ~cider-repl-set-ns~ | -| [[kbd:][<localleader> r r]] | ~cider-ns-refresh~ | - -** Tests -The module also provides support for running tests through cider, including a nicely formatted output. - -| Keybind | Command | -|-----------------------------+--------------------------------------| -| [[kbd:][<localleader> t a]] | ~cider-test-rerun-test~ | -| [[kbd:][<localleader> t l]] | ~cider-test-run-loaded-tests~ | -| [[kbd:][<localleader> t n]] | ~cider-test-run-ns-tests~ | -| [[kbd:][<localleader> t p]] | ~cider-test-run-project-tests~ | -| [[kbd:][<localleader> t r]] | ~cider-test-rerun-failed-tests~ | -| [[kbd:][<localleader> t s]] | ~cider-test-run-ns-tests-with-filters~ | -| [[kbd:][<localleader> t t]] | ~cider-test-run-test~ | - - -** Search/navigation -Some useful bindings for navigating around namespaces and symbols. When using [[doom-module:+lsp]], the bindings in [[doom-module::tools lsp]] are supported. - -| Keybind | Command | -|-----------------------------+---------------------| -| [[kbd:][<localleader> g b]] | ~cider-pop-back~ | -| [[kbd:][<localleader> g g]] | ~cider-find-var~ | -| [[kbd:][<localleader> g n]] | ~cider-find-ns~ | -| [[kbd:][<localleader> h n]] | ~cider-find-ns~ | -| [[kbd:][<localleader> n N]] | ~cider-browse-ns-all~ | -| [[kbd:][<localleader> n n]] | ~cider-browse-ns~ | -| [[kbd:][<localleader> h a]] | ~cider-apropos~ | - -** Evaluation -Outside of the [[kbd:][SPC m e]] bindings for evaluating forms, the following are also available; including some to pretty-print the results. - -| Keybind | Command | -|-----------------------------+----------------------------------------| -| [[kbd:][<localleader> e D]] | ~cider-insert-defun-in-repl~ | -| [[kbd:][<localleader> e E]] | ~cider-insert-last-sexp-in-repl~ | -| [[kbd:][<localleader> e R]] | ~cider-insert-region-in-repl~ | -| [[kbd:][<localleader> e b]] | ~cider-eval-buffer~ | -| [[kbd:][<localleader> e d]] | ~cider-eval-defun-at-point~ | -| [[kbd:][<localleader> e e]] | ~cider-eval-last-sexp~ | -| [[kbd:][<localleader> e r]] | ~cider-eval-region~ | -| [[kbd:][<localleader> p d]] | ~cider-pprint-eval-defun-at-point~ | -| [[kbd:][<localleader> p D]] | ~cider-pprint-eval-defun-to-comment~ | -| [[kbd:][<localleader> p p]] | ~cider-pprint-eval-last-sexp~ | -| [[kbd:][<localleader> p P]] | ~cider-pprint-eval-last-sexp-to-comment~ | -| [[kbd:][<localleader> p r]] | ~cider-pprint-eval-last-sexp-to-repl~ | - -** Debugging -A number of bindings to provide useful overlays that help during debugging. ~cider-enlighten-mode~ is a mode that will highlight the results of a function evaluation, /including the locals/. See a demo [[https://www.youtube.com/watch?v=tCu2AewBTR4][here]]. - -| Keybind | Command | -|-----------------------------+---------------------------| -| [[kbd:][<localleader> M]] | ~cider-macroexpand-all~ | -| [[kbd:][<localleader> R]] | ~hydra-cljr-help-menu/body~ | -| [[kbd:][<localleader> e u]] | ~cider-undef~ | -| [[kbd:][<localleader> i e]] | ~cider-enlighten-mode~ | -| [[kbd:][<localleader> i i]] | ~cider-inspect~ | -| [[kbd:][<localleader> i r]] | ~cider-inspect-last-result~ | -| [[kbd:][<localleader> m]] | ~cider-macroexpand-1~ | - -** Help -Several bindings used for viewing documentation for various functions, both inside and outside of both a REPL and Emacs ([[kbd:][K]] for example uses the sources and a cached version of clojuredocs) - -| Keybind | Command | -|-----------------------------+-----------------------| -| [[kbd:][<localleader> h c]] | ~cider-clojuredocs~ | -| [[kbd:][<localleader> h d]] | ~cider-doc~ | -| [[kbd:][<localleader> h j]] | ~cider-javadoc~ | -| [[kbd:][<localleader> h w]] | ~cider-clojuredocs-web~ | -| [[kbd:][K]] | ~+lookup/documentation~ | - - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/clojure/autoload.el b/.config/emacs/modules/lang/clojure/autoload.el @@ -1,44 +0,0 @@ -;;; lang/clojure/autoload.el -*- lexical-binding: t; -*- - -;;;###autoload -(defun +clojure-cider-lookup-definition (identifier) - "A lookup handler for `cider-mode'. - -This is necessary to fix `cider-find-dwim's inability to capture the full symbol -at point." - (cider-find-dwim identifier)) - - -;; -;;; Commands - -;;;###autoload -(defun +clojure/open-repl (&optional arg type) - "Open a Cider REPL for clojure and return the buffer." - (interactive "P") - ;; TODO Better error handling - ;; type is `clj' for clojure and `cljs' for clojurescript - ;; ... with no type specified, assume `clj'. - (let ((type (or type 'clj))) - (if-let (buffer (cider-current-repl type)) - (pop-to-buffer buffer) - (let ((process (cond ((eq type 'clj) (cider-jack-in-clj arg)) - ((eq type 'cljs) (cider-jack-in-cljs arg))))) - (message "Starting CIDER server for the first time...") - (while (and (process-live-p process) - (not (cider-current-repl type))) - (sit-for 1)) - (message "Starting CIDER server for the first time...done") - (pop-to-buffer (cider-current-repl type)))))) - -;;;###autoload -(defun +clojure/open-cljs-repl (&optional arg) - "Open a Cider REPL for clojurescript and return the buffer." - (interactive "P") - (+clojure/open-repl arg 'cljs)) - -;;;###autoload -(defun +clojure/cider-switch-to-repl-buffer-and-switch-ns () - "TODO" - (interactive) - (cider-switch-to-repl-buffer t)) diff --git a/.config/emacs/modules/lang/clojure/config.el b/.config/emacs/modules/lang/clojure/config.el @@ -1,289 +0,0 @@ -;;; lang/clojure/config.el -*- lexical-binding: t; -*- - -(after! projectile - (pushnew! projectile-project-root-files "project.clj" "build.boot" "deps.edn")) - -;; Large clojure buffers tend to be slower than large buffers of other modes, so -;; it should have a lower threshold too. -(add-to-list 'doom-large-file-size-alist '("\\.\\(?:clj[sc]?\\|dtm\\|edn\\)\\'" . 0.5)) - -(defvar +clojure-load-clj-refactor-with-lsp nil - "Whether or not to include clj-refactor along with clojure-lsp.") - -;; -;;; Packages - -(use-package! clojure-mode - :hook (clojure-mode . rainbow-delimiters-mode) - :config - (when (modulep! +lsp) - (add-hook! '(clojure-mode-local-vars-hook - clojurec-mode-local-vars-hook - clojurescript-mode-local-vars-hook) - :append - (defun +clojure-disable-lsp-indentation-h () - (setq-local lsp-enable-indentation nil)) - #'lsp!) - (after! lsp-clojure - (dolist (m '(clojure-mode - clojurec-mode - clojurescript-mode - clojurex-mode)) - (add-to-list 'lsp-language-id-configuration (cons m "clojure"))))) - - (when (modulep! +tree-sitter) - (add-hook! '(clojure-mode-local-vars-hook - clojurec-mode-local-vars-hook - clojurescript-mode-local-vars-hook) - :append - #'tree-sitter!))) - - -;; `cider-mode' is used instead of the typical `cider' package due to the main -;; library being loaded only when is absolutely needed, which is too late for -;; our purposes -(use-package! cider-mode - ;; NOTE if `org-directory' doesn't exist, `cider-jack' in won't work - :hook (clojure-mode-local-vars . cider-mode) - :init - (after! clojure-mode - (set-repl-handler! '(clojure-mode clojurec-mode) #'+clojure/open-repl :persist t) - (set-repl-handler! 'clojurescript-mode #'+clojure/open-cljs-repl :persist t) - (set-eval-handler! '(clojure-mode clojurescript-mode clojurec-mode) #'cider-eval-region)) - - ;; HACK Fix radian-software/radian#446: CIDER tries to calculate the frame's - ;; background too early; sometimes before the initial frame has been - ;; initialized, causing errors. - (defvar cider-docview-code-background-color nil) - (defvar cider-stacktrace-frames-background-color nil) - (add-transient-hook! #'cider-docview-fontify-code-blocks (cider--docview-adapt-to-theme)) - (add-transient-hook! #'cider-stacktrace-render-cause (cider--stacktrace-adapt-to-theme)) - :config - (add-hook 'cider-mode-hook #'eldoc-mode) - (unless (modulep! +lsp) - (set-lookup-handlers! '(cider-mode cider-repl-mode) - :definition #'+clojure-cider-lookup-definition - :documentation #'cider-doc)) - (set-popup-rules! - '(("^\\*cider-error*" :ignore t) - ("^\\*cider-repl" :quit nil :ttl nil) - ("^\\*cider-repl-history" :vslot 2 :ttl nil))) - - (setq nrepl-hide-special-buffers t - nrepl-log-messages nil - cider-font-lock-dynamically '(macro core function var deprecated) - cider-overlays-use-font-lock t - cider-prompt-for-symbol nil - cider-repl-history-display-duplicates nil - cider-repl-history-display-style 'one-line - cider-repl-history-file (concat doom-cache-dir "cider-repl-history") - cider-repl-history-highlight-current-entry t - cider-repl-history-quit-action 'delete-and-restore - cider-repl-history-highlight-inserted-item t - cider-repl-history-size 1000 - cider-repl-result-prefix ";; => " - cider-repl-print-length 100 - cider-repl-use-clojure-font-lock t - cider-repl-use-pretty-printing t - cider-repl-wrap-history nil - cider-stacktrace-default-filters '(tooling dup) - - ;; Don't focus the CIDER REPL when it starts. Since it can take so long - ;; to start up, you either wait for a minute doing nothing or be - ;; prepared for your cursor to suddenly change buffers without warning. - ;; See https://github.com/clojure-emacs/cider/issues/1872 - cider-repl-pop-to-buffer-on-connect 'display-only) - - (when (modulep! +lsp) - (setq cider-eldoc-display-for-symbol-at-point nil - cider-font-lock-dynamically nil) - (add-hook! 'cider-mode-hook - (defun +clojure--cider-disable-completion () - "Use lsp completion instead of cider." - (remove-hook 'completion-at-point-functions #'cider-complete-at-point t)))) - - ;; UX: CIDER's error messages get quietly funneled into *nrepl-server*. That - ;; sort of information would be more helpful displayed front and center when - ;; opening a *cider-repl*. - (add-hook! 'cider-connected-hook - (defun +clojure--cider-dump-nrepl-server-log-h () - "Copy contents of *nrepl-server* to beginning of *cider-repl*." - (when (buffer-live-p nrepl-server-buffer) - (save-excursion - (goto-char (point-min)) - (insert - (with-current-buffer nrepl-server-buffer - (buffer-string))))))) - - ;; When in cider-debug-mode, override evil keys to not interfere with debug keys - (after! evil - (add-hook! cider--debug-mode - (defun +clojure--cider-setup-debug () - "Setup cider debug to override evil keys cleanly" - (evil-make-overriding-map cider--debug-mode-map 'normal) - (evil-normalize-keymaps)))) - - (when (modulep! :ui modeline +light) - (defvar-local cider-modeline-icon nil) - - (defun +clojure--cider-set-modeline (face label) - "Update repl icon on modeline with cider information." - (setq cider-modeline-icon (concat - " " - (+modeline-format-icon 'faicon "terminal" "" face label -0.0575) - " ")) - (add-to-list 'global-mode-string - '(t (:eval cider-modeline-icon)) - 'append)) - - (add-hook! '(cider-connected-hook - cider-disconnected-hook - cider-mode-hook) - (defun +clojure--cider-connected-update-modeline () - "Update modeline with cider connection state." - (let* ((connected (cider-connected-p)) - (face (if connected 'warning 'shadow)) - (label (if connected "Cider connected" "Cider disconnected"))) - (+clojure--cider-set-modeline face label)))) - - (add-hook! '(cider-before-eval-hook) - (defun +clojure--cider-before-eval-hook-update-modeline () - "Update modeline with cider state before eval." - (+clojure--cider-set-modeline 'warning "Cider evaluating"))) - - (add-hook! '(cider-after-eval-done-hook) - (defun +clojure--cider-after-eval-done-hook-update-modeline () - "Update modeline with cider state after eval." - (+clojure--cider-set-modeline 'success "Cider syncronized"))) - - (add-hook! '(cider-file-loaded-hook) - (defun +clojure--cider-file-loaded-update-modeline () - "Update modeline with cider file loaded state." - (+clojure--cider-set-modeline 'success "Cider syncronized")))) - - ;; Ensure that CIDER is used for sessions in org buffers. - (when (modulep! :lang org) - (after! ob-clojure - (setq! org-babel-clojure-backend 'cider))) - - ;; The CIDER welcome message obscures error messages that the above code is - ;; supposed to be make visible. - (setq cider-repl-display-help-banner nil) - - (map! (:localleader - (:map (clojure-mode-map clojurescript-mode-map clojurec-mode-map) - "'" #'cider-jack-in-clj - "\"" #'cider-jack-in-cljs - "c" #'cider-connect-clj - "C" #'cider-connect-cljs - "m" #'cider-macroexpand-1 - "M" #'cider-macroexpand-all - (:prefix ("d" . "debug") - "d" #'cider-debug-defun-at-point) - (:prefix ("e" . "eval") - "b" #'cider-eval-buffer - "d" #'cider-eval-defun-at-point - "D" #'cider-insert-defun-in-repl - "e" #'cider-eval-last-sexp - "E" #'cider-insert-last-sexp-in-repl - "r" #'cider-eval-region - "R" #'cider-insert-region-in-repl - "u" #'cider-undef) - (:prefix ("g" . "goto") - "b" #'cider-pop-back - "g" #'cider-find-var - "n" #'cider-find-ns) - (:prefix ("h" . "help") - "n" #'cider-find-ns - "a" #'cider-apropos - "c" #'cider-clojuredocs - "d" #'cider-doc - "j" #'cider-javadoc - "w" #'cider-clojuredocs-web) - (:prefix ("i" . "inspect") - "e" #'cider-enlighten-mode - "i" #'cider-inspect - "r" #'cider-inspect-last-result) - (:prefix ("n" . "namespace") - "n" #'cider-browse-ns - "N" #'cider-browse-ns-all - "r" #'cider-ns-refresh) - (:prefix ("p" . "print") - "p" #'cider-pprint-eval-last-sexp - "P" #'cider-pprint-eval-last-sexp-to-comment - "d" #'cider-pprint-eval-defun-at-point - "D" #'cider-pprint-eval-defun-to-comment - "r" #'cider-pprint-eval-last-sexp-to-repl) - (:prefix ("r" . "repl") - "n" #'cider-repl-set-ns - "q" #'cider-quit - "r" #'cider-ns-refresh - "R" #'cider-restart - "b" #'cider-switch-to-repl-buffer - "B" #'+clojure/cider-switch-to-repl-buffer-and-switch-ns - "c" #'cider-find-and-clear-repl-output - "l" #'cider-load-buffer - "L" #'cider-load-buffer-and-switch-to-repl-buffer) - (:prefix ("t" . "test") - "a" #'cider-test-rerun-test - "l" #'cider-test-run-loaded-tests - "n" #'cider-test-run-ns-tests - "p" #'cider-test-run-project-tests - "r" #'cider-test-rerun-failed-tests - "s" #'cider-test-run-ns-tests-with-filters - "t" #'cider-test-run-test))) - - (:when (modulep! :editor evil +everywhere) - :map cider-repl-mode-map - :i [S-return] #'cider-repl-newline-and-indent - :i [M-return] #'cider-repl-return - (:localleader - "n" #'cider-repl-set-ns - "q" #'cider-quit - "r" #'cider-ns-refresh - "R" #'cider-restart - "c" #'cider-repl-clear-buffer) - :map cider-repl-history-mode-map - :i [return] #'cider-repl-history-insert-and-quit - :i "q" #'cider-repl-history-quit - :i "l" #'cider-repl-history-occur - :i "s" #'cider-repl-history-search-forward - :i "r" #'cider-repl-history-search-backward - :i "U" #'cider-repl-history-undo-other-window))) - - -(use-package! clj-refactor - :when (or (not (modulep! +lsp)) - +clojure-load-clj-refactor-with-lsp) - :hook (clojure-mode . clj-refactor-mode) - :config - (set-lookup-handlers! 'clj-refactor-mode - :references #'cljr-find-usages) - (map! :map clojure-mode-map - :localleader - :desc "refactor" "R" #'hydra-cljr-help-menu/body)) - - -;; clojure-lsp already uses clj-kondo under the hood -(use-package! flycheck-clj-kondo - :when (and (modulep! :checkers syntax) - (not (modulep! +lsp))) - :after flycheck) - - -(use-package! neil - :commands (neil-find-clojure-package) - :config - (setq neil-prompt-for-version-p nil - neil-inject-dep-to-project-p t) - (map! :map (clojure-mode-map clojurescript-mode-map clojurec-mode-map) - :localleader - "f" #'neil-find-clojure-package)) - - -(use-package! jet - :commands (jet) - :config - (map! :map (clojure-mode-map clojurescript-mode-map clojurec-mode-map) - :localleader - "j" #'jet)) diff --git a/.config/emacs/modules/lang/clojure/doctor.el b/.config/emacs/modules/lang/clojure/doctor.el @@ -1,7 +0,0 @@ -;; -*- lexical-binding: t; no-byte-compile: t; -*- -;;; lang/clojure/doctor.el - -(when (and (modulep! :checkers syntax) - (not (modulep! +lsp))) - (unless (executable-find "clj-kondo") - (warn! "Couldn't find clj-kondo. flycheck-clj-kondo will not work."))) diff --git a/.config/emacs/modules/lang/clojure/packages.el b/.config/emacs/modules/lang/clojure/packages.el @@ -1,25 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/clojure/packages.el - -;; HACK Fix #5577. Paredit is a cider dependency. We install paredit ourselves -;; to get it from emacsmirror, because the original upstream is a custom -;; git server with shallow clones disabled. -(package! paredit - :recipe (:host github :repo "emacsmirror/paredit") - :pin "9a2c4b37fc8c1c7bdbb1f86fdec874c0d0652e64") - -;; HACK Forward declare these clj-refactor/cider deps so that their deps are -;; byte-compiled first. -(package! parseclj :pin "4d0e780e00f1828b00c43099e6eebc6582998f72") -(package! parseedn :pin "a09686fbb9113b8b1b4f20c9e1dc0d6fea01a64f") - -;;; Core packages -(package! clojure-mode :pin "3453cd229b412227aaffd1dc2870fa8fa213c5b1") -(package! clj-refactor :pin "b5abe655e572a6ecfed02bb8164b64716ef76b8e") -(package! cider :pin "1ed5163433c991c00ea83fdd4447e8daf4aeccbe") -(when (modulep! :checkers syntax) - (package! flycheck-clj-kondo :pin "ff7bed2315755cfe02ef471edf522e27b78cd5ca")) -(package! jet :pin "f007660c568e924e32d486a02aa4cd18203313cc") -(package! neil - :recipe (:host github :repo "babashka/neil" :files ("*.el")) - :pin "1dbac785cee4af8ad499839adbb83a8a297e7c70") diff --git a/.config/emacs/modules/lang/common-lisp/README.org b/.config/emacs/modules/lang/common-lisp/README.org @@ -1,79 +0,0 @@ -#+title: :lang common-lisp -#+subtitle: If you've seen one lisp, you've seen them all -#+created: June 13, 2018 -#+since: 21.12.0 - -* Description :unfold: -This module provides support for [[https://lisp-lang.org/][Common Lisp]] and the [[doom-package:Sly]] development -environment. Common Lisp is not a single language but a specification, with many -competing compiler implementations. By default, [[http://www.sbcl.org/][Steel Bank Common Lisp]] (SBCL) is -assumed to be installed, but this can be configured. - -Common Lisp benefits from a mature specification and rich standard library. -Thanks to its powerful REPL and debugger, it boasts an "interactive programming" -style often unseen in other languages. Compiled Common Lisp programs are trusted -to run unmodified for a long time. - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:sly]] -- [[doom-package:sly-macrostep]] -- [[doom-package:sly-repl-ansi-color]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires [[http://www.sbcl.org/][SBCL]]. - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -This module does not integrate with [[doom-module::tools lsp]]. Sly (and SLIME before it) is -considered the defacto development environment for Common Lisp and provides much -of what is normally expected of an LSP, plus tight integration with the REPL and -Emacs. - -** Sly -Using this module is mostly a matter of using Sly. Please consider reading -through [[http://joaotavora.github.io/sly/#A-SLY-tour-for-SLIME-users][the Sly Tour]]. - -A Sly session will be started when you open a =.lisp= file. Use [[kbd:][<localleader> ']] -to switch to the REPL minibuffer. - -** org-mode -This module also enables the evaluation of =lisp= source blocks in Org Mode. -However, you will need a running Sly session for this to work. ~M-x sly~ starts -such a session if you didn't have one open already. - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -If you don't want Sly to use SBCL, you can configure the variable -~inferior-lisp-program~ to some other binary on your PATH. - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/common-lisp/autoload/common-lisp.el b/.config/emacs/modules/lang/common-lisp/autoload/common-lisp.el @@ -1,81 +0,0 @@ -;;; lang/common-lisp/autoload/common-lisp.el -*- lexical-binding: t; -*- - -;; HACK Fix #1772: void-variable sly-contribs errors due to sly packages (like -;; `sly-macrostep') trying to add to `sly-contribs' before it is defined. -;;;###autoload (defvar sly-contribs '(sly-fancy)) - -;;;###autoload -(defun +lisp/open-repl () - "Open the Sly REPL." - (interactive) - (require 'sly) - (if (sly-connected-p) (sly-mrepl) - (sly nil nil t) - (cl-labels ((recurse (attempt) - (sleep-for 1) - (cond ((sly-connected-p) (sly-mrepl)) - ((> attempt 5) (error "Failed to start Slynk process.")) - (t (recurse (1+ attempt)))))) - (recurse 1)))) - -;;;###autoload -(defun +lisp/load-project-systems () - "Load all systems of the current Lisp project into Sly." - (interactive) - (thread-last (+lisp--project-asd-file) - (+lisp--systems-from-asd) - (mapcar (lambda (s) (format ":%s" s))) - (funcall (lambda (ss) (string-join ss " "))) - (format "(ql:quickload '(%s))") - (sly-interactive-eval))) - -(defun +lisp--project-asd-file () - "Yield an absolute file path to the current project's `.asd' file." - (let* ((proot (doom-project-root)) - (files (doom-files-in proot :depth 1 :match "[.]asd$"))) - (pcase files - ('() (error "No .asd file found in: %s" proot)) - (`(,asdf) asdf) - (_ (error "Too many .asd files found in : %s" proot))))) - -(defun +lisp--systems-from-asd (asdf) - "Given a path to an ASDF project definition, extract the names of -the systems defined therein." - (let ((file (doom-file-read asdf)) - (patt "defsystem \"\\([a-z-/]+\\)")) - (when (not (string-match patt file)) - (error "No systems defined in: %s" asdf)) - (thread-last (s-match-strings-all patt file) - (mapcar #'cl-second)))) - -;; TODO Get this to run in a comint buffer? -;;;###autoload -(defun +lisp/test-system () - "Run `asdf:test-system' on the selected system of the current project." - (interactive) - (thread-last (+lisp--project-asd-file) - (+lisp--systems-from-asd) - (completing-read "Test which Lisp system?") - (format "(asdf:test-system :%s)") - (sly-interactive-eval))) - -;;;###autoload -(defun +lisp/reload-project () - "Restart the Sly session and reload the current project." - (interactive) - (sly-restart-inferior-lisp) - (cl-labels ((recurse (attempt) - (sleep-for 1) - (condition-case nil - (sly-eval "PONG") - (error (if (= 5 attempt) - (error "Failed to reload Lisp project in 5 attempts.") - (recurse (1+ attempt))))))) - (recurse 1) - (+lisp/load-project-systems))) - -;;;###autoload -(defun +lisp/find-file-in-quicklisp () - "Find a file belonging to a library downloaded by Quicklisp." - (interactive) - (doom-project-find-file "~/.quicklisp/dists/")) diff --git a/.config/emacs/modules/lang/common-lisp/config.el b/.config/emacs/modules/lang/common-lisp/config.el @@ -1,166 +0,0 @@ -;;; lang/common-lisp/config.el -*- lexical-binding: t; -*- - -;; `lisp-mode' is loaded at startup. In order to lazy load its config we need to -;; pretend it isn't loaded -(defer-feature! lisp-mode) - - -;; -;; packages - -;;;###package lisp-mode -(defvar inferior-lisp-program "sbcl") -(add-hook 'lisp-mode-hook #'rainbow-delimiters-mode) - - -(use-package! sly - :hook (lisp-mode-local-vars . sly-editing-mode) - :init - ;; I moved this hook to `lisp-mode-local-vars', so it only affects - ;; `lisp-mode', and not every other derived lisp mode (like `fennel-mode'). - ;; We run it twice because the hook is both autoloaded and evaluated at - ;; load-time, so it must be removed twice. - (after! (:or emacs sly) - (remove-hook 'lisp-mode-hook #'sly-editing-mode)) - - (after! lisp-mode - (set-repl-handler! 'lisp-mode #'+lisp/open-repl) - (set-eval-handler! 'lisp-mode #'sly-eval-region) - (set-lookup-handlers! 'lisp-mode - :definition #'sly-edit-definition - :documentation #'sly-describe-symbol)) - - ;; HACK Ensures that sly's contrib modules are loaded as soon as possible, but - ;; also as late as possible, so users have an opportunity to override - ;; `sly-contrib' in an `after!' block. - (add-hook! 'after-init-hook (after! sly (sly-setup))) - - :config - (setq sly-mrepl-history-file-name (concat doom-cache-dir "sly-mrepl-history") - sly-kill-without-query-p t - sly-net-coding-system 'utf-8-unix - ;; Doom defaults to non-fuzzy search, because it is faster and more - ;; precise (but requires more keystrokes). Change this to - ;; `sly-flex-completions' for fuzzy completion - sly-complete-symbol-function 'sly-simple-completions) - - (set-popup-rules! - '(("^\\*sly-mrepl" :vslot 2 :size 0.3 :quit nil :ttl nil) - ("^\\*sly-compilation" :vslot 3 :ttl nil) - ("^\\*sly-traces" :vslot 4 :ttl nil) - ("^\\*sly-description" :vslot 5 :size 0.3 :ttl 0) - ;; Do not display debugger or inspector buffers in a popup window. These - ;; buffers are meant to be displayed with sufficient vertical space. - ("^\\*sly-\\(?:db\\|inspector\\)" :ignore t))) - - (defun +common-lisp--cleanup-sly-maybe-h () - "Kill processes and leftover buffers when killing the last sly buffer." - (unless (cl-loop for buf in (delq (current-buffer) (buffer-list)) - if (and (buffer-local-value 'sly-mode buf) - (get-buffer-window buf)) - return t) - (dolist (conn (sly--purge-connections)) - (sly-quit-lisp-internal conn 'sly-quit-sentinel t)) - (let (kill-buffer-hook kill-buffer-query-functions) - (mapc #'kill-buffer - (cl-loop for buf in (delq (current-buffer) (buffer-list)) - if (buffer-local-value 'sly-mode buf) - collect buf))))) - - (add-hook! 'sly-mode-hook - (defun +common-lisp-init-sly-h () - "Attempt to auto-start sly when opening a lisp buffer." - (cond ((or (doom-temp-buffer-p (current-buffer)) - (sly-connected-p))) - ((executable-find (car (split-string inferior-lisp-program))) - (let ((sly-auto-start 'always)) - (sly-auto-start) - (add-hook 'kill-buffer-hook #'+common-lisp--cleanup-sly-maybe-h nil t))) - ((message "WARNING: Couldn't find `inferior-lisp-program' (%s)" - inferior-lisp-program))))) - - (map! (:map sly-db-mode-map - :n "gr" #'sly-db-restart-frame) - (:map sly-inspector-mode-map - :n "gb" #'sly-inspector-pop - :n "gr" #'sly-inspector-reinspect - :n "gR" #'sly-inspector-fetch-all - :n "K" #'sly-inspector-describe-inspectee) - (:map sly-xref-mode-map - :n "gr" #'sly-recompile-xref - :n "gR" #'sly-recompile-all-xrefs) - (:map lisp-mode-map - :n "gb" #'sly-pop-find-definition-stack) - - (:localleader - :map lisp-mode-map - :desc "Sly" "'" #'sly - :desc "Sly (ask)" ";" (cmd!! #'sly '-) - :desc "Expand macro" "m" #'macrostep-expand - :desc "Find local Quicklisp file" "f" #'+lisp/find-file-in-quicklisp - (:prefix ("c" . "compile") - :desc "Compile file" "c" #'sly-compile-file - :desc "Compile/load file" "C" #'sly-compile-and-load-file - :desc "Compile toplevel form" "f" #'sly-compile-defun - :desc "Load file" "l" #'sly-load-file - :desc "Remove notes" "n" #'sly-remove-notes - :desc "Compile region" "r" #'sly-compile-region) - (:prefix ("e" . "evaluate") - :desc "Evaluate buffer" "b" #'sly-eval-buffer - :desc "Evaluate last" "e" #'sly-eval-last-expression - :desc "Evaluate/print last" "E" #'sly-eval-print-last-expression - :desc "Evaluate defun" "f" #'sly-eval-defun - :desc "Undefine function" "F" #'sly-undefine-function - :desc "Evaluate region" "r" #'sly-eval-region) - (:prefix ("g" . "goto") - :desc "Go back" "b" #'sly-pop-find-definition-stack - :desc "Go to" "d" #'sly-edit-definition - :desc "Go to (other window)" "D" #'sly-edit-definition-other-window - :desc "Next note" "n" #'sly-next-note - :desc "Previous note" "N" #'sly-previous-note - :desc "Next sticker" "s" #'sly-stickers-next-sticker - :desc "Previous sticker" "S" #'sly-stickers-prev-sticker) - (:prefix ("h" . "help") - :desc "Who calls" "<" #'sly-who-calls - :desc "Calls who" ">" #'sly-calls-who - :desc "Lookup format directive" "~" #'hyperspec-lookup-format - :desc "Lookup reader macro" "#" #'hyperspec-lookup-reader-macro - :desc "Apropos" "a" #'sly-apropos - :desc "Who binds" "b" #'sly-who-binds - :desc "Disassemble symbol" "d" #'sly-disassemble-symbol - :desc "Describe symbol" "h" #'sly-describe-symbol - :desc "HyperSpec lookup" "H" #'sly-hyperspec-lookup - :desc "Who macro-expands" "m" #'sly-who-macroexpands - :desc "Apropos package" "p" #'sly-apropos-package - :desc "Who references" "r" #'sly-who-references - :desc "Who specializes" "s" #'sly-who-specializes - :desc "Who sets" "S" #'sly-who-sets) - (:prefix ("r" . "repl") - :desc "Clear REPL" "c" #'sly-mrepl-clear-repl - :desc "Load Project" "l" #'+lisp/load-project-systems - :desc "Quit connection" "q" #'sly-quit-lisp - :desc "Restart connection" "r" #'sly-restart-inferior-lisp - :desc "Reload Project" "R" #'+lisp/reload-project - :desc "Sync REPL" "s" #'sly-mrepl-sync) - (:prefix ("s" . "stickers") - :desc "Toggle breaking stickers" "b" #'sly-stickers-toggle-break-on-stickers - :desc "Clear defun stickers" "c" #'sly-stickers-clear-defun-stickers - :desc "Clear buffer stickers" "C" #'sly-stickers-clear-buffer-stickers - :desc "Fetch stickers" "f" #'sly-stickers-fetch - :desc "Replay stickers" "r" #'sly-stickers-replay - :desc "Add/remove sticker" "s" #'sly-stickers-dwim) - (:prefix ("t" . "test") - :desc "Test System" "s" #'+lisp/test-system) - (:prefix ("T" . "trace") - :desc "Toggle" "t" #'sly-toggle-trace-fdefinition - :desc "Toggle (fancy)" "T" #'sly-toggle-fancy-trace - :desc "Untrace all" "u" #'sly-untrace-all))) - - (when (modulep! :editor evil +everywhere) - (add-hook 'sly-mode-hook #'evil-normalize-keymaps))) - - -(use-package! sly-repl-ansi-color - :defer t - :init - (add-to-list 'sly-contribs 'sly-repl-ansi-color)) diff --git a/.config/emacs/modules/lang/common-lisp/doctor.el b/.config/emacs/modules/lang/common-lisp/doctor.el @@ -1,7 +0,0 @@ -;;; lang/common-lisp/doctor.el -*- lexical-binding: t; -*- - -(when (require 'sly nil t) - (let ((prog-name (car (split-string inferior-lisp-program)))) - (unless (executable-find prog-name) - (warn! "Couldn't find your `inferior-lisp-program' (%s). Is it installed?" - inferior-lisp-program)))) diff --git a/.config/emacs/modules/lang/common-lisp/packages.el b/.config/emacs/modules/lang/common-lisp/packages.el @@ -1,6 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/common-lisp/packages.el - -(when (package! sly :pin "f34c22289a2b3ab10e607f9f8822d62bb5c98cf5") - (package! sly-macrostep :pin "5113e4e926cd752b1d0bcc1508b3ebad5def5fad") - (package! sly-repl-ansi-color :pin "b9cd52d1cf927bf7e08582d46ab0bcf1d4fb5048")) diff --git a/.config/emacs/modules/lang/coq/README.org b/.config/emacs/modules/lang/coq/README.org @@ -1,53 +0,0 @@ -#+title: :lang coq -#+subtitle: Proofs as programs -#+created: August 14, 2018 -#+since: 21.12.0 (#804) - -* Description :unfold: -This module adds [[https://coq.inria.fr][coq]] support, powered by [[https://proofgeneral.github.io][Proof General]]. - -- Code completion ([[https://github.com/cpitclaudel/company-coq][company-coq]]) -- [[https://github.com/hlissner/doom-snippets/tree/master/coq-mode][Snippets]] - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:proof-general]] -- [[doom-package:company-coq]] - -** Hacks -+ Replaces coq-mode abbrevs with yasnippet snippets from doom's snippet library - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -+ [[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] -+ To use the completion features of company-coq you need to enable ~(:completion company)~ -+ Make sure you have Coq installed and that the ~coqtop~ command is available. This comes with a standard installation of Coq. - You can use your linux distribution's Coq package or one of the methods given on the [[https://coq.inria.fr/download][Coq website]]. - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Configuration -This module provides no additional configuration over that of the [[Packages]] it loads - -* Troubleshooting -See [[https://github.com/hlissner/doom-emacs/issues?q=is%3Aissue+is%3Aopen+label%3A%22%3Alang+coq"][related github issues]] -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/coq/config.el b/.config/emacs/modules/lang/coq/config.el @@ -1,91 +0,0 @@ -;;; lang/coq/config.el -*- lexical-binding: t; -*- - -;;;###package proof-general -(setq proof-splash-enable nil) - - -;;;###package coq -(setq-hook! 'coq-mode-hook - ;; Doom syncs other indent variables with `tab-width'; we trust major modes to - ;; set it -- which most of them do -- but coq-mode doesn't, so... - tab-width proof-indent - ;; HACK Fix #2081: Doom continues comments on RET, but coq-mode doesn't have a - ;; sane `comment-line-break-function', so... - comment-line-break-function nil) - -;; We've replaced coq-mode abbrevs with yasnippet snippets (in the snippets -;; library included with Doom). -(setq coq-mode-abbrev-table '()) - -(map! :after coq-mode - :map coq-mode-map - :localleader - "]" #'proof-assert-next-command-interactive - "[" #'proof-undo-last-successful-command - "." #'proof-goto-point - (:prefix ("l" . "layout") - "c" #'pg-response-clear-displays - "l" #'proof-layout-windows - "p" #'proof-prf) - (:prefix ("p" . "proof") - "i" #'proof-interrupt-process - "p" #'proof-process-buffer - "q" #'proof-shell-exit - "r" #'proof-retract-buffer) - (:prefix ("a" . "about/print/check") - "a" #'coq-Print - "A" #'coq-Print-with-all - "b" #'coq-About - "B" #'coq-About-with-all - "c" #'coq-Check - "C" #'coq-Check-show-all - "f" #'proof-find-theorems - (:prefix ("i" . "implicits") - "b" #'coq-About-with-implicits - "c" #'coq-Check-show-implicits - "i" #'coq-Print-with-implicits)) - (:prefix ("g" . "goto") - "e" #'proof-goto-command-end - "l" #'proof-goto-end-of-locked - "s" #'proof-goto-command-start) - (:prefix ("i" . "insert") - "c" #'coq-insert-command - "e" #'coq-end-Section - "i" #'coq-insert-intros - "r" #'coq-insert-requires - "s" #'coq-insert-section-or-module - "t" #'coq-insert-tactic - "T" #'coq-insert-tactical)) - - -;; This package provides more than just code completion, so we load it whether -;; or not :completion company is enabled. -(use-package! company-coq - :hook (coq-mode . company-coq-mode) - :config - (set-popup-rule! "^\\*\\(?:response\\|goals\\)\\*" :ignore t) - (set-lookup-handlers! 'company-coq-mode - :definition #'company-coq-jump-to-definition - :references #'company-coq-grep-symbol - :documentation #'company-coq-doc) - - (setq company-coq-disabled-features '(hello company-defaults spinner)) - - (if (modulep! :completion company) - (define-key coq-mode-map [remap company-complete-common] - #'company-indent-or-complete-common) - ;; `company-coq''s company defaults impose idle-completion on folks, so - ;; we'll set up company ourselves. See - ;; https://github.com/cpitclaudel/company-coq/issues/42 - (add-to-list 'company-coq-disabled-features 'company)) - - (map! :map coq-mode-map - :localleader - "ao" #'company-coq-occur - (:prefix "i" - "l" #'company-coq-lemma-from-goal - "m" #'company-coq-insert-match-construct) - (:prefix ("h" . "help") - "e" #'company-coq-document-error - "E" #'company-coq-browse-error-messages - "h" #'company-coq-doc))) diff --git a/.config/emacs/modules/lang/coq/packages.el b/.config/emacs/modules/lang/coq/packages.el @@ -1,5 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/coq/packages.el - -(package! proof-general :pin "8416875696cb0c4283e96fe721d343277882ecea") -(package! company-coq :pin "5affe7a96a25df9101f9e44bac8a828d8292c2fa") diff --git a/.config/emacs/modules/lang/crystal/README.org b/.config/emacs/modules/lang/crystal/README.org @@ -1,65 +0,0 @@ -#+title: :lang crystal -#+subtitle: Ruby at the speed of C -#+created: January 16, 2017 -#+since: 1.3 - -* Description :unfold: -This modules adds [[https://crystal-lang.org/][crystal]] support. - -- Syntax-checking (~flycheck~) -- REPL (~inf-crystal~) - -** Maintainers -This module has no dedicated maintainers. - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:crystal-mode]] -- [[doom-package:inf-crystal]] -- if [[doom-module::checkers syntax]] - - [[doom-package:flycheck-ameba]] - - [[doom-package:flycheck-crystal]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires: -- [[https://crystal-lang.org/install/][The crystal compiler]] -- [[https://github.com/crystal-community/icr][ICR]], for the REPL - -** Crystal -- MacOS: ~$ brew install crystal~ -- Arch Linux: ~$ pacman -S crystal shards~ - -** ICR (REPL) -[[https://github.com/crystal-community/icr#installation][Installation instructions]]. - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/crystal/config.el b/.config/emacs/modules/lang/crystal/config.el @@ -1,30 +0,0 @@ -;;; lang/crystal/config.el -*- lexical-binding: t; -*- - -(after! crystal-mode - (set-lookup-handlers! 'crystal-mode - :definition #'crystal-def-jump - :references #'crystal-tool-imp) - (when (modulep! +lsp) - (add-hook 'crystal-mode-local-vars-hook #'lsp! 'append)) - (map! :localleader - :map crystal-mode-map - :prefix "t" - "a" #'crystal-spec-all - "v" #'crystal-spec-buffer - "s" #'crystal-spec-line - "t" #'crystal-spec-switch)) - - -(use-package! flycheck-crystal - :when (modulep! :checkers syntax) - :after crystal-mode) - - -(use-package! flycheck-ameba - :when (modulep! :checkers syntax) - :after crystal-mode - :config (flycheck-ameba-setup)) - - -(use-package! inf-crystal - :commands crystal-switch-to-inf) diff --git a/.config/emacs/modules/lang/crystal/doctor.el b/.config/emacs/modules/lang/crystal/doctor.el @@ -1,5 +0,0 @@ -;; -*- lexical-binding: t; no-byte-compile: t; -*- -;;; lang/crystal/doctor.el - -(unless (executable-find "icr") - (warn! "Couldn't find icr. REPL will not work")) diff --git a/.config/emacs/modules/lang/crystal/packages.el b/.config/emacs/modules/lang/crystal/packages.el @@ -1,8 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/crystal/packages.el - -(package! crystal-mode :pin "9bfb9f0f566e937cc6a2f2913d1b56978b81dc99") -(package! inf-crystal :pin "02007b2a2a3bea44902d7c83c4acba1e39d278e3") -(when (modulep! :checkers syntax) - (package! flycheck-crystal :pin "9bfb9f0f566e937cc6a2f2913d1b56978b81dc99") - (package! flycheck-ameba :pin "0c4925ae0e998818326adcb47ed27ddf9761c7dc")) diff --git a/.config/emacs/modules/lang/csharp/README.org b/.config/emacs/modules/lang/csharp/README.org @@ -1,77 +0,0 @@ -#+title: :lang csharp -#+subtitle: Unity, .NET, and Mono shenanigans -#+created: February 20, 2017 -#+since: 2.0.0 - -* Description :unfold: -This module adds C# support to Emacs, powered by Omnisharp (directly or through -LSP). - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +dotnet :: - Enable Dotnet transient interface with Sharper -- +lsp :: - Enable LSP support for ~csharp-mode~. Requires [[doom-module::tools lsp]] and a langserver - (supports =omnisharp-roslyn=). -- +tree-sitter :: - Leverages tree-sitter for better syntax highlighting and structural text - editing. Requires [[doom-module::tools tree-sitter]]. -- +unity :: - Enable special support for the [[https://unity.com/][Unity game engine]] (particularly, support for - HLSL shaders). - -** Packages -- [[doom-package:csharp-mode]] -- [[doom-package:csproj-mode]] -- [[doom-package:shader-mode]] if [[doom-module:+unity]] -- [[doom-package:sharper]] if [[doom-module:+dotnet]] -- [[doom-package:sln-mode]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* TODO Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires: -- Mono (on UNIX platforms) -- .NET SDKs (on Windows) -- .NET Core 1.X - 3.X or .NET 5 for cross platform -- omnisharp-rosyln (if [[doom-module:+lsp]]) - -** TODO MacOS - -** Arch Linux -#+begin_src sh -pacman --needed --noconfirm -S mono -#+end_src - -** TODO NixOS - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/csharp/autoload.el b/.config/emacs/modules/lang/csharp/autoload.el @@ -1,15 +0,0 @@ -;;; lang/csharp/autoload.el -*- lexical-binding: t; -*- - -;;;###autoload -(defun +csharp-sp-point-in-type-p (id action context) - "Return t if point is in the right place for C# angle-brackets." - (and (sp-in-code-p id action context) - (cond ((eq action 'insert) - (sp-point-after-word-p id action context)) - ((eq action 'autoskip) - (/= (char-before) 32))))) - -;;;###autoload -(defun +csharp-kill-omnisharp-server-h () - (unless (doom-buffers-in-mode 'csharp-mode (buffer-list)) - (omnisharp-stop-server))) diff --git a/.config/emacs/modules/lang/csharp/config.el b/.config/emacs/modules/lang/csharp/config.el @@ -1,83 +0,0 @@ -;;; lang/csharp/config.el -*- lexical-binding: t; -*- - -(use-package! csharp-mode - :hook (csharp-mode . rainbow-delimiters-mode) - :config - (set-electric! 'csharp-mode :chars '(?\n ?\})) - (set-rotate-patterns! 'csharp-mode - :symbols '(("public" "protected" "private") - ("class" "struct"))) - (set-ligatures! 'csharp-mode - ;; Functional - :lambda "() =>" - ;; Types - :null "null" - :true "true" - :false "false" - :int "int" - :float "float" - :str "string" - :bool "bool" - :list "List" - ;; Flow - :not "!" - :in "in" - :and "&&" - :or "||" - :for "for" - :return "return" - :yield "yield") - - (sp-local-pair 'csharp-mode "<" ">" - :when '(+csharp-sp-point-in-type-p) - :post-handlers '(("| " "SPC"))) - - (when (modulep! +lsp) - (add-hook 'csharp-mode-local-vars-hook #'lsp! 'append)) - - (defadvice! +csharp-disable-clear-string-fences-a (fn &rest args) - "This turns off `c-clear-string-fences' for `csharp-mode'. When -on for `csharp-mode' font lock breaks after an interpolated string -or terminating simple string." - :around #'csharp-disable-clear-string-fences - (unless (eq major-mode 'csharp-mode) - (apply fn args)))) - - -(use-package! csharp-tree-sitter - :when (modulep! +tree-sitter) - :defer t - :init - (add-hook 'csharp-mode-local-vars-hook #'tree-sitter! 'append) - (if (fboundp #'csharp-tree-sitter-mode) - (add-to-list 'auto-mode-alist '("\\.cs\\'" . csharp-tree-sitter-mode)))) - - -;; Unity shaders -(use-package! shader-mode - :when (modulep! +unity) - :mode "\\.shader\\'" - :config - (def-project-mode! +csharp-unity-mode - :modes '(csharp-mode shader-mode) - :files (and "Assets" "Library/MonoManager.asset" "Library/ScriptMapper"))) - - -(use-package! sharper - :when (modulep! +dotnet) - :general ("C-c d" #'sharper-main-transient) - :config - (map! (:map sharper--solution-management-mode-map - :nv "RET" #'sharper-transient-solution - :nv "gr" #'sharper--solution-management-refresh) - (:map sharper--project-references-mode-map - :nv "RET" #'sharper-transient-project-references - :nv "gr" #'sharper--project-references-refresh) - (:map sharper--project-packages-mode-map - :nv "RET" #'sharper-transient-project-packages - :nv "gr" #'sharper--project-packages-refresh) - (:map sharper--nuget-results-mode-map - :nv "RET" #'sharper--nuget-search-install))) - - -(use-package! sln-mode :mode "\\.sln\\'") diff --git a/.config/emacs/modules/lang/csharp/doctor.el b/.config/emacs/modules/lang/csharp/doctor.el @@ -1,11 +0,0 @@ -;; -*- lexical-binding: t; no-byte-compile: t; -*- -;;; lang/csharp/doctor.el - -(when (and (require 'omnisharp nil t) (not (modulep! +lsp))) - (let ((omnisharp-bin (or omnisharp-server-executable-path (omnisharp--server-installation-path t)))) - (unless (file-exists-p omnisharp-bin) - (warn! "Omnisharp server isn't installed, completion won't work")))) - -(assert! (or (not (modulep! +tree-sitter)) - (modulep! :tools tree-sitter)) - "This module requires (:tools tree-sitter)") diff --git a/.config/emacs/modules/lang/csharp/packages.el b/.config/emacs/modules/lang/csharp/packages.el @@ -1,15 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/csharp/packages.el - -(package! csharp-mode - :pin "02c61c219b2c22491eff9b7315fed661fab423d4" - :built-in 'prefer) ; Built-in as of Emacs 29 - -(package! csproj-mode :pin "a7f0f4610c976a28c41b9b8299892f88b5d0336c") -(package! sln-mode :pin "0f91d1b957c7d2a7bab9278ec57b54d57f1dbd9c") -;; sln-mode depends on font-lock-ext -(package! font-lock-ext :pin "b6c82e8ac7996d96494a54454015a98ceb883feb") -(when (modulep! +unity) - (package! shader-mode :pin "fe5a1982ba69e4a98b834141a46a1908f132df15")) -(when (modulep! +dotnet) - (package! sharper :pin "496e90e337cb09329d85a6d171c0953a85e918fe")) diff --git a/.config/emacs/modules/lang/dart/README.org b/.config/emacs/modules/lang/dart/README.org @@ -1,138 +0,0 @@ -#+title: :lang dart -#+subtitle: Paint ui and not much else -#+created: February 15, 2020 -#+since: 21.12.0 (#2729) - -* Description :unfold: -[[https://dart.dev/][Dart]] is a client-optimized language by Google for fast apps on any platform. It -is fast and optimized for UI, famous for the [[https://flutter.io/][Flutter]] framework, also made by -Google. Both Flutter and Dart are free and open-source. - -This module wraps ~dart-mode~, with [[https://microsoft.github.io/language-server-protocol/][LSP]] features like code completion for -=.dart= files, syntax highlighting, debugging, closing labels, etc. - -** Maintainers -- [[doom-user:][@ericdallo]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +flutter :: - Enable ~flutter~ integration and some sane defaults for Flutter development - along with ~hover~ for desktop development. -- +lsp :: - Enable LSP support for ~dart-mode~. Requires [[doom-module::tools lsp]] and a langserver - (supports flutter). - -** Packages -- [[doom-package:dart-mode]] -- [[doom-package:flutter.el]] -- [[doom-package:hover.el]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -Make sure that the Dart SDK is on your =$PATH=, and if using Flutter, make sure -the Flutter binary is on your =$PATH= as well. - -** Installing Dart SDK -Before starting note that Flutter SDK will have a version of Dart. Therefore, -there is no need to install Dart. If you want to use Flutter just see -the next part. - -The stable version of the SDK is in most major distributions repositories. -If you find it necessary to install any other version or build from source, -please refer to the official website at: https://dart.dev/get-dart - -- *On Debian (also Ubuntu and its derivations):* - #+begin_src sh - apt-get install dart - #+end_src -- *On Arch Linux (and derivations like Manjaro):* - #+begin_src sh - pacman -S dart - #+end_src -- *On macOS*: - #+begin_src sh - brew tap dart-lang/dart - brew install dart - #+end_src -- *On NixOS*: - #+begin_src sh - nix-env -iA nixpkgs.dart - #+end_src - -** Installing Flutter SDK -Due to complications with permissions, it is suggested not to use AUR or any -automatic installation tools for Flutter SDK. - -On any system just run the following commands to install Flutter, once you have -met dependencies named on [[https://flutter.dev/docs/get-started/install/][the site]]: - -#+begin_src sh -git clone https://github.com/flutter/flutter --branch stable # to download Flutter -export PATH="$PATH:$(pwd)/flutter/bin" # to add it to PATH -flutter doctor # for Dependency check and further instructions -#+end_src - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -- Syntax highlighting and formatting for ~.dart~ files provided by LSP. -- Auto import. -- Widget guide lines for Flutter. -- Closing labels for constructors. -- Run tests interactively. -- Outline support via [[doom-package:lsp-treemacs]]. -- Emacs functions for running and debugging Flutter projects. - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** Dart & Flutter -On Linux, the installers for Dart and Flutter use the ~/opt~ directory, and this -module assumes that. However, you may set ~lsp-dart-sdk-dir~ to your Dart -install directory and ~flutter-sdk-path~ to you flutter SDK folder, to make sure -LSP can find the language server included with the Dart SDK. - -Alternatively, these variables shouldn't be necessary if you just include Dart -and Flutter on your ~PATH~ variable. - -** Android -You will also need to setup your system for Android development if you intend to -use Flutter to develop mobile applications. Refer to your distributions package -manager for details. In most distributions the ~/opt/android-sdk~ directory is -used, and you might have to change some permissions in this directory since it's -owned by root. The [[https://wiki.archlinux.org/index.php/Android][Arch Linux wiki has a great guide on this here.]] - -** Flutter mobile development on desktop -[[https://github.com/go-flutter-desktop/go-flutter][Hover]] is an application that can run Flutter mobile apps on your desktop, this -makes the mobile development a lot easier without the need to setup an Android -emulator. - -* Troubleshooting -[[doom-report:][Report an issue?]] - -See the configuration section for information on the binaries for Dart and -Flutter. On new installs to the =/opt= directory, you will likely need to edit -the permissions of the =/opt/dart-sdk= and =/opt/flutter= directories (not to -mention the Android SDK, as discussed above). - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/dart/config.el b/.config/emacs/modules/lang/dart/config.el @@ -1,69 +0,0 @@ -;;; lang/dart/config.el -*- lexical-binding: t; -*- - -(use-package! dart-mode - :hook (dart-mode . rainbow-delimiters-mode) - :config - (when (modulep! +lsp) - (add-hook 'dart-mode-local-vars-hook #'lsp! 'append)) - (set-ligatures! '(dart-mode) - ;; Functional - :def "Function" - :lambda "() =>" - ;; Types - :null "null" - :true "true" :false "false" - :int "int" :float "double" - :str "String" - :bool "bool" - :list "List" - ;; Flow - :not "!" - :in "in" - :and "&&" :or "||" - :for "for" - :return "return" - ;; Other - :yield "yield")) - - -(use-package! flutter - :when (modulep! +flutter) - :defer t - :init - (map! :after dart-mode - :map dart-mode-map - :localleader - (:prefix ("f" . "flutter") - "f" #'flutter-run - "q" #'flutter-quit - "r" #'flutter-hot-reload - "R" #'flutter-hot-restart))) - - -(use-package! lsp-dart - :when (modulep! +lsp) - :defer t - :config - (map! :map dart-mode-map - (:localleader - (:prefix ("t" . "test") - "t" #'lsp-dart-run-test-at-point - "a" #'lsp-dart-run-all-tests - "f" #'lsp-dart-run-test-file - "l" #'lsp-dart-run-last-test - "v" #'lsp-dart-visit-last-test)))) - - -(use-package! hover - :when (modulep! +flutter) - :defer t - :config - (map! :map dart-mode-map - (:localleader - (:prefix ("h" . "hover") - "c" #'hover-clear-buffer - "r" #'hover-run-or-hot-reload - "R" #'hover-run-or-hot-restart - "p" #'hover-take-screenshot - "k" #'hover-kill))) - (set-popup-rule! "\\*Hover\\*" :quit nil)) diff --git a/.config/emacs/modules/lang/dart/doctor.el b/.config/emacs/modules/lang/dart/doctor.el @@ -1,8 +0,0 @@ -;;; lang/dart/doctor.el -*- lexical-binding: t; -*- - -(assert! (or (not (modulep! +lsp)) - (modulep! :tools lsp)) - "This module requires (:tools lsp)") - -(unless (executable-find "dart") - (warn! "Dart isn't on PATH.")) diff --git a/.config/emacs/modules/lang/dart/packages.el b/.config/emacs/modules/lang/dart/packages.el @@ -1,11 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/dart/packages.el - -(package! dart-mode :pin "9c846769abd37f7fdc7ba8388d1f3a2b844b75e3") - -(when (modulep! +lsp) - (package! lsp-dart :pin "3db9f93c83052d6a8976c92d67d2b24473930760")) - -(when (modulep! +flutter) - (package! flutter :pin "edd3f5eb3f4603142f45c5890ee70b0dfb10772b") - (package! hover :pin "4ca0638a14a8b304ac2b46e7b342b8d8732ad199")) diff --git a/.config/emacs/modules/lang/data/README.org b/.config/emacs/modules/lang/data/README.org @@ -1,49 +0,0 @@ -#+title: :lang data -#+subtitle: A dumping ground for data formats -#+created: February 20, 2017 -#+since: 2.0.0 - -* Description :unfold: -This module adds Emacs support for CSV and XML files. - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:csv-mode]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* TODO Usage -#+begin_quote -🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote -🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote -🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/data/config.el b/.config/emacs/modules/lang/data/config.el @@ -1,23 +0,0 @@ -;;; lang/data/config.el -*- lexical-binding: t; -*- - -(use-package! nxml-mode - :mode "\\.p\\(?:list\\|om\\)\\'" ; plist, pom - :mode "\\.xs\\(?:d\\|lt\\)\\'" ; xslt, xsd - :mode "\\.rss\\'" - :config - (setq nxml-slash-auto-complete-flag t - nxml-auto-insert-xml-declaration-flag t) - (set-company-backend! 'nxml-mode '(company-nxml company-yasnippet)) - (setq-hook! 'nxml-mode-hook tab-width nxml-child-indent)) - - -;;;###package csv-mode -(map! :after csv-mode - :localleader - :map csv-mode-map - "a" #'csv-align-fields - "u" #'csv-unalign-fields - "s" #'csv-sort-fields - "S" #'csv-sort-numeric-fields - "k" #'csv-kill-fields - "t" #'csv-transpose) diff --git a/.config/emacs/modules/lang/data/packages.el b/.config/emacs/modules/lang/data/packages.el @@ -1,4 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/data/packages.el - -(package! csv-mode :pin "d190a479b4f36806b604da527e5d5a50909d3ceb") diff --git a/.config/emacs/modules/lang/dhall/README.org b/.config/emacs/modules/lang/dhall/README.org @@ -1,53 +0,0 @@ -#+title: :lang dhall -#+subtitle: Config as code -#+created: August 03, 2021 -#+since: 21.12.0 (#4791) - -* Description :unfold: -This module adds [[https://dhall-lang.org/][Dhall]] language support to Emacs. - -Dhall is a programmable configuration language that you can think of as: JSON + -functions + types + imports. - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:dhall-mode]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires the =dhall-json= package, which provides both the -=dhall-to-json=, =dhall-to-yaml=, and =dhall-format= executables. - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/dhall/config.el b/.config/emacs/modules/lang/dhall/config.el @@ -1,12 +0,0 @@ -;;; lang/dhall/config.el -*- lexical-binding: t; -*- - -(use-package! dhall-mode - :defer t - :config - (set-repl-handler! 'dhall-mode #'dhall-repl-show) - (setq dhall-format-at-save (modulep! :editor format +onsave)) - (map! :map dhall-mode-map - :localleader - "l" #'dhall-lint - "f" #'dhall-freeze - "t" #'dhall-buffer-type-show)) diff --git a/.config/emacs/modules/lang/dhall/packages.el b/.config/emacs/modules/lang/dhall/packages.el @@ -1,4 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/dhall/packages.el - -(package! dhall-mode :pin "c77f1c1e75b6d2725019c5275fc102ae98d25628") diff --git a/.config/emacs/modules/lang/elixir/README.org b/.config/emacs/modules/lang/elixir/README.org @@ -1,103 +0,0 @@ -#+title: :lang elixir -#+subtitle: Erlang done right -#+created: May 24, 2017 -#+since: 2.0.3 (#83) - -* Description :unfold: -This module provides support for [[https://elixir-lang.org/][Elixir programming language]] via [[https://github.com/elixir-lsp/elixir-ls/][elixir-ls]]. - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +lsp :: - Enable LSP support for ~elixir-mode~. Requires [[doom-module::tools lsp]] and a langserver - (supports [[https://github.com/elixir-lsp/elixir-ls/][elixir-ls]]). -- +tree-sitter :: - Leverages tree-sitter for better syntax highlighting and structural text - editing. Requires [[doom-module::tools tree-sitter]]. - -** Packages -- [[doom-package:elixir-mode]] -- [[doom-package:exunit]] -- [[doom-package:flycheck-credo]] if [[doom-module::checkers syntax]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires Elixir. Install it via your distribution's package manager -or a version management tool such as [[https://github.com/asdf-vm/asdf-elixir][asdf]]. - -To add LSP support, install [[https://github.com/JakeBecker/elixir-ls/][elixir-ls]] and enable [[doom-module::tools lsp]]. - -To support linting with [[https://github.com/rrrene/credo][credo]], add ~:checkers syntax~ to ~$DOOMDIR/init.el~. - -** Install Elixir -(See [[https://elixir-lang.org/install.html]] for other operating systems) - -*** With ~asdf~ -#+begin_src sh -asdf plugin-add elixir -asdf install elixir 1.9.1 -#+end_src - -*** Arch Linux -#+begin_src sh -pacman -S elixir -#+end_src - -*** Gentoo Linux -#+begin_src sh -emerge -v dev-lang/elixir -#+end_src - -*** openSUSE -#+begin_src sh -zypper install elixir -#+end_src - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -- Code completion ([[doom-module::completion company]]) -- Documentation lookup ([[doom-module::tools lookup]]) -- Mix integration -- Phoenix support -- ~iex~ integration ([[doom-module::tools eval]]) -- Syntax checking ([[doom-module::checkers syntax]], using [[doom-package:flycheck-credo]]) - -** exunit-mode -The exunit-mode prefix is [[kbd:][<localleader> t]]. Here is some examples: -| command | key / ex command | description | -|--------------------------------------------+-------------------+--------------------------------------------------------| -| ~exunit-verify-all~ | [[kbd:][<localleader> t a]] | Runs exunit on all files | -| ~exunit-rerun~ | [[kbd:][<localleader> t r]] | Re-runs last exunit command | -| ~exunit-verify~ | [[kbd:][<localleader> t v]] | Runs exunit on current file | -| ~exunit-verify-single~ | [[kbd:][<localleader> t s]] | Runs exunit for the item on cursor | -| ~exunit-toggle-file-and-test~ | [[kbd:][<localleader> t t]] | Switch between implementation and test | -| ~exunit-toggle-file-and-test-other-window~ | [[kbd:][<localleader> t T]] | Switch between implementation and test in other window | - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/elixir/config.el b/.config/emacs/modules/lang/elixir/config.el @@ -1,71 +0,0 @@ -;;; lang/elixir/config.el -*- lexical-binding: t; -*- - -(after! projectile - (add-to-list 'projectile-project-root-files "mix.exs")) - - -;; -;;; Packages - -(use-package! elixir-mode - :defer t - :init - ;; Disable default smartparens config. There are too many pairs; we only want - ;; a subset of them (defined below). - (provide 'smartparens-elixir) - :config - (set-ligatures! 'elixir-mode - ;; Functional - :def "def" - :lambda "fn" - ;; :src_block "do" - ;; :src_block_end "end" - ;; Flow - :not "!" - :in "in" :not-in "not in" - :and "and" :or "or" - :for "for" - :return "return" :yield "use") - - ;; ...and only complete the basics - (sp-with-modes 'elixir-mode - (sp-local-pair "do" "end" - :when '(("RET" "<evil-ret>")) - :unless '(sp-in-comment-p sp-in-string-p) - :post-handlers '("||\n[i]")) - (sp-local-pair "do " " end" :unless '(sp-in-comment-p sp-in-string-p)) - (sp-local-pair "fn " " end" :unless '(sp-in-comment-p sp-in-string-p))) - - (when (modulep! +lsp) - (add-hook 'elixir-mode-local-vars-hook #'lsp! 'append) - (after! lsp-mode - (add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]_build\\'"))) - - (when (modulep! +tree-sitter) - (add-hook 'elixir-mode-local-vars-hook #'tree-sitter! 'append)) - - (after! highlight-numbers - (puthash 'elixir-mode - "\\_<-?[[:digit:]]+\\(?:_[[:digit:]]\\{3\\}\\)*\\_>" - highlight-numbers-modelist))) - - -(use-package! flycheck-credo - :when (modulep! :checkers syntax) - :after elixir-mode - :config (flycheck-credo-setup)) - - -(use-package! exunit - :hook (elixir-mode . exunit-mode) - :init - (map! :after elixir-mode - :localleader - :map elixir-mode-map - :prefix ("t" . "test") - "a" #'exunit-verify-all - "r" #'exunit-rerun - "v" #'exunit-verify - "T" #'exunit-toggle-file-and-test - "t" #'exunit-toggle-file-and-test-other-window - "s" #'exunit-verify-single)) diff --git a/.config/emacs/modules/lang/elixir/doctor.el b/.config/emacs/modules/lang/elixir/doctor.el @@ -1,6 +0,0 @@ -;; -*- lexical-binding: t; no-byte-compile: t; -*- -;;; lang/elixir/doctor.el - -(assert! (or (not (modulep! +tree-sitter)) - (modulep! :tools tree-sitter)) - "This module requires (:tools tree-sitter)") diff --git a/.config/emacs/modules/lang/elixir/packages.el b/.config/emacs/modules/lang/elixir/packages.el @@ -1,8 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/elixir/packages.el - -;; +elixir.el -(package! elixir-mode :pin "7641373f0563cab67cc5459c34534a8176b5e676") -(package! exunit :pin "e0a8c2b81f3d53885ed753b911b3cb6ee9229bec") -(when (modulep! :checkers syntax) - (package! flycheck-credo :pin "e88f11ead53805c361ec7706e44c3dfee1daa19f")) diff --git a/.config/emacs/modules/lang/elm/README.org b/.config/emacs/modules/lang/elm/README.org @@ -1,60 +0,0 @@ -#+title: :lang elm -#+subtitle: Care for a cup of TEA? -#+created: May 21, 2017 -#+since: 2.0.3 (#74) - -* Description :unfold: -This module adds [[https://elm-lang.org/][Elm]] support to Doom Emacs. - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +lsp :: - Enable LSP support for ~elm-mode~. Requires [[doom-module::tools lsp]] and a langserver - (supports [[https://github.com/elm-tooling/elm-language-server][elm-language-server]]). -- +tree-sitter :: - Leverages tree-sitter for better syntax highlighting and structural text - editing. Requires [[doom-module::tools tree-sitter]]. - -** Packages -- [[doom-package:elm-mode]] -- [[doom-package:flycheck-elm]] if [[doom-module::checkers syntax]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* TODO Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -#+begin_quote - 🔨 /This module's prerequisites are not all documented./ [[doom-contrib-module:][Document them?]] -#+end_quote - -- If [[doom-module:+lsp]] is enabled, [[https://github.com/elm-tooling/elm-language-server][elm-language-server]] is required to be installed and in - your =$PATH=. - -* TODO Usage -#+begin_quote -🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote -🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote -🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/elm/autoload.el b/.config/emacs/modules/lang/elm/autoload.el @@ -1,29 +0,0 @@ -;;; lang/elm/autoloads.el -*- lexical-binding: t; -*- - -;;;###autoload -(defun +elm/compile-html () - "Compile the current Elm project." - (interactive) - (let ((default-directory (doom-project-root))) - (compile (format "elm make %s" buffer-file-name)))) - -;;;###autoload -(defun +elm/compile-html-optimized () - "Compile the current Elm project with optimizations." - (interactive) - (let ((default-directory (doom-project-root))) - (compile (format "elm make %s --optimize" buffer-file-name)))) - -;;;###autoload -(defun +elm/compile-js () - "Compile the current Elm project to Javascript." - (interactive) - (let ((default-directory (doom-project-root))) - (compile (format "elm make %s --output=main.js" buffer-file-name)))) - -;;;###autoload -(defun +elm/compile-js-optimized () - "Compile the current Elm project to Javascript with optimizations." - (interactive) - (let ((default-directory (doom-project-root))) - (compile (format "elm make %s --output=main.js --optimize" buffer-file-name)))) diff --git a/.config/emacs/modules/lang/elm/config.el b/.config/emacs/modules/lang/elm/config.el @@ -1,32 +0,0 @@ -;;; lang/elm/config.el -*- lexical-binding: t; -*- - -(after! elm-mode - (if (modulep! +lsp) - (add-hook 'elm-mode-local-vars-hook #'lsp! 'append) - (set-company-backend! 'elm-mode 'company-elm)) - - (when (modulep! +tree-sitter) - (add-hook 'elm-mode-local-vars-hook #'tree-sitter! 'append)) - - (set-repl-handler! 'elm-mode #'run-elm-interactive) - (set-ligatures! 'elm-mode - :null "null" - :true "true" :false "false" - :int "Int" :str "String" - :float "Float" - :bool "Bool" - :not "not" - :and "&&" :or "||") - - (map! :map elm-mode-map - :localleader - (:prefix ("m" . "elm make") - :desc "Compile HTML" "m" #'+elm/compile-html - :desc "Compile HTML (optimized)" "M" #'+elm/compile-html-optimized - :desc "Compile JS" "j" #'+elm/compile-js - :desc "Compile JS (optimized)" "J" #'+elm/compile-js-optimized))) - -(use-package! flycheck-elm - :when (modulep! :checkers syntax) - :after elm-mode - :config (add-to-list 'flycheck-checkers 'elm)) diff --git a/.config/emacs/modules/lang/elm/doctor.el b/.config/emacs/modules/lang/elm/doctor.el @@ -1,5 +0,0 @@ -;;; lang/elm/doctor.el -*- lexical-binding: t; -*- - -(assert! (or (not (modulep! +tree-sitter)) - (modulep! :tools tree-sitter)) - "This module requires (:tools tree-sitter)") diff --git a/.config/emacs/modules/lang/elm/packages.el b/.config/emacs/modules/lang/elm/packages.el @@ -1,6 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/elm/packages.el - -(package! elm-mode :pin "5797500d74dd8544a89938c09d3cd5cdf7b5d7bc") -(when (modulep! :checkers syntax) - (package! flycheck-elm :pin "1b60050efd4729bfba548f3e5adbcb58436667cb")) diff --git a/.config/emacs/modules/lang/emacs-lisp/README.org b/.config/emacs/modules/lang/emacs-lisp/README.org @@ -1,73 +0,0 @@ -#+title: :lang emacs-lisp -#+subtitle: A parsel-tongue for the oldest serpent -#+created: January 16, 2017 -#+since: 1.3 - -* Description :unfold: -This module extends support for Emacs Lisp in Doom Emacs. - -- Macro expansion -- Go-to-definitions or references functionality -- Syntax highlighting for defined and quoted symbols -- Replaces the built-in help with the more powerful [[doom-package:helpful]] -- Adds function example uses to documentation - -** Maintainers -- [[doom-user:][@hlissner]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:buttercup]] -- [[doom-package:elisp-def]] -- [[doom-package:elisp-demos]] -- [[doom-package:flycheck-cask]] if [[doom-module::checkers syntax]] -- [[doom-package:flycheck-package]] if [[doom-module::checkers syntax]] -- [[doom-package:highlight-quoted]] -- [[doom-package:macrostep]] -- [[doom-package:overseer]] - -** Hacks -- Symbols that are defined in the current session are highlighted with - ~font-lock-variable-face~. -- Eldoc will display the values of variables next to its documentation. -- ~elisp-demos~ was modified to display API demos for Doom's standard library - (in [[file:../../../docs/api.org][docs/api.org]]). -- This module extends imenu support for Doom's API (e.g. ~package!~, - ~use-package~, ~after!~) -- Flycheck has been configured to tone down the false positives when you are - editing your Emacs or Doom config. - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module's sole dependency is Emacs. It's very obscure, you wouldn't know -about it. - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/emacs-lisp/autoload.el b/.config/emacs/modules/lang/emacs-lisp/autoload.el @@ -1,620 +0,0 @@ -;;; lang/emacs-lisp/autoload.el -*- lexical-binding: t; -*- - -;; -;;; Library - -;;;###autoload -(defun +emacs-lisp-eval (beg end) - "Evaluate a region and print it to the echo area (if one line long), otherwise -to a pop up buffer." - (+eval-display-results - (string-trim-right - (let ((buffer (generate-new-buffer " *+eval-output*")) - (debug-on-error t)) - (unwind-protect - (condition-case-unless-debug e - (doom-module-context-with - (doom-module-from-path - (or (buffer-file-name (buffer-base-buffer)) - default-directory)) - (doom-context-with 'eval - (eval-region beg end buffer load-read-function)) - (with-current-buffer buffer - (let ((pp-max-width nil)) - (require 'pp) - (pp-buffer) - (replace-regexp-in-string "\\\\n" "\n" (string-trim-left (buffer-string)))))) - (error (format "ERROR: %s" e))) - (kill-buffer buffer)))) - (current-buffer))) - -;;;###autoload -(defun +emacs-lisp-outline-level () - "Return outline level for comment at point. -Intended to replace `lisp-outline-level'." - (- (match-end 1) (match-beginning 1))) - - -;; -;;; Handlers - -(defun +emacs-lisp--module-at-point () - "Return (CATEGORY MODULE FLAG) at point inside a `doom!' block." - (let ((origin (point)) - (syntax (syntax-ppss))) - (when (and (> (ppss-depth syntax) 0) (not (ppss-string-terminator syntax))) - (save-excursion - (let ((parens (ppss-open-parens syntax)) - (doom-depth 1)) - (while (and parens (progn (goto-char (car parens)) - (not (looking-at "(doom!\\_>")))) - (setq parens (cdr parens) - doom-depth (1+ doom-depth))) - (when parens ;; Are we inside a `doom!' block? - (goto-char origin) - (let* ((doom-start (car parens)) - (bare-symbol - (if (ppss-comment-depth syntax) - (= (save-excursion (beginning-of-thing 'list)) doom-start) - (null (cdr parens)))) - (sexp-start (if bare-symbol - (beginning-of-thing 'symbol) - (or (cadr parens) (beginning-of-thing 'list)))) - (match-start nil)) - (goto-char sexp-start) - (while (and (not match-start) - (re-search-backward - "\\_<:\\(?:\\sw\\|\\s_\\)+\\_>" ;; Find a keyword. - doom-start 'noerror)) - (unless (looking-back "(") - (let ((kw-syntax (syntax-ppss))) - (when (and (= (ppss-depth kw-syntax) doom-depth) - (not (ppss-string-terminator kw-syntax)) - (not (ppss-comment-depth kw-syntax))) - (setq match-start (point)))))) - (when match-start - (let (category module flag) - ;; `point' is already at `match-start'. - (setq category (symbol-at-point)) - (goto-char origin) - (if bare-symbol - (setq module (symbol-at-point)) - (let ((symbol (symbol-at-point)) - (head (car (list-at-point)))) - (if (and (symbolp head) (not (keywordp head)) - (not (eq head symbol))) - (setq module head - flag symbol) - (setq module symbol)))) - (list category module flag)))))))))) - -;;;###autoload -(defun +emacs-lisp-lookup-definition (_thing) - "Lookup definition of THING." - (if-let (module (+emacs-lisp--module-at-point)) - (doom/help-modules (car module) (cadr module) 'visit-dir) - (call-interactively #'elisp-def))) - -;;;###autoload -(defun +emacs-lisp-lookup-documentation (thing) - "Lookup THING with `helpful-variable' if it's a variable, `helpful-callable' -if it's callable, `apropos' otherwise." - (cond ((when-let (module (+emacs-lisp--module-at-point)) - (doom/help-modules (car module) (cadr module)) - (when (eq major-mode 'org-mode) - (with-demoted-errors "%s" - (re-search-forward - (if (caddr module) - "\\* Module flags$" - "\\* Description$")) - (when (caddr module) - (re-search-forward (format "=\\%s=" (caddr module)) - nil t)) - (when (invisible-p (point)) - (org-show-hidden-entry)))) - 'deferred)) - (thing (helpful-symbol (intern thing))) - ((call-interactively #'helpful-at-point)))) - -;; DEPRECATED Remove when 28 support is dropped. -(unless (fboundp 'lisp--local-defform-body-p) - (fset 'lisp--local-defform-body-p #'ignore)) - -;;;###autoload -(defun +emacs-lisp-indent-function (indent-point state) - "A replacement for `lisp-indent-function'. - -Indents plists more sensibly. Adapted from -https://emacs.stackexchange.com/questions/10230/how-to-indent-keywords-aligned" - (let ((normal-indent (current-column)) - (orig-point (point)) - ;; TODO Refactor `target' usage (ew!) - target) - (goto-char (1+ (elt state 1))) - (parse-partial-sexp (point) calculate-lisp-indent-last-sexp 0 t) - (cond ((and (elt state 2) - (or (eq (char-after) ?:) - (not (looking-at-p "\\sw\\|\\s_")))) - (if (lisp--local-defform-body-p state) - (lisp-indent-defform state indent-point) - (unless (> (save-excursion (forward-line 1) (point)) - calculate-lisp-indent-last-sexp) - (goto-char calculate-lisp-indent-last-sexp) - (beginning-of-line) - (parse-partial-sexp (point) calculate-lisp-indent-last-sexp 0 t)) - (backward-prefix-chars) - (current-column))) - ((and (save-excursion - (goto-char indent-point) - (skip-syntax-forward " ") - (not (eq (char-after) ?:))) - (save-excursion - (goto-char orig-point) - (and (eq (char-after) ?:) - (eq (char-before) ?\() - (setq target (current-column))))) - (save-excursion - (move-to-column target t) - target)) - ((let* ((function (buffer-substring (point) (progn (forward-sexp 1) (point)))) - (method (or (function-get (intern-soft function) 'lisp-indent-function) - (get (intern-soft function) 'lisp-indent-hook)))) - (cond ((or (eq method 'defun) - (and (null method) - (> (length function) 3) - (string-match-p "\\`def" function))) - (lisp-indent-defform state indent-point)) - ((integerp method) - (lisp-indent-specform method state indent-point normal-indent)) - (method - (funcall method indent-point state)))))))) - - -;; -;;; Commands - -;;;###autoload -(defun +emacs-lisp/open-repl () - "Open the Emacs Lisp REPL (`ielm')." - (interactive) - (pop-to-buffer - (or (get-buffer "*ielm*") - (progn (ielm) - (let ((buf (get-buffer "*ielm*"))) - (bury-buffer buf) - buf))))) - -;;;###autoload -(defun +emacs-lisp/buttercup-run-file () - "Run all buttercup tests in the focused buffer." - (interactive) - (let ((load-path - (append (list (doom-path (dir!) "..") - (or (doom-project-root) - default-directory)) - load-path)) - (buttercup-suites nil)) - (save-selected-window - (eval-buffer) - (buttercup-run)) - (message "File executed successfully"))) - -;;;###autoload -(defun +emacs-lisp/buttercup-run-project () - "Run all buttercup tests in the project." - (interactive) - (let* ((default-directory (doom-project-root)) - (load-path (append (list (doom-path "test") - default-directory) - load-path)) - (buttercup-suites nil)) - (buttercup-run-discover))) - -;;;###autoload -(defun +emacs-lisp/edebug-instrument-defun-on () - "Toggle on instrumentalisation for the function under `defun'." - (interactive) - (eval-defun 'edebugit)) - -;;;###autoload -(defun +emacs-lisp/edebug-instrument-defun-off () - "Toggle off instrumentalisation for the function under `defun'." - (interactive) - (eval-defun nil)) - - -;; -;;; Hooks - -(autoload 'straight-register-file-modification "straight") -;;;###autoload -(defun +emacs-lisp-init-straight-maybe-h () - "Make sure straight sees modifications to installed packages." - (when (file-in-directory-p (or buffer-file-name default-directory) doom-local-dir) - (add-hook 'after-save-hook #'straight-register-file-modification - nil 'local))) - -;;;###autoload -(defun +emacs-lisp-extend-imenu-h () - "Improve imenu support in `emacs-lisp-mode' for Doom's APIs." - (setq imenu-generic-expression - `(("Section" "^[ \t]*;;;*\\**[ \t]+\\([^\n]+\\)" 1) - ("Evil commands" "^\\s-*(evil-define-\\(?:command\\|operator\\|motion\\) +\\(\\_<[^ ()\n]+\\_>\\)" 1) - ("Unit tests" "^\\s-*(\\(?:ert-deftest\\|describe\\) +\"\\([^\")]+\\)\"" 1) - ("Package" "^\\s-*\\(?:;;;###package\\|(\\(?:package!\\|use-package!?\\|after!\\)\\) +\\(\\_<[^ ()\n]+\\_>\\)" 1) - ("Major modes" "^\\s-*(define-derived-mode +\\([^ ()\n]+\\)" 1) - ("Minor modes" "^\\s-*(define-\\(?:global\\(?:ized\\)?-minor\\|generic\\|minor\\)-mode +\\([^ ()\n]+\\)" 1) - ("Modelines" "^\\s-*(def-modeline! +\\([^ ()\n]+\\)" 1) - ("Modeline segments" "^\\s-*(def-modeline-segment! +\\([^ ()\n]+\\)" 1) - ("Advice" "^\\s-*(\\(?:def\\(?:\\(?:ine-\\)?advice!?\\)\\) +\\([^ )\n]+\\)" 1) - ("Macros" "^\\s-*(\\(?:cl-\\)?def\\(?:ine-compile-macro\\|macro\\) +\\([^ )\n]+\\)" 1) - ("Inline functions" "\\s-*(\\(?:cl-\\)?defsubst +\\([^ )\n]+\\)" 1) - ("CLI Command" "^\\s-*(\\(def\\(?:cli\\|alias\\|obsolete\\|autoload\\)! +\\([^\n]+\\)\\)" 1) - ("Functions" "^\\s-*(\\(?:cl-\\)?def\\(?:un\\|un\\*\\|method\\|generic\\|-memoized!\\) +\\([^ ,)\n]+\\)" 1) - ("Variables" "^\\s-*(\\(def\\(?:c\\(?:onst\\(?:ant\\)?\\|ustom\\)\\|ine-symbol-macro\\|parameter\\|var\\(?:-local\\)?\\)\\)\\s-+\\(\\(?:\\sw\\|\\s_\\|\\\\.\\)+\\)" 2) - ("Types" "^\\s-*(\\(cl-def\\(?:struct\\|type\\)\\|def\\(?:class\\|face\\|group\\|ine-\\(?:condition\\|error\\|widget\\)\\|package\\|struct\\|t\\(?:\\(?:hem\\|yp\\)e\\)\\)\\)\\s-+'?\\(\\(?:\\sw\\|\\s_\\|\\\\.\\)+\\)" 2)))) - -(defun +emacs-lisp--in-package-buffer-p () - (let* ((file-path (buffer-file-name (buffer-base-buffer))) - (file-base (if file-path (file-name-base file-path)))) - (and (derived-mode-p 'emacs-lisp-mode) - (or (null file-base) - (locate-file file-base (custom-theme--load-path) '(".elc" ".el")) - (save-excursion - (save-restriction - (widen) - (goto-char (point-max)) - (when (re-search-backward "^ *\\((provide\\)\\(?:-theme\\)? +'" - (max (point-min) (- (point-max) 512)) - t) - (goto-char (match-beginning 1)) - (ignore-errors - (and (stringp file-base) - (equal (symbol-name (doom-unquote (nth 1 (read (current-buffer))))) - file-base))))))) - (not (locate-dominating-file default-directory ".doommodule"))))) - -;;;###autoload -(define-minor-mode +emacs-lisp-non-package-mode - "Reduce flycheck verbosity where it is appropriate. - -Essentially, this means in any elisp file that either: -- Is not a theme in `custom-theme-load-path', -- Lacks a `provide' statement, -- Lives in a project with a .doommodule file, -- Is a dotfile (like .dir-locals.el or .doomrc). - -This generally applies to your private config (`doom-user-dir') or Doom's source -\(`doom-emacs-dir')." - :since "3.0.0" - (unless (and (bound-and-true-p flycheck-mode) - (not (+emacs-lisp--in-package-buffer-p))) - (setq +emacs-lisp-non-package-mode nil)) - (when (derived-mode-p 'emacs-lisp-mode) - (add-hook 'after-save-hook #'+emacs-lisp-non-package-mode nil t)) - (if (not +emacs-lisp-non-package-mode) - (when (get 'flycheck-disabled-checkers 'initial-value) - (setq-local flycheck-disabled-checkers (get 'flycheck-disabled-checkers 'initial-value)) - (kill-local-variable 'flycheck-emacs-lisp-check-form)) - (with-memoization (get 'flycheck-disabled-checkers 'initial-value) - flycheck-disabled-checkers) - (setq-local flycheck-emacs-lisp-check-form - (prin1-to-string - `(progn - (setq doom-modules ',doom-modules - doom-disabled-packages ',doom-disabled-packages - byte-compile-warnings ',+emacs-lisp-linter-warnings) - (condition-case e - (progn - (require 'doom) - (require 'doom-cli) - (require 'doom-start)) - (error - (princ - (format "%s:%d:%d:Error:Failed to load Doom: %s\n" - (or ,(ignore-errors - (file-name-nondirectory - (buffer-file-name (buffer-base-buffer)))) - (car command-line-args-left)) - 0 0 (error-message-string e))))) - ,(read (default-toplevel-value 'flycheck-emacs-lisp-check-form)))) - flycheck-disabled-checkers (cons 'emacs-lisp-checkdoc - flycheck-disabled-checkers)))) - - -;; -;;; Fontification - -;;;###autoload -(defun +emacs-lisp-truncate-pin () - "Truncates long SHA1 hashes in `package!' :pin's." - (save-excursion - (goto-char (match-beginning 0)) - (and (stringp (plist-get (sexp-at-point) :pin)) - (search-forward ":pin" nil t) - (let ((start (re-search-forward "\"[^\"\n]\\{12\\}" nil t)) - (finish (and (re-search-forward "\"" (line-end-position) t) - (match-beginning 0)))) - (when (and start finish) - (put-text-property start finish 'display "..."))))) - nil) - -(defvar +emacs-lisp--face nil) -;;;###autoload -(defun +emacs-lisp-highlight-vars-and-faces (end) - "Match defined variables and functions. - -Functions are differentiated into special forms, built-in functions and -library/userland functions" - (catch 'matcher - (while (re-search-forward "\\(?:\\sw\\|\\s_\\)+" end t) - (let ((ppss (save-excursion (syntax-ppss)))) - (cond ((nth 3 ppss) ; strings - (search-forward "\"" end t)) - ((nth 4 ppss) ; comments - (forward-line +1)) - ((let ((symbol (intern-soft (match-string-no-properties 0)))) - (and (cond ((null symbol) nil) - ((eq symbol t) nil) - ((keywordp symbol) nil) - ((special-variable-p symbol) - (setq +emacs-lisp--face 'font-lock-variable-name-face)) - ((and (fboundp symbol) - (eq (char-before (match-beginning 0)) ?\() - (not (memq (char-before (1- (match-beginning 0))) - (list ?\' ?\`)))) - (let ((unaliased (indirect-function symbol))) - (unless (or (macrop unaliased) - (special-form-p unaliased)) - (let (unadvised) - (while (not (eq (setq unadvised (ad-get-orig-definition unaliased)) - (setq unaliased (indirect-function unadvised))))) - unaliased) - (setq +emacs-lisp--face - (if (subrp unaliased) - 'font-lock-constant-face - 'font-lock-function-name-face)))))) - (throw 'matcher t))))))) - nil)) - - -;; -;;; Advice - -;;;###autoload -(defun +emacs-lisp--add-doom-elisp-demos-a (fn symbol) - "Add Doom's own demos to `elisp-demos'. - -Intended as :around advice for `elisp-demos--search'." - (let ((org-inhibit-startup t) - enable-dir-local-variables - org-mode-hook) - (or (funcall fn symbol) - (with-file-contents! (doom-path doom-docs-dir "examples.org") - (save-excursion - (when (re-search-backward - (format "^\\*+[ \t]+\\(?:TODO \\)?%s$" - (regexp-quote (symbol-name symbol))) - nil t) - (forward-line 1) - (let ((demos - (string-trim - (buffer-substring-no-properties - (point) (if (re-search-forward "^\\*+ " nil t) - (line-beginning-position) - (point-max)))))) - (unless (string-blank-p demos) - demos)))))))) - -;;;###autoload (put 'map! 'indent-plists-as-data t) -;;;###autoload -(defun +emacs-lisp--calculate-lisp-indent-a (&optional parse-start) - "Add better indentation for quoted and backquoted lists. - -Intended as :override advice for `calculate-lisp-indent'. - -Adapted from URL `https://www.reddit.com/r/emacs/comments/d7x7x8/finally_fixing_indentation_of_quoted_lists/'." - ;; This line because `calculate-lisp-indent-last-sexp` was defined with - ;; `defvar` with it's value ommited, marking it special and only defining it - ;; locally. So if you don't have this, you'll get a void variable error. - (defvar calculate-lisp-indent-last-sexp) - (save-excursion - (beginning-of-line) - (let ((indent-point (point)) - state - ;; setting this to a number inhibits calling hook - (desired-indent nil) - (retry t) - calculate-lisp-indent-last-sexp containing-sexp) - (cond ((or (markerp parse-start) (integerp parse-start)) - (goto-char parse-start)) - ((null parse-start) - (beginning-of-defun)) - ((setq state parse-start))) - (unless state - ;; Find outermost containing sexp - (while (< (point) indent-point) - (setq state (parse-partial-sexp (point) indent-point 0)))) - ;; Find innermost containing sexp - (while (and retry - state - (> (elt state 0) 0)) - (setq retry nil) - (setq calculate-lisp-indent-last-sexp (elt state 2)) - (setq containing-sexp (elt state 1)) - ;; Position following last unclosed open. - (goto-char (1+ containing-sexp)) - ;; Is there a complete sexp since then? - (if (and calculate-lisp-indent-last-sexp - (> calculate-lisp-indent-last-sexp (point))) - ;; Yes, but is there a containing sexp after that? - (let ((peek (parse-partial-sexp calculate-lisp-indent-last-sexp - indent-point 0))) - (if (setq retry (car (cdr peek))) (setq state peek))))) - (if retry - nil - ;; Innermost containing sexp found - (goto-char (1+ containing-sexp)) - (if (not calculate-lisp-indent-last-sexp) - ;; indent-point immediately follows open paren. Don't call hook. - (setq desired-indent (current-column)) - ;; Find the start of first element of containing sexp. - (parse-partial-sexp (point) calculate-lisp-indent-last-sexp 0 t) - (cond ((looking-at "\\s(") - ;; First element of containing sexp is a list. Indent under - ;; that list. - ) - ((> (save-excursion (forward-line 1) (point)) - calculate-lisp-indent-last-sexp) - ;; This is the first line to start within the containing sexp. - ;; It's almost certainly a function call. - (if (or - ;; Containing sexp has nothing before this line except the - ;; first element. Indent under that element. - (= (point) calculate-lisp-indent-last-sexp) - - (or - ;; Align keywords in plists if each newline begins with - ;; a keyword. This is useful for "unquoted plist - ;; function" macros, like `map!' and `defhydra'. - (when-let ((first (elt state 1)) - (char (char-after (1+ first)))) - (and (eq char ?:) - (ignore-errors - (or (save-excursion - (goto-char first) - ;; FIXME Can we avoid `syntax-ppss'? - (when-let* ((parse-sexp-ignore-comments t) - (end (scan-lists (point) 1 0)) - (depth (ppss-depth (syntax-ppss)))) - (and (re-search-forward "^\\s-*:" end t) - (= (ppss-depth (syntax-ppss)) - (1+ depth))))) - (save-excursion - (cl-loop for pos in (reverse (elt state 9)) - unless (memq (char-after (1+ pos)) '(?: ?\()) - do (goto-char (1+ pos)) - for fn = (read (current-buffer)) - if (symbolp fn) - return (function-get fn 'indent-plists-as-data))))))) - - ;; Check for quotes or backquotes around. - (let ((positions (elt state 9)) - (quotep 0)) - (while positions - (let ((point (pop positions))) - (or (when-let (char (char-before point)) - (cond - ((eq char ?\()) - ((memq char '(?\' ?\`)) - (or (save-excursion - (goto-char (1+ point)) - (skip-chars-forward "( ") - (when-let (fn (ignore-errors (read (current-buffer)))) - (if (and (symbolp fn) - (fboundp fn) - ;; Only special forms and - ;; macros have special - ;; indent needs. - (not (functionp fn))) - (setq quotep 0)))) - (cl-incf quotep))) - ((memq char '(?, ?@)) - (setq quotep 0)))) - ;; If the spelled out `quote' or `backquote' - ;; are used, let's assume - (save-excursion - (goto-char (1+ point)) - (and (looking-at-p "\\(\\(?:back\\)?quote\\)[\t\n\f\s]+(") - (cl-incf quotep 2))) - (setq quotep (max 0 (1- quotep)))))) - (> quotep 0)))) - ;; Containing sexp has nothing before this line except the - ;; first element. Indent under that element. - nil - ;; Skip the first element, find start of second (the first - ;; argument of the function call) and indent under. - (progn (forward-sexp 1) - (parse-partial-sexp (point) - calculate-lisp-indent-last-sexp - 0 t))) - (backward-prefix-chars)) - (t - ;; Indent beneath first sexp on same line as - ;; `calculate-lisp-indent-last-sexp'. Again, it's almost - ;; certainly a function call. - (goto-char calculate-lisp-indent-last-sexp) - (beginning-of-line) - (parse-partial-sexp (point) calculate-lisp-indent-last-sexp - 0 t) - (backward-prefix-chars))))) - ;; Point is at the point to indent under unless we are inside a string. - ;; Call indentation hook except when overridden by lisp-indent-offset or - ;; if the desired indentation has already been computed. - (let ((normal-indent (current-column))) - (cond ((elt state 3) - ;; Inside a string, don't change indentation. - nil) - ((and (integerp lisp-indent-offset) containing-sexp) - ;; Indent by constant offset - (goto-char containing-sexp) - (+ (current-column) lisp-indent-offset)) - ;; in this case calculate-lisp-indent-last-sexp is not nil - (calculate-lisp-indent-last-sexp - (or - ;; try to align the parameters of a known function - (and lisp-indent-function - (not retry) - (funcall lisp-indent-function indent-point state)) - ;; If the function has no special alignment or it does not apply - ;; to this argument, try to align a constant-symbol under the - ;; last preceding constant symbol, if there is such one of the - ;; last 2 preceding symbols, in the previous uncommented line. - (and (save-excursion - (goto-char indent-point) - (skip-chars-forward " \t") - (looking-at ":")) - ;; The last sexp may not be at the indentation where it - ;; begins, so find that one, instead. - (save-excursion - (goto-char calculate-lisp-indent-last-sexp) - ;; Handle prefix characters and whitespace following an - ;; open paren. (Bug#1012) - (backward-prefix-chars) - (while (not (or (looking-back "^[ \t]*\\|([ \t]+" - (line-beginning-position)) - (and containing-sexp - (>= (1+ containing-sexp) (point))))) - (forward-sexp -1) - (backward-prefix-chars)) - (setq calculate-lisp-indent-last-sexp (point))) - (> calculate-lisp-indent-last-sexp - (save-excursion - (goto-char (1+ containing-sexp)) - (parse-partial-sexp (point) calculate-lisp-indent-last-sexp 0 t) - (point))) - (let ((parse-sexp-ignore-comments t) - indent) - (goto-char calculate-lisp-indent-last-sexp) - (or (and (looking-at ":") - (setq indent (current-column))) - (and (< (line-beginning-position) - (prog2 (backward-sexp) (point))) - (looking-at ":") - (setq indent (current-column)))) - indent)) - ;; another symbols or constants not preceded by a constant as - ;; defined above. - normal-indent)) - ;; in this case calculate-lisp-indent-last-sexp is nil - (desired-indent) - (normal-indent)))))) - -;; HACK: Quite a few functions here are called often, and so are especially -;; performance sensitive, so we compile this file on-demand, at least, until -;; Doom adds a formal compile step to 'doom sync'. -(doom-compile-functions #'+emacs-lisp-highlight-vars-and-faces - #'+emacs-lisp-truncate-pin - #'+emacs-lisp--calculate-lisp-indent-a) - -;;; autoload.el ends here diff --git a/.config/emacs/modules/lang/emacs-lisp/config.el b/.config/emacs/modules/lang/emacs-lisp/config.el @@ -1,242 +0,0 @@ -;;; lang/emacs-lisp/config.el -*- lexical-binding: t; -*- - -(defvar +emacs-lisp-enable-extra-fontification t - "If non-nil, highlight special forms, and defined functions and variables.") - -(defvar +emacs-lisp-outline-regexp "[ \t]*;;;\\(;*\\**\\) [^ \t\n]" - "Regexp to use for `outline-regexp' in `emacs-lisp-mode'. -This marks a foldable marker for `outline-minor-mode' in elisp buffers.") - -(defvar +emacs-lisp-linter-warnings - '(not free-vars ; don't complain about unknown variables - noruntime ; don't complain about unknown function calls - unresolved) ; don't complain about undefined functions - "The value for `byte-compile-warnings' in non-packages. - -This reduces the verbosity of flycheck in Emacs configs and scripts, which are -so stateful that the deluge of false positives (from the byte-compiler, -package-lint, and checkdoc) can be more overwhelming than helpful. - -See `+emacs-lisp-non-package-mode' for details.") - - -;; `elisp-mode' is loaded at startup. In order to lazy load its config we need -;; to pretend it isn't loaded -(defer-feature! elisp-mode emacs-lisp-mode) - - -;; -;;; Config - -(use-package! elisp-mode - :mode ("\\.Cask\\'" . emacs-lisp-mode) - :interpreter ("doomscript" . emacs-lisp-mode) - :config - (set-repl-handler! '(emacs-lisp-mode lisp-interaction-mode) #'+emacs-lisp/open-repl) - (set-eval-handler! '(emacs-lisp-mode lisp-interaction-mode) #'+emacs-lisp-eval) - (set-lookup-handlers! '(emacs-lisp-mode lisp-interaction-mode helpful-mode) - :definition #'+emacs-lisp-lookup-definition - :documentation #'+emacs-lisp-lookup-documentation) - (set-docsets! '(emacs-lisp-mode lisp-interaction-mode) "Emacs Lisp") - (set-ligatures! 'emacs-lisp-mode :lambda "lambda") - (set-rotate-patterns! 'emacs-lisp-mode - :symbols '(("t" "nil") - ("let" "let*") - ("when" "unless") - ("advice-add" "advice-remove") - ("defadvice!" "undefadvice!") - ("add-hook" "remove-hook") - ("add-hook!" "remove-hook!") - ("it" "xit") - ("describe" "xdescribe"))) - - (setq-hook! 'emacs-lisp-mode-hook - ;; Emacs' built-in elisp files use a hybrid tab->space indentation scheme - ;; with a tab width of 8. Any smaller and the indentation will be - ;; unreadable. Since Emacs' lisp indenter doesn't respect this variable it's - ;; safe to ignore this setting otherwise. - tab-width 8 - ;; Don't treat autoloads or sexp openers as outline headers, we have - ;; hideshow for that. - outline-regexp +emacs-lisp-outline-regexp - outline-level #'+emacs-lisp-outline-level) - - ;; DEPRECATED: Remove when 27.x support is dropped. - (when (< emacs-major-version 28) - ;; As of Emacs 28+, `emacs-lisp-mode' uses a shorter label in the mode-line - ;; ("ELisp/X", where X = l or d, depending on `lexical-binding'). In <=27, - ;; it uses "Emacs-Lisp". The former is more useful, so I backport it: - (setq-hook! 'emacs-lisp-mode-hook - mode-name `("ELisp" - (lexical-binding (:propertize "/l" - help-echo "Using lexical-binding mode") - (:propertize "/d" - help-echo "Using old dynamic scoping mode" - face warning - mouse-face mode-line-highlight))))) - - ;; Fixed indenter that intends plists sensibly. - (advice-add #'calculate-lisp-indent :override #'+emacs-lisp--calculate-lisp-indent-a) - - ;; variable-width indentation is superior in elisp. Otherwise, `dtrt-indent' - ;; and `editorconfig' would force fixed indentation on elisp. - (add-to-list 'doom-detect-indentation-excluded-modes 'emacs-lisp-mode) - - (add-hook! 'emacs-lisp-mode-hook - ;; Allow folding of outlines in comments - #'outline-minor-mode - ;; Make parenthesis depth easier to distinguish at a glance - #'rainbow-delimiters-mode - ;; Make quoted symbols easier to distinguish from free variables - #'highlight-quoted-mode - ;; Extend imenu support to Doom constructs - #'+emacs-lisp-extend-imenu-h - ;; Ensure straight sees modifications to installed packages - #'+emacs-lisp-init-straight-maybe-h) - - ;; UX: Flycheck's two emacs-lisp checkers produce a *lot* of false positives - ;; in non-packages (like Emacs configs or elisp scripts), so I disable - ;; `emacs-lisp-checkdoc' and set `byte-compile-warnings' to a subset of the - ;; original in the flycheck instance (see `+emacs-lisp-linter-warnings'). - (add-hook 'flycheck-mode-hook #'+emacs-lisp-non-package-mode) - - ;; Enhance elisp syntax highlighting, by highlighting Doom-specific - ;; constructs, defined symbols, and truncating :pin's in `package!' calls. - (font-lock-add-keywords - 'emacs-lisp-mode - (append `(;; custom Doom cookies - ("^;;;###\\(autodef\\|if\\|package\\)[ \n]" (1 font-lock-warning-face t))) - ;; Shorten the :pin of `package!' statements to 10 characters - `(("(package!\\_>" (0 (+emacs-lisp-truncate-pin)))) - ;; highlight defined, special variables & functions - (when +emacs-lisp-enable-extra-fontification - `((+emacs-lisp-highlight-vars-and-faces . +emacs-lisp--face))))) - - ;; Recenter window after following definition - (advice-add #'elisp-def :after #'doom-recenter-a) - - (defadvice! +emacs-lisp-append-value-to-eldoc-a (fn sym) - "Display variable value next to documentation in eldoc." - :around #'elisp-get-var-docstring - (when-let (ret (funcall fn sym)) - (if (boundp sym) - (concat ret " " - (let* ((truncated " [...]") - (print-escape-newlines t) - (str (symbol-value sym)) - (str (prin1-to-string str)) - (limit (- (frame-width) (length ret) (length truncated) 1))) - (format (format "%%0.%ds%%s" (max limit 0)) - (propertize str 'face 'warning) - (if (< (length str) limit) "" truncated)))) - ret))) - - (map! :localleader - :map (emacs-lisp-mode-map lisp-interaction-mode-map) - :desc "Expand macro" "m" #'macrostep-expand - (:prefix ("d" . "debug") - "f" #'+emacs-lisp/edebug-instrument-defun-on - "F" #'+emacs-lisp/edebug-instrument-defun-off) - (:prefix ("e" . "eval") - "b" #'eval-buffer - "d" #'eval-defun - "e" #'eval-last-sexp - "r" #'eval-region - "l" #'load-library) - (:prefix ("g" . "goto") - "f" #'find-function - "v" #'find-variable - "l" #'find-library))) - -(use-package! ielm - :defer t - :config - (set-lookup-handlers! 'inferior-emacs-lisp-mode - :definition #'+emacs-lisp-lookup-definition - :documentation #'+emacs-lisp-lookup-documentation) - - ;; Adapted from http://www.modernemacs.com/post/comint-highlighting/ to add - ;; syntax highlighting to ielm REPLs. - (setq ielm-font-lock-keywords - (append '(("\\(^\\*\\*\\*[^*]+\\*\\*\\*\\)\\(.*$\\)" - (1 font-lock-comment-face) - (2 font-lock-constant-face))) - (when (require 'highlight-numbers nil t) - (highlight-numbers--get-regexp-for-mode 'emacs-lisp-mode)) - (cl-loop for (matcher . match-highlights) - in (append lisp-el-font-lock-keywords-2 - lisp-cl-font-lock-keywords-2) - collect - `((lambda (limit) - (when ,(if (symbolp matcher) - `(,matcher limit) - `(re-search-forward ,matcher limit t)) - ;; Only highlight matches after the prompt - (> (match-beginning 0) (car comint-last-prompt)) - ;; Make sure we're not in a comment or string - (let ((state (syntax-ppss))) - (not (or (nth 3 state) - (nth 4 state)))))) - ,@match-highlights))))) - - -;; -;;; Packages - -;;;###package overseer -(autoload 'overseer-test "overseer" nil t) -;; Properly lazy load overseer by not loading it so early: -(remove-hook 'emacs-lisp-mode-hook #'overseer-enable-mode) - - -(use-package! flycheck-cask - :when (modulep! :checkers syntax) - :defer t - :init - (add-hook! 'emacs-lisp-mode-hook - (add-hook 'flycheck-mode-hook #'flycheck-cask-setup nil t))) - - -(use-package! flycheck-package - :when (modulep! :checkers syntax) - :after flycheck - :config (flycheck-package-setup)) - - -(use-package! elisp-demos - :defer t - :init - (advice-add #'describe-function-1 :after #'elisp-demos-advice-describe-function-1) - (advice-add #'helpful-update :after #'elisp-demos-advice-helpful-update) - :config - (advice-add #'elisp-demos--search :around #'+emacs-lisp--add-doom-elisp-demos-a)) - - -(use-package! buttercup - :defer t - :minor ("/test[/-].+\\.el$" . buttercup-minor-mode) - :preface - ;; buttercup.el doesn't define a keymap for `buttercup-minor-mode', as we have - ;; to fool its internal `define-minor-mode' call into thinking one exists, so - ;; it will associate it with the mode. - (defvar buttercup-minor-mode-map (make-sparse-keymap)) - :config - (set-popup-rule! "^\\*Buttercup\\*$" :size 0.45 :select nil :ttl 0) - (set-yas-minor-mode! 'buttercup-minor-mode) - (when (featurep 'evil) - (add-hook 'buttercup-minor-mode-hook #'evil-normalize-keymaps)) - (map! :localleader - :map buttercup-minor-mode-map - :prefix "t" - "t" #'+emacs-lisp/buttercup-run-file - "a" #'+emacs-lisp/buttercup-run-project - "s" #'buttercup-run-at-point)) - - -;; -;;; Project modes - -(def-project-mode! +emacs-lisp-ert-mode - :modes '(emacs-lisp-mode) - :match "/test[/-].+\\.el$" - :add-hooks '(overseer-enable-mode)) diff --git a/.config/emacs/modules/lang/emacs-lisp/packages.el b/.config/emacs/modules/lang/emacs-lisp/packages.el @@ -1,19 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/emacs-lisp/packages.el - -(package! elisp-mode :built-in t) - -;; Fontification plugins -(package! highlight-quoted :pin "24103478158cd19fbcfb4339a3f1fa1f054f1469") - -;; Tools -(package! macrostep :pin "75ecd041219239f0dceab4883594ea2fe366b484") -(package! overseer :pin "02d49f582e80e36b4334c9187801c5ecfb027789") -(package! elisp-def :pin "1d2e88a232ec16bce036b49577c4d4d96035f9f7") -(package! elisp-demos :pin "792be709c82101aea0585ece7429e2fdded74494") -(when (modulep! :checkers syntax) - (package! flycheck-package :pin "3a6aaed29ff61418c48c0251e1432c30748ae739") - (package! flycheck-cask :pin "4b2ede6362ded4a45678dfbef1876faa42edbd58")) - -;; Libraries -(package! buttercup :pin "07a52c99695845a0089e828d43da154c0ba0c178") diff --git a/.config/emacs/modules/lang/erlang/README.org b/.config/emacs/modules/lang/erlang/README.org @@ -1,63 +0,0 @@ -#+title: :lang erlang -#+subtitle: an elegant language for a more civilized age -#+created: April 07, 2018 -#+since: 21.12.0 (#497) - -* Description :unfold: -This module provides support [[https://www.erlang.org/][Erlang programming language]]. Support for the -[[https://github.com/erlang/sourcer][sourcer]] language server is optional. - -Includes: -- Code completion ([[doom-module:+lsp]], [[doom-module::completion company]], & [[doom-module::completion ivy]]) -- Syntax checking ([[doom-module::checkers syntax]]) - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +lsp :: - Enable LSP support for ~erlang-mode~. Requires [[doom-module::tools lsp]] and a langserver - (supports [[https://github.com/erlang/sourcer][sourcer]]). -- +tree-sitter :: - Leverages tree-sitter for better syntax highlighting and structural text - editing. Requires [[doom-module::tools tree-sitter]]. - -** Packages -- [[doom-package:flycheck-rebar3]] -- [[doom-package:ivy-erlang-complete]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires Erlang be installed (which includes ~erlang-mode~). Check -your distribution's package manager or a version management tool such as [[https://github.com/kerl/kerl][kerl]]. - -For LSP support, install [[https://github.com/erlang/sourcer][sourcer]]. - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/erlang/config.el b/.config/emacs/modules/lang/erlang/config.el @@ -1,12 +0,0 @@ -;;; lang/erlang/config.el -*- lexical-binding: t; -*- - -(use-package! erlang - :mode ("\\.erlang\\'" . erlang-mode) - :mode ("/rebar\\.config\\(?:\\.script\\)?\\'" . erlang-mode) - :mode ("/\\(?:app\\|sys\\)\\.config\\'" . erlang-mode) - :config - (when (modulep! +lsp) - (add-hook 'erlang-mode-local-vars-hook #'lsp! 'append)) - - (when (modulep! +tree-sitter) - (add-hook 'erlang-mode-local-vars-hook #'tree-sitter! 'append))) diff --git a/.config/emacs/modules/lang/erlang/doctor.el b/.config/emacs/modules/lang/erlang/doctor.el @@ -1,6 +0,0 @@ -;; -*- lexical-binding: t; no-byte-compile: t; -*- -;;; lang/erlang/doctor.el - -(assert! (or (not (modulep! +lsp)) - (modulep! :tools lsp)) - "This module requires (:tools lsp)") diff --git a/.config/emacs/modules/lang/erlang/packages.el b/.config/emacs/modules/lang/erlang/packages.el @@ -1,4 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/erlang/packages.el - -(package! erlang :pin "be7109f43beeeea199ae74a42393927d013f75d9") diff --git a/.config/emacs/modules/lang/ess/README.org b/.config/emacs/modules/lang/ess/README.org @@ -1,107 +0,0 @@ -#+title: :lang ess -#+subtitle: 73.6% of all statistics are made up -#+created: February 05, 2018 -#+since: 21.12.0 (#410) - -* Description :unfold: -This module adds support for various statistics languages, including R, S-Plus, -SAS, Julia and Stata. - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +stan :: - Enable support for ~stan-mode~, including code completion and syntax checking. -- +tree-sitter :: - Leverages tree-sitter for better syntax highlighting and structural text - editing. Currently only supports ~ess-r-mode~. Requires [[doom-module::tools tree-sitter]]. - -** Packages -- [[doom-package:ess]] -- [[doom-package:ess-R-data-view]] -- [[doom-package:polymode]] -- [[doom-package:poly-R]] -- if [[doom-module:+stan]] - - [[doom-package:company-stan]] if [[doom-module::completion company]] - - [[doom-package:eldoc-stan]] - - [[doom-package:flycheck-stan]] if [[doom-module::checkers syntax]] - - [[doom-package:stan-mode]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module has several optional dependencies: - -- [[https://github.com/jimhester/lintr][lintr]]: for R linting. -- [[https://github.com/REditorSupport/languageserver][languageserver]]: for LSP support in an R buffer (with [[doom-module:+lsp]] flag). - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** :map ess-doc-map -| key | command | -|-----+----------------------------| -| "h" | ess-display-help-on-object | -| "p" | ess-R-dv-pprint | -| "t" | ess-R-dv-ctable | - -** :map ess-mode-map -| key | command | -|--------------+-----------------------| -| "<s-return>" | ess-eval-line | -| "<up>" | comint-next-input | -| "<down>" | comint-previous-input | - -** :localleader -| state | key | command | -|-------+-------------+---------------------------------------------------| -| :nv | "," | ess-eval-region-or-function-or-paragraph-and-step | -| :n | "'" | R | -| :n | "<tab>" | ess-switch-to-inferior-or-script-buffer | -| :n | "<backtab>" | ess-switch-process | -| :n | "B" | ess-eval-buffer-and-go | -| :n | "b" | ess-eval-buffer | -| :nv | "d" | ess-eval-region-or-line-and-step | -| :n | "D" | ess-eval-function-or-paragraph-and-step | -| :n | "L" | ess-eval-line-and-go | -| :n | "l" | ess-eval-line | -| :nv | "R" | ess-eval-region-and-go | -| :nv | "r" | ess-eval-region | -| :n | "F" | ess-eval-function-and-go | -| :n | "f" | ess-eval-function | -| :n | "h" | ess-doc-map | -| :n | "x" | ess-extra-map | -| :n | "p" | ess-r-package-dev-map | -| :n | "v" | ess-dev-map | -| :n | "cC" | ess-eval-chunk-and-go | -| :n | "cc" | ess-eval-chunk | -| :n | "cd" | ess-eval-chunk-and-step | -| :n | "cm" | ess-noweb-mark-chunk | -| :n | "cp" | ess-noweb-previous-chunk | -| :n | "cn" | ess-noweb-next-chunk | - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/ess/autoload.el b/.config/emacs/modules/lang/ess/autoload.el @@ -1,15 +0,0 @@ -;;; lang/ess/autoload.el -*- lexical-binding: t; -*- - -;;;###autoload -(defun +ess/open-julia-repl (&optional arg) - "Open an ESS Julia REPL" - (interactive "P") - (run-ess-julia arg) - (current-buffer)) - -;;;###autoload -(defun +ess/open-r-repl (&optional arg) - "Open an ESS R REPL" - (interactive "P") - (run-ess-r arg) - (current-buffer)) diff --git a/.config/emacs/modules/lang/ess/config.el b/.config/emacs/modules/lang/ess/config.el @@ -1,109 +0,0 @@ -;;; lang/ess/config.el -*- lexical-binding: t; -*- - -(after! projectile - (add-to-list 'projectile-project-root-files "DESCRIPTION")) - - -;; -;;; Packages - -(use-package! ess - :commands stata SAS - :init - (unless (modulep! :lang julia) - (add-to-list 'auto-mode-alist '("\\.jl\\'" . ess-julia-mode))) - :config - (setq ess-offset-continued 'straight - ess-use-flymake (not (modulep! :checkers syntax)) - ess-nuke-trailing-whitespace-p t - ess-style 'DEFAULT - ess-history-directory (expand-file-name "ess-history/" doom-cache-dir)) - - (set-docsets! 'ess-r-mode "R") - (when (modulep! +lsp) - (add-hook 'ess-r-mode-local-vars-hook #'lsp! 'append)) - - (when (modulep! +tree-sitter) - (add-hook 'ess-r-mode-local-vars-hook #'tree-sitter! 'append)) - - (set-repl-handler! 'ess-r-mode #'+ess/open-r-repl) - (set-repl-handler! 'ess-julia-mode #'+ess/open-julia-repl) - (set-lookup-handlers! '(ess-r-mode ess-julia-mode) - :documentation #'ess-display-help-on-object) - - (set-evil-initial-state! 'ess-r-help-mode 'normal) - (set-eval-handler! 'ess-help-mode #'ess-eval-region-and-go) - (set-eval-handler! 'ess-r-help-mode #'ess-eval-region-and-go) - - (set-company-backend! 'ess-r-mode - '(company-R-args company-R-objects company-dabbrev-code :separate)) - - (setq-hook! 'ess-r-mode-hook - ;; HACK Fix #2233: Doom continues comments on RET, but ess-r-mode doesn't - ;; have a sane `comment-line-break-function', so... - comment-line-break-function nil) - - (map! (:after ess-help - (:map ess-help-mode-map - :n "q" #'kill-current-buffer - :n "Q" #'ess-kill-buffer-and-go - :n "K" #'ess-display-help-on-object - :n "go" #'ess-display-help-in-browser - :n "gO" #'ess-display-help-apropos - :n "gv" #'ess-display-vignettes - :m "]]" #'ess-skip-to-next-section - :m "[[" #'ess-skip-to-previous-section) - (:map ess-doc-map - "h" #'ess-display-help-on-object - "p" #'ess-R-dv-pprint - "t" #'ess-R-dv-ctable - [up] #'comint-next-input - [down] #'comint-previous-input - [C-return] #'ess-eval-line)) - - :map ess-mode-map - :n [C-return] #'ess-eval-line - :localleader - "," #'ess-eval-region-or-function-or-paragraph-and-step - "'" #'R - [tab] #'ess-switch-to-inferior-or-script-buffer - [backtab] #'ess-switch-process - ;; REPL - "B" #'ess-eval-buffer-and-go - "b" #'ess-eval-buffer - "d" #'ess-eval-region-or-line-and-step - "D" #'ess-eval-function-or-paragraph-and-step - "L" #'ess-eval-line-and-go - "l" #'ess-eval-line - "R" #'ess-eval-region-and-go - "r" #'ess-eval-region - "F" #'ess-eval-function-and-go - "f" #'ess-eval-function - ;; predefined keymaps - "h" 'ess-doc-map - "x" 'ess-extra-map - "p" 'ess-r-package-dev-map - "v" 'ess-dev-map - ;; noweb - :prefix "c" - "C" #'ess-eval-chunk-and-go - "c" #'ess-eval-chunk - "d" #'ess-eval-chunk-and-step - "m" #'ess-noweb-mark-chunk - "p" #'ess-noweb-previous-chunk - "n" #'ess-noweb-next-chunk)) - - -(use-package! stan-mode - :when (modulep! +stan) - :hook (stan-mode . stan-mode-setup) - :hook (stan-mode . eldoc-stan-setup) - :init - (use-package! company-stan - :when (modulep! :completion company) - :hook (stan-mode . company-stan-setup)) - - (use-package! flycheck-stan - :when (modulep! :checkers syntax) - :hook (stan-mode . flycheck-stan-stanc2-setup) - :hook (stan-mode . flycheck-stan-stanc3-setup))) diff --git a/.config/emacs/modules/lang/ess/packages.el b/.config/emacs/modules/lang/ess/packages.el @@ -1,15 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/ess/packages.el - -(package! ess :pin "8b4664e4a76a573b76ab3cf7a467d5e20fd5a6de") -(package! ess-R-data-view :pin "d6e98d3ae1e2a2ea39a56eebcdb73e99d29562e9") -(package! polymode :pin "15b6c1e94a450a65a0e32096855c31f4390a3963") -(package! poly-R :pin "e4a39caaf48e1c2e5afab3865644267b10610537") - -(when (modulep! +stan) - (package! stan-mode :pin "150bbbe5fd3ad2b5a3dbfba9d291e66eeea1a581") - (package! eldoc-stan :pin "150bbbe5fd3ad2b5a3dbfba9d291e66eeea1a581") - (when (modulep! :completion company) - (package! company-stan :pin "150bbbe5fd3ad2b5a3dbfba9d291e66eeea1a581")) - (when (modulep! :checkers syntax) - (package! flycheck-stan :pin "150bbbe5fd3ad2b5a3dbfba9d291e66eeea1a581"))) diff --git a/.config/emacs/modules/lang/factor/README.org b/.config/emacs/modules/lang/factor/README.org @@ -1,57 +0,0 @@ -#+title: :lang factor -#+subtitle: ... -#+created: December 03, 2019 -#+since: 21.12.0 (#2129) - -* Description :unfold: -This module adds support to the [[https://github.com/factor/factor][factor]] programming language and its associated -[[doom-package:fuel]] emacs plugin. - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -/This module doesn't install any packages./ - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires [[https://github.com/factor/factor][factor]] for its advanced functionality. - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -This module requires the installation of factor to be available at -~fuel-factor-root-dir~. E.g. -#+begin_src emacs-lisp -;; in $DOOMDIR/config.el -(setq fuel-factor-root-dir "/Applications/factor") -#+end_src - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/factor/config.el b/.config/emacs/modules/lang/factor/config.el @@ -1,77 +0,0 @@ -;;; lang/factor/config.el -*- lexical-binding: t; -*- - -(use-package! fuel-mode - :defer t - :init - (after! factor-mode - (set-eval-handler! 'factor-mode #'fuel-eval-region) - (set-repl-handler! 'factor-mode #'run-factor)) - :config - (set-lookup-handlers! 'factor-mode - :definition #'fuel-edit-word-at-point - :references #'fuel-show-callers - :documentation #'fuel-help)) - -(map! :after fuel-help - :map fuel-help-mode-map - :localleader - "e" #'fuel-help-edit - "d" #'fuel-help-delete-bookmark - "B" #'fuel-help-display-bookmarks - "n" #'fuel-help-next - "d" #'fuel-help-kill-page - "p" #'fuel-help-previous - "b" #'fuel-help-bookmark-page - "e" #'fuel-help-edit) - -(map! :after factor-mode - :map factor-mode-map - :localleader - "t" #'fuel-test-vocab - "F" #'fuel-run-file - "f" #'run-factor - "a" #'fuel-refresh-all - "L" #'fuel-load-usings - "u" #'fuel-vocab-usage - "U" #'fuel-vocab-uses - (:prefix ("c" . "change") - "w" #'fuel-edit-word-at-point - "d" #'fuel-edit-word-doc-at-point - "v" #'fuel-edit-vocabulary) - (:prefix ("e" . "eval") - "d" #'fuel-eval-definition - "R" #'fuel-eval-extended-region - "r" #'fuel-eval-region) - (:prefix ("h" . "help") - "p" #'fuel-apropos - "h" #'fuel-help - "b" #'fuel-help-display-bookmarks - "v" #'fuel-help-vocab - "w" #'fuel-show-file-words - "c" #'fuel-show-callees - "e" #'fuel-stack-effect-region - "s" #'fuel-stack-effect-sexp) - (:prefix ("s" . "scaffold") - "v" #'fuel-scaffold-vocab - "h" #'fuel-scaffold-help - "t" #'fuel-scaffold-tests) - (:prefix ("r" . "refactor") - "s" #'fuel-refactor-extract-sexp - "w" #'fuel-refactor-extract-region - "v" #'fuel-refactor-extract-vocab - "i" #'fuel-refactor-inline-word - "g" #'fuel-refactor-make-generic - "u" #'fuel-update-usings - "r" #'fuel-refactor-rename-word)) - -(map! :after fuel-listener - :map fuel-listener-mode-map - :localleader - "b" #'fuel-switch-to-buffer - "w" #'fuel-switch-to-buffer-other-window - "f" #'fuel-switch-to-buffer-other-frame - "e" #'fuel-edit-vocabulary - "r" #'fuel-refresh-all - "i" #'fuel-stack-mode - "h" #'fuel-help - "s" #'fuel-scaffold-vocab) diff --git a/.config/emacs/modules/lang/factor/packages.el b/.config/emacs/modules/lang/factor/packages.el @@ -1,4 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/factor/packages.el - -(package! fuel :pin "76ac65649d61975899070cf043447a995bf76c97") diff --git a/.config/emacs/modules/lang/faust/README.org b/.config/emacs/modules/lang/faust/README.org @@ -1,69 +0,0 @@ -#+title: :lang faust -#+subtitle: DSP, but you can keep your soul -#+created: October 14, 2019 -#+since: 21.12.0 (#1898) - -* Description :unfold: -Add support to [[https://faust.grame.fr/][Faust language]] inside emacs. - -- Faust code syntax highlighting and indentation -- Project-based (inter-linked Faust files) -- Build/compile with output window -- Graphic diagrams generation and visualization in the (default) browser -- Browse generated C++ code inside Emacs -- Inter-linked files/buffers : - - From "component" to Faust file - - From "include" to Faust library file -- From error to file:line number -- From function name to online documentation -- Fully configurable (build type/target/architecture/toolkit, keyboard - shortcuts, etc.) -- Automatic keyword completion (if Auto-Complete is installed) -- Automatic objets (functions, operators, etc.) template insertion with default - sensible values (if [[doom-module::editor snippets]] is enabled) -- Modeline indicator of the state of the code - -** Maintainers -*This module needs a maintainer.* [[doom-contrib-maintainer:][Become a maintainer?]] - -** Packages -- [[doom-package:faustine]] - -** Hacks -- Both ~faust-mode~ and ~faustine-mode~ are hardcoded to use [[doom-package:auto-complete]], - which Doom does not use. Its obnoxious 'You really should install and use - auto-complete' warnings have been silenced. - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -| Binding | Description | -|-------------------+----------------------| -| [[kbd:][<localleader> b]] | build | -| [[kbd:][<localleader> c]] | syntax check | -| [[kbd:][<localleader> d]] | diagram | -| [[kbd:][<localleader> h]] | online dock | -| [[kbd:][<localleader> RET]] | mdoc | -| [[kbd:][<localleader> o]] | toggle output buffer | -| [[kbd:][<localleader> s]] | source code | -| [[kbd:][<localleader> r]] | run | -| [[kbd:][<localleader> S-b]] | build all | -| [[kbd:][<localleader> S-d]] | diagram all | - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/faust/autoload.el b/.config/emacs/modules/lang/faust/autoload.el @@ -1,13 +0,0 @@ -;;; lang/faust/autoload.el -*- lexical-binding: t; -*- - -;;;###autoload -(defun +faust-company-backend (command &optional arg &rest ignored) - "`company-mode' completion back-end for `faust-mode'." - (interactive (list 'interactive)) - (cl-case command - (interactive (company-begin-backend '+faust-company-backend)) - (prefix (and (derived-mode-p 'faust-mode) - (not (company-in-string-or-comment)) - (or (company-grab-symbol-cons "\\." 1) 'stop))) - (candidates (cl-remove-if-not (lambda (c) (string-prefix-p arg c)) - faust-keywords-all)))) diff --git a/.config/emacs/modules/lang/faust/config.el b/.config/emacs/modules/lang/faust/config.el @@ -1,25 +0,0 @@ -;;; lang/faust/config.el -*- lexical-binding: t; -*- - -(use-package! faustine - :mode ("\\.dsp\\'" . faustine-mode) - :config - (set-company-backend! '(faust-mode faustine-mode) '(company-dabbrev-code +faust-company-backend company-yasnippet)) - - ;; HACK Both `faust-mode' and `faustine-mode' are hardcoded to use - ;; auto-complete. This silences the obnoxious 'You really should install and - ;; use auto-complete' warnings when starting them. - (defvar ac-modes nil) - (defvar ac-sources nil) - - (map! :localleader - :map faustine-mode-map - "RET" #'faustine-mdoc - "b" #'faustine-build - "B" #'faustine-build-all - "c" #'faustine-syntax-check - "d" #'faustine-diagram - "D" #'faustine-diagram-all - "h" #'faustine-online-doc - "o" #'faustine-toggle-output-buffer - "s" #'faustine-source-code - "r" #'faustine-run)) diff --git a/.config/emacs/modules/lang/faust/doctor.el b/.config/emacs/modules/lang/faust/doctor.el @@ -1,5 +0,0 @@ -;; -*- lexical-binding: t; no-byte-compile: t; -*- -;;; lang/faust/doctor.el - -(unless (executable-find "faust") - (warn! "Couldn't find the faust compiler. faustine-mode won't work.")) diff --git a/.config/emacs/modules/lang/faust/packages.el b/.config/emacs/modules/lang/faust/packages.el @@ -1,4 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/faust/packages.el - -(package! faustine :pin "07a38963111518f86123802f9d477be0d4689a3f") diff --git a/.config/emacs/modules/lang/fortran/README.org b/.config/emacs/modules/lang/fortran/README.org @@ -1,119 +0,0 @@ -#+title: :lang fortran -#+subtitle: In FORTRAN, GOD is REAL (unless declared INTEGER) -#+date: October 22, 2021 -#+since: 22.04.0 (#5676) - -* Description :unfold: -This module enables a complete, modern development environment for the [[https://fortran-lang.org/][Fortran]] -language. Initially released in 1956 (a year before Lisp 1.0), Fortran is the -original high-performance computation language and is still widely used in -science and academia. Popular versions of the language include Fortran 77 and -Fortran 90, with further extensions in the 1995 and 2008 varieties. Today, -Fortran has joined the modern age with its own [[https://github.com/fortran-lang/fpm][package manager]], [[https://fortran-lang.org/packages/][package registry]] -and [[https://fortran-lang.discourse.group/][Discourse community]]. - -In particular, this module features: -- Support for all major Fortran varieties. -- Auto-formatting via =fprettier=. -- Integration with the =fpm= package manager. -- LSP support via [[https://github.com/gnikit/fortls][fortls]]. -- Optional Intel Fortran support via the [[doom-module:+intel]] flag. - -#+begin_quote - 💬 After a career of writing Fortran on Mainframes and Windows machines, my - now-retired Dad is switching to Linux. Imagine my surprise when I learned - that off-the-shelf setups for Fortran on Linux basically don't exist! Well, - until now... Cheers Dad, hope this helps. --[[doom-user:][fosskers]] -#+end_quote - -** Maintainers -- [[doom-user:][@fosskers]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +lsp :: - Enable LSP support for ~fortran-mode~. Requires [[doom-module::tools lsp]] and a langserver - (fortls). -- +intel :: - Use the =ifort= compiler by default. - -** Packages -/This module doesn't install any packages./ - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -** General -For minimum functionality, this module requires =gfortran=. For most project -management tasks you will also need [[https://github.com/fortran-lang/fpm][fpm]], the Fortran Package Manager. - -*** Arch Linux -=gfortran= is available from the official repositories: -#+begin_src bash -$ sudo pacman -S gcc-fortran -#+end_src bash - -Whereas =fpm= and =fortls= are available from the AUR and thus must be installed -with an AUR-compatible tool like [[https://github.com/fosskers/aura][Aura]]: -#+begin_src bash -$ sudo aura -A fortran-fpm fortls -#+end_src bash - -** Installing Intel Fortran -Activating the [[doom-module:+intel]] flag won't automatically install Intel Fortan for you. -Here's how to do it on *nix systems. - -You can of course install the entire High-performance Computing kit from Intel, -which includes Fortran, but the installation footprint is quite large. Instead, -you're able to install just Fortran and its core facilities on their own as a -[[https://www.intel.com/content/www/us/en/developer/articles/tool/oneapi-standalone-components.html#fortran][standalone component]]. Download this script, and make it executable via: -#+begin_src bash -$ chmod +x l_fortran-compiler_p_2022.0.3.83_offline.sh -#+end_src bash - -The filepath will of course change with time, so alter the above command -accordingly. Now run the script _as a normal user_ (non-sudo) and follow the -instructions of the installer. This will install =ifort=, etc., in a local -filepath of your choosing. - -To actually use =ifort= and have it link to its libraries properly, we must run -a script provided by Intel to set certain environment variables: -#+begin_src bash -$ . ~/intel/oneapi/setvars.sh -#+end_src - -(Modify according to where you installed Intel Fortran.) Now =ifort= should be -runnable in your terminal as you'd expect. _To persist this, add that line to -your Bash Profile, etc., and log out and in again._ Now Doom will be able to use -=ifort= too. - -Good luck and happy computing! - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/fortran/autoload.el b/.config/emacs/modules/lang/fortran/autoload.el @@ -1,117 +0,0 @@ -;;; lang/fortran/autoload.el -*- lexical-binding: t; -*- - -;; -;;; Generalised Building - -;;;###autoload -(defun +fortran/build () - "Compile a Fortran project or file. - -If the current file is detected to be within an fpm project, then -building will occur with fpm. Otherwise it will default to ifort -or gfortran, depending on what feature flags are set." - (interactive) - (cond ((+fortran--fpm-toml) (+fortran/fpm-build)) - ((modulep! +intel) (+fortran/ifort-compile)) - (t (+fortran/gfortran-compile)))) - -;;;###autoload -(defun +fortran/run () - "Run a Fortran project or file. - -If the current file is detected to be within an fpm project, then -building will occur with fpm. Otherwise it will default to ifort -or gfortran, depending on what feature flags are set." - (interactive) - (cond ((+fortran--fpm-toml) (+fortran/fpm-run)) - ((modulep! +intel) (+fortran/ifort-run)) - (t (+fortran/gfortran-run)))) - -(defun +fortran--exec-name () - "The name of the output executable." - (file-name-sans-extension buffer-file-name)) - -;; -;;; Intel Fortran - -;;;###autoload -(defun +fortran/ifort-compile () - "Compile the current buffer using ifort." - (interactive) - (compile (format "ifort %S -o %S" - (buffer-file-name) - (+fortran--exec-name)))) - -;;;###autoload -(defun +fortran/ifort-run () - "Run the current buffer using ifort." - (interactive) - (let ((exec (+fortran--exec-name))) - (delete-file exec) - (+fortran/ifort-compile) - (while (not (file-exists-p exec)) - (sleep-for 1)) - (compile (format "%S" exec)))) - -;; -;;; GFortran - -(defun +fortran--std () - "Which version of Fortran should we target?" - (pcase major-mode - (`fortran-mode "-std=legacy") - (_ ""))) - -;;;###autoload -(defun +fortran-compilation-buffer-name-fn (mode) - "The name of the buffer produced by `compile'." - "*fortran-compilation*") - -;;;###autoload -(defun +fortran/gfortran-compile () - "Compile the current buffer using gfortran." - (interactive) - (compile (format "gfortran %s %S -o %S" - (+fortran--std) - buffer-file-name - (+fortran--exec-name)))) - -;;;###autoload -(defun +fortran/gfortran-run () - "Run the current buffer using gfortran." - (interactive) - (let ((exec (+fortran--exec-name))) - (delete-file exec) - (+fortran/gfortran-compile) - (while (not (file-exists-p exec)) - (sleep-for 1)) - (compile (format "%S" exec)))) - -;; -;;; FPM - -;;;###autoload -(defun +fortran--fpm-toml () - "If this is an fpm project, find its toml file." - (when-let* ((project-root (doom-project-root)) - (toml (expand-file-name "fpm.toml" project-root))) - (when (file-exists-p toml) - toml))) - -;;;###autoload -(defun +fortran/fpm-build () - "Build the current project using fpm." - (interactive) - (compile "fpm build")) - -;;;###autoload -(defun +fortran/fpm-run () - "Run the current project using fpm." - (interactive) - (compile "fpm run")) - -;;;###autoload -(defun +fortran/fpm-test () - "Test the current project using fpm." - (interactive) - (compile "fpm test")) diff --git a/.config/emacs/modules/lang/fortran/config.el b/.config/emacs/modules/lang/fortran/config.el @@ -1,85 +0,0 @@ -;;; lang/fortran/config.el -*- lexical-binding: t; -*- - -;; -;;; Packages - -(use-package! f90 - :defer t - :mode ("\\.F90" . f90-mode) - :config - ;; --- Compilation --- ;; - ;; Used by `compile' (SPC c c) - (let ((cmd (cond ((modulep! +intel) "ifort ") - (t "gfortran ")))) - (setq-hook! 'f90-mode-hook - compile-command cmd - compilation-buffer-name-function #'+fortran-compilation-buffer-name-fn)) - (set-popup-rule! "^\\*fortran-compilation" :side 'right :size 0.5 :quit t) - - ;; --- LSP Configuration --- ;; - (when (modulep! +lsp) - (setq lsp-clients-fortls-args '("--enable_code_actions" "--hover_signature")) - (add-hook 'f90-mode-local-vars-hook #'lsp! 'append)) - - ;; --- Keybindings --- ;; - (map! :map f90-mode-map - :localleader - (:prefix ("f" . "fpm") - :desc "fpm build" "b" #'+fortran/fpm-build - :desc "fpm run" "r" #'+fortran/fpm-run - :desc "fpm test" "t" #'+fortran/fpm-test) - (:prefix ("g" . "gfortran") - :desc "compile" "c" #'+fortran/gfortran-compile - :desc "run" "r" #'+fortran/gfortran-run) - :desc "build" "b" #'+fortran/build - :desc "run" "r" #'+fortran/run) - - (when (modulep! +intel) - (map! :map f90-mode-map - :localleader - (:prefix ("i" . "ifort") - :desc "compile" "c" #'+fortran/ifort-compile - :desc "run" "r" #'+fortran/ifort-run))) - - (easy-menu-define f90-menu f90-mode-map "Simpler menu for F90 mode." - `("F90" - ["Compile" +fortran/build :active t :help "Compile the Project"] - ["Run" +fortran/run :active t :help "Run the Executable"] - ["Test" +fortran/fpm-test :active (+fortran--fpm-toml) :help "Run the Unit Tests"]))) - -(use-package! fortran - ;; The `.for' extension is automatically recognized by Emacs and invokes - ;; `fortran-mode', but not its capital variant `.FOR'. Many old files are - ;; named the latter way, so we account for that manually here. - :mode ("\\.FOR$" . fortran-mode) - :config - ;; Or else Flycheck will get very mad. - (setq flycheck-gfortran-language-standard "legacy") - - ;; --- Compilation --- ;; - ;; Used by `compile' (SPC c c) - (let ((cmd (cond ((modulep! +intel) "ifort ") - (t "gfortran -std=legacy ")))) - (setq-hook! 'fortran-mode-hook - compile-command cmd - compilation-buffer-name-function #'+fortran-compilation-buffer-name-fn)) - (set-popup-rule! "^\\*fortran-compilation" :side 'right :size 0.5 :quit t) - - ;; --- Keybindings --- ;; - (map! :map fortran-mode-map - :localleader - (:prefix ("g" . "gfortran") - :desc "compile" "c" #'+fortran/gfortran-compile - :desc "run" "r" #'+fortran/gfortran-run)) - - (when (modulep! +intel) - (map! :map fortran-mode-map - :localleader - (:prefix ("i" . "ifort") - :desc "compile" "c" #'+fortran/ifort-compile - :desc "run" "r" #'+fortran/ifort-run))) - - (easy-menu-define fortran-menu fortran-mode-map "Simpler menu for Fortran mode." - '("Fortran" - ["Compile" +fortran/build :active t :help "Compile with Project"] - ["Run" +fortran/run :active t :help "Run the Executable"]))) diff --git a/.config/emacs/modules/lang/fortran/doctor.el b/.config/emacs/modules/lang/fortran/doctor.el @@ -1,23 +0,0 @@ -;; -*- lexical-binding: t; no-byte-compile: t; -*- -;;; lang/fortran/doctor.el - -(assert! (or (not (modulep! +lsp)) - (modulep! :tools lsp)) - "This module requires (:tools lsp)") - -(when (and (modulep! +intel) - (not (executable-find "ifort"))) - (warn! "Couldn't find Intel ifort - compilation will not work.")) - -(when (and (not (modulep! +intel)) - (not (executable-find "gfortran"))) - (warn! "Couldn't find gfortran - compilation will not work.")) - -(unless (executable-find "fpm") - (warn! "Couldn't find fpm - project building/testing will not work.")) - -(when (modulep! +lsp) - (unless (executable-find "fortls") - (warn! "Couldn't find fortls.")) - (unless (executable-find "fprettify") - (warn! "Couldn't find fprettify."))) diff --git a/.config/emacs/modules/lang/fsharp/README.org b/.config/emacs/modules/lang/fsharp/README.org @@ -1,70 +0,0 @@ -#+title: :lang fsharp -#+subtitle: ML stands for Microsoft's Language -#+created: May 23, 2019 -#+since: 21.12.0 (#1327) - -* Description :unfold: -This module adds [[https://fsharp.org/][F#]] support to Doom Emacs. - -*Includes:* -- Code completion -- eldoc support -- Syntax checking - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +lsp :: - Enable LSP support for ~fsharp-mode~. Requires [[doom-module::tools lsp]] and a langserver - (supports [[https://github.com/emacs-lsp/lsp-mode/blob/master/clients/lsp-fsharp.el][lsp-fsharp]].). - -** Packages -- [[doom-package:fsharp-mode]] -- [[doom-package:lsp-fsharp]] if [[doom-package:+lsp]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -To get code completion/syntax checking when not using lsp, you will need to -install [[https://www.mono-project.com/][mono]]. - -** Mono -*** OSX -*Do NOT install mono via brew.* See this [[https://github.com/fsharp/FsAutoComplete/issues/331][issue]]. - -*** Arch Linux -#+begin_src sh -pacman -S mono -#+end_src - -** LSP -The language server is automatically installed by [[https://github.com/emacs-lsp/lsp-mode/blob/master/clients/lsp-fsharp.el][lsp-fsharp]]. - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/fsharp/config.el b/.config/emacs/modules/lang/fsharp/config.el @@ -1,21 +0,0 @@ -;;; lang/fsharp/config.el -*- lexical-binding: t; -*- - -(after! fsharp-mode - (when (executable-find "dotnet") - (setq inferior-fsharp-program "dotnet fsi --readline-")) - (if (modulep! +lsp) - (progn - (setq fsharp-ac-intellisense-enabled nil) - (add-hook 'fsharp-mode-local-vars-hook #'lsp! 'append)) - (setq fsharp-ac-use-popup nil) ; Use a buffer for docs rather than a pop-up - (set-lookup-handlers! 'fsharp-mode :async t :definition #'fsharp-ac/gotodefn-at-point) - (set-company-backend! 'fsharp-mode 'fsharp-ac/company-backend)) - (set-repl-handler! 'fsharp-mode #'run-fsharp) - (map! :localleader - :map fsharp-mode-map - "b" #'fsharp-ac/pop-gotodefn-stack ; Useful for re-tracing your steps - "e" #'fsharp-eval-region - "l" #'fsharp-load-buffer-file - (:unless (modulep! +lsp) - "q" #'fsharp-ac/stop-process - "t" #'fsharp-ac/show-tooltip-at-point))) diff --git a/.config/emacs/modules/lang/fsharp/doctor.el b/.config/emacs/modules/lang/fsharp/doctor.el @@ -1,5 +0,0 @@ -;;; lang/fsharp/doctor.el -*- lexical-binding: t; -*- - -(when (require 'fsharp-mode nil t) - (unless (cl-some #'fsharp-mode--executable-find '("fsharpc" "fsc")) - (warn! "Cannot find the F# compiler. Most features will not work."))) diff --git a/.config/emacs/modules/lang/fsharp/packages.el b/.config/emacs/modules/lang/fsharp/packages.el @@ -1,4 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/fsharp/packages.el - -(package! fsharp-mode :pin "09fec6c91f9c18173f145e28c55d6f21be678231") diff --git a/.config/emacs/modules/lang/fstar/README.org b/.config/emacs/modules/lang/fstar/README.org @@ -1,73 +0,0 @@ -#+title: :lang fstar -#+subtitle: (Dependent) types and (monadic) effects and Z3 -#+created: February 02, 2020 -#+since: 21.12.0 (#2473) - -* Description :unfold: -This module adds [[https://fstar-lang.org/][F*]] support, powered by [[https://github.com/FStarLang/fstar-mode.el][fstar-mode.el]]. - -- Syntax highlighting -- Interactively process F* files one definition at a time -- Query the running F* process to look up definitions, documentation, and - theorems - -** Maintainers -- [[doom-user:][@tchajed]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:fstar-mode]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires [[https://github.com/FStarLang/FStar/blob/master/INSTALL.md][F*]]. - -While ~fstar-mode~ supports the latest release of F*, you may have a better -experience installing a more recent version from source. - -** macOS -#+begin_src sh -brew install fstar -#+end_src - -** Arch Linux -~fstar~ is available in the AUR: -#+begin_src sh -yaourt -S fstar -#+end_src - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -[[doom-report:][Report an issue?]] - -- If you're having trouble getting F* to start correctly, you may need to - configure a few variables in ~fstar-mode~; see its [[https://github.com/FStarLang/fstar-mode.el][README]] for more details. - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/fstar/config.el b/.config/emacs/modules/lang/fstar/config.el @@ -1,55 +0,0 @@ -;;; lang/fstar/config.el -*- lexical-binding: t; -*- - -(after! fstar-mode - (set-lookup-handlers! 'fstar-mode - :definition #'fstar-jump-to-definition - :documentation #'fstar-doc-at-point-dwim) - - (map! :map fstar-mode-map - :localleader - :desc "F* next" "]" #'fstar-subp-advance-next - :desc "F* go to point" "." #'fstar-subp-advance-or-retract-to-point - :desc "F* previous" "[" #'fstar-subp-retract-last - (:prefix ("p" . "proof") - :desc "go to point (lax)" "l" #'fstar-subp-advance-or-retract-to-point-lax - :desc "compile buffer (lax)" "b" #'fstar-subp-advance-to-point-max-lax - "q" #'fstar-subp-kill-one-or-many - "k" #'fstar-subp-kill-z3 - "r" #'fstar-subp-reload-to-point) - - (:prefix ("l" . "layout") - "c" #'fstar-quit-windows - "o" #'fstar-outline) - - ;; Moving around - "'" #'fstar-jump-to-related-error - (:prefix ("j" . "jump") - "j" #'fstar-jump-to-definition - "f" #'fstar-jump-to-definition-other-frame - "w" #'fstar-jump-to-definition-other-window - "e" #'fstar-jump-to-related-error - "F" #'fstar-jump-to-related-error-other-frame - "W" #'fstar-jump-to-related-error-other-window - "d" #'fstar-visit-dependency - "a" #'fstar-visit-interface-or-implementation - :desc "jump to first unprocessed line" "u" #'fstar-subp-goto-beginning-of-unprocessed) - - ;; Help !!! - (:prefix ("h" . "help") - "y" #'fstar-copy-help-at-point - "w" #'fstar-browse-wiki - "W" #'fstar-browse-wiki-in-browser - "o" #'fstar-list-options - "p" #'fstar-quick-peek) - - (:prefix ("a" . "ask (queries)") - "a" #'fstar-print - "e" #'fstar-eval - "E" #'fstar-eval-custom - "s" #'fstar-search - "d" #'fstar-doc) - - (:prefix ("i" . "insert") - "m" #'fstar-insert-match-dwim - "M" #'fstar-insert-match) - )) diff --git a/.config/emacs/modules/lang/fstar/packages.el b/.config/emacs/modules/lang/fstar/packages.el @@ -1,4 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/fstar/packages.el - -(package! fstar-mode :pin "ab0697b9474f36942a12a4b2a75251c247c18e9e") diff --git a/.config/emacs/modules/lang/gdscript/README.org b/.config/emacs/modules/lang/gdscript/README.org @@ -1,78 +0,0 @@ -#+title: :lang gdscript -#+subtitle: the language you waited for -#+created: June 01, 2020 -#+since: 21.12.0 (#3239) - -* Description :unfold: -This module adds support for GDScript, the scripting language of the [[http://godotengine.org/][Godot]] game -engine, to Doom Emacs, powered by [[https://github.com/GDQuest/emacs-gdscript-mode][gdscript-mode]]. - -** Maintainers -*This module needs a maintainer.* [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +lsp :: - Enable LSP support for ~gdscript-mode~. Requires [[doom-module::tools lsp]] and a langserver - (Godot ~3.2.1~ or newer). - -** Packages -- [[doom-package:gdscript-mode]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires Godot 3.2.1+ to be installed to make use of any of its -features (beyond syntax highlighting). - -To format your GDScript code, you will need [[https://github.com/Scony/godot-gdscript-toolkit/][gdtoolkit]]: -#+begin_src sh -# On Windows -pip install gdtoolkit - -# On MacOS and Linux -pip3 install gdtoolkit -#+end_src - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** LSP support -The language server support for GDScript is built into by lsp-mode. As long as -you have [[doom-module:+lsp]] and [[doom-module::tools lsp]] enabled, and Godot 3.2.1+ installed, it should work -out of the box. - -Godot's language server is built into the game engine, so you need to open your -project in Godot ~3.2.1~ or above for the GDScript language server to be -available. - -** Commands -Press the localleader key ([[kbd:][SPC m]] for evil users, [[kbd:][C-c l]] otherwise) to explore -available commands. - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -[[doom-report:][Report an issue?]] - -- The GDScript language server has known issues causing some errors with - [[doom-package:lsp-mode]]. They should be addressed in future releases. - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/gdscript/config.el b/.config/emacs/modules/lang/gdscript/config.el @@ -1,42 +0,0 @@ -;;; lang/gdscript/config.el -*- lexical-binding: t; -*- - -(after! projectile - (add-to-list 'projectile-project-root-files "project.godot")) - - -;; -;;; Packages - -(use-package! gdscript-mode - :defer t - :config - (set-lookup-handlers! 'gdscript-mode - :documentation #'gdscript-docs-browse-symbol-at-point) - - (when (modulep! +lsp) - (add-hook 'gdscript-mode-local-vars-hook #'lsp! 'append)) - - (map! :localleader - :map gdscript-mode-map - - (:prefix ("r" . "run") - :desc "Open project in Godot" "e" #'gdscript-godot-open-project-in-editor - :desc "Run project" "p" #'gdscript-godot-run-project - :desc "Run debug" "d" #'gdscript-godot-run-project-debug - :desc "Run current scene" "s" #'gdscript-godot-run-current-scene) - - (:prefix ("d" . "debug") - :desc "Add breakpoint" "a" #'gdscript-debug-add-breakpoint - :desc "Display breakpoint buffer" "b" #'gdscript-debug-display-breakpoint-buffer - :desc "Remove breakpoint" "d" #'gdscript-debug-remove-breakpoint - :desc "Continue execution" "c" #'gdscript-debug-continue - :desc "Next" "n" #'gdscript-debug-next - :desc "Step" "s" #'gdscript-debug-step) - - (:prefix ("h" . "help") - :desc "Browse online API" "b" #'gdscript-docs-browse-api - :desc "Browse API at point" "f" #'gdscript-docs-browse-symbol-at-point) - - (:prefix ("f" . "format") - :desc "Format buffer" "b" #'gdscript-format-buffer - :desc "Format region" "r" #'gdscript-format-region))) diff --git a/.config/emacs/modules/lang/gdscript/packages.el b/.config/emacs/modules/lang/gdscript/packages.el @@ -1,4 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/gdscript/packages.el - -(package! gdscript-mode :pin "d392e8aa7e7c6dd79ce52fb55d78f7acfa443194") diff --git a/.config/emacs/modules/lang/go/README.org b/.config/emacs/modules/lang/go/README.org @@ -1,141 +0,0 @@ -#+title: :lang go -#+subtitle: The hipster dialect -#+created: June 15, 2015 -#+since: 0.7 - -* Description :unfold: -This module adds [[https://golang.org][Go]] support, with optional (but recommended) LSP support via -[[https://github.com/golang/tools/blob/master/gopls/README.md][gopls]]. - -- Code completion (~gocode~) -- Documentation lookup (~godoc~) -- Eldoc support (~go-eldoc~) -- REPL (~gore~) -- Syntax-checking (~flycheck~) -- Auto-formatting on save (~gofmt~) (requires [[doom-module::editor format +onsave]]) -- Code navigation & refactoring (~go-guru~) -- [[../../editor/file-templates/templates/go-mode][File templates]] -- [[https://github.com/hlissner/doom-snippets/tree/master/go-mode][Snippets]] -- Generate testing code (~go-gen-test~) -- Code checking (~flycheck-golangci-lint~) - -** Maintainers -*This module needs a maintainer.* [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +lsp :: - Enable LSP support for ~go-mode~. Requires [[doom-module::tools lsp]] and a langserver - (supports gopls). Highly recommended, as the non-LSP experience is deprecated - (and poor). -- +tree-sitter :: - Leverages tree-sitter for better syntax highlighting and structural text - editing. Requires [[doom-module::tools tree-sitter]]. - -** Packages -- [[doom-package:company-go]] if [[doom-module::completion company]] (DEPRECATED) -- [[doom-package:flycheck-golangci-lint]] if [[doom-module::checkers syntax]] -- [[doom-package:go-eldoc]] -- [[doom-package:go-gen-test]] -- [[doom-package:go-guru]] -- [[doom-package:go-mode]] -- [[doom-package:gorepl-mode]] -- [[doom-package:go-tag]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires Go, a valid =$GOPATH=, and a number of go packages, listed -below. - -** Go -- macOS: ~$ brew install go~ -- Arch Linux: ~$ pacman -S go~ -- openSUSE: ~$ zypper install go~ - -** Dependencies -- ~gocode~ (for code completion & eldoc support) -- ~godoc~ (for documentation lookup) -- ~gorename~ (for extra refactoring commands) -- ~gore~ (for the REPL) -- ~guru~ (for code navigation & refactoring commands) -- ~goimports~ (/optional/: for auto-formatting code on save & fixing imports) -- ~gotests~ (for generate test code) -- ~gomodifytags~ (for manipulating tags) - -#+begin_src sh -export GOPATH=~/work/go - -go install github.com/x-motemen/gore/cmd/gore@latest -go install github.com/stamblerre/gocode@latest -go install golang.org/x/tools/cmd/godoc@latest -go install golang.org/x/tools/cmd/goimports@latest -go install golang.org/x/tools/cmd/gorename@latest -go install golang.org/x/tools/cmd/guru@latest -go install github.com/cweill/gotests/gotests@latest -go install github.com/fatih/gomodifytags@latest -#+end_src - -- ~golangci-lint~ (optional: for flycheck to integrate golangci-lint results) it - is recommended to *not* use ~$ go get~ to install this one, check the - [[https://github.com/golangci/golangci-lint#binary-release][documentation]]. - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -** Keybinds -| Keys | Description | -|---------------------+-------------------------------------------------------| -| [[kbd:][<localleader> a]] | Add field tags to a struct | -| [[kbd:][<localleader> d]] | Remove field tags from a struct | -| [[kbd:][<localleader> e]] | Evaluate buffer or selection in the Go playground | -| [[kbd:][<localleader> i]] | Go to imports | -| [[kbd:][<localleader> b c]] | run ~$ go clean~ | -| [[kbd:][<localleader> b b]] | run ~$ go build~ | -| [[kbd:][<localleader> b r]] | run ~$ go run .~ | -| [[kbd:][<localleader> h .]] | lookup symbol at point in godoc | -| [[kbd:][<localleader> h d]] | describe symbol at point | -| [[kbd:][<localleader> h v]] | list free variables | -| [[kbd:][<localleader> h i]] | list implements relations for package types | -| [[kbd:][<localleader> h p]] | list peers for channel | -| [[kbd:][<localleader> h P]] | "what does this point to" | -| [[kbd:][<localleader> h r]] | list references to object | -| [[kbd:][<localleader> h e]] | which errors | -| [[kbd:][<localleader> h w]] | what query | -| [[kbd:][<localleader> h c]] | show callers of function at point | -| [[kbd:][<localleader> h C]] | show callees of function at point | -| [[kbd:][<localleader> t t]] | rerun last test | -| [[kbd:][<localleader> t a]] | run all tests in project | -| [[kbd:][<localleader> t f]] | run all tests in current file | -| [[kbd:][<localleader> t s]] | run single test at point | -| [[kbd:][<localleader> t g]] | Generate tests for all exported or selected functions | -| [[kbd:][<localleader> t G]] | Generate tests for all functions | -| [[kbd:][<localleader> t e]] | Generate tests for all exported functions | -| [[kbd:][<localleader> t b s]] | go test.bench single | -| [[kbd:][<localleader> t b a]] | go test.bench all | -| [[kbd:][<localleader> r i a]] | search imports to add | -| [[kbd:][<localleader> r i r]] | reimove unused imports | - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/go/autoload.el b/.config/emacs/modules/lang/go/autoload.el @@ -1,84 +0,0 @@ -;;; lang/go/autoload.el -*- lexical-binding: t; -*- - -;; -;; Tests - -(defvar +go-test-last nil - "The last test run.") - -(defun +go--spawn (cmd) - (save-selected-window - (compile cmd))) - -(defun +go--run-tests (args) - (let ((cmd (concat "go test -test.v " args))) - (setq +go-test-last (concat "cd " default-directory ";" cmd)) - (+go--spawn cmd))) - -;;;###autoload -(defun +go/test-rerun () - "Rerun last run test." - (interactive) - (if +go-test-last - (+go--spawn +go-test-last) - (+go/test-all))) - -;;;###autoload -(defun +go/test-all () - "Run all tests for this project." - (interactive) - (+go--run-tests "")) - -;;;###autoload -(defun +go/test-nested () - "Run all tests in current directory and below, recursively." - (interactive) - (+go--run-tests "./...")) - -;;;###autoload -(defun +go/test-single () - "Run single test at point." - (interactive) - (if (string-match "_test\\.go" buffer-file-name) - (save-excursion - (re-search-backward "^func[ ]+\\(([[:alnum:]]*?[ ]?[*]?[[:alnum:]]+)[ ]+\\)?\\(Test[[:alnum:]_]+\\)(.*)") - (+go--run-tests (concat "-run" "='^\\Q" (match-string-no-properties 2) "\\E$'"))) - (error "Must be in a _test.go file"))) - -;;;###autoload -(defun +go/test-file () - "Run all tests in current file." - (interactive) - (if (string-match "_test\\.go" buffer-file-name) - (save-excursion - (goto-char (point-min)) - (let ((func-list)) - (while (re-search-forward "^func[ ]+\\(([[:alnum:]]*?[ ]?[*]?[[:alnum:]]+)[ ]+\\)?\\(Test[[:alnum:]_]+\\)(.*)" nil t) - (push (match-string-no-properties 2) func-list)) - (+go--run-tests (concat "-run" "='^(" (string-join func-list "|") ")$'")))) - (error "Must be in a _test.go file"))) - -;;;###autoload -(defun +go/bench-all () - "Run all benchmarks in project." - (interactive) - (+go--run-tests "-test.run=NONE -test.bench=\".*\"")) - -;;;###autoload -(defun +go/bench-single () - "Run benchmark at point." - (interactive) - (if (string-match "_test\\.go" buffer-file-name) - (save-excursion - (re-search-backward "^func[ ]+\\(([[:alnum:]]*?[ ]?[*]?[[:alnum:]]+)[ ]+\\)?\\(Benchmark[[:alnum:]_]+\\)(.*)") - (+go--run-tests (concat "-test.run=NONE -test.bench" "='^\\Q" (match-string-no-properties 2) "\\E$'"))) - (error "Must be in a _test.go file"))) - - -;;;###autoload -(defun +go/play-buffer-or-region (&optional beg end) - "Evaluate active selection or buffer in the Go playground." - (interactive "r") - (if (use-region-p) - (go-play-region beg end) - (go-play-buffer))) diff --git a/.config/emacs/modules/lang/go/config.el b/.config/emacs/modules/lang/go/config.el @@ -1,82 +0,0 @@ -;;; lang/go/config.el -*- lexical-binding: t; -*- - -;; -;;; Packages - -(after! go-mode - (set-docsets! 'go-mode "Go") - (set-repl-handler! 'go-mode #'gorepl-run) - (set-lookup-handlers! 'go-mode - :definition #'go-guru-definition - :references #'go-guru-referrers - :documentation #'godoc-at-point) - - ;; Redefines default formatter to *not* use goimports if reformatting a - ;; region; as it doesn't play well with partial code. - (set-formatter! 'gofmt - '(("%s" (if (or +format-region-p - (not (executable-find "goimports"))) - "gofmt" - "goimports")))) - - (if (modulep! +lsp) - (add-hook 'go-mode-local-vars-hook #'lsp! 'append) - (add-hook 'go-mode-hook #'go-eldoc-setup)) - - (when (modulep! +tree-sitter) - (add-hook 'go-mode-local-vars-hook #'tree-sitter! 'append)) - - (map! :map go-mode-map - :localleader - "a" #'go-tag-add - "d" #'go-tag-remove - "e" #'+go/play-buffer-or-region - "i" #'go-goto-imports ; Go to imports - (:prefix ("h" . "help") - "." #'godoc-at-point ; Lookup in godoc - "d" #'go-guru-describe ; Describe this - "v" #'go-guru-freevars ; List free variables - "i" #'go-guru-implements ; Implements relations for package types - "p" #'go-guru-peers ; List peers for channel - "P" #'go-guru-pointsto ; What does this point to - "r" #'go-guru-referrers ; List references to object - "e" #'go-guru-whicherrs ; Which errors - "w" #'go-guru-what ; What query - "c" #'go-guru-callers ; Show callers of this function - "C" #'go-guru-callees) ; Show callees of this function - (:prefix ("ri" . "imports") - "a" #'go-import-add - "r" #'go-remove-unused-imports) - (:prefix ("b" . "build") - :desc "go run ." "r" (cmd! (compile "go run .")) - :desc "go build" "b" (cmd! (compile "go build")) - :desc "go clean" "c" (cmd! (compile "go clean"))) - (:prefix ("t" . "test") - "t" #'+go/test-rerun - "a" #'+go/test-all - "s" #'+go/test-single - "n" #'+go/test-nested - "f" #'+go/test-file - "g" #'go-gen-test-dwim - "G" #'go-gen-test-all - "e" #'go-gen-test-exported - (:prefix ("b" . "bench") - "s" #'+go/bench-single - "a" #'+go/bench-all)))) - - -(use-package! gorepl-mode - :commands gorepl-run-load-current-file) - - -(use-package! company-go - :when (modulep! :completion company) - :unless (modulep! +lsp) - :after go-mode - :config - (set-company-backend! 'go-mode 'company-go) - (setq company-go-show-annotation t)) - -(use-package! flycheck-golangci-lint - :when (modulep! :checkers syntax) - :hook (go-mode . flycheck-golangci-lint-setup)) diff --git a/.config/emacs/modules/lang/go/doctor.el b/.config/emacs/modules/lang/go/doctor.el @@ -1,32 +0,0 @@ -;; -*- lexical-binding: t; no-byte-compile: t; -*- -;;; lang/go/doctor.el - -(assert! (or (not (modulep! +lsp)) - (modulep! :tools lsp)) - "This module requires (:tools lsp)") - -(assert! (or (not (modulep! +tree-sitter)) - (modulep! :tools tree-sitter)) - "This module requires (:tools tree-sitter)") - -(unless (executable-find "guru") - (warn! "Couldn't find guru. Refactoring commands (go-guru-*) won't work")) - -(unless (executable-find "gore") - (warn! "Couldn't find gore. REPL will not work")) - -(unless (executable-find "gotests") - (warn! "Couldn't find gotests. Generating tests will not work")) - -(unless (executable-find "gomodifytags") - (warn! "Couldn't find gomodifytags. Manipulating struct tags will not work")) - -(when (and (modulep! :completion company) - (not (modulep! +lsp))) - (require 'company-go) - (unless (executable-find company-go-gocode-command) - (warn! "Couldn't find gocode. Code completion won't work"))) - -(when (and (modulep! +lsp) - (not (executable-find "gopls"))) - (warn! "Couldn't find gopls.")) diff --git a/.config/emacs/modules/lang/go/packages.el b/.config/emacs/modules/lang/go/packages.el @@ -1,15 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/go/packages.el - -(package! go-eldoc :pin "cbbd2ea1e94a36004432a9ac61414cb5a95a39bd") -(package! go-guru :pin "166dfb1e090233c4609a50c2ec9f57f113c1da72") -(package! go-mode :pin "166dfb1e090233c4609a50c2ec9f57f113c1da72") -(package! gorepl-mode :pin "6a73bf352e8d893f89cad36c958c4db2b5e35e07") -(package! go-tag :pin "33f2059551d5298ca228d90f525b99d1a8d70364") -(package! go-gen-test :pin "f84f4177af7fcbe10ce2116d5417ad5f0485034b") - -(when (modulep! :completion company) - (package! company-go :pin "31948b463f2fc18f8801e5a8fe511fef300eb3dd")) - -(when (modulep! :checkers syntax) - (package! flycheck-golangci-lint :pin "8e446c68311048f0b87febf8ef0379e29d358851")) diff --git a/.config/emacs/modules/lang/graphql/README.org b/.config/emacs/modules/lang/graphql/README.org @@ -1,123 +0,0 @@ -#+title: :lang graphql -#+subtitle: Give queries a REST -#+created: March 31, 2022 -#+since: 22.04.0 (#6226) - -* Description :unfold: -This module adds [[https://www.graphql.org][GraphQL]] support to Doom Emacs. - -It includes: -- Code completion -- LSP support ([[doom-module:+lsp]]) - - Diagnostics (GraphQL syntax linting/validations) (spec-compliant) - - Autocomplete suggestions (spec-compliant) - - Hyperlink to fragment definitions and named types (type, input, enum) definitions (spec-compliant) - - Outline view support for queries and SDL - - Symbols support across the workspace -- Local schema viewer -- Org-babel exporter (requires [[doom-module::lang org]]) - -** Maintainers -- [[doom-user:][@elken]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +lsp :: - Enable LSP support for ~graphql-mode~. Requires [[doom-module::tools lsp]] and a langserver - ([[https://github.com/graphql/graphiql/tree/main/packages/graphql-language-service-cli#readme][graphql-language-service-cli]]). - -** Packages -- [[doom-package:company-graphql]] unless [[doom-module:+lsp]] -- [[doom-package:graphql-mode]] -- [[doom-package:graphql-doc]] - -** Hacks -- Added a convenience function [[fn:+graphql-doc-open-config]] to open schema docs from - a [[https://github.com/jimkyndemeyer/graphql-config-examples][.graphqlconfig]] file. - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module has no direct requirements, but the +lsp flag requires a [[https://emacs-lsp.github.io/lsp-mode/page/lsp-graphql/][supported -LSP server]]. - -* Usage -** Sending queries -When visiting a graphql buffer, you have access to the ability to send the -current query with =C-c C-c= which will prompt you for an optional variables file, -then execute the query and return a buffer of the results. - -It's also possible to send queries using org-babel using a block such as the -ones below (executing correctly will require =:lang org=) - -#+NAME: my-variables -#+begin_src json -{ - "continentCode": "AF" -} -#+end_src - -#+BEGIN_SRC graphql :url https://countries.trevorblades.com/ :variables my-variables -query GetContinents($continentCode: String!) { - continent(code: $continentCode) { - name - code - } -} -#+END_SRC - -#+RESULTS: -: { -: "data": { -: "continent": { -: "name": "Africa", -: "code": "AF" -: } -: } -: } - -** Viewing docs -With this module, there are 3 ways to view schemas: -+ =+graphql-doc-open-config= which uses a local [[https://github.com/jimkyndemeyer/graphql-config-examples][=.graphqlconfig=]] file to seed endpoints to query -+ =graphql-doc= which prompts you to select an endpoint based on ones added manually by =graphql-doc-add-api= -+ =graphql-doc-open-url= which prompts to to manually enter an endpoint url - -When using the doc viewer, there are a few bindings for navigating around. - -| Key | Command | Description | -|-------------+---------------------+-----------------------------------| -| =C-j= | =forward-button= | Follow a forward button | -| =C-k= | =backward-button= | Follow a backward button | -| =<backspace>= | =graphql-doc-go-back= | Go back to a previous page | -| =mouse-1= | - | Follow the next label under =point= | -| =RET= | - | Follow the next label under =point= | - -* Configuration -Most of the "magic" in the module relies on a properly configured [[https://github.com/jimkyndemeyer/graphql-config-examples][.graphqlconfig]] -file, so follow the examples linked to create an appropriate setup. - -LSP configuration is handled through [[https://github.com/graphql/graphiql/tree/main/packages/graphql-language-service-cli#graphql-configuration-file-graphqlrcyml][GraphQL Config]] to handle custom -directives/documents/validation etc. - -These files will also be useful to other editors, so it would be worth checking -them into version control. - -* Troubleshooting -[[doom-report:][Report an issue?]] - -- [[https://github.com/ifitzpatrick/graphql-doc.el/issues][Issues with the doc viewer]] -- [[https://github.com/davazp/graphql-mode/issues][Issues with graphql-mode]] -- [[https://github.com/emacs-lsp/lsp-mode/issues][Issues with LSP]] ([[https://github.com/graphql/graphiql/issues][Upstream LSP issues]]) - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/graphql/autoload.el b/.config/emacs/modules/lang/graphql/autoload.el @@ -1,14 +0,0 @@ -;;; lang/graphql/autoload.el -*- lexical-binding: t; -*- - -;;;###autoload -(defun +graphql-doc-open-config () - "Locate a .graphqlconfig file in the current tree and use that to point to a - schema." - (interactive) - (let ((config (json-read-file (graphql-locate-config ".")))) - (let-alist config - (if-let ((endpoints .extensions.endpoints) - (endpoint (cdr (assq (intern (graphql--completing-read-endpoint endpoints)) endpoints)))) - (let-alist endpoint - (graphql-doc--start .url `(:url ,.url :headers ,.headers))) - (error "No endpoint configurations in .graphqlconfig"))))) diff --git a/.config/emacs/modules/lang/graphql/config.el b/.config/emacs/modules/lang/graphql/config.el @@ -1,38 +0,0 @@ -;;; lang/graphql/config.el -*- lexical-binding: t; -*- - -(after! graphql-mode - (defface all-the-icons-rhodamine - '((t (:foreground "#E10098"))) - "Face for GraphQL icon." - :group 'all-the-icons-faces) - ;; Define a doom-modeline compatiable major-mode icon - (after! all-the-icons - (setf (alist-get "graphql" all-the-icons-extension-icon-alist) - '(all-the-icons-fileicon "graphql" :v-adjust -0.05 :face all-the-icons-rhodamine)) - (setf (alist-get "gql" all-the-icons-extension-icon-alist) - '(all-the-icons-fileicon "graphql" :v-adjust -0.05 :face all-the-icons-rhodamine)) - (setf (alist-get 'graphql-mode all-the-icons-mode-icon-alist) - '(all-the-icons-fileicon "graphql" :v-adjust -0.05 :face all-the-icons-rhodamine))) - (if (modulep! +lsp) - (add-hook 'graphql-mode-local-vars-hook #'lsp! 'append) - (set-company-backend! 'graphql-mode 'company-graphql)) - - (add-hook 'graphql-mode-hook #'rainbow-delimiters-mode) - (set-docsets! 'graphql-mode :add "GraphQL Specification") - - (set-electric! 'graphql-mode - :chars '(?\} ?\)) - :words '("or" "and")) - - (set-ligatures! 'graphql-mode - :null "null" - :true "true" :false "false" - :int "Int" :str "String" - :float "Float" - :bool "Bool" - - :not "not" - :and "and" :or "or")) - -(use-package! graphql-doc - :after graphql-mode) diff --git a/.config/emacs/modules/lang/graphql/packages.el b/.config/emacs/modules/lang/graphql/packages.el @@ -1,9 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/graphql/packages.el - -(package! graphql-mode :pin "1437b790060f6ce4a8dc57df2023443645b899e5") -(package! graphql-doc :pin "d37140267e0c426c7c18aff31900aa1650257394") -(unless (modulep! +lsp) - (package! company-graphql - :recipe (:host github :repo "thaenalpha/company-graphql") - :pin "aed9f5109e877944a895d08fc08bad103f03096b")) diff --git a/.config/emacs/modules/lang/haskell/README.org b/.config/emacs/modules/lang/haskell/README.org @@ -1,95 +0,0 @@ -#+title: :lang haskell -#+subtitle: A language that's lazier than I am -#+created: March 29, 2016 -#+since: 0.9 - -* Description :unfold: -This module adds Haskell support to Doom Emacs. - -** Maintainers -- [[doom-user:][@iyefrat]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +lsp :: - Enable LSP support for ~haskell-mode~. Requires [[doom-module::tools lsp]] and a langserver - (supports [[https://github.com/haskell/haskell-language-server][haskell-language-server]]). -- +tree-sitter :: - Leverages tree-sitter for better syntax highlighting and structural text - editing. Requires [[doom-module::tools tree-sitter]]. - -** Packages -- [[doom-package:haskell-mode]] -- [[doom-package:lsp-haskell]] if [[doom-module:+lsp]] - -** Hacks -/No hacks documented for this module./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -It is recommended to install the haskell tooling using [[https://www.haskell.org/ghcup/][ghcup]]. Only ghc is needed -for basic functionality: - -#+begin_src sh -ghcup install ghc -#+end_src - -but =+lsp= users should also install the language server: - -#+begin_src sh -ghcup install hls -#+end_src - -Installing [[https://www.haskell.org/cabal/][cabal]] or [[https://docs.haskellstack.org/en/stable/README/][stack]] as well is recommended, and can be done through -=ghcup=. - -=haskell-mode= provides support for [[https://github.com/ndmitchell/hoogle][hoogle]], which can be installed through -system package manager, cabal, or stack. - -=haskell-language-server= provides support for [[https://github.com/ndmitchell/hlint/][hlint]], and haskell code -formatters such as [[https://github.com/lspitzner/brittany][brittany]], [[https://github.com/ennocramer/floskell][floskell]], [[https://github.com/tweag/ormolu][ormolu]], [[https://github.com/fourmolu/fourmolu][fourmolu]], and [[https://github.com/haskell/stylish-haskell][stylish-haskell]], -which can be installed through system package manager, cabal, or stack. - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -This module integrates the haskell packages into Doom by providing things such -as REPL support, project root recognition, etc. It also provide the following -keybindings: - -| Keybinding | Description | -|-----------------+-----------------------------------------------| -| [[kbd:][<localleader> b]] | Build the current cabal project | -| [[kbd:][<localleader> c]] | Visit the =.cabal= file of the current buffer | -| [[kbd:][<localleader> h]] | Toggle visibility of the form at point | -| [[kbd:][<localleader> H]] | hides all top level functions | - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -After installing your preferred formatter, make sure to set -=lsp-haskell-formatting-provider= to it. - -Make sure to configure the lsp to use your perfered formatter, e.g.: -#+begin_src emacs-lisp -;; ~/.doom.d/config.el -(after! lsp-haskell - (setq lsp-haskell-formatting-provider "brittany")) -#+end_src - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote -🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/haskell/autoload.el b/.config/emacs/modules/lang/haskell/autoload.el @@ -1,29 +0,0 @@ -;;; lang/haskell/autoload.el -*- lexical-binding: t; -*- - -;;;###autoload -(defun +haskell/open-repl (&optional arg) - "Opens a Haskell REPL." - (interactive "P") - (require 'haskell-interactive-mode) - (if-let (window - (display-buffer - (haskell-session-interactive-buffer (haskell-session)))) - (window-buffer window) - (error "Failed to display Haskell REPL"))) - -;;;###autoload -(defun +haskell/evil-open-above () - "Opens a line above the current mode" - (interactive) - (evil-beginning-of-line) - (haskell-indentation-newline-and-indent) - (evil-previous-line) - (haskell-indentation-indent-line) - (evil-append-line nil)) - -;;;###autoload -(defun +haskell/evil-open-below () - "Opens a line below the current mode" - (interactive) - (evil-append-line nil) - (haskell-indentation-newline-and-indent)) diff --git a/.config/emacs/modules/lang/haskell/config.el b/.config/emacs/modules/lang/haskell/config.el @@ -1,58 +0,0 @@ -;;; lang/haskell/config.el -*- lexical-binding: t; -*- - -(after! projectile - (add-to-list 'projectile-project-root-files "stack.yaml")) - - -;; -;;; Common packages - -(after! haskell-mode - (setq haskell-process-suggest-remove-import-lines t ; warnings for redundant imports etc - haskell-process-auto-import-loaded-modules t - haskell-process-show-overlays (not (modulep! :checkers syntax))) ; redundant with flycheck - - (set-lookup-handlers! 'haskell-mode - :definition #'haskell-mode-jump-to-def-or-tag) - (set-file-template! 'haskell-mode - :trigger #'haskell-auto-insert-module-template - :project t) - (set-repl-handler! - '(haskell-mode haskell-cabal-mode literate-haskell-mode) - #'+haskell/open-repl :persist t) - ;; Don't kill REPL popup on ESC/C-g - (set-popup-rule! "^\\*haskell\\*" :quit nil) - - (add-hook! 'haskell-mode-hook - #'haskell-collapse-mode ; support folding haskell code blocks - #'interactive-haskell-mode) - - (when (modulep! +tree-sitter) - (add-hook 'haskell-mode-local-vars-hook #'tree-sitter! 'append)) - - (add-to-list 'completion-ignored-extensions ".hi") - - (map! :map haskell-mode-map - :n "o" #'+haskell/evil-open-below - :n "O" #'+haskell/evil-open-above - (:when (modulep! :tools lookup) - [remap haskell-mode-jump-to-def-or-tag] #'+lookup/definition)) - - (map! :localleader - :map haskell-mode-map - "b" #'haskell-process-cabal-build - "c" #'haskell-cabal-visit-file - "h" #'haskell-hide-toggle - "H" #'haskell-hide-toggle-all)) - - -(use-package! lsp-haskell - :when (modulep! +lsp) - :defer t - :init - (add-hook 'haskell-mode-local-vars-hook #'lsp! 'append) - (add-hook 'haskell-literate-mode-local-vars-hook #'lsp! 'append) - (after! lsp-mode (require 'lsp-haskell)) - :config - ;; Does some strange indentation if it pastes in the snippet - (setq-hook! 'haskell-mode-hook yas-indent-line 'fixed)) diff --git a/.config/emacs/modules/lang/haskell/doctor.el b/.config/emacs/modules/lang/haskell/doctor.el @@ -1,27 +0,0 @@ -;; -*- lexical-binding: t; no-byte-compile: t; -*- -;;; lang/haskell/doctor.el - -(assert! (or (not (modulep! +lsp)) - (modulep! :tools lsp)) - "This module requires (:tools lsp)") - -(unless (executable-find "cabal") - (warn! "Couldn't find cabal. haskell-mode may have issues.")) - -(unless (executable-find "hoogle") - (warn! "Couldn't find hoogle. Documentation searching will not work.")) - -(unless (or (modulep! +lsp) - (executable-find "hlint")) - (warn! "Couldn't find hlint. Flycheck may have issues in haskell-mode. - Install it or enable +lsp.")) - -(when (and (modulep! :editor format) - (not (modulep! +lsp)) - (not (executable-find "brittany"))) - (warn! "Couldn't find brittany. Code formatting will not work. - Install it or enable +lsp.")) - -(when (and (modulep! +lsp) - (not (executable-find "haskell-language-server-wrapper"))) - (warn! "Couldn't find haskell-language-server.")) diff --git a/.config/emacs/modules/lang/haskell/packages.el b/.config/emacs/modules/lang/haskell/packages.el @@ -1,8 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/haskell/packages.el - -(package! haskell-mode :pin "a34ccdc54be15043ff0d253c3c20087524255491") - -(when (and (modulep! +lsp) - (not (modulep! :tools lsp +eglot))) - (package! lsp-haskell :pin "3249cde75fb411f95fe173c222b848182fd0b752")) diff --git a/.config/emacs/modules/lang/hy/README.org b/.config/emacs/modules/lang/hy/README.org @@ -1,49 +0,0 @@ -#+title: :lang hy -#+subtitle: Lisp is better than ugly -#+created: June 25, 2017 -#+since: 2.0.4 (#122) - -* Description :unfold: -/(No description yet)/ - -** Maintainers -*This module needs a maintainer.* [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:hy-mode]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires [[https://docs.hylang.org/en/alpha/][Hy]]. - -* TODO Usage -#+begin_quote -🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote -🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote -🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/hy/config.el b/.config/emacs/modules/lang/hy/config.el @@ -1,8 +0,0 @@ -;;; lang/hy/config.el -*- lexical-binding: t; -*- - -(use-package! hy-mode - :mode "\\.hy\\'" - :interpreter "hy" - :config - (set-repl-handler! 'hy-mode #'hy-shell-start-or-switch-to-shell) - (set-company-backend! 'hy-mode 'company-hy)) diff --git a/.config/emacs/modules/lang/hy/packages.el b/.config/emacs/modules/lang/hy/packages.el @@ -1,4 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/hy/packages.el - -(package! hy-mode :pin "df814865a1faa8414dacdbb35b2a9029995312ec") diff --git a/.config/emacs/modules/lang/idris/README.org b/.config/emacs/modules/lang/idris/README.org @@ -1,54 +0,0 @@ -#+title: :lang idris -#+subtitle: A language you can depend on -#+created: August 21, 2018 -#+since: 21.12.0 (#822) - -* Description :unfold: -This module adds rudimentary [[https://www.idris-lang.org/][Idris]] support to Doom Emacs. - -** Maintainers -*This module needs a maintainer.* [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:idris-mode]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* TODO Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -#+begin_quote - 🔨 /No installation steps have been documented./ [[doom-contrib-module:][Document them?]] -#+end_quote - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -In addition to ~idris-mode~ goodness, adds frequently used functions under the -[[kbd:][<localleader>]] key. - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/idris/config.el b/.config/emacs/modules/lang/idris/config.el @@ -1,20 +0,0 @@ -;;; lang/idris/config.el -*- lexical-binding: t; -*- - -(after! idris-mode - (add-hook 'idris-mode-hook #'turn-on-idris-simple-indent) - (when (modulep! +lsp) - (add-hook 'idris-mode-hook #'lsp! 'append)) - (set-repl-handler! 'idris-mode 'idris-pop-to-repl) - (set-lookup-handlers! 'idris-mode - :documentation #'idris-docs-at-point) - (map! :localleader - :map idris-mode-map - "r" #'idris-load-file - "t" #'idris-type-at-point - "d" #'idris-add-clause - "l" #'idris-make-lemma - "c" #'idris-case-split - "w" #'idris-make-with-block - "m" #'idris-add-missing - "p" #'idris-proof-search - "h" #'idris-docs-at-point)) diff --git a/.config/emacs/modules/lang/idris/packages.el b/.config/emacs/modules/lang/idris/packages.el @@ -1,4 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/idris/packages.el - -(package! idris-mode :pin "c96f45d1b8fad193f09fb6139da17092003b5e74") diff --git a/.config/emacs/modules/lang/java/+eclim.el b/.config/emacs/modules/lang/java/+eclim.el @@ -1,50 +0,0 @@ -;;; lang/java/+eclim.el -*- lexical-binding: t; -*- -;;;###if (modulep! +eclim) - -;; NOTE This submodule is incomplete - -(use-package! eclim - :hook (java-mode . eclim-mode) - :config - (set-lookup-handlers! 'java-mode - :definition #'eclim-java-find-declaration - :references #'eclim-java-find-references - :documentation #'eclim-java-show-documentation-for-current-element) - - (require 'eclimd) - (setq help-at-pt-display-when-idle t - help-at-pt-timer-delay 0.1) - (help-at-pt-set-timer) - - (map! :localleader - :map java-mode-map - (:prefix ("r" . "refactor") - "gc" #'eclim-java-constructor - "gg" #'eclim-java-generate-getter-and-setter - "oi" #'eclim-java-import-organize - "f" #'eclim-java-format - "r" #'eclim-java-refactor-rename-symbol-at-point) - (:prefix ("h" . "help") - "." #'eclim-java-show-documentation-for-current-element - "r" #'eclim-java-find-references - "c" #'eclim-java-call-hierarchy - "h" #'eclim-java-hierarchy - "p" #'eclim-problems - "r" #'meghanada-reference - "t" #'meghanada-typeinfo) - (:prefix ("b" . "build") - "b" #'eclim-project-build - "c" #'eclim-project-create - "d" #'eclim-project-delete - "g" #'eclim-project-goto - "i" #'eclim-project-import - "k" #'eclim-project-close - "o" #'eclim-project-open - "u" #'eclim-project-update))) - - -(use-package! company-emacs-eclim - :when (modulep! :completion company) - :after java-mode - :config - (set-company-backend! 'java-mode '(company-emacs-eclim))) diff --git a/.config/emacs/modules/lang/java/+lsp.el b/.config/emacs/modules/lang/java/+lsp.el @@ -1,26 +0,0 @@ -;;; lang/java/+lsp.el -*- lexical-binding: t; -*- -;;;###if (and (modulep! +lsp) (not (modulep! :tools lsp +eglot))) - -(use-package! lsp-java - :after lsp-mode - :preface - (setq lsp-java-workspace-dir (concat doom-data-dir "java-workspace")) - (add-hook 'java-mode-local-vars-hook #'lsp! 'append) - :config - (when (modulep! :tools debugger +lsp) - (setq lsp-jt-root (concat lsp-java-server-install-dir "java-test/server/") - dap-java-test-runner (concat lsp-java-server-install-dir "test-runner/junit-platform-console-standalone.jar")))) - - -(use-package! dap-java - :when (modulep! :tools debugger +lsp) - :commands dap-java-run-test-class dap-java-debug-test-class - :init - (map! :after cc-mode ; where `java-mode' is defined - :map java-mode-map - :localleader - (:prefix ("t" . "Test") - :desc "Run test class or method" "t" #'+java/run-test - :desc "Run all tests in class" "a" #'dap-java-run-test-class - :desc "Debug test class or method" "d" #'+java/debug-test - :desc "Debug all tests in class" "D" #'dap-java-debug-test-class))) diff --git a/.config/emacs/modules/lang/java/+meghanada.el b/.config/emacs/modules/lang/java/+meghanada.el @@ -1,38 +0,0 @@ -;;; lang/java/+meghanada.el -*- lexical-binding: t; -*- -;;;###if (modulep! +meghanada) - -(use-package! meghanada - :hook (java-mode-local-vars . meghanada-mode) - :init - (setq meghanada-server-install-dir (concat doom-data-dir "meghanada-server/") - meghanada-use-company (modulep! :completion company) - meghanada-use-flycheck (modulep! :checkers syntax) - meghanada-use-eldoc t - meghanada-use-auto-start t) - - :config - (set-lookup-handlers! 'java-mode - :definition #'meghanada-jump-declaration - :references #'meghanada-reference) - - (defadvice! +java-meghanada-fail-gracefully-a (fn &rest args) - "Toggle `meghanada-mode'. Fail gracefully if java is unavailable." - :around #'meghanada-mode - (if (executable-find meghanada-java-path) - (apply fn args) - (message "Can't find %S binary. Is java installed? Aborting `meghanada-mode'." - meghanada-java-path))) - - (map! :localleader - :map java-mode-map - (:prefix ("r" . "refactor") - "ia" #'meghanada-import-all - "io" #'meghanada-optimize-import - "l" #'meghanada-local-variable - "f" #'meghanada-code-beautify) - (:prefix ("h" . "help") - "r" #'meghanada-reference - "t" #'meghanada-typeinfo) - (:prefix ("b" . "build") - "f" #'meghanada-compile-file - "p" #'meghanada-compile-project))) diff --git a/.config/emacs/modules/lang/java/README.org b/.config/emacs/modules/lang/java/README.org @@ -1,170 +0,0 @@ -#+title: :lang java -#+subtitle: The poster child for carpal tunnel syndrome -#+created: January 16, 2017 -#+since: 1.3 - -* Description :unfold: -This module adds [[https://www.java.com][Java]] support to Doom Emacs, including ~android-mode~ and -~groovy-mode~. - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +lsp :: - Enable LSP support for ~java-mode~. Requires [[doom-module::tools lsp]] and a langserver - (supports eclipse.jdt.ls). *Incompatible with [[doom-module:+meghanada]].* -- +meghanada :: - Enable [[doom-package:meghanada-mode]]. *Incompatible with [[doom-module:+lsp]].* -- +tree-sitter :: - Leverages tree-sitter for better syntax highlighting and structural text - editing. Requires [[doom-module::tools tree-sitter]]. - -** Packages -- [[doom-package:android-mode]] -- [[doom-package:groovy-mode]] -- [[doom-package:meghanada]] if [[doom-module:+meghanada]] -- if [[doom-module:+eclim]] - - [[doom-package:eclim]] - - [[doom-package:company-emacs-eclim]] if [[doom-module::completion company]] -- if [[doom-module:+lsp]] and not [[doom-module::tools lsp +eglot]] - - [[doom-package:lsp-java]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires: -- [[https://www.oracle.com/java/technologies/downloads/][Java SDK]] -- The LSP test runner requires [[doom-module::tools debugger +lsp]] (requires [[doom-package:dap-mode]]) - -** OpenJDK 11 -*** Ubuntu -#+begin-src sh -apt-get install openjdk-11-jdk-headless -#+end_src - -*** Fedora -#+begin_src sh -dnf install java-11-openjdk -#+end_src - -** Oracle JDK 11 -*** Ubuntu -#+begin_src sh -add-apt-repository ppa:linuxuprising/java -apt update -apt install oracle-java11-installer -apt install oracle-java11-set-default -#+end_src - -*** Fedora -#+begin_src sh -curl -O https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_linux-x64_bin.tar.gz -tar zxvf openjdk-11.0.2_linux-x64_bin.tar.gz -sudo mv jdk-11.0.2/ /usr/local/ -#+end_src - -Open =/etc/profile.d/jdk11.sh= as root and add: -#+begin_src sh -export JAVA_HOME=/usr/local/jdk-11.0.2 -export PATH=$PATH:$JAVA_HOME/bin -#+end_src - -Save the file and source it: -#+begin_src sh -source /etc/profile.d/jdk11.sh -java -version -#+end_src - -** Multiple Java Versions -It is common to need support for multiple Java versions. You can use a generic -tool like [[https://github.com/shyiko/jabba][jabba]] to install and manage multiple Java versions on any OS. - -To have a different version of Java per-project, it is recommended you use -[[https://github.com/direnv/direnv][direnv]] and [[doom-module::tools direnv]]; create a =.envrc= in the root of the project pointing -to the Java installation: -#+begin_src sh -PATH_add ~/.jabba/jdk/adopt@1.11.0-3 -JAVA_HOME=~/.jabba/jdk/adopt@1.11.0-3 -#+end_src - -And then run ~$ direnv allow .~ in the project directory. The [[doom-module::tools direnv]] -module will automatically source this environment before activating LSP servers. - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** [[doom-module:+lsp]] features -According to [[https://github.com/emacs-lsp/lsp-java]], you get: -- As you type reporting of parsing and compilation errors (via [[doom-package:flycheck]] or - [[doom-package:lsp-ui]]) -- Code completion ([[doom-package:company-lsp]] or complete-at-point) -- Javadoc hovers ([[doom-package:lsp-ui]]) -- Code actions ([[doom-package:lsp-ui]]) -- Code outline ([[doom-package:imenu]]) -- Code navigation ([[doom-package:xref]]) -- Code lens for references/implementations ([[doom-package:xref]]) -- Highlights -- Code formatting -- Maven pom.xml project support -- Limited Gradle support -- Visual debugger ([[doom-package:dap-mode]]) -- Test runner ([[doom-package:dap-mode]]) -- Project explorer integration ([[doom-package:treemacs]]) -- Integration with [[https://start.spring.io/][Spring Initializr]] - -** =+meghanada= features -According to [[https://github.com/mopemope/meghanada-emacs/]], you get: -- Auto-update server module -- [[https://gradle.org/][Gradle]] and [[http://maven.apache.org/][Maven]] and Eclipse project support -- No need build tool's plugin -- Run build tool task -- Compile your project -- Syntax check and analyze java source ([[doom-package:flycheck-meghanada]]) -- Support =Generic Types= -- Code completion with [[doom-package:company-mode]] ([[doom-package:company-meghanada]]) -- Optimize import and sort -- Jump declaration -- Run [[http://www.junit.org/][JUnit]] test (include test runner) -- Diagnostic reporting with [[doom-package:flycheck]] ([[doom-package:flycheck-meghanada]]) -- Show symbol's type info with [[doom-package:eldoc]] -- Search references -- Full-featured text search - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** [[doom-module:+lsp]] -Install the eclipse server by executing ~M-x lsp-install-server~ and selecting -=jdtls=. After that any newly opened =java= files should start the LSP server -automatically. - -To update the server, perform ~SPC u M-x lsp-install-server~. - -Note that if you change Java version you may need to remove the LSP server and -install it again. You can do this with ~M-x +lsp/uninstall-server~ followed by -~M-x lsp-install-server~. - -Enable the [[doom-module::tools debugger +lsp]] module to get test runner support. - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/java/autoload/java.el b/.config/emacs/modules/lang/java/autoload/java.el @@ -1,87 +0,0 @@ -;;; lang/java/autoload/java.el -*- lexical-binding: t; -*- - -;; yasnippet defuns -;;;###autoload -(defun +java-android-mode-is-layout-file () - (and android-mode - (eq major-mode 'nxml-mode) - (string-equal (file-name-base (directory-file-name default-directory)) "layout"))) - -;;;###autoload -(defun +java-android-mode-in-tags (&rest tags) - (cl-find (android-mode-tag-name) tags)) - -;;;###autoload -(defun +java-android-mode-tag-name () - (save-excursion - (let (beg end) - (nxml-backward-up-element) - (evil-forward-word-begin) - (setq beg (point)) - (evil-forward-WORD-end) - (setq end (1+ (point))) - (buffer-substring-no-properties beg end)))) - -;;;###autoload -(defun +java-android-mode-maybe-h () - "Enable `android-mode' if this looks like an android project. - -It determines this by the existence of AndroidManifest.xml or -src/main/AndroidManifest.xml." - (when (project-file-exists-p! (or "AndroidManifest.xml" - "src/main/AndroidManifest.xml")) - (android-mode +1))) - -;;;###autoload -(defun +java-current-package () - "Converts the current file's path into a namespace. - -For example: ~/some/project/src/net/lissner/game/MyClass.java -Is converted to: net.lissner.game - -It does this by ignoring everything before the nearest package root (see -`+java-project-package-roots' to control what this function considers a package -root)." - (cond ((doom-special-buffer-p (current-buffer)) - "{PackageName}") - ((not (eq major-mode 'java-mode)) - (user-error "Not in java-mode")) - ((when-let (project-root (doom-project-root)) - (let* ((project-root (file-truename project-root)) - (file-path - (file-name-sans-extension - (file-truename (or buffer-file-name - default-directory)))) - (src-root - (cl-loop for root in +java-project-package-roots - if (and (stringp root) - (locate-dominating-file file-path root)) - return (file-name-directory (file-relative-name file-path (expand-file-name root it))) - if (and (integerp root) - (> root 0) - (let* ((parts (split-string (file-relative-name file-path project-root) "/")) - (fixed-parts (reverse (nbutlast (reverse parts) root)))) - (when fixed-parts - (string-join fixed-parts "/")))) - return it))) - (when src-root - (string-remove-suffix "." (replace-regexp-in-string "/" "." src-root)))))) - ((user-error "Can't deduce package name")))) - -;;;###autoload -(defun +java-current-class () - "Get the class name for the current file." - (cond ((doom-special-buffer-p (current-buffer)) - "{ClassName}") - ((not (eq major-mode 'java-mode)) - (user-error "Not in java-mode")) - (buffer-file-name - (file-name-sans-extension (file-name-base (buffer-file-name)))) - ((user-error "Can't deduce the class name")))) - -;;;###autoload -(defun +java/open-groovy-repl () - "Open a Groovy REPL." - (interactive) - (call-interactively #'run-groovy) - (get-buffer groovy-buffer)) diff --git a/.config/emacs/modules/lang/java/autoload/lsp.el b/.config/emacs/modules/lang/java/autoload/lsp.el @@ -1,22 +0,0 @@ -;;; lang/java/autoload/lsp.el -*- lexical-binding: t; -*- -;;;###if (modulep! :tools debugger +lsp) - -;;;###autoload -(defun +java/run-test () - "Runs test at point. -If in a method, runs the test method, otherwise runs the entire test class." - (interactive) - (require 'dap-java) - (condition-case nil - (dap-java-run-test-method) - (user-error (dap-java-run-test-class)))) - -;;;###autoload -(defun +java/debug-test () - "Runs test at point in a debugger. -If in a method, runs the test method, otherwise runs the entire test class." - (interactive) - (require 'dap-java) - (condition-case nil - (call-interactively #'dap-java-debug-test-method) - (user-error (call-interactively #'dap-java-debug-test-class)))) diff --git a/.config/emacs/modules/lang/java/config.el b/.config/emacs/modules/lang/java/config.el @@ -1,54 +0,0 @@ -;;; lang/java/config.el -*- lexical-binding: t; -*- - -(defvar +java-project-package-roots (list "java/" "test/" "main/" "src/" 1) - "A list of relative directories (strings) or depths (integer) used by -`+java-current-package' to delimit the namespace from the current buffer's full -file path. Each root is tried in sequence until one is found. - -If a directory is encountered in the file path, everything before it (including -it) will be ignored when converting the path into a namespace. - -An integer depth is how many directories to pop off the start of the relative -file path (relative to the project root). e.g. - -Say the absolute path is ~/some/project/src/java/net/lissner/game/MyClass.java -The project root is ~/some/project -If the depth is 1, the first directory in src/java/net/lissner/game/MyClass.java - is removed: java.net.lissner.game. -If the depth is 2, the first two directories are removed: net.lissner.game.") - -(after! projectile - (pushnew! projectile-project-root-files "gradlew" "build.gradle")) - - -;; -;;; java-mode - -(add-hook 'java-mode-hook #'rainbow-delimiters-mode) - -(cond ((modulep! +meghanada) (load! "+meghanada")) - ((modulep! :tools lsp +eglot)) - ((modulep! +lsp) (load! "+lsp"))) - -(when (modulep! +tree-sitter) - (add-hook 'java-mode-local-vars-hook #'tree-sitter! 'append)) - - -;; -;;; Common packages - -(use-package! android-mode - :commands android-mode - :init - (add-hook! '(java-mode-hook groovy-mode-hook nxml-mode-hook) - #'+java-android-mode-maybe-h) - :config - (set-yas-minor-mode! 'android-mode)) - - -(use-package! groovy-mode - :mode "\\.g\\(?:radle\\|roovy\\)$" - :config - (set-docsets! 'groovy-mode "Groovy" "Groovy_JDK") - (set-eval-handler! 'groovy-mode "groovy") - (set-repl-handler! 'groovy-mode #'+java/open-groovy-repl)) diff --git a/.config/emacs/modules/lang/java/doctor.el b/.config/emacs/modules/lang/java/doctor.el @@ -1,17 +0,0 @@ -;; -*- lexical-binding: t; no-byte-compile: t; -*- -;;; lang/java/doctor.el - -(assert! (or (not (modulep! +lsp)) - (modulep! :tools lsp)) - "This module requires (:tools lsp)") - -(assert! (or (not (modulep! +tree-sitter)) - (modulep! :tools tree-sitter)) - "This module requires (:tools tree-sitter)") - -(unless (executable-find "javac") - (warn! "Couldn't find the javac executable, are you sure the JDK is installed?")) - -(when (modulep! :editor format) - (unless (executable-find "clang-format") - (warn! "Couldn't find clang-format. Code formatting will not work."))) diff --git a/.config/emacs/modules/lang/java/packages.el b/.config/emacs/modules/lang/java/packages.el @@ -1,17 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/java/packages.el - -(package! android-mode :pin "d5332e339a1f5e30559a53feffb8442ca79265d6") -(package! groovy-mode :pin "c612ac1e9f742856914ad6e8eb9e9dc169f489ab") - -(when (modulep! +meghanada) - (package! meghanada :pin "59c46cabb7eee715fe810ce59424934a1286df84")) - -(when (modulep! +eclim) - (package! eclim :pin "222ddd48fcf0ee01592dec77c58e0cf3f2ea1100") - (when (modulep! :completion company) - (package! company-emacs-eclim :pin "222ddd48fcf0ee01592dec77c58e0cf3f2ea1100"))) - -(when (modulep! +lsp) - (unless (modulep! :tools lsp +eglot) - (package! lsp-java :pin "dbe448a886e2f4fb5d3a616f4499adbe643ba7a5"))) diff --git a/.config/emacs/modules/lang/javascript/README.org b/.config/emacs/modules/lang/javascript/README.org @@ -1,163 +0,0 @@ -#+title: :lang javascript -#+subtitle: all(hope(abandon(ye(who(enter(here)))))) -#+created: January 16, 2017 -#+since: 1.3 - -* Description :unfold: -This module adds [[https://www.javascript.com/][JavaScript]] and [[https://www.typescriptlang.org/][TypeScript]] support to Doom Emacs. - -- Code completion ([[doom-package:tide]]) -- REPL support ([[doom-package:nodejs-repl]]) -- Refactoring commands ([[doom-package:js2-refactor]]) -- Syntax checking ([[doom-package:flycheck]]) -- Browser code injection with [[doom-package:skewer-mode]] -- Coffeescript & JSX support -- Jump-to-definitions and references support ([[doom-package:xref]]) - -** Maintainers -- [[doom-user:][@elken]] -- [[doom-user:][@hlissner]] -- [[doom-user:][@iyefrat]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +lsp :: - Enable LSP support for ~js2-mode~, ~rjsx-mode~, JS in ~web-mode~, and - ~typescript-mode~. Requires [[doom-module::tools lsp]] and a langserver (supports ts-ls and - deno-ls). -- +tree-sitter :: - Leverages tree-sitter for better syntax highlighting and structural text - editing. Requires [[doom-module::tools tree-sitter]]. - -** Packages -- [[doom-package:js2-refactor]] -- [[doom-package:nodejs-repl]] -- [[doom-package:npm-mode]] -- [[doom-package:rjsx-mode]] -- [[doom-package:skewer-mode]] (DEPRECATED) -- [[doom-package:tide]] -- [[doom-package:typescript-mode]] -- [[doom-package:xref-js2]] if [[doom-module::tools lookup]] - -** TODO Hacks -#+begin_quote - 🔨 This module's hacks haven't been documented yet. [[doom-contrib-module:][Document them?]] -#+end_quote - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires [[https://nodejs.org/en/][NodeJS]] and one of [[https://www.npmjs.com/][NPM]] or [[https://yarnpkg.com/][Yarn]] in your =$PATH=. - -- MacOS: ~$ brew install node~ -- Arch Linux: ~$ pacman --needed --noconfirm -S nodejs npm~ -- openSUSE: ~$ zypper install nodejs npm~ - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -~rjsx-mode~ is used for all javascript buffers. - -** Commands -*** rjsx-mode -| command | key / ex command | description | -|----------------------------------+------------------+------------------------------------------------------------| -| ~+javascript/open-repl~ | ~:repl~ | Open the NodeJS REPL (or send the current selection to it) | -| ~+javascript/skewer-this-buffer~ | [[kbd:][<localleader> S]] | Attaches a browser to the current buffer | - -*** Tide -| command | key / ex command | description | -|-------------------------+---------------------+------------------------| -| ~tide-restart-server~ | [[kbd:][<localleader> R]] | Restart tide server | -| ~tide-reformat~ | [[kbd:][<localleader> f]] | Reformat region | -| ~tide-rename-symbol~ | [[kbd:][<localleader> r r s]] | Rename symbol at point | -| ~tide-organize-imports~ | [[kbd:][<localleader> r o i]] | Organize imports | - -*** Refactoring (js2-refactor-mode) -| command | key / ex command | description | -|---------------------------------------------------+---------------------+--------------------------------------------------------------------------------------------------------------------| -| ~js2r-expand-node-at-point~ | [[kbd:][<localleader> r e e]] | Expand bracketed list according to node type at point | -| ~js2r-contract-node-at-point~ | [[kbd:][<localleader> r c c]] | Contract bracketed list according to node type at point | -| ~js2r-extract-function~ | [[kbd:][<localleader> r e f]] | Extracts the marked expressions out into a new named function. | -| ~js2r-extract-method~ | [[kbd:][<localleader> r e m]] | Extracts the marked expressions out into a new named method in an object literal. | -| ~js2r-toggle-function-expression-and-declaration~ | [[kbd:][<localleader> r t f]] | Toggle between function name() {} and var name = function (); | -| ~js2r-toggle-arrow-function-and-expression~ | [[kbd:][<localleader> r t a]] | Toggle between function expression to arrow function. | -| ~js2r-toggle-function-async~ | [[kbd:][<localleader> r t s]] | Toggle between an async and a regular function. | -| ~js2r-introduce-parameter~ | [[kbd:][<localleader> r i p]] | Changes the marked expression to a parameter in a local function. | -| ~js2r-localize-parameter~ | [[kbd:][<localleader> r l p]] | Changes a parameter to a local var in a local function. | -| ~js2r-wrap-buffer-in-iife~ | [[kbd:][<localleader> r w i]] | Wraps the entire buffer in an immediately invoked function expression | -| ~js2r-inject-global-in-iife~ | [[kbd:][<localleader> r i g]] | Creates a shortcut for a marked global by injecting it in the wrapping immediately invoked function expression | -| ~js2r-add-to-globals-annotation~ | [[kbd:][<localleader> r a g]] | Creates a /*global */ annotation if it is missing, and adds the var at point to it. | -| ~js2r-extract-var~ | [[kbd:][<localleader> r e v]] | Takes a marked expression and replaces it with a var. | -| ~js2r-extract-let~ | [[kbd:][<localleader> r e l]] | Similar to extract-var but uses a let-statement. | -| ~js2r-extract-const~ | [[kbd:][<localleader> r e c]] | Similar to extract-var but uses a const-statement. | -| ~js2r-inline-var~ | [[kbd:][<localleader> r i v]] | Replaces all instances of a variable with its initial value. | -| ~js2r-rename-var~ | [[kbd:][<localleader> r r v]] | Renames the variable on point and all occurrences in its lexical scope. | -| ~js2r-var-to-this~ | [[kbd:][<localleader> r v t]] | Changes local var a to be this.a instead. | -| ~js2r-arguments-to-object~ | [[kbd:][<localleader> r a o]] | Replaces arguments to a function call with an object literal of named arguments. | -| ~js2r-ternary-to-if~ | [[kbd:][<localleader> r 3 i]] | Converts ternary operator to if-statement. | -| ~js2r-split-var-declaration~ | [[kbd:][<localleader> r s v]] | Splits a var with multiple vars declared, into several var statements. | -| ~js2r-split-string~ | [[kbd:][<localleader> r s s]] | Splits a string. | -| ~js2r-string-to-template~ | [[kbd:][<localleader> r s t]] | Converts a string into a template string. | -| ~js2r-unwrap~ | [[kbd:][<localleader> r u w]] | Replaces the parent statement with the selected region. | -| ~js2r-log-this~ | [[kbd:][<localleader> r l t]] | Adds a console.log() statement for what is at point (or region). With a prefix argument, use JSON pretty-printing. | -| ~js2r-debug-this~ | [[kbd:][<localleader> r d t]] | Adds a debug() statement for what is at point (or region). | -| ~js2r-forward-slurp~ | [[kbd:][<localleader> r s l]] | Moves the next statement into current function, if-statement, for-loop or while-loop. | -| ~js2r-forward-barf~ | [[kbd:][<localleader> r b a]] | Moves the last child out of current function, if-statement, for-loop or while-loop. | -| ~js2r-kill~ | [[kbd:][<localleader> r k]] | Kills to the end of the line, but does not cross semantic boundaries. | - -*** skewer-mode -**** general -| command | key / ex command | description | -|-------------------------------+-------------------+---------------------------------------| -| ~skewer-eval-last-expression~ | [[kbd:][<localleader> s E]] | Evaluate last expression | -| ~skewer-eval-defun~ | [[kbd:][<localleader> s e]] | Evaluate function definition at point | -| ~skewer-load-buffer~ | [[kbd:][<localleader> s f]] | Load buffer into REPL | - -**** css -| command | key / ex command | description | -|---------------------------------------+-------------------+-------------------------------| -| ~skewer-css-eval-current-declaration~ | [[kbd:][<localleader> s e]] | Evaluate declaration at point | -| ~skewer-css-eval-current-rule~ | [[kbd:][<localleader> s r]] | Evaluate rule at point | -| ~skewer-css-eval-buffer~ | [[kbd:][<localleader> s b]] | Evaluate buffer | -| ~skewer-css-clear-all~ | [[kbd:][<localleader> s c]] | Clear all rules | - -**** html -| command | key / ex command | description | -|------------------------+-------------------+-----------------------| -| ~skewer-html-eval-tag~ | [[kbd:][<localleader> s e]] | Evaluate tag at point | - -*** npm-mode -| command | key / ex command | description | -|---------------------------------+-------------------+------------------------------------------------------------------| -| ~npm-mode-npm-init~ | [[kbd:][<localleader> n n]] | Initialize npm project | -| ~npm-mode-npm-install~ | [[kbd:][<localleader> n i]] | Install npm package | -| ~npm-mode-npm-install-save~ | [[kbd:][<localleader> n s]] | Install npm package and save to package.json | -| ~npm-mode-npm-install-save-dev~ | [[kbd:][<localleader> n d]] | Install npm package and save to package.json as a dev dependency | -| ~npm-mode-npm-uninstall~ | [[kbd:][<localleader> n u]] | Uninstall npm package | -| ~npm-mode-npm-list~ | [[kbd:][<localleader> n l]] | List npm packages | -| ~npm-mode-npm-run~ | [[kbd:][<localleader> n r]] | Run npm task | -| ~npm-mode-visit-project-file~ | [[kbd:][<localleader> n v]] | Find file in npm project | - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/javascript/autoload.el b/.config/emacs/modules/lang/javascript/autoload.el @@ -1,129 +0,0 @@ -;;; lang/javascript/autoload.el -*- lexical-binding: t; -*- - -(defvar +javascript-npm-conf (make-hash-table :test 'equal)) - -;;;###autoload -(defun +javascript-npm-conf (&optional project-root refresh-p) - "Retrieves an alist of this project's 'package.json'. If REFRESH-P is non-nil -ignore the cache." - (let ((project-root (or project-root (doom-project-root)))) - (or (and (not refresh-p) - (gethash project-root +javascript-npm-conf)) - (let ((package-file (expand-file-name "package.json" project-root))) - (when-let (json (and (file-exists-p package-file) - (require 'json) - (json-read-file package-file))) - (puthash project-root json +javascript-npm-conf)))))) - -;;;###autoload -(defun +javascript-npm-dep-p (packages &optional project-root refresh-p) - (when-let (data (and (bound-and-true-p +javascript-npm-mode) - (+javascript-npm-conf project-root refresh-p))) - (let ((deps (append (cdr (assq 'dependencies data)) - (cdr (assq 'devDependencies data))))) - (cond ((listp packages) - (funcall (if (eq (car packages) 'and) - #'cl-every - #'cl-some) - (lambda (pkg) (assq pkg deps)) - (if (listp packages) packages (list packages)))) - ((symbolp packages) - (assq packages deps)) - (t (error "Expected a package symbol or list, got %s" packages)))))) - -;;;###autoload -(defun +javascript-add-npm-path-h () - "Add node_modules/.bin to `exec-path'." - (when-let ((node-modules-parent (locate-dominating-file default-directory "node_modules/")) - (node-modules-dir (expand-file-name "node_modules/.bin/" node-modules-parent))) - (make-local-variable 'exec-path) - (add-to-list 'exec-path node-modules-dir) - (doom-log ":lang:javascript: add %s to $PATH" (expand-file-name "node_modules/" node-modules-parent)))) - - -;; -;; Commands - -;;;###autoload -(defun +javascript/open-repl () - "Open a Javascript REPL. Meaning either `skewer-repl', if any of the -skewer-*-mode's are enabled, or `nodejs-repl' otherwise." - (interactive) - (call-interactively - (if (and (featurep 'skewer-mode) - (or (bound-and-true-p skewer-mode) - (bound-and-true-p skewer-css-mode) - (bound-and-true-p skewer-html-mode))) - #'skewer-repl - #'nodejs-repl)) - (current-buffer)) - -;;;###autoload -(defun +javascript/skewer-this-buffer () - "Toggle a globalized skewer-mode, attaching an external browser (once), -initiating an internal httpd server (once) and enabling the appropriate -skewer-mode for the current buffer. - -Run this for any buffer you want to skewer." - (interactive) - (when (bound-and-true-p impatient-mode) - (error "Skewer-mode isn't compatible with impatient mode")) - (require 'skewer-mode) - (unless (process-status "httpd") - (run-skewer)) - (pcase major-mode - ((or 'css-mode 'scss-mode 'less-css-mode) - (unless (bound-and-true-p skewer-css-mode) - (skewer-css-mode +1))) - ((or 'web-mode 'html-mode) - (unless (bound-and-true-p skewer-html-mode) - (skewer-html-mode +1))) - ('js2-mode - (unless (bound-and-true-p skewer-mode) - (skewer-mode +1))) - (_ (error "Invalid mode %s" major-mode)))) - -;;;###autoload -(defun +javascript/skewer-cleanup () - "Disable skewer-mode globally and disable the httpd server." - (interactive) - (when (process-status "httpd") - (httpd-stop)) - (dolist (buf (buffer-list)) - (with-current-buffer buf - (if (bound-and-true-p skewer-mode) - (skewer-mode -1)) - (if (bound-and-true-p skewer-css-mode) - (skewer-css-mode -1)) - (if (bound-and-true-p skewer-html-mode) - (skewer-html-mode -1))))) - - -;; -;; Hooks - -;;;###autoload -(defun +javascript-cleanup-tide-processes-h () - "Clean up dangling tsserver processes if there are no more buffers with -`tide-mode' active that belong to that server's project." - (when tide-mode - (unless (cl-loop with project-name = (tide-project-name) - for buf in (delq (current-buffer) (buffer-list)) - if (and (buffer-local-value 'tide-mode buf) - (with-current-buffer buf - (string= (tide-project-name) project-name))) - return buf) - (kill-process (tide-current-server))))) - - -;; -;; Advice - -;;;###autoload -(defun +javascript-tide-project-root-a () - "Resolve to `doom-project-root' if `tide-project-root' fails." - (or tide-project-root - (or (locate-dominating-file default-directory "tsconfig.json") - (locate-dominating-file default-directory "jsconfig.json")) - (or (doom-project-root) - default-directory))) diff --git a/.config/emacs/modules/lang/javascript/config.el b/.config/emacs/modules/lang/javascript/config.el @@ -1,329 +0,0 @@ -;;; lang/javascript/config.el -*- lexical-binding: t; -*- - -(after! projectile - (pushnew! projectile-project-root-files "package.json") - (pushnew! projectile-globally-ignored-directories "^node_modules$" "^flow-typed$")) - - -;; -;;; Major modes - -(dolist (feature '(rjsx-mode - typescript-mode - web-mode - (nodejs-repl-mode . nodejs-repl))) - (let ((pkg (or (cdr-safe feature) feature)) - (mode (or (car-safe feature) feature))) - (with-eval-after-load pkg - (set-docsets! mode "JavaScript" - "AngularJS" "Backbone" "BackboneJS" "Bootstrap" "D3JS" "EmberJS" "Express" - "ExtJS" "JQuery" "JQuery_Mobile" "JQuery_UI" "KnockoutJS" "Lo-Dash" - "MarionetteJS" "MomentJS" "NodeJS" "PrototypeJS" "React" "RequireJS" - "SailsJS" "UnderscoreJS" "VueJS" "ZeptoJS") - (set-ligatures! mode - ;; Functional - :def "function" - :lambda "() =>" - :composition "compose" - ;; Types - :null "null" - :true "true" :false "false" - ;; Flow - :not "!" - :and "&&" :or "||" - :for "for" - :return "return" - ;; Other - :yield "import")))) - - -(use-package! rjsx-mode - :mode "\\.[mc]?js\\'" - :mode "\\.es6\\'" - :mode "\\.pac\\'" - :interpreter "node" - :hook (rjsx-mode . rainbow-delimiters-mode) - :init - ;; Parse node stack traces in the compilation buffer - (after! compilation - (add-to-list 'compilation-error-regexp-alist 'node) - (add-to-list 'compilation-error-regexp-alist-alist - '(node "^[[:blank:]]*at \\(.*(\\|\\)\\(.+?\\):\\([[:digit:]]+\\):\\([[:digit:]]+\\)" - 2 3 4))) - :config - (set-repl-handler! 'rjsx-mode #'+javascript/open-repl) - (set-electric! 'rjsx-mode :chars '(?\} ?\) ?. ?:)) - - (setq js-chain-indent t - ;; These have become standard in the JS community - js2-basic-offset 2 - ;; 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 - ;; Flycheck provides these features, so disable them: conflicting with - ;; the eslint settings. - js2-strict-missing-semi-warning nil - ;; maximum fontification - js2-highlight-level 3 - js2-idle-timer-delay 0.15) - - (setq-hook! 'rjsx-mode-hook - ;; Indent switch-case another step - js-switch-indent-offset js2-basic-offset) - - (use-package! xref-js2 - :when (modulep! :tools lookup) - :init - (setq xref-js2-search-program 'rg) - (set-lookup-handlers! 'rjsx-mode - :xref-backend #'xref-js2-xref-backend)) - - ;; HACK `rjsx-electric-gt' relies on js2's parser to tell it when the cursor - ;; is in a self-closing tag, so that it can insert a matching ending tag - ;; at point. The parser doesn't run immediately however, so a fast typist - ;; can outrun it, causing tags to stay unclosed, so force it to parse: - (defadvice! +javascript-reparse-a (n) - ;; if n != 1, rjsx-electric-gt calls rjsx-maybe-reparse itself - :before #'rjsx-electric-gt - (if (= n 1) (rjsx-maybe-reparse)))) - - -(use-package! typescript-mode - :hook (typescript-mode . rainbow-delimiters-mode) - :hook (typescript-tsx-mode . rainbow-delimiters-mode) - :init - (when (modulep! :lang web) - (autoload 'typescript-tsx-mode "typescript-mode" nil t)) - - ;; REVIEW We associate TSX files with `typescript-tsx-mode' derived from - ;; `web-mode' because `typescript-mode' does not officially support - ;; JSX/TSX. See emacs-typescript/typescript.el#4 - (add-to-list 'auto-mode-alist - (cons "\\.tsx\\'" - (if (modulep! :lang web) - #'typescript-tsx-mode - #'typescript-mode))) - - (when (modulep! :checkers syntax) - (after! flycheck - (flycheck-add-mode 'javascript-eslint 'web-mode) - (flycheck-add-mode 'javascript-eslint 'typescript-mode) - (flycheck-add-mode 'javascript-eslint 'typescript-tsx-mode) - (flycheck-add-mode 'typescript-tslint 'typescript-tsx-mode) - (unless (modulep! +lsp) - (after! tide - (flycheck-add-next-checker 'typescript-tide '(warning . javascript-eslint) 'append) - (flycheck-add-mode 'typescript-tide 'typescript-tsx-mode))) - (add-hook! 'typescript-tsx-mode-hook - (defun +javascript-disable-tide-checkers-h () - (pushnew! flycheck-disabled-checkers - 'javascript-jshint - 'tsx-tide - 'jsx-tide))))) - :config - (when (fboundp 'web-mode) - (define-derived-mode typescript-tsx-mode web-mode "TypeScript-TSX") - (when (modulep! +lsp) - (after! lsp-mode - (add-to-list 'lsp--formatting-indent-alist '(typescript-tsx-mode . typescript-indent-level)))) - (when (modulep! +tree-sitter) - (after! evil-textobj-tree-sitter - (pushnew! evil-textobj-tree-sitter-major-mode-language-alist '(typescript-tsx-mode . "tsx"))) - (after! tree-sitter - (pushnew! tree-sitter-major-mode-language-alist '(typescript-tsx-mode . tsx))) - ;; HACK: the tsx grammer doesn't work with the hightlighting provided by - ;; font-lock-keywords. See emacs-tree-sitter/tree-sitter-langs#23 - (setq-hook! 'typescript-tsx-mode-hook - tree-sitter-hl-use-font-lock-keywords nil))) - - (set-docsets! '(typescript-mode typescript-tsx-mode) - :add "TypeScript" "AngularTS") - (set-electric! '(typescript-mode typescript-tsx-mode) - :chars '(?\} ?\)) - :words '("||" "&&")) - ;; HACK Fixes comment continuation on newline - (autoload 'js2-line-break "js2-mode" nil t) - (setq-hook! 'typescript-mode-hook - comment-line-break-function #'js2-line-break - - ;; Most projects use either eslint, prettier, .editorconfig, or tsf in order - ;; to specify indent level and formatting. In the event that no - ;; project-level config is specified (very rarely these days), the community - ;; default is 2, not 4. However, respect what is in tsfmt.json if it is - ;; present in the project - typescript-indent-level - (or (and (bound-and-true-p tide-mode) - (plist-get (tide-tsfmt-options) :indentSize)) - typescript-indent-level) - - ;; Fix #5556: expand .x to className="x" instead of class="x", if - ;; `emmet-mode' is used. - emmet-expand-jsx-className? t)) - - -;; -;;; Tools - -(when (modulep! +tree-sitter) - (add-hook! '(js2-mode-local-vars-hook - typescript-mode-local-vars-hook - typescript-tsx-mode-local-vars-hook - rjsx-mode-local-vars-hook) - :append #'tree-sitter!)) - -(add-hook! '(typescript-mode-local-vars-hook - typescript-tsx-mode-local-vars-hook - web-mode-local-vars-hook - rjsx-mode-local-vars-hook) - (defun +javascript-init-lsp-or-tide-maybe-h () - "Start `lsp' or `tide' in the current buffer. - -LSP will be used if the +lsp flag is enabled for :lang javascript AND if the -current buffer represents a file in a project. - -If LSP fails to start (e.g. no available server or project), then we fall back -to tide." - (let ((buffer-file-name (buffer-file-name (buffer-base-buffer)))) - (when (derived-mode-p 'js-mode 'typescript-mode 'typescript-tsx-mode) - (if (null buffer-file-name) - ;; necessary because `tide-setup' and `lsp' will error if not a - ;; file-visiting buffer - (add-hook 'after-save-hook #'+javascript-init-lsp-or-tide-maybe-h - nil 'local) - (or (if (modulep! +lsp) (lsp!)) - ;; fall back to tide - (if (executable-find "node") - (and (require 'tide nil t) - (progn (tide-setup) tide-mode)) - (ignore - (doom-log "Couldn't start tide because 'node' is missing")))) - (remove-hook 'after-save-hook #'+javascript-init-lsp-or-tide-maybe-h - 'local)))))) - - -(use-package! tide - :hook (tide-mode . tide-hl-identifier-mode) - :config - (set-company-backend! 'tide-mode 'company-tide) - ;; navigation - (set-lookup-handlers! 'tide-mode :async t - :xref-backend #'xref-tide-xref-backend - :documentation #'tide-documentation-at-point) - (set-popup-rule! "^\\*tide-documentation" :quit t) - - (setq tide-completion-detailed t - tide-always-show-documentation t - ;; Fix #1792: by default, tide ignores payloads larger than 100kb. This - ;; is too small for larger projects that produce long completion lists, - ;; so we up it to 512kb. - tide-server-max-response-length 524288 - ;; We'll handle it - tide-completion-setup-company-backend nil) - - ;; Resolve to `doom-project-root' if `tide-project-root' fails - (advice-add #'tide-project-root :override #'+javascript-tide-project-root-a) - - ;; Cleanup tsserver when no tide buffers are left - (add-hook! 'tide-mode-hook - (add-hook 'kill-buffer-hook #'+javascript-cleanup-tide-processes-h - nil 'local)) - - ;; Eldoc is activated too soon and disables itself, thinking there is no eldoc - ;; support in the current buffer, so we must re-enable it later once eldoc - ;; support exists. It is set *after* tide-mode is enabled, so enabling it on - ;; `tide-mode-hook' is too early, so... - (advice-add #'tide-setup :after #'eldoc-mode) - - (map! :localleader - :map tide-mode-map - "R" #'tide-restart-server - "f" #'tide-format - "rrs" #'tide-rename-symbol - "roi" #'tide-organize-imports)) - - -(use-package! js2-refactor - :hook ((js2-mode rjsx-mode) . js2-refactor-mode) - :init - (map! :after js2-mode - :map js2-mode-map - :localleader - (:prefix ("r" . "refactor") - (:prefix ("a" . "add/arguments")) - (:prefix ("b" . "barf")) - (:prefix ("c" . "contract")) - (:prefix ("d" . "debug")) - (:prefix ("e" . "expand/extract")) - (:prefix ("i" . "inject/inline/introduce")) - (:prefix ("l" . "localize/log")) - (:prefix ("o" . "organize")) - (:prefix ("r" . "rename")) - (:prefix ("s" . "slurp/split/string")) - (:prefix ("t" . "toggle")) - (:prefix ("u" . "unwrap")) - (:prefix ("v" . "var")) - (:prefix ("w" . "wrap")) - (:prefix ("3" . "ternary")))) - :config - (when (modulep! :editor evil +everywhere) - (add-hook 'js2-refactor-mode-hook #'evil-normalize-keymaps) - (let ((js2-refactor-mode-map (evil-get-auxiliary-keymap js2-refactor-mode-map 'normal t t))) - (js2r-add-keybindings-with-prefix (format "%s r" doom-localleader-key))))) - - -;;;###package skewer-mode -(map! :localleader - (:after js2-mode - :map js2-mode-map - "S" #'+javascript/skewer-this-buffer - :prefix ("s" . "skewer")) - :prefix "s" - (:after skewer-mode - :map skewer-mode-map - "E" #'skewer-eval-last-expression - "e" #'skewer-eval-defun - "f" #'skewer-load-buffer) - - (:after skewer-css - :map skewer-css-mode-map - "e" #'skewer-css-eval-current-declaration - "r" #'skewer-css-eval-current-rule - "b" #'skewer-css-eval-buffer - "c" #'skewer-css-clear-all) - - (:after skewer-html - :map skewer-html-mode-map - "e" #'skewer-html-eval-tag)) - - -;;;###package npm-mode -(use-package! npm-mode - :hook ((js-mode typescript-mode) . npm-mode) - :config - (map! :localleader - (:map npm-mode-keymap - "n" npm-mode-command-keymap) - (:after js2-mode - :map js2-mode-map - :prefix ("n" . "npm")))) - - -;; -;;; Projects - -(def-project-mode! +javascript-npm-mode - :modes '(html-mode - css-mode - web-mode - markdown-mode - js-mode ; includes js2-mode and rjsx-mode - json-mode - typescript-mode - solidity-mode) - :when (locate-dominating-file default-directory "package.json") - :add-hooks '(+javascript-add-npm-path-h npm-mode)) - -(def-project-mode! +javascript-gulp-mode - :when (locate-dominating-file default-directory "gulpfile.js")) diff --git a/.config/emacs/modules/lang/javascript/doctor.el b/.config/emacs/modules/lang/javascript/doctor.el @@ -1,10 +0,0 @@ -;; -*- lexical-binding: t; no-byte-compile: t; -*- -;;; lang/javascript/doctor.el - -(assert! (or (not (modulep! +lsp)) - (modulep! :tools lsp)) - "This module requires (:tools lsp)") - -(assert! (or (not (modulep! +tree-sitter)) - (modulep! :tools tree-sitter)) - "This module requires (:tools tree-sitter)") diff --git a/.config/emacs/modules/lang/javascript/packages.el b/.config/emacs/modules/lang/javascript/packages.el @@ -1,19 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/javascript/packages.el - -;; Major modes -(package! rjsx-mode :pin "b697fe4d92cc84fa99a7bcb476f815935ea0d919") -(package! typescript-mode :pin "4fcb4594819caf472ae42ea068a1c7795cf07f46") - -;; Tools -(package! js2-refactor :pin "a0977c4ce1918cc266db9d6cd7a2ab63f3a76b9a") -(package! npm-mode :pin "3ee7c0bad5b7a041d4739ef3aaa06a3dc764e5eb") - -;; Eval -(package! nodejs-repl :pin "3b841055cad00f442e4a9159b1056f59411b6646") -(package! skewer-mode :pin "e5bed351939c92a1f788f78398583c2f83f1bb3c") - -;; Programming environment -(package! tide :pin "29475d9eee26f4101322209e9b6b199df5386094") -(when (modulep! :tools lookup) - (package! xref-js2 :pin "fd6b723e7f1f9793d189a815e1904364dc026b03")) diff --git a/.config/emacs/modules/lang/json/README.org b/.config/emacs/modules/lang/json/README.org @@ -1,56 +0,0 @@ -#+title: :lang json -#+subtitle: At least it ain't XML -#+created: April 23, 2020 -#+since: 21.12.0 - -* Description :unfold: -This module adds [[https://www.json.org/json-en.html][JSON]] support to Doom Emacs. - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +lsp :: - Enable LSP support for ~json-mode~. Requires [[doom-module::tools lsp]] and a langserver - (supports [[https://github.com/vscode-langservers/vscode-json-languageserver][vscode-json-languageserver]]). -- +tree-sitter :: - Leverages tree-sitter for better syntax highlighting and structural text - editing. Requires [[doom-module::tools tree-sitter]]. - -** Packages -- [[doom-package:counsel-jq]] if [[doom-module::completion ivy]] -- [[doom-package:json-mode]] -- [[doom-package:json-snatcher]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/json/config.el b/.config/emacs/modules/lang/json/config.el @@ -1,35 +0,0 @@ -;;; lang/json/config.el -*- lexical-binding: t; -*- - -(use-package! json-mode - :mode "\\.js\\(?:on\\|[hl]int\\(?:rc\\)?\\)\\'" - :init - (when (modulep! +lsp) - (add-hook 'json-mode-local-vars-hook #'lsp! 'append)) - (when (modulep! +tree-sitter) - (add-hook! '(json-mode-local-vars-hook - jsonc-mode-local-vars-hook) - :append #'tree-sitter!)) - :config - (set-electric! 'json-mode :chars '(?\n ?: ?{ ?})) - - (map! :after json-mode - :map json-mode-map - :localleader - :desc "Copy path" "p" #'json-mode-show-path - "t" #'json-toggle-boolean - "d" #'json-mode-kill-path - "x" #'json-nullify-sexp - "+" #'json-increment-number-at-point - "-" #'json-decrement-number-at-point - "f" #'json-mode-beautify)) - - - -(use-package! counsel-jq - :when (modulep! :completion ivy) - :defer t - :init - (map! :after json-mode - :map json-mode-map - :localleader - "s" #'counsel-jq)) diff --git a/.config/emacs/modules/lang/json/doctor.el b/.config/emacs/modules/lang/json/doctor.el @@ -1,9 +0,0 @@ -;;; lang/json/doctor.el -*- lexical-binding: t; -*- - -(when (and (modulep! :completion ivy) - (not (executable-find "jq"))) - (warn! "Couldn't find jq. counsel-jq won't work." )) - -(assert! (or (not (modulep! +tree-sitter)) - (modulep! :tools tree-sitter)) - "This module requires (:tools tree-sitter)") diff --git a/.config/emacs/modules/lang/json/packages.el b/.config/emacs/modules/lang/json/packages.el @@ -1,7 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/json/packages.el - -(package! json-mode :pin "eedb4560034f795a7950fa07016bd4347c368873") -(package! json-snatcher :pin "b28d1c0670636da6db508d03872d96ffddbc10f2") -(when (modulep! :completion ivy) - (package! counsel-jq :pin "8cadd2e96470402ede4881b4e955872976443689")) diff --git a/.config/emacs/modules/lang/julia/README.org b/.config/emacs/modules/lang/julia/README.org @@ -1,130 +0,0 @@ -#+title: :lang julia -#+subtitle: A better, faster MATLAB -#+created: April 08, 2020 -#+since: 1.3 - -* Description :unfold: -This module adds support for [[https://julialang.org/][the Julia language]] to Doom Emacs. - -- Syntax highlighting and latex symbols from [[doom-package:julia-mode]] -- REPL integration from [[doom-package:julia-repl]] -- Code completion and syntax checking, requires [[doom-module::tools lsp]] and [[doom-module:+lsp]] - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +lsp :: - Enable LSP support for ~julia-mode~. Requires [[doom-module::tools lsp]] and a langserver - (supports LanguageServer.jl). -- +tree-sitter :: - Leverages tree-sitter for better syntax highlighting and structural text - editing. Requires [[doom-module::tools tree-sitter]]. - -** Packages -- [[doom-package:julia-mode]] -- [[doom-package:julia-repl]] -- if [[doom-package:+lsp]] - - if [[doom-module::tools lsp]] - - [[doom-package:lsp-julia]] - - [[doom-package:lsp]] - - if [[doom-module::tools lsp +eglot]] - - [[doom-package:eglot-jl]] - - [[doom-package:eglot]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires [[https://julialang.org/][Julia]] and an language server if [[doom-module:+lsp]] is enabled. - -** Language Server -[[doom-module:+lsp]] requires ~LanguageServer.jl~ and ~SymbolServer.jl~. The [[doom-package:lsp-julia]] and -[[doom-package:eglot-jl]] packages both come bundled with their own versions of these servers, -which is used by default. If you're happy with that, no further configuration is -necessary. - -However, to use your own installation you will need to install then configure -them. To install them, execute these commands in a Julia REPL: -#+begin_src julia -using Pkg -Pkg.add("LanguageServer") -Pkg.add("SymbolServer") -#+end_src - -Then configure [[doom-package:lsp-julia]] or [[doom-package:eglot-jl]] depending on whether you have enabled -[[doom-module::tools lsp]] or [[doom-module::tools lsp +eglot]], respectively: - -*** =lsp-julia= -To instruct [[doom-package:lsp-julia]] not to use the built-in package: -#+begin_src emacs-lisp -;; in $DOOMDIR/config.el -(setq lsp-julia-package-dir nil) -#+end_src - -To find your installation of ~LanguageServer.jl~, [[doom-package:lsp-julia]] needs to know the -environment in which it is installed. This is set to v1.6 by default as it is -the current LTS: -#+begin_src emacs-lisp -;; in $DOOMDIR/config.el -(after! lsp-julia - (setq lsp-julia-default-environment "~/.julia/environments/v1.6")) -#+end_src - -*** =eglot-jl= -To find your installation of ~LanguageServer.jl~, [[doom-package:eglot-jl]] must know the -environment in which it is installed. This is set to v1.6 by default as it is -the current LTS: -#+begin_src emacs-lisp -;; in $DOOMDIR/config.el -(setq eglot-jl-language-server-project "~/.julia/environments/v1.6") -#+end_src - -But to let [[doom-package:eglot-jl]] use the environment bundled with it, set it to -~eglot-jl-base~ instead: -#+begin_src emacs-lisp -;; in $DOOMDIR/config.el -(after! eglot-jl - (setq eglot-jl-language-server-project eglot-jl-base)) -#+end_src - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** Language Server -[[doom-module:+lsp]] adds code completion, syntax checking, formatting and other [[doom-package:lsp-mode]] or -[[doom-package:eglot]] features. It requires ~LanguageServer.jl~, the installation of which is -described above. - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** Change the default environment for the Julia language server -[[doom-package:lsp-julia]] requires a variable be set for the Julia environment. This is set to -v1.6 by default as it is the current LTS: -#+begin_src emacs-lisp -;; in $DOOMDIR/config.el -(after! lsp-julia - (setq lsp-julia-default-environment "~/.julia/environments/v1.6")) -#+end_src - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/julia/autoload.el b/.config/emacs/modules/lang/julia/autoload.el @@ -1,21 +0,0 @@ -;;; lang/julia/autoload.el -*- lexical-binding: t; -*- - -;; `ob-julia' needs this variable to be defined, but it's defined in -;; `ess-custom', which won't be available if you're using :lang julia and not -;; :lang ess. -;;;###autoload (defvar inferior-julia-program-name (or (executable-find "julia-basic") "julia")) - -;;;###autoload -(defun +julia/open-repl () - "Run an inferior instance of `julia' inside Emacs." - (interactive) - (if (require 'julia-repl nil t) - (prog1 (julia-repl) - (julia-repl-use-emacsclient)) - (let ((buffer (get-buffer-create "*Julia*"))) - (unless (comint-check-proc "*Julia*") - (apply #'make-comint-in-buffer "Julia" "*Julia*" julia-program julia-arguments)) - (pop-to-buffer buffer) - (with-current-buffer buffer - (inferior-julia-mode)) - buffer))) diff --git a/.config/emacs/modules/lang/julia/config.el b/.config/emacs/modules/lang/julia/config.el @@ -1,98 +0,0 @@ -;;; lang/julia/config.el -*- lexical-binding: t; -*- - -(use-package! julia-mode - :interpreter "julia" - :config - (set-repl-handler! 'julia-mode #'+julia/open-repl) - - (when (modulep! +lsp) - (add-hook 'julia-mode-local-vars-hook #'lsp! 'append)) - - (when (modulep! +tree-sitter) - (add-hook 'julia-mode-local-vars-hook #'tree-sitter! 'append)) - - ;; Borrow matlab.el's fontification of math operators. From - ;; <https://web.archive.org/web/20170326183805/https://ogbe.net/emacsconfig.html> - (dolist (mode '(julia-mode ess-julia-mode)) - (font-lock-add-keywords - mode - `((,(let ((OR "\\|")) - (concat "\\(" ; stolen `matlab.el' operators first - ;; `:` defines a symbol in Julia and must not be highlighted - ;; as an operator. The only operators that start with `:` are - ;; `:<` and `::`. This must be defined before `<`. - "[:<]:" OR - "[<>]=?" OR - "\\.[/*^']" OR - "===" OR - "==" OR - "=>" OR - "\\<xor\\>" OR - "[-+*\\/^&|$]=?" OR ; this has to come before next (updating operators) - "[-^&|*+\\/~]" OR - ;; Julia variables and names can have `!`. Thus, `!` must be - ;; highlighted as a single operator only in some - ;; circumstances. However, full support can only be - ;; implemented by a full parser. Thus, here, we will handle - ;; only the simple cases. - "[[:space:]]!=?=?" OR "^!=?=?" OR - ;; The other math operators that starts with `!`. - ;; more extra julia operators follow - "[%$]" OR - ;; bitwise operators - ">>>" OR ">>" OR "<<" OR - ">>>=" OR ">>" OR "<<" OR - "\\)")) - 1 font-lock-type-face))))) - - -(use-package! julia-repl - :preface (defvar +julia-repl-start-hook nil) - :hook (julia-mode . julia-repl-mode) - :hook (+julia-repl-start . +julia-override-repl-escape-char-h) - :hook (+julia-repl-start . julia-repl-use-emacsclient) - :config - (set-popup-rule! "^\\*julia.*\\*$" :ttl nil) - - (when (modulep! :ui workspaces) - (defadvice! +julia--namespace-repl-buffer-to-workspace-a (&optional executable-key suffix) - "Name for a Julia REPL inferior buffer. Uses workspace name for doom emacs" - :override #'julia-repl--inferior-buffer-name - (concat julia-repl-inferior-buffer-name-base ":" (+workspace-current-name)))) - - (defadvice! +julia--run-start-hook-a (inferior-buffer) - "Run `+julia-repl-start-hook' before displaying the REPL." - :after #'julia-repl--setup-term - (with-current-buffer inferior-buffer - (run-hooks '+julia-repl-start-hook))) - - (defun +julia-override-repl-escape-char-h () - "Use C-c instead of C-x for escaping." - (term-set-escape-char ?\C-c))) - - -(use-package! lsp-julia - :when (modulep! +lsp) - :unless (modulep! :tools lsp +eglot) - :after lsp-mode - :preface (setq lsp-julia-default-environment nil) - :init - ;; If no environment is set, then auto-detect one in ~/.julia/environments/, - ;; falling back to `lsp-julia-default-environment's default. - (unless lsp-julia-default-environment - (setq lsp-julia-default-environment - (or (car (last (doom-glob "~/.julia/environments/v*"))) - "~/.julia/environments/v1.6")))) - - -(use-package! eglot-jl - :when (modulep! +lsp) - :when (modulep! :tools lsp +eglot) - :after eglot - :preface - ;; Prevent auto-install of LanguageServer.jl - (setq eglot-jl-language-server-project "~/.julia/environments/v1.6") - :init - ;; Prevent timeout while installing LanguageServer.jl - (setq-hook! 'julia-mode-hook eglot-connect-timeout (max eglot-connect-timeout 60)) - :config (eglot-jl-init)) diff --git a/.config/emacs/modules/lang/julia/doctor.el b/.config/emacs/modules/lang/julia/doctor.el @@ -1,23 +0,0 @@ -;;; lang/julia/doctor.el -*- lexical-binding: t; -*- - -(assert! (or (not (modulep! +lsp)) - (modulep! :tools lsp)) - "This module requires (:tools lsp)") - -(assert! (or (not (modulep! +tree-sitter)) - (modulep! :tools tree-sitter)) - "This module requires (:tools tree-sitter)") - -(when (modulep! +lsp) - (let ((args - (cond ((require 'eglot-jl nil t) - `(,eglot-jl-julia-command - ,(concat "--project=" eglot-jl-language-server-project) - ,@eglot-jl-julia-flags - "-e" "empty!(LOAD_PATH); push!(LOAD_PATH, \"@\"); using LanguageServer, SymbolServer")) - ((require 'lsp-julia nil t) - `(,lsp-julia-command - ,@lsp-julia-flags - "-e" "using LanguageServer, SymbolServer"))))) - (unless (zerop (car (apply #'doom-call-process args))) - (warn! "Couldn't find LanguageServer.jl and/or SymbolServer.jl")))) diff --git a/.config/emacs/modules/lang/julia/packages.el b/.config/emacs/modules/lang/julia/packages.el @@ -1,10 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/julia/packages.el - -(package! julia-mode :pin "7aafa8e77df64a47fa4729a0c1ea572b5bc8e30e") -(package! julia-repl :pin "57a15dfafed680ad7d81f779d414e8cb6717417c") - -(when (modulep! +lsp) - (if (modulep! :tools lsp +eglot) - (package! eglot-jl :pin "2e04597223553a369dd5b6520b6365b41e6ea508") - (package! lsp-julia :pin "d6688bb131ff4a5a0201f6d3826ef0b018265389"))) diff --git a/.config/emacs/modules/lang/kotlin/README.org b/.config/emacs/modules/lang/kotlin/README.org @@ -1,54 +0,0 @@ -#+title: :lang kotlin -#+subtitle: A Java(Script) that won't depress you -#+created: March 28, 2019 -#+since: 21.12.0 - -* Description :unfold: -This module adds [[https://kotlinlang.org/][Kotlin]] support to Doom Emacs. - -** Maintainers -*This module needs a maintainer.* [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +lsp :: - Enable LSP support for ~kotlin-mode~. Requires [[doom-module::tools lsp]] and a langserver - (supports [[https://github.com/emacs-lsp/lsp-mode][kotlin-language-server]]). - -** Packages -- [[doom-package:flycheck-kotlin]] if [[doom-module::checkers syntax]] -- [[doom-package:kotlin-mode]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* TODO Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -#+begin_quote - 🔨 /This module's prerequisites are not documented./ [[doom-contrib-module:][Document them?]] -#+end_quote - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/kotlin/autoload.el b/.config/emacs/modules/lang/kotlin/autoload.el @@ -1,15 +0,0 @@ -;;; lang/kotlin/autoload.el -*- lexical-binding: t; -*- - -;;;autoload -(defun +kotlin-locate-gradlew-file () - "Gradlew file location for this project." - (locate-dominating-file buffer-file-name "gradlew")) - -;;;###autoload -(defun +kotlin/run-gradlew (command) - "Run gradlew in this project." - (interactive "sCommand: ") - (let ((default-directory (+kotlin-locate-gradlew-file)) - (compilation-read-command nil) - (compile-command (format "sh gradlew %s" command))) - (call-interactively #'compile))) diff --git a/.config/emacs/modules/lang/kotlin/config.el b/.config/emacs/modules/lang/kotlin/config.el @@ -1,19 +0,0 @@ -;;; lang/kotlin/config.el -*- lexical-binding: t; -*- - -(after! kotlin-mode - (when (modulep! +lsp) - (add-hook 'kotlin-mode-local-vars-hook #'lsp! 'append)) - (set-docsets! 'kotlin-mode "Kotlin") - (set-repl-handler! 'kotlin-mode #'kotlin-repl) - - (map! :map kotlin-mode-map - :localleader - :prefix ("b" . "build") - :desc "gradlew assemble" "a" (cmd! (+kotlin/run-gradlew "assemble")) - :desc "gradlew build" "b" (cmd! (+kotlin/run-gradlew "build")) - :desc "gradlew test" "t" (cmd! (+kotlin/run-gradlew "test")))) - - -(use-package! flycheck-kotlin - :when (modulep! :checkers syntax) - :hook (kotlin-mode . flycheck-kotlin-setup)) diff --git a/.config/emacs/modules/lang/kotlin/doctor.el b/.config/emacs/modules/lang/kotlin/doctor.el @@ -1,8 +0,0 @@ -;;; lang/kotlin/doctor.el -*- lexical-binding: t; -*- - -(unless (executable-find "ktlint") - (warn! "ktlint not found. flycheck-kotlin won't work.")) - -(assert! (or (not (modulep! +lsp)) - (modulep! :tools lsp)) - "This module requires (:tools lsp)") diff --git a/.config/emacs/modules/lang/kotlin/packages.el b/.config/emacs/modules/lang/kotlin/packages.el @@ -1,7 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/kotlin/packages.el - -(package! kotlin-mode :pin "fddd747e5b4736e8b27a147960f369b86179ddff") - -(when (modulep! :checkers syntax) - (package! flycheck-kotlin :pin "a2a6abb9a7f85c6fb15ce327459ec3c8ff780188")) diff --git a/.config/emacs/modules/lang/latex/+fontification.el b/.config/emacs/modules/lang/latex/+fontification.el @@ -1,88 +0,0 @@ -;;; lang/latex/+fontification.el -*- lexical-binding: t; -*- - -;; Fontification taken from https://tex.stackexchange.com/a/86119/81279. -(setq font-latex-match-reference-keywords - '(;; BibLaTeX. - ("printbibliography" "[{") - ("addbibresource" "[{") - ;; Standard commands. - ("cite" "[{") - ("citep" "[{") - ("citet" "[{") - ("Cite" "[{") - ("parencite" "[{") - ("Parencite" "[{") - ("footcite" "[{") - ("footcitetext" "[{") - ;; Style-specific commands. - ("textcite" "[{") - ("Textcite" "[{") - ("smartcite" "[{") - ("Smartcite" "[{") - ("cite*" "[{") - ("parencite*" "[{") - ("supercite" "[{") - ;; Qualified citation lists. - ("cites" "[{") - ("Cites" "[{") - ("parencites" "[{") - ("Parencites" "[{") - ("footcites" "[{") - ("footcitetexts" "[{") - ("smartcites" "[{") - ("Smartcites" "[{") - ("textcites" "[{") - ("Textcites" "[{") - ("supercites" "[{") - ;; Style-independent commands. - ("autocite" "[{") - ("Autocite" "[{") - ("autocite*" "[{") - ("Autocite*" "[{") - ("autocites" "[{") - ("Autocites" "[{") - ;; Text commands. - ("citeauthor" "[{") - ("Citeauthor" "[{") - ("citetitle" "[{") - ("citetitle*" "[{") - ("citeyear" "[{") - ("citedate" "[{") - ("citeurl" "[{") - ;; Special commands. - ("fullcite" "[{") - ;; Cleveref. - ("cref" "{") - ("Cref" "{") - ("cpageref" "{") - ("Cpageref" "{") - ("cpagerefrange" "{") - ("Cpagerefrange" "{") - ("crefrange" "{") - ("Crefrange" "{") - ("labelcref" "{"))) - -(setq font-latex-match-textual-keywords - '(;; BibLaTeX brackets. - ("parentext" "{") - ("brackettext" "{") - ("hybridblockquote" "[{") - ;; Auxiliary commands. - ("textelp" "{") - ("textelp*" "{") - ("textins" "{") - ("textins*" "{") - ;; Subcaption. - ("subcaption" "[{"))) - -(setq font-latex-match-variable-keywords - '(;; Amsmath. - ("numberwithin" "{") - ;; Enumitem. - ("setlist" "[{") - ("setlist*" "[{") - ("newlist" "{") - ("renewlist" "{") - ("setlistdepth" "{") - ("restartlist" "{") - ("crefname" "{"))) diff --git a/.config/emacs/modules/lang/latex/+ref.el b/.config/emacs/modules/lang/latex/+ref.el @@ -1,42 +0,0 @@ -;;; lang/latex/+ref.el -*- lexical-binding: t; -*- - -(use-package! reftex - :hook (LaTeX-mode . reftex-mode) - :config - ;; Set up completion for citations and references. - (set-company-backend! 'reftex-mode 'company-reftex-labels 'company-reftex-citations) - ;; Get RefTeX working with BibLaTeX, see - ;; http://tex.stackexchange.com/questions/31966/setting-up-reftex-with-biblatex-citation-commands/31992#31992. - (setq reftex-cite-format - '((?a . "\\autocite[]{%l}") - (?b . "\\blockcquote[]{%l}{}") - (?c . "\\cite[]{%l}") - (?f . "\\footcite[]{%l}") - (?n . "\\nocite{%l}") - (?p . "\\parencite[]{%l}") - (?s . "\\smartcite[]{%l}") - (?t . "\\textcite[]{%l}")) - reftex-plug-into-AUCTeX t - reftex-toc-split-windows-fraction 0.3 - ;; This is needed when `reftex-cite-format' is set. See - ;; https://superuser.com/a/1386206 - LaTeX-reftex-cite-format-auto-activate nil) - (when (modulep! :editor evil) - (add-hook 'reftex-mode-hook #'evil-normalize-keymaps)) - (map! :map reftex-mode-map - :localleader - ";" 'reftex-toc) - (add-hook! 'reftex-toc-mode-hook - (reftex-toc-rescan) - (map! :map 'local - :e "j" #'next-line - :e "k" #'previous-line - :e "q" #'kill-buffer-and-window - :e "ESC" #'kill-buffer-and-window))) - -;; Set up mode for bib files. -(after! bibtex - (setq bibtex-dialect 'biblatex - bibtex-align-at-equal-sign t - bibtex-text-indentation 20) - (define-key bibtex-mode-map (kbd "C-c \\") #'bibtex-fill-entry)) diff --git a/.config/emacs/modules/lang/latex/+viewers.el b/.config/emacs/modules/lang/latex/+viewers.el @@ -1,67 +0,0 @@ -;;; lang/latex/+viewers.el -*- lexical-binding: t; -*- - -;; Fall back PDF previewing to `latex-preview-pane-mode'. -(add-to-list 'TeX-view-program-selection '(output-pdf "preview-pane") 'append) -(add-to-list 'TeX-view-program-list '("preview-pane" latex-preview-pane-mode)) - -(dolist (viewer (reverse +latex-viewers)) - (pcase viewer - (`skim - (when-let - (app-path - (and IS-MAC - (file-exists-p! (or "/Applications/Skim.app" - "~/Applications/Skim.app")))) - (add-to-list 'TeX-view-program-selection '(output-pdf "Skim")) - (add-to-list 'TeX-view-program-list - (list "Skim" (format "%s/Contents/SharedSupport/displayline -r -b %%n %%o %%b" - app-path))))) - - (`sumatrapdf - (when (and IS-WINDOWS - (executable-find "SumatraPDF")) - (add-to-list 'TeX-view-program-selection '(output-pdf "SumatraPDF")))) - - (`okular - (when (executable-find "okular") - ;; Configure Okular as viewer. Including a bug fix - ;; (https://bugs.kde.org/show_bug.cgi?id=373855). - (add-to-list 'TeX-view-program-list '("Okular" ("okular --noraise --unique file:%o" (mode-io-correlate "#src:%n%a")))) - (add-to-list 'TeX-view-program-selection '(output-pdf "Okular")))) - - (`zathura - (when (executable-find "zathura") - (add-to-list 'TeX-view-program-selection '(output-pdf "Zathura")))) - - (`evince - (when (executable-find "evince") - (add-to-list 'TeX-view-program-selection '(output-pdf "Evince")))) - - (`pdf-tools - (when (modulep! :tools pdf) - (add-to-list 'TeX-view-program-selection '(output-pdf "PDF Tools")) - (when IS-MAC - ;; PDF Tools isn't in `TeX-view-program-list-builtin' on macs. - (add-to-list 'TeX-view-program-list '("PDF Tools" TeX-pdf-tools-sync-view))) - ;; Update PDF buffers after successful LaTeX runs. - (add-hook 'TeX-after-compilation-finished-functions #'TeX-revert-document-buffer))))) - - -(after! latex-preview-pane - (setq latex-preview-pane-multifile-mode 'auctex) - - ;; TODO: PR this to maintained fork by arifer48. The original project appears abandoned. - (defadvice! +latex--dont-reopen-preview-pane-a (fn &rest args) - "Once the preview pane has been closed it should not be reopened." - :around #'latex-preview-pane-update - (letf! (defun init-latex-preview-pane (&rest _) - ;; HACK Avoid the function because it tries to delete the current - ;; window, but it's already gone, so it ends up deleting the - ;; wrong window. - (setq-local latex-preview-pane-mode nil)) - (apply fn args))) - - (define-key! doc-view-mode-map - "ESC" #'delete-window - "q" #'delete-window - "k" (cmd! (quit-window) (delete-window)))) diff --git a/.config/emacs/modules/lang/latex/README.org b/.config/emacs/modules/lang/latex/README.org @@ -1,155 +0,0 @@ -#+title: :lang latex -#+subtitle: Writing papers in Emacs has never been so fun -#+created: January 16, 2017 -#+since: 1.3 - -* Description :unfold: -Provide a helping hand when working with LaTeX documents. - -- Sane defaults -- Fontification of many popular commands -- Pretty indentation of wrapped lines using the [[doom-package:adaptive-wrap]] package -- Spell checking with [[doom-package:flycheck]] -- Change PDF viewer to Okular or [[doom-package:latex-preview-pane]] -- Bibtex editor -- Autocompletion using [[doom-package:company-mode]] -- Compile your =.tex= code only once using LatexMk - -** Maintainers -- [[doom-user:][@tecosaur]] -- [[doom-user:][@ymarco]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +cdlatex :: - Enable [[doom-package:cdlatex]] for fast math insertion. -- +fold :: - Use TeX-fold (from [[doom-package:auctex]]) to fold LaTeX macros to unicode, and make folding - hook-based and less manual. -- +latexmk :: - Use LatexMk instead of LaTeX to compile documents. -- +lsp :: - Enable LSP support in latex buffers. Requires [[doom-module::tools lsp]] and a langserver - (supports digestif and TexLab). - -** Packages -- [[doom-package:adaptive-wrap]] -- [[doom-package:auctex]] -- [[doom-package:auctex-latexmk]] if [[doom-module:+latexmk]] -- [[doom-package:cdlatex]] if [[doom-module:+cdlatex]] -- [[doom-package:evil-tex]] if [[doom-module::editor evil +everywhere]] -- [[doom-package:latex-preview-pane]] -- if [[doom-module::completion company]] - - [[doom-package:company-auctex]] - - [[doom-package:company-math]] - - [[doom-package:company-reftex]] - -** TODO Hacks -#+begin_quote - 🔨 This module's hacks haven't been documented yet. [[doom-contrib-module:][Document them?]] -#+end_quote - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires ghostscript and a latex compiler. These are provided by the -=texlive= bundle, available through many OS package managers. - -#+begin_quote - 🚧 Ghostscript <= 9.27 is [[/auctex/manual/preview-latex/No-images-are-displayed-with-gs-9_002e27-and-earlier.html][reportedly buggy]] and doesn't work with auctex's math - previews. (You can check you ghostscript version with ~$ gs --version~.) - Most package managers already have newer versions, but if not you might have - to build gs from source. -#+end_quote - -** Ubuntu -#+begin_src sh -apt-get install texlive -#+end_src - -** Arch Linux -#+begin_src sh -pacman -S texlive-core -#+end_src - -** TODO macOS -#+begin_src sh -brew install --cask basictex -# If the above doesn't work, then -brew install --cask mactex # WARNING: large 4gb download! -#+end_src - -#+begin_quote - 🔨 This has not been verified. -#+end_quote - -** NixOS -#+begin_src nix -environment.systemPackages = [ pkgs.texlive.combined.scheme-medium ]; -#+end_src - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Configuration -** Specifying the location of a bibtex file & corresponding PDFs -Reftex has a variable that allow you to specify where it should find your -bibliography file(s): -#+begin_src emacs-lisp -;; in $DOOMDIR/config.el -(setq reftex-default-bibliography "/your/bib/file.bib") -#+end_src - -** Changing the PDFs viewer -This module provides integration for four supported pdf viewers. They are - -+ [[https://skim-app.sourceforge.io/][Skim.app]] (MacOS only) -+ Evince -+ Sumatra PDF -+ Zathura -+ Okular -+ pdf-tools (requires [[doom-module::tools pdf]] module) - -They are searched for in this order. See ~+latex-viewers~ to change the order, -or remove tools from the search altogether. If you want to exclusively use one -tool, for instance: -#+begin_src emacs-lisp -;; in $DOOMDIR/config.el -(setq +latex-viewers '(zathura)) -#+end_src - -If none of these tools are found, ~latex-preview-pane~ (uses ~DocView~ in Emacs) -is used as a fallback. You can use this exclusively by setting ~+latex-viewers~ -to ~nil~. - -** Using cdlatex's snippets despite having yasnippet -[[doom-package:cdlatex]] has a snippet insertion capability which is disabled in favor of -[[doom-package:yasnippet]] when using [[doom-module::editor snippets]]. If you still wanna use it, simply rebind -the [[kbd:][TAB]] key for cdlatex, which takes care of snippet-related stuff: -#+begin_src emacs-lisp -;; in $DOOMDIR/config.el -(map! :map cdlatex-mode-map - :i "TAB" #'cdlatex-tab) -#+end_src - -This would favor yasnippet's expansion and cursor movement over cdlatex's -expansion and movement, but that shouldn't matter if you're not using yasnippet -in latex buffers. - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/latex/autoload.el b/.config/emacs/modules/lang/latex/autoload.el @@ -1,67 +0,0 @@ -;;; lang/latex/autoload.el -*- lexical-binding: t; -*- - -;;;###autoload -(defun +latex-indent-item-fn () - "Indent LaTeX \"itemize\",\"enumerate\", and \"description\" environments. - -\"\\item\" is indented `LaTeX-indent-level' spaces relative to the the beginning -of the environment. - -See `LaTeX-indent-level-item-continuation' for the indentation strategy this -function uses." - (save-match-data - (let* ((re-beg "\\\\begin{") - (re-end "\\\\end{") - (re-env "\\(?:itemize\\|\\enumerate\\|description\\)") - (indent (save-excursion - (when (looking-at (concat re-beg re-env "}")) - (end-of-line)) - (LaTeX-find-matching-begin) - (+ LaTeX-item-indent (current-column)))) - (contin (pcase +latex-indent-item-continuation-offset - (`auto LaTeX-indent-level) - (`align 6) - (`nil (- LaTeX-indent-level)) - (x x)))) - (cond ((looking-at (concat re-beg re-env "}")) - (or (save-excursion - (beginning-of-line) - (ignore-errors - (LaTeX-find-matching-begin) - (+ (current-column) - LaTeX-item-indent - LaTeX-indent-level - (if (looking-at (concat re-beg re-env "}")) - contin - 0)))) - indent)) - ((looking-at (concat re-end re-env "}")) - (save-excursion - (beginning-of-line) - (ignore-errors - (LaTeX-find-matching-begin) - (current-column)))) - ((looking-at "\\\\item") - (+ LaTeX-indent-level indent)) - ((+ contin LaTeX-indent-level indent)))))) - -;;;###autoload -(defun +latex-fold-last-macro-a (&rest _) - "Advice to auto-fold LaTeX macros after functions that -typically insert macros." - ;; A simpler approach would be to just fold the whole line, but if point was - ;; inside a macro that would kick it out. So instead we fold the last macro - ;; before point, hoping its the one newly inserted. - (TeX-fold-region (save-excursion - (search-backward "\\" (line-beginning-position) t) - (point)) - (1+ (point)))) - -;;;###autoload -(defun +latex-symbols-company-backend (command &optional arg &rest _ignored) - "A wrapper backend for `company-mode' that either uses -`company-math-symbols-unicode' or `company-math-symbols-latex'. If -`+latex-enable-unicode-math' is non-nil use the former, otherwise the latter." - (if +latex-enable-unicode-math - (company-math-symbols-unicode command arg) - (company-math-symbols-latex command arg))) diff --git a/.config/emacs/modules/lang/latex/config.el b/.config/emacs/modules/lang/latex/config.el @@ -1,278 +0,0 @@ -;;; lang/latex/config.el -*- lexical-binding: t; -*- - -(defconst +latex-indent-item-continuation-offset 'align - "Level to indent continuation of enumeration-type environments. - -I.e., this affects \\item, \\enumerate, and \\description. - -Set this to `align' for: - - \\item lines aligned - like this. - -Set to `auto' for continuation lines to be offset by `LaTeX-indent-line': - - \\item lines aligned - like this, assuming `LaTeX-indent-line' == 2 - -Any other fixed integer will be added to `LaTeX-item-indent' and the current -indentation level. - -Set this to `nil' to disable all this behavior. - -You'll need to adjust `LaTeX-item-indent' to control indentation of \\item -itself.") - -(defvar +latex-enable-unicode-math nil - "If non-nil, use `company-math-symbols-unicode' backend in `LaTeX-mode', -enabling unicode symbols in math regions. This requires the unicode-math LaTeX -package to be installed.") - -(defvar +latex-viewers '(skim evince sumatrapdf zathura okular pdf-tools) - "A list of enabled LaTeX viewers to use, in this order. If they don't exist, -they will be ignored. Recognized viewers are skim, evince, sumatrapdf, zathura, -okular and pdf-tools. - -If no viewer is found, `latex-preview-pane-mode' is used.") - -;; -(defvar +latex--company-backends nil) - - -;; -;; Packages - -(add-to-list 'auto-mode-alist '("\\.tex\\'" . LaTeX-mode)) - -(setq TeX-parse-self t ; parse on load - TeX-auto-save t ; parse on save - ;; Use hidden directories for AUCTeX files. - TeX-auto-local ".auctex-auto" - TeX-style-local ".auctex-style" - TeX-source-correlate-mode t - TeX-source-correlate-method 'synctex - ;; Don't start the Emacs server when correlating sources. - TeX-source-correlate-start-server nil - ;; Automatically insert braces after sub/superscript in `LaTeX-math-mode'. - TeX-electric-sub-and-superscript t - ;; Just save, don't ask before each compilation. - TeX-save-query nil) - - -(after! tex - ;; Fontify common LaTeX commands. - (load! "+fontification") - ;; Select viewer. - (load! "+viewers") - ;; Do not prompt for a master file. - (setq-default TeX-master t) - ;; Set-up chktex. - (setcar (cdr (assoc "Check" TeX-command-list)) "chktex -v6 -H %s") - (setq-hook! 'TeX-mode-hook - ;; Tell Emacs how to parse TeX files. - ispell-parser 'tex - ;; Don't auto-fill in math blocks. - fill-nobreak-predicate (cons #'texmathp fill-nobreak-predicate)) - ;; Enable word wrapping. - (add-hook 'TeX-mode-hook #'visual-line-mode) - ;; Enable `rainbow-mode' after applying styles to the buffer. - (add-hook 'TeX-update-style-hook #'rainbow-delimiters-mode) - ;; Display output of LaTeX commands in a popup. - (set-popup-rules! '((" output\\*$" :size 15) - ("^\\*TeX \\(?:Help\\|errors\\)" - :size 0.3 :select t :ttl nil))) - (after! smartparens-latex - ;; We have to use lower case modes here, because `smartparens-mode' uses - ;; the same during configuration. - (let ((modes '(tex-mode plain-tex-mode latex-mode LaTeX-mode))) - ;; All these excess pairs dramatically slow down typing in LaTeX buffers, - ;; so we remove them. Let snippets do their job. - (dolist (open '("\\left(" "\\left[" "\\left\\{" "\\left|" - "\\bigl(" "\\biggl(" "\\Bigl(" "\\Biggl(" "\\bigl[" - "\\biggl[" "\\Bigl[" "\\Biggl[" "\\bigl\\{" "\\biggl\\{" - "\\Bigl\\{" "\\Biggl\\{" - "\\lfloor" "\\lceil" "\\langle" - "\\lVert" "\\lvert" "`")) - (sp-local-pair modes open nil :actions :rem)) - ;; And tweak these so that users can decide whether they want use LaTeX - ;; quotes or not, via `+latex-enable-plain-double-quotes'. - (sp-local-pair modes "``" nil :unless '(:add sp-in-math-p)))) - ;; Hook LSP, if enabled. - (when (modulep! +lsp) - (add-hook! '(tex-mode-local-vars-hook - latex-mode-local-vars-hook) - :append #'lsp!)) - (map! :localleader - :map latex-mode-map - :desc "View" "v" #'TeX-view - :desc "Compile" "c" #'TeX-command-run-all - :desc "Run a command" "m" #'TeX-command-master) - (map! :after latex - :localleader - :map LaTeX-mode-map - :desc "View" "v" #'TeX-view - :desc "Compile" "c" #'TeX-command-run-all - :desc "Run a command" "m" #'TeX-command-master)) - - -(use-package! tex-fold - :when (modulep! +fold) - :hook (TeX-mode . +latex-TeX-fold-buffer-h) - :hook (TeX-mode . TeX-fold-mode) - :config - (defun +latex-TeX-fold-buffer-h () - (run-with-idle-timer 0 nil 'TeX-fold-buffer)) - ;; Fold after all AUCTeX macro insertions. - (advice-add #'TeX-insert-macro :after #'+latex-fold-last-macro-a) - ;; Fold after CDLaTeX macro insertions. - (advice-add #'cdlatex-math-symbol :after #'+latex-fold-last-macro-a) - (advice-add #'cdlatex-math-modify :after #'+latex-fold-last-macro-a) - ;; Fold after snippets. - (when (modulep! :editor snippets) - (add-hook! 'TeX-fold-mode-hook - (defun +latex-fold-snippet-contents-h () - (add-hook! 'yas-after-exit-snippet-hook :local - (when (and yas-snippet-beg yas-snippet-end) - (TeX-fold-region yas-snippet-beg yas-snippet-end)))))) - - (add-hook! 'mixed-pitch-mode-hook - (defun +latex-fold-set-variable-pitch-h () - "Fix folded things invariably getting fixed pitch when using mixed-pitch. -Math faces should stay fixed by the mixed-pitch blacklist, this is mostly for -\\section etc." - (when mixed-pitch-mode - ;; Adding to this list makes mixed-pitch clean the face remaps after us - (add-to-list 'mixed-pitch-fixed-cookie - (face-remap-add-relative - 'TeX-fold-folded-face - :family (face-attribute 'variable-pitch :family) - :height (face-attribute 'variable-pitch :height)))))) - - (map! :map TeX-fold-mode-map - :localleader - :desc "Fold paragraph" "f" #'TeX-fold-paragraph - :desc "Unfold paragraph" "F" #'TeX-fold-clearout-paragraph - :desc "Unfold buffer" "C-f" #'TeX-fold-clearout-buffer)) - - -(after! latex - ;; Add the TOC entry to the sectioning hooks. - (setq LaTeX-section-hook - '(LaTeX-section-heading - LaTeX-section-title - LaTeX-section-toc - LaTeX-section-section - LaTeX-section-label) - LaTeX-fill-break-at-separators nil - LaTeX-item-indent 0) - (when +latex--company-backends - (set-company-backend! 'latex-mode +latex--company-backends)) - - ;; Provide proper indentation for LaTeX "itemize", "enumerate", and - ;; "description" environments. See - ;; http://emacs.stackexchange.com/questions/3083/how-to-indent-items-in-latex-auctex-itemize-environments. - ;; Set `+latex-indent-item-continuation-offset' to 0 to disable this. - (dolist (env '("itemize" "enumerate" "description")) - (add-to-list 'LaTeX-indent-environment-list `(,env +latex-indent-item-fn))) - - ;; Fix #1849: allow fill-paragraph in itemize/enumerate. - (defadvice! +latex--re-indent-itemize-and-enumerate-a (fn &rest args) - :around #'LaTeX-fill-region-as-para-do - (let ((LaTeX-indent-environment-list - (append LaTeX-indent-environment-list - '(("itemize" +latex-indent-item-fn) - ("enumerate" +latex-indent-item-fn))))) - (apply fn args))) - (defadvice! +latex--dont-indent-itemize-and-enumerate-a (fn &rest args) - :around #'LaTeX-fill-region-as-paragraph - (let ((LaTeX-indent-environment-list LaTeX-indent-environment-list)) - (delq! "itemize" LaTeX-indent-environment-list 'assoc) - (delq! "enumerate" LaTeX-indent-environment-list 'assoc) - (apply fn args)))) - - -(use-package! preview - :hook (LaTeX-mode . LaTeX-preview-setup) - :config - (setq-default preview-scale 1.4 - preview-scale-function - (lambda () (* (/ 10.0 (preview-document-pt)) preview-scale))) - ;; Don't cache preamble, it creates issues with SyncTeX. Let users enable - ;; caching if they have compilation times that long. - (setq preview-auto-cache-preamble nil) - (map! :map LaTeX-mode-map - :localleader - :desc "Preview" "p" #'preview-at-point - :desc "Unpreview" "P" #'preview-clearout-at-point)) - - -(use-package! cdlatex - :when (modulep! +cdlatex) - :hook (LaTeX-mode . cdlatex-mode) - :hook (org-mode . org-cdlatex-mode) - :config - ;; Use \( ... \) instead of $ ... $. - (setq cdlatex-use-dollar-to-ensure-math nil) - ;; Disabling keys that have overlapping functionality with other parts of Doom. - (map! :map cdlatex-mode-map - ;; Smartparens takes care of inserting closing delimiters, and if you - ;; don't use smartparens you probably don't want these either. - "$" nil - "(" nil - "{" nil - "[" nil - "|" nil - "<" nil - ;; TAB is used for CDLaTeX's snippets and navigation. But we have - ;; Yasnippet for that. - (:when (modulep! :editor snippets) - "TAB" nil) - ;; AUCTeX takes care of auto-inserting {} on _^ if you want, with - ;; `TeX-electric-sub-and-superscript'. - "^" nil - "_" nil - ;; AUCTeX already provides this with `LaTeX-insert-item'. - [(control return)] nil)) - - -;; Nicely indent lines that have wrapped when visual line mode is activated. -(use-package! adaptive-wrap - :hook (LaTeX-mode . adaptive-wrap-prefix-mode) - :init (setq-default adaptive-wrap-extra-indent 0)) - - -(use-package! auctex-latexmk - :when (modulep! +latexmk) - :after latex - :init - ;; Pass the -pdf flag when TeX-PDF-mode is active. - (setq auctex-latexmk-inherit-TeX-PDF-mode t) - ;; Set LatexMk as the default. - (setq-hook! LaTeX-mode TeX-command-default "LatexMk") - :config - ;; Add LatexMk as a TeX target. - (auctex-latexmk-setup)) - - -(use-package! evil-tex - :when (modulep! :editor evil +everywhere) - :hook (LaTeX-mode . evil-tex-mode)) - - -(use-package! company-auctex - :when (modulep! :completion company) - :defer t - :init - (add-to-list '+latex--company-backends #'company-auctex-environments nil #'eq) - (add-to-list '+latex--company-backends #'company-auctex-macros nil #'eq)) - - -(use-package! company-math - :when (modulep! :completion company) - :defer t - :init - (add-to-list '+latex--company-backends #'+latex-symbols-company-backend nil #'eq)) - - -;; BibTeX + RefTeX. -(load! "+ref") diff --git a/.config/emacs/modules/lang/latex/packages.el b/.config/emacs/modules/lang/latex/packages.el @@ -1,26 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/latex/packages.el - -(package! auctex - :recipe (:files ("*.el" "*.info" "dir" - "doc" "etc" "images" "latex" "style")) - :pin "3929d5408b1e0d68cadeef7536a26ce29b1d36ea") -(package! adaptive-wrap :pin "0d5b4a07de76d87dd64333a566a8a0a845f2b9f0") -(package! latex-preview-pane :pin "5297668a89996b50b2b62f99cba01cc544dbed2e") -(when (modulep! :editor evil +everywhere) - (package! evil-tex :pin "3e0a26b91a1a56b0f35cbd450d01431057551750")) - -;; Optional module features. - -(when (modulep! +latexmk) - (package! auctex-latexmk :pin "b00a95e6b34c94987fda5a57c20cfe2f064b1c7a")) - -(when (modulep! +cdlatex) - (package! cdlatex :pin "ac024ce29318cab812a743ad132a531c855c27a5")) - -;; Features according to other user selected options. - -(when (modulep! :completion company) - (package! company-auctex :pin "9400a2ec7459dde8cbf1a5d50dfee4e300ed7e18") - (package! company-reftex :pin "42eb98c6504e65989635d95ab81b65b9d5798e76") - (package! company-math :pin "3eb006874e309ff4076d947fcbd61bb6806aa508")) diff --git a/.config/emacs/modules/lang/lean/README.org b/.config/emacs/modules/lang/lean/README.org @@ -1,54 +0,0 @@ -#+title: :lang lean -#+subtitle: For folks with too much to prove -#+created: September 10, 2019 -#+since: 21.12.0 (#1759) - -* Description :unfold: -This module adds support for the [[https://leanprover.github.io/about/][Lean programming language]] to Doom Emacs. - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:lean-mode]] -- [[doom-package:company-lean]] if [[doom-module::completion company]] - -** TODO Hacks -#+begin_quote -🔨 This module's hacks haven't been documented yet. [[doom-contrib-module:][Document them?]] -#+end_quote - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* TODO Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -#+begin_quote -🔨 /This module's prerequisites are not documented./ [[doom-contrib-module:][Document them?]] -#+end_quote - -* TODO Usage -#+begin_quote -🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote -🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote -🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/lean/config.el b/.config/emacs/modules/lang/lean/config.el @@ -1,36 +0,0 @@ -;;; lang/lean/config.el -*- lexical-binding: t; -*- - -(after! lean-mode - (set-lookup-handlers! 'lean-mode - :definition #'lean-find-definition) - (sp-with-modes 'lean-mode - (sp-local-pair "/-" "-/") - (sp-local-pair "`" "`") - (sp-local-pair "{" "}") - (sp-local-pair "«" "»") - (sp-local-pair "⟨" "⟩") - (sp-local-pair "⟪" "⟫")) - (map! :map lean-mode-map - :localleader - "g" #'lean-toggle-show-goal - "n" #'lean-toggle-next-error - (:prefix ("s" . "server") - "r" #'lean-server-restart - "s" #'lean-server-stop - "v" #'lean-server-switch-version) - (:prefix ("p" . "leanpkg") - "t" #'lean-leanpkg-test - "b" #'lean-leanpkg-build - "c" #'lean-leanpkg-configure) - "f" #'lean-fill-placeholder - "h" #'lean-hole - "m" #'lean-message-boxes-toggle - "e" #'lean-execute)) - - -(use-package! company-lean - :when (modulep! :completion company) - :after lean-mode - :init - (advice-add #'company-lean-hook :override #'ignore) - (set-company-backend! 'lean-mode 'company-lean)) diff --git a/.config/emacs/modules/lang/lean/packages.el b/.config/emacs/modules/lang/lean/packages.el @@ -1,7 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/lean/packages.el - -(package! lean-mode :pin "362bc6fa3efb1874c525ed6b4b6f24f76af22596") - -(when (modulep! :completion company) - (package! company-lean :pin "362bc6fa3efb1874c525ed6b4b6f24f76af22596")) diff --git a/.config/emacs/modules/lang/ledger/README.org b/.config/emacs/modules/lang/ledger/README.org @@ -1,73 +0,0 @@ -#+title: :lang ledger -#+subtitle: Be audit you can be -#+created: September 09, 2017 -#+since: 2.0.6 (#194) - -* Description :unfold: -This module adds support for [[https://www.ledger-cli.org/][ledger]] files. Ledger is a command line double-entry -accounting system that works with simple text files holding transactions in the -following format: -#+begin_src ledger -2015/10/12 Exxon - Expenses:Auto:Gas $10.00 - Liabilities:MasterCard $-10.00 -#+end_src - -This modules enables the following features: -- Syntax and indentation support for ledger files -- Add, edit, and delete transactions -- Generate reports -- Schedule transactions -- Sort transactions -- Display statistics about transactions -- Display balance up to a point - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:evil-ledger]] if [[doom-module::editor evil +everywhere]] -- [[doom-package:flycheck-ledger]] if [[doom-module::checkers syntax]] -- [[doom-package:ledger-mode]] - -** Hacks -- This module sets ~ledger-clear-whole-transactions~ to ~t~ (default value is - ~nil~). This results in ~ledger-toggle-current~ toggling the clear status of - the whole transaction instead of toggling just the current posting. - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires [[https://www.ledger-cli.org/][ledger]] to syntax check and generate reports from your -ledgers. - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -Please refer to ~ledger-mode~'s documentation for information on how to -configure it. You can do so within emacs with [[kbd:][C-h i]] - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/ledger/config.el b/.config/emacs/modules/lang/ledger/config.el @@ -1,88 +0,0 @@ -;;; lang/ledger/config.el -*- lexical-binding: t; -*- - -(use-package! ledger-mode - :defer t - :init - (setq ledger-clear-whole-transactions 1 - ledger-mode-should-check-version nil) - - (add-hook 'ledger-mode-hook #'outline-minor-mode) - - (set-company-backend! 'ledger-mode 'company-capf) - (set-popup-rules! - '(("^\\*Ledger Report" :size 0.5 :quit 'other :ttl 0) - ("^\\*Ledger Error" :quit t :ttl 0))) - - (defadvice! +ledger--fail-gracefully-if-absent-a (fn) - "Fail gracefully if ledger binary isn't available." - :around #'ledger-check-version - (if (executable-find ledger-binary-path) - (funcall fn) - (message "Couldn't find '%s' executable" ledger-binary-path))) - - ;; `ledger-mode' lacks imenu support out of the box, so we gie it some. At - ;; least to make jumping to outline headings or transactions easier. - (setq-hook! 'ledger-mode-hook - imenu-generic-expression - `((nil ,(concat - "^[\\* ]+[ \t]+\\([^\n\r]+\\)\\|" ; outline headings - "^[0-9]\\{4\\}[-/.][0-9]\\{2\\}[-/.][0-9]\\{2\\}[ \t]+[^\n]+") ; transactions - 0))) - - (map! :map ledger-report-mode-map - "C-c C-c" #'ledger-report-edit-report - "C-c C-r" #'ledger-report-redo - "C-c C-s" #'ledger-report-save - :map ledger-reconcile-mode-map - [tab] #'ledger-reconcile-toggle)) - - -(use-package! flycheck-ledger - :when (modulep! :checkers syntax) - :after ledger-mode) - - -(use-package! evil-ledger - :when (modulep! :editor evil +everywhere) - :hook (ledger-mode . evil-ledger-mode) - :config - (set-evil-initial-state! 'ledger-report-mode 'normal) - (map! (:map ledger-report-mode-map - :n "q" #'ledger-report-quit - :n "RET" #'ledger-report-edit-report - :n "gd" #'ledger-report-visit-source - :n "gr" #'ledger-report-redo - ;; This is redundant, but helps `substitute-command-keys' find them - ;; below, in `+ledger--fix-key-help-a'. - :n "C-d" #'evil-scroll-down - :n "C-u" #'evil-scroll-up) - (:map ledger-mode-map - :m "]]" #'ledger-navigate-next-xact-or-directive - :m "[[" #'ledger-navigate-prev-xact-or-directive) - - (:localleader - :map ledger-mode-map - "a" #'ledger-add-transaction - "e" #'ledger-post-edit-amount - "t" #'ledger-toggle-current - "d" #'ledger-delete-current-transaction - "r" #'ledger-report - "R" #'ledger-reconcile - "s" #'ledger-sort-region - "S" #'ledger-schedule-upcoming - (:prefix "g" - "s" #'ledger-display-ledger-stats - "b" #'ledger-display-balance-at-point))) - - (defadvice! +ledger--fix-key-help-a (fn &rest args) - "Fix inaccurate keybind message." - :around #'ledger-report - (quiet! (apply fn args)) - (with-current-buffer (get-buffer ledger-report-buffer-name) - (setq header-line-format - (substitute-command-keys - (concat "\\[ledger-report-quit] to quit; " - "\\[ledger-report-redo] to redo; " - "\\[ledger-report-edit-report] to edit; " - "\\[ledger-report-save] to save; " - "\\[evil-scroll-up] and \\[evil-scroll-down] to scroll")))))) diff --git a/.config/emacs/modules/lang/ledger/doctor.el b/.config/emacs/modules/lang/ledger/doctor.el @@ -1,4 +0,0 @@ -;;; lang/ledger/doctor.el -*- lexical-binding: t; -*- - -(unless (executable-find "ledger") - (warn! "ledger isn't installed")) diff --git a/.config/emacs/modules/lang/ledger/packages.el b/.config/emacs/modules/lang/ledger/packages.el @@ -1,10 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/ledger/packages.el - -(package! ledger-mode :pin "4b32f701736b37f99048be79583b0bde7cc14c85") - -(when (modulep! :editor evil) - (package! evil-ledger :pin "7a9f9f5d39c42fffdba8004f8982642351f2b233")) - -(when (modulep! :checkers syntax) - (package! flycheck-ledger :pin "628e25ba66604946085571652a94a54f4d1ad96f")) diff --git a/.config/emacs/modules/lang/lua/README.org b/.config/emacs/modules/lang/lua/README.org @@ -1,105 +0,0 @@ -#+title: :lang lua -#+subtitle: One-based indices? one-based indices -#+created: Jun 03, 2020 -#+since: 21.12.0 - -* Description :unfold: -This module adds Lua support to Doom Emacs. - -- REPL -- Love2D specific functions -- Moonscript support -- Fennel support - -** Maintainers -- [[doom-user:][@hlissner]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +fennel :: - Enable support for the Fennel language. -- +lsp :: - Enable LSP support for ~lua-mode~. Requires [[doom-module::tools lsp]] and a langserver - (supports EmmyLua, lua-language-server, and lua-lsp). -- +tree-sitter :: - Leverages tree-sitter for better syntax highlighting and structural text - editing. Requires [[doom-module::tools tree-sitter]]. Has support for both Lua and - Fennel. -- +moonscript :: - Enable support for the Moonscript language. - -** Packages -- [[doom-package:company-lua]] if [[doom-module::completion company]] -- [[doom-package:fennel-mode]] if [[doom-module:+fennel]] -- [[doom-package:lua-mode]] -- if [[doom-module:+moonscript]] - - [[doom-package:flycheck-moonscript]] if [[doom-module::checkers syntax]] - - [[doom-package:moonscript-mode]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires Lua 5.1+ for most of its capabilities and, optionally, the -fennel and moonscript transpilers. An LSP server is also required for LSP -support. - -** Language Server Protocol servers -LSP server support depends on which flavor of the [[doom-module::tools lsp]] module you have -installed ([[doom-package:eglot]] or [[doom-package:lsp-mode]]). - -*** LSP-mode -Three servers are supported, ordered from highest to lowest priority: -- [[https://github.com/EmmyLua/EmmyLua-LanguageServer][EmmyLua-LanguageServer]] :: Must be in - =$EMACSDIR/.local/etc/lsp/EmmyLua-LS-all.jar=. See - ~lsp-clients-emmy-lua-jar-path~ variable to change this. -- [[https://github.com/sumneko/lua-language-server][Sumneko language server]] (lua-language-server) :: Must be in - =$EMACSDIR/.local/etc/lsp/lua-language-server/=. See - ~lsp-clients-lua-language-server-bin~ variable to change this. -- [[https://github.com/Alloyed/lua-lsp][lua-lsp]] :: Must be available in =~/.luarocks/bin/lua-lsp=. See - ~lsp-clients-lua-lsp-server-install-dir~ variable to change this. - -[[https://emacs-lsp.github.io/lsp-mode/page/lsp-emmy-lua/][LSP-mode documentation]] has more information about setting up the server and the -configuration variables correctly. - -*** Eglot -Eglot currently only supports one of the above servers out of the box: -+ [[https://github.com/sumneko/lua-language-server][Sumneko language server]] (lua-language-server) :: Must be in - =$EMACSDIR/.local/etc/lsp/lua-language-server/=. See ~+lua-lsp-dir~ variable - to change this. - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -- lua-lsp-dir :: This must be set when using [[doom-module:+lsp]] and using [[https://github.com/sumneko/lua-language-server][lua-language-server]]. - This controls where the repository has been cloned and built to finish the - configuration of the server. - -* Troubleshooting -[[doom-report:][Report an issue?]] - -** Install lua-language-server -A [[https://github.com/sumneko/lua-language-server/issues/60][catch-all issue]] has been created to gather help for installing -lua-language-server on non-VSCode platforms. - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/lua/autoload/lua.el b/.config/emacs/modules/lang/lua/autoload/lua.el @@ -1,51 +0,0 @@ -;;; lang/lua/autoload/lua.el -*- lexical-binding: t; -*- - -(defun +lua-love-build-command () - (when-let (root (+lua-love-project-root)) - (format "%s %s" - (if (executable-find "love") - "love" - (if IS-MAC "open -a love.app")) - (shell-quote-argument root)))) - -;;;###autoload -(defun +lua-love-project-root () - "Returns the directory where a main.lua or main.moon exists. - -Returns nil if 'love' executable can't be found." - (when (executable-find "love") - (if (doom-project-p) - (file-name-directory - (or (project-file-exists-p! (or "main.lua" "src/main.lua")) - (and (modulep! +moonscript) - (project-file-exists-p! (or "main.moon" "src/main.moon"))) - "")) - ;; Since Love2D games are likely to be prototypes, they may not be in a - ;; well-formed project as far as projecitle is concerned, so we search for - ;; main.lua/main.moon up the file tree as a backup. - (or (projectile-locate-dominating-file default-directory "main.lua") - (when-let (root (projectile-locate-dominating-file default-directory "src/main.lua")) - (expand-file-name "src" root)) - (and (modulep! +moonscript) - (or (projectile-locate-dominating-file default-directory "main.moon") - (when-let (root (projectile-locate-dominating-file default-directory "src/main.moon")) - (expand-file-name "src" root)))))))) - - -;; -;;; Commands - -;;;###autoload -(defun +lua/open-repl () - "Open Lua REPL." - (interactive) - (lua-start-process "lua" "lua") - (pop-to-buffer lua-process-buffer)) - -;;;###autoload -(defun +lua/run-love-game () - "Run the current project with Love2D." - (interactive) - (if-let (cmd (+lua-love-build-command)) - (async-shell-command cmd) - (user-error "Couldn't find love project"))) diff --git a/.config/emacs/modules/lang/lua/autoload/moonscript.el b/.config/emacs/modules/lang/lua/autoload/moonscript.el @@ -1,16 +0,0 @@ -;;; lang/lua/autoload/moonscript.el -*- lexical-binding: t; -*- -;;;###if (modulep! +moonscript) - -;;;###autoload -(defun +lua-moonscript-fix-single-quotes-h () - "Single-quoted strings aren't treated as strings." - ;; (modify-syntax-entry ?\" "\"" moonscript-mode-syntax-table) - (modify-syntax-entry ?\' "\"" moonscript-mode-syntax-table)) - -;;;###autoload -(defun +lua-moonscript-fontify-interpolation-h () - "Highlight interpolated expressions in moonscript strings." - (font-lock-add-keywords - nil '(("#{\\([^}]+\\)}" - (0 font-lock-preprocessor-face t) - (1 nil t))))) diff --git a/.config/emacs/modules/lang/lua/config.el b/.config/emacs/modules/lang/lua/config.el @@ -1,96 +0,0 @@ -;;; lang/lua/config.el -*- lexical-binding: t; -*- - -;; sp's default rules are obnoxious, so disable them -(provide 'smartparens-lua) - - -;; -;;; Major modes - -(use-package! lua-mode - :defer t - :init - ;; lua-indent-level defaults to 3 otherwise. Madness. - (setq lua-indent-level 2) - :config - (set-lookup-handlers! 'lua-mode :documentation 'lua-search-documentation) - (set-electric! 'lua-mode :words '("else" "end")) - (set-repl-handler! 'lua-mode #'+lua/open-repl) - (set-company-backend! 'lua-mode '(company-lua company-yasnippet)) - - (when (modulep! +lsp) - (add-hook 'lua-mode-local-vars-hook #'lsp! 'append) - - (when (modulep! :tools lsp +eglot) - (defvar +lua-lsp-dir (concat doom-data-dir "lsp/lua-language-server/") - "Absolute path to the directory of sumneko's lua-language-server. - -This directory MUST contain the 'main.lua' file and be the in-source build of -lua-language-server.") - - (defun +lua-generate-lsp-server-command () - ;; The absolute path to lua-language-server binary is necessary because - ;; the bundled dependencies aren't found otherwise. The only reason this - ;; is a function is to dynamically change when/if `+lua-lsp-dir' does - (list (or (executable-find "lua-language-server") - (doom-path +lua-lsp-dir - (cond (IS-MAC "bin/macOS") - (IS-LINUX "bin/Linux") - (IS-WINDOWS "bin/Windows")) - "lua-language-server")) - "-E" "-e" "LANG=en" - (doom-path +lua-lsp-dir "main.lua"))) - - (set-eglot-client! 'lua-mode (+lua-generate-lsp-server-command))) - - (when (modulep! +tree-sitter) - (add-hook 'lua-mode-local-vars-hook #'tree-sitter! 'append)))) - - -(use-package! moonscript - :when (modulep! +moonscript) - :defer t - :config - (setq-hook! 'moonscript-mode-hook - moonscript-indent-offset tab-width) - (add-hook! 'moonscript-mode-hook - #'+lua-moonscript-fix-single-quotes-h - #'+lua-moonscript-fontify-interpolation-h) - (when (modulep! :checkers syntax) - (require 'flycheck-moonscript nil t))) - - -(use-package! fennel-mode - :when (modulep! +fennel) - :defer t - :config - (set-lookup-handlers! 'fennel-mode - :definition #'fennel-find-definition - :documentation #'fennel-show-documentation) - (set-repl-handler! 'fennel-mode #'fennel-repl) - - (setq-hook! 'fennel-mode-hook - ;; To match the `tab-width' default for other lisp modes - tab-width 2 - ;; Don't treat autoloads or sexp openers as outline headers, we have - ;; hideshow for that. - outline-regexp "[ \t]*;;;;* [^ \t\n]") - - (when (modulep! +tree-sitter) - (add-hook! 'fennel-mode-local-vars-hook 'tree-sitter! 'append))) - - -;; -;;; Frameworks - -(def-project-mode! +lua-love-mode - :modes '(moonscript-mode lua-mode markdown-mode json-mode) - :when (+lua-love-project-root) - :on-load - (progn - (set-project-type! 'love2d - :predicate #'+lua-love-project-root - :run #'+lua-love-build-command) - (map! :localleader - :map +lua-love-mode-map - "b" #'+lua/run-love-game))) diff --git a/.config/emacs/modules/lang/lua/packages.el b/.config/emacs/modules/lang/lua/packages.el @@ -1,17 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/lua/packages.el - -(package! lua-mode :pin "ad639c62e38a110d8d822c4f914af3e20b40ccc4") - -(when (modulep! +moonscript) - (package! moonscript :pin "56f90471e2ced2b0a177aed4d8c2f854797e9cc7") - (when (modulep! :checkers syntax) - (package! flycheck-moonscript - :recipe (:host github :repo "hlissner/emacs-flycheck-moonscript") - :pin "fcb99e5efcf31db05f236f02eaa575986a57172d"))) - -(when (modulep! +fennel) - (package! fennel-mode :pin "52da9715b0d046597cb322d3a98cb27ae6e5719e")) - -(when (modulep! :completion company) - (package! company-lua :pin "29f6819de4d691e5fd0b62893a9f4fbc1c6fcb52")) diff --git a/.config/emacs/modules/lang/markdown/README.org b/.config/emacs/modules/lang/markdown/README.org @@ -1,173 +0,0 @@ -#+title: :lang markdown -#+subtitle: Write docs for people to ignore -#+created: February 19, 2017 -#+since: 2.0.0 - -* Description :unfold: -This module provides Markdown support for Emacs. - -#+begin_quote -Markdown is a text-to-HTML conversion tool for web writers. Markdown allows you -to write using an easy-to-read, easy-to-write plain text format, then convert it -to structurally valid XHTML (or HTML). - -Thus, “Markdown” is two things: (1) a plain text formatting syntax; and (2) a -software tool, written in Perl, that converts the plain text formatting to HTML. -See the Syntax page for details pertaining to Markdown's formatting syntax. You -can try it out, right now, using the online Dingus. - -The overriding design goal for Markdown's formatting syntax is to make it as -readable as possible. The idea is that a Markdown-formatted document should be -publishable as-is, as plain text, without looking like it's been marked up with -tags or formatting instructions. While Markdown's syntax has been influenced by -several existing text-to-HTML filters, the single biggest source of inspiration -for Markdown's syntax is the format of plain text email. -- John Gruber -#+end_quote - -** Maintainers -- [[doom-user:][@hlissner]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +grip :: - Enable [[https://github.com/seagle0128/grip-mode][grip support]] (on [[kbd:][<localleader> p]]), to provide live github-style - previews of your markdown (or org) files. - -** Packages -- [[doom-package:edit-indirect]] -- [[doom-package:evil-markdown]] if [[doom-module::editor evil +everywhere]] -- [[doom-package:grip-mode]] if [[doom-module:+grip]] -- [[doom-package:markdown-mode]] -- [[doom-package:markdown-toc]] - -** Hacks -- [[doom-package:flyspell]] has been configured not to spell check in code blocks, links, HTML - tags or references. - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires: -- A linter (requires [[doom-module::checkers syntax]]) -- A markdown compiler, for previewing Markdown - -** Linters -Out of the box, flycheck recognizes these checkers for markdown-mode and -gfm-mode: - -- Markdown-specific - - [[https://github.com/DavidAnson/markdownlint][markdownlint]] (~$ npm install markdownlint~) - - [[https://github.com/markdownlint/markdownlint][mdl]] (~$ gem install mdl~) -- General (natural language) - - [[http://proselint.com/][proselint]] - - ~$ pip install proselint~ - - Or through your OS package manager - - MacOS: ~$ brew install proselint~ - - Arch Linux: ~$ pacman -S proselint~ - - [[https://github.com/textlint/textlint][textlint]] (~$ npm install textlint~) - -** Markdown compiler -This module requires a markdown compiler in order for ~markdown-preview~ to -work. It will recognize and use one of the following executables, in this order -(you only need one): - -- [[https://github.com/markedjs/marked][markedjs]]: a markdown compiler "built for speed" -- [[https://github.com/jgm/pandoc][pandoc]]: the universal markup transpiler -- [[http://pell.portland.or.us/~orc/Code/discount/][markdown]]: there are various flavors of this compiler. This module will look - for these two: - - John Gruber's [[https://daringfireball.net/projects/markdown/][original perl script]] - - The C implementation called [[http://pell.portland.or.us/~orc/Code/discount/][discount]], by David Parsons -- [[https://fletcher.github.io/MultiMarkdown-6/][multimarkdown]]: a compiler for a language that is a superset of Markdown, with - additional output formats and features. - -*** MarkedJS -Not to be confused with [[https://marked2app.com/][the Marked 2 app]], marked is an npm package: -#+begin_src sh -npm install -g marked -#+end_src - -*** Pandoc -Pandoc is the universal markup transpiler. It should be available through your -system package manager. For example: - -+ MacOS: ~$ brew install pandoc~ -+ Arch Linux: ~$ pacman -S pandoc~ - -*** Markdown -The C implementation of Markdown.pl, called =discount=, is available through -your OS's package manager: - -+ MacOS: ~$ brew install discount~ -+ Arch Linux: ~$ pacman -S discount~ - -The original perl script that discount is inspired from can be found on [[https://daringfireball.net/projects/markdown/][John -Gruber's website]]. - -*** MultiMarkdown -See [[https://fletcher.github.io/MultiMarkdown-6/introduction.html][its documentation]] for details on what MultiMarkdown is. The compiler can be -installed through your OS's package manager: - -+ MacOS: ~$ brew install multimarkdown~ -+ Arch Linux: [[https://aur.archlinux.org/packages/multimarkdown/][multimarkdown]] is available on the AUR - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** Markdown preview -~markdown-preview~ is bound to [[kbd:][<localleader> p]]. This will open a preview of your -compiled markdown document in your browser. - -Alternatively, you can use ~grip-mode~ through [[doom-module:+grip]]. - -* Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** Changing how markdown is compiled -When ~markdown-preview~ is invoked ([[kbd:][<localleader> p]]) it consults -~markdown-command~. Its default value (~#'+markdown-compile~) will consult -~+markdown-compile-functions~: a list of functions that take three arguments: -the start and end point in the current buffer to use as input, and an output -buffer to insert the result in. - -By default, the value of ~+markdown-compile-functions~ is: -#+begin_src lisp -'(+markdown-compile-marked - +markdown-compile-pandoc - +markdown-compile-markdown - +markdown-compile-multimarkdown) -#+end_src - -These functions will attempt to use the marked, pandoc and markdown executables, -if available. Changing this variable will control how markdown is compiled: -#+begin_src emacs-lisp -;; Add a new one -(add-hook '+markdown-compile-functions #'my-compile-function) - -;; Or remove an existing one -(remove-hook '+markdown-compile-functions #'+markdown-compile-markdown) -#+end_src - -Otherwise, you can change ~markdown-command~ directly: -#+begin_src emacs-lisp -(setq markdown-command "markdown | smartypants") -#+end_src - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/markdown/autoload.el b/.config/emacs/modules/lang/markdown/autoload.el @@ -1,107 +0,0 @@ -;;; lang/markdown/autoload.el -*- lexical-binding: t; -*- - -;;;###autoload -(defun +markdown-flyspell-word-p () - "Return t if `flyspell' should check word before point. - -Used for `flyspell-generic-check-word-predicate'. Like -`markdown-flyspell-check-word-p', but also: - -a) Performs spell check in code comments and -b) Inhibits spell check in html markup" - (save-excursion - (goto-char (1- (point))) - (if (or (and (markdown-code-block-at-point-p) - (not (or (markdown-text-property-at-point 'markdown-yaml-metadata-section) - (markdown--face-p (point) '(font-lock-comment-face))))) - (markdown-inline-code-at-point-p) - (markdown-in-comment-p) - (markdown--face-p (point) '(markdown-reference-face - markdown-markup-face - markdown-plain-url-face - markdown-inline-code-face - markdown-url-face - markdown-html-attr-name-face - markdown-html-attr-value-face - markdown-html-tag-name-face))) - (prog1 nil - ;; If flyspell overlay is put, then remove it - (let ((bounds (bounds-of-thing-at-point 'word))) - (when bounds - (cl-loop for ov in (overlays-in (car bounds) (cdr bounds)) - when (overlay-get ov 'flyspell-overlay) - do - (delete-overlay ov))))) - t))) - - -;; -;;; Compilation handlers - -;;;###autoload -(defun +markdown-compile (beg end output-buffer) - "Compile markdown into html. - -Runs `+markdown-compile-functions' until the first function to return non-nil, -otherwise throws an error." - (or (run-hook-with-args-until-success '+markdown-compile-functions - beg end output-buffer) - (user-error "No markdown program could be found. Install marked, pandoc, markdown or multimarkdown."))) - -;;;###autoload -(defun +markdown-compile-marked (beg end output-buffer) - "Compiles markdown with the marked program, if available. -Returns its exit code." - (when (executable-find "marked") - (apply #'call-process-region - beg end "marked" nil output-buffer nil - (when (eq major-mode 'gfm-mode) - (list "--gfm" "--tables" "--breaks"))))) - -;;;###autoload -(defun +markdown-compile-pandoc (beg end output-buffer) - "Compiles markdown with the pandoc program, if available. -Returns its exit code." - (when (executable-find "pandoc") - (call-process-region beg end "pandoc" nil output-buffer nil - "-f" "markdown" - "-t" "html" - "--mathjax" - "--highlight-style=pygments"))) - -;;;###autoload -(defun +markdown-compile-multimarkdown (beg end output-buffer) - "Compiles markdown with the multimarkdown program, if available. Returns its -exit code." - (when (executable-find "multimarkdown") - (call-process-region beg end "multimarkdown" nil output-buffer))) - -;;;###autoload -(defun +markdown-compile-markdown (beg end output-buffer) - "Compiles markdown using the Markdown.pl script (or markdown executable), if -available. Returns its exit code." - (when-let (exe (or (executable-find "Markdown.pl") - (executable-find "markdown"))) - (call-process-region beg end exe nil output-buffer nil))) - - -;; -;;; Commands - -;;;###autoload -(defun +markdown/insert-del () - "Surround region in github strike-through delimiters." - (interactive) - (let ((regexp "\\(^\\|[^\\]\\)\\(\\(~\\{2\\}\\)\\([^ \n \\]\\|[^ \n ]\\(?:.\\|\n[^\n]\\)*?[^\\ ]\\)\\(\\3\\)\\)") - (delim "~~")) - (if (markdown-use-region-p) - ;; Active region - (cl-destructuring-bind (beg . end) - (markdown-unwrap-things-in-region - (region-beginning) (region-end) - regexp 2 4) - (markdown-wrap-or-insert delim delim nil beg end)) - ;; Bold markup removal, bold word at point, or empty markup insertion - (if (thing-at-point-looking-at regexp) - (markdown-unwrap-thing-at-point nil 2 4) - (markdown-wrap-or-insert delim delim 'word nil nil))))) diff --git a/.config/emacs/modules/lang/markdown/config.el b/.config/emacs/modules/lang/markdown/config.el @@ -1,150 +0,0 @@ -;;; lang/markdown/config.el -*- lexical-binding: t; -*- - -(defvar +markdown-compile-functions - '(+markdown-compile-marked - +markdown-compile-pandoc - +markdown-compile-markdown - +markdown-compile-multimarkdown) - "A list of commands to try when attempting to build a markdown file with -`markdown-open' or `markdown-preview', stopping at the first one to return non-nil. - -Each function takes three argument. The beginning position of the region to -capture, the end position, and the output buffer.") - - -;; -;;; Packages - -(use-package! markdown-mode - :mode ("/README\\(?:\\.md\\)?\\'" . gfm-mode) - :init - (setq markdown-enable-math t ; syntax highlighting for latex fragments - markdown-enable-wiki-links t - markdown-italic-underscore t - markdown-asymmetric-header t - markdown-gfm-additional-languages '("sh") - markdown-make-gfm-checkboxes-buttons t - markdown-fontify-whole-heading-line t - - ;; HACK Due to jrblevin/markdown-mode#578, invoking `imenu' throws a - ;; 'wrong-type-argument consp nil' error if you use native-comp. - markdown-nested-imenu-heading-index (not (ignore-errors (native-comp-available-p))) - - ;; `+markdown-compile' offers support for many transpilers (see - ;; `+markdown-compile-functions'), which it tries until one succeeds. - markdown-command #'+markdown-compile - ;; This is set to `nil' by default, which causes a wrong-type-arg error - ;; when you use `markdown-open'. These are more sensible defaults. - markdown-open-command - (cond (IS-MAC "open") - (IS-LINUX "xdg-open")) - - ;; A sensible and simple default preamble for markdown exports that - ;; takes after the github asthetic (plus highlightjs syntax coloring). - markdown-content-type "application/xhtml+xml" - markdown-css-paths - '("https://cdn.jsdelivr.net/npm/github-markdown-css/github-markdown.min.css" - "https://cdn.jsdelivr.net/gh/highlightjs/cdn-release/build/styles/github.min.css") - markdown-xhtml-header-content - (concat "<meta name='viewport' content='width=device-width, initial-scale=1, shrink-to-fit=no'>" - "<style> body { box-sizing: border-box; max-width: 740px; width: 100%; margin: 40px auto; padding: 0 10px; } </style>" - "<script id='MathJax-script' async src='https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js'></script>" - "<script src='https://cdn.jsdelivr.net/gh/highlightjs/cdn-release/build/highlight.min.js'></script>" - "<script>document.addEventListener('DOMContentLoaded', () => { document.body.classList.add('markdown-body'); document.querySelectorAll('pre[lang] > code').forEach((code) => { code.classList.add(code.parentElement.lang); }); document.querySelectorAll('pre > code').forEach((code) => { hljs.highlightBlock(code); }); });</script>")) - - ;; A shorter alias for org src blocks than "markdown" - (after! org-src - (add-to-list 'org-src-lang-modes '("md" . markdown))) - - :config - (set-flyspell-predicate! '(markdown-mode gfm-mode) - #'+markdown-flyspell-word-p) - (set-lookup-handlers! '(markdown-mode gfm-mode) - ;; `markdown-follow-thing-at-point' may open an external program or a - ;; buffer. No good way to tell, so pretend it's async. - :file '(markdown-follow-thing-at-point :async t)) - - (sp-local-pair '(markdown-mode gfm-mode) "`" "`" - :unless '(:add sp-point-before-word-p sp-point-before-same-p)) - - ;; Highly rust blocks correctly - (when (modulep! :lang rust) - (add-to-list 'markdown-code-lang-modes '("rust" . rustic-mode))) - - ;; Don't trigger autofill in code blocks (see `auto-fill-mode') - (setq-hook! 'markdown-mode-hook - fill-nobreak-predicate (cons #'markdown-code-block-at-point-p - fill-nobreak-predicate)) - - ;; HACK Prevent mis-fontification of YAML metadata blocks in `markdown-mode' - ;; which occurs when the first line contains a colon in it. See - ;; jrblevin/markdown-mode#328. - (defadvice! +markdown-disable-front-matter-fontification-a (&rest _) - :override #'markdown-match-generic-metadata - (ignore (goto-char (point-max)))) - - (map! :map markdown-mode-map - :localleader - "'" #'markdown-edit-code-block - "o" #'markdown-open - "p" #'markdown-preview - "e" #'markdown-export - (:when (modulep! +grip) - "p" #'grip-mode) - (:prefix ("i" . "insert") - :desc "Table Of Content" "T" #'markdown-toc-generate-toc - :desc "Image" "i" #'markdown-insert-image - :desc "Link" "l" #'markdown-insert-link - :desc "<hr>" "-" #'markdown-insert-hr - :desc "Heading 1" "1" #'markdown-insert-header-atx-1 - :desc "Heading 2" "2" #'markdown-insert-header-atx-2 - :desc "Heading 3" "3" #'markdown-insert-header-atx-3 - :desc "Heading 4" "4" #'markdown-insert-header-atx-4 - :desc "Heading 5" "5" #'markdown-insert-header-atx-5 - :desc "Heading 6" "6" #'markdown-insert-header-atx-6 - :desc "Code block" "C" #'markdown-insert-gfm-code-block - :desc "Pre region" "P" #'markdown-pre-region - :desc "Blockquote region" "Q" #'markdown-blockquote-region - :desc "Checkbox" "[" #'markdown-insert-gfm-checkbox - :desc "Bold" "b" #'markdown-insert-bold - :desc "Inline code" "c" #'markdown-insert-code - :desc "Italic" "e" #'markdown-insert-italic - :desc "Footnote" "f" #'markdown-insert-footnote - :desc "Header dwim" "h" #'markdown-insert-header-dwim - :desc "Italic" "i" #'markdown-insert-italic - :desc "Kbd" "k" #'markdown-insert-kbd - :desc "Pre" "p" #'markdown-insert-pre - :desc "New blockquote" "q" #'markdown-insert-blockquote - :desc "Strike through" "s" #'markdown-insert-strike-through - :desc "Table" "t" #'markdown-insert-table - :desc "Wiki link" "w" #'markdown-insert-wiki-link) - (:prefix ("t" . "toggle") - :desc "Inline LaTeX" "e" #'markdown-toggle-math - :desc "Code highlights" "f" #'markdown-toggle-fontify-code-blocks-natively - :desc "Inline images" "i" #'markdown-toggle-inline-images - :desc "URL hiding" "l" #'markdown-toggle-url-hiding - :desc "Markup hiding" "m" #'markdown-toggle-markup-hiding - :desc "Wiki links" "w" #'markdown-toggle-wiki-links - :desc "GFM checkbox" "x" #'markdown-toggle-gfm-checkbox))) - - -(use-package! evil-markdown - :when (modulep! :editor evil +everywhere) - :hook (markdown-mode . evil-markdown-mode) - :config - (add-hook 'evil-markdown-mode-hook #'evil-normalize-keymaps) - (map! :map evil-markdown-mode-map - :n "TAB" #'markdown-cycle - :n [backtab] #'markdown-shifttab - :i "M-*" #'markdown-insert-list-item - :i "M-b" #'markdown-insert-bold - :i "M-i" #'markdown-insert-italic - :i "M-`" #'+markdown/insert-del - :i "M--" #'markdown-insert-hr - :n "M-r" #'browse-url-of-file - :m "]h" #'markdown-next-visible-heading - :m "[h" #'markdown-previous-visible-heading - :m "[p" #'markdown-promote - :m "]p" #'markdown-demote - :m "[l" #'markdown-previous-link - :m "]l" #'markdown-next-link)) diff --git a/.config/emacs/modules/lang/markdown/doctor.el b/.config/emacs/modules/lang/markdown/doctor.el @@ -1,22 +0,0 @@ -;; -*- lexical-binding: t; no-byte-compile: t; -*- -;;; lang/markdown/doctor.el - -(when (require 'markdown-mode nil t) - (cond ((eq markdown-command #'+markdown-compile) - (unless (cl-loop for (exe . cmd) in (list (cons "marked" '+markdown-compile-marked) - (cons "pandoc" '+markdown-compile-pandoc) - (cons "markdown" '+markdown-compile-markdown) - (cons "multimarkdown" '+markdown-compile-multimarkdown)) - if (and (memq cmd +markdown-compile-functions) - (executable-find exe)) - return t) - (warn! "Couldn't find a markdown compiler, `markdown-preview' won't work"))) - ((stringp markdown-command) - (let ((cmd (car (split-string markdown-command " ")))) - (unless (executable-find cmd) - (warn! "Couldn't find %S. markdown-preview command won't work" - cmd)))))) - -(when (modulep! +grip) - (unless (executable-find "grip") - (warn! "Couldn't find grip. grip-mode will not work"))) diff --git a/.config/emacs/modules/lang/markdown/packages.el b/.config/emacs/modules/lang/markdown/packages.el @@ -1,14 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/markdown/packages.el - -(package! markdown-mode :pin "c765b73b370f0fcaaa3cee28b2be69652e2d2c39") -(package! markdown-toc :pin "3d724e518a897343b5ede0b976d6fb46c46bcc01") -(package! edit-indirect :pin "f80f63822ffae78de38dbe72cacaeb1aaa96c732") - -(when (modulep! +grip) - (package! grip-mode :pin "5809fb62f6dd7b4bfa7685203aaa1474fca70f4e")) - -(when (modulep! :editor evil +everywhere) - (package! evil-markdown - :recipe (:host github :repo "Somelauw/evil-markdown") - :pin "8e6cc68af83914b2fa9fd3a3b8472573dbcef477")) diff --git a/.config/emacs/modules/lang/nim/README.org b/.config/emacs/modules/lang/nim/README.org @@ -1,73 +0,0 @@ -#+title: :lang nim -#+subtitle: Python + lisp at the speed of C -#+created: May 08, 2018 -#+since: 21.12.0 (#568) - -* Description :unfold: -This module adds [[https://nim-lang.org][Nim]] support to Doom Emacs. - -- Code completion ([[doom-package:nimsuggest]] + [[doom-package:company]]) -- Syntax checking ([[doom-package:nimsuggest]] + [[doom-package:flycheck]]) -- Org babel support ([[doom-package:ob-nim]]) - -** Maintainers -*This module needs a maintainer.* [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:flycheck-nim]] if [[doom-module::checkers syntax]] -- [[doom-package:nim-mode]] - -** Hacks -- [[doom-package:nimsuggest]] was modified to strip invalid characters from its temp file paths - (which would break nimsuggest on Windows systems). -- [[doom-package:nim-mode]] was modified to fail gracefully if =nimsuggest= (the executable) - isn't available. - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires: -- ~nim~, for building & evaluation. -- ~nimsuggest~, for code completion, syntax checking, and jump-to-definition - functionality. - -** Nim -=choosenim= is an installer and version manager for the Nim programming -language. You can install the latest stable release of Nim by running the -following in your terminal and following the onscreen instructions: -#+begin_src sh -curl https://nim-lang.org/choosenim/init.sh -sSf | sh -#+end_src - -Alternatively, nim is usually available through your OS's package manager: -- MacOS: ~$ brew install nim~ -- Arch Linux: ~$ pacman --needed --noconfirm -S nim nimble~ -- openSUSE: ~$ zypper install nim~ - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/nim/config.el b/.config/emacs/modules/lang/nim/config.el @@ -1,39 +0,0 @@ -;;; lang/nim/config.el -*- lexical-binding: t; -*- - -(use-package! nim-mode - :defer t - :init - (add-hook! 'nim-mode-hook - (defun +nim-init-nimsuggest-mode-h () - "Conditionally load `nimsuggest-mode', instead of clumsily erroring out if -nimsuggest isn't installed." - (unless (stringp nimsuggest-path) - (setq nimsuggest-path (executable-find "nimsuggest"))) - (when (and nimsuggest-path (file-executable-p nimsuggest-path)) - (nimsuggest-mode)))) - - (when IS-WINDOWS - ;; TODO File PR/report upstream (https://github.com/nim-lang/nim-mode) - (defadvice! +nim--suggest-get-temp-file-name-a (path) - "Removes invalid characters from the temp file path, including the unicode -character that colon is replaced with, which is known to cause issues on -windows." - :filter-return #'nimsuggest--get-temp-file-name - (replace-regexp-in-string "[꞉* |<>\"?*]" "" path))) - - :config - (set-lookup-handlers! '(nim-mode nimsuggest-mode) - :definition #'+nimsuggest-find-definition - :documentation #'nimsuggest-show-doc) - - (map! :localleader - :map nim-mode-map - "b" #'nim-compile - "h" #'nimsuggest-show-doc - "d" #'nimsuggest-find-definition)) - - -(use-package! flycheck-nim - :when (modulep! :checkers syntax) - :after nim-mode) - diff --git a/.config/emacs/modules/lang/nim/doctor.el b/.config/emacs/modules/lang/nim/doctor.el @@ -1,9 +0,0 @@ -;; -*- lexical-binding: t; no-byte-compile: t; -*- -;;; lang/nim/doctor.el - -(unless (executable-find "nimsuggest") - (warn! "Could not find nimsuggest executable; code-completion, syntax checking and jump-to-definition functionality will be disabled.")) - -(unless (executable-find "nim") - (warn! "Could not find nim executable; build commands will be disabled.")) - diff --git a/.config/emacs/modules/lang/nim/packages.el b/.config/emacs/modules/lang/nim/packages.el @@ -1,9 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/nim/packages.el - -;;; requires nim nimsuggest nimble - -(package! nim-mode :pin "744e076f0bea1c5ddc49f92397d9aa98ffa7eff8") - -(when (modulep! :checkers syntax) - (package! flycheck-nim :pin "ddfade51001571c2399f78bcc509e0aa8eb752a4")) diff --git a/.config/emacs/modules/lang/nix/README.org b/.config/emacs/modules/lang/nix/README.org @@ -1,81 +0,0 @@ -#+title: :lang nix -#+subtitle: I hereby declare "nix geht mehr!" -#+created: December 02, 2017 -#+since: 2.0.8 (#280) - -* Description :unfold: -This module adds support for the Nix language to Doom Emacs, along with tools -for managing [[https://nixos.org/][Nix(OS)]]. - -Includes: -- Syntax highlighting -- Completion through [[doom-package:company]] and/or [[doom-package:helm]] -- Nix option lookup -- Formatting (~nixfmt~) - -** Maintainers -- [[doom-user:][@hlissner]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +tree-sitter :: - Leverages tree-sitter for better syntax highlighting and structural text - editing. Requires [[doom-module::tools tree-sitter]]. - -** Packages -- [[doom-package:company-nixos-options]] if [[doom-module::completion company]] -- [[doom-package:helm-nixos-options]] if [[doom-module::completion helm]] -- [[doom-package:nix-mode]] -- [[doom-package:nix-update]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* TODO Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires: -- [[https://nixos.org/guides/install-nix.html][The Nix package manager]], for a variety of its features (besides syntax - highlighting). -- =nixfmt=, for automatic formatting (requires [[doom-module::editor format]]). - -- *MacOS:* TODO -- *Arch Linux:* TODO -- *NixOS:* in ~pkgs.nixfmt~ - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** Keybindings -| Binding | Description | -|-----------------+----------------------| -| [[kbd:][<localleader> b]] | ~nix-build~ | -| [[kbd:][<localleader> f]] | ~nix-update-fetch~ | -| [[kbd:][<localleader> o]] | ~+nix/lookup-option~ | -| [[kbd:][<localleader> p]] | ~nix-format-buffer~ | -| [[kbd:][<localleader> r]] | ~nix-repl-show~ | -| [[kbd:][<localleader> s]] | ~nix-repl-shell~ | -| [[kbd:][<localleader> u]] | ~nix-unpack~ | - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/nix/autoload.el b/.config/emacs/modules/lang/nix/autoload.el @@ -1,80 +0,0 @@ -;;; lang/nix/autoload.el -*- lexical-binding: t; -*- - -(defun +nix--options-action (candidate) - (switch-to-buffer-other-window - (nixos-options-doc-buffer - (nixos-options-get-documentation-for-option candidate)))) - -;;;###autoload -(defun +nix/open-repl () - "Open a nix repl." - (interactive) - (nix-repl-show) - (current-buffer)) - -;;;###autoload -(defun +nix/lookup-option (&optional initial-input) - "Look up documentation on a nix option." - (interactive - (list - ;; REVIEW Must be a better way to do this - (when (and (looking-at-p "[a-zA-Z0-9-_\\.]") - (not (doom-point-in-string-or-comment-p))) - (buffer-substring-no-properties - (save-excursion - (skip-chars-backward "^ ") - (point)) - (save-excursion - (skip-chars-forward "^ ") - (point)))))) - (cond ((modulep! :completion helm) - (require 'helm-nixos-options) - ;; REVIEW We reimplment `helm-nixos-options' so we can supply - ;; `initial-input'. Maybe use `helm-attrset' instead? - (helm :sources `(,(helm-source-nixos-options-search)) - :buffer "*helm-nixos-options*" - :input initial-input)) - ((modulep! :completion ivy) - (require 'nixos-options) - (ivy-read "NixOS options: " - nixos-options - :require-match t - :initial-input initial-input - :action #'+nix--options-action - :caller '+nix/options)) - ((+nix--options-action (cdr - (assoc - (completing-read "NixOs options: " - nixos-options - nil - t - initial-input) nixos-options))))) - ;; Tell lookup module to let us handle things from here - 'deferred) - -;;;###autoload -(defun +nix-shell-init-mode () - "Resolve a (cached-)?nix-shell shebang to the correct major mode." - (save-excursion - (goto-char (point-min)) - (save-match-data - (if (not (and (re-search-forward "\\_<nix-shell " (line-end-position 2) t) - (re-search-forward "-i +\"?\\([^ \"\n]+\\)" (line-end-position) t))) - (message "Couldn't determine mode for this script") - (let* ((interp (match-string 1)) - (mode - (assoc-default - interp - (mapcar (lambda (e) - (cons (format "\\`%s\\'" (car e)) - (cdr e))) - interpreter-mode-alist) - #'string-match-p))) - (when mode - (prog1 (set-auto-mode-0 mode) - (when (eq major-mode 'sh-mode) - (sh-set-shell interp)) - ;; HACK Without this, quickrun tries to evaluate code directly - ;; with (cached)?nix-shell. - ;; TODO Use the nix-shell/cached-nix-shell-given interpreter - (setq-local quickrun-option-shebang nil)))))))) diff --git a/.config/emacs/modules/lang/nix/config.el b/.config/emacs/modules/lang/nix/config.el @@ -1,53 +0,0 @@ -;;; lang/nix/config.el -*- lexical-binding: t; -*- - -(after! tramp - (add-to-list 'tramp-remote-path "/run/current-system/sw/bin")) - - -;; -;;; Plugins - -(use-package! nix-mode - :interpreter ("\\(?:cached-\\)?nix-shell" . +nix-shell-init-mode) - :mode "\\.nix\\'" - :init - ;; Treat flake.lock files as json. Fall back to js-mode because it's faster - ;; than js2-mode, and its extra features aren't needed there. - (add-to-list 'auto-mode-alist - (cons "/flake\\.lock\\'" - (if (modulep! :lang json) - 'json-mode - 'js-mode))) - :config - (set-repl-handler! 'nix-mode #'+nix/open-repl) - (set-company-backend! 'nix-mode 'company-nixos-options) - (set-lookup-handlers! 'nix-mode - :documentation '(+nix/lookup-option :async t)) - (set-popup-rule! "^\\*nixos-options-doc\\*$" :ttl 0 :quit t) - - ;; Fix #3927: disable idle completion because `company-nixos-options' is - ;; dreadfully slow. It can still be invoked manually.. - (setq-hook! 'nix-mode-hook company-idle-delay nil) - - (when (modulep! +lsp) - (add-hook 'nix-mode-local-vars-hook #'lsp! 'append)) - (when (modulep! +tree-sitter) - (add-hook 'nix-mode-local-vars-hook #'tree-sitter! 'append)) - - (map! :localleader - :map nix-mode-map - "f" #'nix-update-fetch - "p" #'nix-format-buffer - "r" #'nix-repl-show - "s" #'nix-shell - "b" #'nix-build - "u" #'nix-unpack - "o" #'+nix/lookup-option)) - - -(use-package! nix-update - :commands nix-update-fetch) - - -(use-package! nix-repl - :commands nix-repl-show) diff --git a/.config/emacs/modules/lang/nix/doctor.el b/.config/emacs/modules/lang/nix/doctor.el @@ -1,12 +0,0 @@ -;; -*- lexical-binding: t; no-byte-compile: t; -*- -;;; lang/nix/doctor.el - -(unless (executable-find "nix") - (warn! "Couldn't find the nix package manager. nix-mode won't work.")) - -(unless (executable-find "nixfmt") - (warn! "Couldn't find nixfmt. nix-format-buffer won't work.")) - -(assert! (or (not (modulep! +tree-sitter)) - (modulep! :tools tree-sitter)) - "This module requires (:tools tree-sitter)") diff --git a/.config/emacs/modules/lang/nix/packages.el b/.config/emacs/modules/lang/nix/packages.el @@ -1,11 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/nix/packages.el - -(package! nix-mode :pin "c18a24e9ac569a221e88ba9d74d52c7b02b6eb77") -(package! nix-update :pin "aab70a38165575a9cb41726f1cc67df60fbf2832") - -(when (modulep! :completion company) - (package! company-nixos-options :pin "053a2d5110ce05b7f99bcc2ac4804b70cbe87916")) - -(when (modulep! :completion helm) - (package! helm-nixos-options :pin "053a2d5110ce05b7f99bcc2ac4804b70cbe87916")) diff --git a/.config/emacs/modules/lang/ocaml/README.org b/.config/emacs/modules/lang/ocaml/README.org @@ -1,114 +0,0 @@ -#+title: :lang ocaml -#+subtitle: An objective camel -#+created: June 27, 2017 -#+since: 2.0.4 (#128) - -* Description :unfold: -This module adds [[https://ocaml.org/][OCaml]] support to Doom Emacs, powered by [[doom-package:tuareg-mode]]. - -- Code completion, documentation look-up, code navigation and refactoring - ([[doom-package:merlin]]) -- Type, documentation and function argument display on idle ([[doom-package:merlin-eldoc]]) -- REPL ([[doom-package:utop]]) -- Syntax-checking ([[doom-package:merlin]] with [[doom-package:flycheck-ocaml]]) -- Auto-indentation ([[doom-package:ocp-indent]]) -- Code formatting ([[doom-package:ocamlformat]]) -- Dune file format ([[doom-package:dune]]) - -** Maintainers -*This module needs a maintainer.* [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +lsp :: - Enable LSP support for ~tuareg-mode~. Requires [[doom-module::tools lsp]] and a langserver - (supports [[https://github.com/freebroccolo/ocaml-language-server][ocaml-language-server]]). -- +tree-sitter :: - Leverages tree-sitter for better syntax highlighting and structural text - editing. Requires [[doom-module::tools tree-sitter]]. - -** Packages -- [[doom-package:dune]] -- [[doom-package:ocamlformat]] if [[doom-module::editor format]] -- [[doom-package:ocp-indent]] -- [[doom-package:tuareg]] -- [[doom-package:utop]] if [[doom-module::tools eval]] -- unless [[doom-module:+lsp]] - - [[doom-package:flycheck-ocaml]] if [[doom-module::checkers syntax]] - - [[doom-package:merlin]] - - [[doom-package:merlin-company]] - - [[doom-package:merlin-eldoc]] - -** Hacks -- ~set-ligatures!~ is called with the full tuareg prettify symbol list, this can - cause columns to change as certain keywords are shortened (e.g. =fun= becomes - \lambda). -- ~tuareg-opam-update-env~ is called the first time [[doom-package:tuareg]] is loaded - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires the following packages available through [[http://opam.ocaml.org/][opam]]: -- merlin -- utop -- ocp-indent -- dune -- ocamlformat - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -- The following files should have syntax highlighting support: ~.ml{i,p,y,}~, - ~.eliom{i,}~, ~jbuild~, ~dune~, ~opam~ -- ~merlin-mode~ is activated whenever a =.merlin= file is found (including in a - parent directory) and =ocamlmerlin= executable is present -- Line-based auto-indentation is provided by =ocp-indent=, if it is available. - -| Command | Key | Description | -|------------------------------+-----------------+-----------------------------------------------------------| -| ~merlin-type-enclosing~ | [[kbd:][<localleader> t]] | display type under point | -| ~tuareg-find-alternate-file~ | [[kbd:][<localleader> a]] | switch between =.ml= and =.mli= | -| ~merlin-locate~ | [[kbd:][g d]] | lookup definition | -| ~merlin-occurences~ | [[kbd:][SPC c D]] | lookup references | -| ~merlin-document~ | [[kbd:][K]] | lookup documentation | -| ~merlin-imenu~ | [[kbd:][SPC s i]] | symbol lookup in file | -| ~merlin-iedit-occurrences~ | [[kbd:][v R]] | visual refactor identifier under point (multiple cursors) | -| ~utop~ | [[kbd:][SPC o r]] | open =utop= as REPL | -| ~utop-eval-region~ | [[kbd:][SPC c e]] | evaluate selected region in =utop= | - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -- If [[doom-module::completion company]] is enabled then autocomplete is provided by [[doom-package:merlin]] -- When [[doom-module::checkers syntax]] is enabled then [[doom-package:flycheck-ocaml]] is activated to do - on-the-fly syntax/type checking via [[doom-package:merlin]], otherwise this is only done when - the file is saved. -- Spell checking is activated in comments if [[doom-module::checkers spell]] is active -- A REPL is provided if [[doom-package:utop]] is installed and [[doom-module::tools eval]] is active -- If [[doom-module::editor format]] is enabled, the =ocamlformat= executable is available and - there is an =.ocamlformat= file present then ~format-all-buffer~ is bound to - =ocamlformat=, otherwise to =ocp-indent= -- If [[doom-module::editor multiple-cursors]] is enabled then identifiers can be refactored with - [[kbd:][v R]] and multiple cursors (this correctly matches identifier occurrences - according to scope, it is not purely a textual match) - -Run ~$ doom sync~ to install all packages and ~$ doom doctor~ to diagnose -missing tools. - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/ocaml/autoload.el b/.config/emacs/modules/lang/ocaml/autoload.el @@ -1,11 +0,0 @@ -;;; lang/ocaml/autoload.el -*- lexical-binding: t; -*- - -;;;###autoload -(defun +ocaml/comment-indent-new-line (&optional _) - "Break line at point and indent, continuing comment if within one." - (interactive) - (comment-indent-new-line) - (when (eq (char-before) ?*) - (just-one-space)) - (unless (eq (char-after) 32) - (save-excursion (insert " ")))) diff --git a/.config/emacs/modules/lang/ocaml/config.el b/.config/emacs/modules/lang/ocaml/config.el @@ -1,125 +0,0 @@ -;;; lang/ocaml/config.el -*- lexical-binding: t; -*- - -;; -;;; Packages - -(when (modulep! +lsp) - (add-hook! '(tuareg-mode-local-vars-hook - reason-mode-local-vars-hook) - :append #'lsp!)) - - -(after! tuareg - ;; tuareg-mode has the prettify symbols itself - (set-ligatures! 'tuareg-mode :alist - (append tuareg-prettify-symbols-basic-alist - tuareg-prettify-symbols-extra-alist)) - ;; harmless if `prettify-symbols-mode' isn't active - (setq tuareg-prettify-symbols-full t) - - ;; Use opam to set environment - (setq tuareg-opam-insinuate t) - (tuareg-opam-update-env (tuareg-opam-current-compiler)) - - (setq-hook! 'tuareg-mode-hook - comment-line-break-function #'+ocaml/comment-indent-new-line) - - (map! :localleader - :map tuareg-mode-map - "a" #'tuareg-find-alternate-file) - - (use-package! utop - :when (modulep! :tools eval) - :hook (tuareg-mode-local-vars . +ocaml-init-utop-h) - :init - (set-repl-handler! 'tuareg-mode #'utop) - (set-eval-handler! 'tuareg-mode #'utop-eval-region) - (defun +ocaml-init-utop-h () - (when (executable-find "utop") - (utop-minor-mode))) - :config - (set-popup-rule! "^\\*utop\\*" :quit nil))) - - -(use-package! merlin - :unless (modulep! +lsp) - :hook (tuareg-mode-local-vars . +ocaml-init-merlin-h) - :init - (defun +ocaml-init-merlin-h () - "Activate `merlin-mode' if the ocamlmerlin executable exists." - (when (executable-find "ocamlmerlin") - (merlin-mode))) - - (after! tuareg - (set-company-backend! 'tuareg-mode 'merlin-company-backend) - (set-lookup-handlers! 'tuareg-mode :async t - :definition #'merlin-locate - :references #'merlin-occurrences - :documentation #'merlin-document)) - :config - (setq merlin-completion-with-doc t) - - (map! :localleader - :map tuareg-mode-map - "t" #'merlin-type-enclosing) - - (use-package! flycheck-ocaml - :when (modulep! :checkers syntax) - :hook (merlin-mode . +ocaml-init-flycheck-h) - :config - (defun +ocaml-init-flycheck-h () - "Activate `flycheck-ocaml`" - ;; Disable Merlin's own error checking - (setq merlin-error-after-save nil) - ;; Enable Flycheck checker - (flycheck-ocaml-setup))) - - (use-package! merlin-eldoc - :hook (merlin-mode . merlin-eldoc-setup)) - - (use-package! merlin-iedit - :when (modulep! :editor multiple-cursors) - :defer t - :init - (map! :map tuareg-mode-map - :v "R" #'merlin-iedit-occurrences)) - - (use-package! merlin-imenu - :when (modulep! :emacs imenu) - :hook (merlin-mode . merlin-use-merlin-imenu))) - - -(use-package! ocp-indent - ;; must be careful to always defer this, it has autoloads that adds hooks - ;; which we do not want if the executable can't be found - :hook (tuareg-mode-local-vars . +ocaml-init-ocp-indent-h) - :config - (defun +ocaml-init-ocp-indent-h () - "Run `ocp-setup-indent', so long as the ocp-indent binary exists." - (when (executable-find "ocp-indent") - (ocp-setup-indent)))) - - -(use-package! ocamlformat - :when (modulep! :editor format) - :commands ocamlformat - :hook (tuareg-mode-local-vars . +ocaml-init-ocamlformat-h) - :config - (set-formatter! 'ocamlformat #'ocamlformat - :modes '(caml-mode tuareg-mode)) - ;; TODO Fix region-based formatting support - (defun +ocaml-init-ocamlformat-h () - (setq +format-with 'ocp-indent) - (when (and (executable-find "ocamlformat") - (locate-dominating-file default-directory ".ocamlformat")) - (when buffer-file-name - (let ((ext (file-name-extension buffer-file-name t))) - (cond ((equal ext ".eliom") - (setq-local ocamlformat-file-kind 'implementation)) - ((equal ext ".eliomi") - (setq-local ocamlformat-file-kind 'interface))))) - (setq +format-with 'ocamlformat)))) - -;; Tree sitter -(eval-when! (modulep! +tree-sitter) - (add-hook! 'tuareg-mode-local-vars-hook #'tree-sitter!)) diff --git a/.config/emacs/modules/lang/ocaml/doctor.el b/.config/emacs/modules/lang/ocaml/doctor.el @@ -1,28 +0,0 @@ -;; -*- lexical-binding: t; no-byte-compile: t; -*- -;;; lang/ocaml/doctor.el - -(assert! (or (not (modulep! +lsp)) - (modulep! :tools lsp)) - "This module requires (:tools lsp)") - -(assert! (or (not (modulep! +tree-sitter)) - (modulep! :tools tree-sitter)) - "This module requires (:tools tree-sitter)") - -(unless (executable-find "ocamlmerlin") - (warn! "Couldn't find ocamlmerlin. Lookup, completion and syntax checking won't work")) - -;; Tuareg can still indent -(unless (executable-find "ocp-indent") - (warn! "Couldn't find ocp-indent. Auto-indentation will be less precise")) - -(when (modulep! :tools eval) - (unless (executable-find "utop") - (warn! "Couldn't find utop. REPL won't be available"))) - -(unless (executable-find "dune") - (warn! "Couldn't find dune. Won't be able to highlight dune files")) - -(when (modulep! :editor format) - (unless (executable-find "ocamlformat") - (warn! "Couldn't find ocamlformat. Code-formatting will be unavailable"))) diff --git a/.config/emacs/modules/lang/ocaml/packages.el b/.config/emacs/modules/lang/ocaml/packages.el @@ -1,25 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/ocaml/packages.el - -(package! tuareg :pin "53ce2fdfdd372d52f3a6547c33b687e7d403357a") - -(unless (modulep! +lsp) - (package! merlin :pin "306af713e268d810ea0dc80bdf8e98265f96bd51") - (package! merlin-eldoc :pin "bf8edc63d85b35e4def352fa7ce4ea39f43e1fd8") - (package! merlin-company :pin "306af713e268d810ea0dc80bdf8e98265f96bd51") - (when (modulep! :checkers syntax) - (package! flycheck-ocaml :pin "77f8ddbd9bfc3a11957ac7ec7e45d5fa9179b192"))) - -(package! ocp-indent :pin "7c4d434132cebc15a8213c8be9e7323692eb0a2b") - -(when (modulep! :tools eval) - (package! utop :pin "ace481388a54fdf89244a76497fbdedb4ff15207")) - -(when (modulep! :editor format) - (package! ocamlformat - :recipe (:host github :repo "ocaml-ppx/ocamlformat" :files ("emacs/*.el")) - :pin "1ad4bdba9e1fd4a0bd73e22f75b3079c70cdba53")) - -(package! dune - :recipe (:host github :repo "ocaml/dune" :files ("editor-integration/emacs/*.el")) - :pin "f5a5a9c17be60b1cf2ec22fee35d35ccc3bb5e5e") diff --git a/.config/emacs/modules/lang/org/README.org b/.config/emacs/modules/lang/org/README.org @@ -1,307 +0,0 @@ -#+title: :lang org -#+subtitle: Organize your plain life in plain text -#+created: February 20, 2017 -#+since: 2.0.0 - -* Description :unfold: -This module adds org-mode support to Doom Emacs, along with a number of -adjustments, extensions and reasonable defaults to make it more performant and -intuitive out of the box: - -- A custom, centralized attachment system that stores files in one place, rather - than in the same directory as the input file(s) (only applies to attachments - from files in/under var:org-directory). -- Executable code blocks with support for a variety of languages and tools - (depending on what :lang modules are enabled). -- Supports an external org-capture workflow through the =bin/org-capture= shell - script and fn:+org-capture/open-frame. -- A configuration for using org-mode for slide-show presentations or exporting - org files to reveal.js slideshows. -- Drag-and-drop support for images (with inline preview) and media files (drops - a file icon and a short link) (requires [[doom-module:+dragndrop]] flag). -- Integration with pandoc, ipython, jupyter, reveal.js, beamer, and others - (requires flags). -- Export-to-clipboard functionality, for copying text into formatted html, - markdown or rich text to the clipboard (see fn:+org/export-to-clipboard and - fn:+org/export-to-clipboard-as-rich-text). - -#+begin_quote -Org is a system for writing plain text notes with syntax highlighting, code -execution, task scheduling, agenda management, and many more. The whole idea is -that you can write notes and mix them with references to things like articles, -images, and example code combined with the output of that code after it is -executed. - -https://www.mfoot.com/blog/2015/11/22/literate-emacs-configuration-with-org-mode/ -#+end_quote - -** Maintainers -- [[doom-user:][@hlissner]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +brain :: - Enable [[https://github.com/Kungsgeten/org-brain][org-brain]] integration. -- +contacts :: - Enable [[https://gitlab.com/aimebertrand/org-mac-link/][org-contacts]] integration. -- +dragndrop :: - Enable drag-and-drop support for images and files; inserts inline previews - for images and an icon+link for other media types. -- +gnuplot :: - Install gnuplot & gnuplot-mode, which enables rendering images from gnuplot - src blocks or plotting tables with fn:org-plot/gnuplot (bound to =SPC m b p=, - by default). -- +hugo :: - Enable integration with [[https://gohugo.io][hugo]] to export from Emacs well-formed ([[https://github.com/russross/blackfriday][blackfriday]]) - markdown. -- +ipython :: - (**DEPRECATED**) Enable ipython integration for babel. -- +journal :: - Enable [[doom-package:org-journal]] integration. -- +jupyter :: - Enable Jupyter integration for babel. -- +noter :: - Enable [[doom-package:org-noter]] integration. Keeps notes in sync with a document. Requires - [[doom-module::tools pdf]], [[https://www.gnu.org/software/emacs/manual/html_node/emacs/Document-View.html][DocView]], or [[https://github.com/wasamasa/nov.el][nov.el]] to be enabled. -- +pandoc :: - Enable pandoc integration into the Org exporter. -- +passwords :: - Enable [[https://github.com/alfaromurillo/org-passwords.el][org-passwords]] integration. -- +pomodoro :: - Enable a pomodoro timer for clocking time on tasks. -- +present :: - Enable integration with reveal.js, beamer and org-tree-slide, so Emacs can be - used for presentations. It automatically downloads [[https://github.com/hakimel/reveal.js][reveal.js]]. -- +pretty :: - Enable pretty unicode symbols for bullets+priorities and better syntax - highlighting for latex. Keep in mind: this can be expensive. If org becomes - too slow, it'd be wise to disable this flag. -- +roam :: - Enable integration with [[https://github.com/org-roam/org-roam-v1][org-roam v1]]. This requires ~sqlite3~ to be installed - on your system. /Incompatible with [[doom-module:+roam2]]./ -- +roam2 :: - Enable integration with [[https://github.com/org-roam/org-roam][org-roam v2]]. This requires ~sqlite3~ to be installed - on your system. /Incompatible with [[doom-module:+roam]]./ - -** Packages -- [[doom-package:evil-org]] if [[doom-module::editor evil]] -- [[doom-package:htmlize]] -- [[doom-package:jupyter]] if [[doom-module:+jupyter]] -- [[doom-package:ob-ammonite]] if [[doom-module::lang scala]] -- [[doom-package:ob-async]] -- [[doom-package:ob-crystal]] if [[doom-module::lang crystal]] -- [[doom-package:ob-go]] if [[doom-module::lang go]] -- [[doom-package:ob-ipython]] if [[doom-module:+ipython]] -- [[doom-package:ob-nim]] if [[doom-module::lang nim]] -- [[doom-package:ob-racket]] if [[doom-module::lang racket]] -- [[doom-package:ob-restclient]] if [[doom-module::lang rest]] -- [[doom-package:ob-rust]] if [[doom-module::lang rust]] -- [[doom-package:org-contacts]] if [[doom-module:+contacts]] -- [[doom-package:org-cliplink]] -- [[doom-package:org-download]] if [[doom-module:+dragndrop]] -- [[doom-package:orgit]] -- [[doom-package:org-noter]] if [[doom-module:+noter]] -- [[doom-package:org-pdftools]] if [[doom-module::tools pdf]] -- [[doom-package:org-plus-contrib]] -- [[doom-package:org-passwords]] if [[doom-module:+passwords]] -- [[doom-package:org-pomodoro]] if [[doom-module:+pomodoro]] -- [[doom-package:org-roam]] (v1) if [[doom-module:+roam]] -- [[doom-package:org-roam]] (v2) if [[doom-module:+roam2]] -- [[doom-package:org-yt]] -- [[doom-package:ox-clip]] -- [[doom-package:ox-hugo]] if [[doom-module:+hugo]] -- [[doom-package:ox-pandoc]] if [[doom-module:+pandoc]] -- [[doom-package:ox-rst]] if [[doom-module::lang rst]] -- [[doom-package:toc-org]] -- if [[doom-module:+gnuplot]] - - [[doom-package:gnuplot]] - - [[doom-package:gnuplot-mode]] -- if [[doom-module:+present]] - - [[doom-package:centered-window]] - - [[doom-package:org-tree-slide]] - - [[doom-package:org-re-reveal]] -- if [[doom-module:+pretty]] - - [[doom-package:org-superstar]] - - [[doom-package:org-fancy-priorities]] - -** Hacks -- Adds support for a ~:sync~ parameter for org src blocks. This overrides - ~:async~. -- Gracefully degrades ~:async~ babel blocks to ~:sync~ when [[doom-package:ob-async]] would cause - errors or issues (such as with a ~:session~ parameter, which [[doom-package:ob-async]] does not - support, or when exporting org documents). -- The window is recentered when following links. -- The breadcrumbs displayed in eldoc when hovering over an org headline has been - reworked to strip out link syntax and normalize font-size disparities. -- If [[doom-module::ui workspaces]] is enabled, persp-mode won't register org agenda buffers - that are temporarily opened in the background. -- Temporary org agenda files aren't added to recentf. -- =file:= links are highlighted with the [[face:error]] face if they are broken. -- TAB was changed to toggle only the visibility state of the current subtree, - rather than cycle through it recursively. This can be reversed with: - - #+begin_src emacs-lisp - (after! evil-org - (remove-hook 'org-tab-first-hook #'+org-cycle-only-current-subtree-h)) - #+end_src -- (Evil users) Nearby tables are formatted when exiting insert or replace mode - (see [[fn:+org-enable-auto-reformat-tables-h]]). -- Statistics cookies are updated when saving the buffer of exiting insert mode - (see [[fn:+org-enable-auto-update-cookies-h]]). -- Org-protocol has been lazy loaded (see [[fn:+org-init-protocol-lazy-loader-h]]); - loaded when the server receives a request for an =org-protocol://= url. -- Babel and babel plugins are now lazy loaded (see - [[fn:+org-init-babel-lazy-loader-h]]); loaded when a src block is executed. No need - to use [[var:org-babel-do-load-languages]] in your config, just install your babel - packages to extend language support (and ensure its ~org-babel-execute:*~ - function is autoloaded). -- If a variable is used as a file path in [[var:org-capture-template]], it will be - resolved relative to [[var:org-directory]], instead of [[var:default-directory]] (see - [[fn:+org--capture-expand-variable-file-a]]). - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module has no hard requirements, but these soft requirements are needed to -use Org's more esoteric features: -- For inline LaTeX previews, [[doom-executable:latex]] and [[doom-executable:dvipng]] is needed. -- To render GNUPlot images (with [[doom-module:+gnuplot]] flag) the [[doom-executable:gnuplot]] program is needed. -- To execute babel code blocks, you need whatever dependencies those languages - need. It is recommended you enable the associated [[doom-module::lang]] module and ensure its - dependencies are met, e.g. install the [[doom-executable:ruby]] executable for ruby support. To - use ~jupyter kernels~ you need the [[doom-module:+jupyter]] flag, the associated kernel as - well as the [[doom-executable:jupyter]] program. -- [[doom-package:org-roam]] (with [[doom-module:+roam]] or [[doom-module:+roam2]] flag) requires [[doom-executable:sqlite3]] to be installed. - -** MacOS -#+begin_src sh -brew install --cask mactex -brew install gnuplot -#+end_src - -** Arch Linux -#+begin_src sh -pacman -S texlive-core texlive-bin texlive-science texlive-latexextra -pacman -S gnuplot -pacman -S jupyter # required by +jupyter -#+end_src - -** NixOS -#+begin_src nix -environment.systemPackages = with pkgs; [ - # any less than medium isn't guaranteed to work - texlive.combined.scheme-medium - # required by +jupyter - (python38.withPackages(ps: with ps; [jupyter])) -]; -#+end_src - -** TODO Windows - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** Invoking the org-capture frame from outside Emacs -The simplest way to use the org-capture frame is through the ~bin/org-capture~ -script. I'd recommend binding a shortcut key to it. If Emacs isn't running, it -will spawn a temporary daemon for you. - -Alternatively, you can call ~+org-capture/open-frame~ directly, e.g. -#+begin_src sh -emacsclient --eval '(+org-capture/open-frame INITIAL-INPUT KEY)' -#+end_src - -** Built-in custom link types -This module defines a number of custom link types in ~+org-init-custom-links-h~. -They are (with examples): - -- ~doom-docs:index.org~ -> =~/.emacs.d/docs/%s= -- ~doom-modules:editor/evil/README.org~ -> =~/.emacs.d/modules/%s= -- ~doom-repo:issues~ -> =https://github.com/hlissner/doom-emacs/%s= -- ~doom:core/core.el~ -> =~/.emacs.d/%s= -- ~duckduckgo:search terms~ -- ~gimages:search terms~ (Google Images) -- ~github:hlissner/doom-emacs~ -- ~gmap:Toronto, Ontario~ (Google Maps) -- ~google:search terms~ -- ~org:todo.org~ -> ={org-directory}/%s= -- ~wolfram:sin(x^3)~ -- ~wikipedia:Emacs~ -- ~youtube:P196hEuA_Xc~ (link only) -- ~yt:P196hEuA_Xc~ (like =youtube=, but includes an inline preview of the video) - -** evil-mode keybindings -For =evil-mode= users, an overview of org-mode keybindings is provided [[https://github.com/Somelauw/evil-org-mode/blob/master/README.org#keybindings][here]]. - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** Changing ~org-directory~ -~org-directory~ must be set /before/ [[doom-package:org]] has loaded: -#+begin_src emacs-lisp -;; in $DOOMDIR/config.el -(setq org-directory "~/new/org/location/") -#+end_src - -** Changing ~org-noter-notes-search-path~ -#+begin_src emacs-lisp -;; in $DOOMDIR/config.el -(setq org-noter-notes-search-path '("~/notes/path/")) -#+end_src - -* Troubleshooting -[[doom-report:][Report an issue?]] - -** =org-roam= -*** Should I go with =+roam= (v1) or =+roam2= (v2)? -Long story short: if you're new to [[doom-package:org-roam]] and haven't used it, then you should -go with [[doom-module:+roam2]]; if you already have an ~org-roam-directory~ with the v1 files in -it, then you can keep use [[doom-module:+roam]] for the time being, but it will eventually be -removed, so you should [[https://www.orgroam.com/manual.html#How-to-migrate-from-Org_002droam-v1_003f][migrate]] at your earliest convenience. - -V1 isn't actively maintained anymore and is now basically EOL. This means that -the feature disparity between the both will continue to grow, while its existing -bugs and problems won't be addressed, at least by the main maintainers. V2 can -be considered as a complete rewrite of the package so it comes with a lot of -breaking changes. - -To learn more about v2 you can use the next resources: -- [[https://github.com/org-roam/org-roam/blob/master/doc/org-roam.org][Org-roam v2 Official Manual]] -- [[https://github.com/org-roam/org-roam/wiki/Hitchhiker's-Rough-Guide-to-Org-roam-V2][Hitchhiker's Rough Guide to Org roam V2]] -- [[https://blog.jethro.dev/posts/org_roam_v2/][Releasing Org-roam v2 - Jethro Kuan's blog]] -- [[https://org-roam.discourse.group/t/org-roam-major-redesign/1198][Thread about the redesign from Org-Roam Discourse]] - -*** Migrating your existing files from v1 (=+roam=) to v2 (=+roam2=) -V2 comes with a migration wizard for v1 users. It's new, which means issues can -appear during the migration process. Because of that, *don't forget to backup* -your ~org-roam-directory~ before attempting to migrate. - -In order to migrate from v1 to v2 using Doom follow the next steps: -1. Enable [[doom-module:+roam2]] flag (and disable [[doom-module:+roam]] if it was previously enabled) in your - =init.el=. -2. Ensure your ~org-roam-directory~ points to a directory with your v1 files. -3. Run ~$ doom sync -u~ in your shell. -4. Restart Emacs (if it was previously opened) and run ~org-roam-migrate-wizard~ - command (~M-x org-roam-migrate-wizard RET~). The wizard will automatically - attempt to backup your previous ~org-roam-directory~ to =org-roam.bak=, but - just in case backup it yourself too. -4. After the wizard is done you should be good to go. Verify the integrity of - your data and whether it did everything as expected. In case of failure - [[https://github.com/org-roam/org-roam/issues][report]] your issue. - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/org/autoload/contrib-ipython.el b/.config/emacs/modules/lang/org/autoload/contrib-ipython.el @@ -1,152 +0,0 @@ -;;; lang/org/autoload/contrib-ipython.el -*- lexical-binding: t; -*- -;;;###if (modulep! +ipython) - -;;;###autoload -(defun +org-ob-ipython-initiate-session-a (&optional session params) - "Create a session named SESSION according to PARAMS." - (if (string= session "none") - (error - "ob-ipython currently only supports evaluation using a session. -Make sure your src block has a :session param.") - (when (not (string-suffix-p ".json" session t)) - (ob-ipython--create-kernel - (ob-ipython--normalize-session - session) - (cdr (assoc :kernel params)))) - (ob-ipython--create-repl - (ob-ipython--normalize-session - session) - params))) - -(defun +org--ob-ipython-generate-local-path-from-remote (session host params) - "Given a remote SESSION with PARAMS and corresponding HOST, copy remote config to local, start a jupyter console to generate a new one." - (let* ((runtime-dir - (cdr - (doom-call-process "ssh " host "jupyter" "--runtime-dir"))) - (runtime-file (concat runtime-dir "/" "kernel-" session ".json")) - (tramp-path (concat "/ssh:" host ":" runtime-file)) - (tramp-copy (concat (or +ob-ipython-local-runtime-dir - (cdr (doom-call-process "jupyter" "--runtime-dir"))) - "/remote-" host "-kernel-" session ".json")) - (local-path - (concat - "Python:ob-ipython-" - (file-name-sans-extension (file-name-nondirectory tramp-copy)) - "-ssh.json"))) - ;; scp remote file to local - (copy-file tramp-path tramp-copy t) - ;; connect to remote use new config - (let* ((python-shell-interpreter-interactive-arg " console --simple-prompt") - (python-shell-prompt-detect-enabled nil) - (python-shell-completion-native-enable nil) - (buf (python-shell-make-comint - (concat ob-ipython-command - " console --simple-prompt --existing " - tramp-copy " --ssh " host) - (concat "" local-path) - t)) - (proc (get-buffer-process buf)) - (dir (cdr (assoc :pydir params)))) - (sleep-for 3) - (when dir - (with-current-buffer buf - (setq-local default-directory dir))) - (format "*%s*" proc)))) - -;;;###autoload -(defun +org-ob-ipython-create-repl-a (name &optional params) - "Create repl based on NAME and PARAMS. -If PARAMS specifies remote kernel, copy the kernel config from remote server and -create a repl connecting to remote session." - (let ((cmd (string-join (ob-ipython--kernel-repl-cmd name) " "))) - (cond ((string= "default" name) - (run-python cmd nil nil) - (format "*%s*" python-shell-buffer-name)) - ((string-match "^remote-.*ssh.json" name) - (when (not (ignore-errors - (process-live-p - (get-process - (format - "Python:ob-ipython-%s" - name))))) - (let* ((remote (s-split "-" name)) - (remote-host (nth 1 remote)) - (remote-session (nth 3 remote))) - (+org--ob-ipython-generate-local-path-from-remote - remote-session - remote-host - params)))) - ((let* ((process-name (format "Python:ob-ipython-%s" name)) - (python-shell-prompt-detect-enabled nil) - (python-shell-completion-native-enable nil) - (buf (python-shell-make-comint cmd process-name t)) - (dir (cdr (assoc :pydir params)))) - (if dir - (with-current-buffer buf - (setq-local default-directory dir))) - (sleep-for 1) - (format "*%s*" process-name)))))) - -;;;###autoload -(defun +org-babel-execute:ipython-a (body params) - "Execute a BODY of IPython code with PARAMS in org-babel. -This function is called by `org-babel-execute-src-block'." - (message default-directory) - (org-babel-ipython-initiate-session (cdr (assoc :session params)) - params)) - - -;; -;; * org-src-edit - -;;;###autoload -(defun +org-babel-edit-prep:ipython-a (info) - (let* ((params (nth 2 info)) - (session (cdr (assoc :session params)))) - (org-babel-ipython-initiate-session session params)) - ;; Support for python.el's "send-code" commands within edit buffers. - (setq-local python-shell-buffer-name - (format "Python:ob-ipython-%s" - (ob-ipython--normalize-session - (cdr (assoc :session (nth 2 info)))))) - (setq-local default-directory - (format "%s" - (ob-ipython--normalize-session - (cdr (assoc :pydir (nth 2 info)))))) - (ob-ipython-mode 1) - ;; hack on company mode to use company-capf rather than company-anaconda - (when (modulep! :completion company) - (setq-local company-backends - '(company-capf - company-dabbrev - company-files - company-yasnippet)) - (setq-local company-idle-delay nil)) - (when (featurep 'lpy) - (setq lispy-python-proc - (format "Python:ob-ipython-%s" - (ob-ipython--normalize-session - (cdr (assoc :session (nth 2 info))))) - lispy--python-middleware-loaded-p nil) - (lispy--python-middleware-load))) - - -;; -;; * retina - -(defun +org--ob-ipython-mac-2x-image-file-name (filename &optional scale) - "Return the name of high-resolution image file for FILENAME. -The optional arg SCALE is scale factor, and defaults to 2." - (let ((pos (or (string-match "\\.[^./]*\\'" filename) (length filename)))) - (format "%s@%dx%s" - (substring filename 0 pos) - (or scale 2) - (substring filename pos)))) - -;;;###autoload -(defun +org-ob-ipython-write-base64-string-a (oldfunc &rest args) - (let ((file (car args)) - (b64-string (cdr args))) - (let ((file2x (+org--ob-ipython-mac-2x-image-file-name file))) - (apply oldfunc file2x b64-string) - (shell-command (concat "convert " file2x " -resize 50% " file))))) diff --git a/.config/emacs/modules/lang/org/autoload/contrib-present.el b/.config/emacs/modules/lang/org/autoload/contrib-present.el @@ -1,87 +0,0 @@ -;;; lang/org/autoload/contrib-present.el -*- lexical-binding: t; -*- -;;;###if (modulep! +present) - -;; -;;; Helpers - -(defun +org-present--cleanup-org-tree-slides-mode () - (unless (cl-loop for buf in (doom-buffers-in-mode 'org-mode) - if (buffer-local-value 'org-tree-slide-mode buf) - return t) - (org-tree-slide-mode -1) - (remove-hook 'kill-buffer-hook #'+org-present--cleanup-org-tree-slides-mode - 'local))) - - -;; -;;; Hooks - -;;;###autoload -(defun +org-present-hide-blocks-h () - "Hide org #+ constructs." - (save-excursion - (goto-char (point-min)) - (while (re-search-forward "^[[:space:]]*\\(#\\+\\)\\(\\(?:BEGIN\\|END\\|ATTR\\)[^[:space:]]+\\).*" nil t) - (org-fold-region (match-beginning 1) - (match-end 0) - org-tree-slide-mode - 'block)))) - -;;;###autoload -(defun +org-present-hide-leading-stars-h () - "Hide leading stars in headings." - (save-excursion - (goto-char (point-min)) - (while (re-search-forward "^\\(\\*+\\)" nil t) - (org-fold-region (match-beginning 1) - (match-end 1) - org-tree-slide-mode - 'headline)))) - -;;;###autoload -(defun +org-present-detect-slide-h () - "TODO" - (outline-show-all) - (if (member "title" (org-get-tags)) - (text-scale-set 10) - (text-scale-set +org-present-text-scale))) - -(defvar cwm-use-vertical-padding) -(defvar cwm-frame-internal-border) -(defvar cwm-left-fringe-ratio) -(defvar cwm-centered-window-width) -(defvar +org-present--last-wconf nil) -;;;###autoload -(defun +org-present-prettify-slide-h () - "Set up the org window for presentation." - (let ((arg (if org-tree-slide-mode +1 -1))) - (if (not org-tree-slide-mode) - (when +org-present--last-wconf - (set-window-configuration +org-present--last-wconf)) - (setq +org-present--last-wconf (current-window-configuration)) - (doom/window-maximize-buffer)) - (when (fboundp 'centered-window-mode) - (setq-local cwm-use-vertical-padding t) - (setq-local cwm-frame-internal-border 100) - (setq-local cwm-left-fringe-ratio -10) - (setq-local cwm-centered-window-width 300) - (centered-window-mode arg)) - (hide-mode-line-mode arg) - (+org-pretty-mode arg) - (cond (org-tree-slide-mode - (set-window-fringes nil 0 0) - (when (bound-and-true-p flyspell-mode) - (flyspell-mode -1)) - (add-hook 'kill-buffer-hook #'+org-present--cleanup-org-tree-slides-mode - nil 'local) - (text-scale-set +org-present-text-scale) - (ignore-errors (org-latex-preview '(4)))) - (t - (text-scale-set 0) - (pcase (type-of fringe-mode) - ((or 'integer 'symbol) (set-window-fringes nil fringe-mode fringe-mode)) - ('cons (set-window-fringes nil (car fringe-mode) (cdr fringe-mode)))) - (org-clear-latex-preview) - (org-remove-inline-images) - (org-mode))) - (redraw-display))) diff --git a/.config/emacs/modules/lang/org/autoload/contrib-roam2.el b/.config/emacs/modules/lang/org/autoload/contrib-roam2.el @@ -1,131 +0,0 @@ -;;; lang/org/autoload/contrib-roam2.el -*- lexical-binding: t; -*- -;;;###if (modulep! +roam2) - -;;; Custom node accessors -;;;###autoload (autoload 'org-roam-node-doom-filetitle "lang/org/autoload/contrib-roam2" nil t) -(cl-defmethod org-roam-node-doom-filetitle ((node org-roam-node)) - "Return the value of \"#+title:\" (if any) from file that NODE resides in. -If there's no file-level title in the file, return empty string." - (or (if (= (org-roam-node-level node) 0) - (org-roam-node-title node) - (org-roam-node-file-title node)) - "")) - -;;;###autoload (autoload 'org-roam-node-doom-hierarchy "lang/org/autoload/contrib-roam2" nil t) -(cl-defmethod org-roam-node-doom-hierarchy ((node org-roam-node)) - "Return hierarchy for NODE, constructed of its file title, OLP and direct title. -If some elements are missing, they will be stripped out." - (let ((title (org-roam-node-title node)) - (olp (org-roam-node-olp node)) - (level (org-roam-node-level node)) - (filetitle (org-roam-node-doom-filetitle node)) - (separator (propertize org-eldoc-breadcrumb-separator 'face 'shadow))) - (cl-case level - ;; node is a top-level file - (0 filetitle) - ;; node is a level 1 heading - (1 (concat (propertize filetitle 'face '(shadow italic)) - separator title)) - ;; node is a heading with an arbitrary outline path - (t (concat (propertize filetitle 'face '(shadow italic)) - separator (propertize (string-join olp separator) 'face '(shadow italic)) - separator title))))) - -;;;###autoload (autoload 'org-roam-node-doom-subdirs "lang/org/autoload/contrib-roam2" nil t) -(cl-defmethod org-roam-node-doom-subdirs ((node org-roam-node)) - "Return subdirectories of `org-roam-directory' in which NODE resides in. -If there's none, return an empty string." - (thread-first - node - (org-roam-node-file) - (file-relative-name org-roam-directory) - (file-name-directory))) - -;;;###autoload (autoload 'org-roam-node-doom-tags "lang/org/autoload/contrib-roam2" nil t) -(cl-defmethod org-roam-node-doom-tags ((node org-roam-node)) - "Return tags formatted in the same way how they appear in org files." - (cl-remove-if (doom-rpartial - #'member (delq - nil (append - (list (bound-and-true-p org-archive-tag) - (bound-and-true-p org-attach-auto-tag)) - (bound-and-true-p org-num-skip-tags)))) - (org-roam-node-tags node))) - -;;;###autoload (autoload 'org-roam-node-doom-type "lang/org/autoload/contrib-roam2" nil t) -(cl-defmethod org-roam-node-doom-type ((node org-roam-node)) - "Return the directory relative to `org-roam-directory' as a note's \"type\"." - (when-let (dir (thread-first - node - (org-roam-node-file) - (file-relative-name org-roam-directory) - (file-name-directory))) - (directory-file-name dir))) - - -;; -;;; Hooks - -;;;###autoload -(defun +org-roam-manage-backlinks-buffer-h () - "Open or close roam backlinks buffer depending on visible org-roam buffers. - -Intended to be added to `doom-switch-buffer-hook' in `org-roam-find-file-hook'. -Controlled by `+org-roam-open-buffer-on-find-file'." - (when (and +org-roam-auto-backlinks-buffer - (not org-roam-capture--node) ; not for roam capture buffers - (not org-capture-mode) ; not for capture buffers - (not (bound-and-true-p +popup-buffer-mode))) - (let ((visible-p (eq 'visible (org-roam-buffer--visibility)))) - (if (cl-some #'org-roam-buffer-p (doom-visible-buffers)) - (unless visible-p - (org-roam-buffer-toggle)) - (when visible-p - (org-roam-buffer-toggle)) - (unless (doom-buffers-in-mode 'org-mode) - (remove-hook 'doom-switch-buffer-hook #'+org-roam-manage-backlinks-buffer-h)))))) - - -;; -;;; Advice - -;;;###autoload -(defun org-roam-link-follow-link-with-description-a (args) - "Use a 'roam:X' link's description if X is empty." - (when (or (string-empty-p (car args)) - (null (car args))) - (setcar - args (let ((link (org-element-context))) - (and (org-element-property :contents-begin link) - (org-element-property :contents-end link) - (buffer-substring-no-properties - (org-element-property :contents-begin link) - (org-element-property :contents-end link)))))) - args) - -;;;###autoload -(defun org-roam-link-replace-at-point-a (&optional link) - "Replace \"roam:\" LINK at point with an \"id:\" link." - (save-excursion - (save-match-data - (let* ((link (or link (org-element-context))) - (type (org-element-property :type link)) - (path (org-element-property :path link)) - (desc (and (org-element-property :contents-begin link) - (org-element-property :contents-end link) - (buffer-substring-no-properties - (org-element-property :contents-begin link) - (org-element-property :contents-end link)))) - node) - (goto-char (org-element-property :begin link)) - (when (and (org-in-regexp org-link-any-re 1) - (string-equal type "roam") - ;; Added `desc' ref here - (setq node (save-match-data - (org-roam-node-from-title-or-alias - (if (string-empty-p path) - desc - path))))) - (replace-match (org-link-make-string - (concat "id:" (org-roam-node-id node)) - (or desc path)))))))) diff --git a/.config/emacs/modules/lang/org/autoload/org-attach.el b/.config/emacs/modules/lang/org/autoload/org-attach.el @@ -1,59 +0,0 @@ -;;; lang/org/autoload/org-attach.el -*- lexical-binding: t; -*- - -;;;###autoload -(defun +org-attach-icon-for (path) - (char-to-string - (pcase (downcase (file-name-extension path)) - ((or "jpg" "jpeg" "png" "gif") ?) - ("pdf" ?) - ((or "ppt" "pptx") ?) - ((or "xls" "xlsx") ?) - ((or "doc" "docx") ?) - ((or "ogg" "mp3" "wav" "aiff" "flac") ?) - ((or "mp4" "mov" "avi") ?) - ((or "zip" "gz" "tar" "7z" "rar") ?) - (_ ?)))) - -;;;###autoload -(defun +org/open-gallery-from-attachments () - "TODO" - (interactive) - (require 'org-attach) - (if-let (dir (org-attach-dir)) - (pop-to-buffer - ;; Rather than opening dired *and* image-dired windows, suppress them - ;; both and open only the image-dired window. - (save-window-excursion - (image-dired dir) - (current-buffer))) - (user-error "No attachments for this node"))) - -;;;###autoload -(defun +org/find-file-in-attachments () - "Open a file from `org-attach-id-dir'." - (interactive) - (doom-project-browse org-attach-id-dir)) - -;;;###autoload -(defun +org/attach-file-and-insert-link (path) - "Downloads the file at PATH and insert an org link at point. -PATH (a string) can be an url, a local file path, or a base64 encoded datauri." - (interactive "sUri/file: ") - (unless (eq major-mode 'org-mode) - (user-error "Not in an org buffer")) - (require 'org-download) - (condition-case-unless-debug e - (let ((raw-uri (url-unhex-string path))) - (cond ((string-match-p "^data:image/png;base64," path) - (org-download-dnd-base64 path nil)) - ((image-type-from-file-name raw-uri) - (org-download-image raw-uri)) - ((let ((new-path (expand-file-name (org-download--fullname raw-uri)))) - ;; Download the file - (if (string-match-p (concat "^" (regexp-opt '("http" "https" "nfs" "ftp" "file")) ":/") path) - (url-copy-file raw-uri new-path) - (copy-file path new-path)) - ;; insert the link - (org-download-insert-link raw-uri new-path))))) - (error - (user-error "Failed to attach file: %s" (error-message-string e))))) diff --git a/.config/emacs/modules/lang/org/autoload/org-avy.el b/.config/emacs/modules/lang/org/autoload/org-avy.el @@ -1,20 +0,0 @@ -;;; lang/org/autoload/org-avy.el -*- lexical-binding: t; -*- - -;;;###autoload -(defun +org-headline-avy () - "TODO" - (require 'avy) - (save-excursion - (when-let* ((org-reverse-note-order t) - (pos (avy-with avy-goto-line (avy-jump (rx bol (1+ "*") (1+ blank)))))) - (when (integerp (car pos)) - ;; If avy is aborted with "C-g", it returns `t', so we know it was NOT - ;; aborted when it returns an int. If it doesn't return an int, we - ;; return nil. - (copy-marker (car pos)))))) - -;;;###autoload -(defun +org/goto-visible () - "TODO" - (interactive) - (goto-char (+org-headline-avy))) diff --git a/.config/emacs/modules/lang/org/autoload/org-babel.el b/.config/emacs/modules/lang/org/autoload/org-babel.el @@ -1,91 +0,0 @@ -;;; lang/org/autoload/org-babel.el -*- lexical-binding: t; -*- - -;;;###autoload -(defun +org-eval-handler (beg end) - "TODO" - (save-excursion - (if (not (cl-loop for pos in (list beg (point) end) - if (save-excursion (goto-char pos) (org-in-src-block-p t)) - return (goto-char pos))) - (message "Nothing to evaluate at point") - (let* ((element (org-element-at-point)) - (block-beg (save-excursion - (goto-char (org-babel-where-is-src-block-head element)) - (line-beginning-position 2))) - (block-end (save-excursion - (goto-char (org-element-property :end element)) - (skip-chars-backward " \t\n") - (line-beginning-position))) - (beg (if beg (max beg block-beg) block-beg)) - (end (if end (min end block-end) block-end)) - (lang (or (org-eldoc-get-src-lang) - (user-error "No lang specified for this src block")))) - (cond ((and (string-prefix-p "jupyter-" lang) - (require 'jupyter nil t)) - (jupyter-eval-region beg end)) - ((let ((major-mode (org-src-get-lang-mode lang))) - (+eval/region beg end)))))))) - - -;;;###autoload -(defun +org-lookup-definition-handler (identifier) - "TODO" - (when (org-in-src-block-p t) - (let ((mode (org-src-get-lang-mode - (or (org-eldoc-get-src-lang) - (user-error "No lang specified for this src block"))))) - (cond ((and (eq mode 'emacs-lisp-mode) - (fboundp '+emacs-lisp-lookup-definition)) - (+emacs-lisp-lookup-definition identifier) - 'deferred) - ((user-error "Definition lookup in SRC blocks isn't supported yet")))))) - -;;;###autoload -(defun +org-lookup-references-handler (identifier) - "TODO" - (when (org-in-src-block-p t) - (user-error "References lookup in SRC blocks isn't supported yet"))) - -;;;###autoload -(defun +org-lookup-documentation-handler (identifier) - "TODO" - (when (org-in-src-block-p t) - (let ((mode (org-src-get-lang-mode - (or (org-eldoc-get-src-lang) - (user-error "No lang specified for this src block")))) - (info (org-babel-get-src-block-info t))) - (cond ((string-prefix-p "jupyter-" (car info)) - (and (require 'jupyter nil t) - (call-interactively #'jupyter-inspect-at-point) - (display-buffer (help-buffer)) - 'deferred)) - ((and (eq mode 'emacs-lisp-mode) - (fboundp '+emacs-lisp-lookup-documentation)) - (+emacs-lisp-lookup-documentation identifier) - 'deferred) - ((user-error "Documentation lookup in SRC blocks isn't supported yet")))))) - - -;; -;;; Commands - -;;;###autoload -(defun +org/remove-result-blocks (remove-all) - "Remove all result blocks located after current point." - (interactive "P") - (let ((pos (point))) - (org-babel-map-src-blocks nil - (if (or remove-all (< pos end-block)) - (org-babel-remove-result))))) - - -;; -;;; Hooks - -;;;###autoload -(defun +org-clear-babel-results-h () - "Remove the results block for the org babel block at point." - (when (and (org-in-src-block-p t) - (org-babel-where-is-src-block-result)) - (org-babel-remove-result) - t)) diff --git a/.config/emacs/modules/lang/org/autoload/org-capture.el b/.config/emacs/modules/lang/org/autoload/org-capture.el @@ -1,163 +0,0 @@ -;;; lang/org/autoload/org-capture.el -*- lexical-binding: t; -*- - -(defvar org-capture-initial) - - -;; -;;; External frame - -(defvar +org-capture-fn #'org-capture - "Command to use to initiate org-capture.") - -;;;###autoload -(defvar +org-capture-frame-parameters - `((name . "doom-capture") - (width . 70) - (height . 25) - (transient . t) - ,@(when IS-LINUX - `((window-system . ,(if (boundp 'pgtk-initialized) 'pgtk 'x)) - (display . ,(or (getenv "WAYLAND_DISPLAY") - (getenv "DISPLAY") - ":0")))) - ,(if IS-MAC '(menu-bar-lines . 1))) - "TODO") - -;;;###autoload -(defun +org-capture-cleanup-frame-h () - "Closes the org-capture frame once done adding an entry." - (when (and (+org-capture-frame-p) - (not org-capture-is-refiling)) - (delete-frame nil t))) - -;;;###autoload -(defun +org-capture-frame-p (&rest _) - "Return t if the current frame is an org-capture frame opened by -`+org-capture/open-frame'." - (and (equal (alist-get 'name +org-capture-frame-parameters) - (frame-parameter nil 'name)) - (frame-parameter nil 'transient))) - -;;;###autoload -(defun +org-capture/open-frame (&optional initial-input key) - "Opens the org-capture window in a floating frame that cleans itself up once -you're done. This can be called from an external shell script." - (interactive) - (when (and initial-input (string-empty-p initial-input)) - (setq initial-input nil)) - (when (and key (string-empty-p key)) - (setq key nil)) - (let* ((frame-title-format "") - (frame (if (+org-capture-frame-p) - (selected-frame) - (make-frame +org-capture-frame-parameters)))) - (select-frame-set-input-focus frame) ; fix MacOS not focusing new frames - (with-selected-frame frame - (require 'org-capture) - (condition-case ex - (letf! ((#'pop-to-buffer #'switch-to-buffer)) - (switch-to-buffer (doom-fallback-buffer)) - (let ((org-capture-initial initial-input) - org-capture-entry) - (when (and key (not (string-empty-p key))) - (setq org-capture-entry (org-capture-select-template key))) - (funcall +org-capture-fn))) - ('error - (message "org-capture: %s" (error-message-string ex)) - (delete-frame frame)))))) - -;;;###autoload -(defun +org-capture-available-keys () - "TODO" - (string-join (mapcar #'car org-capture-templates) "")) - - -;; -;;; Capture targets - -;;;###autoload -(defun +org-capture-todo-file () - "Expand `+org-capture-todo-file' from `org-directory'. -If it is an absolute path return `+org-capture-todo-file' verbatim." - (expand-file-name +org-capture-todo-file org-directory)) - -;;;###autoload -(defun +org-capture-notes-file () - "Expand `+org-capture-notes-file' from `org-directory'. -If it is an absolute path return `+org-capture-todo-file' verbatim." - (expand-file-name +org-capture-notes-file org-directory)) - -(defun +org--capture-local-root (path) - (let ((filename (file-name-nondirectory path))) - (expand-file-name - filename - (or (locate-dominating-file (file-truename default-directory) - filename) - (doom-project-root) - (user-error "Couldn't detect a project"))))) - -;;;###autoload -(defun +org-capture-project-todo-file () - "Find the nearest `+org-capture-todo-file' in a parent directory, otherwise, -opens a blank one at the project root. Throws an error if not in a project." - (+org--capture-local-root +org-capture-todo-file)) - -;;;###autoload -(defun +org-capture-project-notes-file () - "Find the nearest `+org-capture-notes-file' in a parent directory, otherwise, -opens a blank one at the project root. Throws an error if not in a project." - (+org--capture-local-root +org-capture-notes-file)) - -;;;###autoload -(defun +org-capture-project-changelog-file () - "Find the nearest `+org-capture-changelog-file' in a parent directory, -otherwise, opens a blank one at the project root. Throws an error if not in a -project." - (+org--capture-local-root +org-capture-changelog-file)) - -(defun +org--capture-ensure-heading (headings &optional initial-level) - (if (not headings) - (widen) - (let ((initial-level (or initial-level 1))) - (if (and (re-search-forward (format org-complex-heading-regexp-format - (regexp-quote (car headings))) - nil t) - (= (org-current-level) initial-level)) - (progn - (beginning-of-line) - (org-narrow-to-subtree)) - (goto-char (point-max)) - (unless (and (bolp) (eolp)) (insert "\n")) - (insert (make-string initial-level ?*) - " " (car headings) "\n") - (beginning-of-line 0)) - (+org--capture-ensure-heading (cdr headings) (1+ initial-level))))) - -(defun +org--capture-central-file (file project) - (let ((file (expand-file-name file org-directory))) - (set-buffer (org-capture-target-buffer file)) - (org-capture-put-target-region-and-position) - (widen) - (goto-char (point-min)) - ;; Find or create the project headling - (+org--capture-ensure-heading - (append (org-capture-get :parents) - (list project (org-capture-get :heading)))))) - -;;;###autoload -(defun +org-capture-central-project-todo-file () - "TODO" - (+org--capture-central-file - +org-capture-projects-file (projectile-project-name))) - -;;;###autoload -(defun +org-capture-central-project-notes-file () - "TODO" - (+org--capture-central-file - +org-capture-projects-file (projectile-project-name))) - -;;;###autoload -(defun +org-capture-central-project-changelog-file () - "TODO" - (+org--capture-central-file - +org-capture-projects-file (projectile-project-name))) diff --git a/.config/emacs/modules/lang/org/autoload/org-export.el b/.config/emacs/modules/lang/org/autoload/org-export.el @@ -1,53 +0,0 @@ -;;; lang/org/autoload/org-export.el -*- lexical-binding: t; -*- - -(defun +org--yank-html-buffer (buffer) - (with-current-buffer buffer - (require 'ox-clip) - (cond ((or IS-WINDOWS IS-MAC) - (shell-command-on-region - (point-min) - (point-max) - (cond (IS-WINDOWS ox-clip-w32-cmd) - (IS-MAC ox-clip-osx-cmd)))) - (IS-LINUX - (let ((html (buffer-string))) - (with-temp-file (make-temp-file "ox-clip-md" nil ".html") - (insert html)) - (apply #'start-process "ox-clip" "*ox-clip*" - (split-string ox-clip-linux-cmd " "))))))) - - -;; -;;; Commands - -;;;###autoload -(defun +org/export-to-clipboard (backend) - "Exports the current buffer/selection to the clipboard. - -Prompts for what BACKEND to use. See `org-export-backends' for options." - (interactive - (list (intern (completing-read "Export to: " (progn (require 'ox) org-export-backends))))) - (require 'ox) - (let* ((org-export-show-temporary-export-buffer nil) - (buffer (org-export-to-buffer backend "*Formatted Copy*" nil nil t t))) - (unwind-protect - (with-current-buffer buffer - (kill-new (buffer-string))) - (kill-buffer buffer)))) - -;;;###autoload -(defun +org/export-to-clipboard-as-rich-text (beg end) - "Export the current buffer to HTML then copies it to clipboard as rich text. - -Supports org-mode, markdown-mode, and gfm-mode buffers. In any other mode, -htmlize is used (takes what you see in Emacs and converts it to html, text -properties and font-locking et all)." - (interactive "r") - (pcase major-mode - ((or `markdown-mode `gfm-mode) - (+org--yank-html-buffer (markdown))) - (_ - ;; Omit after/before-string overlay properties in htmlized regions, so we - ;; don't get fringe characters for things like flycheck or git-gutter. - (letf! (defun htmlize-add-before-after-strings (_beg _end text) text) - (ox-clip-formatted-copy beg end))))) diff --git a/.config/emacs/modules/lang/org/autoload/org-link.el b/.config/emacs/modules/lang/org/autoload/org-link.el @@ -1,456 +0,0 @@ -;;; lang/org/autoload/org-link.el -*- lexical-binding: t; -*- - -(defun +org--relative-path (path root) - (if (and buffer-file-name (file-in-directory-p buffer-file-name root)) - (file-relative-name path) - path)) - -(defun +org--read-link-path (key dir &optional fn) - (let ((file (funcall (or fn #'read-file-name) (format "%s: " (capitalize key)) dir))) - (format "%s:%s" key (file-relative-name file dir)))) - -;;;###autoload -(defun +org-define-basic-link (key dir-var &rest plist) - "Define a link with some basic completion & fontification. - -KEY is the name of the link type. DIR-VAR is the directory variable to resolve -links relative to. PLIST is passed to `org-link-set-parameters' verbatim. - -Links defined with this will be rendered in the `error' face if the file doesn't -exist, and `org-link' otherwise." - (declare (indent 2)) - (let ((requires (plist-get plist :requires)) - (dir-fn (if (functionp dir-var) - dir-var - (lambda () (symbol-value dir-var))))) - (apply #'org-link-set-parameters - key - :complete (lambda () - (if requires (mapc #'require (ensure-list requires))) - (+org--relative-path (+org--read-link-path key (funcall dir-fn)) - (funcall dir-fn))) - :follow (lambda (link) - (org-link-open-as-file (expand-file-name link (funcall dir-fn)) nil)) - :face (lambda (link) - (let* ((path (expand-file-name link (funcall dir-fn))) - (option-index (string-match-p "::\\(.*\\)\\'" path)) - (file-name (substring path 0 option-index))) - (if (file-exists-p file-name) - 'org-link - 'error))) - (plist-put plist :requires nil)))) - -;;;###autoload -(defun +org-link-read-desc-at-point (&optional default context) - "TODO" - (if (and (stringp default) (not (string-empty-p default))) - (string-trim default) - (if-let* ((context (or context (org-element-context))) - (context (org-element-lineage context '(link) t)) - (beg (org-element-property :contents-begin context)) - (end (org-element-property :contents-end context))) - (unless (= beg end) - (replace-regexp-in-string - "[ \n]+" " " (string-trim (buffer-substring-no-properties beg end))))))) - -;;;###autoload -(defun +org-link-read-kbd-at-point (&optional default context) - "TODO" - (+org-link--describe-kbd - (+org-link-read-desc-at-point default context))) - -(defun +org-link--describe-kbd (keystr) - (dolist (key `(("<leader>" . ,doom-leader-key) - ("<localleader>" . ,doom-localleader-key) - ("<prefix>" . ,(if (bound-and-true-p evil-mode) - (concat doom-leader-key " u") - "C-u")) - ("<help>" . ,(if (bound-and-true-p evil-mode) - (concat doom-leader-key " h") - "C-h")) - ("\\<M-" . "alt-") - ("\\<S-" . "shift-") - ("\\<s-" . "super-") - ("\\<C-" . "ctrl-"))) - (setq keystr - (replace-regexp-in-string (car key) (cdr key) - keystr t t))) - keystr) - -(defun +org-link--read-module-spec (module-spec-str) - (if (string-prefix-p "+" (string-trim-left module-spec-str)) - (let ((title (cadar (org-collect-keywords '("TITLE"))))) - (if (and title (string-match-p "\\`:[a-z]+ [A-Za-z0-9]+\\'" title)) - (+org-link--read-module-spec (concat title " " module-spec-str)) - (list :category nil :module nil :flag (intern module-spec-str)))) - (cl-destructuring-bind (category &optional module flag) - (mapcar #'intern (split-string - (if (string-prefix-p ":" module-spec-str) - module-spec-str - (concat ":" module-spec-str)) - "[ \n]+" nil)) - (list :category category - :module module - :flag flag)))) - -;;;###autoload -(defun +org-link--var-link-activate-fn (start end var _bracketed-p) - (when buffer-read-only - (add-text-properties - start end - (list 'display - (concat - #(" " 0 1 - (rear-nonsticky - t display (raise 0.05) - face (:family "github-octicons" - :inherit font-lock-variable-name-face - :height 0.8 - :box (:line-width 1 :style none))) - 1 2 (face (:height 0.2))) - var))))) - -;;;###autoload -(defun +org-link--fn-link-activate-fn (start end fn _bracketed-p) - (when buffer-read-only - (add-text-properties - start end - (list 'display - (concat - #("λ " 0 1 (face (:inherit font-lock-function-name-face - :box (:line-width 1 :style none) - :height 0.9)) - 1 2 (face (:height 0.2))) - fn))))) - -;;;###autoload -(defun +org-link--face-link-activate-face (start end face _bracketed-p) - (when buffer-read-only - (add-text-properties - start end - (list 'display - (concat - (propertize - "" - 'rear-nonsticky t - 'display '(raise -0.02) - 'face (list '(:family "file-icons" :height 1.0) - (if (facep (intern face)) - (intern face) - 'default) - '(:underline nil))) - #(" " 0 1 (face (:underline nil))) - face))))) - -(defun +org-link--command-keys (command) - "Convert command reference TEXT to key binding representation." - (let* ((cmd-prefix (mapcar #'reverse - (split-string (reverse command) " "))) - (cmd (intern-soft (car cmd-prefix))) - (prefix (and (cdr cmd-prefix) - (string-join (reverse (cdr cmd-prefix)) " "))) - (key-binding (where-is-internal cmd nil t)) - (key-text (if key-binding - (key-description key-binding) - (format "M-x %s" cmd)))) - (concat prefix (and prefix " ") key-text))) - -;;;###autoload -(defun +org-link--command-link-activate-command (start end command _bracketed-p) - (when buffer-read-only - (add-text-properties - start end (list 'display (+org-link--command-keys command))))) - -;;;###autoload -(defun +org-link--doom-module-link-follow-fn (module-path _arg) - (cl-destructuring-bind (&key category module flag) - (+org-link--read-module-spec module-path) - (when category - (let ((doom-modules-dirs (list doom-modules-dir))) - (if-let* ((path (doom-module-locate-path category module)) - (path (or (car (doom-glob path "README.org")) - path))) - (find-file path) - (user-error "Can't find Doom module '%s'" module-path)))) - (when flag - (goto-char (point-min)) - (when (and (re-search-forward "^\\*+ \\(?:TODO \\)?Module flags") - (re-search-forward (format "^\\s-*- \\+%s ::[ \n]" - (substring (symbol-name flag) 1)) - (save-excursion (org-get-next-sibling) - (point)))) - (org-show-entry) - (recenter))))) - -;;;###autoload -(defun +org-link--doom-module-link-face-fn (module-path) - (cl-destructuring-bind (&key category module flag) - (+org-link--read-module-spec module-path) - (if (and category (doom-module-locate-path category module)) - `(:inherit org-priority - :weight bold) - 'error))) - -;;;###autoload -(defun +org-link--doom-module-link-activate-fn (start end module-path _bracketed-p) - (when buffer-read-only - (cl-destructuring-bind (&key category module flag) - (+org-link--read-module-spec module-path) - (let ((overall-face - (cond - ((doom-module-p category module flag) - '((:underline nil) org-link org-block bold)) - ((and category (doom-module-locate-path category module)) - '(shadow org-block bold)) - (t '((:strike-through t) error org-block)))) - (icon-face - (if (doom-module-p category module flag) 'success 'error))) - (add-text-properties - start end - (list 'face overall-face - 'display - (concat - (propertize - " " - 'rear-nonsticky t - 'display '(raise -0.02) - 'face `(:inherit ,icon-face - :family "FontAwesome" - :height 1.0)) - module-path))))))) - -;;;###autoload -(defun +org-link--doom-package-link-activate-fn (start end package _bracketed-p) - (when buffer-read-only - (let ((overall-face - (if (locate-library package) - '((:underline nil) org-link org-block italic) - '(shadow org-block italic))) - (pkg-face - (cond - ((featurep (intern package)) 'success) - ((locate-library package) 'warning) - (t 'error)))) - (add-text-properties - start end - (list 'face overall-face - 'display - (concat - (propertize - "\uf0c4" ; Octicon package symbol - 'rear-nonsticky t - 'display '(raise -0.02) - 'face `(:family "github-octicons" :height 1.0 - :inherit ,pkg-face)) - " " package)))))) - -;;;###autoload -(defun +org-link-follow-doom-package-fn (pkg _prefixarg) - "TODO" - (doom/describe-package (intern-soft pkg))) - -;;;###autoload -(defun +org-link--doom-executable-link-activate-fn (start end executable _bracketed-p) - (when buffer-read-only - (let ((found (executable-find executable))) - (add-text-properties - start end - (list 'display - (concat - (propertize - "" - 'rear-nonsticky t - 'display '(raise -0.02) - 'face (list :family "all-the-icons" - :height 1.0 - :inherit (if found 'success 'error))) - " " - (propertize - executable - 'face (if found 'org-verbatim 'default)))))))) - -;; -;;; Help-echo / eldoc - -(defadvice! doom-docs--display-docs-link-in-eldoc-a (&rest _) - "Display help for doom-*: links in minibuffer when cursor/mouse is over it." - :before-until #'org-eldoc-documentation-function - (and (bound-and-true-p doom-docs-mode) - (eq (get-text-property (point) 'help-echo) - #'+org-link-doom--help-echo-from-textprop) - (+org-link-doom--help-echo-from-textprop nil (current-buffer) (point)))) - -(defvar +org-link-doom--help-echo-cache nil) - -(defun +org-link-doom--help-echo-from-textprop (_window object pos) - (let ((link (with-current-buffer object - (save-excursion (goto-char pos) (org-element-context))))) - (if (eq (car +org-link-doom--help-echo-cache) - (org-element-property :begin link)) - (cdr +org-link-doom--help-echo-cache) - (cdr (setq +org-link-doom--help-echo-cache - (cons (org-element-property :begin link) - (+org-link-doom--help-string link))))))) - -(defun +org-link-doom--help-string (link) - (if (not buffer-read-only) - (format "LINK: %s" (org-element-property :raw-link link)) - (pcase (org-element-property :type link) - ("kbd" - (concat - "The key sequence " - (propertize (+org-link--describe-kbd (org-element-property :path link)) - 'face 'help-key-binding))) - ("cmd" - (concat - "The command " - (propertize (org-element-property :path link) 'face 'font-lock-function-name-face) - " can be invoked with the key sequence " - (propertize (+org-link--command-keys (org-element-property :path link)) - 'face 'help-key-binding))) - ("doom-package" - (concat - (propertize "Emacs package " 'face 'bold) - (propertize (org-element-property :path link) 'face 'font-lock-keyword-face) - ", currently " - (cond - ((featurep (intern-soft (org-element-property :path link))) - (propertize "installed and loaded" 'face 'success)) - ((locate-library (org-element-property :path link)) - (propertize "installed but not loaded" 'face 'warning)) - (t (propertize "not installed" 'face 'error ))))) - ("doom-module" - (concat - (propertize "Doom module " 'face 'bold) - (propertize (org-element-property :path link) 'face 'font-lock-keyword-face) - ", currently " - (cl-destructuring-bind (&key category module flag) - (+org-link--read-module-spec (org-element-property :path link)) - (cond - ((doom-module-p category module) - (propertize "enabled" 'face 'success)) - ((and category (doom-module-locate-path category module)) - (propertize "disabled" 'face 'error)) - (t (propertize "unknown" 'face '(bold error))))))) - ("doom-executable" - (concat - (propertize "System executable " 'face 'bold) - (propertize (org-element-property :path link) 'face 'font-lock-keyword-face) - ", " - (if (executable-find (org-element-property :path link)) - (propertize "found" 'face 'success) - (propertize "not found" 'face 'error)) - " on PATH"))))) - -;; -;;; Image data functions (for custom inline images) - -;;;###autoload -(defun +org-image-file-data-fn (protocol link _description) - "Intepret LINK as an image file path and return its data." - (setq - link (expand-file-name - 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 - (set-buffer-multibyte nil) - (setq buffer-file-coding-system 'binary) - (insert-file-contents-literally link) - (buffer-substring-no-properties (point-min) (point-max))))) - -;;;###autoload -(defun +org-inline-image-data-fn (_protocol link _description) - "Interpret LINK as base64-encoded image data." - (base64-decode-string link)) - -;;;###autoload -(defun +org-http-image-data-fn (protocol link _description) - "Interpret LINK as an URL to an image file." - (when (and (image-type-from-file-name link) - (not (eq org-display-remote-inline-images 'skip))) - (if-let (buf (url-retrieve-synchronously (concat protocol ":" link))) - (with-current-buffer buf - (goto-char (point-min)) - (re-search-forward "\r?\n\r?\n" nil t) - (buffer-substring-no-properties (point) (point-max))) - (message "Download of image \"%s\" failed" link) - nil))) - -(defvar +org--gif-timers nil) -;;;###autoload -(defun +org-play-gif-at-point-h () - "Play the gif at point, while the cursor remains there (looping)." - (dolist (timer +org--gif-timers (setq +org--gif-timers nil)) - (when (timerp (cdr timer)) - (cancel-timer (cdr timer))) - (image-animate (car timer) nil 0)) - (when-let* ((ov (cl-find-if - (lambda (it) (overlay-get it 'org-image-overlay)) - (overlays-at (point)))) - (dov (overlay-get ov 'display)) - (pt (point))) - (when (image-animated-p dov) - (push (cons - dov (run-with-idle-timer - 0.5 nil - (lambda (dov) - (when (equal - ov (cl-find-if - (lambda (it) (overlay-get it 'org-image-overlay)) - (overlays-at (point)))) - (message "playing gif") - (image-animate dov nil t))) - dov)) - +org--gif-timers)))) - -;;;###autoload -(defun +org-play-all-gifs-h () - "Continuously play all gifs in the visible buffer." - (dolist (ov (overlays-in (point-min) (point-max))) - (when-let* (((overlay-get ov 'org-image-overlay)) - (dov (overlay-get ov 'display)) - ((image-animated-p dov)) - (w (selected-window))) - (while-no-input - (run-with-idle-timer - 0.3 nil - (lambda (dov) - (when (pos-visible-in-window-p (overlay-start ov) w nil) - (unless (plist-get (cdr dov) :animate-buffer) - (image-animate dov)))) - dov))))) - - -;; -;;; Commands - -;;;###autoload -(defun +org/remove-link () - "Unlink the text at point." - (interactive) - (unless (org-in-regexp org-link-bracket-re 1) - (user-error "No link at point")) - (save-excursion - (let ((label (if (match-end 2) - (match-string-no-properties 2) - (org-link-unescape (match-string-no-properties 1))))) - (delete-region (match-beginning 0) (match-end 0)) - (insert label)))) - -;;;###autoload -(defun +org/play-gif-at-point () - "TODO" - (interactive) - (unless (eq 'org-mode major-mode) - (user-error "Not in org-mode")) - (or (+org-play-gif-at-point-h) - (user-error "No gif at point"))) diff --git a/.config/emacs/modules/lang/org/autoload/org-refile.el b/.config/emacs/modules/lang/org/autoload/org-refile.el @@ -1,101 +0,0 @@ -;;; lang/org/autoload/org-refile.el -*- lexical-binding: t; -*- - -;; REVIEW These are all proof-of-concept. Refactor me! - -;;;###autoload -(defun +org/refile-to-current-file (arg &optional file) - "Refile current heading to elsewhere in the current buffer. -If prefix ARG, copy instead of move." - (interactive "P") - (let ((org-refile-targets `((,file :maxlevel . 10))) - (org-refile-use-outline-path t) - (org-refile-keep arg) - current-prefix-arg) - (call-interactively #'org-refile))) - -;;;###autoload -(defun +org/refile-to-file (arg file) - "Refile current heading to a particular org file. -If prefix ARG, copy instead of move." - (interactive - (list current-prefix-arg - (read-file-name "Select file to refile to: " - default-directory - (buffer-file-name (buffer-base-buffer)) - t nil - (lambda (f) (string-match-p "\\.org$" f))))) - (+org/refile-to-current-file arg file)) - -;;;###autoload -(defun +org/refile-to-other-window (arg) - "Refile current heading to an org buffer visible in another window. -If prefix ARG, copy instead of move." - (interactive "P") - (let ((org-refile-keep arg) - org-refile-targets - current-prefix-arg) - (dolist (win (delq (selected-window) (window-list))) - (with-selected-window win - (let ((file (buffer-file-name (buffer-base-buffer)))) - (and (eq major-mode 'org-mode) - file - (cl-pushnew (cons file (cons :maxlevel 10)) - org-refile-targets))))) - (call-interactively #'org-refile))) - -;;;###autoload -(defun +org/refile-to-other-buffer (arg) - "Refile current heading to another, living org buffer. -If prefix ARG, copy instead of move." - (interactive "P") - (let ((org-refile-keep arg) - org-refile-targets - current-prefix-arg) - (dolist (buf (delq (current-buffer) (doom-buffers-in-mode 'org-mode))) - (when-let (file (buffer-file-name (buffer-base-buffer buf))) - (cl-pushnew (cons file (cons :maxlevel 10)) - org-refile-targets))) - (call-interactively #'org-refile))) - -;;;###autoload -(defun +org/refile-to-running-clock (arg) - "Refile current heading to the currently clocked in task. -If prefix ARG, copy instead of move." - (interactive "P") - (unless (bound-and-true-p org-clock-current-task) - (user-error "No active clock to refile to")) - (let ((org-refile-keep arg)) - (org-refile 2))) - -;;;###autoload -(defun +org/refile-to-last-location (arg) - "Refile current heading to the last node you refiled to. -If prefix ARG, copy instead of move." - (interactive "P") - (or (assoc (plist-get org-bookmark-names-plist :last-refile) - bookmark-alist) - (user-error "No saved location to refile to")) - (let ((org-refile-keep arg) - (completing-read-function - (lambda (_p _coll _pred _rm _ii _h default &rest _) - default))) - (org-refile))) - -(defvar org-after-refile-insert-hook) -;; Inspired by org-teleport and alphapapa/alpha-org -;;;###autoload -(defun +org/refile-to-visible () - "Refile current heading as first child of visible heading selected with Avy." - (interactive) - (when-let (marker (+org-headline-avy)) - (let* ((buffer (marker-buffer marker)) - (filename - (buffer-file-name (or (buffer-base-buffer buffer) - buffer))) - (heading - (org-with-point-at marker - (org-get-heading 'no-tags 'no-todo))) - ;; Won't work with target buffers whose filename is nil - (rfloc (list heading filename nil marker)) - (org-after-refile-insert-hook (cons #'org-reveal org-after-refile-insert-hook))) - (org-refile nil nil rfloc)))) diff --git a/.config/emacs/modules/lang/org/autoload/org-tables.el b/.config/emacs/modules/lang/org/autoload/org-tables.el @@ -1,96 +0,0 @@ -;;; lang/org/autoload/org-tables.el -*- lexical-binding: t; -*- - -;; -;;; Row/Column traversal - -;;;###autoload -(defun +org/table-previous-row () - "Go to the previous row (same column) in the current table. Before doing so, -re-align the table if necessary. (Necessary because org-mode has a -`org-table-next-row', but not `org-table-previous-row')" - (interactive) - (org-table-maybe-eval-formula) - (org-table-maybe-recalculate-line) - (if (and org-table-automatic-realign - org-table-may-need-update) - (org-table-align)) - (let ((col (org-table-current-column))) - (beginning-of-line 0) - (when (or (not (org-at-table-p)) (org-at-table-hline-p)) - (beginning-of-line)) - (org-table-goto-column col) - (skip-chars-backward "^|\n\r") - (when (org-looking-at-p " ") - (forward-char)))) - - -;; -;;; Row/Column insertion - -;;;###autoload -(defun +org/table-insert-column-left () - "Insert a new column left of the current column." - (interactive) - (org-table-insert-column) - (org-table-move-column-left)) - -;;;###autoload -(defun +org/table-insert-row-below () - "Insert a new row below the current row." - (interactive) - (org-table-insert-row 'below)) - - -;; -;;; Hooks - -;;;###autoload -(defun +org-realign-table-maybe-h () - "Auto-align table under cursor." - (when (and org-table-automatic-realign (org-at-table-p) org-table-may-need-update) - (let ((pt (point)) - (inhibit-message t)) - (if org-table-may-need-update (org-table-align)) - (goto-char pt)))) - -;;;###autoload -(defun +org-enable-auto-reformat-tables-h () - "Realign tables & update formulas when exiting insert mode (`evil-mode'). -Meant for `org-mode-hook'." - (when (featurep 'evil) - (add-hook 'evil-insert-state-exit-hook #'+org-realign-table-maybe-h nil t) - (add-hook 'evil-replace-state-exit-hook #'+org-realign-table-maybe-h nil t) - (advice-add #'evil-replace :after #'+org-realign-table-maybe-a))) - -;;;###autoload -(defun +org-delete-backward-char-and-realign-table-maybe-h () - "Ensure deleting characters with backspace doesn't deform the table cell." - (when (eq major-mode 'org-mode) - (org-check-before-invisible-edit 'delete-backward) - (save-match-data - (when (and (org-at-table-p) - (not (org-region-active-p)) - (string-match-p "|" (buffer-substring (point-at-bol) (point))) - (looking-at-p ".*?|")) - (let ((pos (point)) - (noalign (looking-at-p "[^|\n\r]* |")) - (c org-table-may-need-update)) - (delete-char -1) - (unless overwrite-mode - (skip-chars-forward "^|") - (insert " ") - (goto-char (1- pos))) - ;; noalign: if there were two spaces at the end, this field - ;; does not determine the width of the column. - (when noalign (setq org-table-may-need-update c))) - t)))) - - -;; -;;; Advice - -;;;###autoload -(defun +org-realign-table-maybe-a (&rest _) - "Auto-align table under cursor and re-calculate formulas." - (when (eq major-mode 'org-mode) - (+org-realign-table-maybe-h))) diff --git a/.config/emacs/modules/lang/org/autoload/org.el b/.config/emacs/modules/lang/org/autoload/org.el @@ -1,520 +0,0 @@ -;;; lang/org/autoload/org.el -*- lexical-binding: t; -*- - -;; -;;; Helpers - -(defun +org--toggle-inline-images-in-subtree (&optional beg end refresh) - "Refresh inline image previews in the current heading/tree." - (let* ((beg (or beg - (if (org-before-first-heading-p) - (save-excursion (point-min)) - (save-excursion (org-back-to-heading) (point))))) - (end (or end - (if (org-before-first-heading-p) - (save-excursion (org-next-visible-heading 1) (point)) - (save-excursion (org-end-of-subtree) (point))))) - (overlays (cl-remove-if-not (lambda (ov) (overlay-get ov 'org-image-overlay)) - (ignore-errors (overlays-in beg end))))) - (dolist (ov overlays nil) - (delete-overlay ov) - (setq org-inline-image-overlays (delete ov org-inline-image-overlays))) - (when (or refresh (not overlays)) - (org-display-inline-images t t beg end) - t))) - -(defun +org--insert-item (direction) - (let ((context (org-element-lineage - (org-element-context) - '(table table-row headline inlinetask item plain-list) - t))) - (pcase (org-element-type context) - ;; Add a new list item (carrying over checkboxes if necessary) - ((or `item `plain-list) - (let ((orig-point (point))) - ;; Position determines where org-insert-todo-heading and `org-insert-item' - ;; insert the new list item. - (if (eq direction 'above) - (org-beginning-of-item) - (end-of-line)) - (let* ((ctx-item? (eq 'item (org-element-type context))) - (ctx-cb (org-element-property :contents-begin context)) - ;; Hack to handle edge case where the point is at the - ;; beginning of the first item - (beginning-of-list? (and (not ctx-item?) - (= ctx-cb orig-point))) - (item-context (if beginning-of-list? - (org-element-context) - context)) - ;; Horrible hack to handle edge case where the - ;; line of the bullet is empty - (ictx-cb (org-element-property :contents-begin item-context)) - (empty? (and (eq direction 'below) - ;; in case contents-begin is nil, or contents-begin - ;; equals the position end of the line, the item is - ;; empty - (or (not ictx-cb) - (= ictx-cb - (1+ (point)))))) - (pre-insert-point (point))) - ;; Insert dummy content, so that `org-insert-item' - ;; inserts content below this item - (when empty? - (insert " ")) - (org-insert-item (org-element-property :checkbox context)) - ;; Remove dummy content - (when empty? - (delete-region pre-insert-point (1+ pre-insert-point)))))) - ;; Add a new table row - ((or `table `table-row) - (pcase direction - ('below (save-excursion (org-table-insert-row t)) - (org-table-next-row)) - ('above (save-excursion (org-shiftmetadown)) - (+org/table-previous-row)))) - - ;; Otherwise, add a new heading, carrying over any todo state, if - ;; necessary. - (_ - (let ((level (or (org-current-level) 1))) - ;; I intentionally avoid `org-insert-heading' and the like because they - ;; impose unpredictable whitespace rules depending on the cursor - ;; position. It's simpler to express this command's responsibility at a - ;; lower level than work around all the quirks in org's API. - (pcase direction - (`below - (let (org-insert-heading-respect-content) - (goto-char (line-end-position)) - (org-end-of-subtree) - (insert "\n" (make-string level ?*) " "))) - (`above - (org-back-to-heading) - (insert (make-string level ?*) " ") - (save-excursion (insert "\n")))) - (run-hooks 'org-insert-heading-hook) - (when-let* ((todo-keyword (org-element-property :todo-keyword context)) - (todo-type (org-element-property :todo-type context))) - (org-todo - (cond ((eq todo-type 'done) - ;; Doesn't make sense to create more "DONE" headings - (car (+org-get-todo-keywords-for todo-keyword))) - (todo-keyword) - ('todo))))))) - - (when (org-invisible-p) - (org-show-hidden-entry)) - (when (and (bound-and-true-p evil-local-mode) - (not (evil-emacs-state-p))) - (evil-insert 1)))) - -;;;###autoload -(defun +org-get-todo-keywords-for (&optional keyword) - "Returns the list of todo keywords that KEYWORD belongs to." - (when keyword - (cl-loop for (type . keyword-spec) - in (cl-remove-if-not #'listp org-todo-keywords) - for keywords = - (mapcar (lambda (x) (if (string-match "^\\([^(]+\\)(" x) - (match-string 1 x) - x)) - keyword-spec) - if (eq type 'sequence) - if (member keyword keywords) - return keywords))) - - -;; -;;; Modes - -;;;###autoload -(define-minor-mode +org-pretty-mode - "Hides emphasis markers and toggles pretty entities." - :init-value nil - :lighter " *" - :group 'evil-org - (setq org-hide-emphasis-markers +org-pretty-mode) - (org-toggle-pretty-entities) - (with-silent-modifications - ;; In case the above un-align tables - (org-table-map-tables 'org-table-align t))) - - -;; -;;; Commands - -;;;###autoload -(defun +org/return () - "Call `org-return' then indent (if `electric-indent-mode' is on)." - (interactive) - (org-return electric-indent-mode)) - -;;;###autoload -(defun +org/dwim-at-point (&optional arg) - "Do-what-I-mean at point. - -If on a: -- checkbox list item or todo heading: toggle it. -- citation: follow it -- headline: cycle ARCHIVE subtrees, toggle latex fragments and inline images in - subtree; update statistics cookies/checkboxes and ToCs. -- clock: update its time. -- footnote reference: jump to the footnote's definition -- footnote definition: jump to the first reference of this footnote -- timestamp: open an agenda view for the time-stamp date/range at point. -- table-row or a TBLFM: recalculate the table's formulas -- table-cell: clear it and go into insert mode. If this is a formula cell, - recaluclate it instead. -- babel-call: execute the source block -- statistics-cookie: update it. -- src block: execute it -- latex fragment: toggle it. -- link: follow it -- otherwise, refresh all inline images in current tree." - (interactive "P") - (if (button-at (point)) - (call-interactively #'push-button) - (let* ((context (org-element-context)) - (type (org-element-type context))) - ;; skip over unimportant contexts - (while (and context (memq type '(verbatim code bold italic underline strike-through subscript superscript))) - (setq context (org-element-property :parent context) - type (org-element-type context))) - (pcase type - ((or `citation `citation-reference) - (org-cite-follow context arg)) - - (`headline - (cond ((memq (bound-and-true-p org-goto-map) - (current-active-maps)) - (org-goto-ret)) - ((and (fboundp 'toc-org-insert-toc) - (member "TOC" (org-get-tags))) - (toc-org-insert-toc) - (message "Updating table of contents")) - ((string= "ARCHIVE" (car-safe (org-get-tags))) - (org-force-cycle-archived)) - ((or (org-element-property :todo-type context) - (org-element-property :scheduled context)) - (org-todo - (if (eq (org-element-property :todo-type context) 'done) - (or (car (+org-get-todo-keywords-for (org-element-property :todo-keyword context))) - 'todo) - 'done)))) - ;; Update any metadata or inline previews in this subtree - (org-update-checkbox-count) - (org-update-parent-todo-statistics) - (when (and (fboundp 'toc-org-insert-toc) - (member "TOC" (org-get-tags))) - (toc-org-insert-toc) - (message "Updating table of contents")) - (let* ((beg (if (org-before-first-heading-p) - (line-beginning-position) - (save-excursion (org-back-to-heading) (point)))) - (end (if (org-before-first-heading-p) - (line-end-position) - (save-excursion (org-end-of-subtree) (point)))) - (overlays (ignore-errors (overlays-in beg end))) - (latex-overlays - (cl-find-if (lambda (o) (eq (overlay-get o 'org-overlay-type) 'org-latex-overlay)) - overlays)) - (image-overlays - (cl-find-if (lambda (o) (overlay-get o 'org-image-overlay)) - overlays))) - (+org--toggle-inline-images-in-subtree beg end) - (if (or image-overlays latex-overlays) - (org-clear-latex-preview beg end) - (org--latex-preview-region beg end)))) - - (`clock (org-clock-update-time-maybe)) - - (`footnote-reference - (org-footnote-goto-definition (org-element-property :label context))) - - (`footnote-definition - (org-footnote-goto-previous-reference (org-element-property :label context))) - - ((or `planning `timestamp) - (org-follow-timestamp-link)) - - ((or `table `table-row) - (if (org-at-TBLFM-p) - (org-table-calc-current-TBLFM) - (ignore-errors - (save-excursion - (goto-char (org-element-property :contents-begin context)) - (org-call-with-arg 'org-table-recalculate (or arg t)))))) - - (`table-cell - (org-table-blank-field) - (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))) - - (`babel-call - (org-babel-lob-execute-maybe)) - - (`statistics-cookie - (save-excursion (org-update-statistics-cookies arg))) - - ((or `src-block `inline-src-block) - (org-babel-execute-src-block arg)) - - ((or `latex-fragment `latex-environment) - (org-latex-preview arg)) - - (`link - (let* ((lineage (org-element-lineage context '(link) t)) - (path (org-element-property :path lineage))) - (if (or (equal (org-element-property :type lineage) "img") - (and path (image-type-from-file-name path))) - (+org--toggle-inline-images-in-subtree - (org-element-property :begin lineage) - (org-element-property :end lineage)) - (org-open-at-point arg)))) - - (`paragraph - (+org--toggle-inline-images-in-subtree)) - - ((guard (org-element-property :checkbox (org-element-lineage context '(item) t))) - (let ((match (and (org-at-item-checkbox-p) (match-string 1)))) - (org-toggle-checkbox (if (equal match "[ ]") '(16))))) - - (_ - (if (or (org-in-regexp org-ts-regexp-both nil t) - (org-in-regexp org-tsr-regexp-both nil t) - (org-in-regexp org-link-any-re nil t)) - (call-interactively #'org-open-at-point) - (+org--toggle-inline-images-in-subtree - (org-element-property :begin context) - (org-element-property :end context)))))))) - -;;;###autoload -(defun +org/shift-return (&optional arg) - "Insert a literal newline, or dwim in tables. -Executes `org-table-copy-down' if in table." - (interactive "p") - (if (org-at-table-p) - (org-table-copy-down arg) - (org-return nil arg))) - - -;; I use these instead of `org-insert-item' or `org-insert-heading' because they -;; impose bizarre whitespace rules depending on cursor location and many -;; settings. These commands have a much simpler responsibility. -;;;###autoload -(defun +org/insert-item-below (count) - "Inserts a new heading, table cell or item below the current one." - (interactive "p") - (dotimes (_ count) (+org--insert-item 'below))) - -;;;###autoload -(defun +org/insert-item-above (count) - "Inserts a new heading, table cell or item above the current one." - (interactive "p") - (dotimes (_ count) (+org--insert-item 'above))) - - -;;;###autoload -(defun +org/toggle-last-clock (arg) - "Toggles last clocked item. - -Clock out if an active clock is running (or cancel it if prefix ARG is non-nil). - -If no clock is active, then clock into the last item. See `org-clock-in-last' to -see how ARG affects this command." - (interactive "P") - (require 'org-clock) - (cond ((org-clocking-p) - (if arg - (org-clock-cancel) - (org-clock-out))) - ((and (null org-clock-history) - (or (org-on-heading-p) - (org-at-item-p)) - (y-or-n-p "No active clock. Clock in on current item?")) - (org-clock-in)) - ((org-clock-in-last arg)))) - - -;;; Folds -;;;###autoload -(defalias #'+org/toggle-fold #'+org-cycle-only-current-subtree-h) - -;;;###autoload -(defun +org/open-fold () - "Open the current fold (not but its children)." - (interactive) - (+org/toggle-fold t)) - -;;;###autoload -(defalias #'+org/close-fold #'outline-hide-subtree) - -;;;###autoload -(defun +org/close-all-folds (&optional level) - "Close all folds in the buffer (or below LEVEL)." - (interactive "p") - (outline-hide-sublevels (or level 1))) - -;;;###autoload -(defun +org/open-all-folds (&optional level) - "Open all folds in the buffer (or up to LEVEL)." - (interactive "P") - (if (integerp level) - (outline-hide-sublevels level) - (outline-show-all))) - -(defun +org--get-foldlevel () - (let ((max 1)) - (save-restriction - (narrow-to-region (window-start) (window-end)) - (save-excursion - (goto-char (point-min)) - (while (not (eobp)) - (org-next-visible-heading 1) - (when (outline-invisible-p (line-end-position)) - (let ((level (org-outline-level))) - (when (> level max) - (setq max level)))))) - max))) - -;;;###autoload -(defun +org/show-next-fold-level (&optional count) - "Decrease the fold-level of the visible area of the buffer. This unfolds -another level of headings on each invocation." - (interactive "p") - (let ((new-level (+ (+org--get-foldlevel) (or count 1)))) - (outline-hide-sublevels new-level) - (message "Folded to level %s" new-level))) - -;;;###autoload -(defun +org/hide-next-fold-level (&optional count) - "Increase the global fold-level of the visible area of the buffer. This folds -another level of headings on each invocation." - (interactive "p") - (let ((new-level (max 1 (- (+org--get-foldlevel) (or count 1))))) - (outline-hide-sublevels new-level) - (message "Folded to level %s" new-level))) - - -;; -;;; Hooks - -;;;###autoload -(defun +org-indent-maybe-h () - "Indent the current item (header or item), if possible. -Made for `org-tab-first-hook' in evil-mode." - (interactive) - (cond ((not (and (bound-and-true-p evil-local-mode) - (evil-insert-state-p))) - nil) - ((and (bound-and-true-p org-cdlatex-mode) - (or (org-inside-LaTeX-fragment-p) - (org-inside-latex-macro-p))) - nil) - ((org-at-item-p) - (if (eq this-command 'org-shifttab) - (org-outdent-item-tree) - (org-indent-item-tree)) - t) - ((org-at-heading-p) - (ignore-errors - (if (eq this-command 'org-shifttab) - (org-promote) - (org-demote))) - t) - ((org-in-src-block-p t) - (save-window-excursion - (org-babel-do-in-edit-buffer - (call-interactively #'indent-for-tab-command))) - t) - ((and (save-excursion - (skip-chars-backward " \t") - (bolp)) - (org-in-subtree-not-table-p)) - (call-interactively #'tab-to-tab-stop) - t))) - -;;;###autoload -(defun +org-yas-expand-maybe-h () - "Expand a yasnippet snippet, if trigger exists at point or region is active. -Made for `org-tab-first-hook'." - (when (and (modulep! :editor snippets) - (require 'yasnippet nil t) - (bound-and-true-p yas-minor-mode)) - (and (let ((major-mode (cond ((org-in-src-block-p t) - (org-src-get-lang-mode (org-eldoc-get-src-lang))) - ((org-inside-LaTeX-fragment-p) - 'latex-mode) - (major-mode))) - (org-src-tab-acts-natively nil) ; causes breakages - ;; Smart indentation doesn't work with yasnippet, and painfully slow - ;; in the few cases where it does. - (yas-indent-line 'fixed)) - (cond ((and (or (not (bound-and-true-p evil-local-mode)) - (evil-insert-state-p) - (evil-emacs-state-p)) - (or (and (bound-and-true-p yas--tables) - (gethash major-mode yas--tables)) - (progn (yas-reload-all) t)) - (yas--templates-for-key-at-point)) - (yas-expand) - t) - ((use-region-p) - (yas-insert-snippet) - t))) - ;; HACK Yasnippet breaks org-superstar-mode because yasnippets is - ;; overzealous about cleaning up overlays. - (when (bound-and-true-p org-superstar-mode) - (org-superstar-restart))))) - -;;;###autoload -(defun +org-cycle-only-current-subtree-h (&optional arg) - "Toggle the local fold at the point, and no deeper. -`org-cycle's standard behavior is to cycle between three levels: collapsed, -subtree and whole document. This is slow, especially in larger org buffer. Most -of the time I just want to peek into the current subtree -- at most, expand -*only* the current subtree. - -All my (performant) foldings needs are met between this and `org-show-subtree' -(on zO for evil users), and `org-cycle' on shift-TAB if I need it." - (interactive "P") - (unless (or (eq this-command 'org-shifttab) - (and (bound-and-true-p org-cdlatex-mode) - (or (org-inside-LaTeX-fragment-p) - (org-inside-latex-macro-p)))) - (save-excursion - (org-beginning-of-line) - (let (invisible-p) - (when (and (org-at-heading-p) - (or org-cycle-open-archived-trees - (not (member org-archive-tag (org-get-tags)))) - (or (not arg) - (setq invisible-p (outline-invisible-p (line-end-position))))) - (unless invisible-p - (setq org-cycle-subtree-status 'subtree)) - (org-cycle-internal-local) - t))))) - -;;;###autoload -(defun +org-make-last-point-visible-h () - "Unfold subtree around point if saveplace places us in a folded region." - (and (not org-inhibit-startup) - (not org-inhibit-startup-visibility-stuff) - ;; Must be done on a timer because `org-show-set-visibility' (used by - ;; `org-reveal') relies on overlays that aren't immediately available - ;; when `org-mode' first initializes. - (run-at-time 0.1 nil #'org-reveal '(4)))) - -;;;###autoload -(defun +org-remove-occur-highlights-h () - "Remove org occur highlights on ESC in normal mode." - (when org-occur-highlights - (org-remove-occur-highlights) - t)) - -;;;###autoload -(defun +org-enable-auto-update-cookies-h () - "Update statistics cookies when saving or exiting insert mode (`evil-mode')." - (when (bound-and-true-p evil-local-mode) - (add-hook 'evil-insert-state-exit-hook #'org-update-parent-todo-statistics nil t)) - (add-hook 'before-save-hook #'org-update-parent-todo-statistics nil t)) diff --git a/.config/emacs/modules/lang/org/config.el b/.config/emacs/modules/lang/org/config.el @@ -1,1459 +0,0 @@ -;;; lang/org/config.el -*- lexical-binding: t; -*- - -(defvar +org-babel-native-async-langs '(python) - "Languages that will use `ob-comint' instead of `ob-async' for `:async'.") - -(defvar +org-babel-mode-alist - '((c . C) - (cpp . C) - (C++ . C) - (D . C) - (elisp . emacs-lisp) - (sh . shell) - (bash . shell) - (matlab . octave) - (rust . rustic-babel) - (amm . ammonite)) - "An alist mapping languages to babel libraries. This is necessary for babel -libraries (ob-*.el) that don't match the name of the language. - -For example, (fish . shell) will cause #+begin_src fish blocks to load -ob-shell.el when executed.") - -(defvar +org-babel-load-functions () - "A list of functions executed to load the current executing src block. They -take one argument (the language specified in the src block, as a string). Stops -at the first function to return non-nil.") - -(defvar +org-capture-todo-file "todo.org" - "Default target for todo entries. - -Is relative to `org-directory', unless it is absolute. Is used in Doom's default -`org-capture-templates'.") - -(defvar +org-capture-changelog-file "changelog.org" - "Default target for changelog entries. - -Is relative to `org-directory' unless it is absolute. Is used in Doom's default -`org-capture-templates'.") - -(defvar +org-capture-notes-file "notes.org" - "Default target for storing notes. - -Used as a fall back file for org-capture.el, for templates that do not specify a -target file. - -Is relative to `org-directory', unless it is absolute. Is used in Doom's default -`org-capture-templates'.") - -(defvar +org-capture-journal-file "journal.org" - "Default target for storing timestamped journal entries. - -Is relative to `org-directory', unless it is absolute. Is used in Doom's default -`org-capture-templates'.") - -(defvar +org-capture-projects-file "projects.org" - "Default, centralized target for org-capture templates.") - -(defvar +org-habit-graph-padding 2 - "The padding added to the end of the consistency graph") - -(defvar +org-habit-min-width 30 - "Hides the consistency graph if the `org-habit-graph-column' is less than this value") - -(defvar +org-habit-graph-window-ratio 0.3 - "The ratio of the consistency graphs relative to the window width") - -(defvar +org-startup-with-animated-gifs nil - "If non-nil, and the cursor is over a gif inline-image preview, animate it!") - - -;; -;;; `org-load' hooks - -(defun +org-init-org-directory-h () - (unless org-directory - (setq-default org-directory "~/org")) - (unless org-id-locations-file - (setq org-id-locations-file (expand-file-name ".orgids" org-directory)))) - - -(defun +org-init-agenda-h () - (unless org-agenda-files - (setq-default org-agenda-files (list org-directory))) - (setq-default - ;; Different colors for different priority levels - org-agenda-deadline-faces - '((1.001 . error) - (1.0 . org-warning) - (0.5 . org-upcoming-deadline) - (0.0 . org-upcoming-distant-deadline)) - ;; Don't monopolize the whole frame just for the agenda - org-agenda-window-setup 'current-window - org-agenda-skip-unavailable-files t - ;; Shift the agenda to show the previous 3 days and the next 7 days for - ;; better context on your week. The past is less important than the future. - org-agenda-span 10 - org-agenda-start-on-weekday nil - org-agenda-start-day "-3d" - ;; Optimize `org-agenda' by inhibiting extra work while opening agenda - ;; buffers in the background. They'll be "restarted" if the user switches to - ;; them anyway (see `+org-exclude-agenda-buffers-from-workspace-h') - org-agenda-inhibit-startup t)) - - -(defun +org-init-appearance-h () - "Configures the UI for `org-mode'." - (setq org-indirect-buffer-display 'current-window - org-eldoc-breadcrumb-separator " → " - org-enforce-todo-dependencies t - org-entities-user - '(("flat" "\\flat" nil "" "" "266D" "♭") - ("sharp" "\\sharp" nil "" "" "266F" "♯")) - org-fontify-done-headline t - org-fontify-quote-and-verse-blocks t - org-fontify-whole-heading-line t - org-hide-leading-stars t - org-image-actual-width nil - org-imenu-depth 6 - org-priority-faces - '((?A . error) - (?B . warning) - (?C . success)) - org-startup-indented t - org-tags-column 0 - org-use-sub-superscripts '{} - ;; `showeverything' is org's default, but it doesn't respect - ;; `org-hide-block-startup' (#+startup: hideblocks), archive trees, - ;; hidden drawers, or VISIBILITY properties. `nil' is equivalent, but - ;; respects these settings. - org-startup-folded nil) - - (setq org-refile-targets - '((nil :maxlevel . 3) - (org-agenda-files :maxlevel . 3)) - ;; Without this, completers like ivy/helm are only given the first level of - ;; each outline candidates. i.e. all the candidates under the "Tasks" heading - ;; are just "Tasks/". This is unhelpful. We want the full path to each refile - ;; target! e.g. FILE/Tasks/heading/subheading - org-refile-use-outline-path 'file - org-outline-path-complete-in-steps nil) - - (plist-put org-format-latex-options :scale 1.5) ; larger previews - - ;; HACK Face specs fed directly to `org-todo-keyword-faces' don't respect - ;; underlying faces like the `org-todo' face does, so we define our own - ;; intermediary faces that extend from org-todo. - (with-no-warnings - (custom-declare-face '+org-todo-active '((t (:inherit (bold font-lock-constant-face org-todo)))) "") - (custom-declare-face '+org-todo-project '((t (:inherit (bold font-lock-doc-face org-todo)))) "") - (custom-declare-face '+org-todo-onhold '((t (:inherit (bold warning org-todo)))) "") - (custom-declare-face '+org-todo-cancel '((t (:inherit (bold error org-todo)))) "")) - (setq org-todo-keywords - '((sequence - "TODO(t)" ; A task that needs doing & is ready to do - "PROJ(p)" ; A project, which usually contains other tasks - "LOOP(r)" ; A recurring task - "STRT(s)" ; A task that is in progress - "WAIT(w)" ; Something external is holding up this task - "HOLD(h)" ; This task is paused/on hold because of me - "IDEA(i)" ; An unconfirmed and unapproved task or notion - "|" - "DONE(d)" ; Task successfully completed - "KILL(k)") ; Task was cancelled, aborted or is no longer applicable - (sequence - "[ ](T)" ; A task that needs doing - "[-](S)" ; Task is in progress - "[?](W)" ; Task is being held up or paused - "|" - "[X](D)") ; Task was completed - (sequence - "|" - "OKAY(o)" - "YES(y)" - "NO(n)")) - org-todo-keyword-faces - '(("[-]" . +org-todo-active) - ("STRT" . +org-todo-active) - ("[?]" . +org-todo-onhold) - ("WAIT" . +org-todo-onhold) - ("HOLD" . +org-todo-onhold) - ("PROJ" . +org-todo-project) - ("NO" . +org-todo-cancel) - ("KILL" . +org-todo-cancel))) - - ;; Automatic indent detection in org files is meaningless - (add-to-list 'doom-detect-indentation-excluded-modes 'org-mode) - - (set-ligatures! 'org-mode - :name "#+NAME:" - :name "#+name:" - :src_block "#+BEGIN_SRC" - :src_block "#+begin_src" - :src_block_end "#+END_SRC" - :src_block_end "#+end_src" - :quote "#+BEGIN_QUOTE" - :quote "#+begin_quote" - :quote_end "#+END_QUOTE" - :quote_end "#+end_quote")) - - -(defun +org-init-babel-h () - (setq org-src-preserve-indentation t ; use native major-mode indentation - org-src-tab-acts-natively t ; we do this ourselves - ;; You don't need my permission (just be careful, mkay?) - org-confirm-babel-evaluate nil - org-link-elisp-confirm-function nil - ;; Show src buffer in popup, and don't monopolize the frame - org-src-window-setup 'other-window - ;; Our :lang common-lisp module uses sly, so... - org-babel-lisp-eval-fn #'sly-eval) - - ;; 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) - - ;; Don't process babel results asynchronously when exporting org, as they - ;; won't likely complete in time, and will instead output an ob-async hash - ;; instead of the wanted evaluation results. - (after! ob - (add-to-list 'org-babel-default-lob-header-args '(:sync))) - - (defadvice! +org-babel-disable-async-maybe-a (fn &optional orig-fn arg info params) - "Use ob-comint where supported, disable async altogether where it isn't. - -We have access to two async backends: ob-comint or ob-async, which have -different requirements. This advice tries to pick the best option between them, -falling back to synchronous execution otherwise. Without this advice, they die -with an error; terrible UX! - -Note: ob-comint support will only kick in for languages listed in -`+org-babel-native-async-langs'. - -Also adds support for a `:sync' parameter to override `:async'." - :around #'ob-async-org-babel-execute-src-block - (if (null orig-fn) - (funcall fn orig-fn arg info params) - (let* ((info (or info (org-babel-get-src-block-info))) - (params (org-babel-merge-params (nth 2 info) params))) - (if (or (assq :sync params) - (not (assq :async params)) - (member (car info) ob-async-no-async-languages-alist) - ;; ob-comint requires a :session, ob-async does not, so fall - ;; back to ob-async if no :session is provided. - (unless (member (alist-get :session params) '("none" nil)) - (unless (memq (let* ((lang (nth 0 info)) - (lang (cond ((symbolp lang) lang) - ((stringp lang) (intern lang))))) - (or (alist-get lang +org-babel-mode-alist) - lang)) - +org-babel-native-async-langs) - (message "Org babel: %s :session is incompatible with :async. Executing synchronously!" - (car info)) - (sleep-for 0.2)) - t)) - (funcall orig-fn arg info params) - (funcall fn orig-fn arg info params))))) - - ;; HACK Fix #6061. Seems `org-babel-do-in-edit-buffer' has the side effect of - ;; deleting side windows. Should be reported upstream! This advice - ;; suppresses this behavior wherever it is known to be used. - (defadvice! +org-fix-window-excursions-a (fn &rest args) - "Suppress changes to the window config anywhere -`org-babel-do-in-edit-buffer' is used." - :around #'evil-org-open-below - :around #'evil-org-open-above - :around #'org-indent-region - :around #'org-indent-line - (save-window-excursion (apply fn args))) - - (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 - (when (and indent - org-src-tab-acts-natively - (org-in-src-block-p t)) - (save-window-excursion - (org-babel-do-in-edit-buffer - (call-interactively #'indent-for-tab-command))))) - - (defadvice! +org-inhibit-mode-hooks-a (fn datum name &optional initialize &rest args) - "Prevent potentially expensive mode hooks in `org-babel-do-in-edit-buffer' ops." - :around #'org-src--edit-element - (apply fn datum name - (if (and (eq org-src-window-setup 'switch-invisibly) - (functionp initialize)) - ;; org-babel-do-in-edit-buffer is used to execute quick, one-off - ;; logic in the context of another major mode, but initializing a - ;; major mode with expensive hooks can be terribly expensive. - ;; Since Doom adds its most expensive hooks to - ;; MAJOR-MODE-local-vars-hook, we can savely inhibit those. - (lambda () - (let ((doom-inhibit-local-var-hooks t)) - (funcall initialize))) - initialize) - args)) - - ;; Refresh inline images after executing src blocks (useful for plantuml or - ;; ipython, where the result could be an image) - (add-hook! 'org-babel-after-execute-hook - (defun +org-redisplay-inline-images-in-babel-result-h () - (unless (or - ;; ...but not while Emacs is exporting an org buffer (where - ;; `org-display-inline-images' can be awfully slow). - (bound-and-true-p org-export-current-backend) - ;; ...and not while tangling org buffers (which happens in a temp - ;; buffer where `buffer-file-name' is nil). - (string-match-p "^ \\*temp" (buffer-name))) - (save-excursion - (when-let ((beg (org-babel-where-is-src-block-result)) - (end (progn (goto-char beg) (forward-line) (org-babel-result-end)))) - (org-display-inline-images nil nil (min beg end) (max beg end))))))) - - (after! python - (unless org-babel-python-command - (setq org-babel-python-command - (string-trim - (concat python-shell-interpreter " " - (if (string-match-p "\\<i?python[23]?$" python-shell-interpreter) - (replace-regexp-in-string - "\\(^\\| \\)-i\\( \\|$\\)" " " python-shell-interpreter-args) - python-shell-interpreter-args)))))) - - (after! ob-ditaa - ;; TODO Should be fixed upstream - (let ((default-directory (org-find-library-dir "org-contribdir"))) - (setq org-ditaa-jar-path (expand-file-name "scripts/ditaa.jar") - org-ditaa-eps-jar-path (expand-file-name "scripts/DitaaEps.jar"))))) - - -(defun +org-init-babel-lazy-loader-h () - "Load babel libraries lazily when babel blocks are executed." - (defun +org--babel-lazy-load (lang &optional async) - (cl-check-type lang (or symbol null)) - (unless (cdr (assq lang org-babel-load-languages)) - (when async - ;; ob-async has its own agenda for lazy loading packages (in the child - ;; process), so we only need to make sure it's loaded. - (require 'ob-async nil t)) - (prog1 (or (run-hook-with-args-until-success '+org-babel-load-functions lang) - (require (intern (format "ob-%s" lang)) nil t) - (require lang nil t)) - (add-to-list 'org-babel-load-languages (cons lang t))))) - - (defadvice! +org--export-lazy-load-library-h (&optional element) - "Lazy load a babel package when a block is executed during exporting." - :before #'org-babel-exp-src-block - (+org--babel-lazy-load-library-a (org-babel-get-src-block-info nil element))) - - (defadvice! +org--src-lazy-load-library-a (lang) - "Lazy load a babel package to ensure syntax highlighting." - :before #'org-src--get-lang-mode - (or (cdr (assoc lang org-src-lang-modes)) - (+org--babel-lazy-load lang))) - - ;; This also works for tangling - (defadvice! +org--babel-lazy-load-library-a (info) - "Load babel libraries lazily when babel blocks are executed." - :after-while #'org-babel-confirm-evaluate - (let* ((lang (nth 0 info)) - (lang (cond ((symbolp lang) lang) - ((stringp lang) (intern lang)))) - (lang (or (cdr (assq lang +org-babel-mode-alist)) - lang))) - (+org--babel-lazy-load - lang (and (not (assq :sync (nth 2 info))) - (assq :async (nth 2 info)))) - t)) - - (advice-add #'org-babel-do-load-languages :override #'ignore)) - - -(defun +org-init-capture-defaults-h () - "Sets up some reasonable defaults, as well as two `org-capture' workflows that -I like: - -1. The traditional way: invoking `org-capture' directly, via SPC X, or through - the :cap ex command. -2. Through a org-capture popup frame that is invoked from outside Emacs (the - ~/.emacs.d/bin/org-capture script). This can be invoked from qutebrowser, - vimperator, dmenu or a global keybinding." - (setq org-default-notes-file - (expand-file-name +org-capture-notes-file org-directory) - +org-capture-journal-file - (expand-file-name +org-capture-journal-file org-directory) - org-capture-templates - '(("t" "Personal todo" entry - (file+headline +org-capture-todo-file "Inbox") - "* [ ] %?\n%i\n%a" :prepend t) - ("n" "Personal notes" entry - (file+headline +org-capture-notes-file "Inbox") - "* %u %?\n%i\n%a" :prepend t) - ("j" "Journal" entry - (file+olp+datetree +org-capture-journal-file) - "* %U %?\n%i\n%a" :prepend t) - - ;; Will use {project-root}/{todo,notes,changelog}.org, unless a - ;; {todo,notes,changelog}.org file is found in a parent directory. - ;; Uses the basename from `+org-capture-todo-file', - ;; `+org-capture-changelog-file' and `+org-capture-notes-file'. - ("p" "Templates for projects") - ("pt" "Project-local todo" entry ; {project-root}/todo.org - (file+headline +org-capture-project-todo-file "Inbox") - "* TODO %?\n%i\n%a" :prepend t) - ("pn" "Project-local notes" entry ; {project-root}/notes.org - (file+headline +org-capture-project-notes-file "Inbox") - "* %U %?\n%i\n%a" :prepend t) - ("pc" "Project-local changelog" entry ; {project-root}/changelog.org - (file+headline +org-capture-project-changelog-file "Unreleased") - "* %U %?\n%i\n%a" :prepend t) - - ;; Will use {org-directory}/{+org-capture-projects-file} and store - ;; these under {ProjectName}/{Tasks,Notes,Changelog} headings. They - ;; support `:parents' to specify what headings to put them under, e.g. - ;; :parents ("Projects") - ("o" "Centralized templates for projects") - ("ot" "Project todo" entry - (function +org-capture-central-project-todo-file) - "* TODO %?\n %i\n %a" - :heading "Tasks" - :prepend nil) - ("on" "Project notes" entry - (function +org-capture-central-project-notes-file) - "* %U %?\n %i\n %a" - :heading "Notes" - :prepend t) - ("oc" "Project changelog" entry - (function +org-capture-central-project-changelog-file) - "* %U %?\n %i\n %a" - :heading "Changelog" - :prepend t))) - - ;; Kill capture buffers by default (unless they've been visited) - (after! org-capture - (org-capture-put :kill-buffer t)) - - ;; Fix #462: when refiling from org-capture, Emacs prompts to kill the - ;; underlying, modified buffer. This fixes that. - (add-hook 'org-after-refile-insert-hook #'save-buffer) - - ;; HACK Doom doesn't support `customize'. Best not to advertise it as an - ;; option in `org-capture's menu. - (defadvice! +org--remove-customize-option-a (fn table title &optional prompt specials) - :around #'org-mks - (funcall fn table title prompt - (remove '("C" "Customize org-capture-templates") - specials))) - - (defadvice! +org--capture-expand-variable-file-a (file) - "If a variable is used for a file path in `org-capture-template', it is used -as is, and expanded relative to `default-directory'. This changes it to be -relative to `org-directory', unless it is an absolute path." - :filter-args #'org-capture-expand-file - (if (and (symbolp file) (boundp file)) - (expand-file-name (symbol-value file) org-directory) - file)) - - (add-hook! 'org-capture-mode-hook - (defun +org-show-target-in-capture-header-h () - (setq header-line-format - (format "%s%s%s" - (propertize (abbreviate-file-name (buffer-file-name (buffer-base-buffer))) - 'face 'font-lock-string-face) - org-eldoc-breadcrumb-separator - header-line-format))))) - - -(defun +org-init-capture-frame-h () - (add-hook 'org-capture-after-finalize-hook #'+org-capture-cleanup-frame-h) - - (defadvice! +org-capture-refile-cleanup-frame-a (&rest _) - :after #'org-capture-refile - (+org-capture-cleanup-frame-h)) - - (when (modulep! :ui doom-dashboard) - (add-hook '+doom-dashboard-inhibit-functions #'+org-capture-frame-p))) - - -(defun +org-init-attachments-h () - "Sets up org's attachment system." - (setq org-attach-store-link-p 'attached ; store link after attaching files - org-attach-use-inheritance t) ; inherit properties from parent nodes - - ;; Autoload all these commands that org-attach doesn't autoload itself - (use-package! org-attach - :commands (org-attach-new - org-attach-open - org-attach-open-in-emacs - org-attach-reveal-in-emacs - org-attach-url - org-attach-set-directory - org-attach-sync) - :config - (unless org-attach-id-dir - ;; Centralized attachments directory by default - (setq-default org-attach-id-dir (expand-file-name ".attach/" org-directory))) - (after! projectile - (add-to-list 'projectile-globally-ignored-directories org-attach-id-dir))) - - ;; Add inline image previews for attachment links - (org-link-set-parameters "attachment" :image-data-fun #'+org-inline-image-data-fn)) - - -(defun +org-init-custom-links-h () - ;; Modify default file: links to colorize broken file links red - (org-link-set-parameters - "file" :face (lambda (path) - (if (or (file-remote-p path) - ;; filter out network shares on windows (slow) - (if IS-WINDOWS (string-prefix-p "\\\\" path)) - (file-exists-p path)) - 'org-link - '(warning org-link)))) - - ;; Additional custom links for convenience - (pushnew! org-link-abbrev-alist - '("github" . "https://github.com/%s") - '("youtube" . "https://youtube.com/watch?v=%s") - '("google" . "https://google.com/search?q=") - '("gimages" . "https://google.com/images?q=%s") - '("gmap" . "https://maps.google.com/maps?q=%s") - '("duckduckgo" . "https://duckduckgo.com/?q=%s") - '("wikipedia" . "https://en.wikipedia.org/wiki/%s") - '("wolfram" . "https://wolframalpha.com/input/?i=%s") - '("doom-repo" . "https://github.com/doomemacs/doomemacs/%s") - `("emacsdir" . ,(doom-path doom-emacs-dir "%s")) - `("doomdir" . ,(doom-path doom-user-dir "%s"))) - - (+org-define-basic-link "org" 'org-directory) - (+org-define-basic-link "doom" 'doom-emacs-dir) - (+org-define-basic-link "doom-docs" 'doom-docs-dir) - (+org-define-basic-link "doom-modules" 'doom-modules-dir) - - ;; Add "lookup" links for packages and keystrings; useful for Emacs - ;; documentation -- especially Doom's! - (letf! ((defun -call-interactively (fn) - (lambda (path _prefixarg) - (funcall - fn (or (intern-soft path) - (user-error "Can't find documentation for %S" path)))))) - (org-link-set-parameters - "kbd" - :follow (lambda (ev) - (interactive "e") - (minibuffer-message "%s" (+org-link-doom--help-echo-from-textprop - nil (current-buffer) (posn-point (event-start ev))))) - :help-echo #'+org-link-doom--help-echo-from-textprop - :face 'help-key-binding) - (org-link-set-parameters - "var" - :follow (-call-interactively #'helpful-variable) - :activate-func #'+org-link--var-link-activate-fn - :face 'org-code) - (org-link-set-parameters - "fn" - :follow (-call-interactively #'helpful-callable) - :activate-func #'+org-link--fn-link-activate-fn - :face 'org-code) - (org-link-set-parameters - "face" - :follow (-call-interactively #'describe-face) - :activate-func #'+org-link--face-link-activate-face - :face '(font-lock-type-face underline)) - (org-link-set-parameters - "cmd" - :follow (-call-interactively #'describe-command) - :activate-func #'+org-link--command-link-activate-command - :face 'help-key-binding - :help-echo #'+org-link-doom--help-echo-from-textprop) - (org-link-set-parameters - "doom-package" - :follow #'+org-link-follow-doom-package-fn - :activate-func #'+org-link--doom-package-link-activate-fn - :face (lambda (_) '(:inherit org-priority :slant italic)) - :help-echo #'+org-link-doom--help-echo-from-textprop) - (org-link-set-parameters - "doom-module" - :follow #'+org-link-follow-doom-module-fn - :activate-func #'+org-link--doom-module-link-activate-fn - :face #'+org-link--doom-module-link-face-fn - :help-echo #'+org-link-doom--help-echo-from-textprop) - (org-link-set-parameters - "doom-executable" - :activate-func #'+org-link--doom-executable-link-activate-fn - :help-echo #'+org-link-doom--help-echo-from-textprop - :face 'org-verbatim) - (org-link-set-parameters - "doom-ref" - :follow (lambda (link) - (let ((link (+org-link-read-desc-at-point link)) - (url "https://github.com") - (doom-repo "doomemacs/doomemacs")) - (save-match-data - (browse-url - (cond ((string-match "^\\([^/]+\\(?:/[^/]+\\)?\\)?#\\([0-9]+\\(?:#.*\\)?\\)" link) - (format "%s/%s/issues/%s" url - (or (match-string 1 link) - doom-repo) - (match-string 2 link))) - ((string-match "^\\([^/]+\\(?:/[^/]+\\)?@\\)?\\([a-z0-9]\\{7,\\}\\(?:#.*\\)?\\)" link) - (format "%s/%s/commit/%s" url - (or (match-string 1 link) - doom-repo) - (match-string 2 link))) - ((user-error "Invalid doom-ref link: %S" link))))))) - :face (lambda (link) - (let ((link (+org-link-read-desc-at-point link))) - (if (or (string-match "^\\([^/]+\\(?:/[^/]+\\)?\\)?#\\([0-9]+\\(?:#.*\\)?\\)" link) - (string-match "^\\([^/]+\\(?:/[^/]+\\)?@\\)?\\([a-z0-9]\\{7,\\}\\(?:#.*\\)?\\)" link)) - 'org-link - 'error)))) - (org-link-set-parameters - "doom-user" - :follow (lambda (link) - (browse-url - (format "https://github.com/%s" - (string-remove-prefix - "@" (+org-link-read-desc-at-point link))))) - :face (lambda (_) 'org-priority)) - (org-link-set-parameters - "doom-changelog" - :follow (lambda (link) - (find-file (doom-path doom-docs-dir "changelog.org")) - (org-match-sparse-tree nil link)))) - - ;; TODO PR this upstream - (defadvice! +org--follow-search-string-a (fn link &optional arg) - "Support ::SEARCH syntax for id: links." - :around #'org-id-open - :around #'org-roam-id-open - (save-match-data - (cl-destructuring-bind (id &optional search) - (split-string link "::") - (prog1 (funcall fn id arg) - (cond ((null search)) - ((string-match-p "\\`[0-9]+\\'" search) - ;; Move N lines after the ID (in case it's a heading), instead - ;; of the start of the buffer. - (forward-line (string-to-number option))) - ((string-match "^/\\([^/]+\\)/$" search) - (let ((match (match-string 1 search))) - (save-excursion (org-link-search search)) - ;; `org-link-search' only reveals matches. Moving the point - ;; to the first match after point is a sensible change. - (when (re-search-forward match) - (goto-char (match-beginning 0))))) - ((org-link-search search))))))) - - ;; Add "lookup" links for packages and keystrings; useful for Emacs - ;; documentation -- especially Doom's! - - ;; Allow inline image previews of http(s)? urls or data uris. - ;; `+org-http-image-data-fn' will respect `org-display-remote-inline-images'. - (setq org-display-remote-inline-images 'download) ; TRAMP urls - (org-link-set-parameters "http" :image-data-fun #'+org-http-image-data-fn) - (org-link-set-parameters "https" :image-data-fun #'+org-http-image-data-fn) - (org-link-set-parameters "img" :image-data-fun #'+org-inline-image-data-fn) - - ;; Add support for youtube links + previews - (require 'org-yt nil t) - - (defadvice! +org-dont-preview-if-disabled-a (&rest _) - "Make `org-yt' respect `org-display-remote-inline-images'." - :before-while #'org-yt-image-data-fun - (not (eq org-display-remote-inline-images 'skip)))) - - -(defun +org-init-export-h () - "TODO" - (setq org-export-with-smart-quotes t - org-html-validation-link nil - org-latex-prefer-user-labels t) - - (when (modulep! :lang markdown) - (add-to-list 'org-export-backends 'md)) - - (use-package! ox-hugo - :when (modulep! +hugo) - :after ox) - - (use-package! ox-pandoc - :when (modulep! +pandoc) - :when (executable-find "pandoc") - :after ox - :init - (add-to-list 'org-export-backends 'pandoc) - (setq org-pandoc-options - '((standalone . t) - (mathjax . t) - (variable . "revealjs-url=https://revealjs.com")))) - - (defadvice! +org--dont-trigger-save-hooks-a (fn &rest args) - "Exporting and tangling trigger save hooks; inadvertantly triggering -mutating hooks on exported output, like formatters." - :around '(org-export-to-file org-babel-tangle) - (let (before-save-hook after-save-hook) - (apply fn args))) - - (defadvice! +org--fix-async-export-a (fn &rest args) - :around '(org-export-to-file org-export-as) - (let ((old-async-init-file org-export-async-init-file) - (org-export-async-init-file (make-temp-file "doom-org-async-export"))) - (doom-file-write - org-export-async-init-file - `((setq org-export-async-debug ,(or org-export-async-debug debug-on-error) - load-path ',load-path) - (unwind-protect - (let ((init-file ,old-async-init-file)) - (if init-file - (load init-file nil t) - (load ,early-init-file nil t) - (require 'doom-start))) - (delete-file load-file-name)))) - (apply fn args)))) - - -(defun +org-init-habit-h () - (add-hook! 'org-agenda-mode-hook - (defun +org-habit-resize-graph-h () - "Right align and resize the consistency graphs based on -`+org-habit-graph-window-ratio'" - (when (featurep 'org-habit) - (let* ((total-days (float (+ org-habit-preceding-days org-habit-following-days))) - (preceding-days-ratio (/ org-habit-preceding-days total-days)) - (graph-width (floor (* (window-width) +org-habit-graph-window-ratio))) - (preceding-days (floor (* graph-width preceding-days-ratio))) - (following-days (- graph-width preceding-days)) - (graph-column (- (window-width) (+ preceding-days following-days))) - (graph-column-adjusted (if (> graph-column +org-habit-min-width) - (- graph-column +org-habit-graph-padding) - nil))) - (setq-local org-habit-preceding-days preceding-days) - (setq-local org-habit-following-days following-days) - (setq-local org-habit-graph-column graph-column-adjusted)))))) - - -(defun +org-init-hacks-h () - "Getting org to behave." - ;; Open file links in current window, rather than new ones - (setf (alist-get 'file org-link-frame-setup) #'find-file) - ;; Open directory links in dired - (add-to-list 'org-file-apps '(directory . emacs)) - (add-to-list 'org-file-apps '(remote . emacs)) - - ;; Open help:* links with helpful-* instead of describe-* - (advice-add #'org-link--open-help :around #'doom-use-helpful-a) - - ;; Unlike the stock showNlevels options, these will also show the parents of - ;; the target level, recursively. - (pushnew! org-startup-options - '("show2levels*" org-startup-folded show2levels*) - '("show3levels*" org-startup-folded show3levels*) - '("show4levels*" org-startup-folded show4levels*) - '("show5levels*" org-startup-folded show5levels*)) - - ;; TODO Upstream this. - (defadvice! +org--recursive-org-persist-mkdir-a (fn &rest args) - "`org-persist-write:index' does not recursively create -`org-persist-directory', which causes an error if it's a parent doesn't exist." - :before #'org-persist-write:index - (make-directory org-persist-directory t)) - - (defadvice! +org--more-startup-folded-options-a () - "Adds support for 'showNlevels*' startup options. -Unlike showNlevels, this will also unfold parent trees." - :before-until #'org-cycle-set-startup-visibility - (when-let (n (pcase org-startup-folded - (`show2levels* 2) - (`show3levels* 3) - (`show4levels* 4) - (`show5levels* 5))) - (org-fold-show-all '(headings)) - (save-excursion - (goto-char (point-max)) - (save-restriction - (narrow-to-region (point-min) (or (re-search-forward org-outline-regexp-bol nil t) (point-max))) - (org-fold-hide-drawer-all)) - (goto-char (point-max)) - (let ((regexp (if (and (wholenump n) (> n 0)) - (format "^\\*\\{%d,%d\\} " (1- n) n) - "^\\*+ ")) - (last (point))) - (while (re-search-backward regexp nil t) - (when (or (not (wholenump n)) - (= (org-current-level) n)) - (org-fold-core-region (line-end-position) last t 'outline)) - (setq last (line-end-position 0))))) - t)) - - ;; Some uses of `org-fix-tags-on-the-fly' occur without a check on - ;; `org-auto-align-tags', such as in `org-self-insert-command' and - ;; `org-delete-backward-char'. - ;; TODO Should be reported/PR'ed upstream - (defadvice! +org--respect-org-auto-align-tags-a (&rest _) - :before-while #'org-fix-tags-on-the-fly - org-auto-align-tags) - - (defadvice! +org--recenter-after-follow-link-a (&rest _args) - "Recenter after following a link, but only internal or file links." - :after '(org-footnote-action - org-follow-timestamp-link - org-link-open-as-file - org-link-search) - (when (get-buffer-window) - (recenter))) - - (defadvice! +org--strip-properties-from-outline-a (fn &rest args) - "Fix variable height faces in eldoc breadcrumbs." - :around #'org-format-outline-path - (let ((org-level-faces - (cl-loop for face in org-level-faces - collect `(:foreground ,(face-foreground face nil t) - :weight bold)))) - (apply fn args))) - - (after! org-eldoc - ;; HACK Fix #2972: infinite recursion when eldoc kicks in in 'org' or - ;; 'python' src blocks. - ;; TODO Should be reported upstream! - (puthash "org" #'ignore org-eldoc-local-functions-cache) - (puthash "plantuml" #'ignore org-eldoc-local-functions-cache) - (puthash "python" #'python-eldoc-function org-eldoc-local-functions-cache)) - - (defun +org--restart-mode-h () - "Restart `org-mode', but only once." - (quiet! (org-mode-restart)) - (delq! (current-buffer) org-agenda-new-buffers) - (remove-hook 'doom-switch-buffer-hook #'+org--restart-mode-h - 'local) - (run-hooks 'find-file-hook)) - - (add-hook! 'org-agenda-finalize-hook - (defun +org-exclude-agenda-buffers-from-workspace-h () - "Don't associate temporary agenda buffers with current workspace." - (when (and org-agenda-new-buffers - (bound-and-true-p persp-mode) - (not org-agenda-sticky)) - (let (persp-autokill-buffer-on-remove) - (persp-remove-buffer org-agenda-new-buffers - (get-current-persp) - nil)))) - (defun +org-defer-mode-in-agenda-buffers-h () - "`org-agenda' opens temporary, incomplete org-mode buffers. -I've disabled a lot of org-mode's startup processes for these invisible buffers -to speed them up (in `+org--exclude-agenda-buffers-from-recentf-a'). However, if -the user tries to visit one of these buffers they'll see a gimped, half-broken -org buffer. To avoid that, restart `org-mode' when they're switched to so they -can grow up to be fully-fledged org-mode buffers." - (dolist (buffer org-agenda-new-buffers) - (when (buffer-live-p buffer) ; Ensure buffer is not killed - (with-current-buffer buffer - (add-hook 'doom-switch-buffer-hook #'+org--restart-mode-h - nil 'local)))))) - - (defvar recentf-exclude) - (defadvice! +org--optimize-backgrounded-agenda-buffers-a (fn file) - "Prevent temporarily opened agenda buffers from polluting recentf." - :around #'org-get-agenda-file-buffer - (let ((recentf-exclude (list (lambda (_file) t))) - (doom-inhibit-large-file-detection t) - org-startup-indented - org-startup-folded - vc-handled-backends - org-mode-hook - find-file-hook) - (funcall fn file))) - - ;; HACK With https://code.orgmode.org/bzg/org-mode/commit/48da60f4, inline - ;; image previews broke for users with imagemagick support built in. This - ;; reverses the problem, but should be removed once it is addressed - ;; upstream (if ever). - (defadvice! +org--fix-inline-images-for-imagemagick-users-a (fn &rest args) - :around #'org-display-inline-images - (letf! (defun create-image (file-or-data &optional type data-p &rest props) - (let ((type (if (plist-get props :width) type))) - (apply create-image file-or-data type data-p props))) - (apply fn args))) - - (defadvice! +org--fix-inconsistent-uuidgen-case-a (uuid) - "Ensure uuidgen always produces lowercase output regardless of system." - :filter-return #'org-id-new - (if (eq org-id-method 'uuid) - (downcase uuid) - uuid))) - - -(defun +org-init-keybinds-h () - "Sets up org-mode and evil keybindings. Tries to fix the idiosyncrasies -between the two." - (add-hook 'doom-escape-hook #'+org-remove-occur-highlights-h) - - ;; C-a & C-e act like `doom/backward-to-bol-or-indent' and - ;; `doom/forward-to-last-non-comment-or-eol', but with more org awareness. - (setq org-special-ctrl-a/e t) - - (setq org-M-RET-may-split-line nil - ;; insert new headings after current subtree rather than inside it - org-insert-heading-respect-content t) - - (add-hook! 'org-tab-first-hook - #'+org-yas-expand-maybe-h - #'+org-indent-maybe-h) - - (add-hook 'doom-delete-backward-functions - #'+org-delete-backward-char-and-realign-table-maybe-h) - - (map! :map org-mode-map - ;; Recently, a [tab] keybind in `outline-mode-cycle-map' has begun - ;; overriding org's [tab] keybind in GUI Emacs. This is needed to undo - ;; that, and should probably be PRed to org. - [tab] #'org-cycle - - "C-c C-S-l" #'+org/remove-link - "C-c C-i" #'org-toggle-inline-images - ;; textmate-esque newline insertion - "S-RET" #'+org/shift-return - "C-RET" #'+org/insert-item-below - "C-S-RET" #'+org/insert-item-above - "C-M-RET" #'org-insert-subheading - [C-return] #'+org/insert-item-below - [C-S-return] #'+org/insert-item-above - [C-M-return] #'org-insert-subheading - (:when IS-MAC - [s-return] #'+org/insert-item-below - [s-S-return] #'+org/insert-item-above - [s-M-return] #'org-insert-subheading) - ;; Org-aware C-a/C-e - [remap doom/backward-to-bol-or-indent] #'org-beginning-of-line - [remap doom/forward-to-last-non-comment-or-eol] #'org-end-of-line - - :localleader - "#" #'org-update-statistics-cookies - "'" #'org-edit-special - "*" #'org-ctrl-c-star - "+" #'org-ctrl-c-minus - "," #'org-switchb - "." #'org-goto - "@" #'org-cite-insert - (:when (modulep! :completion ivy) - "." #'counsel-org-goto - "/" #'counsel-org-goto-all) - (:when (modulep! :completion helm) - "." #'helm-org-in-buffer-headings - "/" #'helm-org-agenda-files-headings) - (:when (modulep! :completion vertico) - "." #'consult-org-heading - "/" #'consult-org-agenda) - "A" #'org-archive-subtree - "e" #'org-export-dispatch - "f" #'org-footnote-action - "h" #'org-toggle-heading - "i" #'org-toggle-item - "I" #'org-id-get-create - "k" #'org-babel-remove-result - "K" #'+org/remove-result-blocks - "n" #'org-store-link - "o" #'org-set-property - "q" #'org-set-tags-command - "t" #'org-todo - "T" #'org-todo-list - "x" #'org-toggle-checkbox - (:prefix ("a" . "attachments") - "a" #'org-attach - "d" #'org-attach-delete-one - "D" #'org-attach-delete-all - "f" #'+org/find-file-in-attachments - "l" #'+org/attach-file-and-insert-link - "n" #'org-attach-new - "o" #'org-attach-open - "O" #'org-attach-open-in-emacs - "r" #'org-attach-reveal - "R" #'org-attach-reveal-in-emacs - "u" #'org-attach-url - "s" #'org-attach-set-directory - "S" #'org-attach-sync - (:when (modulep! +dragndrop) - "c" #'org-download-screenshot - "p" #'org-download-clipboard - "P" #'org-download-yank)) - (:prefix ("b" . "tables") - "-" #'org-table-insert-hline - "a" #'org-table-align - "b" #'org-table-blank-field - "c" #'org-table-create-or-convert-from-region - "e" #'org-table-edit-field - "f" #'org-table-edit-formulas - "h" #'org-table-field-info - "s" #'org-table-sort-lines - "r" #'org-table-recalculate - "R" #'org-table-recalculate-buffer-tables - (:prefix ("d" . "delete") - "c" #'org-table-delete-column - "r" #'org-table-kill-row) - (:prefix ("i" . "insert") - "c" #'org-table-insert-column - "h" #'org-table-insert-hline - "r" #'org-table-insert-row - "H" #'org-table-hline-and-move) - (:prefix ("t" . "toggle") - "f" #'org-table-toggle-formula-debugger - "o" #'org-table-toggle-coordinate-overlays) - (:when (modulep! +gnuplot) - "p" #'org-plot/gnuplot)) - (:prefix ("c" . "clock") - "c" #'org-clock-cancel - "d" #'org-clock-mark-default-task - "e" #'org-clock-modify-effort-estimate - "E" #'org-set-effort - "g" #'org-clock-goto - "G" (cmd! (org-clock-goto 'select)) - "l" #'+org/toggle-last-clock - "i" #'org-clock-in - "I" #'org-clock-in-last - "o" #'org-clock-out - "r" #'org-resolve-clocks - "R" #'org-clock-report - "t" #'org-evaluate-time-range - "=" #'org-clock-timestamps-up - "-" #'org-clock-timestamps-down) - (:prefix ("d" . "date/deadline") - "d" #'org-deadline - "s" #'org-schedule - "t" #'org-time-stamp - "T" #'org-time-stamp-inactive) - (:prefix ("g" . "goto") - "g" #'org-goto - (:when (modulep! :completion ivy) - "g" #'counsel-org-goto - "G" #'counsel-org-goto-all) - (:when (modulep! :completion helm) - "g" #'helm-org-in-buffer-headings - "G" #'helm-org-agenda-files-headings) - (:when (modulep! :completion vertico) - "g" #'consult-org-heading - "G" #'consult-org-agenda) - "c" #'org-clock-goto - "C" (cmd! (org-clock-goto 'select)) - "i" #'org-id-goto - "r" #'org-refile-goto-last-stored - "v" #'+org/goto-visible - "x" #'org-capture-goto-last-stored) - (:prefix ("l" . "links") - "c" #'org-cliplink - "d" #'+org/remove-link - "i" #'org-id-store-link - "l" #'org-insert-link - "L" #'org-insert-all-links - "s" #'org-store-link - "S" #'org-insert-last-stored-link - "t" #'org-toggle-link-display - (:when (modulep! :os macos) - "g" #'org-mac-link-get-link)) - (:prefix ("P" . "publish") - "a" #'org-publish-all - "f" #'org-publish-current-file - "p" #'org-publish - "P" #'org-publish-current-project - "s" #'org-publish-sitemap) - (:prefix ("r" . "refile") - "." #'+org/refile-to-current-file - "c" #'+org/refile-to-running-clock - "l" #'+org/refile-to-last-location - "f" #'+org/refile-to-file - "o" #'+org/refile-to-other-window - "O" #'+org/refile-to-other-buffer - "v" #'+org/refile-to-visible - "r" #'org-refile - "R" #'org-refile-reverse) ; to all `org-refile-targets' - (:prefix ("s" . "tree/subtree") - "a" #'org-toggle-archive-tag - "b" #'org-tree-to-indirect-buffer - "c" #'org-clone-subtree-with-time-shift - "d" #'org-cut-subtree - "h" #'org-promote-subtree - "j" #'org-move-subtree-down - "k" #'org-move-subtree-up - "l" #'org-demote-subtree - "n" #'org-narrow-to-subtree - "r" #'org-refile - "s" #'org-sparse-tree - "A" #'org-archive-subtree - "N" #'widen - "S" #'org-sort) - (:prefix ("p" . "priority") - "d" #'org-priority-down - "p" #'org-priority - "u" #'org-priority-up)) - - (map! :after org-agenda - :map org-agenda-mode-map - :m "C-SPC" #'org-agenda-show-and-scroll-up - :localleader - (:prefix ("d" . "date/deadline") - "d" #'org-agenda-deadline - "s" #'org-agenda-schedule) - (:prefix ("c" . "clock") - "c" #'org-agenda-clock-cancel - "g" #'org-agenda-clock-goto - "i" #'org-agenda-clock-in - "o" #'org-agenda-clock-out - "r" #'org-agenda-clockreport-mode - "s" #'org-agenda-show-clocking-issues) - (:prefix ("p" . "priority") - "d" #'org-agenda-priority-down - "p" #'org-agenda-priority - "u" #'org-agenda-priority-up) - "q" #'org-agenda-set-tags - "r" #'org-agenda-refile - "t" #'org-agenda-todo)) - - -(defun +org-init-popup-rules-h () - (set-popup-rules! - '(("^\\*Org Links" :slot -1 :vslot -1 :size 2 :ttl 0) - ("^ ?\\*\\(?:Agenda Com\\|Calendar\\|Org Export Dispatcher\\)" - :slot -1 :vslot -1 :size #'+popup-shrink-to-fit :ttl 0) - ("^\\*Org \\(?:Select\\|Attach\\)" :slot -1 :vslot -2 :ttl 0 :size 0.25) - ("^\\*Org Agenda" :ignore t) - ("^\\*Org Src" :size 0.42 :quit nil :select t :autosave t :modeline t :ttl nil) - ("^\\*Org-Babel") - ("^\\*Capture\\*$\\|CAPTURE-.*$" :size 0.42 :quit nil :select t :autosave ignore)))) - - -(defun +org-init-smartparens-h () - ;; Disable the slow defaults - (provide 'smartparens-org)) - - -;; -;;; Packages - -(use-package! toc-org ; auto-table of contents - :hook (org-mode . toc-org-enable) - :config - (setq toc-org-hrefify-default "gh") - - (defadvice! +org-inhibit-scrolling-a (fn &rest args) - "Prevent the jarring scrolling that occurs when the-ToC is regenerated." - :around #'toc-org-insert-toc - (let ((p (set-marker (make-marker) (point))) - (s (window-start))) - (prog1 (apply fn args) - (goto-char p) - (set-window-start nil s t) - (set-marker p nil))))) - - -;; TODO Move to +encrypt flag -(use-package! org-crypt ; built-in - :commands org-encrypt-entries org-encrypt-entry org-decrypt-entries org-decrypt-entry - :hook (org-reveal-start . org-decrypt-entry) - :preface - ;; org-crypt falls back to CRYPTKEY property then `epa-file-encrypt-to', which - ;; is a better default than the empty string `org-crypt-key' defaults to. - (defvar org-crypt-key nil) - (after! org - (add-to-list 'org-tags-exclude-from-inheritance "crypt") - (add-hook! 'org-mode-hook - (add-hook 'before-save-hook 'org-encrypt-entries nil t)))) - - -(use-package! org-clock ; built-in - :commands org-clock-save - :init - (setq org-clock-persist-file (concat doom-data-dir "org-clock-save.el")) - (defadvice! +org--clock-load-a (&rest _) - "Lazy load org-clock until its commands are used." - :before '(org-clock-in - org-clock-out - org-clock-in-last - org-clock-goto - org-clock-cancel) - (org-clock-load)) - :config - (setq org-clock-persist 'history - ;; Resume when clocking into task with open clock - org-clock-in-resume t - ;; Remove log if task was clocked for 0:00 (accidental clocking) - org-clock-out-remove-zero-time-clocks t - ;; The default value (5) is too conservative. - org-clock-history-length 20) - (add-hook 'kill-emacs-hook #'org-clock-save)) - - -(use-package! org-pdftools - :when (modulep! :tools pdf) - :commands org-pdftools-export - :init - (after! org - ;; HACK Fixes an issue where org-pdftools link handlers will throw a - ;; 'pdf-info-epdfinfo-program is not executable' error whenever any - ;; link is stored or exported (whether or not they're a pdf link). This - ;; error gimps org until `pdf-tools-install' is run, but this is poor - ;; UX, so we suppress it. - (defun +org--pdftools-link-handler (fn &rest args) - "Produces a link handler for org-pdftools that suppresses missing-epdfinfo errors whenever storing or exporting links." - (lambda (&rest args) - (and (ignore-errors (require 'org-pdftools nil t)) - (file-executable-p pdf-info-epdfinfo-program) - (apply fn args)))) - (org-link-set-parameters (or (bound-and-true-p org-pdftools-link-prefix) "pdf") - :follow (+org--pdftools-link-handler #'org-pdftools-open) - :complete (+org--pdftools-link-handler #'org-pdftools-complete-link) - :store (+org--pdftools-link-handler #'org-pdftools-store-link) - :export (+org--pdftools-link-handler #'org-pdftools-export)) - (add-hook! 'org-open-link-functions - (defun +org-open-legacy-pdf-links-fn (link) - "Open pdftools:* and pdfviews:* links as if they were pdf:* links." - (let ((regexp "^pdf\\(?:tools\\|view\\):")) - (when (string-match-p regexp link) - (org-pdftools-open (replace-regexp-in-string regexp "" link)) - t)))))) - - -(use-package! evil-org - :when (modulep! :editor evil +everywhere) - :hook (org-mode . evil-org-mode) - :hook (org-capture-mode . evil-insert-state) - :hook (doom-docs-org-mode . evil-org-mode) - :init - (defvar evil-org-retain-visual-state-on-shift t) - (defvar evil-org-special-o/O '(table-row)) - (defvar evil-org-use-additional-insert t) - :config - (add-hook 'evil-org-mode-hook #'evil-normalize-keymaps) - (evil-org-set-key-theme) - (add-hook! 'org-tab-first-hook :append - ;; Only fold the current tree, rather than recursively - #'+org-cycle-only-current-subtree-h - ;; Clear babel results if point is inside a src block - #'+org-clear-babel-results-h) - (let-alist evil-org-movement-bindings - (let ((Cright (concat "C-" .right)) - (Cleft (concat "C-" .left)) - (Cup (concat "C-" .up)) - (Cdown (concat "C-" .down)) - (CSright (concat "C-S-" .right)) - (CSleft (concat "C-S-" .left)) - (CSup (concat "C-S-" .up)) - (CSdown (concat "C-S-" .down))) - (map! :map evil-org-mode-map - :ni [C-return] #'+org/insert-item-below - :ni [C-S-return] #'+org/insert-item-above - ;; navigate table cells (from insert-mode) - :i Cright (cmds! (org-at-table-p) #'org-table-next-field - #'org-end-of-line) - :i Cleft (cmds! (org-at-table-p) #'org-table-previous-field - #'org-beginning-of-line) - :i Cup (cmds! (org-at-table-p) #'+org/table-previous-row - #'org-up-element) - :i Cdown (cmds! (org-at-table-p) #'org-table-next-row - #'org-down-element) - :ni CSright #'org-shiftright - :ni CSleft #'org-shiftleft - :ni CSup #'org-shiftup - :ni CSdown #'org-shiftdown - ;; more intuitive RET keybinds - :n [return] #'+org/dwim-at-point - :n "RET" #'+org/dwim-at-point - :i [return] #'+org/return - :i "RET" #'+org/return - :i [S-return] #'+org/shift-return - :i "S-RET" #'+org/shift-return - ;; more vim-esque org motion keys (not covered by evil-org-mode) - :m "]h" #'org-forward-heading-same-level - :m "[h" #'org-backward-heading-same-level - :m "]l" #'org-next-link - :m "[l" #'org-previous-link - :m "]c" #'org-babel-next-src-block - :m "[c" #'org-babel-previous-src-block - :n "gQ" #'org-fill-paragraph - ;; sensible vim-esque folding keybinds - :n "za" #'+org/toggle-fold - :n "zA" #'org-shifttab - :n "zc" #'+org/close-fold - :n "zC" #'outline-hide-subtree - :n "zm" #'+org/hide-next-fold-level - :n "zM" #'+org/close-all-folds - :n "zn" #'org-tree-to-indirect-buffer - :n "zo" #'+org/open-fold - :n "zO" #'outline-show-subtree - :n "zr" #'+org/show-next-fold-level - :n "zR" #'+org/open-all-folds - :n "zi" #'org-toggle-inline-images - - :map org-read-date-minibuffer-local-map - Cleft (cmd! (org-eval-in-calendar '(calendar-backward-day 1))) - Cright (cmd! (org-eval-in-calendar '(calendar-forward-day 1))) - Cup (cmd! (org-eval-in-calendar '(calendar-backward-week 1))) - Cdown (cmd! (org-eval-in-calendar '(calendar-forward-week 1))) - CSleft (cmd! (org-eval-in-calendar '(calendar-backward-month 1))) - CSright (cmd! (org-eval-in-calendar '(calendar-forward-month 1))) - CSup (cmd! (org-eval-in-calendar '(calendar-backward-year 1))) - CSdown (cmd! (org-eval-in-calendar '(calendar-forward-year 1))))))) - - -(use-package! evil-org-agenda - :when (modulep! :editor evil +everywhere) - :hook (org-agenda-mode . evil-org-agenda-mode) - :config - (evil-org-agenda-set-keys) - (evil-define-key* 'motion evil-org-agenda-mode-map - (kbd doom-leader-key) nil)) - - -;; -;;; Bootstrap - -(use-package! org - :defer-incrementally - calendar find-func format-spec org-macs org-compat org-faces org-entities - org-list org-pcomplete org-src org-footnote org-macro ob org org-agenda - org-capture - :preface - ;; Set to nil so we can detect user changes to them later (and fall back on - ;; defaults otherwise). - (defvar org-directory nil) - (defvar org-id-locations-file nil) - (defvar org-attach-id-dir nil) - (defvar org-babel-python-command nil) - - (setq org-persist-directory (concat doom-cache-dir "org/persist/") - org-publish-timestamp-directory (concat doom-cache-dir "org/timestamps/") - org-preview-latex-image-directory (concat doom-cache-dir "org/latex/") - ;; Recognize a), A), a., A., etc -- must be set before org is loaded. - org-list-allow-alphabetical t) - - ;; Make most of the default modules opt-in to lighten its first-time load - ;; delay. I sincerely doubt most users use them all. - (defvar org-modules - '(;; ol-w3m - ;; ol-bbdb - ol-bibtex - ;; ol-docview - ;; ol-gnus - ;; ol-info - ;; ol-irc - ;; ol-mhe - ;; ol-rmail - ;; ol-eww - )) - - ;;; Custom org modules - (dolist (flag (doom-module-context-get 'flags)) - (load! (concat "contrib/" (substring (symbol-name flag) 1)) nil t)) - - ;; Add our general hooks after the submodules, so that any hooks the - ;; submodules add run after them, and can overwrite any defaults if necessary. - (add-hook! 'org-mode-hook - ;; `show-paren-mode' causes flickering with indent overlays made by - ;; `org-indent-mode', so we turn off show-paren-mode altogether - #'doom-disable-show-paren-mode-h - ;; disable `show-trailing-whitespace'; shows a lot of false positives - #'doom-disable-show-trailing-whitespace-h - ;; #'+org-enable-auto-reformat-tables-h - ;; #'+org-enable-auto-update-cookies-h - #'+org-make-last-point-visible-h) - - (add-hook! 'org-load-hook - #'+org-init-org-directory-h - #'+org-init-appearance-h - #'+org-init-agenda-h - #'+org-init-attachments-h - #'+org-init-babel-h - #'+org-init-babel-lazy-loader-h - #'+org-init-capture-defaults-h - #'+org-init-capture-frame-h - #'+org-init-custom-links-h - #'+org-init-export-h - #'+org-init-habit-h - #'+org-init-hacks-h - #'+org-init-keybinds-h - #'+org-init-popup-rules-h - #'+org-init-smartparens-h) - - ;; Wait until an org-protocol link is opened via emacsclient to load - ;; `org-protocol'. Normally you'd simply require `org-protocol' and use it, - ;; but the package loads all of org for no compelling reason, so... - (defadvice! +org--server-visit-files-a (fn files &rest args) - "Advise `server-visit-files' to load `org-protocol' lazily." - :around #'server-visit-files - (if (not (cl-loop with protocol = - (if IS-WINDOWS - ;; On Windows, the file arguments for `emacsclient' - ;; get funnelled through `expand-file-path' by - ;; `server-process-filter'. This substitutes - ;; backslashes with forward slashes and converts each - ;; path to an absolute one. However, *all* absolute - ;; paths on Windows will match the regexp ":/+", so we - ;; need a more discerning regexp. - (regexp-quote - (or (bound-and-true-p org-protocol-the-protocol) - "org-protocol")) - ;; ...but since there is a miniscule possibility users - ;; have changed `org-protocol-the-protocol' I don't want - ;; this behavior for macOS/Linux users. - "") - for var in files - if (string-match-p (format "%s:/+" protocol) (car var)) - return t)) - (apply fn files args) - (require 'org-protocol) - (apply #'org--protocol-detect-protocol-server fn files args))) - (after! org-protocol - (advice-remove 'server-visit-files #'org--protocol-detect-protocol-server)) - - ;; In case the user has eagerly loaded org from their configs - (when (and (featurep 'org) - (not byte-compile-current-file)) - (unless (doom-context-p 'reload) - (message "`org' was already loaded by the time lang/org loaded, this may cause issues")) - (run-hooks 'org-load-hook)) - - :config - (add-to-list 'doom-debug-variables 'org-export-async-debug) - - (set-company-backend! 'org-mode 'company-capf) - (set-eval-handler! 'org-mode #'+org-eval-handler) - (set-lookup-handlers! 'org-mode - :definition #'+org-lookup-definition-handler - :references #'+org-lookup-references-handler - :documentation #'+org-lookup-documentation-handler) - - ;; Save target buffer after archiving a node. - (setq org-archive-subtree-save-file-p t) - - ;; Don't number headings with these tags - (setq org-num-face '(:inherit org-special-keyword :underline nil :weight bold) - org-num-skip-tags '("noexport" "nonum")) - - ;; Prevent modifications made in invisible sections of an org document, as - ;; unintended changes can easily go unseen otherwise. - (setq org-catch-invisible-edits 'smart) - - ;; Global ID state means we can have ID links anywhere. This is required for - ;; `org-brain', however. - (setq org-id-locations-file-relative t) - - ;; HACK `org-id' doesn't check if `org-id-locations-file' exists or is - ;; writeable before trying to read/write to it. - (defadvice! +org--fail-gracefully-a (&rest _) - :before-while '(org-id-locations-save org-id-locations-load) - (file-writable-p org-id-locations-file)) - - (add-hook 'org-open-at-point-functions #'doom-set-jump-h) - ;; HACK For functions that dodge `org-open-at-point-functions', like - ;; `org-id-open', `org-goto', or roam: links. - (advice-add #'org-mark-ring-push :around #'doom-set-jump-a) - - ;; Add the ability to play gifs, at point or throughout the buffer. However, - ;; 'playgifs' is stupid slow and there's not much I can do to fix it; use at - ;; your own risk. - (add-to-list 'org-startup-options '("inlinegifs" +org-startup-with-animated-gifs at-point)) - (add-to-list 'org-startup-options '("playgifs" +org-startup-with-animated-gifs t)) - (add-hook! 'org-mode-local-vars-hook - (defun +org-init-gifs-h () - (remove-hook 'post-command-hook #'+org-play-gif-at-point-h t) - (remove-hook 'post-command-hook #'+org-play-all-gifs-h t) - (pcase +org-startup-with-animated-gifs - (`at-point (add-hook 'post-command-hook #'+org-play-gif-at-point-h nil t)) - (`t (add-hook 'post-command-hook #'+org-play-all-gifs-h nil t)))))) diff --git a/.config/emacs/modules/lang/org/contrib/brain.el b/.config/emacs/modules/lang/org/contrib/brain.el @@ -1,42 +0,0 @@ -;;; lang/org/contrib/brain.el -*- lexical-binding: t; -*- -;;;###if (modulep! +brain) - -(use-package! org-brain - :defer t - :init - (setq org-brain-visualize-default-choices 'all - org-brain-title-max-length 24 - org-brain-include-file-entries nil - org-brain-file-entries-use-title nil) - - :config - (set-popup-rule! "^\\*org-brain" - :side 'right :size 1.00 :select t :quit nil :ttl nil) - - (cl-pushnew '("b" "Brain" plain (function org-brain-goto-end) - "* %i%?" :empty-lines 1) - org-capture-templates - :key #'car :test #'equal) - - (when (modulep! :editor evil +everywhere) - ;; TODO Make a proper evil keybind scheme for org-brain - ;; REVIEW This should be handled upstream by evil-collection - (set-evil-initial-state! - '(org-brain-visualize-mode - org-brain-select-map - org-brain-move-map - org-brain-polymode-map) - 'normal) - (defun +org--evilify-map (map) - (let (keys) - (map-keymap (lambda (event function) - (push function keys) - (push (vector event) keys)) - map) - (apply #'evil-define-key* 'normal map keys))) - - (+org--evilify-map org-brain-visualize-mode-map) - (+org--evilify-map org-brain-select-map) - (+org--evilify-map org-brain-move-map) - (after! polymode - (+org--evilify-map org-brain-polymode-map)))) diff --git a/.config/emacs/modules/lang/org/contrib/dragndrop.el b/.config/emacs/modules/lang/org/contrib/dragndrop.el @@ -1,88 +0,0 @@ -;;; lang/org/contrib/dragndrop.el -*- lexical-binding: t; -*- -;;;###if (modulep! +dragndrop) - -(use-package! org-download - :commands - org-download-dnd - org-download-yank - org-download-screenshot - org-download-clipboard - org-download-dnd-base64 - :init - ;; HACK We add these manually so that org-download is truly lazy-loaded - (pushnew! dnd-protocol-alist - '("^\\(?:https?\\|ftp\\|file\\|nfs\\):" . org-download-dnd) - '("^data:" . org-download-dnd-base64)) - (advice-add #'org-download-enable :override #'ignore) - - (after! org - ;; A shorter link to attachments - (+org-define-basic-link "download" (lambda () (or org-download-image-dir org-attach-id-dir ".")) - :image-data-fun #'+org-image-file-data-fn - :requires 'org-download)) - :config - (unless org-download-image-dir - (setq org-download-image-dir org-attach-id-dir)) - (setq org-download-method 'attach - org-download-timestamp "_%Y%m%d_%H%M%S" - org-download-screenshot-method - (cond (IS-MAC "screencapture -i %s") - (IS-LINUX - (cond ((executable-find "maim") "maim -s %s") - ((executable-find "scrot") "scrot -s %s") - ((executable-find "gnome-screenshot") "gnome-screenshot -a -f %s")))) - - org-download-heading-lvl nil - org-download-link-format "[[download:%s]]\n" - org-download-annotate-function (lambda (_link) "") - org-download-link-format-function - (lambda (filename) - (if (eq org-download-method 'attach) - (format "[[attachment:%s]]\n" - (org-link-escape - (file-relative-name filename (org-attach-dir)))) - ;; Handle non-image files a little differently. Images should be - ;; inserted as normal with previews. Other files, like pdfs or zips, - ;; should be linked to, with an icon indicating the type of file. - (format (concat (unless (image-type-from-file-name filename) - (concat (+org-attach-icon-for filename) - " ")) - org-download-link-format) - (org-link-escape - (funcall org-download-abbreviate-filename-function filename))))) - org-download-abbreviate-filename-function - (lambda (path) - (if (file-in-directory-p path org-download-image-dir) - (file-relative-name path org-download-image-dir) - path))) - - (defadvice! +org--fix-org-download-delete-a (fn beg end &optional times) - "Fix `org-download-delete' for a non-standard `org-download-link-format'." - :around #'org-download--delete - (save-excursion - (save-match-data - (goto-char beg) - (let ((times (or times most-positive-fixnum)) - (linkname - (or (and (string-match "\\[\\[\\(\\w+\\):" org-download-link-format) - (match-string 1 org-download-link-format)) - "file"))) - (while (and (>= (cl-decf times) 0) - (re-search-forward (format "\\[\\[%s:\\([^]]*\\)\\]\\]" - (regexp-quote linkname)) - end t)) - (let ((str (match-string-no-properties 2))) - (delete-region beg (match-end 0)) - (when (file-exists-p str) - (delete-file str)))))))) - - (defadvice! +org--dragndrop-then-display-inline-images-a (_link filename) - :after #'org-download-insert-link - (when (image-type-from-file-name filename) - (save-excursion - (org-display-inline-images - t t - (progn (org-back-to-heading-or-point-min t) (point)) - (progn (org-end-of-subtree t t) - (when (and (org-at-heading-p) (not (eobp))) (backward-char 1)) - (point))))))) diff --git a/.config/emacs/modules/lang/org/contrib/ipython.el b/.config/emacs/modules/lang/org/contrib/ipython.el @@ -1,41 +0,0 @@ -;;; lang/org/contrib/babel.el -*- lexical-binding: t; -*- -;;;###if (modulep! +ipython) - -(use-package! ob-ipython - :defer t - :init - (defvar +ob-ipython-local-runtime-dir nil) - - (setq ob-ipython-resources-dir ".ob-ipython-resrc") - - (add-hook! '+org-babel-load-functions - (defun +org-babel-load-ipython-h (lang) - (and (string-prefix-p "jupyter-" (symbol-name lang)) - (require 'ob-ipython nil t)))) - - (after! org-src - (add-to-list 'org-src-lang-modes '("ipython" . python))) - (after! ox-latex - (add-to-list 'org-latex-minted-langs '(ipython "python"))) - :config - (set-popup-rules! - '(("\\*ob-ipython.*" - :slot 2 :side right :size 100 :height 0.2 - :select nil :quit nil :ttl nil) - ("^ \\*Python" - :slot 0 :side right :size 100 - :select nil :quit nil :ttl nil))) - - ;; advices for remote kernel and org-src-edit - (advice-add #'ob-ipython--create-repl :override #'+org-ob-ipython-create-repl-a) - (advice-add #'org-babel-edit-prep:ipython :override #'+org-babel-edit-prep:ipython-a) - (advice-add #'org-babel-execute:ipython :before #'+org-babel-execute:ipython-a) - (advice-add #'org-babel-ipython-initiate-session :override #'+org-ob-ipython-initiate-session-a) - - ;; retina resolution image hack - (when IS-MAC - (advice-add #'ob-ipython--write-base64-string :around #'+org-ob-ipython-write-base64-string-a)) - - ;; ipython has its own async keyword, disable ipython in ob-async. - (after! ob-async - (add-to-list 'ob-async-no-async-languages-alist "ipython"))) diff --git a/.config/emacs/modules/lang/org/contrib/journal.el b/.config/emacs/modules/lang/org/contrib/journal.el @@ -1,72 +0,0 @@ -;;; lang/org/contrib/journal.el -*- lexical-binding: t; -*- -;;;###if (modulep! +journal) - -(use-package! org-journal - :defer t - :init - ;; HACK `org-journal' adds a `magic-mode-alist' entry for detecting journal - ;; files, but this causes us lazy loaders a big problem: an unacceptable - ;; delay on the first file the user opens, because calling the autoloaded - ;; `org-journal-is-journal' pulls all of `org' with it. So, we replace it - ;; with our own, extra layer of heuristics. - (add-to-list 'magic-mode-alist '(+org-journal-p . org-journal-mode)) - - (defun +org-journal-p () - "Wrapper around `org-journal-is-journal' to lazy load `org-journal'." - (when-let (buffer-file-name (buffer-file-name (buffer-base-buffer))) - (if (or (featurep 'org-journal) - (and (file-in-directory-p - buffer-file-name (expand-file-name org-journal-dir org-directory)) - (require 'org-journal nil t))) - (org-journal-is-journal)))) - - ;; `org-journal-dir' defaults to "~/Documents/journal/", which is an odd - ;; default, so we change it to {org-directory}/journal (we expand it after - ;; org-journal is loaded). - (setq org-journal-dir "journal/" - org-journal-cache-file (concat doom-cache-dir "org-journal")) - - :config - ;; Remove the orginal journal file detector and rely on `+org-journal-p' - ;; instead, to avoid loading org-journal until the last possible moment. - (setq magic-mode-alist (assq-delete-all 'org-journal-is-journal magic-mode-alist)) - - ;; `org-journal' can't deal with symlinks, so resolve them here. - (setq org-journal-dir (expand-file-name org-journal-dir org-directory) - ;; Doom opts for an "open in a popup or here" strategy as a default. - ;; Open in "other window" is less predictable, and can replace a window - ;; we wanted to keep visible. - org-journal-find-file #'find-file) - - ;; Setup carryover to include all configured TODO states. We cannot carry over - ;; [ ] keywords because `org-journal-carryover-items's syntax cannot correctly - ;; interpret it as anything other than a date. - (setq org-journal-carryover-items "TODO=\"TODO\"|TODO=\"PROJ\"|TODO=\"STRT\"|TODO=\"WAIT\"|TODO=\"HOLD\"") - - (set-company-backend! 'org-journal-mode 'company-capf 'company-dabbrev) - - (map! (:map org-journal-mode-map - :n "]f" #'org-journal-next-entry - :n "[f" #'org-journal-previous-entry - :n "C-n" #'org-journal-next-entry - :n "C-p" #'org-journal-previous-entry) - (:map org-journal-search-mode-map - "C-n" #'org-journal-search-next - "C-p" #'org-journal-search-previous) - :localleader - (:map org-journal-mode-map - (:prefix "j" - "c" #'org-journal-new-entry - "d" #'org-journal-new-date-entry - "n" #'org-journal-next-entry - "p" #'org-journal-previous-entry) - (:prefix "s" - "s" #'org-journal-search - "f" #'org-journal-search-forever - "F" #'org-journal-search-future - "w" #'org-journal-search-calendar-week - "m" #'org-journal-search-calendar-month - "y" #'org-journal-search-calendar-year)) - (:map org-journal-search-mode-map - "n" #'org-journal-search-next - "p" #'org-journal-search-prev))) diff --git a/.config/emacs/modules/lang/org/contrib/jupyter.el b/.config/emacs/modules/lang/org/contrib/jupyter.el @@ -1,40 +0,0 @@ -;;; lang/org/contrib/jupyter.el -*- lexical-binding: t; -*- -;;;###if (modulep! +jupyter) - -(use-package! ob-jupyter - :defer t - :init - (after! ob-async - (pushnew! ob-async-no-async-languages-alist - "jupyter-python" - "jupyter-julia" - "jupyter-R")) - - (after! org-src - (dolist (lang '(python julia R)) - (cl-pushnew (cons (format "jupyter-%s" lang) lang) - org-src-lang-modes :key #'car))) - - (add-hook! '+org-babel-load-functions - (defun +org-babel-load-jupyter-h (lang) - (when (string-prefix-p "jupyter-" (symbol-name lang)) - (require 'jupyter) - (let* ((lang-name (symbol-name lang)) - (lang-tail (string-remove-prefix "jupyter-" lang-name))) - (and (not (assoc lang-tail org-src-lang-modes)) - (require (intern (format "ob-%s" lang-tail)) - nil t) - (add-to-list 'org-src-lang-modes (cons lang-name (intern lang-tail))))) - (with-demoted-errors "Jupyter: %s" - (require lang nil t) - (require 'ob-jupyter nil t))))) - :config - (defadvice! +org--ob-jupyter-initiate-session-a (&rest _) - :after #'org-babel-jupyter-initiate-session - (unless (bound-and-true-p jupyter-org-interaction-mode) - (jupyter-org-interaction-mode))) - - ;; Remove text/html since it's not human readable - (delq! :text/html jupyter-org-mime-types) - - (require 'tramp)) diff --git a/.config/emacs/modules/lang/org/contrib/noter.el b/.config/emacs/modules/lang/org/contrib/noter.el @@ -1,14 +0,0 @@ -;;; lang/org/contrib/noter.el -*- lexical-binding: t; -*- -;;;###if (modulep! +noter) - -(use-package! org-noter - :defer t - :preface - ;; Allow the user to preempt this and set the document search path - ;; If not set then use `org-directory' - (defvar org-noter-notes-search-path nil) - :config - (unless org-noter-notes-search-path - (setq org-noter-notes-search-path (list org-directory))) - (setq org-noter-auto-save-last-location t - org-noter-separate-notes-from-heading t)) diff --git a/.config/emacs/modules/lang/org/contrib/pomodoro.el b/.config/emacs/modules/lang/org/contrib/pomodoro.el @@ -1,17 +0,0 @@ -;;; lang/org/contrib/pomodoro.el -*- lexical-binding: t; -*- -;;;###if (modulep! +pomodoro) - -(after! org-pomodoro - ;; prefer PulseAudio to ALSA in $current_year - (setq org-pomodoro-audio-player (or (executable-find "paplay") - org-pomodoro-audio-player)) - - ;; configure pomodoro alerts to use growl or libnotify - (alert-add-rule :category "org-pomodoro" - :style (cond (alert-growl-command - 'growl) - (alert-notifier-command - 'notifier) - (alert-libnotify-command - 'libnotify) - (alert-default-style)))) diff --git a/.config/emacs/modules/lang/org/contrib/present.el b/.config/emacs/modules/lang/org/contrib/present.el @@ -1,68 +0,0 @@ -;;; lang/org/contrib/present.el -*- lexical-binding: t; -*- -;;;###if (modulep! +present) - -(defvar +org-present-text-scale 5 - "The `text-scale-amount' for `org-tree-slide-mode'.") - -(defvar +org-present-hide-first-heading nil - "If non-nil, hide the top-level heading for the current slide. - -Some presenters think the first level heading takes up too much space, or use -them as slide names, rather than titles. Instead, you can use second level -headings as titles, and you have more freedom to place them wherever you like.") - - -(after! ox - (add-to-list 'org-export-backends 'beamer)) - - -;; -;;; Packages - -(use-package! org-re-reveal - :after ox - :config - (setq org-re-reveal-root (expand-file-name "../../" (locate-library "dist/reveal.js" t)) - org-re-reveal-revealjs-version "4")) - - -(use-package! org-tree-slide - :commands org-tree-slide-mode - :config - (org-tree-slide-simple-profile) - (setq org-tree-slide-activate-message " " - org-tree-slide-deactivate-message " " - org-tree-slide-modeline-display nil - org-tree-slide-heading-emphasis t) - - (add-hook 'org-tree-slide-after-narrow-hook #'org-display-inline-images) - (add-hook 'org-tree-slide-mode-hook #'+org-present-prettify-slide-h) - (add-hook 'org-tree-slide-play-hook #'+org-present-hide-blocks-h) - (add-hook 'org-tree-slide-stop-hook #'+org-present-hide-blocks-h) - - (when (modulep! :editor evil) - (map! :map org-tree-slide-mode-map - :n [C-right] #'org-tree-slide-move-next-tree - :n [C-left] #'org-tree-slide-move-previous-tree) - (add-hook 'org-tree-slide-mode-hook #'evil-normalize-keymaps)) - - (defadvice! +org-present--hide-first-heading-maybe-a (fn &rest args) - "Omit the first heading if `+org-present-hide-first-heading' is non-nil." - :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)) - (when +org-present-hide-first-heading - (forward-line 1)) - (point)) - (progn (org-end-of-subtree t t) - (when (and (org-at-heading-p) (not (eobp))) - (backward-char 1)) - (point))))))) - (apply fn args)))) diff --git a/.config/emacs/modules/lang/org/contrib/pretty.el b/.config/emacs/modules/lang/org/contrib/pretty.el @@ -1,28 +0,0 @@ -;;; lang/org/contrib/pretty.el -*- lexical-binding: t; -*- -;;;###if (modulep! +pretty) -(after! org - (setq org-highlight-latex-and-related '(native script entities))) - - -(use-package! org-superstar ; "prettier" bullets - :hook (org-mode . org-superstar-mode) - :config - ;; Make leading stars truly invisible, by rendering them as spaces! - (setq org-superstar-leading-bullet ?\s - org-superstar-leading-fallback ?\s - org-hide-leading-stars nil - org-superstar-todo-bullet-alist - '(("TODO" . 9744) - ("[ ]" . 9744) - ("DONE" . 9745) - ("[X]" . 9745)))) - - -(use-package! org-fancy-priorities ; priority icons - :hook (org-mode . org-fancy-priorities-mode) - :hook (org-agenda-mode . org-fancy-priorities-mode) - :config (setq org-fancy-priorities-list '("⚑" "⬆" "■"))) - - -(use-package! org-appear ; better markup edit - :hook (org-mode . org-appear-mode)) diff --git a/.config/emacs/modules/lang/org/contrib/roam.el b/.config/emacs/modules/lang/org/contrib/roam.el @@ -1,96 +0,0 @@ -;;; lang/org/contrib/roam.el -*- lexical-binding: t; -*- -;;;###if (modulep! +roam) - -(defvar +org-roam-open-buffer-on-find-file t - "If non-nil, open the org-roam buffer when opening an org roam file.") - - -;; -;;; Packages - -(use-package! org-roam - :hook (org-load . +org-init-roam-maybe-h) - :hook (org-roam-backlinks-mode . turn-on-visual-line-mode) - :commands (org-roam-buffer-toggle-display - org-roam-dailies-find-date - org-roam-dailies-find-today - org-roam-dailies-find-tomorrow - org-roam-dailies-find-yesterday) - :preface - ;; Set this to nil so we can later detect if the user has set custom values - ;; for these variables. If not, default values will be set in the :config - ;; section. - (defvar org-roam-directory nil) - (defvar org-roam-db-location nil) - :init - (map! :after org - :map org-mode-map - :localleader - :prefix ("m" . "org-roam") - "b" #'org-roam-switch-to-buffer - "f" #'org-roam-find-file - "g" #'org-roam-graph - "i" #'org-roam-insert - "I" #'org-roam-insert-immediate - "m" #'org-roam - "t" #'org-roam-tag-add - "T" #'org-roam-tag-delete - (:prefix ("d" . "by date") - :desc "Find previous note" "b" #'org-roam-dailies-find-previous-note - :desc "Find date" "d" #'org-roam-dailies-find-date - :desc "Find next note" "f" #'org-roam-dailies-find-next-note - :desc "Find tomorrow" "m" #'org-roam-dailies-find-tomorrow - :desc "Capture today" "n" #'org-roam-dailies-capture-today - :desc "Find today" "t" #'org-roam-dailies-find-today - :desc "Capture Date" "v" #'org-roam-dailies-capture-date - :desc "Find yesterday" "y" #'org-roam-dailies-find-yesterday - :desc "Find directory" "." #'org-roam-dailies-find-directory)) - :config - (defun +org-init-roam-maybe-h () - "Activate `org-roam-mode'. If it fails, fail gracefully." - (unless (with-demoted-errors "ORG ROAM ERROR: %s" - (org-roam-mode +1) - t) - (message "To try reinitializing org-roam, run 'M-x org-roam-mode'") - (org-roam-mode -1))) - - (setq org-roam-directory - (file-name-as-directory - (file-truename - (expand-file-name (or org-roam-directory "roam") - org-directory))) - org-roam-db-location (or org-roam-db-location - (concat doom-data-dir "org-roam.db")) - ;; Make org-roam buffer sticky; i.e. don't replace it when opening a - ;; file with an *-other-window command. - org-roam-buffer-window-parameters '((no-delete-other-windows . t)) - org-roam-link-use-custom-faces 'everywhere - org-roam-completion-everywhere t - org-roam-completion-system - (cond ((modulep! :completion helm) 'helm) - ((modulep! :completion ivy) 'ivy) - ((modulep! :completion ido) 'ido) - ('default))) - - ;; Normally, the org-roam buffer doesn't open until you explicitly call - ;; `org-roam'. If `+org-roam-open-buffer-on-find-file' is non-nil, the - ;; org-roam buffer will be opened for you when you use `org-roam-find-file' - ;; (but not `find-file', to limit the scope of this behavior). - (add-hook! 'find-file-hook - (defun +org-roam-open-buffer-maybe-h () - (and +org-roam-open-buffer-on-find-file - (memq 'org-roam-buffer--update-maybe post-command-hook) - (not (window-parameter nil 'window-side)) ; don't proc for popups - (not (eq 'visible (org-roam-buffer--visibility))) - (with-current-buffer (window-buffer) - (org-roam-buffer--get-create))))) - - ;; Hide the mode line in the org-roam buffer, since it serves no purpose. This - ;; makes it easier to distinguish from other org buffers. - (add-hook 'org-roam-buffer-prepare-hook #'hide-mode-line-mode)) - - -;; Since the org module lazy loads org-protocol (waits until an org URL is -;; detected), we can safely chain `org-roam-protocol' to it. -(use-package! org-roam-protocol - :after org-protocol) diff --git a/.config/emacs/modules/lang/org/contrib/roam2.el b/.config/emacs/modules/lang/org/contrib/roam2.el @@ -1,207 +0,0 @@ -;;; lang/org/contrib/roam2.el -*- lexical-binding: t; -*- -;;;###if (modulep! +roam2) - -(defvar +org-roam-auto-backlinks-buffer nil - "If non-nil, open and close the org-roam backlinks buffer automatically. - -This ensures the backlinks buffer is always present so long as an org roam file -is visible. Once they are all closed or killed, the backlinks buffer will be -closed.") - -(defvar +org-roam-link-to-org-use-id 'create-if-interactive - "`org-roam-directory' local value for `org-id-link-to-org-use-id'. -It's not recommended to set this to nil in order for other parts -of org-mode to properly utilize ID links.") - - -;; -;;; Packages - -(use-package! org-roam - :hook (org-load . +org-init-roam-h) - :preface - ;; Set this to nil so we can later detect if the user has set custom values - ;; for these variables. If not, default values will be set in the :config - ;; section. - (defvar org-roam-directory nil) - - :init - (doom-load-packages-incrementally - '(ansi-color dash f rx seq magit-section emacsql emacsql-sqlite)) - - ;; Don't display warning message dedicated for v1 users. Need to be set early. - (setq org-roam-v2-ack t) - - (defadvice! +org-roam-suppress-sqlite-build-a (fn &rest args) - "Suppress automatic building of sqlite3 binary when loading `org-roam'. -This is a blocking operation that can take a while to complete -and better be deferred when there will be an actual demand for -the database. See `+org-init-roam-h' for the launch process." - :around #'emacsql-sqlite-ensure-binary - (if (not (boundp 'org-roam-db-version)) - (apply fn args) - (advice-remove #'emacsql-sqlite-ensure-binary #'+org-roam-suppress-sqlite-build-a) - nil)) - - :config - (defun +org-init-roam-h () - "Setup `org-roam' but don't immediately initialize its database. -Instead, initialize it when it will be actually needed." - (letf! ((#'org-roam-db-sync #'ignore)) - (org-roam-db-autosync-enable))) - - (defadvice! +org-roam-try-init-db-a (&rest _) - "Try to initialize org-roam database at the last possible safe moment. -In case of failure, fail gracefully." - :before #'org-roam-db-query - (message "Initializing org-roam database...") - (let ((run-cleanup-p t)) - (unwind-protect - ;; Try to build the binary if it doesn't exist. In case of failure - ;; this will error, run the cleanup and exit, and in case of success - ;; this will return nil and sync the database. - (setq run-cleanup-p (emacsql-sqlite-ensure-binary)) - (when run-cleanup-p - (setq org-roam--sqlite-available-p nil) - (org-roam-teardown) - (message (concat "EmacSQL failied to build SQLite binary for org-roam; " - "see *Compile-Log* buffer for details.\n" - "To try reinitialize org-roam, run \"M-x org-roam-setup\""))))) - (advice-remove 'org-roam-db-query #'+org-roam-try-init-db-a) - (org-roam-db-sync)) - - (setq org-roam-directory - (thread-first (or org-roam-directory "roam") - (expand-file-name org-directory) - (file-truename) - (file-name-as-directory)) - org-roam-node-display-template - (format "${doom-hierarchy:*} %s %s" - (propertize "${doom-type:12}" 'face 'font-lock-keyword-face) - (propertize "${doom-tags:42}" 'face 'org-tag)) - org-roam-completion-everywhere t - org-roam-db-gc-threshold most-positive-fixnum - ;; Reverse the default to favor faster searchers over slower ones. - org-roam-list-files-commands '(fd fdfind rg find)) - - (add-to-list 'org-roam-node-template-prefixes '("doom-tags" . "#")) - (add-to-list 'org-roam-node-template-prefixes '("doom-type" . "@")) - - ;; REVIEW Remove when addressed upstream. See org-roam/org-roam#2066. - (defadvice! +org--roam-fix-completion-width-for-vertico-a (fn &rest args) - "Fixes completion candidate width for vertico users." - :around #'org-roam-node-read--to-candidate - (letf! (defun org-roam-node--format-entry (template node &optional width) - (funcall org-roam-node--format-entry template node - (if (bound-and-true-p vertico-mode) - (if (minibufferp) - (window-width) - (1- (frame-width))) - width))) - (apply fn args))) - - (setq-hook! 'org-roam-find-file-hook - org-id-link-to-org-use-id +org-roam-link-to-org-use-id) - - ;; Normally, the org-roam buffer won't open until `org-roam-buffer-toggle' is - ;; explicitly called. If `+org-roam-open-buffer-on-find-file' is non-nil, the - ;; org-roam buffer will automatically open whenever a file in - ;; `org-roam-directory' is visited and closed when no org-roam buffers remain. - (add-hook! 'org-roam-find-file-hook :append - (defun +org-roam-enable-auto-backlinks-buffer-h () - (add-hook 'doom-switch-buffer-hook #'+org-roam-manage-backlinks-buffer-h))) - - (set-popup-rules! - `((,(regexp-quote org-roam-buffer) ; persistent org-roam buffer - :side right :width 0.33 :height 0.5 :ttl nil :modeline nil :quit nil :slot 1) - ("^\\*org-roam: " ; node dedicated org-roam buffer - :side right :width 0.33 :height 0.5 :ttl nil :modeline nil :quit nil :slot 2))) - - ;; Soft-wrap lines in the backlinks buffer - (add-hook 'org-roam-mode-hook #'turn-on-visual-line-mode) - - ;; Use a 'roam:X' link's description if X is empty. - ;; TODO PR this upstream? - (advice-add #'org-roam-link-follow-link :filter-args #'org-roam-link-follow-link-with-description-a) - (advice-add #'org-roam-link-replace-at-point :override #'org-roam-link-replace-at-point-a) - - (map! :map org-mode-map - :localleader - :prefix ("m" . "org-roam") - "D" #'org-roam-demote-entire-buffer - "f" #'org-roam-node-find - "F" #'org-roam-ref-find - "g" #'org-roam-graph - "i" #'org-roam-node-insert - "I" #'org-id-get-create - "m" #'org-roam-buffer-toggle - "M" #'org-roam-buffer-display-dedicated - "n" #'org-roam-capture - "r" #'org-roam-refile - "R" #'org-roam-link-replace-all - (:prefix ("d" . "by date") - :desc "Goto previous note" "b" #'org-roam-dailies-goto-previous-note - :desc "Goto date" "d" #'org-roam-dailies-goto-date - :desc "Capture date" "D" #'org-roam-dailies-capture-date - :desc "Goto next note" "f" #'org-roam-dailies-goto-next-note - :desc "Goto tomorrow" "m" #'org-roam-dailies-goto-tomorrow - :desc "Capture tomorrow" "M" #'org-roam-dailies-capture-tomorrow - :desc "Capture today" "n" #'org-roam-dailies-capture-today - :desc "Goto today" "t" #'org-roam-dailies-goto-today - :desc "Capture today" "T" #'org-roam-dailies-capture-today - :desc "Goto yesterday" "y" #'org-roam-dailies-goto-yesterday - :desc "Capture yesterday" "Y" #'org-roam-dailies-capture-yesterday - :desc "Find directory" "-" #'org-roam-dailies-find-directory) - (:prefix ("o" . "node properties") - "a" #'org-roam-alias-add - "A" #'org-roam-alias-remove - "t" #'org-roam-tag-add - "T" #'org-roam-tag-remove - "r" #'org-roam-ref-add - "R" #'org-roam-ref-remove)) - - (when (modulep! :editor evil +everywhere) - (add-hook! 'org-roam-mode-hook - (defun +org-roam-detach-magit-section-mode-map-h () - "Detach `magit-section-mode-map' from `org-roam-mode-map'. -Inheriting its keymaps introduces a lot of conflicts in -`org-roam-mode' based buffers, where Evil and leader keybindings -will become completely overridden. This is because `magit-section' -uses 'keymap text-property to attach section-unique keymaps, which -has a higher level of precedence than `emulation-mode-map-alists'. - -Note: We do this each time through the hook, because otherwise -sections seems to ignore the detachment." - (set-keymap-parent org-roam-mode-map nil))) - - (map! :map org-roam-mode-map - :nv "]" #'magit-section-forward-sibling - :nv "[" #'magit-section-backward-sibling - :nv "gj" #'magit-section-forward-sibling - :nv "gk" #'magit-section-backward-sibling - :nv "gr" #'revert-buffer - :nv "gR" #'revert-buffer - :nv "z1" #'magit-section-show-level-1 - :nv "z2" #'magit-section-show-level-2 - :nv "z3" #'magit-section-show-level-3 - :nv "z4" #'magit-section-show-level-4 - :nv "za" #'magit-section-toggle - :nv "zc" #'magit-section-hide - :nv "zC" #'magit-section-hide-children - :nv "zo" #'magit-section-show - :nv "zO" #'magit-section-show-children - :nv "zm" #'magit-section-show-level-2-all - :nv "zr" #'magit-section-show-level-4-all - :nv "C-j" #'magit-section-forward - :nv "C-k" #'magit-section-backward - :g "M-p" #'magit-section-backward-sibling - :g "M-n" #'magit-section-forward-sibling - :g [tab] #'magit-section-toggle - :g [C-tab] #'magit-section-cycle - :g [backtab] #'magit-section-cycle-global))) - - -;; Since the org module lazy loads org-protocol (waits until an org URL is -;; detected), we can safely chain `org-roam-protocol' to it. -(use-package! org-roam-protocol - :after org-protocol) diff --git a/.config/emacs/modules/lang/org/doctor.el b/.config/emacs/modules/lang/org/doctor.el @@ -1,32 +0,0 @@ -;; -*- lexical-binding: t; no-byte-compile: t; -*- -;;; lang/org/doctor.el - -(when (modulep! +gnuplot) - (unless (executable-find "gnuplot") - (warn! "Couldn't find gnuplot. org-plot/gnuplot will not work"))) - -(when (modulep! +roam) - (warn! "You are using org-roam-v1. This version is unmaintained Doom support for it will eventually be removed.\ -Migrate your notes to org-roam-v2 and switch to the +roam2 flag (see the module readme).") - (unless (executable-find "sqlite3") - (warn! "Couldn't find the sqlite3 executable. org-roam will not work."))) -(when (or (modulep! +roam) - (modulep! +roam2)) - (unless (executable-find "dot") - (warn! "Couldn't find the dot executable (from graphviz). org-roam will not be able to generate graph visualizations."))) - -(when (modulep! +dragndrop) - (when IS-MAC - (unless (executable-find "pngpaste") - (warn! "Couldn't find the pngpaste executable. org-download-clipboard will not work."))) - (when IS-LINUX - (unless (or (executable-find "maim") (executable-find "scrot") (executable-find "gnome-screenshot")) - (warn! "Couldn't find the maim, scrot or gnome-screenshot executable. org-download-clipboard will not work.")) - (if (string= "wayland" (getenv "XDG_SESSION_TYPE")) - (unless (executable-find "wl-paste") - (warn! "Couldn't find the wl-paste executable (from wl-clipboard). org-download-clipboard will not work.")) - (unless (executable-find "xclip") - (warn! "Couldn't find the xclip executable. org-download-clipboard will not work.")))) - (when IS-WINDOWS - (unless (executable-find "convert") - (warn! "Couldn't find the convert program (from ImageMagick). org-download-clipboard will not work.")))) diff --git a/.config/emacs/modules/lang/org/packages.el b/.config/emacs/modules/lang/org/packages.el @@ -1,167 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/org/packages.el - -(package! org - :recipe (:host github - ;; REVIEW: I intentionally avoid git.savannah.gnu.org because of SSL - ;; issues (see #5655), uptime issues, download time, and lack of - ;; shallow clone support. - :repo "emacs-straight/org-mode" - :files (:defaults "etc") - :depth 1 - ;; HACK: Org has a post-install step that generates org-version.el - ;; and org-loaddefs.el, but Straight doesn't invoke this step, and - ;; the former doesn't work if the Org repo is a shallow clone. - ;; Rather than impose the network burden of a full clone (and other - ;; redundant work in Org's makefile), I'd rather fake these files - ;; instead. Besides, Straight already produces a org-autoloads.el, - ;; so org-loaddefs.el isn't needed. - :build t - :pre-build - (progn - (with-temp-file "org-loaddefs.el") - (with-temp-file "org-version.el" - (let ((version - (with-temp-buffer - (insert-file-contents (doom-path "lisp/org.el") nil 0 1024) - (if (re-search-forward "^;; Version: \\([^\n-]+\\)" nil t) - (match-string-no-properties 1) - "Unknown")))) - (insert (format "(defun org-release () %S)\n" version) - (format "(defun org-git-version (&rest _) \"%s-??-%s\")\n" - version (cdr (doom-call-process "git" "rev-parse" "--short" "HEAD"))) - "(provide 'org-version)\n"))))) - :pin "fe92a3cedba541482d5954eacb2b13e6f57a39c4") -(package! org-contrib - :recipe (:host github - :repo "emacsmirror/org-contrib") - :pin "fff6c888065588527b1c1d7dd7e41c29ef767e17") - -(package! avy) -(package! htmlize :pin "dd27bc3f26efd728f2b1f01f9e4ac4f61f2ffbf9") -(package! org-yt - :recipe (:host github :repo "TobiasZawada/org-yt") - :pin "40cc1ac76d741055cbefa13860d9f070a7ade001") -(package! ox-clip :pin "ff117cf3c619eef12eccc0ccbfa3f11adb73ea68") -(package! toc-org :pin "bf2e4b358efbd860ecafe6e74776de0885d9d100") -(package! org-cliplink :pin "13e0940b65d22bec34e2de4bc8cba1412a7abfbc") - -;; TODO Adjust when this is added to GNU ELPA -(when (modulep! +contacts) - (package! org-contacts - :pin "bb4032eb12c20d34555a4e670f28696cf31a7b54" - :recipe (:host nil - :type git - :repo "https://repo.or.cz/org-contacts.git"))) - -(when (and IS-MAC - (modulep! :os macos)) - (package! org-mac-link :pin "0b18c1d070b9601cc65c40e902169e367e4348c9")) - -(when (modulep! +passwords) - (package! org-passwords - :pin "61584aa701defcc0c435d3e7552916235cb655a6" - :recipe (:host github - :repo "alfaromurillo/org-passwords.el"))) - -(when (modulep! :editor evil +everywhere) - (package! evil-org - :recipe (:host github :repo "hlissner/evil-org-mode") - :pin "a9706da260c45b98601bcd72b1d2c0a24a017700")) -(when (modulep! :tools pdf) - (package! org-pdftools :pin "967f48fb5038bba32915ee9da8dc4e8b10ba3376")) -(when (modulep! :tools magit) - (package! orgit :pin "fc40397f7b36fa513d41f3119b7430cb236de9dd") - (when (modulep! :tools magit +forge) - (package! orgit-forge :pin "6f424ff3a2df7d9c00c217011949c1367cc15227"))) -(when (modulep! +brain) - (package! org-brain :pin "2bad7732aae1a3051e2a14de2e30f970bbe43c25")) -(when (modulep! +dragndrop) - (package! org-download :pin "19e166f0a8c539b4144cfbc614309d47a9b2a9b7")) -(when (modulep! +gnuplot) - (package! gnuplot :pin "7138b139d2dca9683f1a81325c643b2744aa1ea3") - (package! gnuplot-mode :pin "601f6392986f0cba332c87678d31ae0d0a496ce7")) -(when (modulep! +ipython) ; DEPRECATED - (package! ob-ipython :pin "7147455230841744fb5b95dcbe03320313a77124")) -(when (modulep! +jupyter) - (package! jupyter :pin "eebeef1293287075f65d27f5442bb151bf27d92a")) -(when (modulep! +journal) - (package! org-journal :pin "2f220a06e3bf6bfa5cda00ebd44817a7b2fd7b76")) -(when (modulep! +noter) - (package! org-noter :pin "9ead81d42dd4dd5074782d239b2efddf9b8b7b3d")) -(when (modulep! +pomodoro) - (package! org-pomodoro :pin "3f5bcfb80d61556d35fc29e5ddb09750df962cc6")) -(when (modulep! +pretty) - (package! org-appear :pin "eb9f9db40aa529fe4b977235d86494b115281d17") - (package! org-superstar :pin "54c81c27dde2a6dc461bb064e79a8b2089093a2e") - (package! org-fancy-priorities :pin "7f677c6c14ecf05eab8e0efbfe7f1b00ae68eb1d")) -(when (modulep! +present) - (package! centered-window - :recipe (:host github :repo "anler/centered-window-mode") - :pin "80965f6c6afe8d918481433984b493de72af5399") - (package! org-tree-slide :pin "d6529bc2df727d09014e0e56abf4f15a8e8fc20f") - (package! org-re-reveal :pin "91cdd82c47b86990b5eb41fe34446a042194cc83") - (package! revealjs - :recipe (:host github :repo "hakimel/reveal.js" - :files ("css" "dist" "js" "plugin")) - :pin "7de6ccb65b98f657f757cb5610613ad9d4f3da2b")) -(cond - ((modulep! +roam) - (package! org-roam - :recipe (:host github :repo "org-roam/org-roam-v1") - :pin "946a879a4a18756a0508afba1e0b0fe070c6a8b4")) - ((modulep! +roam2) - (package! org-roam - ;; FIXME A :recipe isn't strictly necessary, but without it, our package - ;; bumper fails to distinguish between org-roam v1 and v2. - :recipe (:host github :repo "org-roam/org-roam") - :pin "74422df546a515bc984c2f3d3a681c09d6f43916"))) - -;;; Babel -(package! ob-async :pin "9aac486073f5c356ada20e716571be33a350a982") -(when (modulep! :lang clojure) - (package! ob-clojure-literate - :recipe (:type git - :host nil - :repo "https://repo.or.cz/ob-clojure-literate.el.git") - :pin "18c3ea15b872a43e67c899a9914182c35b00b7ee")) -(when (modulep! :lang crystal) - (package! ob-crystal :pin "d84c1adee4b269cdba06a97caedb8071561a09af")) -(when (modulep! :lang elixir) - (package! ob-elixir :pin "8990a8178b2f7bd93504a9ab136622aab6e82e32")) -(when (modulep! :lang fsharp) - (package! ob-fsharp - :recipe (:host github :repo "elken/ob-fsharp") - :pin "a5bb40915a8b78fb3c5fc4b44ad00393e07e46a4")) -(when (modulep! :lang go) - (package! ob-go :pin "2067ed55f4c1d33a43cb3f6948609d240a8915f5")) -(when (modulep! :lang graphql) - (package! ob-graphql :pin "7c35419f9eec5dc44967cbcfa13c7135b9a96bfc")) -(when (modulep! :lang hy) - (package! ob-hy :pin "a42ecaf440adc03e279afe43ee5ef6093ddd542a")) -(when (modulep! :lang nim) - (package! ob-nim :pin "6fd060a3ecd38be37e4ec2261cd65760a3c35a91")) -(when (modulep! :lang php) - (package! ob-php - :recipe (:type git - :host nil - :repo "https://repo.or.cz/ob-php.git") - :pin "6ebf7799e9ded1d5114094f46785960a50000614")) -(when (modulep! :lang racket) - (package! ob-racket - :recipe (:host github :repo "DEADB17/ob-racket") - :pin "d8fd51bddb019b0eb68755255f88fc800cfe03cb")) -(when (modulep! :lang rest) - (package! ob-restclient :pin "1b021ce1c67c97fa1aa4d2c0816edb7add129e48")) -(when (modulep! :lang scala) - (package! ob-ammonite :pin "39937dff395e70aff76a4224fa49cf2ec6c57cca")) - -;;; Export -(when (modulep! +pandoc) - (package! ox-pandoc :pin "66c32cca4f6047dd7e0f77f10bd565a2d83d4729")) -(when (modulep! +hugo) - (package! ox-hugo - :recipe (:host github :repo "kaushalmodi/ox-hugo" :nonrecursive t) - :pin "706b5f622d168bb8e0cf503e0525d2db9177c83e")) -(when (modulep! :lang rst) - (package! ox-rst :pin "99fa790da55b57a3f2e9aa187493ba434a64250e")) diff --git a/.config/emacs/modules/lang/org/test/test-org.el b/.config/emacs/modules/lang/org/test/test-org.el @@ -1,133 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/org/test/test-autoload-org.el - -(describe "lang/org" - ;; `+org/insert-item' - (describe "insert-item" - (before-all - (require 'org) - (load! "../autoload/org.el")) - (after-all - (unload-feature 'org t)) - - (before-each - (set-buffer (get-buffer-create "org")) - (erase-buffer) - (delay-mode-hooks (org-mode))) - (after-each - (kill-buffer (get-buffer "org"))) - - (describe "headlines" - (it "opens new headline below" - (insert!! "* {0}Header") - (+org/insert-item-below 1) - (expect (eobp)) - (expect (buffer-substring-no-properties (point-min) (point-max)) - :to-equal "* Header\n* ")) - - (it "opens new headline above" - (insert!! "* {0}Header") - (+org/insert-item-above 1) - (expect (eolp)) - (expect (buffer-substring-no-properties (point-min) (point-max)) - :to-equal "* \n* Header")) - - (it "appends headlines, skipping subtrees" - (insert!! "** {0}First\n" - "*** sub 1\n" - "*** sub 2\n" - "**** subsub 1\n" - "** Header") - (+org/insert-item-below 1) - (expect (eolp)) - (expect (line-number-at-pos) :to-be 5) - (expect (buffer-substring-no-properties (point-min) (point-max)) - :to-equal - (string-join '("** First" - "*** sub 1" - "*** sub 2" - "**** subsub 1" - "** " - "** Header") - "\n"))) - (it "prepends headlines, skipping subtrees" - (insert!! "** First\n" - "*** sub 1\n" - "*** sub 2\n" - "**** {0}subsub 1\n" - "** Header") - (+org/insert-item-above 1) - (expect (eolp)) - (expect (line-number-at-pos) :to-be 4) - (expect (buffer-substring-no-properties (point-min) (point-max)) - :to-equal - (string-join '("** First" - "*** sub 1" - "*** sub 2" - "**** " - "**** subsub 1" - "** Header") - "\n")))) - - (describe "plain lists" - (it "appends items" - (insert!! "+ {0}List item") - (+org/insert-item-below 1) - (expect (buffer-substring-no-properties (point-min) (point-max)) - :to-equal "+ List item\n+ ")) - (it "prepends items" - (insert!! "+ {0}List item") - (+org/insert-item-above 1) - (expect (buffer-substring-no-properties (point-min) (point-max)) - :to-equal "+ \n+ List item")) - - (it "appends items, but skips over child items" - (insert!! "+ {0}List item\n" - " + Sub item\n" - "+ List item") - (+org/insert-item-below 1) - (expect (buffer-substring-no-properties (point-min) (point-max)) - :to-equal - (string-join '("+ List item" - " + Sub item" - "+ " - "+ List item") - "\n"))) - (it "prepends items, but skips over child items" - (insert!! "+ List item\n" - " + Sub item\n" - "+ {0}List item") - (+org/insert-item-above 1) - (expect (buffer-substring-no-properties (point-min) (point-max)) - :to-equal - (string-join '("+ List item" - " + Sub item" - "+ " - "+ List item") - "\n")))) - - (describe "numbered lists" - (it "appends items and updates numbers" - (insert!! "1. {0}List item\n" - "2. Sub item\n" - "3. List item") - (+org/insert-item-below 1) - (expect (buffer-substring-no-properties (point-min) (point-max)) - :to-equal - (string-join '("1. List item" - "2. " - "3. Sub item" - "4. List item") - "\n"))) - (it "prepends items and updates numbers" - (insert!! "1. List item\n" - "2. Sub item\n" - "3. {0}List item") - (+org/insert-item-above 1) - (expect (buffer-substring-no-properties (point-min) (point-max)) - :to-equal - (string-join '("1. List item" - "2. Sub item" - "3. " - "4. List item") - "\n")))))) diff --git a/.config/emacs/modules/lang/php/README.org b/.config/emacs/modules/lang/php/README.org @@ -1,256 +0,0 @@ -#+title: :lang php -#+subtitle: Perl's insecure younger brother -#+created: January 16, 2017 -#+since: 1.3 - -* Description :unfold: -This module adds support for PHP 5.3+ (including PHP8) to Doom Emacs. - -- ctags-based code completion (~company-php~ and ~phpctags~) -- eldoc support (~ac-php~ and ~php-extras~) -- REPL (~psysh~) -- Code refactoring commands (~php-refactor-mode~) -- Unit-test commands (~phpunit~) -- Support for ~laravel~ and ~composer~ projects (with project-specific snippets) -- [[../../editor/file-templates/templates/php-mode][File templates]] -- [[https://github.com/hlissner/doom-snippets/tree/master/php-mode][Snippets]] - -#+begin_quote - 💬 PHP was the first programming language I got paid to code in, back in the - Cretaceous period (2003). My sincerest apologies go out to all the - programmers who inherited my earliest PHP work. I know you're out there, - writhing in your straitjackets. -#+end_quote - -** Maintainers -- [[doom-user:][@elken]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +hack :: - Add support for the [[https://hacklang.org/][Hack dialect of PHP]] by Facebook. -- +lsp :: - Enable LSP support for ~php-mode~. Requires [[doom-module::tools lsp]] and a langserver - (supports [[https://phpactor.readthedocs.io/en/develop/usage/standalone.html][phpactor]] and intelephense). -- +tree-sitter :: - Leverages tree-sitter for better syntax highlighting and structural text - editing. Requires [[doom-module::tools tree-sitter]]. - -** Packages -- [[doom-package:async]] -- [[doom-package:hack-mode]] if [[doom-module:+hack]] -- [[doom-package:psysh]] -- [[doom-package:php-cs-fixer]] if [[doom-package::editor format]] -- [[doom-package:php-extras]] -- [[doom-package:php-mode]] -- [[doom-package:php-refactor-mode]] -- [[doom-package:phpunit]] -- if [[doom-module:+lsp]] - - [[doom-package:phpactor]] - - [[doom-package:company-phpactor]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires ~php~ (5.3+) and ~composer~. - -If [[doom-module:+lsp]] is enabled, you'll also need one of these LSP servers: -- Phpactor requires ~php~ 7.3+. -- Intelephense requires ~node~ and ~npm~. - -** PHP -*** MacOS -PHP 5.5 comes prepackaged with newer versions of MacOS. These instructions are -provided for reference: - -#+begin_src sh -brew tap homebrew/homebrew-php -brew install php@8.0 # or php53, php54, php55 -brew install composer - -# If you use intelephense: -brew install node -brew install npm -#+end_src - -*** Arch Linux -#+begin_src sh -sudo pacman --needed --noconfirm -S php composer # or php53, php54, php55 - -# If you use intelephense: -sudo pacman -S nodejs npm -#+end_src - -*** openSUSE -#+begin_src sh -sudo zypper install php-composer - -# If you use intelephense: -sudo zypper install nodejs npm -#+end_src -*** Debian -#+begin_src sh -sudo apt-get install php php-common - -# If you use intelephense: -sudo apt-get install nodejs npm -#+end_src -** LSP Support -There are a number of currently supported LSP servers: - -- [[https://emacs-lsp.github.io/lsp-mode/page/lsp-intelephense/][Intelephense]] (_Recommended_) -- [[https://emacs-lsp.github.io/lsp-mode/page/lsp-phpactor/][phpactor]] -- [[https://emacs-lsp.github.io/lsp-mode/page/lsp-serenata/][Serenata]] -- [[https://emacs-lsp.github.io/lsp-mode/page/lsp-php/][felixbecker]] (Considered unsupported) - -Intelephense is currently the only server that supports automatic installation, -which will trigger either when you open a PHP project or manually invoke -~lsp-install-server~ through [[kbd:][M-x]]. - -The others have to be installed manually and added to your =$PATH=. - -** Dependencies -- ~pysh~ (REPL) -- ~phpctags~ (better code completion) -- ~phpunit~ (unit test commands) -- ~php-cs-fixer~ and ~@prettier/plugin-php~ (for code formatting) -+ ~phpactor~ (for LSP if intelephense isn't desired) - -#+begin_src sh -composer global require \ - psy/psysh \ - phpunit/phpunit \ - techlivezheng/phpctags \ - friendsofphp/php-cs-fixer \ - phpactor/phpactor - -# Needed by php-cs-fixer, otherwise you'll get "Couldn't resolve parser -# 'php'" errors -npm install -g @prettier/plugin-php -#+end_src - -You must ensure that =$HOME/.composer/vendor/bin= is in =$PATH=, so these -executables are visible to Emacs: -#+begin_src sh -# place this in your profile file, like ~/.bash_profile or ~/.zshenv -export PATH="~/.composer/vendor/bin:$PATH" -#+end_src - -You may also need to regenerate your envvar file by running ~$ doom env~ on the -command line. - -*NOTE* phpactor doesn't have to be installed via =composer=, just has to exist in -your =$PATH=. - -*NOTE* Phpactor cannot be installed, globally at least, with PHP ^8. - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** PHPUnit -This module provides an interface to PHPUnit through a number of commands as -detailed below. By default, it loads configuration from the root ~phpunit.xml~. - -+ ~phpunit-current-project~ Launch all tests for the project -+ ~phpunit-current-class~ Launch all tests for the current class/fixture -+ ~phpunit-current-test~ Launch the current test at point - -If for some reason, the default ~phpunit.xml~ is in a different location (or you -use the ~phpunit.xml.dist~ convention) , the path can be changed via -=phpunit-configuration-file= - -#+begin_src emacs-lisp -(setq phpunit-configuration-file "phpunit.xml") -#+end_src - -** Composer -This module provides several convenience methods for triggering composer -commands: - -| Binding | Function | -|---------------------+-----------------------------------| -| [[kbd:][<localleader> m c c]] | ~composer~ | -| [[kbd:][<localleader> m c i]] | ~composer-install~ | -| [[kbd:][<localleader> m c r]] | ~composer-require~ | -| [[kbd:][<localleader> m c u]] | ~composer-update~ | -| [[kbd:][<localleader> m c d]] | ~composer-dump-autoload~ | -| [[kbd:][<localleader> m c s]] | ~composer-run-scripts~ | -| [[kbd:][<localleader> m c v]] | ~composer-run-vendor-bin-command~ | -| [[kbd:][<localleader> m c o]] | ~composer-find-json-file~ | -| [[kbd:][<localleader> m c l]] | ~composer-view-lock-file~ | - -These are all run via [[kbd:][M-x]] too. - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** Docker Compose -A lot of projects rely on running inside docker compose (ie Laravel), and as -such a minor mode has been configured to attempt to run tests inside the =php-fpm= -(by default) container. - -This mode is disabled by default, to opt-in set =+php-run-tests-in-docker= to =t= in -your config. If this is done during Emacs running, you will also have to reload -=php-mode= (i.e. through =M-x php-mode=) - -If you wish to specify a different container, modify the -~+php-default-docker-container~ variable (ideally inside a ~.dir-locals.el~ file) - -#+begin_src emacs-lisp -((php-mode . ((+php-default-docker-container . "php-octane")))) -#+end_src - -* Troubleshooting -[[doom-report:][Report an issue?]] - -** "I'm missing functionality on lsp-mode" -Unfortunately, [[https://intelephense.com/][intelephense]] currently operates under a "freemium" model, and as -such requires a license for extended features. Once purchased, this can be -(insecurely) added directly to your config: -#+begin_src emacs-lisp -(setq lsp-intelephense-licence-key "<key>") -#+end_src - -A more recommended approach would be to utilise Emacs' own ~auth-sources~ for -storing authentication info, which can also be encrypted. - -Create a file in your home directory (which can optionally be encrypted, verify -your ~auth-sources~ has the correct values) called ~~/.authinfo~: -#+begin_src -machine * login intelephense password <key> -#+end_src - -And add the following to your config: -#+begin_src emacs-lisp -(defun my-fetch-password (&rest params) - (require 'auth-source) - (let ((match (car (apply #'auth-source-search params)))) - (if match - (let ((secret (plist-get match :secret))) - (if (functionp secret) - (funcall secret) - secret)) - (error "Password not found for %S" params)))) - -(setq lsp-intelephense-licence-key (my-fetch-password :user intelephense)) -#+end_src - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/php/autoload.el b/.config/emacs/modules/lang/php/autoload.el @@ -1,26 +0,0 @@ -;;; lang/php/autoload.el -*- lexical-binding: t; -*- - -(defvar +php-composer-conf (make-hash-table :test 'equal)) - -;;;###autoload -(defun +php-composer-conf (&optional project-root refresh-p) - "Retrieve the contents of composer.json as an alist. If REFRESH-P is non-nil -ignore the cache." - (let ((project-root (or project-root (doom-project-root)))) - (or (and (not refresh-p) (gethash project-root +php-composer-conf)) - (let ((package-file (expand-file-name "composer.json" project-root))) - (when-let (data (and (file-exists-p package-file) - (require 'json) - (json-read-file package-file))) - (puthash project-root data +php-composer-conf)))))) - -;; -;;; Commands - - -;;;###autoload -(defun +php/open-repl () - "Open PHP REPL." - (interactive) - (psysh) - (pop-to-buffer (current-buffer))) diff --git a/.config/emacs/modules/lang/php/config.el b/.config/emacs/modules/lang/php/config.el @@ -1,181 +0,0 @@ -;;; lang/php/config.el -*- lexical-binding: t; -*- - -(defvar +php--company-backends nil - "List of company backends to use in `php-mode'.") - -(defvar +php-default-docker-container "php-fpm" - "The default docker container to run commands in.") - -(defvar +php-default-docker-compose "docker-compose.yml" - "Path to docker-compose file.") - -(defvar +php-run-tests-in-docker nil - "Whether or not to run tests in a docker environment") - -(after! projectile - (add-to-list 'projectile-project-root-files "composer.json")) - - -;; -;;; Packages - -(use-package! php-mode - :mode "\\.inc\\'" - :hook (php-mode . rainbow-delimiters-mode) - :config - ;; Disable HTML compatibility in php-mode. `web-mode' has superior support for - ;; php+html. Use the .phtml extension instead. - (setq php-mode-template-compatibility nil) - - (set-docsets! 'php-mode "PHP" "PHPUnit" "Laravel" "CakePHP" "CodeIgniter" "Doctrine_ORM") - (set-repl-handler! 'php-mode #'+php/open-repl) - (set-lookup-handlers! 'php-mode :documentation #'php-search-documentation) - (set-formatter! 'php-mode #'php-cs-fixer-fix) - (set-ligatures! 'php-mode - ;; Functional - :lambda "function()" :lambda "fn" - :def "function" - ;; Types - :null "null" - :true "true" :false "false" - :int "int" :float "float" - :str "string" - :bool "list" - ;; Flow - :not "!" - :and "&&" :and "and" - :or "||" :or "or" - :for "for" - :return "return" - :yield "use") - - (if (not (modulep! +lsp)) - ;; `+php-company-backend' uses `company-phpactor', `php-extras-company' or - ;; `company-dabbrev-code', in that order. - (when +php--company-backends - (set-company-backend! 'php-mode - (cons :separate +php--company-backends) - 'company-dabbrev-code)) - (when (executable-find "php-language-server.php") - (setq lsp-clients-php-server-command "php-language-server.php")) - (add-hook 'php-mode-local-vars-hook #'lsp! 'append)) - - (when (modulep! +tree-sitter) - (add-hook 'php-mode-local-vars-hook #'tree-sitter! 'append)) - - ;; Use the smallest `sp-max-pair-length' for optimum `smartparens' performance - (setq-hook! 'php-mode-hook sp-max-pair-length 5) - - (sp-with-modes '(php-mode) - (sp-local-pair "<?" "?>" :post-handlers '(("| " "SPC" "=") ("||\n[i]" "RET") ("[d2]" "p"))) - (sp-local-pair "<?php" "?>" :post-handlers '(("| " "SPC") ("||\n[i]" "RET")))) - - (map! :localleader - :map php-mode-map - :prefix ("t" . "test") - "r" #'phpunit-current-project - "a" #'phpunit-current-class - "s" #'phpunit-current-test)) - - -(use-package! phpactor - :unless (modulep! +lsp) - :after php-mode - :init - (add-to-list '+php--company-backends #'company-phpactor nil 'eq) - :config - (set-lookup-handlers! 'php-mode - :definition #'phpactor-goto-definition) - (map! :localleader - :map php-mode-map - :prefix ("r" . "refactor") - "cc" #'phpactor-copy-class - "mc" #'phpactor-move-class - "oi" #'phpactor-offset-info - "t" #'phpactor-transform - "ic" #'phpactor-import-class)) - - -(use-package! php-refactor-mode - :hook php-mode - :config - (map! :localleader - :map php-refactor-mode-map - :prefix "r" - "cv" #'php-refactor--convert-local-to-instance-variable - "u" #'php-refactor--optimize-use - "xm" #'php-refactor--extract-method - "rv" #'php-refactor--rename-local-variable)) - - -(use-package! php-extras - :after php-mode - :preface - ;; We'll set up company support ourselves - (advice-add #'php-extras-company-setup :override #'ignore) - :init - (add-to-list '+php--company-backends #'php-extras-company) - :config - (setq php-extras-eldoc-functions-file - (concat doom-data-dir "php-extras-eldoc-functions")) - ;; Silence warning if `php-extras-eldoc-functions-file' hasn't finished - ;; generating yet. - (defun php-extras-load-eldoc () - (require 'php-extras-eldoc-functions php-extras-eldoc-functions-file t)) - ;; Make expensive php-extras generation async - (unless (file-exists-p (concat php-extras-eldoc-functions-file ".el")) - (message "Generating PHP eldoc files...") - (require 'async) - (async-start `(lambda () - ,(async-inject-variables "\\`\\(load-path\\|php-extras-eldoc-functions-file\\)$") - (require 'php-extras-gen-eldoc) - (php-extras-generate-eldoc-1 t)) - (lambda (_) - (load (concat php-extras-eldoc-functions-file ".el")) - (message "PHP eldoc updated!"))))) - - -(use-package! hack-mode - :when (modulep! +hack) - :mode "\\.hh$") - - -(use-package! composer - :defer t - :init - (map! :after php-mode - :localleader - :map php-mode-map - :prefix ("c" . "composer") - "c" #'composer - "i" #'composer-install - "r" #'composer-require - "u" #'composer-update - "d" #'composer-dump-autoload - "s" #'composer-run-script - "v" #'composer-run-vendor-bin-command - "o" #'composer-find-json-file - "l" #'composer-view-lock-file)) - - -;; -;; Projects - -(def-project-mode! +php-laravel-mode - :modes '(php-mode yaml-mode web-mode nxml-mode js2-mode scss-mode) - :files (and "artisan" "server.php")) - -(def-project-mode! +php-composer-mode - :modes '(web-mode php-mode) - :files ("composer.json")) - -(def-project-mode! +phpunit-docker-compose-mode - :when +php-run-tests-in-docker - :modes '(php-mode docker-compose-mode) - :files (and "phpunit.xml" (or +php-default-docker-compose "docker-compose.yml")) - :on-enter - (setq phpunit-args `("exec" ,+php-default-docker-container "php" "vendor/bin/phpunit") - phpunit-executable (executable-find "docker-compose")) - :on-exit - (setq phpunit-args nil - phpunit-executable nil)) diff --git a/.config/emacs/modules/lang/php/doctor.el b/.config/emacs/modules/lang/php/doctor.el @@ -1,10 +0,0 @@ -;; -*- lexical-binding: t; no-byte-compile: t; -*- -;;; lang/php/doctor.el - -(assert! (or (not (modulep! +lsp)) - (modulep! :tools lsp)) - "This module requires (:tools lsp)") - -(assert! (or (not (modulep! +tree-sitter)) - (modulep! :tools tree-sitter)) - "This module requires (:tools tree-sitter)") diff --git a/.config/emacs/modules/lang/php/packages.el b/.config/emacs/modules/lang/php/packages.el @@ -1,27 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/php/packages.el - -(package! psysh :pin "796b26a5cd75df9d2ecb206718b310ff21787063") -(package! php-extras - :recipe (:host github :repo "arnested/php-extras") - :pin "d410c5af663c30c01d461ac476d1cbfbacb49367") -(package! php-mode :pin "fb11df8268b7099766264cd53836ef159746adbd") -(package! php-refactor-mode :pin "7a794b0618df2882b1bd586fdd698dba0bc5130d") -(package! phpunit :pin "4a36906344c0abc11f48cc08cd8d50a9f46963f8") -(package! composer :pin "5af1707fefbd9d7db1102afdaeb8f2da893fea37") - -(when (modulep! +hack) - (package! hack-mode - :recipe (:host github :repo "hhvm/hack-mode") - :pin "26f06ffe82574f98e7da381e48202eceb8ef0793")) - -(unless (modulep! +lsp) - (package! phpactor :pin "9440005814c4858880ad45afdaa7d2e637a9d280") - (when (modulep! :completion company) - (package! company-phpactor :pin "9440005814c4858880ad45afdaa7d2e637a9d280"))) - -(when (modulep! :editor format) - (package! php-cs-fixer :pin "efe4368d891f1eec6311363cfd6be3e9eadb5e0a")) - -;; For building php-extras -(package! async :pin "71cc50f27ffc598a89aeaa593488d87818647d02") diff --git a/.config/emacs/modules/lang/plantuml/README.org b/.config/emacs/modules/lang/plantuml/README.org @@ -1,51 +0,0 @@ -#+title: :lang plantuml -#+subtitle: Diagrams to confuse people more -#+created: July 08, 2017 -#+since: 2.0.4 - -* Description :unfold: -This module adds plantuml support to Emacs; allowing you to generate diagrams -from plain text. - -** Maintainers -*This module needs a maintainer.* [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:plantuml-mode]] -- [[doom-package:flycheck-plantuml]] if [[doom-module::checkers syntax]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires =plantuml= to build diagrams with. - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/plantuml/autoload.el b/.config/emacs/modules/lang/plantuml/autoload.el @@ -1,63 +0,0 @@ -;;; lang/plantuml/autoload.el -*- lexical-binding: t; -*- - -;;;###autoload -(defun +plantuml-org-babel-execute:plantuml-a (body params) - "Execute a block of plantuml code with org-babel. -This function is called by `org-babel-execute-src-block'." - (require 'plantuml-mode) - ;; REVIEW Refactor me - (let* ((body (replace-regexp-in-string - "^[[:blank:]\n]*\\(@start\\)" - "\\\\\\1" - body)) - (fullbody (org-babel-plantuml-make-body body params)) - (out-file (or (cdr (assq :file params)) - (org-babel-temp-file "plantuml-" ".png"))) - (in-file (org-babel-temp-file "plantuml-"))) - (if (eq plantuml-default-exec-mode 'server) - (if (bound-and-true-p org-export-current-backend) - (user-error "Exporting plantuml diagrams in server mode is not supported (see `plantuml-default-exec-mode')") - (save-current-buffer - (save-match-data - (with-current-buffer - (url-retrieve-synchronously (plantuml-server-encode-url body) - nil t) - (goto-char (point-min)) - ;; skip the HTTP headers - (while (not (looking-at "\n")) (forward-line)) - (delete-region (point-min) (+ 1 (point))) - (write-file out-file))))) - (let* ((cmd (concat (cond ((eq plantuml-default-exec-mode 'executable) - (unless (executable-find plantuml-executable-path) - (error "Could not find plantuml at %s" - (executable-find plantuml-executable-path))) - (concat (shell-quote-argument (executable-find plantuml-executable-path)) - " --headless")) - ((not (file-exists-p plantuml-jar-path)) - (error "Could not find plantuml.jar at %s" org-plantuml-jar-path)) - ((concat "java " (cdr (assoc :java params)) " -jar " - (shell-quote-argument - (expand-file-name plantuml-jar-path))))) - " " - (pcase (file-name-extension out-file) - ("png" "-tpng") - ("svg" "-tsvg") - ("eps" "-teps") - ("pdf" "-tpdf") - ("tex" "-tlatex") - ("vdx" "-tvdx") - ("xmi" "-txmi") - ("scxml" "-tscxml") - ("html" "-thtml") - ("txt" "-ttxt") - ("utxt" "-utxt")) - " " - " -p " (cdr (assoc :cmdline params)) " < " - (org-babel-process-file-name in-file) - " > " - (org-babel-process-file-name out-file)))) - (with-temp-file in-file (insert fullbody)) - (message "%s" cmd) - (org-babel-eval cmd ""))) - (unless (cdr (assq :file params)) - out-file))) diff --git a/.config/emacs/modules/lang/plantuml/config.el b/.config/emacs/modules/lang/plantuml/config.el @@ -1,29 +0,0 @@ -;;; lang/plantuml/config.el -*- lexical-binding: t; -*- - -(use-package! plantuml-mode - :commands plantuml-download-jar - :init - (setq plantuml-jar-path (concat doom-data-dir "plantuml.jar") - org-plantuml-jar-path plantuml-jar-path) - :config - (set-popup-rule! "^\\*PLANTUML" :size 0.4 :select nil :ttl 0) - - (setq plantuml-default-exec-mode - (cond ((file-exists-p plantuml-jar-path) 'jar) - ((executable-find "plantuml") 'executable) - (plantuml-default-exec-mode)))) - - -(use-package! flycheck-plantuml - :when (modulep! :checkers syntax) - :after plantuml-mode - :config (flycheck-plantuml-setup)) - - -(after! ob-plantuml - ;; HACK Force ob-plantuml to use `plantuml-mode''s building mechanism, which - ;; is more sophisticated. - (advice-add #'org-babel-execute:plantuml - :override #'+plantuml-org-babel-execute:plantuml-a) - (add-to-list 'org-babel-default-header-args:plantuml - '(:cmdline . "-charset utf-8"))) diff --git a/.config/emacs/modules/lang/plantuml/doctor.el b/.config/emacs/modules/lang/plantuml/doctor.el @@ -1,13 +0,0 @@ -;; -*- lexical-binding: t; no-byte-compile: t; -*- -;;; lang/plantuml/doctor.el - -(when (require 'plantuml-mode nil t) - ;; java - (unless (executable-find "java") - (warn! "Couldn't find java. PlantUML preview or syntax checking won't work")) - ;; graphviz - (unless (executable-find "dot") - (warn! "Couldn't find dot. PlantUML will only show outputs for sequence and activity diagrams")) - ;; plantuml.jar - (unless (file-exists-p plantuml-jar-path) - (warn! "Couldn't find plantuml.jar. Install it with M-x plantuml-download-jar"))) diff --git a/.config/emacs/modules/lang/plantuml/packages.el b/.config/emacs/modules/lang/plantuml/packages.el @@ -1,8 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/plantuml/packages.el - -(package! plantuml-mode :pin "ea45a13707abd2a70df183f1aec6447197fc9ccc") -(when (modulep! :checkers syntax) - (package! flycheck-plantuml :pin "183be89e1dbba0b38237dd198dff600e0790309d")) - -;; ob-plantuml is provided by org-plus-contrib diff --git a/.config/emacs/modules/lang/purescript/README.org b/.config/emacs/modules/lang/purescript/README.org @@ -1,55 +0,0 @@ -#+title: :lang purescript -#+subtitle: Javascript, but functional -#+created: May 21, 2017 -#+since: 2.0.3 (#75) - -* Description :unfold: -This module adds [[https://www.purescript.org/][Purescript]] support to Doom Emacs. - -** Maintainers -*This module needs a maintainer.* [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +lsp :: - Enable LSP support for ~purescript-mode~. Requires [[doom-module::tools lsp]] and a langserver - (supports [[https://github.com/nwolverson/purescript-language-server][purescript-language-server]]). - -** Packages -- [[doom-package:psci]] -- [[doom-package:psc-ide]] -- [[doom-package:purescript-mode]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* TODO Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -#+begin_quote -🔨 /This module's prerequisites are not documented./ [[doom-contrib-module:][Document them?]] -#+end_quote - -* TODO Usage -#+begin_quote -🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote -🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote -🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/purescript/config.el b/.config/emacs/modules/lang/purescript/config.el @@ -1,38 +0,0 @@ -;;; lang/purescript/config.el -*- lexical-binding: t; -*- - -(after! purescript-mode - (when (modulep! +lsp) - (add-hook 'purescript-mode-local-vars-hook #'lsp! 'append)) - - (add-hook! 'purescript-mode-hook - #'purescript-indentation-mode - #'rainbow-delimiters-mode) - - (map! :localleader - :map purescript-mode-map - "t" #'psc-ide-show-type - "c" #'psc-ide-case-split - "i" #'psc-ide-add-import - "a" #'psc-ide-add-clause - "f" #'psc-ide-flycheck-insert-suggestion - (:prefix ("l" . "load") - "m" #'psc-ide-load-module - "a" #'psc-ide-load-all) - (:prefix ("s" . "server") - "s" #'psc-ide-server-start - "S" #'psc-ide-server-quit)) - - (set-repl-handler! 'purescript-mode #'psci) - - (set-lookup-handlers! 'purescript-mode - :definition #'psc-ide-goto-definition - :documentation #'purescript-pursuit)) - - -(use-package! psc-ide - :hook (purescript-mode . psc-ide-mode) - :config - (remove-hook 'company-backends 'company-psc-ide-backend) - (when (modulep! :checkers syntax) - (psc-ide-flycheck-setup)) - (set-company-backend! 'purescript-mode 'company-psc-ide-backend)) diff --git a/.config/emacs/modules/lang/purescript/packages.el b/.config/emacs/modules/lang/purescript/packages.el @@ -1,6 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/purescript/packages.el - -(package! psc-ide :pin "ce97d719458ea099b40c02f05b6609601c727e66") -(package! purescript-mode :pin "cf113871f98da672bd2e9ae58da9c852236f3934") -(package! psci :pin "95fb5d14033add8fe9c8c6b4379758beb88af1d0") diff --git a/.config/emacs/modules/lang/python/README.org b/.config/emacs/modules/lang/python/README.org @@ -1,155 +0,0 @@ -#+title: :lang python -#+subtitle: Beautiful is better than ugly -#+created: June 15, 2015 -#+since: 0.7 - -* Description :unfold: -This module adds [[https://www.python.org/][Python]] support to Doom Emacs. - -- Syntax checking ([[doom-package:flycheck]]) -- Snippets -- Run tests ([[doom-package:nose]], [[doom-package:pytest]]) -- Auto-format (with ~black~, requires [[doom-module::editor format]]) -- LSP integration (=mspyls=, =pyls=, or =pyright=) - -** Maintainers -- [[doom-user:][@hlissner]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +conda :: - Enable python virtual environment support via [[https://conda.io/en/latest/][Conda]]. -- +cython :: - Enable support for Cython files support. -- +lsp :: - Enable LSP support for ~python-mode~. Requires [[doom-module::tools lsp]] and a langserver - (supports mspyls, pyls, and pyright). -- +poetry :: - Enable Python packaging, dependency management, and virtual environment - support via [[https://python-poetry.org/][Poetry]]. -- +pyenv :: - Enable Python virtual environment support via [[https://github.com/pyenv/pyenv][pyenv]] -- +pyright :: - Use the pyright LSP server instead of mspyls or pyls (requires [[doom-module:+lsp]]). -- +tree-sitter :: - Leverages tree-sitter for better syntax highlighting and structural text - editing. Requires [[doom-module::tools tree-sitter]]. - -** Packages -- [[doom-package:anaconda-mode]] -- [[doom-package:conda]] -- [[doom-package:nose]] -- [[doom-package:pipenv]] -- [[doom-package:pip-requirements]] -- [[doom-package:poetry]] if [[doom-module:+poetry]] -- [[doom-package:pyenv]] -- [[doom-package:pyimport]] -- [[doom-package:py-isort]] -- [[doom-package:python-pytest]] -- if [[doom-module:+cython]] - - [[doom-package:cython-mode]] - - [[doom-package:flycheck-cython]] if [[doom-module::checkers syntax]] -- if [[doom-module:+lsp]] - - if [[doom-module:+pyright]] - - [[doom-package:lsp-pyright]] - - else - - [[doom-package:lsp-python-ms]] - -** Hacks -- [[doom-package:anaconda-mode]] is configured to activate when [[doom-package:lsp-mode]] (or [[doom-package:eglot]]) don't -- or - fail to. - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module has no hard requirements, but softly depends on: -- For this module's supported test runners: - - ~$ pip install pytest~ - - ~$ pip install nose~ -- The [[doom-module::editor format]] module uses Black for python files: ~$ pip install black~ -- [[doom-package:pyimport]] requires Python's module ~pyflakes~: ~$ pip install pyflakes~ -- [[doom-package:py-isort]] requires [[https://github.com/timothycrosley/isort][isort]] to be installed: ~pip install isort~ -- Python virtual environments install instructions at: - - [[https://github.com/pyenv/pyenv][pyenv]] - - [[https://conda.io/en/latest/][Conda]] - - [[https://python-poetry.org/][Poetry]] - - [[https://pipenv.readthedocs.io/en/latest/][pipenv]] -- ~cython~ requires [[https://cython.org/][Cython]] - -** Language Server Protocol Support -For LSP support the [[doom-module::tools lsp]] module must be enabled, along with this module's -[[doom-module:+lsp]] flag. By default, it supports [[doom-package:mspyls]] and [[doom-package:pyls]], in that order. With the -[[doom-module:+pyright]] flag, it will try Pyright first. - -Each of these servers must be installed on your system via your OS package -manager or manually: -- [[https://pypi.org/project/python-language-server/][*pyls*]] can be installed with ~$ pip install python-language-server[all]~. -- *mspyls* can be installed by typing ~M-x lsp-install-server RET mspyls~. -- *pyright* can be installed with ~$ pip install pyright~ or ~$ npm i -g - pyright~. - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -This module supports LSP. It requires installation of [[https://pypi.org/project/python-language-server/][Python Language Server]], -[[https://github.com/Microsoft/python-language-server][Microsoft Language Server]], or [[https://github.com/microsoft/pyright][pyright]], see [[Language Server Protocol Support][LSP Support]]. - -To enable support for auto-formatting with black enable [[doom-module::editor format]]. - -** Keybindings -| Binding | Description | -|-------------------+----------------------------------| -| [[kbd:][<localleader> c c]] | ~Compile Cython buffer~ | -| [[kbd:][<localleader> i i]] | ~Insert mising imports~ | -| [[kbd:][<localleader> i r]] | ~Remove unused imports~ | -| [[kbd:][<localleader> i s]] | ~Sort imports~ | -| [[kbd:][<localleader> i o]] | ~Optimize imports~ | -| [[kbd:][<localleader> t r]] | ~nosetests-again~ | -| [[kbd:][<localleader> t a]] | ~nosetests-all~ | -| [[kbd:][<localleader> t s]] | ~nosetests-one~ | -| [[kbd:][<localleader> t v]] | ~nosetests-module~ | -| [[kbd:][<localleader> t A]] | ~nosetests-pdb-all~ | -| [[kbd:][<localleader> t O]] | ~nosetests-pdb-one~ | -| [[kbd:][<localleader> t V]] | ~nosetests-pdb-module~ | -| [[kbd:][<localleader> t f]] | ~python-pytest-file~ | -| [[kbd:][<localleader> t k]] | ~python-pytest-file-dwim~ | -| [[kbd:][<localleader> t t]] | ~python-pytest-function~ | -| [[kbd:][<localleader> t m]] | ~python-pytest-function-dwim~ | -| [[kbd:][<localleader> t r]] | ~python-pytest-repeat~ | -| [[kbd:][<localleader> t p]] | ~python-pytest-popup~ | -| [[kbd:][<localleader> g d]] | ~anaconda-mode-find-definitions~ | -| [[kbd:][<localleader> g h]] | ~anaconda-mode-show-doc~ | -| [[kbd:][<localleader> g a]] | ~anaconda-mode-find-assignments~ | -| [[kbd:][<localleader> g f]] | ~anaconda-mode-find-file~ | -| [[kbd:][<localleader> g u]] | ~anaconda-mode-find-references~ | - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -This module has the following variables to set extra arguments to [[https://ipython.org/][ipython]] and -[[https://jupyter.org/][jupyter]] shells: -#+begin_src emacs-lisp -;; in $DOOMDIR/config.el -(setq +python-ipython-repl-args '("-i" "--simple-prompt" "--no-color-info")) -(setq +python-jupyter-repl-args '("--simple-prompt")) -#+end_src - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/python/autoload/compat-28.1.el b/.config/emacs/modules/lang/python/autoload/compat-28.1.el @@ -1,94 +0,0 @@ -;;; lang/python/autoload/compat-28.1.el -*- lexical-binding: t; -*- -;;;###if (versionp! "28.0" <= emacs-version <= "28.1") -;;; Commentary: -;; -;; HACK: 28.1 introduced breakage into the syntax highlighter for `python-mode'. -;; The fix was introduced shortly after, but did not make the 28.1 release. -;; This fix exists solely to patch that issue for 28.1 users. -;; -;; DEPRECATED: Remove when 28.1 support is dropped -;; -;;; Code: - -;;;###autoload -(defadvice! +python--font-lock-assignment-matcher-a (regexp) - :override #'python-font-lock-assignment-matcher - (lambda (limit) - (cl-loop while (re-search-forward regexp limit t) - unless (or (python-syntax-context 'paren) - (equal (char-after) ?=)) - return t))) - -;;;###autoload -(defadvice! +python--rx-a (&rest regexps) - :override #'python-rx - `(rx-let ((block-start (seq symbol-start - (or "def" "class" "if" "elif" "else" "try" - "except" "finally" "for" "while" "with" - ;; Python 3.5+ PEP492 - (and "async" (+ space) - (or "def" "for" "with"))) - symbol-end)) - (dedenter (seq symbol-start - (or "elif" "else" "except" "finally") - symbol-end)) - (block-ender (seq symbol-start - (or - "break" "continue" "pass" "raise" "return") - symbol-end)) - (decorator (seq line-start (* space) ?@ (any letter ?_) - (* (any word ?_)))) - (defun (seq symbol-start - (or "def" "class" - ;; Python 3.5+ PEP492 - (and "async" (+ space) "def")) - symbol-end)) - (if-name-main (seq line-start "if" (+ space) "__name__" - (+ space) "==" (+ space) - (any ?' ?\") "__main__" (any ?' ?\") - (* space) ?:)) - (symbol-name (seq (any letter ?_) (* (any word ?_)))) - (assignment-target (seq (? ?*) - (* symbol-name ?.) symbol-name - (? ?\[ (+ (not ?\])) ?\]))) - (grouped-assignment-target (seq (? ?*) - (* symbol-name ?.) (group symbol-name) - (? ?\[ (+ (not ?\])) ?\]))) - (open-paren (or "{" "[" "(")) - (close-paren (or "}" "]" ")")) - (simple-operator (any ?+ ?- ?/ ?& ?^ ?~ ?| ?* ?< ?> ?= ?%)) - (not-simple-operator (not (or simple-operator ?\n))) - (operator (or "==" ">=" "is" "not" - "**" "//" "<<" ">>" "<=" "!=" - "+" "-" "/" "&" "^" "~" "|" "*" "<" ">" - "=" "%")) - (assignment-operator (or "+=" "-=" "*=" "/=" "//=" "%=" "**=" - ">>=" "<<=" "&=" "^=" "|=" - "=")) - (string-delimiter (seq - ;; Match even number of backslashes. - (or (not (any ?\\ ?\' ?\")) point - ;; Quotes might be preceded by an - ;; escaped quote. - (and (or (not (any ?\\)) point) ?\\ - (* ?\\ ?\\) (any ?\' ?\"))) - (* ?\\ ?\\) - ;; Match single or triple quotes of any kind. - (group (or "\"\"\"" "\"" "'''" "'")))) - (coding-cookie (seq line-start ?# (* space) - (or - ;; # coding=<encoding name> - (: "coding" (or ?: ?=) (* space) - (group-n 1 (+ (or word ?-)))) - ;; # -*- coding: <encoding name> -*- - (: "-*-" (* space) "coding:" (* space) - (group-n 1 (+ (or word ?-))) - (* space) "-*-") - ;; # vim: set fileencoding=<encoding name> : - (: "vim:" (* space) "set" (+ space) - "fileencoding" (* space) ?= (* space) - (group-n 1 (+ (or word ?-))) - (* space) ":"))))) - (rx ,@regexps))) - -;;; compat-28.1.el ends here diff --git a/.config/emacs/modules/lang/python/autoload/conda.el b/.config/emacs/modules/lang/python/autoload/conda.el @@ -1,17 +0,0 @@ -;;; lang/python/autoload/conda.el -*- lexical-binding: t; -*- -;;;###if (modulep! +conda) - -;;;###autoload -(defun +python/set-conda-home () - "Set `conda-anaconda-home' (ANACONDA_HOME). - -Usually it's `~/.anaconda3' on local machine, but it can be set to a remote -directory using TRAMP syntax, e.g. `/ssh:host:/usr/bin/anaconda3'. This way, you -can use a remote conda environment, including the corresponding remote python -executable and packages." - (interactive) - (require 'conda) - (when-let (home (read-directory-name "Set conda home: " "~" nil nil conda-anaconda-home)) - (setq conda-anaconda-home home) - (message "Successfully changed conda home to: %s" (abbreviate-file-name home)))) - diff --git a/.config/emacs/modules/lang/python/autoload/pyenv.el b/.config/emacs/modules/lang/python/autoload/pyenv.el @@ -1,30 +0,0 @@ -;;; lang/python/autoload/pyenv.el -*- lexical-binding: t; -*- -;;;###if (modulep! +pyenv) - -;;;###autoload -(defvar +pyenv--version nil) - -;;;###autoload -(defun +python-pyenv-mode-set-auto-h () - "Set pyenv-mode version from buffer-local variable." - (when (eq major-mode 'python-mode) - (when (not (local-variable-p '+pyenv--version)) - (make-local-variable '+pyenv--version) - (setq +pyenv--version (+python-pyenv-read-version-from-file))) - (if +pyenv--version - (pyenv-mode-set +pyenv--version) - (pyenv-mode-unset)))) - -;;;###autoload -(defun +python-pyenv-read-version-from-file () - "Read pyenv version from .python-version file." - (when-let (root-path (projectile-locate-dominating-file default-directory ".python-version")) - (let* ((file-path (expand-file-name ".python-version" root-path)) - (version - (with-temp-buffer - (insert-file-contents-literally file-path) - (string-trim (buffer-string))))) - (if (member version (pyenv-mode-versions)) - version ;; return. - (message "pyenv: version `%s' is not installed (set by `%s')." - version file-path))))) diff --git a/.config/emacs/modules/lang/python/autoload/python.el b/.config/emacs/modules/lang/python/autoload/python.el @@ -1,74 +0,0 @@ -;;; lang/python/autoload/python.el -*- lexical-binding: t; -*- - -;;;###autoload -(defun +python-executable-find (exe) - "Resolve the path to the EXE executable. -Tries to be aware of your active conda/pipenv/virtualenv environment, before -falling back on searching your PATH." - (if (file-name-absolute-p exe) - (and (file-executable-p exe) - exe) - (let ((exe-root (format "bin/%s" exe))) - (cond ((when python-shell-virtualenv-root - (let ((bin (expand-file-name exe-root python-shell-virtualenv-root))) - (if (file-exists-p bin) bin)))) - ((when (require 'conda nil t) - (let ((bin (expand-file-name (concat conda-env-current-name "/" exe-root) - (conda-env-default-location)))) - (if (file-executable-p bin) bin)))) - ((when-let (bin (projectile-locate-dominating-file default-directory "bin/python")) - (setq-local doom-modeline-python-executable (expand-file-name "bin/python" bin)))) - ((executable-find exe)))))) - -;;;###autoload -(defun +python/open-repl () - "Open the Python REPL." - (interactive) - (require 'python) - (unless python-shell-interpreter - (user-error "`python-shell-interpreter' isn't set")) - (pop-to-buffer - (process-buffer - (let ((dedicated (bound-and-true-p python-shell-dedicated))) - (if-let* ((pipenv (+python-executable-find "pipenv")) - (pipenv-project (pipenv-project-p))) - (let ((default-directory pipenv-project) - (python-shell-interpreter-args - (format "run %s %s" - python-shell-interpreter - python-shell-interpreter-args)) - (python-shell-interpreter pipenv)) - (run-python nil dedicated t)) - (run-python nil dedicated t)))))) - -;;;###autoload -(defun +python/open-ipython-repl () - "Open an IPython REPL." - (interactive) - (require 'python) - (let ((python-shell-interpreter - (or (+python-executable-find (car +python-ipython-command)) - "ipython")) - (python-shell-interpreter-args - (string-join (cdr +python-ipython-command) " "))) - (+python/open-repl))) - -;;;###autoload -(defun +python/open-jupyter-repl () - "Open a Jupyter console." - (interactive) - (require 'python) - (add-to-list 'python-shell-completion-native-disabled-interpreters "jupyter") - (let ((python-shell-interpreter - (or (+python-executable-find (car +python-jupyter-command)) - "jupyter")) - (python-shell-interpreter-args - (string-join (cdr +python-jupyter-command) " "))) - (+python/open-repl))) - -;;;###autoload -(defun +python/optimize-imports () - "organize imports" - (interactive) - (pyimport-remove-unused) - (py-isort-buffer)) diff --git a/.config/emacs/modules/lang/python/config.el b/.config/emacs/modules/lang/python/config.el @@ -1,350 +0,0 @@ -;;; lang/python/config.el -*- lexical-binding: t; -*- - -(defvar +python-ipython-command '("ipython" "-i" "--simple-prompt" "--no-color-info") - "Command to initialize the ipython REPL for `+python/open-ipython-repl'.") - -(defvar +python-jupyter-command '("jupyter" "console" "--simple-prompt") - "Command to initialize the jupyter REPL for `+python/open-jupyter-repl'.") - -(after! projectile - (pushnew! projectile-project-root-files "pyproject.toml" "requirements.txt" "setup.py")) - - -;; -;;; Packages - -(use-package! python - :mode ("[./]flake8\\'" . conf-mode) - :mode ("/Pipfile\\'" . conf-mode) - :init - (setq python-environment-directory doom-cache-dir - python-indent-guess-indent-offset-verbose nil) - - (when (modulep! +lsp) - (add-hook 'python-mode-local-vars-hook #'lsp! 'append) - ;; Use "mspyls" in eglot if in PATH - (when (executable-find "Microsoft.Python.LanguageServer") - (set-eglot-client! 'python-mode '("Microsoft.Python.LanguageServer")))) - - (when (modulep! +tree-sitter) - (add-hook 'python-mode-local-vars-hook #'tree-sitter! 'append)) - :config - (set-repl-handler! 'python-mode #'+python/open-repl - :persist t - :send-region #'python-shell-send-region - :send-buffer #'python-shell-send-buffer) - (set-docsets! '(python-mode inferior-python-mode) "Python 3" "NumPy" "SciPy" "Pandas") - - (set-ligatures! 'python-mode - ;; Functional - :def "def" - :lambda "lambda" - ;; Types - :null "None" - :true "True" :false "False" - :int "int" :str "str" - :float "float" - :bool "bool" - :tuple "tuple" - ;; Flow - :not "not" - :in "in" :not-in "not in" - :and "and" :or "or" - :for "for" - :return "return" :yield "yield") - - ;; Stop the spam! - (setq python-indent-guess-indent-offset-verbose nil) - - ;; Default to Python 3. Prefer the versioned Python binaries since some - ;; systems link the unversioned one to Python 2. - (when (and (executable-find "python3") - (string= python-shell-interpreter "python")) - (setq python-shell-interpreter "python3")) - - (add-hook! 'python-mode-hook - (defun +python-use-correct-flycheck-executables-h () - "Use the correct Python executables for Flycheck." - (let ((executable python-shell-interpreter)) - (save-excursion - (goto-char (point-min)) - (save-match-data - (when (or (looking-at "#!/usr/bin/env \\(python[^ \n]+\\)") - (looking-at "#!\\([^ \n]+/python[^ \n]+\\)")) - (setq executable (substring-no-properties (match-string 1)))))) - ;; Try to compile using the appropriate version of Python for - ;; the file. - (setq-local flycheck-python-pycompile-executable executable) - ;; We might be running inside a virtualenv, in which case the - ;; modules won't be available. But calling the executables - ;; directly will work. - (setq-local flycheck-python-pylint-executable "pylint") - (setq-local flycheck-python-flake8-executable "flake8")))) - - ;; Affects pyenv and conda - (when (modulep! :ui modeline) - (advice-add #'pythonic-activate :after-while #'+modeline-update-env-in-all-windows-h) - (advice-add #'pythonic-deactivate :after #'+modeline-clear-env-in-all-windows-h)) - - (setq-hook! 'python-mode-hook tab-width python-indent-offset)) - - -(use-package! anaconda-mode - :defer t - :init - (setq anaconda-mode-installation-directory (concat doom-data-dir "anaconda/") - anaconda-mode-eldoc-as-single-line t) - - (add-hook! 'python-mode-local-vars-hook :append - (defun +python-init-anaconda-mode-maybe-h () - "Enable `anaconda-mode' if `lsp-mode' is absent and -`python-shell-interpreter' is present." - (unless (or (bound-and-true-p lsp-mode) - (bound-and-true-p eglot--managed-mode) - (bound-and-true-p lsp--buffer-deferred) - (not (executable-find python-shell-interpreter t))) - (anaconda-mode +1)))) - :config - (set-company-backend! 'anaconda-mode '(company-anaconda)) - (set-lookup-handlers! 'anaconda-mode - :definition #'anaconda-mode-find-definitions - :references #'anaconda-mode-find-references - :documentation #'anaconda-mode-show-doc) - (set-popup-rule! "^\\*anaconda-mode" :select nil) - - (add-hook 'anaconda-mode-hook #'anaconda-eldoc-mode) - - (defun +python-auto-kill-anaconda-processes-h () - "Kill anaconda processes if this buffer is the last python buffer." - (when (and (eq major-mode 'python-mode) - (not (delq (current-buffer) - (doom-buffers-in-mode 'python-mode (buffer-list))))) - (anaconda-mode-stop))) - (add-hook! 'python-mode-hook - (add-hook 'kill-buffer-hook #'+python-auto-kill-anaconda-processes-h - nil 'local)) - - (when (featurep 'evil) - (add-hook 'anaconda-mode-hook #'evil-normalize-keymaps)) - (map! :localleader - :map anaconda-mode-map - :prefix "g" - "d" #'anaconda-mode-find-definitions - "h" #'anaconda-mode-show-doc - "a" #'anaconda-mode-find-assignments - "f" #'anaconda-mode-find-file - "u" #'anaconda-mode-find-references)) - - -(use-package! pyimport - :defer t - :init - (map! :after python - :map python-mode-map - :localleader - (:prefix ("i" . "imports") - :desc "Insert missing imports" "i" #'pyimport-insert-missing - :desc "Remove unused imports" "R" #'pyimport-remove-unused - :desc "Optimize imports" "o" #'+python/optimize-imports))) - - -(use-package! py-isort - :defer t - :init - (map! :after python - :map python-mode-map - :localleader - (:prefix ("i" . "imports") - :desc "Sort imports" "s" #'py-isort-buffer - :desc "Sort region" "r" #'py-isort-region))) - -(use-package! nose - :commands nose-mode - :preface (defvar nose-mode-map (make-sparse-keymap)) - :minor ("/test_.+\\.py$" . nose-mode) - :config - (set-popup-rule! "^\\*nosetests" :size 0.4 :select nil) - (set-yas-minor-mode! 'nose-mode) - (when (featurep 'evil) - (add-hook 'nose-mode-hook #'evil-normalize-keymaps)) - - (map! :localleader - :map nose-mode-map - :prefix "t" - "r" #'nosetests-again - "a" #'nosetests-all - "s" #'nosetests-one - "v" #'nosetests-module - "A" #'nosetests-pdb-all - "O" #'nosetests-pdb-one - "V" #'nosetests-pdb-module)) - - -(use-package! python-pytest - :commands python-pytest-dispatch - :init - (map! :after python - :localleader - :map python-mode-map - :prefix ("t" . "test") - "a" #'python-pytest - "f" #'python-pytest-file-dwim - "F" #'python-pytest-file - "t" #'python-pytest-function-dwim - "T" #'python-pytest-function - "r" #'python-pytest-repeat - "p" #'python-pytest-dispatch)) - - -;; -;;; Environment management - -(use-package! pipenv - :commands pipenv-project-p - :hook (python-mode . pipenv-mode) - :init (setq pipenv-with-projectile nil) - :config - (set-eval-handler! 'python-mode - '((:command . (lambda () python-shell-interpreter)) - (:exec (lambda () - (if-let* ((bin (executable-find "pipenv" t)) - (_ (pipenv-project-p))) - (format "PIPENV_MAX_DEPTH=9999 %s run %%c %%o %%s %%a" bin) - "%c %o %s %a"))) - (:description . "Run Python script"))) - (map! :map python-mode-map - :localleader - :prefix "e" - :desc "activate" "a" #'pipenv-activate - :desc "deactivate" "d" #'pipenv-deactivate - :desc "install" "i" #'pipenv-install - :desc "lock" "l" #'pipenv-lock - :desc "open module" "o" #'pipenv-open - :desc "run" "r" #'pipenv-run - :desc "shell" "s" #'pipenv-shell - :desc "uninstall" "u" #'pipenv-uninstall)) - - -(use-package! pyvenv - :after python - :init - (when (modulep! :ui modeline) - (add-hook 'pyvenv-post-activate-hooks #'+modeline-update-env-in-all-windows-h) - (add-hook 'pyvenv-pre-deactivate-hooks #'+modeline-clear-env-in-all-windows-h)) - :config - (add-hook 'python-mode-local-vars-hook #'pyvenv-track-virtualenv) - (add-to-list 'global-mode-string - '(pyvenv-virtual-env-name (" venv:" pyvenv-virtual-env-name " ")) - 'append)) - - - -(use-package! pyenv-mode - :when (modulep! +pyenv) - :after python - :config - (when (executable-find "pyenv") - (pyenv-mode +1) - (add-to-list 'exec-path (expand-file-name "shims" (or (getenv "PYENV_ROOT") "~/.pyenv")))) - (add-hook 'python-mode-local-vars-hook #'+python-pyenv-mode-set-auto-h) - (add-hook 'doom-switch-buffer-hook #'+python-pyenv-mode-set-auto-h)) - - -(use-package! conda - :when (modulep! +conda) - :after python - :config - ;; The location of your anaconda home will be guessed from a list of common - ;; possibilities, starting with `conda-anaconda-home''s default value (which - ;; will consult a ANACONDA_HOME envvar, if it exists). - ;; - ;; If none of these work for you, `conda-anaconda-home' must be set - ;; explicitly. Afterwards, run M-x `conda-env-activate' to switch between - ;; environments - (or (cl-loop for dir in (list conda-anaconda-home - "~/.anaconda" - "~/.miniconda" - "~/.miniconda3" - "~/.miniforge3" - "~/anaconda3" - "~/miniconda3" - "~/miniforge3" - "~/opt/miniconda3" - "/usr/bin/anaconda3" - "/usr/local/anaconda3" - "/usr/local/miniconda3" - "/usr/local/Caskroom/miniconda/base" - "~/.conda") - if (file-directory-p dir) - return (setq conda-anaconda-home (expand-file-name dir) - conda-env-home-directory (expand-file-name dir))) - (message "Cannot find Anaconda installation")) - - ;; integration with term/eshell - (conda-env-initialize-interactive-shells) - (after! eshell (conda-env-initialize-eshell)) - - (add-to-list 'global-mode-string - '(conda-env-current-name (" conda:" conda-env-current-name " ")) - 'append)) - - -(use-package! poetry - :when (modulep! +poetry) - :after python - :init - (setq poetry-tracking-strategy 'switch-buffer) - (add-hook 'python-mode-hook #'poetry-tracking-mode)) - - -(use-package! cython-mode - :when (modulep! +cython) - :mode "\\.p\\(yx\\|x[di]\\)\\'" - :config - (setq cython-default-compile-format "cython -a %s") - (map! :map cython-mode-map - :localleader - :prefix "c" - :desc "Cython compile buffer" "c" #'cython-compile)) - - -(use-package! flycheck-cython - :when (modulep! +cython) - :when (modulep! :checkers syntax) - :after cython-mode) - - -(use-package! pip-requirements - :defer t - :config - ;; HACK `pip-requirements-mode' performs a sudden HTTP request to - ;; https://pypi.org/simple, which causes unexpected hangs (see #5998). This - ;; advice defers this behavior until the first time completion is invoked. - ;; REVIEW More sensible behavior should be PRed upstream. - (defadvice! +python--init-completion-a (&rest args) - "Call `pip-requirements-fetch-packages' first time completion is invoked." - :before #'pip-requirements-complete-at-point - (unless pip-packages (pip-requirements-fetch-packages))) - (defadvice! +python--inhibit-pip-requirements-fetch-packages-a (fn &rest args) - "No-op `pip-requirements-fetch-packages', which can be expensive." - :around #'pip-requirements-mode - (letf! ((#'pip-requirements-fetch-packages #'ignore)) - (apply fn args)))) - - -;; -;;; LSP - -(eval-when! (and (modulep! +lsp) - (not (modulep! :tools lsp +eglot))) - - (use-package! lsp-python-ms - :unless (modulep! +pyright) - :after lsp-mode - :preface - (after! python - (setq lsp-python-ms-python-executable-cmd python-shell-interpreter))) - - (use-package! lsp-pyright - :when (modulep! +pyright) - :after lsp-mode)) diff --git a/.config/emacs/modules/lang/python/doctor.el b/.config/emacs/modules/lang/python/doctor.el @@ -1,57 +0,0 @@ -;;; lang/python/doctor.el -*- lexical-binding: t; -*- - -(assert! (or (not (modulep! +lsp)) - (modulep! :tools lsp)) - "This module requires (:tools lsp)") - -(assert! (or (not (modulep! +tree-sitter)) - (modulep! :tools tree-sitter)) - "This module requires (:tools tree-sitter)") - -(if (not (or (executable-find "python") - (executable-find "python3"))) - (error! "Couldn't find python in your PATH") - (unless (modulep! +lsp) - (unless (or (zerop (shell-command "python -c 'import setuptools'")) - (zerop (shell-command "python3 -c 'import setuptools'"))) - (warn! "setuptools wasn't detected, which anaconda-mode requires")))) - -(when (modulep! +pyenv) - (if (not (executable-find "pyenv")) - (warn! "Couldn't find pyenv in your PATH") - (unless (split-string (shell-command-to-string "pyenv versions --bare") "\n" t) - (warn! "No versions of python are available via pyenv, did you forget to install one?")))) - -(when (modulep! +conda) - (unless (executable-find "conda") - (warn! "Couldn't find conda in your PATH"))) - -(when (modulep! +poetry) - (if (not (executable-find "poetry")) - (warn! "Couldn't find poetry in your PATH"))) - -(when (modulep! +cython) - (unless (executable-find "cython") - (warn! "Couldn't find cython. cython-mode will not work."))) - -(when (modulep! +ipython) - (unless (executable-find "ipython") - (warn! "Couldn't find ipython in your PATH"))) - -(unless (executable-find "pytest") - (warn! "Couldn't find pytest. Running tests through pytest will not work.")) - -(unless (executable-find "nosetests") - (warn! "Couldn't find nosetests. Running tests through nose will not work.")) - -(unless (executable-find "pipenv") - (warn! "Couldn't find pipenv. pipenv support will not work.")) - -(unless (executable-find "isort") - (warn! "Couldn't find isort. Import sorting will not work.")) - -(when (modulep! :editor format) - (unless (executable-find "pyflakes") - (warn! "Couldn't find pyflakes. Import management will not work.")) - (unless (executable-find "black") - (warn! "Couldn't find black. Code formatting will not work."))) diff --git a/.config/emacs/modules/lang/python/packages.el b/.config/emacs/modules/lang/python/packages.el @@ -1,39 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/python/packages.el - -;; Major modes -(package! pip-requirements :pin "216cd1690f80cc965d4ae47b8753fc185f778ff6") -(when (modulep! +cython) - (package! cython-mode :pin "3e4790559d3168fe992cf2aa62f01423038cedb5") - (when (modulep! :checkers syntax) - (package! flycheck-cython :pin "ecc4454d35ab5317ab66a04406f36f0c1dbc0b76"))) - -;; LSP -(when (modulep! +lsp) - (unless (modulep! :tools lsp +eglot) - (if (modulep! +pyright) - (package! lsp-pyright :pin "4cd2adbb32287278d9d9da59a3212a53ecdf8036") - (package! lsp-python-ms :pin "f8e7c4bcaefbc3fd96e1ca53d17589be0403b828")))) - -;; Programming environment -(package! anaconda-mode :pin "ca8edbaa7662d97e4a4416ec9a8d743863303911") -(when (modulep! :completion company) - (package! company-anaconda :pin "da1566db41a68809ef7f91ebf2de28118067c89b")) - -;; Environment management -(package! pipenv :pin "3af159749824c03f59176aff7f66ddd6a5785a10") -(package! pyvenv :pin "31ea715f2164dd611e7fc77b26390ef3ca93509b") -(when (modulep! +pyenv) - (package! pyenv-mode :pin "b818901b8eac0e260ced66a6a5acabdbf6f5ba99")) -(when (modulep! +conda) - (package! conda :pin "28f51e49fd25abff14c1b46dea196a90a77ced64")) -(when (modulep! +poetry) - (package! poetry :pin "5a8575bc78d7fc5a39b2ba4665a909e36961fceb")) - -;; Testing frameworks -(package! nose :pin "f8528297519eba911696c4e68fa88892de9a7b72") -(package! python-pytest :pin "33c921adaa6c9c8f7cceba2342114c6b406e0d7c") - -;; Import managements -(package! pyimport :pin "c006a5fd0e5c9e297aa2ad71b2f02f463286b5e3") -(package! py-isort :pin "e67306f459c47c53a65604e4eea88a3914596560") diff --git a/.config/emacs/modules/lang/qt/README.org b/.config/emacs/modules/lang/qt/README.org @@ -1,53 +0,0 @@ -#+title: :lang qt -#+subtitle: The cutest GUI framework ever -#+created: June 02, 2018 -#+since: 21.12.0 - -* Description :unfold: -This module provides language functionality for [[https://qt.io][Qt]] specific files. - -- Syntax highlighting for [[https:://en.wikipedia.org/wiki/QML][qml]] files -- Syntax highlighting for =.pro= and =.pri= files used by [[https://doc.qt.io/qt-5/qmake-project-files.html][qmake]] - -** Maintainers -*This module needs a maintainer.* [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:qml-mode]] -- [[doom-package:qt-pro-mode]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/qt/autoload.el b/.config/emacs/modules/lang/qt/autoload.el @@ -1,4 +0,0 @@ -;;; lang/qt/autoload.el -*- lexical-binding: t; -*- - -;;;###autoload -(add-to-list 'auto-mode-alist '("\\.pr[io]\\'" . qt-pro-mode)) diff --git a/.config/emacs/modules/lang/qt/packages.el b/.config/emacs/modules/lang/qt/packages.el @@ -1,5 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/qt/packages.el - -(package! qml-mode :pin "6c5f33ba88ae010bf201a80ee8095e20a724558c") -(package! qt-pro-mode :pin "7a2da323de834294b413cbbb3c92f42f54913643") diff --git a/.config/emacs/modules/lang/racket/README.org b/.config/emacs/modules/lang/racket/README.org @@ -1,88 +0,0 @@ -#+title: :lang racket -#+subtitle: The DSL for DSLs -#+created: July 29, 2018 -#+since: 2.0.9 (#772) - -* Description :unfold: -This module adds support for the [[https://www.racket-lang.org/][Racket programming language]] to Doom Emacs. - -** Maintainers -*This module needs a maintainer.* [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +lsp :: - Enable support for ~racket-mode~. Requires [[doom-module::tools lsp]] and a langserver - (supports [[https://github.com/jeapostrophe/racket-langserver][racket-langserver]]). -- +xp :: - Enable the explore mode (~racket-xp-mode~), which "analyzes expanded code to - explain and explore." - -** Packages -- [[doom-package:racket-mode]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires ~racket~. Install it from the [[https://download.racket-lang.org/][racket website]] or through -your OS package manger. - -** Arch Linux -#+begin_src sh -pacman -S racket -#+end_src - -Or, for fewer dependencies: -#+begin_src sh -pacman -S racket-minimal -#+end_src - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** racket-smart-open-bracket-mode -~racket-smart-open-bracket-mode~ gets turned off automatically if you use -~parinfer~, ~lispy~. If you wish to enable it: -#+begin_src emacs-lisp -;; in $DOOMDIR/config.el -(after! racket-mode - (add-hook 'racket-mode-hook #'racket-smart-open-bracket-mode)) -#+end_src - -** Unicode Input -The optional ~racket-unicode~ input method lets you type unicode characters such -as λ or π. To enable unicode input for a single buffer, run -~racket-unicode-input-method-enable~. To enable unicode input by default on all -racket buffers: -#+begin_src emacs-lisp -;; in $DOOMDIR/config.el -(add-hook 'racket-mode-hook #'racket-unicode-input-method-enable) -(add-hook 'racket-repl-mode-hook #'racket-unicode-input-method-enable) -#+end_src - -Once enabled, unicode input can be toggled by pressing C-\ or running -~toggle-input-method~. - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/racket/autoload.el b/.config/emacs/modules/lang/racket/autoload.el @@ -1,30 +0,0 @@ -;;; lang/racket/autoload.el -*- lexical-binding: t; -*- - -;;;###autoload -(defun +racket/open-repl () - "Open the Racket REPL." - (interactive) - (pop-to-buffer - (or (get-buffer "*Racket REPL*") - (progn (racket-run-and-switch-to-repl) - (let ((buf (get-buffer "*Racket REPL*"))) - (bury-buffer buf) - buf))))) - -;;;###autoload -(defun +racket-lookup-documentation (thing) - "A `+lookup/documentation' handler for `racket-mode' and `racket-xp-mode'." - (let ((buf (if racket-xp-mode - (racket-xp-describe thing) - (racket-repl-describe thing)))) - (when buf - (pop-to-buffer buf) - t))) - -;;;###autoload -(defun +racket-lookup-definition (_thing) - "A `+lookup/definition' handler for `racket-mode' and `racket-xp-mode'." - (call-interactively - (if racket-xp-mode - #'racket-xp-visit-definition - #'racket-repl-visit-definition))) diff --git a/.config/emacs/modules/lang/racket/config.el b/.config/emacs/modules/lang/racket/config.el @@ -1,93 +0,0 @@ -;;; lang/racket/config.el -*- lexical-binding: t; -*- - -(after! projectile - (add-to-list 'projectile-project-root-files "info.rkt")) - - -;; -;;; Packages - -(use-package! racket-mode - :mode "\\.rkt\\'" ; give it precedence over :lang scheme - :config - (set-repl-handler! 'racket-mode #'+racket/open-repl) - (set-lookup-handlers! '(racket-mode racket-repl-mode) - :definition #'+racket-lookup-definition - :documentation #'+racket-lookup-documentation) - (set-docsets! 'racket-mode "Racket") - (set-ligatures! 'racket-mode - :lambda "lambda" - :map "map" - :dot ".") - (set-rotate-patterns! 'racket-mode - :symbols '(("#true" "#false"))) - - (add-hook! 'racket-mode-hook - #'rainbow-delimiters-mode - #'highlight-quoted-mode) - - (when (modulep! +lsp) - (add-hook 'racket-mode-local-vars-hook #'lsp! 'append)) - - (when (modulep! +xp) - (add-hook 'racket-mode-local-vars-hook #'racket-xp-mode) - ;; Both flycheck and racket-xp produce error popups, but racket-xp's are - ;; higher quality so disable flycheck's: - (when (modulep! :checkers syntax) - (add-hook! 'racket-xp-mode-hook - (defun +racket-disable-flycheck-h () - (cl-pushnew 'racket flycheck-disabled-checkers))))) - - (unless (or (modulep! :editor parinfer) - (modulep! :editor lispy)) - (add-hook 'racket-mode-hook #'racket-smart-open-bracket-mode)) - - (map! (:map racket-xp-mode-map - [remap racket-doc] #'racket-xp-documentation - [remap racket-visit-definition] #'racket-xp-visit-definition - [remap next-error] #'racket-xp-next-error - [remap previous-error] #'racket-xp-previous-error) - (:localleader - :map racket-mode-map - "a" #'racket-align - "A" #'racket-unalign - "f" #'racket-fold-all-tests - "F" #'racket-unfold-all-tests - "h" #'racket-doc - "i" #'racket-unicode-input-method-enable - "l" #'racket-logger - "o" #'racket-profile - "p" #'racket-cycle-paren-shapes - "r" #'racket-run - "R" #'racket-run-and-switch-to-repl - "t" #'racket-test - "u" #'racket-backward-up-list - "y" #'racket-insert-lambda - (:prefix ("m" . "macros") - "d" #'racket-expand-definition - "e" #'racket-expand-last-sexp - "r" #'racket-expand-region - "a" #'racket-expand-again) - (:prefix ("g" . "goto") - "b" #'racket-unvisit - "d" #'racket-visit-definition - "m" #'racket-visit-module - "r" #'racket-open-require-path) - (:prefix ("s" . "send") - "d" #'racket-send-definition - "e" #'racket-send-last-sexp - "r" #'racket-send-region) - :map racket-repl-mode-map - "l" #'racket-logger - "h" #'racket-repl-documentation - "y" #'racket-insert-lambda - "u" #'racket-backward-up-list - (:prefix ("m" . "macros") - "d" #'racket-expand-definition - "e" #'racket-expand-last-sexp - "f" #'racket-expand-file - "r" #'racket-expand-region) - (:prefix ("g" . "goto") - "b" #'racket-unvisit - "m" #'racket-visit-module - "d" #'racket-repl-visit-definition)))) diff --git a/.config/emacs/modules/lang/racket/doctor.el b/.config/emacs/modules/lang/racket/doctor.el @@ -1,11 +0,0 @@ -;; -*- lexical-binding: t; no-byte-compile: t; -*- -;;; lang/racket/doctor.el - -(unless (executable-find "drracket") - (warn! "Could not find drracket executable; code-completion and syntax checking will not work.")) - -(unless (executable-find "racket") - (warn! "Could not find racket executable; REPL will not work.")) - -(unless (executable-find "raco") - (warn! "Could not find raco executable; commands for install packages and build libraries will not work.")) diff --git a/.config/emacs/modules/lang/racket/packages.el b/.config/emacs/modules/lang/racket/packages.el @@ -1,4 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/racket/packages.el - -(package! racket-mode :pin "947d9806ee27ef241643f978c7901fd1f9e10c98") diff --git a/.config/emacs/modules/lang/raku/README.org b/.config/emacs/modules/lang/raku/README.org @@ -1,50 +0,0 @@ -#+title: :lang raku -#+subtitle: The artist formerly known as perl6 -#+created: June 05, 2020 -#+since: 21.12.0 (#3308) - -* Description :unfold: -This module adds support for the [[https://www.raku.org/][Raku programming language]] to Doom Emacs. - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:raku-mode]] -- [[doom-package:flycheck-raku]] if [[doom-module::checkers syntax]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires [[https://www.raku.org/][Raku]] for linting and evaluating code. - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/raku/config.el b/.config/emacs/modules/lang/raku/config.el @@ -1,13 +0,0 @@ -;;; lang/raku/config.el -*- lexical-binding: t; -*- - -(use-package! raku-mode - :defer t - :init - (defalias 'perl6-mode #'raku-mode) - :config - (set-repl-handler! 'raku-mode #'run-raku)) - - -(use-package! flycheck-raku - :when (modulep! :checkers syntax) - :after raku-mode) diff --git a/.config/emacs/modules/lang/raku/packages.el b/.config/emacs/modules/lang/raku/packages.el @@ -1,9 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/raku/packages.el - -(package! raku-mode :pin "977b14a7c1295ebf2aad2f807d3f8e7c27aeb47f") - -(when (modulep! :checkers syntax) - (package! flycheck-raku - :recipe (:host github :repo "widefox/flycheck-raku") - :pin "b1acccd6e9d9753022571ee96d18b8e9f3227c65")) diff --git a/.config/emacs/modules/lang/rest/README.org b/.config/emacs/modules/lang/rest/README.org @@ -1,71 +0,0 @@ -#+title: :lang rest -#+subtitle: Emacs as a REST client -#+created: February 20, 2017 -#+since: 2.0.0 - -* Description :unfold: -This module turns Emacs into a [[https://en.wikipedia.org/wiki/Representational_state_transfer][REST]] client. - -- Code-completion (~company-restclient~) -- Code evaluation -- Imenu support for ~restclient-mode~ -- org-mode: babel support (~ob-restclient~) - -#+begin_quote - 💡 ~restclient-mode~ is tremendously useful for automated or quick testing REST - APIs. My workflow is to open an ~org-mode~ buffer, create a restclient - source block and hack away. ~restclient-mode~ and ~company-restclient~ power - this arcane wizardry. -#+end_quote - -** Maintainers -- [[doom-user:][@hlissner]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +jq :: - Enable native support for reading and processing REST responses with jq. - *Requires the =jq= command line utility.* - -** Packages -- [[doom-package:company-restclient]] if [[doom-module::completion company]] -- [[doom-package:restclient]] -- if [[doom-module:+jq]] - - [[doom-package:restclient-jq]] - - [[doom-package:jq-mode]] - -** Hacks -- Adds imenu support to ~restclient-mode~. -- [[doom-package:restclient]] has been modified not to silently reject self-signed or invalid - certificates. - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/rest/autoload.el b/.config/emacs/modules/lang/rest/autoload.el @@ -1,28 +0,0 @@ -;;; lang/rest/autoload.el -*- lexical-binding: t; -*- - -(defun +rest-request-at-point-p (&optional pos) - (save-excursion - (if pos (goto-char pos)) - (beginning-of-line) - (and (re-search-forward restclient-method-url-regexp - (line-end-position) t) - (not (nth 4 (syntax-ppss)))))) - -;;;###autoload -(defun +rest/dwim-at-point () - "TODO" - (interactive) - (when (+rest-request-at-point-p) - (restclient-http-send-current-stay-in-window))) - -;;;###autoload -(defun +rest/fold-all () - "TODO" - (interactive) - (save-excursion - (goto-char (point-min)) - (let ((last (point))) - (while (and (restclient-jump-next) - (not (= last (setq last (point))))) - (unless (overlays-at (line-end-position)) - (restclient-toggle-body-visibility)))))) diff --git a/.config/emacs/modules/lang/rest/config.el b/.config/emacs/modules/lang/rest/config.el @@ -1,46 +0,0 @@ -;;; lang/rest/config.el -*- lexical-binding: t; -*- - -(use-package! restclient - :mode ("\\.http\\'" . restclient-mode) - ;; line numbers aren't enabled by default in fundamental-mode-derived modes - :hook (restclient-mode . display-line-numbers-mode) - :config - (set-popup-rule! "^\\*HTTP Response" :size 0.4 :quit 'other) - - (setq-hook! 'restclient-mode-hook - imenu-generic-expression '((nil "^[A-Z]+\s+.+" 0))) - - (defadvice! +rest--permit-self-signed-ssl-a (fn &rest args) - "Forces underlying SSL verification to prompt for self-signed or invalid -certs, rather than reject them silently." - :around #'restclient-http-do - (require 'gnutls) - (let (gnutls-verify-error) - (apply fn args))) - - (map! :map restclient-mode-map - :n [return] #'+rest/dwim-at-point - :n "za" #'restclient-toggle-body-visibility - :n "zm" #'+rest/fold-all - :n "zr" #'outline-show-all - - :localleader - "e" #'restclient-http-send-current - "E" #'restclient-http-send-current-raw - "c" #'restclient-copy-curl-command)) - - -(use-package! company-restclient - :when (modulep! :completion company) - :after restclient - :config (set-company-backend! 'restclient-mode 'company-restclient)) - - -(use-package! restclient-jq - :when (modulep! +jq) - :after restclient) - - -(use-package! jq-mode - :when (modulep! +jq) - :after restclient-jq) diff --git a/.config/emacs/modules/lang/rest/packages.el b/.config/emacs/modules/lang/rest/packages.el @@ -1,10 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/rest/packages.el - -(package! restclient :pin "0ba72816f92f3d5906cdf76f418fd0a3ee72809b") -(when (modulep! :completion company) - (package! company-restclient :pin "e5a3ec54edb44776738c13e13e34c85b3085277b")) - -(when (modulep! +jq) - (package! jq-mode :pin "071c1c29bac30351ad338136f2b625e5601365cd") - (package! restclient-jq :pin "0ba72816f92f3d5906cdf76f418fd0a3ee72809b")) diff --git a/.config/emacs/modules/lang/rst/README.org b/.config/emacs/modules/lang/rst/README.org @@ -1,49 +0,0 @@ -#+title: :lang rst -#+subtitle: ReST in peace -#+created: October 15, 2021 -#+since: 21.12.0 - -* Description :unfold: -This module adds [[https://docutils.sourceforge.io/rst.html][ReStructured Text]] support to Doom Emacs. - -** Maintainers -*This module needs a maintainer.* [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:sphinx-mode]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires [[https://www.sphinx-doc.org/en/master/usage/installation.html][sphinx]] to build RST documents. - -* TODO Usage -#+begin_quote -🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote -🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote -🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/rst/config.el b/.config/emacs/modules/lang/rst/config.el @@ -1,18 +0,0 @@ -;;; lang/rst/config.el -*- lexical-binding: t; -*- - -(use-package! sphinx-mode - :hook (rst-mode . sphinx-mode)) - -(use-package! rst - :defer t - :config - (map! :localleader - :map rst-mode-map - (:prefix ("a" . "adjust") - "a" #'rst-adjust - "r" #'rst-adjust-region) - (:prefix ("t" . "table of contents") - "t" #'rst-toc - "i" #'rst-toc-insert - "u" #'rst-toc-update - "f" #'rst-toc-follow-link))) diff --git a/.config/emacs/modules/lang/rst/packages.el b/.config/emacs/modules/lang/rst/packages.el @@ -1,4 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/rst/packages.el - -(package! sphinx-mode :pin "77ca51adf9ee877f3a8f43e744f59e650772f121") diff --git a/.config/emacs/modules/lang/ruby/README.org b/.config/emacs/modules/lang/ruby/README.org @@ -1,121 +0,0 @@ -#+title: :lang ruby -#+subtitle: 1.step {|i| p "Ruby is #{i.even? ? 'love' : 'life'}"} -#+created: January 16, 2007 -#+since: 1.3 - -* Description :unfold: -This module add Ruby and optional Ruby on Rails support to Emacs. - -- Code completion ([[doom-package:robe]]) -- Syntax checking ([[doom-package:flycheck]]) -- Jump-to-definitions ([[doom-package:robe]]) -- Bundler -- Rubocop integration ([[doom-package:flycheck]]) - -** Maintainers -- [[doom-user:][@hlissner]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +chruby :: - Enable chruby integration. -- +lsp :: - Enable LSP support for ~ruby-mode~. Requires [[doom-module::tools lsp]] and a langserver - (supports solargraph). -- +rails :: - Enable rails navigational commands, plus server+console integration. -- +rbenv :: - Enable rbenv integration. -- +rvm :: - Enable RVM (Ruby Version Manager) integration. -- +tree-sitter :: - Leverages tree-sitter for better syntax highlighting and structural text - editing. Requires [[doom-module::tools tree-sitter]]. - -** Packages -- [[doom-package:bundler]] -- [[doom-package:chruby]] if [[doom-module:+chruby]] -- [[doom-package:company-inf-ruby]] if :completion company -- [[doom-package:inf-ruby]] -- [[doom-package:minitest]] -- [[doom-package:rake]] -- [[doom-package:rbenv]] if [[doom-module:+rbenv]] -- [[doom-package:robe]] -- [[doom-package:rspec-mode]] -- [[doom-package:rubocop]] -- [[doom-package:rvm]] if [[doom-module:+rvm]] -- if [[doom-module:+rails]] - - [[doom-package:inflections]] - - [[doom-package:projectile-rails]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires Ruby and the Rubocop gem. It is recommended you install -both with some version manager (RVM or Rbenv). - -These guides will help you install Ruby: -- [[https://gorails.com/setup/ubuntu/18.04][Ubuntu]] -- [[https://gorails.com/setup/osx/10.15-catalina][MacOS]] -- [[https://gorails.com/setup/windows/10][Windows]] - -Then run ~$ gem install rubocop~ to install rubocop. - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** Commands -*** robe -| command | key / ex command | description | -|----------------------+--------------------+--------------------------------------------------------------------| -| ~robe-start~ | [[kbd:][<localleader> ']] | Open ruby lang server for auto-completions and jump to definitions | -| ~robe-rails-refresh~ | [[kbd:][<localleader> R]] | Refresh the lang server. | - -*** projectile-rails -The projectile-rails prefix is [[kbd:][<localleader> r]]: -| command | key / ex command | description | -|-------------------------------+-------------------+---------------------------------------------------| -| ~projectile-rails-console~ | [[kbd:][<localleader> r r]] | Open Rails console | -| ~projectile-rails-server~ | [[kbd:][<localleader> r R]] | Open Rails server | -| ~projectile-rails-find-model~ | [[kbd:][<localleader> r m]] | Find any model of the project | -| ~projectile-rails-find-model~ | [[kbd:][<localleader> r M]] | Find the model related of currently open resource | - -*** bundler -The bundler prefix is [[kbd:][<localleader> b]]: -| command | key / ex command | description | -|------------------+-------------------+---------------------| -| ~bundle-install~ | [[kbd:][<localleader> b i]] | Runs bundle install | -| ~bundle-update~ | [[kbd:][<localleader> b u]] | Runs bundle update | - -*** rspec-mode -The rspec-mode prefix is [[kbd:][<localleader> t]]: -| command | key / ex command | description | -|-----------------------+------------------+-----------------------------------| -| ~rspec-verify~ | =SPC m t v= | Runs rspec on current file | -| ~rspec-verify-method~ | =SPC m t s= | Runs rspec for the item on cursor | - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/ruby/autoload.el b/.config/emacs/modules/lang/ruby/autoload.el @@ -1,15 +0,0 @@ -;;; lang/ruby/autoload.el -*- lexical-binding: t; -*- - -;;;###autoload -(defun +ruby-cleanup-robe-servers-h () ; TODO Use me - "Clean up dangling inf robe processes if there are no more `ruby-mode' buffers -open." - ;; FIXME This should wait X seconds before cleaning up - (unless (or (not robe-mode) (doom-buffers-in-mode 'ruby-mode)) - (let (inf-buffer kill-buffer-query-functions) - (while (setq inf-buffer (robe-inf-buffer)) - (let ((process (get-buffer-process inf-buffer)) - confirm-kill-processes) - (when (processp process) - (kill-process (get-buffer-process inf-buffer)) - (kill-buffer inf-buffer))))))) diff --git a/.config/emacs/modules/lang/ruby/config.el b/.config/emacs/modules/lang/ruby/config.el @@ -1,200 +0,0 @@ -;;; lang/ruby/config.el -*- lexical-binding: t; -*- - -(after! projectile - (add-to-list 'projectile-project-root-files "Gemfile")) - - -;; -;;; Packages - -(use-package! ruby-mode ; built-in - ;; Other extensions are already registered in `auto-mode-alist' by `ruby-mode' - :mode "\\.\\(?:a?rb\\|aslsx\\)\\'" - :mode "/\\(?:Brew\\|Fast\\)file\\'" - :interpreter "j?ruby\\(?:[0-9.]+\\)" - :config - (setq ruby-insert-encoding-magic-comment nil) - - (set-electric! 'ruby-mode :words '("else" "end" "elsif")) - (set-repl-handler! 'ruby-mode #'inf-ruby) - - (when (modulep! +lsp) - (add-hook 'ruby-mode-local-vars-hook #'lsp! 'append)) - - (when (modulep! +tree-sitter) - (add-hook 'ruby-mode-local-vars-hook #'tree-sitter! 'append)) - - (after! inf-ruby - (add-hook 'inf-ruby-mode-hook #'doom-mark-buffer-as-real-h) - ;; switch to inf-ruby from compile if we detect a breakpoint has been hit - (add-hook 'compilation-filter-hook #'inf-ruby-auto-enter)) - - ;; so class and module pairs work - (setq-hook! 'ruby-mode-hook sp-max-pair-length 6) - - (map! :localleader - :map ruby-mode-map - "[" #'ruby-toggle-block - "{" #'ruby-toggle-block)) - - -(use-package! robe - :defer t - :init - (add-hook! 'ruby-mode-hook - (defun +ruby-init-robe-mode-maybe-h () - "Start `robe-mode' if `lsp-mode' isn't active." - (or (bound-and-true-p lsp-mode) - (bound-and-true-p lsp--buffer-deferred) - (robe-mode +1)))) - :config - (set-repl-handler! 'ruby-mode #'robe-start) - (set-company-backend! 'ruby-mode 'company-robe 'company-dabbrev-code) - (set-lookup-handlers! 'ruby-mode - :definition #'robe-jump - :documentation #'robe-doc) - (when (boundp 'read-process-output-max) - ;; Robe can over saturate IPC, making interacting with it slow/clobbering - ;; the GC, so increase the amount of data Emacs reads from it at a time. - (setq-hook! '(robe-mode-hook inf-ruby-mode-hook) - read-process-output-max (* 1024 1024))) - (when (modulep! :editor evil) - (add-hook 'robe-mode-hook #'evil-normalize-keymaps)) - (map! :localleader - :map robe-mode-map - "'" #'robe-start - "h" #'robe-doc - "R" #'robe-rails-refresh - :prefix "s" - "d" #'ruby-send-definition - "D" #'ruby-send-definition-and-go - "r" #'ruby-send-region - "R" #'ruby-send-region-and-go - "i" #'ruby-switch-to-inf)) - - -;; NOTE Must be loaded before `robe-mode' -(use-package! yard-mode - :hook ruby-mode) - - -(use-package! rubocop - :hook (ruby-mode . rubocop-mode) - :config - (set-popup-rule! "^\\*RuboCop" :select t) - (map! :localleader - :map rubocop-mode-map - "f" #'rubocop-check-current-file - "F" #'rubocop-autocorrect-current-file - "p" #'rubocop-check-project - "P" #'rubocop-autocorrect-project)) - - -;; -;;; Package & Ruby version management - -(use-package! rake - :defer t - :init - (setq rake-cache-file (concat doom-cache-dir "rake.cache")) - (setq rake-completion-system 'default) - (map! :after ruby-mode - :localleader - :map ruby-mode-map - :prefix ("k" . "rake") - "k" #'rake - "r" #'rake-rerun - "R" #'rake-regenerate-cache - "f" #'rake-find-task)) - -(use-package! bundler - :defer t - :init - (map! :after ruby-mode - :localleader - :map ruby-mode-map - :prefix ("b" . "bundle") - "c" #'bundle-check - "C" #'bundle-console - "i" #'bundle-install - "u" #'bundle-update - "e" #'bundle-exec - "o" #'bundle-open)) - -(use-package! chruby - :when (modulep! +chruby) - :hook (ruby-mode . chruby-use-corresponding) - :config - (setq rspec-use-rvm nil - rspec-use-chruby t)) - -(after! rbenv - (setq rspec-use-rvm nil) - (add-to-list 'exec-path (expand-file-name "shims" rbenv-installation-dir))) - - -;; -;;; Testing frameworks - -(use-package! rspec-mode - :mode ("/\\.rspec\\'" . text-mode) - :init - (setq rspec-use-spring-when-possible nil) - (when (modulep! :editor evil) - (add-hook 'rspec-mode-hook #'evil-normalize-keymaps)) - :config - (set-popup-rule! "^\\*\\(rspec-\\)?compilation" :size 0.3 :ttl nil :select t) - (setq rspec-use-rvm (executable-find "rvm")) - (map! :localleader - :prefix "t" - :map (rspec-verifiable-mode-map rspec-dired-mode-map rspec-mode-map) - "a" #'rspec-verify-all - "r" #'rspec-rerun - :map (rspec-verifiable-mode-map rspec-mode-map) - "v" #'rspec-verify - "c" #'rspec-verify-continue - "l" #'rspec-run-last-failed - "T" #'rspec-toggle-spec-and-target - "t" #'rspec-toggle-spec-and-target-find-example - :map rspec-verifiable-mode-map - "f" #'rspec-verify-method - "m" #'rspec-verify-matching - :map rspec-mode-map - "s" #'rspec-verify-single - "e" #'rspec-toggle-example-pendingness - :map rspec-dired-mode-map - "v" #'rspec-dired-verify - "s" #'rspec-dired-verify-single)) - - -(use-package! minitest - :defer t - :config - (when (modulep! :editor evil) - (add-hook 'minitest-mode-hook #'evil-normalize-keymaps)) - (map! :localleader - :map minitest-mode-map - :prefix "t" - "r" #'minitest-rerun - "a" #'minitest-verify-all - "s" #'minitest-verify-single - "v" #'minitest-verify)) - - -(use-package! projectile-rails - :when (modulep! +rails) - :hook ((ruby-mode inf-ruby-mode projectile-rails-server-mode) . projectile-rails-mode) - :hook (projectile-rails-server-mode . doom-mark-buffer-as-real-h) - :hook (projectile-rails-mode . auto-insert-mode) - :init - (setq auto-insert-query nil) - (setq inf-ruby-console-environment "development") - (when (modulep! :lang web) - (add-hook 'web-mode-hook #'projectile-rails-mode)) - :config - (set-popup-rule! "^\\*\\(projectile-\\)?rails" :ttl nil) - (when (modulep! :editor evil) - (add-hook 'projectile-rails-mode-hook #'evil-normalize-keymaps)) - (map! :localleader - :map projectile-rails-mode-map - "r" #'projectile-rails-command-map)) diff --git a/.config/emacs/modules/lang/ruby/doctor.el b/.config/emacs/modules/lang/ruby/doctor.el @@ -1,20 +0,0 @@ -;;; lang/ruby/doctor.el -*- lexical-binding: t; -*- - -(assert! (or (not (modulep! +lsp)) - (modulep! :tools lsp)) - "This module requires (:tools lsp)") - -(assert! (or (not (modulep! +tree-sitter)) - (modulep! :tools tree-sitter)) - "This module requires (:tools tree-sitter)") - -(unless (executable-find "ruby") - (warn! "Ruby isn't installed.")) - -(when (and (executable-find "rbenv") (modulep! +rbenv)) - (unless (split-string (shell-command-to-string "rbenv versions --bare") "\n" t) - (warn! "No versions of ruby are available via rbenv, did you forget to install one?"))) - -(when (and (executable-find "chruby") (modulep! +chruby)) - (unless (split-string (shell-command-to-string "chruby") "\n" t) - (warn! "No versions of ruby are available via chruby, did you forget to install one?"))) diff --git a/.config/emacs/modules/lang/ruby/packages.el b/.config/emacs/modules/lang/ruby/packages.el @@ -1,36 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/ruby/packages.el - -;; Major modes -(package! ruby-mode :built-in t) -(package! yard-mode :pin "ef3426ff55b6e91d581c8da12f5f64855d932527") - -;; REPL -(package! inf-ruby :pin "6f1df882ab319758af43877fa20465f6566efbf3") -(when (modulep! :completion company) - (package! company-inf-ruby :pin "fe3e4863bc971fbb81edad447efad5795ead1b17")) - -;; Programming environment -(package! rubocop :pin "f5fd18aa810c3d3269188cbbd731ddc09006f8f5") -(package! robe :pin "b9d5ab549f73c5587415f538303fa76e0833354d") - -;; Project tools -(package! bundler :pin "43efb6be4ed118b06d787ce7fbcffd68a31732a7") -(package! rake :pin "452ea0caca33376487103c64177c295ed2960cca") - -;; Environment management -(when (modulep! +rbenv) - (package! rbenv :pin "2ea1a5bdc1266caef1dd77700f2c8f42429b03f1")) -(when (modulep! +rvm) - (package! rvm :pin "e1e83b5466c132c066142ac63729ba833c530c83")) -(when (modulep! +chruby) - (package! chruby :pin "42bc6d521f832eca8e2ba210f30d03ad5529788f")) - -;; Testing frameworks -(package! rspec-mode :pin "62853a428b416e6a5fd3d8f57ff83a1798188a3f") -(package! minitest :pin "ddd152c990a528ad09a696bfad23afa4330ea4d7") - -;; Rails -(when (modulep! +rails) - (package! projectile-rails :pin "701784df7befe17b861f1b53fe9cbc59d0b94b9f") - (package! inflections :pin "55caa66a7cc6e0b1a76143fd40eff38416928941")) diff --git a/.config/emacs/modules/lang/rust/README.org b/.config/emacs/modules/lang/rust/README.org @@ -1,121 +0,0 @@ -#+title: :lang rust -#+subtitle: Fe2O3.unwrap().unwrap().unwrap().unwrap() -#+created: September 30, 2015 -#+since: 0.7 - -* Description :unfold: -This module adds support for the Rust language and integration for its tools, -e.g. ~cargo~. - -- Code completion ([[doom-package:racer]] or an LSP server) -- Syntax checking ([[doom-package:flycheck]]) -- LSP support (for rust-analyzer and rls) ([[doom-package:rustic]]) -- Snippets - -** Maintainers -- @hlissner - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +lsp :: - Enable LSP support for ~rustic-mode~. Requires [[doom-module::tools lsp]] and a langserver - (supports [[https://rust-analyzer.github.io/][rust-analyzer]] and rls). -- +tree-sitter :: - Leverages tree-sitter for better syntax highlighting and structural text - editing. Requires [[doom-module::tools tree-sitter]]. - -** Packages -- [[doom-package:rustic]] - -** Hacks -- rustic has been modified /not/ to automatically install lsp-mode or eglot if - they're missing. Doom expects you to have enabled the [[doom-module::tools lsp]] module - yourself. - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires ~rust~, which can be acquired through =rustup=: -#+begin_src sh -curl https://sh.rustup.rs -sSf | sh -#+end_src - -Note that when the Rust /language/ has updates, you are to run =rustup= such -that it doesn't upgrade itself: -#+begin_src sh -rustup update --no-self-update -#+end_src - -** Other Requirements -- If [[doom-module::editor format]] is enabled, you'll need =rustfmt=: ~$ rustup component add - rustfmt-preview~. -- Users with [[doom-module:+lsp]] enabled will need [[https://rust-analyzer.github.io/][rust-analyzer]] (rls is supported, but - [[https://blog.rust-lang.org/2022/07/01/RLS-deprecation.html][deprecated]]). -- Using the following commands requires: - - ~cargo-process-check~: ~$ cargo install cargo-check~ - - ~cargo-process-clippy~: ~$ rustup component add clippy-preview~ - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** LSP support (rls or rust-analyzer) -This module supports LSP integration. For it to work you'll need: - -1. To install [[https://github.com/rust-analyzer/rust-analyzer][rust-analyzer]] through your OS package manager ([[https://github.com/rust-lang/rls][RLS]] is supported - too, but it is [[https://blog.rust-lang.org/2022/07/01/RLS-deprecation.html][deprecated]]). -2. To enable the [[doom-module::tools lsp]] module. -3. To enable the [[doom-module:+lsp]] flag on this module. - -** Format on save -Enable [[doom-module::editor format +onsave]] to get formatting on save with =rustfmt=. No -additional configuration is necessary. - -** Keybinds -| Binding | Description | -|---------------------+-----------------------------| -| =<localleader> b a= | ~cargo audit~ | -| =<localleader> b b= | ~cargo build~ | -| =<localleader> b B= | ~cargo bench~ | -| =<localleader> b c= | ~cargo check~ | -| =<localleader> b C= | ~cargo clippy~ | -| =<localleader> b d= | ~cargo doc~ | -| =<localleader> b n= | ~cargo update~ | -| =<localleader> b o= | ~cargo outdated~ | -| =<localleader> b r= | ~cargo run~ | -| =<localleader> t a= | ~cargo test~ | -| =<localleader> t t= | ~run current test~ | - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** Enabling eglot support for Rust -Doom's [[doom-module::tools lsp]] module has an [[doom-module:+eglot]] flag. Enable it and this module will use -eglot instead. - -* Troubleshooting -[[doom-report:][Report an issue?]] - -** error[E0670]: `async fn` is not permitted in the 2015 edition -You may be seeing this error, despite having ~edition = "2018"~ in your -=Cargo.toml=. This error actually originates from ~rustfmt~, which the LSP -server tries to invoke on save (if you have ~rustic-format-trigger~ or [[doom-module::editor -format]] enabled). - -To fix this your project needs a =rustfmt.toml= with ~edition = "2018"~ in it. - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/rust/autoload.el b/.config/emacs/modules/lang/rust/autoload.el @@ -1,19 +0,0 @@ -;;; lang/rust/autoload.el -*- lexical-binding: t; -*- - -;; TODO (defun +rust/run-cargo () (interactive)) - -;;;###autoload -(defun +rust-cargo-project-p () - "Return t if this is a cargo project." - (locate-dominating-file buffer-file-name "Cargo.toml")) - - -;; -;;; Custom Cargo commands - -(autoload 'rustic-run-cargo-command "rustic-cargo") -;;;###autoload -(defun +rust/cargo-audit () - "Run 'cargo audit' for the current project." - (interactive) - (rustic-run-cargo-command "cargo audit")) diff --git a/.config/emacs/modules/lang/rust/config.el b/.config/emacs/modules/lang/rust/config.el @@ -1,78 +0,0 @@ -;;; lang/rust/config.el -*- lexical-binding: t; -*- - -(after! projectile - (add-to-list 'projectile-project-root-files "Cargo.toml")) - - -;; -;;; Packages - -(use-package! rustic - :mode ("\\.rs$" . rustic-mode) - :preface - ;; HACK `rustic' sets up some things too early. I'd rather disable it and let - ;; our respective modules standardize how they're initialized. - (setq rustic-lsp-client nil) - (after! rustic-lsp - (remove-hook 'rustic-mode-hook 'rustic-setup-lsp)) - (after! rustic-flycheck - (remove-hook 'rustic-mode-hook #'flycheck-mode) - (remove-hook 'rustic-mode-hook #'flymake-mode-off) - (remove-hook 'flycheck-mode-hook #'rustic-flycheck-setup)) - :init - ;; HACK Certainly, `rustic-babel' does this, but the package (and many other - ;; rustic packages) must be loaded in order for them to take effect. To lazy - ;; load it all, we must do it early: - (after! org-src - (defalias 'org-babel-execute:rust #'org-babel-execute:rustic) - (add-to-list 'org-src-lang-modes '("rust" . rustic))) - :config - (add-hook 'rustic-mode-hook #'rainbow-delimiters-mode) - (set-docsets! 'rustic-mode "Rust") - (set-popup-rule! "^\\*rustic-compilation" :vslot -1) - - (setq rustic-indent-method-chain t) - - ;; Conflicts with (and is redundant with) :ui ligatures - (setq rust-prettify-symbols-alist nil) - - ;; Leave automatic reformatting to the :editor format module. - (setq rustic-babel-format-src-block nil - rustic-format-trigger nil) - - (if (not (modulep! +lsp)) - (after! rustic-flycheck - (add-to-list 'flycheck-checkers 'rustic-clippy)) - (setq rustic-lsp-client - (if (modulep! :tools lsp +eglot) - 'eglot - 'lsp-mode)) - (add-hook 'rustic-mode-local-vars-hook #'rustic-setup-lsp 'append)) - - (when (modulep! +tree-sitter) - (add-hook 'rustic-mode-local-vars-hook #'tree-sitter! 'append)) - - ;; HACK If lsp/eglot isn't available, it attempts to install lsp-mode via - ;; package.el. Doom manages its own dependencies through straight so disable - ;; this behavior to avoid package-not-initialized errors. - (defadvice! +rust--dont-install-packages-a (&rest _) - :override #'rustic-install-lsp-client-p - (message "No LSP server running")) - - (map! :map rustic-mode-map - :localleader - (:prefix ("b" . "build") - :desc "cargo audit" "a" #'+rust/cargo-audit - :desc "cargo build" "b" #'rustic-cargo-build - :desc "cargo bench" "B" #'rustic-cargo-bench - :desc "cargo check" "c" #'rustic-cargo-check - :desc "cargo clippy" "C" #'rustic-cargo-clippy - :desc "cargo doc" "d" #'rustic-cargo-build-doc - :desc "cargo doc --open" "D" #'rustic-cargo-doc - :desc "cargo fmt" "f" #'rustic-cargo-fmt - :desc "cargo new" "n" #'rustic-cargo-new - :desc "cargo outdated" "o" #'rustic-cargo-outdated - :desc "cargo run" "r" #'rustic-cargo-run) - (:prefix ("t" . "cargo test") - :desc "all" "a" #'rustic-cargo-test - :desc "current test" "t" #'rustic-cargo-current-test))) diff --git a/.config/emacs/modules/lang/rust/doctor.el b/.config/emacs/modules/lang/rust/doctor.el @@ -1,33 +0,0 @@ -;; -*- lexical-binding: t; no-byte-compile: t; -*- -;;; lang/rust/doctor.el - -(assert! (or (not (modulep! +lsp)) - (modulep! :tools lsp)) - "This module requires (:tools lsp)") - -(assert! (or (not (modulep! +tree-sitter)) - (modulep! :tools tree-sitter)) - "This module requires (:tools tree-sitter)") - -(unless (executable-find "rustc") - (warn! "Couldn't find rustc binary")) - -(unless (executable-find "cargo") - (warn! "Couldn't find cargo binary")) - -(if (modulep! +lsp) - (when (require 'rustic nil t) - (pcase rustic-lsp-server - (`rust-analyzer - (unless (executable-find "rust-analyzer") - (warn! "Couldn't find rust analyzer (rust-analyzer)"))) - (`rls - (unless (executable-find "rls") - (warn! "Couldn't find rls"))))) - (when (require 'racer nil t) - ;; racer - (unless (file-exists-p racer-cmd) - (warn! "Couldn't find the racer binary at `racer-cmd'")) - ;; rust source code (rustup component add rust-src) - (unless (file-directory-p racer-rust-src-path) - (warn! "Couldn't find Rust's source code at RUST_SRC_PATH or `racer-rust-src-path'")))) diff --git a/.config/emacs/modules/lang/rust/packages.el b/.config/emacs/modules/lang/rust/packages.el @@ -1,4 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/rust/packages.el - -(package! rustic :pin "39423d1cf4fa054c36bf9577356451f4c06ee148") diff --git a/.config/emacs/modules/lang/scala/README.org b/.config/emacs/modules/lang/scala/README.org @@ -1,123 +0,0 @@ -#+title: :lang scala -#+subtitle: Java, but good -#+created: May 12, 2016 -#+since: 1.0 - -* Description :unfold: -This module adds [[https://www.scala-lang.org][scala]] and [[https://www.scala-sbt.org/][sbt]] support to Doom Emacs. - -Through the power of [[https://scalameta.org/metals/docs/editors/overview.html][Metals]] (LSP) this module offers: -- Goto Definition -- Completions -- Hover -- Paremeter Hints -- Find References -- Run/Debug -- Find Implementations -- Rename Symbol -- Code Actions -- Document Symbols -- Formatting -- Folding -- Organize Imports - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +lsp :: - Enable LSP support for ~scala-mode~. Requires [[doom-module::tools lsp]] and a langserver - (supports metals). -- +tree-sitter :: - Leverages tree-sitter for better syntax highlighting and structural text - editing. Requires [[doom-module::tools tree-sitter]]. - -** Packages -- [[doom-package:sbt-mode]] -- [[doom-package:scala-mode]] -- [[doom-package:lsp-metals]] if [[doom-module:+lsp]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -** =+lsp= Integration -To set up LSP support for Scala you'll need the Metals LSP server. To install it -you need Coursier installed first: - -*** Coursier -Coursier is only required to install Metals. If you're on Arch linux this step -can be skipped. - -**** Ubuntu / Debian / Fedora -#+begin_src sh -curl -fLo cs https://git.io/coursier-cli-linux && - chmod +x cs && - ./cs -#+end_src - -**** MacOS -#+begin_src sh -curl -fLo cs https://git.io/coursier-cli-macos && - chmod +x cs && - (xattr -d com.apple.quarantine cs || true) && - ./cs -#+end_src - -**** Arch Linux -#+begin_src sh -yay -S coursier -#+end_src - -*** Metals -**** Ubuntu / Debian / Fedora / MacOS -Update following command to latest version of metals [[https://scalameta.org/metals/docs/editors/emacs.html][found here]]. - -#+begin_src sh -coursier bootstrap \ - --java-opt -Xss4m \ - --java-opt -Xms100m \ - --java-opt -Dmetals.client=emacs \ - org.scalameta:metals_2.12:0.9.4 \ - -r bintray:scalacenter/releases \ - -r sonatype:snapshots \ - -o /usr/local/bin/metals-emacs -f -#+end_src - -**** Arch Linux -#+begin_src sh -yay -S metals -#+end_src - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -[[doom-report:][Report an issue?]] - -- Projects are required to have scala version =2.11.12=, =2.12.8=, =2.13.0= or - greater. -- Latest version of sbt is recommended. -- Running ~M-x lsp-metals-doctor-run~ helps diagnose problems. -- Full reference here: https://scalameta.org/metals/docs/editors/emacs.html - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/scala/autoload.el b/.config/emacs/modules/lang/scala/autoload.el @@ -1,54 +0,0 @@ -;;; lang/scala/autoload.el -*- lexical-binding: t; -*- - -;;;###autoload -(defun +scala-comment-indent-new-line-fn (&optional _) - "Continue the commnt on the current line. - -Meant to be used for `scala-mode's `comment-line-break-function'." - (let* ((state (syntax-ppss)) - (comment-start-pos (nth 8 state))) - (save-match-data - (cond ((and (integerp (nth 4 state)) - ;; Ensure that we're inside a scaladoc comment - (string-match-p "^/\\*\\*?[^\\*]?" - (buffer-substring-no-properties - comment-start-pos - (min (+ comment-start-pos 4) - (point-max)))) - (progn - (setq prev-line (buffer-substring-no-properties - (line-beginning-position 0) - (line-end-position 0))) - (or (string-match "^\\s-*\\*" prev-line) - (string-match "\\s-*/*" prev-line)))) - (newline nil t) - (indent-according-to-mode) - (insert (make-string (max 0 (- (1- (match-end 0)) - (match-beginning 0))) - ? ) - "*") - (scala-indent:indent-on-scaladoc-asterisk)) - ((nth 4 state) ; for line comments - (call-interactively #'comment-indent-new-line)) - (t - (newline nil t) - (indent-according-to-mode)))))) - -;;;###autoload -(defun +scala/open-repl () - "Open a scala repl. Uses `run-scala' if in a sbt project." - (interactive) - (if (and (require 'sbt-mode nil t) - (sbt:find-root)) - (let ((buffer-name (sbt:buffer-name))) - (when (and (get-buffer buffer-name) (not (comint-check-proc buffer-name))) - (kill-buffer buffer-name)) - (run-scala) - (get-buffer buffer-name)) - (let* ((buffer-name "*scala-repl") - (buffer - (if (comint-check-proc buffer-name) - (get-buffer buffer-name) - (make-comint-in-buffer "scala-repl" buffer-name "scala")))) - (display-buffer buffer) - buffer))) diff --git a/.config/emacs/modules/lang/scala/config.el b/.config/emacs/modules/lang/scala/config.el @@ -1,55 +0,0 @@ -;;; lang/scala/config.el -*- lexical-binding: t; -*- - -(after! projectile - (add-to-list 'projectile-project-root-files "build.sbt")) - - -;; -;;; Packages - -(after! scala-mode - (setq scala-indent:align-parameters t - ;; indent block comments to first asterix, not second - scala-indent:use-javadoc-style t) - - (setq-hook! 'scala-mode-hook - comment-line-break-function #'+scala-comment-indent-new-line-fn) - - (when (modulep! +lsp) - (setq-hook! 'scala-mode-hook lsp-enable-indentation nil) - (add-hook 'scala-mode-local-vars-hook #'lsp! 'append)) - - (when (modulep! +tree-sitter) - (add-hook 'scala-mode-local-vars-hook #'tree-sitter! 'append)) - - (set-ligatures! 'scala-mode - ;; Functional - :def "def" - :composition "compose" - ;; HKT - :lambda "Lambda" - ;; Types - :null "none" - :null "None" - :true "true" - :false "false" - :int "Int" - :str "String" - :float "Float" - :bool "Boolean" - :list "List" - ;; Flow - :for "for" - :not "!" - :and "&&" - :or "||" - :yield "yield" - ;; Other - :union "union" - :intersect "intersect" - :diff "diff")) - - -(use-package! sbt-mode - :after scala-mode - :config (set-repl-handler! 'scala-mode #'+scala/open-repl :persist t)) diff --git a/.config/emacs/modules/lang/scala/doctor.el b/.config/emacs/modules/lang/scala/doctor.el @@ -1,13 +0,0 @@ -;;; lang/scala/doctor.el -*- lexical-binding: t; -*- - -(assert! (or (not (modulep! +lsp)) - (modulep! :tools lsp)) - "This module requires (:tools lsp)") - -(assert! (or (not (modulep! +tree-sitter)) - (modulep! :tools tree-sitter)) - "This module requires (:tools tree-sitter)") - -(if (and (modulep! +lsp) - (not (executable-find "metals-emacs"))) - (warn! "metals-emacs isn't installed")) diff --git a/.config/emacs/modules/lang/scala/packages.el b/.config/emacs/modules/lang/scala/packages.el @@ -1,8 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/scala/packages.el - -(package! sbt-mode :pin "9fe1e8807c22cc1dc56a6233e000969518907f4d") -(package! scala-mode :pin "5d7cf21c37e345c49f921fe5111a49fd54efd1e0") - -(when (modulep! +lsp) - (package! lsp-metals :pin "a2df7263ece6ac69214e41c52d66aab8d3f650eb")) diff --git a/.config/emacs/modules/lang/scheme/README.org b/.config/emacs/modules/lang/scheme/README.org @@ -1,81 +0,0 @@ -#+title: :lang scheme -#+subtitle: A fully conniving family of lisps -#+created: July 23, 2019 -#+since: 21.12.0 (#1588) - -* Description :unfold: -This module provides support for the Scheme family of Lisp languages, powered by -[[https://www.nongnu.org/geiser/geiser_1.html#introduction][geiser]]. - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +chez :: -- +chibi :: -- +chicken :: -- +gambit :: -- +gauche :: -- +guile :: -- +kawa :: -- +mit :: -- +racket :: - -** Packages -- [[doom-package:flycheck-guile]] if [[doom-module:+guile]] and [[doom-module::checkers syntax]] -- [[doom-package:geiser]] -- [[doom-package:geiser-chez]] if [[doom-module:+chez]] -- [[doom-package:geiser-chibi]] if [[doom-module:+chibi]] -- [[doom-package:geiser-chicken]] if [[doom-module:+chicken]] -- [[doom-package:geiser-gambit]] if [[doom-module:+gambit]] -- [[doom-package:geiser-gauche]] if [[doom-module:+gauche]] -- [[doom-package:geiser-guile]] if [[doom-module:+guile]] -- [[doom-package:geiser-kawa]] if [[doom-module:+kawa]] -- [[doom-package:geiser-mit]] if [[doom-module:+mit]] -- [[doom-package:geiser-racket]] if [[doom-module:+racket]] -- [[doom-package:macrostep-geiser]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -Depending on which flags you have enabled on this module, you'll need the -associated Schemes, namely: -- [[https://www.gnu.org/software/guile][Guile]] 2.2.0 or better -- [[https://call-cc.org][Chicken]] 4.8.0 or better -- [[https://www.gnu.org/software/mit-scheme][MIT/GNU Scheme]] 9.1.1 or better -- [[https://synthcode.com/scheme/chibi][Chibi Scheme]] 0.7.3 or better -- [[https://www.scheme.com][Chez Scheme]] 9.4 or better - -Their executables must be present in your =$PATH= for [[doom-package:geiser]] to work properly. - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -| command | key / ex command | description | -|---------------------+-----------------------+----------------------| -| ~+scheme/open-repl~ | [[kbd:][<leader> o r]], =:repl= | Open the Scheme Repl | - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/scheme/autoload.el b/.config/emacs/modules/lang/scheme/autoload.el @@ -1,73 +0,0 @@ -;;; lang/scheme/autoload.el -*- lexical-binding: t; -*- - -;; HACK `geiser' has poor autoload etiquette. It calls -;; `geiser-activate-implementation' and `geiser-implementation-extension' -;; in their autoloads files. Sure, these functions are autoloaded, but this -;; needlessly (and unavoidably) pulls in the `geiser-impl' package (et co) -;; when geiser-X's autoloads are read (i.e. at startup). -;; -;; I rectify this by inlining calls to these two functions (and the -;; `geiser-impl--add-to-alist' sub-call in -;; `geiser-implementation-extension'), and autoloading the two variables -;; they operate on. I do this from our autoloads file (which is -;; byte-compiled and read at startup before package autoloads). -;; TODO At some point, PR this behavior upstream (but not verbatim!) -;;;###autoload (defvar geiser-active-implementations ()) -;;;###autoload (defvar geiser-implementations-alist ()) -;;;###autoload (eval-and-compile (dolist (sym '(geiser-impl--add-to-alist geiser-activate-implementation geiser-implementation-extension)) (put sym 'byte-optimizer 'byte-compile-inline-expand))) - - -(defvar calculate-lisp-indent-last-sexp) -;; Adapted from https://github.com/alezost/emacs-config/blob/master/utils/al-scheme.el#L76-L123 -;;;###autoload -(defun +scheme-indent-function-a (indent-point state) - "Advice to replace `scheme-indent-function'. - -This function is the same as `scheme-indent-function' except it properly indents -property lists and names starting with 'default'." - (let ((normal-indent (current-column))) - (goto-char (1+ (elt state 1))) - (parse-partial-sexp (point) calculate-lisp-indent-last-sexp 0 t) - (if (and (elt state 2) - ;; NOTE looking-at -> looking-at-p - (not (looking-at-p "\\sw\\|\\s_"))) - (progn - ;; NOTE (if (not ...) (progn ...)) -> (unless ... ...) - (unless (> (save-excursion (forward-line 1) (point)) - calculate-lisp-indent-last-sexp) - (goto-char calculate-lisp-indent-last-sexp) - (beginning-of-line) - (parse-partial-sexp (point) calculate-lisp-indent-last-sexp 0 t)) - (backward-prefix-chars) - (current-column)) - ;; NOTE let -> let* & moved `method' def into let bindings - (let* ((function (buffer-substring - (point) (progn (forward-sexp 1) (point)))) - (method (or (get (intern-soft function) 'scheme-indent-function) - (get (intern-soft function) 'scheme-indent-hook)))) - (cond ((or (eq method 'defun) - (and (null method) - (> (length function) 3) - ;; NOTE string-match -> string-match-p - ;; NOTE The original regexp is "\\`def" but it will mess - ;; up indentation with such names as 'default-...'. - (string-match-p "\\`def" function))) - (lisp-indent-defform state indent-point)) - ;; NOTE Added this clause to handle alignment of keyword symbols - ((and (null method) - (> (length function) 1) - ;; NOTE string-match -> string-match-p - (string-match-p "\\`:" function)) - (let ((lisp-body-indent 1)) - (lisp-indent-defform state indent-point))) - ((integerp method) - (lisp-indent-specform method state indent-point normal-indent)) - (method - (funcall method state indent-point normal-indent))))))) - -;;;###autoload -(defun +scheme/open-repl () - "Open the Scheme REPL." - (interactive) - (call-interactively #'geiser-repl-switch) - (current-buffer)) diff --git a/.config/emacs/modules/lang/scheme/config.el b/.config/emacs/modules/lang/scheme/config.el @@ -1,85 +0,0 @@ -;;; lang/scheme/config.el -*- lexical-binding: t; -*- - -(use-package! scheme - :hook (scheme-mode . rainbow-delimiters-mode) - :config (advice-add #'scheme-indent-function :override #'+scheme-indent-function-a)) - - -(use-package! geiser - :defer t - :init - (setq geiser-autodoc-identifier-format "%s → %s" - geiser-repl-per-project-p t - geiser-repl-current-project-function #'doom-project-root - geiser-repl-history-filename (concat doom-cache-dir "geiser-history")) - - (after! scheme ; built-in - (set-repl-handler! 'scheme-mode #'+scheme/open-repl - :persist t - :send-region #'geiser-eval-region - :send-buffer #'geiser-eval-buffer) - (set-eval-handler! 'scheme-mode #'geiser-eval-region) - (set-lookup-handlers! '(scheme-mode geiser-repl-mode) - :definition #'geiser-edit-symbol-at-point - :documentation #'geiser-doc-symbol-at-point)) - :config - (set-popup-rules! - '(("^\\*[gG]eiser \\(dbg\\|xref\\|messages\\)\\*$" :slot 1 :vslot -1) - ("^\\*Geiser documentation\\*$" :slot 2 :vslot 2 :select t :size 0.35) - ("^\\*Geiser .+ REPL" :size 0.3 :quit nil :ttl nil))) - - (map! :localleader - (:map (scheme-mode-map geiser-repl-mode-map) - :desc "Toggle REPL" "'" #'geiser-repl-switch - :desc "Connect to external Scheme" "\"" #'geiser-connect - :desc "Toggle type of brackets" "[" #'geiser-squarify - :desc "Insert lambda" "\\" #'geiser-insert-lambda - :desc "Set Scheme implementation" "s" #'geiser-set-scheme - :desc "Reload Geiser buffers+REPLs" "R" #'geiser-reload - (:prefix ("h" . "help") - :desc "Show callers of <point>" "<" #'geiser-xref-callers - :desc "Show callees of <point>" ">" #'geiser-xref-callees - :desc "Toggle autodoc mode" "a" #'geiser-autodoc-mode - :desc "Show autodoc of <point>" "s" #'geiser-autodoc-show - :desc "Search manual for <point>" "m" #'geiser-doc-look-up-manual - :desc "Show docstring of <point>" "." #'geiser-doc-symbol-at-point) - (:prefix ("r" . "repl") - :desc "Load file into REPL" "f" #'geiser-load-file - :desc "Restart REPL" "r" #'geiser-restart-repl)) - (:map scheme-mode-map - (:prefix ("e" . "eval") - :desc "Eval buffer" "b" #'geiser-eval-buffer - :desc "Eval buffer and go to REPL" "B" #'geiser-eval-buffer-and-go - :desc "Eval last sexp" "e" #'geiser-eval-last-sexp - :desc "Eval definition" "d" #'geiser-eval-definition - :desc "Eval defn. and go to REPL" "D" #'geiser-eval-definition-and-go - :desc "Eval region" "r" #'geiser-eval-region - :desc "Eval region and go to REPL" "R" #'geiser-eval-region-and-go) - (:prefix ("r" . "repl") - :desc "Load current buffer in REPL" "b" #'geiser-load-current-buffer)) - (:map geiser-repl-mode-map - :desc "Clear REPL buffer" "c" #'geiser-repl-clear-buffer - :desc "Quit REPL" "q" #'geiser-repl-exit))) - - -(use-package! macrostep-geiser - :hook (geiser-mode . macrostep-geiser-setup) - :hook (geiser-repl-mode . macrostep-geiser-setup) - :init - (map! :after geiser - :localleader - :map (scheme-mode-map geiser-repl-mode-map) - :desc "Expand macro by one step" "m" #'macrostep-expand - :desc "Recursively expand macro" "M" #'macrostep-geiser-expand-all)) - - -(use-package! flycheck-guile - :when (modulep! +guile) - :when (modulep! :checkers syntax) - :after geiser) - -;; Add Guix channels to Guile load path -(when (and (modulep! +guile) (executable-find "guix")) - (after! geiser-guile - (add-to-list 'geiser-guile-load-path - (expand-file-name "~/.config/guix/current/share/guile/site/3.0")))) diff --git a/.config/emacs/modules/lang/scheme/packages.el b/.config/emacs/modules/lang/scheme/packages.el @@ -1,32 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/scheme/packages.el - -(when (< emacs-major-version 29) - (package! scheme - :recipe (:host gitlab :repo "flatwhatson/scheme-mode") - :pin "aaef1f88cc34e8b6e07c207f9b8caff33f6e0740")) - -(when (package! geiser :pin "e54d5e6dc659c252d10c4280f4c4d78d38623df5") - (package! macrostep-geiser :pin "f6a2d5bb96ade4f23df557649af87ebd0cc45125") - (when (modulep! +chez) - (package! geiser-chez :pin "246ec4c8bc4e7f64414e5cbe0fa66f0e5ef7d527")) - (when (modulep! +chibi) - (package! geiser-chibi :pin "5a6a5a580ea45cd4974df21629a8d50cbe3d6e99")) - (when (modulep! +chicken) - (package! geiser-chicken :pin "a480598b5908c95bc8d3178a48f13e9072a9235b")) - (when (modulep! +gambit) - (package! geiser-gambit :pin "381d74ca5059b44fe3d8b5daf42214019c6d1a88")) - (when (modulep! +gauche) - (package! geiser-gauche :pin "8ff743f6416f00751e24aef8b9791501a40f5421")) - (when (modulep! +guile) - (package! geiser-guile :pin "24ce15de235c105daf5ecfb818200dae1c9815ee") - (when (modulep! :checkers syntax) - (package! flycheck-guile - :recipe (:host github :repo "flatwhatson/flycheck-guile") - :pin "e23a4d7813179124fd98abf1c2f4190a72569bee"))) - (when (modulep! +kawa) - (package! geiser-kawa :pin "5896b19642923f74f718eb68d447560b2d26d797")) - (when (modulep! +mit) - (package! geiser-mit :pin "4e90e9ae815e89f3540fb9644e6016c663ef5765")) - (when (modulep! +racket) - (package! geiser-racket :pin "22e56ce80389544d3872cf4beb4008fb514b2218"))) diff --git a/.config/emacs/modules/lang/sh/README.org b/.config/emacs/modules/lang/sh/README.org @@ -1,72 +0,0 @@ -#+title: :lang sh -#+subtitle: She sells {ba,z,fi}sh shells on the C xor -#+created: September 28, 2015 -#+since: 0.7 - -* Description :unfold: -This module adds support for shell scripting languages (including Powershell and -Fish script) to Doom Emacs. - -- Code completion ([[doom-package:company-shell]]) -- Syntax Checking ([[doom-package:flycheck]]) - -** Maintainers -- [[doom-user:][@hlissner]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +fish :: - Add syntax highlighting for fish script files. -- +lsp :: - Enable LSP support for ~sh-mode~. Requires [[doom-module::tools lsp]] and a langserver - (supports bash-language-server). -- +powershell :: - Add syntax highlighting for Powershell script files (=.ps1= and =.psm1=). -- +tree-sitter :: - Leverages tree-sitter for better syntax highlighting and structural text - editing. Requires [[doom-module::tools tree-sitter]]. - -** Packages -- [[doom-package:company-shell]] if [[doom-module::completion company]] -- [[doom-package:fish-mode]] if [[doom-module:+fish]] -- [[doom-package:powershell-mode]] if [[doom-module:+powershell]] - -** Hacks -- Interpolated variables are fontified. - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module has several optional dependencies: - -- [[https://github.com/koalaman/shellcheck][shellcheck]]: Enables advanced shell script linting. -- [[https://github.com/mads-hartmann/bash-language-server][bash-language-server]]: Enables LSP support (with [[doom-module:+lsp]] flag). -- With the [[doom-module::tools debugger]] module - - [[http://bashdb.sourceforge.net/][bashdb]]: Enables debugging for bash scripts - - [[https://github.com/rocky/zshdb][zshdb]]: Enables debugging for zsh scripts - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/sh/autoload.el b/.config/emacs/modules/lang/sh/autoload.el @@ -1,53 +0,0 @@ -;;; lang/sh/autoload.el -*- lexical-binding: t; -*- - -;;;###autoload -(defun +sh--match-variables-in-quotes (limit) - "Search for variables in double-quoted strings bounded by LIMIT." - (with-syntax-table sh-mode-syntax-table - (let (res) - (while - (and (setq res - (re-search-forward - "[^\\]\\(\\$\\)\\({.+?}\\|\\<[a-zA-Z0-9_]+\\|[@*#!]\\)" - limit t)) - (not (eq (nth 3 (syntax-ppss)) ?\")))) - res))) - -;;;###autoload -(defun +sh--match-command-subst-in-quotes (limit) - "Search for variables in double-quoted strings bounded by LIMIT." - (with-syntax-table sh-mode-syntax-table - (let (res) - (while - (and (setq res - (re-search-forward "[^\\]\\(\\$(.+?)\\|`.+?`\\)" - limit t)) - (not (eq (nth 3 (syntax-ppss)) ?\")))) - res))) - -(defvar sh-shell-file) -;;;###autoload -(defun +sh/open-repl () - "Open a shell REPL." - (interactive) - (require 'sh-script) - (let* ((dest-sh (symbol-name sh-shell)) - (sh-shell-file dest-sh)) - (sh-shell-process t) - (with-current-buffer "*shell*" - (rename-buffer (format "*shell [%s]*" dest-sh)) - (current-buffer)))) - -;;;###autoload -(defun +sh-lookup-documentation-handler () - "Look up documentation in `man' or `woman'." - (interactive) - (require 'man) - (let ((input (Man-default-man-entry))) - (if (executable-find "man") - (let* ((input (Man-translate-references input)) - (buffer (Man-getpage-in-background input))) - (when (buffer-live-p buffer) - (switch-to-buffer buffer))) - (woman input t) - (current-buffer)))) diff --git a/.config/emacs/modules/lang/sh/config.el b/.config/emacs/modules/lang/sh/config.el @@ -1,98 +0,0 @@ -;;; lang/sh/config.el -*- lexical-binding: t; -*- - -(defvar +sh-builtin-keywords - '("cat" "cd" "chmod" "chown" "cp" "curl" "date" "echo" "find" "git" "grep" - "kill" "less" "ln" "ls" "make" "mkdir" "mv" "pgrep" "pkill" "pwd" "rm" - "sleep" "sudo" "touch") - "A list of common shell commands to be fontified especially in `sh-mode'.") - - -;; -;;; Packages - -(use-package! sh-script ; built-in - :mode ("\\.bats\\'" . sh-mode) - :mode ("\\.\\(?:zunit\\|env\\)\\'" . sh-mode) - :mode ("/bspwmrc\\'" . sh-mode) - :config - (set-docsets! 'sh-mode "Bash") - (set-electric! 'sh-mode :words '("else" "elif" "fi" "done" "then" "do" "esac" ";;")) - (set-formatter! 'shfmt - '("shfmt" "-ci" - ("-i" "%d" (unless indent-tabs-mode tab-width)) - ("-ln" "%s" (pcase sh-shell (`bash "bash") (`mksh "mksh") (_ "posix"))))) - (set-repl-handler! 'sh-mode #'+sh/open-repl) - (set-lookup-handlers! 'sh-mode :documentation #'+sh-lookup-documentation-handler) - (set-ligatures! 'sh-mode - ;; Functional - :def "function" - ;; Types - :true "true" :false "false" - ;; Flow - :not "!" - :and "&&" :or "||" - :in "in" - :for "for" - :return "return" - ;; Other - :dot "." :dot "source") - - (when (modulep! +lsp) - (add-hook 'sh-mode-local-vars-hook #'lsp! 'append)) - - (when (modulep! +tree-sitter) - (add-hook 'sh-mode-local-vars-hook #'tree-sitter! 'append)) - - (setq sh-indent-after-continuation 'always) - - ;; [pedantry intensifies] - (setq-hook! 'sh-mode-hook mode-name "sh") - - ;; recognize function names with dashes in them - (add-to-list 'sh-imenu-generic-expression - '(sh (nil "^\\s-*function\\s-+\\([[:alpha:]_-][[:alnum:]_-]*\\)\\s-*\\(?:()\\)?" 1) - (nil "^\\s-*\\([[:alpha:]_-][[:alnum:]_-]*\\)\\s-*()" 1))) - - ;; `sh-set-shell' is chatty about setting up indentation rules - (advice-add #'sh-set-shell :around #'doom-shut-up-a) - - ;; 1. Fontifies variables in double quotes - ;; 2. Fontify command substitution in double quotes - ;; 3. Fontify built-in/common commands (see `+sh-builtin-keywords') - (add-hook! 'sh-mode-hook - (defun +sh-init-extra-fontification-h () - (font-lock-add-keywords - nil `((+sh--match-variables-in-quotes - (1 'font-lock-constant-face prepend) - (2 'font-lock-variable-name-face prepend)) - (+sh--match-command-subst-in-quotes - (1 'sh-quoted-exec prepend)) - (,(regexp-opt +sh-builtin-keywords 'symbols) - (0 'font-lock-type-face append)))))) - ;; 4. Fontify delimiters by depth - (add-hook 'sh-mode-hook #'rainbow-delimiters-mode) - - ;; autoclose backticks - (sp-local-pair 'sh-mode "`" "`" :unless '(sp-point-before-word-p sp-point-before-same-p))) - -(use-package! company-shell - :when (modulep! :completion company) - :unless (modulep! +lsp) - :after sh-script - :config - (set-company-backend! 'sh-mode '(company-shell company-files)) - (setq company-shell-delete-duplicates t - ;; whatis lookups are exceptionally slow on macOS (#5860) - company-shell-dont-fetch-meta IS-MAC)) - -(use-package! fish-mode - :when (modulep! +fish) - :defer t - :config (set-formatter! 'fish-mode #'fish_indent)) - -(use-package! powershell - :when (modulep! +powershell) - :defer t - :config - (when (modulep! +lsp) - (add-hook 'powershell-mode-local-vars-hook #'lsp! 'append))) diff --git a/.config/emacs/modules/lang/sh/doctor.el b/.config/emacs/modules/lang/sh/doctor.el @@ -1,13 +0,0 @@ -;;; lang/sh/doctor.el -*- lexical-binding: t; -*- - -(when (modulep! :checkers syntax) - (unless (executable-find "shellcheck") - (warn! "Couldn't find shellcheck. Shell script linting will not work"))) - -(when (modulep! :editor format) - (unless (executable-find "shfmt") - (warn! "Couldn't find shfmt. Code formatting will not work."))) - -(assert! (or (not (modulep! +tree-sitter)) - (modulep! :tools tree-sitter)) - "This module requires (:tools tree-sitter)") diff --git a/.config/emacs/modules/lang/sh/packages.el b/.config/emacs/modules/lang/sh/packages.el @@ -1,11 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/sh/packages.el - -(when (modulep! :completion company) - (package! company-shell :pin "5f959a63a6e66eb0cbdac3168cad523a62cc2ccd")) - -(when (modulep! +fish) - (package! fish-mode :pin "d04478c0aba018cb789d77d591bfe315cb25132a")) - -(when (modulep! +powershell) - (package! powershell :pin "f2da15857e430206e215a3c65289b4058ae3c976")) diff --git a/.config/emacs/modules/lang/sml/README.org b/.config/emacs/modules/lang/sml/README.org @@ -1,50 +0,0 @@ -#+title: :lang sml -#+subtitle: ... -#+created: Mar 30, 2020 -#+since: 21.12.0 - -* Description :unfold: -THis module adds [[https://smlfamily.github.io/][SML (Standard ML) programming language]] support to Doom Emacs. - -** Maintainers -*This module needs a maintainer.* [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:company-mlton]] if [[doom-module::completion company]] -- [[doom-package:sml-mode]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* TODO Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires =sml= and =MLton=. - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/sml/config.el b/.config/emacs/modules/lang/sml/config.el @@ -1,29 +0,0 @@ -;;; lang/sml/config.el -*- lexical-binding: t; -*- - -(use-package! sml-mode - :mode "\\.s\\(?:ml\\|ig\\)\\'" - :config - (set-repl-handler! 'sml-mode #'run-sml) - - ;; don't auto-close apostrophes (type 'a = foo) and backticks (`Foo) - (sp-with-modes 'sml-mode - (sp-local-pair "'" nil :actions nil) - (sp-local-pair "`" nil :actions nil)) - - (map! :map sml-mode-map - :i "RET" #'reindent-then-newline-and-indent - :i "S-SPC" #'sml-electric-space - :i "|" #'sml-electric-pipe - :localleader - :desc "Run SML" "'" #'run-sml - :prefix ("e" . "eval") - :desc "Run buffer" "b" #'sml-prog-proc-send-buffer - :desc "Run the paragraph" "f" #'sml-send-function - :desc "Run region" "r" #'sml-prog-proc-send-region)) - - -(use-package! company-mlton - :when (modulep! :completion company) - :hook (sml-mode . company-mlton-init) - :config - (set-company-backend! 'sml-mode company-mlton-grouped-backend)) diff --git a/.config/emacs/modules/lang/sml/packages.el b/.config/emacs/modules/lang/sml/packages.el @@ -1,8 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/sml/packages.el - -(package! sml-mode :pin "5426ff47382441cf079a75ab7fa0a1c90730bf09") -(when (modulep! :completion company) - (package! company-mlton - :recipe (:host github :repo "MatthewFluet/company-mlton" :files ("*.el" "*.basis")) - :pin "9b09d209b4767a2af24784fb5321390ed1d445bf")) diff --git a/.config/emacs/modules/lang/solidity/README.org b/.config/emacs/modules/lang/solidity/README.org @@ -1,77 +0,0 @@ -#+title: :lang solidity -#+subtitle: Do you need a blockchain? No. -#+created: May 19, 2018 -#+since: 21.12.0 (#599) - -* Description :unfold: -This module adds [[https://github.com/ethereum/solidity][Solidity]] support to Doom Emacs. - -- Syntax-checking ([[doom-package:flycheck]]) -- Code completion ([[doom-package:company-solidity]]) -- Gas estimation (~C-c C-g~) - -** Maintainers -*This module needs a maintainer.* [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:company-solidity]] if [[doom-module::completion company]] -- [[doom-package:solidity-flycheck]] if [[doom-module::checkers syntax]] -- [[doom-package:solidity-mode]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires one or both linters for syntax checking: -- [[https://github.com/ethereum/solc-js][Solc]] -- [[http://solium.readthedocs.io/en/latest/user-guide.html#installation][Solium]] - -If both are enabled *Solc* is run first, then *Solium* if *Solc* catches no -errors. - -** Solc -#+begin_src sh -npm install -g solc -#+end_src - -** Solium -#+begin_src sh -npm install -g solium -#+end_src - -By default *solium* looks for =.soliumrc.json= in the project directory, but you -can set it to your own =.soliumrc.json= with: -#+begin_src emacs-lisp -;; in $DOOMDIR/config.el -(setq flycheck-solidity-solium-soliumrcfile "~/.soliumrc.json") -#+end_src - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/solidity/config.el b/.config/emacs/modules/lang/solidity/config.el @@ -1,22 +0,0 @@ -;;; lang/solidity/config.el -*- lexical-binding: t; -*- - -;; -;;; Packages - -(after! solidity-mode - (setq solidity-comment-style 'slash) - (set-docsets! 'solidity-mode "Solidity") - (set-company-backend! 'solidity-mode 'company-solidity) - - (use-package! solidity-flycheck ; included with solidity-mode - :when (modulep! :checkers syntax) - :config - (setq flycheck-solidity-solc-addstd-contracts t) - (when (funcall flycheck-executable-find solidity-solc-path) - (add-to-list 'flycheck-checkers 'solidity-checker nil #'eq)) - (when (funcall flycheck-executable-find solidity-solium-path) - (add-to-list 'flycheck-checkers 'solium-checker nil #'eq))) - - (use-package! company-solidity - :when (modulep! :completion company) - :config (delq! 'company-solidity company-backends))) diff --git a/.config/emacs/modules/lang/solidity/doctor.el b/.config/emacs/modules/lang/solidity/doctor.el @@ -1,8 +0,0 @@ -;; -*- lexical-binding: t; no-byte-compile: t; -*- -;;; lang/solidity/doctor.el - -(when (require 'solidity-common nil t) - (unless (executable-find solidity-solc-path) - (warn! "Solc isn't installed.")) - (unless (executable-find solidity-solium-path) - (warn! "Solium isn't installed."))) diff --git a/.config/emacs/modules/lang/solidity/packages.el b/.config/emacs/modules/lang/solidity/packages.el @@ -1,8 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/solidity/packages.el - -(package! solidity-mode :pin "ddb4a901c33bd29ba2eefff3b7f7461849c6e833") -(when (modulep! :completion company) - (package! company-solidity)) -(when (modulep! :checkers syntax) - (package! solidity-flycheck)) diff --git a/.config/emacs/modules/lang/swift/README.org b/.config/emacs/modules/lang/swift/README.org @@ -1,61 +0,0 @@ -#+title: :lang swift -#+subtitle: We asked for emoji variables? -#+created: June 15, 2015 -#+since: 0.7 - -* Description :unfold: -This module adds support for the [[https://developer.apple.com/swift/][Swift programming language]] to Doom Emacs. - -** Maintainers -*This module needs a maintainer.* [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +lsp :: - Enable LSP support for ~swift-mode~. Requires [[doom-module::tools lsp]] and a langserver - (supports sourcekit). -- +tree-sitter :: - Leverages tree-sitter for better syntax highlighting and structural text - editing. Requires [[doom-module::tools tree-sitter]]. - -** Packages -- [[doom-package:swift-mode]] -- if [[doom-module:+lsp]] - - [[doom-package:lsp-sourcekit]] -- else - - [[doom-package:company-sourcekit]] if [[doom-module::completion company]] - - [[doom-package:flycheck-sourcekit]] if [[doom-module::checkers syntax]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* TODO Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -#+begin_quote -🔨 /This module's prerequisites are not documented./ [[doom-contrib-module:][Document them?]] -#+end_quote - -* TODO Usage -#+begin_quote -🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote -🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote -🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/swift/config.el b/.config/emacs/modules/lang/swift/config.el @@ -1,36 +0,0 @@ -;;; lang/swift/config.el -*- lexical-binding: t; -*- - -(after! swift-mode - (set-repl-handler! 'swift-mode #'run-swift) - - (when (modulep! +tree-sitter) - (add-hook 'swift-mode-local-vars-hook #'tree-sitter! 'append))) - - -(use-package! flycheck-swift - :when (modulep! :checkers syntax) - :unless (modulep! +lsp) - :after swift-mode - :config (flycheck-swift-setup)) - - -(use-package! company-sourcekit - :when (modulep! :completion company) - :unless (modulep! +lsp) - :after swift-mode - :config - (set-company-backend! 'swift-mode '(company-sourcekit company-yasnippet))) - - -(use-package! lsp-sourcekit - :when (modulep! +lsp) - :after swift-mode - :init (add-hook 'swift-mode-local-vars-hook #'lsp! 'append) - :config - (setq lsp-sourcekit-executable - (cl-find-if #'executable-find - (list lsp-sourcekit-executable ; 'sourcekit-lsp' by default - "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/sourcekit-lsp" - "sourcekit" - "/Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin/sourcekit-lsp" - "/Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin/sourcekit")))) diff --git a/.config/emacs/modules/lang/swift/doctor.el b/.config/emacs/modules/lang/swift/doctor.el @@ -1,5 +0,0 @@ -;;; lang/swift/doctor.el -*- lexical-binding: t; -*- - -(assert! (or (not (modulep! +tree-sitter)) - (modulep! :tools tree-sitter)) - "This module requires (:tools tree-sitter)") diff --git a/.config/emacs/modules/lang/swift/packages.el b/.config/emacs/modules/lang/swift/packages.el @@ -1,11 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/swift/packages.el - -(package! swift-mode :pin "1244ee48de1895d33f55fed81fc90acda0c901f1") - -(if (modulep! +lsp) - (package! lsp-sourcekit :pin "468c641e35877e4e843f6b7c52a35937de562995") - (when (modulep! :completion company) - (package! company-sourcekit :pin "a1860ad4dd3a542acd2fa0dfac2a388cbdf4af0c")) - (when (modulep! :checkers syntax) - (package! flycheck-swift :pin "4c5ad401252400a78da395fd56a71e67ff8c2761"))) diff --git a/.config/emacs/modules/lang/terra/README.org b/.config/emacs/modules/lang/terra/README.org @@ -1,52 +0,0 @@ -#+title: :lang terra -#+subtitle: Earth and Moon in alignment for performance. -#+created: March 25, 2019 -#+since: 21.12.0 (#1283) - -* TODO Description :unfold: -/(No description yet)/ - -** Maintainers -*This module needs a maintainer.* [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:company-lua]] if [[doom-module::completion company]] -- [[doom-package:terra-mode]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* TODO Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -#+begin_quote - 🔨 /No installation steps have been documented./ [[doom-contrib-module:][Document them?]] -#+end_quote - -* TODO Usage -#+begin_quote -🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote -🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote -🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/terra/autoload.el b/.config/emacs/modules/lang/terra/autoload.el @@ -1,8 +0,0 @@ -;;; lang/terra/autoload.el -*- lexical-binding: t; -*- - -;;;###autoload -(defun +terra/open-repl () - "Open Terra REPL." - (interactive) - (terra-start-process "terra" "terra") - (pop-to-buffer terra-process-buffer)) diff --git a/.config/emacs/modules/lang/terra/config.el b/.config/emacs/modules/lang/terra/config.el @@ -1,11 +0,0 @@ -;;; lang/lua/config.el -*- lexical-binding: t; -*- - -;; -;;; Major modes - -(after! terra-mode - (set-lookup-handlers! 'terra-mode - :documentation #'terra-search-documentation) - (set-electric! 'terra-mode :words '("else" "end")) - (set-repl-handler! 'terra-mode #'+terra/open-repl) - (set-company-backend! 'terra-mode '(company-lua company-yasnippet))) diff --git a/.config/emacs/modules/lang/terra/packages.el b/.config/emacs/modules/lang/terra/packages.el @@ -1,9 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/lua/packages.el - -(package! terra-mode - :recipe (:host github :repo "StanfordLegion/terra-mode") - :pin "ceef8cae5bddc70ee3d5d4d00aa323e3cd6a11be") - -(when (modulep! :completion company) - (package! company-lua :pin "29f6819de4d691e5fd0b62893a9f4fbc1c6fcb52")) diff --git a/.config/emacs/modules/lang/web/+css.el b/.config/emacs/modules/lang/web/+css.el @@ -1,82 +0,0 @@ -;;; lang/web/+css.el -*- lexical-binding: t; -*- - -(defvar +web-continue-block-comments t - "If non-nil, newlines in block comments are continued with a leading *. - -This also indirectly means the asterisks in the opening /* and closing */ will -be aligned. - -If set to `nil', disable all the above behaviors.") - -(after! projectile - (pushnew! projectile-other-file-alist - '("css" "scss" "sass" "less" "styl") - '("scss" "css") - '("sass" "css") - '("less" "css") - '("styl" "css"))) - - -;; -;;; Major modes - -(setq-hook! 'css-mode-hook - ;; Correctly continue /* and // comments on newline-and-indent - comment-line-break-function #'+css/comment-indent-new-line - ;; Fix `fill-paragraph' not conjoining line comments in CSS modes correctly. - adaptive-fill-function #'+css-adaptive-fill-fn - ;; Fix filled lines not being auto-prefixed with a * when needed. - adaptive-fill-first-line-regexp "\\'[ \t]*\\(?:\\* *\\)?\\'") - -(after! (:any css-mode sass-mode) - (set-docsets! '(css-mode scss-mode sass-mode) - "CSS" "HTML" "Bourbon" "Compass" - ["Sass" (memq major-mode '(scss-mode sass-mode))])) - -(add-hook! '(css-mode-hook sass-mode-hook stylus-mode-hook) - #'rainbow-mode) - -;; built-in. Contains both css-mode & scss-mode -(after! css-mode - ;; css-mode hooks apply to scss and less-css modes - (map! :localleader - :map scss-mode-map - "b" #'+css/scss-build - :map (css-mode-map scss-mode-map less-css-mode-map) - "rb" #'+css/toggle-inline-or-block) - - (use-package! counsel-css - :when (modulep! :completion ivy) - :hook (css-mode . counsel-css-imenu-setup) - :init - (map! :map (css-mode-map scss-mode-map less-css-mode-map) - :localleader ";" #'counsel-css)) - - (use-package! helm-css-scss - :when (modulep! :completion helm) - :defer t - :init - (map! :map (css-mode-map scss-mode-map less-css-mode-map) - :localleader ";" #'helm-css-scss) - :config - (setq helm-css-scss-split-direction #'split-window-vertically - helm-css-scss-split-with-multiple-windows t))) - - -(after! sass-mode - (set-company-backend! 'sass-mode 'company-css) - (map! :map sass-mode-map :localleader "b" #'+css/sass-build)) - - -;; -;;; Tools - -(when (modulep! +lsp) - (add-hook! '(css-mode-local-vars-hook - scss-mode-local-vars-hook - sass-mode-local-vars-hook - less-css-mode-local-vars-hook) - :append #'lsp!)) - -(when (modulep! +tree-sitter) - (add-hook 'css-mode-local-vars-hook #'tree-sitter! 'append)) diff --git a/.config/emacs/modules/lang/web/+html.el b/.config/emacs/modules/lang/web/+html.el @@ -1,174 +0,0 @@ -;;; lang/web/+html.el -*- lexical-binding: t; -*- - -(use-package! web-mode - :mode "\\.[px]?html?\\'" - :mode "\\.\\(?:tpl\\|blade\\)\\(?:\\.php\\)?\\'" - :mode "\\.erb\\'" - :mode "\\.[lh]?eex\\'" - :mode "\\.jsp\\'" - :mode "\\.as[cp]x\\'" - :mode "\\.ejs\\'" - :mode "\\.hbs\\'" - :mode "\\.mustache\\'" - :mode "\\.svelte\\'" - :mode "\\.twig\\'" - :mode "\\.jinja2?\\'" - :mode "\\.eco\\'" - :mode "wp-content/themes/.+/.+\\.php\\'" - :mode "templates/.+\\.php\\'" - :init - ;; If the user has installed `vue-mode' then, by appending this to - ;; `auto-mode-alist' rather than prepending it, its autoload will have - ;; priority over this one. - (add-to-list 'auto-mode-alist '("\\.vue\\'" . web-mode) 'append) - :mode "\\.vue\\'" - :config - (set-docsets! 'web-mode "HTML" "CSS" "Twig" "WordPress") - - ;; tidy is already defined by the format-all package. We redefine it to add - ;; more sensible arguments to the tidy command. - (set-formatter! 'html-tidy - '("tidy" "-q" "-indent" - "--tidy-mark" "no" - "--drop-empty-elements" "no" - ("--show-body-only" "%s" (if +format-region-p "true" "auto")) - ("--indent-spaces" "%d" tab-width) - ("--indent-with-tabs" "%s" (if indent-tabs-mode "yes" "no")) - ("-xml" (memq major-mode '(nxml-mode xml-mode)))) - :ok-statuses '(0 1)) - - (setq web-mode-enable-html-entities-fontification t - web-mode-auto-close-style 1) - - (after! smartparens - (defun +web-is-auto-close-style-3 (_id action _context) - (and (eq action 'insert) - (eq web-mode-auto-close-style 3))) - (sp-local-pair 'web-mode "<" ">" :unless '(:add +web-is-auto-close-style-3)) - - ;; let smartparens handle these - (setq web-mode-enable-auto-quoting nil - web-mode-enable-auto-pairing t) - - ;; 1. Remove web-mode auto pairs whose end pair starts with a latter - ;; (truncated autopairs like <?p and hp ?>). Smartparens handles these - ;; better. - ;; 2. Strips out extra closing pairs to prevent redundant characters - ;; inserted by smartparens. - (dolist (alist web-mode-engines-auto-pairs) - (setcdr alist - (cl-loop for pair in (cdr alist) - unless (string-match-p "^[a-z-]" (cdr pair)) - collect (cons (car pair) - (string-trim-right (cdr pair) - "\\(?:>\\|]\\|}\\)+\\'"))))) - (delq! nil web-mode-engines-auto-pairs)) - - (add-to-list 'web-mode-engines-alist '("elixir" . "\\.eex\\'")) - (add-to-list 'web-mode-engines-alist '("phoenix" . "\\.[lh]eex\\'")) - - ;; Use // instead of /* as the default comment delimited in JS - (setf (alist-get "javascript" web-mode-comment-formats nil nil #'equal) - "//") - - (add-hook! 'web-mode-hook - (defun +web--fix-js-comments-h () - "Fix comment handling in `web-mode' for JavaScript." - (when (member web-mode-content-type '("javascript" "jsx")) - ;; For some reason the default is to insert HTML comments even - ;; in JavaScript. - (setq-local comment-start "//") - (setq-local comment-end "") - ;; Needed since otherwise the default value generated by - ;; `comment-normalize-vars' will key off the syntax and think - ;; that a single "/" starts a comment, which completely borks - ;; auto-fill. - (setq-local comment-start-skip "// *")))) - - (map! :map web-mode-map - (:localleader - :desc "Rehighlight buffer" "h" #'web-mode-reload - :desc "Indent buffer" "i" #'web-mode-buffer-indent - (:prefix ("a" . "attribute") - "b" #'web-mode-attribute-beginning - "e" #'web-mode-attribute-end - "i" #'web-mode-attribute-insert - "n" #'web-mode-attribute-next - "s" #'web-mode-attribute-select - "k" #'web-mode-attribute-kill - "p" #'web-mode-attribute-previous - "t" #'web-mode-attribute-transpose) - (:prefix ("b" . "block") - "b" #'web-mode-block-beginning - "c" #'web-mode-block-close - "e" #'web-mode-block-end - "k" #'web-mode-block-kill - "n" #'web-mode-block-next - "p" #'web-mode-block-previous - "s" #'web-mode-block-select) - (:prefix ("d" . "dom") - "a" #'web-mode-dom-apostrophes-replace - "d" #'web-mode-dom-errors-show - "e" #'web-mode-dom-entities-encode - "n" #'web-mode-dom-normalize - "q" #'web-mode-dom-quotes-replace - "t" #'web-mode-dom-traverse - "x" #'web-mode-dom-xpath) - (:prefix ("e" . "element") - "/" #'web-mode-element-close - "a" #'web-mode-element-content-select - "b" #'web-mode-element-beginning - "c" #'web-mode-element-clone - "d" #'web-mode-element-child - "e" #'web-mode-element-end - "f" #'web-mode-element-children-fold-or-unfold - "i" #'web-mode-element-insert - "k" #'web-mode-element-kill - "m" #'web-mode-element-mute-blanks - "n" #'web-mode-element-next - "p" #'web-mode-element-previous - "r" #'web-mode-element-rename - "s" #'web-mode-element-select - "t" #'web-mode-element-transpose - "u" #'web-mode-element-parent - "v" #'web-mode-element-vanish - "w" #'web-mode-element-wrap) - (:prefix ("t" . "tag") - "a" #'web-mode-tag-attributes-sort - "b" #'web-mode-tag-beginning - "e" #'web-mode-tag-end - "m" #'web-mode-tag-match - "n" #'web-mode-tag-next - "p" #'web-mode-tag-previous - "s" #'web-mode-tag-select)) - - :g "M-/" #'web-mode-comment-or-uncomment - :i "SPC" #'self-insert-command - :n "za" #'web-mode-fold-or-unfold - :nv "]a" #'web-mode-attribute-next - :nv "[a" #'web-mode-attribute-previous - :nv "]t" #'web-mode-tag-next - :nv "[t" #'web-mode-tag-previous - :nv "]T" #'web-mode-element-child - :nv "[T" #'web-mode-element-parent)) - - -;; -(after! pug-mode - (set-company-backend! 'pug-mode 'company-web-jade)) -(after! web-mode - (set-company-backend! 'web-mode 'company-css 'company-web-html)) -(after! slim-mode - (set-company-backend! 'slim-mode 'company-web-slim)) - - -(when (modulep! +lsp) - (add-hook! '(html-mode-local-vars-hook - web-mode-local-vars-hook - nxml-mode-local-vars-hook) - :append #'lsp!)) - -(when (modulep! +tree-sitter) - (add-hook! '(html-mode-local-vars-hook - mhtml-mode-local-vars-hook) - :append #'tree-sitter!)) diff --git a/.config/emacs/modules/lang/web/README.org b/.config/emacs/modules/lang/web/README.org @@ -1,74 +0,0 @@ -#+title: :lang web -#+subtitle: The tubes -#+created: June 15, 2015 -#+since: 0.7 - -* Description :unfold: -This module adds support for various web languages, including HTML5, CSS, -SASS/SCSS, Pug/Jade/Slim, and HAML, as well as various web frameworks, like -ReactJS, Wordpress, Jekyll, Phaser, AngularJS, Djano, and more. - -** Maintainers -- @hlissner - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +lsp :: - Enable LSP support for ~web-mode~ and ~css-mode~. Requires [[doom-module::tools lsp]] and a - langserver. -- +tree-sitter :: - Leverages tree-sitter for better syntax highlighting and structural text - editing. Requires [[doom-module::tools tree-sitter]]. - -** Packages -- [[doom-package:company-web]] if [[doom-module::completion company]] -- [[doom-package:counsel-css]] if [[doom-module::completion ivy]] -- [[doom-package:emmet-mode]] -- [[doom-package:haml-mode]] -- [[doom-package:helm-css-scss]] if [[doom-module::completion helm]] -- [[doom-package:less-css-mode]] -- [[doom-package:pug-mode]] -- [[doom-package:rainbow-mode]] -- [[doom-package:sass-mode]] -- [[doom-package:slim-mode]] -- [[doom-package:stylus-mode]] -- [[doom-package:sws-mode]] -- [[doom-package:web-mode]] - -** TODO Hacks -#+begin_quote - 🔨 This module's hacks haven't been documented yet. [[doom-contrib-module:][Document them?]] -#+end_quote - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* TODO Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -#+begin_quote - 🔨 /No installation steps have been documented./ [[doom-contrib-module:][Document them?]] -#+end_quote - -* TODO Usage -#+begin_quote -🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote -🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote -🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/web/autoload/css.el b/.config/emacs/modules/lang/web/autoload/css.el @@ -1,105 +0,0 @@ -;;; lang/web/autoload/css.el -*- lexical-binding: t; -*- - -;; ;;;###autoload -;; TODO (defun +css/scss-build ()) - -;; ;;;###autoload -;; TODO (defun +css/sass-build ()) - -(defun +css--toggle-inline-or-block (beg end) - (skip-chars-forward " \t") - (let ((orig (point-marker))) - (goto-char beg) - (if (= (line-number-at-pos beg) (line-number-at-pos end)) - (progn - (forward-char) - (insert "\n") - (while (re-search-forward ";\\s-+" end t) - (replace-match ";\n" nil t)) - (indent-region beg end)) - (save-excursion - (while (re-search-forward "\n+" end t) - (replace-match " " nil t))) - (while (re-search-forward "\\([{;]\\) +" end t) - (replace-match (concat (match-string 1) " ") nil t))) - (if orig (goto-char orig)) - (skip-chars-forward " \t"))) - -;;;###autoload -(defun +css/toggle-inline-or-block () - "Toggles between a bracketed block and inline block." - (interactive) - (let ((inhibit-modification-hooks t)) - (cl-destructuring-bind (&key beg end op cl &allow-other-keys) - (save-excursion - (when (and (eq (char-after) ?\{) - (not (eq (char-before) ?\{))) - (forward-char)) - (sp-get-sexp)) - (when (or (not (and beg end op cl)) - (string-empty-p op) (string-empty-p cl)) - (user-error "No block found %s" (list beg end op cl))) - (unless (string= op "{") - (user-error "Incorrect block found")) - (+css--toggle-inline-or-block beg end)))) - -;;;###autoload -(defun +css/comment-indent-new-line (&optional _) - "Continues the comment in an indented new line. - -Meant for `comment-line-break-function' in `css-mode' and `scss-mode'." - (interactive) - (cond ((or (not (doom-point-in-comment-p)) - (and comment-use-syntax - (not (save-excursion (comment-beginning))))) - (let (comment-line-break-function) - (newline-and-indent))) - - ((save-match-data - (let ((at-end (looking-at-p ".+\\*/")) - (indent-char (if indent-tabs-mode ?\t ?\s)) - (post-indent (save-excursion - (move-to-column (1+ (current-indentation))) - (skip-chars-forward " \t" (line-end-position)))) - (pre-indent (current-indentation)) - opener) - (save-excursion - (if comment-use-syntax - (goto-char (comment-beginning)) - (goto-char (line-beginning-position)) - (when (re-search-forward comment-start-skip (line-end-position) t) - (goto-char (or (match-end 1) - (match-beginning 0))))) - (buffer-substring-no-properties (point) (line-end-position)) - (when (looking-at "\\(//\\|/?\\*\\**/?\\)\\(?:[^/]\\)") - (list (match-string-no-properties 1) - (- (match-beginning 1) (line-beginning-position)))) - (if (looking-at "\\(//\\|/?\\*\\**/?\\)\\(?:[^/]\\)") - (setq opener (match-string-no-properties 1) - pre-indent (- (match-beginning 1) (line-beginning-position))) - (setq opener "" - pre-indent 0))) - (insert-and-inherit - "\n" (make-string pre-indent indent-char) - (if (string-prefix-p "/*" opener) - (if (or (eq +web-continue-block-comments t) - (string= "/**" opener)) - " *" - "") - opener) - (make-string post-indent indent-char)) - (when at-end - (save-excursion - (just-one-space) - (insert "\n" (make-string pre-indent indent-char))))))))) - -;;;###autoload -(defun +css-adaptive-fill-fn () - "An `adaptive-fill-function' that conjoins SCSS line comments correctly." - (when (looking-at "[ \t]*/[/*][ \t]*") - (let ((str (match-string 0))) - (when (string-match "/[/*]" str) - (replace-match (if (string= (match-string 0 str) "/*") - " *" - "//") - t t str))))) diff --git a/.config/emacs/modules/lang/web/autoload/evil.el b/.config/emacs/modules/lang/web/autoload/evil.el @@ -1,26 +0,0 @@ -;;; lang/html/autoload/evil.el -*- lexical-binding: t; -*- -;;;###if (modulep! :editor evil) - -;;;###autoload (autoload '+web:encode-html-entities "lang/web/autoload/evil" nil t) -(evil-define-operator +web:encode-html-entities (beg end &optional bang input) - "Encodes HTML entities in INPUT or the selected region." - (interactive "<r><!><a>") - (cond (input - (let ((result (+web-encode-entities input))) - (if bang - (kill-new result) - (insert result)))) - ((and beg end) - (+web/encode-entities-region beg end)))) - -;;;###autoload (autoload '+web:decode-html-entities "lang/web/autoload/evil" nil t) -(evil-define-operator +web:decode-html-entities (beg end &optional bang input) - "Decodes HTML entities in INPUT or the selected region." - (interactive "<r><!><a>") - (cond (input - (let ((result (+web-decode-entities input))) - (if bang - (kill-new result) - (insert result)))) - ((and beg end) - (+web/decode-entities-region beg end)))) diff --git a/.config/emacs/modules/lang/web/autoload/html.el b/.config/emacs/modules/lang/web/autoload/html.el @@ -1,135 +0,0 @@ -;;; lang/web/autoload/html.el -*- lexical-binding: t; -*- - -(defvar +web-entities-list - [["&amp;" "&"] ["&nbsp;" " "] ["&ensp;" " "] ["&emsp;" " "] ["&thinsp;" " "] - ["&lt;" "<"] ["&gt;" ">"] - ["&rlm;" "‏"] ["&lrm;" "‎"] ["&zwj;" "‍"] ["&zwnj;" "‌"] - ["&iexcl;" "¡"] ["&cent;" "¢"] ["&pound;" "£"] ["&curren;" "¤"] ["&yen;" "¥"] - ["&brvbar;" "¦"] ["&sect;" "§"] ["&uml;" "¨"] ["&copy;" "©"] ["&ordf;" "ª"] - ["&laquo;" "«"] ["&not;" "¬"] ["&shy;" "­"] ["&reg;" "®"] ["&macr;" "¯"] - ["&deg;" "°"] ["&plusmn;" "±"] ["&sup2;" "²"] ["&sup3;" "³"] ["&acute;" "´"] - ["&micro;" "µ"] ["&para;" "¶"] ["&middot;" "·"] ["&cedil;" "¸"] ["&sup1;" "¹"] - ["&ordm;" "º"] ["&raquo;" "»"] ["&frac14;" "¼"] ["&frac12;" "½"] - ["&frac34;" "¾"] ["&iquest;" "¿"] ["&Agrave;" "À"] ["&Aacute;" "Á"] - ["&Acirc;" "Â"] ["&Atilde;" "Ã"] ["&Auml;" "Ä"] ["&Aring;" "Å"] ["&AElig;" "Æ"] - ["&Ccedil;" "Ç"] ["&Egrave;" "È"] ["&Eacute;" "É"] ["&Ecirc;" "Ê"] - ["&Euml;" "Ë"] ["&Igrave;" "Ì"] ["&Iacute;" "Í"] ["&Icirc;" "Î"] ["&Iuml;" "Ï"] - ["&ETH;" "Ð"] ["&Ntilde;" "Ñ"] ["&Ograve;" "Ò"] ["&Oacute;" "Ó"] - ["&Ocirc;" "Ô"] ["&Otilde;" "Õ"] ["&Ouml;" "Ö"] ["&times;" "×"] ["&Oslash;" "Ø"] - ["&Ugrave;" "Ù"] ["&Uacute;" "Ú"] ["&Ucirc;" "Û"] ["&Uuml;" "Ü"] - ["&Yacute;" "Ý"] ["&THORN;" "Þ"] ["&szlig;" "ß"] ["&agrave;" "à"] ["&aacute;" "á"] - ["&acirc;" "â"] ["&atilde;" "ã"] ["&auml;" "ä"] ["&aring;" "å"] - ["&aelig;" "æ"] ["&ccedil;" "ç"] ["&egrave;" "è"] ["&eacute;" "é"] ["&ecirc;" "ê"] - ["&euml;" "ë"] ["&igrave;" "ì"] ["&iacute;" "í"] ["&icirc;" "î"] - ["&iuml;" "ï"] ["&eth;" "ð"] ["&ntilde;" "ñ"] ["&ograve;" "ò"] ["&oacute;" "ó"] - ["&ocirc;" "ô"] ["&otilde;" "õ"] ["&ouml;" "ö"] ["&divide;" "÷"] ["&oslash;" "ø"] - ["&ugrave;" "ù"] ["&uacute;" "ú"] ["&ucirc;" "û"] ["&uuml;" "ü"] ["&yacute;" "ý"] - ["&thorn;" "þ"] ["&yuml;" "ÿ"] ["&fnof;" "ƒ"] ["&Alpha;" "Α"] ["&Beta;" "Β"] - ["&Gamma;" "Γ"] ["&Delta;" "Δ"] ["&Epsilon;" "Ε"] ["&Zeta;" "Ζ"] ["&Eta;" "Η"] - ["&Theta;" "Θ"] ["&Iota;" "Ι"] ["&Kappa;" "Κ"] ["&Lambda;" "Λ"] ["&Mu;" "Μ"] - ["&Nu;" "Ν"] ["&Xi;" "Ξ"] ["&Omicron;" "Ο"] ["&Pi;" "Π"] ["&Rho;" "Ρ"] - ["&Sigma;" "Σ"] ["&Tau;" "Τ"] ["&Upsilon;" "Υ"] ["&Phi;" "Φ"] ["&Chi;" "Χ"] - ["&Psi;" "Ψ"] ["&Omega;" "Ω"] ["&alpha;" "α"] ["&beta;" "β"] ["&gamma;" "γ"] - ["&delta;" "δ"] ["&epsilon;" "ε"] ["&zeta;" "ζ"] ["&eta;" "η"] ["&theta;" "θ"] - ["&iota;" "ι"] ["&kappa;" "κ"] ["&lambda;" "λ"] ["&mu;" "μ"] ["&nu;" "ν"] - ["&xi;" "ξ"] ["&omicron;" "ο"] ["&pi;" "π"] ["&rho;" "ρ"] ["&sigmaf;" "ς"] - ["&sigma;" "σ"] ["&tau;" "τ"] ["&upsilon;" "υ"] ["&phi;" "φ"] ["&chi;" "χ"] - ["&psi;" "ψ"] ["&omega;" "ω"] ["&thetasym;" "ϑ"] ["&upsih;" "ϒ"] ["&piv;" "ϖ"] - ["&bull;" "•"] ["&hellip;" "…"] ["&prime;" "′"] ["&Prime;" "″"] ["&oline;" "‾"] - ["&frasl;" "⁄"] ["&weierp;" "℘"] ["&image;" "ℑ"] ["&real;" "ℜ"] ["&trade;" "™"] - ["&alefsym;" "ℵ"] ["&larr;" "←"] ["&uarr;" "↑"] ["&rarr;" "→"] ["&darr;" "↓"] - ["&harr;" "↔"] ["&crarr;" "↵"] ["&lArr;" "⇐"] ["&uArr;" "⇑"] ["&rArr;" "⇒"] - ["&dArr;" "⇓"] ["&hArr;" "⇔"] ["&forall;" "∀"] ["&part;" "∂"] ["&exist;" "∃"] - ["&empty;" "∅"] ["&nabla;" "∇"] ["&isin;" "∈"] ["&notin;" "∉"] ["&ni;" "∋"] - ["&prod;" "∏"] ["&sum;" "∑"] ["&minus;" "−"] ["&lowast;" "∗"] ["&radic;" "√"] - ["&prop;" "∝"] ["&infin;" "∞"] ["&ang;" "∠"] ["&and;" "∧"] ["&or;" "∨"] - ["&cap;" "∩"] ["&cup;" "∪"] ["&int;" "∫"] ["&there4;" "∴"] ["&sim;" "∼"] - ["&cong;" "≅"] ["&asymp;" "≈"] ["&ne;" "≠"] ["&equiv;" "≡"] ["&le;" "≤"] - ["&ge;" "≥"] ["&sub;" "⊂"] ["&sup;" "⊃"] ["&nsub;" "⊄"] ["&sube;" "⊆"] - ["&supe;" "⊇"] ["&oplus;" "⊕"] ["&otimes;" "⊗"] ["&perp;" "⊥"] ["&sdot;" "⋅"] - ["&lceil;" "⌈"] ["&rceil;" "⌉"] ["&lfloor;" "⌊"] ["&rfloor;" "⌋"] ["&lang;" "〈"] - ["&rang;" "〉"] ["&loz;" "◊"] ["&spades;" "♠"] ["&clubs;" "♣"] - ["&hearts;" "♥"] ["&diams;" "♦"] ["&quot;" "\""] ["&OElig;" "Œ"] ["&oelig;" "œ"] - ["&Scaron;" "Š"] ["&scaron;" "š"] ["&Yuml;" "Ÿ"] ["&circ;" "ˆ"] - ["&tilde;" "˜"] ["&ndash;" "–"] ["&mdash;" "—"] ["&lsquo;" "‘"] ["&rsquo;" "’"] - ["&sbquo;" "‚"] ["&ldquo;" "“"] ["&rdquo;" "”"] ["&bdquo;" "„"] - ["&dagger;" "†"] ["&Dagger;" "‡"] ["&permil;" "‰"] ["&lsaquo;" "‹"] ["&rsaquo;" "›"] - ["&euro;" "€"]] - "A list of sequence string pairs, representing an html entity and its decoded -character.") - -(defun +web--entities-string (text &optional decode-p) - "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>") - (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) - "HTML encode/decode the selected region. Based on Xah's replace HTML named entities -function @ http://ergoemacs.org/emacs/elisp_replace_html_entities_command.html" - (save-restriction - (narrow-to-region beg end) - (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))))) - +web-entities-list))) - -;;;###autoload -(defun +web-encode-entities (text) - "TODO" - (+web--entities-string text nil)) - -;;;###autoload -(defun +web-decode-entities (text) - "TODO" - (+web--entities-string text t)) - - -;; -;;; Commands - -;;;###autoload -(defun +web/encode-entities-region (beg end) - "Encode HTML entities in region." - (interactive "r") - (+web--entities-region beg end)) - -;;;###autoload -(defun +web/decode-entities-region (beg end) - "Decode HTML entities in region." - (interactive "r") - (+web--entities-region beg end t)) - -;;;###autoload -(defun +web/indent-or-yas-or-emmet-expand () - "Do-what-I-mean on TAB. - -Invokes `indent-for-tab-command' if at or before text bol, `yas-expand' if on a -snippet, or `emmet-expand-yas'/`emmet-expand-line', depending on whether -`yas-minor-mode' is enabled or not." - (interactive) - (call-interactively - (cond ((or (<= (current-column) (current-indentation)) - (not (eolp)) - (not (or (memq (char-after) (list ?\n ?\s ?\t)) - (eobp)))) - #'indent-for-tab-command) - ((modulep! :editor snippets) - (require 'yasnippet) - (if (yas--templates-for-key-at-point) - #'yas-expand - #'emmet-expand-yas)) - (#'emmet-expand-line)))) diff --git a/.config/emacs/modules/lang/web/config.el b/.config/emacs/modules/lang/web/config.el @@ -1,57 +0,0 @@ -;;; lang/web/config.el -*- lexical-binding: t; -*- - -(load! "+html") -(load! "+css") - - -(use-package! emmet-mode - :preface (defvar emmet-mode-keymap (make-sparse-keymap)) - :hook (css-mode web-mode html-mode haml-mode nxml-mode rjsx-mode reason-mode) - :config - (when (require 'yasnippet nil t) - (add-hook 'emmet-mode-hook #'yas-minor-mode-on)) - (setq emmet-move-cursor-between-quotes t) - (setq-hook! 'rjsx-mode-hook emmet-expand-jsx-className? t) - (map! :map emmet-mode-keymap - :v [tab] #'emmet-wrap-with-markup - [tab] #'+web/indent-or-yas-or-emmet-expand - "M-E" #'emmet-expand-line)) - - -;; -;;; Framework-based minor-modes - -(def-project-mode! +web-jekyll-mode - :modes '(web-mode js-mode coffee-mode css-mode haml-mode pug-mode) - :files (and (or "_config.yml" "_config.toml") - (or "_layouts/" "_posts/")) - :on-enter - (when (eq major-mode 'web-mode) - (web-mode-set-engine "django"))) - -(def-project-mode! +web-django-mode - :modes '(web-mode python-mode) - :files ("manage.py") - :on-enter - (when (derived-mode-p 'web-mode) - (web-mode-set-engine "django"))) - -(def-project-mode! +web-wordpress-mode - :modes '(php-mode web-mode css-mode haml-mode pug-mode) - :files (or "wp-config.php" "wp-config-sample.php")) - -(when (modulep! :lang javascript) - (def-project-mode! +web-angularjs-mode - :modes '(+javascript-npm-mode) - :when (+javascript-npm-dep-p '(angular @angular/core)) - :on-enter - (when (derived-mode-p 'web-mode) - (web-mode-set-engine "angular"))) - - (def-project-mode! +web-react-mode - :modes '(+javascript-npm-mode) - :when (+javascript-npm-dep-p 'react)) - - (def-project-mode! +web-phaser-mode - :modes '(+javascript-npm-mode) - :when (+javascript-npm-dep-p '(or phaser phaser-ce)))) diff --git a/.config/emacs/modules/lang/web/doctor.el b/.config/emacs/modules/lang/web/doctor.el @@ -1,18 +0,0 @@ -;;; lang/web/doctor.el -*- lexical-binding: t; -*- - -(assert! (or (not (modulep! +lsp)) - (modulep! :tools lsp)) - "This module requires (:tools lsp)") - -(assert! (or (not (modulep! +tree-sitter)) - (modulep! :tools tree-sitter)) - "This module requires (:tools tree-sitter)") - -(unless (executable-find "js-beautify") - (warn! "Couldn't find js-beautify. Code formatting in JS/CSS/HTML modes will not work.")) - -(unless (executable-find "stylelint") - (warn! "Couldn't find stylelint. Linting for CSS modes will not work.")) - -(unless (executable-find "tidy") - (warn! "Couldn't find tidy. Code formatting in HTML modes will not work.")) diff --git a/.config/emacs/modules/lang/web/packages.el b/.config/emacs/modules/lang/web/packages.el @@ -1,24 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/web/packages.el - -;; +html.el -(package! emmet-mode :pin "63b6932603184956b5ea8919036d2b307b48d7fd") -(package! haml-mode :pin "bf5b6c11b1206759d2b28af48765e04882dd1fc4") -(package! pug-mode :pin "73f8c2f95eba695f701df20c8436f49abadebdc1") -(package! slim-mode :pin "3636d18ab1c8b316eea71c4732eb44743e2ded87") -(when (package! web-mode :pin "df97ab62c94826a84adbde060a4111ca91deda8e") - (when (modulep! :completion company) - (package! company-web :pin "863fb84b81ed283474e50330cd8d27b1ca0d74f1"))) - -;; +css.el -(package! css-mode :built-in t) -(package! less-css-mode :built-in t :pin "c7fa3d56d83206b28657f2e56439dc62280a2bf2") - -(package! sass-mode :pin "247a0d4b509f10b28e4687cd8763492bca03599b") -(package! stylus-mode :pin "1ad7c51f3c6a6ae64550d9510c5e4e8470014375") -(package! sws-mode :pin "1ad7c51f3c6a6ae64550d9510c5e4e8470014375") -(package! rainbow-mode :pin "8e96388fb4d616a9dde23e712bad0d9cd048fbf0") -(when (modulep! :completion ivy) - (package! counsel-css :pin "8e9c0515fc952452eee786d8ebb43d48ea86c9f8")) -(when (modulep! :completion helm) - (package! helm-css-scss :pin "48b996f73af1fef8d6e88a1c545d98f8c50b0cf3")) diff --git a/.config/emacs/modules/lang/web/test/test-web.el b/.config/emacs/modules/lang/web/test/test-web.el @@ -1,92 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/web/test/test-autoload-web.el - -(describe "lang/web" - (describe "+html" - (before-all (load! "../autoload/html.el")) - - (describe "encode entities" - (it "encodes strings with html entities" - (expect (+web-encode-entities "H€llø wørld") - :to-equal "H&euro;ll&oslash; w&oslash;rld")) - (it "does nothing when html entities are absent" - (expect (+web-encode-entities "Hello world") - :to-equal "Hello world"))) - - (describe "decode entities" - (it "decodes strings with html entities" - (expect (+web-decode-entities "H&euro;ll&oslash; w&oslash;rld") - :to-equal "H€llø wørld")) - (it "does nothing when html entities are absent" - (expect (+web-decode-entities "Hello world") - :to-equal "Hello world")))) - - (describe "+css" - :var (css-indent-offset) - (before-all - (load! "../autoload/css.el") - (require 'smartparens) - (smartparens-mode +1)) - (after-all - (smartparens-mode -1) - (unload-feature 'smartparens t)) - - (before-each - (setq css-indent-offset 2) - (set-buffer (get-buffer-create "css")) - (delay-mode-hooks (css-mode))) - (after-each - (kill-buffer (get-buffer "css"))) - - (describe "toggle-inline-or-block" - (after-each - (quiet! (+css/toggle-inline-or-block)) - (expect (string-trim (buffer-string)) :to-equal - (string-join - '("body {" - " color: red;" - " font-size: 2em;" - "}") - "\n"))) - - (describe "css-mode" - (it "converts inline statements into multiline blocks" - (insert!! "body { color: red{0}; font-size: 2em; }")) - (it "works when cursor is on closing brace" - (insert!! "body { color: red; font-size: 2em; {0}}")) - (it "works when cursor is on opening brace" - (insert!! "body {{0} color: red; font-size: 2em; }")) - (it "works when cursor is on same line" - (insert!! "{0}body { color: red; font-size: 2em; }")))) - - (describe "comment-indent-new-line" - (before-each - (delay-mode-hooks (scss-mode))) - - (it "continues commented lines on newline" - (insert!! "// test{0}\n" - "body { color: red; font-size: 2em; }") - (+css/comment-indent-new-line) - (expect (string-trim (buffer-string)) :to-equal - (string-join - '("// test" - "// " - "body { color: red; font-size: 2em; }") - "\n")) - (expect (eolp)) - (expect (line-number-at-pos) :to-be 2)) - (it "preserves indentation within continued comments" - (insert!! "// test{0}\n" - "body { color: red; font-size: 2em; }") - (+css/comment-indent-new-line) - (expect (string-trim (buffer-string)) :to-equal - (string-join - '("// test" - "// " - "body { color: red; font-size: 2em; }") - "\n")) - (expect (eolp)) - (expect (line-number-at-pos) :to-be 2))))) - - -;; diff --git a/.config/emacs/modules/lang/yaml/README.org b/.config/emacs/modules/lang/yaml/README.org @@ -1,54 +0,0 @@ -#+title: :lang yaml -#+subtitle: JSON, but readable -#+created: April 24, 2020 -#+since: 21.12.0 - -* Description :unfold: -This module provides support for the [[https://yaml.org/][YAML file format]] to Doom Emacs. - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +lsp :: - Enable LSP support for ~yaml-mode~. Requires [[doom-module::tools lsp]] and a langserver - (supports [[https://github.com/redhat-developer/yaml-language-server][yaml-language-server]]). -- +tree-sitter :: - Leverages tree-sitter for better syntax highlighting and structural text - editing. Requires [[doom-module::tools tree-sitter]]. - -** Packages -- [[doom-package:yaml-mode]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/yaml/config.el b/.config/emacs/modules/lang/yaml/config.el @@ -1,11 +0,0 @@ -;;; lang/yaml/config.el -*- lexical-binding: t; -*- - -(use-package! yaml-mode - :mode "Procfile\\'" - :init - (when (modulep! +lsp) - (add-hook 'yaml-mode-local-vars-hook #'lsp! 'append)) - (when (modulep! +tree-sitter) - (add-hook 'yaml-mode-local-vars-hook #'tree-sitter! 'append)) - :config - (setq-hook! 'yaml-mode-hook tab-width yaml-indent-offset)) diff --git a/.config/emacs/modules/lang/yaml/packages.el b/.config/emacs/modules/lang/yaml/packages.el @@ -1,4 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/yaml/packages.el - -(package! yaml-mode :pin "3fcb36d6039bef57e2a0f6e24c51f623c0bf5fb7") diff --git a/.config/emacs/modules/lang/zig/README.org b/.config/emacs/modules/lang/zig/README.org @@ -1,87 +0,0 @@ -#+title: :lang zig -#+subtitle: C, but simpler -#+created: April 05, 2021 -#+since: 21.12.0 (#4827) - -* Description :unfold: -This module adds [[https://ziglang.org/][Zig]] support, with optional (but recommended) LSP support via -[[https://github.com/zigtools/zls][zls]]. - -- Syntax highlighting -- Syntax-checking ([[doom-package:flycheck]]) -- Code completion and LSP integration (~zls~) - -** Maintainers -- [[doom-user:][@bnjmnt4n]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +lsp :: - Enables integration for the zls LSP server. It is highly recommended you use - this. -- +tree-sitter :: - Leverages tree-sitter for better syntax highlighting and structural text - editing. Requires [[doom-module::tools tree-sitter]]. - -** Packages -- [[doom-package:zig-mode]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -To get started with Zig, you need the ~zig~ tool. Pre-built binaries for most -systems are available for download from [[https://ziglang.org/download/]] or from -[[https://github.com/ziglang/zig/wiki/Install-Zig-from-a-Package-Manager][system package managers]]. - -=zls= is a language server for Zig, which provides code completion, - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** LSP support -This module supports LSP integration. For it to work you'll need: - -1. zls installed, -2. The [[doom-module::tools lsp]] module enabled. Only [[doom-package:lsp-mode]] is supported for now, -3. The [[doom-module:+lsp]] flag on this module enabled. - -** Keybinds -| Binding | Description | -|-------------------+---------------------| -| [[kbd:][<localleader> b]] | ~zig-compile~ | -| [[kbd:][<localleader> f]] | ~zig-format-buffer~ | -| [[kbd:][<localleader> r]] | ~zig-run~ | -| [[kbd:][<localleader> t]] | ~zig-test-buffer~ | - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** Customize zls path -To customize the path of the =zls= executable, modify ~lsp-zig-zls-executable~: -#+begin_src emacs-lisp -;; in $DOOMDIR/config.el -(setq lsp-zig-zls-executable "~/path/to/zls") -#+end_src - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/lang/zig/config.el b/.config/emacs/modules/lang/zig/config.el @@ -1,35 +0,0 @@ -;;; lang/zig/config.el -*- lexical-binding: t; -*- - -(after! projectile - (add-to-list 'projectile-project-root-files "build.zig")) - - -;; -;;; Packages - -(use-package! zig-mode - :hook (zig-mode . rainbow-delimiters-mode) - :config - (setq zig-format-on-save nil) ; rely on :editor format instead - - (when (modulep! +lsp) - (add-hook 'zig-mode-local-vars-hook #'lsp! 'append)) - - (when (modulep! +tree-sitter) - (add-hook 'zig-mode-local-vars-hook #'tree-sitter! 'append)) - - (when (modulep! :checkers syntax) - (flycheck-define-checker zig - "A zig syntax checker using zig's `ast-check` command." - :command ("zig" "ast-check" (eval (buffer-file-name))) - :error-patterns - ((error line-start (file-name) ":" line ":" column ": error: " (message) line-end)) - :modes zig-mode) - (add-to-list 'flycheck-checkers 'zig)) - - (map! :localleader - :map zig-mode-map - "b" #'zig-compile - "f" #'zig-format-buffer - "r" #'zig-run - "t" #'zig-test-buffer)) diff --git a/.config/emacs/modules/lang/zig/doctor.el b/.config/emacs/modules/lang/zig/doctor.el @@ -1,17 +0,0 @@ -;; -*- lexical-binding: t; no-byte-compile: t; -*- -;;; lang/zig/doctor.el - -(assert! (or (not (modulep! +lsp)) - (modulep! :tools lsp)) - "This module requires (:tools lsp)") - -(assert! (or (not (modulep! +tree-sitter)) - (modulep! :tools tree-sitter)) - "This module requires (:tools tree-sitter)") - -(unless (executable-find "zig") - (warn! "Couldn't find zig binary")) - -(when (modulep! +lsp) - (unless (executable-find "zls") - (warn! "Couldn't find zls binary"))) diff --git a/.config/emacs/modules/lang/zig/packages.el b/.config/emacs/modules/lang/zig/packages.el @@ -1,4 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; lang/zig/packages.el - -(package! zig-mode :pin "9c5e41d6a0a8d8e081dd2dc9b57696435eebbc30") diff --git a/.config/emacs/modules/os/README.org b/.config/emacs/modules/os/README.org @@ -1,10 +0,0 @@ -#+title: :os -#+created: November 03, 2021 -#+since: 21.12.0 - -* Description -Modules in this category are designed to improve compatibility with certain -operating systems or OS features (like the shell). - -* Frequently asked questions -/This category has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] diff --git a/.config/emacs/modules/os/macos/README.org b/.config/emacs/modules/os/macos/README.org @@ -1,66 +0,0 @@ -#+title: :os macos -#+subtitle: Compatibility for our favorite walled garden -#+created: February 19, 2017 -#+since: 1.3 - -* Description :unfold: -This module provides extra functionality for macOS. - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:ns-auto-titlebar]] -- [[doom-package:osx-trash]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires a macOS environment. - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** "Open with X" -This module adds various macOS-specific launchers under the [[kbd:][SPC o]] prefix ([[kbd:][C-c -o]] for users with Evil disabled). - -It also enables Keychain integration for [[doom-package:auth-source]]. This is used by our [[doom-module::app -irc]] and [[doom-module::tools magit]] modules, for instance. - -To support GitHub Forge add an internet password like this to your keychain: -| Field | Value | -|----------+-------------------------| -| Name | api.github.com | -| Kind | Internet password | -| Account | <username>^forge | -| Where | https://api.github.com/ | -| Password | <token> | - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/os/macos/autoload.el b/.config/emacs/modules/os/macos/autoload.el @@ -1,73 +0,0 @@ -;;; os/macos/autoload.el -*- lexical-binding: t; -*- - -(defun +macos-defaults (action &rest args) - (apply #'doom-call-process "defaults" action args)) - -(defun +macos-open-with (&optional app-name path) - "Send PATH to APP-NAME on OSX." - (interactive) - (let* ((path (expand-file-name - (replace-regexp-in-string - "'" "\\'" - (or path (if (derived-mode-p 'dired-mode) - (dired-get-file-for-visit) - (buffer-file-name))) - nil t))) - (command (format "open %s" - (if app-name - (format "-a %s '%s'" (shell-quote-argument app-name) path) - (format "'%s'" path))))) - (message "Running: %s" command) - (shell-command command))) - -(defmacro +macos--open-with (id &optional app dir) - `(defun ,(intern (format "+macos/%s" id)) () - (interactive) - (+macos-open-with ,app ,dir))) - -(defmacro +macos--open-with-iterm (id &optional dir newwindow?) - `(defun ,(intern (format "+macos/%s" id)) () - (interactive) - (letf! ((defun read-newwindows () - (cdr (+macos-defaults - "read" "com.googlecode.iterm2" "OpenFileInNewWindows"))) - (defun write-newwindows (bool) - (+macos-defaults - "write" "com.googlecode.iterm2" "OpenFileInNewWindows" - "-bool" (if bool "true" "false")))) - (let ((newwindow? - (if ,newwindow? (not (equal (read-newwindows) "1"))))) - (when newwindow? - (write-newwindows t)) - (unwind-protect (+macos-open-with "iTerm" ,dir) - (when newwindow? - (write-newwindows nil))))))) - -;;;###autoload (autoload '+macos/open-in-default-program "os/macos/autoload" nil t) -(+macos--open-with open-in-default-program) - -;;;###autoload (autoload '+macos/reveal-in-finder "os/macos/autoload" nil t) -(+macos--open-with reveal-in-finder "Finder" default-directory) - -;;;###autoload (autoload '+macos/reveal-project-in-finder "os/macos/autoload" nil t) -(+macos--open-with reveal-project-in-finder "Finder" - (or (doom-project-root) default-directory)) - -;;;###autoload (autoload '+macos/send-to-transmit "os/macos/autoload" nil t) -(+macos--open-with send-to-transmit "Transmit") - -;;;###autoload (autoload '+macos/send-cwd-to-transmit "os/macos/autoload" nil t) -(+macos--open-with send-cwd-to-transmit "Transmit" default-directory) - -;;;###autoload (autoload '+macos/send-to-launchbar "os/macos/autoload" nil t) -(+macos--open-with send-to-launchbar "LaunchBar") - -;;;###autoload (autoload '+macos/send-project-to-launchbar "os/macos/autoload" nil t) -(+macos--open-with send-project-to-launchbar "LaunchBar" - (or (doom-project-root) default-directory)) - -;;;###autoload (autoload '+macos/open-in-iterm "os/macos/autoload" nil t) -(+macos--open-with-iterm open-in-iterm default-directory) - -;;;###autoload (autoload '+macos/open-in-iterm-new-window "os/macos/autoload" nil t) -(+macos--open-with-iterm open-in-iterm-new-window default-directory t) diff --git a/.config/emacs/modules/os/macos/config.el b/.config/emacs/modules/os/macos/config.el @@ -1,53 +0,0 @@ -;;; os/macos/config.el -*- lexical-binding: t; -*- - -;; -;;; Reasonable defaults for macOS - -;; Use spotlight search backend as a default for M-x locate (and helm/ivy -;; variants thereof), since it requires no additional setup. -(setq locate-command "mdfind") - - -;; -;;; Compatibilty fixes - -;; Curse Lion and its sudden but inevitable fullscreen mode! -;; This is meaningless to railwaycat's emacs-mac build though. -(setq ns-use-native-fullscreen nil) - -;; Visit files opened outside of Emacs in existing frame, not a new one -(setq ns-pop-up-frames nil) - -;; sane trackpad/mouse scroll settings -(setq mac-redisplay-dont-reset-vscroll t - mac-mouse-wheel-smooth-scroll nil) - -;; Sets `ns-transparent-titlebar' and `ns-appearance' frame parameters so window -;; borders will match the enabled theme. -(and (or (daemonp) - (display-graphic-p)) - (require 'ns-auto-titlebar nil t) - (ns-auto-titlebar-mode +1)) - -;; Integrate with Keychain -(after! auth-source - (pushnew! auth-sources 'macos-keychain-internet 'macos-keychain-generic)) - - -;; -;;; Packages - -(use-package! osx-trash - :commands osx-trash-move-file-to-trash - :init - ;; Delete files to trash on macOS, as an extra layer of precaution against - ;; accidentally deleting wanted files. - (setq delete-by-moving-to-trash t) - - ;; Lazy load `osx-trash' - (when (not (fboundp 'system-move-file-to-trash)) - (defun system-move-file-to-trash (file) - "Move FILE to trash." - (when (and (not IS-LINUX) - (not (file-remote-p default-directory))) - (osx-trash-move-file-to-trash file))))) diff --git a/.config/emacs/modules/os/macos/packages.el b/.config/emacs/modules/os/macos/packages.el @@ -1,5 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; os/macos/packages.el - -(package! osx-trash :pin "90f0c99206022fec646206018fcd63d9d2e57325") -(package! ns-auto-titlebar :pin "60273e764bf8d95abc40dd2fdc23af87ea9ee33b") diff --git a/.config/emacs/modules/os/tty/README.org b/.config/emacs/modules/os/tty/README.org @@ -1,80 +0,0 @@ -#+title: :os tty -#+subtitle: Make TTY Emacs suck less -#+created: August 07, 2020 -#+since: 21.12.0 - -* Description :unfold: -This module configures Emacs for use in the terminal, by providing: - -- System clipboard integration (through an external clipboard program or OSC-52 - escape codes in supported terminals). -- Cursor-shape changing across evil states (requires a terminal that supports - it). -- Mouse support in the terminal. - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +osc :: - Instead of piping your kill ring through external programs, like =xclip= or - =pbcopy=, have Emacs emit OSC-52 escape codes instead, allowing Emacs to - communicate with your clipboard through your terminal, even across SSH - connections or Tmux. However, this requires [[https://github.com/spudlyo/clipetty#terminals-that-support-osc-clipboard-operations][a supported terminal]]. - -** Packages -- [[doom-package:clipetty]] if [[doom-module:+osc]] -- [[doom-package:evil-terminal-cursor-changer]] if [[doom-module::editor evil]] -- [[doom-package:xclip]] unless [[doom-module:+osc]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module has no hard prerequisites, but in order for its features to work you -need: - -- For system clipboard integration: - - A supported clipboard program, such as: - - Linux: =xclip=, =xsel=, or =wl-clibpoard= (Wayland) - - macOS: =pbcopy= and =pbpaste= (included with macOS) - - Windows: =getclip= and =putclip= (cygwin) - - (If [[doom-module:+osc]] is enabled) A terminal that supports OSC 52 escape codes, such as: - xterm (unix), iTerm2 (macOS), alacritty (cross platform), kitty (macOS, - linux), mintty (Windows), hterm (javascript), st (unix), mlterm (cross - platform) -- For cursor shape changing in the terminal you need A terminal that supports - VT's DECSCUSR sequence, such as: Gnome Terminal, xterm, iTerm (macOS), - Konsole, or mintty (Windows). Terminal.app (macOS) is supported too, but - requires [[http://www.culater.net/software/SIMBL/SIMBL.php][SIMBL]] and [[https://github.com/saitoha/mouseterm-plus/releases][MouseTerm]] Plus to work. - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** True-color and italic support -Consult [[https://github.com/syl20bnr/spacemacs/wiki/Terminal][the spacemacs wiki]] for details on achieving true color support for -terminal Emacs. - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/os/tty/config.el b/.config/emacs/modules/os/tty/config.el @@ -1,44 +0,0 @@ -;;; os/tty/config.el -*- lexical-binding: t; -*- - -;; Keep window title up-to-date. Should fail gracefully in non-xterm terminals. -;; Only works in Emacs 27+. -(setq xterm-set-window-title t) -;; DEPRECATED Not needed on Emacs 28+. Remove when dropping 27 support. -(defadvice! +tty--only-set-window-title-in-tty-a (&optional terminal) - "`xterm-set-window-title' fails in GUI Emacs. Stop that. Get some help." - :before-while #'xterm-set-window-title - (not (display-graphic-p terminal))) - -;; Some terminals offer two different cursors: a "visible" static cursor and a -;; "very visible" blinking one. By default, Emacs uses the very visible cursor -;; and will switch back to it when Emacs is started or resumed. A nil -;; `visible-cursor' prevents this. -(setq visible-cursor nil) - -;; Enable the mouse in terminal Emacs -(add-hook 'tty-setup-hook #'xterm-mouse-mode) - -;; Windows terminals don't support what I'm about to do, but best not to wrap -;; this in a IS-WINDOWS check, in case you're using WSL or Cygwin, which do and -;; *might* support it. -(add-hook! 'tty-setup-hook - (defun doom-init-clipboard-in-tty-emacs-h () - ;; Fix the clipboard in tty Emacs by... - (if (modulep! +osc) - ;; ...communicating with the clibpoard through OSC escape codes (must - ;; use a terminal that supports it) - (and (require 'clipetty nil t) - (global-clipetty-mode +1)) - ;; ...OR piping clipboard I/O through xclip, xsel, pb{copy,paste}, - ;; wl-copy, termux-clipboard-get, or getclip (cygwin); depending on what - ;; is available. - (and (require 'xclip nil t) - (with-demoted-errors "%s" (xclip-mode +1)))))) - -;; Fix cursor shape-changing in the terminal. Only supported in XTerm, Gnome -;; Terminal, iTerm, Konsole, dumb (etc. mintty), and Apple Terminal.app. If -;; using Apple Terminal.app, install -;; http://www.culater.net/software/SIMBL/SIMBL.php and -;; https://github.com/saitoha/mouseterm-plus/releases. That makes to support -;; VT's DECSCUSR sequence. -(add-hook 'tty-setup-hook #'evil-terminal-cursor-changer-activate) diff --git a/.config/emacs/modules/os/tty/packages.el b/.config/emacs/modules/os/tty/packages.el @@ -1,13 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; os/tty/packages.el - -(if (modulep! +osc) - (package! clipetty - :recipe (:host github :repo "spudlyo/clipetty") - :pin "01b39044b9b65fa4ea7d3166f8b1ffab6f740362") - ;; Despite its name, this works for macOS as well. - (package! xclip :pin "a1ac607f75a250dddf49866918bb493884451130")) - -;; NOTE Despite the evil-* prefix, evil-terminal-cursor-changer does not depend -;; on evil (anymore). -(package! evil-terminal-cursor-changer :pin "12ea9c0438c67e560b3866dc78b5c7d1d93f8cc5") diff --git a/.config/emacs/modules/source.el b/.config/emacs/modules/source.el @@ -1,7 +0,0 @@ -;; This file supplies some metadata about this module repo to Doom's module -;; manager. None of them are required, but it's a good idea to include them so -;; Doom can perform some sanity checks for you. - -:root "./" ; where the module tree starts -:version "21.12" ; version of this repo -:requires "3.0.0" ; minimum supported version of Doom's core diff --git a/.config/emacs/modules/term/README.org b/.config/emacs/modules/term/README.org @@ -1,15 +0,0 @@ -#+title: :term -#+created: August 01, 2021 -#+since: 21.12.0 - -* Description -What's an operating system without a terminal? The modules in this category -bring varying degrees of terminal emulation into Emacs. - -If you can't decide which to choose, I recommend [[doom-package:vterm]] or [[doom-package:eshell]]. [[doom-module::term vterm]] -offers that best terminal emulation available but requires a few extra steps to -get going. [[doom-module::term eshell]] works everywhere that Emacs runs, even Windows, and -provides a shell entirely implemented in Emacs Lisp. - -* Frequently asked questions -/This category has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] diff --git a/.config/emacs/modules/term/eshell/README.org b/.config/emacs/modules/term/eshell/README.org @@ -1,75 +0,0 @@ -#+title: :term eshell -#+subtitle: The elisp shell that works everywhere -#+created: February 20, 2017 -#+since: 2.0.0 - -* Description :unfold: -This module provides additional features for the built-in [[https://www.gnu.org/software/emacs/manual/html_mono/eshell.html][Emacs Shell]] - -The Emacs Shell or [[doom-package:eshell]] is a shell-like command interpreter implemented in -Emacs Lisp. It is an alternative to traditional shells such as =bash=, =zsh=, -=fish=, etc. that is built into Emacs and entirely cross-platform. - -** Maintainers -- [[doom-user:][@hlissner]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:eshell-did-you-mean]] -- [[doom-package:eshell-up]] -- [[doom-package:eshell-z]] -- [[doom-package:esh-help]] -- [[doom-package:shrink-path]] -- if [[doom-module::completion company]] - - [[doom-package:fish-completion]] - - [[doom-package:bash-completion]] - -** Hacks -- Even with ~fish-completion-fallback-on-bash-p~ non-nil, fish must be installed - for bash completion to work. This has been circumvented. -- [[doom-package:eshell-did-you-mean]] does not work on first invocation, so we manually invoke - it once. - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires either [[https://fishshell.com/][Fish shell]] or [[https://www.gnu.org/software/bash/][Bash]] for code completion. - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -- Command completion with Company -- =fish=-style prompt with Git integration -- [[https://github.com/rupa/z][=z=]]-like directory jumping -- Command-not-found recommendations - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** TERM name -By default, [[doom-package:eshell]] sets the =$TERM= variable to ~"xterm-256color"~, which helps -with rendering various colours. As eshell is /not/ a terminal emulator, these -will not always work 100%. Modifying ~eshell-term-name~ to your liking may help. - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/term/eshell/autoload/backport.el b/.config/emacs/modules/term/eshell/autoload/backport.el @@ -1,145 +0,0 @@ -;;; term/eshell/autoload/mode.el -*- lexical-binding: t; -*- -;;;###if (< emacs-major-version 28) - -;; DEPRECATED Remove this when we drop Emacs 27 support. - -;; HACK Eshell resets its keymap every time `eshell-mode' is enabled. This is -;; fixed in Emacs 28+, but this file backports that fix for 27 users. This -;; way, keys can be safely bound to `eshell-mode-map' and `eshell-command-map' -;; like any normal keymap, rather than a hook. -;; -;; Fun fact: there's a "FIXME What the hell?!" above the offending line in -;; esh-mode.el. - -;;;###autoload -(defvar eshell-mode-map - (let ((map (make-sparse-keymap))) - (define-key map [(control ?c)] 'eshell-command-map) - (define-key map "\r" #'eshell-send-input) - (define-key map "\M-\r" #'eshell-queue-input) - (define-key map [(meta control ?l)] #'eshell-show-output) - (define-key map [(control ?a)] #'eshell-bol) - map)) - -;;;###autoload -(defvar eshell-command-map - (let ((map (define-prefix-command 'eshell-command-map))) - (define-key map [(meta ?o)] #'eshell-mark-output) - (define-key map [(meta ?d)] #'eshell-toggle-direct-send) - (define-key map [(control ?a)] #'eshell-bol) - (define-key map [(control ?b)] #'eshell-backward-argument) - (define-key map [(control ?e)] #'eshell-show-maximum-output) - (define-key map [(control ?f)] #'eshell-forward-argument) - (define-key map [(control ?m)] #'eshell-copy-old-input) - (define-key map [(control ?o)] #'eshell-kill-output) - (define-key map [(control ?r)] #'eshell-show-output) - (define-key map [(control ?t)] #'eshell-truncate-buffer) - (define-key map [(control ?u)] #'eshell-kill-input) - (define-key map [(control ?w)] #'backward-kill-word) - (define-key map [(control ?y)] #'eshell-repeat-argument) - map)) - -;;;###autoload -(after! esh-mode - (define-derived-mode eshell-mode fundamental-mode "Eshell" - "Emacs shell interactive mode." - (setq-local eshell-mode t) - - (when eshell-status-in-mode-line - (make-local-variable 'eshell-command-running-string) - (let ((fmt (copy-sequence mode-line-format))) - (setq-local mode-line-format fmt)) - (let ((mode-line-elt (memq 'mode-line-modified mode-line-format))) - (if mode-line-elt - (setcar mode-line-elt 'eshell-command-running-string)))) - - (set (make-local-variable 'bookmark-make-record-function) - 'eshell-bookmark-make-record) - (setq local-abbrev-table eshell-mode-abbrev-table) - - (set (make-local-variable 'list-buffers-directory) - (expand-file-name default-directory)) - - ;; always set the tab width to 8 in Eshell buffers, since external - ;; commands which do their own formatting almost always expect this - (set (make-local-variable 'tab-width) 8) - - ;; don't ever use auto-fill in Eshell buffers - (setq auto-fill-function nil) - - ;; always display everything from a return value - (if (boundp 'print-length) - (set (make-local-variable 'print-length) nil)) - (if (boundp 'print-level) - (set (make-local-variable 'print-level) nil)) - - ;; set require-final-newline to nil; otherwise, all redirected - ;; output will end with a newline, whether or not the source - ;; indicated it! - (set (make-local-variable 'require-final-newline) nil) - - (set (make-local-variable 'max-lisp-eval-depth) - (max 3000 max-lisp-eval-depth)) - (set (make-local-variable 'max-specpdl-size) - (max 6000 max-lisp-eval-depth)) - - (set (make-local-variable 'eshell-last-input-start) (point-marker)) - (set (make-local-variable 'eshell-last-input-end) (point-marker)) - (set (make-local-variable 'eshell-last-output-start) (point-marker)) - (set (make-local-variable 'eshell-last-output-end) (point-marker)) - (set (make-local-variable 'eshell-last-output-block-begin) (point)) - - (let ((modules-list (copy-sequence eshell-modules-list))) - (make-local-variable 'eshell-modules-list) - (setq eshell-modules-list modules-list)) - - ;; This is to avoid making the paragraph base direction - ;; right-to-left if the first word just happens to start with a - ;; strong R2L character. - (setq bidi-paragraph-direction 'left-to-right) - - ;; load extension modules into memory. This will cause any global - ;; variables they define to be visible, since some of the core - ;; modules sometimes take advantage of their functionality if used. - (dolist (module eshell-modules-list) - (let ((module-fullname (symbol-name module)) - module-shortname) - (if (string-match "^eshell-\\(.*\\)" module-fullname) - (setq module-shortname - (concat "em-" (match-string 1 module-fullname)))) - (unless module-shortname - (error "Invalid Eshell module name: %s" module-fullname)) - (unless (featurep (intern module-shortname)) - (load module-shortname)))) - - (unless (file-exists-p eshell-directory-name) - (eshell-make-private-directory eshell-directory-name t)) - - ;; Load core Eshell modules, then extension modules, for this session. - (dolist (module (append (eshell-subgroups 'eshell) eshell-modules-list)) - (let ((load-hook (intern-soft (format "%s-load-hook" module))) - (initfunc (intern-soft (format "%s-initialize" module)))) - (when (and load-hook (boundp load-hook)) - (if (memq initfunc (symbol-value load-hook)) (setq initfunc nil)) - (run-hooks load-hook)) - ;; So we don't need the -initialize functions on the hooks (bug#5375). - (and initfunc (fboundp initfunc) (funcall initfunc)))) - - (if eshell-send-direct-to-subprocesses - (add-hook 'pre-command-hook #'eshell-intercept-commands t t)) - - (if eshell-scroll-to-bottom-on-input - (add-hook 'pre-command-hook #'eshell-preinput-scroll-to-bottom t t)) - - (when eshell-scroll-show-maximum-output - (set (make-local-variable 'scroll-conservatively) 1000)) - - (when eshell-status-in-mode-line - (add-hook 'eshell-pre-command-hook #'eshell-command-started nil t) - (add-hook 'eshell-post-command-hook #'eshell-command-finished nil t)) - - (add-hook 'kill-buffer-hook #'eshell-kill-buffer-function t t) - - (if eshell-first-time-p - (run-hooks 'eshell-first-time-mode-hook)) - (run-hooks 'eshell-post-command-hook))) diff --git a/.config/emacs/modules/term/eshell/autoload/commands.el b/.config/emacs/modules/term/eshell/autoload/commands.el @@ -1,30 +0,0 @@ -;;; term/eshell/autoload/commands.el -*- lexical-binding: t; -*- - -;;;###autoload -(defun eshell/emacs (&rest files) - "Open a FILES in Emacs. -For folks with a habit of using \"emacs\" to open files, even in eshell." - (if files - (mapc #'find-file - (mapcar #'expand-file-name - (eshell-flatten-list (reverse files)))) - (bury-buffer))) -;;;###autoload -(defalias 'eshell/e #'eshell/emacs) - -;;;###autoload -(defun eshell/cd-to-project () - "Change to the project root of the current directory." - (eshell/cd (doom-project-root (eshell/pwd)))) - -;;;###autoload -(defun eshell/quit-and-close (&rest _) - "Quit the current eshell buffer and close the window it's in." - (setq-local +eshell-kill-window-on-exit t) - (throw 'eshell-terminal t)) - -;;;###autoload -(defun eshell/mkdir-and-cd (dir) - "Create a directory then cd into it." - (make-directory dir t) - (eshell/cd dir)) diff --git a/.config/emacs/modules/term/eshell/autoload/company.el b/.config/emacs/modules/term/eshell/autoload/company.el @@ -1,60 +0,0 @@ -;;; term/eshell/autoload/company.el -*- lexical-binding: t; -*- -;;;###if (modulep! :completion company) - -;; REVIEW Refactor me - -(defvar company-pcomplete-available 'unknown) - -(defun company-pcomplete--prefix () - (with-no-warnings - (let* ((pcomplete-stub) - pcomplete-seen - pcomplete-norm-func - pcomplete-args - pcomplete-last pcomplete-index - (pcomplete-autolist pcomplete-autolist) - (pcomplete-suffix-list pcomplete-suffix-list)) - (pcomplete-completions) - (buffer-substring (pcomplete-begin) (point))))) - -(defun company-pcomplete--candidates () - (with-no-warnings - (let* ((pcomplete-stub) - (pcomplete-show-list t) - pcomplete-seen pcomplete-norm-func - pcomplete-args pcomplete-last pcomplete-index - (pcomplete-autolist pcomplete-autolist) - (pcomplete-suffix-list pcomplete-suffix-list) - (candidates (pcomplete-completions)) - (prefix (buffer-substring (pcomplete-begin) (point))) - ;; Collect all possible completions for the current stub - (cnds (all-completions pcomplete-stub candidates)) - (bnds (completion-boundaries pcomplete-stub candidates nil "")) - (skip (- (length pcomplete-stub) (car bnds)))) - ;; Replace the stub at the beginning of each candidate by the prefix - (mapcar (lambda (cand) - (concat prefix (substring cand skip))) - cnds)))) - -;;;###autoload -(defun company-pcomplete-available () - (when (eq company-pcomplete-available 'unknown) - (condition-case _err - (progn - (company-pcomplete--candidates) - (setq company-pcomplete-available t)) - (error - (message "Company: pcomplete not found") - (setq company-pcomplete-available nil)))) - company-pcomplete-available) - -;;;###autoload -(defun company-pcomplete (command &optional _arg &rest ignored) - "`company-mode' completion backend using `pcomplete'." - (interactive (list 'interactive)) - (cl-case command - (interactive (company-begin-backend 'company-pcomplete)) - (prefix (when (company-pcomplete-available) - (company-pcomplete--prefix))) - (candidates (company-pcomplete--candidates)) - (sorted t))) diff --git a/.config/emacs/modules/term/eshell/autoload/eshell.el b/.config/emacs/modules/term/eshell/autoload/eshell.el @@ -1,324 +0,0 @@ -;;; term/eshell/autoload/eshell.el -*- lexical-binding: t; -*- - -(defvar eshell-buffer-name "*doom:eshell*") - -(defvar +eshell-buffers (make-ring 25) - "List of open eshell buffers.") - - -(defvar +eshell--last-buffer nil) - - -;; -;;; Helpers - -(defun +eshell--add-buffer (buf) - (ring-remove+insert+extend +eshell-buffers buf 'grow)) - -(defun +eshell--remove-buffer (buf) - (when-let (idx (ring-member +eshell-buffers buf)) - (ring-remove +eshell-buffers idx) - t)) - -(defun +eshell--bury-buffer (&optional dedicated-p) - (let ((directory default-directory)) - (unless (switch-to-prev-buffer nil 'bury) - (switch-to-buffer (doom-fallback-buffer))) - (when (eq major-mode 'eshell-mode) - (switch-to-buffer (doom-fallback-buffer))) - (when +eshell-enable-new-shell-on-split - (let ((default-directory directory)) - (when-let (win (get-buffer-window (+eshell/here))) - (set-window-dedicated-p win dedicated-p)))))) - -(defun +eshell--setup-window (window &optional flag) - (when (window-live-p window) - (set-window-parameter window 'no-other-window flag) - (set-window-parameter window 'visible flag))) - -(defun +eshell--unused-buffer (&optional new-p) - (or (unless new-p - (cl-loop for buf in (+eshell-buffers) - if (and (buffer-live-p buf) - (not (get-buffer-window buf t))) - return buf)) - (generate-new-buffer eshell-buffer-name))) - -;;;###autoload -(defun +eshell-last-buffer (&optional noerror) - "Return the last opened eshell buffer." - (let ((buffer (cl-find-if #'buffer-live-p (+eshell-buffers)))) - (cond (buffer) - (noerror nil) - ((user-error "No live eshell buffers remaining"))))) - -;;;###autoload -(defun +eshell-buffers () - "TODO" - (ring-elements +eshell-buffers)) - -;;;###autoload -(defun +eshell-run-command (command &optional buffer) - "TODO" - (let ((buffer - (or buffer - (if (eq major-mode 'eshell-mode) - (current-buffer) - (cl-find-if #'buffer-live-p (+eshell-buffers)))))) - (unless buffer - (user-error "No living eshell buffers available")) - (unless (buffer-live-p buffer) - (user-error "Cannot operate on a dead buffer")) - (with-current-buffer buffer - (goto-char eshell-last-output-end) - (goto-char (line-end-position)) - (insert command) - (eshell-send-input nil t)))) - - -;; -;;; Commands - -;;;###autoload -(defun +eshell/toggle (arg &optional command) - "Toggle eshell popup window." - (interactive "P") - (let ((eshell-buffer - (get-buffer-create - (format "*doom:eshell-popup:%s*" - (if (bound-and-true-p persp-mode) - (safe-persp-name (get-current-persp)) - "main")))) - confirm-kill-processes - current-prefix-arg) - (when arg - (when-let (win (get-buffer-window eshell-buffer)) - (delete-window win)) - (when (buffer-live-p eshell-buffer) - (with-current-buffer eshell-buffer - (fundamental-mode) - (erase-buffer)))) - (if-let (win (get-buffer-window eshell-buffer)) - (let (confirm-kill-processes) - (delete-window win) - (ignore-errors (kill-buffer eshell-buffer))) - (with-current-buffer eshell-buffer - (doom-mark-buffer-as-real-h) - (if (eq major-mode 'eshell-mode) - (run-hooks 'eshell-mode-hook) - (eshell-mode)) - (when command - (+eshell-run-command command eshell-buffer))) - (pop-to-buffer eshell-buffer)))) - -;;;###autoload -(defun +eshell/here (&optional command) - "Open eshell in the current window." - (interactive "P") - (let ((buf (+eshell--unused-buffer))) - (with-current-buffer (switch-to-buffer buf) - (if (eq major-mode 'eshell-mode) - (run-hooks 'eshell-mode-hook) - (eshell-mode)) - (when command - (+eshell-run-command command buf))) - buf)) - -;;;###autoload -(defun +eshell/frame (&optional command) - "Open a frame dedicated to eshell. - -Once the eshell process is killed, the previous frame layout is restored." - (interactive "P") - (let ((buf (+eshell--unused-buffer 'new))) - (unless (frame-parameter nil 'saved-wconf) - (set-frame-parameter nil 'saved-wconf (current-window-configuration))) - (delete-other-windows) - (with-current-buffer (switch-to-buffer buf) - (eshell-mode) - (when command - (+eshell-run-command command buf))) - buf)) - - -;; -;;; Keybinds - -;;;###autoload -(defun +eshell/search-history () - "Search the eshell command history with helm, ivy or `eshell-list-history'." - (interactive) - (cond ((modulep! :completion ivy) - (require 'em-hist) - (let* ((ivy-completion-beg (eshell-bol)) - (ivy-completion-end (point-at-eol)) - (input (buffer-substring-no-properties - ivy-completion-beg - ivy-completion-end))) - ;; Better than `counsel-esh-history' because that doesn't - ;; pre-populate the initial input or selection. - (ivy-read "Command: " - (delete-dups - (when (> (ring-size eshell-history-ring) 0) - (ring-elements eshell-history-ring))) - :initial-input input - :action #'ivy-completion-in-region-action))) - ((modulep! :completion helm) - (helm-eshell-history)) - ((modulep! :completion vertico) - (forward-char 1) ;; Move outside of read only prompt text. - (consult-history)) - ((eshell-list-history)))) - -;;;###autoload -(defun +eshell/pcomplete () - "Use pcomplete with completion-in-region backend instead of popup window at -bottom. This ties pcomplete into ivy or helm, if they are enabled." - (interactive) - (require 'pcomplete) - (if (and (bound-and-true-p company-mode) - (or company-candidates - (and (company-pcomplete-available) - (company-pcomplete--prefix) - (company-pcomplete--candidates)))) - (call-interactively #'company-pcomplete) - (ignore-errors (pcomplete-std-complete)))) - -;;;###autoload -(defun +eshell/quit-or-delete-char (arg) - "Delete a character (ahead of the cursor) or quit eshell if there's nothing to -delete." - (interactive "p") - (if (and (eolp) (looking-back eshell-prompt-regexp nil)) - (eshell-life-is-too-much) - (delete-char arg))) - -;;;###autoload -(defun +eshell/split-below () - "Create a new eshell window below the current one." - (interactive) - (let ((ignore-window-parameters t) - (dedicated-p (window-dedicated-p)) - (+eshell-enable-new-shell-on-split - (or +eshell-enable-new-shell-on-split (frame-parameter nil 'saved-wconf)))) - (select-window (split-window-vertically)) - (+eshell--bury-buffer dedicated-p))) - -;;;###autoload -(defun +eshell/split-right () - "Create a new eshell window to the right of the current one." - (interactive) - (let* ((ignore-window-parameters t) - (dedicated-p (window-dedicated-p)) - (+eshell-enable-new-shell-on-split - (or +eshell-enable-new-shell-on-split (frame-parameter nil 'saved-wconf)))) - (select-window (split-window-horizontally)) - (+eshell--bury-buffer dedicated-p))) - -;;;###autoload -(defun +eshell/switch-to-next () - "Switch to the next eshell buffer." - (interactive) - (when (ring-empty-p +eshell-buffers) - (user-error "No eshell buffers are available")) - (switch-to-buffer (ring-next +eshell-buffers (current-buffer)))) - -;;;###autoload -(defun +eshell/switch-to-previous () - "Switch to the previous eshell buffer." - (interactive) - (when (ring-empty-p +eshell-buffers) - (user-error "No eshell buffers are available")) - (switch-to-buffer (ring-previous +eshell-buffers (current-buffer)))) - -;;;###autoload -(defun +eshell/switch-to-last () - "Switch to the last eshell buffer that was open (and is still alive)." - (interactive) - (unless (buffer-live-p +eshell--last-buffer) - (setq +eshell--last-buffer nil) - (user-error "No last eshell buffer to jump to")) - (switch-to-buffer +eshell--last-buffer)) - -;;;###autoload -(defun +eshell/switch-to (buffer) - "Interactively switch to another eshell buffer." - (interactive - (let ((buffers (doom-buffers-in-mode - 'eshell-mode (delq (current-buffer) (+eshell-buffers))))) - (if (not buffers) - (user-error "No eshell buffers are available") - (list - (completing-read "Eshell buffers" - (mapcar #'buffer-name buffers) - #'get-buffer - 'require-match - nil nil - (when (eq major-mode 'eshell-mode) - (buffer-name (current-buffer)))))))) - (if-let* ((window (get-buffer-window buffer))) - (select-window window) - (switch-to-buffer buffer))) - -;;;###autoload -(defun +eshell/kill-and-close () - "Kill the current eshell buffer and close its window." - (interactive) - (unless (eq major-mode 'eshell-mode) - (user-error "Not in an eshell buffer")) - (let ((+eshell-kill-window-on-exit t)) - (kill-current-buffer))) - - -;; -;;; Hooks - -;;;###autoload -(defun +eshell-init-h () - "Initialize and track this eshell buffer in `+eshell-buffers'." - (let ((current-buffer (current-buffer))) - (dolist (buf (+eshell-buffers)) - (unless (buffer-live-p buf) - (+eshell--remove-buffer buf))) - (+eshell--setup-window (get-buffer-window current-buffer)) - (+eshell--add-buffer current-buffer) - (setq +eshell--last-buffer current-buffer))) - -;;;###autoload -(defun +eshell-cleanup-h () - "Close window (or workspace) on quit." - (let ((buf (current-buffer))) - (when (+eshell--remove-buffer buf) - (when-let (win (get-buffer-window buf)) - (+eshell--setup-window win nil) - (cond ((and (one-window-p t) - (window-configuration-p (frame-parameter nil 'saved-wconf))) - (set-window-configuration (frame-parameter nil 'saved-wconf)) - (set-frame-parameter nil 'saved-wconf nil)) - ((one-window-p) - (let ((prev (save-window-excursion (previous-buffer)))) - (unless (and prev (doom-real-buffer-p prev)) - (switch-to-buffer (doom-fallback-buffer))))) - ((or (window-dedicated-p win) - +eshell-kill-window-on-exit) - (let ((ignore-window-parameters t) - (popup-p (window-dedicated-p win))) - (delete-window win) - (when popup-p - (cl-loop for win in (window-list) - for buf = (window-buffer win) - for mode = (buffer-local-value 'major-mode buf) - if (eq mode 'eshell-mode) - return (select-window win)))))))))) - -;;;###autoload -(defun +eshell-switch-workspace-fn (type) - (when (eq type 'frame) - (setq +eshell-buffers - (or (persp-parameter 'eshell-buffers) - (make-ring 25))))) - -;;;###autoload -(defun +eshell-save-workspace-fn (_workspace target) - (when (framep target) - (set-persp-parameter 'eshell-buffers +eshell-buffers))) diff --git a/.config/emacs/modules/term/eshell/autoload/evil.el b/.config/emacs/modules/term/eshell/autoload/evil.el @@ -1,34 +0,0 @@ -;;; term/eshell/autoload/evil.el -*- lexical-binding: t; -*- -;;;###if (modulep! :editor evil) - -;;;###autoload (autoload '+eshell:run "term/eshell/autoload/evil" nil t) -(evil-define-command +eshell:run (command bang) - "TODO" - (interactive "<fsh><!>") - (let ((buffer (+eshell-last-buffer)) - (command (+evil-replace-filename-modifiers-a command))) - (cond (buffer - (select-window (get-buffer-window buffer)) - (+eshell-run-command command buffer)) - (bang (+eshell/open nil command)) - ((+eshell/open-popup nil command))))) - -;;;###autoload -(defun +eshell-goto-prompt-on-insert-a () - "Move cursor to the prompt when switching to insert mode (if point isn't -already there). - - Meant to replace `evil-collection-eshell-next-prompt-on-insert'." - (when (< (point) eshell-last-output-end) - (goto-char - (if (memq this-command '(evil-append evil-append-line)) - (point-max) - eshell-last-output-end)))) - -;;;###autoload -(defun +eshell/goto-end-of-prompt () - "Move cursor to the prompt when switching to insert mode (if point isn't -already there)." - (interactive) - (goto-char (point-max)) - (evil-append 1)) diff --git a/.config/emacs/modules/term/eshell/autoload/prompts.el b/.config/emacs/modules/term/eshell/autoload/prompts.el @@ -1,39 +0,0 @@ -;;; term/eshell/autoload/prompts.el -*- lexical-binding: t; -*- - -;;;###autoload -(defface +eshell-prompt-pwd '((t (:inherit font-lock-constant-face))) - "TODO" - :group 'eshell) - -;;;###autoload -(defface +eshell-prompt-git-branch '((t (:inherit font-lock-builtin-face))) - "TODO" - :group 'eshell) - - -(defun +eshell--current-git-branch () - ;; TODO Refactor me - (cl-destructuring-bind (status . output) - (doom-call-process "git" "symbolic-ref" "-q" "--short" "HEAD") - (if (equal status 0) - (format " [%s]" output) - (cl-destructuring-bind (status . output) - (doom-call-process "git" "describe" "--all" "--always" "HEAD") - (if (equal status 0) - (format " [%s]" output) - ""))))) - -;;;###autoload -(defun +eshell-default-prompt-fn () - "Generate the prompt string for eshell. Use for `eshell-prompt-function'." - (require 'shrink-path) - (concat (if (bobp) "" "\n") - (let ((pwd (eshell/pwd))) - (propertize (if (equal pwd "~") - pwd - (abbreviate-file-name (shrink-path-file pwd))) - 'face '+eshell-prompt-pwd)) - (propertize (+eshell--current-git-branch) - 'face '+eshell-prompt-git-branch) - (propertize " λ" 'face (if (zerop eshell-last-command-status) 'success 'error)) - " ")) diff --git a/.config/emacs/modules/term/eshell/autoload/settings.el b/.config/emacs/modules/term/eshell/autoload/settings.el @@ -1,26 +0,0 @@ -;;; term/eshell/autoload/settings.el -*- lexical-binding: t; -*- - -;;;###autodef -(defun set-eshell-alias! (&rest aliases) - "Define aliases for eshell. - -ALIASES is a flat list of alias -> command pairs. e.g. - - (set-eshell-alias! - \"hi\" \"echo hello world\" - \"bye\" \"echo goodbye world\")" - (or (cl-evenp (length aliases)) - (signal 'wrong-number-of-arguments (list 'even (length aliases)))) - (after! em-alias - (while aliases - (let ((alias (pop aliases)) - (command (pop aliases))) - (if-let* ((oldval (assoc alias +eshell-aliases))) - (setcdr oldval (list command)) - (push (list alias command) +eshell-aliases)))) - (when (boundp 'eshell-command-aliases-list) - (if +eshell--default-aliases - (setq eshell-command-aliases-list - (append +eshell--default-aliases - +eshell-aliases)) - (setq eshell-command-aliases-list +eshell-aliases))))) diff --git a/.config/emacs/modules/term/eshell/config.el b/.config/emacs/modules/term/eshell/config.el @@ -1,205 +0,0 @@ -;;; term/eshell/config.el -*- lexical-binding: t; -*- - -;; see: -;; + `+eshell/here': open eshell in the current window -;; + `+eshell/toggle': toggles an eshell popup -;; + `+eshell/frame': converts the current frame into an eshell-dedicated -;; frame. Once the last eshell process is killed, the old frame configuration -;; is restored. - -(defvar +eshell-config-dir - (expand-file-name "eshell/" doom-user-dir) - "Where to store eshell configuration files, as opposed to -`eshell-directory-name', which is where Doom will store temporary/data files.") - -(defvar eshell-directory-name (concat doom-data-dir "eshell") - "Where to store temporary/data files, as opposed to `eshell-config-dir', -which is where Doom will store eshell configuration files.") - -(defvar +eshell-enable-new-shell-on-split t - "If non-nil, spawn a new eshell session after splitting from an eshell -buffer.") - -(defvar +eshell-kill-window-on-exit nil - "If non-nil, eshell will close windows along with its eshell buffers.") - -(defvar +eshell-aliases - '(("q" "exit") ; built-in - ("f" "find-file $1") - ("ff" "find-file-other-window $1") - ("d" "dired $1") - ("bd" "eshell-up $1") - ("rg" "rg --color=always $*") - ("l" "ls -lh $*") - ("ll" "ls -lah $*") - ("git" "git --no-pager $*") - ("gg" "magit-status") - ("cdp" "cd-to-project") - ("clear" "clear-scrollback")) ; more sensible than default - "An alist of default eshell aliases, meant to emulate useful shell utilities, -like fasd and bd. Note that you may overwrite these in your -`eshell-aliases-file'. This is here to provide an alternative, elisp-centric way -to define your aliases. - -You should use `set-eshell-alias!' to change this.") - -;; These files are exceptions, because they may contain configuration -(defvar eshell-aliases-file (concat +eshell-config-dir "aliases")) -(defvar eshell-rc-script (concat +eshell-config-dir "profile")) -(defvar eshell-login-script (concat +eshell-config-dir "login")) - -(defvar +eshell--default-aliases nil) - - -;; -;;; Packages - -(after! eshell ; built-in - (setq eshell-banner-message - '(format "%s %s\n" - (propertize (format " %s " (string-trim (buffer-name))) - 'face 'mode-line-highlight) - (propertize (current-time-string) - 'face 'font-lock-keyword-face)) - eshell-scroll-to-bottom-on-input 'all - eshell-scroll-to-bottom-on-output 'all - eshell-kill-processes-on-exit t - eshell-hist-ignoredups t - ;; don't record command in history if prefixed with whitespace - ;; TODO Use `eshell-input-filter-initial-space' when Emacs 25 support is dropped - eshell-input-filter (lambda (input) (not (string-match-p "\\`\\s-+" input))) - ;; em-prompt - eshell-prompt-regexp "^.* λ " - eshell-prompt-function #'+eshell-default-prompt-fn - ;; em-glob - eshell-glob-case-insensitive t - eshell-error-if-no-glob t) - - ;; Consider eshell buffers real - (add-hook 'eshell-mode-hook #'doom-mark-buffer-as-real-h) - - ;; Keep track of open eshell buffers - (add-hook 'eshell-mode-hook #'+eshell-init-h) - (add-hook 'eshell-exit-hook #'+eshell-cleanup-h) - - ;; Enable autopairing in eshell - (add-hook 'eshell-mode-hook #'smartparens-mode) - - ;; Persp-mode/workspaces integration - (when (modulep! :ui workspaces) - (add-hook 'persp-activated-functions #'+eshell-switch-workspace-fn) - (add-hook 'persp-before-switch-functions #'+eshell-save-workspace-fn)) - - ;; UI enhancements - (add-hook! 'eshell-mode-hook - (defun +eshell-remove-fringes-h () - (set-window-fringes nil 0 0) - (set-window-margins nil 1 nil)) - (defun +eshell-enable-text-wrapping-h () - (visual-line-mode +1) - (set-display-table-slot standard-display-table 0 ?\ ))) - - (add-hook 'eshell-mode-hook #'hide-mode-line-mode) - - ;; Remove hscroll-margin in shells, otherwise you get jumpiness when the - ;; cursor comes close to the left/right edges of the window. - (setq-hook! 'eshell-mode-hook hscroll-margin 0) - - ;; Don't auto-write our aliases! Let us manage our own `eshell-aliases-file' - ;; or configure `+eshell-aliases' via elisp. - (advice-add #'eshell-write-aliases-list :override #'ignore) - - ;; REVIEW In Emacs 27 and newer, waiting for esh-module is unnecessary. - (after! esh-module - (add-to-list 'eshell-modules-list 'eshell-tramp)) - - ;; Visual commands require a proper terminal. Eshell can't handle that, so - ;; it delegates these commands to a term buffer. - (after! em-term - (pushnew! eshell-visual-commands "tmux" "htop" "vim" "nvim" "ncmpcpp")) - - (after! em-alias - (setq +eshell--default-aliases eshell-command-aliases-list - eshell-command-aliases-list - (append eshell-command-aliases-list - +eshell-aliases)))) - - -(after! esh-mode - (map! :map eshell-mode-map - :n "RET" #'+eshell/goto-end-of-prompt - :n [return] #'+eshell/goto-end-of-prompt - :ni "C-j" #'eshell-next-matching-input-from-input - :ni "C-k" #'eshell-previous-matching-input-from-input - :ig "C-d" #'+eshell/quit-or-delete-char - :i "C-c h" #'evil-window-left - :i "C-c j" #'evil-window-down - :i "C-c k" #'evil-window-up - :i "C-c l" #'evil-window-right - "C-s" #'+eshell/search-history - ;; Emacs bindings - "C-e" #'end-of-line - ;; Tmux-esque prefix keybinds - "C-c s" #'+eshell/split-below - "C-c v" #'+eshell/split-right - "C-c x" #'+eshell/kill-and-close - [remap split-window-below] #'+eshell/split-below - [remap split-window-right] #'+eshell/split-right - [remap doom/backward-to-bol-or-indent] #'eshell-bol - [remap doom/backward-kill-to-bol-and-indent] #'eshell-kill-input - [remap evil-delete-back-to-indentation] #'eshell-kill-input - [remap evil-window-split] #'+eshell/split-below - [remap evil-window-vsplit] #'+eshell/split-right - ;; To emulate terminal keybinds - "C-l" (cmd! (eshell/clear-scrollback) (eshell-emit-prompt)) - (:localleader - "b" #'eshell-insert-buffer-name - "e" #'eshell-insert-envvar - "s" #'+eshell/search-history))) - - -(use-package! eshell-up - :commands eshell-up eshell-up-peek) - - -(use-package! eshell-z - :after eshell - :config - ;; Use zsh's db if it exists, otherwise, store it in `doom-cache-dir' - (unless (file-exists-p eshell-z-freq-dir-hash-table-file-name) - (setq eshell-z-freq-dir-hash-table-file-name - (expand-file-name "z" eshell-directory-name)))) - - -(use-package! esh-help - :after eshell - :config (setup-esh-help-eldoc)) - - -(use-package! eshell-did-you-mean - :after esh-mode ; Specifically esh-mode, not eshell - :config - (eshell-did-you-mean-setup) - ;; HACK There is a known issue with `eshell-did-you-mean' where it does not - ;; work on first invocation, so we invoke it once manually by setting the - ;; last command and then calling the output filter. - (setq eshell-last-command-name "catt") - (eshell-did-you-mean-output-filter "catt: command not found")) - - -(use-package eshell-syntax-highlighting - :hook (eshell-mode . eshell-syntax-highlighting-mode)) - - -(use-package! fish-completion - :unless IS-WINDOWS - :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-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") ""))) diff --git a/.config/emacs/modules/term/eshell/packages.el b/.config/emacs/modules/term/eshell/packages.el @@ -1,13 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; term/eshell/packages.el - -(package! eshell-up :pin "ff84e6069b98f2ed00857a0f78bff19d96e4955c") -(package! eshell-z :pin "337cb241e17bd472bd3677ff166a0800f684213c") -(package! shrink-path :pin "c14882c8599aec79a6e8ef2d06454254bb3e1e41") -(package! esh-help :pin "417673ed18a983930a66a6692dbfb288a995cb80") -(package! eshell-did-you-mean :pin "80cd8c4b186a2fb29621cf634bcf2bcd914f1e3d") -(package! eshell-syntax-highlighting :pin "1ba39a9ffb2298cd716a4314cf3f369028c7bafe") - -(unless IS-WINDOWS - (package! fish-completion :pin "10384881817b5ae38cf6197a077a663420090d2c") - (package! bash-completion :pin "25611eed1e086c4e8cdd335dbd38b1d796be5b8d")) diff --git a/.config/emacs/modules/term/shell/README.org b/.config/emacs/modules/term/shell/README.org @@ -1,60 +0,0 @@ -#+title: :term shell -#+subtitle: A REPL for your shell -#+created: August 01, 2021 -#+since: 21.12.0 - -* Description :unfold: -Provides a REPL for your shell. - -#+begin_quote - 💡 =shell= is more REPL than terminal emulator. You can edit your command line - like you would any ordinary text in Emacs -- something you can't do in [[doom-package:term]] - (without ~term-line-mode~, which can be unstable) or [[doom-package:vterm]]. - - Due to =shell='s simplicity, you're less likely to encounter edge cases - (e.g. against your shell config), but it's also the least capable. TUI - programs like =htop= or =vim= won't work in shell directly, but will be - launched in a =term= buffer -- which handles them reasonably well. -#+end_quote - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -/This module doesn't install any packages./ - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/term/shell/autoload.el b/.config/emacs/modules/term/shell/autoload.el @@ -1,105 +0,0 @@ -;;; term/shell/autoload.el -*- lexical-binding: t; -*- - -(defun +shell-idle-p (buf) - "Return t if the shell in BUF is not running something. -When available, use process hierarchy information via pstree for -local shells. Otherwise, we ask comint if the point is after a -prompt." - (with-current-buffer buf - (let ((comint-says-idle (and - (> (point) 1) ;; if point > 1 - ;; see if previous char has the prompt face - (equal '(comint-highlight-prompt) - (get-text-property - (- (point) 1) 'font-lock-face))))) - (if (file-remote-p default-directory) - ;; for remote shells we have to rely on comint - comint-says-idle - ;; for local shells, we can potentially do better using pgrep - (condition-case nil - (case (call-process ;; look at the exit code of pgrep -P <pid> - "pgrep" nil nil nil "-P" - (number-to-string (process-id (get-buffer-process buf)))) - (0 nil) ;; child procxesses found, not idle - (1 t) ;; not running any child processes, it's idle - (t comint-says-idle)) ;; anything else, fall back on comint. - (error comint-says-idle)))))) ;; comint fallback if execution failed - -(defun +shell-unused-buffer () - "TODO" - (or (cl-find-if #'+shell-idle-p (doom-buffers-in-mode 'shell-mode)) - (generate-new-buffer "*doom:shell*"))) - -(defun +shell-tramp-hosts () - "Ask tramp for a list of hosts that we can reach through ssh." - (cl-reduce #'append - (mapcar (lambda (x) - (delq nil (mapcar #'cadr (apply (car x) (cdr x))))) - (tramp-get-completion-function "scp")))) - -(defun +shell--sentinel (process _event) - (when (memq (process-status process) '(exit stop)) - (kill-buffer (process-buffer process)))) - -(defun +shell--send-input (buffer input &optional no-newline) - (when input - (with-current-buffer buffer - (unless (number-or-marker-p (cdr comint-last-prompt)) - (message "Waiting for shell to start up...") - (while (not (number-or-marker-p (cdr comint-last-prompt))) - (sleep-for 0.1))) - (goto-char (cdr comint-last-prompt)) - (delete-region (cdr comint-last-prompt) (point-max)) - (insert input) - (comint-send-input no-newline)))) - - -;;;###autoload -(defun +shell/toggle (&optional command) - "Toggle a persistent terminal popup window. - -If popup is visible but unselected, selected it. -If popup is focused, kill it." - (interactive) - (let ((buffer - (get-buffer-create - (format "*doom:shell-popup:%s*" - (if (bound-and-true-p persp-mode) - (safe-persp-name (get-current-persp)) - "main")))) - (dir default-directory)) - (if-let (win (get-buffer-window buffer)) - (let (confirm-kill-processes) - (set-process-query-on-exit-flag (get-buffer-process buffer) nil) - (delete-window win) - (ignore-errors (kill-buffer buffer))) - (with-current-buffer buffer - (if (not (eq major-mode 'shell-mode)) - (shell buffer) - (cd dir) - (run-mode-hooks 'shell-mode-hook))) - (pop-to-buffer buffer)) - (when-let (process (get-buffer-process buffer)) - (set-process-sentinel process #'+shell--sentinel) - (+shell--send-input buffer command)))) - -;;;###autoload -(defun +shell/here (&optional command) - "Open a terminal buffer in the current window. - -If already in a shell buffer, clear it and cd into the current directory." - (interactive) - (let ((buffer (+shell-unused-buffer)) - (dir default-directory)) - (with-current-buffer (switch-to-buffer buffer) - (if (eq major-mode 'shell-mode) - (+shell--send-input buffer (format "cd %S" dir)) - (shell buffer)) - (let ((process (get-buffer-process buffer))) - (set-process-sentinel process #'+shell--sentinel) - (+shell--send-input buffer command))) - buffer)) - - -;; TODO +shell/frame -- dedicate current frame to shell buffers -;; TODO +shell/frame-quite -- revert frame to before +term/frame diff --git a/.config/emacs/modules/term/shell/config.el b/.config/emacs/modules/term/shell/config.el @@ -1,5 +0,0 @@ -;;; term/shell/config.el -*- lexical-binding: t; -*- - -;;;###package shell -(add-hook 'shell-mode-hook #'doom-mark-buffer-as-real-h) -(add-hook 'shell-mode-hook #'hide-mode-line-mode) diff --git a/.config/emacs/modules/term/shell/packages.el b/.config/emacs/modules/term/shell/packages.el @@ -1,4 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; term/shell/packages.el - -(package! shell :built-in t) diff --git a/.config/emacs/modules/term/term/README.org b/.config/emacs/modules/term/term/README.org @@ -1,49 +0,0 @@ -#+title: :term term -#+subtitle: It's terminal -#+created: August 01, 2021 -#+since: 21.12.0 - -* Description :unfold: -/(No description)/ - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:multi-term]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/term/term/autoload.el b/.config/emacs/modules/term/term/autoload.el @@ -1,47 +0,0 @@ -;;; term/term/autoload.el -*- lexical-binding: t; -*- - -(defun +term--kill-dedicated (window buffer) - (when (window-live-p window) - (delete-window window)) - (when (buffer-live-p buffer) - (set-process-query-on-exit-flag (get-buffer-process buffer) nil) - (kill-buffer buffer))) - -;;;###autoload -(defun +term/toggle (arg) - "Toggle a persistent terminal popup window. - -If popup is visible but unselected, select it. -If prefix ARG, recreate the term buffer." - (interactive "P") - (require 'multi-term) - (let ((multi-term-dedicated-select-after-open-p t) - (multi-term-dedicated-buffer-name - (format "doom:term-popup:%s" - (if (bound-and-true-p persp-mode) - (safe-persp-name (get-current-persp)) - "main")))) - (let* ((buffer (multi-term-get-buffer nil t)) - (window (get-buffer-window buffer))) - (when arg - (+term--kill-dedicated window buffer) - (setq buffer (multi-term-get-buffer nil t))) ; recreates buffer - (if (and (window-live-p window) - (buffer-live-p buffer)) - (delete-window window) - (setenv "PROOT" (or (doom-project-root) default-directory)) - (with-current-buffer buffer - (doom-mark-buffer-as-real-h) - (multi-term-internal)) - (unless (window-live-p window) - (when-let (window - (display-buffer-in-side-window - buffer `((window-height . ,multi-term-dedicated-window-height)))) - (select-window window))))))) - -;;;###autoload -(defalias '+term/here #'multi-term) - - -;; TODO +term/frame -- dedicate current frame to term buffers -;; TODO +term/frame-quite -- revert frame to before +term/frame diff --git a/.config/emacs/modules/term/term/config.el b/.config/emacs/modules/term/term/config.el @@ -1,15 +0,0 @@ -;;; term/term/config.el -*- lexical-binding: t; -*- - -;;;###package term -(add-hook 'term-mode-hook #'doom-mark-buffer-as-real-h) -(add-hook 'term-mode-hook #'hide-mode-line-mode) - - -;;;###package multi-term -(setq multi-term-dedicated-window-height 20 - multi-term-switch-after-close 'PREVIOUS - multi-term-buffer-name "doom:terminal") - -;; Remove hscroll-margin in shells, otherwise you get jumpiness when the cursor -;; comes close to the left/right edges of the window. -(setq-hook! 'term-mode-hook hscroll-margin 0) diff --git a/.config/emacs/modules/term/term/packages.el b/.config/emacs/modules/term/term/packages.el @@ -1,5 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; term/term/packages.el - -(package! term :built-in t) -(package! multi-term :pin "017c77c550115936860e2ea71b88e585371475d5") diff --git a/.config/emacs/modules/term/vterm/README.org b/.config/emacs/modules/term/vterm/README.org @@ -1,166 +0,0 @@ -#+title: :term vterm -#+subtitle: As good as terminal emulation gets in Emacs -#+created: January 16, 2019 -#+since: 21.12.0 (#1144) - -* Description :unfold: -This module provides a terminal emulator powered by libvterm. It is still in -alpha and requires a component be compiled (=vterm-module.so=). - -#+begin_quote - 💡 [[doom-package:vterm]] is as good as terminal emulation gets in Emacs (at the time of - writing) and the most performant, as it is implemented in C. However, it - requires extra steps to set up: - - - Emacs must be built with dynamic modules support, - - and =vterm-module.so= must be compiled, which depends on =libvterm=, - =cmake=, and =libtool-bin=. - - [[doom-package:vterm]] will try to automatically build =vterm-module.so= when you first open - it, but this will fail on Windows, NixOS and Guix out of the box. Install - instructions for nix/guix can be found in the [[doom-module::term vterm]] module's - documentation. There is no way to install vterm on Windows that I'm aware of - (but perhaps with WSL?). -#+end_quote - -** Maintainers -- [[doom-user:][@hlissner]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:vterm]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -+ Emacs must be built with dynamic module support, i.e. compiled with the - =--with-modules= option. -+ You need =libvterm= installed on your system. -+ You need =make=, =cmake= and a C compiler such as =gcc= so that vterm can - build =vterm-module.so=. - -** Dynamic Module support -To check if your build of Emacs was built with dynamic module support, check ~$ -doom info~ for ~MODULES~ next to "System features". If it's there, you're good -to go. - -You can also check for ~--with-modules~ in the ~system-configuration-options~ -variable ([[kbd:][SPC h v system-configuration-options]]). - -- Archlinux or Manjaro users who installed Emacs through pacman will have - support baked in. -- MacOS users: - - If you use [[https://emacsformacosx.com/][Emacs For Mac OS X]], this option is enabled. - - If you use [[https://github.com/d12frosted/homebrew-emacs-plus][emacs-plus]], this option is enabled by default. - - If you use [[https://github.com/railwaycat/homebrew-emacsmacport][emacs-mac]], this options is *not* enabled by default. You may have - to reinstall emacs with the option: ~$ brew install emacs-mac - --with-modules~. - -** libvterm -- Ubuntu or Debian users: ~$ apt-get install libvterm-dev~ -- ArchLinux or Manjaro: ~$ pacman -S libvterm~ -- MacOS: ~$ brew install libvterm~ -- NixOS: - - #+begin_src nix - systemPackages = with pkgs; [ - # emacs # no need for this, the next line includes emacs - ((emacsPackagesFor emacs).emacsWithPackages (epkgs: [ - epkgs.vterm - ])) - ]; - #+end_src - - Or for home-manager users: - #+begin_src nix - programs.emacs = { - enable = true; - extraPackages = epkgs: [ epkgs.vterm ]; - }; - #+end_src - - This already contains a version of =vterm-module.so=, so NixOS users need not - compile the module themselves as described below. - - Note: The =nixpkgs=-version used must be compatible with the packages Doom - installs, so it might be necessary to pull in =emacs= and/or - =emacsPackagesFor= from =unstable= or another channel. Otherwise arbitrary - functionality of =vterm= might not work. - -** Compilation tools for vterm-module.so -When you first load vterm, it will compile =vterm-module.so= for you. For this -to succeed, you need the following: - -- =make= -- =cmake= -- A C compiler like =gcc= -- An internet connection (=cmake= will download needed libraries) - -There are several ways to manually install the module: - -1. You can use ~M-x vterm-module-compile~ to let emacs automatically compile and - install the module. - - Modify ~vterm-module-cmake-args~ to pass arguments to the cmake build script. - e.g. To use a local build of libvterm instead of the included one: - #+begin_src emacs-lisp - (setq vterm-module-cmake-args "-DUSE_SYSTEM_LIBVTERM=yes") - #+end_src - - #+begin_quote - 🚧 Emacs will hang during the compilation. It may take a while. - #+end_quote - -2. You can compile and install the module yourself. Go to the vterm installation - directory (usually =$HOME/.emacs.d/.local/packages/elpa/vterm-<version>=) and - run the following: - #+begin_src sh - mkdir -p build - cd build - cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo .. - make - #+end_src - -3. You can also compile =vterm-module.so= elsewhere, but the module must be - moved/symlinked to - =$HOME/.emacs.d/.local/packages/elpa/vterm-<version>/vterm-module.so= - =vterm-module.so=. Keep in mind that this folder will be deleted whenever the - vterm package is updated. - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -The following commands are available to open it: - -- ~+vterm/toggle~ ([[kbd:][<leader> o t]]) -- Toggle vterm pop up window in the current - project. -- ~+vterm/here~ ([[kbd:][<leader> o T]]) -- Opens vterm in the current window. - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/term/vterm/autoload.el b/.config/emacs/modules/term/vterm/autoload.el @@ -1,76 +0,0 @@ -;;; term/vterm/autoload.el -*- lexical-binding: t; -*- - -(defvar +vterm--id nil) - -;;;###autoload -(defun +vterm/toggle (arg) - "Toggles a terminal popup window at project root. - -If prefix ARG is non-nil, recreate vterm buffer in the current project's root. - -Returns the vterm buffer." - (interactive "P") - (+vterm--configure-project-root-and-display - arg - (lambda () - (let ((buffer-name - (format "*doom:vterm-popup:%s*" - (if (bound-and-true-p persp-mode) - (safe-persp-name (get-current-persp)) - "main"))) - confirm-kill-processes - current-prefix-arg) - (when arg - (let ((buffer (get-buffer buffer-name)) - (window (get-buffer-window buffer-name))) - (when (buffer-live-p buffer) - (kill-buffer buffer)) - (when (window-live-p window) - (delete-window window)))) - (if-let (win (get-buffer-window buffer-name)) - (delete-window win) - (let ((buffer (or (cl-loop for buf in (doom-buffers-in-mode 'vterm-mode) - if (equal (buffer-local-value '+vterm--id buf) - buffer-name) - return buf) - (get-buffer-create buffer-name)))) - (with-current-buffer buffer - (setq-local +vterm--id buffer-name) - (unless (eq major-mode 'vterm-mode) - (vterm-mode))) - (pop-to-buffer buffer))) - (get-buffer buffer-name))))) - -;;;###autoload -(defun +vterm/here (arg) - "Open a terminal buffer in the current window at project root. - -If prefix ARG is non-nil, cd into `default-directory' instead of project root. - -Returns the vterm buffer." - (interactive "P") - (+vterm--configure-project-root-and-display - arg - (lambda() - (require 'vterm) - ;; HACK forces vterm to redraw, fixing strange artefacting in the tty. - (save-window-excursion - (pop-to-buffer "*scratch*")) - (let (display-buffer-alist) - (vterm vterm-buffer-name))))) - -(defun +vterm--configure-project-root-and-display (arg display-fn) - "Sets the environment variable PROOT and displays a terminal using `display-fn`. - -If prefix ARG is non-nil, cd into `default-directory' instead of project root. - -Returns the vterm buffer." - (unless (fboundp 'module-load) - (user-error "Your build of Emacs lacks dynamic modules support and cannot load vterm")) - (let* ((project-root (or (doom-project-root) default-directory)) - (default-directory - (if arg - default-directory - project-root))) - (setenv "PROOT" project-root) - (funcall display-fn))) diff --git a/.config/emacs/modules/term/vterm/config.el b/.config/emacs/modules/term/vterm/config.el @@ -1,31 +0,0 @@ -;;; term/vterm/config.el -*- lexical-binding: t; -*- - -(use-package! vterm - :when (featurep 'dynamic-modules) - :commands vterm-mode - :hook (vterm-mode . doom-mark-buffer-as-real-h) - :hook (vterm-mode . hide-mode-line-mode) ; modeline serves no purpose in vterm - :preface - ;; HACK Because vterm clusmily forces vterm-module.so's compilation on us when - ;; the package is loaded, this is necessary to prevent it when - ;; byte-compiling this file (`use-package' blocks eagerly loads packages - ;; when compiled). - (when noninteractive - (advice-add #'vterm-module-compile :override #'ignore) - (provide 'vterm-module)) - - :config - (set-popup-rule! "^\\*vterm" :size 0.25 :vslot -4 :select t :quit nil :ttl 0) - - ;; Once vterm is dead, the vterm buffer is useless. Why keep it around? We can - ;; spawn another if want one. - (setq vterm-kill-buffer-on-exit t) - - ;; 5000 lines of scrollback, instead of 1000 - (setq vterm-max-scrollback 5000) - - (setq-hook! 'vterm-mode-hook - ;; Don't prompt about dying processes when killing vterm - confirm-kill-processes nil - ;; Prevent premature horizontal scrolling - hscroll-margin 0)) diff --git a/.config/emacs/modules/term/vterm/doctor.el b/.config/emacs/modules/term/vterm/doctor.el @@ -1,10 +0,0 @@ -;;; term/vterm/doctor.el -*- lexical-binding: t; -*- - -(unless (executable-find "make") - (warn! "Couldn't find make command. Vterm module won't compile")) - -(unless (executable-find "cmake") - (warn! "Couldn't find cmake command. Vterm module won't compile")) - -(unless (fboundp 'module-load) - (warn! "Your emacs wasn't built with dynamic modules support. The vterm module won't build")) diff --git a/.config/emacs/modules/term/vterm/packages.el b/.config/emacs/modules/term/vterm/packages.el @@ -1,6 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; term/vterm/packages.el - -(package! vterm - :built-in 'prefer - :pin "3e5a9b754b8e61850bb7d1b63b090b9fbf6687f3") diff --git a/.config/emacs/modules/tools/README.org b/.config/emacs/modules/tools/README.org @@ -1,9 +0,0 @@ -#+title: :tools -#+created: July 29, 2021 -#+since: 21.12.0 - -* Description -Modules that integrate external tools into Emacs. - -* Frequently asked questions -/This category has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] diff --git a/.config/emacs/modules/tools/ansible/README.org b/.config/emacs/modules/tools/ansible/README.org @@ -1,53 +0,0 @@ -#+title: :tools ansible -#+subtitle: Allow silly people to focus on silly things -#+created: September 11, 2018 -#+since: 21.12.0 (#881) - -* Description :unfold: -/(No description)/ - -** Maintainers -*This module needs a maintainer.* [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:ansible]] -- [[doom-package:ansible-doc]] -- [[doom-package:company-ansible]] if [[doom-module::completion company]] -- [[doom-package:jinja2-mode]] -- [[doom-package:yaml-mode]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires [[https://www.ansible.com/][Ansible]]. - -* TODO Usage -#+begin_quote -🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote -🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote -🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/tools/ansible/config.el b/.config/emacs/modules/tools/ansible/config.el @@ -1,35 +0,0 @@ -;;; tools/ansible/config.el -*- lexical-binding: t; -*- - -(use-package! ansible - :commands ansible-auto-decrypt-encrypt - :init - (put 'ansible-vault-password-file 'safe-local-variable #'stringp) - :config - (setq ansible-section-face 'font-lock-variable-name-face - ansible-task-label-face 'font-lock-doc-face) - (when (modulep! :completion company) - (set-company-backend! 'ansible 'company-ansible)) - (map! :map ansible-key-map - :localleader - :desc "Decrypt buffer" "d" #'ansible-decrypt-buffer - :desc "Encrypt buffer" "e" #'ansible-encrypt-buffer - :desc "Look up in Ansible docs" "h" #'ansible-doc)) - - -(after! ansible-doc - (set-evil-initial-state! '(ansible-doc-module-mode) 'emacs)) - - -(use-package! jinja2-mode - :mode "\\.j2$" - :config - ;; The default behavior is to reindent the whole buffer on save. This is - ;; disruptive and imposing. There are indentation commands available; the user - ;; can decide when they want their code reindented. - (setq jinja2-enable-indent-on-save nil)) - - -(def-project-mode! +ansible-yaml-mode - :modes '(yaml-mode) - :add-hooks '(ansible ansible-auto-decrypt-encrypt ansible-doc-mode) - :files (or "roles/" "tasks/main.yml" "tasks/main.yaml")) diff --git a/.config/emacs/modules/tools/ansible/doctor.el b/.config/emacs/modules/tools/ansible/doctor.el @@ -1,5 +0,0 @@ -;; -*- lexical-binding: t; no-byte-compile: t; -*- -;;; tools/ansible/doctor.el - -(unless (executable-find "ansible") - (warn! "Couldn't find ansible executable. Some features of the ansible module won't work")) diff --git a/.config/emacs/modules/tools/ansible/packages.el b/.config/emacs/modules/tools/ansible/packages.el @@ -1,10 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; tools/ansible/packages.el - -(package! ansible :recipe (:nonrecursive t) :pin "d89ac0ee57742cca0f0e0a3453d9dcc521575690") -(package! ansible-doc :pin "86083a7bb2ed0468ca64e52076b06441a2f8e9e0") -(package! jinja2-mode :pin "03e5430a7efe1d163a16beaf3c82c5fd2c2caee1") -(package! yaml-mode :pin "3fcb36d6039bef57e2a0f6e24c51f623c0bf5fb7") - -(when (modulep! :completion company) - (package! company-ansible :pin "79dd421b161efa49fbdffad57fa40edb41f484a3")) diff --git a/.config/emacs/modules/tools/biblio/README.org b/.config/emacs/modules/tools/biblio/README.org @@ -1,141 +0,0 @@ -#+title: :tools biblio -#+subtitle: Writes a PhD for you (citation needed) -#+created: April 11, 2020 -#+since: 21.12.0 (#5290) - -* Description :unfold: -This module adds tools to help when working with bibliographies and citations. -Minimal modifications have been made to the packages and the configuration -details are listed in [[*Configuration][Configuration]] below. Some sensible defaults have been -selected so it should be possible to use without modifications. - -** Maintainers -- [[doom-user:][bdarcus]] -- [[doom-user:][bmg]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:bibtex-completion]] if [[doom-module::completion ivy]] or [[doom-module::completion helm]] -- [[doom-package:parsebib]] if [[doom-module::completion ivy]] or [[doom-module::completion helm]] or [[doom-module::completion vertico]] -- [[doom-package:citar]] if [[doom-module::completion vertico]] -- [[doom-package:citar-embark]] if [[doom-module::completion vertico]] -- [[doom-package:citar-org-roam]] if [[doom-module::completion vertico]] and [[doom-module::lang org +roam2]] -- [[doom-package:helm-bibtex]] if [[doom-module::completion helm]] -- [[doom-package:ivy-bibtex]] if [[doom-module::completion ivy]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -There are no hard dependencies for this module, but this module can benefit from -having a PDF reader and one of Doom's [[doom-module::completion]] modules. - -** PDF viewing -An application for opening PDF files is required. By default =DocView= is used -though [[doom-module::tools pdf]] is highly recommended so PDFs can be viewed within Emacs. - -** Bibtex completion -For vertico, helm, or ivy bibtex completion you should enable [[doom-module::completion vertico]], [[doom-module::completion helm]], or [[doom-module::completion ivy]] respectively. - -* Usage -Both [[doom-package:helm-bibtex]] (includes [[doom-package:helm-bibtex]], [[doom-package:ivy-bibtex]], and bibtex-completion code) -and [[doom-package:citar]] provide an extensive range of features so it is best to check their -respective sites for a full list of features. - -On a high-level you can expect: -- bibliography management -- notes per reference -- citation support -- citation lookup -- org integration for writing literate latex (org-roam) -- fast indexing and searching of references. - -To understand the interaction between these packages this [[https://www.reddit.com/r/emacs/comments/cxu0qg/emacs_org_and_bibtex_as_alternative_to_zotero_and/eyqe4vq/][reddit]] thread will -explain the unique features and the overlapping functionality, if any. - -In addition, this module provides support for native Org-mode citations -([[doom-package:org-cite]]). - -* Configuration -To override any defaults set by this module, do so in an ~(after! package ...)~ -block in =$DOOMDIR/config.el=. - -** Org-cite -*** Processor configuration -[[doom-package:org-cite]] provides rich features and flexible configuration options via its -"processor" capabilities. - -1. /insert/ provides =org-cite-insert= integration for inserting and editing - citations. -2. /activate/ provides fontification, previews, etc. -3. /follow/ integrates contextual citation actions with =org-open-at-point=. -4. /export/ for different output targets. - -This module makes the following processors available: -1. The core =oc-basic=, =oc-natbib=, =oc-biblatex=, and =oc-csl=. -2. [[doom-package:citar]] for integration with [[doom-package:vertico]] completion. - -The module configures these processors as follows for the different completion -modules: -| Feature | Vertico | Ivy | Helm | -|----------+---------+----------+----------| -| Insert | citar | oc-basic | oc-basic | -| Activate | citar | oc-basic | oc-basic | -| Follow | citar | oc-basic | oc-basic | - -*** Other configuration options -If you like, you can also set the =oc-csl= processor to look in a specific -directory for your CSL styles: -#+begin_src emacs-lisp -(setq org-cite-csl-styles-dir "~/Zotero/styles") -#+end_src - -** Path configuration -You must set the path variable for either [[doom-package:citar]] (if using [[doom-module::completion vertico]]) -or [[doom-package:bibtex-completion]] (if using [[doom-module::completion ivy][ivy]] or [[doom-module::completion helm][helm]]); this module will in turn set the -[[var:org-cite-global-bibliography]] variable to the same value: -#+begin_src emacs-lisp -(setq! bibtex-completion-bibliography '("/path/to/references.bib")) -#+end_src - -#+begin_src emacs-lisp -(setq! citar-bibliography '("/path/to/references.bib")) -#+end_src - -You may also set the respective note and library path variables as well for -enhanced functionality: -#+begin_src emacs-lisp -(setq! bibtex-completion-library-path '("/path/to/library/path/") - bibtex-completion-notes-path "/path/to/your/notes/") -#+end_src - -#+begin_src emacs-lisp -(setq! citar-library-paths '("/path/to/library/files/") - citar-notes-paths '("/path/to/your/notes/")) -#+end_src - -** Templates -This module provides reasonable default templates for the packages. However, if -you wish to change them, refer to the respective packages' documentation for -in-depth instructions. - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/tools/biblio/config.el b/.config/emacs/modules/tools/biblio/config.el @@ -1,61 +0,0 @@ -;;; tools/biblio/config.el -*- lexical-binding: t; -*- - -;; -;;; `org-cite' - -(use-package! oc - :defer t - :config - (setq org-cite-global-bibliography - (ensure-list - (or (bound-and-true-p citar-bibliography) - (bound-and-true-p bibtex-completion-bibliography))) - ;; Setup export processor; default csl/citeproc-el, with biblatex for - ;; latex - org-cite-export-processors '((latex biblatex) (t csl)) - org-support-shift-select t)) - - -(use-package! citar - :when (modulep! :completion vertico) - :no-require - :config - (setq org-cite-insert-processor 'citar - org-cite-follow-processor 'citar - org-cite-activate-processor 'citar)) - -(use-package! citar-embark - :when (modulep! :completion vertico) - :after citar embark - :config (citar-embark-mode)) - -(use-package! citar-org-roam - :when (modulep! :completion vertico) - :after citar org-roam - :config (citar-org-roam-mode)) - -;; `org-cite' processors -(use-package! oc-biblatex :after oc) -(use-package! oc-csl :after oc) -(use-package! oc-natbib :after oc) - - -;; -;;; Third-party - -(use-package! bibtex-completion - :when (or (modulep! :completion ivy) - (modulep! :completion helm)) - :defer t - :config - (setq bibtex-completion-additional-search-fields '(keywords) - ;; Tell bibtex-completion to look at the File field of the bibtex to - ;; figure out which pdf to open: - bibtex-completion-pdf-field "file")) - - -(use-package! ivy-bibtex - :when (modulep! :completion ivy) - :defer t - :config - (add-to-list 'ivy-re-builders-alist '(ivy-bibtex . ivy--regex-plus))) diff --git a/.config/emacs/modules/tools/biblio/packages.el b/.config/emacs/modules/tools/biblio/packages.el @@ -1,17 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; tools/biblio/packages.el - -(when (modulep! :completion ivy) - (package! bibtex-completion :pin "8ebf50d5bd368082d0b7ab79d26a52f372cdef98") - (package! ivy-bibtex :pin "8ebf50d5bd368082d0b7ab79d26a52f372cdef98")) -(when (modulep! :completion helm) - (package! bibtex-completion :pin "8ebf50d5bd368082d0b7ab79d26a52f372cdef98") - (package! helm-bibtex :pin "8ebf50d5bd368082d0b7ab79d26a52f372cdef98")) -(when (modulep! :completion vertico) - (package! citar :pin "5dac3d5bf287566f049b44465e415afb42f30ec3") - (package! citar-embark :pin "5dac3d5bf287566f049b44465e415afb42f30ec3") - (when (modulep! :lang org +roam2) - (package! citar-org-roam :pin "86e9861a4931a4a0a4a7fc6c2be153ceb937a869"))) - -(package! parsebib :pin "1efca921cbb49380396df9d81308b32e55fc8b63") -(package! citeproc :pin "2623043b2546ee09a4bd86641870ca86332c0bcf") diff --git a/.config/emacs/modules/tools/debugger/README.org b/.config/emacs/modules/tools/debugger/README.org @@ -1,217 +0,0 @@ -#+title: :tools debugger -#+subtitle: Step through code to add more bugs -#+created: February 20, 2020 -#+since: 2.0.0 - -* Description :unfold: -Introduces a code debugger to Emacs, powered by [[doom-package:realgud]] or [[doom-package:dap-mode]] (LSP). - -This document will help you to configure [[doom-package:dap-mode]] [[https://emacs-lsp.github.io/dap-mode/page/configuration/#native-debug-gdblldb][Native Debug(GDB/LLDB)]] as -there is still not *enough* documentation for it. - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +lsp :: - Enable support for [[https://microsoft.github.io/debug-adapter-protocol/][Debug Adapter Protocol]] (DAP) debuggers. - -** Packages -- [[doom-package:realgud]] -- [[doom-package:realgud-trepan-ni]] if [[doom-module::lang javascript]] -- if [[doom-module:+lsp]] - - [[doom-package:dap-mode]] - - [[doom-package:posframe]] - -** Hacks -- Enables ~gdb-many-windows-mode~ in ~gdb-mode~ by default -- Patches [[doom-package:realgud]] to open in a popup window. This causes realgud - bindings to focus the command window. -- Closes [[doom-package:realgud]]'s command buffer after the session ends. - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* TODO Installation -#+begin_quote - 🔨 /This module's prerequisites documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -Make sure all of these pre-requirements is in your ~$PATH~: -- =nodejs= -- =lldb= and =lldb-mi= (optional) -- =gdb= (optional), requires =unzip= - -If you are getting an error like ~Searching for program no such file or -directory "node"~, then you need [[github:nodejs/node][nodejs]] ([[github:emacs-lsp/dap-mode/issues/79][emacs-lsp/dap-mode#79]]). - -** Realgud debuggers -*** lldb and lldb-mi -This is optional if you want to debug with [[https:lldb.llvm.org][LLDB]]. Install lldb and [[github:lldb-tools/lldb-mi][lldb-mi]]. - -*** gdb -This is optional if you want to debug with [[https:www.gnu.org/software/gdb/][GDB]]. Install gdb. - -You will need ~unzip~ for ~dap-gdb-lldb-setup~. It downloads a VS-Code extension -and it needs to extract compressed downloaded file. - -You need this if you are having ~"wrong-type-argument stringp nil"~ error when -calling ~dap-gdb-lldb-setup~. [[github:emacs-lsp/dap-mode/issues/313][See emacs-lsp/dap-mode#313]] - -** DAP debuggers -*** dap-cpptools -- Languages: C, C++, Rust -- Documentation - - [[https://code.visualstudio.com/docs/cpp/cpp-debug][adapter]] - - [[https://emacs-lsp.github.io/dap-mode/page/configuration/#vscode-cpptools][dap-mode configuration]] - -Run =M-x dap-cpptools-setup= to setup the adapter before using it the first -time. - -*** dap-gdb-lldb -- Languages: C, C++, Rust -- Documentation - - [[https://github.com/WebFreak001/code-debug][adapter]] - - [[https://emacs-lsp.github.io/dap-mode/page/configuration/#native-debug-gdblldb][dap-mode configuration]] - -Install the vscode extension using =M-x dap-gdb-lldb-setup= before using it the -first time. - -*** dap-lldb -- Languages: C, C++, Rust -- Documentation - - [[https://github.com/llvm/llvm-project/tree/main/lldb/tools/lldb-vscode][adapter]] - - [[https://emacs-lsp.github.io/dap-mode/page/configuration/#lldb][dap-mode configuration]] - -Needs [[https://github.com/llvm/llvm-project/tree/main/lldb/tools/lldb-vscode][lldb-vscode]]. Install LLDB from your package manager. For example: - -- *Arch Linux:* ~$ pacman -S lldb~ -- *Fedora:* ~$ dnf install lldb~ - -*** dap-python -- Languages: Python -- Documentation: - - [[https://github.com/microsoft/debugpy/][adapter]] - - [[https://emacs-lsp.github.io/dap-mode/page/configuration/#python][dap-mode configuration]] - -By default, DAP expects [[https://github.com/Microsoft/ptvsd][ptvsd]] as the Python debugger, but [[https://github.com/microsoft/debugpy][debugpy]] is -recommended. See [[*Configuration][Configuration]]. - -*installing ptvsd and debugpy:* -#+begin_src sh -$ pip3 install ptvsd --user -$ pip3 install debugpy --user -#+end_src - -#+begin_src emacs-lisp -;; in $DOOMDIR/config.el -(after! dap-mode - (setq dap-python-debugger 'debugpy)) -#+end_src* TODO Usage - -* Usage -Start a debugging session with ~M-x +debugger/start~ (bound to [[kbd:][SPC o d]] in evil). -You'll be prompted to select a debugger preset if this is the first time you've -used it. Otherwise, it will use the last preset automatically. Use the -universal/prefix argument to invoke this prompt again: [[kbd:][SPC u SPC o d]] or [[kbd:][C-u C-c -o d]]. The last used configuration is stored for each project individually. - -~M-x +debugger/start-last~ starts the last used debug configuration, if it -exists, and prints a message otherwise instead of offering a selection. - -Once the session is started, it can be terminated by ~M-x +debugger/quit~ or by -using the mode-specific way. - -** TODO realgud -#+begin_quote - 🔨 Instructions for realgud haven't been written yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -** dap-mode -*** How to add a debug configuration -1. Call ~dap-gdb-lldb-setup~ function. -2. Use ~dap-debug-edit-template~ to configure debugging settings for your - project. [[github:WebFreak001/code-debug/blob/master/package.json#L72][Available settings can be inspected here.]] Call ~eval-buffer~ to save - your settings. *Don't save the file!* -3. Call ~dap-debug~, select a configuration and start debugging. - -*** dap-mode with ~+lsp~ -Intuitive and powerful debugging. - -- Breakpoints -- REPL -- *local variable view:* Allows you to browse variables in the current stack - frame. -- *expressions:* Add expressions to either watch variables or generic - expressions. - -** Keybindings - -*** General -| Keybind | Description | -|---------+--------------------------| -| [[kbd:][SPC o d]] | Start a debugger session | - -*** dap-mode -When a dap-mode session is running, the following mappings are active: - -| Keybind | Description | -|---------+----------------------------------| -| [[kbd:][SPC m d]] | Open a hydra for session control | - -The hydra is defined as follows: -#+begin_src emacs-lisp -(map! :map dap-mode-map - :leader - :prefix ("d" . "dap") - ;; basics - :desc "dap next" "n" #'dap-next - :desc "dap step in" "i" #'dap-step-in - :desc "dap step out" "o" #'dap-step-out - :desc "dap continue" "c" #'dap-continue - :desc "dap hydra" "h" #'dap-hydra - :desc "dap debug restart" "r" #'dap-debug-restart - :desc "dap debug" "s" #'dap-debug - - ;; debug - :prefix ("dd" . "Debug") - :desc "dap debug recent" "r" #'dap-debug-recent - :desc "dap debug last" "l" #'dap-debug-last - - ;; eval - :prefix ("de" . "Eval") - :desc "eval" "e" #'dap-eval - :desc "eval region" "r" #'dap-eval-region - :desc "eval thing at point" "s" #'dap-eval-thing-at-point - :desc "add expression" "a" #'dap-ui-expressions-add - :desc "remove expression" "d" #'dap-ui-expressions-remove - - :prefix ("db" . "Breakpoint") - :desc "dap breakpoint toggle" "b" #'dap-breakpoint-toggle - :desc "dap breakpoint condition" "c" #'dap-breakpoint-condition - :desc "dap breakpoint hit count" "h" #'dap-breakpoint-hit-condition - :desc "dap breakpoint log message" "l" #'dap-breakpoint-log-message) -#+end_src - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -- There is a known issue with the ~+debugger/start~ command, which is bound to - [[kbd:][SPC o d]] right now. It prints "No debugging session to quit" no matter what. - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -** Setting breakpoints in realgud does not work outside a session -This currently is not supported by realgud. - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/tools/debugger/autoload/debugger.el b/.config/emacs/modules/tools/debugger/autoload/debugger.el @@ -1,134 +0,0 @@ -;;; tools/debugger/autoload/debugger.el -*- lexical-binding: t; -*- - -(defvar-local +debugger--last-config nil - "Configuration of the last debugging session of buffer.") -(put '+debugger--last-config 'permanent-local t) ; don't kill on mode change - -(defun +debugger--get-last-config () - "Get last debugging configuration. - -If in a project, returns the configuration of the last debugging session in the -project, if any. Else, returns the last debugging configuration of the current -buffer, if any." - (if (doom-project-p) - (doom-store-get (doom-project-root) "+debugger") - +debugger--last-config)) - -(defun +debugger--set-config (config) - "Remember this debugging configuration for `+debugger/start-last'. - -If in a project, sets the project's debugging session configuration. Else, sets -the debugging configuration of the current buffer." - (if (doom-project-p) - (doom-store-put (doom-project-root) config - (lambda (key _cfg) (file-directory-p key)) - "+debugger") - (setq +debugger--last-config config))) - -(defun +debugger--list-for-dap () - (and (or (bound-and-true-p lsp-mode) - (bound-and-true-p lsp--buffer-deferred)) - (require 'dap-mode nil t) - dap-mode - (mapcar (lambda (c) (cons 'dap c)) - (apply #'append (mapcar #'funcall dap-launch-configuration-providers))))) - -(defun +debugger--list-for-realgud () - (mapcar (lambda (c) (cons 'realgud (list (symbol-name c)))) - (cl-loop for (sym . plist) in +debugger--realgud-alist - for sym-name = (symbol-name sym) - for modes = (plist-get plist :modes) - if (or (null modes) (apply #'derived-mode-p modes)) - collect sym))) - -;; Based on dap--completing-read and dap-debug -(defun +debugger-completing-read () - "Completing read for debug configuration. - -Presents both dap and realgud configurations, and returns a list of the form -\('dap ...) or ('realgud ...) containing the corresponding debug configuration -infromation." - (let* ((result (mapcar (lambda (c) (cons (cadr c) c)) - (append (+debugger--list-for-dap) - (+debugger--list-for-realgud)))) - (completion (completing-read "Start debugger: " (mapcar #'car result) nil t))) - (if (or (null completion) (string-empty-p completion)) - (user-error "No debugging configuration specified.") - (let ((configuration (cdr (assoc completion result)))) - (if (eq (car configuration) 'dap) - ;; get dap debugging arguments - (let* ((debug-args (dap-variables-expand-in-launch-configuration - (copy-tree (cddr configuration)))) - (launch-args (or (catch 'is-nil - (funcall (or (gethash - (or (plist-get debug-args :type) - (throw 'is-nil nil)) dap--debug-providers) - (throw 'is-nil nil)) debug-args)) - (user-error "Have you loaded the `%s' specific dap package?" - (or (plist-get debug-args :type) - (user-error "%s does not specify :type" debug-args)))))) - (cons 'dap launch-args)) - (cons 'realgud (intern (cadr configuration)))))))) - -;; -;;; Interactive commands - -;;;###autoload -(defun +debugger/start-last () - "Relaunch the last debugger session." - (interactive) - (let ((configuration (+debugger--get-last-config))) - (unless configuration - (user-error "No last debugger%s to invoke" - (if (doom-project-p) - " of this project" - ""))) - (let ((launch-args (cdr configuration))) - (if (eq (car configuration) 'dap) - ;; start dap configuration - (if (functionp launch-args) - (funcall launch-args #'dap-start-debugging-noexpand) - (dap-start-debugging-noexpand launch-args)) - ;; else start realgud configuration: - (call-interactively launch-args))))) - -;;;###autoload -(defun +debugger/start (arg) - "Launch a debugger session. - -Launches the last used debugger, if one exists. Otherwise, you will be prompted -for what debugger to use. If the prefix ARG is set, prompt anyway." - (interactive "P") - (when (or arg (null (+debugger--get-last-config))) - (+debugger--set-config (+debugger-completing-read))) - (+debugger/start-last)) - -;;;###autoload -(defun +debugger/quit () - "Quit the active debugger, if any." - (interactive) - (cond ((and (fboundp 'dap--cur-session) (dap--cur-session)) - (dap-disconnect (dap--cur-session))) - ((and (fboundp 'realgud-get-cmdbuf) (realgud-get-cmdbuf)) - (let ((buf (realgud-get-cmdbuf))) - (ignore-errors - (call-interactively #'realgud:cmd-quit)) - (let (realgud-safe-mode) - (kill-buffer buf)))) - ((user-error "No debugging session to quit")))) - -;; TODO debugger breakpoint commands -;; ;;;###autoload -;; (defun +debugger/toggle-breakpoint () -;; (interactive) -;; (user-error "not implemented yet")) - -;; ;;;###autoload -;; (defun +debugger/next-breakpoint () -;; (interactive) -;; (user-error "not implemented yet")) - -;; ;;;###autoload -;; (defun +debugger/previous-breakpoint () -;; (interactive) -;; (user-error "not implemented yet")) diff --git a/.config/emacs/modules/tools/debugger/autoload/evil.el b/.config/emacs/modules/tools/debugger/autoload/evil.el @@ -1,34 +0,0 @@ -;; tools/debugger/autoload/evil.el -*- lexical-binding: t; -*- -;;;###if (modulep! :editor evil) - -;;;###autoload (autoload '+debugger:start "tools/debugger/autoload/evil" nil t) -(evil-define-command +debugger:start (&optional path) - "Initiate debugger for current major mode" - (interactive "<f>") - ;; TODO Add python debugging - (let ((default-directory (doom-project-root))) - (pcase major-mode - ((or 'c-mode 'c++-mode) - (realgud:gdb (if path (concat "gdb " path)))) - ('ruby-mode - ;; FIXME - (doom:repl nil (format "run '%s'" (file-name-nondirectory (or path buffer-file-name))))) - ('sh-mode - (let ((shell sh-shell)) - (when (string= shell "sh") - (setq shell "bash")) - (pcase shell - ("bash" - (realgud:bashdb (if path (concat "bashdb " path)))) - ("zsh" - (realgud:zshdb (if path (concat "zshdb " path)))) - (_ (user-error "No shell debugger for %s" shell))))) - ((or 'js-mode 'js2-mode 'js3-mode) - (realgud:trepanjs)) - ('haskell-mode (haskell-debug)) - (_ (user-error "No debugger for %s" major-mode))))) - -;;;###autoload (autoload '+debugger:toggle-breakpoint "tools/debugger/autoload/evil" nil t) -(evil-define-command +debugger:toggle-breakpoint (&optional bang) - (interactive "<!>") - (call-interactively (if bang #'realgud:cmd-clear #'realgud:cmd-break))) diff --git a/.config/emacs/modules/tools/debugger/config.el b/.config/emacs/modules/tools/debugger/config.el @@ -1,160 +0,0 @@ -;;; tools/debugger/config.el -*- lexical-binding: t; -*- - -(defvar +debugger--realgud-alist - '((realgud:bashdb :modes (sh-mode)) - (realgud:gdb) - (realgud:gub :modes (go-mode)) - (realgud:kshdb :modes (sh-mode)) - (realgud:pdb :modes (python-mode)) - (realgud:perldb :modes (perl-mode perl6-mode)) - (realgud:rdebug :modes (ruby-mode)) - (realgud:remake) - (realgud:trepan :modes (perl-mode perl6-mode)) - (realgud:trepan2 :modes (python-mode)) - (realgud:trepan3k :modes (python-mode)) - (realgud:trepanjs :modes (javascript-mode js2-mode js3-mode)) - (realgud:trepanpl :modes (perl-mode perl6-mode raku-mode)) - (realgud:zshdb :modes (sh-mode)))) - -(defvar +debugger--dap-alist - `(((:lang cc +lsp) :after ccls :require (dap-lldb dap-gdb-lldb)) - ((:lang elixir +lsp) :after elixir-mode :require dap-elixir) - ((:lang go +lsp) :after go-mode :require dap-dlv-go) - ((:lang java +lsp) :after java-mode :require lsp-java) - ((:lang php +lsp) :after php-mode :require dap-php) - ((:lang python +lsp) :after python :require dap-python) - ((:lang ruby +lsp) :after ruby-mode :require dap-ruby) - ((:lang rust +lsp) :after rustic-mode :require (dap-lldb dap-cpptools)) - ((:lang javascript +lsp) - :after (js2-mode typescript-mode) - :require (dap-node dap-chrome dap-firefox ,@(if IS-WINDOWS '(dap-edge))))) - "TODO") - - -;; -;;; Packages - -;;;###package gdb -(setq gdb-show-main t - gdb-many-windows t) - -(use-package! projectile-variable - :defer t - :commands (projectile-variable-put - projectile-variable-get - projectile-variable-alist - projectile-variable-plist)) - -(use-package! realgud - :defer t - :init - (use-package! realgud-trepan-ni - :defer t - :init (add-to-list '+debugger--realgud-alist - '(realgud:trepan-ni :modes (javascript-mode js2-mode js3-mode) - :package realgud-trepan-ni))) - - ;; Realgud doesn't generate its autoloads properly so we do it ourselves - (dolist (debugger +debugger--realgud-alist) - (autoload (car debugger) - (if-let (sym (plist-get (cdr debugger) :package)) - (symbol-name sym) - "realgud") - nil t)) - - :config - (set-popup-rule! "^\\*\\(?:trepanjs:\\(?:g\\|zsh\\|bash\\)db\\|pdb \\)" - :size 20 :select nil :quit nil) - - (defadvice! +debugger--cleanup-after-realgud-a (&optional buf) - "Kill command buffer when debugging session ends (which closes its popup)." - :after #'realgud:terminate - (when (stringp buf) - (setq buf (get-buffer buf))) - (when-let (cmdbuf (realgud-get-cmdbuf buf)) - (let (kill-buffer-hook) - (kill-buffer buf)))) - - ;; Monkey-patch `realgud:run-process' to run in a popup. - ;; TODO Find a more elegant solution - ;; FIXME Causes realgud:cmd-* to focus popup on every invocation - (defadvice! +debugger--realgud-open-in-other-window-a - (debugger-name script-filename cmd-args minibuffer-history-var &optional no-reset) - :override #'realgud:run-process - (let* ((cmd-buf (apply #'realgud-exec-shell debugger-name script-filename - (car cmd-args) no-reset (cdr cmd-args))) - (process (get-buffer-process cmd-buf))) - (cond ((and process (eq 'run (process-status process))) - (pop-to-buffer cmd-buf) - (when (boundp 'evil-emacs-state-local-map) - (define-key evil-emacs-state-local-map (kbd "ESC ESC") #'+debugger/quit)) - (realgud:track-set-debugger debugger-name) - (realgud-cmdbuf-info-in-debugger?= 't) - (realgud-cmdbuf-info-cmd-args= cmd-args) - (when cmd-buf - (switch-to-buffer cmd-buf) - (when realgud-cmdbuf-info - (let* ((info realgud-cmdbuf-info) - (cmd-args (realgud-cmdbuf-info-cmd-args info)) - (cmd-str (mapconcat #'identity cmd-args " "))) - (if (boundp 'starting-directory) - (realgud-cmdbuf-info-starting-directory= starting-directory)) - (set minibuffer-history-var - (cl-remove-duplicates (cons cmd-str (eval minibuffer-history-var)) - :from-end t)))))) - (t - (if cmd-buf (switch-to-buffer cmd-buf)) - (message "Error running command: %s" (mapconcat #'identity cmd-args " ")))) - cmd-buf))) - - -(use-package! dap-mode - :when (and (modulep! +lsp) (not (modulep! :tools lsp +eglot))) - :hook (dap-mode . dap-tooltip-mode) - :init - (setq dap-breakpoints-file (concat doom-data-dir "dap-breakpoints") - dap-utils-extension-path (concat doom-data-dir "dap-extension/")) - (after! lsp-mode (require 'dap-mode)) - :config - (pcase-dolist (`((,category . ,modules) :after ,after :require ,libs) - +debugger--dap-alist) - (when (doom-module-p category (car modules) (cadr modules)) - (dolist (lib (ensure-list after)) - (with-eval-after-load lib - (mapc #'require (ensure-list libs)))))) - - (dap-mode 1) - - (define-minor-mode +dap-running-session-mode - "A mode for adding keybindings to running sessions" - :init-value nil - :keymap (make-sparse-keymap) - (when (bound-and-true-p evil-mode) - (evil-normalize-keymaps)) ; if you use evil, this is necessary to update the keymaps - ;; The following code adds to the dap-terminated-hook so that this minor - ;; mode will be deactivated when the debugger finishes - (when +dap-running-session-mode - (let ((session-at-creation (dap--cur-active-session-or-die))) - (add-hook 'dap-terminated-hook - (lambda (session) - (when (eq session session-at-creation) - (+dap-running-session-mode -1))))))) - - ;; Activate this minor mode when dap is initialized - (add-hook 'dap-session-created-hook #'+dap-running-session-mode) - ;; Activate this minor mode when hitting a breakpoint in another file - (add-hook 'dap-stopped-hook #'+dap-running-session-mode) - ;; Activate this minor mode when stepping into code in another file - (add-hook 'dap-stack-frame-changed-hook (lambda (session) - (when (dap--session-running session) - (+dap-running-session-mode 1)))) - - (map! :localleader - :map +dap-running-session-mode-map - "d" #'dap-hydra)) - - -(use-package! dap-ui - :when (and (modulep! +lsp) (not (modulep! :tools lsp +eglot))) - :hook (dap-mode . dap-ui-mode) - :hook (dap-ui-mode . dap-ui-controls-mode)) diff --git a/.config/emacs/modules/tools/debugger/doctor.el b/.config/emacs/modules/tools/debugger/doctor.el @@ -1,4 +0,0 @@ -;;; tools/debugger/doctor.el -*- lexical-binding: t; -*- - -(when (and (modulep! +lsp) (modulep! :tools lsp +eglot)) - (warn! "+lsp flag is not compatible with :tools (lsp +eglot). Choose only one of (eglot or dap-mode) please")) diff --git a/.config/emacs/modules/tools/debugger/packages.el b/.config/emacs/modules/tools/debugger/packages.el @@ -1,10 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; tools/debugger/packages.el - -(when (package! realgud :pin "aff03aeef1e40d2abb244240bab9787f4b3e6035") - (when (modulep! :lang javascript) - (package! realgud-trepan-ni :pin "0ec088ea343835e24ae73da09bea96bfb02a3130"))) - -(when (modulep! +lsp) - (package! dap-mode :pin "39bfaf1a3400b3ca4e9755f4d15e33abb0dda2c4") - (package! posframe :pin "06b939cfb06168782fc378043ff35bd7fec203b8")) diff --git a/.config/emacs/modules/tools/direnv/README.org b/.config/emacs/modules/tools/direnv/README.org @@ -1,96 +0,0 @@ -#+title: :tools direnv -#+subtitle: Save (or destroy) the environment at your leisure -#+created: April 05, 2019 -#+since: 21.12.0 - -* Description :unfold: -This module integrates direnv into Emacs. - -#+begin_quote - 📌 direnv is an environment switcher for the shell. It knows how to hook into - bash, zsh, tcsh, fish shell and elvish to load or unload environment - variables depending on the current directory. This allows project-specific - environment variables without cluttering the ~/.profile file. - - Before each prompt, direnv checks for the existence of a ".envrc" file in - the current and parent directories. If the file exists (and is authorized), - it is loaded into a bash sub-shell and all exported variables are then - captured by direnv and then made available to the current shell. -#+end_quote - -** Maintainers -- [[doom-user:][@hlissner]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:envrc]] - -** Hacks -- ~envrc-mode~ has been modified to fail gracefully if ~direnv~ isn't available. -- ~envrc-global-mode~ has been modified to activate envrc-mode sooner in the - major mode activation process, so that any env state performed in mode hooks - aren't overwritten by direnv. -- Added direnv support for Org src blocks. - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires [[https://direnv.net/][direnv]]. - -** MacOS -#+begin_src sh -brew install direnv -#+end_src - -** Arch Linux -~direnv~ is available on the AUR: -#+begin_src sh -yay -S direnv -#+end_src - -** NixOS -#+begin_src nix -environment.systemPackages = [ pkgs.direnv ]; -#+end_src - -Or ~$ nix-env -i direnv~ - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -To make use of direnv you need a =.envrc= file in a directory. Any time you open -a file or buffer in said directory, the [[doom-package:envrc]] Emacs package will kick in, -activate the local env, and inject it into Emacs for the current buffer. - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -[[doom-report:][Report an issue?]] - -** direnv + nix is slow -Consider augmenting direnv with [[https://github.com/nix-community/lorri][lorri]], which will cache nix builds and speed up -direnv tremendously: -#+begin_src nix -services.lorri.enable = true; -#+end_src - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/tools/direnv/config.el b/.config/emacs/modules/tools/direnv/config.el @@ -1,41 +0,0 @@ -;;; tools/direnv/config.el -*- lexical-binding: t; -*- - -(use-package! envrc - :hook (doom-first-file . envrc-global-mode) - :config - (add-to-list 'doom-debug-variables 'envrc-debug) - - (set-popup-rule! "^\\*envrc\\*" :quit t :ttl 0) - - ;; HACK: Normally, envrc updates on `after-change-major-mode-hook' (runs after - ;; a major mode's body and hooks). IMHO, this is too late; a mode's hooks - ;; might depend on environmental state that direnv sets up (e.g. starting an - ;; LSP server that expects project-specific envvars), so I move it to - ;; `change-major-mode-after-body-hook' instead, which runs before said - ;; hooks, but not the body. - (add-hook! 'envrc-global-mode-hook - (defun +direnv-init-global-mode-earlier-h () - (let ((fn #'envrc-global-mode-enable-in-buffers)) - (if (not envrc-global-mode) - (remove-hook 'change-major-mode-after-body-hook fn) - (remove-hook 'after-change-major-mode-hook fn) - (add-hook 'change-major-mode-after-body-hook fn 100))))) - - ;; ...However, the above hack causes envrc to trigger in its own, internal - ;; buffers, causing extra direnv errors. - (defadvice! +direnv--debounce-update-a (&rest _) - "Prevent direnv from running multiple times, consecutively in a buffer." - :before-while #'envrc--update - (not (string-prefix-p "*envrc" (buffer-name)))) - - (defadvice! +direnv--fail-gracefully-a (&rest _) - "Don't try to use direnv if the executable isn't present." - :before-while #'envrc-global-mode - (or (executable-find envrc-direnv-executable) - (ignore (doom-log "Failed to locate direnv executable; aborting envrc-global-mode")))) - - ;; Ensure babel's execution environment matches the host buffer's. - (advice-add #'org-babel-execute-src-block :around #'envrc-propagate-environment) - - ;; Make sure any envrc changes are propagated after a `doom/reload' - (add-hook 'doom-after-reload-hook #'envrc-reload-all)) diff --git a/.config/emacs/modules/tools/direnv/doctor.el b/.config/emacs/modules/tools/direnv/doctor.el @@ -1,4 +0,0 @@ -;;; tools/direnv/doctor.el -*- lexical-binding: t; -*- - -(unless (executable-find "direnv") - (warn! "Couldn't find direnv executable")) diff --git a/.config/emacs/modules/tools/direnv/packages.el b/.config/emacs/modules/tools/direnv/packages.el @@ -1,4 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; tools/direnv/packages.el - -(package! envrc :pin "1954e8c0b5c8440ea9852eeb7c046a677fa544f6") diff --git a/.config/emacs/modules/tools/docker/README.org b/.config/emacs/modules/tools/docker/README.org @@ -1,148 +0,0 @@ -#+title: :tools docker -#+subtitle: Yo dawg, I heard you like OSes, so I… -#+created: September 06, 2018 -#+since: 21.12.0 - -* Description :unfold: -This module allows you to manipulate Docker images, containers, and more from -Emacs. - -Provides a major ~dockerfile-mode~ to edit =Dockerfiles=. Additional convenience -functions allow images to be built easily. - -[[doom-package:docker-tramp]] offers [[https://www.gnu.org/software/tramp/][TRAMP]] support for Docker containers. - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +lsp :: - Enable integration for the Dockerfile Language Server. - -** Packages -- [[doom-package:docker]] -- [[doom-package:docker-tramp]] -- [[doom-package:dockerfile-mode]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module assumes =docker=, =docker-compose= and =docker-machine= binaries are -installed and accessible from your PATH. - -Optionally, this module also uses the following programs: -- =docker-langserver= (for LSP users): ~$ npm install -g - dockerfile-language-server-nodejs~ - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** Docker control -Use ~M-x docker~, select a resource, and then mark or unmark items using the -following keybindings (for more marking possibilities, check out -[[github:politza/tablist][politza/tablist]]): -| Binding | Description | -|-----------+----------------------| -| [[kbd:][?]] | List actions | -| [[kbd:][l]] | Configure listing | -| [[kbd:][m]] | Mark item | -| [[kbd:][u]] | Unmark item | -| [[kbd:][t]] | Toggle marks | -| [[kbd:][U]] | Unmark all | -| [[kbd:][s]] | Sort | -| [[kbd:][* r]] | Mark items by regexp | -| [[kbd:][<]] | Shrink column | -| [[kbd:][>]] | Enlarge column | -| [[kbd:][C-c C-e]] | Export to csv | - -*** Supported commands -- ~docker container~: ~attach~, ~cp~, ~diff~, ~inspect~, ~kill~, ~logs~, - ~pause~, ~rename~, ~restart~, ~rm~, ~start~, ~stop~, ~unpause~ -- ~docker image~: ~inspect~, ~pull~, ~push~, ~rm~, ~run~, ~tag~ -- ~docker network~: ~rm~ -- ~docker volume~: ~rm~ -- ~docker-machine~: ~create~, ~env~, ~restart~, ~rm~, ~start~, ~stop~ -- ~docker-compose~: ~build~, ~config~, ~create~, ~down~, ~exec~, ~logs~, ~pull~, - ~push~, ~remove~, ~restart~, ~run~, ~start~, ~stop~, ~up~ - - You can also enter =dired= or open a file inside a container or volume. - -** TRAMP -Offers the [[https://www.gnu.org/software/tramp/][TRAMP]] method =docker= to access running containers: -#+begin_example -C-x C-f /docker:$USER@$CONTAINER:/path/to/file -#+end_example - -| =$USER= | the user that you want to use (optional) | -| =$CONTAINER= | the id or name of the container | - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** Popups -Thanks to [[https://github.com/magit/magit-popup][magit-popup]], all the popups default arguments can be customized. For -example, here is how to customize the arguments for =docker-image-run-popup=: -#+begin_src emacs-lisp -(setq docker-image-run-arguments '("-i" "-t" "--rm")) -#+end_src - -or inside a =use-package= declaration: -#+begin_src emacs-lisp -(use-package! docker - :bind ("C-c d" . docker) - :custom (docker-image-run-arguments '("-i" "-t" "--rm"))) -#+end_src - -*** Other useful variables -| Variable | Description | Default | -|-------------------------------------+---------------------------------------+------------------| -| ~docker-command~ | The docker binary to use | ~docker~ | -| ~docker-container-default-sort-key~ | Sort key for docker containers | ~("Image")~ | -| ~docker-container-shell-file-name~ | Shell to use when entering containers | ~/bin/bash~ | -| ~docker-image-default-sort-key~ | Sort key for docker images | ~("Repository")~ | -| ~docker-machine-default-sort-key~ | Sort key for docker machines | ~("Name")~ | -| ~docker-network-default-sort-key~ | Sort key for docker networks | ~("Name")~ | -| ~docker-run-as-root~ | Run docker as root | ~nil~ | -| ~docker-volume-default-sort-key~ | Sort key for docker volumes | ~("Driver")~ | - -** Completion in Dockerfiles -By default, the keyword completion function detects the =docker-compose= version -of the current buffer and suggests the appropriate keywords. - -You can change the candidates offered by the backend by customizing -=docker-compose-keywords=. - -* Troubleshooting -[[doom-report:][Report an issue?]] - -** Tramp hangs on Alpine container -Busyboxes built with the =ENABLE_FEATURE_EDITING_ASK_TERMINAL= config option -also send escape sequences, which =tramp-wait-for-output= doesn't ignore -correctly. This was [[http://git.savannah.gnu.org/cgit/tramp.git/commit/?id=98a511248a9405848ed44de48a565b0b725af82c][fixed in TRAMP upstream]] and is available since TRAMP 2.3. - -For older versions of TRAMP you can dump [[https://github.com/emacs-pe/docker-tramp.el/blob/master/docker-tramp-compat.el][docker-tramp-compat.el]] in your -~load-path~ somewhere and add the following to =$DOOMDIR/config.el= to overwrite -~tramp-wait-for-output~ with the patch applied: -#+begin_src emacs-lisp -(after! tramp - (require 'docker-tramp-compat)) -#+end_src - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/tools/docker/config.el b/.config/emacs/modules/tools/docker/config.el @@ -1,7 +0,0 @@ -;;; tools/docker/config.el -*- lexical-binding: t; -*- - -(after! dockerfile-mode - (set-docsets! 'dockerfile-mode "Docker") - - (when (modulep! +lsp) - (add-hook 'dockerfile-mode-local-vars-hook #'lsp! 'append))) diff --git a/.config/emacs/modules/tools/docker/packages.el b/.config/emacs/modules/tools/docker/packages.el @@ -1,8 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; tools/docker/packages.el - -(package! docker :pin "cc0046e6a557dce0ccc4108dd22e04f21ba8b0dc") -;; tramp-container (included with Emacs 29+) replaces docker-tramp -(when (< emacs-major-version 29) - (package! docker-tramp :pin "930d7b46c180d8a13240a028c1b40af84f2a3219")) -(package! dockerfile-mode :pin "52c6c00da1d31c0b6c29c74335b3af63ed6bf06c") diff --git a/.config/emacs/modules/tools/editorconfig/README.org b/.config/emacs/modules/tools/editorconfig/README.org @@ -1,87 +0,0 @@ -#+title: :tools editorconfig -#+subtitle: Let someone else argue tabs and spaces -#+created: December 27, 2015 -#+since: 0.9 - -* Description :unfold: -This module integrates [[https://editorconfig.org/][EditorConfig]] into Emacs, allowing users to dictate code -style on a per-project basis with an =.editorconfig= file ([[https://editorconfig-specification.readthedocs.io/][formal -specification]]). - -** Maintainers -- [[doom-user:][@hlissner]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:editorconfig-emacs]] - -** Hacks -- Added logic to guess an extension-less file's type from its shebang line. For - example, editorconfig rules for =*.py= files will apply to =bin/myscript= - assuming its first line is ~#!/usr/bin/env python~. See - ~+editorconfig-mode-alist~ for adding support for more languages. -- *Special integration for =dtrt-indent=:* If the local editorconfig file - specifies ~indent_style~ or ~indent_size~, the [[doom-package:dtrt-indent]] (which tries to - guess your indent settings by analyzing your text file) will bow out. -- *Special integration for =ws-butler=:* this module will use [[doom-package:ws-butler]] to - enforce ~trim_trailing_whitespace~. - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module has one optional dependency: the ~editorconfig~ native binary. -Without it, a built-in elisp implementation will be used, but it has fewer -features and can be a bit slower. - -The editorconfig binary has [[https://github.com/editorconfig#contributing][many implementations]] you can choose from, typically -available through your OS package manager (or build it yourself). - -* Usage -You will need to write an ~.editorconfig~ file in your project (this is usually -in the root of your project) you can find out about all the properties [[https://editorconfig.org/#example-file][here]]. - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** Adding support for more major modes -Out the box, the editorconfig plugin supports many Emacs major modes, but it's -possible you'll find one it doesn't support. Adding support is easy so long as -you know that mode's indentation variables. For example, ~coffee-mode~ has a -~coffee-tab-width~ variable that controls indentation width in CoffeeScript -files. Editorconfig already supports this language, but let's pretend it -doesn't: - -The ~editorconfig-indentation-alist~ variable contains a list of major modes and -their indentation variables. To add coffee-mode to it: -#+begin_src emacs-lisp -;; in $DOOMDIR/config.el -(after! editorconfig - (add-to-list 'editorconfig-indentation-alist '(coffee-mode coffee-tab-width))) -#+end_src - -But what if you don't know the correct indentation variable(s). Use [[kbd:][SPC h v]] ([[kbd:][C-h -v]] for non-evil users) to peruse all the available variables in your current -session of Emacs. Look for variables that have the words =indent=, =offset= or -=tab-width= in them. They will be prefixed with the plugin they belong to (e.g. -~rustic-indent-offset~). - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/tools/editorconfig/autoload.el b/.config/emacs/modules/tools/editorconfig/autoload.el @@ -1,7 +0,0 @@ -;;; tools/editorconfig/autoload.el -*- lexical-binding: t; -*- - -;;;###autodef -(defun set-editorconfig-indent-var! (mode &rest vars) - "Add (MODE VARS...) to `editorconfig-indentation-alist'." - (after! editorconfig - (nconc editorconfig-indentation-alist (cons mode vars)))) diff --git a/.config/emacs/modules/tools/editorconfig/config.el b/.config/emacs/modules/tools/editorconfig/config.el @@ -1,53 +0,0 @@ -;;; tools/editorconfig/config.el -*- lexical-binding: t; -*- - -;; editorconfig cannot procure the correct settings for extension-less files. -;; Executable scripts with a shebang line, for example. So why not use Emacs' -;; major mode to drop editorconfig a hint? This is accomplished by temporarily -;; appending an extension to `buffer-file-name' when we talk to editorconfig. -(defvar +editorconfig-mode-alist - '((emacs-lisp-mode . "el") - (js2-mode . "js") - (perl-mode . "pl") - (php-mode . "php") - (python-mode . "py") - (ruby-mode . "rb") - (sh-mode . "sh")) - "An alist mapping major modes to extensions. Used by -`doom--editorconfig-smart-detection-a' to give editorconfig filetype hints.") - - -;; Handles whitespace (tabs/spaces) settings externally. This way projects can -;; specify their own formatting rules. -(use-package! editorconfig - :hook (doom-first-buffer . editorconfig-mode) - :config - (when (require 'ws-butler nil t) - (setq editorconfig-trim-whitespaces-mode 'ws-butler-mode)) - - ;; Fix #5057 archives don't need editorconfig settings, and they may otherwise - ;; interfere with the process of opening them (office formats are zipped XML - ;; formats). - (add-to-list 'editorconfig-exclude-regexps - "\\.\\(zip\\|\\(doc\\|xls\\|ppt\\)x\\)\\'") - - (defadvice! +editorconfig--smart-detection-a (fn) - "Retrieve the properties for the current file. If it doesn't have an -extension, try to guess one." - :around #'editorconfig-call-editorconfig-exec - (let ((buffer-file-name - (if (and (not (bound-and-true-p org-src-mode)) - (file-name-extension buffer-file-name)) - buffer-file-name - (format "%s%s" (buffer-file-name (buffer-base-buffer)) - (if-let (ext (alist-get major-mode +editorconfig-mode-alist)) - (concat "." ext) - ""))))) - (funcall fn))) - - (add-hook! 'editorconfig-after-apply-functions - (defun +editorconfig-disable-indent-detection-h (props) - "Inhibit `dtrt-indent' if an explicit indent_style and indent_size is -specified by editorconfig." - (when (or (gethash 'indent_style props) - (gethash 'indent_size props)) - (setq doom-inhibit-indent-detection 'editorconfig))))) diff --git a/.config/emacs/modules/tools/editorconfig/doctor.el b/.config/emacs/modules/tools/editorconfig/doctor.el @@ -1,5 +0,0 @@ -;; -*- lexical-binding: t; no-byte-compile: t; -*- -;;; tools/editorconfig/doctor.el - -(unless (executable-find "editorconfig") - (warn! "Couldn't find the editorconfig binary. Using native elisp version (slower)")) diff --git a/.config/emacs/modules/tools/editorconfig/packages.el b/.config/emacs/modules/tools/editorconfig/packages.el @@ -1,6 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; tools/editorconfig/packages.el - -(package! editorconfig - :recipe (:nonrecursive t) - :pin "6f6b5c1a95a7fd326915fedcf6de634fe0d79999") diff --git a/.config/emacs/modules/tools/ein/README.org b/.config/emacs/modules/tools/ein/README.org @@ -1,53 +0,0 @@ -#+title: :tools ein -#+subtitle: Tame Jupyter notebooks with emacs -#+created: April 11, 2018 -#+since: 21.12.0 (#524) - -* Description :unfold: -Adds [[https://jupyter.org/][Jupyter]] notebook integration into Emacs. - -** Maintainers -*This module needs a maintainer.* [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:ein]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* TODO Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -#+begin_quote - 🔨 /This module's prerequisites are not documented./ [[doom-contrib-module:][Document them?]] -#+end_quote - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -Refer to [[https://github.com/millejoh/emacs-ipython-notebook][millejoh/emacs-ipython-notebook's README]]. - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/tools/ein/config.el b/.config/emacs/modules/tools/ein/config.el @@ -1,16 +0,0 @@ -;;; tools/ein/config.el -*- lexical-binding: t; -*- - -;; -;;; Packages - -(after! ein-notebook - (set-popup-rule! "^\\*ein:" :ignore t) - - (defun +ein-buffer-p (buf) - (or (memq buf (ein:notebook-opened-buffers)) - (memq buf (mapcar #'ein:notebooklist-get-buffer (ein:notebooklist-keys))))) - (add-to-list 'doom-real-buffer-functions #'+ein-buffer-p nil #'eq) - (map! :map ein:notebook-mode-map - "M-s" #'ein:notebook-save-notebook-command-km - :map ein:notebooklist-mode-map - "o" #'ein:notebook-open-km)) diff --git a/.config/emacs/modules/tools/ein/packages.el b/.config/emacs/modules/tools/ein/packages.el @@ -1,4 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; tools/ein/packages.el - -(package! ein :pin "b2410dc96f61aa806a7934099d8f1e40c8f6ca18") diff --git a/.config/emacs/modules/tools/ein/test/test-ein.el b/.config/emacs/modules/tools/ein/test/test-ein.el @@ -1,23 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; tools/ein/test/test-ein.el - -(describe "tools/ein" - :var (project-root) - - (require! :tools ein) - (require 'ein-notebook) - - (before-each - (spy-on 'doom-project-root :and-call-fake (lambda () project-root))) - - (it "keymap defs still valid" - (dolist (km (list ein:notebook-mode-map ein:notebooklist-mode-map)) - (cl-labels ((validate-km - (km) - (map-keymap (lambda (type def) - (cond ((keymapp def) - (validate-km def)) - (t (should-not - (and (symbolp def) (not (commandp def))))))) - km))) - (validate-km km))))) diff --git a/.config/emacs/modules/tools/eval/README.org b/.config/emacs/modules/tools/eval/README.org @@ -1,134 +0,0 @@ -#+title: :tools eval -#+subtitle: Run code, run (also, repls) -#+created: February 20, 2017 -#+since: 2.0.0 - -* Description :unfold: -This modules adds inline code evaluation support to Emacs and a universal -interface for opening and interacting with REPLs. - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +overlay :: - Enable the use of overlays (near the cursor) to display the result of inline - code evaluation (rather than the minibuffer). If the results are too big the - minibuffer will be used anyway. - -** Packages -- [[doom-package:quickrun]] - -** Hacks -- Quickrun has been modified to: - - Use only one output window, in case of consecutive execution of code. - - The quickrun window will resize itself to fit its output, once the - underlying process is finished executing the code. - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module has no direct prerequisites. - -However, many languages will require that you install their interpreters, code -runners and/or repls to power the functionality of this module. Visit the -documentation of their respective [[doom-module::lang]] module for instructions. - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** Inline Code Evaluation -Quickrun can be invoked via: -- ~M-x +eval/buffer~ (or [[kbd:][gR]], or [[kbd:][M-r]]) -- ~M-x +eval/region~ -- ~M-x +eval/region-and-replace~ -- Evil users can use the [[kbd:][gr]] operator to select and run a region. - -** REPLs -Invoked via: -- [[kbd:][SPC o r]] or ~:repl~ will open a REPL in a popup window. [[kbd:][SPC o R]] or ~:repl!~ - will open a REPL in the current window. If a REPL is already open and a - selection is active, it will be sent to the REPL. -- ~M-x +eval/open-repl-other-window~ ([[kbd:][SPC o r]]) -- ~M-x +eval/open-repl-same-window~ ([[kbd:][SPC o R]]) -- ~M-x +eval/send-region-to-repl~ ([[kbd:][SPC c s]]) while a selection (and REPL) is - active - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** Register a REPL for a major-mode -REPLs are defined for most languages Doom supports. Check that language module's -README.org to see if it does (and if it requires additional setup). - -To use them, you may use ~M-x +eval/open-repl-other-window~, ~M-x -+eval/open-repl-same-window~, ~:repl~ (for evil users) or the default binding: -[[kbd:][SPC o r]]. These will open a REPL in a popup window. - -#+begin_quote -You can simply call that mode's REPL command manually. e.g. ~M-x ielm~, but this -will bar you from the benefits of Doom's REPL system (like send-to-repl -functionality). -#+end_quote - -Otherwise, you can define your own for a specified major mode: - -~(set-repl-handler! MAJOR-MODES FUNCTION)~ - -=MAJOR-MODES= is a single major mode symbol or a list of them. - -=FUNCTION= should return a repl buffer. Any window changes in this function are -ignored, then the REPL is opened in a popup window. E.g. -#+begin_src emacs-lisp -(defun +lua/open-repl () - (interactive) - (lua-start-process "lua" "lua") - (pop-to-buffer lua-process-buffer)) - -(set-repl-handler! 'lua-mode #'+lua/open-repl) -#+end_src - -** Change how code is evaluated in a major mode -Run regions or entire buffers with [[https://github.com/syohex/emacs-quickrun][Quickrun]]. Output is show in a popup window. - -Quickrun includes support for many languages, usually by sending text directly -to interpreters or compilers. However, occasionally, you'll find a language -without support (like [[https://crystal-lang.org/][Crystal]]), or a language with better Emacs integration -(like elisp). - -To define a "runner": -#+begin_src emacs-lisp -(set-eval-handler! 'crystal-mode - '((:command . "crystal") - (:exec . "%c %s") - (:description . "Run Crystal script"))) -#+end_src - -A simpler version is simply to use the path to the binary: -#+begin_src emacs-lisp -(set-eval-handler! 'groovy-mode "groovy") -#+end_src - -Or if you'd rather run an elisp command: -#+begin_src emacs-lisp -(set-eval-handler! 'emacs-lisp-mode #'+emacs-lisp-eval) -#+end_src - -* TODO Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/tools/eval/autoload/eval.el b/.config/emacs/modules/tools/eval/autoload/eval.el @@ -1,172 +0,0 @@ -;;; tools/eval/autoload/eval.el -*- lexical-binding: t; -*- - -;;;###autoload -(defun +eval-display-results-in-popup (output &optional _source-buffer) - "Display OUTPUT in a popup buffer." - (let ((output-buffer (get-buffer-create "*doom eval*")) - (origin (selected-window))) - (with-current-buffer output-buffer - (setq-local scroll-margin 0) - (erase-buffer) - (insert output) - (goto-char (point-min)) - (if (fboundp '+word-wrap-mode) - (+word-wrap-mode +1) - (visual-line-mode +1))) - (when-let (win (display-buffer output-buffer)) - (fit-window-to-buffer - win (/ (frame-height) 2) - nil (/ (frame-width) 2))) - (select-window origin) - output-buffer)) - -;;;###autoload -(defun +eval-display-results-in-overlay (output &optional source-buffer) - "Display OUTPUT in a floating overlay next to the cursor." - (require 'eros) - (let* ((this-command #'+eval/buffer-or-region) - (prefix eros-eval-result-prefix) - (lines (split-string output "\n")) - (prefixlen (length prefix)) - (len (+ (apply #'max (mapcar #'length lines)) - prefixlen)) - (col (- (current-column) (window-hscroll))) - (next-line? (or (cdr lines) - (< (- (window-width) - (save-excursion (goto-char (point-at-eol)) - (- (current-column) - (window-hscroll)))) - len))) - (pad (if next-line? - (+ (window-hscroll) prefixlen) - 0)) - (where (if next-line? - (line-beginning-position 2) - (line-end-position))) - eros-eval-result-prefix - eros-overlays-use-font-lock) - (with-current-buffer (or source-buffer (current-buffer)) - (eros--make-result-overlay - (concat (make-string (max 0 (- pad prefixlen)) ?\s) - prefix - (string-join lines (concat "\n" (make-string pad ?\s)))) - :where where - :duration eros-eval-result-duration)))) - -;;;###autoload -(defun +eval-display-results (output &optional source-buffer) - "Display OUTPUT in an overlay or a popup buffer." - (funcall (if (or current-prefix-arg - (with-temp-buffer - (insert output) - (or (>= (count-lines (point-min) (point-max)) - +eval-popup-min-lines) - (>= (string-width - (buffer-substring (point-min) - (save-excursion - (goto-char (point-min)) - (line-end-position)))) - (window-width)))) - (not (require 'eros nil t))) - #'+eval-display-results-in-popup - #'+eval-display-results-in-overlay) - output source-buffer) - output) - - -;; -;;; Commands - -(defvar quickrun-option-cmdkey) -;;;###autoload -(defun +eval/buffer () - "Evaluate the whole buffer." - (interactive) - (let ((quickrun-option-cmdkey (bound-and-true-p quickrun-option-cmdkey))) - (if (or (assq major-mode +eval-runners) - (and (fboundp '+eval--ensure-in-repl-buffer) - (ignore-errors - (get-buffer-window (or (+eval--ensure-in-repl-buffer) - t)))) - (and (require 'quickrun nil t) - (equal (setq - quickrun-option-cmdkey - (quickrun--command-key - (buffer-file-name (buffer-base-buffer)))) - "emacs") - (alist-get 'emacs-lisp-mode +eval-runners))) - (if-let ((buffer-handler (plist-get (cdr (alist-get major-mode +eval-repls)) :send-buffer))) - (funcall buffer-handler) - (+eval/region (point-min) (point-max))) - (quickrun)))) - -;;;###autoload -(defun +eval/region (beg end) - "Evaluate a region between BEG and END and display the output." - (interactive "r") - (let ((load-file-name buffer-file-name) - (load-true-file-name - (or buffer-file-truename - (if buffer-file-name - (file-truename buffer-file-name))))) - (cond ((and (fboundp '+eval--ensure-in-repl-buffer) - (ignore-errors - (get-buffer-window (or (+eval--ensure-in-repl-buffer) - t)))) - (funcall (or (plist-get (cdr (alist-get major-mode +eval-repls)) :send-region) - #'+eval/send-region-to-repl) - beg end)) - ((let ((runner - (or (alist-get major-mode +eval-runners) - (and (require 'quickrun nil t) - (equal (setq - lang (quickrun--command-key - (buffer-file-name (buffer-base-buffer)))) - "emacs") - (alist-get 'emacs-lisp-mode +eval-runners)))) - lang) - (if runner - (funcall runner beg end) - (let ((quickrun-option-cmdkey lang)) - (quickrun-region beg end)))))))) - -;;;###autoload -(defun +eval/line-or-region () - "Evaluate the current line or selected region." - (interactive) - (if (use-region-p) - (call-interactively #'+eval/region) - (+eval/region (line-beginning-position) (line-end-position)))) - -;;;###autoload -(defun +eval/buffer-or-region () - "Evaluate the region if it's active, otherwise evaluate the whole buffer. - -If a REPL is open the code will be evaluated in it, otherwise a quickrun -runner will be used." - (interactive) - (call-interactively - (if (use-region-p) - #'+eval/region - #'+eval/buffer))) - -;;;###autoload -(defun +eval/region-and-replace (beg end) - "Evaluation a region between BEG and END, and replace it with the result." - (interactive "r") - (let (lang) - (cond - ((or (eq major-mode 'emacs-lisp-mode) - (and (require 'quickrun nil t) - (equal (setq - lang (quickrun--command-key - (buffer-file-name (buffer-base-buffer)))) - "emacs"))) - (kill-region beg end) - (condition-case nil - (prin1 (eval (read (current-kill 0))) - (current-buffer)) - (error (message "Invalid expression") - (insert (current-kill 0))))) - ((let ((quickrun-option-cmdkey lang)) - (quickrun-replace-region beg end)))))) diff --git a/.config/emacs/modules/tools/eval/autoload/evil.el b/.config/emacs/modules/tools/eval/autoload/evil.el @@ -1,23 +0,0 @@ -;; tools/eval/autoload/evil.el -*- lexical-binding: t; -*- -;;;###if (modulep! :editor evil) - -;;;###autoload (autoload '+eval:region "tools/eval/autoload/evil" nil t) -(evil-define-operator +eval:region (beg end) - "Evaluate selection or sends it to the open REPL, if available." - :move-point nil - (interactive "<r>") - (+eval/region beg end)) - -;;;###autoload (autoload '+eval:replace-region "tools/eval/autoload/evil" nil t) -(evil-define-operator +eval:replace-region (beg end) - "Evaluate selection and replace it with its result." - :move-point nil - (interactive "<r>") - (+eval/region-and-replace beg end)) - -;;;###autoload (autoload '+eval:repl "tools/eval/autoload/evil" nil t) -(evil-define-operator +eval:repl (_beg _end) - "Open REPL and send the current selection to it." - :move-point nil - (interactive "<r>") - (+eval/open-repl-other-window)) diff --git a/.config/emacs/modules/tools/eval/autoload/repl.el b/.config/emacs/modules/tools/eval/autoload/repl.el @@ -1,181 +0,0 @@ -;;; tools/eval/autoload/repl.el -*- lexical-binding: t; -*- - -(defvar +eval-repl-buffers (make-hash-table :test 'equal) - "The buffer of the last open repl.") - -(defvar-local +eval-repl-plist nil) - -(define-minor-mode +eval-repl-mode - "A minor mode for REPL buffers.") - -(defun +eval--ensure-in-repl-buffer (&optional fn plist displayfn) - (maphash (lambda (key buffer) - (unless (buffer-live-p buffer) - (remhash key +eval-repl-buffers))) - +eval-repl-buffers) - (let* ((project-root (doom-project-root)) - (key (cons major-mode project-root)) - (buffer (gethash key +eval-repl-buffers))) - (cl-check-type buffer (or buffer null)) - (unless (or (eq buffer (current-buffer)) - (null fn)) - (setq buffer - (funcall (or displayfn #'get-buffer-create) - (if (buffer-live-p buffer) - buffer - (setq buffer - (save-window-excursion - (if (commandp fn) - (call-interactively fn) - (funcall fn)))) - (cond ((null buffer) - (error "REPL handler %S couldn't open the REPL buffer" fn)) - ((not (bufferp buffer)) - (error "REPL handler %S failed to return a buffer" fn))) - (with-current-buffer buffer - (when plist - (setq +eval-repl-plist plist)) - (+eval-repl-mode +1)) - (puthash key buffer +eval-repl-buffers) - buffer)))) - (when (bufferp buffer) - (with-current-buffer buffer - (unless (or (derived-mode-p 'term-mode) - (eq (current-local-map) (bound-and-true-p term-raw-map))) - (goto-char (if (and (derived-mode-p 'comint-mode) - (cdr comint-last-prompt)) - (cdr comint-last-prompt) - (point-max))))) - buffer))) - -(defun +eval-repl-known-repls () - "Yield the available repl functions as a list of symbols." - (seq-uniq (mapcar (pcase-lambda (`(,mode ,fn . _)) (list mode fn)) +eval-repls))) - -(defun +doom-pretty-mode-name (mode) - "Convert a mode name into a variant nicer for human eyes." - (let ((mode (if (symbolp mode) (symbol-name mode) mode))) - (if (not (string-match "^\\([a-z-]+\\)-mode$" mode)) - (error "Given string/symbol is not a major mode: %s" mode) - (string-join (split-string (capitalize (match-string-no-properties 1 mode)) - "-") - " ")))) - -(defun +eval-repl-found-repls () - "Search the interned symbol list for functions that looks like -repl openers." - (cl-loop for sym being the symbols - for sym-name = (symbol-name sym) - if (string-match "^\\(?:\\+\\)?\\([^/]+\\)/open-\\(?:\\(.+\\)-\\)?repl$" sym-name) - collect - sym)) - -(defun +eval-pretty-mode-name-from-fn (fn) - "Given a symbol name of a repl-opening function, extract a -human-readable variant of its associated major mode name." - (let ((name (symbol-name fn))) - (if (not (string-match "^\\(?:\\+\\)?\\([^/]+\\)/open-\\(?:\\(.+\\)-\\)?repl$" name)) - (error "Given symbol is not a repl function: %s" name) - (string-join (split-string (capitalize (match-string-no-properties 1 name)) - "-") - " ")))) - -(defun +eval-repl-prompt () - "Prompt the user for the choice of a repl to open." - (let* ((knowns (mapcar (pcase-lambda (`(,mode ,fn)) (list (+doom-pretty-mode-name mode) fn)) - (+eval-repl-known-repls))) - (founds (mapcar (lambda (fn) (list (+eval-pretty-mode-name-from-fn fn) fn)) - (+eval-repl-found-repls))) - (repls (seq-uniq (append knowns founds))) - (names (mapcar #'cl-first repls)) - (choice (or (completing-read "Open a REPL for: " names) - (user-error "Aborting")))) - (cl-second (assoc choice repls)))) - -(defun +eval-repl-from-major-mode () - "Fetch the repl associated with the current major mode, if there -is one." - (pcase-let ((`(_ ,fn . ,plist) (assq major-mode +eval-repls))) - (list fn plist))) - -(defun +eval-open-repl (prompt-p &optional displayfn) - "Open a repl via the given DISPLAYFN. If PROMPT-P, the user will be -prompted for a repl choice, even if the major mode they're in -already has a known one." - (pcase-let* ((`(,fn ,plist) (+eval-repl-from-major-mode)) - (fn (cond ((or prompt-p (not fn)) (+eval-repl-prompt)) - (t fn))) - (region (when (use-region-p) - (buffer-substring-no-properties (region-beginning) - (region-end))))) - (unless (commandp fn) - (error "Couldn't find a valid REPL for %s" major-mode)) - (with-current-buffer (+eval--ensure-in-repl-buffer fn plist displayfn) - (when (bound-and-true-p evil-mode) - (call-interactively #'evil-append-line)) - (when region - (insert region)) - t))) - -;; -;;; Commands - -;;;###autoload -(defun +eval/open-repl-same-window (&optional arg) - "Opens (or reopens) the REPL associated with the current major-mode and place -the cursor at the prompt. - -If ARG (universal argument), prompt for a specific REPL to open." - (interactive "P") - (+eval-open-repl arg #'switch-to-buffer)) - -;;;###autoload -(defun +eval/open-repl-other-window (&optional arg) - "Does `+eval/open-repl', but in a popup window. - -If ARG (universal argument), prompt for a specific REPL to open." - (interactive "P") - (+eval-open-repl arg #'pop-to-buffer)) - -;;;###autoload -(defun +eval/send-region-to-repl (beg end &optional inhibit-auto-execute-p) - "Execute the selected region in the REPL. -Opens a REPL if one isn't already open. If AUTO-EXECUTE-P, then execute it -immediately after." - (interactive "rP") - (let ((selection (buffer-substring-no-properties beg end)) - (buffer (+eval--ensure-in-repl-buffer))) - (unless buffer - (error "No REPL open")) - (let ((origin-window (selected-window)) - (selection - (with-temp-buffer - (insert selection) - (goto-char (point-min)) - (when (> (skip-chars-forward "\n") 0) - (delete-region (point-min) (point))) - (indent-rigidly (point) (point-max) - (- (skip-chars-forward " \t"))) - (concat (string-trim-right (buffer-string)) - "\n")))) - (with-selected-window (get-buffer-window buffer) - (with-current-buffer buffer - (dolist (line (split-string selection "\n")) - (insert line) - (if inhibit-auto-execute-p - (insert "\n") - ;; Can't use `comint-send-input' b/c there's no guarantee the - ;; current REPL uses comint. Even if it did, no telling if they - ;; have their own `comint-send-input' wrapper, so to be safe, I - ;; simply emulate the keypress. - (call-interactively - (if (bound-and-true-p evil-local-mode) - (evil-save-state - (evil-insert-state) - (doom-lookup-key (kbd "RET"))) - (doom-lookup-key (kbd "RET"))))) - (sit-for 0.001) - (redisplay 'force))) - (when (and (eq origin-window (selected-window)) - (bound-and-true-p evil-local-mode)) - (call-interactively #'evil-append-line)))))) diff --git a/.config/emacs/modules/tools/eval/autoload/settings.el b/.config/emacs/modules/tools/eval/autoload/settings.el @@ -1,76 +0,0 @@ -;;; tools/eval/autoload/settings.el -*- lexical-binding: t; -*- - -;; -;; REPLs - -(defvar +eval-repls nil - "An alist mapping major modes to plists that describe REPLs. Used by -`+eval/open-repl-other-window' and filled with the `:repl' setting.") - -;;;###autodef -(defun set-repl-handler! (modes command &rest plist) - "Defines a REPL for MODES. - -MODES is either a single major mode symbol or a list of them. COMMAND is a -function that creates and returns the REPL buffer. - -COMMAND can either be a function that takes no arguments, or an interactive -command that will be called interactively. COMMANDS must return either the repl -buffer or a function that takes no arguments and returns the repl buffer. - -PLIST is a property list that map special attributes to this repl. These are -recognized: - - :persist BOOL - If non-nil, this REPL won't be killed when its window is closed. - :send-region FUNC - A function that accepts a BEG and END, and sends the contents of the region - to the REPL. Defaults to `+eval/send-region-to-repl'. - :send-buffer FUNC - A function of no arguments that sends the contents of the buffer to the REPL. - Defaults to `+eval/region', which will run the :send-region specified function - or `+eval/send-region-to-repl'." - (declare (indent defun)) - (dolist (mode (ensure-list modes)) - (setf (alist-get mode +eval-repls) - (cons command plist)))) - - -;; -;; Evaluation - -;;;###autoload -(defvar +eval-runners nil - "Alist mapping major modes to interactive runner functions.") - -;;;###autodef -(defun set-eval-handler! (modes command) - "Define a code evaluator for major mode MODES with `quickrun'. - -MODES can be list of major mode symbols, or a single one. - -1. If MODE is a string and COMMAND is the string, MODE is a file regexp and - COMMAND is a string key for an entry in `quickrun-file-alist'. -2. If MODE is not a string and COMMAND is a string, MODE is a major-mode symbol - and COMMAND is a key (for `quickrun--language-alist'), and will be registered - in `quickrun--major-mode-alist'. -3. If MODE is not a string and COMMAND is an alist, see `quickrun-add-command': - (quickrun-add-command MODE COMMAND :mode MODE). -4. If MODE is not a string and COMMANd is a symbol, add it to - `+eval-runners', which is used by `+eval/region'." - (declare (indent defun)) - (dolist (mode (ensure-list modes)) - (cond ((symbolp command) - (push (cons mode command) +eval-runners)) - ((stringp command) - (after! quickrun - (push (cons mode command) - (if (stringp mode) - quickrun-file-alist - quickrun--major-mode-alist)))) - ((listp command) - (after! quickrun - (quickrun-add-command - (or (cdr (assq mode quickrun--major-mode-alist)) - (string-remove-suffix "-mode" (symbol-name mode))) - command :mode mode)))))) diff --git a/.config/emacs/modules/tools/eval/config.el b/.config/emacs/modules/tools/eval/config.el @@ -1,101 +0,0 @@ -;;; tools/eval/config.el -*- lexical-binding: t; -*- - -(defvar +eval-popup-min-lines 4 - "The output height threshold (inclusive) before output is displayed in a popup -buffer rather than an overlay on the line at point or the minibuffer.") - -;; remove ellipsis when printing sexps in message buffer -(setq eval-expression-print-length nil - eval-expression-print-level nil) - - -;; -;;; Packages - -(set-popup-rule! - (lambda (bufname _) - (when (boundp '+eval-repl-mode) - (buffer-local-value '+eval-repl-mode (get-buffer bufname)))) - :ttl (lambda (buf) - (unless (plist-get +eval-repl-plist :persist) - (when-let (process (get-buffer-process buf)) - (set-process-query-on-exit-flag process nil) - (kill-process process) - (kill-buffer buf)))) - :size 0.25 :quit nil) - - -(after! quickrun - (setq quickrun-focus-p nil) - - (set-popup-rule! "^\\*quickrun" :size 0.3 :ttl 0) - - (defadvice! +eval--quickrun-fix-evil-visual-region-a () - "Make `quickrun-replace-region' recognize evil visual selections." - :override #'quickrun--outputter-replace-region - (let ((output (buffer-substring-no-properties (point-min) (point-max)))) - (with-current-buffer quickrun--original-buffer - (cl-destructuring-bind (beg . end) - ;; Because `deactivate-mark', the function, was used in - ;; `quickrun--region-command-common' instead of `deactivate-mark', - ;; the variable, the selection is disabled by this point. - (if (bound-and-true-p evil-local-mode) - (cons evil-visual-beginning evil-visual-end) - (cons (region-beginning) (region-end))) - (delete-region beg end) - (insert output)) - (setq quickrun-option-outputter quickrun--original-outputter)))) - - (defadvice! +eval--quickrun-auto-close-a (&rest _) - "Silently re-create the quickrun popup when re-evaluating." - :before '(quickrun quickrun-region) - (when-let (win (get-buffer-window quickrun--buffer-name)) - (let ((inhibit-message t)) - (quickrun--kill-running-process) - (message "")) - (delete-window win))) - - (add-hook! 'quickrun-after-run-hook - (defun +eval-quickrun-shrink-window-h () - "Shrink the quickrun output window once code evaluation is complete." - (when-let (win (get-buffer-window quickrun--buffer-name)) - (with-selected-window (get-buffer-window quickrun--buffer-name) - (let ((ignore-window-parameters t)) - (shrink-window-if-larger-than-buffer))))) - (defun +eval-quickrun-scroll-to-bof-h () - "Ensures window is scrolled to BOF on invocation." - (when-let (win (get-buffer-window quickrun--buffer-name)) - (with-selected-window win - (goto-char (point-min)))))) - - ;; Display evaluation results in an overlay at the end of the current line. If - ;; the output is more than `+eval-popup-min-lines' (4) lines long, it is - ;; displayed in a popup. - (when (modulep! +overlay) - (defadvice! +eval--show-output-in-overlay-a (fn) - :filter-return #'quickrun--make-sentinel - (lambda (process event) - (funcall fn process event) - (with-current-buffer quickrun--buffer-name - (when (> (buffer-size) 0) - (+eval-display-results - (string-trim (buffer-string)) - quickrun--original-buffer))))) - - ;; Suppress quickrun's popup window because we're using an overlay instead. - (defadvice! +eval--inhibit-quickrun-popup-a (buf cb) - :override #'quickrun--pop-to-buffer - (setq quickrun--original-buffer (current-buffer)) - (save-window-excursion - (with-current-buffer (pop-to-buffer buf) - (setq quickrun-option-outputter #'ignore) - (funcall cb)))) - - ;; HACK Without this, `+eval--inhibit-quickrun-popup-a' throws a - ;; window-live-p error because no window exists to be recentered! - (advice-add #'quickrun--recenter :override #'ignore))) - - -(use-package! eros - :when (modulep! +overlay) - :hook (emacs-lisp-mode . eros-mode)) diff --git a/.config/emacs/modules/tools/eval/packages.el b/.config/emacs/modules/tools/eval/packages.el @@ -1,6 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; tools/eval/packages.el - -(package! quickrun :pin "7a89313c07a21eae9cd69a1a98e2a134d559e04f") -(when (modulep! +overlay) - (package! eros :pin "dd8910279226259e100dab798b073a52f9b4233a")) diff --git a/.config/emacs/modules/tools/gist/README.org b/.config/emacs/modules/tools/gist/README.org @@ -1,55 +0,0 @@ -#+title: :tools gist -#+subtitle: A pastebin for Githubsters -#+created: May 07, 2017 -#+since: 2.0.3 - -#+begin_quote - 🚧 *This module is deprecated.* gist.el has been abandoned and is generally - buggy. This may be replaced by a more general pastebin module that - interfaces with various pastebin servers. -#+end_quote - -* Description :unfold: -Adds the ability to manage, pull from, or push to your [[https://gist.github.com][Gists]] from within Emacs. - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:gist]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* TODO Usage -#+begin_quote -🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote -🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote -🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/tools/gist/autoload/evil.el b/.config/emacs/modules/tools/gist/autoload/evil.el @@ -1,19 +0,0 @@ -;;; tools/gist/autoload/evil.el -*- lexical-binding: t; -*- -;;;###if (modulep! :editor evil) - -;;;###autoload (autoload '+gist:send "tools/gist/autoload/evil" nil t) -(evil-define-operator +gist:send (bang) - "Create a private gist from the buffer. If BANG then make it public." - :type inclusive :repeat nil - (interactive "<!>") - (if bang - (gist-region-or-buffer) - (gist-region-or-buffer-private))) - -;;;###autoload (autoload '+gist:list "tools/gist/autoload/evil" nil t) -(evil-define-command +gist:list (&optional username) - "Pop up a listing of gists." - (interactive "<a>") - (if username - (gist-list-user username) - (gist-list))) diff --git a/.config/emacs/modules/tools/gist/config.el b/.config/emacs/modules/tools/gist/config.el @@ -1,31 +0,0 @@ -;;; tools/gist/config.el -*- lexical-binding: t; -*- - -;; NOTE On occasion, the cache gets corrupted, causing wrong-type-argument -;; errors. If that happens, try `+gist/kill-cache'. You may have to restart -;; Emacs. - -(after! gist - (set-evil-initial-state! 'gist-list-mode 'normal) - - (set-popup-rule! "^\\*gist-" :ignore t) - - (defadvice! +gist--open-in-popup-a (fn &rest args) - :around #'gist-list-render - (funcall fn (car args) t) - (unless (cadr args) - (pop-to-buffer (current-buffer)))) - - (map! :map gist-list-menu-mode-map - :n "RET" #'gist-fetch-current - :n "TAB" #'gist-fetch-current - :n [tab] #'gist-fetch-current-noselect - :n "go" #'gist-browse-current-url - :n "gr" #'gist-list-reload - :n "c" #'gist-add-buffer - :n "d" #'gist-kill-current - :n "e" #'gist-edit-current-description - :n "f" #'gist-fork - :n "q" #'kill-current-buffer - :n "s" #'gist-star - :n "S" #'gist-unstar - :n "y" #'gist-print-current-url)) diff --git a/.config/emacs/modules/tools/gist/packages.el b/.config/emacs/modules/tools/gist/packages.el @@ -1,4 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; tools/gist/packages.el - -(package! gist :pin "314fe6ab80fae35b95f0734eceb82f72813b6f41") diff --git a/.config/emacs/modules/tools/lookup/README.org b/.config/emacs/modules/tools/lookup/README.org @@ -1,254 +0,0 @@ -#+title: :tools lookup -#+subtitle: Navigate your labyrinthine code and docs -#+created: January 04, 2018 -#+since: 2.0.9 - -* Description :unfold: -This module adds code navigation and documentation lookup tools to help you -quickly look up definitions, references, documentation, dictionary definitions -or synonyms. - -- Jump-to-definition and find-references implementations that just work. -- Powerful xref integration for languages that support it. -- Search online providers like [[https://devdocs.io][devdocs.io]], [[https://stackoverflow.com][stackoverflow]], [[https://google.com][google]], [[https://duckduckgo.com][duckduckgo]], or - [[https://youtube.com][youtube]] (duckduckgo and google have live suggestions). -- Integration with [[https://github.com/Kapeli/feeds][Dash.app docsets]]. -- Support for online (and offline) dictionaries and thesauruses. - -** Maintainers -- [[doom-user:][@hlissner]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +dictionary :: - Enable word definition and thesaurus lookup functionality. -- +docsets :: - Enable integration with Dash.app docsets. -- +offline :: - Install and prefer offline dictionary/thesaurus (with [[doom-module:+dictionary]]). - -** Packages -- [[doom-package:dumb-jump]] -- [[doom-package:helm-xref]] if [[doom-module::completion helm]] -- [[doom-package:ivy-xref]] if [[doom-module::completion ivy]] -- [[doom-package:request]] -- if [[doom-module:+docsets]] - - [[doom-package:dash-docs]] - - [[doom-package:counsel-dash]] if [[doom-module::completion ivy]] - - [[doom-package:helm-dash]] if [[doom-module::completion helm]] -- if [[doom-module:+dictionary]] - - if macOS - - [[doom-package:osx-dictionary]] - - else - - [[doom-package:define-word]] - - [[doom-package:powerthesaurus]] - - if [[doom-module:+offline]] - - [[doom-package:wordnut]] - - [[doom-package:synosaurus]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module has several optional dependencies: - -- ~ripgrep~ as a last-resort fallback for jump-to-definition/find-references. -- ~sqlite3~ for Dash docset support (if you have [[doom-module:+docsets]] enabled) -- ~wordnet~ for offline dictionary and thesaurus support (if you have - [[doom-module:+dictionary]] and [[doom-module:+offline]] enabled). - -** MacOS -#+begin_src sh -brew install ripgrep wordnet - -# An older version of sqlite is included in MacOS. If it causes you problems (and -# folks have reported it will), install it through homebrew: -brew install sqlite -# Note that it's keg-only, meaning it isn't symlinked to /usr/local/bin. You'll -# have to add it to PATH yourself (or symlink it into your PATH somewhere). e.g. -export PATH="/usr/local/opt/sqlite/bin:$PATH" -#+end_src - -** Arch Linux -#+begin_src sh -sudo pacman -S sqlite ripgrep -yay -S wordnet-cli -#+end_src - -** NixOS -#+begin_src nix -environment.systemPackages = with pkgs; [ - ripgrep - sqlite - wordnet -]; -#+end_src - -* Usage -** Jump to definition -Use ~+lookup/definition~ (bound to [[kbd:][gd]] in normal mode) to jump to the definition -of the symbol at point. - -This module provides a goto-definition implementation that will try the -following sources before giving up: - -1. Whatever ~:definition~ function is registered for the current buffer with the - ~:lookup~ setting (see "Configuration" section). -2. Any available xref backends. -3. [[doom-package:dumb-jump]] (a text search with aides to reduce false positives). -3. An ordinary project-wide text search with =ripgrep=. -5. If ~evil-mode~ is active, use ~evil-goto-definition~, which preforms a simple - text search within the current buffer. - -If there are multiple results, you will be prompted to select one. - -** Find references -Use ~+lookup/references~ (bound to [[kbd:][gD]] in normal mode) to see a list of -references for the symbol at point from throughout your project. - -Like ~+lookup/definition~, this tries a number of sources before giving up. It -will try: - -1. Whatever ~:references~ function is registered for the current buffer with the - ~:lookup~ setting (see [[*Configuration][Configuration]]). -2. Any available [[doom-package:xref]] backends. -3. An ordinary project-wide text search with ripgrep. - -If there are multiple results, you will be prompted to select one. - -** Look up documentation -~+lookup/documentation~ (bound to [[kbd:][K]] in normal mode) will open documentation for -the symbol at point. - -Depending on your configuration, this will try a list of sources: - -1. Whatever ~:documentation~ function is registered for the current buffer with - the ~:lookup~ setting (see "Configuration" section). -2. Any Dash.app docsets, if any are installed for the current major mode. -3. devdocs.io, if it has a docset for the current mode. -4. An online search; using the last engine used (it will prompt you the first - time, or if ~current-prefix-arg~ is non-nil). - -** Search a specific documentation backend -You can perform a documentation lookup on any backends directly: - -+ Dash Docsets: ~+lookup/in-docsets~, or ~:dash QUERY~ for evil users. -+ Online (generic): ~+lookup/online~ or ~+lookup/online-select~ (bound to [[kbd:][SPC / - o]]), or ~:lo[okup] QUERY~ for evil users. - -** Dash.app Docset integration -You can install dash docsets with ~M-x dash-docs-install-docset~ and search -them offline with ~M-x +lookup/in-docsets~, or with ~+lookup/documentation~ in -modes that don't have a specialized :documentation lookup handler. - -* Configuration -** Associating lookup handlers with major modes -~set-lookup-handlers! MODES &key DEFINITION REFERENCES DOCUMENTATION FILE -XREF-BACKEND ASYNC~ - -Use ~set-lookup-handlers!~ to register lookup targets for MODES (a major or -minor mode symbol or list thereof). PLIST accepts the following optional -properties: - -- ~:definition FN~ :: - Run when jumping to a symbol's definition. Used by ~+lookup/definition~. -- ~:references FN~ :: - Run when looking for usage references of a symbol in the current project. Used - by ~+lookup/references~. -- ~:documentation FN~ :: - Run when looking up documentation for a symbol. Used by - ~+lookup/documentation~. -- ~:file FN~ :: - Run when looking up the file for a symbol/string. Typically a file path. Used - by ~+lookup/file~. -- ~:xref-backend FN~ :: - Defines an [[doom-package:xref]] backend, which implicitly provides ~:definition~ and - ~:references~ handlers. If you specify them anyway, they will take precedence - over the xref backend, however. - -E.g. -#+begin_src emacs-lisp -;; For python-mode, anaconda-mode offers a backend for all three lookup -;; functions. We can register them like so: -(set-lookup-handlers! 'python-mode - :definition #'anaconda-mode-find-definitions - :references #'anaconda-mode-find-references - :documentation #'anaconda-mode-show-doc) - -;; If a language or plugin provides a custom xref backend available for it, use -;; that instead. It will provide the best jump-to-definition and find-references -;; experience. You can specify custom xref backends with: -(set-lookup-handlers! 'js2-mode :xref-backend #'xref-js2-xref-backend) -;; NOTE: xref doesn't provide a :documentation backend. -#+end_src - -** Associating Dash docsets with major modes -~set-docsets! MODES &rest DOCSETS...~ - -Use ~set-docsets!~ to register DOCSETS (one string or list of strings) for MODES -(one major mode symbol or a list of them). It is used by ~+lookup/in-docsets~ -and ~+lookup/documentation~. - -E.g. -#+begin_src emacs-lisp -(set-docsets! 'js2-mode "JavaScript" "JQuery") -;; Add docsets to minor modes by starting DOCSETS with :add -(set-docsets! 'rjsx-mode :add "React") -;; Or remove docsets from minor modes -(set-docsets! 'nodejs-mode :remove "JQuery") -#+end_src - -This determines what docsets to implicitly search for when you use -~+lookup/documentation~ in a mode with no ~:documentation~ handler. Those -docsets must be installed with ~dash-docs-install-docset~. - -** Open in eww instead of browser -~+lookup/online~ opens the search results with in ~+lookup-open-url-fn~ -(default: ~#'browse-url~). Here is how to change this to EWW (so it opens inside -Emacs): -#+begin_src emacs-lisp -(setq +lookup-open-url-fn #'eww) -#+end_src - -#+begin_quote - 📌 ~+lookup/in-docsets~ consults ~dash-docs-browser-func~ instead, which is - already set to ~#'eww~ by default. -#+end_quote - -** Open in Xwidget WebKit instead of browser -To open results from ~+lookup/online~ or ~+lookup/in-docsets~ in Xwidget WebKit -instead of your system browser, set ~+lookup-open-url-fn~ and/or -~dash-docs-browser-func~ to ~+lookup-xwidget-webkit-open-url-fn~ (needs Emacs -with Xwidgets support): -#+begin_src emacs-lisp -(setq +lookup-open-url-fn #'+lookup-xwidget-webkit-open-url-fn) -(after! dash-docs - (setq dash-docs-browser-func #'+lookup-xwidget-webkit-open-url-fn)) -#+end_src - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 /This module's appendix is incomplete./ [[doom-contrib-module:][Write more?]] -#+end_quote - -** Commands -- ~+lookup/definition~ -- ~+lookup/references~ -- ~+lookup/documentation~ -- ~+lookup/online~ -- ~+lookup/online-select~ -- ~+lookup/in-devdocs~ -- ~+lookup/in-docsets~ diff --git a/.config/emacs/modules/tools/lookup/autoload/docsets.el b/.config/emacs/modules/tools/lookup/autoload/docsets.el @@ -1,132 +0,0 @@ -;;; tools/lookup/autoload/docsets.el -*- lexical-binding: t; -*- -;;;###if (modulep! +docsets) - -(defvar dash-docs-docsets nil) - -;;;###autodef -(defun set-docsets! (modes &rest docsets) - "Registers a list of DOCSETS for MODES. - -MODES can be one major mode, or a list thereof. - -DOCSETS can be strings, each representing a dash docset, or a vector with the -structure [DOCSET FORM]. If FORM evaluates to nil, the DOCSET is omitted. If it -is non-nil, (format DOCSET FORM) is used as the docset. - -The first element in DOCSETS can be :add or :remove, making it easy for users to -add to or remove default docsets from modes. - -DOCSETS can also contain sublists, which will be flattened. - -Example: - - (set-docsets! '(js2-mode rjsx-mode) \"JavaScript\" - [\"React\" (eq major-mode 'rjsx-mode)] - [\"TypeScript\" (bound-and-true-p tide-mode)]) - -Used by `+lookup/in-docsets' and `+lookup/documentation'." - (declare (indent defun)) - (let ((action (if (keywordp (car docsets)) (pop docsets)))) - (dolist (mode (ensure-list modes)) - (let ((hook (intern (format "%s-hook" mode))) - (fn (intern (format "+lookup-init--%s-%s" (or action "set") mode)))) - (if (null docsets) - (remove-hook hook fn) - (fset - fn (lambda () - (make-local-variable 'dash-docs-docsets) - (unless (memq action '(:add :remove)) - (setq dash-docs-docset nil)) - (dolist (spec docsets) - (cl-destructuring-bind (docset . pred) - (cl-typecase spec - (string (cons spec nil)) - (vector (cons (aref spec 0) (aref spec 1))) - (otherwise (signal 'wrong-type-arguments (list spec '(vector string))))) - (when (or (null pred) - (eval pred t)) - (if (eq action :remove) - (setq dash-docs-docsets (delete docset dash-docs-docsets)) - (cl-pushnew docset dash-docs-docsets))))))) - (add-hook hook fn 'append)))))) - -;;;###autoload -(defun +lookup-dash-docsets-backend-fn (identifier) - "Looks up IDENTIFIER in available Dash docsets, if any are installed. - -This backend is meant for `+lookup-documentation-functions'. - -Docsets must be installed with one of the following commands: - -+ `dash-docs-install-docset' -+ `dash-docs-install-docset-from-file' -+ `dash-docs-install-user-docset' -+ `dash-docs-async-install-docset' -+ `dash-docs-async-install-docset-from-file' - -Docsets can be searched directly via `+lookup/in-docsets'." - (when (require 'dash-docs nil t) - (when-let (docsets (cl-remove-if-not #'dash-docs-docset-path (dash-docs-buffer-local-docsets))) - (+lookup/in-docsets nil identifier docsets) - 'deferred))) - - -;; -;;; Commands - -(defun +lookup--consult-search (sync cb) - (lambda (action) - (pcase action - ((pred stringp) - (when-let (cands (with-current-buffer cb - (dash-docs-search action))) - (funcall sync 'flush) - (funcall sync cands))) - (_ (funcall sync action))))) - -;;;###autoload -(defun +lookup/in-docsets (arg &optional query docsets) - "Lookup QUERY in dash DOCSETS. - -QUERY is a string and docsets in an array of strings, each a name of a Dash -docset. Requires either helm or ivy. - -If prefix ARG is supplied, search all installed installed docsets. They can be -installed with `dash-docs-install-docset'." - (interactive "P") - (require 'dash-docs) - (let ((dash-docs-common-docsets) - (dash-docs-docsets - (if arg - (dash-docs-installed-docsets) - (cl-remove-if-not #'dash-docs-docset-path (or docsets dash-docs-docsets)))) - (query (doom-thing-at-point-or-region query))) - (doom-log "Searching docsets %s" dash-docs-docsets) - (cond ((modulep! :completion vertico) - (require 'consult) - (dash-docs-initialize-debugging-buffer) - (dash-docs-create-buffer-connections) - (dash-docs-create-common-connections) - (let* ((sink - (thread-first (consult--async-sink) - (consult--async-refresh-immediate) - (+lookup--consult-search (current-buffer)) - (consult--async-throttle))) - (result - (or (consult--read sink - :prompt "Documentation for: " - :category 'dash - :initial query) - (user-error "Aborted")))) - (dash-docs-browse-url (cdr (assoc result (funcall sink nil)))))) - ((modulep! :completion ivy) - (counsel-dash query)) - ((modulep! :completion helm) - (helm-dash query)) - ((user-error "No dash backend is installed, enable ivy or helm."))))) - -;;;###autoload -(defun +lookup/in-all-docsets (&optional query) - "TODO" - (interactive) - (+lookup/in-docsets t query)) diff --git a/.config/emacs/modules/tools/lookup/autoload/evil.el b/.config/emacs/modules/tools/lookup/autoload/evil.el @@ -1,22 +0,0 @@ -;;; tools/lookup/autoload/evil.el -*- lexical-binding: t; -*- -;;;###if (modulep! :editor evil) - -;;;###autoload (autoload '+lookup:online "tools/lookup/autoload/evil" nil t) -(evil-define-command +lookup:online (query &optional bang) - "Look up QUERY online. Will prompt for search engine the first time, then -reuse it on consecutive uses of this command. If BANG, always prompt for search -engine." - (interactive "<a><!>") - (+lookup/online query (+lookup--online-provider bang 'evil-ex))) - -;;;###autoload (autoload '+lookup:dash "tools/lookup/autoload/evil" nil t) -(evil-define-command +lookup:dash (query &optional bang) - "Look up QUERY in your dash docsets. If BANG, prompt to select a docset (and -install it if necessary)." - (interactive "<a><!>") - (let (selected) - (when bang - (setq selected (helm-dash-read-docset "Select docset" (helm-dash-official-docsets))) - (unless (dash-docs-docset-path selected) - (+lookup/install-docset selected))) - (+lookup/in-docsets query selected))) diff --git a/.config/emacs/modules/tools/lookup/autoload/lookup.el b/.config/emacs/modules/tools/lookup/autoload/lookup.el @@ -1,441 +0,0 @@ -;;; tools/lookup/autoload/lookup.el -*- lexical-binding: t; -*- - -;;;###autodef -(defun set-lookup-handlers! (modes &rest plist) - "Define jump handlers for major or minor MODES. - -A handler is either an interactive command that changes the current buffer -and/or location of the cursor, or a function that takes one argument: the -identifier being looked up, and returns either nil (failed to find it), t -(succeeded at changing the buffer/moving the cursor), or 'deferred (assume this -handler has succeeded, but expect changes not to be visible yet). - -There are several kinds of handlers, which can be defined with the following -properties: - -:definition FN - Run when jumping to a symbol's definition. Used by `+lookup/definition'. -:implementations FN - Run when looking for implementations of a symbol in the current project. Used - by `+lookup/implementations'. -:type-definition FN - Run when jumping to a symbol's type definition. Used by - `+lookup/type-definition'. -:references FN - Run when looking for usage references of a symbol in the current project. Used - by `+lookup/references'. -:documentation FN - Run when looking up documentation for a symbol. Used by - `+lookup/documentation'. -:file FN - Run when looking up the file for a symbol/string. Typically a file path. Used - by `+lookup/file'. -:xref-backend FN - Defines an xref backend for a major-mode. A :definition and :references - handler isn't necessary with a :xref-backend, but will have higher precedence - if they exist. -:async BOOL - Indicates that *all* supplied FNs are asynchronous. Note: lookups will not try - any handlers after async ones, due to their nature. To get around this, you - must write a specialized wrapper to await the async response, or use a - different heuristic to determine, ahead of time, whether the async call will - succeed or not. - - If you only want to specify one FN is async, declare it inline instead: - - (set-lookup-handlers! 'rust-mode - :definition '(racer-find-definition :async t)) - -Handlers can either be interactive or non-interactive. Non-interactive handlers -must take one argument: the identifier being looked up. This function must -change the current buffer or window or return non-nil when it succeeds. - -If it doesn't change the current buffer, or it returns nil, the lookup module -will fall back to the next handler in `+lookup-definition-functions', -`+lookup-implementations-functions', `+lookup-type-definition-functions', -`+lookup-references-functions', `+lookup-file-functions' or -`+lookup-documentation-functions'. - -Consecutive `set-lookup-handlers!' calls will overwrite previously defined -handlers for MODES. If used on minor modes, they are stacked onto handlers -defined for other minor modes or the major mode it's activated in. - -This can be passed nil as its second argument to unset handlers for MODES. e.g. - - (set-lookup-handlers! 'python-mode nil) - -\(fn MODES &key DEFINITION IMPLEMENTATIONS TYPE-DEFINITION REFERENCES DOCUMENTATION FILE XREF-BACKEND ASYNC)" - (declare (indent defun)) - (dolist (mode (ensure-list modes)) - (let ((hook (intern (format "%s-hook" mode))) - (fn (intern (format "+lookup--init-%s-handlers-h" mode)))) - (if (null (car plist)) - (progn - (remove-hook hook fn) - (unintern fn nil)) - (fset - fn - (lambda () - (cl-destructuring-bind (&key definition implementations type-definition references documentation file xref-backend async) - plist - (cl-mapc #'+lookup--set-handler - (list definition - implementations - type-definition - references - documentation - file - xref-backend) - (list '+lookup-definition-functions - '+lookup-implementations-functions - '+lookup-type-definition-functions - '+lookup-references-functions - '+lookup-documentation-functions - '+lookup-file-functions - 'xref-backend-functions) - (make-list 5 async) - (make-list 5 (or (eq major-mode mode) - (and (boundp mode) - (symbol-value mode)))))))) - (add-hook hook fn))))) - - -;; -;;; Helpers - -(defun +lookup--set-handler (spec functions-var &optional async enable) - (when spec - (cl-destructuring-bind (fn . plist) - (ensure-list spec) - (if (not enable) - (remove-hook functions-var fn 'local) - (put fn '+lookup-async (or (plist-get plist :async) async)) - (add-hook functions-var fn nil 'local))))) - -(defun +lookup--run-handler (handler identifier) - (if (commandp handler) - (call-interactively handler) - (funcall handler identifier))) - -(defun +lookup--run-handlers (handler identifier origin) - (doom-log "Looking up '%s' with '%s'" identifier handler) - (condition-case-unless-debug e - (let ((wconf (current-window-configuration)) - (result (condition-case-unless-debug e - (+lookup--run-handler handler identifier) - (error - (doom-log "Lookup handler %S threw an error: %s" handler e) - 'fail)))) - (cond ((eq result 'fail) - (set-window-configuration wconf) - nil) - ((or (get handler '+lookup-async) - (eq result 'deferred))) - ((or result - (null origin) - (/= (point-marker) origin)) - (prog1 (point-marker) - (set-window-configuration wconf))))) - ((error user-error) - (message "Lookup handler %S: %s" handler e) - nil))) - -(defun +lookup--jump-to (prop identifier &optional display-fn arg) - (let* ((origin (point-marker)) - (handlers - (plist-get (list :definition '+lookup-definition-functions - :implementations '+lookup-implementations-functions - :type-definition '+lookup-type-definition-functions - :references '+lookup-references-functions - :documentation '+lookup-documentation-functions - :file '+lookup-file-functions) - prop)) - (result - (if arg - (if-let - (handler - (intern-soft - (completing-read "Select lookup handler: " - (delete-dups - (remq t (append (symbol-value handlers) - (default-value handlers)))) - nil t))) - (+lookup--run-handlers handler identifier origin) - (user-error "No lookup handler selected")) - (run-hook-wrapped handlers #'+lookup--run-handlers identifier origin)))) - (unwind-protect - (when (cond ((null result) - (message "No lookup handler could find %S" identifier) - nil) - ((markerp result) - (funcall (or display-fn #'switch-to-buffer) - (marker-buffer result)) - (goto-char result) - result) - (result)) - (with-current-buffer (marker-buffer origin) - (better-jumper-set-jump (marker-position origin))) - result) - (set-marker origin nil)))) - - -;; -;;; Lookup backends - -(autoload 'xref--show-defs "xref") -(defun +lookup--xref-show (fn identifier &optional show-fn) - (let ((xrefs (funcall fn - (xref-find-backend) - identifier))) - (when xrefs - (let* ((jumped nil) - (xref-after-jump-hook - (cons (lambda () (setq jumped t)) - xref-after-jump-hook))) - (funcall (or show-fn #'xref--show-defs) - (lambda () xrefs) - nil) - (if (cdr xrefs) - 'deferred - jumped))))) - -(defun +lookup-dictionary-definition-backend-fn (identifier) - "Look up dictionary definition for IDENTIFIER." - (when (derived-mode-p 'text-mode) - (+lookup/dictionary-definition identifier) - 'deferred)) - -(defun +lookup-thesaurus-definition-backend-fn (identifier) - "Look up synonyms for IDENTIFIER." - (when (derived-mode-p 'text-mode) - (+lookup/synonyms identifier) - 'deferred)) - -(defun +lookup-xref-definitions-backend-fn (identifier) - "Non-interactive wrapper for `xref-find-definitions'" - (condition-case _ - (+lookup--xref-show 'xref-backend-definitions identifier #'xref--show-defs) - (cl-no-applicable-method nil))) - -(defun +lookup-xref-references-backend-fn (identifier) - "Non-interactive wrapper for `xref-find-references'" - (condition-case _ - (+lookup--xref-show 'xref-backend-references identifier #'xref--show-xrefs) - (cl-no-applicable-method nil))) - -(defun +lookup-dumb-jump-backend-fn (_identifier) - "Look up the symbol at point (or selection) with `dumb-jump', which conducts a -project search with ag, rg, pt, or git-grep, combined with extra heuristics to -reduce false positives. - -This backend prefers \"just working\" over accuracy." - (and (require 'dumb-jump nil t) - (dumb-jump-go))) - -(defun +lookup-project-search-backend-fn (identifier) - "Conducts a simple project text search for IDENTIFIER. - -Uses and requires `+ivy-file-search', `+helm-file-search', or `+vertico-file-search'. -Will return nil if neither is available. These require ripgrep to be installed." - (unless identifier - (let ((query (rxt-quote-pcre identifier))) - (ignore-errors - (cond ((modulep! :completion ivy) - (+ivy-file-search :query query) - t) - ((modulep! :completion helm) - (+helm-file-search :query query) - t) - ((modulep! :completion vertico) - (+vertico-file-search :query query) - t)))))) - -(defun +lookup-evil-goto-definition-backend-fn (_identifier) - "Uses `evil-goto-definition' to conduct a text search for IDENTIFIER in the -current buffer." - (when (fboundp 'evil-goto-definition) - (ignore-errors - (cl-destructuring-bind (beg . end) - (bounds-of-thing-at-point 'symbol) - (evil-goto-definition) - (let ((pt (point))) - (not (and (>= pt beg) - (< pt end)))))))) - -(defun +lookup-ffap-backend-fn (identifier) - "Tries to locate the file at point (or in active selection). -Uses find-in-project functionality (provided by ivy, helm, or project), -otherwise falling back to ffap.el (find-file-at-point)." - (let ((guess - (cond (identifier) - ((doom-region-active-p) - (buffer-substring-no-properties - (doom-region-beginning) - (doom-region-end))) - ((if (require 'ffap) (ffap-guesser))) - ((thing-at-point 'filename t))))) - (cond ((and (stringp guess) - (or (file-exists-p guess) - (ffap-url-p guess))) - (find-file-at-point guess)) - ((and (modulep! :completion ivy) - (doom-project-p)) - (counsel-file-jump guess (doom-project-root))) - ((and (modulep! :completion vertico) - (doom-project-p)) - (+vertico/find-file-in (doom-project-root) guess)) - ((find-file-at-point (ffap-prompter guess)))) - t)) - -(defun +lookup-bug-reference-backend-fn (_identifier) - "Searches for a bug reference in user/repo#123 or #123 format and opens it in -the browser." - (require 'bug-reference) - (when (fboundp 'bug-reference-try-setup-from-vc) - (let ((old-bug-reference-mode bug-reference-mode) - (old-bug-reference-prog-mode bug-reference-prog-mode) - (bug-reference-url-format bug-reference-url-format) - (bug-reference-bug-regexp bug-reference-bug-regexp)) - (bug-reference-try-setup-from-vc) - (unwind-protect - (let ((bug-reference-mode t) - (bug-reference-prog-mode nil)) - (catch 'found - (bug-reference-fontify (line-beginning-position) (line-end-position)) - (dolist (o (overlays-at (point))) - ;; It should only be possible to have one URL overlay. - (when-let (url (overlay-get o 'bug-reference-url)) - (browse-url url) - - (throw 'found t))))) - ;; Restore any messed up fontification as a result of this. - (bug-reference-unfontify (line-beginning-position) (line-end-position)) - (if (or old-bug-reference-mode - old-bug-reference-prog-mode) - (bug-reference-fontify (line-beginning-position) (line-end-position))))))) - - -;; -;;; Main commands - -;;;###autoload -(defun +lookup/definition (identifier &optional arg) - "Jump to the definition of IDENTIFIER (defaults to the symbol at point). - -Each function in `+lookup-definition-functions' is tried until one changes the -point or current buffer. Falls back to dumb-jump, naive -ripgrep/the_silver_searcher text search, then `evil-goto-definition' if -evil-mode is active." - (interactive (list (doom-thing-at-point-or-region) - current-prefix-arg)) - (cond ((null identifier) (user-error "Nothing under point")) - ((+lookup--jump-to :definition identifier nil arg)) - ((user-error "Couldn't find the definition of %S" (substring-no-properties identifier))))) - -;;;###autoload -(defun +lookup/implementations (identifier &optional arg) - "Jump to the implementations of IDENTIFIER (defaults to the symbol at point). - -Each function in `+lookup-implementations-functions' is tried until one changes -the point or current buffer." - (interactive (list (doom-thing-at-point-or-region) - current-prefix-arg)) - (cond ((null identifier) (user-error "Nothing under point")) - ((+lookup--jump-to :implementations identifier nil arg)) - ((user-error "Couldn't find the implementations of %S" (substring-no-properties identifier))))) - -;;;###autoload -(defun +lookup/type-definition (identifier &optional arg) - "Jump to the type definition of IDENTIFIER (defaults to the symbol at point). - -Each function in `+lookup-type-definition-functions' is tried until one changes -the point or current buffer." - (interactive (list (doom-thing-at-point-or-region) - current-prefix-arg)) - (cond ((null identifier) (user-error "Nothing under point")) - ((+lookup--jump-to :type-definition identifier nil arg)) - ((user-error "Couldn't find the definition of %S" (substring-no-properties identifier))))) - -;;;###autoload -(defun +lookup/references (identifier &optional arg) - "Show a list of usages of IDENTIFIER (defaults to the symbol at point) - -Tries each function in `+lookup-references-functions' until one changes the -point and/or current buffer. Falls back to a naive ripgrep/the_silver_searcher -search otherwise." - (interactive (list (doom-thing-at-point-or-region) - current-prefix-arg)) - (cond ((null identifier) (user-error "Nothing under point")) - ((+lookup--jump-to :references identifier nil arg)) - ((user-error "Couldn't find references of %S" (substring-no-properties identifier))))) - -;;;###autoload -(defun +lookup/documentation (identifier &optional arg) - "Show documentation for IDENTIFIER (defaults to symbol at point or selection. - -First attempts the :documentation handler specified with `set-lookup-handlers!' -for the current mode/buffer (if any), then falls back to the backends in -`+lookup-documentation-functions'." - (interactive (list (doom-thing-at-point-or-region) - current-prefix-arg)) - (cond ((+lookup--jump-to :documentation identifier #'pop-to-buffer arg)) - ((user-error "Couldn't find documentation for %S" (substring-no-properties identifier))))) - -;;;###autoload -(defun +lookup/file (&optional path) - "Figure out PATH from whatever is at point and open it. - -Each function in `+lookup-file-functions' is tried until one changes the point -or the current buffer. - -Otherwise, falls back on `find-file-at-point'." - (interactive) - (cond ((and path - buffer-file-name - (file-equal-p path buffer-file-name) - (user-error "Already here"))) - - ((+lookup--jump-to :file path)) - - ((user-error "Couldn't find any files here")))) - - -;; -;;; Dictionary - -;;;###autoload -(defun +lookup/dictionary-definition (identifier &optional arg) - "Look up the definition of the word at point (or selection)." - (interactive - (list (or (doom-thing-at-point-or-region 'word) - (read-string "Look up in dictionary: ")) - current-prefix-arg)) - (message "Looking up dictionary definition for %S" identifier) - (cond ((and IS-MAC (require 'osx-dictionary nil t)) - (osx-dictionary--view-result identifier)) - ((and +lookup-dictionary-prefer-offline - (require 'wordnut nil t)) - (unless (executable-find wordnut-cmd) - (user-error "Couldn't find %S installed on your system" - wordnut-cmd)) - (wordnut-search identifier)) - ((require 'define-word nil t) - (define-word identifier nil arg)) - ((user-error "No dictionary backend is available")))) - -;;;###autoload -(defun +lookup/synonyms (identifier &optional _arg) - "Look up and insert a synonym for the word at point (or selection)." - (interactive - (list (doom-thing-at-point-or-region 'word) ; TODO actually use this - current-prefix-arg)) - (message "Looking up synonyms for %S" identifier) - (cond ((and +lookup-dictionary-prefer-offline - (require 'synosaurus-wordnet nil t)) - (unless (executable-find synosaurus-wordnet--command) - (user-error "Couldn't find %S installed on your system" - synosaurus-wordnet--command)) - (synosaurus-choose-and-replace)) - ((require 'powerthesaurus nil t) - (powerthesaurus-lookup-word-dwim)) - ((user-error "No thesaurus backend is available")))) diff --git a/.config/emacs/modules/tools/lookup/autoload/online.el b/.config/emacs/modules/tools/lookup/autoload/online.el @@ -1,95 +0,0 @@ -;;; tools/lookup/autoload/online.el -*- lexical-binding: t; -*- - -(defvar +lookup--last-provider nil) - -(defun +lookup--online-provider (&optional force-p namespace) - (let ((key (or namespace major-mode))) - (or (and (not force-p) - (cdr (assq key +lookup--last-provider))) - (when-let (provider - (completing-read - "Search on: " - (mapcar #'car +lookup-provider-url-alist) - nil t)) - (setf (alist-get key +lookup--last-provider) provider) - provider)))) - -;;;###autoload -(defun +lookup-online-backend-fn (identifier) - "Open the browser and search for IDENTIFIER online. -When called for the first time, or with a non-nil prefix argument, prompt for -the search engine to use." - (+lookup/online - identifier - (+lookup--online-provider (not current-prefix-arg)))) - -;;;###autoload -(defun +lookup/online (query provider) - "Look up QUERY in the browser using PROVIDER. -When called interactively, prompt for a query and, when called for the first -time, the provider from `+lookup-provider-url-alist'. In subsequent calls, reuse -the previous provider. With a non-nil prefix argument, always prompt for the -provider. - -QUERY must be a string, and PROVIDER must be a key of -`+lookup-provider-url-alist'." - (interactive - (list (if (use-region-p) (doom-thing-at-point-or-region)) - (+lookup--online-provider current-prefix-arg))) - (let ((backends (cdr (assoc provider +lookup-provider-url-alist)))) - (unless backends - (user-error "No available online lookup backend for %S provider" - provider)) - (catch 'done - (dolist (backend backends) - (cl-check-type backend (or string function)) - (cond ((stringp backend) - (funcall +lookup-open-url-fn - (format backend - (url-encode-url - (or query - (read-string (format "Search for (on %s): " provider) - (thing-at-point 'symbol t))))))) - ((condition-case-unless-debug e - (and (fboundp backend) - (funcall backend query)) - (error - (delq! major-mode +lookup--last-provider 'assq) - (signal (car e) (cdr e)))) - (throw 'done t))))))) - -;;;###autoload -(defun +lookup/online-select () - "Run `+lookup/online', but always prompt for the provider to use." - (interactive) - (let ((current-prefix-arg t)) - (call-interactively #'+lookup/online))) - - -;; -;;; Special provider frontends - -(defvar ivy-initial-inputs-alist) -(defvar counsel-search-engine) -;;;###autoload -(defun +lookup--online-backend-google (query) - "Search Google, starting with QUERY, with live autocompletion." - (cond ((and (bound-and-true-p ivy-mode) (fboundp 'counsel-search)) - (let ((ivy-initial-inputs-alist `((t . ,query))) - (counsel-search-engine 'google)) - (call-interactively #'counsel-search) - t)) - ((and (bound-and-true-p helm-mode) (require 'helm-net nil t)) - (helm :sources 'helm-source-google-suggest - :buffer "*helm google*" - :input query) - t))) - -;;;###autoload -(defun +lookup--online-backend-duckduckgo (query) - "Search DuckDuckGo, starting with QUERY, with live autocompletion." - (cond ((and (bound-and-true-p ivy-mode) (fboundp 'counsel-search)) - (let ((ivy-initial-inputs-alist `((t . ,query))) - (counsel-search-engine 'ddg)) - (call-interactively #'counsel-search) - t)))) diff --git a/.config/emacs/modules/tools/lookup/autoload/xwidget.el b/.config/emacs/modules/tools/lookup/autoload/xwidget.el @@ -1,19 +0,0 @@ -;;; tools/lookup/autoload/xwidget.el -*- lexical-binding: t; -*- - -(defvar +lookup--xwidget-webkit-last-session-buffer nil) - -;;;###autoload -(defun +lookup-xwidget-webkit-open-url-fn (url &optional new-session) - (if (not (display-graphic-p)) - (browse-url url) - (unless (featurep 'xwidget-internal) - (user-error "Your build of Emacs lacks Xwidgets support and cannot open Xwidget WebKit browser")) - (let ((orig-last-session-buffer (if (boundp 'xwidget-webkit-last-session-buffer) - xwidget-webkit-last-session-buffer - nil))) - (setq xwidget-webkit-last-session-buffer +lookup--xwidget-webkit-last-session-buffer) - (save-window-excursion - (xwidget-webkit-browse-url url new-session)) - (pop-to-buffer xwidget-webkit-last-session-buffer) - (setq +lookup--xwidget-webkit-last-session-buffer xwidget-webkit-last-session-buffer - xwidget-webkit-last-session-buffer orig-last-session-buffer)))) diff --git a/.config/emacs/modules/tools/lookup/config.el b/.config/emacs/modules/tools/lookup/config.el @@ -1,228 +0,0 @@ -;;; tools/lookup/config.el -*- lexical-binding: t; -*- - -;; "What am I looking at?" This module helps you answer this question. -;; -;; + `+lookup/definition': a jump-to-definition that should 'just work' -;; + `+lookup/implementations': find a symbol's implementations in the current -;; project -;; + `+lookup/references': find a symbol's references in the current project -;; + `+lookup/file': open the file referenced at point -;; + `+lookup/online'; look up a symbol on online resources -;; + `+lookup/in-docsets': look up in Dash docsets -;; -;; This module uses `xref', an experimental new library in Emacs. It may change -;; in the future. When xref can't be depended on it will fall back to -;; `dumb-jump' to find what you want. - -(defvar +lookup-provider-url-alist - (append '(("Doom issues" "https://github.com/orgs/doomemacs/projects/2/views/30?filterQuery=%s") - ("Doom discourse" "https://discourse.doomemacs.org/search?q=%s") - ("Google" +lookup--online-backend-google "https://google.com/search?q=%s") - ("Google images" "https://www.google.com/images?q=%s") - ("Google maps" "https://maps.google.com/maps?q=%s") - ("Project Gutenberg" "http://www.gutenberg.org/ebooks/search/?query=%s") - ("DuckDuckGo" +lookup--online-backend-duckduckgo "https://duckduckgo.com/?q=%s") - ("DevDocs.io" "https://devdocs.io/#q=%s") - ("StackOverflow" "https://stackoverflow.com/search?q=%s") - ("Github" "https://github.com/search?ref=simplesearch&q=%s") - ("Youtube" "https://youtube.com/results?aq=f&oq=&search_query=%s") - ("Wolfram alpha" "https://wolframalpha.com/input/?i=%s") - ("Wikipedia" "https://wikipedia.org/search-redirect.php?language=en&go=Go&search=%s") - ("MDN" "https://developer.mozilla.org/en-US/search?q=%s") - ("Internet archive" "https://web.archive.org/web/*/%s") - ("Sourcegraph" "https://sourcegraph.com/search?q=context:global+%s&patternType=literal")) - (when (modulep! :lang rust) - '(("Rust Docs" "https://doc.rust-lang.org/std/?search=%s")))) - "An alist that maps online resources to either: - - 1. A search url (needs on '%s' to substitute with an url encoded query), - 2. A non-interactive function that returns the search url in #1, - 3. An interactive command that does its own search for that provider. - -Used by `+lookup/online'.") - -(defvar +lookup-open-url-fn #'browse-url - "Function to use to open search urls.") - -(defvar +lookup-definition-functions - '(+lookup-dictionary-definition-backend-fn - +lookup-xref-definitions-backend-fn - +lookup-dumb-jump-backend-fn - +lookup-project-search-backend-fn - +lookup-evil-goto-definition-backend-fn) - "Functions for `+lookup/definition' to try, before resorting to `dumb-jump'. -Stops at the first function to return non-nil or change the current -window/point. - -If the argument is interactive (satisfies `commandp'), it is called with -`call-interactively' (with no arguments). Otherwise, it is called with one -argument: the identifier at point. See `set-lookup-handlers!' about adding to -this list.") - -(defvar +lookup-implementations-functions () - "Function for `+lookup/implementations' to try. Stops at the first function to -return non-nil or change the current window/point. - -If the argument is interactive (satisfies `commandp'), it is called with -`call-interactively' (with no arguments). Otherwise, it is called with one -argument: the identifier at point. See `set-lookup-handlers!' about adding to -this list.") - -(defvar +lookup-type-definition-functions () - "Functions for `+lookup/type-definition' to try. Stops at the first function to -return non-nil or change the current window/point. - -If the argument is interactive (satisfies `commandp'), it is called with -`call-interactively' (with no arguments). Otherwise, it is called with one -argument: the identifier at point. See `set-lookup-handlers!' about adding to -this list.") - -(defvar +lookup-references-functions - '(+lookup-thesaurus-definition-backend-fn - +lookup-xref-references-backend-fn - +lookup-project-search-backend-fn) - "Functions for `+lookup/references' to try, before resorting to `dumb-jump'. -Stops at the first function to return non-nil or change the current -window/point. - -If the argument is interactive (satisfies `commandp'), it is called with -`call-interactively' (with no arguments). Otherwise, it is called with one -argument: the identifier at point. See `set-lookup-handlers!' about adding to -this list.") - -(defvar +lookup-documentation-functions - '(+lookup-online-backend-fn) - "Functions for `+lookup/documentation' to try, before resorting to -`dumb-jump'. Stops at the first function to return non-nil or change the current -window/point. - -If the argument is interactive (satisfies `commandp'), it is called with -`call-interactively' (with no arguments). Otherwise, it is called with one -argument: the identifier at point. See `set-lookup-handlers!' about adding to -this list.") - -(defvar +lookup-file-functions - '(+lookup-bug-reference-backend-fn - +lookup-ffap-backend-fn) - "Function for `+lookup/file' to try, before restoring to `find-file-at-point'. -Stops at the first function to return non-nil or change the current -window/point. - -If the argument is interactive (satisfies `commandp'), it is called with -`call-interactively' (with no arguments). Otherwise, it is called with one -argument: the identifier at point. See `set-lookup-handlers!' about adding to -this list.") - -(defvar +lookup-dictionary-prefer-offline (modulep! +offline) - "If non-nil, look up dictionaries online. - -Setting this to nil will force it to use offline backends, which may be less -than perfect, but available without an internet connection. - -Used by `+lookup/dictionary-definition' and `+lookup/synonyms'. - -For `+lookup/dictionary-definition', this is ignored on Mac, where Emacs users -Dictionary.app behind the scenes to get definitions.") - - -;; -;;; dumb-jump - -(use-package! dumb-jump - :commands dumb-jump-result-follow - :config - (setq dumb-jump-default-project doom-emacs-dir - dumb-jump-prefer-searcher 'rg - dumb-jump-aggressive nil - dumb-jump-selector - (cond ((modulep! :completion ivy) 'ivy) - ((modulep! :completion helm) 'helm) - ('popup))) - (add-hook 'dumb-jump-after-jump-hook #'better-jumper-set-jump)) - - -;; -;;; xref - -;; The lookup commands are superior, and will consult xref if there are no -;; better backends available. -(global-set-key [remap xref-find-definitions] #'+lookup/definition) -(global-set-key [remap xref-find-references] #'+lookup/references) - -(after! xref - ;; We already have `projectile-find-tag' and `evil-jump-to-tag', no need for - ;; xref to be one too. - (remove-hook 'xref-backend-functions #'etags--xref-backend) - ;; ...however, it breaks `projectile-find-tag', unless we put it back. - (defadvice! +lookup--projectile-find-tag-a (fn) - :around #'projectile-find-tag - (let ((xref-backend-functions '(etags--xref-backend t))) - (funcall fn))) - - ;; This integration is already built into evil - (unless (modulep! :editor evil) - ;; Use `better-jumper' instead of xref's marker stack - (advice-add #'xref-push-marker-stack :around #'doom-set-jump-a)) - - (use-package! ivy-xref - :when (modulep! :completion ivy) - :config - (set-popup-rule! "^\\*xref\\*$" :ignore t) - (setq xref-show-definitions-function #'ivy-xref-show-defs - xref-show-xrefs-function #'ivy-xref-show-xrefs) - - ;; HACK Fix #4386: `ivy-xref-show-xrefs' calls `fetcher' twice, which has - ;; side effects that breaks in some cases (i.e. on `dired-do-find-regexp'). - (defadvice! +lookup--fix-ivy-xrefs (fn fetcher alist) - :around #'ivy-xref-show-xrefs - (when (functionp fetcher) - (setf (alist-get 'fetched-xrefs alist) - (funcall fetcher))) - (funcall fn fetcher alist))) - - (use-package! helm-xref - :when (modulep! :completion helm)) - - (use-package! consult-xref - :when (modulep! :completion vertico) - :defer t - :init - (setq xref-show-xrefs-function #'consult-xref - xref-show-definitions-function #'consult-xref))) - - -;; -;;; Dash docset integration - -(use-package! dash-docs - :when (modulep! +docsets) - :defer t - :init - (add-hook '+lookup-documentation-functions #'+lookup-dash-docsets-backend-fn) - :config - (setq dash-docs-enable-debugging init-file-debug - dash-docs-docsets-path (concat doom-data-dir "docsets/") - dash-docs-min-length 2 - dash-docs-browser-func #'eww) - - (cond ((modulep! :completion helm) - (require 'helm-dash nil t)) - ((modulep! :completion ivy) - (require 'counsel-dash nil t)))) - - -;; -;;; Dictionary integration - -(use-package! define-word - :when (modulep! +dictionary) - :unless IS-MAC - :defer t - :config - (setq define-word-displayfn-alist - (cl-loop for (service . _) in define-word-services - collect (cons service #'+eval-display-results-in-popup)))) - - -;;;###package synosaurus -(setq synosaurus-choose-method 'default) ; use ivy/helm instead of ido diff --git a/.config/emacs/modules/tools/lookup/doctor.el b/.config/emacs/modules/tools/lookup/doctor.el @@ -1,5 +0,0 @@ -;;; tools/lookup/doctor.el -*- lexical-binding: t; -*- - -(when (modulep! +docsets) - (unless (executable-find "sqlite3") - (warn! "Couldn't find the sqlite3 executable. dash-docs will not work."))) diff --git a/.config/emacs/modules/tools/lookup/packages.el b/.config/emacs/modules/tools/lookup/packages.el @@ -1,34 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; tools/lookup/packages.el - -;; HACK `dumb-jump' uses the `helm-build-sync-source' macro, but this requires -;; helm be loaded before `dumb-jump' is byte-compiled during installation. -;; To ensure this, we declare helm before dumb-jump. -(when (modulep! :completion helm) - (package! helm)) - -;; -(package! dumb-jump :pin "0a783d1db610ff1dc4e1b7869589cff16ff92f7a") -(when (modulep! :completion ivy) - (package! ivy-xref :pin "a82e8e117d2dd62c28b6a3e3d6e4cfb11c0bda38")) -(when (modulep! :completion helm) - (package! helm-xref :pin "ea0e4ed8a9baf236e4085cbc7178241f109a53fa")) - -;; For dictionary and online lookup -(package! request :pin "01e338c335c07e4407239619e57361944a82cb8a") - -(when (modulep! +docsets) - (package! dash-docs :pin "29848b6b347ac520f7646c200ed2ec36cea3feda") - (when (modulep! :completion helm) - (package! helm-dash :pin "7f853bd34da666f0e9a883011c80f451b06f6c59")) - (when (modulep! :completion ivy) - (package! counsel-dash :pin "8decb980f111ebe7027361ee252279a9076da261"))) - -(when (modulep! +dictionary) - (if IS-MAC - (package! osx-dictionary :pin "0715e5a3ac659df32a0f0fabfbbeef0228fbd9a9") - (package! define-word :pin "31a8c67405afa99d0e25e7c86a4ee7ef84a808fe") - (package! powerthesaurus :pin "88bc5229cba1604c8f74db0a1456d99259d538cc") - (when (modulep! +offline) - (package! wordnut :pin "feac531404041855312c1a046bde7ea18c674915") - (package! synosaurus :pin "14d34fc92a77c3a916b4d58400424c44ae99cd81")))) diff --git a/.config/emacs/modules/tools/lsp/+eglot.el b/.config/emacs/modules/tools/lsp/+eglot.el @@ -1,58 +0,0 @@ -;;; tools/lsp/+eglot.el -*- lexical-binding: t; -*- - -(use-package! eglot - :commands eglot eglot-ensure - :hook (eglot-managed-mode . +lsp-optimization-mode) - :init - (setq eglot-sync-connect 1 - eglot-connect-timeout 10 - eglot-autoshutdown t - eglot-send-changes-idle-time 0.5 - ;; NOTE We disable eglot-auto-display-help-buffer because :select t in - ;; its popup rule causes eglot to steal focus too often. - eglot-auto-display-help-buffer nil) - (when (modulep! :checkers syntax) - (setq eglot-stay-out-of '(flymake))) - - :config - (set-popup-rule! "^\\*eglot-help" :size 0.15 :quit t :select t) - (set-lookup-handlers! 'eglot--managed-mode - :definition #'xref-find-definitions - :references #'xref-find-references - :implementations #'eglot-find-implementation - :type-definition #'eglot-find-typeDefinition - :documentation #'+eglot-lookup-documentation) - - (add-to-list 'doom-debug-variables '(eglot-events-buffer-size . 0)) - - (defadvice! +lsp--defer-server-shutdown-a (fn &optional server) - "Defer server shutdown for a few seconds. -This gives the user a chance to open other project files before the server is -auto-killed (which is a potentially expensive process). It also prevents the -server getting expensively restarted when reverting buffers." - :around #'eglot--managed-mode - (letf! (defun eglot-shutdown (server) - (if (or (null +lsp-defer-shutdown) - (eq +lsp-defer-shutdown 0)) - (prog1 (funcall eglot-shutdown server) - (+lsp-optimization-mode -1)) - (run-at-time - (if (numberp +lsp-defer-shutdown) +lsp-defer-shutdown 3) - nil (lambda (server) - (unless (eglot--managed-buffers server) - (prog1 (funcall eglot-shutdown server) - (+lsp-optimization-mode -1)))) - server))) - (funcall fn server)))) - - -(use-package! consult-eglot - :defer t - :when (modulep! :completion vertico) - :init - (map! :map eglot-mode-map [remap xref-find-apropos] #'consult-eglot-symbols)) - - -(use-package! flycheck-eglot - :when (modulep! :checkers syntax) - :hook (eglot-managed-mode . flycheck-eglot-mode)) diff --git a/.config/emacs/modules/tools/lsp/+lsp.el b/.config/emacs/modules/tools/lsp/+lsp.el @@ -1,192 +0,0 @@ -;;; tools/lsp/+lsp.el -*- lexical-binding: t; -*- - -(defvar +lsp-company-backends - (if (modulep! :editor snippets) - '(:separate company-capf company-yasnippet) - 'company-capf) - "The backends to prepend to `company-backends' in `lsp-mode' buffers. -Can be a list of backends; accepts any value `company-backends' accepts.") - - -;; -;;; Packages - -(use-package! lsp-mode - :commands lsp-install-server - :init - ;; Don't touch ~/.emacs.d, which could be purged without warning - (setq lsp-session-file (concat doom-cache-dir "lsp-session") - lsp-server-install-dir (concat doom-data-dir "lsp")) - ;; Don't auto-kill LSP server after last workspace buffer is killed, because I - ;; will do it for you, after `+lsp-defer-shutdown' seconds. - (setq lsp-keep-workspace-alive nil) - - ;; NOTE I tweak LSP's defaults in order to make its more expensive or imposing - ;; features opt-in. Some servers implement these poorly and, in most - ;; cases, it's safer to rely on Emacs' native mechanisms (eldoc vs - ;; lsp-ui-doc, open in popup vs sideline, etc). - - ;; Disable features that have great potential to be slow. - (setq lsp-enable-folding nil - lsp-enable-text-document-color nil) - ;; Reduce unexpected modifications to code - (setq lsp-enable-on-type-formatting nil) - ;; Make breadcrumbs opt-in; they're redundant with the modeline and imenu - (setq lsp-headerline-breadcrumb-enable nil) - - ;; Let doom bind the lsp keymap. - (when (modulep! :config default +bindings) - (setq lsp-keymap-prefix nil)) - - :config - (add-to-list 'doom-debug-variables 'lsp-log-io) - - (setq lsp-intelephense-storage-path (concat doom-data-dir "lsp-intelephense/") - lsp-vetur-global-snippets-dir - (expand-file-name - "vetur" (or (bound-and-true-p +snippets-dir) - (concat doom-user-dir "snippets/"))) - lsp-xml-jar-file (expand-file-name "org.eclipse.lsp4xml-0.3.0-uber.jar" lsp-server-install-dir) - lsp-groovy-server-file (expand-file-name "groovy-language-server-all.jar" lsp-server-install-dir)) - - ;; REVIEW Remove this once this is fixed upstream. - (add-to-list 'lsp-client-packages 'lsp-racket) - - (add-hook! 'doom-escape-hook - (defun +lsp-signature-stop-maybe-h () - "Close the displayed `lsp-signature'." - (when lsp-signature-mode - (lsp-signature-stop) - t))) - - (set-popup-rule! "^\\*lsp-\\(help\\|install\\)" :size 0.35 :quit t :select t) - (set-lookup-handlers! 'lsp-mode - :definition #'+lsp-lookup-definition-handler - :references #'+lsp-lookup-references-handler - :documentation '(lsp-describe-thing-at-point :async t) - :implementations '(lsp-find-implementation :async t) - :type-definition #'lsp-find-type-definition) - - (defadvice! +lsp--respect-user-defined-checkers-a (fn &rest args) - "Ensure user-defined `flycheck-checker' isn't overwritten by `lsp'." - :around #'lsp-diagnostics-flycheck-enable - (if flycheck-checker - (let ((old-checker flycheck-checker)) - (apply fn args) - (setq-local flycheck-checker old-checker)) - (apply fn args))) - - (add-hook! 'lsp-mode-hook #'+lsp-optimization-mode) - - (when (modulep! :completion company) - (add-hook! 'lsp-completion-mode-hook - (defun +lsp-init-company-backends-h () - (when lsp-completion-mode - (set (make-local-variable 'company-backends) - (cons +lsp-company-backends - (remove +lsp-company-backends - (remq 'company-capf company-backends)))))))) - - (defvar +lsp--deferred-shutdown-timer nil) - (defadvice! +lsp-defer-server-shutdown-a (fn &optional restart) - "Defer server shutdown for a few seconds. -This gives the user a chance to open other project files before the server is -auto-killed (which is a potentially expensive process). It also prevents the -server getting expensively restarted when reverting buffers." - :around #'lsp--shutdown-workspace - (if (or lsp-keep-workspace-alive - restart - (null +lsp-defer-shutdown) - (= +lsp-defer-shutdown 0)) - (prog1 (funcall fn restart) - (+lsp-optimization-mode -1)) - (when (timerp +lsp--deferred-shutdown-timer) - (cancel-timer +lsp--deferred-shutdown-timer)) - (setq +lsp--deferred-shutdown-timer - (run-at-time - (if (numberp +lsp-defer-shutdown) +lsp-defer-shutdown 3) - nil (lambda (workspace) - (with-lsp-workspace workspace - (unless (lsp--workspace-buffers workspace) - (let ((lsp-restart 'ignore)) - (funcall fn)) - (+lsp-optimization-mode -1)))) - lsp--cur-workspace)))) - - (when (modulep! :ui modeline +light) - (defvar-local lsp-modeline-icon nil) - - (add-hook! '(lsp-before-initialize-hook - lsp-after-initialize-hook - lsp-after-uninitialized-functions - lsp-before-open-hook - lsp-after-open-hook) - (defun +lsp-update-modeline (&rest _) - "Update modeline with lsp state." - (let* ((workspaces (lsp-workspaces)) - (face (if workspaces 'success 'warning)) - (label (if workspaces "LSP Connected" "LSP Disconnected"))) - (setq lsp-modeline-icon (concat - " " - (+modeline-format-icon 'faicon "rocket" "" face label -0.0575) - " ")) - (add-to-list 'global-mode-string - '(t (:eval lsp-modeline-icon)) - 'append)))))) - - -(use-package! lsp-ui - :hook (lsp-mode . lsp-ui-mode) - :init - (defadvice! +lsp--use-hook-instead-a (fn &rest args) - "Change `lsp--auto-configure' to not force `lsp-ui-mode' on us. Using a hook -instead is more sensible." - :around #'lsp--auto-configure - (letf! ((#'lsp-ui-mode #'ignore)) - (apply fn args))) - - :config - (when (modulep! +peek) - (set-lookup-handlers! 'lsp-ui-mode - :definition 'lsp-ui-peek-find-definitions - :implementations 'lsp-ui-peek-find-implementation - :references 'lsp-ui-peek-find-references - :async t)) - - (setq lsp-ui-peek-enable (modulep! +peek) - lsp-ui-doc-max-height 8 - lsp-ui-doc-max-width 72 ; 150 (default) is too wide - lsp-ui-doc-delay 0.75 ; 0.2 (default) is too naggy - lsp-ui-doc-show-with-mouse nil ; don't disappear on mouseover - lsp-ui-doc-position 'at-point - lsp-ui-sideline-ignore-duplicate t - ;; Don't show symbol definitions in the sideline. They are pretty noisy, - ;; and there is a bug preventing Flycheck errors from being shown (the - ;; errors flash briefly and then disappear). - lsp-ui-sideline-show-hover nil - ;; Re-enable icon scaling (it's disabled by default upstream for Emacs - ;; 26.x compatibility; see emacs-lsp/lsp-ui#573) - lsp-ui-sideline-actions-icon lsp-ui-sideline-actions-icon-default) - - (map! :map lsp-ui-peek-mode-map - "j" #'lsp-ui-peek--select-next - "k" #'lsp-ui-peek--select-prev - "C-k" #'lsp-ui-peek--select-prev-file - "C-j" #'lsp-ui-peek--select-next-file)) - - -(use-package! helm-lsp - :when (modulep! :completion helm) - :commands helm-lsp-workspace-symbol helm-lsp-global-workspace-symbol) - - -(use-package! lsp-ivy - :when (modulep! :completion ivy) - :commands lsp-ivy-workspace-symbol lsp-ivy-global-workspace-symbol) - - -(use-package! consult-lsp - :defer t - :when (modulep! :completion vertico) - :init - (map! :map lsp-mode-map [remap xref-find-apropos] #'consult-lsp-symbols)) diff --git a/.config/emacs/modules/tools/lsp/README.org b/.config/emacs/modules/tools/lsp/README.org @@ -1,155 +0,0 @@ -#+title: :tools lsp -#+subtitle: M-x vscode -#+created: March 05, 2019 -#+since: 21.12.0 - -* Description :unfold: -This module integrates [[https://langserver.org/][language servers]] into Doom Emacs. They provide features -you'd expect from IDEs, like code completion, realtime linting, language-aware -[[doom-package:imenu]]/[[doom-package:xref]] integration, jump-to-definition/references support, and more. - -As of this writing, this is the state of LSP support in Doom Emacs: - -| Module | Major modes | Default language server | -|------------------+---------------------------------------------------------+---------------------------------------------------------------| -| [[doom-module::lang cc]] | c-mode, c++-mode, objc-mode | ccls, clangd | -| [[doom-module::lang clojure]] | clojure-mode | clojure-lsp | -| [[doom-module::lang csharp]] | csharp-mode | omnisharp | -| [[doom-module::lang elixir]] | elixir-mode | elixir-ls | -| [[doom-module::lang fsharp]] | fsharp-mode | Mono, .NET core | -| [[doom-module::lang go]] | go-mode | go-langserver | -| [[doom-module::lang haskell]] | haskell-mode | haskell-language-server | -| [[doom-module::lang java]] | java-mode | lsp-java | -| [[doom-module::lang javascript]] | js2-mode, rjsx-mode, typescript-mode | ts-ls, deno-ls | -| [[doom-module::lang julia]] | julia-mode | LanguageServer.jl | -| [[doom-module::lang ocaml]] | tuareg-mode | ocaml-language-server | -| [[doom-module::lang php]] | php-mode | php-language-server | -| [[doom-module::lang purescript]] | purescript-mode | purescript-language-server | -| [[doom-module::lang python]] | python-mode | lsp-python-ms | -| [[doom-module::lang ruby]] | ruby-mode | solargraph | -| [[doom-module::lang rust]] | rust-mode | rls | -| [[doom-module::lang scala]] | scala-mode | metals | -| [[doom-module::lang sh]] | sh-mode | bash-language-server | -| [[doom-module::lang swift]] | swift-mode | sourcekit | -| [[doom-module::lang web]] | web-mode, css-mode, scss-mode, sass-mode, less-css-mode | vscode-css-languageserver-bin, vscode-html-languageserver-bin | -| [[doom-module::lang zig]] | zig-mode | zls | - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +eglot :: - Use [[https://elpa.gnu.org/packages/eglot.html][Eglot]] instead of [[https://github.com/emacs-lsp/lsp-mode][LSP-mode]] to implement the LSP client in Emacs. -- +peek :: - Use ~lsp-ui-peek~ when looking up definitions and references with - functionality from the [[doom-module::tools lookup]] module. - -** Packages -- [[doom-package:lsp-mode]] -- [[doom-package:lsp-ui]] -- [[doom-package:lsp-ivy]] ([[doom-module::completion ivy]]) -- [[doom-package:helm-lsp]] ([[doom-module::completion helm]]) -- [[doom-package:consult-lsp]] ([[doom-module::completion vertico]]) -- [[doom-package:eglot]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -To get LSP working, you'll need to do three things: - -1. Enable this module, -2. Install a language server appropriate for your targeted language(s). -3. Enable the [[doom-module:+lsp]] flag on the [[doom-module::lang]] modules you want to enable LSP support for. - -Different languages will need different language servers, some of which [[doom-package:lsp-mode]] -will prompt you to auto-install, but [[doom-package:eglot]] will not. - -A table that lists available language servers and how to install them can be -found [[https://emacs-lsp.github.io/lsp-mode/page/languages/][on the lsp-mode project README]]. The documentation of the module for your -targeted language will contain brief instructions as well. - -For eglot users, a list of [[https://github.com/joaotavora/eglot/blob/master/README.md#connecting-to-a-server][default servers supported is on Eglot's README]], -including instructions to register your own. - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** LSP-powered project search -Without the [[doom-module:+eglot]] flag, and when [[doom-module::completion ivy]], [[doom-module::completion helm]] or -[[doom-module::completion vertico]] is active, LSP is used to search a symbol indexed by the LSP -server: -| Keybind | Description | -|---------+-------------------------------------| -| [[kbd:][SPC c j]] | Jump to symbol in current workspace | -| [[kbd:][SPC c J]] | Jump to symbol in any workspace | - -** Differences between eglot and lsp-mode -The two projects are large and actively developed, so without writing a novel, -it can only be compared in (very) broad strokes: - -- [[doom-package:lsp-mode]] tends to be more featureful, beginner-friendly (e.g. offers to - install servers for you and has more [[https://emacs-lsp.github.io/lsp-mode][helpful documentation]]), and has a user - experience that feels familiar to modern editors/IDEs, but at the cost of - performance (at baseline) and complexity (it has more moving parts and - reinvents a number of wheels to achieve a slicker UI, like ~lsp-ui-peek~, - ~lsp-ui-sideline~, etc). - -- [[doom-package:eglot]] has fewer bells and whistles: it relies on built-in Emacs functionality - more (eldoc, xref, capf, project.el, etc), offers less pre-configuration for - you, and is more performant than lsp-mode (again, at baseline). It also works - with TRAMP out-of-the-box (lsp-mode needs some extra configuration). - -#+begin_quote - 💬 I recommend beginners use lsp-mode. More experienced users may also opt to - disable many of [[https://emacs-lsp.github.io/lsp-mode/tutorials/how-to-turn-off/][its inessential features]] to gain back some ground on - performance and complexity costs. -#+end_quote - -All that said, it's easy to switch between the two implementations by swapping -in/out the [[doom-module:+lsp]] or [[doom-module:+eglot]] flag when [[id:01cffea4-3329-45e2-a892-95a384ab2338][enabling this module]]. - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** Turn off lsp-mode's intrusive features -Many users may not like how many UI elements that lsp-mode adds. They have [[https://emacs-lsp.github.io/lsp-mode/tutorials/how-to-turn-off/][some -excellent documentation]] outlining what these features are called and how to turn -them off. - -* Troubleshooting -[[doom-report:][Report an issue?]] - -** My language server is not found -Check the entry in the [[../../../docs/faq.org][FAQ]] about "Doom can't find my executables/doesn't inherit -the correct ~PATH~" - -** LSP/Eglot is not started automatically in my buffer -Make sure that you have enabled the [[doom-module:+lsp]] flag on the appropriate module(s) (in -your ~doom!~ block in =$DOOMDIR/init.el=): -#+begin_src diff -:lang --python -+(python +lsp) -#+end_src - -** LSP is slow -Follow [[https://emacs-lsp.github.io/lsp-mode/page/performance/#tuning][lsp-tuning-guide]] to further fine-tune LSP mode performance. - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/tools/lsp/autoload/common.el b/.config/emacs/modules/tools/lsp/autoload/common.el @@ -1,10 +0,0 @@ -;;; tools/lsp/autoload/common.el -*- lexical-binding: t; -*- - -;;;###autodef (fset 'lsp! #'ignore) -(defun lsp! () - "Dispatch to call the currently used lsp client entrypoint" - (interactive) - (if (modulep! +eglot) - (eglot-ensure) - (unless (bound-and-true-p lsp-mode) - (lsp-deferred)))) diff --git a/.config/emacs/modules/tools/lsp/autoload/eglot.el b/.config/emacs/modules/tools/lsp/autoload/eglot.el @@ -1,39 +0,0 @@ -;;; tools/lsp/autoload/eglot.el -*- lexical-binding: t; -*- -;;;###if (modulep! +eglot) - -;;;###autodef -(defun set-eglot-client! (mode server-call) - "Add SERVER-CALL list as a possible lsp server for given major MODE. - -Example : (set-eglot-client! 'python-mode `(,(concat doom-data-dir \"lsp/mspyls/Microsoft.Python.LanguageServer\")))" - (after! eglot - (add-to-list 'eglot-server-programs `(,mode . ,server-call)))) - -;; HACK Eglot removed `eglot-help-at-point' in joaotavora/eglot@a044dec for a -;; more problematic approach of deferred to eldoc. Here, I've restored it. -;; Doom's lookup handlers try to open documentation in a separate window -;; (so they can be copied or kept open), but doing so with an eldoc buffer -;; is difficult because a) its contents are generated asynchronously, -;; making them tough to scrape, and b) their contents change frequently -;; (every time you move your cursor). -(defvar +eglot--help-buffer nil) -;;;###autoload -(defun +eglot-lookup-documentation (_identifier) - "Request documentation for the thing at point." - (eglot--dbind ((Hover) contents range) - (jsonrpc-request (eglot--current-server-or-lose) :textDocument/hover - (eglot--TextDocumentPositionParams)) - (let ((blurb (and (not (seq-empty-p contents)) - (eglot--hover-info contents range))) - (hint (thing-at-point 'symbol))) - (if blurb - (with-current-buffer - (or (and (buffer-live-p +eglot--help-buffer) - +eglot--help-buffer) - (setq +eglot--help-buffer (generate-new-buffer "*eglot-help*"))) - (with-help-window (current-buffer) - (rename-buffer (format "*eglot-help for %s*" hint)) - (with-current-buffer standard-output (insert blurb)) - (setq-local nobreak-char-display nil))) - (display-local-help)))) - 'deferred) diff --git a/.config/emacs/modules/tools/lsp/autoload/lsp-mode.el b/.config/emacs/modules/tools/lsp/autoload/lsp-mode.el @@ -1,75 +0,0 @@ -;;; tools/lsp/autoload/lsp-mode.el -*- lexical-binding: t; -*- -;;;###if (not (modulep! +eglot)) - -;;;###autodef -(defun set-lsp-priority! (client priority) - "Change the PRIORITY of lsp CLIENT." - (require 'lsp-mode) - (if-let (client (gethash client lsp-clients)) - (setf (lsp--client-priority client) - priority) - (error "No LSP client named %S" client))) - -;;;###autoload -(defun +lsp/uninstall-server (dir) - "Delete a LSP server from `lsp-server-install-dir'." - (interactive - (list (read-directory-name "Uninstall LSP server: " lsp-server-install-dir nil t))) - (unless (file-directory-p dir) - (user-error "Couldn't find %S directory" dir)) - (delete-directory dir 'recursive) - (message "Uninstalled %S" (file-name-nondirectory dir))) - -;;;###autoload -(defun +lsp/switch-client (client) - "Switch to another LSP server." - (interactive - (progn - (require 'lsp-mode) - (list (completing-read - "Select server: " - (or (mapcar #'lsp--client-server-id (lsp--filter-clients (-andfn #'lsp--supports-buffer? - #'lsp--server-binary-present?))) - (user-error "No available LSP clients for %S" major-mode)))))) - (require 'lsp-mode) - (let* ((client (if (symbolp client) client (intern client))) - (match (car (lsp--filter-clients (lambda (c) (eq (lsp--client-server-id c) client))))) - (workspaces (lsp-workspaces))) - (unless match - (user-error "Couldn't find an LSP client named %S" client)) - (let ((old-priority (lsp--client-priority match))) - (setf (lsp--client-priority match) 9999) - (unwind-protect - (if workspaces - (lsp-workspace-restart - (if (cdr workspaces) - (lsp--completing-read "Select server: " - workspaces - 'lsp--workspace-print - nil t) - (car workspaces))) - (lsp-mode +1)) - (add-transient-hook! 'lsp-after-initialize-hook - (setf (lsp--client-priority match) old-priority)))))) - -;;;###autoload -(defun +lsp-lookup-definition-handler () - "Find definition of the symbol at point using LSP." - (interactive) - (when-let (loc (lsp-request "textDocument/definition" - (lsp--text-document-position-params))) - (lsp-show-xrefs (lsp--locations-to-xref-items loc) nil nil) - 'deferred)) - -;;;###autoload -(defun +lsp-lookup-references-handler (&optional include-declaration) - "Find project-wide references of the symbol at point using LSP." - (interactive "P") - (when-let - (loc (lsp-request "textDocument/references" - (append (lsp--text-document-position-params) - (list - :context `(:includeDeclaration - ,(lsp-json-bool include-declaration)))))) - (lsp-show-xrefs (lsp--locations-to-xref-items loc) nil t) - 'deferred)) diff --git a/.config/emacs/modules/tools/lsp/config.el b/.config/emacs/modules/tools/lsp/config.el @@ -1,47 +0,0 @@ -;;; tools/lsp/config.el -*- lexical-binding: t; -*- - -(defvar +lsp-defer-shutdown 3 - "If non-nil, defer shutdown of LSP servers for this many seconds after last -workspace buffer is closed. - -This delay prevents premature server shutdown when a user still intends on -working on that project after closing the last buffer, or when programmatically -killing and opening many LSP/eglot-powered buffers.") - - -;; -;;; Common - -(defvar +lsp--default-read-process-output-max nil) -(defvar +lsp--default-gcmh-high-cons-threshold nil) -(defvar +lsp--optimization-init-p nil) - -(define-minor-mode +lsp-optimization-mode - "Deploys universal GC and IPC optimizations for `lsp-mode' and `eglot'." - :global t - :init-value nil - (if (not +lsp-optimization-mode) - (setq-default read-process-output-max +lsp--default-read-process-output-max - gcmh-high-cons-threshold +lsp--default-gcmh-high-cons-threshold - +lsp--optimization-init-p nil) - ;; Only apply these settings once! - (unless +lsp--optimization-init-p - (setq +lsp--default-read-process-output-max (default-value 'read-process-output-max) - +lsp--default-gcmh-high-cons-threshold (default-value 'gcmh-high-cons-threshold)) - (setq-default read-process-output-max (* 1024 1024)) - ;; REVIEW LSP causes a lot of allocations, with or without the native JSON - ;; library, so we up the GC threshold to stave off GC-induced - ;; slowdowns/freezes. Doom uses `gcmh' to enforce its GC strategy, - ;; so we modify its variables rather than `gc-cons-threshold' - ;; directly. - (setq-default gcmh-high-cons-threshold (* 2 +lsp--default-gcmh-high-cons-threshold)) - (gcmh-set-high-threshold) - (setq +lsp--optimization-init-p t)))) - - -;; -;;; Implementations - -(if (modulep! +eglot) - (load! "+eglot") - (load! "+lsp")) diff --git a/.config/emacs/modules/tools/lsp/doctor.el b/.config/emacs/modules/tools/lsp/doctor.el @@ -1,9 +0,0 @@ -;;; tools/lsp/doctor.el -*- lexical-binding: t; -*- - -(assert! (not (and (modulep! +eglot) - (modulep! +peek))) - "+eglot and +peek flags are not compatible. Peek uses lsp-mode, while Eglot is another package altogether for LSP.") - -(unless (executable-find "npm") - (warn! "Couldn't find npm, most server installers won't work and will have to be installed manually. -For more information, see https://emacs-lsp.github.io/lsp-mode/page/languages/.")) diff --git a/.config/emacs/modules/tools/lsp/packages.el b/.config/emacs/modules/tools/lsp/packages.el @@ -1,18 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; tools/lsp/packages.el - -(if (modulep! +eglot) - (progn - (package! eglot :pin "e501275e06952889056268dabe08ccd0dbaf23e5") - (when (modulep! :completion vertico) - (package! consult-eglot :pin "6504ccd2b7555452c61cc24a45965f7e2a37c44d")) - (when (modulep! :checkers syntax) - (package! flycheck-eglot :pin "9abab011071c93250a894cf2bfeaf30c8e3367a7"))) - (package! lsp-mode :pin "a655f3600e040f872408da0e9c1b9fe65ca0aad9") - (package! lsp-ui :pin "295d8984da06a745b0a36c56e28ce915bc389adb") - (when (modulep! :completion ivy) - (package! lsp-ivy :pin "9ecf4dd9b1207109802bd1882aa621eb1c385106")) - (when (modulep! :completion helm) - (package! helm-lsp :pin "c2c6974dadfac459b1a69a1217441283874cea92")) - (when (modulep! :completion vertico) - (package! consult-lsp :pin "f8db3252c0daa41225ba4ed1c0d178b281cd3e90"))) diff --git a/.config/emacs/modules/tools/magit/README.org b/.config/emacs/modules/tools/magit/README.org @@ -1,99 +0,0 @@ -#+title: :tools magit -#+subtitle: Wield git like a wizard -#+created: February 20, 2017 -#+since: 2.0.0 - -* Description :unfold: -This module provides Magit, an interface to the Git version control system. - -** Maintainers -- [[doom-user:][@hlissner]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +forge :: - Enable Forge; a porcelain for managing Github issues and PRs from within - Emacs. Will take a while on first run to build =emacsql-sqlite=. - -** Packages -- [[doom-package:evil-magit]] if [[doom-module::editor evil +everywhere]] -- [[doom-package:forge]] if [[doom-module:+forge]] -- [[doom-package:code-review]] if [[doom-module:+forge]] -- [[doom-package:magit]] -- [[doom-package:magit-todos]] - -** Hacks -- [[doom-package:magit]] has been modified to recognize =$XDG_CACHE_HOME/git/credential/socket=. -- [[doom-package:magit]] has been modified to invalidate the projectile cache when you check out - a new branch or commit. -- [[doom-package:magit]] has been modified to revert repo buffers (e.g. after changing branches) - when you later switch to them, rather than all at once. -- [[doom-package:forge]] was modified to defer compilation of emacsql-sqlite until you try to use - forge, rather than when magit first loads (which could be as soon as startup). - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires: -- [[https://git-scm.com/][Git]] -- [[doom-module:+forge]] requires [[https://magit.vc/manual/forge/Token-Creation.html#Token-Creation][a Github API token]] -- [[doom-package:code-review]] will also require a token setup (see [[https://github.com/wandersoncferreira/code-review#configuration][configuration]] for your particular forge) - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -Start magit with [[kbd:][<leader> g g]] (~M-x magit-status~). - -If you are new to Magit, see the [[https://github.com/magit/magit#getting-started][Getting Started]] section of its project readme. - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** Enable Gravatars -To enable gravatars when viewing commits: -#+begin_src emacs-lisp -;; in $DOOMDIR/config.el -(after! magit - (setq magit-revision-show-gravatars '("^Author: " . "^Commit: "))) -#+end_src - -** Enable granular diff-highlights for all hunks -By default, changes are highlighted *linewise* for all but the selected hunk. -This is so for [[https://magit.vc/manual/magit/Performance.html][performance reasons]]. You can enable character-wise highlights for -/all/ visible hunks with: -#+begin_src emacs-lisp -;; in $DOOMDIR/config.el -(after! magit - (setq magit-diff-refine-hunk 'all)) -#+end_src - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -** "I recently updated and now I get 'deferred error : (wrong-type-argument sequencep code-review--auth-token-set\?)' whenever I try to review'" -The previous package "github-review" was replaced with a package that supercedes it called "code-review", which requires a simple change in your authinfo file. - -#+begin_src authinfo -machine api.github.com login yourlogin^github-review password MYTOKENGOESHERE -#+end_src - -becomes - -#+begin_src authinfo -machine api.github.com login yourlogin^code-review password MYTOKENGOESHERE -#+end_src - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/tools/magit/autoload.el b/.config/emacs/modules/tools/magit/autoload.el @@ -1,161 +0,0 @@ -;;; tools/magit/autoload.el -*- lexical-binding: t; -*- - -;; HACK Magit complains loudly (but harmlessly) when it can't determine its own -;; version in a sparse clone. Since I'd rather not compromise on shallow -;; clones, I've gimped `magit-version' so it doesn't complain (unless -;; called interactively). -;;;###autoload -(defadvice! +magit--ignore-version-a (fn &rest args) - :around #'magit-version - (let ((inhibit-message (not (called-interactively-p 'any)))) - (apply fn args))) - -;;;###autoload -(defun +magit-display-buffer-fn (buffer) - "Same as `magit-display-buffer-traditional', except... - -- If opened from a commit window, it will open below it. -- Magit process windows are always opened in small windows below the current. -- Everything else will reuse the same window." - (let ((buffer-mode (buffer-local-value 'major-mode buffer))) - (display-buffer - buffer (cond - ((and (eq buffer-mode 'magit-status-mode) - (get-buffer-window buffer)) - '(display-buffer-reuse-window)) - ;; Any magit buffers opened from a commit window should open below - ;; it. Also open magit process windows below. - ((or (bound-and-true-p git-commit-mode) - (eq buffer-mode 'magit-process-mode)) - (let ((size (if (eq buffer-mode 'magit-process-mode) - 0.35 - 0.7))) - `(display-buffer-below-selected - . ((window-height . ,(truncate (* (window-height) size))))))) - - ;; Everything else should reuse the current window. - ((or (not (derived-mode-p 'magit-mode)) - (not (memq (with-current-buffer buffer major-mode) - '(magit-process-mode - magit-revision-mode - magit-diff-mode - magit-stash-mode - magit-status-mode)))) - '(display-buffer-same-window)) - - ('(+magit--display-buffer-in-direction)))))) - -(defun +magit--display-buffer-in-direction (buffer alist) - "`display-buffer-alist' handler that opens BUFFER in a direction. - -This differs from `display-buffer-in-direction' in one way: it will try to use a -window that already exists in that direction. It will split otherwise." - (let ((direction (or (alist-get 'direction alist) - +magit-open-windows-in-direction)) - (origin-window (selected-window))) - (if-let (window (window-in-direction direction)) - (unless magit-display-buffer-noselect - (select-window window)) - (if-let (window (and (not (one-window-p)) - (window-in-direction - (pcase direction - (`right 'left) - (`left 'right) - ((or `up `above) 'down) - ((or `down `below) 'up))))) - (unless magit-display-buffer-noselect - (select-window window)) - (let ((window (split-window nil nil direction))) - (when (and (not magit-display-buffer-noselect) - (memq direction '(right down below))) - (select-window window)) - (display-buffer-record-window 'reuse window buffer) - (set-window-buffer window buffer) - (set-window-parameter window 'quit-restore (list 'window 'window origin-window buffer)) - (set-window-prev-buffers window nil)))) - (unless magit-display-buffer-noselect - (switch-to-buffer buffer t t) - (selected-window)))) - - -;; -;;; Auto-revert - -(defvar +magit--stale-p nil) - -(defun +magit--revert-buffer (buffer) - (with-current-buffer buffer - (kill-local-variable '+magit--stale-p) - (when (and buffer-file-name (file-exists-p buffer-file-name)) - (if (buffer-modified-p (current-buffer)) - (when (bound-and-true-p vc-mode) - (vc-refresh-state) - (force-mode-line-update)) - (revert-buffer t t t))))) - -;;;###autoload -(defun +magit-mark-stale-buffers-h () - "Revert all visible buffers and mark buried buffers as stale. - -Stale buffers are reverted when they are switched to, assuming they haven't been -modified." - (dolist (buffer (buffer-list)) - (when (buffer-live-p buffer) - (if (get-buffer-window buffer) - (+magit--revert-buffer buffer) - (with-current-buffer buffer - (setq-local +magit--stale-p t)))))) - -;;;###autoload -(defun +magit-revert-buffer-maybe-h () - "Update `vc' and `git-gutter' if out of date." - (when +magit--stale-p - (+magit--revert-buffer (current-buffer)))) - - -;; -;;; Commands - -;;;###autoload -(defun +magit/quit (&optional kill-buffer) - "Bury the current magit buffer. - -If KILL-BUFFER, kill this buffer instead of burying it. -If the buried/killed magit buffer was the last magit buffer open for this repo, -kill all magit buffers for this repo." - (interactive "P") - (let ((topdir (magit-toplevel))) - (funcall magit-bury-buffer-function kill-buffer) - (or (cl-find-if (lambda (win) - (with-selected-window win - (and (derived-mode-p 'magit-mode) - (equal magit--default-directory topdir)))) - (window-list)) - (+magit/quit-all)))) - -;;;###autoload -(defun +magit/quit-all () - "Kill all magit buffers for the current repository." - (interactive) - (mapc #'+magit--kill-buffer (magit-mode-get-buffers)) - (+magit-mark-stale-buffers-h)) - -(defun +magit--kill-buffer (buf) - "TODO" - (when (and (bufferp buf) (buffer-live-p buf)) - (let ((process (get-buffer-process buf))) - (if (not (processp process)) - (kill-buffer buf) - (with-current-buffer buf - (if (process-live-p process) - (run-with-timer 5 nil #'+magit--kill-buffer buf) - (kill-process process) - (kill-buffer buf))))))) - -;;;###autoload -(defun +magit/start-code-review (arg) - (interactive "P") - (call-interactively - (if (or arg (not (featurep 'forge))) - #'code-review-start - #'code-review-forge-pr-at-point))) diff --git a/.config/emacs/modules/tools/magit/config.el b/.config/emacs/modules/tools/magit/config.el @@ -1,293 +0,0 @@ -;;; tools/magit/config.el -*- lexical-binding: t; -*- - -(defvar +magit-open-windows-in-direction 'right - "What direction to open new windows from the status buffer. -For example, diffs and log buffers. Accepts `left', `right', `up', and `down'.") - -(defvar +magit-fringe-size '(13 . 1) - "Size of the fringe in magit-mode buffers. - -Can be an integer or a cons cell whose CAR and CDR are integer widths for the -left and right fringe. - -Only has an effect in GUI Emacs.") - - -;; -;;; Packages - -(use-package! magit - :commands magit-file-delete - :defer-incrementally (dash f s with-editor git-commit package eieio transient) - :init - (setq magit-auto-revert-mode nil) ; we do this ourselves further down - ;; Must be set early to prevent ~/.config/emacs/transient from being created - (setq transient-levels-file (concat doom-data-dir "transient/levels") - transient-values-file (concat doom-data-dir "transient/values") - transient-history-file (concat doom-data-dir "transient/history")) - :config - (add-to-list 'doom-debug-variables 'magit-refresh-verbose) - - (setq transient-default-level 5 - magit-diff-refine-hunk t ; show granular diffs in selected hunk - ;; Don't autosave repo buffers. This is too magical, and saving can - ;; trigger a bunch of unwanted side-effects, like save hooks and - ;; formatters. Trust the user to know what they're doing. - magit-save-repository-buffers nil - ;; Don't display parent/related refs in commit buffers; they are rarely - ;; helpful and only add to runtime costs. - magit-revision-insert-related-refs nil) - (add-hook 'magit-process-mode-hook #'goto-address-mode) - - (defadvice! +magit-revert-repo-buffers-deferred-a (&rest _) - :after '(magit-checkout magit-branch-and-checkout) - ;; Since the project likely now contains new files, best we undo the - ;; projectile cache so it can be regenerated later. - (projectile-invalidate-cache nil) - ;; Use a more efficient strategy to auto-revert buffers whose git state has - ;; changed: refresh the visible buffers immediately... - (+magit-mark-stale-buffers-h)) - ;; ...then refresh the rest only when we switch to them, not all at once. - (add-hook 'doom-switch-buffer-hook #'+magit-revert-buffer-maybe-h) - - ;; Center the target file, because it's poor UX to have it at the bottom of - ;; the window after invoking `magit-status-here'. - (advice-add #'magit-status-here :after #'doom-recenter-a) - - ;; The default location for git-credential-cache is in - ;; ~/.cache/git/credential. However, if ~/.git-credential-cache/ exists, then - ;; it is used instead. Magit seems to be hardcoded to use the latter, so here - ;; we override it to have more correct behavior. - (unless (file-exists-p "~/.git-credential-cache/") - (setq magit-credential-cache-daemon-socket - (doom-glob (or (getenv "XDG_CACHE_HOME") - "~/.cache/") - "git/credential/socket"))) - - ;; Prevent sudden window position resets when staging/unstaging/discarding/etc - ;; hunks in `magit-status-mode' buffers. It's disorienting, especially on - ;; larger projects. - (defvar +magit--pos nil) - (add-hook! 'magit-pre-refresh-hook - (defun +magit--set-window-state-h () - (setq-local +magit--pos (list (current-buffer) (point) (window-start))))) - (add-hook! 'magit-post-refresh-hook - (defun +magit--restore-window-state-h () - (when (and +magit--pos (eq (current-buffer) (car +magit--pos))) - (goto-char (cadr +magit--pos)) - (set-window-start nil (caddr +magit--pos) t) - (kill-local-variable '+magit--pos)))) - - ;; Magit uses `magit-display-buffer-traditional' to display windows, by - ;; default, which is a little primitive. `+magit-display-buffer' marries - ;; `magit-display-buffer-fullcolumn-most-v1' with - ;; `magit-display-buffer-same-window-except-diff-v1', except: - ;; - ;; 1. Magit sub-buffers (like `magit-log') that aren't spawned from a status - ;; screen are opened as popups. - ;; 2. The status screen isn't buried when viewing diffs or logs from the - ;; status screen. - (setq transient-display-buffer-action '(display-buffer-below-selected) - magit-display-buffer-function #'+magit-display-buffer-fn - magit-bury-buffer-function #'magit-mode-quit-window) - (set-popup-rule! "^\\(?:\\*magit\\|magit:\\| \\*transient\\*\\)" :ignore t) - (add-hook 'magit-popup-mode-hook #'hide-mode-line-mode) - - ;; Add additional switches that seem common enough - (transient-append-suffix 'magit-fetch "-p" - '("-t" "Fetch all tags" ("-t" "--tags"))) - (transient-append-suffix 'magit-pull "-r" - '("-a" "Autostash" "--autostash")) - - ;; so magit buffers can be switched to (except for process buffers) - (add-hook! 'doom-real-buffer-functions - (defun +magit-buffer-p (buf) - (with-current-buffer buf - (and (derived-mode-p 'magit-mode) - (not (eq major-mode 'magit-process-mode)))))) - - ;; Clean up after magit by killing leftover magit buffers and reverting - ;; affected buffers (or at least marking them as need-to-be-reverted). - (define-key magit-mode-map "q" #'+magit/quit) - (define-key magit-mode-map "Q" #'+magit/quit-all) - - ;; Close transient with ESC - (define-key transient-map [escape] #'transient-quit-one) - - (add-hook! 'magit-section-mode-hook - (add-hook! 'window-configuration-change-hook :local - (defun +magit-enlargen-fringe-h () - "Make fringe larger in magit." - (and (display-graphic-p) - (derived-mode-p 'magit-section-mode) - +magit-fringe-size - (let ((left (or (car-safe +magit-fringe-size) +magit-fringe-size)) - (right (or (cdr-safe +magit-fringe-size) +magit-fringe-size))) - (set-window-fringes nil left right)))))) - - ;; An optimization that particularly affects macOS and Windows users: by - ;; resolving `magit-git-executable' Emacs does less work to find the - ;; executable in your PATH, which is great because it is called so frequently. - ;; However, absolute paths will break magit in TRAMP/remote projects if the - ;; git executable isn't in the exact same location. - (add-hook! 'magit-status-mode-hook - (defun +magit-optimize-process-calls-h () - (when-let (path (executable-find magit-git-executable t)) - (setq-local magit-git-executable path)))) - - (add-hook! 'magit-diff-visit-file-hook - (defun +magit-reveal-point-if-invisible-h () - "Reveal the point if in an invisible region." - (if (derived-mode-p 'org-mode) - (org-reveal '(4)) - (require 'reveal) - (reveal-post-command))))) - - -(use-package! forge - :when (modulep! +forge) - ;; We defer loading even further because forge's dependencies will try to - ;; compile emacsql, which is a slow and blocking operation. - :after-call magit-status - :commands forge-create-pullreq forge-create-issue - :preface - (setq forge-database-file (concat doom-data-dir "forge/forge-database.sqlite")) - (setq forge-add-default-bindings (not (modulep! :editor evil +everywhere))) - :config - ;; All forge list modes are derived from `forge-topic-list-mode' - (map! :map forge-topic-list-mode-map :n "q" #'kill-current-buffer) - (when (not forge-add-default-bindings) - (map! :map magit-mode-map [remap magit-browse-thing] #'forge-browse-dwim - :map magit-remote-section-map [remap magit-browse-thing] #'forge-browse-remote - :map magit-branch-section-map [remap magit-browse-thing] #'forge-browse-branch)) - (set-popup-rule! "^\\*?[0-9]+:\\(?:new-\\|[0-9]+$\\)" :size 0.45 :modeline t :ttl 0 :quit nil) - (set-popup-rule! "^\\*\\(?:[^/]+/[^ ]+ #[0-9]+\\*$\\|Issues\\|Pull-Requests\\|forge\\)" :ignore t) - - (defadvice! +magit--forge-get-repository-lazily-a (&rest _) - "Make `forge-get-repository' return nil if the binary isn't built yet. -This prevents emacsql getting compiled, which appears to come out of the blue -and blocks Emacs for a short while." - :before-while #'forge-get-repository - (file-executable-p emacsql-sqlite-executable)) - - (defadvice! +magit--forge-build-binary-lazily-a (&rest _) - "Make `forge-dispatch' only build emacsql if necessary. -Annoyingly, the binary gets built as soon as Forge is loaded. Since we've -disabled that in `+magit--forge-get-repository-lazily-a', we must manually -ensure it is built when we actually use Forge." - :before #'forge-dispatch - (unless (file-executable-p emacsql-sqlite-executable) - (emacsql-sqlite-compile 2) - (if (not (file-executable-p emacsql-sqlite-executable)) - (message (concat "Failed to build emacsql; forge may not work correctly.\n" - "See *Compile-Log* buffer for details")) - ;; HACK Due to changes upstream, forge doesn't initialize completely if - ;; it doesn't find `emacsql-sqlite-executable', so we have to do it - ;; manually after installing it. - (setq forge--sqlite-available-p t) - (magit-add-section-hook 'magit-status-sections-hook 'forge-insert-pullreqs nil t) - (magit-add-section-hook 'magit-status-sections-hook 'forge-insert-issues nil t) - (after! forge-topic - (dolist (hook forge-bug-reference-hooks) - (add-hook hook #'forge-bug-reference-setup))))))) - - -(use-package! code-review - :when (modulep! +forge) - :after magit - :init - ;; TODO This needs to either a) be cleaned up or better b) better map things - ;; to fit - (after! evil-collection-magit - (dolist (binding evil-collection-magit-mode-map-bindings) - (pcase-let* ((`(,states _ ,evil-binding ,fn) binding)) - (dolist (state states) - (evil-collection-define-key state 'code-review-mode-map evil-binding fn)))) - (evil-set-initial-state 'code-review-mode evil-default-state)) - (setq code-review-db-database-file (concat doom-data-dir "code-review/code-review-db-file.sqlite") - code-review-log-file (concat doom-data-dir "code-review/code-review-error.log") - code-review-download-dir (concat doom-data-dir "code-review/")) - :config - (transient-append-suffix 'magit-merge "i" - '("y" "Review pull request" +magit/start-code-review)) - (after! forge - (transient-append-suffix 'forge-dispatch "c u" - '("c r" "Review pull request" +magit/start-code-review)))) - - -(use-package! magit-todos - :after magit - :config - (setq magit-todos-keyword-suffix "\\(?:([^)]+)\\)?:?") ; make colon optional - (define-key magit-todos-section-map "j" nil)) - - -(use-package! evil-collection-magit - :when (modulep! :editor evil +everywhere) - :defer t - :init (defvar evil-collection-magit-use-z-for-folds t) - :config - ;; q is enough; ESC is way too easy for a vimmer to accidentally press, - ;; especially when traversing modes in magit buffers. - (evil-define-key* 'normal magit-status-mode-map [escape] nil) - - (after! code-review - (map! :map code-review-mode-map - :n "r" #'code-review-transient-api - :n "RET" #'code-review-comment-add-or-edit)) - - ;; Some extra vim-isms I thought were missing from upstream - (evil-define-key* '(normal visual) magit-mode-map - "*" #'magit-worktree - "zt" #'evil-scroll-line-to-top - "zz" #'evil-scroll-line-to-center - "zb" #'evil-scroll-line-to-bottom - "g=" #'magit-diff-default-context - "gi" #'forge-jump-to-issues - "gm" #'forge-jump-to-pullreqs) - - ;; Fix these keybinds because they are blacklisted - ;; REVIEW There must be a better way to exclude particular evil-collection - ;; modules from the blacklist. - (map! (:map magit-mode-map - :nv "q" #'+magit/quit - :nv "Q" #'+magit/quit-all - :nv "]" #'magit-section-forward-sibling - :nv "[" #'magit-section-backward-sibling - :nv "gr" #'magit-refresh - :nv "gR" #'magit-refresh-all) - (:map magit-status-mode-map - :nv "gz" #'magit-refresh) - (:map magit-diff-mode-map - :nv "gd" #'magit-jump-to-diffstat-or-diff)) - - ;; A more intuitive behavior for TAB in magit buffers: - (define-key! 'normal - (magit-status-mode-map - magit-stash-mode-map - magit-revision-mode-map - magit-process-mode-map - magit-diff-mode-map) - [tab] #'magit-section-toggle) - - (after! git-rebase - (dolist (key '(("M-k" . "gk") ("M-j" . "gj"))) - (when-let (desc (assoc (car key) evil-collection-magit-rebase-commands-w-descriptions)) - (setcar desc (cdr key)))) - (evil-define-key* evil-collection-magit-state git-rebase-mode-map - "gj" #'git-rebase-move-line-down - "gk" #'git-rebase-move-line-up))) - - -(use-package! evil-collection-magit-section - :when (modulep! :editor evil +everywhere) - :defer t - :init - (defvar evil-collection-magit-section-use-z-for-folds evil-collection-magit-use-z-for-folds) - (after! magit-section - ;; These numbered keys mask the numerical prefix keys. Since they've already - ;; been replaced with z1, z2, z3, etc (and 0 with g=), there's no need to - ;; keep them around: - (undefine-key! magit-section-mode-map "M-1" "M-2" "M-3" "M-4" "1" "2" "3" "4" "0") - ;; `evil-collection-magit-section' binds these redundant keys. - (map! :map magit-section-mode-map :n "1" nil :n "2" nil :n "3" nil :n "4" nil))) diff --git a/.config/emacs/modules/tools/magit/packages.el b/.config/emacs/modules/tools/magit/packages.el @@ -1,14 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; tools/magit/packages.el - -(when (package! magit :pin "97a95f70079b6613bf98d2306279d3e03fe51234") - (when (modulep! +forge) - (package! forge :pin "ba35ffc9bafc6457cc95633904e53e34e544543f") - (package! code-review - :recipe (:files ("graphql" "code-review*.el")) - :pin "26f426e99221a1f9356aabf874513e9105b68140") - ; HACK closql c3b34a6ec438 breaks code-review wandersoncferreira/code-review#245, - ; and the current forge commit (but forge does have an upstream fix), - ; pinned as a temporary measure to prevent user breakages - (package! closql :pin "0a7226331ff1f96142199915c0ac7940bac4afdd")) - (package! magit-todos :pin "c6f3fd03aa5b750636c2647253f21cc03329566c")) diff --git a/.config/emacs/modules/tools/make/README.org b/.config/emacs/modules/tools/make/README.org @@ -1,53 +0,0 @@ -#+title: :tools make -#+subtitle: The discount build system -#+created: September 25, 2017 -#+since: 2.0.6 - -* Description :unfold: -This module adds commands for executing Makefile targets. - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:makefile-executor]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires ~make~. - -* TODO Usage -#+begin_quote -🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -To invoke a make command: ~M-x +make/run~ - -To rerun the last make command: ~M-x +make/run-last~ - -* TODO Configuration -#+begin_quote -🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote -🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/tools/make/autoload.el b/.config/emacs/modules/tools/make/autoload.el @@ -1,25 +0,0 @@ -;;; tools/make/autoload.el -*- lexical-binding: t; -*- - -(require 'makefile-executor) - -;;;###autoload -(defun +make/run () - "Run a make task in the current project. If multiple makefiles are available, -you'll be prompted to select one." - (interactive) - (if (doom-project-p) - (makefile-executor-execute-project-target) - (let ((makefile (cl-loop with buffer-file = (or buffer-file-name default-directory) - for file in (list "Makefile" "makefile") - if (locate-dominating-file buffer-file file) - return file))) - (unless makefile - (user-error "Cannot find a makefile in the current project")) - (let ((default-directory (file-name-directory makefile))) - (makefile-executor-execute-target makefile))))) - -;;;###autoload -(defun +make/run-last () - "TODO" - (interactive) - (makefile-executor-execute-last nil)) diff --git a/.config/emacs/modules/tools/make/packages.el b/.config/emacs/modules/tools/make/packages.el @@ -1,4 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; tools/make/packages.el - -(package! makefile-executor :pin "170d14d834a0d163cd618d642d4580ff75b014be") diff --git a/.config/emacs/modules/tools/pass/README.org b/.config/emacs/modules/tools/pass/README.org @@ -1,64 +0,0 @@ -#+title: :tools pass -#+subtitle: A password manager for nerds -#+created: May 04, 2020 -#+since: 21.12.0 - -* Description :unfold: -This module provides an Emacs interface to [[https://www.passwordstore.org/][Pass]]. - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +auth :: - Allow Emacs to use pass for authentication (via ~auth-source-pass~). - -** Packages -- [[doom-package:helm-pass]] if [[doom-module::completion helm]] -- [[doom-package:ivy-pass]] if [[doom-module::completion ivy]] -- [[doom-package:pass]] -- [[doom-package:password-store]] -- [[doom-package:password-store-otp]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires [[https://www.passwordstore.org/][pass]], [[https://gnupg.org/][GnuPG]], and a password library. - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -Start using this module with ~M-x pass~. - -| keybinding | command | -|------------+---------------------------| -| =j= | ~pass-next-entry~ | -| =k= | ~pass-previous-entry~ | -| =d= | ~pass-kill~ | -| =C-j= | ~pass-next-directory~ | -| =C-k= | ~pass-previous-directory~ | - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/tools/pass/autoload/consult.el b/.config/emacs/modules/tools/pass/autoload/consult.el @@ -1,21 +0,0 @@ -;;; tools/pass/autoload/consult.el -*- lexical-binding: t; -*- -;;;###if (modulep! :completion vertico) - -;;;###autoload -(defun +pass/consult (arg pass) - "TODO" - (interactive - (list current-prefix-arg - (progn - (require 'consult) - (consult--read (password-store-list) - :prompt "Pass: " - :sort nil - :require-match t - :category 'pass)))) - (funcall (if arg - #'password-store-url - #'password-store-copy) - pass)) - -;; TODO Add embark actions to +pass/consult diff --git a/.config/emacs/modules/tools/pass/autoload/ivy.el b/.config/emacs/modules/tools/pass/autoload/ivy.el @@ -1,21 +0,0 @@ -;;; tools/pass/autoload/ivy.el -*- lexical-binding: t; -*- -;;;###if (modulep! :completion ivy) - -;;;###autoload -(defun +pass/ivy (arg) - "Complete and act on password store entries." - (interactive "P") - (ivy-read "Pass: " (password-store-list) - :action (if arg - #'password-store-url - #'password-store-copy) - :caller '+pass/ivy)) - -(after! ivy - (ivy-add-actions - '+pass/ivy - '(("o" password-store-copy "copy password") - ("e" password-store-edit "edit entry") - ("u" +pass/copy-user "copy username") - ("b" password-store-url "open url in browser") - ("f" password-store-copy-field "get field")))) diff --git a/.config/emacs/modules/tools/pass/autoload/pass.el b/.config/emacs/modules/tools/pass/autoload/pass.el @@ -1,67 +0,0 @@ -;;; tools/pass/autoload/pass.el -*- lexical-binding: t; -*- - -(defun +pass--copy-username (entry) - (if-let* ((user (+pass-get-field entry +pass-user-fields))) - (progn (password-store-clear) - (message "Copied username to the kill ring.") - (kill-new user)) - (error "Username not found."))) - - -;; -;; API - -;;;###autoload (autoload 'auth-source-pass-parse-entry "auth-source-pass") -;;;###autoload -(defalias '+pass-get-entry #'auth-source-pass-parse-entry) - -;;;###autoload -(defun +pass-get-field (entry fields &optional noerror) - "Fetches the value of a field. FIELDS can be a list of string field names or a -single one. If a list, the first field found will be returned. Will error out -otherwise, unless NOERROR is non-nill." - (if-let* ((data (if (listp entry) entry (+pass-get-entry entry)))) - (cl-loop for key in (ensure-list fields) - when (assoc key data) - return (cdr it)) - (unless noerror - (error "Couldn't find entry: %s" entry)))) - -;;;###autoload -(defun +pass-get-user (entry) - "Fetches the user field from ENTRY. Each of `+pass-user-fields' are tried in -search of your username. May prompt for your gpg passphrase." - (+pass-get-field entry +pass-user-fields)) - -;;;###autoload -(defun +pass-get-secret (entry) - "Fetches your secret from ENTRY. May prompt for your gpg passphrase." - (+pass-get-field entry 'secret)) - - -;; -;; Commands - -;;;###autoload (autoload 'password-store-dir "password-store") -;;;###autoload (autoload 'password-store-list "password-store") -;;;###autoload (autoload 'password-store--completing-read "password-store") - -;;;###autoload -(define-obsolete-function-alias '+pass/edit-entry #'password-store-edit "21.12") - -;;;###autoload -(define-obsolete-function-alias '+pass/copy-field #'password-store-copy-field "21.12") - -;;;###autoload -(define-obsolete-function-alias '+pass/copy-secret #'password-store-copy "21.12") - -;;;###autoload -(defun +pass/copy-user (entry) - "Interactively search for an entry and copy the login to your clipboard. The -fields in `+pass-user-fields' is used to find the login field." - (interactive - (list (password-store--completing-read))) - (+pass--copy-username entry)) - -;;;###autoload -(define-obsolete-function-alias '+pass/browse-url #'password-store-url "21.12") diff --git a/.config/emacs/modules/tools/pass/config.el b/.config/emacs/modules/tools/pass/config.el @@ -1,33 +0,0 @@ -;;; tools/pass/config.el -*- lexical-binding: t; -*- - -(defvar +pass-user-fields '("login" "user" "username" "email") - "A list of fields for `+pass/ivy' to search for the username.") - -(defvar +pass-url-fields '("url" "site" "location") - "A list of fields for `+pass/ivy' to search for the username.") - - -;; -;; Packages - -;;;###package password-store -(setq password-store-password-length 12) - -(after! evil-collection-pass - ;; FIXME This needs to be upstreamed to evil-collection. - (add-to-list 'evil-collection-pass-command-to-label '(pass-update-buffer . "gr"))) - -(after! pass - (set-evil-initial-state! 'pass-mode 'normal) - (set-popup-rule! "^\\*Password-Store" :side 'left :size 0.25 :quit nil) - (map! :map pass-mode-map - :n "j" #'pass-next-entry - :n "k" #'pass-prev-entry - :n "d" #'pass-kill - :n "C-j" #'pass-next-directory - :n "C-k" #'pass-prev-directory)) - - -;; Is built into Emacs 26+ -(when (modulep! +auth) - (auth-source-pass-enable)) diff --git a/.config/emacs/modules/tools/pass/packages.el b/.config/emacs/modules/tools/pass/packages.el @@ -1,11 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; tools/pass/packages.el - -(package! pass :pin "5651da53137db9adcb125b4897c2fe27eeb4368d") -(package! password-store :pin "26d2dae04bb76a87be6960861c10432820cd5d55") -(package! password-store-otp :pin "be3a00a981921ed1b2f78012944dc25eb5a0beca") - -(when (modulep! :completion ivy) - (package! ivy-pass :pin "5b523de1151f2109fdd6a8114d0af12eef83d3c5")) -(when (modulep! :completion helm) - (package! helm-pass :pin "4ce46f1801f2e76e53482c65aa0619d427a3fbf9")) diff --git a/.config/emacs/modules/tools/pass/test/test-pass.el b/.config/emacs/modules/tools/pass/test/test-pass.el @@ -1,41 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; tools/pass/test/test-pass.el - -(describe "tools/pass" - (before-all - (load! "../autoload")) - - (before-each - (spy-on 'auth-source-pass-parse-entry :and-call-fake - (lambda (entry) - (when (equal entry "fake/source") - '((secret . "defuse-account-gad") - ("login" . "HL2532") - ("alt-login" . "hlissner") - ("email" . "henrik@lissner.net") - ("url" . "https://some-place.net/login")))))) - - (describe "get field" - (it "returns specific fields" - (expect (+pass-get-field "fake/source" "email") - :to-equal "henrik@lissner.net")) - (it "returns first existing of a list of fields" - (expect (+pass-get-field "fake/source" '("alt-login" "email")) - :to-equal "hlissner") - (expect (+pass-get-field "fake/source" '("username" "email")) - :to-equal "henrik@lissner.net")) - (it "returns nil for missing fields" - (expect (+pass-get-field "fake/source" '("x" "y" "z")) - :to-be nil)) - (it "throws error on missing entries" - (expect (+pass-get-field "nonexistent/source" "login") - :to-throw))) - - (describe "get user/secret" - (it "returns the user" - (let ((+pass-user-fields '("login" "user" "username" "email"))) - (expect (+pass-get-user "fake/source") - :to-equal "HL2532"))) - (it "returns the secret" - (expect (+pass-get-secret "fake/source") - :to-equal "defuse-account-gad")))) diff --git a/.config/emacs/modules/tools/pdf/README.org b/.config/emacs/modules/tools/pdf/README.org @@ -1,119 +0,0 @@ -#+title: :tools pdf -#+subtitle: Emacs, your next PDF reader -#+created: February 06, 2018 -#+since: 21.12.0 - -* Description :unfold: -This module improves support for reading and interacting with PDF files in -Emacs. - -It uses [[doom-package:pdf-tools]], which is a replacement for the built-in ~doc-view-mode~ for -PDF files. The key difference being pages are not pre-rendered, but instead -rendered on-demand and stored in memory; a much faster approach, especially for -larger PDFs. - -Displaying PDF files is just one function of [[doom-package:pdf-tools]]. See [[https://github.com/politza/pdf-tools][its project website]] -for details and videos. - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:pdf-tools]] -- [[doom-package:saveplace-pdf-view]] - -** TODO Hacks -#+begin_quote - 🔨 This module's hacks haven't been documented yet. [[doom-contrib-module:][Document them?]] -#+end_quote - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires the =epdfinfo= program. Unless you're on Windows, the -[[doom-package:pdf-tools]] plugin will (re)build this program for you, if you issue the ~M-x -pdf-tools-install~ command. See the next section for instructions on how to -build the =epdfinfo= program on Windows. - -** Building =epdfinfo= on Windows -1. [[https://www.msys2.org/][Install MSYS2]] and update the package database and core packages using the - instructions provided. - -2. Update and install dependencies, skipping any you already have: - #+begin_src sh - pacman -Syu - pacman -S base-devel - pacman -S mingw-w64-x86_64-toolchain - pacman -S mingw-w64-x86_64-zlib - pacman -S mingw-w64-x86_64-libpng - pacman -S mingw-w64-x86_64-poppler - pacman -S mingw-w64-x86_64-imagemagick - #+end_src - -3. Install PDF tools in Emacs, but do not try to compile the server. Instead, - get a separate copy of the source somewhere else: - #+begin_src sh - git clone https://github.com/politza/pdf-tools - #+end_src - -4. Open mingw64 shell (Note: You must use mingw64.exe and not msys2.exe) - -5. Compile pdf-tools: - #+begin_src sh - # Cask requires python2 (important: not 3!) - pacman -S python2 - - # Make the mingw-shell aware of your python installation. Adjust the path if - # Emacs is installed elsewhere! - export PATH="/c/Program Files (x86)/Emacs/bin/:$PATH" - - # Cask needs to know where git.exe is; change this path if git is installed - # elsewhere! - export PATH="/c/Program Files/Git/bin:$PATH" - - # Install cask. Certificate errors can be ignored with (unsafe) -k option. - curl -fsSL https://raw.githubusercontent.com/cask/cask/master/go | python - - # Make sure the build process can see cask - export PATH="$HOME/.cask/bin:$PATH" - - cd /path/to/pdf-tools - make -s - #+end_src - -6. This should produce a file =server/epdfinfo.exe=. Copy this file into the - =$HOME/.emacs.d/.local/straight/build/pdf-tools/=. - -7. Start Emacs. - -8. Open a pdf file (or run ~M-x pdf-tools-install~) - -9. Test it out: ~M-x pdf-info-check-epdfinfo~ - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/tools/pdf/config.el b/.config/emacs/modules/tools/pdf/config.el @@ -1,96 +0,0 @@ -;;; tools/pdf/config.el -*- lexical-binding: t; -*- - -(use-package! pdf-tools - :mode ("\\.pdf\\'" . pdf-view-mode) - :magic ("%PDF" . pdf-view-mode) - :init - (after! pdf-annot - (defun +pdf-cleanup-windows-h () - "Kill left-over annotation buffers when the document is killed." - (when (buffer-live-p pdf-annot-list-document-buffer) - (pdf-info-close pdf-annot-list-document-buffer)) - (when (buffer-live-p pdf-annot-list-buffer) - (kill-buffer pdf-annot-list-buffer)) - (let ((contents-buffer (get-buffer "*Contents*"))) - (when (and contents-buffer (buffer-live-p contents-buffer)) - (kill-buffer contents-buffer)))) - (add-hook! 'pdf-view-mode-hook - (add-hook 'kill-buffer-hook #'+pdf-cleanup-windows-h nil t))) - - :config - (defadvice! +pdf--install-epdfinfo-a (fn &rest args) - "Install epdfinfo after the first PDF file, if needed." - :around #'pdf-view-mode - (if (and (require 'pdf-info nil t) - (or (pdf-info-running-p) - (ignore-errors (pdf-info-check-epdfinfo) t))) - (apply fn args) - ;; If we remain in pdf-view-mode, it'll spit out cryptic errors. This - ;; graceful failure is better UX. - (fundamental-mode) - (message "Viewing PDFs in Emacs requires epdfinfo. Use `M-x pdf-tools-install' to build it"))) - - ;; Despite its namesake, this does not call `pdf-tools-install', it only sets - ;; up hooks, auto-mode-alist/magic-mode-alist entries, global modes, and - ;; refreshes pdf-view-mode buffers, if any. - ;; - ;; I avoid calling `pdf-tools-install' directly because `pdf-tools' is easy to - ;; prematurely load in the background (e.g. when exporting an org file or by - ;; packages like org-pdftools). And I don't want pdf-tools to suddenly block - ;; Emacs and spew out compiler output for a few minutes in those cases. It's - ;; abysmal UX. The `pdf-view-mode' advice above works around this with a less - ;; cryptic failure message, at least. - (pdf-tools-install-noverify) - - ;; For consistency with other special modes - (map! :map pdf-view-mode-map :gn "q" #'kill-current-buffer) - - (setq-default pdf-view-display-size 'fit-page) - ;; Enable hiDPI support, but at the cost of memory! See politza/pdf-tools#51 - (setq pdf-view-use-scaling t - pdf-view-use-imagemagick nil) - - ;; Handle PDF-tools related popups better - (set-popup-rules! - '(("^\\*Outline*" :side right :size 40 :select nil) - ("^\\*Edit Annotation " :quit nil) - ("\\(?:^\\*Contents\\|'s annots\\*$\\)" :ignore t))) - - ;; The mode-line does serve any useful purpose is annotation windows - (add-hook 'pdf-annot-list-mode-hook #'hide-mode-line-mode) - - ;; HACK Fix #1107: flickering pdfs when evil-mode is enabled - (setq-hook! 'pdf-view-mode-hook evil-normal-state-cursor (list nil)) - - ;; HACK Refresh FG/BG for pdfs when `pdf-view-midnight-colors' is changed by a - ;; theme or with `setq!'. - ;; TODO PR this upstream? - (defun +pdf-reload-midnight-minor-mode-h () - (when pdf-view-midnight-minor-mode - (pdf-info-setoptions - :render/foreground (car pdf-view-midnight-colors) - :render/background (cdr pdf-view-midnight-colors) - :render/usecolors t) - (pdf-cache-clear-images) - (pdf-view-redisplay t))) - (put 'pdf-view-midnight-colors 'custom-set - (lambda (sym value) - (set-default sym value) - (dolist (buffer (doom-buffers-in-mode 'pdf-view-mode)) - (with-current-buffer buffer - (if (get-buffer-window buffer) - (+pdf-reload-midnight-minor-mode-h) - ;; Defer refresh for buffers that aren't visible, to avoid - ;; blocking Emacs for too long while changing themes. - (add-hook 'doom-switch-buffer-hook #'+pdf-reload-midnight-minor-mode-h - nil 'local)))))) - - ;; Silence "File *.pdf is large (X MiB), really open?" prompts for pdfs - (defadvice! +pdf-suppress-large-file-prompts-a (fn size op-type filename &optional offer-raw) - :around #'abort-if-file-too-large - (unless (string-match-p "\\.pdf\\'" filename) - (funcall fn size op-type filename offer-raw)))) - - -(use-package! saveplace-pdf-view - :after pdf-view) diff --git a/.config/emacs/modules/tools/pdf/packages.el b/.config/emacs/modules/tools/pdf/packages.el @@ -1,5 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; tools/pdf/packages.el - -(package! pdf-tools :pin "bc2ba117e8c3196ff9adf0da4fa1e63a8da3d7c8") -(package! saveplace-pdf-view :pin "54ed966b842501c3c092dbf57b372e37b033c578") diff --git a/.config/emacs/modules/tools/prodigy/README.org b/.config/emacs/modules/tools/prodigy/README.org @@ -1,50 +0,0 @@ -#+title: :tools prodigy -#+subtitle: No sweatshop is complete without child processes -#+created: May 16, 2018 -#+since: 21.12.0 - -* Description :unfold: -This module provides an interface for managing external services from within -Emacs. - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:prodigy]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* TODO Usage -#+begin_quote -🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote -🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote -🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/tools/prodigy/autoload.el b/.config/emacs/modules/tools/prodigy/autoload.el @@ -1,34 +0,0 @@ -;;; tools/prodigy/autoload.el -*- lexical-binding: t; -*- - -;;;###autoload -(defun +prodigy/create () - "Interactively create a new prodigy service." - (interactive) - ;; TODO - ) - -;;;###autoload -(defun +prodigy/delete (arg) - "Delete service at point. Asks for confirmation." - (interactive "P") - (prodigy-with-refresh - (when-let (service (prodigy-service-at-pos)) - (let ((name (plist-get service :name))) - (cond ((or arg - (y-or-n-p (format "Delete '%s' service?" name))) - (setq prodigy-services (delete service prodigy-services)) - (ignore-errors - (prodigy-goto-next-line)) - (message "Successfully deleted service: %s" name)) - (t - (message "Aborted"))))))) - -;;;###autoload -(defun +prodigy/cleanup () - "Delete all services associated with projects that don't exist." - (interactive) - (cl-loop for service in prodigy-services - if (and (plist-member service :project) - (file-directory-p (plist-get service :project))) - collect service into services - finally do (setq prodigy-service services))) diff --git a/.config/emacs/modules/tools/prodigy/config.el b/.config/emacs/modules/tools/prodigy/config.el @@ -1,19 +0,0 @@ -;;; tools/prodigy/config.el -*- lexical-binding: t; -*- - -(after! prodigy - (defadvice! +prodigy--add-project-property-a (fn &rest args) - "Adds a new :project property to prodigy services, which hides the service -unless invoked from the relevant project." - :around #'prodigy-services - (let ((project-root (downcase (or (doom-project-root) default-directory))) - (services (apply fn args))) - (if current-prefix-arg - services - (cl-remove-if-not (lambda (service) - (let ((project (plist-get service :project))) - (or (not project) - (file-in-directory-p project-root project)))) - services)))) - - (define-key prodigy-mode-map "d" #'+prodigy/delete)) - diff --git a/.config/emacs/modules/tools/prodigy/packages.el b/.config/emacs/modules/tools/prodigy/packages.el @@ -1,4 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; tools/prodigy/packages.el - -(package! prodigy :pin "a3be00d3b90a77118c2d7d9f5a2f26151091fa07") diff --git a/.config/emacs/modules/tools/rgb/README.org b/.config/emacs/modules/tools/rgb/README.org @@ -1,61 +0,0 @@ -#+title: :tools rgb -#+subtitle: Creating color strings -#+created: May 06, 2020 -#+since: 21.12.0 - -#+begin_quote - 🚧 *This module is deprecated.* The module is too trivial to warrant a module. -#+end_quote - -* Description :unfold: -Highlights color hex values and names with the color itself, and provides tools -to easily modify color values or formats. - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:kurecolor]] -- [[doom-package:rainbow-mode]] - -** Hacks -/No hacks documented for this module./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* Usage -=rainbow-mode= provides automatic highlighting to hex color codes, and in -relevant modes, color names (e.g. html color names in =css-mode= or LaTeX color -names in =latex-mode=) - -=kurecolor= provides commands to easily change the brightness, saturation, and -hue of hex colors (and a useful hydra for this, if =:ui hydra= is enabled), as -well as conversion between hex and css colors - -* Configuration -=hl-line-mode= overrides the color highlighting of =rainbow-mode=, limiting the -use of that plugin and on-site color changes using =kurecolor=. To automatically -disable it only when =rainbow-mode= is active, you can add the following hook: - -#+begin_src emacs-lisp -;; in $DOOMDIR/config.el -(add-hook! 'rainbow-mode-hook - (hl-line-mode (if rainbow-mode -1 +1))) -#+end_src - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote -🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/tools/rgb/autoload.el b/.config/emacs/modules/tools/rgb/autoload.el @@ -1,14 +0,0 @@ -;;; tools/rgb/autoload.el -*- lexical-binding: t; -*- -;;;###if (modulep! :ui hydra) - -;;;###autoload (autoload '+rgb/kurecolor-hydra/body "tools/rgb/autoload" nil t) -(defhydra +rgb/kurecolor-hydra (:color pink :hint nil) - " -Inc/Dec _w_/_W_ brightness _d_/_D_ saturation _e_/_E_ hue " - ("w" kurecolor-decrease-brightness-by-step) - ("W" kurecolor-increase-brightness-by-step) - ("d" kurecolor-decrease-saturation-by-step) - ("D" kurecolor-increase-saturation-by-step) - ("e" kurecolor-decrease-hue-by-step) - ("E" kurecolor-increase-hue-by-step) - ("q" nil "cancel" :color blue)) diff --git a/.config/emacs/modules/tools/rgb/packages.el b/.config/emacs/modules/tools/rgb/packages.el @@ -1,5 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; tools/rgb/packages.el - -(package! rainbow-mode :pin "8e96388fb4d616a9dde23e712bad0d9cd048fbf0") -(package! kurecolor :pin "ac67ceba85839ab1ced96fad605bf023b697263f") diff --git a/.config/emacs/modules/tools/taskrunner/README.org b/.config/emacs/modules/tools/taskrunner/README.org @@ -1,61 +0,0 @@ -#+title: :tools taskrunner -#+subtitle: Taskrunner for all your projects -#+created: November 09, 2019 -#+since: 21.12.0 - -#+begin_quote - 🚧 *This module is deprecated.* The module is too trivial and taskrunner is no - longer maintained. -#+end_quote - -* Description :unfold: -This module integrates [[doom-package:taskrunner]] into Doom Emacs, which scraps runnable tasks -from build systems like make, gradle, npm and the like. - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:emacs-taskrunner]] -- [[doom-package:helm-taskrunner]] if [[doom-module::completion helm]] -- [[doom-package:ivy-taskrunner]] if [[doom-module::completion ivy]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -Keybindings: -| Binding | Description | -| ~p z~ | ~List project tasks~ | - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/tools/taskrunner/autoload.el b/.config/emacs/modules/tools/taskrunner/autoload.el @@ -1,9 +0,0 @@ -;;; app/taskrunner/autoload.el -*- lexical-binding: t; -*- - -;;;###autoload -(defun +taskrunner/project-tasks () - "Invokes `ivy-taskrunner' or `helm-tasksrunner', depending on which is -available." - (interactive) - (cond ((modulep! :completion ivy) (ivy-taskrunner)) - ((modulep! :completion helm) (helm-taskrunner)))) diff --git a/.config/emacs/modules/tools/taskrunner/config.el b/.config/emacs/modules/tools/taskrunner/config.el @@ -1,14 +0,0 @@ -;;; tools/taskrunner/config.el -*- lexical-binding: t; -*- - -(after! taskrunner - (set-popup-rule! taskrunner--buffer-name-regexp :quit t)) - -(use-package! helm-taskrunner - :when (modulep! :completion helm) - :defer t - :config (helm-taskrunner-minor-mode +1)) - -(use-package! ivy-taskrunner - :when (modulep! :completion ivy) - :defer t - :config (ivy-taskrunner-minor-mode +1)) diff --git a/.config/emacs/modules/tools/taskrunner/packages.el b/.config/emacs/modules/tools/taskrunner/packages.el @@ -1,14 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; tools/taskrunner/packages.el - -(package! taskrunner :pin "716323aff410b4d864d137c9ebe4bbb5b8587f5e") - -(when (modulep! :completion helm) - (package! helm-taskrunner - :pin "70ef8117aafdc01a1f06151a82cecb9a2fcf4d32" - :recipe (:host github :repo "emacs-taskrunner/helm-taskrunner"))) - -(when (modulep! :completion ivy) - (package! ivy-taskrunner - :pin "c731ee6279f65061ef70e79d3818ea1d9678e6da" - :recipe (:host github :repo "emacs-taskrunner/ivy-taskrunner"))) diff --git a/.config/emacs/modules/tools/terraform/README.org b/.config/emacs/modules/tools/terraform/README.org @@ -1,79 +0,0 @@ -#+title: :tools terraform -#+subtitle: Infrastructure as code -#+created: November 21, 2019 -#+since: 21.12.0 - -* Description :unfold: -This module adds support for working with [[https://www.terraform.io][Terraform]] files within Emacs. This -includes syntax highlighting, intelligent code completion, and the ability to -run Terraform commands directly from Emacs. - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:company-terraform]] if [[doom-package::completion company]] -- [[doom-package:terraform-mode]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires the ~terraform~ executable to be installed and in your -=$PATH=. - -* Usage -** Syntax highlighting -Syntax highlighting is provided from ~terraform-mode~ and ~hcl-mode~. - -** Code formatting -[[doom-module::tools terraform]] does not provide code formatting directly, but [[doom-module::editor format]] -works with Terraform files. - -** Code navigation -Code navigation is supported through [[doom-package:imenu]] from [[doom-package:terraform-mode]]. - -** Code completion -Code completion of Terraform builtins is provided from [[doom-package:company-terraform]] and -generally works well despite being generated through a [[https://github.com/rafalcieslak/emacs-company-terraform/blob/master/company-terraform-data.el][static (outdated) file]]. - -[[doom-package:company-terraform]] also provides code completion of resources within your -project. - -** Documentation -Documentation is accessible through the normal [[doom-package:company]] show documentation -functionality, thanks to [[doom-package:company-terraform]]. - -** Executing Terraform commands -[[doom-module::tools terraform]] provides commands under [[kbd:][<localleader>]] to run the most common -Terraform operations: -| key | description | -|-----------------+--------------------------| -| [[kbd:][<localleader> i]] | Runs ~$ terraform init~ | -| [[kbd:][<localleader> p]] | Runs ~$ terraform plan~ | -| [[kbd:][<localleader> a]] | Runs ~$ terraform apply~ | - -* TODO Configuration -#+begin_quote -🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/tools/terraform/config.el b/.config/emacs/modules/tools/terraform/config.el @@ -1,24 +0,0 @@ -;;; tools/terraform/config.el -*- lexical-binding: t; -*- - -(defvar +terraform-runner (if (executable-find "terragrunt") "terragrunt" "terraform") - "The default runner - terraform or terragrunt") - -(when (modulep! +lsp) - (add-hook 'terraform-mode-local-vars-hook #'lsp! 'append)) - -(after! terraform-mode - (set-docsets! 'terraform-mode "Terraform") - - (setq-hook! 'terraform-mode-hook compile-command +terraform-runner) - - (map! :map terraform-mode-map - :localleader - :desc "apply" "a" (cmd! (compile (format "%s apply" +terraform-runner) t)) - :desc "init" "i" (cmd! (compile (format "%s init" +terraform-runner))) - :desc "plan" "p" (cmd! (compile (format "%s plan" +terraform-runner))))) - -(use-package! company-terraform - :when (modulep! :completion company) - :after terraform-mode - :config - (set-company-backend! 'terraform-mode 'company-terraform)) diff --git a/.config/emacs/modules/tools/terraform/doctor.el b/.config/emacs/modules/tools/terraform/doctor.el @@ -1,4 +0,0 @@ -;;; tools/terraform/doctor.el -*- lexical-binding: t; -*- - -(unless (executable-find "terraform") - (warn! "Couldn't find terraform.")) diff --git a/.config/emacs/modules/tools/terraform/packages.el b/.config/emacs/modules/tools/terraform/packages.el @@ -1,6 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; tools/terraform/packages.el - -(package! terraform-mode :pin "39d2fd5bfc86c6bf1c7bc38e6f0016d714f2d79d") -(when (modulep! :completion company) - (package! company-terraform :pin "8d5a16d1bbeeb18ca49a8fd57b5d8cd30c8b8dc7")) diff --git a/.config/emacs/modules/tools/tmux/README.org b/.config/emacs/modules/tools/tmux/README.org @@ -1,49 +0,0 @@ -#+title: :tools tmux -#+subtitle: From one multiplexer to another -#+created: October 15, 2021 -#+since: 21.12.0 - -* Description :unfold: -This module provides an API for talking to Tmux sessions. - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -/This module doesn't install any packages./ - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* TODO Usage -#+begin_quote -🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote -🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote -🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/tools/tmux/autoload/evil.el b/.config/emacs/modules/tools/tmux/autoload/evil.el @@ -1,17 +0,0 @@ -;;; tools/tmux/autoload/evil.el -*- lexical-binding: t; -*- -;;;###if (modulep! :editor evil) - -;;;###autoload (autoload '+tmux:run "tools/tmux/autoload/evil" nil t) -(evil-define-command +tmux:run (bang &optional command) - (interactive "<!><fsh>") - (if (evil-visual-state-p) - (+tmux/send-region evil-visual-beginning evil-visual-end bang) - (+tmux/run command bang))) - -;;;###autoload (autoload '+tmux:cd-here "tools/tmux/autoload/evil" nil t) -(evil-define-command +tmux:cd-here (bang) - (interactive "<!>") - (if bang - (+tmux/cd-to-here) - (+tmux/cd-to-project))) - diff --git a/.config/emacs/modules/tools/tmux/autoload/tmux.el b/.config/emacs/modules/tools/tmux/autoload/tmux.el @@ -1,146 +0,0 @@ -;;; tools/tmux/autoload/tmux.el -*- lexical-binding: t; -*- - -;; This library offers: -;; + A way of communicating with a tmux instance -;; + TODO A way to manage tmuxifier from emacs - -(defvar +tmux-last-command nil - "The last command ran by `+tmux'. Used by `+tmux/rerun'") - -(defvar +tmux-last-retcode nil - "The last tmux return code.") - - -;; -;; Commands - -;;;###autoload -(defun +tmux (command &rest args) - "Execute COMMAND in tmux" - (let ((bin (executable-find "tmux"))) - (unless bin - (error "Could not find tmux executable")) - (let* ((args (mapcar #'shell-quote-argument (delq nil args))) - (cmdstr (format "%s %s" bin (if args (apply #'format command args) command))) - (output (get-buffer-create " *tmux stdout*")) - (errors (get-buffer-create " *tmux stderr*")) - code) - (unwind-protect - (if (= 0 (setq code (quiet! (shell-command cmdstr output errors)))) - (with-current-buffer output - (setq +tmux-last-command `(,(substring cmdstr (+ 1 (length bin))) ,@args)) - (buffer-string)) - (error "[%d] tmux $ %s (%s)" - code - (with-current-buffer errors - (buffer-string)) - cmdstr)) - (and (kill-buffer output) - (kill-buffer errors)))))) - -;;;###autoload -(defun +tmux/run (command &optional noreturn) - "Run COMMAND in tmux. If NORETURN is non-nil, send the commands as keypresses -but do not execute them." - (interactive - (list (read-string "tmux $ ") - current-prefix-arg)) - (+tmux (concat "send-keys C-u " - (shell-quote-argument command) - (unless noreturn " Enter")))) - -;;;###autoload -(defun +tmux/send-region (beg end &optional noreturn) - "Send region to tmux." - (interactive (list (region-beginning) - (region-end) - current-prefix-arg)) - (+tmux/run (string-trim (buffer-substring-no-properties beg end)) - noreturn)) - -;;;###autoload -(defun +tmux/rerun () - "Rerun the last command executed by `+tmux' and `+tmux/run'." - (interactive) - (unless +tmux-last-command - (user-error "No last command to run")) - (apply #'+tmux +tmux-last-command)) - -;;;###autoload -(defun +tmux/cd (&optional directory noreturn) - "Change the pwd of the currently active tmux pane to DIRECTORY. - -DIRECTORY defaults to `default-directory' if omitted, or to `doom-project-root' -if prefix arg is non-nil. - -If NORETURN is non-nil, send the cd command to tmux, but do not execute the -command." - (interactive "D") - (+tmux/run (format "cd %S" (or directory (if current-prefix-arg - (doom-project-root) - default-directory))) - noreturn)) - -;;;###autoload -(defun +tmux/cd-to-here () - "cd into `default-directory' in tmux." - (interactive) - (+tmux/cd default-directory)) - -;;;###autoload -(defun +tmux/cd-to-project () - "cd into `doom-project-root' in tmux." - (interactive) - (+tmux/cd (doom-project-root))) - - -;; -;; Data functions - -;;;###autoload -(defun +tmux-list-sessions () - (let ((lines (+tmux "list-sessions -F '#{session_id};#{session_name};#{session_attached}'"))) - (if lines - (cl-loop for line in (split-string lines "\n" t) - collect - (let ((sess (split-string line ";"))) - (list (nth 0 sess) - :name (nth 1 sess) - :attached (equal (nth 2 sess) "1")))) - (error "There are no sessions")))) - -;;;###autoload -(defun +tmux-list-windows (&optional session) - (if-let* ((lines - (+tmux (format "list-windows %s -F '#{window_id};#{session_id};#{window_active};#{window_name};#{window_activity_flag}'" - (if session - (concat "-t " (shell-quote-argument (car session))) - "-a"))))) - (cl-loop for line in (split-string lines "\n" t) - collect (let ((window (split-string line ";"))) - (list (nth 0 window) - :session-id (nth 1 window) - :name (nth 3 window) - :active (equal (nth 2 window) "1") - :activity (equal (nth 4 window) "1")))) - (error "There are no windows"))) - -;;;###autoload -(defun +tmux-list-panes (&optional sess-or-win) - (if-let* ((lines - (+tmux (format "list-panes %s -F '#{pane_id};#{window_id};#{session_id};#{pane_active};#{pane_title};#{pane_current_path}'" - (if sess-or-win - (concat (if (string-prefix-p "$" (car sess-or-win)) "-s ") - "-t " - (shell-quote-argument (car sess-or-win))) - "-a"))))) - (cl-loop for line in (split-string lines "\n" t) - collect (let ((pane (split-string line ";"))) - (list (nth 0 pane) - :window-id (nth 1 pane) - :session-id (nth 2 pane) - :name (nth 4 pane) - :active (equal (nth 3 pane) "1") - :pwd (nth 5 pane)))) - (error "There are no panes"))) - diff --git a/.config/emacs/modules/tools/tree-sitter/README.org b/.config/emacs/modules/tools/tree-sitter/README.org @@ -1,163 +0,0 @@ -#+title: :tools tree-sitter -#+subtitle: Syntax and parsing, sitting in a tree... -#+created: August 17, 2021 -#+since: 22.06.0 (#5401) - -* Description :unfold: -This module adds [[https://tree-sitter.github.io/tree-sitter/][tree-sitter]] support to Doom Emacs. - -#+begin_quote - 💬 Tree sitter is a parser generator tool and an incremental parsing library. - It can build a concrete syntax tree for a source file and efficiently update - the syntax tree as the source file is edited. This allows for features of - the editor to become syntax aware. -#+end_quote - -It includes: -- Better syntax highlighting of supported languages. -- Structural text objects to manipulate functions statements and other code - structures like any other text object. - -** Maintainers -- [[doom-user:][@jeetelongname]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:evil-textobj-tree-sitter]] if [[doom-module::editor evil +everywhere]] -- [[doom-package:tree-sitter]] -- [[doom-package:tree-sitter-langs]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module has no direct requirements, but some languages may have their own to -fulfill before tree-sitter support works for them. Run ~$ doom doctor~ to find -out what you're missing. - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** Language support -Currently Emacs tree sitter has [[https://github.com/emacs-tree-sitter/tree-sitter-langs/tree/master/repos][parsers for these languages]], and syntax -highlighting support for [[https://github.com/emacs-tree-sitter/tree-sitter-langs/tree/master/queries][these languages]] as well as ~typescript-tsx-mode~. - -To enable tree-sitter support for specific languages, add the =+tree-sitter= -flag to their respective Doom modules. Check the module readme of your language -for support. - -** Text Objects -Not all languages support all text objects (yet). [[https://github.com/nvim-treesitter/nvim-treesitter-textobjects#built-in-textobjects][Here is a table of the text -object languages support]]. - -#+begin_quote - 🚧 Only languages with parsers in Emacs have text object support at the moment. -#+end_quote - -Currently text objects are bound to: -| key | text object | -|-----+---------------------| -| [[kbd:][A]] | parameter list | -| [[kbd:][f]] | function definition | -| [[kbd:][F]] | function call | -| [[kbd:][C]] | class | -| [[kbd:][c]] | comment | -| [[kbd:][v]] | conditional | -| [[kbd:][l]] | loop | - -They are used in a container context (not [[kbd:][vf]], but [[kbd:][vaf]] or [[kbd:][vif]]). - -** Goto certain nodes -To jump to the next/previous node, type in a buffer by using [[kbd:][[g]] or [[kbd:][]g]] -respectfully, the following key will correspond to the text object you want to -jump to. - -Currently keys are bound to: -| key | text object | -|-----+----------------| -| [[kbd:][a]] | parameter list | -| [[kbd:][f]] | function | -| [[kbd:][F]] | function call | -| [[kbd:][c]] | comment | -| [[kbd:][C]] | class | -| [[kbd:][v]] | conditional | -| [[kbd:][l]] | loop | - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** Rebind text objects -Rebinding keys works the same as rebinding any other key, but text-object keys -must be bound on one or both of the ~+tree-sitter-inner-text-object-map~ or -~+tree-sitter-outer-text-object-map~ keymaps: -#+begin_src emacs-lisp -(map! (:map +tree-sitter-outer-text-objects-map - "f" (evil-textobj-tree-sitter-get-textobj "call.inner") - "F" (evil-textobj-tree-sitter-get-textobj "function.inner")) - (:map +tree-sitter-inner-text-objects-map - "f" (evil-textobj-tree-sitter-get-textobj "call.inner") - "F" (evil-textobj-tree-sitter-get-textobj "function.inner"))) -#+end_src - -** Add your own text objects -To [[https://github.com/meain/evil-textobj-tree-sitter#custom-textobjects][add your own custom text objects]], bind them to ~+tree-sitter-{inner, -outer}-text-objects-map~: -#+begin_src emacs-lisp -(map! :map +tree-sitter-outer-text-objects-map - "m" (evil-textobj-tree-sitter-get-textobj "import" - '((python-mode . [(import_statement) @import]) - (rust-mode . [(use_declaration) @import])))) -#+end_src - -** Configuring Tree sitter highlighting -Highlighting is controlled by the variable =+tree-sitter-hl-enabled-modes= -This list allows you to whitelist, blacklist, fully enable or fully disable -tree-sitter highlighting for all major modes - -To use highlighting in select modes add major-modes to -~+tree-sitter-hl-enabled-modes~. This disables highlighting in all other modes. -The symbol that should be used is the major mode symbol, *not the package -symbol*. -#+begin_src emacs-lisp -(setq +tree-sitter-hl-enabled-modes '(python-mode go-mode)) -#+end_src - -If you want to disallow highlighting in certain modes then the car of -~+tree-sitter-hl-enabled-modes~ should be =not=. This enables highlighting in -all modes except the ones disallowed. -#+begin_src emacs-lisp -(setq +tree-sitter-hl-enabled-modes '(not web-mode typescript-tsx-mode)) -#+end_src - -If ~+tree-sitter-hl-enabled-modes~ is set to ~nil~ or ~t~ it will fully disable -or fully enable highlighting in every tree sitter enabled language respectively. - -* Troubleshooting -[[doom-report:][Report an issue?]] - -** =(error "Bad bounding indices: 0, 1")= -This means that the text object does not have the underlying query needed. This -can be fixed by either adding in a custom query (which would override the -current key bound) or [[https://github.com/nvim-treesitter/nvim-treesitter-textobjects/][contributing upstream!]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/tools/tree-sitter/autoload.el b/.config/emacs/modules/tools/tree-sitter/autoload.el @@ -1,41 +0,0 @@ -;;; tools/tree-sitter/autoload.el -*- lexical-binding: t; -*- - -;;;###autodef (fset 'tree-sitter! #'ignore) -(defun tree-sitter! () - "Dispatch to turn on tree sitter. - -Used as a hook function which turns on `tree-sitter-mode' -and selectively turn on `tree-sitter-hl-mode'. -according to `+tree-sitter-hl-enabled-modes'" - (turn-on-tree-sitter-mode) - ;; conditionally enable `tree-sitter-hl-mode' - (let ((mode (bound-and-true-p tree-sitter-hl-mode))) - (when-let (mode (if (pcase +tree-sitter-hl-enabled-modes - (`(not . ,modes) (not (memq major-mode modes))) - ((and `(,_ . ,_) modes) (memq major-mode modes)) - (bool bool)) - (unless mode +1) - (if mode -1))) - (tree-sitter-hl-mode mode)))) - -;;;###autodef (fset 'set-tree-sitter-lang! #'ignore) -(defun set-tree-sitter-lang! (mode lang) - "Associate LANG with major MODE." - (after! tree-sitter-langs - (add-to-list 'tree-sitter-major-mode-language-alist (cons mode lang)))) - -;; HACK: Remove and refactor when `use-package' eager macro expansion is solved or `use-package!' is removed -;;;###autoload -(defun +tree-sitter-get-textobj (group &optional query) - "A wrapper around `evil-textobj-tree-sitter-get-textobj' to -prevent eager expansion." - (eval `(evil-textobj-tree-sitter-get-textobj ,group ,query))) - -;;;###autoload -(defun +tree-sitter-goto-textobj (group &optional previous end query) - "Thin wrapper that returns the symbol of a named function, used in keybindings." - (let ((sym (intern (format "+goto%s%s-%s" (if previous "-previous" "") (if end "-end" "") group)))) - (fset sym (lambda () - (interactive) - (evil-textobj-tree-sitter-goto-textobj group previous end query))) - sym)) diff --git a/.config/emacs/modules/tools/tree-sitter/config.el b/.config/emacs/modules/tools/tree-sitter/config.el @@ -1,77 +0,0 @@ -;;; tools/tree-sitter/config.el -*- lexical-binding: t; -*- - -(defvar +tree-sitter-hl-enabled-modes '(not web-mode typescript-tsx-mode) - "A list of major modes which should be highlighted by tree-sitter. - -If this list begins with `not', then it negates the list. -If it is t, it is enabled in all modes. -If nil, it is disabled in all modes") - -;; -;;; Packages - -(use-package! tree-sitter - :defer t - :config - (require 'tree-sitter-langs) - ;; This makes every node a link to a section of code - (setq tree-sitter-debug-jump-buttons t - ;; and this highlights the entire sub tree in your code - tree-sitter-debug-highlight-jump-region t)) - - -(use-package! evil-textobj-tree-sitter - :when (modulep! :editor evil +everywhere) - :defer t - :init (after! tree-sitter (require 'evil-textobj-tree-sitter)) - :config - (defvar +tree-sitter-inner-text-objects-map (make-sparse-keymap)) - (defvar +tree-sitter-outer-text-objects-map (make-sparse-keymap)) - (defvar +tree-sitter-goto-previous-map (make-sparse-keymap)) - (defvar +tree-sitter-goto-next-map (make-sparse-keymap)) - - (evil-define-key '(visual operator) 'tree-sitter-mode - "i" +tree-sitter-inner-text-objects-map - "a" +tree-sitter-outer-text-objects-map) - (evil-define-key 'normal 'tree-sitter-mode - "[g" +tree-sitter-goto-previous-map - "]g" +tree-sitter-goto-next-map) - - (map! (:map +tree-sitter-inner-text-objects-map - "A" (+tree-sitter-get-textobj '("parameter.inner" "call.inner")) - "f" (+tree-sitter-get-textobj "function.inner") - "F" (+tree-sitter-get-textobj "call.inner") - "C" (+tree-sitter-get-textobj "class.inner") - "v" (+tree-sitter-get-textobj "conditional.inner") - "l" (+tree-sitter-get-textobj "loop.inner")) - (:map +tree-sitter-outer-text-objects-map - "A" (+tree-sitter-get-textobj '("parameter.outer" "call.outer")) - "f" (+tree-sitter-get-textobj "function.outer") - "F" (+tree-sitter-get-textobj "call.outer") - "C" (+tree-sitter-get-textobj "class.outer") - "c" (+tree-sitter-get-textobj "comment.outer") - "v" (+tree-sitter-get-textobj "conditional.outer") - "l" (+tree-sitter-get-textobj "loop.outer")) - - (:map +tree-sitter-goto-previous-map - "a" (+tree-sitter-goto-textobj "parameter.outer" t) - "f" (+tree-sitter-goto-textobj "function.outer" t) - "F" (+tree-sitter-goto-textobj "call.outer" t) - "C" (+tree-sitter-goto-textobj "class.outer" t) - "c" (+tree-sitter-goto-textobj "comment.outer" t) - "v" (+tree-sitter-goto-textobj "conditional.outer" t) - "l" (+tree-sitter-goto-textobj "loop.outer" t)) - (:map +tree-sitter-goto-next-map - "a" (+tree-sitter-goto-textobj "parameter.outer") - "f" (+tree-sitter-goto-textobj "function.outer") - "F" (+tree-sitter-goto-textobj "call.outer") - "C" (+tree-sitter-goto-textobj "class.outer") - "c" (+tree-sitter-goto-textobj "comment.outer") - "v" (+tree-sitter-goto-textobj "conditional.outer") - "l" (+tree-sitter-goto-textobj "loop.outer"))) - - (after! which-key - (setq which-key-allow-multiple-replacements t) - (pushnew! - which-key-replacement-alist - '(("" . "\\`+?evil-textobj-tree-sitter-function--\\(.*\\)\\(?:.inner\\|.outer\\)") . (nil . "\\1"))))) diff --git a/.config/emacs/modules/tools/tree-sitter/doctor.el b/.config/emacs/modules/tools/tree-sitter/doctor.el @@ -1,4 +0,0 @@ -;;; tools/treesitter/doctor.el -*- lexical-binding: t; -*- - -(unless (fboundp 'module-load) - (warn! "Emacs was not built with dynamic modules support. Tree sitter needs this to function")) diff --git a/.config/emacs/modules/tools/tree-sitter/packages.el b/.config/emacs/modules/tools/tree-sitter/packages.el @@ -1,10 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; tools/tree-sitter/packages.el - -(package! tree-sitter :pin "3cfab8a0e945db9b3df84437f27945746a43cc71") -(package! tree-sitter-langs :pin "d8f8ac4faeb4564fbb61e94a631b4672523d84a9") -(package! tree-sitter-indent :pin "4ef246db3e4ff99f672fe5e4b416c890f885c09e") - -(when (modulep! :editor evil +everywhere) - (package! evil-textobj-tree-sitter - :pin "02f8253034042d8f171bc0ef93e3538b71a29153")) diff --git a/.config/emacs/modules/tools/upload/README.org b/.config/emacs/modules/tools/upload/README.org @@ -1,79 +0,0 @@ -#+title: :tools upload -#+subtitle: Map local directories to remotes via ssh/ftp -#+created: February 20, 2017 -#+since: 2.0.0 - -* Description :unfold: -Uses ~ssh-deploy~ to map a local folder to a remote one. - -From the [[https://github.com/cjohansson/emacs-ssh-deploy/blob/master/README.md][ssh-deploy README]]: -#+begin_quote -The ssh-deploy plug-in for Emacs makes it possible to effortlessly deploy local files and directories to remote hosts via Tramp (including but not limited to SSH, SFTP, FTP). It tries to provide functions that can be easily used by custom scripts. - -The idea for this plug-in was to mimic the behavior of PhpStorm deployment functionality. -#+end_quote - -** Maintainers -- [[doom-user:][@hlissner]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:ssh-deploy]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -Uses ~ssh-deploy~ to map a local folder to a remote one. Set -~ssh-deploy-root-remote~ and ~ssh-deploy-root-local~ in a =.dir-locals.el= file -to establish this mapping. E.g. -#+begin_src emacs-lisp -((nil . ((ssh-deploy-root-local . "/local/path/to/project") - (ssh-deploy-root-remote . "/ssh:user@server:/remote/project/") - (ssh-deploy-on-explicit-save . t)))) -#+end_src - -#+begin_quote - 📌 ~ssh-deploy-root-local~ is optional, and will resort to ~doom-project-root~ - if unspecified. -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -Check out [[https://github.com/cjohansson/emacs-ssh-deploy#deployment-configuration-examples][Deployment configuration examples]] for some ideas of what's possible. - -* Troubleshooting -** ~root-local~ and ~root-remote~ must match -The final directory names much match: -#+begin_src emacs-lisp -((nil . ((ssh-deploy-root-local . "/local/path/to/example-project") - (ssh-deploy-root-remote . "/ssh:user@server:/remote/example-project/") -#+end_src - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/tools/upload/config.el b/.config/emacs/modules/tools/upload/config.el @@ -1,52 +0,0 @@ -;;; tools/upload/config.el -*- lexical-binding: t; -*- - -;; Uses `ssh-deploy' to map a local folder to a remote one. Set -;; `ssh-deploy-root-remote' and `ssh-deploy-root-local' in a .dir-locals.el file -;; to establish this mapping. -;; -;; Example: -;; ((nil . ((ssh-deploy-root-local . "/local/path/to/project") -;; (ssh-deploy-root-remote . "/ssh:user@server:/remote/project/") -;; (ssh-deploy-on-explicit-save . t)))) -;; -;; Note: `ssh-deploy-root-local' is optional, and will resort to -;; `doom-project-root' if unspecified. - -(use-package! ssh-deploy - :commands (ssh-deploy-upload-handler - ssh-deploy-upload-handler-forced - ssh-deploy-diff-handler - ssh-deploy-browse-remote-handler - ssh-deploy-remote-changes-handler) - :init - (setq ssh-deploy-revision-folder (concat doom-cache-dir "ssh-revisions/") - ssh-deploy-on-explicit-save t - ssh-deploy-automatically-detect-remote-changes nil) - - ;; Make these safe as file-local variables - (dolist (sym '((ssh-deploy-root-local . stringp) - (ssh-deploy-root-remote . stringp) - (ssh-deploy-script . functionp) - (ssh-deploy-on-explicit-save . booleanp) - (ssh-deploy-force-on-explicit-save . booleanp) - (ssh-deploy-async . booleanp) - (ssh-deploy-exclude-list . listp))) - (put (car sym) 'safe-local-variable (cdr sym))) - - ;; Maybe auto-upload on save - (add-hook! 'after-save-hook - (defun +upload-init-after-save-h () - (when (and (bound-and-true-p ssh-deploy-root-remote) - ssh-deploy-on-explicit-save) - (ssh-deploy-upload-handler ssh-deploy-force-on-explicit-save)))) - - ;; Enable ssh-deploy if variables are set, and check for changes on open file - ;; (if possible) - (add-hook! 'find-file-hook - (defun +upload-init-find-file-h () - (when (bound-and-true-p ssh-deploy-root-remote) - (require 'ssh-deploy) - (unless ssh-deploy-root-local - (setq ssh-deploy-root-local (doom-project-root))) - (when ssh-deploy-automatically-detect-remote-changes - (ssh-deploy-remote-changes-handler)))))) diff --git a/.config/emacs/modules/tools/upload/packages.el b/.config/emacs/modules/tools/upload/packages.el @@ -1,4 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; tools/upload/packages.el - -(package! ssh-deploy :pin "94b56c0428fa0c788578161edc9e7992b13cd400") diff --git a/.config/emacs/modules/ui/README.org b/.config/emacs/modules/ui/README.org @@ -1,10 +0,0 @@ -#+title: :ui -#+created: July 29, 2021 -#+since: 21.12.0 - -* Description -For modules concerned with changing Emacs' appearance or providing interfaces -for its features, like sidebars, tabs, or fonts. - -* Frequently asked questions -/This category has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] diff --git a/.config/emacs/modules/ui/deft/README.org b/.config/emacs/modules/ui/deft/README.org @@ -1,75 +0,0 @@ -#+title: :ui deft -#+subtitle: Notational velocity for Emacs -#+created: August 26, 2018 -#+since: 21.12.0 (#835) - -* Description :unfold: -[[https://jblevins.org/projects/deft/][Deft]] is a major mode for creating, browsing, and filtering notes written in -plain text formats, such as org-mode, markdown, and LaTeX. It enables you to -quickly jot down thoughts and easily retrieve them later. - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:deft]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* TODO Usage -#+begin_quote -🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -To use deft, you first need to specify the directory in which your notes are -stored: -#+begin_src emacs-lisp -;; in $DOOMDIR/config.el -(setq deft-directory "~/notes") -#+end_src - -The default note format is org-mode. You can change this by setting the value of -the variable ~deft-default-extension~. Replacing the value with ~"md"~, for -example, will change the default note format to markdown: -#+begin_src emacs-lisp -(after! deft - (setq deft-default-extension "md")) -#+end_src - -You may also want to alter the way titles and file names are automatically -created by editing ~deft-use-filename-as-title~ and/or -~deft-use-filter-string-for-filename~. - -Further customization options can be found here: -https://github.com/jrblevin/deft#other-customizations - -* Troubleshooting -[[doom-report:][Report an issue?]] - -- It is [[https://github.com/hlissner/doom-emacs/pull/2845/commits/dce80a3c8032f5390f4e763e18a108d5f3f08772][not recommended]] to re-enable deft's buffer auto-save. - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/ui/deft/config.el b/.config/emacs/modules/ui/deft/config.el @@ -1,46 +0,0 @@ -;;; ui/deft/config.el -*- lexical-binding: t; -*- - -(use-package! deft - :commands deft - :init - (setq deft-default-extension "org" - ;; de-couples filename and note title: - deft-use-filename-as-title nil - deft-use-filter-string-for-filename t - ;; disable auto-save - deft-auto-save-interval -1.0 - ;; converts the filter string into a readable file-name using kebab-case: - deft-file-naming-rules - '((noslash . "-") - (nospace . "-") - (case-fn . downcase))) - :config - (add-to-list 'deft-extensions "tex") - (add-hook 'deft-mode-hook #'doom-mark-buffer-as-real-h) - ;; start filtering immediately - (set-evil-initial-state! 'deft-mode 'insert) - (map! :map deft-mode-map - :n "gr" #'deft-refresh - :n "C-s" #'deft-filter - :i "C-n" #'deft-new-file - :i "C-m" #'deft-new-file-named - :i "C-d" #'deft-delete-file - :i "C-r" #'deft-rename-file - :n "r" #'deft-rename-file - :n "a" #'deft-new-file - :n "A" #'deft-new-file-named - :n "d" #'deft-delete-file - :n "D" #'deft-archive-file - :n "q" #'kill-current-buffer - :localleader - "RET" #'deft-new-file-named - "a" #'deft-archive-file - "c" #'deft-filter-clear - "d" #'deft-delete-file - "f" #'deft-find-file - "g" #'deft-refresh - "l" #'deft-filter - "n" #'deft-new-file - "r" #'deft-rename-file - "s" #'deft-toggle-sort-method - "t" #'deft-toggle-incremental-search)) diff --git a/.config/emacs/modules/ui/deft/packages.el b/.config/emacs/modules/ui/deft/packages.el @@ -1,4 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; ui/deft/packages.el - -(package! deft :pin "28be94d89bff2e1c7edef7244d7c5ba0636b1296") diff --git a/.config/emacs/modules/ui/doom-dashboard/README.org b/.config/emacs/modules/ui/doom-dashboard/README.org @@ -1,117 +0,0 @@ -#+title: :ui doom-dashboard -#+subtitle: Welcome to your doom -#+created: February 20, 2017 -#+since: 2.0.0 - -* Description :unfold: -This module adds a minimalistic, Atom-inspired dashboard to Emacs. - -Besides eye candy, the dashboard serves two other purposes: - -1. To improve Doom's startup times (the dashboard is lighter than the scratch - buffer in many cases). - -2. And to preserve the "last open directory" you were in. Occasionally, I kill - the last buffer in my project and I end up who-knows-where (in the working - directory of another buffer/project). It can take some work to find my way - back to where I was. Not with the Dashboard. - - Since the dashboard cannot be killed, and it remembers the working directory - of the last open buffer, ~M-x find-file~ will work from the directory I - expect. - -** Maintainers -- [[doom-user:][@hlissner]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -/This module doesn't install any packages./ - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module only requires that ~all-the-icons~'s icon fonts are installed, which -should've been installed when you ran ~$ doom install~. Otherwise, use ~M-x -all-the-icons-install-fonts~ to install them. - -* Usage -Once this module is enabled, the dashboard will present itself after opening a -fresh instance of Emacs, or after killing all real buffers. - -You can forcibly open the dashboard with ~M-x +doom-dashboard/open~. - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** A custom banner -To use a custom image as your banner, change ~fancy-splash-image~: -#+begin_src emacs-lisp -(setq fancy-splash-image "~/my/banners/image.png") -#+end_src - -#+begin_quote - 📌 Doom will fall back to its ASCII banner in Terminal Emacs. To replace the - ASCII banner, replace the ~doom-dashboard-widget-banner~ function in - ~+doom-dashboard-functions~ with a function that inserts your new banner - into the current file. -#+end_quote - -** Adding text to the dashboard -Doom's dashboard iterates over ~+doom-dashboard-functions~ when it is told to -redraw. Add your own functions to operate on the buffer and potentially add -whatever you like to Doom's splash screen. - -#+begin_quote - 🚧 Keep in mind that inserting text from expensive sources, e.g. your org - agenda, will negate most of Doom's startup benefits. -#+end_quote - -** Customizing Faces -Doom's dashboard defaults to inheriting faces set by the current theme. If you -wish to customize it independently of the theme (or just inherit a different -color from the theme) you can make use of ~custom-set-faces!~ or -~custom-theme-set-faces!~: -#+begin_src emacs-lisp -(custom-set-faces! - '(doom-dashboard-banner :foreground "red" :background "#000000" :weight bold) - '(doom-dashboard-footer :inherit font-lock-constant-face) - '(doom-dashboard-footer-icon :inherit all-the-icons-red) - '(doom-dashboard-loaded :inherit font-lock-warning-face) - '(doom-dashboard-menu-desc :inherit font-lock-string-face) - '(doom-dashboard-menu-title :inherit font-lock-function-name-face)) -#+end_src - -or for a per-theme setting -#+begin_src emacs-lisp -(custom-theme-set-faces! 'doom-tomorrow-night - '(doom-dashboard-banner :foreground "red" :background "#000000" :weight bold) - '(doom-dashboard-footer :inherit font-lock-constant-face) - '(doom-dashboard-footer-icon :inherit all-the-icons-red) - '(doom-dashboard-loaded :inherit font-lock-warning-face) - '(doom-dashboard-menu-desc :inherit font-lock-string-face) - '(doom-dashboard-menu-title :inherit font-lock-function-name-face)) -#+end_src - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/ui/doom-dashboard/autoload.el b/.config/emacs/modules/ui/doom-dashboard/autoload.el @@ -1,28 +0,0 @@ -;;; ui/doom-dashboard/autoload.el -*- lexical-binding: t; -*- - -(defun +doom-dashboard--help-echo () - (when-let* ((btn (button-at (point))) - (msg (button-get btn 'help-echo))) - (message "%s" msg))) - -;;;###autoload -(defun +doom-dashboard/open (frame) - "Switch to the dashboard in the current window, of the current FRAME." - (interactive (list (selected-frame))) - (with-selected-frame frame - (switch-to-buffer (doom-fallback-buffer)) - (+doom-dashboard-reload t))) - -;;;###autoload -(defun +doom-dashboard/forward-button (n) - "Like `forward-button', but don't wrap." - (interactive "p") - (forward-button n nil) - (+doom-dashboard--help-echo)) - -;;;###autoload -(defun +doom-dashboard/backward-button (n) - "Like `backward-button', but don't wrap." - (interactive "p") - (backward-button n nil) - (+doom-dashboard--help-echo)) diff --git a/.config/emacs/modules/ui/doom-dashboard/config.el b/.config/emacs/modules/ui/doom-dashboard/config.el @@ -1,526 +0,0 @@ -;;; ui/doom-dashboard/config.el -*- lexical-binding: t; -*- - -(defvar +doom-dashboard-name "*doom*" - "The name to use for the dashboard buffer.") - -(defvar +doom-dashboard-functions - '(doom-dashboard-widget-banner - doom-dashboard-widget-shortmenu - doom-dashboard-widget-loaded - doom-dashboard-widget-footer) - "List of widget functions to run in the dashboard buffer to construct the -dashboard. These functions take no arguments and the dashboard buffer is current -while they run.") - -(defvar +doom-dashboard-banner-file "default.png" - "The path to the image file to be used in on the dashboard. The path is -relative to `+doom-dashboard-banner-dir'. If nil, always use the ASCII banner.") - -(defvar +doom-dashboard-banner-dir (concat (dir!) "/banners/") - "Where to look for `+doom-dashboard-banner-file'.") - -(defvar +doom-dashboard-ascii-banner-fn #'doom-dashboard-draw-ascii-banner-fn - "The function used to generate the ASCII banner on Doom's dashboard.") - -(defvar +doom-dashboard-banner-padding '(0 . 4) - "Number of newlines to pad the banner with, above and below, respectively.") - -(defvar +doom-dashboard-inhibit-refresh nil - "If non-nil, the doom buffer won't be refreshed.") - -(defvar +doom-dashboard-inhibit-functions () - "A list of functions which take no arguments. If any of them return non-nil, -dashboard reloading is inhibited.") - -(defvar +doom-dashboard-pwd-policy 'last-project - "The policy to use when setting the `default-directory' in the dashboard. - -Possible values: - - 'last-project The `doom-project-root' of the last open buffer. Falls back - to `default-directory' if not in a project. - 'last The `default-directory' of the last open buffer - a FUNCTION A function run with the `default-directory' of the last - open buffer, that returns a directory path - a STRING A fixed path - nil `default-directory' will never change") - -(defvar +doom-dashboard-menu-sections - '(("Reload last session" - :icon (all-the-icons-octicon "history" :face 'doom-dashboard-menu-title) - :when (cond ((modulep! :ui workspaces) - (file-exists-p (expand-file-name persp-auto-save-fname persp-save-dir))) - ((require 'desktop nil t) - (file-exists-p (desktop-full-file-name)))) - :face (:inherit (doom-dashboard-menu-title bold)) - :action doom/quickload-session) - ("Open org-agenda" - :icon (all-the-icons-octicon "calendar" :face 'doom-dashboard-menu-title) - :when (fboundp 'org-agenda) - :action org-agenda) - ("Recently opened files" - :icon (all-the-icons-octicon "file-text" :face 'doom-dashboard-menu-title) - :action recentf-open-files) - ("Open project" - :icon (all-the-icons-octicon "briefcase" :face 'doom-dashboard-menu-title) - :action projectile-switch-project) - ("Jump to bookmark" - :icon (all-the-icons-octicon "bookmark" :face 'doom-dashboard-menu-title) - :action bookmark-jump) - ("Open private configuration" - :icon (all-the-icons-octicon "tools" :face 'doom-dashboard-menu-title) - :when (file-directory-p doom-user-dir) - :action doom/open-private-config) - ("Open documentation" - :icon (all-the-icons-octicon "book" :face 'doom-dashboard-menu-title) - :action doom/help)) - "An alist of menu buttons used by `doom-dashboard-widget-shortmenu'. Each -element is a cons cell (LABEL . PLIST). LABEL is a string to display after the -icon and before the key string. - -PLIST can have the following properties: - - :icon FORM - Uses the return value of FORM as an icon (can be literal string). - :key STRING - The keybind displayed next to the button. - :when FORM - If FORM returns nil, don't display this button. - :face FACE - Displays the icon and text with FACE (a face symbol). - :action FORM - Run FORM when the button is pushed.") - -;; -(defvar +doom-dashboard--last-cwd nil) -(defvar +doom-dashboard--width 80) -(defvar +doom-dashboard--old-fringe-indicator fringe-indicator-alist) -(defvar +doom-dashboard--pwd-alist ()) -(defvar +doom-dashboard--reload-timer nil) - -(defvar all-the-icons-scale-factor) -(defvar all-the-icons-default-adjust) - - -;; -;;; Bootstrap - -(defun +doom-dashboard-init-h () - "Initializes Doom's dashboard." - (unless noninteractive - ;; Ensure the dashboard becomes Emacs' go-to buffer when there's nothing - ;; else to show. - (setq doom-fallback-buffer-name +doom-dashboard-name - initial-buffer-choice #'doom-fallback-buffer) - (unless fancy-splash-image - (setq fancy-splash-image - (expand-file-name +doom-dashboard-banner-file - +doom-dashboard-banner-dir))) - (when (equal (buffer-name) "*scratch*") - (set-window-buffer nil (doom-fallback-buffer)) - (+doom-dashboard-reload)) - (add-hook 'doom-load-theme-hook #'+doom-dashboard-reload-on-theme-change-h) - ;; Ensure the dashboard is up-to-date whenever it is switched to or resized. - (add-hook 'window-configuration-change-hook #'+doom-dashboard-resize-h) - (add-hook 'window-size-change-functions #'+doom-dashboard-resize-h) - (add-hook 'doom-switch-buffer-hook #'+doom-dashboard-reload-maybe-h) - (add-hook 'delete-frame-functions #'+doom-dashboard-reload-frame-h) - ;; `persp-mode' integration: update `default-directory' when switching perspectives - (add-hook 'persp-created-functions #'+doom-dashboard--persp-record-project-h) - (add-hook 'persp-activated-functions #'+doom-dashboard--persp-detect-project-h) - ;; HACK Fix #2219 where, in GUI daemon frames, the dashboard loses center - ;; alignment after switching (or killing) workspaces. - (when (daemonp) - (add-hook 'persp-activated-functions #'+doom-dashboard-reload-maybe-h)) - (add-hook 'persp-before-switch-functions #'+doom-dashboard--persp-record-project-h))) - -(add-hook 'doom-init-ui-hook #'+doom-dashboard-init-h 'append) - -;; -;;; Faces -(defgroup doom-dashboard nil - "Manage how doom-dashboard is coloured and themed." - :prefix "doom-dashboard" - :group 'doom-themes) - -(defface doom-dashboard-banner '((t (:inherit font-lock-comment-face))) - "Face used for the DOOM banner on the dashboard" - :group 'doom-dashboard) - -(defface doom-dashboard-footer '((t (:inherit font-lock-keyword-face))) - "Face used for the footer on the dashboard" - :group 'doom-dashboard) - -(defface doom-dashboard-footer-icon '((t (:inherit all-the-icons-green))) - "Face used for the icon of the footer on the dashboard" - :group 'doom-dashboard) - -(defface doom-dashboard-loaded '((t (:inherit font-lock-comment-face))) - "Face used for the loaded packages benchmark" - :group 'doom-dashboard) - -(defface doom-dashboard-menu-desc '((t (:inherit font-lock-constant-face))) - "Face used for the key description of menu widgets on the dashboard" - :group 'doom-dashboard) - -(defface doom-dashboard-menu-title '((t (:inherit font-lock-keyword-face))) - "Face used for the title of menu widgets on the dashboard" - :group 'doom-dashboard) - - -;; -;;; Major mode - -(define-derived-mode +doom-dashboard-mode special-mode - (format "DOOM v%s" doom-version) - "Major mode for the DOOM dashboard buffer." - :syntax-table nil - :abbrev-table nil - (buffer-disable-undo) - (setq truncate-lines t) - (setq-local whitespace-style nil) - (setq-local show-trailing-whitespace nil) - (setq-local hscroll-margin 0) - (setq-local tab-width 2) - ;; Don't scroll to follow cursor - (setq-local scroll-preserve-screen-position nil) - (setq-local auto-hscroll-mode nil) - ;; Line numbers are ugly with large margins - (setq-local display-line-numbers-type nil) - (cl-loop for (car . _cdr) in fringe-indicator-alist - collect (cons car nil) into alist - finally do (setq-local fringe-indicator-alist alist)) - ;; Ensure point is always on a button - (add-hook 'post-command-hook #'+doom-dashboard-reposition-point-h nil 'local) - ;; hl-line produces an ugly cut-off line highlight in the dashboard, so don't - ;; activate it there (by pretending it's already active). - (setq-local hl-line-mode t)) - -(define-key! +doom-dashboard-mode-map - [left-margin mouse-1] #'ignore - [remap forward-button] #'+doom-dashboard/forward-button - [remap backward-button] #'+doom-dashboard/backward-button - "n" #'forward-button - "p" #'backward-button - "C-n" #'forward-button - "C-p" #'backward-button - [down] #'forward-button - [up] #'backward-button - [tab] #'forward-button - [backtab] #'backward-button - - ;; Evil remaps - [remap evil-next-line] #'forward-button - [remap evil-previous-line] #'backward-button - [remap evil-next-visual-line] #'forward-button - [remap evil-previous-visual-line] #'backward-button - [remap evil-paste-pop-next] #'forward-button - [remap evil-paste-pop] #'backward-button - [remap evil-delete] #'ignore - [remap evil-delete-line] #'ignore - [remap evil-insert] #'ignore - [remap evil-append] #'ignore - [remap evil-replace] #'ignore - [remap evil-enter-replace-state] #'ignore - [remap evil-change] #'ignore - [remap evil-change-line] #'ignore - [remap evil-visual-char] #'ignore - [remap evil-visual-line] #'ignore) - - -;; -;;; Hooks - -(defun +doom-dashboard-reposition-point-h () - "Trap the point in the buttons." - (when (region-active-p) - (setq deactivate-mark t) - (when (bound-and-true-p evil-local-mode) - (evil-change-to-previous-state))) - (or (ignore-errors - (if (button-at (point)) - (forward-button 0) - (backward-button 1))) - (ignore-errors - (goto-char (point-min)) - (forward-button 1)))) - -(defun +doom-dashboard-reload-maybe-h (&rest _) - "Reload the dashboard or its state. - -If this isn't a dashboard buffer, move along, but record its `default-directory' -if the buffer is real. See `doom-real-buffer-p' for an explanation for what -'real' means. - -If this is the dashboard buffer, reload it completely." - (cond ((+doom-dashboard-p (current-buffer)) - (let (+doom-dashboard-inhibit-refresh) - (ignore-errors (+doom-dashboard-reload)))) - ((and (not (file-remote-p default-directory)) - (doom-real-buffer-p (current-buffer))) - (setq +doom-dashboard--last-cwd default-directory) - (+doom-dashboard-update-pwd-h)))) - -(defun +doom-dashboard-reload-frame-h (_frame) - "Reload the dashboard after a brief pause. This is necessary for new frames, -whose dimensions may not be fully initialized by the time this is run." - (when (timerp +doom-dashboard--reload-timer) - (cancel-timer +doom-dashboard--reload-timer)) ; in case this function is run rapidly - (setq +doom-dashboard--reload-timer - (run-with-timer 0.1 nil #'+doom-dashboard-reload t))) - -(defun +doom-dashboard-resize-h (&rest _) - "Recenter the dashboard, and reset its margins and fringes." - (let (buffer-list-update-hook - window-configuration-change-hook - window-size-change-functions) - (when-let (windows (get-buffer-window-list (doom-fallback-buffer) nil t)) - (dolist (win windows) - (set-window-start win 0) - (set-window-fringes win 0 0) - (set-window-margins - win (max 0 (/ (- (window-total-width win) +doom-dashboard--width) 2)))) - (with-current-buffer (doom-fallback-buffer) - (save-excursion - (with-silent-modifications - (goto-char (point-min)) - (delete-region (line-beginning-position) - (save-excursion (skip-chars-forward "\n") - (point))) - (insert (make-string - (+ (max 0 (- (/ (window-height (get-buffer-window)) 2) - (round (/ (count-lines (point-min) (point-max)) - 2)))) - (car +doom-dashboard-banner-padding)) - ?\n)))))))) - -(defun +doom-dashboard--persp-detect-project-h (&rest _) - "Set dashboard's PWD to current persp's `last-project-root', if it exists. - -This and `+doom-dashboard--persp-record-project-h' provides `persp-mode' -integration with the Doom dashboard. It ensures that the dashboard is always in -the correct project (which may be different across perspective)." - (when (bound-and-true-p persp-mode) - (when-let (pwd (persp-parameter 'last-project-root)) - (+doom-dashboard-update-pwd-h pwd)))) - -(defun +doom-dashboard--persp-record-project-h (&optional persp &rest _) - "Record the last `doom-project-root' for the current persp. -See `+doom-dashboard--persp-detect-project-h' for more information." - (when (bound-and-true-p persp-mode) - (set-persp-parameter - 'last-project-root (doom-project-root) - (if (persp-p persp) - persp - (get-current-persp))))) - - -;; -;;; Library - -(defun +doom-dashboard-p (buffer) - "Returns t if BUFFER is the dashboard buffer." - (eq buffer (get-buffer +doom-dashboard-name))) - -(defun +doom-dashboard-update-pwd-h (&optional pwd) - "Update `default-directory' in the Doom dashboard buffer. -What it is set to is controlled by `+doom-dashboard-pwd-policy'." - (if pwd - (with-current-buffer (doom-fallback-buffer) - (doom-log "Changed dashboard's PWD to %s" pwd) - (setq-local default-directory pwd)) - (let ((new-pwd (+doom-dashboard--get-pwd))) - (when (and new-pwd (file-accessible-directory-p new-pwd)) - (+doom-dashboard-update-pwd-h - (concat (directory-file-name new-pwd) - "/")))))) - -(defun +doom-dashboard-reload-on-theme-change-h () - "Forcibly reload the Doom dashboard when theme changes post-startup." - (when after-init-time - (+doom-dashboard-reload 'force))) - -(defun +doom-dashboard-reload (&optional force) - "Update the DOOM scratch buffer (or create it, if it doesn't exist)." - (when (or (and (not +doom-dashboard-inhibit-refresh) - (get-buffer-window (doom-fallback-buffer)) - (not (window-minibuffer-p (frame-selected-window))) - (not (run-hook-with-args-until-success '+doom-dashboard-inhibit-functions))) - force) - (with-current-buffer (doom-fallback-buffer) - (doom-log "Reloading dashboard at %s" (format-time-string "%T")) - (with-silent-modifications - (let ((pt (point))) - (unless (eq major-mode '+doom-dashboard-mode) - (+doom-dashboard-mode)) - (erase-buffer) - (run-hooks '+doom-dashboard-functions) - (goto-char pt) - (+doom-dashboard-reposition-point-h)) - (+doom-dashboard-resize-h) - (+doom-dashboard--persp-detect-project-h) - (+doom-dashboard-update-pwd-h) - (current-buffer))))) - -;; helpers -(defun +doom-dashboard--center (len s) - (concat (make-string (ceiling (max 0 (- len (length s))) 2) ? ) - s)) - -(defun +doom-dashboard--get-pwd () - (let ((lastcwd +doom-dashboard--last-cwd) - (policy +doom-dashboard-pwd-policy)) - (cond ((null policy) - default-directory) - ((stringp policy) - (expand-file-name policy lastcwd)) - ((functionp policy) - (funcall policy lastcwd)) - ((null lastcwd) - default-directory) - ((eq policy 'last-project) - (or (doom-project-root lastcwd) - lastcwd)) - ((eq policy 'last) - lastcwd) - ((warn "`+doom-dashboard-pwd-policy' has an invalid value of '%s'" - policy))))) - - -;; -;;; Widgets - -(defun doom-dashboard-draw-ascii-banner-fn () - (let* ((banner - '("================= =============== =============== ======== ========" - "\\\\ . . . . . . .\\\\ //. . . . . . .\\\\ //. . . . . . .\\\\ \\\\. . .\\\\// . . //" - "||. . ._____. . .|| ||. . ._____. . .|| ||. . ._____. . .|| || . . .\\/ . . .||" - "|| . .|| ||. . || || . .|| ||. . || || . .|| ||. . || ||. . . . . . . ||" - "||. . || || . .|| ||. . || || . .|| ||. . || || . .|| || . | . . . . .||" - "|| . .|| ||. _-|| ||-_ .|| ||. . || || . .|| ||. _-|| ||-_.|\\ . . . . ||" - "||. . || ||-' || || `-|| || . .|| ||. . || ||-' || || `|\\_ . .|. .||" - "|| . _|| || || || || ||_ . || || . _|| || || || |\\ `-_/| . ||" - "||_-' || .|/ || || \\|. || `-_|| ||_-' || .|/ || || | \\ / |-_.||" - "|| ||_-' || || `-_|| || || ||_-' || || | \\ / | `||" - "|| `' || || `' || || `' || || | \\ / | ||" - "|| .===' `===. .==='.`===. .===' /==. | \\/ | ||" - "|| .==' \\_|-_ `===. .===' _|_ `===. .===' _-|/ `== \\/ | ||" - "|| .==' _-' `-_ `=' _-' `-_ `=' _-' `-_ /| \\/ | ||" - "|| .==' _-' '-__\\._-' '-_./__-' `' |. /| | ||" - "||.==' _-' `' | /==.||" - "==' _-' E M A C S \\/ `==" - "\\ _-' `-_ /" - " `'' ``'")) - (longest-line (apply #'max (mapcar #'length banner)))) - (put-text-property - (point) - (dolist (line banner (point)) - (insert (+doom-dashboard--center - +doom-dashboard--width - (concat - line (make-string (max 0 (- longest-line (length line))) - 32))) - "\n")) - 'face 'doom-dashboard-banner))) - -(defun doom-dashboard-widget-banner () - (let ((point (point))) - (when (functionp +doom-dashboard-ascii-banner-fn) - (funcall +doom-dashboard-ascii-banner-fn)) - (when (and (display-graphic-p) - (stringp fancy-splash-image) - (file-readable-p fancy-splash-image)) - (let ((image (create-image (fancy-splash-image-file)))) - (add-text-properties - point (point) `(display ,image rear-nonsticky (display))) - (save-excursion - (goto-char point) - (insert (make-string - (truncate - (max 0 (+ 1 (/ (- +doom-dashboard--width - (car (image-size image nil))) - 2)))) - ? )))) - (insert (make-string (or (cdr +doom-dashboard-banner-padding) 0) - ?\n))))) - -(defun doom-dashboard-widget-loaded () - (when doom-init-time - (insert - "\n\n" - (propertize - (+doom-dashboard--center - +doom-dashboard--width - (doom-display-benchmark-h 'return)) - 'face 'doom-dashboard-loaded) - "\n"))) - -(defun doom-dashboard-widget-shortmenu () - (let ((all-the-icons-scale-factor 1.45) - (all-the-icons-default-adjust -0.02)) - (insert "\n") - (dolist (section +doom-dashboard-menu-sections) - (cl-destructuring-bind (label &key icon action when face key) section - (when (and (fboundp action) - (or (null when) - (eval when t))) - (insert - (+doom-dashboard--center - (- +doom-dashboard--width 1) - (let ((icon (if (stringp icon) icon (eval icon t)))) - (format (format "%s%%s%%-10s" (if icon "%3s\t" "%3s")) - (or icon "") - (with-temp-buffer - (insert-text-button - label - 'action - `(lambda (_) - (call-interactively (or (command-remapping #',action) - #',action))) - 'face (or face 'doom-dashboard-menu-title) - 'follow-link t - 'help-echo - (format "%s (%s)" label - (propertize (symbol-name action) 'face 'doom-dashboard-menu-desc))) - (format "%-37s" (buffer-string))) - ;; Lookup command keys dynamically - (propertize - (or key - (when-let* - ((keymaps - (delq - nil (list (when (bound-and-true-p evil-local-mode) - (evil-get-auxiliary-keymap +doom-dashboard-mode-map 'normal)) - +doom-dashboard-mode-map))) - (key - (or (when keymaps - (where-is-internal action keymaps t)) - (where-is-internal action nil t)))) - (with-temp-buffer - (save-excursion (insert (key-description key))) - (while (re-search-forward "<\\([^>]+\\)>" nil t) - (let ((str (match-string 1))) - (replace-match - (upcase (if (< (length str) 3) - str - (substring str 0 3)))))) - (buffer-string))) - "") - 'face 'doom-dashboard-menu-desc)))) - (if (display-graphic-p) - "\n\n" - "\n"))))))) - -(defun doom-dashboard-widget-footer () - (insert - "\n" - (+doom-dashboard--center - (- +doom-dashboard--width 2) - (with-temp-buffer - (insert-text-button (or (all-the-icons-octicon "octoface" :face 'doom-dashboard-footer-icon :height 1.3 :v-adjust -0.15) - (propertize "github" 'face 'doom-dashboard-footer)) - 'action (lambda (_) (browse-url "https://github.com/hlissner/doom-emacs")) - 'follow-link t - 'help-echo "Open Doom Emacs github page") - (buffer-string))) - "\n")) diff --git a/.config/emacs/modules/ui/doom-dashboard/test/test-doom-dashboard.el b/.config/emacs/modules/ui/doom-dashboard/test/test-doom-dashboard.el @@ -1,40 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; ui/doom-dashboard/test/test-doom-dashboard.el - -(require 'core-projects) -(require 'projectile) -(require! :ui doom-dashboard) - -(describe "ui/doom-dashboard" - :var (default-directory projectile-enable-caching) - (before-all - (setq projectile-enable-caching nil - doom-fallback-buffer-name +doom-dashboard-name)) - - (before-each (projectile-mode +1)) - (after-each (projectile-mode -1)) - - (describe "get-pwd" - :var (+doom-dashboard--last-cwd) - (before-each - (setq +doom-dashboard--last-cwd doom-core-dir - default-directory doom-core-dir)) - (it "returns the current directory when policy is nil" - (let (+doom-dashboard-pwd-policy) - (expect (+doom-dashboard--get-pwd) :to-equal default-directory))) - (it "returns a path if policy is a path" - (let ((+doom-dashboard-pwd-policy "~")) - (expect (+doom-dashboard--get-pwd) :to-equal (expand-file-name "~")))) - (it "returns return value of policy as a function" - (let ((+doom-dashboard-pwd-policy (lambda (x) "x"))) - (expect (+doom-dashboard--get-pwd) :to-equal "x"))) - (it "returns last cwd if policy is 'last" - (let ((+doom-dashboard-pwd-policy 'last)) - (expect (+doom-dashboard--get-pwd) :to-equal doom-core-dir))) - (it "returns last project if policy is 'last-project" - (let ((+doom-dashboard-pwd-policy 'last-project)) - (expect (+doom-dashboard--get-pwd) :to-equal doom-emacs-dir)))) - - (describe "dashboard-p" - (it "changes the fallback buffer to the dashboard buffer" - (expect (+doom-dashboard-p (doom-fallback-buffer)))))) diff --git a/.config/emacs/modules/ui/doom-quit/README.org b/.config/emacs/modules/ui/doom-quit/README.org @@ -1,68 +0,0 @@ -#+title: :ui doom-quit -#+subtitle: One does not simply quit Emacs -#+created: February 19, 2017 -#+since: 2.0.0 - -* Description :unfold: -A silly module that throws cute confirmation prompts at you when you exit Emacs, -like DOOM (the game) did. Some quotes are from the classic games, others are -random, nerdy references that no decent human being has any business -recognizing. - -** Maintainers -- [[doom-user:][@hlissner]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -/This module doesn't install any packages./ - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* Usage -Quit Emacs with [[kbd:][<leader> q q]] and watch it go. The prompt only happens if you -have (real) buffers open. - -#+begin_quote - 🚧 This module won't kick in when killing daemon frames (because that isn't - actually “quitting” Emacs). -#+end_quote - -* Configurations -The messages presented by this module can be customized by changing the -~+doom-quit-messages~ variable: -#+begin_src emacs-lisp -(setq +doom-quit-messages - '(;;from doom 2 - "Don't go now, there's a dimensional shambler waiting at the dos prompt!" - "Get outta here and go back to your boring programs." - "If I were your boss, I'd deathmatch ya in a minute!" - "Look, bud. You leave now and you forfeit your body count!" - "You're lucky I don't smack you for thinking about leaving.")) - #+end_src - -* Troubleshooting -If you have any issues with this module do let me know - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* Appendix -** Variables -- [[var:+doom-quit-messages]] - -** Functions -- [[fn:+doom-quit-fn]] diff --git a/.config/emacs/modules/ui/doom-quit/config.el b/.config/emacs/modules/ui/doom-quit/config.el @@ -1,40 +0,0 @@ -;;; ui/doom-quit/config.el -*- lexical-binding: t; -*- - -(defvar +doom-quit-messages - '(;; from Doom 1 - "Please don't leave, there's more demons to toast!" - "Let's beat it -- This is turning into a bloodbath!" - "I wouldn't leave if I were you. DOS is much worse." - "Don't leave yet -- There's a demon around that corner!" - "Ya know, next time you come in here I'm gonna toast ya." - "Go ahead and leave. See if I care." - "Are you sure you want to quit this great editor?" - ;; from Portal - "Thank you for participating in this Aperture Science computer-aided enrichment activity." - "You can't fire me, I quit!" - "I don't know what you think you are doing, but I don't like it. I want you to stop." - "This isn't brave. It's murder. What did I ever do to you?" - "I'm the man who's going to burn your house down! With the lemons!" - "Okay, look. We've both said a lot of things you're going to regret..." - ;; Custom - "(setq nothing t everything 'permitted)" - "Emacs will remember that." - "Emacs, Emacs never changes." - "Hey! Hey, M-x listen!" - "It's not like I'll miss you or anything, b-baka!" - "Wake up, Mr. Stallman. Wake up and smell the ashes." - "You are *not* prepared!" - "Please don't go. The drones need you. They look up to you.") - "A list of quit messages, picked randomly by `+doom-quit'. Taken from -http://doom.wikia.com/wiki/Quit_messages and elsewhere.") - -(defun +doom-quit-fn (&rest _) - (doom-quit-p - (format "%s %s" - (propertize (nth (random (length +doom-quit-messages)) - +doom-quit-messages) - 'face '(italic default)) - "Really quit Emacs?"))) - -;; -(setq confirm-kill-emacs #'+doom-quit-fn) diff --git a/.config/emacs/modules/ui/doom/README.org b/.config/emacs/modules/ui/doom/README.org @@ -1,115 +0,0 @@ -#+title: :ui doom -#+subtitle: Make Doom fabulous again -#+created: February 20, 2017 -#+since: 2.0.0 - -* Description :unfold: -This module gives Doom its signature look: powered by the [[doom-package:doom-themes][doom-one]] theme -(loosely inspired by [[https://github.com/atom/one-dark-syntax][Atom's One Dark theme]]) and [[doom-package:solaire-mode]]. Includes: - -- A custom folded-region indicator for [[doom-package:hideshow]]. -- "Thin bar" fringe bitmaps for [[doom-package:git-gutter-fringe]]. -- File-visiting buffers are slightly brighter (thanks to [[doom-package:solaire-mode]]). - -** Maintainers -- [[doom-user:][@hlissner]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:doom-themes]] -- [[doom-package:solaire-mode]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** Changing theme -Although this module uses the ~doom-one~ theme by default, [[https://github.com/hlissner/emacs-doom-theme/][doom-themes]] offers a -number of alternatives: - -- *doom-one:* doom-themes' flagship theme, inspired by [[https://atom.io/][Atom's]] One Dark themes -- *doom-vibrant:* a more vibrant version of doom-one -- *doom-molokai:* based on Textmate's monokai -- *doom-nova:* adapted from [[https://github.com/trevordmiller/nova-colors][Nova]] -- *doom-one-light:* light version of doom-one -- *doom-peacock:* based on Peacock from [[https://daylerees.github.io/][daylerees' themes]] -- *doom-tomorrow-night:* by [[https://github.com/ChrisKempson/Tomorrow-Theme][Chris Kempson]] -- And /many/ more... - -This can be changed by changing the ~doom-theme~ variable, e.g. -#+begin_src emacs-lisp -;; in $DOOMDIR/config.el -(setq doom-theme 'doom-molokai) -#+end_src - -** Changing fonts -core/core-ui.el has four relevant variables: - -- ~doom-font~ :: the default font to use in Doom Emacs. -- ~doom-big-font~ :: the font to use when ~doom-big-font-mode~ is enabled. -- ~doom-variable-pitch-font~ :: the font to use when ~variable-pitch-mode~ is active - (or where the ~variable-pitch~ face is used). -- ~doom-unicode-font~ :: the font used to display unicode symbols. This is - ignored if the [[doom-module::ui unicode]] module is enabled. - -#+begin_src emacs-lisp -(setq doom-font (font-spec :family "Fira Mono" :size 12) - doom-variable-pitch-font (font-spec :family "Fira Sans") - doom-unicode-font (font-spec :family "DejaVu Sans Mono") - doom-big-font (font-spec :family "Fira Mono" :size 19)) -#+end_src - -* Troubleshooting -[[doom-report:][Report an issue?]] - -** Strange font symbols -If you're seeing strange unicode symbols, this is likely because you don't have -~all-the-icons~'s font icon installed. You can install them with ~M-x -all-the-icons-install-fonts~. - -** Ugly background colors in tty Emacs for daemon users -[[doom-package:solaire-mode]] is an aesthetic plugin that makes non-file-visiting buffers darker -than the rest of the Emacs' frame (to visually differentiate temporary windows -or sidebars from editing windows). This looks great in GUI Emacs, but can look -questionable in the terminal. - -It disables itself if you start tty Emacs with ~$ emacs -nw~, but if you create -a tty frame from a daemon (which solaire-mode cannot anticipate), you'll get an -ugly background instead. - -If you only use Emacs in the terminal, your best bet is to disable the -solaire-mode package: -#+begin_src emacs-lisp -;; in $DOOMDIR/packages.el -(package! solaire-mode :disable t) -#+end_src - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/ui/doom/config.el b/.config/emacs/modules/ui/doom/config.el @@ -1,24 +0,0 @@ -;;; ui/doom/config.el -*- lexical-binding: t; -*- - -;;;###package pos-tip -(setq pos-tip-internal-border-width 6 - pos-tip-border-width 1) - - -(use-package! doom-themes - ;; improve integration w/ org-mode - :hook (doom-load-theme . doom-themes-org-config) - :init (setq doom-theme 'doom-one) - ;; more Atom-esque file icons for neotree/treemacs - (when (modulep! :ui neotree) - (add-hook 'doom-load-theme-hook #'doom-themes-neotree-config) - (setq doom-themes-neotree-enable-variable-pitch t - doom-themes-neotree-file-icons 'simple - doom-themes-neotree-line-spacing 2)) - (when (modulep! :ui treemacs) - (add-hook 'doom-load-theme-hook #'doom-themes-treemacs-config))) - - -(use-package! solaire-mode - :hook (doom-load-theme . solaire-global-mode) - :hook (+popup-buffer-mode . turn-on-solaire-mode)) diff --git a/.config/emacs/modules/ui/doom/packages.el b/.config/emacs/modules/ui/doom/packages.el @@ -1,5 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; ui/doom/packages.el - -(package! doom-themes :pin "b5ff201f4bea4286e9ed015a2043cf2394182232") -(package! solaire-mode :pin "8af65fbdc50b25ed3214da949b8a484527c7cc14") diff --git a/.config/emacs/modules/ui/emoji/README.org b/.config/emacs/modules/ui/emoji/README.org @@ -1,67 +0,0 @@ -#+title: :ui emoji -#+subtitle: 💩 -#+created: September 30, 2020 -#+since: 21.12.0 - -* Description :unfold: -This module gives Emacs the ability to display and insert emojis (ASCII, Github -style, or unicode styles), as well as convert certain text patterns (e.g. -=:smile:=) into emojis. - -** Maintainers -*This module needs a maintainer.* [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +ascii :: - Include plain text emojis like =:)=. -- +github :: - Include Github-style emojis like =:smile:=. -- +unicode :: - Include unicode emojis like 🙂. - -** Packages -- [[doom-package:emojify]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -From the [[https://github.com/iqbalansari/emacs-emojify/blob/master/README.org#requirements][emojify requirements]] docs: -#+begin_quote -The [[https://github.com/iqbalansari/emacs-emojify][emojify]] package requires Emacs *v24.3* and above. Emacs should be compiled -with support for *PNG* images to display emojis as images. It is *recommended* -that Emacs is compiled with *ImageMagick* support. ~emojify~ will use it to -resize emojis if needed, additionally imagemagick is used to set background -color for emojis to workaround the bug described in [[https://github.com/iqbalansari/emacs-emojify/issues/7][issue 7]]. However these are -*completely optional*. - -PNG support might require some additional steps to on Windows, you might find -[[http://stackoverflow.com/questions/2650041/emacs-under-windows-and-png-files][this]] stackoverflow answer helpful. -#+end_quote - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/ui/emoji/config.el b/.config/emacs/modules/ui/emoji/config.el @@ -1,12 +0,0 @@ -;;; ui/emoji/config.el -*- lexical-binding: t; -*- - -(use-package! emojify - :hook (doom-first-buffer . global-emojify-mode) - :config - (setq emojify-styles - (delq - nil (list (if (modulep! +ascii) 'ascii) - (if (modulep! +github) 'github) - (if (modulep! +unicode) 'unicode)))) - - (emojify-set-emoji-styles emojify-styles)) diff --git a/.config/emacs/modules/ui/emoji/packages.el b/.config/emacs/modules/ui/emoji/packages.el @@ -1,4 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; ui/emoji/packages.el - -(package! emojify :pin "1b726412f19896abf5e4857d4c32220e33400b55") diff --git a/.config/emacs/modules/ui/hl-todo/README.org b/.config/emacs/modules/ui/hl-todo/README.org @@ -1,87 +0,0 @@ -#+title: :ui hl-todo -#+subtitle: TODO FIXME NOTE DEPRECATED HACK REVIEW -#+created: February 19, 2017 -#+since: 1.3 - -* Description :unfold: -This module adds syntax highlighting for various tags in code comments, such as -=TODO=, =FIXME=, and =NOTE=, among others. - -** Maintainers -- [[doom-user:][@hlissner]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:hl-todo]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -By enabling this module, the following keywords will be highlighted if they -occur in code comments: - -- =TODO=: For things that need to be done, just not today. -- =HACK=: For tidbits that are unconventional and not intended uses of the - constituent parts, and may break in a future update. -- =FIXME=: For problems that will become bigger problems later if not fixed - ASAP. -- =REVIEW=: for things that were done hastily and/or hasn't been thoroughly - tested. it may not even be necessary! -- =NOTE=: For especially important gotchas with a given implementation, directed - at another user other than the author. -- =DEPRECATED=: For things that just gotta go and will soon be gone. -- =BUG=: For a known bug that needs a workaround. -- =XXX=: For warning about a problematic or misguiding code. - -** Keybindings -| keybind | description | -|---------+----------------------------------| -| [[kbd:][]t]] | go to next TODO item | -| [[kbd:][[t]] | go to previous TODO item | -| [[kbd:][SPC p t]] | show all TODO items in a project | -| [[kbd:][SPC s p]] | search project for a string | -| [[kbd:][SPC s b]] | search buffer for string | - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -To add your own ITEMS you would need to configure them using -~hl-todo-keyword-faces~: -#+begin_src emacs-lisp -;; in $DOOMDIR/config.el -(after! hl-todo - (setq hl-todo-keyword-faces - `(("FOO" . ,(face-foreground "MY COLOUR HEX CODE")) - ("BAR" . ,(face-foreground 'my-colour-var))))) -#+end_src - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/ui/hl-todo/config.el b/.config/emacs/modules/ui/hl-todo/config.el @@ -1,51 +0,0 @@ -;;; ui/hl-todo/packages.el -*- lexical-binding: t; -*- - -(use-package! hl-todo - :hook (prog-mode . hl-todo-mode) - :hook (yaml-mode . hl-todo-mode) - :config - (setq hl-todo-highlight-punctuation ":" - hl-todo-keyword-faces - '(;; For reminders to change or add something at a later date. - ("TODO" warning bold) - ;; For code (or code paths) that are broken, unimplemented, or slow, - ;; and may become bigger problems later. - ("FIXME" error bold) - ;; For code that needs to be revisited later, either to upstream it, - ;; improve it, or address non-critical issues. - ("REVIEW" font-lock-keyword-face bold) - ;; For code smells where questionable practices are used - ;; intentionally, and/or is likely to break in a future update. - ("HACK" font-lock-constant-face bold) - ;; For sections of code that just gotta go, and will be gone soon. - ;; Specifically, this means the code is deprecated, not necessarily - ;; the feature it enables. - ("DEPRECATED" font-lock-doc-face bold) - ;; Extra keywords commonly found in the wild, whose meaning may vary - ;; from project to project. - ("NOTE" success bold) - ("BUG" error bold) - ("XXX" font-lock-constant-face bold))) - - - (defadvice! +hl-todo-clamp-font-lock-fontify-region-a (fn &rest args) - "Fix an `args-out-of-range' error in some modes." - :around #'hl-todo-mode - (letf! (defun font-lock-fontify-region (beg end &optional loudly) - (funcall font-lock-fontify-region (max beg 1) end loudly)) - (apply fn args))) - - ;; Use a more primitive todo-keyword detection method in major modes that - ;; don't use/have a valid syntax table entry for comments. - (add-hook! '(pug-mode-hook haml-mode-hook) - (defun +hl-todo--use-face-detection-h () - "Use a different, more primitive method of locating todo keywords." - (set (make-local-variable 'hl-todo-keywords) - '(((lambda (limit) - (let (case-fold-search) - (and (re-search-forward hl-todo-regexp limit t) - (memq 'font-lock-comment-face (ensure-list (get-text-property (point) 'face)))))) - (1 (hl-todo-get-face) t t)))) - (when hl-todo-mode - (hl-todo-mode -1) - (hl-todo-mode +1))))) diff --git a/.config/emacs/modules/ui/hl-todo/packages.el b/.config/emacs/modules/ui/hl-todo/packages.el @@ -1,4 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; ui/hl-todo/packages.el - -(package! hl-todo :pin "a627d33214e60fc5a2fe6164411d908e1afdba59") diff --git a/.config/emacs/modules/ui/hydra/README.org b/.config/emacs/modules/ui/hydra/README.org @@ -1,62 +0,0 @@ -#+title: :ui hydra -#+subtitle: Discount modality for mythological beast hunters -#+created: October 29, 2019 -#+since: 2.0.0 - -#+begin_quote - 🚧 *This module is deprecated.* The module is too trivially small, and it's - always been unclear how hydra fits into Doom's vision for its UI. It's been - decided that Doom will head toward Embark, transient, or hercules instead. -#+end_quote - -* Description :unfold: -This module adds hydra to Doom Emacs, as well as a few custom built hydras to -start with: - -- A hydra to control windows ~+hydra/window-nav/body~. -- A hydra to control text zoom level ~+hydra/text-zoom/body~. - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:hydra]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -Configuring this module is only setting bindings to the provided hydra, or -creating your own ones! - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/ui/hydra/autoload/windows.el b/.config/emacs/modules/ui/hydra/autoload/windows.el @@ -1,49 +0,0 @@ -;;; ui/hydra/autoload/windows.el -*- lexical-binding: t; -*- - -;;;###autoload (autoload '+hydra/text-zoom/body "ui/hydra/autoload/windows" nil t) -(defhydra +hydra/text-zoom (:hint nil :color red) - " - Text zoom: _j_:zoom in, _k_:zoom out, _0_:reset -" - ("j" doom/increase-font-size "in") - ("k" doom/decrease-font-size "out") - ("0" doom/reset-font-size "reset")) - -;;;###autoload (autoload '+hydra/window-nav/body "ui/hydra/autoload/windows" nil t) -(defhydra +hydra/window-nav (:hint nil) - " - Split: _v_ert _s_:horz - Delete: _c_lose _o_nly - Switch Window: _h_:left _j_:down _k_:up _l_:right _u_:undo _r_:redo - Buffers: _p_revious _n_ext _b_:select _f_ind-file - Resize: _H_:splitter left _J_:splitter down _K_:splitter up _L_:splitter right - Move: _a_:up _z_:down _i_menu -" - ("z" scroll-up-line) - ("a" scroll-down-line) - ("i" idomenu) - - ("h" windmove-left) - ("j" windmove-down) - ("k" windmove-up) - ("l" windmove-right) - ("u" winner-undo) - ("r" winner-redo) - - ("p" previous-buffer) - ("n" next-buffer) - ("b" switch-to-buffer) - ("f" find-file) - - ("s" split-window-below) - ("v" split-window-right) - - ("c" delete-window) - ("o" delete-other-windows) - - ("H" hydra-move-splitter-left) - ("J" hydra-move-splitter-down) - ("K" hydra-move-splitter-up) - ("L" hydra-move-splitter-right) - - ("q" nil)) diff --git a/.config/emacs/modules/ui/hydra/config.el b/.config/emacs/modules/ui/hydra/config.el @@ -1,15 +0,0 @@ -;;; ui/hydra/config.el -*- lexical-binding: t; -*- - -(use-package! hydra-examples - :commands (hydra-move-splitter-up - hydra-move-splitter-down - hydra-move-splitter-right - hydra-move-splitter-left)) - -;;;###package hydra -(setq lv-use-separator t) - -(defadvice! +hydra--inhibit-window-switch-hooks-a (fn) - :around #'lv-window - (let (doom-switch-window-hook) - (funcall fn))) diff --git a/.config/emacs/modules/ui/hydra/packages.el b/.config/emacs/modules/ui/hydra/packages.el @@ -1,4 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; ui/hydra/packages.el - -(package! hydra :pin "317e1de33086637579a7aeb60f77ed0405bf359b") diff --git a/.config/emacs/modules/ui/indent-guides/README.org b/.config/emacs/modules/ui/indent-guides/README.org @@ -1,49 +0,0 @@ -#+title: :ui indent-guides -#+subtitle: Line up them indent columns -#+created: March 11, 2019 -#+since: 21.12.0 - -* TODO Description :unfold: -/(No description yet)/ - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:highlight-indent-guides]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/ui/indent-guides/config.el b/.config/emacs/modules/ui/indent-guides/config.el @@ -1,20 +0,0 @@ -;;; ui/indent-guides/config.el -*- lexical-binding: t; -*- - -(use-package! highlight-indent-guides - :hook ((prog-mode text-mode conf-mode) . highlight-indent-guides-mode) - :init (setq highlight-indent-guides-method 'character) - :config - ;; HACK: If this package is loaded too early (by the user, and in terminal - ;; Emacs), then `highlight-indent-guides-auto-set-faces' will have been - ;; called much too early to set its faces correctly. To get around this, we - ;; need to call it again, but at a time when I can ensure a frame exists an - ;; the current theme is loaded. - (when (doom-context-p 'init) - (add-hook 'doom-first-buffer-hook #'highlight-indent-guides-auto-set-faces)) - - ;; `highlight-indent-guides' breaks when `org-indent-mode' is active - (add-hook! 'org-mode-local-vars-hook - (defun +indent-guides-disable-maybe-h () - (and highlight-indent-guides-mode - (bound-and-true-p org-indent-mode) - (highlight-indent-guides-mode -1))))) diff --git a/.config/emacs/modules/ui/indent-guides/packages.el b/.config/emacs/modules/ui/indent-guides/packages.el @@ -1,4 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; ui/indent-guides/packages.el - -(package! highlight-indent-guides :pin "cf352c85cd15dd18aa096ba9d9ab9b7ab493e8f6") diff --git a/.config/emacs/modules/ui/ligatures/+fira.el b/.config/emacs/modules/ui/ligatures/+fira.el @@ -1,123 +0,0 @@ -;;; ui/ligatures/+fira.el -*- lexical-binding: t; -*- - -(+ligatures--def-font fira - ("Fira Code Symbol" - :range '(#Xe100 . #Xe16f) - :url "https://github.com/tonsky/FiraCode/raw/13234c0/distr/ttf/%s" - :files '("FiraCode-Bold.ttf" - "FiraCode-Light.ttf" - "FiraCode-Medium.ttf" - "FiraCode-Regular.ttf" - "FiraCode-Retina.ttf")) - ("www" . #Xe100) - ("**" . #Xe101) - ("***" . #Xe102) - ("**/" . #Xe103) - ("*>" . #Xe104) - ("*/" . #Xe105) - ("\\\\" . #Xe106) - ("\\\\\\" . #Xe107) - ("{-" . #Xe108) - ("[]" . #Xe109) - ("::" . #Xe10a) - (":::" . #Xe10b) - (":=" . #Xe10c) - ("!!" . #Xe10d) - ("!=" . #Xe10e) - ("!==" . #Xe10f) - ("-}" . #Xe110) - ("--" . #Xe111) - ("---" . #Xe112) - ("-->" . #Xe113) - ("->" . #Xe114) - ("->>" . #Xe115) - ("-<" . #Xe116) - ("-<<" . #Xe117) - ("-~" . #Xe118) - ("#{" . #Xe119) - ("#[" . #Xe11a) - ("##" . #Xe11b) - ("###" . #Xe11c) - ("####" . #Xe11d) - ("#(" . #Xe11e) - ("#?" . #Xe11f) - ("#_" . #Xe120) - ("#_(" . #Xe121) - (".-" . #Xe122) - (".=" . #Xe123) - (".." . #Xe124) - ("..<" . #Xe125) - ("..." . #Xe126) - ("?=" . #Xe127) - ("??" . #Xe128) - (";;" . #Xe129) - ("/*" . #Xe12a) - ("/**" . #Xe12b) - ("/=" . #Xe12c) - ("/==" . #Xe12d) - ("/>" . #Xe12e) - ("//" . #Xe12f) - ("///" . #Xe130) - ("&&" . #Xe131) - ("||" . #Xe132) - ("||=" . #Xe133) - ("|=" . #Xe134) - ("|>" . #Xe135) - ("^=" . #Xe136) - ("$>" . #Xe137) - ("++" . #Xe138) - ("+++" . #Xe139) - ("+>" . #Xe13a) - ("=:=" . #Xe13b) - ("==" . #Xe13c) - ("===" . #Xe13d) - ("==>" . #Xe13e) - ("=>" . #Xe13f) - ("=>>" . #Xe140) - ("=<" . #Xe141) - ("=<<" . #Xe142) - ("=/=" . #Xe143) - (">-" . #Xe144) - (">=" . #Xe145) - (">=>" . #Xe146) - (">>" . #Xe147) - (">>-" . #Xe148) - (">>=" . #Xe149) - (">>>" . #Xe14a) - ("<*" . #Xe14b) - ("<*>" . #Xe14c) - ("<|" . #Xe14d) - ("<|>" . #Xe14e) - ("<$" . #Xe14f) - ("<$>" . #Xe150) - ("<!--" . #Xe151) - ("<-" . #Xe152) - ("<--" . #Xe153) - ("<->" . #Xe154) - ("<+" . #Xe155) - ("<+>" . #Xe156) - ("<=" . #Xe157) - ("<==" . #Xe158) - ("<=>" . #Xe159) - ("<=<" . #Xe15a) - ("<>" . #Xe15b) - ("<<" . #Xe15c) - ("<<-" . #Xe15d) - ("<<=" . #Xe15e) - ("<<<" . #Xe15f) - ("<~" . #Xe160) - ("<~~" . #Xe161) - ("</" . #Xe162) - ("</>" . #Xe163) - ("~@" . #Xe164) - ("~-" . #Xe165) - ("~=" . #Xe166) - ("~>" . #Xe167) - ("~~" . #Xe168) - ("~~>" . #Xe169) - ("%%" . #Xe16a) - ("x" . #Xe16b) - (":" . #Xe16c) - ("+" . #Xe16d) - ("+" . #Xe16e) - ("*" . #Xe16f)) diff --git a/.config/emacs/modules/ui/ligatures/+hasklig.el b/.config/emacs/modules/ui/ligatures/+hasklig.el @@ -1,62 +0,0 @@ -;;; ui/ligatures/+hasklig.el -*- lexical-binding: t; -*- - -(+ligatures--def-font hasklig - ("Hasklig" - :range '(#Xe100 . #Xe129) - :url "https://github.com/jsravn/hasklig-emacs/raw/33354a3/%s" - :files '("Hasklig-Black.otf" - "Hasklig-BlackIt.otf" - "Hasklig-Bold.otf" - "Hasklig-BoldIt.otf" - "Hasklig-ExtraLight.otf" - "Hasklig-ExtraLightIt.otf" - "Hasklig-It.otf" - "Hasklig-Light.otf" - "Hasklig-LightIt.otf" - "Hasklig-Medium.otf" - "Hasklig-MediumIt.otf" - "Hasklig-Regular.otf" - "Hasklig-Semibold.otf" - "Hasklig-SemiboldIt.otf")) - ("&&" . #Xe100) - ("***" . #Xe101) - ("*>" . #Xe102) - ("\\\\" . #Xe103) - ("||" . #Xe104) - ("|>" . #Xe105) - ("::" . #Xe106) - ("==" . #Xe107) - ("===" . #Xe108) - ("==>" . #Xe109) - ("=>" . #Xe10a) - ("=<<" . #Xe10b) - ("!!" . #Xe10c) - (">>" . #Xe10d) - (">>=" . #Xe10e) - (">>>" . #Xe10f) - (">>-" . #Xe110) - (">-" . #Xe111) - ("->" . #Xe112) - ("-<" . #Xe113) - ("-<<" . #Xe114) - ("<*" . #Xe115) - ("<*>" . #Xe116) - ("<|" . #Xe117) - ("<|>" . #Xe118) - ("<$>" . #Xe119) - ("<>" . #Xe11a) - ("<-" . #Xe11b) - ("<<" . #Xe11c) - ("<<<" . #Xe11d) - ("<+>" . #Xe11e) - (".." . #Xe11f) - ("..." . #Xe120) - ("++" . #Xe121) - ("+++" . #Xe122) - ("/=" . #Xe123) - (":::" . #Xe124) - (">=>" . #Xe125) - ("->>" . #Xe126) - ("<=>" . #Xe127) - ("<=<" . #Xe128) - ("<->" . #Xe129)) diff --git a/.config/emacs/modules/ui/ligatures/+iosevka.el b/.config/emacs/modules/ui/ligatures/+iosevka.el @@ -1,244 +0,0 @@ -;;; ui/ligatures/+iosevka.el -*- lexical-binding: t; -*- - -(+ligatures--def-font iosevka - ("Iosevka" - :range '(#Xe100 . #Xe1cc) - :url "https://github.com/jsravn/iosevka-emacs/raw/20fc2c4/%s" - :files '("iosevka-custom-lightoblique.ttf" - "iosevka-custom-thinoblique.ttf" - "iosevka-custom-mediumitalic.ttf" - "iosevka-custom-light.ttf" - "iosevka-custom-heavy.ttf" - "iosevka-custom-bolditalic.ttf" - "iosevka-custom-bold.ttf" - "iosevka-custom-lightitalic.ttf" - "iosevka-custom-thin.ttf" - "iosevka-custom-extralight.ttf" - "iosevka-custom-oblique.ttf" - "iosevka-custom-italic.ttf" - "iosevka-custom-heavyoblique.ttf" - "iosevka-custom-heavyitalic.ttf" - "iosevka-custom-extralightitalic.ttf" - "iosevka-custom-thinitalic.ttf" - "iosevka-custom-medium.ttf" - "iosevka-custom-mediumoblique.ttf" - "iosevka-custom-extralightoblique.ttf" - "iosevka-custom-boldoblique.ttf" - "iosevka-custom-regular.ttf")) - ;; Double-ended hyphen arrows - ("<->" . #Xe100) - ("<-->" . #Xe101) - ("<--->" . #Xe102) - ("<---->" . #Xe103) - ("<----->" . #Xe104) - ;; Double-ended equals arrows - ("<=>" . #Xe105) - ("<==>" . #Xe106) - ("<===>" . #Xe107) - ("<====>" . #Xe108) - ("<=====>" . #Xe109) - ;; Double-ended asterisk operators - ("<**>" . #Xe10a) - ("<***>" . #Xe10b) - ("<****>" . #Xe10c) - ("<*****>" . #Xe10d) - ;; HTML comments - ("<!--" . #Xe10e) - ("<!---" . #Xe10f) - ;; Three-char ops with discards - ("<$" . #Xe110) - ("<$>" . #Xe111) - ("$>" . #Xe112) - ("<." . #Xe113) - ("<.>" . #Xe114) - (".>" . #Xe115) - ("<*" . #Xe116) - ("<*>" . #Xe117) - ("*>" . #Xe118) - ("<\\" . #Xe119) - ("<\\>" . #Xe11a) - ("\\>" . #Xe11b) - ("</" . #Xe11c) - ("</>" . #Xe11d) - ("/>" . #Xe11e) - ("<\"" . #Xe11f) - ("<\">" . #Xe120) - ("\">" . #Xe121) - ("<'" . #Xe122) - ("<'>" . #Xe123) - ("'>" . #Xe124) - ("<^" . #Xe125) - ("<^>" . #Xe126) - ("^>" . #Xe127) - ("<&" . #Xe128) - ("<&>" . #Xe129) - ("&>" . #Xe12a) - ("<%" . #Xe12b) - ("<%>" . #Xe12c) - ("%>" . #Xe12d) - ("<@" . #Xe12e) - ("<@>" . #Xe12f) - ("@>" . #Xe130) - ("<#" . #Xe131) - ("<#>" . #Xe132) - ("#>" . #Xe133) - ("<+" . #Xe134) - ("<+>" . #Xe135) - ("+>" . #Xe136) - ("<-" . #Xe137) - ("<->" . #Xe138) - ("->" . #Xe139) - ("<!" . #Xe13a) - ("<!>" . #Xe13b) - ("!>" . #Xe13c) - ("<?" . #Xe13d) - ("<?>" . #Xe13e) - ("?>" . #Xe13f) - ("<|" . #Xe140) - ("<|>" . #Xe141) - ("|>" . #Xe142) - ("<:" . #Xe143) - ("<:>" . #Xe144) - (":>" . #Xe145) - ;; Colons - ("::" . #Xe146) - (":::" . #Xe147) - ("::::" . #Xe148) - ;; Arrow-like operators - ("->" . #Xe149) - ("->-" . #Xe14a) - ("->--" . #Xe14b) - ("->>" . #Xe14c) - ("->>-" . #Xe14d) - ("->>--" . #Xe14e) - ("->>>" . #Xe14f) - ("->>>-" . #Xe150) - ("->>>--" . #Xe151) - ("-->" . #Xe152) - ("-->-" . #Xe153) - ("-->--" . #Xe154) - ("-->>" . #Xe155) - ("-->>-" . #Xe156) - ("-->>--" . #Xe157) - ("-->>>" . #Xe158) - ("-->>>-" . #Xe159) - ("-->>>--" . #Xe15a) - (">-" . #Xe15b) - (">--" . #Xe15c) - (">>-" . #Xe15d) - (">>--" . #Xe15e) - (">>>-" . #Xe15f) - (">>>--" . #Xe160) - ("=>" . #Xe161) - ("=>=" . #Xe162) - ("=>==" . #Xe163) - ("=>>" . #Xe164) - ("=>>=" . #Xe165) - ("=>>==" . #Xe166) - ("=>>>" . #Xe167) - ("=>>>=" . #Xe168) - ("=>>>==" . #Xe169) - ("==>" . #Xe16a) - ("==>=" . #Xe16b) - ("==>==" . #Xe16c) - ("==>>" . #Xe16d) - ("==>>=" . #Xe16e) - ("==>>==" . #Xe16f) - ("==>>>" . #Xe170) - ("==>>>=" . #Xe171) - ("==>>>==" . #Xe172) - (">=" . #Xe173) - (">==" . #Xe174) - (">>=" . #Xe175) - (">>==" . #Xe176) - (">>>=" . #Xe177) - (">>>==" . #Xe178) - ("<-" . #Xe179) - ("-<-" . #Xe17a) - ("--<-" . #Xe17b) - ("<<-" . #Xe17c) - ("-<<-" . #Xe17d) - ("--<<-" . #Xe17e) - ("<<<-" . #Xe17f) - ("-<<<-" . #Xe180) - ("--<<<-" . #Xe181) - ("<--" . #Xe182) - ("-<--" . #Xe183) - ("--<--" . #Xe184) - ("<<--" . #Xe185) - ("-<<--" . #Xe186) - ("--<<--" . #Xe187) - ("<<<--" . #Xe188) - ("-<<<--" . #Xe189) - ("--<<<--" . #Xe18a) - ("-<" . #Xe18b) - ("--<" . #Xe18c) - ("-<<" . #Xe18d) - ("--<<" . #Xe18e) - ("-<<<" . #Xe18f) - ("--<<<" . #Xe190) - ("<=" . #Xe191) - ("=<=" . #Xe192) - ("==<=" . #Xe193) - ("<<=" . #Xe194) - ("=<<=" . #Xe195) - ("==<<=" . #Xe196) - ("<<<=" . #Xe197) - ("=<<<=" . #Xe198) - ("==<<<=" . #Xe199) - ("<==" . #Xe19a) - ("=<==" . #Xe19b) - ("==<==" . #Xe19c) - ("<<==" . #Xe19d) - ("=<<==" . #Xe19e) - ("==<<==" . #Xe19f) - ("<<<==" . #Xe1a0) - ("=<<<==" . #Xe1a1) - ("==<<<==" . #Xe1a2) - ("=<" . #Xe1a3) - ("==<" . #Xe1a4) - ("=<<" . #Xe1a5) - ("==<<" . #Xe1a6) - ("=<<<" . #Xe1a7) - ("==<<<" . #Xe1a8) - ;; Monadic operators - (">=>" . #Xe1a9) - (">->" . #Xe1aa) - (">-->" . #Xe1ab) - (">==>" . #Xe1ac) - ("<=<" . #Xe1ad) - ("<-<" . #Xe1ae) - ("<--<" . #Xe1af) - ("<==<" . #Xe1b0) - ;; Composition operators - (">>" . #Xe1b1) - (">>>" . #Xe1b2) - ("<<" . #Xe1b3) - ("<<<" . #Xe1b4) - ;; Lens operators - (":+" . #Xe1b5) - (":-" . #Xe1b6) - (":=" . #Xe1b7) - ("+:" . #Xe1b8) - ("-:" . #Xe1b9) - ("=:" . #Xe1ba) - ("=^" . #Xe1bb) - ("=+" . #Xe1bc) - ("=-" . #Xe1bd) - ("=*" . #Xe1be) - ("=/" . #Xe1bf) - ("=%" . #Xe1c0) - ("^=" . #Xe1c1) - ("+=" . #Xe1c2) - ("-=" . #Xe1c3) - ("*=" . #Xe1c4) - ("/=" . #Xe1c5) - ("%=" . #Xe1c6) - ;; Logical - ("/\\" . #Xe1c7) - ("\\/" . #Xe1c8) - ;; Semigroup/monoid operators - ("<>" . #Xe1c9) - ("<+" . #Xe1ca) - ("<+>" . #Xe1cb) - ("+>" . #Xe1cc)) diff --git a/.config/emacs/modules/ui/ligatures/+pragmata-pro.el b/.config/emacs/modules/ui/ligatures/+pragmata-pro.el @@ -1,259 +0,0 @@ -;;; ui/ligatures/+pragmata-pro.el -*- lexical-binding: t; -*- - -(+ligatures--def-font pragmata-pro - ("PragmataPro") - ;; Double-ended hyphen arrows - ("[INFO]" . #Xe2b0) - ("[WARN]" . #Xe2b1) - ("[PASS]" . #Xe2b2) - ("[VERBOSE]" . #Xe2b3) - ("[KO]" . #Xe2b4) - ("[OK]" . #Xe2b5) - ("[PASS]" . #Xe2b6) - ("[ERROR]" . #Xe2c0) - ("[DEBUG]" . #Xe2c1) - ("[INFO]" . #Xe2c2) - ("[WARN]" . #Xe2c3) - ("[WARNING]" . #Xe2c4) - ("[ERR]" . #Xe2c5) - ("[FATAL]" . #Xe2c6) - ("[TRACE]" . #Xe2c7) - ("[FIXME]" . #Xe2c8) - ("[TODO]" . #Xe2c9) - ("[BUG]" . #Xe2ca) - ("[NOTE]" . #Xe2cb) - ("[HACK]" . #Xe2cc) - ("[MARK]" . #Xe2cd) - ("[FAIL]" . #Xe2ce) - ("// ERROR" . #Xe2e0) - ("// DEBUG" . #Xe2e1) - ("// INFO" . #Xe2e2) - ("// WARN" . #Xe2e3) - ("// WARNING" . #Xe2e4) - ("// ERR" . #Xe2e5) - ("// FATAL" . #Xe2e6) - ("// TRACE" . #Xe2e7) - ("// FIXME" . #Xe2e8) - ("// TODO" . #Xe2e9) - ("// BUG" . #Xe2ea) - ("// NOTE" . #Xe2eb) - ("// HACK" . #Xe2ec) - ("// MARK" . #Xe2ed) - ("// FAIL" . #Xe2ee) - ("# ERROR" . #Xe2f0) - ("# DEBUG" . #Xe2f1) - ("# INFO" . #Xe2f2) - ("# WARN" . #Xe2f3) - ("# WARNING" . #Xe2f4) - ("# ERR" . #Xe2f5) - ("# FATAL" . #Xe2f6) - ("# TRACE" . #Xe2f7) - ("# FIXME" . #Xe2f8) - ("# TODO" . #Xe2f9) - ("# BUG" . #Xe2fa) - ("# NOTE" . #Xe2fb) - ("# HACK" . #Xe2fc) - ("# MARK" . #Xe2fd) - ("# FAIL" . #Xe2fe) - ("!=" . #Xe900) - ("!==" . #Xe901) - ("!≡" . #Xe902) - ("!≡≡" . #Xe903) - ("!=<" . #Xe904) - ("#(" . #Xe90c) - ("#_" . #Xe90d) - ("#{" . #Xe90e) - ("#?" . #Xe90f) - ("##" . #Xe910) - ("#_(" . #Xe911) - ("#[" . #Xe912) - ("%=" . #Xe920) - ("&%" . #Xe92c) - ("&&" . #Xe92d) - ("&+" . #Xe92e) - ("&-" . #Xe92f) - ("&/" . #Xe930) - ("&=" . #Xe931) - ("&&&" . #Xe932) - ("$>" . #Xe93a) - ("(|" . #Xe940) - ("*>" . #Xe946) - ("++" . #Xe94c) - ("+++" . #Xe94d) - ("+=" . #Xe94e) - ("+>" . #Xe94f) - ("++=" . #Xe950) - ("--" . #Xe960) - ("-<" . #Xe961) - ("-<<" . #Xe962) - ("-=" . #Xe963) - ("->" . #Xe964) - ("->>" . #Xe965) - ("---" . #Xe966) - ("-->" . #Xe967) - ("-+-" . #Xe968) - ("-\\/" . #Xe969) - ("-|>" . #Xe96a) - ("-<|" . #Xe96b) - ("->-" . #Xe96c) - ("-<-" . #Xe96d) - ("-|" . #Xe96e) - ("-||" . #Xe96f) - ("-|:" . #Xe970) - (".=" . #Xe979) - ("//=" . #Xe994) - ("/=" . #Xe995) - ("/==" . #Xe996) - ("/-\\" . #Xe997) - ("/-:" . #Xe998) - ("/->" . #Xe999) - ("/=>" . #Xe99a) - ("/-<" . #Xe99b) - ("/=<" . #Xe99c) - ("/=:" . #Xe99d) - (":=" . #Xe9ac) - (":≡" . #Xe9ad) - (":=>" . #Xe9ae) - (":-\\" . #Xe9af) - (":=\\" . #Xe9b0) - (":-/" . #Xe9b1) - (":=/" . #Xe9b2) - (":-|" . #Xe9b3) - (":=|" . #Xe9b4) - (":|-" . #Xe9b5) - (":|=" . #Xe9b6) - ("<$>" . #Xe9c0) - ("<*" . #Xe9c1) - ("<*>" . #Xe9c2) - ("<+>" . #Xe9c3) - ("<-" . #Xe9c4) - ("<<=" . #Xe9c5) - ("<=" . #Xe9c6) - ("<=>" . #Xe9c7) - ("<>" . #Xe9c8) - ("<|>" . #Xe9c9) - ("<<-" . #Xe9ca) - ("<|" . #Xe9cb) - ("<=<" . #Xe9cc) - ("<~" . #Xe9cd) - ("<~~" . #Xe9ce) - ("<<~" . #Xe9cf) - ("<$" . #Xe9d0) - ("<+" . #Xe9d1) - ("<!>" . #Xe9d2) - ("<@>" . #Xe9d3) - ("<#>" . #Xe9d4) - ("<%>" . #Xe9d5) - ("<^>" . #Xe9d6) - ("<&>" . #Xe9d7) - ("<?>" . #Xe9d8) - ("<.>" . #Xe9d9) - ("</>" . #Xe9da) - ("<\\>" . #Xe9db) - ("<\">" . #Xe9dc) - ("<:>" . #Xe9dd) - ("<~>" . #Xe9de) - ("<**>" . #Xe9df) - ("<<^" . #Xe9e0) - ("<=" . #Xe9e1) - ("<->" . #Xe9e2) - ("<!--" . #Xe9e3) - ("<--" . #Xe9e4) - ("<~<" . #Xe9e5) - ("<==>" . #Xe9e6) - ("<|-" . #Xe9e7) - ("<||" . #Xe9e8) - ("<<|" . #Xe9e9) - ("<-<" . #Xe9ea) - ("<-->" . #Xe9eb) - ("<<==" . #Xe9ec) - ("<==" . #Xe9ed) - ("<-\\" . #Xe9ee) - ("<-/" . #Xe9ef) - ("<=\\" . #Xe9f0) - ("<=/" . #Xe9f1) - ("=<<" . #Xea00) - ("==" . #Xea01) - ("===" . #Xea02) - ("==>" . #Xea03) - ("=>" . #Xea04) - ("=~" . #Xea05) - ("=>>" . #Xea06) - ("=~=" . #Xea07) - ("==>>" . #Xea08) - ("=>=" . #Xea09) - ("=<=" . #Xea0a) - ("=<" . #Xea0b) - ("==<" . #Xea0c) - ("=<|" . #Xea0d) - ("=/" . #Xea0e) - ("=/=" . #Xea0f) - ("=/<" . #Xea10) - ("=|" . #Xea11) - ("=||" . #Xea12) - ("=|:" . #Xea13) - (">-" . #Xea20) - (">=" . #Xea21) - (">>-" . #Xea22) - (">>=" . #Xea23) - (">=>" . #Xea24) - (">>^" . #Xea25) - (">>|" . #Xea26) - (">!=" . #Xea27) - (">->" . #Xea28) - (">==" . #Xea29) - (">=" . #Xea2a) - (">/=" . #Xea2b) - (">-|" . #Xea2c) - (">=|" . #Xea2d) - (">-\\" . #Xea2e) - (">=\\" . #Xea2f) - (">-/" . #Xea30) - (">=/" . #Xea31) - (">λ=" . #Xea32) - ("?." . #Xea3f) - ("^=" . #Xea43) - ("^^" . #Xea44) - ("^<<" . #Xea48) - ("^>>" . #Xea49) - ("\\=" . #Xea54) - ("\\==" . #Xea55) - ("\\/-" . #Xea56) - ("\\-/" . #Xea57) - ("\\-:" . #Xea58) - ("\\->" . #Xea59) - ("\\=>" . #Xea5a) - ("\\-<" . #Xea5b) - ("\\=<" . #Xea5c) - ("\\=:" . #Xea5d) - ("|=" . #Xea69) - ("|>=" . #Xea6a) - ("|>" . #Xea6b) - ("|+|" . #Xea6c) - ("|->" . #Xea6d) - ("|-->" . #Xea6e) - ("|=>" . #Xea6f) - ("|==>" . #Xea70) - ("|>-" . #Xea71) - ("|<<" . #Xea72) - ("||>" . #Xea73) - ("|>>" . #Xea74) - ("|-" . #Xea75) - ("||-" . #Xea76) - ("||=" . #Xea77) - ("|)" . #Xea78) - ("|]" . #Xea79) - ("|-:" . #Xea7a) - ("|=:" . #Xea7b) - ("|-<" . #Xea7c) - ("|=<" . #Xea7d) - ("|--<" . #Xea7e) - ("|==<" . #Xea7f) - ("~=" . #Xea8a) - ("~>" . #Xea8b) - ("~~>" . #Xea8c) - ("~>>" . #Xea8d) - ("[[" . #Xea8f) - ("[|" . #Xea90) - ("_|_" . #Xea97) - ("]]" . #Xeaa0)) diff --git a/.config/emacs/modules/ui/ligatures/README.org b/.config/emacs/modules/ui/ligatures/README.org @@ -1,238 +0,0 @@ -#+title: :ui ligatures -#+subtitle: Distract folks from your code -#+created: June 16, 2018 -#+since: 21.12.0 - -* Description :unfold: -This module enables ligatures and arbitrary symbol substitutions with -~mac-auto-operator-composition-mode~ (on supported macOS systems) or composition -tables (harfbuzz on Emacs 28), falling back on ~prettify-symbols-mode~ -otherwise. - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +extra :: - Enables extra symbol substitutions in certain modes, for example ~lambda~ in - lisps are replaced with ~λ~. -- +fira :: - Enable =Fira Code= ligatures. This requires Fira Code Symbol and [[id:a7e7402b-e202-4860-878b-d1933cff1d16][a patched - version of Fira Code]]. -- +hasklig :: - Enable =Hasklig= ligatures. This requires [[id:a7e7402b-e202-4860-878b-d1933cff1d16][a patched version of the HaskLig - font]]. -- +iosevka :: - Enable =Iosevka= ligatures. This requires [[id:a7e7402b-e202-4860-878b-d1933cff1d16][a patched version of the Iosevka - font]]. -- +pragmata-pro :: - Enable =Pragmata Pro= ligatures. This requires the [[https://www.fsd.it/shop/fonts/pragmatapro/][Pragmata Pro font]]. - -#+begin_quote - 🚧 Font flags are ignored _if_ you're sporting either a) Emacs 28+ with - Harfbuzz support (which can compose ligatures natively), or b) Mitsuharu's - =emacs-mac= build on macOS (which uses - ~mac-auto-operator-composition-mode~). -#+end_quote - -** Packages -/This module doesn't install any packages./ - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires one of three setups for ligatures to work: - -- A recent enough version of Emacs which will compose ligatures automatically - (Emacs 28 with Harfbuzz support), or -- Mitsuharu's =emacs-mac= build on macOS (available on Homebrew), or -- A patched font for Doom's fallback ligature support. - -** Mutsuharu's emacs-mac port or Emacs 28+ with Harfbuzz support -Ligatures should be handled without any additional configuration. - -** Not Emacs-mac and Emacs <= 27 -:PROPERTIES: -:ID: a7e7402b-e202-4860-878b-d1933cff1d16 -:END: -1. Enable one of the four ligature font flags: =+fira=, =+hasklig=, =+iosevka= - or =+pragmata-pro=. -2. Install the patched version of the associated font with ~M-x - +ligatures/install-patched-font~. Note: Pragmata Pro cannot be installed this - way because it is a non-free font and must be purchased and installed - manually. - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** TODO Mathematical symbols replacement - -** Coding ligatures -This module includes configuration to compose combinations like =->= or =::= -into prettier glyphs (called a ligature). Depending on the current version of -emacs, this is implemented in two different ways : - -- prettify-symbols-mode method :: this is the "legacy" method. It uses a font - which haves the ligatures as separate unicode symbols, and using - prettify-symbols-mode, =->=-like combinations are manually listed and replaced - with the correct symbol. The mapping between =->=-like sequences and unicode - values in the font are font-specific ; therefore [[doom-module:+fira]], [[doom-module:+iosevka]]... files and - specific fonts are necessary for it to work. -- composition-function-table method :: regexps are used to match all the usual - sequences which are composed into ligatures. These regexps are passed to emacs - directly, which asks Harfbuzz to shape it. Ligatures are obtained - automatically depending on the capabilities of the font, and no font-specific - configuration is necessary. - -Emacs-mac port implements the /composition-function-table/ method in [[https://bitbucket.org/mituharu/emacs-mac/src/26c8fd9920db9d34ae8f78bceaec714230824dac/lisp/term/mac-win.el?at=master#lines-345:805][its code]], -nothing is necessary on Doom side; otherwise, Doom implements the -/composition-function-table/ for emacs 28+ built with Harfbuzz support, and the -/prettify-symbols-mode/ method otherwise. - -Even though harfbuzz has been included in emacs 27, there is currently a [[https://lists.gnu.org/archive/html/bug-gnu-emacs/2020-04/msg01121.html][bug -(#40864)]] which prevents a safe usage of /composition-function-table/ method in -emacs 27. - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** Setting ligatures -If you want to set ligatures for modules that don't have them by default you can -use the ~set-ligatures!~ macro: -#+begin_src emacs-lisp -;; in $DOOMDIR/config.el -(after! PACKAGE - (set-ligatures! 'MAJOR-MODE - :symbol "keyword")) -#+end_src - -E.g. -#+begin_src emacs-lisp -(after! go-mode ; in this case the major mode and package named the same thing - (set-ligatures! 'go-mode - :def "func" ; function keyword - :true "true" :false "false" - ; this will replace not only definitions - ; but coresponding functions aswell - :int "int" :str "string" - :float "float" :bool "bool" - :for "for" - :return "return" :yeild "yeild")) -#+end_src - -You can set these symbols out of the box: -#+begin_src emacs-lisp -(set-ligatures! 'MAJOR-MODE - ;; Functional - :lambda "lambda keyword" - :def "function keyword" - :composition "composition" - :map "map/dictionary keyword" - ;; Types - :null "null type" - :true "true keyword" - :false "false keyword" - :int "int keyword" - :float "float keyword" - :str "string keyword" - :bool "boolean keywork" - :list "list keyword" - ;; Flow - :not "not operator" - :in "in operator" - :not-in "not in operator" - :and "and keyword" - :or "or keyword" - :for "for keyword" - :some "some keyword" - :return "return" - :yield "yeild" - ;; Other - :union "Union keyword" - :intersect "Intersect keyword" - :diff "diff keyword" - :tuple "Tuple Keyword " - :pipe "Pipe Keyword" ;; FIXME: find a non-private char - :dot "Dot operator") -#+end_src - -If you have multiple versions of the same keyword you can set the symbol twice: -#+begin_src emacs-lisp -(set-ligatures! scala-mode - :null "none" - :null "None") -#+end_src - -** Changing ligatures -if you don't like the symbols chosen you can change them by using: -#+begin_src emacs-lisp -;; you don't need to include all of them you can pick and mix -(plist-put! +ligatures-extra-symbols - ;; org - :name "»" - :src_block "»" - :src_block_end "«" - :quote "“" - :quote_end "”" - ;; Functional - :lambda "λ" - :def "ƒ" - :composition "∘" - :map "↦" - ;; Types - :null "∅" - :true "𝕋" - :false "𝔽" - :int "ℤ" - :float "ℝ" - :str "𝕊" - :bool "𝔹" - :list "𝕃" - ;; Flow - :not "¬" - :in "∈" - :not-in "∉" - :and "∧" - :or "∨" - :for "∀" - :some "∃" - :return "⟼" - :yield "⟻" - ;; Other - :union "⋃" - :intersect "∩" - :diff "∖" - :tuple "⨂" - :pipe "" ;; FIXME: find a non-private char - :dot "•") ;; you could also add your own if you want -#+end_src - -* Troubleshooting -[[doom-report:][Report an issue?]] - -** Some symbols are not rendering correctly -This can usually be fixed by doing one of the following: - -- Make sure Symbola (the font) is installed on your system. -- Otherwise, change [[var:doom-unicode-font]] (set to Symbola by default). -- Disable the [[doom-module::ui unicode]] module. It not only overrides [[var:doom-unicode-font]], but - should only be used as a last resort. - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/ui/ligatures/autoload/install.el b/.config/emacs/modules/ui/ligatures/autoload/install.el @@ -1,58 +0,0 @@ -;;; ui/ligatures/autoload/install.el -*- lexical-binding: t; -*- -;;;###if (or (modulep! +fira) (modulep! +hasklig) (modulep! +iosevka)) - -(defun +ligatures--install-font (prefix name url-format fonts-alist &optional extra-fonts) - "Install fonts to the local system. - -If PREFIX is nil, will prompt whether or not to download. NAME is informational -only. URL-FORMAT is a format string that should be a url and have a single %s, -which is expanded for each font in FONTS-ALIST. FONTS-ALIST should be the -filename of each font. It is used as the source and destination filename." - (unless (or prefix - (yes-or-no-p - (format "This will download and install the %s fonts, continue?" - name))) - (user-error "Aborted")) - (let* ((font-dest - (cond (IS-LINUX - (expand-file-name - "fonts/" (or (getenv "XDG_DATA_HOME") - "~/.local/share"))) - (IS-MAC - (expand-file-name "~/Library/Fonts/")))) - (known-dest-p (stringp font-dest)) - (font-dest (or font-dest (read-directory-name "Font installation directory: " "~/")))) - (unless (file-directory-p font-dest) - (mkdir font-dest t)) - (dolist (font fonts-alist) - (url-copy-file (format url-format font) - (expand-file-name font font-dest) - t)) - (when known-dest-p - (message "Font downloaded, updating font cache... <fc-cache -f -v> ") - (shell-command-to-string "fc-cache -f -v")) - (if IS-WINDOWS - (when (y-or-n-p "The %S font was downloaded, but Windows users must install them manually.\n\nShow files in windows explorer?") - (call-process "explorer.exe" nil nil nil font-dest)) - (message "Successfully %s %S fonts to %S!" - (if known-dest-p "installed" "downloaded") - name font-dest)))) - -;;;###autoload -(defun +ligatures/install-patched-font (font-id &optional arg) - "Install the font FONT-ID on your system. -FONT-ID must be a key from `+ligatures--font-alist'. -If PREFIX is non-nil, don't ask for confirmation and install it." - (interactive - (list - (car (cl-find (completing-read - "Install font: " - (mapcar #'cadr +ligatures--font-alist)) - +ligatures--font-alist - :key #'cadr - :test #'equal)) - current-prefix-arg)) - (cl-destructuring-bind (font-name &key _range url files) - (or (alist-get font-id +ligatures--font-alist) - (user-error "%S is not a valid font" font-id)) - (+ligatures--install-font arg font-name url files))) diff --git a/.config/emacs/modules/ui/ligatures/autoload/ligatures.el b/.config/emacs/modules/ui/ligatures/autoload/ligatures.el @@ -1,50 +0,0 @@ -;;; ui/ligatures/autoload/ligatures.el -*- lexical-binding: t; -*- - -;; DEPRECATED -;;;###autodef -(define-obsolete-function-alias 'set-pretty-symbols! 'set-ligatures! "3.0.0") - -;;;###autodef -(defun set-ligatures! (modes &rest plist) - "Associates string patterns with icons in certain major-modes. - - MODES is a major mode symbol or a list of them. - PLIST is a property list whose keys must match keys in -`+ligatures-extra-symbols', and whose values are strings representing the text -to be replaced with that symbol. If the car of PLIST is nil, then unset any -pretty symbols previously defined for MODES. - -This function accepts one special property: - - :alist ALIST - Appends ALIST to `prettify-symbols-alist' literally, without mapping text to - `+ligatures-extra-symbols'. - -For example, the rule for emacs-lisp-mode is very simple: - - (set-ligatures! 'emacs-lisp-mode - :lambda \"lambda\") - -This will replace any instances of \"lambda\" in emacs-lisp-mode with the symbol -assicated with :lambda in `+ligatures-extra-symbols'. - -Pretty symbols can be unset for emacs-lisp-mode with: - - (set-ligatures! 'emacs-lisp-mode nil)" - (declare (indent defun)) - (if (null (car-safe plist)) - (dolist (mode (ensure-list modes)) - (delq! mode +ligatures-extra-alist 'assq)) - (let (results) - (while plist - (let ((key (pop plist))) - (if (eq key :alist) - (prependq! results (pop plist)) - (when-let (char (plist-get +ligatures-extra-symbols key)) - (push (cons (pop plist) char) results))))) - (dolist (mode (ensure-list modes)) - (setf (alist-get mode +ligatures-extra-alist) - (if-let (old-results (alist-get mode +ligatures-extra-alist)) - (dolist (cell results old-results) - (setf (alist-get (car cell) old-results) (cdr cell))) - results)))))) diff --git a/.config/emacs/modules/ui/ligatures/config.el b/.config/emacs/modules/ui/ligatures/config.el @@ -1,220 +0,0 @@ -;;; ui/ligatures/config.el -*- lexical-binding: t; -*- - -(defvar +ligatures-extra-symbols - '(;; org - :name "»" - :src_block "»" - :src_block_end "«" - :quote "“" - :quote_end "”" - ;; Functional - :lambda "λ" - :def "ƒ" - :composition "∘" - :map "↦" - ;; Types - :null "∅" - :true "𝕋" - :false "𝔽" - :int "ℤ" - :float "ℝ" - :str "𝕊" - :bool "𝔹" - :list "𝕃" - ;; Flow - :not "¬" - :in "∈" - :not-in "∉" - :and "∧" - :or "∨" - :for "∀" - :some "∃" - :return "⟼" - :yield "⟻" - ;; Other - :union "⋃" - :intersect "∩" - :diff "∖" - :tuple "⨂" - :pipe "" ;; FIXME: find a non-private char - :dot "•") - "Maps identifiers to symbols, recognized by `set-ligatures'. - -This should not contain any symbols from the Unicode Private Area! There is no -universal way of getting the correct symbol as that area varies from font to -font.") - -(defvar +ligatures-extra-alist '((t)) - "A map of major modes to symbol lists (for `prettify-symbols-alist').") - -(defvar +ligatures-composition-alist - '((?! . "\\(?:!\\(?:==\\|[!=]\\)\\)") ; (regexp-opt '("!!" "!=" "!==")) - (?# . "\\(?:#\\(?:###?\\|_(\\|[#(:=?[_{]\\)\\)") ; (regexp-opt '("##" "###" "####" "#(" "#:" "#=" "#?" "#[" "#_" "#_(" "#{")) - (?$ . "\\(?:\\$>>?\\)") ; (regexp-opt '("$>" "$>>")) - (?% . "\\(?:%%%?\\)") ; (regexp-opt '("%%" "%%%")) - (?& . "\\(?:&&&?\\)") ; (regexp-opt '("&&" "&&&")) - (?* . "\\(?:\\*\\(?:\\*[*/]\\|[)*/>]\\)?\\)") ; (regexp-opt '("*" "**" "***" "**/" "*/" "*>" "*)")) - (?+ . "\\(?:\\+\\(?:\\+\\+\\|[+:>]\\)?\\)") ; (regexp-opt '("+" "++" "+++" "+>" "+:")) - (?- . "\\(?:-\\(?:-\\(?:->\\|[>-]\\)\\|<[<-]\\|>[>-]\\|[:<>|}~-]\\)\\)") ; (regexp-opt '("--" "---" "-->" "--->" "->-" "-<" "-<-" "-<<" "->" "->>" "-}" "-~" "-:" "-|")) - (?. . "\\(?:\\.\\(?:\\.[.<]\\|[.=>-]\\)\\)") ; (regexp-opt '(".-" ".." "..." "..<" ".=" ".>")) - (?/ . "\\(?:/\\(?:\\*\\*\\|//\\|==\\|[*/=>]\\)\\)") ; (regexp-opt '("/*" "/**" "//" "///" "/=" "/==" "/>")) - (?: . "\\(?::\\(?:::\\|[+:<=>]\\)?\\)") ; (regexp-opt '(":" "::" ":::" ":=" ":<" ":=" ":>" ":+")) - (?\; . ";;") ; (regexp-opt '(";;")) - (?0 . "0\\(?:\\(x[a-fA-F0-9]\\).?\\)") ; Tries to match the x in 0xDEADBEEF - ;; (?x . "x") ; Also tries to match the x in 0xDEADBEEF - ;; (regexp-opt '("<!--" "<$" "<$>" "<*" "<*>" "<**>" "<+" "<+>" "<-" "<--" "<---" "<->" "<-->" "<--->" "</" "</>" "<<" "<<-" "<<<" "<<=" "<=" "<=<" "<==" "<=>" "<===>" "<>" "<|" "<|>" "<~" "<~~" "<." "<.>" "<..>")) - (?< . "\\(?:<\\(?:!--\\|\\$>\\|\\*\\(?:\\*?>\\)\\|\\+>\\|-\\(?:-\\(?:->\\|[>-]\\)\\|[>-]\\)\\|\\.\\(?:\\.?>\\)\\|/>\\|<[<=-]\\|=\\(?:==>\\|[<=>]\\)\\||>\\|~~\\|[$*+./<=>|~-]\\)\\)") - (?= . "\\(?:=\\(?:/=\\|:=\\|<[<=]\\|=[=>]\\|>[=>]\\|[=>]\\)\\)") ; (regexp-opt '("=/=" "=:=" "=<<" "==" "===" "==>" "=>" "=>>" "=>=" "=<=")) - (?> . "\\(?:>\\(?:->\\|=>\\|>[=>-]\\|[:=>-]\\)\\)") ; (regexp-opt '(">-" ">->" ">:" ">=" ">=>" ">>" ">>-" ">>=" ">>>")) - (?? . "\\(?:\\?[.:=?]\\)") ; (regexp-opt '("??" "?." "?:" "?=")) - (?\[ . "\\(?:\\[\\(?:|]\\|[]|]\\)\\)") ; (regexp-opt '("[]" "[|]" "[|")) - (?\\ . "\\(?:\\\\\\\\[\\n]?\\)") ; (regexp-opt '("\\\\" "\\\\\\" "\\\\n")) - (?^ . "\\(?:\\^==?\\)") ; (regexp-opt '("^=" "^==")) - (?w . "\\(?:wwww?\\)") ; (regexp-opt '("www" "wwww")) - (?{ . "\\(?:{\\(?:|\\(?:|}\\|[|}]\\)\\|[|-]\\)\\)") ; (regexp-opt '("{-" "{|" "{||" "{|}" "{||}")) - (?| . "\\(?:|\\(?:->\\|=>\\||=\\|[]=>|}-]\\)\\)") ; (regexp-opt '("|=" "|>" "||" "||=" "|->" "|=>" "|]" "|}" "|-")) - (?_ . "\\(?:_\\(?:|?_\\)\\)") ; (regexp-opt '("_|_" "__")) - (?\( . "\\(?:(\\*\\)") ; (regexp-opt '("(*")) - (?~ . "\\(?:~\\(?:~>\\|[=>@~-]\\)\\)")) ; (regexp-opt '("~-" "~=" "~>" "~@" "~~" "~~>")) - "An alist of all ligatures used by `+ligatures-extras-in-modes'. - -The car is the character ASCII number, cdr is a regex which will call -`font-shape-gstring' when matched. - -Because of the underlying code in :ui ligatures module, the regex should match a -string starting with the character contained in car. - -This variable is used only if you built Emacs with Harfbuzz on a version >= 28") - -(defvar +ligatures-in-modes - '(not special-mode comint-mode eshell-mode term-mode vterm-mode Info-mode - elfeed-search-mode elfeed-show-mode) - "List of major modes where ligatures should be enabled. - - If t, enable it everywhere (except `fundamental-mode'). - If the first element is 'not, enable it in any mode besides what is listed. - If nil, don't enable ligatures anywhere.") - -(defvar +ligatures-extras-in-modes t - "List of major modes where extra ligatures should be enabled. - -Extra ligatures are mode-specific substituions, defined in -`+ligatures-extra-symbols' and assigned with `set-ligatures!'. This variable -controls where these are enabled. - - If t, enable it everywhere (except `fundamental-mode'). - If the first element is 'not, enable it in any mode besides what is listed. - If nil, don't enable these extra ligatures anywhere (though it's more -efficient to remove the `+extra' flag from the :ui ligatures module instead).") - -(defvar +ligatures--init-font-hook nil) - -(defun +ligatures--correct-symbol-bounds (ligature-alist) - "Prepend non-breaking spaces to a ligature. - -This way `compose-region' (called by `prettify-symbols-mode') will use the -correct width of the symbols instead of the width measured by `char-width'." - (let ((len (length (car ligature-alist))) - (acc (list (cdr ligature-alist)))) - (while (> len 1) - (setq acc (cons #X00a0 (cons '(Br . Bl) acc)) - len (1- len))) - (cons (car ligature-alist) acc))) - -(defun +ligatures--enable-p (modes) - "Return t if ligatures should be enabled in this buffer depending on MODES." - (unless (eq major-mode 'fundamental-mode) - (or (eq modes t) - (if (eq (car modes) 'not) - (not (apply #'derived-mode-p (cdr modes))) - (apply #'derived-mode-p modes))))) - -(defun +ligatures-init-buffer-h () - "Set up ligatures for the current buffer. - -Extra ligatures are mode-specific substituions, defined in -`+ligatures-extra-symbols', assigned with `set-ligatures!', and made possible -with `prettify-symbols-mode'. This variable controls where these are enabled. -See `+ligatures-extras-in-modes' to control what major modes this function can -and cannot run in." - (when after-init-time - (let ((in-mode-p - (+ligatures--enable-p +ligatures-in-modes)) - (in-mode-extras-p - (and (modulep! +extra) - (+ligatures--enable-p +ligatures-extras-in-modes)))) - (when in-mode-p - (if (boundp '+ligature--composition-table) - (setq-local composition-function-table +ligature--composition-table) - (run-hooks '+ligatures--init-font-hook) - (setq +ligatures--init-font-hook nil))) - (when in-mode-extras-p - (prependq! prettify-symbols-alist - (alist-get major-mode +ligatures-extra-alist))) - (when (and (or in-mode-p in-mode-extras-p) - prettify-symbols-alist) - (when prettify-symbols-mode - (prettify-symbols-mode -1)) - (prettify-symbols-mode +1))))) - - -;; -;;; Bootstrap - -;;;###package prettify-symbols -;; When you get to the right edge, it goes back to how it normally prints -(setq prettify-symbols-unprettify-at-point 'right-edge) - -(add-hook! 'doom-init-ui-hook :append - (defun +ligatures-init-h () - (add-hook 'after-change-major-mode-hook #'+ligatures-init-buffer-h))) - -(cond - ;; The emacs-mac build of Emacs appears to have built-in support for ligatures, - ;; using the same composition-function-table method - ;; https://bitbucket.org/mituharu/emacs-mac/src/26c8fd9920db9d34ae8f78bceaec714230824dac/lisp/term/mac-win.el?at=master#lines-345:805 - ;; so use that instead if this module is enabled. - ((and IS-MAC (fboundp 'mac-auto-operator-composition-mode)) - (add-hook 'doom-init-ui-hook #'mac-auto-operator-composition-mode 'append)) - - ;; Harfbuzz and Mac builds do not need font-specific ligature support - ;; if they are above emacs-27. - ((and (> emacs-major-version 27) - (or (featurep 'ns) - (string-match-p "HARFBUZZ" system-configuration-features)) - (featurep 'composite)) ; Emacs loads `composite' at startup - (defvar +ligature--composition-table (make-char-table nil)) - (add-hook! 'doom-init-ui-hook :append - (defun +ligature-init-composition-table-h () - (dolist (char-regexp +ligatures-composition-alist) - (set-char-table-range - +ligature--composition-table - (car char-regexp) `([,(cdr char-regexp) 0 font-shape-gstring]))) - (set-char-table-parent +ligature--composition-table composition-function-table)))) - - ;; Fallback ligature support for certain, patched fonts. Install them with - ;; `+ligatures/install-patched-font' - ((defmacro +ligatures--def-font (id font-plist &rest alist) - (declare (indent 2)) - (let ((alist-var (intern (format "+ligatures-%s-font-alist" id))) - (setup-fn (intern (format "+ligatures-init-%s-font-h" id)))) - `(progn - (setf (alist-get ',id +ligatures--font-alist) (list ,@font-plist)) - (defvar ,alist-var ',alist ,(format "Name of the %s ligature font." id)) - (defun ,setup-fn (&rest _) - (cl-destructuring-bind (name &key _url files range) - (or (alist-get ',id +ligatures--font-alist) - (error "No ligature font called %s" ',id)) - (when range - (set-fontset-font t range name nil 'prepend)) - (setq-default prettify-symbols-alist - (append (default-value 'prettify-symbols-alist) - (mapcar #'+ligatures--correct-symbol-bounds ,alist-var))))) - (add-hook '+ligatures--init-font-hook #',setup-fn)))) - - (defvar +ligatures--font-alist ()) - - (cond ((modulep! +fira) (load! "+fira")) - ((modulep! +iosevka) (load! "+iosevka")) - ((modulep! +hasklig) (load! "+hasklig")) - ((modulep! +pragmata-pro) (load! "+pragmata-pro"))))) diff --git a/.config/emacs/modules/ui/minimap/README.org b/.config/emacs/modules/ui/minimap/README.org @@ -1,59 +0,0 @@ -#+title: :ui minimap -#+subtitle: A map for lost programmers -#+created: May 08, 2020 -#+since: 21.12.0 - -* Description :unfold: -This module displays a minimap of the buffer in a sidebar, similar to the -feature found in many other editors. - -** Maintainers -- [[doom-user:][@rushsteve1]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:minimap]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -A minimap which provides an overview of the current buffer to the side, -displaying the currently visible region and the current line. You can left-click -and drag to scroll along the buffer, or right-click anywhere to jump to there. - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -There are a number of options provided by the =minimap.el= package this module -is based on. The easiest way to see all of them is [[kbd:][SPC h v minimap]]. - -* Troubleshooting -[[doom-report:][Report an issue?]] - -** Scrolling is slow/laggy -Disable the minimap using [[kbd:][SPC t m]]. - -** TODO Minimap doesn't close when disabled - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/ui/minimap/config.el b/.config/emacs/modules/ui/minimap/config.el @@ -1,10 +0,0 @@ -;;; ui/minimap/config.el -*- lexical-binding: t; -*- - -(use-package! minimap - :defer t - :config - (setq minimap-window-location 'right - minimap-update-delay 0 - minimap-width-fraction 0.09 - minimap-minimum-width 15) - (pushnew! minimap-major-modes 'text-mode 'conf-mode)) diff --git a/.config/emacs/modules/ui/minimap/packages.el b/.config/emacs/modules/ui/minimap/packages.el @@ -1,4 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; ui/minimap/packages.el - -(package! minimap :pin "ed7490652a676c0510ed57d5366c445de20a370b") diff --git a/.config/emacs/modules/ui/modeline/+light.el b/.config/emacs/modules/ui/modeline/+light.el @@ -1,613 +0,0 @@ -;;; ui/modeline/+default.el -*- lexical-binding: t; -*- - -;; This is a slimmed down version of `doom-modeline' that manipulates -;; `mode-line-format' directly. Its purpose is to be truer to the original goal -;; of Doom's modeline: to be more performant and minimalistic alternative to -;; other modeline packages and to be abstraction-light. Too much abstraction is -;; too much magic. -;; -;; Warning: this is still a WIP! - -(defun +modeline--set-var-and-refresh-bars-fn (&optional symbol value) - (when symbol - (set-default symbol value)) - (when (fboundp '+modeline-refresh-bars-h) - (+modeline-refresh-bars-h))) - - -;; -;;; Variables - -(defcustom +modeline-height 31 - "The height of the modeline. - -This is enforced by the xpm bitmap bar in `+modeline-bar'. Without it (and in -the terminal), this variable does nothing. - -Use `setq!' to adjust this variable live, as it will trigger an refresh of the -bars in the modeline. `setq' will not." - :type 'integer - :set #'+modeline--set-var-and-refresh-bars-fn) - -(defcustom +modeline-bar-width 3 - "The width of the bar in the modeline. - -If nil, the bar will be made transparent and 1 pixel wide, as to be invisible, -but without sacrificing its ability to enforce `+modeline-height'. - -Use `setq!' to adjust this variable live, as it will trigger an refresh of the -bars in the modeline. `setq' will not." - :type 'integer - :set #'+modeline--set-var-and-refresh-bars-fn) - -(defvar +modeline-format-alist () - "An alist of modeline formats defined with `def-modeline!'. - -Each entry's CAR is the name and CDR is a cons cell whose CAR is the left-hand -side of the modeline, and whose CDR is the right-hand side.") - - -;; -;;; Faces - -(defface doom-modeline-bar '((t (:inherit highlight))) - "Face used for left-most bar on the mode-line of an active window.") - -(defface doom-modeline-bar-inactive '((t (:inherit mode-line-inactive))) - "Face used for left-most bar on the mode-line of an inactive window.") - -(defface doom-modeline-highlight - '((t (:inherit mode-line-highlight))) - "Face used for highlighted modeline panels (like search counts).") - -(defface doom-modeline-alternate-highlight - '((t (:inherit mode-line-highlight))) - "Alternative face used for highlighted modeline panels (like search counts).") - - -;; -;;; Helpers - -;;; `active' -(defvar +modeline--active-window (selected-window)) - -(defun +modeline-active () - "Return non-nil if the selected window has an active modeline." - (eq (selected-window) +modeline--active-window)) - -(add-hook! 'pre-redisplay-functions - (defun +modeline-set-selected-window-h (&rest _) - "Track the active modeline's window in `+modeline--active-window'." - (let ((win (selected-window))) - (unless (minibuffer-window-active-p win) - (setq +modeline--active-window (frame-selected-window)))))) - -(defun +modeline--make-xpm (color width height) - "Create an XPM bitmap via COLOR, WIDTH and HEIGHT. Inspired by `powerline''s `pl/+modeline--make-xpm'." - (propertize - " " 'display - (let ((data (make-list height (make-list width 1))) - (color (or color "None"))) - (ignore-errors - (create-image - (concat - (format "/* XPM */\nstatic char * percent[] = {\n\"%i %i 2 1\",\n\". c %s\",\n\" c %s\"," - (length (car data)) - (length data) - color - color) - (apply #'concat - (cl-loop with idx = 0 - with len = (length data) - for dl in data - do (cl-incf idx) - collect - (concat "\"" - (cl-loop for d in dl - if (= d 0) collect (string-to-char " ") - else collect (string-to-char ".")) - (if (eq idx len) "\"};" "\",\n"))))) - 'xpm t :ascent 'center))))) - -(defun +modeline-format-icon (icon-set icon label &optional face help-echo voffset) - "Build from ICON-SET the ICON with LABEL. -Using optionals attributes FACE, HELP-ECHO and VOFFSET." - (let ((icon-set-fn (pcase icon-set - ('octicon #'all-the-icons-octicon) - ('faicon #'all-the-icons-faicon) - ('material #'all-the-icons-material) - ('alltheicon #'all-the-icons-alltheicon) - ('fileicon #'all-the-icons-fileicon)))) - (propertize (concat (funcall icon-set-fn - icon - :face face - :height 1.1 - :v-adjust (or voffset -0.225)) - (propertize label 'face face)) - 'help-echo help-echo))) - -(defun set-modeline! (name &optional default) - "Set the modeline to NAME. -If DEFAULT is non-nil, apply to all future buffers. Modelines are defined with -`def-modeline!'." - (if-let (format (assq name +modeline-format-alist)) - (cl-destructuring-bind (lhs . rhs) (cdr format) - (if default - (setq-default +modeline-format-left lhs - +modeline-format-right rhs) - (setq +modeline-format-left lhs - +modeline-format-right rhs))) - (error "Could not find %S modeline format" name))) - -(defun set-modeline-hook! (hooks name) - "Set the modeline to NAME on HOOKS. -See `def-modeline!' on how modelines are defined." - (let ((fn (intern (format "+modeline-set-%s-format-h" name)))) - (dolist (hook (ensure-list hooks)) - (when after-init-time - (dolist (name (mapcar #'car +modeline-format-alist)) - (remove-hook hook (intern (format "+modeline-set-%s-format-h" name))))) - (add-hook hook fn)))) - -(defun def-modeline! (name lhs rhs) - "Define a modeline format by NAME. -LHS and RHS are the formats representing the left and right hand side of the -mode-line, respectively. See the variable `format-mode-line' for details on what -LHS and RHS will accept." - (setf (alist-get name +modeline-format-alist) - (cons lhs rhs)) - (fset (intern (format "+modeline-set-%s-format-h" name)) - (lambda (&rest _) (set-modeline! name)))) - -(defmacro def-modeline-var! (name body &optional docstring &rest plist) - "Define a modeline segment variable." - (unless (stringp docstring) - (push docstring plist) - (setq docstring nil)) - `(progn - (defconst ,name ,body ,docstring) - ,@(if (plist-get plist :local) `((make-variable-buffer-local ',name))) - (put ',name 'risky-local-variable t))) - - -;; -;;; Segments - -(def-modeline-var! +modeline-format-left nil - "The left-hand side of the modeline." - :local t) - -(def-modeline-var! +modeline-format-right nil - "The right-hand side of the modeline." - :local t) - - -;;; `+modeline-bar' -(def-modeline-var! +modeline-bar "") - -(defvar +modeline-active-bar "") -(defvar +modeline-inactive-bar "") - -(add-hook! '(doom-init-ui-hook doom-load-theme-hook) :append - (defun +modeline-refresh-bars-h () - (let ((width (or +modeline-bar-width 1)) - (height (max +modeline-height 0)) - (active-bg (face-background 'doom-modeline-bar nil t)) - (inactive-bg (face-background 'doom-modeline-bar-inactive nil t))) - (when (or (null +modeline-bar-width) - (= +modeline-bar-width 0)) - (setq active-bg nil - inactive-bg nil)) - (setq +modeline-active-bar - (+modeline--make-xpm (and +modeline-bar-width active-bg) - width height) - +modeline-inactive-bar - (+modeline--make-xpm (and +modeline-bar-width inactive-bg) - width height) - +modeline-bar - '(:eval (if (+modeline-active) - +modeline-active-bar - +modeline-inactive-bar)))))) - -(add-hook! 'doom-change-font-size-hook - (defun +modeline-adjust-height-h () - (defvar +modeline--old-height +modeline-height) - (let ((default-height +modeline--old-height) - (scale (or (frame-parameter nil 'font-scale) 0))) - (setq +modeline-height - (if (> scale 0) - (+ default-height (* (or (frame-parameter nil 'font-scale) 1) - doom-font-increment)) - default-height)) - (when doom-init-time - (+modeline-refresh-bars-h))))) - - -;;; `+modeline-matches' -(use-package! anzu - :after-call isearch-mode - :config - ;; We manage our own modeline segments - (setq anzu-cons-mode-line-p nil) - ;; Ensure anzu state is cleared when searches & iedit are done - (add-hook 'iedit-mode-end-hook #'anzu--reset-status) - (advice-add #'evil-force-normal-state :before #'anzu--reset-status) - ;; Fix matches segment mirroring across all buffers - (mapc #'make-variable-buffer-local - '(anzu--total-matched - anzu--current-position - anzu--state - anzu--cached-count - anzu--cached-positions anzu--last-command - anzu--last-isearch-string anzu--overflow-p))) - -(use-package! evil-anzu - :when (modulep! :editor evil) - :after-call evil-ex-start-search evil-ex-start-word-search evil-ex-search-activate-highlight - :config (global-anzu-mode +1)) - -(defun +modeline--anzu () - "Show the match index and total number thereof. -Requires `anzu', also `evil-anzu' if using `evil-mode' for compatibility with -`evil-search'." - (when (and (bound-and-true-p anzu--state) - (not (bound-and-true-p iedit-mode))) - (propertize - (let ((here anzu--current-position) - (total anzu--total-matched)) - (cond ((eq anzu--state 'replace-query) - (format " %d replace " anzu--cached-count)) - ((eq anzu--state 'replace) - (format " %d/%d " (1+ here) total)) - (anzu--overflow-p - (format " %s+ " total)) - (t - (format " %s/%d " here total)))) - 'face (if (+modeline-active) 'doom-modeline-highlight)))) - -(defun +modeline--evil-substitute () - "Show number of matches for evil-ex substitutions and highlights in real time." - (when (and (bound-and-true-p evil-local-mode) - (or (assq 'evil-ex-substitute evil-ex-active-highlights-alist) - (assq 'evil-ex-global-match evil-ex-active-highlights-alist) - (assq 'evil-ex-buffer-match evil-ex-active-highlights-alist))) - (propertize - (let ((range (if evil-ex-range - (cons (car evil-ex-range) (cadr evil-ex-range)) - (cons (line-beginning-position) (line-end-position)))) - (pattern (car-safe (evil-delimited-arguments evil-ex-argument 2)))) - (if pattern - (format " %s matches " (how-many pattern (car range) (cdr range))) - " - ")) - 'face (if (+modeline-active) 'doom-modeline-highlight)))) - -(defun +modeline--multiple-cursors () - "Show the number of multiple cursors." - (when (bound-and-true-p evil-mc-cursor-list) - (let ((count (length evil-mc-cursor-list))) - (when (> count 0) - (let ((face (cond ((not (+modeline-active)) 'mode-line-inactive) - (evil-mc-frozen 'doom-modeline-highlight) - ('doom-modeline-alternate-highlight)))) - (concat (propertize " " 'face face) - (all-the-icons-faicon "i-cursor" :face face :v-adjust -0.0575) - (propertize " " 'face `(:inherit (variable-pitch ,face))) - (propertize (format "%d " count) - 'face face))))))) - -(defun +modeline--overlay< (a b) - "Sort overlay A and B." - (< (overlay-start a) (overlay-start b))) - -(defun +modeline--iedit () - "Show the number of iedit regions matches + what match you're on." - (when (and (bound-and-true-p iedit-mode) - (bound-and-true-p iedit-occurrences-overlays)) - (propertize - (let ((this-oc (or (let ((inhibit-message t)) - (iedit-find-current-occurrence-overlay)) - (save-excursion - (iedit-prev-occurrence) - (iedit-find-current-occurrence-overlay)))) - (length (length iedit-occurrences-overlays))) - (format " %s/%d " - (if this-oc - (- length - (length (memq this-oc (sort (append iedit-occurrences-overlays nil) - #'+modeline--overlay<))) - -1) - "-") - length)) - 'face (if (+modeline-active) 'doom-modeline-highlight)))) - -(defun +modeline--macro-recording () - "Display current Emacs or evil macro being recorded." - (when (and (+modeline-active) - (or defining-kbd-macro - executing-kbd-macro)) - (let ((sep (propertize " " 'face 'doom-modeline-highlight))) - (concat sep - (propertize (if (bound-and-true-p evil-this-macro) - (char-to-string evil-this-macro) - "Macro") - 'face 'doom-modeline-highlight) - sep - (all-the-icons-octicon "triangle-right" - :face 'doom-modeline-highlight - :v-adjust -0.05) - sep)))) - -(def-modeline-var! +modeline-matches - '(:eval - (let ((meta (concat (+modeline--macro-recording) - (+modeline--anzu) - (+modeline--evil-substitute) - (+modeline--iedit) - (+modeline--multiple-cursors)))) - (or (and (not (equal meta "")) meta) - " %I ")))) - - -;;; `+modeline-modes' -(def-modeline-var! +modeline-modes ; remove minor modes - '("" - (:propertize mode-name - face bold - mouse-face doom-modeline-highlight) - mode-line-process - "%n" - " ")) - - -;;; `+modeline-buffer-identification' -(defvar-local +modeline--buffer-id-cache nil) - -;; REVIEW Generating the buffer's file name can be relatively expensive. -;; Compounded with how often the modeline updates this can add up, so -;; we cache it ahead of time. -(add-hook! '(change-major-mode-after-body-hook - ;; In case the user saves the file to a new location - after-save-hook - ;; ...or makes external changes then returns to Emacs - focus-in-hook - ;; ...or when we change the current project! - projectile-after-switch-project-hook - ;; ...when the visited file changes (e.g. it's renamed) - after-set-visited-file-name-hook - ;; ...when the underlying file changes - after-revert-hook) - (defun +modeline--generate-buffer-id-cache-h () - (when after-init-time - (setq +modeline--buffer-id-cache - (let ((file-name (buffer-file-name (buffer-base-buffer)))) - (unless (or (null default-directory) - (null file-name) - (file-remote-p file-name)) - (when-let (project-root (doom-project-root)) - (file-relative-name (or buffer-file-truename (file-truename file-name)) - (concat project-root ".."))))))))) - -(def-modeline-var! +modeline-buffer-identification ; slightly more informative buffer id - '((:eval - (propertize - (or +modeline--buffer-id-cache "%b") - 'face (cond ((buffer-modified-p) '(error bold mode-line-buffer-id)) - ((+modeline-active) 'mode-line-buffer-id)) - 'help-echo (or +modeline--buffer-id-cache (buffer-name)))) - (buffer-read-only (:propertize " RO" face warning)))) - - -;;; `+modeline-position' -(def-modeline-var! +modeline-position '(" %l:%C %p ")) - - -;;; `+modeline-checker' -(def-modeline-var! +modeline-checker nil - "Displays color-coded error status & icon for the current buffer." - :local t) - -(add-hook! '(flycheck-status-changed-functions - flycheck-mode-hook) - (defun +modeline-checker-update (&optional status) - "Update flycheck text via STATUS." - (setq +modeline-checker - (pcase status - (`finished - (if flycheck-current-errors - (let-alist (flycheck-count-errors flycheck-current-errors) - (let ((error (or .error 0)) - (warning (or .warning 0)) - (info (or .info 0))) - (+modeline-format-icon 'material "do_not_disturb_alt" - (number-to-string (+ error warning info)) - (cond ((> error 0) 'error) - ((> warning 0) 'warning) - ('success)) - (format "Errors: %d, Warnings: %d, Debug: %d" - error - warning - info)))) - (+modeline-format-icon 'material "check" "" 'success))) - (`running (+modeline-format-icon 'material "access_time" "*" 'mode-line-inactive "Running...")) - (`errored (+modeline-format-icon 'material "sim_card_alert" "!" 'error "Errored!")) - (`interrupted (+modeline-format-icon 'material "pause" "!" 'mode-line-inactive "Interrupted")) - (`suspicious (+modeline-format-icon 'material "priority_high" "!" 'error "Suspicious")))))) - - - -;;; `+modeline-selection-info' -(defsubst +modeline--column (pos) - "Get the column of the position `POS'." - (save-excursion (goto-char pos) - (current-column))) - -(def-modeline-var! +modeline-selection-info - '(:eval - (when (or (and (bound-and-true-p evil-local-mode) - (eq evil-state 'visual)) - mark-active) - (cl-destructuring-bind (beg . end) - (if (bound-and-true-p evil-visual-selection) - (cons evil-visual-beginning evil-visual-end) - (cons (region-beginning) (region-end))) - (propertize - (let ((lines (count-lines beg (min end (point-max))))) - (concat " " - (cond ((or (bound-and-true-p rectangle-mark-mode) - (and (bound-and-true-p evil-visual-selection) - (eq 'block evil-visual-selection))) - (let ((cols (abs (- (+modeline--column end) - (+modeline--column beg))))) - (format "%dx%dB" lines cols))) - ((and (bound-and-true-p evil-visual-selection) - (eq evil-visual-selection 'line)) - (format "%dL" lines)) - ((> lines 1) - (format "%dC %dL" (- end beg) lines)) - ((format "%dC" (- end beg)))) - (when (derived-mode-p 'text-mode) - (format " %dW" (count-words beg end))) - " ")) - 'face (if (+modeline-active) 'success))))) - "Information about the current selection, such as how many characters and -lines are selected, or the NxM dimensions of a block selection.") - -(defun +modeline-add-selection-segment-h () - (add-to-list '+modeline-format-left '+modeline-selection-info 'append)) -(defun +modeline-remove-selection-segment-h () - (delq! '+modeline-selection-info +modeline-format-left)) - -(if (featurep 'evil) - (progn - (add-hook 'evil-visual-state-entry-hook #'+modeline-add-selection-segment-h) - (add-hook 'evil-visual-state-exit-hook #'+modeline-remove-selection-segment-h)) - (add-hook 'activate-mark-hook #'+modeline-add-selection-segment-h) - (add-hook 'deactivate-mark-hook #'+modeline-remove-selection-segment-h)) - - -;;; `+modeline-encoding' -(def-modeline-var! +modeline-encoding - `(:eval - (let ((sys (coding-system-plist buffer-file-coding-system)) - (eol (coding-system-eol-type-mnemonic buffer-file-coding-system))) - (concat (unless (equal eol ,(if IS-WINDOWS "CRLF" "LF")) - (concat " " eol " ")) - (if (memq (plist-get sys :category) - '(coding-category-undecided coding-category-utf-8)) - (unless (string-match-p "utf-8" (symbol-name buffer-file-coding-system)) - "UTF-8 ") - (concat (upcase (symbol-name (plist-get sys :name))) - " ")))))) - -(def-modeline-var! +modeline-pdf-page nil - "Display page number of pdf" - :local t) - -(defun +modeline-update-pdf-pages () - "Update PDF pages." - (setq +modeline-pdf-page - (format " P%d/%d " - (eval `(pdf-view-current-page)) - (pdf-cache-number-of-pages)))) - -(add-hook 'pdf-view-change-page-hook #'+modeline-update-pdf-pages) - -;; Clearer mnemonic labels for EOL styles -(setq eol-mnemonic-dos "CRLF" - eol-mnemonic-mac "CR" - eol-mnemonic-unix "LF" - eol-mnemonic-undecided "??") - - -;; -;;; Default modeline - -(def-modeline! :main - '("" - +modeline-matches - " " - +modeline-buffer-identification - +modeline-position) - `("" - mode-line-misc-info - +modeline-modes - (vc-mode (" " - ,(all-the-icons-octicon "git-branch" :v-adjust 0.0) - vc-mode " ")) - " " - +modeline-encoding - (+modeline-checker ("" +modeline-checker " ")))) - -(def-modeline! 'project - `(" " - ,(all-the-icons-octicon - "file-directory" - :face 'bold - :v-adjust -0.06 - :height 1.1) - (:propertize (" " (:eval (abbreviate-file-name default-directory))) - face bold)) - '("" mode-line-misc-info +modeline-modes)) - -(def-modeline! 'special - '("" +modeline-matches - " " +modeline-buffer-identification) - '("" +modeline-modes)) - -(def-modeline! 'pdf - '("" - +modeline-matches - " " - +modeline-buffer-identification - +modeline-pdf-page) - `("" - +modeline-modes - " ")) -;; TODO (def-modeline! helm ...) - - -;; Other modes -(set-modeline! :main 'default) -(set-modeline-hook! '+doom-dashboard-mode-hook 'project) -(set-modeline-hook! 'pdf-tools-enabled-hook 'pdf) -(set-modeline-hook! '(special-mode-hook - image-mode-hook - circe-mode-hook) - 'special) - -(add-hook! 'magit-mode-hook - (defun +modeline-init-project-or-hide-h () - (if (eq major-mode 'magit-status-mode) - (set-modeline! 'project) - (hide-mode-line-mode +1)))) - - -;; -;;; Bootstrap - -(defvar +modeline--old-format (default-value 'mode-line-format)) - -(define-minor-mode +modeline-mode - "TODO" - :init-value nil - :global nil - (cond - (+modeline-mode - (setq mode-line-format - (cons - "" '(+modeline-bar - +modeline-format-left - (:eval - (propertize - " " - 'display - `((space :align-to (- (+ right right-fringe right-margin) - ,(string-width - (format-mode-line '("" +modeline-format-right)))))))) - +modeline-format-right)))) - ((setq mode-line-format +modeline--old-format)))) - -(define-global-minor-mode +modeline-global-mode +modeline-mode +modeline-mode) - -(add-hook '+modeline-global-mode-hook #'size-indication-mode) -(add-hook 'doom-init-ui-hook #'+modeline-global-mode) diff --git a/.config/emacs/modules/ui/modeline/README.org b/.config/emacs/modules/ui/modeline/README.org @@ -1,200 +0,0 @@ -#+title: :ui modeline -#+subtitle: Snazzy, Atom-inspired modeline, plus API -#+created: February 20, 2017 -#+since: 2.0.0 - -* Description :unfold: -This module provides an Atom-inspired, minimalistic modeline for Doom Emacs, -powered by the [[doom-package:doom-modeline]] package (where you can find screenshots). - -** Maintainers -- [[doom-user:][@hlissner]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +light :: - Enable a lighter, less featureful version of the modeline that does not depend - on [[doom-package:doom-modeline]], which has performances issues in some cases. - -** Packages -- [[doom-package:anzu]] -- [[doom-package:doom-modeline]] unless [[doom-module:+light]] -- [[doom-package:evil-anzu]] if [[doom-module::editor evil]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** Hiding the modeline -- You can use ~M-x hide-mode-line-mode RET~ to hide modeline for the current - buffer. -- Also, there is ~global-hide-mode-line-mode~ for globally hiding modeline. You - can just add =(global-hide-mode-line-mode)= into =~/.doom.d/config.el~. -- ~hide-mode-line-excluded-modes~ can be set for preventing - ~global-hide-mode-line-mode~ hiding modeline for buffers with the - corresponding major modes. - -** TODO Switching the modeline and header line - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** TODO Changing the default modeline - -** TODO Activating a format - -** TODO Defining a modeline format - -** TODO Defining a modeline segment - -** TODO Extracting Doom's modeline into your config - -* Troubleshooting -[[doom-report:][Report an issue?]] - -** Where are my minor modes? -I rarely need to know what minor modes are active, so I removed them. ~M-x -doom/describe-active-minor-mode~ was written to substitute for it. - -** Icons in my modeline look strange -1. Check whether ~all-the-icons~ are installed. Run ~M-x - all-the-icons-install-fonts~ to install the resource fonts. Note that - ~all-the-icons~ only support GUI. See [[https://github.com/domtronn/all-the-icons.el][all-the-icons]] for details. - -2. ~cnfonts~ will conflict with ~all-the-icons~. You can refer the following - workaround: - #+begin_src emacs-lisp - ;; See https://github.com/seagle0128/doom-modeline/issues/278#issuecomment-569510336 - ;; Add to $DOOMDIR/packages.el - (package! cnfonts) - ;; Add to $DOOMDIR/config.el - (add-hook 'after-setting-font-hook #'cnfonts-set-font) - #+end_src - -3. If ~all-the-icons~ fonts are installed while the icons cannot display - correctly, please install the non-free font [[https://dn-works.com/wp-content/uploads/2020/UFAS-Fonts/Symbola.zip][Symbola]]. This issue usually - occurs on Windows. - -** The right side of the modeline is cut off -I believe the consensus is: this is due to oversized icons, i.e. a font issue. -Some possible solutions: - -1. Tweak ~all-the-icons-scale-factor~ (1.2 by default): ~(setq - all-the-icons-scale-factor 1.1)~ - -2. Add some padding to the modeline definition: - #+begin_src emacs-lisp - (after! doom-modeline - (doom-modeline-def-modeline 'main - '(bar matches buffer-info remote-host buffer-position parrot selection-info) - '(misc-info minor-modes checker input-method buffer-encoding major-mode process vcs " "))) ; <-- added padding here - #+end_src - -3. Use another font for the mode line (or a different ~:height~) (source) - #+begin_src emacs-lisp - (custom-set-faces! - '(mode-line :family "Noto Sans" :height 0.9) - '(mode-line-inactive :family "Noto Sans" :height 0.9)) - #+end_src - -(Mentioned in [[doom-ref:][#1680]], [[doom-ref:][#278]] and [[https://github.com/seagle0128/doom-modeline/issues/334][seagle0128/doom-modeline#334]]) - -4. Change the width of icon characters in ~char-width-table~: - #+begin_src emacs-lisp - (add-hook! 'doom-modeline-mode-hook - (let ((char-table char-width-table)) - (while (setq char-table (char-table-parent char-table))) - (dolist (pair doom-modeline-rhs-icons-alist) - (let ((width 2) ; <-- tweak this - (chars (cdr pair)) - (table (make-char-table nil))) - (dolist (char chars) - (set-char-table-range table char width)) - (optimize-char-table table) - (set-char-table-parent table char-table) - (setq char-width-table table))))) - #+end_src - - If this doesn't help, try different values for ~width~ such as ~width 1~ or - ~width 3~. - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 /This module's appendix is incomplete./ [[doom-contrib-module:][Write more?]] -#+end_quote - -** Autodefs -- ~def-modeline-format! NAME LEFT &optional RIGHT~ -- ~def-modeline-segment! NAME &rest REST~ -- ~set-modeline! NAME &optional DEFAULT~ - -** Variables -- doom-modeline-height -- doom-modeline-bar-width -- doom-modeline-buffer-file-name-style -- doom-modeline-icon -- doom-modeline-major-mode-icon -- doom-modeline-major-mode-color-icon -- doom-modeline-buffer-state-icon -- doom-modeline-buffer-modification-icon -- doom-modeline-minor-modes -- doom-modeline-enable-word-count -- doom-modeline-buffer-encoding -- doom-modeline-indent-info -- doom-modeline-checker-simple-format -- doom-modeline-vcs-max-length -- doom-modeline-persp-name -- doom-modeline-lsp -- doom-modeline-github -- doom-modeline-github-interval -- doom-modeline-env-version -- doom-modeline-mu4e -- doom-modeline-irc -- doom-modeline-irc-stylize - -** Faces -- doom-modeline-buffer-path -- doom-modeline-buffer-file -- doom-modeline-buffer-modified -- doom-modeline-buffer-major-mode -- doom-modeline-buffer-minor-mode -- doom-modeline-project-parent-dir -- doom-modeline-project-dir -- doom-modeline-project-root-dir -- doom-modeline-highlight -- doom-modeline-panel -- doom-modeline-debug -- doom-modeline-info -- doom-modeline-warning -- doom-modeline-urgent -- doom-modeline-unread-number -- doom-modeline-bar -- doom-modeline-inactive-bar -- doom-modeline-evil-emacs-state -- doom-modeline-evil-insert-state -- doom-modeline-evil-motion-state -- doom-modeline-evil-normal-state -- doom-modeline-evil-operator-state -- doom-modeline-evil-visual-state -- doom-modeline-evil-replace-state -- doom-modeline-persp-name -- doom-modeline-persp-buffer-not-in-persp diff --git a/.config/emacs/modules/ui/modeline/autoload.el b/.config/emacs/modules/ui/modeline/autoload.el @@ -1,36 +0,0 @@ -;;; ui/modeline/autoload/modeline.el -*- lexical-binding: t; -*- - -(defvar +modeline--old-bar-height nil) -;;;###autoload -(defun +modeline-resize-for-font-h () - "Adjust the modeline's height when the font size is changed by -`doom/increase-font-size' or `doom/decrease-font-size'. - -Meant for `doom-change-font-size-hook'." - (unless +modeline--old-bar-height - (setq +modeline--old-bar-height doom-modeline-height)) - (let ((default-height +modeline--old-bar-height) - (scale (or (frame-parameter nil 'font-scale) 0))) - (setq doom-modeline-height - (if (> scale 0) - (+ default-height (* scale doom-font-increment)) - default-height)))) - -;;;###autoload -(defun +modeline-update-env-in-all-windows-h (&rest _) - "Update version strings in all buffers." - (dolist (window (window-list)) - (with-selected-window window - (when (fboundp 'doom-modeline-update-env) - (doom-modeline-update-env)) - (force-mode-line-update)))) - -;;;###autoload -(defun +modeline-clear-env-in-all-windows-h (&rest _) - "Blank out version strings in all buffers." - (unless (modulep! +light) - (dolist (buffer (buffer-list)) - (with-current-buffer buffer - (setq doom-modeline-env--version - (bound-and-true-p doom-modeline-load-string))))) - (force-mode-line-update t)) diff --git a/.config/emacs/modules/ui/modeline/config.el b/.config/emacs/modules/ui/modeline/config.el @@ -1,85 +0,0 @@ -;;; ui/modeline/config.el -*- lexical-binding: t; -*- - -(when (modulep! +light) - (load! "+light")) - - -(use-package! doom-modeline - :unless (modulep! +light) - :hook (doom-after-init . doom-modeline-mode) - :hook (doom-modeline-mode . size-indication-mode) ; filesize in modeline - :hook (doom-modeline-mode . column-number-mode) ; cursor column in modeline - :init - (when (>= emacs-major-version 29) - ;; HACK: Emacs 29 treats `nil' for :background as invalid, and complains. - ;; `doom-modeline' hasn't updated its face to address this yet. - ;; REVIEW: PR this fix to doom-modeline - (defface doom-modeline-buffer-modified - '((t (:inherit (error bold) :background unspecified))) - "Face used for the \\='unsaved\\=' symbol in the mode-line." - :group 'doom-modeline-faces)) - - ;; We display project info in the modeline ourselves - (setq projectile-dynamic-mode-line nil) - ;; Set these early so they don't trigger variable watchers - (setq doom-modeline-bar-width 3 - doom-modeline-github nil - doom-modeline-mu4e nil - doom-modeline-persp-name nil - doom-modeline-minor-modes nil - doom-modeline-major-mode-icon nil - doom-modeline-buffer-file-name-style 'relative-from-project - ;; Only show file encoding if it's non-UTF-8 and different line endings - ;; than the current OSes preference - doom-modeline-buffer-encoding 'nondefault - doom-modeline-default-eol-type - (cond (IS-MAC 2) - (IS-WINDOWS 1) - (0))) - - ;; Fix modeline icons in daemon-spawned graphical frames. We have our own - ;; mechanism for disabling all-the-icons, so we don't need doom-modeline to do - ;; it for us. However, this may cause unwanted padding in the modeline in - ;; daemon-spawned terminal frames. If it bothers you, you may prefer - ;; `doom-modeline-icon' set to `nil'. - (when (daemonp) - (setq doom-modeline-icon t)) - :config - ;; HACK Fix #4102 due to empty all-the-icons return value (caused by - ;; `doom--disable-all-the-icons-in-tty-a' advice) in tty daemon frames. - (defadvice! +modeline-disable-icon-in-daemon-a (fn &rest args) - :around #'doom-modeline-propertize-icon - (when (display-graphic-p) - (apply fn args))) - - ;; Fix an issue where these two variables aren't defined in TTY Emacs on MacOS - (defvar mouse-wheel-down-event nil) - (defvar mouse-wheel-up-event nil) - - (add-hook 'after-setting-font-hook #'+modeline-resize-for-font-h) - (add-hook 'doom-load-theme-hook #'doom-modeline-refresh-bars) - - (add-to-list 'doom-modeline-mode-alist '(+doom-dashboard-mode . dashboard)) - (add-hook! 'magit-mode-hook - (defun +modeline-hide-in-non-status-buffer-h () - "Show minimal modeline in magit-status buffer, no modeline elsewhere." - (if (eq major-mode 'magit-status-mode) - (doom-modeline-set-modeline 'magit) - (hide-mode-line-mode)))) - - ;; Some functions modify the buffer, causing the modeline to show a false - ;; modified state, so force them to behave. - (defadvice! +modeline--inhibit-modification-hooks-a (fn &rest args) - :around #'ws-butler-after-save - (with-silent-modifications (apply fn args))) - - - ;; - ;;; Extensions - (use-package! anzu - :after-call isearch-mode) - - (use-package! evil-anzu - :when (modulep! :editor evil) - :after-call evil-ex-start-search evil-ex-start-word-search evil-ex-search-activate-highlight - :config (global-anzu-mode +1))) diff --git a/.config/emacs/modules/ui/modeline/packages.el b/.config/emacs/modules/ui/modeline/packages.el @@ -1,8 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; ui/modeline/packages.el - -(unless (modulep! +light) - (package! doom-modeline :pin "6125309c2caa3c98591a4c802e9b4dd2f7ea83e9")) -(package! anzu :pin "5abb37455ea44fa401d5f4c1bdc58adb2448db67") -(when (modulep! :editor evil) - (package! evil-anzu :pin "d1e98ee6976437164627542909a25c6946497899")) diff --git a/.config/emacs/modules/ui/nav-flash/README.org b/.config/emacs/modules/ui/nav-flash/README.org @@ -1,63 +0,0 @@ -#+title: :ui nav-flash -#+subtitle: Blink after big motions -#+created: June 04, 2017 -#+since: 2.0.0 - -* Description :unfold: -This module flashes the line around the cursor after any significant motion, to -make it easy to follow after big operations. - -#+begin_quote - 💡 Tremendously helpful on large, 1600p+ or 4K displays. -#+end_quote - -** Maintainers -- [[doom-user:][@hlissner]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:nav-flash]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* Usage -By default, [[doom-package:nav-flash]] will be triggered whenever [[fn:recenter]] is called or an entry -is added to the jump-list (managed by [[doom-package:better-jumper]]). - -[[fn:recenter]] is called after many hooks and commands, such as: -- [[var:better-jumper-post-jump-hook]] -- [[var:rtags-after-find-file-hook]] -- [[var:org-follow-link-hook]] -- [[var:imenu-after-jump-hook]] -- [[var:counsel-grep-post-action-hook]] -- [[var:dumb-jump-after-jump-hook]] - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/ui/nav-flash/autoload.el b/.config/emacs/modules/ui/nav-flash/autoload.el @@ -1,48 +0,0 @@ -;;; ui/nav-flash/autoload.el -*- lexical-binding: t; -*- - -(defvar +nav-flash--last-point nil) - -;;;###autoload -(defun +nav-flash-blink-cursor (&rest _) - "Blinks the current line in the current window, to make it clear where the -cursor has landed (typically after a large motion, like switching windows or -jumping to another part of the file)." - (unless (minibufferp) - (nav-flash-show) - ;; only show in the current window - (when (overlayp compilation-highlight-overlay) - (overlay-put compilation-highlight-overlay 'window (selected-window))))) - -;;;###autoload -(defun +nav-flash-blink-cursor-maybe (&rest _) - "Like `+nav-flash-blink-cursor', but no-ops if in special-mode, term-mode, -vterm-mode, or triggered from one of `+nav-flash-exclude-commands'." - (unless (or (memq this-command +nav-flash-exclude-commands) - (bound-and-true-p so-long-minor-mode) - (apply #'derived-mode-p +nav-flash-exclude-modes) - (equal +nav-flash--last-point - (list (selected-window) - (current-buffer) - (point)))) - (+nav-flash-blink-cursor) - (setq +nav-flash--last-point (list (selected-window) (current-buffer) (point))))) - -;;;###autoload -(defun +nav-flash-delayed-blink-cursor-h (&rest _) - "Like `+nav-flash-blink-cursor', but links after a tiny pause, in case it -isn't clear at run-time if the point will be in the correct window/buffer (like -for `org-follow-link-hook')." - (run-at-time 0.1 nil #'+nav-flash-blink-cursor-h)) - -;;;###autoload -(defalias '+nav-flash-blink-cursor-h #'+nav-flash-blink-cursor) -;;;###autoload -(defalias '+nav-flash-blink-cursor-maybe-h #'+nav-flash-blink-cursor-maybe) -;;;###autoload -(defalias '+nav-flash-blink-cursor-a #'+nav-flash-blink-cursor-maybe) - -;;;###autoload -(defun +nav-flash/blink-cursor (&rest _) - "Blink current line using `nav-flash'." - (interactive) - (+nav-flash-blink-cursor)) diff --git a/.config/emacs/modules/ui/nav-flash/config.el b/.config/emacs/modules/ui/nav-flash/config.el @@ -1,43 +0,0 @@ -;;; ui/nav-flash/config.el -*- lexical-binding: t; -*- - -(defvar +nav-flash-exclude-commands - '(mouse-set-point mouse-drag-region evil-mouse-drag-region +org/dwim-at-point - org-find-file org-find-file-at-mouse) - "A list of commands that should not trigger nav-flash.") - -(defvar +nav-flash-exclude-modes - '(so-long-mode special-mode comint-mode term-mode vterm-mode) - "List of major modes where nav-flash won't automatically trigger.") - - -;; -;;; Packages - -;; DEPRECATED To be replaced with pulsar.el when Emacs 28 support is dropped -(use-package! nav-flash - :defer t - :init - ;; NOTE In :tools lookup `recenter' is hooked to a bunch of jumping - ;; commands, which will trigger nav-flash. - (add-hook! '(imenu-after-jump-hook - better-jumper-post-jump-hook - counsel-grep-post-action-hook - consult-after-jump-hook - dumb-jump-after-jump-hook) - #'+nav-flash-blink-cursor-maybe-h) - - (add-hook 'doom-switch-window-hook #'+nav-flash-blink-cursor-maybe-h) - - ;; `org' - (add-hook 'org-follow-link-hook #'+nav-flash-delayed-blink-cursor-h) - - ;; `saveplace' - (advice-add #'save-place-find-file-hook :after #'+nav-flash-blink-cursor-a) - - ;; `evil' - (advice-add #'evil-window-top :after #'+nav-flash-blink-cursor-a) - (advice-add #'evil-window-middle :after #'+nav-flash-blink-cursor-a) - (advice-add #'evil-window-bottom :after #'+nav-flash-blink-cursor-a) - - ;; Bound to `ga' for evil users - (advice-add #'what-cursor-position :after #'+nav-flash-blink-cursor-a)) diff --git a/.config/emacs/modules/ui/nav-flash/packages.el b/.config/emacs/modules/ui/nav-flash/packages.el @@ -1,4 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; ui/nav-flash/packages.el - -(package! nav-flash :pin "5d4b48567862f6be0ca973d6b1dca90e4815cb9b") diff --git a/.config/emacs/modules/ui/neotree/README.org b/.config/emacs/modules/ui/neotree/README.org @@ -1,57 +0,0 @@ -#+title: :ui neotree -#+subtitle: NERDTree for evil nerds -#+created: May 11, 2018 -#+since: 21.12.0 - -* Description :unfold: -This module brings a side panel for browsing project files, inspired by vim's -NERDTree. - -#+begin_quote - 💡 Sure, there's [[doom-package:dired]] and [[doom-package:projectile]], but sometimes I'd like a bird's eye view - of a project. -#+end_quote - -** Maintainers -*This module needs a maintainer.* [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:neotree]] - -** TODO Hacks -#+begin_quote - 🔨 This module's hacks haven't been documented yet. [[doom-contrib-module:][Document them?]] -#+end_quote - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/ui/neotree/autoload.el b/.config/emacs/modules/ui/neotree/autoload.el @@ -1,70 +0,0 @@ -;;; ui/neotree/autoload.el -*- lexical-binding: t; -*- - -;; `neotree-show' and `neotree-find' don't respect the current project, and open -;; neotree in `default-directory'. `+neotree/open' and `neotree/find-this-file' -;; will ensure the neotree pane is always rooted in the project root. - -;;;###autoload -(defun +neotree/open () - "Open the neotree window in the current project." - (interactive) - (require 'neotree) - (if (neo-global--window-exists-p) - (neotree-hide) - (neotree-dir (or (doom-project-root) - default-directory)))) - -;;;###autoload -(defun +neotree/find-this-file () - "Open the neotree window in the current project, and find the current file." - (interactive) - (let ((path buffer-file-name) - (project-root (or (doom-project-root) - default-directory))) - (require 'neotree) - (cond ((and (neo-global--window-exists-p) - (get-buffer-window neo-buffer-name t)) - (neotree-find path project-root) - (neotree-refresh)) - ((not (and (neo-global--window-exists-p) - (equal (file-truename (neo-global--with-buffer neo-buffer--start-node)) - (file-truename project-root)))) - (neotree-dir project-root) - (neotree-find path project-root)) - (t - (neotree-find path project-root))))) - -;;;###autoload -(defun +neotree/collapse-or-up () - "Collapse an expanded directory node or go to the parent node." - (interactive) - (when-let (node (neo-buffer--get-filename-current-line)) - (if (and (file-directory-p node) - (neo-buffer--expanded-node-p node)) - (+neotree/collapse) - (neotree-select-up-node)))) - -;;;###autoload -(defun +neotree/collapse () - "Collapse a neotree node." - (interactive) - (when-let (node (neo-buffer--get-filename-current-line)) - (when (file-directory-p node) - (neo-buffer--set-expand node nil) - (neo-buffer--refresh t)) - (when neo-auto-indent-point - (neo-point-auto-indent)))) - -;;;###autoload -(defun +neotree/expand-or-open () - "Expand or open a neotree node." - (interactive) - (when-let (node (neo-buffer--get-filename-current-line)) - (cond ((file-directory-p node) - (neo-buffer--set-expand node t) - (neo-buffer--refresh t) - (when neo-auto-indent-point - (forward-line) - (neo-point-auto-indent))) - (t - (call-interactively #'neotree-enter))))) diff --git a/.config/emacs/modules/ui/neotree/config.el b/.config/emacs/modules/ui/neotree/config.el @@ -1,73 +0,0 @@ -;;; ui/neotree/config.el -*- lexical-binding: t; -*- - -(use-package! neotree - :commands (neotree-show - neotree-hide - neotree-toggle - neotree-dir - neotree-find - neo-global--with-buffer - neo-global--window-exists-p) - :init - (setq neo-create-file-auto-open nil - neo-auto-indent-point nil - neo-autorefresh nil - neo-mode-line-type 'none - neo-window-width 30 - neo-show-updir-line nil - neo-theme 'icons - neo-banner-message nil - neo-confirm-create-file #'off-p - neo-confirm-create-directory #'off-p - neo-show-hidden-files nil - neo-keymap-style 'concise - neo-show-hidden-files t - neo-hidden-regexp-list - '(;; vcs folders - "^\\.\\(?:git\\|hg\\|svn\\)$" - ;; compiled files - "\\.\\(?:pyc\\|o\\|elc\\|lock\\|css.map\\|class\\)$" - ;; generated files, caches or local pkgs - "^\\(?:node_modules\\|vendor\\|.\\(project\\|cask\\|yardoc\\|sass-cache\\)\\)$" - ;; org-mode folders - "^\\.\\(?:sync\\|export\\|attach\\)$" - ;; temp files - "~$" - "^#.*#$")) - - :config - (set-popup-rule! "^ ?\\*NeoTree" :ignore t) - - (after! winner - (add-to-list 'winner-boring-buffers neo-buffer-name)) - - ;; The cursor always sits at bol. `+neotree--fix-cursor-h' and - ;; `+neotree--indent-cursor-a' change that behavior so that the cursor is - ;; always on the first non-blank character on the line, in the neo buffer. - (add-hook! 'neo-enter-hook - (defun +neotree-fix-cursor-h (&rest _) - (with-current-buffer neo-global--buffer - (+neotree--indent-cursor-a)))) - - (defadvice! +neotree--indent-cursor-a (&rest _) - :after '(neotree-next-line neotree-previous-line) - (beginning-of-line) - (skip-chars-forward " \t\r")) - - (map! :map neotree-mode-map - :n [tab] (neotree-make-executor - :dir-fn #'neo-open-dir - :file-fn #'neotree-quick-look) - :n "DEL" #'evil-window-prev - :n "n" #'neotree-next-line - :n "p" #'neotree-previous-line - :m "h" #'+neotree/collapse-or-up - :m "l" #'+neotree/expand-or-open - :n "J" #'neotree-select-next-sibling-node - :n "K" #'neotree-select-previous-sibling-node - :n "H" #'neotree-select-up-node - :n "L" #'neotree-select-down-node - :n "G" #'evil-goto-line - :n "gg" #'evil-goto-first-line - :n "v" (neotree-make-executor :file-fn 'neo-open-file-vertical-split) - :n "s" (neotree-make-executor :file-fn 'neo-open-file-horizontal-split))) diff --git a/.config/emacs/modules/ui/neotree/packages.el b/.config/emacs/modules/ui/neotree/packages.el @@ -1,4 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; ui/neotree/packages.el - -(package! neotree :pin "98fe21334affaffe2334bf7c987edaf1980d2d0b") diff --git a/.config/emacs/modules/ui/ophints/README.org b/.config/emacs/modules/ui/ophints/README.org @@ -1,56 +0,0 @@ -#+title: :ui ophints -#+subtitle: An indicator for “what did I just do?” -#+created: June 04, 2017 -#+since: 2.0.0 - -* Description :unfold: -This module provides op-hints (operation hinting), i.e. visual feedback for -certain operations. It highlights regions of text that the last operation (like -yank) acted on. - -Uses [[doom-package:evil-goggles]] for evil users and [[doom-package:volatile-highlights]] otherwise. - -** Maintainers -- [[doom-user:][@hlissner]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:evil-goggles]] if [[doom-module::editor evil]] -- [[doom-package:volatile-highlights]] unless [[doom-module::editor evil]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/ui/ophints/config.el b/.config/emacs/modules/ui/ophints/config.el @@ -1,73 +0,0 @@ -;;; ui/ophints/config.el -*- lexical-binding: t; -*- - -(use-package! evil-goggles - :when (modulep! :editor evil) - :hook (doom-first-input . evil-goggles-mode) - :init - (setq evil-goggles-duration 0.1 - evil-goggles-pulse nil ; too slow - ;; evil-goggles provides a good indicator of what has been affected. - ;; delete/change is obvious, so I'd rather disable it for these. - evil-goggles-enable-delete nil - evil-goggles-enable-change nil) - :config - (pushnew! evil-goggles--commands - '(evil-magit-yank-whole-line - :face evil-goggles-yank-face - :switch evil-goggles-enable-yank - :advice evil-goggles--generic-async-advice) - '(+evil:yank-unindented - :face evil-goggles-yank-face - :switch evil-goggles-enable-yank - :advice evil-goggles--generic-async-advice) - '(+eval:region - :face evil-goggles-yank-face - :switch evil-goggles-enable-yank - :advice evil-goggles--generic-async-advice)) - (when (modulep! :editor lispy) - (pushnew! evil-goggles--commands - '(lispyville-delete - :face evil-goggles-delete-face - :switch evil-goggles-enable-delete - :advice evil-goggles--generic-blocking-advice) - '(lispyville-delete-line - :face evil-goggles-delete-face - :switch evil-goggles-enable-delete - :advice evil-goggles--delete-line-advice) - '(lispyville-yank - :face evil-goggles-yank-face - :switch evil-goggles-enable-yank - :advice evil-goggles--generic-async-advice) - '(lispyville-yank-line - :face evil-goggles-yank-face - :switch evil-goggles-enable-yank - :advice evil-goggles--generic-async-advice) - '(lispyville-change - :face evil-goggles-change-face - :switch evil-goggles-enable-change - :advice evil-goggles--generic-blocking-advice) - '(lispyville-change-line - :face evil-goggles-change-face - :switch evil-goggles-enable-change - :advice evil-goggles--generic-blocking-advice) - '(lispyville-change-whole-line - :face evil-goggles-change-face - :switch evil-goggles-enable-change - :advice evil-goggles--generic-blocking-advice) - '(lispyville-indent - :face evil-goggles-indent-face - :switch evil-goggles-enable-indent - :advice evil-goggles--generic-async-advice) - '(lispyville-join - :face evil-goggles-join-face - :switch evil-goggles-enable-join - :advice evil-goggles--join-advice)))) - - -(use-package! volatile-highlights - :unless (modulep! :editor evil) - :hook (doom-first-input . volatile-highlights-mode) - :config - (after! undo-fu - (vhl/define-extension 'undo-fu 'undo-fu-only-undo 'undo-fu-only-redo) - (vhl/install-extension 'undo-fu))) diff --git a/.config/emacs/modules/ui/ophints/packages.el b/.config/emacs/modules/ui/ophints/packages.el @@ -1,6 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; ui/ophints/packages.el - -(if (modulep! :editor evil) - (package! evil-goggles :pin "8f20a16e74016f37ad76dc4f2230d9b00c6df3c2") - (package! volatile-highlights :pin "513c8b73cd3bc06cb9936a100468c227f649851c")) diff --git a/.config/emacs/modules/ui/popup/+hacks.el b/.config/emacs/modules/ui/popup/+hacks.el @@ -1,411 +0,0 @@ -;;; ui/popup/+hacks.el -*- lexical-binding: t; -*- - -;; What follows are all the hacks needed to get various parts of Emacs and other -;; plugins to cooperate with the popup management system. Essentially, it comes -;; down to: -;; -;; 1. Making plugins that control their own window environment less greedy (e.g. -;; org agenda, which tries to reconfigure the entire frame by deleting all -;; other windows just to pop up one tiny window). -;; 2. Forcing plugins to use `display-buffer' and `pop-to-buffer' instead of -;; `switch-to-buffer' (which is unaffected by `display-buffer-alist', which -;; we must rely on, heavily). -;; 3. Closing popups (temporarily) before functions that are highly destructive -;; to the illusion of popup control get run (with the use of the -;; `save-popups!' macro). -;; -;; Keep in mind, all this black magic may break in future updates, and will need -;; to be watched carefully for corner cases. Also, once this file is loaded, -;; many of its changes are irreversible without restarting Emacs! I don't like -;; it either, but I will address this over time. -;; -;; Hacks should be kept in alphabetical order, named after the feature they -;; modify, and should follow a ;;;## package-name header line (if not using -;; `after!' or `use-package!'). - -;; -;;; Core functions - -(defadvice! +popup--make-case-sensitive-a (fn &rest args) - "Make regexps in `display-buffer-alist' case-sensitive. - -To reduce fewer edge cases and improve performance when `display-buffer-alist' -grows larger." - :around #'display-buffer-assq-regexp - (let (case-fold-search) - (apply fn args))) - -;; Don't try to resize popup windows -(advice-add #'balance-windows :around #'+popup-save-a) - -(defun +popup/quit-window () - "The regular `quit-window' sometimes kills the popup buffer and switches to a -buffer that shouldn't be in a popup. We prevent that by remapping `quit-window' -to this commmand." - (interactive) - (let ((orig-buffer (current-buffer))) - (quit-window) - (when (and (eq orig-buffer (current-buffer)) - (+popup-buffer-p)) - (+popup/close nil 'force)))) -(global-set-key [remap quit-window] #'+popup/quit-window) - -(defadvice! +popup-override-display-buffer-alist-a (fn &rest args) - "When `pop-to-buffer' is called with non-nil ACTION, that ACTION should -override `display-buffer-alist'." - :around #'switch-to-buffer-other-tab - :around #'switch-to-buffer-other-window - :around #'switch-to-buffer-other-frame - (let ((display-buffer-alist nil)) - (apply fn args))) - - -;; -;;; External functions - -;;;###package buff-menu -(define-key Buffer-menu-mode-map (kbd "RET") #'Buffer-menu-other-window) - - -;;;###package company -(defadvice! +popup--dont-select-me-a (fn &rest args) - :around #'company-show-doc-buffer - (let ((+popup--inhibit-select t)) - (apply fn args))) - - -;;;###package compile -(defadvice! +popup--compilation-goto-locus-a (fn &rest args) - "Fix links in popup compilation buffers creating a new window each time they -were followed." - :around #'compilation-goto-locus - (letf! (defun pop-to-buffer (buffer &optional action norecord) - (let ((pop-up-windows (not (+popup-buffer-p (current-buffer))))) - (funcall pop-to-buffer buffer action norecord))) - (apply fn args))) - - -;;;###package eshell -(progn - (setq eshell-destroy-buffer-when-process-dies t) - - ;; When eshell runs a visual command (see `eshell-visual-commands'), it spawns - ;; a term buffer to run it in, but where it spawns it is the problem... - (defadvice! +popup--eshell-undedicate-popup (&rest _) - "Force spawned term buffer to share with the eshell popup (if necessary)." - :before #'eshell-exec-visual - (when (+popup-window-p) - (set-window-dedicated-p nil nil) - (add-transient-hook! #'eshell-query-kill-processes :after - (set-window-dedicated-p nil t))))) - - -;;;###package evil -(progn - ;; Make evil-mode cooperate with popups - (defadvice! +popup--evil-command-window-a (hist cmd-key execute-fn) - "Monkey patch the evil command window to use `pop-to-buffer' instead of -`switch-to-buffer', allowing the popup manager to handle it." - :override #'evil-command-window - (when (eq major-mode 'evil-command-window-mode) - (user-error "Cannot recursively open command line window")) - (dolist (win (window-list)) - (when (equal (buffer-name (window-buffer win)) - "*Command Line*") - (kill-buffer (window-buffer win)) - (delete-window win))) - (setq evil-command-window-current-buffer (current-buffer)) - (ignore-errors (kill-buffer "*Command Line*")) - (with-current-buffer (pop-to-buffer "*Command Line*") - (setq-local evil-command-window-execute-fn execute-fn) - (setq-local evil-command-window-cmd-key cmd-key) - (evil-command-window-mode) - (evil-command-window-insert-commands hist))) - - (defadvice! +popup--evil-command-window-execute-a () - "Execute the command under the cursor in the appropriate buffer, rather than -the command buffer." - :override #'evil-command-window-execute - (interactive) - (let ((result (buffer-substring (line-beginning-position) - (line-end-position))) - (execute-fn evil-command-window-execute-fn) - (execute-window (get-buffer-window evil-command-window-current-buffer)) - (popup (selected-window))) - (if execute-window - (select-window execute-window) - (user-error "Originating buffer is no longer active")) - ;; (kill-buffer "*Command Line*") - (delete-window popup) - (funcall execute-fn result) - (setq evil-command-window-current-buffer nil))) - - ;; Don't mess with popups - (advice-add #'+evil--window-swap :around #'+popup-save-a) - (advice-add #'evil-window-move-very-bottom :around #'+popup-save-a) - (advice-add #'evil-window-move-very-top :around #'+popup-save-a) - (advice-add #'evil-window-move-far-left :around #'+popup-save-a) - (advice-add #'evil-window-move-far-right :around #'+popup-save-a)) - - -;;;###package help-mode -(after! help-mode - (defun +popup--switch-from-popup (location) - (let (origin enable-local-variables) - (save-popups! - (switch-to-buffer (car location) nil t) - (if (not (cdr location)) - (message "Unable to find location in file") - (goto-char (cdr location)) - (recenter) - (setq origin (selected-window)))) - (select-window origin))) - - ;; Help buffers use `pop-to-window' to decide where to open followed links, - ;; which can be unpredictable. It should *only* replace the original buffer we - ;; opened the popup from. To fix this these three button types need to be - ;; redefined to set aside the popup before following a link. - (define-button-type 'help-function-def - :supertype 'help-xref - 'help-function - (lambda (fun file) - (require 'find-func) - (when (eq file 'C-source) - (setq file (help-C-file-name (indirect-function fun) 'fun))) - (+popup--switch-from-popup (find-function-search-for-symbol fun nil file)))) - - (define-button-type 'help-variable-def - :supertype 'help-xref - 'help-function - (lambda (var &optional file) - (when (eq file 'C-source) - (setq file (help-C-file-name var 'var))) - (+popup--switch-from-popup (find-variable-noselect var file)))) - - (define-button-type 'help-face-def - :supertype 'help-xref - 'help-function - (lambda (fun file) - (require 'find-func) - (+popup--switch-from-popup (find-function-search-for-symbol fun 'defface file))))) - - -;;;###package helpful -(defadvice! +popup--helpful-open-in-origin-window-a (button) - "Open links in non-popup, originating window rather than helpful's window." - :override #'helpful--navigate - (let ((path (substring-no-properties (button-get button 'path))) - enable-local-variables - origin) - (save-popups! - (find-file path) - (when-let (pos (get-text-property button 'position - (marker-buffer button))) - (goto-char pos)) - (setq origin (selected-window)) - (recenter)) - (select-window origin))) - - -;;;###package helm -;;;###package helm-ag -(when (modulep! :completion helm) - (setq helm-default-display-buffer-functions '(+popup-display-buffer-stacked-side-window-fn)) - - ;; Fix #897: "cannot open side window" error when TAB-completing file links - (defadvice! +popup--helm-hide-org-links-popup-a (fn &rest args) - :around #'org-insert-link - (letf! ((defun org-completing-read (&rest args) - (when-let (win (get-buffer-window "*Org Links*")) - ;; While helm is opened as a popup, it will mistaken the *Org - ;; Links* popup for the "originated window", and will target it - ;; for actions invoked by the user. However, since *Org Links* - ;; is a popup too (they're dedicated side windows), Emacs - ;; complains about being unable to split a side window. The - ;; simple fix: get rid of *Org Links*! - (delete-window win) - ;; ...but it must exist for org to clean up later. - (get-buffer-create "*Org Links*")) - (apply org-completing-read args))) - (apply #'funcall-interactively fn args))) - - ;; Fix left-over popup window when closing persistent help for `helm-M-x' - (defadvice! +popup--helm-elisp--persistent-help-a (candidate _fun &optional _name) - :before #'helm-elisp--persistent-help - (let (win) - (and (helm-attr 'help-running-p) - (string= candidate (helm-attr 'help-current-symbol)) - (setq win (get-buffer-window (get-buffer (help-buffer)))) - (delete-window win))))) - - -;;;###package Info -(defadvice! +popup--switch-to-info-window-a (&rest _) - :after #'info-lookup-symbol - (when-let (win (get-buffer-window "*info*")) - (when (+popup-window-p win) - (select-window win)))) - - -;;;###package latex -(defadvice! +popup--use-popup-window-for-reftex-citation-a (fn &rest args) - :around #'reftex-do-citation - (letf! ((#'switch-to-buffer-other-window #'pop-to-buffer)) - (apply fn args))) - - -;;;###package org -(after! org - (defadvice! +popup--suppress-delete-other-windows-a (fn &rest args) - "Org has a scorched-earth window management policy I'm not fond of. i.e. it -kills all other windows just so it can monopolize the frame. No thanks. We can -do better." - :around #'org-add-log-note - :around #'org-capture-place-template - :around #'org-export--dispatch-ui - :around #'org-agenda-get-restriction-and-command - :around #'org-goto-location - :around #'org-fast-tag-selection - :around #'org-fast-todo-selection - (if +popup-mode - (letf! ((#'delete-other-windows #'ignore) - (#'delete-window #'ignore)) - (apply fn args)) - (apply fn args))) - - (defadvice! +popup--org-fix-goto-a (fn &rest args) - "`org-goto' uses `with-output-to-temp-buffer' to display its help buffer, -for some reason, which is very unconventional, and so requires these gymnastics -to tame (i.e. to get the popup manager to handle it)." - :around #'org-goto-location - (if +popup-mode - (letf! (defun internal-temp-output-buffer-show (buffer) - (let ((temp-buffer-show-function - (doom-rpartial #'+popup-display-buffer-stacked-side-window-fn nil))) - (with-current-buffer buffer - (+popup-buffer-mode +1)) - (funcall internal-temp-output-buffer-show buffer))) - (apply fn args)) - (apply fn args))) - - (defadvice! +popup--org-fix-popup-window-shrinking-a (fn &rest args) - "Hides the mode-line in *Org tags* buffer so you can actually see its -content and displays it in a side window without deleting all other windows. -Ugh, such an ugly hack." - :around #'org-fast-tag-selection - :around #'org-fast-todo-selection - (if +popup-mode - (letf! ((defun read-char-exclusive (&rest args) - (message nil) - (apply read-char-exclusive args)) - (defun split-window-vertically (&optional _size) - (funcall split-window-vertically (- 0 window-min-height 1))) - (defun org-fit-window-to-buffer (&optional window max-height min-height shrink-only) - (when-let (buf (window-buffer window)) - (with-current-buffer buf - (+popup-buffer-mode))) - (when (> (window-buffer-height window) - (window-height window)) - (fit-window-to-buffer window (window-buffer-height window))))) - (apply fn args)) - (apply fn args))) - - (defadvice! +popup--org-edit-src-exit-a (fn &rest args) - "If you switch workspaces or the src window is recreated..." - :around #'org-edit-src-exit - (let* ((window (selected-window)) - (popup-p (+popup-window-p window))) - (prog1 (apply fn args) - (when (and popup-p (window-live-p window)) - (delete-window window))))) - - ;; Ensure todo, agenda, and other minor popups are delegated to the popup system. - (defadvice! +popup--org-pop-to-buffer-a (fn buf &optional norecord) - "Use `pop-to-buffer' instead of `switch-to-buffer' to open buffer.'" - :around #'org-switch-to-buffer-other-window - (if +popup-mode - (pop-to-buffer buf nil norecord) - (funcall fn buf norecord)))) - - -;;;###package org-journal -(defadvice! +popup--use-popup-window-a (fn &rest args) - :around #'org-journal-search-by-string - (letf! ((#'switch-to-buffer #'pop-to-buffer)) - (apply fn args))) - - -;;;###package persp-mode -(defadvice! +popup--persp-mode-restore-popups-a (&rest _) - "Restore popup windows when loading a perspective from file." - :after #'persp-load-state-from-file - (dolist (window (window-list)) - (when (+popup-parameter 'popup window) - (+popup--init window nil)))) - - -;;;###package pdf-tools -(after! pdf-tools - (setq tablist-context-window-display-action - '((+popup-display-buffer-stacked-side-window-fn) - (side . left) - (slot . 2) - (window-height . 0.3) - (inhibit-same-window . t)) - pdf-annot-list-display-buffer-action - '((+popup-display-buffer-stacked-side-window-fn) - (side . left) - (slot . 3) - (inhibit-same-window . t)))) - - -;;;###package profiler -(defadvice! +popup--profiler-report-find-entry-in-other-window-a (fn function) - :around #'profiler-report-find-entry - (letf! ((#'find-function #'find-function-other-window)) - (funcall fn function))) - - -;;;###package undo-tree -(defadvice! +popup--use-popup-window-for-undo-tree-visualizer-a (fn &rest args) - "TODO" - :around #'undo-tree-visualize - (if undo-tree-visualizer-diff - (apply fn args) - (letf! ((#'switch-to-buffer-other-window #'pop-to-buffer)) - (apply fn args)))) - -;;;###package wgrep -(progn - ;; close the popup after you're done with a wgrep buffer - (advice-add #'wgrep-abort-changes :after #'+popup-close-a) - (advice-add #'wgrep-finish-edit :after #'+popup-close-a)) - - -;;;###package which-key -(after! which-key - (when (eq which-key-popup-type 'side-window) - (setq which-key-popup-type 'custom - which-key-custom-popup-max-dimensions-function - (lambda (_) (which-key--side-window-max-dimensions)) - which-key-custom-hide-popup-function #'which-key--hide-buffer-side-window - which-key-custom-show-popup-function - (lambda (act-popup-dim) - (letf! (defun display-buffer-in-side-window (buffer alist) - (+popup-display-buffer-stacked-side-window-fn - buffer (append '((vslot . -9999) (select . t)) alist))) - ;; HACK Fix #2219 where the which-key popup would get cut off. - (setcar act-popup-dim (1+ (car act-popup-dim))) - (which-key--show-buffer-side-window act-popup-dim)))))) - - -;;;###package windmove -;; Users should be able to hop into popups easily, but Elisp shouldn't. -(defadvice! +popup--ignore-window-parameters-a (fn &rest args) - "Allow *interactive* window moving commands to traverse popups." - :around '(windmove-up windmove-down windmove-left windmove-right) - (letf! (defun windmove-find-other-window (dir &optional arg window) - (window-in-direction - (pcase dir (`up 'above) (`down 'below) (_ dir)) - window (bound-and-true-p +popup-mode) arg windmove-wrap-around t)) - (apply fn args))) diff --git a/.config/emacs/modules/ui/popup/README.org b/.config/emacs/modules/ui/popup/README.org @@ -1,160 +0,0 @@ -#+title: :ui popup -#+subtitle: Tame sudden yet inevitable temporary windows -#+created: January 06, 2018 -#+since: 21.12.0 - -* Description :unfold: -This module provides a customizable popup window management system. - -Not all windows are created equally. Some are less important. Some I want gone -once they have served their purpose, like code output or a help buffer. Others I -want to stick around, like a scratch buffer or org-capture popup. - -More than that, popups ought to be the second class citizens of my editor; -spawned off to the side, discarded with the push of a button (e.g. [[kbd:][ESC]] or [[kbd:][C-g]]), -and easily restored if I want to see them again. Of course, this system should -clean up after itself and kill off buffers I mark as transient. - -** Maintainers -- [[doom-user:][@hlissner]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +all :: - Enable fallback rules to ensure all temporary/special buffers (whose name - begins with a space or asterix) are treated as popups. -- +defaults :: - Enable reasonable default popup rules for a variety of buffers. - -** Packages -/This module doesn't install any packages./ - -** Hacks -- [[doom-package:help-mode]] has been advised to follow file links in the buffer you were in - before entering the popup, rather than in a new window. -- [[doom-package:wgrep]] buffers are advised to close themselves when aborting or committing - changes. -- [[doom-package:persp-mode]] is advised to restore popup windows when loading a session from - file. -- Interactive calls to ~windmove-*~ commands (used by ~evil-window-*~ commands) - will ignore the ~no-other-window~ window parameter, allowing you to switch to - popup windows as if they're ordinary windows. -- ~balance-windows~ has been advised to close popups while it does its business, - then restore them afterwards. -- [[doom-package:neotree]] advises ~balance-windows~, which causes major slow-downs when paired - with our ~balance-window~ advice, so we removes neotree's advice. -- [[doom-package:org-mode]] is an ongoing (and huge) effort. It has a scorched-earth window - management system I'm not fond of. ie. it kills all windows and monopolizes - the frame. On top of that, it /really/ likes to use ~switch-to-buffer~ for - most of its buffer management, which completely bypasses - ~display-buffer-alist~. Some work has gone into reversing this. - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** ~set-popup-rule!~ and ~set-popup-rules!~ -This module has two functions for defining your own rules for popups: -#+begin_src emacs-lisp -(set-popup-rule! PREDICATE &key IGNORE ACTIONS SIDE SIZE WIDTH HEIGHT SLOT VSLOT TTL QUIT SELECT MODELINE AUTOSAVE PARAMETERS) -(set-popup-rules! &rest RULESETS) -#+end_src - -~PREDICATE~ is a predicate function or regexp string to match against the -buffer's name. You'll find comprehensive documentation on the other keywords in -~set-popup-rule!~'s docstring ([[kbd:][SPC h f set-popup-rule!]]). - -#+begin_quote - 📌 Popup rules end up in ~display-buffer-alist~, which instructs - ~display-buffer~ calls on how to set up windows for buffers that meet - certain conditions. However, some plugins can avoid it entirely if they use - ~set-buffer~ or ~switch-to-buffer~, which don't obey ~display-buffer-alist~. -#+end_quote - -Multiple popup rules can be defined with ~set-popup-rules!~: -#+begin_src emacs-lisp -(set-popup-rules! - '(("^ \\*" :slot -1) ; fallback rule for special buffers - ("^\\*" :select t) - ("^\\*Completions" :slot -1 :ttl 0) - ("^\\*\\(?:scratch\\|Messages\\)" :ttl t) - ("^\\*Help" :slot -1 :size 0.2 :select t) - ("^\\*doom:" - :size 0.35 :select t :modeline t :quit t :ttl t))) -#+end_src - -Omitted parameters in a ~set-popup-rules!~ will use the defaults set in -~+popup-defaults~. - -** Disabling hidden mode-line in popups -By default, the mode-line is hidden in popups. To disable this, you can either: - -1. Change the default ~:modeline~ property in ~+popup-defaults~: - #+begin_src emacs-lisp - ;; in $DOOMDIR/config.el - (plist-put +popup-defaults :modeline t) - #+end_src - - A value of ~t~ will instruct popups to use the default mode-line. Any popup - rule with a ~:modeline~ property can still override this. - -2. Completely disable management of the mode-line in popups: - #+begin_src emacs-lisp - ;; in $DOOMDIR/config.el - (remove-hook '+popup-buffer-mode-hook #'+popup-set-modeline-on-enable-h) - #+end_src - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 /This module's appendix is incomplete./ [[doom-contrib-module:][Write more?]] -#+end_quote - -** Commands -- ~+popup/other~ (aliased to ~other-popup~, bound to [[kbd:][C-x p]]) -- ~+popup/toggle~ -- ~+popup/close~ -- ~+popup/close-all~ -- ~+popup/toggle~ -- ~+popup/restore~ -- ~+popup/raise~ -** Library -- Functions - - ~+popup-window-p WINDOW~ - - ~+popup-buffer-p BUFFER~ - - ~+popup-buffer BUFFER &optional ALIST~ - - ~+popup-parameter PARAMETER &optional WINDOW~ - - ~+popup-parameter-fn PARAMETER &optional WINDOW~ - - ~+popup-windows~ -- Macros - - ~without-popups!~ - - ~save-popups!~ -- Hooks - - ~+popup-adjust-fringes-h~ - - ~+popup|set-modeline~ - - ~+popup-close-on-escape-h~ - - ~+popup-cleanup-rules-h~ -- Minor modes - - ~+popup-mode~ - - ~+popup-buffer-mode~ diff --git a/.config/emacs/modules/ui/popup/autoload/popup.el b/.config/emacs/modules/ui/popup/autoload/popup.el @@ -1,614 +0,0 @@ -;;; ui/popup/autoload/popup.el -*- lexical-binding: t; -*- - -(defvar +popup--internal nil) - -(defun +popup--remember (windows) - "Remember WINDOWS (a list of windows) for later restoration." - (cl-assert (cl-every #'windowp windows) t) - (setq +popup--last - (cl-loop for w in windows - collect (cons (window-buffer w) - (window-state-get w))))) - -(defun +popup--kill-buffer (buffer ttl) - "Tries to kill BUFFER, as was requested by a transient timer. If it fails, eg. -the buffer is visible, then set another timer and try again later." - (let ((inhibit-quit t)) - (cond ((not (buffer-live-p buffer))) - ((not (get-buffer-window buffer t)) - (with-demoted-errors "Error killing transient buffer: %s" - (with-current-buffer buffer - (let ((kill-buffer-hook (remq '+popup-kill-buffer-hook-h kill-buffer-hook)) - confirm-kill-processes) - (when-let (process (get-buffer-process buffer)) - (when (eq (process-type process) 'real) - (kill-process process))) - (let (kill-buffer-query-functions) - ;; HACK The debugger backtrace buffer, when killed, called - ;; `top-level'. This causes jumpiness when the popup - ;; manager tries to clean it up. - (cl-letf (((symbol-function #'top-level) #'ignore)) - (kill-buffer buffer))))))) - ((let ((ttl (if (= ttl 0) - (or (plist-get +popup-defaults :ttl) 3) - ttl))) - (with-current-buffer buffer - (setq +popup--timer - (run-at-time ttl nil #'+popup--kill-buffer buffer ttl)))))))) - -(defun +popup--delete-window (window) - "Do housekeeping before destroying a popup window. - -+ Disables `+popup-buffer-mode' so that any hooks attached to it get a chance to - run and do cleanup of its own. -+ Either kills the buffer or sets a transient timer, if the window has a - `transient' window parameter (see `+popup-window-parameters'). -+ And finally deletes the window!" - (let ((buffer (window-buffer window)) - (inhibit-quit t)) - (and (or (buffer-file-name buffer) - (if-let (base-buffer (buffer-base-buffer buffer)) - (buffer-file-name base-buffer))) - (buffer-modified-p buffer) - (let ((autosave (+popup-parameter 'autosave window))) - (cond ((eq autosave 't)) - ((null autosave) - (y-or-n-p "Popup buffer is modified. Save it?")) - ((functionp autosave) - (funcall autosave buffer)))) - (with-current-buffer buffer (save-buffer))) - (let ((ignore-window-parameters t)) - (if-let (wconf (window-parameter window 'saved-wconf)) - (set-window-configuration wconf) - (delete-window window))) - (unless (window-live-p window) - (with-current-buffer buffer - (set-buffer-modified-p nil) - (+popup-buffer-mode -1) - (unless +popup--inhibit-transient - (let ((ttl (+popup-parameter 'ttl window))) - (when (eq ttl 't) - (setq ttl (plist-get +popup-defaults :ttl))) - (cond ((null ttl)) - ((functionp ttl) - (funcall ttl buffer)) - ((not (integerp ttl)) - (signal 'wrong-type-argument (list 'integerp ttl))) - ((= ttl 0) - (+popup--kill-buffer buffer 0)) - ((add-hook 'kill-buffer-hook #'+popup-kill-buffer-hook-h nil t) - (setq +popup--timer - (run-at-time ttl nil #'+popup--kill-buffer - buffer ttl)))))))))) - -(defun +popup--delete-other-windows (window) - "Fixes `delete-other-windows' when used from a popup window." - (when-let (window (ignore-errors (+popup/raise window))) - (let ((ignore-window-parameters t)) - (delete-other-windows window))) - nil) - -(defun +popup--normalize-alist (alist) - "Merge `+popup-default-alist' and `+popup-default-parameters' with ALIST." - (when alist - (let ((alist ; handle defaults - (cl-remove-duplicates - (append alist +popup-default-alist) - :key #'car-safe :from-end t)) - (parameters - (cl-remove-duplicates - (append (cdr (assq 'window-parameters alist)) - +popup-default-parameters) - :key #'car-safe :from-end t))) - ;; handle `size' - (when-let* ((size (cdr (assq 'size alist))) - (side (or (cdr (assq 'side alist)) 'bottom)) - (param (if (memq side '(left right)) - 'window-width - 'window-height))) - (setq list (assq-delete-all 'size alist)) - (setf (alist-get param alist) size)) - (setf (alist-get 'window-parameters alist) - parameters) - ;; Fixes #1305: addresses an edge case where a popup with a :size, :width - ;; or :height greater than the current frame's dimensions causes - ;; hanging/freezing (a bug in Emacs' `display-buffer' API perhaps?) - (let ((width (cdr (assq 'window-width alist))) - (height (cdr (assq 'window-height alist)))) - (setf (alist-get 'window-width alist) - (if (numberp width) - (min width (frame-width)) - width)) - (setf (alist-get 'window-height alist) - (if (numberp height) - (min height (frame-height)) - height)) - alist)))) - -(defun +popup--split-window (window size side) - "Ensure a non-dedicated/popup window is selected when splitting a window." - (unless +popup--internal - (cl-loop for win - in (cons (or window (selected-window)) - (window-list nil 0 window)) - unless (+popup-window-p win) - return (setq window win))) - (let ((ignore-window-parameters t)) - (split-window window size side))) - -(defun +popup--maybe-select-window (window origin) - "Select a window based on `+popup--inhibit-select' and this window's `select' parameter." - (unless +popup--inhibit-select - (let ((select (+popup-parameter 'select window))) - (if (functionp select) - (funcall select window origin) - (select-window (if select window origin)))))) - -;;;###autoload -(defun +popup--init (window &optional alist) - "Initializes a popup window. Run any time a popup is opened. It sets the -default window parameters for popup windows, clears leftover transient timers -and enables `+popup-buffer-mode'." - (with-selected-window window - (setq alist (delq (assq 'actions alist) alist)) - (set-window-parameter window 'popup t) - (set-window-parameter window 'split-window #'+popup--split-window) - (set-window-parameter window 'delete-window #'+popup--delete-window) - (set-window-parameter window 'delete-other-windows #'+popup--delete-other-windows) - (set-window-dedicated-p window 'popup) - (window-preserve-size - window (memq (window-parameter window 'window-side) - '(left right)) - t) - (+popup-buffer-mode +1) - (run-hooks '+popup-create-window-hook))) - - -;; -;; Public library - -;;;###autoload -(defun +popup-buffer-p (&optional buffer) - "Return non-nil if BUFFER is a popup buffer. Defaults to the current buffer." - (when +popup-mode - (let ((buffer (or buffer (current-buffer)))) - (and (bufferp buffer) - (buffer-live-p buffer) - (buffer-local-value '+popup-buffer-mode buffer) - buffer)))) - -;;;###autoload -(defun +popup-window-p (&optional window) - "Return non-nil if WINDOW is a popup window. Defaults to the current window." - (when +popup-mode - (let ((window (or window (selected-window)))) - (and (windowp window) - (window-live-p window) - (window-parameter window 'popup) - window)))) - -;;;###autoload -(defun +popup-buffer (buffer &optional alist) - "Open BUFFER in a popup window. ALIST describes its features." - (let* ((origin (selected-window)) - (window-min-height 3) - (alist (+popup--normalize-alist alist)) - (actions (or (cdr (assq 'actions alist)) - +popup-default-display-buffer-actions))) - (or (let* ((alist (remove (assq 'window-width alist) alist)) - (alist (remove (assq 'window-height alist) alist)) - (window (display-buffer-reuse-window buffer alist))) - (when window - (+popup--maybe-select-window window origin) - window)) - (when-let (popup (cl-loop for func in actions - if (funcall func buffer alist) - return it)) - (+popup--init popup alist) - (+popup--maybe-select-window popup origin) - popup)))) - -;;;###autoload -(defun +popup-parameter (parameter &optional window) - "Fetch the window PARAMETER (symbol) of WINDOW" - (window-parameter (or window (selected-window)) parameter)) - -;;;###autoload -(defun +popup-parameter-fn (parameter &optional window &rest args) - "Fetch the window PARAMETER (symbol) of WINDOW. If it is a function, run it -with ARGS to get its return value." - (let ((val (+popup-parameter parameter window))) - (if (functionp val) - (apply val args) - val))) - -;;;###autoload -(defun +popup-windows () - "Returns a list of all popup windows." - (cl-remove-if-not #'+popup-window-p (window-list))) - -;;;###autoload -(defun +popup-shrink-to-fit (&optional window) - "Shrinks WINDOW to fit the buffer contents, if the buffer isn't empty. - -Uses `shrink-window-if-larger-than-buffer'." - (unless window - (setq window (selected-window))) - (unless (= (- (point-max) (point-min)) 0) - (shrink-window-if-larger-than-buffer window))) - -;;;###autoload -(defun +popup-alist-from-window-state (state) - "Convert window STATE (from `window-state-get') to a `display-buffer' alist." - (let* ((params (alist-get 'parameters state))) - `((side . ,(alist-get 'window-side params)) - (window-width . ,(alist-get 'total-width state)) - (window-height . ,(alist-get 'total-height state)) - (window-parameters ,@params)))) - - -;; -;; Hooks - -;;;###autoload -(defun +popup-adjust-fringes-h () - "Hides the fringe in popup windows, restoring them if `+popup-buffer-mode' is -disabled." - (let ((f (if (bound-and-true-p +popup-buffer-mode) 0))) - (set-window-fringes nil f f fringes-outside-margins))) - -;;;###autoload -(defun +popup-adjust-margins-h () - "Creates padding for the popup window determined by `+popup-margin-width', -restoring it if `+popup-buffer-mode' is disabled." - (when +popup-margin-width - (unless (memq (window-parameter nil 'window-side) '(left right)) - (let ((m (if (bound-and-true-p +popup-buffer-mode) +popup-margin-width))) - (set-window-margins nil m m))))) - -(defvar hide-mode-line-format) -;;;###autoload -(defun +popup-set-modeline-on-enable-h () - "Don't show modeline in popup windows without a `modeline' window-parameter. -Possible values for this parameter are: - - t show the mode-line as normal - nil hide the modeline entirely (the default) - a function `mode-line-format' is set to its return value - -Any non-nil value besides the above will be used as the raw value for -`mode-line-format'." - (when (bound-and-true-p +popup-buffer-mode) - (let ((modeline (+popup-parameter 'modeline))) - (cond ((eq modeline 't)) - ((null modeline) - ;; TODO use `mode-line-format' window parameter instead (emacs 26+) - (hide-mode-line-mode +1)) - ((let ((hide-mode-line-format - (if (functionp modeline) - (funcall modeline) - modeline))) - (hide-mode-line-mode +1))))))) -(put '+popup-set-modeline-on-enable-h 'permanent-local-hook t) - -;;;###autoload -(defun +popup-unset-modeline-on-disable-h () - "Restore the modeline when `+popup-buffer-mode' is deactivated." - (when (and (not (bound-and-true-p +popup-buffer-mode)) - (bound-and-true-p hide-mode-line-mode)) - (hide-mode-line-mode -1))) - -;;;###autoload -(defun +popup-close-on-escape-h () - "If called inside a popup, try to close that popup window (see -`+popup/close'). If called outside, try to close all popup windows (see -`+popup/close-all')." - (if (+popup-window-p) - (+popup/close) - (+popup/close-all))) - -;;;###autoload -(defun +popup-cleanup-rules-h () - "Cleans up any duplicate popup rules." - (interactive) - (setq +popup--display-buffer-alist - (cl-delete-duplicates +popup--display-buffer-alist - :key #'car :test #'equal :from-end t)) - (when +popup-mode - (setq display-buffer-alist +popup--display-buffer-alist))) - -;;;###autoload -(defun +popup-kill-buffer-hook-h () - "TODO" - (when-let (window (get-buffer-window)) - (when (+popup-window-p window) - (let ((+popup--inhibit-transient t)) - (+popup--delete-window window))))) - - -;; -;; Commands - -;;;###autoload -(defalias 'other-popup #'+popup/other) - -;;;###autoload -(defun +popup/buffer () - "Open this buffer in a popup window." - (interactive) - (let ((+popup-default-display-buffer-actions - '(+popup-display-buffer-stacked-side-window-fn)) - (display-buffer-alist +popup--display-buffer-alist) - (buffer (current-buffer))) - (push (+popup-make-rule "." +popup-defaults) display-buffer-alist) - (bury-buffer) - (pop-to-buffer buffer))) - -;;;###autoload -(defun +popup/other () - "Cycle through popup windows, like `other-window'. Ignores regular windows." - (interactive) - (if-let (popups (cl-remove-if-not - (lambda (w) (or (+popup-window-p w) - ;; This command should be able to hop between - ;; windows with a `no-other-window' - ;; parameter, since `other-window' won't. - (window-parameter w 'no-other-window))) - (window-list))) - (select-window (if (+popup-window-p) - (let ((window (selected-window))) - (or (car-safe (cdr (memq window popups))) - (car (delq window popups)) - (car popups))) - (car popups))) - (user-error "No popups are open"))) - -;;;###autoload -(defun +popup/close (&optional window force-p) - "Close WINDOW, if it's a popup window. - -This will do nothing if the popup's `quit' window parameter is either nil or -'other. This window parameter is ignored if FORCE-P is non-nil." - (interactive - (list (selected-window) - current-prefix-arg)) - (let ((window (or window (selected-window)))) - (when (and (+popup-window-p window) - (or force-p - (memq (+popup-parameter-fn 'quit window window) - '(t current)))) - (when +popup--remember-last - (+popup--remember (list window))) - (delete-window window) - t))) - -;;;###autoload -(defun +popup/close-all (&optional force-p) - "Close all open popup windows. - -This will ignore popups with an `quit' parameter that is either nil or 'current. -This window parameter is ignored if FORCE-P is non-nil." - (interactive "P") - (let (targets +popup--remember-last) - (dolist (window (+popup-windows)) - (when (or force-p - (memq (+popup-parameter-fn 'quit window window) - '(t other))) - (push window targets))) - (when targets - (+popup--remember targets) - (mapc #'delete-window targets) - t))) - -;;;###autoload -(defun +popup/toggle () - "Toggle any visible popups. -If no popups are available, display the *Messages* buffer in a popup window." - (interactive) - (let ((+popup--inhibit-transient t)) - (cond ((+popup-windows) (+popup/close-all t)) - ((ignore-errors (+popup/restore))) - ((display-buffer (get-buffer "*Messages*")))))) - -;;;###autoload -(defun +popup/restore () - "Restore the last popups that were closed, if any." - (interactive) - (unless +popup--last - (error "No popups to restore")) - (cl-loop for (buffer . state) in +popup--last - if (buffer-live-p buffer) - do (+popup-buffer buffer (+popup-alist-from-window-state state))) - (setq +popup--last nil) - t) - -;;;###autoload -(defun +popup/raise (window &optional arg) - "Raise the current popup window into a regular window and -return it. If prefix ARG, raise the current popup into a new -window and return that window." - (interactive - (list (selected-window) current-prefix-arg)) - (cl-check-type window window) - (unless (+popup-window-p window) - (user-error "Cannot raise a non-popup window")) - (let ((buffer (current-buffer)) - (+popup--inhibit-transient t) - +popup--remember-last) - (+popup/close window 'force) - (if arg - (pop-to-buffer buffer) - (switch-to-buffer buffer)) - (selected-window))) - -;;;###autoload -(defun +popup/diagnose () - "Reveal what popup rule will be used for the current buffer." - (interactive) - (if-let (rule (cl-loop with bname = (buffer-name) - for (pred . action) in display-buffer-alist - if (and (functionp pred) (funcall pred bname action)) - return (cons pred action) - else if (and (stringp pred) (string-match-p pred bname)) - return (cons pred action))) - (message "Rule matches: %s" rule) - (message "No popup rule for this buffer"))) - - -;; -;;; Advice - -;;;###autoload -(defun +popup-close-a (&rest _) - "TODO" - (+popup/close nil t)) - -;;;###autoload -(defun +popup-save-a (fn &rest args) - "Sets aside all popups before executing the original function, usually to -prevent the popup(s) from messing up the UI (or vice versa)." - (save-popups! (apply fn args))) - -;;;###autoload -(defun +popup-display-buffer-fullframe-fn (buffer alist) - "Displays the buffer fullscreen." - (let ((wconf (current-window-configuration))) - (when-let (window (or (display-buffer-reuse-window buffer alist) - (display-buffer-same-window buffer alist) - (display-buffer-pop-up-window buffer alist) - (display-buffer-use-some-window buffer alist))) - (set-window-parameter window 'saved-wconf wconf) - (add-to-list 'window-persistent-parameters '(saved-wconf . t)) - (delete-other-windows window) - window))) - -;;;###autoload -(defun +popup-display-buffer-stacked-side-window-fn (buffer alist) - "A `display-buffer' action that serves as an alternative to -`display-buffer-in-side-window', but allows for stacking popups with the `vslot' -alist entry. - -Accepts the same arguments as `display-buffer-in-side-window'. You must set -`window--sides-inhibit-check' to non-nil for this work properly." - (let* ((side (or (cdr (assq 'side alist)) 'bottom)) - (slot (or (cdr (assq 'slot alist)) 0)) - (vslot (or (cdr (assq 'vslot alist)) 0)) - (left-or-right (memq side '(left right))) - (display-buffer-mark-dedicated (or display-buffer-mark-dedicated 'popup))) - - (cond ((not (memq side '(top bottom left right))) - (error "Invalid side %s specified" side)) - ((not (numberp slot)) - (error "Invalid slot %s specified" slot)) - ((not (numberp vslot)) - (error "Invalid vslot %s specified" vslot))) - - (let* ((major (get-window-with-predicate - (lambda (window) - (and (eq (window-parameter window 'window-side) side) - (eq (window-parameter window 'window-vslot) vslot))) - nil)) - (reversed (window--sides-reverse-on-frame-p (selected-frame))) - (windows - (cond ((window-live-p major) - (list major)) - ((window-valid-p major) - (let* ((first (window-child major)) - (next (window-next-sibling first)) - (windows (list next first))) - (setq reversed (> (window-parameter first 'window-slot) - (window-parameter next 'window-slot))) - (while (setq next (window-next-sibling next)) - (setq windows (cons next windows))) - (if reversed windows (nreverse windows)))))) - (slots (if major (max 1 (window-child-count major)))) - (max-slots - (nth (plist-get '(left 0 top 1 right 2 bottom 3) side) - window-sides-slots)) - (window--sides-inhibit-check t) - window this-window this-slot prev-window next-window - best-window best-slot abs-slot) - - (cond ((and (numberp max-slots) (<= max-slots 0)) - nil) - ((not windows) - (cl-letf (((symbol-function 'window--make-major-side-window-next-to) - (lambda (_side) (frame-root-window (selected-frame))))) - (when-let (window (window--make-major-side-window buffer side slot alist)) - (set-window-parameter window 'window-vslot vslot) - (add-to-list 'window-persistent-parameters '(window-vslot . writable)) - window))) - (t - ;; Scan windows on SIDE. - (catch 'found - (dolist (window windows) - (setq this-slot (window-parameter window 'window-slot)) - (cond ((not (numberp this-slot))) - ((= this-slot slot) ; A window with a matching slot found - (setq this-window window) - (throw 'found t)) - (t - ;; Check if this window has a better slot value wrt the - ;; slot of the window we want. - (setq abs-slot - (if (or (and (> this-slot 0) (> slot 0)) - (and (< this-slot 0) (< slot 0))) - (abs (- slot this-slot)) - (+ (abs slot) (abs this-slot)))) - (unless (and best-slot (<= best-slot abs-slot)) - (setq best-window window) - (setq best-slot abs-slot)) - (if reversed - (cond - ((<= this-slot slot) - (setq next-window window)) - ((not prev-window) - (setq prev-window window))) - (cond - ((<= this-slot slot) - (setq prev-window window)) - ((not next-window) - (setq next-window window)))))))) - - ;; `this-window' is the first window with the same SLOT. - ;; `prev-window' is the window with the largest slot < SLOT. A new - ;; window will be created after it. - ;; `next-window' is the window with the smallest slot > SLOT. A new - ;; window will be created before it. - ;; `best-window' is the window with the smallest absolute - ;; difference of its slot and SLOT. - (or (and this-window - ;; Reuse `this-window'. - (with-current-buffer buffer - (setq window--sides-shown t)) - (window--display-buffer - buffer this-window 'reuse alist)) - (and (or (not max-slots) (< slots max-slots)) - (or (and next-window - ;; Make new window before `next-window'. - (let ((next-side (if left-or-right 'above 'left)) - (+popup--internal t) - (window-combination-resize 'side)) - (setq window - (ignore-errors (split-window next-window nil next-side))))) - (and prev-window - ;; Make new window after `prev-window'. - (let ((prev-side (if left-or-right 'below 'right)) - (+popup--internal t) - (window-combination-resize 'side)) - (setq window - (ignore-errors (split-window prev-window nil prev-side)))))) - (set-window-parameter window 'window-slot slot) - (with-current-buffer buffer - (setq window--sides-shown t)) - (window--display-buffer - buffer window 'window alist)) - (and best-window - ;; Reuse `best-window'. - (progn - ;; Give best-window the new slot value. - (set-window-parameter best-window 'window-slot slot) - (with-current-buffer buffer - (setq window--sides-shown t)) - (window--display-buffer - buffer best-window 'reuse alist))))))))) diff --git a/.config/emacs/modules/ui/popup/autoload/settings.el b/.config/emacs/modules/ui/popup/autoload/settings.el @@ -1,190 +0,0 @@ -;;; ui/popup/autoload/settings.el -*- lexical-binding: t; -*- - -;;;###autoload -(defvar +popup--display-buffer-alist nil) - -;;;###autoload -(defvar +popup-defaults - (list :side 'bottom - :height 0.16 - :width 40 - :quit t - :select #'ignore - :ttl 5) - "Default properties for popup rules defined with `set-popup-rule!'.") - -;;;###autoload -(defun +popup-make-rule (predicate plist) - (if (plist-get plist :ignore) - (list predicate nil) - (let* ((plist (append plist +popup-defaults)) - (alist - `((actions . ,(plist-get plist :actions)) - (side . ,(plist-get plist :side)) - (size . ,(plist-get plist :size)) - (window-width . ,(plist-get plist :width)) - (window-height . ,(plist-get plist :height)) - (slot . ,(plist-get plist :slot)) - (vslot . ,(plist-get plist :vslot)))) - (params - `((ttl . ,(plist-get plist :ttl)) - (quit . ,(plist-get plist :quit)) - (select . ,(plist-get plist :select)) - (modeline . ,(plist-get plist :modeline)) - (autosave . ,(plist-get plist :autosave)) - ,@(plist-get plist :parameters)))) - `(,predicate (+popup-buffer) - ,@alist - (window-parameters ,@params))))) - -;;;###autodef -(defun set-popup-rule! (predicate &rest plist) - "Define a popup rule. - -These rules affect buffers displayed with `pop-to-buffer' and `display-buffer' -(or their siblings). Buffers displayed with `switch-to-buffer' (and its -variants) will not be affected by these rules (as they are unaffected by -`display-buffer-alist', which powers the popup management system). - -PREDICATE can be either a) a regexp string (matched against the buffer's name) -or b) a function that takes two arguments (a buffer name and the ACTION argument -of `display-buffer') and returns a boolean. - -PLIST can be made up of any of the following properties: - -:ignore BOOL - If BOOL is non-nil, popups matching PREDICATE will not be handled by the popup - system. Use this for buffers that have their own window management system like - magit or helm. - -:actions ACTIONS - ACTIONS is a list of functions or an alist containing (FUNCTION . ALIST). See - `display-buffer''s second argument for more information on its format and what - it accepts. If omitted, `+popup-default-display-buffer-actions' is used. - -:side 'bottom|'top|'left|'right - Which side of the frame to open the popup on. This is only respected if - `+popup-display-buffer-stacked-side-window-fn' or `display-buffer-in-side-window' - is in :actions or `+popup-default-display-buffer-actions'. - -:size/:width/:height FLOAT|INT|FN - Determines the size of the popup. If more than one of these size properties are - given :size always takes precedence, and is mapped with window-width or - window-height depending on what :side the popup is opened. Setting a height - for a popup that opens on the left or right is harmless, but comes into play - if two popups occupy the same :vslot. - - If a FLOAT (0 < x < 1), the number represents how much of the window will be - consumed by the popup (a percentage). - If an INT, the number determines the size in lines (height) or units of - character width (width). - If a function, it takes one argument: the popup window, and can do whatever it - wants with it, typically resize it, like `+popup-shrink-to-fit'. - -:slot/:vslot INT - (This only applies to popups with a :side and only if :actions is blank or - contains the `+popup-display-buffer-stacked-side-window-fn' action) These control - how multiple popups are laid out. INT can be any integer, positive and - negative. - - :slot controls lateral positioning (e.g. the horizontal positioning for - top/bottom popups, or vertical positioning for left/right popups). - :vslot controls popup stacking (from the edge of the frame toward the center). - - Let's assume popup A and B are opened with :side 'bottom, in that order. - If they possess the same :slot and :vslot, popup B will replace popup A. - If popup B has a higher :slot, it will open to the right of popup A. - If popup B has a lower :slot, it will open to the left of popup A. - If popup B has a higher :vslot, it will open above popup A. - If popup B has a lower :vslot, it will open below popup A. - -:ttl INT|BOOL|FN - Stands for time-to-live. It can be t, an integer, nil or a function. This - controls how (and if) the popup system will clean up after the popup. - - If any non-zero integer, wait that many seconds before killing the buffer (and - any associated processes). - If 0, the buffer is immediately killed. - If nil, the buffer won't be killed and is left to its own devices. - If t, resort to the default :ttl in `+popup-defaults'. If none exists, this is - the same as nil. - If a function, it takes one argument: the target popup buffer. The popup - system does nothing else and ignores the function's return value. - -:quit FN|BOOL|'other|'current - Can be t, 'other, 'current, nil, or a function. This determines the behavior - of the ESC/C-g keys in or outside of popup windows. - - If t, close the popup if ESC/C-g is pressed anywhere. - If 'other, close this popup if ESC/C-g is pressed outside of any popup. This - is great for popups you may press ESC/C-g a lot in. - If 'current, close the current popup if ESC/C-g is pressed from inside of the - popup. This makes it harder to accidentally close a popup until you really - want to. - If nil, pressing ESC/C-g will never close this popup. - If a function, it takes one argument: the to-be-closed popup window, and is - run when ESC/C-g is pressed while that popup is open. It must return one of - the other values to determine the fate of the popup. - -:select BOOL|FN - Can be a boolean or function. The boolean determines whether to focus the - popup window after it opens (non-nil) or focus the origin window (nil). - - If a function, it takes two arguments: the popup window and originating window - (where you were before the popup opened). The popup system does nothing else - and ignores the function's return value. - -:modeline BOOL|FN|LIST - Can be t (show the default modeline), nil (show no modeline), a function that - returns a modeline format or a valid value for `mode-line-format' to be used - verbatim. The function takes no arguments and is run in the context of the - popup buffer. - -:autosave BOOL|FN - This parameter determines what to do with modified buffers when closing popup - windows. It accepts t, 'ignore, a function or nil. - - If t, no prompts. Just save them automatically (if they're file-visiting - buffers). Same as 'ignore for non-file-visiting buffers. - If nil (the default), prompt the user what to do if the buffer is - file-visiting and modified. - If 'ignore, no prompts, no saving. Just silently kill it. - If a function, it is run with one argument: the popup buffer, and must return - non-nil to save or nil to do nothing (but no prompts). - -:parameters ALIST - An alist of custom window parameters. See `(elisp)Window Parameters'. - -If any of these are omitted, defaults derived from `+popup-defaults' will be -used. - -\(fn PREDICATE &key IGNORE ACTIONS SIDE SIZE WIDTH HEIGHT SLOT VSLOT TTL QUIT SELECT MODELINE AUTOSAVE PARAMETERS)" - (declare (indent defun)) - (push (+popup-make-rule predicate plist) +popup--display-buffer-alist) - (when (bound-and-true-p +popup-mode) - (setq display-buffer-alist +popup--display-buffer-alist)) - +popup--display-buffer-alist) - -;;;###autodef -(defun set-popup-rules! (&rest rulesets) - "Defines multiple popup rules. - -Every entry in RULESETS should be a list of alists where the CAR is the -predicate and CDR is a plist. See `set-popup-rule!' for details on the predicate -and plist. - -Example: - - (set-popup-rules! - '((\"^ \\*\" :slot 1 :vslot -1 :size #'+popup-shrink-to-fit) - (\"^\\*\" :slot 1 :vslot -1 :select t)) - '((\"^\\*Completions\" :slot -1 :vslot -2 :ttl 0) - (\"^\\*Compil\\(?:ation\\|e-Log\\)\" :size 0.3 :ttl 0 :quit t)))" - (declare (indent 0)) - (dolist (rules rulesets) - (dolist (rule rules) - (push (+popup-make-rule (car rule) (cdr rule)) - +popup--display-buffer-alist))) - (when (bound-and-true-p +popup-mode) - (setq display-buffer-alist +popup--display-buffer-alist)) - +popup--display-buffer-alist) diff --git a/.config/emacs/modules/ui/popup/config.el b/.config/emacs/modules/ui/popup/config.el @@ -1,181 +0,0 @@ -;;; ui/popup/config.el -*- lexical-binding: t; -*- - -(defconst +popup-window-parameters '(ttl quit select modeline popup) - "A list of custom parameters to be added to `window-persistent-parameters'. -Modifying this has no effect, unless done before ui/popup loads.") - -(defvar +popup-default-display-buffer-actions - '(+popup-display-buffer-stacked-side-window-fn) - "The functions to use to display the popup buffer.") - -(defvar +popup-default-alist - '((window-height . 0.16) ; remove later - (reusable-frames . visible)) - "The default alist for `display-buffer-alist' rules.") - -(defvar +popup-default-parameters - '((transient . t) ; remove later - (quit . t) ; remove later - (select . ignore) ; remove later - (no-other-window . t)) - "The default window parameters.") - -(defvar +popup-margin-width 1 - "Size of the margins to give popup windows. Set this to nil to disable margin -adjustment.") - -(defvar +popup--inhibit-transient nil) -(defvar +popup--inhibit-select nil) -(defvar +popup--old-display-buffer-alist nil) -(defvar +popup--remember-last t) -(defvar +popup--last nil) -(defvar-local +popup--timer nil) - - -;; -;; Global modes - -(defvar +popup-mode-map (make-sparse-keymap) - "Active keymap in a session with the popup system enabled. See -`+popup-mode'.") - -(defvar +popup-buffer-mode-map - (let ((map (make-sparse-keymap))) - (when (modulep! :editor evil) - ;; For maximum escape coverage in emacs state buffers; this only works in - ;; GUI Emacs, in tty Emacs use C-g instead - (define-key map [escape] #'doom/escape)) - map) - "Active keymap in popup windows. See `+popup-buffer-mode'.") - -(define-minor-mode +popup-mode - "Global minor mode representing Doom's popup management system." - :init-value nil - :global t - :keymap +popup-mode-map - (cond (+popup-mode - (add-hook 'doom-escape-hook #'+popup-close-on-escape-h 'append) - (setq +popup--old-display-buffer-alist display-buffer-alist - display-buffer-alist +popup--display-buffer-alist - window--sides-inhibit-check t) - (dolist (prop +popup-window-parameters) - (push (cons prop 'writable) window-persistent-parameters))) - (t - (remove-hook 'doom-escape-hook #'+popup-close-on-escape-h) - (setq display-buffer-alist +popup--old-display-buffer-alist - window--sides-inhibit-check nil) - (+popup-cleanup-rules-h) - (dolist (prop +popup-window-parameters) - (delq (assq prop window-persistent-parameters) - window-persistent-parameters))))) - -(define-minor-mode +popup-buffer-mode - "Minor mode for individual popup windows. - -It is enabled when a buffer is displayed in a popup window and disabled when -that window has been changed or closed." - :init-value nil - :keymap +popup-buffer-mode-map - (if (not +popup-buffer-mode) - (remove-hook 'after-change-major-mode-hook #'+popup-set-modeline-on-enable-h t) - (add-hook 'after-change-major-mode-hook #'+popup-set-modeline-on-enable-h - nil 'local) - (when (timerp +popup--timer) - (remove-hook 'kill-buffer-hook #'+popup-kill-buffer-hook-h t) - (cancel-timer +popup--timer) - (setq +popup--timer nil)))) - -(put '+popup-buffer-mode 'permanent-local t) -(put '+popup-buffer-mode 'permanent-local-hook t) -(put '+popup-set-modeline-on-enable-h 'permanent-local-hook t) - - -;; -;; Macros - -(defmacro with-popup-rules! (rules &rest body) - "Evaluate BODY with popup RULES. RULES is a list of popup rules. Each rule -should match the arguments of `+popup-define' or the :popup setting." - (declare (indent defun)) - `(let ((+popup--display-buffer-alist +popup--old-display-buffer-alist) - display-buffer-alist) - (set-popup-rules! ,rules) - (when (bound-and-true-p +popup-mode) - (setq display-buffer-alist +popup--display-buffer-alist)) - ,@body)) - -(defmacro save-popups! (&rest body) - "Sets aside all popups before executing the original function, usually to -prevent the popup(s) from messing up the UI (or vice versa)." - `(let* ((in-popup-p (+popup-buffer-p)) - (popups (+popup-windows)) - (+popup--inhibit-transient t) - buffer-list-update-hook - +popup--last) - (dolist (p popups) - (+popup/close p 'force)) - (unwind-protect - (progn ,@body) - (when popups - (let ((origin (selected-window))) - (+popup/restore) - (unless in-popup-p - (select-window origin))))))) - - -;; -;; Default popup rules & bootstrap - -(set-popup-rules! - (when (modulep! +all) - '(("^\\*" :slot 1 :vslot -1 :select t) - ("^ \\*" :slot 1 :vslot -1 :size +popup-shrink-to-fit))) - (when (modulep! +defaults) - '(("^\\*Completions" :ignore t) - ("^\\*Local variables\\*$" - :vslot -1 :slot 1 :size +popup-shrink-to-fit) - ("^\\*\\(?:[Cc]ompil\\(?:ation\\|e-Log\\)\\|Messages\\)" - :vslot -2 :size 0.3 :autosave t :quit t :ttl nil) - ("^\\*\\(?:doom \\|Pp E\\)" ; transient buffers (no interaction required) - :vslot -3 :size +popup-shrink-to-fit :autosave t :select ignore :quit t :ttl 0) - ("^\\*doom:" ; editing buffers (interaction required) - :vslot -4 :size 0.35 :autosave t :select t :modeline t :quit nil :ttl t) - ("^\\*doom:\\(?:v?term\\|e?shell\\)-popup" ; editing buffers (interaction required) - :vslot -5 :size 0.35 :select t :modeline nil :quit nil :ttl nil) - ("^\\*\\(?:Wo\\)?Man " - :vslot -6 :size 0.45 :select t :quit t :ttl 0) - ("^\\*Calc" - :vslot -7 :side bottom :size 0.4 :select t :quit nil :ttl 0) - ("^\\*Customize" - :slot 2 :side right :size 0.5 :select t :quit nil) - ("^ \\*undo-tree\\*" - :slot 2 :side left :size 20 :select t :quit t) - ;; `help-mode', `helpful-mode' - ("^\\*\\([Hh]elp\\|Apropos\\)" - :slot 2 :vslot -8 :size 0.42 :select t) - ("^\\*eww\\*" ; `eww' (and used by dash docsets) - :vslot -11 :size 0.35 :select t) - ("^\\*xwidget" - :vslot -11 :size 0.35 :select nil) - ("^\\*info\\*$" ; `Info-mode' - :slot 2 :vslot 2 :size 0.45 :select t))) - '(("^\\*Warnings" :vslot 99 :size 0.25) - ("^\\*Backtrace" :vslot 99 :size 0.4 :quit nil) - ("^\\*CPU-Profiler-Report " :side bottom :vslot 100 :slot 1 :height 0.4 :width 0.5 :quit nil) - ("^\\*Memory-Profiler-Report " :side bottom :vslot 100 :slot 2 :height 0.4 :width 0.5 :quit nil) - ("^\\*Process List\\*" :side bottom :vslot 101 :size 0.25 :select t :quit t) - ("^\\*\\(?:Proced\\|timer-list\\|Abbrevs\\|Output\\|Occur\\|unsent mail.*?\\|message\\)\\*" :ignore t))) - -(add-hook 'doom-init-ui-hook #'+popup-mode 'append) - -(add-hook! '+popup-buffer-mode-hook - #'+popup-adjust-fringes-h - #'+popup-adjust-margins-h - #'+popup-set-modeline-on-enable-h - #'+popup-unset-modeline-on-disable-h) - - -;; -;;; Hacks - -(load! "+hacks") diff --git a/.config/emacs/modules/ui/popup/test/test-popup.el b/.config/emacs/modules/ui/popup/test/test-popup.el @@ -1,212 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; ui/popup/test/test-popup.el - -(require! :ui popup) - -(describe "ui/popup" - :var (display-buffer-alist - +popup-default-display-buffer-actions - +popup--display-buffer-alist - +popup-defaults - wconf) - - (before-all - (delete-other-windows) - (switch-to-buffer "*scratch*") - (setq wconf (current-window-configuration)) - (+popup-mode +1)) - (after-all - (+popup-mode -1)) - - (before-each - (setq display-buffer-alist nil - +popup--display-buffer-alist nil - +popup-default-display-buffer-actions '(+popup-display-buffer-stacked-side-window-fn) - +popup-defaults '(:side bottom :select ignore :ttl nil :slot 1 :vslot 1))) - (after-each - (set-window-configuration wconf)) - - (describe "set-popup-rule!" - (it "sets popup rules" - (set-popup-rule! "does-not-exist" :size 10) - (let ((rule (cdr (assoc "does-not-exist" display-buffer-alist)))) - (expect rule :to-contain '(+popup-buffer)) - (expect rule :to-contain '(size . 10)))) - (it "shadows old rules" - (set-popup-rule! "a" :size 10) - (set-popup-rule! "a" :size 20) - (expect (cdr (assoc "a" display-buffer-alist)) - :to-contain '(size . 20))) - (it "resolves to defaults" - (let ((+popup-defaults '(:size 5))) - (set-popup-rule! "a") - (expect (cdr (assoc "a" display-buffer-alist)) - :to-contain '(size . 5))))) - - (describe "popup rules" - :var (origin a b c d e f g) - (before-all (setq origin (current-buffer))) - (before-each - (dolist (name '(a b c d e f g)) - (set name (get-buffer-create (symbol-name name))))) - (after-each - (let (kill-buffer-query-functions kill-buffer-hook) - (dolist (x (list a b c d e f g)) - (ignore-errors (delete-window (get-buffer-window x))) - (kill-buffer x)))) - - (describe "slot positioning" - (before-each - (set-popup-rules! - '(("a" :slot 1 :vslot 1) - ("b" :slot 2 :vslot 1) - ("c" :slot 1 :vslot 2) - ("d" :slot 2 :vslot 2) - ("e" :slot 1 :vslot 3) - ("f" :slot 1 :vslot 3) - ("g")))) - - (it "replaces popups with the same slots" - (mapc #'display-buffer (list e f)) - (expect (length (+popup-windows)) :to-be 1)) - - (it "replaces popups among multiple that have the same slots" - (let ((first (display-buffer a)) - (second (display-buffer b)) - (third (display-buffer e)) - (fourth (display-buffer f))) - (expect (+popup-windows) :to-have-same-items-as - (list first second fourth)))) - - (describe ":slot" - (it "opens left of others if lower" - (let ((first (display-buffer b)) - (second (display-buffer a))) - (expect (length (+popup-windows)) :to-be 2) - (expect (window-in-direction 'left first t) - :to-equal second))) - (it "opens right of others if higher" - (let ((first (display-buffer a)) - (second (display-buffer b))) - (expect (length (+popup-windows)) :to-be 2) - (expect (window-in-direction 'right first t) - :to-equal second))) - (it "obeys default :slot" - (let ((window (display-buffer g))) - (expect (window-parameter window 'window-slot) :to-be 1) - (expect (window-parameter window 'window-vslot) :to-be 1)))) - - (describe ":vslot" - ;; TODO Implement this, somehow - (xit "opens lower :vslot popups above others" - (let ((first (display-buffer c)) - (second (display-buffer a))) - (expect (length (+popup-windows)) :to-be 2) - (expect (window-in-direction 'above first t) - :to-equal second))) - (it "opens higher :vslot popups below others" - (let ((first (display-buffer c)) - (second (display-buffer e))) - (expect (length (+popup-windows)) :to-be 2) - (expect (window-in-direction 'below first t) - :to-equal second))))) - - (describe ":select" - (it "selects the popup if non-nil" - (set-popup-rule! "^a$" :select t) - (display-buffer a) - (expect (current-buffer) :to-equal a)) - (it "selects the originating window if nil" - (set-popup-rule! "^a$" :select nil) - (display-buffer a) - (expect (current-buffer) :to-equal origin)) - (it "fall back to base selection if passed #'ignore" - (spy-on 'ignore) - (set-popup-rule! "^a$" :select #'ignore) - (save-window-excursion - (display-buffer a) - (expect (current-buffer) :to-equal origin)) - (save-window-excursion - (pop-to-buffer a) - (expect (current-buffer) :to-equal a)) - (expect 'ignore :to-have-been-called-times 2))) - - (describe ":modeline" - (it "disables the mode-line if nil" - (set-popup-rule! "a" :modeline nil :select t) - (display-buffer a) - (expect mode-line-format :to-be nil)) - (it "uses the default mode-line if t" - (set-popup-rule! "a" :modeline t :select t) - (display-buffer a) - (expect mode-line-format :to-equal (default-value 'mode-line-format))) - (it "uses a predefined mode-line if passed a symbol" - (set-popup-rule! "a" :modeline '("x") :select t) - (display-buffer a) - (expect mode-line-format :to-equal '("x"))) - (it "runs the handler if passed a function" - (set-popup-rule! "a" :modeline (lambda () (setq mode-line-format '("x"))) :select t) - (display-buffer a) - (expect mode-line-format :to-equal '("x")))) - - ;; TODO - (xdescribe ":autosave") - - (describe ":quit" - (it "will close from anywhere if :quit = t" - (set-popup-rule! "a" :quit t) - (save-window-excursion - (display-buffer a) - (call-interactively #'+popup/close-all) - (expect (get-buffer-window a) :to-be nil)) - (save-window-excursion - (pop-to-buffer a) - (call-interactively #'+popup/close) - (expect (get-buffer-window a) :to-be nil))) - (it "will only close from outside if :quit = 'other" - (set-popup-rule! "a" :quit 'other) - (save-window-excursion - (display-buffer a) - (call-interactively #'+popup/close-all) - (expect (get-buffer-window a) :to-be nil)) - (save-window-excursion - (pop-to-buffer a) - (call-interactively #'+popup/close) - (expect (get-buffer-window a)))) - (it "will only close from inside if :quit = 'current" - (set-popup-rule! "a" :quit 'current) - (save-window-excursion - (display-buffer a) - (call-interactively #'+popup/close-all) - (expect (get-buffer-window a))) - (save-window-excursion - (pop-to-buffer a) - (call-interactively #'+popup/close) - (expect (get-buffer-window a) :to-be nil))) - (it "never close a if :quit = nil" - (set-popup-rule! "a" :quit nil) - (save-window-excursion - (display-buffer a) - (call-interactively #'+popup/close-all) - (expect (get-buffer-window a))) - (save-window-excursion - (pop-to-buffer a) - (call-interactively #'+popup/close) - (expect (get-buffer-window a))))) - - ;; TODO - (xdescribe ":ttl") - (xdescribe ":size") - (xdescribe ":width") - (xdescribe ":height") - (xdescribe ":side") - (xdescribe ":actions")) - - ;; TODO - (xdescribe "predicate functions" - (describe "buffer-p") - (describe "window-p")) - - ;; TODO - (xdescribe "save-popups!") - (xdescribe "with-popup-rules!")) diff --git a/.config/emacs/modules/ui/tabs/README.org b/.config/emacs/modules/ui/tabs/README.org @@ -1,49 +0,0 @@ -#+title: :ui tabs -#+subtitle: Keep tabs on your buffers, literally -#+created: July 12, 2019 -#+since: 21.12.0 - -* Description :unfold: -This module adds an Atom-esque tab bar to the Emacs UI. - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:centaur-tabs]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/ui/tabs/autoload.el b/.config/emacs/modules/ui/tabs/autoload.el @@ -1,18 +0,0 @@ -;;; ui/tabs/autoload.el -*- lexical-binding: t; -*- -;;;###if (modulep! :editor evil) - -;;;###autoload (autoload '+tabs:next-or-goto "ui/tabs/autoload" nil t) -(evil-define-command +tabs:next-or-goto (index) - "Switch to the next tab, or to INDEXth tab if a count is given." - (interactive "<c>") - (if index - (centaur-tabs-select-visible-nth-tab index) - (centaur-tabs-forward))) - -;;;###autoload (autoload '+tabs:previous-or-goto "ui/tabs/autoload" nil t) -(evil-define-command +tabs:previous-or-goto (index) - "Switch to the previous tab, or to INDEXth tab if a count is given." - (interactive "<c>") - (if index - (centaur-tabs-select-visible-nth-tab index) - (centaur-tabs-backward))) diff --git a/.config/emacs/modules/ui/tabs/config.el b/.config/emacs/modules/ui/tabs/config.el @@ -1,26 +0,0 @@ -;;; ui/tabs/config.el -*- lexical-binding: t; -*- - -(use-package! centaur-tabs - :hook (doom-first-file . centaur-tabs-mode) - :init - (setq centaur-tabs-set-icons t - centaur-tabs-gray-out-icons 'buffer - centaur-tabs-set-bar 'left - centaur-tabs-set-modified-marker t - centaur-tabs-close-button "✕" - centaur-tabs-modified-marker "•" - ;; Scrolling (with the mouse wheel) past the end of the tab list - ;; replaces the tab list with that of another Doom workspace. This - ;; prevents that. - centaur-tabs-cycle-scope 'tabs) - - :config - (add-hook! '(+doom-dashboard-mode-hook +popup-buffer-mode-hook) - (defun +tabs-disable-centaur-tabs-mode-maybe-h () - "Disable `centaur-tabs-mode' in current buffer." - (when (centaur-tabs-mode-on-p) - (centaur-tabs-local-mode))))) - - -;; TODO tab-bar-mode (emacs 27) -;; TODO tab-line-mode (emacs 27) diff --git a/.config/emacs/modules/ui/tabs/packages.el b/.config/emacs/modules/ui/tabs/packages.el @@ -1,4 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; ui/tabs/packages.el - -(package! centaur-tabs :pin "a2890d968d877b269a814a691356fc5877833c39") diff --git a/.config/emacs/modules/ui/treemacs/README.org b/.config/emacs/modules/ui/treemacs/README.org @@ -1,87 +0,0 @@ -#+title: :ui treemacs -#+subtitle: A sidebar for all the things -#+created: June 09, 2018 -#+since: 21.12.0 (#669) - -* Description :unfold: -[[doom-package:treemacs][Treemacs]] is a file and project explorer similar to NeoTree or vim's NerdTree, -but largely inspired by the Project Explorer in Eclipse. It shows the file -system outlines of your projects in a simple tree layout allowing quick -navigation and exploration, while also possessing basic file management -utilities. It includes: - -- Integration with Git (if [[doom-module::tools magit]] is enabled) -- Integration with Evil (if [[doom-module::editor evil +everywhere]] is enabled) -- Workspace awareness (if [[doom-module::ui workspaces]] is enabled) - -** Maintainers -- [[doom-user:][@hlissner]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +lsp :: - Enable ~lsp-treemacs~ integration and add shortcuts for common commands. - -** Packages -- [[doom-package:lsp-treemacs]] if [[doom-module:+lsp]] -- [[doom-package:treemacs]] -- [[doom-package:treemacs-evil]] if [[doom-module::editor evil +everywhere]] -- [[doom-package:treemacs-magit]] if [[doom-module::tools magit]] -- [[doom-package:treemacs-persp]] if [[doom-module::ui workspaces]] -- [[doom-package:treemacs-projectile]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -If =python3= is present on your =$PATH=, [[doom-package:treemacs]] will use it to display git -status for files. - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -The project bar can be opened using [[kbd:][SPC o p]]. - -| Keybind | Description | -|---------+------------------------------------------------------------------| -| [[kbd:][o s]] | Open a horizontal dired buffer on the currently highlighted node | -| [[kbd:][o v]] | Open a vertical dired buffer on the currently highlighted node | - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -The variable ~+treemacs-git-mode~ sets the type of git integration that treemacs -has. - -There are 3 possible values: -1. ~'simple~ (the default), which highlights only files based on their git - status, and is slightly faster, -2. ~'extended~, which highlights both files and directories, but requires - python, -3. ~'deferred~, same as extended, but highlights asynchronously. - -#+begin_quote - 🚧 ~+treemacs-git-mode~ must be set before treemacs is loaded. -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/ui/treemacs/autoload.el b/.config/emacs/modules/ui/treemacs/autoload.el @@ -1,17 +0,0 @@ -;;; ui/treemacs/autoload.el -*- lexical-binding: t; -*- - -;;;###autoload -(defun +treemacs/toggle () - "Initialize or toggle treemacs. - -Ensures that only the current project is present and all other projects have -been removed. - -Use `treemacs' command for old functionality." - (interactive) - (require 'treemacs) - (pcase (treemacs-current-visibility) - (`visible (delete-window (treemacs-get-local-window))) - (_ (if (doom-project-p) - (treemacs-add-and-display-current-project) - (treemacs))))) diff --git a/.config/emacs/modules/ui/treemacs/config.el b/.config/emacs/modules/ui/treemacs/config.el @@ -1,78 +0,0 @@ -;;; ui/treemacs/config.el -*- lexical-binding: t; -*- - -(defvar +treemacs-git-mode 'simple - "Type of git integration for `treemacs-git-mode'. - -There are 3 possible values: - - 1) `simple', which highlights only files based on their git status, and is - slightly faster, - 2) `extended', which highlights both files and directories, but requires - python, - 3) `deferred', same as extended, but highlights asynchronously. - -This must be set before `treemacs' has loaded.") - - -;; -;;; Packages - -(use-package! treemacs - :defer t - :init - (setq treemacs-follow-after-init t - treemacs-is-never-other-window t - treemacs-sorting 'alphabetic-case-insensitive-asc - treemacs-persist-file (concat doom-cache-dir "treemacs-persist") - treemacs-last-error-persist-file (concat doom-cache-dir "treemacs-last-error-persist")) - :config - ;; Don't follow the cursor - (treemacs-follow-mode -1) - - (set-popup-rule! "^ ?\\*Treemacs" :ignore t) - (when +treemacs-git-mode - ;; If they aren't supported, fall back to simpler methods - (when (and (memq +treemacs-git-mode '(deferred extended)) - (not (executable-find "python3"))) - (setq +treemacs-git-mode 'simple)) - (treemacs-git-mode +treemacs-git-mode) - (setq treemacs-collapse-dirs - (if (memq +treemacs-git-mode '(extended deferred)) - 3 - 0)))) - - -(use-package! treemacs-evil - :when (modulep! :editor evil +everywhere) - :defer t - :init - (after! treemacs (require 'treemacs-evil)) - (add-to-list 'doom-evil-state-alist '(?T . treemacs)) - :config - (define-key! evil-treemacs-state-map - [return] #'treemacs-RET-action - [tab] #'treemacs-TAB-action - "TAB" #'treemacs-TAB-action - ;; REVIEW Fix #1875 to be consistent with C-w {v,s}, but this should really - ;; be considered upstream. - "o v" #'treemacs-visit-node-horizontal-split - "o s" #'treemacs-visit-node-vertical-split)) - - -(use-package! treemacs-projectile - :after treemacs) - - -(use-package! treemacs-magit - :when (modulep! :tools magit) - :after treemacs magit) - - -(use-package! treemacs-persp - :when (modulep! :ui workspaces) - :after treemacs - :config (treemacs-set-scope-type 'Perspectives)) - -(use-package! lsp-treemacs - :when (modulep! +lsp) - :after (treemacs lsp)) diff --git a/.config/emacs/modules/ui/treemacs/doctor.el b/.config/emacs/modules/ui/treemacs/doctor.el @@ -1,5 +0,0 @@ -;;; ui/treemacs/doctor.el -*- lexical-binding: t; -*- - -(assert! (not (and (modulep! +lsp) - (modulep! :tools lsp +eglot))) - "+lsp flag is not supported with eglot, only with lsp-mode.") diff --git a/.config/emacs/modules/ui/treemacs/packages.el b/.config/emacs/modules/ui/treemacs/packages.el @@ -1,14 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; ui/treemacs/packages.el - -(package! treemacs :pin "9986d6cd3d2822db7ae0e6d8a275db7057f3e828") -;; These packages have no :pin because they're in the same repo -(when (modulep! :editor evil +everywhere) - (package! treemacs-evil)) -(package! treemacs-projectile) -(when (modulep! :tools magit) - (package! treemacs-magit)) -(when (modulep! :ui workspaces) - (package! treemacs-persp)) -(when (modulep! +lsp) - (package! lsp-treemacs :pin "a48763ba5d1c024426e237ce65926db849d3ae6f")) diff --git a/.config/emacs/modules/ui/unicode/README.org b/.config/emacs/modules/ui/unicode/README.org @@ -1,119 +0,0 @@ -#+title: :ui unicode -#+subtitle: Extended unicode support for various languages -#+created: June 08, 2020 -#+since: 2.0.0 - -* Description :unfold: -This module extends Doom's ability to display non-English unicode. It is -primarily useful for non-English Emacs users, for whom Doom's built-in unicode -support in insufficient. - -This module relies on the [[https://github.com/rolandwalker/unicode-fonts][unicode-fonts]] package. It tries to setup the default -emacs fontset to cover as many unicode glyphs as possible by scanning all -available glyphs from all available fonts. - -When this module is enabled: -- Emacs will prefer to use the ~doom-unicode-font~ font to display non-latin - glyphs if it provides coverage for them. -- The first time you run Emacs a unicode cache will be generated -- this will - take a while! -- The cache will be regenerated every time Emacs is made aware of new fonts or - you change the font configuration e.g. by modifying ~doom-unicode-font~. -- The cache will be stored and should not be regenerated unless font-related - configuration or the versions of relevant packages changes. - -** Maintainers -*This module needs a maintainer.* [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:unicode-fonts]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -The first font that will be analyzed to see if it contains the glyphs of -non-latin characters will be ~doom-unicode-font~: -#+begin_src emacs-lisp -;; in $DOOMDIR/config.el -(setq doom-unicode-font (font-spec :family "Fira Mono")) -#+end_src - -If your ~doom-font~ provides good unicode coverage use: -#+begin_src emacs-lisp -;; in $DOOMDIR/config.el -(setq doom-unicode-font doom-font) -#+end_src - -If your font does not provide some glyphs, this package will try its best to -find another font that does. - -** Getting fonts with good coverage -A list of fonts with good unicode coverage can be found on the page of the -[[https://github.com/rolandwalker/unicode-fonts#minimum-useful-fonts][unicode-fonts]] package. - -** Advanced configuration -Consult the [[https://github.com/rolandwalker/unicode-fonts][unicode-fonts]] package documentation for a description of more -advanced configuration. The configuration should be placed, as usual, in -=$DOOMDIR/config.el= wrapped in an ~(after! unicode-fonts)~ block. The variable -~unicode-fonts-blocks~ contains a list of all unicode block names and their -character ranges. The default fonts to search for glyphs are in the variable -~unicode-fonts-block-font-mapping~. - -If you want to use the font =Symbola= for =Miscellaneous Symbols= by default -use: -#+begin_src emacs-lisp -;; in $DOOMDIR/config.el -(after! unicode-fonts - (push "Symbola" (cadr (assoc "Miscellaneous Symbols" unicode-fonts-block-font-mapping)))) -#+end_src - -If you want to redefine several blocks an efficient way would be: -#+begin_src emacs-lisp -(after! unicode-fonts - (dolist (unicode-block '("Mathematical Alphanumeric Symbols" - "Mathematical Operators" - "Miscellaneous Mathematical Symbols-A" - "Miscellaneous Mathematical Symbols-B" - "Miscellaneous Symbols" - "Miscellaneous Symbols and Arrows" - "Miscellaneous Symbols and Pictographs")) - (push "DejaVu Math TeX Gyre" (cadr (assoc unicode-block unicode-fonts-block-font-mapping))))) -#+end_src - -You can find a list of fonts available to emacs using ~M-x counsel-fonts~. - -* Troubleshooting -[[doom-report:][Report an issue?]] - -** TODO Emacs daemon mode ([[doom-ref:][#3328]]) -This module may fail to setup fonts when emacs is run in a daemon session. - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/ui/unicode/autoload.el b/.config/emacs/modules/ui/unicode/autoload.el @@ -1,25 +0,0 @@ -;;; ui/unicode/autoload.el -*- lexical-binding: t; -*- - -;;;###autoload -(add-hook! 'after-setting-font-hook :depth -90 - (defun +unicode-init-fonts-h () - "Set up `unicode-fonts' to eventually run; accommodating the daemon, if -necessary." - (setq-default bidi-display-reordering t) - (+unicode-setup-fonts-h (selected-frame)))) - -;;;###autoload -(defun +unicode-setup-fonts-h (&optional frame) - "Initialize `unicode-fonts', if in a GUI session. - -If doom-unicode-font is set, add it as preferred font for all unicode blocks." - (when (and frame (display-multi-font-p frame)) - (with-selected-frame frame - (require 'unicode-fonts) - (when doom-unicode-font - (let ((doom-unicode-font-family (plist-get (font-face-attributes doom-unicode-font) :family))) - (dolist (unicode-block unicode-fonts-block-font-mapping) - (push doom-unicode-font-family (cadr unicode-block))))) - ;; NOTE: will impact startup time on first run - (let (inhibit-redisplay inhibit-message) - (unicode-fonts-setup))))) diff --git a/.config/emacs/modules/ui/unicode/packages.el b/.config/emacs/modules/ui/unicode/packages.el @@ -1,4 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; ui/unicode/packages.el - -(package! unicode-fonts :pin "44d0a22420c39709d1e1fa659a3f135facf3c986") diff --git a/.config/emacs/modules/ui/vc-gutter/README.org b/.config/emacs/modules/ui/vc-gutter/README.org @@ -1,84 +0,0 @@ -#+title: :ui vc-gutter -#+subtitle: Get your diff out of the gutter -#+created: June 26, 2018 -#+since: 21.12.0 - -* Description :unfold: -This module displays a diff of the current file (against HEAD) in the fringe. -Supports Git, Svn, Hg, and Bzr. - -** Maintainers -- [[doom-user:][@hlissner]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +diff-hl :: - Use [[doom-package:diff-hl]] instead of git-gutter to power the VC gutter. It is a little - faster, but is slightly more prone to visual glitching. [[doom-package:diff-hl]] is intended to - replace git-gutter at some point in the future. -- +pretty :: - Apply some stylistic defaults to the fringe, enabling thin bars in the fringe. - This look takes after the modern look of git-gutter in VSCode and Sublime - Text, without sacrificing on fringe width (which squeeze other indicators, - like flycheck's, flymake's, or flyspell's). However, this will look bad with - themes that invert the foreground/background of either git-gutter's or - diff-hl's faces (like modus-themes does). - -** Packages -- [[doom-package:git-gutter-fringe]] unless [[doom-module:+diff-hl]] -- [[doom-package:diff-hl]] if [[doom-module:+diff-hl]] - -** Hacks -- The VC gutter will be updated when pressing ESC, leaving insert mode (evil - users), or refocusing the frame or window where it is active. -- If [[doom-module:+pretty]] is enabled - - The fringes that both git-gutter-fringe and diff-hl define will be replaced - with a set of thin bars. This achieves a slicker look closer to git-gutter's - appearance in VSCode or Sublime Text, but may look weird for themes that - swap their faces' :foreground and :background (like modus-themes). - - The fringes are moved to the outside of the margins (closest to the frame - edge), so they have some breathing space away from the buffer's contents. -- If [[doom-package:+diff-hl]] is enabled: - - ~diff-hl-revert-hunk~ displays a preview popup of the hunk being reverted. - It takes up ~50% of the frame, by default, whether you're reverting 2 lines - or 20. Since this isn't easily customized, it has been advised to shrink - this popup to the side of its contents. - - ~diff-hl-revert-hunk~ will sometimes move the cursor to an unexpected - location (the bounds of hunks, is my guess), but this is not intuitive and - often unexpected. Cursor movements have been suppressed for it. -- If +diff-hl is *not* enabled: - - Sometimes, ~git-gutter:next-hunk~ and ~git-gutter:previous-hunk~ get - confused about the order of hunks. They have been advised to fix this - (although the hack is a little inefficient). - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -This module requires any of Git, Svn, Hg, and/or Bazaar to get gutter diffs in -projects version controlled by them. - -* TODO Usage -#+begin_quote -🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote -🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote -🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/ui/vc-gutter/autoload/diff-hl.el b/.config/emacs/modules/ui/vc-gutter/autoload/diff-hl.el @@ -1,11 +0,0 @@ -;;; ui/vc-gutter/autoload/diff-hl.el -*- lexical-binding: t; -*- -;;;###if (modulep! +diff-hl) - -;;;###autoload -(defalias '+vc-gutter/stage-hunk #'diff-hl-stage-current-hunk) -;;;###autoload -(defalias '+vc-gutter/revert-hunk #'diff-hl-revert-hunk) -;;;###autoload -(defalias '+vc-gutter/next-hunk #'diff-hl-next-hunk) -;;;###autoload -(defalias '+vc-gutter/previous-hunk #'diff-hl-previous-hunk) diff --git a/.config/emacs/modules/ui/vc-gutter/autoload/git-gutter.el b/.config/emacs/modules/ui/vc-gutter/autoload/git-gutter.el @@ -1,11 +0,0 @@ -;;; ui/vc-gutter/autoload/vc-gutter.el -*- lexical-binding: t; -*- -;;;###if (not (modulep! +diff-hl)) - -;;;###autoload -(defalias '+vc-gutter/stage-hunk #'git-gutter:stage-hunk) -;;;###autoload -(defalias '+vc-gutter/revert-hunk #'git-gutter:revert-hunk) -;;;###autoload -(defalias '+vc-gutter/next-hunk #'git-gutter:next-hunk) -;;;###autoload -(defalias '+vc-gutter/previous-hunk #'git-gutter:previous-hunk) diff --git a/.config/emacs/modules/ui/vc-gutter/config.el b/.config/emacs/modules/ui/vc-gutter/config.el @@ -1,220 +0,0 @@ -;;; ui/vc-gutter/config.el -*- lexical-binding: t; -*- - -;; TODO Implement me -(defvar +vc-gutter-in-margin nil - "If non-nil, use the margin for diffs instead of the fringe.") - -(defvar +vc-gutter-in-remote-files nil - "If non-nil, enable the vc gutter in remote files (e.g. open through TRAMP).") - - -;; -;;; Default styles - -(when (modulep! +pretty) - ;; UI: make the fringe small enough that the diff bars aren't too domineering, - ;; while leaving enough room for other indicators. - (if (fboundp 'fringe-mode) (fringe-mode '8)) - ;; UI: the gutter looks less cramped with some space between it and buffer. - (setq-default fringes-outside-margins t) - - ;; STYLE: Redefine fringe bitmaps to take up only half the horizontal space in - ;; the fringe. This way we avoid overbearingly large diff bars without - ;; having to shrink the fringe and sacrifice precious space for other fringe - ;; indicators (like flycheck or flyspell). - ;; REVIEW: Extract these into a package with faces that themes can target. - (if (not (modulep! +diff-hl)) - (after! git-gutter-fringe - (define-fringe-bitmap 'git-gutter-fr:added [224] - nil nil '(center repeated)) - (define-fringe-bitmap 'git-gutter-fr:modified [224] - nil nil '(center repeated)) - (define-fringe-bitmap 'git-gutter-fr:deleted [128 192 224 240] - nil nil 'bottom)) - (defadvice! +vc-gutter-define-thin-bitmaps-a (&rest args) - :override #'diff-hl-define-bitmaps - (define-fringe-bitmap 'diff-hl-bmp-middle [224] nil nil '(center repeated)) - (define-fringe-bitmap 'diff-hl-bmp-delete [240 224 192 128] nil nil 'top)) - (defun +vc-gutter-type-face-fn (type _pos) - (intern (format "diff-hl-%s" type))) - (defun +vc-gutter-type-at-pos-fn (type _pos) - (if (eq type 'delete) - 'diff-hl-bmp-delete - 'diff-hl-bmp-middle)) - (advice-add #'diff-hl-fringe-bmp-from-pos :override #'+vc-gutter-type-at-pos-fn) - (advice-add #'diff-hl-fringe-bmp-from-type :override #'+vc-gutter-type-at-pos-fn) - (setq diff-hl-draw-borders nil) - (add-hook! 'diff-hl-mode-hook - (defun +vc-gutter-fix-diff-hl-faces-h () - (mapc (doom-rpartial #'set-face-background nil) - '(diff-hl-insert - diff-hl-delete - diff-hl-change))))) - - ;; FIX: To minimize overlap between flycheck indicators and git-gutter/diff-hl - ;; indicators in the left fringe. - (after! flycheck - ;; Let diff-hl have left fringe, flycheck can have right fringe - (setq flycheck-indication-mode 'right-fringe) - ;; A non-descript, left-pointing arrow - (define-fringe-bitmap 'flycheck-fringe-bitmap-double-arrow - [16 48 112 240 112 48 16] nil nil 'center))) - - -;; -;;; git-gutter - -(use-package! git-gutter - :unless (modulep! +diff-hl) - :commands git-gutter:revert-hunk git-gutter:stage-hunk git-gutter:previous-hunk git-gutter:next-hunk - :init - (add-hook! 'find-file-hook - (defun +vc-gutter-init-maybe-h () - "Enable `git-gutter-mode' in the current buffer. -If the buffer doesn't represent an existing file, `git-gutter-mode's activation -is deferred until the file is saved. Respects `git-gutter:disabled-modes'." - (let ((file-name (buffer-file-name (buffer-base-buffer)))) - (cond - ((and (file-remote-p (or file-name default-directory)) - (not +vc-gutter-in-remote-files))) - ;; UX: If not a valid file, wait until it is written/saved to activate - ;; git-gutter. - ((not (and file-name (vc-backend file-name))) - (add-hook 'after-save-hook #'+vc-gutter-init-maybe-h nil 'local)) - ;; UX: Allow git-gutter or git-gutter-fringe to activate based on the - ;; type of frame we're in. This allows git-gutter to work for silly - ;; geese who open both tty and gui frames from the daemon. - ((if (and (display-graphic-p) - (require 'git-gutter-fringe nil t)) - (setq-local git-gutter:init-function #'git-gutter-fr:init - git-gutter:view-diff-function #'git-gutter-fr:view-diff-infos - git-gutter:clear-function #'git-gutter-fr:clear - git-gutter:window-width -1) - (setq-local git-gutter:init-function 'nil - git-gutter:view-diff-function #'git-gutter:view-diff-infos - git-gutter:clear-function #'git-gutter:clear-diff-infos - git-gutter:window-width 1)) - (unless (memq major-mode git-gutter:disabled-modes) - (git-gutter-mode +1) - (remove-hook 'after-save-hook #'+vc-gutter-init-maybe-h 'local))))))) - - ;; UX: Disable in Org mode, as per syl20bnr/spacemacs#10555 and - ;; syohex/emacs-git-gutter#24. Apparently, the mode-enabling function for - ;; global minor modes gets called for new buffers while they are still in - ;; `fundamental-mode', before a major mode has been assigned. I don't know - ;; why this is the case, but adding `fundamental-mode' here fixes the issue. - (setq git-gutter:disabled-modes '(fundamental-mode image-mode pdf-view-mode)) - :config - (set-popup-rule! "^\\*git-gutter" :select nil :size '+popup-shrink-to-fit) - - ;; PERF: Only enable the backends that are available, so it doesn't have to - ;; check when opening each buffer. - (setq git-gutter:handled-backends - (cons 'git (cl-remove-if-not #'executable-find (list 'hg 'svn 'bzr) - :key #'symbol-name))) - - ;; UX: update git-gutter on focus (in case I was using git externally) - (add-hook 'focus-in-hook #'git-gutter:update-all-windows) - - (add-hook! '(doom-escape-hook doom-switch-window-hook) :append - (defun +vc-gutter-update-h (&rest _) - "Refresh git-gutter on ESC. Return nil to prevent shadowing other -`doom-escape-hook' hooks." - (ignore (or (memq this-command '(git-gutter:stage-hunk - git-gutter:revert-hunk)) - inhibit-redisplay - (if git-gutter-mode - (git-gutter) - (+vc-gutter-init-maybe-h)))))) - ;; UX: update git-gutter when using magit commands - (advice-add #'magit-stage-file :after #'+vc-gutter-update-h) - (advice-add #'magit-unstage-file :after #'+vc-gutter-update-h) - - ;; FIX: stop git-gutter:{next,previous}-hunk from jumping to random hunks. - (defadvice! +vc-gutter--fix-linearity-of-hunks-a (diffinfos is-reverse) - :override #'git-gutter:search-near-diff-index - (cl-position-if (let ((lineno (line-number-at-pos)) - (fn (if is-reverse #'> #'<))) - (lambda (line) (funcall fn lineno line))) - diffinfos - :key #'git-gutter-hunk-start-line - :from-end is-reverse))) - - -;; -;;; diff-hl - -(use-package! diff-hl - :when (modulep! +diff-hl) - :hook (find-file . diff-hl-mode) - :hook (vc-dir-mode . diff-hl-dir-mode) - :hook (dired-mode . diff-hl-dired-mode) - :hook (diff-hl-mode . diff-hl-flydiff-mode) - :commands diff-hl-stage-current-hunk diff-hl-revert-hunk diff-hl-next-hunk diff-hl-previous-hunk - :config - (set-popup-rule! "^\\*diff-hl" :select nil :size '+popup-shrink-to-fit) - - ;; PERF: reduce load on remote - (defvaralias 'diff-hl-disable-on-remote '+vc-gutter-in-remote-files) - ;; PERF: A slightly faster algorithm for diffing. - (setq vc-git-diff-switches '("--histogram")) - ;; PERF: Slightly more conservative delay before updating the diff - (setq diff-hl-flydiff-delay 0.5) ; default: 0.3 - - ;; UX: get realtime feedback in diffs after staging/unstaging hunks. - (setq diff-hl-show-staged-changes nil) - - ;; UX: Update diffs when it makes sense too, without being too slow - (when (modulep! :editor evil) - (map! :after diff-hl-show-hunk - :map diff-hl-show-hunk-map - :n "p" #'diff-hl-show-hunk-previous - :n "n" #'diff-hl-show-hunk-next - :n "c" #'diff-hl-show-hunk-copy-original-text - :n "r" #'diff-hl-show-hunk-revert-hunk - :n "[" #'diff-hl-show-hunk-previous - :n "]" #'diff-hl-show-hunk-next - :n "{" #'diff-hl-show-hunk-previous - :n "}" #'diff-hl-show-hunk-next - :n "S" #'diff-hl-show-hunk-stage-hunk)) - ;; UX: Refresh git-gutter on ESC or refocusing the Emacs frame. - (add-hook! '(doom-escape-hook doom-switch-window-hook) :append - (defun +vc-gutter-update-h (&rest _) - "Return nil to prevent shadowing other `doom-escape-hook' hooks." - (ignore (or inhibit-redisplay - (and (or (bound-and-true-p diff-hl-mode) - (bound-and-true-p diff-hl-dir-mode)) - (diff-hl-update-once)))))) - ;; UX: Update diff-hl when magit alters git state. - (when (modulep! :tools magit) - (add-hook 'magit-pre-refresh-hook #'diff-hl-magit-pre-refresh) - (add-hook 'magit-post-refresh-hook #'diff-hl-magit-post-refresh)) - - ;; FIX: The revert popup consumes 50% of the frame, whether or not you're - ;; reverting 2 lines or 20. This resizes the popup to match its contents. - (defadvice! +vc-gutter--shrink-popup-a (fn &rest args) - :around #'diff-hl-revert-hunk-1 - (letf! ((refine-mode diff-auto-refine-mode) - (diff-auto-refine-mode t) - (defun diff-refine-hunk () - (when refine-mode - (funcall diff-refine-hunk)) - (shrink-window-if-larger-than-buffer))) - (apply fn args))) - - ;; UX: Don't delete the current hunk's indicators while we're editing - (when (modulep! :editor evil) - (add-hook! 'diff-hl-flydiff-mode-hook - (defun +vc-gutter-init-flydiff-mode-h () - (if (not diff-hl-flydiff-mode) - (remove-hook 'evil-insert-state-exit-hook #'diff-hl-flydiff-update) - (add-hook 'evil-insert-state-exit-hook #'diff-hl-flydiff-update))))) - - ;; FIX: Reverting a hunk causes the cursor to be moved to an unexpected place, - ;; often far from the target hunk. - (defadvice! +vc-gutter--save-excursion-a (fn &rest args) - "Suppresses unexpected cursor movement by `diff-hl-revert-hunk'." - :around #'diff-hl-revert-hunk - (let ((pt (point))) - (prog1 (apply fn args) - (goto-char pt))))) diff --git a/.config/emacs/modules/ui/vc-gutter/packages.el b/.config/emacs/modules/ui/vc-gutter/packages.el @@ -1,6 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; ui/vc-gutter/packages.el - -(if (modulep! +diff-hl) - (package! diff-hl :pin "d20f16bf5eadd66e775f215e800f25caddae8cb5") - (package! git-gutter-fringe :pin "648cb5b57faec55711803cdc9434e55a733c3eba")) diff --git a/.config/emacs/modules/ui/vi-tilde-fringe/README.org b/.config/emacs/modules/ui/vi-tilde-fringe/README.org @@ -1,60 +0,0 @@ -#+title: :ui vi-tilde-fringe -#+subtitle: Fringe tildes beyond EOB -#+created: September 24, 2017 -#+since: 2.0.6 - -* Description :unfold: -Displays a tilde(~) in the left fringe to indicate an empty line, similar to Vi. - -** Maintainers -- [[doom-user:][@hlissner]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:vi-tilde-fringe]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* Usage -Nothing more needs to be done once the module is activated. Tildes will become -visible in all buffers, after EOB. - -* Configuration -By default, doom activates ~vi-tilde-fringe-mode~ for ~prog-mode~, ~text-mode~ -and ~conf-mode~. To change this to your liking, you can remove any of the modes -from the list: -#+begin_src emacs-lisp -;; in $DOOMDIR/config.el -(remove-hook 'text-mode-hook #'vi-tilde-fringe-mode) -#+end_src - -Or add new modes where you would like ~vi-tilde-fringe-mode~ enabled: -#+begin_src emacs-lisp -;; in $DOOMDIR/config.el -(add-hook 'org-mode-hook #'vi-tilde-fringe-mode) -#+end_src - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote -🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/ui/vi-tilde-fringe/autoload.el b/.config/emacs/modules/ui/vi-tilde-fringe/autoload.el @@ -1,5 +0,0 @@ -;;; ui/vi-tilde-fringe/autoload.el -*- lexical-binding: t; -*- - -;;;###autoload -(add-hook! '(prog-mode-hook text-mode-hook conf-mode-hook) - #'vi-tilde-fringe-mode) diff --git a/.config/emacs/modules/ui/vi-tilde-fringe/packages.el b/.config/emacs/modules/ui/vi-tilde-fringe/packages.el @@ -1,4 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; ui/vi-tilde-fringe/packages.el - -(package! vi-tilde-fringe :pin "f1597a8d54535bb1d84b442577b2024e6f910308") diff --git a/.config/emacs/modules/ui/window-select/README.org b/.config/emacs/modules/ui/window-select/README.org @@ -1,90 +0,0 @@ -#+title: :ui window-select -#+subtitle: Visually switch windows -#+created: October 08, 2017 -#+since: 2.0.7 (#237) - -* Description :unfold: -This module provides several methods for selecting windows without the use of -the mouse or spatial navigation (e.g. [[kbd:][C-w {h,j,k,l}]]). - -The command ~other-window~ is remapped to either [[doom-package:switch-window]] or [[doom-package:ace-window]], -depending on which backend you've enabled. It is bound to [[kbd:][C-x o]] (and [[kbd:][C-w C-w]] for -evil users). - -It also provides numbered windows and selection with the [[doom-package:winum]] package, if -desired. Evil users can jump to window N in [[kbd:][C-w <N>]] (where N is a number between -0 and 9). Non evil users have [[kbd:][C-x w <N>]] instead. - -** Maintainers -/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -- +numbers :: - Enable numbered windows and window selection (using [[doom-package:winum]]). -- +switch-window :: - Use the [[doom-package:switch-window]] package as the backend, instead of ace-window ([[doom-package:avy]]). - -** Packages -- [[doom-package:ace-window]] unless [[doom-module:+switch-window]] -- [[doom-package:switch-window]] if [[doom-module:+switch-window]] -- [[doom-package:winum]] if [[doom-module:+numbers]] - -** Hacks -/No hacks documented for this module./ - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* TODO Usage -#+begin_quote - 🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* TODO Configuration -#+begin_quote - 🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -This module provides two backends, both providing the same functionality, but -with different visual cues. They are [[doom-package:ace-window]] and [[doom-package:switch-window]]. - -** ace-window -The first character of the buffers changes to a highlighted, user-selectable -character. - -- *Pros:* the content of the buffers are always visible. -- *Cons:* The display characters are small and difficult to see (see below for a - way to enlarge them). - -*** Custom font-face example -This changes the ace-window display to show a white letter with a red -background. The box attribute adds some padding: -#+begin_src emacs-lisp -(custom-set-faces! - '(aw-leading-char-face - :foreground "white" :background "red" - :weight bold :height 2.5 :box (:line-width 10 :color "red"))) -#+end_src - -** switch-window -Replaces the entire buffer with large letters. - -- *Pros:* The displayed characters are /really/ easy to see. -- *Cons:* You can't see the contents of the buffers. - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote -🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/ui/window-select/config.el b/.config/emacs/modules/ui/window-select/config.el @@ -1,42 +0,0 @@ -;;; ui/window-select/config.el -*- lexical-binding: t; -*- - -(use-package! switch-window - :when (modulep! +switch-window) - :defer t - :init - (global-set-key [remap other-window] #'switch-window) - :config - (setq switch-window-shortcut-style 'qwerty)) - - -(use-package! ace-window - :unless (modulep! +switch-window) - :defer t - :init - (global-set-key [remap other-window] #'ace-window) - :config - (unless (modulep! +numbers) - (setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l))) - (setq aw-scope 'frame - aw-background t)) - - -(use-package! winum - :when (modulep! +numbers) - :after-call doom-switch-window-hook - :config - ;; winum modifies `mode-line-format' in a destructive manner. I'd rather leave - ;; it to modeline plugins (or the user) to add this if they want it. - (setq winum-auto-setup-mode-line nil) - (winum-mode +1) - (map! :map evil-window-map - "0" #'winum-select-window-0-or-10 - "1" #'winum-select-window-1 - "2" #'winum-select-window-2 - "3" #'winum-select-window-3 - "4" #'winum-select-window-4 - "5" #'winum-select-window-5 - "6" #'winum-select-window-6 - "7" #'winum-select-window-7 - "8" #'winum-select-window-8 - "9" #'winum-select-window-9)) diff --git a/.config/emacs/modules/ui/window-select/packages.el b/.config/emacs/modules/ui/window-select/packages.el @@ -1,9 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; ui/window-select/packages.el - -(if (modulep! +switch-window) - (package! switch-window :pin "71ef2f54c97f3fd2e7ff7964d82e6562eb6282f7") - (package! ace-window :pin "77115afc1b0b9f633084cf7479c767988106c196")) - -(when (modulep! +numbers) - (package! winum :pin "c5455e866e8a5f7eab6a7263e2057aff5f1118b9")) diff --git a/.config/emacs/modules/ui/workspaces/README.org b/.config/emacs/modules/ui/workspaces/README.org @@ -1,125 +0,0 @@ -#+title: :ui workspaces -#+subtitle: Tab emulation, persistence, & separate workspaces -#+created: February 20, 2017 -#+since: 2.0.0 - -* Description :unfold: -This module adds support for workspaces, powered by [[doom-package:persp-mode]], as well as a API -for manipulating them. - -#+begin_quote - 💡 There are many ways to use workspaces. I spawn a workspace per task. Say I'm - working in the main workspace, when I realize there is a bug in another part - of my project. I open a new workspace and deal with it in there. In the - meantime, I need to check my email, so mu4e gets its own workspace. - - Once I've completed the task, I close the workspace and return to main. -#+end_quote - -** Maintainers -- [[doom-user:][@hlissner]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:persp-mode]] - -** TODO Hacks -#+begin_quote - 🔨 This module's hacks haven't been documented yet. [[doom-contrib-module:][Document them?]] -#+end_quote - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* TODO Usage -#+begin_quote - 🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]] -#+end_quote - -** Isolated buffer-list -When persp-mode is active, ~doom-buffer-list~ becomes workspace-restricted. You -can overcome this by using ~buffer-list~. - -** Automatic workspaces -A workspace is automatically created (and switched to) when you: - -- Create a new frame (with =make-frame=; bound to [[kbd:][M-N]] by default). -- Switch to a project using ~projectile-switch-project~. - -** Session persistence -By default, your session is autosaved when you quit Emacs (or disable -~persp-mode~). You can load a previous session with ~M-x -+workspace/load-session~ or ~:sl[oad]~ (ex command). - -You can supply either a name to load a specific session to replace your current -one. - -** Workspace persistence -If you'd like to save a specific workspace, use ~M-x +workspace/save~, which can -be loaded into the current session (as another workspace) with ~M-x -+workspace/load~. - -** Commands & Keybindings -Here is a list of available commands, their default keybindings (defined in -[[../../config/default/+evil-bindings.el][config/default/+bindings.el]]), and corresponding ex commands (if any -- defined -in [[../../editor/evil/+commands.el][config/default/+evil-commands.el]]). - -| command | key / ex command | description | -|-----------------------------------+----------------------+------------------------------------------------------------| -| ~+workspace/new~ | [[kbd:][SPC TAB n]] | Create a new, blank workspace | -| ~+workspace/display~ | [[kbd:][SPC TAB TAB]] | Display open workspaces in the mode-line | -| ~+workspace/load~ | [[kbd:][SPC TAB l]] | Load a saved workspace into the current session | -| ~+workspace/restore-last-session~ | [[kbd:][SPC TAB R]] | Restore last session | -| ~+workspace/rename~ | [[kbd:][SPC TAB r]] | Rename the current workspace | -| ~+workspace/save~ | [[kbd:][SPC TAB s]] | Save the current workspace to a file | -| ~+workspace/switch-to~ | [[kbd:][SPC TAB .]] | Switch to an open workspace | -| ~+workspace/other~ | [[kbd:][SPC TAB `]] | Switch to last workspace | -| ~+workspace/switch-left~ | [[kbd:][SPC TAB []] / [[kbd:][[ w]] / [[kbd:][gT]] | Switch to previous workspace | -| ~+workspace/switch-right~ | [[kbd:][SPC TAB ]]] / [[kbd:][] w]] / [[kbd:][gt]] | Switch to next workspace | -| ~+workspace/delete~ | [[kbd:][SPC TAB d]] | Delete the current workspace | -| ~+workspace/kill-session~ | [[kbd:][SPC TAB x]] / [[kbd:][:sclear]] | Clears the current session (kills all windows and buffers) | - -* TODO Configuration -#+begin_quote -🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote - 🔨 /This module's appendix is incomplete./ [[doom-contrib-module:][Write more?]] -#+end_quote - -** API -+ ~+workspace-list~ -> list<Struct> -+ ~+workspace-list-names~ -> list<string> -+ ~+workspace-buffer-list &optional PERSP~ -> bool -+ ~+workspace-p OBJ~ -> bool -+ ~+workspace-exists-p NAME~ -> bool -+ ~+workspace-get NAME &optional NOERROR~ -> Struct -+ ~+workspace-current &optional FRAME WINDOW~ -> Struct -+ ~+workspace-current-name~ -> string -+ ~+workspace-load NAME~ -+ ~+workspace-load-session NAME~ -+ ~+workspace-save NAME~ -+ ~+workspace-save-session NAME~ -+ ~+workspace-new NAME~ -+ ~+workspace-rename NAME NEW-NAME~ -+ ~+workspace-delete NAME &optional INHIBIT-KILL-P~ -+ ~+workspace-switch NAME &optional AUTO-CREATE-P~ -+ ~+workspace-protected-p NAME~ -> bool diff --git a/.config/emacs/modules/ui/workspaces/autoload/evil.el b/.config/emacs/modules/ui/workspaces/autoload/evil.el @@ -1,39 +0,0 @@ -;;; ui/workspaces/autoload/evil.el -*- lexical-binding: t; -*- -;;;###if (modulep! :editor evil) - -;;;###autoload (autoload '+workspace:save "ui/workspaces/autoload/evil" nil t) -(evil-define-command +workspace:save (&optional name) - "Ex wrapper around `+workspace/save-session'." - (interactive "<a>") (+workspace/save name)) - -;;;###autoload (autoload '+workspace:load "ui/workspaces/autoload/evil" nil t) -(evil-define-command +workspace:load (&optional name) - "Ex wrapper around `+workspace/load-session'." - (interactive "<a>") (+workspace/load name)) - -;;;###autoload (autoload '+workspace:new "ui/workspaces/autoload/evil" nil t) -(evil-define-command +workspace:new (bang name) - "Ex wrapper around `+workspace/new'. If BANG, clone the current workspace." - (interactive "<!><a>") (+workspace/new name bang)) - -;;;###autoload (autoload '+workspace:rename "ui/workspaces/autoload/evil" nil t) -(evil-define-command +workspace:rename (new-name) - "Ex wrapper around `+workspace/rename'." - (interactive "<a>") (+workspace/rename new-name)) - -;;;###autoload (autoload '+workspace:delete "ui/workspaces/autoload/evil" nil t) -(evil-define-command +workspace:delete () - "Ex wrapper around `+workspace/delete'." - (interactive) (+workspace/delete (+workspace-current-name))) - -;;;###autoload (autoload '+workspace:switch-next "ui/workspaces/autoload/evil" nil t) -(evil-define-command +workspace:switch-next (&optional count) - "Switch to next workspace. If COUNT, switch to COUNT-th workspace." - (interactive "<c>") - (if count (+workspace/switch-to count) (+workspace/cycle +1))) - -;;;###autoload (autoload '+workspace:switch-previous "ui/workspaces/autoload/evil" nil t) -(evil-define-command +workspace:switch-previous (&optional count) - "Switch to previous workspace. If COUNT, switch to COUNT-th workspace." - (interactive "<c>") - (if count (+workspace/switch-to count) (+workspace/cycle -1))) diff --git a/.config/emacs/modules/ui/workspaces/autoload/ivy.el b/.config/emacs/modules/ui/workspaces/autoload/ivy.el @@ -1,17 +0,0 @@ -;;; ui/workspaces/autoload/ivy.el -*- lexical-binding: t; -*- -;;;###if (modulep! :completion ivy) - -;;;###autoload -(defun +workspace--ivy-rich-preview (workspace) - (if-let (buffers (when-let (workspace (gethash workspace *persp-hash*)) - (cl-loop for (type . rest) in (persp-window-conf workspace) - if (eq type 'buffer) - collect (car leaf) - else if (eq type 'leaf) - append (cl-loop for (type . leaf) in rest - if (eq type 'buffer) - collect (car leaf))))) - (string-join buffers " ") - "*No buffers*")) - -;;; ivy.el ends here diff --git a/.config/emacs/modules/ui/workspaces/autoload/workspaces.el b/.config/emacs/modules/ui/workspaces/autoload/workspaces.el @@ -1,612 +0,0 @@ -;;; ui/workspaces/autoload/workspaces.el -*- lexical-binding: t; -*- - -(defvar +workspace--last nil) -(defvar +workspace--index 0) - -;;;###autoload -(defface +workspace-tab-selected-face '((t (:inherit highlight))) - "The face for selected tabs displayed by `+workspace/display'" - :group 'persp-mode) - -;;;###autoload -(defface +workspace-tab-face '((t (:inherit default))) - "The face for selected tabs displayed by `+workspace/display'" - :group 'persp-mode) - - -;; -;;; Library - -(defun +workspace--protected-p (name) - (equal name persp-nil-name)) - -(defun +workspace--generate-id () - (or (cl-loop for name in (+workspace-list-names) - when (string-match-p "^#[0-9]+$" name) - maximize (string-to-number (substring name 1)) into max - finally return (if max (1+ max))) - 1)) - - -;;; Predicates -;;;###autoload -(defalias #'+workspace-p #'perspective-p - "Return t if OBJ is a perspective hash table.") - -;;;###autoload -(defun +workspace-exists-p (name) - "Returns t if NAME is the name of an existing workspace." - (member name (+workspace-list-names))) - -;;;###autoload -(defalias #'+workspace-contains-buffer-p #'persp-contain-buffer-p - "Return non-nil if BUFFER is in WORKSPACE (defaults to current workspace).") - - -;;; Getters -;;;###autoload -(defalias #'+workspace-current #'get-current-persp - "Return the currently active workspace.") - -;;;###autoload -(defun +workspace-get (name &optional noerror) - "Return a workspace named NAME. Unless NOERROR is non-nil, this throws an -error if NAME doesn't exist." - (cl-check-type name string) - (when-let (persp (persp-get-by-name name)) - (cond ((+workspace-p persp) persp) - ((not noerror) - (error "No workspace called '%s' was found" name))))) - -;;;###autoload -(defun +workspace-current-name () - "Get the name of the current workspace." - (safe-persp-name (+workspace-current))) - -;;;###autoload -(defun +workspace-list () - "Return a list of workspace structs (satisifes `+workspace-p')." - ;; We don't use `hash-table-values' because it doesn't ensure order in older - ;; versions of Emacs - (cl-loop for name in persp-names-cache - if (gethash name *persp-hash*) - collect it)) - -;;;###autoload -(defun +workspace-list-names () - "Return the list of names of open workspaces." - persp-names-cache) - -;;;###autoload -(defun +workspace-buffer-list (&optional persp) - "Return a list of buffers in PERSP. - -PERSP can be a string (name of a workspace) or a workspace (satisfies -`+workspace-p'). If nil or omitted, it defaults to the current workspace." - (let ((persp (or persp (+workspace-current)))) - (unless (+workspace-p persp) - (user-error "Not in a valid workspace (%s)" persp)) - (persp-buffers persp))) - -;;;###autoload -(defun +workspace-orphaned-buffer-list () - "Return a list of buffers that aren't associated with any perspective." - (cl-remove-if #'persp--buffer-in-persps (buffer-list))) - - -;;; Actions -;;;###autoload -(defun +workspace-load (name) - "Loads a single workspace (named NAME) into the current session. Can only -retrieve perspectives that were explicitly saved with `+workspace-save'. - -Returns t if successful, nil otherwise." - (when (+workspace-exists-p name) - (user-error "A workspace named '%s' already exists." name)) - (persp-load-from-file-by-names - (expand-file-name +workspaces-data-file persp-save-dir) - *persp-hash* (list name)) - (+workspace-exists-p name)) - -;;;###autoload -(defun +workspace-save (name) - "Saves a single workspace (NAME) from the current session. Can be loaded again -with `+workspace-load'. NAME can be the string name of a workspace or its -perspective hash table. - -Returns t on success, nil otherwise." - (unless (+workspace-exists-p name) - (error "'%s' is an invalid workspace" name)) - (let ((fname (expand-file-name +workspaces-data-file persp-save-dir))) - (persp-save-to-file-by-names fname *persp-hash* (list name)) - (and (member name (persp-list-persp-names-in-file fname)) - t))) - -;;;###autoload -(defun +workspace-new (name) - "Create a new workspace named NAME. If one already exists, return nil. -Otherwise return t on success, nil otherwise." - (when (+workspace--protected-p name) - (error "Can't create a new '%s' workspace" name)) - (when (+workspace-exists-p name) - (error "A workspace named '%s' already exists" name)) - (let ((persp (persp-add-new name)) - (+popup--inhibit-transient t)) - (save-window-excursion - (let ((ignore-window-parameters t) - (+popup--inhibit-transient t)) - (persp-delete-other-windows)) - (switch-to-buffer (doom-fallback-buffer)) - (setf (persp-window-conf persp) - (funcall persp-window-state-get-function (selected-frame)))) - persp)) - -;;;###autoload -(defun +workspace-rename (name new-name) - "Rename the current workspace named NAME to NEW-NAME. Returns old name on -success, nil otherwise." - (when (+workspace--protected-p name) - (error "Can't rename '%s' workspace" name)) - (persp-rename new-name (+workspace-get name))) - -;;;###autoload -(defun +workspace-delete (workspace &optional inhibit-kill-p) - "Delete the workspace denoted by WORKSPACE, which can be the name of a perspective -or its hash table. If INHIBIT-KILL-P is non-nil, don't kill this workspace's -buffers." - (unless (stringp workspace) - (setq workspace (persp-name workspace))) - (when (+workspace--protected-p workspace) - (error "Can't delete '%s' workspace" workspace)) - (+workspace-get workspace) ; error checking - (persp-kill workspace inhibit-kill-p) - (not (+workspace-exists-p workspace))) - -;;;###autoload -(defun +workspace-switch (name &optional auto-create-p) - "Switch to another workspace named NAME (a string). - -If AUTO-CREATE-P is non-nil, create the workspace if it doesn't exist, otherwise -throws an error." - (unless (+workspace-exists-p name) - (if auto-create-p - (+workspace-new name) - (error "%s is not an available workspace" name))) - (let ((old-name (+workspace-current-name))) - (unless (equal old-name name) - (setq +workspace--last - (or (and (not (string= old-name persp-nil-name)) - old-name) - +workspaces-main)) - (persp-frame-switch name)) - (equal (+workspace-current-name) name))) - - -;; -;;; Commands - -;;;###autoload -(defalias '+workspace/restore-last-session #'doom/quickload-session) - -;;;###autoload -(defun +workspace/load (name) - "Load a workspace and switch to it. If called with C-u, try to reload the -current workspace (by name) from session files." - (interactive - (list - (if current-prefix-arg - (+workspace-current-name) - (completing-read - "Workspace to load: " - (persp-list-persp-names-in-file - (expand-file-name +workspaces-data-file persp-save-dir)))))) - (if (not (+workspace-load name)) - (+workspace-error (format "Couldn't load workspace %s" name)) - (+workspace/switch-to name) - (+workspace/display))) - -;;;###autoload -(defun +workspace/save (name) - "Save the current workspace. If called with C-u, autosave the current -workspace." - (interactive - (list - (if current-prefix-arg - (+workspace-current-name) - (completing-read "Workspace to save: " (+workspace-list-names))))) - (if (+workspace-save name) - (+workspace-message (format "'%s' workspace saved" name) 'success) - (+workspace-error (format "Couldn't save workspace %s" name)))) - -;;;###autoload -(defun +workspace/rename (new-name) - "Rename the current workspace." - (interactive (list (read-from-minibuffer "New workspace name: "))) - (condition-case-unless-debug ex - (let* ((current-name (+workspace-current-name)) - (old-name (+workspace-rename current-name new-name))) - (unless old-name - (error "Failed to rename %s" current-name)) - (+workspace-message (format "Renamed '%s'->'%s'" old-name new-name) 'success)) - ('error (+workspace-error ex t)))) - -;;;###autoload -(defun +workspace/delete (name) - "Delete this workspace. If called with C-u, prompts you for the name of the -workspace to delete." - (interactive - (let ((current-name (+workspace-current-name))) - (list - (if current-prefix-arg - (completing-read (format "Delete workspace (default: %s): " current-name) - (+workspace-list-names) - nil nil nil nil current-name) - current-name)))) - (condition-case-unless-debug ex - ;; REVIEW refactor me - (let ((workspaces (+workspace-list-names))) - (if (not (member name workspaces)) - (+workspace-message (format "'%s' workspace doesn't exist" name) 'warn) - (cond ((delq (selected-frame) (persp-frames-with-persp (get-frame-persp))) - (user-error "Can't close workspace, it's visible in another frame")) - ((not (equal (+workspace-current-name) name)) - (+workspace-delete name)) - ((cdr workspaces) - (+workspace-delete name) - (+workspace-switch - (if (+workspace-exists-p +workspace--last) - +workspace--last - (car (+workspace-list-names)))) - (unless (doom-buffer-frame-predicate (window-buffer)) - (switch-to-buffer (doom-fallback-buffer)))) - (t - (+workspace-switch +workspaces-main t) - (unless (string= (car workspaces) +workspaces-main) - (+workspace-delete name)) - (doom/kill-all-buffers (doom-buffer-list)))) - (+workspace-message (format "Deleted '%s' workspace" name) 'success))) - ('error (+workspace-error ex t)))) - -;;;###autoload -(defun +workspace/kill-session (&optional interactive) - "Delete the current session, all workspaces, windows and their buffers." - (interactive (list t)) - (let ((windows (length (window-list))) - (persps (length (+workspace-list-names))) - (buffers 0)) - (let ((persp-autokill-buffer-on-remove t)) - (unless (cl-every #'+workspace-delete (+workspace-list-names)) - (+workspace-error "Could not clear session"))) - (+workspace-switch +workspaces-main t) - (setq buffers (doom/kill-all-buffers (buffer-list))) - (when interactive - (message "Killed %d workspace(s), %d window(s) & %d buffer(s)" - persps windows buffers)))) - -;;;###autoload -(defun +workspace/kill-session-and-quit () - "Kill emacs without saving anything." - (interactive) - (let ((persp-auto-save-opt 0)) - (kill-emacs))) - -;;;###autoload -(defun +workspace/new (&optional name clone-p) - "Create a new workspace named NAME. If CLONE-P is non-nil, clone the current -workspace, otherwise the new workspace is blank." - (interactive (list nil current-prefix-arg)) - (unless name - (setq name (format "#%s" (+workspace--generate-id)))) - (condition-case e - (cond ((+workspace-exists-p name) - (error "%s already exists" name)) - (clone-p (persp-copy name t)) - (t - (+workspace-switch name t) - (+workspace/display))) - ((debug error) (+workspace-error (cadr e) t)))) - -;;;###autoload -(defun +workspace/new-named (name) - "Create a new workspace with a given NAME." - (interactive "sWorkspace Name: ") - (+workspace/new name)) - -;;;###autoload -(defun +workspace/switch-to (index) - "Switch to a workspace at a given INDEX. A negative number will start from the -end of the workspace list." - (interactive - (list (or current-prefix-arg - (if (modulep! :completion ivy) - (ivy-read "Switch to workspace: " - (+workspace-list-names) - :caller #'+workspace/switch-to - :preselect (+workspace-current-name)) - (completing-read "Switch to workspace: " (+workspace-list-names)))))) - (when (and (stringp index) - (string-match-p "^[0-9]+$" index)) - (setq index (string-to-number index))) - (condition-case-unless-debug ex - (let ((names (+workspace-list-names)) - (old-name (+workspace-current-name))) - (cond ((numberp index) - (let ((dest (nth index names))) - (unless dest - (error "No workspace at #%s" (1+ index))) - (+workspace-switch dest))) - ((stringp index) - (+workspace-switch index t)) - (t - (error "Not a valid index: %s" index))) - (unless (called-interactively-p 'interactive) - (if (equal (+workspace-current-name) old-name) - (+workspace-message (format "Already in %s" old-name) 'warn) - (+workspace/display)))) - ('error (+workspace-error (cadr ex) t)))) - -;;;###autoload -(dotimes (i 9) - (defalias (intern (format "+workspace/switch-to-%d" i)) - (lambda () (interactive) (+workspace/switch-to i)) - (format "Switch to workspace #%d" (1+ i)))) - -;;;###autoload -(defun +workspace/switch-to-final () - "Switch to the final workspace in open workspaces." - (interactive) - (+workspace/switch-to (car (last (+workspace-list-names))))) - -;;;###autoload -(defun +workspace/other () - "Switch to the last activated workspace." - (interactive) - (+workspace/switch-to +workspace--last)) - -;;;###autoload -(defun +workspace/cycle (n) - "Cycle n workspaces to the right (default) or left." - (interactive (list 1)) - (let ((current-name (+workspace-current-name))) - (if (equal current-name persp-nil-name) - (+workspace-switch +workspaces-main t) - (condition-case-unless-debug ex - (let* ((persps (+workspace-list-names)) - (perspc (length persps)) - (index (cl-position current-name persps))) - (when (= perspc 1) - (user-error "No other workspaces")) - (+workspace/switch-to (% (+ index n perspc) perspc)) - (unless (called-interactively-p 'interactive) - (+workspace/display))) - ('user-error (+workspace-error (cadr ex) t)) - ('error (+workspace-error ex t)))))) - -;;;###autoload -(defun +workspace/switch-left () (interactive) (+workspace/cycle -1)) - -;;;###autoload -(defun +workspace/switch-right () (interactive) (+workspace/cycle +1)) - -;;;###autoload -(defun +workspace/close-window-or-workspace () - "Close the selected window. If it's the last window in the workspace, either -close the workspace (as well as its associated frame, if one exists) and move to -the next." - (interactive) - (let ((delete-window-fn (if (featurep 'evil) #'evil-window-delete #'delete-window))) - (if (window-dedicated-p) - (funcall delete-window-fn) - (let ((current-persp-name (+workspace-current-name))) - (cond ((or (+workspace--protected-p current-persp-name) - (cdr (doom-visible-windows))) - (funcall delete-window-fn)) - - ((cdr (+workspace-list-names)) - (let ((frame-persp (frame-parameter nil 'workspace))) - (if (string= frame-persp (+workspace-current-name)) - (delete-frame) - (+workspace/delete current-persp-name)))) - - ((+workspace-error "Can't delete last workspace" t))))))) - -;;;###autoload -(defun +workspace/swap-left (&optional count) - "Swap the current workspace with the COUNTth workspace on its left." - (interactive "p") - (let* ((current-name (+workspace-current-name)) - (count (or count 1)) - (index (- (cl-position current-name persp-names-cache :test #'equal) - count)) - (names (remove current-name persp-names-cache))) - (unless names - (user-error "Only one workspace")) - (let ((index (min (max 0 index) (length names)))) - (setq persp-names-cache - (append (cl-subseq names 0 index) - (list current-name) - (cl-subseq names index)))) - (when (called-interactively-p 'any) - (+workspace/display)))) - -;;;###autoload -(defun +workspace/swap-right (&optional count) - "Swap the current workspace with the COUNTth workspace on its right." - (interactive "p") - (funcall-interactively #'+workspace/swap-left (- count))) - - -;; -;;; Tabs display in minibuffer - -(defun +workspace--tabline (&optional names) - (let ((names (or names (+workspace-list-names))) - (current-name (+workspace-current-name))) - (mapconcat - #'identity - (cl-loop for name in names - for i to (length names) - collect - (propertize (format " [%d] %s " (1+ i) name) - 'face (if (equal current-name name) - '+workspace-tab-selected-face - '+workspace-tab-face))) - " "))) - -(defun +workspace--message-body (message &optional type) - (concat (+workspace--tabline) - (propertize " | " 'face 'font-lock-comment-face) - (propertize (format "%s" message) - 'face (pcase type - ('error 'error) - ('warn 'warning) - ('success 'success) - ('info 'font-lock-comment-face))))) - -;;;###autoload -(defun +workspace-message (message &optional type) - "Show an 'elegant' message in the echo area next to a listing of workspaces." - (message "%s" (+workspace--message-body message type))) - -;;;###autoload -(defun +workspace-error (message &optional noerror) - "Show an 'elegant' error in the echo area next to a listing of workspaces." - (funcall (if noerror #'message #'error) - "%s" (+workspace--message-body message 'error))) - -;;;###autoload -(defun +workspace/display () - "Display a list of workspaces (like tabs) in the echo area." - (interactive) - (let (message-log-max) - (message "%s" (+workspace--tabline)))) - - -;; -;;; Hooks - -;;;###autoload -(defun +workspaces-delete-associated-workspace-h (&optional frame) - "Delete workspace associated with current frame. -A workspace gets associated with a frame when a new frame is interactively -created." - (when (and persp-mode (not (bound-and-true-p with-editor-mode))) - (unless frame - (setq frame (selected-frame))) - (let ((frame-persp (frame-parameter frame 'workspace))) - (when (string= frame-persp (+workspace-current-name)) - (+workspace/delete frame-persp))))) - -;;;###autoload -(defun +workspaces-associate-frame-fn (frame &optional _new-frame-p) - "Create a blank, new perspective and associate it with FRAME." - (when persp-mode - (if (not (persp-frame-list-without-daemon)) - (+workspace-switch +workspaces-main t) - (with-selected-frame frame - (+workspace-switch (format "#%s" (+workspace--generate-id)) t) - (unless (doom-real-buffer-p (current-buffer)) - (switch-to-buffer (doom-fallback-buffer))) - (set-frame-parameter frame 'workspace (+workspace-current-name)) - ;; ensure every buffer has a buffer-predicate - (persp-set-frame-buffer-predicate frame)) - (run-at-time 0.1 nil #'+workspace/display)))) - -(defvar +workspaces--project-dir nil) -;;;###autoload -(defun +workspaces-set-project-action-fn () - "A `projectile-switch-project-action' that sets the project directory for -`+workspaces-switch-to-project-h'." - (setq +workspaces--project-dir default-directory)) - -;;;###autoload -(defun +workspaces-switch-to-project-h (&optional dir) - "Creates a workspace dedicated to a new project. If one already exists, switch -to it. If in the main workspace and it's empty, recycle that workspace, without -renaming it. - -Afterwords, runs `+workspaces-switch-project-function'. By default, this prompts -the user to open a file in the new project. - -This be hooked to `projectile-after-switch-project-hook'." - (when dir - (setq +workspaces--project-dir dir)) - ;; HACK Clear projectile-project-root, otherwise cached roots may interfere - ;; with project switch (see #3166) - (let (projectile-project-root) - (when (and persp-mode +workspaces--project-dir) - (when projectile-before-switch-project-hook - (with-temp-buffer - ;; Load the project dir-local variables into the switch buffer, so the - ;; action can make use of them - (setq default-directory +workspaces--project-dir) - (hack-dir-local-variables-non-file-buffer) - (run-hooks 'projectile-before-switch-project-hook))) - (unwind-protect - (if (and (not (null +workspaces-on-switch-project-behavior)) - (or (eq +workspaces-on-switch-project-behavior t) - (equal (safe-persp-name (get-current-persp)) persp-nil-name) - (+workspace-buffer-list))) - (let* ((persp - (let ((project-name (doom-project-name +workspaces--project-dir))) - (or (+workspace-get project-name t) - (+workspace-new project-name)))) - (new-name (persp-name persp))) - (+workspace-switch new-name) - (with-current-buffer (doom-fallback-buffer) - (setq default-directory +workspaces--project-dir) - (hack-dir-local-variables-non-file-buffer)) - (unless current-prefix-arg - (funcall +workspaces-switch-project-function +workspaces--project-dir)) - (+workspace-message - (format "Switched to '%s' in new workspace" new-name) - 'success)) - (with-current-buffer (doom-fallback-buffer) - (setq default-directory +workspaces--project-dir) - (hack-dir-local-variables-non-file-buffer) - (message "Switched to '%s'" (doom-project-name +workspaces--project-dir))) - (with-demoted-errors "Workspace error: %s" - (+workspace-rename (+workspace-current-name) (doom-project-name +workspaces--project-dir))) - (unless current-prefix-arg - (funcall +workspaces-switch-project-function +workspaces--project-dir))) - (run-hooks 'projectile-after-switch-project-hook) - (setq +workspaces--project-dir nil))))) - -;;;###autoload -(defun +workspaces-save-tab-bar-data-h (_) - "Save the current workspace's tab bar data." - (when (get-current-persp) - (set-persp-parameter - 'tab-bar-tabs (tab-bar-tabs)) - (set-persp-parameter 'tab-bar-closed-tabs tab-bar-closed-tabs))) - -;;;###autoload -(defun +workspaces-save-tab-bar-data-to-file-h (&rest _) - "Save the current workspace's tab bar data to file." - (when (get-current-persp) - ;; HACK: Remove fields (for window-configuration) that cannot be serialized. - (set-persp-parameter 'tab-bar-tabs - (frameset-filter-tabs (tab-bar-tabs) nil nil t)))) - -;;;###autoload -(defun +workspaces-load-tab-bar-data-h (_) - "Restores the tab bar data of the workspace we have just switched to." - (tab-bar-tabs-set (persp-parameter 'tab-bar-tabs)) - (setq tab-bar-closed-tabs (persp-parameter 'tab-bar-closed-tabs)) - (tab-bar--update-tab-bar-lines t)) - -;;;###autoload -(defun +workspaces-load-tab-bar-data-from-file-h (&rest _) - "Restores the tab bar data from file." - (tab-bar-tabs-set (persp-parameter 'tab-bar-tabs)) - (tab-bar--update-tab-bar-lines t)) - -;; -;;; Advice - -;;;###autoload -(defun +workspaces-autosave-real-buffers-a (fn &rest args) - "Don't autosave if no real buffers are open." - (when (doom-real-buffer-list) - (apply fn args)) - t) diff --git a/.config/emacs/modules/ui/workspaces/config.el b/.config/emacs/modules/ui/workspaces/config.el @@ -1,295 +0,0 @@ -;;; ui/workspaces/config.el -*- lexical-binding: t; -*- - -;; `persp-mode' gives me workspaces, a workspace-restricted `buffer-list', and -;; file-based session persistence. I used workgroups2 before this, but abandoned -;; it because it was unstable and slow; `persp-mode' is neither (and still -;; maintained). -;; -;; NOTE persp-mode requires `workgroups' for file persistence in Emacs 24.4. - -(defvar +workspaces-main "main" - "The name of the primary and initial workspace, which cannot be deleted.") - -(defvar +workspaces-switch-project-function #'doom-project-find-file - "The function to run after `projectile-switch-project' or -`counsel-projectile-switch-project'. This function must take one argument: the -new project directory.") - -(defvar +workspaces-on-switch-project-behavior 'non-empty - "Controls the behavior of workspaces when switching to a new project. - -Can be one of the following: - -t Always create a new workspace for the project -'non-empty Only create a new workspace if the current one already has buffers - associated with it. -nil Never create a new workspace on project switch.") - -;; FIXME actually use this for wconf bookmark system -(defvar +workspaces-data-file "_workspaces" - "The basename of the file to store single workspace perspectives. Will be -stored in `persp-save-dir'.") - -(defvar +workspace--old-uniquify-style nil) - - -;; -;; Packages - -(use-package! persp-mode - :unless noninteractive - :commands persp-switch-to-buffer - :hook (doom-init-ui . persp-mode) - :config - (setq persp-autokill-buffer-on-remove 'kill-weak - persp-reset-windows-on-nil-window-conf nil - persp-nil-hidden t - persp-auto-save-fname "autosave" - persp-save-dir (concat doom-data-dir "workspaces/") - persp-set-last-persp-for-new-frames t - persp-switch-to-added-buffer nil - persp-kill-foreign-buffer-behaviour 'kill - persp-remove-buffers-from-nil-persp-behaviour nil - persp-auto-resume-time -1 ; Don't auto-load on startup - persp-auto-save-opt (if noninteractive 0 1)) ; auto-save on kill - - - ;;;; Create main workspace - ;; The default perspective persp-mode creates is special and doesn't represent - ;; a real persp object, so buffers can't really be assigned to it, among other - ;; quirks, so I replace it with a "main" perspective. - (add-hook! '(persp-mode-hook persp-after-load-state-functions) - (defun +workspaces-ensure-no-nil-workspaces-h (&rest _) - (when persp-mode - (dolist (frame (frame-list)) - (when (string= (safe-persp-name (get-current-persp frame)) persp-nil-name) - ;; Take extra steps to ensure no frame ends up in the nil perspective - (persp-frame-switch (or (cadr (hash-table-keys *persp-hash*)) - +workspaces-main) - frame)))))) - - (add-hook! 'persp-mode-hook - (defun +workspaces-init-first-workspace-h (&rest _) - "Ensure a main workspace exists." - (when persp-mode - (let (persp-before-switch-functions) - ;; Try our best to hide the nil perspective. - (when (equal (car persp-names-cache) persp-nil-name) - (pop persp-names-cache)) - ;; ...and create a *real* main workspace to fill this role. - (unless (or (persp-get-by-name +workspaces-main) - ;; Start from 2 b/c persp-mode counts the nil workspace - (> (hash-table-count *persp-hash*) 2)) - (persp-add-new +workspaces-main)) - ;; HACK Fix #319: the warnings buffer gets swallowed when creating - ;; `+workspaces-main', so display it ourselves, if it exists. - (when-let (warnings (get-buffer "*Warnings*")) - (save-excursion - (display-buffer-in-side-window - warnings '((window-height . shrink-window-if-larger-than-buffer)))))))) - (defun +workspaces-init-persp-mode-h () - (cond (persp-mode - ;; `uniquify' breaks persp-mode. It renames old buffers, which causes - ;; errors when switching between perspective (their buffers are - ;; serialized by name and persp-mode expects them to have the same - ;; name when restored). - (when uniquify-buffer-name-style - (setq +workspace--old-uniquify-style uniquify-buffer-name-style)) - (setq uniquify-buffer-name-style nil) - ;; Ensure `persp-kill-buffer-query-function' is last - (remove-hook 'kill-buffer-query-functions #'persp-kill-buffer-query-function) - (add-hook 'kill-buffer-query-functions #'persp-kill-buffer-query-function t) - ;; Restrict buffer list to workspace - (advice-add #'doom-buffer-list :override #'+workspace-buffer-list)) - (t - (when +workspace--old-uniquify-style - (setq uniquify-buffer-name-style +workspace--old-uniquify-style)) - (advice-remove #'doom-buffer-list #'+workspace-buffer-list))))) - - ;; Per-workspace `winner-mode' history - (add-to-list 'window-persistent-parameters '(winner-ring . t)) - - (add-hook! 'persp-before-deactivate-functions - (defun +workspaces-save-winner-data-h (_) - (when (and (bound-and-true-p winner-mode) - (get-current-persp)) - (set-persp-parameter - 'winner-ring (list winner-currents - winner-ring-alist - winner-pending-undo-ring))))) - - (add-hook! 'persp-activated-functions - (defun +workspaces-load-winner-data-h (_) - (when (bound-and-true-p winner-mode) - (cl-destructuring-bind - (currents alist pending-undo-ring) - (or (persp-parameter 'winner-ring) (list nil nil nil)) - (setq winner-undo-frame nil - winner-currents currents - winner-ring-alist alist - winner-pending-undo-ring pending-undo-ring))))) - - ;;;; Registering buffers to perspectives - (add-hook! 'doom-switch-buffer-hook - (defun +workspaces-add-current-buffer-h () - "Add current buffer to focused perspective." - (or (not persp-mode) - (persp-buffer-filtered-out-p - (or (buffer-base-buffer (current-buffer)) - (current-buffer)) - persp-add-buffer-on-after-change-major-mode-filter-functions) - (persp-add-buffer (current-buffer) (get-current-persp) nil nil)))) - - (add-hook 'persp-add-buffer-on-after-change-major-mode-filter-functions - #'doom-unreal-buffer-p) - - (defadvice! +workspaces--evil-alternate-buffer-a (&optional window) - "Make `evil-alternate-buffer' ignore buffers outside the current workspace." - :override #'evil-alternate-buffer - (let* ((prev-buffers - (if persp-mode - (cl-remove-if-not #'persp-contain-buffer-p (window-prev-buffers) - :key #'car) - (window-prev-buffers))) - (head (car prev-buffers))) - (if (eq (car head) (window-buffer window)) - (cadr prev-buffers) - head))) - - ;; HACK Fixes #4196, #1525: selecting deleted buffer error when quitting Emacs - ;; or on some buffer listing ops. - (defadvice! +workspaces-remove-dead-buffers-a (persp) - :before #'persp-buffers-to-savelist - (when (perspective-p persp) - ;; HACK Can't use `persp-buffers' because of a race condition with its gv - ;; getter/setter not being defined in time. - (setf (aref persp 2) - (cl-delete-if-not #'persp-get-buffer-or-null (persp-buffers persp))))) - - ;; Delete the current workspace if closing the last open window - (define-key! persp-mode-map - [remap delete-window] #'+workspace/close-window-or-workspace - [remap evil-window-delete] #'+workspace/close-window-or-workspace) - - ;; per-frame workspaces - (setq persp-init-frame-behaviour t - persp-init-new-frame-behaviour-override nil - persp-interactive-init-frame-behaviour-override #'+workspaces-associate-frame-fn - persp-emacsclient-init-frame-behaviour-override #'+workspaces-associate-frame-fn) - (add-hook 'delete-frame-functions #'+workspaces-delete-associated-workspace-h) - (add-hook 'server-done-hook #'+workspaces-delete-associated-workspace-h) - - ;; per-project workspaces, but reuse current workspace if empty - ;; HACK?? needs review - (setq projectile-switch-project-action (lambda () (+workspaces-set-project-action-fn) (+workspaces-switch-to-project-h)) - counsel-projectile-switch-project-action - '(1 ("o" +workspaces-switch-to-project-h "open project in new workspace") - ("O" counsel-projectile-switch-project-action "jump to a project buffer or file") - ("f" counsel-projectile-switch-project-action-find-file "jump to a project file") - ("d" counsel-projectile-switch-project-action-find-dir "jump to a project directory") - ("D" counsel-projectile-switch-project-action-dired "open project in dired") - ("b" counsel-projectile-switch-project-action-switch-to-buffer "jump to a project buffer") - ("m" counsel-projectile-switch-project-action-find-file-manually "find file manually from project root") - ("w" counsel-projectile-switch-project-action-save-all-buffers "save all project buffers") - ("k" counsel-projectile-switch-project-action-kill-buffers "kill all project buffers") - ("r" counsel-projectile-switch-project-action-remove-known-project "remove project from known projects") - ("c" counsel-projectile-switch-project-action-compile "run project compilation command") - ("C" counsel-projectile-switch-project-action-configure "run project configure command") - ("e" counsel-projectile-switch-project-action-edit-dir-locals "edit project dir-locals") - ("v" counsel-projectile-switch-project-action-vc "open project in vc-dir / magit / monky") - ("s" (lambda (project) - (let ((projectile-switch-project-action - (lambda () (call-interactively #'+ivy/project-search)))) - (counsel-projectile-switch-project-by-name project))) "search project") - ("xs" counsel-projectile-switch-project-action-run-shell "invoke shell from project root") - ("xe" counsel-projectile-switch-project-action-run-eshell "invoke eshell from project root") - ("xt" counsel-projectile-switch-project-action-run-term "invoke term from project root") - ("X" counsel-projectile-switch-project-action-org-capture "org-capture into project"))) - - (when (modulep! :completion ivy) - (after! ivy-rich - (cl-callf plist-put ivy-rich-display-transformers-list - '+workspace/switch-to - '(:columns ((ivy-rich-candidate (:width 50)) - (+workspace--ivy-rich-preview)))))) - - (when (modulep! :completion helm) - (after! helm-projectile - (setcar helm-source-projectile-projects-actions - '("Switch to Project" . +workspaces-switch-to-project-h)))) - - ;; Don't bother auto-saving the session if no real buffers are open. - (advice-add #'persp-asave-on-exit :around #'+workspaces-autosave-real-buffers-a) - - ;; Fix #1973: visual selection surviving workspace changes - (add-hook 'persp-before-deactivate-functions #'deactivate-mark) - - ;; Fix #1017: stop session persistence from restoring a broken posframe - (after! posframe - (add-hook! 'persp-after-load-state-functions - (defun +workspaces-delete-all-posframes-h (&rest _) - (posframe-delete-all)))) - - ;; Don't try to persist dead/remote buffers. They cause errors. - (add-hook! 'persp-filter-save-buffers-functions - (defun +workspaces-dead-buffer-p (buf) - ;; Fix #1525: Ignore dead buffers in PERSP's buffer list - (not (buffer-live-p buf))) - (defun +workspaces-remote-buffer-p (buf) - ;; And don't save TRAMP buffers; they're super slow to restore - (let ((dir (buffer-local-value 'default-directory buf))) - (ignore-errors (file-remote-p dir))))) - - ;; Otherwise, buffers opened via bookmarks aren't treated as "real" and are - ;; excluded from the buffer list. - (add-hook 'bookmark-after-jump-hook #'+workspaces-add-current-buffer-h) - - ;;; eshell - (persp-def-buffer-save/load - :mode 'eshell-mode :tag-symbol 'def-eshell-buffer - :save-vars '(major-mode default-directory)) - ;; compile - (persp-def-buffer-save/load - :mode 'compilation-mode :tag-symbol 'def-compilation-buffer - :save-vars '(major-mode default-directory compilation-directory - compilation-environment compilation-arguments)) - ;; magit - (persp-def-buffer-save/load - :mode 'magit-status-mode :tag-symbol 'def-magit-status-buffer - :save-vars '(default-directory) - :load-function (lambda (savelist &rest _) - (cl-destructuring-bind (buffer-name vars &rest _rest) (cdr savelist) - (magit-status (alist-get 'default-directory vars))))) - ;; Restore indirect buffers - (defvar +workspaces--indirect-buffers-to-restore nil) - (persp-def-buffer-save/load - :tag-symbol 'def-indirect-buffer - :predicate #'buffer-base-buffer - :save-function (lambda (buf tag vars) - (list tag (buffer-name buf) vars - (buffer-name (buffer-base-buffer buf)))) - :load-function (lambda (savelist &rest _rest) - (cl-destructuring-bind (buf-name _vars base-buf-name &rest _) - (cdr savelist) - (push (cons buf-name base-buf-name) - +workspaces--indirect-buffers-to-restore) - nil))) - (add-hook! 'persp-after-load-state-functions - (defun +workspaces-reload-indirect-buffers-h (&rest _) - (dolist (ibc +workspaces--indirect-buffers-to-restore) - (cl-destructuring-bind (buffer-name . base-buffer-name) ibc - (let ((base-buffer (get-buffer base-buffer-name))) - (when (buffer-live-p base-buffer) - (when (get-buffer buffer-name) - (setq buffer-name (generate-new-buffer-name buffer-name))) - (make-indirect-buffer base-buffer buffer-name t))))) - (setq +workspaces--indirect-buffers-to-restore nil))) - -;;; tab-bar - (add-hook! 'tab-bar-mode-hook - (defun +workspaces-set-up-tab-bar-integration-h () - (add-hook 'persp-before-deactivate-functions #'+workspaces-save-tab-bar-data-h) - (add-hook 'persp-activated-functions #'+workspaces-load-tab-bar-data-h) - ;; Load and save configurations for tab-bar. - (add-hook 'persp-before-save-state-to-file-functions #'+workspaces-save-tab-bar-data-to-file-h) - (+workspaces-load-tab-bar-data-from-file-h)))) diff --git a/.config/emacs/modules/ui/workspaces/packages.el b/.config/emacs/modules/ui/workspaces/packages.el @@ -1,4 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; ui/workspaces/packages.el - -(package! persp-mode :pin "df95ea710e2a72f7a88293b72137acb0ca024d90") diff --git a/.config/emacs/modules/ui/workspaces/test/test-workspaces.el b/.config/emacs/modules/ui/workspaces/test/test-workspaces.el @@ -1,124 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; ui/workspaces/test/test-workspaces.el - -(describe "ui/workspaces" - :var (persp-auto-resume-time - persp-auto-save-opt - persp-switch-to-added-buffer - persp-autokill-persp-when-removed-last-buffer - persp-autokill-buffer-on-remove - in1 in2 out1 out2 - persp1 persp1-name persp2 persp2-name - wconf) - - (require! :ui workspaces) - (require 'persp-mode) - - (before-all - (delete-other-windows)) - - (before-each - (switch-to-buffer "*scratch*") - (setq wconf (current-window-configuration) - persp-auto-resume-time -1 - persp-auto-save-opt 0 - persp-switch-to-added-buffer nil - persp-autokill-persp-when-removed-last-buffer nil - persp-autokill-buffer-on-remove nil - in1 (get-buffer-create "in1") - in2 (get-buffer-create "in2") - out1 (get-buffer-create "out1") - out2 (get-buffer-create "out2")) - (doom-set-buffer-real in1 t) - (doom-set-buffer-real out1 t) - (let (noninteractive) - (persp-mode +1) - (let (persp-before-switch-functions persp-activated-functions) - (setq persp1-name +workspaces-main - persp1 (persp-add-new persp1-name) - persp2-name "test" - persp2 (persp-add-new persp2-name)) - (persp-switch persp1-name) - (persp-add-buffer (list in1 in2) persp1)))) - - (after-each - (let (kill-buffer-query-functions kill-buffer-hook) - (let (noninteractive ignore-window-parameters) - (dolist (persp (persp-names)) - (ignore-errors (persp-kill persp))) - (persp-mode -1)) - (set-window-configuration wconf) - (mapc #'kill-buffer (list in1 in2 out1 out2)))) - - ;; - (describe "switch" - (it "throws an error when switching to a non-existent workspace" - (expect (+workspace-switch "non-existent") :to-throw)) - (it "switches to a valid workspace" - (+workspace-switch persp2-name) - (expect (+workspace-current-name) :to-equal persp2-name))) - - (describe "current" - (it "returns the current workspace persp" - (expect (+workspace-p (+workspace-current))) - (expect (+workspace-current) :to-equal (get-current-persp))) - (it "returns the current workspace's name" - (expect (+workspace-current-name) :to-equal persp1-name) - (persp-switch (persp-name persp2)) - (expect (+workspace-current-name) :to-equal persp2-name))) - - (describe "exists-p" - (it "returns t for valid workspaces" - (expect (+workspace-exists-p persp1-name))) - (it "returns t for non-current (but valid) workspaces" - (expect (+workspace-exists-p persp2-name))) - (it "returns nil for non-existent workspaces" - (expect (+workspace-exists-p "non-existent") :to-be nil))) - - (describe "buffer membership" - (it "returns t for buffers in current workspace" - (expect (+workspace-contains-buffer-p in1))) - (it "returns nil for buffers outside of current workspace" - (expect (+workspace-contains-buffer-p out1) :to-be nil)) - (xit "returns a list of orphaned buffers" - (expect (+workspace-orphaned-buffer-list) :to-contain out2))) - - (describe "list" - (it "returns a list of names" - (expect (+workspace-list-names) - :to-have-same-items-as (list persp1-name persp2-name))) - (it "returns a list of perspective structs" - (expect (+workspace-list) - :to-have-same-items-as (list persp1 persp2)))) - - (describe "CRUD" - (it "creates new workspaces" - (+workspace-new "X") - (expect (+workspace-list-names) :to-contain "X")) - (it "renames an existing workspace" - (+workspace-rename persp2-name "X") - (expect (persp-name persp2) :to-equal "X") - (expect (+workspace-list-names) - :to-have-same-items-as (list persp1-name "X"))) - (it "deletes a live workspace" - (+workspace-delete persp2-name) - (expect (+workspace-list-names) :not :to-contain persp2-name))) - - (describe "command" - (describe "close-window-or-workspace" - (before-each - (+workspace-switch persp2-name) - (split-window) - (expect (length (doom-visible-windows)) :to-be 2)) - (it "kills window if more than one window" - (quiet! (+workspace/close-window-or-workspace)) - (expect (length (doom-visible-windows)) :to-be 1)) - (it "kills workspace on last window" - (quiet! (+workspace/close-window-or-workspace) - (+workspace/close-window-or-workspace)) - (expect (+workspace-current-name) :to-equal persp1-name))) - - (describe "rename" - (it "renames the current workspace" - (quiet! (+workspace/rename "X")) - (expect (+workspace-current-name) :to-equal "X"))))) diff --git a/.config/emacs/modules/ui/zen/README.org b/.config/emacs/modules/ui/zen/README.org @@ -1,81 +0,0 @@ -#+title: :ui zen -#+subtitle: Distraction-free mode for the eternally distracted -#+created: December 20, 2019 -#+since: 21.12.0 - -* Description :unfold: -This module provides two minor modes that make Emacs into a more comfortable -writing or coding environment. Folks familiar with "distraction-free" or "zen" -modes from other editors -- or [[doom-package:olivetti]], [[doom-package:sublimity]], and [[doom-package:tabula-rasa]] (Emacs -plugins) -- will feel right at home. - -These modes are: -- ~mixed-pitch-mode~ :: - Which renders (most) text in a variable pitch font (see - ~doom-variable-pitch-font~). Unlike ~variable-pitch-mode~, this will not - affect segments of text that are intended to remain in a fixed pitch font, - such as code blocks or ASCII tables. -- ~writeroom-mode~ :: - Our all-in-one "zen" mode that will: - 1. Center the current buffer. - 2. Remove superfluous UI elements (like the modeline). - 3. Activate ~mixed-pitch-mode~. - 4. Scale up the buffer's text slightly (see ~+zen-text-scale~). - 5. And make the window's borders slightly thicker (see - ~+zen-window-divider-size~). - -** Maintainers -- [[doom-user:][@hlissner]] - -[[doom-contrib-maintainer:][Become a maintainer?]] - -** Module flags -/This module has no flags./ - -** Packages -- [[doom-package:mixed-pitch]] -- [[doom-package:writeroom-mode]] - -** Hacks -+ Doom has disabled all of writeroom-mode's "global" effects - (~writeroom-global-effects~ and ~writeroom-maximize-window~ are set to ~nil~), - and encapsulated them into the ~+zen/toggle-fullscreen~ command, whereas - ~+zen/toggle~ will only operate on the current buffer. This way, the user may - choose how far-reaching they want its effect to be. -+ ~text-scale~ has been advised to adjust ~visual-fill-column~'s margins, so its - text won't "squeeze" as you scale it up (or "spill" when scaled down). - -** TODO Changelog -# This section will be machine generated. Don't edit it by hand. -/This module does not have a changelog yet./ - -* Installation -[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] - -/This module has no external requirements./ - -* Usage -This module provides two entry points: - -- ~M-x +zen/toggle~ (on [[kbd:][<leader> t z]]): toggles ~writeroom-mode~ (restricted to - the current buffer). -- ~M-x +zen/toggle-fullscreen~ (on [[kbd:][<leader> t Z]]): toggles zen mode in - full-screen mode (deletes other windows and full screens the Emacs frame). - -Invoke either command again to undo the change. - -* TODO Configuration -#+begin_quote -🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]] -#+end_quote - -* Troubleshooting -/There are no known problems with this module./ [[doom-report:][Report one?]] - -* Frequently asked questions -/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] - -* TODO Appendix -#+begin_quote -🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]] -#+end_quote diff --git a/.config/emacs/modules/ui/zen/autoload.el b/.config/emacs/modules/ui/zen/autoload.el @@ -1,29 +0,0 @@ -;;; ui/zen/autoload.el -*- lexical-binding: t; -*- - -;;;###autoload -(defalias '+zen/toggle #'writeroom-mode) - -(defvar +zen--last-wconf nil) -;;;###autoload -(defun +zen/toggle-fullscreen () - "Toggle `writeroom-mode' fullscreen and delete all other windows. -Invoke again to revert to the window configuration before it was activated." - (interactive) - (require 'writeroom-mode) - (let ((writeroom-global-effects +zen--old-writeroom-global-effects) - (writeroom-maximize-window t)) - (if writeroom-mode - (progn - (set-frame-parameter - nil 'fullscreen - (let ((fullscreen-restore (frame-parameter nil 'fullscreen-restore))) - (if (memq fullscreen-restore '(maximized fullheight fullwidth)) - fullscreen-restore - nil))) - (set-window-configuration +zen--last-wconf)) - (setq +zen--last-wconf (current-window-configuration)) - (modify-frame-parameters - nil `((fullscreen . fullboth) - (fullscreen-restore . ,(frame-parameter nil 'fullscreen))))) - (let ((writeroom-global-effects (remq 'writeroom-set-fullscreen writeroom-global-effects))) - (call-interactively #'+zen/toggle)))) diff --git a/.config/emacs/modules/ui/zen/config.el b/.config/emacs/modules/ui/zen/config.el @@ -1,76 +0,0 @@ -;;; ui/zen/config.el -*- lexical-binding: t; -*- - -(defvar +zen-mixed-pitch-modes '(adoc-mode rst-mode markdown-mode org-mode) - "What major-modes to enable `mixed-pitch-mode' in with `writeroom-mode'.") - -(defvar +zen-text-scale 2 - "The text-scaling level for `writeroom-mode'.") - -(defvar +zen-window-divider-size 4 - "Pixel size of window dividers when `writeroom-mode' is active.") - -(defvar +zen--old-window-divider-size nil) - - -;; -;;; Packages - -(after! writeroom-mode - ;; Users should be able to activate writeroom-mode in one buffer (e.g. an org - ;; buffer) and code in another. No global behavior should be applied. - ;; Fullscreening/maximizing will be opt-in. - (defvar +zen--old-writeroom-global-effects writeroom-global-effects) - (setq writeroom-global-effects nil) - (setq writeroom-maximize-window nil) - - (add-hook! 'writeroom-mode-hook :append - (defun +zen-enable-text-scaling-mode-h () - "Enable `mixed-pitch-mode' when in `+zen-mixed-pitch-modes'." - (when (/= +zen-text-scale 0) - (text-scale-set (if writeroom-mode +zen-text-scale 0)) - (visual-fill-column-adjust)))) - - (add-hook! 'global-writeroom-mode-hook - (defun +zen-toggle-large-window-dividers-h () - "Make window dividers larger and easier to see." - (when (bound-and-true-p window-divider-mode) - (if writeroom-mode - (setq +zen--old-window-divider-size - (cons window-divider-default-bottom-width - window-divider-default-right-width) - window-divider-default-bottom-width +zen-window-divider-size - window-divider-default-right-width +zen-window-divider-size) - (when +zen--old-window-divider-size - (setq window-divider-default-bottom-width (car +zen--old-window-divider-size) - window-divider-default-right-width (cdr +zen--old-window-divider-size)))) - (window-divider-mode +1)))) - - ;; Adjust margins when text size is changed - (advice-add #'text-scale-adjust :after #'visual-fill-column-adjust)) - - -(use-package! mixed-pitch - :hook (writeroom-mode . +zen-enable-mixed-pitch-mode-h) - :config - (defun +zen-enable-mixed-pitch-mode-h () - "Enable `mixed-pitch-mode' when in `+zen-mixed-pitch-modes'." - (when (apply #'derived-mode-p +zen-mixed-pitch-modes) - (mixed-pitch-mode (if writeroom-mode +1 -1)))) - - (pushnew! mixed-pitch-fixed-pitch-faces - 'solaire-line-number-face - 'org-date - 'org-footnote - 'org-special-keyword - 'org-property-value - 'org-ref-cite-face - 'org-tag - 'org-todo-keyword-todo - 'org-todo-keyword-habt - 'org-todo-keyword-done - 'org-todo-keyword-wait - 'org-todo-keyword-kill - 'org-todo-keyword-outd - 'org-todo - 'org-done - 'font-lock-comment-face)) diff --git a/.config/emacs/modules/ui/zen/packages.el b/.config/emacs/modules/ui/zen/packages.el @@ -1,5 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; ui/zen/packages.el - -(package! writeroom-mode :pin "1fd52848eb58301c864712fd26c4ec37a938cc19") -(package! mixed-pitch :pin "519e05f74825abf04b7d2e0e38ec040d013a125a") diff --git a/.config/emacs/profiles/README.org b/.config/emacs/profiles/README.org @@ -1,154 +0,0 @@ -#+title: Doom's profile directory - -* Introduction -In order to power Doom's soon-to-be generational package manager, I wrote a -profile system. This system can effectively replace [[https://github.com/plexus/chemacs2][Chemacs]]; permitting you to -switch between multiple Emacs configs on-demand (and those configs don't have to -be Doom configs). - -While I work on the formal documentation for this system, I've created this -brief guide to walk users through their use. *However, for this to work, Doom -must live in =~/.emacs.d= or =~/.config/emacs=.* I'll refer to this as -=$EMACSDIR= (and your private Doom config, in =~/.doom.d= or =~/.config/doom=, -as =$DOOMDIR=). - -* How use profiles -1. Declare all your profiles in either: - - One or multiple profile files at: - - =$DOOMDIR/profiles.el= - - =$EMACSDIR/profiles.el= - - =~/.config/doom-profiles.el= - - =~/.doom-profiles.el= - - [[id:f9bce7da-d155-4727-9b6f-b566b5b8d824][Example profiles.el file]]. - - - Or an implicit profile, which are inferred from the sub-directories of: - - =$DOOMDIR/profiles/= - - =$EMACSDIR/profiles/= - - Implicit profiles may have a =.doomprofile= file to apply additional - settings. [[id:ac37ac6f-6082-4c34-b98c-962bc1e528c9][Example .doomprofile]]. - -2. To run ~$ doom sync~ whenever you change the above, to regenerate Doom's - cached profile loader (generated at =$EMACSDIR/profiles/init.X.elc=, where X - is your major Emacs version). - -3. To launch a profile: - - Launch the profile you want: ~$ emacs --profile FOO~ - - Use ~bin/doom~ on the profile you want: ~$ doom sync --profile FOO~ - -* Auto-generated profiles -Doom v3's sandbox and transactional package manager are capable of generating -profiles on-the-fly. The former for rapid, isolated testing, and the latter for -rollback/snapshot traversal for disaster recovery purposes. - -These auto-generated profiles will be stored and versioned in: -=$XDG_DATA_HOME/doom/$PROFILE_NAME/@/$PROFILE_VERSION/= - -* Fallback profile -Unlike Chemacs, Doom's profiles has no notion of a "default"/fallback profile. -The fallback profile is the Doom installation doing the bootloading. This -"global" profile is unique in that it won't respect a =.doomprofile= -- in other -words, it's not treated as a normal profile. - -It is this way so that the profiles system imposes no overhead on users that -aren't interested in the profile system (or prefer to use Chemacs). - -However, you can emulate this behavior by registering the "global" profile as a -profile, and setting ~$DOOMPROFILE~ or aliasing ~emacs~, like so: - -#+begin_src emacs-lisp -;; in a profiles.el file -((default) - - ...) -#+end_src - -#+begin_src bash -# in .zshrc or .bash_profile -export DOOMPROFILE=default - -# Or -alias emacs='emacs --profile default' -#+end_src - -* Gotchas -There are two caveats with this profile system: - -- It requires that Doom live in =~/.config/emacs= or =~/.emacs.d=. A - non-standard install location won't work, unless you use Emacs 29's new - =--init-directory DIR= switch and launch Emacs with ~emacs --init-directory - ~/nonstandard/emacs.d --profile NAME~. =bin/doom= is fine with it, though. - -- The profile system can be storage-inefficient. A barebones Doom config - averages at ~1mb without installed packages and ~3.75mb /with/ (straight alone - is 2.6m). A fully-fledged Doom config can average 500mb-1.4gb; the majority of - which are packages, but include server binaries, elisp+native bytecode, and - caches add up too. - - To mitigate this, Doom dedups packages across snapshots of a single profile - (e.g. =profile@23= -> =profile@24=), but it cannot (yet) do this across - profiles (e.g. if =profile1= and =profile2= both install =org=). Even then, - packages whose recipes change (either locally or upstream) may dodge this - deduplication and get cloned anew (to ensure historical integrity) -- though - this shouldn't happen often, but can build up over time. - - So v3 will introduce a ~doom gc~ command, which offers a couple nix.gc-esque - switches to control it. E.g. - - - Acts on the "global" profile: - - ~doom gc --older-than 21d~ - - ~doom gc --keep 10~ - - Act on a specific profile: - - ~doom gc --profile foo ...~ - - Act on all known profiles - - ~doom gc --profiles '*' ...~ - - Users can change defaults from their =init.el= or =cli.el=, or configure ~doom - sync~ to auto-GC by whatever rules they like. And the good doctor will warn - you if you haven't GCed in a while, or you're in excess of some threshold - (which I haven't decided yet). - -* How to switch from Chemacs -1. Delete [[https://github.com/plexus/chemacs2][Chemacs]] from =$EMACSDIR=. - -2. Install Doom there: ~$ git clone https://github.com/doomemacs/doomemacs - ~/.config/emacs~ - -3. Move =~/.emacs-profiles.el= to =~/.config/doom/profiles.el= and transform the - string keys to symbols and adapt =env= entries like so: - - #+begin_src emacs-lisp - ;; ~/.emacs-profiles.el - (("default" (user-emacs-directory . "~/.emacs.default") - (env ("DOOMDIR" . "~/.doom.private"))) - ("spacemacs" (user-emacs-directory . "~/spacemacs")) - ("prelude" (user-emacs-directory . "~/prelude"))) - - ;; ~/.config/emacs/profiles.el - ((default (user-emacs-directory . "~/.emacs.default") - ("DOOMDIR" . "~/.doom.private")) - (spacemacs (user-emacs-directory . "~/spacemacs")) - (prelude (user-emacs-directory . "~/prelude"))) - #+end_src - - A comprehensive example of Doom's profiles.el file can be found - [[id:f9bce7da-d155-4727-9b6f-b566b5b8d824][in docs/examples.org]]. - - *Differences with Chemacs profiles:* - - Keys are symbols, not strings. - - Doom's profiles.el has a syntax for evaluating code, expanding paths, and - appending/prepending to variables (with deferral). See the examples.org - link above. - - Doom's profile system won't install [[https://github.com/raxod502/straight.el][Straight.el]] for you. - - Doom does not have a special "default" profile. If you don't specify a - --profile, it will simply start up the Doom config living in - =~/.config/emacs=. See the "Fallback profile" section below for a - workaround. - -4. Then launch a profile. E.g. ~$ emacs --profile prelude~. - -* But Doom is kinda heavy to be a bootloader... -I agree! To remedy that, I'll soon split Doom up into three projects: its core -(where its bootloader lives), its official modules, and its community -contributed modules. At that point, Doom will be much lighter! diff --git a/.config/emacs/profiles/load.28.elc b/.config/emacs/profiles/load.28.elc Binary files differ. diff --git a/.config/emacs/profiles/load.el b/.config/emacs/profiles/load.el @@ -1,15 +0,0 @@ -;; -*- lexical-binding: t; tab-width: 8; -*- -;; Updated: 2023-05-21 14:35:06 -;; Generated by 'doom profiles sync' or 'doom sync'. -;; DO NOT EDIT THIS BY HAND! -"3.0.0-pre" -(pcase - (intern - (getenv-internal "DOOMPROFILE")) - ('safe-mode - (let nil - (setq user-emacs-directory - (expand-file-name "safe-mode/" - (expand-file-name "~/.config/emacs/profiles" user-emacs-directory)))))) -(setq user-emacs-directory - (file-name-as-directory user-emacs-directory)) diff --git a/.config/emacs/profiles/safe-mode/init.el b/.config/emacs/profiles/safe-mode/init.el @@ -1 +0,0 @@ -; Nothing here yet! diff --git a/.config/emacs/shell.nix b/.config/emacs/shell.nix @@ -1,101 +0,0 @@ -# Builds a sandbox for Emacs (and optionally, Doom) with a particular version of -# Emacs. Use this as a basis for module shell.nix's. -# -# Usage examples: -# -# To create a doom environment with the test config: -# -# nix-shell -# -# With your own DOOMDIR: -# -# nix-shell --argstr doomdir ~/.config/other-doom-config -# -# With a specific version of Emacs -# -# nix-shell --argstr emacs 26.3 # 26.3 -# nix-shell --argstr emacs 27.1 # 27.1 -# nix-shell --argstr emacs 27.2 # 27.2 -# nix-shell --argstr emacs 28.1 # 28.1 -# nix-shell --argstr emacs 28.2 # 28.2 -# nix-shell --argstr emacs head # 29.0.50 -# nix-shell --argstr emacs ci-26.3 # 26.3 (barebones; no GUI) -# nix-shell --argstr emacs ci-27.1 # 27.1 (barebones; no GUI) -# nix-shell --argstr emacs ci-27.2 # 27.2 (barebones; no GUI) -# nix-shell --argstr emacs ci-HEAD # 29.0.50 (barebones; no GUI) - -{ pkgs ? import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/22.05.tar.gz") - { - overlays = [ - # emacs-overlay: provides EmacsGit, EmacsNativeComp, and EmacsPgtkNativeComp - (import (fetchTarball "https://github.com/nix-community/emacs-overlay/archive/88e410d7f1ddef554b40f66755626e5c883487d9.tar.gz")) - # nix-emacs-ci: provides CI versions of Emacs 26.3, 27.1, 27.2, 28.1, 28.2, and snapshot - (_: _: (import (fetchTarball "https://github.com/purcell/nix-emacs-ci/archive/master.tar.gz"))) - # emacs{26,27-{1,2},28-1} - (_: _: { - emacs26 = (import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/11264a390b197b80edeffac6f20e582f3ea318bd.tar.gz") {}).emacs26; - emacs27-1 = (import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/11264a390b197b80edeffac6f20e582f3ea318bd.tar.gz") {}).emacs; - emacs27-2 = (import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/4c87cb87a2db6b9eb43541c1cf83f2a2f725fa25.tar.gz") {}).emacs; - emacs28-1 = (import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/54e795706d9fa90004ed1274af639a717f04a2aa.tar.gz") {}).emacs; - }) - ]; - } -, emacs ? "28.2" -, emacsdir ? "$(pwd)" -, doomdir ? "" -, doomlocaldir ? "$EMACSDIR/.local" }: - -let emacsPkg = (if emacs == "26.3" then pkgs.emacs26 - else if emacs == "27.1" then pkgs.emacs27-1 - else if emacs == "27.2" then pkgs.emacs27-2 - else if emacs == "28.1" then pkgs.emacs28-1 - else if emacs == "28.2" then pkgs.emacs - else if emacs == "head" then pkgs.emacsGit - else if emacs == "ci-26.3" then pkgs.emacs-26-3 - else if emacs == "ci-27.1" then pkgs.emacs-27-1 - else if emacs == "ci-27.2" then pkgs.emacs-27-2 - else if emacs == "ci-28.1" then pkgs.emacs-28-1 - else if emacs == "ci-28.2" then pkgs.emacs-28-2 - else if emacs == "ci-head" then pkgs.emacs-snapshot - else pkgs.emacs); -in pkgs.stdenv.mkDerivation { - name = "doom-emacs"; - - buildInputs = [ - emacsPkg - pkgs.git - (pkgs.ripgrep.override {withPCRE2 = true;}) - ]; - - shellHook = '' - export EMACS="${emacsPkg}/bin/emacs" - export EMACSVERSION="$($EMACS --no-site-file --batch --eval '(princ emacs-version)')" - if [[ -n "${emacsdir}" ]]; then - export EMACSDIR="$(readlink -f "${emacsdir}")/" - fi - if [[ -n "${doomdir}" ]]; then - export DOOMDIR="$(readlink -f "${doomdir}")/" - fi - if [[ -n "${doomlocaldir}" ]]; then - export DOOMLOCALDIR="$(readlink -f "${doomlocaldir}").$EMACSVERSION/" - fi - export DOOMNOCOMPILE=1 - export PATH="$EMACSDIR/bin:$PATH" - - echo "Running Emacs $EMACSVERSION (emacs=${emacs})" - echo "EMACSDIR=$EMACSDIR" - echo "DOOMDIR=$DOOMDIR" - echo "DOOMLOCALDIR=$DOOMLOCALDIR" - - # Copy your existing repos over to optimize on install times (but not the - # builds, because that may contain stale bytecode). - mkdir -p "$DOOMLOCALDIR/straight" - pushd "$DOOMLOCALDIR/straight" >/dev/null - if [[ -d "$EMACSDIR/.local/straight/repos" && ! -d ./repos ]]; then - echo "Copying '$EMACSDIR/.local/straight/repos' to './$(basename $DOOMLOCALDIR)/straight/repos' to save time" - cp -r "$EMACSDIR/.local/straight/repos" ./repos - fi - popd >/dev/null - echo "Ready! Remember to 'doom sync'!" - ''; -} diff --git a/.config/emacs/templates/BUG_REPORT b/.config/emacs/templates/BUG_REPORT @@ -1,29 +0,0 @@ -Please read through the following before you submit your issue. - -+ [ ] Running `make` (then restarting Emacs) did not fix my issue -+ [ ] If I have byte-compiled, I've tried recompiling with `make compile` -+ [ ] If I changed the version of Emacs installed, I've recompiled by plugins - with `make compile-elpa` -+ [ ] I ran `make doctor` and it produced no leads -+ [ ] My issue cannot be found [on the wiki](/docs/troubleshoot.org) -+ [ ] I filled out the four fields in the template below - -------------------------------------------------------------------- - -### Observed behavior - -<!-- What happened --> - -### Expected behavior - -<!-- What *should* have happened --> - -### Steps to reproduce - -<!-- Tell us how to reproduce the issue in steps --> - -### Extra details - -<!-- Include backtraces & screenshots if possible --> - -------------------------------------------------------------------- diff --git a/.config/emacs/templates/QUICKSTART_INTRO b/.config/emacs/templates/QUICKSTART_INTRO @@ -1,19 +0,0 @@ -But before you doom yourself, here are some things you should know: - -1. Don't forget to run 'doom sync', then restart Emacs, after modifying init.el - or packages.el in ~/.config/doom. - - This command ensures needed packages are installed, orphaned packages are - removed, and your autoloads/cache files are up to date. When in doubt, run - 'doom sync'! - -2. If something goes wrong, run `doom doctor`. It diagnoses common issues with - your environment and setup, and may offer clues about what is wrong. - -3. Use 'doom upgrade' to update Doom. Doing it any other way will require - additional steps. Run 'doom help upgrade' to understand those extra steps. - -4. Access Doom's documentation from within Emacs via 'SPC h d h' or 'C-h d h' - (or 'M-x doom/help') - -Have fun! diff --git a/.config/emacs/templates/VANILLA_SANDBOX b/.config/emacs/templates/VANILLA_SANDBOX @@ -1,12 +0,0 @@ -;; Welcome to the sandbox! -;; -;; This is a test bed for running Emacs Lisp in another instance of Emacs that -;; has varying amounts of Doom loaded: -;; -;; - vanilla Emacs (nothing loaded) \[doom--run-vanilla-emacs] -;; - vanilla Doom (only Doom core) \[doom--run-vanilla-doom] -;; - Doom + modules - your private config \[doom--run-vanilla-doom+] -;; - Doom + modules + your private config \[doom--run-full-doom] -;; -;; This is done without sacrificing access to installed packages. Use the sandbox -;; to reproduce bugs and determine if Doom is to blame. diff --git a/.config/emacs/templates/config.example.el b/.config/emacs/templates/config.example.el @@ -1,76 +0,0 @@ -;;; $DOOMDIR/config.el -*- lexical-binding: t; -*- - -;; Place your private configuration here! Remember, you do not need to run 'doom -;; sync' after modifying this file! - - -;; Some functionality uses this to identify you, e.g. GPG configuration, email -;; clients, file templates and snippets. It is optional. -(setq user-full-name "John Doe" - user-mail-address "john@doe.com") - -;; Doom exposes five (optional) variables for controlling fonts in Doom: -;; -;; - `doom-font' -- the primary font to use -;; - `doom-variable-pitch-font' -- a non-monospace font (where applicable) -;; - `doom-big-font' -- used for `doom-big-font-mode'; use this for -;; presentations or streaming. -;; - `doom-unicode-font' -- for unicode glyphs -;; - `doom-serif-font' -- for the `fixed-pitch-serif' face -;; -;; See 'C-h v doom-font' for documentation and more examples of what they -;; accept. For example: -;; -;;(setq doom-font (font-spec :family "Fira Code" :size 12 :weight 'semi-light) -;; doom-variable-pitch-font (font-spec :family "Fira Sans" :size 13)) -;; -;; If you or Emacs can't find your font, use 'M-x describe-font' to look them -;; up, `M-x eval-region' to execute elisp code, and 'M-x doom/reload-font' to -;; refresh your font settings. If Emacs still can't find your font, it likely -;; wasn't installed correctly. Font issues are rarely Doom issues! - -;; There are two ways to load a theme. Both assume the theme is installed and -;; available. You can either set `doom-theme' or manually load a theme with the -;; `load-theme' function. This is the default: -(setq doom-theme 'doom-one) - -;; This determines the style of line numbers in effect. If set to `nil', line -;; numbers are disabled. For relative line numbers, set this to `relative'. -(setq display-line-numbers-type t) - -;; If you use `org' and don't want your org files in the default location below, -;; change `org-directory'. It must be set before org loads! -(setq org-directory "~/org/") - - -;; Whenever you reconfigure a package, make sure to wrap your config in an -;; `after!' block, otherwise Doom's defaults may override your settings. E.g. -;; -;; (after! PACKAGE -;; (setq x y)) -;; -;; The exceptions to this rule: -;; -;; - Setting file/directory variables (like `org-directory') -;; - Setting variables which explicitly tell you to set them before their -;; package is loaded (see 'C-h v VARIABLE' to look up their documentation). -;; - Setting doom variables (which start with 'doom-' or '+'). -;; -;; Here are some additional functions/macros that will help you configure Doom. -;; -;; - `load!' for loading external *.el files relative to this one -;; - `use-package!' for configuring packages -;; - `after!' for running code after a package has loaded -;; - `add-load-path!' for adding directories to the `load-path', relative to -;; this file. Emacs searches the `load-path' when you load packages with -;; `require' or `use-package'. -;; - `map!' for binding new keys -;; -;; To get information about any of these functions/macros, move the cursor over -;; the highlighted symbol at press 'K' (non-evil users must press 'C-c c k'). -;; This will open documentation for it, including demos of how they are used. -;; Alternatively, use `C-h o' to look up a symbol (functions, variables, faces, -;; etc). -;; -;; You can also try 'gd' (or 'C-c c d') to jump to their definition and see how -;; they are implemented. diff --git a/.config/emacs/templates/init.example.el b/.config/emacs/templates/init.example.el @@ -1,194 +0,0 @@ -;;; init.el -*- lexical-binding: t; -*- - -;; This file controls what Doom modules are enabled and what order they load -;; in. Remember to run 'doom sync' after modifying it! - -;; NOTE Press 'SPC h d h' (or 'C-h d h' for non-vim users) to access Doom's -;; documentation. There you'll find a link to Doom's Module Index where all -;; of our modules are listed, including what flags they support. - -;; NOTE Move your cursor over a module's name (or its flags) and press 'K' (or -;; 'C-c c k' for non-vim users) to view its documentation. This works on -;; flags as well (those symbols that start with a plus). -;; -;; Alternatively, press 'gd' (or 'C-c c d') on a module to browse its -;; directory (for easy access to its source code). - -(doom! :input - ;;bidi ; (tfel ot) thgir etirw uoy gnipleh - ;;chinese - ;;japanese - ;;layout ; auie,ctsrnm is the superior home row - - :completion - company ; the ultimate code completion backend - ;;helm ; the *other* search engine for love and life - ;;ido ; the other *other* search engine... - ;;ivy ; a search engine for love and life - vertico ; the search engine of the future - - :ui - ;;deft ; notational velocity for Emacs - doom ; what makes DOOM look the way it does - doom-dashboard ; a nifty splash screen for Emacs - ;;doom-quit ; DOOM quit-message prompts when you quit Emacs - ;;(emoji +unicode) ; 🙂 - hl-todo ; highlight TODO/FIXME/NOTE/DEPRECATED/HACK/REVIEW - ;;hydra - ;;indent-guides ; highlighted indent columns - ;;ligatures ; ligatures and symbols to make your code pretty again - ;;minimap ; show a map of the code on the side - modeline ; snazzy, Atom-inspired modeline, plus API - ;;nav-flash ; blink cursor line after big motions - ;;neotree ; a project drawer, like NERDTree for vim - ophints ; highlight the region an operation acts on - (popup +defaults) ; tame sudden yet inevitable temporary windows - ;;tabs ; a tab bar for Emacs - ;;treemacs ; a project drawer, like neotree but cooler - ;;unicode ; extended unicode support for various languages - (vc-gutter +pretty) ; vcs diff in the fringe - vi-tilde-fringe ; fringe tildes to mark beyond EOB - ;;window-select ; visually switch windows - workspaces ; tab emulation, persistence & separate workspaces - ;;zen ; distraction-free coding or writing - - :editor - (evil +everywhere); come to the dark side, we have cookies - file-templates ; auto-snippets for empty files - fold ; (nigh) universal code folding - ;;(format +onsave) ; automated prettiness - ;;god ; run Emacs commands without modifier keys - ;;lispy ; vim for lisp, for people who don't like vim - ;;multiple-cursors ; editing in many places at once - ;;objed ; text object editing for the innocent - ;;parinfer ; turn lisp into python, sort of - ;;rotate-text ; cycle region at point between text candidates - snippets ; my elves. They type so I don't have to - ;;word-wrap ; soft wrapping with language-aware indent - - :emacs - dired ; making dired pretty [functional] - electric ; smarter, keyword-based electric-indent - ;;ibuffer ; interactive buffer management - undo ; persistent, smarter undo for your inevitable mistakes - vc ; version-control and Emacs, sitting in a tree - - :term - ;;eshell ; the elisp shell that works everywhere - ;;shell ; simple shell REPL for Emacs - ;;term ; basic terminal emulator for Emacs - ;;vterm ; the best terminal emulation in Emacs - - :checkers - syntax ; tasing you for every semicolon you forget - ;;(spell +flyspell) ; tasing you for misspelling mispelling - ;;grammar ; tasing grammar mistake every you make - - :tools - ;;ansible - ;;biblio ; Writes a PhD for you (citation needed) - ;;debugger ; FIXME stepping through code, to help you add bugs - ;;direnv - ;;docker - ;;editorconfig ; let someone else argue about tabs vs spaces - ;;ein ; tame Jupyter notebooks with emacs - (eval +overlay) ; run code, run (also, repls) - ;;gist ; interacting with github gists - lookup ; navigate your code and its documentation - ;;lsp ; M-x vscode - magit ; a git porcelain for Emacs - ;;make ; run make tasks from Emacs - ;;pass ; password manager for nerds - ;;pdf ; pdf enhancements - ;;prodigy ; FIXME managing external services & code builders - ;;rgb ; creating color strings - ;;taskrunner ; taskrunner for all your projects - ;;terraform ; infrastructure as code - ;;tmux ; an API for interacting with tmux - ;;tree-sitter ; syntax and parsing, sitting in a tree... - ;;upload ; map local to remote projects via ssh/ftp - - :os - (:if IS-MAC macos) ; improve compatibility with macOS - ;;tty ; improve the terminal Emacs experience - - :lang - ;;agda ; types of types of types of types... - ;;beancount ; mind the GAAP - ;;(cc +lsp) ; C > C++ == 1 - ;;clojure ; java with a lisp - ;;common-lisp ; if you've seen one lisp, you've seen them all - ;;coq ; proofs-as-programs - ;;crystal ; ruby at the speed of c - ;;csharp ; unity, .NET, and mono shenanigans - ;;data ; config/data formats - ;;(dart +flutter) ; paint ui and not much else - ;;dhall - ;;elixir ; erlang done right - ;;elm ; care for a cup of TEA? - emacs-lisp ; drown in parentheses - ;;erlang ; an elegant language for a more civilized age - ;;ess ; emacs speaks statistics - ;;factor - ;;faust ; dsp, but you get to keep your soul - ;;fortran ; in FORTRAN, GOD is REAL (unless declared INTEGER) - ;;fsharp ; ML stands for Microsoft's Language - ;;fstar ; (dependent) types and (monadic) effects and Z3 - ;;gdscript ; the language you waited for - ;;(go +lsp) ; the hipster dialect - ;;(graphql +lsp) ; Give queries a REST - ;;(haskell +lsp) ; a language that's lazier than I am - ;;hy ; readability of scheme w/ speed of python - ;;idris ; a language you can depend on - ;;json ; At least it ain't XML - ;;(java +lsp) ; the poster child for carpal tunnel syndrome - ;;javascript ; all(hope(abandon(ye(who(enter(here)))))) - ;;julia ; a better, faster MATLAB - ;;kotlin ; a better, slicker Java(Script) - ;;latex ; writing papers in Emacs has never been so fun - ;;lean ; for folks with too much to prove - ;;ledger ; be audit you can be - ;;lua ; one-based indices? one-based indices - markdown ; writing docs for people to ignore - ;;nim ; python + lisp at the speed of c - ;;nix ; I hereby declare "nix geht mehr!" - ;;ocaml ; an objective camel - org ; organize your plain life in plain text - ;;php ; perl's insecure younger brother - ;;plantuml ; diagrams for confusing people more - ;;purescript ; javascript, but functional - ;;python ; beautiful is better than ugly - ;;qt ; the 'cutest' gui framework ever - ;;racket ; a DSL for DSLs - ;;raku ; the artist formerly known as perl6 - ;;rest ; Emacs as a REST client - ;;rst ; ReST in peace - ;;(ruby +rails) ; 1.step {|i| p "Ruby is #{i.even? ? 'love' : 'life'}"} - ;;(rust +lsp) ; Fe2O3.unwrap().unwrap().unwrap().unwrap() - ;;scala ; java, but good - ;;(scheme +guile) ; a fully conniving family of lisps - sh ; she sells {ba,z,fi}sh shells on the C xor - ;;sml - ;;solidity ; do you need a blockchain? No. - ;;swift ; who asked for emoji variables? - ;;terra ; Earth and Moon in alignment for performance. - ;;web ; the tubes - ;;yaml ; JSON, but readable - ;;zig ; C, but simpler - - :email - ;;(mu4e +org +gmail) - ;;notmuch - ;;(wanderlust +gmail) - - :app - ;;calendar - ;;emms - ;;everywhere ; *leave* Emacs!? You must be joking - ;;irc ; how neckbeards socialize - ;;(rss +org) ; emacs as an RSS reader - ;;twitter ; twitter client https://twitter.com/vnought - - :config - ;;literate - (default +bindings +smartparens)) diff --git a/.config/emacs/templates/packages.example.el b/.config/emacs/templates/packages.example.el @@ -1,50 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; $DOOMDIR/packages.el - -;; To install a package with Doom you must declare them here and run 'doom sync' -;; on the command line, then restart Emacs for the changes to take effect -- or -;; use 'M-x doom/reload'. - - -;; To install SOME-PACKAGE from MELPA, ELPA or emacsmirror: -;(package! some-package) - -;; To install a package directly from a remote git repo, you must specify a -;; `:recipe'. You'll find documentation on what `:recipe' accepts here: -;; https://github.com/radian-software/straight.el#the-recipe-format -;(package! another-package -; :recipe (:host github :repo "username/repo")) - -;; If the package you are trying to install does not contain a PACKAGENAME.el -;; file, or is located in a subdirectory of the repo, you'll need to specify -;; `:files' in the `:recipe': -;(package! this-package -; :recipe (:host github :repo "username/repo" -; :files ("some-file.el" "src/lisp/*.el"))) - -;; If you'd like to disable a package included with Doom, you can do so here -;; with the `:disable' property: -;(package! builtin-package :disable t) - -;; You can override the recipe of a built in package without having to specify -;; all the properties for `:recipe'. These will inherit the rest of its recipe -;; from Doom or MELPA/ELPA/Emacsmirror: -;(package! builtin-package :recipe (:nonrecursive t)) -;(package! builtin-package-2 :recipe (:repo "myfork/package")) - -;; Specify a `:branch' to install a package from a particular branch or tag. -;; This is required for some packages whose default branch isn't 'master' (which -;; our package manager can't deal with; see radian-software/straight.el#279) -;(package! builtin-package :recipe (:branch "develop")) - -;; Use `:pin' to specify a particular commit to install. -;(package! builtin-package :pin "1a2b3c4d5e") - - -;; Doom's packages are pinned to a specific commit and updated from release to -;; release. The `unpin!' macro allows you to unpin single packages... -;(unpin! pinned-package) -;; ...or multiple packages -;(unpin! pinned-package another-pinned-package) -;; ...Or *all* packages (NOT RECOMMENDED; will likely break things) -;(unpin! t)