config

Personal configuration.
git clone git://code.dwrz.net/config
Log | Files | Refs

commit c8c48a113265657b0d393b731d54e74cf22bdb3a
parent db094898f9b368e83ce63dc5b197a5a55f9bb70e
Author: dwrz <dwrz@dwrz.net>
Date:   Wed,  5 Jun 2024 01:42:49 +0000

Update Emacs packages

Diffstat:
Memacs/elpa/archives/gnu/archive-contents | 95+++++++++++++++++++++++++++++++++++++++++++++----------------------------------
Memacs/elpa/archives/gnu/archive-contents.signed | 4++--
Memacs/elpa/archives/melpa/archive-contents | 281+++++++++++++++++++++++++++++++++++++++++--------------------------------------
Memacs/elpa/archives/nongnu/archive-contents | 48+++++++++++++++++++++++-------------------------
Memacs/elpa/archives/nongnu/archive-contents.signed | 4++--
Demacs/elpa/consult-20240516.2240/consult-pkg.el | 15---------------
Demacs/elpa/consult-20240516.2240/consult.el | 5262-------------------------------------------------------------------------------
Demacs/elpa/consult-20240516.2240/consult.elc | 0
Remacs/elpa/consult-20240516.2240/consult-autoloads.el -> emacs/elpa/consult-20240523.754/consult-autoloads.el | 0
Remacs/elpa/consult-20240516.2240/consult-compile.el -> emacs/elpa/consult-20240523.754/consult-compile.el | 0
Remacs/elpa/consult-20240516.2240/consult-compile.elc -> emacs/elpa/consult-20240523.754/consult-compile.elc | 0
Remacs/elpa/consult-20240516.2240/consult-flymake.el -> emacs/elpa/consult-20240523.754/consult-flymake.el | 0
Remacs/elpa/consult-20240516.2240/consult-flymake.elc -> emacs/elpa/consult-20240523.754/consult-flymake.elc | 0
Remacs/elpa/consult-20240516.2240/consult-imenu.el -> emacs/elpa/consult-20240523.754/consult-imenu.el | 0
Remacs/elpa/consult-20240516.2240/consult-imenu.elc -> emacs/elpa/consult-20240523.754/consult-imenu.elc | 0
Remacs/elpa/consult-20240516.2240/consult-info.el -> emacs/elpa/consult-20240523.754/consult-info.el | 0
Remacs/elpa/consult-20240516.2240/consult-info.elc -> emacs/elpa/consult-20240523.754/consult-info.elc | 0
Remacs/elpa/consult-20240516.2240/consult-kmacro.el -> emacs/elpa/consult-20240523.754/consult-kmacro.el | 0
Remacs/elpa/consult-20240516.2240/consult-kmacro.elc -> emacs/elpa/consult-20240523.754/consult-kmacro.elc | 0
Remacs/elpa/consult-20240516.2240/consult-org.el -> emacs/elpa/consult-20240523.754/consult-org.el | 0
Remacs/elpa/consult-20240516.2240/consult-org.elc -> emacs/elpa/consult-20240523.754/consult-org.elc | 0
Aemacs/elpa/consult-20240523.754/consult-pkg.el | 15+++++++++++++++
Remacs/elpa/consult-20240516.2240/consult-register.el -> emacs/elpa/consult-20240523.754/consult-register.el | 0
Remacs/elpa/consult-20240516.2240/consult-register.elc -> emacs/elpa/consult-20240523.754/consult-register.elc | 0
Remacs/elpa/consult-20240516.2240/consult-xref.el -> emacs/elpa/consult-20240523.754/consult-xref.el | 0
Remacs/elpa/consult-20240516.2240/consult-xref.elc -> emacs/elpa/consult-20240523.754/consult-xref.elc | 0
Aemacs/elpa/consult-20240523.754/consult.el | 5262+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aemacs/elpa/consult-20240523.754/consult.elc | 0
Demacs/elpa/corfu-20240413.927/corfu-echo.el | 109-------------------------------------------------------------------------------
Demacs/elpa/corfu-20240413.927/corfu-history.el | 92-------------------------------------------------------------------------------
Demacs/elpa/corfu-20240413.927/corfu-indexed.el | 97-------------------------------------------------------------------------------
Demacs/elpa/corfu-20240413.927/corfu-info.el | 118-------------------------------------------------------------------------------
Demacs/elpa/corfu-20240413.927/corfu-pkg.el | 15---------------
Demacs/elpa/corfu-20240413.927/corfu-popupinfo.el | 523-------------------------------------------------------------------------------
Demacs/elpa/corfu-20240413.927/corfu-quick.el | 154-------------------------------------------------------------------------------
Demacs/elpa/corfu-20240413.927/corfu.el | 1395-------------------------------------------------------------------------------
Remacs/elpa/corfu-20240413.927/corfu-autoloads.el -> emacs/elpa/corfu-20240523.752/corfu-autoloads.el | 0
Aemacs/elpa/corfu-20240523.752/corfu-echo.el | 109+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Remacs/elpa/corfu-20240413.927/corfu-echo.elc -> emacs/elpa/corfu-20240523.752/corfu-echo.elc | 0
Aemacs/elpa/corfu-20240523.752/corfu-history.el | 92+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Remacs/elpa/corfu-20240413.927/corfu-history.elc -> emacs/elpa/corfu-20240523.752/corfu-history.elc | 0
Aemacs/elpa/corfu-20240523.752/corfu-indexed.el | 97+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Remacs/elpa/corfu-20240413.927/corfu-indexed.elc -> emacs/elpa/corfu-20240523.752/corfu-indexed.elc | 0
Aemacs/elpa/corfu-20240523.752/corfu-info.el | 118+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Remacs/elpa/corfu-20240413.927/corfu-info.elc -> emacs/elpa/corfu-20240523.752/corfu-info.elc | 0
Aemacs/elpa/corfu-20240523.752/corfu-pkg.el | 15+++++++++++++++
Aemacs/elpa/corfu-20240523.752/corfu-popupinfo.el | 523+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Remacs/elpa/corfu-20240413.927/corfu-popupinfo.elc -> emacs/elpa/corfu-20240523.752/corfu-popupinfo.elc | 0
Aemacs/elpa/corfu-20240523.752/corfu-quick.el | 154+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Remacs/elpa/corfu-20240413.927/corfu-quick.elc -> emacs/elpa/corfu-20240523.752/corfu-quick.elc | 0
Aemacs/elpa/corfu-20240523.752/corfu.el | 1395+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Remacs/elpa/corfu-20240413.927/corfu.elc -> emacs/elpa/corfu-20240523.752/corfu.elc | 0
Demacs/elpa/csv-mode-1.23.signed | 3---
Demacs/elpa/csv-mode-1.23/csv-mode-pkg.el | 2--
Demacs/elpa/csv-mode-1.23/csv-mode-tests.el | 148-------------------------------------------------------------------------------
Demacs/elpa/csv-mode-1.23/csv-mode-tests.elc | 0
Demacs/elpa/csv-mode-1.23/csv-mode.el | 1965-------------------------------------------------------------------------------
Demacs/elpa/csv-mode-1.23/csv-mode.elc | 0
Aemacs/elpa/csv-mode-1.25.signed | 2++
Remacs/elpa/csv-mode-1.23/csv-mode-autoloads.el -> emacs/elpa/csv-mode-1.25/csv-mode-autoloads.el | 0
Aemacs/elpa/csv-mode-1.25/csv-mode-pkg.el | 2++
Aemacs/elpa/csv-mode-1.25/csv-mode-tests.el | 174+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aemacs/elpa/csv-mode-1.25/csv-mode-tests.elc | 0
Aemacs/elpa/csv-mode-1.25/csv-mode.el | 2000+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aemacs/elpa/csv-mode-1.25/csv-mode.elc | 0
Demacs/elpa/ledger-mode-20240423.445/ledger-commodities.el | 170-------------------------------------------------------------------------------
Demacs/elpa/ledger-mode-20240423.445/ledger-commodities.elc | 0
Demacs/elpa/ledger-mode-20240423.445/ledger-mode-pkg.el | 6------
Demacs/elpa/ledger-mode-20240423.445/ledger-post.el | 195-------------------------------------------------------------------------------
Demacs/elpa/ledger-mode-20240423.445/ledger-post.elc | 0
Remacs/elpa/ledger-mode-20240423.445/dir -> emacs/elpa/ledger-mode-20240527.2134/dir | 0
Remacs/elpa/ledger-mode-20240423.445/ledger-check.el -> emacs/elpa/ledger-mode-20240527.2134/ledger-check.el | 0
Remacs/elpa/ledger-mode-20240423.445/ledger-check.elc -> emacs/elpa/ledger-mode-20240527.2134/ledger-check.elc | 0
Aemacs/elpa/ledger-mode-20240527.2134/ledger-commodities.el | 174+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aemacs/elpa/ledger-mode-20240527.2134/ledger-commodities.elc | 0
Remacs/elpa/ledger-mode-20240423.445/ledger-complete.el -> emacs/elpa/ledger-mode-20240527.2134/ledger-complete.el | 0
Remacs/elpa/ledger-mode-20240423.445/ledger-complete.elc -> emacs/elpa/ledger-mode-20240527.2134/ledger-complete.elc | 0
Remacs/elpa/ledger-mode-20240423.445/ledger-context.el -> emacs/elpa/ledger-mode-20240527.2134/ledger-context.el | 0
Remacs/elpa/ledger-mode-20240423.445/ledger-context.elc -> emacs/elpa/ledger-mode-20240527.2134/ledger-context.elc | 0
Remacs/elpa/ledger-mode-20240423.445/ledger-exec.el -> emacs/elpa/ledger-mode-20240527.2134/ledger-exec.el | 0
Remacs/elpa/ledger-mode-20240423.445/ledger-exec.elc -> emacs/elpa/ledger-mode-20240527.2134/ledger-exec.elc | 0
Remacs/elpa/ledger-mode-20240423.445/ledger-flymake.el -> emacs/elpa/ledger-mode-20240527.2134/ledger-flymake.el | 0
Remacs/elpa/ledger-mode-20240423.445/ledger-flymake.elc -> emacs/elpa/ledger-mode-20240527.2134/ledger-flymake.elc | 0
Remacs/elpa/ledger-mode-20240423.445/ledger-fontify.el -> emacs/elpa/ledger-mode-20240527.2134/ledger-fontify.el | 0
Remacs/elpa/ledger-mode-20240423.445/ledger-fontify.elc -> emacs/elpa/ledger-mode-20240527.2134/ledger-fontify.elc | 0
Remacs/elpa/ledger-mode-20240423.445/ledger-fonts.el -> emacs/elpa/ledger-mode-20240527.2134/ledger-fonts.el | 0
Remacs/elpa/ledger-mode-20240423.445/ledger-fonts.elc -> emacs/elpa/ledger-mode-20240527.2134/ledger-fonts.elc | 0
Remacs/elpa/ledger-mode-20240423.445/ledger-init.el -> emacs/elpa/ledger-mode-20240527.2134/ledger-init.el | 0
Remacs/elpa/ledger-mode-20240423.445/ledger-init.elc -> emacs/elpa/ledger-mode-20240527.2134/ledger-init.elc | 0
Remacs/elpa/ledger-mode-20240423.445/ledger-mode-autoloads.el -> emacs/elpa/ledger-mode-20240527.2134/ledger-mode-autoloads.el | 0
Aemacs/elpa/ledger-mode-20240527.2134/ledger-mode-pkg.el | 6++++++
Remacs/elpa/ledger-mode-20240423.445/ledger-mode.el -> emacs/elpa/ledger-mode-20240527.2134/ledger-mode.el | 0
Remacs/elpa/ledger-mode-20240423.445/ledger-mode.elc -> emacs/elpa/ledger-mode-20240527.2134/ledger-mode.elc | 0
Remacs/elpa/ledger-mode-20240423.445/ledger-mode.info -> emacs/elpa/ledger-mode-20240527.2134/ledger-mode.info | 0
Remacs/elpa/ledger-mode-20240423.445/ledger-navigate.el -> emacs/elpa/ledger-mode-20240527.2134/ledger-navigate.el | 0
Remacs/elpa/ledger-mode-20240423.445/ledger-navigate.elc -> emacs/elpa/ledger-mode-20240527.2134/ledger-navigate.elc | 0
Remacs/elpa/ledger-mode-20240423.445/ledger-occur.el -> emacs/elpa/ledger-mode-20240527.2134/ledger-occur.el | 0
Remacs/elpa/ledger-mode-20240423.445/ledger-occur.elc -> emacs/elpa/ledger-mode-20240527.2134/ledger-occur.elc | 0
Aemacs/elpa/ledger-mode-20240527.2134/ledger-post.el | 249+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aemacs/elpa/ledger-mode-20240527.2134/ledger-post.elc | 0
Remacs/elpa/ledger-mode-20240423.445/ledger-reconcile.el -> emacs/elpa/ledger-mode-20240527.2134/ledger-reconcile.el | 0
Remacs/elpa/ledger-mode-20240423.445/ledger-reconcile.elc -> emacs/elpa/ledger-mode-20240527.2134/ledger-reconcile.elc | 0
Remacs/elpa/ledger-mode-20240423.445/ledger-regex.el -> emacs/elpa/ledger-mode-20240527.2134/ledger-regex.el | 0
Remacs/elpa/ledger-mode-20240423.445/ledger-regex.elc -> emacs/elpa/ledger-mode-20240527.2134/ledger-regex.elc | 0
Remacs/elpa/ledger-mode-20240423.445/ledger-report.el -> emacs/elpa/ledger-mode-20240527.2134/ledger-report.el | 0
Remacs/elpa/ledger-mode-20240423.445/ledger-report.elc -> emacs/elpa/ledger-mode-20240527.2134/ledger-report.elc | 0
Remacs/elpa/ledger-mode-20240423.445/ledger-schedule.el -> emacs/elpa/ledger-mode-20240527.2134/ledger-schedule.el | 0
Remacs/elpa/ledger-mode-20240423.445/ledger-schedule.elc -> emacs/elpa/ledger-mode-20240527.2134/ledger-schedule.elc | 0
Remacs/elpa/ledger-mode-20240423.445/ledger-sort.el -> emacs/elpa/ledger-mode-20240527.2134/ledger-sort.el | 0
Remacs/elpa/ledger-mode-20240423.445/ledger-sort.elc -> emacs/elpa/ledger-mode-20240527.2134/ledger-sort.elc | 0
Remacs/elpa/ledger-mode-20240423.445/ledger-state.el -> emacs/elpa/ledger-mode-20240527.2134/ledger-state.el | 0
Remacs/elpa/ledger-mode-20240423.445/ledger-state.elc -> emacs/elpa/ledger-mode-20240527.2134/ledger-state.elc | 0
Remacs/elpa/ledger-mode-20240423.445/ledger-test.el -> emacs/elpa/ledger-mode-20240527.2134/ledger-test.el | 0
Remacs/elpa/ledger-mode-20240423.445/ledger-test.elc -> emacs/elpa/ledger-mode-20240527.2134/ledger-test.elc | 0
Remacs/elpa/ledger-mode-20240423.445/ledger-texi.el -> emacs/elpa/ledger-mode-20240527.2134/ledger-texi.el | 0
Remacs/elpa/ledger-mode-20240423.445/ledger-texi.elc -> emacs/elpa/ledger-mode-20240527.2134/ledger-texi.elc | 0
Remacs/elpa/ledger-mode-20240423.445/ledger-xact.el -> emacs/elpa/ledger-mode-20240527.2134/ledger-xact.el | 0
Remacs/elpa/ledger-mode-20240423.445/ledger-xact.elc -> emacs/elpa/ledger-mode-20240527.2134/ledger-xact.elc | 0
Demacs/elpa/lsp-mode-20240514.1430/lsp-csharp.el | 467-------------------------------------------------------------------------------
Demacs/elpa/lsp-mode-20240514.1430/lsp-csharp.elc | 0
Demacs/elpa/lsp-mode-20240514.1430/lsp-groovy.el | 66------------------------------------------------------------------
Demacs/elpa/lsp-mode-20240514.1430/lsp-groovy.elc | 0
Demacs/elpa/lsp-mode-20240514.1430/lsp-javascript.el | 1037-------------------------------------------------------------------------------
Demacs/elpa/lsp-mode-20240514.1430/lsp-javascript.elc | 0
Demacs/elpa/lsp-mode-20240514.1430/lsp-mode-pkg.el | 21---------------------
Demacs/elpa/lsp-mode-20240514.1430/lsp-mode.el | 9794-------------------------------------------------------------------------------
Demacs/elpa/lsp-mode-20240514.1430/lsp-mode.elc | 0
Demacs/elpa/lsp-mode-20240514.1430/lsp-protocol.el | 797-------------------------------------------------------------------------------
Demacs/elpa/lsp-mode-20240514.1430/lsp-protocol.elc | 0
Demacs/elpa/lsp-mode-20240514.1430/lsp-rust.el | 1770-------------------------------------------------------------------------------
Demacs/elpa/lsp-mode-20240514.1430/lsp-rust.elc | 0
Demacs/elpa/lsp-mode-20240514.1430/lsp-tex.el | 68--------------------------------------------------------------------
Demacs/elpa/lsp-mode-20240514.1430/lsp-tex.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-actionscript.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-actionscript.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-actionscript.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-actionscript.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-ada.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-ada.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-ada.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-ada.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-angular.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-angular.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-angular.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-angular.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-ansible.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-ansible.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-ansible.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-ansible.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-asm.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-asm.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-asm.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-asm.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-astro.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-astro.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-astro.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-astro.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-autotools.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-autotools.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-autotools.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-autotools.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-awk.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-awk.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-awk.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-awk.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-bash.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-bash.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-bash.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-bash.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-beancount.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-beancount.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-beancount.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-beancount.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-bufls.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-bufls.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-bufls.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-bufls.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-camel.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-camel.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-camel.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-camel.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-clangd.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-clangd.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-clangd.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-clangd.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-clojure.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-clojure.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-clojure.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-clojure.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-cmake.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-cmake.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-cmake.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-cmake.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-cobol.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-cobol.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-cobol.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-cobol.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-completion.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-completion.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-completion.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-completion.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-credo.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-credo.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-credo.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-credo.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-crystal.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-crystal.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-crystal.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-crystal.elc | 0
Aemacs/elpa/lsp-mode-20240531.2326/lsp-csharp.el | 539+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aemacs/elpa/lsp-mode-20240531.2326/lsp-csharp.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-css.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-css.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-css.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-css.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-cucumber.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-cucumber.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-cucumber.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-cucumber.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-cypher.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-cypher.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-cypher.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-cypher.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-d.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-d.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-d.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-d.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-dhall.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-dhall.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-dhall.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-dhall.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-diagnostics.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-diagnostics.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-diagnostics.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-diagnostics.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-dired.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-dired.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-dired.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-dired.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-dockerfile.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-dockerfile.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-dockerfile.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-dockerfile.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-dot.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-dot.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-dot.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-dot.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-elixir.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-elixir.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-elixir.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-elixir.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-elm.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-elm.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-elm.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-elm.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-emmet.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-emmet.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-emmet.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-emmet.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-erlang.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-erlang.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-erlang.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-erlang.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-eslint.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-eslint.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-eslint.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-eslint.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-fortran.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-fortran.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-fortran.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-fortran.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-fsharp.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-fsharp.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-fsharp.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-fsharp.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-gdscript.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-gdscript.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-gdscript.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-gdscript.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-gleam.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-gleam.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-gleam.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-gleam.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-glsl.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-glsl.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-glsl.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-glsl.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-go.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-go.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-go.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-go.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-golangci-lint.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-golangci-lint.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-golangci-lint.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-golangci-lint.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-graphql.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-graphql.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-graphql.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-graphql.elc | 0
Aemacs/elpa/lsp-mode-20240531.2326/lsp-groovy.el | 66++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aemacs/elpa/lsp-mode-20240531.2326/lsp-groovy.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-hack.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-hack.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-hack.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-hack.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-haxe.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-haxe.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-haxe.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-haxe.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-headerline.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-headerline.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-headerline.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-headerline.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-html.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-html.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-html.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-html.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-hy.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-hy.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-hy.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-hy.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-icons.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-icons.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-icons.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-icons.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-ido.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-ido.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-ido.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-ido.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-idris.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-idris.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-idris.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-idris.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-iedit.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-iedit.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-iedit.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-iedit.elc | 0
Aemacs/elpa/lsp-mode-20240531.2326/lsp-javascript.el | 1054+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aemacs/elpa/lsp-mode-20240531.2326/lsp-javascript.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-jq.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-jq.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-jq.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-jq.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-json.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-json.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-json.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-json.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-jsonnet.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-jsonnet.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-jsonnet.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-jsonnet.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-kotlin.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-kotlin.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-kotlin.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-kotlin.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-lens.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-lens.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-lens.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-lens.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-lisp.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-lisp.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-lisp.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-lisp.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-lua.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-lua.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-lua.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-lua.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-magik.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-magik.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-magik.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-magik.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-markdown.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-markdown.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-markdown.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-markdown.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-marksman.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-marksman.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-marksman.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-marksman.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-mdx.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-mdx.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-mdx.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-mdx.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-meson.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-meson.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-meson.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-meson.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-mint.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-mint.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-mint.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-mint.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-mode-autoloads.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-mode-autoloads.el | 0
Aemacs/elpa/lsp-mode-20240531.2326/lsp-mode-pkg.el | 21+++++++++++++++++++++
Aemacs/elpa/lsp-mode-20240531.2326/lsp-mode.el | 9797+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aemacs/elpa/lsp-mode-20240531.2326/lsp-mode.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-modeline.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-modeline.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-modeline.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-modeline.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-mojo.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-mojo.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-mojo.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-mojo.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-move.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-move.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-move.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-move.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-nginx.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-nginx.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-nginx.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-nginx.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-nim.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-nim.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-nim.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-nim.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-nix.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-nix.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-nix.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-nix.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-nushell.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-nushell.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-nushell.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-nushell.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-ocaml.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-ocaml.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-ocaml.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-ocaml.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-openscad.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-openscad.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-openscad.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-openscad.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-perl.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-perl.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-perl.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-perl.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-perlnavigator.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-perlnavigator.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-perlnavigator.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-perlnavigator.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-php.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-php.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-php.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-php.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-pls.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-pls.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-pls.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-pls.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-prolog.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-prolog.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-prolog.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-prolog.elc | 0
Aemacs/elpa/lsp-mode-20240531.2326/lsp-protocol.el | 799+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aemacs/elpa/lsp-mode-20240531.2326/lsp-protocol.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-purescript.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-purescript.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-purescript.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-purescript.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-pwsh.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-pwsh.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-pwsh.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-pwsh.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-pyls.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-pyls.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-pyls.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-pyls.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-pylsp.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-pylsp.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-pylsp.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-pylsp.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-qml.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-qml.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-qml.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-qml.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-r.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-r.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-r.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-r.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-racket.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-racket.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-racket.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-racket.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-remark.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-remark.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-remark.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-remark.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-rf.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-rf.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-rf.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-rf.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-rpm-spec.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-rpm-spec.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-rpm-spec.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-rpm-spec.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-rubocop.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-rubocop.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-rubocop.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-rubocop.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-ruby-lsp.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-ruby-lsp.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-ruby-lsp.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-ruby-lsp.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-ruby-syntax-tree.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-ruby-syntax-tree.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-ruby-syntax-tree.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-ruby-syntax-tree.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-ruff-lsp.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-ruff-lsp.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-ruff-lsp.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-ruff-lsp.elc | 0
Aemacs/elpa/lsp-mode-20240531.2326/lsp-rust.el | 1781+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aemacs/elpa/lsp-mode-20240531.2326/lsp-rust.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-semantic-tokens.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-semantic-tokens.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-semantic-tokens.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-semantic-tokens.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-semgrep.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-semgrep.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-semgrep.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-semgrep.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-sml.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-sml.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-sml.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-sml.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-solargraph.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-solargraph.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-solargraph.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-solargraph.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-solidity.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-solidity.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-solidity.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-solidity.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-sorbet.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-sorbet.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-sorbet.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-sorbet.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-sql.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-sql.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-sql.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-sql.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-sqls.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-sqls.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-sqls.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-sqls.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-steep.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-steep.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-steep.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-steep.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-svelte.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-svelte.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-svelte.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-svelte.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-terraform.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-terraform.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-terraform.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-terraform.elc | 0
Aemacs/elpa/lsp-mode-20240531.2326/lsp-tex.el | 68++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aemacs/elpa/lsp-mode-20240531.2326/lsp-tex.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-tilt.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-tilt.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-tilt.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-tilt.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-toml.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-toml.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-toml.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-toml.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-trunk.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-trunk.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-trunk.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-trunk.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-ttcn3.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-ttcn3.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-ttcn3.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-ttcn3.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-typeprof.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-typeprof.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-typeprof.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-typeprof.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-v.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-v.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-v.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-v.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-vala.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-vala.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-vala.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-vala.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-verilog.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-verilog.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-verilog.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-verilog.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-vetur.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-vetur.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-vetur.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-vetur.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-vhdl.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-vhdl.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-vhdl.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-vhdl.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-vimscript.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-vimscript.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-vimscript.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-vimscript.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-volar.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-volar.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-volar.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-volar.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-wgsl.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-wgsl.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-wgsl.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-wgsl.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-xml.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-xml.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-xml.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-xml.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-yaml.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-yaml.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-yaml.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-yaml.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-yang.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-yang.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-yang.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-yang.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-zig.el -> emacs/elpa/lsp-mode-20240531.2326/lsp-zig.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp-zig.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp-zig.elc | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp.el -> emacs/elpa/lsp-mode-20240531.2326/lsp.el | 0
Remacs/elpa/lsp-mode-20240514.1430/lsp.elc -> emacs/elpa/lsp-mode-20240531.2326/lsp.elc | 0
Demacs/elpa/magit-20240514.1843/magit-diff.elc | 0
Demacs/elpa/magit-20240514.1843/magit-pkg.el | 20--------------------
Demacs/elpa/magit-20240514.1843/magit-transient.elc | 0
Demacs/elpa/magit-20240514.1843/magit.info | 11594-------------------------------------------------------------------------------
Remacs/elpa/magit-20240514.1843/AUTHORS.md -> emacs/elpa/magit-20240522.204/AUTHORS.md | 0
Remacs/elpa/magit-20240514.1843/LICENSE -> emacs/elpa/magit-20240522.204/LICENSE | 0
Remacs/elpa/magit-20240514.1843/dir -> emacs/elpa/magit-20240522.204/dir | 0
Remacs/elpa/magit-20240514.1843/git-rebase.el -> emacs/elpa/magit-20240522.204/git-rebase.el | 0
Remacs/elpa/magit-20240514.1843/git-rebase.elc -> emacs/elpa/magit-20240522.204/git-rebase.elc | 0
Remacs/elpa/magit-20240514.1843/magit-apply.el -> emacs/elpa/magit-20240522.204/magit-apply.el | 0
Remacs/elpa/magit-20240514.1843/magit-apply.elc -> emacs/elpa/magit-20240522.204/magit-apply.elc | 0
Remacs/elpa/magit-20240514.1843/magit-autoloads.el -> emacs/elpa/magit-20240522.204/magit-autoloads.el | 0
Remacs/elpa/magit-20240514.1843/magit-autorevert.el -> emacs/elpa/magit-20240522.204/magit-autorevert.el | 0
Remacs/elpa/magit-20240514.1843/magit-autorevert.elc -> emacs/elpa/magit-20240522.204/magit-autorevert.elc | 0
Remacs/elpa/magit-20240514.1843/magit-base.el -> emacs/elpa/magit-20240522.204/magit-base.el | 0
Remacs/elpa/magit-20240514.1843/magit-base.elc -> emacs/elpa/magit-20240522.204/magit-base.elc | 0
Remacs/elpa/magit-20240514.1843/magit-bisect.el -> emacs/elpa/magit-20240522.204/magit-bisect.el | 0
Remacs/elpa/magit-20240514.1843/magit-bisect.elc -> emacs/elpa/magit-20240522.204/magit-bisect.elc | 0
Remacs/elpa/magit-20240514.1843/magit-blame.el -> emacs/elpa/magit-20240522.204/magit-blame.el | 0
Remacs/elpa/magit-20240514.1843/magit-blame.elc -> emacs/elpa/magit-20240522.204/magit-blame.elc | 0
Remacs/elpa/magit-20240514.1843/magit-bookmark.el -> emacs/elpa/magit-20240522.204/magit-bookmark.el | 0
Remacs/elpa/magit-20240514.1843/magit-bookmark.elc -> emacs/elpa/magit-20240522.204/magit-bookmark.elc | 0
Remacs/elpa/magit-20240514.1843/magit-branch.el -> emacs/elpa/magit-20240522.204/magit-branch.el | 0
Remacs/elpa/magit-20240514.1843/magit-branch.elc -> emacs/elpa/magit-20240522.204/magit-branch.elc | 0
Remacs/elpa/magit-20240514.1843/magit-bundle.el -> emacs/elpa/magit-20240522.204/magit-bundle.el | 0
Remacs/elpa/magit-20240514.1843/magit-bundle.elc -> emacs/elpa/magit-20240522.204/magit-bundle.elc | 0
Remacs/elpa/magit-20240514.1843/magit-clone.el -> emacs/elpa/magit-20240522.204/magit-clone.el | 0
Remacs/elpa/magit-20240514.1843/magit-clone.elc -> emacs/elpa/magit-20240522.204/magit-clone.elc | 0
Remacs/elpa/magit-20240514.1843/magit-commit.el -> emacs/elpa/magit-20240522.204/magit-commit.el | 0
Remacs/elpa/magit-20240514.1843/magit-commit.elc -> emacs/elpa/magit-20240522.204/magit-commit.elc | 0
Remacs/elpa/magit-20240514.1843/magit-core.el -> emacs/elpa/magit-20240522.204/magit-core.el | 0
Remacs/elpa/magit-20240514.1843/magit-core.elc -> emacs/elpa/magit-20240522.204/magit-core.elc | 0
Remacs/elpa/magit-20240514.1843/magit-diff.el -> emacs/elpa/magit-20240522.204/magit-diff.el | 0
Aemacs/elpa/magit-20240522.204/magit-diff.elc | 0
Remacs/elpa/magit-20240514.1843/magit-ediff.el -> emacs/elpa/magit-20240522.204/magit-ediff.el | 0
Remacs/elpa/magit-20240514.1843/magit-ediff.elc -> emacs/elpa/magit-20240522.204/magit-ediff.elc | 0
Remacs/elpa/magit-20240514.1843/magit-extras.el -> emacs/elpa/magit-20240522.204/magit-extras.el | 0
Remacs/elpa/magit-20240514.1843/magit-extras.elc -> emacs/elpa/magit-20240522.204/magit-extras.elc | 0
Remacs/elpa/magit-20240514.1843/magit-fetch.el -> emacs/elpa/magit-20240522.204/magit-fetch.el | 0
Remacs/elpa/magit-20240514.1843/magit-fetch.elc -> emacs/elpa/magit-20240522.204/magit-fetch.elc | 0
Remacs/elpa/magit-20240514.1843/magit-files.el -> emacs/elpa/magit-20240522.204/magit-files.el | 0
Remacs/elpa/magit-20240514.1843/magit-files.elc -> emacs/elpa/magit-20240522.204/magit-files.elc | 0
Remacs/elpa/magit-20240514.1843/magit-git.el -> emacs/elpa/magit-20240522.204/magit-git.el | 0
Remacs/elpa/magit-20240514.1843/magit-git.elc -> emacs/elpa/magit-20240522.204/magit-git.elc | 0
Remacs/elpa/magit-20240514.1843/magit-gitignore.el -> emacs/elpa/magit-20240522.204/magit-gitignore.el | 0
Remacs/elpa/magit-20240514.1843/magit-gitignore.elc -> emacs/elpa/magit-20240522.204/magit-gitignore.elc | 0
Remacs/elpa/magit-20240514.1843/magit-log.el -> emacs/elpa/magit-20240522.204/magit-log.el | 0
Remacs/elpa/magit-20240514.1843/magit-log.elc -> emacs/elpa/magit-20240522.204/magit-log.elc | 0
Remacs/elpa/magit-20240514.1843/magit-margin.el -> emacs/elpa/magit-20240522.204/magit-margin.el | 0
Remacs/elpa/magit-20240514.1843/magit-margin.elc -> emacs/elpa/magit-20240522.204/magit-margin.elc | 0
Remacs/elpa/magit-20240514.1843/magit-merge.el -> emacs/elpa/magit-20240522.204/magit-merge.el | 0
Remacs/elpa/magit-20240514.1843/magit-merge.elc -> emacs/elpa/magit-20240522.204/magit-merge.elc | 0
Remacs/elpa/magit-20240514.1843/magit-mode.el -> emacs/elpa/magit-20240522.204/magit-mode.el | 0
Remacs/elpa/magit-20240514.1843/magit-mode.elc -> emacs/elpa/magit-20240522.204/magit-mode.elc | 0
Remacs/elpa/magit-20240514.1843/magit-notes.el -> emacs/elpa/magit-20240522.204/magit-notes.el | 0
Remacs/elpa/magit-20240514.1843/magit-notes.elc -> emacs/elpa/magit-20240522.204/magit-notes.elc | 0
Remacs/elpa/magit-20240514.1843/magit-patch.el -> emacs/elpa/magit-20240522.204/magit-patch.el | 0
Remacs/elpa/magit-20240514.1843/magit-patch.elc -> emacs/elpa/magit-20240522.204/magit-patch.elc | 0
Aemacs/elpa/magit-20240522.204/magit-pkg.el | 20++++++++++++++++++++
Remacs/elpa/magit-20240514.1843/magit-process.el -> emacs/elpa/magit-20240522.204/magit-process.el | 0
Remacs/elpa/magit-20240514.1843/magit-process.elc -> emacs/elpa/magit-20240522.204/magit-process.elc | 0
Remacs/elpa/magit-20240514.1843/magit-pull.el -> emacs/elpa/magit-20240522.204/magit-pull.el | 0
Remacs/elpa/magit-20240514.1843/magit-pull.elc -> emacs/elpa/magit-20240522.204/magit-pull.elc | 0
Remacs/elpa/magit-20240514.1843/magit-push.el -> emacs/elpa/magit-20240522.204/magit-push.el | 0
Remacs/elpa/magit-20240514.1843/magit-push.elc -> emacs/elpa/magit-20240522.204/magit-push.elc | 0
Remacs/elpa/magit-20240514.1843/magit-reflog.el -> emacs/elpa/magit-20240522.204/magit-reflog.el | 0
Remacs/elpa/magit-20240514.1843/magit-reflog.elc -> emacs/elpa/magit-20240522.204/magit-reflog.elc | 0
Remacs/elpa/magit-20240514.1843/magit-refs.el -> emacs/elpa/magit-20240522.204/magit-refs.el | 0
Remacs/elpa/magit-20240514.1843/magit-refs.elc -> emacs/elpa/magit-20240522.204/magit-refs.elc | 0
Remacs/elpa/magit-20240514.1843/magit-remote.el -> emacs/elpa/magit-20240522.204/magit-remote.el | 0
Remacs/elpa/magit-20240514.1843/magit-remote.elc -> emacs/elpa/magit-20240522.204/magit-remote.elc | 0
Remacs/elpa/magit-20240514.1843/magit-repos.el -> emacs/elpa/magit-20240522.204/magit-repos.el | 0
Remacs/elpa/magit-20240514.1843/magit-repos.elc -> emacs/elpa/magit-20240522.204/magit-repos.elc | 0
Remacs/elpa/magit-20240514.1843/magit-reset.el -> emacs/elpa/magit-20240522.204/magit-reset.el | 0
Remacs/elpa/magit-20240514.1843/magit-reset.elc -> emacs/elpa/magit-20240522.204/magit-reset.elc | 0
Remacs/elpa/magit-20240514.1843/magit-sequence.el -> emacs/elpa/magit-20240522.204/magit-sequence.el | 0
Remacs/elpa/magit-20240514.1843/magit-sequence.elc -> emacs/elpa/magit-20240522.204/magit-sequence.elc | 0
Remacs/elpa/magit-20240514.1843/magit-sparse-checkout.el -> emacs/elpa/magit-20240522.204/magit-sparse-checkout.el | 0
Remacs/elpa/magit-20240514.1843/magit-sparse-checkout.elc -> emacs/elpa/magit-20240522.204/magit-sparse-checkout.elc | 0
Remacs/elpa/magit-20240514.1843/magit-stash.el -> emacs/elpa/magit-20240522.204/magit-stash.el | 0
Remacs/elpa/magit-20240514.1843/magit-stash.elc -> emacs/elpa/magit-20240522.204/magit-stash.elc | 0
Remacs/elpa/magit-20240514.1843/magit-status.el -> emacs/elpa/magit-20240522.204/magit-status.el | 0
Remacs/elpa/magit-20240514.1843/magit-status.elc -> emacs/elpa/magit-20240522.204/magit-status.elc | 0
Remacs/elpa/magit-20240514.1843/magit-submodule.el -> emacs/elpa/magit-20240522.204/magit-submodule.el | 0
Remacs/elpa/magit-20240514.1843/magit-submodule.elc -> emacs/elpa/magit-20240522.204/magit-submodule.elc | 0
Remacs/elpa/magit-20240514.1843/magit-subtree.el -> emacs/elpa/magit-20240522.204/magit-subtree.el | 0
Remacs/elpa/magit-20240514.1843/magit-subtree.elc -> emacs/elpa/magit-20240522.204/magit-subtree.elc | 0
Remacs/elpa/magit-20240514.1843/magit-tag.el -> emacs/elpa/magit-20240522.204/magit-tag.el | 0
Remacs/elpa/magit-20240514.1843/magit-tag.elc -> emacs/elpa/magit-20240522.204/magit-tag.elc | 0
Remacs/elpa/magit-20240514.1843/magit-transient.el -> emacs/elpa/magit-20240522.204/magit-transient.el | 0
Aemacs/elpa/magit-20240522.204/magit-transient.elc | 0
Remacs/elpa/magit-20240514.1843/magit-wip.el -> emacs/elpa/magit-20240522.204/magit-wip.el | 0
Remacs/elpa/magit-20240514.1843/magit-wip.elc -> emacs/elpa/magit-20240522.204/magit-wip.elc | 0
Remacs/elpa/magit-20240514.1843/magit-worktree.el -> emacs/elpa/magit-20240522.204/magit-worktree.el | 0
Remacs/elpa/magit-20240514.1843/magit-worktree.elc -> emacs/elpa/magit-20240522.204/magit-worktree.elc | 0
Remacs/elpa/magit-20240514.1843/magit.el -> emacs/elpa/magit-20240522.204/magit.el | 0
Remacs/elpa/magit-20240514.1843/magit.elc -> emacs/elpa/magit-20240522.204/magit.elc | 0
Aemacs/elpa/magit-20240522.204/magit.info | 11595+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Demacs/elpa/marginalia-20240404.451/marginalia-pkg.el | 15---------------
Demacs/elpa/marginalia-20240404.451/marginalia.el | 1361-------------------------------------------------------------------------------
Demacs/elpa/marginalia-20240404.451/marginalia.elc | 0
Remacs/elpa/marginalia-20240404.451/marginalia-autoloads.el -> emacs/elpa/marginalia-20240523.1240/marginalia-autoloads.el | 0
Aemacs/elpa/marginalia-20240523.1240/marginalia-pkg.el | 15+++++++++++++++
Aemacs/elpa/marginalia-20240523.1240/marginalia.el | 1363+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aemacs/elpa/marginalia-20240523.1240/marginalia.elc | 0
Demacs/elpa/nerd-icons-20240520.1050/nerd-icons-pkg.el | 14--------------
Demacs/elpa/nerd-icons-20240520.1050/nerd-icons.el | 1315-------------------------------------------------------------------------------
Demacs/elpa/nerd-icons-20240520.1050/nerd-icons.elc | 0
Remacs/elpa/nerd-icons-20240520.1050/data/nerd-icons-data-codicon.el -> emacs/elpa/nerd-icons-20240524.311/data/nerd-icons-data-codicon.el | 0
Remacs/elpa/nerd-icons-20240520.1050/data/nerd-icons-data-codicon.elc -> emacs/elpa/nerd-icons-20240524.311/data/nerd-icons-data-codicon.elc | 0
Remacs/elpa/nerd-icons-20240520.1050/data/nerd-icons-data-devicon.el -> emacs/elpa/nerd-icons-20240524.311/data/nerd-icons-data-devicon.el | 0
Remacs/elpa/nerd-icons-20240520.1050/data/nerd-icons-data-devicon.elc -> emacs/elpa/nerd-icons-20240524.311/data/nerd-icons-data-devicon.elc | 0
Remacs/elpa/nerd-icons-20240520.1050/data/nerd-icons-data-faicon.el -> emacs/elpa/nerd-icons-20240524.311/data/nerd-icons-data-faicon.el | 0
Remacs/elpa/nerd-icons-20240520.1050/data/nerd-icons-data-faicon.elc -> emacs/elpa/nerd-icons-20240524.311/data/nerd-icons-data-faicon.elc | 0
Remacs/elpa/nerd-icons-20240520.1050/data/nerd-icons-data-flicon.el -> emacs/elpa/nerd-icons-20240524.311/data/nerd-icons-data-flicon.el | 0
Remacs/elpa/nerd-icons-20240520.1050/data/nerd-icons-data-flicon.elc -> emacs/elpa/nerd-icons-20240524.311/data/nerd-icons-data-flicon.elc | 0
Remacs/elpa/nerd-icons-20240520.1050/data/nerd-icons-data-ipsicon.el -> emacs/elpa/nerd-icons-20240524.311/data/nerd-icons-data-ipsicon.el | 0
Remacs/elpa/nerd-icons-20240520.1050/data/nerd-icons-data-ipsicon.elc -> emacs/elpa/nerd-icons-20240524.311/data/nerd-icons-data-ipsicon.elc | 0
Remacs/elpa/nerd-icons-20240520.1050/data/nerd-icons-data-mdicon.el -> emacs/elpa/nerd-icons-20240524.311/data/nerd-icons-data-mdicon.el | 0
Remacs/elpa/nerd-icons-20240520.1050/data/nerd-icons-data-mdicon.elc -> emacs/elpa/nerd-icons-20240524.311/data/nerd-icons-data-mdicon.elc | 0
Remacs/elpa/nerd-icons-20240520.1050/data/nerd-icons-data-octicon.el -> emacs/elpa/nerd-icons-20240524.311/data/nerd-icons-data-octicon.el | 0
Remacs/elpa/nerd-icons-20240520.1050/data/nerd-icons-data-octicon.elc -> emacs/elpa/nerd-icons-20240524.311/data/nerd-icons-data-octicon.elc | 0
Remacs/elpa/nerd-icons-20240520.1050/data/nerd-icons-data-pomicon.el -> emacs/elpa/nerd-icons-20240524.311/data/nerd-icons-data-pomicon.el | 0
Remacs/elpa/nerd-icons-20240520.1050/data/nerd-icons-data-pomicon.elc -> emacs/elpa/nerd-icons-20240524.311/data/nerd-icons-data-pomicon.elc | 0
Remacs/elpa/nerd-icons-20240520.1050/data/nerd-icons-data-powerline.el -> emacs/elpa/nerd-icons-20240524.311/data/nerd-icons-data-powerline.el | 0
Remacs/elpa/nerd-icons-20240520.1050/data/nerd-icons-data-powerline.elc -> emacs/elpa/nerd-icons-20240524.311/data/nerd-icons-data-powerline.elc | 0
Remacs/elpa/nerd-icons-20240520.1050/data/nerd-icons-data-sucicon.el -> emacs/elpa/nerd-icons-20240524.311/data/nerd-icons-data-sucicon.el | 0
Remacs/elpa/nerd-icons-20240520.1050/data/nerd-icons-data-sucicon.elc -> emacs/elpa/nerd-icons-20240524.311/data/nerd-icons-data-sucicon.elc | 0
Remacs/elpa/nerd-icons-20240520.1050/data/nerd-icons-data-wicon.el -> emacs/elpa/nerd-icons-20240524.311/data/nerd-icons-data-wicon.el | 0
Remacs/elpa/nerd-icons-20240520.1050/data/nerd-icons-data-wicon.elc -> emacs/elpa/nerd-icons-20240524.311/data/nerd-icons-data-wicon.elc | 0
Remacs/elpa/nerd-icons-20240520.1050/nerd-icons-autoloads.el -> emacs/elpa/nerd-icons-20240524.311/nerd-icons-autoloads.el | 0
Remacs/elpa/nerd-icons-20240520.1050/nerd-icons-data.el -> emacs/elpa/nerd-icons-20240524.311/nerd-icons-data.el | 0
Remacs/elpa/nerd-icons-20240520.1050/nerd-icons-data.elc -> emacs/elpa/nerd-icons-20240524.311/nerd-icons-data.elc | 0
Remacs/elpa/nerd-icons-20240520.1050/nerd-icons-faces.el -> emacs/elpa/nerd-icons-20240524.311/nerd-icons-faces.el | 0
Remacs/elpa/nerd-icons-20240520.1050/nerd-icons-faces.elc -> emacs/elpa/nerd-icons-20240524.311/nerd-icons-faces.elc | 0
Aemacs/elpa/nerd-icons-20240524.311/nerd-icons-pkg.el | 14++++++++++++++
Aemacs/elpa/nerd-icons-20240524.311/nerd-icons.el | 1316+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aemacs/elpa/nerd-icons-20240524.311/nerd-icons.elc | 0
Demacs/elpa/notmuch-20240406.1803/notmuch-hello.el | 1025-------------------------------------------------------------------------------
Demacs/elpa/notmuch-20240406.1803/notmuch-hello.elc | 0
Demacs/elpa/notmuch-20240406.1803/notmuch-pkg.el | 4----
Remacs/elpa/notmuch-20240406.1803/coolj.el -> emacs/elpa/notmuch-20240529.1054/coolj.el | 0
Remacs/elpa/notmuch-20240406.1803/coolj.elc -> emacs/elpa/notmuch-20240529.1054/coolj.elc | 0
Remacs/elpa/notmuch-20240406.1803/make-deps.el -> emacs/elpa/notmuch-20240529.1054/make-deps.el | 0
Remacs/elpa/notmuch-20240406.1803/make-deps.elc -> emacs/elpa/notmuch-20240529.1054/make-deps.elc | 0
Remacs/elpa/notmuch-20240406.1803/notmuch-address.el -> emacs/elpa/notmuch-20240529.1054/notmuch-address.el | 0
Remacs/elpa/notmuch-20240406.1803/notmuch-address.elc -> emacs/elpa/notmuch-20240529.1054/notmuch-address.elc | 0
Remacs/elpa/notmuch-20240406.1803/notmuch-autoloads.el -> emacs/elpa/notmuch-20240529.1054/notmuch-autoloads.el | 0
Remacs/elpa/notmuch-20240406.1803/notmuch-company.el -> emacs/elpa/notmuch-20240529.1054/notmuch-company.el | 0
Remacs/elpa/notmuch-20240406.1803/notmuch-company.elc -> emacs/elpa/notmuch-20240529.1054/notmuch-company.elc | 0
Remacs/elpa/notmuch-20240406.1803/notmuch-compat.el -> emacs/elpa/notmuch-20240529.1054/notmuch-compat.el | 0
Remacs/elpa/notmuch-20240406.1803/notmuch-compat.elc -> emacs/elpa/notmuch-20240529.1054/notmuch-compat.elc | 0
Remacs/elpa/notmuch-20240406.1803/notmuch-crypto.el -> emacs/elpa/notmuch-20240529.1054/notmuch-crypto.el | 0
Remacs/elpa/notmuch-20240406.1803/notmuch-crypto.elc -> emacs/elpa/notmuch-20240529.1054/notmuch-crypto.elc | 0
Remacs/elpa/notmuch-20240406.1803/notmuch-draft.el -> emacs/elpa/notmuch-20240529.1054/notmuch-draft.el | 0
Remacs/elpa/notmuch-20240406.1803/notmuch-draft.elc -> emacs/elpa/notmuch-20240529.1054/notmuch-draft.elc | 0
Aemacs/elpa/notmuch-20240529.1054/notmuch-hello.el | 1031+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aemacs/elpa/notmuch-20240529.1054/notmuch-hello.elc | 0
Remacs/elpa/notmuch-20240406.1803/notmuch-jump.el -> emacs/elpa/notmuch-20240529.1054/notmuch-jump.el | 0
Remacs/elpa/notmuch-20240406.1803/notmuch-jump.elc -> emacs/elpa/notmuch-20240529.1054/notmuch-jump.elc | 0
Remacs/elpa/notmuch-20240406.1803/notmuch-lib.el -> emacs/elpa/notmuch-20240529.1054/notmuch-lib.el | 0
Remacs/elpa/notmuch-20240406.1803/notmuch-lib.elc -> emacs/elpa/notmuch-20240529.1054/notmuch-lib.elc | 0
Remacs/elpa/notmuch-20240406.1803/notmuch-logo.svg -> emacs/elpa/notmuch-20240529.1054/notmuch-logo.svg | 0
Remacs/elpa/notmuch-20240406.1803/notmuch-maildir-fcc.el -> emacs/elpa/notmuch-20240529.1054/notmuch-maildir-fcc.el | 0
Remacs/elpa/notmuch-20240406.1803/notmuch-maildir-fcc.elc -> emacs/elpa/notmuch-20240529.1054/notmuch-maildir-fcc.elc | 0
Remacs/elpa/notmuch-20240406.1803/notmuch-message.el -> emacs/elpa/notmuch-20240529.1054/notmuch-message.el | 0
Remacs/elpa/notmuch-20240406.1803/notmuch-message.elc -> emacs/elpa/notmuch-20240529.1054/notmuch-message.elc | 0
Remacs/elpa/notmuch-20240406.1803/notmuch-mua.el -> emacs/elpa/notmuch-20240529.1054/notmuch-mua.el | 0
Remacs/elpa/notmuch-20240406.1803/notmuch-mua.elc -> emacs/elpa/notmuch-20240529.1054/notmuch-mua.elc | 0
Remacs/elpa/notmuch-20240406.1803/notmuch-parser.el -> emacs/elpa/notmuch-20240529.1054/notmuch-parser.el | 0
Remacs/elpa/notmuch-20240406.1803/notmuch-parser.elc -> emacs/elpa/notmuch-20240529.1054/notmuch-parser.elc | 0
Aemacs/elpa/notmuch-20240529.1054/notmuch-pkg.el | 4++++
Remacs/elpa/notmuch-20240406.1803/notmuch-print.el -> emacs/elpa/notmuch-20240529.1054/notmuch-print.el | 0
Remacs/elpa/notmuch-20240406.1803/notmuch-print.elc -> emacs/elpa/notmuch-20240529.1054/notmuch-print.elc | 0
Remacs/elpa/notmuch-20240406.1803/notmuch-query.el -> emacs/elpa/notmuch-20240529.1054/notmuch-query.el | 0
Remacs/elpa/notmuch-20240406.1803/notmuch-query.elc -> emacs/elpa/notmuch-20240529.1054/notmuch-query.elc | 0
Remacs/elpa/notmuch-20240406.1803/notmuch-show.el -> emacs/elpa/notmuch-20240529.1054/notmuch-show.el | 0
Remacs/elpa/notmuch-20240406.1803/notmuch-show.elc -> emacs/elpa/notmuch-20240529.1054/notmuch-show.elc | 0
Remacs/elpa/notmuch-20240406.1803/notmuch-tag.el -> emacs/elpa/notmuch-20240529.1054/notmuch-tag.el | 0
Remacs/elpa/notmuch-20240406.1803/notmuch-tag.elc -> emacs/elpa/notmuch-20240529.1054/notmuch-tag.elc | 0
Remacs/elpa/notmuch-20240406.1803/notmuch-tree.el -> emacs/elpa/notmuch-20240529.1054/notmuch-tree.el | 0
Remacs/elpa/notmuch-20240406.1803/notmuch-tree.elc -> emacs/elpa/notmuch-20240529.1054/notmuch-tree.elc | 0
Remacs/elpa/notmuch-20240406.1803/notmuch-wash.el -> emacs/elpa/notmuch-20240529.1054/notmuch-wash.el | 0
Remacs/elpa/notmuch-20240406.1803/notmuch-wash.elc -> emacs/elpa/notmuch-20240529.1054/notmuch-wash.elc | 0
Remacs/elpa/notmuch-20240406.1803/notmuch.el -> emacs/elpa/notmuch-20240529.1054/notmuch.el | 0
Remacs/elpa/notmuch-20240406.1803/notmuch.elc -> emacs/elpa/notmuch-20240529.1054/notmuch.elc | 0
Remacs/elpa/notmuch-20240406.1803/rstdoc.el -> emacs/elpa/notmuch-20240529.1054/rstdoc.el | 0
Remacs/elpa/notmuch-20240406.1803/rstdoc.elc -> emacs/elpa/notmuch-20240529.1054/rstdoc.elc | 0
Aemacs/elpa/sort-words-20160929.1335/sort-words-autoloads.el | 34++++++++++++++++++++++++++++++++++
Aemacs/elpa/sort-words-20160929.1335/sort-words-pkg.el | 12++++++++++++
Aemacs/elpa/sort-words-20160929.1335/sort-words.el | 71+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aemacs/elpa/sort-words-20160929.1335/sort-words.elc | 0
Demacs/elpa/transient-20240509.1849/transient-pkg.el | 16----------------
Demacs/elpa/transient-20240509.1849/transient.el | 4503-------------------------------------------------------------------------------
Demacs/elpa/transient-20240509.1849/transient.elc | 0
Remacs/elpa/transient-20240509.1849/dir -> emacs/elpa/transient-20240525.1118/dir | 0
Remacs/elpa/transient-20240509.1849/gpl.info -> emacs/elpa/transient-20240525.1118/gpl.info | 0
Remacs/elpa/transient-20240509.1849/transient-autoloads.el -> emacs/elpa/transient-20240525.1118/transient-autoloads.el | 0
Aemacs/elpa/transient-20240525.1118/transient-pkg.el | 16++++++++++++++++
Aemacs/elpa/transient-20240525.1118/transient.el | 4508+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aemacs/elpa/transient-20240525.1118/transient.elc | 0
Remacs/elpa/transient-20240509.1849/transient.info -> emacs/elpa/transient-20240525.1118/transient.info | 0
591 files changed, 44737 insertions(+), 44362 deletions(-)

diff --git a/emacs/elpa/archives/gnu/archive-contents b/emacs/elpa/archives/gnu/archive-contents @@ -297,7 +297,7 @@ ("Artur Malabarba" . "emacs@endlessparentheses.com")) (:commit . "0cf8b60f62876f3e75653a5fb30d5d5cdd74c586"))]) (beframe . - [(1 1 0) + [(1 1 1) ((emacs (28 1))) "Isolate buffers per frame" tar @@ -305,7 +305,7 @@ (:maintainer "Protesilaos Stavrou" . "info@protesilaos.com") (:authors ("Protesilaos Stavrou" . "info@protesilaos.com")) - (:commit . "f5ff228db2f1afaf5ee19ab9c933ba1b3774396c"))]) + (:commit . "c3f4583b0767e7f8c38c83ed29af40af8ba3bdfa"))]) (bicep-ts-mode . [(0 1 3) nil "tree-sitter support for Bicep" tar @@ -682,7 +682,7 @@ ("Daniel Mendler" . "mail@daniel-mendler.de")) (:commit . "8d4e8a366681def88751f5e9975738ecd3180deb"))]) (consult . - [(1 6) + [(1 7) ((emacs (27 1)) (compat @@ -691,7 +691,7 @@ ((:url . "https://github.com/minad/consult") (:keywords "matching" "files" "completion") (:maintainer "Daniel Mendler" . "mail@daniel-mendler.de") - (:commit . "6eba1a3fa8e13681091a30b2490a03bdce5f243a"))]) + (:commit . "fe4852280006e61be7f1374d021ee06155ce5a26"))]) (consult-denote . [(0 0 0) ((emacs @@ -744,7 +744,7 @@ ("Jackson Ray Hamilton" . "jackson@jacksonrayhamilton.com")) (:commit . "1b30a28857727202d1f6a027f83ad66151fb1e92"))]) (corfu . - [(1 3) + [(1 4) ((emacs (27 1)) (compat @@ -755,7 +755,7 @@ (:maintainer "Daniel Mendler" . "mail@daniel-mendler.de") (:authors ("Daniel Mendler" . "mail@daniel-mendler.de")) - (:commit . "6088f0550dc8f10f5bcf6f24d35ce24159b01b43"))]) + (:commit . "cdc3e13ad312f5f12b3f78f842fff0b398eb4473"))]) (coterm . [(1 6) ((emacs @@ -834,7 +834,7 @@ ("Theodor Thornhill" . "theo@thornhill.no")) (:commit . "02c61c219b2c22491eff9b7315fed661fab423d4"))]) (csv-mode . - [(1 23) + [(1 25) ((emacs (27 1)) (cl-lib @@ -845,7 +845,7 @@ (:authors ("Francis J. Wright" . "F.J.Wright@qmul.ac.uk")) (:url . "https://elpa.gnu.org/packages/csv-mode.html") - (:commit . "63f02980978f19786bda354457ac5259b8f969a2"))]) + (:commit . "6e8b70504236325989b2f6e19b38602a23f57ba3"))]) (cursory . [(1 0 1) ((emacs @@ -867,7 +867,7 @@ (:url . "https://elpa.gnu.org/packages/cycle-quotes.html") (:commit . "836b19b39651419876e65cdb1a91e3eef83cc4e7"))]) (dape . - [(0 11 1) + [(0 12 0) ((emacs (29 1)) (jsonrpc @@ -875,7 +875,7 @@ "Debug Adapter Protocol for Emacs" tar ((:url . "https://github.com/svaante/dape") (:maintainer "Daniel Pettersson" . "daniel@dpettersson.net") - (:commit . "957d460f3560d9bea572b9ab4fa15fdd9ea2acb1"))]) + (:commit . "51fad7df7473778fbc4bac703317de7f7713b307"))]) (darkroom . [(0 3) ((cl-lib @@ -1330,7 +1330,7 @@ (:url . "https://elpa.gnu.org/packages/elisp-benchmarks.html") (:commit . "1a3d97954957a95a179806e0d49ca6d178b097af"))]) (ellama . - [(0 9 4) + [(0 9 5) ((emacs (28 1)) (llm @@ -1343,7 +1343,7 @@ (:maintainer "Sergey Kostyaev" . "sskostyaev@gmail.com") (:authors ("Sergey Kostyaev" . "sskostyaev@gmail.com")) - (:commit . "fddc1022b5e16e356d6f65ddac51bd2ccf25209c"))]) + (:commit . "1e1db6d5f1ced38ad1c76ffca1651787d54998de"))]) (emacs-gc-stats . [(1 4 2) ((emacs @@ -1559,16 +1559,21 @@ (:url . "https://elpa.gnu.org/packages/external-completion.html") (:commit . "4bc9c8972ac0a3dfa237a9c5704de89ef24ad82b"))]) (exwm . - [(0 28) - ((xelb - (0 18))) + [(0 30) + ((emacs + (27 1)) + (xelb + (0 19))) "Emacs X Window Manager" tar - ((:url . "https://github.com/ch11ng/exwm") + ((:url . "https://github.com/emacs-exwm/exwm") (:keywords "unix") - (:maintainer "Adrián Medraño Calvo" . "adrian@medranocalvo.com") + (:maintainer + ("Adrián Medraño Calvo" . "adrian@medranocalvo.com") + ("Steven Allen" . "steven@stebalien.com") + ("Daniel Mendler" . "mail@daniel-mendler.de")) (:authors ("Chris Feng" . "chris.w.feng@gmail.com")) - (:commit . "86f43494ebd056cd732fb1d10d440e0eba547228"))]) + (:commit . "3e6bfe36afc8356bf72d89eff940282db6ea7cba"))]) (f90-interface-browser . [(1 1) nil "Parse and browse f90 interfaces" single @@ -1810,14 +1815,14 @@ (:url . "https://elpa.gnu.org/packages/gnu-elpa.html") (:commit . "cd18964ec3176ab99d626da4ca6ca7d4bf2389db"))]) (gnu-elpa-keyring-update . - [(2022 12) + [(2022 12 1) nil "Update Emacs's GPG keyring for GNU ELPA" tar ((:keywords "maint" "tools") (:maintainer "Stefan Monnier" . "monnier@iro.umontreal.ca") (:authors ("Stefan Monnier" . "monnier@iro.umontreal.ca")) (:url . "https://elpa.gnu.org/packages/gnu-elpa-keyring-update.html") - (:commit . "685192692f809e3d8c336e27170a2b819925202f"))]) + (:commit . "1e8726c459258fba62ee38807abdae4e350e5238"))]) (gnugo . [(3 1 2) ((ascii-art-to-unicode @@ -2016,6 +2021,13 @@ (:keywords "comm" "convenience" "files" "frames" "hypermedia" "languages" "mail" "matching" "mouse" "multimedia" "outlines" "tools" "wp") (:maintainer "Mats Lidell" . "matsl@gnu.org") (:commit . "23b118ddb6e0595e3b0668dbce8fa4e8bcec5e71"))]) + (idlwave . + [(6 5 1) + nil "IDL editing mode for GNU Emacs" tar + ((:keywords "languages") + (:maintainer "J.D. Smith" . "jdtsmith@gmail.com") + (:url . "https://elpa.gnu.org/packages/idlwave.html") + (:commit . "e1fcd7244cb32df1e90b09729e53474e50a2e808"))]) (ilist . [(0 3) nil "Display a list in an ibuffer way." tar @@ -2401,7 +2413,7 @@ ("Adam Porter" . "adam@alphapapa.net")) (:commit . "61c511541af474027c012de7063ddfdb3f8cc780"))]) (llm . - [(0 15 0) + [(0 16 0) ((emacs (28 1)) (plz @@ -2411,7 +2423,7 @@ (:maintainer "Andrew Hyatt" . "ahyatt@gmail.com") (:authors ("Andrew Hyatt" . "ahyatt@gmail.com")) - (:commit . "ebb7b6e4cddfd33429440bdc7387a11aac20a153"))]) + (:commit . "c7e208a83522f92588b72d574dcd5aa1331c607a"))]) (lmc . [(1 4) nil "Little Man Computer in Elisp" tar @@ -2638,7 +2650,7 @@ ("Protesilaos Stavrou" . "info@protesilaos.com")) (:commit . "a082d7739f627523c6d9098c869cf143fa60b014"))]) (mpdired . - [(1) + [(2) ((emacs (29))) "A dired-like client for Music Player Daemon" tar @@ -2647,7 +2659,7 @@ (:authors ("Manuel Giraud" . "manuel@ledu-giraud.fr")) (:url . "https://elpa.gnu.org/packages/mpdired.html") - (:commit . "c2fb656038e779c010353ecce1623c4b935dbf69"))]) + (:commit . "ff0fbe100360fbcc25d1e6f3b9120770d759fcfa"))]) (multi-mode . [(1 14) nil "support for multiple major modes" tar @@ -2903,16 +2915,16 @@ ("Omar Antolín Camarena" . "omar@matem.unam.mx")) (:commit . "3847f311077efa17951a786d2759f2639c5f43c8"))]) (org . - [(9 6 30) + [(9 7 1) ((emacs (26 1))) "Outline-based notes management and organizer" tar ((:url . "https://orgmode.org") - (:keywords "outlines" "hypermedia" "calendar" "wp") + (:keywords "outlines" "hypermedia" "calendar" "text") (:maintainer "Bastien Guerry" . "bzg@gnu.org") (:authors ("Carsten Dominik" . "carsten.dominik@gmail.com")) - (:commit . "071c6e986c424d2e496be7d0815d6e9cd83ae4e6"))]) + (:commit . "f737e7213d65f6913c9ec1c792539d4fb6619c02"))]) (org-contacts . [(1 1) ((emacs @@ -3264,14 +3276,14 @@ ("Tom Gillespie" . "tgbugs@gmail.com")) (:commit . "4dad5fcdbbb362a0dc2dfa7b5a38dd5be1551c68"))]) (project . - [(0 10 0) + [(0 11 0) ((emacs (26 1)) (xref - (1 4 0))) + (1 7 0))) "Operations on the current project" tar ((:url . "https://elpa.gnu.org/packages/project.html") - (:commit . "dd2053e8cd3050791bd236d0c1ff5f370170c903"))]) + (:commit . "56871dbd4c1a1af3f0d1624f4858e9be67a89f7e"))]) (psgml . [(1 3 5) nil "SGML-editing mode with parsing support" tar @@ -3935,7 +3947,7 @@ (:url . "https://elpa.gnu.org/packages/stream.html") (:commit . "5c0ffd088fbc344aedb11cc76bd7c0b28f3bc43b"))]) (substitute . - [(0 3 0) + [(0 3 1) ((emacs (27 1))) "Efficiently replace targets in the buffer or context" tar @@ -3943,7 +3955,7 @@ (:maintainer "Protesilaos Stavrou" . "info@protesilaos.com") (:authors ("Protesilaos Stavrou" . "info@protesilaos.com")) - (:commit . "740e301165c39a0e7d4b86219e08f8647cab3706"))]) + (:commit . "6e7de79f8a3436fce6acfe7d04a0a375ad80dc34"))]) (svg . [(1 1) ((emacs @@ -4770,18 +4782,19 @@ ("Yuan Fu" . "casouri@gmail.com")) (:commit . "ea4fa859c1129243b15f259a10e67ea274c5ef63"))]) (xelb . - [(0 18) + [(0 19) ((emacs - (24 4)) - (cl-generic - (0 2))) + (27 1))) "X protocol Emacs Lisp Binding" tar - ((:url . "https://github.com/ch11ng/xelb") + ((:url . "https://github.com/emacs-exwm/xelb") (:keywords "unix") - (:maintainer "Chris Feng" . "chris.w.feng@gmail.com") + (:maintainer + ("Adrián Medraño Calvo" . "adrian@medranocalvo.com") + ("Steven Allen" . "steven@stebalien.com") + ("Daniel Mendler" . "mail@daniel-mendler.de")) (:authors ("Chris Feng" . "chris.w.feng@gmail.com")) - (:commit . "0f10c956349515b17bf1b5ac1fb7c65a736d401d"))]) + (:commit . "3546afe73ef7c65181624da3a99ee6d7d7278582"))]) (xpm . [(1 0 5) ((cl-lib @@ -4807,12 +4820,12 @@ ("Mattias Engdegård" . "mattiase@acm.org")) (:commit . "b3310b138e7f8a9fe315dd435739f83935c5769d"))]) (xref . - [(1 6 3) + [(1 7 0) ((emacs (26 1))) "Cross-referencing commands" tar ((:url . "https://elpa.gnu.org/packages/xref.html") - (:commit . "4b6f2a7028b91128934a19f83572f24106782225"))]) + (:commit . "cef848fe5f355ca34abc176739d0ace835b12eed"))]) (xref-union . [(0 2 0) ((emacs diff --git a/emacs/elpa/archives/gnu/archive-contents.signed b/emacs/elpa/archives/gnu/archive-contents.signed @@ -1 +1 @@ -Good signature from 645357D2883A0966 GNU ELPA Signing Agent (2023) <elpasign@elpa.gnu.org> (trust undefined) created at 2024-05-21T09:05:03+0000 using EDDSA -\ No newline at end of file +Good signature from 645357D2883A0966 GNU ELPA Signing Agent (2023) <elpasign@elpa.gnu.org> (trust undefined) created at 2024-06-02T09:05:03+0000 using EDDSA +\ No newline at end of file diff --git a/emacs/elpa/archives/melpa/archive-contents b/emacs/elpa/archives/melpa/archive-contents @@ -78,7 +78,7 @@ (ag . [(20201031 2202) ((dash (2 8 0)) (s (1 9 0)) (cl-lib (0 5))) "A front-end for ag ('the silver searcher'), the C ack replacement." tar ((:commit . "ed7e32064f92f1315cecbfc43f120bbc7508672c") (:authors ("Wilfred Hughes" . "me@wilfred.me.uk")) (:maintainers ("Wilfred Hughes" . "me@wilfred.me.uk")) (:maintainer "Wilfred Hughes" . "me@wilfred.me.uk") (:url . "https://github.com/Wilfred/ag.el"))]) (agda-editor-tactics . [(20211024 2357) ((s (1 12 0)) (dash (2 16 0)) (emacs (27 1)) (org (9 1))) "An editor tactic to produce Σ-types from Agda records" tar ((:commit . "06e374516cb2ab17018985f3dc4fccdc4acefd08") (:authors ("Musa Al-hassy" . "alhassy@gmail.com")) (:maintainers ("Musa Al-hassy" . "alhassy@gmail.com")) (:maintainer "Musa Al-hassy" . "alhassy@gmail.com") (:keywords "abbrev" "convenience" "languages" "agda" "tools") (:url . "https://github.com/alhassy/next-700-module-systems"))]) (age . [(20240410 433) ((emacs (28 1))) "The Age Encryption Library" tar ((:commit . "890c467ebc27538507c54a03afd2f7260630d7f5") (:authors ("Daiki Ueno" . "ueno@unixuser.org") ("Bas Alberts" . "bas@anti.computer")) (:maintainers ("Bas Alberts" . "bas@anti.computer")) (:maintainer "Bas Alberts" . "bas@anti.computer") (:keywords "data") (:url . "https://github.com/anticomputer/age.el"))]) - (agenix . [(20231016 614) ((emacs (27 1))) "Decrypt and encrypt agenix secrets" tar ((:commit . "c3afc8d109dc19bfe2f97ce47184ca748dbe4816") (:authors ("Tomasz Maciosowski" . "t4ccer@gmail.com")) (:maintainers ("Tomasz Maciosowski" . "t4ccer@gmail.com")) (:maintainer "Tomasz Maciosowski" . "t4ccer@gmail.com") (:url . "https://github.com/t4ccer/agenix.el"))]) + (agenix . [(20240601 1304) ((emacs (27 1))) "Decrypt and encrypt agenix secrets" tar ((:commit . "b9c7ad33b534d80af207949cc06c0bcd1e60fd63") (:authors ("Tomasz Maciosowski" . "t4ccer@gmail.com")) (:maintainers ("Tomasz Maciosowski" . "t4ccer@gmail.com")) (:maintainer "Tomasz Maciosowski" . "t4ccer@gmail.com") (:url . "https://github.com/t4ccer/agenix.el"))]) (aggressive-fill-paragraph . [(20240213 2320) ((dash (2 10 0))) "A mode to automatically keep paragraphs filled" tar ((:commit . "60e4eb5c57d4408e811d12c6b6491b8c89dfa695") (:authors ("David Shepherd" . "davidshepherd7@gmail.com")) (:maintainers ("David Shepherd" . "davidshepherd7@gmail.com")) (:maintainer "David Shepherd" . "davidshepherd7@gmail.com") (:keywords "fill-paragraph" "automatic" "comments") (:url . "https://github.com/davidshepherd7/aggressive-fill-paragraph-mode"))]) (aggressive-indent . [(20230112 1300) ((emacs (24 3))) "Minor mode to aggressively keep your code always indented" tar ((:commit . "a437a45868f94b77362c6b913c5ee8e67b273c42") (:authors ("Artur Malabarba" . "emacs@endlessparentheses.com")) (:maintainers ("Artur Malabarba" . "emacs@endlessparentheses.com")) (:maintainer "Artur Malabarba" . "emacs@endlessparentheses.com") (:keywords "indent" "lisp" "maint" "tools") (:url . "https://github.com/Malabarba/aggressive-indent-mode"))]) (agtags . [(20221026 904) ((emacs (25))) "A frontend to GNU Global" tar ((:commit . "e8e04ece2f32d65b084974597bfe8077da3ddba0") (:authors ("Vietor Liu" . "vietor.liu@gmail.com")) (:maintainers ("Vietor Liu" . "vietor.liu@gmail.com")) (:maintainer "Vietor Liu" . "vietor.liu@gmail.com") (:keywords "tools" "convenience") (:url . "https://github.com/vietor/agtags"))]) @@ -88,7 +88,7 @@ (ahungry-theme . [(20180131 328) ((emacs (24))) "Ahungry color theme for Emacs. Make sure to (load-theme 'ahungry)." tar ((:commit . "a038d91ec593d1f1b19ca66a0576d59bbc24c523") (:authors ("Matthew Carter" . "m@ahungry.com")) (:maintainers ("Matthew Carter" . "m@ahungry.com")) (:maintainer "Matthew Carter" . "m@ahungry.com") (:keywords "ahungry" "palette" "color" "theme" "emacs" "color-theme" "deftheme") (:url . "https://github.com/ahungry/color-theme-ahungry"))]) (aiken-mode . [(20230920 1210) ((emacs (26 1))) "Major mode for Aiken" tar ((:commit . "1af54e4df02eb52cf62034acbe1c6dd54776d843") (:authors ("Sebastian Nagel" . "sebastian.nagel@ncoding.at")) (:maintainers ("Sebastian Nagel" . "sebastian.nagel@ncoding.at")) (:maintainer "Sebastian Nagel" . "sebastian.nagel@ncoding.at") (:keywords "languages" "aiken") (:url . "https://github.com/aiken-lang/aiken-mode"))]) (aio . [(20200610 1904) ((emacs (26 1))) "async/await for Emacs Lisp" tar ((:commit . "da93523e235529fa97d6f251319d9e1d6fc24a41") (:authors ("Christopher Wellons" . "wellons@nullprogram.com")) (:maintainers ("Christopher Wellons" . "wellons@nullprogram.com")) (:maintainer "Christopher Wellons" . "wellons@nullprogram.com") (:url . "https://github.com/skeeto/emacs-aio"))]) - (airline-themes . [(20211214 1749) ((powerline (2 3))) "vim-airline themes for emacs powerline" tar ((:commit . "6bd102e49a7d87af1a72eb86e953991ff7bc954e") (:authors ("Anthony DiGirolamo" . "anthony.digirolamo@gmail.com")) (:maintainers ("Anthony DiGirolamo" . "anthony.digirolamo@gmail.com")) (:maintainer "Anthony DiGirolamo" . "anthony.digirolamo@gmail.com") (:keywords "evil" "mode-line" "powerline" "airline" "themes") (:url . "http://github.com/AnthonyDiGirolamo/airline-themes"))]) + (airline-themes . [(20240530 1704) ((powerline (2 3))) "vim-airline themes for emacs powerline" tar ((:commit . "baaa4f1f0acd339b1efc1058654ea7d9e6e44ead") (:authors ("Anthony DiGirolamo" . "anthony.digirolamo@gmail.com")) (:maintainers ("Anthony DiGirolamo" . "anthony.digirolamo@gmail.com")) (:maintainer "Anthony DiGirolamo" . "anthony.digirolamo@gmail.com") (:keywords "evil" "mode-line" "powerline" "airline" "themes") (:url . "http://github.com/AnthonyDiGirolamo/airline-themes"))]) (airplay . [(20130212 1226) ((request (20130110 2144)) (simple-httpd (1 4 1)) (deferred (0 3 1))) "Airplay bindings to Emacs" tar ((:commit . "46fad71d293a3e18551cf464fe6c6208a7a32d9d") (:authors ("Wataru MIYAGUNI" . "gonngo@gmail.com")) (:maintainers ("Wataru MIYAGUNI" . "gonngo@gmail.com")) (:maintainer "Wataru MIYAGUNI" . "gonngo@gmail.com") (:keywords "appletv" "airplay") (:url . "https://github.com/gongo/airplay-el"))]) (alan-mode . [(20240309 650) ((flycheck (32)) (emacs (25 1)) (s (1 12))) "Major mode for editing Alan files" tar ((:commit . "df6c82f1a37a4bd6f18cb463c3f7ab7d087b91ab") (:authors ("Paul van Dam" . "pvandam@kjerner.com")) (:maintainers ("Paul van Dam" . "pvandam@kjerner.com")) (:maintainer "Paul van Dam" . "pvandam@kjerner.com") (:keywords "alan" "languages") (:url . "https://github.com/Kjerner/AlanForEmacs"))]) (alarm-clock . [(20240114 344) ((emacs (24 4))) "Alarm Clock" tar ((:commit . "f924d0e75eb7ce29055bdc1a1e644bb1dcabda09") (:authors ("Steve Lemuel" . "wlemuel@hotmail.com")) (:maintainers ("Steve Lemuel" . "wlemuel@hotmail.com")) (:maintainer "Steve Lemuel" . "wlemuel@hotmail.com") (:keywords "calendar" "tools" "convenience") (:url . "https://github.com/wlemuel/alarm-clock"))]) @@ -170,7 +170,7 @@ (archive-region . [(20200316 1425) ((emacs (24 4))) "Move region to archive file instead of killing" tar ((:commit . "53cd2d96ea7c33f320353982b36854f25c900c2e") (:authors ("rubikitch" . "rubikitch@ruby-lang.org")) (:maintainers ("rubikitch" . "rubikitch@ruby-lang.org")) (:maintainer "rubikitch" . "rubikitch@ruby-lang.org") (:keywords "languages") (:url . "http://www.emacswiki.org/cgi-bin/wiki/download/archive-region.el"))]) (archive-rpm . [(20220527 632) ((emacs (24 4))) "RPM and CPIO support for archive-mode" tar ((:commit . "cb48fee04cb0cbb26f760a3b95649f7dac78c6ec") (:authors ("Magnus Henoch" . "magnus.henoch@gmail.com")) (:maintainer "Magnus Henoch" . "magnus.henoch@gmail.com") (:keywords "files"))]) (arduino-cli-mode . [(20210511 653) ((emacs (25 1))) "Arduino-CLI command wrapper" tar ((:commit . "9ff2c47a3b56cbffd41a62376f7c2ff16ccbf4e0") (:authors ("Love Lagerkvist")) (:maintainers ("Love Lagerkvist")) (:maintainer "Love Lagerkvist") (:keywords "processes" "tools") (:url . "https://github.com/motform/arduino-cli-mode"))]) - (arduino-mode . [(20220210 1355) ((emacs (25 1)) (spinner (1 7 3))) "Major mode for editing Arduino code" tar ((:commit . "652c6a328fa8f2db06534d5f231c6b6933be3edc") (:maintainers ("stardiviner" . "numbchild@gmail.com")) (:maintainer "stardiviner" . "numbchild@gmail.com") (:keywords "languages" "arduino") (:url . "https://repo.or.cz/arduino-mode.git"))]) + (arduino-mode . [(20240527 1603) ((emacs (25 1)) (spinner (1 7 3))) "Major mode for editing Arduino code" tar ((:commit . "b2ffd8441851659cb1cc844156073967729585e5") (:maintainers ("stardiviner" . "numbchild@gmail.com")) (:maintainer "stardiviner" . "numbchild@gmail.com") (:keywords "languages" "arduino") (:url . "https://repo.or.cz/arduino-mode.git"))]) (aria2 . [(20230314 2131) ((emacs (25 1))) "Control aria2c commandline tool from Emacs" tar ((:commit . "1f2cbe624f3a4e0109b5dc123bb4bbed496b15a7") (:authors ("Łukasz Gruner" . "lukasz@gruner.lu")) (:maintainers ("Łukasz Gruner" . "lukasz@gruner.lu")) (:maintainer "Łukasz Gruner" . "lukasz@gruner.lu") (:keywords "download" "bittorrent" "aria2") (:url . "https://bitbucket.org/ukaszg/aria2-mode"))]) (ariadne . [(20131117 1711) ((bert (0 1))) "Ariadne plugin for Emacs" tar ((:commit . "6fe401c7f996bcbc2f685e7971324c6f5e5eaf15") (:authors ("Oleksandr Manzyuk" . "manzyuk@gmail.com")) (:maintainers ("Oleksandr Manzyuk" . "manzyuk@gmail.com")) (:maintainer "Oleksandr Manzyuk" . "manzyuk@gmail.com") (:keywords "comm" "convenience" "processes"))]) (arjen-grey-theme . [(20170522 2047) nil "A soothing dark grey theme" tar ((:commit . "4cd0be72b65d42390e2105cfdaa408a1ead8d8d1") (:authors ("Arjen Wiersma" . "arjen@wiersma.org")) (:maintainers ("Arjen Wiersma" . "arjen@wiersma.org")) (:maintainer "Arjen Wiersma" . "arjen@wiersma.org") (:keywords "faces") (:url . "https://github.com/credmp/arjen-grey"))]) @@ -268,7 +268,7 @@ (axe . [(20230120 1915) ((emacs (25 1)) (hmac (0 0)) (request (0 3 2)) (s (1 12 0)) (xmlgen (0 5)) (dash (2 17 0)) (mimetypes (1 0))) "AWS Extensions" tar ((:commit . "5168d4f4c33861a071285df34f17fce92137d497") (:authors ("Craig Niles <niles.c at gmail.com>")) (:maintainers ("Craig Niles <niles.c at gmail.com>")) (:maintainer "Craig Niles <niles.c at gmail.com>") (:url . "https://github.com/cniles/axe"))]) (axiom-environment . [(20220612 1535) ((emacs (24 2))) "An environment for using Axiom/OpenAxiom/FriCAS" tar ((:commit . "01d88daa0c864af9918db5a147fbb5e435dec199") (:authors ("Paul Onions" . "paul.onions@acm.org")) (:maintainers ("Paul Onions" . "paul.onions@acm.org")) (:maintainer "Paul Onions" . "paul.onions@acm.org") (:keywords "axiom" "openaxiom" "fricas"))]) (ayu-theme . [(20230306 1924) ((emacs (24 1))) "Ayu theme" tar ((:commit . "dc325520c1202463a0f05d4ece1644109830fef4") (:authors ("Tran Anh Vu")) (:maintainers ("Tran Anh Vu")) (:maintainer "Tran Anh Vu") (:keywords "lisp" "theme" "emacs") (:url . "https://github.com/vutran1710/Ayu-Theme-Emacs"))]) - (babashka . [(20240417 1347) ((emacs (27 1)) (parseedn (1 1 0))) "Babashka Tasks Interface" tar ((:commit . "117138c0b7361e70282ee53825e2f4de1a782609") (:authors ("Mykhaylo Bilyanskyy" . "mb@m1k.pw")) (:maintainers ("Mykhaylo Bilyanskyy" . "mb@m1k.pw")) (:maintainer "Mykhaylo Bilyanskyy" . "mb@m1k.pw") (:url . "https://github.com/licht1stein/babashka.el"))]) + (babashka . [(20240527 732) ((emacs (27 1)) (parseedn (1 1 0))) "Babashka Tasks Interface" tar ((:commit . "4ea9d7febf3e9d301c91231ba2833f3417ba9059") (:authors ("Mykhaylo Bilyanskyy" . "mb@m1k.pw")) (:maintainers ("Mykhaylo Bilyanskyy" . "mb@m1k.pw")) (:maintainer "Mykhaylo Bilyanskyy" . "mb@m1k.pw") (:url . "https://github.com/licht1stein/babashka.el"))]) (babel . [(20210612 640) nil "interface to web translation services such as Babelfish" tar ((:commit . "946e69c61188bc41793402ac48466d8967ddb43d") (:authors ("Juergen Hoetzel" . "juergen@hoetzel.info") ("Eric Marsden" . "emarsden@laas.fr")) (:maintainers ("Juergen Hoetzel" . "juergen@hoetzel.info")) (:maintainer "Juergen Hoetzel" . "juergen@hoetzel.info") (:keywords "translation" "web") (:url . "http://github.com/juergenhoetzel/babel"))]) (babel-repl . [(20160504 2201) ((emacs (24))) "Run babel REPL" tar ((:commit . "0faa2f6518a2b46236f116ca1736a314f7d9c034") (:authors ("Hung Phan")) (:maintainers ("Hung Phan")) (:maintainer "Hung Phan") (:keywords "babel" "javascript" "es6") (:url . "https://github.com/hung-phan/babel-repl/"))]) (back-button . [(20220827 1733) ((nav-flash (1 0 0)) (smartrep (0 0 3)) (list-utils (0 4 2)) (persistent-soft (0 8 8)) (pcache (0 2 3))) "Visual navigation through mark rings" tar ((:commit . "f8783c98a7fefc1d0419959c1b462c7dcadce5a8") (:authors ("Roland Walker" . "walker@pobox.com")) (:maintainers ("Roland Walker" . "walker@pobox.com")) (:maintainer "Roland Walker" . "walker@pobox.com") (:keywords "convenience" "navigation" "interface") (:url . "http://github.com/rolandwalker/back-button"))]) @@ -345,7 +345,7 @@ (bind-map . [(20240308 2050) ((emacs (24 3))) "Bind personal keymaps in multiple locations" tar ((:commit . "d7b0e42b78f708669ec368ebbd1f503094ceee22") (:authors ("Justin Burkett" . "justin@burkett.cc")) (:maintainers ("Justin Burkett" . "justin@burkett.cc")) (:maintainer "Justin Burkett" . "justin@burkett.cc") (:url . "https://github.com/justbur/emacs-bind-map"))]) (binder . [(20230729 350) ((emacs (24 4)) (seq (2 20))) "Global minor mode to facilitate multi-file writing projects" tar ((:commit . "859d89c00e21c83565ed2b45f8d7527b45b1292c") (:authors ("Paul W. Rankin" . "pwr@bydasein.com")) (:maintainers ("Paul W. Rankin" . "pwr@bydasein.com")) (:maintainer "Paul W. Rankin" . "pwr@bydasein.com") (:keywords "files" "outlines" "wp" "text") (:url . "https://github.com/rnkn/binder"))]) (bing-dict . [(20200216 110) nil "Minimalists' English-Chinese Bing dictionary" tar ((:commit . "1d581aaa9622b34f8fb83af5579fa252aa24cfef") (:authors ("Junpeng Qiu" . "qjpchmail@gmail.com")) (:maintainers ("Junpeng Qiu" . "qjpchmail@gmail.com")) (:maintainer "Junpeng Qiu" . "qjpchmail@gmail.com") (:keywords "extensions") (:url . "https://github.com/cute-jumper/bing-dict.el"))]) - (binky . [(20240519 732) ((emacs (29 1)) (dash (2 19 1))) "Jump between points like a rabbit" tar ((:commit . "f2fe74321f87dfe46421a7a7aaaec30b7f831059") (:authors ("liuyinz" . "liuyinz95@gmail.com")) (:maintainers ("liuyinz" . "liuyinz95@gmail.com")) (:maintainer "liuyinz" . "liuyinz95@gmail.com") (:keywords "convenience") (:url . "https://github.com/liuyinz/binky-mode"))]) + (binky . [(20240525 715) ((emacs (29 1)) (dash (2 19 1))) "Jump between points like a rabbit" tar ((:commit . "39c1a1e78aea36f79104fdc256949901e3d3d2c0") (:authors ("liuyinz" . "liuyinz95@gmail.com")) (:maintainers ("liuyinz" . "liuyinz95@gmail.com")) (:maintainer "liuyinz" . "liuyinz95@gmail.com") (:keywords "convenience") (:url . "https://github.com/liuyinz/binky-mode"))]) (biome . [(20240519 1037) ((emacs (27 1)) (transient (0 3 7)) (ct (0 2)) (request (0 3 3)) (compat (29 1 4 1))) "Bountiful Interface to Open Meteo for Emacs" tar ((:commit . "6c5d786219741e10332304566d4a18db3eddae2b") (:authors ("Korytov Pavel" . "thexcloud@gmail.com")) (:maintainers ("Korytov Pavel" . "thexcloud@gmail.com")) (:maintainer "Korytov Pavel" . "thexcloud@gmail.com") (:url . "https://github.com/SqrtMinusOne/biome"))]) (biomejs-format . [(20240401 458) ((emacs (24 1))) "Minor mode to format JS code with Biome on file save" tar ((:commit . "cbfb8aac8bfab6fd893f1ccb4eb9efa29b1b3214") (:authors ("James Long and contributors")) (:maintainers ("Kanon Kakuno" . "yadex205@yadex205.com")) (:maintainer "Kanon Kakuno" . "yadex205@yadex205.com") (:keywords "convenience" "wp" "edit" "js") (:url . "https://github.com/yadex205/emacs-biomejs-format"))]) (birds-of-paradise-plus-theme . [(20130419 2129) nil "A brown/orange light-on-dark theme for Emacs 24 (deftheme)." tar ((:commit . "bb9f9d4ef7f7872a388ec4eee1253069adcadb6f") (:authors ("Jim Myhrberg" . "contact@jimeh.me")) (:maintainers ("Jim Myhrberg" . "contact@jimeh.me")) (:maintainer "Jim Myhrberg" . "contact@jimeh.me") (:keywords "themes") (:url . "https://github.com/jimeh/birds-of-paradise-plus-theme.el"))]) @@ -358,7 +358,7 @@ (blacken . [(20231129 654) ((emacs (25 2))) "Reformat python buffers using the \"black\" formatter" tar ((:commit . "a43695f9cb412df93ac8d38b55ab1515e86e217e") (:authors ("Artem Malyshev" . "proofit404@gmail.com")) (:maintainers ("Artem Malyshev" . "proofit404@gmail.com")) (:maintainer "Artem Malyshev" . "proofit404@gmail.com") (:keywords "convenience" "blacken") (:url . "https://github.com/proofit404/blacken"))]) (blackjack . [(20230821 41) ((emacs (26 2))) "The game of Blackjack" tar ((:commit . "7f9072630a159b59a146346b5dae24ab8fb5f290") (:authors ("Greg Donald" . "gdonald@gmail.com")) (:maintainers ("Greg Donald" . "gdonald@gmail.com")) (:maintainer "Greg Donald" . "gdonald@gmail.com") (:keywords "card" "game" "games" "blackjack" "21") (:url . "https://github.com/gdonald/blackjack-el"))]) (blackout . [(20220509 2350) ((emacs (26))) "Better mode lighter overriding" tar ((:commit . "7707211370f03f03a2f74df15f42ac24a1e99300") (:authors ("Radian LLC" . "contact+blackout@radian.codes")) (:maintainers ("Radian LLC" . "contact+blackout@radian.codes")) (:maintainer "Radian LLC" . "contact+blackout@radian.codes") (:keywords "extensions") (:url . "https://github.com/radian-software/blackout"))]) - (blamer . [(20240512 1514) ((emacs (27 1)) (posframe (1 1 7)) (async (1 9 8))) "Show git blame info about current line" tar ((:commit . "4cc2e6daaecf84c8dd00792f86724413423293a6") (:authors ("Artur Yaroshenko" . "artawower@protonmail.com")) (:maintainers ("Artur Yaroshenko" . "artawower@protonmail.com")) (:maintainer "Artur Yaroshenko" . "artawower@protonmail.com") (:url . "https://github.com/artawower/blamer.el"))]) + (blamer . [(20240528 654) ((emacs (27 1)) (posframe (1 1 7)) (async (1 9 8))) "Show git blame info about current line" tar ((:commit . "281963da789fe9e47ce9efc4f7a9c4d19bf3a405") (:authors ("Artur Yaroshenko" . "artawower@protonmail.com")) (:maintainers ("Artur Yaroshenko" . "artawower@protonmail.com")) (:maintainer "Artur Yaroshenko" . "artawower@protonmail.com") (:url . "https://github.com/artawower/blamer.el"))]) (blgrep . [(20150401 1416) ((clmemo (20140321 715))) "Block grep" tar ((:commit . "605beda210610a5829750a987f5fcebea97af546") (:authors ("Masayuki Ataka" . "masayuki.ataka@gmail.com")) (:maintainers ("Masayuki Ataka" . "masayuki.ataka@gmail.com")) (:maintainer "Masayuki Ataka" . "masayuki.ataka@gmail.com") (:keywords "tools" "convenience"))]) (blimp . [(20180903 2240) ((emacs (25)) (eimp (1 4 0))) "Bustling Image Manipulation Package" tar ((:commit . "b048b037129b68674b99310bcc08fb96d44fdbb4") (:authors ("Sebastian Wålinder" . "s.walinder@gmail.com")) (:maintainers ("Sebastian Wålinder" . "s.walinder@gmail.com")) (:maintainer "Sebastian Wålinder" . "s.walinder@gmail.com") (:keywords "multimedia" "unix") (:url . "https://github.com/walseb/blimp"))]) (bliss-theme . [(20170808 1307) ((emacs (24 0))) "an Emacs 24 theme based on Bliss (tmTheme)" tar ((:commit . "c3cf6d8a666ab26909b7da158f9e94df71a5fbbf") (:authors ("Jason Milkins")) (:maintainers ("Jason Milkins")) (:maintainer "Jason Milkins") (:url . "https://github.com/emacsfodder/tmtheme-to-deftheme"))]) @@ -489,7 +489,8 @@ (cask-package-toolset . [(20170921 2256) ((emacs (24)) (cl-lib (0 3)) (s (1 6 1)) (dash (1 8 0)) (f (0 10 0)) (commander (0 2 0)) (ansi (0 1 0)) (shut-up (0 1 0))) "Toolsettize your package" tar ((:commit . "2c74cd827e88c7f8360581a841e45f0b794510e7") (:authors ("Adrien Becchis" . "adriean.khisbe@live.fr")) (:maintainers ("Adrien Becchis" . "adriean.khisbe@live.fr")) (:maintainer "Adrien Becchis" . "adriean.khisbe@live.fr") (:keywords "convenience" "tools") (:url . "http://github.com/AdrieanKhisbe/cask-package-toolset.el"))]) (caskxy . [(20140513 1539) ((log4e (0 2 0)) (yaxception (0 1))) "Control Cask in Emacs" tar ((:commit . "279f3ab79bd77fe69cb3148a79896b9bf118a9b3") (:authors ("Hiroaki Otsu" . "ootsuhiroaki@gmail.com")) (:maintainers ("Hiroaki Otsu" . "ootsuhiroaki@gmail.com")) (:maintainer "Hiroaki Otsu" . "ootsuhiroaki@gmail.com") (:keywords "convenience") (:url . "https://github.com/aki2o/caskxy"))]) (casual . [(20240416 2237) ((emacs (29 1))) "Transient UI for Calc" tar ((:commit . "a22cf128c3baa3e11f6aaff7dc44ef91cf0fe9ce") (:authors ("Charles Choi" . "kickingvegas@gmail.com")) (:maintainers ("Charles Choi" . "kickingvegas@gmail.com")) (:maintainer "Charles Choi" . "kickingvegas@gmail.com") (:keywords "tools") (:url . "https://github.com/kickingvegas/casual"))]) - (casual-dired . [(20240517 2348) ((emacs (29 1))) "Casual Dired" tar ((:commit . "d49c5c84d222ff8db2038d1f25b32c607a46c8b6") (:authors ("Charles Choi" . "kickingvegas@gmail.com")) (:maintainers ("Charles Choi" . "kickingvegas@gmail.com")) (:maintainer "Charles Choi" . "kickingvegas@gmail.com") (:keywords "tools") (:url . "https://github.com/kickingvegas/casual-dired"))]) + (casual-avy . [(20240529 1711) ((emacs (29 1)) (avy (0 5 0))) "Transient UI for Avy" tar ((:commit . "ab5d952a40ee868f43c48a6207644b4fd54768c0") (:authors ("Charles Choi" . "kickingvegas@gmail.com")) (:maintainers ("Charles Choi" . "kickingvegas@gmail.com")) (:maintainer "Charles Choi" . "kickingvegas@gmail.com") (:keywords "tools") (:url . "https://github.com/kickingvegas/casual-avy"))]) + (casual-dired . [(20240523 1755) ((emacs (29 1))) "Casual Dired" tar ((:commit . "f1dc88480a3847f1defa2dce7efb6d8234eb5b8b") (:authors ("Charles Choi" . "kickingvegas@gmail.com")) (:maintainers ("Charles Choi" . "kickingvegas@gmail.com")) (:maintainer "Charles Choi" . "kickingvegas@gmail.com") (:keywords "tools") (:url . "https://github.com/kickingvegas/casual-dired"))]) (catmacs . [(20170826 1157) ((emacs (24))) "Simple CAT interface for Yaesu Transceivers." tar ((:commit . "6ea9ee195661fe95355413856476c45dcc8e24e8") (:authors ("Frank Singleton" . "b17flyboy@gmail.com")) (:maintainers ("Frank Singleton" . "b17flyboy@gmail.com")) (:maintainer "Frank Singleton" . "b17flyboy@gmail.com") (:keywords "comm" "hardware") (:url . "https://bitbucket.org/pymaximus/catmacs"))]) (catppuccin-theme . [(20240326 900) ((emacs (25 1))) "Catppuccin for Emacs - 🍄 Soothing pastel theme for Emacs" tar ((:commit . "3d93abaa33e95f19b4a8b0e1e9bef1e3e68dd994") (:authors ("nyxkrage")) (:maintainers ("Carsten Kragelund" . "carsten@kragelund.me")) (:maintainer "Carsten Kragelund" . "carsten@kragelund.me") (:url . "https://github.com/catppuccin/emacs"))]) (cats . [(20230407 1316) ((emacs (26 1))) "Monads for Elisp" tar ((:commit . "7fc70db0eeb2c33ffba5c13c4cdc0f31c7b95537") (:authors ("Matúš Goljer" . "matus.goljer@gmail.com")) (:maintainers ("Matúš Goljer" . "matus.goljer@gmail.com")) (:maintainer "Matúš Goljer" . "matus.goljer@gmail.com") (:url . "https://github.com/Fuco1/emacs-cats"))]) @@ -506,7 +507,7 @@ (cedit . [(20200816 526) nil "paredit-like commands for c-like languages" tar ((:commit . "cb38316903e6cfa8b8c978defa7e1dafcd4e0c12") (:authors ("zk_phi")) (:maintainers ("zk_phi")) (:maintainer "zk_phi") (:url . "http://zk-phi.gitub.io/"))]) (celery . [(20170225 924) ((emacs (24)) (dash-functional (2 11 0)) (s (1 9 0)) (deferred (0 3 2))) "a minor mode to draw stats from celery and more?" tar ((:commit . "b3378dd81e5a717432123fb13d70201da5dc841a") (:authors ("ardumont" . "eniotna.t@gmail.com")) (:maintainers ("ardumont" . "eniotna.t@gmail.com")) (:maintainer "ardumont" . "eniotna.t@gmail.com") (:keywords "celery" "convenience") (:url . "https://github.com/ardumont/emacs-celery"))]) (celestial-mode-line . [(20230323 737) ((emacs (24))) "Show lunar phase and sunrise/-set time in modeline" tar ((:commit . "90056322d6664e2e2b593912e4d5e68f1468cafc") (:authors ("Peter" . "craven@gmx.net")) (:maintainers ("Peter" . "craven@gmx.net")) (:maintainer "Peter" . "craven@gmx.net") (:keywords "extensions") (:url . "https://github.com/ecraven/celestial-mode-line"))]) - (centaur-tabs . [(20240518 630) ((emacs (26 1)) (powerline (2 4)) (cl-lib (0 5))) "Aesthetic, modern looking customizable tabs plugin" tar ((:commit . "c86a0abdf2b3fbdfd0c2725a5807196cc9fa6e8e") (:authors ("Emmanuel Bustos" . "ema2159@gmail.com")) (:maintainers ("Jen-Chieh Shen" . "jcs090218@gmail.com")) (:maintainer "Jen-Chieh Shen" . "jcs090218@gmail.com") (:keywords "frames") (:url . "https://github.com/ema2159/centaur-tabs"))]) + (centaur-tabs . [(20240529 815) ((emacs (26 1)) (powerline (2 4)) (cl-lib (0 5))) "Aesthetic, modern looking customizable tabs plugin" tar ((:commit . "fe1f130260655da5b596ebc40054e93e1a852b21") (:authors ("Emmanuel Bustos" . "ema2159@gmail.com")) (:maintainers ("Jen-Chieh Shen" . "jcs090218@gmail.com")) (:maintainer "Jen-Chieh Shen" . "jcs090218@gmail.com") (:keywords "frames") (:url . "https://github.com/ema2159/centaur-tabs"))]) (centered-cursor-mode . [(20230914 1358) nil "cursor stays vertically centered" tar ((:commit . "67ef719e685407dbc455c7430765e4e685fd95a9") (:authors ("André Riemann" . "andre.riemann@web.de")) (:maintainers ("André Riemann" . "andre.riemann@web.de")) (:maintainer "André Riemann" . "andre.riemann@web.de") (:keywords "convenience") (:url . "https://github.com/andre-r/centered-cursor-mode.el"))]) (centered-window . [(20220125 804) ((emacs (24 4))) "Center the text when there's only one window" tar ((:commit . "80965f6c6afe8d918481433984b493de72af5399") (:authors ("Anler Hernández Peral" . "inbox+emacs@anler.me")) (:maintainers ("Anler Hernández Peral" . "inbox+emacs@anler.me")) (:maintainer "Anler Hernández Peral" . "inbox+emacs@anler.me") (:keywords "faces" "windows") (:url . "https://github.com/anler/centered-window-mode"))]) (centimacro . [(20201225 1132) nil "Assign multiple macros as global key bindings" tar ((:commit . "0149877584b333c4f1953f0767f0cae23881b0df") (:authors ("Oleh Krehel" . "ohwoeowho@gmail.com")) (:maintainers ("Oleh Krehel" . "ohwoeowho@gmail.com")) (:maintainer "Oleh Krehel" . "ohwoeowho@gmail.com") (:keywords "macros") (:url . "https://github.com/abo-abo/centimacro"))]) @@ -517,7 +518,7 @@ (cfengine-code-style . [(20171111 1027) nil "C code style for CFEngine project." tar ((:commit . "92a25872a6d1de00c5bfc2b9455ccb0082bf6569") (:authors ("Mikhail Gusarov" . "mikhail.gusarov@cfengine.com")) (:maintainers ("Mikhail Gusarov" . "mikhail.gusarov@cfengine.com")) (:maintainer "Mikhail Gusarov" . "mikhail.gusarov@cfengine.com") (:url . "https://github.com/cfengine/core"))]) (cff . [(20160118 2018) ((cl-lib (0 5)) (emacs (24))) "Search of the C/C++ file header by the source and vice versa" tar ((:commit . "b6ab2a28e64ef06f281ec74cfe3114e450644dfa") (:authors ("Alexey Veretennikov" . "alexey.veretennikov@gmail.com")) (:maintainers ("Alexey Veretennikov" . "alexey.veretennikov@gmail.com")) (:maintainer "Alexey Veretennikov" . "alexey.veretennikov@gmail.com") (:keywords "find-file") (:url . "https://github.com/fourier/cff"))]) (cfml-mode . [(20190617 1130) ((emacs (25))) "Emacs mode for editing CFML files" tar ((:commit . "b06d7cee2af0ed5d55a94f0db80fc1f429a1829a") (:authors ("Andrew Myers" . "am2605@gmail.com")) (:maintainers ("Andrew Myers" . "am2605@gmail.com")) (:maintainer "Andrew Myers" . "am2605@gmail.com") (:url . "https://github.com/am2605/cfml-mode"))]) - (cfn-mode . [(20240519 805) ((emacs (27 0)) (f (0 20 0)) (s (1 12 0)) (yaml-mode (0 0 13))) "AWS cloudformation mode" tar ((:commit . "6ef789934d6b9b78cdbe5c90703f4afead736ead") (:authors ("William Orr" . "will@worrbase.com")) (:maintainers ("William Orr" . "will@worrbase.com")) (:maintainer "William Orr" . "will@worrbase.com") (:keywords "convenience" "languages" "tools") (:url . "https://gitlab.com/worr/cfn-mode"))]) + (cfn-mode . [(20240602 804) ((emacs (27 0)) (f (0 20 0)) (s (1 12 0)) (yaml-mode (0 0 13))) "AWS cloudformation mode" tar ((:commit . "33d9ea0af50a98a440bfde5258ccf07ca2856dd6") (:authors ("William Orr" . "will@worrbase.com")) (:maintainers ("William Orr" . "will@worrbase.com")) (:maintainer "William Orr" . "will@worrbase.com") (:keywords "convenience" "languages" "tools") (:url . "https://gitlab.com/worr/cfn-mode"))]) (cframe . [(20240223 2335) ((emacs (26)) (buffer-manage (0 11)) (dash (2 17 0))) "Customize a frame and fast switch size and positions" tar ((:commit . "580a20573ef413c269c032221de04abc1c97a6a8") (:authors ("Paul Landes")) (:maintainers ("Paul Landes")) (:maintainer "Paul Landes") (:keywords "frames") (:url . "https://github.com/plandes/cframe"))]) (cfrs . [(20220129 1149) ((emacs (26 1)) (dash (2 11 0)) (s (1 10 0)) (posframe (0 6 0))) "Child-frame based read-string" tar ((:commit . "f3a21f237b2a54e6b9f8a420a9da42b4f0a63121") (:authors ("Alexander Miller" . "alexanderm@web.de")) (:maintainers ("Alexander Miller" . "alexanderm@web.de")) (:maintainer "Alexander Miller" . "alexanderm@web.de") (:url . "https://github.com/Alexander-Miller/cfrs"))]) (cg . [(20240430 2040) ((emacs (26 1))) "Major mode for editing Constraint Grammar files" tar ((:commit . "06fb61345a4f3aae4bda74f3dfe261b1ec9d902d") (:authors ("Kevin Brubeck Unhammer" . "unhammer@fsfe.org")) (:maintainers ("Kevin Brubeck Unhammer" . "unhammer@fsfe.org")) (:maintainer "Kevin Brubeck Unhammer" . "unhammer@fsfe.org") (:keywords "languages") (:url . "https://visl.sdu.dk/constraint_grammar.html"))]) @@ -556,10 +557,10 @@ (chronometrist-goal . [(20210510 1831) ((emacs (25 1)) (alert (1 2)) (chronometrist (0 7 0))) "Adds support for time goals to Chronometrist" tar ((:commit . "6cb939d160f5d5966d7853aa23f3ed7c7ef9df44") (:authors ("contrapunctus" . "xmpp:contrapunctus@jabber.fr")) (:maintainers ("contrapunctus" . "xmpp:contrapunctus@jabber.fr")) (:maintainer "contrapunctus" . "xmpp:contrapunctus@jabber.fr") (:keywords "calendar") (:url . "https://tildegit.org/contrapunctus/chronometrist-goal"))]) (chronometrist-key-values . [(20230629 1039) ((chronometrist (0 7 0))) "add key-values to Chronometrist data" tar ((:commit . "d8290a82ea65730413627325a705067269cfa2f1") (:authors ("contrapunctus" . "xmpp:contrapunctus@jabjab.de")) (:maintainers ("contrapunctus" . "xmpp:contrapunctus@jabjab.de")) (:maintainer "contrapunctus" . "xmpp:contrapunctus@jabjab.de") (:keywords "calendar") (:url . "https://tildegit.org/contrapunctus/chronometrist"))]) (chronometrist-spark . [(20230629 1039) ((emacs (25 1)) (chronometrist (0 7 0)) (spark (0 1))) "Show sparklines in Chronometrist buffers" tar ((:commit . "d8290a82ea65730413627325a705067269cfa2f1") (:authors ("contrapunctus" . "xmpp:contrapunctus@jabjab.de")) (:maintainers ("contrapunctus" . "xmpp:contrapunctus@jabjab.de")) (:maintainer "contrapunctus" . "xmpp:contrapunctus@jabjab.de") (:keywords "calendar") (:url . "https://tildegit.org/contrapunctus/chronometrist"))]) - (chronos . [(20230804 1712) ((emacs (27 1))) "Multiple simultaneous countdown / countup timers" tar ((:commit . "517c53f57c54ec64e1bc870a63b0f4cf1772fcf1") (:authors ("David Knight" . "dxknight@opmbx.org")) (:maintainers ("David Knight" . "dxknight@opmbx.org")) (:maintainer "David Knight" . "dxknight@opmbx.org") (:keywords "calendar") (:url . "http://github.com/DarkBuffalo/chronos"))]) + (chronos . [(20240525 1339) ((emacs (27 1))) "Multiple simultaneous countdown / countup timers" tar ((:commit . "5ea0bf7c3881ea905e280446342539b242401979") (:authors ("David Knight" . "dxknight@opmbx.org")) (:maintainers ("David Knight" . "dxknight@opmbx.org")) (:maintainer "David Knight" . "dxknight@opmbx.org") (:keywords "calendar") (:url . "http://github.com/DarkBuffalo/chronos"))]) (chruby . [(20180114 1652) ((cl-lib (0 5))) "Emacs integration for chruby" tar ((:commit . "42bc6d521f832eca8e2ba210f30d03ad5529788f") (:authors ("Arne Brasseur" . "arne@arnebrasseur.net")) (:maintainers ("Arne Brasseur" . "arne@arnebrasseur.net")) (:maintainer "Arne Brasseur" . "arne@arnebrasseur.net") (:keywords "languages") (:url . "https://github.com/plexus/chruby.el"))]) (chyla-theme . [(20231220 1545) nil "chyla.org - green color theme." tar ((:commit . "4d4b9dca3547e919ed5311cc7d04821f77860fbd") (:authors ("Adam Chyła" . "adam@chyla.org")) (:maintainers ("Adam Chyła" . "adam@chyla.org")) (:maintainer "Adam Chyła" . "adam@chyla.org") (:url . "https://github.com/chyla/ChylaThemeForEmacs"))]) - (cider . [(20240521 1504) ((emacs (26)) (clojure-mode (5 18 1)) (parseedn (1 2 1)) (queue (0 2)) (spinner (1 7)) (seq (2 22)) (sesman (0 3 2)) (transient (0 4 1))) "Clojure Interactive Development Environment that Rocks" tar ((:commit . "c2394fc7954170fd05a23f5e44ea74b12c25e637") (:authors ("Tim King" . "kingtim@gmail.com") ("Phil Hagelberg" . "technomancy@gmail.com") ("Bozhidar Batsov" . "bozhidar@batsov.dev") ("Artur Malabarba" . "bruce.connor.am@gmail.com") ("Hugo Duncan" . "hugo@hugoduncan.org") ("Steve Purcell" . "steve@sanityinc.com")) (:maintainers ("Bozhidar Batsov" . "bozhidar@batsov.dev")) (:maintainer "Bozhidar Batsov" . "bozhidar@batsov.dev") (:keywords "languages" "clojure" "cider") (:url . "https://www.github.com/clojure-emacs/cider"))]) + (cider . [(20240602 1213) ((emacs (26)) (clojure-mode (5 19)) (parseedn (1 2 1)) (queue (0 2)) (spinner (1 7)) (seq (2 22)) (sesman (0 3 2)) (transient (0 4 1))) "Clojure Interactive Development Environment that Rocks" tar ((:commit . "5f79b02fda70179349ba34a4fed1436708c669c3") (:authors ("Tim King" . "kingtim@gmail.com") ("Phil Hagelberg" . "technomancy@gmail.com") ("Bozhidar Batsov" . "bozhidar@batsov.dev") ("Artur Malabarba" . "bruce.connor.am@gmail.com") ("Hugo Duncan" . "hugo@hugoduncan.org") ("Steve Purcell" . "steve@sanityinc.com")) (:maintainers ("Bozhidar Batsov" . "bozhidar@batsov.dev")) (:maintainer "Bozhidar Batsov" . "bozhidar@batsov.dev") (:keywords "languages" "clojure" "cider") (:url . "https://www.github.com/clojure-emacs/cider"))]) (cider-decompile . [(20151122 537) ((cider (0 3 0)) (javap-mode (9))) "decompilation extension for cider" tar ((:commit . "5d87035f3c3c14025e8f01c0c53d0ce2c8f56651") (:authors ("Dmitry Bushenko")) (:maintainers ("Dmitry Bushenko")) (:maintainer "Dmitry Bushenko") (:keywords "languages" "clojure" "cider") (:url . "http://www.github.com/clojure-emacs/cider-decompile"))]) (cider-eval-sexp-fu . [(20190311 2152) ((emacs (24)) (eval-sexp-fu (0 5 0))) "Briefly highlights an evaluated sexp." tar ((:commit . "7fd229f1441356866aedba611fd0cf4e89b50921") (:authors ("Sylvain Benner" . "sylvain.benner@gmail.com")) (:maintainers ("Sylvain Benner" . "sylvain.benner@gmail.com")) (:maintainer "Sylvain Benner" . "sylvain.benner@gmail.com") (:keywords "languages" "clojure" "cider"))]) (cider-hydra . [(20190816 1121) ((cider (0 22 0)) (hydra (0 13 0))) "Hydras for CIDER." tar ((:commit . "c3b8a15d72dddfbc390ab6a454bd7e4c765a2c95") (:authors ("Tianxiang Xiong" . "tianxiang.xiong@gmail.com")) (:maintainers ("Tianxiang Xiong" . "tianxiang.xiong@gmail.com")) (:maintainer "Tianxiang Xiong" . "tianxiang.xiong@gmail.com") (:keywords "convenience" "tools") (:url . "https://github.com/clojure-emacs/cider-hydra"))]) @@ -572,12 +573,12 @@ (circe-notifications . [(20180102 2318) ((emacs (24 4)) (circe (2 3)) (alert (1 2))) "Add desktop notifications to Circe." tar ((:commit . "291149ac12877bbd062da993479d3533a26862b0") (:authors ("Ruben Maher" . "r@rkm.id.au")) (:maintainers ("Ruben Maher" . "r@rkm.id.au")) (:maintainer "Ruben Maher" . "r@rkm.id.au") (:url . "https://github.com/eqyiel/circe-notifications"))]) (circleci-api . [(20210227 1607) ((emacs (27)) (request (0 3 2))) "Bindings for the CircleCI API" tar ((:commit . "1432b0ad0f32b03fec564c0815951d5e096c2f6a") (:authors ("Robin Schroer")) (:maintainers ("Robin Schroer")) (:maintainer "Robin Schroer") (:url . "https://github.com/sulami/circleci-api"))]) (citar . [(20240419 2232) ((emacs (27 1)) (parsebib (4 2)) (org (9 5)) (citeproc (0 9))) "Citation-related commands for org, latex, markdown" tar ((:commit . "07d2a63c99fe35cbd468f8e6a322de05f1a29469") (:authors ("Bruce D'Arcus <https://github.com/bdarcus>")) (:maintainers ("Bruce D'Arcus <https://github.com/bdarcus>")) (:maintainer "Bruce D'Arcus <https://github.com/bdarcus>") (:url . "https://github.com/emacs-citar/citar"))]) - (citar-denote . [(20240520 2325) ((emacs (28 1)) (citar (1 4)) (denote (2 0)) (dash (2 19 1))) "Minor mode integrating Citar and Denote" tar ((:commit . "1c62db7107b1ff9de5f87a03d9ac1973c4bbb0ec") (:authors ("Peter Prevos" . "peter@prevos.net")) (:maintainers ("Peter Prevos" . "peter@prevos.net")) (:maintainer "Peter Prevos" . "peter@prevos.net") (:url . "https://github.com/pprevos/citar-denote"))]) + (citar-denote . [(20240524 924) ((emacs (28 1)) (citar (1 4)) (denote (2 0)) (dash (2 19 1))) "Minor mode integrating Citar and Denote" tar ((:commit . "3e0d031be07ec9c2f2205846191393b5783fa038") (:authors ("Peter Prevos" . "peter@prevos.net")) (:maintainers ("Peter Prevos" . "peter@prevos.net")) (:maintainer "Peter Prevos" . "peter@prevos.net") (:url . "https://github.com/pprevos/citar-denote"))]) (citar-embark . [(20231122 1548) ((emacs (27 1)) (embark (0 17)) (citar (0 9 7))) "Citar/Embark integration" tar ((:commit . "572b7b6e569e9423dd948539fa48d3f53ceffe57") (:authors ("Bruce D'Arcus" . "bdarcus@gmail.com")) (:maintainers ("Bruce D'Arcus" . "bdarcus@gmail.com")) (:maintainer "Bruce D'Arcus" . "bdarcus@gmail.com") (:keywords "bib" "extensions") (:url . "https://github.com/emacs-citar/citar"))]) (citar-org-roam . [(20240212 2159) ((emacs (27 1)) (org-roam (2 2)) (citar (1 2 0))) "Citar/org-roam integration" tar ((:commit . "999268c7a077aad6a8f4dfc88d0eeabdf4267fea") (:authors ("Bruce D'Arcus" . "bdarcus@gmail.com")) (:maintainers ("Bruce D'Arcus" . "bdarcus@gmail.com")) (:maintainer "Bruce D'Arcus" . "bdarcus@gmail.com") (:url . "https://github.com/emacs-citar/citar-org-roam"))]) (citeproc . [(20240513 1309) ((emacs (26)) (dash (2 13 0)) (s (1 12 0)) (f (0 18 0)) (queue (0 2)) (string-inflection (1 0)) (org (9)) (parsebib (2 4)) (compat (28 1))) "A CSL 1.0.2 Citation Processor" tar ((:commit . "fed285385c1a8c0248890cd591f64a0e2598334d") (:authors ("András Simonyi" . "andras.simonyi@gmail.com")) (:maintainers ("András Simonyi" . "andras.simonyi@gmail.com")) (:maintainer "András Simonyi" . "andras.simonyi@gmail.com") (:keywords "bib") (:url . "https://github.com/andras-simonyi/citeproc-el"))]) (citeproc-org . [(20200915 2009) ((emacs (25 1)) (dash (2 12 0)) (org (9)) (f (0 18 0)) (citeproc (0 1)) (org-ref (1 1 1))) "Render org-mode references in CSL styles" tar ((:commit . "22a759c4f0ec80075014dcc594baa4d1b470d995") (:authors ("András Simonyi" . "andras.simonyi@gmail.com")) (:maintainers ("András Simonyi" . "andras.simonyi@gmail.com")) (:maintainer "András Simonyi" . "andras.simonyi@gmail.com") (:keywords "org-ref" "org-mode" "cite" "bib") (:url . "https://github.com/andras-simonyi/citeproc-org"))]) - (citre . [(20240508 1154) ((emacs (26 1))) "Superior code reading & auto-completion tool with pluggable backends." tar ((:commit . "fe670ff2410fe4cd59cdce8ef1b947deefa71879") (:authors ("Hao Wang" . "amaikinono@gmail.com")) (:maintainers ("Hao Wang" . "amaikinono@gmail.com")) (:maintainer "Hao Wang" . "amaikinono@gmail.com") (:keywords "convenience" "tools") (:url . "https://github.com/universal-ctags/citre"))]) + (citre . [(20240524 1418) ((emacs (26 1))) "Superior code reading & auto-completion tool with pluggable backends." tar ((:commit . "7c9c77276cc7dfcb77640df7d589eaac3198cfee") (:authors ("Hao Wang" . "amaikinono@gmail.com")) (:maintainers ("Hao Wang" . "amaikinono@gmail.com")) (:maintainer "Hao Wang" . "amaikinono@gmail.com") (:keywords "convenience" "tools") (:url . "https://github.com/universal-ctags/citre"))]) (cl-format . [(20230818 1726) nil "CL format routine." tar ((:commit . "42b662d27eefa458c1a39bea1836d6ada740b863") (:authors ("Andreas Politz" . "politza@fh-trier.de")) (:maintainer "akater" . "nuclearspace@gmail.com") (:keywords "extensions") (:url . "https://gitlab.com/akater/elisp-cl-format"))]) (cl-libify . [(20181130 230) ((emacs (25))) "Update elisp code to use cl-lib instead of cl" tar ((:commit . "e205b96f944a4f312fd523804cbbaf00027a3c8b") (:authors ("Steve Purcell" . "steve@sanityinc.com")) (:maintainers ("Steve Purcell" . "steve@sanityinc.com")) (:maintainer "Steve Purcell" . "steve@sanityinc.com") (:keywords "lisp") (:url . "https://github.com/purcell/cl-libify"))]) (clang-capf . [(20221030 1830) ((emacs (24 4))) "Completion-at-point backend for c/c++ using clang" tar ((:commit . "5e4dfba90ce86bbc7ee61805edfca04fff93c291") (:authors ("Philip K. <philipk [at] posteo [dot] net>")) (:maintainers ("Philip K. <philipk [at] posteo [dot] net>")) (:maintainer "Philip K. <philipk [at] posteo [dot] net>") (:keywords "c" "abbrev" "convenience") (:url . "https://git.sr.ht/~pkal/clang-capf"))]) @@ -614,13 +615,13 @@ (clojars . [(20180825 1951) ((request-deferred (0 2 0))) "clojars.org search interface" tar ((:commit . "c78e4d5ddacda064c253e2b38d1c35188aa1ad71") (:authors ("Joshua Miller" . "josh@joshmiller.io")) (:maintainers ("Joshua Miller" . "josh@joshmiller.io")) (:maintainer "Joshua Miller" . "josh@joshmiller.io") (:keywords "docs" "help" "tools") (:url . "https://github.com/joshuamiller/clojars.el"))]) (clojure-essential-ref . [(20221215 1427) ((emacs (24)) (cider (0 24 0))) "Cider-doc to \"Clojure, The Essential Reference\"" tar ((:commit . "6741bf65cf9b9bc896ab1cc3c384573e8ffe5f96") (:url . "https://github.com/p3r7/clojure-essential-ref"))]) (clojure-essential-ref-nov . [(20221215 1427) ((emacs (24)) (dash (2 16 0)) (nov (0 3 1)) (clojure-essential-ref (0 1 0))) "Cider-doc to \"Clojure, The Essential Reference\" (EPUB)" tar ((:commit . "6741bf65cf9b9bc896ab1cc3c384573e8ffe5f96") (:url . "https://github.com/p3r7/clojure-essential-ref"))]) - (clojure-mode . [(20240516 525) ((emacs (25 1))) "Major mode for Clojure code" tar ((:commit . "faee3efbb1e940af0e5777514923c8dea567f87d") (:maintainers ("Bozhidar Batsov" . "bozhidar@batsov.dev")) (:maintainer "Bozhidar Batsov" . "bozhidar@batsov.dev") (:keywords "languages" "clojure" "clojurescript" "lisp") (:url . "https://github.com/clojure-emacs/clojure-mode"))]) - (clojure-mode-extra-font-locking . [(20231124 732) ((clojure-mode (3 0))) "Extra font-locking for Clojure mode" tar ((:commit . "25d713a67d8e0209ee74bfc0153fdf677697b43f") (:authors ("Bozhidar Batsov" . "bozhidar@batsov.dev")) (:maintainers ("Bozhidar Batsov" . "bozhidar@batsov.dev")) (:maintainer "Bozhidar Batsov" . "bozhidar@batsov.dev") (:keywords "languages" "lisp") (:url . "https://github.com/clojure-emacs/clojure-mode"))]) + (clojure-mode . [(20240526 1825) ((emacs (25 1))) "Major mode for Clojure code" tar ((:commit . "815bc387ec1436fb2fcac00ba8a61207636d0186") (:maintainers ("Bozhidar Batsov" . "bozhidar@batsov.dev")) (:maintainer "Bozhidar Batsov" . "bozhidar@batsov.dev") (:keywords "languages" "clojure" "clojurescript" "lisp") (:url . "https://github.com/clojure-emacs/clojure-mode"))]) + (clojure-mode-extra-font-locking . [(20240526 1824) ((clojure-mode (3 0))) "Extra font-locking for Clojure mode" tar ((:commit . "4afdd3539036bbd6b1c01b2e00559676c4d40085") (:authors ("Bozhidar Batsov" . "bozhidar@batsov.dev")) (:maintainers ("Bozhidar Batsov" . "bozhidar@batsov.dev")) (:maintainer "Bozhidar Batsov" . "bozhidar@batsov.dev") (:keywords "languages" "lisp") (:url . "https://github.com/clojure-emacs/clojure-mode"))]) (clojure-quick-repls . [(20150814 736) ((cider (0 8 1)) (dash (2 9 0))) "Quickly create Clojure and ClojureScript repls for a project." tar ((:commit . "8fe4e44939e8a01a4cdf60c0001d9a6abf8a73c3") (:keywords "languages" "clojure" "cider" "clojurescript") (:url . "https://github.com/symfrog/clojure-quick-repls"))]) (clojure-snippets . [(20220914 950) ((yasnippet (0 10 0))) "Yasnippets for clojure" tar ((:commit . "66d23f0ffedf2cc2be0387c3504b5f89d7300cfa") (:authors ("Max Penet" . "m@qbits.cc")) (:maintainer "Max Penet" . "m@qbits.cc") (:keywords "snippets"))]) (clojure-ts-mode . [(20240314 552) ((emacs (29 1))) "Major mode for Clojure code" tar ((:commit . "8afa5656955814193b3b27020faf4edf00abda88") (:maintainers ("Danny Freeman" . "danny@dfreeman.email")) (:maintainer "Danny Freeman" . "danny@dfreeman.email") (:keywords "languages" "clojure" "clojurescript" "lisp") (:url . "http://github.com/clojure-emacs/clojure-ts-mode"))]) (clomacs . [(20220415 1035) ((emacs (24 3)) (cider (0 22 1)) (s (1 12 0)) (simple-httpd (1 4 6)) (dash (2 19 1))) "Simplifies Emacs Lisp interaction with Clojure." tar ((:commit . "9cd7c9fd86bc7bc627a31275d1ef131378b90a49") (:authors ("Kostafey" . "kostafey@gmail.com")) (:maintainers ("Kostafey" . "kostafey@gmail.com")) (:maintainer "Kostafey" . "kostafey@gmail.com") (:keywords "clojure" "interaction") (:url . "https://github.com/clojure-emacs/clomacs"))]) - (closql . [(20240415 1534) ((emacs (25 1)) (compat (29 1 4 5)) (emacsql (20240124))) "Store EIEIO objects using EmacSQL" tar ((:commit . "2bff36edd28c9a0d0c25b545b3837fa874376cc5") (:authors ("Jonas Bernoulli" . "emacs.closql@jonas.bernoulli.dev")) (:maintainers ("Jonas Bernoulli" . "emacs.closql@jonas.bernoulli.dev")) (:maintainer "Jonas Bernoulli" . "emacs.closql@jonas.bernoulli.dev") (:keywords "extensions") (:url . "https://github.com/emacscollective/closql"))]) + (closql . [(20240531 1836) ((emacs (26 1)) (compat (29 1 4 5)) (emacsql (20240124))) "Store EIEIO objects using EmacSQL" tar ((:commit . "c591e6b310e1e583ca466a8f2c42d3c5d1ada435") (:authors ("Jonas Bernoulli" . "emacs.closql@jonas.bernoulli.dev")) (:maintainers ("Jonas Bernoulli" . "emacs.closql@jonas.bernoulli.dev")) (:maintainer "Jonas Bernoulli" . "emacs.closql@jonas.bernoulli.dev") (:keywords "extensions") (:url . "https://github.com/emacscollective/closql"))]) (closure-lint-mode . [(20101118 2124) nil "minor mode for the Closure Linter" tar ((:commit . "bc3d2fd5c35580bf1b8af43b12484c95a343b4b5") (:authors ("Roman Scherer" . "roman@burningswell.com")) (:maintainers ("Roman Scherer" . "roman@burningswell.com")) (:maintainer "Roman Scherer" . "roman@burningswell.com") (:keywords "tools" "closure" "javascript" "lint" "flymake") (:url . "https://github.com/r0man/closure-lint-mode"))]) (cloud-theme . [(20220205 1336) ((emacs (24))) "A light colored theme" tar ((:commit . "16ef7fbf0a423b29e3c3a0a2d9525afaf265aaed") (:authors ("Valerii Lysenko" . "vallyscode@gmail.com")) (:maintainers ("Valerii Lysenko" . "vallyscode@gmail.com")) (:maintainer "Valerii Lysenko" . "vallyscode@gmail.com") (:keywords "color" "theme") (:url . "https://github.com/vallyscode/cloud-theme"))]) (cloud-to-butt-erc . [(20130627 2308) nil "Replace 'the cloud' with 'my butt'" tar ((:commit . "6710c03d1bc91736435cbfe845924940cae34e5c") (:authors ("David Leatherman" . "leathekd@gmail.com")) (:maintainers ("David Leatherman" . "leathekd@gmail.com")) (:maintainer "David Leatherman" . "leathekd@gmail.com") (:url . "http://www.github.com/leathekd/cloud-to-butt-erc"))]) @@ -678,7 +679,7 @@ (commenter . [(20160219 1627) ((emacs (24 4)) (let-alist (1 0 4))) "multiline-comment support package" tar ((:commit . "6d1885419434ba779270c6fda0e30d390bb074bd") (:authors ("Yuta Yamada <cokesboy\"at\"gmail.com>")) (:maintainers ("Yuta Yamada <cokesboy\"at\"gmail.com>")) (:maintainer "Yuta Yamada <cokesboy\"at\"gmail.com>") (:keywords "comment") (:url . "https://github.com/yuutayamada/commenter"))]) (commify . [(20230616 1042) ((s (1 9 0))) "Toggle grouping commas in numbers" tar ((:commit . "35e2438eb7feeb28273c4920376fcf296cc83283") (:authors ("Daniel E. Doherty" . "ded-commify@ddoherty.net")) (:maintainers ("Daniel E. Doherty" . "ded-commify@ddoherty.net")) (:maintainer "Daniel E. Doherty" . "ded-commify@ddoherty.net") (:keywords "convenience" "editing" "numbers" "grouping" "commas") (:url . "https://github.com/ddoherty03/commify"))]) (common-lisp-snippets . [(20180226 1523) ((yasnippet (0 8 0))) "Yasnippets for Common Lisp" tar ((:commit . "1ddf808311ba4d9e8444a1cb50bd5ee75e4111f6") (:authors ("Mark Karpov" . "markkarpov92@gmail.com")) (:maintainers ("Mark Karpov" . "markkarpov92@gmail.com")) (:maintainer "Mark Karpov" . "markkarpov92@gmail.com") (:keywords "snippets") (:url . "https://github.com/mrkkrp/common-lisp-snippets"))]) - (company . [(20240428 2258) ((emacs (25 1))) "Modular text completion framework" tar ((:commit . "32f030a4c79bbf082cc21ec21b2cf8ba9dfa22cc") (:authors ("Nikolaj Schumacher")) (:maintainers ("Dmitry Gutov" . "dmitry@gutov.dev")) (:maintainer "Dmitry Gutov" . "dmitry@gutov.dev") (:keywords "abbrev" "convenience" "matching") (:url . "http://company-mode.github.io/"))]) + (company . [(20240524 206) ((emacs (25 1))) "Modular text completion framework" tar ((:commit . "6c7731d4ec1e43199ea328e1691999b4fe8967a8") (:authors ("Nikolaj Schumacher")) (:maintainers ("Dmitry Gutov" . "dmitry@gutov.dev")) (:maintainer "Dmitry Gutov" . "dmitry@gutov.dev") (:keywords "abbrev" "convenience" "matching") (:url . "http://company-mode.github.io/"))]) (company-anaconda . [(20230821 2126) ((emacs (25 1)) (company (0 8 0)) (anaconda-mode (0 1 1)) (cl-lib (0 5 0)) (dash (2 6 0)) (s (1 9))) "Anaconda backend for company-mode" tar ((:commit . "14867265e474f7a919120bbac74870c3256cbacf") (:authors ("Artem Malyshev" . "proofit404@gmail.com")) (:maintainers ("Artem Malyshev" . "proofit404@gmail.com")) (:maintainer "Artem Malyshev" . "proofit404@gmail.com") (:keywords "convenience" "company" "anaconda") (:url . "https://github.com/proofit404/anaconda-mode"))]) (company-ansible . [(20240221 2255) ((emacs (24 4)) (company (0 8 12))) "A company back-end for ansible" tar ((:commit . "338922601cf9e8ada863fe6f2dd9d5145d9983b0") (:authors ("Krzysztof Magosa" . "krzysztof@magosa.pl")) (:maintainers ("Krzysztof Magosa" . "krzysztof@magosa.pl")) (:maintainer "Krzysztof Magosa" . "krzysztof@magosa.pl") (:keywords "ansible") (:url . "https://github.com/krzysztof-magosa/company-ansible"))]) (company-arduino . [(20160306 1739) ((emacs (24 1)) (company (0 8 0)) (irony (0 1 0)) (cl-lib (0 5)) (company-irony (0 1 0)) (company-c-headers (20140930)) (arduino-mode (1 0))) "company-mode for Arduino" tar ((:commit . "5958b917cc5cc729dc64d74d947da5ee91c48980") (:authors ("Yuta Yamada" . "sleepboy.zzz@gmail.com")) (:maintainers ("Yuta Yamada" . "sleepboy.zzz@gmail.com")) (:maintainer "Yuta Yamada" . "sleepboy.zzz@gmail.com") (:keywords "convenience" "development" "company") (:url . "https://github.com/yuutayamada/company-arduino"))]) @@ -700,7 +701,7 @@ (company-erlang . [(20170123 538) ((emacs (24 4)) (ivy-erlang-complete (0 1)) (company (0 9 2))) "company backend based on ivy-erlang-complete" tar ((:commit . "bc0524a16f17b66c7397690e4ca0e004f09ea6c5") (:authors ("Sergey Kostyaev" . "feo.me@ya.ru")) (:maintainers ("Sergey Kostyaev" . "feo.me@ya.ru")) (:maintainer "Sergey Kostyaev" . "feo.me@ya.ru") (:keywords "tools"))]) (company-flow . [(20180225 2159) ((company (0 8 0)) (dash (2 13 0))) "Flow backend for company-mode" tar ((:commit . "76ef585c70d2a3206c2eadf24ba61e59124c3a16") (:authors ("Aaron Jensen" . "aaronjensen@gmail.com")) (:maintainers ("Aaron Jensen" . "aaronjensen@gmail.com")) (:maintainer "Aaron Jensen" . "aaronjensen@gmail.com") (:url . "https://github.com/aaronjensen/company-flow"))]) (company-flx . [(20180103 518) ((emacs (24)) (company (0 8 12)) (flx (0 5))) "flx based fuzzy matching for company" tar ((:commit . "05efcafb488f587bb6e60923078d97227462eb68") (:authors ("PythonNut" . "pythonnut@pythonnut.com")) (:maintainers ("PythonNut" . "pythonnut@pythonnut.com")) (:maintainer "PythonNut" . "pythonnut@pythonnut.com") (:keywords "convenience" "company" "fuzzy" "flx") (:url . "https://github.com/PythonNut/company-flx"))]) - (company-fuzzy . [(20240519 904) ((emacs (26 1)) (company (0 8 12)) (s (1 12 0)) (ht (2 0))) "Fuzzy matching for `company-mode'" tar ((:commit . "ae4dbb00d91fae8f13e236093d99c7e4d0d8fa73") (:authors ("Shen, Jen-Chieh" . "jcs090218@gmail.com")) (:maintainers ("Shen, Jen-Chieh" . "jcs090218@gmail.com")) (:maintainer "Shen, Jen-Chieh" . "jcs090218@gmail.com") (:keywords "matching" "auto-complete" "complete" "fuzzy") (:url . "https://github.com/jcs-elpa/company-fuzzy"))]) + (company-fuzzy . [(20240529 2153) ((emacs (26 1)) (company (0 8 12)) (s (1 12 0)) (ht (2 0))) "Fuzzy matching for `company-mode'" tar ((:commit . "04507c338dea5f4a21c6d8872853aeaceabc377e") (:authors ("Shen, Jen-Chieh" . "jcs090218@gmail.com")) (:maintainers ("Shen, Jen-Chieh" . "jcs090218@gmail.com")) (:maintainer "Shen, Jen-Chieh" . "jcs090218@gmail.com") (:keywords "matching" "auto-complete" "complete" "fuzzy") (:url . "https://github.com/jcs-elpa/company-fuzzy"))]) (company-ghci . [(20190707 311) ((company (0 8 11)) (haskell-mode (13))) "company backend which uses the current ghci process." tar ((:commit . "a1d25652583ab4666c5a78cac18cd8039776b50d") (:authors ("Hector Orellana" . "hofm92@gmail.com")) (:maintainers ("Hector Orellana" . "hofm92@gmail.com")) (:maintainer "Hector Orellana" . "hofm92@gmail.com"))]) (company-glsl . [(20210109 1403) ((company (0 9 4)) (glsl-mode (2 4)) (emacs (24 4))) "Support glsl in company-mode" tar ((:commit . "3a40501ba831a30a7fd3e8529b20d1305d0454aa") (:authors ("Guido Schmidt" . "git@guidoschmidt.cc")) (:maintainers ("Guido Schmidt" . "git@guidoschmidt.cc")) (:maintainer "Guido Schmidt" . "git@guidoschmidt.cc") (:url . "https://github.com/guidoschmidt/company-glsl"))]) (company-go . [(20170825 1643) ((company (0 8 0)) (go-mode (1 0 0))) "company-mode backend for Go (using gocode)" tar ((:commit . "31948b463f2fc18f8801e5a8fe511fef300eb3dd") (:authors ("nsf" . "no.smile.face@gmail.com")) (:maintainers ("nsf" . "no.smile.face@gmail.com")) (:maintainer "nsf" . "no.smile.face@gmail.com") (:keywords "languages"))]) @@ -754,7 +755,7 @@ (compile-multi . [(20240507 1829) ((emacs (28 1))) "A multi target interface to compile" tar ((:commit . "1fbd38806c70ebe8ebfec49cc7606284396a31e6") (:authors ("mohsin kaleem" . "mohkale@kisara.moe")) (:maintainers ("mohsin kaleem" . "mohkale@kisara.moe")) (:maintainer "mohsin kaleem" . "mohkale@kisara.moe") (:keywords "tools" "compile" "build") (:url . "https://github.com/mohkale/compile-multi"))]) (compile-multi-all-the-icons . [(20240506 1319) ((emacs (28 0)) (all-the-icons-completion (0 0 1))) "Affixate `compile-multi' with icons" tar ((:commit . "4f9cc1d3c448ecc496540a65578191733c09b0fd") (:authors ("mohsin kaleem" . "mohkale@kisara.moe")) (:maintainers ("mohsin kaleem" . "mohkale@kisara.moe")) (:maintainer "mohsin kaleem" . "mohkale@kisara.moe") (:keywords "tools" "compile" "build") (:url . "https://github.com/mohkale/compile-multi"))]) (compile-multi-embark . [(20230904 1806) ((emacs (28 1)) (compile-multi (0 4)) (embark (0 22 1))) "Integration for `compile-multi' and `embark'" tar ((:commit . "30edb0e86287101269debf20f43cead92310029a") (:authors ("Mohsin Kaleem" . "mohkale@kisara.moe")) (:maintainers ("Mohsin Kaleem" . "mohkale@kisara.moe")) (:maintainer "Mohsin Kaleem" . "mohkale@kisara.moe") (:keywords "project" "convenience") (:url . "https://github.com/mohkale/compile-multi"))]) - (compiler-explorer . [(20240517 1816) ((emacs (26 1)) (plz (0 8)) (eldoc (1 15 0)) (map (3 3 1)) (seq (2 24))) "Compiler explorer client (godbolt.org)" tar ((:commit . "ca01cbfa5941750f3cf2232f00e28032ef7f9bce") (:authors ("Michał Krzywkowski" . "k.michal@zoho.com")) (:maintainers ("Michał Krzywkowski" . "k.michal@zoho.com")) (:maintainer "Michał Krzywkowski" . "k.michal@zoho.com") (:keywords "c" "tools") (:url . "https://github.com/mkcms/compiler-explorer.el"))]) + (compiler-explorer . [(20240530 1705) ((emacs (26 1)) (plz (0 8)) (eldoc (1 15 0)) (map (3 3 1)) (seq (2 23))) "Compiler explorer client (godbolt.org)" tar ((:commit . "689559954dcfa9abfae37962d5127a9922cfb52c") (:authors ("Michał Krzywkowski" . "k.michal@zoho.com")) (:maintainers ("Michał Krzywkowski" . "k.michal@zoho.com")) (:maintainer "Michał Krzywkowski" . "k.michal@zoho.com") (:keywords "c" "tools") (:url . "https://github.com/mkcms/compiler-explorer.el"))]) (composable . [(20220608 1148) ((emacs (25 1))) "composable editing" tar ((:commit . "205a69c64ea95ef67070423c31ed70ec44ec980c") (:authors ("Simon Friis Vindum" . "simon@vindum.io")) (:maintainers ("Simon Friis Vindum" . "simon@vindum.io")) (:maintainer "Simon Friis Vindum" . "simon@vindum.io") (:keywords "lisp"))]) (composer . [(20221120 202) ((emacs (25 1)) (seq (1 9)) (php-runtime (0 1 0))) "Interface to PHP Composer" tar ((:commit . "2299cd731205906350d615021f99a66d7a8905c2") (:authors ("USAMI Kenta" . "tadsan@zonu.me")) (:maintainers ("USAMI Kenta" . "tadsan@zonu.me")) (:maintainer "USAMI Kenta" . "tadsan@zonu.me") (:keywords "tools" "php" "dependency" "manager") (:url . "https://github.com/zonuexe/composer.el"))]) (comware-router-mode . [(20240103 907) ((dash (2 16 0)) (emacs (24 3))) "Major mode for editing Comware configuration files" tar ((:commit . "e1671efe5e0ade2dcbea0c17697d460cd8f0ba67") (:authors ("Davide Restivo" . "davide.restivo@yahoo.it")) (:maintainers ("Davide Restivo" . "davide.restivo@yahoo.it")) (:maintainer "Davide Restivo" . "davide.restivo@yahoo.it") (:keywords "convenience" "faces") (:url . "https://github.com/daviderestivo/comware-router-mode"))]) @@ -766,13 +767,13 @@ (conkeror-minor-mode . [(20150114 1604) nil "Mode for editing conkeror javascript files." tar ((:commit . "476e81c27b056e21c192391fe674a2bf875466b0") (:authors ("Artur Malabarba" . "bruce.connor.am@gmail.com>")) (:maintainers ("Artur Malabarba" . "bruce.connor.am@gmail.com>")) (:maintainer "Artur Malabarba" . "bruce.connor.am@gmail.com>") (:keywords "programming" "tools") (:url . "http://github.com/Bruce-Connor/conkeror-minor-mode"))]) (conllu-mode . [(20200501 2328) ((emacs (25)) (cl-lib (0 5)) (flycheck (30)) (hydra (0 13 0)) (s (1 0))) "editing mode for CoNLL-U files" tar ((:commit . "0db3063572b0de08874822e20570bb153747e6ed") (:authors ("bruno cuconato" . "bcclaro+emacs@gmail.com")) (:maintainers ("bruno cuconato" . "bcclaro+emacs@gmail.com")) (:maintainer "bruno cuconato" . "bcclaro+emacs@gmail.com") (:keywords "extensions") (:url . "https://github.com/odanoburu/conllu-mode"))]) (connection . [(20191111 446) nil "TCP-based client connection" tar ((:commit . "c9cad101100975e88873636bfd426b7a19304ebd") (:authors ("Torsten Hilbrich" . "torsten.hilbrich@gmx.net")) (:maintainers ("Torsten Hilbrich" . "torsten.hilbrich@gmx.net")) (:maintainer "Torsten Hilbrich" . "torsten.hilbrich@gmx.net") (:keywords "network"))]) - (conner . [(20240512 1717) ((emacs (29 1))) "Define and run project specific commands" tar ((:commit . "d8dabaab32e39b01500841b7465076c6ad73c3b9") (:keywords "tools") (:url . "https://github.com/tralph3/conner"))]) + (conner . [(20240529 445) ((emacs (29 1))) "Define and run project specific commands" tar ((:commit . "f9048e03f57a50dcbf7072c0b441496d3f80ea5a") (:keywords "tools") (:url . "https://github.com/tralph3/conner"))]) (constant-theme . [(20180921 1012) ((emacs (24 1))) "A calm, dark, almost monochrome color theme." tar ((:commit . "0feb9f99d708633d62fa548c953ebbe68fd70de0") (:authors ("Jannis Pohlmann" . "contact@jannispohlmann.de")) (:maintainers ("Jannis Pohlmann" . "contact@jannispohlmann.de")) (:maintainer "Jannis Pohlmann" . "contact@jannispohlmann.de") (:keywords "themes") (:url . "https://github.com/jannis/emacs-constant-theme"))]) - (consult . [(20240516 2240) ((emacs (27 1)) (compat (29 1 4 4))) "Consulting completing-read" tar ((:commit . "80407622f323669c735737272ecbc3b602434b77") (:authors ("Daniel Mendler and Consult contributors")) (:maintainers ("Daniel Mendler" . "mail@daniel-mendler.de")) (:maintainer "Daniel Mendler" . "mail@daniel-mendler.de") (:keywords "matching" "files" "completion") (:url . "https://github.com/minad/consult"))]) + (consult . [(20240523 754) ((emacs (27 1)) (compat (29 1 4 4))) "Consulting completing-read" tar ((:commit . "fe4852280006e61be7f1374d021ee06155ce5a26") (:authors ("Daniel Mendler and Consult contributors")) (:maintainers ("Daniel Mendler" . "mail@daniel-mendler.de")) (:maintainer "Daniel Mendler" . "mail@daniel-mendler.de") (:keywords "matching" "files" "completion") (:url . "https://github.com/minad/consult"))]) (consult-ag . [(20230227 406) ((emacs (27 1)) (consult (0 32))) "The silver searcher integration using Consult" tar ((:commit . "9eb4df265aedf2628a714610c2ade6d2f21de053") (:authors ("Kanon Kakuno" . "yadex205@outlook.jp")) (:maintainers ("Kanon Kakuno" . "yadex205@outlook.jp")) (:maintainer "Kanon Kakuno" . "yadex205@outlook.jp") (:url . "https://github.com/yadex205/consult-ag"))]) (consult-codesearch . [(20230315 1424) ((emacs (27 1)) (consult (0 20))) "Consult interface for codesearch" tar ((:commit . "51df545bb57b468058245950322ae15f6c3a0ce2") (:authors ("Youngjoo Lee" . "youngker@gmail.com")) (:maintainers ("Youngjoo Lee" . "youngker@gmail.com")) (:maintainer "Youngjoo Lee" . "youngker@gmail.com") (:keywords "tools") (:url . "https://github.com/youngker/consult-codesearch"))]) (consult-company . [(20230606 1824) ((emacs (27 1)) (company (0 9)) (consult (0 9))) "Consult frontend for company" tar ((:commit . "6e309fa9115c9ecd29aa27bff4e3b733979e5dbc") (:authors ("mohsin kaleem" . "mohkale@kisara.moe")) (:maintainers ("mohsin kaleem" . "mohkale@kisara.moe")) (:maintainer "mohsin kaleem" . "mohkale@kisara.moe") (:url . "https://github.com/mohkale/consult-company"))]) - (consult-compile-multi . [(20230904 1806) ((emacs (28 1)) (compile-multi (0 4)) (consult (0 34))) "Consulting read support for `compile-multi'" tar ((:commit . "30edb0e86287101269debf20f43cead92310029a") (:authors ("mohsin kaleem" . "mohkale@kisara.moe")) (:maintainers ("mohsin kaleem" . "mohkale@kisara.moe")) (:maintainer "mohsin kaleem" . "mohkale@kisara.moe") (:keywords "tools" "compile" "build") (:url . "https://github.com/mohkale/compile-multi"))]) + (consult-compile-multi . [(20240507 1949) ((emacs (28 1)) (compile-multi (0 4)) (consult (0 34))) "Consulting read support for `compile-multi'" tar ((:commit . "a8782ac55115b1afe0bee52664b46bfbd9bf202e") (:authors ("mohsin kaleem" . "mohkale@kisara.moe")) (:maintainers ("mohsin kaleem" . "mohkale@kisara.moe")) (:maintainer "mohsin kaleem" . "mohkale@kisara.moe") (:keywords "tools" "compile" "build") (:url . "https://github.com/mohkale/compile-multi"))]) (consult-dash . [(20230529 1419) ((emacs (27 2)) (dash-docs (1 4 0)) (consult (0 16))) "Consult front-end for dash-docs" tar ((:commit . "af9f26393583e4b5eb5f29fa4d7e72bf1a46d5f9") (:authors ("Ravi R Kiran" . "lists.ravi@gmail.com")) (:maintainers ("Ravi R Kiran" . "lists.ravi@gmail.com")) (:maintainer "Ravi R Kiran" . "lists.ravi@gmail.com") (:keywords "consult" "dash" "docs") (:url . "https://codeberg.org/ravi/consult-dash"))]) (consult-dir . [(20240506 236) ((emacs (27 1)) (consult (1 0))) "Insert paths into the minibuffer prompt" tar ((:commit . "15891383f34d43acc5bb82bda92239b1f54cf178") (:authors ("Karthik Chikmagalur")) (:maintainers ("Karthik Chikmagalur" . "karthik.chikmagalur@gmail.com")) (:maintainer "Karthik Chikmagalur" . "karthik.chikmagalur@gmail.com") (:keywords "convenience") (:url . "https://github.com/karthink/consult-dir"))]) (consult-eglot . [(20240324 1137) ((emacs (27 1)) (eglot (1 7)) (consult (0 31)) (project (0 3 0))) "A consulting-read interface for eglot" tar ((:commit . "4fa151f83f15de22eb2a241ddce95bed80b8ba79") (:authors ("mohsin kaleem" . "mohkale@kisara.moe")) (:maintainers ("Mohsin Kaleem")) (:maintainer "Mohsin Kaleem") (:keywords "tools" "completion" "lsp") (:url . "https://github.com/mohkale/consult-eglot"))]) @@ -782,7 +783,7 @@ (consult-ghq . [(20231111 1303) ((emacs (26 1)) (consult (0 8))) "Ghq interface using consult" tar ((:commit . "65a99980fb313d473376542cb87464a8a44ff25e") (:authors ("Tomoya Otake" . "tomoya.ton@gmail.com")) (:maintainers ("Tomoya Otake" . "tomoya.ton@gmail.com")) (:maintainer "Tomoya Otake" . "tomoya.ton@gmail.com") (:keywords "convenience" "usability" "consult" "ghq") (:url . "https://github.com/tomoya/consult-ghq"))]) (consult-git-log-grep . [(20230204 1753) ((emacs (27 1)) (consult (0 16))) "Consult integration for git log grep" tar ((:commit . "30dfcad5745a6b9882d94fec75d38c345a1eff89") (:authors ("Ghosty")) (:maintainers ("Ghosty")) (:maintainer "Ghosty") (:keywords "git" "convenience") (:url . "https://github.com/Ghosty141/consult-git-log-grep"))]) (consult-hatena-bookmark . [(20221125 109) ((emacs (27 1)) (consult (0 9)) (async-await (1 1))) "Consult commands for the Hatena Bookmark" tar ((:commit . "b85484b11705ebd896878d3ac7fdb12bc8c9637a") (:authors ("Yukinori Kitadai")) (:maintainers ("Yukinori Kitadai")) (:maintainer "Yukinori Kitadai") (:url . "https://github.com/Nyoho/consult-hatena-bookmark"))]) - (consult-ls-git . [(20230924 810) ((emacs (27 1)) (consult (0 16))) "Consult integration for git" tar ((:commit . "3ccd9d80da73a05ef2a74616ffdc469860f74c21") (:authors ("Robin Joy")) (:maintainers ("Robin Joy")) (:maintainer "Robin Joy") (:keywords "convenience") (:url . "https://github.com/rcj/consult-ls-git"))]) + (consult-ls-git . [(20240529 641) ((emacs (27 1)) (consult (0 16))) "Consult integration for git" tar ((:commit . "b1ca94f7c43cbd3811d09a0c9ab04f67f6318e95") (:authors ("Robin Joy")) (:maintainers ("Robin Joy")) (:maintainer "Robin Joy") (:keywords "convenience") (:url . "https://github.com/rcj/consult-ls-git"))]) (consult-lsp . [(20240507 2105) ((emacs (27 1)) (lsp-mode (5 0)) (consult (0 16)) (f (0 20 0))) "LSP-mode Consult integration" tar ((:commit . "68583913168bf66fd4d542b2517a2dcab19c447c") (:authors ("Gerry Agbobada")) (:maintainers ("Gerry Agbobada")) (:maintainer "Gerry Agbobada") (:keywords "tools" "completion" "lsp") (:url . "https://github.com/gagbo/consult-lsp"))]) (consult-notes . [(20240516 1423) ((emacs (27 1)) (consult (0 17)) (s (1 12 0)) (dash (2 19))) "Manage notes with consult" tar ((:commit . "c97420c8e91aaae214be7de897eb7eb9b7843520") (:authors ("Colin McLear" . "mclear@fastmail.com")) (:maintainers ("Colin McLear")) (:maintainer "Colin McLear") (:keywords "convenience") (:url . "https://github.com/mclear-tools/consult-notes"))]) (consult-notmuch . [(20240127 406) ((emacs (26 1)) (consult (0 9)) (notmuch (0 31))) "Notmuch search using consult" tar ((:commit . "d8022e2ddc67ed4e89cc6f5bbe664fdb04e1e815") (:authors ("Jose A Ortega Ruiz" . "jao@gnu.org")) (:maintainers ("Jose A Ortega Ruiz")) (:maintainer "Jose A Ortega Ruiz") (:keywords "mail") (:url . "https://codeberg.org/jao/consult-notmuch"))]) @@ -794,7 +795,7 @@ (consult-tex . [(20240417 1149) ((emacs (28 2)) (consult (0 35))) "Consult powered completion for tex" tar ((:commit . "675755e106f9e64e2c1fd3cf05a43275c09497da") (:authors ("Titus Pinta")) (:maintainers ("Titus Pinta" . "titus.pinta@gmail.com")) (:maintainer "Titus Pinta" . "titus.pinta@gmail.com") (:keywords "consult" "tex" "latex") (:url . "https://gitlab.com/titus.pinta/consult-TeX"))]) (consult-todo . [(20231022 2059) ((emacs (27 1)) (consult (0 35)) (hl-todo (3 1 2))) "Search hl-todo keywords in consult" tar ((:commit . "84f3c9876a285f733d75053076a97cc30f7d8eb9") (:authors ("liuyinz" . "liuyinz@gmail.com")) (:maintainers ("liuyinz" . "liuyinz@gmail.com")) (:maintainer "liuyinz" . "liuyinz@gmail.com") (:url . "https://github.com/liuyinz/consult-todo"))]) (consult-yasnippet . [(20240314 1838) ((emacs (27 1)) (yasnippet (0 14)) (consult (0 16))) "A consulting-read interface for yasnippet" tar ((:commit . "834d39acfe8a7d2c304afbe4d649b9372118c756") (:authors ("mohsin kaleem" . "mohkale@kisara.moe")) (:maintainers ("mohsin kaleem" . "mohkale@kisara.moe")) (:maintainer "mohsin kaleem" . "mohkale@kisara.moe") (:url . "https://github.com/mohkale/consult-yasnippet"))]) - (context-transient . [(20240507 1534) ((emacs (29 1))) "Context specific transients" tar ((:commit . "efd8343f46f9fb2a1ee391c0292fb35d4f91b107") (:authors ("Mykhaylo Bilyanskyy" . "mb@m1k.pw")) (:maintainers ("Mykhaylo Bilyanskyy" . "mb@m1k.pw")) (:maintainer "Mykhaylo Bilyanskyy" . "mb@m1k.pw") (:url . "https://github.com/licht1stein/context-transient.el"))]) + (context-transient . [(20240530 1344) ((emacs (29 1))) "Context specific transients" tar ((:commit . "4461c3a5b8654cb1dacea404f78951172437804f") (:authors ("Mykhaylo Bilyanskyy" . "mb@m1k.pw")) (:maintainers ("Mykhaylo Bilyanskyy" . "mb@m1k.pw")) (:maintainer "Mykhaylo Bilyanskyy" . "mb@m1k.pw") (:url . "https://github.com/licht1stein/context-transient.el"))]) (contextual . [(20180726 800) ((emacs (24)) (dash (2 12 1)) (cl-lib (0 5))) "Contextual profile management system" tar ((:commit . "7ad2bb36426fd182d4d5ee7fd9be1cc0db8c7a84") (:authors ("Alexander Kahl" . "ak@sodosopa.io")) (:maintainers ("Alexander Kahl" . "ak@sodosopa.io")) (:maintainer "Alexander Kahl" . "ak@sodosopa.io") (:keywords "convenience" "tools") (:url . "https://github.com/lshift-de/contextual"))]) (contextual-menubar . [(20180205 709) nil "display the menubar only on a graphical display" tar ((:commit . "f76f55232ac07df76ef9a334a0c527dfab97c40b") (:authors ("Aaron Jensen" . "aaronjensen@gmail.com")) (:maintainers ("Aaron Jensen" . "aaronjensen@gmail.com")) (:maintainer "Aaron Jensen" . "aaronjensen@gmail.com") (:url . "https://github.com/aaronjensen/contextual-menubar"))]) (contrast-color . [(20160903 1807) ((emacs (24 3)) (cl-lib (0 5))) "Pick best contrast color for you" tar ((:commit . "6ff1b807e09ef6a775e4ab1032bb2ea3fc442d9e") (:authors ("Yuta Yamada <cokesboy[at]gmail.com>")) (:maintainers ("Yuta Yamada <cokesboy[at]gmail.com>")) (:maintainer "Yuta Yamada <cokesboy[at]gmail.com>") (:keywords "color" "convenience") (:url . "https://github.com/yuutayamada/contrast-color-el"))]) @@ -806,7 +807,7 @@ (copyit . [(20190919 1258) ((emacs (24 3)) (s (1 9 0))) "Copy it, yank anything!" tar ((:commit . "c4f2c28e5b6270e8e3364341619f1154bb4e682e") (:authors ("USAMI Kenta" . "tadsan@zonu.me")) (:maintainers ("USAMI Kenta" . "tadsan@zonu.me")) (:maintainer "USAMI Kenta" . "tadsan@zonu.me") (:keywords "convenience" "yank" "clipboard") (:url . "https://github.com/zonuexe/emacs-copyit"))]) (copyit-pandoc . [(20190919 1258) ((emacs (24 3)) (copyit (0 1 0)) (pandoc (0 0 1))) "Copy it, yank anything!" tar ((:commit . "c4f2c28e5b6270e8e3364341619f1154bb4e682e") (:authors ("USAMI Kenta" . "tadsan@zonu.me")) (:maintainers ("USAMI Kenta" . "tadsan@zonu.me")) (:maintainer "USAMI Kenta" . "tadsan@zonu.me") (:keywords "convenience" "yank" "clipboard") (:url . "https://github.com/zonuexe/emacs-copyit"))]) (coq-commenter . [(20170822 2309) ((dash (2 13 0)) (s (1 11 0)) (cl-lib (0 5))) "Coq commenting minor mode for proof" tar ((:commit . "7fe9a2cc0ebdb0b1e54a24eb7971d757fb588ac3") (:authors ("Junyoung Clare Jang" . "jjc9310@gmail.com")) (:maintainers ("Junyoung Clare Jang" . "jjc9310@gmail.com")) (:maintainer "Junyoung Clare Jang" . "jjc9310@gmail.com") (:keywords "comment" "coq" "proof") (:url . "http://github.com/ailrun/coq-commenter"))]) - (corfu . [(20240413 927) ((emacs (27 1)) (compat (29 1 4 4))) "COmpletion in Region FUnction" tar ((:commit . "b779552341354d59365a981fd208ae07b7a2950a") (:authors ("Daniel Mendler" . "mail@daniel-mendler.de")) (:maintainers ("Daniel Mendler" . "mail@daniel-mendler.de")) (:maintainer "Daniel Mendler" . "mail@daniel-mendler.de") (:keywords "abbrev" "convenience" "matching" "completion" "text") (:url . "https://github.com/minad/corfu"))]) + (corfu . [(20240523 752) ((emacs (27 1)) (compat (29 1 4 4))) "COmpletion in Region FUnction" tar ((:commit . "cdc3e13ad312f5f12b3f78f842fff0b398eb4473") (:authors ("Daniel Mendler" . "mail@daniel-mendler.de")) (:maintainers ("Daniel Mendler" . "mail@daniel-mendler.de")) (:maintainer "Daniel Mendler" . "mail@daniel-mendler.de") (:keywords "abbrev" "convenience" "matching" "completion" "text") (:url . "https://github.com/minad/corfu"))]) (corfu-candidate-overlay . [(20240322 1814) ((emacs (28 1)) (corfu (0 36))) "Show first candidate in an overlay while typing" tar ((:commit . "f730de2c150720ee70d4d7be4b8bb533c7dfc97e") (:authors ("Adam Kruszewski" . "adam@kruszewski.name")) (:maintainers ("Adam Kruszewski" . "adam@kruszewski.name")) (:maintainer "Adam Kruszewski" . "adam@kruszewski.name") (:url . "https://code.bsdgeek.org/adam/corfu-candidate-overlay/"))]) (corfu-prescient . [(20240226 204) ((emacs (27 1)) (prescient (6 1 0)) (corfu (1 1))) "prescient.el + Corfu" tar ((:commit . "c39bf07c56b427bf41aafd7d20eaef5cf3c312b5") (:authors ("Radian LLC" . "contact+prescient@radian.codes")) (:maintainers ("Radian LLC" . "contact+prescient@radian.codes")) (:maintainer "Radian LLC" . "contact+prescient@radian.codes") (:keywords "extensions") (:url . "https://github.com/radian-software/prescient.el"))]) (corral . [(20160502 948) nil "Quickly surround text with delimiters" tar ((:commit . "e7ab6aa118e46b93d4933d1364bc273f57cd6911") (:authors ("Kevin Liu" . "mail@nivekuil.com")) (:maintainers ("Kevin Liu" . "mail@nivekuil.com")) (:maintainer "Kevin Liu" . "mail@nivekuil.com") (:url . "http://github.com/nivekuil/corral"))]) @@ -907,7 +908,7 @@ (cypher-mode . [(20151110 1142) nil "major mode for editing cypher scripts" tar ((:commit . "ce8543d7877c736c574a17b49874c9dcdc7a06d6") (:authors ("François-Xavier Bois <fxbois AT Google Mail Service>")) (:maintainers ("François-Xavier Bois")) (:maintainer "François-Xavier Bois") (:keywords "cypher" "graph") (:url . "http://github.com/fxbois/cypher-mode"))]) (cython-mode . [(20221130 1257) nil "Major mode for editing Cython files" tar ((:commit . "3e4790559d3168fe992cf2aa62f01423038cedb5"))]) (czech-holidays . [(20160113 1752) nil "Adds a list of Czech public holidays to Emacs calendar" tar ((:commit . "d19828122cf3322bcf50601cefa4ac385d2d8f82") (:authors ("David Chkhikvadze" . "david.chk@outlook.com")) (:maintainers ("David Chkhikvadze" . "david.chk@outlook.com")) (:maintainer "David Chkhikvadze" . "david.chk@outlook.com") (:keywords "calendar"))]) - (d-mode . [(20240218 1753) ((emacs (25 1))) "D Programming Language major mode for (X)Emacs" tar ((:commit . "dc583981dd2d4097ce1c9a80a958a7a1bf225ad4") (:authors ("William Baxter")) (:maintainers ("Russel Winder" . "russel@winder.org.uk")) (:maintainer "Russel Winder" . "russel@winder.org.uk") (:keywords "d" "programming" "language" "emacs" "cc-mode"))]) + (d-mode . [(20240529 611) ((emacs (25 1))) "D Programming Language major mode for (X)Emacs" tar ((:commit . "cbdabb9ca566cc12403f37f46d4102fe778e2721") (:authors ("William Baxter")) (:maintainers ("Russel Winder" . "russel@winder.org.uk")) (:maintainer "Russel Winder" . "russel@winder.org.uk") (:keywords "d" "programming" "language" "emacs" "cc-mode"))]) (d2-mode . [(20230210 1130) ((emacs (26 1))) "Major mode for working with d2 graphs" tar ((:commit . "cbe7b16141bd80fe4344f0403e61fd7ee4e0fd89") (:authors ("Andor Kesselman" . "andor@henosisknot.com")) (:maintainers ("Andor Kesselman" . "andor@henosisknot.com")) (:maintainer "Andor Kesselman" . "andor@henosisknot.com") (:keywords "d2" "graphs" "tools" "processes") (:url . "https://github.com/andorsk/d2-mode"))]) (dactyl-mode . [(20140906 1725) nil "Major mode for editing Pentadactyl config files" tar ((:commit . "cc55fe6b987271d9647492b8df4c812d884f661f") (:keywords "languages" "vim") (:url . "https://github.com/luxbock/dactyl-mode"))]) (dad-joke . [(20170928 658) ((emacs (24))) "Get/display dad jokes" tar ((:commit . "bee47e7b746b403228fa7d7361cb095de19ac9ba") (:authors ("Dave Pearson" . "davep@davep.org")) (:maintainers ("Dave Pearson" . "davep@davep.org")) (:maintainer "Dave Pearson" . "davep@davep.org") (:keywords "games") (:url . "https://github.com/davep/dad-joke.el"))]) @@ -936,7 +937,7 @@ (dash-at-point . [(20211023 104) nil "Search the word at point with Dash" tar ((:commit . "fba1a6f42ea51d05110e12c62bdced664059eb55") (:authors ("Shinji Tanaka" . "shinji.tanaka@gmail.com")) (:maintainers ("Shinji Tanaka" . "shinji.tanaka@gmail.com")) (:maintainer "Shinji Tanaka" . "shinji.tanaka@gmail.com") (:url . "https://github.com/stanaka/dash-at-point"))]) (dash-docs . [(20210830 926) ((emacs (24 4)) (cl-lib (0 5)) (async (1 9 3))) "Offline documentation browser using Dash docsets." tar ((:commit . "29848b6b347ac520f7646c200ed2ec36cea3feda") (:authors ("Raimon Grau" . "raimonster@gmail.com") ("Toni Reina " . "areina0@gmail.com") ("Bryan Gilbert" . "bryan@bryan.sh")) (:maintainers ("Raimon Grau" . "raimonster@gmail.com")) (:maintainer "Raimon Grau" . "raimonster@gmail.com") (:keywords "docs") (:url . "http://github.com/areina/helm-dash"))]) (dash-functional . [(20210826 1149) ((dash (2 18 0))) "Collection of useful combinators for Emacs Lisp" tar ((:commit . "39d067b9fbb2db65fc7a6938bfb21489ad990cb4") (:authors ("Matus Goljer" . "matus.goljer@gmail.com") ("Magnar Sveen" . "magnars@gmail.com")) (:maintainers ("Matus Goljer" . "matus.goljer@gmail.com")) (:maintainer "Matus Goljer" . "matus.goljer@gmail.com") (:keywords "extensions" "lisp") (:url . "https://github.com/magnars/dash.el"))]) - (dashboard . [(20240407 12) ((emacs (26 1))) "A startup screen extracted from Spacemacs" tar ((:commit . "89b42bff4d60fb00ef3d679e2d2289541e5009f6") (:authors ("Rakan Al-Hneiti" . "rakan.alhneiti@gmail.com")) (:maintainers ("Jesús Martínez" . "jesusmartinez93@gmail.com")) (:maintainer "Jesús Martínez" . "jesusmartinez93@gmail.com") (:keywords "startup" "screen" "tools" "dashboard") (:url . "https://github.com/emacs-dashboard/emacs-dashboard"))]) + (dashboard . [(20240529 2058) ((emacs (26 1))) "A startup screen extracted from Spacemacs" tar ((:commit . "3852301f9c6f3104d9cc98389612b5ef3452a7de") (:authors ("Rakan Al-Hneiti" . "rakan.alhneiti@gmail.com")) (:maintainers ("Jesús Martínez" . "jesusmartinez93@gmail.com")) (:maintainer "Jesús Martínez" . "jesusmartinez93@gmail.com") (:keywords "startup" "screen" "tools" "dashboard") (:url . "https://github.com/emacs-dashboard/emacs-dashboard"))]) (dashboard-hackernews . [(20220516 1809) ((emacs (24)) (dashboard (1 2 5)) (request (0 3 0))) "Display Hacker News on dashboard" tar ((:commit . "34d86bffcde7e6d10ffa7c5080a71a144f01f3aa") (:authors ("Hayato KAJIYAMA" . "kaji1216@gmail.com")) (:maintainers ("Hayato KAJIYAMA" . "kaji1216@gmail.com")) (:maintainer "Hayato KAJIYAMA" . "kaji1216@gmail.com") (:url . "https://github.com/hyakt/emacs-dashboard-hackernews"))]) (dashboard-ls . [(20240101 841) ((emacs (26 1)) (dashboard (1 2 5))) "Display files/directories in current directory on Dashboard" tar ((:commit . "bc79640e8fcc625ff1af31d5e17b054b1f535f39") (:authors ("Shen, Jen-Chieh" . "jcs090218@gmail.com")) (:maintainers ("Shen, Jen-Chieh" . "jcs090218@gmail.com")) (:maintainer "Shen, Jen-Chieh" . "jcs090218@gmail.com") (:keywords "convenience" "directory" "file" "show") (:url . "https://github.com/emacs-dashboard/dashboard-ls"))]) (dashboard-project-status . [(20190202 1354) ((emacs (24)) (git (0 1 1)) (dashboard (1 2 5))) "Display a git project status in a dashboard widget." tar ((:commit . "7675c138e9df8fe2c626e7ba9bbb8b6717671a41") (:authors ("Jason Duncan" . "jasond496@msn.com")) (:maintainers ("Jason Duncan" . "jasond496@msn.com")) (:maintainer "Jason Duncan" . "jasond496@msn.com") (:url . "https://github.com/functionreturnfunction/dashboard-project-status"))]) @@ -972,14 +973,14 @@ (define-word . [(20220104 1848) ((emacs (24 3))) "display the definition of word at point." tar ((:commit . "31a8c67405afa99d0e25e7c86a4ee7ef84a808fe") (:authors ("Oleh Krehel" . "ohwoeowho@gmail.com")) (:maintainers ("Oleh Krehel" . "ohwoeowho@gmail.com")) (:maintainer "Oleh Krehel" . "ohwoeowho@gmail.com") (:keywords "dictionary" "convenience") (:url . "https://github.com/abo-abo/define-word"))]) (defproject . [(20151201 2219) ((emacs (24))) "Manager dir-locals and project specific variables" tar ((:commit . "674d48a5e34cb4bba76faa38ee901322ec649086") (:authors (nil . "<kotfic@gmail.com>")) (:maintainers (nil . "<kotfic@gmail.com>")) (:maintainer nil . "<kotfic@gmail.com>") (:keywords "convenience") (:url . "https://github.com/kotfic/defproject"))]) (defrepeater . [(20180830 410) ((emacs (25 2)) (s (1 12 0))) "Easily make commands repeatable" tar ((:commit . "62b00ede57d2e115b9ef9f21268c021ae1186873") (:authors ("Adam Porter" . "adam@alphapapa.net")) (:maintainers ("Adam Porter" . "adam@alphapapa.net")) (:maintainer "Adam Porter" . "adam@alphapapa.net") (:keywords "convenience") (:url . "http://github.com/alphapapa/defrepeater.el"))]) - (deft . [(20240407 149) nil "quickly browse, filter, and edit plain text notes" tar ((:commit . "7f352747a2c4dfe40ba060ab42f47ae8a9ddab41") (:authors ("Jason R. Blevins" . "jrblevin@xbeta.org")) (:maintainers ("Jason R. Blevins" . "jrblevin@xbeta.org")) (:maintainer "Jason R. Blevins" . "jrblevin@xbeta.org") (:keywords "plain text" "notes" "simplenote" "notational velocity") (:url . "https://jblevins.org/projects/deft/"))]) + (deft . [(20240524 1524) nil "quickly browse, filter, and edit plain text notes" tar ((:commit . "b369d7225d86551882568788a23c5497b232509c") (:authors ("Jason R. Blevins" . "jrblevin@xbeta.org")) (:maintainers ("Jason R. Blevins" . "jrblevin@xbeta.org")) (:maintainer "Jason R. Blevins" . "jrblevin@xbeta.org") (:keywords "plain text" "notes" "simplenote" "notational velocity") (:url . "https://jblevins.org/projects/deft/"))]) (delim-kill . [(20100517 620) nil "Kill text between delimiters." tar ((:commit . "1dbe47344f2d2cbc8c54beedf0cf0bf10fd203c1") (:authors ("Thomas Kappler" . "tkappler@gmail.com")) (:maintainers ("Thomas Kappler" . "tkappler@gmail.com")) (:maintainer "Thomas Kappler" . "tkappler@gmail.com") (:keywords "convenience" "languages") (:url . "http://github.com/thomas11/delim-kill/tree/master"))]) (demangle-mode . [(20210822 2210) ((cl-lib (0 1)) (emacs (24 3))) "Automatically demangle C++, D, and Rust symbols" tar ((:commit . "04f545adab066708d6151f13da65aaf519f8ac4e") (:authors ("Ben Liblit" . "liblit@acm.org")) (:maintainers ("Ben Liblit" . "liblit@acm.org")) (:maintainer "Ben Liblit" . "liblit@acm.org") (:keywords "c" "tools") (:url . "https://github.com/liblit/demangle-mode"))]) (demap . [(20220322 2309) ((emacs (25 1))) "Detachable minimap package" tar ((:commit . "c42ec4752544f80ca7c172ff65e705a56089bc96") (:authors ("Sawyer Gardner <https://gitlab.com/sawyerjgardner>")) (:maintainers ("Sawyer Gardner <https://gitlab.com/sawyerjgardner>")) (:maintainer "Sawyer Gardner <https://gitlab.com/sawyerjgardner>") (:keywords "lisp" "tools" "convenience") (:url . "https://gitlab.com/sawyerjgardner/demap.el"))]) (demo-it . [(20211221 2152) nil "Create demonstrations" tar ((:commit . "8ade739bb2605275f1f56128a0a9a8c6b55bab6a") (:authors ("Howard Abrams" . "howard.abrams@gmail.com")) (:maintainers ("Howard Abrams" . "howard.abrams@gmail.com")) (:maintainer "Howard Abrams" . "howard.abrams@gmail.com") (:keywords "demonstration" "presentation" "test"))]) (deno-fmt . [(20230117 1117) ((emacs (24))) "Minor mode for using deno fmt on save" tar ((:commit . "6378966f448a3b9b5ae98af58cd13a031bd26702") (:authors ("Russell Clarey <http://github/rclarey>")) (:maintainers ("Russell Clarey <http://github/rclarey>")) (:maintainer "Russell Clarey <http://github/rclarey>") (:url . "https://github.com/russell/deno-emacs"))]) (deno-ts-mode . [(20230912 202) ((emacs (29 1))) "Major mode for Deno" tar ((:commit . "526b6c00483cd86a028805e31ebd8a4a7000c3da") (:authors ("Graham Marlow" . "info@mgmarlow.com")) (:maintainers ("Graham Marlow" . "info@mgmarlow.com")) (:maintainer "Graham Marlow" . "info@mgmarlow.com") (:keywords "languages") (:url . "https://git.sr.ht/~mgmarlow/deno-ts-mode"))]) - (denote-explore . [(20240512 113) ((emacs (29 1)) (denote (2 3 5)) (dash (2 19 1))) "Explore Denote files" tar ((:commit . "7073ef97758fbcf953557efa15da9226283ff6b0") (:authors ("Peter Prevos" . "peter@prevos.net")) (:maintainers ("Peter Prevos" . "peter@prevos.net")) (:maintainer "Peter Prevos" . "peter@prevos.net") (:url . "https://github.com/pprevos/denote-explore/"))]) + (denote-explore . [(20240602 345) ((emacs (29 1)) (denote (2 3 5)) (dash (2 19 1))) "Explore Denote files" tar ((:commit . "1680f81d816300c5821dac0b4d197e6a4368a876") (:authors ("Peter Prevos" . "peter@prevos.net")) (:maintainers ("Peter Prevos" . "peter@prevos.net")) (:maintainer "Peter Prevos" . "peter@prevos.net") (:url . "https://github.com/pprevos/denote-explore/"))]) (derl . [(20231004 821) ((emacs (29 1))) "Erlang distribution protocol implementation" tar ((:commit . "6f31592bb3083de366cdb13a7db0ed69fc72de47") (:authors ("Axel Forsman" . "axel@axelf.se")) (:maintainers ("Axel Forsman" . "axel@axelf.se")) (:maintainer "Axel Forsman" . "axel@axelf.se") (:keywords "comm" "extensions" "languages" "processes") (:url . "https://github.com/axelf4/derl.el"))]) (describe-hash . [(20200718 1556) nil "Help function for examining a hash map" tar ((:commit . "20dbbbea630055b2401f13a55fbb21216960dc46") (:url . "https://github.com/Junker/describe-hash"))]) (describe-number . [(20151101 55) ((yabin (1 1))) "Describe arbitrarily large number at point." tar ((:commit . "40618345a37831804b29589849a785ef5aa5ac24") (:authors ("Morten Slot Kristensen <msk AT nullpointer DOT dk>")) (:maintainers ("Morten Slot Kristensen <msk AT nullpointer DOT dk>")) (:maintainer "Morten Slot Kristensen <msk AT nullpointer DOT dk>") (:keywords "describe" "value" "help") (:url . "https://github.com/netromdk/describe-number"))]) @@ -1007,7 +1008,7 @@ (difflib . [(20210224 2242) ((emacs (24 4)) (cl-generic (0 3)) (ht (2 2)) (s (1 12 0))) "Helpers for computing deltas between sequences." tar ((:commit . "646fc4388274fe765bbf4661e17a24e4d081250c") (:authors ("Diego A. Mundo" . "dieggsy@pm.me")) (:maintainers ("Diego A. Mundo" . "dieggsy@pm.me")) (:maintainer "Diego A. Mundo" . "dieggsy@pm.me") (:keywords "matching" "tools" "string") (:url . "http://github.com/dieggsy/difflib.el"))]) (diffpdf . [(20210626 1447) ((emacs (25 1)) (transient (0 3 0))) "Transient diffpdf" tar ((:commit . "a5b203b549e373cb9b0ef3f00c0010bd34dd644a") (:authors ("Shuguang Sun" . "shuguang79@qq.com")) (:maintainers ("Shuguang Sun" . "shuguang79@qq.com")) (:maintainer "Shuguang Sun" . "shuguang79@qq.com") (:keywords "tools") (:url . "https://github.com/ShuguangSun/diffpdf.el"))]) (diffscuss-mode . [(20141014 2357) nil "Major mode for diffscuss files." tar ((:commit . "bbc6dbed4b97d1eb9ae5dae021ed1e066129bd98") (:authors ("Edmund Jorgensen" . "edmund@hut8labs.com")) (:maintainers ("Edmund Jorgensen" . "edmund@hut8labs.com")) (:maintainer "Edmund Jorgensen" . "edmund@hut8labs.com") (:keywords "tools"))]) - (difftastic . [(20240429 2057) ((emacs (28 1)) (compat (29 1 4 2)) (magit (20220326))) "Wrapper for difftastic" tar ((:commit . "90b9b223bfc39786f6fcf266cdc1cb982bdc37aa") (:authors ("Przemyslaw Kryger" . "pkryger@gmail.com")) (:maintainers ("Przemyslaw Kryger" . "pkryger@gmail.com")) (:maintainer "Przemyslaw Kryger" . "pkryger@gmail.com") (:keywords "tools" "diff") (:url . "https://github.com/pkryger/difftastic.el"))]) + (difftastic . [(20240528 1657) ((emacs (28 1)) (compat (29 1 4 2)) (magit (20220326))) "Wrapper for difftastic" tar ((:commit . "79753bfec7c32f44dc0d5ed57a8bc6b370392a87") (:authors ("Przemyslaw Kryger" . "pkryger@gmail.com")) (:maintainers ("Przemyslaw Kryger" . "pkryger@gmail.com")) (:maintainer "Przemyslaw Kryger" . "pkryger@gmail.com") (:keywords "tools" "diff") (:url . "https://github.com/pkryger/difftastic.el"))]) (diffview . [(20230224 1916) nil "View diffs in side-by-side format" tar ((:commit . "8f07c0ff4a1acef990589df0d3e32288f19c9d71") (:authors ("Mitchel Humpherys" . "mitch.special@gmail.com")) (:maintainers ("Mitchel Humpherys" . "mitch.special@gmail.com")) (:maintainer "Mitchel Humpherys" . "mitch.special@gmail.com") (:keywords "convenience" "diff") (:url . "https://github.com/mgalgs/diffview-mode"))]) (digistar-mode . [(20240515 1529) nil "major mode for Digistar scripts" tar ((:commit . "546adaccb1f90d6947c2c80c2fab4933f40bc274") (:authors ("John Foerch" . "jjfoerch@gmail.com")) (:maintainers ("John Foerch" . "jjfoerch@gmail.com")) (:maintainer "John Foerch" . "jjfoerch@gmail.com") (:keywords "languages"))]) (digit-groups . [(20200506 37) ((dash (2 11 0))) "Highlight place-value positions in numbers" tar ((:commit . "7b81930cad19b8b7913b7eedbcb498964bfdcbdb") (:authors ("Michael D. Adams <http://michaeldadams.org>")) (:maintainers ("Michael D. Adams <http://michaeldadams.org>")) (:maintainer "Michael D. Adams <http://michaeldadams.org>") (:url . "https://github.com/adamsmd/digit-groups/"))]) @@ -1049,6 +1050,7 @@ (dired-lsi . [(20200812 929) ((emacs (26 1))) "Add memo to directory and show it in dired" tar ((:commit . "0f4038c8b47f6cfc70f82062800700c14c9912c2") (:authors ("Naoya Yamashita" . "conao3@gmail.com")) (:maintainers ("Naoya Yamashita" . "conao3@gmail.com")) (:maintainer "Naoya Yamashita" . "conao3@gmail.com") (:keywords "convenience") (:url . "https://github.com/conao3/dired-lsi.el"))]) (dired-narrow . [(20230512 1107) ((dash (2 7 0)) (dired-hacks-utils (0 0 1))) "Live-narrowing of search results for dired" tar ((:commit . "523f51b4152a3bf4e60fe57f512732c698b5c96f") (:authors ("Matúš Goljer" . "matus.goljer@gmail.com")) (:maintainers ("Matúš Goljer" . "matus.goljer@gmail.com")) (:maintainer "Matúš Goljer" . "matus.goljer@gmail.com") (:keywords "files"))]) (dired-open . [(20240330 1831) ((dash (2 5 0)) (dired-hacks-utils (0 0 1))) "Open files from dired using using custom actions" tar ((:commit . "a01c126c3b1068655509487c76971895f5459d09") (:authors ("Matúš Goljer" . "matus.goljer@gmail.com")) (:maintainers ("Matúš Goljer" . "matus.goljer@gmail.com")) (:maintainer "Matúš Goljer" . "matus.goljer@gmail.com") (:keywords "files"))]) + (dired-open-with . [(20240527 1855) ((emacs (27 1)) (s (1 13 0))) "And \"Open with\" dialog for Dired" tar ((:commit . "e75bc673d11ecc1385e53c378c8f31d85d157113") (:authors ("Jakub Kadlčík" . "frostyx@email.cz")) (:maintainers ("Jakub Kadlčík" . "frostyx@email.cz")) (:maintainer "Jakub Kadlčík" . "frostyx@email.cz") (:keywords "files" "dired" "xdg" "open-with") (:url . "https://github.com/FrostyX/dired-open-with"))]) (dired-posframe . [(20200817 420) ((emacs (26 1)) (posframe (0 7))) "Peep dired items using posframe" tar ((:commit . "1a21eb9ad956a0371dd3c9e1bec53407d685f705") (:authors ("Naoya Yamashita" . "conao3@gmail.com")) (:maintainers ("Naoya Yamashita" . "conao3@gmail.com")) (:maintainer "Naoya Yamashita" . "conao3@gmail.com") (:keywords "convenience") (:url . "https://github.com/conao3/dired-posframe.el"))]) (dired-quick-sort . [(20240411 229) ((hydra (0 13 0)) (emacs (24))) "Persistent quick sorting of dired buffers in various ways." tar ((:commit . "d50b910baa716dfcf4830f1c08226c92bcaee7f6") (:authors ("Hong Xu" . "hong@topbug.net")) (:maintainers ("Hong Xu" . "hong@topbug.net")) (:maintainer "Hong Xu" . "hong@topbug.net") (:keywords "convenience" "files") (:url . "https://gitlab.com/xuhdev/dired-quick-sort#dired-quick-sort"))]) (dired-rainbow . [(20221127 1247) ((dash (2 5 0)) (dired-hacks-utils (0 0 1))) "Extended file highlighting according to its type" tar ((:commit . "41d3eb42195d9f0894c20d18cc8e722b099aa1c1") (:authors ("Matus Goljer" . "matus.goljer@gmail.com")) (:maintainers ("Matus Goljer" . "matus.goljer@gmail.com")) (:maintainer "Matus Goljer" . "matus.goljer@gmail.com") (:keywords "files"))]) @@ -1058,7 +1060,7 @@ (dired-rmjunk . [(20191007 1232) nil "A home directory cleanup utility for Dired." tar ((:commit . "0e890a41fa680a45b4b4aad2c28f9d6dca999cee") (:authors ("Jakob L. Kreuze" . "zerodaysfordays@sdf.lonestar.org")) (:maintainers ("Jakob L. Kreuze" . "zerodaysfordays@sdf.lonestar.org")) (:maintainer "Jakob L. Kreuze" . "zerodaysfordays@sdf.lonestar.org") (:keywords "files" "matching") (:url . "https://git.sr.ht/~jakob/dired-rmjunk"))]) (dired-rsync . [(20230822 1350) ((s (1 12 0)) (dash (2 0 0)) (emacs (25 1))) "Allow rsync from dired buffers" tar ((:commit . "5bcb851f3bf9c4f7c07299fcc25be7c408a68cda") (:authors ("Alex Bennée" . "alex@bennee.com")) (:maintainers ("Alex Bennée" . "alex@bennee.com")) (:maintainer "Alex Bennée" . "alex@bennee.com") (:url . "https://github.com/stsquad/dired-rsync"))]) (dired-rsync-transient . [(20230714 1459) ((dired-rsync (0 6)) (transient (0 3 0)) (emacs (24 4))) "Transient command for dired-rsync" tar ((:commit . "95607fc7eb84e792122b52d2b1d62f49199a2a37") (:authors ("Alex Bennée" . "alex@bennee.com")) (:maintainers ("Alex Bennée" . "alex@bennee.com")) (:maintainer "Alex Bennée" . "alex@bennee.com") (:url . "https://github.com/stsquad/dired-rsync"))]) - (dired-sidebar . [(20240320 1952) ((emacs (25 1)) (dired-subtree (0 0 1))) "Tree browser leveraging dired" tar ((:commit . "573658021fd6e6cf032d789de29aca4e5dd258fd") (:authors ("James Nguyen" . "james@jojojames.com")) (:maintainers ("James Nguyen" . "james@jojojames.com")) (:maintainer "James Nguyen" . "james@jojojames.com") (:keywords "dired" "files" "tools") (:url . "https://github.com/jojojames/dired-sidebar"))]) + (dired-sidebar . [(20240522 2316) ((emacs (25 1)) (dired-subtree (0 0 1))) "Tree browser leveraging dired" tar ((:commit . "702165ad53a473992d84e0207b984b9be5114bde") (:authors ("James Nguyen" . "james@jojojames.com")) (:maintainers ("James Nguyen" . "james@jojojames.com")) (:maintainer "James Nguyen" . "james@jojojames.com") (:keywords "dired" "files" "tools") (:url . "https://github.com/jojojames/dired-sidebar"))]) (dired-single . [(20240131 1148) ((emacs (25 1))) "Reuse the current dired buffer" tar ((:commit . "60fce6599326e12cc2033c28d50b8bf6c6ba164a") (:url . "https://codeberg.org/amano.kenji/dired-single"))]) (dired-subtree . [(20230512 1107) ((dash (2 5 0)) (dired-hacks-utils (0 0 1))) "Insert subdirectories in a tree-like fashion" tar ((:commit . "523f51b4152a3bf4e60fe57f512732c698b5c96f") (:authors ("Matúš Goljer" . "matus.goljer@gmail.com")) (:maintainers ("Matúš Goljer" . "matus.goljer@gmail.com")) (:maintainer "Matúš Goljer" . "matus.goljer@gmail.com") (:keywords "files"))]) (dired-toggle . [(20190616 303) nil "Show dired as sidebar and will not create new buffers when changing dir" tar ((:commit . "b694ba91a45d0762bd032ff1bb4109e4c62ca686") (:authors ("Xu FaSheng <fasheng[AT]fasheng.info>")) (:maintainers ("Xu FaSheng")) (:maintainer "Xu FaSheng") (:keywords "dired" "sidebar") (:url . "https://github.com/fasheng/dired-toggle"))]) @@ -1126,7 +1128,7 @@ (dollaro . [(20151123 1302) ((s (1 6 0))) "simple text templates" tar ((:commit . "500127f0172ac7a1eec627e026b59136580a74ac") (:authors ("Alessandro Piras" . "laynor@gmail.com")) (:maintainers ("Alessandro Piras" . "laynor@gmail.com")) (:maintainer "Alessandro Piras" . "laynor@gmail.com") (:keywords "tools" "convenience"))]) (doom . [(20180301 2308) ((cl-lib (0 5))) "DOM implementation and manipulation library" tar ((:commit . "e59040aefc92dd9b3134eb623624307fb9e4327b") (:authors ("Alex Schroeder" . "alex@gnu.org") ("Henrik.Motakef" . "elisp@henrik-motakef.de") ("Katherine Whitlock" . "toroidal-code@gmail.com") ("Syohei YOSHIDA" . "syohex@gmail.com")) (:maintainers ("Alex Schroeder")) (:maintainer "Alex Schroeder") (:keywords "xml" "dom") (:url . "http://www.github.com/kensanata/doom.el/"))]) (doom-modeline . [(20240510 144) ((emacs (25 1)) (compat (29 1 4 5)) (nerd-icons (0 1 0)) (shrink-path (0 3 1))) "A minimal and modern mode-line" tar ((:commit . "65d0bd83eb7c393092e032c24b882f3ba19b4899") (:authors ("Vincent Zhang" . "seagle0128@gmail.com")) (:maintainers ("Vincent Zhang" . "seagle0128@gmail.com")) (:maintainer "Vincent Zhang" . "seagle0128@gmail.com") (:keywords "faces" "mode-line") (:url . "https://github.com/seagle0128/doom-modeline"))]) - (doom-modeline-now-playing . [(20210831 1442) ((emacs (24 4)) (doom-modeline (3 0 0)) (async (1 9 3))) "Segment for Doom Modeline to show playerctl information" tar ((:commit . "ef9158dfdf32e8eb789b69e7394d0bddaa68f42c") (:authors ("Ellis Kenyő" . "me@elken.dev")) (:maintainers ("Ellis Kenyő" . "me@elken.dev")) (:maintainer "Ellis Kenyő" . "me@elken.dev") (:url . "https://github.com/elken/doom-modeline-now-playing"))]) + (doom-modeline-now-playing . [(20240522 1704) ((emacs (24 4)) (doom-modeline (3 0 0)) (async (1 9 3))) "Segment for Doom Modeline to show playerctl information" tar ((:commit . "1532f324f98a234aa14e12ebdfd17cebba978d6a") (:authors ("Ellis Kenyő" . "me@elken.dev")) (:maintainers ("Ellis Kenyő" . "me@elken.dev")) (:maintainer "Ellis Kenyő" . "me@elken.dev") (:url . "https://github.com/elken/doom-modeline-now-playing"))]) (doom-themes . [(20240404 2042) ((emacs (25 1)) (cl-lib (0 5))) "an opinionated pack of modern color-themes" tar ((:commit . "3b2422b208d28e8734b300cd3cc6a7f4af5eba55") (:authors ("Henrik Lissner" . "contact@henrik.io")) (:maintainers ("Henrik Lissner" . "contact@henrik.io")) (:maintainer "Henrik Lissner" . "contact@henrik.io") (:keywords "themes" "faces") (:url . "https://github.com/doomemacs/themes"))]) (dot-env . [(20230820 2014) ((emacs (24 4)) (s (1 13 0))) "Dotenv functionality" tar ((:commit . "83ce690e8ef9175fc621c85d5fbef4f7ace7b7a8") (:authors ("Amo DelBello")) (:maintainers ("Amo DelBello")) (:maintainer "Amo DelBello") (:keywords "convenience" "dotenv" "environment" "configuration") (:url . "https://github.com/amodelbello/dot-env.el"))]) (dot-mode . [(20180312 2300) ((emacs (24 3))) "minor mode to repeat typing or commands" tar ((:commit . "6ca22b73bcdae2363ee9641b822a60685df16a3e") (:authors ("Robert Wyrick" . "rob@wyrick.org")) (:maintainers ("Robert Wyrick" . "rob@wyrick.org")) (:maintainer "Robert Wyrick" . "rob@wyrick.org") (:keywords "convenience") (:url . "https://github.com/wyrickre/dot-mode"))]) @@ -1168,7 +1170,7 @@ (dut-mode . [(20170729 2111) ((emacs (24))) "Major mode for the Dut programming language" tar ((:commit . "9235c7acaa6690942e9de8b7acd1e4be0c859dc1") (:authors ("The dut-mode Authors")) (:maintainers ("The dut-mode Authors")) (:maintainer "The dut-mode Authors") (:keywords "languages" "gut") (:url . "https://github.com/dut-lang/dut-mode"))]) (dw . [(20210331 2311) ((emacs (25 1))) "Diceware passphrase generation commands" tar ((:commit . "61c5718ba64ace4c9e29de18aa2690ecc3f0f258") (:authors ("D. Williams" . "d.williams@posteo.net")) (:maintainers ("D. Williams" . "d.williams@posteo.net")) (:maintainer "D. Williams" . "d.williams@posteo.net") (:keywords "convenience" "games") (:url . "https://github.com/integral-dw/dw-passphrase-generator"))]) (dwim-coder-mode . [(20230830 1215) ((emacs (29))) "DWIM keybindings for C, Python, Rust, and more" tar ((:commit . "94a752fca078144dd309343880abafbc4eacca5f") (:authors ("Mohammed Sadiq" . "sadiq@sadiqpk.org")) (:maintainers ("Mohammed Sadiq" . "sadiq@sadiqpk.org")) (:maintainer "Mohammed Sadiq" . "sadiq@sadiqpk.org") (:keywords "convenience" "hacks") (:url . "https://sadiqpk.org/projects/dwim-coder-mode.html"))]) - (dwim-shell-command . [(20240520 1732) ((emacs (28 1))) "Shell commands with DWIM behaviour" tar ((:commit . "c20a474ba8fc0ad73a1b30aeb99502cbfc709c0b") (:authors ("Alvaro Ramirez")) (:maintainers ("Alvaro Ramirez")) (:maintainer "Alvaro Ramirez") (:url . "https://github.com/xenodium/dwim-shell-command"))]) + (dwim-shell-command . [(20240526 2142) ((emacs (28 1))) "Shell commands with DWIM behaviour" tar ((:commit . "a1f34ba0f9ccb76673f6551f0c5e06a24ca9aa2a") (:authors ("Alvaro Ramirez")) (:maintainers ("Alvaro Ramirez")) (:maintainer "Alvaro Ramirez") (:url . "https://github.com/xenodium/dwim-shell-command"))]) (dyalog-mode . [(20230214 1027) ((cl-lib (0 2)) (emacs (24 3))) "Major mode for editing Dyalog APL source code" tar ((:commit . "13c0d391aa878a1609259a89fe3e6db8d21935e8") (:authors ("Joakim Hårsman" . "joakim.harsman@gmail.com")) (:maintainers ("Joakim Hårsman" . "joakim.harsman@gmail.com")) (:maintainer "Joakim Hårsman" . "joakim.harsman@gmail.com") (:keywords "languages") (:url . "https://github.com/harsman/dyalog-mode.git"))]) (dylan . [(20220115 1804) ((emacs (25 1))) "Dylan editing modes" tar ((:commit . "9d2891e3e06405b75072d296f385fa795aeb9835") (:url . "https://opendylan.org/"))]) (dynamic-fonts . [(20140731 1226) ((font-utils (0 7 0)) (persistent-soft (0 8 8)) (pcache (0 2 3))) "Set faces based on available fonts" tar ((:commit . "004ee6014dc7dbff8f14d26015c91d9229f6eac0") (:authors ("Roland Walker" . "walker@pobox.com")) (:maintainers ("Roland Walker" . "walker@pobox.com")) (:maintainer "Roland Walker" . "walker@pobox.com") (:keywords "faces" "frames") (:url . "http://github.com/rolandwalker/dynamic-fonts"))]) @@ -1205,7 +1207,7 @@ (ebnf-mode . [(20231022 1759) ((emacs (25 1))) "Major mode for EBNF files" tar ((:commit . "61486b1c9d4746249640410e58087e318f801ed8") (:authors ("Noah Peart" . "noah.v.peart@gmail.com")) (:maintainers ("Noah Peart" . "noah.v.peart@gmail.com")) (:maintainer "Noah Peart" . "noah.v.peart@gmail.com") (:url . "https://github.com/nverno/ebnf-mode"))]) (ebuku . [(20231113 748) ((emacs (25 1))) "Interface to the buku Web bookmark manager" tar ((:commit . "c854d128cba8576fe9693c19109b5deafb573e99") (:authors ("Alexis <flexibeast@gmail.com>, Erik Sjöstrand <sjostrand.erik@gmail.com>, Junji Zhi [https://github.com/junjizhi], Hilton Chain" . "hako@ultrarare.space")) (:maintainers ("Alexis" . "flexibeast@gmail.com")) (:maintainer "Alexis" . "flexibeast@gmail.com") (:keywords "bookmarks" "buku" "data" "web" "www") (:url . "https://github.com/flexibeast/ebuku"))]) (ecb . [(20170728 1921) nil "a code browser for Emacs" tar ((:commit . "1330a44cf3c171781083b0b926ab7622f64e6e81") (:authors ("Jesper Nordenberg" . "mayhem@home.se") ("Klaus Berndl" . "klaus.berndl@sdm.de") ("Kevin A. Burton" . "burton@openprivacy.org")) (:maintainers ("Klaus Berndl" . "klaus.berndl@sdm.de")) (:maintainer "Klaus Berndl" . "klaus.berndl@sdm.de") (:keywords "browser" "code" "programming" "tools"))]) - (echo-bar . [(20240521 326) nil "Turn the echo area into a custom status bar" tar ((:commit . "0e221754cb40406609ae5c79ac294683850638e1") (:authors ("Adam Tillou" . "qaiviq@gmail.com")) (:maintainers ("Adam Tillou" . "qaiviq@gmail.com")) (:maintainer "Adam Tillou" . "qaiviq@gmail.com") (:keywords "convenience" "tools") (:url . "https://github.com/qaiviq/echo-bar.el"))]) + (echo-bar . [(20240601 1744) nil "Turn the echo area into a custom status bar" tar ((:commit . "80f5a8bbd8ac848d4a69796c9568b4a55958e974") (:authors ("Adam Tillou" . "qaiviq@gmail.com")) (:maintainers ("Adam Tillou" . "qaiviq@gmail.com")) (:maintainer "Adam Tillou" . "qaiviq@gmail.com") (:keywords "convenience" "tools") (:url . "https://github.com/qaiviq/echo-bar.el"))]) (eclim . [(20181108 1134) ((dash (2 11 0)) (json (1 2)) (popup (0 5 2)) (s (1 9 0)) (cl-lib (0 5)) (yasnippet (0 10 0))) "An interface to the Eclipse IDE." tar ((:commit . "23f5b294f833ce58516d7b9ae08a7792d70022a1"))]) (eclipse-theme . [(20191113 1518) nil "Theme based on Eclipse circa 2010" tar ((:commit . "dcf97865512ed450f9d5137c1a05e12edb5b7f80") (:authors ("Oleh Krehel" . "ohwoeowho@gmail.com")) (:maintainers ("Oleh Krehel" . "ohwoeowho@gmail.com")) (:maintainer "Oleh Krehel" . "ohwoeowho@gmail.com") (:keywords "themes") (:url . "https://github.com/abo-abo/eclipse-theme"))]) (ecukes . [(20240315 2350) ((emacs (25)) (commander (0 6 1)) (espuds (0 2 2)) (ansi (0 3 0)) (dash (2 2 0)) (s (1 8 0)) (f (0 11 0))) "Cucumber for Emacs" tar ((:commit . "11225972934b3cfe09ada87dd785f8dd0082b6e3"))]) @@ -1225,7 +1227,7 @@ (edit-list . [(20100930 1443) nil "edit a single list" tar ((:commit . "f460d3f9e208a4e606fe6ded307f1b011916ca71") (:authors ("Michael Olson" . "mwolson@gnu.org")) (:maintainers ("Michael Olson" . "mwolson@gnu.org")) (:maintainer "Michael Olson" . "mwolson@gnu.org") (:url . "http://mwolson.org/static/dist/elisp/edit-list.el"))]) (edit-server . [(20220908 1014) nil "server that responds to edit requests from Chrome" tar ((:commit . "3ce09c6eb2919d56ef052b1584bba6abb12f7e99") (:authors ("Alex Bennée" . "alex@bennee.com")) (:maintainers ("Alex Bennée" . "alex@bennee.com")) (:maintainer "Alex Bennée" . "alex@bennee.com") (:url . "https://github.com/stsquad/emacs_chrome"))]) (edit-server-htmlize . [(20130329 2248) ((edit-server (1 9))) "(de)HTMLization hooks for edit-server.el" tar ((:commit . "e7f8dadfabe869c77ca241cd6fbd4c52bd908392") (:authors ("Roland McGrath" . "roland@hack.frob.com")) (:maintainers ("Roland McGrath" . "roland@hack.frob.com")) (:maintainer "Roland McGrath" . "roland@hack.frob.com") (:url . "https://github.com/frobtech/edit-server-htmlize"))]) - (editorconfig . [(20240512 1958) ((emacs (26 1)) (nadvice (0 3))) "EditorConfig Emacs Plugin" tar ((:commit . "6ac848e380322bb52d6f70a032e12f70d60daab1") (:authors ("EditorConfig Team" . "editorconfig@googlegroups.com")) (:maintainers ("EditorConfig Team" . "editorconfig@googlegroups.com")) (:maintainer "EditorConfig Team" . "editorconfig@googlegroups.com") (:keywords "convenience" "editorconfig") (:url . "https://github.com/editorconfig/editorconfig-emacs#readme"))]) + (editorconfig . [(20240531 1319) ((emacs (26 1)) (nadvice (0 3))) "EditorConfig Emacs Plugin" tar ((:commit . "150f8d711203b91a7ddac3ed79a65289b0f87364") (:authors ("EditorConfig Team" . "editorconfig@googlegroups.com")) (:maintainers ("EditorConfig Team" . "editorconfig@googlegroups.com")) (:maintainer "EditorConfig Team" . "editorconfig@googlegroups.com") (:keywords "convenience" "editorconfig") (:url . "https://github.com/editorconfig/editorconfig-emacs#readme"))]) (editorconfig-charset-extras . [(20180223 457) ((editorconfig (0 6 0))) "Extra EditorConfig Charset Support" tar ((:commit . "ddf60923c6f4841cb593b2ea04c9c710a01d262f") (:authors ("10sr" . "8.slashes@gmail.com")) (:maintainers ("10sr" . "8.slashes@gmail.com")) (:maintainer "10sr" . "8.slashes@gmail.com") (:keywords "tools") (:url . "https://github.com/10sr/editorconfig-charset-extras-el"))]) (editorconfig-custom-majormode . [(20180816 244) ((editorconfig (0 6 0))) "Decide major-mode and mmm-mode from EditorConfig" tar ((:commit . "13ad1c83f847bedd4b3a19f9df7fd925853b19de") (:authors ("10sr <8slashes+el [at] gmail [dot] com>")) (:maintainers ("10sr <8slashes+el [at] gmail [dot] com>")) (:maintainer "10sr <8slashes+el [at] gmail [dot] com>") (:keywords "editorconfig" "util") (:url . "https://github.com/10sr/editorconfig-custom-majormode-el"))]) (editorconfig-domain-specific . [(20180505 924) ((cl-lib (0 5)) (editorconfig (0 6 0))) "Apply brace style and other \"domain-specific\" EditorConfig properties" tar ((:commit . "e9824160fb2e466afa755240ee3ab7cc5657fb04") (:authors ("Lassi Kortela" . "lassi@lassi.io")) (:maintainers ("Lassi Kortela" . "lassi@lassi.io")) (:maintainer "Lassi Kortela" . "lassi@lassi.io") (:keywords "editorconfig" "util") (:url . "https://github.com/lassik/editorconfig-emacs-domain-specific"))]) @@ -1279,8 +1281,8 @@ (elcontext . [(20210109 1238) ((ht (2 3)) (hydra (0 14 0)) (emacs (24 3)) (f (0 20 0)) (osx-location (0 4)) (uuidgen (0 3))) "Create context specific actions" tar ((:commit . "2efd3dd8c5176c4f071bb048be6cb069b05d6e9e") (:authors ("Thomas Sojka")) (:maintainers ("Thomas Sojka")) (:maintainer "Thomas Sojka") (:keywords "calendar" "convenience") (:url . "https://github.com/rollacaster/elcontext"))]) (elcord . [(20240305 2138) ((emacs (25 1))) "Allows you to integrate Rich Presence from Discord" tar ((:commit . "e2775f40ec55dfdceea83d535dff77d60534b6bc") (:authors ("heatingdevice") ("Wilfredo Velázquez-Rodríguez" . "zulu.inuoe@gmail.com")) (:maintainers ("heatingdevice")) (:maintainer "heatingdevice") (:keywords "games") (:url . "https://github.com/Mstrodl/elcord"))]) (elcouch . [(20230903 750) ((emacs (25 1)) (json-mode (1 0 0)) (libelcouch (0 11 0)) (navigel (0 3 0))) "View and manipulate CouchDB databases" tar ((:commit . "a426e9bee9501284f4e1e84766621ca6b130c79a") (:authors ("Damien Cassou" . "damien@cassou.me")) (:maintainers ("Damien Cassou" . "damien@cassou.me")) (:maintainer "Damien Cassou" . "damien@cassou.me") (:keywords "data" "tools") (:url . "https://gitlab.petton.fr/DamienCassou/elcouch"))]) - (eldev . [(20240511 2039) ((emacs (24 4))) "Elisp development tool" tar ((:commit . "5153b5a747aaadb51ac14f3963e3ffbf59273e74") (:authors ("Paul Pogonyshev" . "pogonyshev@gmail.com")) (:maintainers ("Paul Pogonyshev" . "pogonyshev@gmail.com")) (:maintainer "Paul Pogonyshev" . "pogonyshev@gmail.com") (:keywords "maint" "tools") (:url . "https://github.com/emacs-eldev/eldev"))]) - (eldoc-box . [(20240426 408) ((emacs (27 1))) "Display documentation in childframe" tar ((:commit . "4392128d4caaa21f7810ba0955514c395e9f3cae") (:authors ("Yuan Fu" . "casouri@gmail.com")) (:maintainers ("Yuan Fu" . "casouri@gmail.com")) (:maintainer "Yuan Fu" . "casouri@gmail.com") (:url . "https://github.com/casouri/eldoc-box"))]) + (eldev . [(20240601 1046) ((emacs (24 4))) "Elisp development tool" tar ((:commit . "b94d85361922297e374edc05d55f249111eb84ec") (:authors ("Paul Pogonyshev" . "pogonyshev@gmail.com")) (:maintainers ("Paul Pogonyshev" . "pogonyshev@gmail.com")) (:maintainer "Paul Pogonyshev" . "pogonyshev@gmail.com") (:keywords "maint" "tools") (:url . "https://github.com/emacs-eldev/eldev"))]) + (eldoc-box . [(20240601 1539) ((emacs (27 1))) "Display documentation in childframe" tar ((:commit . "0be491c30e2f97da6bd680174a3223847eae567a") (:authors ("Yuan Fu" . "casouri@gmail.com")) (:maintainers ("Yuan Fu" . "casouri@gmail.com")) (:maintainer "Yuan Fu" . "casouri@gmail.com") (:url . "https://github.com/casouri/eldoc-box"))]) (eldoc-cmake . [(20190419 2244) ((emacs (25 1))) "Eldoc support for CMake" tar ((:commit . "4453c03b5c95ff32842f13db2fc317fb0fe2f79e") (:authors ("Kirill Ignatiev")) (:maintainers ("Kirill Ignatiev")) (:maintainer "Kirill Ignatiev") (:url . "https://github.com/ikirill/eldoc-cmake"))]) (eldoc-eask . [(20240101 819) ((emacs (26 1)) (eask (0 1 0))) "Eldoc support for Eask-file" tar ((:commit . "ade0f239814f3b8bc77229e903d2c4b806ded90a") (:authors ("Shen, Jen-Chieh" . "jcs090218@gmail.com")) (:maintainers ("Shen, Jen-Chieh" . "jcs090218@gmail.com")) (:maintainer "Shen, Jen-Chieh" . "jcs090218@gmail.com") (:keywords "convenience") (:url . "https://github.com/emacs-eask/eldoc-eask"))]) (eldoc-eval . [(20220106 1951) nil "Enable eldoc support when minibuffer is in use." tar ((:commit . "e91800503c90cb75dc70abe42f1d6ae499346cc1") (:authors ("Thierry Volpiatto" . "thievol@posteo.net")) (:maintainers ("Thierry Volpiatto" . "thievol@posteo.net")) (:maintainer "Thierry Volpiatto" . "thievol@posteo.net"))]) @@ -1327,7 +1329,7 @@ (elixir-mode . [(20230626 1738) ((emacs (25))) "Major mode for editing Elixir files" tar ((:commit . "00d6580a040a750e019218f9392cf9a4c2dac23a") (:keywords "languages" "elixir") (:url . "https://github.com/elixir-editors/emacs-elixir"))]) (elixir-ts-mode . [(20240116 645) ((emacs (29 1)) (heex-ts-mode (1 3))) "Major mode for Elixir with tree-sitter support" tar ((:commit . "6db05baed9a34d01edf0bfdd804d951dedc6dccb") (:authors ("Wilhelm H Kirschbaum")) (:maintainers ("Wilhelm H Kirschbaum")) (:maintainer "Wilhelm H Kirschbaum") (:keywords "elixir" "languages" "tree-sitter") (:url . "https://github.com/wkirschbaum/elixir-ts-mode"))]) (elixir-yasnippets . [(20150417 1239) ((yasnippet (0 8 0))) "Yasnippets for Elixir" tar ((:commit . "980ca7626c14ef0573bec0035ec7942796062783") (:authors ("Yinghai Zhao" . "zyinghai@gmail.com")) (:maintainer "Yinghai Zhao" . "zyinghai@gmail.com") (:keywords "snippets"))]) - (ellama . [(20240517 1457) ((emacs (28 1)) (llm (0 6 0)) (spinner (1 7 4))) "Tool for interacting with LLMs" tar ((:commit . "fddc1022b5e16e356d6f65ddac51bd2ccf25209c") (:authors ("Sergey Kostyaev" . "sskostyaev@gmail.com")) (:maintainers ("Sergey Kostyaev" . "sskostyaev@gmail.com")) (:maintainer "Sergey Kostyaev" . "sskostyaev@gmail.com") (:keywords "help" "local" "tools") (:url . "http://github.com/s-kostyaev/ellama"))]) + (ellama . [(20240602 1504) ((emacs (28 1)) (llm (0 6 0)) (spinner (1 7 4))) "Tool for interacting with LLMs" tar ((:commit . "ef2f43b45d42a086938322c73387833b2acdf94f") (:authors ("Sergey Kostyaev" . "sskostyaev@gmail.com")) (:maintainers ("Sergey Kostyaev" . "sskostyaev@gmail.com")) (:maintainer "Sergey Kostyaev" . "sskostyaev@gmail.com") (:keywords "help" "local" "tools") (:url . "http://github.com/s-kostyaev/ellama"))]) (ellocate . [(20200112 1931) ((emacs (25 1)) (s (1 12 0)) (f (0 20 0))) "The locate command reimplemented in Emacs Lisp" tar ((:commit . "81405082f68f0577c9f176d3d4f034a7142aba59") (:authors ("Sebastian Wålinder" . "s.walinder@gmail.com")) (:maintainers ("Sebastian Wålinder" . "s.walinder@gmail.com")) (:maintainer "Sebastian Wålinder" . "s.walinder@gmail.com") (:keywords "matching") (:url . "https://github.com/walseb/ellocate"))]) (elm-mode . [(20230315 1122) ((f (0 17)) (s (1 7 0)) (emacs (25 1)) (seq (2 23)) (reformatter (0 3))) "Major mode for Elm" tar ((:commit . "699841865e1bd5b7f2077baa7121510b6bcad3c7") (:authors ("Joseph Collard")) (:maintainers ("Joseph Collard")) (:maintainer "Joseph Collard") (:url . "https://github.com/jcollard/elm-mode"))]) (elm-test-runner . [(20230905 331) ((emacs (24 4))) "Enhanced support for running elm-test" tar ((:commit . "b664e50a4c849f5f2e2f434fc01718da10515612") (:authors ("Juan Edi")) (:maintainers ("Juan Edi")) (:maintainer "Juan Edi") (:url . "https://github.com/juanedi/elm-test-runner"))]) @@ -1400,13 +1402,14 @@ (emojify . [(20210108 1111) ((seq (1 11)) (ht (2 0)) (emacs (24 3))) "Display emojis in Emacs" tar ((:commit . "cfa00865388809363df3f884b4dd554a5d44f835") (:authors ("Iqbal Ansari" . "iqbalansari02@yahoo.com")) (:maintainers ("Iqbal Ansari" . "iqbalansari02@yahoo.com")) (:maintainer "Iqbal Ansari" . "iqbalansari02@yahoo.com") (:keywords "multimedia" "convenience") (:url . "https://github.com/iqbalansari/emacs-emojify"))]) (emojify-logos . [(20180814 917) ((emojify (0 4))) "Add logos to emojify" tar ((:commit . "a3e78bcbdf863092d4c9b026ac08bf7d1c7c0e8b") (:authors ("mxgoldstein" . "m_goldstein@gmx.net")) (:maintainers ("mxgoldstein" . "m_goldstein@gmx.net")) (:maintainer "mxgoldstein" . "m_goldstein@gmx.net") (:url . "https://github.com/mxgoldstein/emojify-logos"))]) (empos . [(20151011 1916) nil "Locate bibtex citations from within emacs" tar ((:commit . "7b99ad30e56937adb7e6349777e5a2045597d564") (:authors ("Dimitris Alikaniotis <da352 [at] cam.ac.uk>")) (:maintainers ("Dimitris Alikaniotis <da352 [at] cam.ac.uk>")) (:maintainer "Dimitris Alikaniotis <da352 [at] cam.ac.uk>") (:keywords "citations" "reference" "bibtex" "reftex") (:url . "http://github.com/dimalik/empos/"))]) - (empv . [(20240517 1701) ((emacs (28 1)) (s (1 13 0)) (compat (29 1 4 4))) "A multimedia player/manager, YouTube interface" tar ((:commit . "c7313288e350de7331779c0b37a8298980f6ff57") (:authors ("Isa Mert Gurbuz" . "isamertgurbuz@gmail.com")) (:maintainers ("Isa Mert Gurbuz" . "isamertgurbuz@gmail.com")) (:maintainer "Isa Mert Gurbuz" . "isamertgurbuz@gmail.com") (:url . "https://github.com/isamert/empv.el"))]) + (empv . [(20240529 2013) ((emacs (28 1)) (s (1 13 0)) (compat (29 1 4 4))) "A multimedia player/manager, YouTube interface" tar ((:commit . "6f7adfa844e39301af0f510eec40ef7d5df9c8f3") (:authors ("Isa Mert Gurbuz" . "isamertgurbuz@gmail.com")) (:maintainers ("Isa Mert Gurbuz" . "isamertgurbuz@gmail.com")) (:maintainer "Isa Mert Gurbuz" . "isamertgurbuz@gmail.com") (:url . "https://github.com/isamert/empv.el"))]) (emr . [(20220108 548) ((s (1 3 1)) (dash (1 2 0)) (cl-lib (0 2)) (popup (0 5 0)) (emacs (24 1)) (list-utils (0 3 0)) (paredit (24 0 0)) (projectile (0 9 1)) (clang-format (0 0 1)) (iedit (0 97))) "Emacs refactoring system." tar ((:commit . "cac1b52932926f56d7f6d2923732d20bbd20670d") (:authors ("Chris Barrett" . "chris.d.barrett@me.com")) (:maintainers ("Chris Barrett" . "chris.d.barrett@me.com")) (:maintainer "Chris Barrett" . "chris.d.barrett@me.com") (:keywords "tools" "convenience" "refactoring") (:url . "https://github.com/Wilfred/emacs-refactor"))]) (enclose . [(20121008 1614) nil "Enclose cursor within punctuation pairs." tar ((:commit . "2fff3d4fcc1089f87647042d7164ba04282766ae") (:authors ("Johan Andersson" . "johan.rejeep@gmail.com")) (:maintainer "Johan Andersson" . "johan.rejeep@gmail.com") (:keywords "speed" "convenience") (:url . "http://github.com/rejeep/enclose"))]) (encourage-mode . [(20151128 905) ((emacs (24 4))) "Encourages you in your work. :D" tar ((:commit . "ca411e6bfd3d0edffe95852127bd995730b942e3") (:authors ("Patrick Mosby" . "patrick@schreiblogade.de")) (:maintainers ("Patrick Mosby" . "patrick@schreiblogade.de")) (:maintainer "Patrick Mosby" . "patrick@schreiblogade.de") (:keywords "fun") (:url . "https://github.com/halbtuerke/encourage-mode.el"))]) (encrypt-region . [(20220802 918) ((emacs (26 1))) "Encrypts and decrypts regions" tar ((:commit . "8ff5704bc6f4c57f935a8b7680129e599bbe474f") (:authors ("Carlton Shepherd" . "carlton@linux.com")) (:maintainers ("Carlton Shepherd" . "carlton@linux.com")) (:maintainer "Carlton Shepherd" . "carlton@linux.com") (:keywords "tools" "convenience") (:url . "https://github.com/cgshep/encrypt-region"))]) (engine-mode . [(20230619 1503) ((emacs (24 4))) "Define and query search engines" tar ((:commit . "687266bff45cda00c1de57a22ad2b03de6823c28") (:authors ("Harry R. Schwartz" . "hello@harryrschwartz.com")) (:maintainers ("Harry R. Schwartz" . "hello@harryrschwartz.com")) (:maintainer "Harry R. Schwartz" . "hello@harryrschwartz.com") (:url . "https://github.com/hrs/engine-mode"))]) (enh-ruby-mode . [(20221011 1957) ((emacs (25 1))) "Major mode for editing Ruby files" tar ((:commit . "7e76d754e1632b4fc9a024fa393c3fc837bcc86b") (:authors ("Geoff Jacobsen")) (:maintainers ("Ryan Davis")) (:maintainer "Ryan Davis") (:keywords "languages" "elisp" "ruby") (:url . "https://github.com/zenspider/Enhanced-Ruby-Mode"))]) + (enlight . [(20240601 1150) ((emacs (27 1)) (compat (29 1 4 1))) "Highly customizable startup screen" tar ((:commit . "76753736da1777c8f9ebbeb08beec15b330a5878") (:authors ("Ilya Chernyshov" . "ichernyshovvv@gmail.com")) (:maintainers ("Ilya Chernyshov" . "ichernyshovvv@gmail.com")) (:maintainer "Ilya Chernyshov" . "ichernyshovvv@gmail.com") (:keywords "startup" "screen" "tools" "dashboard") (:url . "https://github.com/ichernyshovvv/enlight"))]) (enlightened-theme . [(20210220 2327) nil "A theme based on enlightened" tar ((:commit . "1bfebd8f47e8a8357c9e557cf6e95d7027861e6d") (:url . "https://hg.sr.ht/~slondr/enlightened"))]) (enlive . [(20170725 1417) nil "query html document with css selectors" tar ((:commit . "604a8ca272b6889f114e2b5a13adb5b1dc4bae86") (:authors ("ZHOU Feng" . "zf.pascal@gmail.com")) (:maintainers ("ZHOU Feng" . "zf.pascal@gmail.com")) (:maintainer "ZHOU Feng" . "zf.pascal@gmail.com") (:keywords "css" "selector" "query") (:url . "http://github.com/zweifisch/enlive"))]) (eno . [(20191013 1239) ((dash (2 12 1)) (edit-at-point (1 0))) "Goto/copy/cut any word/symbol/line in view, similar to ace-jump/easymotion" tar ((:commit . "c5c6193687c0bede1ddf507c430cf8b0a6d272d9") (:authors (nil . "<e.enoson@gmail.com>")) (:maintainers (nil . "<e.enoson@gmail.com>")) (:maintainer nil . "<e.enoson@gmail.com>") (:url . "http://github.com/enoson/eno.el"))]) @@ -1517,15 +1520,15 @@ (evalator-clojure . [(20160208 2148) ((cider (0 10 0)) (evalator (1 0 0))) "Clojure evaluation context for evalator via CIDER." tar ((:commit . "caa4e0a137bdfada86593128a654e16aa617ad50") (:authors ("Sean Irby")) (:maintainers ("Sean Irby" . "sean.t.irby@gmail.com")) (:maintainer "Sean Irby" . "sean.t.irby@gmail.com") (:keywords "languages" "clojure" "cider" "helm") (:url . "http://www.github.com/seanirby/evalator-clojure"))]) (eve-mode . [(20170822 2231) ((emacs (25)) (polymode (1 0)) (markdown-mode (2 0))) "Major mode for editing Eve documents." tar ((:commit . "a4661114d9c18725691b76321d72167ca5a9070a") (:authors ("Joshua Cole" . "joshuafcole@gmail.com")) (:maintainers ("Joshua Cole" . "joshuafcole@gmail.com")) (:maintainer "Joshua Cole" . "joshuafcole@gmail.com") (:keywords "languages" "wp" "tools") (:url . "https://github.com/witheve/emacs-eve-mode"))]) (everlasting-scratch . [(20240430 1713) ((emacs (25 1))) "The *scratch* that lasts forever" tar ((:commit . "1837142ae14fdfd4d634434ceff966b348826259") (:authors ("Huming Chen" . "chenhuming@gmail.com")) (:maintainers ("Huming Chen" . "chenhuming@gmail.com")) (:maintainer "Huming Chen" . "chenhuming@gmail.com") (:keywords "convenience" "tool") (:url . "https://github.com/beacoder/everlasting-scratch"))]) - (evil . [(20240521 954) ((emacs (24 1)) (goto-chg (1 6)) (cl-lib (0 5))) "Extensible Vi layer for Emacs." tar ((:commit . "0b134d3bbf73c93f5fed2bb89a35f408a9d627ed") (:maintainer "Tom Dalziel" . "tom.dalziel@gmail.com") (:keywords "emulations") (:url . "https://github.com/emacs-evil/evil"))]) + (evil . [(20240531 1609) ((emacs (24 1)) (goto-chg (1 6)) (cl-lib (0 5))) "Extensible vi layer" tar ((:commit . "9fada7828a1afadbec1f84675ce3c8e9729e1cdc") (:maintainer "Tom Dalziel" . "tom.dalziel@gmail.com") (:keywords "emulations") (:url . "https://github.com/emacs-evil/evil"))]) (evil-anzu . [(20220911 1939) ((evil (1 0 0)) (anzu (0 46))) "anzu for evil-mode" tar ((:commit . "d1e98ee6976437164627542909a25c6946497899") (:authors ("Syohei YOSHIDA" . "syohex@gmail.com") ("Fredrik Bergroth" . "fbergroth@gmail.com")) (:maintainers ("Syohei YOSHIDA" . "syohex@gmail.com")) (:maintainer "Syohei YOSHIDA" . "syohex@gmail.com") (:url . "https://github.com/syohex/emacs-evil-anzu"))]) (evil-args . [(20240210 504) ((evil (1 0 8))) "Motions and text objects for delimited arguments in Evil." tar ((:commit . "a8151556f63c9d45d0c44c8a7ef9e5a542f3cdc7") (:authors ("Connor Smith" . "wconnorsmith@gmail.com")) (:maintainers ("Connor Smith" . "wconnorsmith@gmail.com")) (:maintainer "Connor Smith" . "wconnorsmith@gmail.com") (:keywords "evil" "vim-emulation") (:url . "http://github.com/wcsmith/evil-args"))]) (evil-avy . [(20150908 748) ((emacs (24 1)) (cl-lib (0 5)) (avy (0 3 0)) (evil (1 2 3))) "set-based completion" tar ((:commit . "2dd955cc3ecaa7ddeb67b295298abdc6d16dd3a5") (:authors ("Yufan Lou" . "loganlyf@gmail.com")) (:maintainers ("Yufan Lou" . "loganlyf@gmail.com")) (:maintainer "Yufan Lou" . "loganlyf@gmail.com") (:keywords "point" "location" "evil" "vim") (:url . "https://github.com/louy2/evil-avy"))]) (evil-better-visual-line . [(20200123 2045) ((evil (1 2 13))) "gj and gk visual line mode fix" tar ((:commit . "7a65dfb17ab93857eb4c7a39d4018d9399705293") (:authors ("<nuckollsp at gmail.com>")) (:maintainers ("<nuckollsp at gmail.com>")) (:maintainer "<nuckollsp at gmail.com>") (:keywords "evil" "vim" "motion") (:url . "https://github.com/yourfin/evil-better-visual-line"))]) - (evil-cleverparens . [(20240308 751) ((evil (1 0)) (paredit (1)) (smartparens (1 6 1)) (emacs (24 4)) (dash (2 12 0))) "Evil friendly minor-mode for editing lisp." tar ((:commit . "aa19ed6fec73c883442fb4ffd8d300355d5a8580") (:authors ("Olli Piepponen" . "opieppo@gmail.com")) (:maintainers ("Olli Piepponen" . "opieppo@gmail.com")) (:maintainer "Olli Piepponen" . "opieppo@gmail.com") (:keywords "convenience" "emulations") (:url . "https://github.com/emacs-evil/evil-cleverparens"))]) + (evil-cleverparens . [(20240529 1025) ((evil (1 0)) (paredit (1)) (smartparens (1 6 1)) (emacs (24 4)) (dash (2 12 0))) "Evil friendly minor-mode for editing lisp." tar ((:commit . "6637717af0bdac55f97eef98433d53a10395cf77") (:authors ("Olli Piepponen" . "opieppo@gmail.com")) (:maintainers ("Olli Piepponen" . "opieppo@gmail.com")) (:maintainer "Olli Piepponen" . "opieppo@gmail.com") (:keywords "convenience" "emulations") (:url . "https://github.com/emacs-evil/evil-cleverparens"))]) (evil-colemak-basics . [(20221230 1443) ((emacs (24 3)) (evil (1 2 12)) (evil-snipe (2 0 3))) "Basic Colemak key bindings for evil-mode" tar ((:commit . "ea519b962f051cabced8aadaf6ed0134b861225c") (:authors ("Wouter Bolsterlee" . "wouter@bolsterl.ee")) (:maintainers ("Wouter Bolsterlee" . "wouter@bolsterl.ee")) (:maintainer "Wouter Bolsterlee" . "wouter@bolsterl.ee") (:keywords "convenience" "emulations" "colemak" "evil") (:url . "https://github.com/wbolster/evil-colemak-basics"))]) (evil-colemak-minimal . [(20171006 1317) ((emacs (24)) (evil (1 2 12))) "Minimal Colemak key bindings for evil-mode" tar ((:commit . "6d98b6da60f414524a0d718f76024c26dce742b3") (:authors ("Bryan Allred" . "bryan@revolvingcow.com")) (:maintainers ("Bryan Allred" . "bryan@revolvingcow.com")) (:maintainer "Bryan Allred" . "bryan@revolvingcow.com") (:keywords "colemak" "evil") (:url . "https://github.com/bmallred/evil-colemak-minimal"))]) - (evil-collection . [(20240417 1647) ((emacs (26 3)) (evil (1 2 13)) (annalist (1 0))) "A set of keybindings for Evil mode" tar ((:commit . "5886bab852dc9e31959e70384d535473e44504ad") (:authors ("James Nguyen" . "james@jojojames.com")) (:maintainers ("James Nguyen" . "james@jojojames.com")) (:maintainer "James Nguyen" . "james@jojojames.com") (:keywords "evil" "tools") (:url . "https://github.com/emacs-evil/evil-collection"))]) + (evil-collection . [(20240523 120) ((emacs (26 3)) (evil (1 2 13)) (annalist (1 0))) "A set of keybindings for Evil mode" tar ((:commit . "b34369cdb5c1bcecaf02094cf7e31e43c5534e32") (:authors ("James Nguyen" . "james@jojojames.com")) (:maintainers ("James Nguyen" . "james@jojojames.com")) (:maintainer "James Nguyen" . "james@jojojames.com") (:keywords "evil" "tools") (:url . "https://github.com/emacs-evil/evil-collection"))]) (evil-commentary . [(20230610 1006) ((evil (1 0 0))) "Comment stuff out. A port of vim-commentary." tar ((:commit . "c5945f28ce47644c828aac1f5f6ec335478d17fb") (:authors ("Quang Linh LE" . "linktohack@gmail.com")) (:maintainers ("Quang Linh LE" . "linktohack@gmail.com")) (:maintainer "Quang Linh LE" . "linktohack@gmail.com") (:keywords "evil" "comment" "commentary" "evil-commentary") (:url . "http://github.com/linktohack/evil-commentary"))]) (evil-dvorak . [(20160416 1841) ((evil (1 0 8))) "evil keybindings for that work with dvorak mode" tar ((:commit . "e7b80077d6f332452049eb3d7ea51f6c8fbf5947") (:authors ("Joshua Branson")) (:maintainer "Joshua Branson") (:keywords "dvorak" "evil" "vim"))]) (evil-easymotion . [(20200424 135) ((emacs (24)) (avy (0 3 0)) (cl-lib (0 5))) "A port of vim's easymotion to emacs" tar ((:commit . "f96c2ed38ddc07908db7c3c11bcd6285a3e8c2e9") (:authors ("PythonNut" . "pythonnut@pythonnut.com")) (:maintainers ("PythonNut" . "pythonnut@pythonnut.com")) (:maintainer "PythonNut" . "pythonnut@pythonnut.com") (:keywords "convenience" "evil") (:url . "https://github.com/pythonnut/evil-easymotion"))]) @@ -1694,6 +1697,7 @@ (finito . [(20240219 2059) ((emacs (27 1)) (dash (2 17 0)) (request (0 3 2)) (f (0 2 0)) (s (1 12 0)) (transient (0 3 0)) (graphql (0 1 1)) (async (1 9 3))) "View and collect books" tar ((:commit . "b4f1c776e3a6cda2f51dd71e55f72de6fd3c1dcf") (:authors ("Laurence Warne")) (:maintainers ("Laurence Warne")) (:maintainer "Laurence Warne") (:keywords "outlines") (:url . "https://github.com/LaurenceWarne/finito.el"))]) (fiplr . [(20140724 645) ((grizzl (0 1 0)) (cl-lib (0 1))) "Fuzzy Search for Files in Projects" tar ((:commit . "bb6b90ba3c558988c195048c4c40140b2ee17530") (:authors ("Chris Corbyn" . "chris@w3style.co.uk")) (:maintainer "Chris Corbyn" . "chris@w3style.co.uk") (:keywords "convenience" "usability" "project") (:url . "https://github.com/d11wtq/fiplr"))]) (fira-code-mode . [(20240228 1728) ((emacs (24 4))) "Minor mode for Fira Code ligatures using prettify-symbols" tar ((:commit . "c48f3f16a4b497b9e455966561bbb6638efe4900") (:authors ("Jonathan Ming" . "jming422@gmail.com")) (:maintainers ("Jonathan Ming" . "jming422@gmail.com")) (:maintainer "Jonathan Ming" . "jming422@gmail.com") (:keywords "faces" "ligatures" "fonts" "programming-ligatures") (:url . "https://github.com/jming422/fira-code-mode"))]) + (firebase-rules-mode . [(20240520 1326) ((emacs (24 3))) "Editing support for firebase.rules" tar ((:commit . "c88cb10251cdfce931e4fe48ce76eaa50cc7e791") (:authors ("Darrel Herbst" . "dherbst@gmail.com")) (:maintainers ("Darrel Herbst" . "dherbst@gmail.com")) (:maintainer "Darrel Herbst" . "dherbst@gmail.com") (:keywords "languages") (:url . "https://github.com/dherbst/firebase-rules-mode"))]) (firecode-theme . [(20170808 1311) ((emacs (24 0))) "an Emacs 24 theme based on FireCode (tmTheme)" tar ((:commit . "8b7b03ecdd41e70dab145b98906017e1392eaef4") (:authors ("Jason Milkins")) (:maintainers ("Jason Milkins")) (:maintainer "Jason Milkins") (:url . "https://github.com/emacsfodder/tmtheme-to-deftheme"))]) (fireplace . [(20200402 2206) nil "A cozy fireplace for emacs" tar ((:commit . "f6c23e259349922aae25cf2898ba815a7d8f2527") (:authors ("Johan Sivertsen" . "johanvts@gmail.com")) (:maintainers ("Johan Sivertsen" . "johanvts@gmail.com")) (:maintainer "Johan Sivertsen" . "johanvts@gmail.com") (:keywords "games") (:url . "https://github.com/johanvts/emacs-fireplace"))]) (firestarter . [(20210508 1626) ((emacs (24 1))) "Execute (shell) commands on save" tar ((:commit . "76070c9074aa363350abe6ad06143e90b3e12ab1") (:authors ("Vasilij Schneidermann" . "mail@vasilij.de")) (:maintainers ("Vasilij Schneidermann" . "mail@vasilij.de")) (:maintainer "Vasilij Schneidermann" . "mail@vasilij.de") (:keywords "convenience") (:url . "https://depp.brause.cc/firestarter"))]) @@ -1816,7 +1820,7 @@ (flycheck-pact . [(20180920 2052) ((emacs (24 3)) (flycheck (0 25)) (pact-mode (0 0 4))) "Flycheck support for pact-mode" tar ((:commit . "0e10045064ef89ec8b6f5a473073d47b976a2ca3") (:authors ("Stuart Popejoy")) (:maintainers ("Stuart Popejoy" . "stuart@kadena.io")) (:maintainer "Stuart Popejoy" . "stuart@kadena.io") (:keywords "pact" "lisp" "languages" "blockchain" "smartcontracts" "tools" "linting") (:url . "http://github.com/kadena-io/flycheck-pact"))]) (flycheck-pest . [(20200710 2327) ((emacs (26 3)) (flycheck (31)) (pest-mode (0 1))) "Flycheck integration for Pest -" tar ((:commit . "43447a2c70f98edd1139005e32f437d3f142442b") (:authors ("Naoya Yamashita" . "conao3@gmail.com")) (:maintainers ("Naoya Yamashita" . "conao3@gmail.com")) (:maintainer "Naoya Yamashita" . "conao3@gmail.com") (:keywords "convenience" "flycheck") (:url . "https://github.com/ksqsf/pest-mode"))]) (flycheck-php-noverify . [(20211005 401) ((flycheck (0 22))) "Flycheck checker for PHP Noverify linter" tar ((:commit . "3aa3035c637eb0476f05bd0fbc66c058aa67ffb7") (:url . "https://github.com/Junker/flycheck-php-noverify"))]) - (flycheck-phpstan . [(20230417 1142) ((emacs (24 3)) (flycheck (26)) (phpstan (0 7 2))) "Flycheck integration for PHPStan" tar ((:commit . "2dc25cb2f3d83484ea0eb063c9ffca8148828a2b") (:authors ("USAMI Kenta" . "tadsan@zonu.me")) (:maintainers ("USAMI Kenta" . "tadsan@zonu.me")) (:maintainer "USAMI Kenta" . "tadsan@zonu.me") (:keywords "tools" "php") (:url . "https://github.com/emacs-php/phpstan.el"))]) + (flycheck-phpstan . [(20240527 2142) ((emacs (24 3)) (flycheck (26)) (phpstan (0 7 2))) "Flycheck integration for PHPStan" tar ((:commit . "6f1c7bb357b1eb90b10a081f1831c1c548c40456") (:authors ("USAMI Kenta" . "tadsan@zonu.me")) (:maintainers ("USAMI Kenta" . "tadsan@zonu.me")) (:maintainer "USAMI Kenta" . "tadsan@zonu.me") (:keywords "tools" "php") (:url . "https://github.com/emacs-php/phpstan.el"))]) (flycheck-pkg-config . [(20230119 1721) ((dash (2 8 0)) (s (1 9 0)) (flycheck (29))) "configure flycheck using pkg-config" tar ((:commit . "c4e4028f6621187365b7362566ac2786206765a1") (:authors ("Wilfred Hughes" . "me@wilfred.me.uk")) (:maintainers ("Wilfred Hughes" . "me@wilfred.me.uk")) (:maintainer "Wilfred Hughes" . "me@wilfred.me.uk") (:keywords "flycheck"))]) (flycheck-plantuml . [(20171018 111) ((flycheck (0 24)) (emacs (24 4)) (plantuml-mode (1 2 2))) "Integrate plantuml with flycheck" tar ((:commit . "183be89e1dbba0b38237dd198dff600e0790309d") (:authors ("Alex Murray" . "murray.alex@gmail.com")) (:maintainers ("Alex Murray" . "murray.alex@gmail.com")) (:maintainer "Alex Murray" . "murray.alex@gmail.com") (:url . "https://github.com/alexmurray/flycheck-plantuml"))]) (flycheck-pony . [(20210118 1327) ((flycheck (0 25 1))) "Pony support in Flycheck" tar ((:commit . "22787cf8223ca9ec309e30a42c20a8e706d8bfbe") (:keywords "tools" "convenience") (:url . "https://github.com/seantallen/flycheck-pony"))]) @@ -1923,7 +1927,7 @@ (fm-bookmarks . [(20170104 1716) ((emacs (24 3)) (cl-lib (0 5))) "Use file manager bookmarks (eg Dolphin, Nautilus, PCManFM) in Dired" tar ((:commit . "11dacfd16a926bfecba96a94c6b13e162c7717f7") (:authors ("Ono Hiroko" . "azazabc123@gmail.com")) (:maintainers ("Ono Hiroko" . "azazabc123@gmail.com")) (:maintainer "Ono Hiroko" . "azazabc123@gmail.com") (:keywords "files" "convenience") (:url . "http://github.com/kuanyui/fm-bookmarks.el"))]) (fmo-mode . [(20240306 1442) ((emacs (29 1)) (difflib (0 3 7)) (format-all (0 5 0))) "Format only changed lines" tar ((:commit . "eb63a36ee8ca0ec985e6fd043db974e6f9b38c83") (:authors ("Xichen Zhou" . "sichem.zh@gmail.com")) (:maintainers ("Xichen Zhou" . "sichem.zh@gmail.com")) (:maintainer "Xichen Zhou" . "sichem.zh@gmail.com") (:keywords "languages" "util") (:url . "https://github.com/xeechou/fmo-mode.el"))]) (fn . [(20210304 1812) ((emacs (24)) (cl-lib (0 5)) (dash (2 18 0))) "Concise anonymous functions for Emacs Lisp" tar ((:commit . "98e3fe1b4785e162d9aca978a2db106baa79260f") (:authors ("Troy Pracy")) (:maintainers ("Troy Pracy")) (:maintainer "Troy Pracy") (:keywords "functional"))]) - (focus . [(20221016 1846) ((emacs (24 3)) (cl-lib (0 5))) "Dim the font color of text in surrounding sections" tar ((:commit . "2507ec4ec5a9402647ef85540669db1815520c15") (:authors ("Lars Tveito" . "larstvei@ifi.uio.no")) (:maintainers ("Lars Tveito" . "larstvei@ifi.uio.no")) (:maintainer "Lars Tveito" . "larstvei@ifi.uio.no") (:url . "http://github.com/larstvei/Focus"))]) + (focus . [(20240528 901) ((emacs (24 3)) (cl-lib (0 5))) "Dim the font color of text in surrounding sections" tar ((:commit . "17c471544f540f2cf9a05fd6cd87e52e5de317e2") (:authors ("Lars Tveito" . "larstvei@ifi.uio.no")) (:maintainers ("Lars Tveito" . "larstvei@ifi.uio.no")) (:maintainer "Lars Tveito" . "larstvei@ifi.uio.no") (:url . "http://github.com/larstvei/Focus"))]) (focus-autosave-mode . [(20160519 2116) ((emacs (24 4))) "Automatically save files in focus-out-hook." tar ((:commit . "e89ed22aa4dfc76e1b844b202aedd468ad58814a") (:authors ("Wojciech Siewierski" . "wojciech.siewierski@onet.pl")) (:maintainers ("Wojciech Siewierski" . "wojciech.siewierski@onet.pl")) (:maintainer "Wojciech Siewierski" . "wojciech.siewierski@onet.pl") (:keywords "convenience" "files" "frames" "mouse"))]) (foggy-night-theme . [(20190123 1614) ((emacs (24))) "Dark low contrast theme with soft and muted colors." tar ((:commit . "14894e06ee5c6e14db36f2cb07387ee971c1736f") (:authors ("Martin Haesler")) (:maintainers ("Martin Haesler")) (:maintainer "Martin Haesler"))]) (fold-dwim . [(20140208 1637) nil "Unified user interface for Emacs folding modes" tar ((:commit . "c46f4bb2ce91b4e307136320e72c28dd50b6cd8b") (:authors ("Peter Heslin" . "p.j.heslin@dur.ac.uk")) (:maintainers ("Peter Heslin" . "p.j.heslin@dur.ac.uk")) (:maintainer "Peter Heslin" . "p.j.heslin@dur.ac.uk") (:url . "http://www.dur.ac.uk/p.j.heslin/Software/Emacs"))]) @@ -1941,7 +1945,7 @@ (foreign-regexp . [(20200325 50) nil "search and replace by foreign regexp." tar ((:commit . "e2dd47f2160cadc194eb156e7c76c3c869e6706e") (:authors ("K-talo Miyazaki <Keitaro dot Miyazaki at gmail dot com>")) (:maintainers ("K-talo Miyazaki <Keitaro dot Miyazaki at gmail dot com>")) (:maintainer "K-talo Miyazaki <Keitaro dot Miyazaki at gmail dot com>") (:keywords "convenience" "emulations" "matching" "tools" "unix" "wp"))]) (foreman-mode . [(20170725 1422) ((s (1 9 0)) (dash (2 10 0)) (dash-functional (1 2 0)) (f (0 17 2)) (emacs (24))) "View and manage Procfile-based applications" tar ((:commit . "22b3bb13134b617870ed1e888af739f4818be929") (:authors ("ZHOU Feng" . "zf.pascal@gmail.com")) (:maintainers ("ZHOU Feng" . "zf.pascal@gmail.com")) (:maintainer "ZHOU Feng" . "zf.pascal@gmail.com") (:keywords "foreman") (:url . "http://github.com/zweifisch/foreman-mode"))]) (forest-blue-theme . [(20160627 842) ((emacs (24))) "Emacs theme with a dark background." tar ((:commit . "58096ce1a25615d2bae806c3775bae3e2775019d") (:authors ("olkinn")) (:maintainers ("olkinn")) (:maintainer "olkinn"))]) - (forge . [(20240519 1510) ((emacs (26 3)) (compat (29 1 4 5)) (closql (20240405)) (dash (2 19 1)) (emacsql (20240124)) (ghub (20240507)) (let-alist (1 0 6)) (magit (20240428)) (markdown-mode (2 6)) (seq (2 24)) (transient (20240421)) (yaml (0 5 5))) "Access Git forges from Magit." tar ((:commit . "d3b14f2cb6740d18827ed713715908b517e4a899") (:authors ("Jonas Bernoulli" . "emacs.forge@jonas.bernoulli.dev")) (:maintainer "Jonas Bernoulli" . "emacs.forge@jonas.bernoulli.dev") (:keywords "git" "tools" "vc") (:url . "https://github.com/magit/forge"))]) + (forge . [(20240523 1103) ((emacs (26 3)) (compat (29 1 4 5)) (closql (20240405)) (dash (2 19 1)) (emacsql (20240124)) (ghub (20240507)) (let-alist (1 0 6)) (magit (20240428)) (markdown-mode (2 6)) (seq (2 24)) (transient (20240421)) (yaml (0 5 5))) "Access Git forges from Magit." tar ((:commit . "ceb6f5b8d257fe5e79532793cdd055c3dddd8806") (:authors ("Jonas Bernoulli" . "emacs.forge@jonas.bernoulli.dev")) (:maintainer "Jonas Bernoulli" . "emacs.forge@jonas.bernoulli.dev") (:keywords "git" "tools" "vc") (:url . "https://github.com/magit/forge"))]) (form-feed . [(20210508 1627) ((emacs (24 1))) "Display ^L glyphs as horizontal lines" tar ((:commit . "ac1f0ef30a11979f5dfe12d8c05a666739e486ff") (:authors ("Vasilij Schneidermann" . "mail@vasilij.de")) (:maintainers ("Vasilij Schneidermann" . "mail@vasilij.de")) (:maintainer "Vasilij Schneidermann" . "mail@vasilij.de") (:keywords "faces") (:url . "https://depp.brause.cc/form-feed"))]) (form-feed-st . [(20231002 2211) ((emacs (25 1))) "Display ^L glyphs as full-width horizontal lines" tar ((:commit . "f91c8daf35b7588e0aa24c8716c8cfd8ff0067c8") (:authors ("Leonardo Schripsema")) (:maintainers ("Leonardo Schripsema")) (:maintainer "Leonardo Schripsema") (:keywords "faces") (:url . "https://github.com/leodag/form-feed-st"))]) (format-all . [(20240511 1811) ((emacs (24 4)) (inheritenv (0 1)) (language-id (0 20))) "Auto-format C, C++, JS, Python, Ruby and 50 other languages" tar ((:commit . "c5ddfc5f3317eaa2a7541a818a0fce961e5e61dd") (:authors ("Lassi Kortela" . "lassi@lassi.io")) (:maintainers ("Lassi Kortela" . "lassi@lassi.io")) (:maintainer "Lassi Kortela" . "lassi@lassi.io") (:keywords "languages" "util") (:url . "https://github.com/lassik/emacs-format-all-the-code"))]) @@ -1950,7 +1954,7 @@ (forth-mode . [(20231206 1127) ((cl-lib (0 2))) "Programming language mode for Forth" tar ((:commit . "59c5ea89ca7593bd49cdde6caefa0893a8780105") (:authors ("Lars Brinkhoff" . "lars@nocrew.org")) (:maintainers ("Lars Brinkhoff" . "lars@nocrew.org")) (:maintainer "Lars Brinkhoff" . "lars@nocrew.org") (:keywords "languages" "forth") (:url . "http://github.com/larsbrinkhoff/forth-mode"))]) (fortpy . [(20150715 2032) ((epc (0 1 0)) (auto-complete (1 4)) (python-environment (0 0 2)) (pos-tip (0 4 5))) "a Fortran auto-completion for Emacs" tar ((:commit . "c614517e9396ef7a78be3b8786fbf303879cf43b") (:authors ("Conrad Rosenbrock <rosenbrockc at gmail.com>")) (:maintainers ("Conrad Rosenbrock <rosenbrockc at gmail.com>")) (:maintainer "Conrad Rosenbrock <rosenbrockc at gmail.com>"))]) (fortune-cookie . [(20181223 842) nil "Print a fortune in your scratch buffer." tar ((:commit . "6c1c08f5be83822c0b762872ab25e3dbee96f333") (:authors ("Andrew Schwartzmeyer" . "andrew@schwartzmeyer.com")) (:maintainers ("Andrew Schwartzmeyer" . "andrew@schwartzmeyer.com")) (:maintainer "Andrew Schwartzmeyer" . "andrew@schwartzmeyer.com") (:keywords "fortune" "cowsay" "scratch" "startup") (:url . "https://github.com/andschwa/fortune-cookie"))]) - (fountain-mode . [(20240520 307) ((emacs (24 4)) (seq (2 20))) "Major mode for screenwriting in Fountain markup" tar ((:commit . "7e10f27dd5d9a5d18e08a5454321e961167dfbf7") (:authors ("Paul W. Rankin" . "hello@paulwrankin.com")) (:maintainers ("Paul W. Rankin" . "hello@paulwrankin.com")) (:maintainer "Paul W. Rankin" . "hello@paulwrankin.com") (:keywords "wp" "text") (:url . "https://www.fountain-mode.org"))]) + (fountain-mode . [(20240602 525) ((emacs (24 4)) (seq (2 20))) "Major mode for screenwriting in Fountain markup" tar ((:commit . "33234ab11cf0b65a8e1e44b783ef34cf621a2008") (:authors ("Paul W. Rankin" . "hello@paulwrankin.com")) (:maintainers ("Paul W. Rankin" . "hello@paulwrankin.com")) (:maintainer "Paul W. Rankin" . "hello@paulwrankin.com") (:keywords "wp" "text") (:url . "https://www.fountain-mode.org"))]) (fpga . [(20240329 1759) ((emacs (29 1))) "FPGA & ASIC Utils" tar ((:commit . "34e521962ba3842321d456bd587aa93e4b627969") (:authors ("Gonzalo Larumbe" . "gonzalomlarumbe@gmail.com")) (:maintainers ("Gonzalo Larumbe" . "gonzalomlarumbe@gmail.com")) (:maintainer "Gonzalo Larumbe" . "gonzalomlarumbe@gmail.com") (:keywords "tools") (:url . "https://github.com/gmlarumbe/fpga"))]) (fraktur-mode . [(20160815 227) ((cl-lib (0 5))) "Easily insert Unicode mathematical Fraktur characters" tar ((:commit . "514baf5546aed12a0d9fa0fe66e87cdcc7843b08") (:authors ("Grant Rettke" . "gcr@wisdomandwonder.com")) (:maintainers (nil . "<gcr@wisdomandwonder.com>")) (:maintainer nil . "<gcr@wisdomandwonder.com>") (:keywords "unicode" "fraktur" "math" "mathematical") (:url . "https://github.com/grettke/fraktur-mode"))]) (frame-local . [(20180330 940) ((emacs (25 1))) "Variables local to a frame" tar ((:commit . "51c0889602626e2dcc6f1c1a812b058bc96df03c") (:authors ("Sebastien Chapuis" . "sebastien@chapu.is")) (:maintainers ("Sebastien Chapuis" . "sebastien@chapu.is")) (:maintainer "Sebastien Chapuis" . "sebastien@chapu.is") (:keywords "frames" "tools" "local" "lisp") (:url . "https://github.com/sebastiencs/frame-local"))]) @@ -1977,7 +1981,7 @@ (fsbot-data-browser . [(20220830 230) nil "browse the fsbot database using tabulated-list-mode" tar ((:commit . "27455860fec01ca47bf98b85f093cc24b9852bef") (:authors ("Benaiah Mischenko")) (:maintainers ("Benaiah Mischenko")) (:maintainer "Benaiah Mischenko") (:keywords "fsbot" "irc" "tabulated-list-mode") (:url . "http://github.com/benaiah/fsbot-data-browser"))]) (fsharp-mode . [(20230622 1854) ((emacs (25))) "Support for the F# programming language" tar ((:commit . "b4d31c3da018cfbb3d1f9e6fd416d8777f0835bd") (:authors ("1993-1997 Xavier Leroy, Jacques Garrigue and Ian T Zimmerman") ("2010-2011 Laurent Le Brun" . "laurent@le-brun.eu") ("2012-2014 Robin Neatherway" . "robin.neatherway@gmail.com") ("2017-2023 Jürgen Hötzel")) (:maintainers ("Jürgen Hötzel")) (:maintainer "Jürgen Hötzel") (:keywords "languages"))]) (fstar-mode . [(20240312 1632) ((emacs (24 3)) (dash (2 11)) (company (0 8 12)) (quick-peek (1 0)) (yasnippet (0 11 0)) (flycheck (30 0)) (company-quickhelp (2 2 0))) "Support for F* programming" tar ((:commit . "6e5d3ea858f3c8a9d01161d9089909c2b22fdfca") (:authors ("Clément Pit-Claudel" . "clement.pitclaudel@live.com")) (:maintainers ("Clément Pit-Claudel" . "clement.pitclaudel@live.com")) (:maintainer "Clément Pit-Claudel" . "clement.pitclaudel@live.com") (:keywords "convenience" "languages") (:url . "https://github.com/FStarLang/fstar-mode.el"))]) - (fuel . [(20230824 1321) ((cl-lib (0 2)) (emacs (24 2))) "Major mode for the Factor programming language." tar ((:commit . "e10b64dbc53a8583098e73580a1eb9ff4ce0c709"))]) + (fuel . [(20240523 1604) ((cl-lib (0 2)) (emacs (24 2))) "Major mode for the Factor programming language." tar ((:commit . "436d9a61aaa1fdaa319f14d0eac6b5aec920db05"))]) (fuff . [(20170202 1503) ((seq (2 3))) "Find files with findutils, recursively" tar ((:commit . "278e849913df87bd8756c59382282d87474802c3") (:authors ("Joel Moberg")) (:maintainers ("Joel Moberg")) (:maintainer "Joel Moberg") (:keywords "files" "project" "convenience") (:url . "https://github.com/joelmo/fuff"))]) (full-ack . [(20140223 1732) nil "a front-end for ack" tar ((:commit . "8345753e9569dabf6426a837f29387557e32f2af") (:authors ("Nikolaj Schumacher <bugs * nschum de>")) (:maintainers ("Nikolaj Schumacher <bugs * nschum de>")) (:maintainer "Nikolaj Schumacher <bugs * nschum de>") (:keywords "tools" "matching") (:url . "http://nschum.de/src/emacs/full-ack/"))]) (fullframe . [(20210226 1057) ((cl-lib (0 5))) "Generalized automatic execution in a single frame" tar ((:commit . "886b831c001b44ec95aec4ff36e8bc1b3003c786") (:authors ("Tom Regner" . "tom@goochesa.de")) (:maintainers ("Tom Regner" . "tom@goochesa.de")) (:maintainer "Tom Regner" . "tom@goochesa.de") (:keywords "fullscreen"))]) @@ -2006,9 +2010,9 @@ (geben . [(20220827 105) ((emacs (24 3)) (cl-lib (0 5))) "DBGp protocol frontend, a script debugger" tar ((:commit . "8df1ed2c8ff13b0ca4ef241c95c46f60a5a4fe3c") (:authors ("Matthew Carter" . "m@ahungry.com")) (:maintainers ("Matthew Carter" . "m@ahungry.com")) (:maintainer "Matthew Carter" . "m@ahungry.com") (:keywords "c" "comm" "tools") (:url . "https://github.com/ahungry/geben"))]) (geben-helm-projectile . [(20170524 334) ((emacs (24)) (geben (0 26)) (helm-projectile (0 13 0))) "Integrate helm-projectile with geben" tar ((:commit . "31ce0faca5dcc71924884f03fd5a7a25d00ccd9b") (:authors ("Matthew Carter" . "m@ahungry.com")) (:maintainers ("Matthew Carter" . "m@ahungry.com")) (:maintainer "Matthew Carter" . "m@ahungry.com") (:keywords "ahungry" "emacs" "geben" "helm" "projectile" "debug") (:url . "https://github.com/ahungry/geben-helm-projectile"))]) (geeknote . [(20220213 612) ((emacs (24))) "Use Evernote in Emacs through geeknote" tar ((:commit . "ce2738aebeeda35f9d31027e9b7bad0813b975c3") (:authors ("Evan Dale Aromin")) (:maintainers ("Evan Dale Aromin")) (:maintainer "Evan Dale Aromin") (:keywords "evernote" "geeknote" "note" "emacs-evernote" "evernote-mode") (:url . "http://github.com/avendael/emacs-geeknote"))]) - (geiser . [(20240208 26) ((emacs (27 1)) (project (0 8 1))) "GNU Emacs and Scheme talk to each other" tar ((:commit . "4e64934bd2ae7c6f0e4acb9f2ed017844c187223") (:authors ("Jose Antonio Ortega Ruiz" . "jao@gnu.org")) (:maintainers ("Jose Antonio Ortega Ruiz" . "jao@gnu.org")) (:maintainer "Jose Antonio Ortega Ruiz" . "jao@gnu.org") (:keywords "languages" "scheme" "geiser") (:url . "https://gitlab.com/emacs-geiser/"))]) + (geiser . [(20240523 33) ((emacs (27 1)) (project (0 8 1))) "GNU Emacs and Scheme talk to each other" tar ((:commit . "b6b4ac070d136345345c80ff649f0084e3c512a5") (:authors ("Jose Antonio Ortega Ruiz" . "jao@gnu.org")) (:maintainers ("Jose Antonio Ortega Ruiz" . "jao@gnu.org")) (:maintainer "Jose Antonio Ortega Ruiz" . "jao@gnu.org") (:keywords "languages" "scheme" "geiser") (:url . "https://gitlab.com/emacs-geiser/"))]) (geiser-chez . [(20230707 1334) ((emacs (26 1)) (geiser (0 19))) "Chez and Geiser talk to each other" tar ((:commit . "605a81ff7b2d2b275a3ec68e3ce7e5b50f85014d") (:authors ("Peter" . "craven@gmx.net")) (:maintainers ("Jose A Ortega Ruiz" . "jao@gnu.org")) (:maintainer "Jose A Ortega Ruiz" . "jao@gnu.org") (:keywords "languages" "chez" "scheme" "geiser") (:url . "https://gitlab.com/emacs-geiser/chez"))]) - (geiser-chibi . [(20240519 2215) ((emacs (24 4)) (geiser (0 18))) "Chibi Scheme's implementation of the geiser protocols" tar ((:commit . "da68e9bcf4382f07121ae3c103f5b6847b3f3047") (:authors ("Peter" . "craven@gmx.net")) (:maintainers ("Jose A Ortega Ruiz" . "jao@gnu.org")) (:maintainer "Jose A Ortega Ruiz" . "jao@gnu.org") (:keywords "languages" "chibi" "scheme" "geiser") (:url . "https://gitlab.com/emacs-geiser/chibi"))]) + (geiser-chibi . [(20240521 2252) ((emacs (24 4)) (geiser (0 18))) "Chibi Scheme's implementation of the geiser protocols" tar ((:commit . "2502fed1349c2703eea528b74bcc980ad6bceab8") (:authors ("Peter" . "craven@gmx.net")) (:maintainers ("Jose A Ortega Ruiz" . "jao@gnu.org")) (:maintainer "Jose A Ortega Ruiz" . "jao@gnu.org") (:keywords "languages" "chibi" "scheme" "geiser") (:url . "https://gitlab.com/emacs-geiser/chibi"))]) (geiser-chicken . [(20220717 1130) ((emacs (24 4)) (geiser (0 19))) "Chicken's implementation of the geiser protocols" tar ((:commit . "a480598b5908c95bc8d3178a48f13e9072a9235b") (:authors ("Daniel Leslie")) (:maintainers ("Daniel Leslie")) (:maintainer "Daniel Leslie") (:keywords "languages" "chicken" "scheme" "geiser") (:url . "https://gitlab.com/emacs-geiser/chicken"))]) (geiser-gambit . [(20220208 1356) ((emacs (26 1)) (geiser (0 18))) "Gambit's implementation of the geiser protocols" tar ((:commit . "381d74ca5059b44fe3d8b5daf42214019c6d1a88") (:authors ("Daniel Leslie")) (:maintainers ("Jose A Ortega Ruiz" . "jao@gnu.org")) (:maintainer "Jose A Ortega Ruiz" . "jao@gnu.org") (:keywords "languages" "gambit" "scheme" "geiser") (:url . "https://gitlab.com/emacs-geiser/gambit"))]) (geiser-gauche . [(20220503 1700) ((emacs (26 1)) (geiser (0 11 2))) "Gauche scheme support for Geiser" tar ((:commit . "8ff743f6416f00751e24aef8b9791501a40f5421") (:authors ("András Simonyi" . "andras.simonyi@gmail.com")) (:maintainers ("András Simonyi" . "andras.simonyi@gmail.com")) (:maintainer "András Simonyi" . "andras.simonyi@gmail.com") (:keywords "languages" "gauche" "scheme" "geiser") (:url . "https://gitlab.com/emacs-geiser/gauche"))]) @@ -2058,8 +2062,10 @@ (git-command . [(20191028 333) ((term-run (0 1 4)) (with-editor (2 3 1))) "A Git Command-Line interface" tar ((:commit . "a773d40da39dfb1c6ecf2b0758aa370ddea8f06d") (:authors ("10sr <8slashes+el [at] gmail [dot] com>")) (:maintainers ("10sr <8slashes+el [at] gmail [dot] com>")) (:maintainer "10sr <8slashes+el [at] gmail [dot] com>") (:keywords "utility" "git") (:url . "https://github.com/10sr/git-command-el"))]) (git-commit . [(20240520 1135) ((emacs (26 1)) (compat (29 1 4 5)) (transient (20240421)) (with-editor (20240415))) "Edit Git commit messages." tar ((:commit . "22fd8f8594202a0679ccc2f7d02bca44d48b8039") (:authors ("Jonas Bernoulli" . "emacs.magit@jonas.bernoulli.dev") ("Sebastian Wiesner" . "lunaryorn@gmail.com") ("Florian Ragwitz" . "rafl@debian.org") ("Marius Vollmer" . "marius.vollmer@gmail.com")) (:maintainer "Jonas Bernoulli" . "emacs.magit@jonas.bernoulli.dev") (:keywords "git" "tools" "vc") (:url . "https://github.com/magit/magit"))]) (git-commit-insert-issue . [(20230512 1416) ((emacs (25)) (projectile (0)) (s (0)) (ghub (0)) (bitbucket (0))) "Get issues list when typing \"Fixes #\"" tar ((:commit . "df7ce0549d1db7bab27d401a351ea0d187c4a673") (:authors ("Vindarel")) (:maintainers ("Vindarel")) (:maintainer "Vindarel") (:keywords "tools" "vc" "github" "gitlab" "bitbucket" "commit" "issues") (:url . "https://gitlab.com/emacs-stuff/git-commit-insert-issue/"))]) + (git-commit-ts-mode . [(20240527 708) ((emacs (29 1))) "Tree-sitter support for Git commit messages" tar ((:commit . "04219fdac2a5c1816cd08141513770adc0c2a48b") (:authors ("Daniil Shvalov" . "daniil.shvalov@gmail.com")) (:maintainers ("Daniil Shvalov" . "daniil.shvalov@gmail.com")) (:maintainer "Daniil Shvalov" . "daniil.shvalov@gmail.com") (:keywords "tree-sitter" "git" "faces") (:url . "https://github.com/danilshvalov/git-commit-ts-mode"))]) (git-dwim . [(20170126 1214) nil "Context-aware git commands such as branch handling" tar ((:commit . "485c732130686c2f28a026e385366006435394b9") (:authors ("rubikitch" . "rubikitch@ruby-lang.org")) (:maintainers ("rubikitch" . "rubikitch@ruby-lang.org")) (:maintainer "rubikitch" . "rubikitch@ruby-lang.org") (:keywords "git" "tools" "convenience") (:url . "http://www.emacswiki.org/cgi-bin/wiki/download/git-dwim.el"))]) (git-grep . [(20200920 1751) ((projectile (0 10 0))) "Search tools using git grep" tar ((:commit . "12ff6045e9b6aa42f98abd4ddc44d670268a0849") (:authors ("Sam Kleinman")) (:maintainers ("tychoish" . "garen@tychoish.com")) (:maintainer "tychoish" . "garen@tychoish.com") (:keywords "matching" "files" "grep" "search" "using" "git-grep") (:url . "https://github.com/tychoish/git-grep.el"))]) + (git-grep-transient . [(20240521 648) ((emacs (27 1)) (magit (3 3 0)) (transient (0 6 0)) (symbol-overlay (4 2))) "Search for text using git grep command" tar ((:commit . "c9eb6d76e6b0600d2f90d009fdc28a171f69dd80") (:authors ("Alain Delplanque" . "alaindelplanque@mailoo.org")) (:maintainers ("Alain Delplanque" . "alaindelplanque@mailoo.org")) (:maintainer "Alain Delplanque" . "alaindelplanque@mailoo.org") (:keywords "git" "tools" "vc") (:url . "https://github.com/adelplanque/git-grep-transient"))]) (git-gutter . [(20240425 647) ((emacs (25 1))) "Port of Sublime Text plugin GitGutter" tar ((:commit . "9afe45b41a82a332606d3e70ef85d323d27b9e4f") (:authors ("Syohei YOSHIDA" . "syohex@gmail.com")) (:maintainers ("Neil Okamoto" . "neil.okamoto+melpa@gmail.com")) (:maintainer "Neil Okamoto" . "neil.okamoto+melpa@gmail.com") (:url . "https://github.com/emacsorphanage/git-gutter"))]) (git-gutter+ . [(20151204 1723) ((git-commit (0)) (dash (0))) "Manage Git hunks straight from the buffer" tar ((:commit . "b7726997806d9a2da9fe84ff00ecf21d62b6f975") (:authors ("Syohei YOSHIDA" . "syohex@gmail.com")) (:maintainers ("Syohei YOSHIDA" . "syohex@gmail.com")) (:maintainer "Syohei YOSHIDA" . "syohex@gmail.com") (:keywords "git" "vc") (:url . "https://github.com/nonsequitur/git-gutter-plus"))]) (git-gutter-fringe . [(20211003 2228) ((git-gutter (0 88)) (fringe-helper (0 1 1)) (cl-lib (0 5)) (emacs (24))) "Fringe version of git-gutter.el" tar ((:commit . "648cb5b57faec55711803cdc9434e55a733c3eba") (:authors ("Syohei YOSHIDA" . "syohex@gmail.com")) (:maintainers ("Neil Okamoto" . "neil.okamoto+melpa@gmail.com")) (:maintainer "Neil Okamoto" . "neil.okamoto+melpa@gmail.com") (:url . "https://github.com/emacsorphanage/git-gutter-fringe"))]) @@ -2114,7 +2120,7 @@ (gnome-calendar . [(20161110 1256) nil "Integration with the GNOME Shell calendar" tar ((:commit . "668591bec95c23934c5e1ef100cec4824e7cb25d") (:authors ("Nicolas Petton" . "nicolas@petton.fr")) (:maintainers ("Nicolas Petton" . "nicolas@petton.fr")) (:maintainer "Nicolas Petton" . "nicolas@petton.fr") (:keywords "gnome" "calendar"))]) (gnome-screencast . [(20210125 2001) ((emacs (25))) "Use Gnome screen recording functionality using elisp" tar ((:commit . "1f4ef60fe9d452320dc02f89e289bac04ef2ad1c") (:authors ("Jürgen Hötzel" . "juergen@hoetzel.info")) (:maintainers ("Jürgen Hötzel" . "juergen@hoetzel.info")) (:maintainer "Jürgen Hötzel" . "juergen@hoetzel.info") (:keywords "tools" "multimedia") (:url . "https://github.com/juergenhoetzel/emacs-gnome-screencast"))]) (gnomenm . [(20150316 1918) ((s (1 9 0)) (dash (2 3 0)) (kv (0 0 19))) "Emacs interface to Gnome nmcli command" tar ((:commit . "9065cda44ffc9e06239b8189a0154d31314c3b4d") (:authors ("Nic Ferrier" . "nferrier@ferrier.me.uk")) (:maintainers ("Nic Ferrier" . "nferrier@ferrier.me.uk")) (:maintainer "Nic Ferrier" . "nferrier@ferrier.me.uk") (:keywords "processes" "hardware") (:url . "http://github.com/nicferrier/emacs-nm"))]) - (gnosis . [(20240517 334) ((emacs (27 2)) (emacsql (20240124)) (compat (29 1 4 2))) "Spaced Repetition System" tar ((:commit . "b9c6c04e33ad2f541ab116dda9e460f21034a8eb") (:authors ("Thanos Apollo" . "public@thanosapollo.org")) (:maintainers ("Thanos Apollo" . "public@thanosapollo.org")) (:maintainer "Thanos Apollo" . "public@thanosapollo.org") (:keywords "extensions") (:url . "https://thanosapollo.org/projects/gnosis"))]) + (gnosis . [(20240529 1437) ((emacs (27 2)) (emacsql (20240124)) (compat (29 1 4 2))) "Spaced Repetition System" tar ((:commit . "9960c893190e3ce462568f987bad0dde9fc9b07c") (:authors ("Thanos Apollo" . "public@thanosapollo.org")) (:maintainers ("Thanos Apollo" . "public@thanosapollo.org")) (:maintainer "Thanos Apollo" . "public@thanosapollo.org") (:keywords "extensions") (:url . "https://thanosapollo.org/projects/gnosis"))]) (gntp . [(20141025 250) nil "Growl Notification Protocol for Emacs" tar ((:commit . "767571135e2c0985944017dc59b0be79af222ef5") (:authors ("Engelke Eschner" . "tekai@gmx.li")) (:maintainers ("Engelke Eschner" . "tekai@gmx.li")) (:maintainer "Engelke Eschner" . "tekai@gmx.li"))]) (gnu-apl-mode . [(20220404 341) ((emacs (27))) "Integrate GNU APL with Emacs" tar ((:commit . "c8695b0d55b5167263a843252ffd21a589018427") (:authors ("Elias Mårtenson" . "lokedhs@gmail.com")) (:maintainer "Elias Mårtenson" . "lokedhs@gmail.com") (:keywords "languages") (:url . "http://www.gnu.org/software/apl/"))]) (gnu-indent . [(20221127 2112) ((emacs (25 1))) "Indent your code with GNU Indent" tar ((:commit . "f31dbe60478b6270bb57b6b05998df8eec56f801") (:authors ("Akib Azmain Turja" . "akib@disroot.org")) (:maintainers ("Akib Azmain Turja" . "akib@disroot.org")) (:maintainer "Akib Azmain Turja" . "akib@disroot.org") (:keywords "tools" "c") (:url . "https://codeberg.org/akib/emacs-gnu-indent"))]) @@ -2154,7 +2160,7 @@ (go-snippets . [(20180113 611) ((yasnippet (0 8 0))) "Yasnippets for go" tar ((:commit . "d437df148879566ffe7f2e503a3cf2602aa9fb28") (:keywords "snippets"))]) (go-stacktracer . [(20150430 2142) nil "parse Go stack traces" tar ((:commit . "a2ac6d801b389f80ca4e2fcc1ab44513a9e55976") (:authors ("Samer Masterson" . "samer@samertm.com")) (:maintainers ("Samer Masterson" . "samer@samertm.com")) (:maintainer "Samer Masterson" . "samer@samertm.com") (:keywords "tools") (:url . "https://github.com/samertm/go-stacktracer.el"))]) (go-tag . [(20230111 651) ((emacs (24 0)) (go-mode (1 5 0))) "Edit Golang struct field tag" tar ((:commit . "33f2059551d5298ca228d90f525b99d1a8d70364") (:authors ("Brantou" . "brantou89@gmail.com")) (:maintainers ("Brantou" . "brantou89@gmail.com")) (:maintainer "Brantou" . "brantou89@gmail.com") (:keywords "tools") (:url . "https://github.com/brantou/emacs-go-tag"))]) - (go-translate . [(20240521 331) ((emacs (28 1))) "Translation framework, configurable and scalable" tar ((:commit . "5ff3fa939f52a3670b39dfccd9d63a185656238d") (:authors ("lorniu" . "lorniu@gmail.com")) (:maintainers ("lorniu" . "lorniu@gmail.com")) (:maintainer "lorniu" . "lorniu@gmail.com") (:keywords "convenience") (:url . "https://github.com/lorniu/go-translate"))]) + (go-translate . [(20240531 208) ((emacs (28 1))) "Translation framework, configurable and scalable" tar ((:commit . "a857774be32bf2e7dabb308abbfde759a63a88fc") (:authors ("lorniu" . "lorniu@gmail.com")) (:maintainers ("lorniu" . "lorniu@gmail.com")) (:maintainer "lorniu" . "lorniu@gmail.com") (:keywords "convenience") (:url . "https://github.com/lorniu/go-translate"))]) (gobgen . [(20161020 1523) ((emacs (24 4))) "Generate GObject descendants using a detailed form" tar ((:commit . "ed2c2b0d217deae293096f3cf14aa492791ddd4f") (:authors ("Gergely Polonkai" . "gergely@polonkai.eu")) (:maintainers ("Gergely Polonkai" . "gergely@polonkai.eu")) (:maintainer "Gergely Polonkai" . "gergely@polonkai.eu") (:keywords "gobject" "glib" "gtk" "helper" "utilities"))]) (god-mode . [(20221230 708) ((emacs (25 1))) "Minor mode for God-like command entering" tar ((:commit . "607aff10a7b27a8aa0c1a15c2c39337ab17cfda7") (:authors ("Chris Done" . "chrisdone@gmail.com")) (:maintainers ("Chris Done" . "chrisdone@gmail.com")) (:maintainer "Chris Done" . "chrisdone@gmail.com") (:url . "https://github.com/emacsorphanage/god-mode"))]) (godoctor . [(20180710 2152) nil "Frontend for godoctor" tar ((:commit . "4b45ff3d0572f0e84056e4c3ba91fcc178199859") (:authors ("Sangho Na" . "microamp@protonmail.com")) (:maintainers ("Sangho Na" . "microamp@protonmail.com")) (:maintainer "Sangho Na" . "microamp@protonmail.com") (:keywords "go" "golang" "refactoring") (:url . "https://github.com/microamp/godoctor.el"))]) @@ -2191,8 +2197,8 @@ (gpt . [(20231112 2012) ((emacs (24 4))) "Run instruction-following language models" tar ((:commit . "c1091d25db420320de4b121baba99d7ac2e23932") (:authors ("Andreas Stuhlmueller" . "andreas@ought.org")) (:maintainers ("Andreas Stuhlmueller" . "andreas@ought.org")) (:maintainer "Andreas Stuhlmueller" . "andreas@ought.org") (:keywords "gpt3" "language" "copilot" "convenience" "tools") (:url . "https://github.com/stuhlmueller/gpt.el"))]) (gpt-commit . [(20230716 331) ((emacs (27 1)) (magit (2 90)) (request (0 3 2))) "Commit messages with GPT in Emacs" tar ((:commit . "8a8883be2051eed499c5bc3035a75ff56d64d5ff") (:authors ("Youngwook Kim" . "youngwook.kim@gmail.com")) (:maintainers ("Youngwook Kim" . "youngwook.kim@gmail.com")) (:maintainer "Youngwook Kim" . "youngwook.kim@gmail.com") (:url . "https://github.com/ywkim/gpt-commit"))]) (gptai . [(20230530 1853) ((emacs (24 1))) "Integrate with the OpenAI API" tar ((:commit . "e7b8b91b425986868e8bc0edcac384ba47d4d4b7") (:authors ("Anton Hibl" . "antonhibl11@gmail.com")) (:maintainers ("Anton Hibl" . "antonhibl11@gmail.com")) (:maintainer "Anton Hibl" . "antonhibl11@gmail.com") (:keywords "comm" "convenience") (:url . "https://github.com/antonhibl/gptai"))]) - (gptel . [(20240520 1943) ((emacs (27 1)) (transient (0 4 0)) (compat (29 1 4 1))) "Interact with ChatGPT or other LLMs" tar ((:commit . "3bce2caa5dc773d1b1fce53e8453d2e1ce534b8b") (:authors ("Karthik Chikmagalur" . "karthik.chikmagalur@gmail.com")) (:maintainers ("Karthik Chikmagalur" . "karthik.chikmagalur@gmail.com")) (:maintainer "Karthik Chikmagalur" . "karthik.chikmagalur@gmail.com") (:keywords "convenience") (:url . "https://github.com/karthink/gptel"))]) - (gpx . [(20240513 1737) ((emacs (27 1))) "Major mode for GPX files" tar ((:commit . "b79baf93040fb5c89e803848e8aff31331ea03b8") (:authors ("Michał Krzywkowski" . "k.michal@zoho.com")) (:maintainers ("Michał Krzywkowski" . "k.michal@zoho.com")) (:maintainer "Michał Krzywkowski" . "k.michal@zoho.com") (:keywords "data" "tools") (:url . "https://github.com/mkcms/gpx-mode"))]) + (gptel . [(20240527 5) ((emacs (27 1)) (transient (0 4 0)) (compat (29 1 4 1))) "Interact with ChatGPT or other LLMs" tar ((:commit . "c0603cb973d160f3e450a0dec49dc5ae948f614c") (:authors ("Karthik Chikmagalur" . "karthik.chikmagalur@gmail.com")) (:maintainers ("Karthik Chikmagalur" . "karthik.chikmagalur@gmail.com")) (:maintainer "Karthik Chikmagalur" . "karthik.chikmagalur@gmail.com") (:keywords "convenience") (:url . "https://github.com/karthink/gptel"))]) + (gpx . [(20240525 1603) ((emacs (27 1))) "Major mode for GPX files" tar ((:commit . "b7cfc0f7ec53808f48c070f9c811934a7afcc580") (:authors ("Michał Krzywkowski" . "k.michal@zoho.com")) (:maintainers ("Michał Krzywkowski" . "k.michal@zoho.com")) (:maintainer "Michał Krzywkowski" . "k.michal@zoho.com") (:keywords "data" "tools") (:url . "https://github.com/mkcms/gpx-mode"))]) (grab-mac-link . [(20210511 1303) ((emacs (24))) "Grab link from Mac Apps and insert it into Emacs" tar ((:commit . "5fdb03bf57bc4a530374b896e0f8b5139dc794e3") (:authors ("Xu Chunyang")) (:maintainers ("Xu Chunyang")) (:maintainer "Xu Chunyang") (:keywords "mac" "hyperlink") (:url . "https://github.com/xuchunyang/grab-mac-link.el"))]) (grab-x-link . [(20191113 848) ((emacs (24)) (cl-lib (0 5))) "Grab links from X11 apps and insert into Emacs" tar ((:commit . "d898db46e4864118359fdedfe915e180de3fe290") (:authors ("Xu Chunyang" . "mail@xuchunyang.me")) (:maintainers ("Xu Chunyang" . "mail@xuchunyang.me")) (:maintainer "Xu Chunyang" . "mail@xuchunyang.me") (:keywords "hyperlink") (:url . "https://github.com/xuchunyang/grab-x-link"))]) (gradle-mode . [(20150313 1905) ((s (1 8 0))) "Gradle integration with Emacs' compile" tar ((:commit . "579de06674551919cddac9cfe42129f4fb0155c9") (:authors ("Daniel Mijares" . "daniel.j.mijares@gmail.com")) (:maintainers ("Daniel Mijares" . "daniel.j.mijares@gmail.com")) (:maintainer "Daniel Mijares" . "daniel.j.mijares@gmail.com") (:keywords "gradle") (:url . "http://github.com/jacobono/emacs-gradle-mode"))]) @@ -2233,7 +2239,7 @@ (gtk-pomodoro-indicator . [(20191007 1500) nil "A pomodoro indicator for the GTK tray" tar ((:commit . "cb026a595de8a9244b16e06876f10c60dce18676") (:authors ("Oleh Krehel" . "ohwoeowho@gmail.com")) (:maintainers ("Oleh Krehel" . "ohwoeowho@gmail.com")) (:maintainer "Oleh Krehel" . "ohwoeowho@gmail.com") (:keywords "convenience" "pomodoro") (:url . "https://github.com/abo-abo/gtk-pomodoro-indicator"))]) (gtk-variant . [(20200416 2136) ((emacs (25 1))) "Set the GTK theme variant (titlebar color)" tar ((:commit . "a60af277fbb52306c17663074cf9954dd6cea024") (:authors ("Paul Oppenheimer")) (:maintainers ("Paul Oppenheimer")) (:maintainer "Paul Oppenheimer") (:keywords "frames" "gtk" "titlebar") (:url . "https://github.com/bepvte/gtk-variant.el"))]) (guake . [(20221029 1811) ((emacs (27 1))) "Interact with Guake via DBus" tar ((:commit . "2753ce833b95bd1f042ac0e4b7adfe34975a88ed") (:authors ("Jürgen Hötzel" . "juergen.hoetzel@hr.de")) (:maintainers ("Jürgen Hötzel" . "juergen.hoetzel@hr.de")) (:maintainer "Jürgen Hötzel" . "juergen.hoetzel@hr.de") (:keywords "convenience") (:url . "https://github.com/juergenhoetzel/emacs-guake"))]) - (guess-language . [(20220408 1545) ((cl-lib (0 5)) (emacs (24))) "Robust automatic language detection" tar ((:commit . "b1fc363ca2c30b8a8ddaf2e366bca7770c8cfbec") (:authors ("Titus von der Malsburg" . "malsburg@posteo.de")) (:maintainers ("Titus von der Malsburg" . "malsburg@posteo.de")) (:maintainer "Titus von der Malsburg" . "malsburg@posteo.de") (:keywords "wp") (:url . "https://github.com/tmalsburg/guess-language.el"))]) + (guess-language . [(20240528 1319) ((cl-lib (0 5)) (emacs (24))) "Robust automatic language detection" tar ((:commit . "a17203d26135b970e4d7c5d101955d41303a758f") (:authors ("Titus von der Malsburg" . "malsburg@posteo.de")) (:maintainers ("Titus von der Malsburg" . "malsburg@posteo.de")) (:maintainer "Titus von der Malsburg" . "malsburg@posteo.de") (:keywords "wp") (:url . "https://github.com/tmalsburg/guess-language.el"))]) (guide-key . [(20150108 635) ((dash (2 10 0)) (popwin (0 3 0)) (s (1 9 0))) "Guide the following key bindings automatically and dynamically" tar ((:commit . "9236d287a7272e307fb941237390a96037c8c0a2") (:authors ("Tsunenobu Kai" . "kai2nenobu@gmail.com")) (:maintainers ("Tsunenobu Kai" . "kai2nenobu@gmail.com")) (:maintainer "Tsunenobu Kai" . "kai2nenobu@gmail.com") (:keywords "help" "convenience") (:url . "https://github.com/kai2nenobu/guide-key"))]) (guide-key-tip . [(20161011 823) ((guide-key (1 2 3)) (pos-tip (0 4 5))) "Show guide-key.el hints using pos-tip.el" tar ((:commit . "02c5d4b0b65f3e91be5a47f0ff1ae5e86e00c64e") (:authors ("Hiroaki Otsu" . "ootsuhiroaki@gmail.com")) (:maintainers ("Hiroaki Otsu" . "ootsuhiroaki@gmail.com")) (:maintainer "Hiroaki Otsu" . "ootsuhiroaki@gmail.com") (:keywords "help" "convenience" "tooltip") (:url . "https://github.com/aki2o/guide-key-tip"))]) (guix . [(20231206 2147) ((emacs (24 3)) (dash (2 11 0)) (geiser (0 8)) (bui (1 2 0)) (magit-popup (2 1 0)) (edit-indirect (0 1 4))) "Interface for GNU Guix" tar ((:commit . "455272c5cc72ed4ba5bad13c669f024f51479a58") (:authors ("Alex Kost" . "alezost@gmail.com")) (:maintainers ("Alex Kost" . "alezost@gmail.com")) (:maintainer "Alex Kost" . "alezost@gmail.com") (:keywords "tools") (:url . "https://emacs-guix.gitlab.io/website/"))]) @@ -2245,8 +2251,8 @@ (gxref . [(20170411 1753) ((emacs (25))) "xref backend using GNU Global." tar ((:commit . "380b02c3c3c2586c828456716eef6a6392bb043b") (:authors ("Dedi Hirschfeld")) (:maintainers ("Dedi Hirschfeld")) (:maintainer "Dedi Hirschfeld") (:keywords "xref" "global" "tools") (:url . "https://github.com/dedi/gxref"))]) (h5dump-mode . [(20221128 1935) ((emacs (25 1))) "Major mode for navigating h5dump output" tar ((:commit . "3c9e4608112da91db76bf316417023bed0422ef3") (:authors ("Eric Berquist")) (:maintainers ("Eric Berquist")) (:maintainer "Eric Berquist") (:keywords "languages" "hdf5") (:url . "https://github.com/berquist/h5dump-mode"))]) (habamax-theme . [(20181001 850) ((emacs (24))) "Boring white background color that gets the job done." tar ((:commit . "6e86a1b23b6e2aaf40d4374b5673da00a28be447") (:authors ("Maxim Kim" . "habamax@gmail.com")) (:maintainers ("Maxim Kim" . "habamax@gmail.com")) (:maintainer "Maxim Kim" . "habamax@gmail.com") (:url . "https://github.com/habamax/habamax-theme"))]) - (habitica . [(20220215 1758) ((org (8 3 5)) (emacs (24 3))) "Interface for habitica.com" tar ((:commit . "9e1fde7f359f7f6a6976b857fbbdbc8dd4fd3327") (:authors ("Adrien Brochard")) (:maintainers ("Adrien Brochard")) (:maintainer "Adrien Brochard") (:keywords "habitica" "todo") (:url . "https://github.com/abrochard/emacs-habitica"))]) - (hack-mode . [(20230227 1950) ((emacs (25 1)) (s (1 11 0))) "Major mode for the Hack programming language" tar ((:commit . "278e4cc4032bff92060496cf1179643cfc6f9c0f") (:authors ("John Allen <jallen@fb.com>, Wilfred Hughes" . "me@wilfred.me.uk")) (:maintainers ("John Allen <jallen@fb.com>, Wilfred Hughes" . "me@wilfred.me.uk")) (:maintainer "John Allen <jallen@fb.com>, Wilfred Hughes" . "me@wilfred.me.uk") (:url . "https://github.com/hhvm/hack-mode"))]) + (habitica . [(20240601 2029) ((org (8 3 5)) (emacs (24 3))) "Interface for habitica.com" tar ((:commit . "b884301058c075e6f530f10e970b744aa29f5937") (:authors ("Adrien Brochard")) (:maintainers ("Adrien Brochard")) (:maintainer "Adrien Brochard") (:keywords "habitica" "todo") (:url . "https://github.com/abrochard/emacs-habitica"))]) + (hack-mode . [(20240524 1838) ((emacs (25 1)) (s (1 11 0))) "Major mode for the Hack programming language" tar ((:commit . "ccf20511f0f2ed45d00d423c703bb91ab6a8b80c") (:authors ("John Allen <jallen@fb.com>, Wilfred Hughes" . "me@wilfred.me.uk")) (:maintainers ("John Allen <jallen@fb.com>, Wilfred Hughes" . "me@wilfred.me.uk")) (:maintainer "John Allen <jallen@fb.com>, Wilfred Hughes" . "me@wilfred.me.uk") (:url . "https://github.com/hhvm/hack-mode"))]) (hacker-typer . [(20170206 1520) ((emacs (24))) "Pretend to write code like a pro" tar ((:commit . "d5a23714a4ccc5071580622f278597d5973f40bd") (:authors ("Diego A. Mundo" . "diegoamundo@gmail.com")) (:maintainers ("Diego A. Mundo" . "diegoamundo@gmail.com")) (:maintainer "Diego A. Mundo" . "diegoamundo@gmail.com") (:keywords "hacker" "typer" "multimedia" "games") (:url . "http://github.com/therockmandolinist/emacs-hacker-typer"))]) (hackernews . [(20240405 807) nil "Hacker News Client for Emacs" tar ((:commit . "7c1e9de10fd6b299d45b383302d223d7e3285da9") (:authors ("Lincoln de Sousa" . "lincoln@clarete.li")) (:maintainers ("Basil L. Contovounesios" . "basil@contovou.net")) (:maintainer "Basil L. Contovounesios" . "basil@contovou.net") (:keywords "comm" "hypermedia" "news") (:url . "https://github.com/clarete/hackernews.el"))]) (haki-theme . [(20240501 1610) ((emacs (27 1))) "An elegant, high-contrast dark theme in modern sense" tar ((:commit . "e076785ca936b723751b8957c5d5eab8dde12346") (:authors ("Dilip")) (:maintainers ("Dilip")) (:maintainer "Dilip") (:keywords "faces" "theme" "accessibility") (:url . "https://github.com/idlip/haki"))]) @@ -2270,7 +2276,7 @@ (haskell-emacs . [(20240205 2225) nil "Write emacs extensions in haskell" tar ((:commit . "777d5209f70229b53e4a60a09d1b714d233b0a7c") (:authors ("Florian Knupfer")) (:maintainers ("Florian Knupfer")) (:maintainer "Florian Knupfer") (:keywords "haskell" "emacs" "ffi") (:url . "https://github.com/knupfer/haskell-emacs"))]) (haskell-emacs-base . [(20160904 2026) ((haskell-emacs (2 4 0))) "Haskell functions from Prelude" tar ((:commit . "a2c6a079175904689eed7c6c200754bfa85d1ed9") (:authors ("Florian Knupfer")) (:maintainers ("Florian Knupfer")) (:maintainer "Florian Knupfer") (:keywords "haskell" "emacs" "ffi") (:url . "https://github.com/knupfer/haskell-emacs/modules/base"))]) (haskell-emacs-text . [(20160904 2026) ((haskell-emacs (2 4 0))) "Haskell functions from Data.Text" tar ((:commit . "a2c6a079175904689eed7c6c200754bfa85d1ed9") (:authors ("Florian Knupfer")) (:maintainers ("Florian Knupfer")) (:maintainer "Florian Knupfer") (:keywords "haskell" "emacs" "ffi") (:url . "https://github.com/knupfer/haskell-emacs/modules/text"))]) - (haskell-mode . [(20240116 1718) ((emacs (25 1))) "A Haskell editing mode" tar ((:commit . "43b4036bf02b02de75643a1a2a31e28efac1c50b") (:keywords "haskell" "cabal" "ghc" "repl" "languages") (:url . "https://github.com/haskell/haskell-mode"))]) + (haskell-mode . [(20240527 853) ((emacs (25 1))) "A Haskell editing mode" tar ((:commit . "727f72a2a4b8e4fd0a7b62129668baea55a2c3e0") (:keywords "haskell" "cabal" "ghc" "repl" "languages") (:url . "https://github.com/haskell/haskell-mode"))]) (haskell-snippets . [(20210228 344) ((cl-lib (0 5)) (yasnippet (0 8 0))) "Yasnippets for Haskell" tar ((:commit . "1c29c4a68ce89848b8d371c6510d1de3b586c8b3") (:authors ("Luke Hoersten" . "luke@hoersten.org")) (:maintainers ("Luke Hoersten" . "luke@hoersten.org")) (:maintainer "Luke Hoersten" . "luke@hoersten.org") (:keywords "snippets" "haskell") (:url . "https://github.com/haskell/haskell-snippets"))]) (haskell-tab-indent . [(20200514 1424) nil "tab-based indentation for haskell-mode" tar ((:commit . "1127f46eca40a48be9cd2380df2cfc5f0b694e63") (:authors ("Sean Whitton" . "spwhitton@spwhitton.name")) (:maintainers ("Sean Whitton" . "spwhitton@spwhitton.name")) (:maintainer "Sean Whitton" . "spwhitton@spwhitton.name") (:keywords "indentation" "haskell") (:url . "https://spwhitton.name/tech/code/haskell-tab-indent/"))]) (hasklig-mode . [(20240102 333) ((emacs (25))) "Hasklig ligatures" tar ((:commit . "9933e55765f006322c7db4ff41c1c5789295768f") (:authors ("Daniel Mendler")) (:maintainers ("Daniel Mendler")) (:maintainer "Daniel Mendler") (:url . "https://github.com/minad/hasklig-mode"))]) @@ -2285,7 +2291,7 @@ (headlong . [(20150417 1526) nil "reckless completion" tar ((:commit . "f6830f87f236eee88263cb6976125f72422abe72") (:authors ("Oleh Krehel" . "ohwoeowho@gmail.com")) (:maintainers ("Oleh Krehel" . "ohwoeowho@gmail.com")) (:maintainer "Oleh Krehel" . "ohwoeowho@gmail.com") (:keywords "completion") (:url . "https://github.com/abo-abo/headlong"))]) (heaven-and-hell . [(20190713 1830) ((emacs (24 4))) "easy toggle light/dark themes" tar ((:commit . "e1febfd60d060c110a1e43c5f093cd8537251308") (:authors ("Valentin Ignatev" . "valentignatev@gmail.com")) (:maintainers ("Valentin Ignatev" . "valentignatev@gmail.com")) (:maintainer "Valentin Ignatev" . "valentignatev@gmail.com") (:keywords "faces") (:url . "https://github.com/valignatev/heaven-and-hell"))]) (heex-ts-mode . [(20240113 1104) ((emacs (29 1))) "Major mode for Heex with tree-sitter support" tar ((:commit . "90142df2929956536dc1eaae3bb5ca04dc4232ab") (:authors ("Wilhelm H Kirschbaum")) (:maintainers ("Wilhelm H Kirschbaum")) (:maintainer "Wilhelm H Kirschbaum") (:keywords "heex" "languages" "tree-sitter") (:url . "https://github.com/wkirschbaum/elixir-ts-mode"))]) - (helm . [(20240521 1457) ((helm-core (3 9 8)) (wfnames (1 1)) (popup (0 5 3))) "Helm is an Emacs incremental and narrowing framework" tar ((:commit . "c65a9039b6574183aa3f3e0b647c85470c002339") (:authors ("Thierry Volpiatto" . "thievol@posteo.net")) (:maintainers ("Thierry Volpiatto" . "thievol@posteo.net")) (:maintainer "Thierry Volpiatto" . "thievol@posteo.net") (:url . "https://emacs-helm.github.io/helm/"))]) + (helm . [(20240530 1546) ((helm-core (3 9 9)) (wfnames (1 2))) "Helm is an Emacs incremental and narrowing framework" tar ((:commit . "aa51c1a8d6ff4e1e88e61e989f41ac3aa808a592") (:authors ("Thierry Volpiatto" . "thievol@posteo.net")) (:maintainers ("Thierry Volpiatto" . "thievol@posteo.net")) (:maintainer "Thierry Volpiatto" . "thievol@posteo.net") (:url . "https://emacs-helm.github.io/helm/"))]) (helm-R . [(20120820 14) ((helm (20120517)) (ess (20120509))) "helm-sources and some utilities for GNU R." tar ((:commit . "b0eb9d5f6a483a9dbe6eb6cf1f2024d4f5938bc2") (:authors ("myuhe <yuhei.maeda_at_gmail.com>")) (:maintainers ("myuhe")) (:maintainer "myuhe") (:keywords "convenience") (:url . "https://github.com/myuhe/helm-R.el"))]) (helm-ack . [(20141030 1226) ((helm (1 0)) (cl-lib (0 5))) "Ack command with helm interface" tar ((:commit . "5982f3cb6ec9f460ebbe06ec0ce7b3590bca3118") (:authors ("Syohei YOSHIDA" . "syohex@gmail.com")) (:maintainers ("Syohei YOSHIDA" . "syohex@gmail.com")) (:maintainer "Syohei YOSHIDA" . "syohex@gmail.com") (:url . "https://github.com/syohex/emacs-helm-ack"))]) (helm-ad . [(20151209 1015) ((dash (2 8 0)) (helm (1 6 2))) "helm source for Active Directory" tar ((:commit . "8ac044705d8620ee354a9cfa8cc1b865e83c0d55") (:authors ("Takahiro Noda" . "takahiro.noda+github@gmail.com")) (:maintainers ("Takahiro Noda" . "takahiro.noda+github@gmail.com")) (:maintainer "Takahiro Noda" . "takahiro.noda+github@gmail.com") (:keywords "comm"))]) @@ -2319,7 +2325,7 @@ (helm-comint . [(20231102 2029) ((emacs (25 1)) (helm (3 9 4))) "Comint prompt navigation for helm" tar ((:commit . "9215b2aa8f42f62cbda66a1503832abb7f491549") (:authors ("Pierre Neidhardt" . "mail@ambrevar.xyz")) (:maintainers ("Benedict Wang" . "foss@bhw.name")) (:maintainer "Benedict Wang" . "foss@bhw.name") (:keywords "processes" "matching") (:url . "https://github.com/benedicthw/helm-comint.git"))]) (helm-commandlinefu . [(20150611 545) ((emacs (24 1)) (helm (1 7 0)) (json (1 3)) (let-alist (1 0 3))) "Search and browse commandlinefu.com from helm" tar ((:commit . "9ee7e018c5db23ae9c8d1c8fa969876f15b7280d") (:authors ("Chunyang Xu" . "xuchunyang56@gmail.com")) (:maintainers ("Chunyang Xu" . "xuchunyang56@gmail.com")) (:maintainer "Chunyang Xu" . "xuchunyang56@gmail.com") (:keywords "commandlinefu.com") (:url . "https://github.com/xuchunyang/helm-commandlinefu"))]) (helm-company . [(20231113 701) ((helm (1 5 9)) (company (0 10 0))) "Helm interface for company-mode" tar ((:commit . "4622b82353220ee6cc33468f710fa5b6b253b7f1") (:authors ("Yasuyuki Oka" . "yasuyk@gmail.com")) (:maintainers ("Daniel Ralston" . "Sodel-the-Vociferous@users.noreply.github.com")) (:maintainer "Daniel Ralston" . "Sodel-the-Vociferous@users.noreply.github.com") (:url . "https://github.com/Sodel-the-Vociferous/helm-company"))]) - (helm-core . [(20240518 1434) ((emacs (25 1)) (async (1 9 7))) "Development files for Helm" tar ((:commit . "ba2eb552353635222f14984b8a2f4456b4ac62e2") (:authors ("Thierry Volpiatto" . "thievol@posteo.net")) (:maintainers ("Thierry Volpiatto" . "thievol@posteo.net")) (:maintainer "Thierry Volpiatto" . "thievol@posteo.net") (:url . "https://emacs-helm.github.io/helm/"))]) + (helm-core . [(20240530 1546) ((emacs (25 1)) (async (1 9 8))) "Development files for Helm" tar ((:commit . "aa51c1a8d6ff4e1e88e61e989f41ac3aa808a592") (:authors ("Thierry Volpiatto" . "thievol@posteo.net")) (:maintainers ("Thierry Volpiatto" . "thievol@posteo.net")) (:maintainer "Thierry Volpiatto" . "thievol@posteo.net") (:url . "https://emacs-helm.github.io/helm/"))]) (helm-cscope . [(20190615 41) ((xcscope (1 0)) (helm (1 6 7)) (cl-lib (0 5)) (emacs (24 1))) "Helm interface for xcscope.el." tar ((:commit . "af1d9e7f4460a88d7400b5a74d5da68084089ac1") (:authors ("alpha22jp" . "alpha22jp@gmail.com")) (:maintainers ("alpha22jp" . "alpha22jp@gmail.com")) (:maintainer "alpha22jp" . "alpha22jp@gmail.com") (:keywords "cscope" "helm") (:url . "https://github.com/alpha22jp/helm-cscope.el"))]) (helm-css-scss . [(20230522 1113) ((emacs (24 3)) (helm (1 0))) "CSS/SCSS/LESS Selectors with helm interface" tar ((:commit . "2169d83d8fdc661241df208cb3235112735d936e") (:authors ("Shingo Fukuyama - http://fukuyama.co")) (:maintainers ("Shingo Fukuyama - http://fukuyama.co")) (:maintainer "Shingo Fukuyama - http://fukuyama.co") (:keywords "convenience" "scss" "css" "less" "selector" "helm") (:url . "https://github.com/ShingoFukuyama/helm-css-scss"))]) (helm-ctest . [(20220721 400) ((s (1 9 0)) (dash (2 11 0)) (helm-core (3 6 0))) "Run ctest from within emacs" tar ((:commit . "48edc9fa862219da34feb423c06c33d8f6d43722") (:authors ("Dan LaManna" . "me@danlamanna.com")) (:maintainers ("Dan LaManna" . "me@danlamanna.com")) (:maintainer "Dan LaManna" . "me@danlamanna.com") (:keywords "helm" "ctest"))]) @@ -2551,7 +2557,7 @@ (html-to-hiccup . [(20230727 1013) ((emacs (25 1)) (s (1 10 0))) "Convert HTML to Hiccup syntax" tar ((:commit . "6879354b8f33ca0c35cf0929581d419cd0ec9ea1") (:authors ("Arne Brasseur" . "arne@arnebrasseur.net")) (:maintainers ("Arne Brasseur" . "arne@arnebrasseur.net")) (:maintainer "Arne Brasseur" . "arne@arnebrasseur.net") (:keywords "html" "hiccup" "clojure" "convenience" "tools") (:url . "https://github.com/plexus/html-to-hiccup"))]) (html-to-markdown . [(20151105 840) ((cl-lib (0 5))) "HTML to Markdown converter written in Emacs-lisp." tar ((:commit . "60c5498c801be186478cf7c05be05b4430c4a144") (:authors ("Artur Malabarba" . "bruce.connor.am@gmail.com")) (:maintainers ("Artur Malabarba" . "bruce.connor.am@gmail.com")) (:maintainer "Artur Malabarba" . "bruce.connor.am@gmail.com") (:keywords "tools" "wp" "languages") (:url . "http://github.com/Bruce-Connor/html-to-markdown"))]) (html2org . [(20170418 501) ((emacs (24 4))) "Convert html to org format text" tar ((:commit . "6904aed40259ad8afccff079ebd8a07bff319ebc") (:authors ("DarkSun" . "lujun9972@gmail.com")) (:maintainers ("DarkSun" . "lujun9972@gmail.com")) (:maintainer "DarkSun" . "lujun9972@gmail.com") (:keywords "convenience" "html" "org") (:url . "http://github.com/lujun9972/html2org.el"))]) - (htmlize . [(20240422 1351) ((emacs (25 1))) "Convert buffer text and decorations to HTML." tar ((:commit . "54ac89c5edc7a83344cf51d8be08e1e701f88863") (:authors ("Hrvoje Niksic" . "hniksic@gmail.com")) (:maintainers ("Hrvoje Niksic" . "hniksic@gmail.com")) (:maintainer "Hrvoje Niksic" . "hniksic@gmail.com") (:keywords "hypermedia" "extensions") (:url . "https://github.com/hniksic/emacs-htmlize"))]) + (htmlize . [(20240527 1456) ((emacs (25 1))) "Convert buffer text and decorations to HTML." tar ((:commit . "ed5e5b05fd260e8f161a488d56f10e7f6e01fb75") (:authors ("Hrvoje Niksic" . "hniksic@gmail.com")) (:maintainers ("Hrvoje Niksic" . "hniksic@gmail.com")) (:maintainer "Hrvoje Niksic" . "hniksic@gmail.com") (:keywords "hypermedia" "extensions") (:url . "https://github.com/hniksic/emacs-htmlize"))]) (htmltagwrap . [(20240120 1010) ((emacs (24 4))) "Wraps a chunk of HTML code in tags" tar ((:commit . "96f89ec74e39903d8ed1f87f261032778c19694a") (:authors ("Shen, Jen-Chieh" . "jcs090218@gmail.com")) (:maintainers ("Shen, Jen-Chieh" . "jcs090218@gmail.com")) (:maintainer "Shen, Jen-Chieh" . "jcs090218@gmail.com") (:url . "https://github.com/emacs-vs/htmltagwrap"))]) (http . [(20201010 920) ((emacs (24 4)) (request (0 2 0)) (edit-indirect (0 1 4))) "Yet another HTTP client" tar ((:commit . "5fdceed1fbf36e274e578e349a53ce922c574774") (:authors ("Mario Rodas" . "marsam@users.noreply.github.com")) (:maintainers ("Mario Rodas" . "marsam@users.noreply.github.com")) (:maintainer "Mario Rodas" . "marsam@users.noreply.github.com") (:keywords "convenience") (:url . "https://github.com/emacs-pe/http.el"))]) (http-post-simple . [(20170715 940) nil "HTTP POST requests using the url library" tar ((:commit . "f53697fca278c741051aeb668b00466b5e0fd3fe") (:authors ("Tom Schutzer-Weissmann")) (:maintainers ("Tom Schutzer-Weissmann")) (:maintainer "Tom Schutzer-Weissmann") (:keywords "comm" "data" "processes" "hypermedia"))]) @@ -2570,17 +2576,18 @@ (hydandata-light-theme . [(20190809 1925) nil "A light color theme that is easy on your eyes" tar ((:commit . "812ffa4bee3163098ef66ee4506feed45018be4e") (:authors ("David Chkhikvadze" . "david@chkhd.net")) (:maintainers ("David Chkhikvadze" . "david@chkhd.net")) (:maintainer "David Chkhikvadze" . "david@chkhd.net") (:keywords "color-theme" "theme") (:url . "https://github.com/chkhd/hydandata-light-theme"))]) (hyde . [(20160508 308) nil "Major mode to help create and manage Jekyll blogs" tar ((:commit . "a8cd6ed00ecd8d7de0ded2f4867015b412b15b76"))]) (hydra . [(20220910 1206) ((cl-lib (0 5)) (lv (0))) "Make bindings that stick around." tar ((:commit . "317e1de33086637579a7aeb60f77ed0405bf359b") (:authors ("Oleh Krehel" . "ohwoeowho@gmail.com")) (:maintainers ("Oleh Krehel" . "ohwoeowho@gmail.com")) (:maintainer "Oleh Krehel" . "ohwoeowho@gmail.com") (:keywords "bindings") (:url . "https://github.com/abo-abo/hydra"))]) - (hyperbole . [(20240519 1800) ((emacs (27 1))) "GNU Hyperbole: The Everyday Hypertextual Information Manager" tar ((:commit . "61937530ea3713b37ed34b8ad62331a507ccf8c6") (:authors ("Robert Weiner" . "rsw@gnu.org")) (:maintainers ("Mats Lidell" . "matsl@gnu.org")) (:maintainer "Mats Lidell" . "matsl@gnu.org") (:keywords "comm" "convenience" "files" "frames" "hypermedia" "languages" "mail" "matching" "mouse" "multimedia" "outlines" "tools" "wp") (:url . "http://www.gnu.org/software/hyperbole"))]) - (hyperdrive . [(20240519 640) ((emacs (28 1)) (map (3 0)) (compat (29 1 4 4)) (plz (0 7 2)) (persist (0 6)) (taxy-magit-section (0 13)) (transient (0 6 0))) "P2P filesystem" tar ((:commit . "261277b30ff560ec40158ee45e380b0200d22fbf") (:authors ("Joseph Turner" . "joseph@ushin.org")) (:maintainers ("Joseph Turner" . "~ushin/ushin@lists.sr.ht")) (:maintainer "Joseph Turner" . "~ushin/ushin@lists.sr.ht") (:url . "https://git.sr.ht/~ushin/hyperdrive.el"))]) + (hyperbole . [(20240602 811) ((emacs (27 1))) "GNU Hyperbole: The Everyday Hypertextual Information Manager" tar ((:commit . "c3050387ea625842e2fa93fa9d7f44bd8d0c1e35") (:authors ("Robert Weiner" . "rsw@gnu.org")) (:maintainers ("Mats Lidell" . "matsl@gnu.org")) (:maintainer "Mats Lidell" . "matsl@gnu.org") (:keywords "comm" "convenience" "files" "frames" "hypermedia" "languages" "mail" "matching" "mouse" "multimedia" "outlines" "tools" "wp") (:url . "http://www.gnu.org/software/hyperbole"))]) + (hyperdrive . [(20240531 2312) ((emacs (28 1)) (map (3 0)) (compat (29 1 4 4)) (plz (0 7 2)) (persist (0 6)) (taxy-magit-section (0 13)) (transient (0 6 0))) "P2P filesystem" tar ((:commit . "bb7a699a4bc44ffa448ceddfd4cb89a0c6bc93aa") (:authors ("Joseph Turner" . "joseph@ushin.org")) (:maintainers ("Joseph Turner" . "~ushin/ushin@lists.sr.ht")) (:maintainer "Joseph Turner" . "~ushin/ushin@lists.sr.ht") (:url . "https://git.sr.ht/~ushin/hyperdrive.el"))]) (hyperkitty . [(20220226 1951) ((request (0 3 2)) (emacs (25 1))) "Emacs interface for Hyperkitty archives" tar ((:commit . "2c1d22ff017d096c359aa151e6a29f7214a58118") (:authors ("Abhilash Raj" . "maxking@asynchronous.in")) (:maintainers ("Abhilash Raj" . "maxking@asynchronous.in")) (:maintainer "Abhilash Raj" . "maxking@asynchronous.in") (:keywords "mail" "hyperkitty" "mailman") (:url . "https://github.com/maxking/hyperkitty.el"))]) (hyperlist-mode . [(20230119 28) ((emacs (24))) "A major-mode for viewing Hyperlists" tar ((:commit . "480dbf33ca72e7b5fade952aaf0d5a5eb43acb1d") (:authors ("Wojciech Siewierski")) (:maintainers ("Wojciech Siewierski")) (:maintainer "Wojciech Siewierski") (:keywords "outlines") (:url . "https://github.com/vifon/hyperlist-mode"))]) (hyperspace . [(20230518 442) ((emacs (25)) (s (1 12 0))) "Get there from here" tar ((:commit . "f574d07fd8715e806ba4f0487b73c699963baed3") (:authors ("Ian Eure" . "ian@retrospec.tv")) (:maintainers ("Ian Eure" . "ian@retrospec.tv")) (:maintainer "Ian Eure" . "ian@retrospec.tv") (:keywords "tools" "convenience") (:url . "https://github.com/ieure/hyperspace-el"))]) + (hyperstitional-themes . [(20240528 2016) ((emacs (24 1))) "Weird themes with incremental palettes" tar ((:commit . "e87e4ca39384c75398c64c920bf4cbc253f6740b") (:authors ("precompute" . "git@precompute.net")) (:maintainers ("precompute" . "git@precompute.net")) (:maintainer "precompute" . "git@precompute.net") (:url . "https://github.com/precompute/hyperstitional-themes"))]) (i-ching . [(20230530 937) ((emacs (25 1)) (request (0 3))) "The Book of Changes" tar ((:commit . "2f1e8393b09f926188eb640604f5bc637707315e") (:authors ("nik gaffney" . "nik@fo.am")) (:maintainers ("nik gaffney" . "nik@fo.am")) (:maintainer "nik gaffney" . "nik@fo.am") (:keywords "games" "divination" "stochastism" "cleromancy" "change") (:url . "https://github.com/zzkt/i-ching"))]) (i2b2-mode . [(20140710 104) nil "Highlights corresponding PHI data in the text portion of an i2b2 XML Document." tar ((:commit . "db10efcfc8bed369a516bbf7526ede41f98cb95a") (:authors ("Dan LaManna" . "dan.lamanna@gmail.com")) (:maintainers ("Dan LaManna" . "dan.lamanna@gmail.com")) (:maintainer "Dan LaManna" . "dan.lamanna@gmail.com") (:keywords "xml" "phi" "i2b2" "deidi2b2"))]) (i3bar . [(20230724 305) ((emacs (28 1))) "Display status from an i3status command in the tab bar" tar ((:commit . "82efd5c87a3b3e9bcb5257c0a678f861f24e477e") (:authors ("Steven Allen" . "steven@stebalien.com")) (:maintainers ("Steven Allen" . "steven@stebalien.com")) (:maintainer "Steven Allen" . "steven@stebalien.com") (:keywords "unix") (:url . "https://github.com/Stebalien/i3bar.el"))]) (i3wm . [(20170822 1438) nil "i3wm integration library" tar ((:commit . "71391dc61063fee77ad174f3b2ca25c60b41009e") (:authors ("Samuel W. Flint" . "swflint@flintfam.org")) (:maintainers ("Samuel W. Flint" . "swflint@flintfam.org")) (:maintainer "Samuel W. Flint" . "swflint@flintfam.org") (:keywords "convenience" "extensions") (:url . "https://git.flintfam.org/swf-projects/emacs-i3"))]) (i3wm-config-mode . [(20220913 1121) ((emacs (24 1))) "Better syntax highlighting for i3wm's config file" tar ((:commit . "188e3978807ec39eba3cb69d973c0062af324215") (:authors ("Alexander Miller" . "alexanderm@web.de")) (:maintainers ("Alexander Miller" . "alexanderm@web.de")) (:maintainer "Alexander Miller" . "alexanderm@web.de") (:keywords "faces" "languages" "i3wm" "font-lock") (:url . "https://github.com/Alexander-Miller/i3wm-Config-Mode"))]) - (ialign . [(20240326 1233) ((emacs (24 4))) "visual align-regexp" tar ((:commit . "764aea597b8c9292da2d91294bb6a70e7ad7d6d7") (:authors ("Michał Krzywkowski" . "k.michal@zoho.com")) (:maintainers ("Michał Krzywkowski" . "k.michal@zoho.com")) (:maintainer "Michał Krzywkowski" . "k.michal@zoho.com") (:keywords "tools" "editing" "align" "interactive") (:url . "https://github.com/mkcms/interactive-align"))]) + (ialign . [(20240531 2023) ((emacs (25 1))) "visual align-regexp" tar ((:commit . "96043dff1c542d15cccf5df46b778927fcf5680d") (:authors ("Michał Krzywkowski" . "k.michal@zoho.com")) (:maintainers ("Michał Krzywkowski" . "k.michal@zoho.com")) (:maintainer "Michał Krzywkowski" . "k.michal@zoho.com") (:keywords "tools" "editing" "align" "interactive") (:url . "https://github.com/mkcms/interactive-align"))]) (iasm-mode . [(20171023 1422) nil "interactive assembly major mode." tar ((:commit . "abbec7f308f9ce97beeb57e459fff35f559b4c18") (:authors ("Rémi Attab" . "remi.attab@gmail.com")) (:maintainers ("Rémi Attab" . "remi.attab@gmail.com")) (:maintainer "Rémi Attab" . "remi.attab@gmail.com") (:keywords ":" "tools") (:url . "https://github.com/RAttab/iasm-mode"))]) (ibrowse . [(20230926 2056) ((emacs (27 1))) "Interact with your browser" tar ((:commit . "addfec54f2c33d505d10bb5f17c084876db5baed") (:authors ("Nicolas Graves" . "ngraves@ngraves.fr")) (:maintainers ("Nicolas Graves" . "ngraves@ngraves.fr")) (:maintainer "Nicolas Graves" . "ngraves@ngraves.fr") (:keywords "comm" "data" "files" "tools") (:url . "https://git.sr.ht/~ngraves/ibrowse.el"))]) (ibuffer-git . [(20110508 731) nil "show git status in ibuffer column" tar ((:commit . "d326319c05ddb8280885b31f9094040c1b365876") (:authors ("Jonathan Rockway" . "jon@jrock.us")) (:maintainers ("Jonathan Rockway" . "jon@jrock.us")) (:maintainer "Jonathan Rockway" . "jon@jrock.us") (:keywords "convenience"))]) @@ -2624,7 +2631,7 @@ (iedit . [(20220216 717) nil "Edit multiple regions in the same way simultaneously." tar ((:commit . "dd5d75b38ee0c52ad81245a8e5c932d3f5c4772d") (:authors ("Victor Ren" . "victorhge@gmail.com")) (:maintainers ("Victor Ren" . "victorhge@gmail.com")) (:maintainer "Victor Ren" . "victorhge@gmail.com") (:keywords "occurrence" "region" "simultaneous" "refactoring") (:url . "https://github.com/victorhge/iedit"))]) (ietf-docs . [(20190420 851) nil "Fetch, Cache and Load IETF documents" tar ((:commit . "ae157549eae5ec78dcbf215c2f48cb662b73abd0") (:authors ("Christian E. Hopps" . "chopps@gmail.com")) (:maintainers ("Christian E. Hopps" . "chopps@gmail.com")) (:maintainer "Christian E. Hopps" . "chopps@gmail.com") (:keywords "ietf" "rfc") (:url . "https://github.com/choppsv1/ietf-docs"))]) (iflipb . [(20220612 858) nil "Interactively flip between recently visited buffers" tar ((:commit . "9ec1888335107bd314e8f40b3e113d525fed8083") (:authors ("Joel Rosdahl" . "joel@rosdahl.net")) (:maintainers ("Joel Rosdahl" . "joel@rosdahl.net")) (:maintainer "Joel Rosdahl" . "joel@rosdahl.net") (:url . "https://github.com/jrosdahl/iflipb"))]) - (igist . [(20240322 953) ((emacs (27 1)) (ghub (3 6 0)) (transient (0 4 1))) "List, create, update and delete GitHub gists" tar ((:commit . "051a58085cd9593665c59c75208cc10189b53504") (:authors ("Karim Aziiev" . "karim.aziiev@gmail.com")) (:maintainers ("Karim Aziiev" . "karim.aziiev@gmail.com")) (:maintainer "Karim Aziiev" . "karim.aziiev@gmail.com") (:keywords "tools") (:url . "https://github.com/KarimAziev/igist"))]) + (igist . [(20240520 1402) ((emacs (27 1)) (ghub (3 6 0)) (transient (0 4 1))) "List, create, update and delete GitHub gists" tar ((:commit . "126e9924f698b97c932f7edb1628aad44e8445b3") (:authors ("Karim Aziiev" . "karim.aziiev@gmail.com")) (:maintainers ("Karim Aziiev" . "karim.aziiev@gmail.com")) (:maintainer "Karim Aziiev" . "karim.aziiev@gmail.com") (:keywords "tools") (:url . "https://github.com/KarimAziev/igist"))]) (ignoramus . [(20220611 1514) ((emacs (24 3))) "Ignore backups, build files, et al." tar ((:commit . "f5e4a66191be12c2fc3cf42a5e0849fcc8518a3f") (:authors ("Roland Walker" . "walker@pobox.com")) (:maintainers ("Roland Walker" . "walker@pobox.com")) (:maintainer "Roland Walker" . "walker@pobox.com") (:keywords "convenience" "tools") (:url . "http://github.com/rolandwalker/ignoramus"))]) (igv . [(20141210 1227) nil "Control Integrative Genomic Viewer within Emacs" tar ((:commit . "47ac6ceede252f451348a2c696398c0cb5279555") (:authors ("Stefano Barbi" . "stefanobarbi@gmail.com")) (:maintainers ("Stefano Barbi" . "stefanobarbi@gmail.com")) (:maintainer "Stefano Barbi" . "stefanobarbi@gmail.com"))]) (image+ . [(20150707 1616) ((cl-lib (0 3))) "Image manipulate extensions for Emacs" tar ((:commit . "6834d0c09bb4df9ecc0d7a559bd7827fed48fffc") (:authors ("Masahiro Hayashi" . "mhayashi1120@gmail.com")) (:maintainers ("Masahiro Hayashi" . "mhayashi1120@gmail.com")) (:maintainer "Masahiro Hayashi" . "mhayashi1120@gmail.com") (:keywords "multimedia" "extensions") (:url . "https://github.com/mhayashi1120/Emacs-imagex"))]) @@ -2648,7 +2655,7 @@ (import-js . [(20220215 1948) ((grizzl (0 1 0)) (emacs (24))) "Import Javascript dependencies" tar ((:commit . "d2bbb53f96395415f9f01de4fa88d82c1f59ba63") (:authors ("Kevin Kehl" . "kevin.kehl@gmail.com")) (:maintainers ("Kevin Kehl" . "kevin.kehl@gmail.com")) (:maintainer "Kevin Kehl" . "kevin.kehl@gmail.com") (:keywords "javascript") (:url . "http://github.com/Galooshi/emacs-import-js/"))]) (import-popwin . [(20170218 1407) ((emacs (24 3)) (popwin (0 6))) "popwin buffer near by import statements with popwin" tar ((:commit . "bb05a9e226f8c63fe7b18a3e92010357049ab5ba") (:authors ("Syohei YOSHIDA" . "syohex@gmail.com")) (:maintainers ("Syohei YOSHIDA" . "syohex@gmail.com")) (:maintainer "Syohei YOSHIDA" . "syohex@gmail.com") (:url . "https://github.com/syohex/emacs-import-popwin"))]) (importmagic . [(20180520 303) ((f (0 11 0)) (epc (0 1 0)) (emacs (24 3))) "Fix Python imports using importmagic." tar ((:commit . "e32ee9f6a5eef937b76eba82fdae8bae85d18088") (:authors ("Nicolás Salas V." . "nikosalas@gmail.com")) (:maintainers ("Nicolás Salas V." . "nikosalas@gmail.com")) (:maintainer "Nicolás Salas V." . "nikosalas@gmail.com") (:keywords "languages" "convenience") (:url . "https://github.com/anachronic/importmagic.el"))]) - (impostman . [(20230111 2012) ((emacs (27 1))) "Import Postman collections" tar ((:commit . "936575500f733c2428ba878f9400f3eef8c9645e") (:authors ("Sébastien Helleu" . "flashcode@flashtux.org")) (:maintainers ("Sébastien Helleu" . "flashcode@flashtux.org")) (:maintainer "Sébastien Helleu" . "flashcode@flashtux.org") (:keywords "tools") (:url . "https://github.com/flashcode/impostman"))]) + (impostman . [(20240524 847) ((emacs (27 1))) "Import Postman collections" tar ((:commit . "c0d7b5b0950fd8113f55a02b3ee7e0fc9c431bea") (:authors ("Sébastien Helleu" . "flashcode@flashtux.org")) (:maintainers ("Sébastien Helleu" . "flashcode@flashtux.org")) (:maintainer "Sébastien Helleu" . "flashcode@flashtux.org") (:keywords "tools") (:url . "https://github.com/flashcode/impostman"))]) (indent-control . [(20240512 503) ((emacs (26 1))) "Management for indentation level" tar ((:commit . "bf4863c9f7d1d5cadf47b78bebbafc5431361597") (:authors ("Shen, Jen-Chieh" . "jcs090218@gmail.com")) (:maintainers ("Shen, Jen-Chieh" . "jcs090218@gmail.com")) (:maintainer "Shen, Jen-Chieh" . "jcs090218@gmail.com") (:keywords "convenience" "control" "indent" "tab" "generic" "level") (:url . "https://github.com/jcs-elpa/indent-control"))]) (indent-guide . [(20210115 400) nil "show vertical lines to guide indentation" tar ((:commit . "d388c3387781a370ca13233ff445d03f3c5cf12f") (:authors ("zk_phi")) (:maintainers ("zk_phi")) (:maintainer "zk_phi") (:url . "http://hins11.yu-yake.com/"))]) (indent-info . [(20210111 745) ((emacs (24 3))) "Show indentation information in status bar" tar ((:commit . "05a787afeb9946714d8b0c724868195a678db49e") (:authors ("Terje Larsen" . "terlar@gmail.com")) (:maintainers ("Terje Larsen" . "terlar@gmail.com")) (:maintainer "Terje Larsen" . "terlar@gmail.com") (:keywords "convenience" "tools") (:url . "https://github.com/terlar/indent-info.el"))]) @@ -2732,7 +2739,7 @@ (iterator . [(20210109 1859) ((emacs (24)) (cl-lib (0 5))) "A library to create and use elisp iterators objects." tar ((:commit . "b514d4d1d0167e5973afbc93a34070d1aa967d82") (:authors ("Thierry Volpiatto <thierry dot volpiatto at gmail dot com>")) (:maintainers ("Thierry Volpiatto <thierry dot volpiatto at gmail dot com>")) (:maintainer "Thierry Volpiatto <thierry dot volpiatto at gmail dot com>") (:url . "https://github.com/thierryvolpiatto/iterator"))]) (ivariants . [(20170823 224) ((emacs (24 3)) (ivs-edit (1 0))) "Ideographic variants editor and browser" tar ((:commit . "ca0b74d32b5d2d77a45cc6ad6edc00be0ee85284") (:authors ("KAWABATA, Taichi <kawabata.taichi_at_gmail.com>")) (:maintainers ("KAWABATA, Taichi <kawabata.taichi_at_gmail.com>")) (:maintainer "KAWABATA, Taichi <kawabata.taichi_at_gmail.com>") (:keywords "i18n" "languages") (:url . "http://github.com/kawabata/ivariants"))]) (ivs-edit . [(20170818 1441) ((emacs (24 3)) (dash (2 6 0)) (cl-lib (1 0))) "IVS (Ideographic Variation Sequence) editing tool" tar ((:commit . "5db39c234aa7393b591168a4fd0a9a4cbbca347d") (:authors ("KAWABATA, Taichi <kawabata.taichi_at_gmail.com>")) (:maintainers ("KAWABATA, Taichi <kawabata.taichi_at_gmail.com>")) (:maintainer "KAWABATA, Taichi <kawabata.taichi_at_gmail.com>") (:keywords "text") (:url . "http://github.com/kawabata/ivs-edit"))]) - (ivy . [(20240519 1636) ((emacs (24 5))) "Incremental Vertical completYon" tar ((:commit . "6a98b006f140b588490c24c5f794aac4250bf300") (:authors ("Oleh Krehel" . "ohwoeowho@gmail.com")) (:maintainers ("Basil L. Contovounesios" . "basil@contovou.net")) (:maintainer "Basil L. Contovounesios" . "basil@contovou.net") (:keywords "matching") (:url . "https://github.com/abo-abo/swiper"))]) + (ivy . [(20240524 1139) ((emacs (24 5))) "Incremental Vertical completYon" tar ((:commit . "2a25a6fb5b081cb141c5eccac8ee58ab1feeb747") (:authors ("Oleh Krehel" . "ohwoeowho@gmail.com")) (:maintainers ("Basil L. Contovounesios" . "basil@contovou.net")) (:maintainer "Basil L. Contovounesios" . "basil@contovou.net") (:keywords "matching") (:url . "https://github.com/abo-abo/swiper"))]) (ivy-avy . [(20240214 2118) ((emacs (24 5)) (ivy (0 14 2)) (avy (0 5 0))) "Avy integration for Ivy" tar ((:commit . "749ac1235a7948011cb0caddd4c31037e3314614") (:authors ("Oleh Krehel" . "ohwoeowho@gmail.com")) (:maintainers ("Basil L. Contovounesios" . "basil@contovou.net")) (:maintainer "Basil L. Contovounesios" . "basil@contovou.net") (:keywords "convenience") (:url . "https://github.com/abo-abo/swiper"))]) (ivy-bibtex . [(20210927 1205) ((bibtex-completion (1 0 0)) (ivy (0 13 0)) (cl-lib (0 5))) "A bibliography manager based on Ivy" tar ((:commit . "bb47f355b0da8518aa3fb516019120c14c8747c9") (:authors ("Justin Burkett" . "justin@burkett.cc")) (:maintainers ("Titus von der Malsburg" . "malsburg@posteo.de")) (:maintainer "Titus von der Malsburg" . "malsburg@posteo.de") (:url . "https://github.com/tmalsburg/helm-bibtex"))]) (ivy-clipmenu . [(20220202 2122) ((emacs (26 1)) (f (0 20 0)) (s (1 12 0)) (dash (2 16 0)) (ivy (0 13 0))) "Ivy client for clipmenu" tar ((:commit . "7c200cd4732821187084fad23547ee3f58365062") (:authors ("William Carroll" . "wpcarro@gmail.com")) (:maintainers ("William Carroll" . "wpcarro@gmail.com")) (:maintainer "William Carroll" . "wpcarro@gmail.com") (:url . "https://github.com/wpcarro/ivy-clipmenu.el"))]) @@ -2767,7 +2774,7 @@ (ivy-youtube . [(20230503 1509) ((request (0 2 0)) (ivy (0 8 0)) (cl-lib (0 5))) "Query YouTube and play videos in your browser" tar ((:commit . "e7a7cc860e967500857e5fd85d8e397c6d752ee1") (:authors ("Brunno dos Santos")) (:maintainers ("Brunno dos Santos")) (:maintainer "Brunno dos Santos") (:keywords "youtube" "multimedia" "mpv" "vlc") (:url . "https://github.com/squiter/ivy-youtube"))]) (ix . [(20131027 1657) ((grapnel (0 5 3))) "Emacs client for http://ix.io pastebin" tar ((:commit . "498dac674f4f1910d39087b1457c5da5465a0614") (:authors ("Abhishek L" . "abhishekl.2006@gmail.com")) (:maintainers ("Abhishek L" . "abhishekl.2006@gmail.com")) (:maintainer "Abhishek L" . "abhishekl.2006@gmail.com") (:url . "http://www.github.com/theanalyst/ix.el"))]) (j-mode . [(20171224 1856) nil "Major mode for editing J programs" tar ((:commit . "e8725ac8af95498faabb2ca3ab3bd809a8f148e6") (:keywords "j" "languages") (:url . "http://github.com/zellio/j-mode"))]) - (jabber . [(20240521 633) ((emacs (27 1)) (fsm (0 2)) (srv (0 2))) "A Jabber client for Emacs." tar ((:commit . "9e7bebfe76d2ed529d66942b602ac4348e0cc61f") (:authors ("Magnus Henoch" . "mange@freemail.hu")) (:maintainer "wgreenhouse" . "wgreenhouse@tilde.club") (:keywords "comm") (:url . "https://codeberg.org/emacs-jabber/emacs-jabber"))]) + (jabber . [(20240525 206) ((emacs (27 1)) (fsm (0 2)) (srv (0 2))) "A Jabber client for Emacs." tar ((:commit . "306e96589263c266b9d3738b33cf55be1a91240a") (:authors ("Magnus Henoch" . "mange@freemail.hu")) (:maintainer "wgreenhouse" . "wgreenhouse@tilde.club") (:keywords "comm") (:url . "https://codeberg.org/emacs-jabber/emacs-jabber"))]) (jack . [(20221122 632) ((emacs (28 1))) "HTML generator library" tar ((:commit . "3b4ea97fcc107d0ffd201ea695129af52f390113") (:authors ("Tony Aldon" . "tony.aldon.adm@gmail.com")) (:maintainers ("Tony Aldon" . "tony.aldon.adm@gmail.com")) (:maintainer "Tony Aldon" . "tony.aldon.adm@gmail.com") (:keywords "lisp" "html") (:url . "https://github.com/tonyaldon/jack"))]) (jack-connect . [(20220201 1417) nil "Manage jack connections within Emacs" tar ((:commit . "1acaebfe8f37f0194e95c3e812c9515a6f688eee") (:authors ("Stefano Barbi" . "stefanobarbi@gmail.com")) (:maintainers ("Stefano Barbi" . "stefanobarbi@gmail.com")) (:maintainer "Stefano Barbi" . "stefanobarbi@gmail.com"))]) (jack-ts-mode . [(20231110 1615) ((emacs (29 1))) "Major mode for jack buffers using tree-sitter" tar ((:commit . "f57f211d96608a90142619a925caeb8808e7c632") (:authors ("Noah Peart" . "noah.v.peart@gmail.com")) (:maintainers ("Noah Peart" . "noah.v.peart@gmail.com")) (:maintainer "Noah Peart" . "noah.v.peart@gmail.com") (:keywords "tree-sitter" "languages" "jack" "nand2tetris") (:url . "https://github.com/nverno/jack-ts-mode"))]) @@ -2818,7 +2825,7 @@ (journalctl-mode . [(20240219 2115) ((emacs (27 1))) "Sample major mode for viewing output journalctl" tar ((:commit . "631d10a5c8f466c94c38c3cd7410a27026f5f822") (:authors ("Sebastian Meisel" . "sebastian.meisel@gmail.com")) (:maintainers ("Sebastian Meisel" . "sebastian.meisel@gmail.com")) (:maintainer "Sebastian Meisel" . "sebastian.meisel@gmail.com") (:keywords "unix") (:url . "https://github.com/SebastianMeisel/journalctl-mode"))]) (jpop . [(20170410 1250) ((emacs (24)) (dash (2 11 0)) (cl-lib (0 5))) "Lightweight project caching and navigation framework" tar ((:commit . "7628b03260be96576b34459d45959ee77d8b2110") (:authors ("Dom Charlesworth" . "dgc336@gmail.com")) (:maintainers ("Dom Charlesworth" . "dgc336@gmail.com")) (:maintainer "Dom Charlesworth" . "dgc336@gmail.com") (:keywords "project" "convenience") (:url . "https://github.com/domtronn/jpop.el"))]) (jq-format . [(20190428 1434) ((emacs (24)) (reformatter (0 3))) "Reformat JSON and JSONLines using jq" tar ((:commit . "47e1c5adb89b37b4d53fe01302d8c675913c20e7") (:authors ("wouter bolsterlee" . "wouter@bolsterl.ee")) (:maintainers ("wouter bolsterlee" . "wouter@bolsterl.ee")) (:maintainer "wouter bolsterlee" . "wouter@bolsterl.ee") (:keywords "languages") (:url . "https://github.com/wbolster/emacs-jq-format"))]) - (jq-mode . [(20240304 911) ((emacs (25 1))) "Edit jq scripts." tar ((:commit . "d533567a680bc87060c56a50f83d80e58646d2f2") (:authors ("Bjarte Johansen <Bjarte dot Johansen at gmail dot com>")) (:maintainers ("Bjarte Johansen <Bjarte dot Johansen at gmail dot com>")) (:maintainer "Bjarte Johansen <Bjarte dot Johansen at gmail dot com>") (:url . "https://github.com/ljos/jq-mode"))]) + (jq-mode . [(20240528 752) ((emacs (25 1))) "Edit jq scripts." tar ((:commit . "a0f79eba786d46f01aeabb5913aadc337e985d6c") (:authors ("Bjarte Johansen <Bjarte dot Johansen at gmail dot com>")) (:maintainers ("Bjarte Johansen <Bjarte dot Johansen at gmail dot com>")) (:maintainer "Bjarte Johansen <Bjarte dot Johansen at gmail dot com>") (:url . "https://github.com/ljos/jq-mode"))]) (jq-ts-mode . [(20240305 1511) ((emacs (29 1))) "Tree-sitter support for jq buffers" tar ((:commit . "9e6a2aab79a973e1200b8e4b5e6f1762b29b0dec") (:authors ("Noah Peart" . "noah.v.peart@gmail.com")) (:maintainers ("Noah Peart" . "noah.v.peart@gmail.com")) (:maintainer "Noah Peart" . "noah.v.peart@gmail.com") (:keywords "jq" "languages" "tree-sitter") (:url . "https://github.com/nverno/jq-ts-mode"))]) (jquery-doc . [(20150812 758) nil "jQuery api documentation interface for emacs" tar ((:commit . "24032284919b942ec27707d929bdd8bf48420062") (:authors ("Anantha kumaran" . "ananthakumaran@gmail.com")) (:maintainers ("Anantha kumaran" . "ananthakumaran@gmail.com")) (:maintainer "Anantha kumaran" . "ananthakumaran@gmail.com") (:keywords "docs" "jquery"))]) (js-auto-beautify . [(20161031 509) ((web-beautify (0 3 1)) (web-mode (14 0 27))) "auto format you js/jsx file" tar ((:commit . "6bc9fef474197ca1722cb1e9051b270f80cdd7cc") (:authors (nil . "quanwei9958@126.com")) (:maintainers (nil . "quanwei9958@126.com")) (:maintainer nil . "quanwei9958@126.com"))]) @@ -2840,7 +2847,7 @@ (jsfmt . [(20180920 1008) nil "Interface to jsfmt command for javascript files" tar ((:commit . "ca141a135c7700eaedef92561d334e1fb7dc28a1") (:authors ("Brett Langdon" . "brett@blangdon.com")) (:maintainers ("Brett Langdon" . "brett@blangdon.com")) (:maintainer "Brett Langdon" . "brett@blangdon.com") (:url . "https://github.com/brettlangdon/jsfmt.el"))]) (json-mode . [(20240427 1245) ((json-snatcher (1 0 0)) (emacs (24 4))) "Major mode for editing JSON files" tar ((:commit . "77125b01c0ddce537085201098bea9b4b8ba6be3") (:authors ("Josh Johnston") ("taku0")) (:maintainers ("Josh Johnston")) (:maintainer "Josh Johnston") (:url . "https://github.com/joshwnj/json-mode"))]) (json-navigator . [(20230904 1757) ((emacs (25 1)) (hierarchy (0 6 0))) "View and navigate JSON structures" tar ((:commit . "f3489153e8509f88296786cb00e31f59597a43f2") (:authors ("Damien Cassou" . "damien@cassou.me")) (:maintainers ("Damien Cassou" . "damien@cassou.me")) (:maintainer "Damien Cassou" . "damien@cassou.me") (:url . "https://github.com/DamienCassou/json-navigator"))]) - (json-par . [(20240217 550) ((emacs (24 4)) (json-mode (1 7 0))) "Minor mode for structural editing of JSON" tar ((:commit . "52f69108d4eca328f7eb74c2dfb841db2f0ffa8a") (:authors ("taku0" . "mxxouy6x3m_github@tatapa.org")) (:maintainers ("taku0" . "mxxouy6x3m_github@tatapa.org")) (:maintainer "taku0" . "mxxouy6x3m_github@tatapa.org") (:keywords "abbrev" "convenience" "files") (:url . "https://github.com/taku0/json-par"))]) + (json-par . [(20240601 1234) ((emacs (24 4)) (json-mode (1 7 0))) "Minor mode for structural editing of JSON" tar ((:commit . "3b057977748abc6fc0cba221ede903096d7c7248") (:authors ("taku0" . "mxxouy6x3m_github@tatapa.org")) (:maintainers ("taku0" . "mxxouy6x3m_github@tatapa.org")) (:maintainer "taku0" . "mxxouy6x3m_github@tatapa.org") (:keywords "abbrev" "convenience" "files") (:url . "https://github.com/taku0/json-par"))]) (json-process-client . [(20230903 1305) ((emacs (27 1))) "Interact with a TCP process using JSON" tar ((:commit . "c4385859ada9b7803698a1f0199fea7fc8880214") (:authors ("Nicolas Petton" . "nicolas@petton.fr") ("Damien Cassou" . "damien@cassou.me")) (:maintainers ("Nicolas Petton" . "nicolas@petton.fr")) (:maintainer "Nicolas Petton" . "nicolas@petton.fr") (:url . "https://gitlab.petton.fr/nico/json-process-client"))]) (json-reformat . [(20220905 2342) ((emacs (24 3))) "Reformatting tool for JSON" tar ((:commit . "e9999b1f1fc933c02ff44f4136602b6a45ed59c6") (:authors ("Wataru MIYAGUNI" . "gonngo@gmail.com")) (:maintainers ("Wataru MIYAGUNI" . "gonngo@gmail.com")) (:maintainer "Wataru MIYAGUNI" . "gonngo@gmail.com") (:keywords "json") (:url . "https://github.com/gongo/json-reformat"))]) (json-rpc . [(20200417 1629) ((emacs (24 1)) (cl-lib (0 5))) "JSON-RPC library" tar ((:commit . "81a5a520072e20d18aeab2aac4d66c046b031e56") (:authors ("Christopher Wellons" . "wellons@nullprogram.com")) (:maintainers ("Christopher Wellons" . "wellons@nullprogram.com")) (:maintainer "Christopher Wellons" . "wellons@nullprogram.com") (:url . "https://github.com/skeeto/elisp-json-rpc"))]) @@ -2868,7 +2875,7 @@ (jumplist . [(20151120 345) ((cl-lib (0 5))) "Jump like vim jumplist or ex jumplist" tar ((:commit . "c482d137d95bc5e1bcd790cdbde25b7f729b2502") (:authors ("ganmacs <ganmacs_at_gmail.com>")) (:maintainers ("ganmacs <ganmacs_at_gmail.com>")) (:maintainer "ganmacs <ganmacs_at_gmail.com>") (:keywords "jumplist" "vim") (:url . "https://github.com/ganmacs/jumplist"))]) (jupyter . [(20240418 1642) ((emacs (26)) (cl-lib (0 5)) (org (9 1 6)) (zmq (0 10 10)) (simple-httpd (1 5 0)) (websocket (1 9))) "Jupyter" tar ((:commit . "f1394d303be76a1fa44d4135b4f3ceab9387a16b") (:authors ("Nathaniel Nicandro" . "nathanielnicandro@gmail.com")) (:maintainers ("Nathaniel Nicandro" . "nathanielnicandro@gmail.com")) (:maintainer "Nathaniel Nicandro" . "nathanielnicandro@gmail.com") (:url . "https://github.com/emacs-jupyter/jupyter"))]) (just-mode . [(20240424 1809) ((emacs (26 1))) "Justfile editing mode" tar ((:commit . "4c0df4cc4b8798f1a7e99fb78b79c4bf7eec12c1") (:authors ("Leon Barrett" . "leon@barrettnexus.com")) (:maintainers ("Leon Barrett" . "leon@barrettnexus.com")) (:maintainer "Leon Barrett" . "leon@barrettnexus.com") (:keywords "files" "languages" "tools") (:url . "https://github.com/leon-barrett/just-mode.el"))]) - (justl . [(20240224 428) ((transient (0 1 0)) (emacs (27 1)) (s (1 2 0)) (f (0 20 0)) (inheritenv (0 2))) "Major mode for driving just files" tar ((:commit . "1b16ca44b227dc761a2c8631690140f62e024f98") (:authors ("Sibi Prabakaran")) (:maintainers ("Sibi Prabakaran")) (:maintainer "Sibi Prabakaran") (:keywords "just" "justfile" "tools" "processes") (:url . "https://github.com/psibi/justl.el"))]) + (justl . [(20240523 232) ((transient (0 1 0)) (emacs (27 1)) (s (1 2 0)) (f (0 20 0)) (inheritenv (0 2))) "Major mode for driving just files" tar ((:commit . "bc7d00966f95c7a9cb519eeeaa3f258f854a7342") (:authors ("Sibi Prabakaran")) (:maintainers ("Sibi Prabakaran")) (:maintainer "Sibi Prabakaran") (:keywords "just" "justfile" "tools" "processes") (:url . "https://github.com/psibi/justl.el"))]) (jvm-mode . [(20150422 708) ((dash (2 6 0)) (emacs (24))) "Monitor and manage your JVMs" tar ((:commit . "3355dbaf5b0185aadfbad24160399abb32c5bea0") (:authors ("Martin Trojer" . "martin.trojer@gmail.com")) (:maintainers ("Martin Trojer" . "martin.trojer@gmail.com")) (:maintainer "Martin Trojer" . "martin.trojer@gmail.com") (:keywords "convenience") (:url . "https://github.com/martintrojer/jvm-mode.el"))]) (k8s-mode . [(20230305 1039) ((emacs (24 3)) (yaml-mode (0 0 10))) "Major mode for Kubernetes configuration file" tar ((:commit . "83266cecd6a39cdf57d124270646047860bfb7ab") (:authors ("Giap Tran" . "txgvnn@gmail.com")) (:maintainers ("Giap Tran" . "txgvnn@gmail.com")) (:maintainer "Giap Tran" . "txgvnn@gmail.com") (:url . "https://github.com/TxGVNN/emacs-k8s-mode"))]) (kaesar . [(20230626 2314) ((emacs (24 3)) (kaesar-pbkdf2 (0 9 0))) "AES algorithm encrypt/decrypt" tar ((:commit . "740eaea4d2510b78d30cceabf4be2c3daca66cf7") (:authors ("Masahiro Hayashi" . "mhayashi1120@gmail.com")) (:maintainers ("Masahiro Hayashi" . "mhayashi1120@gmail.com")) (:maintainer "Masahiro Hayashi" . "mhayashi1120@gmail.com") (:keywords "data") (:url . "https://github.com/mhayashi1120/Emacs-kaesar"))]) @@ -2881,10 +2888,9 @@ (kaleidoscope . [(20170808 817) ((s (1 11 0))) "Controlling Kaleidoscope-powered devices." tar ((:commit . "b89a243f6024099192f1bc38d8a54e3e7a654090") (:authors ("Gergely Nagy")) (:maintainers ("Gergely Nagy")) (:maintainer "Gergely Nagy") (:url . "https://github.com/algernon/kaleidoscope.el"))]) (kaleidoscope-evil-state-flash . [(20170728 1020) ((evil (1 2 12)) (kaleidoscope (0 1 0)) (s (1 11 0))) "Flash keyboard LEDs when changing Evil state" tar ((:commit . "5b88327350c3d6375ef1d43fb31342eaabd88fdc") (:authors ("Gergely Nagy")) (:maintainers ("Gergely Nagy")) (:maintainer "Gergely Nagy") (:url . "https://github.com/algernon/kaleidoscope.el"))]) (kana . [(20210531 1427) ((emacs (24 4)) (dash (2 17 0))) "Learn Japanese hiragana and katakana" tar ((:commit . "d3d550aad67ef8625b3860598bf3622f5b2a7d32") (:authors ("Damon Chan" . "elecming@gmail.com")) (:maintainers ("Damon Chan" . "elecming@gmail.com")) (:maintainer "Damon Chan" . "elecming@gmail.com") (:keywords "tools") (:url . "https://github.com/chenyanming/kana"))]) - (kanagawa-theme . [(20240501 38) ((emacs (24 3))) "An elegant theme inspired by The Great Wave off Kanagawa by Katsushika Hokusa" tar ((:commit . "3ac33b6a4c7c7ad751ec8f264aa05f135b5d953d") (:authors ("Raime Filianore" . "meritamen@sdf.org")) (:maintainers ("Raime Filianore" . "meritamen@sdf.org")) (:maintainer "Raime Filianore" . "meritamen@sdf.org") (:keywords "themes" "faces") (:url . "https://github.com/meritamen/emacs-kanagawa-theme"))]) (kanban . [(20230210 1505) nil "Parse org-todo headlines to use org-tables as Kanban tables" tar ((:commit . "d70fa7acab2bfcbb7d3da43c1343073f7eff4998") (:authors ("Arne Babenhauserheide" . "arne_bab@web.de")) (:maintainers ("Arne Babenhauserheide" . "arne_bab@web.de")) (:maintainer "Arne Babenhauserheide" . "arne_bab@web.de") (:keywords "outlines" "convenience"))]) (kanji-mode . [(20230928 1113) nil "View stroke order for kanji characters at cursor" tar ((:commit . "731b3a5447bcb899ba1d86b645a344e0915d04f3") (:authors ("Wojciech Gac" . "wojciech.s.gac@gmail.com")) (:maintainers ("Wojciech Gac" . "wojciech.s.gac@gmail.com")) (:maintainer "Wojciech Gac" . "wojciech.s.gac@gmail.com") (:url . "http://github.com/wsgac/kanji-mode "))]) - (kaocha-runner . [(20240410 1348) ((emacs (26)) (s (1 4 0)) (cider (0 21 0)) (parseedn (0 1 0))) "A package for running Kaocha tests via CIDER." tar ((:commit . "ab5b4f32c733e238bdf08e10cab9a0606675faa4") (:authors ("Magnar Sveen" . "magnars@gmail.com")) (:maintainers ("Magnar Sveen" . "magnars@gmail.com")) (:maintainer "Magnar Sveen" . "magnars@gmail.com") (:url . "https://github.com/magnars/kaocha-runner.el"))]) + (kaocha-runner . [(20240523 619) ((emacs (26)) (s (1 4 0)) (cider (0 21 0)) (parseedn (0 1 0))) "A package for running Kaocha tests via CIDER." tar ((:commit . "e5071ce09ec2d8c700bac91c902318035c5489bf") (:authors ("Magnar Sveen" . "magnars@gmail.com")) (:maintainers ("Magnar Sveen" . "magnars@gmail.com")) (:maintainer "Magnar Sveen" . "magnars@gmail.com") (:url . "https://github.com/magnars/kaocha-runner.el"))]) (kaolin-themes . [(20240507 1430) ((emacs (25 1)) (autothemer (0 2 2)) (cl-lib (0 6))) "A set of eye pleasing themes" tar ((:commit . "ba7a003d7aa5d4681a8464f4dec6ab4e9fb271d2") (:authors ("Ogden Webb" . "ogdenwebb@gmail.com")) (:maintainers ("Ogden Webb" . "ogdenwebb@gmail.com")) (:maintainer "Ogden Webb" . "ogdenwebb@gmail.com") (:keywords "dark" "light" "teal" "blue" "violet" "purple" "brown" "theme" "faces") (:url . "https://github.com/ogdenwebb/emacs-kaolin-themes"))]) (kaomoji . [(20220721 441) ((emacs (24 3)) (helm-core (3 6 0))) "Input kaomoji superb easily" tar ((:commit . "fba0018a13eba70c2bffc6153dcfee99937fa3d6") (:authors ("Ono Hiroko" . "azazabc123@gmail.com")) (:maintainers ("Ono Hiroko" . "azazabc123@gmail.com")) (:maintainer "Ono Hiroko" . "azazabc123@gmail.com") (:keywords "tools" "fun") (:url . "https://github.com/kuanyui/kaomoji.el"))]) (kapacitor . [(20190414 1908) ((emacs (25 1)) (magit (2 13 0)) (magit-popup (2 12 4))) "Main file for kapacitor-mode" tar ((:commit . "e3300d8b4017a2f66b0d929cb85bcc7ee2612072") (:authors ("Manoj Kumar Manikchand" . "manojm.321@gmail.com")) (:maintainers ("Manoj Kumar Manikchand" . "manojm.321@gmail.com")) (:maintainer "Manoj Kumar Manikchand" . "manojm.321@gmail.com") (:keywords "kapacitor" "emacs" "magit" "tools") (:url . "http://github.com/Manoj321/kapacitor-el"))]) @@ -2895,7 +2901,7 @@ (keepass-mode . [(20211030 958) ((emacs (27))) "Mode for KeePass DB." tar ((:commit . "f432bb60f9f3bd027025140d723906dcabeefaef") (:authors ("Ignasi Fosch" . "natx@y10k.ws")) (:maintainer "Ignasi Fosch" . "natx@y10k.ws") (:keywords "data" "files" "tools") (:url . "https://github.com/ifosch/keepass-mode"))]) (keg . [(20230709 1321) ((emacs (24 1))) "Modern Elisp package development system" tar ((:commit . "c0d24fdad4248e0291685b47a02df54e9f980aba") (:authors ("Naoya Yamashita" . "conao3@gmail.com")) (:maintainers ("Naoya Yamashita" . "conao3@gmail.com")) (:maintainer "Naoya Yamashita" . "conao3@gmail.com") (:keywords "convenience") (:url . "https://github.com/conao3/keg.el"))]) (keg-mode . [(20220307 829) ((emacs (24 4))) "Major mode for editing Keg files" tar ((:commit . "d2ef9cfaee1256849291cfade3d730667f55aaf2") (:authors ("Naoya Yamashita" . "conao3@gmail.com")) (:maintainers ("Naoya Yamashita" . "conao3@gmail.com")) (:maintainer "Naoya Yamashita" . "conao3@gmail.com") (:keywords "convenience") (:url . "https://github.com/conao3/keg.el"))]) - (kele . [(20240428 2141) ((emacs (28 1)) (async (1 9 7)) (dash (2 19 1)) (f (0 20 0)) (ht (2 3)) (memoize (0)) (plz (0 7 3)) (s (1 13 0)) (yaml (0 5 1))) "Spritzy Kubernetes cluster management" tar ((:commit . "ee667b6581113be21e7d24935cf8a431eb382432") (:authors ("Jonathan Jin" . "me@jonathanj.in")) (:maintainers ("Jonathan Jin" . "me@jonathanj.in")) (:maintainer "Jonathan Jin" . "me@jonathanj.in") (:keywords "kubernetes" "tools") (:url . "https://github.com/jinnovation/kele.el"))]) + (kele . [(20240602 1257) ((emacs (28 1)) (async (1 9 7)) (dash (2 19 1)) (f (0 20 0)) (ht (2 3)) (memoize (0)) (plz (0 7 3)) (s (1 13 0)) (yaml (0 5 1))) "Spritzy Kubernetes cluster management" tar ((:commit . "294a75a476b1af7a7bd5c7fa46270741cee2fef3") (:authors ("Jonathan Jin" . "me@jonathanj.in")) (:maintainers ("Jonathan Jin" . "me@jonathanj.in")) (:maintainer "Jonathan Jin" . "me@jonathanj.in") (:keywords "kubernetes" "tools") (:url . "https://github.com/jinnovation/kele.el"))]) (kerl . [(20150424 2005) nil "Emacs integration for kerl" tar ((:commit . "1732ee26213f021bf040919c45ad276aafcaae14") (:authors ("Correl Roush" . "correl@gmail.com")) (:maintainers ("Correl Roush" . "correl@gmail.com")) (:maintainer "Correl Roush" . "correl@gmail.com") (:keywords "tools") (:url . "http://github.com/correl/kerl.el/"))]) (key-assist . [(20231208 446) ((emacs (24 3))) "Minibuffer keybinding cheatsheet and launcher" tar ((:commit . "87d2378db3d997b6b5a7b2c04281c18378e70bbb") (:authors ("Boruch Baum" . "boruch_baum@gmx.com")) (:maintainers ("Boruch Baum" . "boruch_baum@gmx.com")) (:maintainer "Boruch Baum" . "boruch_baum@gmx.com") (:keywords "abbrev" "convenience" "docs" "help") (:url . "https://github.com/Boruch-Baum/emacs-key-assist"))]) (key-chord . [(20240109 1430) ((emacs (24))) "map pairs of simultaneously pressed keys to commands" tar ((:commit . "dbf91fefdad58b1c2f07c92e658ce81490837c60") (:authors ("David Andersson <l.david.andersson(at)sverige.nu>")) (:maintainers ("David Andersson <l.david.andersson(at)sverige.nu>")) (:maintainer "David Andersson <l.david.andersson(at)sverige.nu>") (:keywords "keyboard" "chord" "input"))]) @@ -2917,9 +2923,9 @@ (keytar . [(20240101 846) ((emacs (24 4))) "Emacs Lisp interface for node-keytar" tar ((:commit . "b4fdde53ec884c931db8465b334af6057b30daa1") (:authors ("Shen, Jen-Chieh" . "jcs090218@gmail.com")) (:maintainers ("Shen, Jen-Chieh" . "jcs090218@gmail.com")) (:maintainer "Shen, Jen-Chieh" . "jcs090218@gmail.com") (:keywords "convenience" "keytar" "password" "credential" "secret" "security") (:url . "https://github.com/emacs-grammarly/keytar"))]) (keyword-search . [(20180424 1102) nil "browser keyword search from Emacs" tar ((:commit . "f8475ecaddb8804a9be6bee47678207c86ac8dee") (:maintainers ("Jens Petersen")) (:maintainer "Jens Petersen") (:keywords "web" "search" "keyword") (:url . "https://github.com/juhp/keyword-search"))]) (kfg . [(20140909 538) ((f (0 17 1))) "an emacs configuration system" tar ((:commit . "ffc35b77f227d4c64a1271ec30d31333ffeb0013") (:authors ("Austin Bingham" . "austin.bingham@gmail.com")) (:maintainers ("Austin Bingham" . "austin.bingham@gmail.com")) (:maintainer "Austin Bingham" . "austin.bingham@gmail.com") (:url . "https://github.com/abingham/kfg"))]) - (khalel . [(20240314 1347) ((emacs (27 1))) "Import, edit and create calendar events through khal" tar ((:commit . "9dea9e45ebb2364f9fe873ca773b9324b34b720f") (:authors ("Hanno Perrey <http://gitlab.com/hperrey>")) (:maintainers ("Hanno Perrey" . "hanno@hoowl.se")) (:maintainer "Hanno Perrey" . "hanno@hoowl.se") (:keywords "event" "calendar" "ics" "khal") (:url . "https://gitlab.com/hperrey/khalel"))]) + (khalel . [(20240527 527) ((emacs (27 1))) "Import, edit and create calendar events through khal" tar ((:commit . "14ef50352394cd1d62b80bc17ab14f4f801f47cd") (:authors ("Hanno Perrey <http://gitlab.com/hperrey>")) (:maintainers ("Hanno Perrey" . "hanno@hoowl.se")) (:maintainer "Hanno Perrey" . "hanno@hoowl.se") (:keywords "event" "calendar" "ics" "khal") (:url . "https://gitlab.com/hperrey/khalel"))]) (khardel . [(20231126 1502) ((emacs (27 1)) (yaml-mode (0 0 13))) "Integrate with khard" tar ((:commit . "205e374b36252183a146a7a8f857bcf95a77edc3") (:authors ("Damien Cassou" . "damien@cassou.me")) (:maintainers ("Damien Cassou" . "damien@cassou.me")) (:maintainer "Damien Cassou" . "damien@cassou.me") (:url . "https://github.com/DamienCassou/khardel"))]) - (khoj . [(20240501 1100) ((emacs (27 1)) (transient (0 3 0)) (dash (2 19 1))) "AI copilot for your Second Brain" tar ((:commit . "bc8b92a77dc40c93a5fdf6639f367d814339bbad") (:authors ("Debanjum Singh Solanky" . "debanjum@khoj.dev") ("Saba Imran" . "saba@khoj.dev")) (:maintainers ("Debanjum Singh Solanky" . "debanjum@khoj.dev")) (:maintainer "Debanjum Singh Solanky" . "debanjum@khoj.dev") (:keywords "search" "chat" "org-mode" "outlines" "markdown" "pdf" "image") (:url . "https://github.com/khoj-ai/khoj/tree/master/src/interface/emacs"))]) + (khoj . [(20240524 1612) ((emacs (27 1)) (transient (0 3 0)) (dash (2 19 1))) "AI copilot for your Second Brain" tar ((:commit . "e23c803cee238a95635c9b4ffbf0bde51276b2b4") (:authors ("Debanjum Singh Solanky" . "debanjum@khoj.dev") ("Saba Imran" . "saba@khoj.dev")) (:maintainers ("Debanjum Singh Solanky" . "debanjum@khoj.dev")) (:maintainer "Debanjum Singh Solanky" . "debanjum@khoj.dev") (:keywords "search" "chat" "org-mode" "outlines" "markdown" "pdf" "image") (:url . "https://github.com/khoj-ai/khoj/tree/master/src/interface/emacs"))]) (kibit-helper . [(20150508 1533) ((s (0 8)) (emacs (24))) "Conveniently use the Kibit Leiningen plugin from Emacs" tar ((:commit . "ec5f154db3bb0c838e86f527353f08644cede926") (:authors ("Jonas Enlund") ("James Elliott" . "james@brunchboy.com")) (:maintainers ("Jonas Enlund")) (:maintainer "Jonas Enlund") (:keywords "languages" "clojure" "kibit") (:url . "http://www.github.com/brunchboy/kibit-helper"))]) (kill-file-path . [(20230306 1041) ((emacs (26))) "Copy file name into kill ring" tar ((:commit . "5dcbce69cbae17665216a32dd20f27de54c62972") (:authors ("Adam Chyła" . "adam@chyla.org")) (:maintainers ("Adam Chyła" . "adam@chyla.org")) (:maintainer "Adam Chyła" . "adam@chyla.org") (:keywords "files") (:url . "https://github.com/chyla/kill-file-path/kill-file-path.el"))]) (kill-or-bury-alive . [(20230606 1503) ((emacs (24 4))) "Precise control over buffer killing" tar ((:commit . "16c393db6ad0c7e184af0a24d26b637e23543b1f") (:authors ("Mark Karpov" . "markkarpov92@gmail.com")) (:maintainers ("Mark Karpov" . "markkarpov92@gmail.com")) (:maintainer "Mark Karpov" . "markkarpov92@gmail.com") (:keywords "convenience") (:url . "https://github.com/mrkkrp/kill-or-bury-alive"))]) @@ -3008,7 +3014,7 @@ (leanote . [(20161223 139) ((emacs (24 4)) (cl-lib (0 5)) (request (0 2)) (let-alist (1 0 3)) (pcache (0 4 0)) (s (1 10 0)) (async (1 9))) "A minor mode writing markdown leanote" tar ((:commit . "d499e7b59bb1f1a2fabc0e4c26fb101ed62ebc7b") (:authors ("Aborn Jiang" . "aborn.jiang@gmail.com")) (:maintainers ("Aborn Jiang" . "aborn.jiang@gmail.com")) (:maintainer "Aborn Jiang" . "aborn.jiang@gmail.com") (:keywords "leanote" "note" "markdown") (:url . "https://github.com/aborn/leanote-emacs"))]) (learn-ocaml . [(20211003 1412) ((emacs (25 1))) "Emacs frontend for learn-ocaml" tar ((:commit . "abdc263537a6a534152a4eaaa17b2c3e4e10418b") (:url . "https://github.com/pfitaxel/learn-ocaml.el"))]) (ledger-import . [(20230904 1837) ((emacs (25 1))) "Fetch OFX files from bank and push them to Ledger" tar ((:commit . "e47e8508794462986b982d6ce3d05bcd17c19242") (:authors ("Damien Cassou" . "damien@cassou.me")) (:maintainers ("Damien Cassou" . "damien@cassou.me")) (:maintainer "Damien Cassou" . "damien@cassou.me") (:url . "https://gitlab.petton.fr/mpdel/libmpdel"))]) - (ledger-mode . [(20240423 445) ((emacs (25 1))) "Helper code for use with the \"ledger\" command-line tool" tar ((:commit . "c66e3e9adfb5d91f83a401387fad345f12004c8a"))]) + (ledger-mode . [(20240527 2134) ((emacs (25 1))) "Helper code for use with the \"ledger\" command-line tool" tar ((:commit . "57de7d817296607a9a4721470f64e05c964744da"))]) (leerzeichen . [(20220626 835) nil "Minor mode to display whitespace characters." tar ((:commit . "9d4126d5f6563569080845a69b0867119a9fd6ea") (:authors ("Felix Geller" . "fgeller@gmail.com")) (:maintainers ("Felix Geller" . "fgeller@gmail.com")) (:maintainer "Felix Geller" . "fgeller@gmail.com") (:keywords "whitespace" "characters") (:url . "http://github.com/fgeller/leerzeichen.el"))]) (leetcode . [(20230524 1851) ((emacs (26 1)) (dash (2 16 0)) (graphql (0 1 1)) (spinner (1 7 3)) (aio (1 0)) (log4e (0 3 3))) "An leetcode client" tar ((:commit . "e5701191a98d043acdc7112f28d67e3d5c848228") (:authors ("Wang Kai" . "kaiwkx@gmail.com")) (:maintainers ("Wang Kai" . "kaiwkx@gmail.com")) (:maintainer "Wang Kai" . "kaiwkx@gmail.com") (:keywords "extensions" "tools") (:url . "https://github.com/kaiwk/leetcode.el"))]) (legalese . [(20200119 2248) nil "Add legalese to your program files" tar ((:commit . "e465471d2d5a62d35073d93e0f8d40387a82e302") (:authors ("Jorgen Schaefer" . "forcer@forcix.cx")) (:maintainers ("Jorgen Schaefer" . "forcer@forcix.cx")) (:maintainer "Jorgen Schaefer" . "forcer@forcix.cx") (:keywords "convenience") (:url . "https://github.com/jorgenschaefer/legalese"))]) @@ -3041,7 +3047,7 @@ (ligature . [(20220808 1225) ((emacs (28))) "Display typographical ligatures in major modes" tar ((:commit . "89cbd67a815f61e5001f19d64d6ec1771e867742") (:authors ("Mickey Petersen" . "mickey@masteringemacs.org")) (:maintainers ("Mickey Petersen" . "mickey@masteringemacs.org")) (:maintainer "Mickey Petersen" . "mickey@masteringemacs.org") (:keywords "tools" "faces") (:url . "https://www.github.com/mickeynp/ligature.el"))]) (ligature-pragmatapro . [(20221127 2252) ((emacs (28)) (ligature (1 0))) "PragmataPro support for ligature.el" tar ((:commit . "85f7b15a5cf5f2ee843bc0469e03602a0251c275") (:authors ("Yuri D'Elia" . "wavexx@thregr.org")) (:maintainers ("Yuri D'Elia" . "wavexx@thregr.org")) (:maintainer "Yuri D'Elia" . "wavexx@thregr.org") (:keywords "faces" "fonts" "ligatures" "programming-ligatures") (:url . "https://gitlab.com/wavexx/ligature-pragmatapro.el"))]) (light-soap-theme . [(20150607 1445) ((emacs (24))) "Emacs 24 theme with a light background." tar ((:commit . "76a787bd40c6b567ae68ced7f5d9f9f10725e00d"))]) - (line-reminder . [(20240101 857) ((emacs (25 1)) (fringe-helper (1 0 1)) (ov (1 0 6)) (ht (2 0))) "Line annotation for changed and saved lines" tar ((:commit . "91d8f57f11f5ddbb5e94cb23877c67a8f59d4d8c") (:authors ("Shen, Jen-Chieh" . "jcs090218@gmail.com")) (:maintainers ("Shen, Jen-Chieh" . "jcs090218@gmail.com")) (:maintainer "Shen, Jen-Chieh" . "jcs090218@gmail.com") (:keywords "convenience" "annotation") (:url . "https://github.com/emacs-vs/line-reminder"))]) + (line-reminder . [(20240529 816) ((emacs (25 1)) (fringe-helper (1 0 1)) (ov (1 0 6)) (ht (2 0))) "Line annotation for changed and saved lines" tar ((:commit . "9aba7d5ccd31c16b277130eda21e2147d08da31a") (:authors ("Shen, Jen-Chieh" . "jcs090218@gmail.com")) (:maintainers ("Shen, Jen-Chieh" . "jcs090218@gmail.com")) (:maintainer "Shen, Jen-Chieh" . "jcs090218@gmail.com") (:keywords "convenience" "annotation") (:url . "https://github.com/emacs-vs/line-reminder"))]) (line-up-words . [(20180219 1024) nil "Align words in an intelligent way" tar ((:commit . "2c236f5772e18d0e50d7ca2eee7eebbe356d9b60") (:url . "https://github.com/janestreet/line-up-words"))]) (lines-at-once . [(20180422 247) ((emacs (25))) "Insert and edit multiple lines at once" tar ((:commit . "a018ba90549384d52ec58c2685fd14a0f65252be") (:authors ("Jiahao Li" . "jiahaowork@gmail.com")) (:maintainers ("Jiahao Li" . "jiahaowork@gmail.com")) (:maintainer "Jiahao Li" . "jiahaowork@gmail.com") (:keywords "abbrev" "tools") (:url . "https://github.com/jiahaowork/lines-at-once.el"))]) (lingr . [(20100807 1731) nil "Lingr Client for GNU Emacs" tar ((:commit . "4215a8704492d3c860097cbe2649936c22c196df") (:authors ("lugecy" . "lugecy@gmail.com")) (:maintainers ("lugecy" . "lugecy@gmail.com")) (:maintainer "lugecy" . "lugecy@gmail.com") (:keywords "chat" "client" "internet") (:url . "http://github.com/lugecy/lingr-el"))]) @@ -3080,7 +3086,7 @@ (litex-mode . [(20221107 147) ((emacs (24 4)) (units-mode (0 1 1))) "Minor mode for converting lisp to LaTeX" tar ((:commit . "45004b3a865771799b739d17ebb7849190fffa63") (:authors ("Gaurav Atreya" . "allmanpride@gmail.com")) (:maintainers ("Gaurav Atreya" . "allmanpride@gmail.com")) (:maintainer "Gaurav Atreya" . "allmanpride@gmail.com") (:keywords "calculator" "lisp" "latex") (:url . "https://github.com/Atreyagaurav/litex-mode"))]) (live-code-talks . [(20180907 1647) ((emacs (24)) (cl-lib (0 5)) (narrowed-page-navigation (0 1))) "Support for slides with live code in them" tar ((:commit . "97f16a9ee4e6ff3e0f9291eaead772c66e3e12ae") (:authors ("David Raymond Christiansen" . "david@davidchristiansen.dk")) (:maintainers ("David Raymond Christiansen" . "david@davidchristiansen.dk")) (:maintainer "David Raymond Christiansen" . "david@davidchristiansen.dk") (:keywords "docs" "multimedia"))]) (live-preview . [(20231215 1612) ((emacs (24 4))) "Live preview by any shell command while editing" tar ((:commit . "135f2b9a8ecf81d00cf92175d144a33561e36f4c") (:authors ("Lassi Kortela" . "lassi@lassi.io")) (:maintainers ("Lassi Kortela" . "lassi@lassi.io")) (:maintainer "Lassi Kortela" . "lassi@lassi.io") (:keywords "languages" "util") (:url . "https://github.com/lassik/emacs-live-preview"))]) - (live-py-mode . [(20240419 404) ((emacs (24 3))) "Live Coding in Python" tar ((:commit . "bea9903bca0ece7546df9a00883f17e4eb49b4c7") (:authors ("Don Kirkby http://donkirkby.github.io")) (:maintainers ("Don Kirkby http://donkirkby.github.io")) (:maintainer "Don Kirkby http://donkirkby.github.io") (:keywords "live" "coding") (:url . "http://donkirkby.github.io/live-py-plugin/"))]) + (live-py-mode . [(20240602 513) ((emacs (24 3))) "Live Coding in Python" tar ((:commit . "65eb99ca34c306c9f495ac199b9365f46f50ff03") (:authors ("Don Kirkby http://donkirkby.github.io")) (:maintainers ("Don Kirkby http://donkirkby.github.io")) (:maintainer "Don Kirkby http://donkirkby.github.io") (:keywords "live" "coding") (:url . "http://donkirkby.github.io/live-py-plugin/"))]) (lively . [(20171005 754) nil "interactively updating text" tar ((:commit . "348675828c6a81bfa1ac311ca465aad813542c1b") (:authors ("Luke Gorrie" . "luke@bup.co.nz")) (:maintainers ("Steve Purcell" . "steve@sanityinc.com")) (:maintainer "Steve Purcell" . "steve@sanityinc.com"))]) (livereload . [(20170629 650) ((emacs (25)) (websocket (1 8))) "Livereload server" tar ((:commit . "1e501d7e46dbd476c2c7cc9d20b5ac9d41fb1955") (:authors ("João Távora" . "joaotavora@gmail.com")) (:maintainers ("João Távora" . "joaotavora@gmail.com")) (:maintainer "João Távora" . "joaotavora@gmail.com") (:keywords "convenience"))]) (livescript-mode . [(20221015 1316) ((emacs (24 3))) "Major mode for editing LiveScript files" tar ((:commit . "e71a82a400e9d451c966c397bb8fa7887d35637b") (:authors ("Hisamatsu Yasuyuki" . "yas@null.net")) (:maintainers ("Hisamatsu Yasuyuki" . "yas@null.net")) (:maintainer "Hisamatsu Yasuyuki" . "yas@null.net") (:keywords "languages" "livescript") (:url . "https://github.com/yhisamatsu/livescript-mode"))]) @@ -3127,14 +3133,14 @@ (lsp-haskell . [(20231011 1723) ((emacs (27 1)) (lsp-mode (3 0)) (haskell-mode (16 1))) "Haskell support for lsp-mode" tar ((:commit . "89d16370434e9a247e95b8b701f524f5abfc884b") (:keywords "haskell") (:url . "https://github.com/emacs-lsp/lsp-haskell"))]) (lsp-intellij . [(20180831 2051) ((emacs (25 1)) (lsp-mode (4 1))) "intellij lsp client" tar ((:commit . "cf30f0ac63bd0140e758840b8ab070e8313697b2") (:authors ("Ruin0x11" . "ipickering2@gmail.com")) (:maintainers ("Ruin0x11" . "ipickering2@gmail.com")) (:maintainer "Ruin0x11" . "ipickering2@gmail.com") (:keywords "languages" "processes" "tools") (:url . "https://github.com/Ruin0x11/lsp-intellij"))]) (lsp-ivy . [(20220831 1823) ((emacs (25 1)) (dash (2 14 1)) (lsp-mode (6 2 1)) (ivy (0 13 0))) "LSP ivy integration" tar ((:commit . "9ecf4dd9b1207109802bd1882aa621eb1c385106") (:keywords "languages" "debug") (:url . "https://github.com/emacs-lsp/lsp-ivy"))]) - (lsp-java . [(20240501 1928) ((emacs (27 1)) (lsp-mode (6 0)) (markdown-mode (2 3)) (dash (2 18 0)) (f (0 20 0)) (ht (2 0)) (request (0 3 0)) (treemacs (2 5)) (dap-mode (0 5))) "Java support for lsp-mode" tar ((:commit . "37c95ef7e992001250d893277acfccf4af0099b4") (:keywords "languague" "tools") (:url . "https://github.com/emacs-lsp/lsp-java"))]) + (lsp-java . [(20240524 2207) ((emacs (27 1)) (lsp-mode (6 0)) (markdown-mode (2 3)) (dash (2 18 0)) (f (0 20 0)) (ht (2 0)) (request (0 3 0)) (treemacs (2 5)) (dap-mode (0 5))) "Java support for lsp-mode" tar ((:commit . "4909c14b9012eed669a9c3f11a8df055d5bb8a0e") (:keywords "languague" "tools") (:url . "https://github.com/emacs-lsp/lsp-java"))]) (lsp-javacomp . [(20190124 1755) ((emacs (25 1)) (lsp-mode (3 0)) (s (1 2 0))) "Provide Java IDE features powered by JavaComp." tar ((:commit . "82aa4ad6ca03a74565c35e855b318b1887bcd89b") (:keywords "java" "tools" "lsp") (:url . "https://github.com/tigersoldier/lsp-javacomp"))]) (lsp-jedi . [(20230824 1908) ((emacs (25 1)) (lsp-mode (6 0))) "Lsp client plugin for Python Jedi Language Server" tar ((:commit . "3c828df8dd422dbb94856cc99db6f9acb52b871d") (:authors ("Fred Campos" . "fred.tecnologia@gmail.com")) (:maintainers ("Fred Campos")) (:maintainer "Fred Campos") (:keywords "language-server" "tools" "python" "jedi" "ide") (:url . "http://github.com/fredcamps/lsp-jedi"))]) (lsp-julia . [(20230915 654) ((emacs (25 1)) (lsp-mode (6 3)) (julia-mode (0 3))) "Julia support for lsp-mode" tar ((:commit . "c869b2f6c05a97e5495ed3cc6710a33b4faf41a2") (:authors ("Martin Wolke" . "vibhavp@gmail.com") ("Adam Beckmeyer" . "adam_git@thebeckmeyers.xyz") ("Guido Kraemer" . "gdkrmr@users.noreply.github.com")) (:maintainers ("Guido Kraemer" . "gdkrmr@users.noreply.github.com")) (:maintainer "Guido Kraemer" . "gdkrmr@users.noreply.github.com") (:keywords "languages" "tools") (:url . "https://github.com/gdkrmr/lsp-julia"))]) (lsp-latex . [(20240324 1218) ((emacs (27 1)) (lsp-mode (6 0)) (consult (0 35))) "LSP-mode client for LaTeX, on texlab" tar ((:commit . "30e5ee2a387bee7b320564d402b3e587cdae536c") (:authors ("ROCKTAKEY" . "rocktakey@gmail.com")) (:maintainers ("ROCKTAKEY" . "rocktakey@gmail.com")) (:maintainer "ROCKTAKEY" . "rocktakey@gmail.com") (:keywords "languages" "tex") (:url . "https://github.com/ROCKTAKEY/lsp-latex"))]) (lsp-ltex . [(20240425 2049) ((emacs (27 1)) (lsp-mode (6 1))) "LSP Clients for LTEX" tar ((:commit . "c473ed37aa0f2769bb0b4c344cc28f95975dbc17") (:authors ("Shen, Jen-Chieh" . "jcs090218@gmail.com")) (:maintainers ("Shen, Jen-Chieh" . "jcs090218@gmail.com")) (:maintainer "Shen, Jen-Chieh" . "jcs090218@gmail.com") (:keywords "convenience" "lsp" "languagetool" "checker") (:url . "https://github.com/emacs-languagetool/lsp-ltex"))]) (lsp-metals . [(20240508 627) ((emacs (27 1)) (scala-mode (0 23)) (lsp-mode (7 0)) (lsp-treemacs (0 2)) (dap-mode (0 3)) (dash (2 18 0)) (f (0 20 0)) (ht (2 0)) (treemacs (3 1)) (posframe (1 4 1))) "Scala Client settings" tar ((:commit . "fa4072cbe7a7061cdb218b9a3619979f7facba0e") (:authors ("Ross A. Baker" . "ross@rossabaker.com") ("Evgeny Kurnevsky" . "kurnevsky@gmail.com")) (:maintainers ("Ross A. Baker" . "ross@rossabaker.com")) (:maintainer "Ross A. Baker" . "ross@rossabaker.com") (:keywords "languages" "extensions") (:url . "https://github.com/emacs-lsp/lsp-metals"))]) - (lsp-mode . [(20240514 1430) ((emacs (27 1)) (dash (2 18 0)) (f (0 20 0)) (ht (2 3)) (spinner (1 7 3)) (markdown-mode (2 3)) (lv (0)) (eldoc (1 11))) "LSP mode" tar ((:commit . "62e1f68c1f2363f7ebe8f1c2762e472f3b5de46a") (:authors ("Vibhav Pant, Fangrui Song, Ivan Yonchovski")) (:maintainers ("Vibhav Pant, Fangrui Song, Ivan Yonchovski")) (:maintainer "Vibhav Pant, Fangrui Song, Ivan Yonchovski") (:keywords "languages") (:url . "https://github.com/emacs-lsp/lsp-mode"))]) + (lsp-mode . [(20240531 2326) ((emacs (27 1)) (dash (2 18 0)) (f (0 20 0)) (ht (2 3)) (spinner (1 7 3)) (markdown-mode (2 3)) (lv (0)) (eldoc (1 11))) "LSP mode" tar ((:commit . "acad044ebc343c1eff0d9a875a13fb34ad113a9e") (:authors ("Vibhav Pant, Fangrui Song, Ivan Yonchovski")) (:maintainers ("Vibhav Pant, Fangrui Song, Ivan Yonchovski")) (:maintainer "Vibhav Pant, Fangrui Song, Ivan Yonchovski") (:keywords "languages") (:url . "https://github.com/emacs-lsp/lsp-mode"))]) (lsp-mssql . [(20230510 1124) ((emacs (25 1)) (lsp-mode (6 2)) (dash (2 14 1)) (f (0 20 0)) (ht (2 0)) (lsp-treemacs (0 1))) "MSSQL LSP bindings" tar ((:commit . "a0dba8f86a2ace7e800a9dc8f814767625a509af") (:authors ("Ivan Yonchovski" . "yyoncho@gmail.com")) (:maintainers ("Ivan Yonchovski" . "yyoncho@gmail.com")) (:maintainer "Ivan Yonchovski" . "yyoncho@gmail.com") (:keywords "data" "languages") (:url . "https://github.com/emacs-lsp/lsp-mssql"))]) (lsp-origami . [(20230815 704) ((emacs (27 1)) (origami (1 0)) (lsp-mode (6 1))) "origami.el support for lsp-mode" tar ((:commit . "86aa06517910141c3d5054eea5f7723461fce6a6") (:authors ("Vibhav Pant")) (:maintainers ("Vibhav Pant")) (:maintainer "Vibhav Pant") (:keywords "languages" "lsp-mode") (:url . "https://github.com/emacs-lsp/lsp-origami"))]) (lsp-p4 . [(20190127 1049) ((lsp-mode (3 0))) "P4 support for lsp-mode" tar ((:commit . "084e33a5782f9153502d9b03e63d9cbbe81cdaeb") (:authors ("Dmitri Makarov")) (:maintainers ("Dmitri Makarov")) (:maintainer "Dmitri Makarov") (:keywords "lsp" "p4") (:url . "https://github.com/dmakarov/p4ls"))]) @@ -3174,12 +3180,12 @@ (magic-filetype . [(20240130 1805) ((emacs (24 3)) (s (1 9 0))) "Enhance filetype major mode" tar ((:commit . "3979ddbd8066d7390e31bde2b35f997c5f5f4516") (:authors ("USAMI Kenta" . "tadsan@zonu.me")) (:maintainers ("USAMI Kenta" . "tadsan@zonu.me")) (:maintainer "USAMI Kenta" . "tadsan@zonu.me") (:keywords "emulations" "vim" "ft" "file" "magic-mode") (:url . "https://github.com/emacs-php/magic-filetype.el"))]) (magic-latex-buffer . [(20210306 422) ((cl-lib (0 5)) (emacs (25 1))) "Magically enhance LaTeX-mode font-locking for semi-WYSIWYG editing" tar ((:commit . "903ec91872760e47c0e5715795f8465173615098") (:authors ("zk_phi")) (:maintainers ("zk_phi")) (:maintainer "zk_phi") (:url . "http://zk-phi.github.io/"))]) (magik-mode . [(20240521 1419) ((emacs (24 4)) (compat (28 1))) "Emacs major mode for Smallworld Magik files" tar ((:commit . "51ec2d21e4d68fc549d2022f86a882e090541ec3") (:keywords "languages") (:url . "https://github.com/roadrunner1776/magik"))]) - (magit . [(20240514 1843) ((emacs (26 1)) (compat (29 1 4 5)) (dash (20240405)) (git-commit (20240429)) (magit-section (20240429)) (seq (2 24)) (transient (20240421)) (with-editor (20240415))) "A Git porcelain inside Emacs." tar ((:commit . "9cde118744151caca08b080e15f0c903f17d0f20") (:authors ("Marius Vollmer" . "marius.vollmer@gmail.com") ("Jonas Bernoulli" . "emacs.magit@jonas.bernoulli.dev")) (:maintainer "Jonas Bernoulli" . "emacs.magit@jonas.bernoulli.dev") (:keywords "git" "tools" "vc") (:url . "https://github.com/magit/magit"))]) + (magit . [(20240522 204) ((emacs (26 1)) (compat (29 1 4 5)) (dash (20240405)) (git-commit (20240429)) (magit-section (20240429)) (seq (2 24)) (transient (20240421)) (with-editor (20240415))) "A Git porcelain inside Emacs." tar ((:commit . "f9268a959828d0c6ab26171dd2fb1ffc55e5ae70") (:authors ("Marius Vollmer" . "marius.vollmer@gmail.com") ("Jonas Bernoulli" . "emacs.magit@jonas.bernoulli.dev")) (:maintainer "Jonas Bernoulli" . "emacs.magit@jonas.bernoulli.dev") (:keywords "git" "tools" "vc") (:url . "https://github.com/magit/magit"))]) (magit-annex . [(20231210 2140) ((cl-lib (0 3)) (magit (3 0 0))) "Control git-annex from Magit" tar ((:commit . "056f0d4462cdccbd7bb7589994da7fef9de766da") (:authors ("Kyle Meyer" . "kyle@kyleam.com") ("Rémi Vanicat" . "vanicat@debian.org")) (:maintainers ("Kyle Meyer" . "kyle@kyleam.com")) (:maintainer "Kyle Meyer" . "kyle@kyleam.com") (:keywords "vc" "tools") (:url . "https://github.com/magit/magit-annex"))]) (magit-commit-mark . [(20240421 931) ((emacs (29 1)) (magit (3 3 0))) "Support marking commits as read" tar ((:commit . "d09d0df6f8a697446e9fac77428b32997b94c59e") (:authors ("Campbell Barton" . "ideasman42@gmail.com")) (:maintainers ("Campbell Barton" . "ideasman42@gmail.com")) (:maintainer "Campbell Barton" . "ideasman42@gmail.com") (:url . "https://codeberg.org/ideasman42/emacs-magit-commit-mark"))]) (magit-delta . [(20220125 50) ((emacs (25 1)) (magit (20200426)) (xterm-color (2 0))) "Use Delta when displaying diffs in Magit" tar ((:commit . "5fc7dbddcfacfe46d3fd876172ad02a9ab6ac616") (:authors ("Dan Davison" . "dandavison7@gmail.com")) (:maintainers ("Dan Davison" . "dandavison7@gmail.com")) (:maintainer "Dan Davison" . "dandavison7@gmail.com") (:url . "https://github.com/dandavison/magit-delta"))]) (magit-diff-flycheck . [(20190524 551) ((magit (2)) (flycheck (31)) (seq (2)) (emacs (25 1))) "Report errors in diffs" tar ((:commit . "ad58efa312d708f25661dfcc2a7f83a833cca328") (:authors ("Alex Ragone" . "ragonedk@gmail.com")) (:maintainers ("Alex Ragone" . "ragonedk@gmail.com")) (:maintainer "Alex Ragone" . "ragonedk@gmail.com") (:keywords "convenience" "matching") (:url . "https://github.com/ragone/magit-diff-flycheck"))]) - (magit-file-icons . [(20240520 216) ((emacs (24 3)) (magit (3 3 0)) (nerd-icons (0 1 0)) (el-patch (3 1))) "Icons for file entries in Magit buffers" tar ((:commit . "d85fad81e74a9b6ce9fd7ab341f265d5a181d2a8") (:authors ("Gregor Grigorjan" . "gregor@grigorjan.net")) (:maintainers ("Gregor Grigorjan" . "gregor@grigorjan.net")) (:maintainer "Gregor Grigorjan" . "gregor@grigorjan.net") (:url . "https://github.com/gekoke/magit-file-icons"))]) + (magit-file-icons . [(20240524 1712) ((emacs (24 3)) (magit (3 3 0)) (nerd-icons (0 1 0)) (el-patch (3 1))) "Icons for file entries in Magit buffers" tar ((:commit . "0006e243b0e7aa005f6e8900b4b2e3a92c2d0532") (:authors ("Gregor Grigorjan" . "gregor@grigorjan.net")) (:maintainers ("Gregor Grigorjan" . "gregor@grigorjan.net")) (:maintainer "Gregor Grigorjan" . "gregor@grigorjan.net") (:url . "https://github.com/gekoke/magit-file-icons"))]) (magit-filenotify . [(20151116 2340) ((magit (1 3 0)) (emacs (24 4))) "Refresh status buffer when git tree changes" tar ((:commit . "c0865b3c41af20b6cd89de23d3b0beb54c8401a4") (:authors ("Rüdiger Sonderfeld" . "ruediger@c-plusplus.de")) (:maintainers ("Rüdiger Sonderfeld" . "ruediger@c-plusplus.de")) (:maintainer "Rüdiger Sonderfeld" . "ruediger@c-plusplus.de") (:keywords "tools"))]) (magit-find-file . [(20150702 830) ((magit (2 1 0)) (dash (2 8 0))) "completing-read over all files in Git" tar ((:commit . "035da838b1a19e7a5ee135b4ca8475f4e235b61e") (:authors ("Bradley Wright" . "brad@intranation.com")) (:maintainers ("Bradley Wright" . "brad@intranation.com")) (:maintainer "Bradley Wright" . "brad@intranation.com") (:keywords "git") (:url . "https://github.com/bradleywright/magit-find-file.el"))]) (magit-gerrit . [(20240514 1139) ((emacs (25 1)) (magit (2 90 1)) (transient (0 3 0))) "Magit plugin for Gerrit Code Review" tar ((:commit . "46fe81c76fd2d3e5e97207cd1d951f22ecb16573") (:authors ("Brian Fransioli" . "assem@terranpro.org")) (:maintainers ("Brian Fransioli" . "assem@terranpro.org")) (:maintainer "Brian Fransioli" . "assem@terranpro.org") (:url . "https://github.com/emacsorphanage/magit-gerrit"))]) @@ -3227,7 +3233,7 @@ (map-progress . [(20190128 16) ((cl-lib (0 6 1))) "mapping macros that report progress" tar ((:commit . "1fb916159cd054c233ce3c80d9d01adfae640297") (:authors ("Jonas Bernoulli" . "jonas@bernoul.li")) (:maintainers ("Jonas Bernoulli" . "jonas@bernoul.li")) (:maintainer "Jonas Bernoulli" . "jonas@bernoul.li") (:keywords "convenience") (:url . "https://github.com/tarsius/map-progress"))]) (map-regexp . [(20190128 18) ((cl-lib (0 6 1))) "map over matches of a regular expression" tar ((:commit . "ae2d1c22f786ad987aef3e319925e80160a887a0") (:authors ("Jonas Bernoulli" . "jonas@bernoul.li")) (:maintainers ("Jonas Bernoulli" . "jonas@bernoul.li")) (:maintainer "Jonas Bernoulli" . "jonas@bernoul.li") (:keywords "convenience") (:url . "https://github.com/tarsius/map-regexp"))]) (marcopolo . [(20160421 1004) ((s (1 9 0)) (dash (2 9 0)) (pkg-info (0 5 0)) (request (0 1 0))) "Emacs client to the Docker HUB/Registry API" tar ((:commit . "85db828f2bb4346a811b3326349b1c6d0aae4601") (:authors ("Nicolas Lamirault" . "nicolas.lamirault@gmail.com")) (:maintainers ("Nicolas Lamirault" . "nicolas.lamirault@gmail.com")) (:maintainer "Nicolas Lamirault" . "nicolas.lamirault@gmail.com") (:keywords "docker") (:url . "https://github.com/nlamirault/marcopolo"))]) - (marginalia . [(20240404 451) ((emacs (27 1)) (compat (29 1 4 4))) "Enrich existing commands with completion annotations" tar ((:commit . "58eb5fd6e5cc21b12c5455ae69e7ae93579647bc") (:authors ("Omar Antolín Camarena <omar@matem.unam.mx>, Daniel Mendler" . "mail@daniel-mendler.de")) (:maintainers ("Omar Antolín Camarena <omar@matem.unam.mx>, Daniel Mendler" . "mail@daniel-mendler.de")) (:maintainer "Omar Antolín Camarena <omar@matem.unam.mx>, Daniel Mendler" . "mail@daniel-mendler.de") (:keywords "docs" "help" "matching" "completion") (:url . "https://github.com/minad/marginalia"))]) + (marginalia . [(20240523 1240) ((emacs (27 1)) (compat (29 1 4 4))) "Enrich existing commands with completion annotations" tar ((:commit . "da72da4622c7b38741e6968678028f7e0564816c") (:authors ("Omar Antolín Camarena <omar@matem.unam.mx>, Daniel Mendler" . "mail@daniel-mendler.de")) (:maintainers ("Omar Antolín Camarena <omar@matem.unam.mx>, Daniel Mendler" . "mail@daniel-mendler.de")) (:maintainer "Omar Antolín Camarena <omar@matem.unam.mx>, Daniel Mendler" . "mail@daniel-mendler.de") (:keywords "docs" "help" "matching" "completion") (:url . "https://github.com/minad/marginalia"))]) (mark-multiple . [(20121118 1554) nil "Sorta lets you mark several regions at once." tar ((:commit . "f6a53c7c5283d640ae718f4548b0fda78877a375") (:authors ("Magnar Sveen" . "magnars@gmail.com")) (:maintainer "Magnar Sveen" . "magnars@gmail.com") (:keywords "marking" "library"))]) (mark-thing-at . [(20231019 1111) ((emacs (26)) (choice-program (0 14))) "Mark a pattern at the current point" tar ((:commit . "06cc38fb92c0c1badb06f6744f0110742ffdfe6c") (:authors ("Paul Landes")) (:maintainers ("Paul Landes")) (:maintainer "Paul Landes") (:keywords "mark" "point" "lisp") (:url . "https://github.com/plandes/mark-thing-at"))]) (mark-tools . [(20130614 1025) nil "Some simple tools to access the mark-ring in Emacs" tar ((:commit . "a11b61effa90bd0abc876d12573674d36fc17f0c") (:authors ("Alex Bennée" . "alex@bennee.com")) (:maintainers ("Alex Bennée" . "alex@bennee.com")) (:maintainer "Alex Bennée" . "alex@bennee.com") (:url . "https://github.com/stsquad/emacs-mark-tools"))]) @@ -3248,7 +3254,7 @@ (marshal . [(20201223 1853) ((emacs (25 1)) (ht (2 0))) "eieio extension for automatic (un)marshalling" tar ((:commit . "490496d974d03906f784707ecc2e0ac36ed84b96") (:authors ("Yann Hodique" . "yann.hodique@gmail.com")) (:maintainers ("Yann Hodique" . "yann.hodique@gmail.com")) (:maintainer "Yann Hodique" . "yann.hodique@gmail.com") (:keywords "extensions") (:url . "https://github.com/sigma/marshal.el"))]) (maruo-macro-mode . [(20160616 1349) ((emacs (24 3))) "Major mode for editing Hidemaru/Maruo macro script" tar ((:commit . "8fc9a38ad051eafa8eb94038711acc52c5d1d8d5") (:authors ("USAMI Kenta" . "tadsan@zonu.me")) (:maintainers ("USAMI Kenta" . "tadsan@zonu.me")) (:maintainer "USAMI Kenta" . "tadsan@zonu.me") (:keywords "programming" "editor" "macro"))]) (masm-mode . [(20200308 1450) ((emacs (25 1))) "MASM x86 and x64 assembly major mode" tar ((:commit . "ab63524d195332ec9f703783704231606e69c292") (:authors ("YiGeeker" . "zyfchinese@yeah.net")) (:maintainers ("YiGeeker" . "zyfchinese@yeah.net")) (:maintainer "YiGeeker" . "zyfchinese@yeah.net") (:keywords "languages") (:url . "https://github.com/YiGeeker/masm-mode"))]) - (mastodon . [(20240521 1721) ((emacs (27 1)) (request (0 3 0)) (persist (0 4))) "Client for fediverse services using the Mastodon API" tar ((:commit . "49def07b3d9b6f0718ef9402a3808ca01557245e") (:authors ("Johnson Denen" . "johnson.denen@gmail.com") ("Marty Hiatt" . "martianhiatus@riseup.net")) (:maintainers ("Marty Hiatt" . "martianhiatus@riseup.net")) (:maintainer "Marty Hiatt" . "martianhiatus@riseup.net") (:url . "https://codeberg.org/martianh/mastodon.el"))]) + (mastodon . [(20240531 1213) ((emacs (27 1)) (request (0 3 0)) (persist (0 4))) "Client for fediverse services using the Mastodon API" tar ((:commit . "b7a6145b89d4b07e0932d4c9e7dad20d031c9bd7") (:authors ("Johnson Denen" . "johnson.denen@gmail.com") ("Marty Hiatt" . "martianhiatus@riseup.net")) (:maintainers ("Marty Hiatt" . "martianhiatus@riseup.net")) (:maintainer "Marty Hiatt" . "martianhiatus@riseup.net") (:url . "https://codeberg.org/martianh/mastodon.el"))]) (material-theme . [(20210904 1226) ((emacs (24 1))) "A Theme based on the colors of the Google Material Design" tar ((:commit . "6823009bc92f82aa3a90e27e1009f7da8e87b648") (:authors ("Christoph Paulik" . "cpaulik@gmail.com")) (:maintainers ("Christoph Paulik" . "cpaulik@gmail.com")) (:maintainer "Christoph Paulik" . "cpaulik@gmail.com") (:keywords "themes") (:url . "http://github.com/cpaulik/emacs-material-theme"))]) (math-preview . [(20240519 740) ((emacs (26 1)) (json (1 4)) (dash (2 18 0)) (s (1 12 0))) "Preview TeX math equations inline" tar ((:commit . "7c12235c7f8bb1af0e712a8bfa77f1f2635d964a") (:authors ("Matsievskiy S.V.")) (:maintainers ("Matsievskiy S.V.")) (:maintainer "Matsievskiy S.V.") (:keywords "convenience") (:url . "https://gitlab.com/matsievskiysv/math-preview"))]) (math-symbol-lists . [(20220828 2047) nil "Lists of Unicode math symbols and latex commands" tar ((:commit . "ac3eb053d3b576fcdd192b0ac6ad5090ea3a7079") (:authors ("Vitalie Spinu" . "spinuvit@gmail.com")) (:maintainers ("Vitalie Spinu" . "spinuvit@gmail.com")) (:maintainer "Vitalie Spinu" . "spinuvit@gmail.com") (:keywords "unicode" "symbols" "mathematics") (:url . "https://github.com/vspinu/math-symbol-lists"))]) @@ -3280,7 +3286,7 @@ (memoize . [(20200103 2036) nil "Memoization functions" tar ((:commit . "51b075935ca7070f62fae1d69fe0ff7d8fa56fdd") (:authors ("Christopher Wellons" . "mosquitopsu@gmail.com")) (:maintainers ("Christopher Wellons" . "mosquitopsu@gmail.com")) (:maintainer "Christopher Wellons" . "mosquitopsu@gmail.com") (:url . "https://github.com/skeeto/emacs-memoize"))]) (memolist . [(20150804 1721) ((markdown-mode (22 0)) (ag (0 45))) "memolist.el is Emacs port of memolist.vim." tar ((:commit . "60c296e202a71e9dcf1c3936d47b5c4b95c5839f") (:authors ("mikanfactory <k952i4j14x17_at_gmail.com>")) (:maintainers ("mikanfactory")) (:maintainer "mikanfactory") (:keywords "markdown" "memo") (:url . "http://github.com/mikanfactory/emacs-memolist"))]) (mentor . [(20230103 1146) ((emacs (25 1)) (xml-rpc (1 6 15)) (seq (1 11)) (async (1 9 3)) (url-scgi (0 8))) "Frontend for the rTorrent bittorrent client" tar ((:commit . "f51dd4f3f87c54b7cc92189924b9d873a53f5a75") (:authors ("Stefan Kangas" . "stefankangas@gmail.com")) (:maintainers ("Stefan Kangas" . "stefankangas@gmail.com")) (:maintainer "Stefan Kangas" . "stefankangas@gmail.com") (:keywords "comm" "processes" "bittorrent") (:url . "https://github.com/skangas/mentor"))]) - (meow . [(20240407 1642) ((emacs (27 1))) "Yet Another modal editing" tar ((:commit . "99e08c92bb5d8a695062ce53e2cffeffd3a058a6") (:authors ("Shi Tianshu")) (:maintainers ("Shi Tianshu")) (:maintainer "Shi Tianshu") (:keywords "convenience" "modal-editing") (:url . "https://www.github.com/DogLooksGood/meow"))]) + (meow . [(20240602 504) ((emacs (27 1))) "Yet Another modal editing" tar ((:commit . "f1bfad9518c2756375e16cd3f9f38235c3f57df8") (:authors ("Shi Tianshu")) (:maintainers ("Shi Tianshu")) (:maintainer "Shi Tianshu") (:keywords "convenience" "modal-editing") (:url . "https://www.github.com/DogLooksGood/meow"))]) (merlin . [(20231201 918) ((emacs (25 1))) "Mode for Merlin, an assistant for OCaml" tar ((:commit . "ad9955c76b1cb031e847e139c5cf7b7cc5cb4696") (:authors ("Frédéric Bour <frederic.bour(_)lakaban.net>")) (:maintainers ("Frédéric Bour <frederic.bour(_)lakaban.net>")) (:maintainer "Frédéric Bour <frederic.bour(_)lakaban.net>") (:keywords "ocaml" "languages") (:url . "https://github.com/ocaml/merlin"))]) (merlin-ac . [(20221123 1408) ((emacs (25 1)) (merlin (3)) (auto-complete (1 5))) "Merlin and auto-complete integration" tar ((:commit . "8bcab034a680f57ddf58092fda6288dc4caddd2a") (:authors ("Simon Castellan <simon.castellan(_)iuwt.fr>") ("Frédéric Bour <frederic.bour(_)lakaban.net>") ("Thomas Refis <thomas.refis(_)gmail.com>")) (:maintainers ("Simon Castellan <simon.castellan(_)iuwt.fr>")) (:maintainer "Simon Castellan <simon.castellan(_)iuwt.fr>") (:keywords "ocaml" "languages") (:url . "http://github.com/ocaml/merlin"))]) (merlin-company . [(20221123 1408) ((emacs (25 1)) (merlin (3)) (company (0 9))) "Merlin and company mode integration" tar ((:commit . "8bcab034a680f57ddf58092fda6288dc4caddd2a") (:authors ("Simon Castellan <simon.castellan(_)iuwt.fr>") ("Frédéric Bour <frederic.bour(_)lakaban.net>") ("Thomas Refis <thomas.refis(_)gmail.com>")) (:maintainers ("Simon Castellan <simon.castellan(_)iuwt.fr>")) (:maintainer "Simon Castellan <simon.castellan(_)iuwt.fr>") (:keywords "ocaml" "languages") (:url . "http://github.com/ocaml/merlin"))]) @@ -3289,7 +3295,7 @@ (mermaid-docker-mode . [(20231126 1943) ((emacs (26 1)) (mermaid-mode (1 0))) "Render mermaid graphs with Docker service" tar ((:commit . "9d3421e02704f50e2e695d8dbe6fbb7eb5f2371f") (:authors ("Peter Badida" . "keyweeusr@gmail.com")) (:maintainers ("Peter Badida" . "keyweeusr@gmail.com")) (:maintainer "Peter Badida" . "keyweeusr@gmail.com") (:keywords "convenience" "docker" "mermaid" "mmd" "graph" "design" "jpg" "image" "api") (:url . "https://github.com/KeyWeeUsr/mermaid-docker-mode"))]) (mermaid-mode . [(20240123 1729) ((emacs (25 3))) "major mode for working with mermaid graphs" tar ((:commit . "d8bfb8c819cda9ead19c871842f6b0b8d56c56c0") (:authors ("Adrien Brochard")) (:maintainers ("Adrien Brochard")) (:maintainer "Adrien Brochard") (:keywords "mermaid" "graphs" "tools" "processes") (:url . "https://github.com/abrochard/mermaid-mode"))]) (mermaid-ts-mode . [(20231001 1704) ((emacs (29 1))) "Major mode for Mermaid" tar ((:commit . "3f3a537d249b44e939d6a0d65a6c316761ff8c41") (:authors ("Jonathan Hope" . "jhope@theflatfield.net")) (:maintainers ("Jonathan Hope" . "jhope@theflatfield.net")) (:maintainer "Jonathan Hope" . "jhope@theflatfield.net") (:keywords "mermaid" "languages") (:url . "https://github.com/JonathanHope/mermaid-ts-mode"))]) - (meson-mode . [(20240218 1834) ((emacs (26 1))) "Major mode for the Meson build system files" tar ((:commit . "c8f4fbf075bb5db2bc0872afe02af2edac075e4e") (:authors ("Michal Sojka" . "sojkam1@fel.cvut.cz")) (:maintainers ("Michal Sojka" . "sojkam1@fel.cvut.cz")) (:maintainer "Michal Sojka" . "sojkam1@fel.cvut.cz") (:keywords "languages" "tools") (:url . "https://github.com/wentasah/meson-mode"))]) + (meson-mode . [(20240601 1647) ((emacs (26 1))) "Major mode for the Meson build system files" tar ((:commit . "0449c649daaa9322e1c439c1540d8c290501d455") (:authors ("Michal Sojka" . "sojkam1@fel.cvut.cz")) (:maintainers ("Michal Sojka" . "sojkam1@fel.cvut.cz")) (:maintainer "Michal Sojka" . "sojkam1@fel.cvut.cz") (:keywords "languages" "tools") (:url . "https://github.com/wentasah/meson-mode"))]) (mess . [(20230718 1533) ((emacs (27 1)) (mame (1 0))) "Front-end for MAME MESS" tar ((:commit . "65392b0d0ded45de789d4deab28a4ce88de24567") (:authors ("Yong" . "luo.yong.name@gmail.com")) (:maintainers ("Yong" . "luo.yong.name@gmail.com")) (:maintainer "Yong" . "luo.yong.name@gmail.com") (:url . "https://github.com/Iacob/elmame"))]) (message-attachment-reminder . [(20230124 520) ((emacs (24 1))) "Remind if missing attachment" tar ((:commit . "975381d6e7c6771c462e73abd3398a4ed2a9b86b") (:authors ("Alex Murray" . "murray.alex@gmail.com")) (:maintainers ("Alex Murray" . "murray.alex@gmail.com")) (:maintainer "Alex Murray" . "murray.alex@gmail.com") (:url . "https://github.com/alexmurray/message-attachment-reminder"))]) (message-view-patch . [(20210904 2227) ((emacs (24 4)) (magit (3 0 0))) "Colorize patch-like emails in mu4e" tar ((:commit . "50dd3d92a1794f24b7e375b74e5199c63b54a2d8") (:authors ("Sean Farley")) (:maintainers ("Sean Farley")) (:maintainer "Sean Farley") (:keywords "extensions" "mu4e" "gnus") (:url . "https://github.com/seanfarley/message-view-patch"))]) @@ -3319,7 +3325,7 @@ (mindstream . [(20240519 1715) ((emacs (25 1)) (magit (3 3 0))) "Start writing, stay focused, don't worry" tar ((:commit . "ae8b10b077d71de5e8ad966e03527e8d55b3e18d") (:authors ("Siddhartha Kasivajhula" . "sid@countvajhula.com")) (:maintainers ("Siddhartha Kasivajhula" . "sid@countvajhula.com")) (:maintainer "Siddhartha Kasivajhula" . "sid@countvajhula.com") (:keywords "convenience" "files" "languages" "outlines" "tools" "vc" "wp") (:url . "https://github.com/countvajhula/mindstream"))]) (minesweeper . [(20200416 2342) nil "play minesweeper in Emacs" tar ((:commit . "d4248e3c9b3e9e7277cb9e6d081330611898f334") (:authors ("Zachary Kanfer" . "zkanfer@gmail.com")) (:maintainers ("Zachary Kanfer" . "zkanfer@gmail.com")) (:maintainer "Zachary Kanfer" . "zkanfer@gmail.com") (:keywords "game" "fun" "minesweeper" "inane" "diversion") (:url . "https://hg.sr.ht/~zck/minesweeper"))]) (mingus . [(20230518 1726) ((libmpdee (2 2))) "MPD Interface" tar ((:commit . "3fa9b95552eb062eb245321abb7f442c458618dc") (:authors ("Niels Giesen <pft on #emacs>")) (:maintainers ("Niels Giesen <pft on #emacs>")) (:maintainer "Niels Giesen <pft on #emacs>") (:keywords "multimedia" "elisp" "music" "mpd") (:url . "https://github.com/pft/mingus"))]) - (mini-echo . [(20240518 849) ((emacs (29 1)) (dash (2 19 1)) (hide-mode-line (1 0 3))) "Echo buffer status in minibuffer window" tar ((:commit . "4e2918225bea7fa7d232260bd0b2de48df68c6f8") (:authors ("liuyinz" . "liuyinz95@gmail.com")) (:maintainers ("liuyinz" . "liuyinz95@gmail.com")) (:maintainer "liuyinz" . "liuyinz95@gmail.com") (:keywords "frames") (:url . "https://github.com/liuyinz/mini-echo.el"))]) + (mini-echo . [(20240602 1242) ((emacs (29 1)) (dash (2 19 1)) (hide-mode-line (1 0 3))) "Echo buffer status in minibuffer window" tar ((:commit . "6d419f8b118fa2858da3563e2dfeadcbc51e8902") (:authors ("liuyinz" . "liuyinz95@gmail.com")) (:maintainers ("liuyinz" . "liuyinz95@gmail.com")) (:maintainer "liuyinz" . "liuyinz95@gmail.com") (:keywords "frames") (:url . "https://github.com/liuyinz/mini-echo.el"))]) (mini-frame . [(20220627 2041) ((emacs (26 1))) "Show minibuffer in child frame on read-from-minibuffer" tar ((:commit . "60838f3cab438dcbda8eaa15ab3e5d1af88910e9") (:authors ("Andrii Kolomoiets" . "andreyk.mad@gmail.com")) (:maintainers ("Andrii Kolomoiets" . "andreyk.mad@gmail.com")) (:maintainer "Andrii Kolomoiets" . "andreyk.mad@gmail.com") (:keywords "frames") (:url . "https://github.com/muffinmad/emacs-mini-frame"))]) (mini-header-line . [(20170621 1221) ((emacs (24 4))) "a minimal header-line" tar ((:commit . "73b6724e0a26c4528d93768191c8aa59e6bce2e5") (:authors ("Johannes Goslar")) (:maintainers ("Johannes Goslar")) (:maintainer "Johannes Goslar") (:keywords "header-line" "mode-line") (:url . "https://github.com/ksjogo/mini-header-line"))]) (mini-modeline . [(20230306 1521) ((emacs (25 1)) (dash (2 12 0))) "Display modeline in minibuffer" tar ((:commit . "86e753b6c38a06b0fc80d7560aa6a25245fd4d38") (:authors ("Kien Nguyen" . "kien.n.quang@gmail.com")) (:maintainers ("Kien Nguyen" . "kien.n.quang@gmail.com")) (:maintainer "Kien Nguyen" . "kien.n.quang@gmail.com") (:keywords "convenience" "tools") (:url . "https://github.com/kiennq/emacs-mini-modeline"))]) @@ -3338,12 +3344,12 @@ (mint-mode . [(20221031 411) ((emacs (25 1))) "Major mode for the Mint programming language" tar ((:commit . "7bb0f9946f5833eada199e880fdc4efa6df09e0b") (:authors ("Diwank Tomer" . "singh@diwank.name")) (:maintainers ("jgart" . "jgart@dismail.de")) (:maintainer "jgart" . "jgart@dismail.de") (:keywords "mint" "languages" "processes" "convenience" "tools" "files") (:url . "https://github.com/creatorrr/emacs-mint-mode"))]) (mip-mode . [(20151127 617) nil "virtual projects for emacs." tar ((:commit . "7c88c383b4c7ed0a4c1dc397735f365c1fcb461c") (:authors ("Eeli Reilin" . "gaudecker@fea.st")) (:maintainers ("Eeli Reilin" . "gaudecker@fea.st")) (:maintainer "Eeli Reilin" . "gaudecker@fea.st") (:keywords "workspaces" "workspace" "project" "projects" "mip-mode"))]) (mips-mode . [(20220608 1204) ((emacs (25 1))) "Major-mode for MIPS assembly" tar ((:commit . "98795cdc81979821ac35d9f94ce354cd99780c67") (:authors ("Henrik Lissner <http://github/hlissner>")) (:maintainers ("Henrik Lissner" . "contact@henrik.io")) (:maintainer "Henrik Lissner" . "contact@henrik.io") (:keywords "languages" "mips" "assembly") (:url . "https://github.com/hlissner/emacs-mips-mode"))]) - (mise . [(20240514 452) ((emacs (29 1)) (inheritenv (0 2)) (dash (2 19 1))) "Support for `mise' cli" tar ((:commit . "cb19405eba3cfd679a5e3ac75c8c4c1146b16015") (:authors ("liuyinz" . "liuyinz95@gmail.com")) (:maintainers ("liuyinz" . "liuyinz95@gmail.com")) (:maintainer "liuyinz" . "liuyinz95@gmail.com") (:keywords "tools" "processes") (:url . "https://github.com/liuyinz/mise.el"))]) + (mise . [(20240529 421) ((emacs (29 1)) (inheritenv (0 2)) (dash (2 19 1))) "Support for `mise' cli" tar ((:commit . "f94860f7e3b6fdaea7eb79beff8f4662f137752b") (:authors ("liuyinz" . "liuyinz95@gmail.com")) (:maintainers ("Liuyinz" . "liuyinz95@gmail.com")) (:maintainer "Liuyinz" . "liuyinz95@gmail.com") (:keywords "tools" "processes") (:url . "https://github.com/liuyinz/mise.el"))]) (mistty . [(20240429 1645) ((emacs (29 1))) "Shell/Comint alternative based on term.el" tar ((:commit . "bf68d5b52d9dfae68c83340cabea2681057e82ea") (:authors ("Stephane Zermatten" . "szermatt@gmx.net")) (:maintainers ("Stephane Zermatten" . "szermatt@gmx.net")) (:maintainer "Stephane Zermatten" . "szermatt@gmx.net") (:keywords "convenience" "unix") (:url . "http://github.com/szermatt/mistty"))]) (mix . [(20240122 720) ((emacs (25 1))) "Mix Major Mode. Build Elixir using Mix" tar ((:commit . "16cc69cbf919769c191b1c49c1cab324fd0682a9") (:authors ("Ayrat Badykov" . "ayratin555@gmail.com")) (:maintainers ("Ayrat Badykov" . "ayratin555@gmail.com")) (:maintainer "Ayrat Badykov" . "ayratin555@gmail.com") (:keywords "tools") (:url . "https://github.com/ayrat555/mix.el"))]) (mixed-pitch . [(20210304 1900) ((emacs (24 3))) "Use a variable pitch, keeping fixed pitch where it's sensible" tar ((:commit . "519e05f74825abf04b7d2e0e38ec040d013a125a") (:authors ("J. Alexander Branham" . "branham@utexas.edu")) (:maintainers ("J. Alexander Branham" . "branham@utexas.edu")) (:maintainer "J. Alexander Branham" . "branham@utexas.edu") (:url . "https://gitlab.com/jabranham/mixed-pitch"))]) (mkdown . [(20140517 1418) ((markdown-mode (2 0))) "Pretty Markdown previews based on mkdown.com" tar ((:commit . "8e23de82719af6c5b53b52b3308a02b3a1fb872e") (:authors ("Andrew Tulloch")) (:maintainers ("Andrew Tulloch")) (:maintainer "Andrew Tulloch") (:keywords "markdown") (:url . "https://github.com/ajtulloch/mkdown.el"))]) - (mlscroll . [(20240420 1515) ((emacs (27 1))) "A scroll bar for the modeline" tar ((:commit . "cb9d7a256b8998565795d4be469d5a8dea96eb16") (:authors ("J.D. Smith")) (:maintainers ("J.D. Smith")) (:maintainer "J.D. Smith") (:keywords "convenience") (:url . "https://github.com/jdtsmith/mlscroll"))]) + (mlscroll . [(20240528 2006) ((emacs (27 1))) "A scroll bar for the modeline" tar ((:commit . "b11eda812eb4eabf77af749ca6ae8327157c2d0b") (:authors ("J.D. Smith")) (:maintainers ("J.D. Smith")) (:maintainer "J.D. Smith") (:keywords "convenience") (:url . "https://github.com/jdtsmith/mlscroll"))]) (mmm-jinja2 . [(20170313 1420) ((mmm-mode (0 5 4))) "MMM submode class for Jinja2 Templates" tar ((:commit . "c8cb763174fa2fb61b9a0e5e0ff8cb0210f8492f") (:authors ("Ben Hayden" . "hayden767@gmail.com")) (:maintainers ("Ben Hayden" . "hayden767@gmail.com")) (:maintainer "Ben Hayden" . "hayden767@gmail.com") (:url . "https://github.com/glynnforrest/mmm-jinja2"))]) (mmm-mode . [(20240222 428) ((emacs (25 1)) (cl-lib (0 2))) "Allow Multiple Major Modes in a buffer" tar ((:commit . "b1f5c7dbdc405e6e10d9ddd99a43a6b2ad61b176") (:authors ("Michael Abraham Shulman" . "viritrilbia@gmail.com")) (:maintainers ("Dmitry Gutov" . "dmitry@gutov.dev")) (:maintainer "Dmitry Gutov" . "dmitry@gutov.dev") (:keywords "convenience" "faces" "languages" "tools") (:url . "https://github.com/dgutov/mmm-mode"))]) (mmt . [(20230606 1513) ((emacs (24 5))) "Missing macro tools for Emacs Lisp" tar ((:commit . "2a24463eeb72ebef100e89977ebfb88f5f220217") (:authors ("Mark Karpov" . "markkarpov92@gmail.com")) (:maintainers ("Mark Karpov" . "markkarpov92@gmail.com")) (:maintainer "Mark Karpov" . "markkarpov92@gmail.com") (:keywords "macro" "lisp" "extensions") (:url . "https://github.com/mrkkrp/mmt"))]) @@ -3498,7 +3504,7 @@ (nemerle . [(20161029 2023) nil "major mode for editing nemerle programs" tar ((:commit . "8818c5af5598e16ea59189e1e3245f0a3d7c78f0") (:authors ("Jacek Sliwerski (rzyjontko)" . "rzyj@o2.pl")) (:maintainers ("Jacek Sliwerski (rzyjontko)" . "rzyj@o2.pl")) (:maintainer "Jacek Sliwerski (rzyjontko)" . "rzyj@o2.pl") (:keywords "nemerle" "mode" "languages"))]) (neon-mode . [(20180406 1156) nil "Simple major mode for editing neon files" tar ((:commit . "99d15e46beaf1e7d71e39a00cce810df1f33229d") (:authors ("Matúš Goljer" . "matus.goljer@gmail.com")) (:maintainers ("Matúš Goljer" . "matus.goljer@gmail.com")) (:maintainer "Matúš Goljer" . "matus.goljer@gmail.com") (:keywords "conf"))]) (neotree . [(20230815 219) ((cl-lib (0 5))) "A tree plugin like NerdTree for Vim" tar ((:commit . "2b0cb8285352202c62b1e46a8aa265a5e4f9d966") (:authors ("jaypei" . "jaypei97159@gmail.com")) (:maintainers ("jaypei" . "jaypei97159@gmail.com")) (:maintainer "jaypei" . "jaypei97159@gmail.com") (:url . "https://github.com/jaypei/emacs-neotree"))]) - (nerd-icons . [(20240520 1050) ((emacs (24 3))) "Emacs Nerd Font Icons Library" tar ((:commit . "5ed32f43f2e92ac2600d0ff823ec75e4476cc53e") (:authors ("Hongyu Ding <rainstormstudio@yahoo.com>, Vincent Zhang" . "seagle0128@gmail.com")) (:maintainers ("Hongyu Ding <rainstormstudio@yahoo.com>, Vincent Zhang" . "seagle0128@gmail.com")) (:maintainer "Hongyu Ding <rainstormstudio@yahoo.com>, Vincent Zhang" . "seagle0128@gmail.com") (:keywords "lisp") (:url . "https://github.com/rainstormstudio/nerd-icons.el"))]) + (nerd-icons . [(20240524 311) ((emacs (24 3))) "Emacs Nerd Font Icons Library" tar ((:commit . "3dac80b712fb3043ec2bd7510f587548074484a3") (:authors ("Hongyu Ding <rainstormstudio@yahoo.com>, Vincent Zhang" . "seagle0128@gmail.com")) (:maintainers ("Hongyu Ding <rainstormstudio@yahoo.com>, Vincent Zhang" . "seagle0128@gmail.com")) (:maintainer "Hongyu Ding <rainstormstudio@yahoo.com>, Vincent Zhang" . "seagle0128@gmail.com") (:keywords "lisp") (:url . "https://github.com/rainstormstudio/nerd-icons.el"))]) (nerd-icons-completion . [(20230430 1611) ((emacs (25 1)) (nerd-icons (0 0 1))) "Add icons to completion candidates" tar ((:commit . "5cfee6ff1b9647c783bae944402d60440ce04cbb") (:authors ("Hongyu Ding" . "rainstormstudio@yahoo.com")) (:maintainers ("Hongyu Ding" . "rainstormstudio@yahoo.com")) (:maintainer "Hongyu Ding" . "rainstormstudio@yahoo.com") (:keywords "lisp") (:url . "https://github.com/rainstormstudio/nerd-icons-completion"))]) (nerd-icons-corfu . [(20231019 1618) ((emacs (27 1)) (nerd-icons (0 1 0))) "Icons for Corfu via nerd-icons" tar ((:commit . "7077bb76fefc15aed967476406a19dc5c2500b3c") (:authors ("Luigi Sartor Piucco" . "luigipiucco@gmail.com")) (:maintainers ("Luigi Sartor Piucco" . "luigipiucco@gmail.com")) (:maintainer "Luigi Sartor Piucco" . "luigipiucco@gmail.com") (:keywords "convenience" "files" "icons") (:url . "https://github.com/LuigiPiucco/nerd-icons-corfu"))]) (nerd-icons-dired . [(20231214 2155) ((emacs (24 4)) (nerd-icons (0 0 1))) "Shows icons for each file in dired mode" tar ((:commit . "c1c73488630cc1d19ce1677359f614122ae4c1b9") (:authors ("Hongyu Ding" . "rainstormstudio@yahoo.com")) (:maintainers ("Hongyu Ding" . "rainstormstudio@yahoo.com")) (:maintainer "Hongyu Ding" . "rainstormstudio@yahoo.com") (:keywords "lisp") (:url . "https://github.com/rainstormstudio/nerd-icons-dired"))]) @@ -3527,7 +3533,7 @@ (nikola . [(20170703 2021) ((async (1 5)) (emacs (24 3))) "Simple wrapper for nikola" tar ((:commit . "964715ac30943c9d6976999cad208dc60d09def0") (:authors (": drymer <drymer [ AT ] autistici.org>")) (:maintainers (": drymer <drymer [ AT ] autistici.org>")) (:maintainer ": drymer <drymer [ AT ] autistici.org>") (:keywords ":" "nikola") (:url . ": https://git.daemons.it/drymer/nikola.el"))]) (nim-mode . [(20240220 1033) ((emacs (24 4)) (epc (0 1 1)) (let-alist (1 0 1)) (commenter (0 5 1)) (flycheck-nimsuggest (0 8 1))) "A major mode for the Nim programming language" tar ((:commit . "625cc023bd75a741b7d4e629e5bec3a52f45b4be") (:authors ("Simon Hafner")) (:maintainers ("Simon Hafner" . "hafnersimon@gmail.com")) (:maintainer "Simon Hafner" . "hafnersimon@gmail.com") (:keywords "nim" "languages") (:url . "https://github.com/nim-lang/nim-mode"))]) (nimbus-theme . [(20231227 1644) ((emacs (24 1))) "Nimbus dark theme" tar ((:commit . "09e6dcdd491c7aa5aa355e441a03492991830ad1") (:authors ("Marcin Swieczkowski" . "marcin@realemail.net")) (:maintainers ("Marcin Swieczkowski" . "marcin@realemail.net")) (:maintainer "Marcin Swieczkowski" . "marcin@realemail.net") (:keywords "faces") (:url . "https://github.com/mrcnski/nimbus-theme"))]) - (ninja-mode . [(20230421 1748) ((emacs (24))) "Major mode for editing .ninja files" tar ((:commit . "adf9bddd73869084a505fac83246e55c35880079"))]) + (ninja-mode . [(20240528 1945) ((emacs (24))) "Major mode for editing .ninja files" tar ((:commit . "0b4b43aa3e2fee391443dcc0c961c9d2354d8954") (:keywords "languages") (:url . "https://ninja-build.org/"))]) (nix-buffer . [(20180212 1518) ((f (0 17 3)) (emacs (24 4))) "Set up buffer environments with nix" tar ((:commit . "db57cda36e7477bdc7ef5a136357b971b1d4d099") (:authors ("Shea Levy")) (:maintainers ("Shea Levy")) (:maintainer "Shea Levy") (:url . "https://github.com/shlevy/nix-buffer/tree/master/"))]) (nix-env-install . [(20200812 1305) ((emacs (25 1))) "Install packages using nix-env" tar ((:commit . "79c34bc117ba1cebeb67fab32c364951d2ec37a0") (:authors ("Akira Komamura" . "akira.komamura@gmail.com")) (:maintainers ("Akira Komamura" . "akira.komamura@gmail.com")) (:maintainer "Akira Komamura" . "akira.komamura@gmail.com") (:keywords "processes" "tools") (:url . "https://github.com/akirak/nix-env-install"))]) (nix-haskell-mode . [(20190615 135) ((emacs (25)) (haskell-mode (16 0)) (nix-mode (1 3 0))) "haskell-mode integrations for Nix" tar ((:commit . "68efbcbf949a706ecca6409506968ed2ef928a20") (:authors ("Matthew Bauer" . "mjbauer95@gmail.com")) (:maintainers ("Matthew Bauer" . "mjbauer95@gmail.com")) (:maintainer "Matthew Bauer" . "mjbauer95@gmail.com") (:keywords "nix" "haskell" "languages" "processes") (:url . "https://github.com/matthewbauer/nix-haskell"))]) @@ -3547,7 +3553,7 @@ (nntwitter . [(20230705 1110) ((emacs (25 1)) (dash (20190401)) (anaphora (20180618)) (request (20190819))) "Gnus Backend For Twitter" tar ((:commit . "e27acca9beeb6645dd13545d42f6d4d97d59d82c") (:keywords "news") (:url . "https://github.com/dickmao/nntwitter"))]) (no-clown-fiesta-theme . [(20231214 2115) ((emacs (26 1)) (autothemer (0 2))) "Not-so-colorful-theme" tar ((:commit . "0cd04a72aa5dcf61e82e2a613670334816326b02") (:authors ("ranmaru22")) (:maintainers ("ranmaru22")) (:maintainer "ranmaru22") (:url . "https://github.com/ranmaru22/no-clown-fiesta-theme.el"))]) (no-emoji . [(20180515 1837) ((emacs (24))) "Show :emoji-name: instead of emoji characters" tar ((:commit . "ebceeab50dbfe4d60235180a57633745dbc18c77") (:authors ("Peter" . "craven@gmx.net")) (:maintainers ("Peter" . "craven@gmx.net")) (:maintainer "Peter" . "craven@gmx.net") (:keywords "extensions") (:url . "https://github.com/ecraven/no-emoji"))]) - (no-littering . [(20240415 1545) ((emacs (25 1)) (compat (29 1 4 2))) "Help keeping ~/.config/emacs clean" tar ((:commit . "554d890c5d5b59ebcf83c67256d0012e23cd07f0") (:authors ("Jonas Bernoulli" . "emacs.no-littering@jonas.bernoulli.dev")) (:maintainers ("Jonas Bernoulli" . "emacs.no-littering@jonas.bernoulli.dev")) (:maintainer "Jonas Bernoulli" . "emacs.no-littering@jonas.bernoulli.dev") (:keywords "convenience") (:url . "https://github.com/emacscollective/no-littering"))]) + (no-littering . [(20240601 1254) ((emacs (25 1)) (compat (29 1 4 2))) "Help keeping ~/.config/emacs clean" tar ((:commit . "4a71c736ecf04f9b8e5bdd10a73ef1febb73a557") (:authors ("Jonas Bernoulli" . "emacs.no-littering@jonas.bernoulli.dev")) (:maintainers ("Jonas Bernoulli" . "emacs.no-littering@jonas.bernoulli.dev")) (:maintainer "Jonas Bernoulli" . "emacs.no-littering@jonas.bernoulli.dev") (:keywords "convenience") (:url . "https://github.com/emacscollective/no-littering"))]) (no-spam . [(20190724 1854) ((emacs (25 1))) "Add repeat delays to commands" tar ((:commit . "860860e4a0d59bd15c8e092dc42f5f7f769a428e") (:authors ("Daniel Phan" . "daniel.phan36@gmail.com")) (:maintainers ("Daniel Phan" . "daniel.phan36@gmail.com")) (:maintainer "Daniel Phan" . "daniel.phan36@gmail.com") (:keywords "keyboard" "tools") (:url . "https://github.com/mamapanda/no-spam"))]) (noaa . [(20240317 2321) ((emacs (27 1)) (kv (0 0 19)) (request (0 2 0)) (s (1 12 0))) "Get NOAA weather data" tar ((:commit . "7d68b5a580c64123f3bbd75f795a891dfdeb1746") (:authors ("David Thompson")) (:maintainers ("David Thompson")) (:maintainer "David Thompson") (:keywords "calendar") (:url . "https://codeberg.org/thomp/noaa"))]) (noccur . [(20191015 719) nil "Run multi-occur on project/dired files" tar ((:commit . "fa91647a305e89561d3dbe53da002fff49abe0bb") (:authors ("Nicolas Petton" . "petton.nicolas@gmail.com")) (:maintainers ("Nicolas Petton" . "petton.nicolas@gmail.com")) (:maintainer "Nicolas Petton" . "petton.nicolas@gmail.com") (:keywords "convenience"))]) @@ -3560,6 +3566,7 @@ (nofrils-acme-theme . [(20180620 1248) ((emacs (24))) "Port of \"No Frils Acme\" Vim theme." tar ((:commit . "98ad7bfaff1d85b33dc162645670285b067c6f92") (:authors ("Eric Sessoms" . "esessoms@protonmail.com")) (:maintainers ("Eric Sessoms" . "esessoms@protonmail.com")) (:maintainer "Eric Sessoms" . "esessoms@protonmail.com") (:url . "https://gitlab.com/esessoms/nofrils-theme"))]) (noir-mode . [(20230726 2309) ((emacs (25 1)) (rust-mode (1 0 5))) "Description" tar ((:commit . "aa6686e15a63498af327cc64f1d79e84c60bda42") (:authors ("Hamza Hamud")) (:maintainers ("Hamza Hamud")) (:maintainer "Hamza Hamud") (:keywords "languages") (:url . "https://github.com/hhamud/noir-mode"))]) (noir-ts-mode . [(20240331 137) ((emacs (29 1))) "tree-sitter support for Noir" tar ((:commit . "eb399cc69a3229f4141e193f98efead51d9b3cc8") (:authors ("Hamza Hamud" . "self@hamzahamud.com")) (:maintainers ("Hamza Hamud" . "self@hamzahamud.com")) (:maintainer "Hamza Hamud" . "self@hamzahamud.com") (:keywords "noir" "languages" "tree-sitter") (:url . "https://github.com/hhamud/noir-ts-mode"))]) + (noman . [(20240530 1439) ((emacs (29 1))) "Read command line help without a man page" tar ((:commit . "953e3761b05874dee49952fad63ce1cb3c91d707") (:authors ("Andy Kuszyk" . "emacs@akuszyk.com")) (:maintainers ("Andy Kuszyk" . "emacs@akuszyk.com")) (:maintainer "Andy Kuszyk" . "emacs@akuszyk.com") (:keywords "docs") (:url . "https://github.com/andykuszyk/noman.el"))]) (non-edit-mode . [(20230926 1404) ((emacs (24 1))) "Minor mode that disables editing" tar ((:commit . "bc9d29e437d70675c725f3ef8a66abe574b9a142") (:authors ("aragaer" . "aragaer@gmail.com")) (:maintainers ("aragaer" . "aragaer@gmail.com")) (:maintainer "aragaer" . "aragaer@gmail.com") (:keywords "convenience") (:url . "https://gitlab.com/aragaer/non-edit-mode"))]) (nord-theme . [(20230311 1131) ((emacs (24))) "An arctic, north-bluish clean and elegant theme" tar ((:commit . "5335a7e782fd4ea5b33cd630feae37d902709024") (:authors ("Sven Greb" . "development@svengreb.de")) (:maintainers ("Sven Greb" . "development@svengreb.de")) (:maintainer "Sven Greb" . "development@svengreb.de") (:url . "https://github.com/nordtheme/emacs"))]) (nordic-night-theme . [(20240311 2147) ((emacs (24 1))) "A darker, more colorful version of the lovely Nord theme" tar ((:commit . "a9e5918c7755ccb1fa20d3d8e3a3ea069455f87b") (:authors ("Ashton Wiersdorf" . "mail@wiersdorf.dev")) (:maintainers ("Ashton Wiersdorf" . "mail@wiersdorf.dev")) (:maintainer "Ashton Wiersdorf" . "mail@wiersdorf.dev") (:url . "https://codeberg.org/ashton314/nordic-night"))]) @@ -3568,7 +3575,7 @@ (northcode-theme . [(20180423 1649) ((emacs (24))) "A dark theme focused on blue and orange colors." tar ((:commit . "4d3750461ba25ec45321318b5f1af4e8fdf16147") (:authors ("Andreas Larsen" . "andreas@northcode.no")) (:maintainers ("Andreas Larsen" . "andreas@northcode.no")) (:maintainer "Andreas Larsen" . "andreas@northcode.no") (:url . "https://github.com/Northcode/northcode-theme.el"))]) (nothing-theme . [(20200504 402) ((emacs (24 1))) "Monochrome theme" tar ((:commit . "17fc9ecc94af0c919a24c4fe92bb48890bb4c3b0") (:authors ("Jared Gorski," . "jaredgorski6@gmail.com")) (:maintainers ("Jared Gorski," . "jaredgorski6@gmail.com")) (:maintainer "Jared Gorski," . "jaredgorski6@gmail.com") (:url . "https://github.com/jaredgorski/nothing.el"))]) (notink-theme . [(20220114 1955) ((emacs (26 1))) "A custom theme inspired by e-ink displays" tar ((:commit . "6115857fe75c1adbbce4165a2b77a11a271aaf31") (:authors ("MetroWind" . "chris.corsair@gmail.com")) (:maintainers ("MetroWind" . "chris.corsair@gmail.com")) (:maintainer "MetroWind" . "chris.corsair@gmail.com") (:keywords "faces") (:url . "https://github.com/MetroWind/notink-theme"))]) - (notmuch . [(20240406 1803) nil "run notmuch within emacs" tar ((:commit . "cd89065dc36e36b22a2a53832d2cac9b06fba41c") (:url . "https://notmuchmail.org"))]) + (notmuch . [(20240529 1054) nil "run notmuch within emacs" tar ((:commit . "e8e2d5247e44d9b402cbcc491b859cd9398f045d") (:url . "https://notmuchmail.org"))]) (notmuch-addr . [(20240422 15) ((emacs (27 1)) (compat (29 1 4 1)) (notmuch (0 37))) "An alternative to notmuch-address.el" tar ((:commit . "e5755c5a752d2026b1c847bc5944bdd5f015c1a6") (:authors ("Jonas Bernoulli" . "emacs.notmuch-addr@jonas.bernoulli.dev")) (:maintainers ("Jonas Bernoulli" . "emacs.notmuch-addr@jonas.bernoulli.dev")) (:maintainer "Jonas Bernoulli" . "emacs.notmuch-addr@jonas.bernoulli.dev") (:keywords "mail") (:url . "https://git.sr.ht/~tarsius/notmuch-addr"))]) (notmuch-bookmarks . [(20230727 1504) ((seq (2 20)) (emacs (26 1)) (notmuch (0 29 3))) "Add bookmark handling for notmuch buffers" tar ((:commit . "7c053fd2d278dc3a9f07f86975867bfbb4e7448d") (:authors ("Jörg Volbers" . "joerg@joergvolbers.de")) (:maintainers ("Jörg Volbers" . "joerg@joergvolbers.de")) (:maintainer "Jörg Volbers" . "joerg@joergvolbers.de") (:keywords "mail") (:url . "https://github.com/publicimageltd/notmuch-bookmarks"))]) (notmuch-labeler . [(20131230 1719) ((notmuch (0))) "Improve notmuch way of displaying labels" tar ((:commit . "d65d1129555d368243df4770ecc1e7ccb88efc58") (:authors ("Damien Cassou" . "damien.cassou@gmail.com")) (:maintainers ("Damien Cassou" . "damien.cassou@gmail.com")) (:maintainer "Damien Cassou" . "damien.cassou@gmail.com") (:keywords "emacs" "package" "elisp" "notmuch" "emails") (:url . "https://github.com/DamienCassou/notmuch-labeler"))]) @@ -3738,7 +3745,7 @@ (org-agenda-files-track . [(20231209 1529) ((emacs (27 1))) "Fine-track `org-agenda-files' to speed-up `org-agenda'" tar ((:commit . "c0f5f7746ec023a32ba106ec24812eca5cbe15df") (:authors ("Nicolas Graves" . "ngraves@ngraves.fr")) (:maintainers ("Nicolas Graves" . "ngraves@ngraves.fr")) (:maintainer "Nicolas Graves" . "ngraves@ngraves.fr") (:keywords "data" "files" "tools") (:url . "https://git.sr.ht/~ngraves/org-agenda-files-track"))]) (org-agenda-files-track-ql . [(20231218 627) ((emacs (27 1)) (org-ql (0 7 3))) "Fine-track `org-agenda-files' to speed-up `org-ql-views'" tar ((:commit . "832cffe62c35f32850afb800e9a3b8a20a05ad7b") (:authors ("Nicolas Graves" . "ngraves@ngraves.fr")) (:maintainers ("Nicolas Graves" . "ngraves@ngraves.fr")) (:maintainer "Nicolas Graves" . "ngraves@ngraves.fr") (:keywords "data" "files" "tools") (:url . "https://git.sr.ht/~ngraves/org-agenda-files-track"))]) (org-agenda-property . [(20140626 2116) ((emacs (24 2))) "Display org properties in the agenda buffer." tar ((:commit . "01afb36072eb27846eb09310dfca7991dbae831e") (:authors ("Artur Malabarba" . "bruce.connor.am@gmail.com")) (:maintainers ("Artur Malabarba" . "bruce.connor.am@gmail.com")) (:maintainer "Artur Malabarba" . "bruce.connor.am@gmail.com") (:keywords "calendar") (:url . "http://github.com/Bruce-Connor/org-agenda-property"))]) - (org-ai . [(20240517 1114) ((emacs (27 1)) (websocket (1 15))) "Use ChatGPT and other LLMs in org-mode and beyond" tar ((:commit . "fdcff489ef11bbc4b54c87b34a97bcc02f3994d4") (:authors ("Robert Krahn" . "robert@kra.hn")) (:maintainers ("Robert Krahn" . "robert@kra.hn")) (:maintainer "Robert Krahn" . "robert@kra.hn") (:url . "https://github.com/rksm/org-ai"))]) + (org-ai . [(20240529 1707) ((emacs (27 1)) (websocket (1 15))) "Use ChatGPT and other LLMs in org-mode and beyond" tar ((:commit . "4c164b2af90fa318cced3ab2237f5fe4fce73018") (:authors ("Robert Krahn" . "robert@kra.hn")) (:maintainers ("Robert Krahn" . "robert@kra.hn")) (:maintainer "Robert Krahn" . "robert@kra.hn") (:url . "https://github.com/rksm/org-ai"))]) (org-alert . [(20240122 1728) ((org (9 0)) (alert (1 2))) "Notify org deadlines via notify-send" tar ((:commit . "b4bfd4cead89215cc9a46162234f7a4836da4dad") (:authors ("Stephen Pegoraro" . "spegoraro@tutive.com")) (:maintainers ("Stephen Pegoraro" . "spegoraro@tutive.com")) (:maintainer "Stephen Pegoraro" . "spegoraro@tutive.com") (:keywords "org" "org-mode" "notify" "notifications" "calendar") (:url . "https://github.com/spegoraro/org-alert"))]) (org-analyzer . [(20191001 1717) nil "org-analyzer is a tool that extracts time tracking data from org files." tar ((:commit . "19da62aa4dcf1090be8f574f6f2d4c7e116163a8") (:authors ("Robert Krahn" . "robert@kra.hn")) (:maintainer "Robert Krahn" . "robert@kra.hn") (:keywords "calendar") (:url . "https://github.com/rksm/clj-org-analyzer"))]) (org-anki . [(20240427 1628) ((emacs (27 1)) (request (0 3 2)) (dash (2 17)) (promise (1 1))) "Synchronize org-mode entries to Anki" tar ((:commit . "75c2cd6ababf3e2808107af32efc754bfd06a88b") (:authors ("Markus Läll" . "markus.l2ll@gmail.com")) (:maintainers ("Markus Läll" . "markus.l2ll@gmail.com")) (:maintainer "Markus Läll" . "markus.l2ll@gmail.com") (:keywords "outlines" "flashcards" "memory") (:url . "https://github.com/eyeinsky/org-anki"))]) @@ -3753,20 +3760,20 @@ (org-beautify-theme . [(20170908 2218) nil "A sub-theme to make org-mode more beautiful." tar ((:commit . "df6a1114fda313e1689363e196c8284fbe2a2738") (:authors ("Jonathan Arkell" . "jonnay@jonnay.net")) (:maintainers ("Jonathan Arkell" . "jonnay@jonnay.net")) (:maintainer "Jonathan Arkell" . "jonnay@jonnay.net") (:keywords "org" "theme"))]) (org-board . [(20230408 1041) nil "bookmarking and web archival system for Org mode." tar ((:commit . "500fe02bc114e5b535a2eb2ab73954d79428168f") (:authors ("Charles A. Roelli " . "charles@aurox.ch")) (:maintainers ("Charles A. Roelli " . "charles@aurox.ch")) (:maintainer "Charles A. Roelli " . "charles@aurox.ch") (:keywords "org" "bookmarks" "archives") (:url . "https://github.com/scallywag/org-board"))]) (org-bookmark-heading . [(20231216 1234) ((emacs (24 4))) "Emacs bookmark support for Org mode" tar ((:commit . "ed8b7fe2a08b06a1d750d1e1230e6728815e0bcd") (:authors ("Adam Porter" . "adam@alphapapa.net")) (:maintainers ("Adam Porter" . "adam@alphapapa.net")) (:maintainer "Adam Porter" . "adam@alphapapa.net") (:keywords "hypermedia" "outlines") (:url . "http://github.com/alphapapa/org-bookmark-heading"))]) - (org-bookmarks . [(20240520 16) ((emacs (26 1))) "Manage bookmarks in Org mode" tar ((:commit . "774b2cad8b77920e5ea2089d7dd11c8ccab4a471") (:keywords "outline" "matching" "hypermedia" "org") (:url . "https://repo.or.cz/org-bookmarks.git"))]) + (org-bookmarks . [(20240602 929) ((emacs (26 1))) "Manage bookmarks in Org mode" tar ((:commit . "e673af4511f33b0e673e584be9db7bfa5a7e5620") (:keywords "outline" "matching" "hypermedia" "org") (:url . "https://repo.or.cz/org-bookmarks.git"))]) (org-bookmarks-extractor . [(20220829 146) ((emacs (25 1))) "Extract bookmarks from Org mode" tar ((:commit . "26d810d4d58de1f64f0bbd649e13816f96663d73") (:authors ("Xuqing Jia" . "jxq@jxq.me")) (:maintainers ("Xuqing Jia" . "jxq@jxq.me")) (:maintainer "Xuqing Jia" . "jxq@jxq.me") (:keywords "convenience" "org") (:url . "https://github.com/jxq0/org-bookmarks-extractor"))]) (org-books . [(20210408 1913) ((enlive (0 0 1)) (s (1 11 0)) (helm (2 9 2)) (helm-org (1 0)) (dash (2 14 1)) (org (9 3)) (emacs (25))) "Reading list management with Org mode and helm" tar ((:commit . "9f4ec4a981bfc5eebff993c3ad49a4bed26aebd1") (:authors ("Abhinav Tushar" . "abhinav@lepisma.xyz")) (:maintainers ("Abhinav Tushar" . "abhinav@lepisma.xyz")) (:maintainer "Abhinav Tushar" . "abhinav@lepisma.xyz") (:keywords "outlines") (:url . "https://github.com/lepisma/org-books"))]) (org-brain . [(20230217 1908) ((emacs (25 1)) (org (9 2))) "Org-mode concept mapping" tar ((:commit . "2bad7732aae1a3051e2a14de2e30f970bbe43c25") (:authors ("Erik Sjöstrand" . "sjostrand.erik@gmail.com")) (:maintainers ("Erik Sjöstrand" . "sjostrand.erik@gmail.com")) (:maintainer "Erik Sjöstrand" . "sjostrand.erik@gmail.com") (:keywords "outlines" "hypermedia") (:url . "http://github.com/Kungsgeten/org-brain"))]) (org-bulletproof . [(20230615 640) ((emacs (27 1))) "Automatic plain list bullet cycling" tar ((:commit . "8ae80a53f8034914f502a8655f420c55078e02e1") (:authors ("Pontus Andersson" . "pondersson@gmail.com")) (:maintainers ("Pontus Andersson" . "pondersson@gmail.com")) (:maintainer "Pontus Andersson" . "pondersson@gmail.com") (:keywords "outlines" "convenience") (:url . "https://github.com/pondersson/org-bulletproof"))]) (org-bullets . [(20200317 1740) nil "Show bullets in org-mode as UTF-8 characters" tar ((:commit . "9ec0dbd30be7c6310804141ee952ac8c5f753557") (:authors ("sabof")) (:maintainers ("D. Williams" . "d.williams@posteo.net")) (:maintainer "D. Williams" . "d.williams@posteo.net") (:url . "https://github.com/integral-dw/org-bullets"))]) - (org-caldav . [(20240415 1535) ((emacs (26 3)) (org (9 1))) "Sync org files with external calendar through CalDAV" tar ((:commit . "086a8f385138ef71f7e29f78f19fb3a65f8ee27c") (:authors ("David Engster" . "deng@randomsample.de")) (:maintainers ("David Engster" . "deng@randomsample.de")) (:maintainer "David Engster" . "deng@randomsample.de") (:keywords "calendar" "caldav") (:url . "https://github.com/dengste/org-caldav/"))]) + (org-caldav . [(20240525 2231) ((emacs (26 3)) (org (9 1))) "Sync org files with external calendar through CalDAV" tar ((:commit . "f406828d3945c434de13e8aa9f7707d3466aee1b") (:authors ("David Engster" . "deng@randomsample.de")) (:maintainers ("David Engster" . "deng@randomsample.de")) (:maintainer "David Engster" . "deng@randomsample.de") (:keywords "calendar" "caldav") (:url . "https://github.com/dengste/org-caldav/"))]) (org-calibre-notes . [(20221202 1657) ((emacs (27 1))) "Extract highlights and notes from Calibre EPUB reader" tar ((:commit . "3120797ecbcb58827b91e3610e65579593d9a402") (:authors ("Bibek Panthi" . "bpanthi977@gmail.com")) (:maintainers ("Bibek Panthi" . "bpanthi977@gmail.com")) (:maintainer "Bibek Panthi" . "bpanthi977@gmail.com") (:url . "https://github.com/bpanthi977/org-calibre-notes"))]) (org-capture-pop-frame . [(20230516 236) ((emacs (24 4))) "Run org-capture in a new pop frame" tar ((:commit . "d88b75cc02fc53716701051dbdd906db0515de8c") (:authors ("Feng Shu" . "tumashu@163.com")) (:maintainers ("Feng Shu" . "tumashu@163.com")) (:maintainer "Feng Shu" . "tumashu@163.com") (:url . "https://github.com/tumashu/org-capture-pop-frame.git"))]) (org-category-capture . [(20230830 1733) ((org (9 0 0)) (emacs (24))) "Contextualy capture of org-mode TODOs." tar ((:commit . "bf1c30b750020ab8dd634dd66b2c7b76c56286c5") (:authors ("Ivan Malison" . "IvanMalison@gmail.com")) (:maintainers ("Ivan Malison" . "IvanMalison@gmail.com")) (:maintainer "Ivan Malison" . "IvanMalison@gmail.com") (:keywords "org-mode" "todo" "tools" "outlines") (:url . "https://github.com/IvanMalison/org-project-capture"))]) (org-change . [(20240318 2003) ((emacs (29 1)) (org (9 3))) "Annotate changes in org-mode files" tar ((:commit . "e944bb4a0943cdd06abd9032e6e6cbd34424ea42") (:keywords "wp" "convenience") (:url . "https://github.com/drghirlanda/org-change"))]) (org-chef . [(20231127 1601) ((org (0)) (emacs (24))) "Cookbook and recipe management with org-mode." tar ((:commit . "1710b54441ed744dcdfb125d08fb88cfaf452f10") (:authors ("Calvin Beck" . "hobbes@ualberta.ca")) (:maintainers ("Calvin Beck" . "hobbes@ualberta.ca")) (:maintainer "Calvin Beck" . "hobbes@ualberta.ca") (:keywords "convenience" "abbrev" "outlines" "org" "food" "recipes" "cooking") (:url . "https://github.com/Chobbes/org-chef"))]) - (org-cite-overlay . [(20240207 1611) ((emacs (28 1)) (citeproc (0 9 4))) "Overlays for org-cite citations" tar ((:commit . "cb401787b4569f43815cac55be8a319c489de3de") (:authors ("Samuel W. Flint" . "me@samuelwflint.com")) (:maintainers ("Samuel W. Flint" . "me@samuelwflint.com")) (:maintainer "Samuel W. Flint" . "me@samuelwflint.com") (:keywords "bib" "tex") (:url . "https://git.sr.ht/~swflint/org-cite-overlay"))]) - (org-cite-overlay-sidecar . [(20240213 1802) ((emacs (28 1)) (citeproc (0 9 4)) (org-cite-overlay (0 1 0)) (universal-sidecar (1 5 0)) (universal-sidecar-citeproc (1 0 0))) "Show Sidecar for overlaid org-cite citations" tar ((:commit . "bb23142f5d0d390196839fa9b3ce27ce4d149b59") (:authors ("Samuel W. Flint" . "me@samuelwflint.com")) (:maintainers ("Samuel W. Flint" . "me@samuelwflint.com")) (:maintainer "Samuel W. Flint" . "me@samuelwflint.com") (:keywords "bib") (:url . "https://git.sr.ht/~swflint/org-cite-overlay"))]) + (org-cite-overlay . [(20240523 100) ((emacs (28 1)) (citeproc (0 9 4))) "Overlays for org-cite citations" tar ((:commit . "dc23b55c708c6399a12dbc79281110de7681b121") (:authors ("Samuel W. Flint" . "me@samuelwflint.com")) (:maintainers ("Samuel W. Flint" . "me@samuelwflint.com")) (:maintainer "Samuel W. Flint" . "me@samuelwflint.com") (:keywords "bib" "tex") (:url . "https://git.sr.ht/~swflint/org-cite-overlay"))]) + (org-cite-overlay-sidecar . [(20240523 100) ((emacs (28 1)) (citeproc (0 9 4)) (org-cite-overlay (0 1 0)) (universal-sidecar (1 5 0)) (universal-sidecar-citeproc (1 0 0))) "Show Sidecar for overlaid org-cite citations" tar ((:commit . "dc23b55c708c6399a12dbc79281110de7681b121") (:authors ("Samuel W. Flint" . "me@samuelwflint.com")) (:maintainers ("Samuel W. Flint" . "me@samuelwflint.com")) (:maintainer "Samuel W. Flint" . "me@samuelwflint.com") (:keywords "bib") (:url . "https://git.sr.ht/~swflint/org-cite-overlay"))]) (org-cliplink . [(20201126 1020) ((emacs (24 4))) "insert org-mode links from the clipboard" tar ((:commit . "13e0940b65d22bec34e2de4bc8cba1412a7abfbc") (:authors ("Alexey Kutepov" . "reximkut@gmail.com")) (:maintainers ("Alexey Kutepov" . "reximkut@gmail.com")) (:maintainer "Alexey Kutepov" . "reximkut@gmail.com") (:url . "http://github.com/rexim/org-cliplink"))]) (org-clock-agenda-daytime-mode . [(20240403 1115) ((org (9 6 18)) (emacs (26 1))) "Display the time clocked today in the modeline" tar ((:commit . "f10c7b92a5b2a25f2300b885c2c70526ada50d9c") (:authors ("Arne Babenhauserheide" . "arne_bab@web.de")) (:maintainers ("Arne Babenhauserheide" . "arne_bab@web.de")) (:maintainer "Arne Babenhauserheide" . "arne_bab@web.de") (:keywords "org" "lisp" "clock" "time" "agenda") (:url . "https://www.draketo.de/software/emacs-daytime"))]) (org-clock-convenience . [(20230424 2101) ((org (8)) (emacs (24 3))) "Convenience functions for org time tracking" tar ((:commit . "08417dfd51deb400b890cf71c87b57393fc5ac8c") (:authors ("Derek Feichtinger <dfeich.gmail.com>")) (:maintainers ("Derek Feichtinger <dfeich.gmail.com>")) (:maintainer "Derek Feichtinger <dfeich.gmail.com>") (:keywords "convenience") (:url . "https://github.com/dfeich/org-clock-convenience"))]) @@ -3821,11 +3828,11 @@ (org-journal . [(20240218 1645) ((emacs (26 1)) (org (9 1))) "a simple org-mode based journaling mode" tar ((:commit . "859dc19168dc6b10eba3843f24980a7db79f6869") (:authors ("Bastian Bechtold") ("Christian Schwarzgruber")) (:maintainers ("Bastian Bechtold")) (:maintainer "Bastian Bechtold") (:url . "http://github.com/bastibe/org-journal"))]) (org-journal-list . [(20190221 2052) ((emacs (25))) "Org mode Journal List" tar ((:commit . "2b26d00181bb49bff64b31ad020490acd1b6ae02") (:authors ("Huy Tran" . "huytd189@gmail.com")) (:maintainers ("Huy Tran" . "huytd189@gmail.com")) (:maintainer "Huy Tran" . "huytd189@gmail.com") (:url . "https://github.com/huytd/org-journal-list"))]) (org-journal-tags . [(20240101 4) ((emacs (27 1)) (org-journal (2 1 2)) (magit-section (3 3 0)) (transient (0 3 7))) "Tagging and querying system for org-journal" tar ((:commit . "a68e40a8473ff18bef58a171245a9cdef6eee622") (:authors ("Korytov Pavel" . "thexcloud@gmail.com")) (:maintainers ("Korytov Pavel" . "thexcloud@gmail.com")) (:maintainer "Korytov Pavel" . "thexcloud@gmail.com") (:url . "https://github.com/SqrtMinusOne/org-journal-tags"))]) - (org-kanban . [(20240430 944) ((s (0)) (dash (2 17 0))) "kanban dynamic block for org-mode." tar ((:commit . "e316be6a4f64c4869b911d2cbdc4673a0e398a5f") (:authors ("Christian Köstlin" . "christian.koestlin@gmail.com")) (:maintainers ("Christian Köstlin" . "christian.koestlin@gmail.com")) (:maintainer "Christian Köstlin" . "christian.koestlin@gmail.com") (:keywords "org-mode" "org" "kanban" "tools") (:url . "http://github.com/gizmomogwai/org-kanban"))]) + (org-kanban . [(20240601 2153) ((s (0)) (dash (2 17 0))) "kanban dynamic block for org-mode." tar ((:commit . "93ceed7e5d837c4cd7daa2ad36426669d38f4e46") (:authors ("Christian Köstlin" . "christian.koestlin@gmail.com")) (:maintainers ("Christian Köstlin" . "christian.koestlin@gmail.com")) (:maintainer "Christian Köstlin" . "christian.koestlin@gmail.com") (:keywords "org-mode" "org" "kanban" "tools") (:url . "http://github.com/gizmomogwai/org-kanban"))]) (org-kindle . [(20220210 1408) ((emacs (25)) (cl-lib (0 5)) (seq (2 20))) "Send org link file to ebook reader." tar ((:commit . "fadcfd62e254d0c45e87d63128a82a08ae21869a") (:keywords "org" "link" "ebook" "kindle" "epub" "azw3" "mobi") (:url . "https://repo.or.cz/org-kindle.git"))]) (org-latex-impatient . [(20221111 623) ((emacs (26)) (s (1 8 0)) (posframe (0 8 0)) (org (9 3)) (dash (2 17 0))) "Preview org-latex Fragments Instantly via MathJax" tar ((:commit . "031025a8be9bf7255aa047388d027642cd2d6183") (:authors ("Sheng Yang" . "styang@fastmail.com")) (:maintainers ("Sheng Yang" . "styang@fastmail.com")) (:maintainer "Sheng Yang" . "styang@fastmail.com") (:keywords "tex" "tools") (:url . "https://github.com/yangsheng6810/org-latex-instant-preview"))]) (org-linenote . [(20240325 320) ((emacs (29 1)) (projectile (2 8 0)) (vertico (1 7))) "A package inspired by VSCode Linenote" tar ((:commit . "4c081f4bbe13c48df7cb17f2f006465b8b95196b") (:authors ("Jason Kim" . "sukbeom.kim@gmail.com")) (:maintainers ("Jason Kim" . "sukbeom.kim@gmail.com")) (:maintainer "Jason Kim" . "sukbeom.kim@gmail.com") (:keywords "tools" "note" "org") (:url . "https://github.com/seokbeomKim/org-linenote"))]) - (org-link-beautify . [(20240312 529) ((emacs (28 1)) (nerd-icons (0 0 1)) (fb2-reader (0 1 1)) (qrencode (1 2))) "Beautify Org Links" tar ((:commit . "c77338cfac89a41f90eafea80d11d8134e8096f4") (:keywords "hypermedia") (:url . "https://repo.or.cz/org-link-beautify.git"))]) + (org-link-beautify . [(20240530 113) ((emacs (28 1)) (nerd-icons (0 0 1)) (fb2-reader (0 1 1)) (qrencode (1 2))) "Beautify Org Links" tar ((:commit . "d91f56ca7a4ad63100671a415b0f53d040ef89e8") (:keywords "hypermedia") (:url . "https://repo.or.cz/org-link-beautify.git"))]) (org-link-travis . [(20140405 2327) ((org (7))) "Insert/Export the link of Travis CI on org-mode" tar ((:commit . "596615ad8373d9090bd4138da683524f0ad0bda5") (:authors ("Hiroaki Otsu" . "ootsuhiroaki@gmail.com")) (:maintainers ("Hiroaki Otsu" . "ootsuhiroaki@gmail.com")) (:maintainer "Hiroaki Otsu" . "ootsuhiroaki@gmail.com") (:keywords "org") (:url . "https://github.com/aki2o/org-link-travis"))]) (org-linkotron . [(20200112 2235) ((emacs (26 1)) (org (9 3))) "Org-mode link selector" tar ((:commit . "d0adc5247b205bc73d2f1a83d4a512d2be541eb5") (:authors ("Per Weijnitz" . "per.weijnitz@gmail.com")) (:maintainers ("Per Weijnitz" . "per.weijnitz@gmail.com")) (:maintainer "Per Weijnitz" . "per.weijnitz@gmail.com") (:keywords "hypermedia" "org") (:url . "https://gitlab.com/perweij/org-linkotron"))]) (org-listcruncher . [(20210706 1741) ((seq (2 3)) (emacs (26 1))) "Planning tool - Parse Org mode lists into table" tar ((:commit . "075e0e6d36eb50406a608bc8a2f0dd359ec63938") (:authors ("Derek Feichtinger" . "dfeich@gmail.com")) (:maintainers ("Derek Feichtinger" . "dfeich@gmail.com")) (:maintainer "Derek Feichtinger" . "dfeich@gmail.com") (:keywords "convenience") (:url . "https://github.com/dfeich/org-listcruncher"))]) @@ -3835,10 +3842,10 @@ (org-mind-map . [(20180826 2340) ((emacs (24)) (dash (1 8 0)) (org (8 2 10))) "Creates a directed graph from org-mode files" tar ((:commit . "41df4b2e30455494f1848b4e06cc9208aa9e902b") (:authors ("Ted Wiles" . "theodore.wiles@gmail.com")) (:maintainers ("Ted Wiles" . "theodore.wiles@gmail.com")) (:maintainer "Ted Wiles" . "theodore.wiles@gmail.com") (:keywords "orgmode" "extensions" "graphviz" "dot") (:url . "https://github.com/theodorewiles/org-mind-map"))]) (org-ml . [(20230410 30) ((emacs (27 1)) (org (9 3)) (dash (2 17)) (s (1 12))) "Functional Org Mode API" tar ((:commit . "f57336a9126a168ad32ccce017c072474555395a") (:authors ("Nathan Dwarshuis" . "ndwar@yavin4.ch")) (:maintainers ("Nathan Dwarshuis" . "ndwar@yavin4.ch")) (:maintainer "Nathan Dwarshuis" . "ndwar@yavin4.ch") (:keywords "org-mode" "outlines") (:url . "https://github.com/ndwarshuis/org-ml"))]) (org-mobile-sync . [(20180606 524) ((emacs (24 3 50)) (org (8 0))) "automatically sync org-mobile on changes" tar ((:commit . "06764b943a528827df1e2acc6bc7806cc2c1351f") (:authors ("steckerhalter")) (:maintainers ("steckerhalter")) (:maintainer "steckerhalter") (:keywords "org-mode" "org" "mobile" "sync" "todo") (:url . "https://framagit.org/steckerhalter/org-mobile-sync"))]) - (org-modern . [(20240515 1932) ((emacs (27 1)) (compat (29 1 4 4))) "Modern looks for Org" tar ((:commit . "ea829ce4b3ac035808d411b1a088e0947d75f554") (:authors ("Daniel Mendler" . "mail@daniel-mendler.de")) (:maintainers ("Daniel Mendler" . "mail@daniel-mendler.de")) (:maintainer "Daniel Mendler" . "mail@daniel-mendler.de") (:keywords "outlines" "hypermedia" "text") (:url . "https://github.com/minad/org-modern"))]) + (org-modern . [(20240602 926) ((emacs (27 1)) (compat (29 1 4 4))) "Modern looks for Org" tar ((:commit . "0b7af08548e586c0d3b0ca4a683253da407220d1") (:authors ("Daniel Mendler" . "mail@daniel-mendler.de")) (:maintainers ("Daniel Mendler" . "mail@daniel-mendler.de")) (:maintainer "Daniel Mendler" . "mail@daniel-mendler.de") (:keywords "outlines" "hypermedia" "text") (:url . "https://github.com/minad/org-modern"))]) (org-movies . [(20210920 101) ((emacs (26 1)) (org (9 0)) (request (0 3 0))) "Manage watchlist with Org mode" tar ((:commit . "e96fecaffa2924de64a507aa31d2934e667ee1ea") (:authors ("Anh T Nguyen")) (:maintainers ("Anh T Nguyen")) (:maintainer "Anh T Nguyen") (:keywords "hypermedia" "outlines" "org") (:url . "https://github.com/teeann/org-movies"))]) (org-mpv-notes . [(20231210 628) ((emacs (28 1))) "Take notes in org mode while watching videos in mpv" tar ((:commit . "01d6d52a1f964e7bb61f0f65ac4fb2ccfa986f34") (:authors ("Bibek Panthi" . "bpanthi977@gmail.com")) (:maintainers ("Bibek Panthi" . "bpanthi977@gmail.com")) (:maintainer "Bibek Panthi" . "bpanthi977@gmail.com") (:url . "https://github.com/bpanthi977/org-mpv-notes"))]) - (org-mru-clock . [(20230704 850) ((emacs (26 1))) "Clock in/out of tasks with completion and persistent history" tar ((:commit . "66fe744df9100efc4ec68089f7d0ce56a0d38b8b") (:authors ("Kevin Brubeck Unhammer" . "unhammer@fsfe.org")) (:maintainers ("Kevin Brubeck Unhammer" . "unhammer@fsfe.org")) (:maintainer "Kevin Brubeck Unhammer" . "unhammer@fsfe.org") (:keywords "convenience" "calendar") (:url . "https://github.com/unhammer/org-mru-clock"))]) + (org-mru-clock . [(20240522 826) ((emacs (26 1))) "Clock in/out of tasks with completion and persistent history" tar ((:commit . "198beb2089ea5e457dd13e8ac64d775eeff8fd89") (:authors ("Kevin Brubeck Unhammer" . "unhammer@fsfe.org")) (:maintainers ("Kevin Brubeck Unhammer" . "unhammer@fsfe.org")) (:maintainer "Kevin Brubeck Unhammer" . "unhammer@fsfe.org") (:keywords "convenience" "calendar") (:url . "https://github.com/unhammer/org-mru-clock"))]) (org-msg . [(20240319 1947) ((emacs (24 4)) (htmlize (1 54))) "Org mode to send and reply to email in HTML." tar ((:commit . "8ce92fecae371b7cfd5ef3c0a3ac280e5664487d") (:authors ("Jérémy Compostella" . "jeremy.compostella@gmail.com")) (:maintainers ("Jérémy Compostella" . "jeremy.compostella@gmail.com")) (:maintainer "Jérémy Compostella" . "jeremy.compostella@gmail.com") (:keywords "extensions" "mail") (:url . "https://github.com/jeremy-compostella/org-msg"))]) (org-multi-wiki . [(20210324 1820) ((emacs (26 1)) (dash (2 12)) (s (1 12)) (org-ql (0 5)) (org (9 3))) "Multiple wikis based on Org mode" tar ((:commit . "bf8039aadddaf02569fab473f766071ef7e63563") (:authors ("Akira Komamura" . "akira.komamura@gmail.com")) (:maintainers ("Akira Komamura" . "akira.komamura@gmail.com")) (:maintainer "Akira Komamura" . "akira.komamura@gmail.com") (:keywords "org" "outlines" "files") (:url . "https://github.com/akirak/org-multi-wiki"))]) (org-multiple-keymap . [(20191017 1920) ((org (8 2 4)) (emacs (24)) (cl-lib (0 5))) "Set keymap to elements, such as timestamp and priority." tar ((:commit . "4eb8aa0aada012b2346cc7f0c55e07783141a2c3") (:authors ("myuhe <yuhei.maeda_at_gmail.com>")) (:maintainers ("myuhe")) (:maintainer "myuhe") (:keywords "convenience" "org-mode") (:url . "https://github.com/myuhe/org-multiple-keymap.el"))]) @@ -3877,10 +3884,10 @@ (org-recent-headings . [(20211011 1519) ((emacs (26 1)) (org (9 0 5)) (dash (2 18 0)) (frecency (0 1)) (s (1 12 0))) "Jump to recently used Org headings" tar ((:commit . "97418d581ea030f0718794e50b005e9bae44582e") (:authors ("Adam Porter" . "adam@alphapapa.net")) (:maintainers ("Adam Porter" . "adam@alphapapa.net")) (:maintainer "Adam Porter" . "adam@alphapapa.net") (:keywords "hypermedia" "outlines" "org") (:url . "http://github.com/alphapapa/org-recent-headings"))]) (org-recur . [(20230124 1532) ((emacs (24 1)) (org (9 0)) (dash (2 7 0))) "Recurring org-mode tasks" tar ((:commit . "628099883a63d219f76cd9631cc914fe6ec8a3e3") (:authors ("Marcin Swieczkowski" . "marcin.swieczkowski@gmail.com")) (:maintainers ("Marcin Swieczkowski" . "marcin.swieczkowski@gmail.com")) (:maintainer "Marcin Swieczkowski" . "marcin.swieczkowski@gmail.com") (:url . "https://github.com/mrcnski/org-recur"))]) (org-redmine . [(20160711 1114) nil "Redmine tools using Emacs OrgMode" tar ((:commit . "a526c3ac802634486bf10de9c2283ccb1a30ec8d") (:authors ("Wataru MIYAGUNI" . "gonngo@gmail.com")) (:maintainers ("Wataru MIYAGUNI" . "gonngo@gmail.com")) (:maintainer "Wataru MIYAGUNI" . "gonngo@gmail.com") (:keywords "redmine" "org") (:url . "https://github.com/gongo/org-redmine"))]) - (org-ref . [(20240509 1211) ((org (9 4)) (dash (0)) (s (0)) (f (0)) (htmlize (0)) (hydra (0)) (avy (0)) (parsebib (0)) (bibtex-completion (0)) (citeproc (0)) (ox-pandoc (0)) (request (0))) "citations, cross-references and bibliographies in org-mode" tar ((:commit . "e435bc60228b985806ea7ea0856ceef1e5262c83") (:authors ("John Kitchin" . "jkitchin@andrew.cmu.edu")) (:maintainers ("John Kitchin" . "jkitchin@andrew.cmu.edu")) (:maintainer "John Kitchin" . "jkitchin@andrew.cmu.edu") (:keywords "org-mode" "cite" "ref" "label") (:url . "https://github.com/jkitchin/org-ref"))]) + (org-ref . [(20240602 1316) ((org (9 4)) (dash (0)) (s (0)) (f (0)) (htmlize (0)) (hydra (0)) (avy (0)) (parsebib (0)) (bibtex-completion (0)) (citeproc (0)) (ox-pandoc (0)) (request (0))) "citations, cross-references and bibliographies in org-mode" tar ((:commit . "23d2e06b144e464e3c9498522e090813742b7b7c") (:authors ("John Kitchin" . "jkitchin@andrew.cmu.edu")) (:maintainers ("John Kitchin" . "jkitchin@andrew.cmu.edu")) (:maintainer "John Kitchin" . "jkitchin@andrew.cmu.edu") (:keywords "org-mode" "cite" "ref" "label") (:url . "https://github.com/jkitchin/org-ref"))]) (org-ref-prettify . [(20220507 649) ((emacs (24 3)) (org-ref (3 0)) (bibtex-completion (1 0 0))) "Prettify org-ref citation links" tar ((:commit . "0ec3b6e398ee117c8b8a787a0422b95d9e95f7bb") (:authors ("Alex Kost" . "alezost@gmail.com") ("Vitus Schäfftlein" . "vitusschaefftlein@live.de")) (:maintainers ("Alex Kost" . "alezost@gmail.com")) (:maintainer "Alex Kost" . "alezost@gmail.com") (:keywords "convenience") (:url . "https://github.com/alezost/org-ref-prettify.el"))]) (org-repo-todo . [(20171228 119) nil "Simple repository todo management with org-mode" tar ((:commit . "f73ebd91399c5760ad52c6ad9033de1066042003") (:authors ("justin talbott" . "justin@waymondo.com")) (:maintainers ("justin talbott" . "justin@waymondo.com")) (:maintainer "justin talbott" . "justin@waymondo.com") (:keywords "convenience") (:url . "https://github.com/waymondo/org-repo-todo"))]) - (org-reverse-datetree . [(20221203 259) ((emacs (28 1)) (dash (2 19)) (org (9 5))) "Create reverse date trees in org-mode" tar ((:commit . "fca95cd22ed29653f3217034c71ec0ab0a7c7734") (:authors ("Akira Komamura" . "akira.komamura@gmail.com")) (:maintainers ("Akira Komamura" . "akira.komamura@gmail.com")) (:maintainer "Akira Komamura" . "akira.komamura@gmail.com") (:keywords "outlines") (:url . "https://github.com/akirak/org-reverse-datetree"))]) + (org-reverse-datetree . [(20240530 1306) ((emacs (29 1)) (dash (2 19 1)) (org (9 6))) "Create reverse date trees in org-mode" tar ((:commit . "116d99a6bdf873cb61cc508afb48facffda0c049") (:authors ("Akira Komamura" . "akira.komamura@gmail.com")) (:maintainers ("Akira Komamura" . "akira.komamura@gmail.com")) (:maintainer "Akira Komamura" . "akira.komamura@gmail.com") (:keywords "outlines") (:url . "https://github.com/akirak/org-reverse-datetree"))]) (org-review . [(20230119 1706) nil "schedule reviews for Org entries" tar ((:commit . "77211e40db8a9558b866f5660c7127922b459e6c") (:authors ("Alan Schmitt" . "alan.schmitt@polytechnique.org")) (:maintainers ("Alan Schmitt" . "alan.schmitt@polytechnique.org")) (:maintainer "Alan Schmitt" . "alan.schmitt@polytechnique.org") (:keywords "org" "review") (:url . "https://github.com/brabalan/org-review"))]) (org-rich-yank . [(20240302 659) ((emacs (25 1))) "Paste with org-mode markup and link to source" tar ((:commit . "50925a1183a51a6b3a9cf9ce23c425735e622e42") (:authors ("Kevin Brubeck Unhammer" . "unhammer@fsfe.org")) (:maintainers ("Kevin Brubeck Unhammer" . "unhammer@fsfe.org")) (:maintainer "Kevin Brubeck Unhammer" . "unhammer@fsfe.org") (:keywords "convenience" "hypermedia" "org") (:url . "https://github.com/unhammer/org-rich-yank"))]) (org-roam . [(20240114 1941) ((emacs (26 1)) (dash (2 13)) (org (9 4)) (emacsql (20230228)) (magit-section (3 0 0))) "A database abstraction layer for Org-mode" tar ((:commit . "2e94f55cc58f6dce2772a6f33521eb5afcf67265") (:authors ("Jethro Kuan" . "jethrokuan95@gmail.com")) (:maintainers ("Jethro Kuan" . "jethrokuan95@gmail.com")) (:maintainer "Jethro Kuan" . "jethrokuan95@gmail.com") (:keywords "org-mode" "roam" "convenience") (:url . "https://github.com/org-roam/org-roam"))]) @@ -3895,7 +3902,7 @@ (org-scrum . [(20200131 1129) ((emacs (24 5)) (org (8 2)) (seq (2 3)) (cl-lib (1 0))) "org mode extensions for scrum planning and reporting" tar ((:commit . "a383348ea80c2459bfb96fa0652b98f0059bd311") (:authors ("Ian Martins" . "ianxm@jhu.edu")) (:maintainers ("Ian Martins" . "ianxm@jhu.edu")) (:maintainer "Ian Martins" . "ianxm@jhu.edu") (:url . "https://github.com/ianxm/emacs-scrum"))]) (org-seek . [(20161217 502) ((emacs (24 3)) (ag (0 48))) "Searching Org-mode files with search tools." tar ((:commit . "1f51e6634e3b9a6a29d335d0d14370a6ffef2265") (:authors ("stardiviner" . "numbchild@gmail.com")) (:maintainers ("stardiviner" . "numbchild@gmail.com")) (:maintainer "stardiviner" . "numbchild@gmail.com") (:keywords "org" "search" "ag" "pt") (:url . "https://github.com/stardiviner/org-seek.el"))]) (org-shoplist . [(20210629 2157) ((emacs (25))) "Eat the world" tar ((:commit . "71ea7643e66c97d21df49fb8b600578ca0464f83") (:authors ("lordnik22")) (:maintainers ("lordnik22")) (:maintainer "lordnik22") (:keywords "extensions" "matching") (:url . "https://github.com/lordnik22"))]) - (org-side-tree . [(20240130 656) ((emacs (28 1))) "Navigate Org outlines in side window tree" tar ((:commit . "62169a26edfafacd681ecaf84289dd6b58be6c32") (:authors ("Grant Rosson <https://github.com/localauthor>")) (:maintainers ("Grant Rosson <https://github.com/localauthor>")) (:maintainer "Grant Rosson <https://github.com/localauthor>") (:url . "https://github.com/localauthor/org-side-tree"))]) + (org-side-tree . [(20240601 1001) ((emacs (28 1))) "Navigate Org outlines in side window tree" tar ((:commit . "e8da5217ce23440a62f4a46ef60e2082b6284b28") (:authors ("Grant Rosson <https://github.com/localauthor>")) (:maintainers ("Grant Rosson <https://github.com/localauthor>")) (:maintainer "Grant Rosson <https://github.com/localauthor>") (:url . "https://github.com/localauthor/org-side-tree"))]) (org-sidebar . [(20240102 9) ((emacs (26 1)) (compat (29 1)) (s (1 10 0)) (dash (2 18)) (org (9 6)) (org-ql (0 2)) (org-super-agenda (1 0))) "Helpful sidebar for Org buffers" tar ((:commit . "1e06d1b4ab5f0d09301712cdecb757c9437a7179") (:authors ("Adam Porter" . "adam@alphapapa.net")) (:maintainers ("Adam Porter" . "adam@alphapapa.net")) (:maintainer "Adam Porter" . "adam@alphapapa.net") (:keywords "hypermedia" "outlines" "org" "agenda") (:url . "https://github.com/alphapapa/org-sidebar"))]) (org-sliced-images . [(20240325 710) ((emacs (29 1)) (org (9 6 15))) "Sliced inline images in org-mode" tar ((:commit . "f3964d4ba421953fe9f109a99811b6d884ca56ab") (:authors ("Jacob Fong" . "jacobcfong@gmail.com")) (:maintainers ("Jacob Fong" . "jacobcfong@gmail.com")) (:maintainer "Jacob Fong" . "jacobcfong@gmail.com") (:url . "https://github.com/jcfk/org-sliced-images"))]) (org-snooze . [(20181229 1424) ((emacs (24 4))) "Snooze your code, doc and feed" tar ((:commit . "8799adc14a20f3489063d279ff69312de3180bf9") (:authors ("Bill Xue")) (:maintainers ("Bill Xue")) (:maintainer "Bill Xue") (:keywords "extensions") (:url . "https://github.com/xueeinstein/org-snooze.el"))]) @@ -3912,7 +3919,7 @@ (org-table-color . [(20220311 1927) ((emacs (26 1))) "Add color to your org-mode table cells" tar ((:commit . "2022f301ef323953c3a0e087a1b601da85e06da1") (:authors ("Colin Woodbury" . "colin@fosskers.ca")) (:maintainers ("Colin Woodbury" . "colin@fosskers.ca")) (:maintainer "Colin Woodbury" . "colin@fosskers.ca") (:keywords "data" "faces" "lisp") (:url . "https://github.com/fosskers/org-table-color"))]) (org-table-comment . [(20120209 1851) nil "Org table comment modes." tar ((:commit . "33b9966c33ecbc3e27cca67c2f2cdea04364d74e") (:authors ("Matthew L. Fidler <matthew dot fidler at gmail . com>")) (:maintainers ("Matthew L. Fidler")) (:maintainer "Matthew L. Fidler") (:keywords "org-mode" "orgtbl") (:url . "http://github.com/mlf176f2/org-table-comment.el"))]) (org-table-sticky-header . [(20190924 506) ((org (8 2 10)) (emacs (24 4))) "Sticky header for org-mode tables" tar ((:commit . "b65442857128ab04724aaa301e60aa874a31a798") (:authors ("Junpeng Qiu" . "qjpchmail@gmail.com")) (:maintainers ("Junpeng Qiu" . "qjpchmail@gmail.com")) (:maintainer "Junpeng Qiu" . "qjpchmail@gmail.com") (:keywords "extensions"))]) - (org-tag-beautify . [(20240422 607) ((emacs (26 1)) (nerd-icons (0 0 1))) "Beautify Org mode tags" tar ((:commit . "2f8b66e7aa2227411665f36d96bfc8a1b184bfbb") (:keywords "hypermedia") (:url . "https://repo.or.cz/org-tag-beautify.git"))]) + (org-tag-beautify . [(20240531 1220) ((emacs (26 1)) (nerd-icons (0 0 1))) "Beautify Org mode tags" tar ((:commit . "7a20f8ea4143a9182cc78cb5a6b452ad40a22836") (:keywords "hypermedia") (:url . "https://repo.or.cz/org-tag-beautify.git"))]) (org-tagged . [(20220926 2048) ((s (1 13 0)) (dash (2 19 1)) (emacs (28 1)) (org (9 5 2))) "Dynamic block for tagged org-mode todos" tar ((:commit . "4b0174473772fca976426e982bb3f4a3037c1e37") (:authors ("Christian Köstlin" . "christian.koestlin@gmail.com")) (:maintainers ("Christian Köstlin" . "christian.koestlin@gmail.com")) (:maintainer "Christian Köstlin" . "christian.koestlin@gmail.com") (:keywords "org-mode" "org" "gtd" "tools") (:url . "http://github.com/gizmomogwai/org-tagged"))]) (org-tanglesync . [(20200127 1616) ((emacs (24 4))) "Syncing org src blocks with tangled external files" tar ((:commit . "31aa5502d1d4f8b032807949908c016b00556684") (:authors ("Mehmet Tekman")) (:maintainers ("Mehmet Tekman")) (:maintainer "Mehmet Tekman") (:keywords "outlines") (:url . "https://github.com/mtekman/org-tanglesync.el"))]) (org-tfl . [(20170923 1218) ((org (0 16 2)) (cl-lib (0 5)) (emacs (24 1))) "Transport for London meets Orgmode" tar ((:commit . "f0d7d39106a1de5457f5160cddd98ab892b61066") (:authors ("storax (David Zuber), <zuber [dot] david [at] gmx [dot] de>")) (:maintainers ("storax (David Zuber), <zuber [dot] david [at] gmx [dot] de>")) (:maintainer "storax (David Zuber), <zuber [dot] david [at] gmx [dot] de>") (:keywords "org" "tfl") (:url . "https://github.com/storax/org-tfl"))]) @@ -4054,7 +4061,6 @@ (package-lint-flymake . [(20240330 1458) ((emacs (26 1)) (package-lint (0 5))) "A package-lint Flymake backend" tar ((:commit . "17e4ab20dd3e36fa540007b4f4047170c23bdb10") (:url . "https://github.com/purcell/package-lint"))]) (package-loading-notifier . [(20230809 446) ((emacs (25))) "Notify a package is being loaded" tar ((:commit . "f64f994cb1a55f9d59444deaec884bff0ed2b26e") (:authors ("SeungKi Kim" . "tttuuu888@gmail.com")) (:maintainers ("SeungKi Kim" . "tttuuu888@gmail.com")) (:maintainer "SeungKi Kim" . "tttuuu888@gmail.com") (:keywords "convenience" "faces" "config" "startup") (:url . "https://github.com/tttuuu888/package-loading-notifier"))]) (package-utils . [(20220630 2345) ((restart-emacs (0 1 1))) "Extensions for package.el" tar ((:commit . "0168172062467b1bff913ea955b2ef709b43ecfa") (:authors ("Philippe Vaucher" . "philippe.vaucher@gmail.com")) (:maintainers ("Philippe Vaucher" . "philippe.vaucher@gmail.com")) (:maintainer "Philippe Vaucher" . "philippe.vaucher@gmail.com") (:keywords "package" "convenience") (:url . "https://github.com/Silex/package-utils"))]) - (packed . [(20221130 2228) ((emacs (25 1)) (compat (28 1 1 0))) "[DEPRECATED] Package manager agnostic Emacs Lisp package utilities" tar ((:commit . "169064f7acfe198cc7dd43d02518b773691e1314") (:authors ("Jonas Bernoulli" . "jonas@bernoul.li")) (:maintainers ("Jonas Bernoulli" . "jonas@bernoul.li")) (:maintainer "Jonas Bernoulli" . "jonas@bernoul.li") (:keywords "lisp") (:url . "https://github.com/emacscollective/packed"))]) (pacmacs . [(20220106 2248) ((emacs (24 4)) (dash (2 18 0)) (cl-lib (0 5)) (f (0 18 0))) "Pacman for Emacs" tar ((:commit . "25a8c30210f6bd94634a7ff743a2f8be391ed3b3") (:authors ("Codingteam" . "codingteam@conference.jabber.ru")) (:maintainers ("Alexey Kutepov" . "reximkut@gmail.com")) (:maintainer "Alexey Kutepov" . "reximkut@gmail.com") (:url . "http://github.com/codingteam/pacmacs.el"))]) (pact-mode . [(20201219 2223) ((emacs (24 3))) "Mode for Pact, a LISPlike smart contract language." tar ((:commit . "f48a4faf5f8f8435423bda3888eca6ee67ee13a9") (:authors ("Stuart Popejoy")) (:maintainers ("Stuart Popejoy" . "stuart@kadena.io")) (:maintainer "Stuart Popejoy" . "stuart@kadena.io") (:keywords "pact" "lisp" "languages" "blockchain" "smartcontracts" "tools" "mode") (:url . "https://github.com/kadena-io/pact-mode"))]) (paganini-theme . [(20180815 1921) ((emacs (24 0))) "A colorful, dark and warm theme." tar ((:commit . "255c5a2a8abee9c5935465ec42b9c3604c178c3c") (:authors ("Onur Temizkan")) (:maintainers ("Onur Temizkan")) (:maintainer "Onur Temizkan") (:url . "https://github.com/onurtemizkan/paganini"))]) @@ -4068,7 +4074,7 @@ (panda . [(20240102 348) ((emacs (25))) "Client for Bamboo's REST API." tar ((:commit . "286785687d4ffe29fd1d95c699d378743d32ac00") (:authors ("Sebastian Monia" . "smonia@outlook.com")) (:maintainers ("Sebastian Monia" . "smonia@outlook.com")) (:maintainer "Sebastian Monia" . "smonia@outlook.com") (:keywords "maint" "tool") (:url . "https://github.com/sebasmonia/panda"))]) (panda-theme . [(20181128 1738) ((emacs (24))) "Panda Theme" tar ((:commit . "60aa47c7a930377807da0d601351ad91e8ca446a") (:authors ("jamiecollinson" . "jamiecollinson@gmail.com")) (:maintainers ("jamiecollinson" . "jamiecollinson@gmail.com")) (:maintainer "jamiecollinson" . "jamiecollinson@gmail.com") (:url . "https://github.com/jamiecollinson/emacs-panda-theme"))]) (pandoc . [(20161128 1157) ((emacs (24 4))) "Pandoc interface" tar ((:commit . "198d262d09e30448f1672338b0b5a81cf75e1eaa") (:authors ("USAMI Kenta" . "tadsan@zonu.me")) (:maintainers ("USAMI Kenta" . "tadsan@zonu.me")) (:maintainer "USAMI Kenta" . "tadsan@zonu.me") (:keywords "hypermedia" "documentation" "markup" "converter") (:url . "https://github.com/zonuexe/pandoc.el"))]) - (pandoc-mode . [(20240311 2218) ((hydra (0 10 0)) (dash (2 10 0))) "Minor mode for interacting with Pandoc" tar ((:commit . "c7fa568ab9cfbb2abfb9b22f419d28ce570d7b22") (:authors ("Joost Kremers" . "joostkremers@fastmail.fm")) (:maintainers ("Joost Kremers" . "joostkremers@fastmail.fm")) (:maintainer "Joost Kremers" . "joostkremers@fastmail.fm") (:keywords "text" "pandoc") (:url . "http://joostkremers.github.io/pandoc-mode/"))]) + (pandoc-mode . [(20240602 1006) ((hydra (0 10 0)) (dash (2 10 0))) "Minor mode for interacting with Pandoc" tar ((:commit . "18214fc2df357b50e62c79993aac4ff0cf1d9499") (:authors ("Joost Kremers" . "joostkremers@fastmail.fm")) (:maintainers ("Joost Kremers" . "joostkremers@fastmail.fm")) (:maintainer "Joost Kremers" . "joostkremers@fastmail.fm") (:keywords "text" "pandoc") (:url . "http://joostkremers.github.io/pandoc-mode/"))]) (pangu-spacing . [(20221025 522) nil "Minor-mode to add space between Chinese and English characters." tar ((:commit . "2303013e5cd7852136f1429162fea0e1c8cb0221") (:authors ("coldnew" . "coldnew.tw@gmail.com")) (:maintainers ("coldnew" . "coldnew.tw@gmail.com")) (:maintainer "coldnew" . "coldnew.tw@gmail.com") (:url . "http://github.com/coldnew/pangu-spacing"))]) (paper-theme . [(20230318 48) ((emacs (24))) "A minimal Emacs colour theme." tar ((:commit . "8d337b85592ae44e1fa3ad03f0c65ca99036f9e2") (:authors ("Göktuğ Kayaalp")) (:maintainers ("Göktuğ Kayaalp")) (:maintainer "Göktuğ Kayaalp") (:keywords "theme" "paper") (:url . "https://dev.gkayaalp.com/elisp/index.html#paper"))]) (paperless . [(20240130 1048) ((emacs (29 1)) (f (0 11 0)) (s (1 10 0)) (cl-lib (0 7 1))) "A major mode for sorting and filing PDF documents" tar ((:commit . "ef2e7ef5aeaffa997794f5d6e27be6631ba05d34") (:authors ("Anthony Green" . "green@moxielogic.com")) (:maintainers ("Anthony Green" . "green@moxielogic.com")) (:maintainer "Anthony Green" . "green@moxielogic.com") (:keywords "pdf" "convenience") (:url . "https://github.com/atgreen/paperless"))]) @@ -4080,7 +4086,7 @@ (paren-completer . [(20160501 1052) ((emacs (24 3))) "Automatically, language agnostically, fill in delimiters." tar ((:commit . "74183a8e13fa1266271bdcbcb4bfb29a4f915f0a") (:authors ("Matthew Bregg")) (:maintainers ("Matthew Bregg")) (:maintainer "Matthew Bregg") (:keywords "convenience") (:url . "https://github.com/MatthewBregg/paren-completer"))]) (paren-face . [(20240415 1547) ((emacs (25 1)) (compat (29 1 4 1))) "A face for parentheses in lisp modes" tar ((:commit . "0cad6a4657ebfcdd2902746b99f01fea7cc05bd7") (:authors ("Jonas Bernoulli" . "emacs.paren-face@jonas.bernoulli.dev")) (:maintainers ("Jonas Bernoulli" . "emacs.paren-face@jonas.bernoulli.dev")) (:maintainer "Jonas Bernoulli" . "emacs.paren-face@jonas.bernoulli.dev") (:keywords "faces" "lisp") (:url . "https://github.com/tarsius/paren-face"))]) (parent-mode . [(20240210 1906) nil "get major mode's parent modes" tar ((:commit . "9fe5363b2a190619641c79b3a40d874d8c8f9f40") (:authors ("Fanael Linithien" . "fanael4@gmail.com")) (:maintainers ("Fanael Linithien" . "fanael4@gmail.com")) (:maintainer "Fanael Linithien" . "fanael4@gmail.com") (:url . "https://github.com/Fanael/parent-mode"))]) - (parinfer-rust-mode . [(20240506 816) ((emacs (26 1)) (track-changes (1 1))) "An interface for the parinfer-rust library" tar ((:commit . "d3bfb2745cc0858e2741dc2a2f00a86f456656ec") (:authors ("Justin Barclay" . "justinbarclay@gmail.com")) (:maintainers ("Justin Barclay" . "justinbarclay@gmail.com")) (:maintainer "Justin Barclay" . "justinbarclay@gmail.com") (:keywords "lisp" "tools") (:url . "https://github.com/justinbarclay/parinfer-rust-mode"))]) + (parinfer-rust-mode . [(20240523 1909) ((emacs (26 1)) (track-changes (1 1))) "An interface for the parinfer-rust library" tar ((:commit . "e9a23e136b8c5f1fb718af93c19cd6ed22d8c98c") (:authors ("Justin Barclay" . "justinbarclay@gmail.com")) (:maintainers ("Justin Barclay" . "justinbarclay@gmail.com")) (:maintainer "Justin Barclay" . "justinbarclay@gmail.com") (:keywords "lisp" "tools") (:url . "https://github.com/justinbarclay/parinfer-rust-mode"))]) (parrot . [(20220101 518) ((emacs (24 1))) "Party Parrot rotates gracefully in mode-line." tar ((:commit . "1d381f24d74242018e306d1a0c891bed9a465ac3") (:authors ("Daniel Ting" . "deep.paren.12@gmail.com")) (:maintainers ("Daniel Ting" . "deep.paren.12@gmail.com")) (:maintainer "Daniel Ting" . "deep.paren.12@gmail.com") (:keywords "party" "parrot" "rotate" "sirocco" "kakapo" "games") (:url . "https://github.com/dp12/parrot.git"))]) (parse-csv . [(20160512 1723) nil "Parse strings with CSV fields into s-expressions" tar ((:commit . "96bef1ffbc89ea12d13311c9fa239c5c3e864890") (:authors ("Edward Marco Baringer (Common Lisp)") ("Matt Curtis" . "matt.r.curtis@gmail.com")) (:maintainers ("Matt Curtis" . "matt.r.curtis@gmail.com")) (:maintainer "Matt Curtis" . "matt.r.curtis@gmail.com") (:keywords "csv") (:url . "https://github.com/mrc/el-csv"))]) (parse-it . [(20240101 946) ((emacs (25 1)) (s (1 12 0))) "Basic Parser in Emacs Lisp" tar ((:commit . "cdc4386ef8e94ccdeff3700021d4a944034ae559") (:authors ("Shen, Jen-Chieh" . "jcs090218@gmail.com")) (:maintainers ("Shen, Jen-Chieh" . "jcs090218@gmail.com")) (:maintainer "Shen, Jen-Chieh" . "jcs090218@gmail.com") (:keywords "convenience" "parse" "parser" "lex" "lexer" "ast") (:url . "https://github.com/jcs-elpa/parse-it"))]) @@ -4149,7 +4155,7 @@ (perspective-project-bridge . [(20231024 1737) ((emacs (27 1)) (perspective (2 18))) "Integration of perspective.el + project.el" tar ((:commit . "7b65b08a0151b8279fc3ae75f0016cb8d5eadb53") (:authors ("Arunkumar Vaidyanathan" . "arunkumarmv1997@gmail.com")) (:maintainers ("Arunkumar Vaidyanathan" . "arunkumarmv1997@gmail.com")) (:maintainer "Arunkumar Vaidyanathan" . "arunkumarmv1997@gmail.com") (:keywords "perspective" "project" "convenience" "frames") (:url . "https://github.com/arunkmv/perspective-project-bridge"))]) (perspeen . [(20171203 1021) ((emacs (25 0)) (powerline (2 4))) "An package for multi-workspace" tar ((:commit . "edb70c530bda50ff3d1756e32a703d5fef5e5480") (:authors ("Peng Li" . "seudut@gmail.com")) (:maintainers ("Peng Li" . "seudut@gmail.com")) (:maintainer "Peng Li" . "seudut@gmail.com") (:keywords "lisp") (:url . "https://github.com/seudut/perspeen"))]) (pest-mode . [(20221231 15) ((emacs (26 3))) "Major mode for editing Pest files" tar ((:commit . "8023a92ce59c34dcd1587cbd85ed144f206ddb89") (:authors ("ksqsf" . "i@ksqsf.moe")) (:maintainers ("ksqsf" . "i@ksqsf.moe")) (:maintainer "ksqsf" . "i@ksqsf.moe") (:keywords "languages") (:url . "https://github.com/ksqsf/pest-mode"))]) - (pet . [(20230906 46) ((emacs (26 1)) (f (0 6 0)) (map (3 3 1)) (seq (2 24))) "Executable and virtualenv tracker for python-mode" tar ((:commit . "acd54c5b0171a82f88988b4fe2e6db112df5bf9a") (:authors ("Jimmy Yuen Ho Wong" . "wyuenho@gmail.com")) (:maintainers ("Jimmy Yuen Ho Wong" . "wyuenho@gmail.com")) (:maintainer "Jimmy Yuen Ho Wong" . "wyuenho@gmail.com") (:keywords "tools") (:url . "https://github.com/wyuenho/emacs-pet/"))]) + (pet . [(20240601 2355) ((emacs (26 1)) (f (0 6 0)) (map (3 3 1)) (seq (2 24))) "Executable and virtualenv tracker for python-mode" tar ((:commit . "44304055d666176bf765595f294a39b3226033bd") (:authors ("Jimmy Yuen Ho Wong" . "wyuenho@gmail.com")) (:maintainers ("Jimmy Yuen Ho Wong" . "wyuenho@gmail.com")) (:maintainer "Jimmy Yuen Ho Wong" . "wyuenho@gmail.com") (:keywords "tools") (:url . "https://github.com/wyuenho/emacs-pet/"))]) (pfuture . [(20220913 1401) ((emacs (25 2))) "a simple wrapper around asynchronous processes" tar ((:commit . "19b53aebbc0f2da31de6326c495038901bffb73c") (:authors ("Alexander Miller" . "alexanderm@web.de")) (:maintainers ("Alexander Miller" . "alexanderm@web.de")) (:maintainer "Alexander Miller" . "alexanderm@web.de") (:url . "https://github.com/Alexander-Miller/pfuture"))]) (pg . [(20240520 1322) ((emacs (28 1)) (peg (1 0))) "Emacs Lisp socket-level interface to the PostgreSQL RDBMS" tar ((:commit . "0f20a0051ab898ea53903284c47a4703555380ca") (:authors ("Eric Marsden" . "eric.marsden@risk-engineering.org")) (:maintainers ("Eric Marsden" . "eric.marsden@risk-engineering.org")) (:maintainer "Eric Marsden" . "eric.marsden@risk-engineering.org") (:keywords "data" "comm" "database" "postgresql") (:url . "https://github.com/emarsden/pg-el"))]) (pgdevenv . [(20150105 2236) nil "Manage your PostgreSQL development envs" tar ((:commit . "7f1d5bc734750aca98cf67a9491cdbd5615fd132") (:authors ("Dimitri Fontaine" . "dim@tapoueh.org")) (:maintainers ("Dimitri Fontaine" . "dim@tapoueh.org")) (:maintainer "Dimitri Fontaine" . "dim@tapoueh.org") (:keywords "emacs" "postgresql" "development" "environment" "shell" "debug" "gdb"))]) @@ -4169,13 +4175,13 @@ (php-boris-minor-mode . [(20140209 1835) ((php-boris (0 0 1)) (highlight (0))) "a minor mode to evaluate PHP code in the Boris repl" tar ((:commit . "8648eba604e4ff82ef6594a2c5ee4cb4825e6235") (:authors ("steckerhalter")) (:maintainers ("steckerhalter")) (:maintainer "steckerhalter") (:keywords "php" "repl" "eval") (:url . "https://github.com/steckerhalter/php-boris-minor-mode"))]) (php-cs-fixer . [(20220516 1008) ((cl-lib (0 5))) "php-cs-fixer wrapper." tar ((:commit . "efe4368d891f1eec6311363cfd6be3e9eadb5e0a") (:authors ("Philippe Ivaldi for OVYA")) (:maintainers ("Philippe Ivaldi for OVYA")) (:maintainer "Philippe Ivaldi for OVYA") (:keywords "languages" "php") (:url . "https://github.com/OVYA/php-cs-fixer"))]) (php-eldoc . [(20140202 1941) nil "eldoc backend for php" tar ((:commit . "df05064146b884d9081e10657e32dc480f070cfe") (:authors ("sabof")) (:maintainers ("sabof")) (:maintainer "sabof") (:url . "https://github.com/sabof/php-eldoc"))]) - (php-mode . [(20240118 1458) ((emacs (26 1))) "Major mode for editing PHP code" tar ((:commit . "f0a14387427244251883889ba616c7f042323f6d") (:authors ("Eric James Michael Ritz")) (:maintainers ("USAMI Kenta" . "tadsan@zonu.me")) (:maintainer "USAMI Kenta" . "tadsan@zonu.me") (:keywords "languages" "php") (:url . "https://github.com/emacs-php/php-mode"))]) + (php-mode . [(20240527 1834) ((emacs (26 1))) "Major mode for editing PHP code" tar ((:commit . "c8e4c16ca0d234f4a659713a94467f0c32ef4bc8") (:authors ("Eric James Michael Ritz")) (:maintainers ("USAMI Kenta" . "tadsan@zonu.me")) (:maintainer "USAMI Kenta" . "tadsan@zonu.me") (:keywords "languages" "php") (:url . "https://github.com/emacs-php/php-mode"))]) (php-quickhelp . [(20210819 2025) ((emacs (25 1))) "Quickhelp at point for php" tar ((:commit . "d5e11b7a6bad64550521e8822139a33218b8c9bb") (:authors ("Vincenzo Pupillo")) (:maintainers ("Vincenzo Pupillo")) (:maintainer "Vincenzo Pupillo") (:url . "https://github.com/vpxyz/php-quickhelp"))]) (php-refactor-mode . [(20171124 635) nil "Minor mode to quickly and safely perform common refactorings" tar ((:commit . "d06dabd9ca743a04067e02282b69d7b7467fb4b7") (:authors ("Matthew M. Keeler" . "keelerm84@gmail.com")) (:maintainers ("Matthew M. Keeler" . "keelerm84@gmail.com")) (:maintainer "Matthew M. Keeler" . "keelerm84@gmail.com") (:keywords "php" "refactor") (:url . "https://github.com/keelerm84/php-refactor-mode.el"))]) (php-runtime . [(20230404 1713) ((emacs (25 1)) (compat (29))) "Language binding bridge to PHP" tar ((:commit . "ba64f30e716f89f9cf2c3bd44c5d00da69736868") (:authors ("USAMI Kenta" . "tadsan@zonu.me")) (:maintainers ("USAMI Kenta" . "tadsan@zonu.me")) (:maintainer "USAMI Kenta" . "tadsan@zonu.me") (:keywords "processes" "php" "lisp") (:url . "https://github.com/emacs-php/php-runtime.el"))]) (php-scratch . [(20210706 459) ((emacs (24 3)) (s (1 11 0)) (php-mode (1 17 0))) "A scratch buffer to interactively evaluate php code" tar ((:commit . "b6bfd279da8a8ac7fc30459485956f3fd5d02573") (:authors ("Tijs Mallaerts" . "tijs.mallaerts@gmail.com")) (:maintainers ("Tijs Mallaerts" . "tijs.mallaerts@gmail.com")) (:maintainer "Tijs Mallaerts" . "tijs.mallaerts@gmail.com") (:url . "https://github.com/mallt/php-scratch"))]) - (phpactor . [(20240407 1500) ((emacs (25 1)) (f (0 17)) (php-runtime (0 2)) (composer (0 2 0)) (async (1 9 3))) "Interface to Phpactor" tar ((:commit . "1916e35e08d746a6ff8a2cd88ae43bdb6842feab") (:authors ("USAMI Kenta" . "tadsan@zonu.me") ("Mikael Kermorgant" . "mikael@kgtech.fi")) (:maintainers ("USAMI Kenta" . "tadsan@zonu.me")) (:maintainer "USAMI Kenta" . "tadsan@zonu.me") (:keywords "tools" "php") (:url . "https://github.com/emacs-php/phpactor.el"))]) - (phpstan . [(20230417 1142) ((emacs (24 3)) (compat (29)) (php-mode (1 22 3)) (php-runtime (0 2))) "Interface to PHPStan" tar ((:commit . "2dc25cb2f3d83484ea0eb063c9ffca8148828a2b") (:authors ("USAMI Kenta" . "tadsan@zonu.me")) (:maintainers ("USAMI Kenta" . "tadsan@zonu.me")) (:maintainer "USAMI Kenta" . "tadsan@zonu.me") (:keywords "tools" "php") (:url . "https://github.com/emacs-php/phpstan.el"))]) + (phpactor . [(20240527 459) ((emacs (25 1)) (f (0 17)) (php-runtime (0 2)) (composer (0 2 0)) (async (1 9 3))) "Interface to Phpactor" tar ((:commit . "6b5269ff82785a9bd1e648b2f91e5128353d5a67") (:authors ("USAMI Kenta" . "tadsan@zonu.me") ("Mikael Kermorgant" . "mikael@kgtech.fi")) (:maintainers ("USAMI Kenta" . "tadsan@zonu.me")) (:maintainer "USAMI Kenta" . "tadsan@zonu.me") (:keywords "tools" "php") (:url . "https://github.com/emacs-php/phpactor.el"))]) + (phpstan . [(20240527 2142) ((emacs (24 3)) (compat (29)) (php-mode (1 22 3)) (php-runtime (0 2))) "Interface to PHPStan" tar ((:commit . "6f1c7bb357b1eb90b10a081f1831c1c548c40456") (:authors ("USAMI Kenta" . "tadsan@zonu.me")) (:maintainers ("USAMI Kenta" . "tadsan@zonu.me")) (:maintainer "USAMI Kenta" . "tadsan@zonu.me") (:keywords "tools" "php") (:url . "https://github.com/emacs-php/phpstan.el"))]) (phpt-mode . [(20190512 1809) ((emacs (25)) (polymode (0 1 5)) (php-mode (1 21 2))) "Major mode for editing PHPT test code" tar ((:commit . "deb386f1a81003074c476f15e1975d445ff6df01") (:authors ("USAMI Kenta" . "tadsan@zonu.me")) (:maintainers ("USAMI Kenta" . "tadsan@zonu.me")) (:maintainer "USAMI Kenta" . "tadsan@zonu.me") (:keywords "languages" "php") (:url . "https://github.com/emacs-php/phpt-mode"))]) (phpunit . [(20230801 1523) ((s (1 12 0)) (f (0 19 0)) (pkg-info (0 6)) (cl-lib (0 5)) (emacs (24 3))) "Launch PHP unit tests using phpunit" tar ((:commit . "e5baa445363942fbd9898ac3cb91eea64b69d316") (:authors ("Nicolas Lamirault" . "nicolas.lamirault@gmail.com") ("Eric Hansen" . "hansen.c.eric@gmail.com")) (:maintainers ("Nicolas Lamirault" . "nicolas.lamirault@gmail.com")) (:maintainer "Nicolas Lamirault" . "nicolas.lamirault@gmail.com") (:keywords "tools" "php" "tests" "phpunit") (:url . "https://github.com/nlamirault/phpunit.el"))]) (pianobar . [(20201002 1756) nil "thin wrapper for Pianobar, a Pandora Radio client" tar ((:commit . "d708417608df4f09ee565fddaad03dfe181829a8") (:authors ("Aaron Griffith" . "aargri@gmail.com")) (:maintainers ("Aaron Griffith" . "aargri@gmail.com")) (:maintainer "Aaron Griffith" . "aargri@gmail.com") (:url . "http://github.com/agrif/pianobar.el"))]) @@ -4204,7 +4210,7 @@ (pixiv-novel-mode . [(20160220 1421) nil "Major mode for pixiv novel" tar ((:commit . "0d1ca524d92b91f20a7105402a773bc21779b434") (:authors ("USAMI Kenta" . "tadsan@zonu.me")) (:maintainers ("USAMI Kenta" . "tadsan@zonu.me")) (:maintainer "USAMI Kenta" . "tadsan@zonu.me") (:keywords "novel" "pixiv"))]) (pkg-info . [(20150517 1143) ((epl (0 8))) "Information about packages" tar ((:commit . "4dbe328c9eced79e0004e3fdcd7bfb997a928be5") (:authors ("Sebastian Wiesner" . "swiesner@lunaryorn.com")) (:maintainers ("Sebastian Wiesner" . "swiesner@lunaryorn.com")) (:maintainer "Sebastian Wiesner" . "swiesner@lunaryorn.com") (:keywords "convenience") (:url . "https://github.com/lunaryorn/pkg-info.el"))]) (pkg-overview . [(20210802 1509) ((emacs (24 3))) "Make org documentation from elisp source file" tar ((:commit . "9b2e416758a6c107bb8cc670ec4d2627f82d5590") (:authors ("Boruch Baum" . "boruch_baum@gmx.com")) (:maintainers ("Boruch Baum" . "boruch_baum@gmx.com")) (:maintainer "Boruch Baum" . "boruch_baum@gmx.com") (:keywords "docs" "help" "lisp" "maint" "outlines" "tools") (:url . "https://github.com/Boruch-Baum/emacs-pkg-overview"))]) - (pkgbuild-mode . [(20220802 1951) ((emacs (26 1))) "Interface to the ArchLinux package manager" tar ((:commit . "9525be8ecbd3a0d0bc7cc27e6d0f403e111aa067") (:authors ("Juergen Hoetzel" . "juergen@hoetzel.info")) (:maintainers ("Juergen Hoetzel" . "juergen@hoetzel.info")) (:maintainer "Juergen Hoetzel" . "juergen@hoetzel.info") (:keywords "languages") (:url . "https://github.com/juergenhoetzel/pkgbuild-mode"))]) + (pkgbuild-mode . [(20240531 1602) ((emacs (26 1))) "Interface to the Arch Linux package manager" tar ((:commit . "8ef396d8fa9187b65c065a6bc2ca15dfaf3255df") (:authors ("Juergen Hoetzel" . "juergen@hoetzel.info")) (:maintainers ("Juergen Hoetzel" . "juergen@hoetzel.info")) (:maintainer "Juergen Hoetzel" . "juergen@hoetzel.info") (:keywords "languages") (:url . "https://github.com/juergenhoetzel/pkgbuild-mode"))]) (pkl-mode . [(20240422 1529) ((emacs (24 3))) "Major mode for editing Pkl files" tar ((:commit . "c57fe374a9c57eee6432d0b449e410ab8dc40a89") (:authors ("sin-ack" . "sin-ack@protonmail.com")) (:maintainers ("sin-ack" . "sin-ack@protonmail.com")) (:maintainer "sin-ack" . "sin-ack@protonmail.com") (:keywords "languages" "pkl") (:url . "https://github.com/sin-ack/pkl-mode"))]) (plain-org-wiki . [(20201217 1027) ((emacs (24 3)) (ivy (0 12 0))) "Simple jump-to-org-files in a directory package" tar ((:commit . "faeeb54ca808bbf0f4380a938e75805b7a78dbf7") (:authors ("Oleh Krehel" . "ohwoeowho@gmail.com")) (:maintainers ("Oleh Krehel" . "ohwoeowho@gmail.com")) (:maintainer "Oleh Krehel" . "ohwoeowho@gmail.com") (:keywords "convenience") (:url . "https://github.com/abo-abo/plain-org-wiki"))]) (plain-theme . [(20171124 410) ((emacs (24))) "Plain theme without syntax highlighting" tar ((:commit . "2609a811335d58cfb73a65d6307c156fe09037d3"))]) @@ -4252,7 +4258,7 @@ (poly-wdl . [(20190712 529) ((emacs (25)) (polymode (0 2)) (wdl-mode (20170709))) "Polymode for WDL" tar ((:commit . "fe2ee0c441795c35a8c127fa1f7006a5f251f564") (:authors ("Jean Monlong" . "jean.monlong@gmail.com")) (:maintainers ("Jean Monlong" . "jean.monlong@gmail.com")) (:maintainer "Jean Monlong" . "jean.monlong@gmail.com") (:keywords "languages") (:url . "https://github.com/jmonlong/poly-wdl"))]) (polybar-sesman . [(20210901 1336) ((emacs (25 1)) (dash (2 19 1)) (sesman (0 3 0))) "Display active sesman connections in polybar" tar ((:commit . "5b8ff640ada92da98400206ba9a61140093a823f") (:authors ("Mark Dawson" . "markgdawson@gmail.com")) (:maintainers ("Mark Dawson" . "markgdawson@gmail.com")) (:maintainer "Mark Dawson" . "markgdawson@gmail.com") (:keywords "project" "convenience") (:url . "https://github.com/markgdawson/polybar-sesman.el"))]) (polymode . [(20230317 1218) ((emacs (25))) "Extensible framework for multiple major modes" tar ((:commit . "ca060e081a1f849a880732670dc15370ac987b89") (:authors ("Vitalie Spinu")) (:maintainers ("Vitalie Spinu" . "spinuvit@gmail.com")) (:maintainer "Vitalie Spinu" . "spinuvit@gmail.com") (:keywords "languages" "multi-modes" "processes") (:url . "https://github.com/polymode/polymode"))]) - (pomidor . [(20220714 1932) ((emacs (24 3)) (alert (1 2)) (dash (2 17 0))) "Simple and cool pomodoro timer" tar ((:commit . "394a52f95587b1d10d0c3bdca503d2cc876db35b") (:authors ("TatriX" . "tatrics@gmail.com")) (:maintainers ("TatriX" . "tatrics@gmail.com")) (:maintainer "TatriX" . "tatrics@gmail.com") (:keywords "tools" "time" "applications" "pomodoro technique") (:url . "https://github.com/TatriX/pomidor"))]) + (pomidor . [(20240601 1617) ((emacs (24 3)) (alert (1 2)) (dash (2 17 0))) "Simple and cool pomodoro timer" tar ((:commit . "de71c34a1a9aff745181107094d3389816dbeca5") (:authors ("TatriX" . "tatrics@gmail.com")) (:maintainers ("TatriX" . "tatrics@gmail.com")) (:maintainer "TatriX" . "tatrics@gmail.com") (:keywords "tools" "time" "applications" "pomodoro technique") (:url . "https://github.com/TatriX/pomidor"))]) (pomm . [(20240130 2126) ((emacs (27 1)) (alert (1 2)) (seq (2 22)) (transient (0 3 0))) "Pomodoro and Third Time timers" tar ((:commit . "a95343f643b5674ad7714dc62f8436ba87ad8335") (:authors ("Korytov Pavel" . "thexcloud@gmail.com")) (:maintainers ("Korytov Pavel" . "thexcloud@gmail.com")) (:maintainer "Korytov Pavel" . "thexcloud@gmail.com") (:url . "https://github.com/SqrtMinusOne/pomm.el"))]) (pomodoro . [(20210225 2018) nil "A timer for the Pomodoro Technique" tar ((:commit . "ed888b24d0b89a5dec6f5278b1064c530c827321") (:authors ("David Kerschner" . "dkerschner@gmail.com")) (:maintainers ("David Kerschner" . "dkerschner@gmail.com")) (:maintainer "David Kerschner" . "dkerschner@gmail.com"))]) (pony-mode . [(20170807 1522) nil "Minor mode for working with Django Projects" tar ((:commit . "760684d30b6c234d1b88c9a4673a808f36f7f341") (:authors ("David Miller" . "david@deadpansincerity.com")) (:maintainer "David Miller" . "david@deadpansincerity.com") (:keywords "python" "django") (:url . "https://github.com/davidmiller/pony-mode"))]) @@ -4290,7 +4296,7 @@ (prescient . [(20240226 204) ((emacs (25 1))) "Better sorting and filtering" tar ((:commit . "c39bf07c56b427bf41aafd7d20eaef5cf3c312b5") (:authors ("Radian LLC" . "contact+prescient@radian.codes")) (:maintainers ("Radian LLC" . "contact+prescient@radian.codes")) (:maintainer "Radian LLC" . "contact+prescient@radian.codes") (:keywords "extensions") (:url . "https://github.com/raxod502/prescient.el"))]) (preseed-generic-mode . [(20180210 500) nil "Debian preseed file major mode" tar ((:commit . "3aa8806c4a659064baa01751400c53fbaf847f66") (:authors ("Tong Sun" . "suntong@users.sourceforge.net")) (:maintainers ("Tong Sun" . "suntong@users.sourceforge.net")) (:maintainer "Tong Sun" . "suntong@users.sourceforge.net") (:url . "https://github.com/suntong/preseed-generic-mode"))]) (presentation . [(20180427 224) ((emacs (24 4)) (cl-lib (0 5))) "Display large character for presentation" tar ((:commit . "b1948e6d8b37b6df9290d77d181e1b1d58dd33c0") (:authors ("USAMI Kenta" . "tadsan@zonu.me")) (:maintainers ("USAMI Kenta" . "tadsan@zonu.me")) (:maintainer "USAMI Kenta" . "tadsan@zonu.me") (:keywords "environment" "faces" "frames") (:url . "https://github.com/zonuexe/emacs-presentation-mode"))]) - (prettier . [(20231002 1153) ((emacs (26 1)) (iter2 (0 9)) (nvm (0 2)) (editorconfig (0 8))) "Code formatting with Prettier" tar ((:commit . "d6d7a6ac9e8a08ab497d2cf4d7e2317f6b93dfbf") (:authors ("Julian Scheid" . "julians37@gmail.com")) (:maintainers ("Julian Scheid" . "julians37@gmail.com")) (:maintainer "Julian Scheid" . "julians37@gmail.com") (:keywords "convenience" "languages" "files") (:url . "https://github.com/jscheid/prettier.el"))]) + (prettier . [(20240601 1316) ((emacs (26 1)) (iter2 (0 9)) (nvm (0 2)) (editorconfig (0 8))) "Code formatting with Prettier" tar ((:commit . "53327f039f2d4f3fd1eabece190857059b3765b5") (:authors ("Julian Scheid" . "julians37@gmail.com")) (:maintainers ("Julian Scheid" . "julians37@gmail.com")) (:maintainer "Julian Scheid" . "julians37@gmail.com") (:keywords "convenience" "languages" "files") (:url . "https://github.com/jscheid/prettier.el"))]) (prettier-js . [(20180109 726) nil "Minor mode to format JS code on file save" tar ((:commit . "0e8b95c4e5898a03e85dbc555c37b4f968292aec") (:authors ("James Long and contributors")) (:maintainers ("James Long and contributors")) (:maintainer "James Long and contributors") (:keywords "convenience" "wp" "edit" "js") (:url . "https://github.com/prettier/prettier-emacs"))]) (prettier-rc . [(20220330 145) ((emacs (24 3)) (prettier-js (0 1 0))) "Use local rc rules with prettier" tar ((:commit . "99e40a9783299e41911f6b37156626d53e43809e") (:authors ("Joel Bryan Juliano <joelbryan dot juliano at gmail dot com>")) (:maintainers ("Joel Bryan Juliano <joelbryan dot juliano at gmail dot com>")) (:maintainer "Joel Bryan Juliano <joelbryan dot juliano at gmail dot com>") (:keywords "convenience" "edit" "js" "ts" "rc" "prettierrc" "prettier-rc" "prettier" "prettier-js") (:url . "https://github.com/jjuliano/prettier-rc-emacs"))]) (prettify-greek . [(20160603 908) nil "Greek letters for prettify-symbols" tar ((:commit . "698d07a6ffe85f6fb53f3bfec4f49380c25cfd90") (:keywords "faces") (:url . "https://gitlab.com/fommil/emacs-prettify-greek"))]) @@ -4376,6 +4382,7 @@ (puni . [(20231231 1415) ((emacs (26 1))) "Parentheses Universalistic" tar ((:commit . "72e091ef30e0c9299dbcd0bc4669ab9bb8fb6e47") (:authors ("Hao Wang" . "amaikinono@gmail.com")) (:maintainers ("Hao Wang" . "amaikinono@gmail.com")) (:maintainer "Hao Wang" . "amaikinono@gmail.com") (:keywords "convenience" "lisp" "tools") (:url . "https://github.com/AmaiKinono/puni"))]) (punpun-themes . [(20221121 1018) ((emacs (24 1))) "A set of bleak themes" tar ((:commit . "6a7e04de1ad9f7ba9074b7206bffc9241c33349c") (:authors ("Vasilij Schneidermann" . "mail@vasilij.de")) (:maintainer "Vasilij Schneidermann" . "mail@vasilij.de") (:url . "https://depp.brause.cc/punpun-themes"))]) (puppet-mode . [(20210305 645) ((emacs (24 1)) (pkg-info (0 4))) "Major mode for Puppet manifests" tar ((:commit . "ab25cf379236f4e1bd4bc9c1d77a93c95800e9bf") (:authors ("Vox Pupuli" . "voxpupuli@groups.io") ("Bozhidar Batsov" . "bozhidar@batsov.com") ("Sebastian Wiesner" . "swiesner@lunaryorn.com") ("Russ Allbery" . "rra@stanford.edu")) (:maintainers ("Vox Pupuli" . "voxpupuli@groups.io")) (:maintainer "Vox Pupuli" . "voxpupuli@groups.io") (:keywords "languages") (:url . "https://github.com/voxpupuli/puppet-mode"))]) + (puppet-ts-mode . [(20240530 629) ((emacs (29 1))) "Major mode for Puppet using Tree-sitter" tar ((:commit . "edd6a1f60ebc7b6d59458da482fd5e964f2922fb") (:authors ("Stefan Möding" . "stm@kill-9.net")) (:maintainers ("Stefan Möding" . "stm@kill-9.net")) (:maintainer "Stefan Möding" . "stm@kill-9.net") (:keywords "languages") (:url . "https://github.com/smoeding/puppet-ts-mode"))]) (purescript-mode . [(20230309 1301) ((emacs (25 1))) "A PureScript editing mode" tar ((:commit . "eacc61aaafe6055b5f278c9843558f220f18b153") (:authors ("1992 Simon Marlow") ("1997-1998 Graeme E Moss" . "gem@cs.york.ac.uk") ("Tommy Thorn" . "thorn@irisa.fr") ("2001-2002 Reuben Thomas (>=v1.4)") ("2003 Dave Love" . "fx@gnu.org") ("2014 Tim Dysinger" . "tim@dysinger.net")) (:maintainer "1992 Simon Marlow") (:keywords "faces" "files" "purescript") (:url . "https://github.com/purescript-emacs/purescript-mode"))]) (purp-theme . [(20210912 1940) nil "A dark color theme with few colors" tar ((:commit . "8d3510e1ed995b8323cd5205626ddde6386a76ca") (:authors ("Vincent Foley" . "vfoley@gmail.com")) (:maintainers ("Vincent Foley" . "vfoley@gmail.com")) (:maintainer "Vincent Foley" . "vfoley@gmail.com") (:keywords "faces") (:url . "https://github.com/gnuvince/purp"))]) (purple-haze-theme . [(20141015 229) ((emacs (24 0))) "an overtly purple color theme for Emacs24." tar ((:commit . "3e245cbef7cd09e6b3ee124963e372a04e9a6485") (:authors ("Jason Milkins" . "jasonm23@gmail.com")) (:maintainers ("Jason Milkins" . "jasonm23@gmail.com")) (:maintainer "Jason Milkins" . "jasonm23@gmail.com") (:url . "https://github.com/jasonm23/emacs-purple-haze-theme"))]) @@ -4596,7 +4603,7 @@ (riscv-mode . [(20220916 206) ((emacs (24 4))) "Major-mode for RISC V assembly" tar ((:commit . "8e335b9c93de93ed8dd063d702b0f5ad48eef6d7") (:authors ("Adam Niederer <https://github.com/AdamNiederer>")) (:maintainers ("Adam Niederer")) (:maintainer "Adam Niederer") (:keywords "riscv" "assembly") (:url . "https://github.com/AdamNiederer/riscv-mode"))]) (rivet-mode . [(20201013 1905) ((emacs (24)) (web-mode (16))) "A minor mode for editing Apache Rivet files" tar ((:commit . "6cf58cf04fee933113857af07414b3f27c24b505") (:authors ("Jade Michael Thornton")) (:maintainers ("Jade Michael Thornton")) (:maintainer "Jade Michael Thornton") (:url . "https://gitlab.com/thornjad/rivet-mode"))]) (rjsx-mode . [(20200224 2149) ((emacs (24 4)) (js2-mode (20170504))) "Real support for JSX" tar ((:commit . "0061587a06cdc2579a8d0e90863498d96bf982d8") (:authors ("Felipe Ochoa" . "felipe@fov.space")) (:maintainers ("Felipe Ochoa" . "felipe@fov.space")) (:maintainer "Felipe Ochoa" . "felipe@fov.space") (:keywords "languages") (:url . "https://github.com/felipeochoa/rjsx-mode/"))]) - (rmsbolt . [(20240507 47) ((emacs (25 1))) "A compiler output viewer" tar ((:commit . "32604147643dbfebe499ea8a4b139cc68acd2746") (:authors ("Jay Kamat" . "jaygkamat@gmail.com")) (:maintainers ("Jay Kamat" . "jaygkamat@gmail.com")) (:maintainer "Jay Kamat" . "jaygkamat@gmail.com") (:keywords "compilation" "tools") (:url . "http://gitlab.com/jgkamat/rmsbolt"))]) + (rmsbolt . [(20240601 1656) ((emacs (25 1))) "A compiler output viewer" tar ((:commit . "af0a9d327087c450fd240cabced343273f66763a") (:authors ("Jay Kamat" . "jaygkamat@gmail.com")) (:maintainers ("Jay Kamat" . "jaygkamat@gmail.com")) (:maintainer "Jay Kamat" . "jaygkamat@gmail.com") (:keywords "compilation" "tools") (:url . "http://gitlab.com/jgkamat/rmsbolt"))]) (robe . [(20240509 155) ((inf-ruby (2 5 1)) (emacs (25 1))) "Code navigation, documentation lookup and completion for Ruby" tar ((:commit . "6bc8a07fc483407971de0966d367a11006b3ab80") (:authors ("Dmitry Gutov")) (:maintainers ("Dmitry Gutov")) (:maintainer "Dmitry Gutov") (:keywords "ruby" "convenience" "rails") (:url . "https://github.com/dgutov/robe"))]) (robot-log . [(20220719 1301) ((emacs (28 1))) "Major mode for viewing RobotFramework debug log files" tar ((:commit . "26da47597aa97be9649cb60f4da6d94d47d0c0ac") (:keywords "convenience" "files") (:url . "https://git.sr.ht/~apteryx/emacs-robot-log"))]) (robot-mode . [(20231118 826) ((emacs (26 1))) "Major-mode for Robot Framework files" tar ((:commit . "cb12e5adcba3379a67483e268229c152e0a8405f") (:authors ("Kalle Kankare" . "kalle.kankare@iki.fi")) (:maintainers ("Kalle Kankare" . "kalle.kankare@iki.fi")) (:maintainer "Kalle Kankare" . "kalle.kankare@iki.fi") (:keywords "languages" "files") (:url . "https://github.com/kopoli/robot-mode"))]) @@ -4670,7 +4677,7 @@ (say-what-im-doing . [(20160706 1931) nil "dictate what you're doing with text to speech" tar ((:commit . "5b2ce6783b02805bcac1107a149bfba3852cd9d5") (:authors ("Benaiah Mischenko")) (:maintainers ("Benaiah Mischenko")) (:maintainer "Benaiah Mischenko") (:keywords "text to speech" "dumb" "funny") (:url . "http://github.com/benaiah/say-what-im-doing"))]) (sayid . [(20220101 1357) ((cider (0 21 0))) "sayid nREPL middleware client" tar ((:commit . "879aff586336a0ec4d46c0ed4720fb1de22082bd") (:authors ("Bill Piel" . "bill@billpiel.com")) (:maintainers ("Bozhidar Batsov" . "bozhidar@batsov.dev")) (:maintainer "Bozhidar Batsov" . "bozhidar@batsov.dev") (:keywords "clojure" "cider" "debugger") (:url . "https://github.com/clojure-emacs/sayid"))]) (sbt-mode . [(20240404 1105) ((emacs (24 4))) "Interactive support for sbt projects" tar ((:commit . "cc68728a6ef0600aad369157b3a2d0ce56afba9b") (:keywords "languages") (:url . "https://github.com/hvesalai/emacs-sbt-mode"))]) - (scad-mode . [(20240429 1628) ((emacs (27 1)) (compat (29 1 4 4))) "A major mode for editing OpenSCAD code" tar ((:commit . "8b830727c343bf762d9469b413f0c2a4c1996fe2") (:authors ("Len Trigg, Łukasz Stelmach, zk_phi, Daniel Mendler")) (:maintainers ("Len Trigg <lenbok@gmail.com>, Daniel Mendler" . "mail@daniel-mendler.de")) (:maintainer "Len Trigg <lenbok@gmail.com>, Daniel Mendler" . "mail@daniel-mendler.de") (:keywords "languages") (:url . "https://github.com/openscad/emacs-scad-mode"))]) + (scad-mode . [(20240523 1738) ((emacs (27 1)) (compat (29 1 4 4))) "A major mode for editing OpenSCAD code" tar ((:commit . "3c32b141f083c31539bb24700eb0aa23ea55918c") (:authors ("Len Trigg, Łukasz Stelmach, zk_phi, Daniel Mendler")) (:maintainers ("Len Trigg <lenbok@gmail.com>, Daniel Mendler" . "mail@daniel-mendler.de")) (:maintainer "Len Trigg <lenbok@gmail.com>, Daniel Mendler" . "mail@daniel-mendler.de") (:keywords "languages") (:url . "https://github.com/openscad/emacs-scad-mode"))]) (scad-preview . [(20211212 1128) ((scad-mode (91 0)) (emacs (24 4))) "Preview SCAD models in real-time within Emacs" tar ((:commit . "c5449b26c63f3e0a695905a7e4e84f8d844f761b") (:authors ("zk_phi")) (:maintainers ("zk_phi")) (:maintainer "zk_phi") (:url . "https://zk-phi.github.io/"))]) (scala-mode . [(20240113 1743) nil "Major mode for editing Scala" tar ((:commit . "4c6d636b86e3bb1d95de819dc48dda92abdfbcf4") (:keywords "languages") (:url . "https://github.com/hvesalai/emacs-scala-mode"))]) (scala-repl . [(20240427 1456) ((emacs (29 1))) "Scala REPL Mode" tar ((:commit . "679bdf663e0b32a5a285d6f98daa2e3d5de60289") (:authors ("Daian YUE" . "sheepduke@gmail.com")) (:maintainers ("Daian YUE" . "sheepduke@gmail.com")) (:maintainer "Daian YUE" . "sheepduke@gmail.com") (:keywords "languages" "tools") (:url . "https://github.com/sheepduke/scala-repl.el"))]) @@ -4781,7 +4788,7 @@ (showtip . [(20090830 1040) nil "Show tip at cursor" tar ((:commit . "930da302809a4257e8d69425455b29e1cc91949b") (:authors ("Ye Wenbin" . "wenbinye@gmail.com")) (:maintainers ("Ye Wenbin" . "wenbinye@gmail.com")) (:maintainer "Ye Wenbin" . "wenbinye@gmail.com") (:keywords "help"))]) (shpec-mode . [(20150530 922) nil "Minor mode for shpec specification" tar ((:commit . "76bccd63e3b70233a6c9ca0798dd03550952cc76") (:authors ("AdrieanKhisbe" . "adriean.khisbe@live.fr")) (:maintainers ("AdrieanKhisbe" . "adriean.khisbe@live.fr")) (:maintainer "AdrieanKhisbe" . "adriean.khisbe@live.fr") (:keywords "languages" "tools") (:url . "http://github.com/shpec/shpec-mode"))]) (shr-tag-pre-highlight . [(20240515 1420) ((emacs (25 1)) (language-detection (0 1 0))) "Syntax highlighting code block in HTML" tar ((:commit . "af8ae8d558d1e26d276130c100e02746278ce037") (:authors ("Chunyang Xu" . "mail@xuchunyang.me")) (:maintainers ("Chunyang Xu" . "mail@xuchunyang.me")) (:maintainer "Chunyang Xu" . "mail@xuchunyang.me") (:keywords "html") (:url . "https://github.com/xuchunyang/shr-tag-pre-highlight.el"))]) - (shrface . [(20240401 957) ((emacs (25 1)) (org (9 0)) (language-detection (0 1 0))) "Extend shr/eww with org features and analysis capability" tar ((:commit . "b82a174ee33f19ed96c7e8c85ec362eab147d4aa") (:authors ("Damon Chan" . "elecming@gmail.com")) (:maintainers ("Damon Chan" . "elecming@gmail.com")) (:maintainer "Damon Chan" . "elecming@gmail.com") (:keywords "faces") (:url . "https://github.com/chenyanming/shrface"))]) + (shrface . [(20240530 1456) ((emacs (25 1)) (org (9 0)) (language-detection (0 1 0))) "Extend shr/eww with org features and analysis capability" tar ((:commit . "197507c169d322921f3e6fa99b73a3721101ffc7") (:authors ("Damon Chan" . "elecming@gmail.com")) (:maintainers ("Damon Chan" . "elecming@gmail.com")) (:maintainer "Damon Chan" . "elecming@gmail.com") (:keywords "faces") (:url . "https://github.com/chenyanming/shrface"))]) (shrink-path . [(20190208 1335) ((emacs (24)) (s (1 6 1)) (dash (1 8 0)) (f (0 10 0))) "fish-style path" tar ((:commit . "c14882c8599aec79a6e8ef2d06454254bb3e1e41") (:authors ("Benjamin Andresen")) (:maintainers ("Benjamin Andresen")) (:maintainer "Benjamin Andresen") (:url . "https://gitlab.com/bennya/shrink-path.el"))]) (shrink-whitespace . [(20181003 321) nil "Whitespace removal DWIM key" tar ((:commit . "0407b89c142bd17e65edb666f35e2c6755bd0867") (:authors ("Jean-Christophe Petkovich" . "jcpetkovich@gmail.com")) (:maintainers ("Jean-Christophe Petkovich" . "jcpetkovich@gmail.com")) (:maintainer "Jean-Christophe Petkovich" . "jcpetkovich@gmail.com") (:keywords "convenience") (:url . "https://gitlab.com/jcpetkovich/shrink-whitespace.el"))]) (shroud . [(20210220 1952) ((emacs (25)) (epg (1 0 0)) (s (1 6 0)) (bui (1 2 0)) (dash (2 18 0))) "Shroud secrets" tar ((:commit . "2e6ff2bab4a1e798c090c9d7fbd90b7f3463d5c5") (:authors ("Amar Singh" . "nly@disroot.org")) (:maintainers ("Amar Singh" . "nly@disroot.org")) (:maintainer "Amar Singh" . "nly@disroot.org") (:keywords "tools" "password") (:url . "https://github.com/o-nly/emacs-shroud"))]) @@ -4792,9 +4799,9 @@ (side-hustle . [(20240325 205) ((emacs (24 4)) (seq (2 20))) "Hustle through Imenu in a side window" tar ((:commit . "903380cf9e08d98689c2c116965f8e47d002fad6") (:authors ("Paul W. Rankin" . "hello@paulwrankin.com")) (:maintainers ("Paul W. Rankin" . "hello@paulwrankin.com")) (:maintainer "Paul W. Rankin" . "hello@paulwrankin.com") (:keywords "convenience") (:url . "https://github.com/rnkn/side-hustle"))]) (side-notes . [(20230814 302) ((emacs (24 4))) "Easy access to a directory notes file" tar ((:commit . "fbe409066df83a7e64a6a9ddf6d99ce7177fcdbb") (:authors ("Paul W. Rankin" . "hello@paulwrankin.com")) (:maintainers ("Paul W. Rankin" . "hello@paulwrankin.com")) (:maintainer "Paul W. Rankin" . "hello@paulwrankin.com") (:keywords "convenience") (:url . "https://github.com/rnkn/side-notes"))]) (sidecar-locals . [(20240421 655) ((emacs (27 1))) "A flexible alternative to built-in dir-locals" tar ((:commit . "3daf8c07fac7c4ada7a02a1edad2f64894463614") (:authors ("Campbell Barton" . "ideasman42@gmail.com")) (:maintainers ("Campbell Barton" . "ideasman42@gmail.com")) (:maintainer "Campbell Barton" . "ideasman42@gmail.com") (:keywords "convenience") (:url . "https://codeberg.org/ideasman42/emacs-sidecar-locals"))]) - (sideline . [(20240521 31) ((emacs (27 1)) (ht (2 4))) "Show information on the side" tar ((:commit . "31ef3c21d99785e7a066ad8c188ddcd2b478b5fe") (:authors ("Shen, Jen-Chieh" . "jcs090218@gmail.com")) (:maintainers ("Shen, Jen-Chieh" . "jcs090218@gmail.com")) (:maintainer "Shen, Jen-Chieh" . "jcs090218@gmail.com") (:keywords "convenience") (:url . "https://github.com/emacs-sideline/sideline"))]) + (sideline . [(20240530 2308) ((emacs (27 1)) (ht (2 4))) "Show information on the side" tar ((:commit . "7a7b671273223ed290ccf58a26449a3bebb495fd") (:authors ("Shen, Jen-Chieh" . "jcs090218@gmail.com")) (:maintainers ("Shen, Jen-Chieh" . "jcs090218@gmail.com")) (:maintainer "Shen, Jen-Chieh" . "jcs090218@gmail.com") (:keywords "convenience") (:url . "https://github.com/emacs-sideline/sideline"))]) (sideline-blame . [(20240101 918) ((emacs (27 1)) (sideline (0 1 0)) (vc-msg (1 1 1))) "Show blame messages with sideline" tar ((:commit . "b597c047d2a8ef7dd155e85e43fd65530ecf0a61") (:authors ("Shen, Jen-Chieh" . "jcs090218@gmail.com")) (:maintainers ("Shen, Jen-Chieh" . "jcs090218@gmail.com")) (:maintainer "Shen, Jen-Chieh" . "jcs090218@gmail.com") (:keywords "convenience" "blame") (:url . "https://github.com/emacs-sideline/sideline-blame"))]) - (sideline-flycheck . [(20240509 742) ((emacs (27 1)) (sideline (0 1 1)) (flycheck (0 14)) (ht (2 4))) "Show flycheck errors with sideline" tar ((:commit . "f809e627e433bd9a58471e4dea1ed50305eef7f2") (:authors ("Shen, Jen-Chieh" . "jcs090218@gmail.com")) (:maintainers ("Shen, Jen-Chieh" . "jcs090218@gmail.com")) (:maintainer "Shen, Jen-Chieh" . "jcs090218@gmail.com") (:keywords "convenience" "flycheck") (:url . "https://github.com/emacs-sideline/sideline-flycheck"))]) + (sideline-flycheck . [(20240530 2209) ((emacs (27 1)) (sideline (0 1 1)) (flycheck (0 14)) (ht (2 4))) "Show flycheck errors with sideline" tar ((:commit . "11f34abcd34b55c021453e332e58282654b35a7c") (:authors ("Shen, Jen-Chieh" . "jcs090218@gmail.com")) (:maintainers ("Shen, Jen-Chieh" . "jcs090218@gmail.com")) (:maintainer "Shen, Jen-Chieh" . "jcs090218@gmail.com") (:keywords "convenience" "flycheck") (:url . "https://github.com/emacs-sideline/sideline-flycheck"))]) (sideline-flymake . [(20240509 742) ((emacs (27 1)) (sideline (0 1 0))) "Show flymake errors with sideline" tar ((:commit . "06e84875022a5645ece8f4c2c8b56aa5f003c65d") (:authors ("Shen, Jen-Chieh" . "jcs090218@gmail.com")) (:maintainers ("Shen, Jen-Chieh" . "jcs090218@gmail.com")) (:maintainer "Shen, Jen-Chieh" . "jcs090218@gmail.com") (:keywords "convenience" "flymake") (:url . "https://github.com/emacs-sideline/sideline-flymake"))]) (sideline-lsp . [(20240403 2210) ((emacs (27 1)) (sideline (0 1 0)) (lsp-mode (6 0)) (dash (2 18 0)) (ht (2 4)) (s (1 12 0))) "Show lsp information with sideline" tar ((:commit . "69aca6403509abb4f5c5ba8499e98f80f81ebc88") (:authors ("Shen, Jen-Chieh" . "jcs090218@gmail.com")) (:maintainers ("Shen, Jen-Chieh" . "jcs090218@gmail.com")) (:maintainer "Shen, Jen-Chieh" . "jcs090218@gmail.com") (:keywords "convenience" "lsp") (:url . "https://github.com/emacs-sideline/sideline-lsp"))]) (sift . [(20200421 1423) nil "Front-end for sift, a fast and powerful grep alternative" tar ((:commit . "cdddba2d183146c340915003f1b5d09d13712c22") (:authors ("Nicolas Lamirault" . "nicolas.lamirault@gmail.com")) (:maintainers ("Nicolas Lamirault" . "nicolas.lamirault@gmail.com")) (:maintainer "Nicolas Lamirault" . "nicolas.lamirault@gmail.com") (:keywords "sift" "ack" "pt" "ag" "grep" "search") (:url . "https://github.com/nlamirault/sift.el"))]) @@ -4816,6 +4823,7 @@ (simplenote2 . [(20190321 933) ((request-deferred (0 2 0)) (uuidgen (20140918)) (unicode-escape (1 1))) "Interact with app.simplenote.com" tar ((:commit . "760ffecda63bd218876b623f46d332e3ef079be6") (:authors ("alpha22jp" . "alpha22jp@gmail.com")) (:maintainers ("alpha22jp" . "alpha22jp@gmail.com")) (:maintainer "alpha22jp" . "alpha22jp@gmail.com") (:keywords "simplenote"))]) (simplezen . [(20130421 1000) ((s (1 4 0)) (dash (1 1 0))) "A simple subset of zencoding-mode for Emacs." tar ((:commit . "9f91554a3f7f4e9b2b5ec009effafbf12b091973") (:authors ("Magnar Sveen" . "magnars@gmail.com")) (:maintainers ("Magnar Sveen" . "magnars@gmail.com")) (:maintainer "Magnar Sveen" . "magnars@gmail.com"))]) (simplicity-theme . [(20221016 1444) ((emacs (24 1))) "A minimalist dark theme" tar ((:commit . "f4aab6aa07b536688eb62355b83dde5fcd16e049") (:authors ("Matthieu Petiteau" . "mpetiteau.pro@gmail.com")) (:maintainers ("Matthieu Petiteau" . "mpetiteau.pro@gmail.com")) (:maintainer "Matthieu Petiteau" . "mpetiteau.pro@gmail.com") (:keywords "faces" "theme" "minimal") (:url . "http://github.com/smallwat3r/emacs-simplicity-theme"))]) + (sink . [(20240523 747) ((emacs (25 1))) "Receive messages from the plan9 plumber" tar ((:commit . "a14e1cc0a051543723c043a5ece081ce9a567ddd") (:url . "https://github.com/alcah/sink.el"))]) (siri-shortcuts . [(20211229 1833) ((emacs (25 2))) "Interact with Siri Shortcuts" tar ((:commit . "190f242f71e071adfd89fa1f2f6ea22b62afd133") (:authors ("Daniils Petrovs" . "thedanpetrov@gmail.com")) (:maintainers ("Daniils Petrovs" . "thedanpetrov@gmail.com")) (:maintainer "Daniils Petrovs" . "thedanpetrov@gmail.com") (:keywords "convenience" "multimedia") (:url . "https://github.com/DaniruKun/siri-shortcuts.el"))]) (sis . [(20231211 1602) ((emacs (27 1))) "Less manual switch for native or OS input source (input method)." tar ((:commit . "23f3fe8b95e0570b65aa21b9db57c906aa9f35fd") (:keywords "convenience") (:url . "https://github.com/laishulu/emacs-smart-input-source"))]) (sisyphus . [(20240506 1558) ((emacs (27 1)) (compat (29 1 4 2)) (elx (1 6 0)) (llama (0 3 0)) (magit (3 4 0))) "Create releases of Emacs packages" tar ((:commit . "db9b36065faf149fef214248bdba1d90492cd2e9") (:authors ("Jonas Bernoulli" . "emacs.sisyphus@jonas.bernoulli.dev")) (:maintainers ("Jonas Bernoulli" . "emacs.sisyphus@jonas.bernoulli.dev")) (:maintainer "Jonas Bernoulli" . "emacs.sisyphus@jonas.bernoulli.dev") (:keywords "git" "tools" "vc") (:url . "https://github.com/magit/sisyphus"))]) @@ -4831,7 +4839,7 @@ (slack . [(20211129 310) ((websocket (1 8)) (request (0 2 0)) (oauth2 (0 10)) (circe (2 2)) (alert (1 2)) (emojify (0 2))) "Slack client for Emacs" tar ((:commit . "ff46d88726482211e3ac3d0b9c95dd4fdffe11c2") (:authors ("yuya.minami" . "yuya.minami@yuyaminami-no-MacBook-Pro.local")) (:maintainer "yuya.minami" . "yuya.minami@yuyaminami-no-MacBook-Pro.local") (:keywords "tools") (:url . "https://github.com/yuya373/emacs-slack"))]) (slideview . [(20150324 2240) ((cl-lib (0 3))) "File slideshow" tar ((:commit . "b6d170bda139aedf81b47dc55cbd1a3af512fb4c") (:authors ("Masahiro Hayashi" . "mhayashi1120@gmail.com")) (:maintainers ("Masahiro Hayashi" . "mhayashi1120@gmail.com")) (:maintainer "Masahiro Hayashi" . "mhayashi1120@gmail.com") (:keywords "files") (:url . "https://github.com/mhayashi1120/Emacs-slideview"))]) (slim-mode . [(20240513 2118) nil "Major mode for editing Slim files" tar ((:commit . "8c92169817f2fa59255f547f0a9fb4fbb8309db9") (:authors ("Nathan Weizenbaum")) (:maintainers ("Nathan Weizenbaum")) (:maintainer "Nathan Weizenbaum") (:keywords "markup" "language") (:url . "http://github.com/slim-template/emacs-slim"))]) - (slime . [(20240516 319) ((emacs (24 3)) (macrostep (0 9))) "Superior Lisp Interaction Mode for Emacs" tar ((:commit . "5ced74ab35d91f6be7d8fa10e1098aaae6b749e3") (:keywords "languages" "lisp" "slime") (:url . "https://github.com/slime/slime"))]) + (slime . [(20240527 1527) ((emacs (24 3)) (macrostep (0 9))) "Superior Lisp Interaction Mode for Emacs" tar ((:commit . "e261cc83b2a4675824c196965d060b135f6777ad") (:keywords "languages" "lisp" "slime") (:url . "https://github.com/slime/slime"))]) (slime-company . [(20210124 1627) ((emacs (24 4)) (slime (2 13)) (company (0 9 0))) "slime completion backend for company mode" tar ((:commit . "f20ecc4104d4c35052696e7e760109fb02060e72") (:authors ("Ole Arndt" . "anwyn@sugarshark.com")) (:maintainers ("Ole Arndt" . "anwyn@sugarshark.com")) (:maintainer "Ole Arndt" . "anwyn@sugarshark.com") (:keywords "convenience" "lisp" "abbrev"))]) (slime-docker . [(20210426 1422) ((emacs (24 4)) (slime (2 16)) (docker-tramp (0 1))) "Integration of SLIME with Docker containers" tar ((:commit . "c7d073720f2bd8e9f72a20309fff2afa4c4e798d") (:keywords "docker" "lisp" "slime") (:url . "https://gitlab.common-lisp.net/cl-docker-images/slime-docker"))]) (slime-repl-ansi-color . [(20230214 1453) ((emacs (24)) (slime (2 3 1))) "Turn on ANSI colors in REPL output;" tar ((:commit . "9e8af90490332217e45d7568f1690df3f4e25d4b") (:authors ("Max Mikhanosha" . "max@openchat.com")) (:maintainers ("Augustin Fabre" . "augustin@augfab.fr")) (:maintainer "Augustin Fabre" . "augustin@augfab.fr") (:keywords "lisp") (:url . "https://gitlab.com/augfab/slime-repl-ansi-color"))]) @@ -4945,7 +4953,7 @@ (sparkline . [(20150101 1319) ((cl-lib (0 3))) "Make sparkline images from a list of numbers" tar ((:commit . "a2b5d817d272d6363b67ed8f8cc75499a19fa8d2") (:authors ("Willem Rein Oudshoorn" . "woudshoo@xs4all.nl")) (:maintainers ("Willem Rein Oudshoorn" . "woudshoo@xs4all.nl")) (:maintainer "Willem Rein Oudshoorn" . "woudshoo@xs4all.nl") (:keywords "extensions"))]) (sparql-mode . [(20230104 1113) ((cl-lib (0 5)) (emacs (24 3))) "Edit and interactively evaluate SPARQL queries." tar ((:commit . "1f6196094ec6626722c6e03a13f6844c68f62703") (:authors ("Craig Andera <candera at wangdera dot com>")) (:maintainers ("Bjarte Johansen <Bjarte dot Johansen at gmail dot com>")) (:maintainer "Bjarte Johansen <Bjarte dot Johansen at gmail dot com>") (:url . "https://github.com/ljos/sparql-mode"))]) (spatial-navigate . [(20240421 908) ((emacs (29 1))) "Directional navigation between white-space blocks" tar ((:commit . "4f85fe3ae4d240a35d3d7edd8b865612024f9dda") (:authors ("Campbell Barton" . "ideasman42@gmail.com")) (:maintainers ("Campbell Barton" . "ideasman42@gmail.com")) (:maintainer "Campbell Barton" . "ideasman42@gmail.com") (:url . "https://codeberg.org/ideasman42/emacs-spatial-navigate"))]) - (spdx . [(20240521 104) ((emacs (24 4))) "Insert SPDX license and copyright headers" tar ((:commit . "a26f071d335e7987fd0377057d46056954120b34") (:authors ("Zhiwei Chen" . "condy0919@gmail.com")) (:maintainers ("Zhiwei Chen" . "condy0919@gmail.com")) (:maintainer "Zhiwei Chen" . "condy0919@gmail.com") (:keywords "license" "tools") (:url . "https://github.com/condy0919/spdx.el"))]) + (spdx . [(20240523 104) ((emacs (24 4))) "Insert SPDX license and copyright headers" tar ((:commit . "b8ff69f4cbd345411f95c294920bd3dcfd6e63f8") (:authors ("Zhiwei Chen" . "condy0919@gmail.com")) (:maintainers ("Zhiwei Chen" . "condy0919@gmail.com")) (:maintainer "Zhiwei Chen" . "condy0919@gmail.com") (:keywords "license" "tools") (:url . "https://github.com/condy0919/spdx.el"))]) (speech-tagger . [(20170728 1829) ((cl-lib (0 5))) "tag parts of speech using coreNLP" tar ((:commit . "61955b40d4e8b09e66a3e8033e82893f81657c06") (:authors ("Danny McClanahan" . "danieldmcclanahan@gmail.com")) (:maintainers ("Danny McClanahan" . "danieldmcclanahan@gmail.com")) (:maintainer "Danny McClanahan" . "danieldmcclanahan@gmail.com") (:keywords "speech" "tag" "nlp" "language" "corenlp" "parsing" "natural") (:url . "https://github.com/cosmicexplorer/speech-tagger"))]) (speechd-el . [(20240513 1716) nil "Client to speech synthesizers and Braille displays." tar ((:commit . "ac7497e394bf7d46e0b2c27570f5507f6a50a157") (:authors ("Milan Zamazal" . "pdm@zamazal.org")) (:maintainer "Milan Zamazal" . "pdm@zamazal.org") (:url . "https://github.com/brailcom/speechd-el"))]) (speed-type . [(20230926 838) ((emacs (26 1)) (compat (29 1 3))) "Practice touch and speed typing" tar ((:commit . "28b8e8c1cc24511758168f30bcac18d8fb93706d") (:authors ("Gunther Hagleitner")) (:maintainers ("Daniel Kraus" . "daniel@kraus.my")) (:maintainer "Daniel Kraus" . "daniel@kraus.my") (:keywords "games") (:url . "https://github.com/dakra/speed-type"))]) @@ -4993,7 +5001,7 @@ (stan-snippets . [(20211129 2051) ((emacs (24 3)) (stan-mode (10 3 0)) (yasnippet (0 8 0))) "Yasnippets for Stan" tar ((:commit . "150bbbe5fd3ad2b5a3dbfba9d291e66eeea1a581") (:authors ("Jeffrey Arnold" . "jeffrey.arnold@gmail.com") ("Kazuki Yoshida" . "kazukiyoshida@mail.harvard.edu")) (:maintainers ("Kazuki Yoshida" . "kazukiyoshida@mail.harvard.edu")) (:maintainer "Kazuki Yoshida" . "kazukiyoshida@mail.harvard.edu") (:keywords "languages" "tools") (:url . "https://github.com/stan-dev/stan-mode/tree/master/stan-snippets"))]) (standard-dirs . [(20200621 1603) ((emacs (26 1)) (f (0 20 0)) (s (1 7 0))) "Platform-specific paths for config, cache, and other data" tar ((:commit . "e37b7e1c714c7798cd8e3a6569e4d71b96718a60") (:authors ("Joseph M LaFreniere" . "joseph@lafreniere.xyz")) (:maintainers ("Joseph M LaFreniere" . "joseph@lafreniere.xyz")) (:maintainer "Joseph M LaFreniere" . "joseph@lafreniere.xyz") (:keywords "files") (:url . "https://github.com/lafrenierejm/standard-dirs.el"))]) (standoff-mode . [(20210810 1814) nil "Create stand-off markup, also called external markup." tar ((:commit . "5e603092410d9c393d19050bcbed3014a379f0e6") (:authors ("Christian Lück" . "christian.lueck@ruhr-uni-bochum.de")) (:maintainer "Christian Lück" . "christian.lueck@ruhr-uni-bochum.de") (:keywords "text" "annotations" "ner" "humanities") (:url . "https://github.com/lueck/standoff-mode"))]) - (starhugger . [(20231202 235) ((emacs (28 2)) (compat (29 1 4 0)) (dash (2 18 0)) (s (1 13 1)) (spinner (1 7 4))) "Hugging Face/AI-powered text & code completion client" tar ((:commit . "1bb3464c3a198a4f5f2155817d6505c4bab7dc79") (:keywords "completion" "convenience" "languages") (:url . "https://gitlab.com/daanturo/starhugger.el"))]) + (starhugger . [(20240523 326) ((emacs (28 2)) (compat (29 1 4 0)) (dash (2 18 0)) (s (1 13 1)) (spinner (1 7 4))) "Hugging Face/AI-powered text & code completion client" tar ((:commit . "17c3847566447e2a860d5837d35380160276bed6") (:keywords "completion" "convenience" "languages") (:url . "https://gitlab.com/daanturo/starhugger.el"))]) (starlit-theme . [(20240223 1728) ((emacs (25 1))) "Deep blue dark theme with bright colors from the starlit sky" tar ((:commit . "136bbc4fc4961c5b2cd0824eb0762e672322fbd1") (:authors ("Jonas Jelten" . "jj@sft.lol")) (:maintainers ("Jonas Jelten" . "jj@sft.lol")) (:maintainer "Jonas Jelten" . "jj@sft.lol") (:keywords "faces") (:url . "https://github.com/SFTtech/starlit-emacs"))]) (start-menu . [(20160426 1225) ((cl-lib (0 5)) (config-parser (0 1))) "start-menu for executing external program like in windows" tar ((:commit . "f7d33fed7ad2dc61156f1c1cff9e1805366fbd69") (:authors ("DarkSun" . "lujun9972@gmail.com")) (:maintainers ("DarkSun" . "lujun9972@gmail.com")) (:maintainer "DarkSun" . "lujun9972@gmail.com") (:keywords "convenience" "menu") (:url . "https://github.com/lujun9972/el-start-menu"))]) (stash . [(20151117 1427) nil "lightweight persistent caching" tar ((:commit . "c2e494d20c752b80ebbdffbf66687b3cdfc425ad") (:authors ("Sean Allred" . "code@seanallred.com")) (:maintainers ("Sean Allred" . "code@seanallred.com")) (:maintainer "Sean Allred" . "code@seanallred.com") (:keywords "extensions" "data" "internal" "lisp") (:url . "https://www.github.com/vermiculus/stash.el/"))]) @@ -5130,7 +5138,7 @@ (tea-time . [(20120331 820) nil "Simple timer package, useful to make perfect tea." tar ((:commit . "1f6cf0bdd27c5eb3508989c5095427781f858eca") (:authors ("konsty" . "antipin.konstantin@googlemail.com")) (:maintainers ("Gabriel Saldana" . "gsaldana@gmail.com")) (:maintainer "Gabriel Saldana" . "gsaldana@gmail.com") (:keywords "timer" "tea-time"))]) (teacode-expand . [(20181231 640) ((emacs (24 4))) "Expansion of text by TeaCode program." tar ((:commit . "7df6f9ec95da1fb47bbae489bb3f2c27ed3a9b3a") (:authors ("Richard Guay" . "raguay@customct.com")) (:maintainers ("Richard Guay" . "raguay@customct.com")) (:maintainer "Richard Guay" . "raguay@customct.com") (:keywords "lisp") (:url . "https://github.com/raguay/TeaCode-Expand"))]) (teco . [(20200707 2309) nil "Teco interpreter" tar ((:commit . "2529eb0f7f35c526c1b6fca5250399718ff5138a") (:authors ("Dale R. Worley" . "worley@alum.mit.edu")) (:maintainers ("Mark T. Kennedy" . "mtk@acm.org")) (:maintainer "Mark T. Kennedy" . "mtk@acm.org") (:keywords "convenience" "emulations" "files") (:url . "https://github.com/mtk/teco.git"))]) - (telega . [(20240515 2217) ((emacs (27 1)) (visual-fill-column (1 9)) (rainbow-identifiers (0 2 2)) (transient (0 3 0))) "Telegram client (unofficial)" tar ((:commit . "3d2e5ee323366906b00d8ed40e818d41e82b73e5") (:authors ("Zajcev Evgeny" . "zevlg@yandex.ru")) (:maintainers ("Zajcev Evgeny" . "zevlg@yandex.ru")) (:maintainer "Zajcev Evgeny" . "zevlg@yandex.ru") (:keywords "comm") (:url . "https://github.com/zevlg/telega.el"))]) + (telega . [(20240527 606) ((emacs (27 1)) (visual-fill-column (1 9)) (rainbow-identifiers (0 2 2)) (transient (0 3 0))) "Telegram client (unofficial)" tar ((:commit . "58b4963b292ceb723d665df100b519eb5a99c676") (:authors ("Zajcev Evgeny" . "zevlg@yandex.ru")) (:maintainers ("Zajcev Evgeny" . "zevlg@yandex.ru")) (:maintainer "Zajcev Evgeny" . "zevlg@yandex.ru") (:keywords "comm") (:url . "https://github.com/zevlg/telega.el"))]) (telepathy . [(20131209 1258) nil "Access Telepathy from Emacs" tar ((:commit . "211d785b02a29ddc254422fdcc3db45262582f8c") (:authors ("Nicolas Petton" . "petton.nicolas@gmail.com")) (:maintainers ("Nicolas Petton" . "petton.nicolas@gmail.com")) (:maintainer "Nicolas Petton" . "petton.nicolas@gmail.com") (:keywords "telepathy" "tools"))]) (telephone-line . [(20240109 2021) ((emacs (24 4)) (cl-lib (0 5)) (cl-generic (0 2)) (seq (1 8))) "Rewrite of Powerline" tar ((:commit . "6016418a5e1e8e006cc202eff50ff28b594eeca4") (:authors ("Daniel Bordak" . "dbordak@fastmail.fm")) (:maintainers ("Daniel Bordak" . "dbordak@fastmail.fm")) (:maintainer "Daniel Bordak" . "dbordak@fastmail.fm") (:keywords "mode-line") (:url . "https://github.com/dbordak/telephone-line"))]) (teleport . [(20240501 740) ((emacs (28 1)) (dash (2 18 0))) "Integration for tsh (goteleport.com)" tar ((:commit . "7a99ec17e5c1d3bab3bc842e045b06ea335c97b9") (:authors ("Caramel Hooves" . "caramel.hooves@protonmail.com")) (:maintainers ("Caramel Hooves" . "caramel.hooves@protonmail.com")) (:maintainer "Caramel Hooves" . "caramel.hooves@protonmail.com") (:keywords "tools") (:url . "https://github.com/caramelhooves/teleport.el"))]) @@ -5164,7 +5172,7 @@ (tesouro . [(20221003 1303) ((request (0 3 2)) (emacs (24 4))) "Brazilian Portuguese synonym search in dicio.com.br" tar ((:commit . "3dbfc49209237215163be1ea338dea099ddc0795") (:url . "https://github.com/rberaldo/tesouro.el"))]) (test-c . [(20180423 1720) ((emacs (24 3))) "quickly test c code" tar ((:commit . "761a576f62c7021ba941f178f153c51289df1553") (:authors ("Aurélien Aptel" . "aurelien.aptel@gmail.com")) (:maintainers ("Aurélien Aptel" . "aurelien.aptel@gmail.com")) (:maintainer "Aurélien Aptel" . "aurelien.aptel@gmail.com") (:url . "http://github.com/aaptel/test-c"))]) (test-case-mode . [(20130525 1434) ((fringe-helper (0 1 1))) "unit test front-end" tar ((:commit . "26e397c0f930b7eb0be413ef7dd257b1da052bec") (:authors ("Nikolaj Schumacher <bugs * nschum de>")) (:maintainers ("Nikolaj Schumacher <bugs * nschum de>")) (:maintainer "Nikolaj Schumacher <bugs * nschum de>") (:keywords "tools") (:url . "http://nschum.de/src/emacs/test-case-mode/"))]) - (test-cockpit . [(20240519 1747) ((emacs (28 1)) (projectile (2 7)) (toml (20230411 1449))) "A command center to run tests of a software project" tar ((:commit . "2b836e5f954059210b6efaecebfe5fd7c72e726c") (:authors ("Johannes Mueller" . "github@johannes-mueller.org")) (:maintainers ("Johannes Mueller" . "github@johannes-mueller.org")) (:maintainer "Johannes Mueller" . "github@johannes-mueller.org") (:url . "https://github.com/johannes-mueller/test-cockpit.el"))]) + (test-cockpit . [(20240601 1545) ((emacs (28 1)) (projectile (2 7)) (toml (20230411 1449))) "A command center to run tests of a software project" tar ((:commit . "ad7d4f02d9fe438449befeecf193a547760c0797") (:authors ("Johannes Mueller" . "github@johannes-mueller.org")) (:maintainers ("Johannes Mueller" . "github@johannes-mueller.org")) (:maintainer "Johannes Mueller" . "github@johannes-mueller.org") (:url . "https://github.com/johannes-mueller/test-cockpit.el"))]) (test-kitchen . [(20171129 2035) nil "Run test-kitchen inside of emacs" tar ((:commit . "0fc0ca4808425f03fbeb8125246043723e2a179a") (:authors ("JJ Asghar")) (:maintainers ("JJ Asghar")) (:maintainer "JJ Asghar") (:keywords "chef" "ruby" "test-kitchen") (:url . "http://github.com/jjasghar/test-kitchen-el"))]) (test-simple . [(20230916 1634) ((cl-lib (0))) "Simple Unit Test Framework for Emacs Lisp" tar ((:commit . "8b191842318bb05da74052025192d32ebebb033a") (:authors ("Rocky Bernstein" . "rocky@gnu.org")) (:maintainers ("Rocky Bernstein" . "rocky@gnu.org")) (:maintainer "Rocky Bernstein" . "rocky@gnu.org") (:keywords "unit-test") (:url . "https://github.com/rocky/emacs-test-simple"))]) (tex-smart-umlauts . [(20230416 2051) nil "Smart umlaut conversion for TeX." tar ((:commit . "b28bac71990e0442616157fdb64494179df5575e") (:authors ("Frank Fischer <frank-fischer at shadow-soft.de>")) (:maintainers ("Frank Fischer <frank-fischer at shadow-soft.de>")) (:maintainer "Frank Fischer <frank-fischer at shadow-soft.de>") (:keywords "tex" "wp") (:url . "http://hub.darcs.net/lyro/tex-smart-umlauts"))]) @@ -5188,7 +5196,7 @@ (third-time . [(20240207 1621) ((emacs (27 1))) "Third Time: A Better Way to Work" tar ((:commit . "093b74be860fac389fb173caef5fabf61e417eef") (:authors ("Samuel W. Flint" . "swflint@flintfam.org")) (:maintainers ("Samuel W. Flint" . "swflint@flintfam.org")) (:maintainer "Samuel W. Flint" . "swflint@flintfam.org") (:url . "https://git.sr.ht/~swflint/third-time"))]) (thread-dump . [(20170816 1850) nil "Java thread dump viewer" tar ((:commit . "204c9600242756d4b514bb5ff6293e052bf4b49d") (:authors ("Dmitry Neverov")) (:maintainers ("Dmitry Neverov")) (:maintainer "Dmitry Neverov") (:url . "http://github.com/nd/thread-dump.el"))]) (threes . [(20160820 1242) ((emacs (24)) (seq (1 11))) "A clone of Threes (a tiny puzzle game)" tar ((:commit . "6981acb30b856c77cba6aba63fefbf102cbdfbb2") (:authors ("Chunyang Xu" . "xuchunyang.me@gmail.com")) (:maintainers ("Chunyang Xu" . "xuchunyang.me@gmail.com")) (:maintainer "Chunyang Xu" . "xuchunyang.me@gmail.com") (:keywords "games") (:url . "https://github.com/xuchunyang/threes.el"))]) - (thrift . [(20240519 1631) ((emacs (24))) "major mode for fbthrift and Apache Thrift files" tar ((:commit . "8baf3aed99934494267647ee8f309f9d712d4325") (:keywords "languages"))]) + (thrift . [(20240526 1633) ((emacs (24))) "major mode for fbthrift and Apache Thrift files" tar ((:commit . "f408d11adf2b518358a7fa2cc86c3267354b33d0") (:keywords "languages"))]) (thumb-through . [(20120119 534) nil "Plain text reader of HTML documents" tar ((:commit . "08d8fb720f93c6172653e035191a8fa9c3305e63") (:keywords "html"))]) (tickscript-mode . [(20171219 203) ((emacs (24 1))) "A major mode for Tickscript files" tar ((:commit . "f0579f38ff14954df5002ce30ae6d4a2c978d461") (:authors ("Marc Sherry" . "msherry@gmail.com")) (:maintainers ("Marc Sherry" . "msherry@gmail.com")) (:maintainer "Marc Sherry" . "msherry@gmail.com") (:keywords "languages") (:url . "https://github.com/msherry/tickscript-mode"))]) (tidal . [(20240407 1952) ((haskell-mode (16)) (emacs (25 1))) "Interact with TidalCycles for live coding patterns" tar ((:commit . "88f09edf6bef2228d5f530dea872b08a9d803066") (:authors (nil . "alex@slab.org")) (:maintainers (nil . "alex@slab.org")) (:maintainer nil . "alex@slab.org") (:keywords "tools") (:url . "https://github.com/tidalcycles/Tidal"))]) @@ -5228,6 +5236,7 @@ (todotxt-mode . [(20200228 952) nil "Major mode for editing todo.txt files" tar ((:commit . "8b616ce1cf3e18a60757450a0acf22996abb9b79") (:authors ("Adolfo Villafiorita" . "adolfo.villafiorita@me.com")) (:maintainers ("Adolfo Villafiorita" . "adolfo.villafiorita@me.com")) (:maintainer "Adolfo Villafiorita" . "adolfo.villafiorita@me.com") (:keywords "wp" "files"))]) (togetherly . [(20170426 616) ((cl-lib (0 3))) "allow multiple clients to edit a single buffer online" tar ((:commit . "65072b1d5e04c7098c318ebf1af279f596039ef9") (:authors ("zk_phi")) (:maintainers ("zk_phi")) (:maintainer "zk_phi") (:url . "http://hins11.yu-yake.com/"))]) (toggle-quotes . [(20140710 926) nil "Toggle between single and double quoted string" tar ((:commit . "33abc221d6887f0518337851318065cd86c34b03") (:authors ("Jim Tian" . "tianjin.sc@gmail.com")) (:maintainers ("Jim Tian" . "tianjin.sc@gmail.com")) (:maintainer "Jim Tian" . "tianjin.sc@gmail.com") (:keywords "convenience" "quotes") (:url . "https://github.com/toctan/toggle-quotes.el"))]) + (toggle-term . [(20240527 323) ((emacs (24 3))) "Quickly toggle persistent term and shell buffers" tar ((:commit . "73e3dae13a28fec2c0dd52642ca7cfdf1397c730") (:authors ("justinlime")) (:maintainers ("justinlime")) (:maintainer "justinlime") (:keywords "frames" "convenience" "terminals") (:url . "https://github.com/justinlime/toggle-term.el"))]) (toggle-test . [(20140723 537) nil "Toggle between source and test files in various programming languages" tar ((:commit . "a0b64834101c2b8b24da365baea1d36e57b069b5") (:authors ("Raghunandan Rao" . "r.raghunandan@gmail.com")) (:maintainers ("Raghunandan Rao" . "r.raghunandan@gmail.com")) (:maintainer "Raghunandan Rao" . "r.raghunandan@gmail.com") (:keywords "tdd" "test" "toggle" "productivity") (:url . "https://github.com/rags/toggle-test"))]) (toggle-window . [(20141207 1548) nil "toggle current window size between half and full" tar ((:commit . "e82c60e543933880402ede11e9423e48a17dde53") (:authors ("Kenny Liu")) (:maintainers ("Kenny Liu")) (:maintainer "Kenny Liu") (:keywords "hide" "window") (:url . "https://github.com/deadghost/toggle-window"))]) (tok-theme . [(20231019 947) ((emacs (27 0))) "Minimal monochromatic theme for Emacs in the spirit of Zmacs and Smalltalk-80." tar ((:commit . "61c86fd2902b6342efe4463230dffdd185159d1c") (:authors ("Topi Kettunen" . "topi@topikettunen.com")) (:maintainers ("Topi Kettunen" . "topi@topikettunen.com")) (:maintainer "Topi Kettunen" . "topi@topikettunen.com") (:url . "https://github.com/topikettunen/tok-theme"))]) @@ -5257,7 +5266,7 @@ (tramp-term . [(20220725 1441) nil "Automatic setup of directory tracking in ssh sessions" tar ((:commit . "ed75189122737d301f716a30a8013205aa3736f1") (:authors ("Randy Morris" . "randy.morris@archlinux.us")) (:maintainers ("Randy Morris" . "randy.morris@archlinux.us")) (:maintainer "Randy Morris" . "randy.morris@archlinux.us") (:keywords "comm" "terminals") (:url . "https://github.com/randymorris/tramp-term.el"))]) (transducers . [(20240308 843) ((emacs (28 1))) "Ergonomic, efficient data processing" tar ((:commit . "2d452e4cdc3b5cfa29ee3d7a645ff53d4e993384") (:authors ("Colin Woodbury" . "colin@fosskers.ca")) (:maintainers ("Colin Woodbury" . "colin@fosskers.ca")) (:maintainer "Colin Woodbury" . "colin@fosskers.ca") (:keywords "lisp") (:url . "https://git.sr.ht/~fosskers/transducers.el"))]) (transfer-sh . [(20200601 1708) ((emacs (24 3)) (async (1 0))) "Simple interface for sending buffer contents to transfer.sh" tar ((:commit . "0621a66d00ec91a209a542c10b158095088bd44d") (:keywords "comm" "convenience" "files") (:url . "https://gitlab.com/tuedachu/transfer-sh.el"))]) - (transient . [(20240509 1849) ((emacs (26 1)) (compat (29 1 4 4)) (seq (2 24))) "Transient commands" tar ((:commit . "3d395d643b1476b07c6c3d7217f5b2ad2c0b425e") (:authors ("Jonas Bernoulli" . "emacs.transient@jonas.bernoulli.dev")) (:maintainers ("Jonas Bernoulli" . "emacs.transient@jonas.bernoulli.dev")) (:maintainer "Jonas Bernoulli" . "emacs.transient@jonas.bernoulli.dev") (:keywords "extensions") (:url . "https://github.com/magit/transient"))]) + (transient . [(20240525 1118) ((emacs (26 1)) (compat (29 1 4 4)) (seq (2 24))) "Transient commands" tar ((:commit . "99a68578df4d938598d0fcbb8401e2fe35be6132") (:authors ("Jonas Bernoulli" . "emacs.transient@jonas.bernoulli.dev")) (:maintainers ("Jonas Bernoulli" . "emacs.transient@jonas.bernoulli.dev")) (:maintainer "Jonas Bernoulli" . "emacs.transient@jonas.bernoulli.dev") (:keywords "extensions") (:url . "https://github.com/magit/transient"))]) (transient-dwim . [(20221225 1630) ((emacs (26 1)) (transient (0 1))) "Useful preset transient commands" tar ((:commit . "cb5e0d35729fc6448553b7a17fc5c843f00e8c1d") (:authors ("Naoya Yamashita" . "conao3@gmail.com")) (:maintainers ("Naoya Yamashita" . "conao3@gmail.com")) (:maintainer "Naoya Yamashita" . "conao3@gmail.com") (:keywords "tools") (:url . "https://github.com/conao3/transient-dwim.el"))]) (transient-extras . [(20230721 839) ((emacs (28 1))) "Extra features for transient" tar ((:commit . "ca0d5c597382615f0ee8300ff8718f54f8214359") (:authors ("Al Haji-Ali <abdo.haji.ali@gmail.com>, Samuel W. Flint" . "swflint@flintfam.org")) (:maintainers ("Al Haji-Ali <abdo.haji.ali@gmail.com>, Samuel W. Flint" . "swflint@flintfam.org")) (:maintainer "Al Haji-Ali <abdo.haji.ali@gmail.com>, Samuel W. Flint" . "swflint@flintfam.org") (:keywords "convenience") (:url . "https://github.com/haji-ali/transient-extras.git"))]) (transient-extras-a2ps . [(20230303 1511) ((emacs (28 1)) (transient-extras (1 0 0))) "A transient interface to a2ps" tar ((:commit . "e91a1cddb1f0cb8b99d2bd30db64d467e5fa7ea8") (:authors ("Samuel W. Flint" . "swflint@flintfam.org")) (:maintainers ("Samuel W. Flint" . "swflint@flintfam.org")) (:maintainer "Samuel W. Flint" . "swflint@flintfam.org") (:keywords "convenience") (:url . "https://git.sr.ht/~swflint/transient-extras-a2ps"))]) @@ -5276,9 +5285,9 @@ (tree-sitter . [(20220212 1632) ((emacs (25 1)) (tsc (0 18 0))) "Incremental parsing system" tar ((:commit . "909717c685ff5a2327fa2ca8fb8a25216129361c") (:authors ("Tuấn-Anh Nguyễn" . "ubolonton@gmail.com")) (:maintainers ("Tuấn-Anh Nguyễn" . "ubolonton@gmail.com")) (:maintainer "Tuấn-Anh Nguyễn" . "ubolonton@gmail.com") (:keywords "languages" "tools" "parsers" "tree-sitter") (:url . "https://github.com/emacs-tree-sitter/elisp-tree-sitter"))]) (tree-sitter-ess-r . [(20221012 855) ((emacs (26 1)) (ess (18 10 1)) (tree-sitter (0 12 1)) (tree-sitter-langs (0 12 0))) "R with tree-sitter" tar ((:commit . "9669c00f3d3463e6769725af74c392891e269eed") (:authors ("Shuguang Sun" . "shuguang79@qq.com")) (:maintainers ("Shuguang Sun" . "shuguang79@qq.com")) (:maintainer "Shuguang Sun" . "shuguang79@qq.com") (:keywords "tools") (:url . "https://github.com/ShuguangSun/tree-sitter-ess-r"))]) (tree-sitter-indent . [(20220411 1439) ((emacs (26 1)) (tree-sitter (0 12 1)) (seq (2 20))) "Provide indentation with a Tree-sitter backend" tar ((:commit . "4ef246db3e4ff99f672fe5e4b416c890f885c09e") (:authors ("Felipe Lema" . "felipelema@mortemale.org")) (:maintainers ("Felipe Lema" . "felipelema@mortemale.org")) (:maintainer "Felipe Lema" . "felipelema@mortemale.org") (:keywords "convenience" "internal") (:url . "https://codeberg.org/FelipeLema/tree-sitter-indent.el"))]) - (tree-sitter-ispell . [(20240514 201) ((emacs (26 1)) (tree-sitter (0 15 0))) "Run ispell on tree-sitter text nodes" tar ((:commit . "16ba2d190cd387a0e5349c5b97a373bfad582eee") (:authors ("Erick Navarro" . "erick@navarro.io")) (:maintainers ("Erick Navarro" . "erick@navarro.io")) (:maintainer "Erick Navarro" . "erick@navarro.io") (:url . "https://github.com/erickgnavar/tree-sitter-ispell.el"))]) - (tree-sitter-langs . [(20240519 717) ((emacs (25 1)) (tree-sitter (0 15 0))) "Grammar bundle for tree-sitter" tar ((:commit . "6ce3de71c21a55ffe33ecdead57fff290a5d07df") (:authors ("Tuấn-Anh Nguyễn" . "ubolonton@gmail.com")) (:maintainers ("Tuấn-Anh Nguyễn" . "ubolonton@gmail.com")) (:maintainer "Tuấn-Anh Nguyễn" . "ubolonton@gmail.com") (:keywords "languages" "tools" "parsers" "tree-sitter") (:url . "https://github.com/emacs-tree-sitter/tree-sitter-langs"))]) - (treebundel . [(20240210 343) ((emacs (27 1)) (compat (29 1 4 2))) "Bundle related git-worktrees together" tar ((:commit . "2d6c69cb7798a8cb7fcf9923c4580220dd48b3d4") (:authors ("Ben Whitley")) (:maintainers ("Ben Whitley")) (:maintainer "Ben Whitley") (:keywords "convenience" "vc") (:url . "https://github.com/purplg/treebundel"))]) + (tree-sitter-ispell . [(20240522 1356) ((emacs (26 1)) (tree-sitter (0 15 0))) "Run ispell on tree-sitter text nodes" tar ((:commit . "960e68d6c4a296e5ecf10d27bfd8bac42ba4a2ed") (:authors ("Erick Navarro" . "erick@navarro.io")) (:maintainers ("Erick Navarro" . "erick@navarro.io")) (:maintainer "Erick Navarro" . "erick@navarro.io") (:url . "https://github.com/erickgnavar/tree-sitter-ispell.el"))]) + (tree-sitter-langs . [(20240602 731) ((emacs (25 1)) (tree-sitter (0 15 0))) "Grammar bundle for tree-sitter" tar ((:commit . "a7b51c99c44194a853be138ffde1a73360966bae") (:authors ("Tuấn-Anh Nguyễn" . "ubolonton@gmail.com")) (:maintainers ("Tuấn-Anh Nguyễn" . "ubolonton@gmail.com")) (:maintainer "Tuấn-Anh Nguyễn" . "ubolonton@gmail.com") (:keywords "languages" "tools" "parsers" "tree-sitter") (:url . "https://github.com/emacs-tree-sitter/tree-sitter-langs"))]) + (treebundel . [(20240531 2321) ((emacs (27 1)) (compat (29 1 4 2))) "Bundle related git-worktrees together" tar ((:commit . "b0a5d1bf924d8cadde5bae50b8d9ac131279b828") (:authors ("Ben Whitley")) (:maintainers ("Ben Whitley")) (:maintainer "Ben Whitley") (:keywords "convenience" "vc") (:url . "https://github.com/purplg/treebundel"))]) (treefactor . [(20200516 1631) ((emacs (26 1)) (dash (2 16 0)) (f (0 20 0)) (org (9 2 6)) (avy (0 5 0))) "Restructure your messy Org documents" tar ((:commit . "75357757022a4399ab772ff0d92065bd114dabe9") (:authors ("Leo Littlebook" . "Leo.Littlebook@gmail.com")) (:maintainers ("Leo Littlebook" . "Leo.Littlebook@gmail.com")) (:maintainer "Leo Littlebook" . "Leo.Littlebook@gmail.com") (:keywords "outlines" "files" "convenience") (:url . "https://github.com/cyberthal/treefactor"))]) (treemacs . [(20240518 932) ((emacs (26 1)) (cl-lib (0 5)) (dash (2 11 0)) (s (1 12 0)) (ace-window (0 9 0)) (pfuture (1 7)) (hydra (0 13 2)) (ht (2 2)) (cfrs (1 3 2))) "A tree style file explorer package" tar ((:commit . "923fbbdea57b27ed3293079b13846206add85d9d") (:authors ("Alexander Miller" . "alexanderm@web.de")) (:maintainers ("Alexander Miller" . "alexanderm@web.de")) (:maintainer "Alexander Miller" . "alexanderm@web.de") (:url . "https://github.com/Alexander-Miller/treemacs"))]) (treemacs-all-the-icons . [(20240131 2042) ((emacs (26 1)) (all-the-icons (4 0 1)) (treemacs (0 0))) "all-the-icons integration for treemacs" tar ((:commit . "bcba09c1581c4bd93ff0217d464aead04f6d26d4") (:authors ("Eric Dallo" . "ercdll1337@gmail.com")) (:maintainers ("Eric Dallo" . "ercdll1337@gmail.com")) (:maintainer "Eric Dallo" . "ercdll1337@gmail.com") (:url . "https://github.com/Alexander-Miller/treemacs"))]) @@ -5436,7 +5445,7 @@ (verona-mode . [(20200823 536) ((emacs (25 1)) (dash (2 17 0)) (hydra (0 15 0))) "A major mode for the Verona programming language" tar ((:commit . "72dd31ef847344d79409503f3c42169041eb3da4") (:keywords "languages" "programming") (:url . "https://github.com/damon-kwok/verona-mode"))]) (versuri . [(20211104 1301) ((emacs (26 1)) (dash (2 16 0)) (request (0 3 0)) (anaphora (1 0 4)) (esxml (0 1 0)) (s (1 12 0)) (esqlite (0 3 1))) "The lyrics package" tar ((:commit . "c8ea562304194f3379ed8f9c6a785ce8ee72898e") (:authors ("Mihai Olteanu" . "mihai_olteanu@fastmail.fm")) (:maintainers ("Mihai Olteanu" . "mihai_olteanu@fastmail.fm")) (:maintainer "Mihai Olteanu" . "mihai_olteanu@fastmail.fm") (:keywords "multimedia") (:url . "https://github.com/mihaiolteanu/versuri/"))]) (vertica . [(20131217 1511) ((sql (3 0))) "Vertica SQL mode extension" tar ((:commit . "3c9647b425c5c13c30bf0cba483646af18196588") (:authors ("Roman Scherer" . "roman@burningswell.com")) (:maintainers ("Roman Scherer" . "roman@burningswell.com")) (:maintainer "Roman Scherer" . "roman@burningswell.com") (:keywords "sql" "vertica"))]) - (vertica-snippets . [(20240327 1013) ((yasnippet (0 6 1))) "Yasnippets for Vertica" tar ((:commit . "11dd101eb431b7fc7695e5ad3b2a6444ac49e7a4") (:authors ("Andreas Gerler" . "baron@bundesbrandschatzamt.de")) (:maintainers ("Andreas Gerler" . "baron@bundesbrandschatzamt.de")) (:maintainer "Andreas Gerler" . "baron@bundesbrandschatzamt.de") (:keywords "convenience" "snippets") (:url . "https://github.com/baron42bba/vertica-snippets"))]) + (vertica-snippets . [(20240527 1136) ((yasnippet (0 6 1))) "Yasnippets for Vertica" tar ((:commit . "d764a25bfba01b542d6bc24a5cd3f07d394c1657") (:authors ("Andreas Gerler" . "baron@bundesbrandschatzamt.de")) (:maintainers ("Andreas Gerler" . "baron@bundesbrandschatzamt.de")) (:maintainer "Andreas Gerler" . "baron@bundesbrandschatzamt.de") (:keywords "convenience" "snippets") (:url . "https://github.com/baron42bba/vertica-snippets"))]) (vertico . [(20240511 2047) ((emacs (27 1)) (compat (29 1 4 4))) "VERTical Interactive COmpletion" tar ((:commit . "ba650a7ab90d66686ba787937ac9e71f749c598e") (:authors ("Daniel Mendler" . "mail@daniel-mendler.de")) (:maintainers ("Daniel Mendler" . "mail@daniel-mendler.de")) (:maintainer "Daniel Mendler" . "mail@daniel-mendler.de") (:keywords "convenience" "files" "matching" "completion") (:url . "https://github.com/minad/vertico"))]) (vertico-prescient . [(20240505 2249) ((emacs (27 1)) (prescient (6 1 0)) (vertico (0 28)) (compat (29 1))) "prescient.el + Vertico" tar ((:commit . "0765418e4362099db8788fcb745ce9b7602aa001") (:authors ("Radian LLC" . "contact+prescient@radian.codes")) (:maintainers ("Radian LLC" . "contact+prescient@radian.codes")) (:maintainer "Radian LLC" . "contact+prescient@radian.codes") (:keywords "extensions") (:url . "https://github.com/radian-software/prescient.el"))]) (vertigo . [(20211224 1256) ((dash (2 11 0))) "Jump across lines using the home row." tar ((:commit . "280b30518529242ee36cd436bd2349c34c35abb0") (:authors ("Fox Kiester" . "noct@posteo.net")) (:maintainers ("Fox Kiester" . "noct@posteo.net")) (:maintainer "Fox Kiester" . "noct@posteo.net") (:keywords "vim" "vertigo") (:url . "https://github.com/noctuid/vertigo.el"))]) @@ -5469,8 +5478,8 @@ (voca-builder . [(20161101 1645) ((popup (0 5 2))) "Helps you build up your vocabulary" tar ((:commit . "51573beec8cd8308477b0faf453aad93e17f57c5") (:authors ("Yi Tang" . "yi.tang.uk@me.com")) (:maintainers ("Yi Tang" . "yi.tang.uk@me.com")) (:maintainer "Yi Tang" . "yi.tang.uk@me.com") (:keywords "english" "vocabulary") (:url . "https://github.com/yitang/voca-builder"))]) (volatile-highlights . [(20230301 1402) nil "Minor mode for visual feedback on some operations." tar ((:commit . "fcf6e2778454ce514c189a7d1fe70e03ad81c325") (:authors ("K-talo Miyazaki <Keitaro dot Miyazaki at gmail dot com>")) (:maintainers ("K-talo Miyazaki <Keitaro dot Miyazaki at gmail dot com>")) (:maintainer "K-talo Miyazaki <Keitaro dot Miyazaki at gmail dot com>") (:keywords "emulations" "convenience" "wp") (:url . "http://www.emacswiki.org/emacs/download/volatile-highlights.el"))]) (volume . [(20220904 1727) nil "tweak your sound card volume from Emacs" tar ((:commit . "050d3e6d2543a6771a13f95612055864679b6301") (:authors ("Daniel Brockman" . "daniel@brockman.se")) (:maintainers ("Daniel Brockman" . "daniel@brockman.se")) (:maintainer "Daniel Brockman" . "daniel@brockman.se") (:url . "http://www.brockman.se/software/volume-el/"))]) - (vs-dark-theme . [(20240520 654) ((emacs (24 1))) "Visual Studio IDE dark theme" tar ((:commit . "0eda8bae7fef2d050cf764c5e2b44d8e0a27ab47") (:authors ("Jen-Chieh Shen")) (:maintainers ("Jen-Chieh Shen")) (:maintainer "Jen-Chieh Shen") (:url . "https://github.com/emacs-vs/vs-dark-theme"))]) - (vs-light-theme . [(20240520 105) ((emacs (24 1))) "Visual Studio IDE light theme" tar ((:commit . "ad61f777d374f67db5e5ef66ab6da2967ba83abd") (:authors ("Jen-Chieh Shen")) (:maintainers ("Jen-Chieh Shen")) (:maintainer "Jen-Chieh Shen") (:url . "https://github.com/emacs-vs/vs-light-theme"))]) + (vs-dark-theme . [(20240529 530) ((emacs (24 1))) "Visual Studio IDE dark theme" tar ((:commit . "8f3d8e868cfa5ad8743a723cdba6be154d6a1ae8") (:authors ("Jen-Chieh Shen")) (:maintainers ("Jen-Chieh Shen")) (:maintainer "Jen-Chieh Shen") (:url . "https://github.com/emacs-vs/vs-dark-theme"))]) + (vs-light-theme . [(20240529 531) ((emacs (24 1))) "Visual Studio IDE light theme" tar ((:commit . "fe9079fe76b2daba4a8e26effbe3c1f77cc083ff") (:authors ("Jen-Chieh Shen")) (:maintainers ("Jen-Chieh Shen")) (:maintainer "Jen-Chieh Shen") (:url . "https://github.com/emacs-vs/vs-light-theme"))]) (vscdark-theme . [(20191212 107) ((emacs (24 1))) "VS Code Dark+ like theme" tar ((:commit . "f419553e2a2f091a8bc257fb5ab520326e93ddd4") (:authors ("Alexander L. Belikoff")) (:maintainers ("Alexander L. Belikoff")) (:maintainer "Alexander L. Belikoff") (:url . "https://github.com/abelikoff/vscdark-theme"))]) (vscode-dark-plus-theme . [(20230725 1703) nil "Default Visual Studio Code Dark+ theme" tar ((:commit . "65420ca73b543e1e7955905bea1a8d7e5fe6c5ff") (:authors ("Ian Y.E. Pan")) (:maintainers ("Ian Y.E. Pan")) (:maintainer "Ian Y.E. Pan") (:url . "https://github.com/ianpan870102/vscode-dark-plus-emacs-theme"))]) (vscode-icon . [(20230330 2206) ((emacs (25 1))) "Utility package to provide Vscode style icons" tar ((:commit . "3976bc2e7e2fe0068ae59c11d226f67e0e87aaea") (:authors ("James Nguyen" . "james@jojojames.com")) (:maintainers ("James Nguyen" . "james@jojojames.com")) (:maintainer "James Nguyen" . "james@jojojames.com") (:keywords "files" "tools") (:url . "https://github.com/jojojames/vscode-icon-emacs"))]) @@ -5480,7 +5489,7 @@ (vue-html-mode . [(20180428 2035) nil "Major mode for editing Vue.js templates" tar ((:commit . "361a9fa117f044c3072dc5a7344ff7be31725849") (:authors ("Adam Niederer" . "adam.niederer@gmail.com")) (:maintainers ("Adam Niederer" . "adam.niederer@gmail.com")) (:maintainer "Adam Niederer" . "adam.niederer@gmail.com") (:keywords "languages" "vue" "template") (:url . "http://github.com/AdamNiederer/vue-html-mode"))]) (vue-mode . [(20240101 333) ((mmm-mode (0 5 5)) (vue-html-mode (0 2)) (ssass-mode (0 2)) (edit-indirect (0 1 4))) "Major mode for vue component based on mmm-mode" tar ((:commit . "3a8056bc6ea6458265efb91067c7467860d2c118") (:authors ("codefalling" . "code.falling@gmail.com")) (:maintainers ("codefalling" . "code.falling@gmail.com")) (:maintainer "codefalling" . "code.falling@gmail.com") (:keywords "languages") (:url . "https://github.com/AdamNiederer/vue-mode"))]) (vuiet . [(20231231 1051) ((emacs (26 1)) (lastfm (1 1)) (versuri (1 0)) (s (1 12 0)) (bind-key (2 4)) (mpv (0 1 0)) (ivy (0 14 2))) "The music player and explorer for Emacs" tar ((:commit . "25d79860b165f04d7d39395138ed4f23e982132f") (:authors ("Mihai Olteanu" . "mihai_olteanu@fastmail.fm")) (:maintainers ("Mihai Olteanu" . "mihai_olteanu@fastmail.fm")) (:maintainer "Mihai Olteanu" . "mihai_olteanu@fastmail.fm") (:keywords "multimedia") (:url . "https://github.com/mihaiolteanu/vuiet"))]) - (vulpea . [(20231113 717) ((emacs (27 2)) (org (9 4 4)) (org-roam (2 0 0)) (s (1 12)) (dash (2 19))) "A collection of org-roam note-taking functions" tar ((:commit . "e1ea8480daf3e480effdd7ba3799126295a4a59a") (:authors ("Boris Buliga" . "boris@d12frosted.io")) (:maintainers ("Boris Buliga" . "boris@d12frosted.io")) (:maintainer "Boris Buliga" . "boris@d12frosted.io") (:url . "https://github.com/d12frosted/vulpea"))]) + (vulpea . [(20240528 1638) ((emacs (27 2)) (org (9 4 4)) (org-roam (2 0 0)) (s (1 12)) (dash (2 19))) "A collection of org-roam note-taking functions" tar ((:commit . "06c705a77f2b4b9ccee8d7726398c1668e2af752") (:authors ("Boris Buliga" . "boris@d12frosted.io")) (:maintainers ("Boris Buliga" . "boris@d12frosted.io")) (:maintainer "Boris Buliga" . "boris@d12frosted.io") (:url . "https://github.com/d12frosted/vulpea"))]) (vunit-mode . [(20230913 1754) ((hydra (0 14 0)) (emacs (24 3))) "VUnit Runner Interface" tar ((:commit . "a2126892f17a48c857682b6455f963a3fb7e07f0") (:authors ("Lukas Lichtl" . "support@embed-me.com")) (:maintainers ("Lukas Lichtl" . "support@embed-me.com")) (:maintainer "Lukas Lichtl" . "support@embed-me.com") (:keywords "vunit" "python" "tools") (:url . "https://github.com/embed-me"))]) (vyper-mode . [(20180707 1935) ((emacs (24 3))) "Major mode for the Vyper programming language" tar ((:commit . "323dfddfc38f0b11697e9ebaf04d1b53297e54e5") (:authors ("Alex Stokes" . "r.alex.stokes@gmail.com")) (:maintainers ("Alex Stokes" . "r.alex.stokes@gmail.com")) (:maintainer "Alex Stokes" . "r.alex.stokes@gmail.com") (:keywords "languages") (:url . "https://github.com/ralexstokes/vyper-mode"))]) (w32-browser . [(20170101 1954) nil "Run Windows application associated with a file." tar ((:commit . "e5c60eafd8f8d3546a0fa295ad5af2414d36b4e6") (:authors ("Emacs Wiki, Drew Adams")) (:maintainers (nil . "Drew Adams (concat \"drew.adams\" \"@\" \"oracle\" \".com\")")) (:maintainer nil . "Drew Adams (concat \"drew.adams\" \"@\" \"oracle\" \".com\")") (:keywords "mouse" "dired" "w32" "explorer") (:url . "http://www.emacswiki.org/w32-browser.el"))]) @@ -5701,7 +5710,7 @@ (zeno-theme . [(20211205 2148) ((emacs (24))) "A dark theme using different shades of blue" tar ((:commit . "70fa7b7442f24ea25eab538b5a22da690745fef5") (:authors ("Bharat Joshi" . "jbharat@outlook.com")) (:maintainers ("Bharat Joshi" . "jbharat@outlook.com")) (:maintainer "Bharat Joshi" . "jbharat@outlook.com") (:keywords "faces" "theme" "dark" "blue") (:url . "https://github.com/jbharat/zeno-theme"))]) (zenscript-mode . [(20210102 1350) ((emacs (25 1))) "Major mode for ZenScript" tar ((:commit . "c33b4525502459fe60dd76b383e19919d450aeb8") (:url . "https://github.com/eutropius225/zenscript-mode"))]) (zephir-mode . [(20200417 830) ((cl-lib (0 5)) (pkg-info (0 4)) (emacs (25 1))) "Major mode for editing Zephir code" tar ((:commit . "4e9618b77dff67c1c7b6fff78605a62311db88b8") (:authors ("Serghei Iakovlev" . "egrep@protonmail.ch")) (:maintainers ("Serghei Iakovlev" . "egrep@protonmail.ch")) (:maintainer "Serghei Iakovlev" . "egrep@protonmail.ch") (:keywords "languages") (:url . "https://github.com/zephir-lang/zephir-mode"))]) - (zero-input . [(20200405 1220) ((emacs (24 3)) (s (1 2 0))) "Zero Chinese input method framework" tar ((:commit . "729da9f4b99acb744ee6974ed7f3d4e252fd19da") (:url . "https://gitlab.emacsos.com/sylecn/zero-el"))]) + (zero-input . [(20240527 728) ((emacs (24 4)) (s (1 2 0))) "Zero Chinese input method framework" tar ((:commit . "e87bbf24c1475a784ad9d1ba8447e038824d796b") (:url . "https://gitlab.emacsos.com/sylecn/zero-el"))]) (zerodark-theme . [(20211115 841) ((all-the-icons (2 0 0))) "A dark, medium contrast theme for Emacs" tar ((:commit . "b463528704f6eb00684c0ee003fbd8e42901cde0") (:authors ("Nicolas Petton" . "nicolas@petton.fr")) (:maintainers ("Nicolas Petton" . "nicolas@petton.fr")) (:maintainer "Nicolas Petton" . "nicolas@petton.fr") (:keywords "themes") (:url . "https://github.com/NicolasPetton/zerodark-theme"))]) (zetteldeft . [(20221006 731) ((emacs (25 1)) (deft (0 8)) (ace-window (0 7 0))) "Turn deft into a zettelkasten system" tar ((:commit . "63be6478751376f04d36c6ea52fe65acd69f0927") (:authors ("EFLS <Elias Storms>")) (:maintainers ("EFLS <Elias Storms>")) (:maintainer "EFLS <Elias Storms>") (:keywords "deft" "zettelkasten" "zetteldeft" "wp" "files") (:url . "https://efls.github.io/zetteldeft/"))]) (zetteldesk . [(20230517 2020) ((emacs (27 1)) (org-roam (2 0))) "A revision and outlining tool for org-roam" tar ((:commit . "73f691989c094ec196bb614318ae51b60209a8de") (:authors ("Vidianos Giannitsis" . "vidianosgiannitsis@gmail.com")) (:maintainers ("Vidianos Giannitsis" . "vidianosgiannitsis@gmail.com")) (:maintainer "Vidianos Giannitsis" . "vidianosgiannitsis@gmail.com") (:url . "https://github.com/Vidianos-Giannitsis/zetteldesk.el"))]) diff --git a/emacs/elpa/archives/nongnu/archive-contents b/emacs/elpa/archives/nongnu/archive-contents @@ -85,16 +85,16 @@ ("Justin Talbott" . "justin@waymondo.com")) (:commit . "cb56b8c1a4ea42a329b279e57b3db473f0be4adc"))]) (arduino-mode . - [(1 3 0) + [(1 3 1) ((emacs (25 1)) (spinner (1 7 3))) "Major mode for editing Arduino code" tar - ((:url . "https://github.com/stardiviner/arduino-mode") + ((:url . "https://repo.or.cz/arduino-mode.git") (:keywords "languages" "arduino") (:maintainer "stardiviner" . "numbchild@gmail.com") - (:commit . "b1e264568688a1225126c7b9e522bcdc394f354c"))]) + (:commit . "b2ffd8441851659cb1cc844156073967729585e5"))]) (auto-dim-other-buffers . [(2 1 1) nil "Makes windows without focus less prominent" tar @@ -242,11 +242,11 @@ (:url . "https://elpa.nongnu.org/nongnu/cdlatex.html") (:commit . "33770dec73138909714711b05a63e79da5a19ccd"))]) (cider . - [(1 13 1) + [(1 14 0) ((emacs (26)) (clojure-mode - (5 18 1)) + (5 19)) (parseedn (1 2 1)) (queue @@ -270,16 +270,16 @@ ("Artur Malabarba" . "bruce.connor.am@gmail.com") ("Hugo Duncan" . "hugo@hugoduncan.org") ("Steve Purcell" . "steve@sanityinc.com")) - (:commit . "06dc45844ad05fe23fccb7dec1609404e3cda88e"))]) + (:commit . "c3acf55af0a8c03a2a050f66b328bba8d2402574"))]) (clojure-mode . - [(5 18 1) + [(5 19 0) ((emacs (25 1))) "Major mode for Clojure code" tar ((:url . "https://github.com/clojure-emacs/clojure-mode") (:keywords "languages" "clojure" "clojurescript" "lisp") (:maintainer "Bozhidar Batsov" . "bozhidar@batsov.dev") - (:commit . "25d713a67d8e0209ee74bfc0153fdf677697b43f"))]) + (:commit . "4afdd3539036bbd6b1c01b2e00559676c4d40085"))]) (clojure-ts-mode . [(0 2 2) ((emacs @@ -837,7 +837,7 @@ ("Akib Azmain Turja" . "akib@disroot.org")) (:commit . "ce2ea016a67b200862788e81f0ff1f8f7e4e0454"))]) (geiser . - [(0 30) + [(0 31) ((emacs (27 1)) (project @@ -848,7 +848,7 @@ (:maintainer "Jose Antonio Ortega Ruiz" . "(jao@gnu.org)") (:authors ("Jose Antonio Ortega Ruiz" . "(jao@gnu.org)")) - (:commit . "f343592a52da0f947989d07c208a51ad6c972a5e"))]) + (:commit . "b6b4ac070d136345345c80ff649f0084e3c512a5"))]) (geiser-chez . [(0 18) ((emacs @@ -1152,31 +1152,29 @@ (:keywords "languages") (:commit . "59640ceec33cd4df37096289e11ff6f4b876be03"))]) (helm . - [(3 9 8) + [(3 9 9) ((helm-core - (3 9 8)) + (3 9 9)) (wfnames - (1 1)) - (popup - (0 5 3))) + (1 2))) "Helm is an Emacs incremental and narrowing framework" tar ((:url . "https://emacs-helm.github.io/helm/") (:maintainer "Thierry Volpiatto" . "thievol@posteo.net") (:authors ("Thierry Volpiatto" . "thievol@posteo.net")) - (:commit . "6ae44dba0cb72a3a6950cbe36d104db9c69dfb49"))]) + (:commit . "aa51c1a8d6ff4e1e88e61e989f41ac3aa808a592"))]) (helm-core . - [(3 9 8) + [(3 9 9) ((emacs (25 1)) (async - (1 9 7))) + (1 9 8))) "Development files for Helm" tar ((:url . "https://emacs-helm.github.io/helm/") (:maintainer "Thierry Volpiatto" . "thievol@posteo.net") (:authors ("Thierry Volpiatto" . "thievol@posteo.net")) - (:commit . "6ae44dba0cb72a3a6950cbe36d104db9c69dfb49"))]) + (:commit . "aa51c1a8d6ff4e1e88e61e989f41ac3aa808a592"))]) (highlight-parentheses . [(2 2 2) ((emacs @@ -1460,7 +1458,7 @@ ("Jason R. Blevins" . "jblevins@xbeta.org")) (:commit . "193b61605f44c85d261b8bd82e0a213fd8f1ff32"))]) (mastodon . - [(1 0 12) + [(1 0 23) ((emacs (27 1)) (request @@ -1473,7 +1471,7 @@ (:authors ("Johnson Denen" . "johnson.denen@gmail.com") ("Marty Hiatt" . "martianhiatus@riseup.net")) - (:commit . "cd2d6f23b4f7af63df3000f2fb68227c22bc8dee"))]) + (:commit . "ac5684acaa2c0910350a5a79977b28dea8ddf8d7"))]) (material-theme . [(2015) ((emacs @@ -2002,7 +2000,7 @@ (:keywords "markup" "language" "css") (:commit . "aee28ea552dce5aade05d8a7f91514e6eb37e59f"))]) (scad-mode . - [(93 3) + [(94 0) ((emacs (27 1)) (compat @@ -2013,7 +2011,7 @@ (:maintainer ("Len Trigg" . "lenbok@gmail.com") ("Daniel Mendler" . "mail@daniel-mendler.de")) - (:commit . "8d5650c5cfee96c42d64427bfcadb89f6bda66be"))]) + (:commit . "3c32b141f083c31539bb24700eb0aa23ea55918c"))]) (scala-mode . [(0 23) nil "Major mode for editing Scala" tar @@ -2489,14 +2487,14 @@ ((:url . "https://github.com/lewang/ws-butler") (:commit . "323b651dd70ee40a25accc940b8f80c3a3185205"))]) (xah-fly-keys . - [(25 5 20240515230030) + [(25 6 20240523134425) ((emacs (27))) "ergonomic modal keybinding minor mode." tar ((:url . "http://xahlee.info/emacs/misc/xah-fly-keys.html") (:keywords "convenience" "vi" "vim" "ergoemacs" "keybinding") (:maintainer "Xah Lee" . "xah@xahlee.org") - (:commit . "c8a34178419058c0fcdb821ae6c958a1e7f5d95e"))]) + (:commit . "470c612021ad5370312feefeed48fdcb30088145"))]) (xkcd . [(1 1) ((json diff --git a/emacs/elpa/archives/nongnu/archive-contents.signed b/emacs/elpa/archives/nongnu/archive-contents.signed @@ -1 +1 @@ -Good signature from 645357D2883A0966 GNU ELPA Signing Agent (2023) <elpasign@elpa.gnu.org> (trust undefined) created at 2024-05-21T09:05:05+0000 using EDDSA -\ No newline at end of file +Good signature from 645357D2883A0966 GNU ELPA Signing Agent (2023) <elpasign@elpa.gnu.org> (trust undefined) created at 2024-06-02T09:05:05+0000 using EDDSA +\ No newline at end of file diff --git a/emacs/elpa/consult-20240516.2240/consult-pkg.el b/emacs/elpa/consult-20240516.2240/consult-pkg.el @@ -1,15 +0,0 @@ -(define-package "consult" "20240516.2240" "Consulting completing-read" - '((emacs "27.1") - (compat "29.1.4.4")) - :commit "80407622f323669c735737272ecbc3b602434b77" :authors - '(("Daniel Mendler and Consult contributors")) - :maintainers - '(("Daniel Mendler" . "mail@daniel-mendler.de")) - :maintainer - '("Daniel Mendler" . "mail@daniel-mendler.de") - :keywords - '("matching" "files" "completion") - :url "https://github.com/minad/consult") -;; Local Variables: -;; no-byte-compile: t -;; End: diff --git a/emacs/elpa/consult-20240516.2240/consult.el b/emacs/elpa/consult-20240516.2240/consult.el @@ -1,5262 +0,0 @@ -;;; consult.el --- Consulting completing-read -*- lexical-binding: t -*- - -;; Copyright (C) 2021-2024 Free Software Foundation, Inc. - -;; Author: Daniel Mendler and Consult contributors -;; Maintainer: Daniel Mendler <mail@daniel-mendler.de> -;; Created: 2020 -;; Version: 1.6 -;; Package-Requires: ((emacs "27.1") (compat "29.1.4.4")) -;; Homepage: https://github.com/minad/consult -;; Keywords: matching, files, completion - -;; This file is part of GNU Emacs. - -;; 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 <https://www.gnu.org/licenses/>. - -;;; Commentary: - -;; Consult implements a set of `consult-<thing>' commands, which aim to -;; improve the way you use Emacs. The commands are founded on -;; `completing-read', which selects from a list of candidate strings. -;; Consult provides an enhanced buffer switcher `consult-buffer' and -;; search and navigation commands like `consult-imenu' and -;; `consult-line'. Searching through multiple files is supported by the -;; asynchronous `consult-grep' command. Many Consult commands support -;; previewing candidates. If a candidate is selected in the completion -;; view, the buffer shows the candidate immediately. - -;; The Consult commands are compatible with multiple completion systems -;; based on the Emacs `completing-read' API, including the default -;; completion system, Vertico, Mct and Icomplete. - -;; See the README for an overview of the available Consult commands and -;; the documentation of the configuration and installation of the -;; package. - -;; The full list of contributors can be found in the acknowledgments -;; section of the README. - -;;; Code: - -(eval-when-compile - (require 'cl-lib) - (require 'subr-x)) -(require 'compat) -(require 'bookmark) - -(defgroup consult nil - "Consulting `completing-read'." - :link '(info-link :tag "Info Manual" "(consult)") - :link '(url-link :tag "Homepage" "https://github.com/minad/consult") - :link '(emacs-library-link :tag "Library Source" "consult.el") - :group 'files - :group 'outlines - :group 'minibuffer - :prefix "consult-") - -;;;; Customization - -(defcustom consult-narrow-key nil - "Prefix key for narrowing during completion. - -Good choices for this key are \"<\" and \"C-+\" for example. The -key must be a string accepted by `key-valid-p'." - :type '(choice key (const :tag "None" nil))) - -(defcustom consult-widen-key nil - "Key used for widening during completion. - -If this key is unset, defaults to twice the `consult-narrow-key'. -The key must be a string accepted by `key-valid-p'." - :type '(choice key (const :tag "None" nil))) - -(defcustom consult-project-function - #'consult--default-project-function - "Function which returns project root directory. -The function takes one boolean argument MAY-PROMPT. If -MAY-PROMPT is non-nil, the function may ask the prompt the user -for a project directory. The root directory is used by -`consult-buffer' and `consult-grep'." - :type `(choice - (const :tag "Default project function" ,#'consult--default-project-function) - (function :tag "Custom function") - (const :tag "No project integration" nil))) - -(defcustom consult-async-refresh-delay 0.2 - "Refreshing delay of the completion UI for asynchronous commands. - -The completion UI is only updated every -`consult-async-refresh-delay' seconds. This applies to -asynchronous commands like for example `consult-grep'." - :type '(float :tag "Delay in seconds")) - -(defcustom consult-async-input-throttle 0.5 - "Input throttle for asynchronous commands. - -The asynchronous process is started only every -`consult-async-input-throttle' seconds. This applies to asynchronous -commands, e.g., `consult-grep'." - :type '(float :tag "Delay in seconds")) - -(defcustom consult-async-input-debounce 0.2 - "Input debounce for asynchronous commands. - -The asynchronous process is started only when there has not been new -input for `consult-async-input-debounce' seconds. This applies to -asynchronous commands, e.g., `consult-grep'." - :type '(float :tag "Delay in seconds")) - -(defcustom consult-async-min-input 3 - "Minimum number of characters needed, before asynchronous process is called. - -This applies to asynchronous commands, e.g., `consult-grep'." - :type '(natnum :tag "Number of characters")) - -(defcustom consult-async-split-style 'perl - "Async splitting style, see `consult-async-split-styles-alist'." - :type '(choice (const :tag "No splitting" nil) - (const :tag "Comma" comma) - (const :tag "Semicolon" semicolon) - (const :tag "Perl" perl))) - -(defcustom consult-async-split-styles-alist - `((nil :function ,#'consult--split-nil) - (comma :separator ?, :function ,#'consult--split-separator) - (semicolon :separator ?\; :function ,#'consult--split-separator) - (perl :initial "#" :function ,#'consult--split-perl)) - "Async splitting styles." - :type '(alist :key-type symbol :value-type plist)) - -(defcustom consult-mode-histories - '((eshell-mode eshell-history-ring eshell-history-index eshell-bol) - (comint-mode comint-input-ring comint-input-ring-index comint-bol) - (term-mode term-input-ring term-input-ring-index term-bol)) - "Alist of mode histories (mode history index bol). -The histories can be rings or lists. Index, if provided, is a -variable to set to the index of the selection within the ring or -list. Bol, if provided is a function which jumps to the beginning -of the line after the prompt." - :type '(alist :key-type symbol - :value-type (group :tag "Include Index" - (symbol :tag "List/Ring") - (symbol :tag "Index Variable") - (symbol :tag "Bol Function")))) - -(defcustom consult-themes nil - "List of themes (symbols or regexps) to be presented for selection. -nil shows all `custom-available-themes'." - :type '(repeat (choice symbol regexp))) - -(defcustom consult-after-jump-hook (list #'recenter) - "Function called after jumping to a location. - -Commonly used functions for this hook are `recenter' and -`reposition-window'. You may want to add a function which pulses -the current line, e.g., `pulse-momentary-highlight-one-line' is -supported on Emacs 28 and newer. The hook called during preview -and for the jump after selection." - :type 'hook) - -(defcustom consult-line-start-from-top nil - "Start search from the top if non-nil. -Otherwise start the search at the current line and wrap around." - :type 'boolean) - -(defcustom consult-point-placement 'match-beginning - "Where to leave point when jumping to a match. -This setting affects the command `consult-line' and the `consult-grep' variants." - :type '(choice (const :tag "Beginning of the line" line-beginning) - (const :tag "Beginning of the match" match-beginning) - (const :tag "End of the match" match-end))) - -(defcustom consult-line-numbers-widen t - "Show absolute line numbers when narrowing is active. - -See also `display-line-numbers-widen'." - :type 'boolean) - -(defcustom consult-goto-line-numbers t - "Show line numbers for `consult-goto-line'." - :type 'boolean) - -(defcustom consult-fontify-preserve t - "Preserve fontification for line-based commands." - :type 'boolean) - -(defcustom consult-fontify-max-size 1048576 - "Buffers larger than this byte limit are not fontified. - -This is necessary in order to prevent a large startup time -for navigation commands like `consult-line'." - :type '(natnum :tag "Buffer size in bytes")) - -(defcustom consult-buffer-filter - '("\\` " - "\\`\\*Completions\\*\\'" - "\\`\\*Flymake log\\*\\'" - "\\`\\*Semantic SymRef\\*\\'" - "\\`\\*tramp/.*\\*\\'") - "Filter regexps for `consult-buffer'. - -The default setting is to filter ephemeral buffer names beginning -with a space character, the *Completions* buffer and a few log -buffers. The regular expressions are matched case sensitively." - :type '(repeat regexp)) - -(defcustom consult-buffer-sources - '(consult--source-hidden-buffer - consult--source-modified-buffer - consult--source-buffer - consult--source-recent-file - consult--source-file-register - consult--source-bookmark - consult--source-project-buffer-hidden - consult--source-project-recent-file-hidden) - "Sources used by `consult-buffer'. -See also `consult-project-buffer-sources'. -See `consult--multi' for a description of the source data structure." - :type '(repeat symbol)) - -(defcustom consult-project-buffer-sources - '(consult--source-project-buffer - consult--source-project-recent-file) - "Sources used by `consult-project-buffer'. -See also `consult-buffer-sources'. -See `consult--multi' for a description of the source data structure." - :type '(repeat symbol)) - -(defcustom consult-mode-command-filter - '(;; Filter commands - "-mode\\'" "--" - ;; Filter whole features - simple mwheel time so-long recentf tab-bar tab-line) - "Filter commands for `consult-mode-command'." - :type '(repeat (choice symbol regexp))) - -(defcustom consult-grep-max-columns 300 - "Maximal number of columns of grep output." - :type 'natnum) - -(defconst consult--grep-match-regexp - "\\`\\(?:\\./\\)?\\([^\n\0]+\\)\0\\([0-9]+\\)\\([-:\0]\\)" - "Regexp used to match file and line of grep output.") - -(defcustom consult-grep-args - '("grep" (consult--grep-exclude-args) - "--null --line-buffered --color=never --ignore-case\ - --with-filename --line-number -I -r") - "Command line arguments for grep, see `consult-grep'. -The dynamically computed arguments are appended. -Can be either a string, or a list of strings or expressions." - :type '(choice string (repeat (choice string sexp)))) - -(defcustom consult-git-grep-args - "git --no-pager grep --null --color=never --ignore-case\ - --extended-regexp --line-number -I" - "Command line arguments for git-grep, see `consult-git-grep'. -The dynamically computed arguments are appended. -Can be either a string, or a list of strings or expressions." - :type '(choice string (repeat (choice string sexp)))) - -(defcustom consult-ripgrep-args - "rg --null --line-buffered --color=never --max-columns=1000 --path-separator /\ - --smart-case --no-heading --with-filename --line-number --search-zip" - "Command line arguments for ripgrep, see `consult-ripgrep'. -The dynamically computed arguments are appended. -Can be either a string, or a list of strings or expressions." - :type '(choice string (repeat (choice string sexp)))) - -(defcustom consult-find-args - "find . -not ( -path */.[A-Za-z]* -prune )" - "Command line arguments for find, see `consult-find'. -The dynamically computed arguments are appended. -Can be either a string, or a list of strings or expressions." - :type '(choice string (repeat (choice string sexp)))) - -(defcustom consult-fd-args - '((if (executable-find "fdfind" 'remote) "fdfind" "fd") - "--full-path --color=never") - "Command line arguments for fd, see `consult-fd'. -The dynamically computed arguments are appended. -Can be either a string, or a list of strings or expressions." - :type '(choice string (repeat (choice string sexp)))) - -(defcustom consult-locate-args - "locate --ignore-case" ;; --existing not supported by Debian plocate - "Command line arguments for locate, see `consult-locate'. -The dynamically computed arguments are appended. -Can be either a string, or a list of strings or expressions." - :type '(choice string (repeat (choice string sexp)))) - -(defcustom consult-man-args - "man -k" - "Command line arguments for man, see `consult-man'. -The dynamically computed arguments are appended. -Can be either a string, or a list of strings or expressions." - :type '(choice string (repeat (choice string sexp)))) - -(defcustom consult-preview-key 'any - "Preview trigger keys, can be nil, `any', a single key or a list of keys. -Debouncing can be specified via the `:debounce' attribute. The -individual keys must be strings accepted by `key-valid-p'." - :type '(choice (const :tag "Any key" any) - (list :tag "Debounced" - (const :debounce) - (float :tag "Seconds" 0.1) - (const any)) - (const :tag "No preview" nil) - (key :tag "Key") - (repeat :tag "List of keys" key))) - -(defcustom consult-preview-partial-size 1048576 - "Files larger than this byte limit are previewed partially." - :type '(natnum :tag "File size in bytes")) - -(defcustom consult-preview-partial-chunk 102400 - "Partial preview chunk size in bytes. -If a file is larger than `consult-preview-partial-size' only the -chunk from the beginning of the file is previewed." - :type '(natnum :tag "Chunk size in bytes")) - -(defcustom consult-preview-max-count 10 - "Number of file buffers to keep open temporarily during preview." - :type '(natnum :tag "Number of buffers")) - -(defcustom consult-preview-excluded-files - '("\\`/[^/|:]+:") ;; Do not preview remote files - "List of regexps matched against names of files, which are not previewed." - :type '(repeat regexp)) - -(defcustom consult-preview-allowed-hooks - '(global-font-lock-mode - save-place-find-file-hook) - "List of hooks, which should be executed during file preview. -This variable applies to `find-file-hook', `change-major-mode-hook' and -mode hooks, e.g., `prog-mode-hook'." - :type '(repeat symbol)) - -(defcustom consult-preview-variables - '((inhibit-message . t) - (enable-dir-local-variables . nil) - (enable-local-variables . :safe) - (non-essential . t) - (delay-mode-hooks . t)) - "Variables which are bound for file preview." - :type '(alist :key-type symbol)) - -(defcustom consult-bookmark-narrow - `((?f "File" bookmark-default-handler) - (?h "Help" help-bookmark-jump Info-bookmark-jump - Man-bookmark-jump woman-bookmark-jump) - (?p "Picture" image-bookmark-jump) - (?d "Docview" doc-view-bookmark-jump) - (?m "Mail" gnus-summary-bookmark-jump) - (?s "Eshell" eshell-bookmark-jump) - (?w "Web" eww-bookmark-jump xwidget-webkit-bookmark-jump-handler) - (?v "VC Directory" vc-dir-bookmark-jump) - (nil "Other")) - "Bookmark narrowing configuration. - -Each element of the list must have the form (char name handlers...)." - :type '(alist :key-type character :value-type (cons string (repeat function)))) - -(defcustom consult-yank-rotate - (if (boundp 'yank-from-kill-ring-rotate) - yank-from-kill-ring-rotate - t) - "Rotate the `kill-ring' in the `consult-yank' commands." - :type 'boolean) - -;;;; Faces - -(defgroup consult-faces nil - "Faces used by Consult." - :group 'consult - :group 'faces) - -(defface consult-preview-line - '((t :inherit consult-preview-insertion :extend t)) - "Face used for line previews.") - -(defface consult-highlight-match - '((t :inherit match)) - "Face used to highlight matches in the completion candidates. -Used for example by `consult-grep'.") - -(defface consult-highlight-mark - '((t :inherit consult-highlight-match)) - "Face used for mark positions in completion candidates. -Used for example by `consult-mark'. The face should be different -than the `cursor' face to avoid confusion.") - -(defface consult-preview-match - '((t :inherit isearch)) - "Face used for match previews, e.g., in `consult-line'.") - -(defface consult-preview-insertion - '((t :inherit region)) - "Face used for previews of text to be inserted. -Used by `consult-completion-in-region', `consult-yank' and `consult-history'.") - -(defface consult-narrow-indicator - '((t :inherit warning)) - "Face used for the narrowing indicator.") - -(defface consult-async-running - '((t :inherit consult-narrow-indicator)) - "Face used if asynchronous process is running.") - -(defface consult-async-finished - '((t :inherit success)) - "Face used if asynchronous process has finished.") - -(defface consult-async-failed - '((t :inherit error)) - "Face used if asynchronous process has failed.") - -(defface consult-async-split - '((t :inherit font-lock-negation-char-face)) - "Face used to highlight punctuation character.") - -(defface consult-help - '((t :inherit shadow)) - "Face used to highlight help, e.g., in `consult-register-store'.") - -(defface consult-key - '((t :inherit font-lock-keyword-face)) - "Face used to highlight keys, e.g., in `consult-register'.") - -(defface consult-line-number - '((t :inherit consult-key)) - "Face used to highlight location line in `consult-global-mark'.") - -(defface consult-file - '((t :inherit font-lock-function-name-face)) - "Face used to highlight files in `consult-buffer'.") - -(defface consult-grep-context - '((t :inherit shadow)) - "Face used to highlight grep context in `consult-grep'.") - -(defface consult-bookmark - '((t :inherit font-lock-constant-face)) - "Face used to highlight bookmarks in `consult-buffer'.") - -(defface consult-buffer - '((t)) - "Face used to highlight buffers in `consult-buffer'.") - -(defface consult-line-number-prefix - '((t :inherit line-number)) - "Face used to highlight line number prefixes.") - -(defface consult-line-number-wrapped - '((t :inherit consult-line-number-prefix :inherit font-lock-warning-face)) - "Face used to highlight line number prefixes after wrap around.") - -(defface consult-separator - '((((class color) (min-colors 88) (background light)) - :foreground "#ccc") - (((class color) (min-colors 88) (background dark)) - :foreground "#333")) - "Face used for thin line separators in `consult-register-window'.") - -;;;; Input history variables - -(defvar consult--path-history nil) -(defvar consult--grep-history nil) -(defvar consult--find-history nil) -(defvar consult--man-history nil) -(defvar consult--line-history nil) -(defvar consult--line-multi-history nil) -(defvar consult--theme-history nil) -(defvar consult--minor-mode-menu-history nil) -(defvar consult--buffer-history nil) - -;;;; Internal variables - -(defvar consult--regexp-compiler - #'consult--default-regexp-compiler - "Regular expression compiler used by `consult-grep' and other commands. -The function must return a list of regular expressions and a highlighter -function.") - -(defvar consult--customize-alist - ;; Disable preview in frames, since `consult--jump-preview' does not properly - ;; clean up. See gh:minad/consult#593. This issue should better be fixed in - ;; `consult--jump-preview'. - `((,#'consult-buffer-other-frame :preview-key nil) - (,#'consult-buffer-other-tab :preview-key nil)) - "Command configuration alist for fine-grained configuration. - -Each element of the list must have the form (command-name plist...). The -options set here will be evaluated and passed to `consult--read', when -called from the corresponding command. Note that the options depend on -the private `consult--read' API and should not be considered as stable -as the public API.") - -(defvar consult--buffer-display #'switch-to-buffer - "Buffer display function.") - -(defvar consult--completion-candidate-hook - (list #'consult--default-completion-minibuffer-candidate - #'consult--default-completion-list-candidate) - "Get candidate from completion system.") - -(defvar consult--completion-refresh-hook nil - "Refresh completion system.") - -(defvar-local consult--preview-function nil - "Minibuffer-local variable which exposes the current preview function. -This function can be called by custom completion systems from -outside the minibuffer.") - -(defvar consult--annotate-align-step 10 - "Round candidate width.") - -(defvar consult--annotate-align-width 0 - "Maximum candidate width used for annotation alignment.") - -(defconst consult--tofu-char #x200000 - "Special character used to encode line prefixes for disambiguation. -We use invalid characters outside the Unicode range.") - -(defconst consult--tofu-range #x100000 - "Special character range.") - -(defvar-local consult--narrow nil - "Current narrowing key.") - -(defvar-local consult--narrow-keys nil - "Narrowing prefixes of the current completion.") - -(defvar-local consult--narrow-predicate nil - "Narrowing predicate of the current completion.") - -(defvar-local consult--narrow-overlay nil - "Narrowing indicator overlay.") - -(defvar consult--gc-threshold (* 64 1024 1024) - "Large GC threshold for temporary increase.") - -(defvar consult--gc-percentage 0.5 - "Large GC percentage for temporary increase.") - -(defvar consult--process-chunk (* 1024 1024) - "Increase process output chunk size.") - -(defvar consult--async-log - " *consult-async*" - "Buffer for async logging output used by `consult--async-process'.") - -(defvar-local consult--focus-lines-overlays nil - "Overlays used by `consult-focus-lines'.") - -(defvar-local consult--org-fold-regions nil - "Stored regions for the org-fold API.") - -;;;; Miscellaneous helper functions - -(defun consult--key-parse (key) - "Parse KEY or signal error if invalid." - (unless (key-valid-p key) - (error "%S is not a valid key definition; see `key-valid-p'" key)) - (key-parse key)) - -(defun consult--in-buffer (fun &optional buffer) - "Ensure that FUN is executed inside BUFFER." - (unless buffer (setq buffer (current-buffer))) - (lambda (&rest args) - (with-current-buffer buffer - (apply fun args)))) - -(defun consult--completion-table-in-buffer (table &optional buffer) - "Ensure that completion TABLE is executed inside BUFFER." - (if (functionp table) - (consult--in-buffer - (lambda (str pred action) - (let ((result (funcall table str pred action))) - (pcase action - ('metadata - (setq result - (mapcar - (lambda (x) - (if (and (string-suffix-p "-function" (symbol-name (car-safe x))) (cdr x)) - (cons (car x) (consult--in-buffer (cdr x))) - x)) - result))) - ((and 'completion--unquote (guard (functionp (cadr result)))) - (cl-callf consult--in-buffer (cadr result) buffer) - (cl-callf consult--in-buffer (cadddr result) buffer))) - result)) - buffer) - table)) - -(defun consult--build-args (arg) - "Return ARG as a flat list of split strings. - -Turn ARG into a list, and for each element either: -- split it if it a string. -- eval it if it is an expression." - (seq-mapcat (lambda (x) - (if (stringp x) - (split-string-and-unquote x) - (ensure-list (eval x 'lexical)))) - (ensure-list arg))) - -(defun consult--command-split (str) - "Return command argument and options list given input STR." - (save-match-data - (let ((opts (when (string-match " +--\\( +\\|\\'\\)" str) - (prog1 (substring str (match-end 0)) - (setq str (substring str 0 (match-beginning 0))))))) - ;; split-string-and-unquote fails if the quotes are invalid. Ignore it. - (cons str (and opts (ignore-errors (split-string-and-unquote opts))))))) - -(defmacro consult--keep! (list form) - "Evaluate FORM for every element of LIST and keep the non-nil results." - (declare (indent 1)) - (cl-with-gensyms (head prev result) - `(let* ((,head (cons nil ,list)) - (,prev ,head)) - (while (cdr ,prev) - (if-let (,result (let ((it (cadr ,prev))) ,form)) - (progn - (pop ,prev) - (setcar ,prev ,result)) - (setcdr ,prev (cddr ,prev)))) - (setq ,list (cdr ,head)) - nil))) - -;; Upstream bug#46326, Consult issue gh:minad/consult#193. -(defmacro consult--minibuffer-with-setup-hook (fun &rest body) - "Variant of `minibuffer-with-setup-hook' using a symbol and `fset'. - -This macro is only needed to prevent memory leaking issues with -the upstream `minibuffer-with-setup-hook' macro. -FUN is the hook function and BODY opens the minibuffer." - (declare (indent 1) (debug t)) - (let ((hook (gensym "hook")) - (append)) - (when (eq (car-safe fun) :append) - (setq append '(t) fun (cadr fun))) - `(let ((,hook (make-symbol "consult--minibuffer-setup-hook"))) - (fset ,hook (lambda () - (remove-hook 'minibuffer-setup-hook ,hook) - (funcall ,fun))) - (unwind-protect - (progn - (add-hook 'minibuffer-setup-hook ,hook ,@append) - ,@body) - (remove-hook 'minibuffer-setup-hook ,hook))))) - -(defun consult--completion-filter (pattern cands category _highlight) - "Filter CANDS with PATTERN. - -CATEGORY is the completion category, used to find the completion style via -`completion-category-defaults' and `completion-category-overrides'. -HIGHLIGHT must be non-nil if the resulting strings should be highlighted." - ;; completion-all-completions returns an improper list - ;; where the last link is not necessarily nil. - (nconc (completion-all-completions pattern cands nil (length pattern) - `(metadata (category . ,category))) - nil)) - -(defun consult--completion-filter-complement (pattern cands category _highlight) - "Filter CANDS with complement of PATTERN. -See `consult--completion-filter' for the arguments CATEGORY and HIGHLIGHT." - (let ((ht (consult--string-hash (consult--completion-filter pattern cands category nil)))) - (seq-remove (lambda (x) (gethash x ht)) cands))) - -(defun consult--completion-filter-dispatch (pattern cands category highlight) - "Filter CANDS with PATTERN with optional complement. -Either using `consult--completion-filter' or -`consult--completion-filter-complement', depending on if the pattern starts -with a bang. See `consult--completion-filter' for the arguments CATEGORY and -HIGHLIGHT." - (cond - ((string-match-p "\\`!? ?\\'" pattern) cands) ;; empty pattern - ((string-prefix-p "! " pattern) (consult--completion-filter-complement - (substring pattern 2) cands category nil)) - (t (consult--completion-filter pattern cands category highlight)))) - -(defmacro consult--each-line (beg end &rest body) - "Iterate over each line. - -The line beginning/ending BEG/END is bound in BODY." - (declare (indent 2)) - (cl-with-gensyms (max) - `(save-excursion - (let ((,beg (point-min)) (,max (point-max)) ,end) - (while (< ,beg ,max) - (goto-char ,beg) - (setq ,end (pos-eol)) - ,@body - (setq ,beg (1+ ,end))))))) - -(defun consult--display-width (string) - "Compute width of STRING taking display and invisible properties into account." - (let ((pos 0) (width 0) (end (length string))) - (while (< pos end) - (let ((nextd (next-single-property-change pos 'display string end)) - (display (get-text-property pos 'display string))) - (if (stringp display) - (setq width (+ width (string-width display)) - pos nextd) - (while (< pos nextd) - (let ((nexti (next-single-property-change pos 'invisible string nextd))) - (unless (get-text-property pos 'invisible string) - (setq width (+ width (compat-call string-width string pos nexti)))) - (setq pos nexti)))))) - width)) - -(defun consult--string-hash (strings) - "Create hash table from STRINGS." - (let ((ht (make-hash-table :test #'equal :size (length strings)))) - (dolist (str strings) - (puthash str t ht)) - ht)) - -(defmacro consult--local-let (binds &rest body) - "Buffer local let BINDS of dynamic variables in BODY." - (declare (indent 1)) - (let ((buffer (gensym "buffer")) - (local (mapcar (lambda (x) (cons (gensym "local") (car x))) binds))) - `(let ((,buffer (current-buffer)) - ,@(mapcar (lambda (x) `(,(car x) (local-variable-p ',(cdr x)))) local)) - (unwind-protect - (progn - ,@(mapcar (lambda (x) `(make-local-variable ',(car x))) binds) - (let (,@binds) - ,@body)) - (when (buffer-live-p ,buffer) - (with-current-buffer ,buffer - ,@(mapcar (lambda (x) - `(unless ,(car x) - (kill-local-variable ',(cdr x)))) - local))))))) - -(defvar consult--fast-abbreviate-file-name nil) -(defun consult--fast-abbreviate-file-name (name) - "Return abbreviate file NAME. -This function is a pure variant of `abbreviate-file-name', which -does not access the file system. This is important if we require -that the operation is fast, even for remote paths or paths on -network file systems." - (save-match-data - (let (case-fold-search) ;; Assume that file system is case sensitive. - (setq name (directory-abbrev-apply name)) - (if (string-match (with-memoization consult--fast-abbreviate-file-name - (directory-abbrev-make-regexp (expand-file-name "~"))) - name) - (concat "~" (substring name (match-beginning 1))) - name)))) - -(defun consult--left-truncate-file (file) - "Return abbreviated file name of FILE for use in `completing-read' prompt." - (save-match-data - (let ((afile (abbreviate-file-name file))) - (if (string-match "/\\([^/]+\\)/\\([^/]+/?\\)\\'" afile) - (propertize (format "…/%s/%s" (match-string 1 afile) (match-string 2 afile)) - 'help-echo afile) - afile)))) - -(defun consult--directory-prompt (prompt dir) - "Return prompt, paths and default directory. - -PROMPT is the prompt prefix. The directory is appended to the -prompt prefix. For projects only the project name is shown. The -`default-directory' is not shown. Other directories are -abbreviated and only the last two path components are shown. - -If DIR is a string, it is returned as default directory. If DIR -is a list of strings, the list is returned as search paths. If -DIR is nil the `consult-project-function' is tried to retrieve -the default directory. If no project is found the -`default-directory' is returned as is. Otherwise the user is -asked for the directories or files to search via -`completing-read-multiple'." - (let* ((paths nil) - (dir - (pcase dir - ((pred stringp) dir) - ('nil (or (consult--project-root) default-directory)) - (_ - (pcase (if (stringp (car-safe dir)) - dir - ;; Preserve this-command across `completing-read-multiple' call, - ;; such that `consult-customize' continues to work. - (let ((this-command this-command) - (def (abbreviate-file-name default-directory)) - ;; TODO: `minibuffer-completing-file-name' is - ;; mostly deprecated, but still in use. Packages - ;; should instead use the completion metadata. - (minibuffer-completing-file-name t) - (ignore-case read-file-name-completion-ignore-case)) - (consult--minibuffer-with-setup-hook - (lambda () - (setq-local completion-ignore-case ignore-case) - (set-syntax-table minibuffer-local-filename-syntax)) - (completing-read-multiple "Directories or files: " - #'completion-file-name-table - nil t def 'consult--path-history def)))) - ((and `(,p) (guard (file-directory-p p))) p) - (ps (setq paths (mapcar (lambda (p) - (file-relative-name (expand-file-name p))) - ps)) - default-directory))))) - (edir (file-name-as-directory (expand-file-name dir))) - (pdir (let ((default-directory edir)) - ;; Bind default-directory in order to find the project - (consult--project-root)))) - (list - (format "%s (%s): " prompt - (pcase paths - (`(,p) (consult--left-truncate-file p)) - (`(,p . ,_) - (format "%d paths, %s, …" (length paths) (consult--left-truncate-file p))) - ((guard (equal edir pdir)) (concat "Project " (consult--project-name pdir))) - (_ (consult--left-truncate-file edir)))) - (or paths '(".")) - edir))) - -(defun consult--default-project-function (may-prompt) - "Return project root directory. -When no project is found and MAY-PROMPT is non-nil ask the user." - (when-let (proj (project-current may-prompt)) - (cond - ((fboundp 'project-root) (project-root proj)) - ((fboundp 'project-roots) (car (project-roots proj)))))) - -(defun consult--project-root (&optional may-prompt) - "Return project root as absolute path. -When no project is found and MAY-PROMPT is non-nil ask the user." - ;; Preserve this-command across project selection, - ;; such that `consult-customize' continues to work. - (let ((this-command this-command)) - (when-let (root (and consult-project-function - (funcall consult-project-function may-prompt))) - (expand-file-name root)))) - -(defun consult--project-name (dir) - "Return the project name for DIR." - (if (string-match "/\\([^/]+\\)/\\'" dir) - (propertize (match-string 1 dir) 'help-echo (abbreviate-file-name dir)) - dir)) - -(defun consult--format-file-line-match (file line match) - "Format string FILE:LINE:MATCH with faces." - (setq line (number-to-string line) - match (concat file ":" line ":" match) - file (length file)) - (put-text-property 0 file 'face 'consult-file match) - (put-text-property (1+ file) (+ 1 file (length line)) 'face 'consult-line-number match) - match) - -(defun consult--make-overlay (beg end &rest props) - "Make consult overlay between BEG and END with PROPS." - (let ((ov (make-overlay beg end))) - (while props - (overlay-put ov (car props) (cadr props)) - (setq props (cddr props))) - ov)) - -(defun consult--remove-dups (list) - "Remove duplicate strings from LIST." - (delete-dups (copy-sequence list))) - -(defsubst consult--in-range-p (pos) - "Return t if position POS lies in range `point-min' to `point-max'." - (<= (point-min) pos (point-max))) - -(defun consult--completion-window-p () - "Return non-nil if the selected window belongs to the completion UI." - (or (eq (selected-window) (active-minibuffer-window)) - (eq #'completion-list-mode (buffer-local-value 'major-mode (window-buffer))))) - -(defun consult--original-window () - "Return window which was just selected just before the minibuffer was entered. -In contrast to `minibuffer-selected-window' never return nil and -always return an appropriate non-minibuffer window." - (or (minibuffer-selected-window) - (if (window-minibuffer-p (selected-window)) - (next-window) - (selected-window)))) - -(defun consult--forbid-minibuffer () - "Raise an error if executed from the minibuffer." - (when (minibufferp) - (user-error "`%s' called inside the minibuffer" this-command))) - -(defun consult--require-minibuffer () - "Raise an error if executed outside the minibuffer." - (unless (minibufferp) - (user-error "`%s' must be called inside the minibuffer" this-command))) - -(defun consult--fontify-all () - "Ensure that the whole buffer is fontified." - ;; Font-locking is lazy, i.e., if a line has not been looked at yet, the line - ;; is not font-locked. We would observe this if consulting an unfontified - ;; line. Therefore we have to enforce font-locking now, which is slow. In - ;; order to prevent is hang-up we check the buffer size against - ;; `consult-fontify-max-size'. - (when (and consult-fontify-preserve jit-lock-mode - (< (buffer-size) consult-fontify-max-size)) - (jit-lock-fontify-now))) - -(defun consult--fontify-region (start end) - "Ensure that region between START and END is fontified." - (when (and consult-fontify-preserve jit-lock-mode) - (jit-lock-fontify-now start end))) - -(defmacro consult--with-increased-gc (&rest body) - "Temporarily increase the GC limit in BODY to optimize for throughput." - (cl-with-gensyms (overwrite) - `(let* ((,overwrite (> consult--gc-threshold gc-cons-threshold)) - (gc-cons-threshold (if ,overwrite consult--gc-threshold gc-cons-threshold)) - (gc-cons-percentage (if ,overwrite consult--gc-percentage gc-cons-percentage))) - ,@body))) - -(defmacro consult--slow-operation (message &rest body) - "Show delayed MESSAGE if BODY takes too long. -Also temporarily increase the GC limit via `consult--with-increased-gc'." - (declare (indent 1)) - `(let (set-message-function) ;; bug#63253: Broken `with-delayed-message' - (with-delayed-message (1 ,message) - (consult--with-increased-gc - ,@body)))) - -(defun consult--count-lines (pos) - "Move to position POS and return number of lines." - (let ((line 1)) - (while (< (point) pos) - (forward-line) - (when (<= (point) pos) - (cl-incf line))) - (goto-char pos) - line)) - -(defun consult--marker-from-line-column (buffer line column) - "Get marker in BUFFER from LINE and COLUMN." - (when (buffer-live-p buffer) - (with-current-buffer buffer - (save-excursion - (without-restriction - (goto-char (point-min)) - ;; Location data might be invalid by now! - (ignore-errors - (forward-line (1- line)) - (goto-char (min (+ (point) column) (pos-eol)))) - (point-marker)))))) - -(defun consult--line-prefix (&optional curr-line) - "Annotate `consult-location' candidates with line numbers. -CURR-LINE is the current line number." - (setq curr-line (or curr-line -1)) - (let* ((width (length (number-to-string (line-number-at-pos - (point-max) - consult-line-numbers-widen)))) - (before (format #("%%%dd " 0 6 (face consult-line-number-wrapped)) width)) - (after (format #("%%%dd " 0 6 (face consult-line-number-prefix)) width))) - (lambda (cand) - (let ((line (cdr (get-text-property 0 'consult-location cand)))) - (list cand (format (if (< line curr-line) before after) line) ""))))) - -(defsubst consult--location-candidate (cand marker line tofu &rest props) - "Add MARKER and LINE as `consult-location' text property to CAND. -Furthermore add the additional text properties PROPS, and append -TOFU suffix for disambiguation." - (setq cand (concat cand (consult--tofu-encode tofu))) - (add-text-properties 0 1 `(consult-location (,marker . ,line) ,@props) cand) - cand) - -;; There is a similar variable `yank-excluded-properties'. Unfortunately -;; we cannot use it here since it excludes too much (e.g., invisible) -;; and at the same time not enough (e.g., cursor-sensor-functions). -(defconst consult--remove-text-properties - '(category cursor cursor-intangible cursor-sensor-functions field follow-link - fontified front-sticky help-echo insert-behind-hooks insert-in-front-hooks - intangible keymap local-map modification-hooks mouse-face pointer read-only - rear-nonsticky yank-handler) - "List of text properties to remove from buffer strings.") - -(defsubst consult--buffer-substring (beg end &optional fontify) - "Return buffer substring between BEG and END. -If FONTIFY and `consult-fontify-preserve' are non-nil, first ensure that the -region has been fontified." - (if consult-fontify-preserve - (let (str) - (when fontify (consult--fontify-region beg end)) - (setq str (buffer-substring beg end)) - ;; TODO Propose the upstream addition of a function - ;; `preserve-list-of-text-properties', which should be as efficient as - ;; `remove-list-of-text-properties'. - (remove-list-of-text-properties - 0 (- end beg) consult--remove-text-properties str) - str) - (buffer-substring-no-properties beg end))) - -(defun consult--line-with-mark (marker) - "Current line string where the MARKER position is highlighted." - (let* ((beg (pos-bol)) - (end (pos-eol)) - (str (consult--buffer-substring beg end 'fontify))) - (if (>= marker end) - (concat str #(" " 0 1 (face consult-highlight-mark))) - (put-text-property (- marker beg) (- (1+ marker) beg) - 'face 'consult-highlight-mark str) - str))) - -;;;; Tofu cooks - -(defsubst consult--tofu-p (char) - "Return non-nil if CHAR is a tofu." - (<= consult--tofu-char char (+ consult--tofu-char consult--tofu-range -1))) - -(defun consult--tofu-hide (str) - "Hide the tofus in STR." - (let* ((max (length str)) - (end max)) - (while (and (> end 0) (consult--tofu-p (aref str (1- end)))) - (cl-decf end)) - (when (< end max) - (setq str (copy-sequence str)) - (put-text-property end max 'invisible t str)) - str)) - -(defsubst consult--tofu-append (cand id) - "Append tofu-encoded ID to CAND. -The ID must fit within a single character. It must be smaller -than `consult--tofu-range'." - (setq id (char-to-string (+ consult--tofu-char id))) - (add-text-properties 0 1 '(invisible t consult-strip t) id) - (concat cand id)) - -(defsubst consult--tofu-get (cand) - "Extract tofu-encoded ID from CAND. -See `consult--tofu-append'." - (- (aref cand (1- (length cand))) consult--tofu-char)) - -;; We must disambiguate the lines by adding a prefix such that two lines with -;; the same text can be distinguished. In order to avoid matching the line -;; number, such that the user can search for numbers with `consult-line', we -;; encode the line number as characters outside the Unicode range. By doing -;; that, no accidental matching can occur. -(defun consult--tofu-encode (n) - "Return tofu-encoded number N as a string. -Large numbers are encoded as multiple tofu characters." - (let (str tofu) - (while (progn - (setq tofu (char-to-string - (+ consult--tofu-char (% n consult--tofu-range))) - str (if str (concat tofu str) tofu)) - (and (>= n consult--tofu-range) - (setq n (/ n consult--tofu-range))))) - (add-text-properties 0 (length str) '(invisible t consult-strip t) str) - str)) - -;;;; Regexp utilities - -(defun consult--find-highlights (str start &rest ignored-faces) - "Find highlighted regions in STR from position START. -Highlighted regions have a non-nil face property. -IGNORED-FACES are ignored when searching for matches." - (let (highlights - (end (length str)) - (beg start)) - (while (< beg end) - (let ((next (next-single-property-change beg 'face str end)) - (val (get-text-property beg 'face str))) - (when (and val - (not (memq val ignored-faces)) - (not (and (consp val) - (seq-some (lambda (x) (memq x ignored-faces)) val)))) - (push (cons (- beg start) (- next start)) highlights)) - (setq beg next))) - (nreverse highlights))) - -(defun consult--point-placement (str start &rest ignored-faces) - "Compute point placement from STR with START offset. -IGNORED-FACES are ignored when searching for matches. -Return cons of point position and a list of match begin/end pairs." - (let* ((matches (apply #'consult--find-highlights str start ignored-faces)) - (pos (pcase-exhaustive consult-point-placement - ('match-beginning (or (caar matches) 0)) - ('match-end (or (cdar (last matches)) 0)) - ('line-beginning 0)))) - (dolist (match matches) - (cl-decf (car match) pos) - (cl-decf (cdr match) pos)) - (cons pos matches))) - -(defun consult--highlight-regexps (regexps ignore-case str) - "Highlight REGEXPS in STR. -If a regular expression contains capturing groups, only these are highlighted. -If no capturing groups are used highlight the whole match. Case is ignored -if IGNORE-CASE is non-nil." - (dolist (re regexps) - (let ((i 0)) - (while (and (let ((case-fold-search ignore-case)) - (string-match re str i)) - ;; Ensure that regexp search made progress (edge case for .*) - (> (match-end 0) i)) - ;; Unfortunately there is no way to avoid the allocation of the match - ;; data, since the number of capturing groups is unknown. - (let ((m (match-data))) - (setq i (cadr m) m (or (cddr m) m)) - (while m - (when (car m) - (add-face-text-property (car m) (cadr m) - 'consult-highlight-match nil str)) - (setq m (cddr m))))))) - str) - -(defconst consult--convert-regexp-table - (append - ;; For simplicity, treat word beginning/end as word boundaries, - ;; since PCRE does not make this distinction. Usually the - ;; context determines if \b is the beginning or the end. - '(("\\<" . "\\b") ("\\>" . "\\b") - ("\\_<" . "\\b") ("\\_>" . "\\b")) - ;; Treat \` and \' as beginning and end of line. This is more - ;; widely supported and makes sense for line-based commands. - '(("\\`" . "^") ("\\'" . "$")) - ;; Historical: Unescaped *, +, ? are supported at the beginning - (mapcan (lambda (x) - (mapcar (lambda (y) - (cons (concat x y) - (concat (string-remove-prefix "\\" x) "\\" y))) - '("*" "+" "?"))) - '("" "\\(" "\\(?:" "\\|" "^")) - ;; Different escaping - (mapcan (lambda (x) `(,x (,(cdr x) . ,(car x)))) - '(("\\|" . "|") - ("\\(" . "(") ("\\)" . ")") - ("\\{" . "{") ("\\}" . "}")))) - "Regexp conversion table.") - -(defun consult--convert-regexp (regexp type) - "Convert Emacs REGEXP to regexp syntax TYPE." - (if (memq type '(emacs basic)) - regexp - ;; Support for Emacs regular expressions is fairly complete for basic - ;; usage. There are a few unsupported Emacs regexp features: - ;; - \= point matching - ;; - Syntax classes \sx \Sx - ;; - Character classes \cx \Cx - ;; - Explicitly numbered groups (?3:group) - (replace-regexp-in-string - (rx (or "\\\\" "\\^" ;; Pass through - (seq (or "\\(?:" "\\|") (any "*+?")) ;; Historical: \|+ or \(?:* etc - (seq "\\(" (any "*+")) ;; Historical: \(* or \(+ - (seq (or bos "^") (any "*+?")) ;; Historical: + or * at the beginning - (seq (opt "\\") (any "(){|}")) ;; Escape parens/braces/pipe - (seq "\\" (any "'<>`")) ;; Special escapes - (seq "\\_" (any "<>")))) ;; Beginning or end of symbol - (lambda (x) (or (cdr (assoc x consult--convert-regexp-table)) x)) - regexp 'fixedcase 'literal))) - -(defun consult--default-regexp-compiler (input type ignore-case) - "Compile the INPUT string to a list of regular expressions. -The function should return a pair, the list of regular expressions and a -highlight function. The highlight function should take a single -argument, the string to highlight given the INPUT. TYPE is the desired -type of regular expression, which can be `basic', `extended', `emacs' or -`pcre'. If IGNORE-CASE is non-nil return a highlight function which -matches case insensitively." - (setq input (consult--split-escaped input)) - (cons (mapcar (lambda (x) (consult--convert-regexp x type)) input) - (when-let (regexps (seq-filter #'consult--valid-regexp-p input)) - (apply-partially #'consult--highlight-regexps regexps ignore-case)))) - -(defun consult--split-escaped (str) - "Split STR at spaces, which can be escaped with backslash." - (mapcar - (lambda (x) (string-replace "\0" " " x)) - (split-string (replace-regexp-in-string - "\\\\\\\\\\|\\\\ " - (lambda (x) (if (equal x "\\ ") "\0" x)) - str 'fixedcase 'literal) - " +" t))) - -(defun consult--join-regexps (regexps type) - "Join REGEXPS of TYPE." - ;; Add look-ahead wrapper only if there is more than one regular expression - (cond - ((and (eq type 'pcre) (cdr regexps)) - (concat "^" (mapconcat (lambda (x) (format "(?=.*%s)" x)) - regexps ""))) - ((eq type 'basic) - (string-join regexps ".*")) - (t - (when (length> regexps 3) - (message "Too many regexps, %S ignored. Use post-filtering!" - (string-join (seq-drop regexps 3) " ")) - (setq regexps (seq-take regexps 3))) - (consult--join-regexps-permutations regexps (and (eq type 'emacs) "\\"))))) - -(defun consult--join-regexps-permutations (regexps esc) - "Join all permutations of REGEXPS. -ESC is the escaping string for choice and groups." - (pcase regexps - ('nil "") - (`(,r) r) - (_ (mapconcat - (lambda (r) - (concat esc "(" r esc ").*" esc "(" - (consult--join-regexps-permutations (remove r regexps) esc) - esc ")")) - regexps (concat esc "|"))))) - -(defun consult--valid-regexp-p (re) - "Return t if regexp RE is valid." - (condition-case nil - (progn (string-match-p re "") t) - (invalid-regexp nil))) - -(defun consult--regexp-filter (regexps) - "Create filter regexp from REGEXPS." - (if (stringp regexps) - regexps - (mapconcat (lambda (x) (concat "\\(?:" x "\\)")) regexps "\\|"))) - -;;;; Lookup functions - -(defun consult--lookup-member (selected candidates &rest _) - "Lookup SELECTED in CANDIDATES list, return original element." - (car (member selected candidates))) - -(defun consult--lookup-cons (selected candidates &rest _) - "Lookup SELECTED in CANDIDATES alist, return cons." - (assoc selected candidates)) - -(defun consult--lookup-cdr (selected candidates &rest _) - "Lookup SELECTED in CANDIDATES alist, return `cdr' of element." - (cdr (assoc selected candidates))) - -(defun consult--lookup-location (selected candidates &rest _) - "Lookup SELECTED in CANDIDATES list of `consult-location' category. -Return the location marker." - (when-let (found (member selected candidates)) - (setq found (car (consult--get-location (car found)))) - ;; Check that marker is alive - (and (or (not (markerp found)) (marker-buffer found)) found))) - -(defun consult--lookup-prop (prop selected candidates &rest _) - "Lookup SELECTED in CANDIDATES list and return PROP value." - (when-let (found (member selected candidates)) - (get-text-property 0 prop (car found)))) - -(defun consult--lookup-candidate (selected candidates &rest _) - "Lookup SELECTED in CANDIDATES list and return property `consult--candidate'." - (consult--lookup-prop 'consult--candidate selected candidates)) - -;;;; Preview support - -(defun consult--preview-allowed-p (fun) - "Return non-nil if FUN is an allowed preview mode hook." - (or (memq fun consult-preview-allowed-hooks) - (when-let (((symbolp fun)) - (name (symbol-name fun)) - ;; Global modes in Emacs 29 are activated via a - ;; `find-file-hook' ending with `-check-buffers'. This has been - ;; changed in Emacs 30. Now a `change-major-mode-hook' is used - ;; instead with the suffix `-check-buffers'. - (suffix (if (eval-when-compile (>= emacs-major-version 30)) - "-enable-in-buffer" - "-check-buffers")) - ((string-suffix-p suffix name))) - (memq (intern (string-remove-suffix suffix name)) - consult-preview-allowed-hooks)))) - -(defun consult--filter-find-file-hook (orig &rest hooks) - "Filter `find-file-hook' by `consult-preview-allowed-hooks'. -This function is an advice for `run-hooks'. -ORIG is the original function, HOOKS the arguments." - (if (memq 'find-file-hook hooks) - (cl-letf* (((default-value 'find-file-hook) - (seq-filter #'consult--preview-allowed-p - (default-value 'find-file-hook))) - (find-file-hook (default-value 'find-file-hook))) - (apply orig hooks)) - (apply orig hooks))) - -(defun consult--find-file-temporarily-1 (name) - "Open file NAME, helper function for `consult--find-file-temporarily'." - (when-let (((not (seq-find (lambda (x) (string-match-p x name)) - consult-preview-excluded-files))) - ;; file-attributes may throw permission denied error - (attrs (ignore-errors (file-attributes name))) - (size (file-attribute-size attrs))) - (let* ((partial (>= size consult-preview-partial-size)) - (buffer (if partial - (generate-new-buffer (format "consult-partial-preview-%s" name)) - (find-file-noselect name 'nowarn))) - (success nil)) - (unwind-protect - (with-current-buffer buffer - (if (not partial) - (when (or (eq major-mode 'hexl-mode) - (and (eq major-mode 'fundamental-mode) - (save-excursion (search-forward "\0" nil 'noerror)))) - (error "No preview of binary file `%s'" - (file-name-nondirectory name))) - (with-silent-modifications - (setq buffer-read-only t) - (insert-file-contents name nil 0 consult-preview-partial-chunk) - (goto-char (point-max)) - (insert "\nFile truncated. End of partial preview.\n") - (goto-char (point-min))) - (when (save-excursion (search-forward "\0" nil 'noerror)) - (error "No partial preview of binary file `%s'" - (file-name-nondirectory name))) - ;; Auto detect major mode and hope for the best, given that the - ;; file is only previewed partially. If an error is thrown the - ;; buffer will be killed and preview is aborted. - (set-auto-mode) - (font-lock-mode 1)) - (when (bound-and-true-p so-long-detected-p) - (error "No preview of file `%s' with long lines" - (file-name-nondirectory name))) - ;; Run delayed hooks listed in `consult-preview-allowed-hooks'. - (dolist (hook (reverse (cons 'after-change-major-mode-hook delayed-mode-hooks))) - (run-hook-wrapped hook (lambda (fun) - (when (consult--preview-allowed-p fun) - (funcall fun)) - nil))) - (setq success (current-buffer))) - (unless success - (kill-buffer buffer)))))) - -(defun consult--find-file-temporarily (name) - "Open file NAME temporarily for preview." - (let ((vars (delq nil - (mapcar - (pcase-lambda (`(,k . ,v)) - (if (boundp k) - (list k v (default-value k) (symbol-value k)) - (message "consult-preview-variables: The variable `%s' is not bound" k) - nil)) - consult-preview-variables)))) - (condition-case err - (unwind-protect - (progn - (advice-add #'run-hooks :around #'consult--filter-find-file-hook) - (pcase-dolist (`(,k ,v . ,_) vars) - (set-default k v) - (set k v)) - (consult--find-file-temporarily-1 name)) - (advice-remove #'run-hooks #'consult--filter-find-file-hook) - (pcase-dolist (`(,k ,_ ,d ,v) vars) - (set-default k d) - (set k v))) - (error - (message "%s" (error-message-string err)) - nil)))) - -(defun consult--temporary-files () - "Return a function to open files temporarily for preview." - (let ((dir default-directory) - (hook (make-symbol "consult--temporary-files-upgrade-hook")) - (orig-buffers (buffer-list)) - temporary-buffers) - (fset hook - (lambda (_) - ;; Fully initialize previewed files and keep them alive. - (unless (consult--completion-window-p) - (let (live-files) - (pcase-dolist (`(,file . ,buf) temporary-buffers) - (when-let (wins (and (buffer-live-p buf) - (get-buffer-window-list buf))) - (push (cons file (mapcar - (lambda (win) - (cons win (window-state-get win t))) - wins)) - live-files))) - (pcase-dolist (`(,_ . ,buf) temporary-buffers) - (kill-buffer buf)) - (setq temporary-buffers nil) - (pcase-dolist (`(,file . ,wins) live-files) - (when-let (buf (consult--file-action file)) - (push buf orig-buffers) - (pcase-dolist (`(,win . ,state) wins) - (setf (car (alist-get 'buffer state)) buf) - (window-state-put state win)))))))) - (lambda (&optional name) - (if name - (let ((default-directory dir)) - (setq name (abbreviate-file-name (expand-file-name name))) - (or - ;; Find existing fully initialized buffer (non-previewed). We have - ;; to check for fully initialized buffer before accessing the - ;; previewed buffers, since `embark-act' can open a buffer which is - ;; currently previewed, such that we end up with two buffers for - ;; the same file - one previewed and only partially initialized and - ;; one fully initialized. In this case we prefer the fully - ;; initialized buffer. For directories `get-file-buffer' returns nil, - ;; therefore we have to special case Dired. - (if (and (fboundp 'dired-find-buffer-nocreate) (file-directory-p name)) - (dired-find-buffer-nocreate name) - (get-file-buffer name)) - ;; Find existing previewed buffer. Previewed buffers are not fully - ;; initialized (hooks are delayed) in order to ensure fast preview. - (cdr (assoc name temporary-buffers)) - ;; Finally, if no existing buffer has been found, open the file for - ;; preview. - (when-let (buf (consult--find-file-temporarily name)) - ;; Only add new buffer if not already in the list - (unless (or (rassq buf temporary-buffers) (memq buf orig-buffers)) - (add-hook 'window-selection-change-functions hook) - (push (cons name buf) temporary-buffers) - ;; Disassociate buffer from file by setting `buffer-file-name' - ;; and `dired-directory' to nil and rename the buffer. This - ;; lets us open an already previewed buffer with the Embark - ;; default action C-. RET. - (with-current-buffer buf - (rename-buffer - (format " Preview:%s" - (file-name-nondirectory (directory-file-name name))) - 'unique)) - ;; The buffer disassociation is delayed to avoid breaking modes - ;; like `pdf-view-mode' or `doc-view-mode' which rely on - ;; `buffer-file-name'. Executing (set-visited-file-name nil) - ;; early also prevents the major mode initialization. - (let ((hook (make-symbol "consult--temporary-files-disassociate-hook"))) - (fset hook (lambda () - (when (buffer-live-p buf) - (with-current-buffer buf - (remove-hook 'pre-command-hook hook) - (setq-local buffer-read-only t - dired-directory nil - buffer-file-name nil))))) - (add-hook 'pre-command-hook hook)) - ;; Only keep a few buffers alive - (while (length> temporary-buffers consult-preview-max-count) - (kill-buffer (cdar (last temporary-buffers))) - (setq temporary-buffers (nbutlast temporary-buffers)))) - buf))) - (remove-hook 'window-selection-change-functions hook) - (pcase-dolist (`(,_ . ,buf) temporary-buffers) - (kill-buffer buf)) - (setq temporary-buffers nil))))) - -(defun consult--invisible-open-permanently () - "Open overlays which hide the current line. -See `isearch-open-necessary-overlays' and `isearch-open-overlay-temporary'." - (if (and (derived-mode-p 'org-mode) (fboundp 'org-fold-show-set-visibility)) - ;; New Org 9.6 fold-core API - (let ((inhibit-redisplay t)) ;; HACK: Prevent flicker due to premature redisplay - (org-fold-show-set-visibility 'canonical)) - (dolist (ov (overlays-in (pos-bol) (pos-eol))) - (when-let (fun (overlay-get ov 'isearch-open-invisible)) - (when (invisible-p (overlay-get ov 'invisible)) - (funcall fun ov)))))) - -(defun consult--invisible-open-temporarily () - "Temporarily open overlays which hide the current line. -See `isearch-open-necessary-overlays' and `isearch-open-overlay-temporary'." - (if (and (derived-mode-p 'org-mode) - (fboundp 'org-fold-show-set-visibility) - (fboundp 'org-fold-core-get-regions) - (fboundp 'org-fold-core-region)) - ;; New Org 9.6 fold-core API - ;; TODO The provided Org API `org-fold-show-set-visibility' cannot be used - ;; efficiently. We obtain all regions in the whole buffer in order to - ;; restore them. A better show API would return all the applied - ;; modifications such that we can restore the ones which got modified. - (progn - (unless consult--org-fold-regions - (setq consult--org-fold-regions - (delq nil (org-fold-core-get-regions - :with-markers t :from (point-min) :to (point-max)))) - (when consult--org-fold-regions - (let ((hook (make-symbol "consult--invisible-open-temporarily-cleanup-hook")) - (buffer (current-buffer)) - (depth (recursion-depth))) - (fset hook - (lambda () - (when (= (recursion-depth) depth) - (remove-hook 'minibuffer-exit-hook hook) - (run-at-time - 0 nil - (lambda () - (when (buffer-live-p buffer) - (with-current-buffer buffer - (pcase-dolist (`(,beg ,end ,_) consult--org-fold-regions) - (when (markerp beg) (set-marker beg nil)) - (when (markerp end) (set-marker end nil))) - (kill-local-variable 'consult--org-fold-regions)))))))) - (add-hook 'minibuffer-exit-hook hook)))) - (let ((inhibit-redisplay t)) ;; HACK: Prevent flicker due to premature redisplay - (org-fold-show-set-visibility 'canonical)) - (list (lambda () - (pcase-dolist (`(,beg ,end ,spec) consult--org-fold-regions) - (org-fold-core-region beg end t spec))))) - (let (restore) - (dolist (ov (overlays-in (pos-bol) (pos-eol))) - (let ((inv (overlay-get ov 'invisible))) - (when (and (invisible-p inv) (overlay-get ov 'isearch-open-invisible)) - (push (if-let (fun (overlay-get ov 'isearch-open-invisible-temporary)) - (progn - (funcall fun ov nil) - (lambda () (funcall fun ov t))) - (overlay-put ov 'invisible nil) - (lambda () (overlay-put ov 'invisible inv))) - restore)))) - restore))) - -(defun consult--jump-ensure-buffer (pos) - "Ensure that buffer of marker POS is displayed, return t if successful." - (or (not (markerp pos)) - ;; Switch to buffer if it is not visible - (when-let ((buf (marker-buffer pos))) - (or (and (eq (current-buffer) buf) (eq (window-buffer) buf)) - (consult--buffer-action buf 'norecord) - t)))) - -(defun consult--jump (pos) - "Jump to POS. -First push current position to mark ring, then move to new -position and run `consult-after-jump-hook'." - (when pos - ;; Extract marker from list with with overlay positions, see `consult--line-match' - (when (consp pos) (setq pos (car pos))) - ;; When the marker is in the same buffer, record previous location - ;; such that the user can jump back quickly. - (when (or (not (markerp pos)) (eq (current-buffer) (marker-buffer pos))) - ;; push-mark mutates markers in the mark-ring and the mark-marker. - ;; Therefore we transform the marker to a number to be safe. - ;; We all love side effects! - (setq pos (+ pos 0)) - (push-mark (point) t)) - (when (consult--jump-ensure-buffer pos) - (unless (= (goto-char pos) (point)) ;; Widen if jump failed - (widen) - (goto-char pos)) - (consult--invisible-open-permanently) - (run-hooks 'consult-after-jump-hook))) - nil) - -(defun consult--jump-preview () - "The preview function used if selecting from a list of candidate positions. -The function can be used as the `:state' argument of `consult--read'." - (let (restore) - (lambda (action cand) - (when (eq action 'preview) - (mapc #'funcall restore) - (setq restore nil) - ;; TODO Better buffer preview support - ;; 1. Use consult--buffer-preview instead of consult--jump-ensure-buffer - ;; 2. Remove function consult--jump-ensure-buffer - ;; 3. Remove consult-buffer-other-* from consult-customize-alist - (when-let ((pos (or (car-safe cand) cand)) ;; Candidate can be previewed - ((consult--jump-ensure-buffer pos))) - (let ((saved-min (point-min-marker)) - (saved-max (point-max-marker)) - (saved-pos (point-marker))) - (set-marker-insertion-type saved-max t) ;; Grow when text is inserted - (push (lambda () - (when-let ((buf (marker-buffer saved-pos))) - (with-current-buffer buf - (narrow-to-region saved-min saved-max) - (goto-char saved-pos) - (set-marker saved-pos nil) - (set-marker saved-min nil) - (set-marker saved-max nil)))) - restore)) - (unless (= (goto-char pos) (point)) ;; Widen if jump failed - (widen) - (goto-char pos)) - (setq restore (nconc (consult--invisible-open-temporarily) restore)) - ;; Ensure that cursor is properly previewed (gh:minad/consult#764) - (unless (eq cursor-in-non-selected-windows 'box) - (let ((orig cursor-in-non-selected-windows) - (buf (current-buffer))) - (push - (if (local-variable-p 'cursor-in-non-selected-windows) - (lambda () - (when (buffer-live-p buf) - (with-current-buffer buf - (setq-local cursor-in-non-selected-windows orig)))) - (lambda () - (when (buffer-live-p buf) - (with-current-buffer buf - (kill-local-variable 'cursor-in-non-selected-windows))))) - restore) - (setq-local cursor-in-non-selected-windows 'box))) - ;; Match previews - (let ((overlays - (list (save-excursion - (let ((vbeg (progn (beginning-of-visual-line) (point))) - (vend (progn (end-of-visual-line) (point))) - (end (pos-eol))) - (consult--make-overlay vbeg (if (= vend end) (1+ end) vend) - 'face 'consult-preview-line - 'window (selected-window) - 'priority 1)))))) - (dolist (match (cdr-safe cand)) - (push (consult--make-overlay (+ (point) (car match)) - (+ (point) (cdr match)) - 'face 'consult-preview-match - 'window (selected-window) - 'priority 2) - overlays)) - (push (lambda () (mapc #'delete-overlay overlays)) restore)) - (run-hooks 'consult-after-jump-hook)))))) - -(defun consult--jump-state () - "The state function used if selecting from a list of candidate positions." - (consult--state-with-return (consult--jump-preview) #'consult--jump)) - -(defun consult--get-location (cand) - "Return location from CAND." - (let ((loc (get-text-property 0 'consult-location cand))) - (when (consp (car loc)) - ;; Transform cheap marker to real marker - (setcar loc (set-marker (make-marker) (cdar loc) (caar loc)))) - loc)) - -(defun consult--location-state (candidates) - "Location state function. -The cheap location markers from CANDIDATES are upgraded on window -selection change to full Emacs markers." - (let ((jump (consult--jump-state)) - (hook (make-symbol "consult--location-upgrade-hook"))) - (fset hook - (lambda (_) - (unless (consult--completion-window-p) - (remove-hook 'window-selection-change-functions hook) - (mapc #'consult--get-location - (if (functionp candidates) (funcall candidates) candidates))))) - (lambda (action cand) - (pcase action - ('setup (add-hook 'window-selection-change-functions hook)) - ('exit (remove-hook 'window-selection-change-functions hook))) - (funcall jump action cand)))) - -(defun consult--state-with-return (state return) - "Compose STATE function with RETURN function." - (lambda (action cand) - (funcall state action cand) - (when (and cand (eq action 'return)) - (funcall return cand)))) - -(defmacro consult--define-state (type) - "Define state function for TYPE." - `(defun ,(intern (format "consult--%s-state" type)) () - ,(format "State function for %ss with preview. -The result can be passed as :state argument to `consult--read'." type) - (consult--state-with-return (,(intern (format "consult--%s-preview" type))) - #',(intern (format "consult--%s-action" type))))) - -(defun consult--preview-key-normalize (preview-key) - "Normalize PREVIEW-KEY, return alist of keys and debounce times." - (let ((keys) - (debounce 0)) - (setq preview-key (ensure-list preview-key)) - (while preview-key - (if (eq (car preview-key) :debounce) - (setq debounce (cadr preview-key) - preview-key (cddr preview-key)) - (let ((key (car preview-key))) - (unless (eq key 'any) - (setq key (consult--key-parse key))) - (push (cons key debounce) keys)) - (pop preview-key))) - keys)) - -(defun consult--preview-key-debounce (preview-key cand) - "Return debounce value of PREVIEW-KEY given the current candidate CAND." - (when (and (consp preview-key) (memq :keys preview-key)) - (setq preview-key (funcall (plist-get preview-key :predicate) cand))) - (let ((map (make-sparse-keymap)) - (keys (this-single-command-keys)) - any) - (pcase-dolist (`(,k . ,d) (consult--preview-key-normalize preview-key)) - (if (eq k 'any) - (setq any d) - (define-key map k `(lambda () ,d)))) - (setq keys (lookup-key map keys)) - (if (functionp keys) (funcall keys) any))) - -(defun consult--preview-append-local-pch (fun) - "Append FUN to local `post-command-hook' list." - ;; Symbol indirection because of bug#46407. - (let ((hook (make-symbol "consult--preview-post-command-hook"))) - (fset hook fun) - ;; TODO Emacs 28 has a bug, where the hook--depth-alist is not cleaned up properly - ;; Do not use the broken add-hook here. - ;;(add-hook 'post-command-hook hook 'append 'local) - (setq-local post-command-hook - (append - (remove t post-command-hook) - (list hook) - (and (memq t post-command-hook) '(t)))))) - -(defun consult--with-preview-1 (preview-key state transform candidate save-input fun) - "Add preview support for FUN. -See `consult--with-preview' for the arguments -PREVIEW-KEY, STATE, TRANSFORM, CANDIDATE and SAVE-INPUT." - (let ((mb-input "") mb-narrow selected timer previewed) - (consult--minibuffer-with-setup-hook - (if (and state preview-key) - (lambda () - (let ((hook (make-symbol "consult--preview-minibuffer-exit-hook")) - (depth (recursion-depth))) - (fset hook - (lambda () - (when (= (recursion-depth) depth) - (remove-hook 'minibuffer-exit-hook hook) - (when timer - (cancel-timer timer) - (setq timer nil)) - (with-selected-window (consult--original-window) - ;; STEP 3: Reset preview - (when previewed - (funcall state 'preview nil)) - ;; STEP 4: Notify the preview function of the minibuffer exit - (funcall state 'exit nil))))) - (add-hook 'minibuffer-exit-hook hook)) - ;; STEP 1: Setup the preview function - (with-selected-window (consult--original-window) - (funcall state 'setup nil)) - (setq consult--preview-function - (lambda () - (when-let ((cand (funcall candidate))) - ;; Drop properties to prevent bugs regarding candidate - ;; lookup, which must handle candidates without - ;; properties. Otherwise the arguments passed to the - ;; lookup function are confusing, since during preview - ;; the candidate has properties but for the final lookup - ;; after completion it does not. - (setq cand (substring-no-properties cand)) - (with-selected-window (active-minibuffer-window) - (let ((input (minibuffer-contents-no-properties)) - (narrow consult--narrow) - (win (consult--original-window))) - (with-selected-window win - (when-let ((transformed (funcall transform narrow input cand)) - (debounce (consult--preview-key-debounce preview-key transformed))) - (when timer - (cancel-timer timer) - (setq timer nil)) - ;; The transformed candidate may have text - ;; properties, which change the preview display. - ;; This matters for example for `consult-grep', - ;; where the current candidate and input may - ;; stay equal, but the highlighting of the - ;; candidate changes while the candidates list - ;; is lagging a bit behind and updates - ;; asynchronously. - ;; - ;; In older Consult versions we instead compared - ;; the input without properties, since I worried - ;; that comparing the transformed candidates - ;; could be potentially expensive. However - ;; comparing the transformed candidates is more - ;; correct. The transformed candidate is the - ;; thing which is actually previewed. - (unless (equal-including-properties previewed transformed) - (if (> debounce 0) - (setq timer - (run-at-time - debounce nil - (lambda () - ;; Preview only when a completion - ;; window is selected and when - ;; the preview window is alive. - (when (and (consult--completion-window-p) - (window-live-p win)) - (with-selected-window win - ;; STEP 2: Preview candidate - (funcall state 'preview (setq previewed transformed))))))) - ;; STEP 2: Preview candidate - (funcall state 'preview (setq previewed transformed))))))))))) - (consult--preview-append-local-pch - (lambda () - (setq mb-input (minibuffer-contents-no-properties) - mb-narrow consult--narrow) - (funcall consult--preview-function)))) - (lambda () - (consult--preview-append-local-pch - (lambda () - (setq mb-input (minibuffer-contents-no-properties) - mb-narrow consult--narrow))))) - (unwind-protect - (setq selected (when-let (result (funcall fun)) - (when-let ((save-input) - (list (symbol-value save-input)) - ((equal (car list) result))) - (set save-input (cdr list))) - (funcall transform mb-narrow mb-input result))) - (when save-input - (add-to-history save-input mb-input)) - (when state - ;; STEP 5: The preview function should perform its final action - (funcall state 'return selected)))))) - -(defmacro consult--with-preview (preview-key state transform candidate save-input &rest body) - "Add preview support to BODY. - -STATE is the state function. -TRANSFORM is the transformation function. -CANDIDATE is the function returning the current candidate. -PREVIEW-KEY are the keys which triggers the preview. -SAVE-INPUT can be a history variable symbol to save the input. - -The state function takes two arguments, an action argument and the -selected candidate. The candidate argument can be nil if no candidate is -selected or if the selection was aborted. The function is called in -sequence with the following arguments: - - 1. \\='setup nil After entering the mb (minibuffer-setup-hook). -⎧ 2. \\='preview CAND/nil Preview candidate CAND or reset if CAND is nil. -⎪ \\='preview CAND/nil -⎪ \\='preview CAND/nil -⎪ ... -⎩ 3. \\='preview nil Reset preview. - 4. \\='exit nil Before exiting the mb (minibuffer-exit-hook). - 5. \\='return CAND/nil After leaving the mb, CAND has been selected. - -The state function is always executed with the original window selected, -see `consult--original-window'. The state function is called once in -the beginning of the minibuffer setup with the `setup' argument. This is -useful in order to perform certain setup operations which require that -the minibuffer is initialized. During completion candidates are -previewed. Then the function is called with the `preview' argument and a -candidate CAND or nil if no candidate is selected. Furthermore if nil is -passed for CAND, then the preview must be undone and the original state -must be restored. The call with the `exit' argument happens once at the -end of the completion process, just before exiting the minibuffer. The -minibuffer is still alive at that point. Both `setup' and `exit' are -only useful for setup and cleanup operations. They don't receive a -candidate as argument. After leaving the minibuffer, the selected -candidate or nil is passed to the state function with the action -argument `return'. At this point the state function can perform the -actual action on the candidate. The state function with the `return' -argument is the continuation of `consult--read'. Via `unwind-protect' it -is guaranteed, that if the `setup' action of a state function is -invoked, the state function will also be called with `exit' and -`return'." - (declare (indent 5)) - `(consult--with-preview-1 ,preview-key ,state ,transform ,candidate ,save-input (lambda () ,@body))) - -;;;; Narrowing and grouping - -(defun consult--prefix-group (cand transform) - "Return title for CAND or TRANSFORM the candidate. -The candidate must have a `consult--prefix-group' property." - (if transform - (substring cand (1+ (length (get-text-property 0 'consult--prefix-group cand)))) - (get-text-property 0 'consult--prefix-group cand))) - -(defun consult--type-group (types) - "Return group function for TYPES." - (lambda (cand transform) - (if transform cand - (alist-get (get-text-property 0 'consult--type cand) types)))) - -(defun consult--type-narrow (types) - "Return narrowing configuration from TYPES." - (list :predicate - (lambda (cand) (eq (get-text-property 0 'consult--type cand) consult--narrow)) - :keys types)) - -(defun consult--widen-key () - "Return widening key, if `consult-widen-key' is not set. -The default is twice the `consult-narrow-key'." - (cond - (consult-widen-key - (consult--key-parse consult-widen-key)) - (consult-narrow-key - (let ((key (consult--key-parse consult-narrow-key))) - (vconcat key key))))) - -(defun consult-narrow (key) - "Narrow current completion with KEY. - -This command is used internally by the narrowing system of `consult--read'." - (interactive - (list (unless (equal (this-single-command-keys) (consult--widen-key)) - last-command-event))) - (consult--require-minibuffer) - (setq consult--narrow key) - (when consult--narrow-predicate - (setq minibuffer-completion-predicate (and consult--narrow consult--narrow-predicate))) - (when consult--narrow-overlay - (delete-overlay consult--narrow-overlay)) - (when consult--narrow - (setq consult--narrow-overlay - (consult--make-overlay - (1- (minibuffer-prompt-end)) (minibuffer-prompt-end) - 'before-string - (propertize (format " [%s]" (alist-get consult--narrow - consult--narrow-keys)) - 'face 'consult-narrow-indicator)))) - (run-hooks 'consult--completion-refresh-hook)) - -(defconst consult--narrow-delete - `(menu-item - "" nil :filter - ,(lambda (&optional _) - (when (equal (minibuffer-contents-no-properties) "") - (lambda () - (interactive) - (consult-narrow nil)))))) - -(defconst consult--narrow-space - `(menu-item - "" nil :filter - ,(lambda (&optional _) - (let ((str (minibuffer-contents-no-properties))) - (when-let (pair (or (and (length= str 1) - (assoc (aref str 0) consult--narrow-keys)) - (and (equal str "") - (assoc ?\s consult--narrow-keys)))) - (lambda () - (interactive) - (delete-minibuffer-contents) - (consult-narrow (car pair)))))))) - -(defun consult-narrow-help () - "Print narrowing help as a `minibuffer-message'. - -This command can be bound to a key in `consult-narrow-map', -to make it available for commands with narrowing." - (interactive) - (consult--require-minibuffer) - (let ((minibuffer-message-timeout 1000000)) - (minibuffer-message - (mapconcat (lambda (x) - (concat - (propertize (key-description (list (car x))) 'face 'consult-key) - " " - (propertize (cdr x) 'face 'consult-help))) - consult--narrow-keys - " ")))) - -(defun consult--narrow-setup (settings map) - "Setup narrowing with SETTINGS and keymap MAP." - (if (memq :keys settings) - (setq consult--narrow-predicate (plist-get settings :predicate) - consult--narrow-keys (plist-get settings :keys)) - (setq consult--narrow-predicate nil - consult--narrow-keys settings)) - (when-let ((key consult-narrow-key)) - (setq key (consult--key-parse key)) - (dolist (pair consult--narrow-keys) - (define-key map (vconcat key (vector (car pair))) - (cons (cdr pair) #'consult-narrow)))) - (when-let ((widen (consult--widen-key))) - (define-key map widen (cons "All" #'consult-narrow))) - (when-let ((init (and (memq :keys settings) (plist-get settings :initial)))) - (consult-narrow init))) - -;; Emacs 28: hide in M-X -(put #'consult-narrow-help 'completion-predicate #'ignore) -(put #'consult-narrow 'completion-predicate #'ignore) - -;;;; Splitting completion style - -(defun consult--split-perl (str &optional _plist) - "Split input STR in async input and filtering part. - -The function returns a list with three elements: The async -string, the start position of the completion filter string and a -force flag. If the first character is a punctuation character it -determines the separator. Examples: \"/async/filter\", -\"#async#filter\"." - (if (string-match-p "^[[:punct:]]" str) - (save-match-data - (let ((q (regexp-quote (substring str 0 1)))) - (string-match (concat "^" q "\\([^" q "]*\\)\\(" q "\\)?") str) - `(,(match-string 1 str) - ,(match-end 0) - ;; Force update it two punctuation characters are entered. - ,(match-end 2) - ;; List of highlights - (0 . ,(match-beginning 1)) - ,@(and (match-end 2) `((,(match-beginning 2) . ,(match-end 2))))))) - `(,str ,(length str)))) - -(defun consult--split-nil (str &optional _plist) - "Treat the complete input STR as async input." - `(,str ,(length str))) - -(defun consult--split-separator (str plist) - "Split input STR in async input and filtering part at first separator. -PLIST is the splitter configuration, including the separator." - (let ((sep (regexp-quote (char-to-string (plist-get plist :separator))))) - (save-match-data - (if (string-match (format "^\\([^%s]+\\)\\(%s\\)?" sep sep) str) - `(,(match-string 1 str) - ,(match-end 0) - ;; Force update it space is entered. - ,(match-end 2) - ;; List of highlights - ,@(and (match-end 2) `((,(match-beginning 2) . ,(match-end 2))))) - `(,str ,(length str)))))) - -(defun consult--split-setup (split) - "Setup splitting completion style with splitter function SPLIT." - (let* ((styles completion-styles) - (catdef completion-category-defaults) - (catovr completion-category-overrides) - (try (lambda (str table pred point) - (let ((completion-styles styles) - (completion-category-defaults catdef) - (completion-category-overrides catovr) - (pos (cadr (funcall split str)))) - (pcase (completion-try-completion (substring str pos) table pred - (max 0 (- point pos))) - ('t t) - (`(,newstr . ,newpt) - (cons (concat (substring str 0 pos) newstr) - (+ pos newpt))))))) - (all (lambda (str table pred point) - (let ((completion-styles styles) - (completion-category-defaults catdef) - (completion-category-overrides catovr) - (pos (cadr (funcall split str)))) - (completion-all-completions (substring str pos) table pred - (max 0 (- point pos))))))) - (setq-local completion-styles-alist (cons `(consult--split ,try ,all "") - completion-styles-alist) - completion-styles '(consult--split) - completion-category-defaults nil - completion-category-overrides nil))) - -;;;; Asynchronous filtering functions - -(defun consult--async-p (fun) - "Return t if FUN is an asynchronous completion function." - (and (functionp fun) - (condition-case nil - (progn (funcall fun "" nil 'metadata) nil) - (wrong-number-of-arguments t)))) - -(defmacro consult--with-async (bind &rest body) - "Setup asynchronous completion in BODY. - -BIND is the asynchronous function binding." - (declare (indent 1)) - (let ((async (car bind))) - `(let ((,async ,@(cdr bind)) - (new-chunk (max read-process-output-max consult--process-chunk)) - orig-chunk) - (consult--minibuffer-with-setup-hook - ;; Append such that we overwrite the completion style setting of - ;; `fido-mode'. See `consult--async-split' and - ;; `consult--split-setup'. - (:append - (lambda () - (when (consult--async-p ,async) - (setq orig-chunk read-process-output-max - read-process-output-max new-chunk) - (funcall ,async 'setup) - (let* ((mb (current-buffer)) - (fun (lambda () - (when-let (win (active-minibuffer-window)) - (when (eq (window-buffer win) mb) - (with-current-buffer mb - (let ((inhibit-modification-hooks t)) - ;; Push input string to request refresh. - (funcall ,async (minibuffer-contents-no-properties)))))))) - ;; We use a symbol in order to avoid adding lambdas to - ;; the hook variable. Symbol indirection because of - ;; bug#46407. - (hook (make-symbol "consult--async-after-change-hook"))) - ;; Delay modification hook to ensure that minibuffer is still - ;; alive after the change, such that we don't restart a new - ;; asynchronous search right before exiting the minibuffer. - (fset hook (lambda (&rest _) (run-at-time 0 nil fun))) - (add-hook 'after-change-functions hook nil 'local) - (funcall hook))))) - (let ((,async (if (consult--async-p ,async) ,async (lambda (_) ,async)))) - (unwind-protect - ,(macroexp-progn body) - (funcall ,async 'destroy) - (when (and orig-chunk (eq read-process-output-max new-chunk)) - (setq read-process-output-max orig-chunk)))))))) - -(defun consult--async-sink () - "Create ASYNC sink function. - -An async function must accept a single action argument. For the -\\='setup action it is guaranteed that the call originates from -the minibuffer. For the other actions no assumption about the -context can be made. - -\\='setup Setup the internal closure state. Return nil. -\\='destroy Destroy the internal closure state. Return nil. -\\='flush Flush the list of candidates. Return nil. -\\='refresh Request UI refresh. Return nil. -nil Return the list of candidates. -list Append the list to the already existing candidates list and return it. -string Update with the current user input string. Return nil." - (let (candidates last buffer) - (lambda (action) - (pcase-exhaustive action - ('setup - (setq buffer (current-buffer)) - nil) - ((or (pred stringp) 'destroy) nil) - ('flush (setq candidates nil last nil)) - ('refresh - ;; Refresh the UI when the current minibuffer window belongs - ;; to the current asynchronous completion session. - (when-let (win (active-minibuffer-window)) - (when (eq (window-buffer win) buffer) - (with-selected-window win - (run-hooks 'consult--completion-refresh-hook) - ;; Interaction between asynchronous completion functions and - ;; preview: We have to trigger preview immediately when - ;; candidates arrive (gh:minad/consult#436). - (when (and consult--preview-function candidates) - (funcall consult--preview-function))))) - nil) - ('nil candidates) - ((pred consp) - (setq last (last (if last (setcdr last action) (setq candidates action)))) - candidates))))) - -(defun consult--async-split-style () - "Return the async splitting style function and initial string." - (or (alist-get consult-async-split-style consult-async-split-styles-alist) - (user-error "Splitting style `%s' not found" consult-async-split-style))) - -(defun consult--async-split-initial (initial) - "Return initial string for async command. -INITIAL is the additional initial string." - (concat (plist-get (consult--async-split-style) :initial) initial)) - -(defun consult--async-split-thingatpt (thing) - "Return THING at point with async initial prefix." - (when-let (str (thing-at-point thing)) - (consult--async-split-initial str))) - -(defun consult--async-split (async &optional split) - "Create async function, which splits the input string. -ASYNC is the async sink. -SPLIT is the splitting function." - (unless split - (let* ((style (consult--async-split-style)) - (fn (plist-get style :function))) - (setq split (lambda (str) (funcall fn str style))))) - (lambda (action) - (pcase action - ('setup - (consult--split-setup split) - (funcall async 'setup)) - ((pred stringp) - (pcase-let* ((`(,async-str ,_ ,force . ,highlights) - (funcall split action)) - (async-len (length async-str)) - (input-len (length action)) - (end (minibuffer-prompt-end))) - ;; Highlight punctuation characters - (remove-list-of-text-properties end (+ end input-len) '(face)) - (dolist (hl highlights) - (put-text-property (+ end (car hl)) (+ end (cdr hl)) - 'face 'consult-async-split)) - (funcall async - ;; Pass through if the input is long enough! - (if (or force (>= async-len consult-async-min-input)) - async-str - ;; Pretend that there is no input - "")))) - (_ (funcall async action))))) - -(defun consult--async-indicator (async) - "Create async function with a state indicator overlay. -ASYNC is the async sink." - (let (ov) - (lambda (action &optional state) - (pcase action - ('indicator - (overlay-put ov 'display - (pcase-exhaustive state - ('running #("*" 0 1 (face consult-async-running))) - ('finished #(":" 0 1 (face consult-async-finished))) - ('killed #(";" 0 1 (face consult-async-failed))) - ('failed #("!" 0 1 (face consult-async-failed)))))) - ('setup - (setq ov (make-overlay (- (minibuffer-prompt-end) 2) - (- (minibuffer-prompt-end) 1))) - (funcall async 'setup)) - ('destroy - (delete-overlay ov) - (funcall async 'destroy)) - (_ (funcall async action)))))) - -(defun consult--async-log (formatted &rest args) - "Log FORMATTED ARGS to variable `consult--async-log'." - (with-current-buffer (get-buffer-create consult--async-log) - (goto-char (point-max)) - (insert (apply #'format formatted args)))) - -(defun consult--async-process (async builder &rest props) - "Create process source async function. - -ASYNC is the async function which receives the candidates. -BUILDER is the command line builder function. -PROPS are optional properties passed to `make-process'." - (setq async (consult--async-indicator async)) - (let (proc proc-buf last-args count) - (lambda (action) - (pcase action - ("" ;; If no input is provided kill current process - (when proc - (delete-process proc) - (kill-buffer proc-buf) - (setq proc nil proc-buf nil)) - (setq last-args nil)) - ((pred stringp) - (funcall async action) - (let* ((args (funcall builder action))) - (unless (stringp (car args)) - (setq args (car args))) - (unless (equal args last-args) - (setq last-args args) - (when proc - (delete-process proc) - (kill-buffer proc-buf) - (setq proc nil proc-buf nil)) - (when args - (let* ((flush t) - (rest "") - (proc-filter - (lambda (_ out) - (when flush - (setq flush nil) - (funcall async 'flush)) - (let ((lines (split-string out "[\r\n]+"))) - (if (not (cdr lines)) - (setq rest (concat rest (car lines))) - (setcar lines (concat rest (car lines))) - (let* ((len (length lines)) - (last (nthcdr (- len 2) lines))) - (setq rest (cadr last) - count (+ count len -1)) - (setcdr last nil) - (funcall async lines)))))) - (proc-sentinel - (lambda (_ event) - (when flush - (setq flush nil) - (funcall async 'flush)) - (funcall async 'indicator - (cond - ((string-prefix-p "killed" event) 'killed) - ((string-prefix-p "finished" event) 'finished) - (t 'failed))) - (when (and (string-prefix-p "finished" event) (not (equal rest ""))) - (cl-incf count) - (funcall async (list rest))) - (consult--async-log - "consult--async-process sentinel: event=%s lines=%d\n" - (string-trim event) count) - (when (> (buffer-size proc-buf) 0) - (with-current-buffer (get-buffer-create consult--async-log) - (goto-char (point-max)) - (insert ">>>>> stderr >>>>>\n") - (let ((beg (point))) - (insert-buffer-substring proc-buf) - (save-excursion - (goto-char beg) - (message #("%s" 0 2 (face error)) - (buffer-substring-no-properties (pos-bol) (pos-eol))))) - (insert "<<<<< stderr <<<<<\n"))))) - (process-adaptive-read-buffering nil)) - (funcall async 'indicator 'running) - (consult--async-log "consult--async-process started %S\n" args) - (setq count 0 - proc-buf (generate-new-buffer " *consult-async-stderr*") - proc (apply #'make-process - `(,@props - :connection-type pipe - :name ,(car args) - ;;; XXX tramp bug, the stderr buffer must be empty - :stderr ,proc-buf - :noquery t - :command ,args - :filter ,proc-filter - :sentinel ,proc-sentinel))))))) - nil) - ('destroy - (when proc - (delete-process proc) - (kill-buffer proc-buf) - (setq proc nil proc-buf nil)) - (funcall async 'destroy)) - (_ (funcall async action)))))) - -(defun consult--async-highlight (async builder) - "Return a new ASYNC function with candidate highlighting. -BUILDER is the command line builder function." - (let (highlight) - (lambda (action) - (cond - ((stringp action) - (setq highlight (cdr (funcall builder action))) - (funcall async action)) - ((and (consp action) highlight) - (dolist (str action) - (funcall highlight str)) - (funcall async action)) - (t (funcall async action)))))) - -(defun consult--async-throttle (async &optional throttle debounce) - "Create async function from ASYNC which throttles input. - -The THROTTLE delay defaults to `consult-async-input-throttle'. -The DEBOUNCE delay defaults to `consult-async-input-debounce'." - (setq throttle (or throttle consult-async-input-throttle) - debounce (or debounce consult-async-input-debounce)) - (let* ((input "") (timer (timer-create)) (last 0)) - (lambda (action) - (pcase action - ((pred stringp) - (unless (equal action input) - (cancel-timer timer) - (funcall async "") ;; cancel running process - (setq input action) - (unless (equal action "") - (timer-set-function timer (lambda () - (setq last (float-time)) - (funcall async action))) - (timer-set-time - timer - (timer-relative-time - nil (max debounce (- (+ last throttle) (float-time))))) - (timer-activate timer))) - nil) - ('destroy - (cancel-timer timer) - (funcall async 'destroy)) - (_ (funcall async action)))))) - -(defun consult--async-refresh-immediate (async) - "Create async function from ASYNC, which refreshes the display. - -The refresh happens immediately when candidates are pushed." - (lambda (action) - (pcase action - ((or (pred consp) 'flush) - (prog1 (funcall async action) - (funcall async 'refresh))) - (_ (funcall async action))))) - -(defun consult--async-refresh-timer (async &optional delay) - "Create async function from ASYNC, which refreshes the display. - -The refresh happens after a DELAY, defaulting to `consult-async-refresh-delay'." - (let ((delay (or delay consult-async-refresh-delay)) - (timer (timer-create))) - (timer-set-function timer async '(refresh)) - (lambda (action) - (prog1 (funcall async action) - (pcase action - ((or (pred consp) 'flush) - (unless (memq timer timer-list) - (timer-set-time timer (timer-relative-time nil delay)) - (timer-activate timer))) - ('destroy - (cancel-timer timer))))))) - -(defmacro consult--async-command (builder &rest args) - "Asynchronous command pipeline. -ARGS is a list of `make-process' properties and transforms. -BUILDER is the command line builder function, which takes the -input string and must either return a list of command line -arguments or a pair of the command line argument list and a -highlighting function." - (declare (indent 1)) - `(thread-first - (consult--async-sink) - (consult--async-refresh-timer) - ,@(seq-take-while (lambda (x) (not (keywordp x))) args) - (consult--async-process - ,builder - ,@(seq-drop-while (lambda (x) (not (keywordp x))) args)) - (consult--async-throttle) - (consult--async-split))) - -(defmacro consult--async-transform (async &rest transform) - "Use FUN to TRANSFORM candidates of ASYNC." - (cl-with-gensyms (async-var action-var) - `(let ((,async-var ,async)) - (lambda (,action-var) - (funcall ,async-var (if (consp ,action-var) (,@transform ,action-var) ,action-var)))))) - -(defun consult--async-map (async fun) - "Map candidates of ASYNC by FUN." - (consult--async-transform async mapcar fun)) - -(defun consult--async-filter (async fun) - "Filter candidates of ASYNC by FUN." - (consult--async-transform async seq-filter fun)) - -;;;; Dynamic collections based - -(defun consult--dynamic-compute (async fun &optional debounce) - "Dynamic computation of candidates. -ASYNC is the sink. -FUN computes the candidates given the input. -DEBOUNCE is the time after which an interrupted computation -should be restarted." - (setq debounce (or debounce consult-async-input-debounce)) - (setq async (consult--async-indicator async)) - (let* ((request) (current) (timer) - (cancel (lambda () (when timer (cancel-timer timer) (setq timer nil)))) - (start (lambda (req) (setq request req) (funcall async 'refresh)))) - (lambda (action) - (pcase action - ((and 'nil (guard (not request))) - (funcall async nil)) - ('nil - (funcall cancel) - (let ((state 'killed)) - (unwind-protect - (progn - (funcall async 'indicator 'running) - (redisplay) - ;; Run computation - (let ((response (funcall fun request))) - ;; Flush and update candidate list - (funcall async 'flush) - (setq state 'finished current request) - (funcall async response))) - (funcall async 'indicator state) - ;; If the computation was killed, restart it after some time. - (when (eq state 'killed) - (setq timer (run-at-time debounce nil start request))) - (setq request nil)))) - ((pred stringp) - (funcall cancel) - (if (or (equal action "") (equal action current)) - (funcall async 'indicator 'finished) - (funcall start action))) - ('destroy - (funcall cancel) - (funcall async 'destroy)) - (_ (funcall async action)))))) - -(defun consult--dynamic-collection (fun) - "Dynamic collection with input splitting. -FUN computes the candidates given the input." - (thread-first - (consult--async-sink) - (consult--dynamic-compute fun) - (consult--async-throttle) - (consult--async-split))) - -;;;; Special keymaps - -(defvar-keymap consult-async-map - :doc "Keymap added for commands with asynchronous candidates." - ;; Overwriting some unusable defaults of default minibuffer completion. - "<remap> <minibuffer-complete-word>" #'self-insert-command - ;; Remap Emacs 29 history and default completion for now - ;; (gh:minad/consult#613). - "<remap> <minibuffer-complete-defaults>" #'ignore - "<remap> <minibuffer-complete-history>" #'consult-history) - -(defvar-keymap consult-narrow-map - :doc "Narrowing keymap which is added to the local minibuffer map. -Note that `consult-narrow-key' and `consult-widen-key' are bound dynamically." - "SPC" consult--narrow-space - "DEL" consult--narrow-delete) - -;;;; Internal API: consult--read - -(defun consult--annotate-align (cand ann) - "Align annotation ANN by computing the maximum CAND width." - (setq consult--annotate-align-width - (max consult--annotate-align-width - (* (ceiling (consult--display-width cand) - consult--annotate-align-step) - consult--annotate-align-step))) - (when ann - (concat - #(" " 0 1 (display (space :align-to (+ left consult--annotate-align-width)))) - ann))) - -(defun consult--add-history (async items) - "Add ITEMS to the minibuffer future history. -ASYNC must be non-nil for async completion functions." - (delete-dups - (append - ;; the defaults are at the beginning of the future history - (ensure-list minibuffer-default) - ;; then our custom items - (remove "" (remq nil (ensure-list items))) - ;; Add all the completions for non-async commands. For async commands this - ;; feature is not useful, since if one selects a completion candidate, the - ;; async search is restarted using that candidate string. This usually does - ;; not yield a desired result since the async input uses a special format, - ;; e.g., `#grep#filter'. - (unless async - (all-completions "" - minibuffer-completion-table - minibuffer-completion-predicate))))) - -(defun consult--setup-keymap (keymap async narrow preview-key) - "Setup minibuffer keymap. - -KEYMAP is a command-specific keymap. -ASYNC must be non-nil for async completion functions. -NARROW are the narrow settings. -PREVIEW-KEY are the preview keys." - (let ((old-map (current-local-map)) - (map (make-sparse-keymap))) - - ;; Add narrow keys - (when narrow - (consult--narrow-setup narrow map)) - - ;; Preview trigger keys - (when (and (consp preview-key) (memq :keys preview-key)) - (setq preview-key (plist-get preview-key :keys))) - (setq preview-key (mapcar #'car (consult--preview-key-normalize preview-key))) - (when preview-key - (dolist (key preview-key) - (unless (or (eq key 'any) (lookup-key old-map key)) - (define-key map key #'ignore)))) - - ;; Put the keymap together - (use-local-map - (make-composed-keymap - (delq nil (list keymap - (and async consult-async-map) - (and narrow consult-narrow-map) - map)) - old-map)))) - -(defun consult--tofu-hide-in-minibuffer (&rest _) - "Hide the tofus in the minibuffer." - (let* ((min (minibuffer-prompt-end)) - (max (point-max)) - (pos max)) - (while (and (> pos min) (consult--tofu-p (char-before pos))) - (cl-decf pos)) - (when (< pos max) - (add-text-properties pos max '(invisible t rear-nonsticky t cursor-intangible t))))) - -(defun consult--read-annotate (fun cand) - "Annotate CAND with annotation function FUN." - (pcase (funcall fun cand) - (`(,_ ,_ ,suffix) suffix) - (ann ann))) - -(defun consult--read-affixate (fun cands) - "Affixate CANDS with annotation function FUN." - (mapcar (lambda (cand) - (let ((ann (funcall fun cand))) - (if (consp ann) - ann - (setq ann (or ann "")) - (list cand "" - ;; The default completion UI adds the - ;; `completions-annotations' face if no other faces are - ;; present. - (if (text-property-not-all 0 (length ann) 'face nil ann) - ann - (propertize ann 'face 'completions-annotations)))))) - cands)) - -(cl-defun consult--read-1 (table &key - prompt predicate require-match history default - keymap category initial narrow add-history annotate - state preview-key sort lookup group inherit-input-method) - "See `consult--read' for the documentation of the arguments." - (consult--minibuffer-with-setup-hook - (:append (lambda () - (add-hook 'after-change-functions #'consult--tofu-hide-in-minibuffer nil 'local) - (consult--setup-keymap keymap (consult--async-p table) narrow preview-key) - (setq-local minibuffer-default-add-function - (apply-partially #'consult--add-history (consult--async-p table) add-history)))) - (consult--with-async (async table) - (consult--with-preview - preview-key state - (lambda (narrow input cand) - (funcall lookup cand (funcall async nil) input narrow)) - (apply-partially #'run-hook-with-args-until-success - 'consult--completion-candidate-hook) - (pcase-exhaustive history - (`(:input ,var) var) - ((pred symbolp))) - ;; Do not unnecessarily let-bind the lambdas to avoid over-capturing in - ;; the interpreter. This will make closures and the lambda string - ;; representation larger, which makes debugging much worse. Fortunately - ;; the over-capturing problem does not affect the bytecode interpreter - ;; which does a proper scope analysis. - (let* ((metadata `(metadata - ,@(when category `((category . ,category))) - ,@(when group `((group-function . ,group))) - ,@(when annotate - `((affixation-function - . ,(apply-partially #'consult--read-affixate annotate)) - (annotation-function - . ,(apply-partially #'consult--read-annotate annotate)))) - ,@(unless sort '((cycle-sort-function . identity) - (display-sort-function . identity))))) - (consult--annotate-align-width 0) - (selected - (completing-read - prompt - (lambda (str pred action) - (let ((result (complete-with-action action (funcall async nil) str pred))) - (if (eq action 'metadata) - (if (and (eq (car result) 'metadata) (cdr result)) - ;; Merge metadata - `(metadata ,@(cdr metadata) ,@(cdr result)) - metadata) - result))) - predicate require-match initial - (if (symbolp history) history (cadr history)) - default - inherit-input-method))) - ;; Repair the null completion semantics. `completing-read' may return - ;; an empty string even if REQUIRE-MATCH is non-nil. One can always - ;; opt-in to null completion by passing the empty string for DEFAULT. - (when (and (eq require-match t) (not default) (equal selected "")) - (user-error "No selection")) - selected))))) - -(cl-defun consult--read (table &rest options &key - prompt predicate require-match history default - keymap category initial narrow add-history annotate - state preview-key sort lookup group inherit-input-method) - "Enhanced completing read function to select from TABLE. - -The function is a thin wrapper around `completing-read'. Keyword -arguments are used instead of positional arguments for code -clarity. On top of `completing-read' it additionally supports -computing the candidate list asynchronously, candidate preview -and narrowing. You should use `completing-read' instead of -`consult--read' if you don't use asynchronous candidate -computation or candidate preview. - -Keyword OPTIONS: - -PROMPT is the string which is shown as prompt in the minibuffer. -PREDICATE is a filter function called for each candidate, returns -nil or t. -REQUIRE-MATCH equals t means that an exact match is required. -HISTORY is the symbol of the history variable. -DEFAULT is the default selected value. -ADD-HISTORY is a list of items to add to the history. -CATEGORY is the completion category symbol. -SORT should be set to nil if the candidates are already sorted. -This will disable sorting in the completion UI. -LOOKUP is a lookup function passed the selected candidate string, -the list of candidates, the current input string and the current -narrowing value. -ANNOTATE is a function passed a candidate string. The function -should either return an annotation string or a list of three -strings (candidate prefix postfix). -INITIAL is the initial input string. -STATE is the state function, see `consult--with-preview'. -GROUP is a completion metadata `group-function' as documented in -the Elisp manual. -PREVIEW-KEY are the preview keys. Can be nil, `any', a single -key or a list of keys. -NARROW is an alist of narrowing prefix strings and description. -KEYMAP is a command-specific keymap. -INHERIT-INPUT-METHOD, if non-nil the minibuffer inherits the -input method." - ;; supported types - (cl-assert (or (functionp table) ;; dynamic table or asynchronous function - (obarrayp table) ;; obarray - (hash-table-p table) ;; hash table - (not table) ;; empty list - (stringp (car table)) ;; string list - (and (consp (car table)) (stringp (caar table))) ;; string alist - (and (consp (car table)) (symbolp (caar table))))) ;; symbol alist - (ignore prompt predicate require-match history default - keymap category initial narrow add-history annotate - state preview-key sort lookup group inherit-input-method) - (apply #'consult--read-1 table - (append - (consult--customize-get) - options - (list :prompt "Select: " - :preview-key consult-preview-key - :sort t - :lookup (lambda (selected &rest _) selected))))) - -;;;; Internal API: consult--prompt - -(cl-defun consult--prompt-1 (&key prompt history add-history initial default - keymap state preview-key transform inherit-input-method) - "See `consult--prompt' for documentation." - (consult--minibuffer-with-setup-hook - (:append (lambda () - (consult--setup-keymap keymap nil nil preview-key) - (setq-local minibuffer-default-add-function - (apply-partially #'consult--add-history nil add-history)))) - (consult--with-preview - preview-key state - (lambda (_narrow inp _cand) (funcall transform inp)) - (lambda () "") - history - (read-from-minibuffer prompt initial nil nil history default inherit-input-method)))) - -(cl-defun consult--prompt (&rest options &key prompt history add-history initial default - keymap state preview-key transform inherit-input-method) - "Read from minibuffer. - -Keyword OPTIONS: - -PROMPT is the string to prompt with. -TRANSFORM is a function which is applied to the current input string. -HISTORY is the symbol of the history variable. -INITIAL is initial input. -DEFAULT is the default selected value. -ADD-HISTORY is a list of items to add to the history. -STATE is the state function, see `consult--with-preview'. -PREVIEW-KEY are the preview keys (nil, `any', a single key or a list of keys). -KEYMAP is a command-specific keymap." - (ignore prompt history add-history initial default - keymap state preview-key transform inherit-input-method) - (apply #'consult--prompt-1 - (append - (consult--customize-get) - options - (list :prompt "Input: " - :preview-key consult-preview-key - :transform #'identity)))) - -;;;; Internal API: consult--multi - -(defsubst consult--multi-source (sources cand) - "Lookup source for CAND in SOURCES list." - (aref sources (consult--tofu-get cand))) - -(defun consult--multi-predicate (sources cand) - "Predicate function called for each candidate CAND given SOURCES." - (let* ((src (consult--multi-source sources cand)) - (narrow (plist-get src :narrow)) - (type (or (car-safe narrow) narrow -1))) - (or (eq consult--narrow type) - (not (or consult--narrow (plist-get src :hidden)))))) - -(defun consult--multi-narrow (sources) - "Return narrow list from SOURCES." - (thread-last sources - (mapcar (lambda (src) - (when-let (narrow (plist-get src :narrow)) - (if (consp narrow) - narrow - (when-let (name (plist-get src :name)) - (cons narrow name)))))) - (delq nil) - (delete-dups))) - -(defun consult--multi-annotate (sources cand) - "Annotate candidate CAND from multi SOURCES." - (consult--annotate-align - cand - (let ((src (consult--multi-source sources cand))) - (if-let ((fun (plist-get src :annotate))) - (funcall fun (cdr (get-text-property 0 'multi-category cand))) - (plist-get src :name))))) - -(defun consult--multi-group (sources cand transform) - "Return title of candidate CAND or TRANSFORM the candidate given SOURCES." - (if transform cand - (plist-get (consult--multi-source sources cand) :name))) - -(defun consult--multi-preview-key (sources) - "Return preview keys from SOURCES." - (list :predicate - (lambda (cand) - (if (plist-member (cdr cand) :preview-key) - (plist-get (cdr cand) :preview-key) - consult-preview-key)) - :keys - (delete-dups - (seq-mapcat (lambda (src) - (let ((key (if (plist-member src :preview-key) - (plist-get src :preview-key) - consult-preview-key))) - (ensure-list key))) - sources)))) - -(defun consult--multi-lookup (sources selected candidates _input narrow &rest _) - "Lookup SELECTED in CANDIDATES given SOURCES, with potential NARROW." - (if (or (string-blank-p selected) - (not (consult--tofu-p (aref selected (1- (length selected)))))) - ;; Non-existing candidate without Tofu or default submitted (empty string) - (let* ((src (cond - (narrow (seq-find (lambda (src) - (let ((n (plist-get src :narrow))) - (eq (or (car-safe n) n -1) narrow))) - sources)) - ((seq-find (lambda (src) (plist-get src :default)) sources)) - ((seq-find (lambda (src) (not (plist-get src :hidden))) sources)) - ((aref sources 0)))) - (idx (seq-position sources src)) - (def (and (string-blank-p selected) ;; default candidate - (seq-find (lambda (cand) (eq idx (consult--tofu-get cand))) candidates)))) - (if def - (cons (cdr (get-text-property 0 'multi-category def)) src) - `(,selected :match nil ,@src))) - (if-let (found (member selected candidates)) - ;; Existing candidate submitted - (cons (cdr (get-text-property 0 'multi-category (car found))) - (consult--multi-source sources selected)) - ;; Non-existing Tofu'ed candidate submitted, e.g., via Embark - `(,(substring selected 0 -1) :match nil ,@(consult--multi-source sources selected))))) - -(defun consult--multi-candidates (sources) - "Return `consult--multi' candidates from SOURCES." - (let ((idx 0) candidates) - (seq-doseq (src sources) - (let* ((face (and (plist-member src :face) `(face ,(plist-get src :face)))) - (cat (plist-get src :category)) - (items (plist-get src :items)) - (items (if (functionp items) (funcall items) items))) - (dolist (item items) - (let* ((str (or (car-safe item) item)) - (cand (consult--tofu-append str idx))) - ;; Preserve existing `multi-category' datum of the candidate. - (if (and (eq str item) (get-text-property 0 'multi-category str)) - (when face (add-text-properties 0 (length str) face cand)) - ;; Attach `multi-category' datum and face. - (add-text-properties - 0 (length str) - `(multi-category (,cat . ,(or (cdr-safe item) item)) ,@face) cand)) - (push cand candidates)))) - (cl-incf idx)) - (nreverse candidates))) - -(defun consult--multi-enabled-sources (sources) - "Return vector of enabled SOURCES." - (vconcat - (seq-filter (lambda (src) - (if-let (pred (plist-get src :enabled)) - (funcall pred) - t)) - (mapcar (lambda (src) - (if (symbolp src) (symbol-value src) src)) - sources)))) - -(defun consult--multi-state (sources) - "State function given SOURCES." - (when-let (states (delq nil (mapcar (lambda (src) - (when-let (fun (plist-get src :state)) - (cons src (funcall fun)))) - sources))) - (let (last-fun) - (pcase-lambda (action `(,cand . ,src)) - (pcase action - ('setup - (pcase-dolist (`(,_ . ,fun) states) - (funcall fun 'setup nil))) - ('exit - (pcase-dolist (`(,_ . ,fun) states) - (funcall fun 'exit nil))) - ('preview - (let ((selected-fun (cdr (assq src states)))) - ;; If the candidate source changed during preview communicate to - ;; the last source, that none of its candidates is previewed anymore. - (when (and last-fun (not (eq last-fun selected-fun))) - (funcall last-fun 'preview nil)) - (setq last-fun selected-fun) - (when selected-fun - (funcall selected-fun 'preview cand)))) - ('return - (let ((selected-fun (cdr (assq src states)))) - ;; Finish all the sources, except the selected one. - (pcase-dolist (`(,_ . ,fun) states) - (unless (eq fun selected-fun) - (funcall fun 'return nil))) - ;; Finish the source with the selected candidate - (when selected-fun - (funcall selected-fun 'return cand))))))))) - -(defun consult--multi (sources &rest options) - "Select from candidates taken from a list of SOURCES. - -OPTIONS is the plist of options passed to `consult--read'. The following -options are supported: :require-match, :history, :keymap, :initial, -:add-history, :sort and :inherit-input-method. The other options of -`consult--read' are used by the implementation of `consult--multi' and -should not be overwritten, except in in special scenarios. - -The function returns the selected candidate in the form (cons candidate -source-plist). The plist has the key :match with a value nil if the -candidate does not exist, t if the candidate exists and `new' if the -candidate has been created. The sources of the source list can either be -symbols of source variables or source values. Source values must be -plists with fields from the following list. - -Required source fields: -* :category - Completion category symbol. -* :items - List of strings to select from or function returning - list of strings. Note that the strings can use text properties - to carry metadata, which is then available to the :annotate, - :action and :state functions. - -Optional source fields: -* :name - Name of the source as a string, used for narrowing, - group titles and annotations. -* :narrow - Narrowing character or (character . string) pair. -* :enabled - Function which must return t if the source is enabled. -* :hidden - When t candidates of this source are hidden by default. -* :face - Face used for highlighting the candidates. -* :annotate - Annotation function called for each candidate, returns string. -* :history - Name of history variable to add selected candidate. -* :default - Must be t if the first item of the source is the default value. -* :action - Function called with the selected candidate. -* :new - Function called with new candidate name, only if :require-match is nil. -* :state - State constructor for the source, must return the - state function. The state function is informed about state - changes of the UI and can be used to implement preview. -* Other custom source fields can be added depending on the use - case. Note that the source is returned by `consult--multi' - together with the selected candidate." - (let* ((sources (consult--multi-enabled-sources sources)) - (candidates (consult--with-increased-gc - (consult--multi-candidates sources))) - (selected - (apply #'consult--read - candidates - (append - options - (list - :category 'multi-category - :predicate (apply-partially #'consult--multi-predicate sources) - :annotate (apply-partially #'consult--multi-annotate sources) - :group (apply-partially #'consult--multi-group sources) - :lookup (apply-partially #'consult--multi-lookup sources) - :preview-key (consult--multi-preview-key sources) - :narrow (consult--multi-narrow sources) - :state (consult--multi-state sources)))))) - (when-let (history (plist-get (cdr selected) :history)) - (add-to-history history (car selected))) - (if (plist-member (cdr selected) :match) - (when-let (fun (plist-get (cdr selected) :new)) - (funcall fun (car selected)) - (plist-put (cdr selected) :match 'new)) - (when-let (fun (plist-get (cdr selected) :action)) - (funcall fun (car selected))) - (setq selected `(,(car selected) :match t ,@(cdr selected)))) - selected)) - -;;;; Customization macro - -(defun consult--customize-put (cmds prop form) - "Set property PROP to FORM of commands CMDS." - (dolist (cmd cmds) - (cond - ((and (boundp cmd) (consp (symbol-value cmd))) - (setf (plist-get (symbol-value cmd) prop) (eval form 'lexical))) - ((functionp cmd) - (setf (plist-get (alist-get cmd consult--customize-alist) prop) form)) - (t (user-error "%s is neither a Command command nor a source" cmd)))) - nil) - -(defmacro consult-customize (&rest args) - "Set properties of commands or sources. -ARGS is a list of commands or sources followed by the list of -keyword-value pairs. For `consult-customize' to succeed, the -customized sources and commands must exist. When a command is -invoked, the value of `this-command' is used to lookup the -corresponding customization options." - (let (setter) - (while args - (let ((cmds (seq-take-while (lambda (x) (not (keywordp x))) args))) - (setq args (seq-drop-while (lambda (x) (not (keywordp x))) args)) - (while (keywordp (car args)) - (push `(consult--customize-put ',cmds ,(car args) ',(cadr args)) setter) - (setq args (cddr args))))) - (macroexp-progn setter))) - -(defun consult--customize-get (&optional cmd) - "Get configuration from `consult--customize-alist' for CMD." - (mapcar (lambda (x) (eval x 'lexical)) - (alist-get (or cmd this-command) consult--customize-alist))) - -;;;; Commands - -;;;;; Command: consult-completion-in-region - -(defun consult--insertion-preview (start end) - "State function for previewing a candidate in a specific region. -The candidates are previewed in the region from START to END. This function is -used as the `:state' argument for `consult--read' in the `consult-yank' family -of functions and in `consult-completion-in-region'." - (unless (or (minibufferp) - ;; Disable preview if anything odd is going on with the markers. - ;; Otherwise we get "Marker points into wrong buffer errors". See - ;; gh:minad/consult#375, where Org mode source blocks are - ;; completed in a different buffer than the original buffer. This - ;; completion is probably also problematic in my Corfu completion - ;; package. - (not (eq (window-buffer) (current-buffer))) - (and (markerp start) (not (eq (marker-buffer start) (current-buffer)))) - (and (markerp end) (not (eq (marker-buffer end) (current-buffer))))) - (let (ov) - (lambda (action cand) - (cond - ((and (not cand) ov) - (delete-overlay ov) - (setq ov nil)) - ((and (eq action 'preview) cand) - (unless ov - (setq ov (consult--make-overlay start end - 'invisible t - 'window (selected-window)))) - ;; Use `add-face-text-property' on a copy of "cand in order to merge face properties - (setq cand (copy-sequence cand)) - (add-face-text-property 0 (length cand) 'consult-preview-insertion t cand) - ;; Use the `before-string' property since the overlay might be empty. - (overlay-put ov 'before-string cand))))))) - -;;;###autoload -(defun consult-completion-in-region (start end collection &optional predicate) - "Use minibuffer completion as the UI for `completion-at-point'. - -The function is called with 4 arguments: START END COLLECTION -PREDICATE. The arguments and expected return value are as -specified for `completion-in-region'. Use this function as a -value for `completion-in-region-function'." - (barf-if-buffer-read-only) - (let* ((initial (buffer-substring-no-properties start end)) - (metadata (completion-metadata initial collection predicate)) - ;; TODO: `minibuffer-completing-file-name' is mostly deprecated, but - ;; still in use. Packages should instead use the completion metadata. - (minibuffer-completing-file-name - (eq 'file (completion-metadata-get metadata 'category))) - (threshold (completion--cycle-threshold metadata)) - (all (completion-all-completions initial collection predicate (length initial))) - ;; Wrap all annotation functions to ensure that they are executed - ;; in the original buffer. - (exit-fun (plist-get completion-extra-properties :exit-function)) - (ann-fun (plist-get completion-extra-properties :annotation-function)) - (aff-fun (plist-get completion-extra-properties :affixation-function)) - (docsig-fun (plist-get completion-extra-properties :company-docsig)) - (completion-extra-properties - `(,@(and ann-fun (list :annotation-function (consult--in-buffer ann-fun))) - ,@(and aff-fun (list :affixation-function (consult--in-buffer aff-fun))) - ;; Provide `:annotation-function' if `:company-docsig' is specified. - ,@(and docsig-fun (not ann-fun) (not aff-fun) - (list :annotation-function - (consult--in-buffer - (lambda (cand) - (concat (propertize " " 'display '(space :align-to center)) - (funcall docsig-fun cand))))))))) - ;; error if `threshold' is t or the improper list `all' is too short - (if (and threshold - (or (not (consp (ignore-errors (nthcdr threshold all)))) - (and completion-cycling completion-all-sorted-completions))) - (completion--in-region start end collection predicate) - (let* ((limit (car (completion-boundaries initial collection predicate ""))) - (this-command #'consult-completion-in-region) - (completion - (cond - ((atom all) nil) - ((and (consp all) (atom (cdr all))) - (concat (substring initial 0 limit) (car all))) - (t - (consult--local-let ((enable-recursive-minibuffers t)) - ;; Evaluate completion table in the original buffer. - ;; This is a reasonable thing to do and required by - ;; some completion tables in particular by lsp-mode. - ;; See gh:minad/vertico#61. - (consult--read (consult--completion-table-in-buffer collection) - :prompt "Completion: " - :state (consult--insertion-preview start end) - :predicate predicate - :initial initial)))))) - (if completion - (progn - ;; bug#55205: completion--replace removes properties! - (completion--replace start end (setq completion (concat completion))) - (when exit-fun - (funcall exit-fun completion - ;; If completion is finished and cannot be further - ;; completed, return `finished'. Otherwise return - ;; `exact'. - (if (eq (try-completion completion collection predicate) t) - 'finished 'exact))) - t) - (message "No completion") - nil))))) - -;;;;; Command: consult-outline - -(defun consult--outline-candidates () - "Return alist of outline headings and positions." - (consult--forbid-minibuffer) - (let* ((line (line-number-at-pos (point-min) consult-line-numbers-widen)) - (heading-regexp (concat "^\\(?:" - ;; default definition from outline.el - (or (bound-and-true-p outline-regexp) "[*\^L]+") - "\\)")) - (heading-alist (bound-and-true-p outline-heading-alist)) - (level-fun (or (bound-and-true-p outline-level) - (lambda () ;; as in the default from outline.el - (or (cdr (assoc (match-string 0) heading-alist)) - (- (match-end 0) (match-beginning 0)))))) - (buffer (current-buffer)) - candidates) - (save-excursion - (goto-char (point-min)) - (while (save-excursion - (if-let (fun (bound-and-true-p outline-search-function)) - (funcall fun) - (re-search-forward heading-regexp nil t))) - (cl-incf line (consult--count-lines (match-beginning 0))) - (push (consult--location-candidate - (consult--buffer-substring (pos-bol) (pos-eol) 'fontify) - (cons buffer (point)) (1- line) (1- line) - 'consult--outline-level (funcall level-fun)) - candidates) - (goto-char (1+ (pos-eol))))) - (unless candidates - (user-error "No headings")) - (nreverse candidates))) - -;;;###autoload -(defun consult-outline (&optional level) - "Jump to an outline heading, obtained by matching against `outline-regexp'. - -This command supports narrowing to a heading level and candidate -preview. The initial narrowing LEVEL can be given as prefix -argument. The symbol at point is added to the future history." - (interactive - (list (and current-prefix-arg (prefix-numeric-value current-prefix-arg)))) - (let* ((candidates (consult--slow-operation - "Collecting headings..." - (consult--outline-candidates))) - (min-level (- (cl-loop for cand in candidates minimize - (get-text-property 0 'consult--outline-level cand)) - ?1)) - (narrow-pred (lambda (cand) - (<= (get-text-property 0 'consult--outline-level cand) - (+ consult--narrow min-level)))) - (narrow-keys (mapcar (lambda (c) (cons c (format "Level %c" c))) - (number-sequence ?1 ?9))) - (narrow-init (and level (max ?1 (min ?9 (+ level ?0)))))) - (consult--read - candidates - :prompt "Go to heading: " - :annotate (consult--line-prefix) - :category 'consult-location - :sort nil - :require-match t - :lookup #'consult--line-match - :narrow `(:predicate ,narrow-pred :keys ,narrow-keys :initial ,narrow-init) - :history '(:input consult--line-history) - :add-history (thing-at-point 'symbol) - :state (consult--location-state candidates)))) - -;;;;; Command: consult-mark - -(defun consult--mark-candidates (markers) - "Return list of candidates strings for MARKERS." - (consult--forbid-minibuffer) - (let ((candidates) - (current-buf (current-buffer))) - (save-excursion - (dolist (marker markers) - (when-let ((pos (marker-position marker)) - (buf (marker-buffer marker))) - (when (and (eq buf current-buf) - (consult--in-range-p pos)) - (goto-char pos) - ;; `line-number-at-pos' is a very slow function, which should be - ;; replaced everywhere. However in this case the slow - ;; line-number-at-pos does not hurt much, since the mark ring is - ;; usually small since it is limited by `mark-ring-max'. - (push (consult--location-candidate - (consult--line-with-mark marker) marker - (line-number-at-pos pos consult-line-numbers-widen) - marker) - candidates))))) - (unless candidates - (user-error "No marks")) - (nreverse (delete-dups candidates)))) - -;;;###autoload -(defun consult-mark (&optional markers) - "Jump to a marker in MARKERS list (defaults to buffer-local `mark-ring'). - -The command supports preview of the currently selected marker position. -The symbol at point is added to the future history." - (interactive) - (consult--read - (consult--mark-candidates - (or markers (cons (mark-marker) mark-ring))) - :prompt "Go to mark: " - :annotate (consult--line-prefix) - :category 'consult-location - :sort nil - :require-match t - :lookup #'consult--lookup-location - :history '(:input consult--line-history) - :add-history (thing-at-point 'symbol) - :state (consult--jump-state))) - -;;;;; Command: consult-global-mark - -(defun consult--global-mark-candidates (markers) - "Return list of candidates strings for MARKERS." - (consult--forbid-minibuffer) - (let ((candidates)) - (save-excursion - (dolist (marker markers) - (when-let ((pos (marker-position marker)) - (buf (marker-buffer marker))) - (unless (minibufferp buf) - (with-current-buffer buf - (when (consult--in-range-p pos) - (goto-char pos) - ;; `line-number-at-pos' is slow, see comment in `consult--mark-candidates'. - (let* ((line (line-number-at-pos pos consult-line-numbers-widen)) - (prefix (consult--format-file-line-match (buffer-name buf) line "")) - (cand (concat prefix (consult--line-with-mark marker) (consult--tofu-encode marker)))) - (put-text-property 0 (length prefix) 'consult-strip t cand) - (put-text-property 0 (length cand) 'consult-location (cons marker line) cand) - (push cand candidates)))))))) - (unless candidates - (user-error "No global marks")) - (nreverse (delete-dups candidates)))) - -;;;###autoload -(defun consult-global-mark (&optional markers) - "Jump to a marker in MARKERS list (defaults to `global-mark-ring'). - -The command supports preview of the currently selected marker position. -The symbol at point is added to the future history." - (interactive) - (consult--read - (consult--global-mark-candidates - (or markers global-mark-ring)) - :prompt "Go to global mark: " - ;; Despite `consult-global-mark' formatting the candidates in grep-like - ;; style, we are not using the `consult-grep' category, since the candidates - ;; have location markers attached. - :category 'consult-location - :sort nil - :require-match t - :lookup #'consult--lookup-location - :history '(:input consult--line-history) - :add-history (thing-at-point 'symbol) - :state (consult--jump-state))) - -;;;;; Command: consult-line - -(defun consult--line-candidates (top curr-line) - "Return list of line candidates. -Start from top if TOP non-nil. -CURR-LINE is the current line number." - (consult--forbid-minibuffer) - (consult--fontify-all) - (let* ((buffer (current-buffer)) - (line (line-number-at-pos (point-min) consult-line-numbers-widen)) - default-cand candidates) - (consult--each-line beg end - (unless (looking-at-p "^\\s-*$") - (push (consult--location-candidate - (consult--buffer-substring beg end) - (cons buffer beg) line line) - candidates) - (when (and (not default-cand) (>= line curr-line)) - (setq default-cand candidates))) - (cl-incf line)) - (unless candidates - (user-error "No lines")) - (nreverse - (if (or top (not default-cand)) - candidates - (let ((before (cdr default-cand))) - (setcdr default-cand nil) - (nconc before candidates)))))) - -(defun consult--line-point-placement (selected candidates highlighted &rest ignored-faces) - "Find point position on matching line. -SELECTED is the currently selected candidate. -CANDIDATES is the list of candidates. -HIGHLIGHTED is the highlighted string to determine the match position. -IGNORED-FACES are ignored when determining the match position." - (when-let (pos (consult--lookup-location selected candidates)) - (if highlighted - (let* ((matches (apply #'consult--point-placement highlighted 0 ignored-faces)) - (dest (+ pos (car matches)))) - ;; Only create a new marker when jumping across buffers (for example - ;; `consult-line-multi'). Avoid creating unnecessary markers, when - ;; scrolling through candidates, since creating markers is not free. - (when (and (markerp pos) (not (eq (marker-buffer pos) (current-buffer)))) - (setq dest (move-marker (make-marker) dest (marker-buffer pos)))) - (cons dest (cdr matches))) - pos))) - -(defun consult--line-match (selected candidates input &rest _) - "Lookup position of match. -SELECTED is the currently selected candidate. -CANDIDATES is the list of candidates. -INPUT is the input string entered by the user." - (consult--line-point-placement selected candidates - (and (not (string-blank-p input)) - (car (consult--completion-filter - input - (list (substring-no-properties selected)) - 'consult-location 'highlight))) - 'completions-first-difference)) - -;;;###autoload -(defun consult-line (&optional initial start) - "Search for a matching line. - -Depending on the setting `consult-point-placement' the command -jumps to the beginning or the end of the first match on the line -or the line beginning. The default candidate is the non-empty -line next to point. This command obeys narrowing. Optional -INITIAL input can be provided. The search starting point is -changed if the START prefix argument is set. The symbol at point -and the last `isearch-string' is added to the future history." - (interactive (list nil (not (not current-prefix-arg)))) - (let* ((curr-line (line-number-at-pos (point) consult-line-numbers-widen)) - (top (not (eq start consult-line-start-from-top))) - (candidates (consult--slow-operation "Collecting lines..." - (consult--line-candidates top curr-line)))) - (consult--read - candidates - :prompt (if top "Go to line from top: " "Go to line: ") - :annotate (consult--line-prefix curr-line) - :category 'consult-location - :sort nil - :require-match t - ;; Always add last `isearch-string' to future history - :add-history (list (thing-at-point 'symbol) isearch-string) - :history '(:input consult--line-history) - :lookup #'consult--line-match - :default (car candidates) - ;; Add `isearch-string' as initial input if starting from Isearch - :initial (or initial - (and isearch-mode - (prog1 isearch-string (isearch-done)))) - :state (consult--location-state candidates)))) - -;;;;; Command: consult-line-multi - -(defun consult--line-multi-match (selected candidates &rest _) - "Lookup position of match. -SELECTED is the currently selected candidate. -CANDIDATES is the list of candidates." - (consult--line-point-placement selected candidates - (car (member selected candidates)))) - -(defun consult--line-multi-group (cand transform) - "Group function used by `consult-line-multi'. -If TRANSFORM non-nil, return transformed CAND, otherwise return title." - (if transform cand - (let* ((marker (car (get-text-property 0 'consult-location cand))) - (buf (if (consp marker) - (car marker) ;; Handle cheap marker - (marker-buffer marker)))) - (if buf (buffer-name buf) "Dead buffer")))) - -(defun consult--line-multi-candidates (buffers input) - "Collect matching candidates from multiple buffers. -INPUT is the user input which should be matched. -BUFFERS is the list of buffers." - (pcase-let ((`(,regexps . ,hl) - (funcall consult--regexp-compiler - input 'emacs completion-ignore-case)) - (candidates nil) - (cand-idx 0)) - (save-match-data - (dolist (buf buffers (nreverse candidates)) - (with-current-buffer buf - (save-excursion - (let ((line (line-number-at-pos (point-min) consult-line-numbers-widen))) - (goto-char (point-min)) - (while (and (not (eobp)) - (save-excursion (re-search-forward (car regexps) nil t))) - (cl-incf line (consult--count-lines (match-beginning 0))) - (let ((bol (pos-bol)) - (eol (pos-eol))) - (goto-char bol) - (when (and (not (looking-at-p "^\\s-*$")) - (seq-every-p (lambda (r) - (goto-char bol) - (re-search-forward r eol t)) - (cdr regexps))) - (push (consult--location-candidate - (funcall hl (buffer-substring-no-properties bol eol)) - (cons buf bol) (1- line) cand-idx) - candidates) - (cl-incf cand-idx)) - (goto-char (1+ eol))))))))))) - -;;;###autoload -(defun consult-line-multi (query &optional initial) - "Search for a matching line in multiple buffers. - -By default search across all project buffers. If the prefix -argument QUERY is non-nil, all buffers are searched. Optional -INITIAL input can be provided. The symbol at point and the last -`isearch-string' is added to the future history. In order to -search a subset of buffers, QUERY can be set to a plist according -to `consult--buffer-query'." - (interactive "P") - (unless (keywordp (car-safe query)) - (setq query (list :sort 'alpha-current :directory (and (not query) 'project)))) - (pcase-let* ((`(,prompt . ,buffers) (consult--buffer-query-prompt "Go to line" query)) - (collection (consult--dynamic-collection - (apply-partially #'consult--line-multi-candidates - buffers)))) - (consult--read - collection - :prompt prompt - :annotate (consult--line-prefix) - :category 'consult-location - :sort nil - :require-match t - ;; Always add last Isearch string to future history - :add-history (mapcar #'consult--async-split-initial - (delq nil (list (thing-at-point 'symbol) - isearch-string))) - :history '(:input consult--line-multi-history) - :lookup #'consult--line-multi-match - ;; Add `isearch-string' as initial input if starting from Isearch - :initial (consult--async-split-initial - (or initial - (and isearch-mode - (prog1 isearch-string (isearch-done))))) - :state (consult--location-state (lambda () (funcall collection nil))) - :group #'consult--line-multi-group))) - -;;;;; Command: consult-keep-lines - -(defun consult--keep-lines-state (filter) - "State function for `consult-keep-lines' with FILTER function." - (let ((font-lock-orig font-lock-mode) - (whitespace-orig (bound-and-true-p whitespace-mode)) - (hl-line-orig (bound-and-true-p hl-line-mode)) - (point-orig (point)) - lines content-orig replace last-input) - (if (use-region-p) - (save-restriction - ;; Use the same behavior as `keep-lines'. - (let ((rbeg (region-beginning)) - (rend (save-excursion - (goto-char (region-end)) - (unless (or (bolp) (eobp)) - (forward-line 0)) - (point)))) - (consult--fontify-region rbeg rend) - (narrow-to-region rbeg rend) - (consult--each-line beg end - (push (consult--buffer-substring beg end) lines)) - (setq content-orig (buffer-string) - replace (lambda (content &optional pos) - (delete-region rbeg rend) - (insert-before-markers content) - (goto-char (or pos rbeg)) - (setq rend (+ rbeg (length content))) - (add-face-text-property rbeg rend 'region t))))) - (consult--fontify-all) - (setq content-orig (buffer-string) - replace (lambda (content &optional pos) - (delete-region (point-min) (point-max)) - (insert content) - (goto-char (or pos (point-min))))) - (consult--each-line beg end - (push (consult--buffer-substring beg end) lines))) - (setq lines (nreverse lines)) - (lambda (action input) - ;; Restoring content and point position - (when (and (eq action 'return) last-input) - ;; No undo recording, modification hooks, buffer modified-status - (with-silent-modifications (funcall replace content-orig point-orig))) - ;; Committing or new input provided -> Update - (when (and input ;; Input has been provided - (or - ;; Committing, but not with empty input - (and (eq action 'return) (not (string-match-p "\\`!? ?\\'" input))) - ;; Input has changed - (not (equal input last-input)))) - (let ((filtered-content - (if (string-match-p "\\`!? ?\\'" input) - ;; Special case the empty input for performance. - ;; Otherwise it could happen that the minibuffer is empty, - ;; but the buffer has not been updated. - content-orig - (if (eq action 'return) - (apply #'concat (mapcan (lambda (x) (list x "\n")) - (funcall filter input lines))) - (while-no-input - ;; Heavy computation is interruptible if *not* committing! - ;; Allocate new string candidates since the matching function mutates! - (apply #'concat (mapcan (lambda (x) (list x "\n")) - (funcall filter input (mapcar #'copy-sequence lines))))))))) - (when (stringp filtered-content) - (when font-lock-mode (font-lock-mode -1)) - (when (bound-and-true-p whitespace-mode) (whitespace-mode -1)) - (when (bound-and-true-p hl-line-mode) (hl-line-mode -1)) - (if (eq action 'return) - (atomic-change-group - ;; Disable modification hooks for performance - (let ((inhibit-modification-hooks t)) - (funcall replace filtered-content))) - ;; No undo recording, modification hooks, buffer modified-status - (with-silent-modifications - (funcall replace filtered-content) - (setq last-input input)))))) - ;; Restore modes - (when (eq action 'return) - (when hl-line-orig (hl-line-mode 1)) - (when whitespace-orig (whitespace-mode 1)) - (when font-lock-orig (font-lock-mode 1)))))) - -;;;###autoload -(defun consult-keep-lines (filter &optional initial) - "Select a subset of the lines in the current buffer with live preview. - -The selected lines are kept and the other lines are deleted. When called -interactively, the lines selected are those that match the minibuffer input. In -order to match the inverse of the input, prefix the input with `! '. When -called from Elisp, the filtering is performed by a FILTER function. This -command obeys narrowing. - -FILTER is the filter function. -INITIAL is the initial input." - (interactive - (list (lambda (pattern cands) - ;; Use consult-location completion category when filtering lines - (consult--completion-filter-dispatch - pattern cands 'consult-location 'highlight)))) - (consult--forbid-minibuffer) - (let ((ro buffer-read-only)) - (unwind-protect - (consult--minibuffer-with-setup-hook - (lambda () - (when ro - (minibuffer-message - (substitute-command-keys - " [Unlocked read-only buffer. \\[minibuffer-keyboard-quit] to quit.]")))) - (setq buffer-read-only nil) - (consult--with-increased-gc - (consult--prompt - :prompt "Keep lines: " - :initial initial - :history 'consult--line-history - :state (consult--keep-lines-state filter)))) - (setq buffer-read-only ro)))) - -;;;;; Command: consult-focus-lines - -(defun consult--focus-lines-state (filter) - "State function for `consult-focus-lines' with FILTER function." - (let (lines overlays last-input pt-orig pt-min pt-max) - (save-excursion - (save-restriction - (if (not (use-region-p)) - (consult--fontify-all) - (consult--fontify-region (region-beginning) (region-end)) - (narrow-to-region - (region-beginning) - ;; Behave the same as `keep-lines'. - ;; Move to the next line. - (save-excursion - (goto-char (region-end)) - (unless (or (bolp) (eobp)) - (forward-line 0)) - (point)))) - (setq pt-orig (point) pt-min (point-min) pt-max (point-max)) - (let ((i 0)) - (consult--each-line beg end - ;; Use "\n" for empty lines, since we need a non-empty string to - ;; attach the text property to. - (let ((line (if (eq beg end) (char-to-string ?\n) - (buffer-substring-no-properties beg end)))) - (put-text-property 0 1 'consult--focus-line (cons (cl-incf i) beg) line) - (push line lines))) - (setq lines (nreverse lines))))) - (lambda (action input) - ;; New input provided -> Update - (when (and input (not (equal input last-input))) - (let (new-overlays) - (pcase (while-no-input - (unless (string-match-p "\\`!? ?\\'" input) ;; Empty input. - (let* ((inhibit-quit (eq action 'return)) ;; Non interruptible, when quitting! - (not (string-prefix-p "! " input)) - (stripped (string-remove-prefix "! " input)) - (matches (funcall filter stripped lines)) - (old-ind 0) - (block-beg pt-min) - (block-end pt-min)) - (while old-ind - (let ((match (pop matches)) (ind nil) (beg pt-max) (end pt-max) prop) - (when match - (setq prop (get-text-property 0 'consult--focus-line match) - ind (car prop) - beg (cdr prop) - ;; Check for empty lines, see above. - end (+ 1 beg (if (equal match "\n") 0 (length match))))) - (unless (eq ind (1+ old-ind)) - (let ((a (if not block-beg block-end)) - (b (if not block-end beg))) - (when (/= a b) - (push (consult--make-overlay a b 'invisible t) new-overlays))) - (setq block-beg beg)) - (setq block-end end old-ind ind))))) - 'commit) - ('commit - (mapc #'delete-overlay overlays) - (setq last-input input overlays new-overlays)) - (_ (mapc #'delete-overlay new-overlays))))) - (when (eq action 'return) - (cond - ((not input) - (mapc #'delete-overlay overlays) - (goto-char pt-orig)) - ((equal input "") - (consult-focus-lines nil 'show) - (goto-char pt-orig)) - (t - ;; Successfully terminated -> Remember invisible overlays - (setq consult--focus-lines-overlays - (nconc consult--focus-lines-overlays overlays)) - ;; move point past invisible - (goto-char (if-let (ov (and (invisible-p pt-orig) - (seq-find (lambda (ov) (overlay-get ov 'invisible)) - (overlays-at pt-orig)))) - (overlay-end ov) - pt-orig)))))))) - -;;;###autoload -(defun consult-focus-lines (filter &optional show initial) - "Hide or show lines using overlays. - -The selected lines are shown and the other lines hidden. When called -interactively, the lines selected are those that match the minibuffer input. In -order to match the inverse of the input, prefix the input with `! '. With -optional prefix argument SHOW reveal the hidden lines. Alternatively the -command can be restarted to reveal the lines. When called from Elisp, the -filtering is performed by a FILTER function. This command obeys narrowing. - -FILTER is the filter function. -INITIAL is the initial input." - (interactive - (list (lambda (pattern cands) - ;; Use consult-location completion category when filtering lines - (consult--completion-filter-dispatch - pattern cands 'consult-location nil)) - current-prefix-arg)) - (if show - (progn - (mapc #'delete-overlay consult--focus-lines-overlays) - (setq consult--focus-lines-overlays nil) - (message "All lines revealed")) - (consult--forbid-minibuffer) - (consult--with-increased-gc - (consult--prompt - :prompt - (if consult--focus-lines-overlays - "Focus on lines (RET to reveal): " - "Focus on lines: ") - :initial initial - :history 'consult--line-history - :state (consult--focus-lines-state filter))))) - -;;;;; Command: consult-goto-line - -(defun consult--goto-line-position (str msg) - "Transform input STR to line number. -Print an error message with MSG function." - (save-match-data - (if (and str (string-match "\\`\\([[:digit:]]+\\):?\\([[:digit:]]*\\)\\'" str)) - (let ((line (string-to-number (match-string 1 str))) - (col (string-to-number (match-string 2 str)))) - (save-excursion - (save-restriction - (when consult-line-numbers-widen - (widen)) - (goto-char (point-min)) - (forward-line (1- line)) - (goto-char (min (+ (point) col) (pos-eol))) - (point)))) - (when (and str (not (equal str ""))) - (funcall msg "Please enter a number.")) - nil))) - -;;;###autoload -(defun consult-goto-line (&optional arg) - "Read line number and jump to the line with preview. - -Enter either a line number to jump to the first column of the -given line or line:column in order to jump to a specific column. -Jump directly if a line number is given as prefix ARG. The -command respects narrowing and the settings -`consult-goto-line-numbers' and `consult-line-numbers-widen'." - (interactive "P") - (if arg - (call-interactively #'goto-line) - (consult--forbid-minibuffer) - (consult--local-let ((display-line-numbers consult-goto-line-numbers) - (display-line-numbers-widen consult-line-numbers-widen)) - (while (if-let (pos (consult--goto-line-position - (consult--prompt - :prompt "Go to line: " - :history 'goto-line-history - :state - (let ((preview (consult--jump-preview))) - (lambda (action str) - (funcall preview action - (consult--goto-line-position str #'ignore))))) - #'minibuffer-message)) - (consult--jump pos) - t))))) - -;;;;; Command: consult-recent-file - -(defun consult--file-preview () - "Create preview function for files." - (let ((open (consult--temporary-files)) - (preview (consult--buffer-preview))) - (lambda (action cand) - (unless cand - (funcall open)) - (funcall preview action - (and cand - (eq action 'preview) - (funcall open cand)))))) - -(defun consult--file-action (file) - "Open FILE via `consult--buffer-action'." - ;; Try to preserve the buffer as is, if it has already been opened, for - ;; example in literal or raw mode. - (setq file (abbreviate-file-name (expand-file-name file))) - (consult--buffer-action (or (get-file-buffer file) (find-file-noselect file)))) - -(consult--define-state file) - -;;;###autoload -(defun consult-recent-file () - "Find recent file using `completing-read'." - (interactive) - (find-file - (consult--read - (or - (mapcar #'consult--fast-abbreviate-file-name (bound-and-true-p recentf-list)) - (user-error "No recent files, `recentf-mode' is %s" - (if recentf-mode "enabled" "disabled"))) - :prompt "Find recent file: " - :sort nil - :require-match t - :category 'file - :state (consult--file-preview) - :history 'file-name-history))) - -;;;;; Command: consult-mode-command - -(defun consult--mode-name (mode) - "Return name part of MODE." - (replace-regexp-in-string - "global-\\(.*\\)-mode" "\\1" - (replace-regexp-in-string - "\\(-global\\)?-mode\\'" "" - (if (eq mode 'c-mode) - "cc" - (symbol-name mode)) - 'fixedcase) - 'fixedcase)) - -(defun consult--mode-command-candidates (modes) - "Extract commands from MODES. - -The list of features is searched for files belonging to the modes. -From these files, the commands are extracted." - (let* ((case-fold-search) - (buffer (current-buffer)) - (command-filter (consult--regexp-filter (seq-filter #'stringp consult-mode-command-filter))) - (feature-filter (seq-filter #'symbolp consult-mode-command-filter)) - (minor-hash (consult--string-hash minor-mode-list)) - (minor-local-modes (seq-filter (lambda (m) - (and (gethash m minor-hash) - (local-variable-if-set-p m))) - modes)) - (minor-global-modes (seq-filter (lambda (m) - (and (gethash m minor-hash) - (not (local-variable-if-set-p m)))) - modes)) - (major-modes (seq-remove (lambda (m) - (gethash m minor-hash)) - modes)) - (major-paths-hash (consult--string-hash (mapcar #'symbol-file major-modes))) - (minor-local-paths-hash (consult--string-hash (mapcar #'symbol-file minor-local-modes))) - (minor-global-paths-hash (consult--string-hash (mapcar #'symbol-file minor-global-modes))) - (major-name-regexp (regexp-opt (mapcar #'consult--mode-name major-modes))) - (minor-local-name-regexp (regexp-opt (mapcar #'consult--mode-name minor-local-modes))) - (minor-global-name-regexp (regexp-opt (mapcar #'consult--mode-name minor-global-modes))) - (commands)) - (dolist (feature load-history commands) - (when-let (name (alist-get 'provide feature)) - (let* ((path (car feature)) - (file (file-name-nondirectory path)) - (key (cond - ((memq name feature-filter) nil) - ((or (gethash path major-paths-hash) - (string-match-p major-name-regexp file)) - ?m) - ((or (gethash path minor-local-paths-hash) - (string-match-p minor-local-name-regexp file)) - ?l) - ((or (gethash path minor-global-paths-hash) - (string-match-p minor-global-name-regexp file)) - ?g)))) - (when key - (dolist (cmd (cdr feature)) - (let ((sym (cdr-safe cmd))) - (when (and (consp cmd) - (eq (car cmd) 'defun) - (commandp sym) - (not (get sym 'byte-obsolete-info)) - ;; Emacs 28 has a `read-extended-command-predicate' - (if (bound-and-true-p read-extended-command-predicate) - (funcall read-extended-command-predicate sym buffer) - t)) - (let ((name (symbol-name sym))) - (unless (string-match-p command-filter name) - (push (propertize name - 'consult--candidate sym - 'consult--type key) - commands)))))))))))) - -;;;###autoload -(defun consult-mode-command (&rest modes) - "Run a command from any of the given MODES. - -If no MODES are specified, use currently active major and minor modes." - (interactive) - (unless modes - (setq modes (cons major-mode - (seq-filter (lambda (m) - (and (boundp m) (symbol-value m))) - minor-mode-list)))) - (let ((narrow `((?m . ,(format "Major: %s" major-mode)) - (?l . "Local Minor") - (?g . "Global Minor")))) - (command-execute - (consult--read - (consult--mode-command-candidates modes) - :prompt "Mode command: " - :predicate - (lambda (cand) - (let ((key (get-text-property 0 'consult--type cand))) - (if consult--narrow - (= key consult--narrow) - (/= key ?g)))) - :lookup #'consult--lookup-candidate - :group (consult--type-group narrow) - :narrow narrow - :require-match t - :history 'extended-command-history - :category 'command)))) - -;;;;; Command: consult-yank - -(defun consult--read-from-kill-ring () - "Open kill ring menu and return selected string." - ;; `current-kill' updates `kill-ring' with interprogram paste, see - ;; gh:minad/consult#443. - (current-kill 0) - ;; Do not specify a :lookup function in order to preserve completion-styles - ;; highlighting of the current candidate. We have to perform a final lookup to - ;; obtain the original candidate which may be propertized with yank-specific - ;; properties, like 'yank-handler. - (consult--lookup-member - (consult--read - (consult--remove-dups - (or (if consult-yank-rotate - (append kill-ring-yank-pointer - (butlast kill-ring (length kill-ring-yank-pointer))) - kill-ring) - (user-error "Kill ring is empty"))) - :prompt "Yank from kill-ring: " - :history t ;; disable history - :sort nil - :category 'kill-ring - :require-match t - :state - (consult--insertion-preview - (point) - ;; If previous command is yank, hide previously yanked string - (or (and (eq last-command 'yank) (mark t)) (point)))) - kill-ring)) - -;; Adapted from the Emacs `yank-from-kill-ring' function. -;;;###autoload -(defun consult-yank-from-kill-ring (string &optional arg) - "Select STRING from the kill ring and insert it. -With prefix ARG, put point at beginning, and mark at end, like `yank' does. - -This command behaves like `yank-from-kill-ring' in Emacs 28, which also offers -a `completing-read' interface to the `kill-ring'. Additionally the Consult -version supports preview of the selected string." - (interactive (list (consult--read-from-kill-ring) current-prefix-arg)) - (when string - (setq yank-window-start (window-start)) - (push-mark) - (insert-for-yank string) - (setq this-command 'yank) - (when consult-yank-rotate - (if-let (pos (seq-position kill-ring string)) - (setq kill-ring-yank-pointer (nthcdr pos kill-ring)) - (kill-new string))) - (when (consp arg) - ;; Swap point and mark like in `yank'. - (goto-char (prog1 (mark t) - (set-marker (mark-marker) (point) (current-buffer))))))) - -(put 'consult-yank-replace 'delete-selection 'yank) -(put 'consult-yank-pop 'delete-selection 'yank) -(put 'consult-yank-from-kill-ring 'delete-selection 'yank) - -;;;###autoload -(defun consult-yank-pop (&optional arg) - "If there is a recent yank act like `yank-pop'. - -Otherwise select string from the kill ring and insert it. -See `yank-pop' for the meaning of ARG. - -This command behaves like `yank-pop' in Emacs 28, which also offers a -`completing-read' interface to the `kill-ring'. Additionally the Consult -version supports preview of the selected string." - (interactive "*p") - (if (eq last-command 'yank) - (yank-pop (or arg 1)) - (call-interactively #'consult-yank-from-kill-ring))) - -;; Adapted from the Emacs yank-pop function. -;;;###autoload -(defun consult-yank-replace (string) - "Select STRING from the kill ring. - -If there was no recent yank, insert the string. -Otherwise replace the just-yanked string with the selected string. - -There exists no equivalent of this command in Emacs 28." - (interactive (list (consult--read-from-kill-ring))) - (when string - (if (not (eq last-command 'yank)) - (consult-yank-from-kill-ring string) - (let ((inhibit-read-only t) - (pt (point)) - (mk (mark t))) - (setq this-command 'yank) - (funcall (or yank-undo-function 'delete-region) (min pt mk) (max pt mk)) - (setq yank-undo-function nil) - (set-marker (mark-marker) pt (current-buffer)) - (insert-for-yank string) - (set-window-start (selected-window) yank-window-start t) - (if (< pt mk) - (goto-char (prog1 (mark t) - (set-marker (mark-marker) (point) (current-buffer))))))))) - -;;;;; Command: consult-bookmark - -(defun consult--bookmark-preview () - "Create preview function for bookmarks." - (let ((preview (consult--jump-preview)) - (open (consult--temporary-files))) - (lambda (action cand) - (unless cand - (funcall open)) - (funcall - preview action - ;; Only preview bookmarks with the default handler. - (when-let ((bm (and cand (eq action 'preview) (assoc cand bookmark-alist))) - (handler (or (bookmark-get-handler bm) #'bookmark-default-handler)) - ((eq handler #'bookmark-default-handler)) - (file (bookmark-get-filename bm)) - (pos (bookmark-get-position bm)) - (buf (funcall open file))) - (set-marker (make-marker) pos buf)))))) - -(defun consult--bookmark-action (bm) - "Open BM via `consult--buffer-action'." - (bookmark-jump bm consult--buffer-display)) - -(consult--define-state bookmark) - -(defun consult--bookmark-candidates () - "Return bookmark candidates." - (bookmark-maybe-load-default-file) - (let ((narrow (cl-loop for (y _ . xs) in consult-bookmark-narrow nconc - (cl-loop for x in xs collect (cons x y))))) - (cl-loop for bm in bookmark-alist collect - (propertize (car bm) - 'consult--type - (alist-get - (or (bookmark-get-handler bm) #'bookmark-default-handler) - narrow))))) - -;;;###autoload -(defun consult-bookmark (name) - "If bookmark NAME exists, open it, otherwise create a new bookmark with NAME. - -The command supports preview of file bookmarks and narrowing. See the -variable `consult-bookmark-narrow' for the narrowing configuration." - (interactive - (list - (let ((narrow (cl-loop for (x y . _) in consult-bookmark-narrow collect (cons x y)))) - (consult--read - (consult--bookmark-candidates) - :prompt "Bookmark: " - :state (consult--bookmark-preview) - :category 'bookmark - :history 'bookmark-history - ;; Add default names to future history. - ;; Ignore errors such that `consult-bookmark' can be used in - ;; buffers which are not backed by a file. - :add-history (ignore-errors (bookmark-prop-get (bookmark-make-record) 'defaults)) - :group (consult--type-group narrow) - :narrow (consult--type-narrow narrow))))) - (bookmark-maybe-load-default-file) - (if (assoc name bookmark-alist) - (bookmark-jump name) - (bookmark-set name))) - -;;;;; Command: consult-complex-command - -;;;###autoload -(defun consult-complex-command () - "Select and evaluate command from the command history. - -This command can act as a drop-in replacement for `repeat-complex-command'." - (interactive) - (let* ((history (or (delete-dups (mapcar #'prin1-to-string command-history)) - (user-error "There are no previous complex commands"))) - (cmd (read (consult--read - history - :prompt "Command: " - :default (car history) - :sort nil - :history t ;; disable history - :category 'expression)))) - ;; Taken from `repeat-complex-command' - (add-to-history 'command-history cmd) - (apply #'funcall-interactively - (car cmd) - (mapcar (lambda (e) (eval e t)) (cdr cmd))))) - -;;;;; Command: consult-history - -(declare-function ring-elements "ring") - -(defun consult--current-history () - "Return the history and index variable relevant to the current buffer. -If the minibuffer is active, the minibuffer history is returned, -otherwise the history corresponding to the mode. There is a -special case for `repeat-complex-command', for which the command -history is used." - (cond - ;; In the minibuffer we use the current minibuffer history, - ;; which can be configured by setting `minibuffer-history-variable'. - ((minibufferp) - (when (eq minibuffer-history-variable t) - (user-error "Minibuffer history is disabled for `%s'" this-command)) - (list (mapcar #'consult--tofu-hide - (if (eq minibuffer-history-variable 'command-history) - ;; If pressing "C-x M-:", i.e., `repeat-complex-command', - ;; we are instead querying the `command-history' and get a - ;; full s-expression. Alternatively you might want to use - ;; `consult-complex-command', which can also be bound to - ;; "C-x M-:"! - (mapcar #'prin1-to-string command-history) - (symbol-value minibuffer-history-variable))))) - ;; Otherwise we use a mode-specific history, see `consult-mode-histories'. - (t (let ((found (seq-find (lambda (h) - (and (derived-mode-p (car h)) - (boundp (if (consp (cdr h)) (cadr h) (cdr h))))) - consult-mode-histories))) - (unless found - (user-error "No history configured for `%s', see `consult-mode-histories'" - major-mode)) - (cons (symbol-value (cadr found)) (cddr found)))))) - -;;;###autoload -(defun consult-history (&optional history index bol) - "Insert string from HISTORY of current buffer. -In order to select from a specific HISTORY, pass the history -variable as argument. INDEX is the name of the index variable to -update, if any. BOL is the function which jumps to the beginning -of the prompt. See also `cape-history' from the Cape package." - (interactive) - (pcase-let* ((`(,history ,index ,bol) (if history - (list history index bol) - (consult--current-history))) - (history (if (ring-p history) (ring-elements history) history)) - (`(,beg . ,end) - (if (minibufferp) - (cons (minibuffer-prompt-end) (point-max)) - (if bol - (save-excursion - (funcall bol) - (cons (point) (pos-eol))) - (cons (point) (point))))) - (str (consult--local-let ((enable-recursive-minibuffers t)) - (consult--read - (or (consult--remove-dups history) - (user-error "History is empty")) - :prompt "History: " - :history t ;; disable history - :category ;; Report category depending on history variable - (and (minibufferp) - (pcase minibuffer-history-variable - ('extended-command-history 'command) - ('buffer-name-history 'buffer) - ('face-name-history 'face) - ('read-envvar-name-history 'environment-variable) - ('bookmark-history 'bookmark) - ('file-name-history 'file))) - :sort nil - :initial (buffer-substring-no-properties beg end) - :state (consult--insertion-preview beg end))))) - (delete-region beg end) - (when index - (set index (seq-position history str))) - (insert (substring-no-properties str)))) - -;;;;; Command: consult-isearch-history - -(defun consult-isearch-forward (&optional reverse) - "Continue Isearch forward optionally in REVERSE." - (interactive) - (consult--require-minibuffer) - (setq isearch-new-forward (not reverse) isearch-new-nonincremental nil) - (funcall (or (command-remapping #'exit-minibuffer) #'exit-minibuffer))) - -(defun consult-isearch-backward (&optional reverse) - "Continue Isearch backward optionally in REVERSE." - (interactive) - (consult-isearch-forward (not reverse))) - -;; Emacs 28: hide in M-X -(put #'consult-isearch-backward 'completion-predicate #'ignore) -(put #'consult-isearch-forward 'completion-predicate #'ignore) - -(defvar-keymap consult-isearch-history-map - :doc "Additional keymap used by `consult-isearch-history'." - "<remap> <isearch-forward>" #'consult-isearch-forward - "<remap> <isearch-backward>" #'consult-isearch-backward) - -(defun consult--isearch-history-candidates () - "Return Isearch history candidates." - ;; Do not throw an error on empty history, in order to allow starting a - ;; search. We do not :require-match here. - (let ((history (if (eq t search-default-mode) - (append regexp-search-ring search-ring) - (append search-ring regexp-search-ring)))) - (delete-dups - (mapcar - (lambda (cand) - ;; The search type can be distinguished via text properties. - (let* ((props (plist-member (text-properties-at 0 cand) - 'isearch-regexp-function)) - (type (pcase (cadr props) - ((and 'nil (guard (not props))) ?r) - ('nil ?l) - ('word-search-regexp ?w) - ('isearch-symbol-regexp ?s) - ('char-fold-to-regexp ?c) - (_ ?u)))) - ;; Disambiguate history items. The same string could - ;; occur with different search types. - (consult--tofu-append cand type))) - history)))) - -(defconst consult--isearch-history-narrow - '((?c . "Char") - (?u . "Custom") - (?l . "Literal") - (?r . "Regexp") - (?s . "Symbol") - (?w . "Word"))) - -;;;###autoload -(defun consult-isearch-history () - "Read a search string with completion from the Isearch history. - -This replaces the current search string if Isearch is active, and -starts a new Isearch session otherwise." - (interactive) - (consult--forbid-minibuffer) - (let* ((isearch-message-function #'ignore) - (cursor-in-echo-area t) ;; Avoid cursor flickering - (candidates (consult--isearch-history-candidates))) - (unless isearch-mode (isearch-mode t)) - (with-isearch-suspended - (setq isearch-new-string - (consult--read - candidates - :prompt "I-search: " - :category 'consult-isearch-history - :history t ;; disable history - :sort nil - :initial isearch-string - :keymap consult-isearch-history-map - :annotate - (lambda (cand) - (consult--annotate-align - cand - (alist-get (consult--tofu-get cand) consult--isearch-history-narrow))) - :group - (lambda (cand transform) - (if transform - cand - (alist-get (consult--tofu-get cand) consult--isearch-history-narrow))) - :lookup - (lambda (selected candidates &rest _) - (if-let (found (member selected candidates)) - (substring (car found) 0 -1) - selected)) - :state - (lambda (action cand) - (when (and (eq action 'preview) cand) - (setq isearch-string cand) - (isearch-update-from-string-properties cand) - (isearch-update))) - :narrow - (list :predicate - (lambda (cand) (= (consult--tofu-get cand) consult--narrow)) - :keys consult--isearch-history-narrow)) - isearch-new-message - (mapconcat 'isearch-text-char-description isearch-new-string ""))) - ;; Setting `isearch-regexp' etc only works outside of `with-isearch-suspended'. - (unless (plist-member (text-properties-at 0 isearch-string) 'isearch-regexp-function) - (setq isearch-regexp t - isearch-regexp-function nil)))) - -;;;;; Command: consult-minor-mode-menu - -(defun consult--minor-mode-candidates () - "Return list of minor-mode candidate strings." - (mapcar - (pcase-lambda (`(,name . ,sym)) - (propertize - name - 'consult--candidate sym - 'consult--minor-mode-narrow - (logior - (ash (if (local-variable-if-set-p sym) ?l ?g) 8) - (if (and (boundp sym) (symbol-value sym)) ?i ?o)) - 'consult--minor-mode-group - (concat - (if (local-variable-if-set-p sym) "Local " "Global ") - (if (and (boundp sym) (symbol-value sym)) "On" "Off")))) - (nconc - ;; according to describe-minor-mode-completion-table-for-symbol - ;; the minor-mode-list contains *all* minor modes - (mapcar (lambda (sym) (cons (symbol-name sym) sym)) minor-mode-list) - ;; take the lighters from minor-mode-alist - (delq nil - (mapcar (pcase-lambda (`(,sym ,lighter)) - (when (and lighter (not (equal "" lighter))) - (let (message-log-max) - (setq lighter (string-trim (format-mode-line lighter))) - (unless (string-blank-p lighter) - (cons lighter sym))))) - minor-mode-alist))))) - -(defconst consult--minor-mode-menu-narrow - '((?l . "Local") - (?g . "Global") - (?i . "On") - (?o . "Off"))) - -;;;###autoload -(defun consult-minor-mode-menu () - "Enable or disable minor mode. - -This is an alternative to `minor-mode-menu-from-indicator'." - (interactive) - (call-interactively - (consult--read - (consult--minor-mode-candidates) - :prompt "Minor mode: " - :require-match t - :category 'minor-mode - :group - (lambda (cand transform) - (if transform cand (get-text-property 0 'consult--minor-mode-group cand))) - :narrow - (list :predicate - (lambda (cand) - (let ((narrow (get-text-property 0 'consult--minor-mode-narrow cand))) - (or (= (logand narrow 255) consult--narrow) - (= (ash narrow -8) consult--narrow)))) - :keys - consult--minor-mode-menu-narrow) - :lookup #'consult--lookup-candidate - :history 'consult--minor-mode-menu-history))) - -;;;;; Command: consult-theme - -;;;###autoload -(defun consult-theme (theme) - "Disable current themes and enable THEME from `consult-themes'. - -The command supports previewing the currently selected theme." - (interactive - (list - (let* ((regexp (consult--regexp-filter - (mapcar (lambda (x) (if (stringp x) x (format "\\`%s\\'" x))) - consult-themes))) - (avail-themes (seq-filter - (lambda (x) (string-match-p regexp (symbol-name x))) - (cons 'default (custom-available-themes)))) - (saved-theme (car custom-enabled-themes))) - (consult--read - (mapcar #'symbol-name avail-themes) - :prompt "Theme: " - :require-match t - :category 'theme - :history 'consult--theme-history - :lookup (lambda (selected &rest _) - (setq selected (and selected (intern-soft selected))) - (or (and selected (car (memq selected avail-themes))) - saved-theme)) - :state (lambda (action theme) - (pcase action - ('return (consult-theme (or theme saved-theme))) - ((and 'preview (guard theme)) (consult-theme theme)))) - :default (symbol-name (or saved-theme 'default)))))) - (when (eq theme 'default) (setq theme nil)) - (unless (eq theme (car custom-enabled-themes)) - (mapc #'disable-theme custom-enabled-themes) - (when theme - (if (custom-theme-p theme) - (enable-theme theme) - (load-theme theme :no-confirm))))) - -;;;;; Command: consult-buffer - -(defun consult--buffer-sort-alpha (buffers) - "Sort BUFFERS alphabetically, put starred buffers at the end." - (sort buffers - (lambda (x y) - (setq x (buffer-name x) y (buffer-name y)) - (let ((a (and (length> x 0) (eq (aref x 0) ?*))) - (b (and (length> y 0) (eq (aref y 0) ?*)))) - (if (eq a b) - (string< x y) - (not a)))))) - -(defun consult--buffer-sort-alpha-current (buffers) - "Sort BUFFERS alphabetically, put current at the beginning." - (let ((buffers (consult--buffer-sort-alpha buffers)) - (current (current-buffer))) - (if (memq current buffers) - (cons current (delq current buffers)) - buffers))) - -(defun consult--buffer-sort-visibility (buffers) - "Sort BUFFERS by visibility." - (let ((hidden) - (current (car (memq (current-buffer) buffers)))) - (consult--keep! buffers - (unless (eq it current) - (if (get-buffer-window it 'visible) - it - (push it hidden) - nil))) - (nconc (nreverse hidden) buffers (and current (list current))))) - -(defun consult--normalize-directory (dir) - "Normalize directory DIR. -DIR can be project, nil or a path." - (cond - ((eq dir 'project) (consult--project-root)) - (dir (expand-file-name dir)))) - -(defun consult--buffer-query-prompt (prompt query) - "Return a list of buffers and create an appropriate prompt string. -Return a pair of a prompt string and a list of buffers. PROMPT -is the prefix of the prompt string. QUERY specifies the buffers -to search and is passed to `consult--buffer-query'." - (let* ((dir (plist-get query :directory)) - (ndir (consult--normalize-directory dir)) - (buffers (apply #'consult--buffer-query :directory ndir query)) - (count (length buffers))) - (cons (format "%s (%d buffer%s%s): " prompt count - (if (= count 1) "" "s") - (cond - ((and ndir (eq dir 'project)) - (format ", Project %s" (consult--project-name ndir))) - (ndir (concat ", " (consult--left-truncate-file ndir))) - (t ""))) - buffers))) - -(cl-defun consult--buffer-query (&key sort directory mode as predicate (filter t) - include (exclude consult-buffer-filter) - (buffer-list t)) - "Query for a list of matching buffers. -The function supports filtering by various criteria which are -used throughout Consult. In particular it is the backbone of -most `consult-buffer-sources'. -DIRECTORY can either be the symbol project or a file name. -SORT can be visibility, alpha or nil. -FILTER can be either t, nil or invert. -EXCLUDE is a list of regexps. -INCLUDE is a list of regexps. -MODE can be a mode or a list of modes to restrict the returned buffers. -PREDICATE is a predicate function. -BUFFER-LIST is the unfiltered list of buffers. -AS is a conversion function." - (let ((root (consult--normalize-directory directory))) - (setq buffer-list (if (eq buffer-list t) (buffer-list) (copy-sequence buffer-list))) - (when sort - (setq buffer-list (funcall (intern (format "consult--buffer-sort-%s" sort)) buffer-list))) - (when (or filter mode as root) - (let ((exclude-re (consult--regexp-filter exclude)) - (include-re (consult--regexp-filter include)) - (case-fold-search)) - (consult--keep! buffer-list - (and - (or (not mode) - (let ((mm (buffer-local-value 'major-mode it))) - (if (consp mode) - (seq-some (lambda (m) (provided-mode-derived-p mm m)) mode) - (provided-mode-derived-p mm mode)))) - (pcase-exhaustive filter - ('nil t) - ((or 't 'invert) - (eq (eq filter t) - (and - (or (not exclude) - (not (string-match-p exclude-re (buffer-name it)))) - (or (not include) - (not (not (string-match-p include-re (buffer-name it))))))))) - (or (not root) - (when-let (dir (buffer-local-value 'default-directory it)) - (string-prefix-p root - (if (and (/= 0 (length dir)) (eq (aref dir 0) ?/)) - dir - (expand-file-name dir))))) - (or (not predicate) (funcall predicate it)) - (if as (funcall as it) it))))) - buffer-list)) - -(defun consult--buffer-file-hash () - "Return hash table of all buffer file names." - (consult--string-hash (consult--buffer-query :as #'buffer-file-name))) - -(defun consult--buffer-pair (buffer) - "Return a pair of name of BUFFER and BUFFER." - (cons (buffer-name buffer) buffer)) - -(defun consult--buffer-preview () - "Buffer preview function." - (let ((orig-buf (window-buffer (consult--original-window))) - (orig-prev (copy-sequence (window-prev-buffers))) - (orig-next (copy-sequence (window-next-buffers))) - other-win) - (lambda (action cand) - (pcase action - ('exit - (set-window-prev-buffers other-win orig-prev) - (set-window-next-buffers other-win orig-next)) - ('preview - (when (and (eq consult--buffer-display #'switch-to-buffer-other-window) - (not other-win)) - (switch-to-buffer-other-window orig-buf 'norecord) - (setq other-win (selected-window))) - (let ((win (or other-win (selected-window))) - (buf (or (and cand (get-buffer cand)) orig-buf))) - (when (and (window-live-p win) (buffer-live-p buf)) - (with-selected-window win - (unless (or orig-prev orig-next) - (setq orig-prev (copy-sequence (window-prev-buffers)) - orig-next (copy-sequence (window-next-buffers)))) - (switch-to-buffer buf 'norecord))))))))) - -(defun consult--buffer-action (buffer &optional norecord) - "Switch to BUFFER via `consult--buffer-display' function. -If NORECORD is non-nil, do not record the buffer switch in the buffer list." - (funcall consult--buffer-display buffer norecord)) - -(consult--define-state buffer) - -(defvar consult--source-bookmark - `(:name "Bookmark" - :narrow ?m - :category bookmark - :face consult-bookmark - :history bookmark-history - :items ,#'bookmark-all-names - :state ,#'consult--bookmark-state) - "Bookmark candidate source for `consult-buffer'.") - -(defvar consult--source-project-buffer - `(:name "Project Buffer" - :narrow ?b - :category buffer - :face consult-buffer - :history buffer-name-history - :state ,#'consult--buffer-state - :enabled ,(lambda () consult-project-function) - :items - ,(lambda () - (when-let (root (consult--project-root)) - (consult--buffer-query :sort 'visibility - :directory root - :as #'consult--buffer-pair)))) - "Project buffer candidate source for `consult-buffer'.") - -(defvar consult--source-project-recent-file - `(:name "Project File" - :narrow ?f - :category file - :face consult-file - :history file-name-history - :state ,#'consult--file-state - :new - ,(lambda (file) - (consult--file-action - (expand-file-name file (consult--project-root)))) - :enabled - ,(lambda () - (and consult-project-function - recentf-mode)) - :items - ,(lambda () - (when-let (root (consult--project-root)) - (let ((len (length root)) - (ht (consult--buffer-file-hash)) - items) - (dolist (file (bound-and-true-p recentf-list) (nreverse items)) - ;; Emacs 29 abbreviates file paths by default, see - ;; `recentf-filename-handlers'. I recommend to set - ;; `recentf-filename-handlers' to nil to avoid any slow down. - (unless (eq (aref file 0) ?/) - (let (file-name-handler-alist) ;; No Tramp slowdown please. - (setq file (expand-file-name file)))) - (when (and (not (gethash file ht)) (string-prefix-p root file)) - (let ((part (substring file len))) - (when (equal part "") (setq part "./")) - (put-text-property 0 1 'multi-category `(file . ,file) part) - (push part items)))))))) - "Project file candidate source for `consult-buffer'.") - -(defvar consult--source-project-buffer-hidden - `(:hidden t :narrow (?p . "Project") ,@consult--source-project-buffer) - "Like `consult--source-project-buffer' but hidden by default.") - -(defvar consult--source-project-recent-file-hidden - `(:hidden t :narrow (?p . "Project") ,@consult--source-project-recent-file) - "Like `consult--source-project-recent-file' but hidden by default.") - -(defvar consult--source-hidden-buffer - `(:name "Hidden Buffer" - :narrow ?\s - :hidden t - :category buffer - :face consult-buffer - :history buffer-name-history - :action ,#'consult--buffer-action - :items - ,(lambda () (consult--buffer-query :sort 'visibility - :filter 'invert - :as #'consult--buffer-pair))) - "Hidden buffer candidate source for `consult-buffer'.") - -(defvar consult--source-modified-buffer - `(:name "Modified Buffer" - :narrow ?* - :hidden t - :category buffer - :face consult-buffer - :history buffer-name-history - :state ,#'consult--buffer-state - :items - ,(lambda () (consult--buffer-query :sort 'visibility - :as #'consult--buffer-pair - :predicate - (lambda (buf) - (and (buffer-modified-p buf) - (buffer-file-name buf)))))) - "Modified buffer candidate source for `consult-buffer'.") - -(defvar consult--source-buffer - `(:name "Buffer" - :narrow ?b - :category buffer - :face consult-buffer - :history buffer-name-history - :state ,#'consult--buffer-state - :default t - :items - ,(lambda () (consult--buffer-query :sort 'visibility - :as #'consult--buffer-pair))) - "Buffer candidate source for `consult-buffer'.") - -(defun consult--file-register-p (reg) - "Return non-nil if REG is a file register." - (memq (car-safe (cdr reg)) '(file-query file))) - -(autoload 'consult-register--candidates "consult-register") -(defvar consult--source-file-register - `(:name "File Register" - :narrow (?r . "Register") - :category file - :state ,#'consult--file-state - :enabled ,(lambda () (seq-some #'consult--file-register-p register-alist)) - :items ,(lambda () (consult-register--candidates #'consult--file-register-p))) - "File register source.") - -(defvar consult--source-recent-file - `(:name "File" - :narrow ?f - :category file - :face consult-file - :history file-name-history - :state ,#'consult--file-state - :new ,#'consult--file-action - :enabled ,(lambda () recentf-mode) - :items - ,(lambda () - (let ((ht (consult--buffer-file-hash)) - items) - (dolist (file (bound-and-true-p recentf-list) (nreverse items)) - ;; Emacs 29 abbreviates file paths by default, see - ;; `recentf-filename-handlers'. I recommend to set - ;; `recentf-filename-handlers' to nil to avoid any slow down. - (unless (eq (aref file 0) ?/) - (let (file-name-handler-alist) ;; No Tramp slowdown please. - (setq file (expand-file-name file)))) - (unless (gethash file ht) - (push (consult--fast-abbreviate-file-name file) items)))))) - "Recent file candidate source for `consult-buffer'.") - -;;;###autoload -(defun consult-buffer (&optional sources) - "Enhanced `switch-to-buffer' command with support for virtual buffers. - -The command supports recent files, bookmarks, views and project files as -virtual buffers. Buffers are previewed. Narrowing to buffers (b), files (f), -bookmarks (m) and project files (p) is supported via the corresponding -keys. In order to determine the project-specific files and buffers, the -`consult-project-function' is used. The virtual buffer SOURCES -default to `consult-buffer-sources'. See `consult--multi' for the -configuration of the virtual buffer sources." - (interactive) - (let ((selected (consult--multi (or sources consult-buffer-sources) - :require-match - (confirm-nonexistent-file-or-buffer) - :prompt "Switch to: " - :history 'consult--buffer-history - :sort nil))) - ;; For non-matching candidates, fall back to buffer creation. - (unless (plist-get (cdr selected) :match) - (consult--buffer-action (car selected))))) - -(defmacro consult--with-project (&rest body) - "Ensure that BODY is executed with a project root." - ;; We have to work quite hard here to ensure that the project root is - ;; only overridden at the current recursion level. When entering a - ;; recursive minibuffer session, we should be able to still switch the - ;; project. But who does that? Working on the first level on project A - ;; and on the second level on project B and on the third level on project C? - ;; You mustn't be afraid to dream a little bigger, darling. - `(let ((consult-project-function - (let ((root (or (consult--project-root t) (user-error "No project found"))) - (depth (recursion-depth)) - (orig consult-project-function)) - (lambda (may-prompt) - (if (= depth (recursion-depth)) - root - (funcall orig may-prompt)))))) - ,@body)) - -;;;###autoload -(defun consult-project-buffer () - "Enhanced `project-switch-to-buffer' command with support for virtual buffers. -The command may prompt you for a project directory if it is invoked from -outside a project. See `consult-buffer' for more details." - (interactive) - (consult--with-project - (consult-buffer consult-project-buffer-sources))) - -;;;###autoload -(defun consult-buffer-other-window () - "Variant of `consult-buffer', switching to a buffer in another window." - (interactive) - (let ((consult--buffer-display #'switch-to-buffer-other-window)) - (consult-buffer))) - -;;;###autoload -(defun consult-buffer-other-frame () - "Variant of `consult-buffer', switching to a buffer in another frame." - (interactive) - (let ((consult--buffer-display #'switch-to-buffer-other-frame)) - (consult-buffer))) - -;;;###autoload -(defun consult-buffer-other-tab () - "Variant of `consult-buffer', switching to a buffer in another tab." - (interactive) - (let ((consult--buffer-display #'switch-to-buffer-other-tab)) - (consult-buffer))) - -;;;;; Command: consult-grep - -(defun consult--grep-format (async builder) - "Return ASYNC function highlighting grep match results. -BUILDER is the command line builder function." - (let (highlight) - (lambda (action) - (cond - ((stringp action) - (setq highlight (cdr (funcall builder action))) - (funcall async action)) - ((consp action) - (let ((file "") (file-len 0) result) - (save-match-data - (dolist (str action) - (when (and (string-match consult--grep-match-regexp str) - ;; Filter out empty context lines - (or (/= (aref str (match-beginning 3)) ?-) - (/= (match-end 0) (length str)))) - ;; We share the file name across candidates to reduce - ;; the amount of allocated memory. - (unless (and (= file-len (- (match-end 1) (match-beginning 1))) - (eq t (compare-strings - file 0 file-len - str (match-beginning 1) (match-end 1) nil))) - (setq file (match-string 1 str) - file-len (length file))) - (let* ((line (match-string 2 str)) - (ctx (= (aref str (match-beginning 3)) ?-)) - (sep (if ctx "-" ":")) - (content (substring str (match-end 0))) - (line-len (length line))) - (when (length> content consult-grep-max-columns) - (setq content (substring content 0 consult-grep-max-columns))) - (when highlight - (funcall highlight content)) - (setq str (concat file sep line sep content)) - ;; Store file name in order to avoid allocations in `consult--prefix-group' - (add-text-properties 0 file-len `(face consult-file consult--prefix-group ,file) str) - (put-text-property (1+ file-len) (+ 1 file-len line-len) 'face 'consult-line-number str) - (when ctx - (add-face-text-property (+ 2 file-len line-len) (length str) 'consult-grep-context 'append str)) - (push str result))))) - (funcall async (nreverse result)))) - (t (funcall async action)))))) - -(defun consult--grep-position (cand &optional find-file) - "Return the grep position marker for CAND. -FIND-FILE is the file open function, defaulting to `find-file-noselect'." - (when cand - (let* ((file-end (next-single-property-change 0 'face cand)) - (line-end (next-single-property-change (1+ file-end) 'face cand)) - (matches (consult--point-placement cand (1+ line-end) 'consult-grep-context)) - (file (substring-no-properties cand 0 file-end)) - (line (string-to-number (substring-no-properties cand (+ 1 file-end) line-end)))) - (when-let (pos (consult--marker-from-line-column - (funcall (or find-file #'consult--file-action) file) - line (or (car matches) 0))) - (cons pos (cdr matches)))))) - -(defun consult--grep-state () - "Grep state function." - (let ((open (consult--temporary-files)) - (jump (consult--jump-state))) - (lambda (action cand) - (unless cand - (funcall open)) - (funcall jump action (consult--grep-position - cand - (and (not (eq action 'return)) open)))))) - -(defun consult--grep-exclude-args () - "Produce grep exclude arguments. -Take the variables `grep-find-ignored-directories' and -`grep-find-ignored-files' into account." - (unless (boundp 'grep-find-ignored-files) (require 'grep)) - (nconc (mapcar (lambda (s) (concat "--exclude=" s)) - (bound-and-true-p grep-find-ignored-files)) - (mapcar (lambda (s) (concat "--exclude-dir=" s)) - (bound-and-true-p grep-find-ignored-directories)))) - -(defun consult--grep (prompt make-builder dir initial) - "Run asynchronous grep. - -MAKE-BUILDER is the function that returns the command line -builder function. DIR is a directory or a list of file or -directories. PROMPT is the prompt string. INITIAL is initial -input." - (pcase-let* ((`(,prompt ,paths ,dir) (consult--directory-prompt prompt dir)) - (default-directory dir) - (builder (funcall make-builder paths))) - (consult--read - (consult--async-command builder - (consult--grep-format builder) - :file-handler t) ;; allow tramp - :prompt prompt - :lookup #'consult--lookup-member - :state (consult--grep-state) - :initial (consult--async-split-initial initial) - :add-history (consult--async-split-thingatpt 'symbol) - :require-match t - :category 'consult-grep - :group #'consult--prefix-group - :history '(:input consult--grep-history) - :sort nil))) - -(defun consult--grep-lookahead-p (&rest cmd) - "Return t if grep CMD supports look-ahead." - (eq 0 (process-file-shell-command - (concat "echo xaxbx | " - (mapconcat #'shell-quote-argument `(,@cmd "^(?=.*b)(?=.*a)") " "))))) - -(defun consult--grep-make-builder (paths) - "Build grep command line and grep across PATHS." - (let* ((cmd (consult--build-args consult-grep-args)) - (type (if (consult--grep-lookahead-p (car cmd) "-P") 'pcre 'extended))) - (lambda (input) - (pcase-let* ((`(,arg . ,opts) (consult--command-split input)) - (flags (append cmd opts)) - (ignore-case (or (member "-i" flags) (member "--ignore-case" flags)))) - (if (or (member "-F" flags) (member "--fixed-strings" flags)) - (cons (append cmd (list "-e" arg) opts paths) - (apply-partially #'consult--highlight-regexps - (list (regexp-quote arg)) ignore-case)) - (pcase-let ((`(,re . ,hl) (funcall consult--regexp-compiler arg type ignore-case))) - (when re - (cons (append cmd - (list (if (eq type 'pcre) "-P" "-E") ;; perl or extended - "-e" (consult--join-regexps re type)) - opts paths) - hl)))))))) - -;;;###autoload -(defun consult-grep (&optional dir initial) - "Search with `grep' for files in DIR where the content matches a regexp. - -The initial input is given by the INITIAL argument. DIR can be -nil, a directory string or a list of file/directory paths. If -`consult-grep' is called interactively with a prefix argument, -the user can specify the directories or files to search in. -Multiple directories must be separated by comma in the -minibuffer, since they are read via `completing-read-multiple'. -By default the project directory is used if -`consult-project-function' is defined and returns non-nil. -Otherwise the `default-directory' is searched. - -The input string is split, the first part of the string (grep -input) is passed to the asynchronous grep process and the second -part of the string is passed to the completion-style filtering. - -The input string is split at a punctuation character, which is -given as the first character of the input string. The format is -similar to Perl-style regular expressions, e.g., /regexp/. -Furthermore command line options can be passed to grep, specified -behind --. The overall prompt input has the form -`#async-input -- grep-opts#filter-string'. - -Note that the grep input string is transformed from Emacs regular -expressions to Posix regular expressions. Always enter Emacs -regular expressions at the prompt. `consult-grep' behaves like -builtin Emacs search commands, e.g., Isearch, which take Emacs -regular expressions. Furthermore the asynchronous input split -into words, each word must match separately and in any order. -See `consult--regexp-compiler' for the inner workings. In order -to disable transformations of the grep input, adjust -`consult--regexp-compiler' accordingly. - -Here we give a few example inputs: - -#alpha beta : Search for alpha and beta in any order. -#alpha.*beta : Search for alpha before beta. -#\\(alpha\\|beta\\) : Search for alpha or beta (Note Emacs syntax!) -#word -- -C3 : Search for word, include 3 lines as context -#first#second : Search for first, quick filter for second. - -The symbol at point is added to the future history." - (interactive "P") - (consult--grep "Grep" #'consult--grep-make-builder dir initial)) - -;;;;; Command: consult-git-grep - -(defun consult--git-grep-make-builder (paths) - "Create grep command line builder given PATHS." - (let ((cmd (consult--build-args consult-git-grep-args))) - (lambda (input) - (pcase-let* ((`(,arg . ,opts) (consult--command-split input)) - (flags (append cmd opts)) - (ignore-case (or (member "-i" flags) (member "--ignore-case" flags)))) - (if (or (member "-F" flags) (member "--fixed-strings" flags)) - (cons (append cmd (list "-e" arg) opts paths) - (apply-partially #'consult--highlight-regexps - (list (regexp-quote arg)) ignore-case)) - (pcase-let ((`(,re . ,hl) (funcall consult--regexp-compiler arg 'extended ignore-case))) - (when re - (cons (append cmd - (cdr (mapcan (lambda (x) (list "--and" "-e" x)) re)) - opts paths) - hl)))))))) - -;;;###autoload -(defun consult-git-grep (&optional dir initial) - "Search with `git grep' for files in DIR with INITIAL input. -See `consult-grep' for details." - (interactive "P") - (consult--grep "Git-grep" #'consult--git-grep-make-builder dir initial)) - -;;;;; Command: consult-ripgrep - -(defun consult--ripgrep-make-builder (paths) - "Create ripgrep command line builder given PATHS." - (let* ((cmd (consult--build-args consult-ripgrep-args)) - (type (if (consult--grep-lookahead-p (car cmd) "-P") 'pcre 'extended))) - (lambda (input) - (pcase-let* ((`(,arg . ,opts) (consult--command-split input)) - (flags (append cmd opts)) - (ignore-case - (and (not (or (member "-s" flags) (member "--case-sensitive" flags))) - (or (member "-i" flags) (member "--ignore-case" flags) - (and (or (member "-S" flags) (member "--smart-case" flags)) - (let (case-fold-search) - ;; Case insensitive if there are no uppercase letters - (not (string-match-p "[[:upper:]]" arg)))))))) - (if (or (member "-F" flags) (member "--fixed-strings" flags)) - (cons (append cmd (list "-e" arg) opts paths) - (apply-partially #'consult--highlight-regexps - (list (regexp-quote arg)) ignore-case)) - (pcase-let ((`(,re . ,hl) (funcall consult--regexp-compiler arg type ignore-case))) - (when re - (cons (append cmd (and (eq type 'pcre) '("-P")) - (list "-e" (consult--join-regexps re type)) - opts paths) - hl)))))))) - -;;;###autoload -(defun consult-ripgrep (&optional dir initial) - "Search with `rg' for files in DIR with INITIAL input. -See `consult-grep' for details." - (interactive "P") - (consult--grep "Ripgrep" #'consult--ripgrep-make-builder dir initial)) - -;;;;; Command: consult-find - -(defun consult--find (prompt builder initial) - "Run find command in current directory. - -The function returns the selected file. -The filename at point is added to the future history. - -BUILDER is the command line builder function. -PROMPT is the prompt. -INITIAL is initial input." - (consult--read - (consult--async-command builder - (consult--async-map (lambda (x) (string-remove-prefix "./" x))) - (consult--async-highlight builder) - :file-handler t) ;; allow tramp - :prompt prompt - :sort nil - :require-match t - :initial (consult--async-split-initial initial) - :add-history (consult--async-split-thingatpt 'filename) - :category 'file - :history '(:input consult--find-history))) - -(defun consult--find-make-builder (paths) - "Build find command line, finding across PATHS." - (let* ((cmd (seq-mapcat (lambda (x) - (if (equal x ".") paths (list x))) - (consult--build-args consult-find-args))) - (type (if (eq 0 (process-file-shell-command - (concat (car cmd) " -regextype emacs -version"))) - 'emacs 'basic))) - (lambda (input) - (pcase-let* ((`(,arg . ,opts) (consult--command-split input)) - ;; ignore-case=t since -iregex is used below - (`(,re . ,hl) (funcall consult--regexp-compiler arg type t))) - (when re - (cons (append cmd - (cdr (mapcan - (lambda (x) - `("-and" "-iregex" - ,(format ".*%s.*" - ;; Replace non-capturing groups with capturing groups. - ;; GNU find does not support non-capturing groups. - (replace-regexp-in-string - "\\\\(\\?:" "\\(" x 'fixedcase 'literal)))) - re)) - opts) - hl)))))) - -;;;###autoload -(defun consult-find (&optional dir initial) - "Search for files with `find' in DIR. -The file names must match the input regexp. INITIAL is the -initial minibuffer input. See `consult-grep' for details -regarding the asynchronous search and the arguments." - (interactive "P") - (pcase-let* ((`(,prompt ,paths ,dir) (consult--directory-prompt "Find" dir)) - (default-directory dir) - (builder (consult--find-make-builder paths))) - (find-file (consult--find prompt builder initial)))) - -;;;;; Command: consult-fd - -(defun consult--fd-make-builder (paths) - "Build find command line, finding across PATHS." - (let ((cmd (consult--build-args consult-fd-args))) - (lambda (input) - (pcase-let* ((`(,arg . ,opts) (consult--command-split input)) - (flags (append cmd opts)) - (ignore-case - (and (not (or (member "-s" flags) (member "--case-sensitive" flags))) - (or (member "-i" flags) (member "--ignore-case" flags) - (let (case-fold-search) - ;; Case insensitive if there are no uppercase letters - (not (string-match-p "[[:upper:]]" arg))))))) - (if (or (member "-F" flags) (member "--fixed-strings" flags)) - (cons (append cmd (list arg) opts paths) - (apply-partially #'consult--highlight-regexps - (list (regexp-quote arg)) ignore-case)) - (pcase-let ((`(,re . ,hl) (funcall consult--regexp-compiler arg 'pcre ignore-case))) - (when re - (cons (append cmd - (mapcan (lambda (x) `("--and" ,x)) re) - opts paths) - hl)))))))) - -;;;###autoload -(defun consult-fd (&optional dir initial) - "Search for files with `fd' in DIR. -The file names must match the input regexp. INITIAL is the -initial minibuffer input. See `consult-grep' for details -regarding the asynchronous search and the arguments." - (interactive "P") - (pcase-let* ((`(,prompt ,paths ,dir) (consult--directory-prompt "Fd" dir)) - (default-directory dir) - (builder (consult--fd-make-builder paths))) - (find-file (consult--find prompt builder initial)))) - -;;;;; Command: consult-locate - -(defun consult--locate-builder (input) - "Build command line from INPUT." - (pcase-let ((`(,arg . ,opts) (consult--command-split input))) - (unless (string-blank-p arg) - (cons (append (consult--build-args consult-locate-args) - (consult--split-escaped arg) opts) - (cdr (consult--default-regexp-compiler input 'basic t)))))) - -;;;###autoload -(defun consult-locate (&optional initial) - "Search with `locate' for files which match input given INITIAL input. - -The input is treated literally such that locate can take advantage of -the locate database index. Regular expressions would often force a slow -linear search through the entire database. The locate process is started -asynchronously, similar to `consult-grep'. See `consult-grep' for more -details regarding the asynchronous search." - (interactive) - (find-file (consult--find "Locate: " #'consult--locate-builder initial))) - -;;;;; Command: consult-man - -(defun consult--man-builder (input) - "Build command line from INPUT." - (pcase-let* ((`(,arg . ,opts) (consult--command-split input)) - (`(,re . ,hl) (funcall consult--regexp-compiler arg 'extended t))) - (when re - (cons (append (consult--build-args consult-man-args) - (list (consult--join-regexps re 'extended)) - opts) - hl)))) - -(defun consult--man-format (lines) - "Format man candidates from LINES." - (let ((candidates)) - (save-match-data - (dolist (str lines) - (when (string-match "\\`\\(.*?\\([^ ]+\\) *(\\([^,)]+\\)[^)]*).*?\\) +- +\\(.*\\)\\'" str) - (let* ((names (match-string 1 str)) - (name (match-string 2 str)) - (section (match-string 3 str)) - (desc (match-string 4 str)) - (cand (format "%s - %s" names desc))) - (add-text-properties 0 (length names) - (list 'face 'consult-file - 'consult-man (concat section " " name)) - cand) - (push cand candidates))))) - (nreverse candidates))) - -;;;###autoload -(defun consult-man (&optional initial) - "Search for man page given INITIAL input. - -The input string is not preprocessed and passed literally to the -underlying man commands. The man process is started asynchronously, -similar to `consult-grep'. See `consult-grep' for more details regarding -the asynchronous search." - (interactive) - (man (consult--read - (consult--async-command #'consult--man-builder - (consult--async-transform consult--man-format) - (consult--async-highlight #'consult--man-builder)) - :prompt "Manual entry: " - :require-match t - :category 'consult-man - :lookup (apply-partially #'consult--lookup-prop 'consult-man) - :initial (consult--async-split-initial initial) - :add-history (consult--async-split-thingatpt 'symbol) - :history '(:input consult--man-history)))) - -;;;; Preview at point in completions buffers - -(define-minor-mode consult-preview-at-point-mode - "Preview minor mode for *Completions* buffers. -When moving around in the *Completions* buffer, the candidate at point is -automatically previewed." - :group 'consult - (if consult-preview-at-point-mode - (add-hook 'post-command-hook #'consult-preview-at-point nil 'local) - (remove-hook 'post-command-hook #'consult-preview-at-point 'local))) - -(defun consult-preview-at-point () - "Preview candidate at point in *Completions* buffer." - (interactive) - (when-let ((win (active-minibuffer-window)) - (buf (window-buffer win)) - (fun (buffer-local-value 'consult--preview-function buf))) - (funcall fun))) - -;;;; Integration with completion systems - -;;;;; Integration: Default *Completions* - -(defun consult--default-completion-minibuffer-candidate () - "Return current minibuffer candidate from default completion system or Icomplete." - (when (and (minibufferp) - (eq completing-read-function #'completing-read-default)) - (let ((content (minibuffer-contents-no-properties))) - ;; When the current minibuffer content matches a candidate, return it! - (if (test-completion content - minibuffer-completion-table - minibuffer-completion-predicate) - content - ;; Return the full first candidate of the sorted completion list. - (when-let ((completions (completion-all-sorted-completions))) - (concat - (substring content 0 (or (cdr (last completions)) 0)) - (car completions))))))) - -(defun consult--default-completion-list-candidate () - "Return current candidate at point from completions buffer." - (let (beg end) - (when (and - (derived-mode-p 'completion-list-mode) - ;; Logic taken from `choose-completion'. - ;; TODO Upstream a `completion-list-get-candidate' function. - (cond - ((and (not (eobp)) (get-text-property (point) 'mouse-face)) - (setq end (point) beg (1+ (point)))) - ((and (not (bobp)) (get-text-property (1- (point)) 'mouse-face)) - (setq end (1- (point)) beg (point))))) - (setq beg (previous-single-property-change beg 'mouse-face) - end (or (next-single-property-change end 'mouse-face) (point-max))) - (or (get-text-property beg 'completion--string) - (buffer-substring-no-properties beg end))))) - -;;;;; Integration: Vertico - -(defvar vertico--input) -(declare-function vertico--exhibit "ext:vertico") -(declare-function vertico--candidate "ext:vertico") -(declare-function vertico--filter-completions "ext:vertico") - -(defun consult--vertico-candidate () - "Return current candidate for Consult preview." - (and vertico--input (vertico--candidate 'highlight))) - -(defun consult--vertico-refresh () - "Refresh completion UI." - (when vertico--input - (setq vertico--input t) - (vertico--exhibit))) - -(defun consult--vertico-filter-adv (orig pattern cands category highlight) - "Advice for ORIG `consult--completion-filter' function. -See `consult--completion-filter' for arguments PATTERN, CANDS, CATEGORY -and HIGHLIGHT." - (if (and (not highlight) (bound-and-true-p vertico-mode)) - ;; Optimize `consult--completion-filter' using the deferred highlighting - ;; from Vertico. The advice is not necessary - it is a pure optimization. - (nconc (car (vertico--filter-completions pattern cands nil (length pattern) - `(metadata (category . ,category)))) - nil) - (funcall orig pattern cands category highlight))) - -(with-eval-after-load 'vertico - (advice-add #'consult--completion-filter :around #'consult--vertico-filter-adv) - (add-hook 'consult--completion-candidate-hook #'consult--vertico-candidate) - (add-hook 'consult--completion-refresh-hook #'consult--vertico-refresh) - (define-key consult-async-map [remap vertico-insert] 'vertico-next-group)) - -;;;;; Integration: Mct - -(with-eval-after-load 'mct (add-hook 'consult--completion-refresh-hook - 'mct--live-completions-refresh)) - -;;;;; Integration: Icomplete - -(defvar icomplete-mode) -(declare-function icomplete-exhibit "icomplete") - -(defun consult--icomplete-refresh () - "Refresh icomplete view." - (when icomplete-mode - (let ((top (car completion-all-sorted-completions))) - (completion--flush-all-sorted-completions) - ;; force flushing, otherwise narrowing is broken! - (setq completion-all-sorted-completions nil) - (when top - (let* ((completions (completion-all-sorted-completions)) - (last (last completions)) - (before)) ;; completions before top - ;; warning: completions is an improper list - (while (consp completions) - (if (equal (car completions) top) - (progn - (setcdr last (append (nreverse before) (cdr last))) - (setq completion-all-sorted-completions completions - completions nil)) - (push (car completions) before) - (setq completions (cdr completions))))))) - (icomplete-exhibit))) - -(with-eval-after-load 'icomplete - (add-hook 'consult--completion-refresh-hook #'consult--icomplete-refresh)) - -(provide 'consult) -;;; consult.el ends here diff --git a/emacs/elpa/consult-20240516.2240/consult.elc b/emacs/elpa/consult-20240516.2240/consult.elc Binary files differ. diff --git a/emacs/elpa/consult-20240516.2240/consult-autoloads.el b/emacs/elpa/consult-20240523.754/consult-autoloads.el diff --git a/emacs/elpa/consult-20240516.2240/consult-compile.el b/emacs/elpa/consult-20240523.754/consult-compile.el diff --git a/emacs/elpa/consult-20240516.2240/consult-compile.elc b/emacs/elpa/consult-20240523.754/consult-compile.elc Binary files differ. diff --git a/emacs/elpa/consult-20240516.2240/consult-flymake.el b/emacs/elpa/consult-20240523.754/consult-flymake.el diff --git a/emacs/elpa/consult-20240516.2240/consult-flymake.elc b/emacs/elpa/consult-20240523.754/consult-flymake.elc Binary files differ. diff --git a/emacs/elpa/consult-20240516.2240/consult-imenu.el b/emacs/elpa/consult-20240523.754/consult-imenu.el diff --git a/emacs/elpa/consult-20240516.2240/consult-imenu.elc b/emacs/elpa/consult-20240523.754/consult-imenu.elc Binary files differ. diff --git a/emacs/elpa/consult-20240516.2240/consult-info.el b/emacs/elpa/consult-20240523.754/consult-info.el diff --git a/emacs/elpa/consult-20240516.2240/consult-info.elc b/emacs/elpa/consult-20240523.754/consult-info.elc Binary files differ. diff --git a/emacs/elpa/consult-20240516.2240/consult-kmacro.el b/emacs/elpa/consult-20240523.754/consult-kmacro.el diff --git a/emacs/elpa/consult-20240516.2240/consult-kmacro.elc b/emacs/elpa/consult-20240523.754/consult-kmacro.elc Binary files differ. diff --git a/emacs/elpa/consult-20240516.2240/consult-org.el b/emacs/elpa/consult-20240523.754/consult-org.el diff --git a/emacs/elpa/consult-20240516.2240/consult-org.elc b/emacs/elpa/consult-20240523.754/consult-org.elc Binary files differ. diff --git a/emacs/elpa/consult-20240523.754/consult-pkg.el b/emacs/elpa/consult-20240523.754/consult-pkg.el @@ -0,0 +1,15 @@ +(define-package "consult" "20240523.754" "Consulting completing-read" + '((emacs "27.1") + (compat "29.1.4.4")) + :commit "fe4852280006e61be7f1374d021ee06155ce5a26" :authors + '(("Daniel Mendler and Consult contributors")) + :maintainers + '(("Daniel Mendler" . "mail@daniel-mendler.de")) + :maintainer + '("Daniel Mendler" . "mail@daniel-mendler.de") + :keywords + '("matching" "files" "completion") + :url "https://github.com/minad/consult") +;; Local Variables: +;; no-byte-compile: t +;; End: diff --git a/emacs/elpa/consult-20240516.2240/consult-register.el b/emacs/elpa/consult-20240523.754/consult-register.el diff --git a/emacs/elpa/consult-20240516.2240/consult-register.elc b/emacs/elpa/consult-20240523.754/consult-register.elc Binary files differ. diff --git a/emacs/elpa/consult-20240516.2240/consult-xref.el b/emacs/elpa/consult-20240523.754/consult-xref.el diff --git a/emacs/elpa/consult-20240516.2240/consult-xref.elc b/emacs/elpa/consult-20240523.754/consult-xref.elc Binary files differ. diff --git a/emacs/elpa/consult-20240523.754/consult.el b/emacs/elpa/consult-20240523.754/consult.el @@ -0,0 +1,5262 @@ +;;; consult.el --- Consulting completing-read -*- lexical-binding: t -*- + +;; Copyright (C) 2021-2024 Free Software Foundation, Inc. + +;; Author: Daniel Mendler and Consult contributors +;; Maintainer: Daniel Mendler <mail@daniel-mendler.de> +;; Created: 2020 +;; Version: 1.7 +;; Package-Requires: ((emacs "27.1") (compat "29.1.4.4")) +;; Homepage: https://github.com/minad/consult +;; Keywords: matching, files, completion + +;; This file is part of GNU Emacs. + +;; 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 <https://www.gnu.org/licenses/>. + +;;; Commentary: + +;; Consult implements a set of `consult-<thing>' commands, which aim to +;; improve the way you use Emacs. The commands are founded on +;; `completing-read', which selects from a list of candidate strings. +;; Consult provides an enhanced buffer switcher `consult-buffer' and +;; search and navigation commands like `consult-imenu' and +;; `consult-line'. Searching through multiple files is supported by the +;; asynchronous `consult-grep' command. Many Consult commands support +;; previewing candidates. If a candidate is selected in the completion +;; view, the buffer shows the candidate immediately. + +;; The Consult commands are compatible with multiple completion systems +;; based on the Emacs `completing-read' API, including the default +;; completion system, Vertico, Mct and Icomplete. + +;; See the README for an overview of the available Consult commands and +;; the documentation of the configuration and installation of the +;; package. + +;; The full list of contributors can be found in the acknowledgments +;; section of the README. + +;;; Code: + +(eval-when-compile + (require 'cl-lib) + (require 'subr-x)) +(require 'compat) +(require 'bookmark) + +(defgroup consult nil + "Consulting `completing-read'." + :link '(info-link :tag "Info Manual" "(consult)") + :link '(url-link :tag "Homepage" "https://github.com/minad/consult") + :link '(emacs-library-link :tag "Library Source" "consult.el") + :group 'files + :group 'outlines + :group 'minibuffer + :prefix "consult-") + +;;;; Customization + +(defcustom consult-narrow-key nil + "Prefix key for narrowing during completion. + +Good choices for this key are \"<\" and \"C-+\" for example. The +key must be a string accepted by `key-valid-p'." + :type '(choice key (const :tag "None" nil))) + +(defcustom consult-widen-key nil + "Key used for widening during completion. + +If this key is unset, defaults to twice the `consult-narrow-key'. +The key must be a string accepted by `key-valid-p'." + :type '(choice key (const :tag "None" nil))) + +(defcustom consult-project-function + #'consult--default-project-function + "Function which returns project root directory. +The function takes one boolean argument MAY-PROMPT. If +MAY-PROMPT is non-nil, the function may ask the prompt the user +for a project directory. The root directory is used by +`consult-buffer' and `consult-grep'." + :type `(choice + (const :tag "Default project function" ,#'consult--default-project-function) + (function :tag "Custom function") + (const :tag "No project integration" nil))) + +(defcustom consult-async-refresh-delay 0.2 + "Refreshing delay of the completion UI for asynchronous commands. + +The completion UI is only updated every +`consult-async-refresh-delay' seconds. This applies to +asynchronous commands like for example `consult-grep'." + :type '(float :tag "Delay in seconds")) + +(defcustom consult-async-input-throttle 0.5 + "Input throttle for asynchronous commands. + +The asynchronous process is started only every +`consult-async-input-throttle' seconds. This applies to asynchronous +commands, e.g., `consult-grep'." + :type '(float :tag "Delay in seconds")) + +(defcustom consult-async-input-debounce 0.2 + "Input debounce for asynchronous commands. + +The asynchronous process is started only when there has not been new +input for `consult-async-input-debounce' seconds. This applies to +asynchronous commands, e.g., `consult-grep'." + :type '(float :tag "Delay in seconds")) + +(defcustom consult-async-min-input 3 + "Minimum number of characters needed, before asynchronous process is called. + +This applies to asynchronous commands, e.g., `consult-grep'." + :type '(natnum :tag "Number of characters")) + +(defcustom consult-async-split-style 'perl + "Async splitting style, see `consult-async-split-styles-alist'." + :type '(choice (const :tag "No splitting" nil) + (const :tag "Comma" comma) + (const :tag "Semicolon" semicolon) + (const :tag "Perl" perl))) + +(defcustom consult-async-split-styles-alist + `((nil :function ,#'consult--split-nil) + (comma :separator ?, :function ,#'consult--split-separator) + (semicolon :separator ?\; :function ,#'consult--split-separator) + (perl :initial "#" :function ,#'consult--split-perl)) + "Async splitting styles." + :type '(alist :key-type symbol :value-type plist)) + +(defcustom consult-mode-histories + '((eshell-mode eshell-history-ring eshell-history-index eshell-bol) + (comint-mode comint-input-ring comint-input-ring-index comint-bol) + (term-mode term-input-ring term-input-ring-index term-bol)) + "Alist of mode histories (mode history index bol). +The histories can be rings or lists. Index, if provided, is a +variable to set to the index of the selection within the ring or +list. Bol, if provided is a function which jumps to the beginning +of the line after the prompt." + :type '(alist :key-type symbol + :value-type (group :tag "Include Index" + (symbol :tag "List/Ring") + (symbol :tag "Index Variable") + (symbol :tag "Bol Function")))) + +(defcustom consult-themes nil + "List of themes (symbols or regexps) to be presented for selection. +nil shows all `custom-available-themes'." + :type '(repeat (choice symbol regexp))) + +(defcustom consult-after-jump-hook (list #'recenter) + "Function called after jumping to a location. + +Commonly used functions for this hook are `recenter' and +`reposition-window'. You may want to add a function which pulses +the current line, e.g., `pulse-momentary-highlight-one-line' is +supported on Emacs 28 and newer. The hook called during preview +and for the jump after selection." + :type 'hook) + +(defcustom consult-line-start-from-top nil + "Start search from the top if non-nil. +Otherwise start the search at the current line and wrap around." + :type 'boolean) + +(defcustom consult-point-placement 'match-beginning + "Where to leave point when jumping to a match. +This setting affects the command `consult-line' and the `consult-grep' variants." + :type '(choice (const :tag "Beginning of the line" line-beginning) + (const :tag "Beginning of the match" match-beginning) + (const :tag "End of the match" match-end))) + +(defcustom consult-line-numbers-widen t + "Show absolute line numbers when narrowing is active. + +See also `display-line-numbers-widen'." + :type 'boolean) + +(defcustom consult-goto-line-numbers t + "Show line numbers for `consult-goto-line'." + :type 'boolean) + +(defcustom consult-fontify-preserve t + "Preserve fontification for line-based commands." + :type 'boolean) + +(defcustom consult-fontify-max-size 1048576 + "Buffers larger than this byte limit are not fontified. + +This is necessary in order to prevent a large startup time +for navigation commands like `consult-line'." + :type '(natnum :tag "Buffer size in bytes")) + +(defcustom consult-buffer-filter + '("\\` " + "\\`\\*Completions\\*\\'" + "\\`\\*Flymake log\\*\\'" + "\\`\\*Semantic SymRef\\*\\'" + "\\`\\*tramp/.*\\*\\'") + "Filter regexps for `consult-buffer'. + +The default setting is to filter ephemeral buffer names beginning +with a space character, the *Completions* buffer and a few log +buffers. The regular expressions are matched case sensitively." + :type '(repeat regexp)) + +(defcustom consult-buffer-sources + '(consult--source-hidden-buffer + consult--source-modified-buffer + consult--source-buffer + consult--source-recent-file + consult--source-file-register + consult--source-bookmark + consult--source-project-buffer-hidden + consult--source-project-recent-file-hidden) + "Sources used by `consult-buffer'. +See also `consult-project-buffer-sources'. +See `consult--multi' for a description of the source data structure." + :type '(repeat symbol)) + +(defcustom consult-project-buffer-sources + '(consult--source-project-buffer + consult--source-project-recent-file) + "Sources used by `consult-project-buffer'. +See also `consult-buffer-sources'. +See `consult--multi' for a description of the source data structure." + :type '(repeat symbol)) + +(defcustom consult-mode-command-filter + '(;; Filter commands + "-mode\\'" "--" + ;; Filter whole features + simple mwheel time so-long recentf tab-bar tab-line) + "Filter commands for `consult-mode-command'." + :type '(repeat (choice symbol regexp))) + +(defcustom consult-grep-max-columns 300 + "Maximal number of columns of grep output." + :type 'natnum) + +(defconst consult--grep-match-regexp + "\\`\\(?:\\./\\)?\\([^\n\0]+\\)\0\\([0-9]+\\)\\([-:\0]\\)" + "Regexp used to match file and line of grep output.") + +(defcustom consult-grep-args + '("grep" (consult--grep-exclude-args) + "--null --line-buffered --color=never --ignore-case\ + --with-filename --line-number -I -r") + "Command line arguments for grep, see `consult-grep'. +The dynamically computed arguments are appended. +Can be either a string, or a list of strings or expressions." + :type '(choice string (repeat (choice string sexp)))) + +(defcustom consult-git-grep-args + "git --no-pager grep --null --color=never --ignore-case\ + --extended-regexp --line-number -I" + "Command line arguments for git-grep, see `consult-git-grep'. +The dynamically computed arguments are appended. +Can be either a string, or a list of strings or expressions." + :type '(choice string (repeat (choice string sexp)))) + +(defcustom consult-ripgrep-args + "rg --null --line-buffered --color=never --max-columns=1000 --path-separator /\ + --smart-case --no-heading --with-filename --line-number --search-zip" + "Command line arguments for ripgrep, see `consult-ripgrep'. +The dynamically computed arguments are appended. +Can be either a string, or a list of strings or expressions." + :type '(choice string (repeat (choice string sexp)))) + +(defcustom consult-find-args + "find . -not ( -path */.[A-Za-z]* -prune )" + "Command line arguments for find, see `consult-find'. +The dynamically computed arguments are appended. +Can be either a string, or a list of strings or expressions." + :type '(choice string (repeat (choice string sexp)))) + +(defcustom consult-fd-args + '((if (executable-find "fdfind" 'remote) "fdfind" "fd") + "--full-path --color=never") + "Command line arguments for fd, see `consult-fd'. +The dynamically computed arguments are appended. +Can be either a string, or a list of strings or expressions." + :type '(choice string (repeat (choice string sexp)))) + +(defcustom consult-locate-args + "locate --ignore-case" ;; --existing not supported by Debian plocate + "Command line arguments for locate, see `consult-locate'. +The dynamically computed arguments are appended. +Can be either a string, or a list of strings or expressions." + :type '(choice string (repeat (choice string sexp)))) + +(defcustom consult-man-args + "man -k" + "Command line arguments for man, see `consult-man'. +The dynamically computed arguments are appended. +Can be either a string, or a list of strings or expressions." + :type '(choice string (repeat (choice string sexp)))) + +(defcustom consult-preview-key 'any + "Preview trigger keys, can be nil, `any', a single key or a list of keys. +Debouncing can be specified via the `:debounce' attribute. The +individual keys must be strings accepted by `key-valid-p'." + :type '(choice (const :tag "Any key" any) + (list :tag "Debounced" + (const :debounce) + (float :tag "Seconds" 0.1) + (const any)) + (const :tag "No preview" nil) + (key :tag "Key") + (repeat :tag "List of keys" key))) + +(defcustom consult-preview-partial-size 1048576 + "Files larger than this byte limit are previewed partially." + :type '(natnum :tag "File size in bytes")) + +(defcustom consult-preview-partial-chunk 102400 + "Partial preview chunk size in bytes. +If a file is larger than `consult-preview-partial-size' only the +chunk from the beginning of the file is previewed." + :type '(natnum :tag "Chunk size in bytes")) + +(defcustom consult-preview-max-count 10 + "Number of file buffers to keep open temporarily during preview." + :type '(natnum :tag "Number of buffers")) + +(defcustom consult-preview-excluded-files + '("\\`/[^/|:]+:") ;; Do not preview remote files + "List of regexps matched against names of files, which are not previewed." + :type '(repeat regexp)) + +(defcustom consult-preview-allowed-hooks + '(global-font-lock-mode + save-place-find-file-hook) + "List of hooks, which should be executed during file preview. +This variable applies to `find-file-hook', `change-major-mode-hook' and +mode hooks, e.g., `prog-mode-hook'." + :type '(repeat symbol)) + +(defcustom consult-preview-variables + '((inhibit-message . t) + (enable-dir-local-variables . nil) + (enable-local-variables . :safe) + (non-essential . t) + (delay-mode-hooks . t)) + "Variables which are bound for file preview." + :type '(alist :key-type symbol)) + +(defcustom consult-bookmark-narrow + `((?f "File" bookmark-default-handler) + (?h "Help" help-bookmark-jump Info-bookmark-jump + Man-bookmark-jump woman-bookmark-jump) + (?p "Picture" image-bookmark-jump) + (?d "Docview" doc-view-bookmark-jump) + (?m "Mail" gnus-summary-bookmark-jump) + (?s "Eshell" eshell-bookmark-jump) + (?w "Web" eww-bookmark-jump xwidget-webkit-bookmark-jump-handler) + (?v "VC Directory" vc-dir-bookmark-jump) + (nil "Other")) + "Bookmark narrowing configuration. + +Each element of the list must have the form (char name handlers...)." + :type '(alist :key-type character :value-type (cons string (repeat function)))) + +(defcustom consult-yank-rotate + (if (boundp 'yank-from-kill-ring-rotate) + yank-from-kill-ring-rotate + t) + "Rotate the `kill-ring' in the `consult-yank' commands." + :type 'boolean) + +;;;; Faces + +(defgroup consult-faces nil + "Faces used by Consult." + :group 'consult + :group 'faces) + +(defface consult-preview-line + '((t :inherit consult-preview-insertion :extend t)) + "Face used for line previews.") + +(defface consult-highlight-match + '((t :inherit match)) + "Face used to highlight matches in the completion candidates. +Used for example by `consult-grep'.") + +(defface consult-highlight-mark + '((t :inherit consult-highlight-match)) + "Face used for mark positions in completion candidates. +Used for example by `consult-mark'. The face should be different +than the `cursor' face to avoid confusion.") + +(defface consult-preview-match + '((t :inherit isearch)) + "Face used for match previews, e.g., in `consult-line'.") + +(defface consult-preview-insertion + '((t :inherit region)) + "Face used for previews of text to be inserted. +Used by `consult-completion-in-region', `consult-yank' and `consult-history'.") + +(defface consult-narrow-indicator + '((t :inherit warning)) + "Face used for the narrowing indicator.") + +(defface consult-async-running + '((t :inherit consult-narrow-indicator)) + "Face used if asynchronous process is running.") + +(defface consult-async-finished + '((t :inherit success)) + "Face used if asynchronous process has finished.") + +(defface consult-async-failed + '((t :inherit error)) + "Face used if asynchronous process has failed.") + +(defface consult-async-split + '((t :inherit font-lock-negation-char-face)) + "Face used to highlight punctuation character.") + +(defface consult-help + '((t :inherit shadow)) + "Face used to highlight help, e.g., in `consult-register-store'.") + +(defface consult-key + '((t :inherit font-lock-keyword-face)) + "Face used to highlight keys, e.g., in `consult-register'.") + +(defface consult-line-number + '((t :inherit consult-key)) + "Face used to highlight location line in `consult-global-mark'.") + +(defface consult-file + '((t :inherit font-lock-function-name-face)) + "Face used to highlight files in `consult-buffer'.") + +(defface consult-grep-context + '((t :inherit shadow)) + "Face used to highlight grep context in `consult-grep'.") + +(defface consult-bookmark + '((t :inherit font-lock-constant-face)) + "Face used to highlight bookmarks in `consult-buffer'.") + +(defface consult-buffer + '((t)) + "Face used to highlight buffers in `consult-buffer'.") + +(defface consult-line-number-prefix + '((t :inherit line-number)) + "Face used to highlight line number prefixes.") + +(defface consult-line-number-wrapped + '((t :inherit consult-line-number-prefix :inherit font-lock-warning-face)) + "Face used to highlight line number prefixes after wrap around.") + +(defface consult-separator + '((((class color) (min-colors 88) (background light)) + :foreground "#ccc") + (((class color) (min-colors 88) (background dark)) + :foreground "#333")) + "Face used for thin line separators in `consult-register-window'.") + +;;;; Input history variables + +(defvar consult--path-history nil) +(defvar consult--grep-history nil) +(defvar consult--find-history nil) +(defvar consult--man-history nil) +(defvar consult--line-history nil) +(defvar consult--line-multi-history nil) +(defvar consult--theme-history nil) +(defvar consult--minor-mode-menu-history nil) +(defvar consult--buffer-history nil) + +;;;; Internal variables + +(defvar consult--regexp-compiler + #'consult--default-regexp-compiler + "Regular expression compiler used by `consult-grep' and other commands. +The function must return a list of regular expressions and a highlighter +function.") + +(defvar consult--customize-alist + ;; Disable preview in frames, since `consult--jump-preview' does not properly + ;; clean up. See gh:minad/consult#593. This issue should better be fixed in + ;; `consult--jump-preview'. + `((,#'consult-buffer-other-frame :preview-key nil) + (,#'consult-buffer-other-tab :preview-key nil)) + "Command configuration alist for fine-grained configuration. + +Each element of the list must have the form (command-name plist...). The +options set here will be evaluated and passed to `consult--read', when +called from the corresponding command. Note that the options depend on +the private `consult--read' API and should not be considered as stable +as the public API.") + +(defvar consult--buffer-display #'switch-to-buffer + "Buffer display function.") + +(defvar consult--completion-candidate-hook + (list #'consult--default-completion-minibuffer-candidate + #'consult--default-completion-list-candidate) + "Get candidate from completion system.") + +(defvar consult--completion-refresh-hook nil + "Refresh completion system.") + +(defvar-local consult--preview-function nil + "Minibuffer-local variable which exposes the current preview function. +This function can be called by custom completion systems from +outside the minibuffer.") + +(defvar consult--annotate-align-step 10 + "Round candidate width.") + +(defvar consult--annotate-align-width 0 + "Maximum candidate width used for annotation alignment.") + +(defconst consult--tofu-char #x200000 + "Special character used to encode line prefixes for disambiguation. +We use invalid characters outside the Unicode range.") + +(defconst consult--tofu-range #x100000 + "Special character range.") + +(defvar-local consult--narrow nil + "Current narrowing key.") + +(defvar-local consult--narrow-keys nil + "Narrowing prefixes of the current completion.") + +(defvar-local consult--narrow-predicate nil + "Narrowing predicate of the current completion.") + +(defvar-local consult--narrow-overlay nil + "Narrowing indicator overlay.") + +(defvar consult--gc-threshold (* 64 1024 1024) + "Large GC threshold for temporary increase.") + +(defvar consult--gc-percentage 0.5 + "Large GC percentage for temporary increase.") + +(defvar consult--process-chunk (* 1024 1024) + "Increase process output chunk size.") + +(defvar consult--async-log + " *consult-async*" + "Buffer for async logging output used by `consult--async-process'.") + +(defvar-local consult--focus-lines-overlays nil + "Overlays used by `consult-focus-lines'.") + +(defvar-local consult--org-fold-regions nil + "Stored regions for the org-fold API.") + +;;;; Miscellaneous helper functions + +(defun consult--key-parse (key) + "Parse KEY or signal error if invalid." + (unless (key-valid-p key) + (error "%S is not a valid key definition; see `key-valid-p'" key)) + (key-parse key)) + +(defun consult--in-buffer (fun &optional buffer) + "Ensure that FUN is executed inside BUFFER." + (unless buffer (setq buffer (current-buffer))) + (lambda (&rest args) + (with-current-buffer buffer + (apply fun args)))) + +(defun consult--completion-table-in-buffer (table &optional buffer) + "Ensure that completion TABLE is executed inside BUFFER." + (if (functionp table) + (consult--in-buffer + (lambda (str pred action) + (let ((result (funcall table str pred action))) + (pcase action + ('metadata + (setq result + (mapcar + (lambda (x) + (if (and (string-suffix-p "-function" (symbol-name (car-safe x))) (cdr x)) + (cons (car x) (consult--in-buffer (cdr x))) + x)) + result))) + ((and 'completion--unquote (guard (functionp (cadr result)))) + (cl-callf consult--in-buffer (cadr result) buffer) + (cl-callf consult--in-buffer (cadddr result) buffer))) + result)) + buffer) + table)) + +(defun consult--build-args (arg) + "Return ARG as a flat list of split strings. + +Turn ARG into a list, and for each element either: +- split it if it a string. +- eval it if it is an expression." + (seq-mapcat (lambda (x) + (if (stringp x) + (split-string-and-unquote x) + (ensure-list (eval x 'lexical)))) + (ensure-list arg))) + +(defun consult--command-split (str) + "Return command argument and options list given input STR." + (save-match-data + (let ((opts (when (string-match " +--\\( +\\|\\'\\)" str) + (prog1 (substring str (match-end 0)) + (setq str (substring str 0 (match-beginning 0))))))) + ;; split-string-and-unquote fails if the quotes are invalid. Ignore it. + (cons str (and opts (ignore-errors (split-string-and-unquote opts))))))) + +(defmacro consult--keep! (list form) + "Evaluate FORM for every element of LIST and keep the non-nil results." + (declare (indent 1)) + (cl-with-gensyms (head prev result) + `(let* ((,head (cons nil ,list)) + (,prev ,head)) + (while (cdr ,prev) + (if-let (,result (let ((it (cadr ,prev))) ,form)) + (progn + (pop ,prev) + (setcar ,prev ,result)) + (setcdr ,prev (cddr ,prev)))) + (setq ,list (cdr ,head)) + nil))) + +;; Upstream bug#46326, Consult issue gh:minad/consult#193. +(defmacro consult--minibuffer-with-setup-hook (fun &rest body) + "Variant of `minibuffer-with-setup-hook' using a symbol and `fset'. + +This macro is only needed to prevent memory leaking issues with +the upstream `minibuffer-with-setup-hook' macro. +FUN is the hook function and BODY opens the minibuffer." + (declare (indent 1) (debug t)) + (let ((hook (gensym "hook")) + (append)) + (when (eq (car-safe fun) :append) + (setq append '(t) fun (cadr fun))) + `(let ((,hook (make-symbol "consult--minibuffer-setup-hook"))) + (fset ,hook (lambda () + (remove-hook 'minibuffer-setup-hook ,hook) + (funcall ,fun))) + (unwind-protect + (progn + (add-hook 'minibuffer-setup-hook ,hook ,@append) + ,@body) + (remove-hook 'minibuffer-setup-hook ,hook))))) + +(defun consult--completion-filter (pattern cands category _highlight) + "Filter CANDS with PATTERN. + +CATEGORY is the completion category, used to find the completion style via +`completion-category-defaults' and `completion-category-overrides'. +HIGHLIGHT must be non-nil if the resulting strings should be highlighted." + ;; completion-all-completions returns an improper list + ;; where the last link is not necessarily nil. + (nconc (completion-all-completions pattern cands nil (length pattern) + `(metadata (category . ,category))) + nil)) + +(defun consult--completion-filter-complement (pattern cands category _highlight) + "Filter CANDS with complement of PATTERN. +See `consult--completion-filter' for the arguments CATEGORY and HIGHLIGHT." + (let ((ht (consult--string-hash (consult--completion-filter pattern cands category nil)))) + (seq-remove (lambda (x) (gethash x ht)) cands))) + +(defun consult--completion-filter-dispatch (pattern cands category highlight) + "Filter CANDS with PATTERN with optional complement. +Either using `consult--completion-filter' or +`consult--completion-filter-complement', depending on if the pattern starts +with a bang. See `consult--completion-filter' for the arguments CATEGORY and +HIGHLIGHT." + (cond + ((string-match-p "\\`!? ?\\'" pattern) cands) ;; empty pattern + ((string-prefix-p "! " pattern) (consult--completion-filter-complement + (substring pattern 2) cands category nil)) + (t (consult--completion-filter pattern cands category highlight)))) + +(defmacro consult--each-line (beg end &rest body) + "Iterate over each line. + +The line beginning/ending BEG/END is bound in BODY." + (declare (indent 2)) + (cl-with-gensyms (max) + `(save-excursion + (let ((,beg (point-min)) (,max (point-max)) ,end) + (while (< ,beg ,max) + (goto-char ,beg) + (setq ,end (pos-eol)) + ,@body + (setq ,beg (1+ ,end))))))) + +(defun consult--display-width (string) + "Compute width of STRING taking display and invisible properties into account." + (let ((pos 0) (width 0) (end (length string))) + (while (< pos end) + (let ((nextd (next-single-property-change pos 'display string end)) + (display (get-text-property pos 'display string))) + (if (stringp display) + (setq width (+ width (string-width display)) + pos nextd) + (while (< pos nextd) + (let ((nexti (next-single-property-change pos 'invisible string nextd))) + (unless (get-text-property pos 'invisible string) + (setq width (+ width (compat-call string-width string pos nexti)))) + (setq pos nexti)))))) + width)) + +(defun consult--string-hash (strings) + "Create hash table from STRINGS." + (let ((ht (make-hash-table :test #'equal :size (length strings)))) + (dolist (str strings) + (puthash str t ht)) + ht)) + +(defmacro consult--local-let (binds &rest body) + "Buffer local let BINDS of dynamic variables in BODY." + (declare (indent 1)) + (let ((buffer (gensym "buffer")) + (local (mapcar (lambda (x) (cons (gensym "local") (car x))) binds))) + `(let ((,buffer (current-buffer)) + ,@(mapcar (lambda (x) `(,(car x) (local-variable-p ',(cdr x)))) local)) + (unwind-protect + (progn + ,@(mapcar (lambda (x) `(make-local-variable ',(car x))) binds) + (let (,@binds) + ,@body)) + (when (buffer-live-p ,buffer) + (with-current-buffer ,buffer + ,@(mapcar (lambda (x) + `(unless ,(car x) + (kill-local-variable ',(cdr x)))) + local))))))) + +(defvar consult--fast-abbreviate-file-name nil) +(defun consult--fast-abbreviate-file-name (name) + "Return abbreviate file NAME. +This function is a pure variant of `abbreviate-file-name', which +does not access the file system. This is important if we require +that the operation is fast, even for remote paths or paths on +network file systems." + (save-match-data + (let (case-fold-search) ;; Assume that file system is case sensitive. + (setq name (directory-abbrev-apply name)) + (if (string-match (with-memoization consult--fast-abbreviate-file-name + (directory-abbrev-make-regexp (expand-file-name "~"))) + name) + (concat "~" (substring name (match-beginning 1))) + name)))) + +(defun consult--left-truncate-file (file) + "Return abbreviated file name of FILE for use in `completing-read' prompt." + (save-match-data + (let ((afile (abbreviate-file-name file))) + (if (string-match "/\\([^/]+\\)/\\([^/]+/?\\)\\'" afile) + (propertize (format "…/%s/%s" (match-string 1 afile) (match-string 2 afile)) + 'help-echo afile) + afile)))) + +(defun consult--directory-prompt (prompt dir) + "Return prompt, paths and default directory. + +PROMPT is the prompt prefix. The directory is appended to the +prompt prefix. For projects only the project name is shown. The +`default-directory' is not shown. Other directories are +abbreviated and only the last two path components are shown. + +If DIR is a string, it is returned as default directory. If DIR +is a list of strings, the list is returned as search paths. If +DIR is nil the `consult-project-function' is tried to retrieve +the default directory. If no project is found the +`default-directory' is returned as is. Otherwise the user is +asked for the directories or files to search via +`completing-read-multiple'." + (let* ((paths nil) + (dir + (pcase dir + ((pred stringp) dir) + ('nil (or (consult--project-root) default-directory)) + (_ + (pcase (if (stringp (car-safe dir)) + dir + ;; Preserve this-command across `completing-read-multiple' call, + ;; such that `consult-customize' continues to work. + (let ((this-command this-command) + (def (abbreviate-file-name default-directory)) + ;; TODO: `minibuffer-completing-file-name' is + ;; mostly deprecated, but still in use. Packages + ;; should instead use the completion metadata. + (minibuffer-completing-file-name t) + (ignore-case read-file-name-completion-ignore-case)) + (consult--minibuffer-with-setup-hook + (lambda () + (setq-local completion-ignore-case ignore-case) + (set-syntax-table minibuffer-local-filename-syntax)) + (completing-read-multiple "Directories or files: " + #'completion-file-name-table + nil t def 'consult--path-history def)))) + ((and `(,p) (guard (file-directory-p p))) p) + (ps (setq paths (mapcar (lambda (p) + (file-relative-name (expand-file-name p))) + ps)) + default-directory))))) + (edir (file-name-as-directory (expand-file-name dir))) + (pdir (let ((default-directory edir)) + ;; Bind default-directory in order to find the project + (consult--project-root)))) + (list + (format "%s (%s): " prompt + (pcase paths + (`(,p) (consult--left-truncate-file p)) + (`(,p . ,_) + (format "%d paths, %s, …" (length paths) (consult--left-truncate-file p))) + ((guard (equal edir pdir)) (concat "Project " (consult--project-name pdir))) + (_ (consult--left-truncate-file edir)))) + (or paths '(".")) + edir))) + +(defun consult--default-project-function (may-prompt) + "Return project root directory. +When no project is found and MAY-PROMPT is non-nil ask the user." + (when-let (proj (project-current may-prompt)) + (cond + ((fboundp 'project-root) (project-root proj)) + ((fboundp 'project-roots) (car (project-roots proj)))))) + +(defun consult--project-root (&optional may-prompt) + "Return project root as absolute path. +When no project is found and MAY-PROMPT is non-nil ask the user." + ;; Preserve this-command across project selection, + ;; such that `consult-customize' continues to work. + (let ((this-command this-command)) + (when-let (root (and consult-project-function + (funcall consult-project-function may-prompt))) + (expand-file-name root)))) + +(defun consult--project-name (dir) + "Return the project name for DIR." + (if (string-match "/\\([^/]+\\)/\\'" dir) + (propertize (match-string 1 dir) 'help-echo (abbreviate-file-name dir)) + dir)) + +(defun consult--format-file-line-match (file line match) + "Format string FILE:LINE:MATCH with faces." + (setq line (number-to-string line) + match (concat file ":" line ":" match) + file (length file)) + (put-text-property 0 file 'face 'consult-file match) + (put-text-property (1+ file) (+ 1 file (length line)) 'face 'consult-line-number match) + match) + +(defun consult--make-overlay (beg end &rest props) + "Make consult overlay between BEG and END with PROPS." + (let ((ov (make-overlay beg end))) + (while props + (overlay-put ov (car props) (cadr props)) + (setq props (cddr props))) + ov)) + +(defun consult--remove-dups (list) + "Remove duplicate strings from LIST." + (delete-dups (copy-sequence list))) + +(defsubst consult--in-range-p (pos) + "Return t if position POS lies in range `point-min' to `point-max'." + (<= (point-min) pos (point-max))) + +(defun consult--completion-window-p () + "Return non-nil if the selected window belongs to the completion UI." + (or (eq (selected-window) (active-minibuffer-window)) + (eq #'completion-list-mode (buffer-local-value 'major-mode (window-buffer))))) + +(defun consult--original-window () + "Return window which was just selected just before the minibuffer was entered. +In contrast to `minibuffer-selected-window' never return nil and +always return an appropriate non-minibuffer window." + (or (minibuffer-selected-window) + (if (window-minibuffer-p (selected-window)) + (next-window) + (selected-window)))) + +(defun consult--forbid-minibuffer () + "Raise an error if executed from the minibuffer." + (when (minibufferp) + (user-error "`%s' called inside the minibuffer" this-command))) + +(defun consult--require-minibuffer () + "Raise an error if executed outside the minibuffer." + (unless (minibufferp) + (user-error "`%s' must be called inside the minibuffer" this-command))) + +(defun consult--fontify-all () + "Ensure that the whole buffer is fontified." + ;; Font-locking is lazy, i.e., if a line has not been looked at yet, the line + ;; is not font-locked. We would observe this if consulting an unfontified + ;; line. Therefore we have to enforce font-locking now, which is slow. In + ;; order to prevent is hang-up we check the buffer size against + ;; `consult-fontify-max-size'. + (when (and consult-fontify-preserve jit-lock-mode + (< (buffer-size) consult-fontify-max-size)) + (jit-lock-fontify-now))) + +(defun consult--fontify-region (start end) + "Ensure that region between START and END is fontified." + (when (and consult-fontify-preserve jit-lock-mode) + (jit-lock-fontify-now start end))) + +(defmacro consult--with-increased-gc (&rest body) + "Temporarily increase the GC limit in BODY to optimize for throughput." + (cl-with-gensyms (overwrite) + `(let* ((,overwrite (> consult--gc-threshold gc-cons-threshold)) + (gc-cons-threshold (if ,overwrite consult--gc-threshold gc-cons-threshold)) + (gc-cons-percentage (if ,overwrite consult--gc-percentage gc-cons-percentage))) + ,@body))) + +(defmacro consult--slow-operation (message &rest body) + "Show delayed MESSAGE if BODY takes too long. +Also temporarily increase the GC limit via `consult--with-increased-gc'." + (declare (indent 1)) + `(let (set-message-function) ;; bug#63253: Broken `with-delayed-message' + (with-delayed-message (1 ,message) + (consult--with-increased-gc + ,@body)))) + +(defun consult--count-lines (pos) + "Move to position POS and return number of lines." + (let ((line 1)) + (while (< (point) pos) + (forward-line) + (when (<= (point) pos) + (cl-incf line))) + (goto-char pos) + line)) + +(defun consult--marker-from-line-column (buffer line column) + "Get marker in BUFFER from LINE and COLUMN." + (when (buffer-live-p buffer) + (with-current-buffer buffer + (save-excursion + (without-restriction + (goto-char (point-min)) + ;; Location data might be invalid by now! + (ignore-errors + (forward-line (1- line)) + (goto-char (min (+ (point) column) (pos-eol)))) + (point-marker)))))) + +(defun consult--line-prefix (&optional curr-line) + "Annotate `consult-location' candidates with line numbers. +CURR-LINE is the current line number." + (setq curr-line (or curr-line -1)) + (let* ((width (length (number-to-string (line-number-at-pos + (point-max) + consult-line-numbers-widen)))) + (before (format #("%%%dd " 0 6 (face consult-line-number-wrapped)) width)) + (after (format #("%%%dd " 0 6 (face consult-line-number-prefix)) width))) + (lambda (cand) + (let ((line (cdr (get-text-property 0 'consult-location cand)))) + (list cand (format (if (< line curr-line) before after) line) ""))))) + +(defsubst consult--location-candidate (cand marker line tofu &rest props) + "Add MARKER and LINE as `consult-location' text property to CAND. +Furthermore add the additional text properties PROPS, and append +TOFU suffix for disambiguation." + (setq cand (concat cand (consult--tofu-encode tofu))) + (add-text-properties 0 1 `(consult-location (,marker . ,line) ,@props) cand) + cand) + +;; There is a similar variable `yank-excluded-properties'. Unfortunately +;; we cannot use it here since it excludes too much (e.g., invisible) +;; and at the same time not enough (e.g., cursor-sensor-functions). +(defconst consult--remove-text-properties + '(category cursor cursor-intangible cursor-sensor-functions field follow-link + fontified front-sticky help-echo insert-behind-hooks insert-in-front-hooks + intangible keymap local-map modification-hooks mouse-face pointer read-only + rear-nonsticky yank-handler) + "List of text properties to remove from buffer strings.") + +(defsubst consult--buffer-substring (beg end &optional fontify) + "Return buffer substring between BEG and END. +If FONTIFY and `consult-fontify-preserve' are non-nil, first ensure that the +region has been fontified." + (if consult-fontify-preserve + (let (str) + (when fontify (consult--fontify-region beg end)) + (setq str (buffer-substring beg end)) + ;; TODO Propose the upstream addition of a function + ;; `preserve-list-of-text-properties', which should be as efficient as + ;; `remove-list-of-text-properties'. + (remove-list-of-text-properties + 0 (- end beg) consult--remove-text-properties str) + str) + (buffer-substring-no-properties beg end))) + +(defun consult--line-with-mark (marker) + "Current line string where the MARKER position is highlighted." + (let* ((beg (pos-bol)) + (end (pos-eol)) + (str (consult--buffer-substring beg end 'fontify))) + (if (>= marker end) + (concat str #(" " 0 1 (face consult-highlight-mark))) + (put-text-property (- marker beg) (- (1+ marker) beg) + 'face 'consult-highlight-mark str) + str))) + +;;;; Tofu cooks + +(defsubst consult--tofu-p (char) + "Return non-nil if CHAR is a tofu." + (<= consult--tofu-char char (+ consult--tofu-char consult--tofu-range -1))) + +(defun consult--tofu-hide (str) + "Hide the tofus in STR." + (let* ((max (length str)) + (end max)) + (while (and (> end 0) (consult--tofu-p (aref str (1- end)))) + (cl-decf end)) + (when (< end max) + (setq str (copy-sequence str)) + (put-text-property end max 'invisible t str)) + str)) + +(defsubst consult--tofu-append (cand id) + "Append tofu-encoded ID to CAND. +The ID must fit within a single character. It must be smaller +than `consult--tofu-range'." + (setq id (char-to-string (+ consult--tofu-char id))) + (add-text-properties 0 1 '(invisible t consult-strip t) id) + (concat cand id)) + +(defsubst consult--tofu-get (cand) + "Extract tofu-encoded ID from CAND. +See `consult--tofu-append'." + (- (aref cand (1- (length cand))) consult--tofu-char)) + +;; We must disambiguate the lines by adding a prefix such that two lines with +;; the same text can be distinguished. In order to avoid matching the line +;; number, such that the user can search for numbers with `consult-line', we +;; encode the line number as characters outside the Unicode range. By doing +;; that, no accidental matching can occur. +(defun consult--tofu-encode (n) + "Return tofu-encoded number N as a string. +Large numbers are encoded as multiple tofu characters." + (let (str tofu) + (while (progn + (setq tofu (char-to-string + (+ consult--tofu-char (% n consult--tofu-range))) + str (if str (concat tofu str) tofu)) + (and (>= n consult--tofu-range) + (setq n (/ n consult--tofu-range))))) + (add-text-properties 0 (length str) '(invisible t consult-strip t) str) + str)) + +;;;; Regexp utilities + +(defun consult--find-highlights (str start &rest ignored-faces) + "Find highlighted regions in STR from position START. +Highlighted regions have a non-nil face property. +IGNORED-FACES are ignored when searching for matches." + (let (highlights + (end (length str)) + (beg start)) + (while (< beg end) + (let ((next (next-single-property-change beg 'face str end)) + (val (get-text-property beg 'face str))) + (when (and val + (not (memq val ignored-faces)) + (not (and (consp val) + (seq-some (lambda (x) (memq x ignored-faces)) val)))) + (push (cons (- beg start) (- next start)) highlights)) + (setq beg next))) + (nreverse highlights))) + +(defun consult--point-placement (str start &rest ignored-faces) + "Compute point placement from STR with START offset. +IGNORED-FACES are ignored when searching for matches. +Return cons of point position and a list of match begin/end pairs." + (let* ((matches (apply #'consult--find-highlights str start ignored-faces)) + (pos (pcase-exhaustive consult-point-placement + ('match-beginning (or (caar matches) 0)) + ('match-end (or (cdar (last matches)) 0)) + ('line-beginning 0)))) + (dolist (match matches) + (cl-decf (car match) pos) + (cl-decf (cdr match) pos)) + (cons pos matches))) + +(defun consult--highlight-regexps (regexps ignore-case str) + "Highlight REGEXPS in STR. +If a regular expression contains capturing groups, only these are highlighted. +If no capturing groups are used highlight the whole match. Case is ignored +if IGNORE-CASE is non-nil." + (dolist (re regexps) + (let ((i 0)) + (while (and (let ((case-fold-search ignore-case)) + (string-match re str i)) + ;; Ensure that regexp search made progress (edge case for .*) + (> (match-end 0) i)) + ;; Unfortunately there is no way to avoid the allocation of the match + ;; data, since the number of capturing groups is unknown. + (let ((m (match-data))) + (setq i (cadr m) m (or (cddr m) m)) + (while m + (when (car m) + (add-face-text-property (car m) (cadr m) + 'consult-highlight-match nil str)) + (setq m (cddr m))))))) + str) + +(defconst consult--convert-regexp-table + (append + ;; For simplicity, treat word beginning/end as word boundaries, + ;; since PCRE does not make this distinction. Usually the + ;; context determines if \b is the beginning or the end. + '(("\\<" . "\\b") ("\\>" . "\\b") + ("\\_<" . "\\b") ("\\_>" . "\\b")) + ;; Treat \` and \' as beginning and end of line. This is more + ;; widely supported and makes sense for line-based commands. + '(("\\`" . "^") ("\\'" . "$")) + ;; Historical: Unescaped *, +, ? are supported at the beginning + (mapcan (lambda (x) + (mapcar (lambda (y) + (cons (concat x y) + (concat (string-remove-prefix "\\" x) "\\" y))) + '("*" "+" "?"))) + '("" "\\(" "\\(?:" "\\|" "^")) + ;; Different escaping + (mapcan (lambda (x) `(,x (,(cdr x) . ,(car x)))) + '(("\\|" . "|") + ("\\(" . "(") ("\\)" . ")") + ("\\{" . "{") ("\\}" . "}")))) + "Regexp conversion table.") + +(defun consult--convert-regexp (regexp type) + "Convert Emacs REGEXP to regexp syntax TYPE." + (if (memq type '(emacs basic)) + regexp + ;; Support for Emacs regular expressions is fairly complete for basic + ;; usage. There are a few unsupported Emacs regexp features: + ;; - \= point matching + ;; - Syntax classes \sx \Sx + ;; - Character classes \cx \Cx + ;; - Explicitly numbered groups (?3:group) + (replace-regexp-in-string + (rx (or "\\\\" "\\^" ;; Pass through + (seq (or "\\(?:" "\\|") (any "*+?")) ;; Historical: \|+ or \(?:* etc + (seq "\\(" (any "*+")) ;; Historical: \(* or \(+ + (seq (or bos "^") (any "*+?")) ;; Historical: + or * at the beginning + (seq (opt "\\") (any "(){|}")) ;; Escape parens/braces/pipe + (seq "\\" (any "'<>`")) ;; Special escapes + (seq "\\_" (any "<>")))) ;; Beginning or end of symbol + (lambda (x) (or (cdr (assoc x consult--convert-regexp-table)) x)) + regexp 'fixedcase 'literal))) + +(defun consult--default-regexp-compiler (input type ignore-case) + "Compile the INPUT string to a list of regular expressions. +The function should return a pair, the list of regular expressions and a +highlight function. The highlight function should take a single +argument, the string to highlight given the INPUT. TYPE is the desired +type of regular expression, which can be `basic', `extended', `emacs' or +`pcre'. If IGNORE-CASE is non-nil return a highlight function which +matches case insensitively." + (setq input (consult--split-escaped input)) + (cons (mapcar (lambda (x) (consult--convert-regexp x type)) input) + (when-let (regexps (seq-filter #'consult--valid-regexp-p input)) + (apply-partially #'consult--highlight-regexps regexps ignore-case)))) + +(defun consult--split-escaped (str) + "Split STR at spaces, which can be escaped with backslash." + (mapcar + (lambda (x) (string-replace "\0" " " x)) + (split-string (replace-regexp-in-string + "\\\\\\\\\\|\\\\ " + (lambda (x) (if (equal x "\\ ") "\0" x)) + str 'fixedcase 'literal) + " +" t))) + +(defun consult--join-regexps (regexps type) + "Join REGEXPS of TYPE." + ;; Add look-ahead wrapper only if there is more than one regular expression + (cond + ((and (eq type 'pcre) (cdr regexps)) + (concat "^" (mapconcat (lambda (x) (format "(?=.*%s)" x)) + regexps ""))) + ((eq type 'basic) + (string-join regexps ".*")) + (t + (when (length> regexps 3) + (message "Too many regexps, %S ignored. Use post-filtering!" + (string-join (seq-drop regexps 3) " ")) + (setq regexps (seq-take regexps 3))) + (consult--join-regexps-permutations regexps (and (eq type 'emacs) "\\"))))) + +(defun consult--join-regexps-permutations (regexps esc) + "Join all permutations of REGEXPS. +ESC is the escaping string for choice and groups." + (pcase regexps + ('nil "") + (`(,r) r) + (_ (mapconcat + (lambda (r) + (concat esc "(" r esc ").*" esc "(" + (consult--join-regexps-permutations (remove r regexps) esc) + esc ")")) + regexps (concat esc "|"))))) + +(defun consult--valid-regexp-p (re) + "Return t if regexp RE is valid." + (condition-case nil + (progn (string-match-p re "") t) + (invalid-regexp nil))) + +(defun consult--regexp-filter (regexps) + "Create filter regexp from REGEXPS." + (if (stringp regexps) + regexps + (mapconcat (lambda (x) (concat "\\(?:" x "\\)")) regexps "\\|"))) + +;;;; Lookup functions + +(defun consult--lookup-member (selected candidates &rest _) + "Lookup SELECTED in CANDIDATES list, return original element." + (car (member selected candidates))) + +(defun consult--lookup-cons (selected candidates &rest _) + "Lookup SELECTED in CANDIDATES alist, return cons." + (assoc selected candidates)) + +(defun consult--lookup-cdr (selected candidates &rest _) + "Lookup SELECTED in CANDIDATES alist, return `cdr' of element." + (cdr (assoc selected candidates))) + +(defun consult--lookup-location (selected candidates &rest _) + "Lookup SELECTED in CANDIDATES list of `consult-location' category. +Return the location marker." + (when-let (found (member selected candidates)) + (setq found (car (consult--get-location (car found)))) + ;; Check that marker is alive + (and (or (not (markerp found)) (marker-buffer found)) found))) + +(defun consult--lookup-prop (prop selected candidates &rest _) + "Lookup SELECTED in CANDIDATES list and return PROP value." + (when-let (found (member selected candidates)) + (get-text-property 0 prop (car found)))) + +(defun consult--lookup-candidate (selected candidates &rest _) + "Lookup SELECTED in CANDIDATES list and return property `consult--candidate'." + (consult--lookup-prop 'consult--candidate selected candidates)) + +;;;; Preview support + +(defun consult--preview-allowed-p (fun) + "Return non-nil if FUN is an allowed preview mode hook." + (or (memq fun consult-preview-allowed-hooks) + (when-let (((symbolp fun)) + (name (symbol-name fun)) + ;; Global modes in Emacs 29 are activated via a + ;; `find-file-hook' ending with `-check-buffers'. This has been + ;; changed in Emacs 30. Now a `change-major-mode-hook' is used + ;; instead with the suffix `-check-buffers'. + (suffix (if (eval-when-compile (>= emacs-major-version 30)) + "-enable-in-buffer" + "-check-buffers")) + ((string-suffix-p suffix name))) + (memq (intern (string-remove-suffix suffix name)) + consult-preview-allowed-hooks)))) + +(defun consult--filter-find-file-hook (orig &rest hooks) + "Filter `find-file-hook' by `consult-preview-allowed-hooks'. +This function is an advice for `run-hooks'. +ORIG is the original function, HOOKS the arguments." + (if (memq 'find-file-hook hooks) + (cl-letf* (((default-value 'find-file-hook) + (seq-filter #'consult--preview-allowed-p + (default-value 'find-file-hook))) + (find-file-hook (default-value 'find-file-hook))) + (apply orig hooks)) + (apply orig hooks))) + +(defun consult--find-file-temporarily-1 (name) + "Open file NAME, helper function for `consult--find-file-temporarily'." + (when-let (((not (seq-find (lambda (x) (string-match-p x name)) + consult-preview-excluded-files))) + ;; file-attributes may throw permission denied error + (attrs (ignore-errors (file-attributes name))) + (size (file-attribute-size attrs))) + (let* ((partial (>= size consult-preview-partial-size)) + (buffer (if partial + (generate-new-buffer (format "consult-partial-preview-%s" name)) + (find-file-noselect name 'nowarn))) + (success nil)) + (unwind-protect + (with-current-buffer buffer + (if (not partial) + (when (or (eq major-mode 'hexl-mode) + (and (eq major-mode 'fundamental-mode) + (save-excursion (search-forward "\0" nil 'noerror)))) + (error "No preview of binary file `%s'" + (file-name-nondirectory name))) + (with-silent-modifications + (setq buffer-read-only t) + (insert-file-contents name nil 0 consult-preview-partial-chunk) + (goto-char (point-max)) + (insert "\nFile truncated. End of partial preview.\n") + (goto-char (point-min))) + (when (save-excursion (search-forward "\0" nil 'noerror)) + (error "No partial preview of binary file `%s'" + (file-name-nondirectory name))) + ;; Auto detect major mode and hope for the best, given that the + ;; file is only previewed partially. If an error is thrown the + ;; buffer will be killed and preview is aborted. + (set-auto-mode) + (font-lock-mode 1)) + (when (bound-and-true-p so-long-detected-p) + (error "No preview of file `%s' with long lines" + (file-name-nondirectory name))) + ;; Run delayed hooks listed in `consult-preview-allowed-hooks'. + (dolist (hook (reverse (cons 'after-change-major-mode-hook delayed-mode-hooks))) + (run-hook-wrapped hook (lambda (fun) + (when (consult--preview-allowed-p fun) + (funcall fun)) + nil))) + (setq success (current-buffer))) + (unless success + (kill-buffer buffer)))))) + +(defun consult--find-file-temporarily (name) + "Open file NAME temporarily for preview." + (let ((vars (delq nil + (mapcar + (pcase-lambda (`(,k . ,v)) + (if (boundp k) + (list k v (default-value k) (symbol-value k)) + (message "consult-preview-variables: The variable `%s' is not bound" k) + nil)) + consult-preview-variables)))) + (condition-case err + (unwind-protect + (progn + (advice-add #'run-hooks :around #'consult--filter-find-file-hook) + (pcase-dolist (`(,k ,v . ,_) vars) + (set-default k v) + (set k v)) + (consult--find-file-temporarily-1 name)) + (advice-remove #'run-hooks #'consult--filter-find-file-hook) + (pcase-dolist (`(,k ,_ ,d ,v) vars) + (set-default k d) + (set k v))) + (error + (message "%s" (error-message-string err)) + nil)))) + +(defun consult--temporary-files () + "Return a function to open files temporarily for preview." + (let ((dir default-directory) + (hook (make-symbol "consult--temporary-files-upgrade-hook")) + (orig-buffers (buffer-list)) + temporary-buffers) + (fset hook + (lambda (_) + ;; Fully initialize previewed files and keep them alive. + (unless (consult--completion-window-p) + (let (live-files) + (pcase-dolist (`(,file . ,buf) temporary-buffers) + (when-let (wins (and (buffer-live-p buf) + (get-buffer-window-list buf))) + (push (cons file (mapcar + (lambda (win) + (cons win (window-state-get win t))) + wins)) + live-files))) + (pcase-dolist (`(,_ . ,buf) temporary-buffers) + (kill-buffer buf)) + (setq temporary-buffers nil) + (pcase-dolist (`(,file . ,wins) live-files) + (when-let (buf (consult--file-action file)) + (push buf orig-buffers) + (pcase-dolist (`(,win . ,state) wins) + (setf (car (alist-get 'buffer state)) buf) + (window-state-put state win)))))))) + (lambda (&optional name) + (if name + (let ((default-directory dir)) + (setq name (abbreviate-file-name (expand-file-name name))) + (or + ;; Find existing fully initialized buffer (non-previewed). We have + ;; to check for fully initialized buffer before accessing the + ;; previewed buffers, since `embark-act' can open a buffer which is + ;; currently previewed, such that we end up with two buffers for + ;; the same file - one previewed and only partially initialized and + ;; one fully initialized. In this case we prefer the fully + ;; initialized buffer. For directories `get-file-buffer' returns nil, + ;; therefore we have to special case Dired. + (if (and (fboundp 'dired-find-buffer-nocreate) (file-directory-p name)) + (dired-find-buffer-nocreate name) + (get-file-buffer name)) + ;; Find existing previewed buffer. Previewed buffers are not fully + ;; initialized (hooks are delayed) in order to ensure fast preview. + (cdr (assoc name temporary-buffers)) + ;; Finally, if no existing buffer has been found, open the file for + ;; preview. + (when-let (buf (consult--find-file-temporarily name)) + ;; Only add new buffer if not already in the list + (unless (or (rassq buf temporary-buffers) (memq buf orig-buffers)) + (add-hook 'window-selection-change-functions hook) + (push (cons name buf) temporary-buffers) + ;; Disassociate buffer from file by setting `buffer-file-name' + ;; and `dired-directory' to nil and rename the buffer. This + ;; lets us open an already previewed buffer with the Embark + ;; default action C-. RET. + (with-current-buffer buf + (rename-buffer + (format " Preview:%s" + (file-name-nondirectory (directory-file-name name))) + 'unique)) + ;; The buffer disassociation is delayed to avoid breaking modes + ;; like `pdf-view-mode' or `doc-view-mode' which rely on + ;; `buffer-file-name'. Executing (set-visited-file-name nil) + ;; early also prevents the major mode initialization. + (let ((hook (make-symbol "consult--temporary-files-disassociate-hook"))) + (fset hook (lambda () + (when (buffer-live-p buf) + (with-current-buffer buf + (remove-hook 'pre-command-hook hook) + (setq-local buffer-read-only t + dired-directory nil + buffer-file-name nil))))) + (add-hook 'pre-command-hook hook)) + ;; Only keep a few buffers alive + (while (length> temporary-buffers consult-preview-max-count) + (kill-buffer (cdar (last temporary-buffers))) + (setq temporary-buffers (nbutlast temporary-buffers)))) + buf))) + (remove-hook 'window-selection-change-functions hook) + (pcase-dolist (`(,_ . ,buf) temporary-buffers) + (kill-buffer buf)) + (setq temporary-buffers nil))))) + +(defun consult--invisible-open-permanently () + "Open overlays which hide the current line. +See `isearch-open-necessary-overlays' and `isearch-open-overlay-temporary'." + (if (and (derived-mode-p 'org-mode) (fboundp 'org-fold-show-set-visibility)) + ;; New Org 9.6 fold-core API + (let ((inhibit-redisplay t)) ;; HACK: Prevent flicker due to premature redisplay + (org-fold-show-set-visibility 'canonical)) + (dolist (ov (overlays-in (pos-bol) (pos-eol))) + (when-let (fun (overlay-get ov 'isearch-open-invisible)) + (when (invisible-p (overlay-get ov 'invisible)) + (funcall fun ov)))))) + +(defun consult--invisible-open-temporarily () + "Temporarily open overlays which hide the current line. +See `isearch-open-necessary-overlays' and `isearch-open-overlay-temporary'." + (if (and (derived-mode-p 'org-mode) + (fboundp 'org-fold-show-set-visibility) + (fboundp 'org-fold-core-get-regions) + (fboundp 'org-fold-core-region)) + ;; New Org 9.6 fold-core API + ;; TODO The provided Org API `org-fold-show-set-visibility' cannot be used + ;; efficiently. We obtain all regions in the whole buffer in order to + ;; restore them. A better show API would return all the applied + ;; modifications such that we can restore the ones which got modified. + (progn + (unless consult--org-fold-regions + (setq consult--org-fold-regions + (delq nil (org-fold-core-get-regions + :with-markers t :from (point-min) :to (point-max)))) + (when consult--org-fold-regions + (let ((hook (make-symbol "consult--invisible-open-temporarily-cleanup-hook")) + (buffer (current-buffer)) + (depth (recursion-depth))) + (fset hook + (lambda () + (when (= (recursion-depth) depth) + (remove-hook 'minibuffer-exit-hook hook) + (run-at-time + 0 nil + (lambda () + (when (buffer-live-p buffer) + (with-current-buffer buffer + (pcase-dolist (`(,beg ,end ,_) consult--org-fold-regions) + (when (markerp beg) (set-marker beg nil)) + (when (markerp end) (set-marker end nil))) + (kill-local-variable 'consult--org-fold-regions)))))))) + (add-hook 'minibuffer-exit-hook hook)))) + (let ((inhibit-redisplay t)) ;; HACK: Prevent flicker due to premature redisplay + (org-fold-show-set-visibility 'canonical)) + (list (lambda () + (pcase-dolist (`(,beg ,end ,spec) consult--org-fold-regions) + (org-fold-core-region beg end t spec))))) + (let (restore) + (dolist (ov (overlays-in (pos-bol) (pos-eol))) + (let ((inv (overlay-get ov 'invisible))) + (when (and (invisible-p inv) (overlay-get ov 'isearch-open-invisible)) + (push (if-let (fun (overlay-get ov 'isearch-open-invisible-temporary)) + (progn + (funcall fun ov nil) + (lambda () (funcall fun ov t))) + (overlay-put ov 'invisible nil) + (lambda () (overlay-put ov 'invisible inv))) + restore)))) + restore))) + +(defun consult--jump-ensure-buffer (pos) + "Ensure that buffer of marker POS is displayed, return t if successful." + (or (not (markerp pos)) + ;; Switch to buffer if it is not visible + (when-let ((buf (marker-buffer pos))) + (or (and (eq (current-buffer) buf) (eq (window-buffer) buf)) + (consult--buffer-action buf 'norecord) + t)))) + +(defun consult--jump (pos) + "Jump to POS. +First push current position to mark ring, then move to new +position and run `consult-after-jump-hook'." + (when pos + ;; Extract marker from list with with overlay positions, see `consult--line-match' + (when (consp pos) (setq pos (car pos))) + ;; When the marker is in the same buffer, record previous location + ;; such that the user can jump back quickly. + (when (or (not (markerp pos)) (eq (current-buffer) (marker-buffer pos))) + ;; push-mark mutates markers in the mark-ring and the mark-marker. + ;; Therefore we transform the marker to a number to be safe. + ;; We all love side effects! + (setq pos (+ pos 0)) + (push-mark (point) t)) + (when (consult--jump-ensure-buffer pos) + (unless (= (goto-char pos) (point)) ;; Widen if jump failed + (widen) + (goto-char pos)) + (consult--invisible-open-permanently) + (run-hooks 'consult-after-jump-hook))) + nil) + +(defun consult--jump-preview () + "The preview function used if selecting from a list of candidate positions. +The function can be used as the `:state' argument of `consult--read'." + (let (restore) + (lambda (action cand) + (when (eq action 'preview) + (mapc #'funcall restore) + (setq restore nil) + ;; TODO Better buffer preview support + ;; 1. Use consult--buffer-preview instead of consult--jump-ensure-buffer + ;; 2. Remove function consult--jump-ensure-buffer + ;; 3. Remove consult-buffer-other-* from consult-customize-alist + (when-let ((pos (or (car-safe cand) cand)) ;; Candidate can be previewed + ((consult--jump-ensure-buffer pos))) + (let ((saved-min (point-min-marker)) + (saved-max (point-max-marker)) + (saved-pos (point-marker))) + (set-marker-insertion-type saved-max t) ;; Grow when text is inserted + (push (lambda () + (when-let ((buf (marker-buffer saved-pos))) + (with-current-buffer buf + (narrow-to-region saved-min saved-max) + (goto-char saved-pos) + (set-marker saved-pos nil) + (set-marker saved-min nil) + (set-marker saved-max nil)))) + restore)) + (unless (= (goto-char pos) (point)) ;; Widen if jump failed + (widen) + (goto-char pos)) + (setq restore (nconc (consult--invisible-open-temporarily) restore)) + ;; Ensure that cursor is properly previewed (gh:minad/consult#764) + (unless (eq cursor-in-non-selected-windows 'box) + (let ((orig cursor-in-non-selected-windows) + (buf (current-buffer))) + (push + (if (local-variable-p 'cursor-in-non-selected-windows) + (lambda () + (when (buffer-live-p buf) + (with-current-buffer buf + (setq-local cursor-in-non-selected-windows orig)))) + (lambda () + (when (buffer-live-p buf) + (with-current-buffer buf + (kill-local-variable 'cursor-in-non-selected-windows))))) + restore) + (setq-local cursor-in-non-selected-windows 'box))) + ;; Match previews + (let ((overlays + (list (save-excursion + (let ((vbeg (progn (beginning-of-visual-line) (point))) + (vend (progn (end-of-visual-line) (point))) + (end (pos-eol))) + (consult--make-overlay vbeg (if (= vend end) (1+ end) vend) + 'face 'consult-preview-line + 'window (selected-window) + 'priority 1)))))) + (dolist (match (cdr-safe cand)) + (push (consult--make-overlay (+ (point) (car match)) + (+ (point) (cdr match)) + 'face 'consult-preview-match + 'window (selected-window) + 'priority 2) + overlays)) + (push (lambda () (mapc #'delete-overlay overlays)) restore)) + (run-hooks 'consult-after-jump-hook)))))) + +(defun consult--jump-state () + "The state function used if selecting from a list of candidate positions." + (consult--state-with-return (consult--jump-preview) #'consult--jump)) + +(defun consult--get-location (cand) + "Return location from CAND." + (let ((loc (get-text-property 0 'consult-location cand))) + (when (consp (car loc)) + ;; Transform cheap marker to real marker + (setcar loc (set-marker (make-marker) (cdar loc) (caar loc)))) + loc)) + +(defun consult--location-state (candidates) + "Location state function. +The cheap location markers from CANDIDATES are upgraded on window +selection change to full Emacs markers." + (let ((jump (consult--jump-state)) + (hook (make-symbol "consult--location-upgrade-hook"))) + (fset hook + (lambda (_) + (unless (consult--completion-window-p) + (remove-hook 'window-selection-change-functions hook) + (mapc #'consult--get-location + (if (functionp candidates) (funcall candidates) candidates))))) + (lambda (action cand) + (pcase action + ('setup (add-hook 'window-selection-change-functions hook)) + ('exit (remove-hook 'window-selection-change-functions hook))) + (funcall jump action cand)))) + +(defun consult--state-with-return (state return) + "Compose STATE function with RETURN function." + (lambda (action cand) + (funcall state action cand) + (when (and cand (eq action 'return)) + (funcall return cand)))) + +(defmacro consult--define-state (type) + "Define state function for TYPE." + `(defun ,(intern (format "consult--%s-state" type)) () + ,(format "State function for %ss with preview. +The result can be passed as :state argument to `consult--read'." type) + (consult--state-with-return (,(intern (format "consult--%s-preview" type))) + #',(intern (format "consult--%s-action" type))))) + +(defun consult--preview-key-normalize (preview-key) + "Normalize PREVIEW-KEY, return alist of keys and debounce times." + (let ((keys) + (debounce 0)) + (setq preview-key (ensure-list preview-key)) + (while preview-key + (if (eq (car preview-key) :debounce) + (setq debounce (cadr preview-key) + preview-key (cddr preview-key)) + (let ((key (car preview-key))) + (unless (eq key 'any) + (setq key (consult--key-parse key))) + (push (cons key debounce) keys)) + (pop preview-key))) + keys)) + +(defun consult--preview-key-debounce (preview-key cand) + "Return debounce value of PREVIEW-KEY given the current candidate CAND." + (when (and (consp preview-key) (memq :keys preview-key)) + (setq preview-key (funcall (plist-get preview-key :predicate) cand))) + (let ((map (make-sparse-keymap)) + (keys (this-single-command-keys)) + any) + (pcase-dolist (`(,k . ,d) (consult--preview-key-normalize preview-key)) + (if (eq k 'any) + (setq any d) + (define-key map k `(lambda () ,d)))) + (setq keys (lookup-key map keys)) + (if (functionp keys) (funcall keys) any))) + +(defun consult--preview-append-local-pch (fun) + "Append FUN to local `post-command-hook' list." + ;; Symbol indirection because of bug#46407. + (let ((hook (make-symbol "consult--preview-post-command-hook"))) + (fset hook fun) + ;; TODO Emacs 28 has a bug, where the hook--depth-alist is not cleaned up properly + ;; Do not use the broken add-hook here. + ;;(add-hook 'post-command-hook hook 'append 'local) + (setq-local post-command-hook + (append + (remove t post-command-hook) + (list hook) + (and (memq t post-command-hook) '(t)))))) + +(defun consult--with-preview-1 (preview-key state transform candidate save-input fun) + "Add preview support for FUN. +See `consult--with-preview' for the arguments +PREVIEW-KEY, STATE, TRANSFORM, CANDIDATE and SAVE-INPUT." + (let ((mb-input "") mb-narrow selected timer previewed) + (consult--minibuffer-with-setup-hook + (if (and state preview-key) + (lambda () + (let ((hook (make-symbol "consult--preview-minibuffer-exit-hook")) + (depth (recursion-depth))) + (fset hook + (lambda () + (when (= (recursion-depth) depth) + (remove-hook 'minibuffer-exit-hook hook) + (when timer + (cancel-timer timer) + (setq timer nil)) + (with-selected-window (consult--original-window) + ;; STEP 3: Reset preview + (when previewed + (funcall state 'preview nil)) + ;; STEP 4: Notify the preview function of the minibuffer exit + (funcall state 'exit nil))))) + (add-hook 'minibuffer-exit-hook hook)) + ;; STEP 1: Setup the preview function + (with-selected-window (consult--original-window) + (funcall state 'setup nil)) + (setq consult--preview-function + (lambda () + (when-let ((cand (funcall candidate))) + ;; Drop properties to prevent bugs regarding candidate + ;; lookup, which must handle candidates without + ;; properties. Otherwise the arguments passed to the + ;; lookup function are confusing, since during preview + ;; the candidate has properties but for the final lookup + ;; after completion it does not. + (setq cand (substring-no-properties cand)) + (with-selected-window (active-minibuffer-window) + (let ((input (minibuffer-contents-no-properties)) + (narrow consult--narrow) + (win (consult--original-window))) + (with-selected-window win + (when-let ((transformed (funcall transform narrow input cand)) + (debounce (consult--preview-key-debounce preview-key transformed))) + (when timer + (cancel-timer timer) + (setq timer nil)) + ;; The transformed candidate may have text + ;; properties, which change the preview display. + ;; This matters for example for `consult-grep', + ;; where the current candidate and input may + ;; stay equal, but the highlighting of the + ;; candidate changes while the candidates list + ;; is lagging a bit behind and updates + ;; asynchronously. + ;; + ;; In older Consult versions we instead compared + ;; the input without properties, since I worried + ;; that comparing the transformed candidates + ;; could be potentially expensive. However + ;; comparing the transformed candidates is more + ;; correct. The transformed candidate is the + ;; thing which is actually previewed. + (unless (equal-including-properties previewed transformed) + (if (> debounce 0) + (setq timer + (run-at-time + debounce nil + (lambda () + ;; Preview only when a completion + ;; window is selected and when + ;; the preview window is alive. + (when (and (consult--completion-window-p) + (window-live-p win)) + (with-selected-window win + ;; STEP 2: Preview candidate + (funcall state 'preview (setq previewed transformed))))))) + ;; STEP 2: Preview candidate + (funcall state 'preview (setq previewed transformed))))))))))) + (consult--preview-append-local-pch + (lambda () + (setq mb-input (minibuffer-contents-no-properties) + mb-narrow consult--narrow) + (funcall consult--preview-function)))) + (lambda () + (consult--preview-append-local-pch + (lambda () + (setq mb-input (minibuffer-contents-no-properties) + mb-narrow consult--narrow))))) + (unwind-protect + (setq selected (when-let (result (funcall fun)) + (when-let ((save-input) + (list (symbol-value save-input)) + ((equal (car list) result))) + (set save-input (cdr list))) + (funcall transform mb-narrow mb-input result))) + (when save-input + (add-to-history save-input mb-input)) + (when state + ;; STEP 5: The preview function should perform its final action + (funcall state 'return selected)))))) + +(defmacro consult--with-preview (preview-key state transform candidate save-input &rest body) + "Add preview support to BODY. + +STATE is the state function. +TRANSFORM is the transformation function. +CANDIDATE is the function returning the current candidate. +PREVIEW-KEY are the keys which triggers the preview. +SAVE-INPUT can be a history variable symbol to save the input. + +The state function takes two arguments, an action argument and the +selected candidate. The candidate argument can be nil if no candidate is +selected or if the selection was aborted. The function is called in +sequence with the following arguments: + + 1. \\='setup nil After entering the mb (minibuffer-setup-hook). +⎧ 2. \\='preview CAND/nil Preview candidate CAND or reset if CAND is nil. +⎪ \\='preview CAND/nil +⎪ \\='preview CAND/nil +⎪ ... +⎩ 3. \\='preview nil Reset preview. + 4. \\='exit nil Before exiting the mb (minibuffer-exit-hook). + 5. \\='return CAND/nil After leaving the mb, CAND has been selected. + +The state function is always executed with the original window selected, +see `consult--original-window'. The state function is called once in +the beginning of the minibuffer setup with the `setup' argument. This is +useful in order to perform certain setup operations which require that +the minibuffer is initialized. During completion candidates are +previewed. Then the function is called with the `preview' argument and a +candidate CAND or nil if no candidate is selected. Furthermore if nil is +passed for CAND, then the preview must be undone and the original state +must be restored. The call with the `exit' argument happens once at the +end of the completion process, just before exiting the minibuffer. The +minibuffer is still alive at that point. Both `setup' and `exit' are +only useful for setup and cleanup operations. They don't receive a +candidate as argument. After leaving the minibuffer, the selected +candidate or nil is passed to the state function with the action +argument `return'. At this point the state function can perform the +actual action on the candidate. The state function with the `return' +argument is the continuation of `consult--read'. Via `unwind-protect' it +is guaranteed, that if the `setup' action of a state function is +invoked, the state function will also be called with `exit' and +`return'." + (declare (indent 5)) + `(consult--with-preview-1 ,preview-key ,state ,transform ,candidate ,save-input (lambda () ,@body))) + +;;;; Narrowing and grouping + +(defun consult--prefix-group (cand transform) + "Return title for CAND or TRANSFORM the candidate. +The candidate must have a `consult--prefix-group' property." + (if transform + (substring cand (1+ (length (get-text-property 0 'consult--prefix-group cand)))) + (get-text-property 0 'consult--prefix-group cand))) + +(defun consult--type-group (types) + "Return group function for TYPES." + (lambda (cand transform) + (if transform cand + (alist-get (get-text-property 0 'consult--type cand) types)))) + +(defun consult--type-narrow (types) + "Return narrowing configuration from TYPES." + (list :predicate + (lambda (cand) (eq (get-text-property 0 'consult--type cand) consult--narrow)) + :keys types)) + +(defun consult--widen-key () + "Return widening key, if `consult-widen-key' is not set. +The default is twice the `consult-narrow-key'." + (cond + (consult-widen-key + (consult--key-parse consult-widen-key)) + (consult-narrow-key + (let ((key (consult--key-parse consult-narrow-key))) + (vconcat key key))))) + +(defun consult-narrow (key) + "Narrow current completion with KEY. + +This command is used internally by the narrowing system of `consult--read'." + (interactive + (list (unless (equal (this-single-command-keys) (consult--widen-key)) + last-command-event))) + (consult--require-minibuffer) + (setq consult--narrow key) + (when consult--narrow-predicate + (setq minibuffer-completion-predicate (and consult--narrow consult--narrow-predicate))) + (when consult--narrow-overlay + (delete-overlay consult--narrow-overlay)) + (when consult--narrow + (setq consult--narrow-overlay + (consult--make-overlay + (1- (minibuffer-prompt-end)) (minibuffer-prompt-end) + 'before-string + (propertize (format " [%s]" (alist-get consult--narrow + consult--narrow-keys)) + 'face 'consult-narrow-indicator)))) + (run-hooks 'consult--completion-refresh-hook)) + +(defconst consult--narrow-delete + `(menu-item + "" nil :filter + ,(lambda (&optional _) + (when (equal (minibuffer-contents-no-properties) "") + (lambda () + (interactive) + (consult-narrow nil)))))) + +(defconst consult--narrow-space + `(menu-item + "" nil :filter + ,(lambda (&optional _) + (let ((str (minibuffer-contents-no-properties))) + (when-let (pair (or (and (length= str 1) + (assoc (aref str 0) consult--narrow-keys)) + (and (equal str "") + (assoc ?\s consult--narrow-keys)))) + (lambda () + (interactive) + (delete-minibuffer-contents) + (consult-narrow (car pair)))))))) + +(defun consult-narrow-help () + "Print narrowing help as a `minibuffer-message'. + +This command can be bound to a key in `consult-narrow-map', +to make it available for commands with narrowing." + (interactive) + (consult--require-minibuffer) + (let ((minibuffer-message-timeout 1000000)) + (minibuffer-message + (mapconcat (lambda (x) + (concat + (propertize (key-description (list (car x))) 'face 'consult-key) + " " + (propertize (cdr x) 'face 'consult-help))) + consult--narrow-keys + " ")))) + +(defun consult--narrow-setup (settings map) + "Setup narrowing with SETTINGS and keymap MAP." + (if (memq :keys settings) + (setq consult--narrow-predicate (plist-get settings :predicate) + consult--narrow-keys (plist-get settings :keys)) + (setq consult--narrow-predicate nil + consult--narrow-keys settings)) + (when-let ((key consult-narrow-key)) + (setq key (consult--key-parse key)) + (dolist (pair consult--narrow-keys) + (define-key map (vconcat key (vector (car pair))) + (cons (cdr pair) #'consult-narrow)))) + (when-let ((widen (consult--widen-key))) + (define-key map widen (cons "All" #'consult-narrow))) + (when-let ((init (and (memq :keys settings) (plist-get settings :initial)))) + (consult-narrow init))) + +;; Emacs 28: hide in M-X +(put #'consult-narrow-help 'completion-predicate #'ignore) +(put #'consult-narrow 'completion-predicate #'ignore) + +;;;; Splitting completion style + +(defun consult--split-perl (str &optional _plist) + "Split input STR in async input and filtering part. + +The function returns a list with three elements: The async +string, the start position of the completion filter string and a +force flag. If the first character is a punctuation character it +determines the separator. Examples: \"/async/filter\", +\"#async#filter\"." + (if (string-match-p "^[[:punct:]]" str) + (save-match-data + (let ((q (regexp-quote (substring str 0 1)))) + (string-match (concat "^" q "\\([^" q "]*\\)\\(" q "\\)?") str) + `(,(match-string 1 str) + ,(match-end 0) + ;; Force update it two punctuation characters are entered. + ,(match-end 2) + ;; List of highlights + (0 . ,(match-beginning 1)) + ,@(and (match-end 2) `((,(match-beginning 2) . ,(match-end 2))))))) + `(,str ,(length str)))) + +(defun consult--split-nil (str &optional _plist) + "Treat the complete input STR as async input." + `(,str ,(length str))) + +(defun consult--split-separator (str plist) + "Split input STR in async input and filtering part at first separator. +PLIST is the splitter configuration, including the separator." + (let ((sep (regexp-quote (char-to-string (plist-get plist :separator))))) + (save-match-data + (if (string-match (format "^\\([^%s]+\\)\\(%s\\)?" sep sep) str) + `(,(match-string 1 str) + ,(match-end 0) + ;; Force update it space is entered. + ,(match-end 2) + ;; List of highlights + ,@(and (match-end 2) `((,(match-beginning 2) . ,(match-end 2))))) + `(,str ,(length str)))))) + +(defun consult--split-setup (split) + "Setup splitting completion style with splitter function SPLIT." + (let* ((styles completion-styles) + (catdef completion-category-defaults) + (catovr completion-category-overrides) + (try (lambda (str table pred point) + (let ((completion-styles styles) + (completion-category-defaults catdef) + (completion-category-overrides catovr) + (pos (cadr (funcall split str)))) + (pcase (completion-try-completion (substring str pos) table pred + (max 0 (- point pos))) + ('t t) + (`(,newstr . ,newpt) + (cons (concat (substring str 0 pos) newstr) + (+ pos newpt))))))) + (all (lambda (str table pred point) + (let ((completion-styles styles) + (completion-category-defaults catdef) + (completion-category-overrides catovr) + (pos (cadr (funcall split str)))) + (completion-all-completions (substring str pos) table pred + (max 0 (- point pos))))))) + (setq-local completion-styles-alist (cons `(consult--split ,try ,all "") + completion-styles-alist) + completion-styles '(consult--split) + completion-category-defaults nil + completion-category-overrides nil))) + +;;;; Asynchronous filtering functions + +(defun consult--async-p (fun) + "Return t if FUN is an asynchronous completion function." + (and (functionp fun) + (condition-case nil + (progn (funcall fun "" nil 'metadata) nil) + (wrong-number-of-arguments t)))) + +(defmacro consult--with-async (bind &rest body) + "Setup asynchronous completion in BODY. + +BIND is the asynchronous function binding." + (declare (indent 1)) + (let ((async (car bind))) + `(let ((,async ,@(cdr bind)) + (new-chunk (max read-process-output-max consult--process-chunk)) + orig-chunk) + (consult--minibuffer-with-setup-hook + ;; Append such that we overwrite the completion style setting of + ;; `fido-mode'. See `consult--async-split' and + ;; `consult--split-setup'. + (:append + (lambda () + (when (consult--async-p ,async) + (setq orig-chunk read-process-output-max + read-process-output-max new-chunk) + (funcall ,async 'setup) + (let* ((mb (current-buffer)) + (fun (lambda () + (when-let (win (active-minibuffer-window)) + (when (eq (window-buffer win) mb) + (with-current-buffer mb + (let ((inhibit-modification-hooks t)) + ;; Push input string to request refresh. + (funcall ,async (minibuffer-contents-no-properties)))))))) + ;; We use a symbol in order to avoid adding lambdas to + ;; the hook variable. Symbol indirection because of + ;; bug#46407. + (hook (make-symbol "consult--async-after-change-hook"))) + ;; Delay modification hook to ensure that minibuffer is still + ;; alive after the change, such that we don't restart a new + ;; asynchronous search right before exiting the minibuffer. + (fset hook (lambda (&rest _) (run-at-time 0 nil fun))) + (add-hook 'after-change-functions hook nil 'local) + (funcall hook))))) + (let ((,async (if (consult--async-p ,async) ,async (lambda (_) ,async)))) + (unwind-protect + ,(macroexp-progn body) + (funcall ,async 'destroy) + (when (and orig-chunk (eq read-process-output-max new-chunk)) + (setq read-process-output-max orig-chunk)))))))) + +(defun consult--async-sink () + "Create ASYNC sink function. + +An async function must accept a single action argument. For the +\\='setup action it is guaranteed that the call originates from +the minibuffer. For the other actions no assumption about the +context can be made. + +\\='setup Setup the internal closure state. Return nil. +\\='destroy Destroy the internal closure state. Return nil. +\\='flush Flush the list of candidates. Return nil. +\\='refresh Request UI refresh. Return nil. +nil Return the list of candidates. +list Append the list to the already existing candidates list and return it. +string Update with the current user input string. Return nil." + (let (candidates last buffer) + (lambda (action) + (pcase-exhaustive action + ('setup + (setq buffer (current-buffer)) + nil) + ((or (pred stringp) 'destroy) nil) + ('flush (setq candidates nil last nil)) + ('refresh + ;; Refresh the UI when the current minibuffer window belongs + ;; to the current asynchronous completion session. + (when-let (win (active-minibuffer-window)) + (when (eq (window-buffer win) buffer) + (with-selected-window win + (run-hooks 'consult--completion-refresh-hook) + ;; Interaction between asynchronous completion functions and + ;; preview: We have to trigger preview immediately when + ;; candidates arrive (gh:minad/consult#436). + (when (and consult--preview-function candidates) + (funcall consult--preview-function))))) + nil) + ('nil candidates) + ((pred consp) + (setq last (last (if last (setcdr last action) (setq candidates action)))) + candidates))))) + +(defun consult--async-split-style () + "Return the async splitting style function and initial string." + (or (alist-get consult-async-split-style consult-async-split-styles-alist) + (user-error "Splitting style `%s' not found" consult-async-split-style))) + +(defun consult--async-split-initial (initial) + "Return initial string for async command. +INITIAL is the additional initial string." + (concat (plist-get (consult--async-split-style) :initial) initial)) + +(defun consult--async-split-thingatpt (thing) + "Return THING at point with async initial prefix." + (when-let (str (thing-at-point thing)) + (consult--async-split-initial str))) + +(defun consult--async-split (async &optional split) + "Create async function, which splits the input string. +ASYNC is the async sink. +SPLIT is the splitting function." + (unless split + (let* ((style (consult--async-split-style)) + (fn (plist-get style :function))) + (setq split (lambda (str) (funcall fn str style))))) + (lambda (action) + (pcase action + ('setup + (consult--split-setup split) + (funcall async 'setup)) + ((pred stringp) + (pcase-let* ((`(,async-str ,_ ,force . ,highlights) + (funcall split action)) + (async-len (length async-str)) + (input-len (length action)) + (end (minibuffer-prompt-end))) + ;; Highlight punctuation characters + (remove-list-of-text-properties end (+ end input-len) '(face)) + (dolist (hl highlights) + (put-text-property (+ end (car hl)) (+ end (cdr hl)) + 'face 'consult-async-split)) + (funcall async + ;; Pass through if the input is long enough! + (if (or force (>= async-len consult-async-min-input)) + async-str + ;; Pretend that there is no input + "")))) + (_ (funcall async action))))) + +(defun consult--async-indicator (async) + "Create async function with a state indicator overlay. +ASYNC is the async sink." + (let (ov) + (lambda (action &optional state) + (pcase action + ('indicator + (overlay-put ov 'display + (pcase-exhaustive state + ('running #("*" 0 1 (face consult-async-running))) + ('finished #(":" 0 1 (face consult-async-finished))) + ('killed #(";" 0 1 (face consult-async-failed))) + ('failed #("!" 0 1 (face consult-async-failed)))))) + ('setup + (setq ov (make-overlay (- (minibuffer-prompt-end) 2) + (- (minibuffer-prompt-end) 1))) + (funcall async 'setup)) + ('destroy + (delete-overlay ov) + (funcall async 'destroy)) + (_ (funcall async action)))))) + +(defun consult--async-log (formatted &rest args) + "Log FORMATTED ARGS to variable `consult--async-log'." + (with-current-buffer (get-buffer-create consult--async-log) + (goto-char (point-max)) + (insert (apply #'format formatted args)))) + +(defun consult--async-process (async builder &rest props) + "Create process source async function. + +ASYNC is the async function which receives the candidates. +BUILDER is the command line builder function. +PROPS are optional properties passed to `make-process'." + (setq async (consult--async-indicator async)) + (let (proc proc-buf last-args count) + (lambda (action) + (pcase action + ("" ;; If no input is provided kill current process + (when proc + (delete-process proc) + (kill-buffer proc-buf) + (setq proc nil proc-buf nil)) + (setq last-args nil)) + ((pred stringp) + (funcall async action) + (let* ((args (funcall builder action))) + (unless (stringp (car args)) + (setq args (car args))) + (unless (equal args last-args) + (setq last-args args) + (when proc + (delete-process proc) + (kill-buffer proc-buf) + (setq proc nil proc-buf nil)) + (when args + (let* ((flush t) + (rest "") + (proc-filter + (lambda (_ out) + (when flush + (setq flush nil) + (funcall async 'flush)) + (let ((lines (split-string out "[\r\n]+"))) + (if (not (cdr lines)) + (setq rest (concat rest (car lines))) + (setcar lines (concat rest (car lines))) + (let* ((len (length lines)) + (last (nthcdr (- len 2) lines))) + (setq rest (cadr last) + count (+ count len -1)) + (setcdr last nil) + (funcall async lines)))))) + (proc-sentinel + (lambda (_ event) + (when flush + (setq flush nil) + (funcall async 'flush)) + (funcall async 'indicator + (cond + ((string-prefix-p "killed" event) 'killed) + ((string-prefix-p "finished" event) 'finished) + (t 'failed))) + (when (and (string-prefix-p "finished" event) (not (equal rest ""))) + (cl-incf count) + (funcall async (list rest))) + (consult--async-log + "consult--async-process sentinel: event=%s lines=%d\n" + (string-trim event) count) + (when (> (buffer-size proc-buf) 0) + (with-current-buffer (get-buffer-create consult--async-log) + (goto-char (point-max)) + (insert ">>>>> stderr >>>>>\n") + (let ((beg (point))) + (insert-buffer-substring proc-buf) + (save-excursion + (goto-char beg) + (message #("%s" 0 2 (face error)) + (buffer-substring-no-properties (pos-bol) (pos-eol))))) + (insert "<<<<< stderr <<<<<\n"))))) + (process-adaptive-read-buffering nil)) + (funcall async 'indicator 'running) + (consult--async-log "consult--async-process started %S\n" args) + (setq count 0 + proc-buf (generate-new-buffer " *consult-async-stderr*") + proc (apply #'make-process + `(,@props + :connection-type pipe + :name ,(car args) + ;;; XXX tramp bug, the stderr buffer must be empty + :stderr ,proc-buf + :noquery t + :command ,args + :filter ,proc-filter + :sentinel ,proc-sentinel))))))) + nil) + ('destroy + (when proc + (delete-process proc) + (kill-buffer proc-buf) + (setq proc nil proc-buf nil)) + (funcall async 'destroy)) + (_ (funcall async action)))))) + +(defun consult--async-highlight (async builder) + "Return a new ASYNC function with candidate highlighting. +BUILDER is the command line builder function." + (let (highlight) + (lambda (action) + (cond + ((stringp action) + (setq highlight (cdr (funcall builder action))) + (funcall async action)) + ((and (consp action) highlight) + (dolist (str action) + (funcall highlight str)) + (funcall async action)) + (t (funcall async action)))))) + +(defun consult--async-throttle (async &optional throttle debounce) + "Create async function from ASYNC which throttles input. + +The THROTTLE delay defaults to `consult-async-input-throttle'. +The DEBOUNCE delay defaults to `consult-async-input-debounce'." + (setq throttle (or throttle consult-async-input-throttle) + debounce (or debounce consult-async-input-debounce)) + (let* ((input "") (timer (timer-create)) (last 0)) + (lambda (action) + (pcase action + ((pred stringp) + (unless (equal action input) + (cancel-timer timer) + (funcall async "") ;; cancel running process + (setq input action) + (unless (equal action "") + (timer-set-function timer (lambda () + (setq last (float-time)) + (funcall async action))) + (timer-set-time + timer + (timer-relative-time + nil (max debounce (- (+ last throttle) (float-time))))) + (timer-activate timer))) + nil) + ('destroy + (cancel-timer timer) + (funcall async 'destroy)) + (_ (funcall async action)))))) + +(defun consult--async-refresh-immediate (async) + "Create async function from ASYNC, which refreshes the display. + +The refresh happens immediately when candidates are pushed." + (lambda (action) + (pcase action + ((or (pred consp) 'flush) + (prog1 (funcall async action) + (funcall async 'refresh))) + (_ (funcall async action))))) + +(defun consult--async-refresh-timer (async &optional delay) + "Create async function from ASYNC, which refreshes the display. + +The refresh happens after a DELAY, defaulting to `consult-async-refresh-delay'." + (let ((delay (or delay consult-async-refresh-delay)) + (timer (timer-create))) + (timer-set-function timer async '(refresh)) + (lambda (action) + (prog1 (funcall async action) + (pcase action + ((or (pred consp) 'flush) + (unless (memq timer timer-list) + (timer-set-time timer (timer-relative-time nil delay)) + (timer-activate timer))) + ('destroy + (cancel-timer timer))))))) + +(defmacro consult--async-command (builder &rest args) + "Asynchronous command pipeline. +ARGS is a list of `make-process' properties and transforms. +BUILDER is the command line builder function, which takes the +input string and must either return a list of command line +arguments or a pair of the command line argument list and a +highlighting function." + (declare (indent 1)) + `(thread-first + (consult--async-sink) + (consult--async-refresh-timer) + ,@(seq-take-while (lambda (x) (not (keywordp x))) args) + (consult--async-process + ,builder + ,@(seq-drop-while (lambda (x) (not (keywordp x))) args)) + (consult--async-throttle) + (consult--async-split))) + +(defmacro consult--async-transform (async &rest transform) + "Use FUN to TRANSFORM candidates of ASYNC." + (cl-with-gensyms (async-var action-var) + `(let ((,async-var ,async)) + (lambda (,action-var) + (funcall ,async-var (if (consp ,action-var) (,@transform ,action-var) ,action-var)))))) + +(defun consult--async-map (async fun) + "Map candidates of ASYNC by FUN." + (consult--async-transform async mapcar fun)) + +(defun consult--async-filter (async fun) + "Filter candidates of ASYNC by FUN." + (consult--async-transform async seq-filter fun)) + +;;;; Dynamic collections based + +(defun consult--dynamic-compute (async fun &optional debounce) + "Dynamic computation of candidates. +ASYNC is the sink. +FUN computes the candidates given the input. +DEBOUNCE is the time after which an interrupted computation +should be restarted." + (setq debounce (or debounce consult-async-input-debounce)) + (setq async (consult--async-indicator async)) + (let* ((request) (current) (timer) + (cancel (lambda () (when timer (cancel-timer timer) (setq timer nil)))) + (start (lambda (req) (setq request req) (funcall async 'refresh)))) + (lambda (action) + (pcase action + ((and 'nil (guard (not request))) + (funcall async nil)) + ('nil + (funcall cancel) + (let ((state 'killed)) + (unwind-protect + (progn + (funcall async 'indicator 'running) + (redisplay) + ;; Run computation + (let ((response (funcall fun request))) + ;; Flush and update candidate list + (funcall async 'flush) + (setq state 'finished current request) + (funcall async response))) + (funcall async 'indicator state) + ;; If the computation was killed, restart it after some time. + (when (eq state 'killed) + (setq timer (run-at-time debounce nil start request))) + (setq request nil)))) + ((pred stringp) + (funcall cancel) + (if (or (equal action "") (equal action current)) + (funcall async 'indicator 'finished) + (funcall start action))) + ('destroy + (funcall cancel) + (funcall async 'destroy)) + (_ (funcall async action)))))) + +(defun consult--dynamic-collection (fun) + "Dynamic collection with input splitting. +FUN computes the candidates given the input." + (thread-first + (consult--async-sink) + (consult--dynamic-compute fun) + (consult--async-throttle) + (consult--async-split))) + +;;;; Special keymaps + +(defvar-keymap consult-async-map + :doc "Keymap added for commands with asynchronous candidates." + ;; Overwriting some unusable defaults of default minibuffer completion. + "<remap> <minibuffer-complete-word>" #'self-insert-command + ;; Remap Emacs 29 history and default completion for now + ;; (gh:minad/consult#613). + "<remap> <minibuffer-complete-defaults>" #'ignore + "<remap> <minibuffer-complete-history>" #'consult-history) + +(defvar-keymap consult-narrow-map + :doc "Narrowing keymap which is added to the local minibuffer map. +Note that `consult-narrow-key' and `consult-widen-key' are bound dynamically." + "SPC" consult--narrow-space + "DEL" consult--narrow-delete) + +;;;; Internal API: consult--read + +(defun consult--annotate-align (cand ann) + "Align annotation ANN by computing the maximum CAND width." + (setq consult--annotate-align-width + (max consult--annotate-align-width + (* (ceiling (consult--display-width cand) + consult--annotate-align-step) + consult--annotate-align-step))) + (when ann + (concat + #(" " 0 1 (display (space :align-to (+ left consult--annotate-align-width)))) + ann))) + +(defun consult--add-history (async items) + "Add ITEMS to the minibuffer future history. +ASYNC must be non-nil for async completion functions." + (delete-dups + (append + ;; the defaults are at the beginning of the future history + (ensure-list minibuffer-default) + ;; then our custom items + (remove "" (remq nil (ensure-list items))) + ;; Add all the completions for non-async commands. For async commands this + ;; feature is not useful, since if one selects a completion candidate, the + ;; async search is restarted using that candidate string. This usually does + ;; not yield a desired result since the async input uses a special format, + ;; e.g., `#grep#filter'. + (unless async + (all-completions "" + minibuffer-completion-table + minibuffer-completion-predicate))))) + +(defun consult--setup-keymap (keymap async narrow preview-key) + "Setup minibuffer keymap. + +KEYMAP is a command-specific keymap. +ASYNC must be non-nil for async completion functions. +NARROW are the narrow settings. +PREVIEW-KEY are the preview keys." + (let ((old-map (current-local-map)) + (map (make-sparse-keymap))) + + ;; Add narrow keys + (when narrow + (consult--narrow-setup narrow map)) + + ;; Preview trigger keys + (when (and (consp preview-key) (memq :keys preview-key)) + (setq preview-key (plist-get preview-key :keys))) + (setq preview-key (mapcar #'car (consult--preview-key-normalize preview-key))) + (when preview-key + (dolist (key preview-key) + (unless (or (eq key 'any) (lookup-key old-map key)) + (define-key map key #'ignore)))) + + ;; Put the keymap together + (use-local-map + (make-composed-keymap + (delq nil (list keymap + (and async consult-async-map) + (and narrow consult-narrow-map) + map)) + old-map)))) + +(defun consult--tofu-hide-in-minibuffer (&rest _) + "Hide the tofus in the minibuffer." + (let* ((min (minibuffer-prompt-end)) + (max (point-max)) + (pos max)) + (while (and (> pos min) (consult--tofu-p (char-before pos))) + (cl-decf pos)) + (when (< pos max) + (add-text-properties pos max '(invisible t rear-nonsticky t cursor-intangible t))))) + +(defun consult--read-annotate (fun cand) + "Annotate CAND with annotation function FUN." + (pcase (funcall fun cand) + (`(,_ ,_ ,suffix) suffix) + (ann ann))) + +(defun consult--read-affixate (fun cands) + "Affixate CANDS with annotation function FUN." + (mapcar (lambda (cand) + (let ((ann (funcall fun cand))) + (if (consp ann) + ann + (setq ann (or ann "")) + (list cand "" + ;; The default completion UI adds the + ;; `completions-annotations' face if no other faces are + ;; present. + (if (text-property-not-all 0 (length ann) 'face nil ann) + ann + (propertize ann 'face 'completions-annotations)))))) + cands)) + +(cl-defun consult--read-1 (table &key + prompt predicate require-match history default + keymap category initial narrow add-history annotate + state preview-key sort lookup group inherit-input-method) + "See `consult--read' for the documentation of the arguments." + (consult--minibuffer-with-setup-hook + (:append (lambda () + (add-hook 'after-change-functions #'consult--tofu-hide-in-minibuffer nil 'local) + (consult--setup-keymap keymap (consult--async-p table) narrow preview-key) + (setq-local minibuffer-default-add-function + (apply-partially #'consult--add-history (consult--async-p table) add-history)))) + (consult--with-async (async table) + (consult--with-preview + preview-key state + (lambda (narrow input cand) + (funcall lookup cand (funcall async nil) input narrow)) + (apply-partially #'run-hook-with-args-until-success + 'consult--completion-candidate-hook) + (pcase-exhaustive history + (`(:input ,var) var) + ((pred symbolp))) + ;; Do not unnecessarily let-bind the lambdas to avoid over-capturing in + ;; the interpreter. This will make closures and the lambda string + ;; representation larger, which makes debugging much worse. Fortunately + ;; the over-capturing problem does not affect the bytecode interpreter + ;; which does a proper scope analysis. + (let* ((metadata `(metadata + ,@(when category `((category . ,category))) + ,@(when group `((group-function . ,group))) + ,@(when annotate + `((affixation-function + . ,(apply-partially #'consult--read-affixate annotate)) + (annotation-function + . ,(apply-partially #'consult--read-annotate annotate)))) + ,@(unless sort '((cycle-sort-function . identity) + (display-sort-function . identity))))) + (consult--annotate-align-width 0) + (selected + (completing-read + prompt + (lambda (str pred action) + (let ((result (complete-with-action action (funcall async nil) str pred))) + (if (eq action 'metadata) + (if (and (eq (car result) 'metadata) (cdr result)) + ;; Merge metadata + `(metadata ,@(cdr metadata) ,@(cdr result)) + metadata) + result))) + predicate require-match initial + (if (symbolp history) history (cadr history)) + default + inherit-input-method))) + ;; Repair the null completion semantics. `completing-read' may return + ;; an empty string even if REQUIRE-MATCH is non-nil. One can always + ;; opt-in to null completion by passing the empty string for DEFAULT. + (when (and (eq require-match t) (not default) (equal selected "")) + (user-error "No selection")) + selected))))) + +(cl-defun consult--read (table &rest options &key + prompt predicate require-match history default + keymap category initial narrow add-history annotate + state preview-key sort lookup group inherit-input-method) + "Enhanced completing read function to select from TABLE. + +The function is a thin wrapper around `completing-read'. Keyword +arguments are used instead of positional arguments for code +clarity. On top of `completing-read' it additionally supports +computing the candidate list asynchronously, candidate preview +and narrowing. You should use `completing-read' instead of +`consult--read' if you don't use asynchronous candidate +computation or candidate preview. + +Keyword OPTIONS: + +PROMPT is the string which is shown as prompt in the minibuffer. +PREDICATE is a filter function called for each candidate, returns +nil or t. +REQUIRE-MATCH equals t means that an exact match is required. +HISTORY is the symbol of the history variable. +DEFAULT is the default selected value. +ADD-HISTORY is a list of items to add to the history. +CATEGORY is the completion category symbol. +SORT should be set to nil if the candidates are already sorted. +This will disable sorting in the completion UI. +LOOKUP is a lookup function passed the selected candidate string, +the list of candidates, the current input string and the current +narrowing value. +ANNOTATE is a function passed a candidate string. The function +should either return an annotation string or a list of three +strings (candidate prefix postfix). +INITIAL is the initial input string. +STATE is the state function, see `consult--with-preview'. +GROUP is a completion metadata `group-function' as documented in +the Elisp manual. +PREVIEW-KEY are the preview keys. Can be nil, `any', a single +key or a list of keys. +NARROW is an alist of narrowing prefix strings and description. +KEYMAP is a command-specific keymap. +INHERIT-INPUT-METHOD, if non-nil the minibuffer inherits the +input method." + ;; supported types + (cl-assert (or (functionp table) ;; dynamic table or asynchronous function + (obarrayp table) ;; obarray + (hash-table-p table) ;; hash table + (not table) ;; empty list + (stringp (car table)) ;; string list + (and (consp (car table)) (stringp (caar table))) ;; string alist + (and (consp (car table)) (symbolp (caar table))))) ;; symbol alist + (ignore prompt predicate require-match history default + keymap category initial narrow add-history annotate + state preview-key sort lookup group inherit-input-method) + (apply #'consult--read-1 table + (append + (consult--customize-get) + options + (list :prompt "Select: " + :preview-key consult-preview-key + :sort t + :lookup (lambda (selected &rest _) selected))))) + +;;;; Internal API: consult--prompt + +(cl-defun consult--prompt-1 (&key prompt history add-history initial default + keymap state preview-key transform inherit-input-method) + "See `consult--prompt' for documentation." + (consult--minibuffer-with-setup-hook + (:append (lambda () + (consult--setup-keymap keymap nil nil preview-key) + (setq-local minibuffer-default-add-function + (apply-partially #'consult--add-history nil add-history)))) + (consult--with-preview + preview-key state + (lambda (_narrow inp _cand) (funcall transform inp)) + (lambda () "") + history + (read-from-minibuffer prompt initial nil nil history default inherit-input-method)))) + +(cl-defun consult--prompt (&rest options &key prompt history add-history initial default + keymap state preview-key transform inherit-input-method) + "Read from minibuffer. + +Keyword OPTIONS: + +PROMPT is the string to prompt with. +TRANSFORM is a function which is applied to the current input string. +HISTORY is the symbol of the history variable. +INITIAL is initial input. +DEFAULT is the default selected value. +ADD-HISTORY is a list of items to add to the history. +STATE is the state function, see `consult--with-preview'. +PREVIEW-KEY are the preview keys (nil, `any', a single key or a list of keys). +KEYMAP is a command-specific keymap." + (ignore prompt history add-history initial default + keymap state preview-key transform inherit-input-method) + (apply #'consult--prompt-1 + (append + (consult--customize-get) + options + (list :prompt "Input: " + :preview-key consult-preview-key + :transform #'identity)))) + +;;;; Internal API: consult--multi + +(defsubst consult--multi-source (sources cand) + "Lookup source for CAND in SOURCES list." + (aref sources (consult--tofu-get cand))) + +(defun consult--multi-predicate (sources cand) + "Predicate function called for each candidate CAND given SOURCES." + (let* ((src (consult--multi-source sources cand)) + (narrow (plist-get src :narrow)) + (type (or (car-safe narrow) narrow -1))) + (or (eq consult--narrow type) + (not (or consult--narrow (plist-get src :hidden)))))) + +(defun consult--multi-narrow (sources) + "Return narrow list from SOURCES." + (thread-last sources + (mapcar (lambda (src) + (when-let (narrow (plist-get src :narrow)) + (if (consp narrow) + narrow + (when-let (name (plist-get src :name)) + (cons narrow name)))))) + (delq nil) + (delete-dups))) + +(defun consult--multi-annotate (sources cand) + "Annotate candidate CAND from multi SOURCES." + (consult--annotate-align + cand + (let ((src (consult--multi-source sources cand))) + (if-let ((fun (plist-get src :annotate))) + (funcall fun (cdr (get-text-property 0 'multi-category cand))) + (plist-get src :name))))) + +(defun consult--multi-group (sources cand transform) + "Return title of candidate CAND or TRANSFORM the candidate given SOURCES." + (if transform cand + (plist-get (consult--multi-source sources cand) :name))) + +(defun consult--multi-preview-key (sources) + "Return preview keys from SOURCES." + (list :predicate + (lambda (cand) + (if (plist-member (cdr cand) :preview-key) + (plist-get (cdr cand) :preview-key) + consult-preview-key)) + :keys + (delete-dups + (seq-mapcat (lambda (src) + (let ((key (if (plist-member src :preview-key) + (plist-get src :preview-key) + consult-preview-key))) + (ensure-list key))) + sources)))) + +(defun consult--multi-lookup (sources selected candidates _input narrow &rest _) + "Lookup SELECTED in CANDIDATES given SOURCES, with potential NARROW." + (if (or (string-blank-p selected) + (not (consult--tofu-p (aref selected (1- (length selected)))))) + ;; Non-existing candidate without Tofu or default submitted (empty string) + (let* ((src (cond + (narrow (seq-find (lambda (src) + (let ((n (plist-get src :narrow))) + (eq (or (car-safe n) n -1) narrow))) + sources)) + ((seq-find (lambda (src) (plist-get src :default)) sources)) + ((seq-find (lambda (src) (not (plist-get src :hidden))) sources)) + ((aref sources 0)))) + (idx (seq-position sources src)) + (def (and (string-blank-p selected) ;; default candidate + (seq-find (lambda (cand) (eq idx (consult--tofu-get cand))) candidates)))) + (if def + (cons (cdr (get-text-property 0 'multi-category def)) src) + `(,selected :match nil ,@src))) + (if-let (found (member selected candidates)) + ;; Existing candidate submitted + (cons (cdr (get-text-property 0 'multi-category (car found))) + (consult--multi-source sources selected)) + ;; Non-existing Tofu'ed candidate submitted, e.g., via Embark + `(,(substring selected 0 -1) :match nil ,@(consult--multi-source sources selected))))) + +(defun consult--multi-candidates (sources) + "Return `consult--multi' candidates from SOURCES." + (let ((idx 0) candidates) + (seq-doseq (src sources) + (let* ((face (and (plist-member src :face) `(face ,(plist-get src :face)))) + (cat (plist-get src :category)) + (items (plist-get src :items)) + (items (if (functionp items) (funcall items) items))) + (dolist (item items) + (let* ((str (or (car-safe item) item)) + (cand (consult--tofu-append str idx))) + ;; Preserve existing `multi-category' datum of the candidate. + (if (and (eq str item) (get-text-property 0 'multi-category str)) + (when face (add-text-properties 0 (length str) face cand)) + ;; Attach `multi-category' datum and face. + (add-text-properties + 0 (length str) + `(multi-category (,cat . ,(or (cdr-safe item) item)) ,@face) cand)) + (push cand candidates)))) + (cl-incf idx)) + (nreverse candidates))) + +(defun consult--multi-enabled-sources (sources) + "Return vector of enabled SOURCES." + (vconcat + (seq-filter (lambda (src) + (if-let (pred (plist-get src :enabled)) + (funcall pred) + t)) + (mapcar (lambda (src) + (if (symbolp src) (symbol-value src) src)) + sources)))) + +(defun consult--multi-state (sources) + "State function given SOURCES." + (when-let (states (delq nil (mapcar (lambda (src) + (when-let (fun (plist-get src :state)) + (cons src (funcall fun)))) + sources))) + (let (last-fun) + (pcase-lambda (action `(,cand . ,src)) + (pcase action + ('setup + (pcase-dolist (`(,_ . ,fun) states) + (funcall fun 'setup nil))) + ('exit + (pcase-dolist (`(,_ . ,fun) states) + (funcall fun 'exit nil))) + ('preview + (let ((selected-fun (cdr (assq src states)))) + ;; If the candidate source changed during preview communicate to + ;; the last source, that none of its candidates is previewed anymore. + (when (and last-fun (not (eq last-fun selected-fun))) + (funcall last-fun 'preview nil)) + (setq last-fun selected-fun) + (when selected-fun + (funcall selected-fun 'preview cand)))) + ('return + (let ((selected-fun (cdr (assq src states)))) + ;; Finish all the sources, except the selected one. + (pcase-dolist (`(,_ . ,fun) states) + (unless (eq fun selected-fun) + (funcall fun 'return nil))) + ;; Finish the source with the selected candidate + (when selected-fun + (funcall selected-fun 'return cand))))))))) + +(defun consult--multi (sources &rest options) + "Select from candidates taken from a list of SOURCES. + +OPTIONS is the plist of options passed to `consult--read'. The following +options are supported: :require-match, :history, :keymap, :initial, +:add-history, :sort and :inherit-input-method. The other options of +`consult--read' are used by the implementation of `consult--multi' and +should not be overwritten, except in in special scenarios. + +The function returns the selected candidate in the form (cons candidate +source-plist). The plist has the key :match with a value nil if the +candidate does not exist, t if the candidate exists and `new' if the +candidate has been created. The sources of the source list can either be +symbols of source variables or source values. Source values must be +plists with fields from the following list. + +Required source fields: +* :category - Completion category symbol. +* :items - List of strings to select from or function returning + list of strings. Note that the strings can use text properties + to carry metadata, which is then available to the :annotate, + :action and :state functions. + +Optional source fields: +* :name - Name of the source as a string, used for narrowing, + group titles and annotations. +* :narrow - Narrowing character or (character . string) pair. +* :enabled - Function which must return t if the source is enabled. +* :hidden - When t candidates of this source are hidden by default. +* :face - Face used for highlighting the candidates. +* :annotate - Annotation function called for each candidate, returns string. +* :history - Name of history variable to add selected candidate. +* :default - Must be t if the first item of the source is the default value. +* :action - Function called with the selected candidate. +* :new - Function called with new candidate name, only if :require-match is nil. +* :state - State constructor for the source, must return the + state function. The state function is informed about state + changes of the UI and can be used to implement preview. +* Other custom source fields can be added depending on the use + case. Note that the source is returned by `consult--multi' + together with the selected candidate." + (let* ((sources (consult--multi-enabled-sources sources)) + (candidates (consult--with-increased-gc + (consult--multi-candidates sources))) + (selected + (apply #'consult--read + candidates + (append + options + (list + :category 'multi-category + :predicate (apply-partially #'consult--multi-predicate sources) + :annotate (apply-partially #'consult--multi-annotate sources) + :group (apply-partially #'consult--multi-group sources) + :lookup (apply-partially #'consult--multi-lookup sources) + :preview-key (consult--multi-preview-key sources) + :narrow (consult--multi-narrow sources) + :state (consult--multi-state sources)))))) + (when-let (history (plist-get (cdr selected) :history)) + (add-to-history history (car selected))) + (if (plist-member (cdr selected) :match) + (when-let (fun (plist-get (cdr selected) :new)) + (funcall fun (car selected)) + (plist-put (cdr selected) :match 'new)) + (when-let (fun (plist-get (cdr selected) :action)) + (funcall fun (car selected))) + (setq selected `(,(car selected) :match t ,@(cdr selected)))) + selected)) + +;;;; Customization macro + +(defun consult--customize-put (cmds prop form) + "Set property PROP to FORM of commands CMDS." + (dolist (cmd cmds) + (cond + ((and (boundp cmd) (consp (symbol-value cmd))) + (setf (plist-get (symbol-value cmd) prop) (eval form 'lexical))) + ((functionp cmd) + (setf (plist-get (alist-get cmd consult--customize-alist) prop) form)) + (t (user-error "%s is neither a Command command nor a source" cmd)))) + nil) + +(defmacro consult-customize (&rest args) + "Set properties of commands or sources. +ARGS is a list of commands or sources followed by the list of +keyword-value pairs. For `consult-customize' to succeed, the +customized sources and commands must exist. When a command is +invoked, the value of `this-command' is used to lookup the +corresponding customization options." + (let (setter) + (while args + (let ((cmds (seq-take-while (lambda (x) (not (keywordp x))) args))) + (setq args (seq-drop-while (lambda (x) (not (keywordp x))) args)) + (while (keywordp (car args)) + (push `(consult--customize-put ',cmds ,(car args) ',(cadr args)) setter) + (setq args (cddr args))))) + (macroexp-progn setter))) + +(defun consult--customize-get (&optional cmd) + "Get configuration from `consult--customize-alist' for CMD." + (mapcar (lambda (x) (eval x 'lexical)) + (alist-get (or cmd this-command) consult--customize-alist))) + +;;;; Commands + +;;;;; Command: consult-completion-in-region + +(defun consult--insertion-preview (start end) + "State function for previewing a candidate in a specific region. +The candidates are previewed in the region from START to END. This function is +used as the `:state' argument for `consult--read' in the `consult-yank' family +of functions and in `consult-completion-in-region'." + (unless (or (minibufferp) + ;; Disable preview if anything odd is going on with the markers. + ;; Otherwise we get "Marker points into wrong buffer errors". See + ;; gh:minad/consult#375, where Org mode source blocks are + ;; completed in a different buffer than the original buffer. This + ;; completion is probably also problematic in my Corfu completion + ;; package. + (not (eq (window-buffer) (current-buffer))) + (and (markerp start) (not (eq (marker-buffer start) (current-buffer)))) + (and (markerp end) (not (eq (marker-buffer end) (current-buffer))))) + (let (ov) + (lambda (action cand) + (cond + ((and (not cand) ov) + (delete-overlay ov) + (setq ov nil)) + ((and (eq action 'preview) cand) + (unless ov + (setq ov (consult--make-overlay start end + 'invisible t + 'window (selected-window)))) + ;; Use `add-face-text-property' on a copy of "cand in order to merge face properties + (setq cand (copy-sequence cand)) + (add-face-text-property 0 (length cand) 'consult-preview-insertion t cand) + ;; Use the `before-string' property since the overlay might be empty. + (overlay-put ov 'before-string cand))))))) + +;;;###autoload +(defun consult-completion-in-region (start end collection &optional predicate) + "Use minibuffer completion as the UI for `completion-at-point'. + +The function is called with 4 arguments: START END COLLECTION +PREDICATE. The arguments and expected return value are as +specified for `completion-in-region'. Use this function as a +value for `completion-in-region-function'." + (barf-if-buffer-read-only) + (let* ((initial (buffer-substring-no-properties start end)) + (metadata (completion-metadata initial collection predicate)) + ;; TODO: `minibuffer-completing-file-name' is mostly deprecated, but + ;; still in use. Packages should instead use the completion metadata. + (minibuffer-completing-file-name + (eq 'file (completion-metadata-get metadata 'category))) + (threshold (completion--cycle-threshold metadata)) + (all (completion-all-completions initial collection predicate (length initial))) + ;; Wrap all annotation functions to ensure that they are executed + ;; in the original buffer. + (exit-fun (plist-get completion-extra-properties :exit-function)) + (ann-fun (plist-get completion-extra-properties :annotation-function)) + (aff-fun (plist-get completion-extra-properties :affixation-function)) + (docsig-fun (plist-get completion-extra-properties :company-docsig)) + (completion-extra-properties + `(,@(and ann-fun (list :annotation-function (consult--in-buffer ann-fun))) + ,@(and aff-fun (list :affixation-function (consult--in-buffer aff-fun))) + ;; Provide `:annotation-function' if `:company-docsig' is specified. + ,@(and docsig-fun (not ann-fun) (not aff-fun) + (list :annotation-function + (consult--in-buffer + (lambda (cand) + (concat (propertize " " 'display '(space :align-to center)) + (funcall docsig-fun cand))))))))) + ;; error if `threshold' is t or the improper list `all' is too short + (if (and threshold + (or (not (consp (ignore-errors (nthcdr threshold all)))) + (and completion-cycling completion-all-sorted-completions))) + (completion--in-region start end collection predicate) + (let* ((limit (car (completion-boundaries initial collection predicate ""))) + (this-command #'consult-completion-in-region) + (completion + (cond + ((atom all) nil) + ((and (consp all) (atom (cdr all))) + (concat (substring initial 0 limit) (car all))) + (t + (consult--local-let ((enable-recursive-minibuffers t)) + ;; Evaluate completion table in the original buffer. + ;; This is a reasonable thing to do and required by + ;; some completion tables in particular by lsp-mode. + ;; See gh:minad/vertico#61. + (consult--read (consult--completion-table-in-buffer collection) + :prompt "Completion: " + :state (consult--insertion-preview start end) + :predicate predicate + :initial initial)))))) + (if completion + (progn + ;; bug#55205: completion--replace removes properties! + (completion--replace start end (setq completion (concat completion))) + (when exit-fun + (funcall exit-fun completion + ;; If completion is finished and cannot be further + ;; completed, return `finished'. Otherwise return + ;; `exact'. + (if (eq (try-completion completion collection predicate) t) + 'finished 'exact))) + t) + (message "No completion") + nil))))) + +;;;;; Command: consult-outline + +(defun consult--outline-candidates () + "Return alist of outline headings and positions." + (consult--forbid-minibuffer) + (let* ((line (line-number-at-pos (point-min) consult-line-numbers-widen)) + (heading-regexp (concat "^\\(?:" + ;; default definition from outline.el + (or (bound-and-true-p outline-regexp) "[*\^L]+") + "\\)")) + (heading-alist (bound-and-true-p outline-heading-alist)) + (level-fun (or (bound-and-true-p outline-level) + (lambda () ;; as in the default from outline.el + (or (cdr (assoc (match-string 0) heading-alist)) + (- (match-end 0) (match-beginning 0)))))) + (buffer (current-buffer)) + candidates) + (save-excursion + (goto-char (point-min)) + (while (save-excursion + (if-let (fun (bound-and-true-p outline-search-function)) + (funcall fun) + (re-search-forward heading-regexp nil t))) + (cl-incf line (consult--count-lines (match-beginning 0))) + (push (consult--location-candidate + (consult--buffer-substring (pos-bol) (pos-eol) 'fontify) + (cons buffer (point)) (1- line) (1- line) + 'consult--outline-level (funcall level-fun)) + candidates) + (goto-char (1+ (pos-eol))))) + (unless candidates + (user-error "No headings")) + (nreverse candidates))) + +;;;###autoload +(defun consult-outline (&optional level) + "Jump to an outline heading, obtained by matching against `outline-regexp'. + +This command supports narrowing to a heading level and candidate +preview. The initial narrowing LEVEL can be given as prefix +argument. The symbol at point is added to the future history." + (interactive + (list (and current-prefix-arg (prefix-numeric-value current-prefix-arg)))) + (let* ((candidates (consult--slow-operation + "Collecting headings..." + (consult--outline-candidates))) + (min-level (- (cl-loop for cand in candidates minimize + (get-text-property 0 'consult--outline-level cand)) + ?1)) + (narrow-pred (lambda (cand) + (<= (get-text-property 0 'consult--outline-level cand) + (+ consult--narrow min-level)))) + (narrow-keys (mapcar (lambda (c) (cons c (format "Level %c" c))) + (number-sequence ?1 ?9))) + (narrow-init (and level (max ?1 (min ?9 (+ level ?0)))))) + (consult--read + candidates + :prompt "Go to heading: " + :annotate (consult--line-prefix) + :category 'consult-location + :sort nil + :require-match t + :lookup #'consult--line-match + :narrow `(:predicate ,narrow-pred :keys ,narrow-keys :initial ,narrow-init) + :history '(:input consult--line-history) + :add-history (thing-at-point 'symbol) + :state (consult--location-state candidates)))) + +;;;;; Command: consult-mark + +(defun consult--mark-candidates (markers) + "Return list of candidates strings for MARKERS." + (consult--forbid-minibuffer) + (let ((candidates) + (current-buf (current-buffer))) + (save-excursion + (dolist (marker markers) + (when-let ((pos (marker-position marker)) + (buf (marker-buffer marker))) + (when (and (eq buf current-buf) + (consult--in-range-p pos)) + (goto-char pos) + ;; `line-number-at-pos' is a very slow function, which should be + ;; replaced everywhere. However in this case the slow + ;; line-number-at-pos does not hurt much, since the mark ring is + ;; usually small since it is limited by `mark-ring-max'. + (push (consult--location-candidate + (consult--line-with-mark marker) marker + (line-number-at-pos pos consult-line-numbers-widen) + marker) + candidates))))) + (unless candidates + (user-error "No marks")) + (nreverse (delete-dups candidates)))) + +;;;###autoload +(defun consult-mark (&optional markers) + "Jump to a marker in MARKERS list (defaults to buffer-local `mark-ring'). + +The command supports preview of the currently selected marker position. +The symbol at point is added to the future history." + (interactive) + (consult--read + (consult--mark-candidates + (or markers (cons (mark-marker) mark-ring))) + :prompt "Go to mark: " + :annotate (consult--line-prefix) + :category 'consult-location + :sort nil + :require-match t + :lookup #'consult--lookup-location + :history '(:input consult--line-history) + :add-history (thing-at-point 'symbol) + :state (consult--jump-state))) + +;;;;; Command: consult-global-mark + +(defun consult--global-mark-candidates (markers) + "Return list of candidates strings for MARKERS." + (consult--forbid-minibuffer) + (let ((candidates)) + (save-excursion + (dolist (marker markers) + (when-let ((pos (marker-position marker)) + (buf (marker-buffer marker))) + (unless (minibufferp buf) + (with-current-buffer buf + (when (consult--in-range-p pos) + (goto-char pos) + ;; `line-number-at-pos' is slow, see comment in `consult--mark-candidates'. + (let* ((line (line-number-at-pos pos consult-line-numbers-widen)) + (prefix (consult--format-file-line-match (buffer-name buf) line "")) + (cand (concat prefix (consult--line-with-mark marker) (consult--tofu-encode marker)))) + (put-text-property 0 (length prefix) 'consult-strip t cand) + (put-text-property 0 (length cand) 'consult-location (cons marker line) cand) + (push cand candidates)))))))) + (unless candidates + (user-error "No global marks")) + (nreverse (delete-dups candidates)))) + +;;;###autoload +(defun consult-global-mark (&optional markers) + "Jump to a marker in MARKERS list (defaults to `global-mark-ring'). + +The command supports preview of the currently selected marker position. +The symbol at point is added to the future history." + (interactive) + (consult--read + (consult--global-mark-candidates + (or markers global-mark-ring)) + :prompt "Go to global mark: " + ;; Despite `consult-global-mark' formatting the candidates in grep-like + ;; style, we are not using the `consult-grep' category, since the candidates + ;; have location markers attached. + :category 'consult-location + :sort nil + :require-match t + :lookup #'consult--lookup-location + :history '(:input consult--line-history) + :add-history (thing-at-point 'symbol) + :state (consult--jump-state))) + +;;;;; Command: consult-line + +(defun consult--line-candidates (top curr-line) + "Return list of line candidates. +Start from top if TOP non-nil. +CURR-LINE is the current line number." + (consult--forbid-minibuffer) + (consult--fontify-all) + (let* ((buffer (current-buffer)) + (line (line-number-at-pos (point-min) consult-line-numbers-widen)) + default-cand candidates) + (consult--each-line beg end + (unless (looking-at-p "^\\s-*$") + (push (consult--location-candidate + (consult--buffer-substring beg end) + (cons buffer beg) line line) + candidates) + (when (and (not default-cand) (>= line curr-line)) + (setq default-cand candidates))) + (cl-incf line)) + (unless candidates + (user-error "No lines")) + (nreverse + (if (or top (not default-cand)) + candidates + (let ((before (cdr default-cand))) + (setcdr default-cand nil) + (nconc before candidates)))))) + +(defun consult--line-point-placement (selected candidates highlighted &rest ignored-faces) + "Find point position on matching line. +SELECTED is the currently selected candidate. +CANDIDATES is the list of candidates. +HIGHLIGHTED is the highlighted string to determine the match position. +IGNORED-FACES are ignored when determining the match position." + (when-let (pos (consult--lookup-location selected candidates)) + (if highlighted + (let* ((matches (apply #'consult--point-placement highlighted 0 ignored-faces)) + (dest (+ pos (car matches)))) + ;; Only create a new marker when jumping across buffers (for example + ;; `consult-line-multi'). Avoid creating unnecessary markers, when + ;; scrolling through candidates, since creating markers is not free. + (when (and (markerp pos) (not (eq (marker-buffer pos) (current-buffer)))) + (setq dest (move-marker (make-marker) dest (marker-buffer pos)))) + (cons dest (cdr matches))) + pos))) + +(defun consult--line-match (selected candidates input &rest _) + "Lookup position of match. +SELECTED is the currently selected candidate. +CANDIDATES is the list of candidates. +INPUT is the input string entered by the user." + (consult--line-point-placement selected candidates + (and (not (string-blank-p input)) + (car (consult--completion-filter + input + (list (substring-no-properties selected)) + 'consult-location 'highlight))) + 'completions-first-difference)) + +;;;###autoload +(defun consult-line (&optional initial start) + "Search for a matching line. + +Depending on the setting `consult-point-placement' the command +jumps to the beginning or the end of the first match on the line +or the line beginning. The default candidate is the non-empty +line next to point. This command obeys narrowing. Optional +INITIAL input can be provided. The search starting point is +changed if the START prefix argument is set. The symbol at point +and the last `isearch-string' is added to the future history." + (interactive (list nil (not (not current-prefix-arg)))) + (let* ((curr-line (line-number-at-pos (point) consult-line-numbers-widen)) + (top (not (eq start consult-line-start-from-top))) + (candidates (consult--slow-operation "Collecting lines..." + (consult--line-candidates top curr-line)))) + (consult--read + candidates + :prompt (if top "Go to line from top: " "Go to line: ") + :annotate (consult--line-prefix curr-line) + :category 'consult-location + :sort nil + :require-match t + ;; Always add last `isearch-string' to future history + :add-history (list (thing-at-point 'symbol) isearch-string) + :history '(:input consult--line-history) + :lookup #'consult--line-match + :default (car candidates) + ;; Add `isearch-string' as initial input if starting from Isearch + :initial (or initial + (and isearch-mode + (prog1 isearch-string (isearch-done)))) + :state (consult--location-state candidates)))) + +;;;;; Command: consult-line-multi + +(defun consult--line-multi-match (selected candidates &rest _) + "Lookup position of match. +SELECTED is the currently selected candidate. +CANDIDATES is the list of candidates." + (consult--line-point-placement selected candidates + (car (member selected candidates)))) + +(defun consult--line-multi-group (cand transform) + "Group function used by `consult-line-multi'. +If TRANSFORM non-nil, return transformed CAND, otherwise return title." + (if transform cand + (let* ((marker (car (get-text-property 0 'consult-location cand))) + (buf (if (consp marker) + (car marker) ;; Handle cheap marker + (marker-buffer marker)))) + (if buf (buffer-name buf) "Dead buffer")))) + +(defun consult--line-multi-candidates (buffers input) + "Collect matching candidates from multiple buffers. +INPUT is the user input which should be matched. +BUFFERS is the list of buffers." + (pcase-let ((`(,regexps . ,hl) + (funcall consult--regexp-compiler + input 'emacs completion-ignore-case)) + (candidates nil) + (cand-idx 0)) + (save-match-data + (dolist (buf buffers (nreverse candidates)) + (with-current-buffer buf + (save-excursion + (let ((line (line-number-at-pos (point-min) consult-line-numbers-widen))) + (goto-char (point-min)) + (while (and (not (eobp)) + (save-excursion (re-search-forward (car regexps) nil t))) + (cl-incf line (consult--count-lines (match-beginning 0))) + (let ((bol (pos-bol)) + (eol (pos-eol))) + (goto-char bol) + (when (and (not (looking-at-p "^\\s-*$")) + (seq-every-p (lambda (r) + (goto-char bol) + (re-search-forward r eol t)) + (cdr regexps))) + (push (consult--location-candidate + (funcall hl (buffer-substring-no-properties bol eol)) + (cons buf bol) (1- line) cand-idx) + candidates) + (cl-incf cand-idx)) + (goto-char (1+ eol))))))))))) + +;;;###autoload +(defun consult-line-multi (query &optional initial) + "Search for a matching line in multiple buffers. + +By default search across all project buffers. If the prefix +argument QUERY is non-nil, all buffers are searched. Optional +INITIAL input can be provided. The symbol at point and the last +`isearch-string' is added to the future history. In order to +search a subset of buffers, QUERY can be set to a plist according +to `consult--buffer-query'." + (interactive "P") + (unless (keywordp (car-safe query)) + (setq query (list :sort 'alpha-current :directory (and (not query) 'project)))) + (pcase-let* ((`(,prompt . ,buffers) (consult--buffer-query-prompt "Go to line" query)) + (collection (consult--dynamic-collection + (apply-partially #'consult--line-multi-candidates + buffers)))) + (consult--read + collection + :prompt prompt + :annotate (consult--line-prefix) + :category 'consult-location + :sort nil + :require-match t + ;; Always add last Isearch string to future history + :add-history (mapcar #'consult--async-split-initial + (delq nil (list (thing-at-point 'symbol) + isearch-string))) + :history '(:input consult--line-multi-history) + :lookup #'consult--line-multi-match + ;; Add `isearch-string' as initial input if starting from Isearch + :initial (consult--async-split-initial + (or initial + (and isearch-mode + (prog1 isearch-string (isearch-done))))) + :state (consult--location-state (lambda () (funcall collection nil))) + :group #'consult--line-multi-group))) + +;;;;; Command: consult-keep-lines + +(defun consult--keep-lines-state (filter) + "State function for `consult-keep-lines' with FILTER function." + (let ((font-lock-orig font-lock-mode) + (whitespace-orig (bound-and-true-p whitespace-mode)) + (hl-line-orig (bound-and-true-p hl-line-mode)) + (point-orig (point)) + lines content-orig replace last-input) + (if (use-region-p) + (save-restriction + ;; Use the same behavior as `keep-lines'. + (let ((rbeg (region-beginning)) + (rend (save-excursion + (goto-char (region-end)) + (unless (or (bolp) (eobp)) + (forward-line 0)) + (point)))) + (consult--fontify-region rbeg rend) + (narrow-to-region rbeg rend) + (consult--each-line beg end + (push (consult--buffer-substring beg end) lines)) + (setq content-orig (buffer-string) + replace (lambda (content &optional pos) + (delete-region rbeg rend) + (insert-before-markers content) + (goto-char (or pos rbeg)) + (setq rend (+ rbeg (length content))) + (add-face-text-property rbeg rend 'region t))))) + (consult--fontify-all) + (setq content-orig (buffer-string) + replace (lambda (content &optional pos) + (delete-region (point-min) (point-max)) + (insert content) + (goto-char (or pos (point-min))))) + (consult--each-line beg end + (push (consult--buffer-substring beg end) lines))) + (setq lines (nreverse lines)) + (lambda (action input) + ;; Restoring content and point position + (when (and (eq action 'return) last-input) + ;; No undo recording, modification hooks, buffer modified-status + (with-silent-modifications (funcall replace content-orig point-orig))) + ;; Committing or new input provided -> Update + (when (and input ;; Input has been provided + (or + ;; Committing, but not with empty input + (and (eq action 'return) (not (string-match-p "\\`!? ?\\'" input))) + ;; Input has changed + (not (equal input last-input)))) + (let ((filtered-content + (if (string-match-p "\\`!? ?\\'" input) + ;; Special case the empty input for performance. + ;; Otherwise it could happen that the minibuffer is empty, + ;; but the buffer has not been updated. + content-orig + (if (eq action 'return) + (apply #'concat (mapcan (lambda (x) (list x "\n")) + (funcall filter input lines))) + (while-no-input + ;; Heavy computation is interruptible if *not* committing! + ;; Allocate new string candidates since the matching function mutates! + (apply #'concat (mapcan (lambda (x) (list x "\n")) + (funcall filter input (mapcar #'copy-sequence lines))))))))) + (when (stringp filtered-content) + (when font-lock-mode (font-lock-mode -1)) + (when (bound-and-true-p whitespace-mode) (whitespace-mode -1)) + (when (bound-and-true-p hl-line-mode) (hl-line-mode -1)) + (if (eq action 'return) + (atomic-change-group + ;; Disable modification hooks for performance + (let ((inhibit-modification-hooks t)) + (funcall replace filtered-content))) + ;; No undo recording, modification hooks, buffer modified-status + (with-silent-modifications + (funcall replace filtered-content) + (setq last-input input)))))) + ;; Restore modes + (when (eq action 'return) + (when hl-line-orig (hl-line-mode 1)) + (when whitespace-orig (whitespace-mode 1)) + (when font-lock-orig (font-lock-mode 1)))))) + +;;;###autoload +(defun consult-keep-lines (filter &optional initial) + "Select a subset of the lines in the current buffer with live preview. + +The selected lines are kept and the other lines are deleted. When called +interactively, the lines selected are those that match the minibuffer input. In +order to match the inverse of the input, prefix the input with `! '. When +called from Elisp, the filtering is performed by a FILTER function. This +command obeys narrowing. + +FILTER is the filter function. +INITIAL is the initial input." + (interactive + (list (lambda (pattern cands) + ;; Use consult-location completion category when filtering lines + (consult--completion-filter-dispatch + pattern cands 'consult-location 'highlight)))) + (consult--forbid-minibuffer) + (let ((ro buffer-read-only)) + (unwind-protect + (consult--minibuffer-with-setup-hook + (lambda () + (when ro + (minibuffer-message + (substitute-command-keys + " [Unlocked read-only buffer. \\[minibuffer-keyboard-quit] to quit.]")))) + (setq buffer-read-only nil) + (consult--with-increased-gc + (consult--prompt + :prompt "Keep lines: " + :initial initial + :history 'consult--line-history + :state (consult--keep-lines-state filter)))) + (setq buffer-read-only ro)))) + +;;;;; Command: consult-focus-lines + +(defun consult--focus-lines-state (filter) + "State function for `consult-focus-lines' with FILTER function." + (let (lines overlays last-input pt-orig pt-min pt-max) + (save-excursion + (save-restriction + (if (not (use-region-p)) + (consult--fontify-all) + (consult--fontify-region (region-beginning) (region-end)) + (narrow-to-region + (region-beginning) + ;; Behave the same as `keep-lines'. + ;; Move to the next line. + (save-excursion + (goto-char (region-end)) + (unless (or (bolp) (eobp)) + (forward-line 0)) + (point)))) + (setq pt-orig (point) pt-min (point-min) pt-max (point-max)) + (let ((i 0)) + (consult--each-line beg end + ;; Use "\n" for empty lines, since we need a non-empty string to + ;; attach the text property to. + (let ((line (if (eq beg end) (char-to-string ?\n) + (buffer-substring-no-properties beg end)))) + (put-text-property 0 1 'consult--focus-line (cons (cl-incf i) beg) line) + (push line lines))) + (setq lines (nreverse lines))))) + (lambda (action input) + ;; New input provided -> Update + (when (and input (not (equal input last-input))) + (let (new-overlays) + (pcase (while-no-input + (unless (string-match-p "\\`!? ?\\'" input) ;; Empty input. + (let* ((inhibit-quit (eq action 'return)) ;; Non interruptible, when quitting! + (not (string-prefix-p "! " input)) + (stripped (string-remove-prefix "! " input)) + (matches (funcall filter stripped lines)) + (old-ind 0) + (block-beg pt-min) + (block-end pt-min)) + (while old-ind + (let ((match (pop matches)) (ind nil) (beg pt-max) (end pt-max) prop) + (when match + (setq prop (get-text-property 0 'consult--focus-line match) + ind (car prop) + beg (cdr prop) + ;; Check for empty lines, see above. + end (+ 1 beg (if (equal match "\n") 0 (length match))))) + (unless (eq ind (1+ old-ind)) + (let ((a (if not block-beg block-end)) + (b (if not block-end beg))) + (when (/= a b) + (push (consult--make-overlay a b 'invisible t) new-overlays))) + (setq block-beg beg)) + (setq block-end end old-ind ind))))) + 'commit) + ('commit + (mapc #'delete-overlay overlays) + (setq last-input input overlays new-overlays)) + (_ (mapc #'delete-overlay new-overlays))))) + (when (eq action 'return) + (cond + ((not input) + (mapc #'delete-overlay overlays) + (goto-char pt-orig)) + ((equal input "") + (consult-focus-lines nil 'show) + (goto-char pt-orig)) + (t + ;; Successfully terminated -> Remember invisible overlays + (setq consult--focus-lines-overlays + (nconc consult--focus-lines-overlays overlays)) + ;; move point past invisible + (goto-char (if-let (ov (and (invisible-p pt-orig) + (seq-find (lambda (ov) (overlay-get ov 'invisible)) + (overlays-at pt-orig)))) + (overlay-end ov) + pt-orig)))))))) + +;;;###autoload +(defun consult-focus-lines (filter &optional show initial) + "Hide or show lines using overlays. + +The selected lines are shown and the other lines hidden. When called +interactively, the lines selected are those that match the minibuffer input. In +order to match the inverse of the input, prefix the input with `! '. With +optional prefix argument SHOW reveal the hidden lines. Alternatively the +command can be restarted to reveal the lines. When called from Elisp, the +filtering is performed by a FILTER function. This command obeys narrowing. + +FILTER is the filter function. +INITIAL is the initial input." + (interactive + (list (lambda (pattern cands) + ;; Use consult-location completion category when filtering lines + (consult--completion-filter-dispatch + pattern cands 'consult-location nil)) + current-prefix-arg)) + (if show + (progn + (mapc #'delete-overlay consult--focus-lines-overlays) + (setq consult--focus-lines-overlays nil) + (message "All lines revealed")) + (consult--forbid-minibuffer) + (consult--with-increased-gc + (consult--prompt + :prompt + (if consult--focus-lines-overlays + "Focus on lines (RET to reveal): " + "Focus on lines: ") + :initial initial + :history 'consult--line-history + :state (consult--focus-lines-state filter))))) + +;;;;; Command: consult-goto-line + +(defun consult--goto-line-position (str msg) + "Transform input STR to line number. +Print an error message with MSG function." + (save-match-data + (if (and str (string-match "\\`\\([[:digit:]]+\\):?\\([[:digit:]]*\\)\\'" str)) + (let ((line (string-to-number (match-string 1 str))) + (col (string-to-number (match-string 2 str)))) + (save-excursion + (save-restriction + (when consult-line-numbers-widen + (widen)) + (goto-char (point-min)) + (forward-line (1- line)) + (goto-char (min (+ (point) col) (pos-eol))) + (point)))) + (when (and str (not (equal str ""))) + (funcall msg "Please enter a number.")) + nil))) + +;;;###autoload +(defun consult-goto-line (&optional arg) + "Read line number and jump to the line with preview. + +Enter either a line number to jump to the first column of the +given line or line:column in order to jump to a specific column. +Jump directly if a line number is given as prefix ARG. The +command respects narrowing and the settings +`consult-goto-line-numbers' and `consult-line-numbers-widen'." + (interactive "P") + (if arg + (call-interactively #'goto-line) + (consult--forbid-minibuffer) + (consult--local-let ((display-line-numbers consult-goto-line-numbers) + (display-line-numbers-widen consult-line-numbers-widen)) + (while (if-let (pos (consult--goto-line-position + (consult--prompt + :prompt "Go to line: " + :history 'goto-line-history + :state + (let ((preview (consult--jump-preview))) + (lambda (action str) + (funcall preview action + (consult--goto-line-position str #'ignore))))) + #'minibuffer-message)) + (consult--jump pos) + t))))) + +;;;;; Command: consult-recent-file + +(defun consult--file-preview () + "Create preview function for files." + (let ((open (consult--temporary-files)) + (preview (consult--buffer-preview))) + (lambda (action cand) + (unless cand + (funcall open)) + (funcall preview action + (and cand + (eq action 'preview) + (funcall open cand)))))) + +(defun consult--file-action (file) + "Open FILE via `consult--buffer-action'." + ;; Try to preserve the buffer as is, if it has already been opened, for + ;; example in literal or raw mode. + (setq file (abbreviate-file-name (expand-file-name file))) + (consult--buffer-action (or (get-file-buffer file) (find-file-noselect file)))) + +(consult--define-state file) + +;;;###autoload +(defun consult-recent-file () + "Find recent file using `completing-read'." + (interactive) + (find-file + (consult--read + (or + (mapcar #'consult--fast-abbreviate-file-name (bound-and-true-p recentf-list)) + (user-error "No recent files, `recentf-mode' is %s" + (if recentf-mode "enabled" "disabled"))) + :prompt "Find recent file: " + :sort nil + :require-match t + :category 'file + :state (consult--file-preview) + :history 'file-name-history))) + +;;;;; Command: consult-mode-command + +(defun consult--mode-name (mode) + "Return name part of MODE." + (replace-regexp-in-string + "global-\\(.*\\)-mode" "\\1" + (replace-regexp-in-string + "\\(-global\\)?-mode\\'" "" + (if (eq mode 'c-mode) + "cc" + (symbol-name mode)) + 'fixedcase) + 'fixedcase)) + +(defun consult--mode-command-candidates (modes) + "Extract commands from MODES. + +The list of features is searched for files belonging to the modes. +From these files, the commands are extracted." + (let* ((case-fold-search) + (buffer (current-buffer)) + (command-filter (consult--regexp-filter (seq-filter #'stringp consult-mode-command-filter))) + (feature-filter (seq-filter #'symbolp consult-mode-command-filter)) + (minor-hash (consult--string-hash minor-mode-list)) + (minor-local-modes (seq-filter (lambda (m) + (and (gethash m minor-hash) + (local-variable-if-set-p m))) + modes)) + (minor-global-modes (seq-filter (lambda (m) + (and (gethash m minor-hash) + (not (local-variable-if-set-p m)))) + modes)) + (major-modes (seq-remove (lambda (m) + (gethash m minor-hash)) + modes)) + (major-paths-hash (consult--string-hash (mapcar #'symbol-file major-modes))) + (minor-local-paths-hash (consult--string-hash (mapcar #'symbol-file minor-local-modes))) + (minor-global-paths-hash (consult--string-hash (mapcar #'symbol-file minor-global-modes))) + (major-name-regexp (regexp-opt (mapcar #'consult--mode-name major-modes))) + (minor-local-name-regexp (regexp-opt (mapcar #'consult--mode-name minor-local-modes))) + (minor-global-name-regexp (regexp-opt (mapcar #'consult--mode-name minor-global-modes))) + (commands)) + (dolist (feature load-history commands) + (when-let (name (alist-get 'provide feature)) + (let* ((path (car feature)) + (file (file-name-nondirectory path)) + (key (cond + ((memq name feature-filter) nil) + ((or (gethash path major-paths-hash) + (string-match-p major-name-regexp file)) + ?m) + ((or (gethash path minor-local-paths-hash) + (string-match-p minor-local-name-regexp file)) + ?l) + ((or (gethash path minor-global-paths-hash) + (string-match-p minor-global-name-regexp file)) + ?g)))) + (when key + (dolist (cmd (cdr feature)) + (let ((sym (cdr-safe cmd))) + (when (and (consp cmd) + (eq (car cmd) 'defun) + (commandp sym) + (not (get sym 'byte-obsolete-info)) + ;; Emacs 28 has a `read-extended-command-predicate' + (if (bound-and-true-p read-extended-command-predicate) + (funcall read-extended-command-predicate sym buffer) + t)) + (let ((name (symbol-name sym))) + (unless (string-match-p command-filter name) + (push (propertize name + 'consult--candidate sym + 'consult--type key) + commands)))))))))))) + +;;;###autoload +(defun consult-mode-command (&rest modes) + "Run a command from any of the given MODES. + +If no MODES are specified, use currently active major and minor modes." + (interactive) + (unless modes + (setq modes (cons major-mode + (seq-filter (lambda (m) + (and (boundp m) (symbol-value m))) + minor-mode-list)))) + (let ((narrow `((?m . ,(format "Major: %s" major-mode)) + (?l . "Local Minor") + (?g . "Global Minor")))) + (command-execute + (consult--read + (consult--mode-command-candidates modes) + :prompt "Mode command: " + :predicate + (lambda (cand) + (let ((key (get-text-property 0 'consult--type cand))) + (if consult--narrow + (= key consult--narrow) + (/= key ?g)))) + :lookup #'consult--lookup-candidate + :group (consult--type-group narrow) + :narrow narrow + :require-match t + :history 'extended-command-history + :category 'command)))) + +;;;;; Command: consult-yank + +(defun consult--read-from-kill-ring () + "Open kill ring menu and return selected string." + ;; `current-kill' updates `kill-ring' with interprogram paste, see + ;; gh:minad/consult#443. + (current-kill 0) + ;; Do not specify a :lookup function in order to preserve completion-styles + ;; highlighting of the current candidate. We have to perform a final lookup to + ;; obtain the original candidate which may be propertized with yank-specific + ;; properties, like 'yank-handler. + (consult--lookup-member + (consult--read + (consult--remove-dups + (or (if consult-yank-rotate + (append kill-ring-yank-pointer + (butlast kill-ring (length kill-ring-yank-pointer))) + kill-ring) + (user-error "Kill ring is empty"))) + :prompt "Yank from kill-ring: " + :history t ;; disable history + :sort nil + :category 'kill-ring + :require-match t + :state + (consult--insertion-preview + (point) + ;; If previous command is yank, hide previously yanked string + (or (and (eq last-command 'yank) (mark t)) (point)))) + kill-ring)) + +;; Adapted from the Emacs `yank-from-kill-ring' function. +;;;###autoload +(defun consult-yank-from-kill-ring (string &optional arg) + "Select STRING from the kill ring and insert it. +With prefix ARG, put point at beginning, and mark at end, like `yank' does. + +This command behaves like `yank-from-kill-ring' in Emacs 28, which also offers +a `completing-read' interface to the `kill-ring'. Additionally the Consult +version supports preview of the selected string." + (interactive (list (consult--read-from-kill-ring) current-prefix-arg)) + (when string + (setq yank-window-start (window-start)) + (push-mark) + (insert-for-yank string) + (setq this-command 'yank) + (when consult-yank-rotate + (if-let (pos (seq-position kill-ring string)) + (setq kill-ring-yank-pointer (nthcdr pos kill-ring)) + (kill-new string))) + (when (consp arg) + ;; Swap point and mark like in `yank'. + (goto-char (prog1 (mark t) + (set-marker (mark-marker) (point) (current-buffer))))))) + +(put 'consult-yank-replace 'delete-selection 'yank) +(put 'consult-yank-pop 'delete-selection 'yank) +(put 'consult-yank-from-kill-ring 'delete-selection 'yank) + +;;;###autoload +(defun consult-yank-pop (&optional arg) + "If there is a recent yank act like `yank-pop'. + +Otherwise select string from the kill ring and insert it. +See `yank-pop' for the meaning of ARG. + +This command behaves like `yank-pop' in Emacs 28, which also offers a +`completing-read' interface to the `kill-ring'. Additionally the Consult +version supports preview of the selected string." + (interactive "*p") + (if (eq last-command 'yank) + (yank-pop (or arg 1)) + (call-interactively #'consult-yank-from-kill-ring))) + +;; Adapted from the Emacs yank-pop function. +;;;###autoload +(defun consult-yank-replace (string) + "Select STRING from the kill ring. + +If there was no recent yank, insert the string. +Otherwise replace the just-yanked string with the selected string. + +There exists no equivalent of this command in Emacs 28." + (interactive (list (consult--read-from-kill-ring))) + (when string + (if (not (eq last-command 'yank)) + (consult-yank-from-kill-ring string) + (let ((inhibit-read-only t) + (pt (point)) + (mk (mark t))) + (setq this-command 'yank) + (funcall (or yank-undo-function 'delete-region) (min pt mk) (max pt mk)) + (setq yank-undo-function nil) + (set-marker (mark-marker) pt (current-buffer)) + (insert-for-yank string) + (set-window-start (selected-window) yank-window-start t) + (if (< pt mk) + (goto-char (prog1 (mark t) + (set-marker (mark-marker) (point) (current-buffer))))))))) + +;;;;; Command: consult-bookmark + +(defun consult--bookmark-preview () + "Create preview function for bookmarks." + (let ((preview (consult--jump-preview)) + (open (consult--temporary-files))) + (lambda (action cand) + (unless cand + (funcall open)) + (funcall + preview action + ;; Only preview bookmarks with the default handler. + (when-let ((bm (and cand (eq action 'preview) (assoc cand bookmark-alist))) + (handler (or (bookmark-get-handler bm) #'bookmark-default-handler)) + ((eq handler #'bookmark-default-handler)) + (file (bookmark-get-filename bm)) + (pos (bookmark-get-position bm)) + (buf (funcall open file))) + (set-marker (make-marker) pos buf)))))) + +(defun consult--bookmark-action (bm) + "Open BM via `consult--buffer-action'." + (bookmark-jump bm consult--buffer-display)) + +(consult--define-state bookmark) + +(defun consult--bookmark-candidates () + "Return bookmark candidates." + (bookmark-maybe-load-default-file) + (let ((narrow (cl-loop for (y _ . xs) in consult-bookmark-narrow nconc + (cl-loop for x in xs collect (cons x y))))) + (cl-loop for bm in bookmark-alist collect + (propertize (car bm) + 'consult--type + (alist-get + (or (bookmark-get-handler bm) #'bookmark-default-handler) + narrow))))) + +;;;###autoload +(defun consult-bookmark (name) + "If bookmark NAME exists, open it, otherwise create a new bookmark with NAME. + +The command supports preview of file bookmarks and narrowing. See the +variable `consult-bookmark-narrow' for the narrowing configuration." + (interactive + (list + (let ((narrow (cl-loop for (x y . _) in consult-bookmark-narrow collect (cons x y)))) + (consult--read + (consult--bookmark-candidates) + :prompt "Bookmark: " + :state (consult--bookmark-preview) + :category 'bookmark + :history 'bookmark-history + ;; Add default names to future history. + ;; Ignore errors such that `consult-bookmark' can be used in + ;; buffers which are not backed by a file. + :add-history (ignore-errors (bookmark-prop-get (bookmark-make-record) 'defaults)) + :group (consult--type-group narrow) + :narrow (consult--type-narrow narrow))))) + (bookmark-maybe-load-default-file) + (if (assoc name bookmark-alist) + (bookmark-jump name) + (bookmark-set name))) + +;;;;; Command: consult-complex-command + +;;;###autoload +(defun consult-complex-command () + "Select and evaluate command from the command history. + +This command can act as a drop-in replacement for `repeat-complex-command'." + (interactive) + (let* ((history (or (delete-dups (mapcar #'prin1-to-string command-history)) + (user-error "There are no previous complex commands"))) + (cmd (read (consult--read + history + :prompt "Command: " + :default (car history) + :sort nil + :history t ;; disable history + :category 'expression)))) + ;; Taken from `repeat-complex-command' + (add-to-history 'command-history cmd) + (apply #'funcall-interactively + (car cmd) + (mapcar (lambda (e) (eval e t)) (cdr cmd))))) + +;;;;; Command: consult-history + +(declare-function ring-elements "ring") + +(defun consult--current-history () + "Return the history and index variable relevant to the current buffer. +If the minibuffer is active, the minibuffer history is returned, +otherwise the history corresponding to the mode. There is a +special case for `repeat-complex-command', for which the command +history is used." + (cond + ;; In the minibuffer we use the current minibuffer history, + ;; which can be configured by setting `minibuffer-history-variable'. + ((minibufferp) + (when (eq minibuffer-history-variable t) + (user-error "Minibuffer history is disabled for `%s'" this-command)) + (list (mapcar #'consult--tofu-hide + (if (eq minibuffer-history-variable 'command-history) + ;; If pressing "C-x M-:", i.e., `repeat-complex-command', + ;; we are instead querying the `command-history' and get a + ;; full s-expression. Alternatively you might want to use + ;; `consult-complex-command', which can also be bound to + ;; "C-x M-:"! + (mapcar #'prin1-to-string command-history) + (symbol-value minibuffer-history-variable))))) + ;; Otherwise we use a mode-specific history, see `consult-mode-histories'. + (t (let ((found (seq-find (lambda (h) + (and (derived-mode-p (car h)) + (boundp (if (consp (cdr h)) (cadr h) (cdr h))))) + consult-mode-histories))) + (unless found + (user-error "No history configured for `%s', see `consult-mode-histories'" + major-mode)) + (cons (symbol-value (cadr found)) (cddr found)))))) + +;;;###autoload +(defun consult-history (&optional history index bol) + "Insert string from HISTORY of current buffer. +In order to select from a specific HISTORY, pass the history +variable as argument. INDEX is the name of the index variable to +update, if any. BOL is the function which jumps to the beginning +of the prompt. See also `cape-history' from the Cape package." + (interactive) + (pcase-let* ((`(,history ,index ,bol) (if history + (list history index bol) + (consult--current-history))) + (history (if (ring-p history) (ring-elements history) history)) + (`(,beg . ,end) + (if (minibufferp) + (cons (minibuffer-prompt-end) (point-max)) + (if bol + (save-excursion + (funcall bol) + (cons (point) (pos-eol))) + (cons (point) (point))))) + (str (consult--local-let ((enable-recursive-minibuffers t)) + (consult--read + (or (consult--remove-dups history) + (user-error "History is empty")) + :prompt "History: " + :history t ;; disable history + :category ;; Report category depending on history variable + (and (minibufferp) + (pcase minibuffer-history-variable + ('extended-command-history 'command) + ('buffer-name-history 'buffer) + ('face-name-history 'face) + ('read-envvar-name-history 'environment-variable) + ('bookmark-history 'bookmark) + ('file-name-history 'file))) + :sort nil + :initial (buffer-substring-no-properties beg end) + :state (consult--insertion-preview beg end))))) + (delete-region beg end) + (when index + (set index (seq-position history str))) + (insert (substring-no-properties str)))) + +;;;;; Command: consult-isearch-history + +(defun consult-isearch-forward (&optional reverse) + "Continue Isearch forward optionally in REVERSE." + (interactive) + (consult--require-minibuffer) + (setq isearch-new-forward (not reverse) isearch-new-nonincremental nil) + (funcall (or (command-remapping #'exit-minibuffer) #'exit-minibuffer))) + +(defun consult-isearch-backward (&optional reverse) + "Continue Isearch backward optionally in REVERSE." + (interactive) + (consult-isearch-forward (not reverse))) + +;; Emacs 28: hide in M-X +(put #'consult-isearch-backward 'completion-predicate #'ignore) +(put #'consult-isearch-forward 'completion-predicate #'ignore) + +(defvar-keymap consult-isearch-history-map + :doc "Additional keymap used by `consult-isearch-history'." + "<remap> <isearch-forward>" #'consult-isearch-forward + "<remap> <isearch-backward>" #'consult-isearch-backward) + +(defun consult--isearch-history-candidates () + "Return Isearch history candidates." + ;; Do not throw an error on empty history, in order to allow starting a + ;; search. We do not :require-match here. + (let ((history (if (eq t search-default-mode) + (append regexp-search-ring search-ring) + (append search-ring regexp-search-ring)))) + (delete-dups + (mapcar + (lambda (cand) + ;; The search type can be distinguished via text properties. + (let* ((props (plist-member (text-properties-at 0 cand) + 'isearch-regexp-function)) + (type (pcase (cadr props) + ((and 'nil (guard (not props))) ?r) + ('nil ?l) + ('word-search-regexp ?w) + ('isearch-symbol-regexp ?s) + ('char-fold-to-regexp ?c) + (_ ?u)))) + ;; Disambiguate history items. The same string could + ;; occur with different search types. + (consult--tofu-append cand type))) + history)))) + +(defconst consult--isearch-history-narrow + '((?c . "Char") + (?u . "Custom") + (?l . "Literal") + (?r . "Regexp") + (?s . "Symbol") + (?w . "Word"))) + +;;;###autoload +(defun consult-isearch-history () + "Read a search string with completion from the Isearch history. + +This replaces the current search string if Isearch is active, and +starts a new Isearch session otherwise." + (interactive) + (consult--forbid-minibuffer) + (let* ((isearch-message-function #'ignore) + (cursor-in-echo-area t) ;; Avoid cursor flickering + (candidates (consult--isearch-history-candidates))) + (unless isearch-mode (isearch-mode t)) + (with-isearch-suspended + (setq isearch-new-string + (consult--read + candidates + :prompt "I-search: " + :category 'consult-isearch-history + :history t ;; disable history + :sort nil + :initial isearch-string + :keymap consult-isearch-history-map + :annotate + (lambda (cand) + (consult--annotate-align + cand + (alist-get (consult--tofu-get cand) consult--isearch-history-narrow))) + :group + (lambda (cand transform) + (if transform + cand + (alist-get (consult--tofu-get cand) consult--isearch-history-narrow))) + :lookup + (lambda (selected candidates &rest _) + (if-let (found (member selected candidates)) + (substring (car found) 0 -1) + selected)) + :state + (lambda (action cand) + (when (and (eq action 'preview) cand) + (setq isearch-string cand) + (isearch-update-from-string-properties cand) + (isearch-update))) + :narrow + (list :predicate + (lambda (cand) (= (consult--tofu-get cand) consult--narrow)) + :keys consult--isearch-history-narrow)) + isearch-new-message + (mapconcat 'isearch-text-char-description isearch-new-string ""))) + ;; Setting `isearch-regexp' etc only works outside of `with-isearch-suspended'. + (unless (plist-member (text-properties-at 0 isearch-string) 'isearch-regexp-function) + (setq isearch-regexp t + isearch-regexp-function nil)))) + +;;;;; Command: consult-minor-mode-menu + +(defun consult--minor-mode-candidates () + "Return list of minor-mode candidate strings." + (mapcar + (pcase-lambda (`(,name . ,sym)) + (propertize + name + 'consult--candidate sym + 'consult--minor-mode-narrow + (logior + (ash (if (local-variable-if-set-p sym) ?l ?g) 8) + (if (and (boundp sym) (symbol-value sym)) ?i ?o)) + 'consult--minor-mode-group + (concat + (if (local-variable-if-set-p sym) "Local " "Global ") + (if (and (boundp sym) (symbol-value sym)) "On" "Off")))) + (nconc + ;; according to describe-minor-mode-completion-table-for-symbol + ;; the minor-mode-list contains *all* minor modes + (mapcar (lambda (sym) (cons (symbol-name sym) sym)) minor-mode-list) + ;; take the lighters from minor-mode-alist + (delq nil + (mapcar (pcase-lambda (`(,sym ,lighter)) + (when (and lighter (not (equal "" lighter))) + (let (message-log-max) + (setq lighter (string-trim (format-mode-line lighter))) + (unless (string-blank-p lighter) + (cons lighter sym))))) + minor-mode-alist))))) + +(defconst consult--minor-mode-menu-narrow + '((?l . "Local") + (?g . "Global") + (?i . "On") + (?o . "Off"))) + +;;;###autoload +(defun consult-minor-mode-menu () + "Enable or disable minor mode. + +This is an alternative to `minor-mode-menu-from-indicator'." + (interactive) + (call-interactively + (consult--read + (consult--minor-mode-candidates) + :prompt "Minor mode: " + :require-match t + :category 'minor-mode + :group + (lambda (cand transform) + (if transform cand (get-text-property 0 'consult--minor-mode-group cand))) + :narrow + (list :predicate + (lambda (cand) + (let ((narrow (get-text-property 0 'consult--minor-mode-narrow cand))) + (or (= (logand narrow 255) consult--narrow) + (= (ash narrow -8) consult--narrow)))) + :keys + consult--minor-mode-menu-narrow) + :lookup #'consult--lookup-candidate + :history 'consult--minor-mode-menu-history))) + +;;;;; Command: consult-theme + +;;;###autoload +(defun consult-theme (theme) + "Disable current themes and enable THEME from `consult-themes'. + +The command supports previewing the currently selected theme." + (interactive + (list + (let* ((regexp (consult--regexp-filter + (mapcar (lambda (x) (if (stringp x) x (format "\\`%s\\'" x))) + consult-themes))) + (avail-themes (seq-filter + (lambda (x) (string-match-p regexp (symbol-name x))) + (cons 'default (custom-available-themes)))) + (saved-theme (car custom-enabled-themes))) + (consult--read + (mapcar #'symbol-name avail-themes) + :prompt "Theme: " + :require-match t + :category 'theme + :history 'consult--theme-history + :lookup (lambda (selected &rest _) + (setq selected (and selected (intern-soft selected))) + (or (and selected (car (memq selected avail-themes))) + saved-theme)) + :state (lambda (action theme) + (pcase action + ('return (consult-theme (or theme saved-theme))) + ((and 'preview (guard theme)) (consult-theme theme)))) + :default (symbol-name (or saved-theme 'default)))))) + (when (eq theme 'default) (setq theme nil)) + (unless (eq theme (car custom-enabled-themes)) + (mapc #'disable-theme custom-enabled-themes) + (when theme + (if (custom-theme-p theme) + (enable-theme theme) + (load-theme theme :no-confirm))))) + +;;;;; Command: consult-buffer + +(defun consult--buffer-sort-alpha (buffers) + "Sort BUFFERS alphabetically, put starred buffers at the end." + (sort buffers + (lambda (x y) + (setq x (buffer-name x) y (buffer-name y)) + (let ((a (and (length> x 0) (eq (aref x 0) ?*))) + (b (and (length> y 0) (eq (aref y 0) ?*)))) + (if (eq a b) + (string< x y) + (not a)))))) + +(defun consult--buffer-sort-alpha-current (buffers) + "Sort BUFFERS alphabetically, put current at the beginning." + (let ((buffers (consult--buffer-sort-alpha buffers)) + (current (current-buffer))) + (if (memq current buffers) + (cons current (delq current buffers)) + buffers))) + +(defun consult--buffer-sort-visibility (buffers) + "Sort BUFFERS by visibility." + (let ((hidden) + (current (car (memq (current-buffer) buffers)))) + (consult--keep! buffers + (unless (eq it current) + (if (get-buffer-window it 'visible) + it + (push it hidden) + nil))) + (nconc (nreverse hidden) buffers (and current (list current))))) + +(defun consult--normalize-directory (dir) + "Normalize directory DIR. +DIR can be project, nil or a path." + (cond + ((eq dir 'project) (consult--project-root)) + (dir (expand-file-name dir)))) + +(defun consult--buffer-query-prompt (prompt query) + "Return a list of buffers and create an appropriate prompt string. +Return a pair of a prompt string and a list of buffers. PROMPT +is the prefix of the prompt string. QUERY specifies the buffers +to search and is passed to `consult--buffer-query'." + (let* ((dir (plist-get query :directory)) + (ndir (consult--normalize-directory dir)) + (buffers (apply #'consult--buffer-query :directory ndir query)) + (count (length buffers))) + (cons (format "%s (%d buffer%s%s): " prompt count + (if (= count 1) "" "s") + (cond + ((and ndir (eq dir 'project)) + (format ", Project %s" (consult--project-name ndir))) + (ndir (concat ", " (consult--left-truncate-file ndir))) + (t ""))) + buffers))) + +(cl-defun consult--buffer-query (&key sort directory mode as predicate (filter t) + include (exclude consult-buffer-filter) + (buffer-list t)) + "Query for a list of matching buffers. +The function supports filtering by various criteria which are +used throughout Consult. In particular it is the backbone of +most `consult-buffer-sources'. +DIRECTORY can either be the symbol project or a file name. +SORT can be visibility, alpha or nil. +FILTER can be either t, nil or invert. +EXCLUDE is a list of regexps. +INCLUDE is a list of regexps. +MODE can be a mode or a list of modes to restrict the returned buffers. +PREDICATE is a predicate function. +BUFFER-LIST is the unfiltered list of buffers. +AS is a conversion function." + (let ((root (consult--normalize-directory directory))) + (setq buffer-list (if (eq buffer-list t) (buffer-list) (copy-sequence buffer-list))) + (when sort + (setq buffer-list (funcall (intern (format "consult--buffer-sort-%s" sort)) buffer-list))) + (when (or filter mode as root) + (let ((exclude-re (consult--regexp-filter exclude)) + (include-re (consult--regexp-filter include)) + (case-fold-search)) + (consult--keep! buffer-list + (and + (or (not mode) + (let ((mm (buffer-local-value 'major-mode it))) + (if (consp mode) + (seq-some (lambda (m) (provided-mode-derived-p mm m)) mode) + (provided-mode-derived-p mm mode)))) + (pcase-exhaustive filter + ('nil t) + ((or 't 'invert) + (eq (eq filter t) + (and + (or (not exclude) + (not (string-match-p exclude-re (buffer-name it)))) + (or (not include) + (not (not (string-match-p include-re (buffer-name it))))))))) + (or (not root) + (when-let (dir (buffer-local-value 'default-directory it)) + (string-prefix-p root + (if (and (/= 0 (length dir)) (eq (aref dir 0) ?/)) + dir + (expand-file-name dir))))) + (or (not predicate) (funcall predicate it)) + (if as (funcall as it) it))))) + buffer-list)) + +(defun consult--buffer-file-hash () + "Return hash table of all buffer file names." + (consult--string-hash (consult--buffer-query :as #'buffer-file-name))) + +(defun consult--buffer-pair (buffer) + "Return a pair of name of BUFFER and BUFFER." + (cons (buffer-name buffer) buffer)) + +(defun consult--buffer-preview () + "Buffer preview function." + (let ((orig-buf (window-buffer (consult--original-window))) + (orig-prev (copy-sequence (window-prev-buffers))) + (orig-next (copy-sequence (window-next-buffers))) + other-win) + (lambda (action cand) + (pcase action + ('exit + (set-window-prev-buffers other-win orig-prev) + (set-window-next-buffers other-win orig-next)) + ('preview + (when (and (eq consult--buffer-display #'switch-to-buffer-other-window) + (not other-win)) + (switch-to-buffer-other-window orig-buf 'norecord) + (setq other-win (selected-window))) + (let ((win (or other-win (selected-window))) + (buf (or (and cand (get-buffer cand)) orig-buf))) + (when (and (window-live-p win) (buffer-live-p buf)) + (with-selected-window win + (unless (or orig-prev orig-next) + (setq orig-prev (copy-sequence (window-prev-buffers)) + orig-next (copy-sequence (window-next-buffers)))) + (switch-to-buffer buf 'norecord))))))))) + +(defun consult--buffer-action (buffer &optional norecord) + "Switch to BUFFER via `consult--buffer-display' function. +If NORECORD is non-nil, do not record the buffer switch in the buffer list." + (funcall consult--buffer-display buffer norecord)) + +(consult--define-state buffer) + +(defvar consult--source-bookmark + `(:name "Bookmark" + :narrow ?m + :category bookmark + :face consult-bookmark + :history bookmark-history + :items ,#'bookmark-all-names + :state ,#'consult--bookmark-state) + "Bookmark candidate source for `consult-buffer'.") + +(defvar consult--source-project-buffer + `(:name "Project Buffer" + :narrow ?b + :category buffer + :face consult-buffer + :history buffer-name-history + :state ,#'consult--buffer-state + :enabled ,(lambda () consult-project-function) + :items + ,(lambda () + (when-let (root (consult--project-root)) + (consult--buffer-query :sort 'visibility + :directory root + :as #'consult--buffer-pair)))) + "Project buffer candidate source for `consult-buffer'.") + +(defvar consult--source-project-recent-file + `(:name "Project File" + :narrow ?f + :category file + :face consult-file + :history file-name-history + :state ,#'consult--file-state + :new + ,(lambda (file) + (consult--file-action + (expand-file-name file (consult--project-root)))) + :enabled + ,(lambda () + (and consult-project-function + recentf-mode)) + :items + ,(lambda () + (when-let (root (consult--project-root)) + (let ((len (length root)) + (ht (consult--buffer-file-hash)) + items) + (dolist (file (bound-and-true-p recentf-list) (nreverse items)) + ;; Emacs 29 abbreviates file paths by default, see + ;; `recentf-filename-handlers'. I recommend to set + ;; `recentf-filename-handlers' to nil to avoid any slow down. + (unless (eq (aref file 0) ?/) + (let (file-name-handler-alist) ;; No Tramp slowdown please. + (setq file (expand-file-name file)))) + (when (and (not (gethash file ht)) (string-prefix-p root file)) + (let ((part (substring file len))) + (when (equal part "") (setq part "./")) + (put-text-property 0 1 'multi-category `(file . ,file) part) + (push part items)))))))) + "Project file candidate source for `consult-buffer'.") + +(defvar consult--source-project-buffer-hidden + `(:hidden t :narrow (?p . "Project") ,@consult--source-project-buffer) + "Like `consult--source-project-buffer' but hidden by default.") + +(defvar consult--source-project-recent-file-hidden + `(:hidden t :narrow (?p . "Project") ,@consult--source-project-recent-file) + "Like `consult--source-project-recent-file' but hidden by default.") + +(defvar consult--source-hidden-buffer + `(:name "Hidden Buffer" + :narrow ?\s + :hidden t + :category buffer + :face consult-buffer + :history buffer-name-history + :action ,#'consult--buffer-action + :items + ,(lambda () (consult--buffer-query :sort 'visibility + :filter 'invert + :as #'consult--buffer-pair))) + "Hidden buffer candidate source for `consult-buffer'.") + +(defvar consult--source-modified-buffer + `(:name "Modified Buffer" + :narrow ?* + :hidden t + :category buffer + :face consult-buffer + :history buffer-name-history + :state ,#'consult--buffer-state + :items + ,(lambda () (consult--buffer-query :sort 'visibility + :as #'consult--buffer-pair + :predicate + (lambda (buf) + (and (buffer-modified-p buf) + (buffer-file-name buf)))))) + "Modified buffer candidate source for `consult-buffer'.") + +(defvar consult--source-buffer + `(:name "Buffer" + :narrow ?b + :category buffer + :face consult-buffer + :history buffer-name-history + :state ,#'consult--buffer-state + :default t + :items + ,(lambda () (consult--buffer-query :sort 'visibility + :as #'consult--buffer-pair))) + "Buffer candidate source for `consult-buffer'.") + +(defun consult--file-register-p (reg) + "Return non-nil if REG is a file register." + (memq (car-safe (cdr reg)) '(file-query file))) + +(autoload 'consult-register--candidates "consult-register") +(defvar consult--source-file-register + `(:name "File Register" + :narrow (?r . "Register") + :category file + :state ,#'consult--file-state + :enabled ,(lambda () (seq-some #'consult--file-register-p register-alist)) + :items ,(lambda () (consult-register--candidates #'consult--file-register-p))) + "File register source.") + +(defvar consult--source-recent-file + `(:name "File" + :narrow ?f + :category file + :face consult-file + :history file-name-history + :state ,#'consult--file-state + :new ,#'consult--file-action + :enabled ,(lambda () recentf-mode) + :items + ,(lambda () + (let ((ht (consult--buffer-file-hash)) + items) + (dolist (file (bound-and-true-p recentf-list) (nreverse items)) + ;; Emacs 29 abbreviates file paths by default, see + ;; `recentf-filename-handlers'. I recommend to set + ;; `recentf-filename-handlers' to nil to avoid any slow down. + (unless (eq (aref file 0) ?/) + (let (file-name-handler-alist) ;; No Tramp slowdown please. + (setq file (expand-file-name file)))) + (unless (gethash file ht) + (push (consult--fast-abbreviate-file-name file) items)))))) + "Recent file candidate source for `consult-buffer'.") + +;;;###autoload +(defun consult-buffer (&optional sources) + "Enhanced `switch-to-buffer' command with support for virtual buffers. + +The command supports recent files, bookmarks, views and project files as +virtual buffers. Buffers are previewed. Narrowing to buffers (b), files (f), +bookmarks (m) and project files (p) is supported via the corresponding +keys. In order to determine the project-specific files and buffers, the +`consult-project-function' is used. The virtual buffer SOURCES +default to `consult-buffer-sources'. See `consult--multi' for the +configuration of the virtual buffer sources." + (interactive) + (let ((selected (consult--multi (or sources consult-buffer-sources) + :require-match + (confirm-nonexistent-file-or-buffer) + :prompt "Switch to: " + :history 'consult--buffer-history + :sort nil))) + ;; For non-matching candidates, fall back to buffer creation. + (unless (plist-get (cdr selected) :match) + (consult--buffer-action (car selected))))) + +(defmacro consult--with-project (&rest body) + "Ensure that BODY is executed with a project root." + ;; We have to work quite hard here to ensure that the project root is + ;; only overridden at the current recursion level. When entering a + ;; recursive minibuffer session, we should be able to still switch the + ;; project. But who does that? Working on the first level on project A + ;; and on the second level on project B and on the third level on project C? + ;; You mustn't be afraid to dream a little bigger, darling. + `(let ((consult-project-function + (let ((root (or (consult--project-root t) (user-error "No project found"))) + (depth (recursion-depth)) + (orig consult-project-function)) + (lambda (may-prompt) + (if (= depth (recursion-depth)) + root + (funcall orig may-prompt)))))) + ,@body)) + +;;;###autoload +(defun consult-project-buffer () + "Enhanced `project-switch-to-buffer' command with support for virtual buffers. +The command may prompt you for a project directory if it is invoked from +outside a project. See `consult-buffer' for more details." + (interactive) + (consult--with-project + (consult-buffer consult-project-buffer-sources))) + +;;;###autoload +(defun consult-buffer-other-window () + "Variant of `consult-buffer', switching to a buffer in another window." + (interactive) + (let ((consult--buffer-display #'switch-to-buffer-other-window)) + (consult-buffer))) + +;;;###autoload +(defun consult-buffer-other-frame () + "Variant of `consult-buffer', switching to a buffer in another frame." + (interactive) + (let ((consult--buffer-display #'switch-to-buffer-other-frame)) + (consult-buffer))) + +;;;###autoload +(defun consult-buffer-other-tab () + "Variant of `consult-buffer', switching to a buffer in another tab." + (interactive) + (let ((consult--buffer-display #'switch-to-buffer-other-tab)) + (consult-buffer))) + +;;;;; Command: consult-grep + +(defun consult--grep-format (async builder) + "Return ASYNC function highlighting grep match results. +BUILDER is the command line builder function." + (let (highlight) + (lambda (action) + (cond + ((stringp action) + (setq highlight (cdr (funcall builder action))) + (funcall async action)) + ((consp action) + (let ((file "") (file-len 0) result) + (save-match-data + (dolist (str action) + (when (and (string-match consult--grep-match-regexp str) + ;; Filter out empty context lines + (or (/= (aref str (match-beginning 3)) ?-) + (/= (match-end 0) (length str)))) + ;; We share the file name across candidates to reduce + ;; the amount of allocated memory. + (unless (and (= file-len (- (match-end 1) (match-beginning 1))) + (eq t (compare-strings + file 0 file-len + str (match-beginning 1) (match-end 1) nil))) + (setq file (match-string 1 str) + file-len (length file))) + (let* ((line (match-string 2 str)) + (ctx (= (aref str (match-beginning 3)) ?-)) + (sep (if ctx "-" ":")) + (content (substring str (match-end 0))) + (line-len (length line))) + (when (length> content consult-grep-max-columns) + (setq content (substring content 0 consult-grep-max-columns))) + (when highlight + (funcall highlight content)) + (setq str (concat file sep line sep content)) + ;; Store file name in order to avoid allocations in `consult--prefix-group' + (add-text-properties 0 file-len `(face consult-file consult--prefix-group ,file) str) + (put-text-property (1+ file-len) (+ 1 file-len line-len) 'face 'consult-line-number str) + (when ctx + (add-face-text-property (+ 2 file-len line-len) (length str) 'consult-grep-context 'append str)) + (push str result))))) + (funcall async (nreverse result)))) + (t (funcall async action)))))) + +(defun consult--grep-position (cand &optional find-file) + "Return the grep position marker for CAND. +FIND-FILE is the file open function, defaulting to `find-file-noselect'." + (when cand + (let* ((file-end (next-single-property-change 0 'face cand)) + (line-end (next-single-property-change (1+ file-end) 'face cand)) + (matches (consult--point-placement cand (1+ line-end) 'consult-grep-context)) + (file (substring-no-properties cand 0 file-end)) + (line (string-to-number (substring-no-properties cand (+ 1 file-end) line-end)))) + (when-let (pos (consult--marker-from-line-column + (funcall (or find-file #'consult--file-action) file) + line (or (car matches) 0))) + (cons pos (cdr matches)))))) + +(defun consult--grep-state () + "Grep state function." + (let ((open (consult--temporary-files)) + (jump (consult--jump-state))) + (lambda (action cand) + (unless cand + (funcall open)) + (funcall jump action (consult--grep-position + cand + (and (not (eq action 'return)) open)))))) + +(defun consult--grep-exclude-args () + "Produce grep exclude arguments. +Take the variables `grep-find-ignored-directories' and +`grep-find-ignored-files' into account." + (unless (boundp 'grep-find-ignored-files) (require 'grep)) + (nconc (mapcar (lambda (s) (concat "--exclude=" s)) + (bound-and-true-p grep-find-ignored-files)) + (mapcar (lambda (s) (concat "--exclude-dir=" s)) + (bound-and-true-p grep-find-ignored-directories)))) + +(defun consult--grep (prompt make-builder dir initial) + "Run asynchronous grep. + +MAKE-BUILDER is the function that returns the command line +builder function. DIR is a directory or a list of file or +directories. PROMPT is the prompt string. INITIAL is initial +input." + (pcase-let* ((`(,prompt ,paths ,dir) (consult--directory-prompt prompt dir)) + (default-directory dir) + (builder (funcall make-builder paths))) + (consult--read + (consult--async-command builder + (consult--grep-format builder) + :file-handler t) ;; allow tramp + :prompt prompt + :lookup #'consult--lookup-member + :state (consult--grep-state) + :initial (consult--async-split-initial initial) + :add-history (consult--async-split-thingatpt 'symbol) + :require-match t + :category 'consult-grep + :group #'consult--prefix-group + :history '(:input consult--grep-history) + :sort nil))) + +(defun consult--grep-lookahead-p (&rest cmd) + "Return t if grep CMD supports look-ahead." + (eq 0 (process-file-shell-command + (concat "echo xaxbx | " + (mapconcat #'shell-quote-argument `(,@cmd "^(?=.*b)(?=.*a)") " "))))) + +(defun consult--grep-make-builder (paths) + "Build grep command line and grep across PATHS." + (let* ((cmd (consult--build-args consult-grep-args)) + (type (if (consult--grep-lookahead-p (car cmd) "-P") 'pcre 'extended))) + (lambda (input) + (pcase-let* ((`(,arg . ,opts) (consult--command-split input)) + (flags (append cmd opts)) + (ignore-case (or (member "-i" flags) (member "--ignore-case" flags)))) + (if (or (member "-F" flags) (member "--fixed-strings" flags)) + (cons (append cmd (list "-e" arg) opts paths) + (apply-partially #'consult--highlight-regexps + (list (regexp-quote arg)) ignore-case)) + (pcase-let ((`(,re . ,hl) (funcall consult--regexp-compiler arg type ignore-case))) + (when re + (cons (append cmd + (list (if (eq type 'pcre) "-P" "-E") ;; perl or extended + "-e" (consult--join-regexps re type)) + opts paths) + hl)))))))) + +;;;###autoload +(defun consult-grep (&optional dir initial) + "Search with `grep' for files in DIR where the content matches a regexp. + +The initial input is given by the INITIAL argument. DIR can be +nil, a directory string or a list of file/directory paths. If +`consult-grep' is called interactively with a prefix argument, +the user can specify the directories or files to search in. +Multiple directories must be separated by comma in the +minibuffer, since they are read via `completing-read-multiple'. +By default the project directory is used if +`consult-project-function' is defined and returns non-nil. +Otherwise the `default-directory' is searched. + +The input string is split, the first part of the string (grep +input) is passed to the asynchronous grep process and the second +part of the string is passed to the completion-style filtering. + +The input string is split at a punctuation character, which is +given as the first character of the input string. The format is +similar to Perl-style regular expressions, e.g., /regexp/. +Furthermore command line options can be passed to grep, specified +behind --. The overall prompt input has the form +`#async-input -- grep-opts#filter-string'. + +Note that the grep input string is transformed from Emacs regular +expressions to Posix regular expressions. Always enter Emacs +regular expressions at the prompt. `consult-grep' behaves like +builtin Emacs search commands, e.g., Isearch, which take Emacs +regular expressions. Furthermore the asynchronous input split +into words, each word must match separately and in any order. +See `consult--regexp-compiler' for the inner workings. In order +to disable transformations of the grep input, adjust +`consult--regexp-compiler' accordingly. + +Here we give a few example inputs: + +#alpha beta : Search for alpha and beta in any order. +#alpha.*beta : Search for alpha before beta. +#\\(alpha\\|beta\\) : Search for alpha or beta (Note Emacs syntax!) +#word -- -C3 : Search for word, include 3 lines as context +#first#second : Search for first, quick filter for second. + +The symbol at point is added to the future history." + (interactive "P") + (consult--grep "Grep" #'consult--grep-make-builder dir initial)) + +;;;;; Command: consult-git-grep + +(defun consult--git-grep-make-builder (paths) + "Create grep command line builder given PATHS." + (let ((cmd (consult--build-args consult-git-grep-args))) + (lambda (input) + (pcase-let* ((`(,arg . ,opts) (consult--command-split input)) + (flags (append cmd opts)) + (ignore-case (or (member "-i" flags) (member "--ignore-case" flags)))) + (if (or (member "-F" flags) (member "--fixed-strings" flags)) + (cons (append cmd (list "-e" arg) opts paths) + (apply-partially #'consult--highlight-regexps + (list (regexp-quote arg)) ignore-case)) + (pcase-let ((`(,re . ,hl) (funcall consult--regexp-compiler arg 'extended ignore-case))) + (when re + (cons (append cmd + (cdr (mapcan (lambda (x) (list "--and" "-e" x)) re)) + opts paths) + hl)))))))) + +;;;###autoload +(defun consult-git-grep (&optional dir initial) + "Search with `git grep' for files in DIR with INITIAL input. +See `consult-grep' for details." + (interactive "P") + (consult--grep "Git-grep" #'consult--git-grep-make-builder dir initial)) + +;;;;; Command: consult-ripgrep + +(defun consult--ripgrep-make-builder (paths) + "Create ripgrep command line builder given PATHS." + (let* ((cmd (consult--build-args consult-ripgrep-args)) + (type (if (consult--grep-lookahead-p (car cmd) "-P") 'pcre 'extended))) + (lambda (input) + (pcase-let* ((`(,arg . ,opts) (consult--command-split input)) + (flags (append cmd opts)) + (ignore-case + (and (not (or (member "-s" flags) (member "--case-sensitive" flags))) + (or (member "-i" flags) (member "--ignore-case" flags) + (and (or (member "-S" flags) (member "--smart-case" flags)) + (let (case-fold-search) + ;; Case insensitive if there are no uppercase letters + (not (string-match-p "[[:upper:]]" arg)))))))) + (if (or (member "-F" flags) (member "--fixed-strings" flags)) + (cons (append cmd (list "-e" arg) opts paths) + (apply-partially #'consult--highlight-regexps + (list (regexp-quote arg)) ignore-case)) + (pcase-let ((`(,re . ,hl) (funcall consult--regexp-compiler arg type ignore-case))) + (when re + (cons (append cmd (and (eq type 'pcre) '("-P")) + (list "-e" (consult--join-regexps re type)) + opts paths) + hl)))))))) + +;;;###autoload +(defun consult-ripgrep (&optional dir initial) + "Search with `rg' for files in DIR with INITIAL input. +See `consult-grep' for details." + (interactive "P") + (consult--grep "Ripgrep" #'consult--ripgrep-make-builder dir initial)) + +;;;;; Command: consult-find + +(defun consult--find (prompt builder initial) + "Run find command in current directory. + +The function returns the selected file. +The filename at point is added to the future history. + +BUILDER is the command line builder function. +PROMPT is the prompt. +INITIAL is initial input." + (consult--read + (consult--async-command builder + (consult--async-map (lambda (x) (string-remove-prefix "./" x))) + (consult--async-highlight builder) + :file-handler t) ;; allow tramp + :prompt prompt + :sort nil + :require-match t + :initial (consult--async-split-initial initial) + :add-history (consult--async-split-thingatpt 'filename) + :category 'file + :history '(:input consult--find-history))) + +(defun consult--find-make-builder (paths) + "Build find command line, finding across PATHS." + (let* ((cmd (seq-mapcat (lambda (x) + (if (equal x ".") paths (list x))) + (consult--build-args consult-find-args))) + (type (if (eq 0 (process-file-shell-command + (concat (car cmd) " -regextype emacs -version"))) + 'emacs 'basic))) + (lambda (input) + (pcase-let* ((`(,arg . ,opts) (consult--command-split input)) + ;; ignore-case=t since -iregex is used below + (`(,re . ,hl) (funcall consult--regexp-compiler arg type t))) + (when re + (cons (append cmd + (cdr (mapcan + (lambda (x) + `("-and" "-iregex" + ,(format ".*%s.*" + ;; Replace non-capturing groups with capturing groups. + ;; GNU find does not support non-capturing groups. + (replace-regexp-in-string + "\\\\(\\?:" "\\(" x 'fixedcase 'literal)))) + re)) + opts) + hl)))))) + +;;;###autoload +(defun consult-find (&optional dir initial) + "Search for files with `find' in DIR. +The file names must match the input regexp. INITIAL is the +initial minibuffer input. See `consult-grep' for details +regarding the asynchronous search and the arguments." + (interactive "P") + (pcase-let* ((`(,prompt ,paths ,dir) (consult--directory-prompt "Find" dir)) + (default-directory dir) + (builder (consult--find-make-builder paths))) + (find-file (consult--find prompt builder initial)))) + +;;;;; Command: consult-fd + +(defun consult--fd-make-builder (paths) + "Build find command line, finding across PATHS." + (let ((cmd (consult--build-args consult-fd-args))) + (lambda (input) + (pcase-let* ((`(,arg . ,opts) (consult--command-split input)) + (flags (append cmd opts)) + (ignore-case + (and (not (or (member "-s" flags) (member "--case-sensitive" flags))) + (or (member "-i" flags) (member "--ignore-case" flags) + (let (case-fold-search) + ;; Case insensitive if there are no uppercase letters + (not (string-match-p "[[:upper:]]" arg))))))) + (if (or (member "-F" flags) (member "--fixed-strings" flags)) + (cons (append cmd (list arg) opts paths) + (apply-partially #'consult--highlight-regexps + (list (regexp-quote arg)) ignore-case)) + (pcase-let ((`(,re . ,hl) (funcall consult--regexp-compiler arg 'pcre ignore-case))) + (when re + (cons (append cmd + (mapcan (lambda (x) `("--and" ,x)) re) + opts paths) + hl)))))))) + +;;;###autoload +(defun consult-fd (&optional dir initial) + "Search for files with `fd' in DIR. +The file names must match the input regexp. INITIAL is the +initial minibuffer input. See `consult-grep' for details +regarding the asynchronous search and the arguments." + (interactive "P") + (pcase-let* ((`(,prompt ,paths ,dir) (consult--directory-prompt "Fd" dir)) + (default-directory dir) + (builder (consult--fd-make-builder paths))) + (find-file (consult--find prompt builder initial)))) + +;;;;; Command: consult-locate + +(defun consult--locate-builder (input) + "Build command line from INPUT." + (pcase-let ((`(,arg . ,opts) (consult--command-split input))) + (unless (string-blank-p arg) + (cons (append (consult--build-args consult-locate-args) + (consult--split-escaped arg) opts) + (cdr (consult--default-regexp-compiler input 'basic t)))))) + +;;;###autoload +(defun consult-locate (&optional initial) + "Search with `locate' for files which match input given INITIAL input. + +The input is treated literally such that locate can take advantage of +the locate database index. Regular expressions would often force a slow +linear search through the entire database. The locate process is started +asynchronously, similar to `consult-grep'. See `consult-grep' for more +details regarding the asynchronous search." + (interactive) + (find-file (consult--find "Locate: " #'consult--locate-builder initial))) + +;;;;; Command: consult-man + +(defun consult--man-builder (input) + "Build command line from INPUT." + (pcase-let* ((`(,arg . ,opts) (consult--command-split input)) + (`(,re . ,hl) (funcall consult--regexp-compiler arg 'extended t))) + (when re + (cons (append (consult--build-args consult-man-args) + (list (consult--join-regexps re 'extended)) + opts) + hl)))) + +(defun consult--man-format (lines) + "Format man candidates from LINES." + (let ((candidates)) + (save-match-data + (dolist (str lines) + (when (string-match "\\`\\(.*?\\([^ ]+\\) *(\\([^,)]+\\)[^)]*).*?\\) +- +\\(.*\\)\\'" str) + (let* ((names (match-string 1 str)) + (name (match-string 2 str)) + (section (match-string 3 str)) + (desc (match-string 4 str)) + (cand (format "%s - %s" names desc))) + (add-text-properties 0 (length names) + (list 'face 'consult-file + 'consult-man (concat section " " name)) + cand) + (push cand candidates))))) + (nreverse candidates))) + +;;;###autoload +(defun consult-man (&optional initial) + "Search for man page given INITIAL input. + +The input string is not preprocessed and passed literally to the +underlying man commands. The man process is started asynchronously, +similar to `consult-grep'. See `consult-grep' for more details regarding +the asynchronous search." + (interactive) + (man (consult--read + (consult--async-command #'consult--man-builder + (consult--async-transform consult--man-format) + (consult--async-highlight #'consult--man-builder)) + :prompt "Manual entry: " + :require-match t + :category 'consult-man + :lookup (apply-partially #'consult--lookup-prop 'consult-man) + :initial (consult--async-split-initial initial) + :add-history (consult--async-split-thingatpt 'symbol) + :history '(:input consult--man-history)))) + +;;;; Preview at point in completions buffers + +(define-minor-mode consult-preview-at-point-mode + "Preview minor mode for *Completions* buffers. +When moving around in the *Completions* buffer, the candidate at point is +automatically previewed." + :group 'consult + (if consult-preview-at-point-mode + (add-hook 'post-command-hook #'consult-preview-at-point nil 'local) + (remove-hook 'post-command-hook #'consult-preview-at-point 'local))) + +(defun consult-preview-at-point () + "Preview candidate at point in *Completions* buffer." + (interactive) + (when-let ((win (active-minibuffer-window)) + (buf (window-buffer win)) + (fun (buffer-local-value 'consult--preview-function buf))) + (funcall fun))) + +;;;; Integration with completion systems + +;;;;; Integration: Default *Completions* + +(defun consult--default-completion-minibuffer-candidate () + "Return current minibuffer candidate from default completion system or Icomplete." + (when (and (minibufferp) + (eq completing-read-function #'completing-read-default)) + (let ((content (minibuffer-contents-no-properties))) + ;; When the current minibuffer content matches a candidate, return it! + (if (test-completion content + minibuffer-completion-table + minibuffer-completion-predicate) + content + ;; Return the full first candidate of the sorted completion list. + (when-let ((completions (completion-all-sorted-completions))) + (concat + (substring content 0 (or (cdr (last completions)) 0)) + (car completions))))))) + +(defun consult--default-completion-list-candidate () + "Return current candidate at point from completions buffer." + (let (beg end) + (when (and + (derived-mode-p 'completion-list-mode) + ;; Logic taken from `choose-completion'. + ;; TODO Upstream a `completion-list-get-candidate' function. + (cond + ((and (not (eobp)) (get-text-property (point) 'mouse-face)) + (setq end (point) beg (1+ (point)))) + ((and (not (bobp)) (get-text-property (1- (point)) 'mouse-face)) + (setq end (1- (point)) beg (point))))) + (setq beg (previous-single-property-change beg 'mouse-face) + end (or (next-single-property-change end 'mouse-face) (point-max))) + (or (get-text-property beg 'completion--string) + (buffer-substring-no-properties beg end))))) + +;;;;; Integration: Vertico + +(defvar vertico--input) +(declare-function vertico--exhibit "ext:vertico") +(declare-function vertico--candidate "ext:vertico") +(declare-function vertico--filter-completions "ext:vertico") + +(defun consult--vertico-candidate () + "Return current candidate for Consult preview." + (and vertico--input (vertico--candidate 'highlight))) + +(defun consult--vertico-refresh () + "Refresh completion UI." + (when vertico--input + (setq vertico--input t) + (vertico--exhibit))) + +(defun consult--vertico-filter-adv (orig pattern cands category highlight) + "Advice for ORIG `consult--completion-filter' function. +See `consult--completion-filter' for arguments PATTERN, CANDS, CATEGORY +and HIGHLIGHT." + (if (and (not highlight) (bound-and-true-p vertico-mode)) + ;; Optimize `consult--completion-filter' using the deferred highlighting + ;; from Vertico. The advice is not necessary - it is a pure optimization. + (nconc (car (vertico--filter-completions pattern cands nil (length pattern) + `(metadata (category . ,category)))) + nil) + (funcall orig pattern cands category highlight))) + +(with-eval-after-load 'vertico + (advice-add #'consult--completion-filter :around #'consult--vertico-filter-adv) + (add-hook 'consult--completion-candidate-hook #'consult--vertico-candidate) + (add-hook 'consult--completion-refresh-hook #'consult--vertico-refresh) + (define-key consult-async-map [remap vertico-insert] 'vertico-next-group)) + +;;;;; Integration: Mct + +(with-eval-after-load 'mct (add-hook 'consult--completion-refresh-hook + 'mct--live-completions-refresh)) + +;;;;; Integration: Icomplete + +(defvar icomplete-mode) +(declare-function icomplete-exhibit "icomplete") + +(defun consult--icomplete-refresh () + "Refresh icomplete view." + (when icomplete-mode + (let ((top (car completion-all-sorted-completions))) + (completion--flush-all-sorted-completions) + ;; force flushing, otherwise narrowing is broken! + (setq completion-all-sorted-completions nil) + (when top + (let* ((completions (completion-all-sorted-completions)) + (last (last completions)) + (before)) ;; completions before top + ;; warning: completions is an improper list + (while (consp completions) + (if (equal (car completions) top) + (progn + (setcdr last (append (nreverse before) (cdr last))) + (setq completion-all-sorted-completions completions + completions nil)) + (push (car completions) before) + (setq completions (cdr completions))))))) + (icomplete-exhibit))) + +(with-eval-after-load 'icomplete + (add-hook 'consult--completion-refresh-hook #'consult--icomplete-refresh)) + +(provide 'consult) +;;; consult.el ends here diff --git a/emacs/elpa/consult-20240523.754/consult.elc b/emacs/elpa/consult-20240523.754/consult.elc Binary files differ. diff --git a/emacs/elpa/corfu-20240413.927/corfu-echo.el b/emacs/elpa/corfu-20240413.927/corfu-echo.el @@ -1,109 +0,0 @@ -;;; corfu-echo.el --- Show candidate documentation in echo area -*- lexical-binding: t -*- - -;; Copyright (C) 2021-2024 Free Software Foundation, Inc. - -;; Author: Daniel Mendler <mail@daniel-mendler.de> -;; Maintainer: Daniel Mendler <mail@daniel-mendler.de> -;; Created: 2022 -;; Version: 1.3 -;; Package-Requires: ((emacs "27.1") (compat "29.1.4.4") (corfu "1.3")) -;; Homepage: https://github.com/minad/corfu - -;; This file is part of GNU Emacs. - -;; 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 <https://www.gnu.org/licenses/>. - -;;; Commentary: - -;; Show candidate documentation in echo area. Enable `corfu-echo-mode'. - -;;; Code: - -(require 'corfu) -(eval-when-compile - (require 'subr-x)) - -(defface corfu-echo - '((t :inherit completions-annotations)) - "Face used for echo area messages." - :group 'corfu-faces) - -(defcustom corfu-echo-delay '(2.0 . 1.0) - "Show documentation string in the echo area after that number of seconds. -The value can be a pair of two floats to specify initial and -subsequent delay." - :type '(choice (const :tag "Never" nil) - (number :tag "Delay in seconds") - (cons :tag "Two Delays" - (choice :tag "Initial " number) - (choice :tag "Subsequent" number))) - :group 'corfu) - -(defvar corfu-echo--timer nil - "Echo area message timer.") - -(defvar corfu-echo--message nil - "Last echo message.") - -(defun corfu-echo--cancel (&optional msg) - "Cancel echo timer and refresh MSG." - (when corfu-echo--timer - (cancel-timer corfu-echo--timer) - (setq corfu-echo--timer nil)) - (corfu-echo--show msg) - (unless corfu-echo--message - (setq corfu-echo--timer nil - corfu-echo--message nil))) - -(defun corfu-echo--show (msg) - "Show MSG in echo area." - (when (or msg corfu-echo--message) - (setq msg (or msg "") - corfu-echo--message msg) - (corfu--message "%s" (if (text-property-not-all 0 (length msg) 'face nil msg) - msg - (propertize msg 'face 'corfu-echo))))) - -;;;###autoload -(define-minor-mode corfu-echo-mode - "Show candidate documentation in echo area." - :global t :group 'corfu) - -(cl-defmethod corfu--exhibit :after (&context (corfu-echo-mode (eql t)) &optional _auto) - (if-let ((delay (if (consp corfu-echo-delay) - (funcall (if corfu-echo--message #'cdr #'car) - corfu-echo-delay) - corfu-echo-delay)) - (extra (nth 4 completion-in-region--data)) - (fun (plist-get extra :company-docsig)) - (cand (and (>= corfu--index 0) - (nth corfu--index corfu--candidates)))) - (if (<= delay 0) - (corfu-echo--show (funcall fun cand)) - (corfu-echo--cancel) - (setq corfu-echo--timer - (run-at-time delay nil - (lambda () - (corfu-echo--show (funcall fun cand)))))) - (corfu-echo--cancel))) - -(cl-defmethod corfu--teardown :before (_buf &context (corfu-echo-mode (eql t))) - (corfu-echo--cancel)) - -(cl-defmethod corfu--prepare :before (&context (corfu-echo-mode (eql t))) - ;; The refreshing is needed to prevent flicker if corfu-echo-delay=t. - (corfu-echo--cancel corfu-echo--message)) - -(provide 'corfu-echo) -;;; corfu-echo.el ends here diff --git a/emacs/elpa/corfu-20240413.927/corfu-history.el b/emacs/elpa/corfu-20240413.927/corfu-history.el @@ -1,92 +0,0 @@ -;;; corfu-history.el --- Sorting by history for Corfu -*- lexical-binding: t -*- - -;; Copyright (C) 2022-2024 Free Software Foundation, Inc. - -;; Author: Daniel Mendler <mail@daniel-mendler.de> -;; Maintainer: Daniel Mendler <mail@daniel-mendler.de> -;; Created: 2022 -;; Version: 1.3 -;; Package-Requires: ((emacs "27.1") (compat "29.1.4.4") (corfu "1.3")) -;; Homepage: https://github.com/minad/corfu - -;; This file is part of GNU Emacs. - -;; 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 <https://www.gnu.org/licenses/>. - -;;; Commentary: - -;; Enable `corfu-history-mode' to sort candidates by their history -;; position. Maintain a list of recently selected candidates. In order -;; to save the history across Emacs sessions, enable `savehist-mode' and -;; add `corfu-history' to `savehist-additional-variables'. -;; -;; (corfu-history-mode 1) -;; (savehist-mode 1) -;; (add-to-list 'savehist-additional-variables 'corfu-history) - -;;; Code: - -(require 'corfu) -(eval-when-compile - (require 'cl-lib)) - -(defvar corfu-history nil - "History of Corfu candidates. -The maximum length is determined by the variable `history-length' -or the property `history-length' of `corfu-history'.") - -(defvar corfu-history--hash nil - "Hash table of Corfu candidates.") - -(defun corfu-history--sort-predicate (x y) - "Sorting predicate which compares X and Y." - (or (< (cdr x) (cdr y)) - (and (= (cdr x) (cdr y)) - (corfu--length-string< (car x) (car y))))) - -(defun corfu-history--sort (cands) - "Sort CANDS by history." - (unless corfu-history--hash - (setq corfu-history--hash (make-hash-table :test #'equal :size (length corfu-history))) - (cl-loop for elem in corfu-history for index from 0 do - (unless (gethash elem corfu-history--hash) - (puthash elem index corfu-history--hash)))) - ;; Decorate each candidate with (index<<13) + length. This way we sort first by index and then by - ;; length. We assume that the candidates are shorter than 2**13 characters and that the history is - ;; shorter than 2**16 entries. - (cl-loop for cand on cands do - (setcar cand (cons (car cand) - (+ (ash (gethash (car cand) corfu-history--hash #xFFFF) 13) - (length (car cand)))))) - (setq cands (sort cands #'corfu-history--sort-predicate)) - (cl-loop for cand on cands do (setcar cand (caar cand))) - cands) - -;;;###autoload -(define-minor-mode corfu-history-mode - "Update Corfu history and sort completions by history." - :global t :group 'corfu - (if corfu-history-mode - (add-function :override corfu-sort-function #'corfu-history--sort) - (remove-function corfu-sort-function #'corfu-history--sort))) - -(cl-defmethod corfu--insert :before (_status &context (corfu-history-mode (eql t))) - (when (>= corfu--index 0) - (add-to-history 'corfu-history - (substring-no-properties - (nth corfu--index corfu--candidates))) - (setq corfu-history--hash nil))) - -(provide 'corfu-history) -;;; corfu-history.el ends here diff --git a/emacs/elpa/corfu-20240413.927/corfu-indexed.el b/emacs/elpa/corfu-20240413.927/corfu-indexed.el @@ -1,97 +0,0 @@ -;;; corfu-indexed.el --- Select indexed candidates -*- lexical-binding: t -*- - -;; Copyright (C) 2022-2024 Free Software Foundation, Inc. - -;; Author: Luis Henriquez-Perez <luis@luishp.xyz>, Daniel Mendler <mail@daniel-mendler.de> -;; Maintainer: Daniel Mendler <mail@daniel-mendler.de> -;; Created: 2022 -;; Version: 1.3 -;; Package-Requires: ((emacs "27.1") (compat "29.1.4.4") (corfu "1.3")) -;; Homepage: https://github.com/minad/corfu - -;; This file is part of GNU Emacs. - -;; 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 <https://www.gnu.org/licenses/>. - -;;; Commentary: - -;; This package is a Corfu extension, which prefixes candidates with indices if -;; enabled via `corfu-indexed-mode'. It allows you to select candidates with -;; prefix arguments. This is designed to be a faster alternative to selecting a -;; candidate with `corfu-next' and `corfu-previous'. - -;;; Code: - -(require 'corfu) -(eval-when-compile - (require 'cl-lib)) - -(defface corfu-indexed - '((default :height 0.75) - (((class color) (min-colors 88) (background dark)) - :foreground "#f4f4f4" :background "#323232") - (((class color) (min-colors 88) (background light)) - :foreground "#404148" :background "#d7d7d7") - (t :background "black")) - "Face used for the candidate index prefix." - :group 'corfu-faces) - -(defcustom corfu-indexed-start 0 - "Start of the indexing." - :group 'corfu - :type 'natnum) - -(defvar corfu-indexed--commands - '(corfu-insert corfu-complete) - "Commands that should be indexed.") - -;;;###autoload -(define-minor-mode corfu-indexed-mode - "Prefix candidates with indices." - :global t :group 'corfu) - -(cl-defmethod corfu--prepare :before (&context (corfu-indexed-mode (eql t))) - (when (and prefix-arg (memq this-command corfu-indexed--commands)) - (let ((index (+ corfu--scroll - (- (prefix-numeric-value prefix-arg) - corfu-indexed-start)))) - (if (and (>= index 0) - (< index corfu--total) - (< index (+ corfu--scroll corfu-count))) - (setq corfu--index index) - (message "Out of range") - (setq this-command #'ignore))))) - -(cl-defmethod corfu--affixate :around (cands &context (corfu-indexed-mode (eql t))) - (setq cands (cdr (cl-call-next-method cands))) - (let* ((space #(" " 0 1 (face (:height 0.5 :inherit corfu-indexed)))) - (width (if (length> cands (- 10 corfu-indexed-start)) 2 1)) - (fmt (concat space - (propertize (format "%%%ds" width) - 'face 'corfu-indexed) - space)) - (align - (propertize (make-string width ?\s) - 'display - `(space :align-to (+ left ,(1+ width)))))) - (cl-loop for cand in cands for index from corfu-indexed-start do - (setf (cadr cand) - (concat - (propertize " " 'display (format fmt index)) - align - (cadr cand)))) - (cons t cands))) - -(provide 'corfu-indexed) -;;; corfu-indexed.el ends here diff --git a/emacs/elpa/corfu-20240413.927/corfu-info.el b/emacs/elpa/corfu-20240413.927/corfu-info.el @@ -1,118 +0,0 @@ -;;; corfu-info.el --- Show candidate information in separate buffer -*- lexical-binding: t -*- - -;; Copyright (C) 2022-2024 Free Software Foundation, Inc. - -;; Author: Daniel Mendler <mail@daniel-mendler.de> -;; Maintainer: Daniel Mendler <mail@daniel-mendler.de> -;; Created: 2022 -;; Version: 1.3 -;; Package-Requires: ((emacs "27.1") (compat "29.1.4.4") (corfu "1.3")) -;; Homepage: https://github.com/minad/corfu - -;; This file is part of GNU Emacs. - -;; 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 <https://www.gnu.org/licenses/>. - -;;; Commentary: - -;; This Corfu extension provides commands to show additional information to the -;; candidates in a separate buffer. The commands `corfu-info-location' and -;; `corfu-info-documentation' are bound by default in the `corfu-map' to M-g and -;; M-h respectively. - -;;; Code: - -(require 'corfu) -(eval-when-compile - (require 'subr-x)) - -(defun corfu-info--restore-on-next-command () - "Restore window configuration before next command." - (let ((config (current-window-configuration)) - (other other-window-scroll-buffer) - (restore (make-symbol "corfu--restore"))) - (fset restore - (lambda () - (setq other-window-scroll-buffer other) - (unless (memq this-command '(scroll-other-window scroll-other-window-down)) - (when (memq this-command '(corfu-quit corfu-reset)) - (setq this-command #'ignore)) - (remove-hook 'pre-command-hook restore) - (set-window-configuration config)))) - (add-hook 'pre-command-hook restore))) - -(defun corfu-info--display-buffer (buffer name) - "Display BUFFER and return window displaying the buffer. -Make the buffer persistent with NAME if non-nil." - (if name - (unless (buffer-local-value 'buffer-file-name buffer) - (if-let ((old (get-buffer name))) - (setq buffer (prog1 old (kill-buffer buffer))) - (with-current-buffer buffer - (rename-buffer name)))) - (corfu-info--restore-on-next-command)) - (setq other-window-scroll-buffer buffer) - (display-buffer buffer t)) - -;;;###autoload -(defun corfu-info-documentation (&optional arg) - "Show documentation of current candidate. -If called with a prefix ARG, the buffer is persistent." - (interactive "P") - ;; Company support, taken from `company.el', see `company-show-doc-buffer'. - (when (< corfu--index 0) - (user-error "No candidate selected")) - (let ((cand (nth corfu--index corfu--candidates))) - (if-let ((extra (nth 4 completion-in-region--data)) - (fun (plist-get extra :company-doc-buffer)) - (res (funcall fun cand))) - (set-window-start (corfu-info--display-buffer - (get-buffer (or (car-safe res) res)) - (and arg (format "*corfu doc: %s*" cand))) - (or (cdr-safe res) (point-min))) - (user-error "No documentation available for `%s'" cand)))) - -;;;###autoload -(defun corfu-info-location (&optional arg) - "Show location of current candidate. -If called with a prefix ARG, the buffer is persistent." - (interactive "P") - ;; Company support, taken from `company.el', see `company-show-location'. - (when (< corfu--index 0) - (user-error "No candidate selected")) - (let ((cand (nth corfu--index corfu--candidates))) - (if-let ((extra (nth 4 completion-in-region--data)) - (fun (plist-get extra :company-location)) - ;; BUG: company-location may throw errors if location is not found - (loc (ignore-errors (funcall fun cand)))) - (with-selected-window - (corfu-info--display-buffer - (or (and (bufferp (car loc)) (car loc)) - (find-file-noselect (car loc) t)) - (and arg (format "*corfu loc: %s*" cand))) - (without-restriction - (goto-char (point-min)) - (when-let ((pos (cdr loc))) - (if (bufferp (car loc)) - (goto-char pos) - (forward-line (1- pos)))) - (set-window-start nil (point)))) - (user-error "No location available for `%s'" cand)))) - -;; Emacs 28: Do not show Corfu commands with M-X -(put #'corfu-info-location 'completion-predicate #'ignore) -(put #'corfu-info-documentation 'completion-predicate #'ignore) - -(provide 'corfu-info) -;;; corfu-info.el ends here diff --git a/emacs/elpa/corfu-20240413.927/corfu-pkg.el b/emacs/elpa/corfu-20240413.927/corfu-pkg.el @@ -1,15 +0,0 @@ -(define-package "corfu" "20240413.927" "COmpletion in Region FUnction" - '((emacs "27.1") - (compat "29.1.4.4")) - :commit "b779552341354d59365a981fd208ae07b7a2950a" :authors - '(("Daniel Mendler" . "mail@daniel-mendler.de")) - :maintainers - '(("Daniel Mendler" . "mail@daniel-mendler.de")) - :maintainer - '("Daniel Mendler" . "mail@daniel-mendler.de") - :keywords - '("abbrev" "convenience" "matching" "completion" "text") - :url "https://github.com/minad/corfu") -;; Local Variables: -;; no-byte-compile: t -;; End: diff --git a/emacs/elpa/corfu-20240413.927/corfu-popupinfo.el b/emacs/elpa/corfu-20240413.927/corfu-popupinfo.el @@ -1,523 +0,0 @@ -;;; corfu-popupinfo.el --- Candidate information popup for Corfu -*- lexical-binding: t -*- - -;; Copyright (C) 2021-2024 Free Software Foundation, Inc. - -;; Author: Yuwei Tian <fishtai0@gmail.com>, Daniel Mendler <mail@daniel-mendler.de> -;; Maintainer: Daniel Mendler <mail@daniel-mendler.de> -;; Created: 2022 -;; Version: 1.3 -;; Package-Requires: ((emacs "27.1") (compat "29.1.4.4") (corfu "1.3")) -;; Homepage: https://github.com/minad/corfu - -;; This file is part of GNU Emacs. - -;; 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 <https://www.gnu.org/licenses/>. - -;;; Commentary: - -;; Display an information popup for completion candidate when using -;; Corfu. The popup displays either the candidate documentation or the -;; candidate location. The `corfu-popupinfo-mode' must be enabled -;; globally. Set `corfu-popupinfo-delay' to nil if the info popup should -;; not update automatically. If the popup should not appear initially, -;; but update automatically afterwards, use `(setq corfu-popupinfo-delay -;; (cons nil 1.0))'. - -;; For manual toggling the commands `corfu-popupinfo-toggle', -;; `corfu-popupinfo-location' and `corfu-popupinfo-documentation' are -;; bound in the `corfu-popupinfo-map'. - -;;; Code: - -(require 'corfu) -(eval-when-compile - (require 'cl-lib) - (require 'subr-x)) - -(defface corfu-popupinfo - '((t :inherit corfu-default)) - "Face used for the info popup." - :group 'corfu-faces) - -(defcustom corfu-popupinfo-delay '(2.0 . 1.0) - "Automatically update info popup after that number of seconds. - -The value can be a pair of two floats to specify initial and -subsequent delay. If the value is non-nil or the car of the pair -is non-nil, the popup will automatically appear for the -preselected candidate. Otherwise the popup can be requested -manually via `corfu-popupinfo-toggle', -`corfu-popupinfo-documentation' and `corfu-popupinfo-location'. - -It is *not recommended* to use a short delay or even 0, since -this will create high load for Emacs. Retrieving the -documentation from the backend is usually expensive." - :type '(choice (const :tag "Never" nil) - (number :tag "Delay in seconds") - (cons :tag "Two Delays" - (choice :tag "Initial " - (choice (const nil) number)) - (choice :tag "Subsequent" - (choice (const nil) number)))) - :group 'corfu) - -(defcustom corfu-popupinfo-hide t - "Hide the popup during the transition between candidates." - :type 'boolean - :group 'corfu) - -(defcustom corfu-popupinfo-max-width 80 - "The maximum width of the info popup in characters." - :type 'natnum - :group 'corfu) - -(defcustom corfu-popupinfo-min-width 30 - "The minimum width of the info popup in characters." - :type 'natnum - :group 'corfu) - -(defcustom corfu-popupinfo-max-height 10 - "The maximum height of the info popup in characters." - :type 'natnum - :group 'corfu) - -(defcustom corfu-popupinfo-min-height 1 - "The minimum height of the info popup in characters." - :type 'natnum - :group 'corfu) - -(defcustom corfu-popupinfo-resize t - "Resize the info popup automatically if non-nil." - :type 'boolean - :group 'corfu) - -(defcustom corfu-popupinfo-direction '(right left vertical) - "Preferred directions for the popup in order." - :type '(repeat - (choice - (const left) - (const right) - (const vertical) - (const force-left) - (const force-right) - (const force-vertical))) - :group 'corfu) - -(defvar-keymap corfu-popupinfo-map - :doc "Additional keymap activated in popupinfo mode." - "M-t" #'corfu-popupinfo-toggle - "<remap> <corfu-info-documentation>" #'corfu-popupinfo-documentation - "<remap> <corfu-info-location>" #'corfu-popupinfo-location - "<remap> <scroll-other-window>" #'corfu-popupinfo-scroll-up - "<remap> <scroll-other-window-down>" #'corfu-popupinfo-scroll-down - "<remap> <end-of-buffer-other-window>" #'corfu-popupinfo-end - "<remap> <beginning-of-buffer-other-window>" #'corfu-popupinfo-beginning) - -(defvar corfu-popupinfo--buffer-parameters - '((truncate-partial-width-windows . nil) - (truncate-lines . nil) - (left-margin-width . 1) - (right-margin-width . 1) - (word-wrap . t) - (fringe-indicator-alist (continuation))) - "Buffer parameters.") - -(defvar corfu-popupinfo--frame nil - "Info popup child frame.") - -(defvar corfu-popupinfo--timer nil - "Corfu info popup auto display timer.") - -(defvar corfu-popupinfo--toggle 'init - "Toggle state.") - -(defvar corfu-popupinfo--function - #'corfu-popupinfo--get-documentation - "Function called to obtain documentation string.") - -(defvar corfu-popupinfo--candidate nil - "Completion candidate for the info popup.") - -(defvar corfu-popupinfo--coordinates nil - "Coordinates of the candidate popup. -The coordinates list has the form (LEFT TOP RIGHT BOTTOM) where -all values are in pixels relative to the origin. See -`frame-edges' for details.") - -(defvar corfu-popupinfo--lock-dir nil - "Locked position direction of the info popup.") - -(defconst corfu-popupinfo--initial-state - (mapcar - (lambda (k) (cons k (symbol-value k))) - '(corfu-popupinfo--candidate - corfu-popupinfo--coordinates - corfu-popupinfo--lock-dir - corfu-popupinfo--toggle - corfu-popupinfo--function)) - "Initial state of `corfu-popupinfo-mode'.") - -(defun corfu-popupinfo--visible-p (&optional frame) - "Return non-nil if FRAME is visible." - (setq frame (or frame corfu-popupinfo--frame)) - (and (frame-live-p frame) (frame-visible-p frame))) - -(defun corfu-popupinfo--get-location (candidate) - "Get source at location of CANDIDATE." - (save-excursion - (let ((old-buffers (buffer-list)) (buffer nil)) - (unwind-protect - (when-let - ((extra (nth 4 completion-in-region--data)) - (fun (plist-get extra :company-location)) - ;; BUG: company-location may throw errors if location is not found - (loc (ignore-errors (funcall fun candidate))) - ((setq buffer - (or (and (bufferp (car loc)) (car loc)) - (get-file-buffer (car loc)) - (let ((inhibit-message t) - (message-log-max nil) - (inhibit-redisplay t) - (enable-dir-local-variables nil) - (enable-local-variables :safe) - (non-essential t) - (delay-mode-hooks t) - (find-file-hook '(global-font-lock-mode-check-buffers))) - (find-file-noselect (car loc) t)))))) - (with-current-buffer buffer - (save-excursion - (without-restriction - (goto-char (point-min)) - (when-let ((pos (cdr loc))) - (if (bufferp (car loc)) - (goto-char pos) - (forward-line (1- pos)))) - (let ((beg (point))) - ;; Support a little bit of scrolling. - (forward-line (* 10 corfu-popupinfo-max-height)) - (when jit-lock-mode - (jit-lock-fontify-now beg (point))) - (let ((res (buffer-substring beg (point)))) - (and (not (string-blank-p res)) res))))))) - (when (and buffer (not (memq buffer old-buffers))) - (kill-buffer buffer)))))) - -(defun corfu-popupinfo--get-documentation (candidate) - "Get the documentation for CANDIDATE." - (when-let ((extra (nth 4 completion-in-region--data)) - (fun (plist-get extra :company-doc-buffer)) - (res (save-excursion - (let ((inhibit-message t) - (message-log-max nil) - (inhibit-redisplay t) - ;; Reduce print length for elisp backend (#249) - (print-level 3) - (print-length (* corfu-popupinfo-max-width - corfu-popupinfo-max-height))) - (funcall fun candidate))))) - (with-current-buffer (or (car-safe res) res) - (setq res (string-trim - (replace-regexp-in-string - "[\n\t ]*\\[back\\][\n\t ]*" "" - (buffer-string)))) - (and (not (string-blank-p res)) res)))) - -(defun corfu-popupinfo--size () - "Return popup size as pair." - (let* ((cw (default-font-width)) - (lh (default-line-height)) - (margin - (* cw (+ (alist-get 'left-margin-width corfu-popupinfo--buffer-parameters) - (alist-get 'right-margin-width corfu-popupinfo--buffer-parameters)))) - (max-height (* lh corfu-popupinfo-max-height)) - (max-width (* cw corfu-popupinfo-max-width))) - (or (when corfu-popupinfo-resize - (with-current-buffer " *corfu-popupinfo*" - (cl-letf* (((window-dedicated-p) nil) - ((window-buffer) (current-buffer)) - (size (window-text-pixel-size - nil (point-min) (point-max) - ;; Use 3*max-height as y-limit, to take more text - ;; into account. - max-width (* 3 max-height)))) - ;; Check that width is not exceeded. Otherwise use full height, - ;; since lines will get wrapped. - (when (<= (car size) max-width) - (cons (+ margin (car size)) - ;; XXX HACK: Ensure that popup has at least a height of 1, - ;; which is the minimum frame height (#261). Maybe we - ;; should ask upstream how smaller frames can be created. - ;; I only managed to create smaller frames by setting - ;; `window-safe-min-height' to 0, which feels problematic. - (min (max (cdr size) lh) max-height)))))) - (cons (+ margin max-width) max-height)))) - -(defun corfu-popupinfo--frame-geometry (frame) - "Return position and size geometric attributes of FRAME. - -The geometry represents the position and size in pixels -in the form of (X Y WIDTH HEIGHT)." - (pcase-let ((`(,x . ,y) (frame-position frame))) - (list x y (frame-pixel-width frame) (frame-pixel-height frame)))) - -(defun corfu-popupinfo--fits-p (size area) - "Check if SIZE fits into the AREA. - -SIZE is in the form (WIDTH . HEIGHT). -AREA is in the form (X Y WIDTH HEIGHT DIR)." - (and (>= (nth 2 area) (car size)) (>= (nth 3 area) (cdr size)))) - -(defun corfu-popupinfo--larger-p (area1 area2) - "Check if AREA1 is larger than AREA2. - -AREA1 and AREA2 are both in the form (X Y WIDTH HEIGHT DIR)." - (>= (* (nth 2 area1) (nth 3 area1)) (* (nth 2 area2) (nth 3 area2)))) - -(defun corfu-popupinfo--area (ps) - "Calculate the display area for the info popup. - -PS is the pixel size of the popup. The calculated area is in the -form (X Y WIDTH HEIGHT DIR)." - (pcase-let* - ((cw (default-font-width)) - (lh (default-line-height)) - (border (alist-get 'internal-border-width corfu--frame-parameters)) - (`(,_pfx ,_pfy ,pfw ,pfh) - (corfu-popupinfo--frame-geometry (frame-parent corfu--frame))) - (`(,cfx ,cfy ,cfw ,cfh) (corfu-popupinfo--frame-geometry corfu--frame)) - ;; Candidates popup below input - (below (>= cfy (+ lh (cadr (window-inside-pixel-edges)) - (window-tab-line-height) - (or (cdr (posn-x-y (posn-at-point (point)))) 0)))) - ;; Popups aligned at top - (top-aligned (or below (< (cdr ps) cfh))) - ;; Left display area - (ahy (if top-aligned - cfy - (max 0 (- (+ cfy cfh) border border (cdr ps))))) - (ahh (if top-aligned - (min (- pfh cfy) (cdr ps)) - (min (- (+ cfy cfh) border border) (cdr ps)))) - (al (list (max 0 (- cfx (car ps) border)) ahy - (min (- cfx border) (car ps)) ahh 'left)) - ;; Right display area - (arx (+ cfx cfw (- border))) - (ar (list arx ahy (min (- pfw arx border border) (car ps)) ahh 'right)) - ;; Vertical display area - (avw (min (car ps) (- pfw cfx border border))) - (av (if below - (list cfx (+ cfy cfh (- border)) avw (min (- pfh cfy cfh border) (cdr ps)) 'vertical) - (let ((h (min (- cfy border border) (cdr ps)))) - (list cfx (max 0 (- cfy h border)) avw h 'vertical))))) - (unless (and corfu-popupinfo--lock-dir - (corfu-popupinfo--fits-p - (cons (* cw corfu-popupinfo-min-width) (* lh corfu-popupinfo-min-height)) - (pcase corfu-popupinfo--lock-dir ('left al) ('right ar) ('vertical av)))) - (setq corfu-popupinfo--lock-dir nil)) - (or - (cl-loop for dir in corfu-popupinfo-direction thereis - (pcase dir - ((or 'force-right (guard (eq corfu-popupinfo--lock-dir 'right))) ar) - ((or 'force-left (guard (eq corfu-popupinfo--lock-dir 'left))) al) - ((or 'force-vertical (guard (eq corfu-popupinfo--lock-dir 'vertical))) av) - ((and 'right (guard (corfu-popupinfo--fits-p ps ar))) ar) - ((and 'left (guard (corfu-popupinfo--fits-p ps al))) al) - ((and 'vertical (guard (corfu-popupinfo--fits-p ps av))) av))) - (let ((ah (if (corfu-popupinfo--larger-p ar al) ar al))) - (if (corfu-popupinfo--larger-p av ah) av ah))))) - -(defun corfu-popupinfo--show (candidate) - "Show the info popup for CANDIDATE." - (when corfu-popupinfo--timer - (cancel-timer corfu-popupinfo--timer) - (setq corfu-popupinfo--timer nil)) - (when (and (corfu-popupinfo--visible-p corfu--frame)) - (let* ((cand-changed - (not (and (corfu-popupinfo--visible-p) - (equal candidate corfu-popupinfo--candidate)))) - (new-coords (frame-edges corfu--frame 'inner-edges)) - (coords-changed (not (equal new-coords corfu-popupinfo--coordinates)))) - (when cand-changed - (if-let ((content (funcall corfu-popupinfo--function candidate))) - (with-current-buffer (corfu--make-buffer " *corfu-popupinfo*") - (with-silent-modifications - (erase-buffer) - (insert content) - (goto-char (point-min))) - (dolist (var corfu-popupinfo--buffer-parameters) - (set (make-local-variable (car var)) (cdr var))) - (when-let ((m (memq 'corfu-default (alist-get 'default face-remapping-alist)))) - (setcar m 'corfu-popupinfo))) - (corfu-popupinfo--hide) - (setq cand-changed nil coords-changed nil))) - (when (or cand-changed coords-changed) - (pcase-let* ((border (alist-get 'internal-border-width corfu--frame-parameters)) - (`(,area-x ,area-y ,area-w ,area-h ,area-d) - (corfu-popupinfo--area - (if cand-changed - (corfu-popupinfo--size) - (cons - (- (frame-pixel-width corfu-popupinfo--frame) border border) - (- (frame-pixel-height corfu-popupinfo--frame) border border))))) - (margin-quirk (not corfu-popupinfo--frame))) - (setq corfu-popupinfo--frame - (corfu--make-frame corfu-popupinfo--frame - area-x area-y area-w area-h - " *corfu-popupinfo*") - corfu-popupinfo--toggle t - corfu-popupinfo--lock-dir area-d - corfu-popupinfo--candidate candidate - corfu-popupinfo--coordinates new-coords) - ;; XXX HACK: Force margin update. For some reason, the call to - ;; `set-window-buffer' in `corfu--make-frame' is not effective the - ;; first time. Why does Emacs have all these quirks? - (when margin-quirk - (set-window-buffer - (frame-root-window corfu-popupinfo--frame) - " *corfu-popupinfo*"))))))) - -(defun corfu-popupinfo--hide () - "Clear the info popup buffer content and hide it." - (corfu--hide-frame corfu-popupinfo--frame)) - -(defun corfu-popupinfo-end (&optional n) - "Scroll text of info popup window to its end. - -If arg N is omitted or nil, scroll to end. If a numerical value, -put point N/10 of the way from the end. If the info popup is not -visible, the other window is moved to beginning or end." - (interactive "P") - (if (corfu-popupinfo--visible-p) - (with-selected-frame corfu-popupinfo--frame - (with-current-buffer " *corfu-popupinfo*" - (with-no-warnings - (end-of-buffer n)))) - (end-of-buffer-other-window n))) - -(defun corfu-popupinfo-beginning (&optional n) - "Scroll text of info popup window to beginning of buffer. - -See `corfu-popupinfo-end' for the argument N." - (interactive "P") - (corfu-popupinfo-end (- 10 (if (numberp n) n 0)))) - -(defun corfu-popupinfo-scroll-up (&optional n) - "Scroll text of info popup window upward N lines. - -If ARG is omitted or nil, scroll upward by a near full screen. -See `scroll-up' for details. If the info popup is not visible, -the other window is scrolled." - (interactive "p") - (if (corfu-popupinfo--visible-p) - (with-selected-frame corfu-popupinfo--frame - (with-current-buffer " *corfu-popupinfo*" - (scroll-up n))) - (scroll-other-window n))) - -(defun corfu-popupinfo-scroll-down (&optional n) - "Scroll text of info popup window down N lines. - -See `corfu-popupinfo-scroll-up' for more details." - (interactive "p") - (corfu-popupinfo-scroll-up (- (or n 1)))) - -(defun corfu-popupinfo--toggle (fun) - "Set documentation getter FUN and toggle popup." - (when (< corfu--index 0) - (corfu-popupinfo--hide) - (user-error "No candidate selected")) - (setq corfu-popupinfo--toggle - (not (and (corfu-popupinfo--visible-p) - (eq corfu-popupinfo--function fun)))) - (if (not corfu-popupinfo--toggle) - (corfu-popupinfo--hide) - (setq corfu-popupinfo--function fun - corfu-popupinfo--candidate nil) - (let ((cand (nth corfu--index corfu--candidates))) - (corfu-popupinfo--show cand) - (unless (corfu-popupinfo--visible-p) - (user-error "No %s available for `%s'" - (car (last (split-string (symbol-name fun) "-+"))) - cand))))) - -(defun corfu-popupinfo-documentation () - "Show or hide documentation in popup. -Behaves like `corfu-popupinfo-toggle'." - (interactive) - (corfu-popupinfo--toggle #'corfu-popupinfo--get-documentation)) - -(defun corfu-popupinfo-location () - "Show or hide location in popup. -Behaves like `corfu-popupinfo-toggle'." - (interactive) - (corfu-popupinfo--toggle #'corfu-popupinfo--get-location)) - -(defun corfu-popupinfo-toggle () - "Toggle the info popup display or hide. - -When using this command to manually hide the info popup, it will -not be displayed until this command is called again, even if -`corfu-popupinfo-delay' is non-nil." - (interactive) - (corfu-popupinfo--toggle corfu-popupinfo--function)) - -;;;###autoload -(define-minor-mode corfu-popupinfo-mode - "Corfu info popup minor mode." - :global t :group 'corfu) - -(cl-defmethod corfu--exhibit :after (&context (corfu-popupinfo-mode (eql t)) &optional _auto) - (when completion-in-region-mode - (setf (alist-get #'corfu-popupinfo-mode minor-mode-overriding-map-alist) - corfu-popupinfo-map) - (when corfu-popupinfo--timer - (cancel-timer corfu-popupinfo--timer) - (setq corfu-popupinfo--timer nil)) - (if (and (>= corfu--index 0) (corfu-popupinfo--visible-p corfu--frame)) - (let ((cand (nth corfu--index corfu--candidates))) - (if-let ((delay (if (consp corfu-popupinfo-delay) - (funcall (if (eq corfu-popupinfo--toggle 'init) #'car #'cdr) - corfu-popupinfo-delay) - corfu-popupinfo-delay)) - (corfu-popupinfo--toggle)) - (if (or (<= delay 0) - (and (equal cand corfu-popupinfo--candidate) - (corfu-popupinfo--visible-p))) - (corfu-popupinfo--show cand) - (when (corfu-popupinfo--visible-p) - (cond - (corfu-popupinfo-hide - (corfu-popupinfo--hide)) - (corfu-popupinfo--candidate - (corfu-popupinfo--show corfu-popupinfo--candidate)))) - (setq corfu-popupinfo--timer - (run-at-time delay nil #'corfu-popupinfo--show cand))) - (unless (equal cand corfu-popupinfo--candidate) - (corfu-popupinfo--hide)))) - (corfu-popupinfo--hide)))) - -(cl-defmethod corfu--teardown :before (_buf &context (corfu-popupinfo-mode (eql t))) - (corfu-popupinfo--hide) - (cl-loop for (k . v) in corfu-popupinfo--initial-state do (set k v)) - (cl-callf2 assq-delete-all #'corfu-popupinfo-mode minor-mode-overriding-map-alist)) - -;; Emacs 28: Do not show Corfu commands with M-X -(dolist (sym '(corfu-popupinfo-scroll-down corfu-popupinfo-scroll-up - corfu-popupinfo-documentation corfu-popupinfo-location - corfu-popupinfo-beginning corfu-popupinfo-end - corfu-popupinfo-toggle)) - (put sym 'completion-predicate #'ignore)) - -(provide 'corfu-popupinfo) -;;; corfu-popupinfo.el ends here diff --git a/emacs/elpa/corfu-20240413.927/corfu-quick.el b/emacs/elpa/corfu-20240413.927/corfu-quick.el @@ -1,154 +0,0 @@ -;;; corfu-quick.el --- Quick keys for Corfu -*- lexical-binding: t -*- - -;; Copyright (C) 2022-2024 Free Software Foundation, Inc. - -;; Author: Luis Henriquez-Perez <luis@luishp.xyz>, Daniel Mendler <mail@daniel-mendler.de> -;; Maintainer: Daniel Mendler <mail@daniel-mendler.de> -;; Created: 2022 -;; Version: 1.3 -;; Package-Requires: ((emacs "27.1") (compat "29.1.4.4") (corfu "1.3")) -;; Homepage: https://github.com/minad/corfu - -;; This file is part of GNU Emacs. - -;; 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 <https://www.gnu.org/licenses/>. - -;;; Commentary: - -;; This package is a Corfu extension, which prefixes candidates with -;; quick keys. Typing these quick keys allows you to select the -;; candidate in front of them. This is designed to be a faster -;; alternative to selecting a candidate with `corfu-next' and -;; `corfu-previous'. -;; (keymap-set corfu-map "M-q" #'corfu-quick-complete) -;; (keymap-set corfu-map "C-q" #'corfu-quick-insert) - -;;; Code: - -(require 'corfu) -(eval-when-compile - (require 'cl-lib)) - -(defcustom corfu-quick1 "asdfgh" - "First level quick keys." - :type 'string - :group 'corfu) - -(defcustom corfu-quick2 "jkluionm" - "Second level quick keys." - :type 'string - :group 'corfu) - -(defface corfu-quick1 - '((((class color) (min-colors 88) (background dark)) - :background "#0050af" :foreground "white" :inherit bold) - (((class color) (min-colors 88) (background light)) - :background "#7feaff" :foreground "black" :inherit bold) - (t :background "blue" :foreground "white" :inherit bold)) - "Face used for the first quick key." - :group 'corfu-faces) - -(defface corfu-quick2 - '((((class color) (min-colors 88) (background dark)) - :background "#7f1f7f" :foreground "white" :inherit bold) - (((class color) (min-colors 88) (background light)) - :background "#ffaaff" :foreground "black" :inherit bold) - (t :background "magenta" :foreground "white" :inherit bold)) - "Face used for the second quick key." - :group 'corfu-faces) - -(defun corfu-quick--keys (two idx) ;; See vertico-quick--keys - "Format quick keys prefix. -IDX is the current candidate index. -TWO is non-nil if two keys should be displayed." - (let ((fst (length corfu-quick1)) - (snd (length corfu-quick2))) - (if (>= idx fst) - (let ((first (elt corfu-quick2 (mod (/ (- idx fst) fst) snd))) - (second (elt corfu-quick1 (mod (- idx fst) fst)))) - (cond - ((eq first two) - (list - (concat " " (propertize (char-to-string second) 'face 'corfu-quick1)) - (cons second (+ corfu--scroll idx)))) - (two - (list " ")) - (t - (list - (concat (propertize (char-to-string first) 'face 'corfu-quick1) - (propertize (char-to-string second) 'face 'corfu-quick2)) - (cons first (list first)))))) - (let ((first (elt corfu-quick1 (mod idx fst)))) - (if two - (list " ") - (list - (concat (propertize (char-to-string first) 'face 'corfu-quick1) " ") - (cons first (+ corfu--scroll idx)))))))) - -(defun corfu-quick--read (&optional first) - "Read quick key given FIRST pressed key." - (cl-letf* ((list nil) - (space1 (propertize " " 'display - `(space :width - (+ 0.5 (,(alist-get - 'child-frame-border-width - corfu--frame-parameters)))))) - (space2 #(" " 0 1 (display (space :width 0.5)))) - (orig (symbol-function #'corfu--affixate)) - ((symbol-function #'corfu--affixate) - (lambda (cands) - (setq cands (cdr (funcall orig cands))) - (cl-loop for cand in cands for index from 0 do - (pcase-let ((`(,keys . ,events) (corfu-quick--keys first index))) - (setq list (nconc events list)) - (setf (cadr cand) (concat space1 (propertize " " 'display keys) space2)))) - (cons t cands))) - ;; Increase minimum width to avoid odd jumping - (corfu-min-width (+ 3 corfu-min-width))) - (corfu--candidates-popup - (posn-at-point (+ (car completion-in-region--data) (length corfu--base)))) - (alist-get (read-key) list))) - -;;;###autoload -(defun corfu-quick-jump () - "Jump to candidate using quick keys." - (interactive) - (when (fboundp 'corfu-echo--cancel) - (corfu-echo--cancel)) - (if (= corfu--total 0) - (and (message "No match") nil) - (let ((idx (corfu-quick--read))) - (when (consp idx) (setq idx (corfu-quick--read (car idx)))) - (when idx (setq corfu--index idx))))) - -;;;###autoload -(defun corfu-quick-insert () - "Insert candidate using quick keys." - (interactive) - (when (corfu-quick-jump) - (corfu-insert))) - -;;;###autoload -(defun corfu-quick-complete () - "Complete candidate using quick keys." - (interactive) - (when (corfu-quick-jump) - (corfu-complete))) - -;; Emacs 28: Do not show Corfu commands in M-X -(dolist (sym '(corfu-quick-jump corfu-quick-insert corfu-quick-complete)) - (put sym 'completion-predicate #'ignore)) - -(provide 'corfu-quick) -;;; corfu-quick.el ends here diff --git a/emacs/elpa/corfu-20240413.927/corfu.el b/emacs/elpa/corfu-20240413.927/corfu.el @@ -1,1395 +0,0 @@ -;;; corfu.el --- COmpletion in Region FUnction -*- lexical-binding: t -*- - -;; Copyright (C) 2021-2024 Free Software Foundation, Inc. - -;; Author: Daniel Mendler <mail@daniel-mendler.de> -;; Maintainer: Daniel Mendler <mail@daniel-mendler.de> -;; Created: 2021 -;; Version: 1.3 -;; Package-Requires: ((emacs "27.1") (compat "29.1.4.4")) -;; Homepage: https://github.com/minad/corfu -;; Keywords: abbrev, convenience, matching, completion, text - -;; This file is part of GNU Emacs. - -;; 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 <https://www.gnu.org/licenses/>. - -;;; Commentary: - -;; Corfu enhances in-buffer completion with a small completion popup. -;; The current candidates are shown in a popup below or above the -;; point. The candidates can be selected by moving up and down. -;; Corfu is the minimalistic in-buffer completion counterpart of the -;; Vertico minibuffer UI. - -;;; Code: - -(require 'compat) -(eval-when-compile - (require 'cl-lib) - (require 'subr-x)) - -(defgroup corfu nil - "COmpletion in Region FUnction." - :link '(info-link :tag "Info Manual" "(corfu)") - :link '(url-link :tag "Homepage" "https://github.com/minad/corfu") - :link '(emacs-library-link :tag "Library Source" "corfu.el") - :group 'convenience - :group 'tools - :group 'matching - :prefix "corfu-") - -(defcustom corfu-count 10 - "Maximal number of candidates to show." - :type 'natnum) - -(defcustom corfu-scroll-margin 2 - "Number of lines at the top and bottom when scrolling. -The value should lie between 0 and corfu-count/2." - :type 'natnum) - -(defcustom corfu-min-width 15 - "Popup minimum width in characters." - :type 'natnum) - -(defcustom corfu-max-width 100 - "Popup maximum width in characters." - :type 'natnum) - -(defcustom corfu-cycle nil - "Enable cycling for `corfu-next' and `corfu-previous'." - :type 'boolean) - -(defcustom corfu-on-exact-match 'insert - "Configure how a single exact match should be handled. -- nil: No special handling, continue completion. -- insert: Insert candidate, quit and call the `:exit-function'. -- quit: Quit completion without further action. -- show: Initiate completion even for a single match only." - :type '(choice (const insert) (const show) (const quit) (const nil))) - -(defcustom corfu-continue-commands - ;; nil is undefined command - '(nil ignore universal-argument universal-argument-more digit-argument - "\\`corfu-" "\\`scroll-other-window") - "Continue Corfu completion after executing these commands. -The list can container either command symbols or regular expressions." - :type '(repeat (choice regexp symbol))) - -(defcustom corfu-preview-current 'insert - "Preview currently selected candidate. -If the variable has the value `insert', the candidate is automatically -inserted on further input." - :type '(choice boolean (const insert))) - -(defcustom corfu-preselect 'valid - "Configure if the prompt or first candidate is preselected. -- prompt: Always select the prompt. -- first: Always select the first candidate. -- valid: Only select the prompt if valid and not equal to the first candidate. -- directory: Like first, but select the prompt if it is a directory." - :type '(choice (const prompt) (const valid) (const first) (const directory))) - -(defcustom corfu-separator ?\s - "Component separator character. -The character used for separating components in the input. The presence -of this separator character will inhibit quitting at completion -boundaries, so that any further characters can be entered. To enter the -first separator character, call `corfu-insert-separator' (bound to M-SPC -by default). Useful for multi-component completion styles such as -Orderless." - :type 'character) - -(defcustom corfu-quit-at-boundary 'separator - "Automatically quit at completion boundary. -nil: Never quit at completion boundary. -t: Always quit at completion boundary. -separator: Quit at boundary if no `corfu-separator' has been inserted." - :type '(choice boolean (const separator))) - -(defcustom corfu-quit-no-match 'separator - "Automatically quit if no matching candidate is found. -When staying alive even if there is no match a warning message is -shown in the popup. -nil: Stay alive even if there is no match. -t: Quit if there is no match. -separator: Only stay alive if there is no match and -`corfu-separator' has been inserted." - :type '(choice boolean (const separator))) - -(defcustom corfu-left-margin-width 0.5 - "Width of the left margin in units of the character width." - :type 'float) - -(defcustom corfu-right-margin-width 0.5 - "Width of the right margin in units of the character width." - :type 'float) - -(defcustom corfu-bar-width 0.2 - "Width of the bar in units of the character width." - :type 'float) - -(defcustom corfu-margin-formatters nil - "Registry for margin formatter functions. -Each function of the list is called with the completion metadata as -argument until an appropriate formatter is found. The function should -return a formatter function, which takes the candidate string and must -return a string, possibly an icon." - :type 'hook) - -(defcustom corfu-sort-function #'corfu-sort-length-alpha - "Default sorting function. -This function is used if the completion table does not specify a -`display-sort-function'." - :type `(choice - (const :tag "No sorting" nil) - (const :tag "By length and alpha" ,#'corfu-sort-length-alpha) - (function :tag "Custom function"))) - -(defcustom corfu-sort-override-function nil - "Override sort function which overrides the `display-sort-function'. -This function is used even if a completion table specifies its -own sort function." - :type '(choice (const nil) function)) - -(defcustom corfu-auto-prefix 3 - "Minimum length of prefix for auto completion. -The completion backend can override this with -:company-prefix-length. It is *not recommended* to use a small -prefix length (below 2), since this will create high load for -Emacs. See also `corfu-auto-delay'." - :type 'natnum) - -(defcustom corfu-auto-delay 0.2 - "Delay for auto completion. -It is *not recommended* to use a short delay or even 0, since -this will create high load for Emacs, in particular if executing -the completion backend is costly." - :type 'float) - -(defcustom corfu-auto-commands - '("self-insert-command\\'" "delete-backward-char\\'" "\\`backward-delete-char" - c-electric-colon c-electric-lt-gt c-electric-slash c-scope-operator) - "Commands which initiate auto completion. -The list can container either command symbols or regular expressions." - :type '(repeat (choice regexp symbol))) - -(defcustom corfu-auto nil - "Enable auto completion. -See also the settings `corfu-auto-delay', `corfu-auto-prefix' and -`corfu-auto-commands'." - :type 'boolean) - -(defgroup corfu-faces nil - "Faces used by Corfu." - :group 'corfu - :group 'faces) - -(defface corfu-default - '((((class color) (min-colors 88) (background dark)) :background "#191a1b") - (((class color) (min-colors 88) (background light)) :background "#f0f0f0") - (t :background "gray")) - "Default face, foreground and background colors used for the popup.") - -(defface corfu-current - '((((class color) (min-colors 88) (background dark)) - :background "#00415e" :foreground "white") - (((class color) (min-colors 88) (background light)) - :background "#c0efff" :foreground "black") - (t :background "blue" :foreground "white")) - "Face used to highlight the currently selected candidate.") - -(defface corfu-bar - '((((class color) (min-colors 88) (background dark)) :background "#a8a8a8") - (((class color) (min-colors 88) (background light)) :background "#505050") - (t :background "gray")) - "The background color is used for the scrollbar indicator.") - -(defface corfu-border - '((((class color) (min-colors 88) (background dark)) :background "#323232") - (((class color) (min-colors 88) (background light)) :background "#d7d7d7") - (t :background "gray")) - "The background color used for the thin border.") - -(defface corfu-annotations - '((t :inherit completions-annotations)) - "Face used for annotations.") - -(defface corfu-deprecated - '((t :inherit shadow :strike-through t)) - "Face used for deprecated candidates.") - -(defvar-keymap corfu-mode-map - :doc "Keymap used when `corfu-mode' is active.") - -(defvar-keymap corfu-map - :doc "Keymap used when popup is shown." - "<remap> <move-beginning-of-line>" #'corfu-prompt-beginning - "<remap> <move-end-of-line>" #'corfu-prompt-end - "<remap> <beginning-of-buffer>" #'corfu-first - "<remap> <end-of-buffer>" #'corfu-last - "<remap> <scroll-down-command>" #'corfu-scroll-down - "<remap> <scroll-up-command>" #'corfu-scroll-up - "<remap> <next-line>" #'corfu-next - "<remap> <previous-line>" #'corfu-previous - "<remap> <completion-at-point>" #'corfu-complete - "<remap> <keyboard-escape-quit>" #'corfu-reset - "<down>" #'corfu-next - "<up>" #'corfu-previous - ;; XXX C-a is bound because of Eshell. - ;; Ideally Eshell would remap move-beginning-of-line. - "C-a" #'corfu-prompt-beginning - ;; XXX [tab] is bound because of org-mode and orgtbl-mode. - ;; The binding should be removed from org-mode-map. - "<tab>" #'corfu-complete - "M-n" #'corfu-next - "M-p" #'corfu-previous - "C-g" #'corfu-quit - "RET" #'corfu-insert - "TAB" #'corfu-complete - "M-TAB" #'corfu-expand - "M-g" 'corfu-info-location - "M-h" 'corfu-info-documentation - "M-SPC" #'corfu-insert-separator) - -(defvar corfu--auto-timer (timer-create) - "Auto completion timer.") - -(defvar corfu--candidates nil - "List of candidates.") - -(defvar corfu--metadata nil - "Completion metadata.") - -(defvar corfu--base "" - "Base string, which is concatenated with the candidate.") - -(defvar corfu--total 0 - "Length of the candidate list `corfu--candidates'.") - -(defvar corfu--hilit #'identity - "Lazy candidate highlighting function.") - -(defvar corfu--index -1 - "Index of current candidate or negative for prompt selection.") - -(defvar corfu--preselect -1 - "Index of preselected candidate, negative for prompt selection.") - -(defvar corfu--scroll 0 - "Scroll position.") - -(defvar corfu--input nil - "Cons of last prompt contents and point.") - -(defvar corfu--preview-ov nil - "Current candidate overlay.") - -(defvar corfu--change-group nil - "Undo change group.") - -(defvar corfu--frame nil - "Popup frame.") - -(defconst corfu--initial-state - (mapcar - (lambda (k) (cons k (symbol-value k))) - '(corfu--base - corfu--candidates - corfu--hilit - corfu--index - corfu--preselect - corfu--scroll - corfu--input - corfu--total - corfu--preview-ov - corfu--change-group - corfu--metadata)) - "Initial Corfu state.") - -(defvar corfu--frame-parameters - '((no-accept-focus . t) - (no-focus-on-map . t) - (min-width . t) - (min-height . t) - (border-width . 0) - (outer-border-width . 0) - (internal-border-width . 1) - (child-frame-border-width . 1) - (left-fringe . 0) - (right-fringe . 0) - (vertical-scroll-bars . nil) - (horizontal-scroll-bars . nil) - (menu-bar-lines . 0) - (tool-bar-lines . 0) - (tab-bar-lines . 0) - (no-other-frame . t) - (unsplittable . t) - (undecorated . t) - (cursor-type . nil) - (no-special-glyphs . t) - (desktop-dont-save . t)) - "Default child frame parameters.") - -(defvar corfu--buffer-parameters - '((mode-line-format . nil) - (header-line-format . nil) - (tab-line-format . nil) - (tab-bar-format . nil) ;; Emacs 28 tab-bar-format - (frame-title-format . "") - (truncate-lines . t) - (cursor-in-non-selected-windows . nil) - (cursor-type . nil) - (show-trailing-whitespace . nil) - (display-line-numbers . nil) - (left-fringe-width . nil) - (right-fringe-width . nil) - (left-margin-width . 0) - (right-margin-width . 0) - (fringes-outside-margins . 0) - (fringe-indicator-alist . nil) - (indicate-empty-lines . nil) - (indicate-buffer-boundaries . nil) - (buffer-read-only . t)) - "Default child frame buffer parameters.") - -(defvar corfu--mouse-ignore-map - (let ((map (make-sparse-keymap))) - (dotimes (i 7) - (dolist (k '(mouse down-mouse drag-mouse double-mouse triple-mouse)) - (keymap-set map (format "<%s-%s>" k (1+ i)) #'ignore))) - map) - "Ignore all mouse clicks.") - -(defun corfu--replace (beg end str) - "Replace range between BEG and END with STR." - (unless (equal str (buffer-substring-no-properties beg end)) - ;; bug#55205: completion--replace removed properties as an unwanted - ;; side-effect. We also don't want to leave text properties. - (completion--replace beg end (substring-no-properties str)))) - -(defun corfu--capf-wrapper (fun &optional prefix) - "Wrapper for `completion-at-point' FUN. -The wrapper determines if the Capf is applicable at the current -position and performs sanity checking on the returned result. -For non-exclusive Capfs wrapper additionally checks if the -current input can be completed successfully. PREFIX is a prefix -length override, set to t for manual completion." - (pcase (funcall fun) - ((and res `(,beg ,end ,table . ,plist)) - (and (integer-or-marker-p beg) ;; Valid Capf result - (<= beg (point) end) ;; Sanity checking - ;; When auto completing, check the prefix length! - (let ((len (or prefix - (plist-get plist :company-prefix-length) - (- (point) beg)))) - (or (eq len t) (>= len corfu-auto-prefix))) - ;; For non-exclusive Capfs, check for valid completion. - (or (not (eq 'no (plist-get plist :exclusive))) - (let* ((str (buffer-substring-no-properties beg end)) - (pt (- (point) beg)) - (pred (plist-get plist :predicate)) - (md (completion-metadata (substring str 0 pt) table pred))) - ;; We use `completion-try-completion' to check if there are - ;; completions. The upstream `completion--capf-wrapper' uses - ;; `try-completion' which is incorrect since it only checks for - ;; prefix completions. - (completion-try-completion str table pred pt md))) - (cons fun res))))) - -(defun corfu--make-buffer (name) - "Create buffer with NAME." - (let ((fr face-remapping-alist) - (ls line-spacing) - (buffer (get-buffer-create name))) - (with-current-buffer buffer - ;;; XXX HACK install mouse ignore map - (use-local-map corfu--mouse-ignore-map) - (dolist (var corfu--buffer-parameters) - (set (make-local-variable (car var)) (cdr var))) - (setq-local face-remapping-alist (copy-tree fr) - line-spacing ls) - (cl-pushnew 'corfu-default (alist-get 'default face-remapping-alist)) - buffer))) - -(defvar x-gtk-resize-child-frames) ;; Not present on non-gtk builds -(defvar corfu--gtk-resize-child-frames - (let ((case-fold-search t)) - ;; XXX HACK to fix resizing on gtk3/gnome taken from posframe.el - ;; More information: - ;; * https://github.com/minad/corfu/issues/17 - ;; * https://gitlab.gnome.org/GNOME/mutter/-/issues/840 - ;; * https://lists.gnu.org/archive/html/emacs-devel/2020-02/msg00001.html - (and (string-match-p "gtk3" system-configuration-features) - (string-match-p "gnome\\|cinnamon" - (or (getenv "XDG_CURRENT_DESKTOP") - (getenv "DESKTOP_SESSION") "")) - 'resize-mode))) - -;; Function adapted from posframe.el by tumashu -(defun corfu--make-frame (frame x y width height buffer) - "Show BUFFER in child frame at X/Y with WIDTH/HEIGHT. -FRAME is the existing frame." - (when-let (((frame-live-p frame)) - (timer (frame-parameter frame 'corfu--hide-timer))) - (cancel-timer timer) - (set-frame-parameter frame 'corfu--hide-timer nil)) - (let* ((window-min-height 1) - (window-min-width 1) - (inhibit-redisplay t) - (x-gtk-resize-child-frames corfu--gtk-resize-child-frames) - (before-make-frame-hook) - (after-make-frame-functions) - (parent (window-frame))) - (unless (and (frame-live-p frame) - (eq (frame-parent frame) - (and (not (bound-and-true-p exwm--connection)) parent)) - ;; If there is more than one window, `frame-root-window' may - ;; return nil. Recreate the frame in this case. - (window-live-p (frame-root-window frame))) - (when frame (delete-frame frame)) - (setq frame (make-frame - `((parent-frame . ,parent) - (minibuffer . ,(minibuffer-window parent)) - (width . 0) (height . 0) (visibility . nil) - ,@corfu--frame-parameters)))) - ;; XXX HACK Setting the same frame-parameter/face-background is not a nop. - ;; Check before applying the setting. Without the check, the frame flickers - ;; on Mac. We have to apply the face background before adjusting the frame - ;; parameter, otherwise the border is not updated. - (let ((new (face-attribute 'corfu-border :background nil 'default))) - (unless (equal (face-attribute 'internal-border :background frame 'default) new) - (set-face-background 'internal-border new frame)) - ;; XXX The Emacs Mac Port does not support `internal-border', we also have - ;; to set `child-frame-border'. - (unless (or (not (facep 'child-frame-border)) - (equal (face-attribute 'child-frame-border :background frame 'default) new)) - (set-face-background 'child-frame-border new frame))) - ;; Reset frame parameters if they changed. For example `tool-bar-mode' - ;; overrides the parameter `tool-bar-lines' for every frame, including child - ;; frames. The child frame API is a pleasure to work with. It is full of - ;; lovely surprises. - (let* ((is (frame-parameters frame)) - (should `((background-color - . ,(face-attribute 'corfu-default :background nil 'default)) - (font . ,(frame-parameter parent 'font)) - ,@corfu--frame-parameters)) - (diff (cl-loop for p in should for (k . v) = p - unless (equal (alist-get k is) v) collect p))) - (when diff (modify-frame-parameters frame diff))) - (let ((win (frame-root-window frame))) - (unless (eq (window-buffer win) buffer) - (set-window-buffer win buffer)) - ;; Disallow selection of root window (gh:minad/corfu#63) - (set-window-parameter win 'no-delete-other-windows t) - (set-window-parameter win 'no-other-window t) - ;; Mark window as dedicated to prevent frame reuse (gh:minad/corfu#60) - (set-window-dedicated-p win t)) - (redirect-frame-focus frame parent) - (set-frame-size frame width height t) - (pcase-let ((`(,px . ,py) (frame-position frame))) - (unless (and (= x px) (= y py)) - (set-frame-position frame x y)))) - (make-frame-visible frame) - ;; Unparent child frame if EXWM is used, otherwise EXWM buffers are drawn on - ;; top of the Corfu child frame. - (when (and (bound-and-true-p exwm--connection) (frame-parent frame)) - (set-frame-parameter frame 'parent-frame nil)) - frame) - -(defun corfu--hide-frame-deferred (frame) - "Deferred hiding of child FRAME." - (when (and (frame-live-p frame) (frame-visible-p frame)) - (set-frame-parameter frame 'corfu--hide-timer nil) - (make-frame-invisible frame) - (with-current-buffer (window-buffer (frame-root-window frame)) - (with-silent-modifications - (erase-buffer))))) - -(defun corfu--hide-frame (frame) - "Hide child FRAME." - (when (and (frame-live-p frame) (frame-visible-p frame) - (not (frame-parameter frame 'corfu--hide-timer))) - (set-frame-parameter frame 'corfu--hide-timer - (run-at-time 0 nil #'corfu--hide-frame-deferred frame)))) - -(defun corfu--move-to-front (elem list) - "Move ELEM to front of LIST." - ;; In contrast to Vertico, this function handles duplicates. See also the - ;; special deduplication function `corfu--delete-dups' based on - ;; `equal-including-properties' - (nconc (cl-loop for x in list if (equal x elem) collect x) - (delete elem list))) - -(defun corfu--filter-completions (&rest args) - "Compute all completions for ARGS with lazy highlighting." - (dlet ((completion-lazy-hilit t) (completion-lazy-hilit-fn nil)) - (if (eval-when-compile (>= emacs-major-version 30)) - (cons (apply #'completion-all-completions args) completion-lazy-hilit-fn) - (cl-letf* ((orig-pcm (symbol-function #'completion-pcm--hilit-commonality)) - (orig-flex (symbol-function #'completion-flex-all-completions)) - ((symbol-function #'completion-flex-all-completions) - (lambda (&rest args) - ;; Unfortunately for flex we have to undo the lazy highlighting, since flex uses - ;; the completion-score for sorting, which is applied during highlighting. - (cl-letf (((symbol-function #'completion-pcm--hilit-commonality) orig-pcm)) - (apply orig-flex args)))) - ((symbol-function #'completion-pcm--hilit-commonality) - (lambda (pattern cands) - (setq completion-lazy-hilit-fn - (lambda (x) - ;; `completion-pcm--hilit-commonality' sometimes throws an internal error - ;; for example when entering "/sudo:://u". - (condition-case nil - (car (completion-pcm--hilit-commonality pattern (list x))) - (t x)))) - cands)) - ((symbol-function #'completion-hilit-commonality) - (lambda (cands prefix &optional base) - (setq completion-lazy-hilit-fn - (lambda (x) (car (completion-hilit-commonality (list x) prefix base)))) - (and cands (nconc cands base))))) - (cons (apply #'completion-all-completions args) completion-lazy-hilit-fn))))) - -(defsubst corfu--length-string< (x y) - "Sorting predicate which compares X and Y first by length then by `string<'." - (or (< (length x) (length y)) (and (= (length x) (length y)) (string< x y)))) - -(defmacro corfu--partition! (list form) - "Evaluate FORM for every element and partition LIST." - (cl-with-gensyms (head1 head2 tail1 tail2) - `(let* ((,head1 (cons nil nil)) - (,head2 (cons nil nil)) - (,tail1 ,head1) - (,tail2 ,head2)) - (while ,list - (if (let ((it (car ,list))) ,form) - (progn - (setcdr ,tail1 ,list) - (pop ,tail1)) - (setcdr ,tail2 ,list) - (pop ,tail2)) - (pop ,list)) - (setcdr ,tail1 (cdr ,head2)) - (setcdr ,tail2 nil) - (setq ,list (cdr ,head1))))) - -(defun corfu--move-prefix-candidates-to-front (field cands) - "Move CANDS which match prefix of FIELD to the beginning." - (let* ((word (substring field 0 - (seq-position field corfu-separator))) - (len (length word))) - (corfu--partition! - cands - (and (>= (length it) len) - (eq t (compare-strings word 0 len it 0 len - completion-ignore-case)))))) - -(defun corfu--delete-dups (list) - "Delete `equal-including-properties' consecutive duplicates from LIST." - (let ((beg list)) - (while (cdr beg) - (let ((end (cdr beg))) - (while (equal (car beg) (car end)) (pop end)) - ;; The deduplication is quadratic in the number of duplicates. We can - ;; avoid the quadratic complexity with a hash table which takes - ;; properties into account (available since Emacs 28). - (while (not (eq beg end)) - (let ((dup beg)) - (while (not (eq (cdr dup) end)) - ;; bug#6581: `equal-including-properties' uses `eq' to compare - ;; properties until 29.1. Approximate by comparing - ;; `text-properties-at' position 0. - (if (if (eval-when-compile (< emacs-major-version 29)) - (equal (text-properties-at 0 (car beg)) - (text-properties-at 0 (cadr dup))) - (equal-including-properties (car beg) (cadr dup))) - (setcdr dup (cddr dup)) - (pop dup)))) - (pop beg))))) - list) - -(defun corfu--sort-function () - "Return the sorting function." - (or corfu-sort-override-function - (corfu--metadata-get 'display-sort-function) - corfu-sort-function)) - -(defun corfu--recompute (str pt table pred) - "Recompute state from STR, PT, TABLE and PRED." - (pcase-let* ((before (substring str 0 pt)) - (after (substring str pt)) - (corfu--metadata (completion-metadata before table pred)) - ;; bug#47678: `completion-boundaries' fails for `partial-completion' - ;; if the cursor is moved between the slashes of "~//". - ;; See also vertico.el which has the same issue. - (bounds (condition-case nil - (completion-boundaries before table pred after) - (t (cons 0 (length after))))) - (field (substring str (car bounds) (+ pt (cdr bounds)))) - (completing-file (eq (corfu--metadata-get 'category) 'file)) - (`(,all . ,hl) (corfu--filter-completions str table pred pt corfu--metadata)) - (base (or (when-let ((z (last all))) (prog1 (cdr z) (setcdr z nil))) 0)) - (corfu--base (substring str 0 base)) - (pre nil)) - ;; Filter the ignored file extensions. We cannot use modified predicate for - ;; this filtering, since this breaks the special casing in the - ;; `completion-file-name-table' for `file-exists-p' and `file-directory-p'. - (when completing-file (setq all (completion-pcm--filename-try-filter all))) - ;; Sort using the `display-sort-function' or the Corfu sort functions, and - ;; delete duplicates with respect to `equal-including-properties'. This is - ;; a deviation from the Vertico completion UI with more aggressive - ;; deduplication, where candidates are compared with `equal'. Corfu - ;; preserves candidates which differ in their text properties. Corfu tries - ;; to preserve text properties as much as possible, when calling the - ;; `:exit-function' to help Capfs with candidate disambiguation. This - ;; matters in particular for Lsp backends, which produce duplicates for - ;; overloaded methods. - (setq all (corfu--delete-dups (funcall (or (corfu--sort-function) #'identity) all)) - all (corfu--move-prefix-candidates-to-front field all)) - (when (and completing-file (not (string-suffix-p "/" field))) - (setq all (corfu--move-to-front (concat field "/") all))) - (setq all (corfu--move-to-front field all) - pre (if (or (eq corfu-preselect 'prompt) (not all) - (and completing-file (eq corfu-preselect 'directory) - (= (length corfu--base) (length str)) - (test-completion str table pred)) - (and (eq corfu-preselect 'valid) - (not (equal field (car all))) - (not (and completing-file (equal (concat field "/") (car all)))) - (test-completion str table pred))) - -1 0)) - `((corfu--base . ,corfu--base) - (corfu--metadata . ,corfu--metadata) - (corfu--candidates . ,all) - (corfu--total . ,(length all)) - (corfu--hilit . ,(or hl #'identity)) - (corfu--preselect . ,pre) - (corfu--index . ,(or (and (>= corfu--index 0) (/= corfu--index corfu--preselect) - (seq-position all (nth corfu--index corfu--candidates))) - pre))))) - -(defun corfu--update (&optional interruptible) - "Update state, optionally INTERRUPTIBLE." - (pcase-let* ((`(,beg ,end ,table ,pred . ,_) completion-in-region--data) - (pt (- (point) beg)) - (str (buffer-substring-no-properties beg end)) - (input (cons str pt))) - (unless (equal corfu--input input) - ;; Redisplay such that the input is immediately shown before the expensive - ;; candidate recomputation (gh:minad/corfu#48). See also corresponding - ;; issue gh:minad/vertico#89. - (when interruptible (redisplay)) - ;; Bind non-essential=t to prevent Tramp from opening new connections, - ;; without the user explicitly requesting it via M-TAB. - (pcase (let ((non-essential t)) - ;; XXX Guard against errors during candidate generation. - ;; bug#61274: `dabbrev-capf' signals errors. - (condition-case err - (if interruptible - (while-no-input (corfu--recompute str pt table pred)) - (corfu--recompute str pt table pred)) - (error - (message "Corfu completion error: %s" (error-message-string err)) - t))) - ('nil (keyboard-quit)) - ((and state (pred consp)) - (setq corfu--input input) - (dolist (s state) (set (car s) (cdr s)))))) - input)) - -(defun corfu--match-symbol-p (pattern sym) - "Return non-nil if SYM is matching an element of the PATTERN list." - (cl-loop with case-fold-search = nil - for x in (and (symbolp sym) pattern) - thereis (if (symbolp x) - (eq sym x) - (string-match-p x (symbol-name sym))))) - -(defun corfu--metadata-get (prop) - "Return PROP from completion metadata." - ;; Note: Do not use `completion-metadata-get' in order to avoid Marginalia. - ;; The Marginalia annotators are too heavy for the Corfu popup! - (cdr (assq prop corfu--metadata))) - -(defun corfu--format-candidates (cands) - "Format annotated CANDS." - (setq cands - (cl-loop for c in cands collect - (cl-loop for s in c collect - (replace-regexp-in-string "[ \t]*\n[ \t]*" " " s)))) - (let* ((cw (cl-loop for x in cands maximize (string-width (car x)))) - (pw (cl-loop for x in cands maximize (string-width (cadr x)))) - (sw (cl-loop for x in cands maximize (string-width (caddr x)))) - (width (+ pw cw sw)) - ;; -4 because of margins and some additional safety - (max-width (min corfu-max-width (- (frame-width) 4)))) - (when (> width max-width) - (setq sw (max 0 (- max-width pw cw)) - width (+ pw cw sw))) - (when (< width corfu-min-width) - (setq cw (+ cw (- corfu-min-width width)) - width corfu-min-width)) - (setq width (min width max-width)) - (list pw width - (cl-loop for (cand prefix suffix) in cands collect - (truncate-string-to-width - (concat - prefix (make-string (max 0 (- pw (string-width prefix))) ?\s) - cand - (when (/= sw 0) - (make-string (+ (max 0 (- cw (string-width cand))) - (max 0 (- sw (string-width suffix)))) - ?\s)) - suffix) - width))))) - -(defun corfu--compute-scroll () - "Compute new scroll position." - (let ((off (max (min corfu-scroll-margin (/ corfu-count 2)) 0)) - (corr (if (= corfu-scroll-margin (/ corfu-count 2)) (1- (mod corfu-count 2)) 0))) - (setq corfu--scroll (min (max 0 (- corfu--total corfu-count)) - (max 0 (+ corfu--index off 1 (- corfu-count)) - (min (- corfu--index off corr) corfu--scroll)))))) - -(defun corfu--candidates-popup (pos) - "Show candidates popup at POS." - (corfu--compute-scroll) - (pcase-let* ((last (min (+ corfu--scroll corfu-count) corfu--total)) - (bar (ceiling (* corfu-count corfu-count) corfu--total)) - (lo (min (- corfu-count bar 1) (floor (* corfu-count corfu--scroll) corfu--total))) - (`(,mf . ,acands) (corfu--affixate - (cl-loop repeat corfu-count - for c in (nthcdr corfu--scroll corfu--candidates) - collect (funcall corfu--hilit (substring c))))) - (`(,pw ,width ,fcands) (corfu--format-candidates acands)) - ;; Disable the left margin if a margin formatter is active. - (corfu-left-margin-width (if mf 0 corfu-left-margin-width))) - ;; Nonlinearity at the end and the beginning - (when (/= corfu--scroll 0) - (setq lo (max 1 lo))) - (when (/= last corfu--total) - (setq lo (min (- corfu-count bar 2) lo))) - (corfu--popup-show pos pw width fcands (- corfu--index corfu--scroll) - (and (> corfu--total corfu-count) lo) bar))) - -(defun corfu--range-valid-p () - "Check the completion range, return non-nil if valid." - (pcase-let ((buf (current-buffer)) - (pt (point)) - (`(,beg ,end . ,_) completion-in-region--data)) - (and beg end - (eq buf (marker-buffer beg)) (eq buf (window-buffer)) - (<= beg pt end) - (save-excursion (goto-char beg) (<= (pos-bol) pt (pos-eol)))))) - -(defun corfu--continue-p () - "Check if completion should continue after a command. -Corfu bails out if the current buffer changed unexpectedly or if -point moved out of range, see `corfu--range-valid-p'. Also the -input must satisfy the `completion-in-region-mode--predicate' and -the last command must be listed in `corfu-continue-commands'." - (and (corfu--range-valid-p) - ;; We keep Corfu alive if a `overriding-terminal-local-map' is - ;; installed, e.g., the `universal-argument-map'. It would be good to - ;; think about a better criterion instead. Unfortunately relying on - ;; `this-command' alone is insufficient, since the value of - ;; `this-command' gets clobbered in the case of transient keymaps. - (or overriding-terminal-local-map - ;; Check if it is an explicitly listed continue command - (corfu--match-symbol-p corfu-continue-commands this-command) - (pcase-let ((`(,beg ,end . ,_) completion-in-region--data)) - (and (or (not corfu--input) (< beg end)) ;; Check for empty input - (or (not corfu-quit-at-boundary) ;; Check separator or predicate - (and (eq corfu-quit-at-boundary 'separator) - (or (eq this-command #'corfu-insert-separator) - ;; with separator, any further chars allowed - (seq-contains-p (car corfu--input) corfu-separator))) - (funcall completion-in-region-mode--predicate))))))) - -(defun corfu--preview-current-p () - "Return t if the selected candidate is previewed." - (and corfu-preview-current (>= corfu--index 0) (/= corfu--index corfu--preselect))) - -(defun corfu--preview-current (beg end) - "Show current candidate as overlay given BEG and END." - (when (corfu--preview-current-p) - (setq beg (+ beg (length corfu--base)) - corfu--preview-ov (make-overlay beg end nil)) - (overlay-put corfu--preview-ov 'priority 1000) - (overlay-put corfu--preview-ov 'window (selected-window)) - (overlay-put corfu--preview-ov (if (= beg end) 'after-string 'display) - (nth corfu--index corfu--candidates)))) - -(defun corfu--window-change (_) - "Window and buffer change hook which quits Corfu." - (unless (corfu--range-valid-p) - (corfu-quit))) - -(defun corfu--post-command () - "Refresh Corfu after last command." - (if (corfu--continue-p) - (corfu--exhibit) - (corfu-quit)) - (when corfu-auto - (corfu--auto-post-command))) - -(defun corfu--goto (index) - "Go to candidate with INDEX." - (setq corfu--index (max corfu--preselect (min index (1- corfu--total))))) - -(defun corfu--exit-function (str status cands) - "Call the `:exit-function' with STR and STATUS. -Lookup STR in CANDS to restore text properties." - (when-let ((exit (plist-get completion-extra-properties :exit-function))) - (funcall exit (or (car (member str cands)) str) status))) - -(defun corfu--done (str status cands) - "Exit completion and call the exit function with STR and STATUS. -Lookup STR in CANDS to restore text properties." - (let ((completion-extra-properties (nth 4 completion-in-region--data))) - ;; For successful completions, amalgamate undo operations, - ;; such that completion can be undone in a single step. - (undo-amalgamate-change-group corfu--change-group) - (corfu-quit) - (corfu--exit-function str status cands))) - -(defun corfu--setup (beg end table pred) - "Setup Corfu completion state. -See `completion-in-region' for the arguments BEG, END, TABLE, PRED." - (setq beg (if (markerp beg) beg (copy-marker beg)) - end (if (and (markerp end) (marker-insertion-type end)) end (copy-marker end t)) - completion-in-region--data (list beg end table pred completion-extra-properties)) - (completion-in-region-mode 1) - (activate-change-group (setq corfu--change-group (prepare-change-group))) - (setcdr (assq #'completion-in-region-mode minor-mode-overriding-map-alist) corfu-map) - (add-hook 'pre-command-hook #'corfu--prepare nil 'local) - (add-hook 'window-selection-change-functions #'corfu--window-change nil 'local) - (add-hook 'window-buffer-change-functions #'corfu--window-change nil 'local) - (add-hook 'post-command-hook #'corfu--post-command) - ;; Disable default post-command handling, since we have our own - ;; checks in `corfu--post-command'. - (remove-hook 'post-command-hook #'completion-in-region--postch) - (let ((sym (make-symbol "corfu--teardown")) - (buf (current-buffer))) - (fset sym (lambda () - ;; Ensure that the tear-down runs in the correct buffer, if still alive. - (unless completion-in-region-mode - (remove-hook 'completion-in-region-mode-hook sym) - (corfu--teardown buf)))) - (add-hook 'completion-in-region-mode-hook sym))) - -(defun corfu--in-region (&rest args) - "Corfu completion in region function called with ARGS." - ;; XXX We can get an endless loop when `completion-in-region-function' is set - ;; globally to `corfu--in-region'. This should never happen. - (apply (if (corfu--popup-support-p) #'corfu--in-region-1 - (default-value 'completion-in-region-function)) - args)) - -(defun corfu--in-region-1 (beg end table &optional pred) - "Complete in region, see `completion-in-region' for BEG, END, TABLE, PRED." - (barf-if-buffer-read-only) - ;; Restart the completion. This can happen for example if C-M-/ - ;; (`dabbrev-completion') is pressed while the Corfu popup is already open. - (when completion-in-region-mode (corfu-quit)) - (let* ((pt (max 0 (- (point) beg))) - (str (buffer-substring-no-properties beg end)) - (metadata (completion-metadata (substring str 0 pt) table pred)) - (threshold (completion--cycle-threshold metadata)) - (completion-in-region-mode-predicate - (or completion-in-region-mode-predicate #'always))) - (pcase (completion-try-completion str table pred pt metadata) - ('nil (corfu--message "No match") nil) - ('t (goto-char end) - (corfu--message "Sole match") - (if (eq corfu-on-exact-match 'show) - (corfu--setup beg end table pred) - (corfu--exit-function - str 'finished - (alist-get 'corfu--candidates (corfu--recompute str pt table pred)))) - t) - (`(,newstr . ,newpt) - (setq beg (if (markerp beg) beg (copy-marker beg)) - end (copy-marker end t)) - (corfu--replace beg end newstr) - (goto-char (+ beg newpt)) - (let* ((state (corfu--recompute newstr newpt table pred)) - (base (alist-get 'corfu--base state)) - (total (alist-get 'corfu--total state)) - (candidates (alist-get 'corfu--candidates state))) - (if (= total 1) - ;; If completion is finished and cannot be further completed, and - ;; the value of `corfu-on-exact-match' is not 'show, return - ;; 'finished. Otherwise setup the Corfu popup. - (if (or (eq corfu-on-exact-match 'show) - (consp (completion-try-completion - newstr table pred newpt - (completion-metadata newstr table pred)))) - (corfu--setup beg end table pred) - (corfu--exit-function newstr 'finished candidates)) - (if (or (= total 0) (not threshold) - (and (not (eq threshold t)) (< threshold total))) - (corfu--setup beg end table pred) - (corfu--cycle-candidates total candidates (+ (length base) beg) end) - ;; Do not show Corfu when "trivially" cycling, i.e., - ;; when the completion is finished after the candidate. - (unless (equal (completion-boundaries (car candidates) table pred "") - '(0 . 0)) - (corfu--setup beg end table pred))))) - t)))) - -(defun corfu--message (&rest msg) - "Show completion MSG." - (let (message-log-max) (apply #'message msg))) - -(defun corfu--cycle-candidates (total cands beg end) - "Cycle between TOTAL number of CANDS. -See `completion-in-region' for the arguments BEG, END, TABLE, PRED." - (let* ((idx 0) - (map (make-sparse-keymap)) - (replace (lambda () - (interactive) - (corfu--replace beg end (nth idx cands)) - (corfu--message "Cycling %d/%d..." (1+ idx) total) - (setq idx (mod (1+ idx) total)) - (set-transient-map map)))) - (define-key map [remap completion-at-point] replace) - (define-key map [remap corfu-complete] replace) - (define-key map (vector last-command-event) replace) - (funcall replace))) - -(defun corfu--auto-complete-deferred (&optional tick) - "Initiate auto completion if TICK did not change." - (when (and (not completion-in-region-mode) - (or (not tick) (equal tick (corfu--auto-tick)))) - (pcase (while-no-input ;; Interruptible Capf query - (run-hook-wrapped 'completion-at-point-functions #'corfu--capf-wrapper)) - (`(,fun ,beg ,end ,table . ,plist) - (let ((completion-in-region-mode-predicate - (lambda () - (when-let ((newbeg (car-safe (funcall fun)))) - (= newbeg beg)))) - (completion-extra-properties plist)) - (corfu--setup beg end table (plist-get plist :predicate)) - (corfu--exhibit 'auto)))))) - -(defun corfu--auto-post-command () - "Post command hook which initiates auto completion." - (cancel-timer corfu--auto-timer) - (if (and (not completion-in-region-mode) - (not defining-kbd-macro) - (not buffer-read-only) - (corfu--match-symbol-p corfu-auto-commands this-command) - (corfu--popup-support-p)) - (if (<= corfu-auto-delay 0) - (corfu--auto-complete-deferred) - ;; Do not use `timer-set-idle-time' since this leads to - ;; unpredictable pauses, in particular with `flyspell-mode'. - (timer-set-time corfu--auto-timer - (timer-relative-time nil corfu-auto-delay)) - (timer-set-function corfu--auto-timer #'corfu--auto-complete-deferred - (list (corfu--auto-tick))) - (timer-activate corfu--auto-timer)))) - -(defun corfu--auto-tick () - "Return the current tick/status of the buffer. -Auto completion is only performed if the tick did not change." - (list (selected-window) (current-buffer) (buffer-chars-modified-tick) (point))) - -(cl-defgeneric corfu--popup-show (pos off width lines &optional curr lo bar) - "Show LINES as popup at POS - OFF. -WIDTH is the width of the popup. -The current candidate CURR is highlighted. -A scroll bar is displayed from LO to LO+BAR." - (let ((lh (default-line-height))) - (with-current-buffer (corfu--make-buffer " *corfu*") - (let* ((ch (default-line-height)) - (cw (default-font-width)) - (ml (ceiling (* cw corfu-left-margin-width))) - (mr (ceiling (* cw corfu-right-margin-width))) - (bw (ceiling (min mr (* cw corfu-bar-width)))) - (marginl (and (> ml 0) (propertize " " 'display `(space :width (,ml))))) - (marginr (and (> mr 0) (propertize " " 'display `(space :align-to right)))) - (sbar (when (> bw 0) - (concat (propertize " " 'display `(space :align-to (- right (,mr)))) - (propertize " " 'display `(space :width (,(- mr bw)))) - (propertize " " 'face 'corfu-bar 'display `(space :width (,bw)))))) - (pos (posn-x-y pos)) - (width (+ (* width cw) ml mr)) - ;; XXX HACK: Minimum popup height must be at least 1 line of the - ;; parent frame (gh:minad/corfu#261). - (height (max lh (* (length lines) ch))) - (edge (window-inside-pixel-edges)) - (border (alist-get 'internal-border-width corfu--frame-parameters)) - (x (max 0 (min (+ (car edge) (- (or (car pos) 0) ml (* cw off) border)) - (- (frame-pixel-width) width)))) - (yb (+ (cadr edge) (window-tab-line-height) (or (cdr pos) 0) lh)) - (y (if (> (+ yb (* corfu-count ch) lh lh) (frame-pixel-height)) - (- yb height lh border border) - yb)) - (row 0)) - (with-silent-modifications - (erase-buffer) - (insert (mapconcat (lambda (line) - (let ((str (concat marginl line - (if (and lo (<= lo row (+ lo bar))) - sbar - marginr)))) - (when (eq row curr) - (add-face-text-property - 0 (length str) 'corfu-current 'append str)) - (cl-incf row) - str)) - lines "\n")) - (goto-char (point-min))) - (setq corfu--frame (corfu--make-frame corfu--frame x y - width height (current-buffer))))))) - -(cl-defgeneric corfu--popup-hide () - "Hide Corfu popup." - (corfu--hide-frame corfu--frame)) - -(cl-defgeneric corfu--popup-support-p () - "Return non-nil if child frames are supported." - (display-graphic-p)) - -(cl-defgeneric corfu--insert (status) - "Insert current candidate, exit with STATUS if non-nil." - ;; XXX There is a small bug here, depending on interpretation. - ;; When completing "~/emacs/master/li|/calc" where "|" is the - ;; cursor, then the candidate only includes the prefix - ;; "~/emacs/master/lisp/", but not the suffix "/calc". Default - ;; completion has the same problem when selecting in the - ;; *Completions* buffer. See bug#48356. - (pcase-let* ((`(,beg ,end . ,_) completion-in-region--data) - (str (concat corfu--base (nth corfu--index corfu--candidates)))) - (corfu--replace beg end str) - (corfu--goto -1) ;; Reset selection, completion may continue. - (when status (corfu--done str status nil)) - str)) - -(cl-defgeneric corfu--affixate (cands) - "Annotate CANDS with annotation function." - (let* ((completion-extra-properties (nth 4 completion-in-region--data)) - (dep (plist-get completion-extra-properties :company-deprecated)) - (mf (run-hook-with-args-until-success 'corfu-margin-formatters corfu--metadata))) - (setq cands - (if-let ((aff (or (corfu--metadata-get 'affixation-function) - (plist-get completion-extra-properties :affixation-function)))) - (funcall aff cands) - (if-let ((ann (or (corfu--metadata-get 'annotation-function) - (plist-get completion-extra-properties :annotation-function)))) - (cl-loop for cand in cands collect - (let ((suff (or (funcall ann cand) ""))) - ;; The default completion UI adds the - ;; `completions-annotations' face if no other faces are - ;; present. We use a custom `corfu-annotations' face to - ;; allow further styling which fits better for popups. - (unless (text-property-not-all 0 (length suff) 'face nil suff) - (setq suff (propertize suff 'face 'corfu-annotations))) - (list cand "" suff))) - (cl-loop for cand in cands collect (list cand "" ""))))) - (cl-loop for x in cands for (c . _) = x do - (when mf - (setf (cadr x) (funcall mf c))) - (when (and dep (funcall dep c)) - (setcar x (setq c (substring c))) - (add-face-text-property 0 (length c) 'corfu-deprecated 'append c))) - (cons mf cands))) - -(cl-defgeneric corfu--prepare () - "Insert selected candidate unless command is marked to continue completion." - (when corfu--preview-ov - (delete-overlay corfu--preview-ov) - (setq corfu--preview-ov nil)) - ;; Ensure that state is initialized before next Corfu command - (when (and (symbolp this-command) (string-prefix-p "corfu-" (symbol-name this-command))) - (corfu--update)) - ;; If the next command is not listed in `corfu-continue-commands', insert the - ;; currently selected candidate and bail out of completion. This way you can - ;; continue typing after selecting a candidate. The candidate will be inserted - ;; and your new input will be appended. - (and (corfu--preview-current-p) (eq corfu-preview-current 'insert) - ;; See the comment about `overriding-local-map' in `corfu--post-command'. - (not (or overriding-terminal-local-map - (corfu--match-symbol-p corfu-continue-commands this-command))) - (corfu--insert 'exact))) - -(cl-defgeneric corfu--exhibit (&optional auto) - "Exhibit Corfu UI. -AUTO is non-nil when initializing auto completion." - (pcase-let ((`(,beg ,end ,table ,pred . ,_) completion-in-region--data) - (`(,str . ,pt) (corfu--update 'interruptible))) - (cond - ;; 1) Single exactly matching candidate and no further completion is possible. - ((and (not (equal str "")) - (equal (car corfu--candidates) str) (not (cdr corfu--candidates)) - (not (eq corfu-on-exact-match 'show)) - (or auto corfu-on-exact-match) - (not (consp (completion-try-completion str table pred pt corfu--metadata)))) - ;; Quit directly when initializing auto completion. - (if (or auto (eq corfu-on-exact-match 'quit)) - (corfu-quit) - (corfu--done (car corfu--candidates) 'finished nil))) - ;; 2) There exist candidates => Show candidates popup. - (corfu--candidates - (let ((pos (posn-at-point (+ beg (length corfu--base))))) - (corfu--preview-current beg end) - (corfu--candidates-popup pos))) - ;; 3) No candidates & `corfu-quit-no-match' & initialized => Confirmation popup. - ((pcase-exhaustive corfu-quit-no-match - ('t nil) - ('nil corfu--input) - ('separator (seq-contains-p (car corfu--input) corfu-separator))) - (corfu--popup-show (posn-at-point beg) 0 8 '(#("No match" 0 8 (face italic))))) - ;; 4) No candidates & auto completing or initialized => Quit. - ((or auto corfu--input) (corfu-quit))))) - -(cl-defgeneric corfu--teardown (buffer) - "Tear-down Corfu in BUFFER, which might be dead at this point." - (corfu--popup-hide) - (when corfu--preview-ov (delete-overlay corfu--preview-ov)) - (remove-hook 'post-command-hook #'corfu--post-command) - (when (buffer-live-p buffer) - (with-current-buffer buffer - (remove-hook 'window-selection-change-functions #'corfu--window-change 'local) - (remove-hook 'window-buffer-change-functions #'corfu--window-change 'local) - (remove-hook 'pre-command-hook #'corfu--prepare 'local) - (accept-change-group corfu--change-group))) - (cl-loop for (k . v) in corfu--initial-state do (set k v))) - -(defun corfu-sort-length-alpha (list) - "Sort LIST by length and alphabetically." - (sort list #'corfu--length-string<)) - -(defun corfu-quit () - "Quit Corfu completion." - (interactive) - (completion-in-region-mode -1)) - -(defun corfu-reset () - "Reset Corfu completion. -This command can be executed multiple times by hammering the ESC key. If a -candidate is selected, unselect the candidate. Otherwise reset the input. If -there hasn't been any input, then quit." - (interactive) - (if (/= corfu--index corfu--preselect) - (progn - (corfu--goto -1) - (setq this-command #'corfu-first)) - ;; Cancel all changes and start new change group. - (pcase-let* ((`(,beg ,end . ,_) completion-in-region--data) - (str (buffer-substring-no-properties beg end))) - (cancel-change-group corfu--change-group) - (activate-change-group (setq corfu--change-group (prepare-change-group))) - ;; Quit when resetting, when input did not change. - (when (equal str (buffer-substring-no-properties beg end)) - (corfu-quit))))) - -(defun corfu-insert-separator () - "Insert a separator character, inhibiting quit on completion boundary. -See `corfu-separator' for more details." - (interactive) - (insert corfu-separator)) - -(defun corfu-next (&optional n) - "Go forward N candidates." - (interactive "p") - (let ((index (+ corfu--index (or n 1)))) - (corfu--goto - (cond - ((not corfu-cycle) index) - ((= corfu--total 0) -1) - ((< corfu--preselect 0) (1- (mod (1+ index) (1+ corfu--total)))) - (t (mod index corfu--total)))))) - -(defun corfu-previous (&optional n) - "Go backward N candidates." - (interactive "p") - (corfu-next (- (or n 1)))) - -(defun corfu-scroll-down (&optional n) - "Go back by N pages." - (interactive "p") - (corfu--goto (max 0 (- corfu--index (* (or n 1) corfu-count))))) - -(defun corfu-scroll-up (&optional n) - "Go forward by N pages." - (interactive "p") - (corfu-scroll-down (- (or n 1)))) - -(defun corfu-first () - "Go to first candidate. -If the first candidate is already selected, go to the prompt." - (interactive) - (corfu--goto (if (> corfu--index 0) 0 -1))) - -(defun corfu-last () - "Go to last candidate." - (interactive) - (corfu--goto (1- corfu--total))) - -(defun corfu-prompt-beginning (arg) - "Move to beginning of the prompt line. -If the point is already the beginning of the prompt move to the -beginning of the line. If ARG is not 1 or nil, move backward ARG - 1 -lines first." - (interactive "^p") - (let ((beg (car completion-in-region--data))) - (if (or (not (eq arg 1)) - (and (= corfu--preselect corfu--index) (= (point) beg))) - (move-beginning-of-line arg) - (corfu--goto -1) - (goto-char beg)))) - -(defun corfu-prompt-end (arg) - "Move to end of the prompt line. -If the point is already the end of the prompt move to the end of -the line. If ARG is not 1 or nil, move forward ARG - 1 lines -first." - (interactive "^p") - (let ((end (cadr completion-in-region--data))) - (if (or (not (eq arg 1)) - (and (= corfu--preselect corfu--index) (= (point) end))) - (move-end-of-line arg) - (corfu--goto -1) - (goto-char end)))) - -(defun corfu-complete () - "Complete current input. -If a candidate is selected, insert it. Otherwise invoke -`corfu-expand'. Return non-nil if the input has been expanded." - (interactive) - (if (< corfu--index 0) - (corfu-expand) - ;; Continue completion with selected candidate. Exit with status 'finished - ;; if input is a valid match and no further completion is - ;; possible. Additionally treat completion as finished if at the end of a - ;; boundary, even if other longer candidates would still match, since the - ;; user invoked `corfu-complete' with an explicitly selected candidate! - (pcase-let ((`(,_beg ,_end ,table ,pred . ,_) completion-in-region--data) - (newstr (corfu--insert nil))) - (and (test-completion newstr table pred) - (or (not (consp (completion-try-completion - newstr table pred (length newstr) - (completion-metadata newstr table pred)))) - (equal (completion-boundaries newstr table pred "") '(0 . 0))) - (corfu--done newstr 'finished nil)) - t))) - -(defun corfu-expand () - "Expands the common prefix of all candidates. -If the currently selected candidate is previewed, invoke -`corfu-complete' instead. Expansion relies on the completion -styles via `completion-try-completion'. Return non-nil if the -input has been expanded." - (interactive) - (if (corfu--preview-current-p) - (corfu-complete) - (pcase-let* ((`(,beg ,end ,table ,pred . ,_) completion-in-region--data) - (pt (max 0 (- (point) beg))) - (str (buffer-substring-no-properties beg end)) - (metadata (completion-metadata (substring str 0 pt) table pred))) - (pcase (completion-try-completion str table pred pt metadata) - ('t - (goto-char end) - (corfu--done str 'finished corfu--candidates) - t) - ((and `(,newstr . ,newpt) (guard (not (and (= pt newpt) (equal newstr str))))) - (corfu--replace beg end newstr) - (goto-char (+ beg newpt)) - ;; Exit with status 'finished if input is a valid match - ;; and no further completion is possible. - (and (test-completion newstr table pred) - (not (consp (completion-try-completion - newstr table pred newpt - (completion-metadata (substring newstr 0 newpt) table pred)))) - (corfu--done newstr 'finished corfu--candidates)) - t))))) - -(defun corfu-insert () - "Insert current candidate. -Quit if no candidate is selected." - (interactive) - (if (>= corfu--index 0) - (corfu--insert 'finished) - (corfu-quit))) - -;;;###autoload -(define-minor-mode corfu-mode - "COmpletion in Region FUnction." - :group 'corfu :keymap corfu-mode-map - (cond - (corfu-mode - (and corfu-auto (add-hook 'post-command-hook #'corfu--auto-post-command nil 'local)) - (setq-local completion-in-region-function #'corfu--in-region)) - (t - (remove-hook 'post-command-hook #'corfu--auto-post-command 'local) - (kill-local-variable 'completion-in-region-function)))) - -(defcustom global-corfu-modes t - "List of modes where Corfu should be enabled. -The variable can either be t, nil or a list of t, nil, mode -symbols or elements of the form (not modes). Examples: - - Enable everywhere, except in Org: ((not org-mode) t). - - Enable in programming modes except Python: ((not python-mode) prog-mode). - - Enable only in text modes: (text-mode)." - :type '(choice (const t) (repeat sexp))) - -;;;###autoload -(define-globalized-minor-mode global-corfu-mode - corfu-mode corfu--on - :group 'corfu) - -(defun corfu--on () - "Turn `corfu-mode' on." - (when (and (not (or noninteractive (eq (aref (buffer-name) 0) ?\s))) - ;; TODO backport `easy-mmode--globalized-predicate-p' - (or (eq t global-corfu-modes) - (eq t (cl-loop for p in global-corfu-modes thereis - (pcase-exhaustive p - ('t t) - ('nil 0) - ((pred symbolp) (and (derived-mode-p p) t)) - (`(not . ,m) (and (seq-some #'derived-mode-p m) 0))))))) - (corfu-mode 1))) - -;; Emacs 28: Do not show Corfu commands with M-X -(dolist (sym '(corfu-next corfu-previous corfu-first corfu-last corfu-quit corfu-reset - corfu-complete corfu-insert corfu-scroll-up corfu-scroll-down - corfu-insert-separator corfu-prompt-beginning corfu-prompt-end)) - (put sym 'completion-predicate #'ignore)) - -(defun corfu--capf-wrapper-advice (orig fun which) - "Around advice for `completion--capf-wrapper'. -The ORIG function takes the FUN and WHICH arguments." - (if corfu-mode (corfu--capf-wrapper fun t) (funcall orig fun which))) - -(defun corfu--eldoc-advice () - "Return non-nil if Corfu is currently not active." - (not (and corfu-mode completion-in-region-mode))) - -;; Install advice which fixes `completion--capf-wrapper', such that it respects -;; the completion styles for non-exclusive Capfs. See also the fixme comment in -;; the `completion--capf-wrapper' function in minibuffer.el. -(advice-add #'completion--capf-wrapper :around #'corfu--capf-wrapper-advice) - -;; Register Corfu with ElDoc -(advice-add #'eldoc-display-message-no-interference-p - :before-while #'corfu--eldoc-advice) -(eldoc-add-command #'corfu-complete #'corfu-insert) - -(provide 'corfu) -;;; corfu.el ends here diff --git a/emacs/elpa/corfu-20240413.927/corfu-autoloads.el b/emacs/elpa/corfu-20240523.752/corfu-autoloads.el diff --git a/emacs/elpa/corfu-20240523.752/corfu-echo.el b/emacs/elpa/corfu-20240523.752/corfu-echo.el @@ -0,0 +1,109 @@ +;;; corfu-echo.el --- Show candidate documentation in echo area -*- lexical-binding: t -*- + +;; Copyright (C) 2021-2024 Free Software Foundation, Inc. + +;; Author: Daniel Mendler <mail@daniel-mendler.de> +;; Maintainer: Daniel Mendler <mail@daniel-mendler.de> +;; Created: 2022 +;; Version: 1.4 +;; Package-Requires: ((emacs "27.1") (compat "29.1.4.4") (corfu "1.4")) +;; Homepage: https://github.com/minad/corfu + +;; This file is part of GNU Emacs. + +;; 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 <https://www.gnu.org/licenses/>. + +;;; Commentary: + +;; Show candidate documentation in echo area. Enable `corfu-echo-mode'. + +;;; Code: + +(require 'corfu) +(eval-when-compile + (require 'subr-x)) + +(defface corfu-echo + '((t :inherit completions-annotations)) + "Face used for echo area messages." + :group 'corfu-faces) + +(defcustom corfu-echo-delay '(2.0 . 1.0) + "Show documentation string in the echo area after that number of seconds. +The value can be a pair of two floats to specify initial and +subsequent delay." + :type '(choice (const :tag "Never" nil) + (number :tag "Delay in seconds") + (cons :tag "Two Delays" + (choice :tag "Initial " number) + (choice :tag "Subsequent" number))) + :group 'corfu) + +(defvar corfu-echo--timer nil + "Echo area message timer.") + +(defvar corfu-echo--message nil + "Last echo message.") + +(defun corfu-echo--cancel (&optional msg) + "Cancel echo timer and refresh MSG." + (when corfu-echo--timer + (cancel-timer corfu-echo--timer) + (setq corfu-echo--timer nil)) + (corfu-echo--show msg) + (unless corfu-echo--message + (setq corfu-echo--timer nil + corfu-echo--message nil))) + +(defun corfu-echo--show (msg) + "Show MSG in echo area." + (when (or msg corfu-echo--message) + (setq msg (or msg "") + corfu-echo--message msg) + (corfu--message "%s" (if (text-property-not-all 0 (length msg) 'face nil msg) + msg + (propertize msg 'face 'corfu-echo))))) + +;;;###autoload +(define-minor-mode corfu-echo-mode + "Show candidate documentation in echo area." + :global t :group 'corfu) + +(cl-defmethod corfu--exhibit :after (&context (corfu-echo-mode (eql t)) &optional _auto) + (if-let ((delay (if (consp corfu-echo-delay) + (funcall (if corfu-echo--message #'cdr #'car) + corfu-echo-delay) + corfu-echo-delay)) + (extra (nth 4 completion-in-region--data)) + (fun (plist-get extra :company-docsig)) + (cand (and (>= corfu--index 0) + (nth corfu--index corfu--candidates)))) + (if (<= delay 0) + (corfu-echo--show (funcall fun cand)) + (corfu-echo--cancel) + (setq corfu-echo--timer + (run-at-time delay nil + (lambda () + (corfu-echo--show (funcall fun cand)))))) + (corfu-echo--cancel))) + +(cl-defmethod corfu--teardown :before (_buf &context (corfu-echo-mode (eql t))) + (corfu-echo--cancel)) + +(cl-defmethod corfu--prepare :before (&context (corfu-echo-mode (eql t))) + ;; The refreshing is needed to prevent flicker if corfu-echo-delay=t. + (corfu-echo--cancel corfu-echo--message)) + +(provide 'corfu-echo) +;;; corfu-echo.el ends here diff --git a/emacs/elpa/corfu-20240413.927/corfu-echo.elc b/emacs/elpa/corfu-20240523.752/corfu-echo.elc Binary files differ. diff --git a/emacs/elpa/corfu-20240523.752/corfu-history.el b/emacs/elpa/corfu-20240523.752/corfu-history.el @@ -0,0 +1,92 @@ +;;; corfu-history.el --- Sorting by history for Corfu -*- lexical-binding: t -*- + +;; Copyright (C) 2022-2024 Free Software Foundation, Inc. + +;; Author: Daniel Mendler <mail@daniel-mendler.de> +;; Maintainer: Daniel Mendler <mail@daniel-mendler.de> +;; Created: 2022 +;; Version: 1.4 +;; Package-Requires: ((emacs "27.1") (compat "29.1.4.4") (corfu "1.4")) +;; Homepage: https://github.com/minad/corfu + +;; This file is part of GNU Emacs. + +;; 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 <https://www.gnu.org/licenses/>. + +;;; Commentary: + +;; Enable `corfu-history-mode' to sort candidates by their history +;; position. Maintain a list of recently selected candidates. In order +;; to save the history across Emacs sessions, enable `savehist-mode' and +;; add `corfu-history' to `savehist-additional-variables'. +;; +;; (corfu-history-mode 1) +;; (savehist-mode 1) +;; (add-to-list 'savehist-additional-variables 'corfu-history) + +;;; Code: + +(require 'corfu) +(eval-when-compile + (require 'cl-lib)) + +(defvar corfu-history nil + "History of Corfu candidates. +The maximum length is determined by the variable `history-length' +or the property `history-length' of `corfu-history'.") + +(defvar corfu-history--hash nil + "Hash table of Corfu candidates.") + +(defun corfu-history--sort-predicate (x y) + "Sorting predicate which compares X and Y." + (or (< (cdr x) (cdr y)) + (and (= (cdr x) (cdr y)) + (corfu--length-string< (car x) (car y))))) + +(defun corfu-history--sort (cands) + "Sort CANDS by history." + (unless corfu-history--hash + (setq corfu-history--hash (make-hash-table :test #'equal :size (length corfu-history))) + (cl-loop for elem in corfu-history for index from 0 do + (unless (gethash elem corfu-history--hash) + (puthash elem index corfu-history--hash)))) + ;; Decorate each candidate with (index<<13) + length. This way we sort first by index and then by + ;; length. We assume that the candidates are shorter than 2**13 characters and that the history is + ;; shorter than 2**16 entries. + (cl-loop for cand on cands do + (setcar cand (cons (car cand) + (+ (ash (gethash (car cand) corfu-history--hash #xFFFF) 13) + (length (car cand)))))) + (setq cands (sort cands #'corfu-history--sort-predicate)) + (cl-loop for cand on cands do (setcar cand (caar cand))) + cands) + +;;;###autoload +(define-minor-mode corfu-history-mode + "Update Corfu history and sort completions by history." + :global t :group 'corfu + (if corfu-history-mode + (add-function :override corfu-sort-function #'corfu-history--sort) + (remove-function corfu-sort-function #'corfu-history--sort))) + +(cl-defmethod corfu--insert :before (_status &context (corfu-history-mode (eql t))) + (when (>= corfu--index 0) + (add-to-history 'corfu-history + (substring-no-properties + (nth corfu--index corfu--candidates))) + (setq corfu-history--hash nil))) + +(provide 'corfu-history) +;;; corfu-history.el ends here diff --git a/emacs/elpa/corfu-20240413.927/corfu-history.elc b/emacs/elpa/corfu-20240523.752/corfu-history.elc Binary files differ. diff --git a/emacs/elpa/corfu-20240523.752/corfu-indexed.el b/emacs/elpa/corfu-20240523.752/corfu-indexed.el @@ -0,0 +1,97 @@ +;;; corfu-indexed.el --- Select indexed candidates -*- lexical-binding: t -*- + +;; Copyright (C) 2022-2024 Free Software Foundation, Inc. + +;; Author: Luis Henriquez-Perez <luis@luishp.xyz>, Daniel Mendler <mail@daniel-mendler.de> +;; Maintainer: Daniel Mendler <mail@daniel-mendler.de> +;; Created: 2022 +;; Version: 1.4 +;; Package-Requires: ((emacs "27.1") (compat "29.1.4.4") (corfu "1.4")) +;; Homepage: https://github.com/minad/corfu + +;; This file is part of GNU Emacs. + +;; 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 <https://www.gnu.org/licenses/>. + +;;; Commentary: + +;; This package is a Corfu extension, which prefixes candidates with indices if +;; enabled via `corfu-indexed-mode'. It allows you to select candidates with +;; prefix arguments. This is designed to be a faster alternative to selecting a +;; candidate with `corfu-next' and `corfu-previous'. + +;;; Code: + +(require 'corfu) +(eval-when-compile + (require 'cl-lib)) + +(defface corfu-indexed + '((default :height 0.75) + (((class color) (min-colors 88) (background dark)) + :foreground "#f4f4f4" :background "#323232") + (((class color) (min-colors 88) (background light)) + :foreground "#404148" :background "#d7d7d7") + (t :background "black")) + "Face used for the candidate index prefix." + :group 'corfu-faces) + +(defcustom corfu-indexed-start 0 + "Start of the indexing." + :group 'corfu + :type 'natnum) + +(defvar corfu-indexed--commands + '(corfu-insert corfu-complete) + "Commands that should be indexed.") + +;;;###autoload +(define-minor-mode corfu-indexed-mode + "Prefix candidates with indices." + :global t :group 'corfu) + +(cl-defmethod corfu--prepare :before (&context (corfu-indexed-mode (eql t))) + (when (and prefix-arg (memq this-command corfu-indexed--commands)) + (let ((index (+ corfu--scroll + (- (prefix-numeric-value prefix-arg) + corfu-indexed-start)))) + (if (and (>= index 0) + (< index corfu--total) + (< index (+ corfu--scroll corfu-count))) + (setq corfu--index index) + (message "Out of range") + (setq this-command #'ignore))))) + +(cl-defmethod corfu--affixate :around (cands &context (corfu-indexed-mode (eql t))) + (setq cands (cdr (cl-call-next-method cands))) + (let* ((space #(" " 0 1 (face (:height 0.5 :inherit corfu-indexed)))) + (width (if (length> cands (- 10 corfu-indexed-start)) 2 1)) + (fmt (concat space + (propertize (format "%%%ds" width) + 'face 'corfu-indexed) + space)) + (align + (propertize (make-string width ?\s) + 'display + `(space :align-to (+ left ,(1+ width)))))) + (cl-loop for cand in cands for index from corfu-indexed-start do + (setf (cadr cand) + (concat + (propertize " " 'display (format fmt index)) + align + (cadr cand)))) + (cons t cands))) + +(provide 'corfu-indexed) +;;; corfu-indexed.el ends here diff --git a/emacs/elpa/corfu-20240413.927/corfu-indexed.elc b/emacs/elpa/corfu-20240523.752/corfu-indexed.elc Binary files differ. diff --git a/emacs/elpa/corfu-20240523.752/corfu-info.el b/emacs/elpa/corfu-20240523.752/corfu-info.el @@ -0,0 +1,118 @@ +;;; corfu-info.el --- Show candidate information in separate buffer -*- lexical-binding: t -*- + +;; Copyright (C) 2022-2024 Free Software Foundation, Inc. + +;; Author: Daniel Mendler <mail@daniel-mendler.de> +;; Maintainer: Daniel Mendler <mail@daniel-mendler.de> +;; Created: 2022 +;; Version: 1.4 +;; Package-Requires: ((emacs "27.1") (compat "29.1.4.4") (corfu "1.4")) +;; Homepage: https://github.com/minad/corfu + +;; This file is part of GNU Emacs. + +;; 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 <https://www.gnu.org/licenses/>. + +;;; Commentary: + +;; This Corfu extension provides commands to show additional information to the +;; candidates in a separate buffer. The commands `corfu-info-location' and +;; `corfu-info-documentation' are bound by default in the `corfu-map' to M-g and +;; M-h respectively. + +;;; Code: + +(require 'corfu) +(eval-when-compile + (require 'subr-x)) + +(defun corfu-info--restore-on-next-command () + "Restore window configuration before next command." + (let ((config (current-window-configuration)) + (other other-window-scroll-buffer) + (restore (make-symbol "corfu--restore"))) + (fset restore + (lambda () + (setq other-window-scroll-buffer other) + (unless (memq this-command '(scroll-other-window scroll-other-window-down)) + (when (memq this-command '(corfu-quit corfu-reset)) + (setq this-command #'ignore)) + (remove-hook 'pre-command-hook restore) + (set-window-configuration config)))) + (add-hook 'pre-command-hook restore))) + +(defun corfu-info--display-buffer (buffer name) + "Display BUFFER and return window displaying the buffer. +Make the buffer persistent with NAME if non-nil." + (if name + (unless (buffer-local-value 'buffer-file-name buffer) + (if-let ((old (get-buffer name))) + (setq buffer (prog1 old (kill-buffer buffer))) + (with-current-buffer buffer + (rename-buffer name)))) + (corfu-info--restore-on-next-command)) + (setq other-window-scroll-buffer buffer) + (display-buffer buffer t)) + +;;;###autoload +(defun corfu-info-documentation (&optional arg) + "Show documentation of current candidate. +If called with a prefix ARG, the buffer is persistent." + (interactive "P") + ;; Company support, taken from `company.el', see `company-show-doc-buffer'. + (when (< corfu--index 0) + (user-error "No candidate selected")) + (let ((cand (nth corfu--index corfu--candidates))) + (if-let ((extra (nth 4 completion-in-region--data)) + (fun (plist-get extra :company-doc-buffer)) + (res (funcall fun cand))) + (set-window-start (corfu-info--display-buffer + (get-buffer (or (car-safe res) res)) + (and arg (format "*corfu doc: %s*" cand))) + (or (cdr-safe res) (point-min))) + (user-error "No documentation available for `%s'" cand)))) + +;;;###autoload +(defun corfu-info-location (&optional arg) + "Show location of current candidate. +If called with a prefix ARG, the buffer is persistent." + (interactive "P") + ;; Company support, taken from `company.el', see `company-show-location'. + (when (< corfu--index 0) + (user-error "No candidate selected")) + (let ((cand (nth corfu--index corfu--candidates))) + (if-let ((extra (nth 4 completion-in-region--data)) + (fun (plist-get extra :company-location)) + ;; BUG: company-location may throw errors if location is not found + (loc (ignore-errors (funcall fun cand)))) + (with-selected-window + (corfu-info--display-buffer + (or (and (bufferp (car loc)) (car loc)) + (find-file-noselect (car loc) t)) + (and arg (format "*corfu loc: %s*" cand))) + (without-restriction + (goto-char (point-min)) + (when-let ((pos (cdr loc))) + (if (bufferp (car loc)) + (goto-char pos) + (forward-line (1- pos)))) + (set-window-start nil (point)))) + (user-error "No location available for `%s'" cand)))) + +;; Emacs 28: Do not show Corfu commands with M-X +(put #'corfu-info-location 'completion-predicate #'ignore) +(put #'corfu-info-documentation 'completion-predicate #'ignore) + +(provide 'corfu-info) +;;; corfu-info.el ends here diff --git a/emacs/elpa/corfu-20240413.927/corfu-info.elc b/emacs/elpa/corfu-20240523.752/corfu-info.elc Binary files differ. diff --git a/emacs/elpa/corfu-20240523.752/corfu-pkg.el b/emacs/elpa/corfu-20240523.752/corfu-pkg.el @@ -0,0 +1,15 @@ +(define-package "corfu" "20240523.752" "COmpletion in Region FUnction" + '((emacs "27.1") + (compat "29.1.4.4")) + :commit "cdc3e13ad312f5f12b3f78f842fff0b398eb4473" :authors + '(("Daniel Mendler" . "mail@daniel-mendler.de")) + :maintainers + '(("Daniel Mendler" . "mail@daniel-mendler.de")) + :maintainer + '("Daniel Mendler" . "mail@daniel-mendler.de") + :keywords + '("abbrev" "convenience" "matching" "completion" "text") + :url "https://github.com/minad/corfu") +;; Local Variables: +;; no-byte-compile: t +;; End: diff --git a/emacs/elpa/corfu-20240523.752/corfu-popupinfo.el b/emacs/elpa/corfu-20240523.752/corfu-popupinfo.el @@ -0,0 +1,523 @@ +;;; corfu-popupinfo.el --- Candidate information popup for Corfu -*- lexical-binding: t -*- + +;; Copyright (C) 2021-2024 Free Software Foundation, Inc. + +;; Author: Yuwei Tian <fishtai0@gmail.com>, Daniel Mendler <mail@daniel-mendler.de> +;; Maintainer: Daniel Mendler <mail@daniel-mendler.de> +;; Created: 2022 +;; Version: 1.4 +;; Package-Requires: ((emacs "27.1") (compat "29.1.4.4") (corfu "1.4")) +;; Homepage: https://github.com/minad/corfu + +;; This file is part of GNU Emacs. + +;; 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 <https://www.gnu.org/licenses/>. + +;;; Commentary: + +;; Display an information popup for completion candidate when using +;; Corfu. The popup displays either the candidate documentation or the +;; candidate location. The `corfu-popupinfo-mode' must be enabled +;; globally. Set `corfu-popupinfo-delay' to nil if the info popup should +;; not update automatically. If the popup should not appear initially, +;; but update automatically afterwards, use `(setq corfu-popupinfo-delay +;; (cons nil 1.0))'. + +;; For manual toggling the commands `corfu-popupinfo-toggle', +;; `corfu-popupinfo-location' and `corfu-popupinfo-documentation' are +;; bound in the `corfu-popupinfo-map'. + +;;; Code: + +(require 'corfu) +(eval-when-compile + (require 'cl-lib) + (require 'subr-x)) + +(defface corfu-popupinfo + '((t :inherit corfu-default)) + "Face used for the info popup." + :group 'corfu-faces) + +(defcustom corfu-popupinfo-delay '(2.0 . 1.0) + "Automatically update info popup after that number of seconds. + +The value can be a pair of two floats to specify initial and +subsequent delay. If the value is non-nil or the car of the pair +is non-nil, the popup will automatically appear for the +preselected candidate. Otherwise the popup can be requested +manually via `corfu-popupinfo-toggle', +`corfu-popupinfo-documentation' and `corfu-popupinfo-location'. + +It is *not recommended* to use a short delay or even 0, since +this will create high load for Emacs. Retrieving the +documentation from the backend is usually expensive." + :type '(choice (const :tag "Never" nil) + (number :tag "Delay in seconds") + (cons :tag "Two Delays" + (choice :tag "Initial " + (choice (const nil) number)) + (choice :tag "Subsequent" + (choice (const nil) number)))) + :group 'corfu) + +(defcustom corfu-popupinfo-hide t + "Hide the popup during the transition between candidates." + :type 'boolean + :group 'corfu) + +(defcustom corfu-popupinfo-max-width 80 + "The maximum width of the info popup in characters." + :type 'natnum + :group 'corfu) + +(defcustom corfu-popupinfo-min-width 30 + "The minimum width of the info popup in characters." + :type 'natnum + :group 'corfu) + +(defcustom corfu-popupinfo-max-height 10 + "The maximum height of the info popup in characters." + :type 'natnum + :group 'corfu) + +(defcustom corfu-popupinfo-min-height 1 + "The minimum height of the info popup in characters." + :type 'natnum + :group 'corfu) + +(defcustom corfu-popupinfo-resize t + "Resize the info popup automatically if non-nil." + :type 'boolean + :group 'corfu) + +(defcustom corfu-popupinfo-direction '(right left vertical) + "Preferred directions for the popup in order." + :type '(repeat + (choice + (const left) + (const right) + (const vertical) + (const force-left) + (const force-right) + (const force-vertical))) + :group 'corfu) + +(defvar-keymap corfu-popupinfo-map + :doc "Additional keymap activated in popupinfo mode." + "M-t" #'corfu-popupinfo-toggle + "<remap> <corfu-info-documentation>" #'corfu-popupinfo-documentation + "<remap> <corfu-info-location>" #'corfu-popupinfo-location + "<remap> <scroll-other-window>" #'corfu-popupinfo-scroll-up + "<remap> <scroll-other-window-down>" #'corfu-popupinfo-scroll-down + "<remap> <end-of-buffer-other-window>" #'corfu-popupinfo-end + "<remap> <beginning-of-buffer-other-window>" #'corfu-popupinfo-beginning) + +(defvar corfu-popupinfo--buffer-parameters + '((truncate-partial-width-windows . nil) + (truncate-lines . nil) + (left-margin-width . 1) + (right-margin-width . 1) + (word-wrap . t) + (fringe-indicator-alist (continuation))) + "Buffer parameters.") + +(defvar corfu-popupinfo--frame nil + "Info popup child frame.") + +(defvar corfu-popupinfo--timer nil + "Corfu info popup auto display timer.") + +(defvar corfu-popupinfo--toggle 'init + "Toggle state.") + +(defvar corfu-popupinfo--function + #'corfu-popupinfo--get-documentation + "Function called to obtain documentation string.") + +(defvar corfu-popupinfo--candidate nil + "Completion candidate for the info popup.") + +(defvar corfu-popupinfo--coordinates nil + "Coordinates of the candidate popup. +The coordinates list has the form (LEFT TOP RIGHT BOTTOM) where +all values are in pixels relative to the origin. See +`frame-edges' for details.") + +(defvar corfu-popupinfo--lock-dir nil + "Locked position direction of the info popup.") + +(defconst corfu-popupinfo--initial-state + (mapcar + (lambda (k) (cons k (symbol-value k))) + '(corfu-popupinfo--candidate + corfu-popupinfo--coordinates + corfu-popupinfo--lock-dir + corfu-popupinfo--toggle + corfu-popupinfo--function)) + "Initial state of `corfu-popupinfo-mode'.") + +(defun corfu-popupinfo--visible-p (&optional frame) + "Return non-nil if FRAME is visible." + (setq frame (or frame corfu-popupinfo--frame)) + (and (frame-live-p frame) (frame-visible-p frame))) + +(defun corfu-popupinfo--get-location (candidate) + "Get source at location of CANDIDATE." + (save-excursion + (let ((old-buffers (buffer-list)) (buffer nil)) + (unwind-protect + (when-let + ((extra (nth 4 completion-in-region--data)) + (fun (plist-get extra :company-location)) + ;; BUG: company-location may throw errors if location is not found + (loc (ignore-errors (funcall fun candidate))) + ((setq buffer + (or (and (bufferp (car loc)) (car loc)) + (get-file-buffer (car loc)) + (let ((inhibit-message t) + (message-log-max nil) + (inhibit-redisplay t) + (enable-dir-local-variables nil) + (enable-local-variables :safe) + (non-essential t) + (delay-mode-hooks t) + (find-file-hook '(global-font-lock-mode-check-buffers))) + (find-file-noselect (car loc) t)))))) + (with-current-buffer buffer + (save-excursion + (without-restriction + (goto-char (point-min)) + (when-let ((pos (cdr loc))) + (if (bufferp (car loc)) + (goto-char pos) + (forward-line (1- pos)))) + (let ((beg (point))) + ;; Support a little bit of scrolling. + (forward-line (* 10 corfu-popupinfo-max-height)) + (when jit-lock-mode + (jit-lock-fontify-now beg (point))) + (let ((res (buffer-substring beg (point)))) + (and (not (string-blank-p res)) res))))))) + (when (and buffer (not (memq buffer old-buffers))) + (kill-buffer buffer)))))) + +(defun corfu-popupinfo--get-documentation (candidate) + "Get the documentation for CANDIDATE." + (when-let ((extra (nth 4 completion-in-region--data)) + (fun (plist-get extra :company-doc-buffer)) + (res (save-excursion + (let ((inhibit-message t) + (message-log-max nil) + (inhibit-redisplay t) + ;; Reduce print length for elisp backend (#249) + (print-level 3) + (print-length (* corfu-popupinfo-max-width + corfu-popupinfo-max-height))) + (funcall fun candidate))))) + (with-current-buffer (or (car-safe res) res) + (setq res (string-trim + (replace-regexp-in-string + "[\n\t ]*\\[back\\][\n\t ]*" "" + (buffer-string)))) + (and (not (string-blank-p res)) res)))) + +(defun corfu-popupinfo--size () + "Return popup size as pair." + (let* ((cw (default-font-width)) + (lh (default-line-height)) + (margin + (* cw (+ (alist-get 'left-margin-width corfu-popupinfo--buffer-parameters) + (alist-get 'right-margin-width corfu-popupinfo--buffer-parameters)))) + (max-height (* lh corfu-popupinfo-max-height)) + (max-width (* cw corfu-popupinfo-max-width))) + (or (when corfu-popupinfo-resize + (with-current-buffer " *corfu-popupinfo*" + (cl-letf* (((window-dedicated-p) nil) + ((window-buffer) (current-buffer)) + (size (window-text-pixel-size + nil (point-min) (point-max) + ;; Use 3*max-height as y-limit, to take more text + ;; into account. + max-width (* 3 max-height)))) + ;; Check that width is not exceeded. Otherwise use full height, + ;; since lines will get wrapped. + (when (<= (car size) max-width) + (cons (+ margin (car size)) + ;; XXX HACK: Ensure that popup has at least a height of 1, + ;; which is the minimum frame height (#261). Maybe we + ;; should ask upstream how smaller frames can be created. + ;; I only managed to create smaller frames by setting + ;; `window-safe-min-height' to 0, which feels problematic. + (min (max (cdr size) lh) max-height)))))) + (cons (+ margin max-width) max-height)))) + +(defun corfu-popupinfo--frame-geometry (frame) + "Return position and size geometric attributes of FRAME. + +The geometry represents the position and size in pixels +in the form of (X Y WIDTH HEIGHT)." + (pcase-let ((`(,x . ,y) (frame-position frame))) + (list x y (frame-pixel-width frame) (frame-pixel-height frame)))) + +(defun corfu-popupinfo--fits-p (size area) + "Check if SIZE fits into the AREA. + +SIZE is in the form (WIDTH . HEIGHT). +AREA is in the form (X Y WIDTH HEIGHT DIR)." + (and (>= (nth 2 area) (car size)) (>= (nth 3 area) (cdr size)))) + +(defun corfu-popupinfo--larger-p (area1 area2) + "Check if AREA1 is larger than AREA2. + +AREA1 and AREA2 are both in the form (X Y WIDTH HEIGHT DIR)." + (>= (* (nth 2 area1) (nth 3 area1)) (* (nth 2 area2) (nth 3 area2)))) + +(defun corfu-popupinfo--area (ps) + "Calculate the display area for the info popup. + +PS is the pixel size of the popup. The calculated area is in the +form (X Y WIDTH HEIGHT DIR)." + (pcase-let* + ((cw (default-font-width)) + (lh (default-line-height)) + (border (alist-get 'internal-border-width corfu--frame-parameters)) + (`(,_pfx ,_pfy ,pfw ,pfh) + (corfu-popupinfo--frame-geometry (frame-parent corfu--frame))) + (`(,cfx ,cfy ,cfw ,cfh) (corfu-popupinfo--frame-geometry corfu--frame)) + ;; Candidates popup below input + (below (>= cfy (+ lh (cadr (window-inside-pixel-edges)) + (window-tab-line-height) + (or (cdr (posn-x-y (posn-at-point (point)))) 0)))) + ;; Popups aligned at top + (top-aligned (or below (< (cdr ps) cfh))) + ;; Left display area + (ahy (if top-aligned + cfy + (max 0 (- (+ cfy cfh) border border (cdr ps))))) + (ahh (if top-aligned + (min (- pfh cfy) (cdr ps)) + (min (- (+ cfy cfh) border border) (cdr ps)))) + (al (list (max 0 (- cfx (car ps) border)) ahy + (min (- cfx border) (car ps)) ahh 'left)) + ;; Right display area + (arx (+ cfx cfw (- border))) + (ar (list arx ahy (min (- pfw arx border border) (car ps)) ahh 'right)) + ;; Vertical display area + (avw (min (car ps) (- pfw cfx border border))) + (av (if below + (list cfx (+ cfy cfh (- border)) avw (min (- pfh cfy cfh border) (cdr ps)) 'vertical) + (let ((h (min (- cfy border border) (cdr ps)))) + (list cfx (max 0 (- cfy h border)) avw h 'vertical))))) + (unless (and corfu-popupinfo--lock-dir + (corfu-popupinfo--fits-p + (cons (* cw corfu-popupinfo-min-width) (* lh corfu-popupinfo-min-height)) + (pcase corfu-popupinfo--lock-dir ('left al) ('right ar) ('vertical av)))) + (setq corfu-popupinfo--lock-dir nil)) + (or + (cl-loop for dir in corfu-popupinfo-direction thereis + (pcase dir + ((or 'force-right (guard (eq corfu-popupinfo--lock-dir 'right))) ar) + ((or 'force-left (guard (eq corfu-popupinfo--lock-dir 'left))) al) + ((or 'force-vertical (guard (eq corfu-popupinfo--lock-dir 'vertical))) av) + ((and 'right (guard (corfu-popupinfo--fits-p ps ar))) ar) + ((and 'left (guard (corfu-popupinfo--fits-p ps al))) al) + ((and 'vertical (guard (corfu-popupinfo--fits-p ps av))) av))) + (let ((ah (if (corfu-popupinfo--larger-p ar al) ar al))) + (if (corfu-popupinfo--larger-p av ah) av ah))))) + +(defun corfu-popupinfo--show (candidate) + "Show the info popup for CANDIDATE." + (when corfu-popupinfo--timer + (cancel-timer corfu-popupinfo--timer) + (setq corfu-popupinfo--timer nil)) + (when (and (corfu-popupinfo--visible-p corfu--frame)) + (let* ((cand-changed + (not (and (corfu-popupinfo--visible-p) + (equal candidate corfu-popupinfo--candidate)))) + (new-coords (frame-edges corfu--frame 'inner-edges)) + (coords-changed (not (equal new-coords corfu-popupinfo--coordinates)))) + (when cand-changed + (if-let ((content (funcall corfu-popupinfo--function candidate))) + (with-current-buffer (corfu--make-buffer " *corfu-popupinfo*") + (with-silent-modifications + (erase-buffer) + (insert content) + (goto-char (point-min))) + (dolist (var corfu-popupinfo--buffer-parameters) + (set (make-local-variable (car var)) (cdr var))) + (when-let ((m (memq 'corfu-default (alist-get 'default face-remapping-alist)))) + (setcar m 'corfu-popupinfo))) + (corfu-popupinfo--hide) + (setq cand-changed nil coords-changed nil))) + (when (or cand-changed coords-changed) + (pcase-let* ((border (alist-get 'internal-border-width corfu--frame-parameters)) + (`(,area-x ,area-y ,area-w ,area-h ,area-d) + (corfu-popupinfo--area + (if cand-changed + (corfu-popupinfo--size) + (cons + (- (frame-pixel-width corfu-popupinfo--frame) border border) + (- (frame-pixel-height corfu-popupinfo--frame) border border))))) + (margin-quirk (not corfu-popupinfo--frame))) + (setq corfu-popupinfo--frame + (corfu--make-frame corfu-popupinfo--frame + area-x area-y area-w area-h + " *corfu-popupinfo*") + corfu-popupinfo--toggle t + corfu-popupinfo--lock-dir area-d + corfu-popupinfo--candidate candidate + corfu-popupinfo--coordinates new-coords) + ;; XXX HACK: Force margin update. For some reason, the call to + ;; `set-window-buffer' in `corfu--make-frame' is not effective the + ;; first time. Why does Emacs have all these quirks? + (when margin-quirk + (set-window-buffer + (frame-root-window corfu-popupinfo--frame) + " *corfu-popupinfo*"))))))) + +(defun corfu-popupinfo--hide () + "Clear the info popup buffer content and hide it." + (corfu--hide-frame corfu-popupinfo--frame)) + +(defun corfu-popupinfo-end (&optional n) + "Scroll text of info popup window to its end. + +If arg N is omitted or nil, scroll to end. If a numerical value, +put point N/10 of the way from the end. If the info popup is not +visible, the other window is moved to beginning or end." + (interactive "P") + (if (corfu-popupinfo--visible-p) + (with-selected-frame corfu-popupinfo--frame + (with-current-buffer " *corfu-popupinfo*" + (with-no-warnings + (end-of-buffer n)))) + (end-of-buffer-other-window n))) + +(defun corfu-popupinfo-beginning (&optional n) + "Scroll text of info popup window to beginning of buffer. + +See `corfu-popupinfo-end' for the argument N." + (interactive "P") + (corfu-popupinfo-end (- 10 (if (numberp n) n 0)))) + +(defun corfu-popupinfo-scroll-up (&optional n) + "Scroll text of info popup window upward N lines. + +If ARG is omitted or nil, scroll upward by a near full screen. +See `scroll-up' for details. If the info popup is not visible, +the other window is scrolled." + (interactive "p") + (if (corfu-popupinfo--visible-p) + (with-selected-frame corfu-popupinfo--frame + (with-current-buffer " *corfu-popupinfo*" + (scroll-up n))) + (scroll-other-window n))) + +(defun corfu-popupinfo-scroll-down (&optional n) + "Scroll text of info popup window down N lines. + +See `corfu-popupinfo-scroll-up' for more details." + (interactive "p") + (corfu-popupinfo-scroll-up (- (or n 1)))) + +(defun corfu-popupinfo--toggle (fun) + "Set documentation getter FUN and toggle popup." + (when (< corfu--index 0) + (corfu-popupinfo--hide) + (user-error "No candidate selected")) + (setq corfu-popupinfo--toggle + (not (and (corfu-popupinfo--visible-p) + (eq corfu-popupinfo--function fun)))) + (if (not corfu-popupinfo--toggle) + (corfu-popupinfo--hide) + (setq corfu-popupinfo--function fun + corfu-popupinfo--candidate nil) + (let ((cand (nth corfu--index corfu--candidates))) + (corfu-popupinfo--show cand) + (unless (corfu-popupinfo--visible-p) + (user-error "No %s available for `%s'" + (car (last (split-string (symbol-name fun) "-+"))) + cand))))) + +(defun corfu-popupinfo-documentation () + "Show or hide documentation in popup. +Behaves like `corfu-popupinfo-toggle'." + (interactive) + (corfu-popupinfo--toggle #'corfu-popupinfo--get-documentation)) + +(defun corfu-popupinfo-location () + "Show or hide location in popup. +Behaves like `corfu-popupinfo-toggle'." + (interactive) + (corfu-popupinfo--toggle #'corfu-popupinfo--get-location)) + +(defun corfu-popupinfo-toggle () + "Toggle the info popup display or hide. + +When using this command to manually hide the info popup, it will +not be displayed until this command is called again, even if +`corfu-popupinfo-delay' is non-nil." + (interactive) + (corfu-popupinfo--toggle corfu-popupinfo--function)) + +;;;###autoload +(define-minor-mode corfu-popupinfo-mode + "Corfu info popup minor mode." + :global t :group 'corfu) + +(cl-defmethod corfu--exhibit :after (&context (corfu-popupinfo-mode (eql t)) &optional _auto) + (when completion-in-region-mode + (setf (alist-get #'corfu-popupinfo-mode minor-mode-overriding-map-alist) + corfu-popupinfo-map) + (when corfu-popupinfo--timer + (cancel-timer corfu-popupinfo--timer) + (setq corfu-popupinfo--timer nil)) + (if (and (>= corfu--index 0) (corfu-popupinfo--visible-p corfu--frame)) + (let ((cand (nth corfu--index corfu--candidates))) + (if-let ((delay (if (consp corfu-popupinfo-delay) + (funcall (if (eq corfu-popupinfo--toggle 'init) #'car #'cdr) + corfu-popupinfo-delay) + corfu-popupinfo-delay)) + (corfu-popupinfo--toggle)) + (if (or (<= delay 0) + (and (equal cand corfu-popupinfo--candidate) + (corfu-popupinfo--visible-p))) + (corfu-popupinfo--show cand) + (when (corfu-popupinfo--visible-p) + (cond + (corfu-popupinfo-hide + (corfu-popupinfo--hide)) + (corfu-popupinfo--candidate + (corfu-popupinfo--show corfu-popupinfo--candidate)))) + (setq corfu-popupinfo--timer + (run-at-time delay nil #'corfu-popupinfo--show cand))) + (unless (equal cand corfu-popupinfo--candidate) + (corfu-popupinfo--hide)))) + (corfu-popupinfo--hide)))) + +(cl-defmethod corfu--teardown :before (_buf &context (corfu-popupinfo-mode (eql t))) + (corfu-popupinfo--hide) + (cl-loop for (k . v) in corfu-popupinfo--initial-state do (set k v)) + (cl-callf2 assq-delete-all #'corfu-popupinfo-mode minor-mode-overriding-map-alist)) + +;; Emacs 28: Do not show Corfu commands with M-X +(dolist (sym '(corfu-popupinfo-scroll-down corfu-popupinfo-scroll-up + corfu-popupinfo-documentation corfu-popupinfo-location + corfu-popupinfo-beginning corfu-popupinfo-end + corfu-popupinfo-toggle)) + (put sym 'completion-predicate #'ignore)) + +(provide 'corfu-popupinfo) +;;; corfu-popupinfo.el ends here diff --git a/emacs/elpa/corfu-20240413.927/corfu-popupinfo.elc b/emacs/elpa/corfu-20240523.752/corfu-popupinfo.elc Binary files differ. diff --git a/emacs/elpa/corfu-20240523.752/corfu-quick.el b/emacs/elpa/corfu-20240523.752/corfu-quick.el @@ -0,0 +1,154 @@ +;;; corfu-quick.el --- Quick keys for Corfu -*- lexical-binding: t -*- + +;; Copyright (C) 2022-2024 Free Software Foundation, Inc. + +;; Author: Luis Henriquez-Perez <luis@luishp.xyz>, Daniel Mendler <mail@daniel-mendler.de> +;; Maintainer: Daniel Mendler <mail@daniel-mendler.de> +;; Created: 2022 +;; Version: 1.4 +;; Package-Requires: ((emacs "27.1") (compat "29.1.4.4") (corfu "1.4")) +;; Homepage: https://github.com/minad/corfu + +;; This file is part of GNU Emacs. + +;; 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 <https://www.gnu.org/licenses/>. + +;;; Commentary: + +;; This package is a Corfu extension, which prefixes candidates with +;; quick keys. Typing these quick keys allows you to select the +;; candidate in front of them. This is designed to be a faster +;; alternative to selecting a candidate with `corfu-next' and +;; `corfu-previous'. +;; (keymap-set corfu-map "M-q" #'corfu-quick-complete) +;; (keymap-set corfu-map "C-q" #'corfu-quick-insert) + +;;; Code: + +(require 'corfu) +(eval-when-compile + (require 'cl-lib)) + +(defcustom corfu-quick1 "asdfgh" + "First level quick keys." + :type 'string + :group 'corfu) + +(defcustom corfu-quick2 "jkluionm" + "Second level quick keys." + :type 'string + :group 'corfu) + +(defface corfu-quick1 + '((((class color) (min-colors 88) (background dark)) + :background "#0050af" :foreground "white" :inherit bold) + (((class color) (min-colors 88) (background light)) + :background "#7feaff" :foreground "black" :inherit bold) + (t :background "blue" :foreground "white" :inherit bold)) + "Face used for the first quick key." + :group 'corfu-faces) + +(defface corfu-quick2 + '((((class color) (min-colors 88) (background dark)) + :background "#7f1f7f" :foreground "white" :inherit bold) + (((class color) (min-colors 88) (background light)) + :background "#ffaaff" :foreground "black" :inherit bold) + (t :background "magenta" :foreground "white" :inherit bold)) + "Face used for the second quick key." + :group 'corfu-faces) + +(defun corfu-quick--keys (two idx) ;; See vertico-quick--keys + "Format quick keys prefix. +IDX is the current candidate index. +TWO is non-nil if two keys should be displayed." + (let ((fst (length corfu-quick1)) + (snd (length corfu-quick2))) + (if (>= idx fst) + (let ((first (elt corfu-quick2 (mod (/ (- idx fst) fst) snd))) + (second (elt corfu-quick1 (mod (- idx fst) fst)))) + (cond + ((eq first two) + (list + (concat " " (propertize (char-to-string second) 'face 'corfu-quick1)) + (cons second (+ corfu--scroll idx)))) + (two + (list " ")) + (t + (list + (concat (propertize (char-to-string first) 'face 'corfu-quick1) + (propertize (char-to-string second) 'face 'corfu-quick2)) + (cons first (list first)))))) + (let ((first (elt corfu-quick1 (mod idx fst)))) + (if two + (list " ") + (list + (concat (propertize (char-to-string first) 'face 'corfu-quick1) " ") + (cons first (+ corfu--scroll idx)))))))) + +(defun corfu-quick--read (&optional first) + "Read quick key given FIRST pressed key." + (cl-letf* ((list nil) + (space1 (propertize " " 'display + `(space :width + (+ 0.5 (,(alist-get + 'child-frame-border-width + corfu--frame-parameters)))))) + (space2 #(" " 0 1 (display (space :width 0.5)))) + (orig (symbol-function #'corfu--affixate)) + ((symbol-function #'corfu--affixate) + (lambda (cands) + (setq cands (cdr (funcall orig cands))) + (cl-loop for cand in cands for index from 0 do + (pcase-let ((`(,keys . ,events) (corfu-quick--keys first index))) + (setq list (nconc events list)) + (setf (cadr cand) (concat space1 (propertize " " 'display keys) space2)))) + (cons t cands))) + ;; Increase minimum width to avoid odd jumping + (corfu-min-width (+ 3 corfu-min-width))) + (corfu--candidates-popup + (posn-at-point (+ (car completion-in-region--data) (length corfu--base)))) + (alist-get (read-key) list))) + +;;;###autoload +(defun corfu-quick-jump () + "Jump to candidate using quick keys." + (interactive) + (when (fboundp 'corfu-echo--cancel) + (corfu-echo--cancel)) + (if (= corfu--total 0) + (and (message "No match") nil) + (let ((idx (corfu-quick--read))) + (when (consp idx) (setq idx (corfu-quick--read (car idx)))) + (when idx (setq corfu--index idx))))) + +;;;###autoload +(defun corfu-quick-insert () + "Insert candidate using quick keys." + (interactive) + (when (corfu-quick-jump) + (corfu-insert))) + +;;;###autoload +(defun corfu-quick-complete () + "Complete candidate using quick keys." + (interactive) + (when (corfu-quick-jump) + (corfu-complete))) + +;; Emacs 28: Do not show Corfu commands in M-X +(dolist (sym '(corfu-quick-jump corfu-quick-insert corfu-quick-complete)) + (put sym 'completion-predicate #'ignore)) + +(provide 'corfu-quick) +;;; corfu-quick.el ends here diff --git a/emacs/elpa/corfu-20240413.927/corfu-quick.elc b/emacs/elpa/corfu-20240523.752/corfu-quick.elc Binary files differ. diff --git a/emacs/elpa/corfu-20240523.752/corfu.el b/emacs/elpa/corfu-20240523.752/corfu.el @@ -0,0 +1,1395 @@ +;;; corfu.el --- COmpletion in Region FUnction -*- lexical-binding: t -*- + +;; Copyright (C) 2021-2024 Free Software Foundation, Inc. + +;; Author: Daniel Mendler <mail@daniel-mendler.de> +;; Maintainer: Daniel Mendler <mail@daniel-mendler.de> +;; Created: 2021 +;; Version: 1.4 +;; Package-Requires: ((emacs "27.1") (compat "29.1.4.4")) +;; Homepage: https://github.com/minad/corfu +;; Keywords: abbrev, convenience, matching, completion, text + +;; This file is part of GNU Emacs. + +;; 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 <https://www.gnu.org/licenses/>. + +;;; Commentary: + +;; Corfu enhances in-buffer completion with a small completion popup. +;; The current candidates are shown in a popup below or above the +;; point. The candidates can be selected by moving up and down. +;; Corfu is the minimalistic in-buffer completion counterpart of the +;; Vertico minibuffer UI. + +;;; Code: + +(require 'compat) +(eval-when-compile + (require 'cl-lib) + (require 'subr-x)) + +(defgroup corfu nil + "COmpletion in Region FUnction." + :link '(info-link :tag "Info Manual" "(corfu)") + :link '(url-link :tag "Homepage" "https://github.com/minad/corfu") + :link '(emacs-library-link :tag "Library Source" "corfu.el") + :group 'convenience + :group 'tools + :group 'matching + :prefix "corfu-") + +(defcustom corfu-count 10 + "Maximal number of candidates to show." + :type 'natnum) + +(defcustom corfu-scroll-margin 2 + "Number of lines at the top and bottom when scrolling. +The value should lie between 0 and corfu-count/2." + :type 'natnum) + +(defcustom corfu-min-width 15 + "Popup minimum width in characters." + :type 'natnum) + +(defcustom corfu-max-width 100 + "Popup maximum width in characters." + :type 'natnum) + +(defcustom corfu-cycle nil + "Enable cycling for `corfu-next' and `corfu-previous'." + :type 'boolean) + +(defcustom corfu-on-exact-match 'insert + "Configure how a single exact match should be handled. +- nil: No special handling, continue completion. +- insert: Insert candidate, quit and call the `:exit-function'. +- quit: Quit completion without further action. +- show: Initiate completion even for a single match only." + :type '(choice (const insert) (const show) (const quit) (const nil))) + +(defcustom corfu-continue-commands + ;; nil is undefined command + '(nil ignore universal-argument universal-argument-more digit-argument + "\\`corfu-" "\\`scroll-other-window") + "Continue Corfu completion after executing these commands. +The list can container either command symbols or regular expressions." + :type '(repeat (choice regexp symbol))) + +(defcustom corfu-preview-current 'insert + "Preview currently selected candidate. +If the variable has the value `insert', the candidate is automatically +inserted on further input." + :type '(choice boolean (const insert))) + +(defcustom corfu-preselect 'valid + "Configure if the prompt or first candidate is preselected. +- prompt: Always select the prompt. +- first: Always select the first candidate. +- valid: Only select the prompt if valid and not equal to the first candidate. +- directory: Like first, but select the prompt if it is a directory." + :type '(choice (const prompt) (const valid) (const first) (const directory))) + +(defcustom corfu-separator ?\s + "Component separator character. +The character used for separating components in the input. The presence +of this separator character will inhibit quitting at completion +boundaries, so that any further characters can be entered. To enter the +first separator character, call `corfu-insert-separator' (bound to M-SPC +by default). Useful for multi-component completion styles such as +Orderless." + :type 'character) + +(defcustom corfu-quit-at-boundary 'separator + "Automatically quit at completion boundary. +nil: Never quit at completion boundary. +t: Always quit at completion boundary. +separator: Quit at boundary if no `corfu-separator' has been inserted." + :type '(choice boolean (const separator))) + +(defcustom corfu-quit-no-match 'separator + "Automatically quit if no matching candidate is found. +When staying alive even if there is no match a warning message is +shown in the popup. +nil: Stay alive even if there is no match. +t: Quit if there is no match. +separator: Only stay alive if there is no match and +`corfu-separator' has been inserted." + :type '(choice boolean (const separator))) + +(defcustom corfu-left-margin-width 0.5 + "Width of the left margin in units of the character width." + :type 'float) + +(defcustom corfu-right-margin-width 0.5 + "Width of the right margin in units of the character width." + :type 'float) + +(defcustom corfu-bar-width 0.2 + "Width of the bar in units of the character width." + :type 'float) + +(defcustom corfu-margin-formatters nil + "Registry for margin formatter functions. +Each function of the list is called with the completion metadata as +argument until an appropriate formatter is found. The function should +return a formatter function, which takes the candidate string and must +return a string, possibly an icon." + :type 'hook) + +(defcustom corfu-sort-function #'corfu-sort-length-alpha + "Default sorting function. +This function is used if the completion table does not specify a +`display-sort-function'." + :type `(choice + (const :tag "No sorting" nil) + (const :tag "By length and alpha" ,#'corfu-sort-length-alpha) + (function :tag "Custom function"))) + +(defcustom corfu-sort-override-function nil + "Override sort function which overrides the `display-sort-function'. +This function is used even if a completion table specifies its +own sort function." + :type '(choice (const nil) function)) + +(defcustom corfu-auto-prefix 3 + "Minimum length of prefix for auto completion. +The completion backend can override this with +:company-prefix-length. It is *not recommended* to use a small +prefix length (below 2), since this will create high load for +Emacs. See also `corfu-auto-delay'." + :type 'natnum) + +(defcustom corfu-auto-delay 0.2 + "Delay for auto completion. +It is *not recommended* to use a short delay or even 0, since +this will create high load for Emacs, in particular if executing +the completion backend is costly." + :type 'float) + +(defcustom corfu-auto-commands + '("self-insert-command\\'" "delete-backward-char\\'" "\\`backward-delete-char" + c-electric-colon c-electric-lt-gt c-electric-slash c-scope-operator) + "Commands which initiate auto completion. +The list can container either command symbols or regular expressions." + :type '(repeat (choice regexp symbol))) + +(defcustom corfu-auto nil + "Enable auto completion. +See also the settings `corfu-auto-delay', `corfu-auto-prefix' and +`corfu-auto-commands'." + :type 'boolean) + +(defgroup corfu-faces nil + "Faces used by Corfu." + :group 'corfu + :group 'faces) + +(defface corfu-default + '((((class color) (min-colors 88) (background dark)) :background "#191a1b") + (((class color) (min-colors 88) (background light)) :background "#f0f0f0") + (t :background "gray")) + "Default face, foreground and background colors used for the popup.") + +(defface corfu-current + '((((class color) (min-colors 88) (background dark)) + :background "#00415e" :foreground "white") + (((class color) (min-colors 88) (background light)) + :background "#c0efff" :foreground "black") + (t :background "blue" :foreground "white")) + "Face used to highlight the currently selected candidate.") + +(defface corfu-bar + '((((class color) (min-colors 88) (background dark)) :background "#a8a8a8") + (((class color) (min-colors 88) (background light)) :background "#505050") + (t :background "gray")) + "The background color is used for the scrollbar indicator.") + +(defface corfu-border + '((((class color) (min-colors 88) (background dark)) :background "#323232") + (((class color) (min-colors 88) (background light)) :background "#d7d7d7") + (t :background "gray")) + "The background color used for the thin border.") + +(defface corfu-annotations + '((t :inherit completions-annotations)) + "Face used for annotations.") + +(defface corfu-deprecated + '((t :inherit shadow :strike-through t)) + "Face used for deprecated candidates.") + +(defvar-keymap corfu-mode-map + :doc "Keymap used when `corfu-mode' is active.") + +(defvar-keymap corfu-map + :doc "Keymap used when popup is shown." + "<remap> <move-beginning-of-line>" #'corfu-prompt-beginning + "<remap> <move-end-of-line>" #'corfu-prompt-end + "<remap> <beginning-of-buffer>" #'corfu-first + "<remap> <end-of-buffer>" #'corfu-last + "<remap> <scroll-down-command>" #'corfu-scroll-down + "<remap> <scroll-up-command>" #'corfu-scroll-up + "<remap> <next-line>" #'corfu-next + "<remap> <previous-line>" #'corfu-previous + "<remap> <completion-at-point>" #'corfu-complete + "<remap> <keyboard-escape-quit>" #'corfu-reset + "<down>" #'corfu-next + "<up>" #'corfu-previous + ;; XXX C-a is bound because of Eshell. + ;; Ideally Eshell would remap move-beginning-of-line. + "C-a" #'corfu-prompt-beginning + ;; XXX [tab] is bound because of org-mode and orgtbl-mode. + ;; The binding should be removed from org-mode-map. + "<tab>" #'corfu-complete + "M-n" #'corfu-next + "M-p" #'corfu-previous + "C-g" #'corfu-quit + "RET" #'corfu-insert + "TAB" #'corfu-complete + "M-TAB" #'corfu-expand + "M-g" 'corfu-info-location + "M-h" 'corfu-info-documentation + "M-SPC" #'corfu-insert-separator) + +(defvar corfu--auto-timer (timer-create) + "Auto completion timer.") + +(defvar corfu--candidates nil + "List of candidates.") + +(defvar corfu--metadata nil + "Completion metadata.") + +(defvar corfu--base "" + "Base string, which is concatenated with the candidate.") + +(defvar corfu--total 0 + "Length of the candidate list `corfu--candidates'.") + +(defvar corfu--hilit #'identity + "Lazy candidate highlighting function.") + +(defvar corfu--index -1 + "Index of current candidate or negative for prompt selection.") + +(defvar corfu--preselect -1 + "Index of preselected candidate, negative for prompt selection.") + +(defvar corfu--scroll 0 + "Scroll position.") + +(defvar corfu--input nil + "Cons of last prompt contents and point.") + +(defvar corfu--preview-ov nil + "Current candidate overlay.") + +(defvar corfu--change-group nil + "Undo change group.") + +(defvar corfu--frame nil + "Popup frame.") + +(defconst corfu--initial-state + (mapcar + (lambda (k) (cons k (symbol-value k))) + '(corfu--base + corfu--candidates + corfu--hilit + corfu--index + corfu--preselect + corfu--scroll + corfu--input + corfu--total + corfu--preview-ov + corfu--change-group + corfu--metadata)) + "Initial Corfu state.") + +(defvar corfu--frame-parameters + '((no-accept-focus . t) + (no-focus-on-map . t) + (min-width . t) + (min-height . t) + (border-width . 0) + (outer-border-width . 0) + (internal-border-width . 1) + (child-frame-border-width . 1) + (left-fringe . 0) + (right-fringe . 0) + (vertical-scroll-bars . nil) + (horizontal-scroll-bars . nil) + (menu-bar-lines . 0) + (tool-bar-lines . 0) + (tab-bar-lines . 0) + (no-other-frame . t) + (unsplittable . t) + (undecorated . t) + (cursor-type . nil) + (no-special-glyphs . t) + (desktop-dont-save . t)) + "Default child frame parameters.") + +(defvar corfu--buffer-parameters + '((mode-line-format . nil) + (header-line-format . nil) + (tab-line-format . nil) + (tab-bar-format . nil) ;; Emacs 28 tab-bar-format + (frame-title-format . "") + (truncate-lines . t) + (cursor-in-non-selected-windows . nil) + (cursor-type . nil) + (show-trailing-whitespace . nil) + (display-line-numbers . nil) + (left-fringe-width . nil) + (right-fringe-width . nil) + (left-margin-width . 0) + (right-margin-width . 0) + (fringes-outside-margins . 0) + (fringe-indicator-alist . nil) + (indicate-empty-lines . nil) + (indicate-buffer-boundaries . nil) + (buffer-read-only . t)) + "Default child frame buffer parameters.") + +(defvar corfu--mouse-ignore-map + (let ((map (make-sparse-keymap))) + (dotimes (i 7) + (dolist (k '(mouse down-mouse drag-mouse double-mouse triple-mouse)) + (keymap-set map (format "<%s-%s>" k (1+ i)) #'ignore))) + map) + "Ignore all mouse clicks.") + +(defun corfu--replace (beg end str) + "Replace range between BEG and END with STR." + (unless (equal str (buffer-substring-no-properties beg end)) + ;; bug#55205: completion--replace removed properties as an unwanted + ;; side-effect. We also don't want to leave text properties. + (completion--replace beg end (substring-no-properties str)))) + +(defun corfu--capf-wrapper (fun &optional prefix) + "Wrapper for `completion-at-point' FUN. +The wrapper determines if the Capf is applicable at the current +position and performs sanity checking on the returned result. +For non-exclusive Capfs wrapper additionally checks if the +current input can be completed successfully. PREFIX is a prefix +length override, set to t for manual completion." + (pcase (funcall fun) + ((and res `(,beg ,end ,table . ,plist)) + (and (integer-or-marker-p beg) ;; Valid Capf result + (<= beg (point) end) ;; Sanity checking + ;; When auto completing, check the prefix length! + (let ((len (or prefix + (plist-get plist :company-prefix-length) + (- (point) beg)))) + (or (eq len t) (>= len corfu-auto-prefix))) + ;; For non-exclusive Capfs, check for valid completion. + (or (not (eq 'no (plist-get plist :exclusive))) + (let* ((str (buffer-substring-no-properties beg end)) + (pt (- (point) beg)) + (pred (plist-get plist :predicate)) + (md (completion-metadata (substring str 0 pt) table pred))) + ;; We use `completion-try-completion' to check if there are + ;; completions. The upstream `completion--capf-wrapper' uses + ;; `try-completion' which is incorrect since it only checks for + ;; prefix completions. + (completion-try-completion str table pred pt md))) + (cons fun res))))) + +(defun corfu--make-buffer (name) + "Create buffer with NAME." + (let ((fr face-remapping-alist) + (ls line-spacing) + (buffer (get-buffer-create name))) + (with-current-buffer buffer + ;;; XXX HACK install mouse ignore map + (use-local-map corfu--mouse-ignore-map) + (dolist (var corfu--buffer-parameters) + (set (make-local-variable (car var)) (cdr var))) + (setq-local face-remapping-alist (copy-tree fr) + line-spacing ls) + (cl-pushnew 'corfu-default (alist-get 'default face-remapping-alist)) + buffer))) + +(defvar x-gtk-resize-child-frames) ;; Not present on non-gtk builds +(defvar corfu--gtk-resize-child-frames + (let ((case-fold-search t)) + ;; XXX HACK to fix resizing on gtk3/gnome taken from posframe.el + ;; More information: + ;; * https://github.com/minad/corfu/issues/17 + ;; * https://gitlab.gnome.org/GNOME/mutter/-/issues/840 + ;; * https://lists.gnu.org/archive/html/emacs-devel/2020-02/msg00001.html + (and (string-match-p "gtk3" system-configuration-features) + (string-match-p "gnome\\|cinnamon" + (or (getenv "XDG_CURRENT_DESKTOP") + (getenv "DESKTOP_SESSION") "")) + 'resize-mode))) + +;; Function adapted from posframe.el by tumashu +(defun corfu--make-frame (frame x y width height buffer) + "Show BUFFER in child frame at X/Y with WIDTH/HEIGHT. +FRAME is the existing frame." + (when-let (((frame-live-p frame)) + (timer (frame-parameter frame 'corfu--hide-timer))) + (cancel-timer timer) + (set-frame-parameter frame 'corfu--hide-timer nil)) + (let* ((window-min-height 1) + (window-min-width 1) + (inhibit-redisplay t) + (x-gtk-resize-child-frames corfu--gtk-resize-child-frames) + (before-make-frame-hook) + (after-make-frame-functions) + (parent (window-frame))) + (unless (and (frame-live-p frame) + (eq (frame-parent frame) + (and (not (bound-and-true-p exwm--connection)) parent)) + ;; If there is more than one window, `frame-root-window' may + ;; return nil. Recreate the frame in this case. + (window-live-p (frame-root-window frame))) + (when frame (delete-frame frame)) + (setq frame (make-frame + `((parent-frame . ,parent) + (minibuffer . ,(minibuffer-window parent)) + (width . 0) (height . 0) (visibility . nil) + ,@corfu--frame-parameters)))) + ;; XXX HACK Setting the same frame-parameter/face-background is not a nop. + ;; Check before applying the setting. Without the check, the frame flickers + ;; on Mac. We have to apply the face background before adjusting the frame + ;; parameter, otherwise the border is not updated. + (let ((new (face-attribute 'corfu-border :background nil 'default))) + (unless (equal (face-attribute 'internal-border :background frame 'default) new) + (set-face-background 'internal-border new frame)) + ;; XXX The Emacs Mac Port does not support `internal-border', we also have + ;; to set `child-frame-border'. + (unless (or (not (facep 'child-frame-border)) + (equal (face-attribute 'child-frame-border :background frame 'default) new)) + (set-face-background 'child-frame-border new frame))) + ;; Reset frame parameters if they changed. For example `tool-bar-mode' + ;; overrides the parameter `tool-bar-lines' for every frame, including child + ;; frames. The child frame API is a pleasure to work with. It is full of + ;; lovely surprises. + (let* ((is (frame-parameters frame)) + (should `((background-color + . ,(face-attribute 'corfu-default :background nil 'default)) + (font . ,(frame-parameter parent 'font)) + ,@corfu--frame-parameters)) + (diff (cl-loop for p in should for (k . v) = p + unless (equal (alist-get k is) v) collect p))) + (when diff (modify-frame-parameters frame diff))) + (let ((win (frame-root-window frame))) + (unless (eq (window-buffer win) buffer) + (set-window-buffer win buffer)) + ;; Disallow selection of root window (gh:minad/corfu#63) + (set-window-parameter win 'no-delete-other-windows t) + (set-window-parameter win 'no-other-window t) + ;; Mark window as dedicated to prevent frame reuse (gh:minad/corfu#60) + (set-window-dedicated-p win t)) + (redirect-frame-focus frame parent) + (set-frame-size frame width height t) + (pcase-let ((`(,px . ,py) (frame-position frame))) + (unless (and (= x px) (= y py)) + (set-frame-position frame x y)))) + (make-frame-visible frame) + ;; Unparent child frame if EXWM is used, otherwise EXWM buffers are drawn on + ;; top of the Corfu child frame. + (when (and (bound-and-true-p exwm--connection) (frame-parent frame)) + (set-frame-parameter frame 'parent-frame nil)) + frame) + +(defun corfu--hide-frame-deferred (frame) + "Deferred hiding of child FRAME." + (when (and (frame-live-p frame) (frame-visible-p frame)) + (set-frame-parameter frame 'corfu--hide-timer nil) + (make-frame-invisible frame) + (with-current-buffer (window-buffer (frame-root-window frame)) + (with-silent-modifications + (erase-buffer))))) + +(defun corfu--hide-frame (frame) + "Hide child FRAME." + (when (and (frame-live-p frame) (frame-visible-p frame) + (not (frame-parameter frame 'corfu--hide-timer))) + (set-frame-parameter frame 'corfu--hide-timer + (run-at-time 0 nil #'corfu--hide-frame-deferred frame)))) + +(defun corfu--move-to-front (elem list) + "Move ELEM to front of LIST." + ;; In contrast to Vertico, this function handles duplicates. See also the + ;; special deduplication function `corfu--delete-dups' based on + ;; `equal-including-properties' + (nconc (cl-loop for x in list if (equal x elem) collect x) + (delete elem list))) + +(defun corfu--filter-completions (&rest args) + "Compute all completions for ARGS with lazy highlighting." + (dlet ((completion-lazy-hilit t) (completion-lazy-hilit-fn nil)) + (if (eval-when-compile (>= emacs-major-version 30)) + (cons (apply #'completion-all-completions args) completion-lazy-hilit-fn) + (cl-letf* ((orig-pcm (symbol-function #'completion-pcm--hilit-commonality)) + (orig-flex (symbol-function #'completion-flex-all-completions)) + ((symbol-function #'completion-flex-all-completions) + (lambda (&rest args) + ;; Unfortunately for flex we have to undo the lazy highlighting, since flex uses + ;; the completion-score for sorting, which is applied during highlighting. + (cl-letf (((symbol-function #'completion-pcm--hilit-commonality) orig-pcm)) + (apply orig-flex args)))) + ((symbol-function #'completion-pcm--hilit-commonality) + (lambda (pattern cands) + (setq completion-lazy-hilit-fn + (lambda (x) + ;; `completion-pcm--hilit-commonality' sometimes throws an internal error + ;; for example when entering "/sudo:://u". + (condition-case nil + (car (completion-pcm--hilit-commonality pattern (list x))) + (t x)))) + cands)) + ((symbol-function #'completion-hilit-commonality) + (lambda (cands prefix &optional base) + (setq completion-lazy-hilit-fn + (lambda (x) (car (completion-hilit-commonality (list x) prefix base)))) + (and cands (nconc cands base))))) + (cons (apply #'completion-all-completions args) completion-lazy-hilit-fn))))) + +(defsubst corfu--length-string< (x y) + "Sorting predicate which compares X and Y first by length then by `string<'." + (or (< (length x) (length y)) (and (= (length x) (length y)) (string< x y)))) + +(defmacro corfu--partition! (list form) + "Evaluate FORM for every element and partition LIST." + (cl-with-gensyms (head1 head2 tail1 tail2) + `(let* ((,head1 (cons nil nil)) + (,head2 (cons nil nil)) + (,tail1 ,head1) + (,tail2 ,head2)) + (while ,list + (if (let ((it (car ,list))) ,form) + (progn + (setcdr ,tail1 ,list) + (pop ,tail1)) + (setcdr ,tail2 ,list) + (pop ,tail2)) + (pop ,list)) + (setcdr ,tail1 (cdr ,head2)) + (setcdr ,tail2 nil) + (setq ,list (cdr ,head1))))) + +(defun corfu--move-prefix-candidates-to-front (field cands) + "Move CANDS which match prefix of FIELD to the beginning." + (let* ((word (substring field 0 + (seq-position field corfu-separator))) + (len (length word))) + (corfu--partition! + cands + (and (>= (length it) len) + (eq t (compare-strings word 0 len it 0 len + completion-ignore-case)))))) + +(defun corfu--delete-dups (list) + "Delete `equal-including-properties' consecutive duplicates from LIST." + (let ((beg list)) + (while (cdr beg) + (let ((end (cdr beg))) + (while (equal (car beg) (car end)) (pop end)) + ;; The deduplication is quadratic in the number of duplicates. We can + ;; avoid the quadratic complexity with a hash table which takes + ;; properties into account (available since Emacs 28). + (while (not (eq beg end)) + (let ((dup beg)) + (while (not (eq (cdr dup) end)) + ;; bug#6581: `equal-including-properties' uses `eq' to compare + ;; properties until 29.1. Approximate by comparing + ;; `text-properties-at' position 0. + (if (if (eval-when-compile (< emacs-major-version 29)) + (equal (text-properties-at 0 (car beg)) + (text-properties-at 0 (cadr dup))) + (equal-including-properties (car beg) (cadr dup))) + (setcdr dup (cddr dup)) + (pop dup)))) + (pop beg))))) + list) + +(defun corfu--sort-function () + "Return the sorting function." + (or corfu-sort-override-function + (corfu--metadata-get 'display-sort-function) + corfu-sort-function)) + +(defun corfu--recompute (str pt table pred) + "Recompute state from STR, PT, TABLE and PRED." + (pcase-let* ((before (substring str 0 pt)) + (after (substring str pt)) + (corfu--metadata (completion-metadata before table pred)) + ;; bug#47678: `completion-boundaries' fails for `partial-completion' + ;; if the cursor is moved between the slashes of "~//". + ;; See also vertico.el which has the same issue. + (bounds (condition-case nil + (completion-boundaries before table pred after) + (t (cons 0 (length after))))) + (field (substring str (car bounds) (+ pt (cdr bounds)))) + (completing-file (eq (corfu--metadata-get 'category) 'file)) + (`(,all . ,hl) (corfu--filter-completions str table pred pt corfu--metadata)) + (base (or (when-let ((z (last all))) (prog1 (cdr z) (setcdr z nil))) 0)) + (corfu--base (substring str 0 base)) + (pre nil)) + ;; Filter the ignored file extensions. We cannot use modified predicate for + ;; this filtering, since this breaks the special casing in the + ;; `completion-file-name-table' for `file-exists-p' and `file-directory-p'. + (when completing-file (setq all (completion-pcm--filename-try-filter all))) + ;; Sort using the `display-sort-function' or the Corfu sort functions, and + ;; delete duplicates with respect to `equal-including-properties'. This is + ;; a deviation from the Vertico completion UI with more aggressive + ;; deduplication, where candidates are compared with `equal'. Corfu + ;; preserves candidates which differ in their text properties. Corfu tries + ;; to preserve text properties as much as possible, when calling the + ;; `:exit-function' to help Capfs with candidate disambiguation. This + ;; matters in particular for Lsp backends, which produce duplicates for + ;; overloaded methods. + (setq all (corfu--delete-dups (funcall (or (corfu--sort-function) #'identity) all)) + all (corfu--move-prefix-candidates-to-front field all)) + (when (and completing-file (not (string-suffix-p "/" field))) + (setq all (corfu--move-to-front (concat field "/") all))) + (setq all (corfu--move-to-front field all) + pre (if (or (eq corfu-preselect 'prompt) (not all) + (and completing-file (eq corfu-preselect 'directory) + (= (length corfu--base) (length str)) + (test-completion str table pred)) + (and (eq corfu-preselect 'valid) + (not (equal field (car all))) + (not (and completing-file (equal (concat field "/") (car all)))) + (test-completion str table pred))) + -1 0)) + `((corfu--base . ,corfu--base) + (corfu--metadata . ,corfu--metadata) + (corfu--candidates . ,all) + (corfu--total . ,(length all)) + (corfu--hilit . ,(or hl #'identity)) + (corfu--preselect . ,pre) + (corfu--index . ,(or (and (>= corfu--index 0) (/= corfu--index corfu--preselect) + (seq-position all (nth corfu--index corfu--candidates))) + pre))))) + +(defun corfu--update (&optional interruptible) + "Update state, optionally INTERRUPTIBLE." + (pcase-let* ((`(,beg ,end ,table ,pred . ,_) completion-in-region--data) + (pt (- (point) beg)) + (str (buffer-substring-no-properties beg end)) + (input (cons str pt))) + (unless (equal corfu--input input) + ;; Redisplay such that the input is immediately shown before the expensive + ;; candidate recomputation (gh:minad/corfu#48). See also corresponding + ;; issue gh:minad/vertico#89. + (when interruptible (redisplay)) + ;; Bind non-essential=t to prevent Tramp from opening new connections, + ;; without the user explicitly requesting it via M-TAB. + (pcase (let ((non-essential t)) + ;; XXX Guard against errors during candidate generation. + ;; bug#61274: `dabbrev-capf' signals errors. + (condition-case err + (if interruptible + (while-no-input (corfu--recompute str pt table pred)) + (corfu--recompute str pt table pred)) + (error + (message "Corfu completion error: %s" (error-message-string err)) + t))) + ('nil (keyboard-quit)) + ((and state (pred consp)) + (setq corfu--input input) + (dolist (s state) (set (car s) (cdr s)))))) + input)) + +(defun corfu--match-symbol-p (pattern sym) + "Return non-nil if SYM is matching an element of the PATTERN list." + (cl-loop with case-fold-search = nil + for x in (and (symbolp sym) pattern) + thereis (if (symbolp x) + (eq sym x) + (string-match-p x (symbol-name sym))))) + +(defun corfu--metadata-get (prop) + "Return PROP from completion metadata." + ;; Note: Do not use `completion-metadata-get' in order to avoid Marginalia. + ;; The Marginalia annotators are too heavy for the Corfu popup! + (cdr (assq prop corfu--metadata))) + +(defun corfu--format-candidates (cands) + "Format annotated CANDS." + (setq cands + (cl-loop for c in cands collect + (cl-loop for s in c collect + (replace-regexp-in-string "[ \t]*\n[ \t]*" " " s)))) + (let* ((cw (cl-loop for x in cands maximize (string-width (car x)))) + (pw (cl-loop for x in cands maximize (string-width (cadr x)))) + (sw (cl-loop for x in cands maximize (string-width (caddr x)))) + (width (+ pw cw sw)) + ;; -4 because of margins and some additional safety + (max-width (min corfu-max-width (- (frame-width) 4)))) + (when (> width max-width) + (setq sw (max 0 (- max-width pw cw)) + width (+ pw cw sw))) + (when (< width corfu-min-width) + (setq cw (+ cw (- corfu-min-width width)) + width corfu-min-width)) + (setq width (min width max-width)) + (list pw width + (cl-loop for (cand prefix suffix) in cands collect + (truncate-string-to-width + (concat + prefix (make-string (max 0 (- pw (string-width prefix))) ?\s) + cand + (when (/= sw 0) + (make-string (+ (max 0 (- cw (string-width cand))) + (max 0 (- sw (string-width suffix)))) + ?\s)) + suffix) + width))))) + +(defun corfu--compute-scroll () + "Compute new scroll position." + (let ((off (max (min corfu-scroll-margin (/ corfu-count 2)) 0)) + (corr (if (= corfu-scroll-margin (/ corfu-count 2)) (1- (mod corfu-count 2)) 0))) + (setq corfu--scroll (min (max 0 (- corfu--total corfu-count)) + (max 0 (+ corfu--index off 1 (- corfu-count)) + (min (- corfu--index off corr) corfu--scroll)))))) + +(defun corfu--candidates-popup (pos) + "Show candidates popup at POS." + (corfu--compute-scroll) + (pcase-let* ((last (min (+ corfu--scroll corfu-count) corfu--total)) + (bar (ceiling (* corfu-count corfu-count) corfu--total)) + (lo (min (- corfu-count bar 1) (floor (* corfu-count corfu--scroll) corfu--total))) + (`(,mf . ,acands) (corfu--affixate + (cl-loop repeat corfu-count + for c in (nthcdr corfu--scroll corfu--candidates) + collect (funcall corfu--hilit (substring c))))) + (`(,pw ,width ,fcands) (corfu--format-candidates acands)) + ;; Disable the left margin if a margin formatter is active. + (corfu-left-margin-width (if mf 0 corfu-left-margin-width))) + ;; Nonlinearity at the end and the beginning + (when (/= corfu--scroll 0) + (setq lo (max 1 lo))) + (when (/= last corfu--total) + (setq lo (min (- corfu-count bar 2) lo))) + (corfu--popup-show pos pw width fcands (- corfu--index corfu--scroll) + (and (> corfu--total corfu-count) lo) bar))) + +(defun corfu--range-valid-p () + "Check the completion range, return non-nil if valid." + (pcase-let ((buf (current-buffer)) + (pt (point)) + (`(,beg ,end . ,_) completion-in-region--data)) + (and beg end + (eq buf (marker-buffer beg)) (eq buf (window-buffer)) + (<= beg pt end) + (save-excursion (goto-char beg) (<= (pos-bol) pt (pos-eol)))))) + +(defun corfu--continue-p () + "Check if completion should continue after a command. +Corfu bails out if the current buffer changed unexpectedly or if +point moved out of range, see `corfu--range-valid-p'. Also the +input must satisfy the `completion-in-region-mode--predicate' and +the last command must be listed in `corfu-continue-commands'." + (and (corfu--range-valid-p) + ;; We keep Corfu alive if a `overriding-terminal-local-map' is + ;; installed, e.g., the `universal-argument-map'. It would be good to + ;; think about a better criterion instead. Unfortunately relying on + ;; `this-command' alone is insufficient, since the value of + ;; `this-command' gets clobbered in the case of transient keymaps. + (or overriding-terminal-local-map + ;; Check if it is an explicitly listed continue command + (corfu--match-symbol-p corfu-continue-commands this-command) + (pcase-let ((`(,beg ,end . ,_) completion-in-region--data)) + (and (or (not corfu--input) (< beg end)) ;; Check for empty input + (or (not corfu-quit-at-boundary) ;; Check separator or predicate + (and (eq corfu-quit-at-boundary 'separator) + (or (eq this-command #'corfu-insert-separator) + ;; with separator, any further chars allowed + (seq-contains-p (car corfu--input) corfu-separator))) + (funcall completion-in-region-mode--predicate))))))) + +(defun corfu--preview-current-p () + "Return t if the selected candidate is previewed." + (and corfu-preview-current (>= corfu--index 0) (/= corfu--index corfu--preselect))) + +(defun corfu--preview-current (beg end) + "Show current candidate as overlay given BEG and END." + (when (corfu--preview-current-p) + (setq beg (+ beg (length corfu--base)) + corfu--preview-ov (make-overlay beg end nil)) + (overlay-put corfu--preview-ov 'priority 1000) + (overlay-put corfu--preview-ov 'window (selected-window)) + (overlay-put corfu--preview-ov (if (= beg end) 'after-string 'display) + (nth corfu--index corfu--candidates)))) + +(defun corfu--window-change (_) + "Window and buffer change hook which quits Corfu." + (unless (corfu--range-valid-p) + (corfu-quit))) + +(defun corfu--post-command () + "Refresh Corfu after last command." + (if (corfu--continue-p) + (corfu--exhibit) + (corfu-quit)) + (when corfu-auto + (corfu--auto-post-command))) + +(defun corfu--goto (index) + "Go to candidate with INDEX." + (setq corfu--index (max corfu--preselect (min index (1- corfu--total))))) + +(defun corfu--exit-function (str status cands) + "Call the `:exit-function' with STR and STATUS. +Lookup STR in CANDS to restore text properties." + (when-let ((exit (plist-get completion-extra-properties :exit-function))) + (funcall exit (or (car (member str cands)) str) status))) + +(defun corfu--done (str status cands) + "Exit completion and call the exit function with STR and STATUS. +Lookup STR in CANDS to restore text properties." + (let ((completion-extra-properties (nth 4 completion-in-region--data))) + ;; For successful completions, amalgamate undo operations, + ;; such that completion can be undone in a single step. + (undo-amalgamate-change-group corfu--change-group) + (corfu-quit) + (corfu--exit-function str status cands))) + +(defun corfu--setup (beg end table pred) + "Setup Corfu completion state. +See `completion-in-region' for the arguments BEG, END, TABLE, PRED." + (setq beg (if (markerp beg) beg (copy-marker beg)) + end (if (and (markerp end) (marker-insertion-type end)) end (copy-marker end t)) + completion-in-region--data (list beg end table pred completion-extra-properties)) + (completion-in-region-mode 1) + (activate-change-group (setq corfu--change-group (prepare-change-group))) + (setcdr (assq #'completion-in-region-mode minor-mode-overriding-map-alist) corfu-map) + (add-hook 'pre-command-hook #'corfu--prepare nil 'local) + (add-hook 'window-selection-change-functions #'corfu--window-change nil 'local) + (add-hook 'window-buffer-change-functions #'corfu--window-change nil 'local) + (add-hook 'post-command-hook #'corfu--post-command) + ;; Disable default post-command handling, since we have our own + ;; checks in `corfu--post-command'. + (remove-hook 'post-command-hook #'completion-in-region--postch) + (let ((sym (make-symbol "corfu--teardown")) + (buf (current-buffer))) + (fset sym (lambda () + ;; Ensure that the tear-down runs in the correct buffer, if still alive. + (unless completion-in-region-mode + (remove-hook 'completion-in-region-mode-hook sym) + (corfu--teardown buf)))) + (add-hook 'completion-in-region-mode-hook sym))) + +(defun corfu--in-region (&rest args) + "Corfu completion in region function called with ARGS." + ;; XXX We can get an endless loop when `completion-in-region-function' is set + ;; globally to `corfu--in-region'. This should never happen. + (apply (if (corfu--popup-support-p) #'corfu--in-region-1 + (default-value 'completion-in-region-function)) + args)) + +(defun corfu--in-region-1 (beg end table &optional pred) + "Complete in region, see `completion-in-region' for BEG, END, TABLE, PRED." + (barf-if-buffer-read-only) + ;; Restart the completion. This can happen for example if C-M-/ + ;; (`dabbrev-completion') is pressed while the Corfu popup is already open. + (when completion-in-region-mode (corfu-quit)) + (let* ((pt (max 0 (- (point) beg))) + (str (buffer-substring-no-properties beg end)) + (metadata (completion-metadata (substring str 0 pt) table pred)) + (threshold (completion--cycle-threshold metadata)) + (completion-in-region-mode-predicate + (or completion-in-region-mode-predicate #'always))) + (pcase (completion-try-completion str table pred pt metadata) + ('nil (corfu--message "No match") nil) + ('t (goto-char end) + (corfu--message "Sole match") + (if (eq corfu-on-exact-match 'show) + (corfu--setup beg end table pred) + (corfu--exit-function + str 'finished + (alist-get 'corfu--candidates (corfu--recompute str pt table pred)))) + t) + (`(,newstr . ,newpt) + (setq beg (if (markerp beg) beg (copy-marker beg)) + end (copy-marker end t)) + (corfu--replace beg end newstr) + (goto-char (+ beg newpt)) + (let* ((state (corfu--recompute newstr newpt table pred)) + (base (alist-get 'corfu--base state)) + (total (alist-get 'corfu--total state)) + (candidates (alist-get 'corfu--candidates state))) + (if (= total 1) + ;; If completion is finished and cannot be further completed, and + ;; the value of `corfu-on-exact-match' is not 'show, return + ;; 'finished. Otherwise setup the Corfu popup. + (if (or (eq corfu-on-exact-match 'show) + (consp (completion-try-completion + newstr table pred newpt + (completion-metadata newstr table pred)))) + (corfu--setup beg end table pred) + (corfu--exit-function newstr 'finished candidates)) + (if (or (= total 0) (not threshold) + (and (not (eq threshold t)) (< threshold total))) + (corfu--setup beg end table pred) + (corfu--cycle-candidates total candidates (+ (length base) beg) end) + ;; Do not show Corfu when "trivially" cycling, i.e., + ;; when the completion is finished after the candidate. + (unless (equal (completion-boundaries (car candidates) table pred "") + '(0 . 0)) + (corfu--setup beg end table pred))))) + t)))) + +(defun corfu--message (&rest msg) + "Show completion MSG." + (let (message-log-max) (apply #'message msg))) + +(defun corfu--cycle-candidates (total cands beg end) + "Cycle between TOTAL number of CANDS. +See `completion-in-region' for the arguments BEG, END, TABLE, PRED." + (let* ((idx 0) + (map (make-sparse-keymap)) + (replace (lambda () + (interactive) + (corfu--replace beg end (nth idx cands)) + (corfu--message "Cycling %d/%d..." (1+ idx) total) + (setq idx (mod (1+ idx) total)) + (set-transient-map map)))) + (define-key map [remap completion-at-point] replace) + (define-key map [remap corfu-complete] replace) + (define-key map (vector last-command-event) replace) + (funcall replace))) + +(defun corfu--auto-complete-deferred (&optional tick) + "Initiate auto completion if TICK did not change." + (when (and (not completion-in-region-mode) + (or (not tick) (equal tick (corfu--auto-tick)))) + (pcase (while-no-input ;; Interruptible Capf query + (run-hook-wrapped 'completion-at-point-functions #'corfu--capf-wrapper)) + (`(,fun ,beg ,end ,table . ,plist) + (let ((completion-in-region-mode-predicate + (lambda () + (when-let ((newbeg (car-safe (funcall fun)))) + (= newbeg beg)))) + (completion-extra-properties plist)) + (corfu--setup beg end table (plist-get plist :predicate)) + (corfu--exhibit 'auto)))))) + +(defun corfu--auto-post-command () + "Post command hook which initiates auto completion." + (cancel-timer corfu--auto-timer) + (if (and (not completion-in-region-mode) + (not defining-kbd-macro) + (not buffer-read-only) + (corfu--match-symbol-p corfu-auto-commands this-command) + (corfu--popup-support-p)) + (if (<= corfu-auto-delay 0) + (corfu--auto-complete-deferred) + ;; Do not use `timer-set-idle-time' since this leads to + ;; unpredictable pauses, in particular with `flyspell-mode'. + (timer-set-time corfu--auto-timer + (timer-relative-time nil corfu-auto-delay)) + (timer-set-function corfu--auto-timer #'corfu--auto-complete-deferred + (list (corfu--auto-tick))) + (timer-activate corfu--auto-timer)))) + +(defun corfu--auto-tick () + "Return the current tick/status of the buffer. +Auto completion is only performed if the tick did not change." + (list (selected-window) (current-buffer) (buffer-chars-modified-tick) (point))) + +(cl-defgeneric corfu--popup-show (pos off width lines &optional curr lo bar) + "Show LINES as popup at POS - OFF. +WIDTH is the width of the popup. +The current candidate CURR is highlighted. +A scroll bar is displayed from LO to LO+BAR." + (let ((lh (default-line-height))) + (with-current-buffer (corfu--make-buffer " *corfu*") + (let* ((ch (default-line-height)) + (cw (default-font-width)) + (ml (ceiling (* cw corfu-left-margin-width))) + (mr (ceiling (* cw corfu-right-margin-width))) + (bw (ceiling (min mr (* cw corfu-bar-width)))) + (marginl (and (> ml 0) (propertize " " 'display `(space :width (,ml))))) + (marginr (and (> mr 0) (propertize " " 'display `(space :align-to right)))) + (sbar (when (> bw 0) + (concat (propertize " " 'display `(space :align-to (- right (,mr)))) + (propertize " " 'display `(space :width (,(- mr bw)))) + (propertize " " 'face 'corfu-bar 'display `(space :width (,bw)))))) + (pos (posn-x-y pos)) + (width (+ (* width cw) ml mr)) + ;; XXX HACK: Minimum popup height must be at least 1 line of the + ;; parent frame (gh:minad/corfu#261). + (height (max lh (* (length lines) ch))) + (edge (window-inside-pixel-edges)) + (border (alist-get 'internal-border-width corfu--frame-parameters)) + (x (max 0 (min (+ (car edge) (- (or (car pos) 0) ml (* cw off) border)) + (- (frame-pixel-width) width)))) + (yb (+ (cadr edge) (window-tab-line-height) (or (cdr pos) 0) lh)) + (y (if (> (+ yb (* corfu-count ch) lh lh) (frame-pixel-height)) + (- yb height lh border border) + yb)) + (row 0)) + (with-silent-modifications + (erase-buffer) + (insert (mapconcat (lambda (line) + (let ((str (concat marginl line + (if (and lo (<= lo row (+ lo bar))) + sbar + marginr)))) + (when (eq row curr) + (add-face-text-property + 0 (length str) 'corfu-current 'append str)) + (cl-incf row) + str)) + lines "\n")) + (goto-char (point-min))) + (setq corfu--frame (corfu--make-frame corfu--frame x y + width height (current-buffer))))))) + +(cl-defgeneric corfu--popup-hide () + "Hide Corfu popup." + (corfu--hide-frame corfu--frame)) + +(cl-defgeneric corfu--popup-support-p () + "Return non-nil if child frames are supported." + (display-graphic-p)) + +(cl-defgeneric corfu--insert (status) + "Insert current candidate, exit with STATUS if non-nil." + ;; XXX There is a small bug here, depending on interpretation. + ;; When completing "~/emacs/master/li|/calc" where "|" is the + ;; cursor, then the candidate only includes the prefix + ;; "~/emacs/master/lisp/", but not the suffix "/calc". Default + ;; completion has the same problem when selecting in the + ;; *Completions* buffer. See bug#48356. + (pcase-let* ((`(,beg ,end . ,_) completion-in-region--data) + (str (concat corfu--base (nth corfu--index corfu--candidates)))) + (corfu--replace beg end str) + (corfu--goto -1) ;; Reset selection, completion may continue. + (when status (corfu--done str status nil)) + str)) + +(cl-defgeneric corfu--affixate (cands) + "Annotate CANDS with annotation function." + (let* ((completion-extra-properties (nth 4 completion-in-region--data)) + (dep (plist-get completion-extra-properties :company-deprecated)) + (mf (run-hook-with-args-until-success 'corfu-margin-formatters corfu--metadata))) + (setq cands + (if-let ((aff (or (corfu--metadata-get 'affixation-function) + (plist-get completion-extra-properties :affixation-function)))) + (funcall aff cands) + (if-let ((ann (or (corfu--metadata-get 'annotation-function) + (plist-get completion-extra-properties :annotation-function)))) + (cl-loop for cand in cands collect + (let ((suff (or (funcall ann cand) ""))) + ;; The default completion UI adds the + ;; `completions-annotations' face if no other faces are + ;; present. We use a custom `corfu-annotations' face to + ;; allow further styling which fits better for popups. + (unless (text-property-not-all 0 (length suff) 'face nil suff) + (setq suff (propertize suff 'face 'corfu-annotations))) + (list cand "" suff))) + (cl-loop for cand in cands collect (list cand "" ""))))) + (cl-loop for x in cands for (c . _) = x do + (when mf + (setf (cadr x) (funcall mf c))) + (when (and dep (funcall dep c)) + (setcar x (setq c (substring c))) + (add-face-text-property 0 (length c) 'corfu-deprecated 'append c))) + (cons mf cands))) + +(cl-defgeneric corfu--prepare () + "Insert selected candidate unless command is marked to continue completion." + (when corfu--preview-ov + (delete-overlay corfu--preview-ov) + (setq corfu--preview-ov nil)) + ;; Ensure that state is initialized before next Corfu command + (when (and (symbolp this-command) (string-prefix-p "corfu-" (symbol-name this-command))) + (corfu--update)) + ;; If the next command is not listed in `corfu-continue-commands', insert the + ;; currently selected candidate and bail out of completion. This way you can + ;; continue typing after selecting a candidate. The candidate will be inserted + ;; and your new input will be appended. + (and (corfu--preview-current-p) (eq corfu-preview-current 'insert) + ;; See the comment about `overriding-local-map' in `corfu--post-command'. + (not (or overriding-terminal-local-map + (corfu--match-symbol-p corfu-continue-commands this-command))) + (corfu--insert 'exact))) + +(cl-defgeneric corfu--exhibit (&optional auto) + "Exhibit Corfu UI. +AUTO is non-nil when initializing auto completion." + (pcase-let ((`(,beg ,end ,table ,pred . ,_) completion-in-region--data) + (`(,str . ,pt) (corfu--update 'interruptible))) + (cond + ;; 1) Single exactly matching candidate and no further completion is possible. + ((and (not (equal str "")) + (equal (car corfu--candidates) str) (not (cdr corfu--candidates)) + (not (eq corfu-on-exact-match 'show)) + (or auto corfu-on-exact-match) + (not (consp (completion-try-completion str table pred pt corfu--metadata)))) + ;; Quit directly when initializing auto completion. + (if (or auto (eq corfu-on-exact-match 'quit)) + (corfu-quit) + (corfu--done (car corfu--candidates) 'finished nil))) + ;; 2) There exist candidates => Show candidates popup. + (corfu--candidates + (let ((pos (posn-at-point (+ beg (length corfu--base))))) + (corfu--preview-current beg end) + (corfu--candidates-popup pos))) + ;; 3) No candidates & `corfu-quit-no-match' & initialized => Confirmation popup. + ((pcase-exhaustive corfu-quit-no-match + ('t nil) + ('nil corfu--input) + ('separator (seq-contains-p (car corfu--input) corfu-separator))) + (corfu--popup-show (posn-at-point beg) 0 8 '(#("No match" 0 8 (face italic))))) + ;; 4) No candidates & auto completing or initialized => Quit. + ((or auto corfu--input) (corfu-quit))))) + +(cl-defgeneric corfu--teardown (buffer) + "Tear-down Corfu in BUFFER, which might be dead at this point." + (corfu--popup-hide) + (when corfu--preview-ov (delete-overlay corfu--preview-ov)) + (remove-hook 'post-command-hook #'corfu--post-command) + (when (buffer-live-p buffer) + (with-current-buffer buffer + (remove-hook 'window-selection-change-functions #'corfu--window-change 'local) + (remove-hook 'window-buffer-change-functions #'corfu--window-change 'local) + (remove-hook 'pre-command-hook #'corfu--prepare 'local) + (accept-change-group corfu--change-group))) + (cl-loop for (k . v) in corfu--initial-state do (set k v))) + +(defun corfu-sort-length-alpha (list) + "Sort LIST by length and alphabetically." + (sort list #'corfu--length-string<)) + +(defun corfu-quit () + "Quit Corfu completion." + (interactive) + (completion-in-region-mode -1)) + +(defun corfu-reset () + "Reset Corfu completion. +This command can be executed multiple times by hammering the ESC key. If a +candidate is selected, unselect the candidate. Otherwise reset the input. If +there hasn't been any input, then quit." + (interactive) + (if (/= corfu--index corfu--preselect) + (progn + (corfu--goto -1) + (setq this-command #'corfu-first)) + ;; Cancel all changes and start new change group. + (pcase-let* ((`(,beg ,end . ,_) completion-in-region--data) + (str (buffer-substring-no-properties beg end))) + (cancel-change-group corfu--change-group) + (activate-change-group (setq corfu--change-group (prepare-change-group))) + ;; Quit when resetting, when input did not change. + (when (equal str (buffer-substring-no-properties beg end)) + (corfu-quit))))) + +(defun corfu-insert-separator () + "Insert a separator character, inhibiting quit on completion boundary. +See `corfu-separator' for more details." + (interactive) + (insert corfu-separator)) + +(defun corfu-next (&optional n) + "Go forward N candidates." + (interactive "p") + (let ((index (+ corfu--index (or n 1)))) + (corfu--goto + (cond + ((not corfu-cycle) index) + ((= corfu--total 0) -1) + ((< corfu--preselect 0) (1- (mod (1+ index) (1+ corfu--total)))) + (t (mod index corfu--total)))))) + +(defun corfu-previous (&optional n) + "Go backward N candidates." + (interactive "p") + (corfu-next (- (or n 1)))) + +(defun corfu-scroll-down (&optional n) + "Go back by N pages." + (interactive "p") + (corfu--goto (max 0 (- corfu--index (* (or n 1) corfu-count))))) + +(defun corfu-scroll-up (&optional n) + "Go forward by N pages." + (interactive "p") + (corfu-scroll-down (- (or n 1)))) + +(defun corfu-first () + "Go to first candidate. +If the first candidate is already selected, go to the prompt." + (interactive) + (corfu--goto (if (> corfu--index 0) 0 -1))) + +(defun corfu-last () + "Go to last candidate." + (interactive) + (corfu--goto (1- corfu--total))) + +(defun corfu-prompt-beginning (arg) + "Move to beginning of the prompt line. +If the point is already the beginning of the prompt move to the +beginning of the line. If ARG is not 1 or nil, move backward ARG - 1 +lines first." + (interactive "^p") + (let ((beg (car completion-in-region--data))) + (if (or (not (eq arg 1)) + (and (= corfu--preselect corfu--index) (= (point) beg))) + (move-beginning-of-line arg) + (corfu--goto -1) + (goto-char beg)))) + +(defun corfu-prompt-end (arg) + "Move to end of the prompt line. +If the point is already the end of the prompt move to the end of +the line. If ARG is not 1 or nil, move forward ARG - 1 lines +first." + (interactive "^p") + (let ((end (cadr completion-in-region--data))) + (if (or (not (eq arg 1)) + (and (= corfu--preselect corfu--index) (= (point) end))) + (move-end-of-line arg) + (corfu--goto -1) + (goto-char end)))) + +(defun corfu-complete () + "Complete current input. +If a candidate is selected, insert it. Otherwise invoke +`corfu-expand'. Return non-nil if the input has been expanded." + (interactive) + (if (< corfu--index 0) + (corfu-expand) + ;; Continue completion with selected candidate. Exit with status 'finished + ;; if input is a valid match and no further completion is + ;; possible. Additionally treat completion as finished if at the end of a + ;; boundary, even if other longer candidates would still match, since the + ;; user invoked `corfu-complete' with an explicitly selected candidate! + (pcase-let ((`(,_beg ,_end ,table ,pred . ,_) completion-in-region--data) + (newstr (corfu--insert nil))) + (and (test-completion newstr table pred) + (or (not (consp (completion-try-completion + newstr table pred (length newstr) + (completion-metadata newstr table pred)))) + (equal (completion-boundaries newstr table pred "") '(0 . 0))) + (corfu--done newstr 'finished nil)) + t))) + +(defun corfu-expand () + "Expands the common prefix of all candidates. +If the currently selected candidate is previewed, invoke +`corfu-complete' instead. Expansion relies on the completion +styles via `completion-try-completion'. Return non-nil if the +input has been expanded." + (interactive) + (if (corfu--preview-current-p) + (corfu-complete) + (pcase-let* ((`(,beg ,end ,table ,pred . ,_) completion-in-region--data) + (pt (max 0 (- (point) beg))) + (str (buffer-substring-no-properties beg end)) + (metadata (completion-metadata (substring str 0 pt) table pred))) + (pcase (completion-try-completion str table pred pt metadata) + ('t + (goto-char end) + (corfu--done str 'finished corfu--candidates) + t) + ((and `(,newstr . ,newpt) (guard (not (and (= pt newpt) (equal newstr str))))) + (corfu--replace beg end newstr) + (goto-char (+ beg newpt)) + ;; Exit with status 'finished if input is a valid match + ;; and no further completion is possible. + (and (test-completion newstr table pred) + (not (consp (completion-try-completion + newstr table pred newpt + (completion-metadata (substring newstr 0 newpt) table pred)))) + (corfu--done newstr 'finished corfu--candidates)) + t))))) + +(defun corfu-insert () + "Insert current candidate. +Quit if no candidate is selected." + (interactive) + (if (>= corfu--index 0) + (corfu--insert 'finished) + (corfu-quit))) + +;;;###autoload +(define-minor-mode corfu-mode + "COmpletion in Region FUnction." + :group 'corfu :keymap corfu-mode-map + (cond + (corfu-mode + (and corfu-auto (add-hook 'post-command-hook #'corfu--auto-post-command nil 'local)) + (setq-local completion-in-region-function #'corfu--in-region)) + (t + (remove-hook 'post-command-hook #'corfu--auto-post-command 'local) + (kill-local-variable 'completion-in-region-function)))) + +(defcustom global-corfu-modes t + "List of modes where Corfu should be enabled. +The variable can either be t, nil or a list of t, nil, mode +symbols or elements of the form (not modes). Examples: + - Enable everywhere, except in Org: ((not org-mode) t). + - Enable in programming modes except Python: ((not python-mode) prog-mode). + - Enable only in text modes: (text-mode)." + :type '(choice (const t) (repeat sexp))) + +;;;###autoload +(define-globalized-minor-mode global-corfu-mode + corfu-mode corfu--on + :group 'corfu) + +(defun corfu--on () + "Turn `corfu-mode' on." + (when (and (not (or noninteractive (eq (aref (buffer-name) 0) ?\s))) + ;; TODO backport `easy-mmode--globalized-predicate-p' + (or (eq t global-corfu-modes) + (eq t (cl-loop for p in global-corfu-modes thereis + (pcase-exhaustive p + ('t t) + ('nil 0) + ((pred symbolp) (and (derived-mode-p p) t)) + (`(not . ,m) (and (seq-some #'derived-mode-p m) 0))))))) + (corfu-mode 1))) + +;; Emacs 28: Do not show Corfu commands with M-X +(dolist (sym '(corfu-next corfu-previous corfu-first corfu-last corfu-quit corfu-reset + corfu-complete corfu-insert corfu-scroll-up corfu-scroll-down + corfu-insert-separator corfu-prompt-beginning corfu-prompt-end)) + (put sym 'completion-predicate #'ignore)) + +(defun corfu--capf-wrapper-advice (orig fun which) + "Around advice for `completion--capf-wrapper'. +The ORIG function takes the FUN and WHICH arguments." + (if corfu-mode (corfu--capf-wrapper fun t) (funcall orig fun which))) + +(defun corfu--eldoc-advice () + "Return non-nil if Corfu is currently not active." + (not (and corfu-mode completion-in-region-mode))) + +;; Install advice which fixes `completion--capf-wrapper', such that it respects +;; the completion styles for non-exclusive Capfs. See also the fixme comment in +;; the `completion--capf-wrapper' function in minibuffer.el. +(advice-add #'completion--capf-wrapper :around #'corfu--capf-wrapper-advice) + +;; Register Corfu with ElDoc +(advice-add #'eldoc-display-message-no-interference-p + :before-while #'corfu--eldoc-advice) +(eldoc-add-command #'corfu-complete #'corfu-insert) + +(provide 'corfu) +;;; corfu.el ends here diff --git a/emacs/elpa/corfu-20240413.927/corfu.elc b/emacs/elpa/corfu-20240523.752/corfu.elc Binary files differ. diff --git a/emacs/elpa/csv-mode-1.23.signed b/emacs/elpa/csv-mode-1.23.signed @@ -1,2 +0,0 @@ -Good signature from 066DAFCB81E42C40 GNU ELPA Signing Agent (2019) <elpasign@elpa.gnu.org> (trust undefined) created at 2024-03-31T09:15:04+0000 using RSA -Good signature from 645357D2883A0966 GNU ELPA Signing Agent (2023) <elpasign@elpa.gnu.org> (trust undefined) created at 2024-03-31T09:15:04+0000 using EDDSA -\ No newline at end of file diff --git a/emacs/elpa/csv-mode-1.23/csv-mode-pkg.el b/emacs/elpa/csv-mode-1.23/csv-mode-pkg.el @@ -1,2 +0,0 @@ -;; Generated package description from csv-mode.el -*- no-byte-compile: t -*- -(define-package "csv-mode" "1.23" "Major mode for editing comma/char separated values" '((emacs "27.1") (cl-lib "0.5")) :commit "63f02980978f19786bda354457ac5259b8f969a2" :url "https://elpa.gnu.org/packages/csv-mode.html" :authors '(("Francis J. Wright" . "F.J.Wright@qmul.ac.uk")) :maintainer '(nil . "emacs-devel@gnu.org") :keywords '("convenience")) diff --git a/emacs/elpa/csv-mode-1.23/csv-mode-tests.el b/emacs/elpa/csv-mode-1.23/csv-mode-tests.el @@ -1,148 +0,0 @@ -;;; csv-mode-tests.el --- Tests for CSV mode -*- lexical-binding: t; -*- - -;; Copyright (C) 2020-2022 Free Software Foundation, Inc - -;; Author: Simen Heggestøyl <simenheg@runbox.com> -;; Keywords: - -;; 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 <https://www.gnu.org/licenses/>. - -;;; Commentary: - -;; - -;;; Code: - -(require 'ert) -(require 'csv-mode) -(eval-when-compile (require 'subr-x)) - -(ert-deftest csv-tests-end-of-field () - (with-temp-buffer - (csv-mode) - (insert "aaa,bbb") - (goto-char (point-min)) - (csv-end-of-field) - (should (equal (buffer-substring (point-min) (point)) "aaa")) - (forward-char) - (csv-end-of-field) - (should (equal (buffer-substring (point-min) (point)) - "aaa,bbb")))) - -(ert-deftest csv-tests-end-of-field-with-quotes () - (with-temp-buffer - (csv-mode) - (insert "aaa,\"b,b\"") - (goto-char (point-min)) - (csv-end-of-field) - (should (equal (buffer-substring (point-min) (point)) "aaa")) - (forward-char) - (csv-end-of-field) - (should (equal (buffer-substring (point-min) (point)) - "aaa,\"b,b\"")))) - -(ert-deftest csv-tests-beginning-of-field () - (with-temp-buffer - (csv-mode) - (insert "aaa,bbb") - (csv-beginning-of-field) - (should (equal (buffer-substring (point) (point-max)) "bbb")) - (backward-char) - (csv-beginning-of-field) - (should (equal (buffer-substring (point) (point-max)) - "aaa,bbb")))) - -(ert-deftest csv-tests-beginning-of-field-with-quotes () - (with-temp-buffer - (csv-mode) - (insert "aaa,\"b,b\"") - (csv-beginning-of-field) - (should (equal (buffer-substring (point) (point-max)) "\"b,b\"")) - (backward-char) - (csv-beginning-of-field) - (should (equal (buffer-substring (point) (point-max)) - "aaa,\"b,b\"")))) - -(defun csv-tests--align-fields (before after) - (with-temp-buffer - (insert (string-join before "\n")) - (csv-align-fields t (point-min) (point-max)) - (should (equal (buffer-string) (string-join after "\n"))))) - -(ert-deftest csv-tests-align-fields () - (csv-tests--align-fields - '("aaa,bbb,ccc" - "1,2,3") - '("aaa, bbb, ccc" - "1 , 2 , 3"))) - -(ert-deftest csv-tests-align-fields-with-quotes () - (csv-tests--align-fields - '("aaa,\"b,b\",ccc" - "1,2,3") - '("aaa, \"b,b\", ccc" - "1 , 2 , 3"))) - -;; Bug#14053 -(ert-deftest csv-tests-align-fields-double-quote-comma () - (csv-tests--align-fields - '("1,2,3" - "a,\"b\"\"c,\",d") - '("1, 2 , 3" - "a, \"b\"\"c,\", d"))) - -(defvar csv-tests--data - "1,4;Sun, 2022-04-10;4,12 -8;Mon, 2022-04-11;3,19 -3,2;Tue, 2022-04-12;1,00 -2;Wed, 2022-04-13;0,37 -9;Wed, 2022-04-13;0,37") - -(ert-deftest csv-tests-guess-separator () - (should-not (csv-guess-separator "")) - (should (= (csv-guess-separator csv-tests--data 3) ?,)) - (should (= (csv-guess-separator csv-tests--data) ?\;)) - (should (= (csv-guess-separator csv-tests--data) - (csv-guess-separator csv-tests--data - (length csv-tests--data))))) - -(ert-deftest csv-tests-separator-candidates () - (should-not (csv--separator-candidates "")) - (should-not (csv--separator-candidates csv-tests--data 0)) - (should - (equal (sort (csv--separator-candidates csv-tests--data 4) #'<) - '(?, ?\;))) - (should - (equal (sort (csv--separator-candidates csv-tests--data) #'<) - '(?\s ?, ?- ?\;))) - (should - (equal - (sort (csv--separator-candidates csv-tests--data) #'<) - (sort (csv--separator-candidates csv-tests--data - (length csv-tests--data)) - #'<)))) - -(ert-deftest csv-tests-separator-score () - (should (< (csv--separator-score ?, csv-tests--data) - (csv--separator-score ?\s csv-tests--data) - (csv--separator-score ?- csv-tests--data))) - (should (= (csv--separator-score ?- csv-tests--data) - (csv--separator-score ?\; csv-tests--data))) - (should (= 0 (csv--separator-score ?\; csv-tests--data 0))) - (should (= (csv--separator-score ?\; csv-tests--data) - (csv--separator-score ?\; csv-tests--data - (length csv-tests--data))))) - -(provide 'csv-mode-tests) -;;; csv-mode-tests.el ends here diff --git a/emacs/elpa/csv-mode-1.23/csv-mode-tests.elc b/emacs/elpa/csv-mode-1.23/csv-mode-tests.elc Binary files differ. diff --git a/emacs/elpa/csv-mode-1.23/csv-mode.el b/emacs/elpa/csv-mode-1.23/csv-mode.el @@ -1,1965 +0,0 @@ -;;; csv-mode.el --- Major mode for editing comma/char separated values -*- lexical-binding: t -*- - -;; Copyright (C) 2003-2023 Free Software Foundation, Inc - -;; Author: "Francis J. Wright" <F.J.Wright@qmul.ac.uk> -;; Maintainer: emacs-devel@gnu.org -;; Version: 1.23 -;; Package-Requires: ((emacs "27.1") (cl-lib "0.5")) -;; Keywords: convenience - -;; This package 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, or (at your option) -;; any later version. - -;; This package 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 GNU Emacs. If not, see <https://www.gnu.org/licenses/>. - -;;; Commentary: - -;; This package implements CSV mode, a major mode for editing records -;; in a generalized CSV (character-separated values) format. It binds -;; files with prefix ".csv" to `csv-mode' (and ".tsv" to `tsv-mode') in -;; `auto-mode-alist'. - -;; In CSV mode, the following commands are available: - -;; - C-c C-s (`csv-sort-fields') and C-c C-n (`csv-sort-numeric-fields') -;; respectively sort lexicographically and numerically on a -;; specified field or column. - -;; - C-c C-r (`csv-reverse-region') reverses the order. (These -;; commands are based closely on, and use, code in `sort.el'.) - -;; - C-c C-k (`csv-kill-fields') and C-c C-y (`csv-yank-fields') kill -;; and yank fields or columns, although they do not use the normal -;; kill ring. C-c C-k can kill more than one field at once, but -;; multiple killed fields can be yanked only as a fixed group -;; equivalent to a single field. - -;; - `csv-align-mode' keeps fields visually aligned, on-the-fly. -;; It truncates fields to a maximum width that can be changed per-column -;; with `csv-align-set-column-width'. -;; Alternatively, C-c C-a (`csv-align-fields') aligns fields into columns -;; and C-c C-u (`csv-unalign-fields') undoes such alignment; -;; separators can be hidden within aligned records (controlled by -;; `csv-invisibility-default' and `csv-toggle-invisibility'). - -;; - C-c C-t (`csv-transpose') interchanges rows and columns. For -;; details, see the documentation for the individual commands. - -;; - `csv-set-separator' sets the CSV separator of the current buffer, -;; while `csv-guess-set-separator' guesses and sets the separator -;; based on the current buffer's contents. -;; `csv-guess-set-separator' can be useful to add to the mode hook -;; to have CSV mode guess and set the separator automatically when -;; visiting a buffer: -;; -;; (add-hook 'csv-mode-hook 'csv-guess-set-separator) - -;; CSV mode can recognize fields separated by any of several single -;; characters, specified by the value of the customizable user option -;; `csv-separators'. CSV data fields can be delimited by quote -;; characters (and must if they contain separator characters). This -;; implementation supports quoted fields, where the quote characters -;; allowed are specified by the value of the customizable user option -;; `csv-field-quotes'. By default, the both commas and tabs are considered -;; as separators and the only field quote is a double quote. -;; These user options can be changed ONLY by customizing them, e.g. via M-x -;; customize-variable. - -;; CSV mode commands ignore blank lines and comment lines beginning -;; with the value of the buffer local variable `csv-comment-start', -;; which by default is #. The user interface is similar to that of -;; the standard commands `sort-fields' and `sort-numeric-fields', but -;; see the major mode documentation below. - -;; The global minor mode `csv-field-index-mode' provides display of -;; the current field index in the mode line, cf. `line-number-mode' -;; and `column-number-mode'. It is on by default. - -;;;; See also: - -;; the standard GNU Emacs 21 packages align.el, which will align -;; columns within a region, and delim-col.el, which helps to prettify -;; columns in a text region or rectangle; - -;; csv.el by Ulf Jasper <ulf.jasper at web.de>, which provides -;; functions for reading/parsing comma-separated value files and is -;; available at http://de.geocities.com/ulf_jasper/emacs.html (and in -;; the gnu.emacs.sources archives). - -;;; Installation: - -;; Put this file somewhere that Emacs can find it (i.e. in one of the -;; directories in your `load-path' such as `site-lisp'), optionally -;; byte-compile it (recommended), and put this in your .emacs file: -;; -;; (add-to-list 'auto-mode-alist '("\\.[Cc][Ss][Vv]\\'" . csv-mode)) -;; (autoload 'csv-mode "csv-mode" -;; "Major mode for editing comma-separated value files." t) - -;;; News: - -;; Since 1.21: -;; - New command `csv-insert-column'. -;; - New config var `csv-align-min-width' for `csv-align-mode'. -;; - New option `csv-confirm-region'. - -;; Since 1.9: -;; - `csv-align-mode' auto-aligns columns dynamically (on screen). - -;; Before that: -;; Begun on 15 November 2003 to provide lexicographic sorting of -;; simple CSV data by field and released as csv.el. Facilities to -;; kill multiple fields and customize separator added on 9 April 2004. -;; Converted to a major mode and renamed csv-mode.el on 10 April 2004, -;; partly at the suggestion of Stefan Monnier <monnier at -;; IRO.UMontreal.CA> to avoid conflict with csv.el by Ulf Jasper. -;; Field alignment, comment support and CSV mode customization group -;; added on 1 May 2004. Support for index ranges added on 6 June -;; 2004. Multiple field separators added on 12 June 2004. -;; Transposition added on 22 June 2004. Separator invisibility added -;; on 23 June 2004. - -;;; To do (maybe): - -;; Make separators and quotes buffer-local and locally settable. -;; Support (La)TeX tables: set separator and comment; support record -;; end string. -;; Convert comma-separated to space- or tab-separated. - -;;; Code: - -(eval-when-compile - (require 'cl-lib) - (require 'subr-x)) - -(defgroup CSV nil - "Major mode for editing files of comma-separated value type." - :group 'convenience) - -(defvar csv-separator-chars nil - "Field separators as a list of character. -Set by customizing `csv-separators' -- do not set directly!") - -(defvar csv-separator-regexp nil - "Regexp to match a field separator. -Set by customizing `csv-separators' -- do not set directly!") - -(defvar csv--skip-chars nil - "Char set used by `skip-chars-forward' etc. to skip fields. -Set by customizing `csv-separators' -- do not set directly!") - -(defvar csv-font-lock-keywords nil - "Font lock keywords to highlight the field separators in CSV mode. -Set by customizing `csv-separators' -- do not set directly!") - -(defcustom csv-separators '("," "\t") - "Field separators: a list of *single-character* strings. -For example: (\",\"), the default, or (\",\" \";\" \":\"). -Neighbouring fields may be separated by any one of these characters. -The first is used when inserting a field separator into the buffer. -All must be different from the field quote characters, `csv-field-quotes'. - -Changing this variable with `setq' won't affect the current Emacs -session. Use `customize-set-variable' instead if that is required." - ;; Suggested by Eckhard Neber <neber@mwt.e-technik.uni-ulm.de> - :type '(repeat string) - ;; FIXME: Character would be better, but in Emacs 21.3 does not display - ;; correctly in a customization buffer. - :set (lambda (variable value) - (mapc (lambda (x) - (if (/= (length x) 1) - (error "Non-single-char string %S" x)) - (if (and (boundp 'csv-field-quotes) - (member x csv-field-quotes)) - (error "%S is already a quote" x))) - value) - (custom-set-default variable value) - (setq csv-separator-chars (mapcar #'string-to-char value)) - (setq csv--skip-chars - (apply #'concat "^\n" - (mapcar (lambda (s) (concat "\\" s)) value))) - (setq csv-separator-regexp (regexp-opt value)) - (setq csv-font-lock-keywords - ;; NB: csv-separator-face variable evaluates to itself. - `((,csv-separator-regexp (0 'csv-separator-face)))))) - -(defcustom csv-field-quotes '("\"") - "Field quotes: a list of *single-character* strings. -For example: (\"\\\"\"), the default, or (\"\\\"\" \"\\='\" \"\\=`\"). -A field can be delimited by a pair of any of these characters. -All must be different from the field separators, `csv-separators'." - :type '(repeat string) - ;; Character would be better, but in Emacs 21 does not display - ;; correctly in a customization buffer. - :set (lambda (variable value) - (mapc (lambda (x) - (if (/= (length x) 1) - (error "Non-single-char string %S" x)) - (if (member x csv-separators) - (error "%S is already a separator" x))) - value) - (when (boundp 'csv-mode-syntax-table) - ;; FIRST remove old quote syntax: - (with-syntax-table text-mode-syntax-table - (mapc (lambda (x) - (modify-syntax-entry - (string-to-char x) - (string (char-syntax (string-to-char x))) - ;; symbol-value to avoid compiler warning: - (symbol-value 'csv-mode-syntax-table))) - csv-field-quotes)) - ;; THEN set new quote syntax: - (csv-set-quote-syntax value)) - ;; BEFORE setting new value of `csv-field-quotes': - (custom-set-default variable value))) - -(defun csv-set-quote-syntax (field-quotes) - "Set syntax for field quote characters FIELD-QUOTES to be \"string\". -FIELD-QUOTES should be a list of single-character strings." - (mapc (lambda (x) - (modify-syntax-entry - (string-to-char x) "\"" - ;; symbol-value to avoid compiler warning: - (symbol-value 'csv-mode-syntax-table))) - field-quotes)) - -(defvar csv-comment-start nil - "String that starts a comment line, or nil if no comment syntax. -Such comment lines are ignored by CSV mode commands. -This variable is buffer local; its default value is that of -`csv-comment-start-default'. It is set by the function -`csv-set-comment-start' -- do not set it directly!") - -(make-variable-buffer-local 'csv-comment-start) - -(defcustom csv-comment-start-default "#" - "String that starts a comment line, or nil if no comment syntax. -Such comment lines are ignored by CSV mode commands. -Default value of buffer-local variable `csv-comment-start'. -Changing this variable does not affect any existing CSV mode buffer." - :type '(choice (const :tag "None" nil) string) - :set (lambda (variable value) - (custom-set-default variable value) - (setq-default csv-comment-start value))) - -(defcustom csv-align-style 'left - "Aligned field style: one of `left', `centre', `right' or `auto'. -Alignment style used by `csv-align-mode' and `csv-align-fields'. -Auto-alignment means left align text and right align numbers." - :type '(choice (const left) (const centre) - (const right) (const auto))) - -(defcustom csv-align-padding 1 - "Aligned field spacing: must be a positive integer. -Number of spaces used by `csv-align-mode' and `csv-align-fields' -after separators." - :type 'integer) - -(defcustom csv-header-lines 0 - "Header lines to skip when setting region automatically." - :type 'integer) - -(defcustom csv-invisibility-default t - "If non-nil, make separators in aligned records invisible." - :type 'boolean) - -(defcustom csv-confirm-region t - "If non-nil, confirm that region is OK in interactive commands." - :type 'boolean) - -(defface csv-separator-face - '((t :inherit escape-glyph)) - "CSV mode face used to highlight separators.") - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; Mode definition, key bindings and menu -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - - -(defconst csv-mode-line-format - '(csv-field-index-string ("" csv-field-index-string)) - "Mode line format string for CSV mode.") - -(defvar csv-mode-map - (let ((map (make-sparse-keymap))) - (define-key map [(control ?c) (control ?v)] #'csv-toggle-invisibility) - (define-key map [(control ?c) (control ?t)] #'csv-transpose) - (define-key map [(control ?c) (control ?c)] #'csv-set-comment-start) - (define-key map [(control ?c) (control ?u)] #'csv-unalign-fields) - (define-key map [(control ?c) (control ?a)] #'csv-align-fields) - (define-key map [(control ?c) (control ?z)] #'csv-yank-as-new-table) - (define-key map [(control ?c) (control ?y)] #'csv-yank-fields) - (define-key map [(control ?c) (control ?k)] #'csv-kill-fields) - (define-key map [(control ?c) (control ?d)] #'csv-toggle-descending) - (define-key map [(control ?c) (control ?r)] #'csv-reverse-region) - (define-key map [(control ?c) (control ?n)] #'csv-sort-numeric-fields) - (define-key map [(control ?c) (control ?s)] #'csv-sort-fields) - (define-key map "\t" #'csv-tab-command) - (define-key map [backtab] #'csv-backtab-command) - map)) - -;;;###autoload -(define-derived-mode csv-mode text-mode "CSV" - "Major mode for editing files of comma-separated value type. - -CSV mode is derived from `text-mode', and runs `text-mode-hook' before -running `csv-mode-hook'. It turns `auto-fill-mode' off by default. -CSV mode can be customized by user options in the CSV customization -group. The separators are specified by the value of `csv-separators'. - -CSV mode commands ignore blank lines and comment lines beginning with -the value of `csv-comment-start', which delimit \"paragraphs\". -\"Sexp\" is re-interpreted to mean \"field\", so that `forward-sexp' -\(\\[forward-sexp]), `kill-sexp' (\\[kill-sexp]), etc. all apply to fields. -Standard comment commands apply, such as `comment-dwim' (\\[comment-dwim]). - -If `font-lock-mode' is enabled then separators, quoted values and -comment lines are highlighted using respectively `csv-separator-face', -`font-lock-string-face' and `font-lock-comment-face'. - -The user interface (UI) for CSV mode commands is similar to that of -the standard commands `sort-fields' and `sort-numeric-fields', except -that if there is no prefix argument then the UI prompts for the field -index or indices. In `transient-mark-mode' only: if the region is not -set then the UI attempts to set it to include all consecutive CSV -records around point, and prompts for confirmation; if there is no -prefix argument then the UI prompts for it, offering as a default the -index of the field containing point if the region was not set -explicitly. The region set automatically is delimited by blank lines -and comment lines, and the number of header lines at the beginning of -the region given by the value of `csv-header-lines' are skipped. - -Sort order is controlled by `csv-descending'. - -CSV mode provides the following specific keyboard key bindings: - -\\{csv-mode-map}" - :group 'CSV - ;; We used to `turn-off-auto-fill' here instead, but that's not very - ;; effective since text-mode-hook is run afterwards anyway! - (setq-local normal-auto-fill-function nil) - ;; Set syntax for field quotes: - (csv-set-quote-syntax csv-field-quotes) - ;; Make sexp functions apply to fields: - (set (make-local-variable 'forward-sexp-function) #'csv-forward-field) - (csv-set-comment-start csv-comment-start) - ;; Font locking -- separator plus syntactic: - (setq font-lock-defaults '(csv-font-lock-keywords)) - (setq-local jit-lock-contextually nil) ;Each line should be independent. - (if csv-invisibility-default (add-to-invisibility-spec 'csv)) - ;; Mode line to support `csv-field-index-mode': - (set (make-local-variable 'mode-line-position) - (pcase mode-line-position - (`(,(or (pred consp) (pred stringp)) . ,_) - `(,@mode-line-position ,csv-mode-line-format)) - (_ `("" ,mode-line-position ,csv-mode-line-format)))) - (set (make-local-variable 'truncate-lines) t) - ;; Enable or disable `csv-field-index-mode' (could probably do this - ;; a bit more efficiently): - (csv-field-index-mode (symbol-value 'csv-field-index-mode))) - -(defun csv-set-comment-start (string) - "Set comment start for this CSV mode buffer to STRING. -It must be either a string or nil." - (interactive - (list (edit-and-eval-command - "Comment start (string or nil): " csv-comment-start))) - ;; Paragraph means a group of contiguous records: - (set (make-local-variable 'paragraph-separate) "[[:space:]]*$") ; White space. - (set (make-local-variable 'paragraph-start) "\n");Must include \n explicitly! - ;; Remove old comment-start/end if available - (with-syntax-table text-mode-syntax-table - (when comment-start - (modify-syntax-entry (string-to-char comment-start) - (string (char-syntax (string-to-char comment-start))) - csv-mode-syntax-table)) - (modify-syntax-entry ?\n - (string (char-syntax ?\n)) - csv-mode-syntax-table)) - (when string - (setq paragraph-separate (concat paragraph-separate "\\|" string) - paragraph-start (concat paragraph-start "\\|" string)) - (set (make-local-variable 'comment-start) string) - (modify-syntax-entry - (string-to-char string) "<" csv-mode-syntax-table) - (modify-syntax-entry ?\n ">" csv-mode-syntax-table)) - (setq csv-comment-start string)) - -(defvar csv--set-separator-history nil) - -(defun csv-set-separator (sep) - "Set the CSV separator in the current buffer to SEP." - (interactive (list (read-char-from-minibuffer - "Separator: " nil 'csv--set-separator-history))) - (when (and (boundp 'csv-field-quotes) - (member (string sep) csv-field-quotes)) - (error "%c is already a quote" sep)) - (setq-local csv-separators (list (string sep))) - (setq-local csv-separator-chars (list sep)) - (setq-local csv--skip-chars (format "^\n\\%c" sep)) - (setq-local csv-separator-regexp (regexp-quote (string sep))) - (setq-local csv-font-lock-keywords - `((,csv-separator-regexp (0 'csv-separator-face)))) - (font-lock-refresh-defaults)) - -;;;###autoload -(add-to-list 'auto-mode-alist '("\\.[Cc][Ss][Vv]\\'" . csv-mode)) - -(defvar csv-descending nil - "If non-nil, CSV mode sort functions sort in order of descending sort key. -Usually they sort in order of ascending sort key.") - -(defun csv-toggle-descending () - "Toggle `csv-descending'." - (interactive) - (setq csv-descending (not csv-descending)) - (message "Sort order is %sscending" (if csv-descending "de" "a"))) - -(defun csv-toggle-invisibility () - ;; FIXME: Make it into a proper minor mode? - "Toggle `buffer-invisibility-spec'." - (interactive) - (if (memq 'csv buffer-invisibility-spec) - (remove-from-invisibility-spec 'csv) - (add-to-invisibility-spec 'csv)) - (message "Separators in aligned records will be %svisible \ -\(after re-aligning if soft)" - (if (memq 'csv buffer-invisibility-spec) "in" "")) - (redraw-frame (selected-frame))) - -(easy-menu-define - csv-menu - csv-mode-map - "CSV major mode menu keymap" - '("CSV" - ["Sort By Field Lexicographically" csv-sort-fields :active t - :help "Sort lines in region lexicographically by the specified field"] - ["Sort By Field Numerically" csv-sort-numeric-fields :active t - :help "Sort lines in region numerically by the specified field"] - ["Reverse Order of Lines" csv-reverse-region :active t - :help "Reverse the order of the lines in the region"] - ["Use Descending Sort Order" csv-toggle-descending :active t - :style toggle :selected csv-descending - :help "If selected, use descending order when sorting"] - "--" - ["Kill Fields (Columns)" csv-kill-fields :active t - :help "Kill specified fields of each line in the region"] - ["Yank Fields (Columns)" csv-yank-fields :active t - :help "Yank killed fields as specified field of each line in region"] - ["Yank As New Table" csv-yank-as-new-table :active t - :help "Yank killed fields as a new table at point"] - ["Align Fields into Columns" csv-align-fields :active t - :help "Align the start of every field of each line in the region"] - ["Unalign Columns into Fields" csv-unalign-fields :active t - :help "Undo soft alignment and optionally remove redundant white space"] - ["Transpose Rows and Columns" csv-transpose :active t - :help "Rewrite rows (which may have different lengths) as columns"] - "--" - ["Forward Field" forward-sexp :active t - :help "Move forward across one field; with ARG, do it that many times"] - ["Backward Field" backward-sexp :active t - :help "Move backward across one field; with ARG, do it that many times"] - ["Kill Field Forward" kill-sexp :active t - :help "Kill field following cursor; with ARG, do it that many times"] - ["Kill Field Backward" backward-kill-sexp :active t - :help "Kill field preceding cursor; with ARG, do it that many times"] - "--" - ("Alignment Style" - ["Left" (setq csv-align-style 'left) :active t - :style radio :selected (eq csv-align-style 'left) - :help "If selected, `csv-align' left aligns fields"] - ["Centre" (setq csv-align-style 'centre) :active t - :style radio :selected (eq csv-align-style 'centre) - :help "If selected, `csv-align' centres fields"] - ["Right" (setq csv-align-style 'right) :active t - :style radio :selected (eq csv-align-style 'right) - :help "If selected, `csv-align' right aligns fields"] - ["Auto" (setq csv-align-style 'auto) :active t - :style radio :selected (eq csv-align-style 'auto) - :help "\ -If selected, `csv-align' left aligns text and right aligns numbers"] - ) - ["Set header line" csv-header-line :active t] - ["Auto-(re)align fields" csv-align-mode - :style toggle :selected csv-align-mode] - ["Show Current Field Index" csv-field-index-mode :active t - :style toggle :selected csv-field-index-mode - :help "If selected, display current field index in mode line"] - ["Make Separators Invisible" csv-toggle-invisibility :active t - :style toggle :selected (memq 'csv buffer-invisibility-spec) - :visible (not (tsv--mode-p)) - :help "If selected, separators in aligned records are invisible"] - ["Set Buffer's Comment Start" csv-set-comment-start :active t - :help "Set comment start string for this buffer"] - ["Customize CSV Mode" (customize-group 'CSV) :active t - :help "Open a customization buffer to change CSV mode options"] - )) - -(require 'sort) - -(defsubst csv-not-looking-at-record () - "Return t if looking at blank or comment line, nil otherwise. -Assumes point is at beginning of line." - (looking-at paragraph-separate)) - -(defun csv-interactive-args (&optional type) - "Get arg or field(s) and region interactively, offering sensible defaults. -Signal an error if the buffer is read-only. -If TYPE is noarg then return a list (beg end). -Otherwise, return a list (arg beg end), where arg is: - the raw prefix argument by default; - a single field index if TYPE is single; - a list of field indices or index ranges if TYPE is multiple. -Field defaults to the current prefix arg; if not set, prompt user. - -A field index list consists of positive or negative integers or ranges, -separated by any non-integer characters. A range has the form m-n, -where m and n are positive or negative integers, m < n, and n defaults -to the last field index if omitted. - -In transient mark mode, if the mark is not active then automatically -select and highlight CSV records around point, and query user. -The default field when read interactively is the current field." - ;; Must be run interactively to activate mark! - (let* ((arg current-prefix-arg) (default-field 1) - (region - (if (not (use-region-p)) - ;; Set region automatically: - (save-excursion - (if arg - (beginning-of-line) - (let ((lbp (line-beginning-position))) - (while (re-search-backward csv-separator-regexp lbp 1) - ;; Move as far as possible, i.e. to beginning of line. - (setq default-field (1+ default-field))))) - (if (csv-not-looking-at-record) - (error "Point must be within CSV records")) - (let ((startline (point))) - ;; Set mark at beginning of region: - (while (not (or (bobp) (csv-not-looking-at-record))) - (forward-line -1)) - (if (csv-not-looking-at-record) (forward-line 1)) - ;; Skip header lines: - (forward-line csv-header-lines) - (set-mark (point)) ; OK since in save-excursion - ;; Move point to end of region: - (goto-char startline) - (beginning-of-line) - (while (not (or (eobp) (csv-not-looking-at-record))) - (forward-line 1)) - ;; Show mark briefly if necessary: - (unless (and (pos-visible-in-window-p) - (pos-visible-in-window-p (mark))) - (exchange-point-and-mark) - (sit-for 1) - (exchange-point-and-mark)) - (when csv-confirm-region - (or (y-or-n-p "Region OK? ") - (error "Action aborted by user")) - (message nil)) ; clear y-or-n-p message - (list (region-beginning) (region-end)))) - ;; Use region set by user: - (list (region-beginning) (region-end))))) - (setq default-field (number-to-string default-field)) - (cond - ((eq type 'multiple) - (if arg - ;; Ensure that field is a list: - (or (consp arg) - (setq arg (list (prefix-numeric-value arg)))) - ;; Read field interactively, ignoring non-integers: - (setq arg - (mapcar - (lambda (x) - (if (string-match "-" x 1) ; not first character - ;; Return a range as a pair - the cdr may be nil: - (let ((m (substring x 0 (match-beginning 0))) - (n (substring x (match-end 0)))) - (cons (car (read-from-string m)) - (and (not (string= n "")) - (car (read-from-string n))))) - ;; Return a number as a number: - (car (read-from-string x)))) - (split-string - (read-string - "Fields (sequence of integers or ranges): " default-field) - "[^-+0-9]+"))))) - ((eq type 'single) - (if arg - (setq arg (prefix-numeric-value arg)) - (while (not (integerp arg)) - (setq arg (eval-minibuffer "Field (integer): " default-field)))))) - (if (eq type 'noarg) region (cons arg region)))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; Sorting by field -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(defun csv-nextrecfun () - "Called by `csv-sort-fields-1' with point at end of previous record. -It moves point to the start of the next record. -It should move point to the end of the buffer if there are no more records." - (forward-line) - (while (and (not (eobp)) (csv-not-looking-at-record)) - (forward-line))) - -(defun csv-sort-fields-1 (field beg end startkeyfun endkeyfun) - "Modified version of `sort-fields-1' that skips blank or comment lines. - -FIELD is a single field index, and BEG and END specify the region to -sort. - -STARTKEYFUN moves from the start of the record to the start of the key. -It may return either a non-nil value to be used as the key, or -else the key is the substring between the values of point after -STARTKEYFUN and ENDKEYFUN are called. If STARTKEYFUN is nil, the key -starts at the beginning of the record. - -ENDKEYFUN moves from the start of the sort key to the end of the sort key. -ENDKEYFUN may be nil if STARTKEYFUN returns a value or if it would be the -same as ENDRECFUN." - (let ((tbl (syntax-table))) - (if (zerop field) (setq field 1)) - (unwind-protect - (save-excursion - (save-restriction - (narrow-to-region beg end) - (goto-char (point-min)) - (set-syntax-table sort-fields-syntax-table) - (sort-subr csv-descending - 'csv-nextrecfun 'end-of-line - startkeyfun endkeyfun))) - (set-syntax-table tbl)))) - -(defun csv-sort-fields (field beg end) - "Sort lines in region lexicographically by the ARGth field of each line. -If not set, the region defaults to the CSV records around point. -Fields are separated by `csv-separators' and null fields are allowed anywhere. -Field indices increase from 1 on the left or decrease from -1 on the right. -A prefix argument specifies a single field, otherwise prompt for field index. -Ignore blank and comment lines. The variable `sort-fold-case' -determines whether alphabetic case affects the sort order. -When called non-interactively, FIELD is a single field index; -BEG and END specify the region to sort." - ;; (interactive "*P\nr") - (interactive (csv-interactive-args 'single)) - (barf-if-buffer-read-only) - (csv-sort-fields-1 field beg end - (lambda () (csv-sort-skip-fields field) nil) - (lambda () (skip-chars-forward csv--skip-chars)))) - -(defun csv-sort-numeric-fields (field beg end) - "Sort lines in region numerically by the ARGth field of each line. -If not set, the region defaults to the CSV records around point. -Fields are separated by `csv-separators'. -Null fields are allowed anywhere and sort as zeros. -Field indices increase from 1 on the left or decrease from -1 on the right. -A prefix argument specifies a single field, otherwise prompt for field index. -Specified non-null field must contain a number in each line of the region, -which may begin with \"0x\" or \"0\" for hexadecimal and octal values. -Otherwise, the number is interpreted according to sort-numeric-base. -Ignore blank and comment lines. -When called non-interactively, FIELD is a single field index; -BEG and END specify the region to sort." - ;; (interactive "*P\nr") - (interactive (csv-interactive-args 'single)) - (barf-if-buffer-read-only) - (csv-sort-fields-1 field beg end - (lambda () - (csv-sort-skip-fields field) - (let* ((case-fold-search t) - (base - (if (looking-at "\\(0x\\)[0-9a-f]\\|\\(0\\)[0-7]") - (cond ((match-beginning 1) - (goto-char (match-end 1)) - 16) - ((match-beginning 2) - (goto-char (match-end 2)) - 8) - (t nil))))) - (string-to-number (buffer-substring (point) - (save-excursion - (forward-sexp 1) - (point))) - (or base sort-numeric-base)))) - nil)) - -(defun csv-reverse-region (beg end) - "Reverse the order of the lines in the region. -This is just a CSV-mode style interface to `reverse-region', which is -the function that should be used non-interactively. It takes two -point or marker arguments, BEG and END, delimiting the region." - ;; (interactive "*P\nr") - (interactive (csv-interactive-args 'noarg)) - (barf-if-buffer-read-only) - (reverse-region beg end)) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; Moving by field -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(defun csv-end-of-field () - "Skip forward over one field." - (skip-chars-forward " ") - ;; If the first character is a double quote, then we have a quoted - ;; value. - (when (eq (char-syntax (following-char)) ?\") - (forward-char) - (let ((ended nil)) - (while (not ended) - (cond ((not (eq (char-syntax (following-char)) ?\")) - (forward-char 1)) - ;; According to RFC-4180 (sec 2.7), quotes inside quoted strings - ;; are quoted by doubling the quote char: a,"b""c,",d - ;; FIXME: Maybe we should handle this via syntax-propertize? - ((let ((c (char-after (1+ (point))))) - (and c (eq (char-syntax c) ?\"))) - (forward-char 2)) - (t - (setq ended t)))))) - (skip-chars-forward csv--skip-chars)) - -(defun csv--bof-p () - (or (bolp) - (memq (preceding-char) csv-separator-chars))) - -(defun csv--eof-p () - (or (eolp) - (memq (following-char) csv-separator-chars))) - -(defun csv-beginning-of-field () - "Skip backward over one field." - (skip-syntax-backward " ") - (if (eq (char-syntax (preceding-char)) ?\") - (goto-char (scan-sexps (point) -1))) - (skip-chars-backward csv--skip-chars)) - -(defun csv-forward-field (arg) - "Move forward across one field, cf. `forward-sexp'. -With ARG, do it that many times. Negative arg -N means -move backward across N fields." - (interactive "p") - (if (< arg 0) - (csv-backward-field (- arg)) - (while (>= (setq arg (1- arg)) 0) - (if (or (bolp) - (when (and (not (eobp)) (eolp)) (forward-char) t)) - (while (and (not (eobp)) (csv-not-looking-at-record)) - (forward-line 1))) - (if (memq (following-char) csv-separator-chars) (forward-char)) - (csv-end-of-field)))) - -(defun csv-backward-field (arg) - "Move backward across one field, cf. `backward-sexp'. -With ARG, do it that many times. Negative arg -N means -move forward across N fields." - (interactive "p") - (if (< arg 0) - (csv-forward-field (- arg)) - (while (>= (setq arg (1- arg)) 0) - (when (or (eolp) - (when (and (not (bobp)) (bolp)) (backward-char) t)) - (while (progn - (beginning-of-line) - (csv-not-looking-at-record)) - (backward-char)) - (end-of-line)) - (if (memq (preceding-char) csv-separator-chars) (backward-char)) - (csv-beginning-of-field)))) - -(defun csv-tab-command () - "Skip to the next field on the same line. -Create a new field at end of line, if needed." - (interactive) - (skip-chars-forward csv--skip-chars) - (if (eolp) - (insert (car csv-separators)) - (forward-char 1))) - -(defun csv-backtab-command () - "Skip to the beginning of the previous field." - (interactive) - (skip-chars-backward csv--skip-chars) - (forward-char -1) - (skip-chars-backward csv--skip-chars)) - -(defun csv-sort-skip-fields (n &optional yank) - "Position point at the beginning of field N on the current line. -Fields are separated by `csv-separators'; null terminal field allowed. -Assumes point is initially at the beginning of the line. -YANK non-nil allows N to be greater than the number of fields, in -which case extend the record as necessary." - (if (> n 0) - ;; Skip across N - 1 fields. - (let ((i (1- n))) - (while (> i 0) - (csv-end-of-field) - (if (eolp) - (if yank - (if (> i 1) (insert (car csv-separators))) - (error "Line has too few fields: %s" - (buffer-substring - (save-excursion (beginning-of-line) (point)) - (save-excursion (end-of-line) (point))))) - (forward-char)) ; skip separator - (setq i (1- i)))) - (end-of-line) - ;; Skip back across -N - 1 fields. - (let ((i (1- (- n)))) - (while (> i 0) - (csv-beginning-of-field) - (if (bolp) - (error "Line has too few fields: %s" - (buffer-substring - (save-excursion (beginning-of-line) (point)) - (save-excursion (end-of-line) (point))))) - (backward-char) ; skip separator - (setq i (1- i))) - ;; Position at the front of the field - ;; even if moving backwards. - (csv-beginning-of-field)))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; Field index mode -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -;; Based partly on paren.el - -(defcustom csv-field-index-delay 0.125 - "Time in seconds to delay before updating field index display." - :type '(number :tag "seconds")) - -(defvar csv-field-index-idle-timer nil) - -(defvar csv-field-index-string nil) -(make-variable-buffer-local 'csv-field-index-string) - -(defvar csv-field-index-old nil) -(make-variable-buffer-local 'csv-field-index-old) - -(define-minor-mode csv-field-index-mode - "Toggle CSV-Field-Index mode. -With prefix ARG, turn CSV-Field-Index mode on if and only if ARG is positive. -Returns the new status of CSV-Field-Index mode (non-nil means on). -When CSV-Field-Index mode is enabled, the current field index appears in -the mode line after `csv-field-index-delay' seconds of Emacs idle time." - :global t - :init-value t ; for documentation, since default is t - ;; This macro generates a function that first sets the mode - ;; variable, then runs the following code, runs the mode hooks, - ;; displays a message if interactive, updates the mode line and - ;; finally returns the variable value. - - ;; First, always disable the mechanism (to avoid having two timers): - (when csv-field-index-idle-timer - (cancel-timer csv-field-index-idle-timer) - (setq csv-field-index-idle-timer nil)) - ;; Now, if the mode is on and any buffer is in CSV mode then - ;; re-initialize and enable the mechanism by setting up a new timer: - (if csv-field-index-mode - (if (memq t (mapcar (lambda (buffer) - (with-current-buffer buffer - (when (derived-mode-p 'csv-mode) - (setq csv-field-index-string nil - csv-field-index-old nil) - t))) - (buffer-list))) - (setq csv-field-index-idle-timer - (run-with-idle-timer csv-field-index-delay t - #'csv-field-index))) - ;; but if the mode is off then remove the display from the mode - ;; lines of all CSV buffers: - (mapc (lambda (buffer) - (with-current-buffer buffer - (when (derived-mode-p 'csv-mode) - (setq csv-field-index-string nil - csv-field-index-old nil) - (force-mode-line-update)))) - (buffer-list)))) - -(defun csv--field-index () - (save-excursion - (let ((start (point)) - (field 0)) - (beginning-of-line) - (while (and (<= (point) start) - (not (eolp))) - (csv-end-of-field) - (unless (eolp) - (forward-char 1)) - (setq field (1+ field))) - field))) - -(defun csv-field-index () - "Construct `csv-field-index-string' to display in mode line. -Called by `csv-field-index-idle-timer'." - (if (derived-mode-p 'csv-mode) - (let ((field (csv--field-index))) - (when (not (eq field csv-field-index-old)) - (setq csv-field-index-old field - csv-field-index-string - (and field (format "F%d" field))) - (force-mode-line-update))))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; Killing and yanking fields -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(defvar csv-killed-fields nil - "A list of the fields or sub-records last killed by `csv-kill-fields'.") - -(defun csv-kill-fields (fields beg end) - "Kill specified fields of each line in the region. -If not set, the region defaults to the CSV records around point. -Fields are separated by `csv-separators' and null fields are allowed anywhere. -Field indices increase from 1 on the left or decrease from -1 on the right. -The fields are stored for use by `csv-yank-fields'. Fields can be -specified in any order but are saved in increasing index order. -Ignore blank and comment lines. - -When called interactively, a prefix argument specifies a single field, -otherwise prompt for a field list, which may include ranges in the form -m-n, where m < n and n defaults to the last field index if omitted. - -When called non-interactively, FIELDS is a single field index or a -list of field indices, with ranges specified as (m.n) or (m), and BEG -and END specify the region to process." - ;; (interactive "*P\nr") - (interactive (csv-interactive-args 'multiple)) - (barf-if-buffer-read-only) - ;; Kill the field(s): - (setq csv-killed-fields nil) - (save-excursion - (save-restriction - (narrow-to-region beg end) - (goto-char (point-min)) - (if (or (cdr fields) (consp (car fields))) - (csv-kill-many-columns fields) - (csv-kill-one-column (car fields))))) - (setq csv-killed-fields (nreverse csv-killed-fields))) - -(defun csv-kill-one-field (field) - "Kill field with index FIELD in current line. -Return killed text. Assumes point is at beginning of line." - ;; Move to start of field to kill: - (csv-sort-skip-fields field) - ;; Kill to end of field (cf. `kill-region'): - (prog1 (delete-and-extract-region - (point) - (progn (csv-end-of-field) (point))) - (if (eolp) - (unless (bolp) (delete-char -1)) ; Delete trailing separator at eol - (delete-char 1)))) ; or following separator otherwise. - -(defun csv-kill-one-column (field) - "Kill field with index FIELD in all lines in (narrowed) buffer. -Save killed fields in `csv-killed-fields'. -Assumes point is at `point-min'. Called by `csv-kill-fields'. -Ignore blank and comment lines." - (while (not (eobp)) - (or (csv-not-looking-at-record) - (push (csv-kill-one-field field) csv-killed-fields)) - (forward-line))) - -(defun csv-insert-column (field) - "Insert an empty column at point." - (interactive - (let ((cur (csv--field-index))) - (list (if (and (csv--eof-p) (not (csv--bof-p))) (1+ cur) cur)))) - (save-excursion - (goto-char (point-min)) - (while (not (eobp)) - (or (csv-not-looking-at-record) - (progn - (csv-sort-skip-fields field t) - (insert (car csv-separators)))) - (forward-line 1)) - (csv--jit-flush-columns))) - -(defun csv-kill-many-columns (fields) - "Kill several fields in all lines in (narrowed) buffer. -FIELDS is an unordered list of field indices. -Save killed fields in increasing index order in `csv-killed-fields'. -Assumes point is at `point-min'. Called by `csv-kill-fields'. -Ignore blank and comment lines." - (if (eolp) (error "First record is empty")) - ;; Convert non-positive to positive field numbers: - (let ((last 1) (f fields)) - (csv-end-of-field) - (while (not (eolp)) - (forward-char) ; skip separator - (csv-end-of-field) - (setq last (1+ last))) ; last = # fields in first record - (while f - (cond ((consp (car f)) - ;; Expand a field range: (m.n) -> m m+1 ... n-1 n. - ;; If n is nil then it defaults to the number of fields. - (let* ((range (car f)) (cdrf (cdr f)) - (m (car range)) (n (cdr range))) - (if (< m 0) (setq m (+ m last 1))) - (if n - (if (< n 0) (setq n (+ n last 1))) - (setq n last)) - (setq range (list n)) - (while (> n m) (push (setq n (1- n)) range)) - (setcar f (car range)) - (setcdr f (cdr range)) - (setcdr (setq f (last range)) cdrf))) - ((zerop (car f)) (setcar f 1)) - ((< (car f) 0) (setcar f (+ f last 1)))) - (setq f (cdr f)))) - (goto-char (point-min)) - ;; Kill from right to avoid miscounting: - (setq fields (sort fields #'>)) - (while (not (eobp)) - (or (csv-not-looking-at-record) - (let ((fields fields) killed-fields field) - (while fields - (setq field (car fields) - fields (cdr fields)) - (beginning-of-line) - (push (csv-kill-one-field field) killed-fields)) - (push (mapconcat #'identity killed-fields (car csv-separators)) - csv-killed-fields))) - (forward-line))) - -(defun csv-yank-fields (field beg end) - "Yank fields as the ARGth field of each line in the region. -ARG may be arbitrarily large and records are extended as necessary. -If not set, the region defaults to the CSV records around point; -if point is not in a CSV record then offer to yank as a new table. -The fields yanked are those last killed by `csv-kill-fields'. -Fields are separated by `csv-separators' and null fields are allowed anywhere. -Field indices increase from 1 on the left or decrease from -1 on the right. -A prefix argument specifies a single field, otherwise prompt for field index. -Ignore blank and comment lines. When called non-interactively, FIELD -is a single field index; BEG and END specify the region to process." - ;; (interactive "*P\nr") - (interactive (condition-case err - (csv-interactive-args 'single) - (error (list nil nil err)))) - (barf-if-buffer-read-only) - (if (null beg) - (if (y-or-n-p (concat (error-message-string end) - ". Yank as a new table? ")) - (csv-yank-as-new-table) - (error (error-message-string end))) - (if (<= field 0) (setq field (1+ field))) - (save-excursion - (save-restriction - (narrow-to-region beg end) - (goto-char (point-min)) - (let ((fields csv-killed-fields)) - (while (not (eobp)) - (unless (csv-not-looking-at-record) - ;; Yank at start of specified field if possible, - ;; otherwise yank at end of record: - (if (zerop field) - (end-of-line) - (csv-sort-skip-fields field 'yank)) - (and (eolp) (insert (car csv-separators))) - (when fields - (insert (car fields)) - (setq fields (cdr fields))) - (or (eolp) (insert (car csv-separators)))) - (forward-line))))))) - -(defun csv-yank-as-new-table () - "Yank fields as a new table starting at point. -The fields yanked are those last killed by `csv-kill-fields'." - (interactive "*") - (let ((fields csv-killed-fields)) - (while fields - (insert (car fields) ?\n) - (setq fields (cdr fields))))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; Aligning fields -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(defun csv--make-overlay (beg end &optional buffer front-advance rear-advance props) - (let ((o (make-overlay beg end buffer front-advance rear-advance))) - (overlay-put o 'csv t) - (while props - (overlay-put o (pop props) (pop props))) - o)) - -(defun csv--delete-overlay (o) - (and (overlay-get o 'csv) (delete-overlay o))) - -(defun csv--column-widths (beg end) - "Return a list of two lists (COLUMN-WIDTHS FIELD-WIDTHS). -COLUMN-WIDTHS is a list of elements (WIDTH START END) -indicating the widths of the columns after point (and the position of the -widest field that determined the overall width). -FIELD-WIDTHS contains the widths of each individual field after -point." - (let ((column-widths '()) - (field-widths '())) - (goto-char beg) - ;; Construct list of column widths: - (while (< (point) end) ; for each record... - (or (csv-not-looking-at-record) - (let ((w column-widths) - (col (current-column)) - (beg (point)) - field-width) - (while (not (eolp)) - (csv-end-of-field) - (setq field-width (- (current-column) col)) - (push field-width field-widths) - (if w - (if (> field-width (caar w)) - (setcar w (list field-width beg (point)))) - (setq w (list (list field-width beg (point))) - column-widths (nconc column-widths w))) - (or (eolp) (forward-char)) ; Skip separator. - (setq w (cdr w) col (current-column) beg (point))))) - (forward-line)) - (list column-widths (nreverse field-widths)))) - -(defun csv-align-fields (hard beg end) - "Align all the fields in the region to form columns. -The alignment style is specified by `csv-align-style'. The number of -spaces specified by `csv-align-padding' appears after each separator. -Use soft alignment done by displaying virtual white space after the -separators unless invoked with an argument, in which case insert real -space characters into the buffer after the separators. -Unalign first (see `csv-unalign-fields'). Ignore blank and comment lines. - -In hard-aligned records, separators become invisible whenever -`buffer-invisibility-spec' is non-nil. In soft-aligned records, make -separators invisible if and only if `buffer-invisibility-spec' is -non-nil when the records are aligned; this can be changed only by -re-aligning. \(Unaligning always makes separators visible.) - -When called non-interactively, use hard alignment if HARD is non-nil; -BEG and END specify the region to align. -If there is no selected region, default to the whole buffer." - (interactive (cons current-prefix-arg - (if (use-region-p) - (list (region-beginning) (region-end)) - (list (point-min) (point-max))))) - ;; FIXME: Use csv--jit-align when applicable! - (setq end (copy-marker end)) - (csv-unalign-fields hard beg end) ; If hard then barfs if buffer read only. - (save-excursion - (pcase-let ((`(,column-widths ,field-widths) (csv--column-widths beg end))) - (save-restriction - (narrow-to-region beg end) - (set-marker end nil) - - ;; Align fields: - (goto-char (point-min)) - (while (not (eobp)) ; for each record... - (unless (csv-not-looking-at-record) - (let ((w column-widths) - (column 0)) ;Desired position of left-side of this column. - (while (and w (not (eolp))) - (let* ((beg (point)) - (align-padding (if (bolp) 0 csv-align-padding)) - (left-padding 0) (right-padding 0) - (field-width (pop field-widths)) - (column-width (car (pop w))) - (x (- column-width field-width))) ; Required padding. - (csv-end-of-field) - (set-marker end (point)) ; End of current field. - ;; beg = beginning of current field - ;; end = (point) = end of current field - - ;; Compute required padding: - (cond - ((eq csv-align-style 'left) - ;; Left align -- pad on the right: - (setq left-padding align-padding - right-padding x)) - ((eq csv-align-style 'right) - ;; Right align -- pad on the left: - (setq left-padding (+ align-padding x))) - ((eq csv-align-style 'auto) - ;; Auto align -- left align text, right align numbers: - (if (string-match "\\`[-+.[:digit:]]+\\'" - (buffer-substring beg (point))) - ;; Right align -- pad on the left: - (setq left-padding (+ align-padding x)) - ;; Left align -- pad on the right: - (setq left-padding align-padding - right-padding x))) - ((eq csv-align-style 'centre) - ;; Centre -- pad on both left and right: - (let ((y (/ x 2))) ; truncated integer quotient - (setq left-padding (+ align-padding y) - right-padding (- x y))))) - - (cond - (hard ;; Hard alignment... - (when (> left-padding 0) ; Pad on the left. - ;; Insert spaces before field: - (if (= beg end) ; null field - (insert (make-string left-padding ?\ )) - (goto-char beg) ; beginning of current field - (insert (make-string left-padding ?\ )) - (goto-char end))) ; end of current field - (unless (eolp) - (if (> right-padding 0) ; pad on the right - ;; Insert spaces after field: - (insert (make-string right-padding ?\ ))) - ;; Make separator (potentially) invisible; - ;; in Emacs 21.3, neighbouring overlays - ;; conflict, so use the following only - ;; with hard alignment: - (csv--make-overlay (point) (1+ (point)) nil t nil - '(invisible csv evaporate t)) - (forward-char))) ; skip separator - - ;; Soft alignment... - ((or (memq 'csv buffer-invisibility-spec) - ;; For TSV, hidden or not doesn't make much difference, - ;; but the behavior is slightly better when we "hide" - ;; the TABs with a `display' property than if we add - ;; before/after-strings. - (tsv--mode-p)) - - ;; Hide separators... - ;; Merge right-padding from previous field - ;; with left-padding from this field: - (if (zerop column) - (when (> left-padding 0) - ;; Display spaces before first field - ;; by overlaying first character: - (csv--make-overlay - beg (1+ beg) nil nil nil - `(before-string ,(make-string left-padding ?\ )))) - ;; Display separator as spaces: - (with-silent-modifications - (put-text-property - (1- beg) beg - 'display `(space :align-to - ,(+ left-padding column))))) - (unless (eolp) (forward-char)) ; Skip separator. - (setq column (+ column column-width align-padding))) - - (t ;; Do not hide separators... - (let ((overlay (csv--make-overlay beg (point) nil nil t))) - (when (> left-padding 0) ; Pad on the left. - ;; Display spaces before field: - (overlay-put overlay 'before-string - (make-string left-padding ?\ ))) - (unless (eolp) - (if (> right-padding 0) ; Pad on the right. - ;; Display spaces after field: - (overlay-put - overlay - 'after-string (make-string right-padding ?\ ))) - (forward-char)))) ; Skip separator. - - ))))) - (forward-line))))) - (set-marker end nil)) - -(defun csv-unalign-fields (hard beg end) - "Undo soft alignment and optionally remove redundant white space. -Undo soft alignment introduced by `csv-align-fields'. If invoked with -an argument then also remove all spaces and tabs around separators. -Also make all invisible separators visible again. -Ignore blank and comment lines. When called non-interactively, remove -spaces and tabs if HARD non-nil; BEG and END specify region to unalign. -If there is no selected region, default to the whole buffer." - (interactive (cons current-prefix-arg - (if (use-region-p) - (list (region-beginning) (region-end)) - (list (point-min) (point-max))))) - ;; Remove any soft alignment: - (mapc #'csv--delete-overlay (overlays-in beg end)) - (with-silent-modifications - (remove-list-of-text-properties beg end '(display invisible))) - (when hard - (barf-if-buffer-read-only) - ;; Remove any white-space padding around separators: - (save-excursion - (save-restriction - (narrow-to-region beg end) - (goto-char (point-min)) - (while (not (eobp)) - (or (csv-not-looking-at-record) - (while (not (eolp)) - ;; Delete horizontal white space forward: - ;; (delete-horizontal-space) - ;; This relies on left-to-right argument evaluation; - ;; see info node (elisp) Function Forms. - (delete-region (point) - (+ (point) (skip-chars-forward " \t"))) - (csv-end-of-field) - ;; Delete horizontal white space backward: - ;; (delete-horizontal-space t) - (delete-region (point) - (+ (point) (skip-chars-backward " \t"))) - (or (eolp) (forward-char)))) - (forward-line)))))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; Transposing rows and columns -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(defun csv-transpose (beg end) - "Rewrite rows (which may have different lengths) as columns. -Null fields are introduced as necessary within records but are -stripped from the ends of records. Preserve soft alignment. -This function is its own inverse. Ignore blank and comment lines. -When called non-interactively, BEG and END specify region to process." - ;; (interactive "*P\nr") - (interactive (csv-interactive-args 'noarg)) - (barf-if-buffer-read-only) - (save-excursion - (save-restriction - (narrow-to-region beg end) - (goto-char (point-min)) - ;; Delete rows and collect them as a reversed list of lists of - ;; fields, skipping comment and blank lines: - (let ((sep (car csv-separators)) - (align (overlays-in beg end)) - rows columns) - ;; Remove soft alignment if necessary: - (when align - (mapc #'csv--delete-overlay align) - (setq align t)) - (while (not (eobp)) - (if (csv-not-looking-at-record) - ;; Skip blank and comment lines: - (forward-line) - (let ((lep (line-end-position))) - (push - (csv--collect-fields lep) - rows) - (delete-region (point) lep) - (or (eobp) (delete-char 1))))) - ;; Rows must have monotonic decreasing lengths to be - ;; transposable, so ensure this by padding with null fields. - ;; rows is currently a reversed list of field lists, which - ;; must therefore have monotonic increasing lengths. - (let ((oldlen (length (car rows))) newlen - (r (cdr rows))) - (while r - (setq newlen (length (car r))) - (if (< newlen oldlen) - (nconc (car r) (make-list (- oldlen newlen) nil)) - (setq oldlen newlen)) - (setq r (cdr r)))) - ;; Collect columns as a reversed list of lists of fields: - (while rows - (let (column (r rows) row) - (while r - (setq row (car r)) - ;; Provided it would not be a trailing null field, push - ;; field onto column: - (if (or column (string< "" (car row))) - (push (car row) column)) - ;; Pop field off row: - (setcar r (cdr row)) - ;; If row is now empty then remove it: - (or (car r) (setq rows (cdr rows))) - (setq r (cdr r))) - (push column columns))) - ;; Insert columns into buffer as rows: - (setq columns (nreverse columns)) - (while columns - (insert (mapconcat #'identity (car columns) sep) ?\n) - (setq columns (cdr columns))) - ;; Re-do soft alignment if necessary: - (if align (csv-align-fields nil (point-min) (point-max))))))) - -(defun csv--collect-fields (row-end-position) - "Collect the fields of a row. -Splits a row into fields, honoring quoted fields, and returns -the list of fields. ROW-END-POSITION is the end-of-line position. -point is assumed to be at the beginning of the line." - (let ((csv-field-quotes-regexp (apply #'concat `("[" ,@csv-field-quotes "]"))) - (row-text (buffer-substring-no-properties (point) row-end-position)) - fields field-start) - (if (not (string-match csv-field-quotes-regexp row-text)) - (split-string row-text csv-separator-regexp) - (save-excursion - (while (< (setq field-start (point)) row-end-position) - ;; csv-forward-field will skip a separator if point is on - ;; it, and we'll miss an empty field - (unless (memq (following-char) csv-separator-chars) - (csv-forward-field 1)) - (push - (buffer-substring-no-properties field-start (point)) - fields) - (if (memq (following-char) csv-separator-chars) - (forward-char))) - (nreverse fields))))) - -(defvar-local csv--header-line nil) -(defvar-local csv--header-hscroll nil) -(defvar-local csv--header-string nil) - -(defun csv-header-line (&optional use-current-line) - "Set/unset the header line. -If the optional prefix arg USE-CURRENT-LINE is nil, use the first line -as the header line. -If there is already a header line, then unset the header line." - (interactive "P") - (if csv--header-line - (progn - (delete-overlay csv--header-line) - (setq csv--header-line nil) - (kill-local-variable 'header-line-format)) - (save-excursion - (unless use-current-line (goto-char (point-min))) - (setq csv--header-line (make-overlay (line-beginning-position) - (line-end-position) - nil nil t)) - (overlay-put csv--header-line 'modification-hooks - '(csv--header-flush))) - (csv--header-flush) - ;; These are introduced in Emacs 29. - (unless (boundp 'header-line-indent) - (setq-local header-line-indent "" - header-line-indent-width 0)) - (setq header-line-format - '("" header-line-indent (:eval (csv--header-string)))))) - -(defun csv--header-flush (&rest _) - ;; Force re-computation of the header-line. - (setq csv--header-hscroll nil)) - -(defun csv--header-string () - ;; FIXME: Won't work with multiple windows showing that same buffer. - (if (eql (window-hscroll) csv--header-hscroll) - csv--header-string - (setq csv--header-hscroll (window-hscroll)) - (setq csv--header-string - (csv--compute-header-string)))) - -(defun csv--compute-header-string () - (with-demoted-errors "csv--compute-header-string %S" - (save-excursion - (goto-char (overlay-start csv--header-line)) - ;; Re-set the line-end-position, just in case. - (move-overlay csv--header-line (point) (line-end-position)) - (jit-lock-fontify-now (point) (line-end-position)) - ;; Not sure why it is sometimes nil! - (move-to-column (or csv--header-hscroll 0)) - (let ((str (replace-regexp-in-string - "%" "%%" (buffer-substring (point) (line-end-position)))) - (i 0)) - (while (and i (< i (length str))) - (let ((prop (get-text-property i 'display str))) - (and (eq (car-safe prop) 'space) - (eq (car-safe (cdr prop)) :align-to) - (let* ((x (nth 2 prop)) - (nexti (next-single-property-change i 'display str)) - (newprop - `(space :align-to - (+ ,(if (numberp x) - (- x (or csv--header-hscroll 0)) - `(- ,x csv--header-hscroll)) - header-line-indent-width)))) - (put-text-property i (or nexti (length str)) - 'display newprop str) - (setq i nexti)))) - (setq i (next-single-property-change i 'display str))) - (concat (propertize " " 'display '((space :align-to 0))) str))))) - -;;; Auto-alignment - -(defcustom csv-align-max-width 40 - "Maximum width of a column in `csv-align-mode'. -This does not apply to the last column (for which the usual `truncate-lines' -setting works better)." - :type 'integer) - -(defcustom csv-align-min-width 1 - "Minimum width of a column in `csv-align-mode'." - :type 'integer) - -(defvar-local csv--config-column-widths nil - "Settings per column, stored as a list indexed by the column.") - -(defun csv-align--set-column (column value) - (let ((len (length csv--config-column-widths))) - (if (< len column) - (setq csv--config-column-widths - (nconc csv--config-column-widths (make-list (- column len) nil)))) - (setf (nth (1- column) csv--config-column-widths) value))) - -(defun csv-align-set-column-width (column width) - "Set the max WIDTH to use for COLUMN." - (interactive - (let* ((field (or (csv--field-index) 1)) - (curwidth (nth (1- field) csv--config-column-widths))) - (list field - (cond - ((numberp current-prefix-arg) - current-prefix-arg) - (current-prefix-arg - (read-number (format "Column width (for field %d): " field) - curwidth)) - (t (if curwidth nil (csv--ellipsis-width))))))) - (when (eql width csv-align-max-width) - (setq width nil)) - (csv-align--set-column column width) - (jit-lock-refontify)) - -(defvar-local csv--jit-columns nil) - -(defun csv--jit-flush-columns () - "Throw away all cached info about column widths." - ;; FIXME: Maybe we should kill its overlays as well. - (setq csv--jit-columns nil)) - -(defun csv--jit-merge-columns (column-widths) - ;; FIXME: The incremental update (delayed by jit-lock-context-time) of column - ;; width is a bit jarring at times. It's OK while scrolling or when - ;; extending a column, but not right when enabling the csv-align-mode or - ;; when shortening the longest field (or deleting the line containing it), - ;; because in that case we have *several* cascaded updates, e.g.: - ;; - Remove the line with the longest field of column N. - ;; - Edit some line: this line is updated as if its field was the widest, - ;; hence its subsequent fields are too much to the left. - ;; - The rest is updated starting from the first few lines (according - ;; to jit-lock-chunk-size). - ;; - After the first few lines, come the next set of few lines, - ;; which may cause the previous few lines to need refresh again. - ;; - etc.. until arriving again at the edited line which is re-aligned - ;; again. - ;; - etc.. until the end of the windows, potentially causing yet more - ;; refreshes as we discover yet-wider fields for this column. - (let ((old-columns csv--jit-columns) - (changed nil)) - (while (and old-columns column-widths) - (when (or (> (caar column-widths) (caar old-columns)) - ;; Apparently modification-hooks aren't run when the - ;; whole text containing the overlay is deleted (e.g. - ;; the whole line), so detect this case here. - ;; It's a bit too late, but better than never. - (null (overlay-buffer (cdar old-columns)))) - (setq changed t) ;; Return non-nil if some existing column changed. - (pcase-let ((`(,width ,beg ,end) (car column-widths))) - (setf (caar old-columns) width) - (move-overlay (cdar old-columns) beg end))) - (setq old-columns (cdr old-columns)) - (setq column-widths (cdr column-widths))) - (when column-widths - ;; New columns appeared. - (setq csv--jit-columns - (nconc csv--jit-columns - (mapcar (lambda (x) - (pcase-let* - ((`(,width ,beg ,end) x) - (ol (make-overlay beg end))) - (overlay-put ol 'csv-width t) - (overlay-put ol 'evaporate t) - (overlay-put ol 'modification-hooks - (list #'csv--jit-width-change)) - (cons width ol))) - column-widths)))) - changed)) - -(defun csv--jit-width-change (ol after _beg _end &optional len) - (when (and after (> len 0)) - ;; (let ((x (rassq ol csv--jit-columns))) - ;; (when x (setf (car x) -1))) - (delete-overlay ol))) - -(defun csv--jit-unalign (beg end) - (with-silent-modifications - (remove-text-properties beg end - '( display nil csv--jit nil invisible nil - cursor-sensor-functions nil csv--revealed nil)) - (remove-overlays beg end 'csv--jit t))) - -(defun csv--jit-flush (beg end) - "Cause all the buffer (except for the BEG...END region) to be re-aligned." - (cl-assert (>= end beg)) - ;; The buffer shouldn't have changed since beg/end were computed, - ;; but just in case, let's make sure they're still sane. - (when (< beg (point-min)) - (setq beg (point-min) end (max end beg))) - (when (< (point-max) end) - (setq end (point-max) beg (min end beg))) - (let ((pos (point-min))) - (while (and (< pos beg) - (setq pos (text-property-any pos beg 'csv--jit t))) - (jit-lock-refontify - pos (setq pos (or (text-property-any pos beg 'csv--jit nil) beg)))) - (setq pos end) - (while (and (< pos (point-max)) - (setq pos (text-property-any pos (point-max) 'csv--jit t))) - (jit-lock-refontify - pos (setq pos (or (text-property-any pos (point-max) 'csv--jit nil) - (point-max)))))) - (csv--header-flush)) - -(defun csv--ellipsis-width () - (let ((ellipsis - (when standard-display-table - (display-table-slot standard-display-table - 'selective-display)))) - (if ellipsis (length ellipsis) 3))) - -(defun csv-align--cursor-truncated (window oldpos dir) - ;; FIXME: Neither the `entered' nor the `left' event are guaranteed - ;; to be sent, and for the `left' case, even when we do get called, - ;; it may be unclear where the revealed text was (it's somewhere around - ;; `oldpos', but that position can be stale). - ;; Worse, if we have several windows displaying the buffer, when one - ;; cursor leaves we may need to keep the text revealed because of - ;; another window's cursor. - (let* ((prop (if (eq dir 'entered) 'invisible 'csv--revealed)) - (pos (cond - ((eq dir 'entered) (window-point window)) - (t (max (point-min) - (min (point-max) - (or oldpos (window-point window))))))) - (start (cond - ((and (> pos (point-min)) - (eq (get-text-property (1- pos) prop) 'csv-truncate)) - (or (previous-single-property-change pos prop) (point-min))) - (t pos))) - (end (if (eq (get-text-property pos prop) 'csv-truncate) - (or (next-single-property-change pos prop) (point-max)) - pos))) - (unless (eql start end) - (with-silent-modifications - (put-text-property start end - (if (eq dir 'entered) 'csv--revealed 'invisible) - 'csv-truncate) - (remove-text-properties start end (list prop)))))) - -(defun csv--jit-align (beg end) - (save-excursion - ;; This is run with inhibit-modification-hooks set, so the overlays' - ;; modification-hook doesn't work :-( - (and csv--header-line - (<= beg (overlay-end csv--header-line)) - (>= end (overlay-start csv--header-line)) - (csv--header-flush)) - ;; First, round up to a whole number of lines. - (goto-char end) - (unless (bolp) (forward-line 1) (setq end (point))) - (goto-char beg) - (unless (bolp) (forward-line 1) (setq beg (point))) - (csv--jit-unalign beg end) - (put-text-property beg end 'csv--jit t) - - (pcase-let* ((`(,column-widths ,field-widths) (csv--column-widths beg end)) - (changed (csv--jit-merge-columns column-widths)) - (ellipsis-width (csv--ellipsis-width))) - (when changed - ;; Do it after the current redisplay is over. - (run-with-timer jit-lock-context-time nil #'csv--jit-flush beg end)) - - ;; Align fields: - (goto-char beg) - (while (< (point) end) - (unless (csv-not-looking-at-record) - (let ((w csv--jit-columns) - (widths-config csv--config-column-widths) - (column 0)) ;Desired position of left-side of this column. - (while (and w (not (eolp))) - (let* ((field-beg (point)) - (width-config (pop widths-config)) - (align-padding (if (bolp) 0 csv-align-padding)) - (left-padding 0) (right-padding 0) - (field-width (pop field-widths)) - (column-width - (min (max csv-align-min-width - (car (pop w))) - (or width-config - ;; Don't apply csv-align-max-width - ;; to the last field! - (if w csv-align-max-width - most-positive-fixnum)))) - (x (- column-width field-width)) ; Required padding. - (truncate nil)) - (csv-end-of-field) - ;; beg = beginning of current field - ;; end = (point) = end of current field - (when (< x 0) - (setq truncate (max column - (+ column column-width - align-padding (- ellipsis-width)))) - (setq x 0)) - ;; Compute required padding: - (pcase csv-align-style - ('left - ;; Left align -- pad on the right: - (setq left-padding align-padding - right-padding x)) - ('right - ;; Right align -- pad on the left: - (setq left-padding (+ align-padding x))) - ('auto - ;; Auto align -- left align text, right align numbers: - (if (string-match "\\`[-+.[:digit:]]+\\'" - (buffer-substring field-beg (point))) - ;; Right align -- pad on the left: - (setq left-padding (+ align-padding x)) - ;; Left align -- pad on the right: - (setq left-padding align-padding - right-padding x))) - ('centre - ;; Centre -- pad on both left and right: - (let ((y (/ x 2))) ; truncated integer quotient - (setq left-padding (+ align-padding y) - right-padding (- x y))))) - - (cond - - ((or (memq 'csv buffer-invisibility-spec) - ;; For TSV, hidden or not doesn't make much difference, - ;; but the behavior is slightly better when we "hide" - ;; the TABs with a `display' property than if we add - ;; before/after-strings. - (tsv--mode-p)) - - ;; Hide separators... - ;; Merge right-padding from previous field - ;; with left-padding from this field: - (if (zerop column) - (when (> left-padding 0) - ;; Display spaces before first field - ;; by overlaying first character: - (csv--make-overlay - field-beg (1+ field-beg) nil nil nil - `(before-string ,(make-string left-padding ?\ ) - csv--jit t))) - ;; Display separator as spaces: - (with-silent-modifications - (put-text-property - (1- field-beg) field-beg - 'display `(space :align-to - ,(+ left-padding column)))))) - - (t ;; Do not hide separators... - (let ((overlay (csv--make-overlay field-beg (point) - nil nil t - '(csv--jit t)))) - (when (> left-padding 0) ; Pad on the left. - ;; Display spaces before field: - (overlay-put overlay 'before-string - (make-string left-padding ?\ ))) - (unless (eolp) - (if (> right-padding 0) ; Pad on the right. - ;; Display spaces after field: - (overlay-put - overlay - 'after-string (make-string right-padding ?\ ))))))) - (setq column (+ column column-width align-padding)) - ;; Do it after applying the property, so `move-to-column' can - ;; take it into account. - (when truncate - (let ((trunc-pos - (save-excursion - ;; ¡¡ BIG UGLY HACK !! - ;; `current-column' and `move-to-column' count - ;; text hidden with an ellipsis "as if" it were - ;; fully visible, which is completely wrong here, - ;; so circumvent this by temporarily pretending - ;; that `csv-truncate' is fully invisible (which - ;; isn't quite right either, but should work - ;; just well enough for us here). - (let ((buffer-invisibility-spec - buffer-invisibility-spec)) - (add-to-invisibility-spec 'csv-truncate) - (move-to-column truncate)) - (point)))) - (put-text-property trunc-pos (point) - 'invisible 'csv-truncate) - (when (> (- (point) trunc-pos) 1) - ;; Arrange to temporarily untruncate the string when - ;; cursor moves into it. - ;; FIXME: This only works if - ;; `global-disable-point-adjustment' is non-nil! - ;; Arguably this should be fixed by making - ;; point-adjustment code pay attention to - ;; cursor-sensor-functions! - (put-text-property - (1+ trunc-pos) (point) - 'cursor-sensor-functions - (list #'csv-align--cursor-truncated))))) - (unless (eolp) (forward-char)) ; Skip separator. - )))) - (forward-line))) - `(jit-lock-bounds ,beg . ,end))) - -(define-minor-mode csv-align-mode - "Align columns on the fly." - :global nil - (csv-unalign-fields nil (point-min) (point-max)) ;Just in case. - (cond - (csv-align-mode - (add-to-invisibility-spec '(csv-truncate . t)) - (kill-local-variable 'csv--jit-columns) - (cursor-sensor-mode 1) - (when (fboundp 'header-line-indent-mode) - (header-line-indent-mode)) - (jit-lock-register #'csv--jit-align) - (jit-lock-refontify)) - (t - (remove-from-invisibility-spec '(csv-truncate . t)) - (jit-lock-unregister #'csv--jit-align) - (csv--jit-unalign (point-min) (point-max)))) - (csv--header-flush)) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; Separator guessing -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(defvar csv--preferred-separators - '(?, ?\; ?\t) - "Preferred separator characters in case of a tied score.") - -(defun csv-guess-set-separator () - "Guess and set the CSV separator of the current buffer. - -Add it to the mode hook to have CSV mode guess and set the -separator automatically when visiting a buffer: - - (add-hook \\='csv-mode-hook \\='csv-guess-set-separator)" - (interactive) - (let ((sep (csv-guess-separator - (buffer-substring-no-properties - (point-min) - ;; We're probably only going to look at the first 2048 - ;; or so chars, but take more than we probably need to - ;; minimize the chance of breaking the input in the - ;; middle of a (long) row. - (min 8192 (point-max))) - 2048))) - (when sep - (csv-set-separator sep)))) - -(defun csv-guess-separator (text &optional cutoff) - "Return a guess of which character is the CSV separator in TEXT." - (let ((best-separator nil) - (best-score 0)) - (dolist (candidate (csv--separator-candidates text cutoff)) - (let ((candidate-score - (csv--separator-score candidate text cutoff))) - (when (or (> candidate-score best-score) - (and (= candidate-score best-score) - (member candidate csv--preferred-separators))) - (setq best-separator candidate) - (setq best-score candidate-score)))) - best-separator)) - -(defun csv--separator-candidates (text &optional cutoff) - "Return a list of candidate CSV separators in TEXT. -When CUTOFF is passed, look only at the first CUTOFF number of characters." - (let ((chars (make-hash-table))) - (dolist (c (string-to-list - (if cutoff - (substring text 0 (min cutoff (length text))) - text))) - (when (and (not (gethash c chars)) - (or (= c ?\t) - (and (not (member c '(?. ?/ ?\" ?'))) - (not (member (get-char-code-property c 'general-category) - '(Lu Ll Lt Lm Lo Nd Nl No Ps Pe Cc Co)))))) - (puthash c t chars))) - (hash-table-keys chars))) - -(defun csv--separator-score (separator text &optional cutoff) - "Return a score on how likely SEPARATOR is a separator in TEXT. - -When CUTOFF is passed, stop the calculation at the next whole -line after having read CUTOFF number of characters. - -The scoring is based on the idea that most CSV data is tabular, -i.e. separators should appear equally often on each line. -Furthermore, more commonly appearing characters are scored higher -than those who appear less often. - -Adapted from the paper \"Wrangling Messy CSV Files by Detecting -Row and Type Patterns\" by Gerrit J.J. van den Burg , Alfredo -Nazábal, and Charles Sutton: https://arxiv.org/abs/1811.11242." - (let ((groups - (with-temp-buffer - (csv-set-separator separator) - (save-excursion - (insert text)) - (let ((groups (make-hash-table)) - (chars-read 0)) - (while (and (/= (point) (point-max)) - (or (not cutoff) - (< chars-read cutoff))) - (let* ((lep (line-end-position)) - (nfields (length (csv--collect-fields lep)))) - (cl-incf (gethash nfields groups 0)) - (cl-incf chars-read (- lep (point))) - (goto-char (+ lep 1)))) - groups))) - (sum 0)) - (maphash - (lambda (length num) - (cl-incf sum (* num (/ (- length 1) (float length))))) - groups) - (let ((unique-groups (hash-table-count groups))) - (if (= 0 unique-groups) - 0 - (/ sum unique-groups))))) - -;;; TSV support - -;; Since "the" CSV format is really a bunch of different formats, it includes -;; TSV as a subcase, but this subcase is sufficiently interesting that it has -;; its own mime-type and mostly standard file extension, also it suffers -;; less from the usual quoting problems of CSV (because the only problematic -;; chars are LF and TAB, really, which are much less common inside fields than -;; commas, space, and semi-colons) so it's "better behaved". - -(defvar tsv-mode-syntax-table - ;; Inherit from `text-mode-syntax-table' rather than from - ;; `csv-mode-syntax-table' so as not to inherit the - ;; `csv-field-quotes' settings. - (let ((st (make-syntax-table text-mode-syntax-table))) - st)) - -(defvar tsv-mode-map - (let ((map (make-sparse-keymap))) - ;; In `tsv-mode', the `csv-invisibility-default/csv-toggle-invisibility' - ;; business doesn't make much sense. - (define-key map [remap csv-toggle-invisibility] #'undefined) - map)) - -;;;###autoload -(add-to-list 'auto-mode-alist '("\\.tsv\\'" . tsv-mode)) - -(defun tsv--mode-p () - (equal csv-separator-chars '(?\t))) - -;;;###autoload -(define-derived-mode tsv-mode csv-mode "TSV" - "Major mode for editing files of tab-separated value type." - :group 'CSV - ;; In TSV we know TAB is the only possible separator. - (setq-local csv-separators '("\t")) - ;; FIXME: Copy&pasted from the `:set'ter of csv-separators! - (setq-local csv-separator-chars '(?\t)) - (setq-local csv--skip-chars "^\n\t") - (setq-local csv-separator-regexp "\t") - (setq-local csv-font-lock-keywords - ;; NB: csv-separator-face variable evaluates to itself. - `((,csv-separator-regexp (0 'csv-separator-face)))) - - ;; According to wikipedia, TSV doesn't use quotes but uses backslash escapes - ;; of the form \n, \t, \r, and \\ instead. - (setq-local csv-field-quotes nil)) - - -(provide 'csv-mode) - -;;; csv-mode.el ends here diff --git a/emacs/elpa/csv-mode-1.23/csv-mode.elc b/emacs/elpa/csv-mode-1.23/csv-mode.elc Binary files differ. diff --git a/emacs/elpa/csv-mode-1.25.signed b/emacs/elpa/csv-mode-1.25.signed @@ -0,0 +1 @@ +Good signature from 645357D2883A0966 GNU ELPA Signing Agent (2023) <elpasign@elpa.gnu.org> (trust undefined) created at 2024-05-29T09:05:02+0000 using EDDSA +\ No newline at end of file diff --git a/emacs/elpa/csv-mode-1.23/csv-mode-autoloads.el b/emacs/elpa/csv-mode-1.25/csv-mode-autoloads.el diff --git a/emacs/elpa/csv-mode-1.25/csv-mode-pkg.el b/emacs/elpa/csv-mode-1.25/csv-mode-pkg.el @@ -0,0 +1,2 @@ +;; Generated package description from csv-mode.el -*- no-byte-compile: t -*- +(define-package "csv-mode" "1.25" "Major mode for editing comma/char separated values" '((emacs "27.1") (cl-lib "0.5")) :commit "6e8b70504236325989b2f6e19b38602a23f57ba3" :url "https://elpa.gnu.org/packages/csv-mode.html" :authors '(("Francis J. Wright" . "F.J.Wright@qmul.ac.uk")) :maintainer '(nil . "emacs-devel@gnu.org") :keywords '("convenience")) diff --git a/emacs/elpa/csv-mode-1.25/csv-mode-tests.el b/emacs/elpa/csv-mode-1.25/csv-mode-tests.el @@ -0,0 +1,174 @@ +;;; csv-mode-tests.el --- Tests for CSV mode -*- lexical-binding: t; -*- + +;; Copyright (C) 2020-2022 Free Software Foundation, Inc + +;; Author: Simen Heggestøyl <simenheg@runbox.com> +;; Keywords: + +;; 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 <https://www.gnu.org/licenses/>. + +;;; Commentary: + +;; + +;;; Code: + +(require 'ert) +(require 'csv-mode) +(eval-when-compile (require 'subr-x)) + +(ert-deftest csv-tests-end-of-field () + (with-temp-buffer + (csv-mode) + (insert "aaa,bbb") + (goto-char (point-min)) + (csv-end-of-field) + (should (equal (buffer-substring (point-min) (point)) "aaa")) + (forward-char) + (csv-end-of-field) + (should (equal (buffer-substring (point-min) (point)) + "aaa,bbb")))) + +(ert-deftest csv-tests-end-of-field-with-quotes () + (with-temp-buffer + (csv-mode) + (insert "aaa,\"b,b\"") + (goto-char (point-min)) + (csv-end-of-field) + (should (equal (buffer-substring (point-min) (point)) "aaa")) + (forward-char) + (csv-end-of-field) + (should (equal (buffer-substring (point-min) (point)) + "aaa,\"b,b\"")))) + +(ert-deftest csv-tests-beginning-of-field () + (with-temp-buffer + (csv-mode) + (insert "aaa,bbb") + (csv-beginning-of-field) + (should (equal (buffer-substring (point) (point-max)) "bbb")) + (backward-char) + (csv-beginning-of-field) + (should (equal (buffer-substring (point) (point-max)) + "aaa,bbb")))) + +(ert-deftest csv-tests-beginning-of-field-with-quotes () + (with-temp-buffer + (csv-mode) + (insert "aaa,\"b,b\"") + (csv-beginning-of-field) + (should (equal (buffer-substring (point) (point-max)) "\"b,b\"")) + (backward-char) + (csv-beginning-of-field) + (should (equal (buffer-substring (point) (point-max)) + "aaa,\"b,b\"")))) + +(defun csv-tests--align-fields (before after) + (with-temp-buffer + (insert (string-join before "\n")) + (csv-align-fields t (point-min) (point-max)) + (should (equal (buffer-string) (string-join after "\n"))))) + +(ert-deftest csv-tests-align-fields () + (csv-tests--align-fields + '("aaa,bbb,ccc" + "1,2,3") + '("aaa, bbb, ccc" + "1 , 2 , 3"))) + +(ert-deftest csv-tests-align-fields-with-quotes () + (csv-tests--align-fields + '("aaa,\"b,b\",ccc" + "1,2,3") + '("aaa, \"b,b\", ccc" + "1 , 2 , 3"))) + +;; Bug#14053 +(ert-deftest csv-tests-align-fields-double-quote-comma () + (csv-tests--align-fields + '("1,2,3" + "a,\"b\"\"c,\",d") + '("1, 2 , 3" + "a, \"b\"\"c,\", d"))) + +(defvar csv-tests--data + "1,4;Sun, 2022-04-10;4,12 +8;Mon, 2022-04-11;3,19 +3,2;Tue, 2022-04-12;1,00 +2;Wed, 2022-04-13;0,37 +9;Wed, 2022-04-13;0,37") + +(ert-deftest csv-tests-guess-separator () + (should-not (csv-guess-separator "")) + (should (= (csv-guess-separator csv-tests--data 3) ?,)) + (should (= (csv-guess-separator csv-tests--data) ?\;)) + (should (= (csv-guess-separator csv-tests--data) + (csv-guess-separator csv-tests--data + (length csv-tests--data))))) + +(ert-deftest csv-tests-separator-candidates () + (should-not (csv--separator-candidates "")) + (should-not (csv--separator-candidates csv-tests--data 0)) + (should + (equal (sort (csv--separator-candidates csv-tests--data 4) #'<) + '(?, ?\;))) + (should + (equal (sort (csv--separator-candidates csv-tests--data) #'<) + '(?\s ?, ?- ?\;))) + (should + (equal + (sort (csv--separator-candidates csv-tests--data) #'<) + (sort (csv--separator-candidates csv-tests--data + (length csv-tests--data)) + #'<)))) + +(ert-deftest csv-tests-separator-score () + (should (< (csv--separator-score ?, csv-tests--data) + (csv--separator-score ?\s csv-tests--data) + (csv--separator-score ?- csv-tests--data))) + (should (= (csv--separator-score ?- csv-tests--data) + (csv--separator-score ?\; csv-tests--data))) + (should (= 0 (csv--separator-score ?\; csv-tests--data 0))) + (should (= (csv--separator-score ?\; csv-tests--data) + (csv--separator-score ?\; csv-tests--data + (length csv-tests--data))))) + +(ert-deftest csv-tests-unquote-value () + (should (equal (csv--unquote-value "Hello, World") + "Hello, World")) + (should (equal (csv--unquote-value "\"Hello, World\"") + "Hello, World")) + (should (equal (csv--unquote-value "Hello, \"\"World") + "Hello, \"\"World")) + (should (equal (csv--unquote-value "\"Hello, \"\"World\"\"\"") + "Hello, \"World\"")) + (should (equal (csv--unquote-value "'Hello, World'") + "'Hello, World'")) + (should (equal (let ((csv-field-quotes '("\"" "'"))) + (csv--unquote-value "\"Hello, World'")) + "\"Hello, World'")) + (should (equal (let ((csv-field-quotes '("\"" "'"))) + (csv--unquote-value "'Hello, World'")) + "Hello, World")) + (should (equal (let ((csv-field-quotes '("\"" "'"))) + (csv--unquote-value "'Hello, ''World'''")) + "Hello, 'World'")) + (should (equal (let ((csv-field-quotes '("\"" "'"))) + (csv--unquote-value "'Hello, \"World\"'")) + "Hello, \"World\"")) + (should (equal (csv--unquote-value "|Hello, World|") + "|Hello, World|"))) + +(provide 'csv-mode-tests) +;;; csv-mode-tests.el ends here diff --git a/emacs/elpa/csv-mode-1.25/csv-mode-tests.elc b/emacs/elpa/csv-mode-1.25/csv-mode-tests.elc Binary files differ. diff --git a/emacs/elpa/csv-mode-1.25/csv-mode.el b/emacs/elpa/csv-mode-1.25/csv-mode.el @@ -0,0 +1,2000 @@ +;;; csv-mode.el --- Major mode for editing comma/char separated values -*- lexical-binding: t -*- + +;; Copyright (C) 2003-2024 Free Software Foundation, Inc + +;; Author: "Francis J. Wright" <F.J.Wright@qmul.ac.uk> +;; Maintainer: emacs-devel@gnu.org +;; Version: 1.25 +;; Package-Requires: ((emacs "27.1") (cl-lib "0.5")) +;; Keywords: convenience + +;; This package 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, or (at your option) +;; any later version. + +;; This package 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 GNU Emacs. If not, see <https://www.gnu.org/licenses/>. + +;;; Commentary: + +;; This package implements CSV mode, a major mode for editing records +;; in a generalized CSV (character-separated values) format. It binds +;; files with prefix ".csv" to `csv-mode' (and ".tsv" to `tsv-mode') in +;; `auto-mode-alist'. + +;; In CSV mode, the following commands are available: + +;; - C-c C-s (`csv-sort-fields') and C-c C-n (`csv-sort-numeric-fields') +;; respectively sort lexicographically and numerically on a +;; specified field or column. + +;; - C-c C-r (`csv-reverse-region') reverses the order. (These +;; commands are based closely on, and use, code in `sort.el'.) + +;; - C-c C-k (`csv-kill-fields') and C-c C-y (`csv-yank-fields') kill +;; and yank fields or columns, although they do not use the normal +;; kill ring. C-c C-k can kill more than one field at once, but +;; multiple killed fields can be yanked only as a fixed group +;; equivalent to a single field. + +;; - `csv-align-mode' keeps fields visually aligned, on-the-fly. +;; It truncates fields to a maximum width that can be changed per-column +;; with `csv-align-set-column-width'. +;; Alternatively, C-c C-a (`csv-align-fields') aligns fields into columns +;; and C-c C-u (`csv-unalign-fields') undoes such alignment; +;; separators can be hidden within aligned records (controlled by +;; `csv-invisibility-default' and `csv-toggle-invisibility'). + +;; - C-c C-t (`csv-transpose') interchanges rows and columns. For +;; details, see the documentation for the individual commands. + +;; - `csv-set-separator' sets the CSV separator of the current buffer, +;; while `csv-guess-set-separator' guesses and sets the separator +;; based on the current buffer's contents. +;; `csv-guess-set-separator' can be useful to add to the mode hook +;; to have CSV mode guess and set the separator automatically when +;; visiting a buffer: +;; +;; (add-hook 'csv-mode-hook 'csv-guess-set-separator) + +;; CSV mode can recognize fields separated by any of several single +;; characters, specified by the value of the customizable user option +;; `csv-separators'. CSV data fields can be delimited by quote +;; characters (and must if they contain separator characters). This +;; implementation supports quoted fields, where the quote characters +;; allowed are specified by the value of the customizable user option +;; `csv-field-quotes'. By default, the both commas and tabs are considered +;; as separators and the only field quote is a double quote. +;; These user options can be changed ONLY by customizing them, e.g. via M-x +;; customize-variable. + +;; CSV mode commands ignore blank lines and comment lines beginning +;; with the value of the buffer local variable `csv-comment-start', +;; which by default is #. The user interface is similar to that of +;; the standard commands `sort-fields' and `sort-numeric-fields', but +;; see the major mode documentation below. + +;; The global minor mode `csv-field-index-mode' provides display of +;; the current field index in the mode line, cf. `line-number-mode' +;; and `column-number-mode'. It is on by default. + +;;;; See also: + +;; the standard GNU Emacs 21 packages align.el, which will align +;; columns within a region, and delim-col.el, which helps to prettify +;; columns in a text region or rectangle; + +;; csv.el by Ulf Jasper <ulf.jasper at web.de>, which provides +;; functions for reading/parsing comma-separated value files and is +;; available at http://de.geocities.com/ulf_jasper/emacs.html (and in +;; the gnu.emacs.sources archives). + +;;; Installation: + +;; Put this file somewhere that Emacs can find it (i.e. in one of the +;; directories in your `load-path' such as `site-lisp'), optionally +;; byte-compile it (recommended), and put this in your .emacs file: +;; +;; (add-to-list 'auto-mode-alist '("\\.[Cc][Ss][Vv]\\'" . csv-mode)) +;; (autoload 'csv-mode "csv-mode" +;; "Major mode for editing comma-separated value files." t) + +;;; News: + +;; Since 1.25: +;; - The ASCII control character 31 Unit Separator can now be +;; recognized as a CSV separator by `csv-guess-separator'. + +;; Since 1.24: +;; - New function `csv--unquote-value'. +;; - New function `csv-parse-current-row'. + +;; Since 1.21: +;; - New command `csv-insert-column'. +;; - New config var `csv-align-min-width' for `csv-align-mode'. +;; - New option `csv-confirm-region'. + +;; Since 1.20: +;; - New command `csv-guess-set-separator' that automatically guesses +;; and sets the CSV separator of the current buffer. +;; - New command `csv-set-separator' for setting the CSV separator +;; manually. + +;; Since 1.9: +;; - `csv-align-mode' auto-aligns columns dynamically (on screen). + +;; Before that: +;; Begun on 15 November 2003 to provide lexicographic sorting of +;; simple CSV data by field and released as csv.el. Facilities to +;; kill multiple fields and customize separator added on 9 April 2004. +;; Converted to a major mode and renamed csv-mode.el on 10 April 2004, +;; partly at the suggestion of Stefan Monnier <monnier at +;; IRO.UMontreal.CA> to avoid conflict with csv.el by Ulf Jasper. +;; Field alignment, comment support and CSV mode customization group +;; added on 1 May 2004. Support for index ranges added on 6 June +;; 2004. Multiple field separators added on 12 June 2004. +;; Transposition added on 22 June 2004. Separator invisibility added +;; on 23 June 2004. + +;;; To do (maybe): + +;; Make separators and quotes buffer-local and locally settable. +;; Support (La)TeX tables: set separator and comment; support record +;; end string. +;; Convert comma-separated to space- or tab-separated. + +;;; Code: + +(eval-when-compile + (require 'cl-lib) + (require 'subr-x)) + +(defgroup CSV nil + "Major mode for editing files of comma-separated value type." + :group 'convenience) + +(defvar csv-separator-chars nil + "Field separators as a list of character. +Set by customizing `csv-separators' -- do not set directly!") + +(defvar csv-separator-regexp nil + "Regexp to match a field separator. +Set by customizing `csv-separators' -- do not set directly!") + +(defvar csv--skip-chars nil + "Char set used by `skip-chars-forward' etc. to skip fields. +Set by customizing `csv-separators' -- do not set directly!") + +(defvar csv-font-lock-keywords nil + "Font lock keywords to highlight the field separators in CSV mode. +Set by customizing `csv-separators' -- do not set directly!") + +(defcustom csv-separators '("," "\t") + "Field separators: a list of *single-character* strings. +For example: (\",\"), the default, or (\",\" \";\" \":\"). +Neighbouring fields may be separated by any one of these characters. +The first is used when inserting a field separator into the buffer. +All must be different from the field quote characters, `csv-field-quotes'. + +Changing this variable with `setq' won't affect the current Emacs +session. Use `customize-set-variable' instead if that is required." + ;; Suggested by Eckhard Neber <neber@mwt.e-technik.uni-ulm.de> + :type '(repeat string) + ;; FIXME: Character would be better, but in Emacs 21.3 does not display + ;; correctly in a customization buffer. + :set (lambda (variable value) + (mapc (lambda (x) + (if (/= (length x) 1) + (error "Non-single-char string %S" x)) + (if (and (boundp 'csv-field-quotes) + (member x csv-field-quotes)) + (error "%S is already a quote" x))) + value) + (custom-set-default variable value) + (setq csv-separator-chars (mapcar #'string-to-char value)) + (setq csv--skip-chars + (apply #'concat "^\n" + (mapcar (lambda (s) (concat "\\" s)) value))) + (setq csv-separator-regexp (regexp-opt value)) + (setq csv-font-lock-keywords + ;; NB: csv-separator-face variable evaluates to itself. + `((,csv-separator-regexp (0 'csv-separator-face)))))) + +(defcustom csv-field-quotes '("\"") + "Field quotes: a list of *single-character* strings. +For example: (\"\\\"\"), the default, or (\"\\\"\" \"\\='\" \"\\=`\"). +A field can be delimited by a pair of any of these characters. +All must be different from the field separators, `csv-separators'." + :type '(repeat string) + ;; Character would be better, but in Emacs 21 does not display + ;; correctly in a customization buffer. + :set (lambda (variable value) + (mapc (lambda (x) + (if (/= (length x) 1) + (error "Non-single-char string %S" x)) + (if (member x csv-separators) + (error "%S is already a separator" x))) + value) + (when (boundp 'csv-mode-syntax-table) + ;; FIRST remove old quote syntax: + (with-syntax-table text-mode-syntax-table + (mapc (lambda (x) + (modify-syntax-entry + (string-to-char x) + (string (char-syntax (string-to-char x))) + ;; symbol-value to avoid compiler warning: + (symbol-value 'csv-mode-syntax-table))) + csv-field-quotes)) + ;; THEN set new quote syntax: + (csv-set-quote-syntax value)) + ;; BEFORE setting new value of `csv-field-quotes': + (custom-set-default variable value))) + +(defun csv-set-quote-syntax (field-quotes) + "Set syntax for field quote characters FIELD-QUOTES to be \"string\". +FIELD-QUOTES should be a list of single-character strings." + (mapc (lambda (x) + (modify-syntax-entry + (string-to-char x) "\"" + ;; symbol-value to avoid compiler warning: + (symbol-value 'csv-mode-syntax-table))) + field-quotes)) + +(defvar csv-comment-start nil + "String that starts a comment line, or nil if no comment syntax. +Such comment lines are ignored by CSV mode commands. +This variable is buffer local; its default value is that of +`csv-comment-start-default'. It is set by the function +`csv-set-comment-start' -- do not set it directly!") + +(make-variable-buffer-local 'csv-comment-start) + +(defcustom csv-comment-start-default "#" + "String that starts a comment line, or nil if no comment syntax. +Such comment lines are ignored by CSV mode commands. +Default value of buffer-local variable `csv-comment-start'. +Changing this variable does not affect any existing CSV mode buffer." + :type '(choice (const :tag "None" nil) string) + :set (lambda (variable value) + (custom-set-default variable value) + (setq-default csv-comment-start value))) + +(defcustom csv-align-style 'left + "Aligned field style: one of `left', `centre', `right' or `auto'. +Alignment style used by `csv-align-mode' and `csv-align-fields'. +Auto-alignment means left align text and right align numbers." + :type '(choice (const left) (const centre) + (const right) (const auto))) + +(defcustom csv-align-padding 1 + "Aligned field spacing: must be a positive integer. +Number of spaces used by `csv-align-mode' and `csv-align-fields' +after separators." + :type 'integer) + +(defcustom csv-header-lines 0 + "Header lines to skip when setting region automatically." + :type 'integer) + +(defcustom csv-invisibility-default t + "If non-nil, make separators in aligned records invisible." + :type 'boolean) + +(defcustom csv-confirm-region t + "If non-nil, confirm that region is OK in interactive commands." + :type 'boolean) + +(defface csv-separator-face + '((t :inherit escape-glyph)) + "CSV mode face used to highlight separators.") + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Mode definition, key bindings and menu +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + +(defconst csv-mode-line-format + '(csv-field-index-string ("" csv-field-index-string)) + "Mode line format string for CSV mode.") + +(defvar csv-mode-map + (let ((map (make-sparse-keymap))) + (define-key map [(control ?c) (control ?v)] #'csv-toggle-invisibility) + (define-key map [(control ?c) (control ?t)] #'csv-transpose) + (define-key map [(control ?c) (control ?c)] #'csv-set-comment-start) + (define-key map [(control ?c) (control ?u)] #'csv-unalign-fields) + (define-key map [(control ?c) (control ?a)] #'csv-align-fields) + (define-key map [(control ?c) (control ?z)] #'csv-yank-as-new-table) + (define-key map [(control ?c) (control ?y)] #'csv-yank-fields) + (define-key map [(control ?c) (control ?k)] #'csv-kill-fields) + (define-key map [(control ?c) (control ?d)] #'csv-toggle-descending) + (define-key map [(control ?c) (control ?r)] #'csv-reverse-region) + (define-key map [(control ?c) (control ?n)] #'csv-sort-numeric-fields) + (define-key map [(control ?c) (control ?s)] #'csv-sort-fields) + (define-key map "\t" #'csv-tab-command) + (define-key map [backtab] #'csv-backtab-command) + map)) + +;;;###autoload +(define-derived-mode csv-mode text-mode "CSV" + "Major mode for editing files of comma-separated value type. + +CSV mode is derived from `text-mode', and runs `text-mode-hook' before +running `csv-mode-hook'. It turns `auto-fill-mode' off by default. +CSV mode can be customized by user options in the CSV customization +group. The separators are specified by the value of `csv-separators'. + +CSV mode commands ignore blank lines and comment lines beginning with +the value of `csv-comment-start', which delimit \"paragraphs\". +\"Sexp\" is re-interpreted to mean \"field\", so that `forward-sexp' +\(\\[forward-sexp]), `kill-sexp' (\\[kill-sexp]), etc. all apply to fields. +Standard comment commands apply, such as `comment-dwim' (\\[comment-dwim]). + +If `font-lock-mode' is enabled then separators, quoted values and +comment lines are highlighted using respectively `csv-separator-face', +`font-lock-string-face' and `font-lock-comment-face'. + +The user interface (UI) for CSV mode commands is similar to that of +the standard commands `sort-fields' and `sort-numeric-fields', except +that if there is no prefix argument then the UI prompts for the field +index or indices. In `transient-mark-mode' only: if the region is not +set then the UI attempts to set it to include all consecutive CSV +records around point, and prompts for confirmation; if there is no +prefix argument then the UI prompts for it, offering as a default the +index of the field containing point if the region was not set +explicitly. The region set automatically is delimited by blank lines +and comment lines, and the number of header lines at the beginning of +the region given by the value of `csv-header-lines' are skipped. + +Sort order is controlled by `csv-descending'. + +CSV mode provides the following specific keyboard key bindings: + +\\{csv-mode-map}" + :group 'CSV + ;; We used to `turn-off-auto-fill' here instead, but that's not very + ;; effective since text-mode-hook is run afterwards anyway! + (setq-local normal-auto-fill-function nil) + ;; Set syntax for field quotes: + (csv-set-quote-syntax csv-field-quotes) + ;; Make sexp functions apply to fields: + (set (make-local-variable 'forward-sexp-function) #'csv-forward-field) + (csv-set-comment-start csv-comment-start) + ;; Font locking -- separator plus syntactic: + (setq font-lock-defaults '(csv-font-lock-keywords)) + (setq-local jit-lock-contextually nil) ;Each line should be independent. + (if csv-invisibility-default (add-to-invisibility-spec 'csv)) + ;; Mode line to support `csv-field-index-mode': + (set (make-local-variable 'mode-line-position) + (pcase mode-line-position + (`(,(or (pred consp) (pred stringp)) . ,_) + `(,@mode-line-position ,csv-mode-line-format)) + (_ `("" ,mode-line-position ,csv-mode-line-format)))) + (set (make-local-variable 'truncate-lines) t) + ;; Enable or disable `csv-field-index-mode' (could probably do this + ;; a bit more efficiently): + (csv-field-index-mode (symbol-value 'csv-field-index-mode))) + +(defun csv-set-comment-start (string) + "Set comment start for this CSV mode buffer to STRING. +It must be either a string or nil." + (interactive + (list (edit-and-eval-command + "Comment start (string or nil): " csv-comment-start))) + ;; Paragraph means a group of contiguous records: + (set (make-local-variable 'paragraph-separate) "[[:space:]]*$") ; White space. + (set (make-local-variable 'paragraph-start) "\n");Must include \n explicitly! + ;; Remove old comment-start/end if available + (with-syntax-table text-mode-syntax-table + (when comment-start + (modify-syntax-entry (string-to-char comment-start) + (string (char-syntax (string-to-char comment-start))) + csv-mode-syntax-table)) + (modify-syntax-entry ?\n + (string (char-syntax ?\n)) + csv-mode-syntax-table)) + (when string + (setq paragraph-separate (concat paragraph-separate "\\|" string) + paragraph-start (concat paragraph-start "\\|" string)) + (set (make-local-variable 'comment-start) string) + (modify-syntax-entry + (string-to-char string) "<" csv-mode-syntax-table) + (modify-syntax-entry ?\n ">" csv-mode-syntax-table)) + (setq csv-comment-start string)) + +(defvar csv--set-separator-history nil) + +(defun csv-set-separator (sep) + "Set the CSV separator in the current buffer to SEP." + (interactive (list (read-char-from-minibuffer + "Separator: " nil 'csv--set-separator-history))) + (when (and (boundp 'csv-field-quotes) + (member (string sep) csv-field-quotes)) + (error "%c is already a quote" sep)) + (setq-local csv-separators (list (string sep))) + (setq-local csv-separator-chars (list sep)) + (setq-local csv--skip-chars (format "^\n\\%c" sep)) + (setq-local csv-separator-regexp (regexp-quote (string sep))) + (setq-local csv-font-lock-keywords + `((,csv-separator-regexp (0 'csv-separator-face)))) + (font-lock-refresh-defaults)) + +;;;###autoload +(add-to-list 'auto-mode-alist '("\\.[Cc][Ss][Vv]\\'" . csv-mode)) + +(defvar csv-descending nil + "If non-nil, CSV mode sort functions sort in order of descending sort key. +Usually they sort in order of ascending sort key.") + +(defun csv-toggle-descending () + "Toggle `csv-descending'." + (interactive) + (setq csv-descending (not csv-descending)) + (message "Sort order is %sscending" (if csv-descending "de" "a"))) + +(defun csv-toggle-invisibility () + ;; FIXME: Make it into a proper minor mode? + "Toggle `buffer-invisibility-spec'." + (interactive) + (if (memq 'csv buffer-invisibility-spec) + (remove-from-invisibility-spec 'csv) + (add-to-invisibility-spec 'csv)) + (message "Separators in aligned records will be %svisible \ +\(after re-aligning if soft)" + (if (memq 'csv buffer-invisibility-spec) "in" "")) + (redraw-frame (selected-frame))) + +(easy-menu-define + csv-menu + csv-mode-map + "CSV major mode menu keymap" + '("CSV" + ["Sort By Field Lexicographically" csv-sort-fields :active t + :help "Sort lines in region lexicographically by the specified field"] + ["Sort By Field Numerically" csv-sort-numeric-fields :active t + :help "Sort lines in region numerically by the specified field"] + ["Reverse Order of Lines" csv-reverse-region :active t + :help "Reverse the order of the lines in the region"] + ["Use Descending Sort Order" csv-toggle-descending :active t + :style toggle :selected csv-descending + :help "If selected, use descending order when sorting"] + "--" + ["Kill Fields (Columns)" csv-kill-fields :active t + :help "Kill specified fields of each line in the region"] + ["Yank Fields (Columns)" csv-yank-fields :active t + :help "Yank killed fields as specified field of each line in region"] + ["Yank As New Table" csv-yank-as-new-table :active t + :help "Yank killed fields as a new table at point"] + ["Align Fields into Columns" csv-align-fields :active t + :help "Align the start of every field of each line in the region"] + ["Unalign Columns into Fields" csv-unalign-fields :active t + :help "Undo soft alignment and optionally remove redundant white space"] + ["Transpose Rows and Columns" csv-transpose :active t + :help "Rewrite rows (which may have different lengths) as columns"] + "--" + ["Forward Field" forward-sexp :active t + :help "Move forward across one field; with ARG, do it that many times"] + ["Backward Field" backward-sexp :active t + :help "Move backward across one field; with ARG, do it that many times"] + ["Kill Field Forward" kill-sexp :active t + :help "Kill field following cursor; with ARG, do it that many times"] + ["Kill Field Backward" backward-kill-sexp :active t + :help "Kill field preceding cursor; with ARG, do it that many times"] + "--" + ("Alignment Style" + ["Left" (setq csv-align-style 'left) :active t + :style radio :selected (eq csv-align-style 'left) + :help "If selected, `csv-align' left aligns fields"] + ["Centre" (setq csv-align-style 'centre) :active t + :style radio :selected (eq csv-align-style 'centre) + :help "If selected, `csv-align' centres fields"] + ["Right" (setq csv-align-style 'right) :active t + :style radio :selected (eq csv-align-style 'right) + :help "If selected, `csv-align' right aligns fields"] + ["Auto" (setq csv-align-style 'auto) :active t + :style radio :selected (eq csv-align-style 'auto) + :help "\ +If selected, `csv-align' left aligns text and right aligns numbers"] + ) + ["Set header line" csv-header-line :active t] + ["Auto-(re)align fields" csv-align-mode + :style toggle :selected csv-align-mode] + ["Show Current Field Index" csv-field-index-mode :active t + :style toggle :selected csv-field-index-mode + :help "If selected, display current field index in mode line"] + ["Make Separators Invisible" csv-toggle-invisibility :active t + :style toggle :selected (memq 'csv buffer-invisibility-spec) + :visible (not (tsv--mode-p)) + :help "If selected, separators in aligned records are invisible"] + ["Set Buffer's Comment Start" csv-set-comment-start :active t + :help "Set comment start string for this buffer"] + ["Customize CSV Mode" (customize-group 'CSV) :active t + :help "Open a customization buffer to change CSV mode options"] + )) + +(require 'sort) + +(defsubst csv-not-looking-at-record () + "Return t if looking at blank or comment line, nil otherwise. +Assumes point is at beginning of line." + (looking-at paragraph-separate)) + +(defun csv-interactive-args (&optional type) + "Get arg or field(s) and region interactively, offering sensible defaults. +Signal an error if the buffer is read-only. +If TYPE is noarg then return a list (beg end). +Otherwise, return a list (arg beg end), where arg is: + the raw prefix argument by default; + a single field index if TYPE is single; + a list of field indices or index ranges if TYPE is multiple. +Field defaults to the current prefix arg; if not set, prompt user. + +A field index list consists of positive or negative integers or ranges, +separated by any non-integer characters. A range has the form m-n, +where m and n are positive or negative integers, m < n, and n defaults +to the last field index if omitted. + +In transient mark mode, if the mark is not active then automatically +select and highlight CSV records around point, and query user. +The default field when read interactively is the current field." + ;; Must be run interactively to activate mark! + (let* ((arg current-prefix-arg) (default-field 1) + (region + (if (not (use-region-p)) + ;; Set region automatically: + (save-excursion + (if arg + (beginning-of-line) + (let ((lbp (line-beginning-position))) + (while (re-search-backward csv-separator-regexp lbp 1) + ;; Move as far as possible, i.e. to beginning of line. + (setq default-field (1+ default-field))))) + (if (csv-not-looking-at-record) + (error "Point must be within CSV records")) + (let ((startline (point))) + ;; Set mark at beginning of region: + (while (not (or (bobp) (csv-not-looking-at-record))) + (forward-line -1)) + (if (csv-not-looking-at-record) (forward-line 1)) + ;; Skip header lines: + (forward-line csv-header-lines) + (set-mark (point)) ; OK since in save-excursion + ;; Move point to end of region: + (goto-char startline) + (beginning-of-line) + (while (not (or (eobp) (csv-not-looking-at-record))) + (forward-line 1)) + ;; Show mark briefly if necessary: + (unless (and (pos-visible-in-window-p) + (pos-visible-in-window-p (mark))) + (exchange-point-and-mark) + (sit-for 1) + (exchange-point-and-mark)) + (when csv-confirm-region + (or (y-or-n-p "Region OK? ") + (error "Action aborted by user")) + (message nil)) ; clear y-or-n-p message + (list (region-beginning) (region-end)))) + ;; Use region set by user: + (list (region-beginning) (region-end))))) + (setq default-field (number-to-string default-field)) + (cond + ((eq type 'multiple) + (if arg + ;; Ensure that field is a list: + (or (consp arg) + (setq arg (list (prefix-numeric-value arg)))) + ;; Read field interactively, ignoring non-integers: + (setq arg + (mapcar + (lambda (x) + (if (string-match "-" x 1) ; not first character + ;; Return a range as a pair - the cdr may be nil: + (let ((m (substring x 0 (match-beginning 0))) + (n (substring x (match-end 0)))) + (cons (car (read-from-string m)) + (and (not (string= n "")) + (car (read-from-string n))))) + ;; Return a number as a number: + (car (read-from-string x)))) + (split-string + (read-string + "Fields (sequence of integers or ranges): " default-field) + "[^-+0-9]+"))))) + ((eq type 'single) + (if arg + (setq arg (prefix-numeric-value arg)) + (while (not (integerp arg)) + (setq arg (eval-minibuffer "Field (integer): " default-field)))))) + (if (eq type 'noarg) region (cons arg region)))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Sorting by field +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defun csv-nextrecfun () + "Called by `csv-sort-fields-1' with point at end of previous record. +It moves point to the start of the next record. +It should move point to the end of the buffer if there are no more records." + (forward-line) + (while (and (not (eobp)) (csv-not-looking-at-record)) + (forward-line))) + +(defun csv-sort-fields-1 (field beg end startkeyfun endkeyfun) + "Modified version of `sort-fields-1' that skips blank or comment lines. + +FIELD is a single field index, and BEG and END specify the region to +sort. + +STARTKEYFUN moves from the start of the record to the start of the key. +It may return either a non-nil value to be used as the key, or +else the key is the substring between the values of point after +STARTKEYFUN and ENDKEYFUN are called. If STARTKEYFUN is nil, the key +starts at the beginning of the record. + +ENDKEYFUN moves from the start of the sort key to the end of the sort key. +ENDKEYFUN may be nil if STARTKEYFUN returns a value or if it would be the +same as ENDRECFUN." + (let ((tbl (syntax-table))) + (if (zerop field) (setq field 1)) + (unwind-protect + (save-excursion + (save-restriction + (narrow-to-region beg end) + (goto-char (point-min)) + (set-syntax-table sort-fields-syntax-table) + (sort-subr csv-descending + 'csv-nextrecfun 'end-of-line + startkeyfun endkeyfun))) + (set-syntax-table tbl)))) + +(defun csv-sort-fields (field beg end) + "Sort lines in region lexicographically by the ARGth field of each line. +If not set, the region defaults to the CSV records around point. +Fields are separated by `csv-separators' and null fields are allowed anywhere. +Field indices increase from 1 on the left or decrease from -1 on the right. +A prefix argument specifies a single field, otherwise prompt for field index. +Ignore blank and comment lines. The variable `sort-fold-case' +determines whether alphabetic case affects the sort order. +When called non-interactively, FIELD is a single field index; +BEG and END specify the region to sort." + ;; (interactive "*P\nr") + (interactive (csv-interactive-args 'single)) + (barf-if-buffer-read-only) + (csv-sort-fields-1 field beg end + (lambda () (csv-sort-skip-fields field) nil) + (lambda () (skip-chars-forward csv--skip-chars)))) + +(defun csv-sort-numeric-fields (field beg end) + "Sort lines in region numerically by the ARGth field of each line. +If not set, the region defaults to the CSV records around point. +Fields are separated by `csv-separators'. +Null fields are allowed anywhere and sort as zeros. +Field indices increase from 1 on the left or decrease from -1 on the right. +A prefix argument specifies a single field, otherwise prompt for field index. +Specified non-null field must contain a number in each line of the region, +which may begin with \"0x\" or \"0\" for hexadecimal and octal values. +Otherwise, the number is interpreted according to sort-numeric-base. +Ignore blank and comment lines. +When called non-interactively, FIELD is a single field index; +BEG and END specify the region to sort." + ;; (interactive "*P\nr") + (interactive (csv-interactive-args 'single)) + (barf-if-buffer-read-only) + (csv-sort-fields-1 field beg end + (lambda () + (csv-sort-skip-fields field) + (let* ((case-fold-search t) + (base + (if (looking-at "\\(0x\\)[0-9a-f]\\|\\(0\\)[0-7]") + (cond ((match-beginning 1) + (goto-char (match-end 1)) + 16) + ((match-beginning 2) + (goto-char (match-end 2)) + 8) + (t nil))))) + (string-to-number (buffer-substring (point) + (save-excursion + (forward-sexp 1) + (point))) + (or base sort-numeric-base)))) + nil)) + +(defun csv-reverse-region (beg end) + "Reverse the order of the lines in the region. +This is just a CSV-mode style interface to `reverse-region', which is +the function that should be used non-interactively. It takes two +point or marker arguments, BEG and END, delimiting the region." + ;; (interactive "*P\nr") + (interactive (csv-interactive-args 'noarg)) + (barf-if-buffer-read-only) + (reverse-region beg end)) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Moving by field +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defun csv-end-of-field () + "Skip forward over one field." + (skip-chars-forward " ") + ;; If the first character is a double quote, then we have a quoted + ;; value. + (when (eq (char-syntax (following-char)) ?\") + (forward-char) + (let ((ended nil)) + (while (not ended) + (cond ((not (eq (char-syntax (following-char)) ?\")) + (forward-char 1)) + ;; According to RFC-4180 (sec 2.7), quotes inside quoted strings + ;; are quoted by doubling the quote char: a,"b""c,",d + ;; FIXME: Maybe we should handle this via syntax-propertize? + ((let ((c (char-after (1+ (point))))) + (and c (eq (char-syntax c) ?\"))) + (forward-char 2)) + (t + (setq ended t)))))) + (skip-chars-forward csv--skip-chars)) + +(defun csv--bof-p () + (or (bolp) + (memq (preceding-char) csv-separator-chars))) + +(defun csv--eof-p () + (or (eolp) + (memq (following-char) csv-separator-chars))) + +(defun csv-beginning-of-field () + "Skip backward over one field." + (skip-syntax-backward " ") + (if (eq (char-syntax (preceding-char)) ?\") + (goto-char (scan-sexps (point) -1))) + (skip-chars-backward csv--skip-chars)) + +(defun csv-forward-field (arg) + "Move forward across one field, cf. `forward-sexp'. +With ARG, do it that many times. Negative arg -N means +move backward across N fields." + (interactive "p") + (if (< arg 0) + (csv-backward-field (- arg)) + (while (>= (setq arg (1- arg)) 0) + (if (or (bolp) + (when (and (not (eobp)) (eolp)) (forward-char) t)) + (while (and (not (eobp)) (csv-not-looking-at-record)) + (forward-line 1))) + (if (memq (following-char) csv-separator-chars) (forward-char)) + (csv-end-of-field)))) + +(defun csv-backward-field (arg) + "Move backward across one field, cf. `backward-sexp'. +With ARG, do it that many times. Negative arg -N means +move forward across N fields." + (interactive "p") + (if (< arg 0) + (csv-forward-field (- arg)) + (while (>= (setq arg (1- arg)) 0) + (when (or (eolp) + (when (and (not (bobp)) (bolp)) (backward-char) t)) + (while (progn + (beginning-of-line) + (csv-not-looking-at-record)) + (backward-char)) + (end-of-line)) + (if (memq (preceding-char) csv-separator-chars) (backward-char)) + (csv-beginning-of-field)))) + +(defun csv-tab-command () + "Skip to the next field on the same line. +Create a new field at end of line, if needed." + (interactive) + (skip-chars-forward csv--skip-chars) + (if (eolp) + (insert (car csv-separators)) + (forward-char 1))) + +(defun csv-backtab-command () + "Skip to the beginning of the previous field." + (interactive) + (skip-chars-backward csv--skip-chars) + (forward-char -1) + (skip-chars-backward csv--skip-chars)) + +(defun csv-sort-skip-fields (n &optional yank) + "Position point at the beginning of field N on the current line. +Fields are separated by `csv-separators'; null terminal field allowed. +Assumes point is initially at the beginning of the line. +YANK non-nil allows N to be greater than the number of fields, in +which case extend the record as necessary." + (if (> n 0) + ;; Skip across N - 1 fields. + (let ((i (1- n))) + (while (> i 0) + (csv-end-of-field) + (if (eolp) + (if yank + (if (> i 1) (insert (car csv-separators))) + (error "Line has too few fields: %s" + (buffer-substring + (save-excursion (beginning-of-line) (point)) + (save-excursion (end-of-line) (point))))) + (forward-char)) ; skip separator + (setq i (1- i)))) + (end-of-line) + ;; Skip back across -N - 1 fields. + (let ((i (1- (- n)))) + (while (> i 0) + (csv-beginning-of-field) + (if (bolp) + (error "Line has too few fields: %s" + (buffer-substring + (save-excursion (beginning-of-line) (point)) + (save-excursion (end-of-line) (point))))) + (backward-char) ; skip separator + (setq i (1- i))) + ;; Position at the front of the field + ;; even if moving backwards. + (csv-beginning-of-field)))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Field index mode +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; Based partly on paren.el + +(defcustom csv-field-index-delay 0.125 + "Time in seconds to delay before updating field index display." + :type '(number :tag "seconds")) + +(defvar csv-field-index-idle-timer nil) + +(defvar csv-field-index-string nil) +(make-variable-buffer-local 'csv-field-index-string) + +(defvar csv-field-index-old nil) +(make-variable-buffer-local 'csv-field-index-old) + +(define-minor-mode csv-field-index-mode + "Toggle CSV-Field-Index mode. +With prefix ARG, turn CSV-Field-Index mode on if and only if ARG is positive. +Returns the new status of CSV-Field-Index mode (non-nil means on). +When CSV-Field-Index mode is enabled, the current field index appears in +the mode line after `csv-field-index-delay' seconds of Emacs idle time." + :global t + :init-value t ; for documentation, since default is t + ;; This macro generates a function that first sets the mode + ;; variable, then runs the following code, runs the mode hooks, + ;; displays a message if interactive, updates the mode line and + ;; finally returns the variable value. + + ;; First, always disable the mechanism (to avoid having two timers): + (when csv-field-index-idle-timer + (cancel-timer csv-field-index-idle-timer) + (setq csv-field-index-idle-timer nil)) + ;; Now, if the mode is on and any buffer is in CSV mode then + ;; re-initialize and enable the mechanism by setting up a new timer: + (if csv-field-index-mode + (if (memq t (mapcar (lambda (buffer) + (with-current-buffer buffer + (when (derived-mode-p 'csv-mode) + (setq csv-field-index-string nil + csv-field-index-old nil) + t))) + (buffer-list))) + (setq csv-field-index-idle-timer + (run-with-idle-timer csv-field-index-delay t + #'csv-field-index))) + ;; but if the mode is off then remove the display from the mode + ;; lines of all CSV buffers: + (mapc (lambda (buffer) + (with-current-buffer buffer + (when (derived-mode-p 'csv-mode) + (setq csv-field-index-string nil + csv-field-index-old nil) + (force-mode-line-update)))) + (buffer-list)))) + +(defun csv--field-index () + (save-excursion + (let ((start (point)) + (field 0)) + (beginning-of-line) + (while (and (<= (point) start) + (not (eolp))) + (csv-end-of-field) + (unless (eolp) + (forward-char 1)) + (setq field (1+ field))) + field))) + +(defun csv-field-index () + "Construct `csv-field-index-string' to display in mode line. +Called by `csv-field-index-idle-timer'." + (if (derived-mode-p 'csv-mode) + (let ((field (csv--field-index))) + (when (not (eq field csv-field-index-old)) + (setq csv-field-index-old field + csv-field-index-string + (and field (format "F%d" field))) + (force-mode-line-update))))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Killing and yanking fields +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defvar csv-killed-fields nil + "A list of the fields or sub-records last killed by `csv-kill-fields'.") + +(defun csv-kill-fields (fields beg end) + "Kill specified fields of each line in the region. +If not set, the region defaults to the CSV records around point. +Fields are separated by `csv-separators' and null fields are allowed anywhere. +Field indices increase from 1 on the left or decrease from -1 on the right. +The fields are stored for use by `csv-yank-fields'. Fields can be +specified in any order but are saved in increasing index order. +Ignore blank and comment lines. + +When called interactively, a prefix argument specifies a single field, +otherwise prompt for a field list, which may include ranges in the form +m-n, where m < n and n defaults to the last field index if omitted. + +When called non-interactively, FIELDS is a single field index or a +list of field indices, with ranges specified as (m.n) or (m), and BEG +and END specify the region to process." + ;; (interactive "*P\nr") + (interactive (csv-interactive-args 'multiple)) + (barf-if-buffer-read-only) + ;; Kill the field(s): + (setq csv-killed-fields nil) + (save-excursion + (save-restriction + (narrow-to-region beg end) + (goto-char (point-min)) + (if (or (cdr fields) (consp (car fields))) + (csv-kill-many-columns fields) + (csv-kill-one-column (car fields))))) + (setq csv-killed-fields (nreverse csv-killed-fields))) + +(defun csv-kill-one-field (field) + "Kill field with index FIELD in current line. +Return killed text. Assumes point is at beginning of line." + ;; Move to start of field to kill: + (csv-sort-skip-fields field) + ;; Kill to end of field (cf. `kill-region'): + (prog1 (delete-and-extract-region + (point) + (progn (csv-end-of-field) (point))) + (if (eolp) + (unless (bolp) (delete-char -1)) ; Delete trailing separator at eol + (delete-char 1)))) ; or following separator otherwise. + +(defun csv-kill-one-column (field) + "Kill field with index FIELD in all lines in (narrowed) buffer. +Save killed fields in `csv-killed-fields'. +Assumes point is at `point-min'. Called by `csv-kill-fields'. +Ignore blank and comment lines." + (while (not (eobp)) + (or (csv-not-looking-at-record) + (push (csv-kill-one-field field) csv-killed-fields)) + (forward-line))) + +(defun csv-insert-column (field) + "Insert an empty column at point." + (interactive + (let ((cur (csv--field-index))) + (list (if (and (csv--eof-p) (not (csv--bof-p))) (1+ cur) cur)))) + (save-excursion + (goto-char (point-min)) + (while (not (eobp)) + (or (csv-not-looking-at-record) + (progn + (csv-sort-skip-fields field t) + (insert (car csv-separators)))) + (forward-line 1)) + (csv--jit-flush-columns))) + +(defun csv-kill-many-columns (fields) + "Kill several fields in all lines in (narrowed) buffer. +FIELDS is an unordered list of field indices. +Save killed fields in increasing index order in `csv-killed-fields'. +Assumes point is at `point-min'. Called by `csv-kill-fields'. +Ignore blank and comment lines." + (if (eolp) (error "First record is empty")) + ;; Convert non-positive to positive field numbers: + (let ((last 1) (f fields)) + (csv-end-of-field) + (while (not (eolp)) + (forward-char) ; skip separator + (csv-end-of-field) + (setq last (1+ last))) ; last = # fields in first record + (while f + (cond ((consp (car f)) + ;; Expand a field range: (m.n) -> m m+1 ... n-1 n. + ;; If n is nil then it defaults to the number of fields. + (let* ((range (car f)) (cdrf (cdr f)) + (m (car range)) (n (cdr range))) + (if (< m 0) (setq m (+ m last 1))) + (if n + (if (< n 0) (setq n (+ n last 1))) + (setq n last)) + (setq range (list n)) + (while (> n m) (push (setq n (1- n)) range)) + (setcar f (car range)) + (setcdr f (cdr range)) + (setcdr (setq f (last range)) cdrf))) + ((zerop (car f)) (setcar f 1)) + ((< (car f) 0) (setcar f (+ f last 1)))) + (setq f (cdr f)))) + (goto-char (point-min)) + ;; Kill from right to avoid miscounting: + (setq fields (sort fields #'>)) + (while (not (eobp)) + (or (csv-not-looking-at-record) + (let ((fields fields) killed-fields field) + (while fields + (setq field (car fields) + fields (cdr fields)) + (beginning-of-line) + (push (csv-kill-one-field field) killed-fields)) + (push (mapconcat #'identity killed-fields (car csv-separators)) + csv-killed-fields))) + (forward-line))) + +(defun csv-yank-fields (field beg end) + "Yank fields as the ARGth field of each line in the region. +ARG may be arbitrarily large and records are extended as necessary. +If not set, the region defaults to the CSV records around point; +if point is not in a CSV record then offer to yank as a new table. +The fields yanked are those last killed by `csv-kill-fields'. +Fields are separated by `csv-separators' and null fields are allowed anywhere. +Field indices increase from 1 on the left or decrease from -1 on the right. +A prefix argument specifies a single field, otherwise prompt for field index. +Ignore blank and comment lines. When called non-interactively, FIELD +is a single field index; BEG and END specify the region to process." + ;; (interactive "*P\nr") + (interactive (condition-case err + (csv-interactive-args 'single) + (error (list nil nil err)))) + (barf-if-buffer-read-only) + (if (null beg) + (if (y-or-n-p (concat (error-message-string end) + ". Yank as a new table? ")) + (csv-yank-as-new-table) + (error (error-message-string end))) + (if (<= field 0) (setq field (1+ field))) + (save-excursion + (save-restriction + (narrow-to-region beg end) + (goto-char (point-min)) + (let ((fields csv-killed-fields)) + (while (not (eobp)) + (unless (csv-not-looking-at-record) + ;; Yank at start of specified field if possible, + ;; otherwise yank at end of record: + (if (zerop field) + (end-of-line) + (csv-sort-skip-fields field 'yank)) + (and (eolp) (insert (car csv-separators))) + (when fields + (insert (car fields)) + (setq fields (cdr fields))) + (or (eolp) (insert (car csv-separators)))) + (forward-line))))))) + +(defun csv-yank-as-new-table () + "Yank fields as a new table starting at point. +The fields yanked are those last killed by `csv-kill-fields'." + (interactive "*") + (let ((fields csv-killed-fields)) + (while fields + (insert (car fields) ?\n) + (setq fields (cdr fields))))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Aligning fields +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defun csv--make-overlay (beg end &optional buffer front-advance rear-advance props) + (let ((o (make-overlay beg end buffer front-advance rear-advance))) + (overlay-put o 'csv t) + (while props + (overlay-put o (pop props) (pop props))) + o)) + +(defun csv--delete-overlay (o) + (and (overlay-get o 'csv) (delete-overlay o))) + +(defun csv--column-widths (beg end) + "Return a list of two lists (COLUMN-WIDTHS FIELD-WIDTHS). +COLUMN-WIDTHS is a list of elements (WIDTH START END) +indicating the widths of the columns after point (and the position of the +widest field that determined the overall width). +FIELD-WIDTHS contains the widths of each individual field after +point." + (let ((column-widths '()) + (field-widths '())) + (goto-char beg) + ;; Construct list of column widths: + (while (< (point) end) ; for each record... + (or (csv-not-looking-at-record) + (let ((w column-widths) + (col (current-column)) + (beg (point)) + field-width) + (while (not (eolp)) + (csv-end-of-field) + (setq field-width (- (current-column) col)) + (push field-width field-widths) + (if w + (if (> field-width (caar w)) + (setcar w (list field-width beg (point)))) + (setq w (list (list field-width beg (point))) + column-widths (nconc column-widths w))) + (or (eolp) (forward-char)) ; Skip separator. + (setq w (cdr w) col (current-column) beg (point))))) + (forward-line)) + (list column-widths (nreverse field-widths)))) + +(defun csv-align-fields (hard beg end) + "Align all the fields in the region to form columns. +The alignment style is specified by `csv-align-style'. The number of +spaces specified by `csv-align-padding' appears after each separator. +Use soft alignment done by displaying virtual white space after the +separators unless invoked with an argument, in which case insert real +space characters into the buffer after the separators. +Unalign first (see `csv-unalign-fields'). Ignore blank and comment lines. + +In hard-aligned records, separators become invisible whenever +`buffer-invisibility-spec' is non-nil. In soft-aligned records, make +separators invisible if and only if `buffer-invisibility-spec' is +non-nil when the records are aligned; this can be changed only by +re-aligning. \(Unaligning always makes separators visible.) + +When called non-interactively, use hard alignment if HARD is non-nil; +BEG and END specify the region to align. +If there is no selected region, default to the whole buffer." + (interactive (cons current-prefix-arg + (if (use-region-p) + (list (region-beginning) (region-end)) + (list (point-min) (point-max))))) + ;; FIXME: Use csv--jit-align when applicable! + (setq end (copy-marker end)) + (csv-unalign-fields hard beg end) ; If hard then barfs if buffer read only. + (save-excursion + (pcase-let ((`(,column-widths ,field-widths) (csv--column-widths beg end))) + (save-restriction + (narrow-to-region beg end) + (set-marker end nil) + + ;; Align fields: + (goto-char (point-min)) + (while (not (eobp)) ; for each record... + (unless (csv-not-looking-at-record) + (let ((w column-widths) + (column 0)) ;Desired position of left-side of this column. + (while (and w (not (eolp))) + (let* ((beg (point)) + (align-padding (if (bolp) 0 csv-align-padding)) + (left-padding 0) (right-padding 0) + (field-width (pop field-widths)) + (column-width (car (pop w))) + (x (- column-width field-width))) ; Required padding. + (csv-end-of-field) + (set-marker end (point)) ; End of current field. + ;; beg = beginning of current field + ;; end = (point) = end of current field + + ;; Compute required padding: + (cond + ((eq csv-align-style 'left) + ;; Left align -- pad on the right: + (setq left-padding align-padding + right-padding x)) + ((eq csv-align-style 'right) + ;; Right align -- pad on the left: + (setq left-padding (+ align-padding x))) + ((eq csv-align-style 'auto) + ;; Auto align -- left align text, right align numbers: + (if (string-match "\\`[-+.[:digit:]]+\\'" + (buffer-substring beg (point))) + ;; Right align -- pad on the left: + (setq left-padding (+ align-padding x)) + ;; Left align -- pad on the right: + (setq left-padding align-padding + right-padding x))) + ((eq csv-align-style 'centre) + ;; Centre -- pad on both left and right: + (let ((y (/ x 2))) ; truncated integer quotient + (setq left-padding (+ align-padding y) + right-padding (- x y))))) + + (cond + (hard ;; Hard alignment... + (when (> left-padding 0) ; Pad on the left. + ;; Insert spaces before field: + (if (= beg end) ; null field + (insert (make-string left-padding ?\ )) + (goto-char beg) ; beginning of current field + (insert (make-string left-padding ?\ )) + (goto-char end))) ; end of current field + (unless (eolp) + (if (> right-padding 0) ; pad on the right + ;; Insert spaces after field: + (insert (make-string right-padding ?\ ))) + ;; Make separator (potentially) invisible; + ;; in Emacs 21.3, neighbouring overlays + ;; conflict, so use the following only + ;; with hard alignment: + (csv--make-overlay (point) (1+ (point)) nil t nil + '(invisible csv evaporate t)) + (forward-char))) ; skip separator + + ;; Soft alignment... + ((or (memq 'csv buffer-invisibility-spec) + ;; For TSV, hidden or not doesn't make much difference, + ;; but the behavior is slightly better when we "hide" + ;; the TABs with a `display' property than if we add + ;; before/after-strings. + (tsv--mode-p)) + + ;; Hide separators... + ;; Merge right-padding from previous field + ;; with left-padding from this field: + (if (zerop column) + (when (> left-padding 0) + ;; Display spaces before first field + ;; by overlaying first character: + (csv--make-overlay + beg (1+ beg) nil nil nil + `(before-string ,(make-string left-padding ?\ )))) + ;; Display separator as spaces: + (with-silent-modifications + (put-text-property + (1- beg) beg + 'display `(space :align-to + ,(+ left-padding column))))) + (unless (eolp) (forward-char)) ; Skip separator. + (setq column (+ column column-width align-padding))) + + (t ;; Do not hide separators... + (let ((overlay (csv--make-overlay beg (point) nil nil t))) + (when (> left-padding 0) ; Pad on the left. + ;; Display spaces before field: + (overlay-put overlay 'before-string + (make-string left-padding ?\ ))) + (unless (eolp) + (if (> right-padding 0) ; Pad on the right. + ;; Display spaces after field: + (overlay-put + overlay + 'after-string (make-string right-padding ?\ ))) + (forward-char)))) ; Skip separator. + + ))))) + (forward-line))))) + (set-marker end nil)) + +(defun csv-unalign-fields (hard beg end) + "Undo soft alignment and optionally remove redundant white space. +Undo soft alignment introduced by `csv-align-fields'. If invoked with +an argument then also remove all spaces and tabs around separators. +Also make all invisible separators visible again. +Ignore blank and comment lines. When called non-interactively, remove +spaces and tabs if HARD non-nil; BEG and END specify region to unalign. +If there is no selected region, default to the whole buffer." + (interactive (cons current-prefix-arg + (if (use-region-p) + (list (region-beginning) (region-end)) + (list (point-min) (point-max))))) + ;; Remove any soft alignment: + (mapc #'csv--delete-overlay (overlays-in beg end)) + (with-silent-modifications + (remove-list-of-text-properties beg end '(display invisible))) + (when hard + (barf-if-buffer-read-only) + ;; Remove any white-space padding around separators: + (save-excursion + (save-restriction + (narrow-to-region beg end) + (goto-char (point-min)) + (while (not (eobp)) + (or (csv-not-looking-at-record) + (while (not (eolp)) + ;; Delete horizontal white space forward: + ;; (delete-horizontal-space) + ;; This relies on left-to-right argument evaluation; + ;; see info node (elisp) Function Forms. + (delete-region (point) + (+ (point) (skip-chars-forward " \t"))) + (csv-end-of-field) + ;; Delete horizontal white space backward: + ;; (delete-horizontal-space t) + (delete-region (point) + (+ (point) (skip-chars-backward " \t"))) + (or (eolp) (forward-char)))) + (forward-line)))))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Transposing rows and columns +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defun csv-transpose (beg end) + "Rewrite rows (which may have different lengths) as columns. +Null fields are introduced as necessary within records but are +stripped from the ends of records. Preserve soft alignment. +This function is its own inverse. Ignore blank and comment lines. +When called non-interactively, BEG and END specify region to process." + ;; (interactive "*P\nr") + (interactive (csv-interactive-args 'noarg)) + (barf-if-buffer-read-only) + (save-excursion + (save-restriction + (narrow-to-region beg end) + (goto-char (point-min)) + ;; Delete rows and collect them as a reversed list of lists of + ;; fields, skipping comment and blank lines: + (let ((sep (car csv-separators)) + (align (overlays-in beg end)) + rows columns) + ;; Remove soft alignment if necessary: + (when align + (mapc #'csv--delete-overlay align) + (setq align t)) + (while (not (eobp)) + (if (csv-not-looking-at-record) + ;; Skip blank and comment lines: + (forward-line) + (let ((lep (line-end-position))) + (push + (csv--collect-fields lep) + rows) + (delete-region (point) lep) + (or (eobp) (delete-char 1))))) + ;; Rows must have monotonic decreasing lengths to be + ;; transposable, so ensure this by padding with null fields. + ;; rows is currently a reversed list of field lists, which + ;; must therefore have monotonic increasing lengths. + (let ((oldlen (length (car rows))) newlen + (r (cdr rows))) + (while r + (setq newlen (length (car r))) + (if (< newlen oldlen) + (nconc (car r) (make-list (- oldlen newlen) nil)) + (setq oldlen newlen)) + (setq r (cdr r)))) + ;; Collect columns as a reversed list of lists of fields: + (while rows + (let (column (r rows) row) + (while r + (setq row (car r)) + ;; Provided it would not be a trailing null field, push + ;; field onto column: + (if (or column (string< "" (car row))) + (push (car row) column)) + ;; Pop field off row: + (setcar r (cdr row)) + ;; If row is now empty then remove it: + (or (car r) (setq rows (cdr rows))) + (setq r (cdr r))) + (push column columns))) + ;; Insert columns into buffer as rows: + (setq columns (nreverse columns)) + (while columns + (insert (mapconcat #'identity (car columns) sep) ?\n) + (setq columns (cdr columns))) + ;; Re-do soft alignment if necessary: + (if align (csv-align-fields nil (point-min) (point-max))))))) + +(defun csv--collect-fields (row-end-position) + "Collect the fields of a row. +Splits a row into fields, honoring quoted fields, and returns +the list of fields. ROW-END-POSITION is the end-of-line position. +point is assumed to be at the beginning of the line." + (let ((csv-field-quotes-regexp (apply #'concat `("[" ,@csv-field-quotes "]"))) + (row-text (buffer-substring-no-properties (point) row-end-position)) + fields field-start) + (if (not (string-match csv-field-quotes-regexp row-text)) + (split-string row-text csv-separator-regexp) + (save-excursion + (while (< (setq field-start (point)) row-end-position) + ;; csv-forward-field will skip a separator if point is on + ;; it, and we'll miss an empty field + (unless (memq (following-char) csv-separator-chars) + (csv-forward-field 1)) + (push + (buffer-substring-no-properties field-start (point)) + fields) + (if (memq (following-char) csv-separator-chars) + (forward-char))) + (nreverse fields))))) + +(defun csv--unquote-value (value) + "Remove quotes around VALUE. +If VALUE contains escaped quote characters, un-escape them. If +VALUE is not quoted, return it unchanged." + (save-match-data + (let ((quote-regexp (apply #'concat `("[" ,@csv-field-quotes "]")))) + (if-let (((string-match (concat "^\\(" quote-regexp "\\)\\(.*\\)\\(" quote-regexp "\\)$") value)) + (quote-char (match-string 1 value)) + ((equal quote-char (match-string 3 value))) + (unquoted (match-string 2 value))) + (replace-regexp-in-string (concat quote-char quote-char) quote-char unquoted) + value)))) + +(defun csv-parse-current-row () + "Parse the current CSV line. +Return the field values as a list." + (save-mark-and-excursion + (goto-char (line-beginning-position)) + (mapcar #'csv--unquote-value (csv--collect-fields (line-end-position))))) + +(defvar-local csv--header-line nil) +(defvar-local csv--header-hscroll nil) +(defvar-local csv--header-string nil) + +(defun csv-header-line (&optional use-current-line) + "Set/unset the header line. +If the optional prefix arg USE-CURRENT-LINE is nil, use the first line +as the header line. +If there is already a header line, then unset the header line." + (interactive "P") + (if csv--header-line + (progn + (delete-overlay csv--header-line) + (setq csv--header-line nil) + (kill-local-variable 'header-line-format)) + (save-excursion + (unless use-current-line (goto-char (point-min))) + (setq csv--header-line (make-overlay (line-beginning-position) + (line-end-position) + nil nil t)) + (overlay-put csv--header-line 'modification-hooks + '(csv--header-flush))) + (csv--header-flush) + ;; These are introduced in Emacs 29. + (unless (boundp 'header-line-indent) + (setq-local header-line-indent "" + header-line-indent-width 0)) + (setq header-line-format + '("" header-line-indent (:eval (csv--header-string)))))) + +(defun csv--header-flush (&rest _) + ;; Force re-computation of the header-line. + (setq csv--header-hscroll nil)) + +(defun csv--header-string () + ;; FIXME: Won't work with multiple windows showing that same buffer. + (if (eql (window-hscroll) csv--header-hscroll) + csv--header-string + (setq csv--header-hscroll (window-hscroll)) + (setq csv--header-string + (csv--compute-header-string)))) + +(defun csv--compute-header-string () + (with-demoted-errors "csv--compute-header-string %S" + (save-excursion + (goto-char (overlay-start csv--header-line)) + ;; Re-set the line-end-position, just in case. + (move-overlay csv--header-line (point) (line-end-position)) + (jit-lock-fontify-now (point) (line-end-position)) + ;; Not sure why it is sometimes nil! + (move-to-column (or csv--header-hscroll 0)) + (let ((str (replace-regexp-in-string + "%" "%%" (buffer-substring (point) (line-end-position)))) + (i 0)) + (while (and i (< i (length str))) + (let ((prop (get-text-property i 'display str))) + (and (eq (car-safe prop) 'space) + (eq (car-safe (cdr prop)) :align-to) + (let* ((x (nth 2 prop)) + (nexti (next-single-property-change i 'display str)) + (newprop + `(space :align-to + (+ ,(if (numberp x) + (- x (or csv--header-hscroll 0)) + `(- ,x csv--header-hscroll)) + header-line-indent-width)))) + (put-text-property i (or nexti (length str)) + 'display newprop str) + (setq i nexti)))) + (setq i (next-single-property-change i 'display str))) + (concat (propertize " " 'display '((space :align-to 0))) str))))) + +;;; Auto-alignment + +(defcustom csv-align-max-width 40 + "Maximum width of a column in `csv-align-mode'. +This does not apply to the last column (for which the usual `truncate-lines' +setting works better)." + :type 'integer) + +(defcustom csv-align-min-width 1 + "Minimum width of a column in `csv-align-mode'." + :type 'integer) + +(defvar-local csv--config-column-widths nil + "Settings per column, stored as a list indexed by the column.") + +(defun csv-align--set-column (column value) + (let ((len (length csv--config-column-widths))) + (if (< len column) + (setq csv--config-column-widths + (nconc csv--config-column-widths (make-list (- column len) nil)))) + (setf (nth (1- column) csv--config-column-widths) value))) + +(defun csv-align-set-column-width (column width) + "Set the max WIDTH to use for COLUMN." + (interactive + (let* ((field (or (csv--field-index) 1)) + (curwidth (nth (1- field) csv--config-column-widths))) + (list field + (cond + ((numberp current-prefix-arg) + current-prefix-arg) + (current-prefix-arg + (read-number (format "Column width (for field %d): " field) + curwidth)) + (t (if curwidth nil (csv--ellipsis-width))))))) + (when (eql width csv-align-max-width) + (setq width nil)) + (csv-align--set-column column width) + (jit-lock-refontify)) + +(defvar-local csv--jit-columns nil) + +(defun csv--jit-flush-columns () + "Throw away all cached info about column widths." + ;; FIXME: Maybe we should kill its overlays as well. + (setq csv--jit-columns nil)) + +(defun csv--jit-merge-columns (column-widths) + ;; FIXME: The incremental update (delayed by jit-lock-context-time) of column + ;; width is a bit jarring at times. It's OK while scrolling or when + ;; extending a column, but not right when enabling the csv-align-mode or + ;; when shortening the longest field (or deleting the line containing it), + ;; because in that case we have *several* cascaded updates, e.g.: + ;; - Remove the line with the longest field of column N. + ;; - Edit some line: this line is updated as if its field was the widest, + ;; hence its subsequent fields are too much to the left. + ;; - The rest is updated starting from the first few lines (according + ;; to jit-lock-chunk-size). + ;; - After the first few lines, come the next set of few lines, + ;; which may cause the previous few lines to need refresh again. + ;; - etc.. until arriving again at the edited line which is re-aligned + ;; again. + ;; - etc.. until the end of the windows, potentially causing yet more + ;; refreshes as we discover yet-wider fields for this column. + (let ((old-columns csv--jit-columns) + (changed nil)) + (while (and old-columns column-widths) + (when (or (> (caar column-widths) (caar old-columns)) + ;; Apparently modification-hooks aren't run when the + ;; whole text containing the overlay is deleted (e.g. + ;; the whole line), so detect this case here. + ;; It's a bit too late, but better than never. + (null (overlay-buffer (cdar old-columns)))) + (setq changed t) ;; Return non-nil if some existing column changed. + (pcase-let ((`(,width ,beg ,end) (car column-widths))) + (setf (caar old-columns) width) + (move-overlay (cdar old-columns) beg end))) + (setq old-columns (cdr old-columns)) + (setq column-widths (cdr column-widths))) + (when column-widths + ;; New columns appeared. + (setq csv--jit-columns + (nconc csv--jit-columns + (mapcar (lambda (x) + (pcase-let* + ((`(,width ,beg ,end) x) + (ol (make-overlay beg end))) + (overlay-put ol 'csv-width t) + (overlay-put ol 'evaporate t) + (overlay-put ol 'modification-hooks + (list #'csv--jit-width-change)) + (cons width ol))) + column-widths)))) + changed)) + +(defun csv--jit-width-change (ol after _beg _end &optional len) + (when (and after (> len 0)) + ;; (let ((x (rassq ol csv--jit-columns))) + ;; (when x (setf (car x) -1))) + (delete-overlay ol))) + +(defun csv--jit-unalign (beg end) + (with-silent-modifications + (remove-text-properties beg end + '( display nil csv--jit nil invisible nil + cursor-sensor-functions nil csv--revealed nil)) + (remove-overlays beg end 'csv--jit t))) + +(defun csv--jit-flush (beg end) + "Cause all the buffer (except for the BEG...END region) to be re-aligned." + (cl-assert (>= end beg)) + ;; The buffer shouldn't have changed since beg/end were computed, + ;; but just in case, let's make sure they're still sane. + (when (< beg (point-min)) + (setq beg (point-min) end (max end beg))) + (when (< (point-max) end) + (setq end (point-max) beg (min end beg))) + (let ((pos (point-min))) + (while (and (< pos beg) + (setq pos (text-property-any pos beg 'csv--jit t))) + (jit-lock-refontify + pos (setq pos (or (text-property-any pos beg 'csv--jit nil) beg)))) + (setq pos end) + (while (and (< pos (point-max)) + (setq pos (text-property-any pos (point-max) 'csv--jit t))) + (jit-lock-refontify + pos (setq pos (or (text-property-any pos (point-max) 'csv--jit nil) + (point-max)))))) + (csv--header-flush)) + +(defun csv--ellipsis-width () + (let ((ellipsis + (when standard-display-table + (display-table-slot standard-display-table + 'selective-display)))) + (if ellipsis (length ellipsis) 3))) + +(defun csv-align--cursor-truncated (window oldpos dir) + ;; FIXME: Neither the `entered' nor the `left' event are guaranteed + ;; to be sent, and for the `left' case, even when we do get called, + ;; it may be unclear where the revealed text was (it's somewhere around + ;; `oldpos', but that position can be stale). + ;; Worse, if we have several windows displaying the buffer, when one + ;; cursor leaves we may need to keep the text revealed because of + ;; another window's cursor. + (let* ((prop (if (eq dir 'entered) 'invisible 'csv--revealed)) + (pos (cond + ((eq dir 'entered) (window-point window)) + (t (max (point-min) + (min (point-max) + (or oldpos (window-point window))))))) + (start (cond + ((and (> pos (point-min)) + (eq (get-text-property (1- pos) prop) 'csv-truncate)) + (or (previous-single-property-change pos prop) (point-min))) + (t pos))) + (end (if (eq (get-text-property pos prop) 'csv-truncate) + (or (next-single-property-change pos prop) (point-max)) + pos))) + (unless (eql start end) + (with-silent-modifications + (put-text-property start end + (if (eq dir 'entered) 'csv--revealed 'invisible) + 'csv-truncate) + (remove-text-properties start end (list prop)))))) + +(defun csv--jit-align (beg end) + (save-excursion + ;; This is run with inhibit-modification-hooks set, so the overlays' + ;; modification-hook doesn't work :-( + (and csv--header-line + (<= beg (overlay-end csv--header-line)) + (>= end (overlay-start csv--header-line)) + (csv--header-flush)) + ;; First, round up to a whole number of lines. + (goto-char end) + (unless (bolp) (forward-line 1) (setq end (point))) + (goto-char beg) + (unless (bolp) (forward-line 1) (setq beg (point))) + (csv--jit-unalign beg end) + (put-text-property beg end 'csv--jit t) + + (pcase-let* ((`(,column-widths ,field-widths) (csv--column-widths beg end)) + (changed (csv--jit-merge-columns column-widths)) + (ellipsis-width (csv--ellipsis-width))) + (when changed + ;; Do it after the current redisplay is over. + (run-with-timer jit-lock-context-time nil #'csv--jit-flush beg end)) + + ;; Align fields: + (goto-char beg) + (while (< (point) end) + (unless (csv-not-looking-at-record) + (let ((w csv--jit-columns) + (widths-config csv--config-column-widths) + (column 0)) ;Desired position of left-side of this column. + (while (and w (not (eolp))) + (let* ((field-beg (point)) + (width-config (pop widths-config)) + (align-padding (if (bolp) 0 csv-align-padding)) + (left-padding 0) (right-padding 0) + (field-width (pop field-widths)) + (column-width + (min (max csv-align-min-width + (car (pop w))) + (or width-config + ;; Don't apply csv-align-max-width + ;; to the last field! + (if w csv-align-max-width + most-positive-fixnum)))) + (x (- column-width field-width)) ; Required padding. + (truncate nil)) + (csv-end-of-field) + ;; beg = beginning of current field + ;; end = (point) = end of current field + (when (< x 0) + (setq truncate (max column + (+ column column-width + align-padding (- ellipsis-width)))) + (setq x 0)) + ;; Compute required padding: + (pcase csv-align-style + ('left + ;; Left align -- pad on the right: + (setq left-padding align-padding + right-padding x)) + ('right + ;; Right align -- pad on the left: + (setq left-padding (+ align-padding x))) + ('auto + ;; Auto align -- left align text, right align numbers: + (if (string-match "\\`[-+.[:digit:]]+\\'" + (buffer-substring field-beg (point))) + ;; Right align -- pad on the left: + (setq left-padding (+ align-padding x)) + ;; Left align -- pad on the right: + (setq left-padding align-padding + right-padding x))) + ('centre + ;; Centre -- pad on both left and right: + (let ((y (/ x 2))) ; truncated integer quotient + (setq left-padding (+ align-padding y) + right-padding (- x y))))) + + (cond + + ((or (memq 'csv buffer-invisibility-spec) + ;; For TSV, hidden or not doesn't make much difference, + ;; but the behavior is slightly better when we "hide" + ;; the TABs with a `display' property than if we add + ;; before/after-strings. + (tsv--mode-p)) + + ;; Hide separators... + ;; Merge right-padding from previous field + ;; with left-padding from this field: + (if (zerop column) + (when (> left-padding 0) + ;; Display spaces before first field + ;; by overlaying first character: + (csv--make-overlay + field-beg (1+ field-beg) nil nil nil + `(before-string ,(make-string left-padding ?\ ) + csv--jit t))) + ;; Display separator as spaces: + (with-silent-modifications + (put-text-property + (1- field-beg) field-beg + 'display `(space :align-to + ,(+ left-padding column)))))) + + (t ;; Do not hide separators... + (let ((overlay (csv--make-overlay field-beg (point) + nil nil t + '(csv--jit t)))) + (when (> left-padding 0) ; Pad on the left. + ;; Display spaces before field: + (overlay-put overlay 'before-string + (make-string left-padding ?\ ))) + (unless (eolp) + (if (> right-padding 0) ; Pad on the right. + ;; Display spaces after field: + (overlay-put + overlay + 'after-string (make-string right-padding ?\ ))))))) + (setq column (+ column column-width align-padding)) + ;; Do it after applying the property, so `move-to-column' can + ;; take it into account. + (when truncate + (let ((trunc-pos + (save-excursion + ;; ¡¡ BIG UGLY HACK !! + ;; `current-column' and `move-to-column' count + ;; text hidden with an ellipsis "as if" it were + ;; fully visible, which is completely wrong here, + ;; so circumvent this by temporarily pretending + ;; that `csv-truncate' is fully invisible (which + ;; isn't quite right either, but should work + ;; just well enough for us here). + (let ((buffer-invisibility-spec + buffer-invisibility-spec)) + (add-to-invisibility-spec 'csv-truncate) + (move-to-column truncate)) + (point)))) + (put-text-property trunc-pos (point) + 'invisible 'csv-truncate) + (when (> (- (point) trunc-pos) 1) + ;; Arrange to temporarily untruncate the string when + ;; cursor moves into it. + ;; FIXME: This only works if + ;; `global-disable-point-adjustment' is non-nil! + ;; Arguably this should be fixed by making + ;; point-adjustment code pay attention to + ;; cursor-sensor-functions! + (put-text-property + (1+ trunc-pos) (point) + 'cursor-sensor-functions + (list #'csv-align--cursor-truncated))))) + (unless (eolp) (forward-char)) ; Skip separator. + )))) + (forward-line))) + `(jit-lock-bounds ,beg . ,end))) + +(define-minor-mode csv-align-mode + "Align columns on the fly." + :global nil + (csv-unalign-fields nil (point-min) (point-max)) ;Just in case. + (cond + (csv-align-mode + (add-to-invisibility-spec '(csv-truncate . t)) + (kill-local-variable 'csv--jit-columns) + (cursor-sensor-mode 1) + (when (fboundp 'header-line-indent-mode) + (header-line-indent-mode)) + (jit-lock-register #'csv--jit-align) + (jit-lock-refontify)) + (t + (remove-from-invisibility-spec '(csv-truncate . t)) + (jit-lock-unregister #'csv--jit-align) + (csv--jit-unalign (point-min) (point-max)))) + (csv--header-flush)) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Separator guessing +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defvar csv--preferred-separators + '(?, ?\; ?\t) + "Preferred separator characters in case of a tied score.") + +(defun csv-guess-set-separator () + "Guess and set the CSV separator of the current buffer. + +Add it to the mode hook to have CSV mode guess and set the +separator automatically when visiting a buffer: + + (add-hook \\='csv-mode-hook \\='csv-guess-set-separator)" + (interactive) + (let ((sep (csv-guess-separator + (buffer-substring-no-properties + (point-min) + ;; We're probably only going to look at the first 2048 + ;; or so chars, but take more than we probably need to + ;; minimize the chance of breaking the input in the + ;; middle of a (long) row. + (min 8192 (point-max))) + 2048))) + (when sep + (csv-set-separator sep)))) + +(defun csv-guess-separator (text &optional cutoff) + "Return a guess of which character is the CSV separator in TEXT." + (let ((best-separator nil) + (best-score 0)) + (dolist (candidate (csv--separator-candidates text cutoff)) + (let ((candidate-score + (csv--separator-score candidate text cutoff))) + (when (or (> candidate-score best-score) + (and (= candidate-score best-score) + (member candidate csv--preferred-separators))) + (setq best-separator candidate) + (setq best-score candidate-score)))) + best-separator)) + +(defun csv--separator-candidates (text &optional cutoff) + "Return a list of candidate CSV separators in TEXT. +When CUTOFF is passed, look only at the first CUTOFF number of characters." + (let ((chars (make-hash-table))) + (dolist (c (string-to-list + (if cutoff + (substring text 0 (min cutoff (length text))) + text))) + (when (and (not (gethash c chars)) + (or (= c ?\t) + (= c ?\C-_) + (and (not (member c '(?. ?/ ?\" ?'))) + (not (member (get-char-code-property c 'general-category) + '(Lu Ll Lt Lm Lo Nd Nl No Ps Pe Cc Co)))))) + (puthash c t chars))) + (hash-table-keys chars))) + +(defun csv--separator-score (separator text &optional cutoff) + "Return a score on how likely SEPARATOR is a separator in TEXT. + +When CUTOFF is passed, stop the calculation at the next whole +line after having read CUTOFF number of characters. + +The scoring is based on the idea that most CSV data is tabular, +i.e. separators should appear equally often on each line. +Furthermore, more commonly appearing characters are scored higher +than those who appear less often. + +Adapted from the paper \"Wrangling Messy CSV Files by Detecting +Row and Type Patterns\" by Gerrit J.J. van den Burg , Alfredo +Nazábal, and Charles Sutton: https://arxiv.org/abs/1811.11242." + (let ((groups + (with-temp-buffer + (csv-set-separator separator) + (save-excursion + (insert text)) + (let ((groups (make-hash-table)) + (chars-read 0)) + (while (and (/= (point) (point-max)) + (or (not cutoff) + (< chars-read cutoff))) + (let* ((lep (line-end-position)) + (nfields (length (csv--collect-fields lep)))) + (cl-incf (gethash nfields groups 0)) + (cl-incf chars-read (- lep (point))) + (goto-char (+ lep 1)))) + groups))) + (sum 0)) + (maphash + (lambda (length num) + (cl-incf sum (* num (/ (- length 1) (float length))))) + groups) + (let ((unique-groups (hash-table-count groups))) + (if (= 0 unique-groups) + 0 + (/ sum unique-groups))))) + +;;; TSV support + +;; Since "the" CSV format is really a bunch of different formats, it includes +;; TSV as a subcase, but this subcase is sufficiently interesting that it has +;; its own mime-type and mostly standard file extension, also it suffers +;; less from the usual quoting problems of CSV (because the only problematic +;; chars are LF and TAB, really, which are much less common inside fields than +;; commas, space, and semi-colons) so it's "better behaved". + +(defvar tsv-mode-syntax-table + ;; Inherit from `text-mode-syntax-table' rather than from + ;; `csv-mode-syntax-table' so as not to inherit the + ;; `csv-field-quotes' settings. + (let ((st (make-syntax-table text-mode-syntax-table))) + st)) + +(defvar tsv-mode-map + (let ((map (make-sparse-keymap))) + ;; In `tsv-mode', the `csv-invisibility-default/csv-toggle-invisibility' + ;; business doesn't make much sense. + (define-key map [remap csv-toggle-invisibility] #'undefined) + map)) + +;;;###autoload +(add-to-list 'auto-mode-alist '("\\.tsv\\'" . tsv-mode)) + +(defun tsv--mode-p () + (equal csv-separator-chars '(?\t))) + +;;;###autoload +(define-derived-mode tsv-mode csv-mode "TSV" + "Major mode for editing files of tab-separated value type." + :group 'CSV + ;; In TSV we know TAB is the only possible separator. + (setq-local csv-separators '("\t")) + ;; FIXME: Copy&pasted from the `:set'ter of csv-separators! + (setq-local csv-separator-chars '(?\t)) + (setq-local csv--skip-chars "^\n\t") + (setq-local csv-separator-regexp "\t") + (setq-local csv-font-lock-keywords + ;; NB: csv-separator-face variable evaluates to itself. + `((,csv-separator-regexp (0 'csv-separator-face)))) + + ;; According to wikipedia, TSV doesn't use quotes but uses backslash escapes + ;; of the form \n, \t, \r, and \\ instead. + (setq-local csv-field-quotes nil)) + + +(provide 'csv-mode) + +;;; csv-mode.el ends here diff --git a/emacs/elpa/csv-mode-1.25/csv-mode.elc b/emacs/elpa/csv-mode-1.25/csv-mode.elc Binary files differ. diff --git a/emacs/elpa/ledger-mode-20240423.445/ledger-commodities.el b/emacs/elpa/ledger-mode-20240423.445/ledger-commodities.el @@ -1,170 +0,0 @@ -;;; ledger-commodities.el --- Helper code for use with the "ledger" command-line tool -*- lexical-binding: t; -*- - -;; Copyright (C) 2003-2016 John Wiegley (johnw AT gnu DOT org) - -;; This file is not part of GNU Emacs. - -;; This 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 2, or (at your option) any later -;; version. -;; -;; This 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 GNU Emacs; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -;; MA 02110-1301 USA. - -;;; Commentary: -;; Helper functions to deal with commoditized numbers. A commoditized -;; number will be a list of value and string where the string contains -;; the commodity - -;;; Code: - -(require 'ledger-regex) - -;; These keep the byte-compiler from warning about them, but have no other -;; effect: -(defvar ledger-environment-alist) -(declare-function ledger-exec-ledger "ledger-exec" (input-buffer &optional output-buffer &rest args)) - -(defcustom ledger-reconcile-default-commodity "$" - "The default commodity for use in target calculations in ledger reconcile." - :type 'string - :group 'ledger-reconcile) - -(defun ledger-read-commodity-with-prompt (prompt) - "Read commodity name after PROMPT. - -Default value is `ledger-reconcile-default-commodity'." - (let* ((buffer (current-buffer)) - (commodities (with-temp-buffer - (ledger-exec-ledger buffer (current-buffer) "commodities") - (split-string (buffer-string) "\n" t)))) - (completing-read prompt commodities nil t nil nil ledger-reconcile-default-commodity))) - -(defun ledger-split-commodity-string (str) - "Split a commoditized string, STR, into two parts. -Returns a list with (value commodity)." - (let ((number-regex (if (assoc "decimal-comma" ledger-environment-alist) - ledger-amount-decimal-comma-regex - ledger-amount-decimal-period-regex))) - (if (> (length str) 0) - (with-temp-buffer - (insert str) - (goto-char (point-min)) - (cond - ((re-search-forward "\"\\(.*\\)\"" nil t) ; look for quoted commodities - (let ((com (delete-and-extract-region - (match-beginning 1) - (match-end 1)))) - (if (re-search-forward - number-regex nil t) - (list - (ledger-string-to-number - (delete-and-extract-region (match-beginning 0) (match-end 0))) - com)))) - ((re-search-forward number-regex nil t) - ;; found a number in the current locale, return it in the - ;; car. Anything left over is annotation, the first - ;; thing should be the commodity, separated by - ;; whitespace, return it in the cdr. I can't think of - ;; any counterexamples - (list - (ledger-string-to-number - (delete-and-extract-region (match-beginning 0) (match-end 0))) - (nth 0 (split-string (buffer-substring-no-properties (point-min) (point-max)))))) - ((re-search-forward "0" nil t) - ;; couldn't find a decimal number, look for a single 0, - ;; indicating account with zero balance - (list 0 ledger-reconcile-default-commodity)) - ;; nothing found, return 0 - (t (list 0 ledger-reconcile-default-commodity))))))) - -(defun ledger-string-balance-to-commoditized-amount (str) - "Return a commoditized amount (val, \"comm\") from STR." - ; break any balances with multi commodities into a list - (mapcar #'(lambda (st) - (ledger-split-commodity-string st)) - (split-string str "[\n\r]"))) - -(defun ledger-subtract-commodity (c1 c2) - "Subtract C2 from C1, ensuring their commodities match. - -As an exception, if the quantity of C2 is zero, C1 is returned -directly." - (cond - ((zerop (car c2)) c1) - ((string= (cadr c1) (cadr c2)) - (list (- (car c1) (car c2)) (cadr c1))) - (t (error "Can't subtract different commodities: %S - %S" c1 c2)))) - -(defun ledger-add-commodity (c1 c2) - "Add C1 and C2, ensuring their commodities match. - -As an exception, if the quantity of C2 is zero, C1 is returned -directly." - (cond - ((zerop (car c2)) c1) - ((string= (cadr c1) (cadr c2)) - (list (+ (car c1) (car c2)) (cadr c1))) - (t (error "Can't add different commodities: %S + %S" c1 c2)))) - -(defun ledger-strip (str char) - "Return STR with CHAR removed." - (replace-regexp-in-string char "" str)) - -(defun ledger-string-to-number (str &optional decimal-comma) - "Parse STR as a number and return that number. - -Improves builtin `string-to-number' by handling -internationalization, and return nil if number can't be parsed. -See `ledger-environment-alist' for DECIMAL-COMMA." - (let ((nstr (if (or decimal-comma - (assoc "decimal-comma" ledger-environment-alist)) - (ledger-strip str "[.]") - (ledger-strip str ",")))) - (while (string-match "," nstr) ;if there is a comma now, it is a decimal point - (setq nstr (replace-match "." nil nil nstr))) - (string-to-number nstr))) - -(defun ledger-number-to-string (n &optional decimal-comma) - "See `number-to-string' for N. -DECIMAL-COMMA is as documented in `ledger-environment-alist'." - (let ((str (number-to-string n))) - (when (or decimal-comma - (assoc "decimal-comma" ledger-environment-alist)) - (while (string-match "\\." str) - (setq str (replace-match "," nil nil str)))) - str)) - -(defun ledger-commodity-to-string (c1) - "Return string representing C1. -Single character commodities are placed ahead of the value, -longer ones are after the value." - (let ((str (ledger-number-to-string (car c1))) - (commodity (cadr c1))) - (if (> (length commodity) 1) - (concat str " " commodity) - (concat commodity " " str)))) - -(defun ledger-read-commodity-string (prompt) - "Read an amount from mini-buffer using PROMPT." - (let ((str (read-from-minibuffer - (concat prompt " (" ledger-reconcile-default-commodity "): "))) - comm) - (when (and (> (length str) 0) - (ledger-split-commodity-string str)) - (setq comm (ledger-split-commodity-string str)) - (if (cadr comm) - comm - (list (car comm) ledger-reconcile-default-commodity))))) - -(provide 'ledger-commodities) - -;;; ledger-commodities.el ends here diff --git a/emacs/elpa/ledger-mode-20240423.445/ledger-commodities.elc b/emacs/elpa/ledger-mode-20240423.445/ledger-commodities.elc Binary files differ. diff --git a/emacs/elpa/ledger-mode-20240423.445/ledger-mode-pkg.el b/emacs/elpa/ledger-mode-20240423.445/ledger-mode-pkg.el @@ -1,6 +0,0 @@ -(define-package "ledger-mode" "20240423.445" "Helper code for use with the \"ledger\" command-line tool" - '((emacs "25.1")) - :commit "c66e3e9adfb5d91f83a401387fad345f12004c8a") -;; Local Variables: -;; no-byte-compile: t -;; End: diff --git a/emacs/elpa/ledger-mode-20240423.445/ledger-post.el b/emacs/elpa/ledger-mode-20240423.445/ledger-post.el @@ -1,195 +0,0 @@ -;;; ledger-post.el --- Helper code for use with the "ledger" command-line tool -*- lexical-binding: t; -*- - -;; Copyright (C) 2003-2016 John Wiegley (johnw AT gnu DOT org) - -;; This file is not part of GNU Emacs. - -;; This 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 2, or (at your option) any later -;; version. -;; -;; This 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 GNU Emacs; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -;; MA 02110-1301 USA. - - -;;; Commentary: -;; Utility functions for dealing with postings. - -(require 'ledger-regex) -(require 'ledger-navigate) - -(declare-function calc-renumber-stack "calc" ()) -(declare-function ledger-string-to-number "ledger-commodities" (str &optional decimal-comma)) - -;;; Code: - -(defgroup ledger-post nil - "Options for controlling how Ledger-mode deals with postings and completion" - :group 'ledger) - -(defcustom ledger-post-account-alignment-column 4 - "The column Ledger-mode attempts to align accounts to." - :type 'integer - :group 'ledger-post - :safe 'integerp) - -(defcustom ledger-post-amount-alignment-column 52 - "The column Ledger-mode attempts to align amounts to." - :type 'integer - :group 'ledger-post - :safe 'integerp) - -(defcustom ledger-post-amount-alignment-at :end - "Position at which the amount is aligned. - -Can be :end to align on the last number of the amount (can be -followed by unaligned commodity) or :decimal to align at the -decimal separator." - :type '(radio (const :tag "align at the end of amount" :end) - (const :tag "align at the decimal separator" :decimal)) - :group 'ledger-post - :safe (lambda (x) (memq x '(:end :decimal)))) - -(defcustom ledger-post-auto-align t - "When non-nil, realign post amounts when indenting or completing." - :type 'boolean - :group 'ledger-post - :package-version '(ledger-mode . "4.0.0") - :safe 'booleanp) - -(defun ledger-next-amount (&optional end) - "Move point to the next amount, as long as it is not past END. -Return the width of the amount field as an integer and leave -point at beginning of the commodity." - ;;(beginning-of-line) - (let ((case-fold-search nil)) - (when (re-search-forward ledger-amount-regex end t) - (goto-char (match-beginning 0)) - (skip-syntax-forward " ") - (cond - ((eq ledger-post-amount-alignment-at :end) - (- (or (match-end 4) (match-end 3)) (point))) - ((eq ledger-post-amount-alignment-at :decimal) - (- (match-end 3) (point))))))) - -(defun ledger-next-account (&optional end) - "Move to the beginning of the posting, or status marker. -Return the column of the beginning of the account and leave point -at beginning of account. -Looks only as far as END, if supplied, otherwise `point-max'." - (let ((end (or end (point-max)))) - (if (> end (point)) - (when (re-search-forward ledger-account-any-status-regex (1+ end) t) - ;; the 1+ is to make sure we can catch the newline - (if (match-beginning 1) - (goto-char (match-beginning 1)) - (goto-char (match-beginning 2))) - (current-column))))) - -(defun ledger-post-align-xact (pos) - "Align all the posting in the xact at POS." - (interactive "d") - (let ((bounds (ledger-navigate-find-xact-extents pos))) - (ledger-post-align-postings (car bounds) (cadr bounds)))) - -(defun ledger-post-align-postings (beg end) - "Align all accounts and amounts between BEG and END. -The current region is used, or, if no region, the current line." - (interactive "r") - (save-match-data - (save-excursion - (let ((inhibit-modification-hooks t) - ;; Extend region to whole lines - (beg (save-excursion (goto-char beg) (line-beginning-position))) - (end (save-excursion (goto-char end) (move-end-of-line 1) (point-marker)))) - (untabify beg end) - (goto-char beg) - (while (< (point) end) - (when (looking-at-p " ") - ;; fix spaces at beginning of line: - (just-one-space ledger-post-account-alignment-column) - ;; fix spaces before amount if any: - (when (re-search-forward "\t\\| \\| \t" (line-end-position) t) - (goto-char (match-beginning 0)) - (let ((acct-end-column (current-column)) - (amt-width (ledger-next-amount (line-end-position))) - amt-adjust) - (when amt-width - (if (/= 0 (setq amt-adjust (- (if (> (- ledger-post-amount-alignment-column amt-width) - (+ 2 acct-end-column)) - ledger-post-amount-alignment-column ;;we have room - (+ acct-end-column 2 amt-width)) - amt-width - (current-column)))) - (if (> amt-adjust 0) - (insert (make-string amt-adjust ? )) - (delete-char amt-adjust))))))) - (forward-line 1)))))) - -(defun ledger-indent-line () - "Indent the current line." - ;; Ensure indent if the previous line was indented - (let ((indent-level (save-excursion (if (and (zerop (forward-line -1)) - (memq (ledger-thing-at-point) '(transaction posting))) - ledger-post-account-alignment-column - 0)))) - (unless (= (current-indentation) indent-level) - (back-to-indentation) - (delete-horizontal-space t) - (indent-to indent-level))) - (when ledger-post-auto-align - (ledger-post-align-postings (line-beginning-position) (line-end-position)))) - -(defun ledger-post-align-dwim () - "Align all the posting of the current xact or the current region. - -If the point is in a comment, fill the comment paragraph as -regular text." - (interactive) - (cond - ((nth 4 (syntax-ppss)) - (call-interactively 'ledger-post-align-postings) - (fill-paragraph)) - ((use-region-p) (call-interactively 'ledger-post-align-postings)) - (t (call-interactively 'ledger-post-align-xact)))) - -(defun ledger-post-edit-amount () - "Call `calc' and push the amount in the posting to the top of stack, if any. - -In the calc buffer, press y to use the top value in the stack as -the amount and return to ledger." - (interactive) - (beginning-of-line) - (when (re-search-forward ledger-post-line-regexp (line-end-position) t) - (goto-char (match-end ledger-regex-post-line-group-account)) ;; go to the end of the account - ;; determine if there is an amount to edit - (if (re-search-forward ledger-amount-regexp (line-end-position) t) - (let ((val-string (match-string 0))) - (goto-char (match-beginning 0)) - (delete-region (match-beginning 0) (match-end 0)) - (push-mark (point) 'nomsg) - (calc) - ;; edit the amount, first removing thousands separators and converting - ;; decimal commas to calc's input format - (calc-eval (number-to-string (ledger-string-to-number val-string)) 'push) - (calc-renumber-stack)) - ;; make sure there are two spaces after the account name and go to calc - (if (search-backward " " (- (point) 3) t) - (end-of-line) - (insert " ")) - (push-mark (point) 'nomsg) - (calc)))) - -(provide 'ledger-post) - - - -;;; ledger-post.el ends here diff --git a/emacs/elpa/ledger-mode-20240423.445/ledger-post.elc b/emacs/elpa/ledger-mode-20240423.445/ledger-post.elc Binary files differ. diff --git a/emacs/elpa/ledger-mode-20240423.445/dir b/emacs/elpa/ledger-mode-20240527.2134/dir diff --git a/emacs/elpa/ledger-mode-20240423.445/ledger-check.el b/emacs/elpa/ledger-mode-20240527.2134/ledger-check.el diff --git a/emacs/elpa/ledger-mode-20240423.445/ledger-check.elc b/emacs/elpa/ledger-mode-20240527.2134/ledger-check.elc Binary files differ. diff --git a/emacs/elpa/ledger-mode-20240527.2134/ledger-commodities.el b/emacs/elpa/ledger-mode-20240527.2134/ledger-commodities.el @@ -0,0 +1,174 @@ +;;; ledger-commodities.el --- Helper code for use with the "ledger" command-line tool -*- lexical-binding: t; -*- + +;; Copyright (C) 2003-2016 John Wiegley (johnw AT gnu DOT org) + +;; This file is not part of GNU Emacs. + +;; This 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 2, or (at your option) any later +;; version. +;; +;; This 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 GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +;; MA 02110-1301 USA. + +;;; Commentary: +;; Helper functions to deal with commoditized numbers. A commoditized +;; number will be a list of value and string where the string contains +;; the commodity + +;;; Code: + +(require 'ledger-regex) + +;; These keep the byte-compiler from warning about them, but have no other +;; effect: +(defvar ledger-environment-alist) +(declare-function ledger-exec-ledger "ledger-exec" (input-buffer &optional output-buffer &rest args)) + +(defcustom ledger-reconcile-default-commodity "$" + "The default commodity for use in target calculations in ledger reconcile." + :type 'string + :group 'ledger-reconcile) + +(defun ledger-read-commodity-with-prompt (prompt) + "Read commodity name after PROMPT. + +Default value is `ledger-reconcile-default-commodity'." + (let* ((buffer (current-buffer)) + (commodities (with-temp-buffer + (ledger-exec-ledger buffer (current-buffer) "commodities") + (split-string (buffer-string) "\n" t)))) + (completing-read prompt commodities nil t nil nil ledger-reconcile-default-commodity))) + +(defun ledger-split-commodity-string (str) + "Split a commoditized string, STR, into two parts. +Returns a list with (value commodity)." + (let ((number-regex (if (assoc "decimal-comma" ledger-environment-alist) + ledger-amount-decimal-comma-regex + ledger-amount-decimal-period-regex))) + (if (> (length str) 0) + (with-temp-buffer + (insert str) + (goto-char (point-min)) + (cond + ((re-search-forward "\"\\(.*\\)\"" nil t) ; look for quoted commodities + (let ((com (delete-and-extract-region + (match-beginning 1) + (match-end 1)))) + (if (re-search-forward + number-regex nil t) + (list + (ledger-string-to-number + (delete-and-extract-region (match-beginning 0) (match-end 0))) + com)))) + ((re-search-forward number-regex nil t) + ;; found a number in the current locale, return it in the + ;; car. Anything left over is annotation, the first + ;; thing should be the commodity, separated by + ;; whitespace, return it in the cdr. I can't think of + ;; any counterexamples + (list + (ledger-string-to-number + (delete-and-extract-region (match-beginning 0) (match-end 0))) + (nth 0 (split-string (buffer-substring-no-properties (point-min) (point-max)))))) + ((re-search-forward "0" nil t) + ;; couldn't find a decimal number, look for a single 0, + ;; indicating account with zero balance + (list 0 ledger-reconcile-default-commodity)) + ;; nothing found, return 0 + (t (list 0 ledger-reconcile-default-commodity))))))) + +(defun ledger-string-balance-to-commoditized-amount (str) + "Return a commoditized amount (val, \"comm\") from STR." + ; break any balances with multi commodities into a list + (mapcar #'(lambda (st) + (ledger-split-commodity-string st)) + (split-string str "[\n\r]"))) + +(defun ledger-subtract-commodity (c1 c2) + "Subtract C2 from C1, ensuring their commodities match. + +As an exception, if the quantity of C2 is zero, C1 is returned +directly." + (cond + ((zerop (car c2)) c1) + ((string= (cadr c1) (cadr c2)) + (list (- (car c1) (car c2)) (cadr c1))) + (t (error "Can't subtract different commodities: %S - %S" c1 c2)))) + +(defun ledger-add-commodity (c1 c2) + "Add C1 and C2, ensuring their commodities match. + +As an exception, if the quantity of C2 is zero, C1 is returned +directly." + (cond + ((zerop (car c2)) c1) + ((string= (cadr c1) (cadr c2)) + (list (+ (car c1) (car c2)) (cadr c1))) + (t (error "Can't add different commodities: %S + %S" c1 c2)))) + +(defun ledger-negate-commodity (c) + "Return the negative of the commoditized amount C." + (list (- (car c)) (cadr c))) + +(defun ledger-strip (str char) + "Return STR with CHAR removed." + (replace-regexp-in-string char "" str)) + +(defun ledger-string-to-number (str &optional decimal-comma) + "Parse STR as a number and return that number. + +Improves builtin `string-to-number' by handling +internationalization, and return nil if number can't be parsed. +See `ledger-environment-alist' for DECIMAL-COMMA." + (let ((nstr (if (or decimal-comma + (assoc "decimal-comma" ledger-environment-alist)) + (ledger-strip str "[.]") + (ledger-strip str ",")))) + (while (string-match "," nstr) ;if there is a comma now, it is a decimal point + (setq nstr (replace-match "." nil nil nstr))) + (string-to-number nstr))) + +(defun ledger-number-to-string (n &optional decimal-comma) + "See `number-to-string' for N. +DECIMAL-COMMA is as documented in `ledger-environment-alist'." + (let ((str (number-to-string n))) + (when (or decimal-comma + (assoc "decimal-comma" ledger-environment-alist)) + (while (string-match "\\." str) + (setq str (replace-match "," nil nil str)))) + str)) + +(defun ledger-commodity-to-string (c1) + "Return string representing C1. +Single character commodities are placed ahead of the value, +longer ones are after the value." + (let ((str (ledger-number-to-string (car c1))) + (commodity (cadr c1))) + (if (> (length commodity) 1) + (concat str " " commodity) + (concat commodity " " str)))) + +(defun ledger-read-commodity-string (prompt) + "Read an amount from mini-buffer using PROMPT." + (let ((str (read-from-minibuffer + (concat prompt " (" ledger-reconcile-default-commodity "): "))) + comm) + (when (and (> (length str) 0) + (ledger-split-commodity-string str)) + (setq comm (ledger-split-commodity-string str)) + (if (cadr comm) + comm + (list (car comm) ledger-reconcile-default-commodity))))) + +(provide 'ledger-commodities) + +;;; ledger-commodities.el ends here diff --git a/emacs/elpa/ledger-mode-20240527.2134/ledger-commodities.elc b/emacs/elpa/ledger-mode-20240527.2134/ledger-commodities.elc Binary files differ. diff --git a/emacs/elpa/ledger-mode-20240423.445/ledger-complete.el b/emacs/elpa/ledger-mode-20240527.2134/ledger-complete.el diff --git a/emacs/elpa/ledger-mode-20240423.445/ledger-complete.elc b/emacs/elpa/ledger-mode-20240527.2134/ledger-complete.elc Binary files differ. diff --git a/emacs/elpa/ledger-mode-20240423.445/ledger-context.el b/emacs/elpa/ledger-mode-20240527.2134/ledger-context.el diff --git a/emacs/elpa/ledger-mode-20240423.445/ledger-context.elc b/emacs/elpa/ledger-mode-20240527.2134/ledger-context.elc Binary files differ. diff --git a/emacs/elpa/ledger-mode-20240423.445/ledger-exec.el b/emacs/elpa/ledger-mode-20240527.2134/ledger-exec.el diff --git a/emacs/elpa/ledger-mode-20240423.445/ledger-exec.elc b/emacs/elpa/ledger-mode-20240527.2134/ledger-exec.elc Binary files differ. diff --git a/emacs/elpa/ledger-mode-20240423.445/ledger-flymake.el b/emacs/elpa/ledger-mode-20240527.2134/ledger-flymake.el diff --git a/emacs/elpa/ledger-mode-20240423.445/ledger-flymake.elc b/emacs/elpa/ledger-mode-20240527.2134/ledger-flymake.elc Binary files differ. diff --git a/emacs/elpa/ledger-mode-20240423.445/ledger-fontify.el b/emacs/elpa/ledger-mode-20240527.2134/ledger-fontify.el diff --git a/emacs/elpa/ledger-mode-20240423.445/ledger-fontify.elc b/emacs/elpa/ledger-mode-20240527.2134/ledger-fontify.elc Binary files differ. diff --git a/emacs/elpa/ledger-mode-20240423.445/ledger-fonts.el b/emacs/elpa/ledger-mode-20240527.2134/ledger-fonts.el diff --git a/emacs/elpa/ledger-mode-20240423.445/ledger-fonts.elc b/emacs/elpa/ledger-mode-20240527.2134/ledger-fonts.elc Binary files differ. diff --git a/emacs/elpa/ledger-mode-20240423.445/ledger-init.el b/emacs/elpa/ledger-mode-20240527.2134/ledger-init.el diff --git a/emacs/elpa/ledger-mode-20240423.445/ledger-init.elc b/emacs/elpa/ledger-mode-20240527.2134/ledger-init.elc Binary files differ. diff --git a/emacs/elpa/ledger-mode-20240423.445/ledger-mode-autoloads.el b/emacs/elpa/ledger-mode-20240527.2134/ledger-mode-autoloads.el diff --git a/emacs/elpa/ledger-mode-20240527.2134/ledger-mode-pkg.el b/emacs/elpa/ledger-mode-20240527.2134/ledger-mode-pkg.el @@ -0,0 +1,6 @@ +(define-package "ledger-mode" "20240527.2134" "Helper code for use with the \"ledger\" command-line tool" + '((emacs "25.1")) + :commit "57de7d817296607a9a4721470f64e05c964744da") +;; Local Variables: +;; no-byte-compile: t +;; End: diff --git a/emacs/elpa/ledger-mode-20240423.445/ledger-mode.el b/emacs/elpa/ledger-mode-20240527.2134/ledger-mode.el diff --git a/emacs/elpa/ledger-mode-20240423.445/ledger-mode.elc b/emacs/elpa/ledger-mode-20240527.2134/ledger-mode.elc Binary files differ. diff --git a/emacs/elpa/ledger-mode-20240423.445/ledger-mode.info b/emacs/elpa/ledger-mode-20240527.2134/ledger-mode.info diff --git a/emacs/elpa/ledger-mode-20240423.445/ledger-navigate.el b/emacs/elpa/ledger-mode-20240527.2134/ledger-navigate.el diff --git a/emacs/elpa/ledger-mode-20240423.445/ledger-navigate.elc b/emacs/elpa/ledger-mode-20240527.2134/ledger-navigate.elc Binary files differ. diff --git a/emacs/elpa/ledger-mode-20240423.445/ledger-occur.el b/emacs/elpa/ledger-mode-20240527.2134/ledger-occur.el diff --git a/emacs/elpa/ledger-mode-20240423.445/ledger-occur.elc b/emacs/elpa/ledger-mode-20240527.2134/ledger-occur.elc Binary files differ. diff --git a/emacs/elpa/ledger-mode-20240527.2134/ledger-post.el b/emacs/elpa/ledger-mode-20240527.2134/ledger-post.el @@ -0,0 +1,249 @@ +;;; ledger-post.el --- Helper code for use with the "ledger" command-line tool -*- lexical-binding: t; -*- + +;; Copyright (C) 2003-2016 John Wiegley (johnw AT gnu DOT org) + +;; This file is not part of GNU Emacs. + +;; This 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 2, or (at your option) any later +;; version. +;; +;; This 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 GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +;; MA 02110-1301 USA. + + +;;; Commentary: +;; Utility functions for dealing with postings. + +(require 'ledger-regex) +(require 'ledger-navigate) + +(declare-function calc-renumber-stack "calc" ()) +(declare-function ledger-add-commodity "ledger-commodities" (c1 c2)) +(declare-function ledger-commodity-to-string "ledger-commodities" (c1)) +(declare-function ledger-negate-commodity "ledger-commodities" (c)) +(declare-function ledger-split-commodity-string "ledger-commodities" (str)) +(declare-function ledger-string-to-number "ledger-commodities" (str &optional decimal-comma)) + +;;; Code: + +(defgroup ledger-post nil + "Options for controlling how Ledger-mode deals with postings and completion" + :group 'ledger) + +(defcustom ledger-post-account-alignment-column 4 + "The column Ledger-mode attempts to align accounts to." + :type 'integer + :group 'ledger-post + :safe 'integerp) + +(defcustom ledger-post-amount-alignment-column 52 + "The column Ledger-mode attempts to align amounts to." + :type 'integer + :group 'ledger-post + :safe 'integerp) + +(defcustom ledger-post-amount-alignment-at :end + "Position at which the amount is aligned. + +Can be :end to align on the last number of the amount (can be +followed by unaligned commodity) or :decimal to align at the +decimal separator." + :type '(radio (const :tag "align at the end of amount" :end) + (const :tag "align at the decimal separator" :decimal)) + :group 'ledger-post + :safe (lambda (x) (memq x '(:end :decimal)))) + +(defcustom ledger-post-auto-align t + "When non-nil, realign post amounts when indenting or completing." + :type 'boolean + :group 'ledger-post + :package-version '(ledger-mode . "4.0.0") + :safe 'booleanp) + +(defun ledger-next-amount (&optional end) + "Move point to the next amount, as long as it is not past END. +Return the width of the amount field as an integer and leave +point at beginning of the commodity." + ;;(beginning-of-line) + (let ((case-fold-search nil)) + (when (re-search-forward ledger-amount-regex end t) + (goto-char (match-beginning 0)) + (skip-syntax-forward " ") + (cond + ((eq ledger-post-amount-alignment-at :end) + (- (or (match-end 4) (match-end 3)) (point))) + ((eq ledger-post-amount-alignment-at :decimal) + (- (match-end 3) (point))))))) + +(defun ledger-next-account (&optional end) + "Move to the beginning of the posting, or status marker. +Return the column of the beginning of the account and leave point +at beginning of account. +Looks only as far as END, if supplied, otherwise `point-max'." + (let ((end (or end (point-max)))) + (if (> end (point)) + (when (re-search-forward ledger-account-any-status-regex (1+ end) t) + ;; the 1+ is to make sure we can catch the newline + (if (match-beginning 1) + (goto-char (match-beginning 1)) + (goto-char (match-beginning 2))) + (current-column))))) + +(defun ledger-post-align-xact (pos) + "Align all the posting in the xact at POS." + (interactive "d") + (let ((bounds (ledger-navigate-find-xact-extents pos))) + (ledger-post-align-postings (car bounds) (cadr bounds)))) + +(defun ledger-post-align-postings (beg end) + "Align all accounts and amounts between BEG and END. +The current region is used, or, if no region, the current line." + (interactive "r") + (save-match-data + (save-excursion + (let ((inhibit-modification-hooks t) + ;; Extend region to whole lines + (beg (save-excursion (goto-char beg) (line-beginning-position))) + (end (save-excursion (goto-char end) (move-end-of-line 1) (point-marker)))) + (untabify beg end) + (goto-char beg) + (while (< (point) end) + (when (looking-at-p " ") + ;; fix spaces at beginning of line: + (just-one-space ledger-post-account-alignment-column) + ;; fix spaces before amount if any: + (when (re-search-forward "\t\\| \\| \t" (line-end-position) t) + (goto-char (match-beginning 0)) + (let ((acct-end-column (current-column)) + (amt-width (ledger-next-amount (line-end-position))) + amt-adjust) + (when amt-width + (if (/= 0 (setq amt-adjust (- (if (> (- ledger-post-amount-alignment-column amt-width) + (+ 2 acct-end-column)) + ledger-post-amount-alignment-column ;;we have room + (+ acct-end-column 2 amt-width)) + amt-width + (current-column)))) + (if (> amt-adjust 0) + (insert (make-string amt-adjust ? )) + (delete-char amt-adjust))))))) + (forward-line 1)))))) + +(defun ledger-indent-line () + "Indent the current line." + ;; Ensure indent if the previous line was indented + (let ((indent-level (save-excursion (if (and (zerop (forward-line -1)) + (memq (ledger-thing-at-point) '(transaction posting))) + ledger-post-account-alignment-column + 0)))) + (unless (= (current-indentation) indent-level) + (back-to-indentation) + (delete-horizontal-space t) + (indent-to indent-level))) + (when ledger-post-auto-align + (ledger-post-align-postings (line-beginning-position) (line-end-position)))) + +(defun ledger-post-align-dwim () + "Align all the posting of the current xact or the current region. + +If the point is in a comment, fill the comment paragraph as +regular text." + (interactive) + (cond + ((nth 4 (syntax-ppss)) + (call-interactively 'ledger-post-align-postings) + (fill-paragraph)) + ((use-region-p) (call-interactively 'ledger-post-align-postings)) + (t (call-interactively 'ledger-post-align-xact)))) + +(defun ledger-post-edit-amount () + "Call `calc' and push the amount in the posting to the top of stack, if any. + +In the calc buffer, press y to use the top value in the stack as +the amount and return to ledger." + (interactive) + (beginning-of-line) + (when (re-search-forward ledger-post-line-regexp (line-end-position) t) + (goto-char (match-end ledger-regex-post-line-group-account)) ;; go to the end of the account + ;; determine if there is an amount to edit + (if (re-search-forward ledger-amount-regexp (line-end-position) t) + (let ((val-string (match-string 0))) + (goto-char (match-beginning 0)) + (delete-region (match-beginning 0) (match-end 0)) + (push-mark (point) 'nomsg) + (calc) + ;; edit the amount, first removing thousands separators and converting + ;; decimal commas to calc's input format + (calc-eval (number-to-string (ledger-string-to-number val-string)) 'push) + (calc-renumber-stack)) + ;; make sure there are two spaces after the account name and go to calc + (if (search-backward " " (- (point) 3) t) + (end-of-line) + (insert " ")) + (push-mark (point) 'nomsg) + (calc)))) + +(defun ledger-post-xact-total () + "Return (TOTAL . MISSING-POSITIONS) for the transaction at point. + +TOTAL is a commoditized amount representing the total amount of +the postings in the transaction. + +MISSING-POSITIONS is a list of positions in the buffer where the +transaction do not have an amount specified (such postings do not +contribute to TOTAL). Specifically, the positions are at the end +of the account name on such posting lines. + +Error if the commodities do not match." + (save-excursion + (pcase-let ((`(,begin ,end) (ledger-navigate-find-xact-extents (point)))) + (goto-char begin) + (cl-loop + while (re-search-forward ledger-post-line-regexp end t) + for account-end = (match-end ledger-regex-post-line-group-account) + for amount-string = (when-let ((amount-string (match-string ledger-regex-post-line-group-amount))) + (unless (string-empty-p (string-trim amount-string)) + amount-string)) + if (not amount-string) + collect account-end into missing-positions + else + collect (ledger-split-commodity-string amount-string) into amounts + finally return (cons (if amounts + (cl-reduce #'ledger-add-commodity amounts) + '(0 nil)) + missing-positions))))) + +(defun ledger-post-fill () + "Find a posting with no amount and insert it. + +Even if ledger allows for one missing amount per transaction, you +might want to insert it anyway." + (interactive) + (pcase-let* ((`(,total . ,missing-positions) (ledger-post-xact-total)) + (missing-amount (ledger-negate-commodity total)) + (amounts-balance (< (abs (car missing-amount)) 0.0001))) + (pcase missing-positions + ('() (unless amounts-balance + (user-error "Postings do not balance, but no posting to fill"))) + (`(,missing-pos) + (if amounts-balance + (user-error "Missing amount but amounts balance already") + (goto-char missing-pos) + (insert " " (ledger-commodity-to-string missing-amount)) + (ledger-post-align-xact (point)))) + (_ (user-error "More than one posting with missing amount"))))) + +(provide 'ledger-post) + + + +;;; ledger-post.el ends here diff --git a/emacs/elpa/ledger-mode-20240527.2134/ledger-post.elc b/emacs/elpa/ledger-mode-20240527.2134/ledger-post.elc Binary files differ. diff --git a/emacs/elpa/ledger-mode-20240423.445/ledger-reconcile.el b/emacs/elpa/ledger-mode-20240527.2134/ledger-reconcile.el diff --git a/emacs/elpa/ledger-mode-20240423.445/ledger-reconcile.elc b/emacs/elpa/ledger-mode-20240527.2134/ledger-reconcile.elc Binary files differ. diff --git a/emacs/elpa/ledger-mode-20240423.445/ledger-regex.el b/emacs/elpa/ledger-mode-20240527.2134/ledger-regex.el diff --git a/emacs/elpa/ledger-mode-20240423.445/ledger-regex.elc b/emacs/elpa/ledger-mode-20240527.2134/ledger-regex.elc Binary files differ. diff --git a/emacs/elpa/ledger-mode-20240423.445/ledger-report.el b/emacs/elpa/ledger-mode-20240527.2134/ledger-report.el diff --git a/emacs/elpa/ledger-mode-20240423.445/ledger-report.elc b/emacs/elpa/ledger-mode-20240527.2134/ledger-report.elc Binary files differ. diff --git a/emacs/elpa/ledger-mode-20240423.445/ledger-schedule.el b/emacs/elpa/ledger-mode-20240527.2134/ledger-schedule.el diff --git a/emacs/elpa/ledger-mode-20240423.445/ledger-schedule.elc b/emacs/elpa/ledger-mode-20240527.2134/ledger-schedule.elc Binary files differ. diff --git a/emacs/elpa/ledger-mode-20240423.445/ledger-sort.el b/emacs/elpa/ledger-mode-20240527.2134/ledger-sort.el diff --git a/emacs/elpa/ledger-mode-20240423.445/ledger-sort.elc b/emacs/elpa/ledger-mode-20240527.2134/ledger-sort.elc Binary files differ. diff --git a/emacs/elpa/ledger-mode-20240423.445/ledger-state.el b/emacs/elpa/ledger-mode-20240527.2134/ledger-state.el diff --git a/emacs/elpa/ledger-mode-20240423.445/ledger-state.elc b/emacs/elpa/ledger-mode-20240527.2134/ledger-state.elc Binary files differ. diff --git a/emacs/elpa/ledger-mode-20240423.445/ledger-test.el b/emacs/elpa/ledger-mode-20240527.2134/ledger-test.el diff --git a/emacs/elpa/ledger-mode-20240423.445/ledger-test.elc b/emacs/elpa/ledger-mode-20240527.2134/ledger-test.elc Binary files differ. diff --git a/emacs/elpa/ledger-mode-20240423.445/ledger-texi.el b/emacs/elpa/ledger-mode-20240527.2134/ledger-texi.el diff --git a/emacs/elpa/ledger-mode-20240423.445/ledger-texi.elc b/emacs/elpa/ledger-mode-20240527.2134/ledger-texi.elc Binary files differ. diff --git a/emacs/elpa/ledger-mode-20240423.445/ledger-xact.el b/emacs/elpa/ledger-mode-20240527.2134/ledger-xact.el diff --git a/emacs/elpa/ledger-mode-20240423.445/ledger-xact.elc b/emacs/elpa/ledger-mode-20240527.2134/ledger-xact.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-csharp.el b/emacs/elpa/lsp-mode-20240514.1430/lsp-csharp.el @@ -1,467 +0,0 @@ -;;; lsp-csharp.el --- description -*- lexical-binding: t; -*- - -;; Copyright (C) 2019 Jostein Kjønigsen, Saulius Menkevicius - -;; Author: Saulius Menkevicius <saulius.menkevicius@fastmail.com> -;; Keywords: - -;; 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 <https://www.gnu.org/licenses/>. - -;;; Commentary: - -;; lsp-csharp client - -;;; Code: - -(require 'lsp-mode) -(require 'gnutls) -(require 'f) - -(defgroup lsp-csharp nil - "LSP support for C#, using the Omnisharp Language Server. -Version 1.34.3 minimum is required." - :group 'lsp-mode - :link '(url-link "https://github.com/OmniSharp/omnisharp-roslyn")) - -(defgroup lsp-csharp-omnisharp nil - "LSP support for C#, using the Omnisharp Language Server. -Version 1.34.3 minimum is required." - :group 'lsp-mode - :link '(url-link "https://github.com/OmniSharp/omnisharp-roslyn") - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-csharp-server-install-dir - (f-join lsp-server-install-dir "omnisharp-roslyn/") - "Installation directory for OmniSharp Roslyn server." - :group 'lsp-csharp-omnisharp - :type 'directory) - -(defcustom lsp-csharp-server-path - nil - "The path to the OmniSharp Roslyn language-server binary. -Set this if you have the binary installed or have it built yourself." - :group 'lsp-csharp-omnisharp - :type '(string :tag "Single string value or nil")) - -(defcustom lsp-csharp-test-run-buffer-name - "*lsp-csharp test run*" - "The name of buffer used for outputting lsp-csharp test run results." - :group 'lsp-csharp-omnisharp - :type 'string) - -(defcustom lsp-csharp-solution-file - nil - "Solution to load when starting the server. -Usually this is to be set in your .dir-locals.el on the project root directory." - :group 'lsp-csharp-omnisharp - :type 'string) - -(defcustom lsp-csharp-omnisharp-roslyn-download-url - (concat "https://github.com/omnisharp/omnisharp-roslyn/releases/latest/download/" - (cond ((eq system-type 'windows-nt) - ; On Windows we're trying to avoid a crash starting 64bit .NET PE binaries in - ; Emacs by using x86 version of omnisharp-roslyn on older (<= 26.4) versions - ; of Emacs. See https://lists.nongnu.org/archive/html/bug-gnu-emacs/2017-06/msg00893.html" - (if (and (string-match "^x86_64-.*" system-configuration) - (version<= "26.4" emacs-version)) - "omnisharp-win-x64.zip" - "omnisharp-win-x86.zip")) - - ((eq system-type 'darwin) - (if (string-match "aarch64-.*" system-configuration) - "omnisharp-osx-arm64-net6.0.zip" - "omnisharp-osx-x64-net6.0.zip")) - - ((and (eq system-type 'gnu/linux) - (or (eq (string-match "^x86_64" system-configuration) 0) - (eq (string-match "^i[3-6]86" system-configuration) 0))) - "omnisharp-linux-x64-net6.0.zip") - - (t "omnisharp-mono.zip"))) - "Automatic download url for omnisharp-roslyn." - :group 'lsp-csharp-omnisharp - :type 'string) - -(defcustom lsp-csharp-omnisharp-roslyn-store-path - (f-join lsp-csharp-server-install-dir "latest" "omnisharp-roslyn.zip") - "The path where omnisharp-roslyn .zip archive will be stored." - :group 'lsp-csharp-omnisharp - :type 'file) - -(defcustom lsp-csharp-omnisharp-roslyn-binary-path - (f-join lsp-csharp-server-install-dir "latest" (if (eq system-type 'windows-nt) - "OmniSharp.exe" - "OmniSharp")) - "The path where omnisharp-roslyn binary after will be stored." - :group 'lsp-csharp-omnisharp - :type 'file) - -(defcustom lsp-csharp-omnisharp-roslyn-server-dir - (f-join lsp-csharp-server-install-dir "latest" "omnisharp-roslyn") - "The path where omnisharp-roslyn .zip archive will be extracted." - :group 'lsp-csharp-omnisharp - :type 'file) - -(lsp-dependency - 'omnisharp-roslyn - `(:download :url lsp-csharp-omnisharp-roslyn-download-url - :decompress :zip - :store-path lsp-csharp-omnisharp-roslyn-store-path - :binary-path lsp-csharp-omnisharp-roslyn-binary-path - :set-executable? t) - '(:system "OmniSharp")) - -(defun lsp-csharp--omnisharp-download-server (_client callback error-callback _update?) - "Download zip package for omnisharp-roslyn and install it. -Will invoke CALLBACK on success, ERROR-CALLBACK on error." - (lsp-package-ensure 'omnisharp-roslyn callback error-callback)) - -(defun lsp-csharp--language-server-path () - "Resolve path to use to start the server." - (let ((executable-name (if (eq system-type 'windows-nt) - "OmniSharp.exe" - "OmniSharp"))) - (or (and lsp-csharp-server-path - (executable-find lsp-csharp-server-path)) - (executable-find executable-name) - (lsp-package-path 'omnisharp-roslyn)))) - -(defun lsp-csharp-open-project-file () - "Open corresponding project file (.csproj) for the current file." - (interactive) - (-let* ((project-info-req (lsp-make-omnisharp-project-information-request :file-name (buffer-file-name))) - (project-info (lsp-request "o#/project" project-info-req)) - ((&omnisharp:ProjectInformation :ms-build-project) project-info) - ((&omnisharp:MsBuildProject :path) ms-build-project)) - (find-file path))) - -(defun lsp-csharp--get-buffer-code-elements () - "Retrieve code structure by calling into the /v2/codestructure endpoint. -Returns :elements from omnisharp:CodeStructureResponse." - (-let* ((code-structure (lsp-request "o#/v2/codestructure" - (lsp-make-omnisharp-code-structure-request :file-name (buffer-file-name)))) - ((&omnisharp:CodeStructureResponse :elements) code-structure)) - elements)) - -(defun lsp-csharp--inspect-code-elements-recursively (fn elements) - "Invoke FN for every omnisharp:CodeElement found recursively in ELEMENTS." - (seq-each - (lambda (el) - (funcall fn el) - (-let (((&omnisharp:CodeElement :children) el)) - (lsp-csharp--inspect-code-elements-recursively fn children))) - elements)) - -(defun lsp-csharp--collect-code-elements-recursively (predicate elements) - "Flatten the omnisharp:CodeElement tree in ELEMENTS matching PREDICATE." - (let ((results nil)) - (lsp-csharp--inspect-code-elements-recursively (lambda (el) - (when (funcall predicate el) - (setq results (cons el results)))) - elements) - results)) - -(lsp-defun lsp-csharp--l-c-within-range (l c (&omnisharp:Range :start :end)) - "Determine if L (line) and C (column) are within RANGE." - (-let* (((&omnisharp:Point :line start-l :column start-c) start) - ((&omnisharp:Point :line end-l :column end-c) end)) - (or (and (= l start-l) (>= c start-c) (or (> end-l start-l) (<= c end-c))) - (and (> l start-l) (< l end-l)) - (and (= l end-l) (<= c end-c))))) - -(defun lsp-csharp--code-element-stack-on-l-c (l c elements) - "Return omnisharp:CodeElement stack at L (line) and C (column) in ELEMENTS tree." - (when-let ((matching-element (seq-find (lambda (el) - (-when-let* (((&omnisharp:CodeElement :ranges) el) - ((&omnisharp:RangeList :full?) ranges)) - (lsp-csharp--l-c-within-range l c full?))) - elements))) - (-let (((&omnisharp:CodeElement :children) matching-element)) - (cons matching-element (lsp-csharp--code-element-stack-on-l-c l c children))))) - -(defun lsp-csharp--code-element-stack-at-point () - "Return omnisharp:CodeElement stack at point as a list." - (let ((pos-line (plist-get (lsp--cur-position) :line)) - (pos-col (plist-get (lsp--cur-position) :character))) - (lsp-csharp--code-element-stack-on-l-c pos-line - pos-col - (lsp-csharp--get-buffer-code-elements)))) - -(lsp-defun lsp-csharp--code-element-test-method-p (element) - "Return test method name and test framework for a given ELEMENT." - (when element - (-when-let* (((&omnisharp:CodeElement :properties) element) - ((&omnisharp:CodeElementProperties :test-method-name? :test-framework?) properties)) - (list test-method-name? test-framework?)))) - -(defun lsp-csharp--reset-test-buffer (present-buffer) - "Create new or reuse an existing test result output buffer. -PRESENT-BUFFER will make the buffer be presented to the user." - (with-current-buffer (get-buffer-create lsp-csharp-test-run-buffer-name) - (compilation-mode) - (read-only-mode) - (let ((inhibit-read-only t)) - (erase-buffer))) - - (when present-buffer - (display-buffer lsp-csharp-test-run-buffer-name))) - -(defun lsp-csharp--start-tests (test-method-framework test-method-names) - "Run test(s) identified by TEST-METHOD-NAMES using TEST-METHOD-FRAMEWORK." - (if (and test-method-framework test-method-names) - (let ((request-message (lsp-make-omnisharp-run-tests-in-class-request - :file-name (buffer-file-name) - :test-frameworkname test-method-framework - :method-names (vconcat test-method-names)))) - (lsp-csharp--reset-test-buffer t) - (lsp-session-set-metadata "last-test-method-framework" test-method-framework) - (lsp-session-set-metadata "last-test-method-names" test-method-names) - (lsp-request-async "o#/v2/runtestsinclass" - request-message - (-lambda ((&omnisharp:RunTestResponse)) - (message "lsp-csharp: Test run has started")))) - (message "lsp-csharp: No test methods to run"))) - -(defun lsp-csharp--test-message (message) - "Emit a MESSAGE to lsp-csharp test run buffer." - (when-let ((existing-buffer (get-buffer lsp-csharp-test-run-buffer-name)) - (inhibit-read-only t)) - (with-current-buffer existing-buffer - (save-excursion - (goto-char (point-max)) - (insert message "\n"))))) - -(defun lsp-csharp-run-test-at-point () - "Start test run at current point (if any)." - (interactive) - (let* ((stack (lsp-csharp--code-element-stack-at-point)) - (element-on-point (car (last stack))) - (test-method (lsp-csharp--code-element-test-method-p element-on-point)) - (test-method-name (car test-method)) - (test-method-framework (car (cdr test-method)))) - (lsp-csharp--start-tests test-method-framework (list test-method-name)))) - -(defun lsp-csharp-run-all-tests-in-buffer () - "Run all test methods in the current buffer." - (interactive) - (let* ((elements (lsp-csharp--get-buffer-code-elements)) - (test-methods (lsp-csharp--collect-code-elements-recursively 'lsp-csharp--code-element-test-method-p elements)) - (test-method-framework (car (cdr (lsp-csharp--code-element-test-method-p (car test-methods))))) - (test-method-names (mapcar (lambda (method) - (car (lsp-csharp--code-element-test-method-p method))) - test-methods))) - (lsp-csharp--start-tests test-method-framework test-method-names))) - -(defun lsp-csharp-run-test-in-buffer () - "Run selected test in current buffer." - (interactive) - (when-let* ((elements (lsp-csharp--get-buffer-code-elements)) - (test-methods (lsp-csharp--collect-code-elements-recursively 'lsp-csharp--code-element-test-method-p elements)) - (test-method-framework (car (cdr (lsp-csharp--code-element-test-method-p (car test-methods))))) - (test-method-names (mapcar (lambda (method) - (car (lsp-csharp--code-element-test-method-p method))) - test-methods)) - (selected-test-method-name (lsp--completing-read "Select test:" test-method-names 'identity))) - (lsp-csharp--start-tests test-method-framework (list selected-test-method-name)))) - -(defun lsp-csharp-run-last-tests () - "Re-run test(s) that were run last time." - (interactive) - (if-let ((last-test-method-framework (lsp-session-get-metadata "last-test-method-framework")) - (last-test-method-names (lsp-session-get-metadata "last-test-method-names"))) - (lsp-csharp--start-tests last-test-method-framework last-test-method-names) - (message "lsp-csharp: No test method(s) found to be ran previously on this workspace"))) - -(lsp-defun lsp-csharp--handle-os-error (_workspace (&omnisharp:ErrorMessage :file-name :text)) - "Handle the `o#/error' (interop) notification displaying a message." - (lsp-warn "%s: %s" file-name text)) - -(lsp-defun lsp-csharp--handle-os-testmessage (_workspace (&omnisharp:TestMessageEvent :message)) - "Handle the `o#/testmessage and display test message on test output buffer." - (lsp-csharp--test-message message)) - -(lsp-defun lsp-csharp--handle-os-testcompleted (_workspace (&omnisharp:DotNetTestResult - :method-name - :outcome - :error-message - :error-stack-trace - :standard-output - :standard-error)) - "Handle the `o#/testcompleted' message from the server. - -Will display the results of the test on the lsp-csharp test output buffer." - (let ((passed (string-equal "passed" outcome))) - (lsp-csharp--test-message - (format "[%s] %s " - (propertize (upcase outcome) 'font-lock-face (if passed 'success 'error)) - method-name)) - - (unless passed - (lsp-csharp--test-message error-message) - - (when error-stack-trace - (lsp-csharp--test-message error-stack-trace)) - - (unless (seq-empty-p standard-output) - (lsp-csharp--test-message "STANDARD OUTPUT:") - (seq-doseq (stdout-line standard-output) - (lsp-csharp--test-message stdout-line))) - - (unless (seq-empty-p standard-error) - (lsp-csharp--test-message "STANDARD ERROR:") - (seq-doseq (stderr-line standard-error) - (lsp-csharp--test-message stderr-line)))))) - -(lsp-defun lsp-csharp--action-client-find-references ((&Command :arguments?)) - "Read first argument from ACTION as Location and display xrefs for that location -using the `textDocument/references' request." - (-if-let* (((&Location :uri :range) (lsp-seq-first arguments?)) - ((&Range :start range-start) range) - (find-refs-params (append (lsp--text-document-position-params (list :uri uri) range-start) - (list :context (list :includeDeclaration json-false)))) - (locations-found (lsp-request "textDocument/references" find-refs-params))) - (lsp-show-xrefs (lsp--locations-to-xref-items locations-found) nil t) - (message "No references found"))) - -(lsp-register-client - (make-lsp-client :new-connection - (lsp-stdio-connection - #'(lambda () - (append - (list (lsp-csharp--language-server-path) "-lsp") - (when lsp-csharp-solution-file - (list "-s" (expand-file-name lsp-csharp-solution-file))))) - #'(lambda () - (when-let ((binary (lsp-csharp--language-server-path))) - (f-exists? binary)))) - :activation-fn (lsp-activate-on "csharp") - :server-id 'omnisharp - :priority -1 - :action-handlers (ht ("omnisharp/client/findReferences" 'lsp-csharp--action-client-find-references)) - :notification-handlers (ht ("o#/projectadded" 'ignore) - ("o#/projectchanged" 'ignore) - ("o#/projectremoved" 'ignore) - ("o#/packagerestorestarted" 'ignore) - ("o#/msbuildprojectdiagnostics" 'ignore) - ("o#/packagerestorefinished" 'ignore) - ("o#/unresolveddependencies" 'ignore) - ("o#/error" 'lsp-csharp--handle-os-error) - ("o#/testmessage" 'lsp-csharp--handle-os-testmessage) - ("o#/testcompleted" 'lsp-csharp--handle-os-testcompleted) - ("o#/projectconfiguration" 'ignore) - ("o#/projectdiagnosticstatus" 'ignore) - ("o#/backgrounddiagnosticstatus" 'ignore)) - :download-server-fn #'lsp-csharp--omnisharp-download-server)) - -;; -;; Alternative "csharp-ls" language server support -;; see https://github.com/razzmatazz/csharp-language-server -;; -(lsp-defun lsp-csharp--cls-metadata-uri-handler (uri) - "Handle `csharp:/(metadata)' uri from csharp-ls server. - -`csharp/metadata' request is issued to retrieve metadata from the server. -A cache file is created on project root dir that stores this metadata and -filename is returned so lsp-mode can display this file." - - (-when-let* ((metadata-req (lsp-make-csharp-ls-c-sharp-metadata - :text-document (lsp-make-text-document-identifier :uri uri))) - (metadata (lsp-request "csharp/metadata" metadata-req)) - ((&csharp-ls:CSharpMetadataResponse :project-name - :assembly-name - :symbol-name - :source) metadata) - (filename (f-join ".cache" - "lsp-csharp" - "metadata" - "projects" project-name - "assemblies" assembly-name - (concat symbol-name ".cs"))) - (file-location (expand-file-name filename (lsp-workspace-root))) - (metadata-file-location (concat file-location ".metadata-uri")) - (path (f-dirname file-location))) - - (unless (file-exists-p file-location) - (unless (file-directory-p path) - (make-directory path t)) - - (with-temp-file metadata-file-location - (insert uri)) - - (with-temp-file file-location - (insert source))) - - file-location)) - -(defun lsp-csharp--cls-before-file-open (_workspace) - "Set `lsp-buffer-uri' variable after C# file is open from *.metadata-uri file." - - (let ((metadata-file-name (concat buffer-file-name ".metadata-uri"))) - (setq-local lsp-buffer-uri - (when (file-exists-p metadata-file-name) - (with-temp-buffer (insert-file-contents metadata-file-name) - (buffer-string)))))) - -(defun lsp-csharp--cls-make-launch-cmd () - "Return command line to invoke csharp-ls." - - ;; emacs-28.1 on macOS has an issue - ;; that it launches processes using posix_spawn but does not reset sigmask properly - ;; thus causing dotnet runtime to lockup awaiting a SIGCHLD signal that never comes - ;; from subprocesses that quit - ;; - ;; as a workaround we will wrap csharp-ls invocation in "/bin/ksh -c" on macos - ;; so it launches with proper sigmask - ;; - ;; see https://lists.gnu.org/archive/html/emacs-devel/2022-02/msg00461.html - - (let ((startup-wrapper (cond ((and (eq 'darwin system-type) - (version= "28.1" emacs-version)) - (list "/bin/ksh" "-c")) - - (t nil))) - - (csharp-ls-exec (or (executable-find "csharp-ls") - (f-join (or (getenv "USERPROFILE") (getenv "HOME")) - ".dotnet" "tools" "csharp-ls"))) - - (solution-file-params (when lsp-csharp-solution-file - (list "-s" lsp-csharp-solution-file)))) - (append startup-wrapper - (list csharp-ls-exec) - solution-file-params))) - -(defun lsp-csharp--cls-download-server (_client callback error-callback update?) - "Install/update csharp-ls language server using `dotnet tool'. - -Will invoke CALLBACK or ERROR-CALLBACK based on result. -Will update if UPDATE? is t" - (lsp-async-start-process - callback - error-callback - "dotnet" "tool" (if update? "update" "install") "-g" "csharp-ls")) - -(lsp-register-client - (make-lsp-client :new-connection (lsp-stdio-connection #'lsp-csharp--cls-make-launch-cmd) - :priority -2 - :server-id 'csharp-ls - :activation-fn (lsp-activate-on "csharp") - :before-file-open-fn #'lsp-csharp--cls-before-file-open - :uri-handlers (ht ("csharp" #'lsp-csharp--cls-metadata-uri-handler)) - :download-server-fn #'lsp-csharp--cls-download-server)) - -(lsp-consistency-check lsp-csharp) - -(provide 'lsp-csharp) -;;; lsp-csharp.el ends here diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-csharp.elc b/emacs/elpa/lsp-mode-20240514.1430/lsp-csharp.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-groovy.el b/emacs/elpa/lsp-mode-20240514.1430/lsp-groovy.el @@ -1,66 +0,0 @@ -;;; lsp-groovy.el --- description -*- lexical-binding: t; -*- - -;; Copyright (C) 2020 emacs-lsp maintainers - -;; Author: emacs-lsp maintainers -;; Keywords: lsp, groovy - -;; 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 <https://www.gnu.org/licenses/>. - -;;; Commentary: - -;; LSP Clients for the Groovy Programming Language. - -;;; Code: - -(require 'lsp-mode) -(require 'f) - -(defgroup lsp-groovy nil - "LSP support for Groovy, using groovy-language-server." - :group 'lsp-mode - :link '(url-link "https://github.com/prominic/groovy-language-server")) - -(defcustom lsp-groovy-server-file (f-join lsp-server-install-dir "groovy-language-server-all.jar") - "JAR file path for groovy-language-server-all.jar." - :group 'lsp-groovy - :risky t - :type 'file) - -(defun lsp-groovy--lsp-command () - "Generate LSP startup command." - `("java" "-jar" ,(expand-file-name lsp-groovy-server-file))) - -(defcustom lsp-groovy-classpath ["/usr/local/opt/groovy/libexec/lib"] - "List of paths to Groovy JARs." - :group 'lsp-groovy - :risky t - :type 'lsp-string-vector) - -(lsp-register-custom-settings - '(("groovy.classpath" lsp-groovy-classpath))) - -(lsp-register-client - (make-lsp-client :new-connection (lsp-stdio-connection 'lsp-groovy--lsp-command) - :major-modes '(groovy-mode) - :priority -1 - :server-id 'groovy-ls - :initialized-fn (lambda (workspace) - (with-lsp-workspace workspace - (lsp--set-configuration (lsp-configuration-section "groovy")))))) - -(lsp-consistency-check lsp-groovy) - -(provide 'lsp-groovy) -;;; lsp-groovy.el ends here diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-groovy.elc b/emacs/elpa/lsp-mode-20240514.1430/lsp-groovy.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-javascript.el b/emacs/elpa/lsp-mode-20240514.1430/lsp-javascript.el @@ -1,1037 +0,0 @@ -;;; lsp-javascript.el --- description -*- lexical-binding: t; -*- - -;; Copyright (C) 2020 emacs-lsp maintainers - -;; Author: emacs-lsp maintainers -;; Keywords: lsp, - -;; 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 <https://www.gnu.org/licenses/>. - -;;; Commentary: - -;; LSP Clients for the JavaScript and TypeScript Programming Languages. - -;;; Code: - -(require 'lsp-mode) - -(lsp-dependency 'javascript-typescript-langserver - '(:system "javascript-typescript-stdio") - '(:npm :package "javascript-typescript-langserver" - :path "javascript-typescript-stdio")) - -(defgroup lsp-typescript-javascript nil - "Support for TypeScript/JavaScript, using Sourcegraph's JavaScript/TypeScript language server." - :group 'lsp-mode - :link '(url-link "https://github.com/sourcegraph/javascript-typescript-langserver")) - -;; Original name can be confused with initializationOptions. Preferences is just one option of initializationOptions. -(define-obsolete-variable-alias - 'lsp-clients-typescript-init-opts - 'lsp-clients-typescript-preferences - "lsp-mode 9.0.0") - -(defcustom lsp-clients-typescript-javascript-server-args '() - "Extra arguments for the typescript-language-server language server." - :group 'lsp-typescript-javascript - :risky t - :type '(repeat string)) - -(defun lsp-typescript-javascript-tsx-jsx-activate-p (filename &optional _) - "Check if the js-ts lsp server should be enabled based on FILENAME." - (or (string-match-p "\\.[cm]js\\|\\.[jt]sx?\\'" filename) - (and (derived-mode-p 'js-mode 'js-ts-mode 'typescript-mode 'typescript-ts-mode) - (not (derived-mode-p 'json-mode))))) - -;; Unmaintained sourcegraph server -(lsp-register-client - (make-lsp-client :new-connection (lsp-stdio-connection (lambda () - (cons (lsp-package-path 'javascript-typescript-langserver) - lsp-clients-typescript-javascript-server-args))) - :activation-fn 'lsp-typescript-javascript-tsx-jsx-activate-p - :priority -3 - :completion-in-comments? t - :server-id 'jsts-ls - :download-server-fn (lambda (_client callback error-callback _update?) - (lsp-package-ensure - 'javascript-typescript-langserver - callback - error-callback)) - :initialized-fn (lambda (_workspace) - (warn (concat "The javascript-typescript-langserver (jsts-ls) is unmaintained; " - "it is recommended to use ts-ls or deno-ls instead."))))) - -(defgroup lsp-typescript nil - "LSP support for TypeScript, using Theia/Typefox's TypeScript Language Server." - :group 'lsp-mode - :link '(url-link "https://github.com/theia-ide/typescript-language-server")) - -(defcustom lsp-clients-typescript-tls-path "typescript-language-server" - "Path to the typescript-language-server binary." - :group 'lsp-typescript - :risky t - :type 'string) - -(defcustom lsp-clients-typescript-server-args '("--stdio") - "Extra arguments for the typescript-language-server language server." - :group 'lsp-typescript - :risky t - :type '(repeat string)) - -(defcustom lsp-clients-typescript-disable-automatic-typing-acquisition nil - "Disable tsserver from automatically fetching missing type definitions. -\(@types packages) for external modules." - :group 'lsp-typescript - :type 'boolean) - -(defcustom lsp-clients-typescript-log-verbosity "info" - "The verbosity level of the information printed in the log by tsserver." - :group 'lsp-typescript - :type '(choice - (const "off") - (const "terse") - (const "normal") - (const "requesttime") - (const "verbose"))) - -(defcustom lsp-clients-typescript-max-ts-server-memory nil - "The maximum size of the V8's old memory section in megabytes. -\(for example 4096 means 4GB). The default value is dynamically configured -by Node so can differ per system. Increase for very big projects that -exceed allowed memory usage." - :group 'lsp-typescript - :type 'integer) - -(defcustom lsp-clients-typescript-npm-location nil - "Specifies the path to the NPM exec used for Automatic Type Acquisition." - :group 'lsp-typescript - :type 'string) - -(defcustom lsp-clients-typescript-prefer-use-project-ts-server nil - "When set, prefers using the tsserver.js from your project. This -can allow loading plugins configured in your tsconfig.json." - :group 'lsp-typescript - :type 'boolean) - -(defcustom lsp-clients-typescript-plugins (vector) - "The list of plugins to load. -It should be a vector of plist with keys `:location' and `:name' -where `:name' is the name of the package and `:location' is the -directory containing the package. Example: -\(vector - \(list :name \"@vsintellicode/typescript-intellicode-plugin\" - :location \"<path>.vscode/extensions/visualstudioexptteam. - vscodeintellicode-1.1.9/\"))" - :group 'lsp-typescript - :type '(restricted-sexp :tag "Vector" - :match-alternatives - (lambda (xs) - (and (vectorp xs) (seq-every-p - (-lambda ((&plist :name :location)) - (and name location)) - xs))))) - -(defcustom lsp-clients-typescript-preferences nil - "Preferences passed to the Typescript (tsserver) process. -See https://github.com/typescript-language-server/typescript-language-server#initializationoptions for the list of preferences available in the latest version of TypeScript." - :group 'lsp-typescript - :type 'plist) - -(defcustom lsp-clients-typescript-tsserver nil - "Options related to the tsserver process. See below for more info. -See https://github.com/typescript-language-server/typescript-language-server#initializationoptions for the list of tsserver available in the latest version of TypeScript." - :group 'lsp-typescript - :type 'plist) - -(defcustom lsp-typescript-tsdk nil - "Specifies the folder path containing tsserver and lib*.d.ts files to use." - :type '(repeat string) - :group 'lsp-vetur - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-typescript-disable-automatic-type-acquisition nil - "Disables automatic type acquisition. -Automatic type acquisition fetches `@types` packages from npm to improve -IntelliSense for external libraries." - :type 'boolean - :group 'lsp-vetur - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-typescript-npm nil - "Specifies the path to the NPM exec used for Automatic Type Acquisition. -Requires using TypeScript 2.3.4 or newer in the -workspace." - :type '(repeat string) - :group 'lsp-vetur - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-typescript-check-npm-is-installed t - "Check if NPM is installed for Automatic Type Acquisition." - :type 'boolean - :group 'lsp-vetur - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-javascript-references-code-lens-enabled nil - "Enable/disable references CodeLens in JavaScript files." - :type 'boolean - :group 'lsp-vetur - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-typescript-references-code-lens-enabled nil - "Enable/disable references CodeLens in TypeScript files." - :type 'boolean - :group 'lsp-vetur - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-typescript-implementations-code-lens-enabled nil - "Enable/disable implementations CodeLens. -This CodeLens shows the implementers of an interface." - :type 'boolean - :group 'lsp-vetur - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-typescript-tsserver-log "off" - "Enables logging of the TS server to a file. -This log can be used to diagnose TS Server issues. The log may contain file -paths, source code, and other potentially sensitive information -from your project." - :type '(choice - (const "off") - (const "terse") - (const "normal") - (const "verbose")) - :group 'lsp-vetur - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-typescript-tsserver-plugin-paths nil - "Additional paths to discover Typescript Language Service plugins. -Requires using TypeScript 2.3.0 or newer in the -workspace." - :type '(repeat string) - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-typescript-tsserver-trace "off" - "Enables tracing of messages sent to the TS server. -This trace can be used to diagnose TS Server issues. The trace may contain -file paths, source code, and other potentially sensitive -information from your project." - :type '(choice - (const "off") - (const "messages") - (const "verbose")) - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-javascript-suggest-complete-function-calls nil - "Complete functions with their parameter signature." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-typescript-suggest-complete-function-calls nil - "Complete functions with their parameter signature." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-typescript-report-style-checks-as-warnings t - "Report style checks as warnings." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-typescript-validate-enable t - "Enable/disable TypeScript validation." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-typescript-format-enable t - "Enable/disable default TypeScript formatter." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-typescript-format-insert-space-after-comma-delimiter t - "Defines space handling after a comma delimiter." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-typescript-format-insert-space-after-constructor nil - "Defines space handling after the constructor keyword. -Requires using TypeScript 2.3.0 or newer in the workspace." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-typescript-format-insert-space-after-semicolon-in-for-statements t - "Defines space handling after a semicolon in a for statement." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-typescript-format-insert-space-before-and-after-binary-operators t - "Defines space handling after a binary operator." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-typescript-format-insert-space-after-keywords-in-control-flow-statements t - "Defines space handling after keywords in a control flow statement." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-typescript-format-insert-space-after-function-keyword-for-anonymous-functions t - "Defines space handling after function keyword for anonymous functions." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-typescript-format-insert-space-before-function-parenthesis nil - "Defines space handling before function argument parentheses." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-typescript-format-insert-space-after-opening-and-before-closing-empty-braces nil - "Defines space handling after opening/before closing empty braces." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-typescript-format-insert-space-after-opening-and-before-closing-nonempty-parenthesis nil - "Defines space handling after opening/before closing non-empty parenthesis." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-typescript-format-insert-space-after-opening-and-before-closing-nonempty-brackets nil - "Defines space handling after opening and before closing non-empty brackets." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-typescript-format-insert-space-after-opening-and-before-closing-nonempty-braces t - "Defines space handling after opening and before closing non-empty braces. -Requires using TypeScript 2.3.0 or newer in the workspace." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-typescript-format-insert-space-after-opening-and-before-closing-template-string-braces nil - "Defines space handling after opening/before closing template string braces." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-typescript-format-insert-space-after-opening-and-before-closing-jsx-expression-braces nil - "Defines space handling after opening/before closing JSX expression braces." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-typescript-format-insert-space-after-type-assertion nil - "Defines space handling after type assertions in TypeScript. -Requires using TypeScript 2.4 or newer in the workspace." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-typescript-format-place-open-brace-on-new-line-for-functions nil - "Defines whether an open brace is put onto a new line for functions or not." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-typescript-format-place-open-brace-on-new-line-for-control-blocks nil - "Defines whether an open brace is put onto a newline for control blocks." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-javascript-validate-enable t - "Enable/disable JavaScript validation." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-javascript-format-enable t - "Enable/disable default JavaScript formatter." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-javascript-format-insert-space-after-comma-delimiter t - "Defines space handling after a comma delimiter." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-javascript-format-insert-space-after-constructor nil - "Defines space handling after the constructor keyword. -Requires using TypeScript 2.3.0 or newer in the workspace." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-javascript-format-insert-space-after-semicolon-in-for-statements t - "Defines space handling after a semicolon in a for statement." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-javascript-format-insert-space-before-and-after-binary-operators t - "Defines space handling after a binary operator." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-javascript-format-insert-space-after-keywords-in-control-flow-statements t - "Defines space handling after keywords in a control flow statement." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-javascript-format-insert-space-after-function-keyword-for-anonymous-functions t - "Defines space handling after function keyword for anonymous functions." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-javascript-format-insert-space-before-function-parenthesis nil - "Defines space handling before function argument parentheses." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-javascript-format-insert-space-after-opening-and-before-closing-empty-braces nil - "Defines space handling after opening/before closing empty braces." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-javascript-format-insert-space-after-opening-and-before-closing-nonempty-parenthesis nil - "Defines space handling after opening and before closing non-empty parenthesis." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-javascript-format-insert-space-after-opening-and-before-closing-nonempty-brackets nil - "Defines space handling after opening and before closing non-empty brackets." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-javascript-format-insert-space-after-opening-and-before-closing-nonempty-braces t - "Defines space handling after opening and before closing non-empty braces. -Requires using TypeScript 2.3.0 or newer in the workspace." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-javascript-format-insert-space-after-opening-and-before-closing-template-string-braces nil - "Defines space handling after opening/before closing template string braces." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-javascript-format-insert-space-after-opening-and-before-closing-jsx-expression-braces nil - "Defines space handling after opening/before closing JSX expression braces." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-javascript-format-place-open-brace-on-new-line-for-functions nil - "Defines whether an open brace is put onto a new line for functions or not." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-javascript-format-place-open-brace-on-new-line-for-control-blocks nil - "Defines whether an open brace is put onto a new line for control blocks or not." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-javascript-implicit-project-config-check-js nil - "Enable/disable semantic checking of JavaScript files. -Existing jsconfig.json or tsconfig.json files override this setting. -Requires using TypeScript 2.3.1 or newer in the workspace." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-javascript-implicit-project-config-experimental-decorators nil - nil - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-javascript-suggest-names t - "Enable/disable including unique names from the file in JavaScript suggestions." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-typescript-tsc-auto-detect "on" - "Controls auto detection of tsc tasks." - :type '(choice - (const "on") - (const "off") - (const "build") - (const "watch")) - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-javascript-suggest-paths t - "Enable/disable suggestions for paths in import statements and require calls." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-typescript-suggest-paths t - "Enable/disable suggestions for paths in import statements and require calls." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-javascript-suggest-auto-imports t - "Enable/disable auto import suggestions. -Requires using TypeScript 2.6.1 or newer in the workspace." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-typescript-suggest-auto-imports t - "Enable/disable auto import suggestions. Requires using -TypeScript 2.6.1 or newer in the workspace." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-javascript-suggest-complete-js-docs t - "Enable/disable suggestion to complete JSDoc comments." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-typescript-suggest-complete-js-docs t - "Enable/disable suggestion to complete JSDoc comments." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-typescript-locale nil - nil - :type '(choice - (const "de") - (const "es") - (const "en") - (const "fr") - (const "it") - (const "ja") - (const "ko") - (const "ru") - (const "zh-CN") - (const "zh-TW") - (const :tag "default" nil)) - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-javascript-suggestion-actions-enabled t - "Enable/disable suggestion diagnostics for JavaScript files in -the editor. Requires using TypeScript 2.8 or newer in the -workspace." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-typescript-suggestion-actions-enabled t - "Enable/disable suggestion diagnostics for TypeScript files in -the editor. Requires using TypeScript 2.8 or newer in the -workspace." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-javascript-preferences-quote-style "auto" nil - :type '(choice - (const "auto") - (const "single") - (const "double")) - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-typescript-preferences-quote-style "auto" nil - :type '(choice - (const "auto") - (const "single") - (const "double")) - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-javascript-preferences-import-module-specifier "auto" - "Preferred path style for auto imports." - :type '(choice - (const "auto") - (const "relative") - (const "non-relative")) - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-typescript-preferences-import-module-specifier "auto" - "Infer the shortest path type." - :type '(choice - (const "auto") - (const "relative") - (const "non-relative")) - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-javascript-preferences-rename-shorthand-properties t - "Enable/disable introducing aliases for object shorthand -properties during renames. Requires using TypeScript 3.4 or newer -in the workspace." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-typescript-preferences-rename-shorthand-properties t - "Enable/disable introducing aliases for object shorthand -properties during renames. Requires using TypeScript 3.4 or newer -in the workspace." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-typescript-update-imports-on-file-move-enabled "prompt" - "Enable/disable automatic updating of import paths when you -rename or move a file in VS Code. Requires using TypeScript 2.9 -or newer in the workspace." - :type '(choice - (const "prompt") - (const "always") - (const "never")) - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-javascript-update-imports-on-file-move-enabled "prompt" - "Prompt on each rename." - :type '(choice - (const "prompt") - (const "always") - (const "never")) - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-typescript-auto-closing-tags t - "Enable/disable automatic closing of JSX tags. Requires using -TypeScript 3.0 or newer in the workspace." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-javascript-auto-closing-tags t - "Enable/disable automatic closing of JSX tags. Requires using -TypeScript 3.0 or newer in the workspace." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-javascript-suggest-enabled t - "Enabled/disable autocomplete suggestions." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-typescript-suggest-enabled t - "Enabled/disable autocomplete suggestions." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-typescript-surveys-enabled t - "Enabled/disable occasional surveys that help us improve VS -Code's JavaScript and TypeScript support." - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-javascript-display-enum-member-value-hints nil - "Show inlay hints for enum member values." - :type 'boolean - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-javascript-display-return-type-hints nil - "Show inlay hints for function return types." - :type 'boolean - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-javascript-display-parameter-type-hints nil - "Show inlay hints for function parameters." - :type 'boolean - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-javascript-display-parameter-name-hints "none" - "Level of hinting for parameter types." - :type '(choice (const :tag "none" "none") - (const :tag "literals" "literals") - (const :tag "all" "all")) - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-javascript-display-parameter-name-hints-when-argument-matches-name nil - "Show inlay hints for function parameters even when argument matches -name (e.g. `data' variable passed as `data' parameter)." - :type 'boolean - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-javascript-display-property-declaration-type-hints nil - "Show inlay hints for property declaration types." - :type 'boolean - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-javascript-display-variable-type-hints nil - "Show inlay hints for variable types." - :type 'boolean - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-javascript-completions-complete-function-calls t - "Complete function calls." - :type 'boolean - :package-version '(lsp-mode . "9.0.0")) - -(lsp-register-custom-settings - '(("javascript.autoClosingTags" lsp-javascript-auto-closing-tags t) - ("javascript.implicitProjectConfig.checkJs" lsp-javascript-implicit-project-config-check-js t) - ("javascript.implicitProjectConfig.experimentalDecorators" lsp-javascript-implicit-project-config-experimental-decorators t) - ("javascript.preferences.importModuleSpecifier" lsp-javascript-preferences-import-module-specifier) - ("javascript.preferences.quoteStyle" lsp-javascript-preferences-quote-style) - ("javascript.preferences.renameShorthandProperties" lsp-javascript-preferences-rename-shorthand-properties t) - ("javascript.referencesCodeLens.enabled" lsp-javascript-references-code-lens-enabled t) - ("javascript.suggest.autoImports" lsp-javascript-suggest-auto-imports t) - ("javascript.suggest.completeFunctionCalls" lsp-javascript-suggest-complete-function-calls t) - ("javascript.suggest.completeJSDocs" lsp-javascript-suggest-complete-js-docs t) - ("javascript.suggest.enabled" lsp-javascript-suggest-enabled t) - ("javascript.suggest.names" lsp-javascript-suggest-names t) - ("javascript.suggest.paths" lsp-javascript-suggest-paths t) - ("javascript.suggestionActions.enabled" lsp-javascript-suggestion-actions-enabled t) - ("javascript.updateImportsOnFileMove.enabled" lsp-javascript-update-imports-on-file-move-enabled) - ("javascript.validate.enable" lsp-javascript-validate-enable t) - ("javascript.format.enable" lsp-javascript-format-enable t) - ("javascript.format.insertSpaceAfterCommaDelimiter" lsp-javascript-format-insert-space-after-comma-delimiter t) - ("javascript.format.insertSpaceAfterConstructor" lsp-javascript-format-insert-space-after-constructor t) - ("javascript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions" lsp-javascript-format-insert-space-after-function-keyword-for-anonymous-functions t) - ("javascript.format.insertSpaceAfterKeywordsInControlFlowStatements" lsp-javascript-format-insert-space-after-keywords-in-control-flow-statements t) - ("javascript.format.insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces" lsp-javascript-format-insert-space-after-opening-and-before-closing-jsx-expression-braces t) - ("javascript.format.insertSpaceAfterOpeningAndBeforeClosingEmptyBraces" lsp-javascript-format-insert-space-after-opening-and-before-closing-empty-braces t) - ("javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces" lsp-javascript-format-insert-space-after-opening-and-before-closing-nonempty-braces t) - ("javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets" lsp-javascript-format-insert-space-after-opening-and-before-closing-nonempty-brackets t) - ("javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis" lsp-javascript-format-insert-space-after-opening-and-before-closing-nonempty-parenthesis t) - ("javascript.format.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces" lsp-javascript-format-insert-space-after-opening-and-before-closing-template-string-braces t) - ("javascript.format.insertSpaceAfterSemicolonInForStatements" lsp-javascript-format-insert-space-after-semicolon-in-for-statements t) - ("javascript.format.insertSpaceBeforeAndAfterBinaryOperators" lsp-javascript-format-insert-space-before-and-after-binary-operators t) - ("javascript.format.insertSpaceBeforeFunctionParenthesis" lsp-javascript-format-insert-space-before-function-parenthesis t) - ("javascript.format.placeOpenBraceOnNewLineForControlBlocks" lsp-javascript-format-place-open-brace-on-new-line-for-control-blocks t) - ("javascript.format.placeOpenBraceOnNewLineForFunctions" lsp-javascript-format-place-open-brace-on-new-line-for-functions t) - ("typescript.autoClosingTags" lsp-typescript-auto-closing-tags t) - ("typescript.check.npmIsInstalled" lsp-typescript-check-npm-is-installed t) - ("typescript.disableAutomaticTypeAcquisition" lsp-typescript-disable-automatic-type-acquisition t) - ("typescript.implementationsCodeLens.enabled" lsp-typescript-implementations-code-lens-enabled t) - ("typescript.locale" lsp-typescript-locale) - ("typescript.npm" lsp-typescript-npm) - ("typescript.preferences.importModuleSpecifier" lsp-typescript-preferences-import-module-specifier) - ("typescript.preferences.quoteStyle" lsp-typescript-preferences-quote-style) - ("typescript.preferences.renameShorthandProperties" lsp-typescript-preferences-rename-shorthand-properties t) - ("typescript.referencesCodeLens.enabled" lsp-typescript-references-code-lens-enabled t) - ("typescript.reportStyleChecksAsWarnings" lsp-typescript-report-style-checks-as-warnings t) - ("typescript.suggest.autoImports" lsp-typescript-suggest-auto-imports t) - ("typescript.suggest.completeFunctionCalls" lsp-typescript-suggest-complete-function-calls t) - ("typescript.suggest.completeJSDocs" lsp-typescript-suggest-complete-js-docs t) - ("typescript.suggest.enabled" lsp-typescript-suggest-enabled t) - ("typescript.suggest.paths" lsp-typescript-suggest-paths t) - ("typescript.suggestionActions.enabled" lsp-typescript-suggestion-actions-enabled t) - ("typescript.surveys.enabled" lsp-typescript-surveys-enabled t) - ("typescript.tsc.autoDetect" lsp-typescript-tsc-auto-detect) - ("typescript.tsdk" lsp-typescript-tsdk) - ("typescript.tsserver.log" lsp-typescript-tsserver-log) - ("typescript.tsserver.pluginPaths" lsp-typescript-tsserver-plugin-paths) - ("typescript.tsserver.trace" lsp-typescript-tsserver-trace) - ("typescript.updateImportsOnFileMove.enabled" lsp-typescript-update-imports-on-file-move-enabled) - ("typescript.validate.enable" lsp-typescript-validate-enable t) - ("typescript.format.enable" lsp-typescript-format-enable t) - ("typescript.format.insertSpaceAfterCommaDelimiter" lsp-typescript-format-insert-space-after-comma-delimiter t) - ("typescript.format.insertSpaceAfterConstructor" lsp-typescript-format-insert-space-after-constructor t) - ("typescript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions" lsp-typescript-format-insert-space-after-function-keyword-for-anonymous-functions t) - ("typescript.format.insertSpaceAfterKeywordsInControlFlowStatements" lsp-typescript-format-insert-space-after-keywords-in-control-flow-statements t) - ("typescript.format.insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces" lsp-typescript-format-insert-space-after-opening-and-before-closing-jsx-expression-braces t) - ("typescript.format.insertSpaceAfterOpeningAndBeforeClosingEmptyBraces" lsp-typescript-format-insert-space-after-opening-and-before-closing-empty-braces t) - ("typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces" lsp-typescript-format-insert-space-after-opening-and-before-closing-nonempty-braces t) - ("typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets" lsp-typescript-format-insert-space-after-opening-and-before-closing-nonempty-brackets t) - ("typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis" lsp-typescript-format-insert-space-after-opening-and-before-closing-nonempty-parenthesis t) - ("typescript.format.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces" lsp-typescript-format-insert-space-after-opening-and-before-closing-template-string-braces t) - ("typescript.format.insertSpaceAfterSemicolonInForStatements" lsp-typescript-format-insert-space-after-semicolon-in-for-statements t) - ("typescript.format.insertSpaceAfterTypeAssertion" lsp-typescript-format-insert-space-after-type-assertion t) - ("typescript.format.insertSpaceBeforeAndAfterBinaryOperators" lsp-typescript-format-insert-space-before-and-after-binary-operators t) - ("typescript.format.insertSpaceBeforeFunctionParenthesis" lsp-typescript-format-insert-space-before-function-parenthesis t) - ("typescript.format.placeOpenBraceOnNewLineForControlBlocks" lsp-typescript-format-place-open-brace-on-new-line-for-control-blocks t) - ("typescript.format.placeOpenBraceOnNewLineForFunctions" lsp-typescript-format-place-open-brace-on-new-line-for-functions t) - ("typescript.inlayHints.includeInlayEnumMemberValueHints" lsp-javascript-display-enum-member-value-hints t) - ("typescript.inlayHints.includeInlayFunctionLikeReturnTypeHints" lsp-javascript-display-return-type-hints t) - ("typescript.inlayHints.includeInlayFunctionParameterTypeHints" lsp-javascript-display-parameter-type-hints t) - ("typescript.inlayHints.includeInlayParameterNameHints" lsp-javascript-display-parameter-name-hints nil) - ("typescript.inlayHints.includeInlayParameterNameHintsWhenArgumentMatchesName" lsp-javascript-display-parameter-name-hints-when-argument-matches-name t) - ("typescript.inlayHints.includeInlayPropertyDeclarationTypeHints" lsp-javascript-display-property-declaration-type-hints t) - ("typescript.inlayHints.includeInlayVariableTypeHints" lsp-javascript-display-variable-type-hints t) - ("javascript.inlayHints.includeInlayEnumMemberValueHints" lsp-javascript-display-enum-member-value-hints t) - ("javascript.inlayHints.includeInlayFunctionLikeReturnTypeHints" lsp-javascript-display-return-type-hints t) - ("javascript.inlayHints.includeInlayFunctionParameterTypeHints" lsp-javascript-display-parameter-type-hints t) - ("javascript.inlayHints.includeInlayParameterNameHints" lsp-javascript-display-parameter-name-hints nil) - ("javascript.inlayHints.includeInlayParameterNameHintsWhenArgumentMatchesName" lsp-javascript-display-parameter-name-hints-when-argument-matches-name t) - ("javascript.inlayHints.includeInlayPropertyDeclarationTypeHints" lsp-javascript-display-property-declaration-type-hints t) - ("javascript.inlayHints.includeInlayVariableTypeHints" lsp-javascript-display-variable-type-hints t) - ("completions.completeFunctionCalls" lsp-javascript-completions-complete-function-calls t))) - -(lsp-dependency 'typescript-language-server - '(:system lsp-clients-typescript-tls-path) - '(:npm :package "typescript-language-server" - :path "typescript-language-server")) - -(lsp-dependency 'typescript - '(:system "tsserver") - '(:npm :package "typescript" - :path "tsserver")) - -(defun lsp-javascript--rename (_workspace args) - (let ((path (lsp--uri-to-path (lsp-get (lsp-get args :textDocument) :uri)))) - (if (f-exists? path) - (with-current-buffer (find-file path) - (goto-char (lsp--position-to-point - (lsp-get args :position)))) - (error "There is no file %s" path))) - (call-interactively #'lsp-rename) - nil) - -(defun lsp-javascript-rename-file () - "Rename current file and all it's references in other files." - (interactive) - (let* ((name (buffer-name)) - (old (buffer-file-name)) - (basename (file-name-nondirectory old))) - (unless (and old (file-exists-p old)) - (error "Buffer '%s' is not visiting a file." name)) - (let ((new (read-file-name "New name: " (file-name-directory old) basename nil basename))) - (when (get-file-buffer new) - (error "A buffer named '%s' already exists." new)) - (when (file-exists-p new) - (error "A file named '%s' already exists." new)) - (lsp--send-execute-command - "_typescript.applyRenameFile" - (vector (list :sourceUri (lsp--buffer-uri) - :targetUri (lsp--path-to-uri new)))) - (mkdir (file-name-directory new) t) - (rename-file old new) - (rename-buffer new) - (set-visited-file-name new) - (set-buffer-modified-p nil) - (lsp-disconnect) - (setq-local lsp-buffer-uri nil) - (lsp) - (lsp--info "Renamed '%s' to '%s'." name (file-name-nondirectory new))))) - -(defun lsp-javascript-initialized? () - (when-let ((workspace (lsp-find-workspace 'ts-ls (buffer-file-name)))) - (eq 'initialized (lsp--workspace-status workspace)))) - -(defun lsp-clients-typescript-project-ts-server-path () - "Return the project local TS server path." - (f-join (lsp-workspace-root) "node_modules" "typescript" "lib" "tsserver.js")) - -(defun lsp-clients-typescript-server-path () - "Return the TS sever path base on settings." - (cond - ((and lsp-clients-typescript-prefer-use-project-ts-server - (f-exists? (lsp-clients-typescript-project-ts-server-path))) - (lsp-clients-typescript-project-ts-server-path)) - (t - (if (memq system-type '(cygwin windows-nt ms-dos)) - (f-join (f-parent (lsp-package-path 'typescript)) "node_modules" "typescript" "lib") - (f-join (f-parent (f-parent (lsp-package-path 'typescript))) "lib" "node_modules" "typescript" "lib"))))) - -(lsp-register-client - (make-lsp-client :new-connection (lsp-stdio-connection (lambda () - `(,(lsp-package-path 'typescript-language-server) - ,@lsp-clients-typescript-server-args))) - :activation-fn 'lsp-typescript-javascript-tsx-jsx-activate-p - :priority -2 - :completion-in-comments? t - :initialization-options (lambda () - (append - (when lsp-clients-typescript-disable-automatic-typing-acquisition - (list :disableAutomaticTypingAcquisition lsp-clients-typescript-disable-automatic-typing-acquisition)) - (when lsp-clients-typescript-log-verbosity - (list :logVerbosity lsp-clients-typescript-log-verbosity)) - (when lsp-clients-typescript-max-ts-server-memory - (list :maxTsServerMemory lsp-clients-typescript-max-ts-server-memory)) - (when lsp-clients-typescript-npm-location - (list :npmLocation lsp-clients-typescript-npm-location)) - (when lsp-clients-typescript-plugins - (list :plugins lsp-clients-typescript-plugins)) - (when lsp-clients-typescript-preferences - (list :preferences lsp-clients-typescript-preferences)) - `(:tsserver ( :path ,(lsp-clients-typescript-server-path) - ,@lsp-clients-typescript-tsserver)))) - :initialized-fn (lambda (workspace) - (with-lsp-workspace workspace - (lsp--set-configuration - (ht-merge (lsp-configuration-section "javascript") - (lsp-configuration-section "typescript") - (lsp-configuration-section "completions") - (lsp-configuration-section "diagnostics")))) - (let ((caps (lsp--workspace-server-capabilities workspace)) - (format-enable (or lsp-javascript-format-enable lsp-typescript-format-enable))) - (lsp:set-server-capabilities-document-formatting-provider? caps format-enable) - (lsp:set-server-capabilities-document-range-formatting-provider? caps format-enable))) - :ignore-messages '("readFile .*? requested by TypeScript but content not available") - :server-id 'ts-ls - :request-handlers (ht ("_typescript.rename" #'lsp-javascript--rename)) - :download-server-fn (lambda (_client callback error-callback _update?) - (lsp-package-ensure - 'typescript - (-partial #'lsp-package-ensure - 'typescript-language-server - callback - error-callback) - error-callback)))) - - -(defgroup lsp-flow nil - "LSP support for the Flow Javascript type checker." - :group 'lsp-mode - :link '(url-link "https://flow.org")) - -(defcustom lsp-clients-flow-server "flow" - "The Flow executable to use. -Leave as just the executable name to use the default behavior of -finding the executable with variable `exec-path'." - :group 'lsp-flow - :risky t - :type 'file) - -(defcustom lsp-clients-flow-server-args '("lsp") - "Extra arguments for starting the Flow language server." - :group 'lsp-flow - :risky t - :type '(repeat string)) - -(defun lsp-clients-flow-tag-file-present-p (file-name) - "Check if the '// @flow' or `/* @flow */' tag is present in -the contents of FILE-NAME." - (if-let ((buffer (find-buffer-visiting file-name))) - (with-current-buffer buffer - (lsp-clients-flow-tag-string-present-p)) - (with-temp-buffer - (insert-file-contents file-name) - (lsp-clients-flow-tag-string-present-p)))) - -(defun lsp-clients-flow-tag-string-present-p () - "Helper for `lsp-clients-flow-tag-file-present-p' that works -with the file contents." - (save-excursion - (goto-char (point-min)) - (let (stop found) - (while (not stop) - (unless (re-search-forward "[^\n[:space:]]" nil t) - (setq stop t)) - (if (= (point) (point-min)) (setq stop t) (backward-char)) - (cond ((or (looking-at-p "//+[ ]*@flow") - (looking-at-p "/\\**[ ]*@flow") - (looking-at-p "[ ]*\\*[ ]*@flow")) - (setq found t) (setq stop t)) - ((or (looking-at-p "//") (looking-at-p "*")) - (forward-line)) - ((looking-at-p "/\\*") - (save-excursion - (unless (re-search-forward "*/" nil t) (setq stop t))) - (forward-line)) - (t (setq stop t)))) - found))) - -(defun lsp-clients-flow-project-p (file-name) - "Check if FILE-NAME is part of a Flow project, that is, if -there is a .flowconfig file in the folder hierarchy." - (locate-dominating-file file-name ".flowconfig")) - -(defun lsp-clients-flow-activate-p (file-name _mode) - "Check if the Flow language server should be enabled for a -particular FILE-NAME and MODE." - (and (derived-mode-p 'js-mode 'web-mode 'js2-mode 'flow-js2-mode 'rjsx-mode) - (not (derived-mode-p 'json-mode)) - (or (lsp-clients-flow-project-p file-name) - (lsp-clients-flow-tag-file-present-p file-name)))) - -(lsp-register-client - (make-lsp-client :new-connection - (lsp-stdio-connection (lambda () - (cons lsp-clients-flow-server - lsp-clients-flow-server-args))) - :priority -1 - :activation-fn 'lsp-clients-flow-activate-p - :server-id 'flow-ls)) - -(defgroup lsp-deno nil - "LSP support for the Deno language server." - :group 'lsp-mode - :link '(url-link "https://deno.land/")) - -(defcustom lsp-clients-deno-server "deno" - "The Deno executable to use. -Leave as just the executable name to use the default behavior of -finding the executable with variable `exec-path'." - :group 'lsp-deno - :risky t - :type 'file - :package-version '(lsp-mode . "8.0.0")) - -(defcustom lsp-clients-deno-server-args '("lsp") - "Extra arguments for starting the Deno language server." - :group 'lsp-deno - :risky t - :type '(repeat string) - :package-version '(lsp-mode . "8.0.0")) - -(defcustom lsp-clients-deno-enable-lint t - "Controls if linting information will be provided by the Deno Language Server." - :group 'lsp-deno - :risky t - :type 'boolean - :package-version '(lsp-mode . "8.0.0")) - -(defcustom lsp-clients-deno-enable-code-lens-references t - "Enables or disables the display of code lens information." - :group 'lsp-deno - :risky t - :type 'boolean - :package-version '(lsp-mode . "8.0.0")) - -(defcustom lsp-clients-deno-enable-code-lens-references-all-functions t - "Enables or disables the display of code lens information for all functions. -Setting this variable to `non-nil' implicitly enables -`lsp-clients-deno-enable-code-lens-references'." - :group 'lsp-deno - :risky t - :type 'boolean - :package-version '(lsp-mode . "8.0.0")) - -(defcustom lsp-clients-deno-enable-code-lens-implementations t - "Enables or disables the display of code lens information for implementations." - :group 'lsp-deno - :risky t - :type 'boolean - :package-version '(lsp-mode . "8.0.0")) - -(defcustom lsp-clients-deno-config nil - "The file path to a tsconfig.json file. -The path can be either be relative to the workspace, or an -absolute path. - -Examples: `./tsconfig.json', -`/path/to/tsconfig.json', `C:\\path\\to\\tsconfig.json'" - :group 'lsp-deno - :risky t - :type 'file - :package-version '(lsp-mode . "8.0.0")) - -(defcustom lsp-clients-deno-import-map nil - "The file path to an import map. -Import maps provide a way to relocate modules based on their -specifiers. The path can either be relative to the workspace, or -an absolute path. - -Examples: `./import-map.json', -`/path/to/import-map.json', `C:\\path\\to\\import-map.json'." - :group 'lsp-deno - :risky t - :type 'file - :package-version '(lsp-mode . "8.0.0")) - -(defcustom lsp-clients-deno-enable-unstable nil - "Controls if code will be type checked with Deno's unstable APIs." - :group 'lsp-deno - :risky t - :type 'boolean - :package-version '(lsp-mode . "8.0.0")) - -(defun lsp-clients-deno--make-init-options () - "Initialization options for the Deno language server." - `( :enable t - :config ,lsp-clients-deno-config - :importMap ,lsp-clients-deno-import-map - :lint ,(lsp-json-bool lsp-clients-deno-enable-lint) - :unstable ,(lsp-json-bool lsp-clients-deno-enable-unstable) - :codeLens ( :implementations ,(lsp-json-bool lsp-clients-deno-enable-code-lens-implementations) - :references ,(lsp-json-bool (or lsp-clients-deno-enable-code-lens-references - lsp-clients-deno-enable-code-lens-references-all-functions)) - :referencesAllFunctions ,(lsp-json-bool lsp-clients-deno-enable-code-lens-references-all-functions)))) - -(lsp-register-client - (make-lsp-client :new-connection - (lsp-stdio-connection (lambda () - (cons lsp-clients-deno-server - lsp-clients-deno-server-args))) - :initialization-options #'lsp-clients-deno--make-init-options - :priority -5 - :activation-fn #'lsp-typescript-javascript-tsx-jsx-activate-p - :server-id 'deno-ls)) - -(lsp-consistency-check lsp-javascript) - -(provide 'lsp-javascript) -;;; lsp-javascript.el ends here diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-javascript.elc b/emacs/elpa/lsp-mode-20240514.1430/lsp-javascript.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-mode-pkg.el b/emacs/elpa/lsp-mode-20240514.1430/lsp-mode-pkg.el @@ -1,21 +0,0 @@ -(define-package "lsp-mode" "20240514.1430" "LSP mode" - '((emacs "27.1") - (dash "2.18.0") - (f "0.20.0") - (ht "2.3") - (spinner "1.7.3") - (markdown-mode "2.3") - (lv "0") - (eldoc "1.11")) - :commit "62e1f68c1f2363f7ebe8f1c2762e472f3b5de46a" :authors - '(("Vibhav Pant, Fangrui Song, Ivan Yonchovski")) - :maintainers - '(("Vibhav Pant, Fangrui Song, Ivan Yonchovski")) - :maintainer - '("Vibhav Pant, Fangrui Song, Ivan Yonchovski") - :keywords - '("languages") - :url "https://github.com/emacs-lsp/lsp-mode") -;; Local Variables: -;; no-byte-compile: t -;; End: diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-mode.el b/emacs/elpa/lsp-mode-20240514.1430/lsp-mode.el @@ -1,9794 +0,0 @@ -;;; lsp-mode.el --- LSP mode -*- lexical-binding: t; -*- - -;; Copyright (C) 2020-2024 emacs-lsp maintainers - -;; Author: Vibhav Pant, Fangrui Song, Ivan Yonchovski -;; Keywords: languages -;; Package-Requires: ((emacs "27.1") (dash "2.18.0") (f "0.20.0") (ht "2.3") (spinner "1.7.3") (markdown-mode "2.3") (lv "0") (eldoc "1.11")) -;; Version: 9.0.1 - -;; URL: https://github.com/emacs-lsp/lsp-mode -;; 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 <https://www.gnu.org/licenses/>. - -;;; Commentary: - -;; Emacs client/library for the Language Server Protocol - -;;; Code: - -(require 'cl-generic) -(require 'cl-lib) -(require 'compile) -(require 'dash) -(require 'epg) -(require 'ewoc) -(require 'f) -(require 'filenotify) -(require 'files) -(require 'ht) -(require 'imenu) -(require 'inline) -(require 'json) -(require 'lv) -(require 'markdown-mode) -(require 'network-stream) -(require 'pcase) -(require 'rx) -(require 's) -(require 'seq) -(require 'spinner) -(require 'subr-x) -(require 'tree-widget) -(require 'url-parse) -(require 'url-util) -(require 'widget) -(require 'xref) -(require 'minibuffer) -(require 'help-mode) -(require 'lsp-protocol) - -(defgroup lsp-mode nil - "Language Server Protocol client." - :group 'tools - :tag "Language Server (lsp-mode)") - -(declare-function evil-set-command-property "ext:evil-common") -(declare-function projectile-project-root "ext:projectile") -(declare-function yas-expand-snippet "ext:yasnippet") -(declare-function dap-mode "ext:dap-mode") -(declare-function dap-auto-configure-mode "ext:dap-mode") - -(defvar yas-inhibit-overlay-modification-protection) -(defvar yas-indent-line) -(defvar yas-wrap-around-region) -(defvar yas-also-auto-indent-first-line) -(defvar dap-auto-configure-mode) -(defvar dap-ui-menu-items) -(defvar company-minimum-prefix-length) - -(defconst lsp--message-type-face - `((1 . ,compilation-error-face) - (2 . ,compilation-warning-face) - (3 . ,compilation-message-face) - (4 . ,compilation-info-face))) - -(defconst lsp--errors - '((-32700 "Parse Error") - (-32600 "Invalid Request") - (-32601 "Method not Found") - (-32602 "Invalid Parameters") - (-32603 "Internal Error") - (-32099 "Server Start Error") - (-32000 "Server End Error") - (-32002 "Server Not Initialized") - (-32001 "Unknown Error Code") - (-32800 "Request Cancelled")) - "Alist of error codes to user friendly strings.") - -(defconst lsp--empty-ht (make-hash-table)) - -(eval-and-compile - (defun dash-expand:&lsp-wks (key source) - `(,(intern-soft (format "lsp--workspace-%s" (eval key))) ,source)) - - (defun dash-expand:&lsp-cln (key source) - `(,(intern-soft (format "lsp--client-%s" (eval key))) ,source))) - -(define-obsolete-variable-alias 'lsp-print-io 'lsp-log-io "lsp-mode 6.1") - -(defcustom lsp-log-io nil - "If non-nil, log all messages from the language server to a *lsp-log* buffer." - :group 'lsp-mode - :type 'boolean) - -(defcustom lsp-log-io-allowlist-methods '() - "The methods to filter before print to lsp-log-io." - :group 'lsp-mode - :type '(repeat string) - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-log-max message-log-max - "Maximum number of lines to keep in the log buffer. -If nil, disable message logging. If t, log messages but don’t truncate -the buffer when it becomes large." - :group 'lsp-mode - :type '(choice (const :tag "Disable" nil) - (integer :tag "lines") - (const :tag "Unlimited" t)) - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-io-messages-max t - "Maximum number of messages that can be locked in a `lsp-io' buffer." - :group 'lsp-mode - :type '(choice (const :tag "Unlimited" t) - (integer :tag "Messages")) - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-keep-workspace-alive t - "If non nil keep workspace alive when the last workspace buffer is closed." - :group 'lsp-mode - :type 'boolean) - -(defcustom lsp-enable-snippet t - "Enable/disable snippet completion support." - :group 'lsp-completion - :type 'boolean) - -(defcustom lsp-enable-folding t - "Enable/disable code folding support." - :group 'lsp-mode - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(define-obsolete-variable-alias 'lsp-enable-semantic-highlighting 'lsp-semantic-tokens-enable "lsp-mode 8.0.0") - -(defcustom lsp-semantic-tokens-enable nil - "Enable/disable support for semantic tokens. -As defined by the Language Server Protocol 3.16." - :group 'lsp-semantic-tokens - :type 'boolean) - -(defcustom lsp-folding-range-limit nil - "The maximum number of folding ranges to receive from the language server." - :group 'lsp-mode - :type '(choice (const :tag "No limit." nil) - (integer :tag "Number of lines.")) - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-folding-line-folding-only nil - "If non-nil, only fold complete lines." - :group 'lsp-mode - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-client-packages - '( ccls lsp-actionscript lsp-ada lsp-angular lsp-ansible lsp-asm lsp-astro - lsp-autotools lsp-awk lsp-bash lsp-beancount lsp-bufls lsp-clangd - lsp-clojure lsp-cmake lsp-cobol lsp-credo lsp-crystal lsp-csharp lsp-css - lsp-cucumber lsp-cypher lsp-d lsp-dart lsp-dhall lsp-docker lsp-dockerfile - lsp-elixir lsp-elm lsp-emmet lsp-erlang lsp-eslint lsp-fortran lsp-fsharp - lsp-gdscript lsp-gleam lsp-glsl lsp-go lsp-golangci-lint lsp-grammarly - lsp-graphql lsp-groovy lsp-hack lsp-haskell lsp-haxe lsp-idris lsp-java - lsp-javascript lsp-jq lsp-json lsp-kotlin lsp-latex lsp-lisp lsp-ltex - lsp-lua lsp-magik lsp-markdown lsp-marksman lsp-mdx lsp-meson lsp-metals lsp-mint - lsp-mojo lsp-move lsp-mssql lsp-nginx lsp-nim lsp-nix lsp-nushell lsp-ocaml - lsp-openscad lsp-pascal lsp-perl lsp-perlnavigator lsp-php lsp-pls - lsp-purescript lsp-pwsh lsp-pyls lsp-pylsp lsp-pyright lsp-python-ms - lsp-qml lsp-r lsp-racket lsp-remark lsp-rf lsp-rubocop lsp-ruby-lsp - lsp-ruby-syntax-tree lsp-ruff-lsp lsp-rust lsp-semgrep lsp-shader - lsp-solargraph lsp-solidity lsp-sonarlint lsp-sorbet lsp-sourcekit - lsp-sql lsp-sqls lsp-steep lsp-svelte lsp-tailwindcss lsp-terraform - lsp-tex lsp-tilt lsp-toml lsp-trunk lsp-ttcn3 lsp-typeprof lsp-v - lsp-vala lsp-verilog lsp-vetur lsp-vhdl lsp-vimscript lsp-volar lsp-wgsl - lsp-xml lsp-yaml lsp-yang lsp-zig) - "List of the clients to be automatically required." - :group 'lsp-mode - :type '(repeat symbol)) - -(defcustom lsp-progress-via-spinner t - "If non-nil, display LSP $/progress reports via a spinner in the modeline." - :group 'lsp-mode - :type 'boolean) - -(defcustom lsp-progress-spinner-type 'progress-bar - "Holds the type of spinner to be used in the mode-line. -Takes a value accepted by `spinner-start'." - :group 'lsp-mode - :type `(choice :tag "Choose a spinner by name" - ,@(mapcar (lambda (c) (list 'const (car c))) - spinner-types))) - -(defvar-local lsp-use-workspace-root-for-server-default-directory nil - "Use `lsp-workspace-root' for `default-directory' when starting LSP process.") - -(defvar-local lsp--cur-workspace nil) - -(defvar-local lsp--cur-version 0) -(defvar-local lsp--virtual-buffer-connections nil) -(defvar-local lsp--virtual-buffer nil) -(defvar lsp--virtual-buffer-mappings (ht)) - -(defvar lsp--uri-file-prefix (pcase system-type - (`windows-nt "file:///") - (_ "file://")) - "Prefix for a file-uri.") - -(defvar-local lsp-buffer-uri nil - "If set, return it instead of calculating it using `buffer-file-name'.") - -(define-error 'lsp-error "Unknown lsp-mode error") -(define-error 'lsp-empty-response-error - "Empty response from the language server" 'lsp-error) -(define-error 'lsp-timed-out-error - "Timed out while waiting for a response from the language server" 'lsp-error) -(define-error 'lsp-capability-not-supported - "Capability not supported by the language server" 'lsp-error) -(define-error 'lsp-file-scheme-not-supported - "Unsupported file scheme" 'lsp-error) -(define-error 'lsp-client-already-exists-error - "A client with this server-id already exists" 'lsp-error) -(define-error 'lsp-no-code-actions - "No code actions" 'lsp-error) - -(defcustom lsp-auto-guess-root nil - "Automatically guess the project root using projectile/project. -Do *not* use this setting unless you are familiar with `lsp-mode' -internals and you are sure that all of your projects are -following `projectile'/`project.el' conventions." - :group 'lsp-mode - :type 'boolean) - -(defcustom lsp-guess-root-without-session nil - "Ignore the session file when calculating the project root. -You almost always want to set lsp-auto-guess-root too. -Do *not* use this setting unless you are familiar with `lsp-mode' -internals and you are sure that all of your projects are -following `projectile'/`project.el' conventions." - :group 'lsp-mode - :type 'boolean) - -(defcustom lsp-restart 'interactive - "Defines how server-exited events must be handled." - :group 'lsp-mode - :type '(choice (const interactive) - (const auto-restart) - (const ignore))) - -(defcustom lsp-session-file (expand-file-name (locate-user-emacs-file ".lsp-session-v1")) - "File where session information is stored." - :group 'lsp-mode - :type 'file) - -(defcustom lsp-auto-configure t - "Auto configure `lsp-mode' main features. -When set to t `lsp-mode' will auto-configure completion, -code-actions, breadcrumb, `flycheck', `flymake', `imenu', symbol highlighting, -lenses, links, and so on. - -For finer granularity you may use `lsp-enable-*' properties." - :group 'lsp-mode - :type 'boolean - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-disabled-clients nil - "A list of disabled/blocklisted clients. -Each entry in the list can be either: -a symbol, the server-id for the LSP client, or -a cons pair (MAJOR-MODE . CLIENTS), where MAJOR-MODE is the major-mode, -and CLIENTS is either a client or a list of clients. - -This option can also be used as a file- or directory-local variable to -disable a language server for individual files or directories/projects -respectively." - :group 'lsp-mode - :type '(repeat (symbol)) - :safe 'listp - :package-version '(lsp-mode . "6.1")) - -(defvar lsp-clients (make-hash-table :test 'eql) - "Hash table server-id -> client. -It contains all of the clients that are currently registered.") - -(defvar lsp-enabled-clients nil - "List of clients allowed to be used for projects. -When nil, all registered clients are considered candidates.") - -(defvar lsp-last-id 0 - "Last request id.") - -(defcustom lsp-before-initialize-hook nil - "List of functions to be called before a Language Server has been initialized -for a new workspace." - :type 'hook - :group 'lsp-mode) - -(defcustom lsp-after-initialize-hook nil - "List of functions to be called after a Language Server has been initialized -for a new workspace." - :type 'hook - :group 'lsp-mode) - -(defcustom lsp-before-open-hook nil - "List of functions to be called before a new file with LSP support is opened." - :type 'hook - :group 'lsp-mode) - -(defcustom lsp-after-open-hook nil - "List of functions to be called after a new file with LSP support is opened." - :type 'hook - :group 'lsp-mode) - -(defcustom lsp-enable-file-watchers t - "If non-nil lsp-mode will watch the files in the workspace if -the server has requested that." - :type 'boolean - :group 'lsp-mode - :package-version '(lsp-mode . "6.1")) -;;;###autoload(put 'lsp-enable-file-watchers 'safe-local-variable #'booleanp) - -(define-obsolete-variable-alias 'lsp-file-watch-ignored 'lsp-file-watch-ignored-directories "8.0.0") - -(defcustom lsp-file-watch-ignored-directories - '(; SCM tools - "[/\\\\]\\.git\\'" - "[/\\\\]\\.github\\'" - "[/\\\\]\\.gitlab\\'" - "[/\\\\]\\.circleci\\'" - "[/\\\\]\\.hg\\'" - "[/\\\\]\\.bzr\\'" - "[/\\\\]_darcs\\'" - "[/\\\\]\\.svn\\'" - "[/\\\\]_FOSSIL_\\'" - ;; IDE or build tools - "[/\\\\]\\.idea\\'" - "[/\\\\]\\.ensime_cache\\'" - "[/\\\\]\\.eunit\\'" - "[/\\\\]node_modules" - "[/\\\\]\\.yarn\\'" - "[/\\\\]\\.fslckout\\'" - "[/\\\\]\\.tox\\'" - "[/\\\\]\\.nox\\'" - "[/\\\\]dist\\'" - "[/\\\\]dist-newstyle\\'" - "[/\\\\]\\.stack-work\\'" - "[/\\\\]\\.bloop\\'" - "[/\\\\]\\.metals\\'" - "[/\\\\]target\\'" - "[/\\\\]\\.ccls-cache\\'" - "[/\\\\]\\.vs\\'" - "[/\\\\]\\.vscode\\'" - "[/\\\\]\\.venv\\'" - "[/\\\\]\\.mypy_cache\\'" - "[/\\\\]\\.pytest_cache\\'" - ;; Swift Package Manager - "[/\\\\]\\.build\\'" - ;; Python - "[/\\\\]__pycache__\\'" - ;; Autotools output - "[/\\\\]\\.deps\\'" - "[/\\\\]build-aux\\'" - "[/\\\\]autom4te.cache\\'" - "[/\\\\]\\.reference\\'" - ;; Bazel - "[/\\\\]bazel-[^/\\\\]+\\'" - ;; CSharp - "[/\\\\]\\.cache[/\\\\]lsp-csharp\\'" - "[/\\\\]\\.meta\\'" - "[/\\\\]\\.nuget\\'" - ;; Unity - "[/\\\\]Library\\'" - ;; Clojure - "[/\\\\]\\.lsp\\'" - "[/\\\\]\\.clj-kondo\\'" - "[/\\\\]\\.shadow-cljs\\'" - "[/\\\\]\\.babel_cache\\'" - "[/\\\\]\\.cpcache\\'" - "[/\\\\]\\checkouts\\'" - ;; Gradle - "[/\\\\]\\.gradle\\'" - ;; Maven - "[/\\\\]\\.m2\\'" - ;; .Net Core build-output - "[/\\\\]bin/Debug\\'" - "[/\\\\]obj\\'" - ;; OCaml and Dune - "[/\\\\]_opam\\'" - "[/\\\\]_build\\'" - ;; Elixir - "[/\\\\]\\.elixir_ls\\'" - ;; Elixir Credo - "[/\\\\]\\.elixir-tools\\'" - ;; terraform and terragrunt - "[/\\\\]\\.terraform\\'" - "[/\\\\]\\.terragrunt-cache\\'" - ;; nix-direnv - "[/\\\\]\\result" - "[/\\\\]\\result-bin" - "[/\\\\]\\.direnv\\'") - "List of regexps matching directory paths which won't be monitored when -creating file watches. Customization of this variable is only honored at -the global level or at a root of an lsp workspace." - :group 'lsp-mode - :type '(repeat string) - :package-version '(lsp-mode . "8.0.0")) - -(define-obsolete-function-alias 'lsp-file-watch-ignored 'lsp-file-watch-ignored-directories "7.0.1") - -(defun lsp-file-watch-ignored-directories () - lsp-file-watch-ignored-directories) - -;; Allow lsp-file-watch-ignored-directories as a file or directory-local variable -;;;###autoload(put 'lsp-file-watch-ignored-directories 'safe-local-variable 'lsp--string-listp) - -(defcustom lsp-file-watch-ignored-files - '( - ;; Flycheck tempfiles - "[/\\\\]flycheck_[^/\\\\]+\\'" - ;; lockfiles - "[/\\\\]\\.#[^/\\\\]+\\'" - ;; backup files - "[/\\\\][^/\\\\]+~\\'" ) - "List of regexps matching files for which change events will -not be sent to the server. - -This setting has no impact on whether a file-watch is created for -a directory; it merely prevents notifications pertaining to -matched files from being sent to the server. To prevent a -file-watch from being created for a directory, customize -`lsp-file-watch-ignored-directories' - -Customization of this variable is only honored at the global -level or at a root of an lsp workspace." - :group 'lsp-mode - :type '(repeat string) - :package-version '(lsp-mode . "8.0.0")) - -;; Allow lsp-file-watch-ignored-files as a file or directory-local variable -;;;###autoload(put 'lsp-file-watch-ignored-files 'safe-local-variable 'lsp--string-listp) - -(defcustom lsp-after-uninitialized-functions nil - "List of functions to be called after a Language Server has been uninitialized." - :type 'hook - :group 'lsp-mode - :package-version '(lsp-mode . "6.3")) - -(defconst lsp--sync-full 1) -(defconst lsp--sync-incremental 2) - -(defcustom lsp-debounce-full-sync-notifications t - "If non-nil debounce full sync events. -This flag affects only servers which do not support incremental updates." - :type 'boolean - :group 'lsp-mode - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-debounce-full-sync-notifications-interval 1.0 - "Time to wait before sending full sync synchronization after buffer modification." - :type 'float - :group 'lsp-mode - :package-version '(lsp-mode . "6.1")) - -(defvar lsp--stderr-index 0) - -(defvar lsp--delayed-requests nil) -(defvar lsp--delay-timer nil) - -(defcustom lsp-document-sync-method nil - "How to sync the document with the language server." - :type '(choice (const :tag "Documents are synced by always sending the full content of the document." lsp--sync-full) - (const :tag "Documents are synced by always sending incremental changes to the document." lsp--sync-incremental) - (const :tag "Use the method recommended by the language server." nil)) - :group 'lsp-mode) - -(defcustom lsp-auto-execute-action t - "Auto-execute single action." - :type 'boolean - :group 'lsp-mode) - -(defcustom lsp-enable-links t - "If non-nil, all references to links in a file will be made clickable, if -supported by the language server." - :type 'boolean - :group 'lsp-mode - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-enable-imenu t - "If non-nil, automatically enable `imenu' integration when server provides -`textDocument/documentSymbol'." - :type 'boolean - :group 'lsp-mode - :package-version '(lsp-mode . "6.2")) - -(defcustom lsp-enable-dap-auto-configure t - "If non-nil, enable `dap-auto-configure-mode`." - :type 'boolean - :group 'lsp-mode - :package-version '(lsp-mode . "7.0")) - -(defcustom lsp-eldoc-enable-hover t - "If non-nil, `eldoc' will display hover info when it is present." - :type 'boolean - :group 'lsp-mode) - -(defcustom lsp-eldoc-render-all nil - "Display all of the info returned by document/onHover. -If this is set to nil, `eldoc' will show only the symbol information." - :type 'boolean - :group 'lsp-mode) - -(define-obsolete-variable-alias 'lsp-enable-completion-at-point - 'lsp-completion-enable "lsp-mode 7.0.1") - -(defcustom lsp-completion-enable t - "Enable `completion-at-point' integration." - :type 'boolean - :group 'lsp-completion) - -(defcustom lsp-enable-symbol-highlighting t - "Highlight references of the symbol at point." - :type 'boolean - :group 'lsp-mode) - -(defcustom lsp-enable-xref t - "Enable xref integration." - :type 'boolean - :group 'lsp-mode) - -(defcustom lsp-references-exclude-definition nil - "If non-nil, exclude declarations when finding references." - :type 'boolean - :group 'lsp-mode) - -(defcustom lsp-enable-indentation t - "Indent regions using the file formatting functionality provided by the -language server." - :type 'boolean - :group 'lsp-mode) - -(defcustom lsp-enable-on-type-formatting t - "Enable `textDocument/onTypeFormatting' integration." - :type 'boolean - :group 'lsp-mode) - -(defcustom lsp-enable-text-document-color t - "Enable `textDocument/documentColor' integration." - :type 'boolean - :group 'lsp-mode) - -(defcustom lsp-before-save-edits t - "If non-nil, `lsp-mode' will apply edits suggested by the language server -before saving a document." - :type 'boolean - :group 'lsp-mode) - -(defcustom lsp-after-apply-edits-hook nil - "Hooks to run when text edit is applied. -It contains the operation source." - :type 'hook - :group 'lsp-mode - :package-version '(lsp-mode . "8.0.0")) - -(defcustom lsp-apply-edits-after-file-operations t - "Whether to apply edits returned by server after file operations if any. -Applicable only if server supports workspace.fileOperations for operations: -`workspace/willRenameFiles', `workspace/willCreateFiles' and -`workspace/willDeleteFiles'." - :group 'lsp-mode - :type 'boolean) - -(defcustom lsp-modeline-code-actions-enable t - "Whether to show code actions on modeline." - :type 'boolean - :group 'lsp-modeline) - -(defcustom lsp-modeline-diagnostics-enable t - "Whether to show diagnostics on modeline." - :type 'boolean - :group 'lsp-modeline) - -(defcustom lsp-modeline-workspace-status-enable t - "Whether to show workspace status on modeline." - :type 'boolean - :group 'lsp-modeline - :package-version '(lsp-mode . "8.0.0")) - -(defcustom lsp-headerline-breadcrumb-enable t - "Whether to enable breadcrumb on headerline." - :type 'boolean - :group 'lsp-headerline) - -(defcustom lsp-configure-hook nil - "Hooks to run when `lsp-configure-buffer' is called." - :type 'hook - :group 'lsp-mode) - -(defcustom lsp-unconfigure-hook nil - "Hooks to run when `lsp-unconfig-buffer' is called." - :type 'hook - :group 'lsp-mode) - -(defcustom lsp-after-diagnostics-hook nil - "Hooks to run after diagnostics are received. -Note: it runs only if the receiving buffer is open. Use -`lsp-diagnostics-updated-hook'if you want to be notified when -diagnostics have changed." - :type 'hook - :group 'lsp-mode) - -(define-obsolete-variable-alias 'lsp-after-diagnostics-hook - 'lsp-diagnostics-updated-hook "lsp-mode 6.4") - -(defcustom lsp-diagnostics-updated-hook nil - "Hooks to run after diagnostics are received." - :type 'hook - :group 'lsp-mode) - -(define-obsolete-variable-alias 'lsp-workspace-folders-changed-hook - 'lsp-workspace-folders-changed-functions "lsp-mode 6.3") - -(defcustom lsp-workspace-folders-changed-functions nil - "Hooks to run after the folders has changed. -The hook will receive two parameters list of added and removed folders." - :type 'hook - :group 'lsp-mode) - -(define-obsolete-variable-alias 'lsp-eldoc-hook 'eldoc-documentation-functions "lsp-mode 9.0.0") - -(defcustom lsp-before-apply-edits-hook nil - "Hooks to run before applying edits." - :type 'hook - :group 'lsp-mode) - -(defgroup lsp-imenu nil - "LSP Imenu." - :group 'lsp-mode - :tag "LSP Imenu") - -(defcustom lsp-imenu-show-container-name t - "Display the symbol's container name in an imenu entry." - :type 'boolean - :group 'lsp-imenu) - -(defcustom lsp-imenu-container-name-separator "/" - "Separator string to use to separate the container name from the symbol while -displaying imenu entries." - :type 'string - :group 'lsp-imenu) - -(defcustom lsp-imenu-sort-methods '(kind name) - "How to sort the imenu items. - -The value is a list of `kind' `name' or `position'. Priorities -are determined by the index of the element." - :type '(repeat (choice (const name) - (const position) - (const kind))) - :group 'lsp-imenu) - -(defcustom lsp-imenu-index-symbol-kinds nil - "Which symbol kinds to show in imenu." - :type '(repeat (choice (const :tag "Miscellaneous" nil) - (const :tag "File" File) - (const :tag "Module" Module) - (const :tag "Namespace" Namespace) - (const :tag "Package" Package) - (const :tag "Class" Class) - (const :tag "Method" Method) - (const :tag "Property" Property) - (const :tag "Field" Field) - (const :tag "Constructor" Constructor) - (const :tag "Enum" Enum) - (const :tag "Interface" Interface) - (const :tag "Function" Function) - (const :tag "Variable" Variable) - (const :tag "Constant" Constant) - (const :tag "String" String) - (const :tag "Number" Number) - (const :tag "Boolean" Boolean) - (const :tag "Array" Array) - (const :tag "Object" Object) - (const :tag "Key" Key) - (const :tag "Null" Null) - (const :tag "Enum Member" EnumMember) - (const :tag "Struct" Struct) - (const :tag "Event" Event) - (const :tag "Operator" Operator) - (const :tag "Type Parameter" TypeParameter))) - :group 'lsp-imenu) - -;; vibhavp: Should we use a lower value (5)? -(defcustom lsp-response-timeout 10 - "Number of seconds to wait for a response from the language server before -timing out. Nil if no timeout." - :type '(choice - (number :tag "Seconds") - (const :tag "No timeout" nil)) - :group 'lsp-mode) - -(defcustom lsp-tcp-connection-timeout 2 - "The timeout for tcp connection in seconds." - :type 'number - :group 'lsp-mode - :package-version '(lsp-mode . "6.2")) - -(defconst lsp--imenu-compare-function-alist - (list (cons 'name #'lsp--imenu-compare-name) - (cons 'kind #'lsp--imenu-compare-kind) - (cons 'position #'lsp--imenu-compare-line-col)) - "An alist of (METHOD . FUNCTION). -METHOD is one of the symbols accepted by -`lsp-imenu-sort-methods'. - -FUNCTION takes two hash tables representing DocumentSymbol. It -returns a negative number, 0, or a positive number indicating -whether the first parameter is less than, equal to, or greater -than the second parameter.") - -(defcustom lsp-diagnostic-clean-after-change nil - "When non-nil, clean the diagnostics on change. - -Note that when that setting is nil, `lsp-mode' will show stale -diagnostics until server publishes the new set of diagnostics" - :type 'boolean - :group 'lsp-diagnostics - :package-version '(lsp-mode . "7.0.1")) - -(defcustom lsp-server-trace nil - "Request tracing on the server side. -The actual trace output at each level depends on the language server in use. -Changes take effect only when a new session is started." - :type '(choice (const :tag "Disabled" "off") - (const :tag "Messages only" "messages") - (const :tag "Verbose" "verbose") - (const :tag "Default (disabled)" nil)) - :group 'lsp-mode - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-auto-touch-files t - "If non-nil ensure the files exist before sending -`textDocument/didOpen' notification." - :type 'boolean - :group 'lsp-mode - :package-version '(lsp-mode . "9.0.0")) - -(defvar lsp-language-id-configuration - '(("\\(^CMakeLists\\.txt\\|\\.cmake\\)\\'" . "cmake") - ("\\(^Dockerfile\\(?:\\..*\\)?\\|\\.[Dd]ockerfile\\)\\'" . "dockerfile") - ("\\.astro$" . "astro") - ("\\.cs\\'" . "csharp") - ("\\.css$" . "css") - ("\\.cypher$" . "cypher") - ("\\.ebuild$" . "shellscript") - ("\\.go\\'" . "go") - ("\\.html$" . "html") - ("\\.hx$" . "haxe") - ("\\.hy$" . "hy") - ("\\.java\\'" . "java") - ("\\.jq$" . "jq") - ("\\.js$" . "javascript") - ("\\.json$" . "json") - ("\\.jsonc$" . "jsonc") - ("\\.jsonnet$" . "jsonnet") - ("\\.jsx$" . "javascriptreact") - ("\\.lua$" . "lua") - ("\\.mdx\\'" . "mdx") - ("\\.nu$" . "nushell") - ("\\.php$" . "php") - ("\\.ps[dm]?1\\'" . "powershell") - ("\\.rs\\'" . "rust") - ("\\.spec\\'" . "rpm-spec") - ("\\.sql$" . "sql") - ("\\.svelte$" . "svelte") - ("\\.toml\\'" . "toml") - ("\\.ts$" . "typescript") - ("\\.tsx$" . "typescriptreact") - ("\\.ttcn3$" . "ttcn3") - ("\\.vue$" . "vue") - ("\\.xml$" . "xml") - ("\\ya?ml$" . "yaml") - ("^PKGBUILD$" . "shellscript") - ("^go\\.mod\\'" . "go.mod") - ("^settings\\.json$" . "jsonc") - ("^yang\\.settings$" . "jsonc") - ("^meson\\(_options\\.txt\\|\\.\\(build\\|format\\)\\)\\'" . "meson") - (ada-mode . "ada") - (ada-ts-mode . "ada") - (gpr-mode . "gpr") - (gpr-ts-mode . "gpr") - (awk-mode . "awk") - (awk-ts-mode . "awk") - (nxml-mode . "xml") - (sql-mode . "sql") - (vimrc-mode . "vim") - (vimscript-ts-mode . "vim") - (sh-mode . "shellscript") - (bash-ts-mode . "shellscript") - (ebuild-mode . "shellscript") - (pkgbuild-mode . "shellscript") - (envrc-file-mode . "shellscript") - (scala-mode . "scala") - (scala-ts-mode . "scala") - (julia-mode . "julia") - (julia-ts-mode . "julia") - (clojure-mode . "clojure") - (clojurec-mode . "clojure") - (clojurescript-mode . "clojurescript") - (clojure-ts-mode . "clojure") - (clojure-ts-clojurec-mode . "clojure") - (clojure-ts-clojurescript-mode . "clojurescript") - (java-mode . "java") - (java-ts-mode . "java") - (jdee-mode . "java") - (groovy-mode . "groovy") - (python-mode . "python") - (python-ts-mode . "python") - (cython-mode . "python") - ("\\(\\.mojo\\|\\.🔥\\)\\'" . "mojo") - (lsp--render-markdown . "markdown") - (move-mode . "move") - (rust-mode . "rust") - (rust-ts-mode . "rust") - (rustic-mode . "rust") - (kotlin-mode . "kotlin") - (kotlin-ts-mode . "kotlin") - (css-mode . "css") - (css-ts-mode . "css") - (less-mode . "less") - (less-css-mode . "less") - (lua-mode . "lua") - (lua-ts-mode . "lua") - (sass-mode . "sass") - (ssass-mode . "sass") - (scss-mode . "scss") - (scad-mode . "openscad") - (xml-mode . "xml") - (c-mode . "c") - (c-ts-mode . "c") - (c++-mode . "cpp") - (c++-ts-mode . "cpp") - (cuda-mode . "cuda") - (objc-mode . "objective-c") - (html-mode . "html") - (html-ts-mode . "html") - (sgml-mode . "html") - (mhtml-mode . "html") - (mint-mode . "mint") - (go-dot-mod-mode . "go.mod") - (go-mod-ts-mode . "go.mod") - (go-mode . "go") - (go-ts-mode . "go") - (graphql-mode . "graphql") - (haskell-mode . "haskell") - (hack-mode . "hack") - (php-mode . "php") - (php-ts-mode . "php") - (powershell-mode . "powershell") - (powershell-mode . "PowerShell") - (powershell-ts-mode . "powershell") - (json-mode . "json") - (json-ts-mode . "json") - (jsonc-mode . "jsonc") - (rjsx-mode . "javascript") - (js2-mode . "javascript") - (js-mode . "javascript") - (js-ts-mode . "javascript") - (typescript-mode . "typescript") - (typescript-ts-mode . "typescript") - (tsx-ts-mode . "typescriptreact") - (svelte-mode . "svelte") - (fsharp-mode . "fsharp") - (reason-mode . "reason") - (caml-mode . "ocaml") - (tuareg-mode . "ocaml") - (swift-mode . "swift") - (elixir-mode . "elixir") - (elixir-ts-mode . "elixir") - (heex-ts-mode . "elixir") - (conf-javaprop-mode . "spring-boot-properties") - (yaml-mode . "yaml") - (yaml-ts-mode . "yaml") - (ruby-mode . "ruby") - (enh-ruby-mode . "ruby") - (ruby-ts-mode . "ruby") - (fortran-mode . "fortran") - (f90-mode . "fortran") - (elm-mode . "elm") - (dart-mode . "dart") - (erlang-mode . "erlang") - (dockerfile-mode . "dockerfile") - (dockerfile-ts-mode . "dockerfile") - (csharp-mode . "csharp") - (csharp-tree-sitter-mode . "csharp") - (csharp-ts-mode . "csharp") - (plain-tex-mode . "plaintex") - (context-mode . "context") - (cypher-mode . "cypher") - (latex-mode . "latex") - (v-mode . "v") - (vhdl-mode . "vhdl") - (vhdl-ts-mode . "vhdl") - (verilog-mode . "verilog") - (terraform-mode . "terraform") - (ess-julia-mode . "julia") - (ess-r-mode . "r") - (crystal-mode . "crystal") - (nim-mode . "nim") - (dhall-mode . "dhall") - (cmake-mode . "cmake") - (cmake-ts-mode . "cmake") - (purescript-mode . "purescript") - (gdscript-mode . "gdscript") - (gdscript-ts-mode . "gdscript") - (perl-mode . "perl") - (cperl-mode . "perl") - (robot-mode . "robot") - (racket-mode . "racket") - (nix-mode . "nix") - (nix-ts-mode . "Nix") - (prolog-mode . "prolog") - (vala-mode . "vala") - (actionscript-mode . "actionscript") - (d-mode . "d") - (zig-mode . "zig") - (text-mode . "plaintext") - (markdown-mode . "markdown") - (gfm-mode . "markdown") - (beancount-mode . "beancount") - (conf-toml-mode . "toml") - (toml-ts-mode . "toml") - (org-mode . "org") - (org-journal-mode . "org") - (nginx-mode . "nginx") - (magik-mode . "magik") - (magik-ts-mode . "magik") - (idris-mode . "idris") - (idris2-mode . "idris2") - (gleam-mode . "gleam") - (graphviz-dot-mode . "dot") - (tiltfile-mode . "tiltfile") - (solidity-mode . "solidity") - (bibtex-mode . "bibtex") - (rst-mode . "restructuredtext") - (glsl-mode . "glsl") - (shader-mode . "shaderlab") - (wgsl-mode . "wgsl") - (jq-mode . "jq") - (jq-ts-mode . "jq") - (protobuf-mode . "protobuf") - (nushell-mode . "nushell") - (nushell-ts-mode . "nushell") - (meson-mode . "meson") - (yang-mode . "yang")) - "Language id configuration.") - -(defvar lsp--last-active-workspaces nil - "Keep track of last active workspace. -We want to try the last workspace first when jumping into a library -directory") - -(defvar lsp-method-requirements - '(("textDocument/callHierarchy" :capability :callHierarchyProvider) - ("textDocument/codeAction" :capability :codeActionProvider) - ("codeAction/resolve" - :check-command (lambda (workspace) - (with-lsp-workspace workspace - (lsp:code-action-options-resolve-provider? - (lsp--capability-for-method "textDocument/codeAction"))))) - ("textDocument/codeLens" :capability :codeLensProvider) - ("textDocument/completion" :capability :completionProvider) - ("completionItem/resolve" - :check-command (lambda (wk) - (with-lsp-workspace wk - (lsp:completion-options-resolve-provider? - (lsp--capability-for-method "textDocument/completion"))))) - ("textDocument/declaration" :capability :declarationProvider) - ("textDocument/definition" :capability :definitionProvider) - ("textDocument/documentColor" :capability :colorProvider) - ("textDocument/documentLink" :capability :documentLinkProvider) - ("textDocument/inlayHint" :capability :inlayHintProvider) - ("textDocument/documentHighlight" :capability :documentHighlightProvider) - ("textDocument/documentSymbol" :capability :documentSymbolProvider) - ("textDocument/foldingRange" :capability :foldingRangeProvider) - ("textDocument/formatting" :capability :documentFormattingProvider) - ("textDocument/hover" :capability :hoverProvider) - ("textDocument/implementation" :capability :implementationProvider) - ("textDocument/linkedEditingRange" :capability :linkedEditingRangeProvider) - ("textDocument/onTypeFormatting" :capability :documentOnTypeFormattingProvider) - ("textDocument/prepareRename" - :check-command (lambda (workspace) - (with-lsp-workspace workspace - (lsp:rename-options-prepare-provider? - (lsp--capability-for-method "textDocument/rename"))))) - ("textDocument/rangeFormatting" :capability :documentRangeFormattingProvider) - ("textDocument/references" :capability :referencesProvider) - ("textDocument/rename" :capability :renameProvider) - ("textDocument/selectionRange" :capability :selectionRangeProvider) - ("textDocument/semanticTokens" :capability :semanticTokensProvider) - ("textDocument/semanticTokensFull" - :check-command (lambda (workspace) - (with-lsp-workspace workspace - (lsp-get (lsp--capability :semanticTokensProvider) :full)))) - ("textDocument/semanticTokensFull/Delta" - :check-command (lambda (workspace) - (with-lsp-workspace workspace - (let ((capFull (lsp-get (lsp--capability :semanticTokensProvider) :full))) - (and (not (booleanp capFull)) (lsp-get capFull :delta)))))) - ("textDocument/semanticTokensRangeProvider" - :check-command (lambda (workspace) - (with-lsp-workspace workspace - (lsp-get (lsp--capability :semanticTokensProvider) :range)))) - ("textDocument/signatureHelp" :capability :signatureHelpProvider) - ("textDocument/typeDefinition" :capability :typeDefinitionProvider) - ("textDocument/typeHierarchy" :capability :typeHierarchyProvider) - ("workspace/executeCommand" :capability :executeCommandProvider) - ("workspace/symbol" :capability :workspaceSymbolProvider)) - - "Map methods to requirements. -It is used by request-sending functions to determine which server -must be used for handling a particular message.") - -(defconst lsp--file-change-type - `((created . 1) - (changed . 2) - (deleted . 3))) - -(defconst lsp--watch-kind - `((create . 1) - (change . 2) - (delete . 4))) - -(defvar lsp-window-body-width 40 - "Window body width when rendering doc.") - -(defface lsp-face-highlight-textual - '((t :inherit highlight)) - "Face used for textual occurrences of symbols." - :group 'lsp-mode) - -(defface lsp-face-highlight-read - '((t :inherit highlight :underline t)) - "Face used for highlighting symbols being read." - :group 'lsp-mode) - -(defface lsp-face-highlight-write - '((t :inherit highlight :weight bold)) - "Face used for highlighting symbols being written to." - :group 'lsp-mode) - -(define-obsolete-variable-alias 'lsp-lens-auto-enable - 'lsp-lens-enable "lsp-mode 7.0.1") - -(defcustom lsp-lens-enable t - "Auto enable lenses if server supports." - :group 'lsp-lens - :type 'boolean - :package-version '(lsp-mode . "6.3")) - -(defcustom lsp-symbol-highlighting-skip-current nil - "If non-nil skip current symbol when setting symbol highlights." - :group 'lsp-mode - :type 'boolean) - -(defcustom lsp-file-watch-threshold 1000 - "Show warning if the files to watch are more than. -Set to nil to disable the warning." - :type 'number - :group 'lsp-mode) -;;;###autoload(put 'lsp-file-watch-threshold 'safe-local-variable (lambda (i) (or (numberp i) (not i)))) - -(defvar lsp-custom-markup-modes - '((rust-mode "no_run" "rust,no_run" "rust,ignore" "rust,should_panic")) - "Mode to uses with markdown code blocks. -They are added to `markdown-code-lang-modes'") - -(defcustom lsp-signature-render-documentation t - "Display signature documentation in `eldoc'." - :type 'boolean - :group 'lsp-mode - :package-version '(lsp-mode . "6.2")) - -(defcustom lsp-signature-auto-activate '(:on-trigger-char :on-server-request) - "Auto activate signature conditions." - :type '(repeat (choice (const :tag "On trigger chars pressed." :on-trigger-char) - (const :tag "After selected completion." :after-completion) - (const :tag "When the server has sent show signature help." :on-server-request))) - :group 'lsp-mode - :package-version '(lsp-mode . "6.2")) - -(defcustom lsp-signature-doc-lines 20 - "If number, limit the number of lines to show in the docs." - :type 'number - :group 'lsp-mode - :package-version '(lsp-mode . "6.3")) - -(defcustom lsp-signature-function 'lsp-lv-message - "The function used for displaying signature info. -It will be called with one param - the signature info. When -called with nil the signature info must be cleared." - :type 'function - :group 'lsp-mode - :package-version '(lsp-mode . "6.3")) - -(defcustom lsp-keymap-prefix "s-l" - "LSP-mode keymap prefix." - :group 'lsp-mode - :type 'string - :package-version '(lsp-mode . "6.3")) - -(defvar-local lsp--buffer-workspaces () - "List of the buffer workspaces.") - -(defvar-local lsp--buffer-deferred nil - "Whether buffer was loaded via `lsp-deferred'.") - -(defvar lsp--session nil - "Contain the `lsp-session' for the current Emacs instance.") - -(defvar lsp--tcp-port 10000) - -(defvar lsp--client-packages-required nil - "If nil, `lsp-client-packages' are yet to be required.") - -(defvar lsp--tcp-server-port 0 - "The server socket which is opened when using `lsp-tcp-server' (a server -socket is opened in Emacs and the language server connects to it). The -default value of 0 ensures that a random high port is used. Set it to a positive -integer to use a specific port.") - -(defvar lsp--tcp-server-wait-seconds 10 - "Wait this amount of time for the client to connect to our server socket -when using `lsp-tcp-server'.") - -(defvar-local lsp--document-symbols nil - "The latest document symbols.") - -(defvar-local lsp--document-selection-range-cache nil - "The document selection cache.") - -(defvar-local lsp--document-symbols-request-async nil - "If non-nil, request document symbols asynchronously.") - -(defvar-local lsp--document-symbols-tick -1 - "The value of `buffer-chars-modified-tick' when document - symbols were last retrieved.") - -(defvar-local lsp--have-document-highlights nil - "Set to `t' on symbol highlighting, cleared on -`lsp--cleanup-highlights-if-needed'. Checking a separately -defined flag is substantially faster than unconditionally -calling `remove-overlays'.") - -;; Buffer local variable for storing number of lines. -(defvar lsp--log-lines) - -(defvar-local lsp--eldoc-saved-message nil) - -(defvar lsp--on-change-timer nil) -(defvar lsp--on-idle-timer nil) - -(defvar-local lsp--signature-last nil) -(defvar-local lsp--signature-last-index nil) -(defvar lsp--signature-last-buffer nil) - -(defvar-local lsp--virtual-buffer-point-max nil) - -(cl-defmethod lsp-execute-command (_server _command _arguments) - "Ask SERVER to execute COMMAND with ARGUMENTS.") - -(defun lsp-elt (sequence n) - "Return Nth element of SEQUENCE or nil if N is out of range." - (cond - ((listp sequence) (elt sequence n)) - ((arrayp sequence) - (and (> (length sequence) n) (aref sequence n))) - (t (and (> (length sequence) n) (elt sequence n))))) - -;; define seq-first and seq-rest for older emacs -(defun lsp-seq-first (sequence) - "Return the first element of SEQUENCE." - (lsp-elt sequence 0)) - -(defun lsp-seq-rest (sequence) - "Return a sequence of the elements of SEQUENCE except the first one." - (seq-drop sequence 1)) - -;;;###autoload -(defun lsp--string-listp (sequence) - "Return t if all elements of SEQUENCE are strings, else nil." - (not (seq-find (lambda (x) (not (stringp x))) sequence))) - -(defun lsp--string-vector-p (candidate) - "Returns true if CANDIDATE is a vector data structure and -every element of it is of type string, else nil." - (and - (vectorp candidate) - (seq-every-p #'stringp candidate))) - -(make-obsolete 'lsp--string-vector-p nil "lsp-mode 8.0.0") - -(defun lsp--editable-vector-match (widget value) - "Function for `lsp-editable-vector' :match." - ;; Value must be a list or a vector and all the members must match the type. - (and (or (listp value) (vectorp value)) - (length (cdr (lsp--editable-vector-match-inline widget value))))) - -(defun lsp--editable-vector-match-inline (widget value) - "Value for `lsp-editable-vector' :match-inline." - (let ((type (nth 0 (widget-get widget :args))) - (ok t) - found) - (while (and value ok) - (let ((answer (widget-match-inline type value))) - (if answer - (let ((head (if (vectorp answer) (aref answer 0) (car answer))) - (tail (if (vectorp answer) (seq-drop 1 answer) (cdr answer)))) - (setq found (append found head) - value tail)) - (setq ok nil)))) - (cons found value))) - -(defun lsp--editable-vector-value-to-external (_widget internal-value) - "Convert the internal list value to a vector." - (if (listp internal-value) - (apply 'vector internal-value) - internal-value)) - -(defun lsp--editable-vector-value-to-internal (_widget external-value) - "Convert the external vector value to a list." - (if (vectorp external-value) - (append external-value nil) - external-value)) - -(define-widget 'lsp--editable-vector 'editable-list - "A subclass of `editable-list' that accepts and returns a -vector instead of a list." - :value-to-external 'lsp--editable-vector-value-to-external - :value-to-internal 'lsp--editable-vector-value-to-internal - :match 'lsp--editable-vector-match - :match-inline 'lsp--editable-vector-match-inline) - -(define-widget 'lsp-repeatable-vector 'lsp--editable-vector - "A variable length homogeneous vector." - :tag "Repeat" - :format "%{%t%}:\n%v%i\n") - -(define-widget 'lsp-string-vector 'lazy - "A vector of zero or more elements, every element of which is a string. -Appropriate for any language-specific `defcustom' that needs to -serialize as a JSON array of strings. - -Deprecated. Use `lsp-repeatable-vector' instead. " - :offset 4 - :tag "Vector" - :type '(lsp-repeatable-vector string)) - -(make-obsolete 'lsp-string-vector nil "lsp-mode 8.0.0") - -(defvar lsp--show-message t - "If non-nil, show debug message from `lsp-mode'.") - -(defun lsp--message (format &rest args) - "Wrapper for `message' - -We `inhibit-message' the message when the cursor is in the -minibuffer and when emacs version is before emacs 27 due to the -fact that we often use `lsp--info', `lsp--warn' and `lsp--error' -in async context and the call to these function is removing the -minibuffer prompt. The issue with async messages is already fixed -in emacs 27. - -See #2049" - (when lsp--show-message - (let ((inhibit-message (or inhibit-message - (and (minibufferp) - (version< emacs-version "27.0"))))) - (apply #'message format args)))) - -(defun lsp--info (format &rest args) - "Display lsp info message with FORMAT with ARGS." - (lsp--message "%s :: %s" (propertize "LSP" 'face 'success) (apply #'format format args))) - -(defun lsp--warn (format &rest args) - "Display lsp warn message with FORMAT with ARGS." - (lsp--message "%s :: %s" (propertize "LSP" 'face 'warning) (apply #'format format args))) - -(defun lsp--error (format &rest args) - "Display lsp error message with FORMAT with ARGS." - (lsp--message "%s :: %s" (propertize "LSP" 'face 'error) (apply #'format format args))) - -(defun lsp-log (format &rest args) - "Log message to the ’*lsp-log*’ buffer. - -FORMAT and ARGS i the same as for `message'." - (when lsp-log-max - (let ((log-buffer (get-buffer "*lsp-log*")) - (inhibit-read-only t)) - (unless log-buffer - (setq log-buffer (get-buffer-create "*lsp-log*")) - (with-current-buffer log-buffer - (buffer-disable-undo) - (view-mode 1) - (set (make-local-variable 'lsp--log-lines) 0))) - (with-current-buffer log-buffer - (save-excursion - (let* ((message (apply 'format format args)) - ;; Count newlines in message. - (newlines (1+ (cl-loop with start = 0 - for count from 0 - while (string-match "\n" message start) - do (setq start (match-end 0)) - finally return count)))) - (goto-char (point-max)) - - ;; in case the buffer is not empty insert before last \n to preserve - ;; the point position(in case it is in the end) - (if (eq (point) (point-min)) - (progn - (insert "\n") - (backward-char)) - (backward-char) - (insert "\n")) - (insert message) - - (setq lsp--log-lines (+ lsp--log-lines newlines)) - - (when (and (integerp lsp-log-max) (> lsp--log-lines lsp-log-max)) - (let ((to-delete (- lsp--log-lines lsp-log-max))) - (goto-char (point-min)) - (forward-line to-delete) - (delete-region (point-min) (point)) - (setq lsp--log-lines lsp-log-max))))))))) - -(defalias 'lsp-message 'lsp-log) - -(defalias 'lsp-ht 'ht) - -(defalias 'lsp-file-local-name 'file-local-name) - -(defun lsp-f-canonical (file-name) - "Return the canonical FILE-NAME, without a trailing slash." - (directory-file-name (expand-file-name file-name))) - -(defalias 'lsp-canonical-file-name 'lsp-f-canonical) - -(defun lsp-f-same? (path-a path-b) - "Return t if PATH-A and PATH-B are references to the same file. -Symlinks are not followed." - (when (and (f-exists? path-a) - (f-exists? path-b)) - (equal - (lsp-f-canonical (directory-file-name (f-expand path-a))) - (lsp-f-canonical (directory-file-name (f-expand path-b)))))) - -(defun lsp-f-parent (path) - "Return the parent directory to PATH. -Symlinks are not followed." - (let ((parent (file-name-directory - (directory-file-name (f-expand path default-directory))))) - (unless (lsp-f-same? path parent) - (if (f-relative? path) - (f-relative parent) - (directory-file-name parent))))) - -(defun lsp-f-ancestor-of? (path-a path-b) - "Return t if PATH-A is an ancestor of PATH-B. -Symlinks are not followed." - (unless (lsp-f-same? path-a path-b) - (s-prefix? (concat (lsp-f-canonical path-a) (f-path-separator)) - (lsp-f-canonical path-b)))) - -(defun lsp--merge-results (results method) - "Merge RESULTS by filtering the empty hash-tables and merging -the lists according to METHOD." - (pcase (--map (if (vectorp it) - (append it nil) it) - (-filter #'identity results)) - (`() ()) - ;; only one result - simply return it - (`(,fst) fst) - ;; multiple results merge it based on strategy - (results - (pcase method - ("textDocument/hover" (pcase (seq-filter - (-compose #'not #'lsp-empty?) - results) - (`(,hover) hover) - (hovers (lsp-make-hover - :contents - (-mapcat - (-lambda ((&Hover :contents)) - (if (and (sequencep contents) - (not (stringp contents))) - (append contents ()) - (list contents))) - hovers))))) - ("textDocument/completion" - (lsp-make-completion-list - :is-incomplete (seq-some - #'lsp:completion-list-is-incomplete - results) - :items (cl-mapcan (lambda (it) (append (if (lsp-completion-list? it) - (lsp:completion-list-items it) - it) - nil)) - results))) - ("completionItem/resolve" - (let ((item (cl-first results))) - (when-let ((details (seq-filter #'identity - (seq-map #'lsp:completion-item-detail? results)))) - (lsp:set-completion-item-detail? - item - (string-join details " "))) - (when-let ((docs (seq-filter #'identity - (seq-map #'lsp:completion-item-documentation? results)))) - (lsp:set-completion-item-documentation? - item - (lsp-make-markup-content - :kind (or (seq-some (lambda (it) - (when (equal (lsp:markup-content-kind it) - lsp/markup-kind-markdown) - lsp/markup-kind-markdown)) - docs) - lsp/markup-kind-plain-text) - :value (string-join (seq-map (lambda (doc) - (or (lsp:markup-content-value doc) - (and (stringp doc) doc))) - docs) - "\n")))) - (when-let ((edits (seq-filter #'identity - (seq-map #'lsp:completion-item-additional-text-edits? results)))) - (lsp:set-completion-item-additional-text-edits? - item - (cl-mapcan (lambda (it) (if (seqp it) it (list it))) edits))) - item)) - (_ (cl-mapcan (lambda (it) (if (seqp it) it (list it))) results)))))) - -(defun lsp--spinner-start () - "Start spinner indication." - (condition-case _err (spinner-start (lsp-progress-spinner-type)) (error))) - -(defun lsp--propertize (str type) - "Propertize STR as per TYPE." - (propertize str 'face (alist-get type lsp--message-type-face))) - -(defun lsp-workspaces () - "Return the lsp workspaces associated with the current project." - (if lsp--cur-workspace (list lsp--cur-workspace) lsp--buffer-workspaces)) - -(defun lsp--completing-read (prompt collection transform-fn &optional predicate - require-match initial-input - hist def inherit-input-method) - "Wrap `completing-read' to provide transformation function and disable sort. - -TRANSFORM-FN will be used to transform each of the items before displaying. - -PROMPT COLLECTION PREDICATE REQUIRE-MATCH INITIAL-INPUT HIST DEF -INHERIT-INPUT-METHOD will be proxied to `completing-read' without changes." - (let* ((col (--map (cons (funcall transform-fn it) it) collection)) - (completion (completing-read prompt - (lambda (string pred action) - (if (eq action 'metadata) - `(metadata (display-sort-function . identity)) - (complete-with-action action col string pred))) - predicate require-match initial-input hist - def inherit-input-method))) - (cdr (assoc completion col)))) - -(defconst lsp--system-arch (lambda () - (setq lsp--system-arch - (pcase system-type - ('windows-nt - (pcase system-configuration - ((rx bol "x86_64-") 'x64) - (_ 'x86))) - ('darwin - (pcase system-configuration - ((rx "aarch64-") 'arm64) - (_ 'x64))) - ('gnu/linux - (pcase system-configuration - ((rx bol "x86_64") 'x64) - ((rx bol (| "i386" "i886")) 'x32))) - (_ - (pcase system-configuration - ((rx bol "x86_64") 'x64) - ((rx bol (| "i386" "i886")) 'x32)))))) - "Return the system architecture of `Emacs'. -Special values: - `x64' 64bit - `x32' 32bit - `arm64' ARM 64bit") - -(defmacro lsp-with-current-buffer (buffer-id &rest body) - (declare (indent 1) (debug t)) - `(if-let ((wcb (plist-get ,buffer-id :with-current-buffer))) - (with-lsp-workspaces (plist-get ,buffer-id :workspaces) - (funcall wcb (lambda () ,@body))) - (with-current-buffer ,buffer-id - ,@body))) - -(defvar lsp--throw-on-input nil - "Make `lsp-*-while-no-input' throws `input' on interrupted.") - -(defmacro lsp--catch (tag bodyform &rest handlers) - "Catch TAG thrown in BODYFORM. -The return value from TAG will be handled in HANDLERS by `pcase'." - (declare (debug (form form &rest (pcase-PAT body))) (indent 2)) - (let ((re-sym (make-symbol "re"))) - `(let ((,re-sym (catch ,tag ,bodyform))) - (pcase ,re-sym - ,@handlers)))) - -(defmacro lsp--while-no-input (&rest body) - "Wrap BODY in `while-no-input' and respecting `non-essential'. -If `lsp--throw-on-input' is set, will throw if input is pending, else -return value of `body' or nil if interrupted." - (declare (debug t) (indent 0)) - `(if non-essential - (let ((res (while-no-input ,@body))) - (cond - ((and lsp--throw-on-input (equal res t)) - (throw 'input :interrupted)) - ((booleanp res) nil) - (t res))) - ,@body)) - -;; A ‘lsp--client’ object describes the client-side behavior of a language -;; server. It is used to start individual server processes, each of which is -;; represented by a ‘lsp--workspace’ object. Client objects are normally -;; created using ‘lsp-define-stdio-client’ or ‘lsp-define-tcp-client’. Each -;; workspace refers to exactly one client, but there can be multiple workspaces -;; for a single client. -(cl-defstruct lsp--client - ;; ‘language-id’ is a function that receives a buffer as a single argument - ;; and should return the language identifier for that buffer. See - ;; https://microsoft.github.io/language-server-protocol/specification#textdocumentitem - ;; for a list of language identifiers. Also consult the documentation for - ;; the language server represented by this client to find out what language - ;; identifiers it supports or expects. - (language-id nil) - - ;; ‘add-on?’ when set to t the server will be started no matter whether there - ;; is another server handling the same mode. - (add-on? nil) - ;; ‘new-connection’ is a function that should start a language server process - ;; and return a cons (COMMAND-PROCESS . COMMUNICATION-PROCESS). - ;; COMMAND-PROCESS must be a process object representing the server process - ;; just started. COMMUNICATION-PROCESS must be a process (including pipe and - ;; network processes) that ‘lsp-mode’ uses to communicate with the language - ;; server using the language server protocol. COMMAND-PROCESS and - ;; COMMUNICATION-PROCESS may be the same process; in that case - ;; ‘new-connection’ may also return that process as a single - ;; object. ‘new-connection’ is called with two arguments, FILTER and - ;; SENTINEL. FILTER should be used as process filter for - ;; COMMUNICATION-PROCESS, and SENTINEL should be used as process sentinel for - ;; COMMAND-PROCESS. - (new-connection nil) - - ;; ‘ignore-regexps’ is a list of regexps. When a data packet from the - ;; language server matches any of these regexps, it will be ignored. This is - ;; intended for dealing with language servers that output non-protocol data. - (ignore-regexps nil) - - ;; ‘ignore-messages’ is a list of regexps. When a message from the language - ;; server matches any of these regexps, it will be ignored. This is useful - ;; for filtering out unwanted messages; such as servers that send nonstandard - ;; message types, or extraneous log messages. - (ignore-messages nil) - - ;; ‘notification-handlers’ is a hash table mapping notification method names - ;; (strings) to functions handling the respective notifications. Upon - ;; receiving a notification, ‘lsp-mode’ will call the associated handler - ;; function passing two arguments, the ‘lsp--workspace’ object and the - ;; deserialized notification parameters. - (notification-handlers (make-hash-table :test 'equal)) - - ;; ‘request-handlers’ is a hash table mapping request method names - ;; (strings) to functions handling the respective notifications. Upon - ;; receiving a request, ‘lsp-mode’ will call the associated handler function - ;; passing two arguments, the ‘lsp--workspace’ object and the deserialized - ;; request parameters. - (request-handlers (make-hash-table :test 'equal)) - - ;; ‘response-handlers’ is a hash table mapping integral JSON-RPC request - ;; identifiers for pending asynchronous requests to functions handling the - ;; respective responses. Upon receiving a response from the language server, - ;; ‘lsp-mode’ will call the associated response handler function with a - ;; single argument, the deserialized response parameters. - (response-handlers (make-hash-table :test 'eql)) - - ;; ‘prefix-function’ is called for getting the prefix for completion. - ;; The function takes no parameter and returns a cons (start . end) representing - ;; the start and end bounds of the prefix. If it's not set, the client uses a - ;; default prefix function." - (prefix-function nil) - - ;; Contains mapping of scheme to the function that is going to be used to load - ;; the file. - (uri-handlers (make-hash-table :test #'equal)) - - ;; ‘action-handlers’ is a hash table mapping action to a handler function. It - ;; can be used in `lsp-execute-code-action' to determine whether the action - ;; current client is interested in executing the action instead of sending it - ;; to the server. - (action-handlers (make-hash-table :test 'equal)) - - ;; major modes supported by the client. - major-modes - ;; Function that will be called to decide if this language client - ;; should manage a particular buffer. The function will be passed - ;; the file name and major mode to inform the decision. Setting - ;; `activation-fn' will override `major-modes', if - ;; present. - activation-fn - ;; Break the tie when major-mode is supported by multiple clients. - (priority 0) - ;; Unique identifier for representing the client object. - server-id - ;; defines whether the client supports multi root workspaces. - multi-root - ;; Initialization options or a function that returns initialization options. - initialization-options - ;; `semantic-tokens-faces-overrides’ is a plist that can be used to extend, or - ;; completely replace, the faces used for semantic highlighting on a - ;; client-by-client basis. - ;; - ;; It recognizes four members, all of which are optional: `:types’ and - ;; `:modifiers’, respectively, should be face definition lists akin to - ;; `:lsp-semantic-token-faces’. If specified, each of these face lists will be - ;; merged with the default face definition list. - ;; - ;; Alternatively, if the plist members `:discard-default-types’ or - ;; `:discard-default-modifiers' are non-nil, the default `:type' or `:modifiers' - ;; face definitions will be replaced entirely by their respective overrides. - ;; - ;; For example, setting `:semantic-tokens-faces-overrides' to - ;; `(:types (("macro" . font-lock-keyword-face)))' will remap "macro" tokens from - ;; their default face `lsp-face-semhl-macro' to `font-lock-keyword-face'. - ;; - ;; `(:types (("macro" . font-lock-keyword-face) ("not-quite-a-macro" . some-face)))' - ;; will also remap "macro", but on top of that associate the fictional token type - ;; "not-quite-a-macro" with the face named `some-face'. - ;; - ;; `(:types (("macro" . font-lock-keyword-face)) - ;; :modifiers (("declaration" . lsp-face-semhl-interface)) - ;; :discard-default-types t - ;; :discard-default-modifiers t)' - ;; will discard all default face definitions, hence leaving the client with - ;; only one token type "macro", mapped to `font-lock-keyword-face', and one - ;; modifier type "declaration", mapped to `lsp-face-semhl-interface'. - semantic-tokens-faces-overrides - ;; Provides support for registering LSP Server specific capabilities. - custom-capabilities - ;; Function which returns the folders that are considered to be not projects but library files. - ;; The function accepts one parameter currently active workspace. - ;; See: https://github.com/emacs-lsp/lsp-mode/issues/225. - library-folders-fn - ;; function which will be called when opening file in the workspace to perform - ;; client specific initialization. The function accepts one parameter - ;; currently active workspace. - before-file-open-fn - ;; Function which will be called right after a workspace has been initialized. - initialized-fn - ;; ‘remote?’ indicate whether the client can be used for LSP server over TRAMP. - (remote? nil) - - ;; ‘completion-in-comments?’ t if the client supports completion in comments. - (completion-in-comments? nil) - - ;; ‘path->uri-fn’ the function to use for path->uri conversion for the client. - (path->uri-fn nil) - - ;; ‘uri->path-fn’ the function to use for uri->path conversion for the client. - (uri->path-fn nil) - ;; Function that returns an environment structure that will be used - ;; to set some environment variables when starting the language - ;; server process. These environment variables enable some - ;; additional features in the language server. The environment - ;; structure is an alist of the form (KEY . VALUE), where KEY is a - ;; string (regularly in all caps), and VALUE may be a string, a - ;; boolean, or a sequence of strings. - environment-fn - - ;; ‘after-open-fn’ workspace after open specific hooks. - (after-open-fn nil) - - ;; ‘async-request-handlers’ is a hash table mapping request method names - ;; (strings) to functions handling the respective requests that may take - ;; time to finish. Upon receiving a request, ‘lsp-mode’ will call the - ;; associated handler function passing three arguments, the ‘lsp--workspace’ - ;; object, the deserialized request parameters and the callback which accept - ;; result as its parameter. - (async-request-handlers (make-hash-table :test 'equal)) - download-server-fn - download-in-progress? - buffers - synchronize-sections) - -(defun lsp-clients-executable-find (find-command &rest args) - "Finds an executable by invoking a search command. - -FIND-COMMAND is the executable finder that searches for the -actual language server executable. ARGS is a list of arguments to -give to FIND-COMMAND to find the language server. Returns the -output of FIND-COMMAND if it exits successfully, nil otherwise. - -Typical uses include finding an executable by invoking `find' in -a project, finding LLVM commands on macOS with `xcrun', or -looking up project-specific language servers for projects written -in the various dynamic languages, e.g. `nvm', `pyenv' and `rbenv' -etc." - (when-let* ((find-command-path (executable-find find-command)) - (executable-path - (with-temp-buffer - (when (zerop (apply 'call-process find-command-path nil t nil args)) - (buffer-substring-no-properties (point-min) (point-max)))))) - (string-trim executable-path))) - -(defvar lsp--already-widened nil) - -(defmacro lsp-save-restriction-and-excursion (&rest form) - (declare (indent 0) (debug t)) - `(if lsp--already-widened - (save-excursion ,@form) - (-let [lsp--already-widened t] - (save-restriction - (widen) - (save-excursion ,@form))))) - -;; from http://emacs.stackexchange.com/questions/8082/how-to-get-buffer-position-given-line-number-and-column-number -(defun lsp--line-character-to-point (line character) - "Return the point for character CHARACTER on line LINE." - (or (lsp-virtual-buffer-call :line/character->point line character) - (let ((inhibit-field-text-motion t)) - (lsp-save-restriction-and-excursion - (goto-char (point-min)) - (forward-line line) - ;; server may send character position beyond the current line and we - ;; should fallback to line end. - (-let [line-end (line-end-position)] - (if (> character (- line-end (point))) - line-end - (forward-char character) - (point))))))) - -(lsp-defun lsp--position-to-point ((&Position :line :character)) - "Convert `Position' object in PARAMS to a point." - (lsp--line-character-to-point line character)) - -(lsp-defun lsp--range-to-region ((&RangeToPoint :start :end)) - (cons start end)) - -(lsp-defun lsp--range-text ((&RangeToPoint :start :end)) - (buffer-substring start end)) - -(lsp-defun lsp--find-wrapping-range ((&SelectionRange :parent? :range (&RangeToPoint :start :end))) - (cond - ((and - (region-active-p) - (<= start (region-beginning) end) - (<= start (region-end) end) - (or (not (= start (region-beginning))) - (not (= end (region-end))))) - (cons start end)) - ((and (<= start (point) end) - (not (region-active-p))) - (cons start end)) - (parent? (lsp--find-wrapping-range parent?)))) - -(defun lsp--get-selection-range () - (or - (-when-let ((cache . cache-tick) lsp--document-selection-range-cache) - (when (= cache-tick (buffer-modified-tick)) cache)) - (let ((response (cl-first - (lsp-request - "textDocument/selectionRange" - (list :textDocument (lsp--text-document-identifier) - :positions (vector (lsp--cur-position))))))) - (setq lsp--document-selection-range-cache - (cons response (buffer-modified-tick))) - response))) - -(defun lsp-extend-selection () - "Extend selection." - (interactive) - (unless (lsp-feature? "textDocument/selectionRange") - (signal 'lsp-capability-not-supported (list "selectionRangeProvider"))) - (-when-let ((start . end) (lsp--find-wrapping-range (lsp--get-selection-range))) - (goto-char start) - (set-mark (point)) - (goto-char end) - (exchange-point-and-mark))) - -(defun lsp-warn (message &rest args) - "Display a warning message made from (`format-message' MESSAGE ARGS...). -This is equivalent to `display-warning', using `lsp-mode' as the type and -`:warning' as the level." - (display-warning 'lsp-mode (apply #'format-message message args))) - -(defun lsp--get-uri-handler (scheme) - "Get uri handler for SCHEME in the current workspace." - (--some (gethash scheme (lsp--client-uri-handlers (lsp--workspace-client it))) - (or (lsp-workspaces) (lsp--session-workspaces (lsp-session))))) - -(defun lsp--fix-path-casing (path) - "On windows, downcases path because the windows file system is -case-insensitive. - -On other systems, returns path without change." - (if (eq system-type 'windows-nt) (downcase path) path)) - -(defun lsp--uri-to-path (uri) - "Convert URI to a file path." - (if-let ((fn (->> (lsp-workspaces) - (-keep (-compose #'lsp--client-uri->path-fn #'lsp--workspace-client)) - (cl-first)))) - (funcall fn uri) - (lsp--uri-to-path-1 uri))) - -(defun lsp-remap-path-if-needed (file-name) - (-if-let ((virtual-buffer &as &plist :buffer) (gethash file-name lsp--virtual-buffer-mappings)) - (propertize (buffer-local-value 'buffer-file-name buffer) - 'lsp-virtual-buffer virtual-buffer) - file-name)) - -(defun lsp--uri-to-path-1 (uri) - "Convert URI to a file path." - (let* ((url (url-generic-parse-url (url-unhex-string uri))) - (type (url-type url)) - (target (url-target url)) - (file - (concat (decode-coding-string (url-filename url) - (or locale-coding-system 'utf-8)) - (when (and target - (not (s-match - (rx "#" (group (1+ num)) (or "," "#") - (group (1+ num)) - string-end) - uri))) - (concat "#" target)))) - (file-name (if (and type (not (string= type "file"))) - (if-let ((handler (lsp--get-uri-handler type))) - (funcall handler uri) - uri) - ;; `url-generic-parse-url' is buggy on windows: - ;; https://github.com/emacs-lsp/lsp-mode/pull/265 - (or (and (eq system-type 'windows-nt) - (eq (elt file 0) ?\/) - (substring file 1)) - file)))) - (->> file-name - (concat (-some #'lsp--workspace-host-root (lsp-workspaces))) - (lsp-remap-path-if-needed)))) - -(defun lsp--buffer-uri () - "Return URI of the current buffer." - (or lsp-buffer-uri - (plist-get lsp--virtual-buffer :buffer-uri) - (lsp--path-to-uri - (or (buffer-file-name) (buffer-file-name (buffer-base-buffer)))))) - -(defun lsp-register-client-capabilities (&rest _args) - "Implemented only to make `company-lsp' happy. -DELETE when `lsp-mode.el' is deleted.") - -(defconst lsp--url-path-allowed-chars - (url--allowed-chars (append '(?/) url-unreserved-chars)) - "`url-unreserved-chars' with additional delim ?/. -This set of allowed chars is enough for hexifying local file paths.") - -(defun lsp--path-to-uri-1 (path) - (concat lsp--uri-file-prefix - (--> path - (expand-file-name it) - (or (file-remote-p it 'localname t) it) - (url-hexify-string it lsp--url-path-allowed-chars)))) - -(defun lsp--path-to-uri (path) - "Convert PATH to a uri." - (if-let ((uri-fn (->> (lsp-workspaces) - (-keep (-compose #'lsp--client-path->uri-fn #'lsp--workspace-client)) - (cl-first)))) - (funcall uri-fn path) - (lsp--path-to-uri-1 path))) - -(defun lsp--string-match-any (regex-list str) - "Return the first regex, if any, within REGEX-LIST matching STR." - (--first (string-match it str) regex-list)) - -(cl-defstruct lsp-watch - (descriptors (make-hash-table :test 'equal)) - root-directory) - -(defun lsp--folder-watch-callback (event callback watch ignored-files ignored-directories) - (let ((file-name (cl-third event)) - (event-type (cl-second event))) - (cond - ((and (file-directory-p file-name) - (equal 'created event-type) - (not (lsp--string-match-any ignored-directories file-name))) - - (lsp-watch-root-folder (file-truename file-name) callback ignored-files ignored-directories watch) - - ;; process the files that are already present in - ;; the directory. - (->> (directory-files-recursively file-name ".*" t) - (seq-do (lambda (f) - (unless (file-directory-p f) - (funcall callback (list nil 'created f))))))) - ((and (memq event-type '(created deleted changed)) - (not (file-directory-p file-name)) - (not (lsp--string-match-any ignored-files file-name))) - (funcall callback event)) - ((and (memq event-type '(renamed)) - (not (file-directory-p file-name)) - (not (lsp--string-match-any ignored-files file-name))) - (funcall callback `(,(cl-first event) deleted ,(cl-third event))) - (funcall callback `(,(cl-first event) created ,(cl-fourth event))))))) - -(defun lsp--ask-about-watching-big-repo (number-of-directories dir) - "Ask the user if they want to watch NUMBER-OF-DIRECTORIES from a repository DIR. -This is useful when there is a lot of files in a repository, as -that may slow Emacs down. Returns t if the user wants to watch -the entire repository, nil otherwise." - (prog1 - (yes-or-no-p - (format - "Watching all the files in %s would require adding watches to %s directories, so watching the repo may slow Emacs down. -Do you want to watch all files in %s? " - dir - number-of-directories - dir)) - (lsp--info - (concat "You can configure this warning with the `lsp-enable-file-watchers' " - "and `lsp-file-watch-threshold' variables")))) - - -(defun lsp--path-is-watchable-directory (path dir ignored-directories) - "Figure out whether PATH (inside of DIR) is meant to have a file watcher set. -IGNORED-DIRECTORIES is a list of regexes to filter out directories we don't -want to watch." - (let - ((full-path (f-join dir path))) - (and (file-accessible-directory-p full-path) - (not (equal path ".")) - (not (equal path "..")) - (not (lsp--string-match-any ignored-directories full-path))))) - - -(defun lsp--all-watchable-directories (dir ignored-directories) - "Traverse DIR recursively returning a list of paths that should have watchers. -IGNORED-DIRECTORIES will be used for exclusions" - (let* ((dir (if (f-symlink? dir) - (file-truename dir) - dir))) - (apply #'nconc - ;; the directory itself is assumed to be part of the set - (list dir) - ;; collect all subdirectories that are watchable - (-map - (lambda (path) (lsp--all-watchable-directories (f-join dir path) ignored-directories)) - ;; but only look at subdirectories that are watchable - (-filter (lambda (path) (lsp--path-is-watchable-directory path dir ignored-directories)) - (directory-files dir)))))) - -(defun lsp-watch-root-folder (dir callback ignored-files ignored-directories &optional watch warn-big-repo?) - "Create recursive file notification watch in DIR. -CALLBACK will be called when there are changes in any of -the monitored files. WATCHES is a hash table directory->file -notification handle which contains all of the watch that -already have been created. Watches will not be created for -any directory that matches any regex in IGNORED-DIRECTORIES. -Watches will not be created for any file that matches any -regex in IGNORED-FILES." - (let* ((dir (if (f-symlink? dir) - (file-truename dir) - dir)) - (watch (or watch (make-lsp-watch :root-directory dir))) - (dirs-to-watch (lsp--all-watchable-directories dir ignored-directories))) - (lsp-log "Creating watchers for following %s folders:\n %s" - (length dirs-to-watch) - (s-join "\n " dirs-to-watch)) - (when (or - (not warn-big-repo?) - (not lsp-file-watch-threshold) - (let ((number-of-directories (length dirs-to-watch))) - (or - (< number-of-directories lsp-file-watch-threshold) - (condition-case nil - (lsp--ask-about-watching-big-repo number-of-directories dir) - (quit))))) - (dolist (current-dir dirs-to-watch) - (condition-case err - (progn - (puthash - current-dir - (file-notify-add-watch current-dir - '(change) - (lambda (event) - (lsp--folder-watch-callback event callback watch ignored-files ignored-directories))) - (lsp-watch-descriptors watch))) - (error (lsp-log "Failed to create a watch for %s: message" (error-message-string err))) - (file-missing (lsp-log "Failed to create a watch for %s: message" (error-message-string err)))))) - watch)) - -(defun lsp-kill-watch (watch) - "Delete WATCH." - (-> watch lsp-watch-descriptors hash-table-values (-each #'file-notify-rm-watch)) - (ht-clear! (lsp-watch-descriptors watch))) - -(defun lsp-json-bool (val) - "Convert VAL to JSON boolean." - (if val t :json-false)) - -(defmacro with-lsp-workspace (workspace &rest body) - "Helper macro for invoking BODY in WORKSPACE context." - (declare (debug (form body)) - (indent 1)) - `(let ((lsp--cur-workspace ,workspace)) ,@body)) - -(defmacro with-lsp-workspaces (workspaces &rest body) - "Helper macro for invoking BODY against multiple WORKSPACES." - (declare (debug (form body)) - (indent 1)) - `(let ((lsp--buffer-workspaces ,workspaces)) ,@body)) - - - -(defmacro lsp-consistency-check (package) - `(defconst ,(intern (concat (symbol-name package) - "-plist-value-when-compiled")) - (eval-when-compile lsp-use-plists))) - - -;; loading code-workspace files - -;;;###autoload -(defun lsp-load-vscode-workspace (file) - "Load vscode workspace from FILE" - (interactive "fSelect file to import: ") - (mapc #'lsp-workspace-folders-remove (lsp-session-folders (lsp-session))) - - (let ((dir (f-dirname file))) - (->> file - (json-read-file) - (alist-get 'folders) - (-map (-lambda ((&alist 'path)) - (lsp-workspace-folders-add (expand-file-name path dir))))))) - -;;;###autoload -(defun lsp-save-vscode-workspace (file) - "Save vscode workspace to FILE" - (interactive "FSelect file to save to: ") - - (let ((json-encoding-pretty-print t)) - (f-write-text (json-encode - `((folders . ,(->> (lsp-session) - (lsp-session-folders) - (--map `((path . ,it))))))) - 'utf-8 - file))) - - -(defmacro lsp-foreach-workspace (&rest body) - "Execute BODY for each of the current workspaces." - (declare (debug (form body))) - `(--map (with-lsp-workspace it ,@body) (lsp-workspaces))) - -(defmacro when-lsp-workspace (workspace &rest body) - "Helper macro for invoking BODY in WORKSPACE context if present." - (declare (debug (form body)) - (indent 1)) - `(when-let ((lsp--cur-workspace ,workspace)) ,@body)) - -(lsp-defun lsp--window-show-quick-pick (_workspace (&ShowQuickPickParams :place-holder :can-pick-many :items)) - (if-let* ((selectfunc (if can-pick-many #'completing-read-multiple #'completing-read)) - (itemLabels (seq-map (-lambda ((item &as &QuickPickItem :label)) (format "%s" label)) - items)) - (result (funcall-interactively - selectfunc - (format "%s%s " place-holder (if can-pick-many " (* for all)" "")) itemLabels)) - (choices (if (listp result) - (if (equal result '("*")) - itemLabels - result) - (list result)))) - (vconcat (seq-filter #'identity (seq-map (-lambda ((item &as &QuickPickItem :label :user-data)) - (if (member label choices) - (lsp-make-quick-pick-item :label label :picked t :user-data user-data) - nil)) - items))))) - -(lsp-defun lsp--window-show-input-box (_workspace (&ShowInputBoxParams :prompt :value?)) - (read-string (format "%s: " prompt) (or value? ""))) - -(lsp-defun lsp--window-show-message (_workspace (&ShowMessageRequestParams :message :type)) - "Send the server's messages to log. -PARAMS - the data sent from _WORKSPACE." - (funcall (cl-case type - (1 'lsp--error) - (2 'lsp--warn) - (t 'lsp--info)) - "%s" - message)) - -(lsp-defun lsp--window-log-message (workspace (&ShowMessageRequestParams :message :type)) - "Send the server's messages to log. -PARAMS - the data sent from WORKSPACE." - (ignore - (let ((client (lsp--workspace-client workspace))) - (when (or (not client) - (cl-notany (-rpartial #'string-match-p message) - (lsp--client-ignore-messages client))) - (lsp-log "%s" (lsp--propertize message type)))))) - -(lsp-defun lsp--window-log-message-request ((&ShowMessageRequestParams :message :type :actions?)) - "Display a message request to user sending the user selection back to server." - (let* ((message (lsp--propertize message type)) - (choices (seq-map #'lsp:message-action-item-title actions?))) - (if choices - (completing-read (concat message " ") (seq-into choices 'list) nil t) - (lsp-log message)))) - -(lsp-defun lsp--window-show-document ((&ShowDocumentParams :uri :selection?)) - "Show document URI in a buffer and go to SELECTION if any." - (let ((path (lsp--uri-to-path uri))) - (when (f-exists? path) - (with-current-buffer (find-file path) - (when selection? - (goto-char (lsp--position-to-point (lsp:range-start selection?)))) - t)))) - -(defcustom lsp-progress-prefix " ⌛ " - "Progress prefix." - :group 'lsp-mode - :type 'string - :package-version '(lsp-mode . "8.0.0")) - -(defcustom lsp-progress-function #'lsp-on-progress-modeline - "Function for handling the progress notifications." - :group 'lsp-mode - :type '(choice - (const :tag "Use modeline" lsp-on-progress-modeline) - (const :tag "Legacy(uses either `progress-reporter' or `spinner' based on `lsp-progress-via-spinner')" - lsp-on-progress-legacy) - (const :tag "Ignore" ignore) - (function :tag "Other function")) - :package-version '(lsp-mode . "8.0.0")) - -(defcustom lsp-request-while-no-input-may-block nil - "Have `lsp-request-while-no-input` block unless `non-essential` is t." - :group 'lsp-mode - :type 'boolean) - -(defun lsp--progress-status () - "Returns the status of the progress for the current workspaces." - (-let ((progress-status - (s-join - "|" - (-keep - (lambda (workspace) - (let ((tokens (lsp--workspace-work-done-tokens workspace))) - (unless (ht-empty? tokens) - (mapconcat - (-lambda ((&WorkDoneProgressBegin :message? :title :percentage?)) - (concat (if percentage? - (if (numberp percentage?) - (format "%.0f%%%% " percentage?) - (format "%s%%%% " percentage?)) - "") - (or message? title))) - (ht-values tokens) - "|")))) - (lsp-workspaces))))) - (unless (s-blank? progress-status) - (concat lsp-progress-prefix progress-status)))) - -(lsp-defun lsp-on-progress-modeline (workspace (&ProgressParams :token :value - (value &as &WorkDoneProgress :kind))) - "PARAMS contains the progress data. -WORKSPACE is the workspace that contains the progress token." - (add-to-list 'global-mode-string '(t (:eval (lsp--progress-status)))) - (pcase kind - ("begin" (lsp-workspace-set-work-done-token token value workspace)) - ("report" (lsp-workspace-set-work-done-token token value workspace)) - ("end" (lsp-workspace-rem-work-done-token token workspace))) - (force-mode-line-update)) - -(lsp-defun lsp-on-progress-legacy (workspace (&ProgressParams :token :value - (value &as &WorkDoneProgress :kind))) - "PARAMS contains the progress data. -WORKSPACE is the workspace that contains the progress token." - (pcase kind - ("begin" - (-let* (((&WorkDoneProgressBegin :title :percentage?) value) - (reporter - (if lsp-progress-via-spinner - (let* ((spinner-strings (alist-get (lsp-progress-spinner-type) spinner-types)) - ;; Set message as a tooltip for the spinner strings - (propertized-strings - (seq-map (lambda (string) (propertize string 'help-echo title)) - spinner-strings)) - (spinner-type (vconcat propertized-strings))) - ;; The progress relates to the server as a whole, - ;; display it on all buffers. - (mapcar (lambda (buffer) - (lsp-with-current-buffer buffer - (spinner-start spinner-type)) - buffer) - (lsp--workspace-buffers workspace))) - (if percentage? - (make-progress-reporter title 0 100 percentage?) - ;; No percentage, just progress - (make-progress-reporter title nil nil))))) - (lsp-workspace-set-work-done-token token reporter workspace))) - ("report" - (when-let ((reporter (lsp-workspace-get-work-done-token token workspace))) - (unless lsp-progress-via-spinner - (progress-reporter-update reporter (lsp:work-done-progress-report-percentage? value))))) - - ("end" - (when-let ((reporter (lsp-workspace-get-work-done-token token workspace))) - (if lsp-progress-via-spinner - (mapc (lambda (buffer) - (when (lsp-buffer-live-p buffer) - (lsp-with-current-buffer buffer - (spinner-stop)))) - reporter) - (progress-reporter-done reporter)) - (lsp-workspace-rem-work-done-token token workspace))))) - - -;; diagnostics - -(defvar lsp-diagnostic-filter nil - "A a function which will be called with - `&PublishDiagnosticsParams' and `workspace' which can be used - to filter out the diagnostics. The function should return - `&PublishDiagnosticsParams'. - -Common usecase are: -1. Filter the diagnostics for a particular language server. -2. Filter out the diagnostics under specific level.") - -(defvar lsp-diagnostic-stats (ht)) - -(defun lsp-diagnostics (&optional current-workspace?) - "Return the diagnostics from all workspaces." - (or (pcase (if current-workspace? - (lsp-workspaces) - (lsp--session-workspaces (lsp-session))) - (`() ()) - (`(,workspace) (lsp--workspace-diagnostics workspace)) - (`,workspaces (let ((result (make-hash-table :test 'equal))) - (mapc (lambda (workspace) - (->> workspace - (lsp--workspace-diagnostics) - (maphash (lambda (file-name diagnostics) - (puthash file-name - (append (gethash file-name result) diagnostics) - result))))) - workspaces) - result))) - (ht))) - -(defun lsp-diagnostics-stats-for (path) - "Get diagnostics statistics for PATH. -The result format is vector [_ errors warnings infos hints] or nil." - (gethash (lsp--fix-path-casing path) lsp-diagnostic-stats)) - -(defun lsp-diagnostics--update-path (path new-stats) - (let ((new-stats (copy-sequence new-stats)) - (path (lsp--fix-path-casing (directory-file-name path)))) - (if-let ((old-data (gethash path lsp-diagnostic-stats))) - (dotimes (idx 5) - (cl-callf + (aref old-data idx) - (aref new-stats idx))) - (puthash path new-stats lsp-diagnostic-stats)))) - -(lsp-defun lsp--on-diagnostics-update-stats (workspace - (&PublishDiagnosticsParams :uri :diagnostics)) - (let ((path (lsp--fix-path-casing (lsp--uri-to-path uri))) - (new-stats (make-vector 5 0))) - (mapc (-lambda ((&Diagnostic :severity?)) - (cl-incf (aref new-stats (or severity? 1)))) - diagnostics) - (when-let ((old-diags (gethash path (lsp--workspace-diagnostics workspace)))) - (mapc (-lambda ((&Diagnostic :severity?)) - (cl-decf (aref new-stats (or severity? 1)))) - old-diags)) - (lsp-diagnostics--update-path path new-stats) - (while (not (string= path (setf path (file-name-directory - (directory-file-name path))))) - (lsp-diagnostics--update-path path new-stats)))) - -(defun lsp--on-diagnostics (workspace params) - "Callback for textDocument/publishDiagnostics. -interface PublishDiagnosticsParams { - uri: string; - diagnostics: Diagnostic[]; -} -PARAMS contains the diagnostics data. -WORKSPACE is the workspace that contains the diagnostics." - (when lsp-diagnostic-filter - (setf params (funcall lsp-diagnostic-filter params workspace))) - - (lsp--on-diagnostics-update-stats workspace params) - - (-let* (((&PublishDiagnosticsParams :uri :diagnostics) params) - (lsp--virtual-buffer-mappings (ht)) - (file (lsp--fix-path-casing (lsp--uri-to-path uri))) - (workspace-diagnostics (lsp--workspace-diagnostics workspace))) - - (if (seq-empty-p diagnostics) - (remhash file workspace-diagnostics) - (puthash file (append diagnostics nil) workspace-diagnostics)) - - (run-hooks 'lsp-diagnostics-updated-hook))) - -(defun lsp-diagnostics--workspace-cleanup (workspace) - (->> workspace - (lsp--workspace-diagnostics) - (maphash (lambda (key _) - (lsp--on-diagnostics-update-stats - workspace - (lsp-make-publish-diagnostics-params - :uri (lsp--path-to-uri key) - :diagnostics []))))) - (clrhash (lsp--workspace-diagnostics workspace))) - - - -;; textDocument/foldingRange support - -(cl-defstruct lsp--folding-range beg end kind children) - -(defvar-local lsp--cached-folding-ranges nil) -(defvar-local lsp--cached-nested-folding-ranges nil) - -(defun lsp--folding-range-width (range) - (- (lsp--folding-range-end range) - (lsp--folding-range-beg range))) - -(defun lsp--get-folding-ranges () - "Get the folding ranges for the current buffer." - (unless (eq (buffer-chars-modified-tick) (car lsp--cached-folding-ranges)) - (let* ((ranges (lsp-request "textDocument/foldingRange" - `(:textDocument ,(lsp--text-document-identifier)))) - (sorted-line-col-pairs (->> ranges - (cl-mapcan (-lambda ((&FoldingRange :start-line - :start-character? - :end-line - :end-character?)) - (list (cons start-line start-character?) - (cons end-line end-character?)))) - (-sort #'lsp--line-col-comparator))) - (line-col-to-point-map (lsp--convert-line-col-to-points-batch - sorted-line-col-pairs))) - (setq lsp--cached-folding-ranges - (cons (buffer-chars-modified-tick) - (--> ranges - (seq-map (-lambda ((range &as - &FoldingRange :start-line - :start-character? - :end-line - :end-character? - :kind?)) - (make-lsp--folding-range - :beg (ht-get line-col-to-point-map - (cons start-line start-character?)) - :end (ht-get line-col-to-point-map - (cons end-line end-character?)) - :kind kind?)) - it) - (seq-filter (lambda (folding-range) - (< (lsp--folding-range-beg folding-range) - (lsp--folding-range-end folding-range))) - it) - (seq-into it 'list) - (delete-dups it)))))) - (cdr lsp--cached-folding-ranges)) - -(defun lsp--get-nested-folding-ranges () - "Get a list of nested folding ranges for the current buffer." - (-let [(tick . _) lsp--cached-folding-ranges] - (if (and (eq tick (buffer-chars-modified-tick)) - lsp--cached-nested-folding-ranges) - lsp--cached-nested-folding-ranges - (setq lsp--cached-nested-folding-ranges - (lsp--folding-range-build-trees (lsp--get-folding-ranges)))))) - -(defun lsp--folding-range-build-trees (ranges) - (setq ranges (seq-sort #'lsp--range-before-p ranges)) - (let* ((dummy-node (make-lsp--folding-range - :beg most-negative-fixnum - :end most-positive-fixnum)) - (stack (list dummy-node))) - (dolist (range ranges) - (while (not (lsp--range-inside-p range (car stack))) - (pop stack)) - (push range (lsp--folding-range-children (car stack))) - (push range stack)) - (lsp--folding-range-children dummy-node))) - -(defun lsp--range-inside-p (r1 r2) - "Return non-nil if folding range R1 lies inside R2" - (and (>= (lsp--folding-range-beg r1) (lsp--folding-range-beg r2)) - (<= (lsp--folding-range-end r1) (lsp--folding-range-end r2)))) - -(defun lsp--range-before-p (r1 r2) - "Return non-nil if folding range R1 ends before R2" - ;; Ensure r1 comes before r2 - (or (< (lsp--folding-range-beg r1) - (lsp--folding-range-beg r2)) - ;; If beg(r1) == beg(r2) make sure r2 ends first - (and (= (lsp--folding-range-beg r1) - (lsp--folding-range-beg r2)) - (< (lsp--folding-range-end r2) - (lsp--folding-range-end r1))))) - -(defun lsp--point-inside-range-p (point range) - "Return non-nil if POINT lies inside folding range RANGE." - (and (>= point (lsp--folding-range-beg range)) - (<= point (lsp--folding-range-end range)))) - -(cl-defun lsp--get-current-innermost-folding-range (&optional (point (point))) - "Return the innermost folding range POINT lies in." - (seq-reduce (lambda (innermost-range curr-range) - (if (and (lsp--point-inside-range-p point curr-range) - (or (null innermost-range) - (lsp--range-inside-p curr-range innermost-range))) - curr-range - innermost-range)) - (lsp--get-folding-ranges) - nil)) - -(cl-defun lsp--get-current-outermost-folding-range (&optional (point (point))) - "Return the outermost folding range POINT lies in." - (cdr (seq-reduce (-lambda ((best-pair &as outermost-width . _) curr-range) - (let ((curr-width (lsp--folding-range-width curr-range))) - (if (and (lsp--point-inside-range-p point curr-range) - (or (null best-pair) - (> curr-width outermost-width))) - (cons curr-width curr-range) - best-pair))) - (lsp--get-folding-ranges) - nil))) - -(defun lsp--folding-range-at-point-bounds () - (when (and lsp-enable-folding - (lsp-feature? "textDocument/foldingRange")) - (if-let ((range (lsp--get-current-innermost-folding-range))) - (cons (lsp--folding-range-beg range) - (lsp--folding-range-end range))))) -(put 'lsp--folding-range 'bounds-of-thing-at-point - #'lsp--folding-range-at-point-bounds) - -(defun lsp--get-nearest-folding-range (&optional backward) - (let ((point (point)) - (found nil)) - (while (not - (or found - (if backward - (<= point (point-min)) - (>= point (point-max))))) - (if backward (cl-decf point) (cl-incf point)) - (setq found (lsp--get-current-innermost-folding-range point))) - found)) - -(defun lsp--folding-range-at-point-forward-op (n) - (when (and lsp-enable-folding - (not (zerop n)) - (lsp-feature? "textDocument/foldingRange")) - (cl-block break - (dotimes (_ (abs n)) - (if-let ((range (lsp--get-nearest-folding-range (< n 0)))) - (goto-char (if (< n 0) - (lsp--folding-range-beg range) - (lsp--folding-range-end range))) - (cl-return-from break)))))) -(put 'lsp--folding-range 'forward-op - #'lsp--folding-range-at-point-forward-op) - -(defun lsp--folding-range-at-point-beginning-op () - (goto-char (car (lsp--folding-range-at-point-bounds)))) -(put 'lsp--folding-range 'beginning-op - #'lsp--folding-range-at-point-beginning-op) - -(defun lsp--folding-range-at-point-end-op () - (goto-char (cdr (lsp--folding-range-at-point-bounds)))) -(put 'lsp--folding-range 'end-op - #'lsp--folding-range-at-point-end-op) - -(defun lsp--range-at-point-bounds () - (or (lsp--folding-range-at-point-bounds) - (when-let ((range (and - (lsp-feature? "textDocument/hover") - (->> (lsp--text-document-position-params) - (lsp-request "textDocument/hover") - (lsp:hover-range?))))) - (lsp--range-to-region range)))) - -;; A more general purpose "thing", useful for applications like focus.el -(put 'lsp--range 'bounds-of-thing-at-point - #'lsp--range-at-point-bounds) - -(defun lsp--log-io-p (method) - "Return non nil if should log for METHOD." - (and lsp-log-io - (or (not lsp-log-io-allowlist-methods) - (member method lsp-log-io-allowlist-methods)))) - - -;; toggles - -(defun lsp-toggle-trace-io () - "Toggle client-server protocol logging." - (interactive) - (setq lsp-log-io (not lsp-log-io)) - (lsp--info "Server logging %s." (if lsp-log-io "enabled" "disabled"))) - -(defun lsp-toggle-signature-auto-activate () - "Toggle signature auto activate." - (interactive) - (setq lsp-signature-auto-activate - (unless lsp-signature-auto-activate '(:on-trigger-char))) - (lsp--info "Signature autoactivate %s." (if lsp-signature-auto-activate "enabled" "disabled")) - (lsp--update-signature-help-hook)) - -(defun lsp-toggle-on-type-formatting () - "Toggle on type formatting." - (interactive) - (setq lsp-enable-on-type-formatting (not lsp-enable-on-type-formatting)) - (lsp--info "On type formatting is %s." (if lsp-enable-on-type-formatting "enabled" "disabled")) - (lsp--update-on-type-formatting-hook)) - -(defun lsp-toggle-symbol-highlight () - "Toggle symbol highlighting." - (interactive) - (setq lsp-enable-symbol-highlighting (not lsp-enable-symbol-highlighting)) - - (cond - ((and lsp-enable-symbol-highlighting - (lsp-feature? "textDocument/documentHighlight")) - (add-hook 'lsp-on-idle-hook #'lsp--document-highlight nil t) - (lsp--info "Symbol highlighting enabled in current buffer.")) - ((not lsp-enable-symbol-highlighting) - (remove-hook 'lsp-on-idle-hook #'lsp--document-highlight t) - (lsp--remove-overlays 'lsp-highlight) - (lsp--info "Symbol highlighting disabled in current buffer.")))) - - -;; keybindings -(defvar lsp--binding-descriptions nil - "List of key binding/short description pair.") - -(defmacro lsp-define-conditional-key (keymap key def desc cond &rest bindings) - "In KEYMAP, define key sequence KEY as DEF conditionally. -This is like `define-key', except the definition disappears -whenever COND evaluates to nil. -DESC is the short-description for the binding. -BINDINGS is a list of (key def desc cond)." - (declare (indent defun) - (debug (form form form form form &rest sexp))) - (->> (cl-list* key def desc cond bindings) - (-partition 4) - (-mapcat (-lambda ((key def desc cond)) - `((define-key ,keymap ,key - '(menu-item - ,(format "maybe-%s" def) - ,def - :filter - (lambda (item) - (when (with-current-buffer (or (when (buffer-live-p lsp--describe-buffer) - lsp--describe-buffer) - (current-buffer)) - ,cond) - item)))) - (when (stringp ,key) - (setq lsp--binding-descriptions - (append lsp--binding-descriptions '(,key ,desc))))))) - macroexp-progn)) - -(defvar lsp--describe-buffer nil) - -(defun lsp-describe-buffer-bindings-advice (fn buffer &optional prefix menus) - (let ((lsp--describe-buffer buffer)) - (funcall fn buffer prefix menus))) - -(advice-add 'describe-buffer-bindings - :around - #'lsp-describe-buffer-bindings-advice) - -(defun lsp--prepend-prefix (mappings) - (->> mappings - (-partition 2) - (-mapcat (-lambda ((key description)) - (list (concat lsp-keymap-prefix " " key) - description))))) - -(defvar lsp-command-map - (-doto (make-sparse-keymap) - (lsp-define-conditional-key - ;; workspaces - "wD" lsp-disconnect "disconnect" (lsp-workspaces) - "wd" lsp-describe-session "describe session" t - "wq" lsp-workspace-shutdown "shutdown server" (lsp-workspaces) - "wr" lsp-workspace-restart "restart server" (lsp-workspaces) - "ws" lsp "start server" t - - ;; formatting - "==" lsp-format-buffer "format buffer" (or (lsp-feature? "textDocument/rangeFormatting") - (lsp-feature? "textDocument/formatting")) - "=r" lsp-format-region "format region" (lsp-feature? "textDocument/rangeFormatting") - - ;; folders - "Fa" lsp-workspace-folders-add "add folder" t - "Fb" lsp-workspace-blocklist-remove "un-blocklist folder" t - "Fr" lsp-workspace-folders-remove "remove folder" t - - ;; toggles - "TD" lsp-modeline-diagnostics-mode "toggle modeline diagnostics" (lsp-feature? - "textDocument/publishDiagnostics") - "TL" lsp-toggle-trace-io "toggle log io" t - "TS" lsp-ui-sideline-mode "toggle sideline" (featurep 'lsp-ui-sideline) - "TT" lsp-treemacs-sync-mode "toggle treemacs integration" (featurep 'lsp-treemacs) - "Ta" lsp-modeline-code-actions-mode "toggle modeline code actions" (lsp-feature? - "textDocument/codeAction") - "Tb" lsp-headerline-breadcrumb-mode "toggle breadcrumb" (lsp-feature? - "textDocument/documentSymbol") - "Td" lsp-ui-doc-mode "toggle documentation popup" (featurep 'lsp-ui-doc) - "Tf" lsp-toggle-on-type-formatting "toggle on type formatting" (lsp-feature? - "textDocument/onTypeFormatting") - "Th" lsp-toggle-symbol-highlight "toggle highlighting" (lsp-feature? "textDocument/documentHighlight") - "Tl" lsp-lens-mode "toggle lenses" (lsp-feature? "textDocument/codeLens") - "Ts" lsp-toggle-signature-auto-activate "toggle signature" (lsp-feature? "textDocument/signatureHelp") - - ;; goto - "ga" xref-find-apropos "find symbol in workspace" (lsp-feature? "workspace/symbol") - "gd" lsp-find-declaration "find declarations" (lsp-feature? "textDocument/declaration") - "ge" lsp-treemacs-errors-list "show errors" (fboundp 'lsp-treemacs-errors-list) - "gg" lsp-find-definition "find definitions" (lsp-feature? "textDocument/definition") - "gh" lsp-treemacs-call-hierarchy "call hierarchy" (and (lsp-feature? "callHierarchy/incomingCalls") - (fboundp 'lsp-treemacs-call-hierarchy)) - "gi" lsp-find-implementation "find implementations" (lsp-feature? "textDocument/implementation") - "gr" lsp-find-references "find references" (lsp-feature? "textDocument/references") - "gt" lsp-find-type-definition "find type definition" (lsp-feature? "textDocument/typeDefinition") - - ;; help - "hg" lsp-ui-doc-glance "glance symbol" (and (featurep 'lsp-ui-doc) - (lsp-feature? "textDocument/hover")) - "hh" lsp-describe-thing-at-point "describe symbol at point" (lsp-feature? "textDocument/hover") - "hs" lsp-signature-activate "signature help" (lsp-feature? "textDocument/signatureHelp") - - ;; refactoring - "ro" lsp-organize-imports "organize imports" (lsp-feature? "textDocument/codeAction") - "rr" lsp-rename "rename" (lsp-feature? "textDocument/rename") - - ;; actions - "aa" lsp-execute-code-action "code actions" (lsp-feature? "textDocument/codeAction") - "ah" lsp-document-highlight "highlight symbol" (lsp-feature? "textDocument/documentHighlight") - "al" lsp-avy-lens "lens" (and (bound-and-true-p lsp-lens-mode) (featurep 'avy)) - - ;; peeks - "Gg" lsp-ui-peek-find-definitions "peek definitions" (and (lsp-feature? "textDocument/definition") - (fboundp 'lsp-ui-peek-find-definitions)) - "Gi" lsp-ui-peek-find-implementation "peek implementations" (and - (fboundp 'lsp-ui-peek-find-implementation) - (lsp-feature? "textDocument/implementation")) - "Gr" lsp-ui-peek-find-references "peek references" (and (fboundp 'lsp-ui-peek-find-references) - (lsp-feature? "textDocument/references")) - "Gs" lsp-ui-peek-find-workspace-symbol "peek workspace symbol" (and (fboundp - 'lsp-ui-peek-find-workspace-symbol) - (lsp-feature? "workspace/symbol"))))) - - -;; which-key integration - -(declare-function which-key-add-major-mode-key-based-replacements "ext:which-key") -(declare-function which-key-add-key-based-replacements "ext:which-key") - -(defun lsp-enable-which-key-integration (&optional all-modes) - "Adds descriptions for `lsp-mode-map' to `which-key-mode' for the current -active `major-mode', or for all major modes when ALL-MODES is t." - (cl-flet ((which-key-fn (if all-modes - 'which-key-add-key-based-replacements - (apply-partially 'which-key-add-major-mode-key-based-replacements major-mode)))) - (apply - #'which-key-fn - (lsp--prepend-prefix - (cl-list* - "" "lsp" - "w" "workspaces" - "F" "folders" - "=" "formatting" - "T" "toggle" - "g" "goto" - "h" "help" - "r" "refactor" - "a" "code actions" - "G" "peek" - lsp--binding-descriptions))))) - - -;; Globbing syntax - -;; We port VSCode's glob-to-regexp code -;; (https://github.com/Microsoft/vscode/blob/466da1c9013c624140f6d1473b23a870abc82d44/src/vs/base/common/glob.ts) -;; since the LSP globbing syntax seems to be the same as that of -;; VSCode. - -(defconst lsp-globstar "**" - "Globstar pattern.") - -(defconst lsp-glob-split ?/ - "The character by which we split path components in a glob -pattern.") - -(defconst lsp-path-regexp "[/\\\\]" - "Forward or backslash to be used as a path separator in -computed regexps.") - -(defconst lsp-non-path-regexp "[^/\\\\]" - "A regexp matching anything other than a slash.") - -(defconst lsp-globstar-regexp - (format "\\(?:%s\\|%s+%s\\|%s%s+\\)*?" - lsp-path-regexp - lsp-non-path-regexp lsp-path-regexp - lsp-path-regexp lsp-non-path-regexp) - "Globstar in regexp form.") - -(defun lsp-split-glob-pattern (pattern split-char) - "Split PATTERN at SPLIT-CHAR while respecting braces and brackets." - (when pattern - (let ((segments nil) - (in-braces nil) - (in-brackets nil) - (current-segment "")) - (dolist (char (string-to-list pattern)) - (cl-block 'exit-point - (if (eq char split-char) - (when (and (null in-braces) - (null in-brackets)) - (push current-segment segments) - (setq current-segment "") - (cl-return-from 'exit-point)) - (pcase char - (?{ - (setq in-braces t)) - (?} - (setq in-braces nil)) - (?\[ - (setq in-brackets t)) - (?\] - (setq in-brackets nil)))) - (setq current-segment (concat current-segment - (char-to-string char))))) - (unless (string-empty-p current-segment) - (push current-segment segments)) - (nreverse segments)))) - -(defun lsp--glob-to-regexp (pattern) - "Helper function to convert a PATTERN from LSP's glob syntax to -an Elisp regexp." - (if (string-empty-p pattern) - "" - (let ((current-regexp "") - (glob-segments (lsp-split-glob-pattern pattern lsp-glob-split))) - (if (-all? (lambda (segment) (eq segment lsp-globstar)) - glob-segments) - ".*" - (let ((prev-segment-was-globstar nil)) - (seq-do-indexed - (lambda (segment index) - (if (string-equal segment lsp-globstar) - (unless prev-segment-was-globstar - (setq current-regexp (concat current-regexp - lsp-globstar-regexp)) - (setq prev-segment-was-globstar t)) - (let ((in-braces nil) - (brace-val "") - (in-brackets nil) - (bracket-val "")) - (dolist (char (string-to-list segment)) - (cond - ((and (not (char-equal char ?\})) - in-braces) - (setq brace-val (concat brace-val - (char-to-string char)))) - ((and in-brackets - (or (not (char-equal char ?\])) - (string-empty-p bracket-val))) - (let ((curr (cond - ((char-equal char ?-) - "-") - ;; NOTE: ?\^ and ?^ are different characters - ((and (memq char '(?^ ?!)) - (string-empty-p bracket-val)) - "^") - ((char-equal char lsp-glob-split) - "") - (t - (regexp-quote (char-to-string char)))))) - (setq bracket-val (concat bracket-val curr)))) - (t - (cl-case char - (?{ - (setq in-braces t)) - (?\[ - (setq in-brackets t)) - (?} - (let* ((choices (lsp-split-glob-pattern brace-val ?\,)) - (brace-regexp (concat "\\(?:" - (mapconcat #'lsp--glob-to-regexp choices "\\|") - "\\)"))) - (setq current-regexp (concat current-regexp - brace-regexp)) - (setq in-braces nil) - (setq brace-val ""))) - (?\] - (setq current-regexp - (concat current-regexp - "[" bracket-val "]")) - (setq in-brackets nil) - (setq bracket-val "")) - (?? - (setq current-regexp - (concat current-regexp - lsp-non-path-regexp))) - (?* - (setq current-regexp - (concat current-regexp - lsp-non-path-regexp "*?"))) - (t - (setq current-regexp - (concat current-regexp - (regexp-quote (char-to-string char))))))))) - (when (and (< index (1- (length glob-segments))) - (or (not (string-equal (nth (1+ index) glob-segments) - lsp-globstar)) - (< (+ index 2) - (length glob-segments)))) - (setq current-regexp - (concat current-regexp - lsp-path-regexp))) - (setq prev-segment-was-globstar nil)))) - glob-segments) - current-regexp))))) - -;; See https://github.com/emacs-lsp/lsp-mode/issues/2365 -(defun lsp-glob-unbrace-at-top-level (glob-pattern) - "If GLOB-PATTERN does not start with a brace, return a singleton list -containing GLOB-PATTERN. - -If GLOB-PATTERN does start with a brace, return a list of the -comma-separated globs within the top-level braces." - (if (not (string-prefix-p "{" glob-pattern)) - (list glob-pattern) - (lsp-split-glob-pattern (substring glob-pattern 1 -1) ?\,))) - -(defun lsp-glob-convert-to-wrapped-regexp (glob-pattern) - "Convert GLOB-PATTERN to a regexp wrapped with the beginning- -and end-of-string meta-characters." - (concat "\\`" (lsp--glob-to-regexp (string-trim glob-pattern)) "\\'")) - -(defun lsp-glob-to-regexps (glob-pattern) - "Convert a GLOB-PATTERN to a list of Elisp regexps." - (when-let* - ((glob-pattern (cond ((hash-table-p glob-pattern) - (ht-get glob-pattern "pattern")) - ((stringp glob-pattern) glob-pattern) - (t (error "Unknown glob-pattern type: %s" glob-pattern)))) - (trimmed-pattern (string-trim glob-pattern)) - (top-level-unbraced-patterns (lsp-glob-unbrace-at-top-level trimmed-pattern))) - (seq-map #'lsp-glob-convert-to-wrapped-regexp - top-level-unbraced-patterns))) - - - -(defvar lsp-mode-menu) - -(defun lsp-mouse-click (event) - (interactive "e") - (let* ((ec (event-start event)) - (choice (x-popup-menu event lsp-mode-menu)) - (action (lookup-key lsp-mode-menu (apply 'vector choice)))) - - (select-window (posn-window ec)) - - (unless (and (region-active-p) (eq action 'lsp-execute-code-action)) - (goto-char (posn-point ec))) - (run-with-idle-timer - 0.001 nil - (lambda () - (cl-labels ((check (value) (not (null value)))) - (when choice - (call-interactively action))))))) - -(defvar lsp-mode-map - (let ((map (make-sparse-keymap))) - (define-key map (kbd "C-<down-mouse-1>") #'lsp-find-definition-mouse) - (define-key map (kbd "C-<mouse-1>") #'ignore) - (define-key map (kbd "<mouse-3>") #'lsp-mouse-click) - (define-key map (kbd "C-S-SPC") #'lsp-signature-activate) - (when lsp-keymap-prefix - (define-key map (kbd lsp-keymap-prefix) lsp-command-map)) - map) - "Keymap for `lsp-mode'.") - -(define-minor-mode lsp-mode "Mode for LSP interaction." - :keymap lsp-mode-map - :lighter - (" LSP[" - (lsp--buffer-workspaces - (:eval (mapconcat #'lsp--workspace-print lsp--buffer-workspaces "][")) - (:propertize "Disconnected" face warning)) - "]") - :group 'lsp-mode - (when (and lsp-mode (not lsp--buffer-workspaces) (not lsp--buffer-deferred)) - ;; fire up `lsp' when someone calls `lsp-mode' instead of `lsp' - (lsp))) - -(defvar lsp-mode-menu - (easy-menu-create-menu - nil - `(["Go to definition" lsp-find-definition - :active (lsp-feature? "textDocument/definition")] - ["Find references" lsp-find-references - :active (lsp-feature? "textDocument/references")] - ["Find implementations" lsp-find-implementation - :active (lsp-feature? "textDocument/implementation")] - ["Find declarations" lsp-find-declaration - :active (lsp-feature? "textDocument/declaration")] - ["Go to type declaration" lsp-find-type-definition - :active (lsp-feature? "textDocument/typeDefinition")] - "--" - ["Describe" lsp-describe-thing-at-point] - ["Code action" lsp-execute-code-action] - ["Format" lsp-format-buffer] - ["Highlight references" lsp-document-highlight] - ["Type Hierarchy" lsp-java-type-hierarchy - :visible (lsp-can-execute-command? "java.navigate.resolveTypeHierarchy")] - ["Type Hierarchy" lsp-treemacs-type-hierarchy - :visible (and (not (lsp-can-execute-command? "java.navigate.resolveTypeHierarchy")) - (functionp 'lsp-treemacs-type-hierarchy) - (lsp-feature? "textDocument/typeHierarchy"))] - ["Call Hierarchy" lsp-treemacs-call-hierarchy - :visible (and (functionp 'lsp-treemacs-call-hierarchy) - (lsp-feature? "textDocument/callHierarchy"))] - ["Rename" lsp-rename - :active (lsp-feature? "textDocument/rename")] - "--" - ("Session" - ["View logs" lsp-workspace-show-log] - ["Describe" lsp-describe-session] - ["Shutdown" lsp-shutdown-workspace] - ["Restart" lsp-restart-workspace]) - ("Workspace Folders" - ["Add" lsp-workspace-folders-add] - ["Remove" lsp-workspace-folders-remove] - ["Open" lsp-workspace-folders-open]) - ("Toggle features" - ["Lenses" lsp-lens-mode] - ["Headerline breadcrumb" lsp-headerline-breadcrumb-mode] - ["Modeline code actions" lsp-modeline-code-actions-mode] - ["Modeline diagnostics" lsp-modeline-diagnostics-mode]) - "---" - ("Debug" - :active (bound-and-true-p dap-ui-mode) - :filter ,(lambda (_) - (and (boundp 'dap-ui-menu-items) - (nthcdr 3 dap-ui-menu-items)))))) - "Menu for lsp-mode.") - -(defalias 'make-lsp-client 'make-lsp--client) - -(cl-defstruct lsp--registered-capability - (id "") - (method " ") - (options nil)) - -;; A ‘lsp--workspace’ object represents exactly one language server process. -(cl-defstruct lsp--workspace - ;; the `ewoc' object for displaying I/O to and from the server - (ewoc nil) - - ;; ‘server-capabilities’ is a hash table of the language server capabilities. - ;; It is the hash table representation of a LSP ServerCapabilities structure; - ;; cf. https://microsoft.github.io/language-server-protocol/specification#initialize. - (server-capabilities nil) - - ;; ‘registered-server-capabilities’ is a list of hash tables that represent - ;; dynamically-registered Registration objects. See - ;; https://microsoft.github.io/language-server-protocol/specification#client_registerCapability. - (registered-server-capabilities nil) - - ;; ‘root’ is a directory name or a directory file name for the workspace - ;; root. ‘lsp-mode’ passes this directory to the ‘initialize’ method of the - ;; language server; see - ;; https://microsoft.github.io/language-server-protocol/specification#initialize. - (root nil) - - ;; ‘client’ is the ‘lsp--client’ object associated with this workspace. - (client nil) - - ;; ‘host-root’ contains the host root info as derived from `file-remote-p'. It - ;; used to derive the file path in `lsp--uri-to-path' when using tramp - ;; connection. - (host-root nil) - - ;; ‘proc’ is a process object; it may represent a regular process, a pipe, or - ;; a network connection. ‘lsp-mode’ communicates with ‘proc’ using the - ;; language server protocol. ‘proc’ corresponds to the COMMUNICATION-PROCESS - ;; element of the return value of the client’s ‘get-root’ field, which see. - (proc nil) - - ;; ‘proc’ is a process object; it must represent a regular process, not a - ;; pipe or network process. It represents the actual server process that - ;; corresponds to this workspace. ‘cmd-proc’ corresponds to the - ;; COMMAND-PROCESS element of the return value of the client’s ‘get-root’ - ;; field, which see. - (cmd-proc nil) - - ;; ‘buffers’ is a list of buffers associated with this workspace. - (buffers nil) - - ;; if semantic tokens is enabled, `semantic-tokens-faces' contains - ;; one face (or nil) for each token type supported by the language server. - (semantic-tokens-faces nil) - - ;; If semantic highlighting is enabled, `semantic-tokens-modifier-faces' - ;; contains one face (or nil) for each modifier type supported by the language - ;; server - (semantic-tokens-modifier-faces nil) - - ;; Extra client capabilities provided by third-party packages using - ;; `lsp-register-client-capabilities'. It's value is an alist of (PACKAGE-NAME - ;; . CAPS), where PACKAGE-NAME is a symbol of the third-party package name, - ;; and CAPS is either a plist of the client capabilities, or a function that - ;; takes no argument and returns a plist of the client capabilities or nil. - (extra-client-capabilities nil) - - ;; Workspace status - (status nil) - - ;; ‘metadata’ is a generic storage for workspace specific data. It is - ;; accessed via `lsp-workspace-set-metadata' and `lsp-workspace-set-metadata' - (metadata (make-hash-table :test 'equal)) - - ;; contains all the file notification watches that have been created for the - ;; current workspace in format filePath->file notification handle. - (watches (make-hash-table :test 'equal)) - - ;; list of workspace folders - (workspace-folders nil) - - ;; ‘last-id’ the last request id for the current workspace. - (last-id 0) - - ;; ‘status-string’ allows extensions to specify custom status string based on - ;; the Language Server specific messages. - (status-string nil) - - ;; ‘shutdown-action’ flag used to mark that workspace should not be restarted (e.g. it - ;; was stopped). - shutdown-action - - ;; ‘diagnostics’ a hashmap with workspace diagnostics. - (diagnostics (make-hash-table :test 'equal)) - - ;; contains all the workDone progress tokens that have been created - ;; for the current workspace. - (work-done-tokens (make-hash-table :test 'equal))) - - -(cl-defstruct lsp-session - ;; contains the folders that are part of the current session - folders - ;; contains the folders that must not be imported in the current workspace. - folders-blocklist - ;; contains the list of folders that must be imported in a project in case of - ;; multi root LSP server. - (server-id->folders (make-hash-table :test 'equal)) - ;; folder to list of the servers that are associated with the folder. - (folder->servers (make-hash-table :test 'equal)) - ;; ‘metadata’ is a generic storage for workspace specific data. It is - ;; accessed via `lsp-workspace-set-metadata' and `lsp-workspace-set-metadata' - (metadata (make-hash-table :test 'equal))) - -(defun lsp-workspace-status (status-string &optional workspace) - "Set current workspace status to STATUS-STRING. -If WORKSPACE is not specified defaults to lsp--cur-workspace." - (let ((status-string (when status-string (replace-regexp-in-string "%" "%%" status-string)))) - (setf (lsp--workspace-status-string (or workspace lsp--cur-workspace)) status-string))) - -(defun lsp-session-set-metadata (key value &optional _workspace) - "Associate KEY with VALUE in the WORKSPACE metadata. -If WORKSPACE is not provided current workspace will be used." - (puthash key value (lsp-session-metadata (lsp-session)))) - -(defalias 'lsp-workspace-set-metadata 'lsp-session-set-metadata) - -(defun lsp-session-get-metadata (key &optional _workspace) - "Lookup KEY in WORKSPACE metadata. -If WORKSPACE is not provided current workspace will be used." - (gethash key (lsp-session-metadata (lsp-session)))) - -(defalias 'lsp-workspace-get-metadata 'lsp-session-get-metadata) - -(defun lsp-workspace-set-work-done-token (token value workspace) - "Associate TOKEN with VALUE in the WORKSPACE work-done-tokens." - (puthash token value (lsp--workspace-work-done-tokens workspace))) - -(defun lsp-workspace-get-work-done-token (token workspace) - "Lookup TOKEN in the WORKSPACE work-done-tokens." - (gethash token (lsp--workspace-work-done-tokens workspace))) - -(defun lsp-workspace-rem-work-done-token (token workspace) - "Remove TOKEN from the WORKSPACE work-done-tokens." - (remhash token (lsp--workspace-work-done-tokens workspace))) - - -(defun lsp--make-notification (method &optional params) - "Create notification body for method METHOD and parameters PARAMS." - (list :jsonrpc "2.0" :method method :params params)) - -(defalias 'lsp--make-request 'lsp--make-notification) -(defalias 'lsp-make-request 'lsp--make-notification) - -(defun lsp--make-response (id result) - "Create response for REQUEST with RESULT." - `(:jsonrpc "2.0" :id ,id :result ,result)) - -(defun lsp-make-notification (method &optional params) - "Create notification body for method METHOD and parameters PARAMS." - (lsp--make-notification method params)) - -(defmacro lsp--json-serialize (params) - (if (progn - (require 'json) - (fboundp 'json-serialize)) - `(json-serialize ,params - :null-object nil - :false-object :json-false) - `(let ((json-false :json-false)) - (json-encode ,params)))) - -(defun lsp--make-message (params) - "Create a LSP message from PARAMS, after encoding it to a JSON string." - (let ((body (lsp--json-serialize params))) - (concat "Content-Length: " - (number-to-string (1+ (string-bytes body))) - "\r\n\r\n" - body - "\n"))) - -(cl-defstruct lsp--log-entry timestamp process-time type method id body) - -(defun lsp--make-log-entry (method id body type &optional process-time) - "Create an outgoing log object from BODY with method METHOD and id ID. -If ID is non-nil, then the body is assumed to be a notification. -TYPE can either be `incoming' or `outgoing'" - (cl-assert (memq type '(incoming-req outgoing-req incoming-notif - outgoing-notif incoming-resp - outgoing-resp))) - (make-lsp--log-entry - :timestamp (format-time-string "%I:%M:%S %p") - :process-time process-time - :method method - :id id - :type type - :body body)) - -(defun lsp--log-font-lock-json (body) - "Font lock JSON BODY." - (with-temp-buffer - (insert body) - ;; We set the temp buffer file-name extension to .json and call `set-auto-mode' - ;; so the users configured json mode is used which could be - ;; `json-mode', `json-ts-mode', `jsonian-mode', etc. - (let ((buffer-file-name "lsp-log.json")) - (delay-mode-hooks - (set-auto-mode) - (if (fboundp 'font-lock-ensure) - (font-lock-ensure) - (with-no-warnings - (font-lock-fontify-buffer))))) - (buffer-string))) - -(defun lsp--log-entry-pp (entry) - (cl-assert (lsp--log-entry-p entry)) - (pcase-let (((cl-struct lsp--log-entry timestamp method id type process-time - body) - entry) - (json-false :json-false) - (json-encoding-pretty-print t) - (str nil)) - (setq str - (concat (format "[Trace - %s] " timestamp) - (pcase type - ('incoming-req (format "Received request '%s - (%s)." method id)) - ('outgoing-req (format "Sending request '%s - (%s)'." method id)) - - ('incoming-notif (format "Received notification '%s'." method)) - ('outgoing-notif (format "Sending notification '%s'." method)) - - ('incoming-resp (format "Received response '%s - (%s)' in %dms." - method id process-time)) - ('outgoing-resp - (format - "Sending response '%s - (%s)'. Processing request took %dms" - method id process-time))) - "\n" - (if (memq type '(incoming-resp ougoing-resp)) - "Result: " - "Params: ") - (lsp--log-font-lock-json (json-encode body)) - "\n\n\n")) - (setq str (propertize str 'mouse-face 'highlight 'read-only t)) - (insert str))) - -(defvar-local lsp--log-io-ewoc nil) - -(defun lsp--get-create-io-ewoc (workspace) - (if (and (lsp--workspace-ewoc workspace) - (buffer-live-p (ewoc-buffer (lsp--workspace-ewoc workspace)))) - (lsp--workspace-ewoc workspace) - (with-current-buffer (lsp--get-log-buffer-create workspace) - (unless (eq 'lsp-log-io-mode major-mode) (lsp-log-io-mode)) - (setq-local window-point-insertion-type t) - (setq lsp--log-io-ewoc (ewoc-create #'lsp--log-entry-pp nil nil t)) - (setf (lsp--workspace-ewoc workspace) lsp--log-io-ewoc)) - (lsp--workspace-ewoc workspace))) - -(defun lsp--ewoc-count (ewoc) - (let* ((count 0) - (count-fn (lambda (_) (setq count (1+ count))))) - (ewoc-map count-fn ewoc) - count)) - -(defun lsp--log-entry-new (entry workspace) - (let* ((ewoc (lsp--get-create-io-ewoc workspace)) - (count (and (not (eq lsp-io-messages-max t)) (lsp--ewoc-count ewoc))) - (node (if (or (eq lsp-io-messages-max t) - (>= lsp-io-messages-max count)) - nil - (ewoc-nth ewoc (1- lsp-io-messages-max)))) - (prev nil) - (inhibit-read-only t)) - (while node - (setq prev (ewoc-prev ewoc node)) - (ewoc-delete ewoc node) - (setq node prev)) - (ewoc-enter-last ewoc entry))) - -(defun lsp--send-notification (body) - "Send BODY as a notification to the language server." - (lsp-foreach-workspace - (when (lsp--log-io-p (plist-get body :method)) - (lsp--log-entry-new (lsp--make-log-entry - (plist-get body :method) - nil (plist-get body :params) 'outgoing-notif) - lsp--cur-workspace)) - (lsp--send-no-wait body - (lsp--workspace-proc lsp--cur-workspace)))) - -(defalias 'lsp-send-notification 'lsp--send-notification) - -(defun lsp-notify (method params) - "Send notification METHOD with PARAMS." - (lsp--send-notification (lsp--make-notification method params))) - -(defun lsp--cur-workspace-check () - "Check whether buffer lsp workspace(s) are set." - (cl-assert (lsp-workspaces) nil - "No language server(s) is associated with this buffer.")) - -(defun lsp--send-request (body &optional no-wait no-merge) - "Send BODY as a request to the language server, get the response. -If NO-WAIT is non-nil, don't synchronously wait for a response. -If NO-MERGE is non-nil, don't merge the results but return an -alist mapping workspace->result." - (lsp-request (plist-get body :method) - (plist-get body :params) - :no-wait no-wait - :no-merge no-merge)) - -(defalias 'lsp-send-request 'lsp--send-request - "Send BODY as a request to the language server and return the response -synchronously. -\n(fn BODY)") - -(cl-defun lsp-request (method params &key no-wait no-merge) - "Send request METHOD with PARAMS. -If NO-MERGE is non-nil, don't merge the results but return alist -workspace->result. -If NO-WAIT is non-nil send the request as notification." - (if no-wait - (lsp-notify method params) - (let* ((send-time (float-time)) - ;; max time by which we must get a response - (expected-time - (and - lsp-response-timeout - (+ send-time lsp-response-timeout))) - resp-result resp-error done?) - (unwind-protect - (progn - (lsp-request-async method params - (lambda (res) (setf resp-result (or res :finished)) (throw 'lsp-done '_)) - :error-handler (lambda (err) (setf resp-error err) (throw 'lsp-done '_)) - :no-merge no-merge - :mode 'detached - :cancel-token :sync-request) - (while (not (or resp-error resp-result)) - (if (functionp 'json-rpc-connection) - (catch 'lsp-done (sit-for 0.01)) - (catch 'lsp-done - (accept-process-output - nil - (if expected-time (- expected-time send-time) 1)))) - (setq send-time (float-time)) - (when (and expected-time (< expected-time send-time)) - (error "Timeout while waiting for response. Method: %s" method))) - (setq done? t) - (cond - ((eq resp-result :finished) nil) - (resp-result resp-result) - ((lsp-json-error? resp-error) (error (lsp:json-error-message resp-error))) - ((lsp-json-error? (cl-first resp-error)) - (error (lsp:json-error-message (cl-first resp-error)))))) - (unless done? - (lsp-cancel-request-by-token :sync-request)))))) - -(cl-defun lsp-request-while-no-input (method params) - "Send request METHOD with PARAMS and waits until there is no input. -Return same value as `lsp--while-no-input' and respecting `non-essential'." - (if (or non-essential (not lsp-request-while-no-input-may-block)) - (let* ((send-time (float-time)) - ;; max time by which we must get a response - (expected-time - (and - lsp-response-timeout - (+ send-time lsp-response-timeout))) - resp-result resp-error done?) - (unwind-protect - (progn - (lsp-request-async method params - (lambda (res) (setf resp-result (or res :finished)) (throw 'lsp-done '_)) - :error-handler (lambda (err) (setf resp-error err) (throw 'lsp-done '_)) - :mode 'detached - :cancel-token :sync-request) - (while (not (or resp-error resp-result (input-pending-p))) - (catch 'lsp-done - (sit-for - (if expected-time (- expected-time send-time) 1))) - (setq send-time (float-time)) - (when (and expected-time (< expected-time send-time)) - (error "Timeout while waiting for response. Method: %s" method))) - (setq done? (or resp-error resp-result)) - (cond - ((eq resp-result :finished) nil) - (resp-result resp-result) - ((lsp-json-error? resp-error) (error (lsp:json-error-message resp-error))) - ((lsp-json-error? (cl-first resp-error)) - (error (lsp:json-error-message (cl-first resp-error)))))) - (unless done? - (lsp-cancel-request-by-token :sync-request)) - (when (and (input-pending-p) lsp--throw-on-input) - (throw 'input :interrupted)))) - (lsp-request method params))) - -(defvar lsp--cancelable-requests (ht)) - -(cl-defun lsp-request-async (method params callback - &key mode error-handler cancel-handler no-merge cancel-token) - "Send METHOD with PARAMS as a request to the language server. -Call CALLBACK with the response received from the server -asynchronously. -MODE determines when the callback will be called depending on the -condition of the original buffer. It could be: -- `detached' which means that the callback will be executed no -matter what has happened to the buffer. -- `alive' - the callback will be executed only if the buffer from -which the call was executed is still alive. -- `current' the callback will be executed only if the original buffer -is still selected. -- `tick' - the callback will be executed only if the buffer was not modified. -- `unchanged' - the callback will be executed only if the buffer hasn't -changed and if the buffer is not modified. - -ERROR-HANDLER will be called in case the request has failed. -CANCEL-HANDLER will be called in case the request is being canceled. -If NO-MERGE is non-nil, don't merge the results but return alist -workspace->result. -CANCEL-TOKEN is the token that can be used to cancel request." - (lsp--send-request-async `(:jsonrpc "2.0" :method ,method :params ,params) - callback mode error-handler cancel-handler no-merge cancel-token)) - -(defun lsp--create-request-cancel (id workspaces hook buf method cancel-callback) - (lambda (&rest _) - (unless (and (equal 'post-command-hook hook) - (equal (current-buffer) buf)) - (lsp--request-cleanup-hooks id) - (with-lsp-workspaces workspaces - (lsp--cancel-request id) - (when cancel-callback (funcall cancel-callback))) - (lsp-log "Cancelling %s(%s) in hook %s" method id hook)))) - -(defun lsp--create-async-callback - (callback method no-merge workspaces) - "Create async handler expecting COUNT results, merge them and call CALLBACK. -MODE determines when the callback will be called depending on the -condition of the original buffer. METHOD is the invoked method. -If NO-MERGE is non-nil, don't merge the results but return alist -workspace->result. ID is the request id." - (let (results errors) - (lambda (result) - (push (cons lsp--cur-workspace result) - (if (eq result :error) errors results)) - (when (and (not (eq (length errors) (length workspaces))) - (eq (+ (length errors) (length results)) (length workspaces))) - (funcall callback - (if no-merge - results - (lsp--merge-results (-map #'cl-rest results) method))))))) - -(defcustom lsp-default-create-error-handler-fn nil - "Default error handler customization. -Handler should give METHOD as argument and return function of one argument -ERROR." - :type 'function - :group 'lsp-mode - :package-version '(lsp-mode . "9.0.0")) - -(defun lsp--create-default-error-handler (method) - "Default error handler. -METHOD is the executed method." - (if lsp-default-create-error-handler-fn - (funcall lsp-default-create-error-handler-fn method) - (lambda (error) - (lsp--warn "%s" (or (lsp--error-string error) - (format "%s Request has failed" method)))))) - -(defvar lsp--request-cleanup-hooks (ht)) - -(defun lsp--request-cleanup-hooks (request-id) - (when-let ((cleanup-function (gethash request-id lsp--request-cleanup-hooks))) - (funcall cleanup-function) - (remhash request-id lsp--request-cleanup-hooks))) - -(defun lsp-cancel-request-by-token (cancel-token) - "Cancel request using CANCEL-TOKEN." - (-when-let ((request-id . workspaces) (gethash cancel-token lsp--cancelable-requests)) - (with-lsp-workspaces workspaces - (lsp--cancel-request request-id)) - (remhash cancel-token lsp--cancelable-requests) - (lsp--request-cleanup-hooks request-id))) - -(defun lsp--send-request-async (body callback - &optional mode error-callback cancel-callback - no-merge cancel-token) - "Send BODY as a request to the language server. -Call CALLBACK with the response received from the server -asynchronously. -MODE determines when the callback will be called depending on the -condition of the original buffer. It could be: -- `detached' which means that the callback will be executed no -matter what has happened to the buffer. -- `alive' - the callback will be executed only if the buffer from -which the call was executed is still alive. -- `current' the callback will be executed only if the original buffer -is still selected. -- `tick' - the callback will be executed only if the buffer was not modified. -- `unchanged' - the callback will be executed only if the buffer hasn't -changed and if the buffer is not modified. - -ERROR-CALLBACK will be called in case the request has failed. -CANCEL-CALLBACK will be called in case the request is being canceled. -If NO-MERGE is non-nil, don't merge the results but return alist -workspace->result. -CANCEL-TOKEN is the token that can be used to cancel request." - (when cancel-token - (lsp-cancel-request-by-token cancel-token)) - - (if-let ((target-workspaces (lsp--find-workspaces-for body))) - (let* ((start-time (current-time)) - (method (plist-get body :method)) - (id (cl-incf lsp-last-id)) - (buf (current-buffer)) - (cancel-callback (when cancel-callback - (pcase mode - ((or 'alive 'tick 'unchanged) - (lambda () - (with-current-buffer buf - (funcall cancel-callback)))) - (_ cancel-callback)))) - ;; calculate what are the (hook . local) pairs which will cancel - ;; the request - (hooks (pcase mode - ('alive '((kill-buffer-hook . t))) - ('tick '((kill-buffer-hook . t) (after-change-functions . t))) - ('unchanged '((after-change-functions . t) (post-command-hook . nil))) - ('current '((post-command-hook . nil))))) - ;; note: lambdas in emacs can be compared but we should make sure - ;; that all of the captured arguments are the same - in our case - ;; `lsp--create-request-cancel' will return the same lambda when - ;; called with the same params. - (cleanup-hooks - (lambda () (mapc - (-lambda ((hook . local)) - (if local - (when (buffer-live-p buf) - (with-current-buffer buf - (remove-hook hook - (lsp--create-request-cancel - id target-workspaces hook buf method cancel-callback) - t))) - (remove-hook hook (lsp--create-request-cancel - id target-workspaces hook buf method cancel-callback)))) - hooks) - (remhash cancel-token lsp--cancelable-requests))) - (callback (pcase mode - ((or 'alive 'tick 'unchanged) (lambda (&rest args) - (with-current-buffer buf - (apply callback args)))) - (_ callback))) - (callback (lsp--create-async-callback callback - method - no-merge - target-workspaces)) - (callback (lambda (result) - (lsp--request-cleanup-hooks id) - (funcall callback result))) - (error-callback (lsp--create-async-callback - (or error-callback - (lsp--create-default-error-handler method)) - method - nil - target-workspaces)) - (error-callback (lambda (error) - (funcall callback :error) - (lsp--request-cleanup-hooks id) - (funcall error-callback error))) - (body (plist-put body :id id))) - - ;; cancel request in any of the hooks - (mapc (-lambda ((hook . local)) - (add-hook hook - (lsp--create-request-cancel - id target-workspaces hook buf method cancel-callback) - nil local)) - hooks) - (puthash id cleanup-hooks lsp--request-cleanup-hooks) - - (setq lsp--last-active-workspaces target-workspaces) - - (when cancel-token - (puthash cancel-token (cons id target-workspaces) lsp--cancelable-requests)) - - (seq-doseq (workspace target-workspaces) - (when (lsp--log-io-p method) - (lsp--log-entry-new (lsp--make-log-entry method id - (plist-get body :params) - 'outgoing-req) - workspace)) - (puthash id - (list callback error-callback method start-time (current-time)) - (-> workspace - (lsp--workspace-client) - (lsp--client-response-handlers))) - (lsp--send-no-wait body (lsp--workspace-proc workspace))) - body) - (error "The connected server(s) does not support method %s. -To find out what capabilities support your server use `M-x lsp-describe-session' -and expand the capabilities section" - (plist-get body :method)))) - -;; deprecated, use lsp-request-async. -(defalias 'lsp-send-request-async 'lsp--send-request-async) -(make-obsolete 'lsp-send-request-async 'lsp-request-async "lsp-mode 7.0.1") - -;; Clean up the entire state of lsp mode when Emacs is killed, to get rid of any -;; pending language servers. -(add-hook 'kill-emacs-hook #'lsp--global-teardown) - -(defun lsp--global-teardown () - "Unload working workspaces." - (lsp-foreach-workspace (lsp--shutdown-workspace))) - -(defun lsp--shutdown-workspace (&optional restart) - "Shut down the language server process for ‘lsp--cur-workspace’." - (with-demoted-errors "LSP error: %S" - (let ((lsp-response-timeout 0.5)) - (condition-case err - (lsp-request "shutdown" nil) - (error (lsp--error "%s" err)))) - (lsp-notify "exit" nil)) - (setf (lsp--workspace-shutdown-action lsp--cur-workspace) (or (and restart 'restart) 'shutdown)) - (lsp--uninitialize-workspace)) - -(defcustom lsp-inlay-hint-enable nil - "If non-nil it will enable inlay hints." - :type 'boolean - :group 'lsp-mode - :package-version '(lsp-mode . "9.0.0")) - -(defun lsp--uninitialize-workspace () - "Cleanup buffer state. -When a workspace is shut down, by request or from just -disappearing, unset all the variables related to it." - (-let [(&lsp-wks 'cmd-proc 'buffers) lsp--cur-workspace] - (lsp-process-kill cmd-proc) - (mapc (lambda (buf) - (when (lsp-buffer-live-p buf) - (lsp-with-current-buffer buf - (lsp-managed-mode -1)))) - buffers) - (lsp-diagnostics--workspace-cleanup lsp--cur-workspace))) - -(defun lsp--client-capabilities (&optional custom-capabilities) - "Return the client capabilities appending CUSTOM-CAPABILITIES." - (append - `((general . ((positionEncodings . ["utf-32", "utf-16"]))) - (workspace . ((workspaceEdit . ((documentChanges . t) - (resourceOperations . ["create" "rename" "delete"]))) - (applyEdit . t) - (symbol . ((symbolKind . ((valueSet . ,(apply 'vector (number-sequence 1 26))))))) - (executeCommand . ((dynamicRegistration . :json-false))) - ,@(when lsp-enable-file-watchers '((didChangeWatchedFiles . ((dynamicRegistration . t))))) - (workspaceFolders . t) - (configuration . t) - ,@(when lsp-semantic-tokens-enable - `((semanticTokens . ((refreshSupport . ,(or (and (boundp 'lsp-semantic-tokens-honor-refresh-requests) - lsp-semantic-tokens-honor-refresh-requests) - :json-false)))))) - ,@(when lsp-lens-enable '((codeLens . ((refreshSupport . t))))) - ,@(when lsp-inlay-hint-enable '((inlayHint . ((refreshSupport . :json-false))))) - (fileOperations . ((didCreate . :json-false) - (willCreate . :json-false) - (didRename . t) - (willRename . t) - (didDelete . :json-false) - (willDelete . :json-false))))) - (textDocument . ((declaration . ((dynamicRegistration . t) - (linkSupport . t))) - (definition . ((dynamicRegistration . t) - (linkSupport . t))) - (references . ((dynamicRegistration . t))) - (implementation . ((dynamicRegistration . t) - (linkSupport . t))) - (typeDefinition . ((dynamicRegistration . t) - (linkSupport . t))) - (synchronization . ((willSave . t) (didSave . t) (willSaveWaitUntil . t))) - (documentSymbol . ((symbolKind . ((valueSet . ,(apply 'vector (number-sequence 1 26))))) - (hierarchicalDocumentSymbolSupport . t))) - (formatting . ((dynamicRegistration . t))) - (rangeFormatting . ((dynamicRegistration . t))) - (onTypeFormatting . ((dynamicRegistration . t))) - ,@(when (and lsp-semantic-tokens-enable - (functionp 'lsp--semantic-tokens-capabilities)) - (lsp--semantic-tokens-capabilities)) - (rename . ((dynamicRegistration . t) (prepareSupport . t))) - (codeAction . ((dynamicRegistration . t) - (isPreferredSupport . t) - (codeActionLiteralSupport . ((codeActionKind . ((valueSet . ["" - "quickfix" - "refactor" - "refactor.extract" - "refactor.inline" - "refactor.rewrite" - "source" - "source.organizeImports"]))))) - (resolveSupport . ((properties . ["edit" "command"]))) - (dataSupport . t))) - (completion . ((completionItem . ((snippetSupport . ,(cond - ((and lsp-enable-snippet (not (fboundp 'yas-minor-mode))) - (lsp--warn (concat - "Yasnippet is not installed, but `lsp-enable-snippet' is set to `t'. " - "You must either install yasnippet, or disable snippet support.")) - :json-false) - (lsp-enable-snippet t) - (t :json-false))) - (documentationFormat . ["markdown" "plaintext"]) - ;; Remove this after jdtls support resolveSupport - (resolveAdditionalTextEditsSupport . t) - (insertReplaceSupport . t) - (deprecatedSupport . t) - (resolveSupport - . ((properties . ["documentation" - "detail" - "additionalTextEdits" - "command"]))) - (insertTextModeSupport . ((valueSet . [1 2]))))) - (contextSupport . t) - (dynamicRegistration . t))) - (signatureHelp . ((signatureInformation . ((parameterInformation . ((labelOffsetSupport . t))))) - (dynamicRegistration . t))) - (documentLink . ((dynamicRegistration . t) - (tooltipSupport . t))) - (hover . ((contentFormat . ["markdown" "plaintext"]) - (dynamicRegistration . t))) - ,@(when lsp-enable-folding - `((foldingRange . ((dynamicRegistration . t) - ,@(when lsp-folding-range-limit - `((rangeLimit . ,lsp-folding-range-limit))) - ,@(when lsp-folding-line-folding-only - `((lineFoldingOnly . t))))))) - (selectionRange . ((dynamicRegistration . t))) - (callHierarchy . ((dynamicRegistration . :json-false))) - (typeHierarchy . ((dynamicRegistration . t))) - (publishDiagnostics . ((relatedInformation . t) - (tagSupport . ((valueSet . [1 2]))) - (versionSupport . t))) - (linkedEditingRange . ((dynamicRegistration . t))))) - (window . ((workDoneProgress . t) - (showDocument . ((support . t)))))) - custom-capabilities)) - -(defun lsp-find-roots-for-workspace (workspace session) - "Get all roots for the WORKSPACE." - (-filter #'identity (ht-map (lambda (folder workspaces) - (when (-contains? workspaces workspace) - folder)) - (lsp-session-folder->servers session)))) - -(defun lsp-session-watches (&optional session) - "Get watches created for SESSION." - (or (gethash "__watches" (lsp-session-metadata (or session (lsp-session)))) - (-let [res (make-hash-table :test 'equal)] - (puthash "__watches" res (lsp-session-metadata (or session (lsp-session)))) - res))) - -(defun lsp--file-process-event (session root-folder event) - "Process file event." - (let* ((changed-file (cl-third event)) - (rel-changed-file (f-relative changed-file root-folder)) - (event-numeric-kind (alist-get (cl-second event) lsp--file-change-type)) - (bit-position (1- event-numeric-kind)) - (watch-bit (ash 1 bit-position))) - (->> - session - lsp-session-folder->servers - (gethash root-folder) - (seq-do (lambda (workspace) - (when (->> - workspace - lsp--workspace-registered-server-capabilities - (-any? - (lambda (capability) - (and - (equal (lsp--registered-capability-method capability) - "workspace/didChangeWatchedFiles") - (->> - capability - lsp--registered-capability-options - (lsp:did-change-watched-files-registration-options-watchers) - (seq-find - (-lambda ((fs-watcher &as &FileSystemWatcher :glob-pattern :kind? :_cachedRegexp cached-regexp)) - (when (or (null kind?) - (> (logand kind? watch-bit) 0)) - (-let [regexes (or cached-regexp - (let ((regexp (lsp-glob-to-regexps glob-pattern))) - (lsp-put fs-watcher :_cachedRegexp regexp) - regexp))] - (-any? (lambda (re) - (or (string-match re changed-file) - (string-match re rel-changed-file))) - regexes)))))))))) - (with-lsp-workspace workspace - (lsp-notify - "workspace/didChangeWatchedFiles" - `((changes . [((type . ,event-numeric-kind) - (uri . ,(lsp--path-to-uri changed-file)))])))))))))) - -(lsp-defun lsp--server-register-capability ((&Registration :method :id :register-options?)) - "Register capability REG." - (when (and lsp-enable-file-watchers - (equal method "workspace/didChangeWatchedFiles")) - (-let* ((created-watches (lsp-session-watches (lsp-session))) - (root-folders (cl-set-difference - (lsp-find-roots-for-workspace lsp--cur-workspace (lsp-session)) - (ht-keys created-watches)))) - ;; create watch for each root folder without such - (dolist (folder root-folders) - (let* ((watch (make-lsp-watch :root-directory folder)) - (ignored-things (lsp--get-ignored-regexes-for-workspace-root folder)) - (ignored-files-regex-list (car ignored-things)) - (ignored-directories-regex-list (cadr ignored-things))) - (puthash folder watch created-watches) - (lsp-watch-root-folder (file-truename folder) - (-partial #'lsp--file-process-event (lsp-session) folder) - ignored-files-regex-list - ignored-directories-regex-list - watch - t))))) - - (push - (make-lsp--registered-capability :id id :method method :options register-options?) - (lsp--workspace-registered-server-capabilities lsp--cur-workspace))) - -(defmacro lsp--with-workspace-temp-buffer (workspace-root &rest body) - "With a temp-buffer under `WORKSPACE-ROOT' and evaluate `BODY', useful to -access dir-local variables." - (declare (indent 1) (debug t)) - `(with-temp-buffer - ;; Set the buffer's name to something under the root so that we can hack the local variables - ;; This file doesn't need to exist and will not be created due to this. - (setq-local buffer-file-name (expand-file-name "lsp-mode-temp" (expand-file-name ,workspace-root))) - (hack-local-variables) - (prog1 ,@body - (setq-local buffer-file-name nil)))) - -(defun lsp--get-ignored-regexes-for-workspace-root (workspace-root) - "Return a list of the form -(lsp-file-watch-ignored-files lsp-file-watch-ignored-directories) for the given -WORKSPACE-ROOT." - ;; The intent of this function is to provide per-root workspace-level customization of the - ;; lsp-file-watch-ignored-directories and lsp-file-watch-ignored-files variables. - (lsp--with-workspace-temp-buffer workspace-root - (list lsp-file-watch-ignored-files (lsp-file-watch-ignored-directories)))) - - -(defun lsp--cleanup-hanging-watches () - "Cleanup watches in case there are no more workspaces that are interested -in that particular folder." - (let* ((session (lsp-session)) - (watches (lsp-session-watches session))) - (dolist (watched-folder (ht-keys watches)) - (when (-none? (lambda (workspace) - (with-lsp-workspace workspace - (lsp--registered-capability "workspace/didChangeWatchedFiles"))) - (gethash watched-folder (lsp-session-folder->servers (lsp-session)))) - (lsp-log "Cleaning up watches for folder %s. There is no workspace watching this folder..." watched-folder) - (lsp-kill-watch (gethash watched-folder watches)) - (remhash watched-folder watches))))) - -(lsp-defun lsp--server-unregister-capability ((&Unregistration :id :method)) - "Unregister capability UNREG." - (setf (lsp--workspace-registered-server-capabilities lsp--cur-workspace) - (seq-remove (lambda (e) (equal (lsp--registered-capability-id e) id)) - (lsp--workspace-registered-server-capabilities lsp--cur-workspace))) - (when (equal method "workspace/didChangeWatchedFiles") - (lsp--cleanup-hanging-watches))) - -(defun lsp--server-capabilities () - "Return the capabilities of the language server associated with the buffer." - (->> (lsp-workspaces) - (-keep #'lsp--workspace-server-capabilities) - (apply #'lsp-merge))) - -(defun lsp--send-open-close-p () - "Return whether open and close notifications should be sent to the server." - (let ((sync (lsp:server-capabilities-text-document-sync? (lsp--server-capabilities)))) - (or (memq sync '(1 2)) - (lsp:text-document-sync-options-open-close? sync)))) - -(defun lsp--send-will-save-p () - "Return whether willSave notifications should be sent to the server." - (-> (lsp--server-capabilities) - (lsp:server-capabilities-text-document-sync?) - (lsp:text-document-sync-options-will-save?))) - -(defun lsp--send-will-save-wait-until-p () - "Return whether willSaveWaitUntil notifications should be sent to the server." - (-> (lsp--server-capabilities) - (lsp:server-capabilities-text-document-sync?) - (lsp:text-document-sync-options-will-save-wait-until?))) - -(defun lsp--send-did-save-p () - "Return whether didSave notifications should be sent to the server." - (let ((sync (lsp:server-capabilities-text-document-sync? (lsp--server-capabilities)))) - (or (memq sync '(1 2)) - (lsp:text-document-sync-options-save? sync)))) - -(defun lsp--save-include-text-p () - "Return whether save notifications should include the text document's contents." - (->> (lsp--server-capabilities) - (lsp:server-capabilities-text-document-sync?) - (lsp:text-document-sync-options-save?) - (lsp:text-document-save-registration-options-include-text?))) - -(defun lsp--send-will-rename-files-p (path) - "Return whether willRenameFiles request should be sent to the server. -If any filters, checks if it applies for PATH." - (let* ((will-rename (-> (lsp--server-capabilities) - (lsp:server-capabilities-workspace?) - (lsp:workspace-server-capabilities-file-operations?) - (lsp:workspace-file-operations-will-rename?))) - (filters (seq-into (lsp:file-operation-registration-options-filters will-rename) 'list))) - (and will-rename - (or (seq-empty-p filters) - (-any? (-lambda ((&FileOperationFilter :scheme? :pattern (&FileOperationPattern :glob))) - (-let [regexes (lsp-glob-to-regexps glob)] - (and (or (not scheme?) - (string-prefix-p scheme? (lsp--path-to-uri path))) - (-any? (lambda (re) - (string-match re path)) - regexes)))) - filters))))) - -(defun lsp--send-did-rename-files-p () - "Return whether didRenameFiles notification should be sent to the server." - (-> (lsp--server-capabilities) - (lsp:server-capabilities-workspace?) - (lsp:workspace-server-capabilities-file-operations?) - (lsp:workspace-file-operations-did-rename?))) - -(declare-function project-roots "ext:project" (project) t) -(declare-function project-root "ext:project" (project) t) - -(defun lsp--suggest-project-root () - "Get project root." - (or - (when (featurep 'projectile) (condition-case nil - (projectile-project-root) - (error nil))) - (when (featurep 'project) - (when-let ((project (project-current))) - (if (fboundp 'project-root) - (project-root project) - (car (with-no-warnings - (project-roots project)))))) - default-directory)) - -(defun lsp--read-from-file (file) - "Read FILE content." - (when (file-exists-p file) - (cl-first (read-from-string (f-read-text file 'utf-8))))) - -(defun lsp--persist (file-name to-persist) - "Persist TO-PERSIST in FILE-NAME. - -This function creates the parent directories if they don't exist -yet." - (let ((print-length nil) - (print-level nil)) - ;; Create all parent directories: - (make-directory (f-parent file-name) t) - (f-write-text (prin1-to-string to-persist) 'utf-8 file-name))) - -(defun lsp-workspace-folders-add (project-root) - "Add PROJECT-ROOT to the list of workspace folders." - (interactive - (list (read-directory-name "Select folder to add: " - (or (lsp--suggest-project-root) default-directory) nil t))) - (cl-pushnew (lsp-f-canonical project-root) - (lsp-session-folders (lsp-session)) :test 'equal) - (lsp--persist-session (lsp-session)) - - (run-hook-with-args 'lsp-workspace-folders-changed-functions (list project-root) nil)) - -(defun lsp-workspace-folders-remove (project-root) - "Remove PROJECT-ROOT from the list of workspace folders." - (interactive (list (completing-read "Select folder to remove: " - (lsp-session-folders (lsp-session)) - nil t nil nil - (lsp-find-session-folder (lsp-session) default-directory)))) - - (setq project-root (lsp-f-canonical project-root)) - - ;; send remove folder to each multiroot workspace associated with the folder - (dolist (wks (->> (lsp-session) - (lsp-session-folder->servers) - (gethash project-root) - (--filter (lsp--client-multi-root (lsp--workspace-client it))))) - (with-lsp-workspace wks - (lsp-notify "workspace/didChangeWorkspaceFolders" - (lsp-make-did-change-workspace-folders-params - :event (lsp-make-workspace-folders-change-event - :removed (vector (lsp-make-workspace-folder - :uri (lsp--path-to-uri project-root) - :name (f-filename project-root))) - :added []))))) - - ;; turn off servers in the removed directory - (let* ((session (lsp-session)) - (folder->servers (lsp-session-folder->servers session)) - (server-id->folders (lsp-session-server-id->folders session)) - (workspaces (gethash project-root folder->servers))) - - (remhash project-root folder->servers) - - ;; turn off the servers without root folders - (dolist (workspace workspaces) - (when (--none? (-contains? it workspace) (ht-values folder->servers)) - (lsp--info "Shutdown %s since folder %s is removed..." - (lsp--workspace-print workspace) project-root) - (with-lsp-workspace workspace (lsp--shutdown-workspace)))) - - (setf (lsp-session-folders session) - (-remove-item project-root (lsp-session-folders session))) - - (ht-aeach (puthash key - (-remove-item project-root value) - server-id->folders) - server-id->folders) - (lsp--persist-session (lsp-session))) - - (run-hook-with-args 'lsp-workspace-folders-changed-functions nil (list project-root))) - -(defun lsp-workspace-blocklist-remove (project-root) - "Remove PROJECT-ROOT from the workspace blocklist." - (interactive (list (completing-read "Select folder to remove:" - (lsp-session-folders-blocklist (lsp-session)) - nil t))) - (setf (lsp-session-folders-blocklist (lsp-session)) - (delete project-root - (lsp-session-folders-blocklist (lsp-session)))) - (lsp--persist-session (lsp-session))) - -(define-obsolete-function-alias 'lsp-workspace-folders-switch - 'lsp-workspace-folders-open "lsp-mode 6.1") - -(defun lsp-workspace-folders-open (project-root) - "Open the directory located at PROJECT-ROOT" - (interactive (list (completing-read "Open folder: " - (lsp-session-folders (lsp-session)) - nil t))) - (find-file project-root)) - -(defun lsp--maybe-enable-signature-help (trigger-characters) - (let ((ch last-command-event)) - (when (cl-find ch trigger-characters :key #'string-to-char) - (lsp-signature-activate)))) - -(defun lsp--on-type-formatting-handler-create () - (when-let ((provider (lsp--capability-for-method "textDocument/onTypeFormatting" ))) - (-let [(&DocumentOnTypeFormattingOptions :more-trigger-character? - :first-trigger-character) provider] - (lambda () - (lsp--on-type-formatting first-trigger-character - more-trigger-character?))))) - -(defun lsp--update-on-type-formatting-hook (&optional cleanup?) - (let ((on-type-formatting-handler (lsp--on-type-formatting-handler-create))) - (cond - ((and lsp-enable-on-type-formatting on-type-formatting-handler (not cleanup?)) - (add-hook 'post-self-insert-hook on-type-formatting-handler nil t)) - ((or cleanup? - (not lsp-enable-on-type-formatting)) - (remove-hook 'post-self-insert-hook on-type-formatting-handler t))))) - -(defun lsp--signature-help-handler-create () - (-when-let ((&SignatureHelpOptions? :trigger-characters?) - (lsp--capability-for-method "textDocument/signatureHelp")) - (lambda () - (lsp--maybe-enable-signature-help trigger-characters?)))) - -(defun lsp--update-signature-help-hook (&optional cleanup?) - (let ((signature-help-handler (lsp--signature-help-handler-create))) - (cond - ((and (or (equal lsp-signature-auto-activate t) - (memq :on-trigger-char lsp-signature-auto-activate)) - signature-help-handler) - (add-hook 'post-self-insert-hook signature-help-handler nil t)) - - ((or cleanup? - (not (or (equal lsp-signature-auto-activate t) - (memq :on-trigger-char lsp-signature-auto-activate)))) - (remove-hook 'post-self-insert-hook signature-help-handler t))))) - -(defun lsp--after-set-visited-file-name () - (lsp-disconnect) - (lsp)) - -;; TODO remove those eldoc workarounds when dropping support for Emacs 27 -;; https://github.com/emacs-lsp/lsp-mode/issues/3295#issuecomment-1308994099 -(defvar eldoc-documentation-default) ; CI -(when (< emacs-major-version 28) - (unless (boundp 'eldoc-documentation-functions) - (load "eldoc" nil 'nomessage)) - (when (memq (default-value 'eldoc-documentation-function) '(nil ignore)) - ;; actually `eldoc-documentation-strategy', but CI was failing - (setq-default eldoc-documentation-function 'eldoc-documentation-default))) - -(define-minor-mode lsp-managed-mode - "Mode for source buffers managed by lsp-mode." - :lighter nil - (cond - (lsp-managed-mode - (when (lsp-feature? "textDocument/hover") - (add-hook 'eldoc-documentation-functions #'lsp-eldoc-function nil t) - (eldoc-mode 1)) - - (add-hook 'after-change-functions #'lsp-on-change nil t) - (add-hook 'after-revert-hook #'lsp-on-revert nil t) - (add-hook 'after-save-hook #'lsp-on-save nil t) - (add-hook 'auto-save-hook #'lsp--on-auto-save nil t) - (add-hook 'before-change-functions #'lsp-before-change nil t) - (add-hook 'before-save-hook #'lsp--before-save nil t) - (add-hook 'kill-buffer-hook #'lsp--text-document-did-close nil t) - (add-hook 'post-command-hook #'lsp--post-command nil t) - - (lsp--update-on-type-formatting-hook) - (lsp--update-signature-help-hook) - - (when lsp-enable-xref - (add-hook 'xref-backend-functions #'lsp--xref-backend nil t)) - - (lsp-configure-buffer) - - ;; make sure we turn off lsp-mode in case major mode changes, because major - ;; mode change will wipe the buffer locals. - (add-hook 'change-major-mode-hook #'lsp-disconnect nil t) - (add-hook 'after-set-visited-file-name-hook #'lsp--after-set-visited-file-name nil t) - - (let ((buffer (lsp-current-buffer))) - (run-with-idle-timer - 0.0 nil - (lambda () - (when (lsp-buffer-live-p buffer) - (lsp-with-current-buffer buffer - (lsp--on-change-debounce buffer) - (lsp--on-idle buffer))))))) - (t - (lsp-unconfig-buffer) - - (remove-hook 'eldoc-documentation-functions #'lsp-eldoc-function t) - (remove-hook 'post-command-hook #'lsp--post-command t) - (remove-hook 'after-change-functions #'lsp-on-change t) - (remove-hook 'after-revert-hook #'lsp-on-revert t) - (remove-hook 'after-save-hook #'lsp-on-save t) - (remove-hook 'auto-save-hook #'lsp--on-auto-save t) - (remove-hook 'before-change-functions #'lsp-before-change t) - (remove-hook 'before-save-hook #'lsp--before-save t) - (remove-hook 'kill-buffer-hook #'lsp--text-document-did-close t) - - (lsp--update-on-type-formatting-hook :cleanup) - (lsp--update-signature-help-hook :cleanup) - - (when lsp--on-idle-timer - (cancel-timer lsp--on-idle-timer) - (setq lsp--on-idle-timer nil)) - - (remove-hook 'lsp-on-idle-hook #'lsp--document-links t) - (remove-hook 'lsp-on-idle-hook #'lsp--document-highlight t) - - (lsp--remove-overlays 'lsp-highlight) - (lsp--remove-overlays 'lsp-links) - - (remove-hook 'xref-backend-functions #'lsp--xref-backend t) - (remove-hook 'change-major-mode-hook #'lsp-disconnect t) - (remove-hook 'after-set-visited-file-name-hook #'lsp--after-set-visited-file-name t) - (setq-local lsp-buffer-uri nil)))) - -(defun lsp-configure-buffer () - "Configure LSP features for current buffer." - ;; make sure the core is running in the context of all available workspaces - ;; to avoid misconfiguration in case we are running in `with-lsp-workspace' context - (let ((lsp--buffer-workspaces (cond - (lsp--buffer-workspaces) - (lsp--cur-workspace (list lsp--cur-workspace)))) - lsp--cur-workspace) - (when lsp-auto-configure - (lsp--auto-configure) - - (when (and lsp-enable-text-document-color - (lsp-feature? "textDocument/documentColor")) - (add-hook 'lsp-on-change-hook #'lsp--document-color nil t)) - - (when (and lsp-enable-imenu - (lsp-feature? "textDocument/documentSymbol")) - (lsp-enable-imenu)) - - (when (and lsp-enable-indentation - (lsp-feature? "textDocument/rangeFormatting")) - (add-function :override (local 'indent-region-function) #'lsp-format-region)) - - (when (and lsp-enable-symbol-highlighting - (lsp-feature? "textDocument/documentHighlight")) - (add-hook 'lsp-on-idle-hook #'lsp--document-highlight nil t)) - - (when (and lsp-enable-links - (lsp-feature? "textDocument/documentLink")) - (add-hook 'lsp-on-idle-hook #'lsp--document-links nil t)) - - (when (and lsp-inlay-hint-enable - (lsp-feature? "textDocument/inlayHint")) - (lsp-inlay-hints-mode)) - - (when (and lsp-enable-dap-auto-configure - (functionp 'dap-mode)) - (dap-auto-configure-mode 1))) - (run-hooks 'lsp-configure-hook))) - -(defun lsp-unconfig-buffer () - "Unconfigure LSP features for buffer." - (lsp--remove-overlays 'lsp-color) - - (when (advice-function-member-p 'lsp--imenu-create-index imenu-create-index-function) - (remove-function (local 'imenu-create-index-function) #'lsp--imenu-create-index) - (setq-local imenu-menubar-modified-tick 0) - (setq-local imenu--index-alist nil) - (imenu--cleanup)) - - (remove-function (local 'indent-region-function) #'lsp-format-region) - - (remove-hook 'lsp-on-change-hook #'lsp--document-color t) - (remove-hook 'lsp-on-idle-hook #'lsp--document-highlight t) - (remove-hook 'lsp-on-idle-hook #'lsp--document-links t) - - (when (and lsp-enable-dap-auto-configure - (functionp 'dap-mode)) - (dap-auto-configure-mode -1)) - - (run-hooks 'lsp-unconfigure-hook)) - -(defun lsp--buffer-content () - (lsp-save-restriction-and-excursion - (or (lsp-virtual-buffer-call :buffer-string) - (buffer-substring-no-properties (point-min) - (point-max))))) - -(defun lsp--text-document-did-open () - "`document/didOpen' event." - (run-hooks 'lsp-before-open-hook) - (when (and lsp-auto-touch-files - (not (f-exists? (lsp--uri-to-path (lsp--buffer-uri))))) - (lsp--info "Saving file '%s' because it is not present on the disk." (lsp--buffer-uri)) - (save-buffer)) - - (setq lsp--cur-version (or lsp--cur-version 0)) - (cl-pushnew (lsp-current-buffer) (lsp--workspace-buffers lsp--cur-workspace)) - (lsp-notify - "textDocument/didOpen" - (list :textDocument - (list :uri (lsp--buffer-uri) - :languageId (lsp-buffer-language) - :version lsp--cur-version - :text (lsp--buffer-content)))) - - (lsp-managed-mode 1) - - (run-hooks 'lsp-after-open-hook) - (when-let ((client (-some-> lsp--cur-workspace (lsp--workspace-client)))) - (-some-> (lsp--client-after-open-fn client) - (funcall)) - (-some-> (format "lsp-%s-after-open-hook" (lsp--client-server-id client)) - (intern-soft) - (run-hooks)))) - -(defun lsp--text-document-identifier () - "Make TextDocumentIdentifier." - (list :uri (lsp--buffer-uri))) - -(defun lsp--versioned-text-document-identifier () - "Make VersionedTextDocumentIdentifier." - (plist-put (lsp--text-document-identifier) :version lsp--cur-version)) - -(defun lsp--cur-line (&optional point) - (1- (line-number-at-pos point))) - -(defun lsp--cur-position () - "Make a Position object for the current point." - (or (lsp-virtual-buffer-call :cur-position) - (lsp-save-restriction-and-excursion - (list :line (lsp--cur-line) - :character (- (point) (line-beginning-position)))))) - -(defun lsp--point-to-position (point) - "Convert POINT to Position." - (lsp-save-restriction-and-excursion - (goto-char point) - (lsp--cur-position))) - -(defun lsp--range (start end) - "Make Range body from START and END." - ;; make sure start and end are Position objects - (list :start start :end end)) - -(defun lsp--region-to-range (start end) - "Make Range object for the current region." - (lsp--range (lsp--point-to-position start) - (lsp--point-to-position end))) - -(defun lsp--region-or-line () - "The active region or the current line." - (if (use-region-p) - (lsp--region-to-range (region-beginning) (region-end)) - (lsp--region-to-range (line-beginning-position) (line-end-position)))) - -(defun lsp--check-document-changes-version (document-changes) - "Verify that DOCUMENT-CHANGES have the proper version." - (unless (seq-every-p - (-lambda ((&TextDocumentEdit :text-document)) - (or - (not text-document) - (let* ((filename (-> text-document - lsp:versioned-text-document-identifier-uri - lsp--uri-to-path)) - (version (lsp:versioned-text-document-identifier-version? text-document))) - (with-current-buffer (find-file-noselect filename) - (or (null version) (zerop version) (= -1 version) - (equal version lsp--cur-version)))))) - document-changes) - (error "Document changes cannot be applied due to different document version"))) - -(defun lsp--apply-workspace-edit (workspace-edit &optional operation) - "Apply the WorkspaceEdit object WORKSPACE-EDIT. -OPERATION is symbol representing the source of this text edit." - (-let (((&WorkspaceEdit :document-changes? :changes?) workspace-edit)) - (if-let ((document-changes (seq-reverse document-changes?))) - (progn - (lsp--check-document-changes-version document-changes) - (->> document-changes - (seq-filter (-lambda ((&CreateFile :kind)) (equal kind "create"))) - (seq-do (lambda (change) (lsp--apply-text-document-edit change operation)))) - (->> document-changes - (seq-filter (-lambda ((&CreateFile :kind)) - (and (or (not kind) (equal kind "edit")) - (not (equal kind "create"))))) - (seq-do (lambda (change) (lsp--apply-text-document-edit change operation)))) - (->> document-changes - (seq-filter (-lambda ((&CreateFile :kind)) - (and (not (or (not kind) (equal kind "edit"))) - (not (equal kind "create"))))) - (seq-do (lambda (change) (lsp--apply-text-document-edit change operation))))) - (lsp-map - (lambda (uri text-edits) - (with-current-buffer (-> uri lsp--uri-to-path find-file-noselect) - (lsp--apply-text-edits text-edits operation))) - changes?)))) - -(defmacro lsp-with-filename (file &rest body) - "Execute BODY with FILE as a context. -Need to handle the case when FILE indicates virtual buffer." - (declare (indent 1) (debug t)) - `(if-let ((lsp--virtual-buffer (get-text-property 0 'lsp-virtual-buffer ,file))) - (lsp-with-current-buffer lsp--virtual-buffer - ,@body) - ,@body)) - -(defun lsp--apply-text-document-edit (edit &optional operation) - "Apply the TextDocumentEdit object EDIT. -OPERATION is symbol representing the source of this text edit. -If the file is not being visited by any buffer, it is opened with -`find-file-noselect'. -Because lsp-mode does not store previous document versions, the edit is only -applied if the version of the textDocument matches the version of the -corresponding file. - -interface TextDocumentEdit { - textDocument: VersionedTextDocumentIdentifier; - edits: TextEdit[]; -}" - (pcase (lsp:edit-kind edit) - ("create" (-let* (((&CreateFile :uri :options?) edit) - (file-name (lsp--uri-to-path uri))) - (mkdir (f-dirname file-name) t) - (f-touch file-name) - (when (lsp:create-file-options-overwrite? options?) - (f-write-text "" nil file-name)) - (find-file-noselect file-name))) - ("delete" (-let (((&DeleteFile :uri :options? (&DeleteFileOptions? :recursive?)) edit)) - (f-delete (lsp--uri-to-path uri) recursive?))) - ("rename" (-let* (((&RenameFile :old-uri :new-uri :options? (&RenameFileOptions? :overwrite?)) edit) - (old-file-name (lsp--uri-to-path old-uri)) - (new-file-name (lsp--uri-to-path new-uri)) - (buf (find-buffer-visiting old-file-name))) - (when buf - (lsp-with-current-buffer buf - (save-buffer) - (lsp--text-document-did-close))) - (mkdir (f-dirname new-file-name) t) - (rename-file old-file-name new-file-name overwrite?) - (when buf - (lsp-with-current-buffer buf - (set-buffer-modified-p nil) - (setq lsp-buffer-uri nil) - (set-visited-file-name new-file-name) - (lsp))))) - (_ (let ((file-name (->> edit - (lsp:text-document-edit-text-document) - (lsp:versioned-text-document-identifier-uri) - (lsp--uri-to-path)))) - (lsp-with-current-buffer (find-buffer-visiting file-name) - (lsp-with-filename file-name - (lsp--apply-text-edits (lsp:text-document-edit-edits edit) operation))))))) - -(lsp-defun lsp--position-compare ((&Position :line left-line - :character left-character) - (&Position :line right-line - :character right-character)) - "Return t if position LEFT is greater than RIGHT." - (if (= left-line right-line) - (> left-character right-character) - (> left-line right-line))) - -(lsp-defun lsp-point-in-range? (position (&Range :start :end)) - "Returns if POINT is in RANGE." - (not (or (lsp--position-compare start position) - (lsp--position-compare position end)))) - -(lsp-defun lsp--position-equal ((&Position :line left-line - :character left-character) - (&Position :line right-line - :character right-character)) - "Return whether LEFT and RIGHT positions are equal." - (and (= left-line right-line) - (= left-character right-character))) - -(lsp-defun lsp--text-edit-sort-predicate ((&TextEdit :range (&Range :start left-start :end left-end)) - (&TextEdit :range (&Range :start right-start :end right-end))) - (if (lsp--position-equal left-start right-start) - (lsp--position-compare left-end right-end) - (lsp--position-compare left-start right-start))) - -(lsp-defun lsp--apply-text-edit ((edit &as &TextEdit :range (&RangeToPoint :start :end) :new-text)) - "Apply the edits described in the TextEdit object in TEXT-EDIT." - (setq new-text (s-replace "\r" "" (or new-text ""))) - (lsp:set-text-edit-new-text edit new-text) - (goto-char start) - (delete-region start end) - (insert new-text)) - -;; WORKAROUND: typescript-language might send -1 when applying code actions. -;; see https://github.com/emacs-lsp/lsp-mode/issues/1582 -(lsp-defun lsp--fix-point ((point &as &Position :character :line)) - (-doto point - (lsp:set-position-line (max 0 line)) - (lsp:set-position-character (max 0 character)))) - -(lsp-defun lsp--apply-text-edit-replace-buffer-contents ((edit &as - &TextEdit - :range (&Range :start :end) - :new-text)) - "Apply the edits described in the TextEdit object in TEXT-EDIT. -The method uses `replace-buffer-contents'." - (setq new-text (s-replace "\r" "" (or new-text ""))) - (lsp:set-text-edit-new-text edit new-text) - (-let* ((source (current-buffer)) - ((beg . end) (lsp--range-to-region (lsp-make-range :start (lsp--fix-point start) - :end (lsp--fix-point end))))) - (with-temp-buffer - (insert new-text) - (let ((temp (current-buffer))) - (with-current-buffer source - (save-excursion - (save-restriction - (narrow-to-region beg end) - - ;; On emacs versions < 26.2, - ;; `replace-buffer-contents' is buggy - it calls - ;; change functions with invalid arguments - so we - ;; manually call the change functions here. - ;; - ;; See emacs bugs #32237, #32278: - ;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=32237 - ;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=32278 - (let ((inhibit-modification-hooks t) - (length (- end beg))) - (run-hook-with-args 'before-change-functions - beg end) - (replace-buffer-contents temp) - (run-hook-with-args 'after-change-functions - beg (+ beg (length new-text)) - length))))))))) - -(defun lsp--to-yasnippet-snippet (snippet) - "Convert LSP SNIPPET to yasnippet snippet." - ;; LSP snippet doesn't escape "{" and "`", but yasnippet requires escaping it. - (replace-regexp-in-string (rx (or bos (not (any "$" "\\"))) (group (or "{" "`"))) - (rx "\\" (backref 1)) - snippet - nil nil 1)) - -(defvar-local lsp-enable-relative-indentation nil - "Enable relative indentation when insert texts, snippets ... -from language server.") - -(defun lsp--expand-snippet (snippet &optional start end expand-env) - "Wrapper of `yas-expand-snippet' with all of it arguments. -The snippet will be convert to LSP style and indent according to -LSP server result." - (require 'yasnippet nil t) - (let* ((inhibit-field-text-motion t) - (yas-wrap-around-region nil) - (yas-indent-line 'none) - (yas-also-auto-indent-first-line nil)) - (yas-expand-snippet - (lsp--to-yasnippet-snippet snippet) - start end expand-env))) - -(defun lsp--indent-lines (start end &optional insert-text-mode?) - "Indent from START to END based on INSERT-TEXT-MODE? value. -- When INSERT-TEXT-MODE? is provided - - if it's `lsp/insert-text-mode-as-it', do no editor indentation. - - if it's `lsp/insert-text-mode-adjust-indentation', adjust leading - whitespaces to match the line where text is inserted. -- When it's not provided, using `indent-line-function' for each line." - (save-excursion - (goto-char end) - (let* ((end-line (line-number-at-pos)) - (offset (save-excursion - (goto-char start) - (current-indentation))) - (indent-line-function - (cond ((equal insert-text-mode? lsp/insert-text-mode-as-it) - #'ignore) - ((or (equal insert-text-mode? lsp/insert-text-mode-adjust-indentation) - lsp-enable-relative-indentation - ;; Indenting snippets is extremely slow in `org-mode' buffers - ;; since it has to calculate indentation based on SRC block - ;; position. Thus we use relative indentation as default. - (derived-mode-p 'org-mode)) - (lambda () (save-excursion - (beginning-of-line) - (indent-to-column offset)))) - (t indent-line-function)))) - (goto-char start) - (forward-line) - (while (and (not (eobp)) - (<= (line-number-at-pos) end-line)) - (funcall indent-line-function) - (forward-line))))) - -(defun lsp--apply-text-edits (edits &optional operation) - "Apply the EDITS described in the TextEdit[] object. -OPERATION is symbol representing the source of this text edit." - (unless (seq-empty-p edits) - (atomic-change-group - (run-hooks 'lsp-before-apply-edits-hook) - (let* ((change-group (prepare-change-group)) - (howmany (length edits)) - (message (format "Applying %s edits to `%s' ..." howmany (current-buffer))) - (_ (lsp--info message)) - (reporter (make-progress-reporter message 0 howmany)) - (done 0) - (apply-edit (if (not lsp--virtual-buffer) - #'lsp--apply-text-edit-replace-buffer-contents - #'lsp--apply-text-edit))) - (unwind-protect - (->> edits - ;; We sort text edits so as to apply edits that modify latter - ;; parts of the document first. Furthermore, because the LSP - ;; spec dictates that: "If multiple inserts have the same - ;; position, the order in the array defines which edit to - ;; apply first." We reverse the initial list and sort stably - ;; to make sure the order among edits with the same position - ;; is preserved. - (nreverse) - (seq-sort #'lsp--text-edit-sort-predicate) - (mapc (lambda (edit) - (progress-reporter-update reporter (cl-incf done)) - (funcall apply-edit edit) - (when (lsp:snippet-text-edit-insert-text-format? edit) - (-when-let ((&SnippetTextEdit :range (&RangeToPoint :start) - :insert-text-format? :new-text) edit) - (when (eq insert-text-format? lsp/insert-text-format-snippet) - ;; No `save-excursion' needed since expand snippet will change point anyway - (goto-char (+ start (length new-text))) - (lsp--indent-lines start (point)) - (lsp--expand-snippet new-text start (point))))) - (run-hook-with-args 'lsp-after-apply-edits-hook operation)))) - (undo-amalgamate-change-group change-group) - (progress-reporter-done reporter)))))) - -(defun lsp--create-apply-text-edits-handlers () - "Create (handler cleanup-fn) for applying text edits in async request. -Only works when mode is `tick or `alive." - (let* (first-edited - (func (lambda (start &rest _) - (setq first-edited (if first-edited - (min start first-edited) - start))))) - (add-hook 'before-change-functions func nil t) - (list - (lambda (edits) - (if (and first-edited - (seq-find (-lambda ((&TextEdit :range (&RangeToPoint :end))) - ;; Text edit region is overlapped - (> end first-edited)) - edits)) - (lsp--warn "TextEdits will not be applied since document has been modified before of them.") - (lsp--apply-text-edits edits 'completion-cleanup))) - (lambda () - (remove-hook 'before-change-functions func t))))) - -(defun lsp--capability (cap &optional capabilities) - "Get the value of capability CAP. If CAPABILITIES is non-nil, use them instead." - (when (stringp cap) - (setq cap (intern (concat ":" cap)))) - - (lsp-get (or capabilities - (lsp--server-capabilities)) - cap)) - -(defun lsp--registered-capability (method) - "Check whether there is workspace providing METHOD." - (->> (lsp-workspaces) - (--keep (seq-find (lambda (reg) - (equal (lsp--registered-capability-method reg) method)) - (lsp--workspace-registered-server-capabilities it))) - cl-first)) - -(defun lsp--capability-for-method (method) - "Get the value of capability for METHOD." - (-let* ((reqs (cdr (assoc method lsp-method-requirements))) - ((&plist :capability) reqs)) - (or (and capability (lsp--capability capability)) - (-some-> (lsp--registered-capability method) - (lsp--registered-capability-options))))) - -(defvar-local lsp--before-change-vals nil - "Store the positions from the `lsp-before-change' function call, for -validation and use in the `lsp-on-change' function.") - -(defun lsp--text-document-content-change-event (start end length) - "Make a TextDocumentContentChangeEvent body for START to END, of length LENGTH." - ;; So (47 54 0) means add 7 chars starting at pos 47 - ;; must become - ;; {"range":{"start":{"line":5,"character":6} - ;; ,"end" :{"line":5,"character":6}} - ;; ,"rangeLength":0 - ;; ,"text":"\nbb = 5"} - ;; - ;; And (47 47 7) means delete 7 chars starting at pos 47 - ;; must become - ;; {"range":{"start":{"line":6,"character":0} - ;; ,"end" :{"line":7,"character":0}} - ;; ,"rangeLength":7 - ;; ,"text":""} - ;; - ;; (208 221 3) means delete 3 chars starting at pos 208, and replace them with - ;; 13 chars. So it must become - ;; {"range":{"start":{"line":5,"character":8} - ;; ,"end" :{"line":5,"character":11}} - ;; ,"rangeLength":3 - ;; ,"text":"new-chars-xxx"} - ;; - - ;; Adding text: - ;; lsp-before-change:(start,end)=(33,33) - ;; lsp-on-change:(start,end,length)=(33,34,0) - ;; - ;; Changing text: - ;; lsp-before-change:(start,end)=(208,211) - ;; lsp-on-change:(start,end,length)=(208,221,3) - ;; - ;; Deleting text: - ;; lsp-before-change:(start,end)=(19,27) - ;; lsp-on-change:(start,end,length)=(19,19,8) - (if (zerop length) - ;; Adding something only, work from start only - `( :range ,(lsp--range - (lsp--point-to-position start) - (lsp--point-to-position start)) - :rangeLength 0 - :text ,(buffer-substring-no-properties start end)) - - (if (eq start end) - ;; Deleting something only - (if (lsp--bracketed-change-p start length) - ;; The before-change value is bracketed, use it - `( :range ,(lsp--range - (lsp--point-to-position start) - (plist-get lsp--before-change-vals :end-pos)) - :rangeLength ,length - :text "") - ;; If the change is not bracketed, send a full change event instead. - (lsp--full-change-event)) - - ;; Deleting some things, adding others - (if (lsp--bracketed-change-p start length) - ;; The before-change value is valid, use it - `( :range ,(lsp--range - (lsp--point-to-position start) - (plist-get lsp--before-change-vals :end-pos)) - :rangeLength ,length - :text ,(buffer-substring-no-properties start end)) - (lsp--full-change-event))))) - -(defun lsp--bracketed-change-p (start length) - "If the before and after positions are the same, and the length -is the size of the start range, we are probably good." - (-let [(&plist :end before-end :start before-start) lsp--before-change-vals] - (and (eq start before-start) - (eq length (- before-end before-start))))) - -(defun lsp--full-change-event () - `(:text ,(lsp--buffer-content))) - -(defun lsp-before-change (start end) - "Executed before a file is changed. -Added to `before-change-functions'." - ;; Note: - ;; - ;; This variable holds a list of functions to call when Emacs is about to - ;; modify a buffer. Each function gets two arguments, the beginning and end of - ;; the region that is about to change, represented as integers. The buffer - ;; that is about to change is always the current buffer when the function is - ;; called. - ;; - ;; WARNING: - ;; - ;; Do not expect the before-change hooks and the after-change hooks be called - ;; in balanced pairs around each buffer change. Also don't expect the - ;; before-change hooks to be called for every chunk of text Emacs is about to - ;; delete. These hooks are provided on the assumption that Lisp programs will - ;; use either before- or the after-change hooks, but not both, and the - ;; boundaries of the region where the changes happen might include more than - ;; just the actual changed text, or even lump together several changes done - ;; piecemeal. - (save-match-data - (lsp-save-restriction-and-excursion - (setq lsp--before-change-vals - (list :start start - :end end - :end-pos (lsp--point-to-position end)))))) - -(defun lsp--flush-delayed-changes () - (let ((inhibit-quit t)) - (when lsp--delay-timer - (cancel-timer lsp--delay-timer)) - (mapc (-lambda ((workspace buffer document change)) - (with-current-buffer buffer - (with-lsp-workspace workspace - (lsp-notify "textDocument/didChange" - (list :textDocument document - :contentChanges (vector change)))))) - (prog1 (nreverse lsp--delayed-requests) - (setq lsp--delayed-requests nil))))) - -(defun lsp--workspace-sync-method (workspace) - (let ((sync (-> workspace - (lsp--workspace-server-capabilities) - (lsp:server-capabilities-text-document-sync?)))) - (if (lsp-text-document-sync-options? sync) - (lsp:text-document-sync-options-change? sync) - sync))) - -(defun lsp-on-change (start end length &optional content-change-event-fn) - "Executed when a file is changed. -Added to `after-change-functions'." - ;; Note: - ;; - ;; Each function receives three arguments: the beginning and end of the region - ;; just changed, and the length of the text that existed before the change. - ;; All three arguments are integers. The buffer that has been changed is - ;; always the current buffer when the function is called. - ;; - ;; The length of the old text is the difference between the buffer positions - ;; before and after that text as it was before the change. As for the - ;; changed text, its length is simply the difference between the first two - ;; arguments. - ;; - ;; So (47 54 0) means add 7 chars starting at pos 47 - ;; So (47 47 7) means delete 7 chars starting at pos 47 - (save-match-data - (let ((inhibit-quit t) - ;; make sure that `lsp-on-change' is called in multi-workspace context - ;; see #2901 - lsp--cur-workspace) - ;; A (revert-buffer) call with the 'preserve-modes parameter (eg, as done - ;; by auto-revert-mode) will cause this handler to get called with a nil - ;; buffer-file-name. We need the buffer-file-name to send notifications; - ;; so we skip handling revert-buffer-caused changes and instead handle - ;; reverts separately in lsp-on-revert - (when (not revert-buffer-in-progress-p) - (cl-incf lsp--cur-version) - (mapc - (lambda (workspace) - (pcase (or lsp-document-sync-method - (lsp--workspace-sync-method workspace)) - (1 - (if lsp-debounce-full-sync-notifications - (setq lsp--delayed-requests - (->> lsp--delayed-requests - (-remove (-lambda ((_ buffer)) - (equal (current-buffer) buffer))) - (cons (list workspace - (current-buffer) - (lsp--versioned-text-document-identifier) - (lsp--full-change-event))))) - (with-lsp-workspace workspace - (lsp-notify "textDocument/didChange" - (list :contentChanges (vector (lsp--full-change-event)) - :textDocument (lsp--versioned-text-document-identifier)))))) - (2 - (with-lsp-workspace workspace - (lsp-notify - "textDocument/didChange" - (list :textDocument (lsp--versioned-text-document-identifier) - :contentChanges (vector - (if content-change-event-fn - (funcall content-change-event-fn start end length) - (lsp--text-document-content-change-event - start end length))))))))) - (lsp-workspaces)) - (when lsp--delay-timer (cancel-timer lsp--delay-timer)) - (setq lsp--delay-timer (run-with-idle-timer - lsp-debounce-full-sync-notifications-interval - nil - #'lsp--flush-delayed-changes)) - ;; force cleanup overlays after each change - (lsp--remove-overlays 'lsp-highlight) - (lsp--after-change (current-buffer)) - (setq lsp--signature-last-index nil - lsp--signature-last nil) - ;; cleanup diagnostics - (when lsp-diagnostic-clean-after-change - (lsp-foreach-workspace - (-let [diagnostics (lsp--workspace-diagnostics lsp--cur-workspace)] - (remhash (lsp--fix-path-casing (buffer-file-name)) diagnostics)))))))) - - - -;; facilities for on change hooks. We do not want to make lsp calls on each -;; change event so we add debounce to avoid flooding the server with events. -;; Additionally, we want to have a mechanism for stopping the server calls in -;; particular cases like, e. g. when performing completion. - -(defvar lsp-inhibit-lsp-hooks nil - "Flag to control.") - -(defcustom lsp-on-change-hook nil - "Hooks to run when buffer has changed." - :type 'hook - :group 'lsp-mode) - -(defcustom lsp-idle-delay 0.500 - "Debounce interval for `after-change-functions'." - :type 'number - :group 'lsp-mode) - -(defcustom lsp-on-idle-hook nil - "Hooks to run after `lsp-idle-delay'." - :type 'hook - :group 'lsp-mode) - -(defun lsp--idle-reschedule (buffer) - (when lsp--on-idle-timer - (cancel-timer lsp--on-idle-timer)) - - (setq lsp--on-idle-timer (run-with-idle-timer - lsp-idle-delay - nil - #'lsp--on-idle - buffer))) - -(defun lsp--post-command () - (lsp--cleanup-highlights-if-needed) - (lsp--idle-reschedule (current-buffer))) - -(defun lsp--on-idle (buffer) - "Start post command loop." - (when (and (buffer-live-p buffer) - (equal buffer (current-buffer)) - (not lsp-inhibit-lsp-hooks) - lsp-managed-mode) - (run-hooks 'lsp-on-idle-hook))) - -(defun lsp--on-change-debounce (buffer) - (when (and (buffer-live-p buffer) - (equal buffer (current-buffer)) - (not lsp-inhibit-lsp-hooks) - lsp-managed-mode) - (run-hooks 'lsp-on-change-hook))) - -(defun lsp--after-change (buffer) - (when (fboundp 'lsp--semantic-tokens-refresh-if-enabled) - (lsp--semantic-tokens-refresh-if-enabled buffer)) - (when lsp--on-change-timer - (cancel-timer lsp--on-change-timer)) - (setq lsp--on-change-timer (run-with-idle-timer - lsp-idle-delay - nil - #'lsp--on-change-debounce - buffer)) - (lsp--idle-reschedule buffer)) - - -(defcustom lsp-trim-trailing-whitespace t - "Trim trailing whitespace on a line." - :group 'lsp-mode - :type 'boolean) - -(defcustom lsp-insert-final-newline t - "Insert a newline character at the end of the file if one does not exist." - :group 'lsp-mode - :type 'boolean) - -(defcustom lsp-trim-final-newlines t - "Trim all newlines after the final newline at the end of the file." - :group 'lsp-mode - :type 'boolean) - - -(defun lsp--on-type-formatting (first-trigger-characters more-trigger-characters) - "Self insert handling. -Applies on type formatting." - (let ((ch last-command-event)) - (when (or (eq (string-to-char first-trigger-characters) ch) - (cl-find ch more-trigger-characters :key #'string-to-char)) - (lsp-request-async "textDocument/onTypeFormatting" - (lsp-make-document-on-type-formatting-params - :text-document (lsp--text-document-identifier) - :options (lsp-make-formatting-options - :tab-size (symbol-value (lsp--get-indent-width major-mode)) - :insert-spaces (lsp-json-bool (not indent-tabs-mode)) - :trim-trailing-whitespace? (lsp-json-bool lsp-trim-trailing-whitespace) - :insert-final-newline? (lsp-json-bool lsp-insert-final-newline) - :trim-final-newlines? (lsp-json-bool lsp-trim-final-newlines)) - :ch (char-to-string ch) - :position (lsp--cur-position)) - (lambda (data) (lsp--apply-text-edits data 'format)) - :mode 'tick)))) - - -;; links -(defun lsp--document-links () - (when (lsp-feature? "textDocument/documentLink") - (lsp-request-async - "textDocument/documentLink" - `(:textDocument ,(lsp--text-document-identifier)) - (lambda (links) - (lsp--remove-overlays 'lsp-link) - (seq-do - (-lambda ((link &as &DocumentLink :range (&Range :start :end))) - (-doto (make-button (lsp--position-to-point start) - (lsp--position-to-point end) - 'action (lsp--document-link-keymap link) - 'keymap (let ((map (make-sparse-keymap))) - (define-key map [M-return] 'push-button) - (define-key map [mouse-2] 'push-button) - map) - 'help-echo "mouse-2, M-RET: Visit this link") - (overlay-put 'lsp-link t))) - links)) - :mode 'unchanged))) - -(defun lsp--document-link-handle-target (url) - (let* ((parsed-url (url-generic-parse-url (url-unhex-string url))) - (type (url-type parsed-url))) - (pcase type - ("file" - (xref-push-marker-stack) - (find-file (lsp--uri-to-path url)) - (-when-let ((_ line column) (s-match (rx "#" (group (1+ num)) (or "," "#") (group (1+ num))) url)) - (goto-char (lsp--position-to-point - (lsp-make-position :character (1- (string-to-number column)) - :line (1- (string-to-number line))))))) - ((or "http" "https") (browse-url url)) - (type (if-let ((handler (lsp--get-uri-handler type))) - (funcall handler url) - (signal 'lsp-file-scheme-not-supported (list url))))))) - -(lsp-defun lsp--document-link-keymap ((link &as &DocumentLink :target?)) - (if target? - (lambda (_) - (interactive) - (lsp--document-link-handle-target target?)) - (lambda (_) - (interactive) - (when (lsp:document-link-registration-options-resolve-provider? - (lsp--capability-for-method "textDocument/documentLink")) - (lsp-request-async - "documentLink/resolve" - link - (-lambda ((&DocumentLink :target?)) - (lsp--document-link-handle-target target?))))))) - - - -(defcustom lsp-warn-no-matched-clients t - "Whether to show messages when there are no supported clients." - :group 'lsp-mode - :type 'boolean) - -(defun lsp-buffer-language--configured-id () - "Return nil when not registered." - (->> lsp-language-id-configuration - (-first - (-lambda ((mode-or-pattern . language)) - (cond - ((and (stringp mode-or-pattern) - (s-matches? mode-or-pattern (buffer-file-name))) - language) - ((eq mode-or-pattern major-mode) language)))) - cl-rest)) - -(defvar-local lsp--buffer-language nil - "Locally cached returned value of `lsp-buffer-language'.") - -(defun lsp-buffer-language () - "Get language corresponding current buffer." - (or lsp--buffer-language - (let* ((configured-language (lsp-buffer-language--configured-id))) - (setq lsp--buffer-language - (or configured-language - ;; ensure non-nil - (string-remove-suffix "-mode" (symbol-name major-mode)))) - (when (and lsp-warn-no-matched-clients - (null configured-language)) - (lsp-warn "Unable to calculate the languageId for buffer `%s'. \ -Take a look at `lsp-language-id-configuration'. The `major-mode' is %s" - (buffer-name) - major-mode)) - lsp--buffer-language))) - -(defun lsp-activate-on (&rest languages) - "Returns language activation function. -The function will return t when the `lsp-buffer-language' returns -one of the LANGUAGES." - (lambda (_file-name _mode) - (-contains? languages (lsp-buffer-language)))) - -(defun lsp-workspace-root (&optional path) - "Find the workspace root for the current file or PATH." - (-when-let* ((file-name (or path (buffer-file-name))) - (file-name (lsp-f-canonical file-name))) - (->> (lsp-session) - (lsp-session-folders) - (--filter (and (lsp--files-same-host it file-name) - (or (lsp-f-ancestor-of? it file-name) - (equal it file-name)))) - (--max-by (> (length it) (length other)))))) - -(defun lsp-on-revert () - "Executed when a file is reverted. -Added to `after-revert-hook'." - (let ((n (buffer-size)) - (revert-buffer-in-progress-p nil)) - (lsp-on-change 0 n n))) - -(defun lsp--text-document-did-close (&optional keep-workspace-alive) - "Executed when the file is closed, added to `kill-buffer-hook'. - -If KEEP-WORKSPACE-ALIVE is non-nil, do not shutdown the workspace -if it's closing the last buffer in the workspace." - (lsp-foreach-workspace - (cl-callf2 delq (lsp-current-buffer) (lsp--workspace-buffers lsp--cur-workspace)) - (with-demoted-errors "Error sending didClose notification in ‘lsp--text-document-did-close’: %S" - (lsp-notify "textDocument/didClose" - `(:textDocument ,(lsp--text-document-identifier)))) - (when (and (not lsp-keep-workspace-alive) - (not keep-workspace-alive) - (not (lsp--workspace-buffers lsp--cur-workspace))) - (lsp--shutdown-workspace)))) - -(defun lsp--will-save-text-document-params (reason) - (list :textDocument (lsp--text-document-identifier) - :reason reason)) - -(defun lsp--before-save () - "Before save handler." - (with-demoted-errors "Error in ‘lsp--before-save’: %S" - (let ((params (lsp--will-save-text-document-params 1))) - (when (lsp--send-will-save-p) - (lsp-notify "textDocument/willSave" params)) - (when (and (lsp--send-will-save-wait-until-p) lsp-before-save-edits) - (let ((lsp-response-timeout 0.1)) - (condition-case nil - (lsp--apply-text-edits - (lsp-request "textDocument/willSaveWaitUntil" - params) - 'before-save) - (error))))))) - -(defun lsp--on-auto-save () - "Handler for auto-save." - (when (lsp--send-will-save-p) - (with-demoted-errors "Error in ‘lsp--on-auto-save’: %S" - (lsp-notify "textDocument/willSave" (lsp--will-save-text-document-params 2))))) - -(defun lsp--text-document-did-save () - "Executed when the file is closed, added to `after-save-hook''." - (when (lsp--send-did-save-p) - (with-demoted-errors "Error on ‘lsp--text-document-did-save: %S’" - (lsp-notify "textDocument/didSave" - `( :textDocument ,(lsp--versioned-text-document-identifier) - ,@(when (lsp--save-include-text-p) - (list :text (lsp--buffer-content)))))))) - -(defun lsp--text-document-position-params (&optional identifier position) - "Make TextDocumentPositionParams for the current point in the current document. -If IDENTIFIER and POSITION are non-nil, they will be used as the document -identifier and the position respectively." - (list :textDocument (or identifier (lsp--text-document-identifier)) - :position (or position (lsp--cur-position)))) - -(defun lsp--get-buffer-diagnostics () - "Return buffer diagnostics." - (gethash (or - (plist-get lsp--virtual-buffer :buffer-file-name) - (lsp--fix-path-casing (buffer-file-name))) - (lsp-diagnostics t))) - -(defun lsp-cur-line-diagnostics () - "Return any diagnostics that apply to the current line." - (-let [(&plist :start (&plist :line start) :end (&plist :line end)) (lsp--region-or-line)] - (cl-coerce (-filter - (-lambda ((&Diagnostic :range (&Range :start (&Position :line)))) - (and (>= line start) (<= line end))) - (lsp--get-buffer-diagnostics)) - 'vector))) - -(lsp-defun lsp-range-overlapping?((left &as &Range :start left-start :end left-end) - (right &as &Range :start right-start :end right-end)) - (or (lsp-point-in-range? right-start left) - (lsp-point-in-range? right-end left) - (lsp-point-in-range? left-start right) - (lsp-point-in-range? left-end right))) - -(defun lsp-make-position-1 (position) - (lsp-make-position :line (plist-get position :line) - :character (plist-get position :character))) - -(defun lsp-cur-possition-diagnostics () - "Return any diagnostics that apply to the current line." - (-let* ((start (if (use-region-p) (region-beginning) (point))) - (end (if (use-region-p) (region-end) (point))) - (current-range (lsp-make-range :start (lsp-make-position-1 (lsp-point-to-position start)) - :end (lsp-make-position-1 (lsp-point-to-position end))))) - (->> (lsp--get-buffer-diagnostics) - (-filter - (-lambda ((&Diagnostic :range)) - (lsp-range-overlapping? range current-range))) - (apply 'vector)))) - -(defalias 'lsp--cur-line-diagnotics 'lsp-cur-line-diagnostics) - -(defun lsp--extract-line-from-buffer (pos) - "Return the line pointed to by POS (a Position object) in the current buffer." - (let* ((point (lsp--position-to-point pos)) - (inhibit-field-text-motion t)) - (save-excursion - (goto-char point) - (buffer-substring (line-beginning-position) (line-end-position))))) - -(lsp-defun lsp--xref-make-item (filename (&Range :start (start &as &Position :character start-char :line start-line) - :end (end &as &Position :character end-char))) - "Return a xref-item from a RANGE in FILENAME." - (let* ((line (lsp--extract-line-from-buffer start)) - (len (length line))) - (add-face-text-property (max (min start-char len) 0) - (max (min end-char len) 0) - 'xref-match t line) - ;; LINE is nil when FILENAME is not being current visited by any buffer. - (xref-make (or line filename) - (xref-make-file-location - filename - (lsp-translate-line (1+ start-line)) - (lsp-translate-column start-char))))) - -(defun lsp--location-uri (loc) - (if (lsp-location? loc) - (lsp:location-uri loc) - (lsp:location-link-target-uri loc))) - -(lsp-defun lsp-goto-location ((loc &as &Location :uri :range (&Range :start))) - "Go to location." - (let ((path (lsp--uri-to-path uri))) - (if (f-exists? path) - (with-current-buffer (find-file path) - (goto-char (lsp--position-to-point start))) - (error "There is no file %s" path)))) - -(defun lsp--location-range (loc) - (if (lsp-location? loc) - (lsp:location-range loc) - (lsp:location-link-target-selection-range loc))) - -(defun lsp--locations-to-xref-items (locations) - "Return a list of `xref-item' given LOCATIONS, which can be of -type Location, LocationLink, Location[] or LocationLink[]." - (setq locations - (pcase locations - ((seq (or (Location) - (LocationLink))) - (append locations nil)) - ((or (Location) - (LocationLink)) - (list locations)))) - - (cl-labels ((get-xrefs-in-file - (file-locs) - (-let [(filename . matches) file-locs] - (condition-case err - (let ((visiting (find-buffer-visiting filename)) - (fn (lambda (loc) - (lsp-with-filename filename - (lsp--xref-make-item filename - (lsp--location-range loc)))))) - (if visiting - (with-current-buffer visiting - (seq-map fn matches)) - (when (file-readable-p filename) - (with-temp-buffer - (insert-file-contents-literally filename) - (seq-map fn matches))))) - (error (lsp-warn "Failed to process xref entry for filename '%s': %s" - filename (error-message-string err))) - (file-error (lsp-warn "Failed to process xref entry, file-error, '%s': %s" - filename (error-message-string err))))))) - - (->> locations - (seq-sort #'lsp--location-before-p) - (seq-group-by (-compose #'lsp--uri-to-path #'lsp--location-uri)) - (seq-map #'get-xrefs-in-file) - (apply #'nconc)))) - -(defun lsp--location-before-p (left right) - "Sort first by file, then by line, then by column." - (let ((left-uri (lsp--location-uri left)) - (right-uri (lsp--location-uri right))) - (if (not (string= left-uri right-uri)) - (string< left-uri right-uri) - (-let (((&Range :start left-start) (lsp--location-range left)) - ((&Range :start right-start) (lsp--location-range right))) - (lsp--position-compare right-start left-start))))) - -(defun lsp--make-reference-params (&optional td-position exclude-declaration) - "Make a ReferenceParam object. -If TD-POSITION is non-nil, use it as TextDocumentPositionParams object instead. -If EXCLUDE-DECLARATION is non-nil, request the server to include declarations." - (let ((json-false :json-false)) - (plist-put (or td-position (lsp--text-document-position-params)) - :context `(:includeDeclaration ,(lsp-json-bool (not exclude-declaration)))))) - -(defun lsp--cancel-request (id) - "Cancel request with ID in all workspaces." - (lsp-foreach-workspace - (->> lsp--cur-workspace lsp--workspace-client lsp--client-response-handlers (remhash id)) - (lsp-notify "$/cancelRequest" `(:id ,id)))) - -(defvar-local lsp--hover-saved-bounds nil) - -(defun lsp-eldoc-function (cb &rest _ignored) - "`lsp-mode' eldoc function to display hover info (based on `textDocument/hover')." - (if (and lsp--hover-saved-bounds - (lsp--point-in-bounds-p lsp--hover-saved-bounds)) - lsp--eldoc-saved-message - (setq lsp--hover-saved-bounds nil - lsp--eldoc-saved-message nil) - (if (looking-at-p "[[:space:]\n]") - (setq lsp--eldoc-saved-message nil) ; And returns nil. - (when (and lsp-eldoc-enable-hover (lsp-feature? "textDocument/hover")) - (lsp-request-async - "textDocument/hover" - (lsp--text-document-position-params) - (-lambda ((hover &as &Hover? :range? :contents)) - (setq lsp--hover-saved-bounds (when range? - (lsp--range-to-region range?))) - (funcall cb (setq lsp--eldoc-saved-message - (when contents - (lsp--render-on-hover-content - contents - lsp-eldoc-render-all))))) - :error-handler #'ignore - :mode 'tick - :cancel-token :eldoc-hover))))) - -(defun lsp--point-on-highlight? () - (-some? (lambda (overlay) - (overlay-get overlay 'lsp-highlight)) - (overlays-at (point)))) - -(defun lsp--cleanup-highlights-if-needed () - (when (and lsp-enable-symbol-highlighting - lsp--have-document-highlights - (not (lsp--point-on-highlight?))) - (lsp--remove-overlays 'lsp-highlight) - (setq lsp--have-document-highlights nil) - (lsp-cancel-request-by-token :highlights))) - -(defvar-local lsp--symbol-bounds-of-last-highlight-invocation nil - "The bounds of the symbol from which `lsp--document-highlight' - most recently requested highlights.") - -(defun lsp--document-highlight () - (when (lsp-feature? "textDocument/documentHighlight") - (let ((curr-sym-bounds (bounds-of-thing-at-point 'symbol))) - (unless (or (looking-at-p "[[:space:]\n]") - (not lsp-enable-symbol-highlighting) - (and lsp--have-document-highlights - curr-sym-bounds - (equal curr-sym-bounds - lsp--symbol-bounds-of-last-highlight-invocation))) - (setq lsp--symbol-bounds-of-last-highlight-invocation - curr-sym-bounds) - (lsp-request-async "textDocument/documentHighlight" - (lsp--text-document-position-params) - #'lsp--document-highlight-callback - :mode 'tick - :cancel-token :highlights))))) - -(defun lsp--help-open-link (&rest _) - "Open markdown link at point via mouse or keyboard." - (interactive "P") - (let ((buffer-list-update-hook nil)) - (-let [(buffer point) (if-let* ((valid (and (listp last-input-event) - (eq (car last-input-event) 'mouse-2))) - (event (cadr last-input-event)) - (win (posn-window event)) - (buffer (window-buffer win))) - `(,buffer ,(posn-point event)) - `(,(current-buffer) ,(point)))] - (with-current-buffer buffer - (when-let* ((face (get-text-property point 'face)) - (url (or (and (eq face 'markdown-link-face) - (get-text-property point 'help-echo)) - (and (memq face '(markdown-url-face markdown-plain-url-face)) - (nth 3 (markdown-link-at-pos point)))))) - (lsp--document-link-handle-target url)))))) - -(defvar lsp-help-mode-map - (-doto (make-sparse-keymap) - (define-key [remap markdown-follow-link-at-point] #'lsp--help-open-link)) - "Keymap for `lsp-help-mode'.") - -(define-derived-mode lsp-help-mode help-mode "LspHelp" - "Major mode for displaying lsp help.") - -(defun lsp-describe-thing-at-point () - "Display the type signature and documentation of the thing at point." - (interactive) - (let ((contents (-some->> (lsp--text-document-position-params) - (lsp--make-request "textDocument/hover") - (lsp--send-request) - (lsp:hover-contents)))) - (if (and contents (not (equal contents ""))) - (let ((lsp-help-buf-name "*lsp-help*")) - (with-current-buffer (get-buffer-create lsp-help-buf-name) - (delay-mode-hooks - (lsp-help-mode) - (with-help-window lsp-help-buf-name - (insert (string-trim-right (lsp--render-on-hover-content contents t))))) - (run-mode-hooks))) - (lsp--info "No content at point.")))) - -(defun lsp--point-in-bounds-p (bounds) - "Return whether the current point is within BOUNDS." - (and (<= (car bounds) (point)) (< (point) (cdr bounds)))) - -(defun lsp-get-renderer (language) - "Get renderer for LANGUAGE." - (lambda (str) - (lsp--render-string str language))) - -(defun lsp--setup-markdown (mode) - "Setup the ‘markdown-mode’ in the frame. -MODE is the mode used in the parent frame." - (make-local-variable 'markdown-code-lang-modes) - (dolist (mark (alist-get mode lsp-custom-markup-modes)) - (add-to-list 'markdown-code-lang-modes (cons mark mode))) - (setq-local markdown-fontify-code-blocks-natively t) - (setq-local markdown-fontify-code-block-default-mode mode) - (setq-local markdown-hide-markup t) - - ;; Render some common HTML entities. - ;; This should really happen in markdown-mode instead, - ;; but it doesn't, so we do it here for now. - (setq prettify-symbols-alist - (cl-loop for i from 0 to 255 - collect (cons (format "&#x%02X;" i) i))) - (push '("&lt;" . ?<) prettify-symbols-alist) - (push '("&gt;" . ?>) prettify-symbols-alist) - (push '("&amp;" . ?&) prettify-symbols-alist) - (push '("&nbsp;" . ? ) prettify-symbols-alist) - (setq prettify-symbols-compose-predicate - (lambda (_start _end _match) t)) - (prettify-symbols-mode 1)) - -(defvar lsp-help-link-keymap - (let ((map (make-sparse-keymap))) - (define-key map [mouse-2] #'lsp--help-open-link) - (define-key map "\r" #'lsp--help-open-link) - map) - "Keymap active on links in *lsp-help* mode.") - -(defun lsp--fix-markdown-links () - (let ((inhibit-read-only t) - (inhibit-modification-hooks t) - (prop)) - (save-restriction - (goto-char (point-min)) - (while (setq prop (markdown-find-next-prop 'face)) - (let ((end (or (next-single-property-change (car prop) 'face) - (point-max)))) - (when (memq (get-text-property (car prop) 'face) - '(markdown-link-face - markdown-url-face - markdown-plain-url-face)) - (add-text-properties (car prop) end - (list 'button t - 'category 'lsp-help-link - 'follow-link t - 'keymap lsp-help-link-keymap))) - (goto-char end)))))) - -(defun lsp--buffer-string-visible () - "Return visible buffer string. -Stolen from `org-copy-visible'." - (let ((temp (generate-new-buffer " *temp*")) - (beg (point-min)) - (end (point-max))) - (while (/= beg end) - (when (get-char-property beg 'invisible) - (setq beg (next-single-char-property-change beg 'invisible nil end))) - (let* ((next (next-single-char-property-change beg 'invisible nil end)) - (substring (buffer-substring beg next))) - (with-current-buffer temp (insert substring)) - ;; (setq result (concat result substring)) - (setq beg next))) - (setq deactivate-mark t) - (prog1 (with-current-buffer temp - (s-chop-suffix "\n" (buffer-string))) - (kill-buffer temp)))) - -(defvar lsp-buffer-major-mode nil - "Holds the major mode when fontification function is running. -See #2588") - -(defvar view-inhibit-help-message) - -(defun lsp--render-markdown () - "Render markdown." - - (let ((markdown-enable-math nil)) - (goto-char (point-min)) - (while (re-search-forward - (rx (and "\\" (group (or "\\" "`" "*" "_" ":" "/" - "{" "}" "[" "]" "(" ")" - "#" "+" "-" "." "!" "|")))) - nil t) - (replace-match (rx (backref 1)))) - - ;; markdown-mode v2.3 does not yet provide gfm-view-mode - (if (fboundp 'gfm-view-mode) - (let ((view-inhibit-help-message t)) - (gfm-view-mode)) - (gfm-mode)) - - (lsp--setup-markdown lsp-buffer-major-mode))) - -(defvar lsp--display-inline-image-alist - '((lsp--render-markdown - (:regexp - "!\\[.*?\\](data:image/[a-zA-Z]+;base64,\\([A-Za-z0-9+/\n]+?=*?\\)\\(|[^)]+\\)?)" - :sexp - (create-image - (base64-decode-string - (buffer-substring-no-properties (match-beginning 1) (match-end 1))) - nil t)))) - "Replaced string regexp and function returning image. -Each element should have the form (MODE . (PROPERTY-LIST...)). -MODE (car) is function which is defined in `lsp-language-id-configuration'. -Cdr should be list of PROPERTY-LIST. - -Each PROPERTY-LIST should have properties: -:regexp Regexp which determines what string is relpaced to image. - You should also get information of image, by parenthesis constructs. - By default, all matched string is replaced to image, but you can - change index of replaced string by keyword :replaced-index. - -:sexp Return image when evaluated. You can use information of regexp - by using (match-beggining N), (match-end N) or (match-substring N). - -In addition, each can have property: -:replaced-index Determine index which is used to replace regexp to image. - The value means first argument of `match-beginning' and - `match-end'. If omitted, interpreted as index 0.") - -(defcustom lsp-display-inline-image t - "Showing inline image or not." - :group 'lsp-mode - :type 'boolean) - -(defcustom lsp-enable-suggest-server-download t - "When non-nil enable server downloading suggestions." - :group 'lsp-mode - :type 'boolean - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-auto-register-remote-clients t - "When non-nil register remote when registering the local one." - :group 'lsp-mode - :type 'boolean - :package-version '(lsp-mode . "9.0.0")) - -(defun lsp--display-inline-image (mode) - "Add image property if available." - (let ((plist-list (cdr (assq mode lsp--display-inline-image-alist)))) - (when (and (display-images-p) lsp-display-inline-image) - (cl-loop - for plist in plist-list - with regexp with replaced-index - do - (setq regexp (plist-get plist :regexp)) - (setq replaced-index (or (plist-get plist :replaced-index) 0)) - - (font-lock-remove-keywords nil (list regexp replaced-index)) - (let ((inhibit-read-only t)) - (save-excursion - (goto-char (point-min)) - (while (re-search-forward regexp nil t) - (set-text-properties - (match-beginning replaced-index) (match-end replaced-index) - nil) - (add-text-properties - (match-beginning replaced-index) (match-end replaced-index) - `(display ,(eval (plist-get plist :sexp))))))))))) - -(defun lsp--fontlock-with-mode (str mode) - "Fontlock STR with MODE." - (let ((lsp-buffer-major-mode major-mode)) - (with-temp-buffer - (with-demoted-errors "Error during doc rendering: %s" - (insert str) - (delay-mode-hooks (funcall mode)) - (cl-flet ((window-body-width () lsp-window-body-width)) - ;; This can go wrong in some cases, and the fontification would - ;; not work as expected. - ;; - ;; See #2984 - (ignore-errors (font-lock-ensure)) - (lsp--display-inline-image mode) - (when (eq mode 'lsp--render-markdown) - (lsp--fix-markdown-links)))) - (lsp--buffer-string-visible)))) - -(defun lsp--render-string (str language) - "Render STR using `major-mode' corresponding to LANGUAGE. -When language is nil render as markup if `markdown-mode' is loaded." - (setq str (s-replace "\r" "" (or str ""))) - (if-let* ((modes (-keep (-lambda ((mode . lang)) - (when (and (equal lang language) (functionp mode)) - mode)) - lsp-language-id-configuration)) - (mode (car (or (member major-mode modes) modes)))) - (lsp--fontlock-with-mode str mode) - str)) - -(defun lsp--render-element (content) - "Render CONTENT element." - (let ((inhibit-message t)) - (or - (pcase content - ((MarkedString :value :language) - (lsp--render-string value language)) - ((MarkupContent :value :kind) - (lsp--render-string value kind)) - ;; plain string - ((pred stringp) (lsp--render-string content "markdown")) - ((pred null) "") - (_ (error "Failed to handle %s" content))) - ""))) - -(defun lsp--create-unique-string-fn () - (let (elements) - (lambda (element) - (let ((count (cl-count element elements :test #'string=))) - (prog1 (if (zerop count) - element - (format "%s (%s)" element count)) - (push element elements)))))) - -(defun lsp--select-action (actions) - "Select an action to execute from ACTIONS." - (cond - ((seq-empty-p actions) (signal 'lsp-no-code-actions nil)) - ((and (eq (seq-length actions) 1) lsp-auto-execute-action) - (lsp-seq-first actions)) - (t (let ((completion-ignore-case t)) - (lsp--completing-read "Select code action: " - (seq-into actions 'list) - (-compose (lsp--create-unique-string-fn) - #'lsp:code-action-title) - nil t))))) - -(defun lsp--workspace-server-id (workspace) - "Return the server ID of WORKSPACE." - (-> workspace lsp--workspace-client lsp--client-server-id)) - -(defun lsp--handle-rendered-for-echo-area (contents) - "Return a single line from RENDERED, appropriate for display in the echo area." - (pcase (lsp-workspaces) - (`(,workspace) - (lsp-clients-extract-signature-on-hover contents (lsp--workspace-server-id workspace))) - ;; For projects with multiple active workspaces we also default to - ;; render the first line. - (_ (lsp-clients-extract-signature-on-hover contents nil)))) - -(cl-defmethod lsp-clients-extract-signature-on-hover (contents _server-id) - "Extract a representative line from CONTENTS, to show in the echo area." - (car (s-lines (s-trim (lsp--render-element contents))))) - -(defun lsp--render-on-hover-content (contents render-all) - "Render the content received from `document/onHover' request. -CONTENTS - MarkedString | MarkedString[] | MarkupContent -RENDER-ALL - nil if only the signature should be rendered." - (cond - ((lsp-markup-content? contents) - ;; MarkupContent. - ;; It tends to be long and is not suitable to display fully in the echo area. - ;; Just display the first line which is typically the signature. - (if render-all - (lsp--render-element contents) - (lsp--handle-rendered-for-echo-area contents))) - ((and (stringp contents) (not (string-match-p "\n" contents))) - ;; If the contents is a single string containing a single line, - ;; render it always. - (lsp--render-element contents)) - (t - ;; MarkedString -> MarkedString[] - (when (or (lsp-marked-string? contents) (stringp contents)) - (setq contents (list contents))) - ;; Consider the signature consisting of the elements who have a renderable - ;; "language" property. When render-all is nil, ignore other elements. - (string-join - (seq-map - #'lsp--render-element - (if render-all - contents - ;; Only render contents that have an available renderer. - (seq-take - (seq-filter - (-andfn #'lsp-marked-string? - (-compose #'lsp-get-renderer #'lsp:marked-string-language)) - contents) - 1))) - (if (bound-and-true-p page-break-lines-mode) - "\n \n" - "\n"))))) - - - -(defvar lsp-signature-mode-map - (-doto (make-sparse-keymap) - (define-key (kbd "M-n") #'lsp-signature-next) - (define-key (kbd "M-p") #'lsp-signature-previous) - (define-key (kbd "M-a") #'lsp-signature-toggle-full-docs) - (define-key (kbd "C-c C-k") #'lsp-signature-stop) - (define-key (kbd "C-g") #'lsp-signature-stop)) - "Keymap for `lsp-signature-mode'.") - -(define-minor-mode lsp-signature-mode - "Mode used to show signature popup." - :keymap lsp-signature-mode-map - :lighter "" - :group 'lsp-mode) - -(defun lsp-signature-stop () - "Stop showing current signature help." - (interactive) - (lsp-cancel-request-by-token :signature) - (remove-hook 'post-command-hook #'lsp-signature) - (funcall lsp-signature-function nil) - (lsp-signature-mode -1)) - -(declare-function page-break-lines--update-display-tables "ext:page-break-lines") - -(defun lsp--setup-page-break-mode-if-present () - "Enable `page-break-lines-mode' in current buffer." - (when (fboundp 'page-break-lines-mode) - (page-break-lines-mode) - ;; force page-break-lines-mode to update the display tables. - (page-break-lines--update-display-tables))) - -(defun lsp-lv-message (message) - (add-hook 'lv-window-hook #'lsp--setup-page-break-mode-if-present) - (if message - (progn - (setq lsp--signature-last-buffer (current-buffer)) - (let ((lv-force-update t)) - (lv-message "%s" message))) - (lv-delete-window) - (remove-hook 'lv-window-hook #'lsp--setup-page-break-mode-if-present))) - -(declare-function posframe-show "ext:posframe") -(declare-function posframe-hide "ext:posframe") -(declare-function posframe-poshandler-point-bottom-left-corner-upward "ext:posframe") - -(defface lsp-signature-posframe - '((t :inherit tooltip)) - "Background and foreground for `lsp-signature-posframe'." - :group 'lsp-mode) - -(defvar lsp-signature-posframe-params - (list :poshandler #'posframe-poshandler-point-bottom-left-corner-upward - :height 10 - :width 60 - :border-width 1 - :min-width 60) - "Params for signature and `posframe-show'.") - -(defun lsp-signature-posframe (str) - "Use posframe to show the STR signatureHelp string." - (if str - (apply #'posframe-show - (with-current-buffer (get-buffer-create " *lsp-signature*") - (erase-buffer) - (insert str) - (visual-line-mode 1) - (lsp--setup-page-break-mode-if-present) - (current-buffer)) - (append - lsp-signature-posframe-params - (list :position (point) - :background-color (face-attribute 'lsp-signature-posframe :background nil t) - :foreground-color (face-attribute 'lsp-signature-posframe :foreground nil t) - :border-color (face-attribute 'font-lock-comment-face :foreground nil t)))) - (posframe-hide " *lsp-signature*"))) - -(defun lsp--handle-signature-update (signature) - (let ((message - (if (lsp-signature-help? signature) - (lsp--signature->message signature) - (mapconcat #'lsp--signature->message signature "\n")))) - (if (s-present? message) - (funcall lsp-signature-function message) - (lsp-signature-stop)))) - -(defun lsp-signature-activate () - "Activate signature help. -It will show up only if current point has signature help." - (interactive) - (setq lsp--signature-last nil - lsp--signature-last-index nil - lsp--signature-last-buffer (current-buffer)) - (add-hook 'post-command-hook #'lsp-signature) - (lsp-signature-mode t)) - -(defcustom lsp-signature-cycle t - "Whether `lsp-signature-next' and prev should cycle." - :type 'boolean - :group 'lsp-mode) - -(defun lsp-signature-next () - "Show next signature." - (interactive) - (let ((nsigs (length (lsp:signature-help-signatures lsp--signature-last)))) - (when (and lsp--signature-last-index - lsp--signature-last - (or lsp-signature-cycle (< (1+ lsp--signature-last-index) nsigs))) - (setq lsp--signature-last-index (% (1+ lsp--signature-last-index) nsigs)) - (funcall lsp-signature-function (lsp--signature->message lsp--signature-last))))) - -(defun lsp-signature-previous () - "Next signature." - (interactive) - (when (and lsp--signature-last-index - lsp--signature-last - (or lsp-signature-cycle (not (zerop lsp--signature-last-index)))) - (setq lsp--signature-last-index (1- (if (zerop lsp--signature-last-index) - (length (lsp:signature-help-signatures lsp--signature-last)) - lsp--signature-last-index))) - (funcall lsp-signature-function (lsp--signature->message lsp--signature-last)))) - -(defun lsp-signature-toggle-full-docs () - "Toggle full/partial signature documentation." - (interactive) - (let ((all? (not (numberp lsp-signature-doc-lines)))) - (setq lsp-signature-doc-lines (if all? - (or (car-safe lsp-signature-doc-lines) - 20) - (list lsp-signature-doc-lines)))) - (lsp-signature-activate)) - -(defun lsp--signature->message (signature-help) - "Generate eldoc message from SIGNATURE-HELP response." - (setq lsp--signature-last signature-help) - - (when (and signature-help (not (seq-empty-p (lsp:signature-help-signatures signature-help)))) - (-let* (((&SignatureHelp :active-signature? - :active-parameter? - :signatures) signature-help) - (active-signature? (or lsp--signature-last-index active-signature? 0)) - (_ (setq lsp--signature-last-index active-signature?)) - ((signature &as &SignatureInformation? :label :parameters?) (seq-elt signatures active-signature?)) - (prefix (if (= (length signatures) 1) - "" - (concat (propertize (format " %s/%s" - (1+ active-signature?) - (length signatures)) - 'face 'success) - " "))) - (method-docs (when - (and lsp-signature-render-documentation - (or (not (numberp lsp-signature-doc-lines)) (< 0 lsp-signature-doc-lines))) - (let ((docs (lsp--render-element - (lsp:parameter-information-documentation? signature)))) - (when (s-present? docs) - (concat - "\n" - (if (fboundp 'page-break-lines-mode) - " \n" - "") - (if (and (numberp lsp-signature-doc-lines) - (> (length (s-lines docs)) lsp-signature-doc-lines)) - (concat (s-join "\n" (-take lsp-signature-doc-lines (s-lines docs))) - (propertize "\nTruncated..." 'face 'highlight)) - docs))))))) - (when (and active-parameter? (not (seq-empty-p parameters?))) - (-when-let* ((param (when (and (< -1 active-parameter? (length parameters?))) - (seq-elt parameters? active-parameter?))) - (selected-param-label (let ((label (lsp:parameter-information-label param))) - (if (stringp label) label (append label nil)))) - (start (if (stringp selected-param-label) - (s-index-of selected-param-label label) - (cl-first selected-param-label))) - (end (if (stringp selected-param-label) - (+ start (length selected-param-label)) - (cl-second selected-param-label)))) - (add-face-text-property start end 'eldoc-highlight-function-argument nil label))) - (concat prefix label method-docs)))) - -(defun lsp-signature () - "Display signature info (based on `textDocument/signatureHelp')" - (if (and lsp--signature-last-buffer - (not (equal (current-buffer) lsp--signature-last-buffer))) - (lsp-signature-stop) - (lsp-request-async "textDocument/signatureHelp" - (lsp--text-document-position-params) - #'lsp--handle-signature-update - :cancel-token :signature))) - - -(defcustom lsp-overlay-document-color-char "■" - "Display the char represent the document color in overlay" - :type 'string - :group 'lsp-mode) - -;; color presentation -(defun lsp--color-create-interactive-command (color range) - (lambda () - (interactive) - (-let [(&ColorPresentation? :text-edit? - :additional-text-edits?) - (lsp--completing-read - "Select color presentation: " - (lsp-request - "textDocument/colorPresentation" - `( :textDocument ,(lsp--text-document-identifier) - :color ,color - :range ,range)) - #'lsp:color-presentation-label - nil - t)] - (when text-edit? - (lsp--apply-text-edit text-edit?)) - (when additional-text-edits? - (lsp--apply-text-edits additional-text-edits? 'color-presentation))))) - -(defun lsp--number->color (number) - (let ((result (format "%x" - (round (* (or number 0) 255.0))))) - (if (= 1 (length result)) - (concat "0" result) - result))) - -(defun lsp--document-color () - "Document color handler." - (when (lsp-feature? "textDocument/documentColor") - (lsp-request-async - "textDocument/documentColor" - `(:textDocument ,(lsp--text-document-identifier)) - (lambda (result) - (lsp--remove-overlays 'lsp-color) - (seq-do - (-lambda ((&ColorInformation :color (color &as &Color :red :green :blue) - :range)) - (-let* (((beg . end) (lsp--range-to-region range)) - (overlay (make-overlay beg end)) - (command (lsp--color-create-interactive-command color range))) - (overlay-put overlay 'lsp-color t) - (overlay-put overlay 'evaporate t) - (overlay-put overlay - 'before-string - (propertize - lsp-overlay-document-color-char - 'face `((:foreground ,(format - "#%s%s%s" - (lsp--number->color red) - (lsp--number->color green) - (lsp--number->color blue)))) - 'action command - 'mouse-face 'lsp-lens-mouse-face - 'local-map (-doto (make-sparse-keymap) - (define-key [mouse-1] command)))))) - result)) - :mode 'unchanged - :cancel-token :document-color-token))) - - - -(defun lsp--action-trigger-parameter-hints (_command) - "Handler for editor.action.triggerParameterHints." - (when (member :on-server-request lsp-signature-auto-activate) - (lsp-signature-activate))) - -(defun lsp--action-trigger-suggest (_command) - "Handler for editor.action.triggerSuggest." - (cond - ((and (bound-and-true-p company-mode) - (fboundp 'company-auto-begin) - (fboundp 'company-post-command)) - (run-at-time 0 nil - (lambda () - (let ((this-command 'company-idle-begin) - (company-minimum-prefix-length 0)) - (company-auto-begin) - (company-post-command))))) - (t - (completion-at-point)))) - -(defconst lsp--default-action-handlers - (ht ("editor.action.triggerParameterHints" #'lsp--action-trigger-parameter-hints) - ("editor.action.triggerSuggest" #'lsp--action-trigger-suggest)) - "Default action handlers.") - -(defun lsp--find-action-handler (command) - "Find action handler for particular COMMAND." - (or - (--some (-some->> it - (lsp--workspace-client) - (lsp--client-action-handlers) - (gethash command)) - (lsp-workspaces)) - (gethash command lsp--default-action-handlers))) - -(defun lsp--text-document-code-action-params (&optional kind) - "Code action params." - (list :textDocument (lsp--text-document-identifier) - :range (if (use-region-p) - (lsp--region-to-range (region-beginning) (region-end)) - (lsp--region-to-range (point) (point))) - :context `( :diagnostics ,(lsp-cur-possition-diagnostics) - ,@(when kind (list :only (vector kind)))))) - -(defun lsp-code-actions-at-point (&optional kind) - "Retrieve the code actions for the active region or the current line. -It will filter by KIND if non nil." - (lsp-request "textDocument/codeAction" (lsp--text-document-code-action-params kind))) - -(defun lsp-execute-code-action-by-kind (command-kind) - "Execute code action by COMMAND-KIND." - (if-let ((action (->> (lsp-get-or-calculate-code-actions command-kind) - (-filter (-lambda ((&CodeAction :kind?)) - (and kind? (s-prefix? command-kind kind?)))) - lsp--select-action))) - (lsp-execute-code-action action) - (signal 'lsp-no-code-actions '(command-kind)))) - -(defalias 'lsp-get-or-calculate-code-actions 'lsp-code-actions-at-point) - -(lsp-defun lsp--execute-command ((action &as &Command :command :arguments?)) - "Parse and execute a code ACTION represented as a Command LSP type." - (let ((server-id (->> (lsp-workspaces) - (cl-first) - (or lsp--cur-workspace) - (lsp--workspace-client) - (lsp--client-server-id)))) - (condition-case nil - (with-no-warnings - (lsp-execute-command server-id (intern command) arguments?)) - (cl-no-applicable-method - (if-let ((action-handler (lsp--find-action-handler command))) - (funcall action-handler action) - (lsp-send-execute-command command arguments?)))))) - -(lsp-defun lsp-execute-code-action ((action &as &CodeAction :command? :edit?)) - "Execute code action ACTION. For example, when text under the -caret has a suggestion to apply a fix from an lsp-server, calling -this function will do so. -If ACTION is not set it will be selected from `lsp-code-actions-at-point'. -Request codeAction/resolve for more info if server supports." - (interactive (list (lsp--select-action (lsp-code-actions-at-point)))) - (if (and (lsp-feature? "codeAction/resolve") - (not command?) - (not edit?)) - (lsp--execute-code-action (lsp-request "codeAction/resolve" action)) - (lsp--execute-code-action action))) - -(lsp-defun lsp--execute-code-action ((action &as &CodeAction :command? :edit?)) - "Execute code action ACTION." - (when edit? - (lsp--apply-workspace-edit edit? 'code-action)) - - (cond - ((stringp command?) (lsp--execute-command action)) - ((lsp-command? command?) (lsp--execute-command command?)))) - -(defvar lsp--formatting-indent-alist - ;; Taken from `dtrt-indent-mode' - '( - (ada-mode . ada-indent) ; Ada - (ada-ts-mode . ada-ts-mode-indent-offset) - (c++-mode . c-basic-offset) ; C++ - (c++-ts-mode . c-ts-mode-indent-offset) - (c-mode . c-basic-offset) ; C - (c-ts-mode . c-ts-mode-indent-offset) - (cperl-mode . cperl-indent-level) ; Perl - (crystal-mode . crystal-indent-level) ; Crystal (Ruby) - (csharp-mode . c-basic-offset) ; C# - (csharp-tree-sitter-mode . csharp-tree-sitter-indent-offset) ; C# - (csharp-ts-mode . csharp-ts-mode-indent-offset) ; C# (tree-sitter, Emacs29) - (css-mode . css-indent-offset) ; CSS - (d-mode . c-basic-offset) ; D - (enh-ruby-mode . enh-ruby-indent-level) ; Ruby - (erlang-mode . erlang-indent-level) ; Erlang - (ess-mode . ess-indent-offset) ; ESS (R) - (go-ts-mode . go-ts-mode-indent-offset) - (gpr-mode . gpr-indent-offset) ; GNAT Project - (gpr-ts-mode . gpr-ts-mode-indent-offset) - (hack-mode . hack-indent-offset) ; Hack - (java-mode . c-basic-offset) ; Java - (java-ts-mode . java-ts-mode-indent-offset) - (jde-mode . c-basic-offset) ; Java (JDE) - (js-mode . js-indent-level) ; JavaScript - (js-ts-mode . js-indent-level) - (js2-mode . js2-basic-offset) ; JavaScript-IDE - (js3-mode . js3-indent-level) ; JavaScript-IDE - (json-mode . js-indent-level) ; JSON - (json-ts-mode . json-ts-mode-indent-offset) - (lua-mode . lua-indent-level) ; Lua - (lua-ts-mode . lua-ts-indent-offset) - (nxml-mode . nxml-child-indent) ; XML - (objc-mode . c-basic-offset) ; Objective C - (pascal-mode . pascal-indent-level) ; Pascal - (perl-mode . perl-indent-level) ; Perl - (php-mode . c-basic-offset) ; PHP - (php-ts-mode . php-ts-mode-indent-offset) ; PHP - (powershell-mode . powershell-indent) ; PowerShell - (powershell-ts-mode . powershell-ts-mode-indent-offset) ; PowerShell - (raku-mode . raku-indent-offset) ; Perl6/Raku - (ruby-mode . ruby-indent-level) ; Ruby - (rust-mode . rust-indent-offset) ; Rust - (rust-ts-mode . rust-ts-mode-indent-offset) - (rustic-mode . rustic-indent-offset) ; Rust - (scala-mode . scala-indent:step) ; Scala - (sgml-mode . sgml-basic-offset) ; SGML - (sh-mode . sh-basic-offset) ; Shell Script - (toml-ts-mode . toml-ts-mode-indent-offset) - (typescript-mode . typescript-indent-level) ; Typescript - (typescript-ts-mode . typescript-ts-mode-indent-offset) ; Typescript (tree-sitter, Emacs29) - (yaml-mode . yaml-indent-offset) ; YAML - (yang-mode . c-basic-offset) ; YANG (yang-mode) - - (default . standard-indent)) ; default fallback - "A mapping from `major-mode' to its indent variable.") - -(defun lsp--get-indent-width (mode) - "Get indentation offset for MODE." - (or (alist-get mode lsp--formatting-indent-alist) - (lsp--get-indent-width (or (get mode 'derived-mode-parent) 'default)))) - -(defun lsp--make-document-formatting-params () - "Create document formatting params." - (lsp-make-document-formatting-params - :text-document (lsp--text-document-identifier) - :options (lsp-make-formatting-options - :tab-size (symbol-value (lsp--get-indent-width major-mode)) - :insert-spaces (lsp-json-bool (not indent-tabs-mode)) - :trim-trailing-whitespace? (lsp-json-bool lsp-trim-trailing-whitespace) - :insert-final-newline? (lsp-json-bool lsp-insert-final-newline) - :trim-final-newlines? (lsp-json-bool lsp-trim-final-newlines)))) - -(defun lsp-format-buffer () - "Ask the server to format this document." - (interactive "*") - (cond ((lsp-feature? "textDocument/formatting") - (let ((edits (lsp-request "textDocument/formatting" - (lsp--make-document-formatting-params)))) - (if (seq-empty-p edits) - (lsp--info "No formatting changes provided") - (lsp--apply-text-edits edits 'format)))) - ((lsp-feature? "textDocument/rangeFormatting") - (save-restriction - (widen) - (lsp-format-region (point-min) (point-max)))) - (t (signal 'lsp-capability-not-supported (list "documentFormattingProvider"))))) - -(defun lsp-format-region (s e) - "Ask the server to format the region, or if none is selected, the current line." - (interactive "r") - (let ((edits (lsp-request - "textDocument/rangeFormatting" - (lsp--make-document-range-formatting-params s e)))) - (if (seq-empty-p edits) - (lsp--info "No formatting changes provided") - (lsp--apply-text-edits edits 'format)))) - -(defmacro lsp-make-interactive-code-action (func-name code-action-kind) - "Define an interactive function FUNC-NAME that attempts to -execute a CODE-ACTION-KIND action." - `(defun ,(intern (concat "lsp-" (symbol-name func-name))) () - ,(format "Perform the %s code action, if available." code-action-kind) - (interactive) - ;; Even when `lsp-auto-execute-action' is nil, it still makes sense to - ;; auto-execute here: the user has specified exactly what they want. - (let ((lsp-auto-execute-action t)) - (condition-case nil - (lsp-execute-code-action-by-kind ,code-action-kind) - (lsp-no-code-actions - (when (called-interactively-p 'any) - (lsp--info ,(format "%s action not available" code-action-kind)))))))) - -(lsp-make-interactive-code-action organize-imports "source.organizeImports") - -(defun lsp--make-document-range-formatting-params (start end) - "Make DocumentRangeFormattingParams for selected region." - (lsp:set-document-range-formatting-params-range (lsp--make-document-formatting-params) - (lsp--region-to-range start end))) - -(defconst lsp--highlight-kind-face - '((1 . lsp-face-highlight-textual) - (2 . lsp-face-highlight-read) - (3 . lsp-face-highlight-write))) - -(defun lsp--remove-overlays (name) - (save-restriction - (widen) - (remove-overlays (point-min) (point-max) name t))) - -(defun lsp-document-highlight () - "Highlight all relevant references to the symbol under point." - (interactive) - (lsp--remove-overlays 'lsp-highlight) ;; clear any previous highlights - (setq lsp--have-document-highlights nil - lsp--symbol-bounds-of-last-highlight-invocation nil) - (let ((lsp-enable-symbol-highlighting t)) - (lsp--document-highlight))) - -(defun lsp--document-highlight-callback (highlights) - "Create a callback to process the reply of a -`textDocument/documentHighlight' message for the buffer BUF. -A reference is highlighted only if it is visible in a window." - (lsp--remove-overlays 'lsp-highlight) - - (let* ((wins-visible-pos (-map (lambda (win) - (cons (1- (line-number-at-pos (window-start win) t)) - (1+ (line-number-at-pos (window-end win) t)))) - (get-buffer-window-list nil nil 'visible)))) - (setq lsp--have-document-highlights t) - (-map - (-lambda ((&DocumentHighlight :range (&Range :start (start &as &Position :line start-line) - :end (end &as &Position :line end-line)) - :kind?)) - (-map - (-lambda ((start-window . end-window)) - ;; Make the overlay only if the reference is visible - (let ((start-point (lsp--position-to-point start)) - (end-point (lsp--position-to-point end))) - (when (and (> (1+ start-line) start-window) - (< (1+ end-line) end-window) - (not (and lsp-symbol-highlighting-skip-current - (<= start-point (point) end-point)))) - (-doto (make-overlay start-point end-point) - (overlay-put 'face (cdr (assq (or kind? 1) lsp--highlight-kind-face))) - (overlay-put 'lsp-highlight t))))) - wins-visible-pos)) - highlights))) - -(defcustom lsp-symbol-kinds - '((1 . "File") - (2 . "Module") - (3 . "Namespace") - (4 . "Package") - (5 . "Class") - (6 . "Method") - (7 . "Property") - (8 . "Field") - (9 . "Constructor") - (10 . "Enum") - (11 . "Interface") - (12 . "Function") - (13 . "Variable") - (14 . "Constant") - (15 . "String") - (16 . "Number") - (17 . "Boolean") - (18 . "Array") - (19 . "Object") - (20 . "Key") - (21 . "Null") - (22 . "Enum Member") - (23 . "Struct") - (24 . "Event") - (25 . "Operator") - (26 . "Type Parameter")) - "Alist mapping SymbolKinds to human-readable strings. -Various Symbol objects in the LSP protocol have an integral type, -specifying what they are. This alist maps such type integrals to -readable representations of them. See -`https://microsoft.github.io/language-server-protocol/specifications/specification-current/', -namespace SymbolKind." - :group 'lsp-mode - :type '(alist :key-type integer :value-type string)) -(defalias 'lsp--symbol-kind 'lsp-symbol-kinds) - -(lsp-defun lsp--symbol-information-to-xref - ((&SymbolInformation :kind :name - :location (&Location :uri :range (&Range :start - (&Position :line :character))))) - "Return a `xref-item' from SYMBOL information." - (xref-make (format "[%s] %s" (alist-get kind lsp-symbol-kinds) name) - (xref-make-file-location (lsp--uri-to-path uri) - line - character))) - -(defun lsp--get-document-symbols () - "Get document symbols. - -If the buffer has not been modified since symbols were last -retrieved, simply return the latest result. - -Else, if the request was initiated by Imenu updating its menu-bar -entry, perform it asynchronously; i.e., give Imenu the latest -result and then force a refresh when a new one is available. - -Else (e.g., due to interactive use of `imenu' or `xref'), -perform the request synchronously." - (if (= (buffer-chars-modified-tick) lsp--document-symbols-tick) - lsp--document-symbols - (let ((method "textDocument/documentSymbol") - (params `(:textDocument ,(lsp--text-document-identifier))) - (tick (buffer-chars-modified-tick))) - (if (not lsp--document-symbols-request-async) - (prog1 - (setq lsp--document-symbols (lsp-request method params)) - (setq lsp--document-symbols-tick tick)) - (lsp-request-async method params - (lambda (document-symbols) - (setq lsp--document-symbols document-symbols - lsp--document-symbols-tick tick) - (lsp--imenu-refresh)) - :mode 'alive - :cancel-token :document-symbols) - lsp--document-symbols)))) - -(advice-add 'imenu-update-menubar :around - (lambda (oldfun &rest r) - (let ((lsp--document-symbols-request-async t)) - (apply oldfun r)))) - -(defun lsp--document-symbols->document-symbols-hierarchy (document-symbols current-position) - "Convert DOCUMENT-SYMBOLS to symbols hierarchy on CURRENT-POSITION." - (-let (((symbol &as &DocumentSymbol? :children?) - (seq-find (-lambda ((&DocumentSymbol :range)) - (lsp-point-in-range? current-position range)) - document-symbols))) - (if children? - (cons symbol (lsp--document-symbols->document-symbols-hierarchy children? current-position)) - (when symbol - (list symbol))))) - -(lsp-defun lsp--symbol-information->document-symbol ((&SymbolInformation :name :kind :location :container-name? :deprecated?)) - "Convert a SymbolInformation to a DocumentInformation" - (lsp-make-document-symbol :name name - :kind kind - :range (lsp:location-range location) - :children? nil - :deprecated? deprecated? - :selection-range (lsp:location-range location) - :detail? container-name?)) - -(defun lsp--symbols-informations->document-symbols-hierarchy (symbols-informations current-position) - "Convert SYMBOLS-INFORMATIONS to symbols hierarchy on CURRENT-POSITION." - (--> symbols-informations - (-keep (-lambda ((symbol &as &SymbolInformation :location (&Location :range))) - (when (lsp-point-in-range? current-position range) - (lsp--symbol-information->document-symbol symbol))) - it) - (sort it (-lambda ((&DocumentSymbol :range (&Range :start a-start-position :end a-end-position)) - (&DocumentSymbol :range (&Range :start b-start-position :end b-end-position))) - (and (lsp--position-compare b-start-position a-start-position) - (lsp--position-compare a-end-position b-end-position)))))) - -(defun lsp--symbols->document-symbols-hierarchy (symbols) - "Convert SYMBOLS to symbols-hierarchy." - (when-let ((first-symbol (lsp-seq-first symbols))) - (let ((cur-position (lsp-make-position :line (plist-get (lsp--cur-position) :line) - :character (plist-get (lsp--cur-position) :character)))) - (if (lsp-symbol-information? first-symbol) - (lsp--symbols-informations->document-symbols-hierarchy symbols cur-position) - (lsp--document-symbols->document-symbols-hierarchy symbols cur-position))))) - -(defun lsp--xref-backend () 'xref-lsp) - -(cl-defmethod xref-backend-identifier-at-point ((_backend (eql xref-lsp))) - (propertize (or (thing-at-point 'symbol) "") - 'identifier-at-point t)) - -(defun lsp--xref-elements-index (symbols path) - (-mapcat - (-lambda (sym) - (pcase-exhaustive sym - ((DocumentSymbol :name :children? :selection-range (Range :start)) - (cons (cons (concat path name) - (lsp--position-to-point start)) - (lsp--xref-elements-index children? (concat path name " / ")))) - ((SymbolInformation :name :location (Location :range (Range :start))) - (list (cons (concat path name) - (lsp--position-to-point start)))))) - symbols)) - -(defvar-local lsp--symbols-cache nil) - -(cl-defmethod xref-backend-identifier-completion-table ((_backend (eql xref-lsp))) - (if (lsp--find-workspaces-for "textDocument/documentSymbol") - (progn - (setq lsp--symbols-cache (lsp--xref-elements-index - (lsp--get-document-symbols) nil)) - lsp--symbols-cache) - (list (propertize (or (thing-at-point 'symbol) "") - 'identifier-at-point t)))) - -(cl-defmethod xref-backend-definitions ((_backend (eql xref-lsp)) identifier) - (save-excursion - (unless (get-text-property 0 'identifier-at-point identifier) - (goto-char (cl-rest (or (assoc identifier lsp--symbols-cache) - (user-error "Unable to find symbol %s in current document" identifier))))) - (lsp--locations-to-xref-items (lsp-request "textDocument/definition" - (lsp--text-document-position-params))))) - -(cl-defmethod xref-backend-references ((_backend (eql xref-lsp)) identifier) - (save-excursion - (unless (get-text-property 0 'identifier-at-point identifier) - (goto-char (cl-rest (or (assoc identifier lsp--symbols-cache) - (user-error "Unable to find symbol %s" identifier))))) - (lsp--locations-to-xref-items (lsp-request "textDocument/references" - (lsp--make-reference-params nil lsp-references-exclude-definition))))) - -(cl-defmethod xref-backend-apropos ((_backend (eql xref-lsp)) pattern) - (seq-map #'lsp--symbol-information-to-xref - (lsp-request "workspace/symbol" `(:query ,pattern)))) - -(defcustom lsp-rename-use-prepare t - "Whether `lsp-rename' should do a prepareRename first. -For some language servers, textDocument/prepareRename might be -too slow, in which case this variable may be set to nil. -`lsp-rename' will then use `thing-at-point' `symbol' to determine -the symbol to rename at point." - :group 'lsp-mode - :type 'boolean) - -(defun lsp--get-symbol-to-rename () - "Get a symbol to rename and placeholder at point. -Returns a cons ((START . END) . PLACEHOLDER?), and nil if -renaming is generally supported but cannot be done at point. -START and END are the bounds of the identifiers being renamed, -while PLACEHOLDER?, is either nil or a string suggested by the -language server as the initial input of a new-name prompt." - (unless (lsp-feature? "textDocument/rename") - (error "The connected server(s) doesn't support renaming")) - (if (and lsp-rename-use-prepare (lsp-feature? "textDocument/prepareRename")) - (when-let ((response - (lsp-request "textDocument/prepareRename" - (lsp--text-document-position-params)))) - (let* ((bounds (lsp--range-to-region - (if (lsp-range? response) - response - (lsp:prepare-rename-result-range response)))) - (placeholder - (and (not (lsp-range? response)) - (lsp:prepare-rename-result-placeholder response)))) - (cons bounds placeholder))) - (when-let ((bounds (bounds-of-thing-at-point 'symbol))) - (cons bounds nil)))) - -(defface lsp-face-rename '((t :underline t)) - "Face used to highlight the identifier being renamed. -Renaming can be done using `lsp-rename'." - :group 'lsp-mode) - -(defface lsp-rename-placeholder-face '((t :inherit font-lock-variable-name-face)) - "Face used to display the rename placeholder in. -When calling `lsp-rename' interactively, this will be the face of -the new name." - :group 'lsp-mode) - -(defvar lsp-rename-history '() - "History for `lsp--read-rename'.") - -(defun lsp--read-rename (at-point) - "Read a new name for a `lsp-rename' at `point' from the user. -AT-POINT shall be a structure as returned by -`lsp--get-symbol-to-rename'. - -Returns a string, which should be the new name for the identifier -at point. If renaming cannot be done at point (as determined from -AT-POINT), throw a `user-error'. - -This function is for use in `lsp-rename' only, and shall not be -relied upon." - (unless at-point - (user-error "`lsp-rename' is invalid here")) - (-let* ((((start . end) . placeholder?) at-point) - ;; Do the `buffer-substring' first to not include `lsp-face-rename' - (rename-me (buffer-substring start end)) - (placeholder (or placeholder? rename-me)) - (placeholder (propertize placeholder 'face 'lsp-rename-placeholder-face)) - - overlay) - ;; We need unwind protect, as the user might cancel here, causing the - ;; overlay to linger. - (unwind-protect - (progn - (setq overlay (make-overlay start end)) - (overlay-put overlay 'face 'lsp-face-rename) - - (read-string (format "Rename %s to: " rename-me) placeholder - 'lsp-rename-history)) - (and overlay (delete-overlay overlay))))) - -(defun lsp-rename (newname) - "Rename the symbol (and all references to it) under point to NEWNAME." - (interactive (list (lsp--read-rename (lsp--get-symbol-to-rename)))) - (when-let ((edits (lsp-request "textDocument/rename" - `( :textDocument ,(lsp--text-document-identifier) - :position ,(lsp--cur-position) - :newName ,newname)))) - (lsp--apply-workspace-edit edits 'rename))) - -(defun lsp--on-rename-file (old-func old-name new-name &optional ok-if-already-exists?) - "Advice around function `rename-file'. -Applies OLD-FUNC with OLD-NAME, NEW-NAME and OK-IF-ALREADY-EXISTS?. - -This advice sends workspace/willRenameFiles before renaming file -to check if server wants to apply any workspaceEdits after renamed." - (if (and lsp-apply-edits-after-file-operations - (lsp--send-will-rename-files-p old-name)) - (let ((params (lsp-make-rename-files-params - :files (vector (lsp-make-file-rename - :oldUri (lsp--path-to-uri old-name) - :newUri (lsp--path-to-uri new-name)))))) - (when-let ((edits (lsp-request "workspace/willRenameFiles" params))) - (lsp--apply-workspace-edit edits 'rename-file) - (funcall old-func old-name new-name ok-if-already-exists?) - (when (lsp--send-did-rename-files-p) - (lsp-notify "workspace/didRenameFiles" params)))) - (funcall old-func old-name new-name ok-if-already-exists?))) - -(advice-add 'rename-file :around #'lsp--on-rename-file) - -(defcustom lsp-xref-force-references nil - "If non-nil threat everything as references(e. g. jump if only one item.)" - :group 'lsp-mode - :type 'boolean) - -(defun lsp-show-xrefs (xrefs display-action references?) - (unless (region-active-p) (push-mark nil t)) - (if (boundp 'xref-show-definitions-function) - (with-no-warnings - (xref-push-marker-stack) - (funcall (if (and references? (not lsp-xref-force-references)) - xref-show-xrefs-function - xref-show-definitions-function) - (-const xrefs) - `((window . ,(selected-window)) - (display-action . ,display-action) - ,(if (and references? (not lsp-xref-force-references)) - `(auto-jump . ,xref-auto-jump-to-first-xref) - `(auto-jump . ,xref-auto-jump-to-first-definition))))) - (xref--show-xrefs xrefs display-action))) - -(cl-defmethod seq-empty-p ((ht hash-table)) - "Function `seq-empty-p' for hash-table." - (hash-table-empty-p ht)) - -(cl-defun lsp-find-locations (method &optional extra &key display-action references?) - "Send request named METHOD and get cross references of the symbol under point. -EXTRA is a plist of extra parameters. -REFERENCES? t when METHOD returns references." - (let ((loc (lsp-request method - (append (lsp--text-document-position-params) extra)))) - (if (seq-empty-p loc) - (lsp--error "Not found for: %s" (or (thing-at-point 'symbol t) "")) - (lsp-show-xrefs (lsp--locations-to-xref-items loc) display-action references?)))) - -(cl-defun lsp-find-declaration (&key display-action) - "Find declarations of the symbol under point." - (interactive) - (lsp-find-locations "textDocument/declaration" nil :display-action display-action)) - -(cl-defun lsp-find-definition (&key display-action) - "Find definitions of the symbol under point." - (interactive) - (lsp-find-locations "textDocument/definition" nil :display-action display-action)) - -(defun lsp-find-definition-mouse (click) - "Click to start `lsp-find-definition' at clicked point." - (interactive "e") - (let* ((ec (event-start click)) - (p1 (posn-point ec)) - (w1 (posn-window ec))) - (select-window w1) - (goto-char p1) - (lsp-find-definition))) - -(cl-defun lsp-find-implementation (&key display-action) - "Find implementations of the symbol under point." - (interactive) - (lsp-find-locations "textDocument/implementation" - nil - :display-action display-action - :references? t)) - -(cl-defun lsp-find-references (&optional exclude-declaration &key display-action) - "Find references of the symbol under point." - (interactive "P") - (lsp-find-locations "textDocument/references" - (list :context `(:includeDeclaration ,(lsp-json-bool (not (or exclude-declaration lsp-references-exclude-definition))))) - :display-action display-action - :references? t)) - -(cl-defun lsp-find-type-definition (&key display-action) - "Find type definitions of the symbol under point." - (interactive) - (lsp-find-locations "textDocument/typeDefinition" nil :display-action display-action)) - -(defalias 'lsp-find-custom #'lsp-find-locations) -(defalias 'lsp-goto-implementation #'lsp-find-implementation) -(defalias 'lsp-goto-type-definition #'lsp-find-type-definition) - -(with-eval-after-load 'evil - (evil-set-command-property 'lsp-find-definition :jump t) - (evil-set-command-property 'lsp-find-implementation :jump t) - (evil-set-command-property 'lsp-find-references :jump t) - (evil-set-command-property 'lsp-find-type-definition :jump t)) - -(defun lsp--workspace-method-supported? (check-command method capability workspace) - (with-lsp-workspace workspace - (if check-command - (funcall check-command workspace) - (or - (when capability (lsp--capability capability)) - (lsp--registered-capability method) - (and (not capability) (not check-command)))))) - -(defun lsp-disable-method-for-server (method server-id) - "Disable METHOD for SERVER-ID." - (cl-callf - (lambda (reqs) - (-let (((&plist :check-command :capability) reqs)) - (list :check-command - (lambda (workspace) - (unless (-> workspace - lsp--workspace-client - lsp--client-server-id - (eq server-id)) - (lsp--workspace-method-supported? check-command - method - capability - workspace)))))) - (alist-get method lsp-method-requirements nil nil 'string=))) - -(defun lsp--find-workspaces-for (msg-or-method) - "Find all workspaces in the current project that can handle MSG." - (let ((method (if (stringp msg-or-method) - msg-or-method - (plist-get msg-or-method :method)))) - (-if-let (reqs (cdr (assoc method lsp-method-requirements))) - (-let (((&plist :capability :check-command) reqs)) - (-filter - (-partial #'lsp--workspace-method-supported? - check-command method capability) - (lsp-workspaces))) - (lsp-workspaces)))) - -(defun lsp-can-execute-command? (command-name) - "Returns non-nil if current language server(s) can execute COMMAND-NAME. -The command is executed via `workspace/executeCommand'" - (cl-position - command-name - (lsp:execute-command-options-commands - (lsp:server-capabilities-execute-command-provider? - (lsp--server-capabilities))) - :test #'equal)) - -(defalias 'lsp-feature? 'lsp--find-workspaces-for) - -(cl-defmethod lsp-execute-command (_server _command _arguments) - "Dispatch COMMAND execution." - (signal 'cl-no-applicable-method nil)) - -(defun lsp-workspace-command-execute (command &optional args) - "Execute workspace COMMAND with ARGS." - (condition-case-unless-debug err - (let ((params (if args - (list :command command :arguments args) - (list :command command)))) - (lsp-request "workspace/executeCommand" params)) - (error - (error "`workspace/executeCommand' with `%s' failed.\n\n%S" - command err)))) - -(defun lsp-send-execute-command (command &optional args) - "Create and send a `workspace/executeCommand' message having command COMMAND -and optional ARGS." - (lsp-workspace-command-execute command args)) - -(defalias 'lsp-point-to-position #'lsp--point-to-position) -(defalias 'lsp-text-document-identifier #'lsp--text-document-identifier) -(defalias 'lsp--send-execute-command #'lsp-send-execute-command) -(defalias 'lsp-on-open #'lsp--text-document-did-open) -(defalias 'lsp-on-save #'lsp--text-document-did-save) - -(defun lsp--set-configuration (settings) - "Set the SETTINGS for the lsp server." - (lsp-notify "workspace/didChangeConfiguration" `(:settings ,settings))) - -(defun lsp-current-buffer () - (or lsp--virtual-buffer - (current-buffer))) - -(defun lsp-buffer-live-p (buffer-id) - (if-let ((buffer-live (plist-get buffer-id :buffer-live?))) - (funcall buffer-live buffer-id) - (buffer-live-p buffer-id))) - -(defun lsp--on-set-visited-file-name (old-func &rest args) - "Advice around function `set-visited-file-name'. - -This advice sends textDocument/didClose for the old file and -textDocument/didOpen for the new file." - (when lsp--cur-workspace - (lsp--text-document-did-close t)) - (prog1 (apply old-func args) - (when lsp--cur-workspace - (lsp--text-document-did-open)))) - -(advice-add 'set-visited-file-name :around #'lsp--on-set-visited-file-name) - -(defvar lsp--flushing-delayed-changes nil) - -(defun lsp--send-no-wait (message proc) - "Send MESSAGE to PROC without waiting for further output." - - (unless lsp--flushing-delayed-changes - (let ((lsp--flushing-delayed-changes t)) - (lsp--flush-delayed-changes))) - (lsp-process-send proc message)) - -(define-error 'lsp-parse-error - "Error parsing message from language server" 'lsp-error) -(define-error 'lsp-unknown-message-type - "Unknown message type" '(lsp-error lsp-parse-error)) -(define-error 'lsp-unknown-json-rpc-version - "Unknown JSON-RPC protocol version" '(lsp-error lsp-parse-error)) -(define-error 'lsp-no-content-length - "Content-Length header missing in message" '(lsp-error lsp-parse-error)) -(define-error 'lsp-invalid-header-name - "Invalid header name" '(lsp-error lsp-parse-error)) - -;; id method -;; x x request -;; x . response -;; . x notification -(defun lsp--get-message-type (json-data) - "Get the message type from JSON-DATA." - (if (lsp:json-message-id? json-data) - (if (lsp:json-message-error? json-data) - 'response-error - (if (lsp:json-message-method? json-data) - 'request - 'response)) - 'notification)) - -(defconst lsp--default-notification-handlers - (ht ("window/showMessage" #'lsp--window-show-message) - ("window/logMessage" #'lsp--window-log-message) - ("window/showInputBox" #'lsp--window-show-input-box) - ("window/showQuickPick" #'lsp--window-show-quick-pick) - ("textDocument/publishDiagnostics" #'lsp--on-diagnostics) - ("textDocument/diagnosticsEnd" #'ignore) - ("textDocument/diagnosticsBegin" #'ignore) - ("telemetry/event" #'ignore) - ("$/progress" (lambda (workspace params) - (funcall lsp-progress-function workspace params))))) - -(lsp-defun lsp--on-notification (workspace (&JSONNotification :params :method)) - "Call the appropriate handler for NOTIFICATION." - (-let ((client (lsp--workspace-client workspace))) - (when (lsp--log-io-p method) - (lsp--log-entry-new (lsp--make-log-entry method nil params 'incoming-notif) - lsp--cur-workspace)) - (if-let ((handler (or (gethash method (lsp--client-notification-handlers client)) - (gethash method lsp--default-notification-handlers)))) - (funcall handler workspace params) - (when (and method (not (string-prefix-p "$" method))) - (lsp-warn "Unknown notification: %s" method))))) - -(lsp-defun lsp--build-workspace-configuration-response ((&ConfigurationParams :items)) - "Get section configuration. -PARAMS are the `workspace/configuration' request params" - (->> items - (-map (-lambda ((&ConfigurationItem :section?)) - (-let* ((path-parts (split-string section? "\\.")) - (path-without-last (s-join "." (-slice path-parts 0 -1))) - (path-parts-len (length path-parts))) - (cond - ((<= path-parts-len 1) - (ht-get (lsp-configuration-section section?) - (car-safe path-parts) - (ht-create))) - ((> path-parts-len 1) - (when-let ((section (lsp-configuration-section path-without-last)) - (keys path-parts)) - (while (and keys section) - (setf section (ht-get section (pop keys)))) - section)))))) - (apply #'vector))) - -(defun lsp--ms-since (timestamp) - "Integer number of milliseconds since TIMESTAMP. Fractions discarded." - (floor (* 1000 (float-time (time-since timestamp))))) - -(defun lsp--send-request-response (workspace recv-time request response) - "Send the RESPONSE for REQUEST in WORKSPACE and log if needed." - (-let* (((&JSONResponse :params :method :id) request) - (process (lsp--workspace-proc workspace)) - (response (lsp--make-response id response)) - (req-entry (and lsp-log-io - (lsp--make-log-entry method id params 'incoming-req))) - (resp-entry (and lsp-log-io - (lsp--make-log-entry method id response 'outgoing-resp - (lsp--ms-since recv-time))))) - ;; Send response to the server. - (when (lsp--log-io-p method) - (lsp--log-entry-new req-entry workspace) - (lsp--log-entry-new resp-entry workspace)) - (lsp--send-no-wait response process))) - -(lsp-defun lsp--on-request (workspace (request &as &JSONRequest :params :method)) - "Call the appropriate handler for REQUEST, and send the return value to the -server. WORKSPACE is the active workspace." - (-let* ((recv-time (current-time)) - (client (lsp--workspace-client workspace)) - (buffers (lsp--workspace-buffers workspace)) - handler - (response (cond - ((setq handler (gethash method (lsp--client-request-handlers client) nil)) - (funcall handler workspace params)) - ((setq handler (gethash method (lsp--client-async-request-handlers client) nil)) - (funcall handler workspace params - (-partial #'lsp--send-request-response - workspace recv-time request)) - 'delay-response) - ((equal method "client/registerCapability") - (mapc #'lsp--server-register-capability - (lsp:registration-params-registrations params)) - (mapc (lambda (buf) - (when (lsp-buffer-live-p buf) - (lsp-with-current-buffer buf - (lsp-unconfig-buffer) - (lsp-configure-buffer)))) - buffers) - nil) - ((equal method "window/showMessageRequest") - (let ((choice (lsp--window-log-message-request params))) - `(:title ,choice))) - ((equal method "window/showDocument") - (let ((success? (lsp--window-show-document params))) - (lsp-make-show-document-result :success (or success? - :json-false)))) - ((equal method "client/unregisterCapability") - (mapc #'lsp--server-unregister-capability - (lsp:unregistration-params-unregisterations params)) - (mapc (lambda (buf) - (when (lsp-buffer-live-p buf) - (lsp-with-current-buffer buf - (lsp-unconfig-buffer) - (lsp-configure-buffer)))) - buffers) - nil) - ((equal method "workspace/applyEdit") - (list :applied (condition-case err - (prog1 t - (lsp--apply-workspace-edit (lsp:apply-workspace-edit-params-edit params) 'server-requested)) - (error - (lsp--error "Failed to apply edits with message %s" - (error-message-string err)) - :json-false)))) - ((equal method "workspace/configuration") - (with-lsp-workspace workspace - (if-let ((buf (car buffers))) - (lsp-with-current-buffer buf - (lsp--build-workspace-configuration-response params)) - (lsp--with-workspace-temp-buffer (lsp--workspace-root workspace) - (lsp--build-workspace-configuration-response params))))) - ((equal method "workspace/workspaceFolders") - (let ((folders (or (-> workspace - (lsp--workspace-client) - (lsp--client-server-id) - (gethash (lsp-session-server-id->folders (lsp-session)))) - (lsp-session-folders (lsp-session))))) - (->> folders - (-distinct) - (-map (lambda (folder) - (list :uri (lsp--path-to-uri folder)))) - (apply #'vector)))) - ((equal method "window/workDoneProgress/create") - nil ;; no specific reply, no processing required - ) - ((equal method "workspace/semanticTokens/refresh") - (when (and lsp-semantic-tokens-enable - (fboundp 'lsp--semantic-tokens-on-refresh)) - (lsp--semantic-tokens-on-refresh workspace)) - nil) - ((equal method "workspace/codeLens/refresh") - (when (and lsp-lens-enable - (fboundp 'lsp--lens-on-refresh)) - (lsp--lens-on-refresh workspace)) - nil) - (t (lsp-warn "Unknown request method: %s" method) nil)))) - ;; Send response to the server. - (unless (eq response 'delay-response) - (lsp--send-request-response workspace recv-time request response)))) - -(lsp-defun lsp--error-string ((&JSONError :message :code)) - "Format ERR as a user friendly string." - (format "Error from the Language Server: %s (%s)" - message - (or (car (alist-get code lsp--errors)) "Unknown error"))) - -(defun lsp--get-body-length (headers) - (let ((content-length (cdr (assoc "Content-Length" headers)))) - (if content-length - (string-to-number content-length) - - ;; This usually means either the server or our parser is - ;; screwed up with a previous Content-Length - (error "No Content-Length header")))) - -(defun lsp--parse-header (s) - "Parse string S as a LSP (KEY . VAL) header." - (let ((pos (string-match "\:" s)) - key val) - (unless pos - (signal 'lsp-invalid-header-name (list s))) - (setq key (substring s 0 pos) - val (s-trim-left (substring s (+ 1 pos)))) - (when (equal key "Content-Length") - (cl-assert (cl-loop for c across val - when (or (> c ?9) (< c ?0)) return nil - finally return t) - nil (format "Invalid Content-Length value: %s" val))) - (cons key val))) - -(defmacro lsp--read-json (str) - "Read json string STR." - (if (progn - (require 'json) - (fboundp 'json-parse-string)) - `(json-parse-string ,str - :object-type (if lsp-use-plists - 'plist - 'hash-table) - :null-object nil - :false-object nil) - `(let ((json-array-type 'vector) - (json-object-type (if lsp-use-plists - 'plist - 'hash-table)) - (json-false nil)) - (json-read-from-string ,str)))) - -(defmacro lsp-json-read-buffer () - "Read json from the current buffer." - (if (progn - (require 'json) - (fboundp 'json-parse-buffer)) - `(json-parse-buffer :object-type (if lsp-use-plists - 'plist - 'hash-table) - :null-object nil - :false-object nil) - `(let ((json-array-type 'vector) - (json-object-type (if lsp-use-plists - 'plist - 'hash-table)) - (json-false nil)) - (json-read)))) - -(defun lsp--read-json-file (file-path) - "Read json file." - (-> file-path - (f-read-text) - (lsp--read-json))) - -(defun lsp--parser-on-message (json-data workspace) - "Called when the parser P read a complete MSG from the server." - (with-demoted-errors "Error processing message %S." - (with-lsp-workspace workspace - (let* ((client (lsp--workspace-client workspace)) - (id (--when-let (lsp:json-response-id json-data) - (if (stringp it) (string-to-number it) it))) - (data (lsp:json-response-result json-data))) - (pcase (lsp--get-message-type json-data) - ('response - (cl-assert id) - (-let [(callback _ method _ before-send) (gethash id (lsp--client-response-handlers client))] - (when (lsp--log-io-p method) - (lsp--log-entry-new - (lsp--make-log-entry method id data 'incoming-resp - (lsp--ms-since before-send)) - workspace)) - (when callback - (remhash id (lsp--client-response-handlers client)) - (funcall callback (lsp:json-response-result json-data))))) - ('response-error - (cl-assert id) - (-let [(_ callback method _ before-send) (gethash id (lsp--client-response-handlers client))] - (when (lsp--log-io-p method) - (lsp--log-entry-new - (lsp--make-log-entry method id (lsp:json-response-error-error json-data) - 'incoming-resp (lsp--ms-since before-send)) - workspace)) - (when callback - (remhash id (lsp--client-response-handlers client)) - (funcall callback (lsp:json-response-error-error json-data))))) - ('notification - (lsp--on-notification workspace json-data)) - ('request (lsp--on-request workspace json-data))))))) - -(defun lsp--create-filter-function (workspace) - "Make filter for the workspace." - (let ((body-received 0) - leftovers body-length body chunk) - (lambda (_proc input) - (setf chunk (if (s-blank? leftovers) - input - (concat leftovers input))) - - (let (messages) - (while (not (s-blank? chunk)) - (if (not body-length) - ;; Read headers - (if-let ((body-sep-pos (string-match-p "\r\n\r\n" chunk))) - ;; We've got all the headers, handle them all at once: - (setf body-length (lsp--get-body-length - (mapcar #'lsp--parse-header - (split-string - (substring-no-properties chunk - (or (string-match-p "Content-Length" chunk) - (error "Unable to find Content-Length header.")) - body-sep-pos) - "\r\n"))) - body-received 0 - leftovers nil - chunk (substring-no-properties chunk (+ body-sep-pos 4))) - - ;; Haven't found the end of the headers yet. Save everything - ;; for when the next chunk arrives and await further input. - (setf leftovers chunk - chunk nil)) - (let* ((chunk-length (string-bytes chunk)) - (left-to-receive (- body-length body-received)) - (this-body (if (< left-to-receive chunk-length) - (prog1 (substring-no-properties chunk 0 left-to-receive) - (setf chunk (substring-no-properties chunk left-to-receive))) - (prog1 chunk - (setf chunk nil)))) - (body-bytes (string-bytes this-body))) - (push this-body body) - (setf body-received (+ body-received body-bytes)) - (when (>= chunk-length left-to-receive) - (condition-case err - (with-temp-buffer - (apply #'insert - (nreverse - (prog1 body - (setf leftovers nil - body-length nil - body-received nil - body nil)))) - (decode-coding-region (point-min) - (point-max) - 'utf-8) - (goto-char (point-min)) - (push (lsp-json-read-buffer) messages)) - - (error - (lsp-warn "Failed to parse the following chunk:\n'''\n%s\n'''\nwith message %s" - (concat leftovers input) - err))))))) - (mapc (lambda (msg) - (lsp--parser-on-message msg workspace)) - (nreverse messages)))))) - -(defvar-local lsp--line-col-to-point-hash-table nil - "Hash table with keys (line . col) and values that are either point positions -or markers.") - -(defcustom lsp-imenu-detailed-outline t - "Whether `lsp-imenu' should include signatures. -This will be ignored if the server doesn't provide the necessary -information, for example if it doesn't support DocumentSymbols." - :group 'lsp-imenu - :type 'boolean) - -(defcustom lsp-imenu-hide-parent-details t - "Whether `lsp-imenu' should hide signatures of parent nodes." - :group 'lsp-imenu - :type 'boolean) - -(defface lsp-details-face '((t :height 0.8 :inherit shadow)) - "Used to display additional information throughout `lsp'. -Things like line numbers, signatures, ... are considered -additional information. Often, additional faces are defined that -inherit from this face by default, like `lsp-signature-face', and -they may be customized for finer control." - :group 'lsp-mode) - -(defface lsp-signature-face '((t :inherit lsp-details-face)) - "Used to display signatures in `imenu', ...." - :group 'lsp-mode) - -(lsp-defun lsp-render-symbol ((&DocumentSymbol :name :detail? :deprecated?) - show-detail?) - "Render INPUT0, an `&DocumentSymbol', to a string. -If SHOW-DETAIL? is set, make use of its `:detail?' field (often -the signature)." - (let ((detail (and show-detail? (s-present? detail?) - (propertize (concat " " (s-trim-left detail?)) - 'face 'lsp-signature-face))) - (name (if deprecated? - (propertize name 'face 'lsp-face-semhl-deprecated) name))) - (concat name detail))) - -(lsp-defun lsp-render-symbol-information ((&SymbolInformation :name :deprecated? :container-name?) - separator) - "Render a piece of SymbolInformation. -Handle :deprecated?. If SEPARATOR is non-nil, the -symbol's (optional) parent, SEPARATOR and the symbol itself are -concatenated." - (when (and separator container-name? (not (string-empty-p container-name?))) - (setq name (concat name separator container-name?))) - (if deprecated? (propertize name 'face 'lsp-face-semhl-deprecated) name)) - -(defun lsp--symbol-to-imenu-elem (sym) - "Convert SYM to imenu element. - -SYM is a SymbolInformation message. - -Return a cons cell (full-name . start-point)." - (let ((start-point (ht-get lsp--line-col-to-point-hash-table - (lsp--get-line-and-col sym)))) - (cons (lsp-render-symbol-information - sym (and lsp-imenu-show-container-name - lsp-imenu-container-name-separator)) - start-point))) - -(lsp-defun lsp--symbol-to-hierarchical-imenu-elem ((sym &as &DocumentSymbol :children?)) - "Convert SYM to hierarchical imenu elements. - -SYM is a DocumentSymbol message. - -Return cons cell (\"symbol-name (symbol-kind)\" . start-point) if -SYM doesn't have any children. Otherwise return a cons cell with -an alist - - (\"symbol-name\" . ((\"(symbol-kind)\" . start-point) - cons-cells-from-children))" - (let ((filtered-children (lsp--imenu-filter-symbols children?)) - (signature (lsp-render-symbol sym lsp-imenu-detailed-outline))) - (if (seq-empty-p filtered-children) - (cons signature - (ht-get lsp--line-col-to-point-hash-table - (lsp--get-line-and-col sym))) - (cons signature - (lsp--imenu-create-hierarchical-index filtered-children))))) - -(lsp-defun lsp--symbol-ignore ((&SymbolInformation :kind)) - "Determine if SYM is for the current document and is to be shown." - ;; It's a SymbolInformation or DocumentSymbol, which is always in the - ;; current buffer file. - (and lsp-imenu-index-symbol-kinds - (numberp kind) - (let ((clamped-kind (if (< 0 kind (length lsp/symbol-kind-lookup)) - kind - 0))) - (not (memql (aref lsp/symbol-kind-lookup clamped-kind) - lsp-imenu-index-symbol-kinds))))) - -(lsp-defun lsp--get-symbol-type ((&SymbolInformation :kind)) - "The string name of the kind of SYM." - (alist-get kind lsp-symbol-kinds "Other")) - -(defun lsp--get-line-and-col (sym) - "Obtain the line and column corresponding to SYM." - (-let* ((location (lsp:symbol-information-location sym)) - (name-range (or (and location (lsp:location-range location)) - (lsp:document-symbol-selection-range sym))) - ((&Range :start (&Position :line :character)) name-range)) - (cons line character))) - -(defun lsp--collect-lines-and-cols (symbols) - "Return a sorted list ((line . col) ...) of the locations of SYMBOLS." - (let ((stack (mapcar 'identity symbols)) - line-col-list) - (while stack - (let ((sym (pop stack))) - (push (lsp--get-line-and-col sym) line-col-list) - (unless (seq-empty-p (lsp:document-symbol-children? sym)) - (setf stack (nconc (lsp--imenu-filter-symbols (lsp:document-symbol-children? sym)) stack))))) - (-sort #'lsp--line-col-comparator line-col-list))) - -(defun lsp--convert-line-col-to-points-batch (line-col-list) - "Convert a sorted list of positions from line-column -representation to point representation." - (let ((line-col-to-point-map (ht-create)) - (inhibit-field-text-motion t) - (curr-line 0)) - (lsp-save-restriction-and-excursion - (goto-char (point-min)) - (cl-loop for (line . col) in line-col-list do - (forward-line (- line curr-line)) - (setq curr-line line) - (let ((line-end (line-end-position))) - (if (or (not col) (> col (- line-end (point)))) - (goto-char line-end) - (forward-char col))) - (ht-set! line-col-to-point-map (cons line col) (if imenu-use-markers - (point-marker) - (point))))) - line-col-to-point-map)) - -(cl-defun lsp--line-col-comparator ((l1 . c1) (l2 . c2)) - (or (< l1 l2) - (and (= l1 l2) - (cond ((and c1 c2) - (< c1 c2)) - (c1 t))))) - -(defun lsp-imenu-create-uncategorized-index (symbols) - "Create imenu index from document SYMBOLS. -This function, unlike `lsp-imenu-create-categorized-index', does -not categorize by type, but instead returns an `imenu' index -corresponding to the symbol hierarchy returned by the server -directly." - (let* ((lsp--line-col-to-point-hash-table (-> symbols - lsp--collect-lines-and-cols - lsp--convert-line-col-to-points-batch))) - (if (lsp--imenu-hierarchical-p symbols) - (lsp--imenu-create-hierarchical-index symbols) - (lsp--imenu-create-non-hierarchical-index symbols)))) - -(defcustom lsp-imenu-symbol-kinds - '((1 . "Files") - (2 . "Modules") - (3 . "Namespaces") - (4 . "Packages") - (5 . "Classes") - (6 . "Methods") - (7 . "Properties") - (8 . "Fields") - (9 . "Constructors") - (10 . "Enums") - (11 . "Interfaces") - (12 . "Functions") - (13 . "Variables") - (14 . "Constants") - (15 . "Strings") - (16 . "Numbers") - (17 . "Booleans") - (18 . "Arrays") - (19 . "Objects") - (20 . "Keys") - (21 . "Nulls") - (22 . "Enum Members") - (23 . "Structs") - (24 . "Events") - (25 . "Operators") - (26 . "Type Parameters")) - "`lsp-symbol-kinds', but only used by `imenu'. -A new variable is needed, as it is `imenu' convention to use -pluralized categories, which `lsp-symbol-kinds' doesn't. If the -non-pluralized names are preferred, this can be set to -`lsp-symbol-kinds'." - :type '(alist :key-type integer :value-type string)) - -(defun lsp--imenu-kind->name (kind) - (alist-get kind lsp-imenu-symbol-kinds "?")) - -(defun lsp-imenu-create-top-level-categorized-index (symbols) - "Create an `imenu' index categorizing SYMBOLS by type. -Only root symbols are categorized. - -See `lsp-symbol-kinds' to customize the category naming. SYMBOLS -shall be a list of DocumentSymbols or SymbolInformation." - (mapcan - (-lambda ((type . symbols)) - (let ((cat (lsp--imenu-kind->name type)) - (symbols (lsp-imenu-create-uncategorized-index symbols))) - ;; If there is no :kind (this is being defensive), or we couldn't look it - ;; up, just display the symbols inline, without categories. - (if cat (list (cons cat symbols)) symbols))) - (sort (seq-group-by #'lsp:document-symbol-kind symbols) - (-lambda ((kinda) (kindb)) (< kinda kindb))))) - -(lsp-defun lsp--symbol->imenu ((sym &as &DocumentSymbol :selection-range (&RangeToPoint :start))) - "Convert an `&DocumentSymbol' to an `imenu' entry." - (cons (lsp-render-symbol sym lsp-imenu-detailed-outline) start)) - -(defun lsp--imenu-create-categorized-index-1 (symbols) - "Returns an `imenu' index from SYMBOLS categorized by type. -The result looks like this: ((\"Variables\" . (...)))." - (->> - symbols - (mapcan - (-lambda ((sym &as &DocumentSymbol :kind :children?)) - (if (seq-empty-p children?) - (list (list kind (lsp--symbol->imenu sym))) - (let ((parent (lsp-render-symbol sym (and lsp-imenu-detailed-outline - (not lsp-imenu-hide-parent-details))))) - (cons - (list kind (lsp--symbol->imenu sym)) - (mapcar (-lambda ((type . imenu-items)) - (list type (cons parent (mapcan #'cdr imenu-items)))) - (-group-by #'car (lsp--imenu-create-categorized-index-1 children?)))))))) - (-group-by #'car) - (mapcar - (-lambda ((kind . syms)) - (cons kind (mapcan #'cdr syms)))))) - -(defun lsp--imenu-create-categorized-index (symbols) - (let ((syms (lsp--imenu-create-categorized-index-1 symbols))) - (dolist (sym syms) - (setcar sym (lsp--imenu-kind->name (car sym)))) - syms)) - -(lsp-defun lsp--symbol-information->imenu ((sym &as &SymbolInformation :location (&Location :range (&RangeToPoint :start)))) - (cons (lsp-render-symbol-information sym nil) start)) - -(defun lsp--imenu-create-categorized-index-flat (symbols) - "Create a kind-categorized index for SymbolInformation." - (mapcar (-lambda ((kind . syms)) - (cons (lsp--imenu-kind->name kind) - (mapcan (-lambda ((parent . children)) - (let ((children (mapcar #'lsp--symbol-information->imenu children))) - (if parent (list (cons parent children)) children))) - (-group-by #'lsp:symbol-information-container-name? syms)))) - (seq-group-by #'lsp:symbol-information-kind symbols))) - -(defun lsp-imenu-create-categorized-index (symbols) - (if (lsp--imenu-hierarchical-p symbols) - (lsp--imenu-create-categorized-index symbols) - (lsp--imenu-create-categorized-index-flat symbols))) - -(defcustom lsp-imenu-index-function #'lsp-imenu-create-uncategorized-index - "Function that should create an `imenu' index. -It will be called with a list of SymbolInformation or -DocumentSymbols, whose first level is already filtered. It shall -then return an appropriate `imenu' index (see -`imenu-create-index-function'). - -Note that this interface is not stable, and subject to change any -time." - :group 'lsp-imenu - :type '(radio - (const :tag "Categorize by type" - lsp-imenu-create-categorized-index) - (const :tag "Categorize root symbols by type" - lsp-imenu-create-top-level-categorized-index) - (const :tag "Uncategorized, inline entries" - lsp-imenu-create-uncategorized-index) - (function :tag "Custom function"))) - -(defun lsp--imenu-create-index () - "Create an `imenu' index based on the language server. -Respects `lsp-imenu-index-function'." - (let ((symbols (lsp--imenu-filter-symbols (lsp--get-document-symbols)))) - (funcall lsp-imenu-index-function symbols))) - -(defun lsp--imenu-filter-symbols (symbols) - "Filter out unsupported symbols from SYMBOLS." - (seq-remove #'lsp--symbol-ignore symbols)) - -(defun lsp--imenu-hierarchical-p (symbols) - "Determine whether any element in SYMBOLS has children." - (seq-some #'lsp-document-symbol? symbols)) - -(defun lsp--imenu-create-non-hierarchical-index (symbols) - "Create imenu index for non-hierarchical SYMBOLS. - -SYMBOLS are a list of DocumentSymbol messages. - -Return a nested alist keyed by symbol names. e.g. - - ((\"SomeClass\" (\"(Class)\" . 10) - (\"someField (Field)\" . 20) - (\"someFunction (Function)\" . 25) - (\"SomeSubClass\" (\"(Class)\" . 30) - (\"someSubField (Field)\" . 35)) - (\"someFunction (Function)\" . 40))" - (seq-map (lambda (nested-alist) - (cons (car nested-alist) - (seq-map #'lsp--symbol-to-imenu-elem (cdr nested-alist)))) - (seq-group-by #'lsp--get-symbol-type symbols))) - -(defun lsp--imenu-create-hierarchical-index (symbols) - "Create imenu index for hierarchical SYMBOLS. - -SYMBOLS are a list of DocumentSymbol messages. - -Return a nested alist keyed by symbol names. e.g. - - ((\"SomeClass\" (\"(Class)\" . 10) - (\"someField (Field)\" . 20) - (\"someFunction (Function)\" . 25) - (\"SomeSubClass\" (\"(Class)\" . 30) - (\"someSubField (Field)\" . 35)) - (\"someFunction (Function)\" . 40))" - (seq-map #'lsp--symbol-to-hierarchical-imenu-elem - (seq-sort #'lsp--imenu-symbol-lessp symbols))) - -(defun lsp--imenu-symbol-lessp (sym1 sym2) - (let* ((compare-results (mapcar (lambda (method) - (funcall (alist-get method lsp--imenu-compare-function-alist) - sym1 sym2)) - lsp-imenu-sort-methods)) - (result (seq-find (lambda (result) - (not (= result 0))) - compare-results - 0))) - (and (numberp result) (< result 0)))) - -(lsp-defun lsp--imenu-compare-kind ((&SymbolInformation :kind left) - (&SymbolInformation :kind right)) - "Compare SYM1 and SYM2 by kind." - (- left right)) - -(defun lsp--imenu-compare-line-col (sym1 sym2) - (if (lsp--line-col-comparator - (lsp--get-line-and-col sym1) - (lsp--get-line-and-col sym2)) - -1 - 1)) - -(lsp-defun lsp--imenu-compare-name ((&SymbolInformation :name name1) - (&SymbolInformation :name name2)) - "Compare SYM1 and SYM2 by name." - (let ((result (compare-strings name1 0 (length name1) name2 0 (length name2)))) - (if (numberp result) result 0))) - -(defun lsp--imenu-refresh () - "Force Imenu to refresh itself." - (imenu--menubar-select imenu--rescan-item)) - -(defun lsp-enable-imenu () - "Use lsp-imenu for the current buffer." - (imenu--cleanup) - (add-function :override (local 'imenu-create-index-function) #'lsp--imenu-create-index) - (setq-local imenu-menubar-modified-tick -1) - (setq-local imenu--index-alist nil) - (when menu-bar-mode - (lsp--imenu-refresh))) - -(defun lsp-resolve-final-command (command &optional test?) - "Resolve final function COMMAND." - (let* ((command (lsp-resolve-value command)) - (command (cl-etypecase command - (list - (cl-assert (seq-every-p (apply-partially #'stringp) command) nil - "Invalid command list") - command) - (string (list command))))) - (if (and (file-remote-p default-directory) (not test?)) - (list shell-file-name "-c" - (string-join (cons "stty raw > /dev/null;" - (mapcar #'shell-quote-argument command)) - " ")) - command))) - -(defun lsp-server-present? (final-command) - "Check whether FINAL-COMMAND is present." - (let ((binary-found? (executable-find (cl-first final-command) t))) - (if binary-found? - (lsp-log "Command \"%s\" is present on the path." (s-join " " final-command)) - (lsp-log "Command \"%s\" is not present on the path." (s-join " " final-command))) - binary-found?)) - -(defun lsp--value-to-string (value) - "Convert VALUE to a string that can be set as value in an environment -variable." - (cond - ((stringp value) value) - ((booleanp value) (if value - "1" - "0")) - ((and (sequencep value) - (seq-every-p #'stringp value)) (string-join value ":")) - (t (user-error "Only strings, booleans, and sequences of strings are supported as environment variables")))) - -(defun lsp--compute-process-environment (environment-fn) - "Append a list of KEY=VALUE from the alist ENVIRONMENT to `process-environment'. -Ignore non-boolean keys whose value is nil." - (let ((environment (if environment-fn - (funcall environment-fn) - nil))) - (-flatten (cons (cl-loop for (key . value) in environment - if (or (eval value) - (eq (get value 'custom-type) 'boolean)) - collect (concat key "=" (lsp--value-to-string - (eval value)))) - process-environment)))) - -(defun lsp--default-directory-for-connection (&optional path) - "Return path to be used for the working directory of a LSP process. - -If `lsp-use-workspace-root-for-server-default-directory' is -non-nil, uses `lsp-workspace-root' to find the directory -corresponding to PATH, else returns `default-directory'." - (if lsp-use-workspace-root-for-server-default-directory - (lsp-workspace-root path) - default-directory)) - -(defun lsp--fix-remote-cmd (program) - "Helper for `lsp-stdio-connection'. -Originally coppied from eglot." - - (if (file-remote-p default-directory) - (list shell-file-name "-c" - (string-join (cons "stty raw > /dev/null;" - (mapcar #'shell-quote-argument program)) - " ")) - program)) - -(defvar tramp-use-ssh-controlmaster-options) -(defvar tramp-ssh-controlmaster-options) - -(defun lsp-stdio-connection (command &optional test-command) - "Returns a connection property list using COMMAND. -COMMAND can be: A string, denoting the command to launch the -language server. A list of strings, denoting an executable with -its command line arguments. A function, that either returns a -string or a list of strings. In all cases, the launched language -server should send and receive messages on standard I/O. -TEST-COMMAND is a function with no arguments which returns -whether the command is present or not. When not specified -`lsp-mode' will check whether the first element of the list -returned by COMMAND is available via `executable-find'" - (cl-check-type command (or string - function - (and list - (satisfies (lambda (l) - (seq-every-p (lambda (el) - (stringp el)) - l)))))) - (list :connect (lambda (filter sentinel name environment-fn workspace) - (if (and (functionp 'json-rpc-connection) - (not (file-remote-p default-directory))) - (lsp-json-rpc-connection workspace (lsp-resolve-final-command command)) - (let ((final-command (lsp-resolve-final-command command)) - (process-name (generate-new-buffer-name name)) - (process-environment - (lsp--compute-process-environment environment-fn))) - (let* ((stderr-buf (get-buffer-create (format "*%s::stderr*" process-name))) - (default-directory (lsp--default-directory-for-connection)) - (tramp-use-ssh-controlmaster-options 'suppress) - (tramp-ssh-controlmaster-options "-o ControlMaster=no -o ControlPath=none") - (proc (make-process - :name process-name - :connection-type 'pipe - :buffer (format "*%s*" process-name) - :coding 'no-conversion - :command final-command - :filter filter - :sentinel sentinel - :stderr stderr-buf - :noquery t - :file-handler t))) - (set-process-query-on-exit-flag proc nil) - (set-process-query-on-exit-flag (get-buffer-process stderr-buf) nil) - (with-current-buffer (get-buffer stderr-buf) - ;; Make the *NAME::stderr* buffer buffer-read-only, q to bury, etc. - (special-mode)) - (cons proc proc))))) - :test? (or - test-command - (lambda () - (lsp-server-present? (lsp-resolve-final-command command t)))))) - -(defun lsp--open-network-stream (host port name) - "Open network stream to HOST:PORT. - NAME will be passed to `open-network-stream'. - RETRY-COUNT is the number of the retries. - SLEEP-INTERVAL is the sleep interval between each retry." - (let* ((retries 0) - (sleep-interval 0.01) - (number-of-retries (/ lsp-tcp-connection-timeout sleep-interval)) - connection) - (while (and (not connection) (< retries number-of-retries)) - (condition-case err - (setq connection (open-network-stream name nil host port - :type 'plain - :coding 'no-conversion)) - (file-error - (let ((inhibit-message t)) - (lsp--warn "Failed to connect to %s:%s with error message %s" - host - port - (error-message-string err)) - (sleep-for sleep-interval) - (cl-incf retries))))) - (or connection (error "Port %s was never taken. Consider increasing `lsp-tcp-connection-timeout'." port)))) - -(defun lsp--port-available (host port) - "Return non-nil if HOST and PORT are available." - (condition-case _err - (delete-process (open-network-stream "*connection-test*" nil host port :type 'plain)) - (file-error t))) - -(defun lsp--find-available-port (host starting-port) - "Find available port on HOST starting from STARTING-PORT." - (let ((port starting-port)) - (while (not (lsp--port-available host port)) - (cl-incf port)) - port)) - -(defun lsp-tcp-connection (command-fn) - "Returns a connection property list similar to `lsp-stdio-connection'. -COMMAND-FN can only be a function that takes a single argument, a -port number. It should return a command for launches a language server -process listening for TCP connections on the provided port." - (cl-check-type command-fn function) - (list - :connect (lambda (filter sentinel name environment-fn _workspace) - (let* ((host "localhost") - (port (lsp--find-available-port host (cl-incf lsp--tcp-port))) - (command (funcall command-fn port)) - (final-command (if (consp command) command (list command))) - (_ (unless (lsp-server-present? final-command) - (user-error (format "Couldn't find executable %s" (cl-first final-command))))) - (process-environment - (lsp--compute-process-environment environment-fn)) - (proc (make-process :name name :connection-type 'pipe :coding 'no-conversion - :command final-command :sentinel sentinel :stderr (format "*%s::stderr*" name) :noquery t)) - (tcp-proc (lsp--open-network-stream host port (concat name "::tcp")))) - - ;; TODO: Same :noquery issue (see above) - (set-process-query-on-exit-flag proc nil) - (set-process-query-on-exit-flag tcp-proc nil) - (set-process-filter tcp-proc filter) - (cons tcp-proc proc))) - :test? (lambda () (lsp-server-present? (funcall command-fn 0))))) - -(defalias 'lsp-tcp-server 'lsp-tcp-server-command) - -(defun lsp-tcp-server-command (command-fn) - "Create tcp server connection. -In this mode Emacs is TCP server and the language server connects -to it. COMMAND is function with one parameter(the port) and it -should return the command to start the LS server." - (cl-check-type command-fn function) - (list - :connect (lambda (filter sentinel name environment-fn _workspace) - (let* (tcp-client-connection - (tcp-server (make-network-process :name (format "*tcp-server-%s*" name) - :buffer (format "*tcp-server-%s*" name) - :family 'ipv4 - :service lsp--tcp-server-port - :sentinel (lambda (proc _string) - (lsp-log "Language server %s is connected." name) - (setf tcp-client-connection proc)) - :server 't)) - (port (process-contact tcp-server :service)) - (final-command (funcall command-fn port)) - (process-environment - (lsp--compute-process-environment environment-fn)) - (cmd-proc (make-process :name name - :connection-type 'pipe - :coding 'no-conversion - :command final-command - :stderr (format "*tcp-server-%s*::stderr" name) - :noquery t))) - (let ((retries 0)) - ;; wait for the client to connect (we sit-for 500 ms, so have to double lsp--tcp-server-wait-seconds) - (while (and (not tcp-client-connection) (< retries (* 2 lsp--tcp-server-wait-seconds))) - (lsp--info "Waiting for connection for %s, retries: %s" name retries) - (sit-for 0.500) - (cl-incf retries))) - - (unless tcp-client-connection - (condition-case nil (delete-process tcp-server) (error)) - (condition-case nil (delete-process cmd-proc) (error)) - (error "Failed to create connection to %s on port %s" name port)) - (lsp--info "Successfully connected to %s" name) - - (set-process-query-on-exit-flag cmd-proc nil) - (set-process-query-on-exit-flag tcp-client-connection nil) - (set-process-query-on-exit-flag tcp-server nil) - - (set-process-filter tcp-client-connection filter) - (set-process-sentinel tcp-client-connection sentinel) - (cons tcp-client-connection cmd-proc))) - :test? (lambda () (lsp-server-present? (funcall command-fn 0))))) - -(defalias 'lsp-tramp-connection 'lsp-stdio-connection) - -(defun lsp--auto-configure () - "Autoconfigure `company', `flycheck', `lsp-ui', etc if they are installed." - (when (functionp 'lsp-ui-mode) - (lsp-ui-mode)) - - (if lsp-headerline-breadcrumb-enable - (add-hook 'lsp-configure-hook 'lsp-headerline-breadcrumb-mode) - (remove-hook 'lsp-configure-hook 'lsp-headerline-breadcrumb-mode)) - (if lsp-modeline-code-actions-enable - (add-hook 'lsp-configure-hook 'lsp-modeline-code-actions-mode) - (remove-hook 'lsp-configure-hook 'lsp-modeline-code-actions-mode)) - (if lsp-modeline-diagnostics-enable - (add-hook 'lsp-configure-hook 'lsp-modeline-diagnostics-mode) - (remove-hook 'lsp-configure-hook 'lsp-modeline-diagnostics-mode)) - (if lsp-modeline-workspace-status-enable - (add-hook 'lsp-configure-hook 'lsp-modeline-workspace-status-mode) - (remove-hook 'lsp-configure-hook 'lsp-modeline-workspace-status-mode)) - (if lsp-lens-enable - (add-hook 'lsp-configure-hook 'lsp-lens--enable) - (remove-hook 'lsp-configure-hook 'lsp-lens--enable)) - (if lsp-semantic-tokens-enable - (add-hook 'lsp-configure-hook 'lsp-semantic-tokens--enable) - (remove-hook 'lsp-configure-hook 'lsp-semantic-tokens--enable)) - - ;; yas-snippet config - (setq-local yas-inhibit-overlay-modification-protection t)) - -(defun lsp--restart-if-needed (workspace) - "Handler restart for WORKSPACE." - (when (or (eq lsp-restart 'auto-restart) - (eq (lsp--workspace-shutdown-action workspace) 'restart) - (and (eq lsp-restart 'interactive) - (let ((query (format - "Server %s exited (check corresponding stderr buffer for details). Do you want to restart it?" - (lsp--workspace-print workspace)))) - (y-or-n-p query)))) - (--each (lsp--workspace-buffers workspace) - (when (lsp-buffer-live-p it) - (lsp-with-current-buffer it - (if lsp--buffer-deferred - (lsp-deferred) - (lsp--info "Restarting LSP in buffer %s" (buffer-name)) - (lsp))))))) - -(defun lsp--update-key (table key fn) - "Apply FN on value corresponding to KEY in TABLE." - (let ((existing-value (gethash key table))) - (if-let ((new-value (funcall fn existing-value))) - (puthash key new-value table) - (remhash key table)))) - -(defun lsp--process-sentinel (workspace process exit-str) - "Create the sentinel for WORKSPACE." - (unless (process-live-p process) - (lsp--handle-process-exit workspace exit-str))) - -(defun lsp--handle-process-exit (workspace exit-str) - (let* ((folder->workspaces (lsp-session-folder->servers (lsp-session))) - (proc (lsp--workspace-proc workspace))) - (lsp--warn "%s has exited (%s)" - (lsp-process-name proc) - (string-trim-right (or exit-str ""))) - (with-lsp-workspace workspace - ;; Clean workspace related data in each of the buffers - ;; in the workspace. - (--each (lsp--workspace-buffers workspace) - (when (lsp-buffer-live-p it) - (lsp-with-current-buffer it - (setq lsp--buffer-workspaces (delete workspace lsp--buffer-workspaces)) - (lsp--uninitialize-workspace) - (lsp--spinner-stop) - (lsp--remove-overlays 'lsp-highlight)))) - - ;; Cleanup session from references to the closed workspace. - (--each (hash-table-keys folder->workspaces) - (lsp--update-key folder->workspaces it (apply-partially 'delete workspace))) - - (lsp-process-cleanup proc)) - - (run-hook-with-args 'lsp-after-uninitialized-functions workspace) - - (if (eq (lsp--workspace-shutdown-action workspace) 'shutdown) - (lsp--info "Workspace %s shutdown." (lsp--workspace-print workspace)) - (lsp--restart-if-needed workspace)) - (lsp--cleanup-hanging-watches))) - -(defun lsp-workspace-folders (workspace) - "Return all folders associated with WORKSPACE." - (let (result) - (->> (lsp-session) - (lsp-session-folder->servers) - (maphash (lambda (folder workspaces) - (when (-contains? workspaces workspace) - (push folder result))))) - result)) - -(defun lsp--start-workspace (session client-template root &optional initialization-options) - "Create new workspace for CLIENT-TEMPLATE with project root ROOT. -INITIALIZATION-OPTIONS are passed to initialize function. -SESSION is the active session." - (lsp--spinner-start) - (-let* ((default-directory root) - (client (copy-lsp--client client-template)) - (workspace (make-lsp--workspace - :root root - :client client - :status 'starting - :buffers (list (lsp-current-buffer)) - :host-root (file-remote-p root))) - ((&lsp-cln 'server-id 'environment-fn 'new-connection 'custom-capabilities - 'multi-root 'initialized-fn) client) - ((proc . cmd-proc) (funcall - (or (plist-get new-connection :connect) - (user-error "Client %s is configured incorrectly" client)) - (lsp--create-filter-function workspace) - (apply-partially #'lsp--process-sentinel workspace) - (format "%s" server-id) - environment-fn - workspace)) - (workspace-folders (gethash server-id (lsp-session-server-id->folders session)))) - (setf (lsp--workspace-proc workspace) proc - (lsp--workspace-cmd-proc workspace) cmd-proc) - - ;; update (lsp-session-folder->servers) depending on whether we are starting - ;; multi/single folder workspace - (mapc (lambda (project-root) - (->> session - (lsp-session-folder->servers) - (gethash project-root) - (cl-pushnew workspace))) - (or workspace-folders (list root))) - - (with-lsp-workspace workspace - (run-hooks 'lsp-before-initialize-hook) - (lsp-request-async - "initialize" - (append - (list :processId (unless (file-remote-p (buffer-file-name)) - (emacs-pid)) - :rootPath (lsp-file-local-name (expand-file-name root)) - :clientInfo (list :name "emacs" - :version (emacs-version)) - :rootUri (lsp--path-to-uri root) - :capabilities (lsp--client-capabilities custom-capabilities) - :initializationOptions initialization-options - :workDoneToken "1") - (when lsp-server-trace - (list :trace lsp-server-trace)) - (when multi-root - (->> workspace-folders - (-distinct) - (-map (lambda (folder) - (list :uri (lsp--path-to-uri folder) - :name (f-filename folder)))) - (apply 'vector) - (list :workspaceFolders)))) - (-lambda ((&InitializeResult :capabilities)) - ;; we know that Rust Analyzer will send {} which will be parsed as null - ;; when using plists - (when (equal 'rust-analyzer server-id) - (-> capabilities - (lsp:server-capabilities-text-document-sync?) - (lsp:set-text-document-sync-options-save? t))) - - (setf (lsp--workspace-server-capabilities workspace) capabilities - (lsp--workspace-status workspace) 'initialized) - - (with-lsp-workspace workspace - (lsp-notify "initialized" lsp--empty-ht)) - - (when initialized-fn (funcall initialized-fn workspace)) - - (cl-callf2 -filter #'lsp-buffer-live-p (lsp--workspace-buffers workspace)) - (->> workspace - (lsp--workspace-buffers) - (mapc (lambda (buffer) - (lsp-with-current-buffer buffer - (lsp--open-in-workspace workspace))))) - - (with-lsp-workspace workspace - (run-hooks 'lsp-after-initialize-hook)) - (lsp--info "%s initialized successfully in folders: %s" - (lsp--workspace-print workspace) - (lsp-workspace-folders workspace))) - :mode 'detached)) - workspace)) - -(defun lsp--load-default-session () - "Load default session." - (setq lsp--session (or (condition-case err - (lsp--read-from-file lsp-session-file) - (error (lsp--error "Failed to parse the session %s, starting with clean one." - (error-message-string err)) - nil)) - (make-lsp-session)))) - -(defun lsp-session () - "Get the session associated with the current buffer." - (or lsp--session (setq lsp--session (lsp--load-default-session)))) - -(defun lsp--client-disabled-p (buffer-major-mode client) - (seq-some - (lambda (entry) - (pcase entry - ((pred symbolp) (eq entry client)) - (`(,mode . ,client-or-list) - (and (eq mode buffer-major-mode) - (if (listp client-or-list) - (memq client client-or-list) - (eq client client-or-list)))))) - lsp-disabled-clients)) - - -;; download server - -(defcustom lsp-server-install-dir (expand-file-name - (locate-user-emacs-file (f-join ".cache" "lsp"))) - "Directory in which the servers will be installed." - :risky t - :type 'directory - :package-version '(lsp-mode . "6.3") - :group 'lsp-mode) - -(defcustom lsp-verify-signature t - "Whether to check GPG signatures of downloaded files." - :type 'boolean - :package-version '(lsp-mode . "8.0.0") - :group 'lsp-mode) - -(defvar lsp--dependencies (ht)) - -(defun lsp-dependency (name &rest definitions) - "Used to specify a language server DEPENDENCY, the server -executable or other required file path. Typically, the -DEPENDENCY is found by locating it on the system path using -`executable-find'. - -You can explicitly call lsp-dependency in your environment to -specify the absolute path to the DEPENDENCY. For example, the -typescript-language-server requires both the server and the -typescript compiler. If you have installed them in a team shared -read-only location, you can instruct lsp-mode to use them via - - (eval-after-load `lsp-mode - `(progn - (require lsp-javascript) - (lsp-dependency typescript-language-server (:system ,tls-exe)) - (lsp-dependency typescript (:system ,ts-js)))) - -where tls-exe is the absolute path to the typescript-language-server -executable and ts-js is the absolute path to the typescript compiler -JavaScript file, tsserver.js (the *.js is required for Windows)." - (ht-set lsp--dependencies name definitions)) - -(defun lsp--server-binary-present? (client) - (unless (equal (lsp--client-server-id client) 'lsp-pwsh) - (condition-case () - (-some-> client lsp--client-new-connection (plist-get :test?) funcall) - (error nil) - (args-out-of-range nil)))) - -(define-minor-mode lsp-installation-buffer-mode - "Mode used in *lsp-installation* buffers. -It can be used to set-up keybindings, etc. Disabling this mode -detaches the installation buffer from commands like -`lsp-select-installation-buffer'." - :init-value nil - :lighter nil) - -(defface lsp-installation-finished-buffer-face '((t :foreground "orange")) - "Face used for finished installation buffers. -Used in `lsp-select-installation-buffer'." - :group 'lsp-mode) - -(defface lsp-installation-buffer-face '((t :foreground "green")) - "Face used for installation buffers still in progress. -Used in `lsp-select-installation-buffer'." - :group 'lsp-mode) - -(defun lsp--installation-buffer? (buf) - "Check whether BUF is an `lsp-async-start-process' buffer." - (buffer-local-value 'lsp-installation-buffer-mode buf)) - -(defun lsp-select-installation-buffer (&optional show-finished) - "Interactively choose an installation buffer. -If SHOW-FINISHED is set, leftover (finished) installation buffers -are still shown." - (interactive "P") - (let ((bufs (--filter (and (lsp--installation-buffer? it) - (or show-finished (get-buffer-process it))) - (buffer-list)))) - (pcase bufs - (`nil (user-error "No installation buffers")) - (`(,buf) (pop-to-buffer buf)) - (bufs (pop-to-buffer (completing-read "Select installation buffer: " - (--map (propertize (buffer-name it) 'face - (if (get-buffer-process it) - 'lsp-installation-buffer-face - 'lsp-installation-finished-buffer-face)) - bufs))))))) - -(defun lsp-cleanup-installation-buffers () - "Delete finished *lsp-installation* buffers." - (interactive) - (dolist (buf (buffer-list)) - (when (and (lsp--installation-buffer? buf) (not (get-buffer-process buf))) - (kill-buffer buf)))) - -(defun lsp--download-status () - (-some--> #'lsp--client-download-in-progress? - (lsp--filter-clients it) - (-map (-compose #'symbol-name #'lsp--client-server-id) it) - (format "%s" it) - (propertize it 'face 'success) - (format " Installing following servers: %s" it) - (propertize it - 'local-map (make-mode-line-mouse-map - 'mouse-1 #'lsp-select-installation-buffer) - 'mouse-face 'highlight))) - -(defun lsp--install-server-internal (client &optional update?) - (unless (lsp--client-download-server-fn client) - (user-error "There is no automatic installation for `%s', you have to install it manually following lsp-mode's documentation." - (lsp--client-server-id client))) - - (setf (lsp--client-download-in-progress? client) t) - (add-to-list 'global-mode-string '(t (:eval (lsp--download-status)))) - (cl-flet ((done - (success? &optional error-message) - ;; run with idle timer to make sure the lsp command is executed in - ;; the main thread, see #2739. - (run-with-timer - 0.0 - nil - (lambda () - (-let [(&lsp-cln 'server-id 'buffers) client] - (setf (lsp--client-download-in-progress? client) nil - (lsp--client-buffers client) nil) - (if success? - (lsp--info "Server %s downloaded, auto-starting in %s buffers." server-id - (length buffers)) - (lsp--error "Server %s install process failed with the following error message: %s. -Check `*lsp-install*' and `*lsp-log*' buffer." - server-id - error-message)) - (seq-do - (lambda (buffer) - (when (lsp-buffer-live-p buffer) - (lsp-with-current-buffer buffer - (cl-callf2 -remove-item '(t (:eval (lsp--download-status))) - global-mode-string) - (when success? (lsp))))) - buffers) - (unless (lsp--filter-clients #'lsp--client-download-in-progress?) - (cl-callf2 -remove-item '(t (:eval (lsp--download-status))) - global-mode-string))))))) - (lsp--info "Download %s started." (lsp--client-server-id client)) - (condition-case err - (funcall - (lsp--client-download-server-fn client) - client - (lambda () (done t)) - (lambda (msg) (done nil msg)) - update?) - (error - (done nil (error-message-string err)))))) - -(defun lsp--require-packages () - "Load `lsp-client-packages' if needed." - (when (and lsp-auto-configure (not lsp--client-packages-required)) - (seq-do (lambda (package) - ;; loading client is slow and `lsp' can be called repeatedly - (unless (featurep package) - (require package nil t))) - lsp-client-packages) - (setq lsp--client-packages-required t))) - -;;;###autoload -(defun lsp-install-server (update? &optional server-id) - "Interactively install or re-install server. -When prefix UPDATE? is t force installation even if the server is present." - (interactive "P") - (lsp--require-packages) - (let* ((chosen-client (or (gethash server-id lsp-clients) - (lsp--completing-read - "Select server to install/re-install: " - (or (->> lsp-clients - (ht-values) - (-filter (-andfn - (-not #'lsp--client-download-in-progress?) - #'lsp--client-download-server-fn))) - (user-error "There are no servers with automatic installation")) - (lambda (client) - (let ((server-name (-> client lsp--client-server-id symbol-name))) - (if (lsp--server-binary-present? client) - (concat server-name " (Already installed)") - server-name))) - nil - t))) - (update? (or update? - (and (not (lsp--client-download-in-progress? chosen-client)) - (lsp--server-binary-present? chosen-client))))) - (lsp--install-server-internal chosen-client update?))) - -;;;###autoload -(defun lsp-uninstall-server (dir) - "Delete a LSP server from `lsp-server-install-dir'." - (interactive - (list (read-directory-name "Uninstall LSP server: " (f-slash lsp-server-install-dir)))) - (unless (file-directory-p dir) - (user-error "Couldn't find %s directory" dir)) - (delete-directory dir 'recursive) - (message "Server `%s' uninstalled." (file-name-nondirectory (directory-file-name dir)))) - -;;;###autoload -(defun lsp-uninstall-servers () - "Uninstall all installed servers." - (interactive) - (let* ((dir lsp-server-install-dir) - (servers (ignore-errors - (directory-files dir t - directory-files-no-dot-files-regexp)))) - (if (or (not (file-directory-p dir)) (zerop (length servers))) - (user-error "No servers to uninstall") - (when (yes-or-no-p - (format "Servers to uninstall: %d (%s), proceed? " - (length servers) - (mapconcat (lambda (server) - (file-name-nondirectory (directory-file-name server))) - servers " "))) - (mapc #'lsp-uninstall-server servers) - (message "All servers uninstalled"))))) - -;;;###autoload -(defun lsp-update-server (&optional server-id) - "Interactively update (reinstall) a server." - (interactive) - (lsp--require-packages) - (let ((chosen-client (or (gethash server-id lsp-clients) - (lsp--completing-read - "Select server to update (if not on the list, probably you need to `lsp-install-server`): " - (or (->> lsp-clients - (ht-values) - (-filter (-andfn - (-not #'lsp--client-download-in-progress?) - #'lsp--client-download-server-fn - #'lsp--server-binary-present?))) - (user-error "There are no servers to update")) - (lambda (client) - (-> client lsp--client-server-id symbol-name)) - nil - t)))) - (lsp--install-server-internal chosen-client t))) - -;;;###autoload -(defun lsp-update-servers () - "Update (reinstall) all installed servers." - (interactive) - (lsp--require-packages) - (mapc (lambda (client) (lsp--install-server-internal client t)) - (-filter (-andfn - (-not #'lsp--client-download-in-progress?) - #'lsp--client-download-server-fn - #'lsp--server-binary-present?) (hash-table-values lsp-clients)))) - -;;;###autoload -(defun lsp-ensure-server (server-id) - "Ensure server SERVER-ID" - (lsp--require-packages) - (if-let ((client (gethash server-id lsp-clients))) - (unless (lsp--server-binary-present? client) - (lsp--info "Server `%s' is not preset, installing..." server-id) - (lsp-install-server nil server-id)) - (warn "Unable to find server registration with id %s" server-id))) - -(defun lsp-async-start-process (callback error-callback &rest command) - "Start async process COMMAND with CALLBACK and ERROR-CALLBACK." - (let ((name (cl-first command))) - (with-current-buffer (compilation-start (mapconcat #'shell-quote-argument (-filter (lambda (cmd) - (not (null cmd))) - command) - " ") t - (lambda (&rest _) - (generate-new-buffer-name (format "*lsp-install: %s*" name)))) - (lsp-installation-buffer-mode +1) - (view-mode +1) - (add-hook - 'compilation-finish-functions - (lambda (_buf status) - (if (string= "finished\n" status) - (condition-case err - (funcall callback) - (error - (funcall error-callback (error-message-string err)))) - (funcall error-callback (s-trim-right status)))) - nil t)))) - -(defun lsp-resolve-value (value) - "Resolve VALUE's value. -If it is function - call it. -If it is a variable - return it's value -Otherwise returns value itself." - (cond - ((functionp value) (funcall value)) - ((and (symbolp value) (boundp value)) (symbol-value value)) - (value))) - -(defvar lsp-deps-providers - (list :npm (list :path #'lsp--npm-dependency-path - :install #'lsp--npm-dependency-install) - :cargo (list :path #'lsp--cargo-dependency-path - :install #'lsp--cargo-dependency-install) - :system (list :path #'lsp--system-path) - :download (list :path #'lsp-download-path - :install #'lsp-download-install))) - -(defun lsp--system-path (path) - "If PATH is absolute and exists return it as is. Otherwise, -return the absolute path to the executable defined by PATH or -nil." - ;; For node.js 'sub-packages' PATH may point to a *.js file. Consider the - ;; typescript-language-server. When lsp invokes the server, lsp needs to - ;; supply the path to the typescript compiler, tsserver.js, as an argument. To - ;; make code platform independent, one must pass the absolute path to the - ;; tsserver.js file (Windows requires a *.js file - see help on the JavaScript - ;; child process spawn command that is invoked by the - ;; typescript-language-server). This is why we check for existence and not - ;; that the path is executable. - (let ((path (lsp-resolve-value path))) - (cond - ((and (f-absolute? path) - (f-exists? path)) - path) - ((executable-find path t) path)))) - -(defun lsp-package-path (dependency) - "Path to the DEPENDENCY each of the registered providers." - (let (path) - (-first (-lambda ((provider . rest)) - (setq path (-some-> lsp-deps-providers - (plist-get provider) - (plist-get :path) - (apply rest)))) - (gethash dependency lsp--dependencies)) - path)) - -(defun lsp-package-ensure (dependency callback error-callback) - "Asynchronously ensure a package." - (or (-first (-lambda ((provider . rest)) - (-some-> lsp-deps-providers - (plist-get provider) - (plist-get :install) - (apply (cl-list* callback error-callback rest)))) - (gethash dependency lsp--dependencies)) - (funcall error-callback (format "Unable to find a way to install %s" dependency)))) - - -;; npm handling - -;; https://docs.npmjs.com/files/folders#executables -(cl-defun lsp--npm-dependency-path (&key package path &allow-other-keys) - "Return npm dependency PATH for PACKAGE." - (let ((path (executable-find - (f-join lsp-server-install-dir "npm" package - (cond ((eq system-type 'windows-nt) "") - (t "bin")) - path) - t))) - (unless (and path (f-exists? path)) - (error "The package %s is not installed. Unable to find %s" package path)) - path)) - -(cl-defun lsp--npm-dependency-install (callback error-callback &key package &allow-other-keys) - (if-let ((npm-binary (executable-find "npm"))) - (progn - ;; Explicitly `make-directory' to work around NPM bug in - ;; versions 7.0.0 through 7.4.1. See - ;; https://github.com/emacs-lsp/lsp-mode/issues/2364 for - ;; discussion. - (make-directory (f-join lsp-server-install-dir "npm" package "lib") 'parents) - (lsp-async-start-process (lambda () - (if (string-empty-p - (string-trim (shell-command-to-string - (mapconcat #'shell-quote-argument `(,npm-binary "view" ,package "peerDependencies") " ")))) - (funcall callback) - (let ((default-directory (f-dirname (car (last (directory-files-recursively (f-join lsp-server-install-dir "npm" package) "package.json"))))) - (process-environment (append '("npm_config_yes=true") process-environment))) ;; Disable prompting for older versions of npx - (when (f-dir-p default-directory) - (lsp-async-start-process callback - error-callback - (executable-find "npx") - "npm-install-peers"))))) - error-callback - npm-binary - "-g" - "--prefix" - (f-join lsp-server-install-dir "npm" package) - "install" - package)) - (lsp-log "Unable to install %s via `npm' because it is not present" package) - nil)) - - -;; Cargo dependency handling -(cl-defun lsp--cargo-dependency-path (&key package path &allow-other-keys) - (let ((path (executable-find - (f-join lsp-server-install-dir - "cargo" - package - "bin" - path) - t))) - (unless (and path (f-exists? path)) - (error "The package %s is not installed. Unable to find %s" package path)) - path)) - -(cl-defun lsp--cargo-dependency-install (callback error-callback &key package git &allow-other-keys) - (if-let ((cargo-binary (executable-find "cargo"))) - (lsp-async-start-process - callback - error-callback - cargo-binary - "install" - package - (when git - "--git") - git - "--root" - (f-join lsp-server-install-dir "cargo" package)) - (lsp-log "Unable to install %s via `cargo' because it is not present" package) - nil)) - - - -;; Download URL handling -(cl-defun lsp-download-install (callback error-callback &key url asc-url pgp-key store-path decompress &allow-other-keys) - (let* ((url (lsp-resolve-value url)) - (store-path (lsp-resolve-value store-path)) - ;; (decompress (lsp-resolve-value decompress)) - (download-path - (pcase decompress - (:gzip (concat store-path ".gz")) - (:zip (concat store-path ".zip")) - (:targz (concat store-path ".tar.gz")) - (`nil store-path) - (_ (error ":decompress must be `:gzip', `:zip', `:targz' or `nil'"))))) - (make-thread - (lambda () - (condition-case err - (progn - (when (f-exists? download-path) - (f-delete download-path)) - (when (f-exists? store-path) - (f-delete store-path)) - (lsp--info "Starting to download %s to %s..." url download-path) - (mkdir (f-parent download-path) t) - (url-copy-file url download-path) - (lsp--info "Finished downloading %s..." download-path) - (when (and lsp-verify-signature asc-url pgp-key) - (if (executable-find epg-gpg-program) - (let ((asc-download-path (concat download-path ".asc")) - (context (epg-make-context)) - (fingerprint) - (signature)) - (when (f-exists? asc-download-path) - (f-delete asc-download-path)) - (lsp--info "Starting to download %s to %s..." asc-url asc-download-path) - (url-copy-file asc-url asc-download-path) - (lsp--info "Finished downloading %s..." asc-download-path) - (epg-import-keys-from-string context pgp-key) - (setq fingerprint (epg-import-status-fingerprint - (car - (epg-import-result-imports - (epg-context-result-for context 'import))))) - (lsp--info "Verifying signature %s..." asc-download-path) - (epg-verify-file context asc-download-path download-path) - (setq signature (car (epg-context-result-for context 'verify))) - (unless (and - (eq (epg-signature-status signature) 'good) - (equal (epg-signature-fingerprint signature) fingerprint)) - (error "Failed to verify GPG signature: %s" (epg-signature-to-string signature)))) - (lsp--warn "GPG is not installed, skipping the signature check."))) - (when decompress - (lsp--info "Decompressing %s..." download-path) - (pcase decompress - (:gzip - (lsp-gunzip download-path)) - (:zip (lsp-unzip download-path (f-parent store-path))) - (:targz (lsp-tar-gz-decompress download-path (f-parent store-path)))) - (lsp--info "Decompressed %s..." store-path)) - (funcall callback)) - (error (funcall error-callback err))))))) - -(cl-defun lsp-download-path (&key store-path binary-path set-executable? &allow-other-keys) - "Download URL and store it into STORE-PATH. - -SET-EXECUTABLE? when non-nil change the executable flags of -STORE-PATH to make it executable. BINARY-PATH can be specified -when the binary to start does not match the name of the -archive (e.g. when the archive has multiple files)" - (let ((store-path (or (lsp-resolve-value binary-path) - (lsp-resolve-value store-path)))) - (cond - ((executable-find store-path) store-path) - ((and set-executable? (f-exists? store-path)) - (set-file-modes store-path #o0700) - store-path) - ((f-exists? store-path) store-path)))) - -(defun lsp--find-latest-gh-release-url (url regex) - "Fetch the latest version in the releases given by URL by using REGEX." - (let ((url-request-method "GET")) - (with-current-buffer (url-retrieve-synchronously url) - (goto-char (point-min)) - (re-search-forward "\n\n" nil 'noerror) - (delete-region (point-min) (point)) - (let* ((json-result (lsp-json-read-buffer))) - (message "Latest version found: %s" (lsp-get json-result :tag_name)) - (--> json-result - (lsp-get it :assets) - (seq-find (lambda (entry) (string-match-p regex (lsp-get entry :name))) it) - (lsp-get it :browser_download_url)))))) - -;; unzip - -(defconst lsp-ext-pwsh-script "powershell -noprofile -noninteractive \ --nologo -ex bypass -command Expand-Archive -path '%s' -dest '%s'" - "Powershell script to unzip file.") - -(defconst lsp-ext-unzip-script "bash -c 'mkdir -p %2$s && unzip -qq -o %1$s -d %2$s'" - "Unzip script to unzip file.") - -(defcustom lsp-unzip-script (lambda () - (cond ((executable-find "unzip") lsp-ext-unzip-script) - ((executable-find "powershell") lsp-ext-pwsh-script) - (t nil))) - "The script to unzip." - :group 'lsp-mode - :type 'string - :package-version '(lsp-mode . "8.0.0")) - -(defun lsp-unzip (zip-file dest) - "Unzip ZIP-FILE to DEST." - (unless lsp-unzip-script - (error "Unable to find `unzip' or `powershell' on the path, please customize `lsp-unzip-script'")) - (shell-command (format (lsp-resolve-value lsp-unzip-script) zip-file dest))) - -;; gunzip - -(defconst lsp-ext-gunzip-script "gzip -d %1$s" - "Script to decompress a gzippped file with gzip.") - -(defcustom lsp-gunzip-script (lambda () - (cond ((executable-find "gzip") lsp-ext-gunzip-script) - (t nil))) - "The script to decompress a gzipped file. -Should be a format string with one argument for the file to be decompressed -in place." - :group 'lsp-mode - :type 'string - :package-version '(lsp-mode . "8.0.0")) - -(defun lsp-gunzip (gz-file) - "Decompress GZ-FILE in place." - (unless lsp-gunzip-script - (error "Unable to find `gzip' on the path, please either customize `lsp-gunzip-script' or manually decompress %s" gz-file)) - (shell-command (format (lsp-resolve-value lsp-gunzip-script) gz-file))) - -;; tar.gz decompression - -(defconst lsp-ext-tar-script "bash -c 'mkdir -p %2$s; tar xf %1$s --directory=%2$s'" - "Script to decompress a .tar.gz file.") - -(defcustom lsp-tar-script (lambda () - (cond ((executable-find "tar") lsp-ext-tar-script) - (t nil))) - "The script to decompress a .tar.gz file. -Should be a format string with one argument for the file to be decompressed -in place." - :group 'lsp-mode - :type 'string) - -(defun lsp-tar-gz-decompress (targz-file dest) - "Decompress TARGZ-FILE in DEST." - (unless lsp-tar-script - (error "Unable to find `tar' on the path, please either customize `lsp-tar-script' or manually decompress %s" targz-file)) - (shell-command (format (lsp-resolve-value lsp-tar-script) targz-file dest))) - - -;; VSCode marketplace - -(defcustom lsp-vscode-ext-url - "https://marketplace.visualstudio.com/_apis/public/gallery/publishers/%s/vsextensions/%s/%s/vspackage%s" - "Vscode extension template url." - :group 'lsp-mode - :type 'string - :package-version '(lsp-mode . "8.0.0")) - -(defun lsp-vscode-extension-url (publisher name version &optional targetPlatform) - "Return the URL to vscode extension. -PUBLISHER is the extension publisher. -NAME is the name of the extension. -VERSION is the version of the extension. -TARGETPLATFORM is the targetPlatform of the extension." - (format lsp-vscode-ext-url publisher name version (or targetPlatform ""))) - - - -;; Queueing prompts - -(defvar lsp--question-queue nil - "List of questions yet to be asked by `lsp-ask-question'.") - -(defun lsp-ask-question (question options callback) - "Prompt the user to answer the QUESTION with one of the OPTIONS from the -minibuffer. Once the user selects an option, the CALLBACK function will be -called, passing the selected option to it. - -If the user is currently being shown a question, the question will be stored in -`lsp--question-queue', and will be asked once the user has answered the current -question." - (add-to-list 'lsp--question-queue `(("question" . ,question) - ("options" . ,options) - ("callback" . ,callback)) t) - (when (eq (length lsp--question-queue) 1) - (lsp--process-question-queue))) - -(defun lsp--process-question-queue () - "Take the first question from `lsp--question-queue', process it, then process -the next question until the queue is empty." - (-let* (((&alist "question" "options" "callback") (car lsp--question-queue)) - (answer (completing-read question options nil t))) - (pop lsp--question-queue) - (funcall callback answer) - (when lsp--question-queue - (lsp--process-question-queue)))) - -(defun lsp--supports-buffer? (client) - (and - ;; both file and client remote or both local - (eq (---truthy? (file-remote-p (buffer-file-name))) - (---truthy? (lsp--client-remote? client))) - - ;; activation function or major-mode match. - (if-let ((activation-fn (lsp--client-activation-fn client))) - (funcall activation-fn (buffer-file-name) major-mode) - (-contains? (lsp--client-major-modes client) major-mode)) - - ;; check whether it is enabled if `lsp-enabled-clients' is not null - (or (null lsp-enabled-clients) - (or (member (lsp--client-server-id client) lsp-enabled-clients) - (ignore (lsp--info "Client %s is not in lsp-enabled-clients" - (lsp--client-server-id client))))) - - ;; check whether it is not disabled. - (not (lsp--client-disabled-p major-mode (lsp--client-server-id client))))) - -(defun lsp--filter-clients (pred) - (->> lsp-clients hash-table-values (-filter pred))) - -(defun lsp--find-clients () - "Find clients which can handle current buffer." - (-when-let (matching-clients (lsp--filter-clients (-andfn #'lsp--supports-buffer? - #'lsp--server-binary-present?))) - (lsp-log "Found the following clients for %s: %s" - (buffer-file-name) - (s-join ", " - (-map (lambda (client) - (format "(server-id %s, priority %s)" - (lsp--client-server-id client) - (lsp--client-priority client))) - matching-clients))) - (-let* (((add-on-clients main-clients) (-separate #'lsp--client-add-on? matching-clients)) - (selected-clients (if-let ((main-client (and main-clients - (--max-by (> (lsp--client-priority it) - (lsp--client-priority other)) - main-clients)))) - (cons main-client add-on-clients) - add-on-clients))) - (lsp-log "The following clients were selected based on priority: %s" - (s-join ", " - (-map (lambda (client) - (format "(server-id %s, priority %s)" - (lsp--client-server-id client) - (lsp--client-priority client))) - selected-clients))) - selected-clients))) - -(defun lsp-workspace-remove-all-folders() - "Delete all lsp tracked folders." - (interactive) - (--each (lsp-session-folders (lsp-session)) - (lsp-workspace-folders-remove it))) - -(defun lsp-register-client (client) - "Registers LSP client CLIENT." - (let ((client-id (lsp--client-server-id client))) - (puthash client-id client lsp-clients) - (setplist (intern (format "lsp-%s-after-open-hook" client-id)) - `( standard-value (nil) custom-type hook - custom-package-version (lsp-mode . "7.0.1") - variable-documentation ,(format "Hooks to run after `%s' server is run." client-id) - custom-requests nil))) - (when (and lsp-auto-register-remote-clients - (not (lsp--client-remote? client))) - (let ((remote-client (copy-lsp--client client))) - (setf (lsp--client-remote? remote-client) t - (lsp--client-server-id remote-client) (intern - (format "%s-tramp" - (lsp--client-server-id client))) - ;; disable automatic download - (lsp--client-download-server-fn remote-client) nil) - (lsp-register-client remote-client)))) - -(defun lsp--create-initialization-options (_session client) - "Create initialization-options from SESSION and CLIENT. -Add workspace folders depending on server being multiroot and -session workspace folder configuration for the server." - (let* ((initialization-options-or-fn (lsp--client-initialization-options client))) - (if (functionp initialization-options-or-fn) - (funcall initialization-options-or-fn) - initialization-options-or-fn))) - -(defvar lsp-client-settings (make-hash-table :test 'equal) - "For internal use, any external users please use - `lsp-register-custom-settings' function instead") - -(defun lsp-register-custom-settings (props) - "Register PROPS. -PROPS is list of triple (path value boolean?) where PATH is the path to the -property; VALUE can be a literal value, symbol to be evaluated, or either a -function or lambda function to be called without arguments; BOOLEAN? is an -optional flag that should be non-nil for boolean settings, when it is nil the -property will be ignored if the VALUE is nil. - -Example: `(lsp-register-custom-settings `((\"foo.bar.buzz.enabled\" t t)))' -\(note the double parentheses)" - (mapc - (-lambda ((path . rest)) - (puthash path rest lsp-client-settings)) - props)) - -(defun lsp-region-text (region) - "Get the text for REGION in current buffer." - (-let (((start . end) (lsp--range-to-region region))) - (buffer-substring-no-properties start end))) - -(defun lsp-ht-set (tbl paths value) - "Set nested hash table value. -TBL - a hash table, PATHS is the path to the nested VALUE." - (pcase paths - (`(,path) (ht-set! tbl path value)) - (`(,path . ,rst) (let ((nested-tbl (or (gethash path tbl) - (let ((temp-tbl (ht))) - (ht-set! tbl path temp-tbl) - temp-tbl)))) - (lsp-ht-set nested-tbl rst value))))) - -;; sections - -(defalias 'defcustom-lsp 'lsp-defcustom) - -(defmacro lsp-defcustom (symbol standard doc &rest args) - "Defines `lsp-mode' server property." - (declare (doc-string 3) (debug (name body)) - (indent defun)) - (let ((path (plist-get args :lsp-path))) - (cl-remf args :lsp-path) - `(progn - (lsp-register-custom-settings - (quote ((,path ,symbol ,(equal ''boolean (plist-get args :type)))))) - - (defcustom ,symbol ,standard ,doc - :set (lambda (sym val) - (lsp--set-custom-property sym val ,path)) - ,@args)))) - -(defun lsp--set-custom-property (sym val path) - (set sym val) - (let ((section (cl-first (s-split "\\." path)))) - (mapc (lambda (workspace) - (when (-contains? (lsp--client-synchronize-sections (lsp--workspace-client workspace)) - section) - (with-lsp-workspace workspace - (lsp--set-configuration (lsp-configuration-section section))))) - (lsp--session-workspaces (lsp-session))))) - -(defun lsp-configuration-section (section) - "Get settings for SECTION." - (let ((ret (ht-create))) - (maphash (-lambda (path (variable boolean?)) - (when (s-matches? (concat (regexp-quote section) "\\..*") path) - (let* ((symbol-value (-> variable - lsp-resolve-value - lsp-resolve-value)) - (value (if (and boolean? (not symbol-value)) - :json-false - symbol-value))) - (when (or boolean? value) - (lsp-ht-set ret (s-split "\\." path) value))))) - lsp-client-settings) - ret)) - - -(defun lsp--start-connection (session client project-root) - "Initiates connection created from CLIENT for PROJECT-ROOT. -SESSION is the active session." - (when (lsp--client-multi-root client) - (cl-pushnew project-root (gethash (lsp--client-server-id client) - (lsp-session-server-id->folders session)))) - (run-hook-with-args 'lsp-workspace-folders-changed-functions (list project-root) nil) - - (unwind-protect - (lsp--start-workspace session client project-root (lsp--create-initialization-options session client)) - (lsp--spinner-stop))) - -;; lsp-log-io-mode - -(defvar lsp-log-io-mode-map - (let ((map (make-sparse-keymap))) - (define-key map (kbd "M-n") #'lsp-log-io-next) - (define-key map (kbd "M-p") #'lsp-log-io-prev) - (define-key map (kbd "k") #'lsp--erase-log-buffer) - (define-key map (kbd "K") #'lsp--erase-session-log-buffers) - map) - "Keymap for lsp log buffer mode.") - -(define-derived-mode lsp-log-io-mode special-mode "LspLogIo" - "Special mode for viewing IO logs.") - -(defun lsp-workspace-show-log (workspace) - "Display the log buffer of WORKSPACE." - (interactive - (list (if lsp-log-io - (if (eq (length (lsp-workspaces)) 1) - (cl-first (lsp-workspaces)) - (lsp--completing-read "Workspace: " (lsp-workspaces) - #'lsp--workspace-print nil t)) - (user-error "IO logging is disabled")))) - (pop-to-buffer (lsp--get-log-buffer-create workspace))) - -(defalias 'lsp-switch-to-io-log-buffer 'lsp-workspace-show-log) - -(defun lsp--get-log-buffer-create (workspace) - "Return the lsp log buffer of WORKSPACE, creating a new one if needed." - (let* ((server-id (-> workspace lsp--workspace-client lsp--client-server-id symbol-name)) - (pid (-> workspace lsp--workspace-cmd-proc lsp-process-id))) - (get-buffer-create (format "*lsp-log: %s:%s*" server-id pid)))) - -(defun lsp--erase-log-buffer (&optional all) - "Delete contents of current lsp log buffer. -When ALL is t, erase all log buffers of the running session." - (interactive) - (let* ((workspaces (lsp--session-workspaces (lsp-session))) - (current-log-buffer (current-buffer))) - (dolist (w workspaces) - (let ((b (lsp--get-log-buffer-create w))) - (when (or all (eq b current-log-buffer)) - (with-current-buffer b - (let ((inhibit-read-only t)) - (erase-buffer)))))))) - -(defun lsp--erase-session-log-buffers () - "Erase log buffers of the running session." - (interactive) - (lsp--erase-log-buffer t)) - -(defun lsp-log-io-next (arg) - "Move to next log entry." - (interactive "P") - (ewoc-goto-next lsp--log-io-ewoc (or arg 1))) - -(defun lsp-log-io-prev (arg) - "Move to previous log entry." - (interactive "P") - (ewoc-goto-prev lsp--log-io-ewoc (or arg 1))) - - - -(cl-defmethod lsp-process-id ((process process)) - (process-id process)) - -(cl-defmethod lsp-process-name ((process process)) (process-name process)) - -(cl-defmethod lsp-process-status ((process process)) (process-status process)) - -(cl-defmethod lsp-process-kill ((process process)) - (when (process-live-p process) - (kill-process process))) - -(cl-defmethod lsp-process-send ((process process) message) - (condition-case err - (process-send-string process (lsp--make-message message)) - (error (lsp--error "Sending to process failed with the following error: %s" - (error-message-string err))))) - -(cl-defmethod lsp-process-cleanup (process) - ;; Kill standard error buffer only if the process exited normally. - ;; Leave it intact otherwise for debugging purposes. - (let ((buffer (-> process process-name get-buffer))) - (when (and (eq (process-status process) 'exit) - (zerop (process-exit-status process)) - (buffer-live-p buffer)) - (kill-buffer buffer)))) - - -;; native JSONRPC - -(declare-function json-rpc "ext:json") -(declare-function json-rpc-connection "ext:json") -(declare-function json-rpc-send "ext:json") -(declare-function json-rpc-shutdown "ext:json") -(declare-function json-rpc-stderr "ext:json") -(declare-function json-rpc-pid "ext:json") - -(defvar lsp-json-rpc-thread nil) -(defvar lsp-json-rpc-queue nil) -(defvar lsp-json-rpc-done nil) -(defvar lsp-json-rpc-mutex (make-mutex)) -(defvar lsp-json-rpc-condition (make-condition-variable lsp-json-rpc-mutex)) - -(defun lsp-json-rpc-process-queue () - (while (not lsp-json-rpc-done) - (while lsp-json-rpc-queue - (-let (((proc . message) (pop lsp-json-rpc-queue))) - (json-rpc-send - proc message - :null-object nil - :false-object :json-false))) - (with-mutex lsp-json-rpc-mutex - (condition-wait lsp-json-rpc-condition)))) - -(cl-defmethod lsp-process-id (process) (json-rpc-pid process)) - -(cl-defmethod lsp-process-name (_process) "TBD") - -(cl-defmethod lsp-process-kill (process) (json-rpc-shutdown process)) - -(cl-defmethod lsp-process-send (proc message) - (unless lsp-json-rpc-thread - (with-current-buffer (get-buffer-create " *json-rpc*") - (setq lsp-json-rpc-thread (make-thread #'lsp-json-rpc-process-queue "*json-rpc-queue*")))) - - (with-mutex lsp-json-rpc-mutex - (setq lsp-json-rpc-queue (append lsp-json-rpc-queue - (list (cons proc message)))) - (condition-notify lsp-json-rpc-condition))) - -(cl-defmethod lsp-process-cleanup (_proc)) - -(defun lsp-json-rpc-connection (workspace command) - (let ((con (apply #'json-rpc-connection command)) - (object-type (if lsp-use-plists 'plist 'hash-table))) - (with-current-buffer (get-buffer-create " *json-rpc*") - (make-thread - (lambda () - (json-rpc - con - (lambda (result err done) - (run-with-timer - 0.0 - nil - (lambda () - (cond - (result (lsp--parser-on-message result workspace)) - (err (warn "Json parsing failed with the following error: %s" err)) - (done (lsp--handle-process-exit workspace "")))))) - :object-type object-type - :null-object nil - :false-object nil)) - "*json-rpc-connection*")) - (cons con con))) - -(defun lsp-json-rpc-stderr () - (interactive) - (--when-let (pcase (lsp-workspaces) - (`nil (user-error "There are no active servers in the current buffer")) - (`(,workspace) workspace) - (workspaces (lsp--completing-read "Select server: " - workspaces - 'lsp--workspace-print nil t))) - (let ((content (json-rpc-stderr (lsp--workspace-cmd-proc it))) - (buffer (format "*stderr-%s*" (lsp--workspace-print it)) )) - (with-current-buffer (get-buffer-create buffer) - (with-help-window buffer - (insert content)))))) - - -(defun lsp--workspace-print (workspace) - "Visual representation WORKSPACE." - (let* ((proc (lsp--workspace-cmd-proc workspace)) - (status (lsp--workspace-status workspace)) - (server-id (-> workspace lsp--workspace-client lsp--client-server-id symbol-name)) - (pid (lsp-process-id proc))) - - (if (eq 'initialized status) - (format "%s:%s" server-id pid) - (format "%s:%s/%s" server-id pid status)))) - -(defun lsp--map-tree-widget (m) - "Build `tree-widget' from a hash-table or plist M." - (when (lsp-structure-p m) - (let (nodes) - (lsp-map (lambda (k v) - (push `(tree-widget - :tag ,(if (lsp-structure-p v) - (format "%s:" k) - (format "%s: %s" k - (propertize (format "%s" v) - 'face - 'font-lock-string-face))) - :open t - ,@(lsp--map-tree-widget v)) - nodes)) - m) - nodes))) - -(defun lsp-buffer-name (buffer-id) - (if-let ((buffer-name (plist-get buffer-id :buffer-name))) - (funcall buffer-name buffer-id) - (buffer-name buffer-id))) - -(defun lsp--render-workspace (workspace) - "Tree node representation of WORKSPACE." - `(tree-widget :tag ,(lsp--workspace-print workspace) - :open t - (tree-widget :tag ,(propertize "Buffers" 'face 'font-lock-function-name-face) - :open t - ,@(->> workspace - (lsp--workspace-buffers) - (--map `(tree-widget - :tag ,(when (lsp-buffer-live-p it) - (let ((buffer-name (lsp-buffer-name it))) - (if (lsp-with-current-buffer it buffer-read-only) - (propertize buffer-name 'face 'font-lock-constant-face) - buffer-name))))))) - (tree-widget :tag ,(propertize "Capabilities" 'face 'font-lock-function-name-face) - ,@(-> workspace lsp--workspace-server-capabilities lsp--map-tree-widget)))) - -(define-derived-mode lsp-browser-mode special-mode "LspBrowser" - "Define mode for displaying lsp sessions." - (setq-local display-buffer-base-action '(nil . ((inhibit-same-window . t))))) - -(defun lsp-describe-session () - "Describes current `lsp-session'." - (interactive) - (let ((session (lsp-session)) - (buf (get-buffer-create "*lsp session*")) - (root (lsp-workspace-root))) - (with-current-buffer buf - (lsp-browser-mode) - (let ((inhibit-read-only t)) - (erase-buffer) - (--each (lsp-session-folders session) - (widget-create - `(tree-widget - :tag ,(propertize it 'face 'font-lock-keyword-face) - :open t - ,@(->> session - (lsp-session-folder->servers) - (gethash it) - (-map 'lsp--render-workspace))))))) - (pop-to-buffer buf) - (goto-char (point-min)) - (cl-loop for tag = (widget-get (widget-get (widget-at) :node) :tag) - until (or (and root (string= tag root)) (eobp)) - do (goto-char (next-overlay-change (point)))))) - -(defun lsp--session-workspaces (session) - "Get all workspaces that are part of the SESSION." - (-> session lsp-session-folder->servers hash-table-values -flatten -uniq)) - -(defun lsp--find-multiroot-workspace (session client project-root) - "Look for a multiroot connection in SESSION created from CLIENT for -PROJECT-ROOT and BUFFER-MAJOR-MODE." - (when (lsp--client-multi-root client) - (-when-let (multi-root-workspace (->> session - (lsp--session-workspaces) - (--first (eq (-> it lsp--workspace-client lsp--client-server-id) - (lsp--client-server-id client))))) - (with-lsp-workspace multi-root-workspace - (lsp-notify "workspace/didChangeWorkspaceFolders" - (lsp-make-did-change-workspace-folders-params - :event (lsp-make-workspace-folders-change-event - :added (vector (lsp-make-workspace-folder - :uri (lsp--path-to-uri project-root) - :name (f-filename project-root))) - :removed [])))) - - (->> session (lsp-session-folder->servers) (gethash project-root) (cl-pushnew multi-root-workspace)) - (->> session (lsp-session-server-id->folders) (gethash (lsp--client-server-id client)) (cl-pushnew project-root)) - - (lsp--persist-session session) - - (lsp--info "Opened folder %s in workspace %s" project-root (lsp--workspace-print multi-root-workspace)) - (lsp--open-in-workspace multi-root-workspace) - - multi-root-workspace))) - -(defun lsp--ensure-lsp-servers (session clients project-root ignore-multi-folder) - "Ensure that SESSION contain server CLIENTS created for PROJECT-ROOT. -IGNORE-MULTI-FOLDER to ignore multi folder server." - (-map (lambda (client) - (or - (lsp--find-workspace session client project-root) - (unless ignore-multi-folder - (lsp--find-multiroot-workspace session client project-root)) - (lsp--start-connection session client project-root))) - clients)) - -(defun lsp--spinner-stop () - "Stop the spinner in case all of the workspaces are started." - (when (--all? (eq (lsp--workspace-status it) 'initialized) - lsp--buffer-workspaces) - (spinner-stop))) - -(defun lsp--open-in-workspace (workspace) - "Open in existing WORKSPACE." - (if (eq 'initialized (lsp--workspace-status workspace)) - ;; when workspace is initialized just call document did open. - (progn - (with-lsp-workspace workspace - (when-let ((before-document-open-fn (-> workspace - lsp--workspace-client - lsp--client-before-file-open-fn))) - (funcall before-document-open-fn workspace)) - (lsp--text-document-did-open)) - (lsp--spinner-stop)) - ;; when it is not initialized - (lsp--spinner-start) - (cl-pushnew (lsp-current-buffer) (lsp--workspace-buffers workspace)))) - -(defun lsp--find-workspace (session client project-root) - "Find server connection created with CLIENT in SESSION for PROJECT-ROOT." - (when-let ((workspace (->> session - (lsp-session-folder->servers) - (gethash project-root) - (--first (eql (-> it lsp--workspace-client lsp--client-server-id) - (lsp--client-server-id client)))))) - (lsp--open-in-workspace workspace) - workspace)) - -(defun lsp--read-char (prompt &optional options) - "Wrapper for `read-char-from-minibuffer' if Emacs +27. -Fallback to `read-key' otherwise. -PROMPT is the message and OPTIONS the available options." - (if (fboundp 'read-char-from-minibuffer) - (read-char-from-minibuffer prompt options) - (read-key prompt))) - -(defun lsp--find-root-interactively (session) - "Find project interactively. -Returns nil if the project should not be added to the current SESSION." - (condition-case nil - (let* ((project-root-suggestion (or (lsp--suggest-project-root) default-directory)) - (action (lsp--read-char - (format - "%s is not part of any project. - -%s ==> Import project root %s -%s ==> Import project by selecting root directory interactively -%s ==> Import project at current directory %s -%s ==> Do not ask again for the current project by adding %s to lsp-session-folders-blocklist -%s ==> Do not ask again for the current project by selecting ignore path interactively -%s ==> Do nothing: ask again when opening other files from the current project - -Select action: " - (propertize (buffer-name) 'face 'bold) - (propertize "i" 'face 'success) - (propertize project-root-suggestion 'face 'bold) - (propertize "I" 'face 'success) - (propertize "." 'face 'success) - (propertize default-directory 'face 'bold) - (propertize "d" 'face 'warning) - (propertize project-root-suggestion 'face 'bold) - (propertize "D" 'face 'warning) - (propertize "n" 'face 'warning)) - '(?i ?\r ?I ?. ?d ?D ?n)))) - (cl-case action - (?i project-root-suggestion) - (?\r project-root-suggestion) - (?I (read-directory-name "Select workspace folder to add: " - (or project-root-suggestion default-directory) - nil - t)) - (?. default-directory) - (?d (push project-root-suggestion (lsp-session-folders-blocklist session)) - (lsp--persist-session session) - nil) - (?D (push (read-directory-name "Select folder to blocklist: " - (or project-root-suggestion default-directory) - nil - t) - (lsp-session-folders-blocklist session)) - (lsp--persist-session session) - nil) - (t nil))) - (quit))) - -(declare-function tramp-file-name-host "ext:tramp" (file) t) -(declare-function tramp-dissect-file-name "ext:tramp" (file &optional nodefault)) - -(defun lsp--files-same-host (f1 f2) - "Predicate on whether or not two files are on the same host." - (or (not (or (file-remote-p f1) (file-remote-p f2))) - (and (file-remote-p f1) - (file-remote-p f2) - (progn (require 'tramp) - (equal (tramp-file-name-host (tramp-dissect-file-name f1)) - (tramp-file-name-host (tramp-dissect-file-name f2))))))) - -(defun lsp-find-session-folder (session file-name) - "Look in the current SESSION for folder containing FILE-NAME." - (let ((file-name-canonical (lsp-f-canonical file-name))) - (->> session - (lsp-session-folders) - (--filter (and (lsp--files-same-host it file-name-canonical) - (or (lsp-f-same? it file-name-canonical) - (and (f-dir? it) - (lsp-f-ancestor-of? it file-name-canonical))))) - (--max-by (> (length it) - (length other)))))) - -(defun lsp-find-workspace (server-id &optional file-name) - "Find workspace for SERVER-ID for FILE-NAME." - (-when-let* ((session (lsp-session)) - (folder->servers (lsp-session-folder->servers session)) - (workspaces (if file-name - (gethash (lsp-find-session-folder session file-name) folder->servers) - (lsp--session-workspaces session)))) - - (--first (eq (lsp--client-server-id (lsp--workspace-client it)) server-id) workspaces))) - -(defun lsp--calculate-root (session file-name) - "Calculate project root for FILE-NAME in SESSION." - (and - (->> session - (lsp-session-folders-blocklist) - (--first (and (lsp--files-same-host it file-name) - (lsp-f-ancestor-of? it file-name) - (prog1 t - (lsp--info "File %s is in blocklisted directory %s" file-name it)))) - not) - (or - (when lsp-auto-guess-root - (lsp--suggest-project-root)) - (unless lsp-guess-root-without-session - (lsp-find-session-folder session file-name)) - (unless lsp-auto-guess-root - (when-let ((root-folder (lsp--find-root-interactively session))) - (if (or (not (f-equal? root-folder (expand-file-name "~/"))) - (yes-or-no-p - (concat - (propertize "[WARNING] " 'face 'warning) - "You are trying to import your home folder as project root. This may cause performance issue because some language servers (python, lua, etc) will try to scan all files under project root. To avoid that you may: - -1. Use `I' option from the interactive project import to select subfolder(e. g. `~/foo/bar' instead of `~/'). -2. If your file is under `~/' then create a subfolder and move that file in this folder. - -Type `No' to go back to project selection. -Type `Yes' to confirm `HOME' as project root. -Type `C-g' to cancel project import process and stop `lsp'"))) - root-folder - (lsp--calculate-root session file-name))))))) - -(defun lsp--try-open-in-library-workspace () - "Try opening current file as library file in any of the active workspace. -The library folders are defined by each client for each of the active workspace." - (when-let ((workspace (->> (lsp-session) - (lsp--session-workspaces) - ;; Sort the last active workspaces first as they are more likely to be - ;; the correct ones, especially when jumping to a definition. - (-sort (lambda (a _b) - (-contains? lsp--last-active-workspaces a))) - (--first - (and (-> it lsp--workspace-client lsp--supports-buffer?) - (when-let ((library-folders-fn - (-> it lsp--workspace-client lsp--client-library-folders-fn))) - (-first (lambda (library-folder) - (lsp-f-ancestor-of? library-folder (buffer-file-name))) - (funcall library-folders-fn it)))))))) - (lsp--open-in-workspace workspace) - (view-mode t) - (lsp--info "Opening read-only library file %s." (buffer-file-name)) - (list workspace))) - -(defun lsp--persist-session (session) - "Persist SESSION to `lsp-session-file'." - (lsp--persist lsp-session-file (make-lsp-session - :folders (lsp-session-folders session) - :folders-blocklist (lsp-session-folders-blocklist session) - :server-id->folders (lsp-session-server-id->folders session)))) - -(defun lsp--try-project-root-workspaces (ask-for-client ignore-multi-folder) - "Try create opening file as a project file. -When IGNORE-MULTI-FOLDER is t the lsp mode will start new -language server even if there is language server which can handle -current language. When IGNORE-MULTI-FOLDER is nil current file -will be opened in multi folder language server if there is -such." - (-let ((session (lsp-session))) - (-if-let (clients (if ask-for-client - (list (lsp--completing-read "Select server to start: " - (ht-values lsp-clients) - (-compose 'symbol-name 'lsp--client-server-id) nil t)) - (lsp--find-clients))) - (-if-let (project-root (-some-> session - (lsp--calculate-root (buffer-file-name)) - (lsp-f-canonical))) - (progn - ;; update project roots if needed and persist the lsp session - (unless (-contains? (lsp-session-folders session) project-root) - (cl-pushnew project-root (lsp-session-folders session)) - (lsp--persist-session session)) - (lsp--ensure-lsp-servers session clients project-root ignore-multi-folder)) - (lsp--warn "%s not in project or it is blocklisted." (buffer-name)) - nil) - (lsp--warn "No LSP server for %s(check *lsp-log*)." major-mode) - nil))) - -(defun lsp-shutdown-workspace () - "Shutdown language server." - (interactive) - (--when-let (pcase (lsp-workspaces) - (`nil (user-error "There are no active servers in the current buffer")) - (`(,workspace) (when (y-or-n-p (format "Are you sure you want to stop the server %s?" - (lsp--workspace-print workspace))) - workspace)) - (workspaces (lsp--completing-read "Select server: " - workspaces - 'lsp--workspace-print nil t))) - (lsp-workspace-shutdown it))) - -(make-obsolete 'lsp-shutdown-workspace 'lsp-workspace-shutdown "lsp-mode 6.1") - -(defcustom lsp-auto-select-workspace t - "Shutdown or restart a single workspace. -If set and the current buffer has only a single workspace -associated with it, `lsp-shutdown-workspace' and -`lsp-restart-workspace' will act on it without asking." - :type 'boolean - :group 'lsp-mode) - -(defun lsp--read-workspace () - "Ask the user to select a workspace. -Errors if there are none." - (pcase (lsp-workspaces) - (`nil (error "No workspaces associated with the current buffer")) - ((and `(,workspace) (guard lsp-auto-select-workspace)) workspace) - (workspaces (lsp--completing-read "Select workspace: " workspaces - #'lsp--workspace-print nil t)))) - -(defun lsp-workspace-shutdown (workspace) - "Shut the workspace WORKSPACE and the language server associated with it" - (interactive (list (lsp--read-workspace))) - (lsp--warn "Stopping %s" (lsp--workspace-print workspace)) - (with-lsp-workspace workspace (lsp--shutdown-workspace))) - -(defun lsp-disconnect () - "Disconnect the buffer from the language server." - (interactive) - (lsp--text-document-did-close t) - (lsp-managed-mode -1) - (lsp-mode -1) - (setq lsp--buffer-workspaces nil) - (lsp--info "Disconnected")) - -(defun lsp-restart-workspace () - (interactive) - (--when-let (pcase (lsp-workspaces) - (`nil (user-error "There are no active servers in the current buffer")) - (`(,workspace) workspace) - (workspaces (lsp--completing-read "Select server: " - workspaces - 'lsp--workspace-print nil t))) - (lsp-workspace-restart it))) - -(make-obsolete 'lsp-restart-workspace 'lsp-workspace-restart "lsp-mode 6.1") - -(defun lsp-workspace-restart (workspace) - "Restart the workspace WORKSPACE and the language server associated with it" - (interactive (list (lsp--read-workspace))) - (lsp--warn "Restarting %s" (lsp--workspace-print workspace)) - (with-lsp-workspace workspace (lsp--shutdown-workspace t))) - -;;;###autoload -(defun lsp (&optional arg) - "Entry point for the server startup. -When ARG is t the lsp mode will start new language server even if -there is language server which can handle current language. When -ARG is nil current file will be opened in multi folder language -server if there is such. When `lsp' is called with prefix -argument ask the user to select which language server to start." - (interactive "P") - - (lsp--require-packages) - - (when (buffer-file-name) - (let (clients - (matching-clients (lsp--filter-clients - (-andfn #'lsp--supports-buffer? - #'lsp--server-binary-present?)))) - (cond - (matching-clients - (when (setq lsp--buffer-workspaces - (or (and - ;; Don't open as library file if file is part of a project. - (not (lsp-find-session-folder (lsp-session) (buffer-file-name))) - (lsp--try-open-in-library-workspace)) - (lsp--try-project-root-workspaces (equal arg '(4)) - (and arg (not (equal arg 1)))))) - (lsp-mode 1) - (when lsp-auto-configure (lsp--auto-configure)) - (setq lsp-buffer-uri (lsp--buffer-uri)) - (lsp--info "Connected to %s." - (apply 'concat (--map (format "[%s %s]" - (lsp--workspace-print it) - (lsp--workspace-root it)) - lsp--buffer-workspaces))))) - ;; look for servers which are currently being downloaded. - ((setq clients (lsp--filter-clients (-andfn #'lsp--supports-buffer? - #'lsp--client-download-in-progress?))) - (lsp--info "There are language server(%s) installation in progress. -The server(s) will be started in the buffer when it has finished." - (-map #'lsp--client-server-id clients)) - (seq-do (lambda (client) - (cl-pushnew (current-buffer) (lsp--client-buffers client))) - clients)) - ;; look for servers to install - ((setq clients (lsp--filter-clients - (-andfn #'lsp--supports-buffer? - (-const lsp-enable-suggest-server-download) - #'lsp--client-download-server-fn - (-not #'lsp--client-download-in-progress?)))) - (let ((client (lsp--completing-read - (concat "Unable to find installed server supporting this file. " - "The following servers could be installed automatically: ") - clients - (-compose #'symbol-name #'lsp--client-server-id) - nil - t))) - (cl-pushnew (current-buffer) (lsp--client-buffers client)) - (lsp--install-server-internal client))) - ;; ignore other warnings - ((not lsp-warn-no-matched-clients) - nil) - ;; automatic installation disabled - ((setq clients (unless matching-clients - (lsp--filter-clients (-andfn #'lsp--supports-buffer? - #'lsp--client-download-server-fn - (-not (-const lsp-enable-suggest-server-download)) - (-not #'lsp--server-binary-present?))))) - (lsp--warn "The following servers support current file but automatic download is disabled: %s -\(If you have already installed the server check *lsp-log*)." - (mapconcat (lambda (client) - (symbol-name (lsp--client-server-id client))) - clients - " "))) - ;; no clients present - ((setq clients (unless matching-clients - (lsp--filter-clients (-andfn #'lsp--supports-buffer? - (-not #'lsp--server-binary-present?))))) - (lsp--warn "The following servers support current file but do not have automatic installation: %s -You may find the installation instructions at https://emacs-lsp.github.io/lsp-mode/page/languages. -\(If you have already installed the server check *lsp-log*)." - (mapconcat (lambda (client) - (symbol-name (lsp--client-server-id client))) - clients - " "))) - ;; no matches - ((-> #'lsp--supports-buffer? lsp--filter-clients not) - (lsp--error "There are no language servers supporting current mode `%s' registered with `lsp-mode'. -This issue might be caused by: -1. The language you are trying to use does not have built-in support in `lsp-mode'. You must install the required support manually. Examples of this are `lsp-java' or `lsp-metals'. -2. The language server that you expect to run is not configured to run for major mode `%s'. You may check that by checking the `:major-modes' that are passed to `lsp-register-client'. -3. `lsp-mode' doesn't have any integration for the language behind `%s'. Refer to https://emacs-lsp.github.io/lsp-mode/page/languages and https://langserver.org/ . -4. You are over `tramp'. In this case follow https://emacs-lsp.github.io/lsp-mode/page/remote/. -5. You have disabled the `lsp-mode' clients for that file. (Check `lsp-enabled-clients' and `lsp-disabled-clients'). -You can customize `lsp-warn-no-matched-clients' to disable this message." - major-mode major-mode major-mode)))))) - -(defun lsp--buffer-visible-p () - "Return non nil if current buffer is visible." - (or (buffer-modified-p) (get-buffer-window nil t))) - -(defun lsp--init-if-visible () - "Run `lsp' for the current buffer if the buffer is visible. -Returns non nil if `lsp' was run for the buffer." - (when (lsp--buffer-visible-p) - (remove-hook 'window-configuration-change-hook #'lsp--init-if-visible t) - (lsp) - t)) - -;;;###autoload -(defun lsp-deferred () - "Entry point that defers server startup until buffer is visible. -`lsp-deferred' will wait until the buffer is visible before invoking `lsp'. -This avoids overloading the server with many files when starting Emacs." - ;; Workspace may not be initialized yet. Use a buffer local variable to - ;; remember that we deferred loading of this buffer. - (setq lsp--buffer-deferred t) - (let ((buffer (current-buffer))) - ;; Avoid false positives as desktop-mode restores buffers by deferring - ;; visibility check until the stack clears. - (run-with-idle-timer 0 nil (lambda () - (when (buffer-live-p buffer) - (with-current-buffer buffer - (unless (lsp--init-if-visible) - (add-hook 'window-configuration-change-hook #'lsp--init-if-visible nil t)))))))) - - - -(defvar lsp-file-truename-cache (ht)) - -(defmacro lsp-with-cached-filetrue-name (&rest body) - "Executes BODY caching the `file-truename' calls." - `(let ((old-fn (symbol-function 'file-truename))) - (unwind-protect - (progn - (fset 'file-truename - (lambda (file-name &optional counter prev-dirs) - (or (gethash file-name lsp-file-truename-cache) - (puthash file-name (apply old-fn (list file-name counter prev-dirs)) - lsp-file-truename-cache)))) - ,@body) - (fset 'file-truename old-fn)))) - - -(defun lsp-virtual-buffer-call (key &rest args) - (when lsp--virtual-buffer - (when-let ((fn (plist-get lsp--virtual-buffer key))) - (apply fn args)))) - -(defun lsp-translate-column (column) - "Translate COLUMN taking into account virtual buffers." - (or (lsp-virtual-buffer-call :real->virtual-char column) - column)) - -(defun lsp-translate-line (line) - "Translate LINE taking into account virtual buffers." - (or (lsp-virtual-buffer-call :real->virtual-line line) - line)) - - -;; lsp internal validation. - -(defmacro lsp--doctor (&rest checks) - `(-let [buf (current-buffer)] - (with-current-buffer (get-buffer-create "*lsp-performance*") - (with-help-window (current-buffer) - ,@(-map (-lambda ((msg form)) - `(insert (format "%s: %s\n" ,msg - (let ((res (with-current-buffer buf - ,form))) - (cond - ((eq res :optional) (propertize "OPTIONAL" 'face 'warning)) - (res (propertize "OK" 'face 'success)) - (t (propertize "ERROR" 'face 'error))))))) - (-partition 2 checks)))))) - -(define-obsolete-function-alias 'lsp-diagnose - 'lsp-doctor "lsp-mode 8.0.0") - -(defun lsp-doctor () - "Validate performance settings." - (interactive) - (lsp--doctor - "Checking for Native JSON support" (functionp 'json-serialize) - "Check emacs supports `read-process-output-max'" (boundp 'read-process-output-max) - "Check `read-process-output-max' default has been changed from 4k" - (and (boundp 'read-process-output-max) - (> read-process-output-max 4096)) - "Byte compiled against Native JSON (recompile lsp-mode if failing when Native JSON available)" - (condition-case _err - (progn (lsp--make-message (list "a" "b")) - nil) - (error t)) - "`gc-cons-threshold' increased?" (> gc-cons-threshold 800000) - "Using `plist' for deserialized objects? (refer to https://emacs-lsp.github.io/lsp-mode/page/performance/#use-plists-for-deserialization)" (or lsp-use-plists :optional) - "Using emacs 28+ with native compilation?" - (or (and (fboundp 'native-comp-available-p) - (native-comp-available-p)) - :optional))) - -(declare-function package-version-join "ext:package") -(declare-function package-desc-version "ext:package") -(declare-function package--alist "ext:package") - -(defun lsp-version () - "Return string describing current version of `lsp-mode'." - (interactive) - (unless (featurep 'package) - (require 'package)) - (let ((ver (format "lsp-mode %s, Emacs %s, %s" - (package-version-join - (package-desc-version - (car (alist-get 'lsp-mode (package--alist))))) - emacs-version - system-type))) - (if (called-interactively-p 'interactive) - (lsp--info "%s" ver) - ver))) - - - -;; org-mode/virtual-buffer - -(declare-function org-babel-get-src-block-info "ext:ob-core") -(declare-function org-do-remove-indentation "ext:org-macs") -(declare-function org-src-get-lang-mode "ext:org-src") -(declare-function org-element-context "ext:org-element") - -(defun lsp--virtual-buffer-update-position () - (-if-let (virtual-buffer (-first (-lambda ((&plist :in-range)) - (funcall in-range)) - lsp--virtual-buffer-connections)) - (unless (equal virtual-buffer lsp--virtual-buffer) - (lsp-org)) - (when lsp-managed-mode - (lsp-managed-mode -1) - (lsp-mode -1) - (setq lsp--buffer-workspaces nil) - (setq lsp--virtual-buffer nil) - (setq lsp-buffer-uri nil) - - ;; force refresh of diagnostics - (run-hooks 'lsp-after-diagnostics-hook)))) - -(defun lsp-virtual-buffer-on-change (start end length) - "Adjust on change event to be executed against the proper language server." - (let ((max-point (max end - (or (plist-get lsp--before-change-vals :end) 0) - (+ start length)))) - (when-let ((virtual-buffer (-first (lambda (vb) - (let ((lsp--virtual-buffer vb)) - (and (lsp-virtual-buffer-call :in-range start) - (lsp-virtual-buffer-call :in-range max-point)))) - lsp--virtual-buffer-connections))) - (lsp-with-current-buffer virtual-buffer - (lsp-on-change start end length - (lambda (&rest _) - (list :range (lsp--range (list :character 0 :line 0) - lsp--virtual-buffer-point-max) - :text (lsp--buffer-content)))))))) - -(defun lsp-virtual-buffer-before-change (start _end) - (when-let ((virtual-buffer (-first (lambda (vb) - (lsp-with-current-buffer vb - (lsp-virtual-buffer-call :in-range start))) - lsp--virtual-buffer-connections))) - (lsp-with-current-buffer virtual-buffer - (setq lsp--virtual-buffer-point-max - (lsp--point-to-position (lsp-virtual-buffer-call :last-point)))))) - -(defun lsp-patch-on-change-event () - (remove-hook 'after-change-functions #'lsp-on-change t) - (add-hook 'after-change-functions #'lsp-virtual-buffer-on-change nil t) - (add-hook 'before-change-functions #'lsp-virtual-buffer-before-change nil t)) - -(defun lsp-kill-virtual-buffers () - (mapc #'lsp-virtual-buffer-disconnect lsp--virtual-buffer-connections)) - -(defun lsp--move-point-in-indentation (point indentation) - (save-excursion - (goto-char point) - (if (<= point (+ (line-beginning-position) indentation)) - (line-beginning-position) - point))) - -(declare-function flycheck-checker-supports-major-mode-p "ext:flycheck") -(declare-function flycheck-add-mode "ext:flycheck") -(declare-function lsp-diagnostics-lsp-checker-if-needed "lsp-diagnostics") - -(defalias 'lsp-client-download-server-fn 'lsp--client-download-server-fn) - -(defun lsp-flycheck-add-mode (mode) - "Register flycheck support for MODE." - (lsp-diagnostics-lsp-checker-if-needed) - (unless (flycheck-checker-supports-major-mode-p 'lsp mode) - (flycheck-add-mode 'lsp mode))) - -(defun lsp-progress-spinner-type () - "Retrieve the spinner type value, if value is not a symbol of `spinner-types -defaults to `progress-bar." - (or (car (assoc lsp-progress-spinner-type spinner-types)) 'progress-bar)) - -(defun lsp-org () - (interactive) - (-if-let ((virtual-buffer &as &plist :workspaces) (-first (-lambda ((&plist :in-range)) - (funcall in-range)) - lsp--virtual-buffer-connections)) - (unless (equal lsp--virtual-buffer virtual-buffer) - (setq lsp--buffer-workspaces workspaces) - (setq lsp--virtual-buffer virtual-buffer) - (setq lsp-buffer-uri nil) - (lsp-mode 1) - (lsp-managed-mode 1) - (lsp-patch-on-change-event)) - - (save-excursion - (-let* (virtual-buffer - (wcb (lambda (f) - (with-current-buffer (plist-get virtual-buffer :buffer) - (-let* (((&plist :major-mode :buffer-file-name - :goto-buffer :workspaces) virtual-buffer) - (lsp--virtual-buffer virtual-buffer) - (lsp--buffer-workspaces workspaces)) - (save-excursion - (funcall goto-buffer) - (funcall f)))))) - ((&plist :begin :end :post-blank :language) (cl-second (org-element-context))) - ((&alist :tangle file-name) (cl-third (org-babel-get-src-block-info 'light))) - - (file-name (if file-name - (f-expand file-name) - (user-error "You should specify file name in the src block header."))) - (begin-marker (progn - (goto-char begin) - (forward-line) - (set-marker (make-marker) (point)))) - (end-marker (progn - (goto-char end) - (forward-line (1- (- post-blank))) - (set-marker (make-marker) (1+ (point))))) - (buf (current-buffer)) - (src-block (buffer-substring-no-properties begin-marker - (1- end-marker))) - (indentation (with-temp-buffer - (insert src-block) - - (goto-char (point-min)) - (let ((indentation (current-indentation))) - (plist-put lsp--virtual-buffer :indentation indentation) - (org-do-remove-indentation) - (goto-char (point-min)) - (- indentation (current-indentation)))))) - (add-hook 'post-command-hook #'lsp--virtual-buffer-update-position nil t) - - (when (fboundp 'flycheck-add-mode) - (lsp-flycheck-add-mode 'org-mode)) - - (setq lsp--virtual-buffer - (list - :in-range (lambda (&optional point) - (<= begin-marker (or point (point)) (1- end-marker))) - :goto-buffer (lambda () (goto-char begin-marker)) - :buffer-string - (lambda () - (let ((src-block (buffer-substring-no-properties - begin-marker - (1- end-marker)))) - (with-temp-buffer - (insert src-block) - - (goto-char (point-min)) - (while (not (eobp)) - (delete-region (point) (if (> (+ (point) indentation) (line-end-position)) - (line-end-position) - (+ (point) indentation))) - (forward-line)) - (buffer-substring-no-properties (point-min) - (point-max))))) - :buffer buf - :begin begin-marker - :end end-marker - :indentation indentation - :last-point (lambda () (1- end-marker)) - :cur-position (lambda () - (lsp-save-restriction-and-excursion - (list :line (- (lsp--cur-line) - (lsp--cur-line begin-marker)) - :character (let ((character (- (point) - (line-beginning-position) - indentation))) - (if (< character 0) - 0 - character))))) - :line/character->point (-lambda (line character) - (-let [inhibit-field-text-motion t] - (+ indentation - (lsp-save-restriction-and-excursion - (goto-char begin-marker) - (forward-line line) - (-let [line-end (line-end-position)] - (if (> character (- line-end (point))) - line-end - (forward-char character) - (point))))))) - :major-mode (org-src-get-lang-mode language) - :buffer-file-name file-name - :buffer-uri (lsp--path-to-uri file-name) - :with-current-buffer wcb - :buffer-live? (lambda (_) (buffer-live-p buf)) - :buffer-name (lambda (_) - (propertize (format "%s(%s:%s)%s" - (buffer-name buf) - begin-marker - end-marker - language) - 'face 'italic)) - :real->virtual-line (lambda (line) - (+ line (line-number-at-pos begin-marker) -1)) - :real->virtual-char (lambda (char) (+ char indentation)) - :cleanup (lambda () - (set-marker begin-marker nil) - (set-marker end-marker nil)))) - (setf virtual-buffer lsp--virtual-buffer) - (puthash file-name virtual-buffer lsp--virtual-buffer-mappings) - (push virtual-buffer lsp--virtual-buffer-connections) - - ;; TODO: tangle only connected sections - (add-hook 'after-save-hook 'org-babel-tangle nil t) - (add-hook 'lsp-after-open-hook #'lsp-patch-on-change-event nil t) - (add-hook 'kill-buffer-hook #'lsp-kill-virtual-buffers nil t) - - (setq lsp--buffer-workspaces - (lsp-with-current-buffer virtual-buffer - (lsp) - (plist-put virtual-buffer :workspaces (lsp-workspaces)) - (lsp-workspaces))))))) - -(defun lsp-virtual-buffer-disconnect (virtual-buffer) - (interactive (list (or - lsp--virtual-buffer - (when lsp--virtual-buffer-connections - (lsp--completing-read "Select virtual buffer to disconnect: " - lsp--virtual-buffer-connections - (-lambda ((&plist :buffer-file-name)) - buffer-file-name)))))) - (-if-let ((&plist :buffer-file-name file-name :cleanup) virtual-buffer) - (progn - (lsp-with-current-buffer virtual-buffer - (lsp--text-document-did-close)) - (setq lsp--virtual-buffer-connections (-remove-item virtual-buffer lsp--virtual-buffer-connections)) - (when (eq virtual-buffer lsp--virtual-buffer) - (setf lsp--virtual-buffer nil)) - (when cleanup (funcall cleanup)) - (remhash file-name lsp--virtual-buffer-mappings) - - (lsp--virtual-buffer-update-position) - (lsp--info "Disconnected from buffer %s" file-name)) - (lsp--error "Nothing to disconnect from?"))) - - -;; inlay hints - -(defface lsp-inlay-hint-face - '((t :inherit font-lock-comment-face)) - "The face to use for the JavaScript inlays." - :group 'lsp-mode - :package-version '(lsp-mode . "9.0.0")) - -(defface lsp-inlay-hint-type-face - '((t :inherit lsp-inlay-hint-face)) - "Face for inlay type hints (e.g. inferred variable types)." - :group 'lsp-mode - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-inlay-hint-type-format "%s" - "Format string for variable inlays (part of the inlay face)." - :type '(string :tag "String") - :group 'lsp-mode - :package-version '(lsp-mode . "9.0.0")) - -(defface lsp-inlay-hint-parameter-face - '((t :inherit lsp-inlay-hint-face)) - "Face for inlay parameter hints (e.g. function parameter names at -call-site)." - :group 'lsp-mode - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-inlay-hint-param-format "%s" - "Format string for parameter inlays (part of the inlay face)." - :type '(string :tag "String") - :group 'lsp-mode - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-update-inlay-hints-on-scroll t - "If non-nil update inlay hints immediately when scrolling or -modifying window sizes." - :type 'boolean - :package-version '(lsp-mode . "9.0.0")) - -(defun lsp--format-inlay (text kind) - (cond - ((eql kind lsp/inlay-hint-kind-type-hint) (format lsp-inlay-hint-type-format text)) - ((eql kind lsp/inlay-hint-kind-parameter-hint) (format lsp-inlay-hint-param-format text)) - (t text))) - -(defun lsp--face-for-inlay (kind) - (cond - ((eql kind lsp/inlay-hint-kind-type-hint) 'lsp-inlay-hint-type-face) - ((eql kind lsp/inlay-hint-kind-parameter-hint) 'lsp-inlay-hint-parameter-face) - (t 'lsp-inlay-hint-face))) - -(defun lsp--update-inlay-hints-scroll-function (window start) - (lsp-update-inlay-hints start (window-end window t))) - -(defun lsp--update-inlay-hints () - (lsp-update-inlay-hints (window-start) (window-end nil t))) - -(defun lsp--label-from-inlay-hints-response (label) - "Returns a string label built from an array of -InlayHintLabelParts or the argument itself if it's already a -string." - (cl-typecase label - (string label) - (vector - (string-join (mapcar (lambda (part) - (-let (((&InlayHintLabelPart :value) part)) - value)) - label))))) - -(defun lsp-update-inlay-hints (start end) - (lsp-request-async - "textDocument/inlayHint" - (lsp-make-inlay-hints-params - :text-document (lsp--text-document-identifier) - :range (lsp-make-range :start - (lsp-point-to-position start) - :end - (lsp-point-to-position end))) - (lambda (res) - (lsp--remove-overlays 'lsp-inlay-hint) - (dolist (hint res) - (-let* (((&InlayHint :label :position :kind? :padding-left? :padding-right?) hint) - (kind (or kind? lsp/inlay-hint-kind-type-hint)) - (label (lsp--label-from-inlay-hints-response label)) - (pos (lsp--position-to-point position)) - (overlay (make-overlay pos pos nil 'front-advance 'end-advance))) - (when (stringp label) - (overlay-put overlay 'lsp-inlay-hint t) - (overlay-put overlay 'before-string - (format "%s%s%s" - (if padding-left? " " "") - (propertize (lsp--format-inlay label kind) - 'font-lock-face (lsp--face-for-inlay kind)) - (if padding-right? " " ""))))))) - :mode 'tick)) - -(define-minor-mode lsp-inlay-hints-mode - "Mode for displaying inlay hints." - :lighter nil - (cond - ((and lsp-inlay-hints-mode lsp--buffer-workspaces) - (add-hook 'lsp-on-idle-hook #'lsp--update-inlay-hints nil t) - (when lsp-update-inlay-hints-on-scroll - (add-to-list (make-local-variable 'window-scroll-functions) - #'lsp--update-inlay-hints-scroll-function))) - (t - (lsp--remove-overlays 'lsp-inlay-hint) - (remove-hook 'lsp-on-idle-hook #'lsp--update-inlay-hints t) - (setf window-scroll-functions - (delete #'lsp--update-inlay-hints-scroll-function window-scroll-functions))))) - - - -;;;###autoload -(defun lsp-start-plain () - "Start `lsp-mode' using minimal configuration using the latest `melpa' version -of the packages. - -In case the major-mode that you are using for " - (interactive) - (let ((start-plain (make-temp-file "plain" nil ".el"))) - (url-copy-file "https://raw.githubusercontent.com/emacs-lsp/lsp-mode/master/scripts/lsp-start-plain.el" - start-plain t) - (async-shell-command - (format "%s -q -l %s %s" - (expand-file-name invocation-name invocation-directory) - start-plain - (or (buffer-file-name) "")) - (generate-new-buffer " *lsp-start-plain*")))) - - - -(provide 'lsp-mode) -;;; lsp-mode.el ends here diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-mode.elc b/emacs/elpa/lsp-mode-20240514.1430/lsp-mode.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-protocol.el b/emacs/elpa/lsp-mode-20240514.1430/lsp-protocol.el @@ -1,797 +0,0 @@ -;;; lsp-protocol.el --- Language Sever Protocol Bindings -*- lexical-binding: t; -*- - -;; Copyright (C) 2020 Ivan Yonchovski - -;; Author: Ivan Yonchovski <yyoncho@gmail.com> -;; Keywords: convenience - -;; 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 <https://www.gnu.org/licenses/>. - -;;; Commentary: - -;; Autogenerated bindings from lsp4j using -;; https://github.com/victools/jsonschema-generator+scripts to generate -;; scripts/generated.protocol.schema.json and then -;; scripts/lsp-generate-bindings.el - -;;; Code: - -(require 'cl-lib) -(require 'dash) -(require 'ht) -(require 's) -(require 'json) - -(eval-and-compile - (defun lsp-keyword->symbol (keyword) - "Convert a KEYWORD to symbol." - (intern (substring (symbol-name keyword) 1))) - - (defun lsp-keyword->string (keyword) - "Convert a KEYWORD to string." - (substring (symbol-name keyword) 1)) - - (defvar lsp-use-plists (getenv "LSP_USE_PLISTS"))) - -(defmacro lsp-interface (&rest interfaces) - "Generate LSP bindings from INTERFACES triplet. - -Example usage with `dash`. - -\(-let [(&ApplyWorkspaceEditResponse - :failure-reason?) (ht (\"failureReason\" \"...\"))] - failure-reason?) - -\(fn (INTERFACE-NAME-1 REQUIRED-FIELDS-1 OPTIONAL-FIELDS-1) (INTERFACE-NAME-2 REQUIRED-FIELDS-2 OPTIONAL-FIELDS-2) ...)" - (with-case-table ascii-case-table - (->> interfaces - (-map (-lambda ((interface required optional)) - (let ((params (nconc - (-map (lambda (param-name) - (cons - (intern (concat ":" (s-dashed-words (symbol-name param-name)) "?")) - param-name)) - optional) - (-map (lambda (param-name) - (cons (intern (concat ":" (s-dashed-words (symbol-name param-name)))) - param-name)) - required)))) - (cl-list* - `(defun ,(intern (format "dash-expand:&%s" interface)) (key source) - (unless (or (member key ',(-map #'cl-first params)) - (s-starts-with? ":_" (symbol-name key))) - (error "Unknown key: %s. Available keys: %s" key ',(-map #'cl-first params))) - ,(if lsp-use-plists - ``(plist-get ,source - ,(if (s-starts-with? ":_" (symbol-name key)) - key - (cl-rest (assoc key ',params)))) - ``(gethash ,(if (s-starts-with? ":_" (symbol-name key)) - (substring (symbol-name key) 1) - (substring (symbol-name - (cl-rest (assoc key ',params))) - 1)) - ,source))) - `(defun ,(intern (format "dash-expand:&%s?" interface)) (key source) - (unless (member key ',(-map #'cl-first params)) - (error "Unknown key: %s. Available keys: %s" key ',(-map #'cl-first params))) - ,(if lsp-use-plists - ``(plist-get ,source - ,(if (s-starts-with? ":_" (symbol-name key)) - key - (cl-rest (assoc key ',params)))) - ``(when (ht? ,source) - (gethash ,(substring (symbol-name - (cl-rest (assoc key ',params))) - 1) - ,source)))) - - `(defun ,(intern (format "lsp-%s?" (s-dashed-words (symbol-name interface)))) (object) - (cond - ((ht? object) - (-all? (let ((keys (ht-keys object))) - (lambda (prop) - (member prop keys))) - ',(-map (lambda (field-name) - (substring (symbol-name field-name) 1)) - required))) - ((listp object) (-all? (lambda (prop) - (plist-member object prop)) - ',required)))) - `(cl-defun ,(intern (format "lsp-make-%s" (s-dashed-words (symbol-name interface)))) - (&rest plist &key ,@(-map (-lambda ((key)) - (intern (substring (symbol-name key) 1))) params) - &allow-other-keys) - (ignore ,@(-map (-lambda ((key)) - (intern (substring (symbol-name key) 1))) params)) - ,(format "Constructs %s from `plist.' -Allowed params: %s" interface (reverse (-map #'cl-first params))) - ,(if lsp-use-plists - `(-mapcat (-lambda ((key value)) - (list (or (cl-rest (assoc key ',params)) key) value)) - (-partition 2 plist)) - `(let (($$result (ht))) - (mapc (-lambda ((key value)) - (puthash (lsp-keyword->string (or (cl-rest (assoc key ',params)) - key)) - value - $$result)) - (-partition 2 plist)) - $$result))) - `(pcase-defmacro ,interface (&rest property-bindings) - ,(if lsp-use-plists - ``(and - (pred listp) - ;; Check if all the types required by the - ;; interface exist in the expr-val. - ,@(-map - (lambda (key) - `(pred - (lambda (plist) - (plist-member plist ,key)))) - ',required) - ;; Recursively generate the bindings. - ,@(let ((current-list property-bindings) - (output-bindings nil)) - ;; Invariant: while current-list is - ;; non-nil, the car of current-list is - ;; always of the form :key, while the - ;; cadr of current-list is either a) - ;; nil, b) of the form :key-next or c) - ;; a pcase pattern that can - ;; recursively match an expression. - (while current-list - (-let* (((curr-binding-as-keyword next-entry . _) current-list) - (curr-binding-as-camelcased-symbol - (or (alist-get curr-binding-as-keyword ',params) - (error "Unknown key: %s. Available keys: %s" - (symbol-name curr-binding-as-keyword) - ',(-map #'cl-first params)))) - (bound-name (lsp-keyword->symbol curr-binding-as-keyword)) - (next-entry-is-key-or-nil - (and (symbolp next-entry) - (or (null next-entry) - (s-starts-with? ":" (symbol-name next-entry)))))) - (cond - ;; If the next-entry is either a - ;; plist-key or nil, then bind to - ;; bound-name the value corresponding - ;; to the camelcased symbol. Pop - ;; current-list once. - (next-entry-is-key-or-nil - (push `(app (lambda (plist) - (plist-get plist ,curr-binding-as-camelcased-symbol)) - ,bound-name) - output-bindings) - (setf current-list (cdr current-list))) - ;; Otherwise, next-entry is a pcase - ;; pattern we recursively match to the - ;; expression. This can in general - ;; create additional bindings that we - ;; persist in the top level of - ;; bindings. We pop current-list - ;; twice. - (t - (push `(app (lambda (plist) - (plist-get plist ,curr-binding-as-camelcased-symbol)) - ,next-entry) - output-bindings) - (setf current-list (cddr current-list)))))) - output-bindings)) - ``(and - (pred ht?) - ,@(-map - (lambda (key) - `(pred - (lambda (hash-table) - (ht-contains? hash-table ,(lsp-keyword->string key))))) - ',required) - ,@(let ((current-list property-bindings) - (output-bindings nil)) - (while current-list - (-let* (((curr-binding-as-keyword next-entry . _) current-list) - (curr-binding-as-camelcased-string - (lsp-keyword->string (or (alist-get curr-binding-as-keyword ',params) - (error "Unknown key: %s. Available keys: %s" - (symbol-name curr-binding-as-keyword) - ',(-map #'cl-first params))))) - (bound-name (lsp-keyword->symbol curr-binding-as-keyword)) - (next-entry-is-key-or-nil - (and (symbolp next-entry) - (or (null next-entry) - (s-starts-with? ":" (symbol-name next-entry)))))) - (cond - (next-entry-is-key-or-nil - (push `(app (lambda (hash-table) - (ht-get hash-table ,curr-binding-as-camelcased-string)) - ,bound-name) - output-bindings) - (setf current-list (cdr current-list))) - (t - (push `(app (lambda (hash-table) - (ht-get hash-table ,curr-binding-as-camelcased-string)) - ,next-entry) - output-bindings) - (setf current-list (cddr current-list)))))) - output-bindings)))) - (-mapcat (-lambda ((label . name)) - (list - `(defun ,(intern (format "lsp:%s-%s" - (s-dashed-words (symbol-name interface)) - (substring (symbol-name label) 1))) - (object) - ,(if lsp-use-plists - `(plist-get object ,name) - `(when (ht? object) (gethash ,(lsp-keyword->string name) object)))) - `(defun ,(intern (format "lsp:set-%s-%s" - (s-dashed-words (symbol-name interface)) - (substring (symbol-name label) 1))) - (object value) - ,@(if lsp-use-plists - `((plist-put object ,name value)) - `((puthash ,(lsp-keyword->string name) value object) - object))))) - params))))) - (apply #'append) - (cl-list* 'progn)))) - -(if lsp-use-plists - (progn - (defun lsp-get (from key) - (plist-get from key)) - (defun lsp-put (where key value) - (plist-put where key value)) - (defun lsp-map (fn value) - (-map (-lambda ((k v)) - (funcall fn (lsp-keyword->string k) v)) - (-partition 2 value ))) - (defalias 'lsp-merge 'append) - (defalias 'lsp-empty? 'null) - (defalias 'lsp-copy 'copy-sequence) - (defun lsp-member? (from key) - (when (listp from) - (plist-member from key))) - (defalias 'lsp-structure-p 'json-plist-p) - (defun lsp-delete (from key) - (cl-remf from key) - from)) - (defun lsp-get (from key) - (when from - (gethash (lsp-keyword->string key) from))) - (defun lsp-put (where key value) - (prog1 where - (puthash (lsp-keyword->string key) value where))) - (defun lsp-map (fn value) - (when value - (maphash fn value))) - (defalias 'lsp-merge 'ht-merge) - (defalias 'lsp-empty? 'ht-empty?) - (defalias 'lsp-copy 'ht-copy) - (defun lsp-member? (from key) - (when (hash-table-p from) - (not (eq (gethash (lsp-keyword->string key) from :__lsp_default) - :__lsp_default)))) - (defalias 'lsp-structure-p 'hash-table-p) - (defun lsp-delete (from key) - (ht-remove from (lsp-keyword->string key)) - from)) - -(defmacro lsp-defun (name match-form &rest body) - "Define a function named NAME. -The function destructures its input as MATCH-FORM then executes BODY. - -Note that you have to enclose the MATCH-FORM in a pair of parens, -such that: - - (-defun (x) body) - (-defun (x y ...) body) - -has the usual semantics of `defun'. Furthermore, these get -translated into a normal `defun', so there is no performance -penalty. - -See `-let' for a description of the destructuring mechanism." - (declare (doc-string 3) (indent defun) - (debug (&define name sexp - [&optional stringp] - [&optional ("declare" &rest sexp)] - [&optional ("interactive" interactive)] - def-body))) - (cond - ((nlistp match-form) - (signal 'wrong-type-argument (list #'listp match-form))) - ;; no destructuring, so just return regular defun to make things faster - ((-all? #'symbolp match-form) - `(defun ,name ,match-form ,@body)) - (t - (-let* ((inputs (--map-indexed (list it (make-symbol (format "input%d" it-index))) match-form)) - ((body docs) (cond - ;; only docs - ((and (stringp (car body)) - (not (cdr body))) - (list body (car body))) - ;; docs + body - ((stringp (car body)) - (list (cdr body) (car body))) - ;; no docs - (t (list body)))) - ((body interactive-form) (cond - ;; interactive form - ((and (listp (car body)) - (eq (caar body) 'interactive)) - (list (cdr body) (car body))) - ;; no interactive form - (t (list body))))) - ;; TODO: because inputs to the defun are evaluated only once, - ;; -let* need not to create the extra bindings to ensure that. - ;; We should find a way to optimize that. Not critical however. - `(defun ,name ,(-map #'cadr inputs) - ,@(when docs (list docs)) - ,@(when interactive-form (list interactive-form)) - (-let* ,inputs ,@body)))))) - - - - -;; manually defined interfaces -(defconst lsp/markup-kind-plain-text "plaintext") -(defconst lsp/markup-kind-markdown "markdown") - -(lsp-interface (JSONResponse (:params :id :method :result) nil) - (JSONResponseError (:error) nil) - (JSONMessage nil (:params :id :method :result :error)) - (JSONResult nil (:params :id :method)) - (JSONNotification (:params :method) nil) - (JSONRequest (:params :method) nil) - (JSONError (:message :code) (:data)) - (ProgressParams (:token :value) nil) - (Edit (:kind) nil) - (WorkDoneProgress (:kind) nil) - (WorkDoneProgressBegin (:kind :title) (:cancellable :message :percentage)) - (WorkDoneProgressReport (:kind) (:cancellable :message :percentage)) - (WorkDoneProgressEnd (:kind) (:message)) - (WorkDoneProgressOptions nil (:workDoneProgress)) - (SemanticTokensOptions (:legend) (:rangeProvider :documentProvider)) - (SemanticTokensLegend (:tokenTypes :tokenModifiers)) - (SemanticTokensResult (:resultId) (:data)) - (SemanticTokensPartialResult nil (:data)) - (SemanticTokensEdit (:start :deleteCount) (:data)) - (SemanticTokensDelta (:resultId) (:edits)) - (SemanticTokensDeltaPartialResult nil (:edits))) - -(lsp-interface (v1:ProgressParams (:id :title) (:message :percentage :done))) - -(defun dash-expand:&RangeToPoint (key source) - "Convert the position KEY from SOURCE into a point." - `(lsp--position-to-point - (lsp-get ,source ,key))) - -(lsp-interface (eslint:StatusParams (:state) nil) - (eslint:OpenESLintDocParams (:url) nil) - (eslint:ConfirmExecutionParams (:scope :file :libraryPath) nil)) - -(lsp-interface (haxe:ProcessStartNotification (:title) nil)) - -(lsp-interface (pwsh:ScriptRegion (:StartLineNumber :EndLineNumber :StartColumnNumber :EndColumnNumber :Text) nil)) - -(lsp-interface (omnisharp:ErrorMessage (:Text :FileName :Line :Column)) - (omnisharp:ProjectInformationRequest (:FileName)) - (omnisharp:MsBuildProject (:IsUnitProject :IsExe :Platform :Configuration :IntermediateOutputPath :OutputPath :TargetFrameworks :SourceFiles :TargetFramework :TargetPath :AssemblyName :Path :ProjectGuid)) - (omnisharp:ProjectInformation (:ScriptProject :MsBuildProject)) - (omnisharp:CodeStructureRequest (:FileName)) - (omnisharp:CodeStructureResponse (:Elements)) - (omnisharp:CodeElement (:Kind :Name :DisplayName :Children :Ranges :Properties)) - (omnisharp:CodeElementProperties () (:static :accessibility :testMethodName :testFramework)) - (omnisharp:Range (:Start :End)) - (omnisharp:RangeList () (:attributes :full :name)) - (omnisharp:Point (:Line :Column)) - (omnisharp:RunTestsInClassRequest (:MethodNames :RunSettings :TestFrameworkname :TargetFrameworkVersion :NoBuild :Line :Column :Buffer :FileName)) - (omnisharp:RunTestResponse (:Results :Pass :Failure :ContextHadNoTests)) - (omnisharp:TestMessageEvent (:MessageLevel :Message)) - (omnisharp:DotNetTestResult (:MethodName :Outcome :ErrorMessage :ErrorStackTrace :StandardOutput :StandardError))) - -(lsp-interface (csharp-ls:CSharpMetadata (:textDocument)) - (csharp-ls:CSharpMetadataResponse (:source :projectName :assemblyName :symbolName))) - -(lsp-interface (rls:Cmd (:args :binary :env :cwd) nil)) - -(lsp-interface (rust-analyzer:AnalyzerStatusParams (:textDocument)) - (rust-analyzer:SyntaxTreeParams (:textDocument) (:range)) - (rust-analyzer:ViewHir (:textDocument :position)) - (rust-analyzer:ViewItemTree (:textDocument)) - (rust-analyzer:ExpandMacroParams (:textDocument :position) nil) - (rust-analyzer:ExpandedMacro (:name :expansion) nil) - (rust-analyzer:MatchingBraceParams (:textDocument :positions) nil) - (rust-analyzer:OpenCargoTomlParams (:textDocument) nil) - (rust-analyzer:OpenExternalDocsParams (:textDocument :position) nil) - (rust-analyzer:ResovedCodeActionParams (:id :codeActionParams) nil) - (rust-analyzer:JoinLinesParams (:textDocument :ranges) nil) - (rust-analyzer:MoveItemParams (:textDocument :range :direction) nil) - (rust-analyzer:RunnablesParams (:textDocument) (:position)) - (rust-analyzer:Runnable (:label :kind :args) (:location)) - (rust-analyzer:RunnableArgs (:cargoArgs :executableArgs) (:workspaceRoot :expectTest)) - (rust-analyzer:RelatedTestsParams (:textDocument :position) nil) - (rust-analyzer:RelatedTests (:runnable) nil) - (rust-analyzer:SsrParams (:query :parseOnly) nil) - (rust-analyzer:CommandLink (:title :command) (:arguments :tooltip)) - (rust-analyzer:CommandLinkGroup (:commands) (:title))) - -(lsp-interface (clojure-lsp:TestTreeParams (:uri :tree) nil) - (clojure-lsp:TestTreeNode (:name :range :nameRange :kind) (:children)) - (clojure-lsp:ProjectTreeNode (:name :type) (:nodes :final :id :uri :detail :range))) - -(lsp-interface (terraform-ls:ModuleCalls (:v :module_calls) nil)) -(lsp-interface (terraform-ls:Module (:name :docs_link :version :source_type :dependent_modules) nil)) -(lsp-interface (terraform-ls:Providers (:v :provider_requirements :installed_providers) nil)) -(lsp-interface (terraform-ls:module.terraform (:v :required_version :discovered_version))) - - -;; begin autogenerated code - -(defvar lsp/completion-item-kind-lookup - [nil Text Method Function Constructor Field Variable Class Interface Module Property Unit Value Enum Keyword Snippet Color File Reference Folder EnumMember Constant Struct Event Operator TypeParameter]) -(defconst lsp/completion-item-kind-text 1) -(defconst lsp/completion-item-kind-method 2) -(defconst lsp/completion-item-kind-function 3) -(defconst lsp/completion-item-kind-constructor 4) -(defconst lsp/completion-item-kind-field 5) -(defconst lsp/completion-item-kind-variable 6) -(defconst lsp/completion-item-kind-class 7) -(defconst lsp/completion-item-kind-interface 8) -(defconst lsp/completion-item-kind-module 9) -(defconst lsp/completion-item-kind-property 10) -(defconst lsp/completion-item-kind-unit 11) -(defconst lsp/completion-item-kind-value 12) -(defconst lsp/completion-item-kind-enum 13) -(defconst lsp/completion-item-kind-keyword 14) -(defconst lsp/completion-item-kind-snippet 15) -(defconst lsp/completion-item-kind-color 16) -(defconst lsp/completion-item-kind-file 17) -(defconst lsp/completion-item-kind-reference 18) -(defconst lsp/completion-item-kind-folder 19) -(defconst lsp/completion-item-kind-enum-member 20) -(defconst lsp/completion-item-kind-constant 21) -(defconst lsp/completion-item-kind-struct 22) -(defconst lsp/completion-item-kind-event 23) -(defconst lsp/completion-item-kind-operator 24) -(defconst lsp/completion-item-kind-type-parameter 25) -(defvar lsp/completion-trigger-kind-lookup - [nil Invoked TriggerCharacter TriggerForIncompleteCompletions]) -(defconst lsp/completion-trigger-kind-invoked 1) -(defconst lsp/completion-trigger-kind-trigger-character 2) -(defconst lsp/completion-trigger-kind-trigger-for-incomplete-completions 3) -(defvar lsp/diagnostic-severity-lookup - [nil Error Warning Information Hint Max]) -(defconst lsp/diagnostic-severity-error 1) -(defconst lsp/diagnostic-severity-warning 2) -(defconst lsp/diagnostic-severity-information 3) -(defconst lsp/diagnostic-severity-hint 4) -(defconst lsp/diagnostic-severity-max 5) -(defvar lsp/diagnostic-tag-lookup - [nil Unnecessary Deprecated]) -(defconst lsp/diagnostic-tag-unnecessary 1) -(defconst lsp/diagnostic-tag-deprecated 2) -(defvar lsp/completion-item-tag-lookup - [nil Deprecated]) -(defconst lsp/completion-item-tag-deprecated 1) -(defvar lsp/document-highlight-kind-lookup - [nil Text Read Write]) -(defconst lsp/document-highlight-kind-text 1) -(defconst lsp/document-highlight-kind-read 2) -(defconst lsp/document-highlight-kind-write 3) -(defvar lsp/file-change-type-lookup - [nil Created Changed Deleted]) -(defconst lsp/file-change-type-created 1) -(defconst lsp/file-change-type-changed 2) -(defconst lsp/file-change-type-deleted 3) -(defvar lsp/insert-text-format-lookup - [nil PlainText Snippet]) -(defconst lsp/insert-text-format-plain-text 1) -(defconst lsp/insert-text-format-snippet 2) -(defvar lsp/insert-text-mode-lookup - [nil AsIs AdjustIndentation]) -(defconst lsp/insert-text-mode-as-it 1) -(defconst lsp/insert-text-mode-adjust-indentation 2) -(defvar lsp/message-type-lookup - [nil Error Warning Info Log]) -(defconst lsp/message-type-error 1) -(defconst lsp/message-type-warning 2) -(defconst lsp/message-type-info 3) -(defconst lsp/message-type-log 4) -(defvar lsp/signature-help-trigger-kind-lookup - [nil Invoked TriggerCharacter ContentChange]) -(defconst lsp/signature-help-trigger-kind-invoked 1) -(defconst lsp/signature-help-trigger-kind-trigger-character 2) -(defconst lsp/signature-help-trigger-kind-content-change 3) -(defvar lsp/symbol-kind-lookup - [nil File Module Namespace Package Class Method Property Field Constructor Enum Interface Function Variable Constant String Number Boolean Array Object Key Null EnumMember Struct Event Operator TypeParameter]) -(defconst lsp/symbol-kind-file 1) -(defconst lsp/symbol-kind-module 2) -(defconst lsp/symbol-kind-namespace 3) -(defconst lsp/symbol-kind-package 4) -(defconst lsp/symbol-kind-class 5) -(defconst lsp/symbol-kind-method 6) -(defconst lsp/symbol-kind-property 7) -(defconst lsp/symbol-kind-field 8) -(defconst lsp/symbol-kind-constructor 9) -(defconst lsp/symbol-kind-enum 10) -(defconst lsp/symbol-kind-interface 11) -(defconst lsp/symbol-kind-function 12) -(defconst lsp/symbol-kind-variable 13) -(defconst lsp/symbol-kind-constant 14) -(defconst lsp/symbol-kind-string 15) -(defconst lsp/symbol-kind-number 16) -(defconst lsp/symbol-kind-boolean 17) -(defconst lsp/symbol-kind-array 18) -(defconst lsp/symbol-kind-object 19) -(defconst lsp/symbol-kind-key 20) -(defconst lsp/symbol-kind-null 21) -(defconst lsp/symbol-kind-enum-member 22) -(defconst lsp/symbol-kind-struct 23) -(defconst lsp/symbol-kind-event 24) -(defconst lsp/symbol-kind-operator 25) -(defconst lsp/symbol-kind-type-parameter 26) -(defvar lsp/text-document-save-reason-lookup - [nil Manual AfterDelay FocusOut]) -(defconst lsp/text-document-save-reason-manual 1) -(defconst lsp/text-document-save-reason-after-delay 2) -(defconst lsp/text-document-save-reason-focus-out 3) -(defvar lsp/text-document-sync-kind-lookup - [None Full Incremental]) -(defconst lsp/text-document-sync-kind-none 0) -(defconst lsp/text-document-sync-kind-full 1) -(defconst lsp/text-document-sync-kind-incremental 2) -(defvar lsp/type-hierarchy-direction-lookup - [nil Children Parents Both]) -(defconst lsp/type-hierarchy-direction-children 1) -(defconst lsp/type-hierarchy-direction-parents 2) -(defconst lsp/type-hierarchy-direction-both 3) -(defvar lsp/call-hierarchy-direction-lookup - [nil CallsFrom CallsTo]) -(defconst lsp/call-hierarchy-direction-calls-from 1) -(defconst lsp/call-hierarchy-direction-calls-to 2) -(defvar lsp/response-error-code-lookup - [nil ParseError InvalidRequest MethodNotFound InvalidParams InternalError serverErrorStart serverErrorEnd]) -(defconst lsp/response-error-code-parse-error 1) -(defconst lsp/response-error-code-invalid-request 2) -(defconst lsp/response-error-code-method-not-found 3) -(defconst lsp/response-error-code-invalid-params 4) -(defconst lsp/response-error-code-internal-error 5) -(defconst lsp/response-error-code-server-error-start 6) -(defconst lsp/response-error-code-server-error-end 7) - -(lsp-interface - (CallHierarchyCapabilities nil (:dynamicRegistration)) - (CallHierarchyItem (:kind :name :range :selectionRange :uri) (:detail :tags)) - (ClientCapabilities nil (:experimental :textDocument :workspace)) - (ClientInfo (:name) (:version)) - (CodeActionCapabilities nil (:codeActionLiteralSupport :dynamicRegistration :isPreferredSupport :dataSupport :resolveSupport)) - (CodeActionContext (:diagnostics) (:only)) - (CodeActionKindCapabilities (:valueSet) nil) - (CodeActionLiteralSupportCapabilities nil (:codeActionKind)) - (CodeActionOptions nil (:codeActionKinds :resolveProvider)) - (CodeLensCapabilities nil (:dynamicRegistration)) - (CodeLensOptions (:resolveProvider) nil) - (Color (:red :green :blue :alpha) nil) - (ColorProviderCapabilities nil (:dynamicRegistration)) - (ColorProviderOptions nil (:documentSelector :id)) - (ColoringInformation (:range :styles) nil) - (Command (:title :command) (:arguments)) - (CompletionCapabilities nil (:completionItem :completionItemKind :contextSupport :dynamicRegistration)) - (CompletionContext (:triggerKind) (:triggerCharacter)) - (CompletionItem (:label) (:additionalTextEdits :command :commitCharacters :data :deprecated :detail :documentation :filterText :insertText :insertTextFormat :insertTextMode :kind :preselect :sortText :tags :textEdit :score :labelDetails)) - (CompletionItemCapabilities nil (:commitCharactersSupport :deprecatedSupport :documentationFormat :preselectSupport :snippetSupport :tagSupport :insertReplaceSupport :resolveSupport)) - (CompletionItemKindCapabilities nil (:valueSet)) - (CompletionItemTagSupportCapabilities (:valueSet) nil) - (CompletionOptions nil (:resolveProvider :triggerCharacters :allCommitCharacters)) - (ConfigurationItem nil (:scopeUri :section)) - (CreateFileOptions nil (:ignoreIfExists :overwrite)) - (DeclarationCapabilities nil (:dynamicRegistration :linkSupport)) - (DefinitionCapabilities nil (:dynamicRegistration :linkSupport)) - (DeleteFileOptions nil (:ignoreIfNotExists :recursive)) - (Diagnostic (:range :message) (:code :relatedInformation :severity :source :tags)) - (DiagnosticRelatedInformation (:location :message) nil) - (DiagnosticsTagSupport (:valueSet) nil) - (DidChangeConfigurationCapabilities nil (:dynamicRegistration)) - (DidChangeWatchedFilesCapabilities nil (:dynamicRegistration)) - (DocumentFilter nil (:language :pattern :scheme)) - (DocumentHighlightCapabilities nil (:dynamicRegistration)) - (DocumentLinkCapabilities nil (:dynamicRegistration :tooltipSupport)) - (DocumentLinkOptions nil (:resolveProvider)) - (DocumentOnTypeFormattingOptions (:firstTriggerCharacter) (:moreTriggerCharacter)) - (DocumentSymbol (:kind :name :range :selectionRange) (:children :deprecated :detail)) - (DocumentSymbolCapabilities nil (:dynamicRegistration :hierarchicalDocumentSymbolSupport :symbolKind)) - (ExecuteCommandCapabilities nil (:dynamicRegistration)) - (ExecuteCommandOptions (:commands) nil) - (FileEvent (:type :uri) nil) - (FileSystemWatcher (:globPattern) (:kind)) - (FileOperationFilter (:pattern) (:scheme)) - (FileOperationPattern (:glob) (:matches :options)) - (FileOperationPatternOptions nil (:ignoreCase)) - (FileOperationRegistrationOptions (:filters) nil) - (FoldingRangeCapabilities nil (:dynamicRegistration :lineFoldingOnly :rangeLimit)) - (FoldingRangeProviderOptions nil (:documentSelector :id)) - (FormattingCapabilities nil (:dynamicRegistration)) - (FormattingOptions (:tabSize :insertSpaces) (:trimTrailingWhitespace :insertFinalNewline :trimFinalNewlines)) - (HoverCapabilities nil (:contentFormat :dynamicRegistration)) - (ImplementationCapabilities nil (:dynamicRegistration :linkSupport)) - (LabelDetails (:detail :description) nil) - (LinkedEditingRanges (:ranges) (:wordPattern)) - (Location (:range :uri) nil) - (MarkedString (:language :value) nil) - (MarkupContent (:kind :value) nil) - (MessageActionItem (:title) nil) - (OnTypeFormattingCapabilities nil (:dynamicRegistration)) - (ParameterInformation (:label) (:documentation)) - (ParameterInformationCapabilities nil (:labelOffsetSupport)) - (Position (:character :line) nil) - (PublishDiagnosticsCapabilities nil (:relatedInformation :tagSupport :versionSupport)) - (Range (:start :end) nil) - (RangeFormattingCapabilities nil (:dynamicRegistration)) - (ReferenceContext (:includeDeclaration) nil) - (ReferencesCapabilities nil (:dynamicRegistration)) - (Registration (:method :id) (:registerOptions)) - (RenameCapabilities nil (:dynamicRegistration :prepareSupport)) - (RenameFileOptions nil (:ignoreIfExists :overwrite)) - (RenameOptions nil (:documentSelector :id :prepareProvider)) - (ResourceChange nil (:current :newUri)) - (ResourceOperation (:kind) nil) - (SaveOptions nil (:includeText)) - (SelectionRange (:range) (:parent)) - (SelectionRangeCapabilities nil (:dynamicRegistration)) - (SemanticHighlightingCapabilities nil (:semanticHighlighting)) - (SemanticHighlightingInformation (:line) (:tokens)) - (SemanticHighlightingServerCapabilities nil (:scopes)) - (ServerCapabilities nil (:callHierarchyProvider :codeActionProvider :codeLensProvider :colorProvider :completionProvider :declarationProvider :definitionProvider :documentFormattingProvider :documentHighlightProvider :documentLinkProvider :documentOnTypeFormattingProvider :documentRangeFormattingProvider :documentSymbolProvider :executeCommandProvider :experimental :foldingRangeProvider :hoverProvider :implementationProvider :referencesProvider :renameProvider :selectionRangeProvider :semanticHighlighting :signatureHelpProvider :textDocumentSync :typeDefinitionProvider :typeHierarchyProvider :workspace :workspaceSymbolProvider :semanticTokensProvider)) - (ServerInfo (:name) (:version)) - (SignatureHelp (:signatures) (:activeParameter :activeSignature)) - (SignatureHelpCapabilities nil (:contextSupport :dynamicRegistration :signatureInformation)) - (SignatureHelpContext (:triggerKind :isRetrigger) (:activeSignatureHelp :triggerCharacter)) - (SignatureHelpOptions nil (:retriggerCharacters :triggerCharacters)) - (SignatureInformation (:label) (:documentation :parameters)) - (SignatureInformationCapabilities nil (:documentationFormat :parameterInformation)) - (StaticRegistrationOptions nil (:documentSelector :id)) - (SymbolCapabilities nil (:dynamicRegistration :symbolKind)) - (SymbolKindCapabilities nil (:valueSet)) - (SynchronizationCapabilities nil (:didSave :dynamicRegistration :willSave :willSaveWaitUntil)) - (TextDocumentClientCapabilities nil (:callHierarchy :codeAction :codeLens :colorProvider :completion :declaration :definition :documentHighlight :documentLink :documentSymbol :foldingRange :formatting :hover :implementation :onTypeFormatting :publishDiagnostics :rangeFormatting :references :rename :selectionRange :semanticHighlightingCapabilities :signatureHelp :synchronization :typeDefinition :typeHierarchyCapabilities)) - (TextDocumentContentChangeEvent (:text) (:range :rangeLength)) - (TextDocumentEdit (:textDocument :edits) nil) - (TextDocumentIdentifier (:uri) nil) - (TextDocumentItem (:languageId :text :uri :version) nil) - (TextDocumentSyncOptions nil (:change :openClose :save :willSave :willSaveWaitUntil)) - (TextEdit (:newText :range) nil) - (InsertReplaceEdit (:newText :insert :replace) nil) - (SnippetTextEdit (:newText :range) (:insertTextFormat)) - (TypeDefinitionCapabilities nil (:dynamicRegistration :linkSupport)) - (TypeHierarchyCapabilities nil (:dynamicRegistration)) - (TypeHierarchyItem (:kind :name :range :selectionRange :uri) (:children :data :deprecated :detail :parents)) - (Unregistration (:method :id) nil) - (VersionedTextDocumentIdentifier (:uri) (:version)) - (WorkspaceClientCapabilities nil (:applyEdit :configuration :didChangeConfiguration :didChangeWatchedFiles :executeCommand :symbol :workspaceEdit :workspaceFolders)) - (WorkspaceEdit nil (:changes :documentChanges :resourceChanges)) - (WorkspaceEditCapabilities nil (:documentChanges :failureHandling :resourceChanges :resourceOperations)) - (WorkspaceFolder (:uri :name) nil) - (WorkspaceFoldersChangeEvent (:removed :added) nil) - (WorkspaceFoldersOptions nil (:changeNotifications :supported)) - (WorkspaceServerCapabilities nil (:workspaceFolders :fileOperations)) - (WorkspaceFileOperations nil (:didCreate :willCreate :didRename :willRename :didDelete :willDelete)) - (ApplyWorkspaceEditParams (:edit) (:label)) - (ApplyWorkspaceEditResponse (:applied) nil) - (CallHierarchyIncomingCall (:from :fromRanges) nil) - (CallHierarchyIncomingCallsParams (:item) nil) - (CallHierarchyOutgoingCall (:to :fromRanges) nil) - (CallHierarchyOutgoingCallsParams (:item) nil) - (CallHierarchyPrepareParams (:textDocument :position) (:uri)) - (CodeAction (:title) (:command :diagnostics :edit :isPreferred :kind :data)) - (CodeActionKind nil nil) - (CodeActionParams (:textDocument :context :range) nil) - (CodeLens (:range) (:command :data)) - (CodeLensParams (:textDocument) nil) - (CodeLensRegistrationOptions nil (:documentSelector :resolveProvider)) - (ColorInformation (:color :range) nil) - (ColorPresentation (:label) (:additionalTextEdits :textEdit)) - (ColorPresentationParams (:color :textDocument :range) nil) - (ColoringParams (:uri :infos) nil) - (ColoringStyle nil nil) - (CompletionList (:items :isIncomplete) nil) - (CompletionParams (:textDocument :position) (:context :uri)) - (CompletionRegistrationOptions nil (:documentSelector :resolveProvider :triggerCharacters)) - (ConfigurationParams (:items) nil) - (CreateFile (:kind :uri) (:options)) - (DeclarationParams (:textDocument :position) (:uri)) - (DefinitionParams (:textDocument :position) (:uri)) - (DeleteFile (:kind :uri) (:options)) - (DidChangeConfigurationParams (:settings) nil) - (DidChangeTextDocumentParams (:contentChanges :textDocument) (:uri)) - (DidChangeWatchedFilesParams (:changes) nil) - (DidChangeWatchedFilesRegistrationOptions (:watchers) nil) - (DidChangeWorkspaceFoldersParams (:event) nil) - (DidCloseTextDocumentParams (:textDocument) nil) - (DidOpenTextDocumentParams (:textDocument) (:text)) - (DidSaveTextDocumentParams (:textDocument) (:text)) - (DocumentColorParams (:textDocument) nil) - (DocumentFormattingParams (:textDocument :options) nil) - (DocumentHighlight (:range) (:kind)) - (DocumentHighlightParams (:textDocument :position) (:uri)) - (DocumentLink (:range) (:data :target :tooltip)) - (DocumentLinkParams (:textDocument) nil) - (DocumentLinkRegistrationOptions nil (:documentSelector :resolveProvider)) - (DocumentOnTypeFormattingParams (:ch :textDocument :options :position) nil) - (DocumentOnTypeFormattingRegistrationOptions (:firstTriggerCharacter) (:documentSelector :moreTriggerCharacter)) - (DocumentRangeFormattingParams (:textDocument :options :range) nil) - (DocumentSymbolParams (:textDocument) nil) - (DynamicRegistrationCapabilities nil (:dynamicRegistration)) - (ExecuteCommandParams (:command) (:arguments)) - (ExecuteCommandRegistrationOptions (:commands) nil) - (FailureHandlingKind nil nil) - (FileRename (:oldUri :newUri) nil) - (FoldingRange (:endLine :startLine) (:endCharacter :kind :startCharacter)) - (FoldingRangeKind nil nil) - (FoldingRangeRequestParams (:textDocument) nil) - (Hover (:contents) (:range)) - (HoverParams (:textDocument :position) (:uri)) - (ImplementationParams (:textDocument :position) (:uri)) - (InitializeError (:retry) nil) - (InitializeErrorCode nil nil) - (InitializeParams nil (:capabilities :clientInfo :clientName :initializationOptions :processId :rootPath :rootUri :trace :workspaceFolders)) - (InitializeResult (:capabilities) (:serverInfo)) - (InitializedParams nil nil) - (LocationLink (:targetSelectionRange :targetUri :targetRange) (:originSelectionRange)) - (MarkupKind nil nil) - (MessageParams (:type :message) nil) - (PrepareRenameParams (:textDocument :position) (:uri)) - (PrepareRenameResult (:range :placeholder) nil) - (PublishDiagnosticsParams (:diagnostics :uri) (:version)) - (QuickPickItem (:label :picked :userData) nil) - (ReferenceParams (:textDocument :context :position) (:uri)) - (RegistrationParams (:registrations) nil) - (RenameFile (:kind :newUri :oldUri) (:options)) - (RenameFilesParams (:files) nil) - (RenameParams (:newName :textDocument :position) (:uri)) - (ResolveTypeHierarchyItemParams (:item :resolve :direction) nil) - (ResourceOperationKind nil nil) - (SelectionRangeParams (:textDocument :positions) nil) - (SemanticHighlightingParams (:textDocument :lines) nil) - (ShowDocumentParams (:uri) (:external :takeFocus :selection)) - (ShowDocumentResult (:success) nil) - (ShowInputBoxParams (:prompt) (:value)) - (ShowMessageRequestParams (:type :message) (:actions)) - (ShowQuickPickParams (:placeHolder :canPickMany :items) nil) - (SignatureHelpParams (:textDocument :position) (:context :uri)) - (SignatureHelpRegistrationOptions nil (:documentSelector :triggerCharacters)) - (SymbolInformation (:kind :name :location) (:containerName :deprecated)) - (TextDocumentChangeRegistrationOptions (:syncKind) (:documentSelector)) - (TextDocumentPositionParams (:textDocument :position) (:uri)) - (TextDocumentRegistrationOptions nil (:documentSelector)) - (TextDocumentSaveRegistrationOptions nil (:documentSelector :includeText)) - (TypeDefinitionParams (:textDocument :position) (:uri)) - (TypeHierarchyParams (:resolve :textDocument :position) (:direction :uri)) - (UnregistrationParams (:unregisterations) nil) - (WatchKind nil nil) - (WillSaveTextDocumentParams (:reason :textDocument) nil) - (WorkspaceSymbolParams (:query) nil) - ;; 3.17 - (InlayHint (:label :position) (:kind :paddingLeft :paddingRight)) - (InlayHintLabelPart (:value) (:tooltip :location :command)) - (InlayHintsParams (:textDocument) (:range))) - -;; 3.17 -(defconst lsp/inlay-hint-kind-type-hint 1) -(defconst lsp/inlay-hint-kind-parameter-hint 2) - - -(provide 'lsp-protocol) - -;;; lsp-protocol.el ends here diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-protocol.elc b/emacs/elpa/lsp-mode-20240514.1430/lsp-protocol.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-rust.el b/emacs/elpa/lsp-mode-20240514.1430/lsp-rust.el @@ -1,1770 +0,0 @@ -;;; lsp-rust.el --- Rust Client settings -*- lexical-binding: t; -*- - -;; Copyright (C) 2019 Ivan Yonchovski - -;; Author: Ivan Yonchovski <yyoncho@gmail.com> -;; Keywords: - -;; 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 <https://www.gnu.org/licenses/>. - -;;; Commentary: - -;; lsp-rust client - -;;; Code: - -(require 'lsp-mode) -(require 'ht) -(require 'dash) -(require 'lsp-semantic-tokens) - -(defgroup lsp-rust nil - "LSP support for Rust, using Rust Language Server or rust-analyzer." - :group 'lsp-mode - :link '(url-link "https://github.com/rust-lang/rls") - :package-version '(lsp-mode . "6.1")) - -(defgroup lsp-rust-rls nil - "LSP support for Rust, using Rust Language Server." - :group 'lsp-mode - :link '(url-link "https://github.com/rust-lang/rls") - :package-version '(lsp-mode . "8.0.0")) - -(defgroup lsp-rust-analyzer nil - "LSP support for Rust, using rust-analyzer." - :group 'lsp-mode - :link '(url-link "https://github.com/rust-lang/rust-analyzer") - :package-version '(lsp-mode . "8.0.0")) - -(defgroup lsp-rust-analyzer-semantic-tokens nil - "LSP semantic tokens support for rust-analyzer." - :group 'lsp-rust-analyzer - :link '(url-link "https://github.com/rust-lang/rust-analyzer") - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-server 'rust-analyzer - "Choose LSP server." - :type '(choice (const :tag "rls" rls) - (const :tag "rust-analyzer" rust-analyzer)) - :group 'lsp-rust - :package-version '(lsp-mode . "6.2")) - -;; RLS - -(defcustom lsp-rust-rls-server-command '("rls") - "Command to start RLS." - :type '(repeat string) - :group 'lsp-rust-rls - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-rust-library-directories - '("~/.cargo/registry/src" "~/.rustup/toolchains") - "List of directories which will be considered to be libraries." - :risky t - :type '(repeat string) - :group 'lsp-rust-rls - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-rust-sysroot nil - "If non-nil, use the given path as the sysroot for all rustc invocations -instead of trying to detect the sysroot automatically." - :type '(choice - (const :tag "None" nil) - (string :tag "Sysroot")) - :group 'lsp-rust-rls - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-rust-target nil - "If non-nil, use the given target triple for all rustc invocations." - :type '(choice - (const :tag "None" nil) - (string :tag "Target")) - :group 'lsp-rust-rls - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-rust-rustflags nil - "Flags added to RUSTFLAGS." - :type '(choice - (const :tag "None" nil) - (string :tag "Flags")) - :group 'lsp-rust-rls - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-rust-clear-env-rust-log t - "Clear the RUST_LOG environment variable before running rustc or cargo." - :type 'boolean - :group 'lsp-rust-rls - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-rust-build-lib nil - "If non-nil, checks the project as if you passed the `--lib' argument to -cargo. - -Mutually exclusive with, and preferred over, `lsp-rust-build-bin'. (Unstable)" - :type 'boolean - :group 'lsp-rust-rls - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-rust-build-bin nil - "If non-nil, checks the project as if you passed `-- bin <build_bin>' -argument to cargo. - -Mutually exclusive with `lsp-rust-build-lib'. (Unstable)" - :type '(choice - (const :tag "None" nil) - (string :tag "Binary")) - :group 'lsp-rust-rls - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-rust-cfg-test nil - "If non-nil, checks the project as if you were running `cargo test' rather -than cargo build. - -I.e., compiles (but does not run) test code." - :type 'boolean - :group 'lsp-rust-rls - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-rust-unstable-features nil - "Enable unstable features." - :type 'boolean - :group 'lsp-rust-rls - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-rust-wait-to-build nil - "Time in milliseconds between receiving a change notification -and starting build. If not specified, automatically inferred by -the latest build duration." - :type '(choice - (const :tag "Auto" nil) - (number :tag "Time")) - :group 'lsp-rust-rls - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-rust-show-warnings t - "Show warnings." - :type 'boolean - :group 'lsp-rust-rls - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-rust-crate-blocklist [ - "cocoa" - "gleam" - "glium" - "idna" - "libc" - "openssl" - "rustc_serialize" - "serde" - "serde_json" - "typenum" - "unicode_normalization" - "unicode_segmentation" - "winapi" - ] - "A list of Cargo crates to blocklist." - :type 'lsp-string-vector - :group 'lsp-rust-rls - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-rust-build-on-save nil - "Only index the project when a file is saved and not on change." - :type 'boolean - :group 'lsp-rust-rls - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-rust-features [] - "List of features to activate. -Set this to `\"all\"` to pass `--all-features` to cargo." - :type 'lsp-string-vector - :group 'lsp-rust-rls - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-rust-all-features nil - "Enable all Cargo features." - :type 'boolean - :group 'lsp-rust-rls - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-rust-no-default-features nil - "Do not enable default Cargo features." - :type 'boolean - :group 'lsp-rust-rls - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-rust-racer-completion t - "Enables code completion using racer." - :type 'boolean - :group 'lsp-rust-rls - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-rust-clippy-preference "opt-in" - "Controls eagerness of clippy diagnostics when available. -Valid values are (case-insensitive): - - \"off\": Disable clippy lints. - - \"opt-in\": Clippy lints are shown when crates specify `#![warn(clippy)]'. - - \"on\": Clippy lints enabled for all crates in workspace. - -You need to install clippy via rustup if you haven't already." - :type '(choice - (const "on") - (const "opt-in") - (const "off")) - :group 'lsp-rust-rls - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-rust-jobs nil - "Number of Cargo jobs to be run in parallel." - :type '(choice - (const :tag "Auto" nil) - (number :tag "Jobs")) - :group 'lsp-rust-rls - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-rust-all-targets t - "Checks the project as if you were running cargo check --all-targets. -I.e., check all targets and integration tests too." - :type 'boolean - :group 'lsp-rust-rls - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-rust-target-dir nil - "When specified, it places the generated analysis files at the -specified target directory. By default it is placed target/rls -directory." - :type '(choice - (const :tag "Default" nil) - (string :tag "Directory")) - :group 'lsp-rust-rls - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-rust-rustfmt-path nil - "When specified, RLS will use the Rustfmt pointed at the path -instead of the bundled one" - :type '(choice - (const :tag "Bundled" nil) - (string :tag "Path")) - :group 'lsp-rust-rls - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-rust-build-command nil - "EXPERIMENTAL (requires `rust.unstable_features') -If set, executes a given program responsible for rebuilding save-analysis to be -loaded by the RLS. The program given should output a list of resulting .json -files on stdout. - -Implies `rust.build_on_save': true." - :type '(choice - (const :tag "None" nil) - (string :tag "Command")) - :group 'lsp-rust-rls - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-rust-full-docs nil - "Instructs cargo to enable full documentation extraction during -save-analysis while building the crate." - :type 'boolean - :group 'lsp-rust-rls - :package-version '(lsp-mode . "6.1")) - -(defcustom lsp-rust-show-hover-context t - "Show additional context in hover tooltips when available. This -is often the type local variable declaration." - :type 'boolean - :group 'lsp-rust-rls - :package-version '(lsp-mode . "6.1")) - -(lsp-register-custom-settings - '(("rust.show_hover_context" lsp-rust-show-hover-context t) - ("rust.full_docs" lsp-rust-full-docs t) - ("rust.build_command" lsp-rust-build-command) - ("rust.rustfmt_path" lsp-rust-rustfmt-path) - ("rust.target_dir" lsp-rust-target-dir) - ("rust.all_targets" lsp-rust-all-targets t) - ("rust.jobs" lsp-rust-jobs) - ("rust.clippy_preference" lsp-rust-clippy-preference) - ("rust.racer_completion" lsp-rust-racer-completion t) - ("rust.no_default_features" lsp-rust-no-default-features t) - ("rust.all_features" lsp-rust-all-features t) - ("rust.features" lsp-rust-features) - ("rust.build_on_save" lsp-rust-build-on-save t) - ("rust.crate_blocklist" lsp-rust-crate-blocklist) - ("rust.show_warnings" lsp-rust-show-warnings t) - ("rust.wait_to_build" lsp-rust-wait-to-build) - ("rust.unstable_features" lsp-rust-unstable-features t) - ("rust.cfg_test" lsp-rust-cfg-test t) - ("rust.build_bin" lsp-rust-build-bin) - ("rust.build_lib" lsp-rust-build-lib t) - ("rust.clear_env_rust_log" lsp-rust-clear-env-rust-log t) - ("rust.rustflags" lsp-rust-rustflags) - ("rust.target" lsp-rust-target) - ("rust.sysroot" lsp-rust-sysroot))) - -(defun lsp-clients--rust-window-progress (workspace params) - "Progress report handling. -PARAMS progress report notification data." - (-let [(&v1:ProgressParams :done? :message? :title) params] - (if (or done? (s-blank-str? message?)) - (lsp-workspace-status nil workspace) - (lsp-workspace-status (format "%s - %s" title (or message? "")) workspace)))) - -(lsp-defun lsp-rust--rls-run ((&Command :arguments? params)) - (-let* (((&rls:Cmd :env :binary :args :cwd) (lsp-seq-first params)) - (default-directory (or cwd (lsp-workspace-root) default-directory) )) - (compile - (format "%s %s %s" - (s-join " " (ht-amap (format "%s=%s" key value) env)) - binary - (s-join " " args))))) - -(lsp-register-client - (make-lsp-client :new-connection (lsp-stdio-connection (lambda () lsp-rust-rls-server-command)) - :activation-fn (lsp-activate-on "rust") - :priority (if (eq lsp-rust-server 'rls) 1 -1) - :initialization-options '((omitInitBuild . t) - (cmdRun . t)) - :notification-handlers (ht ("window/progress" 'lsp-clients--rust-window-progress)) - :action-handlers (ht ("rls.run" 'lsp-rust--rls-run)) - :library-folders-fn (lambda (_workspace) lsp-rust-library-directories) - :initialized-fn (lambda (workspace) - (with-lsp-workspace workspace - (lsp--set-configuration - (lsp-configuration-section "rust")))) - :server-id 'rls)) - - -;; rust-analyzer -(defcustom lsp-rust-analyzer-server-command '("rust-analyzer") - "Command to start rust-analyzer." - :type '(repeat string) - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "6.2")) - -(defcustom lsp-rust-analyzer-library-directories - '("~/.cargo/registry/src" "~/.rustup/toolchains") - "List of directories which will be considered to be libraries." - :risky t - :type '(repeat string) - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-server-format-inlay-hints t - "Whether to ask rust-analyzer to format inlay hints itself. If -active, the various inlay format settings are not used." - :type 'boolean - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-hide-closure-initialization nil - "Whether to hide inlay type hints for `let` statements that initialize -to a closure. Only applies to closures with blocks, same as -`#rust-analyzer.inlayHints.closureReturnTypeHints.enable#`." - :type 'boolean - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-highlight-breakpoints t - "Enables highlighting of related references while the cursor is on -`break`, `loop`, `while`, or `for` keywords." - :type 'boolean - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-highlight-closure-captures t - "Enables highlighting of all captures of a closure while the -cursor is on the `|` or move keyword of a closure." - :type 'boolean - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-highlight-exit-points t - "Enables highlighting of all exit points while the cursor is on -any `return`, `?`, `fn`, or return type arrow (`->`)." - :type 'boolean - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-highlight-references t - "Enables highlighting of related references while the cursor is on -any identifier." - :type 'boolean - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-highlight-yield-points t - "Enables highlighting of all break points for a loop or block -context while the cursor is on any `async` or `await` keywords." - :type 'boolean - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-closure-return-type-hints "never" - "Whether to show inlay type hints for return types of closures." - :type '(choice - (const "never") - (const "always") - (const "with_block")) - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-discriminants-hints "never" - "Whether to show enum variant discriminant hints." - :type '(choice - (const "never") - (const "always") - (const "fieldless")) - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-expression-adjustment-hints "never" - "Whether to show inlay hints for type adjustments.." - :type '(choice - (const "never") - (const "always") - (const "reborrow")) - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-expression-adjustment-hints-mode "prefix" - "Whether to show inlay hints as postfix ops (`.*` instead of `*`, etc)." - :type '(choice - (const "prefix") - (const "postfix") - (const "prefer_prefix") - (const "prefer_postfix")) - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-expression-adjustment-hide-unsafe nil - "Whether to hide inlay hints for type adjustments outside of -`unsafe` blocks." - :type 'boolean - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-implicit-drops nil - "Whether to show implicit drop hints." - :type 'boolean - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "9.0.0")) - - -(defcustom lsp-rust-analyzer-closure-capture-hints nil - "Whether to show inlay hints for closure captures." - :type 'boolean - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-closure-style "impl_fn" - "Closure notation in type and chaining inlay hints." - :type 'string - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-hide-named-constructor nil - "Whether to hide inlay type hints for constructors." - :type 'boolean - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-max-inlay-hint-length nil - "Max inlay hint length." - :type 'integer - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "6.2.2")) - -(defcustom lsp-rust-analyzer-display-chaining-hints nil - "Whether to show inlay type hints for method chains. These -hints will be formatted with the type hint formatting options, if -the mode is not configured to ask the server to format them." - :type 'boolean - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "6.2.2")) - -(defcustom lsp-rust-analyzer-display-lifetime-elision-hints-enable "never" - "Whether to show elided lifetime inlay hints." - :type '(choice - (const "never") - (const "always") - (const "skip_trivial")) - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-display-lifetime-elision-hints-use-parameter-names nil - "When showing elided lifetime inlay hints, whether to use -parameter names or numeric placeholder names for the lifetimes." - :type 'boolean - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-display-closure-return-type-hints nil - "Whether to show closure return type inlay hints for closures -with block bodies." - :type 'boolean - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-display-parameter-hints nil - "Whether to show function parameter name inlay hints at the call site." - :type 'boolean - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "6.2.2")) - -(defcustom lsp-rust-analyzer-display-reborrow-hints "never" - "Whether to show inlay type hints for compiler inserted reborrows." - :type '(choice - (const "always") - (const "never") - (const "mutable")) - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-binding-mode-hints nil - "Whether to show inlay type hints for binding modes." - :type 'boolean - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-closing-brace-hints t - "Whether to show inlay hints after a closing `}` to indicate what item it -belongs to." - :type 'boolean - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-closing-brace-hints-min-lines 25 - "Minimum number of lines required before the `}` until the hint is shown -\(set to 0 or 1 to always show them)." - :type 'integer - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-lru-capacity nil - "Number of syntax trees rust-analyzer keeps in memory." - :type 'integer - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "6.2.2")) - -(defcustom lsp-rust-analyzer-cargo-target nil - "Compilation target (target triple)." - :type '(choice - (string :tag "Target") - (const :tag "None" nil)) - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "8.0.0")) - -(defcustom lsp-rust-analyzer-cargo-watch-enable t - "Enable Cargo watch." - :type 'boolean - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "6.2.2")) - -(defcustom lsp-rust-analyzer-cargo-watch-command "check" - "Cargo watch command." - :type 'string - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "6.2.2")) - -(defcustom lsp-rust-analyzer-cargo-watch-args [] - "Extra arguments for `cargo check`." - :type 'lsp-string-vector - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "6.2.2")) - -(defcustom lsp-rust-analyzer-cargo-override-command [] - "Advanced option, fully override the command rust-analyzer uses for checking. -The command should include `--message=format=json` or similar option." - :type 'lsp-string-vector - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "6.2.2")) - -(defcustom lsp-rust-analyzer-check-all-targets t - "Enables --all-targets for `cargo check`." - :type 'boolean - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "8.0.2")) - -(defcustom lsp-rust-analyzer-checkonsave-features [] - "List of features to activate. -Set this to `\"all\"` to pass `--all-features` to cargo." - :type 'lsp-string-vector - :group 'lsp-rust-rust-analyzer - :package-version '(lsp-mode . "8.0.2")) - -(defcustom lsp-rust-analyzer-cargo-unset-test [] - "force rust-analyzer to unset `#[cfg(test)]` for the specified crates." - :type 'lsp-string-vector - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-use-client-watching t - "Use client watching" - :type 'boolean - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "6.2.2")) - -(defcustom lsp-rust-analyzer-exclude-globs [] - "Exclude globs" - :type 'lsp-string-vector - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "6.2.2")) - -(defcustom lsp-rust-analyzer-exclude-dirs [] - "These directories will be ignored by rust-analyzer." - :type 'lsp-string-vector - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "8.0.0")) - -(defcustom lsp-rust-analyzer-macro-expansion-method 'lsp-rust-analyzer-macro-expansion-default - "Use a different function if you want formatted macro expansion results and -syntax highlighting." - :type 'function - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "6.2.2")) - -(defcustom lsp-rust-analyzer-diagnostics-enable t - "Whether to show native rust-analyzer diagnostics." - :type 'boolean - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "6.3.2")) - -(defcustom lsp-rust-analyzer-diagnostics-enable-experimental nil - "Whether to show native rust-analyzer diagnostics that are still experimental -\(might have more false positives than usual)." - :type 'boolean - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "8.0.0")) - -(defcustom lsp-rust-analyzer-diagnostics-disabled [] - "List of native rust-analyzer diagnostics to disable." - :type 'lsp-string-vector - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "8.0.0")) - -(defcustom lsp-rust-analyzer-diagnostics-warnings-as-hint [] - "List of warnings that should be displayed with hint severity." - :type 'lsp-string-vector - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "8.0.0")) - -(defcustom lsp-rust-analyzer-diagnostics-warnings-as-info [] - "List of warnings that should be displayed with info severity." - :type 'lsp-string-vector - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "8.0.0")) - -(define-obsolete-variable-alias - 'lsp-rust-analyzer-cargo-load-out-dirs-from-check - 'lsp-rust-analyzer-cargo-run-build-scripts - "8.0.0") - -(defcustom lsp-rust-analyzer-cargo-run-build-scripts t - "Whether to run build scripts (`build.rs`) for more precise code analysis." - :type 'boolean - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "8.0.0")) - -(defcustom lsp-rust-analyzer-rustfmt-extra-args [] - "Additional arguments to rustfmt." - :type 'lsp-string-vector - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "6.3.2")) - -(defcustom lsp-rust-analyzer-rustfmt-override-command [] - "Advanced option, fully override the command rust-analyzer uses -for formatting." - :type 'lsp-string-vector - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "6.3.2")) - -(defcustom lsp-rust-analyzer-rustfmt-rangeformatting-enable nil - "Enables the use of rustfmt's unstable range formatting command for the -`textDocument/rangeFormatting` request. The rustfmt option is unstable and only -available on a nightly build." - :type 'boolean - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-completion-add-call-parenthesis t - "Whether to add parenthesis when completing functions." - :type 'boolean - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "6.3.2")) - -(defcustom lsp-rust-analyzer-completion-add-call-argument-snippets t - "Whether to add argument snippets when completing functions." - :type 'boolean - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "6.3.2")) - -(defcustom lsp-rust-analyzer-completion-postfix-enable t - "Whether to show postfix snippets like `dbg`, `if`, `not`, etc." - :type 'boolean - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "6.3.2")) - -(defcustom lsp-rust-analyzer-call-info-full t - "Whether to show function name and docs in parameter hints." - :type 'boolean - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "6.3.2")) - -(defcustom lsp-rust-analyzer-proc-macro-enable t - "Enable Proc macro support. -Implies `lsp-rust-analyzer-cargo-run-build-scripts'" - :type 'boolean - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "6.3.2")) - -(defcustom lsp-rust-analyzer-import-prefix "plain" - "The path structure for newly inserted paths to use. -Valid values are: - - \"plain\": Insert import paths relative to the current module, using up to -one `super' prefix if the parent module contains the requested item. - - \"by_self\": Prefix all import paths with `self' if they don't begin with -`self', `super', `crate' or a crate name. - - \"by_crate\": Force import paths to be absolute by always starting -them with `crate' or the crate name they refer to." - :type '(choice - (const "plain") - (const "by_self") - (const "by_crate")) - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "8.0.0")) - -(defcustom lsp-rust-analyzer-import-granularity "crate" - "How imports should be grouped into use statements." - :type '(choice - (const "crate" :doc "Merge imports from the same crate into a single use statement. This kind of nesting is only supported in Rust versions later than 1.24.") - (const "module" :doc "Merge imports from the same module into a single use statement.") - (const "item" :doc "Don’t merge imports at all, creating one import per item.") - (const "preserve" :doc "Do not change the granularity of any imports. For auto-import this has the same effect as `\"item\"'")) - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "8.0.0")) - -(defcustom lsp-rust-analyzer-cargo-auto-reload t - "Automatically refresh project info via `cargo metadata' on `Cargo.toml' changes." - :type 'boolean - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "8.0.0")) - -(defcustom lsp-rust-analyzer-use-rustc-wrapper-for-build-scripts t - "Use `RUSTC_WRAPPER=rust-analyzer' when running build scripts to avoid -compiling unnecessary things." - :type 'boolean - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "8.0.0")) - -(defcustom lsp-rust-analyzer-completion-auto-import-enable t - "Toggles the additional completions that automatically add imports when -completed. `lsp-completion-enable-additional-text-edit' must be non-nil - for this feature to be fully enabled." - :type 'boolean - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "8.0.0")) - -(defcustom lsp-rust-analyzer-completion-auto-self-enable t - "Toggles the additional completions that automatically show method calls -and field accesses with self prefixed to them when inside a method." - :type 'boolean - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "8.0.0")) - -(defcustom lsp-rust-analyzer-import-enforce-granularity nil - "Whether to enforce the import granularity setting for all files. - If set to nil rust-analyzer will try to keep import styles consistent per file." - :type 'boolean - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "8.0.0")) - -(defcustom lsp-rust-analyzer-imports-merge-glob t - "Whether to allow import insertion to merge new imports into single path -glob imports like `use std::fmt::*;`." - :type 'boolean - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-import-group t - "Group inserted imports by the following order: -https://rust-analyzer.github.io/manual.html#auto-import. - Groups are separated by newlines." - :type 'boolean - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "8.0.0")) - -(defcustom lsp-rust-analyzer-highlighting-strings t - "Use semantic tokens for strings." - :type 'boolean - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "8.0.0")) - -(defcustom lsp-rust-analyzer-rustc-source nil - "Path to the Cargo.toml of the rust compiler workspace." - :type '(choice - (file :tag "Path") - (const :tag "None" nil)) - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "8.0.0")) - -(defcustom lsp-rust-analyzer-linked-projects [] - "Disable project auto-discovery in favor of explicitly specified set of -projects. Elements must be paths pointing to `Cargo.toml`, `rust-project.json`, -or JSON objects in `rust-project.json` format." - :type 'lsp-string-vector - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-experimental-proc-attr-macros t - "Whether to enable experimental support for expanding proc macro attributes." - :type 'boolean - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "8.0.0")) - -(defcustom lsp-rust-analyzer-cargo-extra-args [] - "Extra arguments that are passed to every cargo invocation." - :type 'lsp-string-vector - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-cargo-extra-env [] - "Extra environment variables that will be set when running cargo, rustc or -other commands within the workspace. Useful for setting RUSTFLAGS." - :type 'lsp-string-vector - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "9.0.0")) - -(defconst lsp-rust-notification-handlers - '(("rust-analyzer/publishDecorations" . (lambda (_w _p))))) - -(defconst lsp-rust-action-handlers - '()) - -(define-derived-mode lsp-rust-analyzer-syntax-tree-mode special-mode "Rust-Analyzer-Syntax-Tree" - "Mode for the rust-analyzer syntax tree buffer.") - -(defun lsp-rust-analyzer-syntax-tree () - "Display syntax tree for current buffer." - (interactive) - (-let* ((root (lsp-workspace-root default-directory)) - (params (lsp-make-rust-analyzer-syntax-tree-params - :text-document (lsp--text-document-identifier) - :range? (if (use-region-p) - (lsp--region-to-range (region-beginning) (region-end)) - (lsp--region-to-range (point-min) (point-max))))) - (results (lsp-send-request (lsp-make-request - "rust-analyzer/syntaxTree" - params)))) - (let ((buf (get-buffer-create (format "*rust-analyzer syntax tree %s*" root))) - (inhibit-read-only t)) - (with-current-buffer buf - (lsp-rust-analyzer-syntax-tree-mode) - (erase-buffer) - (insert results) - (goto-char (point-min))) - (pop-to-buffer buf)))) - -(define-derived-mode lsp-rust-analyzer-status-mode special-mode "Rust-Analyzer-Status" - "Mode for the rust-analyzer status buffer.") - -(defun lsp-rust-analyzer-status () - "Displays status information for rust-analyzer." - (interactive) - (-let* ((root (lsp-workspace-root default-directory)) - (params (lsp-make-rust-analyzer-analyzer-status-params - :text-document (lsp--text-document-identifier))) - (results (lsp-send-request (lsp-make-request - "rust-analyzer/analyzerStatus" - params)))) - (let ((buf (get-buffer-create (format "*rust-analyzer status %s*" root))) - (inhibit-read-only t)) - (with-current-buffer buf - (lsp-rust-analyzer-status-mode) - (erase-buffer) - (insert results) - (pop-to-buffer buf))))) - -(defun lsp-rust-analyzer-view-item-tree () - "Show item tree of rust file." - (interactive) - (-let* ((params (lsp-make-rust-analyzer-view-item-tree - :text-document (lsp--text-document-identifier))) - (results (lsp-send-request (lsp-make-request - "rust-analyzer/viewItemTree" - params)))) - (let ((buf (get-buffer-create "*rust-analyzer item tree*")) - (inhibit-read-only t)) - (with-current-buffer buf - (special-mode) - (erase-buffer) - (insert (lsp--render-string results "rust")) - (pop-to-buffer buf))))) - -(defun lsp-rust-analyzer-view-hir () - "View Hir of function at point." - (interactive) - (-let* ((params (lsp-make-rust-analyzer-expand-macro-params - :text-document (lsp--text-document-identifier) - :position (lsp--cur-position))) - (results (lsp-send-request (lsp-make-request - "rust-analyzer/viewHir" - params)))) - (let ((buf (get-buffer-create "*rust-analyzer hir*")) - (inhibit-read-only t)) - (with-current-buffer buf - (special-mode) - (erase-buffer) - (insert results) - (pop-to-buffer buf))))) - -(defun lsp-rust-analyzer-join-lines () - "Join selected lines into one, smartly fixing up whitespace and trailing commas." - (interactive) - (let* ((params (lsp-make-rust-analyzer-join-lines-params - :text-document (lsp--text-document-identifier) - :ranges (vector (if (use-region-p) - (lsp--region-to-range (region-beginning) (region-end)) - (lsp--region-to-range (point) (point)))))) - (result (lsp-send-request (lsp-make-request "experimental/joinLines" params)))) - (lsp--apply-text-edits result 'code-action))) - -(defun lsp-rust-analyzer-reload-workspace () - "Reload workspace, picking up changes from Cargo.toml" - (interactive) - (lsp--cur-workspace-check) - (lsp-send-request (lsp-make-request "rust-analyzer/reloadWorkspace"))) - -(defcustom lsp-rust-analyzer-download-url - (let* ((x86 (string-prefix-p "x86_64" system-configuration)) - (arch (if x86 "x86_64" "aarch64"))) - (format "https://github.com/rust-lang/rust-analyzer/releases/latest/download/%s" - (pcase system-type - ('gnu/linux (format "rust-analyzer-%s-unknown-linux-gnu.gz" arch)) - ('darwin (format "rust-analyzer-%s-apple-darwin.gz" arch)) - ('windows-nt (format "rust-analyzer-%s-pc-windows-msvc.zip" arch))))) - "Automatic download url for Rust Analyzer" - :type 'string - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "8.0.0")) - -(defcustom lsp-rust-analyzer-store-path (f-join lsp-server-install-dir "rust" - (pcase system-type - ('windows-nt "rust-analyzer.exe") - (_ "rust-analyzer"))) - "The path to the file in which `rust-analyzer' will be stored." - :type 'file - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "8.0.0")) - -(lsp-dependency - 'rust-analyzer - `(:download :url lsp-rust-analyzer-download-url - :decompress ,(pcase system-type ('windows-nt :zip) (_ :gzip)) - :store-path lsp-rust-analyzer-store-path - :set-executable? t) - `(:system ,(file-name-nondirectory lsp-rust-analyzer-store-path))) - -(lsp-defun lsp-rust--analyzer-run-single ((&Command :arguments?)) - (lsp-rust-analyzer-run (lsp-seq-first arguments?))) - -(lsp-defun lsp-rust--analyzer-show-references - ((&Command :title :arguments? [_uri _filepos references])) - (lsp-show-xrefs (lsp--locations-to-xref-items references) nil - (s-contains-p "reference" title))) - -(declare-function dap-debug "ext:dap-mode" (template) t) - -(lsp-defun lsp-rust--analyzer-debug-lens ((&Command :arguments? [args])) - (lsp-rust-analyzer-debug args)) - -;; Semantic tokens - -;; Modifier faces -(defface lsp-rust-analyzer-documentation-modifier-face - '((t nil)) - "The face modification to use for documentation items." - :group 'lsp-rust-analyzer-semantic-tokens) - -(defface lsp-rust-analyzer-declaration-modifier-face - '((t nil)) - "The face modification to use for declaration items." - :group 'lsp-rust-analyzer-semantic-tokens) - -(defface lsp-rust-analyzer-definition-modifier-face - '((t nil)) - "The face modification to use for definition items." - :group 'lsp-rust-analyzer-semantic-tokens) - -(defface lsp-rust-analyzer-static-modifier-face - '((t nil)) - "The face modification to use for static items." - :group 'lsp-rust-analyzer-semantic-tokens) - -(defface lsp-rust-analyzer-abstract-modifier-face - '((t nil)) - "The face modification to use for abstract items." - :group 'lsp-rust-analyzer-semantic-tokens) - -(defface lsp-rust-analyzer-deprecated-modifier-face - '((t nil)) - "The face modification to use for deprecated items." - :group 'lsp-rust-analyzer-semantic-tokens) - -(defface lsp-rust-analyzer-readonly-modifier-face - '((t nil)) - "The face modification to use for readonly items." - :group 'lsp-rust-analyzer-semantic-tokens) - -(defface lsp-rust-analyzer-default-library-modifier-face - '((t nil)) - "The face modification to use for default-library items." - :group 'lsp-rust-analyzer-semantic-tokens) - -(defface lsp-rust-analyzer-async-modifier-face - '((t nil)) - "The face modification to use for async items." - :group 'lsp-rust-analyzer-semantic-tokens) - -(defface lsp-rust-analyzer-attribute-modifier-face - '((t nil)) - "The face modification to use for attribute items." - :group 'lsp-rust-analyzer-semantic-tokens) - -(defface lsp-rust-analyzer-callable-modifier-face - '((t nil)) - "The face modification to use for callable items." - :group 'lsp-rust-analyzer-semantic-tokens) - -(defface lsp-rust-analyzer-constant-modifier-face - '((t nil)) - "The face modification to use for constant items." - :group 'lsp-rust-analyzer-semantic-tokens) - -(defface lsp-rust-analyzer-consuming-modifier-face - '((t nil)) - "The face modification to use for consuming items." - :group 'lsp-rust-analyzer-semantic-tokens) - -(defface lsp-rust-analyzer-control-flow-modifier-face - '((t nil)) - "The face modification to use for control-flow items." - :group 'lsp-rust-analyzer-semantic-tokens) - -(defface lsp-rust-analyzer-crate-root-modifier-face - '((t nil)) - "The face modification to use for crate-root items." - :group 'lsp-rust-analyzer-semantic-tokens) - -(defface lsp-rust-analyzer-injected-modifier-face - '((t nil)) - "The face modification to use for injected items." - :group 'lsp-rust-analyzer-semantic-tokens) - -(defface lsp-rust-analyzer-intra-doc-link-modifier-face - '((t nil)) - "The face modification to use for intra-doc-link items." - :group 'lsp-rust-analyzer-semantic-tokens) - -(defface lsp-rust-analyzer-library-modifier-face - '((t nil)) - "The face modification to use for library items." - :group 'lsp-rust-analyzer-semantic-tokens) - -(defface lsp-rust-analyzer-mutable-modifier-face - '((t :underline t)) - "The face modification to use for mutable items." - :group 'lsp-rust-analyzer-semantic-tokens) - -(defface lsp-rust-analyzer-public-modifier-face - '((t nil)) - "The face modification to use for public items." - :group 'lsp-rust-analyzer-semantic-tokens) - -(defface lsp-rust-analyzer-reference-modifier-face - '((t :bold t)) - "The face modification to use for reference items." - :group 'lsp-rust-analyzer-semantic-tokens) - -(defface lsp-rust-analyzer-trait-modifier-face - '((t nil)) - "The face modification to use for trait items." - :group 'lsp-rust-analyzer-semantic-tokens) - -(defface lsp-rust-analyzer-unsafe-modifier-face - '((t nil)) - "The face modification to use for unsafe items." - :group 'lsp-rust-analyzer-semantic-tokens) - - -;; --------------------------------------------------------------------- -;; Semantic token modifier face customization - -(defcustom lsp-rust-analyzer-documentation-modifier 'lsp-rust-analyzer-documentation-modifier-face - "Face for semantic token modifier for `documentation' attribute." - :type 'face - :group 'lsp-rust-analyzer-semantic-tokens - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-declaration-modifier 'lsp-rust-analyzer-declaration-modifier-face - "Face for semantic token modifier for `declaration' attribute." - :type 'face - :group 'lsp-rust-analyzer-semantic-tokens - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-definition-modifier 'lsp-rust-analyzer-definition-modifier-face - "Face for semantic token modifier for `definition' attribute." - :type 'face - :group 'lsp-rust-analyzer-semantic-tokens - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-static-modifier 'lsp-rust-analyzer-static-modifier-face - "Face for semantic token modifier for `static' attribute." - :type 'face - :group 'lsp-rust-analyzer-semantic-tokens - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-abstract-modifier 'lsp-rust-analyzer-abstract-modifier-face - "Face for semantic token modifier for `abstract' attribute." - :type 'face - :group 'lsp-rust-analyzer-semantic-tokens - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-deprecated-modifier 'lsp-rust-analyzer-deprecated-modifier-face - "Face for semantic token modifier for `deprecated' attribute." - :type 'face - :group 'lsp-rust-analyzer-semantic-tokens - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-readonly-modifier 'lsp-rust-analyzer-readonly-modifier-face - "Face for semantic token modifier for `readonly' attribute." - :type 'face - :group 'lsp-rust-analyzer-semantic-tokens - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-default-library-modifier 'lsp-rust-analyzer-default-library-modifier-face - "Face for semantic token modifier for `default' attribute." - :type 'face - :group 'lsp-rust-analyzer-semantic-tokens - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-async-modifier 'lsp-rust-analyzer-async-modifier-face - "Face for semantic token modifier for `async' attribute." - :type 'face - :group 'lsp-rust-analyzer-semantic-tokens - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-attribute-modifier 'lsp-rust-analyzer-attribute-modifier-face - "Face for semantic token modifier for `attribute' attribute." - :type 'face - :group 'lsp-rust-analyzer-semantic-tokens - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-callable-modifier 'lsp-rust-analyzer-callable-modifier-face - "Face for semantic token modifier for `callable' attribute." - :type 'face - :group 'lsp-rust-analyzer-semantic-tokens - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-constant-modifier 'lsp-rust-analyzer-constant-modifier-face - "Face for semantic token modifier for `constant' attribute." - :type 'face - :group 'lsp-rust-analyzer-semantic-tokens - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-consuming-modifier 'lsp-rust-analyzer-consuming-modifier-face - "Face for semantic token modifier for `consuming' attribute." - :type 'face - :group 'lsp-rust-analyzer-semantic-tokens - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-control-flow-modifier 'lsp-rust-analyzer-control-flow-modifier-face - "Face for semantic token modifier for `control_flow' attribute." - :type 'face - :group 'lsp-rust-analyzer-semantic-tokens - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-crate-root-modifier 'lsp-rust-analyzer-crate-root-modifier-face - "Face for semantic token modifier for `crate_root' attribute." - :type 'face - :group 'lsp-rust-analyzer-semantic-tokens - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-injected-modifier 'lsp-rust-analyzer-injected-modifier-face - "Face for semantic token modifier for `injected' attribute." - :type 'face - :group 'lsp-rust-analyzer-semantic-tokens - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-intra-doc-link-modifier 'lsp-rust-analyzer-intra-doc-link-modifier-face - "Face for semantic token modifier for `intra_doc_link' attribute." - :type 'face - :group 'lsp-rust-analyzer-semantic-tokens - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-library-modifier 'lsp-rust-analyzer-library-modifier-face - "Face for semantic token modifier for `library' attribute." - :type 'face - :group 'lsp-rust-analyzer-semantic-tokens - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-mutable-modifier 'lsp-rust-analyzer-mutable-modifier-face - "Face for semantic token modifier for `mutable' attribute." - :type 'face - :group 'lsp-rust-analyzer-semantic-tokens - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-public-modifier 'lsp-rust-analyzer-public-modifier-face - "Face for semantic token modifier for `public' attribute." - :type 'face - :group 'lsp-rust-analyzer-semantic-tokens - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-reference-modifier 'lsp-rust-analyzer-reference-modifier-face - "Face for semantic token modifier for `reference' attribute." - :type 'face - :group 'lsp-rust-analyzer-semantic-tokens - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-trait-modifier 'lsp-rust-analyzer-trait-modifier-face - "Face for semantic token modifier for `trait' attribute." - :type 'face - :group 'lsp-rust-analyzer-semantic-tokens - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-unsafe-modifier 'lsp-rust-analyzer-unsafe-modifier-face - "Face for semantic token modifier for `unsafe' attribute." - :type 'face - :group 'lsp-rust-analyzer-semantic-tokens - :package-version '(lsp-mode . "9.0.0")) - -;; --------------------------------------------------------------------- - -(defun lsp-rust-analyzer--semantic-modifiers () - "Mapping between rust-analyzer keywords and fonts to apply. -The keywords are sent in the initialize response, in the semantic -tokens legend." - `(("documentation" . ,lsp-rust-analyzer-documentation-modifier) - ("declaration" . ,lsp-rust-analyzer-declaration-modifier) - ("definition" . ,lsp-rust-analyzer-definition-modifier) - ("static" . ,lsp-rust-analyzer-static-modifier) - ("abstract" . ,lsp-rust-analyzer-abstract-modifier) - ("deprecated" . ,lsp-rust-analyzer-deprecated-modifier) - ("readonly" . ,lsp-rust-analyzer-readonly-modifier) - ("default_library" . ,lsp-rust-analyzer-default-library-modifier) - ("async" . ,lsp-rust-analyzer-async-modifier) - ("attribute" . ,lsp-rust-analyzer-attribute-modifier) - ("callable" . ,lsp-rust-analyzer-callable-modifier) - ("constant" . ,lsp-rust-analyzer-constant-modifier) - ("consuming" . ,lsp-rust-analyzer-consuming-modifier) - ("control_flow" . ,lsp-rust-analyzer-control-flow-modifier) - ("crate_root" . ,lsp-rust-analyzer-crate-root-modifier) - ("injected" . ,lsp-rust-analyzer-injected-modifier) - ("intra_doc_link" . ,lsp-rust-analyzer-intra-doc-link-modifier) - ("library" . ,lsp-rust-analyzer-library-modifier) - ("mutable" . ,lsp-rust-analyzer-mutable-modifier) - ("public" . ,lsp-rust-analyzer-public-modifier) - ("reference" . ,lsp-rust-analyzer-reference-modifier) - ("trait" . ,lsp-rust-analyzer-trait-modifier) - ("unsafe" . ,lsp-rust-analyzer-unsafe-modifier))) - -(defun lsp-rust-switch-server (&optional lsp-server) - "Switch priorities of lsp servers, unless LSP-SERVER is already active." - (interactive) - (let ((current-server (if (> (lsp--client-priority (gethash 'rls lsp-clients)) 0) - 'rls - 'rust-analyzer))) - (unless (eq lsp-server current-server) - (dolist (server '(rls rust-analyzer)) - (when (natnump (setf (lsp--client-priority (gethash server lsp-clients)) - (* (lsp--client-priority (gethash server lsp-clients)) -1))) - (message (format "Switched to server %s." server))))))) - -;; -;;; Inlay hints - -(defcustom lsp-rust-analyzer-debug-lens-extra-dap-args - '(:MIMode "gdb" :miDebuggerPath "gdb" :stopAtEntry t :externalConsole :json-false) - "Extra arguments to pass to DAP template when debugging a test from code lens. - -As a rule of the thumb, do not add extra keys to this plist unless you exactly -what you are doing, it might break the \"Debug test\" lens otherwise. - -See dap-mode documentation and cpptools documentation for the extra variables -meaning." - :type 'plist - :group 'lsp-rust-analyzer - :package-version '(lsp-mode . "8.0.0")) - -;; -;;; Lenses - -(defgroup lsp-rust-analyzer-lens nil - "LSP lens support for Rust when using rust-analyzer. - -Lenses are (depending on your configuration) clickable links to -the right of function definitions and the like. These display -some useful information in their own right and/or perform a -shortcut action when clicked such as displaying uses of that -function or running an individual test. -" - :prefix "lsp-rust-analyzer-lens-" - :group 'lsp-rust-analyzer - :link '(url-link "https://emacs-lsp.github.io/lsp-mode/") - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-lens-debug-enable t - "Enable or disable the Debug lens." - :type 'boolean - :group 'lsp-rust-analyzer-lens - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-lens-enable t - "Master-enable of lenses in Rust files." - :type 'boolean - :group 'lsp-rust-analyzer-lens - :package-version '(lsp-mode . "9.0.0")) - -;; This customisation "works" in that it works as described, but the default is fine and changing it -;; from the default will either stop lenses working or do nothing. -;; -;; If this is ever uncommented to re-enable the option, don't forget to also uncomment it in defun -;; lsp-rust-analyzer--make-init-options too or it'll not do anything. - -;; (defcustom lsp-rust-analyzer-lens-force-custom-commands t -;; "Internal config: use custom client-side commands even when the -;; client doesn't set the corresponding capability." -;; :type 'boolean -;; :group 'lsp-rust-analyzer-lens -;; :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-lens-implementations-enable t - "Enable or disable the Implementations lens. - -The Implementations lens shows `NN implementations' to the right -of the first line of an enum, struct, or union declaration. This -is the count of impl blocks, including derived traits. Clicking -on it gives a list of the impls of that type. -" - :type 'boolean - :group 'lsp-rust-analyzer-lens - :package-version '(lsp-mode . "9.0.0")) - -;; The valid range of values for this is documented in the rust-lang/rust-analyzer repository at the -;; path "editors/code/package.json"; the TL:DR is that it's "above_name" or "above_whole_item". -;; However, setting it to "above_whole_item" causes lenses to disappear in Emacs. I suspect this -;; feature has only ever been tested in some other IDE and it's broken in Emacs. So I've disabled it -;; for now. -;; -;; If this is ever uncommented to re-enable the option, don't forget to also uncomment it in defun -;; lsp-rust-analyzer--make-init-options too or it'll not do anything. - -;; (defcustom lsp-rust-analyzer-lens-location "above_name" -;; "Where to render annotations." -;; :type '(choice -;; (const :tag "Above name" "above_name") -;; (const :tag "Above whole item" "above_whole_item") -;; :group 'lsp-rust-analyzer-lens -;; :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-lens-references-adt-enable nil - "Enable or disable the References lens on enums, structs, and traits. - -The References lens shows `NN references` to the right of the -first line of each enum, struct, or union declaration. This is -the count of uses of that type. Clicking on it gives a list of -where that type is used." - :type 'boolean - :group 'lsp-rust-analyzer-lens - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-lens-references-enum-variant-enable nil - "Enable or disable the References lens on enum variants. - -The References lens shows `NN references` to the right of the -first (or only) line of each enum variant. This is the count of -uses of that enum variant. Clicking on it gives a list of where -that enum variant is used." - :type 'boolean - :group 'lsp-rust-analyzer-lens - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-lens-references-method-enable nil - "Enable or disable the References lens on functions. - -The References lens shows `NN references` to the right of the -first line of each function declaration. This is the count of -uses of that function. Clicking on it gives a list of where that -function is used." - - :type 'boolean - :group 'lsp-rust-analyzer-lens - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-lens-references-trait-enable nil - "Enable or disable the References lens on traits. - -The References lens shows `NN references` to the right of the -first line of each trait declaration. This is a count of uses of -that trait. Clicking on it gives a list of where that trait is -used. - -There is some overlap with the Implementations lens which slows -all of the trait's impl blocks, but this also shows other uses -such as imports and dyn traits." - :type 'boolean - :group 'lsp-rust-analyzer-lens - :package-version '(lsp-mode . "9.0.0")) - -(defcustom lsp-rust-analyzer-lens-run-enable t - "Enable or disable the Run lens." - :type 'boolean - :group 'lsp-rust-analyzer-lens - :package-version '(lsp-mode . "9.0.0")) - -(defun lsp-rust-analyzer-initialized? () - (when-let ((workspace (lsp-find-workspace 'rust-analyzer (buffer-file-name)))) - (eq 'initialized (lsp--workspace-status workspace)))) - -(defun lsp-rust-analyzer-expand-macro () - "Expands the macro call at point recursively." - (interactive) - (-if-let* ((params (lsp-make-rust-analyzer-expand-macro-params - :text-document (lsp--text-document-identifier) - :position (lsp--cur-position))) - (response (lsp-request - "rust-analyzer/expandMacro" - params)) - ((&rust-analyzer:ExpandedMacro :expansion) response)) - (funcall lsp-rust-analyzer-macro-expansion-method expansion) - (lsp--error "No macro found at point, or it could not be expanded."))) - -(defun lsp-rust-analyzer-macro-expansion-default (result) - "Default method for displaying macro expansion." - (let* ((root (lsp-workspace-root default-directory)) - (buf (get-buffer-create (get-buffer-create (format "*rust-analyzer macro expansion %s*" root))))) - (with-current-buffer buf - (let ((inhibit-read-only t)) - (erase-buffer) - (insert (lsp--render-string result "rust")) - (special-mode))) - (pop-to-buffer buf))) - -;; -;;; Runnables - -(defvar lsp-rust-analyzer--last-runnable nil - "Record the last runnable.") - -(defun lsp-rust-analyzer--runnables () - "Return list of runnables." - (lsp-send-request (lsp-make-request - "experimental/runnables" - (lsp-make-rust-analyzer-runnables-params - :text-document (lsp--text-document-identifier) - :position? (lsp--cur-position))))) - -(defun lsp-rust-analyzer--select-runnable () - "Select runnable." - (lsp--completing-read - "Select runnable:" - (if lsp-rust-analyzer--last-runnable - (cons lsp-rust-analyzer--last-runnable - (-remove (-lambda ((&rust-analyzer:Runnable :label)) - (equal label (lsp-get lsp-rust-analyzer--last-runnable :label))) - (lsp-rust-analyzer--runnables))) - (lsp-rust-analyzer--runnables)) - (-lambda ((&rust-analyzer:Runnable :label)) label))) - -(defun lsp-rust-analyzer--common-runner (runnable) - "Execute a given RUNNABLE. - -Extract the arguments, prepare the minor mode (cargo-process-mode if possible) -and run a compilation" - (-let* (((&rust-analyzer:Runnable :kind :label :args) runnable) - ((&rust-analyzer:RunnableArgs :cargo-args :executable-args :workspace-root? :expect-test?) args) - (default-directory (or workspace-root? default-directory))) - (if (not (string-equal kind "cargo")) - (lsp--error "'%s' runnable is not supported" kind) - (compilation-start - (string-join (append (when expect-test? '("env" "UPDATE_EXPECT=1")) - (list "cargo") cargo-args - (when executable-args '("--")) executable-args '()) " ") - - ;; cargo-process-mode is nice, but try to work without it... - (if (functionp 'cargo-process-mode) 'cargo-process-mode nil) - (lambda (_) (concat "*" label "*")))))) - -(defun lsp-rust-analyzer-run (runnable) - "Select and run a RUNNABLE action." - (interactive (list (lsp-rust-analyzer--select-runnable))) - (when (lsp-rust-analyzer--common-runner runnable) - (setq lsp-rust-analyzer--last-runnable runnable))) - -(defun lsp-rust-analyzer-debug (runnable) - "Select and debug a RUNNABLE action." - (interactive (list (lsp-rust-analyzer--select-runnable))) - (unless (or (featurep 'dap-cpptools) (featurep 'dap-gdb)) - (user-error "You must require `dap-cpptools' or 'dap-gdb'")) - (-let (((&rust-analyzer:Runnable - :args (&rust-analyzer:RunnableArgs :cargo-args :workspace-root? :executable-args) - :label) runnable)) - (pcase (aref cargo-args 0) - ("run" (aset cargo-args 0 "build")) - ("test" (when (-contains? (append cargo-args ()) "--no-run") - (cl-callf append cargo-args (list "--no-run"))))) - (->> (append (list (executable-find "cargo")) - cargo-args - (list "--message-format=json")) - (s-join " ") - (shell-command-to-string) - (s-lines) - (-keep (lambda (s) - (condition-case nil - (-let* ((json-object-type 'plist) - ((msg &as &plist :reason :executable) (json-read-from-string s))) - (when (and executable (string= "compiler-artifact" reason)) - executable)) - (error)))) - (funcall - (lambda (artifact-spec) - (pcase artifact-spec - (`() (user-error "No compilation artifacts or obtaining the runnable artifacts failed")) - (`(,spec) spec) - (_ (user-error "Multiple compilation artifacts are not supported"))))) - (list :type (if (featurep 'dap-gdb) "gdb" "cppdbg") - :request "launch" - :name label - :args executable-args - :cwd workspace-root? - :sourceLanguages ["rust"] - :program) - (append lsp-rust-analyzer-debug-lens-extra-dap-args) - (dap-debug)))) - -(defun lsp-rust-analyzer-rerun (&optional runnable) - (interactive (list (or lsp-rust-analyzer--last-runnable - (lsp-rust-analyzer--select-runnable)))) - (lsp-rust-analyzer-run (or runnable lsp-rust-analyzer--last-runnable))) - -;; goto parent module -(cl-defun lsp-rust-find-parent-module (&key display-action) - "Find parent module of current module." - (interactive) - (lsp-find-locations "experimental/parentModule" nil :display-action display-action)) - -(defun lsp-rust-analyzer-open-cargo-toml (&optional new-window) - "Open the closest Cargo.toml from the current file. - -Rust-Analyzer LSP protocol documented here and added in November 2020 -https://github.com/rust-lang/rust-analyzer/blob/master/docs/dev/lsp-extensions.md#open-cargotoml - -If NEW-WINDOW (interactively the prefix argument) is non-nil, -open in a new window." - (interactive "P") - (-if-let (workspace (lsp-find-workspace 'rust-analyzer (buffer-file-name))) - (-if-let* ((response (with-lsp-workspace workspace - (lsp-send-request (lsp-make-request - "experimental/openCargoToml" - (lsp-make-rust-analyzer-open-cargo-toml-params - :text-document (lsp--text-document-identifier)))))) - ((&Location :uri :range) response)) - (funcall (if new-window #'find-file-other-window #'find-file) - (lsp--uri-to-path uri)) - (lsp--warn "Couldn't find a Cargo.toml file or your version of rust-analyzer doesn't support this extension")) - (lsp--error "OpenCargoToml is an extension available only with rust-analyzer"))) - -(defun lsp-rust-analyzer-open-external-docs () - "Open a URL for documentation related to the current TextDocumentPosition. - -Rust-Analyzer LSP protocol documented here -https://github.com/rust-lang/rust-analyzer/blob/master/docs/dev/lsp-extensions.md#open-external-documentation" - (interactive) - (-if-let* ((params (lsp-make-rust-analyzer-open-external-docs-params - :text-document (lsp--text-document-identifier) - :position (lsp--cur-position))) - (url (lsp-request "experimental/externalDocs" params))) - (browse-url url) - (lsp--warn "Couldn't find documentation URL or your version of rust-analyzer doesn't support this extension"))) - -(defun lsp-rust-analyzer--related-tests () - "Get runnable test items related to the current TextDocumentPosition. -Calls a rust-analyzer LSP extension endpoint that returns a wrapper over -Runnable[]." - (lsp-send-request (lsp-make-request - "rust-analyzer/relatedTests" - (lsp--text-document-position-params)))) - -(defun lsp-rust-analyzer--select-related-test () - "Call the endpoint and ask for user selection. - -Cannot reuse `lsp-rust-analyzer--select-runnable' because the runnables endpoint -responds with Runnable[], while relatedTests responds with TestInfo[], -which is a wrapper over runnable. Also, this method doesn't set -the `lsp-rust-analyzer--last-runnable' variable." - (-if-let* ((resp (lsp-rust-analyzer--related-tests)) - (runnables (seq-map - #'lsp:rust-analyzer-related-tests-runnable - resp))) - (lsp--completing-read - "Select test: " - runnables - #'lsp:rust-analyzer-runnable-label))) - -(defun lsp-rust-analyzer-related-tests (runnable) - "Execute a RUNNABLE test related to the current document position. - -Rust-Analyzer LSP protocol extension -https://github.com/rust-lang/rust-analyzer/blob/master/docs/dev/lsp-extensions.md#related-tests" - (interactive (list (lsp-rust-analyzer--select-related-test))) - (if runnable - (lsp-rust-analyzer--common-runner runnable) - (lsp--info "There are no tests related to the symbol at point"))) - -(defun lsp-rust-analyzer-move-item (direction) - "Move item under cursor or selection in some DIRECTION" - (let* ((params (lsp-make-rust-analyzer-move-item-params - :text-document (lsp--text-document-identifier) - :range (if (use-region-p) - (lsp--region-to-range (region-beginning) (region-end)) - (lsp--region-to-range (point) (point))) - :direction direction)) - (edits (lsp-request "experimental/moveItem" params))) - (lsp--apply-text-edits edits 'code-action))) - -(defun lsp-rust-analyzer-move-item-up () - "Move item under cursor or selection up" - (interactive) - (lsp-rust-analyzer-move-item "Up")) - -(defun lsp-rust-analyzer-move-item-down () - "Move item under cursor or selection down" - (interactive) - (lsp-rust-analyzer-move-item "Down")) - -(defun lsp-rust-analyzer--make-init-options () - "Init options for rust-analyzer" - `(:diagnostics - ( :enable ,(lsp-json-bool lsp-rust-analyzer-diagnostics-enable) - :enableExperimental ,(lsp-json-bool lsp-rust-analyzer-diagnostics-enable-experimental) - :disabled ,lsp-rust-analyzer-diagnostics-disabled - :warningsAsHint ,lsp-rust-analyzer-diagnostics-warnings-as-hint - :warningsAsInfo ,lsp-rust-analyzer-diagnostics-warnings-as-info) - :imports ( :granularity ( :enforce ,(lsp-json-bool lsp-rust-analyzer-import-enforce-granularity) - :group ,lsp-rust-analyzer-import-granularity) - :group ,(lsp-json-bool lsp-rust-analyzer-import-group) - :merge (:glob ,(lsp-json-bool lsp-rust-analyzer-imports-merge-glob)) - :prefix ,lsp-rust-analyzer-import-prefix) - :lruCapacity ,lsp-rust-analyzer-lru-capacity - :checkOnSave ( :enable ,(lsp-json-bool lsp-rust-analyzer-cargo-watch-enable) - :command ,lsp-rust-analyzer-cargo-watch-command - :extraArgs ,lsp-rust-analyzer-cargo-watch-args - :allTargets ,(lsp-json-bool lsp-rust-analyzer-check-all-targets) - :features ,lsp-rust-analyzer-checkonsave-features - :overrideCommand ,lsp-rust-analyzer-cargo-override-command) - :highlightRelated ( :breakPoints (:enable ,(lsp-json-bool lsp-rust-analyzer-highlight-breakpoints)) - :closureCaptures (:enable ,(lsp-json-bool lsp-rust-analyzer-highlight-closure-captures)) - :exitPoints (:enable ,(lsp-json-bool lsp-rust-analyzer-highlight-exit-points)) - :references (:enable ,(lsp-json-bool lsp-rust-analyzer-highlight-references)) - :yieldPoints (:enable ,(lsp-json-bool lsp-rust-analyzer-highlight-yield-points))) - :files ( :exclude ,lsp-rust-analyzer-exclude-globs - :watcher ,(if lsp-rust-analyzer-use-client-watching "client" "notify") - :excludeDirs ,lsp-rust-analyzer-exclude-dirs) - :cargo ( :allFeatures ,(lsp-json-bool lsp-rust-all-features) - :noDefaultFeatures ,(lsp-json-bool lsp-rust-no-default-features) - :features ,lsp-rust-features - :extraArgs ,lsp-rust-analyzer-cargo-extra-args - :extraEnv ,lsp-rust-analyzer-cargo-extra-env - :target ,lsp-rust-analyzer-cargo-target - :runBuildScripts ,(lsp-json-bool lsp-rust-analyzer-cargo-run-build-scripts) - ;; Obsolete, but used by old Rust-Analyzer versions - :loadOutDirsFromCheck ,(lsp-json-bool lsp-rust-analyzer-cargo-run-build-scripts) - :autoreload ,(lsp-json-bool lsp-rust-analyzer-cargo-auto-reload) - :useRustcWrapperForBuildScripts ,(lsp-json-bool lsp-rust-analyzer-use-rustc-wrapper-for-build-scripts) - :unsetTest ,lsp-rust-analyzer-cargo-unset-test) - :rustfmt ( :extraArgs ,lsp-rust-analyzer-rustfmt-extra-args - :overrideCommand ,lsp-rust-analyzer-rustfmt-override-command - :rangeFormatting (:enable ,(lsp-json-bool lsp-rust-analyzer-rustfmt-rangeformatting-enable))) - :lens ( :debug (:enable ,(lsp-json-bool lsp-rust-analyzer-lens-debug-enable)) - :enable ,(lsp-json-bool lsp-rust-analyzer-lens-enable) - ;; :forceCustomCommands ,(lsp-json-bool lsp-rust-analyzer-lens-force-custom-commands) - :implementations (:enable ,(lsp-json-bool lsp-rust-analyzer-lens-implementations-enable)) - ;; :location ,lsp-rust-analyzer-lens-location - :references ( :adt (:enable ,(lsp-json-bool lsp-rust-analyzer-lens-references-adt-enable)) - :enumVariant (:enable ,(lsp-json-bool lsp-rust-analyzer-lens-references-enum-variant-enable)) - :method (:enable ,(lsp-json-bool lsp-rust-analyzer-lens-references-method-enable)) - :trait (:enable ,(lsp-json-bool lsp-rust-analyzer-lens-references-trait-enable))) - :run (:enable ,(lsp-json-bool lsp-rust-analyzer-lens-run-enable))) - - :inlayHints ( :bindingModeHints (:enable ,(lsp-json-bool lsp-rust-analyzer-binding-mode-hints)) - :chainingHints (:enable ,(lsp-json-bool lsp-rust-analyzer-display-chaining-hints)) - :closingBraceHints ( :enable ,(lsp-json-bool lsp-rust-analyzer-closing-brace-hints) - :minLines ,lsp-rust-analyzer-closing-brace-hints-min-lines) - :closureCaptureHints (:enable ,(lsp-json-bool lsp-rust-analyzer-closure-capture-hints)) - :closureReturnTypeHints (:enable ,lsp-rust-analyzer-closure-return-type-hints) - :closureStyle ,lsp-rust-analyzer-closure-style - :discriminantHints (:enable ,lsp-rust-analyzer-discriminants-hints) - - :expressionAdjustmentHints ( :enable ,lsp-rust-analyzer-expression-adjustment-hints - :hideOutsideUnsafe ,(lsp-json-bool lsp-rust-analyzer-expression-adjustment-hide-unsafe) - :mode ,lsp-rust-analyzer-expression-adjustment-hints-mode) - :implicitDrops (:enable ,(lsp-json-bool lsp-rust-analyzer-implicit-drops)) - :lifetimeElisionHints ( :enable ,lsp-rust-analyzer-display-lifetime-elision-hints-enable - :useParameterNames ,(lsp-json-bool lsp-rust-analyzer-display-lifetime-elision-hints-use-parameter-names)) - :maxLength ,lsp-rust-analyzer-max-inlay-hint-length - :parameterHints (:enable ,(lsp-json-bool lsp-rust-analyzer-display-parameter-hints)) - :reborrowHints (:enable ,lsp-rust-analyzer-display-reborrow-hints) - :renderColons ,(lsp-json-bool lsp-rust-analyzer-server-format-inlay-hints) - :typeHints ( :enable ,(lsp-json-bool lsp-inlay-hint-enable) - :hideClosureInitialization ,(lsp-json-bool lsp-rust-analyzer-hide-closure-initialization) - :hideNamedConstructor ,(lsp-json-bool lsp-rust-analyzer-hide-named-constructor))) - :completion ( :addCallParenthesis ,(lsp-json-bool lsp-rust-analyzer-completion-add-call-parenthesis) - :addCallArgumentSnippets ,(lsp-json-bool lsp-rust-analyzer-completion-add-call-argument-snippets) - :postfix (:enable ,(lsp-json-bool lsp-rust-analyzer-completion-postfix-enable)) - :autoimport (:enable ,(lsp-json-bool lsp-rust-analyzer-completion-auto-import-enable)) - :autoself (:enable ,(lsp-json-bool lsp-rust-analyzer-completion-auto-self-enable))) - :callInfo (:full ,(lsp-json-bool lsp-rust-analyzer-call-info-full)) - :procMacro (:enable ,(lsp-json-bool lsp-rust-analyzer-proc-macro-enable)) - :rustcSource ,lsp-rust-analyzer-rustc-source - :linkedProjects ,lsp-rust-analyzer-linked-projects - :highlighting (:strings ,(lsp-json-bool lsp-rust-analyzer-highlighting-strings)) - :experimental (:procAttrMacros ,(lsp-json-bool lsp-rust-analyzer-experimental-proc-attr-macros)))) - -(lsp-register-client - (make-lsp-client - :new-connection (lsp-stdio-connection - (lambda () - `(,(or (executable-find - (cl-first lsp-rust-analyzer-server-command)) - (lsp-package-path 'rust-analyzer) - "rust-analyzer") - ,@(cl-rest lsp-rust-analyzer-server-command)))) - :activation-fn (lsp-activate-on "rust") - :priority (if (eq lsp-rust-server 'rust-analyzer) 1 -1) - :initialization-options 'lsp-rust-analyzer--make-init-options - :notification-handlers (ht<-alist lsp-rust-notification-handlers) - :action-handlers (ht ("rust-analyzer.runSingle" #'lsp-rust--analyzer-run-single) - ("rust-analyzer.debugSingle" #'lsp-rust--analyzer-debug-lens) - ("rust-analyzer.showReferences" #'lsp-rust--analyzer-show-references) - ("rust-analyzer.triggerParameterHints" #'lsp--action-trigger-parameter-hints)) - :library-folders-fn (lambda (_workspace) lsp-rust-analyzer-library-directories) - :semantic-tokens-faces-overrides `( :discard-default-modifiers t - :modifiers ,(lsp-rust-analyzer--semantic-modifiers)) - :server-id 'rust-analyzer - :custom-capabilities `((experimental . ((snippetTextEdit . ,(and lsp-enable-snippet (fboundp 'yas-minor-mode)))))) - :download-server-fn (lambda (_client callback error-callback _update?) - (lsp-package-ensure 'rust-analyzer callback error-callback)))) - -(lsp-consistency-check lsp-rust) - -(provide 'lsp-rust) -;;; lsp-rust.el ends here diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-rust.elc b/emacs/elpa/lsp-mode-20240514.1430/lsp-rust.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-tex.el b/emacs/elpa/lsp-mode-20240514.1430/lsp-tex.el @@ -1,68 +0,0 @@ -;;; lsp-tex.el --- description -*- lexical-binding: t; -*- - -;; Copyright (C) 2020 emacs-lsp maintainers - -;; Author: emacs-lsp maintainers -;; Keywords: lsp, tex - -;; 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 <https://www.gnu.org/licenses/>. - -;;; Commentary: - -;; LSP Clients for the Tex Typesetting Language. - -;;; Code: - -(require 'lsp-mode) - -(defgroup lsp-tex nil - "LSP support for TeX and friends, using Digestif and texlab." - :group 'lsp-mode - :link '(url-link "https://github.com/astoff/digestif/") - :link '(url-link "https://github.com/latex-lsp/texlab")) - -(defcustom lsp-tex-server 'texlab - "Choose LSP tex server." - :type '(choice (const :tag "texlab" texlab) - (const :tag "digestif" digestif)) - :group 'lsp-tex) - -(defcustom lsp-clients-digestif-executable "digestif" - "Command to start the Digestif language server." - :group 'lsp-tex - :risky t - :type 'file) - -(lsp-register-client - (make-lsp-client :new-connection (lsp-stdio-connection lsp-clients-digestif-executable) - :major-modes '(plain-tex-mode latex-mode context-mode texinfo-mode) - :priority (if (eq lsp-tex-server 'digestif) 1 -1) - :server-id 'digestif)) - -(defcustom lsp-clients-texlab-executable "texlab" - "Command to start the texlab language server." - :group 'lsp-tex - :risky t - :type 'file) - -(lsp-register-client - (make-lsp-client :new-connection (lsp-stdio-connection lsp-clients-texlab-executable) - :major-modes '(plain-tex-mode latex-mode) - :priority (if (eq lsp-tex-server 'texlab) 1 -1) - :server-id 'texlab)) - -(lsp-consistency-check lsp-tex) - -(provide 'lsp-tex) -;;; lsp-tex.el ends here diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-tex.elc b/emacs/elpa/lsp-mode-20240514.1430/lsp-tex.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-actionscript.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-actionscript.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-actionscript.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-actionscript.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-ada.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-ada.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-ada.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-ada.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-angular.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-angular.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-angular.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-angular.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-ansible.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-ansible.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-ansible.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-ansible.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-asm.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-asm.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-asm.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-asm.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-astro.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-astro.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-astro.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-astro.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-autotools.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-autotools.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-autotools.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-autotools.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-awk.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-awk.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-awk.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-awk.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-bash.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-bash.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-bash.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-bash.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-beancount.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-beancount.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-beancount.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-beancount.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-bufls.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-bufls.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-bufls.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-bufls.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-camel.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-camel.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-camel.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-camel.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-clangd.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-clangd.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-clangd.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-clangd.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-clojure.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-clojure.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-clojure.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-clojure.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-cmake.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-cmake.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-cmake.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-cmake.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-cobol.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-cobol.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-cobol.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-cobol.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-completion.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-completion.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-completion.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-completion.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-credo.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-credo.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-credo.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-credo.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-crystal.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-crystal.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-crystal.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-crystal.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240531.2326/lsp-csharp.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-csharp.el @@ -0,0 +1,539 @@ +;;; lsp-csharp.el --- description -*- lexical-binding: t; -*- + +;; Copyright (C) 2019 Jostein Kjønigsen, Saulius Menkevicius + +;; Author: Saulius Menkevicius <saulius.menkevicius@fastmail.com> +;; Keywords: + +;; 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 <https://www.gnu.org/licenses/>. + +;;; Commentary: + +;; lsp-csharp client + +;;; Code: + +(require 'lsp-mode) +(require 'gnutls) +(require 'f) + +(defgroup lsp-csharp nil + "LSP support for C#, using the Omnisharp Language Server. +Version 1.34.3 minimum is required." + :group 'lsp-mode + :link '(url-link "https://github.com/OmniSharp/omnisharp-roslyn")) + +(defgroup lsp-csharp-omnisharp nil + "LSP support for C#, using the Omnisharp Language Server. +Version 1.34.3 minimum is required." + :group 'lsp-mode + :link '(url-link "https://github.com/OmniSharp/omnisharp-roslyn") + :package-version '(lsp-mode . "9.0.0")) + +(defconst lsp-csharp--omnisharp-metadata-uri-re + "^file:///%24metadata%24/Project/\\(.+\\)/Assembly/\\(.+\\)/Symbol/\\(.+\\)\.cs$" + "Regular expression matching omnisharp's metadata uri. +Group 1 contains the Project name +Group 2 contains the Assembly name +Group 3 contains the Type name") + +(defcustom lsp-csharp-server-install-dir + (f-join lsp-server-install-dir "omnisharp-roslyn/") + "Installation directory for OmniSharp Roslyn server." + :group 'lsp-csharp-omnisharp + :type 'directory) + +(defcustom lsp-csharp-server-path + nil + "The path to the OmniSharp Roslyn language-server binary. +Set this if you have the binary installed or have it built yourself." + :group 'lsp-csharp-omnisharp + :type '(string :tag "Single string value or nil")) + +(defcustom lsp-csharp-test-run-buffer-name + "*lsp-csharp test run*" + "The name of buffer used for outputting lsp-csharp test run results." + :group 'lsp-csharp-omnisharp + :type 'string) + +(defcustom lsp-csharp-solution-file + nil + "Solution to load when starting the server. +Usually this is to be set in your .dir-locals.el on the project root directory." + :group 'lsp-csharp-omnisharp + :type 'string) + +(defcustom lsp-csharp-omnisharp-roslyn-download-url + (concat "https://github.com/omnisharp/omnisharp-roslyn/releases/latest/download/" + (cond ((eq system-type 'windows-nt) + ; On Windows we're trying to avoid a crash starting 64bit .NET PE binaries in + ; Emacs by using x86 version of omnisharp-roslyn on older (<= 26.4) versions + ; of Emacs. See https://lists.nongnu.org/archive/html/bug-gnu-emacs/2017-06/msg00893.html" + (if (and (string-match "^x86_64-.*" system-configuration) + (version<= "26.4" emacs-version)) + "omnisharp-win-x64.zip" + "omnisharp-win-x86.zip")) + + ((eq system-type 'darwin) + (if (string-match "aarch64-.*" system-configuration) + "omnisharp-osx-arm64-net6.0.zip" + "omnisharp-osx-x64-net6.0.zip")) + + ((and (eq system-type 'gnu/linux) + (or (eq (string-match "^x86_64" system-configuration) 0) + (eq (string-match "^i[3-6]86" system-configuration) 0))) + "omnisharp-linux-x64-net6.0.zip") + + (t "omnisharp-mono.zip"))) + "Automatic download url for omnisharp-roslyn." + :group 'lsp-csharp-omnisharp + :type 'string) + +(defcustom lsp-csharp-omnisharp-roslyn-store-path + (f-join lsp-csharp-server-install-dir "latest" "omnisharp-roslyn.zip") + "The path where omnisharp-roslyn .zip archive will be stored." + :group 'lsp-csharp-omnisharp + :type 'file) + +(defcustom lsp-csharp-omnisharp-roslyn-binary-path + (f-join lsp-csharp-server-install-dir "latest" (if (eq system-type 'windows-nt) + "OmniSharp.exe" + "OmniSharp")) + "The path where omnisharp-roslyn binary after will be stored." + :group 'lsp-csharp-omnisharp + :type 'file) + +(defcustom lsp-csharp-omnisharp-roslyn-server-dir + (f-join lsp-csharp-server-install-dir "latest" "omnisharp-roslyn") + "The path where omnisharp-roslyn .zip archive will be extracted." + :group 'lsp-csharp-omnisharp + :type 'file) + +(defcustom lsp-csharp-omnisharp-enable-decompilation-support + nil + "Decompile bytecode when browsing method metadata for types in assemblies. +Otherwise only declarations for the methods are visible (the default)." + :group 'lsp-csharp + :type 'boolean) + +(lsp-dependency + 'omnisharp-roslyn + `(:download :url lsp-csharp-omnisharp-roslyn-download-url + :decompress :zip + :store-path lsp-csharp-omnisharp-roslyn-store-path + :binary-path lsp-csharp-omnisharp-roslyn-binary-path + :set-executable? t) + '(:system "OmniSharp")) + +(defun lsp-csharp--omnisharp-download-server (_client callback error-callback _update?) + "Download zip package for omnisharp-roslyn and install it. +Will invoke CALLBACK on success, ERROR-CALLBACK on error." + (lsp-package-ensure 'omnisharp-roslyn callback error-callback)) + +(defun lsp-csharp--language-server-path () + "Resolve path to use to start the server." + (let ((executable-name (if (eq system-type 'windows-nt) + "OmniSharp.exe" + "OmniSharp"))) + (or (and lsp-csharp-server-path + (executable-find lsp-csharp-server-path)) + (executable-find executable-name) + (lsp-package-path 'omnisharp-roslyn)))) + +(defun lsp-csharp-open-project-file () + "Open corresponding project file (.csproj) for the current file." + (interactive) + (-let* ((project-info-req (lsp-make-omnisharp-project-information-request :file-name (buffer-file-name))) + (project-info (lsp-request "o#/project" project-info-req)) + ((&omnisharp:ProjectInformation :ms-build-project) project-info) + ((&omnisharp:MsBuildProject :path) ms-build-project)) + (find-file path))) + +(defun lsp-csharp--get-buffer-code-elements () + "Retrieve code structure by calling into the /v2/codestructure endpoint. +Returns :elements from omnisharp:CodeStructureResponse." + (-let* ((code-structure (lsp-request "o#/v2/codestructure" + (lsp-make-omnisharp-code-structure-request :file-name (buffer-file-name)))) + ((&omnisharp:CodeStructureResponse :elements) code-structure)) + elements)) + +(defun lsp-csharp--inspect-code-elements-recursively (fn elements) + "Invoke FN for every omnisharp:CodeElement found recursively in ELEMENTS." + (seq-each + (lambda (el) + (funcall fn el) + (-let (((&omnisharp:CodeElement :children) el)) + (lsp-csharp--inspect-code-elements-recursively fn children))) + elements)) + +(defun lsp-csharp--collect-code-elements-recursively (predicate elements) + "Flatten the omnisharp:CodeElement tree in ELEMENTS matching PREDICATE." + (let ((results nil)) + (lsp-csharp--inspect-code-elements-recursively (lambda (el) + (when (funcall predicate el) + (setq results (cons el results)))) + elements) + results)) + +(lsp-defun lsp-csharp--l-c-within-range (l c (&omnisharp:Range :start :end)) + "Determine if L (line) and C (column) are within RANGE." + (-let* (((&omnisharp:Point :line start-l :column start-c) start) + ((&omnisharp:Point :line end-l :column end-c) end)) + (or (and (= l start-l) (>= c start-c) (or (> end-l start-l) (<= c end-c))) + (and (> l start-l) (< l end-l)) + (and (= l end-l) (<= c end-c))))) + +(defun lsp-csharp--code-element-stack-on-l-c (l c elements) + "Return omnisharp:CodeElement stack at L (line) and C (column) in ELEMENTS tree." + (when-let ((matching-element (seq-find (lambda (el) + (-when-let* (((&omnisharp:CodeElement :ranges) el) + ((&omnisharp:RangeList :full?) ranges)) + (lsp-csharp--l-c-within-range l c full?))) + elements))) + (-let (((&omnisharp:CodeElement :children) matching-element)) + (cons matching-element (lsp-csharp--code-element-stack-on-l-c l c children))))) + +(defun lsp-csharp--code-element-stack-at-point () + "Return omnisharp:CodeElement stack at point as a list." + (let ((pos-line (plist-get (lsp--cur-position) :line)) + (pos-col (plist-get (lsp--cur-position) :character))) + (lsp-csharp--code-element-stack-on-l-c pos-line + pos-col + (lsp-csharp--get-buffer-code-elements)))) + +(lsp-defun lsp-csharp--code-element-test-method-p (element) + "Return test method name and test framework for a given ELEMENT." + (when element + (-when-let* (((&omnisharp:CodeElement :properties) element) + ((&omnisharp:CodeElementProperties :test-method-name? :test-framework?) properties)) + (list test-method-name? test-framework?)))) + +(defun lsp-csharp--reset-test-buffer (present-buffer) + "Create new or reuse an existing test result output buffer. +PRESENT-BUFFER will make the buffer be presented to the user." + (with-current-buffer (get-buffer-create lsp-csharp-test-run-buffer-name) + (compilation-mode) + (read-only-mode) + (let ((inhibit-read-only t)) + (erase-buffer))) + + (when present-buffer + (display-buffer lsp-csharp-test-run-buffer-name))) + +(defun lsp-csharp--start-tests (test-method-framework test-method-names) + "Run test(s) identified by TEST-METHOD-NAMES using TEST-METHOD-FRAMEWORK." + (if (and test-method-framework test-method-names) + (let ((request-message (lsp-make-omnisharp-run-tests-in-class-request + :file-name (buffer-file-name) + :test-frameworkname test-method-framework + :method-names (vconcat test-method-names)))) + (lsp-csharp--reset-test-buffer t) + (lsp-session-set-metadata "last-test-method-framework" test-method-framework) + (lsp-session-set-metadata "last-test-method-names" test-method-names) + (lsp-request-async "o#/v2/runtestsinclass" + request-message + (-lambda ((&omnisharp:RunTestResponse)) + (message "lsp-csharp: Test run has started")))) + (message "lsp-csharp: No test methods to run"))) + +(defun lsp-csharp--test-message (message) + "Emit a MESSAGE to lsp-csharp test run buffer." + (when-let ((existing-buffer (get-buffer lsp-csharp-test-run-buffer-name)) + (inhibit-read-only t)) + (with-current-buffer existing-buffer + (save-excursion + (goto-char (point-max)) + (insert message "\n"))))) + +(defun lsp-csharp-run-test-at-point () + "Start test run at current point (if any)." + (interactive) + (let* ((stack (lsp-csharp--code-element-stack-at-point)) + (element-on-point (car (last stack))) + (test-method (lsp-csharp--code-element-test-method-p element-on-point)) + (test-method-name (car test-method)) + (test-method-framework (car (cdr test-method)))) + (lsp-csharp--start-tests test-method-framework (list test-method-name)))) + +(defun lsp-csharp-run-all-tests-in-buffer () + "Run all test methods in the current buffer." + (interactive) + (let* ((elements (lsp-csharp--get-buffer-code-elements)) + (test-methods (lsp-csharp--collect-code-elements-recursively 'lsp-csharp--code-element-test-method-p elements)) + (test-method-framework (car (cdr (lsp-csharp--code-element-test-method-p (car test-methods))))) + (test-method-names (mapcar (lambda (method) + (car (lsp-csharp--code-element-test-method-p method))) + test-methods))) + (lsp-csharp--start-tests test-method-framework test-method-names))) + +(defun lsp-csharp-run-test-in-buffer () + "Run selected test in current buffer." + (interactive) + (when-let* ((elements (lsp-csharp--get-buffer-code-elements)) + (test-methods (lsp-csharp--collect-code-elements-recursively 'lsp-csharp--code-element-test-method-p elements)) + (test-method-framework (car (cdr (lsp-csharp--code-element-test-method-p (car test-methods))))) + (test-method-names (mapcar (lambda (method) + (car (lsp-csharp--code-element-test-method-p method))) + test-methods)) + (selected-test-method-name (lsp--completing-read "Select test:" test-method-names 'identity))) + (lsp-csharp--start-tests test-method-framework (list selected-test-method-name)))) + +(defun lsp-csharp-run-last-tests () + "Re-run test(s) that were run last time." + (interactive) + (if-let ((last-test-method-framework (lsp-session-get-metadata "last-test-method-framework")) + (last-test-method-names (lsp-session-get-metadata "last-test-method-names"))) + (lsp-csharp--start-tests last-test-method-framework last-test-method-names) + (message "lsp-csharp: No test method(s) found to be ran previously on this workspace"))) + +(lsp-defun lsp-csharp--handle-os-error (_workspace (&omnisharp:ErrorMessage :file-name :text)) + "Handle the `o#/error' (interop) notification displaying a message." + (lsp-warn "%s: %s" file-name text)) + +(lsp-defun lsp-csharp--handle-os-testmessage (_workspace (&omnisharp:TestMessageEvent :message)) + "Handle the `o#/testmessage and display test message on test output buffer." + (lsp-csharp--test-message message)) + +(lsp-defun lsp-csharp--handle-os-testcompleted (_workspace (&omnisharp:DotNetTestResult + :method-name + :outcome + :error-message + :error-stack-trace + :standard-output + :standard-error)) + "Handle the `o#/testcompleted' message from the server. + +Will display the results of the test on the lsp-csharp test output buffer." + (let ((passed (string-equal "passed" outcome))) + (lsp-csharp--test-message + (format "[%s] %s " + (propertize (upcase outcome) 'font-lock-face (if passed 'success 'error)) + method-name)) + + (unless passed + (lsp-csharp--test-message error-message) + + (when error-stack-trace + (lsp-csharp--test-message error-stack-trace)) + + (unless (seq-empty-p standard-output) + (lsp-csharp--test-message "STANDARD OUTPUT:") + (seq-doseq (stdout-line standard-output) + (lsp-csharp--test-message stdout-line))) + + (unless (seq-empty-p standard-error) + (lsp-csharp--test-message "STANDARD ERROR:") + (seq-doseq (stderr-line standard-error) + (lsp-csharp--test-message stderr-line)))))) + +(lsp-defun lsp-csharp--action-client-find-references ((&Command :arguments?)) + "Read first argument from ACTION as Location and display xrefs for that location +using the `textDocument/references' request." + (-if-let* (((&Location :uri :range) (lsp-seq-first arguments?)) + ((&Range :start range-start) range) + (find-refs-params (append (lsp--text-document-position-params (list :uri uri) range-start) + (list :context (list :includeDeclaration json-false)))) + (locations-found (lsp-request "textDocument/references" find-refs-params))) + (lsp-show-xrefs (lsp--locations-to-xref-items locations-found) nil t) + (message "No references found"))) + +(defun lsp-csharp--omnisharp-path->qualified-name (path) + "Convert PATH to qualified-namespace-like name." + (replace-regexp-in-string + (regexp-quote "/") + "." + path)) + +(defun lsp-csharp--omnisharp-metadata-uri-handler (uri) + "Handle `file:/(metadata)' URI from omnisharp-roslyn server. + +The URI is parsed and then `o#/metadata' request is issued to retrieve +metadata from the server. A cache file is created on project root dir that +stores this metadata and filename is returned so lsp-mode can display this file." + (string-match lsp-csharp--omnisharp-metadata-uri-re uri) + (-when-let* ((project-name (lsp-csharp--omnisharp-path->qualified-name (url-unhex-string (match-string 1 uri)))) + (assembly-name (lsp-csharp--omnisharp-path->qualified-name (url-unhex-string (match-string 2 uri)))) + (type-name (lsp-csharp--omnisharp-path->qualified-name (url-unhex-string (match-string 3 uri)))) + (metadata-req (lsp-make-omnisharp-metadata-request :project-name project-name + :assembly-name assembly-name + :type-name type-name)) + (metadata (lsp-request "o#/metadata" metadata-req)) + ((&omnisharp:MetadataResponse :source-name :source) metadata) + (filename (f-join ".cache" + "lsp-csharp" + "metadata" + "Project" project-name + "Assembly" assembly-name + "Symbol" (concat type-name ".cs"))) + (file-location (expand-file-name filename (lsp--suggest-project-root))) + (metadata-file-location (concat file-location ".metadata-uri")) + (path (f-dirname file-location))) + + (unless (find-buffer-visiting file-location) + (unless (file-directory-p path) + (make-directory path t)) + + (with-temp-file metadata-file-location + (insert uri)) + + (with-temp-file file-location + (insert source))) + + file-location)) + +(defun lsp-csharp--omnisharp-uri->path-fn (uri) + "Custom implementation of lsp--uri-to-path function to glue omnisharp's +metadata uri." + (if (string-match-p lsp-csharp--omnisharp-metadata-uri-re uri) + (lsp-csharp--omnisharp-metadata-uri-handler uri) + (lsp--uri-to-path-1 uri))) + +(defun lsp-csharp--omnisharp-environment-fn () + "Build environment structure for current values of lsp-csharp customizables. +See https://github.com/OmniSharp/omnisharp-roslyn/wiki/Configuration-Options" + `(("OMNISHARP_RoslynExtensionsOptions:enableDecompilationSupport" . ,(if lsp-csharp-omnisharp-enable-decompilation-support "true" "false")))) + +(lsp-register-client + (make-lsp-client :new-connection + (lsp-stdio-connection + #'(lambda () + (append + (list (lsp-csharp--language-server-path) "-lsp") + (when lsp-csharp-solution-file + (list "-s" (expand-file-name lsp-csharp-solution-file))))) + #'(lambda () + (when-let ((binary (lsp-csharp--language-server-path))) + (f-exists? binary)))) + :activation-fn (lsp-activate-on "csharp") + :server-id 'omnisharp + :priority -1 + :uri->path-fn #'lsp-csharp--omnisharp-uri->path-fn + :environment-fn #'lsp-csharp--omnisharp-environment-fn + :action-handlers (ht ("omnisharp/client/findReferences" 'lsp-csharp--action-client-find-references)) + :notification-handlers (ht ("o#/projectadded" 'ignore) + ("o#/projectchanged" 'ignore) + ("o#/projectremoved" 'ignore) + ("o#/packagerestorestarted" 'ignore) + ("o#/msbuildprojectdiagnostics" 'ignore) + ("o#/packagerestorefinished" 'ignore) + ("o#/unresolveddependencies" 'ignore) + ("o#/error" 'lsp-csharp--handle-os-error) + ("o#/testmessage" 'lsp-csharp--handle-os-testmessage) + ("o#/testcompleted" 'lsp-csharp--handle-os-testcompleted) + ("o#/projectconfiguration" 'ignore) + ("o#/projectdiagnosticstatus" 'ignore) + ("o#/backgrounddiagnosticstatus" 'ignore)) + :download-server-fn #'lsp-csharp--omnisharp-download-server)) + +;; +;; Alternative "csharp-ls" language server support +;; see https://github.com/razzmatazz/csharp-language-server +;; +(lsp-defun lsp-csharp--cls-metadata-uri-handler (uri) + "Handle `csharp:/(metadata)' uri from csharp-ls server. + +`csharp/metadata' request is issued to retrieve metadata from the server. +A cache file is created on project root dir that stores this metadata and +filename is returned so lsp-mode can display this file." + + (-when-let* ((metadata-req (lsp-make-csharp-ls-c-sharp-metadata + :text-document (lsp-make-text-document-identifier :uri uri))) + (metadata (lsp-request "csharp/metadata" metadata-req)) + ((&csharp-ls:CSharpMetadataResponse :project-name + :assembly-name + :symbol-name + :source) metadata) + (filename (f-join ".cache" + "lsp-csharp" + "metadata" + "projects" project-name + "assemblies" assembly-name + (concat symbol-name ".cs"))) + (file-location (expand-file-name filename (lsp-workspace-root))) + (metadata-file-location (concat file-location ".metadata-uri")) + (path (f-dirname file-location))) + + (unless (file-exists-p file-location) + (unless (file-directory-p path) + (make-directory path t)) + + (with-temp-file metadata-file-location + (insert uri)) + + (with-temp-file file-location + (insert source))) + + file-location)) + +(defun lsp-csharp--cls-before-file-open (_workspace) + "Set `lsp-buffer-uri' variable after C# file is open from *.metadata-uri file." + + (let ((metadata-file-name (concat buffer-file-name ".metadata-uri"))) + (setq-local lsp-buffer-uri + (when (file-exists-p metadata-file-name) + (with-temp-buffer (insert-file-contents metadata-file-name) + (buffer-string)))))) + +(defun lsp-csharp--cls-make-launch-cmd () + "Return command line to invoke csharp-ls." + + ;; emacs-28.1 on macOS has an issue + ;; that it launches processes using posix_spawn but does not reset sigmask properly + ;; thus causing dotnet runtime to lockup awaiting a SIGCHLD signal that never comes + ;; from subprocesses that quit + ;; + ;; as a workaround we will wrap csharp-ls invocation in "/bin/ksh -c" on macos + ;; so it launches with proper sigmask + ;; + ;; see https://lists.gnu.org/archive/html/emacs-devel/2022-02/msg00461.html + + (let ((startup-wrapper (cond ((and (eq 'darwin system-type) + (version= "28.1" emacs-version)) + (list "/bin/ksh" "-c")) + + (t nil))) + + (csharp-ls-exec (or (executable-find "csharp-ls") + (f-join (or (getenv "USERPROFILE") (getenv "HOME")) + ".dotnet" "tools" "csharp-ls"))) + + (solution-file-params (when lsp-csharp-solution-file + (list "-s" lsp-csharp-solution-file)))) + (append startup-wrapper + (list csharp-ls-exec) + solution-file-params))) + +(defun lsp-csharp--cls-download-server (_client callback error-callback update?) + "Install/update csharp-ls language server using `dotnet tool'. + +Will invoke CALLBACK or ERROR-CALLBACK based on result. +Will update if UPDATE? is t" + (lsp-async-start-process + callback + error-callback + "dotnet" "tool" (if update? "update" "install") "-g" "csharp-ls")) + +(lsp-register-client + (make-lsp-client :new-connection (lsp-stdio-connection #'lsp-csharp--cls-make-launch-cmd) + :priority -2 + :server-id 'csharp-ls + :activation-fn (lsp-activate-on "csharp") + :before-file-open-fn #'lsp-csharp--cls-before-file-open + :uri-handlers (ht ("csharp" #'lsp-csharp--cls-metadata-uri-handler)) + :download-server-fn #'lsp-csharp--cls-download-server)) + +(lsp-consistency-check lsp-csharp) + +(provide 'lsp-csharp) +;;; lsp-csharp.el ends here diff --git a/emacs/elpa/lsp-mode-20240531.2326/lsp-csharp.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-csharp.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-css.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-css.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-css.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-css.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-cucumber.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-cucumber.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-cucumber.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-cucumber.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-cypher.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-cypher.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-cypher.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-cypher.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-d.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-d.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-d.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-d.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-dhall.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-dhall.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-dhall.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-dhall.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-diagnostics.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-diagnostics.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-diagnostics.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-diagnostics.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-dired.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-dired.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-dired.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-dired.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-dockerfile.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-dockerfile.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-dockerfile.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-dockerfile.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-dot.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-dot.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-dot.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-dot.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-elixir.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-elixir.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-elixir.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-elixir.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-elm.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-elm.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-elm.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-elm.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-emmet.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-emmet.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-emmet.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-emmet.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-erlang.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-erlang.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-erlang.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-erlang.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-eslint.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-eslint.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-eslint.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-eslint.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-fortran.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-fortran.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-fortran.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-fortran.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-fsharp.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-fsharp.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-fsharp.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-fsharp.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-gdscript.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-gdscript.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-gdscript.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-gdscript.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-gleam.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-gleam.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-gleam.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-gleam.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-glsl.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-glsl.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-glsl.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-glsl.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-go.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-go.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-go.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-go.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-golangci-lint.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-golangci-lint.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-golangci-lint.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-golangci-lint.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-graphql.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-graphql.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-graphql.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-graphql.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240531.2326/lsp-groovy.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-groovy.el @@ -0,0 +1,66 @@ +;;; lsp-groovy.el --- description -*- lexical-binding: t; -*- + +;; Copyright (C) 2020 emacs-lsp maintainers + +;; Author: emacs-lsp maintainers +;; Keywords: lsp, groovy + +;; 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 <https://www.gnu.org/licenses/>. + +;;; Commentary: + +;; LSP Clients for the Groovy Programming Language. + +;;; Code: + +(require 'lsp-mode) +(require 'f) + +(defgroup lsp-groovy nil + "LSP support for Groovy, using groovy-language-server." + :group 'lsp-mode + :link '(url-link "https://github.com/GroovyLanguageServer/groovy-language-server")) + +(defcustom lsp-groovy-server-file (f-join lsp-server-install-dir "groovy-language-server-all.jar") + "JAR file path for groovy-language-server-all.jar." + :group 'lsp-groovy + :risky t + :type 'file) + +(defun lsp-groovy--lsp-command () + "Generate LSP startup command." + `("java" "-jar" ,(expand-file-name lsp-groovy-server-file))) + +(defcustom lsp-groovy-classpath ["/usr/local/opt/groovy/libexec/lib"] + "List of paths to Groovy JARs." + :group 'lsp-groovy + :risky t + :type 'lsp-string-vector) + +(lsp-register-custom-settings + '(("groovy.classpath" lsp-groovy-classpath))) + +(lsp-register-client + (make-lsp-client :new-connection (lsp-stdio-connection 'lsp-groovy--lsp-command) + :major-modes '(groovy-mode) + :priority -1 + :server-id 'groovy-ls + :initialized-fn (lambda (workspace) + (with-lsp-workspace workspace + (lsp--set-configuration (lsp-configuration-section "groovy")))))) + +(lsp-consistency-check lsp-groovy) + +(provide 'lsp-groovy) +;;; lsp-groovy.el ends here diff --git a/emacs/elpa/lsp-mode-20240531.2326/lsp-groovy.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-groovy.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-hack.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-hack.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-hack.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-hack.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-haxe.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-haxe.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-haxe.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-haxe.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-headerline.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-headerline.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-headerline.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-headerline.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-html.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-html.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-html.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-html.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-hy.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-hy.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-hy.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-hy.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-icons.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-icons.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-icons.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-icons.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-ido.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-ido.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-ido.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-ido.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-idris.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-idris.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-idris.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-idris.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-iedit.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-iedit.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-iedit.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-iedit.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240531.2326/lsp-javascript.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-javascript.el @@ -0,0 +1,1054 @@ +;;; lsp-javascript.el --- description -*- lexical-binding: t; -*- + +;; Copyright (C) 2020 emacs-lsp maintainers + +;; Author: emacs-lsp maintainers +;; Keywords: lsp, + +;; 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 <https://www.gnu.org/licenses/>. + +;;; Commentary: + +;; LSP Clients for the JavaScript and TypeScript Programming Languages. + +;;; Code: + +(require 'lsp-mode) + +(lsp-dependency 'javascript-typescript-langserver + '(:system "javascript-typescript-stdio") + '(:npm :package "javascript-typescript-langserver" + :path "javascript-typescript-stdio")) + +(defgroup lsp-typescript-javascript nil + "Support for TypeScript/JavaScript, using Sourcegraph's JavaScript/TypeScript language server." + :group 'lsp-mode + :link '(url-link "https://github.com/sourcegraph/javascript-typescript-langserver")) + +;; Original name can be confused with initializationOptions. Preferences is just one option of initializationOptions. +(define-obsolete-variable-alias + 'lsp-clients-typescript-init-opts + 'lsp-clients-typescript-preferences + "lsp-mode 9.0.0") + +(defcustom lsp-clients-typescript-javascript-server-args '() + "Extra arguments for the typescript-language-server language server." + :group 'lsp-typescript-javascript + :risky t + :type '(repeat string)) + +(defun lsp-typescript-javascript-tsx-jsx-activate-p (filename &optional _) + "Check if the js-ts lsp server should be enabled based on FILENAME." + (or (string-match-p "\\.[cm]js\\|\\.[jt]sx?\\'" filename) + (and (derived-mode-p 'js-mode 'js-ts-mode 'typescript-mode 'typescript-ts-mode) + (not (derived-mode-p 'json-mode))))) + +;; Unmaintained sourcegraph server +(lsp-register-client + (make-lsp-client :new-connection (lsp-stdio-connection (lambda () + (cons (lsp-package-path 'javascript-typescript-langserver) + lsp-clients-typescript-javascript-server-args))) + :activation-fn 'lsp-typescript-javascript-tsx-jsx-activate-p + :priority -3 + :completion-in-comments? t + :server-id 'jsts-ls + :download-server-fn (lambda (_client callback error-callback _update?) + (lsp-package-ensure + 'javascript-typescript-langserver + callback + error-callback)) + :initialized-fn (lambda (_workspace) + (warn (concat "The javascript-typescript-langserver (jsts-ls) is unmaintained; " + "it is recommended to use ts-ls or deno-ls instead."))))) + +(defgroup lsp-typescript nil + "LSP support for TypeScript, using Theia/Typefox's TypeScript Language Server." + :group 'lsp-mode + :link '(url-link "https://github.com/theia-ide/typescript-language-server")) + +(defcustom lsp-clients-typescript-tls-path "typescript-language-server" + "Path to the typescript-language-server binary." + :group 'lsp-typescript + :risky t + :type 'string) + +(defcustom lsp-clients-typescript-server-args '("--stdio") + "Extra arguments for the typescript-language-server language server." + :group 'lsp-typescript + :risky t + :type '(repeat string)) + +(defcustom lsp-clients-typescript-disable-automatic-typing-acquisition nil + "Disable tsserver from automatically fetching missing type definitions. +\(@types packages) for external modules." + :group 'lsp-typescript + :type 'boolean) + +(defcustom lsp-clients-typescript-log-verbosity "info" + "The verbosity level of the information printed in the log by tsserver." + :group 'lsp-typescript + :type '(choice + (const "off") + (const "terse") + (const "normal") + (const "requesttime") + (const "verbose"))) + +(defcustom lsp-clients-typescript-max-ts-server-memory nil + "The maximum size of the V8's old memory section in megabytes. +\(for example 4096 means 4GB). The default value is dynamically configured +by Node so can differ per system. Increase for very big projects that +exceed allowed memory usage." + :group 'lsp-typescript + :type 'integer) + +(defcustom lsp-clients-typescript-npm-location nil + "Specifies the path to the NPM exec used for Automatic Type Acquisition." + :group 'lsp-typescript + :type 'string) + +(defcustom lsp-clients-typescript-prefer-use-project-ts-server nil + "When set, prefers using the tsserver.js from your project. This +can allow loading plugins configured in your tsconfig.json." + :group 'lsp-typescript + :type 'boolean) + +(defcustom lsp-clients-typescript-plugins (vector) + "The list of plugins to load. +It should be a vector of plist with keys `:location' and `:name' +where `:name' is the name of the package and `:location' is the +directory containing the package. Example: +\(vector + \(list :name \"@vsintellicode/typescript-intellicode-plugin\" + :location \"<path>.vscode/extensions/visualstudioexptteam. + vscodeintellicode-1.1.9/\"))" + :group 'lsp-typescript + :type '(restricted-sexp :tag "Vector" + :match-alternatives + (lambda (xs) + (and (vectorp xs) (seq-every-p + (-lambda ((&plist :name :location)) + (and name location)) + xs))))) + +(defcustom lsp-clients-typescript-preferences nil + "Preferences passed to the Typescript (tsserver) process. +See https://github.com/typescript-language-server/typescript-language-server#initializationoptions for the list of preferences available in the latest version of TypeScript." + :group 'lsp-typescript + :type 'plist) + +(defcustom lsp-clients-typescript-tsserver nil + "Options related to the tsserver process. See below for more info. +See https://github.com/typescript-language-server/typescript-language-server#initializationoptions for the list of tsserver available in the latest version of TypeScript." + :group 'lsp-typescript + :type 'plist) + +(defcustom lsp-typescript-tsdk nil + "Specifies the folder path containing tsserver and lib*.d.ts files to use." + :type '(repeat string) + :group 'lsp-vetur + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-typescript-disable-automatic-type-acquisition nil + "Disables automatic type acquisition. +Automatic type acquisition fetches `@types` packages from npm to improve +IntelliSense for external libraries." + :type 'boolean + :group 'lsp-vetur + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-typescript-npm nil + "Specifies the path to the NPM exec used for Automatic Type Acquisition. +Requires using TypeScript 2.3.4 or newer in the +workspace." + :type '(repeat string) + :group 'lsp-vetur + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-typescript-check-npm-is-installed t + "Check if NPM is installed for Automatic Type Acquisition." + :type 'boolean + :group 'lsp-vetur + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-javascript-references-code-lens-enabled nil + "Enable/disable references CodeLens in JavaScript files." + :type 'boolean + :group 'lsp-vetur + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-typescript-references-code-lens-enabled nil + "Enable/disable references CodeLens in TypeScript files." + :type 'boolean + :group 'lsp-vetur + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-typescript-implementations-code-lens-enabled nil + "Enable/disable implementations CodeLens. +This CodeLens shows the implementers of an interface." + :type 'boolean + :group 'lsp-vetur + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-typescript-tsserver-log "off" + "Enables logging of the TS server to a file. +This log can be used to diagnose TS Server issues. The log may contain file +paths, source code, and other potentially sensitive information +from your project." + :type '(choice + (const "off") + (const "terse") + (const "normal") + (const "verbose")) + :group 'lsp-vetur + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-typescript-tsserver-plugin-paths nil + "Additional paths to discover Typescript Language Service plugins. +Requires using TypeScript 2.3.0 or newer in the +workspace." + :type '(repeat string) + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-typescript-tsserver-trace "off" + "Enables tracing of messages sent to the TS server. +This trace can be used to diagnose TS Server issues. The trace may contain +file paths, source code, and other potentially sensitive +information from your project." + :type '(choice + (const "off") + (const "messages") + (const "verbose")) + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-javascript-suggest-complete-function-calls nil + "Complete functions with their parameter signature." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-typescript-suggest-complete-function-calls nil + "Complete functions with their parameter signature." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-typescript-report-style-checks-as-warnings t + "Report style checks as warnings." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-typescript-validate-enable t + "Enable/disable TypeScript validation." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-typescript-format-enable t + "Enable/disable default TypeScript formatter." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-typescript-format-insert-space-after-comma-delimiter t + "Defines space handling after a comma delimiter." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-typescript-format-insert-space-after-constructor nil + "Defines space handling after the constructor keyword. +Requires using TypeScript 2.3.0 or newer in the workspace." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-typescript-format-insert-space-after-semicolon-in-for-statements t + "Defines space handling after a semicolon in a for statement." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-typescript-format-insert-space-before-and-after-binary-operators t + "Defines space handling after a binary operator." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-typescript-format-insert-space-after-keywords-in-control-flow-statements t + "Defines space handling after keywords in a control flow statement." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-typescript-format-insert-space-after-function-keyword-for-anonymous-functions t + "Defines space handling after function keyword for anonymous functions." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-typescript-format-insert-space-before-function-parenthesis nil + "Defines space handling before function argument parentheses." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-typescript-format-insert-space-after-opening-and-before-closing-empty-braces nil + "Defines space handling after opening/before closing empty braces." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-typescript-format-insert-space-after-opening-and-before-closing-nonempty-parenthesis nil + "Defines space handling after opening/before closing non-empty parenthesis." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-typescript-format-insert-space-after-opening-and-before-closing-nonempty-brackets nil + "Defines space handling after opening and before closing non-empty brackets." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-typescript-format-insert-space-after-opening-and-before-closing-nonempty-braces t + "Defines space handling after opening and before closing non-empty braces. +Requires using TypeScript 2.3.0 or newer in the workspace." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-typescript-format-insert-space-after-opening-and-before-closing-template-string-braces nil + "Defines space handling after opening/before closing template string braces." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-typescript-format-insert-space-after-opening-and-before-closing-jsx-expression-braces nil + "Defines space handling after opening/before closing JSX expression braces." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-typescript-format-insert-space-after-type-assertion nil + "Defines space handling after type assertions in TypeScript. +Requires using TypeScript 2.4 or newer in the workspace." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-typescript-format-place-open-brace-on-new-line-for-functions nil + "Defines whether an open brace is put onto a new line for functions or not." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-typescript-format-place-open-brace-on-new-line-for-control-blocks nil + "Defines whether an open brace is put onto a newline for control blocks." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-javascript-validate-enable t + "Enable/disable JavaScript validation." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-javascript-format-enable t + "Enable/disable default JavaScript formatter." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-javascript-format-insert-space-after-comma-delimiter t + "Defines space handling after a comma delimiter." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-javascript-format-insert-space-after-constructor nil + "Defines space handling after the constructor keyword. +Requires using TypeScript 2.3.0 or newer in the workspace." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-javascript-format-insert-space-after-semicolon-in-for-statements t + "Defines space handling after a semicolon in a for statement." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-javascript-format-insert-space-before-and-after-binary-operators t + "Defines space handling after a binary operator." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-javascript-format-insert-space-after-keywords-in-control-flow-statements t + "Defines space handling after keywords in a control flow statement." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-javascript-format-insert-space-after-function-keyword-for-anonymous-functions t + "Defines space handling after function keyword for anonymous functions." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-javascript-format-insert-space-before-function-parenthesis nil + "Defines space handling before function argument parentheses." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-javascript-format-insert-space-after-opening-and-before-closing-empty-braces nil + "Defines space handling after opening/before closing empty braces." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-javascript-format-insert-space-after-opening-and-before-closing-nonempty-parenthesis nil + "Defines space handling after opening and before closing non-empty parenthesis." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-javascript-format-insert-space-after-opening-and-before-closing-nonempty-brackets nil + "Defines space handling after opening and before closing non-empty brackets." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-javascript-format-insert-space-after-opening-and-before-closing-nonempty-braces t + "Defines space handling after opening and before closing non-empty braces. +Requires using TypeScript 2.3.0 or newer in the workspace." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-javascript-format-insert-space-after-opening-and-before-closing-template-string-braces nil + "Defines space handling after opening/before closing template string braces." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-javascript-format-insert-space-after-opening-and-before-closing-jsx-expression-braces nil + "Defines space handling after opening/before closing JSX expression braces." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-javascript-format-place-open-brace-on-new-line-for-functions nil + "Defines whether an open brace is put onto a new line for functions or not." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-javascript-format-place-open-brace-on-new-line-for-control-blocks nil + "Defines whether an open brace is put onto a new line for control blocks or not." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-javascript-implicit-project-config-check-js nil + "Enable/disable semantic checking of JavaScript files. +Existing jsconfig.json or tsconfig.json files override this setting. +Requires using TypeScript 2.3.1 or newer in the workspace." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-javascript-implicit-project-config-experimental-decorators nil + nil + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-javascript-suggest-names t + "Enable/disable including unique names from the file in JavaScript suggestions." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-typescript-tsc-auto-detect "on" + "Controls auto detection of tsc tasks." + :type '(choice + (const "on") + (const "off") + (const "build") + (const "watch")) + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-javascript-suggest-paths t + "Enable/disable suggestions for paths in import statements and require calls." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-typescript-suggest-paths t + "Enable/disable suggestions for paths in import statements and require calls." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-javascript-suggest-auto-imports t + "Enable/disable auto import suggestions. +Requires using TypeScript 2.6.1 or newer in the workspace." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-typescript-suggest-auto-imports t + "Enable/disable auto import suggestions. Requires using +TypeScript 2.6.1 or newer in the workspace." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-javascript-suggest-complete-js-docs t + "Enable/disable suggestion to complete JSDoc comments." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-typescript-suggest-complete-js-docs t + "Enable/disable suggestion to complete JSDoc comments." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-typescript-locale nil + nil + :type '(choice + (const "de") + (const "es") + (const "en") + (const "fr") + (const "it") + (const "ja") + (const "ko") + (const "ru") + (const "zh-CN") + (const "zh-TW") + (const :tag "default" nil)) + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-javascript-suggestion-actions-enabled t + "Enable/disable suggestion diagnostics for JavaScript files in +the editor. Requires using TypeScript 2.8 or newer in the +workspace." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-typescript-suggestion-actions-enabled t + "Enable/disable suggestion diagnostics for TypeScript files in +the editor. Requires using TypeScript 2.8 or newer in the +workspace." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-javascript-preferences-quote-style "auto" nil + :type '(choice + (const "auto") + (const "single") + (const "double")) + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-typescript-preferences-quote-style "auto" nil + :type '(choice + (const "auto") + (const "single") + (const "double")) + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-javascript-preferences-import-module-specifier "auto" + "Preferred path style for auto imports." + :type '(choice + (const "auto") + (const "relative") + (const "non-relative")) + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-typescript-preferences-import-module-specifier "auto" + "Infer the shortest path type." + :type '(choice + (const "auto") + (const "relative") + (const "non-relative")) + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-javascript-preferences-rename-shorthand-properties t + "Enable/disable introducing aliases for object shorthand +properties during renames. Requires using TypeScript 3.4 or newer +in the workspace." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-typescript-preferences-rename-shorthand-properties t + "Enable/disable introducing aliases for object shorthand +properties during renames. Requires using TypeScript 3.4 or newer +in the workspace." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-typescript-update-imports-on-file-move-enabled "prompt" + "Enable/disable automatic updating of import paths when you +rename or move a file in VS Code. Requires using TypeScript 2.9 +or newer in the workspace." + :type '(choice + (const "prompt") + (const "always") + (const "never")) + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-javascript-update-imports-on-file-move-enabled "prompt" + "Prompt on each rename." + :type '(choice + (const "prompt") + (const "always") + (const "never")) + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-typescript-auto-closing-tags t + "Enable/disable automatic closing of JSX tags. Requires using +TypeScript 3.0 or newer in the workspace." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-javascript-auto-closing-tags t + "Enable/disable automatic closing of JSX tags. Requires using +TypeScript 3.0 or newer in the workspace." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-javascript-suggest-enabled t + "Enabled/disable autocomplete suggestions." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-typescript-suggest-enabled t + "Enabled/disable autocomplete suggestions." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-typescript-surveys-enabled t + "Enabled/disable occasional surveys that help us improve VS +Code's JavaScript and TypeScript support." + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-javascript-display-enum-member-value-hints nil + "Show inlay hints for enum member values." + :type 'boolean + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-javascript-display-return-type-hints nil + "Show inlay hints for function return types." + :type 'boolean + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-javascript-display-parameter-type-hints nil + "Show inlay hints for function parameters." + :type 'boolean + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-javascript-display-parameter-name-hints "none" + "Level of hinting for parameter types." + :type '(choice (const :tag "none" "none") + (const :tag "literals" "literals") + (const :tag "all" "all")) + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-javascript-display-parameter-name-hints-when-argument-matches-name nil + "Show inlay hints for function parameters even when argument matches +name (e.g. `data' variable passed as `data' parameter)." + :type 'boolean + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-javascript-display-property-declaration-type-hints nil + "Show inlay hints for property declaration types." + :type 'boolean + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-javascript-display-variable-type-hints nil + "Show inlay hints for variable types." + :type 'boolean + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-javascript-completions-complete-function-calls t + "Complete function calls." + :type 'boolean + :package-version '(lsp-mode . "9.0.0")) + +(lsp-register-custom-settings + '(("javascript.autoClosingTags" lsp-javascript-auto-closing-tags t) + ("javascript.implicitProjectConfig.checkJs" lsp-javascript-implicit-project-config-check-js t) + ("javascript.implicitProjectConfig.experimentalDecorators" lsp-javascript-implicit-project-config-experimental-decorators t) + ("javascript.preferences.importModuleSpecifier" lsp-javascript-preferences-import-module-specifier) + ("javascript.preferences.quoteStyle" lsp-javascript-preferences-quote-style) + ("javascript.preferences.renameShorthandProperties" lsp-javascript-preferences-rename-shorthand-properties t) + ("javascript.referencesCodeLens.enabled" lsp-javascript-references-code-lens-enabled t) + ("javascript.suggest.autoImports" lsp-javascript-suggest-auto-imports t) + ("javascript.suggest.completeFunctionCalls" lsp-javascript-suggest-complete-function-calls t) + ("javascript.suggest.completeJSDocs" lsp-javascript-suggest-complete-js-docs t) + ("javascript.suggest.enabled" lsp-javascript-suggest-enabled t) + ("javascript.suggest.names" lsp-javascript-suggest-names t) + ("javascript.suggest.paths" lsp-javascript-suggest-paths t) + ("javascript.suggestionActions.enabled" lsp-javascript-suggestion-actions-enabled t) + ("javascript.updateImportsOnFileMove.enabled" lsp-javascript-update-imports-on-file-move-enabled) + ("javascript.validate.enable" lsp-javascript-validate-enable t) + ("javascript.format.enable" lsp-javascript-format-enable t) + ("javascript.format.insertSpaceAfterCommaDelimiter" lsp-javascript-format-insert-space-after-comma-delimiter t) + ("javascript.format.insertSpaceAfterConstructor" lsp-javascript-format-insert-space-after-constructor t) + ("javascript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions" lsp-javascript-format-insert-space-after-function-keyword-for-anonymous-functions t) + ("javascript.format.insertSpaceAfterKeywordsInControlFlowStatements" lsp-javascript-format-insert-space-after-keywords-in-control-flow-statements t) + ("javascript.format.insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces" lsp-javascript-format-insert-space-after-opening-and-before-closing-jsx-expression-braces t) + ("javascript.format.insertSpaceAfterOpeningAndBeforeClosingEmptyBraces" lsp-javascript-format-insert-space-after-opening-and-before-closing-empty-braces t) + ("javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces" lsp-javascript-format-insert-space-after-opening-and-before-closing-nonempty-braces t) + ("javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets" lsp-javascript-format-insert-space-after-opening-and-before-closing-nonempty-brackets t) + ("javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis" lsp-javascript-format-insert-space-after-opening-and-before-closing-nonempty-parenthesis t) + ("javascript.format.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces" lsp-javascript-format-insert-space-after-opening-and-before-closing-template-string-braces t) + ("javascript.format.insertSpaceAfterSemicolonInForStatements" lsp-javascript-format-insert-space-after-semicolon-in-for-statements t) + ("javascript.format.insertSpaceBeforeAndAfterBinaryOperators" lsp-javascript-format-insert-space-before-and-after-binary-operators t) + ("javascript.format.insertSpaceBeforeFunctionParenthesis" lsp-javascript-format-insert-space-before-function-parenthesis t) + ("javascript.format.placeOpenBraceOnNewLineForControlBlocks" lsp-javascript-format-place-open-brace-on-new-line-for-control-blocks t) + ("javascript.format.placeOpenBraceOnNewLineForFunctions" lsp-javascript-format-place-open-brace-on-new-line-for-functions t) + ("typescript.autoClosingTags" lsp-typescript-auto-closing-tags t) + ("typescript.check.npmIsInstalled" lsp-typescript-check-npm-is-installed t) + ("typescript.disableAutomaticTypeAcquisition" lsp-typescript-disable-automatic-type-acquisition t) + ("typescript.implementationsCodeLens.enabled" lsp-typescript-implementations-code-lens-enabled t) + ("typescript.locale" lsp-typescript-locale) + ("typescript.npm" lsp-typescript-npm) + ("typescript.preferences.importModuleSpecifier" lsp-typescript-preferences-import-module-specifier) + ("typescript.preferences.quoteStyle" lsp-typescript-preferences-quote-style) + ("typescript.preferences.renameShorthandProperties" lsp-typescript-preferences-rename-shorthand-properties t) + ("typescript.referencesCodeLens.enabled" lsp-typescript-references-code-lens-enabled t) + ("typescript.reportStyleChecksAsWarnings" lsp-typescript-report-style-checks-as-warnings t) + ("typescript.suggest.autoImports" lsp-typescript-suggest-auto-imports t) + ("typescript.suggest.completeFunctionCalls" lsp-typescript-suggest-complete-function-calls t) + ("typescript.suggest.completeJSDocs" lsp-typescript-suggest-complete-js-docs t) + ("typescript.suggest.enabled" lsp-typescript-suggest-enabled t) + ("typescript.suggest.paths" lsp-typescript-suggest-paths t) + ("typescript.suggestionActions.enabled" lsp-typescript-suggestion-actions-enabled t) + ("typescript.surveys.enabled" lsp-typescript-surveys-enabled t) + ("typescript.tsc.autoDetect" lsp-typescript-tsc-auto-detect) + ("typescript.tsdk" lsp-typescript-tsdk) + ("typescript.tsserver.log" lsp-typescript-tsserver-log) + ("typescript.tsserver.pluginPaths" lsp-typescript-tsserver-plugin-paths) + ("typescript.tsserver.trace" lsp-typescript-tsserver-trace) + ("typescript.updateImportsOnFileMove.enabled" lsp-typescript-update-imports-on-file-move-enabled) + ("typescript.validate.enable" lsp-typescript-validate-enable t) + ("typescript.format.enable" lsp-typescript-format-enable t) + ("typescript.format.insertSpaceAfterCommaDelimiter" lsp-typescript-format-insert-space-after-comma-delimiter t) + ("typescript.format.insertSpaceAfterConstructor" lsp-typescript-format-insert-space-after-constructor t) + ("typescript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions" lsp-typescript-format-insert-space-after-function-keyword-for-anonymous-functions t) + ("typescript.format.insertSpaceAfterKeywordsInControlFlowStatements" lsp-typescript-format-insert-space-after-keywords-in-control-flow-statements t) + ("typescript.format.insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces" lsp-typescript-format-insert-space-after-opening-and-before-closing-jsx-expression-braces t) + ("typescript.format.insertSpaceAfterOpeningAndBeforeClosingEmptyBraces" lsp-typescript-format-insert-space-after-opening-and-before-closing-empty-braces t) + ("typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces" lsp-typescript-format-insert-space-after-opening-and-before-closing-nonempty-braces t) + ("typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets" lsp-typescript-format-insert-space-after-opening-and-before-closing-nonempty-brackets t) + ("typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis" lsp-typescript-format-insert-space-after-opening-and-before-closing-nonempty-parenthesis t) + ("typescript.format.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces" lsp-typescript-format-insert-space-after-opening-and-before-closing-template-string-braces t) + ("typescript.format.insertSpaceAfterSemicolonInForStatements" lsp-typescript-format-insert-space-after-semicolon-in-for-statements t) + ("typescript.format.insertSpaceAfterTypeAssertion" lsp-typescript-format-insert-space-after-type-assertion t) + ("typescript.format.insertSpaceBeforeAndAfterBinaryOperators" lsp-typescript-format-insert-space-before-and-after-binary-operators t) + ("typescript.format.insertSpaceBeforeFunctionParenthesis" lsp-typescript-format-insert-space-before-function-parenthesis t) + ("typescript.format.placeOpenBraceOnNewLineForControlBlocks" lsp-typescript-format-place-open-brace-on-new-line-for-control-blocks t) + ("typescript.format.placeOpenBraceOnNewLineForFunctions" lsp-typescript-format-place-open-brace-on-new-line-for-functions t) + ("typescript.inlayHints.includeInlayEnumMemberValueHints" lsp-javascript-display-enum-member-value-hints t) + ("typescript.inlayHints.includeInlayFunctionLikeReturnTypeHints" lsp-javascript-display-return-type-hints t) + ("typescript.inlayHints.includeInlayFunctionParameterTypeHints" lsp-javascript-display-parameter-type-hints t) + ("typescript.inlayHints.includeInlayParameterNameHints" lsp-javascript-display-parameter-name-hints nil) + ("typescript.inlayHints.includeInlayParameterNameHintsWhenArgumentMatchesName" lsp-javascript-display-parameter-name-hints-when-argument-matches-name t) + ("typescript.inlayHints.includeInlayPropertyDeclarationTypeHints" lsp-javascript-display-property-declaration-type-hints t) + ("typescript.inlayHints.includeInlayVariableTypeHints" lsp-javascript-display-variable-type-hints t) + ("javascript.inlayHints.includeInlayEnumMemberValueHints" lsp-javascript-display-enum-member-value-hints t) + ("javascript.inlayHints.includeInlayFunctionLikeReturnTypeHints" lsp-javascript-display-return-type-hints t) + ("javascript.inlayHints.includeInlayFunctionParameterTypeHints" lsp-javascript-display-parameter-type-hints t) + ("javascript.inlayHints.includeInlayParameterNameHints" lsp-javascript-display-parameter-name-hints nil) + ("javascript.inlayHints.includeInlayParameterNameHintsWhenArgumentMatchesName" lsp-javascript-display-parameter-name-hints-when-argument-matches-name t) + ("javascript.inlayHints.includeInlayPropertyDeclarationTypeHints" lsp-javascript-display-property-declaration-type-hints t) + ("javascript.inlayHints.includeInlayVariableTypeHints" lsp-javascript-display-variable-type-hints t) + ("completions.completeFunctionCalls" lsp-javascript-completions-complete-function-calls t))) + +(lsp-dependency 'typescript-language-server + '(:system lsp-clients-typescript-tls-path) + '(:npm :package "typescript-language-server" + :path "typescript-language-server")) + +(lsp-dependency 'typescript + '(:system "tsserver") + '(:npm :package "typescript" + :path "tsserver")) + +(defun lsp-javascript--rename (_workspace args) + (let ((path (lsp--uri-to-path (lsp-get (lsp-get args :textDocument) :uri)))) + (if (f-exists? path) + (with-current-buffer (find-file path) + (goto-char (lsp--position-to-point + (lsp-get args :position)))) + (error "There is no file %s" path))) + (call-interactively #'lsp-rename) + nil) + +(defun lsp-javascript-rename-file () + "Rename current file and all it's references in other files." + (interactive) + (let* ((name (buffer-name)) + (old (buffer-file-name)) + (basename (file-name-nondirectory old))) + (unless (and old (file-exists-p old)) + (error "Buffer '%s' is not visiting a file." name)) + (let ((new (read-file-name "New name: " (file-name-directory old) basename nil basename))) + (when (get-file-buffer new) + (error "A buffer named '%s' already exists." new)) + (when (file-exists-p new) + (error "A file named '%s' already exists." new)) + (lsp--send-execute-command + "_typescript.applyRenameFile" + (vector (list :sourceUri (lsp--buffer-uri) + :targetUri (lsp--path-to-uri new)))) + (mkdir (file-name-directory new) t) + (rename-file old new) + (rename-buffer new) + (set-visited-file-name new) + (set-buffer-modified-p nil) + (lsp-disconnect) + (setq-local lsp-buffer-uri nil) + (lsp) + (lsp--info "Renamed '%s' to '%s'." name (file-name-nondirectory new))))) + +(defun lsp-javascript-initialized? () + (when-let ((workspace (lsp-find-workspace 'ts-ls (buffer-file-name)))) + (eq 'initialized (lsp--workspace-status workspace)))) + +(defun lsp-clients-typescript-require-resolve (&optional dir) + "Get the location of the typescript. +Use Node.js require. +The node_modules directory structure is suspect +and should be trusted as little as possible. +If you call require in Node.js, +it should take into account the various hooks. +For example, yarn PnP. + +Optional argument DIR specifies the working directory +to run the command in." + (when-let* + ((default-directory (or dir default-directory)) + (output + (string-trim-right + (shell-command-to-string + "node -e \"console.log(require.resolve('typescript'))\""))) + (not-empty (not (string-empty-p output)))) + (f-parent output))) + +(defun lsp-clients-typescript-server-path () + "Return the TS server path based on settings." + (if-let* ((use-project-ts lsp-clients-typescript-prefer-use-project-ts-server) + (server-path (lsp-clients-typescript-require-resolve)) + (server-path-exist (f-exists? server-path))) + server-path + (if (memq system-type '(cygwin windows-nt ms-dos)) + ;; The Windows environment does not recognize the top-level PATH returned by `lsp-package-path', + ;; so the real PATH is returned through Node.js. + (lsp-clients-typescript-require-resolve (f-parent (lsp-package-path 'typescript))) + (lsp-package-path 'typescript)))) + +(lsp-register-client + (make-lsp-client :new-connection (lsp-stdio-connection (lambda () + `(,(lsp-package-path 'typescript-language-server) + ,@lsp-clients-typescript-server-args))) + :activation-fn 'lsp-typescript-javascript-tsx-jsx-activate-p + :priority -2 + :completion-in-comments? t + :initialization-options (lambda () + (append + (when lsp-clients-typescript-disable-automatic-typing-acquisition + (list :disableAutomaticTypingAcquisition lsp-clients-typescript-disable-automatic-typing-acquisition)) + (when lsp-clients-typescript-log-verbosity + (list :logVerbosity lsp-clients-typescript-log-verbosity)) + (when lsp-clients-typescript-max-ts-server-memory + (list :maxTsServerMemory lsp-clients-typescript-max-ts-server-memory)) + (when lsp-clients-typescript-npm-location + (list :npmLocation lsp-clients-typescript-npm-location)) + (when lsp-clients-typescript-plugins + (list :plugins lsp-clients-typescript-plugins)) + (when lsp-clients-typescript-preferences + (list :preferences lsp-clients-typescript-preferences)) + `(:tsserver ( :path ,(lsp-clients-typescript-server-path) + ,@lsp-clients-typescript-tsserver)))) + :initialized-fn (lambda (workspace) + (with-lsp-workspace workspace + (lsp--set-configuration + (ht-merge (lsp-configuration-section "javascript") + (lsp-configuration-section "typescript") + (lsp-configuration-section "completions") + (lsp-configuration-section "diagnostics")))) + (let ((caps (lsp--workspace-server-capabilities workspace)) + (format-enable (or lsp-javascript-format-enable lsp-typescript-format-enable))) + (lsp:set-server-capabilities-document-formatting-provider? caps format-enable) + (lsp:set-server-capabilities-document-range-formatting-provider? caps format-enable))) + :ignore-messages '("readFile .*? requested by TypeScript but content not available") + :server-id 'ts-ls + :request-handlers (ht ("_typescript.rename" #'lsp-javascript--rename)) + :download-server-fn (lambda (_client callback error-callback _update?) + (lsp-package-ensure + 'typescript + (-partial #'lsp-package-ensure + 'typescript-language-server + callback + error-callback) + error-callback)))) + + +(defgroup lsp-flow nil + "LSP support for the Flow Javascript type checker." + :group 'lsp-mode + :link '(url-link "https://flow.org")) + +(defcustom lsp-clients-flow-server "flow" + "The Flow executable to use. +Leave as just the executable name to use the default behavior of +finding the executable with variable `exec-path'." + :group 'lsp-flow + :risky t + :type 'file) + +(defcustom lsp-clients-flow-server-args '("lsp") + "Extra arguments for starting the Flow language server." + :group 'lsp-flow + :risky t + :type '(repeat string)) + +(defun lsp-clients-flow-tag-file-present-p (file-name) + "Check if the '// @flow' or `/* @flow */' tag is present in +the contents of FILE-NAME." + (if-let ((buffer (find-buffer-visiting file-name))) + (with-current-buffer buffer + (lsp-clients-flow-tag-string-present-p)) + (with-temp-buffer + (insert-file-contents file-name) + (lsp-clients-flow-tag-string-present-p)))) + +(defun lsp-clients-flow-tag-string-present-p () + "Helper for `lsp-clients-flow-tag-file-present-p' that works +with the file contents." + (save-excursion + (goto-char (point-min)) + (let (stop found) + (while (not stop) + (unless (re-search-forward "[^\n[:space:]]" nil t) + (setq stop t)) + (if (= (point) (point-min)) (setq stop t) (backward-char)) + (cond ((or (looking-at-p "//+[ ]*@flow") + (looking-at-p "/\\**[ ]*@flow") + (looking-at-p "[ ]*\\*[ ]*@flow")) + (setq found t) (setq stop t)) + ((or (looking-at-p "//") (looking-at-p "*")) + (forward-line)) + ((looking-at-p "/\\*") + (save-excursion + (unless (re-search-forward "*/" nil t) (setq stop t))) + (forward-line)) + (t (setq stop t)))) + found))) + +(defun lsp-clients-flow-project-p (file-name) + "Check if FILE-NAME is part of a Flow project, that is, if +there is a .flowconfig file in the folder hierarchy." + (locate-dominating-file file-name ".flowconfig")) + +(defun lsp-clients-flow-activate-p (file-name _mode) + "Check if the Flow language server should be enabled for a +particular FILE-NAME and MODE." + (and (derived-mode-p 'js-mode 'web-mode 'js2-mode 'flow-js2-mode 'rjsx-mode) + (not (derived-mode-p 'json-mode)) + (or (lsp-clients-flow-project-p file-name) + (lsp-clients-flow-tag-file-present-p file-name)))) + +(lsp-register-client + (make-lsp-client :new-connection + (lsp-stdio-connection (lambda () + (cons lsp-clients-flow-server + lsp-clients-flow-server-args))) + :priority -1 + :activation-fn 'lsp-clients-flow-activate-p + :server-id 'flow-ls)) + +(defgroup lsp-deno nil + "LSP support for the Deno language server." + :group 'lsp-mode + :link '(url-link "https://deno.land/")) + +(defcustom lsp-clients-deno-server "deno" + "The Deno executable to use. +Leave as just the executable name to use the default behavior of +finding the executable with variable `exec-path'." + :group 'lsp-deno + :risky t + :type 'file + :package-version '(lsp-mode . "8.0.0")) + +(defcustom lsp-clients-deno-server-args '("lsp") + "Extra arguments for starting the Deno language server." + :group 'lsp-deno + :risky t + :type '(repeat string) + :package-version '(lsp-mode . "8.0.0")) + +(defcustom lsp-clients-deno-enable-lint t + "Controls if linting information will be provided by the Deno Language Server." + :group 'lsp-deno + :risky t + :type 'boolean + :package-version '(lsp-mode . "8.0.0")) + +(defcustom lsp-clients-deno-enable-code-lens-references t + "Enables or disables the display of code lens information." + :group 'lsp-deno + :risky t + :type 'boolean + :package-version '(lsp-mode . "8.0.0")) + +(defcustom lsp-clients-deno-enable-code-lens-references-all-functions t + "Enables or disables the display of code lens information for all functions. +Setting this variable to `non-nil' implicitly enables +`lsp-clients-deno-enable-code-lens-references'." + :group 'lsp-deno + :risky t + :type 'boolean + :package-version '(lsp-mode . "8.0.0")) + +(defcustom lsp-clients-deno-enable-code-lens-implementations t + "Enables or disables the display of code lens information for implementations." + :group 'lsp-deno + :risky t + :type 'boolean + :package-version '(lsp-mode . "8.0.0")) + +(defcustom lsp-clients-deno-config nil + "The file path to a tsconfig.json file. +The path can be either be relative to the workspace, or an +absolute path. + +Examples: `./tsconfig.json', +`/path/to/tsconfig.json', `C:\\path\\to\\tsconfig.json'" + :group 'lsp-deno + :risky t + :type 'file + :package-version '(lsp-mode . "8.0.0")) + +(defcustom lsp-clients-deno-import-map nil + "The file path to an import map. +Import maps provide a way to relocate modules based on their +specifiers. The path can either be relative to the workspace, or +an absolute path. + +Examples: `./import-map.json', +`/path/to/import-map.json', `C:\\path\\to\\import-map.json'." + :group 'lsp-deno + :risky t + :type 'file + :package-version '(lsp-mode . "8.0.0")) + +(defcustom lsp-clients-deno-enable-unstable nil + "Controls if code will be type checked with Deno's unstable APIs." + :group 'lsp-deno + :risky t + :type 'boolean + :package-version '(lsp-mode . "8.0.0")) + +(defun lsp-clients-deno--make-init-options () + "Initialization options for the Deno language server." + `( :enable t + :config ,lsp-clients-deno-config + :importMap ,lsp-clients-deno-import-map + :lint ,(lsp-json-bool lsp-clients-deno-enable-lint) + :unstable ,(lsp-json-bool lsp-clients-deno-enable-unstable) + :codeLens ( :implementations ,(lsp-json-bool lsp-clients-deno-enable-code-lens-implementations) + :references ,(lsp-json-bool (or lsp-clients-deno-enable-code-lens-references + lsp-clients-deno-enable-code-lens-references-all-functions)) + :referencesAllFunctions ,(lsp-json-bool lsp-clients-deno-enable-code-lens-references-all-functions)))) + +(lsp-register-client + (make-lsp-client :new-connection + (lsp-stdio-connection (lambda () + (cons lsp-clients-deno-server + lsp-clients-deno-server-args))) + :initialization-options #'lsp-clients-deno--make-init-options + :priority -5 + :activation-fn #'lsp-typescript-javascript-tsx-jsx-activate-p + :server-id 'deno-ls)) + +(lsp-consistency-check lsp-javascript) + +(provide 'lsp-javascript) +;;; lsp-javascript.el ends here diff --git a/emacs/elpa/lsp-mode-20240531.2326/lsp-javascript.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-javascript.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-jq.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-jq.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-jq.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-jq.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-json.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-json.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-json.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-json.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-jsonnet.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-jsonnet.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-jsonnet.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-jsonnet.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-kotlin.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-kotlin.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-kotlin.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-kotlin.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-lens.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-lens.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-lens.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-lens.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-lisp.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-lisp.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-lisp.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-lisp.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-lua.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-lua.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-lua.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-lua.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-magik.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-magik.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-magik.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-magik.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-markdown.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-markdown.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-markdown.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-markdown.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-marksman.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-marksman.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-marksman.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-marksman.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-mdx.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-mdx.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-mdx.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-mdx.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-meson.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-meson.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-meson.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-meson.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-mint.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-mint.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-mint.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-mint.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-mode-autoloads.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-mode-autoloads.el diff --git a/emacs/elpa/lsp-mode-20240531.2326/lsp-mode-pkg.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-mode-pkg.el @@ -0,0 +1,21 @@ +(define-package "lsp-mode" "20240531.2326" "LSP mode" + '((emacs "27.1") + (dash "2.18.0") + (f "0.20.0") + (ht "2.3") + (spinner "1.7.3") + (markdown-mode "2.3") + (lv "0") + (eldoc "1.11")) + :commit "acad044ebc343c1eff0d9a875a13fb34ad113a9e" :authors + '(("Vibhav Pant, Fangrui Song, Ivan Yonchovski")) + :maintainers + '(("Vibhav Pant, Fangrui Song, Ivan Yonchovski")) + :maintainer + '("Vibhav Pant, Fangrui Song, Ivan Yonchovski") + :keywords + '("languages") + :url "https://github.com/emacs-lsp/lsp-mode") +;; Local Variables: +;; no-byte-compile: t +;; End: diff --git a/emacs/elpa/lsp-mode-20240531.2326/lsp-mode.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-mode.el @@ -0,0 +1,9797 @@ +;;; lsp-mode.el --- LSP mode -*- lexical-binding: t; -*- + +;; Copyright (C) 2020-2024 emacs-lsp maintainers + +;; Author: Vibhav Pant, Fangrui Song, Ivan Yonchovski +;; Keywords: languages +;; Package-Requires: ((emacs "27.1") (dash "2.18.0") (f "0.20.0") (ht "2.3") (spinner "1.7.3") (markdown-mode "2.3") (lv "0") (eldoc "1.11")) +;; Version: 9.0.1 + +;; URL: https://github.com/emacs-lsp/lsp-mode +;; 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 <https://www.gnu.org/licenses/>. + +;;; Commentary: + +;; Emacs client/library for the Language Server Protocol + +;;; Code: + +(require 'cl-generic) +(require 'cl-lib) +(require 'compile) +(require 'dash) +(require 'epg) +(require 'ewoc) +(require 'f) +(require 'filenotify) +(require 'files) +(require 'ht) +(require 'imenu) +(require 'inline) +(require 'json) +(require 'lv) +(require 'markdown-mode) +(require 'network-stream) +(require 'pcase) +(require 'rx) +(require 's) +(require 'seq) +(require 'spinner) +(require 'subr-x) +(require 'tree-widget) +(require 'url-parse) +(require 'url-util) +(require 'widget) +(require 'xref) +(require 'minibuffer) +(require 'help-mode) +(require 'lsp-protocol) + +(defgroup lsp-mode nil + "Language Server Protocol client." + :group 'tools + :tag "Language Server (lsp-mode)") + +(declare-function evil-set-command-property "ext:evil-common") +(declare-function projectile-project-root "ext:projectile") +(declare-function yas-expand-snippet "ext:yasnippet") +(declare-function dap-mode "ext:dap-mode") +(declare-function dap-auto-configure-mode "ext:dap-mode") + +(defvar yas-inhibit-overlay-modification-protection) +(defvar yas-indent-line) +(defvar yas-wrap-around-region) +(defvar yas-also-auto-indent-first-line) +(defvar dap-auto-configure-mode) +(defvar dap-ui-menu-items) +(defvar company-minimum-prefix-length) + +(defconst lsp--message-type-face + `((1 . ,compilation-error-face) + (2 . ,compilation-warning-face) + (3 . ,compilation-message-face) + (4 . ,compilation-info-face))) + +(defconst lsp--errors + '((-32700 "Parse Error") + (-32600 "Invalid Request") + (-32601 "Method not Found") + (-32602 "Invalid Parameters") + (-32603 "Internal Error") + (-32099 "Server Start Error") + (-32000 "Server End Error") + (-32002 "Server Not Initialized") + (-32001 "Unknown Error Code") + (-32800 "Request Cancelled")) + "Alist of error codes to user friendly strings.") + +(defconst lsp--empty-ht (make-hash-table)) + +(eval-and-compile + (defun dash-expand:&lsp-wks (key source) + `(,(intern-soft (format "lsp--workspace-%s" (eval key))) ,source)) + + (defun dash-expand:&lsp-cln (key source) + `(,(intern-soft (format "lsp--client-%s" (eval key))) ,source))) + +(define-obsolete-variable-alias 'lsp-print-io 'lsp-log-io "lsp-mode 6.1") + +(defcustom lsp-log-io nil + "If non-nil, log all messages from the language server to a *lsp-log* buffer." + :group 'lsp-mode + :type 'boolean) + +(defcustom lsp-log-io-allowlist-methods '() + "The methods to filter before print to lsp-log-io." + :group 'lsp-mode + :type '(repeat string) + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-log-max message-log-max + "Maximum number of lines to keep in the log buffer. +If nil, disable message logging. If t, log messages but don’t truncate +the buffer when it becomes large." + :group 'lsp-mode + :type '(choice (const :tag "Disable" nil) + (integer :tag "lines") + (const :tag "Unlimited" t)) + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-io-messages-max t + "Maximum number of messages that can be locked in a `lsp-io' buffer." + :group 'lsp-mode + :type '(choice (const :tag "Unlimited" t) + (integer :tag "Messages")) + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-keep-workspace-alive t + "If non nil keep workspace alive when the last workspace buffer is closed." + :group 'lsp-mode + :type 'boolean) + +(defcustom lsp-enable-snippet t + "Enable/disable snippet completion support." + :group 'lsp-completion + :type 'boolean) + +(defcustom lsp-enable-folding t + "Enable/disable code folding support." + :group 'lsp-mode + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(define-obsolete-variable-alias 'lsp-enable-semantic-highlighting 'lsp-semantic-tokens-enable "lsp-mode 8.0.0") + +(defcustom lsp-semantic-tokens-enable nil + "Enable/disable support for semantic tokens. +As defined by the Language Server Protocol 3.16." + :group 'lsp-semantic-tokens + :type 'boolean) + +(defcustom lsp-folding-range-limit nil + "The maximum number of folding ranges to receive from the language server." + :group 'lsp-mode + :type '(choice (const :tag "No limit." nil) + (integer :tag "Number of lines.")) + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-folding-line-folding-only nil + "If non-nil, only fold complete lines." + :group 'lsp-mode + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-client-packages + '( ccls lsp-actionscript lsp-ada lsp-angular lsp-ansible lsp-asm lsp-astro + lsp-autotools lsp-awk lsp-bash lsp-beancount lsp-bufls lsp-clangd + lsp-clojure lsp-cmake lsp-cobol lsp-credo lsp-crystal lsp-csharp lsp-css + lsp-cucumber lsp-cypher lsp-d lsp-dart lsp-dhall lsp-docker lsp-dockerfile + lsp-elixir lsp-elm lsp-emmet lsp-erlang lsp-eslint lsp-fortran lsp-fsharp + lsp-gdscript lsp-gleam lsp-glsl lsp-go lsp-golangci-lint lsp-grammarly + lsp-graphql lsp-groovy lsp-hack lsp-haskell lsp-haxe lsp-idris lsp-java + lsp-javascript lsp-jq lsp-json lsp-kotlin lsp-latex lsp-lisp lsp-ltex + lsp-lua lsp-magik lsp-markdown lsp-marksman lsp-mdx lsp-meson lsp-metals lsp-mint + lsp-mojo lsp-move lsp-mssql lsp-nginx lsp-nim lsp-nix lsp-nushell lsp-ocaml + lsp-openscad lsp-pascal lsp-perl lsp-perlnavigator lsp-php lsp-pls + lsp-purescript lsp-pwsh lsp-pyls lsp-pylsp lsp-pyright lsp-python-ms + lsp-qml lsp-r lsp-racket lsp-remark lsp-rf lsp-rubocop lsp-ruby-lsp + lsp-ruby-syntax-tree lsp-ruff-lsp lsp-rust lsp-semgrep lsp-shader + lsp-solargraph lsp-solidity lsp-sonarlint lsp-sorbet lsp-sourcekit + lsp-sql lsp-sqls lsp-steep lsp-svelte lsp-tailwindcss lsp-terraform + lsp-tex lsp-tilt lsp-toml lsp-trunk lsp-ttcn3 lsp-typeprof lsp-v + lsp-vala lsp-verilog lsp-vetur lsp-vhdl lsp-vimscript lsp-volar lsp-wgsl + lsp-xml lsp-yaml lsp-yang lsp-zig) + "List of the clients to be automatically required." + :group 'lsp-mode + :type '(repeat symbol)) + +(defcustom lsp-progress-via-spinner t + "If non-nil, display LSP $/progress reports via a spinner in the modeline." + :group 'lsp-mode + :type 'boolean) + +(defcustom lsp-progress-spinner-type 'progress-bar + "Holds the type of spinner to be used in the mode-line. +Takes a value accepted by `spinner-start'." + :group 'lsp-mode + :type `(choice :tag "Choose a spinner by name" + ,@(mapcar (lambda (c) (list 'const (car c))) + spinner-types))) + +(defvar-local lsp-use-workspace-root-for-server-default-directory nil + "Use `lsp-workspace-root' for `default-directory' when starting LSP process.") + +(defvar-local lsp--cur-workspace nil) + +(defvar-local lsp--cur-version 0) +(defvar-local lsp--virtual-buffer-connections nil) +(defvar-local lsp--virtual-buffer nil) +(defvar lsp--virtual-buffer-mappings (ht)) + +(defvar lsp--uri-file-prefix (pcase system-type + (`windows-nt "file:///") + (_ "file://")) + "Prefix for a file-uri.") + +(defvar-local lsp-buffer-uri nil + "If set, return it instead of calculating it using `buffer-file-name'.") + +(define-error 'lsp-error "Unknown lsp-mode error") +(define-error 'lsp-empty-response-error + "Empty response from the language server" 'lsp-error) +(define-error 'lsp-timed-out-error + "Timed out while waiting for a response from the language server" 'lsp-error) +(define-error 'lsp-capability-not-supported + "Capability not supported by the language server" 'lsp-error) +(define-error 'lsp-file-scheme-not-supported + "Unsupported file scheme" 'lsp-error) +(define-error 'lsp-client-already-exists-error + "A client with this server-id already exists" 'lsp-error) +(define-error 'lsp-no-code-actions + "No code actions" 'lsp-error) + +(defcustom lsp-auto-guess-root nil + "Automatically guess the project root using projectile/project. +Do *not* use this setting unless you are familiar with `lsp-mode' +internals and you are sure that all of your projects are +following `projectile'/`project.el' conventions." + :group 'lsp-mode + :type 'boolean) + +(defcustom lsp-guess-root-without-session nil + "Ignore the session file when calculating the project root. +You almost always want to set lsp-auto-guess-root too. +Do *not* use this setting unless you are familiar with `lsp-mode' +internals and you are sure that all of your projects are +following `projectile'/`project.el' conventions." + :group 'lsp-mode + :type 'boolean) + +(defcustom lsp-restart 'interactive + "Defines how server-exited events must be handled." + :group 'lsp-mode + :type '(choice (const interactive) + (const auto-restart) + (const ignore))) + +(defcustom lsp-session-file (expand-file-name (locate-user-emacs-file ".lsp-session-v1")) + "File where session information is stored." + :group 'lsp-mode + :type 'file) + +(defcustom lsp-auto-configure t + "Auto configure `lsp-mode' main features. +When set to t `lsp-mode' will auto-configure completion, +code-actions, breadcrumb, `flycheck', `flymake', `imenu', symbol highlighting, +lenses, links, and so on. + +For finer granularity you may use `lsp-enable-*' properties." + :group 'lsp-mode + :type 'boolean + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-disabled-clients nil + "A list of disabled/blocklisted clients. +Each entry in the list can be either: +a symbol, the server-id for the LSP client, or +a cons pair (MAJOR-MODE . CLIENTS), where MAJOR-MODE is the major-mode, +and CLIENTS is either a client or a list of clients. + +This option can also be used as a file- or directory-local variable to +disable a language server for individual files or directories/projects +respectively." + :group 'lsp-mode + :type '(repeat (symbol)) + :safe 'listp + :package-version '(lsp-mode . "6.1")) + +(defvar lsp-clients (make-hash-table :test 'eql) + "Hash table server-id -> client. +It contains all of the clients that are currently registered.") + +(defvar lsp-enabled-clients nil + "List of clients allowed to be used for projects. +When nil, all registered clients are considered candidates.") + +(defvar lsp-last-id 0 + "Last request id.") + +(defcustom lsp-before-initialize-hook nil + "List of functions to be called before a Language Server has been initialized +for a new workspace." + :type 'hook + :group 'lsp-mode) + +(defcustom lsp-after-initialize-hook nil + "List of functions to be called after a Language Server has been initialized +for a new workspace." + :type 'hook + :group 'lsp-mode) + +(defcustom lsp-before-open-hook nil + "List of functions to be called before a new file with LSP support is opened." + :type 'hook + :group 'lsp-mode) + +(defcustom lsp-after-open-hook nil + "List of functions to be called after a new file with LSP support is opened." + :type 'hook + :group 'lsp-mode) + +(defcustom lsp-enable-file-watchers t + "If non-nil lsp-mode will watch the files in the workspace if +the server has requested that." + :type 'boolean + :group 'lsp-mode + :package-version '(lsp-mode . "6.1")) +;;;###autoload(put 'lsp-enable-file-watchers 'safe-local-variable #'booleanp) + +(define-obsolete-variable-alias 'lsp-file-watch-ignored 'lsp-file-watch-ignored-directories "8.0.0") + +(defcustom lsp-file-watch-ignored-directories + '(; SCM tools + "[/\\\\]\\.git\\'" + "[/\\\\]\\.github\\'" + "[/\\\\]\\.gitlab\\'" + "[/\\\\]\\.circleci\\'" + "[/\\\\]\\.hg\\'" + "[/\\\\]\\.bzr\\'" + "[/\\\\]_darcs\\'" + "[/\\\\]\\.svn\\'" + "[/\\\\]_FOSSIL_\\'" + ;; IDE or build tools + "[/\\\\]\\.idea\\'" + "[/\\\\]\\.ensime_cache\\'" + "[/\\\\]\\.eunit\\'" + "[/\\\\]node_modules" + "[/\\\\]\\.yarn\\'" + "[/\\\\]\\.fslckout\\'" + "[/\\\\]\\.tox\\'" + "[/\\\\]\\.nox\\'" + "[/\\\\]dist\\'" + "[/\\\\]dist-newstyle\\'" + "[/\\\\]\\.stack-work\\'" + "[/\\\\]\\.bloop\\'" + "[/\\\\]\\.metals\\'" + "[/\\\\]target\\'" + "[/\\\\]\\.ccls-cache\\'" + "[/\\\\]\\.vs\\'" + "[/\\\\]\\.vscode\\'" + "[/\\\\]\\.venv\\'" + "[/\\\\]\\.mypy_cache\\'" + "[/\\\\]\\.pytest_cache\\'" + ;; Swift Package Manager + "[/\\\\]\\.build\\'" + ;; Python + "[/\\\\]__pycache__\\'" + ;; Autotools output + "[/\\\\]\\.deps\\'" + "[/\\\\]build-aux\\'" + "[/\\\\]autom4te.cache\\'" + "[/\\\\]\\.reference\\'" + ;; Bazel + "[/\\\\]bazel-[^/\\\\]+\\'" + ;; CSharp + "[/\\\\]\\.cache[/\\\\]lsp-csharp\\'" + "[/\\\\]\\.meta\\'" + "[/\\\\]\\.nuget\\'" + ;; Unity + "[/\\\\]Library\\'" + ;; Clojure + "[/\\\\]\\.lsp\\'" + "[/\\\\]\\.clj-kondo\\'" + "[/\\\\]\\.shadow-cljs\\'" + "[/\\\\]\\.babel_cache\\'" + "[/\\\\]\\.cpcache\\'" + "[/\\\\]\\checkouts\\'" + ;; Gradle + "[/\\\\]\\.gradle\\'" + ;; Maven + "[/\\\\]\\.m2\\'" + ;; .Net Core build-output + "[/\\\\]bin/Debug\\'" + "[/\\\\]obj\\'" + ;; OCaml and Dune + "[/\\\\]_opam\\'" + "[/\\\\]_build\\'" + ;; Elixir + "[/\\\\]\\.elixir_ls\\'" + ;; Elixir Credo + "[/\\\\]\\.elixir-tools\\'" + ;; terraform and terragrunt + "[/\\\\]\\.terraform\\'" + "[/\\\\]\\.terragrunt-cache\\'" + ;; nix-direnv + "[/\\\\]\\result" + "[/\\\\]\\result-bin" + "[/\\\\]\\.direnv\\'") + "List of regexps matching directory paths which won't be monitored when +creating file watches. Customization of this variable is only honored at +the global level or at a root of an lsp workspace." + :group 'lsp-mode + :type '(repeat string) + :package-version '(lsp-mode . "8.0.0")) + +(define-obsolete-function-alias 'lsp-file-watch-ignored 'lsp-file-watch-ignored-directories "7.0.1") + +(defun lsp-file-watch-ignored-directories () + lsp-file-watch-ignored-directories) + +;; Allow lsp-file-watch-ignored-directories as a file or directory-local variable +;;;###autoload(put 'lsp-file-watch-ignored-directories 'safe-local-variable 'lsp--string-listp) + +(defcustom lsp-file-watch-ignored-files + '( + ;; Flycheck tempfiles + "[/\\\\]flycheck_[^/\\\\]+\\'" + ;; lockfiles + "[/\\\\]\\.#[^/\\\\]+\\'" + ;; backup files + "[/\\\\][^/\\\\]+~\\'" ) + "List of regexps matching files for which change events will +not be sent to the server. + +This setting has no impact on whether a file-watch is created for +a directory; it merely prevents notifications pertaining to +matched files from being sent to the server. To prevent a +file-watch from being created for a directory, customize +`lsp-file-watch-ignored-directories' + +Customization of this variable is only honored at the global +level or at a root of an lsp workspace." + :group 'lsp-mode + :type '(repeat string) + :package-version '(lsp-mode . "8.0.0")) + +;; Allow lsp-file-watch-ignored-files as a file or directory-local variable +;;;###autoload(put 'lsp-file-watch-ignored-files 'safe-local-variable 'lsp--string-listp) + +(defcustom lsp-after-uninitialized-functions nil + "List of functions to be called after a Language Server has been uninitialized." + :type 'hook + :group 'lsp-mode + :package-version '(lsp-mode . "6.3")) + +(defconst lsp--sync-full 1) +(defconst lsp--sync-incremental 2) + +(defcustom lsp-debounce-full-sync-notifications t + "If non-nil debounce full sync events. +This flag affects only servers which do not support incremental updates." + :type 'boolean + :group 'lsp-mode + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-debounce-full-sync-notifications-interval 1.0 + "Time to wait before sending full sync synchronization after buffer modification." + :type 'float + :group 'lsp-mode + :package-version '(lsp-mode . "6.1")) + +(defvar lsp--stderr-index 0) + +(defvar lsp--delayed-requests nil) +(defvar lsp--delay-timer nil) + +(defcustom lsp-document-sync-method nil + "How to sync the document with the language server." + :type '(choice (const :tag "Documents are synced by always sending the full content of the document." lsp--sync-full) + (const :tag "Documents are synced by always sending incremental changes to the document." lsp--sync-incremental) + (const :tag "Use the method recommended by the language server." nil)) + :group 'lsp-mode) + +(defcustom lsp-auto-execute-action t + "Auto-execute single action." + :type 'boolean + :group 'lsp-mode) + +(defcustom lsp-enable-links t + "If non-nil, all references to links in a file will be made clickable, if +supported by the language server." + :type 'boolean + :group 'lsp-mode + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-enable-imenu t + "If non-nil, automatically enable `imenu' integration when server provides +`textDocument/documentSymbol'." + :type 'boolean + :group 'lsp-mode + :package-version '(lsp-mode . "6.2")) + +(defcustom lsp-enable-dap-auto-configure t + "If non-nil, enable `dap-auto-configure-mode`." + :type 'boolean + :group 'lsp-mode + :package-version '(lsp-mode . "7.0")) + +(defcustom lsp-eldoc-enable-hover t + "If non-nil, `eldoc' will display hover info when it is present." + :type 'boolean + :group 'lsp-mode) + +(defcustom lsp-eldoc-render-all nil + "Display all of the info returned by document/onHover. +If this is set to nil, `eldoc' will show only the symbol information." + :type 'boolean + :group 'lsp-mode) + +(define-obsolete-variable-alias 'lsp-enable-completion-at-point + 'lsp-completion-enable "lsp-mode 7.0.1") + +(defcustom lsp-completion-enable t + "Enable `completion-at-point' integration." + :type 'boolean + :group 'lsp-completion) + +(defcustom lsp-enable-symbol-highlighting t + "Highlight references of the symbol at point." + :type 'boolean + :group 'lsp-mode) + +(defcustom lsp-enable-xref t + "Enable xref integration." + :type 'boolean + :group 'lsp-mode) + +(defcustom lsp-references-exclude-definition nil + "If non-nil, exclude declarations when finding references." + :type 'boolean + :group 'lsp-mode) + +(defcustom lsp-enable-indentation t + "Indent regions using the file formatting functionality provided by the +language server." + :type 'boolean + :group 'lsp-mode) + +(defcustom lsp-enable-on-type-formatting t + "Enable `textDocument/onTypeFormatting' integration." + :type 'boolean + :group 'lsp-mode) + +(defcustom lsp-enable-text-document-color t + "Enable `textDocument/documentColor' integration." + :type 'boolean + :group 'lsp-mode) + +(defcustom lsp-before-save-edits t + "If non-nil, `lsp-mode' will apply edits suggested by the language server +before saving a document." + :type 'boolean + :group 'lsp-mode) + +(defcustom lsp-after-apply-edits-hook nil + "Hooks to run when text edit is applied. +It contains the operation source." + :type 'hook + :group 'lsp-mode + :package-version '(lsp-mode . "8.0.0")) + +(defcustom lsp-apply-edits-after-file-operations t + "Whether to apply edits returned by server after file operations if any. +Applicable only if server supports workspace.fileOperations for operations: +`workspace/willRenameFiles', `workspace/willCreateFiles' and +`workspace/willDeleteFiles'." + :group 'lsp-mode + :type 'boolean) + +(defcustom lsp-modeline-code-actions-enable t + "Whether to show code actions on modeline." + :type 'boolean + :group 'lsp-modeline) + +(defcustom lsp-modeline-diagnostics-enable t + "Whether to show diagnostics on modeline." + :type 'boolean + :group 'lsp-modeline) + +(defcustom lsp-modeline-workspace-status-enable t + "Whether to show workspace status on modeline." + :type 'boolean + :group 'lsp-modeline + :package-version '(lsp-mode . "8.0.0")) + +(defcustom lsp-headerline-breadcrumb-enable t + "Whether to enable breadcrumb on headerline." + :type 'boolean + :group 'lsp-headerline) + +(defcustom lsp-configure-hook nil + "Hooks to run when `lsp-configure-buffer' is called." + :type 'hook + :group 'lsp-mode) + +(defcustom lsp-unconfigure-hook nil + "Hooks to run when `lsp-unconfig-buffer' is called." + :type 'hook + :group 'lsp-mode) + +(defcustom lsp-after-diagnostics-hook nil + "Hooks to run after diagnostics are received. +Note: it runs only if the receiving buffer is open. Use +`lsp-diagnostics-updated-hook'if you want to be notified when +diagnostics have changed." + :type 'hook + :group 'lsp-mode) + +(define-obsolete-variable-alias 'lsp-after-diagnostics-hook + 'lsp-diagnostics-updated-hook "lsp-mode 6.4") + +(defcustom lsp-diagnostics-updated-hook nil + "Hooks to run after diagnostics are received." + :type 'hook + :group 'lsp-mode) + +(define-obsolete-variable-alias 'lsp-workspace-folders-changed-hook + 'lsp-workspace-folders-changed-functions "lsp-mode 6.3") + +(defcustom lsp-workspace-folders-changed-functions nil + "Hooks to run after the folders has changed. +The hook will receive two parameters list of added and removed folders." + :type 'hook + :group 'lsp-mode) + +(define-obsolete-variable-alias 'lsp-eldoc-hook 'eldoc-documentation-functions "lsp-mode 9.0.0") + +(defcustom lsp-before-apply-edits-hook nil + "Hooks to run before applying edits." + :type 'hook + :group 'lsp-mode) + +(defgroup lsp-imenu nil + "LSP Imenu." + :group 'lsp-mode + :tag "LSP Imenu") + +(defcustom lsp-imenu-show-container-name t + "Display the symbol's container name in an imenu entry." + :type 'boolean + :group 'lsp-imenu) + +(defcustom lsp-imenu-container-name-separator "/" + "Separator string to use to separate the container name from the symbol while +displaying imenu entries." + :type 'string + :group 'lsp-imenu) + +(defcustom lsp-imenu-sort-methods '(kind name) + "How to sort the imenu items. + +The value is a list of `kind' `name' or `position'. Priorities +are determined by the index of the element." + :type '(repeat (choice (const name) + (const position) + (const kind))) + :group 'lsp-imenu) + +(defcustom lsp-imenu-index-symbol-kinds nil + "Which symbol kinds to show in imenu." + :type '(repeat (choice (const :tag "Miscellaneous" nil) + (const :tag "File" File) + (const :tag "Module" Module) + (const :tag "Namespace" Namespace) + (const :tag "Package" Package) + (const :tag "Class" Class) + (const :tag "Method" Method) + (const :tag "Property" Property) + (const :tag "Field" Field) + (const :tag "Constructor" Constructor) + (const :tag "Enum" Enum) + (const :tag "Interface" Interface) + (const :tag "Function" Function) + (const :tag "Variable" Variable) + (const :tag "Constant" Constant) + (const :tag "String" String) + (const :tag "Number" Number) + (const :tag "Boolean" Boolean) + (const :tag "Array" Array) + (const :tag "Object" Object) + (const :tag "Key" Key) + (const :tag "Null" Null) + (const :tag "Enum Member" EnumMember) + (const :tag "Struct" Struct) + (const :tag "Event" Event) + (const :tag "Operator" Operator) + (const :tag "Type Parameter" TypeParameter))) + :group 'lsp-imenu) + +;; vibhavp: Should we use a lower value (5)? +(defcustom lsp-response-timeout 10 + "Number of seconds to wait for a response from the language server before +timing out. Nil if no timeout." + :type '(choice + (number :tag "Seconds") + (const :tag "No timeout" nil)) + :group 'lsp-mode) + +(defcustom lsp-tcp-connection-timeout 2 + "The timeout for tcp connection in seconds." + :type 'number + :group 'lsp-mode + :package-version '(lsp-mode . "6.2")) + +(defconst lsp--imenu-compare-function-alist + (list (cons 'name #'lsp--imenu-compare-name) + (cons 'kind #'lsp--imenu-compare-kind) + (cons 'position #'lsp--imenu-compare-line-col)) + "An alist of (METHOD . FUNCTION). +METHOD is one of the symbols accepted by +`lsp-imenu-sort-methods'. + +FUNCTION takes two hash tables representing DocumentSymbol. It +returns a negative number, 0, or a positive number indicating +whether the first parameter is less than, equal to, or greater +than the second parameter.") + +(defcustom lsp-diagnostic-clean-after-change nil + "When non-nil, clean the diagnostics on change. + +Note that when that setting is nil, `lsp-mode' will show stale +diagnostics until server publishes the new set of diagnostics" + :type 'boolean + :group 'lsp-diagnostics + :package-version '(lsp-mode . "7.0.1")) + +(defcustom lsp-server-trace nil + "Request tracing on the server side. +The actual trace output at each level depends on the language server in use. +Changes take effect only when a new session is started." + :type '(choice (const :tag "Disabled" "off") + (const :tag "Messages only" "messages") + (const :tag "Verbose" "verbose") + (const :tag "Default (disabled)" nil)) + :group 'lsp-mode + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-auto-touch-files t + "If non-nil ensure the files exist before sending +`textDocument/didOpen' notification." + :type 'boolean + :group 'lsp-mode + :package-version '(lsp-mode . "9.0.0")) + +(defvar lsp-language-id-configuration + '(("\\(^CMakeLists\\.txt\\|\\.cmake\\)\\'" . "cmake") + ("\\(^Dockerfile\\(?:\\..*\\)?\\|\\.[Dd]ockerfile\\)\\'" . "dockerfile") + ("\\.astro$" . "astro") + ("\\.cs\\'" . "csharp") + ("\\.css$" . "css") + ("\\.cypher$" . "cypher") + ("\\.ebuild$" . "shellscript") + ("\\.go\\'" . "go") + ("\\.html$" . "html") + ("\\.hx$" . "haxe") + ("\\.hy$" . "hy") + ("\\.java\\'" . "java") + ("\\.jq$" . "jq") + ("\\.js$" . "javascript") + ("\\.json$" . "json") + ("\\.jsonc$" . "jsonc") + ("\\.jsonnet$" . "jsonnet") + ("\\.jsx$" . "javascriptreact") + ("\\.lua$" . "lua") + ("\\.mdx\\'" . "mdx") + ("\\.nu$" . "nushell") + ("\\.php$" . "php") + ("\\.ps[dm]?1\\'" . "powershell") + ("\\.rs\\'" . "rust") + ("\\.spec\\'" . "rpm-spec") + ("\\.sql$" . "sql") + ("\\.svelte$" . "svelte") + ("\\.toml\\'" . "toml") + ("\\.ts$" . "typescript") + ("\\.tsx$" . "typescriptreact") + ("\\.ttcn3$" . "ttcn3") + ("\\.vue$" . "vue") + ("\\.xml$" . "xml") + ("\\ya?ml$" . "yaml") + ("^PKGBUILD$" . "shellscript") + ("^go\\.mod\\'" . "go.mod") + ("^settings\\.json$" . "jsonc") + ("^yang\\.settings$" . "jsonc") + ("^meson\\(_options\\.txt\\|\\.\\(build\\|format\\)\\)\\'" . "meson") + (ada-mode . "ada") + (ada-ts-mode . "ada") + (gpr-mode . "gpr") + (gpr-ts-mode . "gpr") + (awk-mode . "awk") + (awk-ts-mode . "awk") + (nxml-mode . "xml") + (sql-mode . "sql") + (vimrc-mode . "vim") + (vimscript-ts-mode . "vim") + (sh-mode . "shellscript") + (bash-ts-mode . "shellscript") + (ebuild-mode . "shellscript") + (pkgbuild-mode . "shellscript") + (envrc-file-mode . "shellscript") + (scala-mode . "scala") + (scala-ts-mode . "scala") + (julia-mode . "julia") + (julia-ts-mode . "julia") + (clojure-mode . "clojure") + (clojurec-mode . "clojure") + (clojurescript-mode . "clojurescript") + (clojure-ts-mode . "clojure") + (clojure-ts-clojurec-mode . "clojure") + (clojure-ts-clojurescript-mode . "clojurescript") + (java-mode . "java") + (java-ts-mode . "java") + (jdee-mode . "java") + (groovy-mode . "groovy") + (python-mode . "python") + (python-ts-mode . "python") + (cython-mode . "python") + ("\\(\\.mojo\\|\\.🔥\\)\\'" . "mojo") + (lsp--render-markdown . "markdown") + (move-mode . "move") + (rust-mode . "rust") + (rust-ts-mode . "rust") + (rustic-mode . "rust") + (kotlin-mode . "kotlin") + (kotlin-ts-mode . "kotlin") + (css-mode . "css") + (css-ts-mode . "css") + (less-mode . "less") + (less-css-mode . "less") + (lua-mode . "lua") + (lua-ts-mode . "lua") + (sass-mode . "sass") + (ssass-mode . "sass") + (scss-mode . "scss") + (scad-mode . "openscad") + (xml-mode . "xml") + (c-mode . "c") + (c-ts-mode . "c") + (c++-mode . "cpp") + (c++-ts-mode . "cpp") + (cuda-mode . "cuda") + (objc-mode . "objective-c") + (html-mode . "html") + (html-ts-mode . "html") + (sgml-mode . "html") + (mhtml-mode . "html") + (mint-mode . "mint") + (go-dot-mod-mode . "go.mod") + (go-mod-ts-mode . "go.mod") + (go-mode . "go") + (go-ts-mode . "go") + (graphql-mode . "graphql") + (haskell-mode . "haskell") + (hack-mode . "hack") + (php-mode . "php") + (php-ts-mode . "php") + (powershell-mode . "powershell") + (powershell-mode . "PowerShell") + (powershell-ts-mode . "powershell") + (json-mode . "json") + (json-ts-mode . "json") + (jsonc-mode . "jsonc") + (rjsx-mode . "javascript") + (js2-mode . "javascript") + (js-mode . "javascript") + (js-ts-mode . "javascript") + (typescript-mode . "typescript") + (typescript-ts-mode . "typescript") + (tsx-ts-mode . "typescriptreact") + (svelte-mode . "svelte") + (fsharp-mode . "fsharp") + (reason-mode . "reason") + (caml-mode . "ocaml") + (tuareg-mode . "ocaml") + (swift-mode . "swift") + (elixir-mode . "elixir") + (elixir-ts-mode . "elixir") + (heex-ts-mode . "elixir") + (conf-javaprop-mode . "spring-boot-properties") + (yaml-mode . "yaml") + (yaml-ts-mode . "yaml") + (ruby-mode . "ruby") + (enh-ruby-mode . "ruby") + (ruby-ts-mode . "ruby") + (fortran-mode . "fortran") + (f90-mode . "fortran") + (elm-mode . "elm") + (dart-mode . "dart") + (erlang-mode . "erlang") + (dockerfile-mode . "dockerfile") + (dockerfile-ts-mode . "dockerfile") + (csharp-mode . "csharp") + (csharp-tree-sitter-mode . "csharp") + (csharp-ts-mode . "csharp") + (plain-tex-mode . "plaintex") + (context-mode . "context") + (cypher-mode . "cypher") + (latex-mode . "latex") + (LaTeX-mode . "latex") + (v-mode . "v") + (vhdl-mode . "vhdl") + (vhdl-ts-mode . "vhdl") + (verilog-mode . "verilog") + (terraform-mode . "terraform") + (ess-julia-mode . "julia") + (ess-r-mode . "r") + (crystal-mode . "crystal") + (nim-mode . "nim") + (dhall-mode . "dhall") + (cmake-mode . "cmake") + (cmake-ts-mode . "cmake") + (purescript-mode . "purescript") + (gdscript-mode . "gdscript") + (gdscript-ts-mode . "gdscript") + (perl-mode . "perl") + (cperl-mode . "perl") + (robot-mode . "robot") + (racket-mode . "racket") + (nix-mode . "nix") + (nix-ts-mode . "Nix") + (prolog-mode . "prolog") + (vala-mode . "vala") + (actionscript-mode . "actionscript") + (d-mode . "d") + (zig-mode . "zig") + (text-mode . "plaintext") + (markdown-mode . "markdown") + (gfm-mode . "markdown") + (beancount-mode . "beancount") + (conf-toml-mode . "toml") + (toml-ts-mode . "toml") + (org-mode . "org") + (org-journal-mode . "org") + (nginx-mode . "nginx") + (magik-mode . "magik") + (magik-ts-mode . "magik") + (idris-mode . "idris") + (idris2-mode . "idris2") + (gleam-mode . "gleam") + (graphviz-dot-mode . "dot") + (tiltfile-mode . "tiltfile") + (solidity-mode . "solidity") + (bibtex-mode . "bibtex") + (rst-mode . "restructuredtext") + (glsl-mode . "glsl") + (shader-mode . "shaderlab") + (wgsl-mode . "wgsl") + (jq-mode . "jq") + (jq-ts-mode . "jq") + (protobuf-mode . "protobuf") + (nushell-mode . "nushell") + (nushell-ts-mode . "nushell") + (meson-mode . "meson") + (yang-mode . "yang")) + "Language id configuration.") + +(defvar lsp--last-active-workspaces nil + "Keep track of last active workspace. +We want to try the last workspace first when jumping into a library +directory") + +(defvar lsp-method-requirements + '(("textDocument/callHierarchy" :capability :callHierarchyProvider) + ("textDocument/codeAction" :capability :codeActionProvider) + ("codeAction/resolve" + :check-command (lambda (workspace) + (with-lsp-workspace workspace + (lsp:code-action-options-resolve-provider? + (lsp--capability-for-method "textDocument/codeAction"))))) + ("textDocument/codeLens" :capability :codeLensProvider) + ("textDocument/completion" :capability :completionProvider) + ("completionItem/resolve" + :check-command (lambda (wk) + (with-lsp-workspace wk + (lsp:completion-options-resolve-provider? + (lsp--capability-for-method "textDocument/completion"))))) + ("textDocument/declaration" :capability :declarationProvider) + ("textDocument/definition" :capability :definitionProvider) + ("textDocument/documentColor" :capability :colorProvider) + ("textDocument/documentLink" :capability :documentLinkProvider) + ("textDocument/inlayHint" :capability :inlayHintProvider) + ("textDocument/documentHighlight" :capability :documentHighlightProvider) + ("textDocument/documentSymbol" :capability :documentSymbolProvider) + ("textDocument/foldingRange" :capability :foldingRangeProvider) + ("textDocument/formatting" :capability :documentFormattingProvider) + ("textDocument/hover" :capability :hoverProvider) + ("textDocument/implementation" :capability :implementationProvider) + ("textDocument/linkedEditingRange" :capability :linkedEditingRangeProvider) + ("textDocument/onTypeFormatting" :capability :documentOnTypeFormattingProvider) + ("textDocument/prepareRename" + :check-command (lambda (workspace) + (with-lsp-workspace workspace + (lsp:rename-options-prepare-provider? + (lsp--capability-for-method "textDocument/rename"))))) + ("textDocument/rangeFormatting" :capability :documentRangeFormattingProvider) + ("textDocument/references" :capability :referencesProvider) + ("textDocument/rename" :capability :renameProvider) + ("textDocument/selectionRange" :capability :selectionRangeProvider) + ("textDocument/semanticTokens" :capability :semanticTokensProvider) + ("textDocument/semanticTokensFull" + :check-command (lambda (workspace) + (with-lsp-workspace workspace + (lsp-get (lsp--capability :semanticTokensProvider) :full)))) + ("textDocument/semanticTokensFull/Delta" + :check-command (lambda (workspace) + (with-lsp-workspace workspace + (let ((capFull (lsp-get (lsp--capability :semanticTokensProvider) :full))) + (and (not (booleanp capFull)) (lsp-get capFull :delta)))))) + ("textDocument/semanticTokensRangeProvider" + :check-command (lambda (workspace) + (with-lsp-workspace workspace + (lsp-get (lsp--capability :semanticTokensProvider) :range)))) + ("textDocument/signatureHelp" :capability :signatureHelpProvider) + ("textDocument/typeDefinition" :capability :typeDefinitionProvider) + ("textDocument/typeHierarchy" :capability :typeHierarchyProvider) + ("workspace/executeCommand" :capability :executeCommandProvider) + ("workspace/symbol" :capability :workspaceSymbolProvider)) + + "Map methods to requirements. +It is used by request-sending functions to determine which server +must be used for handling a particular message.") + +(defconst lsp--file-change-type + `((created . 1) + (changed . 2) + (deleted . 3))) + +(defconst lsp--watch-kind + `((create . 1) + (change . 2) + (delete . 4))) + +(defvar lsp-window-body-width 40 + "Window body width when rendering doc.") + +(defface lsp-face-highlight-textual + '((t :inherit highlight)) + "Face used for textual occurrences of symbols." + :group 'lsp-mode) + +(defface lsp-face-highlight-read + '((t :inherit highlight :underline t)) + "Face used for highlighting symbols being read." + :group 'lsp-mode) + +(defface lsp-face-highlight-write + '((t :inherit highlight :weight bold)) + "Face used for highlighting symbols being written to." + :group 'lsp-mode) + +(define-obsolete-variable-alias 'lsp-lens-auto-enable + 'lsp-lens-enable "lsp-mode 7.0.1") + +(defcustom lsp-lens-enable t + "Auto enable lenses if server supports." + :group 'lsp-lens + :type 'boolean + :package-version '(lsp-mode . "6.3")) + +(defcustom lsp-symbol-highlighting-skip-current nil + "If non-nil skip current symbol when setting symbol highlights." + :group 'lsp-mode + :type 'boolean) + +(defcustom lsp-file-watch-threshold 1000 + "Show warning if the files to watch are more than. +Set to nil to disable the warning." + :type 'number + :group 'lsp-mode) +;;;###autoload(put 'lsp-file-watch-threshold 'safe-local-variable (lambda (i) (or (numberp i) (not i)))) + +(defvar lsp-custom-markup-modes + '((rust-mode "no_run" "rust,no_run" "rust,ignore" "rust,should_panic")) + "Mode to uses with markdown code blocks. +They are added to `markdown-code-lang-modes'") + +(defcustom lsp-signature-render-documentation t + "Display signature documentation in `eldoc'." + :type 'boolean + :group 'lsp-mode + :package-version '(lsp-mode . "6.2")) + +(defcustom lsp-signature-auto-activate '(:on-trigger-char :on-server-request) + "Auto activate signature conditions." + :type '(repeat (choice (const :tag "On trigger chars pressed." :on-trigger-char) + (const :tag "After selected completion." :after-completion) + (const :tag "When the server has sent show signature help." :on-server-request))) + :group 'lsp-mode + :package-version '(lsp-mode . "6.2")) + +(defcustom lsp-signature-doc-lines 20 + "If number, limit the number of lines to show in the docs." + :type 'number + :group 'lsp-mode + :package-version '(lsp-mode . "6.3")) + +(defcustom lsp-signature-function 'lsp-lv-message + "The function used for displaying signature info. +It will be called with one param - the signature info. When +called with nil the signature info must be cleared." + :type 'function + :group 'lsp-mode + :package-version '(lsp-mode . "6.3")) + +(defcustom lsp-keymap-prefix "s-l" + "LSP-mode keymap prefix." + :group 'lsp-mode + :type 'string + :package-version '(lsp-mode . "6.3")) + +(defvar-local lsp--buffer-workspaces () + "List of the buffer workspaces.") + +(defvar-local lsp--buffer-deferred nil + "Whether buffer was loaded via `lsp-deferred'.") + +(defvar lsp--session nil + "Contain the `lsp-session' for the current Emacs instance.") + +(defvar lsp--tcp-port 10000) + +(defvar lsp--client-packages-required nil + "If nil, `lsp-client-packages' are yet to be required.") + +(defvar lsp--tcp-server-port 0 + "The server socket which is opened when using `lsp-tcp-server' (a server +socket is opened in Emacs and the language server connects to it). The +default value of 0 ensures that a random high port is used. Set it to a positive +integer to use a specific port.") + +(defvar lsp--tcp-server-wait-seconds 10 + "Wait this amount of time for the client to connect to our server socket +when using `lsp-tcp-server'.") + +(defvar-local lsp--document-symbols nil + "The latest document symbols.") + +(defvar-local lsp--document-selection-range-cache nil + "The document selection cache.") + +(defvar-local lsp--document-symbols-request-async nil + "If non-nil, request document symbols asynchronously.") + +(defvar-local lsp--document-symbols-tick -1 + "The value of `buffer-chars-modified-tick' when document + symbols were last retrieved.") + +(defvar-local lsp--have-document-highlights nil + "Set to `t' on symbol highlighting, cleared on +`lsp--cleanup-highlights-if-needed'. Checking a separately +defined flag is substantially faster than unconditionally +calling `remove-overlays'.") + +;; Buffer local variable for storing number of lines. +(defvar lsp--log-lines) + +(defvar-local lsp--eldoc-saved-message nil) + +(defvar lsp--on-change-timer nil) +(defvar lsp--on-idle-timer nil) + +(defvar-local lsp--signature-last nil) +(defvar-local lsp--signature-last-index nil) +(defvar lsp--signature-last-buffer nil) + +(defvar-local lsp--virtual-buffer-point-max nil) + +(cl-defmethod lsp-execute-command (_server _command _arguments) + "Ask SERVER to execute COMMAND with ARGUMENTS.") + +(defun lsp-elt (sequence n) + "Return Nth element of SEQUENCE or nil if N is out of range." + (cond + ((listp sequence) (elt sequence n)) + ((arrayp sequence) + (and (> (length sequence) n) (aref sequence n))) + (t (and (> (length sequence) n) (elt sequence n))))) + +;; define seq-first and seq-rest for older emacs +(defun lsp-seq-first (sequence) + "Return the first element of SEQUENCE." + (lsp-elt sequence 0)) + +(defun lsp-seq-rest (sequence) + "Return a sequence of the elements of SEQUENCE except the first one." + (seq-drop sequence 1)) + +;;;###autoload +(defun lsp--string-listp (sequence) + "Return t if all elements of SEQUENCE are strings, else nil." + (not (seq-find (lambda (x) (not (stringp x))) sequence))) + +(defun lsp--string-vector-p (candidate) + "Returns true if CANDIDATE is a vector data structure and +every element of it is of type string, else nil." + (and + (vectorp candidate) + (seq-every-p #'stringp candidate))) + +(make-obsolete 'lsp--string-vector-p nil "lsp-mode 8.0.0") + +(defun lsp--editable-vector-match (widget value) + "Function for `lsp-editable-vector' :match." + ;; Value must be a list or a vector and all the members must match the type. + (and (or (listp value) (vectorp value)) + (length (cdr (lsp--editable-vector-match-inline widget value))))) + +(defun lsp--editable-vector-match-inline (widget value) + "Value for `lsp-editable-vector' :match-inline." + (let ((type (nth 0 (widget-get widget :args))) + (ok t) + found) + (while (and value ok) + (let ((answer (widget-match-inline type value))) + (if answer + (let ((head (if (vectorp answer) (aref answer 0) (car answer))) + (tail (if (vectorp answer) (seq-drop 1 answer) (cdr answer)))) + (setq found (append found head) + value tail)) + (setq ok nil)))) + (cons found value))) + +(defun lsp--editable-vector-value-to-external (_widget internal-value) + "Convert the internal list value to a vector." + (if (listp internal-value) + (apply 'vector internal-value) + internal-value)) + +(defun lsp--editable-vector-value-to-internal (_widget external-value) + "Convert the external vector value to a list." + (if (vectorp external-value) + (append external-value nil) + external-value)) + +(define-widget 'lsp--editable-vector 'editable-list + "A subclass of `editable-list' that accepts and returns a +vector instead of a list." + :value-to-external 'lsp--editable-vector-value-to-external + :value-to-internal 'lsp--editable-vector-value-to-internal + :match 'lsp--editable-vector-match + :match-inline 'lsp--editable-vector-match-inline) + +(define-widget 'lsp-repeatable-vector 'lsp--editable-vector + "A variable length homogeneous vector." + :tag "Repeat" + :format "%{%t%}:\n%v%i\n") + +(define-widget 'lsp-string-vector 'lazy + "A vector of zero or more elements, every element of which is a string. +Appropriate for any language-specific `defcustom' that needs to +serialize as a JSON array of strings. + +Deprecated. Use `lsp-repeatable-vector' instead. " + :offset 4 + :tag "Vector" + :type '(lsp-repeatable-vector string)) + +(make-obsolete 'lsp-string-vector nil "lsp-mode 8.0.0") + +(defvar lsp--show-message t + "If non-nil, show debug message from `lsp-mode'.") + +(defun lsp--message (format &rest args) + "Wrapper for `message' + +We `inhibit-message' the message when the cursor is in the +minibuffer and when emacs version is before emacs 27 due to the +fact that we often use `lsp--info', `lsp--warn' and `lsp--error' +in async context and the call to these function is removing the +minibuffer prompt. The issue with async messages is already fixed +in emacs 27. + +See #2049" + (when lsp--show-message + (let ((inhibit-message (or inhibit-message + (and (minibufferp) + (version< emacs-version "27.0"))))) + (apply #'message format args)))) + +(defun lsp--info (format &rest args) + "Display lsp info message with FORMAT with ARGS." + (lsp--message "%s :: %s" (propertize "LSP" 'face 'success) (apply #'format format args))) + +(defun lsp--warn (format &rest args) + "Display lsp warn message with FORMAT with ARGS." + (lsp--message "%s :: %s" (propertize "LSP" 'face 'warning) (apply #'format format args))) + +(defun lsp--error (format &rest args) + "Display lsp error message with FORMAT with ARGS." + (lsp--message "%s :: %s" (propertize "LSP" 'face 'error) (apply #'format format args))) + +(defun lsp-log (format &rest args) + "Log message to the ’*lsp-log*’ buffer. + +FORMAT and ARGS i the same as for `message'." + (when lsp-log-max + (let ((log-buffer (get-buffer "*lsp-log*")) + (inhibit-read-only t)) + (unless log-buffer + (setq log-buffer (get-buffer-create "*lsp-log*")) + (with-current-buffer log-buffer + (buffer-disable-undo) + (view-mode 1) + (set (make-local-variable 'lsp--log-lines) 0))) + (with-current-buffer log-buffer + (save-excursion + (let* ((message (apply 'format format args)) + ;; Count newlines in message. + (newlines (1+ (cl-loop with start = 0 + for count from 0 + while (string-match "\n" message start) + do (setq start (match-end 0)) + finally return count)))) + (goto-char (point-max)) + + ;; in case the buffer is not empty insert before last \n to preserve + ;; the point position(in case it is in the end) + (if (eq (point) (point-min)) + (progn + (insert "\n") + (backward-char)) + (backward-char) + (insert "\n")) + (insert message) + + (setq lsp--log-lines (+ lsp--log-lines newlines)) + + (when (and (integerp lsp-log-max) (> lsp--log-lines lsp-log-max)) + (let ((to-delete (- lsp--log-lines lsp-log-max))) + (goto-char (point-min)) + (forward-line to-delete) + (delete-region (point-min) (point)) + (setq lsp--log-lines lsp-log-max))))))))) + +(defalias 'lsp-message 'lsp-log) + +(defalias 'lsp-ht 'ht) + +(defalias 'lsp-file-local-name 'file-local-name) + +(defun lsp-f-canonical (file-name) + "Return the canonical FILE-NAME, without a trailing slash." + (directory-file-name (expand-file-name file-name))) + +(defalias 'lsp-canonical-file-name 'lsp-f-canonical) + +(defun lsp-f-same? (path-a path-b) + "Return t if PATH-A and PATH-B are references to the same file. +Symlinks are not followed." + (when (and (f-exists? path-a) + (f-exists? path-b)) + (equal + (lsp-f-canonical (directory-file-name (f-expand path-a))) + (lsp-f-canonical (directory-file-name (f-expand path-b)))))) + +(defun lsp-f-parent (path) + "Return the parent directory to PATH. +Symlinks are not followed." + (let ((parent (file-name-directory + (directory-file-name (f-expand path default-directory))))) + (unless (lsp-f-same? path parent) + (if (f-relative? path) + (f-relative parent) + (directory-file-name parent))))) + +(defun lsp-f-ancestor-of? (path-a path-b) + "Return t if PATH-A is an ancestor of PATH-B. +Symlinks are not followed." + (unless (lsp-f-same? path-a path-b) + (s-prefix? (concat (lsp-f-canonical path-a) (f-path-separator)) + (lsp-f-canonical path-b)))) + +(defun lsp--merge-results (results method) + "Merge RESULTS by filtering the empty hash-tables and merging +the lists according to METHOD." + (pcase (--map (if (vectorp it) + (append it nil) it) + (-filter #'identity results)) + (`() ()) + ;; only one result - simply return it + (`(,fst) fst) + ;; multiple results merge it based on strategy + (results + (pcase method + ("textDocument/hover" (pcase (seq-filter + (-compose #'not #'lsp-empty?) + results) + (`(,hover) hover) + (hovers (lsp-make-hover + :contents + (-mapcat + (-lambda ((&Hover :contents)) + (if (and (sequencep contents) + (not (stringp contents))) + (append contents ()) + (list contents))) + hovers))))) + ("textDocument/completion" + (lsp-make-completion-list + :is-incomplete (seq-some + #'lsp:completion-list-is-incomplete + results) + :items (cl-mapcan (lambda (it) (append (if (lsp-completion-list? it) + (lsp:completion-list-items it) + it) + nil)) + results))) + ("completionItem/resolve" + (let ((item (cl-first results))) + (when-let ((details (seq-filter #'identity + (seq-map #'lsp:completion-item-detail? results)))) + (lsp:set-completion-item-detail? + item + (string-join details " "))) + (when-let ((docs (seq-filter #'identity + (seq-map #'lsp:completion-item-documentation? results)))) + (lsp:set-completion-item-documentation? + item + (lsp-make-markup-content + :kind (or (seq-some (lambda (it) + (when (equal (lsp:markup-content-kind it) + lsp/markup-kind-markdown) + lsp/markup-kind-markdown)) + docs) + lsp/markup-kind-plain-text) + :value (string-join (seq-map (lambda (doc) + (or (lsp:markup-content-value doc) + (and (stringp doc) doc))) + docs) + "\n")))) + (when-let ((edits (seq-filter #'identity + (seq-map #'lsp:completion-item-additional-text-edits? results)))) + (lsp:set-completion-item-additional-text-edits? + item + (cl-mapcan (lambda (it) (if (seqp it) it (list it))) edits))) + item)) + (_ (cl-mapcan (lambda (it) (if (seqp it) it (list it))) results)))))) + +(defun lsp--spinner-start () + "Start spinner indication." + (condition-case _err (spinner-start (lsp-progress-spinner-type)) (error))) + +(defun lsp--propertize (str type) + "Propertize STR as per TYPE." + (propertize str 'face (alist-get type lsp--message-type-face))) + +(defun lsp-workspaces () + "Return the lsp workspaces associated with the current project." + (if lsp--cur-workspace (list lsp--cur-workspace) lsp--buffer-workspaces)) + +(defun lsp--completing-read (prompt collection transform-fn &optional predicate + require-match initial-input + hist def inherit-input-method) + "Wrap `completing-read' to provide transformation function and disable sort. + +TRANSFORM-FN will be used to transform each of the items before displaying. + +PROMPT COLLECTION PREDICATE REQUIRE-MATCH INITIAL-INPUT HIST DEF +INHERIT-INPUT-METHOD will be proxied to `completing-read' without changes." + (let* ((col (--map (cons (funcall transform-fn it) it) collection)) + (completion (completing-read prompt + (lambda (string pred action) + (if (eq action 'metadata) + `(metadata (display-sort-function . identity)) + (complete-with-action action col string pred))) + predicate require-match initial-input hist + def inherit-input-method))) + (cdr (assoc completion col)))) + +(defconst lsp--system-arch (lambda () + (setq lsp--system-arch + (pcase system-type + ('windows-nt + (pcase system-configuration + ((rx bol "x86_64-") 'x64) + (_ 'x86))) + ('darwin + (pcase system-configuration + ((rx "aarch64-") 'arm64) + (_ 'x64))) + ('gnu/linux + (pcase system-configuration + ((rx bol "x86_64") 'x64) + ((rx bol (| "i386" "i886")) 'x32))) + (_ + (pcase system-configuration + ((rx bol "x86_64") 'x64) + ((rx bol (| "i386" "i886")) 'x32)))))) + "Return the system architecture of `Emacs'. +Special values: + `x64' 64bit + `x32' 32bit + `arm64' ARM 64bit") + +(defmacro lsp-with-current-buffer (buffer-id &rest body) + (declare (indent 1) (debug t)) + `(if-let ((wcb (plist-get ,buffer-id :with-current-buffer))) + (with-lsp-workspaces (plist-get ,buffer-id :workspaces) + (funcall wcb (lambda () ,@body))) + (with-current-buffer ,buffer-id + ,@body))) + +(defvar lsp--throw-on-input nil + "Make `lsp-*-while-no-input' throws `input' on interrupted.") + +(defmacro lsp--catch (tag bodyform &rest handlers) + "Catch TAG thrown in BODYFORM. +The return value from TAG will be handled in HANDLERS by `pcase'." + (declare (debug (form form &rest (pcase-PAT body))) (indent 2)) + (let ((re-sym (make-symbol "re"))) + `(let ((,re-sym (catch ,tag ,bodyform))) + (pcase ,re-sym + ,@handlers)))) + +(defmacro lsp--while-no-input (&rest body) + "Wrap BODY in `while-no-input' and respecting `non-essential'. +If `lsp--throw-on-input' is set, will throw if input is pending, else +return value of `body' or nil if interrupted." + (declare (debug t) (indent 0)) + `(if non-essential + (let ((res (while-no-input ,@body))) + (cond + ((and lsp--throw-on-input (equal res t)) + (throw 'input :interrupted)) + ((booleanp res) nil) + (t res))) + ,@body)) + +;; A ‘lsp--client’ object describes the client-side behavior of a language +;; server. It is used to start individual server processes, each of which is +;; represented by a ‘lsp--workspace’ object. Client objects are normally +;; created using ‘lsp-define-stdio-client’ or ‘lsp-define-tcp-client’. Each +;; workspace refers to exactly one client, but there can be multiple workspaces +;; for a single client. +(cl-defstruct lsp--client + ;; ‘language-id’ is a function that receives a buffer as a single argument + ;; and should return the language identifier for that buffer. See + ;; https://microsoft.github.io/language-server-protocol/specification#textdocumentitem + ;; for a list of language identifiers. Also consult the documentation for + ;; the language server represented by this client to find out what language + ;; identifiers it supports or expects. + (language-id nil) + + ;; ‘add-on?’ when set to t the server will be started no matter whether there + ;; is another server handling the same mode. + (add-on? nil) + ;; ‘new-connection’ is a function that should start a language server process + ;; and return a cons (COMMAND-PROCESS . COMMUNICATION-PROCESS). + ;; COMMAND-PROCESS must be a process object representing the server process + ;; just started. COMMUNICATION-PROCESS must be a process (including pipe and + ;; network processes) that ‘lsp-mode’ uses to communicate with the language + ;; server using the language server protocol. COMMAND-PROCESS and + ;; COMMUNICATION-PROCESS may be the same process; in that case + ;; ‘new-connection’ may also return that process as a single + ;; object. ‘new-connection’ is called with two arguments, FILTER and + ;; SENTINEL. FILTER should be used as process filter for + ;; COMMUNICATION-PROCESS, and SENTINEL should be used as process sentinel for + ;; COMMAND-PROCESS. + (new-connection nil) + + ;; ‘ignore-regexps’ is a list of regexps. When a data packet from the + ;; language server matches any of these regexps, it will be ignored. This is + ;; intended for dealing with language servers that output non-protocol data. + (ignore-regexps nil) + + ;; ‘ignore-messages’ is a list of regexps. When a message from the language + ;; server matches any of these regexps, it will be ignored. This is useful + ;; for filtering out unwanted messages; such as servers that send nonstandard + ;; message types, or extraneous log messages. + (ignore-messages nil) + + ;; ‘notification-handlers’ is a hash table mapping notification method names + ;; (strings) to functions handling the respective notifications. Upon + ;; receiving a notification, ‘lsp-mode’ will call the associated handler + ;; function passing two arguments, the ‘lsp--workspace’ object and the + ;; deserialized notification parameters. + (notification-handlers (make-hash-table :test 'equal)) + + ;; ‘request-handlers’ is a hash table mapping request method names + ;; (strings) to functions handling the respective notifications. Upon + ;; receiving a request, ‘lsp-mode’ will call the associated handler function + ;; passing two arguments, the ‘lsp--workspace’ object and the deserialized + ;; request parameters. + (request-handlers (make-hash-table :test 'equal)) + + ;; ‘response-handlers’ is a hash table mapping integral JSON-RPC request + ;; identifiers for pending asynchronous requests to functions handling the + ;; respective responses. Upon receiving a response from the language server, + ;; ‘lsp-mode’ will call the associated response handler function with a + ;; single argument, the deserialized response parameters. + (response-handlers (make-hash-table :test 'eql)) + + ;; ‘prefix-function’ is called for getting the prefix for completion. + ;; The function takes no parameter and returns a cons (start . end) representing + ;; the start and end bounds of the prefix. If it's not set, the client uses a + ;; default prefix function." + (prefix-function nil) + + ;; Contains mapping of scheme to the function that is going to be used to load + ;; the file. + (uri-handlers (make-hash-table :test #'equal)) + + ;; ‘action-handlers’ is a hash table mapping action to a handler function. It + ;; can be used in `lsp-execute-code-action' to determine whether the action + ;; current client is interested in executing the action instead of sending it + ;; to the server. + (action-handlers (make-hash-table :test 'equal)) + + ;; major modes supported by the client. + major-modes + ;; Function that will be called to decide if this language client + ;; should manage a particular buffer. The function will be passed + ;; the file name and major mode to inform the decision. Setting + ;; `activation-fn' will override `major-modes', if + ;; present. + activation-fn + ;; Break the tie when major-mode is supported by multiple clients. + (priority 0) + ;; Unique identifier for representing the client object. + server-id + ;; defines whether the client supports multi root workspaces. + multi-root + ;; Initialization options or a function that returns initialization options. + initialization-options + ;; `semantic-tokens-faces-overrides’ is a plist that can be used to extend, or + ;; completely replace, the faces used for semantic highlighting on a + ;; client-by-client basis. + ;; + ;; It recognizes four members, all of which are optional: `:types’ and + ;; `:modifiers’, respectively, should be face definition lists akin to + ;; `:lsp-semantic-token-faces’. If specified, each of these face lists will be + ;; merged with the default face definition list. + ;; + ;; Alternatively, if the plist members `:discard-default-types’ or + ;; `:discard-default-modifiers' are non-nil, the default `:type' or `:modifiers' + ;; face definitions will be replaced entirely by their respective overrides. + ;; + ;; For example, setting `:semantic-tokens-faces-overrides' to + ;; `(:types (("macro" . font-lock-keyword-face)))' will remap "macro" tokens from + ;; their default face `lsp-face-semhl-macro' to `font-lock-keyword-face'. + ;; + ;; `(:types (("macro" . font-lock-keyword-face) ("not-quite-a-macro" . some-face)))' + ;; will also remap "macro", but on top of that associate the fictional token type + ;; "not-quite-a-macro" with the face named `some-face'. + ;; + ;; `(:types (("macro" . font-lock-keyword-face)) + ;; :modifiers (("declaration" . lsp-face-semhl-interface)) + ;; :discard-default-types t + ;; :discard-default-modifiers t)' + ;; will discard all default face definitions, hence leaving the client with + ;; only one token type "macro", mapped to `font-lock-keyword-face', and one + ;; modifier type "declaration", mapped to `lsp-face-semhl-interface'. + semantic-tokens-faces-overrides + ;; Provides support for registering LSP Server specific capabilities. + custom-capabilities + ;; Function which returns the folders that are considered to be not projects but library files. + ;; The function accepts one parameter currently active workspace. + ;; See: https://github.com/emacs-lsp/lsp-mode/issues/225. + library-folders-fn + ;; function which will be called when opening file in the workspace to perform + ;; client specific initialization. The function accepts one parameter + ;; currently active workspace. + before-file-open-fn + ;; Function which will be called right after a workspace has been initialized. + initialized-fn + ;; ‘remote?’ indicate whether the client can be used for LSP server over TRAMP. + (remote? nil) + + ;; ‘completion-in-comments?’ t if the client supports completion in comments. + (completion-in-comments? nil) + + ;; ‘path->uri-fn’ the function to use for path->uri conversion for the client. + (path->uri-fn nil) + + ;; ‘uri->path-fn’ the function to use for uri->path conversion for the client. + (uri->path-fn nil) + ;; Function that returns an environment structure that will be used + ;; to set some environment variables when starting the language + ;; server process. These environment variables enable some + ;; additional features in the language server. The environment + ;; structure is an alist of the form (KEY . VALUE), where KEY is a + ;; string (regularly in all caps), and VALUE may be a string, a + ;; boolean, or a sequence of strings. + environment-fn + + ;; ‘after-open-fn’ workspace after open specific hooks. + (after-open-fn nil) + + ;; ‘async-request-handlers’ is a hash table mapping request method names + ;; (strings) to functions handling the respective requests that may take + ;; time to finish. Upon receiving a request, ‘lsp-mode’ will call the + ;; associated handler function passing three arguments, the ‘lsp--workspace’ + ;; object, the deserialized request parameters and the callback which accept + ;; result as its parameter. + (async-request-handlers (make-hash-table :test 'equal)) + download-server-fn + download-in-progress? + buffers + synchronize-sections) + +(defun lsp-clients-executable-find (find-command &rest args) + "Finds an executable by invoking a search command. + +FIND-COMMAND is the executable finder that searches for the +actual language server executable. ARGS is a list of arguments to +give to FIND-COMMAND to find the language server. Returns the +output of FIND-COMMAND if it exits successfully, nil otherwise. + +Typical uses include finding an executable by invoking `find' in +a project, finding LLVM commands on macOS with `xcrun', or +looking up project-specific language servers for projects written +in the various dynamic languages, e.g. `nvm', `pyenv' and `rbenv' +etc." + (when-let* ((find-command-path (executable-find find-command)) + (executable-path + (with-temp-buffer + (when (zerop (apply 'call-process find-command-path nil t nil args)) + (buffer-substring-no-properties (point-min) (point-max)))))) + (string-trim executable-path))) + +(defvar lsp--already-widened nil) + +(defmacro lsp-save-restriction-and-excursion (&rest form) + (declare (indent 0) (debug t)) + `(if lsp--already-widened + (save-excursion ,@form) + (-let [lsp--already-widened t] + (save-restriction + (widen) + (save-excursion ,@form))))) + +;; from http://emacs.stackexchange.com/questions/8082/how-to-get-buffer-position-given-line-number-and-column-number +(defun lsp--line-character-to-point (line character) + "Return the point for character CHARACTER on line LINE." + (or (lsp-virtual-buffer-call :line/character->point line character) + (let ((inhibit-field-text-motion t)) + (lsp-save-restriction-and-excursion + (goto-char (point-min)) + (forward-line line) + ;; server may send character position beyond the current line and we + ;; should fallback to line end. + (-let [line-end (line-end-position)] + (if (> character (- line-end (point))) + line-end + (forward-char character) + (point))))))) + +(lsp-defun lsp--position-to-point ((&Position :line :character)) + "Convert `Position' object in PARAMS to a point." + (lsp--line-character-to-point line character)) + +(lsp-defun lsp--range-to-region ((&RangeToPoint :start :end)) + (cons start end)) + +(lsp-defun lsp--range-text ((&RangeToPoint :start :end)) + (buffer-substring start end)) + +(lsp-defun lsp--find-wrapping-range ((&SelectionRange :parent? :range (&RangeToPoint :start :end))) + (cond + ((and + (region-active-p) + (<= start (region-beginning) end) + (<= start (region-end) end) + (or (not (= start (region-beginning))) + (not (= end (region-end))))) + (cons start end)) + ((and (<= start (point) end) + (not (region-active-p))) + (cons start end)) + (parent? (lsp--find-wrapping-range parent?)))) + +(defun lsp--get-selection-range () + (or + (-when-let ((cache . cache-tick) lsp--document-selection-range-cache) + (when (= cache-tick (buffer-modified-tick)) cache)) + (let ((response (cl-first + (lsp-request + "textDocument/selectionRange" + (list :textDocument (lsp--text-document-identifier) + :positions (vector (lsp--cur-position))))))) + (setq lsp--document-selection-range-cache + (cons response (buffer-modified-tick))) + response))) + +(defun lsp-extend-selection () + "Extend selection." + (interactive) + (unless (lsp-feature? "textDocument/selectionRange") + (signal 'lsp-capability-not-supported (list "selectionRangeProvider"))) + (-when-let ((start . end) (lsp--find-wrapping-range (lsp--get-selection-range))) + (goto-char start) + (set-mark (point)) + (goto-char end) + (exchange-point-and-mark))) + +(defun lsp-warn (message &rest args) + "Display a warning message made from (`format-message' MESSAGE ARGS...). +This is equivalent to `display-warning', using `lsp-mode' as the type and +`:warning' as the level." + (display-warning 'lsp-mode (apply #'format-message message args))) + +(defun lsp--get-uri-handler (scheme) + "Get uri handler for SCHEME in the current workspace." + (--some (gethash scheme (lsp--client-uri-handlers (lsp--workspace-client it))) + (or (lsp-workspaces) (lsp--session-workspaces (lsp-session))))) + +(defun lsp--fix-path-casing (path) + "On windows, downcases path because the windows file system is +case-insensitive. + +On other systems, returns path without change." + (if (eq system-type 'windows-nt) (downcase path) path)) + +(defun lsp--uri-to-path (uri) + "Convert URI to a file path." + (if-let ((fn (->> (lsp-workspaces) + (-keep (-compose #'lsp--client-uri->path-fn #'lsp--workspace-client)) + (cl-first)))) + (funcall fn uri) + (lsp--uri-to-path-1 uri))) + +(defun lsp-remap-path-if-needed (file-name) + (-if-let ((virtual-buffer &as &plist :buffer) (gethash file-name lsp--virtual-buffer-mappings)) + (propertize (buffer-local-value 'buffer-file-name buffer) + 'lsp-virtual-buffer virtual-buffer) + file-name)) + +(defun lsp--uri-to-path-1 (uri) + "Convert URI to a file path." + (let* ((url (url-generic-parse-url (url-unhex-string uri))) + (type (url-type url)) + (target (url-target url)) + (file + (concat (decode-coding-string (url-filename url) + (or locale-coding-system 'utf-8)) + (when (and target + (not (s-match + (rx "#" (group (1+ num)) (or "," "#") + (group (1+ num)) + string-end) + uri))) + (concat "#" target)))) + (file-name (if (and type (not (string= type "file"))) + (if-let ((handler (lsp--get-uri-handler type))) + (funcall handler uri) + uri) + ;; `url-generic-parse-url' is buggy on windows: + ;; https://github.com/emacs-lsp/lsp-mode/pull/265 + (or (and (eq system-type 'windows-nt) + (eq (elt file 0) ?\/) + (substring file 1)) + file)))) + (->> file-name + (concat (-some #'lsp--workspace-host-root (lsp-workspaces))) + (lsp-remap-path-if-needed)))) + +(defun lsp--buffer-uri () + "Return URI of the current buffer." + (or lsp-buffer-uri + (plist-get lsp--virtual-buffer :buffer-uri) + (lsp--path-to-uri + (or (buffer-file-name) (buffer-file-name (buffer-base-buffer)))))) + +(defun lsp-register-client-capabilities (&rest _args) + "Implemented only to make `company-lsp' happy. +DELETE when `lsp-mode.el' is deleted.") + +(defconst lsp--url-path-allowed-chars + (url--allowed-chars (append '(?/) url-unreserved-chars)) + "`url-unreserved-chars' with additional delim ?/. +This set of allowed chars is enough for hexifying local file paths.") + +(defun lsp--path-to-uri-1 (path) + (concat lsp--uri-file-prefix + (--> path + (expand-file-name it) + (or (file-remote-p it 'localname t) it) + (url-hexify-string it lsp--url-path-allowed-chars)))) + +(defun lsp--path-to-uri (path) + "Convert PATH to a uri." + (if-let ((uri-fn (->> (lsp-workspaces) + (-keep (-compose #'lsp--client-path->uri-fn #'lsp--workspace-client)) + (cl-first)))) + (funcall uri-fn path) + (lsp--path-to-uri-1 path))) + +(defun lsp--string-match-any (regex-list str) + "Return the first regex, if any, within REGEX-LIST matching STR." + (--first (string-match it str) regex-list)) + +(cl-defstruct lsp-watch + (descriptors (make-hash-table :test 'equal)) + root-directory) + +(defun lsp--folder-watch-callback (event callback watch ignored-files ignored-directories) + (let ((file-name (cl-third event)) + (event-type (cl-second event))) + (cond + ((and (file-directory-p file-name) + (equal 'created event-type) + (not (lsp--string-match-any ignored-directories file-name))) + + (lsp-watch-root-folder (file-truename file-name) callback ignored-files ignored-directories watch) + + ;; process the files that are already present in + ;; the directory. + (->> (directory-files-recursively file-name ".*" t) + (seq-do (lambda (f) + (unless (file-directory-p f) + (funcall callback (list nil 'created f))))))) + ((and (memq event-type '(created deleted changed)) + (not (file-directory-p file-name)) + (not (lsp--string-match-any ignored-files file-name))) + (funcall callback event)) + ((and (memq event-type '(renamed)) + (not (file-directory-p file-name)) + (not (lsp--string-match-any ignored-files file-name))) + (funcall callback `(,(cl-first event) deleted ,(cl-third event))) + (funcall callback `(,(cl-first event) created ,(cl-fourth event))))))) + +(defun lsp--ask-about-watching-big-repo (number-of-directories dir) + "Ask the user if they want to watch NUMBER-OF-DIRECTORIES from a repository DIR. +This is useful when there is a lot of files in a repository, as +that may slow Emacs down. Returns t if the user wants to watch +the entire repository, nil otherwise." + (prog1 + (yes-or-no-p + (format + "Watching all the files in %s would require adding watches to %s directories, so watching the repo may slow Emacs down. +Do you want to watch all files in %s? " + dir + number-of-directories + dir)) + (lsp--info + (concat "You can configure this warning with the `lsp-enable-file-watchers' " + "and `lsp-file-watch-threshold' variables")))) + + +(defun lsp--path-is-watchable-directory (path dir ignored-directories) + "Figure out whether PATH (inside of DIR) is meant to have a file watcher set. +IGNORED-DIRECTORIES is a list of regexes to filter out directories we don't +want to watch." + (let + ((full-path (f-join dir path))) + (and (file-accessible-directory-p full-path) + (not (equal path ".")) + (not (equal path "..")) + (not (lsp--string-match-any ignored-directories full-path))))) + + +(defun lsp--all-watchable-directories (dir ignored-directories) + "Traverse DIR recursively returning a list of paths that should have watchers. +IGNORED-DIRECTORIES will be used for exclusions" + (let* ((dir (if (f-symlink? dir) + (file-truename dir) + dir))) + (apply #'nconc + ;; the directory itself is assumed to be part of the set + (list dir) + ;; collect all subdirectories that are watchable + (-map + (lambda (path) (lsp--all-watchable-directories (f-join dir path) ignored-directories)) + ;; but only look at subdirectories that are watchable + (-filter (lambda (path) (lsp--path-is-watchable-directory path dir ignored-directories)) + (directory-files dir)))))) + +(defun lsp-watch-root-folder (dir callback ignored-files ignored-directories &optional watch warn-big-repo?) + "Create recursive file notification watch in DIR. +CALLBACK will be called when there are changes in any of +the monitored files. WATCHES is a hash table directory->file +notification handle which contains all of the watch that +already have been created. Watches will not be created for +any directory that matches any regex in IGNORED-DIRECTORIES. +Watches will not be created for any file that matches any +regex in IGNORED-FILES." + (let* ((dir (if (f-symlink? dir) + (file-truename dir) + dir)) + (watch (or watch (make-lsp-watch :root-directory dir))) + (dirs-to-watch (lsp--all-watchable-directories dir ignored-directories))) + (lsp-log "Creating watchers for following %s folders:\n %s" + (length dirs-to-watch) + (s-join "\n " dirs-to-watch)) + (when (or + (not warn-big-repo?) + (not lsp-file-watch-threshold) + (let ((number-of-directories (length dirs-to-watch))) + (or + (< number-of-directories lsp-file-watch-threshold) + (condition-case nil + (lsp--ask-about-watching-big-repo number-of-directories dir) + (quit))))) + (dolist (current-dir dirs-to-watch) + (condition-case err + (progn + (puthash + current-dir + (file-notify-add-watch current-dir + '(change) + (lambda (event) + (lsp--folder-watch-callback event callback watch ignored-files ignored-directories))) + (lsp-watch-descriptors watch))) + (error (lsp-log "Failed to create a watch for %s: message" (error-message-string err))) + (file-missing (lsp-log "Failed to create a watch for %s: message" (error-message-string err)))))) + watch)) + +(defun lsp-kill-watch (watch) + "Delete WATCH." + (-> watch lsp-watch-descriptors hash-table-values (-each #'file-notify-rm-watch)) + (ht-clear! (lsp-watch-descriptors watch))) + +(defun lsp-json-bool (val) + "Convert VAL to JSON boolean." + (if val t :json-false)) + +(defmacro with-lsp-workspace (workspace &rest body) + "Helper macro for invoking BODY in WORKSPACE context." + (declare (debug (form body)) + (indent 1)) + `(let ((lsp--cur-workspace ,workspace)) ,@body)) + +(defmacro with-lsp-workspaces (workspaces &rest body) + "Helper macro for invoking BODY against multiple WORKSPACES." + (declare (debug (form body)) + (indent 1)) + `(let ((lsp--buffer-workspaces ,workspaces)) ,@body)) + + + +(defmacro lsp-consistency-check (package) + `(defconst ,(intern (concat (symbol-name package) + "-plist-value-when-compiled")) + (eval-when-compile lsp-use-plists))) + + +;; loading code-workspace files + +;;;###autoload +(defun lsp-load-vscode-workspace (file) + "Load vscode workspace from FILE" + (interactive "fSelect file to import: ") + (mapc #'lsp-workspace-folders-remove (lsp-session-folders (lsp-session))) + + (let ((dir (f-dirname file))) + (->> file + (json-read-file) + (alist-get 'folders) + (-map (-lambda ((&alist 'path)) + (lsp-workspace-folders-add (expand-file-name path dir))))))) + +;;;###autoload +(defun lsp-save-vscode-workspace (file) + "Save vscode workspace to FILE" + (interactive "FSelect file to save to: ") + + (let ((json-encoding-pretty-print t)) + (f-write-text (json-encode + `((folders . ,(->> (lsp-session) + (lsp-session-folders) + (--map `((path . ,it))))))) + 'utf-8 + file))) + + +(defmacro lsp-foreach-workspace (&rest body) + "Execute BODY for each of the current workspaces." + (declare (debug (form body))) + `(--map (with-lsp-workspace it ,@body) (lsp-workspaces))) + +(defmacro when-lsp-workspace (workspace &rest body) + "Helper macro for invoking BODY in WORKSPACE context if present." + (declare (debug (form body)) + (indent 1)) + `(when-let ((lsp--cur-workspace ,workspace)) ,@body)) + +(lsp-defun lsp--window-show-quick-pick (_workspace (&ShowQuickPickParams :place-holder :can-pick-many :items)) + (if-let* ((selectfunc (if can-pick-many #'completing-read-multiple #'completing-read)) + (itemLabels (seq-map (-lambda ((item &as &QuickPickItem :label)) (format "%s" label)) + items)) + (result (funcall-interactively + selectfunc + (format "%s%s " place-holder (if can-pick-many " (* for all)" "")) itemLabels)) + (choices (if (listp result) + (if (equal result '("*")) + itemLabels + result) + (list result)))) + (vconcat (seq-filter #'identity (seq-map (-lambda ((item &as &QuickPickItem :label :user-data)) + (if (member label choices) + (lsp-make-quick-pick-item :label label :picked t :user-data user-data) + nil)) + items))))) + +(lsp-defun lsp--window-show-input-box (_workspace (&ShowInputBoxParams :prompt :value?)) + (read-string (format "%s: " prompt) (or value? ""))) + +(lsp-defun lsp--window-show-message (_workspace (&ShowMessageRequestParams :message :type)) + "Send the server's messages to log. +PARAMS - the data sent from _WORKSPACE." + (funcall (cl-case type + (1 'lsp--error) + (2 'lsp--warn) + (t 'lsp--info)) + "%s" + message)) + +(lsp-defun lsp--window-log-message (workspace (&ShowMessageRequestParams :message :type)) + "Send the server's messages to log. +PARAMS - the data sent from WORKSPACE." + (ignore + (let ((client (lsp--workspace-client workspace))) + (when (or (not client) + (cl-notany (-rpartial #'string-match-p message) + (lsp--client-ignore-messages client))) + (lsp-log "%s" (lsp--propertize message type)))))) + +(lsp-defun lsp--window-log-message-request ((&ShowMessageRequestParams :message :type :actions?)) + "Display a message request to user sending the user selection back to server." + (let* ((message (lsp--propertize message type)) + (choices (seq-map #'lsp:message-action-item-title actions?))) + (if choices + (completing-read (concat message " ") (seq-into choices 'list) nil t) + (lsp-log message)))) + +(lsp-defun lsp--window-show-document ((&ShowDocumentParams :uri :selection?)) + "Show document URI in a buffer and go to SELECTION if any." + (let ((path (lsp--uri-to-path uri))) + (when (f-exists? path) + (with-current-buffer (find-file path) + (when selection? + (goto-char (lsp--position-to-point (lsp:range-start selection?)))) + t)))) + +(defcustom lsp-progress-prefix " ⌛ " + "Progress prefix." + :group 'lsp-mode + :type 'string + :package-version '(lsp-mode . "8.0.0")) + +(defcustom lsp-progress-function #'lsp-on-progress-modeline + "Function for handling the progress notifications." + :group 'lsp-mode + :type '(choice + (const :tag "Use modeline" lsp-on-progress-modeline) + (const :tag "Legacy(uses either `progress-reporter' or `spinner' based on `lsp-progress-via-spinner')" + lsp-on-progress-legacy) + (const :tag "Ignore" ignore) + (function :tag "Other function")) + :package-version '(lsp-mode . "8.0.0")) + +(defcustom lsp-request-while-no-input-may-block nil + "Have `lsp-request-while-no-input` block unless `non-essential` is t." + :group 'lsp-mode + :type 'boolean) + +(defun lsp--progress-status () + "Returns the status of the progress for the current workspaces." + (-let ((progress-status + (s-join + "|" + (-keep + (lambda (workspace) + (let ((tokens (lsp--workspace-work-done-tokens workspace))) + (unless (ht-empty? tokens) + (mapconcat + (-lambda ((&WorkDoneProgressBegin :message? :title :percentage?)) + (concat (if percentage? + (if (numberp percentage?) + (format "%.0f%%%% " percentage?) + (format "%s%%%% " percentage?)) + "") + (or message? title))) + (ht-values tokens) + "|")))) + (lsp-workspaces))))) + (unless (s-blank? progress-status) + (concat lsp-progress-prefix progress-status)))) + +(lsp-defun lsp-on-progress-modeline (workspace (&ProgressParams :token :value + (value &as &WorkDoneProgress :kind))) + "PARAMS contains the progress data. +WORKSPACE is the workspace that contains the progress token." + (add-to-list 'global-mode-string '(t (:eval (lsp--progress-status)))) + (pcase kind + ("begin" (lsp-workspace-set-work-done-token token value workspace)) + ("report" (lsp-workspace-set-work-done-token token value workspace)) + ("end" (lsp-workspace-rem-work-done-token token workspace))) + (force-mode-line-update)) + +(lsp-defun lsp-on-progress-legacy (workspace (&ProgressParams :token :value + (value &as &WorkDoneProgress :kind))) + "PARAMS contains the progress data. +WORKSPACE is the workspace that contains the progress token." + (pcase kind + ("begin" + (-let* (((&WorkDoneProgressBegin :title :percentage?) value) + (reporter + (if lsp-progress-via-spinner + (let* ((spinner-strings (alist-get (lsp-progress-spinner-type) spinner-types)) + ;; Set message as a tooltip for the spinner strings + (propertized-strings + (seq-map (lambda (string) (propertize string 'help-echo title)) + spinner-strings)) + (spinner-type (vconcat propertized-strings))) + ;; The progress relates to the server as a whole, + ;; display it on all buffers. + (mapcar (lambda (buffer) + (lsp-with-current-buffer buffer + (spinner-start spinner-type)) + buffer) + (lsp--workspace-buffers workspace))) + (if percentage? + (make-progress-reporter title 0 100 percentage?) + ;; No percentage, just progress + (make-progress-reporter title nil nil))))) + (lsp-workspace-set-work-done-token token reporter workspace))) + ("report" + (when-let ((reporter (lsp-workspace-get-work-done-token token workspace))) + (unless lsp-progress-via-spinner + (progress-reporter-update reporter (lsp:work-done-progress-report-percentage? value))))) + + ("end" + (when-let ((reporter (lsp-workspace-get-work-done-token token workspace))) + (if lsp-progress-via-spinner + (mapc (lambda (buffer) + (when (lsp-buffer-live-p buffer) + (lsp-with-current-buffer buffer + (spinner-stop)))) + reporter) + (progress-reporter-done reporter)) + (lsp-workspace-rem-work-done-token token workspace))))) + + +;; diagnostics + +(defvar lsp-diagnostic-filter nil + "A a function which will be called with + `&PublishDiagnosticsParams' and `workspace' which can be used + to filter out the diagnostics. The function should return + `&PublishDiagnosticsParams'. + +Common usecase are: +1. Filter the diagnostics for a particular language server. +2. Filter out the diagnostics under specific level.") + +(defvar lsp-diagnostic-stats (ht)) + +(defun lsp-diagnostics (&optional current-workspace?) + "Return the diagnostics from all workspaces." + (or (pcase (if current-workspace? + (lsp-workspaces) + (lsp--session-workspaces (lsp-session))) + (`() ()) + (`(,workspace) (lsp--workspace-diagnostics workspace)) + (`,workspaces (let ((result (make-hash-table :test 'equal))) + (mapc (lambda (workspace) + (->> workspace + (lsp--workspace-diagnostics) + (maphash (lambda (file-name diagnostics) + (puthash file-name + (append (gethash file-name result) diagnostics) + result))))) + workspaces) + result))) + (ht))) + +(defun lsp-diagnostics-stats-for (path) + "Get diagnostics statistics for PATH. +The result format is vector [_ errors warnings infos hints] or nil." + (gethash (lsp--fix-path-casing path) lsp-diagnostic-stats)) + +(defun lsp-diagnostics--update-path (path new-stats) + (let ((new-stats (copy-sequence new-stats)) + (path (lsp--fix-path-casing (directory-file-name path)))) + (if-let ((old-data (gethash path lsp-diagnostic-stats))) + (dotimes (idx 5) + (cl-callf + (aref old-data idx) + (aref new-stats idx))) + (puthash path new-stats lsp-diagnostic-stats)))) + +(lsp-defun lsp--on-diagnostics-update-stats (workspace + (&PublishDiagnosticsParams :uri :diagnostics)) + (let ((path (lsp--fix-path-casing (lsp--uri-to-path uri))) + (new-stats (make-vector 5 0))) + (mapc (-lambda ((&Diagnostic :severity?)) + (cl-incf (aref new-stats (or severity? 1)))) + diagnostics) + (when-let ((old-diags (gethash path (lsp--workspace-diagnostics workspace)))) + (mapc (-lambda ((&Diagnostic :severity?)) + (cl-decf (aref new-stats (or severity? 1)))) + old-diags)) + (lsp-diagnostics--update-path path new-stats) + (while (not (string= path (setf path (file-name-directory + (directory-file-name path))))) + (lsp-diagnostics--update-path path new-stats)))) + +(defun lsp--on-diagnostics (workspace params) + "Callback for textDocument/publishDiagnostics. +interface PublishDiagnosticsParams { + uri: string; + diagnostics: Diagnostic[]; +} +PARAMS contains the diagnostics data. +WORKSPACE is the workspace that contains the diagnostics." + (when lsp-diagnostic-filter + (setf params (funcall lsp-diagnostic-filter params workspace))) + + (lsp--on-diagnostics-update-stats workspace params) + + (-let* (((&PublishDiagnosticsParams :uri :diagnostics) params) + (lsp--virtual-buffer-mappings (ht)) + (file (lsp--fix-path-casing (lsp--uri-to-path uri))) + (workspace-diagnostics (lsp--workspace-diagnostics workspace))) + + (if (seq-empty-p diagnostics) + (remhash file workspace-diagnostics) + (puthash file (append diagnostics nil) workspace-diagnostics)) + + (run-hooks 'lsp-diagnostics-updated-hook))) + +(defun lsp-diagnostics--workspace-cleanup (workspace) + (->> workspace + (lsp--workspace-diagnostics) + (maphash (lambda (key _) + (lsp--on-diagnostics-update-stats + workspace + (lsp-make-publish-diagnostics-params + :uri (lsp--path-to-uri key) + :diagnostics []))))) + (clrhash (lsp--workspace-diagnostics workspace))) + + + +;; textDocument/foldingRange support + +(cl-defstruct lsp--folding-range beg end kind children) + +(defvar-local lsp--cached-folding-ranges nil) +(defvar-local lsp--cached-nested-folding-ranges nil) + +(defun lsp--folding-range-width (range) + (- (lsp--folding-range-end range) + (lsp--folding-range-beg range))) + +(defun lsp--get-folding-ranges () + "Get the folding ranges for the current buffer." + (unless (eq (buffer-chars-modified-tick) (car lsp--cached-folding-ranges)) + (let* ((ranges (lsp-request "textDocument/foldingRange" + `(:textDocument ,(lsp--text-document-identifier)))) + (sorted-line-col-pairs (->> ranges + (cl-mapcan (-lambda ((&FoldingRange :start-line + :start-character? + :end-line + :end-character?)) + (list (cons start-line start-character?) + (cons end-line end-character?)))) + (-sort #'lsp--line-col-comparator))) + (line-col-to-point-map (lsp--convert-line-col-to-points-batch + sorted-line-col-pairs))) + (setq lsp--cached-folding-ranges + (cons (buffer-chars-modified-tick) + (--> ranges + (seq-map (-lambda ((range &as + &FoldingRange :start-line + :start-character? + :end-line + :end-character? + :kind?)) + (make-lsp--folding-range + :beg (ht-get line-col-to-point-map + (cons start-line start-character?)) + :end (ht-get line-col-to-point-map + (cons end-line end-character?)) + :kind kind?)) + it) + (seq-filter (lambda (folding-range) + (< (lsp--folding-range-beg folding-range) + (lsp--folding-range-end folding-range))) + it) + (seq-into it 'list) + (delete-dups it)))))) + (cdr lsp--cached-folding-ranges)) + +(defun lsp--get-nested-folding-ranges () + "Get a list of nested folding ranges for the current buffer." + (-let [(tick . _) lsp--cached-folding-ranges] + (if (and (eq tick (buffer-chars-modified-tick)) + lsp--cached-nested-folding-ranges) + lsp--cached-nested-folding-ranges + (setq lsp--cached-nested-folding-ranges + (lsp--folding-range-build-trees (lsp--get-folding-ranges)))))) + +(defun lsp--folding-range-build-trees (ranges) + (setq ranges (seq-sort #'lsp--range-before-p ranges)) + (let* ((dummy-node (make-lsp--folding-range + :beg most-negative-fixnum + :end most-positive-fixnum)) + (stack (list dummy-node))) + (dolist (range ranges) + (while (not (lsp--range-inside-p range (car stack))) + (pop stack)) + (push range (lsp--folding-range-children (car stack))) + (push range stack)) + (lsp--folding-range-children dummy-node))) + +(defun lsp--range-inside-p (r1 r2) + "Return non-nil if folding range R1 lies inside R2" + (and (>= (lsp--folding-range-beg r1) (lsp--folding-range-beg r2)) + (<= (lsp--folding-range-end r1) (lsp--folding-range-end r2)))) + +(defun lsp--range-before-p (r1 r2) + "Return non-nil if folding range R1 ends before R2" + ;; Ensure r1 comes before r2 + (or (< (lsp--folding-range-beg r1) + (lsp--folding-range-beg r2)) + ;; If beg(r1) == beg(r2) make sure r2 ends first + (and (= (lsp--folding-range-beg r1) + (lsp--folding-range-beg r2)) + (< (lsp--folding-range-end r2) + (lsp--folding-range-end r1))))) + +(defun lsp--point-inside-range-p (point range) + "Return non-nil if POINT lies inside folding range RANGE." + (and (>= point (lsp--folding-range-beg range)) + (<= point (lsp--folding-range-end range)))) + +(cl-defun lsp--get-current-innermost-folding-range (&optional (point (point))) + "Return the innermost folding range POINT lies in." + (seq-reduce (lambda (innermost-range curr-range) + (if (and (lsp--point-inside-range-p point curr-range) + (or (null innermost-range) + (lsp--range-inside-p curr-range innermost-range))) + curr-range + innermost-range)) + (lsp--get-folding-ranges) + nil)) + +(cl-defun lsp--get-current-outermost-folding-range (&optional (point (point))) + "Return the outermost folding range POINT lies in." + (cdr (seq-reduce (-lambda ((best-pair &as outermost-width . _) curr-range) + (let ((curr-width (lsp--folding-range-width curr-range))) + (if (and (lsp--point-inside-range-p point curr-range) + (or (null best-pair) + (> curr-width outermost-width))) + (cons curr-width curr-range) + best-pair))) + (lsp--get-folding-ranges) + nil))) + +(defun lsp--folding-range-at-point-bounds () + (when (and lsp-enable-folding + (lsp-feature? "textDocument/foldingRange")) + (if-let ((range (lsp--get-current-innermost-folding-range))) + (cons (lsp--folding-range-beg range) + (lsp--folding-range-end range))))) +(put 'lsp--folding-range 'bounds-of-thing-at-point + #'lsp--folding-range-at-point-bounds) + +(defun lsp--get-nearest-folding-range (&optional backward) + (let ((point (point)) + (found nil)) + (while (not + (or found + (if backward + (<= point (point-min)) + (>= point (point-max))))) + (if backward (cl-decf point) (cl-incf point)) + (setq found (lsp--get-current-innermost-folding-range point))) + found)) + +(defun lsp--folding-range-at-point-forward-op (n) + (when (and lsp-enable-folding + (not (zerop n)) + (lsp-feature? "textDocument/foldingRange")) + (cl-block break + (dotimes (_ (abs n)) + (if-let ((range (lsp--get-nearest-folding-range (< n 0)))) + (goto-char (if (< n 0) + (lsp--folding-range-beg range) + (lsp--folding-range-end range))) + (cl-return-from break)))))) +(put 'lsp--folding-range 'forward-op + #'lsp--folding-range-at-point-forward-op) + +(defun lsp--folding-range-at-point-beginning-op () + (goto-char (car (lsp--folding-range-at-point-bounds)))) +(put 'lsp--folding-range 'beginning-op + #'lsp--folding-range-at-point-beginning-op) + +(defun lsp--folding-range-at-point-end-op () + (goto-char (cdr (lsp--folding-range-at-point-bounds)))) +(put 'lsp--folding-range 'end-op + #'lsp--folding-range-at-point-end-op) + +(defun lsp--range-at-point-bounds () + (or (lsp--folding-range-at-point-bounds) + (when-let ((range (and + (lsp-feature? "textDocument/hover") + (->> (lsp--text-document-position-params) + (lsp-request "textDocument/hover") + (lsp:hover-range?))))) + (lsp--range-to-region range)))) + +;; A more general purpose "thing", useful for applications like focus.el +(put 'lsp--range 'bounds-of-thing-at-point + #'lsp--range-at-point-bounds) + +(defun lsp--log-io-p (method) + "Return non nil if should log for METHOD." + (and lsp-log-io + (or (not lsp-log-io-allowlist-methods) + (member method lsp-log-io-allowlist-methods)))) + + +;; toggles + +(defun lsp-toggle-trace-io () + "Toggle client-server protocol logging." + (interactive) + (setq lsp-log-io (not lsp-log-io)) + (lsp--info "Server logging %s." (if lsp-log-io "enabled" "disabled"))) + +(defun lsp-toggle-signature-auto-activate () + "Toggle signature auto activate." + (interactive) + (setq lsp-signature-auto-activate + (unless lsp-signature-auto-activate '(:on-trigger-char))) + (lsp--info "Signature autoactivate %s." (if lsp-signature-auto-activate "enabled" "disabled")) + (lsp--update-signature-help-hook)) + +(defun lsp-toggle-on-type-formatting () + "Toggle on type formatting." + (interactive) + (setq lsp-enable-on-type-formatting (not lsp-enable-on-type-formatting)) + (lsp--info "On type formatting is %s." (if lsp-enable-on-type-formatting "enabled" "disabled")) + (lsp--update-on-type-formatting-hook)) + +(defun lsp-toggle-symbol-highlight () + "Toggle symbol highlighting." + (interactive) + (setq lsp-enable-symbol-highlighting (not lsp-enable-symbol-highlighting)) + + (cond + ((and lsp-enable-symbol-highlighting + (lsp-feature? "textDocument/documentHighlight")) + (add-hook 'lsp-on-idle-hook #'lsp--document-highlight nil t) + (lsp--info "Symbol highlighting enabled in current buffer.")) + ((not lsp-enable-symbol-highlighting) + (remove-hook 'lsp-on-idle-hook #'lsp--document-highlight t) + (lsp--remove-overlays 'lsp-highlight) + (lsp--info "Symbol highlighting disabled in current buffer.")))) + + +;; keybindings +(defvar lsp--binding-descriptions nil + "List of key binding/short description pair.") + +(defmacro lsp-define-conditional-key (keymap key def desc cond &rest bindings) + "In KEYMAP, define key sequence KEY as DEF conditionally. +This is like `define-key', except the definition disappears +whenever COND evaluates to nil. +DESC is the short-description for the binding. +BINDINGS is a list of (key def desc cond)." + (declare (indent defun) + (debug (form form form form form &rest sexp))) + (->> (cl-list* key def desc cond bindings) + (-partition 4) + (-mapcat (-lambda ((key def desc cond)) + `((define-key ,keymap ,key + '(menu-item + ,(format "maybe-%s" def) + ,def + :filter + (lambda (item) + (when (with-current-buffer (or (when (buffer-live-p lsp--describe-buffer) + lsp--describe-buffer) + (current-buffer)) + ,cond) + item)))) + (when (stringp ,key) + (setq lsp--binding-descriptions + (append lsp--binding-descriptions '(,key ,desc))))))) + macroexp-progn)) + +(defvar lsp--describe-buffer nil) + +(defun lsp-describe-buffer-bindings-advice (fn buffer &optional prefix menus) + (let ((lsp--describe-buffer buffer)) + (funcall fn buffer prefix menus))) + +(advice-add 'describe-buffer-bindings + :around + #'lsp-describe-buffer-bindings-advice) + +(defun lsp--prepend-prefix (mappings) + (->> mappings + (-partition 2) + (-mapcat (-lambda ((key description)) + (list (concat lsp-keymap-prefix " " key) + description))))) + +(defvar lsp-command-map + (-doto (make-sparse-keymap) + (lsp-define-conditional-key + ;; workspaces + "wD" lsp-disconnect "disconnect" (lsp-workspaces) + "wd" lsp-describe-session "describe session" t + "wq" lsp-workspace-shutdown "shutdown server" (lsp-workspaces) + "wr" lsp-workspace-restart "restart server" (lsp-workspaces) + "ws" lsp "start server" t + + ;; formatting + "==" lsp-format-buffer "format buffer" (or (lsp-feature? "textDocument/rangeFormatting") + (lsp-feature? "textDocument/formatting")) + "=r" lsp-format-region "format region" (lsp-feature? "textDocument/rangeFormatting") + + ;; folders + "Fa" lsp-workspace-folders-add "add folder" t + "Fb" lsp-workspace-blocklist-remove "un-blocklist folder" t + "Fr" lsp-workspace-folders-remove "remove folder" t + + ;; toggles + "TD" lsp-modeline-diagnostics-mode "toggle modeline diagnostics" (lsp-feature? + "textDocument/publishDiagnostics") + "TL" lsp-toggle-trace-io "toggle log io" t + "TS" lsp-ui-sideline-mode "toggle sideline" (featurep 'lsp-ui-sideline) + "TT" lsp-treemacs-sync-mode "toggle treemacs integration" (featurep 'lsp-treemacs) + "Ta" lsp-modeline-code-actions-mode "toggle modeline code actions" (lsp-feature? + "textDocument/codeAction") + "Tb" lsp-headerline-breadcrumb-mode "toggle breadcrumb" (lsp-feature? + "textDocument/documentSymbol") + "Td" lsp-ui-doc-mode "toggle documentation popup" (featurep 'lsp-ui-doc) + "Tf" lsp-toggle-on-type-formatting "toggle on type formatting" (lsp-feature? + "textDocument/onTypeFormatting") + "Th" lsp-toggle-symbol-highlight "toggle highlighting" (lsp-feature? "textDocument/documentHighlight") + "Tl" lsp-lens-mode "toggle lenses" (lsp-feature? "textDocument/codeLens") + "Ts" lsp-toggle-signature-auto-activate "toggle signature" (lsp-feature? "textDocument/signatureHelp") + + ;; goto + "ga" xref-find-apropos "find symbol in workspace" (lsp-feature? "workspace/symbol") + "gd" lsp-find-declaration "find declarations" (lsp-feature? "textDocument/declaration") + "ge" lsp-treemacs-errors-list "show errors" (fboundp 'lsp-treemacs-errors-list) + "gg" lsp-find-definition "find definitions" (lsp-feature? "textDocument/definition") + "gh" lsp-treemacs-call-hierarchy "call hierarchy" (and (lsp-feature? "callHierarchy/incomingCalls") + (fboundp 'lsp-treemacs-call-hierarchy)) + "gi" lsp-find-implementation "find implementations" (lsp-feature? "textDocument/implementation") + "gr" lsp-find-references "find references" (lsp-feature? "textDocument/references") + "gt" lsp-find-type-definition "find type definition" (lsp-feature? "textDocument/typeDefinition") + + ;; help + "hg" lsp-ui-doc-glance "glance symbol" (and (featurep 'lsp-ui-doc) + (lsp-feature? "textDocument/hover")) + "hh" lsp-describe-thing-at-point "describe symbol at point" (lsp-feature? "textDocument/hover") + "hs" lsp-signature-activate "signature help" (lsp-feature? "textDocument/signatureHelp") + + ;; refactoring + "ro" lsp-organize-imports "organize imports" (lsp-feature? "textDocument/codeAction") + "rr" lsp-rename "rename" (lsp-feature? "textDocument/rename") + + ;; actions + "aa" lsp-execute-code-action "code actions" (lsp-feature? "textDocument/codeAction") + "ah" lsp-document-highlight "highlight symbol" (lsp-feature? "textDocument/documentHighlight") + "al" lsp-avy-lens "lens" (and (bound-and-true-p lsp-lens-mode) (featurep 'avy)) + + ;; peeks + "Gg" lsp-ui-peek-find-definitions "peek definitions" (and (lsp-feature? "textDocument/definition") + (fboundp 'lsp-ui-peek-find-definitions)) + "Gi" lsp-ui-peek-find-implementation "peek implementations" (and + (fboundp 'lsp-ui-peek-find-implementation) + (lsp-feature? "textDocument/implementation")) + "Gr" lsp-ui-peek-find-references "peek references" (and (fboundp 'lsp-ui-peek-find-references) + (lsp-feature? "textDocument/references")) + "Gs" lsp-ui-peek-find-workspace-symbol "peek workspace symbol" (and (fboundp + 'lsp-ui-peek-find-workspace-symbol) + (lsp-feature? "workspace/symbol"))))) + + +;; which-key integration + +(declare-function which-key-add-major-mode-key-based-replacements "ext:which-key") +(declare-function which-key-add-key-based-replacements "ext:which-key") + +(defun lsp-enable-which-key-integration (&optional all-modes) + "Adds descriptions for `lsp-mode-map' to `which-key-mode' for the current +active `major-mode', or for all major modes when ALL-MODES is t." + (cl-flet ((which-key-fn (if all-modes + 'which-key-add-key-based-replacements + (apply-partially 'which-key-add-major-mode-key-based-replacements major-mode)))) + (apply + #'which-key-fn + (lsp--prepend-prefix + (cl-list* + "" "lsp" + "w" "workspaces" + "F" "folders" + "=" "formatting" + "T" "toggle" + "g" "goto" + "h" "help" + "r" "refactor" + "a" "code actions" + "G" "peek" + lsp--binding-descriptions))))) + + +;; Globbing syntax + +;; We port VSCode's glob-to-regexp code +;; (https://github.com/Microsoft/vscode/blob/466da1c9013c624140f6d1473b23a870abc82d44/src/vs/base/common/glob.ts) +;; since the LSP globbing syntax seems to be the same as that of +;; VSCode. + +(defconst lsp-globstar "**" + "Globstar pattern.") + +(defconst lsp-glob-split ?/ + "The character by which we split path components in a glob +pattern.") + +(defconst lsp-path-regexp "[/\\\\]" + "Forward or backslash to be used as a path separator in +computed regexps.") + +(defconst lsp-non-path-regexp "[^/\\\\]" + "A regexp matching anything other than a slash.") + +(defconst lsp-globstar-regexp + (format "\\(?:%s\\|%s+%s\\|%s%s+\\)*?" + lsp-path-regexp + lsp-non-path-regexp lsp-path-regexp + lsp-path-regexp lsp-non-path-regexp) + "Globstar in regexp form.") + +(defun lsp-split-glob-pattern (pattern split-char) + "Split PATTERN at SPLIT-CHAR while respecting braces and brackets." + (when pattern + (let ((segments nil) + (in-braces nil) + (in-brackets nil) + (current-segment "")) + (dolist (char (string-to-list pattern)) + (cl-block 'exit-point + (if (eq char split-char) + (when (and (null in-braces) + (null in-brackets)) + (push current-segment segments) + (setq current-segment "") + (cl-return-from 'exit-point)) + (pcase char + (?{ + (setq in-braces t)) + (?} + (setq in-braces nil)) + (?\[ + (setq in-brackets t)) + (?\] + (setq in-brackets nil)))) + (setq current-segment (concat current-segment + (char-to-string char))))) + (unless (string-empty-p current-segment) + (push current-segment segments)) + (nreverse segments)))) + +(defun lsp--glob-to-regexp (pattern) + "Helper function to convert a PATTERN from LSP's glob syntax to +an Elisp regexp." + (if (string-empty-p pattern) + "" + (let ((current-regexp "") + (glob-segments (lsp-split-glob-pattern pattern lsp-glob-split))) + (if (-all? (lambda (segment) (eq segment lsp-globstar)) + glob-segments) + ".*" + (let ((prev-segment-was-globstar nil)) + (seq-do-indexed + (lambda (segment index) + (if (string-equal segment lsp-globstar) + (unless prev-segment-was-globstar + (setq current-regexp (concat current-regexp + lsp-globstar-regexp)) + (setq prev-segment-was-globstar t)) + (let ((in-braces nil) + (brace-val "") + (in-brackets nil) + (bracket-val "")) + (dolist (char (string-to-list segment)) + (cond + ((and (not (char-equal char ?\})) + in-braces) + (setq brace-val (concat brace-val + (char-to-string char)))) + ((and in-brackets + (or (not (char-equal char ?\])) + (string-empty-p bracket-val))) + (let ((curr (cond + ((char-equal char ?-) + "-") + ;; NOTE: ?\^ and ?^ are different characters + ((and (memq char '(?^ ?!)) + (string-empty-p bracket-val)) + "^") + ((char-equal char lsp-glob-split) + "") + (t + (regexp-quote (char-to-string char)))))) + (setq bracket-val (concat bracket-val curr)))) + (t + (cl-case char + (?{ + (setq in-braces t)) + (?\[ + (setq in-brackets t)) + (?} + (let* ((choices (lsp-split-glob-pattern brace-val ?\,)) + (brace-regexp (concat "\\(?:" + (mapconcat #'lsp--glob-to-regexp choices "\\|") + "\\)"))) + (setq current-regexp (concat current-regexp + brace-regexp)) + (setq in-braces nil) + (setq brace-val ""))) + (?\] + (setq current-regexp + (concat current-regexp + "[" bracket-val "]")) + (setq in-brackets nil) + (setq bracket-val "")) + (?? + (setq current-regexp + (concat current-regexp + lsp-non-path-regexp))) + (?* + (setq current-regexp + (concat current-regexp + lsp-non-path-regexp "*?"))) + (t + (setq current-regexp + (concat current-regexp + (regexp-quote (char-to-string char))))))))) + (when (and (< index (1- (length glob-segments))) + (or (not (string-equal (nth (1+ index) glob-segments) + lsp-globstar)) + (< (+ index 2) + (length glob-segments)))) + (setq current-regexp + (concat current-regexp + lsp-path-regexp))) + (setq prev-segment-was-globstar nil)))) + glob-segments) + current-regexp))))) + +;; See https://github.com/emacs-lsp/lsp-mode/issues/2365 +(defun lsp-glob-unbrace-at-top-level (glob-pattern) + "If GLOB-PATTERN does not start with a brace, return a singleton list +containing GLOB-PATTERN. + +If GLOB-PATTERN does start with a brace, return a list of the +comma-separated globs within the top-level braces." + (if (not (string-prefix-p "{" glob-pattern)) + (list glob-pattern) + (lsp-split-glob-pattern (substring glob-pattern 1 -1) ?\,))) + +(defun lsp-glob-convert-to-wrapped-regexp (glob-pattern) + "Convert GLOB-PATTERN to a regexp wrapped with the beginning- +and end-of-string meta-characters." + (concat "\\`" (lsp--glob-to-regexp (string-trim glob-pattern)) "\\'")) + +(defun lsp-glob-to-regexps (glob-pattern) + "Convert a GLOB-PATTERN to a list of Elisp regexps." + (when-let* + ((glob-pattern (cond ((hash-table-p glob-pattern) + (ht-get glob-pattern "pattern")) + ((stringp glob-pattern) glob-pattern) + (t (error "Unknown glob-pattern type: %s" glob-pattern)))) + (trimmed-pattern (string-trim glob-pattern)) + (top-level-unbraced-patterns (lsp-glob-unbrace-at-top-level trimmed-pattern))) + (seq-map #'lsp-glob-convert-to-wrapped-regexp + top-level-unbraced-patterns))) + + + +(defvar lsp-mode-menu) + +(defun lsp-mouse-click (event) + (interactive "e") + (let* ((ec (event-start event)) + (choice (x-popup-menu event lsp-mode-menu)) + (action (lookup-key lsp-mode-menu (apply 'vector choice)))) + + (select-window (posn-window ec)) + + (unless (and (region-active-p) (eq action 'lsp-execute-code-action)) + (goto-char (posn-point ec))) + (run-with-idle-timer + 0.001 nil + (lambda () + (cl-labels ((check (value) (not (null value)))) + (when choice + (call-interactively action))))))) + +(defvar lsp-mode-map + (let ((map (make-sparse-keymap))) + (define-key map (kbd "C-<down-mouse-1>") #'lsp-find-definition-mouse) + (define-key map (kbd "C-<mouse-1>") #'ignore) + (define-key map (kbd "<mouse-3>") #'lsp-mouse-click) + (define-key map (kbd "C-S-SPC") #'lsp-signature-activate) + (when lsp-keymap-prefix + (define-key map (kbd lsp-keymap-prefix) lsp-command-map)) + map) + "Keymap for `lsp-mode'.") + +(define-minor-mode lsp-mode "Mode for LSP interaction." + :keymap lsp-mode-map + :lighter + (" LSP[" + (lsp--buffer-workspaces + (:eval (mapconcat #'lsp--workspace-print lsp--buffer-workspaces "][")) + (:propertize "Disconnected" face warning)) + "]") + :group 'lsp-mode + (when (and lsp-mode (not lsp--buffer-workspaces) (not lsp--buffer-deferred)) + ;; fire up `lsp' when someone calls `lsp-mode' instead of `lsp' + (lsp))) + +(defvar lsp-mode-menu + (easy-menu-create-menu + nil + `(["Go to definition" lsp-find-definition + :active (lsp-feature? "textDocument/definition")] + ["Find references" lsp-find-references + :active (lsp-feature? "textDocument/references")] + ["Find implementations" lsp-find-implementation + :active (lsp-feature? "textDocument/implementation")] + ["Find declarations" lsp-find-declaration + :active (lsp-feature? "textDocument/declaration")] + ["Go to type declaration" lsp-find-type-definition + :active (lsp-feature? "textDocument/typeDefinition")] + "--" + ["Describe" lsp-describe-thing-at-point] + ["Code action" lsp-execute-code-action] + ["Format" lsp-format-buffer] + ["Highlight references" lsp-document-highlight] + ["Type Hierarchy" lsp-java-type-hierarchy + :visible (lsp-can-execute-command? "java.navigate.resolveTypeHierarchy")] + ["Type Hierarchy" lsp-treemacs-type-hierarchy + :visible (and (not (lsp-can-execute-command? "java.navigate.resolveTypeHierarchy")) + (functionp 'lsp-treemacs-type-hierarchy) + (lsp-feature? "textDocument/typeHierarchy"))] + ["Call Hierarchy" lsp-treemacs-call-hierarchy + :visible (and (functionp 'lsp-treemacs-call-hierarchy) + (lsp-feature? "textDocument/callHierarchy"))] + ["Rename" lsp-rename + :active (lsp-feature? "textDocument/rename")] + "--" + ("Session" + ["View logs" lsp-workspace-show-log] + ["Describe" lsp-describe-session] + ["Shutdown" lsp-shutdown-workspace] + ["Restart" lsp-restart-workspace]) + ("Workspace Folders" + ["Add" lsp-workspace-folders-add] + ["Remove" lsp-workspace-folders-remove] + ["Open" lsp-workspace-folders-open]) + ("Toggle features" + ["Lenses" lsp-lens-mode] + ["Headerline breadcrumb" lsp-headerline-breadcrumb-mode] + ["Modeline code actions" lsp-modeline-code-actions-mode] + ["Modeline diagnostics" lsp-modeline-diagnostics-mode]) + "---" + ("Debug" + :active (bound-and-true-p dap-ui-mode) + :filter ,(lambda (_) + (and (boundp 'dap-ui-menu-items) + (nthcdr 3 dap-ui-menu-items)))))) + "Menu for lsp-mode.") + +(defalias 'make-lsp-client 'make-lsp--client) + +(cl-defstruct lsp--registered-capability + (id "") + (method " ") + (options nil)) + +;; A ‘lsp--workspace’ object represents exactly one language server process. +(cl-defstruct lsp--workspace + ;; the `ewoc' object for displaying I/O to and from the server + (ewoc nil) + + ;; ‘server-capabilities’ is a hash table of the language server capabilities. + ;; It is the hash table representation of a LSP ServerCapabilities structure; + ;; cf. https://microsoft.github.io/language-server-protocol/specification#initialize. + (server-capabilities nil) + + ;; ‘registered-server-capabilities’ is a list of hash tables that represent + ;; dynamically-registered Registration objects. See + ;; https://microsoft.github.io/language-server-protocol/specification#client_registerCapability. + (registered-server-capabilities nil) + + ;; ‘root’ is a directory name or a directory file name for the workspace + ;; root. ‘lsp-mode’ passes this directory to the ‘initialize’ method of the + ;; language server; see + ;; https://microsoft.github.io/language-server-protocol/specification#initialize. + (root nil) + + ;; ‘client’ is the ‘lsp--client’ object associated with this workspace. + (client nil) + + ;; ‘host-root’ contains the host root info as derived from `file-remote-p'. It + ;; used to derive the file path in `lsp--uri-to-path' when using tramp + ;; connection. + (host-root nil) + + ;; ‘proc’ is a process object; it may represent a regular process, a pipe, or + ;; a network connection. ‘lsp-mode’ communicates with ‘proc’ using the + ;; language server protocol. ‘proc’ corresponds to the COMMUNICATION-PROCESS + ;; element of the return value of the client’s ‘get-root’ field, which see. + (proc nil) + + ;; ‘proc’ is a process object; it must represent a regular process, not a + ;; pipe or network process. It represents the actual server process that + ;; corresponds to this workspace. ‘cmd-proc’ corresponds to the + ;; COMMAND-PROCESS element of the return value of the client’s ‘get-root’ + ;; field, which see. + (cmd-proc nil) + + ;; ‘buffers’ is a list of buffers associated with this workspace. + (buffers nil) + + ;; if semantic tokens is enabled, `semantic-tokens-faces' contains + ;; one face (or nil) for each token type supported by the language server. + (semantic-tokens-faces nil) + + ;; If semantic highlighting is enabled, `semantic-tokens-modifier-faces' + ;; contains one face (or nil) for each modifier type supported by the language + ;; server + (semantic-tokens-modifier-faces nil) + + ;; Extra client capabilities provided by third-party packages using + ;; `lsp-register-client-capabilities'. It's value is an alist of (PACKAGE-NAME + ;; . CAPS), where PACKAGE-NAME is a symbol of the third-party package name, + ;; and CAPS is either a plist of the client capabilities, or a function that + ;; takes no argument and returns a plist of the client capabilities or nil. + (extra-client-capabilities nil) + + ;; Workspace status + (status nil) + + ;; ‘metadata’ is a generic storage for workspace specific data. It is + ;; accessed via `lsp-workspace-set-metadata' and `lsp-workspace-set-metadata' + (metadata (make-hash-table :test 'equal)) + + ;; contains all the file notification watches that have been created for the + ;; current workspace in format filePath->file notification handle. + (watches (make-hash-table :test 'equal)) + + ;; list of workspace folders + (workspace-folders nil) + + ;; ‘last-id’ the last request id for the current workspace. + (last-id 0) + + ;; ‘status-string’ allows extensions to specify custom status string based on + ;; the Language Server specific messages. + (status-string nil) + + ;; ‘shutdown-action’ flag used to mark that workspace should not be restarted (e.g. it + ;; was stopped). + shutdown-action + + ;; ‘diagnostics’ a hashmap with workspace diagnostics. + (diagnostics (make-hash-table :test 'equal)) + + ;; contains all the workDone progress tokens that have been created + ;; for the current workspace. + (work-done-tokens (make-hash-table :test 'equal))) + + +(cl-defstruct lsp-session + ;; contains the folders that are part of the current session + folders + ;; contains the folders that must not be imported in the current workspace. + folders-blocklist + ;; contains the list of folders that must be imported in a project in case of + ;; multi root LSP server. + (server-id->folders (make-hash-table :test 'equal)) + ;; folder to list of the servers that are associated with the folder. + (folder->servers (make-hash-table :test 'equal)) + ;; ‘metadata’ is a generic storage for workspace specific data. It is + ;; accessed via `lsp-workspace-set-metadata' and `lsp-workspace-set-metadata' + (metadata (make-hash-table :test 'equal))) + +(defun lsp-workspace-status (status-string &optional workspace) + "Set current workspace status to STATUS-STRING. +If WORKSPACE is not specified defaults to lsp--cur-workspace." + (let ((status-string (when status-string (replace-regexp-in-string "%" "%%" status-string)))) + (setf (lsp--workspace-status-string (or workspace lsp--cur-workspace)) status-string))) + +(defun lsp-session-set-metadata (key value &optional _workspace) + "Associate KEY with VALUE in the WORKSPACE metadata. +If WORKSPACE is not provided current workspace will be used." + (puthash key value (lsp-session-metadata (lsp-session)))) + +(defalias 'lsp-workspace-set-metadata 'lsp-session-set-metadata) + +(defun lsp-session-get-metadata (key &optional _workspace) + "Lookup KEY in WORKSPACE metadata. +If WORKSPACE is not provided current workspace will be used." + (gethash key (lsp-session-metadata (lsp-session)))) + +(defalias 'lsp-workspace-get-metadata 'lsp-session-get-metadata) + +(defun lsp-workspace-set-work-done-token (token value workspace) + "Associate TOKEN with VALUE in the WORKSPACE work-done-tokens." + (puthash token value (lsp--workspace-work-done-tokens workspace))) + +(defun lsp-workspace-get-work-done-token (token workspace) + "Lookup TOKEN in the WORKSPACE work-done-tokens." + (gethash token (lsp--workspace-work-done-tokens workspace))) + +(defun lsp-workspace-rem-work-done-token (token workspace) + "Remove TOKEN from the WORKSPACE work-done-tokens." + (remhash token (lsp--workspace-work-done-tokens workspace))) + + +(defun lsp--make-notification (method &optional params) + "Create notification body for method METHOD and parameters PARAMS." + (list :jsonrpc "2.0" :method method :params params)) + +(defalias 'lsp--make-request 'lsp--make-notification) +(defalias 'lsp-make-request 'lsp--make-notification) + +(defun lsp--make-response (id result) + "Create response for REQUEST with RESULT." + `(:jsonrpc "2.0" :id ,id :result ,result)) + +(defun lsp-make-notification (method &optional params) + "Create notification body for method METHOD and parameters PARAMS." + (lsp--make-notification method params)) + +(defmacro lsp--json-serialize (params) + (if (progn + (require 'json) + (fboundp 'json-serialize)) + `(json-serialize ,params + :null-object nil + :false-object :json-false) + `(let ((json-false :json-false)) + (json-encode ,params)))) + +(defun lsp--make-message (params) + "Create a LSP message from PARAMS, after encoding it to a JSON string." + (let ((body (lsp--json-serialize params))) + (concat "Content-Length: " + (number-to-string (1+ (string-bytes body))) + "\r\n\r\n" + body + "\n"))) + +(cl-defstruct lsp--log-entry timestamp process-time type method id body) + +(defun lsp--make-log-entry (method id body type &optional process-time) + "Create an outgoing log object from BODY with method METHOD and id ID. +If ID is non-nil, then the body is assumed to be a notification. +TYPE can either be `incoming' or `outgoing'" + (cl-assert (memq type '(incoming-req outgoing-req incoming-notif + outgoing-notif incoming-resp + outgoing-resp))) + (make-lsp--log-entry + :timestamp (format-time-string "%I:%M:%S %p") + :process-time process-time + :method method + :id id + :type type + :body body)) + +(defun lsp--log-font-lock-json (body) + "Font lock JSON BODY." + (with-temp-buffer + (insert body) + ;; We set the temp buffer file-name extension to .json and call `set-auto-mode' + ;; so the users configured json mode is used which could be + ;; `json-mode', `json-ts-mode', `jsonian-mode', etc. + (let ((buffer-file-name "lsp-log.json")) + (delay-mode-hooks + (set-auto-mode) + (if (fboundp 'font-lock-ensure) + (font-lock-ensure) + (with-no-warnings + (font-lock-fontify-buffer))))) + (buffer-string))) + +(defun lsp--log-entry-pp (entry) + (cl-assert (lsp--log-entry-p entry)) + (pcase-let (((cl-struct lsp--log-entry timestamp method id type process-time + body) + entry) + (json-false :json-false) + (json-encoding-pretty-print t) + (str nil)) + (setq str + (concat (format "[Trace - %s] " timestamp) + (pcase type + ('incoming-req (format "Received request '%s - (%s)." method id)) + ('outgoing-req (format "Sending request '%s - (%s)'." method id)) + + ('incoming-notif (format "Received notification '%s'." method)) + ('outgoing-notif (format "Sending notification '%s'." method)) + + ('incoming-resp (format "Received response '%s - (%s)' in %dms." + method id process-time)) + ('outgoing-resp + (format + "Sending response '%s - (%s)'. Processing request took %dms" + method id process-time))) + "\n" + (if (memq type '(incoming-resp ougoing-resp)) + "Result: " + "Params: ") + (lsp--log-font-lock-json (json-encode body)) + "\n\n\n")) + (setq str (propertize str 'mouse-face 'highlight 'read-only t)) + (insert str))) + +(defvar-local lsp--log-io-ewoc nil) + +(defun lsp--get-create-io-ewoc (workspace) + (if (and (lsp--workspace-ewoc workspace) + (buffer-live-p (ewoc-buffer (lsp--workspace-ewoc workspace)))) + (lsp--workspace-ewoc workspace) + (with-current-buffer (lsp--get-log-buffer-create workspace) + (unless (eq 'lsp-log-io-mode major-mode) (lsp-log-io-mode)) + (setq-local window-point-insertion-type t) + (setq lsp--log-io-ewoc (ewoc-create #'lsp--log-entry-pp nil nil t)) + (setf (lsp--workspace-ewoc workspace) lsp--log-io-ewoc)) + (lsp--workspace-ewoc workspace))) + +(defun lsp--ewoc-count (ewoc) + (let* ((count 0) + (count-fn (lambda (_) (setq count (1+ count))))) + (ewoc-map count-fn ewoc) + count)) + +(defun lsp--log-entry-new (entry workspace) + (let* ((ewoc (lsp--get-create-io-ewoc workspace)) + (count (and (not (eq lsp-io-messages-max t)) (lsp--ewoc-count ewoc))) + (node (if (or (eq lsp-io-messages-max t) + (>= lsp-io-messages-max count)) + nil + (ewoc-nth ewoc (1- lsp-io-messages-max)))) + (prev nil) + (inhibit-read-only t)) + (while node + (setq prev (ewoc-prev ewoc node)) + (ewoc-delete ewoc node) + (setq node prev)) + (ewoc-enter-last ewoc entry))) + +(defun lsp--send-notification (body) + "Send BODY as a notification to the language server." + (lsp-foreach-workspace + (when (lsp--log-io-p (plist-get body :method)) + (lsp--log-entry-new (lsp--make-log-entry + (plist-get body :method) + nil (plist-get body :params) 'outgoing-notif) + lsp--cur-workspace)) + (lsp--send-no-wait body + (lsp--workspace-proc lsp--cur-workspace)))) + +(defalias 'lsp-send-notification 'lsp--send-notification) + +(defun lsp-notify (method params) + "Send notification METHOD with PARAMS." + (lsp--send-notification (lsp--make-notification method params))) + +(defun lsp--cur-workspace-check () + "Check whether buffer lsp workspace(s) are set." + (cl-assert (lsp-workspaces) nil + "No language server(s) is associated with this buffer.")) + +(defun lsp--send-request (body &optional no-wait no-merge) + "Send BODY as a request to the language server, get the response. +If NO-WAIT is non-nil, don't synchronously wait for a response. +If NO-MERGE is non-nil, don't merge the results but return an +alist mapping workspace->result." + (lsp-request (plist-get body :method) + (plist-get body :params) + :no-wait no-wait + :no-merge no-merge)) + +(defalias 'lsp-send-request 'lsp--send-request + "Send BODY as a request to the language server and return the response +synchronously. +\n(fn BODY)") + +(cl-defun lsp-request (method params &key no-wait no-merge) + "Send request METHOD with PARAMS. +If NO-MERGE is non-nil, don't merge the results but return alist +workspace->result. +If NO-WAIT is non-nil send the request as notification." + (if no-wait + (lsp-notify method params) + (let* ((send-time (float-time)) + ;; max time by which we must get a response + (expected-time + (and + lsp-response-timeout + (+ send-time lsp-response-timeout))) + resp-result resp-error done?) + (unwind-protect + (progn + (lsp-request-async method params + (lambda (res) (setf resp-result (or res :finished)) (throw 'lsp-done '_)) + :error-handler (lambda (err) (setf resp-error err) (throw 'lsp-done '_)) + :no-merge no-merge + :mode 'detached + :cancel-token :sync-request) + (while (not (or resp-error resp-result)) + (if (functionp 'json-rpc-connection) + (catch 'lsp-done (sit-for 0.01)) + (catch 'lsp-done + (accept-process-output + nil + (if expected-time (- expected-time send-time) 1)))) + (setq send-time (float-time)) + (when (and expected-time (< expected-time send-time)) + (error "Timeout while waiting for response. Method: %s" method))) + (setq done? t) + (cond + ((eq resp-result :finished) nil) + (resp-result resp-result) + ((lsp-json-error? resp-error) (error (lsp:json-error-message resp-error))) + ((lsp-json-error? (cl-first resp-error)) + (error (lsp:json-error-message (cl-first resp-error)))))) + (unless done? + (lsp-cancel-request-by-token :sync-request)))))) + +(cl-defun lsp-request-while-no-input (method params) + "Send request METHOD with PARAMS and waits until there is no input. +Return same value as `lsp--while-no-input' and respecting `non-essential'." + (if (or non-essential (not lsp-request-while-no-input-may-block)) + (let* ((send-time (float-time)) + ;; max time by which we must get a response + (expected-time + (and + lsp-response-timeout + (+ send-time lsp-response-timeout))) + resp-result resp-error done?) + (unwind-protect + (progn + (lsp-request-async method params + (lambda (res) (setf resp-result (or res :finished)) (throw 'lsp-done '_)) + :error-handler (lambda (err) (setf resp-error err) (throw 'lsp-done '_)) + :mode 'detached + :cancel-token :sync-request) + (while (not (or resp-error resp-result (input-pending-p))) + (catch 'lsp-done + (sit-for + (if expected-time (- expected-time send-time) 1))) + (setq send-time (float-time)) + (when (and expected-time (< expected-time send-time)) + (error "Timeout while waiting for response. Method: %s" method))) + (setq done? (or resp-error resp-result)) + (cond + ((eq resp-result :finished) nil) + (resp-result resp-result) + ((lsp-json-error? resp-error) (error (lsp:json-error-message resp-error))) + ((lsp-json-error? (cl-first resp-error)) + (error (lsp:json-error-message (cl-first resp-error)))))) + (unless done? + (lsp-cancel-request-by-token :sync-request)) + (when (and (input-pending-p) lsp--throw-on-input) + (throw 'input :interrupted)))) + (lsp-request method params))) + +(defvar lsp--cancelable-requests (ht)) + +(cl-defun lsp-request-async (method params callback + &key mode error-handler cancel-handler no-merge cancel-token) + "Send METHOD with PARAMS as a request to the language server. +Call CALLBACK with the response received from the server +asynchronously. +MODE determines when the callback will be called depending on the +condition of the original buffer. It could be: +- `detached' which means that the callback will be executed no +matter what has happened to the buffer. +- `alive' - the callback will be executed only if the buffer from +which the call was executed is still alive. +- `current' the callback will be executed only if the original buffer +is still selected. +- `tick' - the callback will be executed only if the buffer was not modified. +- `unchanged' - the callback will be executed only if the buffer hasn't +changed and if the buffer is not modified. + +ERROR-HANDLER will be called in case the request has failed. +CANCEL-HANDLER will be called in case the request is being canceled. +If NO-MERGE is non-nil, don't merge the results but return alist +workspace->result. +CANCEL-TOKEN is the token that can be used to cancel request." + (lsp--send-request-async `(:jsonrpc "2.0" :method ,method :params ,params) + callback mode error-handler cancel-handler no-merge cancel-token)) + +(defun lsp--create-request-cancel (id workspaces hook buf method cancel-callback) + (lambda (&rest _) + (unless (and (equal 'post-command-hook hook) + (equal (current-buffer) buf)) + (lsp--request-cleanup-hooks id) + (with-lsp-workspaces workspaces + (lsp--cancel-request id) + (when cancel-callback (funcall cancel-callback))) + (lsp-log "Cancelling %s(%s) in hook %s" method id hook)))) + +(defun lsp--create-async-callback + (callback method no-merge workspaces) + "Create async handler expecting COUNT results, merge them and call CALLBACK. +MODE determines when the callback will be called depending on the +condition of the original buffer. METHOD is the invoked method. +If NO-MERGE is non-nil, don't merge the results but return alist +workspace->result. ID is the request id." + (let (results errors) + (lambda (result) + (push (cons lsp--cur-workspace result) + (if (eq result :error) errors results)) + (when (and (not (eq (length errors) (length workspaces))) + (eq (+ (length errors) (length results)) (length workspaces))) + (funcall callback + (if no-merge + results + (lsp--merge-results (-map #'cl-rest results) method))))))) + +(defcustom lsp-default-create-error-handler-fn nil + "Default error handler customization. +Handler should give METHOD as argument and return function of one argument +ERROR." + :type 'function + :group 'lsp-mode + :package-version '(lsp-mode . "9.0.0")) + +(defun lsp--create-default-error-handler (method) + "Default error handler. +METHOD is the executed method." + (if lsp-default-create-error-handler-fn + (funcall lsp-default-create-error-handler-fn method) + (lambda (error) + (lsp--warn "%s" (or (lsp--error-string error) + (format "%s Request has failed" method)))))) + +(defvar lsp--request-cleanup-hooks (ht)) + +(defun lsp--request-cleanup-hooks (request-id) + (when-let ((cleanup-function (gethash request-id lsp--request-cleanup-hooks))) + (funcall cleanup-function) + (remhash request-id lsp--request-cleanup-hooks))) + +(defun lsp-cancel-request-by-token (cancel-token) + "Cancel request using CANCEL-TOKEN." + (-when-let ((request-id . workspaces) (gethash cancel-token lsp--cancelable-requests)) + (with-lsp-workspaces workspaces + (lsp--cancel-request request-id)) + (remhash cancel-token lsp--cancelable-requests) + (lsp--request-cleanup-hooks request-id))) + +(defun lsp--send-request-async (body callback + &optional mode error-callback cancel-callback + no-merge cancel-token) + "Send BODY as a request to the language server. +Call CALLBACK with the response received from the server +asynchronously. +MODE determines when the callback will be called depending on the +condition of the original buffer. It could be: +- `detached' which means that the callback will be executed no +matter what has happened to the buffer. +- `alive' - the callback will be executed only if the buffer from +which the call was executed is still alive. +- `current' the callback will be executed only if the original buffer +is still selected. +- `tick' - the callback will be executed only if the buffer was not modified. +- `unchanged' - the callback will be executed only if the buffer hasn't +changed and if the buffer is not modified. + +ERROR-CALLBACK will be called in case the request has failed. +CANCEL-CALLBACK will be called in case the request is being canceled. +If NO-MERGE is non-nil, don't merge the results but return alist +workspace->result. +CANCEL-TOKEN is the token that can be used to cancel request." + (when cancel-token + (lsp-cancel-request-by-token cancel-token)) + + (if-let ((target-workspaces (lsp--find-workspaces-for body))) + (let* ((start-time (current-time)) + (method (plist-get body :method)) + (id (cl-incf lsp-last-id)) + (buf (current-buffer)) + (cancel-callback (when cancel-callback + (pcase mode + ((or 'alive 'tick 'unchanged) + (lambda () + (with-current-buffer buf + (funcall cancel-callback)))) + (_ cancel-callback)))) + ;; calculate what are the (hook . local) pairs which will cancel + ;; the request + (hooks (pcase mode + ('alive '((kill-buffer-hook . t))) + ('tick '((kill-buffer-hook . t) (after-change-functions . t))) + ('unchanged '((after-change-functions . t) (post-command-hook . nil))) + ('current '((post-command-hook . nil))))) + ;; note: lambdas in emacs can be compared but we should make sure + ;; that all of the captured arguments are the same - in our case + ;; `lsp--create-request-cancel' will return the same lambda when + ;; called with the same params. + (cleanup-hooks + (lambda () (mapc + (-lambda ((hook . local)) + (if local + (when (buffer-live-p buf) + (with-current-buffer buf + (remove-hook hook + (lsp--create-request-cancel + id target-workspaces hook buf method cancel-callback) + t))) + (remove-hook hook (lsp--create-request-cancel + id target-workspaces hook buf method cancel-callback)))) + hooks) + (remhash cancel-token lsp--cancelable-requests))) + (callback (pcase mode + ((or 'alive 'tick 'unchanged) (lambda (&rest args) + (with-current-buffer buf + (apply callback args)))) + (_ callback))) + (callback (lsp--create-async-callback callback + method + no-merge + target-workspaces)) + (callback (lambda (result) + (lsp--request-cleanup-hooks id) + (funcall callback result))) + (error-callback (lsp--create-async-callback + (or error-callback + (lsp--create-default-error-handler method)) + method + nil + target-workspaces)) + (error-callback (lambda (error) + (funcall callback :error) + (lsp--request-cleanup-hooks id) + (funcall error-callback error))) + (body (plist-put body :id id))) + + ;; cancel request in any of the hooks + (mapc (-lambda ((hook . local)) + (add-hook hook + (lsp--create-request-cancel + id target-workspaces hook buf method cancel-callback) + nil local)) + hooks) + (puthash id cleanup-hooks lsp--request-cleanup-hooks) + + (setq lsp--last-active-workspaces target-workspaces) + + (when cancel-token + (puthash cancel-token (cons id target-workspaces) lsp--cancelable-requests)) + + (seq-doseq (workspace target-workspaces) + (when (lsp--log-io-p method) + (lsp--log-entry-new (lsp--make-log-entry method id + (plist-get body :params) + 'outgoing-req) + workspace)) + (puthash id + (list callback error-callback method start-time (current-time)) + (-> workspace + (lsp--workspace-client) + (lsp--client-response-handlers))) + (lsp--send-no-wait body (lsp--workspace-proc workspace))) + body) + (error "The connected server(s) does not support method %s. +To find out what capabilities support your server use `M-x lsp-describe-session' +and expand the capabilities section" + (plist-get body :method)))) + +;; deprecated, use lsp-request-async. +(defalias 'lsp-send-request-async 'lsp--send-request-async) +(make-obsolete 'lsp-send-request-async 'lsp-request-async "lsp-mode 7.0.1") + +;; Clean up the entire state of lsp mode when Emacs is killed, to get rid of any +;; pending language servers. +(add-hook 'kill-emacs-hook #'lsp--global-teardown) + +(defun lsp--global-teardown () + "Unload working workspaces." + (lsp-foreach-workspace (lsp--shutdown-workspace))) + +(defun lsp--shutdown-workspace (&optional restart) + "Shut down the language server process for ‘lsp--cur-workspace’." + (with-demoted-errors "LSP error: %S" + (let ((lsp-response-timeout 0.5)) + (condition-case err + (lsp-request "shutdown" nil) + (error (lsp--error "%s" err)))) + (lsp-notify "exit" nil)) + (setf (lsp--workspace-shutdown-action lsp--cur-workspace) (or (and restart 'restart) 'shutdown)) + (lsp--uninitialize-workspace)) + +(defcustom lsp-inlay-hint-enable nil + "If non-nil it will enable inlay hints." + :type 'boolean + :group 'lsp-mode + :package-version '(lsp-mode . "9.0.0")) + +(defun lsp--uninitialize-workspace () + "Cleanup buffer state. +When a workspace is shut down, by request or from just +disappearing, unset all the variables related to it." + (-let [(&lsp-wks 'cmd-proc 'buffers) lsp--cur-workspace] + (lsp-process-kill cmd-proc) + (mapc (lambda (buf) + (when (lsp-buffer-live-p buf) + (lsp-with-current-buffer buf + (lsp-managed-mode -1)))) + buffers) + (lsp-diagnostics--workspace-cleanup lsp--cur-workspace))) + +(defun lsp--client-capabilities (&optional custom-capabilities) + "Return the client capabilities appending CUSTOM-CAPABILITIES." + (append + `((general . ((positionEncodings . ["utf-32", "utf-16"]))) + (workspace . ((workspaceEdit . ((documentChanges . t) + (resourceOperations . ["create" "rename" "delete"]))) + (applyEdit . t) + (symbol . ((symbolKind . ((valueSet . ,(apply 'vector (number-sequence 1 26))))))) + (executeCommand . ((dynamicRegistration . :json-false))) + ,@(when lsp-enable-file-watchers '((didChangeWatchedFiles . ((dynamicRegistration . t))))) + (workspaceFolders . t) + (configuration . t) + ,@(when lsp-semantic-tokens-enable + `((semanticTokens . ((refreshSupport . ,(or (and (boundp 'lsp-semantic-tokens-honor-refresh-requests) + lsp-semantic-tokens-honor-refresh-requests) + :json-false)))))) + ,@(when lsp-lens-enable '((codeLens . ((refreshSupport . t))))) + ,@(when lsp-inlay-hint-enable '((inlayHint . ((refreshSupport . :json-false))))) + (fileOperations . ((didCreate . :json-false) + (willCreate . :json-false) + (didRename . t) + (willRename . t) + (didDelete . :json-false) + (willDelete . :json-false))))) + (textDocument . ((declaration . ((dynamicRegistration . t) + (linkSupport . t))) + (definition . ((dynamicRegistration . t) + (linkSupport . t))) + (references . ((dynamicRegistration . t))) + (implementation . ((dynamicRegistration . t) + (linkSupport . t))) + (typeDefinition . ((dynamicRegistration . t) + (linkSupport . t))) + (synchronization . ((willSave . t) (didSave . t) (willSaveWaitUntil . t))) + (documentSymbol . ((symbolKind . ((valueSet . ,(apply 'vector (number-sequence 1 26))))) + (hierarchicalDocumentSymbolSupport . t))) + (formatting . ((dynamicRegistration . t))) + (rangeFormatting . ((dynamicRegistration . t))) + (onTypeFormatting . ((dynamicRegistration . t))) + ,@(when (and lsp-semantic-tokens-enable + (functionp 'lsp--semantic-tokens-capabilities)) + (lsp--semantic-tokens-capabilities)) + (rename . ((dynamicRegistration . t) (prepareSupport . t))) + (codeAction . ((dynamicRegistration . t) + (isPreferredSupport . t) + (codeActionLiteralSupport . ((codeActionKind . ((valueSet . ["" + "quickfix" + "refactor" + "refactor.extract" + "refactor.inline" + "refactor.rewrite" + "source" + "source.organizeImports"]))))) + (resolveSupport . ((properties . ["edit" "command"]))) + (dataSupport . t))) + (completion . ((completionItem . ((snippetSupport . ,(cond + ((and lsp-enable-snippet (not (fboundp 'yas-minor-mode))) + (lsp--warn (concat + "Yasnippet is not installed, but `lsp-enable-snippet' is set to `t'. " + "You must either install yasnippet, or disable snippet support.")) + :json-false) + (lsp-enable-snippet t) + (t :json-false))) + (documentationFormat . ["markdown" "plaintext"]) + ;; Remove this after jdtls support resolveSupport + (resolveAdditionalTextEditsSupport . t) + (insertReplaceSupport . t) + (deprecatedSupport . t) + (resolveSupport + . ((properties . ["documentation" + "detail" + "additionalTextEdits" + "command"]))) + (insertTextModeSupport . ((valueSet . [1 2]))))) + (contextSupport . t) + (dynamicRegistration . t))) + (signatureHelp . ((signatureInformation . ((parameterInformation . ((labelOffsetSupport . t))))) + (dynamicRegistration . t))) + (documentLink . ((dynamicRegistration . t) + (tooltipSupport . t))) + (hover . ((contentFormat . ["markdown" "plaintext"]) + (dynamicRegistration . t))) + ,@(when lsp-enable-folding + `((foldingRange . ((dynamicRegistration . t) + ,@(when lsp-folding-range-limit + `((rangeLimit . ,lsp-folding-range-limit))) + ,@(when lsp-folding-line-folding-only + `((lineFoldingOnly . t))))))) + (selectionRange . ((dynamicRegistration . t))) + (callHierarchy . ((dynamicRegistration . :json-false))) + (typeHierarchy . ((dynamicRegistration . t))) + (publishDiagnostics . ((relatedInformation . t) + (tagSupport . ((valueSet . [1 2]))) + (versionSupport . t))) + (linkedEditingRange . ((dynamicRegistration . t))))) + (window . ((workDoneProgress . t) + (showDocument . ((support . t)))))) + custom-capabilities)) + +(defun lsp-find-roots-for-workspace (workspace session) + "Get all roots for the WORKSPACE." + (-filter #'identity (ht-map (lambda (folder workspaces) + (when (-contains? workspaces workspace) + folder)) + (lsp-session-folder->servers session)))) + +(defun lsp-session-watches (&optional session) + "Get watches created for SESSION." + (or (gethash "__watches" (lsp-session-metadata (or session (lsp-session)))) + (-let [res (make-hash-table :test 'equal)] + (puthash "__watches" res (lsp-session-metadata (or session (lsp-session)))) + res))) + +(defun lsp--file-process-event (session root-folder event) + "Process file event." + (let* ((changed-file (cl-third event)) + (rel-changed-file (f-relative changed-file root-folder)) + (event-numeric-kind (alist-get (cl-second event) lsp--file-change-type)) + (bit-position (1- event-numeric-kind)) + (watch-bit (ash 1 bit-position))) + (->> + session + lsp-session-folder->servers + (gethash root-folder) + (seq-do (lambda (workspace) + (when (->> + workspace + lsp--workspace-registered-server-capabilities + (-any? + (lambda (capability) + (and + (equal (lsp--registered-capability-method capability) + "workspace/didChangeWatchedFiles") + (->> + capability + lsp--registered-capability-options + (lsp:did-change-watched-files-registration-options-watchers) + (seq-find + (-lambda ((fs-watcher &as &FileSystemWatcher :glob-pattern :kind? :_cachedRegexp cached-regexp)) + (when (or (null kind?) + (> (logand kind? watch-bit) 0)) + (-let [regexes (or cached-regexp + (let ((regexp (lsp-glob-to-regexps glob-pattern))) + (lsp-put fs-watcher :_cachedRegexp regexp) + regexp))] + (-any? (lambda (re) + (or (string-match re changed-file) + (string-match re rel-changed-file))) + regexes)))))))))) + (with-lsp-workspace workspace + (lsp-notify + "workspace/didChangeWatchedFiles" + `((changes . [((type . ,event-numeric-kind) + (uri . ,(lsp--path-to-uri changed-file)))])))))))))) + +(lsp-defun lsp--server-register-capability ((&Registration :method :id :register-options?)) + "Register capability REG." + (when (and lsp-enable-file-watchers + (equal method "workspace/didChangeWatchedFiles")) + (-let* ((created-watches (lsp-session-watches (lsp-session))) + (root-folders (cl-set-difference + (lsp-find-roots-for-workspace lsp--cur-workspace (lsp-session)) + (ht-keys created-watches)))) + ;; create watch for each root folder without such + (dolist (folder root-folders) + (let* ((watch (make-lsp-watch :root-directory folder)) + (ignored-things (lsp--get-ignored-regexes-for-workspace-root folder)) + (ignored-files-regex-list (car ignored-things)) + (ignored-directories-regex-list (cadr ignored-things))) + (puthash folder watch created-watches) + (lsp-watch-root-folder (file-truename folder) + (-partial #'lsp--file-process-event (lsp-session) folder) + ignored-files-regex-list + ignored-directories-regex-list + watch + t))))) + + (push + (make-lsp--registered-capability :id id :method method :options register-options?) + (lsp--workspace-registered-server-capabilities lsp--cur-workspace))) + +(defmacro lsp--with-workspace-temp-buffer (workspace-root &rest body) + "With a temp-buffer under `WORKSPACE-ROOT' and evaluate `BODY', useful to +access dir-local variables." + (declare (indent 1) (debug t)) + `(with-temp-buffer + ;; Set the buffer's name to something under the root so that we can hack the local variables + ;; This file doesn't need to exist and will not be created due to this. + (setq-local buffer-file-name (expand-file-name "lsp-mode-temp" (expand-file-name ,workspace-root))) + (hack-local-variables) + (prog1 ,@body + (setq-local buffer-file-name nil)))) + +(defun lsp--get-ignored-regexes-for-workspace-root (workspace-root) + "Return a list of the form +(lsp-file-watch-ignored-files lsp-file-watch-ignored-directories) for the given +WORKSPACE-ROOT." + ;; The intent of this function is to provide per-root workspace-level customization of the + ;; lsp-file-watch-ignored-directories and lsp-file-watch-ignored-files variables. + (lsp--with-workspace-temp-buffer workspace-root + (list lsp-file-watch-ignored-files (lsp-file-watch-ignored-directories)))) + + +(defun lsp--cleanup-hanging-watches () + "Cleanup watches in case there are no more workspaces that are interested +in that particular folder." + (let* ((session (lsp-session)) + (watches (lsp-session-watches session))) + (dolist (watched-folder (ht-keys watches)) + (when (-none? (lambda (workspace) + (with-lsp-workspace workspace + (lsp--registered-capability "workspace/didChangeWatchedFiles"))) + (gethash watched-folder (lsp-session-folder->servers (lsp-session)))) + (lsp-log "Cleaning up watches for folder %s. There is no workspace watching this folder..." watched-folder) + (lsp-kill-watch (gethash watched-folder watches)) + (remhash watched-folder watches))))) + +(lsp-defun lsp--server-unregister-capability ((&Unregistration :id :method)) + "Unregister capability UNREG." + (setf (lsp--workspace-registered-server-capabilities lsp--cur-workspace) + (seq-remove (lambda (e) (equal (lsp--registered-capability-id e) id)) + (lsp--workspace-registered-server-capabilities lsp--cur-workspace))) + (when (equal method "workspace/didChangeWatchedFiles") + (lsp--cleanup-hanging-watches))) + +(defun lsp--server-capabilities () + "Return the capabilities of the language server associated with the buffer." + (->> (lsp-workspaces) + (-keep #'lsp--workspace-server-capabilities) + (apply #'lsp-merge))) + +(defun lsp--send-open-close-p () + "Return whether open and close notifications should be sent to the server." + (let ((sync (lsp:server-capabilities-text-document-sync? (lsp--server-capabilities)))) + (or (memq sync '(1 2)) + (lsp:text-document-sync-options-open-close? sync)))) + +(defun lsp--send-will-save-p () + "Return whether willSave notifications should be sent to the server." + (-> (lsp--server-capabilities) + (lsp:server-capabilities-text-document-sync?) + (lsp:text-document-sync-options-will-save?))) + +(defun lsp--send-will-save-wait-until-p () + "Return whether willSaveWaitUntil notifications should be sent to the server." + (-> (lsp--server-capabilities) + (lsp:server-capabilities-text-document-sync?) + (lsp:text-document-sync-options-will-save-wait-until?))) + +(defun lsp--send-did-save-p () + "Return whether didSave notifications should be sent to the server." + (let ((sync (lsp:server-capabilities-text-document-sync? (lsp--server-capabilities)))) + (or (memq sync '(1 2)) + (lsp:text-document-sync-options-save? sync)))) + +(defun lsp--save-include-text-p () + "Return whether save notifications should include the text document's contents." + (->> (lsp--server-capabilities) + (lsp:server-capabilities-text-document-sync?) + (lsp:text-document-sync-options-save?) + (lsp:text-document-save-registration-options-include-text?))) + +(defun lsp--send-will-rename-files-p (path) + "Return whether willRenameFiles request should be sent to the server. +If any filters, checks if it applies for PATH." + (let* ((will-rename (-> (lsp--server-capabilities) + (lsp:server-capabilities-workspace?) + (lsp:workspace-server-capabilities-file-operations?) + (lsp:workspace-file-operations-will-rename?))) + (filters (seq-into (lsp:file-operation-registration-options-filters will-rename) 'list))) + (and will-rename + (or (seq-empty-p filters) + (-any? (-lambda ((&FileOperationFilter :scheme? :pattern (&FileOperationPattern :glob))) + (-let [regexes (lsp-glob-to-regexps glob)] + (and (or (not scheme?) + (string-prefix-p scheme? (lsp--path-to-uri path))) + (-any? (lambda (re) + (string-match re path)) + regexes)))) + filters))))) + +(defun lsp--send-did-rename-files-p () + "Return whether didRenameFiles notification should be sent to the server." + (-> (lsp--server-capabilities) + (lsp:server-capabilities-workspace?) + (lsp:workspace-server-capabilities-file-operations?) + (lsp:workspace-file-operations-did-rename?))) + +(declare-function project-roots "ext:project" (project) t) +(declare-function project-root "ext:project" (project) t) + +(defun lsp--suggest-project-root () + "Get project root." + (or + (when (fboundp 'projectile-project-root) + (condition-case nil + (projectile-project-root) + (error nil))) + (when (fboundp 'project-current) + (when-let ((project (project-current))) + (if (fboundp 'project-root) + (project-root project) + (car (with-no-warnings + (project-roots project)))))) + default-directory)) + +(defun lsp--read-from-file (file) + "Read FILE content." + (when (file-exists-p file) + (cl-first (read-from-string (f-read-text file 'utf-8))))) + +(defun lsp--persist (file-name to-persist) + "Persist TO-PERSIST in FILE-NAME. + +This function creates the parent directories if they don't exist +yet." + (let ((print-length nil) + (print-level nil)) + ;; Create all parent directories: + (make-directory (f-parent file-name) t) + (f-write-text (prin1-to-string to-persist) 'utf-8 file-name))) + +(defun lsp-workspace-folders-add (project-root) + "Add PROJECT-ROOT to the list of workspace folders." + (interactive + (list (read-directory-name "Select folder to add: " + (or (lsp--suggest-project-root) default-directory) nil t))) + (cl-pushnew (lsp-f-canonical project-root) + (lsp-session-folders (lsp-session)) :test 'equal) + (lsp--persist-session (lsp-session)) + + (run-hook-with-args 'lsp-workspace-folders-changed-functions (list project-root) nil)) + +(defun lsp-workspace-folders-remove (project-root) + "Remove PROJECT-ROOT from the list of workspace folders." + (interactive (list (completing-read "Select folder to remove: " + (lsp-session-folders (lsp-session)) + nil t nil nil + (lsp-find-session-folder (lsp-session) default-directory)))) + + (setq project-root (lsp-f-canonical project-root)) + + ;; send remove folder to each multiroot workspace associated with the folder + (dolist (wks (->> (lsp-session) + (lsp-session-folder->servers) + (gethash project-root) + (--filter (lsp--client-multi-root (lsp--workspace-client it))))) + (with-lsp-workspace wks + (lsp-notify "workspace/didChangeWorkspaceFolders" + (lsp-make-did-change-workspace-folders-params + :event (lsp-make-workspace-folders-change-event + :removed (vector (lsp-make-workspace-folder + :uri (lsp--path-to-uri project-root) + :name (f-filename project-root))) + :added []))))) + + ;; turn off servers in the removed directory + (let* ((session (lsp-session)) + (folder->servers (lsp-session-folder->servers session)) + (server-id->folders (lsp-session-server-id->folders session)) + (workspaces (gethash project-root folder->servers))) + + (remhash project-root folder->servers) + + ;; turn off the servers without root folders + (dolist (workspace workspaces) + (when (--none? (-contains? it workspace) (ht-values folder->servers)) + (lsp--info "Shutdown %s since folder %s is removed..." + (lsp--workspace-print workspace) project-root) + (with-lsp-workspace workspace (lsp--shutdown-workspace)))) + + (setf (lsp-session-folders session) + (-remove-item project-root (lsp-session-folders session))) + + (ht-aeach (puthash key + (-remove-item project-root value) + server-id->folders) + server-id->folders) + (lsp--persist-session (lsp-session))) + + (run-hook-with-args 'lsp-workspace-folders-changed-functions nil (list project-root))) + +(defun lsp-workspace-blocklist-remove (project-root) + "Remove PROJECT-ROOT from the workspace blocklist." + (interactive (list (completing-read "Select folder to remove:" + (lsp-session-folders-blocklist (lsp-session)) + nil t))) + (setf (lsp-session-folders-blocklist (lsp-session)) + (delete project-root + (lsp-session-folders-blocklist (lsp-session)))) + (lsp--persist-session (lsp-session))) + +(define-obsolete-function-alias 'lsp-workspace-folders-switch + 'lsp-workspace-folders-open "lsp-mode 6.1") + +(defun lsp-workspace-folders-open (project-root) + "Open the directory located at PROJECT-ROOT" + (interactive (list (completing-read "Open folder: " + (lsp-session-folders (lsp-session)) + nil t))) + (find-file project-root)) + +(defun lsp--maybe-enable-signature-help (trigger-characters) + (let ((ch last-command-event)) + (when (cl-find ch trigger-characters :key #'string-to-char) + (lsp-signature-activate)))) + +(defun lsp--on-type-formatting-handler-create () + (when-let ((provider (lsp--capability-for-method "textDocument/onTypeFormatting" ))) + (-let [(&DocumentOnTypeFormattingOptions :more-trigger-character? + :first-trigger-character) provider] + (lambda () + (lsp--on-type-formatting first-trigger-character + more-trigger-character?))))) + +(defun lsp--update-on-type-formatting-hook (&optional cleanup?) + (let ((on-type-formatting-handler (lsp--on-type-formatting-handler-create))) + (cond + ((and lsp-enable-on-type-formatting on-type-formatting-handler (not cleanup?)) + (add-hook 'post-self-insert-hook on-type-formatting-handler nil t)) + ((or cleanup? + (not lsp-enable-on-type-formatting)) + (remove-hook 'post-self-insert-hook on-type-formatting-handler t))))) + +(defun lsp--signature-help-handler-create () + (-when-let ((&SignatureHelpOptions? :trigger-characters?) + (lsp--capability-for-method "textDocument/signatureHelp")) + (lambda () + (lsp--maybe-enable-signature-help trigger-characters?)))) + +(defun lsp--update-signature-help-hook (&optional cleanup?) + (let ((signature-help-handler (lsp--signature-help-handler-create))) + (cond + ((and (or (equal lsp-signature-auto-activate t) + (memq :on-trigger-char lsp-signature-auto-activate)) + signature-help-handler) + (add-hook 'post-self-insert-hook signature-help-handler nil t)) + + ((or cleanup? + (not (or (equal lsp-signature-auto-activate t) + (memq :on-trigger-char lsp-signature-auto-activate)))) + (remove-hook 'post-self-insert-hook signature-help-handler t))))) + +(defun lsp--after-set-visited-file-name () + (lsp-disconnect) + (lsp)) + +;; TODO remove those eldoc workarounds when dropping support for Emacs 27 +;; https://github.com/emacs-lsp/lsp-mode/issues/3295#issuecomment-1308994099 +(defvar eldoc-documentation-default) ; CI +(when (< emacs-major-version 28) + (unless (boundp 'eldoc-documentation-functions) + (load "eldoc" nil 'nomessage)) + (when (memq (default-value 'eldoc-documentation-function) '(nil ignore)) + ;; actually `eldoc-documentation-strategy', but CI was failing + (setq-default eldoc-documentation-function 'eldoc-documentation-default))) + +(define-minor-mode lsp-managed-mode + "Mode for source buffers managed by lsp-mode." + :lighter nil + (cond + (lsp-managed-mode + (when (lsp-feature? "textDocument/hover") + (add-hook 'eldoc-documentation-functions #'lsp-eldoc-function nil t) + (eldoc-mode 1)) + + (add-hook 'after-change-functions #'lsp-on-change nil t) + (add-hook 'after-revert-hook #'lsp-on-revert nil t) + (add-hook 'after-save-hook #'lsp-on-save nil t) + (add-hook 'auto-save-hook #'lsp--on-auto-save nil t) + (add-hook 'before-change-functions #'lsp-before-change nil t) + (add-hook 'before-save-hook #'lsp--before-save nil t) + (add-hook 'kill-buffer-hook #'lsp--text-document-did-close nil t) + (add-hook 'post-command-hook #'lsp--post-command nil t) + + (lsp--update-on-type-formatting-hook) + (lsp--update-signature-help-hook) + + (when lsp-enable-xref + (add-hook 'xref-backend-functions #'lsp--xref-backend nil t)) + + (lsp-configure-buffer) + + ;; make sure we turn off lsp-mode in case major mode changes, because major + ;; mode change will wipe the buffer locals. + (add-hook 'change-major-mode-hook #'lsp-disconnect nil t) + (add-hook 'after-set-visited-file-name-hook #'lsp--after-set-visited-file-name nil t) + + (let ((buffer (lsp-current-buffer))) + (run-with-idle-timer + 0.0 nil + (lambda () + (when (lsp-buffer-live-p buffer) + (lsp-with-current-buffer buffer + (lsp--on-change-debounce buffer) + (lsp--on-idle buffer))))))) + (t + (lsp-unconfig-buffer) + + (remove-hook 'eldoc-documentation-functions #'lsp-eldoc-function t) + (remove-hook 'post-command-hook #'lsp--post-command t) + (remove-hook 'after-change-functions #'lsp-on-change t) + (remove-hook 'after-revert-hook #'lsp-on-revert t) + (remove-hook 'after-save-hook #'lsp-on-save t) + (remove-hook 'auto-save-hook #'lsp--on-auto-save t) + (remove-hook 'before-change-functions #'lsp-before-change t) + (remove-hook 'before-save-hook #'lsp--before-save t) + (remove-hook 'kill-buffer-hook #'lsp--text-document-did-close t) + + (lsp--update-on-type-formatting-hook :cleanup) + (lsp--update-signature-help-hook :cleanup) + + (when lsp--on-idle-timer + (cancel-timer lsp--on-idle-timer) + (setq lsp--on-idle-timer nil)) + + (remove-hook 'lsp-on-idle-hook #'lsp--document-links t) + (remove-hook 'lsp-on-idle-hook #'lsp--document-highlight t) + + (lsp--remove-overlays 'lsp-highlight) + (lsp--remove-overlays 'lsp-links) + + (remove-hook 'xref-backend-functions #'lsp--xref-backend t) + (remove-hook 'change-major-mode-hook #'lsp-disconnect t) + (remove-hook 'after-set-visited-file-name-hook #'lsp--after-set-visited-file-name t) + (setq-local lsp-buffer-uri nil)))) + +(defun lsp-configure-buffer () + "Configure LSP features for current buffer." + ;; make sure the core is running in the context of all available workspaces + ;; to avoid misconfiguration in case we are running in `with-lsp-workspace' context + (let ((lsp--buffer-workspaces (cond + (lsp--buffer-workspaces) + (lsp--cur-workspace (list lsp--cur-workspace)))) + lsp--cur-workspace) + (when lsp-auto-configure + (lsp--auto-configure) + + (when (and lsp-enable-text-document-color + (lsp-feature? "textDocument/documentColor")) + (add-hook 'lsp-on-change-hook #'lsp--document-color nil t)) + + (when (and lsp-enable-imenu + (lsp-feature? "textDocument/documentSymbol")) + (lsp-enable-imenu)) + + (when (and lsp-enable-indentation + (lsp-feature? "textDocument/rangeFormatting")) + (add-function :override (local 'indent-region-function) #'lsp-format-region)) + + (when (and lsp-enable-symbol-highlighting + (lsp-feature? "textDocument/documentHighlight")) + (add-hook 'lsp-on-idle-hook #'lsp--document-highlight nil t)) + + (when (and lsp-enable-links + (lsp-feature? "textDocument/documentLink")) + (add-hook 'lsp-on-idle-hook #'lsp--document-links nil t)) + + (when (and lsp-inlay-hint-enable + (lsp-feature? "textDocument/inlayHint")) + (lsp-inlay-hints-mode)) + + (when (and lsp-enable-dap-auto-configure + (functionp 'dap-mode)) + (dap-auto-configure-mode 1))) + (run-hooks 'lsp-configure-hook))) + +(defun lsp-unconfig-buffer () + "Unconfigure LSP features for buffer." + (lsp--remove-overlays 'lsp-color) + + (when (advice-function-member-p 'lsp--imenu-create-index imenu-create-index-function) + (remove-function (local 'imenu-create-index-function) #'lsp--imenu-create-index) + (setq-local imenu-menubar-modified-tick 0) + (setq-local imenu--index-alist nil) + (imenu--cleanup)) + + (remove-function (local 'indent-region-function) #'lsp-format-region) + + (remove-hook 'lsp-on-change-hook #'lsp--document-color t) + (remove-hook 'lsp-on-idle-hook #'lsp--document-highlight t) + (remove-hook 'lsp-on-idle-hook #'lsp--document-links t) + + (when (and lsp-enable-dap-auto-configure + (functionp 'dap-mode)) + (dap-auto-configure-mode -1)) + + (run-hooks 'lsp-unconfigure-hook)) + +(defun lsp--buffer-content () + (lsp-save-restriction-and-excursion + (or (lsp-virtual-buffer-call :buffer-string) + (buffer-substring-no-properties (point-min) + (point-max))))) + +(defun lsp--text-document-did-open () + "`document/didOpen' event." + (run-hooks 'lsp-before-open-hook) + (when (and lsp-auto-touch-files + (not (f-exists? (lsp--uri-to-path (lsp--buffer-uri))))) + (lsp--info "Saving file '%s' because it is not present on the disk." (lsp--buffer-uri)) + (save-buffer)) + + (setq lsp--cur-version (or lsp--cur-version 0)) + (cl-pushnew (lsp-current-buffer) (lsp--workspace-buffers lsp--cur-workspace)) + (lsp-notify + "textDocument/didOpen" + (list :textDocument + (list :uri (lsp--buffer-uri) + :languageId (lsp-buffer-language) + :version lsp--cur-version + :text (lsp--buffer-content)))) + + (lsp-managed-mode 1) + + (run-hooks 'lsp-after-open-hook) + (when-let ((client (-some-> lsp--cur-workspace (lsp--workspace-client)))) + (-some-> (lsp--client-after-open-fn client) + (funcall)) + (-some-> (format "lsp-%s-after-open-hook" (lsp--client-server-id client)) + (intern-soft) + (run-hooks)))) + +(defun lsp--text-document-identifier () + "Make TextDocumentIdentifier." + (list :uri (lsp--buffer-uri))) + +(defun lsp--versioned-text-document-identifier () + "Make VersionedTextDocumentIdentifier." + (plist-put (lsp--text-document-identifier) :version lsp--cur-version)) + +(defun lsp--cur-line (&optional point) + (1- (line-number-at-pos point))) + +(defun lsp--cur-position () + "Make a Position object for the current point." + (or (lsp-virtual-buffer-call :cur-position) + (lsp-save-restriction-and-excursion + (list :line (lsp--cur-line) + :character (- (point) (line-beginning-position)))))) + +(defun lsp--point-to-position (point) + "Convert POINT to Position." + (lsp-save-restriction-and-excursion + (goto-char point) + (lsp--cur-position))) + +(defun lsp--range (start end) + "Make Range body from START and END." + ;; make sure start and end are Position objects + (list :start start :end end)) + +(defun lsp--region-to-range (start end) + "Make Range object for the current region." + (lsp--range (lsp--point-to-position start) + (lsp--point-to-position end))) + +(defun lsp--region-or-line () + "The active region or the current line." + (if (use-region-p) + (lsp--region-to-range (region-beginning) (region-end)) + (lsp--region-to-range (line-beginning-position) (line-end-position)))) + +(defun lsp--check-document-changes-version (document-changes) + "Verify that DOCUMENT-CHANGES have the proper version." + (unless (seq-every-p + (-lambda ((&TextDocumentEdit :text-document)) + (or + (not text-document) + (let* ((filename (-> text-document + lsp:versioned-text-document-identifier-uri + lsp--uri-to-path)) + (version (lsp:versioned-text-document-identifier-version? text-document))) + (with-current-buffer (find-file-noselect filename) + (or (null version) (zerop version) (= -1 version) + (equal version lsp--cur-version)))))) + document-changes) + (error "Document changes cannot be applied due to different document version"))) + +(defun lsp--apply-workspace-edit (workspace-edit &optional operation) + "Apply the WorkspaceEdit object WORKSPACE-EDIT. +OPERATION is symbol representing the source of this text edit." + (-let (((&WorkspaceEdit :document-changes? :changes?) workspace-edit)) + (if-let ((document-changes (seq-reverse document-changes?))) + (progn + (lsp--check-document-changes-version document-changes) + (->> document-changes + (seq-filter (-lambda ((&CreateFile :kind)) (equal kind "create"))) + (seq-do (lambda (change) (lsp--apply-text-document-edit change operation)))) + (->> document-changes + (seq-filter (-lambda ((&CreateFile :kind)) + (and (or (not kind) (equal kind "edit")) + (not (equal kind "create"))))) + (seq-do (lambda (change) (lsp--apply-text-document-edit change operation)))) + (->> document-changes + (seq-filter (-lambda ((&CreateFile :kind)) + (and (not (or (not kind) (equal kind "edit"))) + (not (equal kind "create"))))) + (seq-do (lambda (change) (lsp--apply-text-document-edit change operation))))) + (lsp-map + (lambda (uri text-edits) + (with-current-buffer (-> uri lsp--uri-to-path find-file-noselect) + (lsp--apply-text-edits text-edits operation))) + changes?)))) + +(defmacro lsp-with-filename (file &rest body) + "Execute BODY with FILE as a context. +Need to handle the case when FILE indicates virtual buffer." + (declare (indent 1) (debug t)) + `(if-let ((lsp--virtual-buffer (get-text-property 0 'lsp-virtual-buffer ,file))) + (lsp-with-current-buffer lsp--virtual-buffer + ,@body) + ,@body)) + +(defun lsp--apply-text-document-edit (edit &optional operation) + "Apply the TextDocumentEdit object EDIT. +OPERATION is symbol representing the source of this text edit. +If the file is not being visited by any buffer, it is opened with +`find-file-noselect'. +Because lsp-mode does not store previous document versions, the edit is only +applied if the version of the textDocument matches the version of the +corresponding file. + +interface TextDocumentEdit { + textDocument: VersionedTextDocumentIdentifier; + edits: TextEdit[]; +}" + (pcase (lsp:edit-kind edit) + ("create" (-let* (((&CreateFile :uri :options?) edit) + (file-name (lsp--uri-to-path uri))) + (mkdir (f-dirname file-name) t) + (f-touch file-name) + (when (lsp:create-file-options-overwrite? options?) + (f-write-text "" nil file-name)) + (find-file-noselect file-name))) + ("delete" (-let (((&DeleteFile :uri :options? (&DeleteFileOptions? :recursive?)) edit)) + (f-delete (lsp--uri-to-path uri) recursive?))) + ("rename" (-let* (((&RenameFile :old-uri :new-uri :options? (&RenameFileOptions? :overwrite?)) edit) + (old-file-name (lsp--uri-to-path old-uri)) + (new-file-name (lsp--uri-to-path new-uri)) + (buf (find-buffer-visiting old-file-name))) + (when buf + (lsp-with-current-buffer buf + (save-buffer) + (lsp--text-document-did-close))) + (mkdir (f-dirname new-file-name) t) + (rename-file old-file-name new-file-name overwrite?) + (when buf + (lsp-with-current-buffer buf + (set-buffer-modified-p nil) + (setq lsp-buffer-uri nil) + (set-visited-file-name new-file-name) + (lsp))))) + (_ (let ((file-name (->> edit + (lsp:text-document-edit-text-document) + (lsp:versioned-text-document-identifier-uri) + (lsp--uri-to-path)))) + (lsp-with-current-buffer (find-buffer-visiting file-name) + (lsp-with-filename file-name + (lsp--apply-text-edits (lsp:text-document-edit-edits edit) operation))))))) + +(lsp-defun lsp--position-compare ((&Position :line left-line + :character left-character) + (&Position :line right-line + :character right-character)) + "Return t if position LEFT is greater than RIGHT." + (if (= left-line right-line) + (> left-character right-character) + (> left-line right-line))) + +(lsp-defun lsp-point-in-range? (position (&Range :start :end)) + "Returns if POINT is in RANGE." + (not (or (lsp--position-compare start position) + (lsp--position-compare position end)))) + +(lsp-defun lsp--position-equal ((&Position :line left-line + :character left-character) + (&Position :line right-line + :character right-character)) + "Return whether LEFT and RIGHT positions are equal." + (and (= left-line right-line) + (= left-character right-character))) + +(lsp-defun lsp--text-edit-sort-predicate ((&TextEdit :range (&Range :start left-start :end left-end)) + (&TextEdit :range (&Range :start right-start :end right-end))) + (if (lsp--position-equal left-start right-start) + (lsp--position-compare left-end right-end) + (lsp--position-compare left-start right-start))) + +(lsp-defun lsp--apply-text-edit ((edit &as &TextEdit :range (&RangeToPoint :start :end) :new-text)) + "Apply the edits described in the TextEdit object in TEXT-EDIT." + (setq new-text (s-replace "\r" "" (or new-text ""))) + (lsp:set-text-edit-new-text edit new-text) + (goto-char start) + (delete-region start end) + (insert new-text)) + +;; WORKAROUND: typescript-language might send -1 when applying code actions. +;; see https://github.com/emacs-lsp/lsp-mode/issues/1582 +(lsp-defun lsp--fix-point ((point &as &Position :character :line)) + (-doto point + (lsp:set-position-line (max 0 line)) + (lsp:set-position-character (max 0 character)))) + +(lsp-defun lsp--apply-text-edit-replace-buffer-contents ((edit &as + &TextEdit + :range (&Range :start :end) + :new-text)) + "Apply the edits described in the TextEdit object in TEXT-EDIT. +The method uses `replace-buffer-contents'." + (setq new-text (s-replace "\r" "" (or new-text ""))) + (lsp:set-text-edit-new-text edit new-text) + (-let* ((source (current-buffer)) + ((beg . end) (lsp--range-to-region (lsp-make-range :start (lsp--fix-point start) + :end (lsp--fix-point end))))) + (with-temp-buffer + (insert new-text) + (let ((temp (current-buffer))) + (with-current-buffer source + (save-excursion + (save-restriction + (narrow-to-region beg end) + + ;; On emacs versions < 26.2, + ;; `replace-buffer-contents' is buggy - it calls + ;; change functions with invalid arguments - so we + ;; manually call the change functions here. + ;; + ;; See emacs bugs #32237, #32278: + ;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=32237 + ;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=32278 + (let ((inhibit-modification-hooks t) + (length (- end beg))) + (run-hook-with-args 'before-change-functions + beg end) + (replace-buffer-contents temp) + (run-hook-with-args 'after-change-functions + beg (+ beg (length new-text)) + length))))))))) + +(defun lsp--to-yasnippet-snippet (snippet) + "Convert LSP SNIPPET to yasnippet snippet." + ;; LSP snippet doesn't escape "{" and "`", but yasnippet requires escaping it. + (replace-regexp-in-string (rx (or bos (not (any "$" "\\"))) (group (or "{" "`"))) + (rx "\\" (backref 1)) + snippet + nil nil 1)) + +(defvar-local lsp-enable-relative-indentation nil + "Enable relative indentation when insert texts, snippets ... +from language server.") + +(defun lsp--expand-snippet (snippet &optional start end expand-env) + "Wrapper of `yas-expand-snippet' with all of it arguments. +The snippet will be convert to LSP style and indent according to +LSP server result." + (require 'yasnippet nil t) + (let* ((inhibit-field-text-motion t) + (yas-wrap-around-region nil) + (yas-indent-line 'none) + (yas-also-auto-indent-first-line nil)) + (yas-expand-snippet + (lsp--to-yasnippet-snippet snippet) + start end expand-env))) + +(defun lsp--indent-lines (start end &optional insert-text-mode?) + "Indent from START to END based on INSERT-TEXT-MODE? value. +- When INSERT-TEXT-MODE? is provided + - if it's `lsp/insert-text-mode-as-it', do no editor indentation. + - if it's `lsp/insert-text-mode-adjust-indentation', adjust leading + whitespaces to match the line where text is inserted. +- When it's not provided, using `indent-line-function' for each line." + (save-excursion + (goto-char end) + (let* ((end-line (line-number-at-pos)) + (offset (save-excursion + (goto-char start) + (current-indentation))) + (indent-line-function + (cond ((equal insert-text-mode? lsp/insert-text-mode-as-it) + #'ignore) + ((or (equal insert-text-mode? lsp/insert-text-mode-adjust-indentation) + lsp-enable-relative-indentation + ;; Indenting snippets is extremely slow in `org-mode' buffers + ;; since it has to calculate indentation based on SRC block + ;; position. Thus we use relative indentation as default. + (derived-mode-p 'org-mode)) + (lambda () (save-excursion + (beginning-of-line) + (indent-to-column offset)))) + (t indent-line-function)))) + (goto-char start) + (forward-line) + (while (and (not (eobp)) + (<= (line-number-at-pos) end-line)) + (funcall indent-line-function) + (forward-line))))) + +(defun lsp--apply-text-edits (edits &optional operation) + "Apply the EDITS described in the TextEdit[] object. +OPERATION is symbol representing the source of this text edit." + (unless (seq-empty-p edits) + (atomic-change-group + (run-hooks 'lsp-before-apply-edits-hook) + (let* ((change-group (prepare-change-group)) + (howmany (length edits)) + (message (format "Applying %s edits to `%s' ..." howmany (current-buffer))) + (_ (lsp--info message)) + (reporter (make-progress-reporter message 0 howmany)) + (done 0) + (apply-edit (if (not lsp--virtual-buffer) + #'lsp--apply-text-edit-replace-buffer-contents + #'lsp--apply-text-edit))) + (unwind-protect + (->> edits + ;; We sort text edits so as to apply edits that modify latter + ;; parts of the document first. Furthermore, because the LSP + ;; spec dictates that: "If multiple inserts have the same + ;; position, the order in the array defines which edit to + ;; apply first." We reverse the initial list and sort stably + ;; to make sure the order among edits with the same position + ;; is preserved. + (nreverse) + (seq-sort #'lsp--text-edit-sort-predicate) + (mapc (lambda (edit) + (progress-reporter-update reporter (cl-incf done)) + (funcall apply-edit edit) + (when (lsp:snippet-text-edit-insert-text-format? edit) + (-when-let ((&SnippetTextEdit :range (&RangeToPoint :start) + :insert-text-format? :new-text) edit) + (when (eq insert-text-format? lsp/insert-text-format-snippet) + ;; No `save-excursion' needed since expand snippet will change point anyway + (goto-char (+ start (length new-text))) + (lsp--indent-lines start (point)) + (lsp--expand-snippet new-text start (point))))) + (run-hook-with-args 'lsp-after-apply-edits-hook operation)))) + (undo-amalgamate-change-group change-group) + (progress-reporter-done reporter)))))) + +(defun lsp--create-apply-text-edits-handlers () + "Create (handler cleanup-fn) for applying text edits in async request. +Only works when mode is `tick or `alive." + (let* (first-edited + (func (lambda (start &rest _) + (setq first-edited (if first-edited + (min start first-edited) + start))))) + (add-hook 'before-change-functions func nil t) + (list + (lambda (edits) + (if (and first-edited + (seq-find (-lambda ((&TextEdit :range (&RangeToPoint :end))) + ;; Text edit region is overlapped + (> end first-edited)) + edits)) + (lsp--warn "TextEdits will not be applied since document has been modified before of them.") + (lsp--apply-text-edits edits 'completion-cleanup))) + (lambda () + (remove-hook 'before-change-functions func t))))) + +(defun lsp--capability (cap &optional capabilities) + "Get the value of capability CAP. If CAPABILITIES is non-nil, use them instead." + (when (stringp cap) + (setq cap (intern (concat ":" cap)))) + + (lsp-get (or capabilities + (lsp--server-capabilities)) + cap)) + +(defun lsp--registered-capability (method) + "Check whether there is workspace providing METHOD." + (->> (lsp-workspaces) + (--keep (seq-find (lambda (reg) + (equal (lsp--registered-capability-method reg) method)) + (lsp--workspace-registered-server-capabilities it))) + cl-first)) + +(defun lsp--capability-for-method (method) + "Get the value of capability for METHOD." + (-let* ((reqs (cdr (assoc method lsp-method-requirements))) + ((&plist :capability) reqs)) + (or (and capability (lsp--capability capability)) + (-some-> (lsp--registered-capability method) + (lsp--registered-capability-options))))) + +(defvar-local lsp--before-change-vals nil + "Store the positions from the `lsp-before-change' function call, for +validation and use in the `lsp-on-change' function.") + +(defun lsp--text-document-content-change-event (start end length) + "Make a TextDocumentContentChangeEvent body for START to END, of length LENGTH." + ;; So (47 54 0) means add 7 chars starting at pos 47 + ;; must become + ;; {"range":{"start":{"line":5,"character":6} + ;; ,"end" :{"line":5,"character":6}} + ;; ,"rangeLength":0 + ;; ,"text":"\nbb = 5"} + ;; + ;; And (47 47 7) means delete 7 chars starting at pos 47 + ;; must become + ;; {"range":{"start":{"line":6,"character":0} + ;; ,"end" :{"line":7,"character":0}} + ;; ,"rangeLength":7 + ;; ,"text":""} + ;; + ;; (208 221 3) means delete 3 chars starting at pos 208, and replace them with + ;; 13 chars. So it must become + ;; {"range":{"start":{"line":5,"character":8} + ;; ,"end" :{"line":5,"character":11}} + ;; ,"rangeLength":3 + ;; ,"text":"new-chars-xxx"} + ;; + + ;; Adding text: + ;; lsp-before-change:(start,end)=(33,33) + ;; lsp-on-change:(start,end,length)=(33,34,0) + ;; + ;; Changing text: + ;; lsp-before-change:(start,end)=(208,211) + ;; lsp-on-change:(start,end,length)=(208,221,3) + ;; + ;; Deleting text: + ;; lsp-before-change:(start,end)=(19,27) + ;; lsp-on-change:(start,end,length)=(19,19,8) + (if (zerop length) + ;; Adding something only, work from start only + `( :range ,(lsp--range + (lsp--point-to-position start) + (lsp--point-to-position start)) + :rangeLength 0 + :text ,(buffer-substring-no-properties start end)) + + (if (eq start end) + ;; Deleting something only + (if (lsp--bracketed-change-p start length) + ;; The before-change value is bracketed, use it + `( :range ,(lsp--range + (lsp--point-to-position start) + (plist-get lsp--before-change-vals :end-pos)) + :rangeLength ,length + :text "") + ;; If the change is not bracketed, send a full change event instead. + (lsp--full-change-event)) + + ;; Deleting some things, adding others + (if (lsp--bracketed-change-p start length) + ;; The before-change value is valid, use it + `( :range ,(lsp--range + (lsp--point-to-position start) + (plist-get lsp--before-change-vals :end-pos)) + :rangeLength ,length + :text ,(buffer-substring-no-properties start end)) + (lsp--full-change-event))))) + +(defun lsp--bracketed-change-p (start length) + "If the before and after positions are the same, and the length +is the size of the start range, we are probably good." + (-let [(&plist :end before-end :start before-start) lsp--before-change-vals] + (and (eq start before-start) + (eq length (- before-end before-start))))) + +(defun lsp--full-change-event () + `(:text ,(lsp--buffer-content))) + +(defun lsp-before-change (start end) + "Executed before a file is changed. +Added to `before-change-functions'." + ;; Note: + ;; + ;; This variable holds a list of functions to call when Emacs is about to + ;; modify a buffer. Each function gets two arguments, the beginning and end of + ;; the region that is about to change, represented as integers. The buffer + ;; that is about to change is always the current buffer when the function is + ;; called. + ;; + ;; WARNING: + ;; + ;; Do not expect the before-change hooks and the after-change hooks be called + ;; in balanced pairs around each buffer change. Also don't expect the + ;; before-change hooks to be called for every chunk of text Emacs is about to + ;; delete. These hooks are provided on the assumption that Lisp programs will + ;; use either before- or the after-change hooks, but not both, and the + ;; boundaries of the region where the changes happen might include more than + ;; just the actual changed text, or even lump together several changes done + ;; piecemeal. + (save-match-data + (lsp-save-restriction-and-excursion + (setq lsp--before-change-vals + (list :start start + :end end + :end-pos (lsp--point-to-position end)))))) + +(defun lsp--flush-delayed-changes () + (let ((inhibit-quit t)) + (when lsp--delay-timer + (cancel-timer lsp--delay-timer)) + (mapc (-lambda ((workspace buffer document change)) + (with-current-buffer buffer + (with-lsp-workspace workspace + (lsp-notify "textDocument/didChange" + (list :textDocument document + :contentChanges (vector change)))))) + (prog1 (nreverse lsp--delayed-requests) + (setq lsp--delayed-requests nil))))) + +(defun lsp--workspace-sync-method (workspace) + (let ((sync (-> workspace + (lsp--workspace-server-capabilities) + (lsp:server-capabilities-text-document-sync?)))) + (if (lsp-text-document-sync-options? sync) + (lsp:text-document-sync-options-change? sync) + sync))) + +(defun lsp-on-change (start end length &optional content-change-event-fn) + "Executed when a file is changed. +Added to `after-change-functions'." + ;; Note: + ;; + ;; Each function receives three arguments: the beginning and end of the region + ;; just changed, and the length of the text that existed before the change. + ;; All three arguments are integers. The buffer that has been changed is + ;; always the current buffer when the function is called. + ;; + ;; The length of the old text is the difference between the buffer positions + ;; before and after that text as it was before the change. As for the + ;; changed text, its length is simply the difference between the first two + ;; arguments. + ;; + ;; So (47 54 0) means add 7 chars starting at pos 47 + ;; So (47 47 7) means delete 7 chars starting at pos 47 + (save-match-data + (let ((inhibit-quit t) + ;; make sure that `lsp-on-change' is called in multi-workspace context + ;; see #2901 + lsp--cur-workspace) + ;; A (revert-buffer) call with the 'preserve-modes parameter (eg, as done + ;; by auto-revert-mode) will cause this handler to get called with a nil + ;; buffer-file-name. We need the buffer-file-name to send notifications; + ;; so we skip handling revert-buffer-caused changes and instead handle + ;; reverts separately in lsp-on-revert + (when (not revert-buffer-in-progress-p) + (cl-incf lsp--cur-version) + (mapc + (lambda (workspace) + (pcase (or lsp-document-sync-method + (lsp--workspace-sync-method workspace)) + (1 + (if lsp-debounce-full-sync-notifications + (setq lsp--delayed-requests + (->> lsp--delayed-requests + (-remove (-lambda ((_ buffer)) + (equal (current-buffer) buffer))) + (cons (list workspace + (current-buffer) + (lsp--versioned-text-document-identifier) + (lsp--full-change-event))))) + (with-lsp-workspace workspace + (lsp-notify "textDocument/didChange" + (list :contentChanges (vector (lsp--full-change-event)) + :textDocument (lsp--versioned-text-document-identifier)))))) + (2 + (with-lsp-workspace workspace + (lsp-notify + "textDocument/didChange" + (list :textDocument (lsp--versioned-text-document-identifier) + :contentChanges (vector + (if content-change-event-fn + (funcall content-change-event-fn start end length) + (lsp--text-document-content-change-event + start end length))))))))) + (lsp-workspaces)) + (when lsp--delay-timer (cancel-timer lsp--delay-timer)) + (setq lsp--delay-timer (run-with-idle-timer + lsp-debounce-full-sync-notifications-interval + nil + #'lsp--flush-delayed-changes)) + ;; force cleanup overlays after each change + (lsp--remove-overlays 'lsp-highlight) + (lsp--after-change (current-buffer)) + (setq lsp--signature-last-index nil + lsp--signature-last nil) + ;; cleanup diagnostics + (when lsp-diagnostic-clean-after-change + (lsp-foreach-workspace + (-let [diagnostics (lsp--workspace-diagnostics lsp--cur-workspace)] + (remhash (lsp--fix-path-casing (buffer-file-name)) diagnostics)))))))) + + + +;; facilities for on change hooks. We do not want to make lsp calls on each +;; change event so we add debounce to avoid flooding the server with events. +;; Additionally, we want to have a mechanism for stopping the server calls in +;; particular cases like, e. g. when performing completion. + +(defvar lsp-inhibit-lsp-hooks nil + "Flag to control.") + +(defcustom lsp-on-change-hook nil + "Hooks to run when buffer has changed." + :type 'hook + :group 'lsp-mode) + +(defcustom lsp-idle-delay 0.500 + "Debounce interval for `after-change-functions'." + :type 'number + :group 'lsp-mode) + +(defcustom lsp-on-idle-hook nil + "Hooks to run after `lsp-idle-delay'." + :type 'hook + :group 'lsp-mode) + +(defun lsp--idle-reschedule (buffer) + (when lsp--on-idle-timer + (cancel-timer lsp--on-idle-timer)) + + (setq lsp--on-idle-timer (run-with-idle-timer + lsp-idle-delay + nil + #'lsp--on-idle + buffer))) + +(defun lsp--post-command () + (lsp--cleanup-highlights-if-needed) + (lsp--idle-reschedule (current-buffer))) + +(defun lsp--on-idle (buffer) + "Start post command loop." + (when (and (buffer-live-p buffer) + (equal buffer (current-buffer)) + (not lsp-inhibit-lsp-hooks) + lsp-managed-mode) + (run-hooks 'lsp-on-idle-hook))) + +(defun lsp--on-change-debounce (buffer) + (when (and (buffer-live-p buffer) + (equal buffer (current-buffer)) + (not lsp-inhibit-lsp-hooks) + lsp-managed-mode) + (run-hooks 'lsp-on-change-hook))) + +(defun lsp--after-change (buffer) + (when (fboundp 'lsp--semantic-tokens-refresh-if-enabled) + (lsp--semantic-tokens-refresh-if-enabled buffer)) + (when lsp--on-change-timer + (cancel-timer lsp--on-change-timer)) + (setq lsp--on-change-timer (run-with-idle-timer + lsp-idle-delay + nil + #'lsp--on-change-debounce + buffer)) + (lsp--idle-reschedule buffer)) + + +(defcustom lsp-trim-trailing-whitespace t + "Trim trailing whitespace on a line." + :group 'lsp-mode + :type 'boolean) + +(defcustom lsp-insert-final-newline t + "Insert a newline character at the end of the file if one does not exist." + :group 'lsp-mode + :type 'boolean) + +(defcustom lsp-trim-final-newlines t + "Trim all newlines after the final newline at the end of the file." + :group 'lsp-mode + :type 'boolean) + + +(defun lsp--on-type-formatting (first-trigger-characters more-trigger-characters) + "Self insert handling. +Applies on type formatting." + (let ((ch last-command-event)) + (when (or (eq (string-to-char first-trigger-characters) ch) + (cl-find ch more-trigger-characters :key #'string-to-char)) + (lsp-request-async "textDocument/onTypeFormatting" + (lsp-make-document-on-type-formatting-params + :text-document (lsp--text-document-identifier) + :options (lsp-make-formatting-options + :tab-size (symbol-value (lsp--get-indent-width major-mode)) + :insert-spaces (lsp-json-bool (not indent-tabs-mode)) + :trim-trailing-whitespace? (lsp-json-bool lsp-trim-trailing-whitespace) + :insert-final-newline? (lsp-json-bool lsp-insert-final-newline) + :trim-final-newlines? (lsp-json-bool lsp-trim-final-newlines)) + :ch (char-to-string ch) + :position (lsp--cur-position)) + (lambda (data) (lsp--apply-text-edits data 'format)) + :mode 'tick)))) + + +;; links +(defun lsp--document-links () + (when (lsp-feature? "textDocument/documentLink") + (lsp-request-async + "textDocument/documentLink" + `(:textDocument ,(lsp--text-document-identifier)) + (lambda (links) + (lsp--remove-overlays 'lsp-link) + (seq-do + (-lambda ((link &as &DocumentLink :range (&Range :start :end))) + (-doto (make-button (lsp--position-to-point start) + (lsp--position-to-point end) + 'action (lsp--document-link-keymap link) + 'keymap (let ((map (make-sparse-keymap))) + (define-key map [M-return] 'push-button) + (define-key map [mouse-2] 'push-button) + map) + 'help-echo "mouse-2, M-RET: Visit this link") + (overlay-put 'lsp-link t))) + links)) + :mode 'unchanged))) + +(defun lsp--document-link-handle-target (url) + (let* ((parsed-url (url-generic-parse-url (url-unhex-string url))) + (type (url-type parsed-url))) + (pcase type + ("file" + (xref-push-marker-stack) + (find-file (lsp--uri-to-path url)) + (-when-let ((_ line column) (s-match (rx "#" (group (1+ num)) (or "," "#") (group (1+ num))) url)) + (goto-char (lsp--position-to-point + (lsp-make-position :character (1- (string-to-number column)) + :line (1- (string-to-number line))))))) + ((or "http" "https") (browse-url url)) + (type (if-let ((handler (lsp--get-uri-handler type))) + (funcall handler url) + (signal 'lsp-file-scheme-not-supported (list url))))))) + +(lsp-defun lsp--document-link-keymap ((link &as &DocumentLink :target?)) + (if target? + (lambda (_) + (interactive) + (lsp--document-link-handle-target target?)) + (lambda (_) + (interactive) + (when (lsp:document-link-registration-options-resolve-provider? + (lsp--capability-for-method "textDocument/documentLink")) + (lsp-request-async + "documentLink/resolve" + link + (-lambda ((&DocumentLink :target?)) + (lsp--document-link-handle-target target?))))))) + + + +(defcustom lsp-warn-no-matched-clients t + "Whether to show messages when there are no supported clients." + :group 'lsp-mode + :type 'boolean) + +(defun lsp-buffer-language--configured-id () + "Return nil when not registered." + (->> lsp-language-id-configuration + (-first + (-lambda ((mode-or-pattern . language)) + (cond + ((and (stringp mode-or-pattern) + (s-matches? mode-or-pattern (buffer-file-name))) + language) + ((eq mode-or-pattern major-mode) language)))) + cl-rest)) + +(defvar-local lsp--buffer-language nil + "Locally cached returned value of `lsp-buffer-language'.") + +(defun lsp-buffer-language () + "Get language corresponding current buffer." + (or lsp--buffer-language + (let* ((configured-language (lsp-buffer-language--configured-id))) + (setq lsp--buffer-language + (or configured-language + ;; ensure non-nil + (string-remove-suffix "-mode" (symbol-name major-mode)))) + (when (and lsp-warn-no-matched-clients + (null configured-language)) + (lsp-warn "Unable to calculate the languageId for buffer `%s'. \ +Take a look at `lsp-language-id-configuration'. The `major-mode' is %s" + (buffer-name) + major-mode)) + lsp--buffer-language))) + +(defun lsp-activate-on (&rest languages) + "Returns language activation function. +The function will return t when the `lsp-buffer-language' returns +one of the LANGUAGES." + (lambda (_file-name _mode) + (-contains? languages (lsp-buffer-language)))) + +(defun lsp-workspace-root (&optional path) + "Find the workspace root for the current file or PATH." + (-when-let* ((file-name (or path (buffer-file-name))) + (file-name (lsp-f-canonical file-name))) + (->> (lsp-session) + (lsp-session-folders) + (--filter (and (lsp--files-same-host it file-name) + (or (lsp-f-ancestor-of? it file-name) + (equal it file-name)))) + (--max-by (> (length it) (length other)))))) + +(defun lsp-on-revert () + "Executed when a file is reverted. +Added to `after-revert-hook'." + (let ((n (buffer-size)) + (revert-buffer-in-progress-p nil)) + (lsp-on-change 0 n n))) + +(defun lsp--text-document-did-close (&optional keep-workspace-alive) + "Executed when the file is closed, added to `kill-buffer-hook'. + +If KEEP-WORKSPACE-ALIVE is non-nil, do not shutdown the workspace +if it's closing the last buffer in the workspace." + (lsp-foreach-workspace + (cl-callf2 delq (lsp-current-buffer) (lsp--workspace-buffers lsp--cur-workspace)) + (with-demoted-errors "Error sending didClose notification in ‘lsp--text-document-did-close’: %S" + (lsp-notify "textDocument/didClose" + `(:textDocument ,(lsp--text-document-identifier)))) + (when (and (not lsp-keep-workspace-alive) + (not keep-workspace-alive) + (not (lsp--workspace-buffers lsp--cur-workspace))) + (lsp--shutdown-workspace)))) + +(defun lsp--will-save-text-document-params (reason) + (list :textDocument (lsp--text-document-identifier) + :reason reason)) + +(defun lsp--before-save () + "Before save handler." + (with-demoted-errors "Error in ‘lsp--before-save’: %S" + (let ((params (lsp--will-save-text-document-params 1))) + (when (lsp--send-will-save-p) + (lsp-notify "textDocument/willSave" params)) + (when (and (lsp--send-will-save-wait-until-p) lsp-before-save-edits) + (let ((lsp-response-timeout 0.1)) + (condition-case nil + (lsp--apply-text-edits + (lsp-request "textDocument/willSaveWaitUntil" + params) + 'before-save) + (error))))))) + +(defun lsp--on-auto-save () + "Handler for auto-save." + (when (lsp--send-will-save-p) + (with-demoted-errors "Error in ‘lsp--on-auto-save’: %S" + (lsp-notify "textDocument/willSave" (lsp--will-save-text-document-params 2))))) + +(defun lsp--text-document-did-save () + "Executed when the file is closed, added to `after-save-hook''." + (when (lsp--send-did-save-p) + (with-demoted-errors "Error on ‘lsp--text-document-did-save: %S’" + (lsp-notify "textDocument/didSave" + `( :textDocument ,(lsp--versioned-text-document-identifier) + ,@(when (lsp--save-include-text-p) + (list :text (lsp--buffer-content)))))))) + +(defun lsp--text-document-position-params (&optional identifier position) + "Make TextDocumentPositionParams for the current point in the current document. +If IDENTIFIER and POSITION are non-nil, they will be used as the document +identifier and the position respectively." + (list :textDocument (or identifier (lsp--text-document-identifier)) + :position (or position (lsp--cur-position)))) + +(defun lsp--get-buffer-diagnostics () + "Return buffer diagnostics." + (gethash (or + (plist-get lsp--virtual-buffer :buffer-file-name) + (lsp--fix-path-casing (buffer-file-name))) + (lsp-diagnostics t))) + +(defun lsp-cur-line-diagnostics () + "Return any diagnostics that apply to the current line." + (-let [(&plist :start (&plist :line start) :end (&plist :line end)) (lsp--region-or-line)] + (cl-coerce (-filter + (-lambda ((&Diagnostic :range (&Range :start (&Position :line)))) + (and (>= line start) (<= line end))) + (lsp--get-buffer-diagnostics)) + 'vector))) + +(lsp-defun lsp-range-overlapping?((left &as &Range :start left-start :end left-end) + (right &as &Range :start right-start :end right-end)) + (or (lsp-point-in-range? right-start left) + (lsp-point-in-range? right-end left) + (lsp-point-in-range? left-start right) + (lsp-point-in-range? left-end right))) + +(defun lsp-make-position-1 (position) + (lsp-make-position :line (plist-get position :line) + :character (plist-get position :character))) + +(defun lsp-cur-possition-diagnostics () + "Return any diagnostics that apply to the current line." + (-let* ((start (if (use-region-p) (region-beginning) (point))) + (end (if (use-region-p) (region-end) (point))) + (current-range (lsp-make-range :start (lsp-make-position-1 (lsp-point-to-position start)) + :end (lsp-make-position-1 (lsp-point-to-position end))))) + (->> (lsp--get-buffer-diagnostics) + (-filter + (-lambda ((&Diagnostic :range)) + (lsp-range-overlapping? range current-range))) + (apply 'vector)))) + +(defalias 'lsp--cur-line-diagnotics 'lsp-cur-line-diagnostics) + +(defun lsp--extract-line-from-buffer (pos) + "Return the line pointed to by POS (a Position object) in the current buffer." + (let* ((point (lsp--position-to-point pos)) + (inhibit-field-text-motion t)) + (save-excursion + (goto-char point) + (buffer-substring (line-beginning-position) (line-end-position))))) + +(lsp-defun lsp--xref-make-item (filename (&Range :start (start &as &Position :character start-char :line start-line) + :end (end &as &Position :character end-char))) + "Return a xref-item from a RANGE in FILENAME." + (let* ((line (lsp--extract-line-from-buffer start)) + (len (length line))) + (add-face-text-property (max (min start-char len) 0) + (max (min end-char len) 0) + 'xref-match t line) + ;; LINE is nil when FILENAME is not being current visited by any buffer. + (xref-make-match (or line filename) + (xref-make-file-location + filename + (lsp-translate-line (1+ start-line)) + (lsp-translate-column start-char)) + (- end-char start-char)))) + +(defun lsp--location-uri (loc) + (if (lsp-location? loc) + (lsp:location-uri loc) + (lsp:location-link-target-uri loc))) + +(lsp-defun lsp-goto-location ((loc &as &Location :uri :range (&Range :start))) + "Go to location." + (let ((path (lsp--uri-to-path uri))) + (if (f-exists? path) + (with-current-buffer (find-file path) + (goto-char (lsp--position-to-point start))) + (error "There is no file %s" path)))) + +(defun lsp--location-range (loc) + (if (lsp-location? loc) + (lsp:location-range loc) + (lsp:location-link-target-selection-range loc))) + +(defun lsp--locations-to-xref-items (locations) + "Return a list of `xref-item' given LOCATIONS, which can be of +type Location, LocationLink, Location[] or LocationLink[]." + (setq locations + (pcase locations + ((seq (or (Location) + (LocationLink))) + (append locations nil)) + ((or (Location) + (LocationLink)) + (list locations)))) + + (cl-labels ((get-xrefs-in-file + (file-locs) + (-let [(filename . matches) file-locs] + (condition-case err + (let ((visiting (find-buffer-visiting filename)) + (fn (lambda (loc) + (lsp-with-filename filename + (lsp--xref-make-item filename + (lsp--location-range loc)))))) + (if visiting + (with-current-buffer visiting + (seq-map fn matches)) + (when (file-readable-p filename) + (with-temp-buffer + (insert-file-contents-literally filename) + (seq-map fn matches))))) + (error (lsp-warn "Failed to process xref entry for filename '%s': %s" + filename (error-message-string err))) + (file-error (lsp-warn "Failed to process xref entry, file-error, '%s': %s" + filename (error-message-string err))))))) + + (->> locations + (seq-sort #'lsp--location-before-p) + (seq-group-by (-compose #'lsp--uri-to-path #'lsp--location-uri)) + (seq-map #'get-xrefs-in-file) + (apply #'nconc)))) + +(defun lsp--location-before-p (left right) + "Sort first by file, then by line, then by column." + (let ((left-uri (lsp--location-uri left)) + (right-uri (lsp--location-uri right))) + (if (not (string= left-uri right-uri)) + (string< left-uri right-uri) + (-let (((&Range :start left-start) (lsp--location-range left)) + ((&Range :start right-start) (lsp--location-range right))) + (lsp--position-compare right-start left-start))))) + +(defun lsp--make-reference-params (&optional td-position exclude-declaration) + "Make a ReferenceParam object. +If TD-POSITION is non-nil, use it as TextDocumentPositionParams object instead. +If EXCLUDE-DECLARATION is non-nil, request the server to include declarations." + (let ((json-false :json-false)) + (plist-put (or td-position (lsp--text-document-position-params)) + :context `(:includeDeclaration ,(lsp-json-bool (not exclude-declaration)))))) + +(defun lsp--cancel-request (id) + "Cancel request with ID in all workspaces." + (lsp-foreach-workspace + (->> lsp--cur-workspace lsp--workspace-client lsp--client-response-handlers (remhash id)) + (lsp-notify "$/cancelRequest" `(:id ,id)))) + +(defvar-local lsp--hover-saved-bounds nil) + +(defun lsp-eldoc-function (cb &rest _ignored) + "`lsp-mode' eldoc function to display hover info (based on `textDocument/hover')." + (if (and lsp--hover-saved-bounds + (lsp--point-in-bounds-p lsp--hover-saved-bounds)) + lsp--eldoc-saved-message + (setq lsp--hover-saved-bounds nil + lsp--eldoc-saved-message nil) + (if (looking-at-p "[[:space:]\n]") + (setq lsp--eldoc-saved-message nil) ; And returns nil. + (when (and lsp-eldoc-enable-hover (lsp-feature? "textDocument/hover")) + (lsp-request-async + "textDocument/hover" + (lsp--text-document-position-params) + (-lambda ((hover &as &Hover? :range? :contents)) + (setq lsp--hover-saved-bounds (when range? + (lsp--range-to-region range?))) + (funcall cb (setq lsp--eldoc-saved-message + (when contents + (lsp--render-on-hover-content + contents + lsp-eldoc-render-all))))) + :error-handler #'ignore + :mode 'tick + :cancel-token :eldoc-hover))))) + +(defun lsp--point-on-highlight? () + (-some? (lambda (overlay) + (overlay-get overlay 'lsp-highlight)) + (overlays-at (point)))) + +(defun lsp--cleanup-highlights-if-needed () + (when (and lsp-enable-symbol-highlighting + lsp--have-document-highlights + (not (lsp--point-on-highlight?))) + (lsp--remove-overlays 'lsp-highlight) + (setq lsp--have-document-highlights nil) + (lsp-cancel-request-by-token :highlights))) + +(defvar-local lsp--symbol-bounds-of-last-highlight-invocation nil + "The bounds of the symbol from which `lsp--document-highlight' + most recently requested highlights.") + +(defun lsp--document-highlight () + (when (lsp-feature? "textDocument/documentHighlight") + (let ((curr-sym-bounds (bounds-of-thing-at-point 'symbol))) + (unless (or (looking-at-p "[[:space:]\n]") + (not lsp-enable-symbol-highlighting) + (and lsp--have-document-highlights + curr-sym-bounds + (equal curr-sym-bounds + lsp--symbol-bounds-of-last-highlight-invocation))) + (setq lsp--symbol-bounds-of-last-highlight-invocation + curr-sym-bounds) + (lsp-request-async "textDocument/documentHighlight" + (lsp--text-document-position-params) + #'lsp--document-highlight-callback + :mode 'tick + :cancel-token :highlights))))) + +(defun lsp--help-open-link (&rest _) + "Open markdown link at point via mouse or keyboard." + (interactive "P") + (let ((buffer-list-update-hook nil)) + (-let [(buffer point) (if-let* ((valid (and (listp last-input-event) + (eq (car last-input-event) 'mouse-2))) + (event (cadr last-input-event)) + (win (posn-window event)) + (buffer (window-buffer win))) + `(,buffer ,(posn-point event)) + `(,(current-buffer) ,(point)))] + (with-current-buffer buffer + (when-let* ((face (get-text-property point 'face)) + (url (or (and (eq face 'markdown-link-face) + (get-text-property point 'help-echo)) + (and (memq face '(markdown-url-face markdown-plain-url-face)) + (nth 3 (markdown-link-at-pos point)))))) + (lsp--document-link-handle-target url)))))) + +(defvar lsp-help-mode-map + (-doto (make-sparse-keymap) + (define-key [remap markdown-follow-link-at-point] #'lsp--help-open-link)) + "Keymap for `lsp-help-mode'.") + +(define-derived-mode lsp-help-mode help-mode "LspHelp" + "Major mode for displaying lsp help.") + +(defun lsp-describe-thing-at-point () + "Display the type signature and documentation of the thing at point." + (interactive) + (let ((contents (-some->> (lsp--text-document-position-params) + (lsp--make-request "textDocument/hover") + (lsp--send-request) + (lsp:hover-contents)))) + (if (and contents (not (equal contents ""))) + (let ((lsp-help-buf-name "*lsp-help*")) + (with-current-buffer (get-buffer-create lsp-help-buf-name) + (delay-mode-hooks + (lsp-help-mode) + (with-help-window lsp-help-buf-name + (insert (string-trim-right (lsp--render-on-hover-content contents t))))) + (run-mode-hooks))) + (lsp--info "No content at point.")))) + +(defun lsp--point-in-bounds-p (bounds) + "Return whether the current point is within BOUNDS." + (and (<= (car bounds) (point)) (< (point) (cdr bounds)))) + +(defun lsp-get-renderer (language) + "Get renderer for LANGUAGE." + (lambda (str) + (lsp--render-string str language))) + +(defun lsp--setup-markdown (mode) + "Setup the ‘markdown-mode’ in the frame. +MODE is the mode used in the parent frame." + (make-local-variable 'markdown-code-lang-modes) + (dolist (mark (alist-get mode lsp-custom-markup-modes)) + (add-to-list 'markdown-code-lang-modes (cons mark mode))) + (setq-local markdown-fontify-code-blocks-natively t) + (setq-local markdown-fontify-code-block-default-mode mode) + (setq-local markdown-hide-markup t) + + ;; Render some common HTML entities. + ;; This should really happen in markdown-mode instead, + ;; but it doesn't, so we do it here for now. + (setq prettify-symbols-alist + (cl-loop for i from 0 to 255 + collect (cons (format "&#x%02X;" i) i))) + (push '("&lt;" . ?<) prettify-symbols-alist) + (push '("&gt;" . ?>) prettify-symbols-alist) + (push '("&amp;" . ?&) prettify-symbols-alist) + (push '("&nbsp;" . ? ) prettify-symbols-alist) + (setq prettify-symbols-compose-predicate + (lambda (_start _end _match) t)) + (prettify-symbols-mode 1)) + +(defvar lsp-help-link-keymap + (let ((map (make-sparse-keymap))) + (define-key map [mouse-2] #'lsp--help-open-link) + (define-key map "\r" #'lsp--help-open-link) + map) + "Keymap active on links in *lsp-help* mode.") + +(defun lsp--fix-markdown-links () + (let ((inhibit-read-only t) + (inhibit-modification-hooks t) + (prop)) + (save-restriction + (goto-char (point-min)) + (while (setq prop (markdown-find-next-prop 'face)) + (let ((end (or (next-single-property-change (car prop) 'face) + (point-max)))) + (when (memq (get-text-property (car prop) 'face) + '(markdown-link-face + markdown-url-face + markdown-plain-url-face)) + (add-text-properties (car prop) end + (list 'button t + 'category 'lsp-help-link + 'follow-link t + 'keymap lsp-help-link-keymap))) + (goto-char end)))))) + +(defun lsp--buffer-string-visible () + "Return visible buffer string. +Stolen from `org-copy-visible'." + (let ((temp (generate-new-buffer " *temp*")) + (beg (point-min)) + (end (point-max))) + (while (/= beg end) + (when (get-char-property beg 'invisible) + (setq beg (next-single-char-property-change beg 'invisible nil end))) + (let* ((next (next-single-char-property-change beg 'invisible nil end)) + (substring (buffer-substring beg next))) + (with-current-buffer temp (insert substring)) + ;; (setq result (concat result substring)) + (setq beg next))) + (setq deactivate-mark t) + (prog1 (with-current-buffer temp + (s-chop-suffix "\n" (buffer-string))) + (kill-buffer temp)))) + +(defvar lsp-buffer-major-mode nil + "Holds the major mode when fontification function is running. +See #2588") + +(defvar view-inhibit-help-message) + +(defun lsp--render-markdown () + "Render markdown." + + (let ((markdown-enable-math nil)) + (goto-char (point-min)) + (while (re-search-forward + (rx (and "\\" (group (or "\\" "`" "*" "_" ":" "/" + "{" "}" "[" "]" "(" ")" + "#" "+" "-" "." "!" "|")))) + nil t) + (replace-match (rx (backref 1)))) + + ;; markdown-mode v2.3 does not yet provide gfm-view-mode + (if (fboundp 'gfm-view-mode) + (let ((view-inhibit-help-message t)) + (gfm-view-mode)) + (gfm-mode)) + + (lsp--setup-markdown lsp-buffer-major-mode))) + +(defvar lsp--display-inline-image-alist + '((lsp--render-markdown + (:regexp + "!\\[.*?\\](data:image/[a-zA-Z]+;base64,\\([A-Za-z0-9+/\n]+?=*?\\)\\(|[^)]+\\)?)" + :sexp + (create-image + (base64-decode-string + (buffer-substring-no-properties (match-beginning 1) (match-end 1))) + nil t)))) + "Replaced string regexp and function returning image. +Each element should have the form (MODE . (PROPERTY-LIST...)). +MODE (car) is function which is defined in `lsp-language-id-configuration'. +Cdr should be list of PROPERTY-LIST. + +Each PROPERTY-LIST should have properties: +:regexp Regexp which determines what string is relpaced to image. + You should also get information of image, by parenthesis constructs. + By default, all matched string is replaced to image, but you can + change index of replaced string by keyword :replaced-index. + +:sexp Return image when evaluated. You can use information of regexp + by using (match-beggining N), (match-end N) or (match-substring N). + +In addition, each can have property: +:replaced-index Determine index which is used to replace regexp to image. + The value means first argument of `match-beginning' and + `match-end'. If omitted, interpreted as index 0.") + +(defcustom lsp-display-inline-image t + "Showing inline image or not." + :group 'lsp-mode + :type 'boolean) + +(defcustom lsp-enable-suggest-server-download t + "When non-nil enable server downloading suggestions." + :group 'lsp-mode + :type 'boolean + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-auto-register-remote-clients t + "When non-nil register remote when registering the local one." + :group 'lsp-mode + :type 'boolean + :package-version '(lsp-mode . "9.0.0")) + +(defun lsp--display-inline-image (mode) + "Add image property if available." + (let ((plist-list (cdr (assq mode lsp--display-inline-image-alist)))) + (when (and (display-images-p) lsp-display-inline-image) + (cl-loop + for plist in plist-list + with regexp with replaced-index + do + (setq regexp (plist-get plist :regexp)) + (setq replaced-index (or (plist-get plist :replaced-index) 0)) + + (font-lock-remove-keywords nil (list regexp replaced-index)) + (let ((inhibit-read-only t)) + (save-excursion + (goto-char (point-min)) + (while (re-search-forward regexp nil t) + (set-text-properties + (match-beginning replaced-index) (match-end replaced-index) + nil) + (add-text-properties + (match-beginning replaced-index) (match-end replaced-index) + `(display ,(eval (plist-get plist :sexp))))))))))) + +(defun lsp--fontlock-with-mode (str mode) + "Fontlock STR with MODE." + (let ((lsp-buffer-major-mode major-mode)) + (with-temp-buffer + (with-demoted-errors "Error during doc rendering: %s" + (insert str) + (delay-mode-hooks (funcall mode)) + (cl-flet ((window-body-width () lsp-window-body-width)) + ;; This can go wrong in some cases, and the fontification would + ;; not work as expected. + ;; + ;; See #2984 + (ignore-errors (font-lock-ensure)) + (lsp--display-inline-image mode) + (when (eq mode 'lsp--render-markdown) + (lsp--fix-markdown-links)))) + (lsp--buffer-string-visible)))) + +(defun lsp--render-string (str language) + "Render STR using `major-mode' corresponding to LANGUAGE. +When language is nil render as markup if `markdown-mode' is loaded." + (setq str (s-replace "\r" "" (or str ""))) + (if-let* ((modes (-keep (-lambda ((mode . lang)) + (when (and (equal lang language) (functionp mode)) + mode)) + lsp-language-id-configuration)) + (mode (car (or (member major-mode modes) modes)))) + (lsp--fontlock-with-mode str mode) + str)) + +(defun lsp--render-element (content) + "Render CONTENT element." + (let ((inhibit-message t)) + (or + (pcase content + ((MarkedString :value :language) + (lsp--render-string value language)) + ((MarkupContent :value :kind) + (lsp--render-string value kind)) + ;; plain string + ((pred stringp) (lsp--render-string content "markdown")) + ((pred null) "") + (_ (error "Failed to handle %s" content))) + ""))) + +(defun lsp--create-unique-string-fn () + (let (elements) + (lambda (element) + (let ((count (cl-count element elements :test #'string=))) + (prog1 (if (zerop count) + element + (format "%s (%s)" element count)) + (push element elements)))))) + +(defun lsp--select-action (actions) + "Select an action to execute from ACTIONS." + (cond + ((seq-empty-p actions) (signal 'lsp-no-code-actions nil)) + ((and (eq (seq-length actions) 1) lsp-auto-execute-action) + (lsp-seq-first actions)) + (t (let ((completion-ignore-case t)) + (lsp--completing-read "Select code action: " + (seq-into actions 'list) + (-compose (lsp--create-unique-string-fn) + #'lsp:code-action-title) + nil t))))) + +(defun lsp--workspace-server-id (workspace) + "Return the server ID of WORKSPACE." + (-> workspace lsp--workspace-client lsp--client-server-id)) + +(defun lsp--handle-rendered-for-echo-area (contents) + "Return a single line from RENDERED, appropriate for display in the echo area." + (pcase (lsp-workspaces) + (`(,workspace) + (lsp-clients-extract-signature-on-hover contents (lsp--workspace-server-id workspace))) + ;; For projects with multiple active workspaces we also default to + ;; render the first line. + (_ (lsp-clients-extract-signature-on-hover contents nil)))) + +(cl-defmethod lsp-clients-extract-signature-on-hover (contents _server-id) + "Extract a representative line from CONTENTS, to show in the echo area." + (car (s-lines (s-trim (lsp--render-element contents))))) + +(defun lsp--render-on-hover-content (contents render-all) + "Render the content received from `document/onHover' request. +CONTENTS - MarkedString | MarkedString[] | MarkupContent +RENDER-ALL - nil if only the signature should be rendered." + (cond + ((lsp-markup-content? contents) + ;; MarkupContent. + ;; It tends to be long and is not suitable to display fully in the echo area. + ;; Just display the first line which is typically the signature. + (if render-all + (lsp--render-element contents) + (lsp--handle-rendered-for-echo-area contents))) + ((and (stringp contents) (not (string-match-p "\n" contents))) + ;; If the contents is a single string containing a single line, + ;; render it always. + (lsp--render-element contents)) + (t + ;; MarkedString -> MarkedString[] + (when (or (lsp-marked-string? contents) (stringp contents)) + (setq contents (list contents))) + ;; Consider the signature consisting of the elements who have a renderable + ;; "language" property. When render-all is nil, ignore other elements. + (string-join + (seq-map + #'lsp--render-element + (if render-all + contents + ;; Only render contents that have an available renderer. + (seq-take + (seq-filter + (-andfn #'lsp-marked-string? + (-compose #'lsp-get-renderer #'lsp:marked-string-language)) + contents) + 1))) + (if (bound-and-true-p page-break-lines-mode) + "\n \n" + "\n"))))) + + + +(defvar lsp-signature-mode-map + (-doto (make-sparse-keymap) + (define-key (kbd "M-n") #'lsp-signature-next) + (define-key (kbd "M-p") #'lsp-signature-previous) + (define-key (kbd "M-a") #'lsp-signature-toggle-full-docs) + (define-key (kbd "C-c C-k") #'lsp-signature-stop) + (define-key (kbd "C-g") #'lsp-signature-stop)) + "Keymap for `lsp-signature-mode'.") + +(define-minor-mode lsp-signature-mode + "Mode used to show signature popup." + :keymap lsp-signature-mode-map + :lighter "" + :group 'lsp-mode) + +(defun lsp-signature-stop () + "Stop showing current signature help." + (interactive) + (lsp-cancel-request-by-token :signature) + (remove-hook 'post-command-hook #'lsp-signature) + (funcall lsp-signature-function nil) + (lsp-signature-mode -1)) + +(declare-function page-break-lines--update-display-tables "ext:page-break-lines") + +(defun lsp--setup-page-break-mode-if-present () + "Enable `page-break-lines-mode' in current buffer." + (when (fboundp 'page-break-lines-mode) + (page-break-lines-mode) + ;; force page-break-lines-mode to update the display tables. + (page-break-lines--update-display-tables))) + +(defun lsp-lv-message (message) + (add-hook 'lv-window-hook #'lsp--setup-page-break-mode-if-present) + (if message + (progn + (setq lsp--signature-last-buffer (current-buffer)) + (let ((lv-force-update t)) + (lv-message "%s" message))) + (lv-delete-window) + (remove-hook 'lv-window-hook #'lsp--setup-page-break-mode-if-present))) + +(declare-function posframe-show "ext:posframe") +(declare-function posframe-hide "ext:posframe") +(declare-function posframe-poshandler-point-bottom-left-corner-upward "ext:posframe") + +(defface lsp-signature-posframe + '((t :inherit tooltip)) + "Background and foreground for `lsp-signature-posframe'." + :group 'lsp-mode) + +(defvar lsp-signature-posframe-params + (list :poshandler #'posframe-poshandler-point-bottom-left-corner-upward + :height 10 + :width 60 + :border-width 1 + :min-width 60) + "Params for signature and `posframe-show'.") + +(defun lsp-signature-posframe (str) + "Use posframe to show the STR signatureHelp string." + (if str + (apply #'posframe-show + (with-current-buffer (get-buffer-create " *lsp-signature*") + (erase-buffer) + (insert str) + (visual-line-mode 1) + (lsp--setup-page-break-mode-if-present) + (current-buffer)) + (append + lsp-signature-posframe-params + (list :position (point) + :background-color (face-attribute 'lsp-signature-posframe :background nil t) + :foreground-color (face-attribute 'lsp-signature-posframe :foreground nil t) + :border-color (face-attribute 'font-lock-comment-face :foreground nil t)))) + (posframe-hide " *lsp-signature*"))) + +(defun lsp--handle-signature-update (signature) + (let ((message + (if (lsp-signature-help? signature) + (lsp--signature->message signature) + (mapconcat #'lsp--signature->message signature "\n")))) + (if (s-present? message) + (funcall lsp-signature-function message) + (lsp-signature-stop)))) + +(defun lsp-signature-activate () + "Activate signature help. +It will show up only if current point has signature help." + (interactive) + (setq lsp--signature-last nil + lsp--signature-last-index nil + lsp--signature-last-buffer (current-buffer)) + (add-hook 'post-command-hook #'lsp-signature) + (lsp-signature-mode t)) + +(defcustom lsp-signature-cycle t + "Whether `lsp-signature-next' and prev should cycle." + :type 'boolean + :group 'lsp-mode) + +(defun lsp-signature-next () + "Show next signature." + (interactive) + (let ((nsigs (length (lsp:signature-help-signatures lsp--signature-last)))) + (when (and lsp--signature-last-index + lsp--signature-last + (or lsp-signature-cycle (< (1+ lsp--signature-last-index) nsigs))) + (setq lsp--signature-last-index (% (1+ lsp--signature-last-index) nsigs)) + (funcall lsp-signature-function (lsp--signature->message lsp--signature-last))))) + +(defun lsp-signature-previous () + "Next signature." + (interactive) + (when (and lsp--signature-last-index + lsp--signature-last + (or lsp-signature-cycle (not (zerop lsp--signature-last-index)))) + (setq lsp--signature-last-index (1- (if (zerop lsp--signature-last-index) + (length (lsp:signature-help-signatures lsp--signature-last)) + lsp--signature-last-index))) + (funcall lsp-signature-function (lsp--signature->message lsp--signature-last)))) + +(defun lsp-signature-toggle-full-docs () + "Toggle full/partial signature documentation." + (interactive) + (let ((all? (not (numberp lsp-signature-doc-lines)))) + (setq lsp-signature-doc-lines (if all? + (or (car-safe lsp-signature-doc-lines) + 20) + (list lsp-signature-doc-lines)))) + (lsp-signature-activate)) + +(defun lsp--signature->message (signature-help) + "Generate eldoc message from SIGNATURE-HELP response." + (setq lsp--signature-last signature-help) + + (when (and signature-help (not (seq-empty-p (lsp:signature-help-signatures signature-help)))) + (-let* (((&SignatureHelp :active-signature? + :active-parameter? + :signatures) signature-help) + (active-signature? (or lsp--signature-last-index active-signature? 0)) + (_ (setq lsp--signature-last-index active-signature?)) + ((signature &as &SignatureInformation? :label :parameters?) (seq-elt signatures active-signature?)) + (prefix (if (= (length signatures) 1) + "" + (concat (propertize (format " %s/%s" + (1+ active-signature?) + (length signatures)) + 'face 'success) + " "))) + (method-docs (when + (and lsp-signature-render-documentation + (or (not (numberp lsp-signature-doc-lines)) (< 0 lsp-signature-doc-lines))) + (let ((docs (lsp--render-element + (lsp:parameter-information-documentation? signature)))) + (when (s-present? docs) + (concat + "\n" + (if (fboundp 'page-break-lines-mode) + " \n" + "") + (if (and (numberp lsp-signature-doc-lines) + (> (length (s-lines docs)) lsp-signature-doc-lines)) + (concat (s-join "\n" (-take lsp-signature-doc-lines (s-lines docs))) + (propertize "\nTruncated..." 'face 'highlight)) + docs))))))) + (when (and active-parameter? (not (seq-empty-p parameters?))) + (-when-let* ((param (when (and (< -1 active-parameter? (length parameters?))) + (seq-elt parameters? active-parameter?))) + (selected-param-label (let ((label (lsp:parameter-information-label param))) + (if (stringp label) label (append label nil)))) + (start (if (stringp selected-param-label) + (s-index-of selected-param-label label) + (cl-first selected-param-label))) + (end (if (stringp selected-param-label) + (+ start (length selected-param-label)) + (cl-second selected-param-label)))) + (add-face-text-property start end 'eldoc-highlight-function-argument nil label))) + (concat prefix label method-docs)))) + +(defun lsp-signature () + "Display signature info (based on `textDocument/signatureHelp')" + (if (and lsp--signature-last-buffer + (not (equal (current-buffer) lsp--signature-last-buffer))) + (lsp-signature-stop) + (lsp-request-async "textDocument/signatureHelp" + (lsp--text-document-position-params) + #'lsp--handle-signature-update + :cancel-token :signature))) + + +(defcustom lsp-overlay-document-color-char "■" + "Display the char represent the document color in overlay" + :type 'string + :group 'lsp-mode) + +;; color presentation +(defun lsp--color-create-interactive-command (color range) + (lambda () + (interactive) + (-let [(&ColorPresentation? :text-edit? + :additional-text-edits?) + (lsp--completing-read + "Select color presentation: " + (lsp-request + "textDocument/colorPresentation" + `( :textDocument ,(lsp--text-document-identifier) + :color ,color + :range ,range)) + #'lsp:color-presentation-label + nil + t)] + (when text-edit? + (lsp--apply-text-edit text-edit?)) + (when additional-text-edits? + (lsp--apply-text-edits additional-text-edits? 'color-presentation))))) + +(defun lsp--number->color (number) + (let ((result (format "%x" + (round (* (or number 0) 255.0))))) + (if (= 1 (length result)) + (concat "0" result) + result))) + +(defun lsp--document-color () + "Document color handler." + (when (lsp-feature? "textDocument/documentColor") + (lsp-request-async + "textDocument/documentColor" + `(:textDocument ,(lsp--text-document-identifier)) + (lambda (result) + (lsp--remove-overlays 'lsp-color) + (seq-do + (-lambda ((&ColorInformation :color (color &as &Color :red :green :blue) + :range)) + (-let* (((beg . end) (lsp--range-to-region range)) + (overlay (make-overlay beg end)) + (command (lsp--color-create-interactive-command color range))) + (overlay-put overlay 'lsp-color t) + (overlay-put overlay 'evaporate t) + (overlay-put overlay + 'before-string + (propertize + lsp-overlay-document-color-char + 'face `((:foreground ,(format + "#%s%s%s" + (lsp--number->color red) + (lsp--number->color green) + (lsp--number->color blue)))) + 'action command + 'mouse-face 'lsp-lens-mouse-face + 'local-map (-doto (make-sparse-keymap) + (define-key [mouse-1] command)))))) + result)) + :mode 'unchanged + :cancel-token :document-color-token))) + + + +(defun lsp--action-trigger-parameter-hints (_command) + "Handler for editor.action.triggerParameterHints." + (when (member :on-server-request lsp-signature-auto-activate) + (lsp-signature-activate))) + +(defun lsp--action-trigger-suggest (_command) + "Handler for editor.action.triggerSuggest." + (cond + ((and (bound-and-true-p company-mode) + (fboundp 'company-auto-begin) + (fboundp 'company-post-command)) + (run-at-time 0 nil + (lambda () + (let ((this-command 'company-idle-begin) + (company-minimum-prefix-length 0)) + (company-auto-begin) + (company-post-command))))) + (t + (completion-at-point)))) + +(defconst lsp--default-action-handlers + (ht ("editor.action.triggerParameterHints" #'lsp--action-trigger-parameter-hints) + ("editor.action.triggerSuggest" #'lsp--action-trigger-suggest)) + "Default action handlers.") + +(defun lsp--find-action-handler (command) + "Find action handler for particular COMMAND." + (or + (--some (-some->> it + (lsp--workspace-client) + (lsp--client-action-handlers) + (gethash command)) + (lsp-workspaces)) + (gethash command lsp--default-action-handlers))) + +(defun lsp--text-document-code-action-params (&optional kind) + "Code action params." + (list :textDocument (lsp--text-document-identifier) + :range (if (use-region-p) + (lsp--region-to-range (region-beginning) (region-end)) + (lsp--region-to-range (point) (point))) + :context `( :diagnostics ,(lsp-cur-possition-diagnostics) + ,@(when kind (list :only (vector kind)))))) + +(defun lsp-code-actions-at-point (&optional kind) + "Retrieve the code actions for the active region or the current line. +It will filter by KIND if non nil." + (lsp-request "textDocument/codeAction" (lsp--text-document-code-action-params kind))) + +(defun lsp-execute-code-action-by-kind (command-kind) + "Execute code action by COMMAND-KIND." + (if-let ((action (->> (lsp-get-or-calculate-code-actions command-kind) + (-filter (-lambda ((&CodeAction :kind?)) + (and kind? (s-prefix? command-kind kind?)))) + lsp--select-action))) + (lsp-execute-code-action action) + (signal 'lsp-no-code-actions '(command-kind)))) + +(defalias 'lsp-get-or-calculate-code-actions 'lsp-code-actions-at-point) + +(lsp-defun lsp--execute-command ((action &as &Command :command :arguments?)) + "Parse and execute a code ACTION represented as a Command LSP type." + (let ((server-id (->> (lsp-workspaces) + (cl-first) + (or lsp--cur-workspace) + (lsp--workspace-client) + (lsp--client-server-id)))) + (condition-case nil + (with-no-warnings + (lsp-execute-command server-id (intern command) arguments?)) + (cl-no-applicable-method + (if-let ((action-handler (lsp--find-action-handler command))) + (funcall action-handler action) + (lsp-send-execute-command command arguments?)))))) + +(lsp-defun lsp-execute-code-action ((action &as &CodeAction :command? :edit?)) + "Execute code action ACTION. For example, when text under the +caret has a suggestion to apply a fix from an lsp-server, calling +this function will do so. +If ACTION is not set it will be selected from `lsp-code-actions-at-point'. +Request codeAction/resolve for more info if server supports." + (interactive (list (lsp--select-action (lsp-code-actions-at-point)))) + (if (and (lsp-feature? "codeAction/resolve") + (not command?) + (not edit?)) + (lsp--execute-code-action (lsp-request "codeAction/resolve" action)) + (lsp--execute-code-action action))) + +(lsp-defun lsp--execute-code-action ((action &as &CodeAction :command? :edit?)) + "Execute code action ACTION." + (when edit? + (lsp--apply-workspace-edit edit? 'code-action)) + + (cond + ((stringp command?) (lsp--execute-command action)) + ((lsp-command? command?) (lsp--execute-command command?)))) + +(defvar lsp--formatting-indent-alist + ;; Taken from `dtrt-indent-mode' + '( + (ada-mode . ada-indent) ; Ada + (ada-ts-mode . ada-ts-mode-indent-offset) + (c++-mode . c-basic-offset) ; C++ + (c++-ts-mode . c-ts-mode-indent-offset) + (c-mode . c-basic-offset) ; C + (c-ts-mode . c-ts-mode-indent-offset) + (cperl-mode . cperl-indent-level) ; Perl + (crystal-mode . crystal-indent-level) ; Crystal (Ruby) + (csharp-mode . c-basic-offset) ; C# + (csharp-tree-sitter-mode . csharp-tree-sitter-indent-offset) ; C# + (csharp-ts-mode . csharp-ts-mode-indent-offset) ; C# (tree-sitter, Emacs29) + (css-mode . css-indent-offset) ; CSS + (d-mode . c-basic-offset) ; D + (enh-ruby-mode . enh-ruby-indent-level) ; Ruby + (erlang-mode . erlang-indent-level) ; Erlang + (ess-mode . ess-indent-offset) ; ESS (R) + (go-ts-mode . go-ts-mode-indent-offset) + (gpr-mode . gpr-indent-offset) ; GNAT Project + (gpr-ts-mode . gpr-ts-mode-indent-offset) + (hack-mode . hack-indent-offset) ; Hack + (java-mode . c-basic-offset) ; Java + (java-ts-mode . java-ts-mode-indent-offset) + (jde-mode . c-basic-offset) ; Java (JDE) + (js-mode . js-indent-level) ; JavaScript + (js-ts-mode . js-indent-level) + (js2-mode . js2-basic-offset) ; JavaScript-IDE + (js3-mode . js3-indent-level) ; JavaScript-IDE + (json-mode . js-indent-level) ; JSON + (json-ts-mode . json-ts-mode-indent-offset) + (lua-mode . lua-indent-level) ; Lua + (lua-ts-mode . lua-ts-indent-offset) + (nxml-mode . nxml-child-indent) ; XML + (objc-mode . c-basic-offset) ; Objective C + (pascal-mode . pascal-indent-level) ; Pascal + (perl-mode . perl-indent-level) ; Perl + (php-mode . c-basic-offset) ; PHP + (php-ts-mode . php-ts-mode-indent-offset) ; PHP + (powershell-mode . powershell-indent) ; PowerShell + (powershell-ts-mode . powershell-ts-mode-indent-offset) ; PowerShell + (raku-mode . raku-indent-offset) ; Perl6/Raku + (ruby-mode . ruby-indent-level) ; Ruby + (rust-mode . rust-indent-offset) ; Rust + (rust-ts-mode . rust-ts-mode-indent-offset) + (rustic-mode . rustic-indent-offset) ; Rust + (scala-mode . scala-indent:step) ; Scala + (sgml-mode . sgml-basic-offset) ; SGML + (sh-mode . sh-basic-offset) ; Shell Script + (toml-ts-mode . toml-ts-mode-indent-offset) + (typescript-mode . typescript-indent-level) ; Typescript + (typescript-ts-mode . typescript-ts-mode-indent-offset) ; Typescript (tree-sitter, Emacs29) + (yaml-mode . yaml-indent-offset) ; YAML + (yang-mode . c-basic-offset) ; YANG (yang-mode) + + (default . standard-indent)) ; default fallback + "A mapping from `major-mode' to its indent variable.") + +(defun lsp--get-indent-width (mode) + "Get indentation offset for MODE." + (or (alist-get mode lsp--formatting-indent-alist) + (lsp--get-indent-width (or (get mode 'derived-mode-parent) 'default)))) + +(defun lsp--make-document-formatting-params () + "Create document formatting params." + (lsp-make-document-formatting-params + :text-document (lsp--text-document-identifier) + :options (lsp-make-formatting-options + :tab-size (symbol-value (lsp--get-indent-width major-mode)) + :insert-spaces (lsp-json-bool (not indent-tabs-mode)) + :trim-trailing-whitespace? (lsp-json-bool lsp-trim-trailing-whitespace) + :insert-final-newline? (lsp-json-bool lsp-insert-final-newline) + :trim-final-newlines? (lsp-json-bool lsp-trim-final-newlines)))) + +(defun lsp-format-buffer () + "Ask the server to format this document." + (interactive "*") + (cond ((lsp-feature? "textDocument/formatting") + (let ((edits (lsp-request "textDocument/formatting" + (lsp--make-document-formatting-params)))) + (if (seq-empty-p edits) + (lsp--info "No formatting changes provided") + (lsp--apply-text-edits edits 'format)))) + ((lsp-feature? "textDocument/rangeFormatting") + (save-restriction + (widen) + (lsp-format-region (point-min) (point-max)))) + (t (signal 'lsp-capability-not-supported (list "documentFormattingProvider"))))) + +(defun lsp-format-region (s e) + "Ask the server to format the region, or if none is selected, the current line." + (interactive "r") + (let ((edits (lsp-request + "textDocument/rangeFormatting" + (lsp--make-document-range-formatting-params s e)))) + (if (seq-empty-p edits) + (lsp--info "No formatting changes provided") + (lsp--apply-text-edits edits 'format)))) + +(defmacro lsp-make-interactive-code-action (func-name code-action-kind) + "Define an interactive function FUNC-NAME that attempts to +execute a CODE-ACTION-KIND action." + `(defun ,(intern (concat "lsp-" (symbol-name func-name))) () + ,(format "Perform the %s code action, if available." code-action-kind) + (interactive) + ;; Even when `lsp-auto-execute-action' is nil, it still makes sense to + ;; auto-execute here: the user has specified exactly what they want. + (let ((lsp-auto-execute-action t)) + (condition-case nil + (lsp-execute-code-action-by-kind ,code-action-kind) + (lsp-no-code-actions + (when (called-interactively-p 'any) + (lsp--info ,(format "%s action not available" code-action-kind)))))))) + +(lsp-make-interactive-code-action organize-imports "source.organizeImports") + +(defun lsp--make-document-range-formatting-params (start end) + "Make DocumentRangeFormattingParams for selected region." + (lsp:set-document-range-formatting-params-range (lsp--make-document-formatting-params) + (lsp--region-to-range start end))) + +(defconst lsp--highlight-kind-face + '((1 . lsp-face-highlight-textual) + (2 . lsp-face-highlight-read) + (3 . lsp-face-highlight-write))) + +(defun lsp--remove-overlays (name) + (save-restriction + (widen) + (remove-overlays (point-min) (point-max) name t))) + +(defun lsp-document-highlight () + "Highlight all relevant references to the symbol under point." + (interactive) + (lsp--remove-overlays 'lsp-highlight) ;; clear any previous highlights + (setq lsp--have-document-highlights nil + lsp--symbol-bounds-of-last-highlight-invocation nil) + (let ((lsp-enable-symbol-highlighting t)) + (lsp--document-highlight))) + +(defun lsp--document-highlight-callback (highlights) + "Create a callback to process the reply of a +`textDocument/documentHighlight' message for the buffer BUF. +A reference is highlighted only if it is visible in a window." + (lsp--remove-overlays 'lsp-highlight) + + (let* ((wins-visible-pos (-map (lambda (win) + (cons (1- (line-number-at-pos (window-start win) t)) + (1+ (line-number-at-pos (window-end win) t)))) + (get-buffer-window-list nil nil 'visible)))) + (setq lsp--have-document-highlights t) + (-map + (-lambda ((&DocumentHighlight :range (&Range :start (start &as &Position :line start-line) + :end (end &as &Position :line end-line)) + :kind?)) + (-map + (-lambda ((start-window . end-window)) + ;; Make the overlay only if the reference is visible + (let ((start-point (lsp--position-to-point start)) + (end-point (lsp--position-to-point end))) + (when (and (> (1+ start-line) start-window) + (< (1+ end-line) end-window) + (not (and lsp-symbol-highlighting-skip-current + (<= start-point (point) end-point)))) + (-doto (make-overlay start-point end-point) + (overlay-put 'face (cdr (assq (or kind? 1) lsp--highlight-kind-face))) + (overlay-put 'lsp-highlight t))))) + wins-visible-pos)) + highlights))) + +(defcustom lsp-symbol-kinds + '((1 . "File") + (2 . "Module") + (3 . "Namespace") + (4 . "Package") + (5 . "Class") + (6 . "Method") + (7 . "Property") + (8 . "Field") + (9 . "Constructor") + (10 . "Enum") + (11 . "Interface") + (12 . "Function") + (13 . "Variable") + (14 . "Constant") + (15 . "String") + (16 . "Number") + (17 . "Boolean") + (18 . "Array") + (19 . "Object") + (20 . "Key") + (21 . "Null") + (22 . "Enum Member") + (23 . "Struct") + (24 . "Event") + (25 . "Operator") + (26 . "Type Parameter")) + "Alist mapping SymbolKinds to human-readable strings. +Various Symbol objects in the LSP protocol have an integral type, +specifying what they are. This alist maps such type integrals to +readable representations of them. See +`https://microsoft.github.io/language-server-protocol/specifications/specification-current/', +namespace SymbolKind." + :group 'lsp-mode + :type '(alist :key-type integer :value-type string)) +(defalias 'lsp--symbol-kind 'lsp-symbol-kinds) + +(lsp-defun lsp--symbol-information-to-xref + ((&SymbolInformation :kind :name + :location (&Location :uri :range (&Range :start + (&Position :line :character))))) + "Return a `xref-item' from SYMBOL information." + (xref-make (format "[%s] %s" (alist-get kind lsp-symbol-kinds) name) + (xref-make-file-location (lsp--uri-to-path uri) + line + character))) + +(defun lsp--get-document-symbols () + "Get document symbols. + +If the buffer has not been modified since symbols were last +retrieved, simply return the latest result. + +Else, if the request was initiated by Imenu updating its menu-bar +entry, perform it asynchronously; i.e., give Imenu the latest +result and then force a refresh when a new one is available. + +Else (e.g., due to interactive use of `imenu' or `xref'), +perform the request synchronously." + (if (= (buffer-chars-modified-tick) lsp--document-symbols-tick) + lsp--document-symbols + (let ((method "textDocument/documentSymbol") + (params `(:textDocument ,(lsp--text-document-identifier))) + (tick (buffer-chars-modified-tick))) + (if (not lsp--document-symbols-request-async) + (prog1 + (setq lsp--document-symbols (lsp-request method params)) + (setq lsp--document-symbols-tick tick)) + (lsp-request-async method params + (lambda (document-symbols) + (setq lsp--document-symbols document-symbols + lsp--document-symbols-tick tick) + (lsp--imenu-refresh)) + :mode 'alive + :cancel-token :document-symbols) + lsp--document-symbols)))) + +(advice-add 'imenu-update-menubar :around + (lambda (oldfun &rest r) + (let ((lsp--document-symbols-request-async t)) + (apply oldfun r)))) + +(defun lsp--document-symbols->document-symbols-hierarchy (document-symbols current-position) + "Convert DOCUMENT-SYMBOLS to symbols hierarchy on CURRENT-POSITION." + (-let (((symbol &as &DocumentSymbol? :children?) + (seq-find (-lambda ((&DocumentSymbol :range)) + (lsp-point-in-range? current-position range)) + document-symbols))) + (if children? + (cons symbol (lsp--document-symbols->document-symbols-hierarchy children? current-position)) + (when symbol + (list symbol))))) + +(lsp-defun lsp--symbol-information->document-symbol ((&SymbolInformation :name :kind :location :container-name? :deprecated?)) + "Convert a SymbolInformation to a DocumentInformation" + (lsp-make-document-symbol :name name + :kind kind + :range (lsp:location-range location) + :children? nil + :deprecated? deprecated? + :selection-range (lsp:location-range location) + :detail? container-name?)) + +(defun lsp--symbols-informations->document-symbols-hierarchy (symbols-informations current-position) + "Convert SYMBOLS-INFORMATIONS to symbols hierarchy on CURRENT-POSITION." + (--> symbols-informations + (-keep (-lambda ((symbol &as &SymbolInformation :location (&Location :range))) + (when (lsp-point-in-range? current-position range) + (lsp--symbol-information->document-symbol symbol))) + it) + (sort it (-lambda ((&DocumentSymbol :range (&Range :start a-start-position :end a-end-position)) + (&DocumentSymbol :range (&Range :start b-start-position :end b-end-position))) + (and (lsp--position-compare b-start-position a-start-position) + (lsp--position-compare a-end-position b-end-position)))))) + +(defun lsp--symbols->document-symbols-hierarchy (symbols) + "Convert SYMBOLS to symbols-hierarchy." + (when-let ((first-symbol (lsp-seq-first symbols))) + (let ((cur-position (lsp-make-position :line (plist-get (lsp--cur-position) :line) + :character (plist-get (lsp--cur-position) :character)))) + (if (lsp-symbol-information? first-symbol) + (lsp--symbols-informations->document-symbols-hierarchy symbols cur-position) + (lsp--document-symbols->document-symbols-hierarchy symbols cur-position))))) + +(defun lsp--xref-backend () 'xref-lsp) + +(cl-defmethod xref-backend-identifier-at-point ((_backend (eql xref-lsp))) + (propertize (or (thing-at-point 'symbol) "") + 'identifier-at-point t)) + +(defun lsp--xref-elements-index (symbols path) + (-mapcat + (-lambda (sym) + (pcase-exhaustive sym + ((DocumentSymbol :name :children? :selection-range (Range :start)) + (cons (cons (concat path name) + (lsp--position-to-point start)) + (lsp--xref-elements-index children? (concat path name " / ")))) + ((SymbolInformation :name :location (Location :range (Range :start))) + (list (cons (concat path name) + (lsp--position-to-point start)))))) + symbols)) + +(defvar-local lsp--symbols-cache nil) + +(cl-defmethod xref-backend-identifier-completion-table ((_backend (eql xref-lsp))) + (if (lsp--find-workspaces-for "textDocument/documentSymbol") + (progn + (setq lsp--symbols-cache (lsp--xref-elements-index + (lsp--get-document-symbols) nil)) + lsp--symbols-cache) + (list (propertize (or (thing-at-point 'symbol) "") + 'identifier-at-point t)))) + +(cl-defmethod xref-backend-definitions ((_backend (eql xref-lsp)) identifier) + (save-excursion + (unless (get-text-property 0 'identifier-at-point identifier) + (goto-char (cl-rest (or (assoc identifier lsp--symbols-cache) + (user-error "Unable to find symbol %s in current document" identifier))))) + (lsp--locations-to-xref-items (lsp-request "textDocument/definition" + (lsp--text-document-position-params))))) + +(cl-defmethod xref-backend-references ((_backend (eql xref-lsp)) identifier) + (save-excursion + (unless (get-text-property 0 'identifier-at-point identifier) + (goto-char (cl-rest (or (assoc identifier lsp--symbols-cache) + (user-error "Unable to find symbol %s" identifier))))) + (lsp--locations-to-xref-items (lsp-request "textDocument/references" + (lsp--make-reference-params nil lsp-references-exclude-definition))))) + +(cl-defmethod xref-backend-apropos ((_backend (eql xref-lsp)) pattern) + (seq-map #'lsp--symbol-information-to-xref + (lsp-request "workspace/symbol" `(:query ,pattern)))) + +(defcustom lsp-rename-use-prepare t + "Whether `lsp-rename' should do a prepareRename first. +For some language servers, textDocument/prepareRename might be +too slow, in which case this variable may be set to nil. +`lsp-rename' will then use `thing-at-point' `symbol' to determine +the symbol to rename at point." + :group 'lsp-mode + :type 'boolean) + +(defun lsp--get-symbol-to-rename () + "Get a symbol to rename and placeholder at point. +Returns a cons ((START . END) . PLACEHOLDER?), and nil if +renaming is generally supported but cannot be done at point. +START and END are the bounds of the identifiers being renamed, +while PLACEHOLDER?, is either nil or a string suggested by the +language server as the initial input of a new-name prompt." + (unless (lsp-feature? "textDocument/rename") + (error "The connected server(s) doesn't support renaming")) + (if (and lsp-rename-use-prepare (lsp-feature? "textDocument/prepareRename")) + (when-let ((response + (lsp-request "textDocument/prepareRename" + (lsp--text-document-position-params)))) + (let* ((bounds (lsp--range-to-region + (if (lsp-range? response) + response + (lsp:prepare-rename-result-range response)))) + (placeholder + (and (not (lsp-range? response)) + (lsp:prepare-rename-result-placeholder response)))) + (cons bounds placeholder))) + (when-let ((bounds (bounds-of-thing-at-point 'symbol))) + (cons bounds nil)))) + +(defface lsp-face-rename '((t :underline t)) + "Face used to highlight the identifier being renamed. +Renaming can be done using `lsp-rename'." + :group 'lsp-mode) + +(defface lsp-rename-placeholder-face '((t :inherit font-lock-variable-name-face)) + "Face used to display the rename placeholder in. +When calling `lsp-rename' interactively, this will be the face of +the new name." + :group 'lsp-mode) + +(defvar lsp-rename-history '() + "History for `lsp--read-rename'.") + +(defun lsp--read-rename (at-point) + "Read a new name for a `lsp-rename' at `point' from the user. +AT-POINT shall be a structure as returned by +`lsp--get-symbol-to-rename'. + +Returns a string, which should be the new name for the identifier +at point. If renaming cannot be done at point (as determined from +AT-POINT), throw a `user-error'. + +This function is for use in `lsp-rename' only, and shall not be +relied upon." + (unless at-point + (user-error "`lsp-rename' is invalid here")) + (-let* ((((start . end) . placeholder?) at-point) + ;; Do the `buffer-substring' first to not include `lsp-face-rename' + (rename-me (buffer-substring start end)) + (placeholder (or placeholder? rename-me)) + (placeholder (propertize placeholder 'face 'lsp-rename-placeholder-face)) + + overlay) + ;; We need unwind protect, as the user might cancel here, causing the + ;; overlay to linger. + (unwind-protect + (progn + (setq overlay (make-overlay start end)) + (overlay-put overlay 'face 'lsp-face-rename) + + (read-string (format "Rename %s to: " rename-me) placeholder + 'lsp-rename-history)) + (and overlay (delete-overlay overlay))))) + +(defun lsp-rename (newname) + "Rename the symbol (and all references to it) under point to NEWNAME." + (interactive (list (lsp--read-rename (lsp--get-symbol-to-rename)))) + (when-let ((edits (lsp-request "textDocument/rename" + `( :textDocument ,(lsp--text-document-identifier) + :position ,(lsp--cur-position) + :newName ,newname)))) + (lsp--apply-workspace-edit edits 'rename))) + +(defun lsp--on-rename-file (old-func old-name new-name &optional ok-if-already-exists?) + "Advice around function `rename-file'. +Applies OLD-FUNC with OLD-NAME, NEW-NAME and OK-IF-ALREADY-EXISTS?. + +This advice sends workspace/willRenameFiles before renaming file +to check if server wants to apply any workspaceEdits after renamed." + (if (and lsp-apply-edits-after-file-operations + (lsp--send-will-rename-files-p old-name)) + (let ((params (lsp-make-rename-files-params + :files (vector (lsp-make-file-rename + :oldUri (lsp--path-to-uri old-name) + :newUri (lsp--path-to-uri new-name)))))) + (when-let ((edits (lsp-request "workspace/willRenameFiles" params))) + (lsp--apply-workspace-edit edits 'rename-file) + (funcall old-func old-name new-name ok-if-already-exists?) + (when (lsp--send-did-rename-files-p) + (lsp-notify "workspace/didRenameFiles" params)))) + (funcall old-func old-name new-name ok-if-already-exists?))) + +(advice-add 'rename-file :around #'lsp--on-rename-file) + +(defcustom lsp-xref-force-references nil + "If non-nil threat everything as references(e. g. jump if only one item.)" + :group 'lsp-mode + :type 'boolean) + +(defun lsp-show-xrefs (xrefs display-action references?) + (unless (region-active-p) (push-mark nil t)) + (if (boundp 'xref-show-definitions-function) + (with-no-warnings + (xref-push-marker-stack) + (funcall (if (and references? (not lsp-xref-force-references)) + xref-show-xrefs-function + xref-show-definitions-function) + (-const xrefs) + `((window . ,(selected-window)) + (display-action . ,display-action) + ,(if (and references? (not lsp-xref-force-references)) + `(auto-jump . ,xref-auto-jump-to-first-xref) + `(auto-jump . ,xref-auto-jump-to-first-definition))))) + (xref--show-xrefs xrefs display-action))) + +(cl-defmethod seq-empty-p ((ht hash-table)) + "Function `seq-empty-p' for hash-table." + (hash-table-empty-p ht)) + +(cl-defun lsp-find-locations (method &optional extra &key display-action references?) + "Send request named METHOD and get cross references of the symbol under point. +EXTRA is a plist of extra parameters. +REFERENCES? t when METHOD returns references." + (let ((loc (lsp-request method + (append (lsp--text-document-position-params) extra)))) + (if (seq-empty-p loc) + (lsp--error "Not found for: %s" (or (thing-at-point 'symbol t) "")) + (lsp-show-xrefs (lsp--locations-to-xref-items loc) display-action references?)))) + +(cl-defun lsp-find-declaration (&key display-action) + "Find declarations of the symbol under point." + (interactive) + (lsp-find-locations "textDocument/declaration" nil :display-action display-action)) + +(cl-defun lsp-find-definition (&key display-action) + "Find definitions of the symbol under point." + (interactive) + (lsp-find-locations "textDocument/definition" nil :display-action display-action)) + +(defun lsp-find-definition-mouse (click) + "Click to start `lsp-find-definition' at clicked point." + (interactive "e") + (let* ((ec (event-start click)) + (p1 (posn-point ec)) + (w1 (posn-window ec))) + (select-window w1) + (goto-char p1) + (lsp-find-definition))) + +(cl-defun lsp-find-implementation (&key display-action) + "Find implementations of the symbol under point." + (interactive) + (lsp-find-locations "textDocument/implementation" + nil + :display-action display-action + :references? t)) + +(cl-defun lsp-find-references (&optional exclude-declaration &key display-action) + "Find references of the symbol under point." + (interactive "P") + (lsp-find-locations "textDocument/references" + (list :context `(:includeDeclaration ,(lsp-json-bool (not (or exclude-declaration lsp-references-exclude-definition))))) + :display-action display-action + :references? t)) + +(cl-defun lsp-find-type-definition (&key display-action) + "Find type definitions of the symbol under point." + (interactive) + (lsp-find-locations "textDocument/typeDefinition" nil :display-action display-action)) + +(defalias 'lsp-find-custom #'lsp-find-locations) +(defalias 'lsp-goto-implementation #'lsp-find-implementation) +(defalias 'lsp-goto-type-definition #'lsp-find-type-definition) + +(with-eval-after-load 'evil + (evil-set-command-property 'lsp-find-definition :jump t) + (evil-set-command-property 'lsp-find-implementation :jump t) + (evil-set-command-property 'lsp-find-references :jump t) + (evil-set-command-property 'lsp-find-type-definition :jump t)) + +(defun lsp--workspace-method-supported? (check-command method capability workspace) + (with-lsp-workspace workspace + (if check-command + (funcall check-command workspace) + (or + (when capability (lsp--capability capability)) + (lsp--registered-capability method) + (and (not capability) (not check-command)))))) + +(defun lsp-disable-method-for-server (method server-id) + "Disable METHOD for SERVER-ID." + (cl-callf + (lambda (reqs) + (-let (((&plist :check-command :capability) reqs)) + (list :check-command + (lambda (workspace) + (unless (-> workspace + lsp--workspace-client + lsp--client-server-id + (eq server-id)) + (lsp--workspace-method-supported? check-command + method + capability + workspace)))))) + (alist-get method lsp-method-requirements nil nil 'string=))) + +(defun lsp--find-workspaces-for (msg-or-method) + "Find all workspaces in the current project that can handle MSG." + (let ((method (if (stringp msg-or-method) + msg-or-method + (plist-get msg-or-method :method)))) + (-if-let (reqs (cdr (assoc method lsp-method-requirements))) + (-let (((&plist :capability :check-command) reqs)) + (-filter + (-partial #'lsp--workspace-method-supported? + check-command method capability) + (lsp-workspaces))) + (lsp-workspaces)))) + +(defun lsp-can-execute-command? (command-name) + "Returns non-nil if current language server(s) can execute COMMAND-NAME. +The command is executed via `workspace/executeCommand'" + (cl-position + command-name + (lsp:execute-command-options-commands + (lsp:server-capabilities-execute-command-provider? + (lsp--server-capabilities))) + :test #'equal)) + +(defalias 'lsp-feature? 'lsp--find-workspaces-for) + +(cl-defmethod lsp-execute-command (_server _command _arguments) + "Dispatch COMMAND execution." + (signal 'cl-no-applicable-method nil)) + +(defun lsp-workspace-command-execute (command &optional args) + "Execute workspace COMMAND with ARGS." + (condition-case-unless-debug err + (let ((params (if args + (list :command command :arguments args) + (list :command command)))) + (lsp-request "workspace/executeCommand" params)) + (error + (error "`workspace/executeCommand' with `%s' failed.\n\n%S" + command err)))) + +(defun lsp-send-execute-command (command &optional args) + "Create and send a `workspace/executeCommand' message having command COMMAND +and optional ARGS." + (lsp-workspace-command-execute command args)) + +(defalias 'lsp-point-to-position #'lsp--point-to-position) +(defalias 'lsp-text-document-identifier #'lsp--text-document-identifier) +(defalias 'lsp--send-execute-command #'lsp-send-execute-command) +(defalias 'lsp-on-open #'lsp--text-document-did-open) +(defalias 'lsp-on-save #'lsp--text-document-did-save) + +(defun lsp--set-configuration (settings) + "Set the SETTINGS for the lsp server." + (lsp-notify "workspace/didChangeConfiguration" `(:settings ,settings))) + +(defun lsp-current-buffer () + (or lsp--virtual-buffer + (current-buffer))) + +(defun lsp-buffer-live-p (buffer-id) + (if-let ((buffer-live (plist-get buffer-id :buffer-live?))) + (funcall buffer-live buffer-id) + (buffer-live-p buffer-id))) + +(defun lsp--on-set-visited-file-name (old-func &rest args) + "Advice around function `set-visited-file-name'. + +This advice sends textDocument/didClose for the old file and +textDocument/didOpen for the new file." + (when lsp--cur-workspace + (lsp--text-document-did-close t)) + (prog1 (apply old-func args) + (when lsp--cur-workspace + (lsp--text-document-did-open)))) + +(advice-add 'set-visited-file-name :around #'lsp--on-set-visited-file-name) + +(defvar lsp--flushing-delayed-changes nil) + +(defun lsp--send-no-wait (message proc) + "Send MESSAGE to PROC without waiting for further output." + + (unless lsp--flushing-delayed-changes + (let ((lsp--flushing-delayed-changes t)) + (lsp--flush-delayed-changes))) + (lsp-process-send proc message)) + +(define-error 'lsp-parse-error + "Error parsing message from language server" 'lsp-error) +(define-error 'lsp-unknown-message-type + "Unknown message type" '(lsp-error lsp-parse-error)) +(define-error 'lsp-unknown-json-rpc-version + "Unknown JSON-RPC protocol version" '(lsp-error lsp-parse-error)) +(define-error 'lsp-no-content-length + "Content-Length header missing in message" '(lsp-error lsp-parse-error)) +(define-error 'lsp-invalid-header-name + "Invalid header name" '(lsp-error lsp-parse-error)) + +;; id method +;; x x request +;; x . response +;; . x notification +(defun lsp--get-message-type (json-data) + "Get the message type from JSON-DATA." + (if (lsp:json-message-id? json-data) + (if (lsp:json-message-error? json-data) + 'response-error + (if (lsp:json-message-method? json-data) + 'request + 'response)) + 'notification)) + +(defconst lsp--default-notification-handlers + (ht ("window/showMessage" #'lsp--window-show-message) + ("window/logMessage" #'lsp--window-log-message) + ("window/showInputBox" #'lsp--window-show-input-box) + ("window/showQuickPick" #'lsp--window-show-quick-pick) + ("textDocument/publishDiagnostics" #'lsp--on-diagnostics) + ("textDocument/diagnosticsEnd" #'ignore) + ("textDocument/diagnosticsBegin" #'ignore) + ("telemetry/event" #'ignore) + ("$/progress" (lambda (workspace params) + (funcall lsp-progress-function workspace params))))) + +(lsp-defun lsp--on-notification (workspace (&JSONNotification :params :method)) + "Call the appropriate handler for NOTIFICATION." + (-let ((client (lsp--workspace-client workspace))) + (when (lsp--log-io-p method) + (lsp--log-entry-new (lsp--make-log-entry method nil params 'incoming-notif) + lsp--cur-workspace)) + (if-let ((handler (or (gethash method (lsp--client-notification-handlers client)) + (gethash method lsp--default-notification-handlers)))) + (funcall handler workspace params) + (when (and method (not (string-prefix-p "$" method))) + (lsp-warn "Unknown notification: %s" method))))) + +(lsp-defun lsp--build-workspace-configuration-response ((&ConfigurationParams :items)) + "Get section configuration. +PARAMS are the `workspace/configuration' request params" + (->> items + (-map (-lambda ((&ConfigurationItem :section?)) + (-let* ((path-parts (split-string section? "\\.")) + (path-without-last (s-join "." (-slice path-parts 0 -1))) + (path-parts-len (length path-parts))) + (cond + ((<= path-parts-len 1) + (ht-get (lsp-configuration-section section?) + (car-safe path-parts) + (ht-create))) + ((> path-parts-len 1) + (when-let ((section (lsp-configuration-section path-without-last)) + (keys path-parts)) + (while (and keys section) + (setf section (ht-get section (pop keys)))) + section)))))) + (apply #'vector))) + +(defun lsp--ms-since (timestamp) + "Integer number of milliseconds since TIMESTAMP. Fractions discarded." + (floor (* 1000 (float-time (time-since timestamp))))) + +(defun lsp--send-request-response (workspace recv-time request response) + "Send the RESPONSE for REQUEST in WORKSPACE and log if needed." + (-let* (((&JSONResponse :params :method :id) request) + (process (lsp--workspace-proc workspace)) + (response (lsp--make-response id response)) + (req-entry (and lsp-log-io + (lsp--make-log-entry method id params 'incoming-req))) + (resp-entry (and lsp-log-io + (lsp--make-log-entry method id response 'outgoing-resp + (lsp--ms-since recv-time))))) + ;; Send response to the server. + (when (lsp--log-io-p method) + (lsp--log-entry-new req-entry workspace) + (lsp--log-entry-new resp-entry workspace)) + (lsp--send-no-wait response process))) + +(lsp-defun lsp--on-request (workspace (request &as &JSONRequest :params :method)) + "Call the appropriate handler for REQUEST, and send the return value to the +server. WORKSPACE is the active workspace." + (-let* ((recv-time (current-time)) + (client (lsp--workspace-client workspace)) + (buffers (lsp--workspace-buffers workspace)) + handler + (response (cond + ((setq handler (gethash method (lsp--client-request-handlers client) nil)) + (funcall handler workspace params)) + ((setq handler (gethash method (lsp--client-async-request-handlers client) nil)) + (funcall handler workspace params + (-partial #'lsp--send-request-response + workspace recv-time request)) + 'delay-response) + ((equal method "client/registerCapability") + (mapc #'lsp--server-register-capability + (lsp:registration-params-registrations params)) + (mapc (lambda (buf) + (when (lsp-buffer-live-p buf) + (lsp-with-current-buffer buf + (lsp-unconfig-buffer) + (lsp-configure-buffer)))) + buffers) + nil) + ((equal method "window/showMessageRequest") + (let ((choice (lsp--window-log-message-request params))) + `(:title ,choice))) + ((equal method "window/showDocument") + (let ((success? (lsp--window-show-document params))) + (lsp-make-show-document-result :success (or success? + :json-false)))) + ((equal method "client/unregisterCapability") + (mapc #'lsp--server-unregister-capability + (lsp:unregistration-params-unregisterations params)) + (mapc (lambda (buf) + (when (lsp-buffer-live-p buf) + (lsp-with-current-buffer buf + (lsp-unconfig-buffer) + (lsp-configure-buffer)))) + buffers) + nil) + ((equal method "workspace/applyEdit") + (list :applied (condition-case err + (prog1 t + (lsp--apply-workspace-edit (lsp:apply-workspace-edit-params-edit params) 'server-requested)) + (error + (lsp--error "Failed to apply edits with message %s" + (error-message-string err)) + :json-false)))) + ((equal method "workspace/configuration") + (with-lsp-workspace workspace + (if-let ((buf (car buffers))) + (lsp-with-current-buffer buf + (lsp--build-workspace-configuration-response params)) + (lsp--with-workspace-temp-buffer (lsp--workspace-root workspace) + (lsp--build-workspace-configuration-response params))))) + ((equal method "workspace/workspaceFolders") + (let ((folders (or (-> workspace + (lsp--workspace-client) + (lsp--client-server-id) + (gethash (lsp-session-server-id->folders (lsp-session)))) + (lsp-session-folders (lsp-session))))) + (->> folders + (-distinct) + (-map (lambda (folder) + (list :uri (lsp--path-to-uri folder)))) + (apply #'vector)))) + ((equal method "window/workDoneProgress/create") + nil ;; no specific reply, no processing required + ) + ((equal method "workspace/semanticTokens/refresh") + (when (and lsp-semantic-tokens-enable + (fboundp 'lsp--semantic-tokens-on-refresh)) + (lsp--semantic-tokens-on-refresh workspace)) + nil) + ((equal method "workspace/codeLens/refresh") + (when (and lsp-lens-enable + (fboundp 'lsp--lens-on-refresh)) + (lsp--lens-on-refresh workspace)) + nil) + (t (lsp-warn "Unknown request method: %s" method) nil)))) + ;; Send response to the server. + (unless (eq response 'delay-response) + (lsp--send-request-response workspace recv-time request response)))) + +(lsp-defun lsp--error-string ((&JSONError :message :code)) + "Format ERR as a user friendly string." + (format "Error from the Language Server: %s (%s)" + message + (or (car (alist-get code lsp--errors)) "Unknown error"))) + +(defun lsp--get-body-length (headers) + (let ((content-length (cdr (assoc "Content-Length" headers)))) + (if content-length + (string-to-number content-length) + + ;; This usually means either the server or our parser is + ;; screwed up with a previous Content-Length + (error "No Content-Length header")))) + +(defun lsp--parse-header (s) + "Parse string S as a LSP (KEY . VAL) header." + (let ((pos (string-match "\:" s)) + key val) + (unless pos + (signal 'lsp-invalid-header-name (list s))) + (setq key (substring s 0 pos) + val (s-trim-left (substring s (+ 1 pos)))) + (when (equal key "Content-Length") + (cl-assert (cl-loop for c across val + when (or (> c ?9) (< c ?0)) return nil + finally return t) + nil (format "Invalid Content-Length value: %s" val))) + (cons key val))) + +(defmacro lsp--read-json (str) + "Read json string STR." + (if (progn + (require 'json) + (fboundp 'json-parse-string)) + `(json-parse-string ,str + :object-type (if lsp-use-plists + 'plist + 'hash-table) + :null-object nil + :false-object nil) + `(let ((json-array-type 'vector) + (json-object-type (if lsp-use-plists + 'plist + 'hash-table)) + (json-false nil)) + (json-read-from-string ,str)))) + +(defmacro lsp-json-read-buffer () + "Read json from the current buffer." + (if (progn + (require 'json) + (fboundp 'json-parse-buffer)) + `(json-parse-buffer :object-type (if lsp-use-plists + 'plist + 'hash-table) + :null-object nil + :false-object nil) + `(let ((json-array-type 'vector) + (json-object-type (if lsp-use-plists + 'plist + 'hash-table)) + (json-false nil)) + (json-read)))) + +(defun lsp--read-json-file (file-path) + "Read json file." + (-> file-path + (f-read-text) + (lsp--read-json))) + +(defun lsp--parser-on-message (json-data workspace) + "Called when the parser P read a complete MSG from the server." + (with-demoted-errors "Error processing message %S." + (with-lsp-workspace workspace + (let* ((client (lsp--workspace-client workspace)) + (id (--when-let (lsp:json-response-id json-data) + (if (stringp it) (string-to-number it) it))) + (data (lsp:json-response-result json-data))) + (pcase (lsp--get-message-type json-data) + ('response + (cl-assert id) + (-let [(callback _ method _ before-send) (gethash id (lsp--client-response-handlers client))] + (when (lsp--log-io-p method) + (lsp--log-entry-new + (lsp--make-log-entry method id data 'incoming-resp + (lsp--ms-since before-send)) + workspace)) + (when callback + (remhash id (lsp--client-response-handlers client)) + (funcall callback (lsp:json-response-result json-data))))) + ('response-error + (cl-assert id) + (-let [(_ callback method _ before-send) (gethash id (lsp--client-response-handlers client))] + (when (lsp--log-io-p method) + (lsp--log-entry-new + (lsp--make-log-entry method id (lsp:json-response-error-error json-data) + 'incoming-resp (lsp--ms-since before-send)) + workspace)) + (when callback + (remhash id (lsp--client-response-handlers client)) + (funcall callback (lsp:json-response-error-error json-data))))) + ('notification + (lsp--on-notification workspace json-data)) + ('request (lsp--on-request workspace json-data))))))) + +(defun lsp--create-filter-function (workspace) + "Make filter for the workspace." + (let ((body-received 0) + leftovers body-length body chunk) + (lambda (_proc input) + (setf chunk (if (s-blank? leftovers) + input + (concat leftovers input))) + + (let (messages) + (while (not (s-blank? chunk)) + (if (not body-length) + ;; Read headers + (if-let ((body-sep-pos (string-match-p "\r\n\r\n" chunk))) + ;; We've got all the headers, handle them all at once: + (setf body-length (lsp--get-body-length + (mapcar #'lsp--parse-header + (split-string + (substring-no-properties chunk + (or (string-match-p "Content-Length" chunk) + (error "Unable to find Content-Length header.")) + body-sep-pos) + "\r\n"))) + body-received 0 + leftovers nil + chunk (substring-no-properties chunk (+ body-sep-pos 4))) + + ;; Haven't found the end of the headers yet. Save everything + ;; for when the next chunk arrives and await further input. + (setf leftovers chunk + chunk nil)) + (let* ((chunk-length (string-bytes chunk)) + (left-to-receive (- body-length body-received)) + (this-body (if (< left-to-receive chunk-length) + (prog1 (substring-no-properties chunk 0 left-to-receive) + (setf chunk (substring-no-properties chunk left-to-receive))) + (prog1 chunk + (setf chunk nil)))) + (body-bytes (string-bytes this-body))) + (push this-body body) + (setf body-received (+ body-received body-bytes)) + (when (>= chunk-length left-to-receive) + (condition-case err + (with-temp-buffer + (apply #'insert + (nreverse + (prog1 body + (setf leftovers nil + body-length nil + body-received nil + body nil)))) + (decode-coding-region (point-min) + (point-max) + 'utf-8) + (goto-char (point-min)) + (push (lsp-json-read-buffer) messages)) + + (error + (lsp-warn "Failed to parse the following chunk:\n'''\n%s\n'''\nwith message %s" + (concat leftovers input) + err))))))) + (mapc (lambda (msg) + (lsp--parser-on-message msg workspace)) + (nreverse messages)))))) + +(defvar-local lsp--line-col-to-point-hash-table nil + "Hash table with keys (line . col) and values that are either point positions +or markers.") + +(defcustom lsp-imenu-detailed-outline t + "Whether `lsp-imenu' should include signatures. +This will be ignored if the server doesn't provide the necessary +information, for example if it doesn't support DocumentSymbols." + :group 'lsp-imenu + :type 'boolean) + +(defcustom lsp-imenu-hide-parent-details t + "Whether `lsp-imenu' should hide signatures of parent nodes." + :group 'lsp-imenu + :type 'boolean) + +(defface lsp-details-face '((t :height 0.8 :inherit shadow)) + "Used to display additional information throughout `lsp'. +Things like line numbers, signatures, ... are considered +additional information. Often, additional faces are defined that +inherit from this face by default, like `lsp-signature-face', and +they may be customized for finer control." + :group 'lsp-mode) + +(defface lsp-signature-face '((t :inherit lsp-details-face)) + "Used to display signatures in `imenu', ...." + :group 'lsp-mode) + +(lsp-defun lsp-render-symbol ((&DocumentSymbol :name :detail? :deprecated?) + show-detail?) + "Render INPUT0, an `&DocumentSymbol', to a string. +If SHOW-DETAIL? is set, make use of its `:detail?' field (often +the signature)." + (let ((detail (and show-detail? (s-present? detail?) + (propertize (concat " " (s-trim-left detail?)) + 'face 'lsp-signature-face))) + (name (if deprecated? + (propertize name 'face 'lsp-face-semhl-deprecated) name))) + (concat name detail))) + +(lsp-defun lsp-render-symbol-information ((&SymbolInformation :name :deprecated? :container-name?) + separator) + "Render a piece of SymbolInformation. +Handle :deprecated?. If SEPARATOR is non-nil, the +symbol's (optional) parent, SEPARATOR and the symbol itself are +concatenated." + (when (and separator container-name? (not (string-empty-p container-name?))) + (setq name (concat name separator container-name?))) + (if deprecated? (propertize name 'face 'lsp-face-semhl-deprecated) name)) + +(defun lsp--symbol-to-imenu-elem (sym) + "Convert SYM to imenu element. + +SYM is a SymbolInformation message. + +Return a cons cell (full-name . start-point)." + (let ((start-point (ht-get lsp--line-col-to-point-hash-table + (lsp--get-line-and-col sym)))) + (cons (lsp-render-symbol-information + sym (and lsp-imenu-show-container-name + lsp-imenu-container-name-separator)) + start-point))) + +(lsp-defun lsp--symbol-to-hierarchical-imenu-elem ((sym &as &DocumentSymbol :children?)) + "Convert SYM to hierarchical imenu elements. + +SYM is a DocumentSymbol message. + +Return cons cell (\"symbol-name (symbol-kind)\" . start-point) if +SYM doesn't have any children. Otherwise return a cons cell with +an alist + + (\"symbol-name\" . ((\"(symbol-kind)\" . start-point) + cons-cells-from-children))" + (let ((filtered-children (lsp--imenu-filter-symbols children?)) + (signature (lsp-render-symbol sym lsp-imenu-detailed-outline))) + (if (seq-empty-p filtered-children) + (cons signature + (ht-get lsp--line-col-to-point-hash-table + (lsp--get-line-and-col sym))) + (cons signature + (lsp--imenu-create-hierarchical-index filtered-children))))) + +(lsp-defun lsp--symbol-ignore ((&SymbolInformation :kind)) + "Determine if SYM is for the current document and is to be shown." + ;; It's a SymbolInformation or DocumentSymbol, which is always in the + ;; current buffer file. + (and lsp-imenu-index-symbol-kinds + (numberp kind) + (let ((clamped-kind (if (< 0 kind (length lsp/symbol-kind-lookup)) + kind + 0))) + (not (memql (aref lsp/symbol-kind-lookup clamped-kind) + lsp-imenu-index-symbol-kinds))))) + +(lsp-defun lsp--get-symbol-type ((&SymbolInformation :kind)) + "The string name of the kind of SYM." + (alist-get kind lsp-symbol-kinds "Other")) + +(defun lsp--get-line-and-col (sym) + "Obtain the line and column corresponding to SYM." + (-let* ((location (lsp:symbol-information-location sym)) + (name-range (or (and location (lsp:location-range location)) + (lsp:document-symbol-selection-range sym))) + ((&Range :start (&Position :line :character)) name-range)) + (cons line character))) + +(defun lsp--collect-lines-and-cols (symbols) + "Return a sorted list ((line . col) ...) of the locations of SYMBOLS." + (let ((stack (mapcar 'identity symbols)) + line-col-list) + (while stack + (let ((sym (pop stack))) + (push (lsp--get-line-and-col sym) line-col-list) + (unless (seq-empty-p (lsp:document-symbol-children? sym)) + (setf stack (nconc (lsp--imenu-filter-symbols (lsp:document-symbol-children? sym)) stack))))) + (-sort #'lsp--line-col-comparator line-col-list))) + +(defun lsp--convert-line-col-to-points-batch (line-col-list) + "Convert a sorted list of positions from line-column +representation to point representation." + (let ((line-col-to-point-map (ht-create)) + (inhibit-field-text-motion t) + (curr-line 0)) + (lsp-save-restriction-and-excursion + (goto-char (point-min)) + (cl-loop for (line . col) in line-col-list do + (forward-line (- line curr-line)) + (setq curr-line line) + (let ((line-end (line-end-position))) + (if (or (not col) (> col (- line-end (point)))) + (goto-char line-end) + (forward-char col))) + (ht-set! line-col-to-point-map (cons line col) (if imenu-use-markers + (point-marker) + (point))))) + line-col-to-point-map)) + +(cl-defun lsp--line-col-comparator ((l1 . c1) (l2 . c2)) + (or (< l1 l2) + (and (= l1 l2) + (cond ((and c1 c2) + (< c1 c2)) + (c1 t))))) + +(defun lsp-imenu-create-uncategorized-index (symbols) + "Create imenu index from document SYMBOLS. +This function, unlike `lsp-imenu-create-categorized-index', does +not categorize by type, but instead returns an `imenu' index +corresponding to the symbol hierarchy returned by the server +directly." + (let* ((lsp--line-col-to-point-hash-table (-> symbols + lsp--collect-lines-and-cols + lsp--convert-line-col-to-points-batch))) + (if (lsp--imenu-hierarchical-p symbols) + (lsp--imenu-create-hierarchical-index symbols) + (lsp--imenu-create-non-hierarchical-index symbols)))) + +(defcustom lsp-imenu-symbol-kinds + '((1 . "Files") + (2 . "Modules") + (3 . "Namespaces") + (4 . "Packages") + (5 . "Classes") + (6 . "Methods") + (7 . "Properties") + (8 . "Fields") + (9 . "Constructors") + (10 . "Enums") + (11 . "Interfaces") + (12 . "Functions") + (13 . "Variables") + (14 . "Constants") + (15 . "Strings") + (16 . "Numbers") + (17 . "Booleans") + (18 . "Arrays") + (19 . "Objects") + (20 . "Keys") + (21 . "Nulls") + (22 . "Enum Members") + (23 . "Structs") + (24 . "Events") + (25 . "Operators") + (26 . "Type Parameters")) + "`lsp-symbol-kinds', but only used by `imenu'. +A new variable is needed, as it is `imenu' convention to use +pluralized categories, which `lsp-symbol-kinds' doesn't. If the +non-pluralized names are preferred, this can be set to +`lsp-symbol-kinds'." + :type '(alist :key-type integer :value-type string)) + +(defun lsp--imenu-kind->name (kind) + (alist-get kind lsp-imenu-symbol-kinds "?")) + +(defun lsp-imenu-create-top-level-categorized-index (symbols) + "Create an `imenu' index categorizing SYMBOLS by type. +Only root symbols are categorized. + +See `lsp-symbol-kinds' to customize the category naming. SYMBOLS +shall be a list of DocumentSymbols or SymbolInformation." + (mapcan + (-lambda ((type . symbols)) + (let ((cat (lsp--imenu-kind->name type)) + (symbols (lsp-imenu-create-uncategorized-index symbols))) + ;; If there is no :kind (this is being defensive), or we couldn't look it + ;; up, just display the symbols inline, without categories. + (if cat (list (cons cat symbols)) symbols))) + (sort (seq-group-by #'lsp:document-symbol-kind symbols) + (-lambda ((kinda) (kindb)) (< kinda kindb))))) + +(lsp-defun lsp--symbol->imenu ((sym &as &DocumentSymbol :selection-range (&RangeToPoint :start))) + "Convert an `&DocumentSymbol' to an `imenu' entry." + (cons (lsp-render-symbol sym lsp-imenu-detailed-outline) start)) + +(defun lsp--imenu-create-categorized-index-1 (symbols) + "Returns an `imenu' index from SYMBOLS categorized by type. +The result looks like this: ((\"Variables\" . (...)))." + (->> + symbols + (mapcan + (-lambda ((sym &as &DocumentSymbol :kind :children?)) + (if (seq-empty-p children?) + (list (list kind (lsp--symbol->imenu sym))) + (let ((parent (lsp-render-symbol sym (and lsp-imenu-detailed-outline + (not lsp-imenu-hide-parent-details))))) + (cons + (list kind (lsp--symbol->imenu sym)) + (mapcar (-lambda ((type . imenu-items)) + (list type (cons parent (mapcan #'cdr imenu-items)))) + (-group-by #'car (lsp--imenu-create-categorized-index-1 children?)))))))) + (-group-by #'car) + (mapcar + (-lambda ((kind . syms)) + (cons kind (mapcan #'cdr syms)))))) + +(defun lsp--imenu-create-categorized-index (symbols) + (let ((syms (lsp--imenu-create-categorized-index-1 symbols))) + (dolist (sym syms) + (setcar sym (lsp--imenu-kind->name (car sym)))) + syms)) + +(lsp-defun lsp--symbol-information->imenu ((sym &as &SymbolInformation :location (&Location :range (&RangeToPoint :start)))) + (cons (lsp-render-symbol-information sym nil) start)) + +(defun lsp--imenu-create-categorized-index-flat (symbols) + "Create a kind-categorized index for SymbolInformation." + (mapcar (-lambda ((kind . syms)) + (cons (lsp--imenu-kind->name kind) + (mapcan (-lambda ((parent . children)) + (let ((children (mapcar #'lsp--symbol-information->imenu children))) + (if parent (list (cons parent children)) children))) + (-group-by #'lsp:symbol-information-container-name? syms)))) + (seq-group-by #'lsp:symbol-information-kind symbols))) + +(defun lsp-imenu-create-categorized-index (symbols) + (if (lsp--imenu-hierarchical-p symbols) + (lsp--imenu-create-categorized-index symbols) + (lsp--imenu-create-categorized-index-flat symbols))) + +(defcustom lsp-imenu-index-function #'lsp-imenu-create-uncategorized-index + "Function that should create an `imenu' index. +It will be called with a list of SymbolInformation or +DocumentSymbols, whose first level is already filtered. It shall +then return an appropriate `imenu' index (see +`imenu-create-index-function'). + +Note that this interface is not stable, and subject to change any +time." + :group 'lsp-imenu + :type '(radio + (const :tag "Categorize by type" + lsp-imenu-create-categorized-index) + (const :tag "Categorize root symbols by type" + lsp-imenu-create-top-level-categorized-index) + (const :tag "Uncategorized, inline entries" + lsp-imenu-create-uncategorized-index) + (function :tag "Custom function"))) + +(defun lsp--imenu-create-index () + "Create an `imenu' index based on the language server. +Respects `lsp-imenu-index-function'." + (let ((symbols (lsp--imenu-filter-symbols (lsp--get-document-symbols)))) + (funcall lsp-imenu-index-function symbols))) + +(defun lsp--imenu-filter-symbols (symbols) + "Filter out unsupported symbols from SYMBOLS." + (seq-remove #'lsp--symbol-ignore symbols)) + +(defun lsp--imenu-hierarchical-p (symbols) + "Determine whether any element in SYMBOLS has children." + (seq-some #'lsp-document-symbol? symbols)) + +(defun lsp--imenu-create-non-hierarchical-index (symbols) + "Create imenu index for non-hierarchical SYMBOLS. + +SYMBOLS are a list of DocumentSymbol messages. + +Return a nested alist keyed by symbol names. e.g. + + ((\"SomeClass\" (\"(Class)\" . 10) + (\"someField (Field)\" . 20) + (\"someFunction (Function)\" . 25) + (\"SomeSubClass\" (\"(Class)\" . 30) + (\"someSubField (Field)\" . 35)) + (\"someFunction (Function)\" . 40))" + (seq-map (lambda (nested-alist) + (cons (car nested-alist) + (seq-map #'lsp--symbol-to-imenu-elem (cdr nested-alist)))) + (seq-group-by #'lsp--get-symbol-type symbols))) + +(defun lsp--imenu-create-hierarchical-index (symbols) + "Create imenu index for hierarchical SYMBOLS. + +SYMBOLS are a list of DocumentSymbol messages. + +Return a nested alist keyed by symbol names. e.g. + + ((\"SomeClass\" (\"(Class)\" . 10) + (\"someField (Field)\" . 20) + (\"someFunction (Function)\" . 25) + (\"SomeSubClass\" (\"(Class)\" . 30) + (\"someSubField (Field)\" . 35)) + (\"someFunction (Function)\" . 40))" + (seq-map #'lsp--symbol-to-hierarchical-imenu-elem + (seq-sort #'lsp--imenu-symbol-lessp symbols))) + +(defun lsp--imenu-symbol-lessp (sym1 sym2) + (let* ((compare-results (mapcar (lambda (method) + (funcall (alist-get method lsp--imenu-compare-function-alist) + sym1 sym2)) + lsp-imenu-sort-methods)) + (result (seq-find (lambda (result) + (not (= result 0))) + compare-results + 0))) + (and (numberp result) (< result 0)))) + +(lsp-defun lsp--imenu-compare-kind ((&SymbolInformation :kind left) + (&SymbolInformation :kind right)) + "Compare SYM1 and SYM2 by kind." + (- left right)) + +(defun lsp--imenu-compare-line-col (sym1 sym2) + (if (lsp--line-col-comparator + (lsp--get-line-and-col sym1) + (lsp--get-line-and-col sym2)) + -1 + 1)) + +(lsp-defun lsp--imenu-compare-name ((&SymbolInformation :name name1) + (&SymbolInformation :name name2)) + "Compare SYM1 and SYM2 by name." + (let ((result (compare-strings name1 0 (length name1) name2 0 (length name2)))) + (if (numberp result) result 0))) + +(defun lsp--imenu-refresh () + "Force Imenu to refresh itself." + (imenu--menubar-select imenu--rescan-item)) + +(defun lsp-enable-imenu () + "Use lsp-imenu for the current buffer." + (imenu--cleanup) + (add-function :override (local 'imenu-create-index-function) #'lsp--imenu-create-index) + (setq-local imenu-menubar-modified-tick -1) + (setq-local imenu--index-alist nil) + (when menu-bar-mode + (lsp--imenu-refresh))) + +(defun lsp-resolve-final-command (command &optional test?) + "Resolve final function COMMAND." + (let* ((command (lsp-resolve-value command)) + (command (cl-etypecase command + (list + (cl-assert (seq-every-p (apply-partially #'stringp) command) nil + "Invalid command list") + command) + (string (list command))))) + (if (and (file-remote-p default-directory) (not test?)) + (list shell-file-name "-c" + (string-join (cons "stty raw > /dev/null;" + (mapcar #'shell-quote-argument command)) + " ")) + command))) + +(defun lsp-server-present? (final-command) + "Check whether FINAL-COMMAND is present." + (let ((binary-found? (executable-find (cl-first final-command) t))) + (if binary-found? + (lsp-log "Command \"%s\" is present on the path." (s-join " " final-command)) + (lsp-log "Command \"%s\" is not present on the path." (s-join " " final-command))) + binary-found?)) + +(defun lsp--value-to-string (value) + "Convert VALUE to a string that can be set as value in an environment +variable." + (cond + ((stringp value) value) + ((booleanp value) (if value + "1" + "0")) + ((and (sequencep value) + (seq-every-p #'stringp value)) (string-join value ":")) + (t (user-error "Only strings, booleans, and sequences of strings are supported as environment variables")))) + +(defun lsp--compute-process-environment (environment-fn) + "Append a list of KEY=VALUE from the alist ENVIRONMENT to `process-environment'. +Ignore non-boolean keys whose value is nil." + (let ((environment (if environment-fn + (funcall environment-fn) + nil))) + (-flatten (cons (cl-loop for (key . value) in environment + if (or (eval value) + (eq (get value 'custom-type) 'boolean)) + collect (concat key "=" (lsp--value-to-string + (eval value)))) + process-environment)))) + +(defun lsp--default-directory-for-connection (&optional path) + "Return path to be used for the working directory of a LSP process. + +If `lsp-use-workspace-root-for-server-default-directory' is +non-nil, uses `lsp-workspace-root' to find the directory +corresponding to PATH, else returns `default-directory'." + (if lsp-use-workspace-root-for-server-default-directory + (lsp-workspace-root path) + default-directory)) + +(defun lsp--fix-remote-cmd (program) + "Helper for `lsp-stdio-connection'. +Originally coppied from eglot." + + (if (file-remote-p default-directory) + (list shell-file-name "-c" + (string-join (cons "stty raw > /dev/null;" + (mapcar #'shell-quote-argument program)) + " ")) + program)) + +(defvar tramp-use-ssh-controlmaster-options) +(defvar tramp-ssh-controlmaster-options) + +(defun lsp-stdio-connection (command &optional test-command) + "Returns a connection property list using COMMAND. +COMMAND can be: A string, denoting the command to launch the +language server. A list of strings, denoting an executable with +its command line arguments. A function, that either returns a +string or a list of strings. In all cases, the launched language +server should send and receive messages on standard I/O. +TEST-COMMAND is a function with no arguments which returns +whether the command is present or not. When not specified +`lsp-mode' will check whether the first element of the list +returned by COMMAND is available via `executable-find'" + (cl-check-type command (or string + function + (and list + (satisfies (lambda (l) + (seq-every-p (lambda (el) + (stringp el)) + l)))))) + (list :connect (lambda (filter sentinel name environment-fn workspace) + (if (and (functionp 'json-rpc-connection) + (not (file-remote-p default-directory))) + (lsp-json-rpc-connection workspace (lsp-resolve-final-command command)) + (let ((final-command (lsp-resolve-final-command command)) + (process-name (generate-new-buffer-name name)) + (process-environment + (lsp--compute-process-environment environment-fn))) + (let* ((stderr-buf (get-buffer-create (format "*%s::stderr*" process-name))) + (default-directory (lsp--default-directory-for-connection)) + (tramp-use-ssh-controlmaster-options 'suppress) + (tramp-ssh-controlmaster-options "-o ControlMaster=no -o ControlPath=none") + (proc (make-process + :name process-name + :connection-type 'pipe + :buffer (format "*%s*" process-name) + :coding 'no-conversion + :command final-command + :filter filter + :sentinel sentinel + :stderr stderr-buf + :noquery t + :file-handler t))) + (set-process-query-on-exit-flag proc nil) + (set-process-query-on-exit-flag (get-buffer-process stderr-buf) nil) + (with-current-buffer (get-buffer stderr-buf) + ;; Make the *NAME::stderr* buffer buffer-read-only, q to bury, etc. + (special-mode)) + (cons proc proc))))) + :test? (or + test-command + (lambda () + (lsp-server-present? (lsp-resolve-final-command command t)))))) + +(defun lsp--open-network-stream (host port name) + "Open network stream to HOST:PORT. + NAME will be passed to `open-network-stream'. + RETRY-COUNT is the number of the retries. + SLEEP-INTERVAL is the sleep interval between each retry." + (let* ((retries 0) + (sleep-interval 0.01) + (number-of-retries (/ lsp-tcp-connection-timeout sleep-interval)) + connection) + (while (and (not connection) (< retries number-of-retries)) + (condition-case err + (setq connection (open-network-stream name nil host port + :type 'plain + :coding 'no-conversion)) + (file-error + (let ((inhibit-message t)) + (lsp--warn "Failed to connect to %s:%s with error message %s" + host + port + (error-message-string err)) + (sleep-for sleep-interval) + (cl-incf retries))))) + (or connection (error "Port %s was never taken. Consider increasing `lsp-tcp-connection-timeout'." port)))) + +(defun lsp--port-available (host port) + "Return non-nil if HOST and PORT are available." + (condition-case _err + (delete-process (open-network-stream "*connection-test*" nil host port :type 'plain)) + (file-error t))) + +(defun lsp--find-available-port (host starting-port) + "Find available port on HOST starting from STARTING-PORT." + (let ((port starting-port)) + (while (not (lsp--port-available host port)) + (cl-incf port)) + port)) + +(defun lsp-tcp-connection (command-fn) + "Returns a connection property list similar to `lsp-stdio-connection'. +COMMAND-FN can only be a function that takes a single argument, a +port number. It should return a command for launches a language server +process listening for TCP connections on the provided port." + (cl-check-type command-fn function) + (list + :connect (lambda (filter sentinel name environment-fn _workspace) + (let* ((host "localhost") + (port (lsp--find-available-port host (cl-incf lsp--tcp-port))) + (command (funcall command-fn port)) + (final-command (if (consp command) command (list command))) + (_ (unless (lsp-server-present? final-command) + (user-error (format "Couldn't find executable %s" (cl-first final-command))))) + (process-environment + (lsp--compute-process-environment environment-fn)) + (proc (make-process :name name :connection-type 'pipe :coding 'no-conversion + :command final-command :sentinel sentinel :stderr (format "*%s::stderr*" name) :noquery t)) + (tcp-proc (lsp--open-network-stream host port (concat name "::tcp")))) + + ;; TODO: Same :noquery issue (see above) + (set-process-query-on-exit-flag proc nil) + (set-process-query-on-exit-flag tcp-proc nil) + (set-process-filter tcp-proc filter) + (cons tcp-proc proc))) + :test? (lambda () (lsp-server-present? (funcall command-fn 0))))) + +(defalias 'lsp-tcp-server 'lsp-tcp-server-command) + +(defun lsp-tcp-server-command (command-fn) + "Create tcp server connection. +In this mode Emacs is TCP server and the language server connects +to it. COMMAND is function with one parameter(the port) and it +should return the command to start the LS server." + (cl-check-type command-fn function) + (list + :connect (lambda (filter sentinel name environment-fn _workspace) + (let* (tcp-client-connection + (tcp-server (make-network-process :name (format "*tcp-server-%s*" name) + :buffer (format "*tcp-server-%s*" name) + :family 'ipv4 + :service lsp--tcp-server-port + :sentinel (lambda (proc _string) + (lsp-log "Language server %s is connected." name) + (setf tcp-client-connection proc)) + :server 't)) + (port (process-contact tcp-server :service)) + (final-command (funcall command-fn port)) + (process-environment + (lsp--compute-process-environment environment-fn)) + (cmd-proc (make-process :name name + :connection-type 'pipe + :coding 'no-conversion + :command final-command + :stderr (format "*tcp-server-%s*::stderr" name) + :noquery t))) + (let ((retries 0)) + ;; wait for the client to connect (we sit-for 500 ms, so have to double lsp--tcp-server-wait-seconds) + (while (and (not tcp-client-connection) (< retries (* 2 lsp--tcp-server-wait-seconds))) + (lsp--info "Waiting for connection for %s, retries: %s" name retries) + (sit-for 0.500) + (cl-incf retries))) + + (unless tcp-client-connection + (condition-case nil (delete-process tcp-server) (error)) + (condition-case nil (delete-process cmd-proc) (error)) + (error "Failed to create connection to %s on port %s" name port)) + (lsp--info "Successfully connected to %s" name) + + (set-process-query-on-exit-flag cmd-proc nil) + (set-process-query-on-exit-flag tcp-client-connection nil) + (set-process-query-on-exit-flag tcp-server nil) + + (set-process-filter tcp-client-connection filter) + (set-process-sentinel tcp-client-connection sentinel) + (cons tcp-client-connection cmd-proc))) + :test? (lambda () (lsp-server-present? (funcall command-fn 0))))) + +(defalias 'lsp-tramp-connection 'lsp-stdio-connection) + +(defun lsp--auto-configure () + "Autoconfigure `company', `flycheck', `lsp-ui', etc if they are installed." + (when (functionp 'lsp-ui-mode) + (lsp-ui-mode)) + + (if lsp-headerline-breadcrumb-enable + (add-hook 'lsp-configure-hook 'lsp-headerline-breadcrumb-mode) + (remove-hook 'lsp-configure-hook 'lsp-headerline-breadcrumb-mode)) + (if lsp-modeline-code-actions-enable + (add-hook 'lsp-configure-hook 'lsp-modeline-code-actions-mode) + (remove-hook 'lsp-configure-hook 'lsp-modeline-code-actions-mode)) + (if lsp-modeline-diagnostics-enable + (add-hook 'lsp-configure-hook 'lsp-modeline-diagnostics-mode) + (remove-hook 'lsp-configure-hook 'lsp-modeline-diagnostics-mode)) + (if lsp-modeline-workspace-status-enable + (add-hook 'lsp-configure-hook 'lsp-modeline-workspace-status-mode) + (remove-hook 'lsp-configure-hook 'lsp-modeline-workspace-status-mode)) + (if lsp-lens-enable + (add-hook 'lsp-configure-hook 'lsp-lens--enable) + (remove-hook 'lsp-configure-hook 'lsp-lens--enable)) + (if lsp-semantic-tokens-enable + (add-hook 'lsp-configure-hook 'lsp-semantic-tokens--enable) + (remove-hook 'lsp-configure-hook 'lsp-semantic-tokens--enable)) + + ;; yas-snippet config + (setq-local yas-inhibit-overlay-modification-protection t)) + +(defun lsp--restart-if-needed (workspace) + "Handler restart for WORKSPACE." + (when (or (eq lsp-restart 'auto-restart) + (eq (lsp--workspace-shutdown-action workspace) 'restart) + (and (eq lsp-restart 'interactive) + (let ((query (format + "Server %s exited (check corresponding stderr buffer for details). Do you want to restart it?" + (lsp--workspace-print workspace)))) + (y-or-n-p query)))) + (--each (lsp--workspace-buffers workspace) + (when (lsp-buffer-live-p it) + (lsp-with-current-buffer it + (if lsp--buffer-deferred + (lsp-deferred) + (lsp--info "Restarting LSP in buffer %s" (buffer-name)) + (lsp))))))) + +(defun lsp--update-key (table key fn) + "Apply FN on value corresponding to KEY in TABLE." + (let ((existing-value (gethash key table))) + (if-let ((new-value (funcall fn existing-value))) + (puthash key new-value table) + (remhash key table)))) + +(defun lsp--process-sentinel (workspace process exit-str) + "Create the sentinel for WORKSPACE." + (unless (process-live-p process) + (lsp--handle-process-exit workspace exit-str))) + +(defun lsp--handle-process-exit (workspace exit-str) + (let* ((folder->workspaces (lsp-session-folder->servers (lsp-session))) + (proc (lsp--workspace-proc workspace))) + (lsp--warn "%s has exited (%s)" + (lsp-process-name proc) + (string-trim-right (or exit-str ""))) + (with-lsp-workspace workspace + ;; Clean workspace related data in each of the buffers + ;; in the workspace. + (--each (lsp--workspace-buffers workspace) + (when (lsp-buffer-live-p it) + (lsp-with-current-buffer it + (setq lsp--buffer-workspaces (delete workspace lsp--buffer-workspaces)) + (lsp--uninitialize-workspace) + (lsp--spinner-stop) + (lsp--remove-overlays 'lsp-highlight)))) + + ;; Cleanup session from references to the closed workspace. + (--each (hash-table-keys folder->workspaces) + (lsp--update-key folder->workspaces it (apply-partially 'delete workspace))) + + (lsp-process-cleanup proc)) + + (run-hook-with-args 'lsp-after-uninitialized-functions workspace) + + (if (eq (lsp--workspace-shutdown-action workspace) 'shutdown) + (lsp--info "Workspace %s shutdown." (lsp--workspace-print workspace)) + (lsp--restart-if-needed workspace)) + (lsp--cleanup-hanging-watches))) + +(defun lsp-workspace-folders (workspace) + "Return all folders associated with WORKSPACE." + (let (result) + (->> (lsp-session) + (lsp-session-folder->servers) + (maphash (lambda (folder workspaces) + (when (-contains? workspaces workspace) + (push folder result))))) + result)) + +(defun lsp--start-workspace (session client-template root &optional initialization-options) + "Create new workspace for CLIENT-TEMPLATE with project root ROOT. +INITIALIZATION-OPTIONS are passed to initialize function. +SESSION is the active session." + (lsp--spinner-start) + (-let* ((default-directory root) + (client (copy-lsp--client client-template)) + (workspace (make-lsp--workspace + :root root + :client client + :status 'starting + :buffers (list (lsp-current-buffer)) + :host-root (file-remote-p root))) + ((&lsp-cln 'server-id 'environment-fn 'new-connection 'custom-capabilities + 'multi-root 'initialized-fn) client) + ((proc . cmd-proc) (funcall + (or (plist-get new-connection :connect) + (user-error "Client %s is configured incorrectly" client)) + (lsp--create-filter-function workspace) + (apply-partially #'lsp--process-sentinel workspace) + (format "%s" server-id) + environment-fn + workspace)) + (workspace-folders (gethash server-id (lsp-session-server-id->folders session)))) + (setf (lsp--workspace-proc workspace) proc + (lsp--workspace-cmd-proc workspace) cmd-proc) + + ;; update (lsp-session-folder->servers) depending on whether we are starting + ;; multi/single folder workspace + (mapc (lambda (project-root) + (->> session + (lsp-session-folder->servers) + (gethash project-root) + (cl-pushnew workspace))) + (or workspace-folders (list root))) + + (with-lsp-workspace workspace + (run-hooks 'lsp-before-initialize-hook) + (lsp-request-async + "initialize" + (append + (list :processId (unless (file-remote-p (buffer-file-name)) + (emacs-pid)) + :rootPath (lsp-file-local-name (expand-file-name root)) + :clientInfo (list :name "emacs" + :version (emacs-version)) + :rootUri (lsp--path-to-uri root) + :capabilities (lsp--client-capabilities custom-capabilities) + :initializationOptions initialization-options + :workDoneToken "1") + (when lsp-server-trace + (list :trace lsp-server-trace)) + (when multi-root + (->> workspace-folders + (-distinct) + (-map (lambda (folder) + (list :uri (lsp--path-to-uri folder) + :name (f-filename folder)))) + (apply 'vector) + (list :workspaceFolders)))) + (-lambda ((&InitializeResult :capabilities)) + ;; we know that Rust Analyzer will send {} which will be parsed as null + ;; when using plists + (when (equal 'rust-analyzer server-id) + (-> capabilities + (lsp:server-capabilities-text-document-sync?) + (lsp:set-text-document-sync-options-save? t))) + + (setf (lsp--workspace-server-capabilities workspace) capabilities + (lsp--workspace-status workspace) 'initialized) + + (with-lsp-workspace workspace + (lsp-notify "initialized" lsp--empty-ht)) + + (when initialized-fn (funcall initialized-fn workspace)) + + (cl-callf2 -filter #'lsp-buffer-live-p (lsp--workspace-buffers workspace)) + (->> workspace + (lsp--workspace-buffers) + (mapc (lambda (buffer) + (lsp-with-current-buffer buffer + (lsp--open-in-workspace workspace))))) + + (with-lsp-workspace workspace + (run-hooks 'lsp-after-initialize-hook)) + (lsp--info "%s initialized successfully in folders: %s" + (lsp--workspace-print workspace) + (lsp-workspace-folders workspace))) + :mode 'detached)) + workspace)) + +(defun lsp--load-default-session () + "Load default session." + (setq lsp--session (or (condition-case err + (lsp--read-from-file lsp-session-file) + (error (lsp--error "Failed to parse the session %s, starting with clean one." + (error-message-string err)) + nil)) + (make-lsp-session)))) + +(defun lsp-session () + "Get the session associated with the current buffer." + (or lsp--session (setq lsp--session (lsp--load-default-session)))) + +(defun lsp--client-disabled-p (buffer-major-mode client) + (seq-some + (lambda (entry) + (pcase entry + ((pred symbolp) (eq entry client)) + (`(,mode . ,client-or-list) + (and (eq mode buffer-major-mode) + (if (listp client-or-list) + (memq client client-or-list) + (eq client client-or-list)))))) + lsp-disabled-clients)) + + +;; download server + +(defcustom lsp-server-install-dir (expand-file-name + (locate-user-emacs-file (f-join ".cache" "lsp"))) + "Directory in which the servers will be installed." + :risky t + :type 'directory + :package-version '(lsp-mode . "6.3") + :group 'lsp-mode) + +(defcustom lsp-verify-signature t + "Whether to check GPG signatures of downloaded files." + :type 'boolean + :package-version '(lsp-mode . "8.0.0") + :group 'lsp-mode) + +(defvar lsp--dependencies (ht)) + +(defun lsp-dependency (name &rest definitions) + "Used to specify a language server DEPENDENCY, the server +executable or other required file path. Typically, the +DEPENDENCY is found by locating it on the system path using +`executable-find'. + +You can explicitly call lsp-dependency in your environment to +specify the absolute path to the DEPENDENCY. For example, the +typescript-language-server requires both the server and the +typescript compiler. If you have installed them in a team shared +read-only location, you can instruct lsp-mode to use them via + + (eval-after-load `lsp-mode + `(progn + (require lsp-javascript) + (lsp-dependency typescript-language-server (:system ,tls-exe)) + (lsp-dependency typescript (:system ,ts-js)))) + +where tls-exe is the absolute path to the typescript-language-server +executable and ts-js is the absolute path to the typescript compiler +JavaScript file, tsserver.js (the *.js is required for Windows)." + (ht-set lsp--dependencies name definitions)) + +(defun lsp--server-binary-present? (client) + (unless (equal (lsp--client-server-id client) 'lsp-pwsh) + (condition-case () + (-some-> client lsp--client-new-connection (plist-get :test?) funcall) + (error nil) + (args-out-of-range nil)))) + +(define-minor-mode lsp-installation-buffer-mode + "Mode used in *lsp-installation* buffers. +It can be used to set-up keybindings, etc. Disabling this mode +detaches the installation buffer from commands like +`lsp-select-installation-buffer'." + :init-value nil + :lighter nil) + +(defface lsp-installation-finished-buffer-face '((t :foreground "orange")) + "Face used for finished installation buffers. +Used in `lsp-select-installation-buffer'." + :group 'lsp-mode) + +(defface lsp-installation-buffer-face '((t :foreground "green")) + "Face used for installation buffers still in progress. +Used in `lsp-select-installation-buffer'." + :group 'lsp-mode) + +(defun lsp--installation-buffer? (buf) + "Check whether BUF is an `lsp-async-start-process' buffer." + (buffer-local-value 'lsp-installation-buffer-mode buf)) + +(defun lsp-select-installation-buffer (&optional show-finished) + "Interactively choose an installation buffer. +If SHOW-FINISHED is set, leftover (finished) installation buffers +are still shown." + (interactive "P") + (let ((bufs (--filter (and (lsp--installation-buffer? it) + (or show-finished (get-buffer-process it))) + (buffer-list)))) + (pcase bufs + (`nil (user-error "No installation buffers")) + (`(,buf) (pop-to-buffer buf)) + (bufs (pop-to-buffer (completing-read "Select installation buffer: " + (--map (propertize (buffer-name it) 'face + (if (get-buffer-process it) + 'lsp-installation-buffer-face + 'lsp-installation-finished-buffer-face)) + bufs))))))) + +(defun lsp-cleanup-installation-buffers () + "Delete finished *lsp-installation* buffers." + (interactive) + (dolist (buf (buffer-list)) + (when (and (lsp--installation-buffer? buf) (not (get-buffer-process buf))) + (kill-buffer buf)))) + +(defun lsp--download-status () + (-some--> #'lsp--client-download-in-progress? + (lsp--filter-clients it) + (-map (-compose #'symbol-name #'lsp--client-server-id) it) + (format "%s" it) + (propertize it 'face 'success) + (format " Installing following servers: %s" it) + (propertize it + 'local-map (make-mode-line-mouse-map + 'mouse-1 #'lsp-select-installation-buffer) + 'mouse-face 'highlight))) + +(defun lsp--install-server-internal (client &optional update?) + (unless (lsp--client-download-server-fn client) + (user-error "There is no automatic installation for `%s', you have to install it manually following lsp-mode's documentation." + (lsp--client-server-id client))) + + (setf (lsp--client-download-in-progress? client) t) + (add-to-list 'global-mode-string '(t (:eval (lsp--download-status)))) + (cl-flet ((done + (success? &optional error-message) + ;; run with idle timer to make sure the lsp command is executed in + ;; the main thread, see #2739. + (run-with-timer + 0.0 + nil + (lambda () + (-let [(&lsp-cln 'server-id 'buffers) client] + (setf (lsp--client-download-in-progress? client) nil + (lsp--client-buffers client) nil) + (if success? + (lsp--info "Server %s downloaded, auto-starting in %s buffers." server-id + (length buffers)) + (lsp--error "Server %s install process failed with the following error message: %s. +Check `*lsp-install*' and `*lsp-log*' buffer." + server-id + error-message)) + (seq-do + (lambda (buffer) + (when (lsp-buffer-live-p buffer) + (lsp-with-current-buffer buffer + (cl-callf2 -remove-item '(t (:eval (lsp--download-status))) + global-mode-string) + (when success? (lsp))))) + buffers) + (unless (lsp--filter-clients #'lsp--client-download-in-progress?) + (cl-callf2 -remove-item '(t (:eval (lsp--download-status))) + global-mode-string))))))) + (lsp--info "Download %s started." (lsp--client-server-id client)) + (condition-case err + (funcall + (lsp--client-download-server-fn client) + client + (lambda () (done t)) + (lambda (msg) (done nil msg)) + update?) + (error + (done nil (error-message-string err)))))) + +(defun lsp--require-packages () + "Load `lsp-client-packages' if needed." + (when (and lsp-auto-configure (not lsp--client-packages-required)) + (seq-do (lambda (package) + ;; loading client is slow and `lsp' can be called repeatedly + (unless (featurep package) + (require package nil t))) + lsp-client-packages) + (setq lsp--client-packages-required t))) + +;;;###autoload +(defun lsp-install-server (update? &optional server-id) + "Interactively install or re-install server. +When prefix UPDATE? is t force installation even if the server is present." + (interactive "P") + (lsp--require-packages) + (let* ((chosen-client (or (gethash server-id lsp-clients) + (lsp--completing-read + "Select server to install/re-install: " + (or (->> lsp-clients + (ht-values) + (-filter (-andfn + (-not #'lsp--client-download-in-progress?) + #'lsp--client-download-server-fn))) + (user-error "There are no servers with automatic installation")) + (lambda (client) + (let ((server-name (-> client lsp--client-server-id symbol-name))) + (if (lsp--server-binary-present? client) + (concat server-name " (Already installed)") + server-name))) + nil + t))) + (update? (or update? + (and (not (lsp--client-download-in-progress? chosen-client)) + (lsp--server-binary-present? chosen-client))))) + (lsp--install-server-internal chosen-client update?))) + +;;;###autoload +(defun lsp-uninstall-server (dir) + "Delete a LSP server from `lsp-server-install-dir'." + (interactive + (list (read-directory-name "Uninstall LSP server: " (f-slash lsp-server-install-dir)))) + (unless (file-directory-p dir) + (user-error "Couldn't find %s directory" dir)) + (delete-directory dir 'recursive) + (message "Server `%s' uninstalled." (file-name-nondirectory (directory-file-name dir)))) + +;;;###autoload +(defun lsp-uninstall-servers () + "Uninstall all installed servers." + (interactive) + (let* ((dir lsp-server-install-dir) + (servers (ignore-errors + (directory-files dir t + directory-files-no-dot-files-regexp)))) + (if (or (not (file-directory-p dir)) (zerop (length servers))) + (user-error "No servers to uninstall") + (when (yes-or-no-p + (format "Servers to uninstall: %d (%s), proceed? " + (length servers) + (mapconcat (lambda (server) + (file-name-nondirectory (directory-file-name server))) + servers " "))) + (mapc #'lsp-uninstall-server servers) + (message "All servers uninstalled"))))) + +;;;###autoload +(defun lsp-update-server (&optional server-id) + "Interactively update (reinstall) a server." + (interactive) + (lsp--require-packages) + (let ((chosen-client (or (gethash server-id lsp-clients) + (lsp--completing-read + "Select server to update (if not on the list, probably you need to `lsp-install-server`): " + (or (->> lsp-clients + (ht-values) + (-filter (-andfn + (-not #'lsp--client-download-in-progress?) + #'lsp--client-download-server-fn + #'lsp--server-binary-present?))) + (user-error "There are no servers to update")) + (lambda (client) + (-> client lsp--client-server-id symbol-name)) + nil + t)))) + (lsp--install-server-internal chosen-client t))) + +;;;###autoload +(defun lsp-update-servers () + "Update (reinstall) all installed servers." + (interactive) + (lsp--require-packages) + (mapc (lambda (client) (lsp--install-server-internal client t)) + (-filter (-andfn + (-not #'lsp--client-download-in-progress?) + #'lsp--client-download-server-fn + #'lsp--server-binary-present?) (hash-table-values lsp-clients)))) + +;;;###autoload +(defun lsp-ensure-server (server-id) + "Ensure server SERVER-ID" + (lsp--require-packages) + (if-let ((client (gethash server-id lsp-clients))) + (unless (lsp--server-binary-present? client) + (lsp--info "Server `%s' is not preset, installing..." server-id) + (lsp-install-server nil server-id)) + (warn "Unable to find server registration with id %s" server-id))) + +(defun lsp-async-start-process (callback error-callback &rest command) + "Start async process COMMAND with CALLBACK and ERROR-CALLBACK." + (let ((name (cl-first command))) + (with-current-buffer (compilation-start (mapconcat #'shell-quote-argument (-filter (lambda (cmd) + (not (null cmd))) + command) + " ") t + (lambda (&rest _) + (generate-new-buffer-name (format "*lsp-install: %s*" name)))) + (lsp-installation-buffer-mode +1) + (view-mode +1) + (add-hook + 'compilation-finish-functions + (lambda (_buf status) + (if (string= "finished\n" status) + (condition-case err + (funcall callback) + (error + (funcall error-callback (error-message-string err)))) + (funcall error-callback (s-trim-right status)))) + nil t)))) + +(defun lsp-resolve-value (value) + "Resolve VALUE's value. +If it is function - call it. +If it is a variable - return it's value +Otherwise returns value itself." + (cond + ((functionp value) (funcall value)) + ((and (symbolp value) (boundp value)) (symbol-value value)) + (value))) + +(defvar lsp-deps-providers + (list :npm (list :path #'lsp--npm-dependency-path + :install #'lsp--npm-dependency-install) + :cargo (list :path #'lsp--cargo-dependency-path + :install #'lsp--cargo-dependency-install) + :system (list :path #'lsp--system-path) + :download (list :path #'lsp-download-path + :install #'lsp-download-install))) + +(defun lsp--system-path (path) + "If PATH is absolute and exists return it as is. Otherwise, +return the absolute path to the executable defined by PATH or +nil." + ;; For node.js 'sub-packages' PATH may point to a *.js file. Consider the + ;; typescript-language-server. When lsp invokes the server, lsp needs to + ;; supply the path to the typescript compiler, tsserver.js, as an argument. To + ;; make code platform independent, one must pass the absolute path to the + ;; tsserver.js file (Windows requires a *.js file - see help on the JavaScript + ;; child process spawn command that is invoked by the + ;; typescript-language-server). This is why we check for existence and not + ;; that the path is executable. + (let ((path (lsp-resolve-value path))) + (cond + ((and (f-absolute? path) + (f-exists? path)) + path) + ((executable-find path t) path)))) + +(defun lsp-package-path (dependency) + "Path to the DEPENDENCY each of the registered providers." + (let (path) + (-first (-lambda ((provider . rest)) + (setq path (-some-> lsp-deps-providers + (plist-get provider) + (plist-get :path) + (apply rest)))) + (gethash dependency lsp--dependencies)) + path)) + +(defun lsp-package-ensure (dependency callback error-callback) + "Asynchronously ensure a package." + (or (-first (-lambda ((provider . rest)) + (-some-> lsp-deps-providers + (plist-get provider) + (plist-get :install) + (apply (cl-list* callback error-callback rest)))) + (gethash dependency lsp--dependencies)) + (funcall error-callback (format "Unable to find a way to install %s" dependency)))) + + +;; npm handling + +;; https://docs.npmjs.com/files/folders#executables +(cl-defun lsp--npm-dependency-path (&key package path &allow-other-keys) + "Return npm dependency PATH for PACKAGE." + (let ((path (executable-find + (f-join lsp-server-install-dir "npm" package + (cond ((eq system-type 'windows-nt) "") + (t "bin")) + path) + t))) + (unless (and path (f-exists? path)) + (error "The package %s is not installed. Unable to find %s" package path)) + path)) + +(cl-defun lsp--npm-dependency-install (callback error-callback &key package &allow-other-keys) + (if-let ((npm-binary (executable-find "npm"))) + (progn + ;; Explicitly `make-directory' to work around NPM bug in + ;; versions 7.0.0 through 7.4.1. See + ;; https://github.com/emacs-lsp/lsp-mode/issues/2364 for + ;; discussion. + (make-directory (f-join lsp-server-install-dir "npm" package "lib") 'parents) + (lsp-async-start-process (lambda () + (if (string-empty-p + (string-trim (shell-command-to-string + (mapconcat #'shell-quote-argument `(,npm-binary "view" ,package "peerDependencies") " ")))) + (funcall callback) + (let ((default-directory (f-dirname (car (last (directory-files-recursively (f-join lsp-server-install-dir "npm" package) "package.json"))))) + (process-environment (append '("npm_config_yes=true") process-environment))) ;; Disable prompting for older versions of npx + (when (f-dir-p default-directory) + (lsp-async-start-process callback + error-callback + (executable-find "npx") + "npm-install-peers"))))) + error-callback + npm-binary + "-g" + "--prefix" + (f-join lsp-server-install-dir "npm" package) + "install" + package)) + (lsp-log "Unable to install %s via `npm' because it is not present" package) + nil)) + + +;; Cargo dependency handling +(cl-defun lsp--cargo-dependency-path (&key package path &allow-other-keys) + (let ((path (executable-find + (f-join lsp-server-install-dir + "cargo" + package + "bin" + path) + t))) + (unless (and path (f-exists? path)) + (error "The package %s is not installed. Unable to find %s" package path)) + path)) + +(cl-defun lsp--cargo-dependency-install (callback error-callback &key package git &allow-other-keys) + (if-let ((cargo-binary (executable-find "cargo"))) + (lsp-async-start-process + callback + error-callback + cargo-binary + "install" + package + (when git + "--git") + git + "--root" + (f-join lsp-server-install-dir "cargo" package)) + (lsp-log "Unable to install %s via `cargo' because it is not present" package) + nil)) + + + +;; Download URL handling +(cl-defun lsp-download-install (callback error-callback &key url asc-url pgp-key store-path decompress &allow-other-keys) + (let* ((url (lsp-resolve-value url)) + (store-path (lsp-resolve-value store-path)) + ;; (decompress (lsp-resolve-value decompress)) + (download-path + (pcase decompress + (:gzip (concat store-path ".gz")) + (:zip (concat store-path ".zip")) + (:targz (concat store-path ".tar.gz")) + (`nil store-path) + (_ (error ":decompress must be `:gzip', `:zip', `:targz' or `nil'"))))) + (make-thread + (lambda () + (condition-case err + (progn + (when (f-exists? download-path) + (f-delete download-path)) + (when (f-exists? store-path) + (f-delete store-path)) + (lsp--info "Starting to download %s to %s..." url download-path) + (mkdir (f-parent download-path) t) + (url-copy-file url download-path) + (lsp--info "Finished downloading %s..." download-path) + (when (and lsp-verify-signature asc-url pgp-key) + (if (executable-find epg-gpg-program) + (let ((asc-download-path (concat download-path ".asc")) + (context (epg-make-context)) + (fingerprint) + (signature)) + (when (f-exists? asc-download-path) + (f-delete asc-download-path)) + (lsp--info "Starting to download %s to %s..." asc-url asc-download-path) + (url-copy-file asc-url asc-download-path) + (lsp--info "Finished downloading %s..." asc-download-path) + (epg-import-keys-from-string context pgp-key) + (setq fingerprint (epg-import-status-fingerprint + (car + (epg-import-result-imports + (epg-context-result-for context 'import))))) + (lsp--info "Verifying signature %s..." asc-download-path) + (epg-verify-file context asc-download-path download-path) + (setq signature (car (epg-context-result-for context 'verify))) + (unless (and + (eq (epg-signature-status signature) 'good) + (equal (epg-signature-fingerprint signature) fingerprint)) + (error "Failed to verify GPG signature: %s" (epg-signature-to-string signature)))) + (lsp--warn "GPG is not installed, skipping the signature check."))) + (when decompress + (lsp--info "Decompressing %s..." download-path) + (pcase decompress + (:gzip + (lsp-gunzip download-path)) + (:zip (lsp-unzip download-path (f-parent store-path))) + (:targz (lsp-tar-gz-decompress download-path (f-parent store-path)))) + (lsp--info "Decompressed %s..." store-path)) + (funcall callback)) + (error (funcall error-callback err))))))) + +(cl-defun lsp-download-path (&key store-path binary-path set-executable? &allow-other-keys) + "Download URL and store it into STORE-PATH. + +SET-EXECUTABLE? when non-nil change the executable flags of +STORE-PATH to make it executable. BINARY-PATH can be specified +when the binary to start does not match the name of the +archive (e.g. when the archive has multiple files)" + (let ((store-path (or (lsp-resolve-value binary-path) + (lsp-resolve-value store-path)))) + (cond + ((executable-find store-path) store-path) + ((and set-executable? (f-exists? store-path)) + (set-file-modes store-path #o0700) + store-path) + ((f-exists? store-path) store-path)))) + +(defun lsp--find-latest-gh-release-url (url regex) + "Fetch the latest version in the releases given by URL by using REGEX." + (let ((url-request-method "GET")) + (with-current-buffer (url-retrieve-synchronously url) + (goto-char (point-min)) + (re-search-forward "\n\n" nil 'noerror) + (delete-region (point-min) (point)) + (let* ((json-result (lsp-json-read-buffer))) + (message "Latest version found: %s" (lsp-get json-result :tag_name)) + (--> json-result + (lsp-get it :assets) + (seq-find (lambda (entry) (string-match-p regex (lsp-get entry :name))) it) + (lsp-get it :browser_download_url)))))) + +;; unzip + +(defconst lsp-ext-pwsh-script "powershell -noprofile -noninteractive \ +-nologo -ex bypass -command Expand-Archive -path '%s' -dest '%s'" + "Powershell script to unzip file.") + +(defconst lsp-ext-unzip-script "bash -c 'mkdir -p %2$s && unzip -qq -o %1$s -d %2$s'" + "Unzip script to unzip file.") + +(defcustom lsp-unzip-script (lambda () + (cond ((executable-find "unzip") lsp-ext-unzip-script) + ((executable-find "powershell") lsp-ext-pwsh-script) + (t nil))) + "The script to unzip." + :group 'lsp-mode + :type 'string + :package-version '(lsp-mode . "8.0.0")) + +(defun lsp-unzip (zip-file dest) + "Unzip ZIP-FILE to DEST." + (unless lsp-unzip-script + (error "Unable to find `unzip' or `powershell' on the path, please customize `lsp-unzip-script'")) + (shell-command (format (lsp-resolve-value lsp-unzip-script) zip-file dest))) + +;; gunzip + +(defconst lsp-ext-gunzip-script "gzip -d %1$s" + "Script to decompress a gzippped file with gzip.") + +(defcustom lsp-gunzip-script (lambda () + (cond ((executable-find "gzip") lsp-ext-gunzip-script) + (t nil))) + "The script to decompress a gzipped file. +Should be a format string with one argument for the file to be decompressed +in place." + :group 'lsp-mode + :type 'string + :package-version '(lsp-mode . "8.0.0")) + +(defun lsp-gunzip (gz-file) + "Decompress GZ-FILE in place." + (unless lsp-gunzip-script + (error "Unable to find `gzip' on the path, please either customize `lsp-gunzip-script' or manually decompress %s" gz-file)) + (shell-command (format (lsp-resolve-value lsp-gunzip-script) gz-file))) + +;; tar.gz decompression + +(defconst lsp-ext-tar-script "bash -c 'mkdir -p %2$s; tar xf %1$s --directory=%2$s'" + "Script to decompress a .tar.gz file.") + +(defcustom lsp-tar-script (lambda () + (cond ((executable-find "tar") lsp-ext-tar-script) + (t nil))) + "The script to decompress a .tar.gz file. +Should be a format string with one argument for the file to be decompressed +in place." + :group 'lsp-mode + :type 'string) + +(defun lsp-tar-gz-decompress (targz-file dest) + "Decompress TARGZ-FILE in DEST." + (unless lsp-tar-script + (error "Unable to find `tar' on the path, please either customize `lsp-tar-script' or manually decompress %s" targz-file)) + (shell-command (format (lsp-resolve-value lsp-tar-script) targz-file dest))) + + +;; VSCode marketplace + +(defcustom lsp-vscode-ext-url + "https://marketplace.visualstudio.com/_apis/public/gallery/publishers/%s/vsextensions/%s/%s/vspackage%s" + "Vscode extension template url." + :group 'lsp-mode + :type 'string + :package-version '(lsp-mode . "8.0.0")) + +(defun lsp-vscode-extension-url (publisher name version &optional targetPlatform) + "Return the URL to vscode extension. +PUBLISHER is the extension publisher. +NAME is the name of the extension. +VERSION is the version of the extension. +TARGETPLATFORM is the targetPlatform of the extension." + (format lsp-vscode-ext-url publisher name version (or targetPlatform ""))) + + + +;; Queueing prompts + +(defvar lsp--question-queue nil + "List of questions yet to be asked by `lsp-ask-question'.") + +(defun lsp-ask-question (question options callback) + "Prompt the user to answer the QUESTION with one of the OPTIONS from the +minibuffer. Once the user selects an option, the CALLBACK function will be +called, passing the selected option to it. + +If the user is currently being shown a question, the question will be stored in +`lsp--question-queue', and will be asked once the user has answered the current +question." + (add-to-list 'lsp--question-queue `(("question" . ,question) + ("options" . ,options) + ("callback" . ,callback)) t) + (when (eq (length lsp--question-queue) 1) + (lsp--process-question-queue))) + +(defun lsp--process-question-queue () + "Take the first question from `lsp--question-queue', process it, then process +the next question until the queue is empty." + (-let* (((&alist "question" "options" "callback") (car lsp--question-queue)) + (answer (completing-read question options nil t))) + (pop lsp--question-queue) + (funcall callback answer) + (when lsp--question-queue + (lsp--process-question-queue)))) + +(defun lsp--supports-buffer? (client) + (and + ;; both file and client remote or both local + (eq (---truthy? (file-remote-p (buffer-file-name))) + (---truthy? (lsp--client-remote? client))) + + ;; activation function or major-mode match. + (if-let ((activation-fn (lsp--client-activation-fn client))) + (funcall activation-fn (buffer-file-name) major-mode) + (-contains? (lsp--client-major-modes client) major-mode)) + + ;; check whether it is enabled if `lsp-enabled-clients' is not null + (or (null lsp-enabled-clients) + (or (member (lsp--client-server-id client) lsp-enabled-clients) + (ignore (lsp--info "Client %s is not in lsp-enabled-clients" + (lsp--client-server-id client))))) + + ;; check whether it is not disabled. + (not (lsp--client-disabled-p major-mode (lsp--client-server-id client))))) + +(defun lsp--filter-clients (pred) + (->> lsp-clients hash-table-values (-filter pred))) + +(defun lsp--find-clients () + "Find clients which can handle current buffer." + (-when-let (matching-clients (lsp--filter-clients (-andfn #'lsp--supports-buffer? + #'lsp--server-binary-present?))) + (lsp-log "Found the following clients for %s: %s" + (buffer-file-name) + (s-join ", " + (-map (lambda (client) + (format "(server-id %s, priority %s)" + (lsp--client-server-id client) + (lsp--client-priority client))) + matching-clients))) + (-let* (((add-on-clients main-clients) (-separate #'lsp--client-add-on? matching-clients)) + (selected-clients (if-let ((main-client (and main-clients + (--max-by (> (lsp--client-priority it) + (lsp--client-priority other)) + main-clients)))) + (cons main-client add-on-clients) + add-on-clients))) + (lsp-log "The following clients were selected based on priority: %s" + (s-join ", " + (-map (lambda (client) + (format "(server-id %s, priority %s)" + (lsp--client-server-id client) + (lsp--client-priority client))) + selected-clients))) + selected-clients))) + +(defun lsp-workspace-remove-all-folders() + "Delete all lsp tracked folders." + (interactive) + (--each (lsp-session-folders (lsp-session)) + (lsp-workspace-folders-remove it))) + +(defun lsp-register-client (client) + "Registers LSP client CLIENT." + (let ((client-id (lsp--client-server-id client))) + (puthash client-id client lsp-clients) + (setplist (intern (format "lsp-%s-after-open-hook" client-id)) + `( standard-value (nil) custom-type hook + custom-package-version (lsp-mode . "7.0.1") + variable-documentation ,(format "Hooks to run after `%s' server is run." client-id) + custom-requests nil))) + (when (and lsp-auto-register-remote-clients + (not (lsp--client-remote? client))) + (let ((remote-client (copy-lsp--client client))) + (setf (lsp--client-remote? remote-client) t + (lsp--client-server-id remote-client) (intern + (format "%s-tramp" + (lsp--client-server-id client))) + ;; disable automatic download + (lsp--client-download-server-fn remote-client) nil) + (lsp-register-client remote-client)))) + +(defun lsp--create-initialization-options (_session client) + "Create initialization-options from SESSION and CLIENT. +Add workspace folders depending on server being multiroot and +session workspace folder configuration for the server." + (let* ((initialization-options-or-fn (lsp--client-initialization-options client))) + (if (functionp initialization-options-or-fn) + (funcall initialization-options-or-fn) + initialization-options-or-fn))) + +(defvar lsp-client-settings (make-hash-table :test 'equal) + "For internal use, any external users please use + `lsp-register-custom-settings' function instead") + +(defun lsp-register-custom-settings (props) + "Register PROPS. +PROPS is list of triple (path value boolean?) where PATH is the path to the +property; VALUE can be a literal value, symbol to be evaluated, or either a +function or lambda function to be called without arguments; BOOLEAN? is an +optional flag that should be non-nil for boolean settings, when it is nil the +property will be ignored if the VALUE is nil. + +Example: `(lsp-register-custom-settings `((\"foo.bar.buzz.enabled\" t t)))' +\(note the double parentheses)" + (mapc + (-lambda ((path . rest)) + (puthash path rest lsp-client-settings)) + props)) + +(defun lsp-region-text (region) + "Get the text for REGION in current buffer." + (-let (((start . end) (lsp--range-to-region region))) + (buffer-substring-no-properties start end))) + +(defun lsp-ht-set (tbl paths value) + "Set nested hash table value. +TBL - a hash table, PATHS is the path to the nested VALUE." + (pcase paths + (`(,path) (ht-set! tbl path value)) + (`(,path . ,rst) (let ((nested-tbl (or (gethash path tbl) + (let ((temp-tbl (ht))) + (ht-set! tbl path temp-tbl) + temp-tbl)))) + (lsp-ht-set nested-tbl rst value))))) + +;; sections + +(defalias 'defcustom-lsp 'lsp-defcustom) + +(defmacro lsp-defcustom (symbol standard doc &rest args) + "Defines `lsp-mode' server property." + (declare (doc-string 3) (debug (name body)) + (indent defun)) + (let ((path (plist-get args :lsp-path))) + (cl-remf args :lsp-path) + `(progn + (lsp-register-custom-settings + (quote ((,path ,symbol ,(equal ''boolean (plist-get args :type)))))) + + (defcustom ,symbol ,standard ,doc + :set (lambda (sym val) + (lsp--set-custom-property sym val ,path)) + ,@args)))) + +(defun lsp--set-custom-property (sym val path) + (set sym val) + (let ((section (cl-first (s-split "\\." path)))) + (mapc (lambda (workspace) + (when (-contains? (lsp--client-synchronize-sections (lsp--workspace-client workspace)) + section) + (with-lsp-workspace workspace + (lsp--set-configuration (lsp-configuration-section section))))) + (lsp--session-workspaces (lsp-session))))) + +(defun lsp-configuration-section (section) + "Get settings for SECTION." + (let ((ret (ht-create))) + (maphash (-lambda (path (variable boolean?)) + (when (s-matches? (concat (regexp-quote section) "\\..*") path) + (let* ((symbol-value (-> variable + lsp-resolve-value + lsp-resolve-value)) + (value (if (and boolean? (not symbol-value)) + :json-false + symbol-value))) + (when (or boolean? value) + (lsp-ht-set ret (s-split "\\." path) value))))) + lsp-client-settings) + ret)) + + +(defun lsp--start-connection (session client project-root) + "Initiates connection created from CLIENT for PROJECT-ROOT. +SESSION is the active session." + (when (lsp--client-multi-root client) + (cl-pushnew project-root (gethash (lsp--client-server-id client) + (lsp-session-server-id->folders session)))) + (run-hook-with-args 'lsp-workspace-folders-changed-functions (list project-root) nil) + + (unwind-protect + (lsp--start-workspace session client project-root (lsp--create-initialization-options session client)) + (lsp--spinner-stop))) + +;; lsp-log-io-mode + +(defvar lsp-log-io-mode-map + (let ((map (make-sparse-keymap))) + (define-key map (kbd "M-n") #'lsp-log-io-next) + (define-key map (kbd "M-p") #'lsp-log-io-prev) + (define-key map (kbd "k") #'lsp--erase-log-buffer) + (define-key map (kbd "K") #'lsp--erase-session-log-buffers) + map) + "Keymap for lsp log buffer mode.") + +(define-derived-mode lsp-log-io-mode special-mode "LspLogIo" + "Special mode for viewing IO logs.") + +(defun lsp-workspace-show-log (workspace) + "Display the log buffer of WORKSPACE." + (interactive + (list (if lsp-log-io + (if (eq (length (lsp-workspaces)) 1) + (cl-first (lsp-workspaces)) + (lsp--completing-read "Workspace: " (lsp-workspaces) + #'lsp--workspace-print nil t)) + (user-error "IO logging is disabled")))) + (pop-to-buffer (lsp--get-log-buffer-create workspace))) + +(defalias 'lsp-switch-to-io-log-buffer 'lsp-workspace-show-log) + +(defun lsp--get-log-buffer-create (workspace) + "Return the lsp log buffer of WORKSPACE, creating a new one if needed." + (let* ((server-id (-> workspace lsp--workspace-client lsp--client-server-id symbol-name)) + (pid (-> workspace lsp--workspace-cmd-proc lsp-process-id))) + (get-buffer-create (format "*lsp-log: %s:%s*" server-id pid)))) + +(defun lsp--erase-log-buffer (&optional all) + "Delete contents of current lsp log buffer. +When ALL is t, erase all log buffers of the running session." + (interactive) + (let* ((workspaces (lsp--session-workspaces (lsp-session))) + (current-log-buffer (current-buffer))) + (dolist (w workspaces) + (let ((b (lsp--get-log-buffer-create w))) + (when (or all (eq b current-log-buffer)) + (with-current-buffer b + (let ((inhibit-read-only t)) + (erase-buffer)))))))) + +(defun lsp--erase-session-log-buffers () + "Erase log buffers of the running session." + (interactive) + (lsp--erase-log-buffer t)) + +(defun lsp-log-io-next (arg) + "Move to next log entry." + (interactive "P") + (ewoc-goto-next lsp--log-io-ewoc (or arg 1))) + +(defun lsp-log-io-prev (arg) + "Move to previous log entry." + (interactive "P") + (ewoc-goto-prev lsp--log-io-ewoc (or arg 1))) + + + +(cl-defmethod lsp-process-id ((process process)) + (process-id process)) + +(cl-defmethod lsp-process-name ((process process)) (process-name process)) + +(cl-defmethod lsp-process-status ((process process)) (process-status process)) + +(cl-defmethod lsp-process-kill ((process process)) + (when (process-live-p process) + (kill-process process))) + +(cl-defmethod lsp-process-send ((process process) message) + (condition-case err + (process-send-string process (lsp--make-message message)) + (error (lsp--error "Sending to process failed with the following error: %s" + (error-message-string err))))) + +(cl-defmethod lsp-process-cleanup (process) + ;; Kill standard error buffer only if the process exited normally. + ;; Leave it intact otherwise for debugging purposes. + (let ((buffer (-> process process-name get-buffer))) + (when (and (eq (process-status process) 'exit) + (zerop (process-exit-status process)) + (buffer-live-p buffer)) + (kill-buffer buffer)))) + + +;; native JSONRPC + +(declare-function json-rpc "ext:json") +(declare-function json-rpc-connection "ext:json") +(declare-function json-rpc-send "ext:json") +(declare-function json-rpc-shutdown "ext:json") +(declare-function json-rpc-stderr "ext:json") +(declare-function json-rpc-pid "ext:json") + +(defvar lsp-json-rpc-thread nil) +(defvar lsp-json-rpc-queue nil) +(defvar lsp-json-rpc-done nil) +(defvar lsp-json-rpc-mutex (make-mutex)) +(defvar lsp-json-rpc-condition (make-condition-variable lsp-json-rpc-mutex)) + +(defun lsp-json-rpc-process-queue () + (while (not lsp-json-rpc-done) + (while lsp-json-rpc-queue + (-let (((proc . message) (pop lsp-json-rpc-queue))) + (json-rpc-send + proc message + :null-object nil + :false-object :json-false))) + (with-mutex lsp-json-rpc-mutex + (condition-wait lsp-json-rpc-condition)))) + +(cl-defmethod lsp-process-id (process) (json-rpc-pid process)) + +(cl-defmethod lsp-process-name (_process) "TBD") + +(cl-defmethod lsp-process-kill (process) (json-rpc-shutdown process)) + +(cl-defmethod lsp-process-send (proc message) + (unless lsp-json-rpc-thread + (with-current-buffer (get-buffer-create " *json-rpc*") + (setq lsp-json-rpc-thread (make-thread #'lsp-json-rpc-process-queue "*json-rpc-queue*")))) + + (with-mutex lsp-json-rpc-mutex + (setq lsp-json-rpc-queue (append lsp-json-rpc-queue + (list (cons proc message)))) + (condition-notify lsp-json-rpc-condition))) + +(cl-defmethod lsp-process-cleanup (_proc)) + +(defun lsp-json-rpc-connection (workspace command) + (let ((con (apply #'json-rpc-connection command)) + (object-type (if lsp-use-plists 'plist 'hash-table))) + (with-current-buffer (get-buffer-create " *json-rpc*") + (make-thread + (lambda () + (json-rpc + con + (lambda (result err done) + (run-with-timer + 0.0 + nil + (lambda () + (cond + (result (lsp--parser-on-message result workspace)) + (err (warn "Json parsing failed with the following error: %s" err)) + (done (lsp--handle-process-exit workspace "")))))) + :object-type object-type + :null-object nil + :false-object nil)) + "*json-rpc-connection*")) + (cons con con))) + +(defun lsp-json-rpc-stderr () + (interactive) + (--when-let (pcase (lsp-workspaces) + (`nil (user-error "There are no active servers in the current buffer")) + (`(,workspace) workspace) + (workspaces (lsp--completing-read "Select server: " + workspaces + 'lsp--workspace-print nil t))) + (let ((content (json-rpc-stderr (lsp--workspace-cmd-proc it))) + (buffer (format "*stderr-%s*" (lsp--workspace-print it)) )) + (with-current-buffer (get-buffer-create buffer) + (with-help-window buffer + (insert content)))))) + + +(defun lsp--workspace-print (workspace) + "Visual representation WORKSPACE." + (let* ((proc (lsp--workspace-cmd-proc workspace)) + (status (lsp--workspace-status workspace)) + (server-id (-> workspace lsp--workspace-client lsp--client-server-id symbol-name)) + (pid (lsp-process-id proc))) + + (if (eq 'initialized status) + (format "%s:%s" server-id pid) + (format "%s:%s/%s" server-id pid status)))) + +(defun lsp--map-tree-widget (m) + "Build `tree-widget' from a hash-table or plist M." + (when (lsp-structure-p m) + (let (nodes) + (lsp-map (lambda (k v) + (push `(tree-widget + :tag ,(if (lsp-structure-p v) + (format "%s:" k) + (format "%s: %s" k + (propertize (format "%s" v) + 'face + 'font-lock-string-face))) + :open t + ,@(lsp--map-tree-widget v)) + nodes)) + m) + nodes))) + +(defun lsp-buffer-name (buffer-id) + (if-let ((buffer-name (plist-get buffer-id :buffer-name))) + (funcall buffer-name buffer-id) + (buffer-name buffer-id))) + +(defun lsp--render-workspace (workspace) + "Tree node representation of WORKSPACE." + `(tree-widget :tag ,(lsp--workspace-print workspace) + :open t + (tree-widget :tag ,(propertize "Buffers" 'face 'font-lock-function-name-face) + :open t + ,@(->> workspace + (lsp--workspace-buffers) + (--map `(tree-widget + :tag ,(when (lsp-buffer-live-p it) + (let ((buffer-name (lsp-buffer-name it))) + (if (lsp-with-current-buffer it buffer-read-only) + (propertize buffer-name 'face 'font-lock-constant-face) + buffer-name))))))) + (tree-widget :tag ,(propertize "Capabilities" 'face 'font-lock-function-name-face) + ,@(-> workspace lsp--workspace-server-capabilities lsp--map-tree-widget)))) + +(define-derived-mode lsp-browser-mode special-mode "LspBrowser" + "Define mode for displaying lsp sessions." + (setq-local display-buffer-base-action '(nil . ((inhibit-same-window . t))))) + +(defun lsp-describe-session () + "Describes current `lsp-session'." + (interactive) + (let ((session (lsp-session)) + (buf (get-buffer-create "*lsp session*")) + (root (lsp-workspace-root))) + (with-current-buffer buf + (lsp-browser-mode) + (let ((inhibit-read-only t)) + (erase-buffer) + (--each (lsp-session-folders session) + (widget-create + `(tree-widget + :tag ,(propertize it 'face 'font-lock-keyword-face) + :open t + ,@(->> session + (lsp-session-folder->servers) + (gethash it) + (-map 'lsp--render-workspace))))))) + (pop-to-buffer buf) + (goto-char (point-min)) + (cl-loop for tag = (widget-get (widget-get (widget-at) :node) :tag) + until (or (and root (string= tag root)) (eobp)) + do (goto-char (next-overlay-change (point)))))) + +(defun lsp--session-workspaces (session) + "Get all workspaces that are part of the SESSION." + (-> session lsp-session-folder->servers hash-table-values -flatten -uniq)) + +(defun lsp--find-multiroot-workspace (session client project-root) + "Look for a multiroot connection in SESSION created from CLIENT for +PROJECT-ROOT and BUFFER-MAJOR-MODE." + (when (lsp--client-multi-root client) + (-when-let (multi-root-workspace (->> session + (lsp--session-workspaces) + (--first (eq (-> it lsp--workspace-client lsp--client-server-id) + (lsp--client-server-id client))))) + (with-lsp-workspace multi-root-workspace + (lsp-notify "workspace/didChangeWorkspaceFolders" + (lsp-make-did-change-workspace-folders-params + :event (lsp-make-workspace-folders-change-event + :added (vector (lsp-make-workspace-folder + :uri (lsp--path-to-uri project-root) + :name (f-filename project-root))) + :removed [])))) + + (->> session (lsp-session-folder->servers) (gethash project-root) (cl-pushnew multi-root-workspace)) + (->> session (lsp-session-server-id->folders) (gethash (lsp--client-server-id client)) (cl-pushnew project-root)) + + (lsp--persist-session session) + + (lsp--info "Opened folder %s in workspace %s" project-root (lsp--workspace-print multi-root-workspace)) + (lsp--open-in-workspace multi-root-workspace) + + multi-root-workspace))) + +(defun lsp--ensure-lsp-servers (session clients project-root ignore-multi-folder) + "Ensure that SESSION contain server CLIENTS created for PROJECT-ROOT. +IGNORE-MULTI-FOLDER to ignore multi folder server." + (-map (lambda (client) + (or + (lsp--find-workspace session client project-root) + (unless ignore-multi-folder + (lsp--find-multiroot-workspace session client project-root)) + (lsp--start-connection session client project-root))) + clients)) + +(defun lsp--spinner-stop () + "Stop the spinner in case all of the workspaces are started." + (when (--all? (eq (lsp--workspace-status it) 'initialized) + lsp--buffer-workspaces) + (spinner-stop))) + +(defun lsp--open-in-workspace (workspace) + "Open in existing WORKSPACE." + (if (eq 'initialized (lsp--workspace-status workspace)) + ;; when workspace is initialized just call document did open. + (progn + (with-lsp-workspace workspace + (when-let ((before-document-open-fn (-> workspace + lsp--workspace-client + lsp--client-before-file-open-fn))) + (funcall before-document-open-fn workspace)) + (lsp--text-document-did-open)) + (lsp--spinner-stop)) + ;; when it is not initialized + (lsp--spinner-start) + (cl-pushnew (lsp-current-buffer) (lsp--workspace-buffers workspace)))) + +(defun lsp--find-workspace (session client project-root) + "Find server connection created with CLIENT in SESSION for PROJECT-ROOT." + (when-let ((workspace (->> session + (lsp-session-folder->servers) + (gethash project-root) + (--first (eql (-> it lsp--workspace-client lsp--client-server-id) + (lsp--client-server-id client)))))) + (lsp--open-in-workspace workspace) + workspace)) + +(defun lsp--read-char (prompt &optional options) + "Wrapper for `read-char-from-minibuffer' if Emacs +27. +Fallback to `read-key' otherwise. +PROMPT is the message and OPTIONS the available options." + (if (fboundp 'read-char-from-minibuffer) + (read-char-from-minibuffer prompt options) + (read-key prompt))) + +(defun lsp--find-root-interactively (session) + "Find project interactively. +Returns nil if the project should not be added to the current SESSION." + (condition-case nil + (let* ((project-root-suggestion (or (lsp--suggest-project-root) default-directory)) + (action (lsp--read-char + (format + "%s is not part of any project. + +%s ==> Import project root %s +%s ==> Import project by selecting root directory interactively +%s ==> Import project at current directory %s +%s ==> Do not ask again for the current project by adding %s to lsp-session-folders-blocklist +%s ==> Do not ask again for the current project by selecting ignore path interactively +%s ==> Do nothing: ask again when opening other files from the current project + +Select action: " + (propertize (buffer-name) 'face 'bold) + (propertize "i" 'face 'success) + (propertize project-root-suggestion 'face 'bold) + (propertize "I" 'face 'success) + (propertize "." 'face 'success) + (propertize default-directory 'face 'bold) + (propertize "d" 'face 'warning) + (propertize project-root-suggestion 'face 'bold) + (propertize "D" 'face 'warning) + (propertize "n" 'face 'warning)) + '(?i ?\r ?I ?. ?d ?D ?n)))) + (cl-case action + (?i project-root-suggestion) + (?\r project-root-suggestion) + (?I (read-directory-name "Select workspace folder to add: " + (or project-root-suggestion default-directory) + nil + t)) + (?. default-directory) + (?d (push project-root-suggestion (lsp-session-folders-blocklist session)) + (lsp--persist-session session) + nil) + (?D (push (read-directory-name "Select folder to blocklist: " + (or project-root-suggestion default-directory) + nil + t) + (lsp-session-folders-blocklist session)) + (lsp--persist-session session) + nil) + (t nil))) + (quit))) + +(declare-function tramp-file-name-host "ext:tramp" (file) t) +(declare-function tramp-dissect-file-name "ext:tramp" (file &optional nodefault)) + +(defun lsp--files-same-host (f1 f2) + "Predicate on whether or not two files are on the same host." + (or (not (or (file-remote-p f1) (file-remote-p f2))) + (and (file-remote-p f1) + (file-remote-p f2) + (progn (require 'tramp) + (equal (tramp-file-name-host (tramp-dissect-file-name f1)) + (tramp-file-name-host (tramp-dissect-file-name f2))))))) + +(defun lsp-find-session-folder (session file-name) + "Look in the current SESSION for folder containing FILE-NAME." + (let ((file-name-canonical (lsp-f-canonical file-name))) + (->> session + (lsp-session-folders) + (--filter (and (lsp--files-same-host it file-name-canonical) + (or (lsp-f-same? it file-name-canonical) + (and (f-dir? it) + (lsp-f-ancestor-of? it file-name-canonical))))) + (--max-by (> (length it) + (length other)))))) + +(defun lsp-find-workspace (server-id &optional file-name) + "Find workspace for SERVER-ID for FILE-NAME." + (-when-let* ((session (lsp-session)) + (folder->servers (lsp-session-folder->servers session)) + (workspaces (if file-name + (gethash (lsp-find-session-folder session file-name) folder->servers) + (lsp--session-workspaces session)))) + + (--first (eq (lsp--client-server-id (lsp--workspace-client it)) server-id) workspaces))) + +(defun lsp--calculate-root (session file-name) + "Calculate project root for FILE-NAME in SESSION." + (and + (->> session + (lsp-session-folders-blocklist) + (--first (and (lsp--files-same-host it file-name) + (lsp-f-ancestor-of? it file-name) + (prog1 t + (lsp--info "File %s is in blocklisted directory %s" file-name it)))) + not) + (or + (when lsp-auto-guess-root + (lsp--suggest-project-root)) + (unless lsp-guess-root-without-session + (lsp-find-session-folder session file-name)) + (unless lsp-auto-guess-root + (when-let ((root-folder (lsp--find-root-interactively session))) + (if (or (not (f-equal? root-folder (expand-file-name "~/"))) + (yes-or-no-p + (concat + (propertize "[WARNING] " 'face 'warning) + "You are trying to import your home folder as project root. This may cause performance issue because some language servers (python, lua, etc) will try to scan all files under project root. To avoid that you may: + +1. Use `I' option from the interactive project import to select subfolder(e. g. `~/foo/bar' instead of `~/'). +2. If your file is under `~/' then create a subfolder and move that file in this folder. + +Type `No' to go back to project selection. +Type `Yes' to confirm `HOME' as project root. +Type `C-g' to cancel project import process and stop `lsp'"))) + root-folder + (lsp--calculate-root session file-name))))))) + +(defun lsp--try-open-in-library-workspace () + "Try opening current file as library file in any of the active workspace. +The library folders are defined by each client for each of the active workspace." + (when-let ((workspace (->> (lsp-session) + (lsp--session-workspaces) + ;; Sort the last active workspaces first as they are more likely to be + ;; the correct ones, especially when jumping to a definition. + (-sort (lambda (a _b) + (-contains? lsp--last-active-workspaces a))) + (--first + (and (-> it lsp--workspace-client lsp--supports-buffer?) + (when-let ((library-folders-fn + (-> it lsp--workspace-client lsp--client-library-folders-fn))) + (-first (lambda (library-folder) + (lsp-f-ancestor-of? library-folder (buffer-file-name))) + (funcall library-folders-fn it)))))))) + (lsp--open-in-workspace workspace) + (view-mode t) + (lsp--info "Opening read-only library file %s." (buffer-file-name)) + (list workspace))) + +(defun lsp--persist-session (session) + "Persist SESSION to `lsp-session-file'." + (lsp--persist lsp-session-file (make-lsp-session + :folders (lsp-session-folders session) + :folders-blocklist (lsp-session-folders-blocklist session) + :server-id->folders (lsp-session-server-id->folders session)))) + +(defun lsp--try-project-root-workspaces (ask-for-client ignore-multi-folder) + "Try create opening file as a project file. +When IGNORE-MULTI-FOLDER is t the lsp mode will start new +language server even if there is language server which can handle +current language. When IGNORE-MULTI-FOLDER is nil current file +will be opened in multi folder language server if there is +such." + (-let ((session (lsp-session))) + (-if-let (clients (if ask-for-client + (list (lsp--completing-read "Select server to start: " + (ht-values lsp-clients) + (-compose 'symbol-name 'lsp--client-server-id) nil t)) + (lsp--find-clients))) + (-if-let (project-root (-some-> session + (lsp--calculate-root (buffer-file-name)) + (lsp-f-canonical))) + (progn + ;; update project roots if needed and persist the lsp session + (unless (-contains? (lsp-session-folders session) project-root) + (cl-pushnew project-root (lsp-session-folders session)) + (lsp--persist-session session)) + (lsp--ensure-lsp-servers session clients project-root ignore-multi-folder)) + (lsp--warn "%s not in project or it is blocklisted." (buffer-name)) + nil) + (lsp--warn "No LSP server for %s(check *lsp-log*)." major-mode) + nil))) + +(defun lsp-shutdown-workspace () + "Shutdown language server." + (interactive) + (--when-let (pcase (lsp-workspaces) + (`nil (user-error "There are no active servers in the current buffer")) + (`(,workspace) (when (y-or-n-p (format "Are you sure you want to stop the server %s?" + (lsp--workspace-print workspace))) + workspace)) + (workspaces (lsp--completing-read "Select server: " + workspaces + 'lsp--workspace-print nil t))) + (lsp-workspace-shutdown it))) + +(make-obsolete 'lsp-shutdown-workspace 'lsp-workspace-shutdown "lsp-mode 6.1") + +(defcustom lsp-auto-select-workspace t + "Shutdown or restart a single workspace. +If set and the current buffer has only a single workspace +associated with it, `lsp-shutdown-workspace' and +`lsp-restart-workspace' will act on it without asking." + :type 'boolean + :group 'lsp-mode) + +(defun lsp--read-workspace () + "Ask the user to select a workspace. +Errors if there are none." + (pcase (lsp-workspaces) + (`nil (error "No workspaces associated with the current buffer")) + ((and `(,workspace) (guard lsp-auto-select-workspace)) workspace) + (workspaces (lsp--completing-read "Select workspace: " workspaces + #'lsp--workspace-print nil t)))) + +(defun lsp-workspace-shutdown (workspace) + "Shut the workspace WORKSPACE and the language server associated with it" + (interactive (list (lsp--read-workspace))) + (lsp--warn "Stopping %s" (lsp--workspace-print workspace)) + (with-lsp-workspace workspace (lsp--shutdown-workspace))) + +(defun lsp-disconnect () + "Disconnect the buffer from the language server." + (interactive) + (lsp--text-document-did-close t) + (lsp-managed-mode -1) + (lsp-mode -1) + (setq lsp--buffer-workspaces nil) + (lsp--info "Disconnected")) + +(defun lsp-restart-workspace () + (interactive) + (--when-let (pcase (lsp-workspaces) + (`nil (user-error "There are no active servers in the current buffer")) + (`(,workspace) workspace) + (workspaces (lsp--completing-read "Select server: " + workspaces + 'lsp--workspace-print nil t))) + (lsp-workspace-restart it))) + +(make-obsolete 'lsp-restart-workspace 'lsp-workspace-restart "lsp-mode 6.1") + +(defun lsp-workspace-restart (workspace) + "Restart the workspace WORKSPACE and the language server associated with it" + (interactive (list (lsp--read-workspace))) + (lsp--warn "Restarting %s" (lsp--workspace-print workspace)) + (with-lsp-workspace workspace (lsp--shutdown-workspace t))) + +;;;###autoload +(defun lsp (&optional arg) + "Entry point for the server startup. +When ARG is t the lsp mode will start new language server even if +there is language server which can handle current language. When +ARG is nil current file will be opened in multi folder language +server if there is such. When `lsp' is called with prefix +argument ask the user to select which language server to start." + (interactive "P") + + (lsp--require-packages) + + (when (buffer-file-name) + (let (clients + (matching-clients (lsp--filter-clients + (-andfn #'lsp--supports-buffer? + #'lsp--server-binary-present?)))) + (cond + (matching-clients + (when (setq lsp--buffer-workspaces + (or (and + ;; Don't open as library file if file is part of a project. + (not (lsp-find-session-folder (lsp-session) (buffer-file-name))) + (lsp--try-open-in-library-workspace)) + (lsp--try-project-root-workspaces (equal arg '(4)) + (and arg (not (equal arg 1)))))) + (lsp-mode 1) + (when lsp-auto-configure (lsp--auto-configure)) + (setq lsp-buffer-uri (lsp--buffer-uri)) + (lsp--info "Connected to %s." + (apply 'concat (--map (format "[%s %s]" + (lsp--workspace-print it) + (lsp--workspace-root it)) + lsp--buffer-workspaces))))) + ;; look for servers which are currently being downloaded. + ((setq clients (lsp--filter-clients (-andfn #'lsp--supports-buffer? + #'lsp--client-download-in-progress?))) + (lsp--info "There are language server(%s) installation in progress. +The server(s) will be started in the buffer when it has finished." + (-map #'lsp--client-server-id clients)) + (seq-do (lambda (client) + (cl-pushnew (current-buffer) (lsp--client-buffers client))) + clients)) + ;; look for servers to install + ((setq clients (lsp--filter-clients + (-andfn #'lsp--supports-buffer? + (-const lsp-enable-suggest-server-download) + #'lsp--client-download-server-fn + (-not #'lsp--client-download-in-progress?)))) + (let ((client (lsp--completing-read + (concat "Unable to find installed server supporting this file. " + "The following servers could be installed automatically: ") + clients + (-compose #'symbol-name #'lsp--client-server-id) + nil + t))) + (cl-pushnew (current-buffer) (lsp--client-buffers client)) + (lsp--install-server-internal client))) + ;; ignore other warnings + ((not lsp-warn-no-matched-clients) + nil) + ;; automatic installation disabled + ((setq clients (unless matching-clients + (lsp--filter-clients (-andfn #'lsp--supports-buffer? + #'lsp--client-download-server-fn + (-not (-const lsp-enable-suggest-server-download)) + (-not #'lsp--server-binary-present?))))) + (lsp--warn "The following servers support current file but automatic download is disabled: %s +\(If you have already installed the server check *lsp-log*)." + (mapconcat (lambda (client) + (symbol-name (lsp--client-server-id client))) + clients + " "))) + ;; no clients present + ((setq clients (unless matching-clients + (lsp--filter-clients (-andfn #'lsp--supports-buffer? + (-not #'lsp--server-binary-present?))))) + (lsp--warn "The following servers support current file but do not have automatic installation: %s +You may find the installation instructions at https://emacs-lsp.github.io/lsp-mode/page/languages. +\(If you have already installed the server check *lsp-log*)." + (mapconcat (lambda (client) + (symbol-name (lsp--client-server-id client))) + clients + " "))) + ;; no matches + ((-> #'lsp--supports-buffer? lsp--filter-clients not) + (lsp--error "There are no language servers supporting current mode `%s' registered with `lsp-mode'. +This issue might be caused by: +1. The language you are trying to use does not have built-in support in `lsp-mode'. You must install the required support manually. Examples of this are `lsp-java' or `lsp-metals'. +2. The language server that you expect to run is not configured to run for major mode `%s'. You may check that by checking the `:major-modes' that are passed to `lsp-register-client'. +3. `lsp-mode' doesn't have any integration for the language behind `%s'. Refer to https://emacs-lsp.github.io/lsp-mode/page/languages and https://langserver.org/ . +4. You are over `tramp'. In this case follow https://emacs-lsp.github.io/lsp-mode/page/remote/. +5. You have disabled the `lsp-mode' clients for that file. (Check `lsp-enabled-clients' and `lsp-disabled-clients'). +You can customize `lsp-warn-no-matched-clients' to disable this message." + major-mode major-mode major-mode)))))) + +(defun lsp--buffer-visible-p () + "Return non nil if current buffer is visible." + (or (buffer-modified-p) (get-buffer-window nil t))) + +(defun lsp--init-if-visible () + "Run `lsp' for the current buffer if the buffer is visible. +Returns non nil if `lsp' was run for the buffer." + (when (lsp--buffer-visible-p) + (remove-hook 'window-configuration-change-hook #'lsp--init-if-visible t) + (lsp) + t)) + +;;;###autoload +(defun lsp-deferred () + "Entry point that defers server startup until buffer is visible. +`lsp-deferred' will wait until the buffer is visible before invoking `lsp'. +This avoids overloading the server with many files when starting Emacs." + ;; Workspace may not be initialized yet. Use a buffer local variable to + ;; remember that we deferred loading of this buffer. + (setq lsp--buffer-deferred t) + (let ((buffer (current-buffer))) + ;; Avoid false positives as desktop-mode restores buffers by deferring + ;; visibility check until the stack clears. + (run-with-idle-timer 0 nil (lambda () + (when (buffer-live-p buffer) + (with-current-buffer buffer + (unless (lsp--init-if-visible) + (add-hook 'window-configuration-change-hook #'lsp--init-if-visible nil t)))))))) + + + +(defvar lsp-file-truename-cache (ht)) + +(defmacro lsp-with-cached-filetrue-name (&rest body) + "Executes BODY caching the `file-truename' calls." + `(let ((old-fn (symbol-function 'file-truename))) + (unwind-protect + (progn + (fset 'file-truename + (lambda (file-name &optional counter prev-dirs) + (or (gethash file-name lsp-file-truename-cache) + (puthash file-name (apply old-fn (list file-name counter prev-dirs)) + lsp-file-truename-cache)))) + ,@body) + (fset 'file-truename old-fn)))) + + +(defun lsp-virtual-buffer-call (key &rest args) + (when lsp--virtual-buffer + (when-let ((fn (plist-get lsp--virtual-buffer key))) + (apply fn args)))) + +(defun lsp-translate-column (column) + "Translate COLUMN taking into account virtual buffers." + (or (lsp-virtual-buffer-call :real->virtual-char column) + column)) + +(defun lsp-translate-line (line) + "Translate LINE taking into account virtual buffers." + (or (lsp-virtual-buffer-call :real->virtual-line line) + line)) + + +;; lsp internal validation. + +(defmacro lsp--doctor (&rest checks) + `(-let [buf (current-buffer)] + (with-current-buffer (get-buffer-create "*lsp-performance*") + (with-help-window (current-buffer) + ,@(-map (-lambda ((msg form)) + `(insert (format "%s: %s\n" ,msg + (let ((res (with-current-buffer buf + ,form))) + (cond + ((eq res :optional) (propertize "OPTIONAL" 'face 'warning)) + (res (propertize "OK" 'face 'success)) + (t (propertize "ERROR" 'face 'error))))))) + (-partition 2 checks)))))) + +(define-obsolete-function-alias 'lsp-diagnose + 'lsp-doctor "lsp-mode 8.0.0") + +(defun lsp-doctor () + "Validate performance settings." + (interactive) + (lsp--doctor + "Checking for Native JSON support" (functionp 'json-serialize) + "Check emacs supports `read-process-output-max'" (boundp 'read-process-output-max) + "Check `read-process-output-max' default has been changed from 4k" + (and (boundp 'read-process-output-max) + (> read-process-output-max 4096)) + "Byte compiled against Native JSON (recompile lsp-mode if failing when Native JSON available)" + (condition-case _err + (progn (lsp--make-message (list "a" "b")) + nil) + (error t)) + "`gc-cons-threshold' increased?" (> gc-cons-threshold 800000) + "Using `plist' for deserialized objects? (refer to https://emacs-lsp.github.io/lsp-mode/page/performance/#use-plists-for-deserialization)" (or lsp-use-plists :optional) + "Using emacs 28+ with native compilation?" + (or (and (fboundp 'native-comp-available-p) + (native-comp-available-p)) + :optional))) + +(declare-function package-version-join "ext:package") +(declare-function package-desc-version "ext:package") +(declare-function package--alist "ext:package") + +(defun lsp-version () + "Return string describing current version of `lsp-mode'." + (interactive) + (unless (featurep 'package) + (require 'package)) + (let ((ver (format "lsp-mode %s, Emacs %s, %s" + (package-version-join + (package-desc-version + (car (alist-get 'lsp-mode (package--alist))))) + emacs-version + system-type))) + (if (called-interactively-p 'interactive) + (lsp--info "%s" ver) + ver))) + + + +;; org-mode/virtual-buffer + +(declare-function org-babel-get-src-block-info "ext:ob-core") +(declare-function org-do-remove-indentation "ext:org-macs") +(declare-function org-src-get-lang-mode "ext:org-src") +(declare-function org-element-context "ext:org-element") + +(defun lsp--virtual-buffer-update-position () + (-if-let (virtual-buffer (-first (-lambda ((&plist :in-range)) + (funcall in-range)) + lsp--virtual-buffer-connections)) + (unless (equal virtual-buffer lsp--virtual-buffer) + (lsp-org)) + (when lsp-managed-mode + (lsp-managed-mode -1) + (lsp-mode -1) + (setq lsp--buffer-workspaces nil) + (setq lsp--virtual-buffer nil) + (setq lsp-buffer-uri nil) + + ;; force refresh of diagnostics + (run-hooks 'lsp-after-diagnostics-hook)))) + +(defun lsp-virtual-buffer-on-change (start end length) + "Adjust on change event to be executed against the proper language server." + (let ((max-point (max end + (or (plist-get lsp--before-change-vals :end) 0) + (+ start length)))) + (when-let ((virtual-buffer (-first (lambda (vb) + (let ((lsp--virtual-buffer vb)) + (and (lsp-virtual-buffer-call :in-range start) + (lsp-virtual-buffer-call :in-range max-point)))) + lsp--virtual-buffer-connections))) + (lsp-with-current-buffer virtual-buffer + (lsp-on-change start end length + (lambda (&rest _) + (list :range (lsp--range (list :character 0 :line 0) + lsp--virtual-buffer-point-max) + :text (lsp--buffer-content)))))))) + +(defun lsp-virtual-buffer-before-change (start _end) + (when-let ((virtual-buffer (-first (lambda (vb) + (lsp-with-current-buffer vb + (lsp-virtual-buffer-call :in-range start))) + lsp--virtual-buffer-connections))) + (lsp-with-current-buffer virtual-buffer + (setq lsp--virtual-buffer-point-max + (lsp--point-to-position (lsp-virtual-buffer-call :last-point)))))) + +(defun lsp-patch-on-change-event () + (remove-hook 'after-change-functions #'lsp-on-change t) + (add-hook 'after-change-functions #'lsp-virtual-buffer-on-change nil t) + (add-hook 'before-change-functions #'lsp-virtual-buffer-before-change nil t)) + +(defun lsp-kill-virtual-buffers () + (mapc #'lsp-virtual-buffer-disconnect lsp--virtual-buffer-connections)) + +(defun lsp--move-point-in-indentation (point indentation) + (save-excursion + (goto-char point) + (if (<= point (+ (line-beginning-position) indentation)) + (line-beginning-position) + point))) + +(declare-function flycheck-checker-supports-major-mode-p "ext:flycheck") +(declare-function flycheck-add-mode "ext:flycheck") +(declare-function lsp-diagnostics-lsp-checker-if-needed "lsp-diagnostics") + +(defalias 'lsp-client-download-server-fn 'lsp--client-download-server-fn) + +(defun lsp-flycheck-add-mode (mode) + "Register flycheck support for MODE." + (lsp-diagnostics-lsp-checker-if-needed) + (unless (flycheck-checker-supports-major-mode-p 'lsp mode) + (flycheck-add-mode 'lsp mode))) + +(defun lsp-progress-spinner-type () + "Retrieve the spinner type value, if value is not a symbol of `spinner-types +defaults to `progress-bar." + (or (car (assoc lsp-progress-spinner-type spinner-types)) 'progress-bar)) + +(defun lsp-org () + (interactive) + (-if-let ((virtual-buffer &as &plist :workspaces) (-first (-lambda ((&plist :in-range)) + (funcall in-range)) + lsp--virtual-buffer-connections)) + (unless (equal lsp--virtual-buffer virtual-buffer) + (setq lsp--buffer-workspaces workspaces) + (setq lsp--virtual-buffer virtual-buffer) + (setq lsp-buffer-uri nil) + (lsp-mode 1) + (lsp-managed-mode 1) + (lsp-patch-on-change-event)) + + (save-excursion + (-let* (virtual-buffer + (wcb (lambda (f) + (with-current-buffer (plist-get virtual-buffer :buffer) + (-let* (((&plist :major-mode :buffer-file-name + :goto-buffer :workspaces) virtual-buffer) + (lsp--virtual-buffer virtual-buffer) + (lsp--buffer-workspaces workspaces)) + (save-excursion + (funcall goto-buffer) + (funcall f)))))) + ((&plist :begin :end :post-blank :language) (cl-second (org-element-context))) + ((&alist :tangle file-name) (cl-third (org-babel-get-src-block-info 'light))) + + (file-name (if file-name + (f-expand file-name) + (user-error "You should specify file name in the src block header."))) + (begin-marker (progn + (goto-char begin) + (forward-line) + (set-marker (make-marker) (point)))) + (end-marker (progn + (goto-char end) + (forward-line (1- (- post-blank))) + (set-marker (make-marker) (1+ (point))))) + (buf (current-buffer)) + (src-block (buffer-substring-no-properties begin-marker + (1- end-marker))) + (indentation (with-temp-buffer + (insert src-block) + + (goto-char (point-min)) + (let ((indentation (current-indentation))) + (plist-put lsp--virtual-buffer :indentation indentation) + (org-do-remove-indentation) + (goto-char (point-min)) + (- indentation (current-indentation)))))) + (add-hook 'post-command-hook #'lsp--virtual-buffer-update-position nil t) + + (when (fboundp 'flycheck-add-mode) + (lsp-flycheck-add-mode 'org-mode)) + + (setq lsp--virtual-buffer + (list + :in-range (lambda (&optional point) + (<= begin-marker (or point (point)) (1- end-marker))) + :goto-buffer (lambda () (goto-char begin-marker)) + :buffer-string + (lambda () + (let ((src-block (buffer-substring-no-properties + begin-marker + (1- end-marker)))) + (with-temp-buffer + (insert src-block) + + (goto-char (point-min)) + (while (not (eobp)) + (delete-region (point) (if (> (+ (point) indentation) (line-end-position)) + (line-end-position) + (+ (point) indentation))) + (forward-line)) + (buffer-substring-no-properties (point-min) + (point-max))))) + :buffer buf + :begin begin-marker + :end end-marker + :indentation indentation + :last-point (lambda () (1- end-marker)) + :cur-position (lambda () + (lsp-save-restriction-and-excursion + (list :line (- (lsp--cur-line) + (lsp--cur-line begin-marker)) + :character (let ((character (- (point) + (line-beginning-position) + indentation))) + (if (< character 0) + 0 + character))))) + :line/character->point (-lambda (line character) + (-let [inhibit-field-text-motion t] + (+ indentation + (lsp-save-restriction-and-excursion + (goto-char begin-marker) + (forward-line line) + (-let [line-end (line-end-position)] + (if (> character (- line-end (point))) + line-end + (forward-char character) + (point))))))) + :major-mode (org-src-get-lang-mode language) + :buffer-file-name file-name + :buffer-uri (lsp--path-to-uri file-name) + :with-current-buffer wcb + :buffer-live? (lambda (_) (buffer-live-p buf)) + :buffer-name (lambda (_) + (propertize (format "%s(%s:%s)%s" + (buffer-name buf) + begin-marker + end-marker + language) + 'face 'italic)) + :real->virtual-line (lambda (line) + (+ line (line-number-at-pos begin-marker) -1)) + :real->virtual-char (lambda (char) (+ char indentation)) + :cleanup (lambda () + (set-marker begin-marker nil) + (set-marker end-marker nil)))) + (setf virtual-buffer lsp--virtual-buffer) + (puthash file-name virtual-buffer lsp--virtual-buffer-mappings) + (push virtual-buffer lsp--virtual-buffer-connections) + + ;; TODO: tangle only connected sections + (add-hook 'after-save-hook 'org-babel-tangle nil t) + (add-hook 'lsp-after-open-hook #'lsp-patch-on-change-event nil t) + (add-hook 'kill-buffer-hook #'lsp-kill-virtual-buffers nil t) + + (setq lsp--buffer-workspaces + (lsp-with-current-buffer virtual-buffer + (lsp) + (plist-put virtual-buffer :workspaces (lsp-workspaces)) + (lsp-workspaces))))))) + +(defun lsp-virtual-buffer-disconnect (virtual-buffer) + (interactive (list (or + lsp--virtual-buffer + (when lsp--virtual-buffer-connections + (lsp--completing-read "Select virtual buffer to disconnect: " + lsp--virtual-buffer-connections + (-lambda ((&plist :buffer-file-name)) + buffer-file-name)))))) + (-if-let ((&plist :buffer-file-name file-name :cleanup) virtual-buffer) + (progn + (lsp-with-current-buffer virtual-buffer + (lsp--text-document-did-close)) + (setq lsp--virtual-buffer-connections (-remove-item virtual-buffer lsp--virtual-buffer-connections)) + (when (eq virtual-buffer lsp--virtual-buffer) + (setf lsp--virtual-buffer nil)) + (when cleanup (funcall cleanup)) + (remhash file-name lsp--virtual-buffer-mappings) + + (lsp--virtual-buffer-update-position) + (lsp--info "Disconnected from buffer %s" file-name)) + (lsp--error "Nothing to disconnect from?"))) + + +;; inlay hints + +(defface lsp-inlay-hint-face + '((t :inherit font-lock-comment-face)) + "The face to use for the JavaScript inlays." + :group 'lsp-mode + :package-version '(lsp-mode . "9.0.0")) + +(defface lsp-inlay-hint-type-face + '((t :inherit lsp-inlay-hint-face)) + "Face for inlay type hints (e.g. inferred variable types)." + :group 'lsp-mode + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-inlay-hint-type-format "%s" + "Format string for variable inlays (part of the inlay face)." + :type '(string :tag "String") + :group 'lsp-mode + :package-version '(lsp-mode . "9.0.0")) + +(defface lsp-inlay-hint-parameter-face + '((t :inherit lsp-inlay-hint-face)) + "Face for inlay parameter hints (e.g. function parameter names at +call-site)." + :group 'lsp-mode + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-inlay-hint-param-format "%s" + "Format string for parameter inlays (part of the inlay face)." + :type '(string :tag "String") + :group 'lsp-mode + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-update-inlay-hints-on-scroll t + "If non-nil update inlay hints immediately when scrolling or +modifying window sizes." + :type 'boolean + :package-version '(lsp-mode . "9.0.0")) + +(defun lsp--format-inlay (text kind) + (cond + ((eql kind lsp/inlay-hint-kind-type-hint) (format lsp-inlay-hint-type-format text)) + ((eql kind lsp/inlay-hint-kind-parameter-hint) (format lsp-inlay-hint-param-format text)) + (t text))) + +(defun lsp--face-for-inlay (kind) + (cond + ((eql kind lsp/inlay-hint-kind-type-hint) 'lsp-inlay-hint-type-face) + ((eql kind lsp/inlay-hint-kind-parameter-hint) 'lsp-inlay-hint-parameter-face) + (t 'lsp-inlay-hint-face))) + +(defun lsp--update-inlay-hints-scroll-function (window start) + (lsp-update-inlay-hints start (window-end window t))) + +(defun lsp--update-inlay-hints () + (lsp-update-inlay-hints (window-start) (window-end nil t))) + +(defun lsp--label-from-inlay-hints-response (label) + "Returns a string label built from an array of +InlayHintLabelParts or the argument itself if it's already a +string." + (cl-typecase label + (string label) + (vector + (string-join (mapcar (lambda (part) + (-let (((&InlayHintLabelPart :value) part)) + value)) + label))))) + +(defun lsp-update-inlay-hints (start end) + (lsp-request-async + "textDocument/inlayHint" + (lsp-make-inlay-hints-params + :text-document (lsp--text-document-identifier) + :range (lsp-make-range :start + (lsp-point-to-position start) + :end + (lsp-point-to-position end))) + (lambda (res) + (lsp--remove-overlays 'lsp-inlay-hint) + (dolist (hint res) + (-let* (((&InlayHint :label :position :kind? :padding-left? :padding-right?) hint) + (kind (or kind? lsp/inlay-hint-kind-type-hint)) + (label (lsp--label-from-inlay-hints-response label)) + (pos (lsp--position-to-point position)) + (overlay (make-overlay pos pos nil 'front-advance 'end-advance))) + (when (stringp label) + (overlay-put overlay 'lsp-inlay-hint t) + (overlay-put overlay 'before-string + (format "%s%s%s" + (if padding-left? " " "") + (propertize (lsp--format-inlay label kind) + 'font-lock-face (lsp--face-for-inlay kind)) + (if padding-right? " " ""))))))) + :mode 'tick)) + +(define-minor-mode lsp-inlay-hints-mode + "Mode for displaying inlay hints." + :lighter nil + (cond + ((and lsp-inlay-hints-mode lsp--buffer-workspaces) + (add-hook 'lsp-on-idle-hook #'lsp--update-inlay-hints nil t) + (when lsp-update-inlay-hints-on-scroll + (add-to-list (make-local-variable 'window-scroll-functions) + #'lsp--update-inlay-hints-scroll-function))) + (t + (lsp--remove-overlays 'lsp-inlay-hint) + (remove-hook 'lsp-on-idle-hook #'lsp--update-inlay-hints t) + (setf window-scroll-functions + (delete #'lsp--update-inlay-hints-scroll-function window-scroll-functions))))) + + + +;;;###autoload +(defun lsp-start-plain () + "Start `lsp-mode' using minimal configuration using the latest `melpa' version +of the packages. + +In case the major-mode that you are using for " + (interactive) + (let ((start-plain (make-temp-file "plain" nil ".el"))) + (url-copy-file "https://raw.githubusercontent.com/emacs-lsp/lsp-mode/master/scripts/lsp-start-plain.el" + start-plain t) + (async-shell-command + (format "%s -q -l %s %s" + (expand-file-name invocation-name invocation-directory) + start-plain + (or (buffer-file-name) "")) + (generate-new-buffer " *lsp-start-plain*")))) + + + +(provide 'lsp-mode) +;;; lsp-mode.el ends here diff --git a/emacs/elpa/lsp-mode-20240531.2326/lsp-mode.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-mode.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-modeline.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-modeline.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-modeline.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-modeline.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-mojo.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-mojo.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-mojo.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-mojo.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-move.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-move.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-move.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-move.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-nginx.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-nginx.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-nginx.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-nginx.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-nim.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-nim.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-nim.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-nim.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-nix.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-nix.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-nix.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-nix.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-nushell.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-nushell.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-nushell.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-nushell.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-ocaml.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-ocaml.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-ocaml.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-ocaml.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-openscad.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-openscad.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-openscad.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-openscad.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-perl.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-perl.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-perl.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-perl.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-perlnavigator.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-perlnavigator.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-perlnavigator.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-perlnavigator.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-php.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-php.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-php.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-php.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-pls.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-pls.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-pls.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-pls.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-prolog.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-prolog.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-prolog.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-prolog.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240531.2326/lsp-protocol.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-protocol.el @@ -0,0 +1,799 @@ +;;; lsp-protocol.el --- Language Sever Protocol Bindings -*- lexical-binding: t; -*- + +;; Copyright (C) 2020 Ivan Yonchovski + +;; Author: Ivan Yonchovski <yyoncho@gmail.com> +;; Keywords: convenience + +;; 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 <https://www.gnu.org/licenses/>. + +;;; Commentary: + +;; Autogenerated bindings from lsp4j using +;; https://github.com/victools/jsonschema-generator+scripts to generate +;; scripts/generated.protocol.schema.json and then +;; scripts/lsp-generate-bindings.el + +;;; Code: + +(require 'cl-lib) +(require 'dash) +(require 'ht) +(require 's) +(require 'json) + +(eval-and-compile + (defun lsp-keyword->symbol (keyword) + "Convert a KEYWORD to symbol." + (intern (substring (symbol-name keyword) 1))) + + (defun lsp-keyword->string (keyword) + "Convert a KEYWORD to string." + (substring (symbol-name keyword) 1)) + + (defvar lsp-use-plists (getenv "LSP_USE_PLISTS"))) + +(defmacro lsp-interface (&rest interfaces) + "Generate LSP bindings from INTERFACES triplet. + +Example usage with `dash`. + +\(-let [(&ApplyWorkspaceEditResponse + :failure-reason?) (ht (\"failureReason\" \"...\"))] + failure-reason?) + +\(fn (INTERFACE-NAME-1 REQUIRED-FIELDS-1 OPTIONAL-FIELDS-1) (INTERFACE-NAME-2 REQUIRED-FIELDS-2 OPTIONAL-FIELDS-2) ...)" + (with-case-table ascii-case-table + (->> interfaces + (-map (-lambda ((interface required optional)) + (let ((params (nconc + (-map (lambda (param-name) + (cons + (intern (concat ":" (s-dashed-words (symbol-name param-name)) "?")) + param-name)) + optional) + (-map (lambda (param-name) + (cons (intern (concat ":" (s-dashed-words (symbol-name param-name)))) + param-name)) + required)))) + (cl-list* + `(defun ,(intern (format "dash-expand:&%s" interface)) (key source) + (unless (or (member key ',(-map #'cl-first params)) + (s-starts-with? ":_" (symbol-name key))) + (error "Unknown key: %s. Available keys: %s" key ',(-map #'cl-first params))) + ,(if lsp-use-plists + ``(plist-get ,source + ,(if (s-starts-with? ":_" (symbol-name key)) + key + (cl-rest (assoc key ',params)))) + ``(gethash ,(if (s-starts-with? ":_" (symbol-name key)) + (substring (symbol-name key) 1) + (substring (symbol-name + (cl-rest (assoc key ',params))) + 1)) + ,source))) + `(defun ,(intern (format "dash-expand:&%s?" interface)) (key source) + (unless (member key ',(-map #'cl-first params)) + (error "Unknown key: %s. Available keys: %s" key ',(-map #'cl-first params))) + ,(if lsp-use-plists + ``(plist-get ,source + ,(if (s-starts-with? ":_" (symbol-name key)) + key + (cl-rest (assoc key ',params)))) + ``(when (ht? ,source) + (gethash ,(substring (symbol-name + (cl-rest (assoc key ',params))) + 1) + ,source)))) + + `(defun ,(intern (format "lsp-%s?" (s-dashed-words (symbol-name interface)))) (object) + (cond + ((ht? object) + (-all? (let ((keys (ht-keys object))) + (lambda (prop) + (member prop keys))) + ',(-map (lambda (field-name) + (substring (symbol-name field-name) 1)) + required))) + ((listp object) (-all? (lambda (prop) + (plist-member object prop)) + ',required)))) + `(cl-defun ,(intern (format "lsp-make-%s" (s-dashed-words (symbol-name interface)))) + (&rest plist &key ,@(-map (-lambda ((key)) + (intern (substring (symbol-name key) 1))) params) + &allow-other-keys) + (ignore ,@(-map (-lambda ((key)) + (intern (substring (symbol-name key) 1))) params)) + ,(format "Constructs %s from `plist.' +Allowed params: %s" interface (reverse (-map #'cl-first params))) + ,(if lsp-use-plists + `(-mapcat (-lambda ((key value)) + (list (or (cl-rest (assoc key ',params)) key) value)) + (-partition 2 plist)) + `(let (($$result (ht))) + (mapc (-lambda ((key value)) + (puthash (lsp-keyword->string (or (cl-rest (assoc key ',params)) + key)) + value + $$result)) + (-partition 2 plist)) + $$result))) + `(pcase-defmacro ,interface (&rest property-bindings) + ,(if lsp-use-plists + ``(and + (pred listp) + ;; Check if all the types required by the + ;; interface exist in the expr-val. + ,@(-map + (lambda (key) + `(pred + (lambda (plist) + (plist-member plist ,key)))) + ',required) + ;; Recursively generate the bindings. + ,@(let ((current-list property-bindings) + (output-bindings nil)) + ;; Invariant: while current-list is + ;; non-nil, the car of current-list is + ;; always of the form :key, while the + ;; cadr of current-list is either a) + ;; nil, b) of the form :key-next or c) + ;; a pcase pattern that can + ;; recursively match an expression. + (while current-list + (-let* (((curr-binding-as-keyword next-entry . _) current-list) + (curr-binding-as-camelcased-symbol + (or (alist-get curr-binding-as-keyword ',params) + (error "Unknown key: %s. Available keys: %s" + (symbol-name curr-binding-as-keyword) + ',(-map #'cl-first params)))) + (bound-name (lsp-keyword->symbol curr-binding-as-keyword)) + (next-entry-is-key-or-nil + (and (symbolp next-entry) + (or (null next-entry) + (s-starts-with? ":" (symbol-name next-entry)))))) + (cond + ;; If the next-entry is either a + ;; plist-key or nil, then bind to + ;; bound-name the value corresponding + ;; to the camelcased symbol. Pop + ;; current-list once. + (next-entry-is-key-or-nil + (push `(app (lambda (plist) + (plist-get plist ,curr-binding-as-camelcased-symbol)) + ,bound-name) + output-bindings) + (setf current-list (cdr current-list))) + ;; Otherwise, next-entry is a pcase + ;; pattern we recursively match to the + ;; expression. This can in general + ;; create additional bindings that we + ;; persist in the top level of + ;; bindings. We pop current-list + ;; twice. + (t + (push `(app (lambda (plist) + (plist-get plist ,curr-binding-as-camelcased-symbol)) + ,next-entry) + output-bindings) + (setf current-list (cddr current-list)))))) + output-bindings)) + ``(and + (pred ht?) + ,@(-map + (lambda (key) + `(pred + (lambda (hash-table) + (ht-contains? hash-table ,(lsp-keyword->string key))))) + ',required) + ,@(let ((current-list property-bindings) + (output-bindings nil)) + (while current-list + (-let* (((curr-binding-as-keyword next-entry . _) current-list) + (curr-binding-as-camelcased-string + (lsp-keyword->string (or (alist-get curr-binding-as-keyword ',params) + (error "Unknown key: %s. Available keys: %s" + (symbol-name curr-binding-as-keyword) + ',(-map #'cl-first params))))) + (bound-name (lsp-keyword->symbol curr-binding-as-keyword)) + (next-entry-is-key-or-nil + (and (symbolp next-entry) + (or (null next-entry) + (s-starts-with? ":" (symbol-name next-entry)))))) + (cond + (next-entry-is-key-or-nil + (push `(app (lambda (hash-table) + (ht-get hash-table ,curr-binding-as-camelcased-string)) + ,bound-name) + output-bindings) + (setf current-list (cdr current-list))) + (t + (push `(app (lambda (hash-table) + (ht-get hash-table ,curr-binding-as-camelcased-string)) + ,next-entry) + output-bindings) + (setf current-list (cddr current-list)))))) + output-bindings)))) + (-mapcat (-lambda ((label . name)) + (list + `(defun ,(intern (format "lsp:%s-%s" + (s-dashed-words (symbol-name interface)) + (substring (symbol-name label) 1))) + (object) + ,(if lsp-use-plists + `(plist-get object ,name) + `(when (ht? object) (gethash ,(lsp-keyword->string name) object)))) + `(defun ,(intern (format "lsp:set-%s-%s" + (s-dashed-words (symbol-name interface)) + (substring (symbol-name label) 1))) + (object value) + ,@(if lsp-use-plists + `((plist-put object ,name value)) + `((puthash ,(lsp-keyword->string name) value object) + object))))) + params))))) + (apply #'append) + (cl-list* 'progn)))) + +(if lsp-use-plists + (progn + (defun lsp-get (from key) + (plist-get from key)) + (defun lsp-put (where key value) + (plist-put where key value)) + (defun lsp-map (fn value) + (-map (-lambda ((k v)) + (funcall fn (lsp-keyword->string k) v)) + (-partition 2 value ))) + (defalias 'lsp-merge 'append) + (defalias 'lsp-empty? 'null) + (defalias 'lsp-copy 'copy-sequence) + (defun lsp-member? (from key) + (when (listp from) + (plist-member from key))) + (defalias 'lsp-structure-p 'json-plist-p) + (defun lsp-delete (from key) + (cl-remf from key) + from)) + (defun lsp-get (from key) + (when from + (gethash (lsp-keyword->string key) from))) + (defun lsp-put (where key value) + (prog1 where + (puthash (lsp-keyword->string key) value where))) + (defun lsp-map (fn value) + (when value + (maphash fn value))) + (defalias 'lsp-merge 'ht-merge) + (defalias 'lsp-empty? 'ht-empty?) + (defalias 'lsp-copy 'ht-copy) + (defun lsp-member? (from key) + (when (hash-table-p from) + (not (eq (gethash (lsp-keyword->string key) from :__lsp_default) + :__lsp_default)))) + (defalias 'lsp-structure-p 'hash-table-p) + (defun lsp-delete (from key) + (ht-remove from (lsp-keyword->string key)) + from)) + +(defmacro lsp-defun (name match-form &rest body) + "Define a function named NAME. +The function destructures its input as MATCH-FORM then executes BODY. + +Note that you have to enclose the MATCH-FORM in a pair of parens, +such that: + + (-defun (x) body) + (-defun (x y ...) body) + +has the usual semantics of `defun'. Furthermore, these get +translated into a normal `defun', so there is no performance +penalty. + +See `-let' for a description of the destructuring mechanism." + (declare (doc-string 3) (indent defun) + (debug (&define name sexp + [&optional stringp] + [&optional ("declare" &rest sexp)] + [&optional ("interactive" interactive)] + def-body))) + (cond + ((nlistp match-form) + (signal 'wrong-type-argument (list #'listp match-form))) + ;; no destructuring, so just return regular defun to make things faster + ((-all? #'symbolp match-form) + `(defun ,name ,match-form ,@body)) + (t + (-let* ((inputs (--map-indexed (list it (make-symbol (format "input%d" it-index))) match-form)) + ((body docs) (cond + ;; only docs + ((and (stringp (car body)) + (not (cdr body))) + (list body (car body))) + ;; docs + body + ((stringp (car body)) + (list (cdr body) (car body))) + ;; no docs + (t (list body)))) + ((body interactive-form) (cond + ;; interactive form + ((and (listp (car body)) + (eq (caar body) 'interactive)) + (list (cdr body) (car body))) + ;; no interactive form + (t (list body))))) + ;; TODO: because inputs to the defun are evaluated only once, + ;; -let* need not to create the extra bindings to ensure that. + ;; We should find a way to optimize that. Not critical however. + `(defun ,name ,(-map #'cadr inputs) + ,@(when docs (list docs)) + ,@(when interactive-form (list interactive-form)) + (-let* ,inputs ,@body)))))) + + + + +;; manually defined interfaces +(defconst lsp/markup-kind-plain-text "plaintext") +(defconst lsp/markup-kind-markdown "markdown") + +(lsp-interface (JSONResponse (:params :id :method :result) nil) + (JSONResponseError (:error) nil) + (JSONMessage nil (:params :id :method :result :error)) + (JSONResult nil (:params :id :method)) + (JSONNotification (:params :method) nil) + (JSONRequest (:params :method) nil) + (JSONError (:message :code) (:data)) + (ProgressParams (:token :value) nil) + (Edit (:kind) nil) + (WorkDoneProgress (:kind) nil) + (WorkDoneProgressBegin (:kind :title) (:cancellable :message :percentage)) + (WorkDoneProgressReport (:kind) (:cancellable :message :percentage)) + (WorkDoneProgressEnd (:kind) (:message)) + (WorkDoneProgressOptions nil (:workDoneProgress)) + (SemanticTokensOptions (:legend) (:rangeProvider :documentProvider)) + (SemanticTokensLegend (:tokenTypes :tokenModifiers)) + (SemanticTokensResult (:resultId) (:data)) + (SemanticTokensPartialResult nil (:data)) + (SemanticTokensEdit (:start :deleteCount) (:data)) + (SemanticTokensDelta (:resultId) (:edits)) + (SemanticTokensDeltaPartialResult nil (:edits))) + +(lsp-interface (v1:ProgressParams (:id :title) (:message :percentage :done))) + +(defun dash-expand:&RangeToPoint (key source) + "Convert the position KEY from SOURCE into a point." + `(lsp--position-to-point + (lsp-get ,source ,key))) + +(lsp-interface (eslint:StatusParams (:state) nil) + (eslint:OpenESLintDocParams (:url) nil) + (eslint:ConfirmExecutionParams (:scope :file :libraryPath) nil)) + +(lsp-interface (haxe:ProcessStartNotification (:title) nil)) + +(lsp-interface (pwsh:ScriptRegion (:StartLineNumber :EndLineNumber :StartColumnNumber :EndColumnNumber :Text) nil)) + +(lsp-interface (omnisharp:ErrorMessage (:Text :FileName :Line :Column)) + (omnisharp:ProjectInformationRequest (:FileName)) + (omnisharp:MsBuildProject (:IsUnitProject :IsExe :Platform :Configuration :IntermediateOutputPath :OutputPath :TargetFrameworks :SourceFiles :TargetFramework :TargetPath :AssemblyName :Path :ProjectGuid)) + (omnisharp:ProjectInformation (:ScriptProject :MsBuildProject)) + (omnisharp:CodeStructureRequest (:FileName)) + (omnisharp:CodeStructureResponse (:Elements)) + (omnisharp:CodeElement (:Kind :Name :DisplayName :Children :Ranges :Properties)) + (omnisharp:CodeElementProperties () (:static :accessibility :testMethodName :testFramework)) + (omnisharp:Range (:Start :End)) + (omnisharp:RangeList () (:attributes :full :name)) + (omnisharp:Point (:Line :Column)) + (omnisharp:RunTestsInClassRequest (:MethodNames :RunSettings :TestFrameworkname :TargetFrameworkVersion :NoBuild :Line :Column :Buffer :FileName)) + (omnisharp:RunTestResponse (:Results :Pass :Failure :ContextHadNoTests)) + (omnisharp:TestMessageEvent (:MessageLevel :Message)) + (omnisharp:DotNetTestResult (:MethodName :Outcome :ErrorMessage :ErrorStackTrace :StandardOutput :StandardError)) + (omnisharp:MetadataRequest (:AssemblyName :TypeName :ProjectName :VersionNumber :Language)) + (omnisharp:MetadataResponse (:SourceName :Source))) + +(lsp-interface (csharp-ls:CSharpMetadata (:textDocument)) + (csharp-ls:CSharpMetadataResponse (:source :projectName :assemblyName :symbolName))) + +(lsp-interface (rls:Cmd (:args :binary :env :cwd) nil)) + +(lsp-interface (rust-analyzer:AnalyzerStatusParams (:textDocument)) + (rust-analyzer:SyntaxTreeParams (:textDocument) (:range)) + (rust-analyzer:ViewHir (:textDocument :position)) + (rust-analyzer:ViewItemTree (:textDocument)) + (rust-analyzer:ExpandMacroParams (:textDocument :position) nil) + (rust-analyzer:ExpandedMacro (:name :expansion) nil) + (rust-analyzer:MatchingBraceParams (:textDocument :positions) nil) + (rust-analyzer:OpenCargoTomlParams (:textDocument) nil) + (rust-analyzer:OpenExternalDocsParams (:textDocument :position) nil) + (rust-analyzer:ResovedCodeActionParams (:id :codeActionParams) nil) + (rust-analyzer:JoinLinesParams (:textDocument :ranges) nil) + (rust-analyzer:MoveItemParams (:textDocument :range :direction) nil) + (rust-analyzer:RunnablesParams (:textDocument) (:position)) + (rust-analyzer:Runnable (:label :kind :args) (:location)) + (rust-analyzer:RunnableArgs (:cargoArgs :executableArgs) (:workspaceRoot :expectTest)) + (rust-analyzer:RelatedTestsParams (:textDocument :position) nil) + (rust-analyzer:RelatedTests (:runnable) nil) + (rust-analyzer:SsrParams (:query :parseOnly) nil) + (rust-analyzer:CommandLink (:title :command) (:arguments :tooltip)) + (rust-analyzer:CommandLinkGroup (:commands) (:title))) + +(lsp-interface (clojure-lsp:TestTreeParams (:uri :tree) nil) + (clojure-lsp:TestTreeNode (:name :range :nameRange :kind) (:children)) + (clojure-lsp:ProjectTreeNode (:name :type) (:nodes :final :id :uri :detail :range))) + +(lsp-interface (terraform-ls:ModuleCalls (:v :module_calls) nil)) +(lsp-interface (terraform-ls:Module (:name :docs_link :version :source_type :dependent_modules) nil)) +(lsp-interface (terraform-ls:Providers (:v :provider_requirements :installed_providers) nil)) +(lsp-interface (terraform-ls:module.terraform (:v :required_version :discovered_version))) + + +;; begin autogenerated code + +(defvar lsp/completion-item-kind-lookup + [nil Text Method Function Constructor Field Variable Class Interface Module Property Unit Value Enum Keyword Snippet Color File Reference Folder EnumMember Constant Struct Event Operator TypeParameter]) +(defconst lsp/completion-item-kind-text 1) +(defconst lsp/completion-item-kind-method 2) +(defconst lsp/completion-item-kind-function 3) +(defconst lsp/completion-item-kind-constructor 4) +(defconst lsp/completion-item-kind-field 5) +(defconst lsp/completion-item-kind-variable 6) +(defconst lsp/completion-item-kind-class 7) +(defconst lsp/completion-item-kind-interface 8) +(defconst lsp/completion-item-kind-module 9) +(defconst lsp/completion-item-kind-property 10) +(defconst lsp/completion-item-kind-unit 11) +(defconst lsp/completion-item-kind-value 12) +(defconst lsp/completion-item-kind-enum 13) +(defconst lsp/completion-item-kind-keyword 14) +(defconst lsp/completion-item-kind-snippet 15) +(defconst lsp/completion-item-kind-color 16) +(defconst lsp/completion-item-kind-file 17) +(defconst lsp/completion-item-kind-reference 18) +(defconst lsp/completion-item-kind-folder 19) +(defconst lsp/completion-item-kind-enum-member 20) +(defconst lsp/completion-item-kind-constant 21) +(defconst lsp/completion-item-kind-struct 22) +(defconst lsp/completion-item-kind-event 23) +(defconst lsp/completion-item-kind-operator 24) +(defconst lsp/completion-item-kind-type-parameter 25) +(defvar lsp/completion-trigger-kind-lookup + [nil Invoked TriggerCharacter TriggerForIncompleteCompletions]) +(defconst lsp/completion-trigger-kind-invoked 1) +(defconst lsp/completion-trigger-kind-trigger-character 2) +(defconst lsp/completion-trigger-kind-trigger-for-incomplete-completions 3) +(defvar lsp/diagnostic-severity-lookup + [nil Error Warning Information Hint Max]) +(defconst lsp/diagnostic-severity-error 1) +(defconst lsp/diagnostic-severity-warning 2) +(defconst lsp/diagnostic-severity-information 3) +(defconst lsp/diagnostic-severity-hint 4) +(defconst lsp/diagnostic-severity-max 5) +(defvar lsp/diagnostic-tag-lookup + [nil Unnecessary Deprecated]) +(defconst lsp/diagnostic-tag-unnecessary 1) +(defconst lsp/diagnostic-tag-deprecated 2) +(defvar lsp/completion-item-tag-lookup + [nil Deprecated]) +(defconst lsp/completion-item-tag-deprecated 1) +(defvar lsp/document-highlight-kind-lookup + [nil Text Read Write]) +(defconst lsp/document-highlight-kind-text 1) +(defconst lsp/document-highlight-kind-read 2) +(defconst lsp/document-highlight-kind-write 3) +(defvar lsp/file-change-type-lookup + [nil Created Changed Deleted]) +(defconst lsp/file-change-type-created 1) +(defconst lsp/file-change-type-changed 2) +(defconst lsp/file-change-type-deleted 3) +(defvar lsp/insert-text-format-lookup + [nil PlainText Snippet]) +(defconst lsp/insert-text-format-plain-text 1) +(defconst lsp/insert-text-format-snippet 2) +(defvar lsp/insert-text-mode-lookup + [nil AsIs AdjustIndentation]) +(defconst lsp/insert-text-mode-as-it 1) +(defconst lsp/insert-text-mode-adjust-indentation 2) +(defvar lsp/message-type-lookup + [nil Error Warning Info Log]) +(defconst lsp/message-type-error 1) +(defconst lsp/message-type-warning 2) +(defconst lsp/message-type-info 3) +(defconst lsp/message-type-log 4) +(defvar lsp/signature-help-trigger-kind-lookup + [nil Invoked TriggerCharacter ContentChange]) +(defconst lsp/signature-help-trigger-kind-invoked 1) +(defconst lsp/signature-help-trigger-kind-trigger-character 2) +(defconst lsp/signature-help-trigger-kind-content-change 3) +(defvar lsp/symbol-kind-lookup + [nil File Module Namespace Package Class Method Property Field Constructor Enum Interface Function Variable Constant String Number Boolean Array Object Key Null EnumMember Struct Event Operator TypeParameter]) +(defconst lsp/symbol-kind-file 1) +(defconst lsp/symbol-kind-module 2) +(defconst lsp/symbol-kind-namespace 3) +(defconst lsp/symbol-kind-package 4) +(defconst lsp/symbol-kind-class 5) +(defconst lsp/symbol-kind-method 6) +(defconst lsp/symbol-kind-property 7) +(defconst lsp/symbol-kind-field 8) +(defconst lsp/symbol-kind-constructor 9) +(defconst lsp/symbol-kind-enum 10) +(defconst lsp/symbol-kind-interface 11) +(defconst lsp/symbol-kind-function 12) +(defconst lsp/symbol-kind-variable 13) +(defconst lsp/symbol-kind-constant 14) +(defconst lsp/symbol-kind-string 15) +(defconst lsp/symbol-kind-number 16) +(defconst lsp/symbol-kind-boolean 17) +(defconst lsp/symbol-kind-array 18) +(defconst lsp/symbol-kind-object 19) +(defconst lsp/symbol-kind-key 20) +(defconst lsp/symbol-kind-null 21) +(defconst lsp/symbol-kind-enum-member 22) +(defconst lsp/symbol-kind-struct 23) +(defconst lsp/symbol-kind-event 24) +(defconst lsp/symbol-kind-operator 25) +(defconst lsp/symbol-kind-type-parameter 26) +(defvar lsp/text-document-save-reason-lookup + [nil Manual AfterDelay FocusOut]) +(defconst lsp/text-document-save-reason-manual 1) +(defconst lsp/text-document-save-reason-after-delay 2) +(defconst lsp/text-document-save-reason-focus-out 3) +(defvar lsp/text-document-sync-kind-lookup + [None Full Incremental]) +(defconst lsp/text-document-sync-kind-none 0) +(defconst lsp/text-document-sync-kind-full 1) +(defconst lsp/text-document-sync-kind-incremental 2) +(defvar lsp/type-hierarchy-direction-lookup + [nil Children Parents Both]) +(defconst lsp/type-hierarchy-direction-children 1) +(defconst lsp/type-hierarchy-direction-parents 2) +(defconst lsp/type-hierarchy-direction-both 3) +(defvar lsp/call-hierarchy-direction-lookup + [nil CallsFrom CallsTo]) +(defconst lsp/call-hierarchy-direction-calls-from 1) +(defconst lsp/call-hierarchy-direction-calls-to 2) +(defvar lsp/response-error-code-lookup + [nil ParseError InvalidRequest MethodNotFound InvalidParams InternalError serverErrorStart serverErrorEnd]) +(defconst lsp/response-error-code-parse-error 1) +(defconst lsp/response-error-code-invalid-request 2) +(defconst lsp/response-error-code-method-not-found 3) +(defconst lsp/response-error-code-invalid-params 4) +(defconst lsp/response-error-code-internal-error 5) +(defconst lsp/response-error-code-server-error-start 6) +(defconst lsp/response-error-code-server-error-end 7) + +(lsp-interface + (CallHierarchyCapabilities nil (:dynamicRegistration)) + (CallHierarchyItem (:kind :name :range :selectionRange :uri) (:detail :tags)) + (ClientCapabilities nil (:experimental :textDocument :workspace)) + (ClientInfo (:name) (:version)) + (CodeActionCapabilities nil (:codeActionLiteralSupport :dynamicRegistration :isPreferredSupport :dataSupport :resolveSupport)) + (CodeActionContext (:diagnostics) (:only)) + (CodeActionKindCapabilities (:valueSet) nil) + (CodeActionLiteralSupportCapabilities nil (:codeActionKind)) + (CodeActionOptions nil (:codeActionKinds :resolveProvider)) + (CodeLensCapabilities nil (:dynamicRegistration)) + (CodeLensOptions (:resolveProvider) nil) + (Color (:red :green :blue :alpha) nil) + (ColorProviderCapabilities nil (:dynamicRegistration)) + (ColorProviderOptions nil (:documentSelector :id)) + (ColoringInformation (:range :styles) nil) + (Command (:title :command) (:arguments)) + (CompletionCapabilities nil (:completionItem :completionItemKind :contextSupport :dynamicRegistration)) + (CompletionContext (:triggerKind) (:triggerCharacter)) + (CompletionItem (:label) (:additionalTextEdits :command :commitCharacters :data :deprecated :detail :documentation :filterText :insertText :insertTextFormat :insertTextMode :kind :preselect :sortText :tags :textEdit :score :labelDetails)) + (CompletionItemCapabilities nil (:commitCharactersSupport :deprecatedSupport :documentationFormat :preselectSupport :snippetSupport :tagSupport :insertReplaceSupport :resolveSupport)) + (CompletionItemKindCapabilities nil (:valueSet)) + (CompletionItemTagSupportCapabilities (:valueSet) nil) + (CompletionOptions nil (:resolveProvider :triggerCharacters :allCommitCharacters)) + (ConfigurationItem nil (:scopeUri :section)) + (CreateFileOptions nil (:ignoreIfExists :overwrite)) + (DeclarationCapabilities nil (:dynamicRegistration :linkSupport)) + (DefinitionCapabilities nil (:dynamicRegistration :linkSupport)) + (DeleteFileOptions nil (:ignoreIfNotExists :recursive)) + (Diagnostic (:range :message) (:code :relatedInformation :severity :source :tags)) + (DiagnosticRelatedInformation (:location :message) nil) + (DiagnosticsTagSupport (:valueSet) nil) + (DidChangeConfigurationCapabilities nil (:dynamicRegistration)) + (DidChangeWatchedFilesCapabilities nil (:dynamicRegistration)) + (DocumentFilter nil (:language :pattern :scheme)) + (DocumentHighlightCapabilities nil (:dynamicRegistration)) + (DocumentLinkCapabilities nil (:dynamicRegistration :tooltipSupport)) + (DocumentLinkOptions nil (:resolveProvider)) + (DocumentOnTypeFormattingOptions (:firstTriggerCharacter) (:moreTriggerCharacter)) + (DocumentSymbol (:kind :name :range :selectionRange) (:children :deprecated :detail)) + (DocumentSymbolCapabilities nil (:dynamicRegistration :hierarchicalDocumentSymbolSupport :symbolKind)) + (ExecuteCommandCapabilities nil (:dynamicRegistration)) + (ExecuteCommandOptions (:commands) nil) + (FileEvent (:type :uri) nil) + (FileSystemWatcher (:globPattern) (:kind)) + (FileOperationFilter (:pattern) (:scheme)) + (FileOperationPattern (:glob) (:matches :options)) + (FileOperationPatternOptions nil (:ignoreCase)) + (FileOperationRegistrationOptions (:filters) nil) + (FoldingRangeCapabilities nil (:dynamicRegistration :lineFoldingOnly :rangeLimit)) + (FoldingRangeProviderOptions nil (:documentSelector :id)) + (FormattingCapabilities nil (:dynamicRegistration)) + (FormattingOptions (:tabSize :insertSpaces) (:trimTrailingWhitespace :insertFinalNewline :trimFinalNewlines)) + (HoverCapabilities nil (:contentFormat :dynamicRegistration)) + (ImplementationCapabilities nil (:dynamicRegistration :linkSupport)) + (LabelDetails (:detail :description) nil) + (LinkedEditingRanges (:ranges) (:wordPattern)) + (Location (:range :uri) nil) + (MarkedString (:language :value) nil) + (MarkupContent (:kind :value) nil) + (MessageActionItem (:title) nil) + (OnTypeFormattingCapabilities nil (:dynamicRegistration)) + (ParameterInformation (:label) (:documentation)) + (ParameterInformationCapabilities nil (:labelOffsetSupport)) + (Position (:character :line) nil) + (PublishDiagnosticsCapabilities nil (:relatedInformation :tagSupport :versionSupport)) + (Range (:start :end) nil) + (RangeFormattingCapabilities nil (:dynamicRegistration)) + (ReferenceContext (:includeDeclaration) nil) + (ReferencesCapabilities nil (:dynamicRegistration)) + (Registration (:method :id) (:registerOptions)) + (RenameCapabilities nil (:dynamicRegistration :prepareSupport)) + (RenameFileOptions nil (:ignoreIfExists :overwrite)) + (RenameOptions nil (:documentSelector :id :prepareProvider)) + (ResourceChange nil (:current :newUri)) + (ResourceOperation (:kind) nil) + (SaveOptions nil (:includeText)) + (SelectionRange (:range) (:parent)) + (SelectionRangeCapabilities nil (:dynamicRegistration)) + (SemanticHighlightingCapabilities nil (:semanticHighlighting)) + (SemanticHighlightingInformation (:line) (:tokens)) + (SemanticHighlightingServerCapabilities nil (:scopes)) + (ServerCapabilities nil (:callHierarchyProvider :codeActionProvider :codeLensProvider :colorProvider :completionProvider :declarationProvider :definitionProvider :documentFormattingProvider :documentHighlightProvider :documentLinkProvider :documentOnTypeFormattingProvider :documentRangeFormattingProvider :documentSymbolProvider :executeCommandProvider :experimental :foldingRangeProvider :hoverProvider :implementationProvider :referencesProvider :renameProvider :selectionRangeProvider :semanticHighlighting :signatureHelpProvider :textDocumentSync :typeDefinitionProvider :typeHierarchyProvider :workspace :workspaceSymbolProvider :semanticTokensProvider)) + (ServerInfo (:name) (:version)) + (SignatureHelp (:signatures) (:activeParameter :activeSignature)) + (SignatureHelpCapabilities nil (:contextSupport :dynamicRegistration :signatureInformation)) + (SignatureHelpContext (:triggerKind :isRetrigger) (:activeSignatureHelp :triggerCharacter)) + (SignatureHelpOptions nil (:retriggerCharacters :triggerCharacters)) + (SignatureInformation (:label) (:documentation :parameters)) + (SignatureInformationCapabilities nil (:documentationFormat :parameterInformation)) + (StaticRegistrationOptions nil (:documentSelector :id)) + (SymbolCapabilities nil (:dynamicRegistration :symbolKind)) + (SymbolKindCapabilities nil (:valueSet)) + (SynchronizationCapabilities nil (:didSave :dynamicRegistration :willSave :willSaveWaitUntil)) + (TextDocumentClientCapabilities nil (:callHierarchy :codeAction :codeLens :colorProvider :completion :declaration :definition :documentHighlight :documentLink :documentSymbol :foldingRange :formatting :hover :implementation :onTypeFormatting :publishDiagnostics :rangeFormatting :references :rename :selectionRange :semanticHighlightingCapabilities :signatureHelp :synchronization :typeDefinition :typeHierarchyCapabilities)) + (TextDocumentContentChangeEvent (:text) (:range :rangeLength)) + (TextDocumentEdit (:textDocument :edits) nil) + (TextDocumentIdentifier (:uri) nil) + (TextDocumentItem (:languageId :text :uri :version) nil) + (TextDocumentSyncOptions nil (:change :openClose :save :willSave :willSaveWaitUntil)) + (TextEdit (:newText :range) nil) + (InsertReplaceEdit (:newText :insert :replace) nil) + (SnippetTextEdit (:newText :range) (:insertTextFormat)) + (TypeDefinitionCapabilities nil (:dynamicRegistration :linkSupport)) + (TypeHierarchyCapabilities nil (:dynamicRegistration)) + (TypeHierarchyItem (:kind :name :range :selectionRange :uri) (:children :data :deprecated :detail :parents)) + (Unregistration (:method :id) nil) + (VersionedTextDocumentIdentifier (:uri) (:version)) + (WorkspaceClientCapabilities nil (:applyEdit :configuration :didChangeConfiguration :didChangeWatchedFiles :executeCommand :symbol :workspaceEdit :workspaceFolders)) + (WorkspaceEdit nil (:changes :documentChanges :resourceChanges)) + (WorkspaceEditCapabilities nil (:documentChanges :failureHandling :resourceChanges :resourceOperations)) + (WorkspaceFolder (:uri :name) nil) + (WorkspaceFoldersChangeEvent (:removed :added) nil) + (WorkspaceFoldersOptions nil (:changeNotifications :supported)) + (WorkspaceServerCapabilities nil (:workspaceFolders :fileOperations)) + (WorkspaceFileOperations nil (:didCreate :willCreate :didRename :willRename :didDelete :willDelete)) + (ApplyWorkspaceEditParams (:edit) (:label)) + (ApplyWorkspaceEditResponse (:applied) nil) + (CallHierarchyIncomingCall (:from :fromRanges) nil) + (CallHierarchyIncomingCallsParams (:item) nil) + (CallHierarchyOutgoingCall (:to :fromRanges) nil) + (CallHierarchyOutgoingCallsParams (:item) nil) + (CallHierarchyPrepareParams (:textDocument :position) (:uri)) + (CodeAction (:title) (:command :diagnostics :edit :isPreferred :kind :data)) + (CodeActionKind nil nil) + (CodeActionParams (:textDocument :context :range) nil) + (CodeLens (:range) (:command :data)) + (CodeLensParams (:textDocument) nil) + (CodeLensRegistrationOptions nil (:documentSelector :resolveProvider)) + (ColorInformation (:color :range) nil) + (ColorPresentation (:label) (:additionalTextEdits :textEdit)) + (ColorPresentationParams (:color :textDocument :range) nil) + (ColoringParams (:uri :infos) nil) + (ColoringStyle nil nil) + (CompletionList (:items :isIncomplete) nil) + (CompletionParams (:textDocument :position) (:context :uri)) + (CompletionRegistrationOptions nil (:documentSelector :resolveProvider :triggerCharacters)) + (ConfigurationParams (:items) nil) + (CreateFile (:kind :uri) (:options)) + (DeclarationParams (:textDocument :position) (:uri)) + (DefinitionParams (:textDocument :position) (:uri)) + (DeleteFile (:kind :uri) (:options)) + (DidChangeConfigurationParams (:settings) nil) + (DidChangeTextDocumentParams (:contentChanges :textDocument) (:uri)) + (DidChangeWatchedFilesParams (:changes) nil) + (DidChangeWatchedFilesRegistrationOptions (:watchers) nil) + (DidChangeWorkspaceFoldersParams (:event) nil) + (DidCloseTextDocumentParams (:textDocument) nil) + (DidOpenTextDocumentParams (:textDocument) (:text)) + (DidSaveTextDocumentParams (:textDocument) (:text)) + (DocumentColorParams (:textDocument) nil) + (DocumentFormattingParams (:textDocument :options) nil) + (DocumentHighlight (:range) (:kind)) + (DocumentHighlightParams (:textDocument :position) (:uri)) + (DocumentLink (:range) (:data :target :tooltip)) + (DocumentLinkParams (:textDocument) nil) + (DocumentLinkRegistrationOptions nil (:documentSelector :resolveProvider)) + (DocumentOnTypeFormattingParams (:ch :textDocument :options :position) nil) + (DocumentOnTypeFormattingRegistrationOptions (:firstTriggerCharacter) (:documentSelector :moreTriggerCharacter)) + (DocumentRangeFormattingParams (:textDocument :options :range) nil) + (DocumentSymbolParams (:textDocument) nil) + (DynamicRegistrationCapabilities nil (:dynamicRegistration)) + (ExecuteCommandParams (:command) (:arguments)) + (ExecuteCommandRegistrationOptions (:commands) nil) + (FailureHandlingKind nil nil) + (FileRename (:oldUri :newUri) nil) + (FoldingRange (:endLine :startLine) (:endCharacter :kind :startCharacter)) + (FoldingRangeKind nil nil) + (FoldingRangeRequestParams (:textDocument) nil) + (Hover (:contents) (:range)) + (HoverParams (:textDocument :position) (:uri)) + (ImplementationParams (:textDocument :position) (:uri)) + (InitializeError (:retry) nil) + (InitializeErrorCode nil nil) + (InitializeParams nil (:capabilities :clientInfo :clientName :initializationOptions :processId :rootPath :rootUri :trace :workspaceFolders)) + (InitializeResult (:capabilities) (:serverInfo)) + (InitializedParams nil nil) + (LocationLink (:targetSelectionRange :targetUri :targetRange) (:originSelectionRange)) + (MarkupKind nil nil) + (MessageParams (:type :message) nil) + (PrepareRenameParams (:textDocument :position) (:uri)) + (PrepareRenameResult (:range :placeholder) nil) + (PublishDiagnosticsParams (:diagnostics :uri) (:version)) + (QuickPickItem (:label :picked :userData) nil) + (ReferenceParams (:textDocument :context :position) (:uri)) + (RegistrationParams (:registrations) nil) + (RenameFile (:kind :newUri :oldUri) (:options)) + (RenameFilesParams (:files) nil) + (RenameParams (:newName :textDocument :position) (:uri)) + (ResolveTypeHierarchyItemParams (:item :resolve :direction) nil) + (ResourceOperationKind nil nil) + (SelectionRangeParams (:textDocument :positions) nil) + (SemanticHighlightingParams (:textDocument :lines) nil) + (ShowDocumentParams (:uri) (:external :takeFocus :selection)) + (ShowDocumentResult (:success) nil) + (ShowInputBoxParams (:prompt) (:value)) + (ShowMessageRequestParams (:type :message) (:actions)) + (ShowQuickPickParams (:placeHolder :canPickMany :items) nil) + (SignatureHelpParams (:textDocument :position) (:context :uri)) + (SignatureHelpRegistrationOptions nil (:documentSelector :triggerCharacters)) + (SymbolInformation (:kind :name :location) (:containerName :deprecated)) + (TextDocumentChangeRegistrationOptions (:syncKind) (:documentSelector)) + (TextDocumentPositionParams (:textDocument :position) (:uri)) + (TextDocumentRegistrationOptions nil (:documentSelector)) + (TextDocumentSaveRegistrationOptions nil (:documentSelector :includeText)) + (TypeDefinitionParams (:textDocument :position) (:uri)) + (TypeHierarchyParams (:resolve :textDocument :position) (:direction :uri)) + (UnregistrationParams (:unregisterations) nil) + (WatchKind nil nil) + (WillSaveTextDocumentParams (:reason :textDocument) nil) + (WorkspaceSymbolParams (:query) nil) + ;; 3.17 + (InlayHint (:label :position) (:kind :paddingLeft :paddingRight)) + (InlayHintLabelPart (:value) (:tooltip :location :command)) + (InlayHintsParams (:textDocument) (:range))) + +;; 3.17 +(defconst lsp/inlay-hint-kind-type-hint 1) +(defconst lsp/inlay-hint-kind-parameter-hint 2) + + +(provide 'lsp-protocol) + +;;; lsp-protocol.el ends here diff --git a/emacs/elpa/lsp-mode-20240531.2326/lsp-protocol.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-protocol.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-purescript.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-purescript.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-purescript.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-purescript.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-pwsh.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-pwsh.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-pwsh.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-pwsh.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-pyls.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-pyls.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-pyls.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-pyls.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-pylsp.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-pylsp.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-pylsp.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-pylsp.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-qml.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-qml.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-qml.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-qml.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-r.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-r.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-r.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-r.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-racket.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-racket.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-racket.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-racket.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-remark.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-remark.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-remark.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-remark.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-rf.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-rf.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-rf.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-rf.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-rpm-spec.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-rpm-spec.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-rpm-spec.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-rpm-spec.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-rubocop.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-rubocop.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-rubocop.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-rubocop.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-ruby-lsp.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-ruby-lsp.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-ruby-lsp.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-ruby-lsp.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-ruby-syntax-tree.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-ruby-syntax-tree.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-ruby-syntax-tree.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-ruby-syntax-tree.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-ruff-lsp.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-ruff-lsp.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-ruff-lsp.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-ruff-lsp.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240531.2326/lsp-rust.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-rust.el @@ -0,0 +1,1781 @@ +;;; lsp-rust.el --- Rust Client settings -*- lexical-binding: t; -*- + +;; Copyright (C) 2019 Ivan Yonchovski + +;; Author: Ivan Yonchovski <yyoncho@gmail.com> +;; Keywords: + +;; 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 <https://www.gnu.org/licenses/>. + +;;; Commentary: + +;; lsp-rust client + +;;; Code: + +(require 'lsp-mode) +(require 'ht) +(require 'dash) +(require 'lsp-semantic-tokens) +(require 's) + +(defgroup lsp-rust nil + "LSP support for Rust, using Rust Language Server or rust-analyzer." + :group 'lsp-mode + :link '(url-link "https://github.com/rust-lang/rls") + :package-version '(lsp-mode . "6.1")) + +(defgroup lsp-rust-rls nil + "LSP support for Rust, using Rust Language Server." + :group 'lsp-mode + :link '(url-link "https://github.com/rust-lang/rls") + :package-version '(lsp-mode . "8.0.0")) + +(defgroup lsp-rust-analyzer nil + "LSP support for Rust, using rust-analyzer." + :group 'lsp-mode + :link '(url-link "https://github.com/rust-lang/rust-analyzer") + :package-version '(lsp-mode . "8.0.0")) + +(defgroup lsp-rust-analyzer-semantic-tokens nil + "LSP semantic tokens support for rust-analyzer." + :group 'lsp-rust-analyzer + :link '(url-link "https://github.com/rust-lang/rust-analyzer") + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-server 'rust-analyzer + "Choose LSP server." + :type '(choice (const :tag "rls" rls) + (const :tag "rust-analyzer" rust-analyzer)) + :group 'lsp-rust + :package-version '(lsp-mode . "6.2")) + +;; RLS + +(defcustom lsp-rust-rls-server-command '("rls") + "Command to start RLS." + :type '(repeat string) + :group 'lsp-rust-rls + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-rust-library-directories + '("~/.cargo/registry/src" "~/.rustup/toolchains") + "List of directories which will be considered to be libraries." + :risky t + :type '(repeat string) + :group 'lsp-rust-rls + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-rust-sysroot nil + "If non-nil, use the given path as the sysroot for all rustc invocations +instead of trying to detect the sysroot automatically." + :type '(choice + (const :tag "None" nil) + (string :tag "Sysroot")) + :group 'lsp-rust-rls + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-rust-target nil + "If non-nil, use the given target triple for all rustc invocations." + :type '(choice + (const :tag "None" nil) + (string :tag "Target")) + :group 'lsp-rust-rls + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-rust-rustflags nil + "Flags added to RUSTFLAGS." + :type '(choice + (const :tag "None" nil) + (string :tag "Flags")) + :group 'lsp-rust-rls + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-rust-clear-env-rust-log t + "Clear the RUST_LOG environment variable before running rustc or cargo." + :type 'boolean + :group 'lsp-rust-rls + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-rust-build-lib nil + "If non-nil, checks the project as if you passed the `--lib' argument to +cargo. + +Mutually exclusive with, and preferred over, `lsp-rust-build-bin'. (Unstable)" + :type 'boolean + :group 'lsp-rust-rls + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-rust-build-bin nil + "If non-nil, checks the project as if you passed `-- bin <build_bin>' +argument to cargo. + +Mutually exclusive with `lsp-rust-build-lib'. (Unstable)" + :type '(choice + (const :tag "None" nil) + (string :tag "Binary")) + :group 'lsp-rust-rls + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-rust-cfg-test nil + "If non-nil, checks the project as if you were running `cargo test' rather +than cargo build. + +I.e., compiles (but does not run) test code." + :type 'boolean + :group 'lsp-rust-rls + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-rust-unstable-features nil + "Enable unstable features." + :type 'boolean + :group 'lsp-rust-rls + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-rust-wait-to-build nil + "Time in milliseconds between receiving a change notification +and starting build. If not specified, automatically inferred by +the latest build duration." + :type '(choice + (const :tag "Auto" nil) + (number :tag "Time")) + :group 'lsp-rust-rls + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-rust-show-warnings t + "Show warnings." + :type 'boolean + :group 'lsp-rust-rls + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-rust-crate-blocklist [ + "cocoa" + "gleam" + "glium" + "idna" + "libc" + "openssl" + "rustc_serialize" + "serde" + "serde_json" + "typenum" + "unicode_normalization" + "unicode_segmentation" + "winapi" + ] + "A list of Cargo crates to blocklist." + :type 'lsp-string-vector + :group 'lsp-rust-rls + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-rust-build-on-save nil + "Only index the project when a file is saved and not on change." + :type 'boolean + :group 'lsp-rust-rls + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-rust-features [] + "List of features to activate. +Set this to `\"all\"` to pass `--all-features` to cargo." + :type 'lsp-string-vector + :group 'lsp-rust-rls + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-rust-all-features nil + "Enable all Cargo features." + :type 'boolean + :group 'lsp-rust-rls + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-rust-no-default-features nil + "Do not enable default Cargo features." + :type 'boolean + :group 'lsp-rust-rls + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-rust-racer-completion t + "Enables code completion using racer." + :type 'boolean + :group 'lsp-rust-rls + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-rust-clippy-preference "opt-in" + "Controls eagerness of clippy diagnostics when available. +Valid values are (case-insensitive): + - \"off\": Disable clippy lints. + - \"opt-in\": Clippy lints are shown when crates specify `#![warn(clippy)]'. + - \"on\": Clippy lints enabled for all crates in workspace. + +You need to install clippy via rustup if you haven't already." + :type '(choice + (const "on") + (const "opt-in") + (const "off")) + :group 'lsp-rust-rls + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-rust-jobs nil + "Number of Cargo jobs to be run in parallel." + :type '(choice + (const :tag "Auto" nil) + (number :tag "Jobs")) + :group 'lsp-rust-rls + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-rust-all-targets t + "Checks the project as if you were running cargo check --all-targets. +I.e., check all targets and integration tests too." + :type 'boolean + :group 'lsp-rust-rls + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-rust-target-dir nil + "When specified, it places the generated analysis files at the +specified target directory. By default it is placed target/rls +directory." + :type '(choice + (const :tag "Default" nil) + (string :tag "Directory")) + :group 'lsp-rust-rls + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-rust-rustfmt-path nil + "When specified, RLS will use the Rustfmt pointed at the path +instead of the bundled one" + :type '(choice + (const :tag "Bundled" nil) + (string :tag "Path")) + :group 'lsp-rust-rls + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-rust-build-command nil + "EXPERIMENTAL (requires `rust.unstable_features') +If set, executes a given program responsible for rebuilding save-analysis to be +loaded by the RLS. The program given should output a list of resulting .json +files on stdout. + +Implies `rust.build_on_save': true." + :type '(choice + (const :tag "None" nil) + (string :tag "Command")) + :group 'lsp-rust-rls + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-rust-full-docs nil + "Instructs cargo to enable full documentation extraction during +save-analysis while building the crate." + :type 'boolean + :group 'lsp-rust-rls + :package-version '(lsp-mode . "6.1")) + +(defcustom lsp-rust-show-hover-context t + "Show additional context in hover tooltips when available. This +is often the type local variable declaration." + :type 'boolean + :group 'lsp-rust-rls + :package-version '(lsp-mode . "6.1")) + +(lsp-register-custom-settings + '(("rust.show_hover_context" lsp-rust-show-hover-context t) + ("rust.full_docs" lsp-rust-full-docs t) + ("rust.build_command" lsp-rust-build-command) + ("rust.rustfmt_path" lsp-rust-rustfmt-path) + ("rust.target_dir" lsp-rust-target-dir) + ("rust.all_targets" lsp-rust-all-targets t) + ("rust.jobs" lsp-rust-jobs) + ("rust.clippy_preference" lsp-rust-clippy-preference) + ("rust.racer_completion" lsp-rust-racer-completion t) + ("rust.no_default_features" lsp-rust-no-default-features t) + ("rust.all_features" lsp-rust-all-features t) + ("rust.features" lsp-rust-features) + ("rust.build_on_save" lsp-rust-build-on-save t) + ("rust.crate_blocklist" lsp-rust-crate-blocklist) + ("rust.show_warnings" lsp-rust-show-warnings t) + ("rust.wait_to_build" lsp-rust-wait-to-build) + ("rust.unstable_features" lsp-rust-unstable-features t) + ("rust.cfg_test" lsp-rust-cfg-test t) + ("rust.build_bin" lsp-rust-build-bin) + ("rust.build_lib" lsp-rust-build-lib t) + ("rust.clear_env_rust_log" lsp-rust-clear-env-rust-log t) + ("rust.rustflags" lsp-rust-rustflags) + ("rust.target" lsp-rust-target) + ("rust.sysroot" lsp-rust-sysroot))) + +(defun lsp-clients--rust-window-progress (workspace params) + "Progress report handling. +PARAMS progress report notification data." + (-let [(&v1:ProgressParams :done? :message? :title) params] + (if (or done? (s-blank-str? message?)) + (lsp-workspace-status nil workspace) + (lsp-workspace-status (format "%s - %s" title (or message? "")) workspace)))) + +(lsp-defun lsp-rust--rls-run ((&Command :arguments? params)) + (-let* (((&rls:Cmd :env :binary :args :cwd) (lsp-seq-first params)) + (default-directory (or cwd (lsp-workspace-root) default-directory) )) + (compile + (format "%s %s %s" + (s-join " " (ht-amap (format "%s=%s" key value) env)) + binary + (s-join " " args))))) + +(lsp-register-client + (make-lsp-client :new-connection (lsp-stdio-connection (lambda () lsp-rust-rls-server-command)) + :activation-fn (lsp-activate-on "rust") + :priority (if (eq lsp-rust-server 'rls) 1 -1) + :initialization-options '((omitInitBuild . t) + (cmdRun . t)) + :notification-handlers (ht ("window/progress" 'lsp-clients--rust-window-progress)) + :action-handlers (ht ("rls.run" 'lsp-rust--rls-run)) + :library-folders-fn (lambda (_workspace) lsp-rust-library-directories) + :initialized-fn (lambda (workspace) + (with-lsp-workspace workspace + (lsp--set-configuration + (lsp-configuration-section "rust")))) + :server-id 'rls)) + + +;; rust-analyzer +(defcustom lsp-rust-analyzer-server-command '("rust-analyzer") + "Command to start rust-analyzer." + :type '(repeat string) + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "6.2")) + +(defcustom lsp-rust-analyzer-library-directories + '("~/.cargo/registry/src" "~/.rustup/toolchains") + "List of directories which will be considered to be libraries." + :risky t + :type '(repeat string) + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-server-format-inlay-hints t + "Whether to ask rust-analyzer to format inlay hints itself. If +active, the various inlay format settings are not used." + :type 'boolean + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-hide-closure-initialization nil + "Whether to hide inlay type hints for `let` statements that initialize +to a closure. Only applies to closures with blocks, same as +`#rust-analyzer.inlayHints.closureReturnTypeHints.enable#`." + :type 'boolean + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-highlight-breakpoints t + "Enables highlighting of related references while the cursor is on +`break`, `loop`, `while`, or `for` keywords." + :type 'boolean + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-highlight-closure-captures t + "Enables highlighting of all captures of a closure while the +cursor is on the `|` or move keyword of a closure." + :type 'boolean + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-highlight-exit-points t + "Enables highlighting of all exit points while the cursor is on +any `return`, `?`, `fn`, or return type arrow (`->`)." + :type 'boolean + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-highlight-references t + "Enables highlighting of related references while the cursor is on +any identifier." + :type 'boolean + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-highlight-yield-points t + "Enables highlighting of all break points for a loop or block +context while the cursor is on any `async` or `await` keywords." + :type 'boolean + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-closure-return-type-hints "never" + "Whether to show inlay type hints for return types of closures." + :type '(choice + (const "never") + (const "always") + (const "with_block")) + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-discriminants-hints "never" + "Whether to show enum variant discriminant hints." + :type '(choice + (const "never") + (const "always") + (const "fieldless")) + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-expression-adjustment-hints "never" + "Whether to show inlay hints for type adjustments.." + :type '(choice + (const "never") + (const "always") + (const "reborrow")) + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-expression-adjustment-hints-mode "prefix" + "Whether to show inlay hints as postfix ops (`.*` instead of `*`, etc)." + :type '(choice + (const "prefix") + (const "postfix") + (const "prefer_prefix") + (const "prefer_postfix")) + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-expression-adjustment-hide-unsafe nil + "Whether to hide inlay hints for type adjustments outside of +`unsafe` blocks." + :type 'boolean + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-implicit-drops nil + "Whether to show implicit drop hints." + :type 'boolean + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "9.0.0")) + + +(defcustom lsp-rust-analyzer-closure-capture-hints nil + "Whether to show inlay hints for closure captures." + :type 'boolean + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-closure-style "impl_fn" + "Closure notation in type and chaining inlay hints." + :type 'string + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-hide-named-constructor nil + "Whether to hide inlay type hints for constructors." + :type 'boolean + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-max-inlay-hint-length nil + "Max inlay hint length." + :type 'integer + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "6.2.2")) + +(defcustom lsp-rust-analyzer-display-chaining-hints nil + "Whether to show inlay type hints for method chains. These +hints will be formatted with the type hint formatting options, if +the mode is not configured to ask the server to format them." + :type 'boolean + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "6.2.2")) + +(defcustom lsp-rust-analyzer-display-lifetime-elision-hints-enable "never" + "Whether to show elided lifetime inlay hints." + :type '(choice + (const "never") + (const "always") + (const "skip_trivial")) + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-display-lifetime-elision-hints-use-parameter-names nil + "When showing elided lifetime inlay hints, whether to use +parameter names or numeric placeholder names for the lifetimes." + :type 'boolean + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-display-closure-return-type-hints nil + "Whether to show closure return type inlay hints for closures +with block bodies." + :type 'boolean + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-display-parameter-hints nil + "Whether to show function parameter name inlay hints at the call site." + :type 'boolean + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "6.2.2")) + +(defcustom lsp-rust-analyzer-display-reborrow-hints "never" + "Whether to show inlay type hints for compiler inserted reborrows." + :type '(choice + (const "always") + (const "never") + (const "mutable")) + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-binding-mode-hints nil + "Whether to show inlay type hints for binding modes." + :type 'boolean + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-closing-brace-hints t + "Whether to show inlay hints after a closing `}` to indicate what item it +belongs to." + :type 'boolean + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-closing-brace-hints-min-lines 25 + "Minimum number of lines required before the `}` until the hint is shown +\(set to 0 or 1 to always show them)." + :type 'integer + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-lru-capacity nil + "Number of syntax trees rust-analyzer keeps in memory." + :type 'integer + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "6.2.2")) + +(defcustom lsp-rust-analyzer-cargo-target nil + "Compilation target (target triple)." + :type '(choice + (string :tag "Target") + (const :tag "None" nil)) + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "8.0.0")) + +(defcustom lsp-rust-analyzer-cargo-watch-enable t + "Enable Cargo watch." + :type 'boolean + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "6.2.2")) + +(defcustom lsp-rust-analyzer-cargo-watch-command "check" + "Cargo watch command." + :type 'string + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "6.2.2")) + +(defcustom lsp-rust-analyzer-cargo-watch-args [] + "Extra arguments for `cargo check`." + :type 'lsp-string-vector + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "6.2.2")) + +(defcustom lsp-rust-analyzer-cargo-override-command [] + "Advanced option, fully override the command rust-analyzer uses for checking. +The command should include `--message=format=json` or similar option." + :type 'lsp-string-vector + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "6.2.2")) + +(defcustom lsp-rust-analyzer-check-all-targets t + "Enables --all-targets for `cargo check`." + :type 'boolean + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "8.0.2")) + +(defcustom lsp-rust-analyzer-checkonsave-features [] + "List of features to activate. +Set this to `\"all\"` to pass `--all-features` to cargo." + :type 'lsp-string-vector + :group 'lsp-rust-rust-analyzer + :package-version '(lsp-mode . "8.0.2")) + +(defcustom lsp-rust-analyzer-cargo-unset-test [] + "force rust-analyzer to unset `#[cfg(test)]` for the specified crates." + :type 'lsp-string-vector + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-use-client-watching t + "Use client watching" + :type 'boolean + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "6.2.2")) + +(defcustom lsp-rust-analyzer-exclude-globs [] + "Exclude globs" + :type 'lsp-string-vector + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "6.2.2")) + +(defcustom lsp-rust-analyzer-exclude-dirs [] + "These directories will be ignored by rust-analyzer." + :type 'lsp-string-vector + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "8.0.0")) + +(defcustom lsp-rust-analyzer-macro-expansion-method 'lsp-rust-analyzer-macro-expansion-default + "Use a different function if you want formatted macro expansion results and +syntax highlighting." + :type 'function + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "6.2.2")) + +(defcustom lsp-rust-analyzer-diagnostics-enable t + "Whether to show native rust-analyzer diagnostics." + :type 'boolean + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "6.3.2")) + +(defcustom lsp-rust-analyzer-diagnostics-enable-experimental nil + "Whether to show native rust-analyzer diagnostics that are still experimental +\(might have more false positives than usual)." + :type 'boolean + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "8.0.0")) + +(defcustom lsp-rust-analyzer-diagnostics-disabled [] + "List of native rust-analyzer diagnostics to disable." + :type 'lsp-string-vector + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "8.0.0")) + +(defcustom lsp-rust-analyzer-diagnostics-warnings-as-hint [] + "List of warnings that should be displayed with hint severity." + :type 'lsp-string-vector + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "8.0.0")) + +(defcustom lsp-rust-analyzer-diagnostics-warnings-as-info [] + "List of warnings that should be displayed with info severity." + :type 'lsp-string-vector + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "8.0.0")) + +(define-obsolete-variable-alias + 'lsp-rust-analyzer-cargo-load-out-dirs-from-check + 'lsp-rust-analyzer-cargo-run-build-scripts + "8.0.0") + +(defcustom lsp-rust-analyzer-cargo-run-build-scripts t + "Whether to run build scripts (`build.rs`) for more precise code analysis." + :type 'boolean + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "8.0.0")) + +(defcustom lsp-rust-analyzer-rustfmt-extra-args [] + "Additional arguments to rustfmt." + :type 'lsp-string-vector + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "6.3.2")) + +(defcustom lsp-rust-analyzer-rustfmt-override-command [] + "Advanced option, fully override the command rust-analyzer uses +for formatting." + :type 'lsp-string-vector + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "6.3.2")) + +(defcustom lsp-rust-analyzer-rustfmt-rangeformatting-enable nil + "Enables the use of rustfmt's unstable range formatting command for the +`textDocument/rangeFormatting` request. The rustfmt option is unstable and only +available on a nightly build." + :type 'boolean + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-completion-add-call-parenthesis t + "Whether to add parenthesis when completing functions." + :type 'boolean + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "6.3.2")) + +(defcustom lsp-rust-analyzer-completion-add-call-argument-snippets t + "Whether to add argument snippets when completing functions." + :type 'boolean + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "6.3.2")) + +(defcustom lsp-rust-analyzer-completion-postfix-enable t + "Whether to show postfix snippets like `dbg`, `if`, `not`, etc." + :type 'boolean + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "6.3.2")) + +(defcustom lsp-rust-analyzer-call-info-full t + "Whether to show function name and docs in parameter hints." + :type 'boolean + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "6.3.2")) + +(defcustom lsp-rust-analyzer-proc-macro-enable t + "Enable Proc macro support. +Implies `lsp-rust-analyzer-cargo-run-build-scripts'" + :type 'boolean + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "6.3.2")) + +(defcustom lsp-rust-analyzer-import-prefix "plain" + "The path structure for newly inserted paths to use. +Valid values are: + - \"plain\": Insert import paths relative to the current module, using up to +one `super' prefix if the parent module contains the requested item. + - \"by_self\": Prefix all import paths with `self' if they don't begin with +`self', `super', `crate' or a crate name. + - \"by_crate\": Force import paths to be absolute by always starting +them with `crate' or the crate name they refer to." + :type '(choice + (const "plain") + (const "by_self") + (const "by_crate")) + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "8.0.0")) + +(defcustom lsp-rust-analyzer-import-granularity "crate" + "How imports should be grouped into use statements." + :type '(choice + (const "crate" :doc "Merge imports from the same crate into a single use statement. This kind of nesting is only supported in Rust versions later than 1.24.") + (const "module" :doc "Merge imports from the same module into a single use statement.") + (const "item" :doc "Don’t merge imports at all, creating one import per item.") + (const "preserve" :doc "Do not change the granularity of any imports. For auto-import this has the same effect as `\"item\"'")) + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "8.0.0")) + +(defcustom lsp-rust-analyzer-cargo-auto-reload t + "Automatically refresh project info via `cargo metadata' on `Cargo.toml' changes." + :type 'boolean + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "8.0.0")) + +(defcustom lsp-rust-analyzer-use-rustc-wrapper-for-build-scripts t + "Use `RUSTC_WRAPPER=rust-analyzer' when running build scripts to avoid +compiling unnecessary things." + :type 'boolean + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "8.0.0")) + +(defcustom lsp-rust-analyzer-completion-auto-import-enable t + "Toggles the additional completions that automatically add imports when +completed. `lsp-completion-enable-additional-text-edit' must be non-nil + for this feature to be fully enabled." + :type 'boolean + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "8.0.0")) + +(defcustom lsp-rust-analyzer-completion-auto-self-enable t + "Toggles the additional completions that automatically show method calls +and field accesses with self prefixed to them when inside a method." + :type 'boolean + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "8.0.0")) + +(defcustom lsp-rust-analyzer-import-enforce-granularity nil + "Whether to enforce the import granularity setting for all files. + If set to nil rust-analyzer will try to keep import styles consistent per file." + :type 'boolean + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "8.0.0")) + +(defcustom lsp-rust-analyzer-imports-merge-glob t + "Whether to allow import insertion to merge new imports into single path +glob imports like `use std::fmt::*;`." + :type 'boolean + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-import-group t + "Group inserted imports by the following order: +https://rust-analyzer.github.io/manual.html#auto-import. + Groups are separated by newlines." + :type 'boolean + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "8.0.0")) + +(defcustom lsp-rust-analyzer-highlighting-strings t + "Use semantic tokens for strings." + :type 'boolean + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "8.0.0")) + +(defcustom lsp-rust-analyzer-rustc-source nil + "Path to the Cargo.toml of the rust compiler workspace." + :type '(choice + (file :tag "Path") + (const :tag "None" nil)) + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "8.0.0")) + +(defcustom lsp-rust-analyzer-linked-projects [] + "Disable project auto-discovery in favor of explicitly specified set of +projects. Elements must be paths pointing to `Cargo.toml`, `rust-project.json`, +or JSON objects in `rust-project.json` format." + :type 'lsp-string-vector + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-experimental-proc-attr-macros t + "Whether to enable experimental support for expanding proc macro attributes." + :type 'boolean + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "8.0.0")) + +(defcustom lsp-rust-analyzer-cargo-extra-args [] + "Extra arguments that are passed to every cargo invocation." + :type 'lsp-string-vector + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-cargo-extra-env [] + "Extra environment variables that will be set when running cargo, rustc or +other commands within the workspace. Useful for setting RUSTFLAGS." + :type 'lsp-string-vector + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "9.0.0")) + +(defconst lsp-rust-notification-handlers + '(("rust-analyzer/publishDecorations" . (lambda (_w _p))))) + +(defconst lsp-rust-action-handlers + '()) + +(define-derived-mode lsp-rust-analyzer-syntax-tree-mode special-mode "Rust-Analyzer-Syntax-Tree" + "Mode for the rust-analyzer syntax tree buffer.") + +(defun lsp-rust-analyzer-syntax-tree () + "Display syntax tree for current buffer." + (interactive) + (-let* ((root (lsp-workspace-root default-directory)) + (params (lsp-make-rust-analyzer-syntax-tree-params + :text-document (lsp--text-document-identifier) + :range? (if (use-region-p) + (lsp--region-to-range (region-beginning) (region-end)) + (lsp--region-to-range (point-min) (point-max))))) + (results (lsp-send-request (lsp-make-request + "rust-analyzer/syntaxTree" + params)))) + (let ((buf (get-buffer-create (format "*rust-analyzer syntax tree %s*" root))) + (inhibit-read-only t)) + (with-current-buffer buf + (lsp-rust-analyzer-syntax-tree-mode) + (erase-buffer) + (insert results) + (goto-char (point-min))) + (pop-to-buffer buf)))) + +(define-derived-mode lsp-rust-analyzer-status-mode special-mode "Rust-Analyzer-Status" + "Mode for the rust-analyzer status buffer.") + +(defun lsp-rust-analyzer-status () + "Displays status information for rust-analyzer." + (interactive) + (-let* ((root (lsp-workspace-root default-directory)) + (params (lsp-make-rust-analyzer-analyzer-status-params + :text-document (lsp--text-document-identifier))) + (results (lsp-send-request (lsp-make-request + "rust-analyzer/analyzerStatus" + params)))) + (let ((buf (get-buffer-create (format "*rust-analyzer status %s*" root))) + (inhibit-read-only t)) + (with-current-buffer buf + (lsp-rust-analyzer-status-mode) + (erase-buffer) + (insert results) + (pop-to-buffer buf))))) + +(defun lsp-rust-analyzer-view-item-tree () + "Show item tree of rust file." + (interactive) + (-let* ((params (lsp-make-rust-analyzer-view-item-tree + :text-document (lsp--text-document-identifier))) + (results (lsp-send-request (lsp-make-request + "rust-analyzer/viewItemTree" + params)))) + (let ((buf (get-buffer-create "*rust-analyzer item tree*")) + (inhibit-read-only t)) + (with-current-buffer buf + (special-mode) + (erase-buffer) + (insert (lsp--render-string results "rust")) + (pop-to-buffer buf))))) + +(defun lsp-rust-analyzer-view-hir () + "View Hir of function at point." + (interactive) + (-let* ((params (lsp-make-rust-analyzer-expand-macro-params + :text-document (lsp--text-document-identifier) + :position (lsp--cur-position))) + (results (lsp-send-request (lsp-make-request + "rust-analyzer/viewHir" + params)))) + (let ((buf (get-buffer-create "*rust-analyzer hir*")) + (inhibit-read-only t)) + (with-current-buffer buf + (special-mode) + (erase-buffer) + (insert results) + (pop-to-buffer buf))))) + +(defun lsp-rust-analyzer-join-lines () + "Join selected lines into one, smartly fixing up whitespace and trailing commas." + (interactive) + (let* ((params (lsp-make-rust-analyzer-join-lines-params + :text-document (lsp--text-document-identifier) + :ranges (vector (if (use-region-p) + (lsp--region-to-range (region-beginning) (region-end)) + (lsp--region-to-range (point) (point)))))) + (result (lsp-send-request (lsp-make-request "experimental/joinLines" params)))) + (lsp--apply-text-edits result 'code-action))) + +(defun lsp-rust-analyzer-reload-workspace () + "Reload workspace, picking up changes from Cargo.toml" + (interactive) + (lsp--cur-workspace-check) + (lsp-send-request (lsp-make-request "rust-analyzer/reloadWorkspace"))) + +(defcustom lsp-rust-analyzer-download-url + (let* ((x86 (string-prefix-p "x86_64" system-configuration)) + (arch (if x86 "x86_64" "aarch64"))) + (format "https://github.com/rust-lang/rust-analyzer/releases/latest/download/%s" + (pcase system-type + ('gnu/linux (format "rust-analyzer-%s-unknown-linux-gnu.gz" arch)) + ('darwin (format "rust-analyzer-%s-apple-darwin.gz" arch)) + ('windows-nt (format "rust-analyzer-%s-pc-windows-msvc.zip" arch))))) + "Automatic download url for Rust Analyzer" + :type 'string + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "8.0.0")) + +(defcustom lsp-rust-analyzer-store-path (f-join lsp-server-install-dir "rust" + (pcase system-type + ('windows-nt "rust-analyzer.exe") + (_ "rust-analyzer"))) + "The path to the file in which `rust-analyzer' will be stored." + :type 'file + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "8.0.0")) + +(lsp-dependency + 'rust-analyzer + `(:download :url lsp-rust-analyzer-download-url + :decompress ,(pcase system-type ('windows-nt :zip) (_ :gzip)) + :store-path lsp-rust-analyzer-store-path + :set-executable? t) + `(:system ,(file-name-nondirectory lsp-rust-analyzer-store-path))) + +(lsp-defun lsp-rust--analyzer-run-single ((&Command :arguments?)) + (lsp-rust-analyzer-run (lsp-seq-first arguments?))) + +(lsp-defun lsp-rust--analyzer-show-references + ((&Command :title :arguments? [_uri _filepos references])) + (lsp-show-xrefs (lsp--locations-to-xref-items references) nil + (s-contains-p "reference" title))) + +(declare-function dap-debug "ext:dap-mode" (template) t) + +(lsp-defun lsp-rust--analyzer-debug-lens ((&Command :arguments? [args])) + (lsp-rust-analyzer-debug args)) + +;; Semantic tokens + +;; Modifier faces +(defface lsp-rust-analyzer-documentation-modifier-face + '((t nil)) + "The face modification to use for documentation items." + :group 'lsp-rust-analyzer-semantic-tokens) + +(defface lsp-rust-analyzer-declaration-modifier-face + '((t nil)) + "The face modification to use for declaration items." + :group 'lsp-rust-analyzer-semantic-tokens) + +(defface lsp-rust-analyzer-definition-modifier-face + '((t nil)) + "The face modification to use for definition items." + :group 'lsp-rust-analyzer-semantic-tokens) + +(defface lsp-rust-analyzer-static-modifier-face + '((t nil)) + "The face modification to use for static items." + :group 'lsp-rust-analyzer-semantic-tokens) + +(defface lsp-rust-analyzer-abstract-modifier-face + '((t nil)) + "The face modification to use for abstract items." + :group 'lsp-rust-analyzer-semantic-tokens) + +(defface lsp-rust-analyzer-deprecated-modifier-face + '((t nil)) + "The face modification to use for deprecated items." + :group 'lsp-rust-analyzer-semantic-tokens) + +(defface lsp-rust-analyzer-readonly-modifier-face + '((t nil)) + "The face modification to use for readonly items." + :group 'lsp-rust-analyzer-semantic-tokens) + +(defface lsp-rust-analyzer-default-library-modifier-face + '((t nil)) + "The face modification to use for default-library items." + :group 'lsp-rust-analyzer-semantic-tokens) + +(defface lsp-rust-analyzer-async-modifier-face + '((t nil)) + "The face modification to use for async items." + :group 'lsp-rust-analyzer-semantic-tokens) + +(defface lsp-rust-analyzer-attribute-modifier-face + '((t nil)) + "The face modification to use for attribute items." + :group 'lsp-rust-analyzer-semantic-tokens) + +(defface lsp-rust-analyzer-callable-modifier-face + '((t nil)) + "The face modification to use for callable items." + :group 'lsp-rust-analyzer-semantic-tokens) + +(defface lsp-rust-analyzer-constant-modifier-face + '((t nil)) + "The face modification to use for constant items." + :group 'lsp-rust-analyzer-semantic-tokens) + +(defface lsp-rust-analyzer-consuming-modifier-face + '((t nil)) + "The face modification to use for consuming items." + :group 'lsp-rust-analyzer-semantic-tokens) + +(defface lsp-rust-analyzer-control-flow-modifier-face + '((t nil)) + "The face modification to use for control-flow items." + :group 'lsp-rust-analyzer-semantic-tokens) + +(defface lsp-rust-analyzer-crate-root-modifier-face + '((t nil)) + "The face modification to use for crate-root items." + :group 'lsp-rust-analyzer-semantic-tokens) + +(defface lsp-rust-analyzer-injected-modifier-face + '((t nil)) + "The face modification to use for injected items." + :group 'lsp-rust-analyzer-semantic-tokens) + +(defface lsp-rust-analyzer-intra-doc-link-modifier-face + '((t nil)) + "The face modification to use for intra-doc-link items." + :group 'lsp-rust-analyzer-semantic-tokens) + +(defface lsp-rust-analyzer-library-modifier-face + '((t nil)) + "The face modification to use for library items." + :group 'lsp-rust-analyzer-semantic-tokens) + +(defface lsp-rust-analyzer-mutable-modifier-face + '((t :underline t)) + "The face modification to use for mutable items." + :group 'lsp-rust-analyzer-semantic-tokens) + +(defface lsp-rust-analyzer-public-modifier-face + '((t nil)) + "The face modification to use for public items." + :group 'lsp-rust-analyzer-semantic-tokens) + +(defface lsp-rust-analyzer-reference-modifier-face + '((t :bold t)) + "The face modification to use for reference items." + :group 'lsp-rust-analyzer-semantic-tokens) + +(defface lsp-rust-analyzer-trait-modifier-face + '((t nil)) + "The face modification to use for trait items." + :group 'lsp-rust-analyzer-semantic-tokens) + +(defface lsp-rust-analyzer-unsafe-modifier-face + '((t nil)) + "The face modification to use for unsafe items." + :group 'lsp-rust-analyzer-semantic-tokens) + + +;; --------------------------------------------------------------------- +;; Semantic token modifier face customization + +(defcustom lsp-rust-analyzer-documentation-modifier 'lsp-rust-analyzer-documentation-modifier-face + "Face for semantic token modifier for `documentation' attribute." + :type 'face + :group 'lsp-rust-analyzer-semantic-tokens + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-declaration-modifier 'lsp-rust-analyzer-declaration-modifier-face + "Face for semantic token modifier for `declaration' attribute." + :type 'face + :group 'lsp-rust-analyzer-semantic-tokens + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-definition-modifier 'lsp-rust-analyzer-definition-modifier-face + "Face for semantic token modifier for `definition' attribute." + :type 'face + :group 'lsp-rust-analyzer-semantic-tokens + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-static-modifier 'lsp-rust-analyzer-static-modifier-face + "Face for semantic token modifier for `static' attribute." + :type 'face + :group 'lsp-rust-analyzer-semantic-tokens + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-abstract-modifier 'lsp-rust-analyzer-abstract-modifier-face + "Face for semantic token modifier for `abstract' attribute." + :type 'face + :group 'lsp-rust-analyzer-semantic-tokens + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-deprecated-modifier 'lsp-rust-analyzer-deprecated-modifier-face + "Face for semantic token modifier for `deprecated' attribute." + :type 'face + :group 'lsp-rust-analyzer-semantic-tokens + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-readonly-modifier 'lsp-rust-analyzer-readonly-modifier-face + "Face for semantic token modifier for `readonly' attribute." + :type 'face + :group 'lsp-rust-analyzer-semantic-tokens + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-default-library-modifier 'lsp-rust-analyzer-default-library-modifier-face + "Face for semantic token modifier for `default' attribute." + :type 'face + :group 'lsp-rust-analyzer-semantic-tokens + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-async-modifier 'lsp-rust-analyzer-async-modifier-face + "Face for semantic token modifier for `async' attribute." + :type 'face + :group 'lsp-rust-analyzer-semantic-tokens + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-attribute-modifier 'lsp-rust-analyzer-attribute-modifier-face + "Face for semantic token modifier for `attribute' attribute." + :type 'face + :group 'lsp-rust-analyzer-semantic-tokens + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-callable-modifier 'lsp-rust-analyzer-callable-modifier-face + "Face for semantic token modifier for `callable' attribute." + :type 'face + :group 'lsp-rust-analyzer-semantic-tokens + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-constant-modifier 'lsp-rust-analyzer-constant-modifier-face + "Face for semantic token modifier for `constant' attribute." + :type 'face + :group 'lsp-rust-analyzer-semantic-tokens + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-consuming-modifier 'lsp-rust-analyzer-consuming-modifier-face + "Face for semantic token modifier for `consuming' attribute." + :type 'face + :group 'lsp-rust-analyzer-semantic-tokens + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-control-flow-modifier 'lsp-rust-analyzer-control-flow-modifier-face + "Face for semantic token modifier for `control_flow' attribute." + :type 'face + :group 'lsp-rust-analyzer-semantic-tokens + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-crate-root-modifier 'lsp-rust-analyzer-crate-root-modifier-face + "Face for semantic token modifier for `crate_root' attribute." + :type 'face + :group 'lsp-rust-analyzer-semantic-tokens + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-injected-modifier 'lsp-rust-analyzer-injected-modifier-face + "Face for semantic token modifier for `injected' attribute." + :type 'face + :group 'lsp-rust-analyzer-semantic-tokens + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-intra-doc-link-modifier 'lsp-rust-analyzer-intra-doc-link-modifier-face + "Face for semantic token modifier for `intra_doc_link' attribute." + :type 'face + :group 'lsp-rust-analyzer-semantic-tokens + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-library-modifier 'lsp-rust-analyzer-library-modifier-face + "Face for semantic token modifier for `library' attribute." + :type 'face + :group 'lsp-rust-analyzer-semantic-tokens + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-mutable-modifier 'lsp-rust-analyzer-mutable-modifier-face + "Face for semantic token modifier for `mutable' attribute." + :type 'face + :group 'lsp-rust-analyzer-semantic-tokens + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-public-modifier 'lsp-rust-analyzer-public-modifier-face + "Face for semantic token modifier for `public' attribute." + :type 'face + :group 'lsp-rust-analyzer-semantic-tokens + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-reference-modifier 'lsp-rust-analyzer-reference-modifier-face + "Face for semantic token modifier for `reference' attribute." + :type 'face + :group 'lsp-rust-analyzer-semantic-tokens + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-trait-modifier 'lsp-rust-analyzer-trait-modifier-face + "Face for semantic token modifier for `trait' attribute." + :type 'face + :group 'lsp-rust-analyzer-semantic-tokens + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-unsafe-modifier 'lsp-rust-analyzer-unsafe-modifier-face + "Face for semantic token modifier for `unsafe' attribute." + :type 'face + :group 'lsp-rust-analyzer-semantic-tokens + :package-version '(lsp-mode . "9.0.0")) + +;; --------------------------------------------------------------------- + +(defun lsp-rust-analyzer--semantic-modifiers () + "Mapping between rust-analyzer keywords and fonts to apply. +The keywords are sent in the initialize response, in the semantic +tokens legend." + `(("documentation" . ,lsp-rust-analyzer-documentation-modifier) + ("declaration" . ,lsp-rust-analyzer-declaration-modifier) + ("definition" . ,lsp-rust-analyzer-definition-modifier) + ("static" . ,lsp-rust-analyzer-static-modifier) + ("abstract" . ,lsp-rust-analyzer-abstract-modifier) + ("deprecated" . ,lsp-rust-analyzer-deprecated-modifier) + ("readonly" . ,lsp-rust-analyzer-readonly-modifier) + ("default_library" . ,lsp-rust-analyzer-default-library-modifier) + ("async" . ,lsp-rust-analyzer-async-modifier) + ("attribute" . ,lsp-rust-analyzer-attribute-modifier) + ("callable" . ,lsp-rust-analyzer-callable-modifier) + ("constant" . ,lsp-rust-analyzer-constant-modifier) + ("consuming" . ,lsp-rust-analyzer-consuming-modifier) + ("control_flow" . ,lsp-rust-analyzer-control-flow-modifier) + ("crate_root" . ,lsp-rust-analyzer-crate-root-modifier) + ("injected" . ,lsp-rust-analyzer-injected-modifier) + ("intra_doc_link" . ,lsp-rust-analyzer-intra-doc-link-modifier) + ("library" . ,lsp-rust-analyzer-library-modifier) + ("mutable" . ,lsp-rust-analyzer-mutable-modifier) + ("public" . ,lsp-rust-analyzer-public-modifier) + ("reference" . ,lsp-rust-analyzer-reference-modifier) + ("trait" . ,lsp-rust-analyzer-trait-modifier) + ("unsafe" . ,lsp-rust-analyzer-unsafe-modifier))) + +(defun lsp-rust-switch-server (&optional lsp-server) + "Switch priorities of lsp servers, unless LSP-SERVER is already active." + (interactive) + (let ((current-server (if (> (lsp--client-priority (gethash 'rls lsp-clients)) 0) + 'rls + 'rust-analyzer))) + (unless (eq lsp-server current-server) + (dolist (server '(rls rust-analyzer)) + (when (natnump (setf (lsp--client-priority (gethash server lsp-clients)) + (* (lsp--client-priority (gethash server lsp-clients)) -1))) + (message (format "Switched to server %s." server))))))) + +;; +;;; Inlay hints + +(defcustom lsp-rust-analyzer-debug-lens-extra-dap-args + '(:MIMode "gdb" :miDebuggerPath "gdb" :stopAtEntry t :externalConsole :json-false) + "Extra arguments to pass to DAP template when debugging a test from code lens. + +As a rule of the thumb, do not add extra keys to this plist unless you exactly +what you are doing, it might break the \"Debug test\" lens otherwise. + +See dap-mode documentation and cpptools documentation for the extra variables +meaning." + :type 'plist + :group 'lsp-rust-analyzer + :package-version '(lsp-mode . "8.0.0")) + +;; +;;; Lenses + +(defgroup lsp-rust-analyzer-lens nil + "LSP lens support for Rust when using rust-analyzer. + +Lenses are (depending on your configuration) clickable links to +the right of function definitions and the like. These display +some useful information in their own right and/or perform a +shortcut action when clicked such as displaying uses of that +function or running an individual test. +" + :prefix "lsp-rust-analyzer-lens-" + :group 'lsp-rust-analyzer + :link '(url-link "https://emacs-lsp.github.io/lsp-mode/") + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-lens-debug-enable t + "Enable or disable the Debug lens." + :type 'boolean + :group 'lsp-rust-analyzer-lens + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-lens-enable t + "Master-enable of lenses in Rust files." + :type 'boolean + :group 'lsp-rust-analyzer-lens + :package-version '(lsp-mode . "9.0.0")) + +;; This customisation "works" in that it works as described, but the default is fine and changing it +;; from the default will either stop lenses working or do nothing. +;; +;; If this is ever uncommented to re-enable the option, don't forget to also uncomment it in defun +;; lsp-rust-analyzer--make-init-options too or it'll not do anything. + +;; (defcustom lsp-rust-analyzer-lens-force-custom-commands t +;; "Internal config: use custom client-side commands even when the +;; client doesn't set the corresponding capability." +;; :type 'boolean +;; :group 'lsp-rust-analyzer-lens +;; :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-lens-implementations-enable t + "Enable or disable the Implementations lens. + +The Implementations lens shows `NN implementations' to the right +of the first line of an enum, struct, or union declaration. This +is the count of impl blocks, including derived traits. Clicking +on it gives a list of the impls of that type. +" + :type 'boolean + :group 'lsp-rust-analyzer-lens + :package-version '(lsp-mode . "9.0.0")) + +;; The valid range of values for this is documented in the rust-lang/rust-analyzer repository at the +;; path "editors/code/package.json"; the TL:DR is that it's "above_name" or "above_whole_item". +;; However, setting it to "above_whole_item" causes lenses to disappear in Emacs. I suspect this +;; feature has only ever been tested in some other IDE and it's broken in Emacs. So I've disabled it +;; for now. +;; +;; If this is ever uncommented to re-enable the option, don't forget to also uncomment it in defun +;; lsp-rust-analyzer--make-init-options too or it'll not do anything. + +;; (defcustom lsp-rust-analyzer-lens-location "above_name" +;; "Where to render annotations." +;; :type '(choice +;; (const :tag "Above name" "above_name") +;; (const :tag "Above whole item" "above_whole_item") +;; :group 'lsp-rust-analyzer-lens +;; :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-lens-references-adt-enable nil + "Enable or disable the References lens on enums, structs, and traits. + +The References lens shows `NN references` to the right of the +first line of each enum, struct, or union declaration. This is +the count of uses of that type. Clicking on it gives a list of +where that type is used." + :type 'boolean + :group 'lsp-rust-analyzer-lens + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-lens-references-enum-variant-enable nil + "Enable or disable the References lens on enum variants. + +The References lens shows `NN references` to the right of the +first (or only) line of each enum variant. This is the count of +uses of that enum variant. Clicking on it gives a list of where +that enum variant is used." + :type 'boolean + :group 'lsp-rust-analyzer-lens + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-lens-references-method-enable nil + "Enable or disable the References lens on functions. + +The References lens shows `NN references` to the right of the +first line of each function declaration. This is the count of +uses of that function. Clicking on it gives a list of where that +function is used." + + :type 'boolean + :group 'lsp-rust-analyzer-lens + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-lens-references-trait-enable nil + "Enable or disable the References lens on traits. + +The References lens shows `NN references` to the right of the +first line of each trait declaration. This is a count of uses of +that trait. Clicking on it gives a list of where that trait is +used. + +There is some overlap with the Implementations lens which slows +all of the trait's impl blocks, but this also shows other uses +such as imports and dyn traits." + :type 'boolean + :group 'lsp-rust-analyzer-lens + :package-version '(lsp-mode . "9.0.0")) + +(defcustom lsp-rust-analyzer-lens-run-enable t + "Enable or disable the Run lens." + :type 'boolean + :group 'lsp-rust-analyzer-lens + :package-version '(lsp-mode . "9.0.0")) + +(defun lsp-rust-analyzer-initialized? () + (when-let ((workspace (lsp-find-workspace 'rust-analyzer (buffer-file-name)))) + (eq 'initialized (lsp--workspace-status workspace)))) + +(defun lsp-rust-analyzer-expand-macro () + "Expands the macro call at point recursively." + (interactive) + (-if-let* ((params (lsp-make-rust-analyzer-expand-macro-params + :text-document (lsp--text-document-identifier) + :position (lsp--cur-position))) + (response (lsp-request + "rust-analyzer/expandMacro" + params)) + ((&rust-analyzer:ExpandedMacro :expansion) response)) + (funcall lsp-rust-analyzer-macro-expansion-method expansion) + (lsp--error "No macro found at point, or it could not be expanded."))) + +(defun lsp-rust-analyzer-macro-expansion-default (result) + "Default method for displaying macro expansion." + (let* ((root (lsp-workspace-root default-directory)) + (buf (get-buffer-create (get-buffer-create (format "*rust-analyzer macro expansion %s*" root))))) + (with-current-buffer buf + (let ((inhibit-read-only t)) + (erase-buffer) + (insert (lsp--render-string result "rust")) + (special-mode))) + (pop-to-buffer buf))) + +;; +;;; Runnables + +(defvar lsp-rust-analyzer--last-runnable nil + "Record the last runnable.") + +(defun lsp-rust-analyzer--runnables () + "Return list of runnables." + (lsp-send-request (lsp-make-request + "experimental/runnables" + (lsp-make-rust-analyzer-runnables-params + :text-document (lsp--text-document-identifier) + :position? (lsp--cur-position))))) + +(defun lsp-rust-analyzer--select-runnable () + "Select runnable." + (lsp--completing-read + "Select runnable:" + (if lsp-rust-analyzer--last-runnable + (cons lsp-rust-analyzer--last-runnable + (-remove (-lambda ((&rust-analyzer:Runnable :label)) + (equal label (lsp-get lsp-rust-analyzer--last-runnable :label))) + (lsp-rust-analyzer--runnables))) + (lsp-rust-analyzer--runnables)) + (-lambda ((&rust-analyzer:Runnable :label)) label))) + +(defun lsp-rust-analyzer--common-runner (runnable) + "Execute a given RUNNABLE. + +Extract the arguments, prepare the minor mode (cargo-process-mode if possible) +and run a compilation" + (-let* (((&rust-analyzer:Runnable :kind :label :args) runnable) + ((&rust-analyzer:RunnableArgs :cargo-args :executable-args :workspace-root? :expect-test?) args) + (default-directory (or workspace-root? default-directory))) + (if (not (string-equal kind "cargo")) + (lsp--error "'%s' runnable is not supported" kind) + (compilation-start + (string-join (append (when expect-test? '("env" "UPDATE_EXPECT=1")) + (list "cargo") cargo-args + (when executable-args '("--")) executable-args '()) " ") + + ;; cargo-process-mode is nice, but try to work without it... + (if (functionp 'cargo-process-mode) 'cargo-process-mode nil) + (lambda (_) (concat "*" label "*")))))) + +(defun lsp-rust-analyzer-run (runnable) + "Select and run a RUNNABLE action." + (interactive (list (lsp-rust-analyzer--select-runnable))) + (when (lsp-rust-analyzer--common-runner runnable) + (setq lsp-rust-analyzer--last-runnable runnable))) + +(defun lsp-rust-analyzer-debug (runnable) + "Select and debug a RUNNABLE action." + (interactive (list (lsp-rust-analyzer--select-runnable))) + (unless (or (featurep 'dap-cpptools) (featurep 'dap-gdb)) + (user-error "You must require `dap-cpptools' or 'dap-gdb'")) + (-let (((&rust-analyzer:Runnable + :args (&rust-analyzer:RunnableArgs :cargo-args :workspace-root? :executable-args) + :label) runnable)) + (pcase (aref cargo-args 0) + ("run" (aset cargo-args 0 "build")) + ("test" (when (-contains? (append cargo-args ()) "--no-run") + (cl-callf append cargo-args (list "--no-run"))))) + (->> (append (list (executable-find "cargo")) + cargo-args + (list "--message-format=json")) + (s-join " ") + (shell-command-to-string) + (s-lines) + (-keep (lambda (s) + (condition-case nil + (-let* ((json-object-type 'plist) + ((msg &as &plist :reason :executable) (json-read-from-string s))) + (when (and executable (string= "compiler-artifact" reason)) + executable)) + (error)))) + (funcall + (lambda (artifact-spec) + (pcase artifact-spec + (`() (user-error "No compilation artifacts or obtaining the runnable artifacts failed")) + (`(,spec) spec) + (_ (user-error "Multiple compilation artifacts are not supported"))))) + (list :type (if (featurep 'dap-gdb) "gdb" "cppdbg") + :request "launch" + :name label + :args executable-args + :cwd workspace-root? + :sourceLanguages ["rust"] + :program) + (append lsp-rust-analyzer-debug-lens-extra-dap-args) + (dap-debug)))) + +(defun lsp-rust-analyzer-rerun (&optional runnable) + (interactive (list (or lsp-rust-analyzer--last-runnable + (lsp-rust-analyzer--select-runnable)))) + (lsp-rust-analyzer-run (or runnable lsp-rust-analyzer--last-runnable))) + +;; goto parent module +(cl-defun lsp-rust-find-parent-module (&key display-action) + "Find parent module of current module." + (interactive) + (lsp-find-locations "experimental/parentModule" nil :display-action display-action)) + +(defun lsp-rust-analyzer-open-cargo-toml (&optional new-window) + "Open the closest Cargo.toml from the current file. + +Rust-Analyzer LSP protocol documented here and added in November 2020 +https://github.com/rust-lang/rust-analyzer/blob/master/docs/dev/lsp-extensions.md#open-cargotoml + +If NEW-WINDOW (interactively the prefix argument) is non-nil, +open in a new window." + (interactive "P") + (-if-let (workspace (lsp-find-workspace 'rust-analyzer (buffer-file-name))) + (-if-let* ((response (with-lsp-workspace workspace + (lsp-send-request (lsp-make-request + "experimental/openCargoToml" + (lsp-make-rust-analyzer-open-cargo-toml-params + :text-document (lsp--text-document-identifier)))))) + ((&Location :uri :range) response)) + (funcall (if new-window #'find-file-other-window #'find-file) + (lsp--uri-to-path uri)) + (lsp--warn "Couldn't find a Cargo.toml file or your version of rust-analyzer doesn't support this extension")) + (lsp--error "OpenCargoToml is an extension available only with rust-analyzer"))) + +(defun lsp-rust-analyzer-open-external-docs () + "Open a URL for documentation related to the current TextDocumentPosition. + +Rust-Analyzer LSP protocol documented here +https://github.com/rust-lang/rust-analyzer/blob/master/docs/dev/lsp-extensions.md#open-external-documentation" + (interactive) + (-if-let* ((params (lsp-make-rust-analyzer-open-external-docs-params + :text-document (lsp--text-document-identifier) + :position (lsp--cur-position))) + (url (lsp-request "experimental/externalDocs" params))) + (browse-url url) + (lsp--warn "Couldn't find documentation URL or your version of rust-analyzer doesn't support this extension"))) + +(defun lsp-rust-analyzer--related-tests () + "Get runnable test items related to the current TextDocumentPosition. +Calls a rust-analyzer LSP extension endpoint that returns a wrapper over +Runnable[]." + (lsp-send-request (lsp-make-request + "rust-analyzer/relatedTests" + (lsp--text-document-position-params)))) + +(defun lsp-rust-analyzer--select-related-test () + "Call the endpoint and ask for user selection. + +Cannot reuse `lsp-rust-analyzer--select-runnable' because the runnables endpoint +responds with Runnable[], while relatedTests responds with TestInfo[], +which is a wrapper over runnable. Also, this method doesn't set +the `lsp-rust-analyzer--last-runnable' variable." + (-if-let* ((resp (lsp-rust-analyzer--related-tests)) + (runnables (seq-map + #'lsp:rust-analyzer-related-tests-runnable + resp))) + (lsp--completing-read + "Select test: " + runnables + #'lsp:rust-analyzer-runnable-label))) + +(defun lsp-rust-analyzer-related-tests (runnable) + "Execute a RUNNABLE test related to the current document position. + +Rust-Analyzer LSP protocol extension +https://github.com/rust-lang/rust-analyzer/blob/master/docs/dev/lsp-extensions.md#related-tests" + (interactive (list (lsp-rust-analyzer--select-related-test))) + (if runnable + (lsp-rust-analyzer--common-runner runnable) + (lsp--info "There are no tests related to the symbol at point"))) + +(defun lsp-rust-analyzer-move-item (direction) + "Move item under cursor or selection in some DIRECTION" + (let* ((params (lsp-make-rust-analyzer-move-item-params + :text-document (lsp--text-document-identifier) + :range (if (use-region-p) + (lsp--region-to-range (region-beginning) (region-end)) + (lsp--region-to-range (point) (point))) + :direction direction)) + (edits (lsp-request "experimental/moveItem" params))) + (lsp--apply-text-edits edits 'code-action))) + +(defun lsp-rust-analyzer-move-item-up () + "Move item under cursor or selection up" + (interactive) + (lsp-rust-analyzer-move-item "Up")) + +(defun lsp-rust-analyzer-move-item-down () + "Move item under cursor or selection down" + (interactive) + (lsp-rust-analyzer-move-item "Down")) + +(defun lsp-rust-analyzer--make-init-options () + "Init options for rust-analyzer" + `(:diagnostics + ( :enable ,(lsp-json-bool lsp-rust-analyzer-diagnostics-enable) + :enableExperimental ,(lsp-json-bool lsp-rust-analyzer-diagnostics-enable-experimental) + :disabled ,lsp-rust-analyzer-diagnostics-disabled + :warningsAsHint ,lsp-rust-analyzer-diagnostics-warnings-as-hint + :warningsAsInfo ,lsp-rust-analyzer-diagnostics-warnings-as-info) + :imports ( :granularity ( :enforce ,(lsp-json-bool lsp-rust-analyzer-import-enforce-granularity) + :group ,lsp-rust-analyzer-import-granularity) + :group ,(lsp-json-bool lsp-rust-analyzer-import-group) + :merge (:glob ,(lsp-json-bool lsp-rust-analyzer-imports-merge-glob)) + :prefix ,lsp-rust-analyzer-import-prefix) + :lruCapacity ,lsp-rust-analyzer-lru-capacity + :checkOnSave ( :enable ,(lsp-json-bool lsp-rust-analyzer-cargo-watch-enable) + :command ,lsp-rust-analyzer-cargo-watch-command + :extraArgs ,lsp-rust-analyzer-cargo-watch-args + :allTargets ,(lsp-json-bool lsp-rust-analyzer-check-all-targets) + :features ,lsp-rust-analyzer-checkonsave-features + :overrideCommand ,lsp-rust-analyzer-cargo-override-command) + :highlightRelated ( :breakPoints (:enable ,(lsp-json-bool lsp-rust-analyzer-highlight-breakpoints)) + :closureCaptures (:enable ,(lsp-json-bool lsp-rust-analyzer-highlight-closure-captures)) + :exitPoints (:enable ,(lsp-json-bool lsp-rust-analyzer-highlight-exit-points)) + :references (:enable ,(lsp-json-bool lsp-rust-analyzer-highlight-references)) + :yieldPoints (:enable ,(lsp-json-bool lsp-rust-analyzer-highlight-yield-points))) + :files ( :exclude ,lsp-rust-analyzer-exclude-globs + :watcher ,(if lsp-rust-analyzer-use-client-watching "client" "notify") + :excludeDirs ,lsp-rust-analyzer-exclude-dirs) + :cargo ( :allFeatures ,(lsp-json-bool lsp-rust-all-features) + :noDefaultFeatures ,(lsp-json-bool lsp-rust-no-default-features) + :features ,lsp-rust-features + :extraArgs ,lsp-rust-analyzer-cargo-extra-args + :extraEnv ,lsp-rust-analyzer-cargo-extra-env + :target ,lsp-rust-analyzer-cargo-target + :runBuildScripts ,(lsp-json-bool lsp-rust-analyzer-cargo-run-build-scripts) + ;; Obsolete, but used by old Rust-Analyzer versions + :loadOutDirsFromCheck ,(lsp-json-bool lsp-rust-analyzer-cargo-run-build-scripts) + :autoreload ,(lsp-json-bool lsp-rust-analyzer-cargo-auto-reload) + :useRustcWrapperForBuildScripts ,(lsp-json-bool lsp-rust-analyzer-use-rustc-wrapper-for-build-scripts) + :unsetTest ,lsp-rust-analyzer-cargo-unset-test) + :rustfmt ( :extraArgs ,lsp-rust-analyzer-rustfmt-extra-args + :overrideCommand ,lsp-rust-analyzer-rustfmt-override-command + :rangeFormatting (:enable ,(lsp-json-bool lsp-rust-analyzer-rustfmt-rangeformatting-enable))) + :lens ( :debug (:enable ,(lsp-json-bool lsp-rust-analyzer-lens-debug-enable)) + :enable ,(lsp-json-bool lsp-rust-analyzer-lens-enable) + ;; :forceCustomCommands ,(lsp-json-bool lsp-rust-analyzer-lens-force-custom-commands) + :implementations (:enable ,(lsp-json-bool lsp-rust-analyzer-lens-implementations-enable)) + ;; :location ,lsp-rust-analyzer-lens-location + :references ( :adt (:enable ,(lsp-json-bool lsp-rust-analyzer-lens-references-adt-enable)) + :enumVariant (:enable ,(lsp-json-bool lsp-rust-analyzer-lens-references-enum-variant-enable)) + :method (:enable ,(lsp-json-bool lsp-rust-analyzer-lens-references-method-enable)) + :trait (:enable ,(lsp-json-bool lsp-rust-analyzer-lens-references-trait-enable))) + :run (:enable ,(lsp-json-bool lsp-rust-analyzer-lens-run-enable))) + + :inlayHints ( :bindingModeHints (:enable ,(lsp-json-bool lsp-rust-analyzer-binding-mode-hints)) + :chainingHints (:enable ,(lsp-json-bool lsp-rust-analyzer-display-chaining-hints)) + :closingBraceHints ( :enable ,(lsp-json-bool lsp-rust-analyzer-closing-brace-hints) + :minLines ,lsp-rust-analyzer-closing-brace-hints-min-lines) + :closureCaptureHints (:enable ,(lsp-json-bool lsp-rust-analyzer-closure-capture-hints)) + :closureReturnTypeHints (:enable ,lsp-rust-analyzer-closure-return-type-hints) + :closureStyle ,lsp-rust-analyzer-closure-style + :discriminantHints (:enable ,lsp-rust-analyzer-discriminants-hints) + + :expressionAdjustmentHints ( :enable ,lsp-rust-analyzer-expression-adjustment-hints + :hideOutsideUnsafe ,(lsp-json-bool lsp-rust-analyzer-expression-adjustment-hide-unsafe) + :mode ,lsp-rust-analyzer-expression-adjustment-hints-mode) + :implicitDrops (:enable ,(lsp-json-bool lsp-rust-analyzer-implicit-drops)) + :lifetimeElisionHints ( :enable ,lsp-rust-analyzer-display-lifetime-elision-hints-enable + :useParameterNames ,(lsp-json-bool lsp-rust-analyzer-display-lifetime-elision-hints-use-parameter-names)) + :maxLength ,lsp-rust-analyzer-max-inlay-hint-length + :parameterHints (:enable ,(lsp-json-bool lsp-rust-analyzer-display-parameter-hints)) + :reborrowHints (:enable ,lsp-rust-analyzer-display-reborrow-hints) + :renderColons ,(lsp-json-bool lsp-rust-analyzer-server-format-inlay-hints) + :typeHints ( :enable ,(lsp-json-bool lsp-inlay-hint-enable) + :hideClosureInitialization ,(lsp-json-bool lsp-rust-analyzer-hide-closure-initialization) + :hideNamedConstructor ,(lsp-json-bool lsp-rust-analyzer-hide-named-constructor))) + :completion ( :addCallParenthesis ,(lsp-json-bool lsp-rust-analyzer-completion-add-call-parenthesis) + :addCallArgumentSnippets ,(lsp-json-bool lsp-rust-analyzer-completion-add-call-argument-snippets) + :postfix (:enable ,(lsp-json-bool lsp-rust-analyzer-completion-postfix-enable)) + :autoimport (:enable ,(lsp-json-bool lsp-rust-analyzer-completion-auto-import-enable)) + :autoself (:enable ,(lsp-json-bool lsp-rust-analyzer-completion-auto-self-enable))) + :callInfo (:full ,(lsp-json-bool lsp-rust-analyzer-call-info-full)) + :procMacro (:enable ,(lsp-json-bool lsp-rust-analyzer-proc-macro-enable)) + :rustcSource ,lsp-rust-analyzer-rustc-source + :linkedProjects ,lsp-rust-analyzer-linked-projects + :highlighting (:strings ,(lsp-json-bool lsp-rust-analyzer-highlighting-strings)) + :experimental (:procAttrMacros ,(lsp-json-bool lsp-rust-analyzer-experimental-proc-attr-macros)))) + +(lsp-register-client + (make-lsp-client + :new-connection (lsp-stdio-connection + (lambda () + `(,(or (executable-find + (cl-first lsp-rust-analyzer-server-command)) + (lsp-package-path 'rust-analyzer) + "rust-analyzer") + ,@(cl-rest lsp-rust-analyzer-server-command)))) + :activation-fn (lsp-activate-on "rust") + :priority (if (eq lsp-rust-server 'rust-analyzer) 1 -1) + :initialization-options 'lsp-rust-analyzer--make-init-options + :notification-handlers (ht<-alist lsp-rust-notification-handlers) + :action-handlers (ht ("rust-analyzer.runSingle" #'lsp-rust--analyzer-run-single) + ("rust-analyzer.debugSingle" #'lsp-rust--analyzer-debug-lens) + ("rust-analyzer.showReferences" #'lsp-rust--analyzer-show-references) + ("rust-analyzer.triggerParameterHints" #'lsp--action-trigger-parameter-hints)) + :library-folders-fn (lambda (_workspace) lsp-rust-analyzer-library-directories) + :semantic-tokens-faces-overrides `( :discard-default-modifiers t + :modifiers ,(lsp-rust-analyzer--semantic-modifiers)) + :server-id 'rust-analyzer + :custom-capabilities `((experimental . ((snippetTextEdit . ,(and lsp-enable-snippet (fboundp 'yas-minor-mode)))))) + :download-server-fn (lambda (_client callback error-callback _update?) + (lsp-package-ensure 'rust-analyzer callback error-callback)))) + +(cl-defmethod lsp-clients-extract-signature-on-hover (contents (_server-id (eql rust-analyzer))) + "Extract first non-comment line from rust-analyzer's hover CONTENTS. +The first line of the hover contents is usally about memory layout or notable +traits starting with //, with the actual signature follows." + (let* ((lines (s-lines (s-trim (lsp--render-element contents)))) + (non-comment-lines (--filter (not (s-prefix? "//" it)) lines))) + (if non-comment-lines + (car non-comment-lines) + (car lines)))) + +(lsp-consistency-check lsp-rust) + +(provide 'lsp-rust) +;;; lsp-rust.el ends here diff --git a/emacs/elpa/lsp-mode-20240531.2326/lsp-rust.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-rust.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-semantic-tokens.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-semantic-tokens.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-semantic-tokens.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-semantic-tokens.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-semgrep.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-semgrep.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-semgrep.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-semgrep.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-sml.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-sml.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-sml.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-sml.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-solargraph.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-solargraph.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-solargraph.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-solargraph.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-solidity.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-solidity.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-solidity.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-solidity.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-sorbet.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-sorbet.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-sorbet.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-sorbet.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-sql.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-sql.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-sql.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-sql.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-sqls.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-sqls.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-sqls.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-sqls.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-steep.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-steep.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-steep.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-steep.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-svelte.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-svelte.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-svelte.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-svelte.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-terraform.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-terraform.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-terraform.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-terraform.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240531.2326/lsp-tex.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-tex.el @@ -0,0 +1,68 @@ +;;; lsp-tex.el --- description -*- lexical-binding: t; -*- + +;; Copyright (C) 2020 emacs-lsp maintainers + +;; Author: emacs-lsp maintainers +;; Keywords: lsp, tex + +;; 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 <https://www.gnu.org/licenses/>. + +;;; Commentary: + +;; LSP Clients for the Tex Typesetting Language. + +;;; Code: + +(require 'lsp-mode) + +(defgroup lsp-tex nil + "LSP support for TeX and friends, using Digestif and texlab." + :group 'lsp-mode + :link '(url-link "https://github.com/astoff/digestif/") + :link '(url-link "https://github.com/latex-lsp/texlab")) + +(defcustom lsp-tex-server 'texlab + "Choose LSP tex server." + :type '(choice (const :tag "texlab" texlab) + (const :tag "digestif" digestif)) + :group 'lsp-tex) + +(defcustom lsp-clients-digestif-executable "digestif" + "Command to start the Digestif language server." + :group 'lsp-tex + :risky t + :type 'file) + +(lsp-register-client + (make-lsp-client :new-connection (lsp-stdio-connection lsp-clients-digestif-executable) + :major-modes '(plain-tex-mode latex-mode context-mode texinfo-mode LaTex-mode) + :priority (if (eq lsp-tex-server 'digestif) 1 -1) + :server-id 'digestif)) + +(defcustom lsp-clients-texlab-executable "texlab" + "Command to start the texlab language server." + :group 'lsp-tex + :risky t + :type 'file) + +(lsp-register-client + (make-lsp-client :new-connection (lsp-stdio-connection lsp-clients-texlab-executable) + :major-modes '(plain-tex-mode latex-mode LaTeX-mode) + :priority (if (eq lsp-tex-server 'texlab) 1 -1) + :server-id 'texlab)) + +(lsp-consistency-check lsp-tex) + +(provide 'lsp-tex) +;;; lsp-tex.el ends here diff --git a/emacs/elpa/lsp-mode-20240531.2326/lsp-tex.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-tex.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-tilt.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-tilt.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-tilt.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-tilt.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-toml.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-toml.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-toml.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-toml.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-trunk.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-trunk.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-trunk.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-trunk.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-ttcn3.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-ttcn3.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-ttcn3.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-ttcn3.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-typeprof.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-typeprof.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-typeprof.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-typeprof.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-v.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-v.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-v.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-v.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-vala.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-vala.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-vala.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-vala.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-verilog.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-verilog.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-verilog.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-verilog.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-vetur.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-vetur.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-vetur.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-vetur.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-vhdl.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-vhdl.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-vhdl.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-vhdl.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-vimscript.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-vimscript.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-vimscript.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-vimscript.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-volar.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-volar.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-volar.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-volar.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-wgsl.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-wgsl.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-wgsl.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-wgsl.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-xml.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-xml.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-xml.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-xml.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-yaml.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-yaml.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-yaml.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-yaml.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-yang.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-yang.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-yang.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-yang.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-zig.el b/emacs/elpa/lsp-mode-20240531.2326/lsp-zig.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp-zig.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp-zig.elc Binary files differ. diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp.el b/emacs/elpa/lsp-mode-20240531.2326/lsp.el diff --git a/emacs/elpa/lsp-mode-20240514.1430/lsp.elc b/emacs/elpa/lsp-mode-20240531.2326/lsp.elc Binary files differ. diff --git a/emacs/elpa/magit-20240514.1843/magit-diff.elc b/emacs/elpa/magit-20240514.1843/magit-diff.elc Binary files differ. diff --git a/emacs/elpa/magit-20240514.1843/magit-pkg.el b/emacs/elpa/magit-20240514.1843/magit-pkg.el @@ -1,20 +0,0 @@ -(define-package "magit" "20240514.1843" "A Git porcelain inside Emacs." - '((emacs "26.1") - (compat "29.1.4.5") - (dash "20240405") - (git-commit "20240429") - (magit-section "20240429") - (seq "2.24") - (transient "20240421") - (with-editor "20240415")) - :commit "9cde118744151caca08b080e15f0c903f17d0f20" :authors - '(("Marius Vollmer" . "marius.vollmer@gmail.com") - ("Jonas Bernoulli" . "emacs.magit@jonas.bernoulli.dev")) - :maintainer - '("Jonas Bernoulli" . "emacs.magit@jonas.bernoulli.dev") - :keywords - '("git" "tools" "vc") - :url "https://github.com/magit/magit") -;; Local Variables: -;; no-byte-compile: t -;; End: diff --git a/emacs/elpa/magit-20240514.1843/magit-transient.elc b/emacs/elpa/magit-20240514.1843/magit-transient.elc Binary files differ. diff --git a/emacs/elpa/magit-20240514.1843/magit.info b/emacs/elpa/magit-20240514.1843/magit.info @@ -1,11594 +0,0 @@ -This is magit.info, produced by makeinfo version 6.7 from magit.texi. - - Copyright (C) 2015-2024 Jonas Bernoulli - <emacs.magit@jonas.bernoulli.dev> - - You can redistribute this document 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 document 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. - -INFO-DIR-SECTION Emacs -START-INFO-DIR-ENTRY -* Magit: (magit). Using Git from Emacs with Magit. -END-INFO-DIR-ENTRY - - -File: magit.info, Node: Top, Next: Introduction, Up: (dir) - -Magit User Manual -***************** - -Magit is an interface to the version control system Git, implemented as -an Emacs package. Magit aspires to be a complete Git porcelain. While -we cannot (yet) claim that Magit wraps and improves upon each and every -Git command, it is complete enough to allow even experienced Git users -to perform almost all of their daily version control tasks directly from -within Emacs. While many fine Git clients exist, only Magit and Git -itself deserve to be called porcelains. - -This manual is for Magit version 3.3.0.50-git. - - Copyright (C) 2015-2024 Jonas Bernoulli - <emacs.magit@jonas.bernoulli.dev> - - You can redistribute this document 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 document 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. - -* Menu: - -* Introduction:: -* Installation:: -* Getting Started:: -* Interface Concepts:: -* Inspecting:: -* Manipulating:: -* Transferring:: -* Miscellaneous:: -* Customizing:: -* Plumbing:: -* FAQ:: -* Debugging Tools:: -* Keystroke Index:: -* Function and Command Index:: -* Variable Index:: - -— The Detailed Node Listing — - -Installation - -* Installing from Melpa:: -* Installing from the Git Repository:: -* Post-Installation Tasks:: - -Interface Concepts - -* Modes and Buffers:: -* Sections:: -* Transient Commands:: -* Transient Arguments and Buffer Variables:: -* Completion, Confirmation and the Selection: Completion Confirmation and the Selection. -* Mouse Support:: -* Running Git:: - -Modes and Buffers - -* Switching Buffers:: -* Naming Buffers:: -* Quitting Windows:: -* Automatic Refreshing of Magit Buffers:: -* Automatic Saving of File-Visiting Buffers:: -* Automatic Reverting of File-Visiting Buffers:: - - -Sections - -* Section Movement:: -* Section Visibility:: -* Section Hooks:: -* Section Types and Values:: -* Section Options:: - - -Completion, Confirmation and the Selection - -* Action Confirmation:: -* Completion and Confirmation:: -* The Selection:: -* The hunk-internal region:: -* Support for Completion Frameworks:: -* Additional Completion Options:: - - -Running Git - -* Viewing Git Output:: -* Git Process Status:: -* Running Git Manually:: -* Git Executable:: -* Global Git Arguments:: - - -Inspecting - -* Status Buffer:: -* Repository List:: -* Logging:: -* Diffing:: -* Ediffing:: -* References Buffer:: -* Bisecting:: -* Visiting Files and Blobs:: -* Blaming:: - -Status Buffer - -* Status Sections:: -* Status Header Sections:: -* Status Module Sections:: -* Status Options:: - - -Logging - -* Refreshing Logs:: -* Log Buffer:: -* Log Margin:: -* Select from Log:: -* Reflog:: -* Cherries:: - - -Diffing - -* Refreshing Diffs:: -* Commands Available in Diffs:: -* Diff Options:: -* Revision Buffer:: - - -References Buffer - -* References Sections:: - - -Visiting Files and Blobs - -* General-Purpose Visit Commands:: -* Visiting Files and Blobs from a Diff:: - - -Manipulating - -* Creating Repository:: -* Cloning Repository:: -* Staging and Unstaging:: -* Applying:: -* Committing:: -* Branching:: -* Merging:: -* Resolving Conflicts:: -* Rebasing:: -* Cherry Picking:: -* Resetting:: -* Stashing:: - -Staging and Unstaging - -* Staging from File-Visiting Buffers:: - - -Committing - -* Initiating a Commit:: -* Editing Commit Messages:: - - -Branching - -* The Two Remotes:: -* Branch Commands:: -* Branch Git Variables:: -* Auxiliary Branch Commands:: - - -Rebasing - -* Editing Rebase Sequences:: -* Information About In-Progress Rebase:: - - -Cherry Picking - -* Reverting:: - - -Transferring - -* Remotes:: -* Fetching:: -* Pulling:: -* Pushing:: -* Plain Patches:: -* Maildir Patches:: - -Remotes - -* Remote Commands:: -* Remote Git Variables:: - - -Miscellaneous - -* Tagging:: -* Notes:: -* Submodules:: -* Subtree:: -* Worktree:: -* Sparse checkouts:: -* Bundle:: -* Common Commands:: -* Wip Modes:: -* Commands for Buffers Visiting Files:: -* Minor Mode for Buffers Visiting Blobs:: - -Submodules - -* Listing Submodules:: -* Submodule Transient:: - - -Wip Modes - -* Wip Graph:: -* Legacy Wip Modes:: - - -Customizing - -* Per-Repository Configuration:: -* Essential Settings:: - -Essential Settings - -* Safety:: -* Performance:: -* Global Bindings:: - - -Plumbing - -* Calling Git:: -* Section Plumbing:: -* Refreshing Buffers:: -* Conventions:: - -Calling Git - -* Getting a Value from Git:: -* Calling Git for Effect:: - - -Section Plumbing - -* Creating Sections:: -* Section Selection:: -* Matching Sections:: - - -Conventions - -* Theming Faces:: - - -FAQ - -* FAQ - How to ...?:: -* FAQ - Issues and Errors:: - -FAQ - How to ...? - -* How to pronounce Magit?:: -* How to show git's output?:: -* How to install the gitman info manual?:: -* How to show diffs for gpg-encrypted files?:: -* How does branching and pushing work?:: -* Should I disable VC?:: - - -FAQ - Issues and Errors - -* Magit is slow:: -* I changed several thousand files at once and now Magit is unusable:: -* I am having problems committing:: -* I am using MS Windows and cannot push with Magit:: -* I am using macOS and SOMETHING works in shell, but not in Magit: I am using macOS and SOMETHING works in shell but not in Magit. -* Expanding a file to show the diff causes it to disappear:: -* Point is wrong in the COMMIT_EDITMSG buffer:: -* The mode-line information isn't always up-to-date:: -* A branch and tag sharing the same name breaks SOMETHING:: -* My Git hooks work on the command-line but not inside Magit:: -* git-commit-mode isn't used when committing from the command-line:: -* Point ends up inside invisible text when jumping to a file-visiting buffer:: -* I am no longer able to save popup defaults:: - - - - -File: magit.info, Node: Introduction, Next: Installation, Prev: Top, Up: Top - -1 Introduction -************** - -Magit is an interface to the version control system Git, implemented as -an Emacs package. Magit aspires to be a complete Git porcelain. While -we cannot (yet) claim that Magit wraps and improves upon each and every -Git command, it is complete enough to allow even experienced Git users -to perform almost all of their daily version control tasks directly from -within Emacs. While many fine Git clients exist, only Magit and Git -itself deserve to be called porcelains. - - Staging and otherwise applying changes is one of the most important -features in a Git porcelain and here Magit outshines anything else, -including Git itself. Git’s own staging interface (‘git add --patch’) -is so cumbersome that many users only use it in exceptional cases. In -Magit staging a hunk or even just part of a hunk is as trivial as -staging all changes made to a file. - - The most visible part of Magit’s interface is the status buffer, -which displays information about the current repository. Its content is -created by running several Git commands and making their output -actionable. Among other things, it displays information about the -current branch, lists unpulled and unpushed changes and contains -sections displaying the staged and unstaged changes. That might sound -noisy, but, since sections are collapsible, it’s not. - - To stage or unstage a change one places the cursor on the change and -then types ‘s’ or ‘u’. The change can be a file or a hunk, or when the -region is active (i.e., when there is a selection) several files or -hunks, or even just part of a hunk. The change or changes that these -commands - and many others - would act on are highlighted. - - Magit also implements several other "apply variants" in addition to -staging and unstaging. One can discard or reverse a change, or apply it -to the working tree. Git’s own porcelain only supports this for staging -and unstaging and you would have to do something like ‘git diff ... | -??? | git apply ...’ to discard, revert, or apply a single hunk on the -command line. In fact that’s exactly what Magit does internally (which -is what lead to the term "apply variants"). - - Magit isn’t just for Git experts, but it does assume some prior -experience with Git as well as Emacs. That being said, many users have -reported that using Magit was what finally taught them what Git is -capable of and how to use it to its fullest. Other users wished they -had switched to Emacs sooner so that they would have gotten their hands -on Magit earlier. - - While one has to know the basic features of Emacs to be able to make -full use of Magit, acquiring just enough Emacs skills doesn’t take long -and is worth it, even for users who prefer other editors. Vim users are -advised to give Evil (https://github.com/emacs-evil/evil), the -"Extensible VI Layer for Emacs", and Spacemacs -(https://github.com/syl20bnr/spacemacs), an "Emacs starter-kit focused -on Evil" a try. - - Magit provides a consistent and efficient Git porcelain. After a -short learning period, you will be able to perform most of your daily -version control tasks faster than you would on the command line. You -will likely also start using features that seemed too daunting in the -past. - - Magit fully embraces Git. It exposes many advanced features using a -simple but flexible interface instead of only wrapping the trivial ones -like many GUI clients do. Of course Magit supports logging, cloning, -pushing, and other commands that usually don’t fail in spectacular ways; -but it also supports tasks that often cannot be completed in a single -step. Magit fully supports tasks such as merging, rebasing, -cherry-picking, reverting, and blaming by not only providing a command -to initiate these tasks but also by displaying context sensitive -information along the way and providing commands that are useful for -resolving conflicts and resuming the sequence after doing so. - - Magit wraps and in many cases improves upon at least the following -Git porcelain commands: ‘add’, ‘am’, ‘bisect’, ‘blame’, ‘branch’, -‘checkout’, ‘cherry’, ‘cherry-pick’, ‘clean’, ‘clone’, ‘commit’, -‘config’, ‘describe’, ‘diff’, ‘fetch’, ‘format-patch’, ‘init’, ‘log’, -‘merge’, ‘merge-tree’, ‘mv’, ‘notes’, ‘pull’, ‘rebase’, ‘reflog’, -‘remote’, ‘request-pull’, ‘reset’, ‘revert’, ‘rm’, ‘show’, ‘stash’, -‘submodule’, ‘subtree’, ‘tag’, and ‘worktree.’ Many more Magit porcelain -commands are implemented on top of Git plumbing commands. - - -File: magit.info, Node: Installation, Next: Getting Started, Prev: Introduction, Up: Top - -2 Installation -************** - -Magit can be installed using Emacs’ package manager or manually from its -development repository. - -* Menu: - -* Installing from Melpa:: -* Installing from the Git Repository:: -* Post-Installation Tasks:: - - -File: magit.info, Node: Installing from Melpa, Next: Installing from the Git Repository, Up: Installation - -2.1 Installing from Melpa -========================= - -Magit is available from Melpa and Melpa-Stable. If you haven’t used -Emacs’ package manager before, then it is high time you familiarize -yourself with it by reading the documentation in the Emacs manual, see -*note (emacs)Packages::. Then add one of the archives to -‘package-archives’: - - • To use Melpa: - - (require 'package) - (add-to-list 'package-archives - '("melpa" . "https://melpa.org/packages/") t) - - • To use Melpa-Stable: - - (require 'package) - (add-to-list 'package-archives - '("melpa-stable" . "https://stable.melpa.org/packages/") t) - - Once you have added your preferred archive, you need to update the -local package list using: - - M-x package-refresh-contents RET - - Once you have done that, you can install Magit and its dependencies -using: - - M-x package-install RET magit RET - - Now see *note Post-Installation Tasks::. - - -File: magit.info, Node: Installing from the Git Repository, Next: Post-Installation Tasks, Prev: Installing from Melpa, Up: Installation - -2.2 Installing from the Git Repository -====================================== - -Magit depends on the ‘compat’, ‘dash’, ‘transient’ and ‘with-editor’ -libraries which are available from Melpa and Melpa-Stable. Install them -using ‘M-x package-install RET <package> RET’. Of course you may also -install them manually from their repository. - - Then clone the Magit repository: - - $ git clone https://github.com/magit/magit.git ~/.emacs.d/site-lisp/magit - $ cd ~/.emacs.d/site-lisp/magit - - Then compile the libraries and generate the info manuals: - - $ make - - If you haven’t installed ‘compat’, ‘dash’, ‘transient’ and -‘with-editor’ from Melpa or at ‘/path/to/magit/../<package>’, then you -have to tell ‘make’ where to find them. To do so create the file -‘/path/to/magit/config.mk’ with the following content before running -‘make’: - - LOAD_PATH = -L ~/.emacs.d/site-lisp/magit/lisp - LOAD_PATH += -L ~/.emacs.d/site-lisp/dash - LOAD_PATH += -L ~/.emacs.d/site-lisp/transient/lisp - LOAD_PATH += -L ~/.emacs.d/site-lisp/with-editor/lisp - LOAD_PATH += -L ~/.emacs.d/site-lisp/compat - - Finally add this to your init file: - - (add-to-list 'load-path "~/.emacs.d/site-lisp/magit/lisp") - (require 'magit) - - (with-eval-after-load 'info - (info-initialize) - (add-to-list 'Info-directory-list - "~/.emacs.d/site-lisp/magit/Documentation/")) - - Of course if you installed the dependencies manually as well, then -you have to tell Emacs about them too, by prefixing the above with: - - (add-to-list 'load-path "~/.emacs.d/site-lisp/dash") - (add-to-list 'load-path "~/.emacs.d/site-lisp/transient/lisp") - (add-to-list 'load-path "~/.emacs.d/site-lisp/with-editor") - - Note that you have to add the ‘lisp’ subdirectory to the ‘load-path’, -not the top-level of the repository, and that elements of ‘load-path’ -should not end with a slash, while those of ‘Info-directory-list’ -should. - - Instead of requiring the feature ‘magit’, you could load just the -autoload definitions, by loading the file ‘magit-autoloads.el’. - - (load "/path/to/magit/lisp/magit-autoloads") - - Instead of running Magit directly from the repository by adding that -to the ‘load-path’, you might want to instead install it in some other -directory using ‘sudo make install’ and setting ‘load-path’ accordingly. - - To update Magit use: - - $ git pull - $ make - - At times it might be necessary to run ‘make clean all’ instead. - - To view all available targets use ‘make help’. - - Now see *note Post-Installation Tasks::. - - -File: magit.info, Node: Post-Installation Tasks, Prev: Installing from the Git Repository, Up: Installation - -2.3 Post-Installation Tasks -=========================== - -After installing Magit you should verify that you are indeed using the -Magit, Git, and Emacs releases you think you are using. It’s best to -restart Emacs before doing so, to make sure you are not using an -outdated value for ‘load-path’. - - M-x magit-version RET - - should display something like - - Magit 2.8.0, Git 2.10.2, Emacs 25.1.1, gnu/linux - - Then you might also want to read about options that many users likely -want to customize. See *note Essential Settings::. - - To be able to follow cross references to Git manpages found in this -manual, you might also have to manually install the ‘gitman’ info -manual, or advice ‘Info-follow-nearest-node’ to instead open the actual -manpage. See *note How to install the gitman info manual?::. - - If you are completely new to Magit then see *note Getting Started::. - - If you run into problems, then please see the *note FAQ::. Also see -the *note Debugging Tools::. - - And last but not least please consider making a donation, to ensure -that I can keep working on Magit. See <https://magit.vc/donations>. -for various donation options. - - -File: magit.info, Node: Getting Started, Next: Interface Concepts, Prev: Installation, Up: Top - -3 Getting Started -***************** - -This short tutorial describes the most essential features that many -Magitians use on a daily basis. It only scratches the surface but -should be enough to get you started. - - IMPORTANT: It is safest if you clone some repository just for this -tutorial. Alternatively you can use an existing local repository, but -if you do that, then you should commit all uncommitted changes before -proceeding. - - Type ‘C-x g’ to display information about the current Git repository -in a dedicated buffer, called the status buffer. - - Most Magit commands are commonly invoked from the status buffer. It -can be considered the primary interface for interacting with Git using -Magit. Many other Magit buffers may exist at a given time, but they are -often created from this buffer. - - Depending on what state your repository is in, this buffer may -contain sections titled "Staged changes", "Unstaged changes", "Unmerged -into origin/master", "Unpushed to origin/master", and many others. - - Since we are starting from a safe state, which you can easily return -to (by doing a ‘git reset --hard PRE-MAGIT-STATE’), there currently are -no staged or unstaged changes. Edit some files and save the changes. -Then go back to the status buffer, while at the same time refreshing it, -by typing ‘C-x g’. (When the status buffer, or any Magit buffer for -that matter, is the current buffer, then you can also use just ‘g’ to -refresh it). - - Move between sections using ‘p’ and ‘n’. Note that the bodies of -some sections are hidden. Type ‘TAB’ to expand or collapse the section -at point. You can also use ‘C-tab’ to cycle the visibility of the -current section and its children. Move to a file section inside the -section named "Unstaged changes" and type ‘s’ to stage the changes you -have made to that file. That file now appears under "Staged changes". - - Magit can stage and unstage individual hunks, not just complete -files. Move to the file you have just staged, expand it using ‘TAB’, -move to one of the hunks using ‘n’, and unstage just that by typing ‘u’. -Note how the staging (‘s’) and unstaging (‘u’) commands operate on the -change at point. Many other commands behave the same way. - - You can also un-/stage just part of a hunk. Inside the body of a -hunk section (move there using ‘C-n’), set the mark using ‘C-SPC’ and -move down until some added and/or removed lines fall inside the region -but not all of them. Again type ‘s’ to stage. - - It is also possible to un-/stage multiple files at once. Move to a -file section, type ‘C-SPC’, move to the next file using ‘n’, and then -‘s’ to stage both files. Note that both the mark and point have to be -on the headings of sibling sections for this to work. If the region -looks like it does in other buffers, then it doesn’t select Magit -sections that can be acted on as a unit. - - And then of course you want to commit your changes. Type ‘c’. This -shows the available commit commands and arguments in a buffer at the -bottom of the frame. Each command and argument is prefixed with the key -that invokes/sets it. Do not worry about this for now. We want to -create a "normal" commit, which is done by typing ‘c’ again. - - Now two new buffers appear. One is for writing the commit message, -the other shows a diff with the changes that you are about to commit. -Write a message and then type ‘C-c C-c’ to actually create the commit. - - You probably don’t want to push the commit you just created because -you just committed some random changes, but if that is not the case you -could push it by typing ‘P’ to show all the available push commands and -arguments and then ‘p’ to push to a branch with the same name as the -local branch onto the remote configured as the push-remote. (If the -push-remote is not configured yet, then you would first be prompted for -the remote to push to.) - - So far we have mentioned the commit and push menu commands. These -are probably among the menus you will be using the most, but many others -exist. To show a menu that lists all other menus (as well as the -various apply commands and some other essential commands), type ‘h’. -Try a few. (Such menus are also called "transient prefix commands" or -just "transients".) - - The key bindings in that menu correspond to the bindings in Magit -buffers, including but not limited to the status buffer. So you could -type ‘h d’ to bring up the diff menu, but once you remember that "d" -stands for "diff", you would usually do so by just typing ‘d’. - - This "prefix of prefixes" is useful even once you have memorized all -the bindings, as it can provide easy access to Magit commands from -non-Magit buffers. So, by default, it is globally bound to ‘C-x M-g’. - - A similar menu featuring (for the most part) commands that act on -just the file being visited in the current buffer, is globally bound to -‘C-c M-g’. That binding can also be used in buffers, which do not visit -a file, but then only a subset of the commands is available. - - The global key bindings mentioned in the previous two paragraphs are -quite inconvenient. We recommend using ‘C-c g’ and ‘C-c f’ instead, but -cannot use those key sequences by default because they are strictly -reserved for bindings added by the user. See *note Global Bindings::, -if you want to explicitly opt-in to the recommended key bindings. - - Magit also provides context menus and other mouse commands, see *note -Mouse Support::. - - It is not necessary that you do so now, but if you stick with Magit, -then it is highly recommended that you read the next section too. - - -File: magit.info, Node: Interface Concepts, Next: Inspecting, Prev: Getting Started, Up: Top - -4 Interface Concepts -******************** - -* Menu: - -* Modes and Buffers:: -* Sections:: -* Transient Commands:: -* Transient Arguments and Buffer Variables:: -* Completion, Confirmation and the Selection: Completion Confirmation and the Selection. -* Mouse Support:: -* Running Git:: - - -File: magit.info, Node: Modes and Buffers, Next: Sections, Up: Interface Concepts - -4.1 Modes and Buffers -===================== - -Magit provides several major-modes. For each of these modes there -usually exists only one buffer per repository. Separate modes and thus -buffers exist for commits, diffs, logs, and some other things. - - Besides these special purpose buffers, there also exists an overview -buffer, called the *status buffer*. It’s usually from this buffer that -the user invokes Git commands, or creates or visits other buffers. - - In this manual we often speak about "Magit buffers". By that we mean -buffers whose major-modes derive from ‘magit-mode’. - -‘M-x magit-toggle-buffer-lock’ - This command locks the current buffer to its value or if the buffer - is already locked, then it unlocks it. - - Locking a buffer to its value prevents it from being reused to - display another value. The name of a locked buffer contains its - value, which allows telling it apart from other locked buffers and - the unlocked buffer. - - Not all Magit buffers can be locked to their values; for example, - it wouldn’t make sense to lock a status buffer. - - There can only be a single unlocked buffer using a certain - major-mode per repository. So when a buffer is being unlocked and - another unlocked buffer already exists for that mode and - repository, then the former buffer is instead deleted and the - latter is displayed in its place. - -* Menu: - -* Switching Buffers:: -* Naming Buffers:: -* Quitting Windows:: -* Automatic Refreshing of Magit Buffers:: -* Automatic Saving of File-Visiting Buffers:: -* Automatic Reverting of File-Visiting Buffers:: - - -File: magit.info, Node: Switching Buffers, Next: Naming Buffers, Up: Modes and Buffers - -4.1.1 Switching Buffers ------------------------ - - -- Function: magit-display-buffer buffer &optional display-function - This function is a wrapper around ‘display-buffer’ and is used to - display any Magit buffer. It displays BUFFER in some window and, - unlike ‘display-buffer’, also selects that window, provided - ‘magit-display-buffer-noselect’ is ‘nil’. It also runs the hooks - mentioned below. - - If optional DISPLAY-FUNCTION is non-nil, then that is used to - display the buffer. Usually that is ‘nil’ and the function - specified by ‘magit-display-buffer-function’ is used. - - -- Variable: magit-display-buffer-noselect - When this is non-nil, then ‘magit-display-buffer’ only displays the - buffer but forgoes also selecting the window. This variable should - not be set globally, it is only intended to be let-bound, by code - that automatically updates "the other window". This is used for - example when the revision buffer is updated when you move inside - the log buffer. - - -- User Option: magit-display-buffer-function - The function specified here is called by ‘magit-display-buffer’ - with one argument, a buffer, to actually display that buffer. This - function should call ‘display-buffer’ with that buffer as first and - a list of display actions as second argument. - - Magit provides several functions, listed below, that are suitable - values for this option. If you want to use different rules, then a - good way of doing that is to start with a copy of one of these - functions and then adjust it to your needs. - - Instead of using a wrapper around ‘display-buffer’, that function - itself can be used here, in which case the display actions have to - be specified by adding them to ‘display-buffer-alist’ instead. - - To learn about display actions, see *note (elisp)Choosing Window::. - - -- Function: magit-display-buffer-traditional buffer - This function is the current default value of the option - ‘magit-display-buffer-function’. Before that option and this - function were added, the behavior was hard-coded in many places all - over the code base but now all the rules are contained in this one - function (except for the "noselect" special case mentioned above). - - -- Function: magit-display-buffer-same-window-except-diff-v1 - This function displays most buffers in the currently selected - window. If a buffer’s mode derives from ‘magit-diff-mode’ or - ‘magit-process-mode’, it is displayed in another window. - - -- Function: magit-display-buffer-fullframe-status-v1 - This function fills the entire frame when displaying a status - buffer. Otherwise, it behaves like - ‘magit-display-buffer-traditional’. - - -- Function: magit-display-buffer-fullframe-status-topleft-v1 - This function fills the entire frame when displaying a status - buffer. It behaves like ‘magit-display-buffer-fullframe-status-v1’ - except that it displays buffers that derive from ‘magit-diff-mode’ - or ‘magit-process-mode’ to the top or left of the current buffer - rather than to the bottom or right. As a result, Magit buffers - tend to pop up on the same side as they would if - ‘magit-display-buffer-traditional’ were in use. - - -- Function: magit-display-buffer-fullcolumn-most-v1 - This function displays most buffers so that they fill the entire - height of the frame. However, the buffer is displayed in another - window if (1) the buffer’s mode derives from ‘magit-process-mode’, - or (2) the buffer’s mode derives from ‘magit-diff-mode’, provided - that the mode of the current buffer derives from ‘magit-log-mode’ - or ‘magit-cherry-mode’. - - -- User Option: magit-pre-display-buffer-hook - This hook is run by ‘magit-display-buffer’ before displaying the - buffer. - - -- Function: magit-save-window-configuration - This function saves the current window configuration. Later when - the buffer is buried, it may be restored by - ‘magit-restore-window-configuration’. - - -- User Option: magit-post-display-buffer-hook - This hook is run by ‘magit-display-buffer’ after displaying the - buffer. - - -- Function: magit-maybe-set-dedicated - This function remembers if a new window had to be created to - display the buffer, or whether an existing window was reused. This - information is later used by ‘magit-mode-quit-window’, to determine - whether the window should be deleted when its last Magit buffer is - buried. - - -File: magit.info, Node: Naming Buffers, Next: Quitting Windows, Prev: Switching Buffers, Up: Modes and Buffers - -4.1.2 Naming Buffers --------------------- - - -- User Option: magit-generate-buffer-name-function - The function used to generate the names of Magit buffers. - - Such a function should take the options - ‘magit-uniquify-buffer-names’ as well as ‘magit-buffer-name-format’ - into account. If it doesn’t, then should be clearly stated in the - doc-string. And if it supports %-sequences beyond those mentioned - in the doc-string of the option ‘magit-buffer-name-format’, then - its own doc-string should describe the additions. - - -- Function: magit-generate-buffer-name-default-function mode - This function returns a buffer name suitable for a buffer whose - major-mode is MODE and which shows information about the repository - in which ‘default-directory’ is located. - - This function uses ‘magit-buffer-name-format’ and supporting all of - the %-sequences mentioned the documentation of that option. It - also respects the option ‘magit-uniquify-buffer-names’. - - -- User Option: magit-buffer-name-format - The format string used to name Magit buffers. - - At least the following %-sequences are supported: - - • ‘%m’ - - The name of the major-mode, but with the ‘-mode’ suffix - removed. - - • ‘%M’ - - Like ‘%m’ but abbreviate ‘magit-status-mode’ as ‘magit’. - - • ‘%v’ - - The value the buffer is locked to, in parentheses, or an empty - string if the buffer is not locked to a value. - - • ‘%V’ - - Like ‘%v’, but the string is prefixed with a space, unless it - is an empty string. - - • ‘%t’ - - The top-level directory of the working tree of the repository, - or if ‘magit-uniquify-buffer-names’ is non-nil an abbreviation - of that. - - • ‘%x’ - - If ‘magit-uniquify-buffer-names’ is nil "*", otherwise the - empty string. Due to limitations of the ‘uniquify’ package, - buffer names must end with the path. - - The value should always contain ‘%m’ or ‘%M’, ‘%v’ or ‘%V’, and - ‘%t’. If ‘magit-uniquify-buffer-names’ is non-nil, then the value - must end with ‘%t’ or ‘%t%x’. See issue #2841. - - -- User Option: magit-uniquify-buffer-names - This option controls whether the names of Magit buffers are - uniquified. If the names are not being uniquified, then they - contain the full path of the top-level of the working tree of the - corresponding repository. If they are being uniquified, then they - end with the basename of the top-level, or if that would conflict - with the name used for other buffers, then the names of all these - buffers are adjusted until they no longer conflict. - - This is done using the ‘uniquify’ package; customize its options to - control how buffer names are uniquified. - - -File: magit.info, Node: Quitting Windows, Next: Automatic Refreshing of Magit Buffers, Prev: Naming Buffers, Up: Modes and Buffers - -4.1.3 Quitting Windows ----------------------- - -‘q’ (‘magit-mode-bury-buffer’) - This command buries or kills the current Magit buffer. The - function specified by option ‘magit-bury-buffer-function’ is used - to bury the buffer when called without a prefix argument or to kill - it when called with a single prefix argument. - - When called with two or more prefix arguments then it always kills - all Magit buffers, associated with the current project, including - the current buffer. - - -- User Option: magit-bury-buffer-function - The function used to actually bury or kill the current buffer. - - ‘magit-mode-bury-buffer’ calls this function with one argument. If - the argument is non-nil, then the function has to kill the current - buffer. Otherwise it has to bury it alive. The default value - currently is ‘magit-mode-quit-window’. - - -- Function: magit-restore-window-configuration kill-buffer - Bury or kill the current buffer using ‘quit-window’, which is - called with KILL-BUFFER as first and the selected window as second - argument. - - Then restore the window configuration that existed right before the - current buffer was displayed in the selected frame. Unfortunately - that also means that point gets adjusted in all the buffers, which - are being displayed in the selected frame. - - -- Function: magit-mode-quit-window kill-buffer - Bury or kill the current buffer using ‘quit-window’, which is - called with KILL-BUFFER as first and the selected window as second - argument. - - Then, if the window was originally created to display a Magit - buffer and the buried buffer was the last remaining Magit buffer - that was ever displayed in the window, then that is deleted. - - -File: magit.info, Node: Automatic Refreshing of Magit Buffers, Next: Automatic Saving of File-Visiting Buffers, Prev: Quitting Windows, Up: Modes and Buffers - -4.1.4 Automatic Refreshing of Magit Buffers -------------------------------------------- - -After running a command which may change the state of the current -repository, the current Magit buffer and the corresponding status buffer -are refreshed. The status buffer can be automatically refreshed -whenever a buffer is saved to a file inside the respective repository by -adding a hook, like so: - - (with-eval-after-load 'magit-mode - (add-hook 'after-save-hook 'magit-after-save-refresh-status t)) - - Automatically refreshing Magit buffers ensures that the displayed -information is up-to-date most of the time but can lead to a noticeable -delay in big repositories. Other Magit buffers are not refreshed to -keep the delay to a minimum and also because doing so can sometimes be -undesirable. - - Buffers can also be refreshed explicitly, which is useful in buffers -that weren’t current during the last refresh and after changes were made -to the repository outside of Magit. - -‘g’ (‘magit-refresh’) - This command refreshes the current buffer if its major mode derives - from ‘magit-mode’ as well as the corresponding status buffer. - - If the option ‘magit-revert-buffers’ calls for it, then it also - reverts all unmodified buffers that visit files being tracked in - the current repository. - -‘G’ (‘magit-refresh-all’) - This command refreshes all Magit buffers belonging to the current - repository and also reverts all unmodified buffers that visit files - being tracked in the current repository. - - The file-visiting buffers are always reverted, even if - ‘magit-revert-buffers’ is nil. - - -- User Option: magit-refresh-buffer-hook - This hook is run in each Magit buffer that was refreshed during the - current refresh - normally the current buffer and the status - buffer. - - -- User Option: magit-refresh-status-buffer - When this option is non-nil, then the status buffer is - automatically refreshed after running git for side-effects, in - addition to the current Magit buffer, which is always refreshed - automatically. - - Only set this to nil after exhausting all other options to improve - performance. - - -- Function: magit-after-save-refresh-status - This function is intended to be added to ‘after-save-hook’. After - doing that the corresponding status buffer is refreshed whenever a - buffer is saved to a file inside a repository. - - Note that refreshing a Magit buffer is done by re-creating its - contents from scratch, which can be slow in large repositories. If - you are not satisfied with Magit’s performance, then you should - obviously not add this function to that hook. - - -File: magit.info, Node: Automatic Saving of File-Visiting Buffers, Next: Automatic Reverting of File-Visiting Buffers, Prev: Automatic Refreshing of Magit Buffers, Up: Modes and Buffers - -4.1.5 Automatic Saving of File-Visiting Buffers ------------------------------------------------ - -File-visiting buffers are by default saved at certain points in time. -This doesn’t guarantee that Magit buffers are always up-to-date, but, -provided one only edits files by editing them in Emacs and uses only -Magit to interact with Git, one can be fairly confident. When in doubt -or after outside changes, type ‘g’ (‘magit-refresh’) to save and refresh -explicitly. - - -- User Option: magit-save-repository-buffers - This option controls whether file-visiting buffers are saved before - certain events. - - If this is non-nil then all modified file-visiting buffers - belonging to the current repository may be saved before running - commands, before creating new Magit buffers, and before explicitly - refreshing such buffers. If this is ‘dontask’ then this is done - without user intervention. If it is ‘t’ then the user has to - confirm each save. - - -File: magit.info, Node: Automatic Reverting of File-Visiting Buffers, Prev: Automatic Saving of File-Visiting Buffers, Up: Modes and Buffers - -4.1.6 Automatic Reverting of File-Visiting Buffers --------------------------------------------------- - -By default Magit automatically reverts buffers that are visiting files -that are being tracked in a Git repository, after they have changed on -disk. When using Magit one often changes files on disk by running Git, -i.e., "outside Emacs", making this a rather important feature. - - For example, if you discard a change in the status buffer, then that -is done by running ‘git apply --reverse ...’, and Emacs considers the -file to have "changed on disk". If Magit did not automatically revert -the buffer, then you would have to type ‘M-x revert-buffer RET RET’ in -the visiting buffer before you could continue making changes. - - -- User Option: magit-auto-revert-mode - When this mode is enabled, then buffers that visit tracked files - are automatically reverted after the visited files change on disk. - - -- User Option: global-auto-revert-mode - When this mode is enabled, then any file-visiting buffer is - automatically reverted after the visited file changes on disk. - - If you like buffers that visit tracked files to be automatically - reverted, then you might also like any buffer to be reverted, not - just those visiting tracked files. If that is the case, then - enable this mode _instead of_ ‘magit-auto-revert-mode’. - - -- User Option: magit-auto-revert-immediately - This option controls whether Magit reverts buffers immediately. - - If this is non-nil and either ‘global-auto-revert-mode’ or - ‘magit-auto-revert-mode’ is enabled, then Magit immediately reverts - buffers by explicitly calling ‘auto-revert-buffers’ after running - Git for side-effects. - - If ‘auto-revert-use-notify’ is non-nil (and file notifications are - actually supported), then ‘magit-auto-revert-immediately’ does not - have to be non-nil, because the reverts happen immediately anyway. - - If ‘magit-auto-revert-immediately’ and ‘auto-revert-use-notify’ are - both ‘nil’, then reverts happen after ‘auto-revert-interval’ - seconds of user inactivity. That is not desirable. - - -- User Option: auto-revert-use-notify - This option controls whether file notification functions should be - used. Note that this variable unfortunately defaults to ‘t’ even - on systems on which file notifications cannot be used. - - -- User Option: magit-auto-revert-tracked-only - This option controls whether ‘magit-auto-revert-mode’ only reverts - tracked files or all files that are located inside Git - repositories, including untracked files and files located inside - Git’s control directory. - - -- User Option: auto-revert-mode - The global mode ‘magit-auto-revert-mode’ works by turning on this - local mode in the appropriate buffers (but - ‘global-auto-revert-mode’ is implemented differently). You can - also turn it on or off manually, which might be necessary if Magit - does not notice that a previously untracked file now is being - tracked or vice-versa. - - -- User Option: auto-revert-stop-on-user-input - This option controls whether the arrival of user input suspends the - automatic reverts for ‘auto-revert-interval’ seconds. - - -- User Option: auto-revert-interval - This option controls how many seconds Emacs waits for before - resuming suspended reverts. - - -- User Option: auto-revert-buffer-list-filter - This option specifies an additional filter used by - ‘auto-revert-buffers’ to determine whether a buffer should be - reverted or not. - - This option is provided by Magit, which also advises - ‘auto-revert-buffers’ to respect it. Magit users who do not turn - on the local mode ‘auto-revert-mode’ themselves, are best served by - setting the value to ‘magit-auto-revert-repository-buffer-p’. - - However the default is nil, so as not to disturb users who do use - the local mode directly. If you experience delays when running - Magit commands, then you should consider using one of the - predicates provided by Magit - especially if you also use Tramp. - - Users who do turn on ‘auto-revert-mode’ in buffers in which Magit - doesn’t do that for them, should likely not use any filter. Users - who turn on ‘global-auto-revert-mode’, do not have to worry about - this option, because it is disregarded if the global mode is - enabled. - - -- User Option: auto-revert-verbose - This option controls whether Emacs reports when a buffer has been - reverted. - - The options with the ‘auto-revert-’ prefix are located in the Custom -group named ‘auto-revert’. The other, Magit-specific, options are -located in the ‘magit’ group. - -* Menu: - -* Risk of Reverting Automatically:: - - -File: magit.info, Node: Risk of Reverting Automatically, Up: Automatic Reverting of File-Visiting Buffers - -Risk of Reverting Automatically -............................... - -For the vast majority of users, automatically reverting file-visiting -buffers after they have changed on disk is harmless. - - If a buffer is modified (i.e., it contains changes that haven’t been -saved yet), then Emacs will refuse to automatically revert it. If you -save a previously modified buffer, then that results in what is seen by -Git as an uncommitted change. Git will then refuse to carry out any -commands that would cause these changes to be lost. In other words, if -there is anything that could be lost, then either Git or Emacs will -refuse to discard the changes. - - However, if you use file-visiting buffers as a sort of ad hoc -"staging area", then the automatic reverts could potentially cause data -loss. So far I have heard from only one user who uses such a workflow. - - An example: You visit some file in a buffer, edit it, and save the -changes. Then, outside of Emacs (or at least not using Magit or by -saving the buffer) you change the file on disk again. At this point the -buffer is the only place where the intermediate version still exists. -You have saved the changes to disk, but that has since been overwritten. -Meanwhile Emacs considers the buffer to be unmodified (because you have -not made any changes to it since you last saved it to the visited file) -and therefore would not object to it being automatically reverted. At -this point an Auto-Revert mode would kick in. It would check whether -the buffer is modified and since that is not the case it would revert -it. The intermediate version would be lost. (Actually you could still -get it back using the ‘undo’ command.) - - If your workflow depends on Emacs preserving the intermediate version -in the buffer, then you have to disable all Auto-Revert modes. But -please consider that such a workflow would be dangerous even without -using an Auto-Revert mode, and should therefore be avoided. If Emacs -crashes or if you quit Emacs by mistake, then you would also lose the -buffer content. There would be no autosave file still containing the -intermediate version (because that was deleted when you saved the -buffer) and you would not be asked whether you want to save the buffer -(because it isn’t modified). - - -File: magit.info, Node: Sections, Next: Transient Commands, Prev: Modes and Buffers, Up: Interface Concepts - -4.2 Sections -============ - -Magit buffers are organized into nested sections, which can be collapsed -and expanded, similar to how sections are handled in Org mode. Each -section also has a type, and some sections also have a value. For each -section type there can also be a local keymap, shared by all sections of -that type. - - Taking advantage of the section value and type, many commands operate -on the current section, or when the region is active and selects -sections of the same type, all of the selected sections. Commands that -only make sense for a particular section type (as opposed to just -behaving differently depending on the type) are usually bound in section -type keymaps. - -* Menu: - -* Section Movement:: -* Section Visibility:: -* Section Hooks:: -* Section Types and Values:: -* Section Options:: - - -File: magit.info, Node: Section Movement, Next: Section Visibility, Up: Sections - -4.2.1 Section Movement ----------------------- - -To move within a section use the usual keys (‘C-p’, ‘C-n’, ‘C-b’, ‘C-f’ -etc), whose global bindings are not shadowed. To move to another -section use the following commands. - -‘p’ (‘magit-section-backward’) - When not at the beginning of a section, then move to the beginning - of the current section. At the beginning of a section, instead - move to the beginning of the previous visible section. - -‘n’ (‘magit-section-forward’) - Move to the beginning of the next visible section. - -‘M-p’ (‘magit-section-backward-siblings’) - Move to the beginning of the previous sibling section. If there is - no previous sibling section, then move to the parent section - instead. - -‘M-n’ (‘magit-section-forward-siblings’) - Move to the beginning of the next sibling section. If there is no - next sibling section, then move to the parent section instead. - -‘^’ (‘magit-section-up’) - Move to the beginning of the parent of the current section. - - The above commands all call the hook ‘magit-section-movement-hook’. -Any of the functions listed below can be used as members of this hook. - - You might want to remove some of the functions that Magit adds using -‘add-hook’. In doing so you have to make sure you do not attempt to -remove function that haven’t even been added yet, for example: - - (with-eval-after-load 'magit-diff - (remove-hook 'magit-section-movement-hook - 'magit-hunk-set-window-start)) - - -- Variable: magit-section-movement-hook - This hook is run by all of the above movement commands, after - arriving at the destination. - - -- Function: magit-hunk-set-window-start - This hook function ensures that the beginning of the current - section is visible, provided it is a ‘hunk’ section. Otherwise, it - does nothing. - - Loading ‘magit-diff’ adds this function to the hook. - - -- Function: magit-section-set-window-start - This hook function ensures that the beginning of the current - section is visible, regardless of the section’s type. If you add - this to ‘magit-section-movement-hook’, then you must remove the - hunk-only variant in turn. - - -- Function: magit-log-maybe-show-more-commits - This hook function only has an effect in log buffers, and ‘point’ - is on the "show more" section. If that is the case, then it - doubles the number of commits that are being shown. - - Loading ‘magit-log’ adds this function to the hook. - - -- Function: magit-log-maybe-update-revision-buffer - When moving inside a log buffer, then this function updates the - revision buffer, provided it is already being displayed in another - window of the same frame. - - Loading ‘magit-log’ adds this function to the hook. - - -- Function: magit-log-maybe-update-blob-buffer - When moving inside a log buffer and another window of the same - frame displays a blob buffer, then this function instead displays - the blob buffer for the commit at point in that window. - - -- Function: magit-status-maybe-update-revision-buffer - When moving inside a status buffer, then this function updates the - revision buffer, provided it is already being displayed in another - window of the same frame. - - -- Function: magit-status-maybe-update-stash-buffer - When moving inside a status buffer, then this function updates the - stash buffer, provided it is already being displayed in another - window of the same frame. - - -- Function: magit-status-maybe-update-blob-buffer - When moving inside a status buffer and another window of the same - frame displays a blob buffer, then this function instead displays - the blob buffer for the commit at point in that window. - - -- Function: magit-stashes-maybe-update-stash-buffer - When moving inside a buffer listing stashes, then this function - updates the stash buffer, provided it is already being displayed in - another window of the same frame. - - -- User Option: magit-update-other-window-delay - Delay before automatically updating the other window. - - When moving around in certain buffers, then certain other buffers, - which are being displayed in another window, may optionally be - updated to display information about the section at point. - - When holding down a key to move by more than just one section, then - that would update that buffer for each section on the way. To - prevent that, updating the revision buffer is delayed, and this - option controls for how long. For optimal experience you might - have to adjust this delay and/or the keyboard repeat rate and delay - of your graphical environment or operating system. - - -File: magit.info, Node: Section Visibility, Next: Section Hooks, Prev: Section Movement, Up: Sections - -4.2.2 Section Visibility ------------------------- - -Magit provides many commands for changing the visibility of sections, -but all you need to get started are the next two. - -‘<TAB>’ (‘magit-section-toggle’) - Toggle the visibility of the body of the current section. - -‘C-c <TAB>’ (‘magit-section-cycle’) -‘C-<tab>’ (‘magit-section-cycle’) - Cycle the visibility of current section and its children. - - If this command is invoked using ‘C-<tab>’ and that is globally - bound to ‘tab-next’, then this command pivots to behave like that - command, and you must instead use ‘C-c TAB’ to cycle section - visibility. - - If you would like to keep using ‘C-<tab>’ to cycle section - visibility but also want to use ‘tab-bar-mode’, then you have to - prevent that mode from using this key and instead bind another key - to ‘tab-next’. Because ‘tab-bar-mode’ does not use a mode map but - instead manipulates the global map, this involves advising - ‘tab-bar--define-keys’. - -‘M-<tab>’ (‘magit-section-cycle-diffs’) - Cycle the visibility of diff-related sections in the current - buffer. - -‘S-<tab>’ (‘magit-section-cycle-global’) - Cycle the visibility of all sections in the current buffer. - -‘1’ (‘magit-section-show-level-1’) -‘2’ (‘magit-section-show-level-2’) -‘3’ (‘magit-section-show-level-3’) -‘4’ (‘magit-section-show-level-4’) - Show sections surrounding the current section up to level N. - -‘M-1’ (‘magit-section-show-level-1-all’) -‘M-2’ (‘magit-section-show-level-2-all’) -‘M-3’ (‘magit-section-show-level-3-all’) -‘M-4’ (‘magit-section-show-level-4-all’) - Show all sections up to level N. - - Some functions, which are used to implement the above commands, are -also exposed as commands themselves. By default no keys are bound to -these commands, as they are generally perceived to be much less useful. -But your mileage may vary. - - -- Command: magit-section-show - Show the body of the current section. - - -- Command: magit-section-hide - Hide the body of the current section. - - -- Command: magit-section-show-headings - Recursively show headings of children of the current section. Only - show the headings. Previously shown text-only bodies are hidden. - - -- Command: magit-section-show-children - Recursively show the bodies of children of the current section. - With a prefix argument show children down to the level of the - current section, and hide deeper children. - - -- Command: magit-section-hide-children - Recursively hide the bodies of children of the current section. - - -- Command: magit-section-toggle-children - Toggle visibility of bodies of children of the current section. - - When a buffer is first created then some sections are shown expanded -while others are not. This is hard coded. When a buffer is refreshed -then the previous visibility is preserved. The initial visibility of -certain sections can also be overwritten using the hook -‘magit-section-set-visibility-hook’. - - -- User Option: magit-section-initial-visibility-alist - This options can be used to override the initial visibility of - sections. In the future it will also be used to define the - defaults, but currently a section’s default is still hardcoded. - - The value is an alist. Each element maps a section type or lineage - to the initial visibility state for such sections. The state has - to be one of ‘show’ or ‘hide’, or a function that returns one of - these symbols. A function is called with the section as the only - argument. - - Use the command ‘magit-describe-section-briefly’ to determine a - section’s lineage or type. The vector in the output is the section - lineage and the type is the first element of that vector. - Wildcards can be used, see ‘magit-section-match’. - - -- User Option: magit-section-cache-visibility - This option controls for which sections the previous visibility - state should be restored if a section disappears and later appears - again. The value is a boolean or a list of section types. If t, - then the visibility of all sections is cached. Otherwise this is - only done for sections whose type matches one of the listed types. - - This requires that the function ‘magit-section-cached-visibility’ - is a member of ‘magit-section-set-visibility-hook’. - - -- Variable: magit-section-set-visibility-hook - This hook is run when first creating a buffer and also when - refreshing an existing buffer, and is used to determine the - visibility of the section currently being inserted. - - Each function is called with one argument, the section being - inserted. It should return ‘hide’ or ‘show’, or to leave the - visibility undefined ‘nil’. If no function decides on the - visibility and the buffer is being refreshed, then the visibility - is preserved; or if the buffer is being created, then the hard - coded default is used. - - Usually this should only be used to set the initial visibility but - not during refreshes. If ‘magit-insert-section--oldroot’ is - non-nil, then the buffer is being refreshed and these functions - should immediately return ‘nil’. - - -- User Option: magit-section-visibility-indicator - This option controls whether and how to indicate that a section can - be expanded/collapsed. - - If nil, then no visibility indicators are shown. Otherwise the - value has to have one of these two forms: - - • ‘(EXPANDABLE-BITMAP . COLLAPSIBLE-BITMAP)’ - - Both values have to be variables whose values are fringe - bitmaps. In this case every section that can be expanded or - collapsed gets an indicator in the left fringe. - - To provide extra padding around the indicator, set - ‘left-fringe-width’ in ‘magit-mode-hook’, e.g.: - - (add-hook 'magit-mode-hook (lambda () - (setq left-fringe-width 20))) - - • ‘(STRING . BOOLEAN)’ - - In this case STRING (usually an ellipsis) is shown at the end - of the heading of every collapsed section. Expanded sections - get no indicator. The cdr controls whether the appearance of - these ellipsis take section highlighting into account. Doing - so might potentially have an impact on performance, while not - doing so is kinda ugly. - - -File: magit.info, Node: Section Hooks, Next: Section Types and Values, Prev: Section Visibility, Up: Sections - -4.2.3 Section Hooks -------------------- - -Which sections are inserted into certain buffers is controlled with -hooks. This includes the status and the refs buffers. For other -buffers, e.g., log and diff buffers, this is not possible. The command -‘magit-describe-section’ can be used to see which hook (if any) was -responsible for inserting the section at point. - - For buffers whose sections can be customized by the user, a hook -variable called ‘magit-TYPE-sections-hook’ exists. This hook should be -changed using ‘magit-add-section-hook’. Avoid using ‘add-hooks’ or the -Custom interface. - - The various available section hook variables are described later in -this manual along with the appropriate "section inserter functions". - - -- Function: magit-add-section-hook hook function &optional at append - local - Add the function FUNCTION to the value of section hook HOOK. - - Add FUNCTION at the beginning of the hook list unless optional - APPEND is non-nil, in which case FUNCTION is added at the end. If - FUNCTION already is a member then move it to the new location. - - If optional AT is non-nil and a member of the hook list, then add - FUNCTION next to that instead. Add before or after AT, or replace - AT with FUNCTION depending on APPEND. If APPEND is the symbol - ‘replace’, then replace AT with FUNCTION. For any other non-nil - value place FUNCTION right after AT. If nil, then place FUNCTION - right before AT. If FUNCTION already is a member of the list but - AT is not, then leave FUNCTION where ever it already is. - - If optional LOCAL is non-nil, then modify the hook’s buffer-local - value rather than its global value. This makes the hook local by - copying the default value. That copy is then modified. - - HOOK should be a symbol. If HOOK is void, it is first set to nil. - HOOK’s value must not be a single hook function. FUNCTION should - be a function that takes no arguments and inserts one or multiple - sections at point, moving point forward. FUNCTION may choose not - to insert its section(s), when doing so would not make sense. It - should not be abused for other side-effects. - - To remove a function from a section hook, use ‘remove-hook’. - - -File: magit.info, Node: Section Types and Values, Next: Section Options, Prev: Section Hooks, Up: Sections - -4.2.4 Section Types and Values ------------------------------- - -Each section has a type, for example ‘hunk’, ‘file’, and ‘commit’. -Instances of certain section types also have a value. The value of a -section of type ‘file’, for example, is a file name. - - Users usually do not have to worry about a section’s type and value, -but knowing them can be handy at times. - -‘H’ (‘magit-describe-section’) - This command shows information about the section at point in a - separate buffer. - - -- Command: magit-describe-section-briefly - This command shows information about the section at point in the - echo area, as ‘#<magit-section VALUE [TYPE PARENT-TYPE...] - BEGINNING-END>’. - - Many commands behave differently depending on the type of the section -at point and/or somehow consume the value of that section. But that is -only one of the reasons why the same key may do something different, -depending on what section is current. - - Additionally for each section type a keymap *might* be defined, named -‘magit-TYPE-section-map’. That keymap is used as text property keymap -of all text belonging to any section of the respective type. If such a -map does not exist for a certain type, then you can define it yourself, -and it will automatically be used. - - -File: magit.info, Node: Section Options, Prev: Section Types and Values, Up: Sections - -4.2.5 Section Options ---------------------- - -This section describes options that have an effect on more than just a -certain type of sections. As you can see there are not many of those. - - -- User Option: magit-section-show-child-count - Whether to append the number of children to section headings. This - only affects sections that could benefit from this information. - - -File: magit.info, Node: Transient Commands, Next: Transient Arguments and Buffer Variables, Prev: Sections, Up: Interface Concepts - -4.3 Transient Commands -====================== - -Many Magit commands are implemented as *transient* commands. First the -user invokes a *prefix* command, which causes its *infix* arguments and -*suffix* commands to be displayed in the echo area. The user then -optionally sets some infix arguments and finally invokes one of the -suffix commands. - - This is implemented in the library ‘transient’. Earlier Magit -releases used the package ‘magit-popup’ and even earlier versions -library ‘magit-key-mode’. - - Transient is documented in *note (transient)Top::. - -‘C-x M-g’ (‘magit-dispatch’) -‘C-c g’ (‘magit-dispatch’) - This transient prefix command binds most of Magit’s other prefix - commands as suffix commands and displays them in a temporary buffer - until one of them is invoked. Invoking such a sub-prefix causes - the suffixes of that command to be bound and displayed instead of - those of ‘magit-dispatch’. - - This command is also, or especially, useful outside Magit buffers, - so Magit by default binds it to ‘C-c M-g’ in the global keymap. - ‘C-c g’ would be a better binding, but we cannot use that by - default, because that key sequence is reserved for the user. See - *note Global Bindings:: to learn more default and recommended key - bindings. - - -File: magit.info, Node: Transient Arguments and Buffer Variables, Next: Completion Confirmation and the Selection, Prev: Transient Commands, Up: Interface Concepts - -4.4 Transient Arguments and Buffer Variables -============================================ - -The infix arguments of many of Magit’s transient prefix commands cease -to have an effect once the ‘git’ command that is called with those -arguments has returned. Commands that create a commit are a good -example for this. If the user changes the arguments, then that only -affects the next invocation of a suffix command. If the same transient -prefix command is later invoked again, then the arguments are initially -reset to the default value. This default value can be set for the -current Emacs session or saved permanently, see *note (transient)Saving -Values::. It is also possible to cycle through previously used sets of -arguments using ‘C-M-p’ and ‘C-M-n’, see *note (transient)Using -History::. - - However the infix arguments of many other transient commands continue -to have an effect even after the ‘git’ command that was called with -those arguments has returned. The most important commands like this are -those that display a diff or log in a dedicated buffer. Their arguments -obviously continue to have an effect for as long as the respective diff -or log is being displayed. Furthermore the used arguments are stored in -buffer-local variables for future reference. - - For commands in the second group it isn’t always desirable to reset -their arguments to the global value when the transient prefix command is -invoked again. - - As mentioned above, it is possible to cycle through previously used -sets of arguments while a transient popup is visible. That means that -we could always reset the infix arguments to the default because the set -of arguments that is active in the existing buffer is only a few ‘C-M-p’ -away. Magit can be configured to behave like that, but because I expect -that most users would not find that very convenient, it is not the -default. - - Also note that it is possible to change the diff and log arguments -used in the current buffer (including the status buffer, which contains -both diff and log sections) using the respective "refresh" transient -prefix commands on ‘D’ and ‘L’. (‘d’ and ‘l’ on the other hand are -intended to change *what* diff or log is being displayed. It is -possible to also change *how* the diff or log is being displayed at the -same time, but if you only want to do the latter, then you should use -the refresh variants.) Because these secondary diff and log transient -prefixes are about *changing* the arguments used in the current buffer, -they *always* start out with the set of arguments that are currently in -effect in that buffer. - - Some commands are usually invoked directly even though they can also -be invoked as the suffix of a transient prefix command. Most -prominently ‘magit-show-commit’ is usually invoked by typing ‘RET’ while -point is on a commit in a log, but it can also be invoked from the -‘magit-diff’ transient prefix. - - When such a command is invoked directly, then it is important to -reuse the arguments as specified by the respective buffer-local values, -instead of using the default arguments. Imagine you press ‘RET’ in a -log to display the commit at point in a different buffer and then use -‘D’ to change how the diff is displayed in that buffer. And then you -press ‘RET’ on another commit to show that instead and the diff -arguments are reset to the default. Not cool; so Magit does not do that -by default. - - -- User Option: magit-prefix-use-buffer-arguments - This option controls whether the infix arguments initially shown in - certain transient prefix commands are based on the arguments that - are currently in effect in the buffer that their suffixes update. - - The ‘magit-diff’ and ‘magit-log’ transient prefix commands are - affected by this option. - - -- User Option: magit-direct-use-buffer-arguments - This option controls whether certain commands, when invoked - directly (i.e., not as the suffix of a transient prefix command), - use the arguments that are currently active in the buffer that they - are about to update. The alternative is to use the default value - for these arguments, which might change the arguments that are used - in the buffer. - -Valid values for both of the above options are: - - • ‘always’: Always use the set of arguments that is currently active - in the respective buffer, provided that buffer exists of course. - • ‘selected’ or ‘t’: Use the set of arguments from the respective - buffer, but only if it is displayed in a window of the current - frame. This is the default for both variables. - • ‘current’: Use the set of arguments from the respective buffer, but - only if it is the current buffer. - • ‘never’: Never use the set of arguments from the respective buffer. - -I am afraid it gets more complicated still: - - • The global diff and log arguments are set for each supported mode - individually. The diff arguments for example have different values - in ‘magit-diff-mode’, ‘magit-revision-mode’, - ‘magit-merge-preview-mode’ and ‘magit-status-mode’ buffers. - Setting or saving the value for one mode does not change the value - for other modes. The history however is shared. - - • When ‘magit-show-commit’ is invoked directly from a log buffer, - then the file filter is picked up from that buffer, not from the - revision buffer or the mode’s global diff arguments. - - • Even though they are suffixes of the diff prefix - ‘magit-show-commit’ and ‘magit-stash-show’ do not use the diff - buffer used by the diff commands, instead they use the dedicated - revision and stash buffers. - - At the time you invoke the diff prefix it is unknown to Magit which - of the suffix commands you are going to invoke. While not certain, - more often than not users invoke one of the commands that use the - diff buffer, so the initial infix arguments are those used in that - buffer. However if you invoke one of these commands directly, then - Magit knows that it should use the arguments from the revision - resp. stash buffer. - - • The log prefix also features reflog commands, but these commands do - not use the log arguments. - - • If ‘magit-show-refs’ is invoked from a ‘magit-refs-mode’ buffer, - then it acts as a refresh prefix and therefore unconditionally uses - the buffer’s arguments as initial arguments. If it is invoked - elsewhere with a prefix argument, then it acts as regular prefix - and therefore respects ‘magit-prefix-use-buffer-arguments’. If it - is invoked elsewhere without a prefix argument, then it acts as a - direct command and therefore respects - ‘magit-direct-use-buffer-arguments’. - - -File: magit.info, Node: Completion Confirmation and the Selection, Next: Mouse Support, Prev: Transient Arguments and Buffer Variables, Up: Interface Concepts - -4.5 Completion, Confirmation and the Selection -============================================== - -* Menu: - -* Action Confirmation:: -* Completion and Confirmation:: -* The Selection:: -* The hunk-internal region:: -* Support for Completion Frameworks:: -* Additional Completion Options:: - - -File: magit.info, Node: Action Confirmation, Next: Completion and Confirmation, Up: Completion Confirmation and the Selection - -4.5.1 Action Confirmation -------------------------- - -By default many actions that could potentially lead to data loss have to -be confirmed. This includes many very common actions, so this can -quickly become annoying. Many of these actions can be undone and if you -have thought about how to undo certain mistakes, then it should be safe -to disable confirmation for the respective actions. - - The option ‘magit-no-confirm’ can be used to tell Magit to perform -certain actions without the user having to confirm them. Note that -while this option can only be used to disable confirmation for a -specific set of actions, the next section explains another way of -telling Magit to ask fewer questions. - - -- User Option: magit-no-confirm - The value of this option is a list of symbols, representing actions - that do not have to be confirmed by the user before being carried - out. - - By default many potentially dangerous commands ask the user for - confirmation. Each of the below symbols stands for an action - which, when invoked unintentionally or without being fully aware of - the consequences, could lead to tears. In many cases there are - several commands that perform variations of a certain action, so we - don’t use the command names but more generic symbols. - - • Applying changes: - - • ‘discard’ Discarding one or more changes (i.e., hunks or - the complete diff for a file) loses that change, - obviously. - - • ‘reverse’ Reverting one or more changes can usually be - undone by reverting the reversion. - - • ‘stage-all-changes’, ‘unstage-all-changes’ When there are - both staged and unstaged changes, then un-/staging - everything would destroy that distinction. Of course - that also applies when un-/staging a single change, but - then less is lost and one does that so often that having - to confirm every time would be unacceptable. - - • Files: - - • ‘delete’ When a file that isn’t yet tracked by Git is - deleted, then it is completely lost, not just the last - changes. Very dangerous. - - • ‘trash’ Instead of deleting a file it can also be move to - the system trash. Obviously much less dangerous than - deleting it. - - Also see option ‘magit-delete-by-moving-to-trash’. - - • ‘resurrect’ A deleted file can easily be resurrected by - "deleting" the deletion, which is done using the same - command that was used to delete the same file in the - first place. - - • ‘untrack’ Untracking a file can be undone by tracking it - again. - - • ‘rename’ Renaming a file can easily be undone. - - • Sequences: - - • ‘reset-bisect’ Aborting (known to Git as "resetting") a - bisect operation loses all information collected so far. - - • ‘abort-cherry-pick’ Aborting a cherry-pick throws away - all conflict resolutions which have already been carried - out by the user. - - • ‘abort-revert’ Aborting a revert throws away all conflict - resolutions which have already been carried out by the - user. - - • ‘abort-rebase’ Aborting a rebase throws away all already - modified commits, but it’s possible to restore those from - the reflog. - - • ‘abort-merge’ Aborting a merge throws away all conflict - resolutions which have already been carried out by the - user. - - • ‘merge-dirty’ Merging with a dirty worktree can make it - hard to go back to the state before the merge was - initiated. - - • References: - - • ‘delete-unmerged-branch’ Once a branch has been deleted, - it can only be restored using low-level recovery tools - provided by Git. And even then the reflog is gone. The - user always has to confirm the deletion of a branch by - accepting the default choice (or selecting another - branch), but when a branch has not been merged yet, also - make sure the user is aware of that. - - • ‘delete-pr-remote’ When deleting a branch that was - created from a pull-request and if no other branches - still exist on that remote, then ‘magit-branch-delete’ - offers to delete the remote as well. This should be safe - because it only happens if no other refs exist in the - remotes namespace, and you can recreate the remote if - necessary. - - • ‘drop-stashes’ Dropping a stash is dangerous because Git - stores stashes in the reflog. Once a stash is removed, - there is no going back without using low-level recovery - tools provided by Git. When a single stash is dropped, - then the user always has to confirm by accepting the - default (or selecting another). This action only - concerns the deletion of multiple stashes at once. - - • Publishing: - - • ‘set-and-push’ When pushing to the upstream or the - push-remote and that isn’t actually configured yet, then - the user can first set the target. If s/he confirms the - default too quickly, then s/he might end up pushing to - the wrong branch and if the remote repository is - configured to disallow fixing such mistakes, then that - can be quite embarrassing and annoying. - - • Edit published history: - - Without adding these symbols here, you will be warned before - editing commits that have already been pushed to one of the - branches listed in ‘magit-published-branches’. - - • ‘amend-published’ Affects most commands that amend to - "HEAD". - - • ‘rebase-published’ Affects commands that perform - interactive rebases. This includes commands from the - commit transient that modify a commit other than "HEAD", - namely the various fixup and squash variants. - - • ‘edit-published’ Affects the commands - ‘magit-edit-line-commit’ and - ‘magit-diff-edit-hunk-commit’. These two commands make - it quite easy to accidentally edit a published commit, so - you should think twice before configuring them not to ask - for confirmation. - - To disable confirmation completely, add all three symbols here - or set ‘magit-published-branches’ to ‘nil’. - - • Various: - - • ‘stash-apply-3way’ When a stash cannot be applied using - ‘git stash apply’, then Magit uses ‘git apply’ instead, - possibly using the ‘--3way’ argument, which isn’t always - perfectly safe. See also ‘magit-stash-apply’. - - • ‘kill-process’ There seldom is a reason to kill a - process. - - • Global settings: - - Instead of adding all of the above symbols to the value of - this option, you can also set it to the atom ‘t’, which has - the same effect as adding all of the above symbols. Doing - that most certainly is a bad idea, especially because other - symbols might be added in the future. So even if you don’t - want to be asked for confirmation for any of these actions, - you are still better of adding all of the respective symbols - individually. - - When ‘magit-wip-before-change-mode’ is enabled, then the - following actions can be undone fairly easily: ‘discard’, - ‘reverse’, ‘stage-all-changes’, and ‘unstage-all-changes’. If - and only if this mode is enabled, then ‘safe-with-wip’ has the - same effect as adding all of these symbols individually. - - -File: magit.info, Node: Completion and Confirmation, Next: The Selection, Prev: Action Confirmation, Up: Completion Confirmation and the Selection - -4.5.2 Completion and Confirmation ---------------------------------- - -Many Magit commands ask the user to select from a list of possible -things to act on, while offering the most likely choice as the default. -For many of these commands the default is the thing at point, provided -that it actually is a valid thing to act on. For many commands that act -on a branch, the current branch serves as the default if there is no -branch at point. - - These commands combine asking for confirmation and asking for a -target to act on into a single action. The user can confirm the default -target using ‘RET’ or abort using ‘C-g’. This is similar to a -‘y-or-n-p’ prompt, but the keys to confirm or abort differ. - - At the same time the user is also given the opportunity to select -another target, which is useful because for some commands and/or in some -situations you might want to select the action before selecting the -target by moving to it. - - However you might find that for some commands you always want to use -the default target, if any, or even that you want the command to act on -the default without requiring any confirmation at all. The option -‘magit-dwim-selection’ can be used to configure certain commands to that -effect. - - Note that when the region is active then many commands act on the -things that are selected using a mechanism based on the region, in many -cases after asking for confirmation. This region-based mechanism is -called the "selection" and is described in detail in the next section. -When a selection exists that is valid for the invoked command, then that -command never offers to act on something else, and whether it asks for -confirmation is not controlled by this option. - - Also note that Magit asks for confirmation of certain actions that -are not coupled with completion (or the selection). Such dialogs are -also not affected by this option and are described in the previous -section. - - -- User Option: magit-dwim-selection - This option can be used to tell certain commands to use the thing at -point instead of asking the user to select a candidate to act on, with -or without confirmation. - - The value has the form ‘((COMMAND nil|PROMPT DEFAULT)...)’. - - • COMMAND is the command that should not prompt for a choice. To - have an effect, the command has to use the function - ‘magit-completing-read’ or a utility function which in turn uses - that function. - - • If the command uses ‘magit-completing-read’ multiple times, then - PROMPT can be used to only affect one of these uses. PROMPT, if - non-nil, is a regular expression that is used to match against the - PROMPT argument passed to ‘magit-completing-read’. - - • DEFAULT specifies how to use the default. If it is ‘t’, then the - DEFAULT argument passed to ‘magit-completing-read’ is used without - confirmation. If it is ‘ask’, then the user is given a chance to - abort. DEFAULT can also be ‘nil’, in which case the entry has no - effect. - - -File: magit.info, Node: The Selection, Next: The hunk-internal region, Prev: Completion and Confirmation, Up: Completion Confirmation and the Selection - -4.5.3 The Selection -------------------- - -If the region is active, then many Magit commands act on the things that -are selected using a mechanism based on the region instead of one single -thing. When the region is not active, then these commands act on the -thing at point or read a single thing to act on. This is described in -the previous section — this section only covers how multiple things are -selected, how that is visualized, and how certain commands behave when -that is the case. - - Magit’s mechanism for selecting multiple things, or rather sections -that represent these things, is based on the Emacs region, but the area -that Magit considers to be selected is typically larger than the region -and additional restrictions apply. - - Magit makes a distinction between a region that qualifies as forming -a valid Magit selection and a region that does not. If the region does -not qualify, then it is displayed as it is in other Emacs buffers. If -the region does qualify as a Magit selection, then the selection is -always visualized, while the region itself is only visualized if it -begins and ends on the same line. - - For a region to qualify as a Magit selection, it must begin in the -heading of one section and end in the heading of a sibling section. -Note that if the end of the region is at the very beginning of section -heading (i.e., at the very beginning of a line) then that section is -considered to be *inside* the selection. - - This is not consistent with how the region is normally treated in -Emacs — if the region ends at the beginning of a line, then that line is -outside the region. Due to how Magit visualizes the selection, it -should be obvious that this difference exists. - - Not every command acts on every valid selection. Some commands do -not even consider the location of point, others may act on the section -at point but not support acting on the selection, and even commands that -do support the selection of course only do so if it selects things that -they can act on. - - This is the main reason why the selection must include the section at -point. Even if a selection exists, the invoked command may disregard -it, in which case it may act on the current section only. It is much -safer to only act on the current section but not the other selected -sections than it is to act on the current section *instead* of the -selected sections. The latter would be much more surprising and if the -current section always is part of the selection, then that cannot -happen. - - -- Variable: magit-keep-region-overlay - This variable controls whether the region is visualized as usual - even when a valid Magit selection or a hunk-internal region exists. - See the doc-string for more information. - - -File: magit.info, Node: The hunk-internal region, Next: Support for Completion Frameworks, Prev: The Selection, Up: Completion Confirmation and the Selection - -4.5.4 The hunk-internal region ------------------------------- - -Somewhat related to the Magit selection described in the previous -section is the hunk-internal region. - - Like the selection, the hunk-internal region is based on the Emacs -region but causes that region to not be visualized as it would in other -Emacs buffers, and includes the line on which the region ends even if it -ends at the very beginning of that line. - - Unlike the selection, which is based on a region that must begin in -the heading of one section and ends in the section of a sibling section, -the hunk-internal region must begin inside the *body* of a hunk section -and end in the body of the *same* section. - - The hunk-internal region is honored by "apply" commands, which can, -among other targets, act on a hunk. If the hunk-internal region is -active, then such commands act only on the marked part of the hunk -instead of on the complete hunk. - - -File: magit.info, Node: Support for Completion Frameworks, Next: Additional Completion Options, Prev: The hunk-internal region, Up: Completion Confirmation and the Selection - -4.5.5 Support for Completion Frameworks ---------------------------------------- - -The built-in option ‘completing-read-function’ specifies the low-level -function used by ‘completing-read’ to ask a user to select from a list -of choices. Its default value is ‘completing-read-default’. -Alternative completion frameworks typically activate themselves by -substituting their own implementation. - - Mostly for historic reasons Magit provides a similar option named -‘magit-completing-read-function’, which only controls the low-level -function used by ‘magit-completing-read’. This option also makes it -possible to use a different completing mechanism for Magit than for the -rest of Emacs, but doing that is not recommend. - - You most likely don’t have to customize the magit-specific option to -use an alternative completion framework. For example, if you enable -‘ivy-mode’, then Magit will respect that, and if you enable ‘helm-mode’, -then you are done too. - - However if you want to use Ido, then ‘ido-mode’ won’t do the trick. -You will also have to install the ‘ido-completing-read+’ package and use -‘magit-ido-completing-read’ as ‘magit-completing-read-function’. - - -- User Option: magit-completing-read-function - The value of this variable is the low-level function used to - perform completion by code that uses ‘magit-completing-read’ (as - opposed to the built-in ‘completing-read’). - - The default value, ‘magit-builtin-completing-read’, is suitable for - the standard completion mechanism, ‘ivy-mode’, and ‘helm-mode’ at - least. - - The built-in ‘completing-read’ and ‘completing-read-default’ are - *not* suitable to be used here. ‘magit-builtin-completing-read’ - performs some additional work, and any function used in its place - has to do the same. - - -- Function: magit-builtin-completing-read prompt choices &optional - predicate require-match initial-input hist def - This function performs completion using the built-in - ‘completing-read’ and does some additional magit-specific work. - - -- Function: magit-ido-completing-read prompt choices &optional - predicate require-match initial-input hist def - This function performs completion using ‘ido-completing-read+’ from - the package by the same name (which you have to explicitly install) - and does some additional magit-specific work. - - We have to use ‘ido-completing-read+’ instead of the - ‘ido-completing-read’ that comes with Ido itself, because the - latter, while intended as a drop-in replacement, cannot serve that - purpose because it violates too many of the implicit conventions. - - -- Function: magit-completing-read prompt choices &optional predicate - require-match initial-input hist def fallback - This is the function that Magit commands use when they need the - user to select a single thing to act on. The arguments have the - same meaning as for ‘completing-read’, except for FALLBACK, which - is unique to this function and is described below. - - Instead of asking the user to choose from a list of possible - candidates, this function may just return the default specified by - DEF, with or without requiring user confirmation. Whether that is - the case depends on PROMPT, ‘this-command’ and - ‘magit-dwim-selection’. See the documentation of the latter for - more information. - - If it does read a value in the minibuffer, then this function acts - similar to ‘completing-read’, except for the following: - - • COLLECTION must be a list of choices. A function is not - supported. - - • If REQUIRE-MATCH is ‘nil’ and the user exits without a choice, - then ‘nil’ is returned instead of an empty string. - - • If REQUIRE-MATCH is non-nil and the users exits without a - choice, an user-error is raised. - - • FALLBACK specifies a secondary default that is only used if - the primary default DEF is ‘nil’. The secondary default is - not subject to ‘magit-dwim-selection’ — if DEF is ‘nil’ but - FALLBACK is not, then this function always asks the user to - choose a candidate, just as if both defaults were ‘nil’. - - • ‘format-prompt’ is called on PROMPT and DEF (or FALLBACK if - DEF is ‘nil’). This appends ": " to the prompt and may also - add the default to the prompt, using the format specified by - ‘minibuffer-default-prompt-format’ and depending on - ‘magit-completing-read-default-prompt-predicate’. - - -File: magit.info, Node: Additional Completion Options, Prev: Support for Completion Frameworks, Up: Completion Confirmation and the Selection - -4.5.6 Additional Completion Options ------------------------------------ - - -- User Option: magit-list-refs-sortby - For many commands that read a ref or refs from the user, the value - of this option can be used to control the order of the refs. Valid - values include any key accepted by the ‘--sort’ flag of ‘git - for-each-ref’. By default, refs are sorted alphabetically by their - full name (e.g., "refs/heads/master"). - - -File: magit.info, Node: Mouse Support, Next: Running Git, Prev: Completion Confirmation and the Selection, Up: Interface Concepts - -4.6 Mouse Support -================= - -Double clicking on a section heading toggles the visibility of its body, -if any. Likewise clicking in the left fringe toggles the visibility of -the appropriate section. - - A context menu is provided but has to be enabled explicitly. In -Emacs 28 and greater, enable the global mode ‘context-menu-mode’. If -you use an older Emacs release, set -‘magit-section-show-context-menu-for-emacs<28’. - - -File: magit.info, Node: Running Git, Prev: Mouse Support, Up: Interface Concepts - -4.7 Running Git -=============== - -* Menu: - -* Viewing Git Output:: -* Git Process Status:: -* Running Git Manually:: -* Git Executable:: -* Global Git Arguments:: - - -File: magit.info, Node: Viewing Git Output, Next: Git Process Status, Up: Running Git - -4.7.1 Viewing Git Output ------------------------- - -Magit runs Git either for side-effects (e.g., when pushing) or to get -some value (e.g., the name of the current branch). - - When Git is run for side-effects, the process output is logged in a -per-repository log buffer, which can be consulted using the -‘magit-process’ command when things don’t go as expected. - - The output/errors for up to ‘magit-process-log-max’ Git commands are -retained. - -‘$’ (‘magit-process’) - This commands displays the process buffer for the current - repository. - - Inside that buffer, the usual key bindings for navigating and showing -sections are available. There is one additional command. - -‘k’ (‘magit-process-kill’) - This command kills the process represented by the section at point. - - -- Variable: magit-git-debug - This option controls whether additional reporting of git errors is - enabled. - - Magit basically calls git for one of these two reasons: for - side-effects or to do something with its standard output. - - When git is run for side-effects then its output, including error - messages, go into the process buffer which is shown when using ‘$’. - - When git’s output is consumed in some way, then it would be too - expensive to also insert it into this buffer, but when this option - is non-nil and git returns with a non-zero exit status, then at - least its standard error is inserted into this buffer. - - This is only intended for debugging purposes. Do not enable this - permanently, that would negatively affect performance. - - This is only intended for debugging purposes. Do not enable this - permanently, that would negatively affect performance. Also note - that just because git exits with a non-zero exit status and prints - an error message that usually doesn’t mean that it is an error as - far as Magit is concerned, which is another reason we usually hide - these error messages. Whether some error message is relevant in - the context of some unexpected behavior has to be judged on a case - by case basis. - - The command ‘magit-toggle-git-debug’ changes the value of this - variable. - - -- Variable: magit-process-extreme-logging - This option controls whether ‘magit-process-file’ logs to the - ‘*Messages*’ buffer. - - Only intended for temporary use when you try to figure out how - Magit uses Git behind the scene. Output that normally goes to the - magit-process buffer continues to go there. Not all output goes to - either of these two buffers. - - -File: magit.info, Node: Git Process Status, Next: Running Git Manually, Prev: Viewing Git Output, Up: Running Git - -4.7.2 Git Process Status ------------------------- - -When a Git process is running for side-effects, Magit displays an -indicator in the mode line, using the ‘magit-mode-line-process’ face. - - If the Git process exits successfully, the process indicator is -removed from the mode line immediately. - - In the case of a Git error, the process indicator is not removed, but -is instead highlighted with the ‘magit-mode-line-process-error’ face, -and the error details from the process buffer are provided as a tooltip -for mouse users. This error indicator persists in the mode line until -the next magit buffer refresh. - - If you do not wish process errors to be indicated in the mode line, -customize the ‘magit-process-display-mode-line-error’ user option. - - Process errors are additionally indicated at the top of the status -buffer. - - -File: magit.info, Node: Running Git Manually, Next: Git Executable, Prev: Git Process Status, Up: Running Git - -4.7.3 Running Git Manually --------------------------- - -While Magit provides many Emacs commands to interact with Git, it does -not cover everything. In those cases your existing Git knowledge will -come in handy. Magit provides some commands for running arbitrary Git -commands by typing them into the minibuffer, instead of having to switch -to a shell. - -‘!’ (‘magit-run’) - This transient prefix command binds the following suffix commands - and displays them in a temporary buffer until a suffix is invoked. - -‘! !’ (‘magit-git-command-topdir’) - This command reads a command from the user and executes it in the - top-level directory of the current working tree. - - The string "git " is used as initial input when prompting the user - for the command. It can be removed to run another command. - -‘:’ (‘magit-git-command’) -‘! p’ - This command reads a command from the user and executes it in - ‘default-directory’. With a prefix argument the command is - executed in the top-level directory of the current working tree - instead. - - The string "git " is used as initial input when prompting the user - for the command. It can be removed to run another command. - -‘! s’ (‘magit-shell-command-topdir’) - This command reads a command from the user and executes it in the - top-level directory of the current working tree. - -‘! S’ (‘magit-shell-command’) - This command reads a command from the user and executes it in - ‘default-directory’. With a prefix argument the command is - executed in the top-level directory of the current working tree - instead. - - -- User Option: magit-shell-command-verbose-prompt - Whether the prompt, used by the above commands when reading a shell - command, shows the directory in which it will be run. - - These suffix commands start external gui tools. - -‘! k’ (‘magit-run-gitk’) - This command runs ‘gitk’ in the current repository. - -‘! a’ (‘magit-run-gitk-all’) - This command runs ‘gitk --all’ in the current repository. - -‘! b’ (‘magit-run-gitk-branches’) - This command runs ‘gitk --branches’ in the current repository. - -‘! g’ (‘magit-run-git-gui’) - This command runs ‘git gui’ in the current repository. - -‘! m’ (‘magit-git-mergetool’) - This command runs ‘git mergetool --gui’ in the current repository. - - With a prefix argument this acts as a transient prefix command, - allowing the user to select the mergetool and change some settings. - - -File: magit.info, Node: Git Executable, Next: Global Git Arguments, Prev: Running Git Manually, Up: Running Git - -4.7.4 Git Executable --------------------- - -When Magit calls Git, then it may do so using the absolute path to the -‘git’ executable, or using just its name. - - When running ‘git’ locally and the ‘system-type’ is ‘windows-nt’ (any -Windows version) or ‘darwin’ (macOS) then ‘magit-git-executable’ is set -to an absolute path when Magit is loaded. - - On Windows it is necessary to use an absolute path because Git comes -with several wrapper scripts for the actual ‘git’ binary, which are also -placed on ‘$PATH’, and using one of these wrappers instead of the binary -would degrade performance horribly. For some macOS users using just the -name of the executable also performs horribly, so we avoid doing that on -that platform as well. On other platforms, using just the name seems to -work just fine. - - Using an absolute path when running ‘git’ on a remote machine over -Tramp, would be problematic to use an absolute path that is suitable on -the local machine, so a separate option is used to control the name or -path that is used on remote machines. - - -- User Option: magit-git-executable - The ‘git’ executable used by Magit on the local host. This should - be either the absolute path to the executable, or the string "git" - to let Emacs find the executable itself, using the standard - mechanism for doing such things. - - -- User Option: magit-remote-git-executable - The ‘git’ executable used by Magit on remote machines over Tramp. - Normally this should be just the string "git". Consider - customizing ‘tramp-remote-path’ instead of this option. - - If Emacs is unable to find the correct executable, then you can work -around that by explicitly setting the value of one of these two options. -Doing that should be considered a kludge; it is better to make sure that -the order in ‘exec-path’ or ‘tramp-remote-path’ is correct. - - Note that ‘exec-path’ is set based on the value of the ‘PATH’ -environment variable that is in effect when Emacs is started. If you -set ‘PATH’ in your shell’s init files, then that only has an effect on -Emacs if you start it from that shell (because the environment of a -process is only passed to its child processes, not to arbitrary other -processes). If that is not how you start Emacs, then the -‘exec-path-from-shell’ package can help; though honestly I consider that -a kludge too. - - The command ‘magit-debug-git-executable’ can be useful to find out -where Emacs is searching for ‘git’. - -‘M-x magit-debug-git-executable’ - This command displays a buffer with information about - ‘magit-git-executable’ and ‘magit-remote-git-executable’. - -‘M-x magit-version’ - This command shows the currently used versions of Magit, Git, and - Emacs in the echo area. Non-interactively this just returns the - Magit version. - - -File: magit.info, Node: Global Git Arguments, Prev: Git Executable, Up: Running Git - -4.7.5 Global Git Arguments --------------------------- - - -- User Option: magit-git-global-arguments - The arguments set here are used every time the git executable is - run as a subprocess. They are placed right after the executable - itself and before the git command - as in ‘git HERE... COMMAND - REST’. For valid arguments see *note (gitman)git::. - - Be careful what you add here, especially if you are using Tramp to - connect to servers with ancient Git versions. Never remove - anything that is part of the default value, unless you really know - what you are doing. And think very hard before adding something; - it will be used every time Magit runs Git for any purpose. - - -File: magit.info, Node: Inspecting, Next: Manipulating, Prev: Interface Concepts, Up: Top - -5 Inspecting -************ - -The functionality provided by Magit can be roughly divided into three -groups: inspecting existing data, manipulating existing data or adding -new data, and transferring data. Of course that is a rather crude -distinction that often falls short, but it’s more useful than no -distinction at all. This section is concerned with inspecting data, the -next two with manipulating and transferring it. Then follows a section -about miscellaneous functionality, which cannot easily be fit into this -distinction. - - Of course other distinctions make sense too, e.g., Git’s distinction -between porcelain and plumbing commands, which for the most part is -equivalent to Emacs’ distinction between interactive commands and -non-interactive functions. All of the sections mentioned before are -mainly concerned with the porcelain – Magit’s plumbing layer is -described later. - -* Menu: - -* Status Buffer:: -* Repository List:: -* Logging:: -* Diffing:: -* Ediffing:: -* References Buffer:: -* Bisecting:: -* Visiting Files and Blobs:: -* Blaming:: - - -File: magit.info, Node: Status Buffer, Next: Repository List, Up: Inspecting - -5.1 Status Buffer -================= - -While other Magit buffers contain, e.g., one particular diff or one -particular log, the status buffer contains the diffs for staged and -unstaged changes, logs for unpushed and unpulled commits, lists of -stashes and untracked files, and information related to the current -branch. - - During certain incomplete operations – for example when a merge -resulted in a conflict – additional information is displayed that helps -proceeding with or aborting the operation. - - The command ‘magit-status’ displays the status buffer belonging to -the current repository in another window. This command is used so often -that it should be bound globally. We recommend using ‘C-x g’: - - (global-set-key (kbd "C-x g") 'magit-status) - -‘C-x g’ (‘magit-status’) - When invoked from within an existing Git repository, then this - command shows the status of that repository in a buffer. - - If the current directory isn’t located within a Git repository, - then this command prompts for an existing repository or an - arbitrary directory, depending on the option - ‘magit-repository-directories’, and the status for the selected - repository is shown instead. - - • If that option specifies any existing repositories, then the - user is asked to select one of them. - - • Otherwise the user is asked to select an arbitrary directory - using regular file-name completion. If the selected directory - is the top-level directory of an existing working tree, then - the status buffer for that is shown. - - • Otherwise the user is offered to initialize the selected - directory as a new repository. After creating the repository - its status buffer is shown. - - These fallback behaviors can also be forced using one or more - prefix arguments: - - • With two prefix arguments (or more precisely a numeric prefix - value of 16 or greater) an arbitrary directory is read, which - is then acted on as described above. The same could be - accomplished using the command ‘magit-init’. - - • With a single prefix argument an existing repository is read - from the user, or if no repository can be found based on the - value of ‘magit-repository-directories’, then the behavior is - the same as with two prefix arguments. - - -- User Option: magit-repository-directories - List of directories that are Git repositories or contain Git - repositories. - - Each element has the form ‘(DIRECTORY . DEPTH)’. DIRECTORY has to - be a directory or a directory file-name, a string. DEPTH, an - integer, specifies the maximum depth to look for Git repositories. - If it is 0, then only add DIRECTORY itself. - - This option controls which repositories are being listed by - ‘magit-list-repositories’. It also affects ‘magit-status’ (which - see) in potentially surprising ways (see above). - - -- Command: magit-status-quick - This command is an alternative to ‘magit-status’ that usually - avoids refreshing the status buffer. - - If the status buffer of the current Git repository exists but isn’t - being displayed in the selected frame, then it is displayed without - being refreshed. - - If the status buffer is being displayed in the selected frame, then - this command refreshes it. - - Prefix arguments have the same meaning as for ‘magit-status’, and - additionally cause the buffer to be refresh. - - To use this command add this to your init file: - - (global-set-key (kbd "C-x g") 'magit-status-quick). - - If you do that and then for once want to redisplay the buffer and - also immediately refresh it, then type ‘C-x g’ followed by ‘g’. - - A possible alternative command is - ‘magit-display-repository-buffer’. It supports displaying any - existing Magit buffer that belongs to the current repository; not - just the status buffer. - - -- Command: ido-enter-magit-status - From an Ido prompt used to open a file, instead drop into - ‘magit-status’. This is similar to ‘ido-magic-delete-char’, which, - despite its name, usually causes a Dired buffer to be created. - - To make this command available, use something like: - - (add-hook 'ido-setup-hook - (lambda () - (define-key ido-completion-map - (kbd \"C-x g\") 'ido-enter-magit-status))) - - Starting with Emacs 25.1 the Ido keymaps are defined just once - instead of every time Ido is invoked, so now you can modify it like - pretty much every other keymap: - - (define-key ido-common-completion-map - (kbd \"C-x g\") 'ido-enter-magit-status) - -* Menu: - -* Status Sections:: -* Status Header Sections:: -* Status Module Sections:: -* Status Options:: - - -File: magit.info, Node: Status Sections, Next: Status Header Sections, Up: Status Buffer - -5.1.1 Status Sections ---------------------- - -The contents of status buffers is controlled using the hook -‘magit-status-sections-hook’. See *note Section Hooks:: to learn about -such hooks and how to customize them. - - -- User Option: magit-status-sections-hook - Hook run to insert sections into a status buffer. - - The first function on that hook by default is -‘magit-insert-status-headers’; it is described in the next section. By -default the following functions are also members of that hook: - - -- Function: magit-insert-merge-log - Insert section for the on-going merge. Display the heads that are - being merged. If no merge is in progress, do nothing. - - -- Function: magit-insert-rebase-sequence - Insert section for the on-going rebase sequence. If no such - sequence is in progress, do nothing. - - -- Function: magit-insert-am-sequence - Insert section for the on-going patch applying sequence. If no - such sequence is in progress, do nothing. - - -- Function: magit-insert-sequencer-sequence - Insert section for the on-going cherry-pick or revert sequence. If - no such sequence is in progress, do nothing. - - -- Function: magit-insert-bisect-output - While bisecting, insert section with output from ‘git bisect’. - - -- Function: magit-insert-bisect-rest - While bisecting, insert section visualizing the bisect state. - - -- Function: magit-insert-bisect-log - While bisecting, insert section logging bisect progress. - - -- Function: magit-insert-untracked-files - Maybe insert a list or tree of untracked files. - - Do so depending on the value of ‘status.showUntrackedFiles’. Note - that even if the value is ‘all’, Magit still initially only shows - directories. But the directory sections can then be expanded using - ‘TAB’. - - -- Function: magit-insert-unstaged-changes - Insert section showing unstaged changes. - - -- Function: magit-insert-staged-changes - Insert section showing staged changes. - - -- Function: magit-insert-stashes &optional ref heading - Insert the ‘stashes’ section showing reflog for "refs/stash". If - optional REF is non-nil show reflog for that instead. If optional - HEADING is non-nil use that as section heading instead of - "Stashes:". - - -- Function: magit-insert-unpulled-from-upstream - Insert section showing commits that haven’t been pulled from the - upstream branch yet. - - -- Function: magit-insert-unpulled-from-pushremote - Insert section showing commits that haven’t been pulled from the - push-remote branch yet. - - -- Function: magit-insert-unpushed-to-upstream - Insert section showing commits that haven’t been pushed to the - upstream yet. - - -- Function: magit-insert-unpushed-to-pushremote - Insert section showing commits that haven’t been pushed to the - push-remote yet. - - The following functions can also be added to the above hook: - - -- Function: magit-insert-tracked-files - Insert a tree of tracked files. - - -- Function: magit-insert-ignored-files - Insert a tree of ignored files. Its possible to limit the logs in - the current buffer to a certain directory using ‘D = f <DIRECTORY> - RET g’. If you do that, then that that also affects this command. - - The log filter can be used to limit to multiple files. In that - case this function only respects the first of the files and only if - it is a directory. - - -- Function: magit-insert-skip-worktree-files - Insert a tree of skip-worktree files. If the first element of - ‘magit-buffer-diff-files’ is a directory, then limit the list to - files below that. The value of that variable can be set using ‘D - -- DIRECTORY RET g’. - - -- Function: magit-insert-assumed-unchanged-files - Insert a tree of files that are assumed to be unchanged. If the - first element of ‘magit-buffer-diff-files’ is a directory, then - limit the list to files below that. The value of that variable can - be set using ‘D -- DIRECTORY RET g’. - - -- Function: magit-insert-unpulled-or-recent-commits - Insert section showing unpulled or recent commits. If an upstream - is configured for the current branch and it is ahead of the current - branch, then show the missing commits. Otherwise, show the last - ‘magit-log-section-commit-count’ commits. - - -- Function: magit-insert-recent-commits - Insert section showing the last ‘magit-log-section-commit-count’ - commits. - - -- User Option: magit-log-section-commit-count - How many recent commits ‘magit-insert-recent-commits’ and - ‘magit-insert-unpulled-or-recent-commits’ (provided there are no - unpulled commits) show. - - -- Function: magit-insert-unpulled-cherries - Insert section showing unpulled commits. Like - ‘magit-insert-unpulled-commits’ but prefix each commit that has not - been applied yet (i.e., a commit with a patch-id not shared with - any local commit) with "+", and all others with "-". - - -- Function: magit-insert-unpushed-cherries - Insert section showing unpushed commits. Like - ‘magit-insert-unpushed-commits’ but prefix each commit which has - not been applied to upstream yet (i.e., a commit with a patch-id - not shared with any upstream commit) with "+" and all others with - "-". - - See *note References Buffer:: for some more section inserters, which -could be used here. - - -File: magit.info, Node: Status Header Sections, Next: Status Module Sections, Prev: Status Sections, Up: Status Buffer - -5.1.2 Status Header Sections ----------------------------- - -The contents of status buffers is controlled using the hook -‘magit-status-sections-hook’ (see *note Status Sections::). - - By default ‘magit-insert-status-headers’ is the first member of that -hook variable. - - -- Function: magit-insert-status-headers - Insert headers sections appropriate for ‘magit-status-mode’ - buffers. The sections are inserted by running the functions on the - hook ‘magit-status-headers-hook’. - - -- User Option: magit-status-headers-hook - Hook run to insert headers sections into the status buffer. - - This hook is run by ‘magit-insert-status-headers’, which in turn - has to be a member of ‘magit-status-sections-hook’ to be used at - all. - - By default the following functions are members of the above hook: - - -- Function: magit-insert-error-header - Insert a header line showing the message about the Git error that - just occurred. - - This function is only aware of the last error that occur when Git - was run for side-effects. If, for example, an error occurs while - generating a diff, then that error won’t be inserted. Refreshing - the status buffer causes this section to disappear again. - - -- Function: magit-insert-diff-filter-header - Insert a header line showing the effective diff filters. - - -- Function: magit-insert-head-branch-header - Insert a header line about the current branch or detached ‘HEAD’. - - -- Function: magit-insert-upstream-branch-header - Insert a header line about the branch that is usually pulled into - the current branch. - - -- Function: magit-insert-push-branch-header - Insert a header line about the branch that the current branch is - usually pushed to. - - -- Function: magit-insert-tags-header - Insert a header line about the current and/or next tag, along with - the number of commits between the tag and ‘HEAD’. - - The following functions can also be added to the above hook: - - -- Function: magit-insert-repo-header - Insert a header line showing the path to the repository top-level. - - -- Function: magit-insert-remote-header - Insert a header line about the remote of the current branch. - - If no remote is configured for the current branch, then fall back - showing the "origin" remote, or if that does not exist the first - remote in alphabetic order. - - -- Function: magit-insert-user-header - Insert a header line about the current user. - - -File: magit.info, Node: Status Module Sections, Next: Status Options, Prev: Status Header Sections, Up: Status Buffer - -5.1.3 Status Module Sections ----------------------------- - -The contents of status buffers is controlled using the hook -‘magit-status-sections-hook’ (see *note Status Sections::). - - By default ‘magit-insert-modules’ is _not_ a member of that hook -variable. - - -- Function: magit-insert-modules - Insert submodule sections. - - Hook ‘magit-module-sections-hook’ controls which module sections - are inserted, and option ‘magit-module-sections-nested’ controls - whether they are wrapped in an additional section. - - -- User Option: magit-module-sections-hook - Hook run by ‘magit-insert-modules’. - - -- User Option: magit-module-sections-nested - This option controls whether ‘magit-insert-modules’ wraps inserted - sections in an additional section. - - If this is non-nil, then only a single top-level section is - inserted. If it is nil, then all sections listed in - ‘magit-module-sections-hook’ become top-level sections. - - -- Function: magit-insert-modules-overview - Insert sections for all submodules. For each section insert the - path, the branch, and the output of ‘git describe --tags’, or, - failing that, the abbreviated HEAD commit hash. - - Press ‘RET’ on such a submodule section to show its own status - buffer. Press ‘RET’ on the "Modules" section to display a list of - submodules in a separate buffer. This shows additional information - not displayed in the super-repository’s status buffer. - - -- Function: magit-insert-modules-unpulled-from-upstream - Insert sections for modules that haven’t been pulled from the - upstream yet. These sections can be expanded to show the - respective commits. - - -- Function: magit-insert-modules-unpulled-from-pushremote - Insert sections for modules that haven’t been pulled from the - push-remote yet. These sections can be expanded to show the - respective commits. - - -- Function: magit-insert-modules-unpushed-to-upstream - Insert sections for modules that haven’t been pushed to the - upstream yet. These sections can be expanded to show the - respective commits. - - -- Function: magit-insert-modules-unpushed-to-pushremote - Insert sections for modules that haven’t been pushed to the - push-remote yet. These sections can be expanded to show the - respective commits. - - -File: magit.info, Node: Status Options, Prev: Status Module Sections, Up: Status Buffer - -5.1.4 Status Options --------------------- - - -- User Option: magit-status-margin - This option specifies whether the margin is initially shown in - Magit-Status mode buffers and how it is formatted. - - The value has the form ‘(INIT STYLE WIDTH AUTHOR AUTHOR-WIDTH)’. - - • If INIT is non-nil, then the margin is shown initially. - • STYLE controls how to format the author or committer date. It - can be one of ‘age’ (to show the age of the commit), - ‘age-abbreviated’ (to abbreviate the time unit to a - character), or a string (suitable for ‘format-time-string’) to - show the actual date. Option - ‘magit-log-margin-show-committer-date’ controls which date is - being displayed. - • WIDTH controls the width of the margin. This exists for - forward compatibility and currently the value should not be - changed. - • AUTHOR controls whether the name of the author is also shown - by default. - • AUTHOR-WIDTH has to be an integer. When the name of the - author is shown, then this specifies how much space is used to - do so. - - Also see the proceeding section for more options concerning status -buffers. - - -File: magit.info, Node: Repository List, Next: Logging, Prev: Status Buffer, Up: Inspecting - -5.2 Repository List -=================== - - -- Command: magit-list-repositories - This command displays a list of repositories in a separate buffer. - - The option ‘magit-repository-directories’ controls which - repositories are displayed. - - -- User Option: magit-repolist-columns - This option controls what columns are displayed by the command - ‘magit-list-repositories’ and how they are displayed. - - Each element has the form ‘(HEADER WIDTH FORMAT PROPS)’. - - HEADER is the string displayed in the header. WIDTH is the width - of the column. FORMAT is a function that is called with one - argument, the repository identification (usually its basename), and - with ‘default-directory’ bound to the toplevel of its working tree. - It has to return a string to be inserted or nil. PROPS is an alist - that supports the keys ‘:right-align’, ‘:pad-right’ and ‘:sort’. - - The ‘:sort’ function has a weird interface described in the - docstring of ‘tabulated-list--get-sort’. Alternatively ‘<’ and - ‘magit-repolist-version<’ can be used as those functions are - automatically replaced with functions that satisfy the interface. - Set ‘:sort’ to ‘nil’ to inhibit sorting; if unspecified, then the - column is sortable using the default sorter. - - You may wish to display a range of numeric columns using just one - character per column and without any padding between columns, in - which case you should use an appropriate HEADER, set WIDTH to 1, - and set ‘:pad-right’ to 9. ‘+’ is substituted for numbers higher - than 9. - -The following functions can be added to the above option: - - -- Function: magit-repolist-column-ident - This function inserts the identification of the repository. - Usually this is just its basename. - - -- Function: magit-repolist-column-path - This function inserts the absolute path of the repository. - - -- Function: magit-repolist-column-version - This function inserts a description of the repository’s ‘HEAD’ - revision. - - -- Function: magit-repolist-column-branch - This function inserts the name of the current branch. - - -- Function: magit-repolist-column-upstream - This function inserts the name of the upstream branch of the - current branch. - - -- Function: magit-repolist-column-branches - This function inserts the number of branches. - - -- Function: magit-repolist-column-stashes - This function inserts the number of stashes. - - -- Function: magit-repolist-column-flag - This function inserts a flag as specified by - ‘magit-repolist-column-flag-alist’. - - By default this indicates whether there are uncommitted changes. - - • ‘N’ if there is at least one untracked file. - • ‘U’ if there is at least one unstaged file. - • ‘S’ if there is at least one staged file. - - Only the first one of these that applies is shown. - - -- Function: magit-repolist-column-flags - This functions insert all flags as specified by - ‘magit-repolist-column-flag-alist’. - - This is an alternative to function ‘magit-repolist-column-flag’, - which only lists the first one found. - - -- Function: magit-repolist-column-unpulled-from-upstream - This function inserts the number of upstream commits not in the - current branch. - - -- Function: magit-repolist-column-unpulled-from-pushremote - This function inserts the number of commits in the push branch but - not the current branch. - - -- Function: magit-repolist-column-unpushed-to-upstream - This function inserts the number of commits in the current branch - but not its upstream. - - -- Function: magit-repolist-column-unpushed-to-pushremote - This function inserts the number of commits in the current branch - but not its push branch. - -The following commands are available in repolist buffers: - -‘<RET>’ (‘magit-repolist-status’) - This command shows the status for the repository at point. - -‘m’ (‘magit-repolist-mark’) - This command marks the repository at point. - -‘u’ (‘magit-repolist-unmark’) - This command unmarks the repository at point. - -‘f’ (‘magit-repolist-fetch’) - This command fetches all marked repositories. If no repositories - are marked, then it offers to fetch all displayed repositories. - -‘5’ (‘magit-repolist-find-file-other-frame’) - This command reads a relative file-name (without completion) and - opens the respective file in each marked repository in a new frame. - If no repositories are marked, then it offers to do this for all - displayed repositories. - - -File: magit.info, Node: Logging, Next: Diffing, Prev: Repository List, Up: Inspecting - -5.3 Logging -=========== - -The status buffer contains logs for the unpushed and unpulled commits, -but that obviously isn’t enough. The transient prefix command -‘magit-log’, on ‘l’, features several suffix commands, which show a -specific log in a separate log buffer. - - Like other transient prefix commands, ‘magit-log’ also features -several infix arguments that can be changed before invoking one of the -suffix commands. However, in the case of the log transient, these -arguments may be taken from those currently in use in the current -repository’s log buffer, depending on the value of -‘magit-prefix-use-buffer-arguments’ (see *note Transient Arguments and -Buffer Variables::). - - For information about the various arguments, see *note -(gitman)git-log::. - - The switch ‘++order=VALUE’ is converted to one of -‘--author-date-order’, ‘--date-order’, or ‘--topo-order’ before being -passed to ‘git log’. - - The log transient also features several reflog commands. See *note -Reflog::. - -‘l’ (‘magit-log’) - This transient prefix command binds the following suffix commands - along with the appropriate infix arguments and displays them in a - temporary buffer until a suffix is invoked. - -‘l l’ (‘magit-log-current’) - Show log for the current branch. When ‘HEAD’ is detached or with a - prefix argument, show log for one or more revs read from the - minibuffer. - -‘l h’ (‘magit-log-head’) - Show log for ‘HEAD’. - -‘l u’ (‘magit-log-related’) - Show log for the current branch, its upstream and its push target. - When the upstream is a local branch, then also show its own - upstream. When ‘HEAD’ is detached, then show log for that, the - previously checked out branch and its upstream and push-target. - -‘l o’ (‘magit-log-other’) - Show log for one or more revs read from the minibuffer. The user - can input any revision or revisions separated by a space, or even - ranges, but only branches, tags, and a representation of the commit - at point are available as completion candidates. - -‘l L’ (‘magit-log-branches’) - Show log for all local branches and ‘HEAD’. - -‘l b’ (‘magit-log-all-branches’) - Show log for all local and remote branches and ‘HEAD’. - -‘l a’ (‘magit-log-all’) - Show log for all references and ‘HEAD’. - - Two additional commands that show the log for the file or blob that -is being visited in the current buffer exists, see *note Commands for -Buffers Visiting Files::. The command ‘magit-cherry’ also shows a log, -see *note Cherries::. - -* Menu: - -* Refreshing Logs:: -* Log Buffer:: -* Log Margin:: -* Select from Log:: -* Reflog:: -* Cherries:: - - -File: magit.info, Node: Refreshing Logs, Next: Log Buffer, Up: Logging - -5.3.1 Refreshing Logs ---------------------- - -The transient prefix command ‘magit-log-refresh’, on ‘L’, can be used to -change the log arguments used in the current buffer, without changing -which log is shown. This works in dedicated log buffers, but also in -the status buffer. - -‘L’ (‘magit-log-refresh’) - This transient prefix command binds the following suffix commands - along with the appropriate infix arguments and displays them in a - temporary buffer until a suffix is invoked. - -‘L g’ (‘magit-log-refresh’) - This suffix command sets the local log arguments for the current - buffer. - -‘L s’ (‘magit-log-set-default-arguments’) - This suffix command sets the default log arguments for buffers of - the same type as that of the current buffer. Other existing - buffers of the same type are not affected because their local - values have already been initialized. - -‘L w’ (‘magit-log-save-default-arguments’) - This suffix command sets the default log arguments for buffers of - the same type as that of the current buffer, and saves the value - for future sessions. Other existing buffers of the same type are - not affected because their local values have already been - initialized. - -‘L L’ (‘magit-toggle-margin’) - Show or hide the margin. - - -File: magit.info, Node: Log Buffer, Next: Log Margin, Prev: Refreshing Logs, Up: Logging - -5.3.2 Log Buffer ----------------- - -‘L’ (‘magit-log-refresh’) - This transient prefix command binds the following suffix commands - along with the appropriate infix arguments and displays them in a - temporary buffer until a suffix is invoked. - - See *note Refreshing Logs::. - -‘q’ (‘magit-log-bury-buffer’) - Bury the current buffer or the revision buffer in the same frame. - Like ‘magit-mode-bury-buffer’ (which see) but with a negative - prefix argument instead bury the revision buffer, provided it is - displayed in the current frame. - -‘C-c C-b’ (‘magit-go-backward’) - Move backward in current buffer’s history. - -‘C-c C-f’ (‘magit-go-forward’) - Move forward in current buffer’s history. - -‘C-c C-n’ (‘magit-log-move-to-parent’) - Move to a parent of the current commit. By default, this is the - first parent, but a numeric prefix can be used to specify another - parent. - -‘j’ (‘magit-log-move-to-revision’) - Read a revision and move to it in current log buffer. - - If the chosen reference or revision isn’t being displayed in the - current log buffer, then inform the user about that and do nothing - else. - - If invoked outside any log buffer, then display the log buffer of - the current repository first; creating it if necessary. - -‘<SPC>’ (‘magit-diff-show-or-scroll-up’) - Update the commit or diff buffer for the thing at point. - - Either show the commit or stash at point in the appropriate buffer, - or if that buffer is already being displayed in the current frame - and contains information about that commit or stash, then instead - scroll the buffer up. If there is no commit or stash at point, - then prompt for a commit. - -‘<DEL>’ (‘magit-diff-show-or-scroll-down’) - Update the commit or diff buffer for the thing at point. - - Either show the commit or stash at point in the appropriate buffer, - or if that buffer is already being displayed in the current frame - and contains information about that commit or stash, then instead - scroll the buffer down. If there is no commit or stash at point, - then prompt for a commit. - -‘=’ (‘magit-log-toggle-commit-limit’) - Toggle the number of commits the current log buffer is limited to. - If the number of commits is currently limited, then remove that - limit. Otherwise set it to 256. - -‘+’ (‘magit-log-double-commit-limit’) - Double the number of commits the current log buffer is limited to. - -‘-’ (‘magit-log-half-commit-limit’) - Half the number of commits the current log buffer is limited to. - - -- User Option: magit-log-auto-more - Insert more log entries automatically when moving past the last - entry. Only considered when moving past the last entry with - ‘magit-goto-*-section’ commands. - - -- User Option: magit-log-show-refname-after-summary - Whether to show the refnames after the commit summaries. This is - useful if you use really long branch names. - - -- User Option: magit-log-show-color-graph-limit - When showing more commits than specified by this option, then the - ‘--color’ argument, if specified, is silently dropped. This is - necessary because the ‘ansi-color’ library, which is used to turn - control sequences into faces, is just too slow. - - -- User Option: magit-log-show-signatures-limit - When showing more commits than specified by this option, then the - ‘--show-signature’ argument, if specified, is silently dropped. - This is necessary because checking the signature of a large number - of commits is just too slow. - - Magit displays references in logs a bit differently from how Git does -it. - - Local branches are blue and remote branches are green. Of course -that depends on the used theme, as do the colors used for other types of -references. The current branch has a box around it, as do remote -branches that are their respective remote’s ‘HEAD’ branch. - - If a local branch and its push-target point at the same commit, then -their names are combined to preserve space and to make that relationship -visible. For example: - - origin/feature - [green][blue-] - - instead of - - feature origin/feature - [blue-] [green-------] - - Also note that while the transient features the ‘--show-signature’ -argument, that won’t actually be used when enabled, because Magit -defaults to use just one line per commit. Instead the commit colorized -to indicate the validity of the signed commit object, using the faces -named ‘magit-signature-*’ (which see). - - For a description of ‘magit-log-margin’ see *note Log Margin::. - - -File: magit.info, Node: Log Margin, Next: Select from Log, Prev: Log Buffer, Up: Logging - -5.3.3 Log Margin ----------------- - -In buffers which show one or more logs, it is possible to show -additional information about each commit in the margin. The options -used to configure the margin are named ‘magit-INFIX-margin’, where INFIX -is the same as in the respective major-mode ‘magit-INFIX-mode’. In -regular log buffers that would be ‘magit-log-margin’. - - -- User Option: magit-log-margin - This option specifies whether the margin is initially shown in - Magit-Log mode buffers and how it is formatted. - - The value has the form ‘(INIT STYLE WIDTH AUTHOR AUTHOR-WIDTH)’. - - • If INIT is non-nil, then the margin is shown initially. - • STYLE controls how to format the author or committer date. It - can be one of ‘age’ (to show the age of the commit), - ‘age-abbreviated’ (to abbreviate the time unit to a - character), or a string (suitable for ‘format-time-string’) to - show the actual date. Option - ‘magit-log-margin-show-committer-date’ controls which date is - being displayed. - • WIDTH controls the width of the margin. This exists for - forward compatibility and currently the value should not be - changed. - • AUTHOR controls whether the name of the author is also shown - by default. - • AUTHOR-WIDTH has to be an integer. When the name of the - author is shown, then this specifies how much space is used to - do so. - - You can change the STYLE and AUTHOR-WIDTH of all ‘magit-INFIX-margin’ -options to the same values by customizing ‘magit-log-margin’ *before* -‘magit’ is loaded. If you do that, then the respective values for the -other options will default to what you have set for that variable. -Likewise if you set INIT in ‘magit-log-margin’ to ‘nil’, then that is -used in the default of all other options. But setting it to ‘t’, i.e. -re-enforcing the default for that option, does not carry to other -options. - - -- User Option: magit-log-margin-show-committer-date - This option specifies whether to show the committer date in the - margin. This option only controls whether the committer date is - displayed instead of the author date. Whether some date is - displayed in the margin and whether the margin is displayed at all - is controlled by other options. - -‘L’ (‘magit-margin-settings’) - This transient prefix command binds the following suffix commands, - each of which changes the appearance of the margin in some way. - - In some buffers that support the margin, ‘L’ is instead bound to -‘magit-log-refresh’, but that transient features the same commands, and -then some other unrelated commands. - -‘L L’ (‘magit-toggle-margin’) - This command shows or hides the margin. - -‘L l’ (‘magit-cycle-margin-style’) - This command cycles the style used for the margin. - -‘L d’ (‘magit-toggle-margin-details’) - This command shows or hides details in the margin. - - -File: magit.info, Node: Select from Log, Next: Reflog, Prev: Log Margin, Up: Logging - -5.3.4 Select from Log ---------------------- - -When the user has to select a recent commit that is reachable from -‘HEAD’, using regular completion would be inconvenient (because most -humans cannot remember hashes or "HEAD~5", at least not without double -checking). Instead a log buffer is used to select the commit, which has -the advantage that commits are presented in order and with the commit -message. - - Such selection logs are used when selecting the beginning of a rebase -and when selecting the commit to be squashed into. - - In addition to the key bindings available in all log buffers, the -following additional key bindings are available in selection log -buffers: - -‘C-c C-c’ (‘magit-log-select-pick’) - Select the commit at point and act on it. Call - ‘magit-log-select-pick-function’ with the selected commit as - argument. - -‘C-c C-k’ (‘magit-log-select-quit’) - Abort selecting a commit, don’t act on any commit. - - -- User Option: magit-log-select-margin - This option specifies whether the margin is initially shown in - Magit-Log-Select mode buffers and how it is formatted. - - The value has the form ‘(INIT STYLE WIDTH AUTHOR AUTHOR-WIDTH)’. - - • If INIT is non-nil, then the margin is shown initially. - • STYLE controls how to format the author or committer date. It - can be one of ‘age’ (to show the age of the commit), - ‘age-abbreviated’ (to abbreviate the time unit to a - character), or a string (suitable for ‘format-time-string’) to - show the actual date. Option - ‘magit-log-margin-show-committer-date’ controls which date is - being displayed. - • WIDTH controls the width of the margin. This exists for - forward compatibility and currently the value should not be - changed. - • AUTHOR controls whether the name of the author is also shown - by default. - • AUTHOR-WIDTH has to be an integer. When the name of the - author is shown, then this specifies how much space is used to - do so. - - -File: magit.info, Node: Reflog, Next: Cherries, Prev: Select from Log, Up: Logging - -5.3.5 Reflog ------------- - -Also see *note (gitman)git-reflog::. - - These reflog commands are available from the log transient. See -*note Logging::. - -‘l r’ (‘magit-reflog-current’) - Display the reflog of the current branch. - -‘l O’ (‘magit-reflog-other’) - Display the reflog of a branch or another ref. - -‘l H’ (‘magit-reflog-head’) - Display the ‘HEAD’ reflog. - - -- User Option: magit-reflog-margin - This option specifies whether the margin is initially shown in - Magit-Reflog mode buffers and how it is formatted. - - The value has the form ‘(INIT STYLE WIDTH AUTHOR AUTHOR-WIDTH)’. - - • If INIT is non-nil, then the margin is shown initially. - • STYLE controls how to format the author or committer date. It - can be one of ‘age’ (to show the age of the commit), - ‘age-abbreviated’ (to abbreviate the time unit to a - character), or a string (suitable for ‘format-time-string’) to - show the actual date. Option - ‘magit-log-margin-show-committer-date’ controls which date is - being displayed. - • WIDTH controls the width of the margin. This exists for - forward compatibility and currently the value should not be - changed. - • AUTHOR controls whether the name of the author is also shown - by default. - • AUTHOR-WIDTH has to be an integer. When the name of the - author is shown, then this specifies how much space is used to - do so. - - -File: magit.info, Node: Cherries, Prev: Reflog, Up: Logging - -5.3.6 Cherries --------------- - -Cherries are commits that haven’t been applied upstream (yet), and are -usually visualized using a log. Each commit is prefixed with ‘-’ if it -has an equivalent in the upstream and ‘+’ if it does not, i.e., if it is -a cherry. - - The command ‘magit-cherry’ shows cherries for a single branch, but -the references buffer (see *note References Buffer::) can show cherries -for multiple "upstreams" at once. - - Also see *note (gitman)git-reflog::. - -‘Y’ (‘magit-cherry’) - Show commits that are in a certain branch but that have not been - merged in the upstream branch. - - -- User Option: magit-cherry-margin - This option specifies whether the margin is initially shown in - Magit-Cherry mode buffers and how it is formatted. - - The value has the form ‘(INIT STYLE WIDTH AUTHOR AUTHOR-WIDTH)’. - - • If INIT is non-nil, then the margin is shown initially. - • STYLE controls how to format the author or committer date. It - can be one of ‘age’ (to show the age of the commit), - ‘age-abbreviated’ (to abbreviate the time unit to a - character), or a string (suitable for ‘format-time-string’) to - show the actual date. Option - ‘magit-log-margin-show-committer-date’ controls which date is - being displayed. - • WIDTH controls the width of the margin. This exists for - forward compatibility and currently the value should not be - changed. - • AUTHOR controls whether the name of the author is also shown - by default. - • AUTHOR-WIDTH has to be an integer. When the name of the - author is shown, then this specifies how much space is used to - do so. - - -File: magit.info, Node: Diffing, Next: Ediffing, Prev: Logging, Up: Inspecting - -5.4 Diffing -=========== - -The status buffer contains diffs for the staged and unstaged commits, -but that obviously isn’t enough. The transient prefix command -‘magit-diff’, on ‘d’, features several suffix commands, which show a -specific diff in a separate diff buffer. - - Like other transient prefix commands, ‘magit-diff’ also features -several infix arguments that can be changed before invoking one of the -suffix commands. However, in the case of the diff transient, these -arguments may be taken from those currently in use in the current -repository’s diff buffer, depending on the value of -‘magit-prefix-use-buffer-arguments’ (see *note Transient Arguments and -Buffer Variables::). - - Also see *note (gitman)git-diff::. - -‘d’ (‘magit-diff’) - This transient prefix command binds the following suffix commands - along with the appropriate infix arguments and displays them in a - temporary buffer until a suffix is invoked. - -‘d d’ (‘magit-diff-dwim’) - Show changes for the thing at point. - -‘d r’ (‘magit-diff-range’) - Show differences between two commits. - - RANGE should be a range (A..B or A...B) but can also be a single - commit. If one side of the range is omitted, then it defaults to - ‘HEAD’. If just a commit is given, then changes in the working - tree relative to that commit are shown. - - If the region is active, use the revisions on the first and last - line of the region. With a prefix argument, instead of diffing the - revisions, choose a revision to view changes along, starting at the - common ancestor of both revisions (i.e., use a "..." range). - -‘d w’ (‘magit-diff-working-tree’) - Show changes between the current working tree and the ‘HEAD’ - commit. With a prefix argument show changes between the working - tree and a commit read from the minibuffer. - -‘d s’ (‘magit-diff-staged’) - Show changes between the index and the ‘HEAD’ commit. With a - prefix argument show changes between the index and a commit read - from the minibuffer. - -‘d u’ (‘magit-diff-unstaged’) - Show changes between the working tree and the index. - -‘d p’ (‘magit-diff-paths’) - Show changes between any two files on disk. - - All of the above suffix commands update the repository’s diff buffer. -The diff transient also features two commands which show differences in -another buffer: - -‘d c’ (‘magit-show-commit’) - Show the commit at point. If there is no commit at point or with a - prefix argument, prompt for a commit. - -‘d t’ (‘magit-stash-show’) - Show all diffs of a stash in a buffer. - - Two additional commands that show the diff for the file or blob that -is being visited in the current buffer exists, see *note Commands for -Buffers Visiting Files::. - -* Menu: - -* Refreshing Diffs:: -* Commands Available in Diffs:: -* Diff Options:: -* Revision Buffer:: - - -File: magit.info, Node: Refreshing Diffs, Next: Commands Available in Diffs, Up: Diffing - -5.4.1 Refreshing Diffs ----------------------- - -The transient prefix command ‘magit-diff-refresh’, on ‘D’, can be used -to change the diff arguments used in the current buffer, without -changing which diff is shown. This works in dedicated diff buffers, but -also in the status buffer. - - (There is one exception; diff arguments cannot be changed in buffers -created by ‘magit-merge-preview’ because the underlying Git command does -not support these arguments.) - -‘D’ (‘magit-diff-refresh’) - This transient prefix command binds the following suffix commands - along with the appropriate infix arguments and displays them in a - temporary buffer until a suffix is invoked. - -‘D g’ (‘magit-diff-refresh’) - This suffix command sets the local diff arguments for the current - buffer. - -‘D s’ (‘magit-diff-set-default-arguments’) - This suffix command sets the default diff arguments for buffers of - the same type as that of the current buffer. Other existing - buffers of the same type are not affected because their local - values have already been initialized. - -‘D w’ (‘magit-diff-save-default-arguments’) - This suffix command sets the default diff arguments for buffers of - the same type as that of the current buffer, and saves the value - for future sessions. Other existing buffers of the same type are - not affected because their local values have already been - initialized. - -‘D t’ (‘magit-diff-toggle-refine-hunk’) - This command toggles hunk refinement on or off. - -‘D r’ (‘magit-diff-switch-range-type’) - This command converts the diff range type from "revA..revB" to - "revB...revA", or vice versa. - -‘D f’ (‘magit-diff-flip-revs’) - This command swaps revisions in the diff range from "revA..revB" to - "revB..revA", or vice versa. - -‘D F’ (‘magit-diff-toggle-file-filter’) - This command toggles the file restriction of the diffs in the - current buffer, allowing you to quickly switch between viewing all - the changes in the commit and the restricted subset. As a special - case, when this command is called from a log buffer, it toggles the - file restriction in the repository’s revision buffer, which is - useful when you display a revision from a log buffer that is - restricted to a file or files. - - In addition to the above transient, which allows changing any of the -supported arguments, there also exist some commands that change only a -particular argument. - -‘-’ (‘magit-diff-less-context’) - This command decreases the context for diff hunks by COUNT lines. - -‘+’ (‘magit-diff-more-context’) - This command increases the context for diff hunks by COUNT lines. - -‘0’ (‘magit-diff-default-context’) - This command resets the context for diff hunks to the default - height. - - The following commands quickly change what diff is being displayed -without having to using one of the diff transient. - -‘C-c C-d’ (‘magit-diff-while-committing’) - While committing, this command shows the changes that are about to - be committed. While amending, invoking the command again toggles - between showing just the new changes or all the changes that will - be committed. - - This binding is available in the diff buffer as well as the commit - message buffer. - -‘C-c C-b’ (‘magit-go-backward’) - This command moves backward in current buffer’s history. - -‘C-c C-f’ (‘magit-go-forward’) - This command moves forward in current buffer’s history. - - -File: magit.info, Node: Commands Available in Diffs, Next: Diff Options, Prev: Refreshing Diffs, Up: Diffing - -5.4.2 Commands Available in Diffs ---------------------------------- - -Some commands are only available if point is inside a diff. - - ‘magit-diff-visit-file’ and related commands visit the appropriate -version of the file that the diff at point is about. Likewise -‘magit-diff-visit-worktree-file’ and related commands visit the worktree -version of the file that the diff at point is about. See *note Visiting -Files and Blobs from a Diff:: for more information and the key bindings. - -‘C-c C-t’ (‘magit-diff-trace-definition’) - This command shows a log for the definition at point. - - -- User Option: magit-log-trace-definition-function - The function specified by this option is used by - ‘magit-log-trace-definition’ to determine the function at point. - For major-modes that have special needs, you could set the local - value using the mode’s hook. - -‘C-c C-e’ (‘magit-diff-edit-hunk-commit’) - From a hunk, this command edits the respective commit and visits - the file. - - First it visits the file being modified by the hunk at the correct - location using ‘magit-diff-visit-file’. This actually visits a - blob. When point is on a diff header, not within an individual - hunk, then this visits the blob the first hunk is about. - - Then it invokes ‘magit-edit-line-commit’, which uses an interactive - rebase to make the commit editable, or if that is not possible - because the commit is not reachable from ‘HEAD’ by checking out - that commit directly. This also causes the actual worktree file to - be visited. - - Neither the blob nor the file buffer are killed when finishing the - rebase. If that is undesirable, then it might be better to use - ‘magit-rebase-edit-commit’ instead of this command. - -‘j’ (‘magit-jump-to-diffstat-or-diff’) - This command jumps to the diffstat or diff. When point is on a - file inside the diffstat section, then jump to the respective diff - section. Otherwise, jump to the diffstat section or a child - thereof. - - The next two commands are not specific to Magit-Diff mode (or and -Magit buffer for that matter), but it might be worth pointing out that -they are available here too. - -‘<SPC>’ (‘scroll-up’) - This command scrolls text upward. - -‘<DEL>’ (‘scroll-down’) - This command scrolls text downward. - - -File: magit.info, Node: Diff Options, Next: Revision Buffer, Prev: Commands Available in Diffs, Up: Diffing - -5.4.3 Diff Options ------------------- - - -- User Option: magit-diff-refine-hunk - Whether to show word-granularity differences within diff hunks. - - • ‘nil’ Never show fine differences. - • ‘t’ Show fine differences for the current diff hunk only. - • ‘all’ Show fine differences for all displayed diff hunks. - - -- User Option: magit-diff-refine-ignore-whitespace - Whether to ignore whitespace changes in word-granularity - differences. - - -- User Option: magit-diff-adjust-tab-width - Whether to adjust the width of tabs in diffs. - - Determining the correct width can be expensive if it requires - opening large and/or many files, so the widths are cached in the - variable ‘magit-diff--tab-width-cache’. Set that to nil to - invalidate the cache. - - • ‘nil’ Never adjust tab width. Use ‘tab-width’s value from the - Magit buffer itself instead. - - • ‘t’ If the corresponding file-visiting buffer exits, then use - ‘tab-width’’s value from that buffer. Doing this is cheap, so - this value is used even if a corresponding cache entry exists. - - • ‘always’ If there is no such buffer, then temporarily visit - the file to determine the value. - - • NUMBER Like ‘always’, but don’t visit files larger than NUMBER - bytes. - - -- User Option: magit-diff-paint-whitespace - Specify where to highlight whitespace errors. - - See ‘magit-diff-highlight-trailing’, - ‘magit-diff-highlight-indentation’. The symbol ‘t’ means in all - diffs, ‘status’ means only in the status buffer, and nil means - nowhere. - - • ‘nil’ Never highlight whitespace errors. - • ‘t’ Highlight whitespace errors everywhere. - • ‘uncommitted’ Only highlight whitespace errors in diffs - showing uncommitted changes. For backward compatibility - ‘status’ is treated as a synonym. - - -- User Option: magit-diff-paint-whitespace-lines - Specify in what kind of lines to highlight whitespace errors. - - • ‘t’ Highlight only in added lines. - • ‘both’ Highlight in added and removed lines. - • ‘all’ Highlight in added, removed and context lines. - - -- User Option: magit-diff-highlight-trailing - Whether to highlight whitespace at the end of a line in diffs. - Used only when ‘magit-diff-paint-whitespace’ is non-nil. - - -- User Option: magit-diff-highlight-indentation - This option controls whether to highlight the indentation in case - it used the "wrong" indentation style. Indentation is only - highlighted if ‘magit-diff-paint-whitespace’ is also non-nil. - - The value is an alist of the form ‘((REGEXP . INDENT)...)’. The - path to the current repository is matched against each element in - reverse order. Therefore if a REGEXP matches, then earlier - elements are not tried. - - If the used INDENT is ‘tabs’, highlight indentation with tabs. If - INDENT is an integer, highlight indentation with at least that many - spaces. Otherwise, highlight neither. - - -- User Option: magit-diff-hide-trailing-cr-characters - Whether to hide ^M characters at the end of a line in diffs. - - -- User Option: magit-diff-highlight-hunk-region-functions - This option specifies the functions used to highlight the - hunk-internal region. - - ‘magit-diff-highlight-hunk-region-dim-outside’ overlays the outside - of the hunk internal selection with a face that causes the added - and removed lines to have the same background color as context - lines. This function should not be removed from the value of this - option. - - ‘magit-diff-highlight-hunk-region-using-overlays’ and - ‘magit-diff-highlight-hunk-region-using-underline’ emphasize the - region by placing delimiting horizontal lines before and after it. - Both of these functions have glitches which cannot be fixed due to - limitations of Emacs’ display engine. For more information see - <https://github.com/magit/magit/issues/2758> ff. - - Instead of, or in addition to, using delimiting horizontal lines, - to emphasize the boundaries, you may wish to emphasize the text - itself, using ‘magit-diff-highlight-hunk-region-using-face’. - - In terminal frames it’s not possible to draw lines as the overlay - and underline variants normally do, so there they fall back to - calling the face function instead. - - -- User Option: magit-diff-unmarked-lines-keep-foreground - This option controls whether added and removed lines outside the - hunk-internal region only lose their distinct background color or - also the foreground color. Whether the outside of the region is - dimmed at all depends on - ‘magit-diff-highlight-hunk-region-functions’. - - -- User Option: magit-diff-extra-stat-arguments - This option specifies additional arguments to be used alongside - ‘--stat’. - - The value is a list of zero or more arguments or a function that - takes no argument and returns such a list. These arguments are - allowed here: ‘--stat-width’, ‘--stat-name-width’, - ‘--stat-graph-width’ and ‘--compact-summary’. Also see *note - (gitman)git-diff::. - - -File: magit.info, Node: Revision Buffer, Prev: Diff Options, Up: Diffing - -5.4.4 Revision Buffer ---------------------- - - -- User Option: magit-revision-insert-related-refs - Whether to show related branches in revision buffers. - - • ‘nil’ Don’t show any related branches. - • ‘t’ Show related local branches. - • ‘all’ Show related local and remote branches. - • ‘mixed’ Show all containing branches and local merged - branches. - - -- User Option: magit-revision-show-gravatars - Whether to show gravatar images in revision buffers. - - If ‘nil’, then don’t insert any gravatar images. If ‘t’, then - insert both images. If ‘author’ or ‘committer’, then insert only - the respective image. - - If you have customized the option ‘magit-revision-headers-format’ - and want to insert the images then you might also have to specify - where to do so. In that case the value has to be a cons-cell of - two regular expressions. The car specifies where to insert the - author’s image. The top half of the image is inserted right after - the matched text, the bottom half on the next line in the same - column. The cdr specifies where to insert the committer’s image, - accordingly. Either the car or the cdr may be nil." - - -- User Option: magit-revision-use-hash-sections - Whether to turn hashes inside the commit message into sections. - - If non-nil, then hashes inside the commit message are turned into - ‘commit’ sections. There is a trade off to be made between - performance and reliability: - - • ‘slow’ calls git for every word to be absolutely sure. - • ‘quick’ skips words less than seven characters long. - • ‘quicker’ additionally skips words that don’t contain a - number. - • ‘quickest’ uses all words that are at least seven characters - long and which contain at least one number as well as at least - one letter. - - If nil, then no hashes are turned into sections, but you can still - visit the commit at point using "RET". - - The diffs shown in the revision buffer may be automatically -restricted to a subset of the changed files. If the revision buffer is -displayed from a log buffer, the revision buffer will share the same -file restriction as that log buffer (also see the command -‘magit-diff-toggle-file-filter’). - - -- User Option: magit-revision-filter-files-on-follow - Whether showing a commit from a log buffer honors the log’s file - filter when the log arguments include ‘--follow’. - - When this option is nil, displaying a commit from a log ignores the - log’s file filter if the log arguments include ‘--follow’. Doing - so avoids showing an empty diff in revision buffers for commits - before a rename event. In such cases, the ‘--patch’ argument of - the log transient can be used to show the file-restricted diffs - inline. - - Set this option to non-nil to keep the log’s file restriction even - if ‘--follow’ is present in the log arguments. - - If the revision buffer is not displayed from a log buffer, the file -restriction is determined as usual (see *note Transient Arguments and -Buffer Variables::). - - -File: magit.info, Node: Ediffing, Next: References Buffer, Prev: Diffing, Up: Inspecting - -5.5 Ediffing -============ - -This section describes how to enter Ediff from Magit buffers. For -information on how to use Ediff itself, see *note (ediff)Top::. - -‘e’ (‘magit-ediff-dwim’) - Compare, stage, or resolve using Ediff. - - This command tries to guess what file, and what commit or range the - user wants to compare, stage, or resolve using Ediff. It might - only be able to guess either the file, or range/commit, in which - case the user is asked about the other. It might not always guess - right, in which case the appropriate ‘magit-ediff-*’ command has to - be used explicitly. If it cannot read the user’s mind at all, then - it asks the user for a command to run. - -‘E’ (‘magit-ediff’) - This transient prefix command binds the following suffix commands - and displays them in a temporary buffer until a suffix is invoked. - -‘E r’ (‘magit-ediff-compare’) - Compare two revisions of a file using Ediff. - - If the region is active, use the revisions on the first and last - line of the region. With a prefix argument, instead of diffing the - revisions, choose a revision to view changes along, starting at the - common ancestor of both revisions (i.e., use a "..." range). - -‘E m’ (‘magit-ediff-resolve-rest’) - This command allows you to resolve outstanding conflicts in the - file at point using Ediff. If there is no file at point or if it - doesn’t have any unmerged changes, then this command prompts for a - file. - - Provided that the value of ‘merge.conflictstyle’ is ‘diff3’, you - can view the file’s merge-base revision using ‘/’ in the Ediff - control buffer. - - The A, B and Ancestor buffers are constructed from the conflict - markers in the worktree file. Because you and/or Git may have - already resolved some conflicts, that means that these buffers may - not contain the actual versions from the respective blobs. - -‘E M’ (‘magit-ediff-resolve-all’) - This command allows you to resolve all conflicts in the file at - point using Ediff. If there is no file at point or if it doesn’t - have any unmerged changes, then this command prompts for a file. - - Provided that the value of ‘merge.conflictstyle’ is ‘diff3’, you - can view the file’s merge-base revision using ‘/’ in the Ediff - control buffer. - - First the file in the worktree is moved aside, appending the suffix - ‘.ORIG’, so that you could later go back to that version. Then it - is reconstructed from the two sides of the conflict and the - merge-base, if available. - - It would be nice if the worktree file were just used as-is, but - Ediff does not support that. This means that all conflicts, that - Git has already resolved, are restored. On the other hand Ediff - also tries to resolve conflicts, and in many cases Ediff and Git - should produce similar results. - - However if you have already resolved some conflicts manually, then - those changes are discarded (though you can recover them from the - backup file). In such cases ‘magit-ediff-resolve-rest’ might be - more suitable. - - The advantage that this command has over ‘magit-ediff-resolve-rest’ - is that the A, B and Ancestor buffers correspond to blobs from the - respective commits, allowing you to inspect a side in context and - to use Magit commands in these buffers to do so. Blame and log - commands are particularly useful here. - -‘E t’ (‘magit-git-mergetool’) - This command does not actually use Ediff. While it serves the same - purpose as ‘magit-ediff-resolve-rest’, it uses ‘git mergetool - --gui’ to resolve conflicts. - - With a prefix argument this acts as a transient prefix command, - allowing the user to select the mergetool and change some settings. - -‘E s’ (‘magit-ediff-stage’) - Stage and unstage changes to a file using Ediff, defaulting to the - file at point. - -‘E u’ (‘magit-ediff-show-unstaged’) - Show unstaged changes to a file using Ediff. - -‘E i’ (‘magit-ediff-show-staged’) - Show staged changes to a file using Ediff. - -‘E w’ (‘magit-ediff-show-working-tree’) - Show changes in a file between ‘HEAD’ and working tree using Ediff. - -‘E c’ (‘magit-ediff-show-commit’) - Show changes to a file introduced by a commit using Ediff. - -‘E z’ (‘magit-ediff-show-stash’) - Show changes to a file introduced by a stash using Ediff. - - -- User Option: magit-ediff-dwim-resolve-function - This option controls which function ‘magit-ediff-dwim’ uses to - resolve conflicts. One of ‘magit-ediff-resolve-rest’, - ‘magit-ediff-resolve-all’ or ‘magit-git-mergetool’; which are all - discussed above. - - -- User Option: magit-ediff-dwim-show-on-hunks - This option controls what command ‘magit-ediff-dwim’ calls when - point is on uncommitted hunks. When nil, always run - ‘magit-ediff-stage’. Otherwise, use ‘magit-ediff-show-staged’ and - ‘magit-ediff-show-unstaged’ to show staged and unstaged changes, - respectively. - - -- User Option: magit-ediff-show-stash-with-index - This option controls whether ‘magit-ediff-show-stash’ includes a - buffer containing the file’s state in the index at the time the - stash was created. This makes it possible to tell which changes in - the stash were staged. - - -- User Option: magit-ediff-quit-hook - This hook is run after quitting an Ediff session that was created - using a Magit command. The hook functions are run inside the Ediff - control buffer, and should not change the current buffer. - - This is similar to ‘ediff-quit-hook’ but takes the needs of Magit - into account. The regular ‘ediff-quit-hook’ is ignored by Ediff - sessions that were created using a Magit command. - - -File: magit.info, Node: References Buffer, Next: Bisecting, Prev: Ediffing, Up: Inspecting - -5.6 References Buffer -===================== - -‘y’ (‘magit-show-refs’) - This command lists branches and tags in a dedicated buffer. - - However if this command is invoked again from this buffer or if it - is invoked with a prefix argument, then it acts as a transient - prefix command, which binds the following suffix commands and some - infix arguments. - - All of the following suffix commands list exactly the same branches -and tags. The only difference the optional feature that can be enabled -by changing the value of ‘magit-refs-show-commit-count’ (see below). -These commands specify a different branch or commit against which all -the other references are compared. - -‘y y’ (‘magit-show-refs-head’) - This command lists branches and tags in a dedicated buffer. Each - reference is being compared with ‘HEAD’. - -‘y c’ (‘magit-show-refs-current’) - This command lists branches and tags in a dedicated buffer. Each - reference is being compared with the current branch or ‘HEAD’ if it - is detached. - -‘y o’ (‘magit-show-refs-other’) - This command lists branches and tags in a dedicated buffer. Each - reference is being compared with a branch read from the user. - -‘y r’ (‘magit-refs-set-show-commit-count’) - This command changes for which refs the commit count is shown. - - -- User Option: magit-refs-show-commit-count - Whether to show commit counts in Magit-Refs mode buffers. - - • ‘all’ Show counts for branches and tags. - • ‘branch’ Show counts for branches only. - • ‘nil’ Never show counts. - - The default is ‘nil’ because anything else can be very expensive. - - -- User Option: magit-refs-pad-commit-counts - Whether to pad all commit counts on all sides in Magit-Refs mode - buffers. - - If this is nil, then some commit counts are displayed right next to - one of the branches that appear next to the count, without any - space in between. This might look bad if the branch name faces - look too similar to ‘magit-dimmed’. - - If this is non-nil, then spaces are placed on both sides of all - commit counts. - - -- User Option: magit-refs-show-remote-prefix - Whether to show the remote prefix in lists of remote branches. - - Showing the prefix is redundant because the name of the remote is - already shown in the heading preceding the list of its branches. - - -- User Option: magit-refs-primary-column-width - Width of the primary column in ‘magit-refs-mode’ buffers. The - primary column is the column that contains the name of the branch - that the current row is about. - - If this is an integer, then the column is that many columns wide. - Otherwise it has to be a cons-cell of two integers. The first - specifies the minimal width, the second the maximal width. In that - case the actual width is determined using the length of the names - of the shown local branches. (Remote branches and tags are not - taken into account when calculating to optimal width.) - - -- User Option: magit-refs-focus-column-width - Width of the focus column in ‘magit-refs-mode’ buffers. - - The focus column is the first column, which marks one branch - (usually the current branch) as the focused branch using ‘*’ or - ‘@’. For each other reference, this column optionally shows how - many commits it is ahead of the focused branch and ‘<’, or if it - isn’t ahead then the commits it is behind and ‘>’, or if it isn’t - behind either, then a ‘=’. - - This column may also display only ‘*’ or ‘@’ for the focused - branch, in which case this option is ignored. Use ‘L v’ to change - the verbosity of this column. - - -- User Option: magit-refs-margin - This option specifies whether the margin is initially shown in - Magit-Refs mode buffers and how it is formatted. - - The value has the form ‘(INIT STYLE WIDTH AUTHOR AUTHOR-WIDTH)’. - - • If INIT is non-nil, then the margin is shown initially. - • STYLE controls how to format the author or committer date. It - can be one of ‘age’ (to show the age of the commit), - ‘age-abbreviated’ (to abbreviate the time unit to a - character), or a string (suitable for ‘format-time-string’) to - show the actual date. Option - ‘magit-log-margin-show-committer-date’ controls which date is - being displayed. - • WIDTH controls the width of the margin. This exists for - forward compatibility and currently the value should not be - changed. - • AUTHOR controls whether the name of the author is also shown - by default. - • AUTHOR-WIDTH has to be an integer. When the name of the - author is shown, then this specifies how much space is used to - do so. - - -- User Option: magit-refs-margin-for-tags - This option specifies whether to show information about tags in the - margin. This is disabled by default because it is slow if there - are many tags. - - The following variables control how individual refs are displayed. -If you change one of these variables (especially the "%c" part), then -you should also change the others to keep things aligned. The following -%-sequences are supported: - - • ‘%a’ Number of commits this ref has over the one we compare to. - • ‘%b’ Number of commits the ref we compare to has over this one. - • ‘%c’ Number of commits this ref has over the one we compare to. - For the ref which all other refs are compared this is instead "@", - if it is the current branch, or "#" otherwise. - • ‘%C’ For the ref which all other refs are compared this is "@", if - it is the current branch, or "#" otherwise. For all other refs " - ". - • ‘%h’ Hash of this ref’s tip. - • ‘%m’ Commit summary of the tip of this ref. - • ‘%n’ Name of this ref. - • ‘%u’ Upstream of this local branch. - • ‘%U’ Upstream of this local branch and additional local vs. - upstream information. - - -- User Option: magit-refs-filter-alist - The purpose of this option is to forgo displaying certain refs - based on their name. If you want to not display any refs of a - certain type, then you should remove the appropriate function from - ‘magit-refs-sections-hook’ instead. - - This alist controls which tags and branches are omitted from being - displayed in ‘magit-refs-mode’ buffers. If it is ‘nil’, then all - refs are displayed (subject to ‘magit-refs-sections-hook’). - - All keys are tried in order until one matches. Then its value is - used and subsequent elements are ignored. If the value is non-nil, - then the reference is displayed, otherwise it is not. If no - element matches, then the reference is displayed. - - A key can either be a regular expression that the refname has to - match, or a function that takes the refname as only argument and - returns a boolean. A remote branch such as "origin/master" is - displayed as just "master", however for this comparison the former - is used. - -‘<RET>’ (‘magit-visit-ref’) - This command visits the reference or revision at point in another - buffer. If there is no revision at point or with a prefix argument - then it prompts for a revision. - - This command behaves just like ‘magit-show-commit’ as described - above, except if point is on a reference in a ‘magit-refs-mode’ - buffer, in which case the behavior may be different, but only if - you have customized the option ‘magit-visit-ref-behavior’. - - -- User Option: magit-visit-ref-behavior - This option controls how ‘magit-visit-ref’ behaves in - ‘magit-refs-mode’ buffers. - - By default ‘magit-visit-ref’ behaves like ‘magit-show-commit’, in - all buffers, including ‘magit-refs-mode’ buffers. When the type of - the section at point is ‘commit’ then "RET" is bound to - ‘magit-show-commit’, and when the type is either ‘branch’ or ‘tag’ - then it is bound to ‘magit-visit-ref’. - - "RET" is one of Magit’s most essential keys and at least by default - it should behave consistently across all of Magit, especially - because users quickly learn that it does something very harmless; - it shows more information about the thing at point in another - buffer. - - However "RET" used to behave differently in ‘magit-refs-mode’ - buffers, doing surprising things, some of which cannot really be - described as "visit this thing". If you’ve grown accustomed this - behavior, you can restore it by adding one or more of the below - symbols to the value of this option. But keep in mind that by - doing so you don’t only introduce inconsistencies, you also lose - some functionality and might have to resort to ‘M-x - magit-show-commit’ to get it back. - - ‘magit-visit-ref’ looks for these symbols in the order in which - they are described here. If the presence of a symbol applies to - the current situation, then the symbols that follow do not affect - the outcome. - - • ‘focus-on-ref’ - - With a prefix argument update the buffer to show commit counts - and lists of cherry commits relative to the reference at point - instead of relative to the current buffer or ‘HEAD’. - - Instead of adding this symbol, consider pressing "C-u y o - RET". - - • ‘create-branch’ - - If point is on a remote branch, then create a new local branch - with the same name, use the remote branch as its upstream, and - then check out the local branch. - - Instead of adding this symbol, consider pressing "b c RET - RET", like you would do in other buffers. - - • ‘checkout-any’ - - Check out the reference at point. If that reference is a tag - or a remote branch, then this results in a detached ‘HEAD’. - - Instead of adding this symbol, consider pressing "b b RET", - like you would do in other buffers. - - • ‘checkout-branch’ - - Check out the local branch at point. - - Instead of adding this symbol, consider pressing "b b RET", - like you would do in other buffers. - -* Menu: - -* References Sections:: - - -File: magit.info, Node: References Sections, Up: References Buffer - -5.6.1 References Sections -------------------------- - -The contents of references buffers is controlled using the hook -‘magit-refs-sections-hook’. See *note Section Hooks:: to learn about -such hooks and how to customize them. All of the below functions are -members of the default value. Note that it makes much less sense to -customize this hook than it does for the respective hook used for the -status buffer. - - -- User Option: magit-refs-sections-hook - Hook run to insert sections into a references buffer. - - -- Function: magit-insert-local-branches - Insert sections showing all local branches. - - -- Function: magit-insert-remote-branches - Insert sections showing all remote-tracking branches. - - -- Function: magit-insert-tags - Insert sections showing all tags. - - -File: magit.info, Node: Bisecting, Next: Visiting Files and Blobs, Prev: References Buffer, Up: Inspecting - -5.7 Bisecting -============= - -Also see *note (gitman)git-bisect::. - -‘B’ (‘magit-bisect’) - This transient prefix command binds the following suffix commands - and displays them in a temporary buffer until a suffix is invoked. - - When bisecting is not in progress, then the transient features the -following suffix commands. - -‘B B’ (‘magit-bisect-start’) - Start a bisect session. - - Bisecting a bug means to find the commit that introduced it. This - command starts such a bisect session by asking for a known good - commit and a known bad commit. If you’re bisecting a change that - isn’t a regression, you can select alternate terms that are - conceptually more fitting than "bad" and "good", but the infix - arguments to do so are disabled by default. - -‘B s’ (‘magit-bisect-run’) - Bisect automatically by running commands after each step. - - When bisecting in progress, then the transient instead features the -following suffix commands. - -‘B b’ (‘magit-bisect-bad’) - Mark the current commit as bad. Use this after you have asserted - that the commit does contain the bug in question. - -‘B g’ (‘magit-bisect-good’) - Mark the current commit as good. Use this after you have asserted - that the commit does not contain the bug in question. - -‘B m’ (‘magit-bisect-mark’) - Mark the current commit with one of the bisect terms. This command - provides an alternative to ‘magit-bisect-bad’ and - ‘magit-bisect-good’ and is useful when using terms other than "bad" - and "good". This suffix is disabled by default. - -‘B k’ (‘magit-bisect-skip’) - Skip the current commit. Use this if for some reason the current - commit is not a good one to test. This command lets Git choose a - different one. - -‘B r’ (‘magit-bisect-reset’) - After bisecting, cleanup bisection state and return to original - ‘HEAD’. - - By default the status buffer shows information about the ongoing -bisect session. - - -- User Option: magit-bisect-show-graph - This option controls whether a graph is displayed for the log of - commits that still have to be bisected. - - -File: magit.info, Node: Visiting Files and Blobs, Next: Blaming, Prev: Bisecting, Up: Inspecting - -5.8 Visiting Files and Blobs -============================ - -Magit provides several commands that visit a file or blob (the version -of a file that is stored in a certain commit). Actually it provides -several *groups* of such commands and the several *variants* within each -group. - - Also see *note Commands for Buffers Visiting Files::. - -* Menu: - -* General-Purpose Visit Commands:: -* Visiting Files and Blobs from a Diff:: - - -File: magit.info, Node: General-Purpose Visit Commands, Next: Visiting Files and Blobs from a Diff, Up: Visiting Files and Blobs - -5.8.1 General-Purpose Visit Commands ------------------------------------- - -These commands can be used anywhere to open any blob. Currently no keys -are bound to these commands by default, but that is likely to change. - - -- Command: magit-find-file - This command reads a filename and revision from the user and visits - the respective blob in a buffer. The buffer is displayed in the - selected window. - - -- Command: magit-find-file-other-window - This command reads a filename and revision from the user and visits - the respective blob in a buffer. The buffer is displayed in - another window. - - -- Command: magit-find-file-other-frame - This command reads a filename and revision from the user and visits - the respective blob in a buffer. The buffer is displayed in - another frame. - - -File: magit.info, Node: Visiting Files and Blobs from a Diff, Prev: General-Purpose Visit Commands, Up: Visiting Files and Blobs - -5.8.2 Visiting Files and Blobs from a Diff ------------------------------------------- - -These commands can only be used when point is inside a diff. - -‘<RET>’ (‘magit-diff-visit-file’) - This command visits the appropriate version of the file that the - diff at point is about. - - This commands visits the worktree version of the appropriate file. - The location of point inside the diff determines which file is - being visited. The visited version depends on what changes the - diff is about. - - 1. If the diff shows uncommitted changes (i.e., staged or - unstaged changes), then visit the file in the working tree - (i.e., the same "real" file that ‘find-file’ would visit. In - all other cases visit a "blob" (i.e., the version of a file as - stored in some commit). - - 2. If point is on a removed line, then visit the blob for the - first parent of the commit that removed that line, i.e., the - last commit where that line still exists. - - 3. If point is on an added or context line, then visit the blob - that adds that line, or if the diff shows from more than a - single commit, then visit the blob from the last of these - commits. - - In the file-visiting buffer this command goes to the line that - corresponds to the line that point is on in the diff. - - The buffer is displayed in the selected window. With a prefix - argument the buffer is displayed in another window instead. - - -- User Option: magit-diff-visit-previous-blob - This option controls whether ‘magit-diff-visit-file’ may visit the - previous blob. When this is ‘t’ (the default) and point is on a - removed line in a diff for a committed change, then - ‘magit-diff-visit-file’ visits the blob from the last revision - which still had that line. - - Currently this is only supported for committed changes, for staged - and unstaged changes ‘magit-diff-visit-file’ always visits the file - in the working tree. - -‘C-<return>’ (‘magit-diff-visit-file-worktree’) - This command visits the worktree version of the appropriate file. - The location of point inside the diff determines which file is - being visited. Unlike ‘magit-diff-visit-file’ it always visits the - "real" file in the working tree, i.e the "current version" of the - file. - - In the file-visiting buffer this command goes to the line that - corresponds to the line that point is on in the diff. Lines that - were added or removed in the working tree, the index and other - commits in between are automatically accounted for. - - The buffer is displayed in the selected window. With a prefix - argument the buffer is displayed in another window instead. - - Variants of the above two commands exist that instead visit the file -in another window or in another frame. If you prefer such behavior, -then you may want to change the above key bindings, but note that the -above commands also use another window when invoked with a prefix -argument. - - -- Command: magit-diff-visit-file-other-window - -- Command: magit-diff-visit-file-other-frame - -- Command: magit-diff-visit-worktree-file-other-window - -- Command: magit-diff-visit-worktree-file-other-frame - - -File: magit.info, Node: Blaming, Prev: Visiting Files and Blobs, Up: Inspecting - -5.9 Blaming -=========== - -Also see *note (gitman)git-blame::. - - To start blaming, invoke the ‘magit-file-dispatch’ transient prefix -command. When using the default key bindings, that can be done by -pressing ‘C-c M-g’. When using the recommended bindings, this command -is instead bound to ‘C-c f’. Also see *note Global Bindings::. - - The blaming suffix commands can be invoked directly from the file -dispatch transient. However if you want to set an infix argument, then -you have to enter the blaming sub-prefix first. - -‘C-c f B’ (‘magit-blame’) -‘C-c f b’ (‘magit-blame-addition’) -‘C-c f B b’ -‘C-c f r’ (‘magit-blame-removal’) -‘C-c f B r’ -‘C-c f f’ (‘magit-blame-reverse’) -‘C-c f B f’ -‘C-c f e’ (‘magit-blame-echo’) -‘C-c f B e’ -‘C-c f q’ (‘magit-blame-quit’) -‘C-c f B q’ - Each of these commands is documented individually right below, - alongside their default key bindings. The bindings shown above are - the recommended bindings, which you can enable by following the - instructions in *note Global Bindings::. - -‘C-c M-g B’ (‘magit-blame’) - This transient prefix command binds the following suffix commands - along with the appropriate infix arguments and displays them in a - temporary buffer until a suffix is invoked. - - Note that not all of the following suffixes are available at all -times. For example if ‘magit-blame-mode’ is not enabled, then the -command whose purpose is to turn off that mode would not be of any use -and therefore isn’t available. - -‘C-c M-g b’ (‘magit-blame-addition’) -‘C-c M-g B b’ - This command augments each line or chunk of lines in the current - file-visiting or blob-visiting buffer with information about what - commits last touched these lines. - - If the buffer visits a revision of that file, then history up to - that revision is considered. Otherwise, the file’s full history is - considered, including uncommitted changes. - - If Magit-Blame mode is already turned on in the current buffer then - blaming is done recursively, by visiting REVISION:FILE (using - ‘magit-find-file’), where REVISION is a parent of the revision that - added the current line or chunk of lines. - -‘C-c M-g r’ (‘magit-blame-removal’) -‘C-c M-g B r’ - This command augments each line or chunk of lines in the current - blob-visiting buffer with information about the revision that - removes it. It cannot be used in file-visiting buffers. - - Like ‘magit-blame-addition’, this command can be used recursively. - -‘C-c M-g f’ (‘magit-blame-reverse’) -‘C-c M-g B f’ - This command augments each line or chunk of lines in the current - file-visiting or blob-visiting buffer with information about the - last revision in which a line still existed. - - Like ‘magit-blame-addition’, this command can be used recursively. - -‘C-c M-g e’ (‘magit-blame-echo’) -‘C-c M-g B e’ - This command is like ‘magit-blame-addition’ except that it doesn’t - turn on ‘read-only-mode’ and that it initially uses the - visualization style specified by option ‘magit-blame-echo-style’. - - The following key bindings are available when Magit-Blame mode is -enabled and Read-Only mode is not enabled. These commands are also -available in other buffers; here only the behavior is described that is -relevant in file-visiting buffers that are being blamed. - -‘C-c M-g q’ (‘magit-blame-quit’) -‘C-c M-g B q’ - This command turns off Magit-Blame mode. If the buffer was created - during a recursive blame, then it also kills the buffer. - -‘<RET>’ (‘magit-show-commit’) - This command shows the commit that last touched the line at point. - -‘<SPC>’ (‘magit-diff-show-or-scroll-up’) - This command updates the commit buffer. - - This either shows the commit that last touched the line at point in - the appropriate buffer, or if that buffer is already being - displayed in the current frame and if that buffer contains - information about that commit, then the buffer is scrolled up - instead. - -‘<DEL>’ (‘magit-diff-show-or-scroll-down’) - This command updates the commit buffer. - - This either shows the commit that last touched the line at point in - the appropriate buffer, or if that buffer is already being - displayed in the current frame and if that buffer contains - information about that commit, then the buffer is scrolled down - instead. - - The following key bindings are available when both Magit-Blame mode -and Read-Only mode are enabled. - -‘b’ (‘magit-blame’) - See above. - -‘n’ (‘magit-blame-next-chunk’) - This command moves to the next chunk. - -‘N’ (‘magit-blame-next-chunk-same-commit’) - This command moves to the next chunk from the same commit. - -‘p’ (‘magit-blame-previous-chunk’) - This command moves to the previous chunk. - -‘P’ (‘magit-blame-previous-chunk-same-commit’) - This command moves to the previous chunk from the same commit. - -‘q’ (‘magit-blame-quit’) - This command turns off Magit-Blame mode. If the buffer was created - during a recursive blame, then it also kills the buffer. - -‘M-w’ (‘magit-blame-copy-hash’) - This command saves the hash of the current chunk’s commit to the - kill ring. - - When the region is active, the command saves the region’s content - instead of the hash, like ‘kill-ring-save’ would. - -‘c’ (‘magit-blame-cycle-style’) - This command changes how blame information is visualized in the - current buffer by cycling through the styles specified using the - option ‘magit-blame-styles’. - - Blaming is also controlled using the following options. - - -- User Option: magit-blame-styles - This option defines a list of styles used to visualize blame - information. For now see its doc-string to learn more. - - -- User Option: magit-blame-echo-style - This option specifies the blame visualization style used by the - command ‘magit-blame-echo’. This must be a symbol that is used as - the identifier for one of the styles defined in - ‘magit-blame-styles’. - - -- User Option: magit-blame-time-format - This option specifies the format string used to display times when - showing blame information. - - -- User Option: magit-blame-read-only - This option controls whether blaming a buffer also makes - temporarily read-only. - - -- User Option: magit-blame-disable-modes - This option lists incompatible minor-modes that should be disabled - temporarily when a buffer contains blame information. They are - enabled again when the buffer no longer shows blame information. - - -- User Option: magit-blame-goto-chunk-hook - This hook is run when moving between chunks. - - -File: magit.info, Node: Manipulating, Next: Transferring, Prev: Inspecting, Up: Top - -6 Manipulating -************** - -* Menu: - -* Creating Repository:: -* Cloning Repository:: -* Staging and Unstaging:: -* Applying:: -* Committing:: -* Branching:: -* Merging:: -* Resolving Conflicts:: -* Rebasing:: -* Cherry Picking:: -* Resetting:: -* Stashing:: - - -File: magit.info, Node: Creating Repository, Next: Cloning Repository, Up: Manipulating - -6.1 Creating Repository -======================= - -‘I’ (‘magit-init’) - This command initializes a repository and then shows the status - buffer for the new repository. - - If the directory is below an existing repository, then the user has - to confirm that a new one should be created inside. If the - directory is the root of the existing repository, then the user has - to confirm that it should be reinitialized. - - -File: magit.info, Node: Cloning Repository, Next: Staging and Unstaging, Prev: Creating Repository, Up: Manipulating - -6.2 Cloning Repository -====================== - -To clone a remote or local repository use ‘C’, which is bound to the -command ‘magit-clone’. This command either act as a transient prefix -command, which binds several infix arguments and suffix commands, or it -can invoke ‘git clone’ directly, depending on whether a prefix argument -is used and on the value of ‘magit-clone-always-transient’. - - -- User Option: magit-clone-always-transient - This option controls whether the command ‘magit-clone’ always acts - as a transient prefix command, regardless of whether a prefix - argument is used or not. If ‘t’, then that command always acts as - a transient prefix. If ‘nil’, then a prefix argument has to be - used for it to act as a transient. - -‘C’ (‘magit-clone’) - This command either acts as a transient prefix command as described - above or does the same thing as ‘transient-clone-regular’ as - described below. - - If it acts as a transient prefix, then it binds the following - suffix commands and several infix arguments. - -‘C C’ (‘magit-clone-regular’) - This command creates a regular clone of an existing repository. - The repository and the target directory are read from the user. - -‘C s’ (‘magit-clone-shallow’) - This command creates a shallow clone of an existing repository. - The repository and the target directory are read from the user. By - default the depth of the cloned history is a single commit, but - with a prefix argument the depth is read from the user. - -‘C >’ (‘magit-clone-sparse’) - This command creates a clone of an existing repository and - initializes a sparse checkout, avoiding a checkout of the full - working tree. To add more directories, use the - ‘magit-sparse-checkout’ transient (see *note Sparse checkouts::). - -‘C b’ (‘magit-clone-bare’) - This command creates a bare clone of an existing repository. The - repository and the target directory are read from the user. - -‘C m’ (‘magit-clone-mirror’) - This command creates a mirror of an existing repository. The - repository and the target directory are read from the user. - - The following suffixes are disabled by default. See *note -(transient)Enabling and Disabling Suffixes:: for how to enable them. - -‘C d’ (‘magit-clone-shallow-since’) - This command creates a shallow clone of an existing repository. - Only commits that were committed after a date are cloned, which is - read from the user. The repository and the target directory are - also read from the user. - -‘C e’ (‘magit-clone-shallow-exclude’) - This command creates a shallow clone of an existing repository. - This reads a branch or tag from the user. Commits that are - reachable from that are not cloned. The repository and the target - directory are also read from the user. - - -- User Option: magit-clone-set-remote-head - This option controls whether cloning causes the reference - ‘refs/remotes/<remote>/HEAD’ to be created in the clone. The - default is to delete the reference after running ‘git clone’, which - insists on creating it. This is because the reference has not been - found to be particularly useful as it is not automatically updated - when the ‘HEAD’ of the remote changes. Setting this option to ‘t’ - preserves Git’s default behavior of creating the reference. - - -- User Option: magit-clone-set-remote.pushDefault - This option controls whether the value of the Git variable - ‘remote.pushDefault’ is set after cloning. - - • If ‘t’, then it is always set without asking. - • If ‘ask’, then the users are asked every time they clone a - repository. - • If ‘nil’, then it is never set. - - -- User Option: magit-clone-default-directory - This option control the default directory name used when reading - the destination for a cloning operation. - - • If ‘nil’ (the default), then the value of ‘default-directory’ - is used. - • If a directory, then that is used. - • If a function, then that is called with the remote url as the - only argument and the returned value is used. - - -- User Option: magit-clone-name-alist - This option maps regular expressions, which match repository names, - to repository urls, making it possible for users to enter short - names instead of urls when cloning repositories. - - Each element has the form ‘(REGEXP HOSTNAME USER)’. When the user - enters a name when a cloning command asks for a name or url, then - that is looked up in this list. The first element whose REGEXP - matches is used. - - The format specified by option ‘magit-clone-url-format’ is used to - turn the name into an url, using HOSTNAME and the repository name. - If the provided name contains a slash, then that is used. - Otherwise if the name omits the owner of the repository, then the - default user specified in the matched entry is used. - - If USER contains a dot, then it is treated as a Git variable and - the value of that is used as the username. Otherwise it is used as - the username itself. - - -- User Option: magit-clone-url-format - The format specified by this option is used when turning repository - names into urls. ‘%h’ is the hostname and ‘%n’ is the repository - name, including the name of the owner. The value can be a string - (representing a single static format) or an alist with elements - ‘(HOSTNAME . FORMAT)’ mapping hostnames to formats. When an alist - is used, the ‘t’ key represents the default format. - - Example of a single format string: - - (setq magit-clone-url-format - "git@%h:%n.git") - - Example of by-hostname format strings: - - (setq magit-clone-url-format - '(("git.example.com" . "git@%h:~%n") - (nil . "git@%h:%n.git"))) - - -- User Option: magit-post-clone-hook - Hook run after the Git process has successfully finished cloning - the repository. When the hook is called, ‘default-directory’ is - let-bound to the directory where the repository has been cloned. - - -File: magit.info, Node: Staging and Unstaging, Next: Applying, Prev: Cloning Repository, Up: Manipulating - -6.3 Staging and Unstaging -========================= - -Like Git, Magit can of course stage and unstage complete files. Unlike -Git, it also allows users to gracefully un-/stage individual hunks and -even just part of a hunk. To stage individual hunks and parts of hunks -using Git directly, one has to use the very modal and rather clumsy -interface of a ‘git add --interactive’ session. - - With Magit, on the other hand, one can un-/stage individual hunks by -just moving point into the respective section inside a diff displayed in -the status buffer or a separate diff buffer and typing ‘s’ or ‘u’. To -operate on just parts of a hunk, mark the changes that should be -un-/staged using the region and then press the same key that would be -used to un-/stage. To stage multiple files or hunks at once use a -region that starts inside the heading of such a section and ends inside -the heading of a sibling section of the same type. - - Besides staging and unstaging, Magit also provides several other -"apply variants" that can also operate on a file, multiple files at -once, a hunk, multiple hunks at once, and on parts of a hunk. These -apply variants are described in the next section. - - You can also use Ediff to stage and unstage. See *note Ediffing::. - -‘s’ (‘magit-stage’) - Add the change at point to the staging area. - - With a prefix argument and an untracked file (or files) at point, - stage the file but not its content. This makes it possible to - stage only a subset of the new file’s changes. - -‘S’ (‘magit-stage-modified’) - Stage all changes to files modified in the worktree. Stage all new - content of tracked files and remove tracked files that no longer - exist in the working tree from the index also. With a prefix - argument also stage previously untracked (but not ignored) files. - -‘u’ (‘magit-unstage’) - Remove the change at point from the staging area. - - Only staged changes can be unstaged. But by default this command - performs an action that is somewhat similar to unstaging, when it - is called on a committed change: it reverses the change in the - index but not in the working tree. - -‘U’ (‘magit-unstage-all’) - Remove all changes from the staging area. - - -- User Option: magit-unstage-committed - This option controls whether ‘magit-unstage’ "unstages" committed - changes by reversing them in the index but not the working tree. - The alternative is to raise an error. - -‘M-x magit-reverse-in-index’ - This command reverses the committed change at point in the index - but not the working tree. By default no key is bound directly to - this command, but it is indirectly called when ‘u’ - (‘magit-unstage’) is pressed on a committed change. - - This allows extracting a change from ‘HEAD’, while leaving it in - the working tree, so that it can later be committed using a - separate commit. A typical workflow would be: - - 1. Optionally make sure that there are no uncommitted changes. - 2. Visit the ‘HEAD’ commit and navigate to the change that should - not have been included in that commit. - 3. Type ‘u’ (‘magit-unstage’) to reverse it in the index. This - assumes that ‘magit-unstage-committed-changes’ is non-nil. - 4. Type ‘c e’ to extend ‘HEAD’ with the staged changes, including - those that were already staged before. - 5. Optionally stage the remaining changes using ‘s’ or ‘S’ and - then type ‘c c’ to create a new commit. - -‘M-x magit-reset-index’ - Reset the index to some commit. The commit is read from the user - and defaults to the commit at point. If there is no commit at - point, then it defaults to ‘HEAD’. - -* Menu: - -* Staging from File-Visiting Buffers:: - - -File: magit.info, Node: Staging from File-Visiting Buffers, Up: Staging and Unstaging - -6.3.1 Staging from File-Visiting Buffers ----------------------------------------- - -Fine-grained un-/staging has to be done from the status or a diff -buffer, but it’s also possible to un-/stage all changes made to the file -visited in the current buffer right from inside that buffer. - -‘M-x magit-stage-file’ - When invoked inside a file-visiting buffer, then stage all changes - to that file. In a Magit buffer, stage the file at point if any. - Otherwise prompt for a file to be staged. With a prefix argument - always prompt the user for a file, even in a file-visiting buffer - or when there is a file section at point. - -‘M-x magit-unstage-file’ - When invoked inside a file-visiting buffer, then unstage all - changes to that file. In a Magit buffer, unstage the file at point - if any. Otherwise prompt for a file to be unstaged. With a prefix - argument always prompt the user for a file, even in a file-visiting - buffer or when there is a file section at point. - - -File: magit.info, Node: Applying, Next: Committing, Prev: Staging and Unstaging, Up: Manipulating - -6.4 Applying -============ - -Magit provides several "apply variants": stage, unstage, discard, -reverse, and "regular apply". At least when operating on a hunk they -are all implemented using ‘git apply’, which is why they are called -"apply variants". - - • Stage. Apply a change from the working tree to the index. The - change also remains in the working tree. - - • Unstage. Remove a change from the index. The change remains in - the working tree. - - • Discard. On a staged change, remove it from the working tree and - the index. On an unstaged change, remove it from the working tree - only. - - • Reverse. Reverse a change in the working tree. Both committed and - staged changes can be reversed. Unstaged changes cannot be - reversed. Discard them instead. - - • Apply. Apply a change to the working tree. Both committed and - staged changes can be applied. Unstaged changes cannot be applied - - as they already have been applied. - - The previous section described the staging and unstaging commands. -What follows are the commands which implement the remaining apply -variants. - -‘a’ (‘magit-apply’) - Apply the change at point to the working tree. - - With a prefix argument fallback to a 3-way merge. Doing so causes - the change to be applied to the index as well. - -‘k’ (‘magit-discard’) - Remove the change at point from the working tree. - - On a hunk or file with unresolved conflicts prompt which side to - keep (while discarding the other). If point is within the text of - a side, then keep that side without prompting. - -‘v’ (‘magit-reverse’) - Reverse the change at point in the working tree. - - With a prefix argument fallback to a 3-way merge. Doing so causes - the change to be applied to the index as well. - - With a prefix argument all apply variants attempt a 3-way merge when -appropriate (i.e., when ‘git apply’ is used internally). - - -File: magit.info, Node: Committing, Next: Branching, Prev: Applying, Up: Manipulating - -6.5 Committing -============== - -When the user initiates a commit, Magit calls ‘git commit’ without any -arguments, so Git has to get it from the user. It creates the file -‘.git/COMMIT_EDITMSG’ and then opens that file in an editor. Magit -arranges for that editor to be the Emacsclient. Once the user finishes -the editing session, the Emacsclient exits and Git creates the commit -using the file’s content as message. - -* Menu: - -* Initiating a Commit:: -* Editing Commit Messages:: - - -File: magit.info, Node: Initiating a Commit, Next: Editing Commit Messages, Up: Committing - -6.5.1 Initiating a Commit -------------------------- - -Also see *note (gitman)git-commit::. - -‘c’ (‘magit-commit’) - This transient prefix command binds the following suffix commands - along with the appropriate infix arguments and displays them in a - temporary buffer until a suffix is invoked. - -‘c c’ (‘magit-commit-create’) - Create a new commit on ‘HEAD’. With a prefix argument amend to the - commit at ‘HEAD’ instead. - -‘c a’ (‘magit-commit-amend’) - Amend the last commit. - -‘c e’ (‘magit-commit-extend’) - Amend the last commit, without editing the message. With a prefix - argument keep the committer date, otherwise change it. The option - ‘magit-commit-extend-override-date’ can be used to inverse the - meaning of the prefix argument. - - Non-interactively respect the optional OVERRIDE-DATE argument and - ignore the option. - -‘c w’ (‘magit-commit-reword’) - Reword the last commit, ignoring staged changes. With a prefix - argument keep the committer date, otherwise change it. The option - ‘magit-commit-reword-override-date’ can be used to inverse the - meaning of the prefix argument. - - Non-interactively respect the optional OVERRIDE-DATE argument and - ignore the option. - -‘c f’ (‘magit-commit-fixup’) - Create a fixup commit. - - With a prefix argument the target commit has to be confirmed. - Otherwise the commit at point may be used without confirmation - depending on the value of option ‘magit-commit-squash-confirm’. - -‘c F’ (‘magit-commit-instant-fixup’) - Create a fixup commit and instantly rebase. - -‘c s’ (‘magit-commit-squash’) - Create a squash commit, without editing the squash message. - - With a prefix argument the target commit has to be confirmed. - Otherwise the commit at point may be used without confirmation - depending on the value of option ‘magit-commit-squash-confirm’. - -‘c S’ (‘magit-commit-instant-squash’) - Create a squash commit and instantly rebase. - -‘c A’ (‘magit-commit-augment’) - Create a squash commit, editing the squash message. - - With a prefix argument the target commit has to be confirmed. - Otherwise the commit at point may be used without confirmation - depending on the value of option ‘magit-commit-squash-confirm’. - - -- User Option: magit-commit-ask-to-stage - Whether to ask to stage all unstaged changes when committing and - nothing is staged. - - -- User Option: magit-commit-show-diff - Whether the relevant diff is automatically shown when committing. - - -- User Option: magit-commit-extend-override-date - Whether using ‘magit-commit-extend’ changes the committer date. - - -- User Option: magit-commit-reword-override-date - Whether using ‘magit-commit-reword’ changes the committer date. - - -- User Option: magit-commit-squash-confirm - Whether the commit targeted by squash and fixup has to be - confirmed. When non-nil then the commit at point (if any) is used - as default choice. Otherwise it has to be confirmed. This option - only affects ‘magit-commit-squash’ and ‘magit-commit-fixup’. The - "instant" variants always require confirmation because making an - error while using those is harder to recover from. - - -- User Option: magit-post-commit-hook - Hook run after creating a commit without the user editing a - message. - - This hook is run by ‘magit-refresh’ if ‘this-command’ is a member - of ‘magit-post-commit-hook-commands’. This only includes commands - named ‘magit-commit-*’ that do *not* require that the user edits - the commit message in a buffer. - - Also see ‘git-commit-post-finish-hook’. - - -- User Option: magit-commit-diff-inhibit-same-window - Whether to inhibit use of same window when showing diff while - committing. - - When writing a commit, then a diff of the changes to be committed - is automatically shown. The idea is that the diff is shown in a - different window of the same frame and for most users that just - works. In other words most users can completely ignore this option - because its value doesn’t make a difference for them. - - However for users who configured Emacs to never create a new window - even when the package explicitly tries to do so, then displaying - two new buffers necessarily means that the first is immediately - replaced by the second. In our case the message buffer is - immediately replaced by the diff buffer, which is of course highly - undesirable. - - A workaround is to suppress this user configuration in this - particular case. Users have to explicitly opt-in by toggling this - option. We cannot enable the workaround unconditionally because - that again causes issues for other users: if the frame is too tiny - or the relevant settings too aggressive, then the diff buffer would - end up being displayed in a new frame. - - Also see <https://github.com/magit/magit/issues/4132>. - - -File: magit.info, Node: Editing Commit Messages, Prev: Initiating a Commit, Up: Committing - -6.5.2 Editing Commit Messages ------------------------------ - -After initiating a commit as described in the previous section, two new -buffers appear. One shows the changes that are about to be committed, -while the other is used to write the message. - - Commit messages are edited in an edit session - in the background -‘git’ is waiting for the editor, in our case ‘emacsclient’, to save the -commit message in a file (in most cases ‘.git/COMMIT_EDITMSG’) and then -return. If the editor returns with a non-zero exit status then ‘git’ -does not create the commit. So the most important commands are those -for finishing and aborting the commit. - -‘C-c C-c’ (‘with-editor-finish’) - Finish the current editing session by returning with exit code 0. - Git then creates the commit using the message it finds in the file. - -‘C-c C-k’ (‘with-editor-cancel’) - Cancel the current editing session by returning with exit code 1. - Git then cancels the commit, but leaves the file untouched. - - In addition to being used by ‘git commit’, messages may also be -stored in a ring that persists until Emacs is closed. By default the -message is stored at the beginning and the end of an edit session -(regardless of whether the session is finished successfully or was -canceled). It is sometimes useful to bring back messages from that -ring. - -‘C-c M-s’ (‘git-commit-save-message’) - Save the current buffer content to the commit message ring. - -‘M-p’ (‘git-commit-prev-message’) - Cycle backward through the commit message ring, after saving the - current message to the ring. With a numeric prefix ARG, go back - ARG comments. - -‘M-n’ (‘git-commit-next-message’) - Cycle forward through the commit message ring, after saving the - current message to the ring. With a numeric prefix ARG, go back - ARG comments. - - By default the diff for the changes that are about to be committed -are automatically shown when invoking the commit. To prevent that, -remove ‘magit-commit-diff’ from ‘server-switch-hook’. - - When amending to an existing commit it may be useful to show either -the changes that are about to be added to that commit or to show those -changes alongside those that have already been committed. - -‘C-c C-d’ (‘magit-diff-while-committing’) - While committing, show the changes that are about to be committed. - While amending, invoking the command again toggles between showing - just the new changes or all the changes that will be committed. - -* Menu: - -* Using the Revision Stack:: -* Commit Pseudo Headers:: -* Commit Mode and Hooks:: -* Commit Message Conventions:: - - -File: magit.info, Node: Using the Revision Stack, Next: Commit Pseudo Headers, Up: Editing Commit Messages - -Using the Revision Stack -........................ - -‘C-c C-w’ (‘magit-pop-revision-stack’) - This command inserts a representation of a revision into the - current buffer. It can be used inside buffers used to write commit - messages but also in other buffers such as buffers used to edit - emails or ChangeLog files. - - By default this command pops the revision which was last added to - the ‘magit-revision-stack’ and inserts it into the current buffer - according to ‘magit-pop-revision-stack-format’. Revisions can be - put on the stack using ‘magit-copy-section-value’ and - ‘magit-copy-buffer-revision’. - - If the stack is empty or with a prefix argument it instead reads a - revision in the minibuffer. By using the minibuffer history this - allows selecting an item which was popped earlier or to insert an - arbitrary reference or revision without first pushing it onto the - stack. - - When reading the revision from the minibuffer, then it might not be - possible to guess the correct repository. When this command is - called inside a repository (e.g., while composing a commit - message), then that repository is used. Otherwise (e.g., while - composing an email) then the repository recorded for the top - element of the stack is used (even though we insert another - revision). If not called inside a repository and with an empty - stack, or with two prefix arguments, then read the repository in - the minibuffer too. - - -- User Option: magit-pop-revision-stack-format - This option controls how the command ‘magit-pop-revision-stack’ - inserts a revision into the current buffer. - - The entries on the stack have the format ‘(HASH TOPLEVEL)’ and this - option has the format ‘(POINT-FORMAT EOB-FORMAT INDEX-REGEXP)’, all - of which may be nil or a string (though either one of EOB-FORMAT or - POINT-FORMAT should be a string, and if INDEX-REGEXP is non-nil, - then the two formats should be too). - - First INDEX-REGEXP is used to find the previously inserted entry, - by searching backward from point. The first submatch must match - the index number. That number is incremented by one, and becomes - the index number of the entry to be inserted. If you don’t want to - number the inserted revisions, then use nil for INDEX-REGEXP. - - If INDEX-REGEXP is non-nil then both POINT-FORMAT and EOB-FORMAT - should contain \"%N\", which is replaced with the number that was - determined in the previous step. - - Both formats, if non-nil and after removing %N, are then expanded - using ‘git show --format=FORMAT ...’ inside TOPLEVEL. - - The expansion of POINT-FORMAT is inserted at point, and the - expansion of EOB-FORMAT is inserted at the end of the buffer (if - the buffer ends with a comment, then it is inserted right before - that). - - -File: magit.info, Node: Commit Pseudo Headers, Next: Commit Mode and Hooks, Prev: Using the Revision Stack, Up: Editing Commit Messages - -Commit Pseudo Headers -..................... - -Some projects use pseudo headers in commit messages. Magit colorizes -such headers and provides some commands to insert such headers. - - -- User Option: git-commit-known-pseudo-headers - A list of Git pseudo headers to be highlighted. - -‘C-c C-i’ (‘git-commit-insert-pseudo-header’) - Insert a commit message pseudo header. - -‘C-c C-a’ (‘git-commit-ack’) - Insert a header acknowledging that you have looked at the commit. - -‘C-c C-r’ (‘git-commit-review’) - Insert a header acknowledging that you have reviewed the commit. - -‘C-c C-s’ (‘git-commit-signoff’) - Insert a header to sign off the commit. - -‘C-c C-t’ (‘git-commit-test’) - Insert a header acknowledging that you have tested the commit. - -‘C-c C-o’ (‘git-commit-cc’) - Insert a header mentioning someone who might be interested. - -‘C-c C-p’ (‘git-commit-reported’) - Insert a header mentioning the person who reported the issue being - fixed by the commit. - -‘C-c M-i’ (‘git-commit-suggested’) - Insert a header mentioning the person who suggested the change. - - -File: magit.info, Node: Commit Mode and Hooks, Next: Commit Message Conventions, Prev: Commit Pseudo Headers, Up: Editing Commit Messages - -Commit Mode and Hooks -..................... - -‘git-commit-mode’ is a minor mode that is only used to establish certain -key bindings. This makes it possible to use an arbitrary major mode in -buffers used to edit commit messages. It is even possible to use -different major modes in different repositories, which is useful when -different projects impose different commit message conventions. - - -- User Option: git-commit-major-mode - The value of this option is the major mode used to edit Git commit - messages. - - Because ‘git-commit-mode’ is a minor mode, we don’t use its mode hook -to setup the buffer, except for the key bindings. All other setup -happens in the function ‘git-commit-setup’, which among other things -runs the hook ‘git-commit-setup-hook’. - - -- User Option: git-commit-setup-hook - Hook run at the end of ‘git-commit-setup’. - -The following functions are suitable for this hook: - - -- Function: git-commit-save-message - Save the current buffer content to the commit message ring. - - -- Function: git-commit-setup-changelog-support - After this function is called, ChangeLog entries are treated as - paragraphs. - - -- Function: git-commit-turn-on-auto-fill - Turn on ‘auto-fill-mode’. - - -- Function: git-commit-turn-on-flyspell - Turn on Flyspell mode. Also prevent comments from being checked - and finally check current non-comment text. - - -- Function: git-commit-propertize-diff - Propertize the diff shown inside the commit message buffer. Git - inserts such diffs into the commit message template when the - ‘--verbose’ argument is used. ‘magit-commit’ by default does not - offer that argument because the diff that is shown in a separate - buffer is more useful. But some users disagree, which is why this - function exists. - - -- Function: bug-reference-mode - Hyperlink bug references in the buffer. - - -- Function: with-editor-usage-message - Show usage information in the echo area. - - -- User Option: git-commit-post-finish-hook - Hook run after the user finished writing a commit message. - - This hook is only run after pressing ‘C-c C-c’ in a buffer used to - edit a commit message. If a commit is created without the user - typing a message into a buffer, then this hook is not run. - - This hook is not run until the new commit has been created. If - doing so takes Git longer than one second, then this hook isn’t run - at all. For certain commands such as ‘magit-rebase-continue’ this - hook is never run because doing so would lead to a race condition. - - This hook is only run if ‘magit’ is available. - - Also see ‘magit-post-commit-hook’. - - -File: magit.info, Node: Commit Message Conventions, Prev: Commit Mode and Hooks, Up: Editing Commit Messages - -Commit Message Conventions -.......................... - -Git-Commit highlights certain violations of commonly accepted commit -message conventions. Certain violations even cause Git-Commit to ask -you to confirm that you really want to do that. This nagging can of -course be turned off, but the result of doing that usually is that -instead of some code it’s now the human who is reviewing your commits -who has to waste some time telling you to fix your commits. - - -- User Option: git-commit-summary-max-length - The intended maximal length of the summary line of commit messages. - Characters beyond this column are colorized to indicate that this - preference has been violated. - - -- User Option: git-commit-finish-query-functions - List of functions called to query before performing commit. - - The commit message buffer is current while the functions are - called. If any of them returns nil, then the commit is not - performed and the buffer is not killed. The user should then fix - the issue and try again. - - The functions are called with one argument. If it is non-nil then - that indicates that the user used a prefix argument to force - finishing the session despite issues. Functions should usually - honor this wish and return non-nil. - - By default the only member is ‘git-commit-check-style-conventions’. - - -- Function: git-commit-check-style-conventions - This function checks for violations of certain basic style - conventions. For each violation it asks users if they want to - proceed anyway. - - -- User Option: git-commit-style-convention-checks - This option controls what conventions the function by the same name - tries to enforce. The value is a list of self-explanatory symbols - identifying certain conventions; ‘non-empty-second-line’ and - ‘overlong-summary-line’. - - -File: magit.info, Node: Branching, Next: Merging, Prev: Committing, Up: Manipulating - -6.6 Branching -============= - -* Menu: - -* The Two Remotes:: -* Branch Commands:: -* Branch Git Variables:: -* Auxiliary Branch Commands:: - - -File: magit.info, Node: The Two Remotes, Next: Branch Commands, Up: Branching - -6.6.1 The Two Remotes ---------------------- - -The upstream branch of some local branch is the branch into which the -commits on that local branch should eventually be merged, usually -something like ‘origin/master’. For the ‘master’ branch itself the -upstream branch and the branch it is being pushed to, are usually the -same remote branch. But for a feature branch the upstream branch and -the branch it is being pushed to should differ. - - The commits on feature branches too should _eventually_ end up in a -remote branch such as ‘origin/master’ or ‘origin/maint’. Such a branch -should therefore be used as the upstream. But feature branches -shouldn’t be pushed directly to such branches. Instead a feature branch -‘my-feature’ is usually pushed to ‘my-fork/my-feature’ or if you are a -contributor ‘origin/my-feature’. After the new feature has been -reviewed, the maintainer merges the feature into ‘master’. And finally -‘master’ (not ‘my-feature’ itself) is pushed to ‘origin/master’. - - But new features seldom are perfect on the first try, and so feature -branches usually have to be reviewed, improved, and re-pushed several -times. Pushing should therefore be easy to do, and for that reason many -Git users have concluded that it is best to use the remote branch to -which the local feature branch is being pushed as its upstream. - - But luckily Git has long ago gained support for a push-remote which -can be configured separately from the upstream branch, using the -variables ‘branch.<name>.pushRemote’ and ‘remote.pushDefault’. So we no -longer have to choose which of the two remotes should be used as "the -remote". - - Each of the fetching, pulling, and pushing transient commands -features three suffix commands that act on the current branch and some -other branch. Of these, ‘p’ is bound to a command which acts on the -push-remote, ‘u’ is bound to a command which acts on the upstream, and -‘e’ is bound to a command which acts on any other branch. The status -buffer shows unpushed and unpulled commits for both the push-remote and -the upstream. - - It’s fairly simple to configure these two remotes. The values of all -the variables that are related to fetching, pulling, and pushing (as -well as some other branch-related variables) can be inspected and -changed using the command ‘magit-branch-configure’, which is available -from many transient prefix commands that deal with branches. It is also -possible to set the push-remote or upstream while pushing (see *note -Pushing::). - - -File: magit.info, Node: Branch Commands, Next: Branch Git Variables, Prev: The Two Remotes, Up: Branching - -6.6.2 Branch Commands ---------------------- - -The transient prefix command ‘magit-branch’ is used to create and -checkout branches, and to make changes to existing branches. It is not -used to fetch, pull, merge, rebase, or push branches, i.e., this command -deals with branches themselves, not with the commits reachable from -them. Those features are available from separate transient command. - -‘b’ (‘magit-branch’) - This transient prefix command binds the following suffix commands - and displays them in a temporary buffer until a suffix is invoked. - - By default it also binds and displays the values of some - branch-related Git variables and allows changing their values. - - -- User Option: magit-branch-direct-configure - This option controls whether the transient command ‘magit-branch’ - can be used to directly change the values of Git variables. This - defaults to ‘t’ (to avoid changing key bindings). When set to - ‘nil’, then no variables are displayed by that transient command, - and its suffix command ‘magit-branch-configure’ has to be used - instead to view and change branch related variables. - -‘b C’ (‘magit-branch-configure’) -‘f C’ -‘F C’ -‘P C’ - This transient prefix command binds commands that set the value of - branch-related variables and displays them in a temporary buffer - until the transient is exited. - - With a prefix argument, this command always prompts for a branch. - - Without a prefix argument this depends on whether it was invoked as - a suffix of ‘magit-branch’ and on the - ‘magit-branch-direct-configure’ option. If ‘magit-branch’ already - displays the variables for the current branch, then it isn’t useful - to invoke another transient that displays them for the same branch. - In that case this command prompts for a branch. - - The variables are described in *note Branch Git Variables::. - -‘b b’ (‘magit-checkout’) - Checkout a revision read in the minibuffer and defaulting to the - branch or arbitrary revision at point. If the revision is a local - branch then that becomes the current branch. If it is something - else then ‘HEAD’ becomes detached. Checkout fails if the working - tree or the staging area contain changes. - -‘b n’ (‘magit-branch-create’) - Create a new branch. The user is asked for a branch or arbitrary - revision to use as the starting point of the new branch. When a - branch name is provided, then that becomes the upstream branch of - the new branch. The name of the new branch is also read in the - minibuffer. - - Also see option ‘magit-branch-prefer-remote-upstream’. - -‘b c’ (‘magit-branch-and-checkout’) - This command creates a new branch like ‘magit-branch-create’, but - then also checks it out. - - Also see option ‘magit-branch-prefer-remote-upstream’. - -‘b l’ (‘magit-branch-checkout’) - This command checks out an existing or new local branch. It reads - a branch name from the user offering all local branches and a - subset of remote branches as candidates. Remote branches for which - a local branch by the same name exists are omitted from the list of - candidates. The user can also enter a completely new branch name. - - • If the user selects an existing local branch, then that is - checked out. - - • If the user selects a remote branch, then it creates and - checks out a new local branch with the same name, and - configures the selected remote branch as the push target. - - • If the user enters a new branch name, then it creates and - checks that out, after also reading the starting-point from - the user. - - In the latter two cases the upstream is also set. Whether it is - set to the chosen starting point or something else depends on the - value of ‘magit-branch-adjust-remote-upstream-alist’. - -‘b s’ (‘magit-branch-spinoff’) - This command creates and checks out a new branch starting at and - tracking the current branch. That branch in turn is reset to the - last commit it shares with its upstream. If the current branch has - no upstream or no unpushed commits, then the new branch is created - anyway and the previously current branch is not touched. - - This is useful to create a feature branch after work has already - began on the old branch (likely but not necessarily "master"). - - If the current branch is a member of the value of option - ‘magit-branch-prefer-remote-upstream’ (which see), then the current - branch will be used as the starting point as usual, but the - upstream of the starting-point may be used as the upstream of the - new branch, instead of the starting-point itself. - - If optional FROM is non-nil, then the source branch is reset to - ‘FROM~’, instead of to the last commit it shares with its upstream. - Interactively, FROM is only ever non-nil, if the region selects - some commits, and among those commits, FROM is the commit that is - the fewest commits ahead of the source branch. - - The commit at the other end of the selection actually does not - matter, all commits between FROM and ‘HEAD’ are moved to the new - branch. If FROM is not reachable from ‘HEAD’ or is reachable from - the source branch’s upstream, then an error is raised. - -‘b S’ (‘magit-branch-spinout’) - This command behaves like ‘magit-branch-spinoff’, except that it - does not change the current branch. If there are any uncommitted - changes, then it behaves exactly like ‘magit-branch-spinoff’. - -‘b x’ (‘magit-branch-reset’) - This command resets a branch, defaulting to the branch at point, to - the tip of another branch or any other commit. - - When the branch being reset is the current branch, then a hard - reset is performed. If there are any uncommitted changes, then the - user has to confirm the reset because those changes would be lost. - - This is useful when you have started work on a feature branch but - realize it’s all crap and want to start over. - - When resetting to another branch and a prefix argument is used, - then the target branch is set as the upstream of the branch that is - being reset. - -‘b k’ (‘magit-branch-delete’) - Delete one or multiple branches. If the region marks multiple - branches, then offer to delete those. Otherwise, prompt for a - single branch to be deleted, defaulting to the branch at point. - - Require confirmation when deleting branches is dangerous in some - way. Option ‘magit-no-confirm’ can be customized to not require - confirmation in certain cases. See its docstring to learn why - confirmation is required by default in certain cases or if a prompt - is confusing. - -‘b m’ (‘magit-branch-rename’) - Rename a branch. The branch and the new name are read in the - minibuffer. With prefix argument the branch is renamed even if - that name conflicts with an existing branch. - - -- User Option: magit-branch-read-upstream-first - When creating a branch, whether to read the upstream branch before - the name of the branch that is to be created. The default is ‘t’, - and I recommend you leave it at that. - - -- User Option: magit-branch-prefer-remote-upstream - This option specifies whether remote upstreams are favored over - local upstreams when creating new branches. - - When a new branch is created, then the branch, commit, or stash at - point is suggested as the starting point of the new branch, or if - there is no such revision at point the current branch. In either - case the user may choose another starting point. - - If the chosen starting point is a branch, then it may also be set - as the upstream of the new branch, depending on the value of the - Git variable ‘branch.autoSetupMerge’. By default this is done for - remote branches, but not for local branches. - - You might prefer to always use some remote branch as upstream. If - the chosen starting point is (1) a local branch, (2) whose name - matches a member of the value of this option, (3) the upstream of - that local branch is a remote branch with the same name, and (4) - that remote branch can be fast-forwarded to the local branch, then - the chosen branch is used as starting point, but its own upstream - is used as the upstream of the new branch. - - Members of this option’s value are treated as branch names that - have to match exactly unless they contain a character that makes - them invalid as a branch name. Recommended characters to use to - trigger interpretation as a regexp are "*" and "^". Some other - characters which you might expect to be invalid, actually are not, - e.g., ".+$" are all perfectly valid. More precisely, if ‘git - check-ref-format --branch STRING’ exits with a non-zero status, - then treat STRING as a regexp. - - Assuming the chosen branch matches these conditions you would end - up with with e.g.: - - feature --upstream--> origin/master - - instead of - - feature --upstream--> master --upstream--> origin/master - - Which you prefer is a matter of personal preference. If you do - prefer the former, then you should add branches such as ‘master’, - ‘next’, and ‘maint’ to the value of this options. - - -- User Option: magit-branch-adjust-remote-upstream-alist - The value of this option is an alist of branches to be used as the - upstream when branching a remote branch. - - When creating a local branch from an ephemeral branch located on a - remote, e.g., a feature or hotfix branch, then that remote branch - should usually not be used as the upstream branch, since the - push-remote already allows accessing it and having both the - upstream and the push-remote reference the same related branch - would be wasteful. Instead a branch like "maint" or "master" - should be used as the upstream. - - This option allows specifying the branch that should be used as the - upstream when branching certain remote branches. The value is an - alist of the form ‘((UPSTREAM . RULE)...)’. The first matching - element is used, the following elements are ignored. - - UPSTREAM is the branch to be used as the upstream for branches - specified by RULE. It can be a local or a remote branch. - - RULE can either be a regular expression, matching branches whose - upstream should be the one specified by UPSTREAM. Or it can be a - list of the only branches that should *not* use UPSTREAM; all other - branches will. Matching is done after stripping the remote part of - the name of the branch that is being branched from. - - If you use a finite set of non-ephemeral branches across all your - repositories, then you might use something like: - - (("origin/master" . ("master" "next" "maint"))) - - Or if the names of all your ephemeral branches contain a slash, at - least in some repositories, then a good value could be: - - (("origin/master" . "/")) - - Of course you can also fine-tune: - - (("origin/maint" . "\\`hotfix/") - ("origin/master" . "\\`feature/")) - - UPSTREAM can be a local branch: - - (("master" . ("master" "next" "maint"))) - - Because the main branch is no longer almost always named "master" you -should also account for other common names: - - (("main" . ("main" "master" "next" "maint")) - ("master" . ("main" "master" "next" "maint"))) - - -- Command: magit-branch-orphan - This command creates and checks out a new orphan branch with - contents from a given revision. - - -- Command: magit-branch-or-checkout - This command is a hybrid between ‘magit-checkout’ and - ‘magit-branch-and-checkout’ and is intended as a replacement for - the former in ‘magit-branch’. - - It first asks the user for an existing branch or revision. If the - user input actually can be resolved as a branch or revision, then - it checks that out, just like ‘magit-checkout’ would. - - Otherwise it creates and checks out a new branch using the input as - its name. Before doing so it reads the starting-point for the new - branch. This is similar to what ‘magit-branch-and-checkout’ does. - - To use this command instead of ‘magit-checkout’ add this to your - init file: - - (transient-replace-suffix 'magit-branch 'magit-checkout - '("b" "dwim" magit-branch-or-checkout)) - - -File: magit.info, Node: Branch Git Variables, Next: Auxiliary Branch Commands, Prev: Branch Commands, Up: Branching - -6.6.3 Branch Git Variables --------------------------- - -These variables can be set from the transient prefix command -‘magit-branch-configure’. By default they can also be set from -‘magit-branch’. See *note Branch Commands::. - - -- Variable: branch.NAME.merge - Together with ‘branch.NAME.remote’ this variable defines the - upstream branch of the local branch named NAME. The value of this - variable is the full reference of the upstream _branch_. - - -- Variable: branch.NAME.remote - Together with ‘branch.NAME.merge’ this variable defines the - upstream branch of the local branch named NAME. The value of this - variable is the name of the upstream _remote_. - - -- Variable: branch.NAME.rebase - This variable controls whether pulling into the branch named NAME - is done by rebasing or by merging the fetched branch. - - • When ‘true’ then pulling is done by rebasing. - • When ‘false’ then pulling is done by merging. - • When undefined then the value of ‘pull.rebase’ is used. The - default of that variable is ‘false’. - - -- Variable: branch.NAME.pushRemote - This variable specifies the remote that the branch named NAME is - usually pushed to. The value has to be the name of an existing - remote. - - It is not possible to specify the name of _branch_ to push the - local branch to. The name of the remote branch is always the same - as the name of the local branch. - - If this variable is undefined but ‘remote.pushDefault’ is defined, - then the value of the latter is used. By default - ‘remote.pushDefault’ is undefined. - - -- Variable: branch.NAME.description - This variable can be used to describe the branch named NAME. That - description is used, e.g., when turning the branch into a series of - patches. - - The following variables specify defaults which are used if the above -branch-specific variables are not set. - - -- Variable: pull.rebase - This variable specifies whether pulling is done by rebasing or by - merging. It can be overwritten using ‘branch.NAME.rebase’. - - • When ‘true’ then pulling is done by rebasing. - • When ‘false’ (the default) then pulling is done by merging. - - Since it is never a good idea to merge the upstream branch into a - feature or hotfix branch and most branches are such branches, you - should consider setting this to ‘true’, and ‘branch.master.rebase’ - to ‘false’. - - -- Variable: remote.pushDefault - This variable specifies what remote the local branches are usually - pushed to. This can be overwritten per branch using - ‘branch.NAME.pushRemote’. - - The following variables are used during the creation of a branch and -control whether the various branch-specific variables are automatically -set at this time. - - -- Variable: branch.autoSetupMerge - This variable specifies under what circumstances creating a branch - NAME should result in the variables ‘branch.NAME.merge’ and - ‘branch.NAME.remote’ being set according to the starting point used - to create the branch. If the starting point isn’t a branch, then - these variables are never set. - - • When ‘always’ then the variables are set regardless of whether - the starting point is a local or a remote branch. - • When ‘true’ (the default) then the variables are set when the - starting point is a remote branch, but not when it is a local - branch. - • When ‘false’ then the variables are never set. - - -- Variable: branch.autoSetupRebase - This variable specifies whether creating a branch NAME should - result in the variable ‘branch.NAME.rebase’ being set to ‘true’. - - • When ‘always’ then the variable is set regardless of whether - the starting point is a local or a remote branch. - • When ‘local’ then the variable are set when the starting point - is a local branch, but not when it is a remote branch. - • When ‘remote’ then the variable are set when the starting - point is a remote branch, but not when it is a local branch. - • When ‘never’ (the default) then the variable is never set. - - Note that the respective commands always change the repository-local -values. If you want to change the global value, which is used when the -local value is undefined, then you have to do so on the command line, -e.g.: - - git config --global remote.autoSetupMerge always - - For more information about these variables you should also see - - *note (gitman)git-config::. Also see *note (gitman)git-branch::. , -*note (gitman)git-checkout::. and *note Pushing::. - - -- User Option: magit-prefer-remote-upstream - This option controls whether commands that read a branch from the - user and then set it as the upstream branch, offer a local or a - remote branch as default completion candidate, when they have the - choice. - - This affects all commands that use ‘magit-read-upstream-branch’ or - ‘magit-read-starting-point’, which includes all commands that - change the upstream and many which create new branches. - - -File: magit.info, Node: Auxiliary Branch Commands, Prev: Branch Git Variables, Up: Branching - -6.6.4 Auxiliary Branch Commands -------------------------------- - -These commands are not available from the transient ‘magit-branch’ by -default. - - -- Command: magit-branch-shelve - This command shelves a branch. This is done by deleting the - branch, and creating a new reference "refs/shelved/BRANCH-NAME" - pointing at the same commit as the branch pointed at. If the - deleted branch had a reflog, then that is preserved as the reflog - of the new reference. - - This is useful if you want to move a branch out of sight, but are - not ready to completely discard it yet. - - -- Command: magit-branch-unshelve - This command unshelves a branch that was previously shelved using - ‘magit-branch-shelve’. This is done by deleting the reference - "refs/shelved/BRANCH-NAME" and creating a branch "BRANCH-NAME" - pointing at the same commit as the deleted reference pointed at. - If the deleted reference had a reflog, then that is restored as the - reflog of the branch. - - -File: magit.info, Node: Merging, Next: Resolving Conflicts, Prev: Branching, Up: Manipulating - -6.7 Merging -=========== - -Also see *note (gitman)git-merge::. For information on how to resolve -merge conflicts see the next section. - -‘m’ (‘magit-merge’) - This transient prefix command binds the following suffix commands - along with the appropriate infix arguments and displays them in a - temporary buffer until a suffix is invoked. - - When no merge is in progress, then the transient features the -following suffix commands. - -‘m m’ (‘magit-merge-plain’) - This command merges another branch or an arbitrary revision into - the current branch. The branch or revision to be merged is read in - the minibuffer and defaults to the branch at point. - - Unless there are conflicts or a prefix argument is used, then the - resulting merge commit uses a generic commit message, and the user - does not get a chance to inspect or change it before the commit is - created. With a prefix argument this does not actually create the - merge commit, which makes it possible to inspect how conflicts were - resolved and to adjust the commit message. - -‘m e’ (‘magit-merge-editmsg’) - This command merges another branch or an arbitrary revision into - the current branch and opens a commit message buffer, so that the - user can make adjustments. The commit is not actually created - until the user finishes with ‘C-c C-c’. - -‘m n’ (‘magit-merge-nocommit’) - This command merges another branch or an arbitrary revision into - the current branch, but does not actually create the merge commit. - The user can then further adjust the merge, even when automatic - conflict resolution succeeded and/or adjust the commit message. - -‘m a’ (‘magit-merge-absorb’) - This command merges another local branch into the current branch - and then removes the former. - - Before the source branch is merged, it is first force pushed to its - push-remote, provided the respective remote branch already exists. - This ensures that the respective pull-request (if any) won’t get - stuck on some obsolete version of the commits that are being - merged. Finally, if ‘magit-branch-pull-request’ was used to create - the merged branch, then the respective remote branch is also - removed. - -‘m i’ (‘magit-merge-into’) - This command merges the current branch into another local branch - and then removes the former. The latter becomes the new current - branch. - - Before the source branch is merged, it is first force pushed to its - push-remote, provided the respective remote branch already exists. - This ensures that the respective pull-request (if any) won’t get - stuck on some obsolete version of the commits that are being - merged. Finally, if ‘magit-branch-pull-request’ was used to create - the merged branch, then the respective remote branch is also - removed. - -‘m s’ (‘magit-merge-squash’) - This command squashes the changes introduced by another branch or - an arbitrary revision into the current branch. This only applies - the changes made by the squashed commits. No information is - preserved that would allow creating an actual merge commit. - Instead of this command you should probably use a command from the - apply transient. - -‘m p’ (‘magit-merge-preview’) - This command shows a preview of merging another branch or an - arbitrary revision into the current branch. - - Note that commands, that normally change how a diff is displayed, - do not work in buffers created by this command, because the - underlying Git command does not support diff arguments. - - When a merge is in progress, then the transient instead features the -following suffix commands. - -‘m m’ (‘magit-merge’) - After the user resolved conflicts, this command proceeds with the - merge. If some conflicts weren’t resolved, then this command - fails. - -‘m a’ (‘magit-merge-abort’) - This command aborts the current merge operation. - - -File: magit.info, Node: Resolving Conflicts, Next: Rebasing, Prev: Merging, Up: Manipulating - -6.8 Resolving Conflicts -======================= - -When merging branches (or otherwise combining or changing history) -conflicts can occur. If you edited two completely different parts of -the same file in two branches and then merge one of these branches into -the other, then Git can resolve that on its own, but if you edit the -same area of a file, then a human is required to decide how the two -versions, or "sides of the conflict", are to be combined into one. - - Here we can only provide a brief introduction to the subject and -point you toward some tools that can help. If you are new to this, then -please also consult Git’s own documentation as well as other resources. - - If a file has conflicts and Git cannot resolve them by itself, then -it puts both versions into the affected file along with special markers -whose purpose is to denote the boundaries of the unresolved part of the -file and between the different versions. These boundary lines begin -with the strings consisting of seven times the same character, one of -‘<’, ‘|’, ‘=’ and ‘>’, and are followed by information about the source -of the respective versions, e.g.: - - <<<<<<< HEAD - Take the blue pill. - ======= - Take the red pill. - >>>>>>> feature - - In this case you have chosen to take the red pill on one branch and -on another you picked the blue pill. Now that you are merging these two -diverging branches, Git cannot possibly know which pill you want to -take. - - To resolve that conflict you have to create a version of the affected -area of the file by keeping only one of the sides, possibly by editing -it in order to bring in the changes from the other side, remove the -other versions as well as the markers, and then stage the result. A -possible resolution might be: - - Take both pills. - - Often it is useful to see not only the two sides of the conflict but -also the "original" version from before the same area of the file was -modified twice on different branches. Instruct Git to insert that -version as well by running this command once: - - git config --global merge.conflictStyle diff3 - - The above conflict might then have looked like this: - - <<<<<<< HEAD - Take the blue pill. - ||||||| merged common ancestors - Take either the blue or the red pill, but not both. - ======= - Take the red pill. - >>>>>>> feature - - If that were the case, then the above conflict resolution would not -have been correct, which demonstrates why seeing the original version -alongside the conflicting versions can be useful. - - You can perform the conflict resolution completely by hand, but Emacs -also provides some packages that help in the process: Smerge, Ediff -(*note (ediff)Top::), and Emerge (*note (emacs)Emerge::). Magit does -not provide its own tools for conflict resolution, but it does make -using Smerge and Ediff more convenient. (Ediff supersedes Emerge, so -you probably don’t want to use the latter anyway.) - - In the Magit status buffer, files with unresolved conflicts are -listed in the "Unstaged changes" and/or "Staged changes" sections. They -are prefixed with the word "unmerged", which in this context essentially -is a synonym for "unresolved". - - Pressing ‘RET’ while point is on such a file section shows a buffer -visiting that file, turns on ‘smerge-mode’ in that buffer, and places -point inside the first area with conflicts. You should then resolve -that conflict using regular edit commands and/or Smerge commands. - - Unfortunately Smerge does not have a manual, but you can get a list -of commands and binding ‘C-c ^ C-h’ and press ‘RET’ while point is on a -command name to read its documentation. - - Normally you would edit one version and then tell Smerge to keep only -that version. Use ‘C-c ^ m’ (‘smerge-keep-mine’) to keep the ‘HEAD’ -version or ‘C-c ^ o’ (‘smerge-keep-other’) to keep the version that -follows "|||||||". Then use ‘C-c ^ n’ to move to the next conflicting -area in the same file. Once you are done resolving conflicts, return to -the Magit status buffer. The file should now be shown as "modified", no -longer as "unmerged", because Smerge automatically stages the file when -you save the buffer after resolving the last conflict. - - Magit now wraps the mentioned Smerge commands, allowing you to use -these key bindings without having to go to the file-visiting buffer. -Additionally ‘k’ (‘magit-discard’) on a hunk with unresolved conflicts -asks which side to keep or, if point is on a side, then it keeps it -without prompting. Similarly ‘k’ on a unresolved file ask which side to -keep. - - Alternatively you could use Ediff, which uses separate buffers for -the different versions of the file. To resolve conflicts in a file -using Ediff press ‘e’ while point is on such a file in the status -buffer. - - Ediff can be used for other purposes as well. For more information -on how to enter Ediff from Magit, see *note Ediffing::. Explaining how -to use Ediff is beyond the scope of this manual, instead see *note -(ediff)Top::. - - If you are unsure whether you should Smerge or Ediff, then use the -former. It is much easier to understand and use, and except for truly -complex conflicts, the latter is usually overkill. - - -File: magit.info, Node: Rebasing, Next: Cherry Picking, Prev: Resolving Conflicts, Up: Manipulating - -6.9 Rebasing -============ - -Also see *note (gitman)git-rebase::. For information on how to resolve -conflicts that occur during rebases see the preceding section. - -‘r’ (‘magit-rebase’) - This transient prefix command binds the following suffix commands - along with the appropriate infix arguments and displays them in a - temporary buffer until a suffix is invoked. - - When no rebase is in progress, then the transient features the -following suffix commands. - - Using one of these commands _starts_ a rebase sequence. Git might -then stop somewhere along the way, either because you told it to do so, -or because applying a commit failed due to a conflict. When that -happens, then the status buffer shows information about the rebase -sequence which is in progress in a section similar to a log section. -See *note Information About In-Progress Rebase::. - - For information about the upstream and the push-remote, see *note The -Two Remotes::. - -‘r p’ (‘magit-rebase-onto-pushremote’) - This command rebases the current branch onto its push-remote. - - With a prefix argument or when the push-remote is either not - configured or unusable, then let the user first configure the - push-remote. - -‘r u’ (‘magit-rebase-onto-upstream’) - This command rebases the current branch onto its upstream branch. - - With a prefix argument or when the upstream is either not - configured or unusable, then let the user first configure the - upstream. - -‘r e’ (‘magit-rebase-branch’) - This command rebases the current branch onto a branch read in the - minibuffer. All commits that are reachable from head but not from - the selected branch TARGET are being rebased. - -‘r s’ (‘magit-rebase-subset’) - This command starts a non-interactive rebase sequence to transfer - commits from START to ‘HEAD’ onto NEWBASE. START has to be - selected from a list of recent commits. - - By default Magit uses the ‘--autostash’ argument, which causes -uncommitted changes to be stored in a stash before the rebase begins. -These changes are restored after the rebase completes and if possible -the stash is removed. If the stash does not apply cleanly, then the -stash is not removed. In case something goes wrong when resolving the -conflicts, this allows you to start over. - - Even though one of the actions is dedicated to interactive rebases, -the transient also features the infix argument ‘--interactive’. This -can be used to turn one of the other, non-interactive rebase variants -into an interactive rebase. - - For example if you want to clean up a feature branch and at the same -time rebase it onto ‘master’, then you could use ‘r-iu’. But we -recommend that you instead do that in two steps. First use ‘ri’ to -cleanup the feature branch, and then in a second step ‘ru’ to rebase it -onto ‘master’. That way if things turn out to be more complicated than -you thought and/or you make a mistake and have to start over, then you -only have to redo half the work. - - Explicitly enabling ‘--interactive’ won’t have an effect on the -following commands as they always use that argument anyway, even if it -is not enabled in the transient. - -‘r i’ (‘magit-rebase-interactive’) - This command starts an interactive rebase sequence. - -‘r f’ (‘magit-rebase-autosquash’) - This command combines squash and fixup commits with their intended - targets. - -‘r m’ (‘magit-rebase-edit-commit’) - This command starts an interactive rebase sequence that lets the - user edit a single older commit. - -‘r w’ (‘magit-rebase-reword-commit’) - This command starts an interactive rebase sequence that lets the - user reword a single older commit. - -‘r k’ (‘magit-rebase-remove-commit’) - This command removes a single older commit using rebase. - - When a rebase is in progress, then the transient instead features the -following suffix commands. - -‘r r’ (‘magit-rebase-continue’) - This command restart the current rebasing operation. - - In some cases this pops up a commit message buffer for you do edit. - With a prefix argument the old message is reused as-is. - -‘r s’ (‘magit-rebase-skip’) - This command skips the current commit and restarts the current - rebase operation. - -‘r e’ (‘magit-rebase-edit’) - This command lets the user edit the todo list of the current rebase - operation. - -‘r a’ (‘magit-rebase-abort’) - This command aborts the current rebase operation, restoring the - original branch. - -* Menu: - -* Editing Rebase Sequences:: -* Information About In-Progress Rebase:: - - -File: magit.info, Node: Editing Rebase Sequences, Next: Information About In-Progress Rebase, Up: Rebasing - -6.9.1 Editing Rebase Sequences ------------------------------- - -‘C-c C-c’ (‘with-editor-finish’) - Finish the current editing session by returning with exit code 0. - Git then uses the rebase instructions it finds in the file. - -‘C-c C-k’ (‘with-editor-cancel’) - Cancel the current editing session by returning with exit code 1. - Git then forgoes starting the rebase sequence. - -‘<RET>’ (‘git-rebase-show-commit’) - Show the commit on the current line in another buffer and select - that buffer. - -‘<SPC>’ (‘git-rebase-show-or-scroll-up’) - Show the commit on the current line in another buffer without - selecting that buffer. If the revision buffer is already visible - in another window of the current frame, then instead scroll that - window up. - -‘<DEL>’ (‘git-rebase-show-or-scroll-down’) - Show the commit on the current line in another buffer without - selecting that buffer. If the revision buffer is already visible - in another window of the current frame, then instead scroll that - window down. - -‘p’ (‘git-rebase-backward-line’) - Move to previous line. - -‘n’ (‘forward-line’) - Move to next line. - -‘M-p’ (‘git-rebase-move-line-up’) - Move the current commit (or command) up. - -‘M-n’ (‘git-rebase-move-line-down’) - Move the current commit (or command) down. - -‘r’ (‘git-rebase-reword’) - Edit message of commit on current line. - -‘e’ (‘git-rebase-edit’) - Stop at the commit on the current line. - -‘s’ (‘git-rebase-squash’) - Meld commit on current line into previous commit, and edit message. - -‘f’ (‘git-rebase-fixup’) - Meld commit on current line into previous commit, discarding the - current commit’s message. - -‘k’ (‘git-rebase-kill-line’) - Kill the current action line. - -‘c’ (‘git-rebase-pick’) - Use commit on current line. - -‘x’ (‘git-rebase-exec’) - Insert a shell command to be run after the proceeding commit. - - If there already is such a command on the current line, then edit - that instead. With a prefix argument insert a new command even - when there already is one on the current line. With empty input - remove the command on the current line, if any. - -‘b’ (‘git-rebase-break’) - Insert a break action before the current line, instructing Git to - return control to the user. - -‘y’ (‘git-rebase-insert’) - Read an arbitrary commit and insert it below current line. - -‘C-x u’ (‘git-rebase-undo’) - Undo some previous changes. Like ‘undo’ but works in read-only - buffers. - - -- User Option: git-rebase-auto-advance - Whether to move to next line after changing a line. - - -- User Option: git-rebase-show-instructions - Whether to show usage instructions inside the rebase buffer. - - -- User Option: git-rebase-confirm-cancel - Whether confirmation is required to cancel. - - When a rebase is performed with the ‘--rebase-merges’ option, the -sequence will include a few other types of actions and the following -commands become relevant. - -‘l’ (‘git-rebase-label’) - This commands inserts a label action or edits the one at point. - -‘t’ (‘git-rebase-reset’) - This command inserts a reset action or edits the one at point. The - prompt will offer the labels that are currently present in the - buffer. - -‘MM’ (‘git-rebase-merge’) - The command inserts a merge action or edits the one at point. The - prompt will offer the labels that are currently present in the - buffer. Specifying a message to reuse via ‘-c’ or ‘-C’ is not - supported; an editor will always be invoked for the merge. - -‘Mt’ (‘git-rebase-merge-toggle-editmsg’) - This command toggles between the ‘-C’ and ‘-c’ options of the merge - action at point. These options both specify a commit whose message - should be reused. The lower-case variant instructs Git to invoke - the editor when creating the merge, allowing the user to edit the - message. - - -File: magit.info, Node: Information About In-Progress Rebase, Prev: Editing Rebase Sequences, Up: Rebasing - -6.9.2 Information About In-Progress Rebase ------------------------------------------- - -While a rebase sequence is in progress, the status buffer features a -section that lists the commits that have already been applied as well as -the commits that still have to be applied. - - The commits are split in two halves. When rebase stops at a commit, -either because the user has to deal with a conflict or because s/he -explicitly requested that rebase stops at that commit, then point is -placed on the commit that separates the two groups, i.e., on ‘HEAD’. -The commits above it have not been applied yet, while the ‘HEAD’ and the -commits below it have already been applied. In between these two groups -of applied and yet-to-be applied commits, there sometimes is a commit -which has been dropped. - - Each commit is prefixed with a word and these words are additionally -shown in different colors to indicate the status of the commits. - - The following colors are used: - - • Commits that use the same foreground color as the ‘default’ face - have not been applied yet. - - • Yellow commits have some special relationship to the commit rebase - stopped at. This is used for the words "join", "goal", "same" and - "work" (see below). - - • Gray commits have already been applied. - - • The blue commit is the ‘HEAD’ commit. - - • The green commit is the commit the rebase sequence stopped at. If - this is the same commit as ‘HEAD’ (e.g., because you haven’t done - anything yet after rebase stopped at the commit, then this commit - is shown in blue, not green). There can only be a green *and* a - blue commit at the same time, if you create one or more new commits - after rebase stops at a commit. - - • Red commits have been dropped. They are shown for reference only, - e.g., to make it easier to diff. - - Of course these colors are subject to the color-theme in use. - - The following words are used: - - • Commits prefixed with ‘pick’, ‘reword’, ‘edit’, ‘squash’, and - ‘fixup’ have not been applied yet. These words have the same - meaning here as they do in the buffer used to edit the rebase - sequence. See *note Editing Rebase Sequences::. When the - ‘--rebase-merges’ option was specified, ‘reset’, ‘label’, and - ‘merge’ lines may also be present. - - • Commits prefixed with ‘done’ and ‘onto’ have already been applied. - It is possible for such a commit to be the ‘HEAD’, in which case it - is blue. Otherwise it is grey. - - • The commit prefixed with ‘onto’ is the commit on top of which - all the other commits are being re-applied. This commit - itself did not have to be re-applied, it is the commit rebase - did rewind to before starting to re-apply other commits. - - • Commits prefixed with ‘done’ have already been re-applied. - This includes commits that have been re-applied but also new - commits that you have created during the rebase. - - • All other commits, those not prefixed with any of the above words, - are in some way related to the commit at which rebase stopped. - - To determine whether a commit is related to the stopped-at commit - their hashes, trees and patch-ids (1) are being compared. The - commit message is not used for this purpose. - - Generally speaking commits that are related to the stopped-at - commit can have any of the used colors, though not all color/word - combinations are possible. - - Words used for stopped-at commits are: - - • When a commit is prefixed with ‘void’, then that indicates - that Magit knows for sure that all the changes in that commit - have been applied using several new commits. This commit is - no longer reachable from ‘HEAD’, and it also isn’t one of the - commits that will be applied when resuming the session. - - • When a commit is prefixed with ‘join’, then that indicates - that the rebase sequence stopped at that commit due to a - conflict - you now have to join (merge) the changes with what - has already been applied. In a sense this is the commit - rebase stopped at, but while its effect is already in the - index and in the worktree (with conflict markers), the commit - itself has not actually been applied yet (it isn’t the - ‘HEAD’). So it is shown in yellow, like the other commits - that still have to be applied. - - • When a commit is prefixed with ‘stop’ or a _blue_ or _green_ - ‘same’, then that indicates that rebase stopped at this - commit, that it is still applied or has been applied again, - and that at least its patch-id is unchanged. - - • When a commit is prefixed with ‘stop’, then that - indicates that rebase stopped at that commit because you - requested that earlier, and its patch-id is unchanged. - It might even still be the exact same commit. - - • When a commit is prefixed with a _blue_ or _green_ - ‘same’, then that indicates that while its tree or hash - changed, its patch-id did not. If it is blue, then it is - the ‘HEAD’ commit (as always for blue). When it is - green, then it no longer is ‘HEAD’ because other commit - have been created since (but before continuing the - rebase). - - • When a commit is prefixed with ‘goal’, a _yellow_ ‘same,’ or - ‘work’, then that indicates that rebase applied that commit - but that you then reset ‘HEAD’ to an earlier commit (likely to - split it up into multiple commits), and that there are some - uncommitted changes remaining which likely (but not - necessarily) originate from that commit. - - • When a commit is prefixed with ‘goal’, then that - indicates that it is still possible to create a new - commit with the exact same tree (the "goal") without - manually editing any files, by committing the index, or - by staging all changes and then committing that. This is - the case when the original tree still exists in the index - or worktree in untainted form. - - • When a commit is prefixed with a yellow ‘same’, then that - indicates that it is no longer possible to create a - commit with the exact same tree, but that it is still - possible to create a commit with the same patch-id. This - would be the case if you created a new commit with other - changes, but the changes from the original commit still - exist in the index or working tree in untainted form. - - • When a commit is prefixed with ‘work’, then that - indicates that you reset ‘HEAD’ to an earlier commit, and - that there are some staged and/or unstaged changes - (likely, but not necessarily) originating from that - commit. However it is no longer possible to create a new - commit with the same tree or at least the same patch-id - because you have already made other changes. - - • When a commit is prefixed with ‘poof’ or ‘gone’, then that - indicates that rebase applied that commit but that you then - reset ‘HEAD’ to an earlier commit (likely to split it up into - multiple commits), and that there are no uncommitted changes. - - • When a commit is prefixed with ‘poof’, then that - indicates that it is no longer reachable from ‘HEAD’, but - that it has been replaced with one or more commits, which - together have the exact same effect. - - • When a commit is prefixed with ‘gone’, then that - indicates that it is no longer reachable from ‘HEAD’ and - that we also cannot determine whether its changes are - still in effect in one or more new commits. They might - be, but if so, then there must also be other changes - which makes it impossible to know for sure. - - Do not worry if you do not fully understand the above. That’s okay, -you will acquire a good enough understanding through practice. - - For other sequence operations such as cherry-picking, a similar -section is displayed, but they lack some of the features described -above, due to limitations in the git commands used to implement them. -Most importantly these sequences only support "picking" a commit but not -other actions such as "rewording", and they do not keep track of the -commits which have already been applied. - - ---------- Footnotes ---------- - - (1) The patch-id is a hash of the _changes_ introduced by a commit. -It differs from the hash of the commit itself, which is a hash of the -result of applying that change (i.e., the resulting trees and blobs) as -well as author and committer information, the commit message, and the -hashes of the parents of the commit. The patch-id hash on the other -hand is created only from the added and removed lines, even line numbers -and whitespace changes are ignored when calculating this hash. The -patch-ids of two commits can be used to answer the question "Do these -commits make the same change?". - - -File: magit.info, Node: Cherry Picking, Next: Resetting, Prev: Rebasing, Up: Manipulating - -6.10 Cherry Picking -=================== - -Also see *note (gitman)git-cherry-pick::. - -‘A’ (‘magit-cherry-pick’) - This transient prefix command binds the following suffix commands - along with the appropriate infix arguments and displays them in a - temporary buffer until a suffix is invoked. - - When no cherry-pick or revert is in progress, then the transient -features the following suffix commands. - -‘A A’ (‘magit-cherry-copy’) - This command copies COMMITS from another branch onto the current - branch. If the region selects multiple commits, then those are - copied, without prompting. Otherwise the user is prompted for a - commit or range, defaulting to the commit at point. - -‘A a’ (‘magit-cherry-apply’) - This command applies the changes in COMMITS from another branch - onto the current branch. If the region selects multiple commits, - then those are used, without prompting. Otherwise the user is - prompted for a commit or range, defaulting to the commit at point. - - This command also has a top-level binding, which can be invoked - without using the transient by typing ‘a’ at the top-level. - - The following commands not only apply some commits to some branch, -but also remove them from some other branch. The removal is performed -using either ‘git-update-ref’ or if necessary ‘git-rebase’. Both -applying commits as well as removing them using ‘git-rebase’ can lead to -conflicts. If that happens, then these commands abort and you not only -have to resolve the conflicts but also finish the process the same way -you would have to if these commands didn’t exist at all. - -‘A h’ (‘magit-cherry-harvest’) - This command moves the selected COMMITS that must be located on - another BRANCH onto the current branch instead, removing them from - the former. When this command succeeds, then the same branch is - current as before. - - Applying the commits on the current branch or removing them from - the other branch can lead to conflicts. When that happens, then - this command stops and you have to resolve the conflicts and then - finish the process manually. - -‘A d’ (‘magit-cherry-donate’) - This command moves the selected COMMITS from the current branch - onto another existing BRANCH, removing them from the former. When - this command succeeds, then the same branch is current as before. - ‘HEAD’ is allowed to be detached initially. - - Applying the commits on the other branch or removing them from the - current branch can lead to conflicts. When that happens, then this - command stops and you have to resolve the conflicts and then finish - the process manually. - -‘A n’ (‘magit-cherry-spinout’) - This command moves the selected COMMITS from the current branch - onto a new branch BRANCH, removing them from the former. When this - command succeeds, then the same branch is current as before. - - Applying the commits on the other branch or removing them from the - current branch can lead to conflicts. When that happens, then this - command stops and you have to resolve the conflicts and then finish - the process manually. - -‘A s’ (‘magit-cherry-spinoff’) - This command moves the selected COMMITS from the current branch - onto a new branch BRANCH, removing them from the former. When this - command succeeds, then the new branch is checked out. - - Applying the commits on the other branch or removing them from the - current branch can lead to conflicts. When that happens, then this - command stops and you have to resolve the conflicts and then finish - the process manually. - - When a cherry-pick or revert is in progress, then the transient -instead features the following suffix commands. - -‘A A’ (‘magit-sequence-continue’) - Resume the current cherry-pick or revert sequence. - -‘A s’ (‘magit-sequence-skip’) - Skip the stopped at commit during a cherry-pick or revert sequence. - -‘A a’ (‘magit-sequence-abort’) - Abort the current cherry-pick or revert sequence. This discards - all changes made since the sequence started. - -* Menu: - -* Reverting:: - - -File: magit.info, Node: Reverting, Up: Cherry Picking - -6.10.1 Reverting ----------------- - -‘V’ (‘magit-revert’) - This transient prefix command binds the following suffix commands - along with the appropriate infix arguments and displays them in a - temporary buffer until a suffix is invoked. - - When no cherry-pick or revert is in progress, then the transient -features the following suffix commands. - -‘V V’ (‘magit-revert-and-commit’) - Revert a commit by creating a new commit. Prompt for a commit, - defaulting to the commit at point. If the region selects multiple - commits, then revert all of them, without prompting. - -‘V v’ (‘magit-revert-no-commit’) - Revert a commit by applying it in reverse to the working tree. - Prompt for a commit, defaulting to the commit at point. If the - region selects multiple commits, then revert all of them, without - prompting. - - When a cherry-pick or revert is in progress, then the transient -instead features the following suffix commands. - -‘V V’ (‘magit-sequence-continue’) - Resume the current cherry-pick or revert sequence. - -‘V s’ (‘magit-sequence-skip’) - Skip the stopped at commit during a cherry-pick or revert sequence. - -‘V a’ (‘magit-sequence-abort’) - Abort the current cherry-pick or revert sequence. This discards - all changes made since the sequence started. - - -File: magit.info, Node: Resetting, Next: Stashing, Prev: Cherry Picking, Up: Manipulating - -6.11 Resetting -============== - -Also see *note (gitman)git-reset::. - -‘x’ (‘magit-reset-quickly’) - Reset the ‘HEAD’ and index to some commit read from the user and - defaulting to the commit at point, and possibly also reset the - working tree. With a prefix argument reset the working tree - otherwise don’t. - -‘X m’ (‘magit-reset-mixed’) - Reset the ‘HEAD’ and index to some commit read from the user and - defaulting to the commit at point. The working tree is kept as-is. - -‘X s’ (‘magit-reset-soft’) - Reset the ‘HEAD’ to some commit read from the user and defaulting - to the commit at point. The index and the working tree are kept - as-is. - -‘X h’ (‘magit-reset-hard’) - Reset the ‘HEAD’, index, and working tree to some commit read from - the user and defaulting to the commit at point. - -‘X k’ (‘magit-reset-keep’) - Reset the ‘HEAD’, index, and working tree to some commit read from - the user and defaulting to the commit at point. Uncommitted - changes are kept as-is. - -‘X i’ (‘magit-reset-index’) - Reset the index to some commit read from the user and defaulting to - the commit at point. Keep the ‘HEAD’ and working tree as-is, so if - the commit refers to the ‘HEAD’, then this effectively unstages all - changes. - -‘X w’ (‘magit-reset-worktree’) - Reset the working tree to some commit read from the user and - defaulting to the commit at point. Keep the ‘HEAD’ and index - as-is. - -‘X f’ (‘magit-file-checkout’) - Update file in the working tree and index to the contents from a - revision. Both the revision and file are read from the user. - - -File: magit.info, Node: Stashing, Prev: Resetting, Up: Manipulating - -6.12 Stashing -============= - -Also see *note (gitman)git-stash::. - -‘z’ (‘magit-stash’) - This transient prefix command binds the following suffix commands - along with the appropriate infix arguments and displays them in a - temporary buffer until a suffix is invoked. - -‘z z’ (‘magit-stash-both’) - Create a stash of the index and working tree. Untracked files are - included according to infix arguments. One prefix argument is - equivalent to ‘--include-untracked’ while two prefix arguments are - equivalent to ‘--all’. - -‘z i’ (‘magit-stash-index’) - Create a stash of the index only. Unstaged and untracked changes - are not stashed. - -‘z w’ (‘magit-stash-worktree’) - Create a stash of unstaged changes in the working tree. Untracked - files are included according to infix arguments. One prefix - argument is equivalent to ‘--include-untracked’ while two prefix - arguments are equivalent to ‘--all’. - -‘z x’ (‘magit-stash-keep-index’) - Create a stash of the index and working tree, keeping index intact. - Untracked files are included according to infix arguments. One - prefix argument is equivalent to ‘--include-untracked’ while two - prefix arguments are equivalent to ‘--all’. - -‘z Z’ (‘magit-snapshot-both’) - Create a snapshot of the index and working tree. Untracked files - are included according to infix arguments. One prefix argument is - equivalent to ‘--include-untracked’ while two prefix arguments are - equivalent to ‘--all’. - -‘z I’ (‘magit-snapshot-index’) - Create a snapshot of the index only. Unstaged and untracked - changes are not stashed. - -‘z W’ (‘magit-snapshot-worktree’) - Create a snapshot of unstaged changes in the working tree. - Untracked files are included according to infix arguments. One - prefix argument is equivalent to ‘--include-untracked’ while two - prefix arguments are equivalent to ‘--all’-. - -‘z a’ (‘magit-stash-apply’) - Apply a stash to the working tree. - - First try ‘git stash apply --index’, which tries to preserve the - index stored in the stash, if any. This may fail because applying - the stash could result in conflicts and those have to be stored in - the index, making it impossible to also store the stash’s index - there as well. - - If the above failed, then try ‘git stash apply’. This fails (with - or without ‘--index’) if there are any uncommitted changes to files - that are also modified in the stash. - - If both of the above failed, then apply using ‘git apply’. If - there are no conflicting files, use ‘--3way’. If there are - conflicting files, then using ‘--3way’ requires that those files - are staged first, which may be undesirable, so prompt the user - whether to use ‘--3way’ or ‘--reject’. - - Customize ‘magit-no-confirm’ if you want to always use ‘--3way’, - without being prompted. - -‘z p’ (‘magit-stash-pop’) - Apply a stash to the working tree. On complete success (if the - stash can be applied without any conflicts, and while preserving - the stash’s index) then remove the stash from stash list. - - First try ‘git stash pop --index’, which tries to preserve the - index stored in the stash, if any. This may fail because applying - the stash could result in conflicts and those have to be stored in - the index, making it impossible to also store the stash’s index - there as well. - - If the above failed, then try ‘git stash apply’. This fails (with - or without ‘--index’) if there are any uncommitted changes to files - that are also modified in the stash. - - If both of the above failed, then apply using ‘git apply’. If - there are no conflicting files, use ‘--3way’. If there are - conflicting files, then using ‘--3way’ requires that those files - are staged first, which may be undesirable, so prompt the user - whether to use ‘--3way’ or ‘--reject’. - - Customize ‘magit-no-confirm’ if you want to always use ‘--3way’, - without being prompted. - -‘z k’ (‘magit-stash-drop’) - Remove a stash from the stash list. When the region is active, - offer to drop all contained stashes. - -‘z v’ (‘magit-stash-show’) - Show all diffs of a stash in a buffer. - -‘z b’ (‘magit-stash-branch’) - Create and checkout a new branch from an existing stash. The new - branch starts at the commit that was current when the stash was - created. - -‘z B’ (‘magit-stash-branch-here’) - Create and checkout a new branch from an existing stash. Use the - current branch or ‘HEAD’ as the starting-point of the new branch. - Then apply the stash, dropping it if it applies cleanly. - -‘z f’ (‘magit-stash-format-patch’) - Create a patch from STASH. - -‘k’ (‘magit-stash-clear’) - Remove all stashes saved in REF’s reflog by deleting REF. - -‘z l’ (‘magit-stash-list’) - List all stashes in a buffer. - - -- User Option: magit-stashes-margin - This option specifies whether the margin is initially shown in - stashes buffers and how it is formatted. - - The value has the form ‘(INIT STYLE WIDTH AUTHOR AUTHOR-WIDTH)’. - - • If INIT is non-nil, then the margin is shown initially. - • STYLE controls how to format the author or committer date. It - can be one of ‘age’ (to show the age of the commit), - ‘age-abbreviated’ (to abbreviate the time unit to a - character), or a string (suitable for ‘format-time-string’) to - show the actual date. Option - ‘magit-log-margin-show-committer-date’ controls which date is - being displayed. - • WIDTH controls the width of the margin. This exists for - forward compatibility and currently the value should not be - changed. - • AUTHOR controls whether the name of the author is also shown - by default. - • AUTHOR-WIDTH has to be an integer. When the name of the - author is shown, then this specifies how much space is used to - do so. - - -File: magit.info, Node: Transferring, Next: Miscellaneous, Prev: Manipulating, Up: Top - -7 Transferring -************** - -* Menu: - -* Remotes:: -* Fetching:: -* Pulling:: -* Pushing:: -* Plain Patches:: -* Maildir Patches:: - - -File: magit.info, Node: Remotes, Next: Fetching, Up: Transferring - -7.1 Remotes -=========== - -* Menu: - -* Remote Commands:: -* Remote Git Variables:: - - -File: magit.info, Node: Remote Commands, Next: Remote Git Variables, Up: Remotes - -7.1.1 Remote Commands ---------------------- - -The transient prefix command ‘magit-remote’ is used to add remotes and -to make changes to existing remotes. This command only deals with -remotes themselves, not with branches or the transfer of commits. Those -features are available from separate transient commands. - - Also see *note (gitman)git-remote::. - -‘M’ (‘magit-remote’) - This transient prefix command binds the following suffix commands - and displays them in a temporary buffer until a suffix is invoked. - - By default it also binds and displays the values of some - remote-related Git variables and allows changing their values. - - -- User Option: magit-remote-direct-configure - This option controls whether remote-related Git variables are - accessible directly from the transient ‘magit-remote’. - - If ‘t’ (the default) and a local branch is checked out, then - ‘magit-remote’ features the variables for the upstream remote of - that branch, or if ‘HEAD’ is detached, for ‘origin’, provided that - exists. - - If ‘nil’, then ‘magit-remote-configure’ has to be used to do so. - -‘M C’ (‘magit-remote-configure’) - This transient prefix command binds commands that set the value of - remote-related variables and displays them in a temporary buffer - until the transient is exited. - - With a prefix argument, this command always prompts for a remote. - - Without a prefix argument this depends on whether it was invoked as - a suffix of ‘magit-remote’ and on the - ‘magit-remote-direct-configure’ option. If ‘magit-remote’ already - displays the variables for the upstream, then it does not make - sense to invoke another transient that displays them for the same - remote. In that case this command prompts for a remote. - - The variables are described in *note Remote Git Variables::. - -‘M a’ (‘magit-remote-add’) - This command add a remote and fetches it. The remote name and url - are read in the minibuffer. - -‘M r’ (‘magit-remote-rename’) - This command renames a remote. Both the old and the new names are - read in the minibuffer. - -‘M u’ (‘magit-remote-set-url’) - This command changes the url of a remote. Both the remote and the - new url are read in the minibuffer. - -‘M k’ (‘magit-remote-remove’) - This command deletes a remote, read in the minibuffer. - -‘M p’ (‘magit-remote-prune’) - This command removes stale remote-tracking branches for a remote - read in the minibuffer. - -‘M P’ (‘magit-remote-prune-refspecs’) - This command removes stale refspecs for a remote read in the - minibuffer. - - A refspec is stale if there no longer exists at least one branch on - the remote that would be fetched due to that refspec. A stale - refspec is problematic because its existence causes Git to refuse - to fetch according to the remaining non-stale refspecs. - - If only stale refspecs remain, then this command offers to either - delete the remote or to replace the stale refspecs with the default - refspec ("+refs/heads/*:refs/remotes/REMOTE/*"). - - This command also removes the remote-tracking branches that were - created due to the now stale refspecs. Other stale branches are - not removed. - - -- User Option: magit-remote-add-set-remote.pushDefault - This option controls whether the user is asked whether they want to - set ‘remote.pushDefault’ after adding a remote. - - If ‘ask’, then users is always ask. If ‘ask-if-unset’, then the - user is only if the variable isn’t set already. If ‘nil’, then the - user isn’t asked and the variable isn’t set. If the value is a - string, then the variable is set without the user being asked, - provided that the name of the added remote is equal to that string - and the variable isn’t already set. - - -File: magit.info, Node: Remote Git Variables, Prev: Remote Commands, Up: Remotes - -7.1.2 Remote Git Variables --------------------------- - -These variables can be set from the transient prefix command -‘magit-remote-configure’. By default they can also be set from -‘magit-remote’. See *note Remote Commands::. - - -- Variable: remote.NAME.url - This variable specifies the url of the remote named NAME. It can - have multiple values. - - -- Variable: remote.NAME.fetch - The refspec used when fetching from the remote named NAME. It can - have multiple values. - - -- Variable: remote.NAME.pushurl - This variable specifies the url used for pushing to the remote - named NAME. If it is not specified, then ‘remote.NAME.url’ is used - instead. It can have multiple values. - - -- Variable: remote.NAME.push - The refspec used when pushing to the remote named NAME. It can - have multiple values. - - -- Variable: remote.NAME.tagOpts - This variable specifies what tags are fetched by default. If the - value is ‘--no-tags’ then no tags are fetched. If the value is - ‘--tags’, then all tags are fetched. If this variable has no - value, then only tags are fetched that are reachable from fetched - branches. - - -File: magit.info, Node: Fetching, Next: Pulling, Prev: Remotes, Up: Transferring - -7.2 Fetching -============ - -Also see *note (gitman)git-fetch::. For information about the upstream -and the push-remote, see *note The Two Remotes::. - -‘f’ (‘magit-fetch’) - This transient prefix command binds the following suffix commands - along with the appropriate infix arguments and displays them in a - temporary buffer until a suffix is invoked. - -‘f p’ (‘magit-fetch-from-pushremote’) - This command fetches from the current push-remote. - - With a prefix argument or when the push-remote is either not - configured or unusable, then let the user first configure the - push-remote. - -‘f u’ (‘magit-fetch-from-upstream’) - This command fetch from the upstream of the current branch. - - If the upstream is configured for the current branch and names an - existing remote, then use that. Otherwise try to use another - remote: If only a single remote is configured, then use that. - Otherwise if a remote named "origin" exists, then use that. - - If no remote can be determined, then this command is not available - from the ‘magit-fetch’ transient prefix and invoking it directly - results in an error. - -‘f e’ (‘magit-fetch-other’) - This command fetch from a repository read from the minibuffer. - -‘f o’ (‘magit-fetch-branch’) - This command fetches a branch from a remote, both of which are read - from the minibuffer. - -‘f r’ (‘magit-fetch-refspec’) - This command fetches from a remote using an explicit refspec, both - of which are read from the minibuffer. - -‘f a’ (‘magit-fetch-all’) - This command fetches from all remotes. - -‘f m’ (‘magit-submodule-fetch’) - This command fetches all submodules. With a prefix argument it - fetches all remotes of all submodules. - - -- User Option: magit-pull-or-fetch - By default fetch and pull commands are available from separate - transient prefix command. Setting this to ‘t’ adds some (but not - all) of the above suffix commands to the ‘magit-pull’ transient. - - If you do that, then you might also want to change the key binding - for these prefix commands, e.g.: - - (setq magit-pull-or-fetch t) - (define-key magit-mode-map "f" 'magit-pull) ; was magit-fetch - (define-key magit-mode-map "F" nil) ; was magit-pull - - -File: magit.info, Node: Pulling, Next: Pushing, Prev: Fetching, Up: Transferring - -7.3 Pulling -=========== - -Also see *note (gitman)git-pull::. For information about the upstream -and the push-remote, see *note The Two Remotes::. - -‘F’ (‘magit-pull’) - This transient prefix command binds the following suffix commands - and displays them in a temporary buffer until a suffix is invoked. - -‘F p’ (‘magit-pull-from-pushremote’) - This command pulls from the push-remote of the current branch. - - With a prefix argument or when the push-remote is either not - configured or unusable, then let the user first configure the - push-remote. - -‘F u’ (‘magit-pull-from-upstream’) - This command pulls from the upstream of the current branch. - - With a prefix argument or when the upstream is either not - configured or unusable, then let the user first configure the - upstream. - -‘F e’ (‘magit-pull-branch’) - This command pulls from a branch read in the minibuffer. - - -File: magit.info, Node: Pushing, Next: Plain Patches, Prev: Pulling, Up: Transferring - -7.4 Pushing -=========== - -Also see *note (gitman)git-push::. For information about the upstream -and the push-remote, see *note The Two Remotes::. - -‘P’ (‘magit-push’) - This transient prefix command binds the following suffix commands - along with the appropriate infix arguments and displays them in a - temporary buffer until a suffix is invoked. - -‘P p’ (‘magit-push-current-to-pushremote’) - This command pushes the current branch to its push-remote. - - With a prefix argument or when the push-remote is either not - configured or unusable, then let the user first configure the - push-remote. - -‘P u’ (‘magit-push-current-to-upstream’) - This command pushes the current branch to its upstream branch. - - With a prefix argument or when the upstream is either not - configured or unusable, then let the user first configure the - upstream. - -‘P e’ (‘magit-push-current’) - This command pushes the current branch to a branch read in the - minibuffer. - -‘P o’ (‘magit-push-other’) - This command pushes an arbitrary branch or commit somewhere. Both - the source and the target are read in the minibuffer. - -‘P r’ (‘magit-push-refspecs’) - This command pushes one or multiple refspecs to a remote, both of - which are read in the minibuffer. - - To use multiple refspecs, separate them with commas. Completion is - only available for the part before the colon, or when no colon is - used. - -‘P m’ (‘magit-push-matching’) - This command pushes all matching branches to another repository. - - If only one remote exists, then push to that. Otherwise prompt for - a remote, offering the remote configured for the current branch as - default. - -‘P t’ (‘magit-push-tags’) - This command pushes all tags to another repository. - - If only one remote exists, then push to that. Otherwise prompt for - a remote, offering the remote configured for the current branch as - default. - -‘P T’ (‘magit-push-tag’) - This command pushes a tag to another repository. - - One of the infix arguments, ‘--force-with-lease’, deserves a word of -caution. It is passed without a value, which means "permit a force push -as long as the remote-tracking branches match their counterparts on the -remote end". If you’ve set up a tool to do automatic fetches (Magit -itself does not provide such functionality), using ‘--force-with-lease’ -can be dangerous because you don’t actually control or know the state of -the remote-tracking refs. In that case, you should consider setting -‘push.useForceIfIncludes’ to ‘true’ (available since Git 2.30). - - Two more push commands exist, which by default are not available from -the push transient. See their doc-strings for instructions on how to -add them to the transient. - - -- Command: magit-push-implicitly args - This command pushes somewhere without using an explicit refspec. - - This command simply runs ‘git push -v [ARGS]’. ARGS are the infix - arguments. No explicit refspec arguments are used. Instead the - behavior depends on at least these Git variables: ‘push.default’, - ‘remote.pushDefault’, ‘branch.<branch>.pushRemote’, - ‘branch.<branch>.remote’, ‘branch.<branch>.merge’, and - ‘remote.<remote>.push’. - - If you add this suffix to a transient prefix without explicitly - specifying the description, then an attempt is made to predict what - this command will do. For example: - - (transient-insert-suffix 'magit-push \"p\" - '(\"i\" magit-push-implicitly))" - - -- Command: magit-push-to-remote remote args - This command pushes to the remote REMOTE without using an explicit - refspec. The remote is read in the minibuffer. - - This command simply runs ‘git push -v [ARGS] REMOTE’. ARGS are the - infix arguments. No refspec arguments are used. Instead the - behavior depends on at least these Git variables: ‘push.default’, - ‘remote.pushDefault’, ‘branch.<branch>.pushRemote’, - ‘branch.<branch>.remote’, ‘branch.<branch>.merge’, and - ‘remote.<remote>.push’. - - -File: magit.info, Node: Plain Patches, Next: Maildir Patches, Prev: Pushing, Up: Transferring - -7.5 Plain Patches -================= - -‘W’ (‘magit-patch’) - This transient prefix command binds the following suffix commands - along with the appropriate infix arguments and displays them in a - temporary buffer until a suffix is invoked. - -‘W c’ (‘magit-patch-create’) - This command creates patches for a set commits. If the region - marks several commits, then it creates patches for all of them. - Otherwise it functions as a transient prefix command, which - features several infix arguments and binds itself as a suffix - command. When this command is invoked as a suffix of itself, then - it creates a patch using the specified infix arguments. - -‘w a’ (‘magit-patch-apply’) - This command applies a patch. This is a transient prefix command, - which features several infix arguments and binds itself as a suffix - command. When this command is invoked as a suffix of itself, then - it applies a patch using the specified infix arguments. - -‘W s’ (‘magit-patch-save’) - This command creates a patch from the current diff. - - Inside ‘magit-diff-mode’ or ‘magit-revision-mode’ buffers, ‘C-x - C-w’ is also bound to this command. - - It is also possible to save a plain patch file by using ‘C-x C-w’ -inside a ‘magit-diff-mode’ or ‘magit-revision-mode’ buffer. - - -File: magit.info, Node: Maildir Patches, Prev: Plain Patches, Up: Transferring - -7.6 Maildir Patches -=================== - -Also see *note (gitman)git-am::. and *note (gitman)git-apply::. - -‘w’ (‘magit-am’) - This transient prefix command binds the following suffix commands - along with the appropriate infix arguments and displays them in a - temporary buffer until a suffix is invoked. - -‘w w’ (‘magit-am-apply-patches’) - This command applies one or more patches. If the region marks - files, then those are applied as patches. Otherwise this command - reads a file-name in the minibuffer, defaulting to the file at - point. - -‘w m’ (‘magit-am-apply-maildir’) - This command applies patches from a maildir. - -‘w a’ (‘magit-patch-apply’) - This command applies a plain patch. For a longer description see - *note Plain Patches::. This command is only available from the - ‘magit-am’ transient for historic reasons. - - When an "am" operation is in progress, then the transient instead -features the following suffix commands. - -‘w w’ (‘magit-am-continue’) - This command resumes the current patch applying sequence. - -‘w s’ (‘magit-am-skip’) - This command skips the stopped at patch during a patch applying - sequence. - -‘w a’ (‘magit-am-abort’) - This command aborts the current patch applying sequence. This - discards all changes made since the sequence started. - - -File: magit.info, Node: Miscellaneous, Next: Customizing, Prev: Transferring, Up: Top - -8 Miscellaneous -*************** - -* Menu: - -* Tagging:: -* Notes:: -* Submodules:: -* Subtree:: -* Worktree:: -* Sparse checkouts:: -* Bundle:: -* Common Commands:: -* Wip Modes:: -* Commands for Buffers Visiting Files:: -* Minor Mode for Buffers Visiting Blobs:: - - -File: magit.info, Node: Tagging, Next: Notes, Up: Miscellaneous - -8.1 Tagging -=========== - -Also see *note (gitman)git-tag::. - -‘t’ (‘magit-tag’) - This transient prefix command binds the following suffix commands - along with the appropriate infix arguments and displays them in a - temporary buffer until a suffix is invoked. - -‘t t’ (‘magit-tag-create’) - This command creates a new tag with the given NAME at REV. With a - prefix argument it creates an annotated tag. - -‘t r’ (‘magit-tag-release’) - This commands creates a release tag. It assumes that release tags - match ‘magit-release-tag-regexp’. - - First it prompts for the name of the new tag using the highest - existing tag as initial input and leaving it to the user to - increment the desired part of the version string. If you use - unconventional release tags or version numbers (e.g., - ‘v1.2.3-custom.1’), you can set the ‘magit-release-tag-regexp’ and - ‘magit-tag-version-regexp-alist’ variables. - - If ‘--annotate’ is enabled then it prompts for the message of the - new tag. The proposed tag message is based on the message of the - highest tag, provided that that contains the corresponding version - string and substituting the new version string for that. Otherwise - it proposes something like "Foo-Bar 1.2.3", given, for example, a - TAG "v1.2.3" and a repository located at something like - "/path/to/foo-bar". - -‘t k’ (‘magit-tag-delete’) - This command deletes one or more tags. If the region marks - multiple tags (and nothing else), then it offers to delete those. - Otherwise, it prompts for a single tag to be deleted, defaulting to - the tag at point. - -‘t p’ (‘magit-tag-prune’) - This command offers to delete tags missing locally from REMOTE, and - vice versa. - - -File: magit.info, Node: Notes, Next: Submodules, Prev: Tagging, Up: Miscellaneous - -8.2 Notes -========= - -Also see *note (gitman)git-notes::. - -‘T’ (‘magit-notes’) - This transient prefix command binds the following suffix commands - along with the appropriate infix arguments and displays them in a - temporary buffer until a suffix is invoked. - -‘T T’ (‘magit-notes-edit’) - Edit the note attached to a commit, defaulting to the commit at - point. - - By default use the value of Git variable ‘core.notesRef’ or - "refs/notes/commits" if that is undefined. - -‘T r’ (‘magit-notes-remove’) - Remove the note attached to a commit, defaulting to the commit at - point. - - By default use the value of Git variable ‘core.notesRef’ or - "refs/notes/commits" if that is undefined. - -‘T p’ (‘magit-notes-prune’) - Remove notes about unreachable commits. - - It is possible to merge one note ref into another. That may result -in conflicts which have to resolved in the temporary worktree -".git/NOTES_MERGE_WORKTREE". - -‘T m’ (‘magit-notes-merge’) - Merge the notes of a ref read from the user into the current notes - ref. The current notes ref is the value of Git variable - ‘core.notesRef’ or "refs/notes/commits" if that is undefined. - - When a notes merge is in progress then the transient features the -following suffix commands, instead of those listed above. - -‘T c’ (‘magit-notes-merge-commit’) - Commit the current notes ref merge, after manually resolving - conflicts. - -‘T a’ (‘magit-notes-merge-abort’) - Abort the current notes ref merge. - - The following variables control what notes reference ‘magit-notes-*’, -‘git notes’ and ‘git show’ act on and display. Both the local and -global values are displayed and can be modified. - - -- Variable: core.notesRef - This variable specifies the notes ref that is displayed by default - and which commands act on by default. - - -- Variable: notes.displayRef - This variable specifies additional notes ref to be displayed in - addition to the ref specified by ‘core.notesRef’. It can have - multiple values and may end with ‘*’ to display all refs in the - ‘refs/notes/’ namespace (or ‘**’ if some names contain slashes). - - -File: magit.info, Node: Submodules, Next: Subtree, Prev: Notes, Up: Miscellaneous - -8.3 Submodules -============== - -Also see *note (gitman)git-submodule::. - -* Menu: - -* Listing Submodules:: -* Submodule Transient:: - - -File: magit.info, Node: Listing Submodules, Next: Submodule Transient, Up: Submodules - -8.3.1 Listing Submodules ------------------------- - -The command ‘magit-list-submodules’ displays a list of the current -repository’s submodules in a separate buffer. It’s also possible to -display information about submodules directly in the status buffer of -the super-repository by adding ‘magit-insert-modules’ to the hook -‘magit-status-sections-hook’ as described in *note Status Module -Sections::. - - -- Command: magit-list-submodules - This command displays a list of the current repository’s populated - submodules in a separate buffer. - - It can be invoked by pressing ‘RET’ on the section titled - "Modules". - - -- User Option: magit-submodule-list-columns - This option controls what columns are displayed by the command - ‘magit-list-submodules’ and how they are displayed. - - Each element has the form ‘(HEADER WIDTH FORMAT PROPS)’. - - HEADER is the string displayed in the header. WIDTH is the width - of the column. FORMAT is a function that is called with one - argument, the repository identification (usually its basename), and - with ‘default-directory’ bound to the toplevel of its working tree. - It has to return a string to be inserted or nil. PROPS is an alist - that supports the keys ‘:right-align’, ‘:pad-right’ and ‘:sort’. - - The ‘:sort’ function has a weird interface described in the - docstring of ‘tabulated-list--get-sort’. Alternatively ‘<’ and - ‘magit-repolist-version<’ can be used as those functions are - automatically replaced with functions that satisfy the interface. - Set ‘:sort’ to ‘nil’ to inhibit sorting; if unspecified, then the - column is sortable using the default sorter. - - You may wish to display a range of numeric columns using just one - character per column and without any padding between columns, in - which case you should use an appropriate HEADER, set WIDTH to 1, - and set ‘:pad-right’ to 9. ‘+’ is substituted for numbers higher - than 9. - - -File: magit.info, Node: Submodule Transient, Prev: Listing Submodules, Up: Submodules - -8.3.2 Submodule Transient -------------------------- - -‘o’ (‘magit-submodule’) - This transient prefix command binds the following suffix commands - along with the appropriate infix arguments and displays them in a - temporary buffer until a suffix is invoked. - - Some of the below commands default to act on the modules that are -selected using the region. For brevity their description talk about -"the selected modules", but if no modules are selected, then they act on -the current module instead, or if point isn’t on a module, then the read -a single module to act on. With a prefix argument these commands ignore -the selection and the current module and instead act on all suitable -modules. - -‘o a’ (‘magit-submodule-add’) - This commands adds the repository at URL as a module. Optional - PATH is the path to the module relative to the root of the - super-project. If it is nil then the path is determined based on - URL. - -‘o r’ (‘magit-submodule-register’) - This command registers the selected modules by copying their urls - from ".gitmodules" to "$GIT_DIR/config". These values can then be - edited before running ‘magit-submodule-populate’. If you don’t - need to edit any urls, then use the latter directly. - -‘o p’ (‘magit-submodule-populate’) - This command creates the working directory or directories of the - selected modules, checking out the recorded commits. - -‘o u’ (‘magit-submodule-update’) - This command updates the selected modules checking out the recorded - commits. - -‘o s’ (‘magit-submodule-synchronize’) - This command synchronizes the urls of the selected modules, copying - the values from ".gitmodules" to the ".git/config" of the - super-project as well those of the modules. - -‘o d’ (‘magit-submodule-unpopulate’) - This command removes the working directory of the selected modules. - -‘o l’ (‘magit-list-submodules’) - This command displays a list of the current repository’s modules. - -‘o f’ (‘magit-fetch-modules’) - This command fetches all populated modules. - - Option ‘magit-fetch-modules-jobs’ controls how many submodules are - being fetched in parallel. Also fetch the super-repository, - because ‘git fetch’ does not support not doing that. With a prefix - argument fetch all remotes. - - -File: magit.info, Node: Subtree, Next: Worktree, Prev: Submodules, Up: Miscellaneous - -8.4 Subtree -=========== - -Also see *note (gitman)git-subtree::. - -‘O’ (‘magit-subtree’) - This transient prefix command binds the two sub-transients; one for - importing a subtree and one for exporting a subtree. - -‘O i’ (‘magit-subtree-import’) - This transient prefix command binds the following suffix commands - along with the appropriate infix arguments and displays them in a - temporary buffer until a suffix is invoked. - - The suffixes of this command import subtrees. - - If the ‘--prefix’ argument is set, then the suffix commands use - that prefix without prompting the user. If it is unset, then they - read the prefix in the minibuffer. - -‘O i a’ (‘magit-subtree-add’) - This command adds COMMIT from REPOSITORY as a new subtree at - PREFIX. - -‘O i c’ (‘magit-subtree-add-commit’) - This command add COMMIT as a new subtree at PREFIX. - -‘O i m’ (‘magit-subtree-merge’) - This command merges COMMIT into the PREFIX subtree. - -‘O i f’ (‘magit-subtree-pull’) - This command pulls COMMIT from REPOSITORY into the PREFIX subtree. - -‘O e’ (‘magit-subtree-export’) - This transient prefix command binds the following suffix commands - along with the appropriate infix arguments and displays them in a - temporary buffer until a suffix is invoked. - - The suffixes of this command export subtrees. - - If the ‘--prefix’ argument is set, then the suffix commands use - that prefix without prompting the user. If it is unset, then they - read the prefix in the minibuffer. - -‘O e p’ (‘magit-subtree-push’) - This command extract the history of the subtree PREFIX and pushes - it to REF on REPOSITORY. - -‘O e s’ (‘magit-subtree-split’) - This command extracts the history of the subtree PREFIX. - - -File: magit.info, Node: Worktree, Next: Sparse checkouts, Prev: Subtree, Up: Miscellaneous - -8.5 Worktree -============ - -Also see *note (gitman)git-worktree::. - -‘Z’ (‘magit-worktree’) - This transient prefix command binds the following suffix commands - and displays them in a temporary buffer until a suffix is invoked. - -‘Z b’ (‘magit-worktree-checkout’) - Checkout BRANCH in a new worktree at PATH. - -‘Z c’ (‘magit-worktree-branch’) - Create a new BRANCH and check it out in a new worktree at PATH. - -‘Z m’ (‘magit-worktree-move’) - Move an existing worktree to a new PATH. - -‘Z k’ (‘magit-worktree-delete’) - Delete a worktree, defaulting to the worktree at point. The - primary worktree cannot be deleted. - -‘Z g’ (‘magit-worktree-status’) - Show the status for the worktree at point. - - If there is no worktree at point, then read one in the minibuffer. - If the worktree at point is the one whose status is already being - displayed in the current buffer, then show it in Dired instead. - - -File: magit.info, Node: Sparse checkouts, Next: Bundle, Prev: Worktree, Up: Miscellaneous - -8.6 Sparse checkouts -==================== - -Sparse checkouts provide a way to restrict the working tree to a subset -of directories. See *note (gitman)git-sparse-checkout::. - - *Warning*: Git introduced the ‘git sparse-checkout’ command in -version 2.25 and still advertises it as experimental and subject to -change. Magit’s interface should be considered the same. In -particular, if Git introduces a backward incompatible change, Magit’s -sparse checkout functionality may be updated in a way that requires a -more recent Git version. - -‘>’ (‘magit-sparse-checkout’) - This transient prefix command binds the following suffix commands - and displays them in a temporary buffer until a suffix is invoked. - -‘> e’ (‘magit-sparse-checkout-enable’) - This command initializes a sparse checkout that includes only the - files in the top-level directory. - - Note that ‘magit-sparse-checkout-set’ and - ‘magit-sparse-checkout-add’ automatically initialize a sparse - checkout if necessary. However, you may want to call - ‘magit-sparse-checkout-enable’ explicitly to re-initialize a sparse - checkout after calling ‘magit-sparse-checkout-disable’, to pass - additional arguments to ‘git sparse-checkout init’, or to execute - the initialization asynchronously. - -‘> s’ (‘magit-sparse-checkout-set’) - This command takes a list of directories and configures the sparse - checkout to include only files in those subdirectories. Any - previously included directories are excluded unless they are in the - provided list of directories. - -‘> a’ (‘magit-sparse-checkout-add’) - This command is like ‘magit-sparse-checkout-set’, but instead adds - the specified list of directories to the set of directories that is - already included in the sparse checkout. - -‘> r’ (‘magit-sparse-checkout-reapply’) - This command applies the currently configured sparse checkout - patterns to the working tree. This is useful to call if excluded - files have been checked out after operations such as merging or - rebasing. - -‘> d’ (‘magit-sparse-checkout-disable’) - This command restores the full checkout. To return to the previous - sparse checkout, call ‘magit-sparse-checkout-enable’. - - A sparse checkout can also be initiated when cloning a repository by -using the ‘magit-clone-sparse’ command in the ‘magit-clone’ transient -(see *note Cloning Repository::). - - If you want the status buffer to indicate when a sparse checkout is -enabled, add the function ‘magit-sparse-checkout-insert-header’ to -‘magit-status-headers-hook’. - - -File: magit.info, Node: Bundle, Next: Common Commands, Prev: Sparse checkouts, Up: Miscellaneous - -8.7 Bundle -========== - -Also see *note (gitman)git-bundle::. - - -- Command: magit-bundle - This transient prefix command binds several suffix commands for - running ‘git bundle’ subcommands and displays them in a temporary - buffer until a suffix is invoked. - - -File: magit.info, Node: Common Commands, Next: Wip Modes, Prev: Bundle, Up: Miscellaneous - -8.8 Common Commands -=================== - - -- Command: magit-switch-to-repository-buffer - -- Command: magit-switch-to-repository-buffer-other-window - -- Command: magit-switch-to-repository-buffer-other-frame - -- Command: magit-display-repository-buffer - These commands read any existing Magit buffer that belongs to the - current repository from the user and then switch to the selected - buffer (without refreshing it). - - The last variant uses ‘magit-display-buffer’ to do so and thus - respects ‘magit-display-buffer-function’. - - These are some of the commands that can be used in all buffers whose -major-modes derive from ‘magit-mode’. There are other common commands -beside the ones below, but these didn’t fit well anywhere else. - -‘C-w’ (‘magit-copy-section-value’) - This command saves the value of the current section to the - ‘kill-ring’, and, provided that the current section is a commit, - branch, or tag section, it also pushes the (referenced) revision to - the ‘magit-revision-stack’. - - When the current section is a branch or a tag, and a prefix - argument is used, then it saves the revision at its tip to the - ‘kill-ring’ instead of the reference name. - - When the region is active, this command saves that to the - ‘kill-ring’, like ‘kill-ring-save’ would, instead of behaving as - described above. If a prefix argument is used and the region is - within a hunk, then it strips the diff marker column and keeps only - either the added or removed lines, depending on the sign of the - prefix argument. - -‘M-w’ (‘magit-copy-buffer-revision’) - This command saves the revision being displayed in the current - buffer to the ‘kill-ring’ and also pushes it to the - ‘magit-revision-stack’. It is mainly intended for use in - ‘magit-revision-mode’ buffers, the only buffers where it is always - unambiguous exactly which revision should be saved. - - Most other Magit buffers usually show more than one revision, in - some way or another, so this command has to select one of them, and - that choice might not always be the one you think would have been - the best pick. - - Outside of Magit ‘M-w’ and ‘C-w’ are usually bound to -‘kill-ring-save’ and ‘kill-region’, and these commands would also be -useful in Magit buffers. Therefore when the region is active, then both -of these commands behave like ‘kill-ring-save’ instead of as described -above. - - -File: magit.info, Node: Wip Modes, Next: Commands for Buffers Visiting Files, Prev: Common Commands, Up: Miscellaneous - -8.9 Wip Modes -============= - -Git keeps *committed* changes around long enough for users to recover -changes they have accidentally deleted. It does so by not garbage -collecting any committed but no longer referenced objects for a certain -period of time, by default 30 days. - - But Git does *not* keep track of *uncommitted* changes in the working -tree and not even the index (the staging area). Because Magit makes it -so convenient to modify uncommitted changes, it also makes it easy to -shoot yourself in the foot in the process. - - For that reason Magit provides a global mode that saves *tracked* -files to work-in-progress references after or before certain actions. -(At present untracked files are never saved and for technical reasons -nothing is saved before the first commit has been created). - - Two separate work-in-progress references are used to track the state -of the index and of the working tree: ‘refs/wip/index/<branchref>’ and -‘refs/wip/wtree/<branchref>’, where ‘<branchref>’ is the full ref of the -current branch, e.g., ‘refs/heads/master’. When the ‘HEAD’ is detached -then ‘HEAD’ is used in place of ‘<branchref>’. - - Checking out another branch (or detaching ‘HEAD’) causes the use of -different wip refs for subsequent changes. - - -- User Option: magit-wip-mode - When this mode is enabled, then uncommitted changes are committed - to dedicated work-in-progress refs whenever appropriate (i.e., when - dataloss would be a possibility otherwise). - - Setting this variable directly does not take effect; either use the - Custom interface to do so or call the respective mode function. - - For historic reasons this mode is implemented on top of four other - ‘magit-wip-*’ modes, which can also be used individually, if you - want finer control over when the wip refs are updated; but that is - discouraged. See *note Legacy Wip Modes::. - - To view the log for a branch and its wip refs use the commands -‘magit-wip-log’ and ‘magit-wip-log-current’. You should use ‘--graph’ -when using these commands. - - -- Command: magit-wip-log - This command shows the log for a branch and its wip refs. With a - negative prefix argument only the worktree wip ref is shown. - - The absolute numeric value of the prefix argument controls how many - "branches" of each wip ref are shown. This is only relevant if the - value of ‘magit-wip-merge-branch’ is ‘nil’. - - -- Command: magit-wip-log-current - This command shows the log for the current branch and its wip refs. - With a negative prefix argument only the worktree wip ref is shown. - - The absolute numeric value of the prefix argument controls how many - "branches" of each wip ref are shown. This is only relevant if the - value of ‘magit-wip-merge-branch’ is ‘nil’. - -‘X w’ (‘magit-reset-worktree’) - This command resets the working tree to some commit read from the - user and defaulting to the commit at point, while keeping the - ‘HEAD’ and index as-is. - - This can be used to restore files to the state committed to a wip - ref. Note that this will discard any unstaged changes that might - have existed before invoking this command (but of course only after - committing that to the working tree wip ref). - - Note that even if you enable ‘magit-wip-mode’ this won’t give you -perfect protection. The most likely scenario for losing changes despite -the use of ‘magit-wip-mode’ is making a change outside Emacs and then -destroying it also outside Emacs. In some such a scenario, Magit, being -an Emacs package, didn’t get the opportunity to keep you from shooting -yourself in the foot. - - When you are unsure whether Magit did commit a change to the wip -refs, then you can explicitly request that all changes to all tracked -files are being committed. - -‘M-x magit-wip-commit’ - This command commits all changes to all tracked files to the index - and working tree work-in-progress refs. Like the modes described - above, it does not commit untracked files, but it does check all - tracked files for changes. Use this command when you suspect that - the modes might have overlooked a change made outside Emacs/Magit. - - -- User Option: magit-wip-namespace - The namespace used for work-in-progress refs. It has to end with a - slash. The wip refs are named ‘<namespace>index/<branchref>’ and - ‘<namespace>wtree/<branchref>’. When snapshots are created while - the ‘HEAD’ is detached then ‘HEAD’ is used in place of - ‘<branchref>’. - - -- User Option: magit-wip-mode-lighter - Mode-line lighter for ‘magit-wip--mode’. - -* Menu: - -* Wip Graph:: -* Legacy Wip Modes:: - - -File: magit.info, Node: Wip Graph, Next: Legacy Wip Modes, Up: Wip Modes - -8.9.1 Wip Graph ---------------- - - -- User Option: magit-wip-merge-branch - This option controls whether the current branch is merged into the - wip refs after a new commit was created on the branch. - - If non-nil and the current branch has new commits, then it is - merged into the wip ref before creating a new wip commit. This - makes it easier to inspect wip history and the wip commits are - never garbage collected. - - If nil and the current branch has new commits, then the wip ref is - reset to the tip of the branch before creating a new wip commit. - With this setting wip commits are eventually garbage collected. - - When ‘magit-wip-merge-branch’ is ‘t’, then the history looks like -this: - - *--*--*--*--*--* refs/wip/index/refs/heads/master - / / / - A-----B-----C refs/heads/master - - When ‘magit-wip-merge-branch’ is ‘nil’, then creating a commit on the -real branch and then making a change causes the wip refs to be recreated -to fork from the new commit. But the old commits on the wip refs are -not lost. They are still available from the reflog. To make it easier -to see when the fork point of a wip ref was changed, an additional -commit with the message "restart autosaving" is created on it (‘xxO’ -commits below are such boundary commits). - - Starting with - - BI0---BI1 refs/wip/index/refs/heads/master - / - A---B refs/heads/master - \ - BW0---BW1 refs/wip/wtree/refs/heads/master - - and committing the staged changes and editing and saving a file would -result in - - BI0---BI1 refs/wip/index/refs/heads/master - / - A---B---C refs/heads/master - \ \ - \ CW0---CW1 refs/wip/wtree/refs/heads/master - \ - BW0---BW1 refs/wip/wtree/refs/heads/master@{2} - - The fork-point of the index wip ref is not changed until some change -is being staged. Likewise just checking out a branch or creating a -commit does not change the fork-point of the working tree wip ref. The -fork-points are not adjusted until there actually is a change that -should be committed to the respective wip ref. - - -File: magit.info, Node: Legacy Wip Modes, Prev: Wip Graph, Up: Wip Modes - -8.9.2 Legacy Wip Modes ----------------------- - -It is recommended that you use the mode ‘magit-wip-mode’ (which see) and -ignore the existence of the following modes, which are preserved for -historic reasons. - - Setting the following variables directly does not take effect; either -use the Custom interface to do so or call the respective mode functions. - - -- User Option: magit-wip-after-save-mode - When this mode is enabled, then saving a buffer that visits a file - tracked in a Git repository causes its current state to be - committed to the working tree wip ref for the current branch. - - -- User Option: magit-wip-after-apply-mode - When this mode is enabled, then applying (i.e., staging, unstaging, - discarding, reversing, and regularly applying) a change to a file - tracked in a Git repository causes its current state to be - committed to the index and/or working tree wip refs for the current - branch. - - If you only ever edit files using Emacs and only ever interact with -Git using Magit, then the above two modes should be enough to protect -each and every change from accidental loss. In practice nobody does -that. Two additional modes exists that do commit to the wip refs before -making changes that could cause the loss of earlier changes. - - -- User Option: magit-wip-before-change-mode - When this mode is enabled, then certain commands commit the - existing changes to the files they are about to make changes to. - - -- User Option: magit-wip-initial-backup-mode - When this mode is enabled, then the current version of a file is - committed to the worktree wip ref before the buffer visiting that - file is saved for the first time since the buffer was created. - - This backs up the same version of the file that ‘backup-buffer’ - would save. While ‘backup-buffer’ uses a backup file, this mode - uses the same worktree wip ref as used by the other Magit Wip - modes. Like ‘backup-buffer’, it only does this once; unless you - kill the buffer and visit the file again only one backup will be - created per Emacs session. - - This mode ignores the variables that affect ‘backup-buffer’ and can - be used along-side that function, which is recommended because it - only backs up files that are tracked in a Git repository. - - -- User Option: magit-wip-after-save-local-mode-lighter - Mode-line lighter for ‘magit-wip-after-save-local-mode’. - - -- User Option: magit-wip-after-apply-mode-lighter - Mode-line lighter for ‘magit-wip-after-apply-mode’. - - -- User Option: magit-wip-before-change-mode-lighter - Mode-line lighter for ‘magit-wip-before-change-mode’. - - -- User Option: magit-wip-initial-backup-mode-lighter - Mode-line lighter for ‘magit-wip-initial-backup-mode’. - - -File: magit.info, Node: Commands for Buffers Visiting Files, Next: Minor Mode for Buffers Visiting Blobs, Prev: Wip Modes, Up: Miscellaneous - -8.10 Commands for Buffers Visiting Files -======================================== - -By default Magit defines a few global key bindings. These bindings are -a compromise between providing no bindings at all and providing the -better bindings I would have liked to use instead. Magit cannot provide -the set of recommended bindings by default because those key sequences -are strictly reserved for bindings added by the user. Also see *note -Global Bindings:: and *note (elisp)Key Binding Conventions::. - - To use the recommended bindings, add this to your init file and -restart Emacs. - - (setq magit-define-global-key-bindings 'recommended) - - If you don’t want Magit to add any bindings to the global keymap at -all, add this to your init file and restart Emacs. - - (setq magit-define-global-key-bindings nil) - -‘C-c f’ (‘magit-file-dispatch’) -‘C-c f s’ (‘magit-stage-file’) -‘C-c f s’ (‘magit-stage-buffer-file’) -‘C-c f u’ (‘magit-unstage-file’) -‘C-c f u’ (‘magit-unstage-buffer-file’) -‘C-c f , x’ (‘magit-file-untrack’) -‘C-c f , r’ (‘magit-file-rename’) -‘C-c f , k’ (‘magit-file-delete’) -‘C-c f , c’ (‘magit-file-checkout’) -‘C-c f D’ (‘magit-diff’) -‘C-c f d’ (‘magit-diff-buffer-file’) -‘C-c f L’ (‘magit-log’) -‘C-c f l’ (‘magit-log-buffer-file’) -‘C-c f t’ (‘magit-log-trace-definition’) -‘C-c f M’ (‘magit-log-merged’) -‘C-c f B’ (‘magit-blame’) -‘C-c f b’ (‘magit-blame-additions’) -‘C-c f r’ (‘magit-blame-removal’) -‘C-c f f’ (‘magit-blame-reverse’) -‘C-c f m’ (‘magit-blame-echo’) -‘C-c f q’ (‘magit-blame-quit’) -‘C-c f p’ (‘magit-blob-previous’) -‘C-c f n’ (‘magit-blob-next’) -‘C-c f v’ (‘magit-find-file’) -‘C-c f V’ (‘magit-blob-visit-file’) -‘C-c f g’ (‘magit-status-here’) -‘C-c f G’ (‘magit-display-repository-buffer’) -‘C-c f c’ (‘magit-commit’) -‘C-c f e’ (‘magit-edit-line-commit’) - Each of these commands is documented individually right below, - alongside their default key bindings. The bindings shown above are - the recommended bindings, which you can enable by following the - instructions further up. - -‘C-c M-g’ (‘magit-file-dispatch’) - This transient prefix command binds the following suffix commands - and displays them in a temporary buffer until a suffix is invoked. - -‘C-c M-g s’ (‘magit-stage-file’) -‘C-c M-g s’ (‘magit-stage-buffer-file’) - Stage all changes to the file being visited in the current buffer. - When not visiting a file, then the first command is used, which - prompts for a file. - -‘C-c M-g u’ (‘magit-unstage-file’) -‘C-c M-g u’ (‘magit-unstage-buffer-file’) - Unstage all changes to the file being visited in the current - buffer. When not visiting a file, then the first command is used, - which prompts for a file. - -‘C-c M-g , x’ (‘magit-file-untrack’) - This command untracks a file read from the user, defaulting to the - visited file. - -‘C-c M-g , r’ (‘magit-file-rename’) - This command renames a file read from the user, defaulting to the - visited file. - -‘C-c M-g , k’ (‘magit-file-delete’) - This command deletes a file read from the user, defaulting to the - visited file. - -‘C-c M-g , c’ (‘magit-file-checkout’) - This command updates a file in the working tree and index to the - contents from a revision. Both the revision and file are read from - the user. - -‘C-c M-g D’ (‘magit-diff’) - This transient prefix command binds several diff suffix commands - and infix arguments and displays them in a temporary buffer until a - suffix is invoked. See *note Diffing::. - - This is the same command that ‘d’ is bound to in Magit buffers. If - this command is invoked from a file-visiting buffer, then the - initial value of the option (‘--’) that limits the diff to certain - file(s) is set to the visited file. - -‘C-c M-g d’ (‘magit-diff-buffer-file’) - This command shows the diff for the file of blob that the current - buffer visits. - - -- User Option: magit-diff-buffer-file-locked - This option controls whether ‘magit-diff-buffer-file’ uses a - dedicated buffer. See *note Modes and Buffers::. - -‘C-c M-g L’ (‘magit-log’) - This transient prefix command binds several log suffix commands and - infix arguments and displays them in a temporary buffer until a - suffix is invoked. See *note Logging::. - - This is the same command that ‘l’ is bound to in Magit buffers. If - this command is invoked from a file-visiting buffer, then the - initial value of the option (‘--’) that limits the log to certain - file(s) is set to the visited file. - -‘C-c M-g l’ (‘magit-log-buffer-file’) - This command shows the log for the file of blob that the current - buffer visits. Renames are followed when a prefix argument is used - or when ‘--follow’ is an active log argument. When the region is - active, the log is restricted to the selected line range. - - -- User Option: magit-log-buffer-file-locked - This option controls whether ‘magit-log-buffer-file’ uses a - dedicated buffer. See *note Modes and Buffers::. - -‘C-c M-g t’ (‘magit-log-trace-definition’) - This command shows the log for the definition at point. - -‘C-c M-g M’ (‘magit-log-merged’) - This command reads a commit and a branch in shows a log concerning - the merge of the former into the latter. This shows multiple - commits even in case of a fast-forward merge. - -‘C-c M-g B’ (‘magit-blame’) - This transient prefix command binds all blaming suffix commands - along with the appropriate infix arguments and displays them in a - temporary buffer until a suffix is invoked. - - For more information about this and the following commands also see - *note Blaming::. - - In addition to the ‘magit-blame’ sub-transient, the dispatch - transient also binds several blaming suffix commands directly. See - *note Blaming:: for information about those commands and bindings. - -‘C-c M-g p’ (‘magit-blob-previous’) - This command visits the previous blob which modified the current - file. - -‘C-c M-g n’ (‘magit-blob-next’) - This command visits the next blob which modified the current file. - -‘C-c M-g v’ (‘magit-find-file’) - This command reads a revision and file and visits the respective - blob. - -‘C-c M-g V’ (‘magit-blob-visit-file’) - This command visits the file from the working tree, corresponding - to the current blob. When visiting a blob or the version from the - index, then it goes to the same location in the respective file in - the working tree. - -‘C-c M-g g’ (‘magit-status-here’) - This command displays the status of the current repository in a - buffer, like ‘magit-status’ does. Additionally it tries to go to - the position in that buffer, which corresponds to the position in - the current file-visiting buffer (if any). - -‘C-c M-g G’ (‘magit-display-repository-buffer’) - This command reads and displays a Magit buffer belonging to the - current repository, without refreshing it. - -‘C-c M-g c’ (‘magit-commit’) - This transient prefix command binds the following suffix commands - along with the appropriate infix arguments and displays them in a - temporary buffer until a suffix is invoked. See *note Initiating a - Commit::. - -‘C-c M-g e’ (‘magit-edit-line-commit’) - This command makes the commit editable that added the current line. - - With a prefix argument it makes the commit editable that removes - the line, if any. The commit is determined using ‘git blame’ and - made editable using ‘git rebase --interactive’ if it is reachable - from ‘HEAD’, or by checking out the commit (or a branch that points - at it) otherwise. - - -File: magit.info, Node: Minor Mode for Buffers Visiting Blobs, Prev: Commands for Buffers Visiting Files, Up: Miscellaneous - -8.11 Minor Mode for Buffers Visiting Blobs -========================================== - -The ‘magit-blob-mode’ enables certain Magit features in blob-visiting -buffers. Such buffers can be created using ‘magit-find-file’ and some -of the commands mentioned below, which also take care of turning on this -minor mode. Currently this mode only establishes a few key bindings, -but this might be extended. - -‘p’ (‘magit-blob-previous’) - Visit the previous blob which modified the current file. - -‘n’ (‘magit-blob-next’) - Visit the next blob which modified the current file. - -‘q’ (‘magit-kill-this-buffer’) - Kill the current buffer. - - -File: magit.info, Node: Customizing, Next: Plumbing, Prev: Miscellaneous, Up: Top - -9 Customizing -************* - -Both Git and Emacs are highly customizable. Magit is both a Git -porcelain as well as an Emacs package, so it makes sense to customize it -using both Git variables as well as Emacs options. However this -flexibility doesn’t come without problems, including but not limited to -the following. - - • Some Git variables automatically have an effect in Magit without - requiring any explicit support. Sometimes that is desirable - in - other cases, it breaks Magit. - - When a certain Git setting breaks Magit but you want to keep using - that setting on the command line, then that can be accomplished by - overriding the value for Magit only by appending something like - ‘("-c" "some.variable=compatible-value")’ to - ‘magit-git-global-arguments’. - - • Certain settings like ‘fetch.prune=true’ are respected by Magit - commands (because they simply call the respective Git command) but - their value is not reflected in the respective transient buffers. - In this case the ‘--prune’ argument in ‘magit-fetch’ might be - active or inactive, but that doesn’t keep the Git variable from - being honored by the suffix commands anyway. So pruning might - happen despite the ‘--prune’ arguments being displayed in a way - that seems to indicate that no pruning will happen. - - I intend to address these and similar issues in a future release. - -* Menu: - -* Per-Repository Configuration:: -* Essential Settings:: - - -File: magit.info, Node: Per-Repository Configuration, Next: Essential Settings, Up: Customizing - -9.1 Per-Repository Configuration -================================ - -Magit can be configured on a per-repository level using both Git -variables as well as Emacs options. - - To set a Git variable for one repository only, simply set it in -‘/path/to/repo/.git/config’ instead of ‘$HOME/.gitconfig’ or -‘/etc/gitconfig’. See *note (gitman)git-config::. - - Similarly, Emacs options can be set for one repository only by -editing ‘/path/to/repo/.dir-locals.el’. See *note (emacs)Directory -Variables::. For example to disable automatic refreshes of -file-visiting buffers in just one huge repository use this: - - • ‘/path/to/huge/repo/.dir-locals.el’ - - ((nil . ((magit-refresh-buffers . nil)))) - - It might only be costly to insert certain information into Magit -buffers for repositories that are exceptionally large, in which case you -can disable the respective section inserters just for that repository: - - • ‘/path/to/tag/invested/repo/.dir-locals.el’ - - ((magit-status-mode - . ((eval . (magit-disable-section-inserter 'magit-insert-tags-header))))) - - -- Function: magit-disable-section-inserter fn - This function disables the section inserter FN in the current - repository. It is only intended for use in ‘.dir-locals.el’ and - ‘.dir-locals-2.el’. - - If you want to apply the same settings to several, but not all, -repositories then keeping the repository-local config files in sync -would quickly become annoying. To avoid that you can create config -files for certain classes of repositories (e.g., "huge repositories") -and then include those files in the per-repository config files. For -example: - - • ‘/path/to/huge/repo/.git/config’ - - [include] - path = /path/to/huge-gitconfig - - • ‘/path/to/huge-gitconfig’ - - [status] - showUntrackedFiles = no - - • ‘$HOME/.emacs.d/init.el’ - - (dir-locals-set-class-variables 'huge-git-repository - '((nil . ((magit-refresh-buffers . nil))))) - - (dir-locals-set-directory-class - "/path/to/huge/repo/" 'huge-git-repository) - - -File: magit.info, Node: Essential Settings, Prev: Per-Repository Configuration, Up: Customizing - -9.2 Essential Settings -====================== - -The next three sections list and discuss several variables that many -users might want to customize, for safety and/or performance reasons. - -* Menu: - -* Safety:: -* Performance:: -* Global Bindings:: - - -File: magit.info, Node: Safety, Next: Performance, Up: Essential Settings - -9.2.1 Safety ------------- - -This section discusses various variables that you might want to change -(or *not* change) for safety reasons. - - Git keeps *committed* changes around long enough for users to recover -changes they have accidentally been deleted. It does not do the same -for *uncommitted* changes in the working tree and not even the index -(the staging area). Because Magit makes it so easy to modify -uncommitted changes, it also makes it easy to shoot yourself in the foot -in the process. For that reason Magit provides three global modes that -save *tracked* files to work-in-progress references after or before -certain actions. See *note Wip Modes::. - - These modes are not enabled by default because of performance -concerns. Instead a lot of potentially destructive commands require -confirmation every time they are used. In many cases this can be -disabled by adding a symbol to ‘magit-no-confirm’ (see *note Completion -and Confirmation::). If you enable the various wip modes then you -should add ‘safe-with-wip’ to this list. - - Similarly it isn’t necessary to require confirmation before moving a -file to the system trash - if you trashed a file by mistake then you can -recover it from there. Option ‘magit-delete-by-moving-to-trash’ -controls whether the system trash is used, which is the case by default. -Nevertheless, ‘trash’ isn’t a member of ‘magit-no-confirm’ - you might -want to change that. - - By default buffers visiting files are automatically reverted when the -visited file changes on disk. This isn’t as risky as it might seem, but -to make an informed decision you should see *note Risk of Reverting -Automatically::. - - -File: magit.info, Node: Performance, Next: Global Bindings, Prev: Safety, Up: Essential Settings - -9.2.2 Performance ------------------ - -After Magit has run ‘git’ for side-effects, it also refreshes the -current Magit buffer and the respective status buffer. This is -necessary because otherwise outdated information might be displayed -without the user noticing. Magit buffers are updated by recreating -their content from scratch, which makes updating simpler and less -error-prone, but also more costly. Keeping it simple and just -re-creating everything from scratch is an old design decision and -departing from that will require major refactoring. - - Meanwhile you can tell Magit to only automatically refresh the -current Magit buffer, but not the status buffer. If you do that, then -the status buffer is only refreshed automatically if it is the current -buffer. - - (setq magit-refresh-status-buffer nil) - - You should also check whether any third-party packages have added -anything to ‘magit-refresh-buffer-hook’, ‘magit-pre-refresh-hook’, and -‘magit-post-refresh-hook’. If so, then check whether those additions -impact performance significantly. - - Magit can be told to refresh buffers verbosely using ‘M-x -magit-toggle-verbose-refresh’. Enabling this helps figuring out which -sections are bottlenecks. Each line printed to the ‘*Messages*’ buffer -contains a section name, the number of seconds it took to show this -section, and from 0 to 2 exclamation marks: the more exclamation marks -the slower the section is. - - Magit also reverts buffers for visited files located inside the -current repository when the visited file changes on disk. That is -implemented on top of ‘auto-revert-mode’ from the built-in library -‘autorevert’. To figure out whether that impacts performance, check -whether performance is significantly worse, when many buffers exist -and/or when some buffers visit files using TRAMP. If so, then this -should help. - - (setq auto-revert-buffer-list-filter - 'magit-auto-revert-repository-buffer-p) - - For alternative approaches see *note Automatic Reverting of -File-Visiting Buffers::. - - If you have enabled any features that are disabled by default, then -you should check whether they impact performance significantly. It’s -likely that they were not enabled by default because it is known that -they reduce performance at least in large repositories. - - If performance is only slow inside certain unusually large -repositories, then you might want to disable certain features on a -per-repository or per-repository-class basis only. See *note -Per-Repository Configuration::. For example it takes a long time to -determine the next and current tag in repository with exceptional -numbers of tags. It would therefore be a good idea to disable -‘magit-insert-tags-headers’, as explained at the mentioned node. - -* Menu: - -* Microsoft Windows Performance:: -* MacOS Performance:: - -Log Performance -............... - -When showing logs, Magit limits the number of commits initially shown in -the hope that this avoids unnecessary work. When ‘--graph’ is used, -then this unfortunately does not have the desired effect for large -histories. Junio, Git’s maintainer, said on the git mailing list -(<https://www.spinics.net/lists/git/msg232230.html>): "‘--graph’ wants -to compute the whole history and the max-count only affects the output -phase after ‘--graph’ does its computation". - - In other words, it’s not that Git is slow at outputting the -differences, or that Magit is slow at parsing the output - the problem -is that Git first goes outside and has a smoke. - - We actually work around this issue by limiting the number of commits -not only by using ‘-<N>’ but by also using a range. But unfortunately -that’s not always possible. - - When more than a few thousand commits are shown, then the use of -‘--graph’ can slow things down. - - Using ‘--color --graph’ is even slower. Magit uses code that is part -of Emacs to turn control characters into faces. That code is pretty -slow and this is quite noticeable when showing a log with many branches -and merges. For that reason ‘--color’ is not enabled by default -anymore. Consider leaving it at that. - -Diff Performance -................ - -If diffs are slow, then consider turning off some optional diff features -by setting all or some of the following variables to ‘nil’: -‘magit-diff-highlight-indentation’, ‘magit-diff-highlight-trailing’, -‘magit-diff-paint-whitespace’, ‘magit-diff-highlight-hunk-body’, and -‘magit-diff-refine-hunk’. - - When showing a commit instead of some arbitrary diff, then some -additional information is displayed. Calculating this information can -be quite expensive given certain circumstances. If looking at a commit -using ‘magit-revision-mode’ takes considerably more time than looking at -the same commit in ‘magit-diff-mode’, then consider setting -‘magit-revision-insert-related-refs’ to ‘nil’. - - When you are often confronted with diffs that contain deleted files, -then you might want to enable the ‘--irreversible-delete’ argument. If -you do that then diffs still show that a file was deleted but without -also showing the complete deleted content of the file. This argument is -not available by default, see *note (transient)Enabling and Disabling -Suffixes::. Once you have done that you should enable it and save that -setting, see *note (transient)Saving Values::. You should do this in -both the diff (‘d’) and the diff refresh (‘D’) transient popups. - -Refs Buffer Performance -....................... - -When refreshing the "references buffer" is slow, then that’s usually -because several hundred refs are being displayed. The best way to -address that is to display fewer refs, obviously. - - If you are not, or only mildly, interested in seeing the list of -tags, then start by not displaying them: - - (remove-hook 'magit-refs-sections-hook 'magit-insert-tags) - - Then you should also make sure that the listed remote branches -actually all exist. You can do so by pruning branches which no longer -exist using ‘f-pa’. - -Committing Performance -...................... - -When you initiate a commit, then Magit by default automatically shows a -diff of the changes you are about to commit. For large commits this can -take a long time, which is especially distracting when you are -committing large amounts of generated data which you don’t actually -intend to inspect before committing. This behavior can be turned off -using: - - (remove-hook 'server-switch-hook 'magit-commit-diff) - (remove-hook 'with-editor-filter-visit-hook 'magit-commit-diff) - - Then you can type ‘C-c C-d’ to show the diff when you actually want -to see it, but only then. Alternatively you can leave the hook alone -and just type ‘C-g’ in those cases when it takes too long to generate -the diff. If you do that, then you will end up with a broken diff -buffer, but doing it this way has the advantage that you usually get to -see the diff, which is useful because it increases the odds that you -spot potential issues. - - -File: magit.info, Node: Microsoft Windows Performance, Next: MacOS Performance, Up: Performance - -Microsoft Windows Performance -............................. - -In order to update the status buffer, ‘git’ has to be run a few dozen -times. That is problematic on Microsoft Windows, because that operating -system is exceptionally slow at starting processes. Sadly this is an -issue that can only be fixed by Microsoft itself, and they don’t appear -to be particularly interested in doing so. - - Beside the subprocess issue, there are also other Windows-specific -performance issues. Some of these have workarounds. The maintainers of -"Git for Windows" try to improve performance on Windows. Always use the -latest release in order to benefit from the latest performance tweaks. -Magit too tries to work around some Windows-specific issues. - - According to some sources, setting the following Git variables can -also help. - - git config --global core.preloadindex true # default since v2.1 - git config --global core.fscache true # default since v2.8 - git config --global gc.auto 256 - - You should also check whether an anti-virus program is affecting -performance. - - -File: magit.info, Node: MacOS Performance, Prev: Microsoft Windows Performance, Up: Performance - -MacOS Performance -................. - -Before Emacs 26.1 child processes were created using ‘fork’ on macOS. -That needlessly copied GUI resources, which is expensive. The result -was that forking took about 30 times as long on Darwin than on Linux, -and because Magit starts many ‘git’ processes that made quite a -difference. - - So make sure that you are using at least Emacs 26.1, in which case -the faster ‘vfork’ will be used. (The creation of child processes still -takes about twice as long on Darwin compared to Linux.) See (1) for -more information. - - Additionally, ‘git’ installed from a package manager like ‘brew’ or -‘nix’ seems to be slower than the native executable. Profile the ‘git’ -executable you’re running against the one at ‘/usr/bin/git’, and if you -notice a notable difference try using the latter as -‘magit-git-executable’. - - ---------- Footnotes ---------- - - (1) -<https://lists.gnu.org/archive/html/bug-gnu-emacs/2017-04/msg00201.html> - - -File: magit.info, Node: Global Bindings, Prev: Performance, Up: Essential Settings - -9.2.3 Global Bindings ---------------------- - - -- User Option: magit-define-global-key-bindings - This option controls which set of Magit key bindings, if any, may - be added to the global keymap, even before Magit is first used in - the current Emacs session. - - • If the value is ‘nil’, no bindings are added. - - • If ‘default’, maybe add: - - ‘C-x g’ ‘magit-status’ - ‘C-x M-g’ ‘magit-dispatch’ - ‘C-c M-g’ ‘magit-file-dispatch’ - - • If ‘recommended’, maybe add: - - ‘C-x g’ ‘magit-status’ - ‘C-c g’ ‘magit-dispatch’ - ‘C-c f’ ‘magit-file-dispatch’ - - These bindings are strongly recommended, but we cannot use - them by default, because the ‘C-c <LETTER>’ namespace is - strictly reserved for bindings added by the user (see *note - (elisp)Key Binding Conventions::). - - The bindings in the chosen set may be added when ‘after-init-hook’ - is run. Each binding is added if, and only if, at that time no - other key is bound to the same command, and no other command is - bound to the same key. In other words we try to avoid adding - bindings that are unnecessary, as well as bindings that conflict - with other bindings. - - Adding these bindings is delayed until ‘after-init-hook’ is run to - allow users to set the variable anywhere in their init file - (without having to make sure to do so before ‘magit’ is loaded or - autoloaded) and to increase the likelihood that all the potentially - conflicting user bindings have already been added. - - To set this variable use either ‘setq’ or the Custom interface. Do - not use the function ‘customize-set-variable’ because doing that - would cause Magit to be loaded immediately, when that form is - evaluated (this differs from ‘custom-set-variables’, which doesn’t - load the libraries that define the customized variables). - - Setting this variable has no effect if ‘after-init-hook’ has - already been run. - - -File: magit.info, Node: Plumbing, Next: FAQ, Prev: Customizing, Up: Top - -10 Plumbing -*********** - -The following sections describe how to use several of Magit’s core -abstractions to extend Magit itself or implement a separate extension. - - A few of the low-level features used by Magit have been factored out -into separate libraries/packages, so that they can be used by other -packages, without having to depend on Magit. See *note -(with-editor)Top:: for information about ‘with-editor’. ‘transient’ -doesn’t have a manual yet. - - If you are trying to find an unused key that you can bind to a -command provided by your own Magit extension, then checkout -<https://github.com/magit/magit/wiki/Plugin-Dispatch-Key-Registry>. - -* Menu: - -* Calling Git:: -* Section Plumbing:: -* Refreshing Buffers:: -* Conventions:: - - -File: magit.info, Node: Calling Git, Next: Section Plumbing, Up: Plumbing - -10.1 Calling Git -================ - -Magit provides many specialized functions for calling Git. All of these -functions are defined in either ‘magit-git.el’ or ‘magit-process.el’ and -have one of the prefixes ‘magit-run-’, ‘magit-call-’, ‘magit-start-’, or -‘magit-git-’ (which is also used for other things). - - All of these functions accept an indefinite number of arguments, -which are strings that specify command line arguments for Git (or in -some cases an arbitrary executable). These arguments are flattened -before being passed on to the executable; so instead of strings they can -also be lists of strings and arguments that are ‘nil’ are silently -dropped. Some of these functions also require a single mandatory -argument before these command line arguments. - - Roughly speaking, these functions run Git either to get some value or -for side-effects. The functions that return a value are useful to -collect the information necessary to populate a Magit buffer, while the -others are used to implement Magit commands. - - The functions in the value-only group always run synchronously, and -they never trigger a refresh. The function in the side-effect group can -be further divided into subgroups depending on whether they run Git -synchronously or asynchronously, and depending on whether they trigger a -refresh when the executable has finished. - -* Menu: - -* Getting a Value from Git:: -* Calling Git for Effect:: - - -File: magit.info, Node: Getting a Value from Git, Next: Calling Git for Effect, Up: Calling Git - -10.1.1 Getting a Value from Git -------------------------------- - -These functions run Git in order to get a value, an exit status, or -output. Of course you could also use them to run Git commands that have -side-effects, but that should be avoided. - - -- Function: magit-git-exit-code &rest args - Executes git with ARGS and returns its exit code. - - -- Function: magit-git-success &rest args - Executes git with ARGS and returns ‘t’ if the exit code is ‘0’, - ‘nil’ otherwise. - - -- Function: magit-git-failure &rest args - Executes git with ARGS and returns ‘t’ if the exit code is ‘1’, - ‘nil’ otherwise. - - -- Function: magit-git-true &rest args - Executes git with ARGS and returns ‘t’ if the first line printed by - git is the string "true", ‘nil’ otherwise. - - -- Function: magit-git-false &rest args - Executes git with ARGS and returns ‘t’ if the first line printed by - git is the string "false", ‘nil’ otherwise. - - -- Function: magit-git-insert &rest args - Executes git with ARGS and inserts its output at point. - - -- Function: magit-git-string &rest args - Executes git with ARGS and returns the first line of its output. - If there is no output or if it begins with a newline character, - then this returns ‘nil’. - - -- Function: magit-git-lines &rest args - Executes git with ARGS and returns its output as a list of lines. - Empty lines anywhere in the output are omitted. - - -- Function: magit-git-items &rest args - Executes git with ARGS and returns its null-separated output as a - list. Empty items anywhere in the output are omitted. - - If the value of option ‘magit-git-debug’ is non-nil and git exits - with a non-zero exit status, then warn about that in the echo area - and add a section containing git’s standard error in the current - repository’s process buffer. - - -- Function: magit-process-git destination &rest args - Calls Git synchronously in a separate process, returning its exit - code. DESTINATION specifies how to handle the output, like for - ‘call-process’, except that file handlers are supported. Enables - Cygwin’s "noglob" option during the call and ensures unix eol - conversion. - - -- Function: magit-process-file process &optional infile buffer display - &rest args - Processes files synchronously in a separate process. Identical to - ‘process-file’ but temporarily enables Cygwin’s "noglob" option - during the call and ensures unix eol conversion. - - If an error occurs when using one of the above functions, then that -is usually due to a bug, i.e., using an argument which is not actually -supported. Such errors are usually not reported, but when they occur we -need to be able to debug them. - - -- User Option: magit-git-debug - Whether to report errors that occur when using ‘magit-git-insert’, - ‘magit-git-string’, ‘magit-git-lines’, or ‘magit-git-items’. This - does not actually raise an error. Instead a message is shown in - the echo area, and git’s standard error is insert into a new - section in the current repository’s process buffer. - - -- Function: magit-git-str &rest args - This is a variant of ‘magit-git-string’ that ignores the option - ‘magit-git-debug’. It is mainly intended to be used while handling - errors in functions that do respect that option. Using such a - function while handing an error could cause yet another error and - therefore lead to an infinite recursion. You probably won’t ever - need to use this function. - - -File: magit.info, Node: Calling Git for Effect, Prev: Getting a Value from Git, Up: Calling Git - -10.1.2 Calling Git for Effect ------------------------------ - -These functions are used to run git to produce some effect. Most Magit -commands that actually run git do so by using such a function. - - Because we do not need to consume git’s output when using these -functions, their output is instead logged into a per-repository buffer, -which can be shown using ‘$’ from a Magit buffer or ‘M-x magit-process’ -elsewhere. - - These functions can have an effect in two distinct ways. Firstly, -running git may change something, i.e., create or push a new commit. -Secondly, that change may require that Magit buffers are refreshed to -reflect the changed state of the repository. But refreshing isn’t -always desirable, so only some of these functions do perform such a -refresh after git has returned. - - Sometimes it is useful to run git asynchronously. For example, when -the user has just initiated a push, then there is no reason to make her -wait until that has completed. In other cases it makes sense to wait -for git to complete before letting the user do something else. For -example after staging a change it is useful to wait until after the -refresh because that also automatically moves to the next change. - - -- Function: magit-call-git &rest args - Calls git synchronously with ARGS. - - -- Function: magit-call-process program &rest args - Calls PROGRAM synchronously with ARGS. - - -- Function: magit-run-git &rest args - Calls git synchronously with ARGS and then refreshes. - - -- Function: magit-run-git-with-input &rest args - Calls git synchronously with ARGS and sends it the content of the - current buffer on standard input. - - If the current buffer’s ‘default-directory’ is on a remote - filesystem, this function actually runs git asynchronously. But - then it waits for the process to return, so the function itself is - synchronous. - - -- Function: magit-git &rest args - Calls git synchronously with ARGS for side-effects only. This - function does not refresh the buffer. - - -- Function: magit-git-wash washer &rest args - Execute Git with ARGS, inserting washed output at point. Actually - first insert the raw output at point. If there is no output call - ‘magit-cancel-section’. Otherwise temporarily narrow the buffer to - the inserted text, move to its beginning, and then call function - WASHER with ARGS as its sole argument. - - And now for the asynchronous variants. - - -- Function: magit-run-git-async &rest args - Start Git, prepare for refresh, and return the process object. - ARGS is flattened and then used as arguments to Git. - - Display the command line arguments in the echo area. - - After Git returns some buffers are refreshed: the buffer that was - current when this function was called (if it is a Magit buffer and - still alive), as well as the respective Magit status buffer. - Unmodified buffers visiting files that are tracked in the current - repository are reverted if ‘magit-revert-buffers’ is non-nil. - - -- Function: magit-run-git-with-editor &rest args - Export GIT_EDITOR and start Git. Also prepare for refresh and - return the process object. ARGS is flattened and then used as - arguments to Git. - - Display the command line arguments in the echo area. - - After Git returns some buffers are refreshed: the buffer that was - current when this function was called (if it is a Magit buffer and - still alive), as well as the respective Magit status buffer. - - -- Function: magit-start-git input &rest args - Start Git, prepare for refresh, and return the process object. - - If INPUT is non-nil, it has to be a buffer or the name of an - existing buffer. The buffer content becomes the processes standard - input. - - Option ‘magit-git-executable’ specifies the Git executable and - option ‘magit-git-global-arguments’ specifies constant arguments. - The remaining arguments ARGS specify arguments to Git. They are - flattened before use. - - After Git returns, some buffers are refreshed: the buffer that was - current when this function was called (if it is a Magit buffer and - still alive), as well as the respective Magit status buffer. - Unmodified buffers visiting files that are tracked in the current - repository are reverted if ‘magit-revert-buffers’ is non-nil. - - -- Function: magit-start-process &rest args - Start PROGRAM, prepare for refresh, and return the process object. - - If optional argument INPUT is non-nil, it has to be a buffer or the - name of an existing buffer. The buffer content becomes the - processes standard input. - - The process is started using ‘start-file-process’ and then setup to - use the sentinel ‘magit-process-sentinel’ and the filter - ‘magit-process-filter’. Information required by these functions is - stored in the process object. When this function returns the - process has not started to run yet so it is possible to override - the sentinel and filter. - - After the process returns, ‘magit-process-sentinel’ refreshes the - buffer that was current when ‘magit-start-process’ was called (if - it is a Magit buffer and still alive), as well as the respective - Magit status buffer. Unmodified buffers visiting files that are - tracked in the current repository are reverted if - ‘magit-revert-buffers’ is non-nil. - - -- Variable: magit-this-process - The child process which is about to start. This can be used to - change the filter and sentinel. - - -- Variable: magit-process-raise-error - When this is non-nil, then ‘magit-process-sentinel’ raises an error - if git exits with a non-zero exit status. For debugging purposes. - - -File: magit.info, Node: Section Plumbing, Next: Refreshing Buffers, Prev: Calling Git, Up: Plumbing - -10.2 Section Plumbing -===================== - -* Menu: - -* Creating Sections:: -* Section Selection:: -* Matching Sections:: - - -File: magit.info, Node: Creating Sections, Next: Section Selection, Up: Section Plumbing - -10.2.1 Creating Sections ------------------------- - - -- Macro: magit-insert-section &rest args - Insert a section at point. - - TYPE is the section type, a symbol. Many commands that act on the - current section behave differently depending on that type. Also if - a variable ‘magit-TYPE-section-map’ exists, then use that as the - text-property ‘keymap’ of all text belonging to the section (but - this may be overwritten in subsections). TYPE can also have the - form ‘(eval FORM)’ in which case FORM is evaluated at runtime. - - Optional VALUE is the value of the section, usually a string that - is required when acting on the section. - - When optional HIDE is non-nil collapse the section body by default, - i.e., when first creating the section, but not when refreshing the - buffer. Otherwise, expand it by default. This can be overwritten - using ‘magit-section-set-visibility-hook’. When a section is - recreated during a refresh, then the visibility of predecessor is - inherited and HIDE is ignored (but the hook is still honored). - - BODY is any number of forms that actually insert the section’s - heading and body. Optional NAME, if specified, has to be a symbol, - which is then bound to the struct of the section being inserted. - - Before BODY is evaluated the ‘start’ of the section object is set - to the value of ‘point’ and after BODY was evaluated its ‘end’ is - set to the new value of ‘point’; BODY is responsible for moving - ‘point’ forward. - - If it turns out inside BODY that the section is empty, then - ‘magit-cancel-section’ can be used to abort and remove all traces - of the partially inserted section. This can happen when creating a - section by washing Git’s output and Git didn’t actually output - anything this time around. - - -- Function: magit-insert-heading &rest args - Insert the heading for the section currently being inserted. - - This function should only be used inside ‘magit-insert-section’. - - When called without any arguments, then just set the ‘content’ slot - of the object representing the section being inserted to a marker - at ‘point’. The section should only contain a single line when - this function is used like this. - - When called with arguments ARGS, which have to be strings, then - insert those strings at point. The section should not contain any - text before this happens and afterwards it should again only - contain a single line. If the ‘face’ property is set anywhere - inside any of these strings, then insert all of them unchanged. - Otherwise use the ‘magit-section-heading’ face for all inserted - text. - - The ‘content’ property of the section struct is the end of the - heading (which lasts from ‘start’ to ‘content’) and the beginning - of the body (which lasts from ‘content’ to ‘end’). If the value of - ‘content’ is nil, then the section has no heading and its body - cannot be collapsed. If a section does have a heading then its - height must be exactly one line, including a trailing newline - character. This isn’t enforced; you are responsible for getting it - right. The only exception is that this function does insert a - newline character if necessary. - - -- Function: magit-cancel-section - Cancel the section currently being inserted. This exits the - innermost call to ‘magit-insert-section’ and removes all traces of - what has already happened inside that call. - - -- Function: magit-define-section-jumper sym title &optional value - Define an interactive function to go to section SYM. TITLE is the - displayed title of the section. - - -File: magit.info, Node: Section Selection, Next: Matching Sections, Prev: Creating Sections, Up: Section Plumbing - -10.2.2 Section Selection ------------------------- - - -- Function: magit-current-section - Return the section at point. - - -- Function: magit-region-sections &optional condition multiple - Return a list of the selected sections. - - When the region is active and constitutes a valid section - selection, then return a list of all selected sections. This is - the case when the region begins in the heading of a section and - ends in the heading of the same section or in that of a sibling - section. If optional MULTIPLE is non-nil, then the region cannot - begin and end in the same section. - - When the selection is not valid, then return nil. In this case, - most commands that can act on the selected sections will instead - act on the section at point. - - When the region looks like it would in any other buffer then the - selection is invalid. When the selection is valid then the region - uses the ‘magit-section-highlight’ face. This does not apply to - diffs where things get a bit more complicated, but even here if the - region looks like it usually does, then that’s not a valid - selection as far as this function is concerned. - - If optional CONDITION is non-nil, then the selection not only has - to be valid; all selected sections additionally have to match - CONDITION, or nil is returned. See ‘magit-section-match’ for the - forms CONDITION can take. - - -- Function: magit-region-values &optional condition multiple - Return a list of the values of the selected sections. - - Return the values that themselves would be returned by - ‘magit-region-sections’ (which see). - - -File: magit.info, Node: Matching Sections, Prev: Section Selection, Up: Section Plumbing - -10.2.3 Matching Sections ------------------------- - -‘M-x magit-describe-section-briefly’ - Show information about the section at point. This command is - intended for debugging purposes. - - -- Function: magit-section-ident section - Return an unique identifier for SECTION. The return value has the - form ‘((TYPE . VALUE)...)’. - - -- Function: magit-get-section ident &optional root - Return the section identified by IDENT. IDENT has to be a list as - returned by ‘magit-section-ident’. - - -- Function: magit-section-match condition &optional section - Return ‘t’ if SECTION matches CONDITION. SECTION defaults to the - section at point. If SECTION is not specified and there also is no - section at point, then return ‘nil’. - - CONDITION can take the following forms: - • ‘(CONDITION...)’ - - matches if any of the CONDITIONs matches. - - • ‘[CLASS...]’ - - matches if the section’s class is the same as the first CLASS - or a subclass of that; the section’s parent class matches the - second CLASS; and so on. - - • ‘[* CLASS...]’ - - matches sections that match ‘[CLASS...]’ and also recursively - all their child sections. - - • ‘CLASS’ - - matches if the section’s class is the same as CLASS or a - subclass of that; regardless of the classes of the parent - sections. - - Each CLASS should be a class symbol, identifying a class that - derives from ‘magit-section’. For backward compatibility CLASS can - also be a "type symbol". A section matches such a symbol if the - value of its ‘type’ slot is ‘eq’. If a type symbol has an entry in - ‘magit--section-type-alist’, then a section also matches that type - if its class is a subclass of the class that corresponds to the - type as per that alist. - - Note that it is not necessary to specify the complete section - lineage as printed by ‘magit-describe-section-briefly’, unless of - course you want to be that precise. - - -- Function: magit-section-value-if condition &optional section - If the section at point matches CONDITION, then return its value. - - If optional SECTION is non-nil then test whether that matches - instead. If there is no section at point and SECTION is nil, then - return nil. If the section does not match, then return nil. - - See ‘magit-section-match’ for the forms CONDITION can take. - - -- Function: magit-section-case &rest clauses - Choose among clauses on the type of the section at point. - - Each clause looks like (CONDITION BODY...). The type of the - section is compared against each CONDITION; the BODY forms of the - first match are evaluated sequentially and the value of the last - form is returned. Inside BODY the symbol ‘it’ is bound to the - section at point. If no clause succeeds or if there is no section - at point return nil. - - See ‘magit-section-match’ for the forms CONDITION can take. - Additionally a CONDITION of t is allowed in the final clause and - matches if no other CONDITION match, even if there is no section at - point. - - -- Variable: magit-root-section - The root section in the current buffer. All other sections are - descendants of this section. The value of this variable is set by - ‘magit-insert-section’ and you should never modify it. - - For diff related sections a few additional tools exist. - - -- Function: magit-diff-type &optional section - Return the diff type of SECTION. - - The returned type is one of the symbols ‘staged’, ‘unstaged’, - ‘committed’, or ‘undefined’. This type serves a similar purpose as - the general type common to all sections (which is stored in the - ‘type’ slot of the corresponding ‘magit-section’ struct) but takes - additional information into account. When the SECTION isn’t - related to diffs and the buffer containing it also isn’t a - diff-only buffer, then return nil. - - Currently the type can also be one of ‘tracked’ and ‘untracked’, - but these values are not handled explicitly in every place they - should be. A possible fix could be to just return nil here. - - The section has to be a ‘diff’ or ‘hunk’ section, or a section - whose children are of type ‘diff’. If optional SECTION is nil, - return the diff type for the current section. In buffers whose - major mode is ‘magit-diff-mode’ SECTION is ignored and the type is - determined using other means. In ‘magit-revision-mode’ buffers the - type is always ‘committed’. - - -- Function: magit-diff-scope &optional section strict - Return the diff scope of SECTION or the selected section(s). - - A diff’s "scope" describes what part of a diff is selected, it is a - symbol, one of ‘region’, ‘hunk’, ‘hunks’, ‘file’, ‘files’, or - ‘list’. Do not confuse this with the diff "type", as returned by - ‘magit-diff-type’. - - If optional SECTION is non-nil, then return the scope of that, - ignoring the sections selected by the region. Otherwise return the - scope of the current section, or if the region is active and - selects a valid group of diff related sections, the type of these - sections, i.e., ‘hunks’ or ‘files’. If SECTION (or if the current - section that is nil) is a ‘hunk’ section and the region starts and - ends inside the body of a that section, then the type is ‘region’. - - If optional STRICT is non-nil then return nil if the diff type of - the section at point is ‘untracked’ or the section at point is not - actually a ‘diff’ but a ‘diffstat’ section. - - -File: magit.info, Node: Refreshing Buffers, Next: Conventions, Prev: Section Plumbing, Up: Plumbing - -10.3 Refreshing Buffers -======================= - -All commands that create a new Magit buffer or change what is being -displayed in an existing buffer do so by calling ‘magit-mode-setup’. -Among other things, that function sets the buffer local values of -‘default-directory’ (to the top-level of the repository), -‘magit-refresh-function’, and ‘magit-refresh-args’. - - Buffers are refreshed by calling the function that is the local value -of ‘magit-refresh-function’ (a function named ‘magit-*-refresh-buffer’, -where ‘*’ may be something like ‘diff’) with the value of -‘magit-refresh-args’ as arguments. - - -- Macro: magit-mode-setup buffer switch-func mode refresh-func - &optional refresh-args - This function displays and selects BUFFER, turns on MODE, and - refreshes a first time. - - This function displays and optionally selects BUFFER by calling - ‘magit-mode-display-buffer’ with BUFFER, MODE and SWITCH-FUNC as - arguments. Then it sets the local value of - ‘magit-refresh-function’ to REFRESH-FUNC and that of - ‘magit-refresh-args’ to REFRESH-ARGS. Finally it creates the - buffer content by calling REFRESH-FUNC with REFRESH-ARGS as - arguments. - - All arguments are evaluated before switching to BUFFER. - - -- Function: magit-mode-display-buffer buffer mode &optional - switch-function - This function display BUFFER in some window and select it. BUFFER - may be a buffer or a string, the name of a buffer. The buffer is - returned. - - Unless BUFFER is already displayed in the selected frame, store the - previous window configuration as a buffer local value, so that it - can later be restored by ‘magit-mode-bury-buffer’. - - The buffer is displayed and selected using SWITCH-FUNCTION. If - that is ‘nil’ then ‘pop-to-buffer’ is used if the current buffer’s - major mode derives from ‘magit-mode’. Otherwise ‘switch-to-buffer’ - is used. - - -- Variable: magit-refresh-function - The value of this buffer-local variable is the function used to - refresh the current buffer. It is called with ‘magit-refresh-args’ - as arguments. - - -- Variable: magit-refresh-args - The list of arguments used by ‘magit-refresh-function’ to refresh - the current buffer. ‘magit-refresh-function’ is called with these - arguments. - - The value is usually set using ‘magit-mode-setup’, but in some - cases it’s also useful to provide commands that can change the - value. For example, the ‘magit-diff-refresh’ transient can be used - to change any of the arguments used to display the diff, without - having to specify again which differences should be shown, but - ‘magit-diff-more-context’, ‘magit-diff-less-context’ and - ‘magit-diff-default-context’ change just the ‘-U<N>’ argument. In - both case this is done by changing the value of this variable and - then calling this ‘magit-refresh-function’. - - -File: magit.info, Node: Conventions, Prev: Refreshing Buffers, Up: Plumbing - -10.4 Conventions -================ - -Also see *note Completion and Confirmation::. - -* Menu: - -* Theming Faces:: - - -File: magit.info, Node: Theming Faces, Up: Conventions - -10.4.1 Theming Faces --------------------- - -The default theme uses blue for local branches, green for remote -branches, and goldenrod (brownish yellow) for tags. When creating a new -theme, you should probably follow that example. If your theme already -uses other colors, then stick to that. - - In older releases these reference faces used to have a background -color and a box around them. The basic default faces no longer do so, -to make Magit buffers much less noisy, and you should follow that -example at least with regards to boxes. (Boxes were used in the past to -work around a conflict between the highlighting overlay and text -property backgrounds. That’s no longer necessary because highlighting -no longer causes other background colors to disappear.) Alternatively -you can keep the background color and/or box, but then have to take -special care to adjust ‘magit-branch-current’ accordingly. By default -it looks mostly like ‘magit-branch-local’, but with a box (by default -the former is the only face that uses a box, exactly so that it sticks -out). If the former also uses a box, then you have to make sure that it -differs in some other way from the latter. - - The most difficult faces to theme are those related to diffs, -headings, highlighting, and the region. There are faces that fall into -all four groups - expect to spend some time getting this right. - - The ‘region’ face in the default theme, in both the light and dark -variants, as well as in many other themes, distributed with Emacs or by -third-parties, is very ugly. It is common to use a background color -that really sticks out, which is ugly but if that were the only problem -then it would be acceptable. Unfortunately many themes also set the -foreground color, which ensures that all text within the region is -readable. Without doing that there might be cases where some foreground -color is too close to the region background color to still be readable. -But it also means that text within the region loses all syntax -highlighting. - - I consider the work that went into getting the ‘region’ face right to -be a good indicator for the general quality of a theme. My -recommendation for the ‘region’ face is this: use a background color -slightly different from the background color of the ‘default’ face, and -do not set the foreground color at all. So for a light theme you might -use a light (possibly tinted) gray as the background color of ‘default’ -and a somewhat darker gray for the background of ‘region’. That should -usually be enough to not collide with the foreground color of any other -face. But if some other faces also set a light gray as background -color, then you should also make sure it doesn’t collide with those (in -some cases it might be acceptable though). - - Magit only uses the ‘region’ face when the region is "invalid" by its -own definition. In a Magit buffer the region is used to either select -multiple sibling sections, so that commands which support it act on all -of these sections instead of just the current section, or to select -lines within a single hunk section. In all other cases, the section is -considered invalid and Magit won’t act on it. But such invalid sections -happen, either because the user has not moved point enough yet to make -it valid or because she wants to use a non-magit command to act on the -region, e.g., ‘kill-region’. - - So using the regular ‘region’ face for invalid sections is a feature. -It tells the user that Magit won’t be able to act on it. It’s -acceptable if that face looks a bit odd and even (but less so) if it -collides with the background colors of section headings and other things -that have a background color. - - Magit highlights the current section. If a section has subsections, -then all of them are highlighted. This is done using faces that have -"highlight" in their names. For most sections, -‘magit-section-highlight’ is used for both the body and the heading. -Like the ‘region’ face, it should only set the background color to -something similar to that of ‘default’. The highlight background color -must be different from both the ‘region’ background color and the -‘default’ background color. - - For diff related sections Magit uses various faces to highlight -different parts of the selected section(s). Note that hunk headings, -unlike all other section headings, by default have a background color, -because it is useful to have very visible separators between hunks. -That face ‘magit-diff-hunk-heading’, should be different from both -‘magit-diff-hunk-heading-highlight’ and ‘magit-section-highlight’, as -well as from ‘magit-diff-context’ and ‘magit-diff-context-highlight’. -By default we do that by changing the foreground color. Changing the -background color would lead to complications, and there are already -enough we cannot get around. (Also note that it is generally a good -idea for section headings to always be bold, but only for sections that -have subsections). - - When there is a valid region selecting diff-related sibling sections, -i.e., multiple files or hunks, then the bodies of all these sections use -the respective highlight faces, but additionally the headings instead -use one of the faces ‘magit-diff-file-heading-selection’ or -‘magit-diff-hunk-heading-selection’. These faces have to be different -from the regular highlight variants to provide explicit visual -indication that the region is active. - - When theming diff related faces, start by setting the option -‘magit-diff-refine-hunk’ to ‘all’. You might personally prefer to only -refine the current hunk or not use hunk refinement at all, but some of -the users of your theme want all hunks to be refined, so you have to -cater to that. - - (Also turn on ‘magit-diff-highlight-indentation’, -‘magit-diff-highlight-trailing’, and ‘magit-diff-paint-whitespace’; and -insert some whitespace errors into the code you use for testing.) - - For added lines you have to adjust three faces: ‘magit-diff-added’, -‘magit-diff-added-highlight’, and ‘diff-refined-added’. Make sure that -the latter works well with both of the former, as well as ‘smerge-other’ -and ‘diff-added’. Then do the same for the removed lines, context -lines, lines added by us, and lines added by them. Also make sure the -respective added, removed, and context faces use approximately the same -saturation for both the highlighted and unhighlighted variants. Also -make sure the file and diff headings work nicely with context lines -(e.g., make them look different). Line faces should set both the -foreground and the background color. For example, for added lines use -two different greens. - - It’s best if the foreground color of both the highlighted and the -unhighlighted variants are the same, so you will need to have to find a -color that works well on the highlight and unhighlighted background, the -refine background, and the highlight context background. When there is -an hunk internal region, then the added- and removed-lines background -color is used only within that region. Outside the region the -highlighted context background color is used. This makes it easier to -see what is being staged. With an hunk internal region the hunk heading -is shown using ‘magit-diff-hunk-heading-selection’, and so are the thin -lines that are added around the lines that fall within the region. The -background color of that has to be distinct enough from the various -other involved background colors. - - Nobody said this would be easy. If your theme restricts itself to a -certain set of colors, then you should make an exception here. -Otherwise it would be impossible to make the diffs look good in each and -every variation. Actually you might want to just stick to the default -definitions for these faces. You have been warned. Also please note -that if you do not get this right, this will in some cases look to users -like bugs in Magit - so please do it right or not at all. - - -File: magit.info, Node: FAQ, Next: Debugging Tools, Prev: Plumbing, Up: Top - -Appendix A FAQ -************** - -The next two nodes lists frequently asked questions. For a list of -frequently *and recently* asked questions, i.e., questions that haven’t -made it into the manual yet, see -<https://github.com/magit/magit/wiki/FAQ>. - - Please also see *note Debugging Tools::. - -* Menu: - -* FAQ - How to ...?:: -* FAQ - Issues and Errors:: - - -File: magit.info, Node: FAQ - How to ...?, Next: FAQ - Issues and Errors, Up: FAQ - -A.1 FAQ - How to ...? -===================== - -* Menu: - -* How to pronounce Magit?:: -* How to show git's output?:: -* How to install the gitman info manual?:: -* How to show diffs for gpg-encrypted files?:: -* How does branching and pushing work?:: -* Should I disable VC?:: - - -File: magit.info, Node: How to pronounce Magit?, Next: How to show git's output?, Up: FAQ - How to ...? - -A.1.1 How to pronounce Magit? ------------------------------ - -Either ‘mu[m's] git’ or ‘magi{c => t}’ is fine. - - The slogan is "It’s Magit! The magical Git client", so it makes -sense to pronounce Magit like magic, while taking into account that C -and T do not sound the same. - - The German "Magie" is not pronounced the same as the English "magic", -so if you speak German then you can use the above rationale to justify -using the former pronunciation; ‘Mag{ie => it}’. - - You can also choose to use the former pronunciation just because you -like it better. - - Also see <https://magit.vc/assets/videos/magic.mp4>. Also see -<https://emacs.stackexchange.com/questions/13696>. - - -File: magit.info, Node: How to show git's output?, Next: How to install the gitman info manual?, Prev: How to pronounce Magit?, Up: FAQ - How to ...? - -A.1.2 How to show git’s output? -------------------------------- - -To show the output of recently run git commands, press ‘$’ (or, if that -isn’t available, ‘M-x magit-process-buffer’). This will show a buffer -containing a section per git invocation; as always press ‘TAB’ to expand -or collapse them. - - By default, git’s output is only inserted into the process buffer if -it is run for side-effects. When the output is consumed in some way, -also inserting it into the process buffer would be too expensive. For -debugging purposes, it’s possible to do so anyway by setting -‘magit-git-debug’ to ‘t’. - - -File: magit.info, Node: How to install the gitman info manual?, Next: How to show diffs for gpg-encrypted files?, Prev: How to show git's output?, Up: FAQ - How to ...? - -A.1.3 How to install the gitman info manual? --------------------------------------------- - -Git’s manpages can be exported as an info manual called ‘gitman’. -Magit’s own info manual links to nodes in that manual instead of the -actual manpages because Info doesn’t support linking to manpages. - - Unfortunately some distributions do not install the ‘gitman’ manual -by default and you will have to install a separate documentation package -to get it. - - Magit patches Info adding the ability to visit links to the ‘gitman’ -Info manual by instead viewing the respective manpage. If you prefer -that approach, then set the value of ‘magit-view-git-manual-method’ to -one of the supported packages ‘man’ or ‘woman’, e.g.: - - (setq magit-view-git-manual-method 'man) - - -File: magit.info, Node: How to show diffs for gpg-encrypted files?, Next: How does branching and pushing work?, Prev: How to install the gitman info manual?, Up: FAQ - How to ...? - -A.1.4 How to show diffs for gpg-encrypted files? ------------------------------------------------- - -Git supports showing diffs for encrypted files, but has to be told to do -so. Since Magit just uses Git to get the diffs, configuring Git also -affects the diffs displayed inside Magit. - - git config --global diff.gpg.textconv "gpg --no-tty --decrypt" - echo "*.gpg filter=gpg diff=gpg" > .gitattributes - - -File: magit.info, Node: How does branching and pushing work?, Next: Should I disable VC?, Prev: How to show diffs for gpg-encrypted files?, Up: FAQ - How to ...? - -A.1.5 How does branching and pushing work? ------------------------------------------- - -Please see *note Branching:: and -<https://emacsair.me/2016/01/17/magit-2.4> - - -File: magit.info, Node: Should I disable VC?, Prev: How does branching and pushing work?, Up: FAQ - How to ...? - -A.1.6 Should I disable VC? --------------------------- - -If you don’t use VC (the built-in version control interface) then you -might be tempted to disable it, not least because we used to recommend -that you do that. - - We no longer recommend that you disable VC. Doing so would break -useful third-party packages (such as ‘diff-hl’), which depend on VC -being enabled. - - If you choose to disable VC anyway, then you can do so by changing -the value of ‘vc-handled-backends’. - - -File: magit.info, Node: FAQ - Issues and Errors, Prev: FAQ - How to ...?, Up: FAQ - -A.2 FAQ - Issues and Errors -=========================== - -* Menu: - -* Magit is slow:: -* I changed several thousand files at once and now Magit is unusable:: -* I am having problems committing:: -* I am using MS Windows and cannot push with Magit:: -* I am using macOS and SOMETHING works in shell, but not in Magit: I am using macOS and SOMETHING works in shell but not in Magit. -* Expanding a file to show the diff causes it to disappear:: -* Point is wrong in the COMMIT_EDITMSG buffer:: -* The mode-line information isn't always up-to-date:: -* A branch and tag sharing the same name breaks SOMETHING:: -* My Git hooks work on the command-line but not inside Magit:: -* git-commit-mode isn't used when committing from the command-line:: -* Point ends up inside invisible text when jumping to a file-visiting buffer:: -* I am no longer able to save popup defaults:: - - -File: magit.info, Node: Magit is slow, Next: I changed several thousand files at once and now Magit is unusable, Up: FAQ - Issues and Errors - -A.2.1 Magit is slow -------------------- - -See *note Performance:: and *note I changed several thousand files at -once and now Magit is unusable::. - - -File: magit.info, Node: I changed several thousand files at once and now Magit is unusable, Next: I am having problems committing, Prev: Magit is slow, Up: FAQ - Issues and Errors - -A.2.2 I changed several thousand files at once and now Magit is unusable ------------------------------------------------------------------------- - -Magit is currently not expected to work well under such conditions. It -sure would be nice if it did. Reaching satisfactory performance under -such conditions will require some heavy refactoring. This is no small -task but I hope to eventually find the time to make it happen. - - But for now we recommend you use the command line to complete this -one commit. Also see *note Performance::. - - -File: magit.info, Node: I am having problems committing, Next: I am using MS Windows and cannot push with Magit, Prev: I changed several thousand files at once and now Magit is unusable, Up: FAQ - Issues and Errors - -A.2.3 I am having problems committing -------------------------------------- - -That likely means that Magit is having problems finding an appropriate -emacsclient executable. See *note (with-editor)Configuring -With-Editor:: and *note (with-editor)Debugging::. - - -File: magit.info, Node: I am using MS Windows and cannot push with Magit, Next: I am using macOS and SOMETHING works in shell but not in Magit, Prev: I am having problems committing, Up: FAQ - Issues and Errors - -A.2.4 I am using MS Windows and cannot push with Magit ------------------------------------------------------- - -It’s almost certain that Magit is only incidental to this issue. It is -much more likely that this is a configuration issue, even if you can -push on the command line. - - Detailed setup instructions can be found at -<https://github.com/magit/magit/wiki/Pushing-with-Magit-from-Windows>. - - -File: magit.info, Node: I am using macOS and SOMETHING works in shell but not in Magit, Next: Expanding a file to show the diff causes it to disappear, Prev: I am using MS Windows and cannot push with Magit, Up: FAQ - Issues and Errors - -A.2.5 I am using macOS and SOMETHING works in shell, but not in Magit ---------------------------------------------------------------------- - -This usually occurs because Emacs doesn’t have the same environment -variables as your shell. Try installing and configuring -<https://github.com/purcell/exec-path-from-shell>. By default it -synchronizes ‘$PATH’, which helps Magit find the same ‘git’ as the one -you are using on the shell. - - If SOMETHING is "passphrase caching with gpg-agent for commit and/or -tag signing", then you’ll also need to synchronize ‘$GPG_AGENT_INFO’. - - -File: magit.info, Node: Expanding a file to show the diff causes it to disappear, Next: Point is wrong in the COMMIT_EDITMSG buffer, Prev: I am using macOS and SOMETHING works in shell but not in Magit, Up: FAQ - Issues and Errors - -A.2.6 Expanding a file to show the diff causes it to disappear --------------------------------------------------------------- - -This is probably caused by a customization of a ‘diff.*’ Git variable. -You probably set that variable for a reason, and should therefore only -undo that setting in Magit by customizing ‘magit-git-global-arguments’. - - -File: magit.info, Node: Point is wrong in the COMMIT_EDITMSG buffer, Next: The mode-line information isn't always up-to-date, Prev: Expanding a file to show the diff causes it to disappear, Up: FAQ - Issues and Errors - -A.2.7 Point is wrong in the ‘COMMIT_EDITMSG’ buffer ---------------------------------------------------- - -Neither Magit nor ‘git-commit‘ fiddle with point in the buffer used to -write commit messages, so something else must be doing it. - - You have probably globally enabled a mode which restores point in -file-visiting buffers. It might be a bit surprising, but when you write -a commit message, then you are actually editing a file. - - So you have to figure out which package is doing it. ‘saveplace’, -‘pointback’, and ‘session’ are likely candidates. These snippets might -help: - - (setq session-name-disable-regexp "\\(?:\\`'\\.git/[A-Z_]+\\'\\)") - - (with-eval-after-load 'pointback - (lambda () - (when (or git-commit-mode git-rebase-mode) - (pointback-mode -1)))) - - -File: magit.info, Node: The mode-line information isn't always up-to-date, Next: A branch and tag sharing the same name breaks SOMETHING, Prev: Point is wrong in the COMMIT_EDITMSG buffer, Up: FAQ - Issues and Errors - -A.2.8 The mode-line information isn’t always up-to-date -------------------------------------------------------- - -Magit is not responsible for the version control information that is -being displayed in the mode-line and looks something like ‘Git-master’. -The built-in "Version Control" package, also known as "VC", updates that -information, and can be told to do so more often: - - (setq auto-revert-check-vc-info t) - - But doing so isn’t good for performance. For more (overly -optimistic) information see *note (emacs)VC Mode Line::. - - If you don’t really care about seeing this information in the -mode-line, but just don’t want to see _incorrect_ information, then -consider simply not displaying it in the mode-line: - - (setq-default mode-line-format - (delete '(vc-mode vc-mode) mode-line-format)) - - -File: magit.info, Node: A branch and tag sharing the same name breaks SOMETHING, Next: My Git hooks work on the command-line but not inside Magit, Prev: The mode-line information isn't always up-to-date, Up: FAQ - Issues and Errors - -A.2.9 A branch and tag sharing the same name breaks SOMETHING -------------------------------------------------------------- - -Or more generally, ambiguous refnames break SOMETHING. - - Magit assumes that refs are named non-ambiguously across the -"refs/heads/", "refs/tags/", and "refs/remotes/" namespaces (i.e., all -the names remain unique when those prefixes are stripped). We consider -ambiguous refnames unsupported and recommend that you use a -non-ambiguous naming scheme. However, if you do work with a repository -that has ambiguous refnames, please report any issues you encounter, so -that we can investigate whether there is a simple fix. - - -File: magit.info, Node: My Git hooks work on the command-line but not inside Magit, Next: git-commit-mode isn't used when committing from the command-line, Prev: A branch and tag sharing the same name breaks SOMETHING, Up: FAQ - Issues and Errors - -A.2.10 My Git hooks work on the command-line but not inside Magit ------------------------------------------------------------------ - -When Magit calls ‘git’ it adds a few global arguments including -‘--literal-pathspecs’ and the ‘git’ process started by Magit then passes -that setting on to other ‘git’ process it starts itself. It does so by -setting the environment variable ‘GIT_LITERAL_PATHSPECS’, not by calling -subprocesses with the ‘--literal-pathspecs’ argument. You can therefore -override this setting in hook scripts using ‘unset -GIT_LITERAL_PATHSPECS’. - - -File: magit.info, Node: git-commit-mode isn't used when committing from the command-line, Next: Point ends up inside invisible text when jumping to a file-visiting buffer, Prev: My Git hooks work on the command-line but not inside Magit, Up: FAQ - Issues and Errors - -A.2.11 ‘git-commit-mode’ isn’t used when committing from the command-line -------------------------------------------------------------------------- - -The reason for this is that ‘git-commit.el’ has not been loaded yet -and/or that the server has not been started yet. These things have -always already been taken care of when you commit from Magit because in -order to do so, Magit has to be loaded and doing that involves loading -‘git-commit’ and starting the server. - - If you want to commit from the command-line, then you have to take -care of these things yourself. Your ‘init.el’ file should contain: - - (require 'git-commit) - (server-mode) - - Instead of ‘(require ’git-commit)‘ you may also use: - - (load "/path/to/magit-autoloads.el") - - You might want to do that because loading ‘git-commit’ causes large -parts of Magit to be loaded. - - There are also some variations of ‘(server-mode)’ that you might want -to try. Personally I use: - - (use-package server - :config (or (server-running-p) (server-mode))) - - Now you can use: - - $ emacs& - $ EDITOR=emacsclient git commit - - However you cannot use: - - $ killall emacs - $ EDITOR="emacsclient --alternate-editor emacs" git commit - - This will actually end up using ‘emacs’, not ‘emacsclient’. If you -do this, then you can still edit the commit message but -‘git-commit-mode’ won’t be used and you have to exit ‘emacs’ to finish -the process. - - Tautology ahead. If you want to be able to use ‘emacsclient’ to -connect to a running ‘emacs’ instance, even though no ‘emacs’ instance -is running, then you cannot use ‘emacsclient’ directly. - - Instead you have to create a script that does something like this: - - Try to use ‘emacsclient’ (without using ‘--alternate-editor’). If -that succeeds, do nothing else. Otherwise start ‘emacs &’ (and -‘init.el’ must call ‘server-start’) and try to use ‘emacsclient’ again. - - -File: magit.info, Node: Point ends up inside invisible text when jumping to a file-visiting buffer, Next: I am no longer able to save popup defaults, Prev: git-commit-mode isn't used when committing from the command-line, Up: FAQ - Issues and Errors - -A.2.12 Point ends up inside invisible text when jumping to a file-visiting buffer ---------------------------------------------------------------------------------- - -This can happen when you type ‘RET’ on a hunk to visit the respective -file at the respective position. One solution to this problem is to use -‘global-reveal-mode’. It makes sure that text around point is always -visible. If that is too drastic for your taste, then you may instead -use ‘magit-diff-visit-file-hook’ to reveal the text, possibly using -‘reveal-post-command’ or for Org buffers ‘org-reveal’. - - -File: magit.info, Node: I am no longer able to save popup defaults, Prev: Point ends up inside invisible text when jumping to a file-visiting buffer, Up: FAQ - Issues and Errors - -A.2.13 I am no longer able to save popup defaults -------------------------------------------------- - -Magit used to use Magit-Popup to implement the transient popup menus. -Now it used Transient instead, which is Magit-Popup’s successor. - - In the older Magit-Popup menus, it was possible to save user settings -(e.g., setting the gpg signing key for commits) by using ‘C-c C-c’ in -the popup buffer. This would dismiss the popup, but save the settings -as the defaults for future popups. - - When switching to Transient menus, this functionality is now -available via ‘C-x C-s’ instead; the ‘C-x’ prefix has other options as -well when using Transient, which will be displayed when it is typed. -See <https://magit.vc/manual/transient/Saving-Values.html#Saving-Values> -for more details. - - -File: magit.info, Node: Debugging Tools, Next: Keystroke Index, Prev: FAQ, Up: Top - -B Debugging Tools -***************** - -Magit and its dependencies provide a few debugging tools, and we -appreciate it very much if you use those tools before reporting an -issue. Please include all relevant output when reporting an issue. - -‘M-x magit-version’ - This command shows the currently used versions of Magit, Git, and - Emacs in the echo area. Non-interactively this just returns the - Magit version. - -‘M-x magit-emacs-Q-command’ - This command shows a debugging shell command in the echo area and - adds it to the kill ring. Paste that command into a shell and run - it. - - This shell command starts ‘emacs’ with only ‘magit’ and its - dependencies loaded. Neither your configuration nor other - installed packages are loaded. This makes it easier to determine - whether some issue lays with Magit or something else. - - If you run Magit from its Git repository, then you should be able - to use ‘make emacs-Q’ instead of the output of this command. - -‘M-x magit-toggle-git-debug’ - This command toggles whether additional git errors are reported. - - Magit basically calls git for one of these two reasons: for - side-effects or to do something with its standard output. - - When git is run for side-effects then its output, including error - messages, go into the process buffer which is shown when using ‘$’. - - When git’s output is consumed in some way, then it would be too - expensive to also insert it into this buffer, but when this option - is non-nil and git returns with a non-zero exit status, then at - least its standard error is inserted into this buffer. - - This is only intended for debugging purposes. Do not enable this - permanently, that would negatively affect performance. Also note - that just because git exits with a non-zero exit status and prints - an error message that usually doesn’t mean that it is an error as - far as Magit is concerned, which is another reason we usually hide - these error messages. Whether some error message is relevant in - the context of some unexpected behavior has to be judged on a case - by case basis. - -‘M-x magit-toggle-verbose-refresh’ - This command toggles whether Magit refreshes buffers verbosely. - Enabling this helps figuring out which sections are bottlenecks. - The additional output can be found in the ‘*Messages*’ buffer. - -‘M-x magit-debug-git-executable’ - This command displays a buffer containing information about the - available and used ‘git’ executable(s), and can be useful when - investigating ‘exec-path’ issues. - - Also see *note Git Executable::. - -‘M-x with-editor-debug’ - This command displays a buffer containing information about the - available and used ‘emacsclient’ executable(s), and can be useful - when investigating why Magit (or rather ‘with-editor’) cannot find - an appropriate ‘emacsclient’ executable. - - Also see *note (with-editor)Debugging::. - -Please also see *note FAQ::. - - -File: magit.info, Node: Keystroke Index, Next: Function and Command Index, Prev: Debugging Tools, Up: Top - -Appendix C Keystroke Index -************************** - - -* Menu: - -* !: Running Git Manually. - (line 13) -* ! !: Running Git Manually. - (line 17) -* ! a: Running Git Manually. - (line 53) -* ! b: Running Git Manually. - (line 56) -* ! g: Running Git Manually. - (line 59) -* ! k: Running Git Manually. - (line 50) -* ! m: Running Git Manually. - (line 62) -* ! p: Running Git Manually. - (line 25) -* ! s: Running Git Manually. - (line 34) -* ! S: Running Git Manually. - (line 38) -* $: Viewing Git Output. (line 17) -* +: Log Buffer. (line 64) -* + <1>: Refreshing Diffs. (line 65) -* -: Log Buffer. (line 67) -* - <1>: Refreshing Diffs. (line 62) -* 0: Refreshing Diffs. (line 68) -* 1: Section Visibility. (line 39) -* 2: Section Visibility. (line 39) -* 3: Section Visibility. (line 39) -* 4: Section Visibility. (line 39) -* 5: Repository List. (line 115) -* :: Running Git Manually. - (line 25) -* =: Log Buffer. (line 59) -* >: Sparse checkouts. (line 17) -* > a: Sparse checkouts. (line 39) -* > d: Sparse checkouts. (line 50) -* > e: Sparse checkouts. (line 21) -* > r: Sparse checkouts. (line 44) -* > s: Sparse checkouts. (line 33) -* ^: Section Movement. (line 28) -* a: Applying. (line 34) -* A: Cherry Picking. (line 9) -* A A: Cherry Picking. (line 17) -* A a: Cherry Picking. (line 23) -* A A <1>: Cherry Picking. (line 85) -* A a <1>: Cherry Picking. (line 91) -* A d: Cherry Picking. (line 51) -* A h: Cherry Picking. (line 40) -* A n: Cherry Picking. (line 62) -* A s: Cherry Picking. (line 72) -* A s <1>: Cherry Picking. (line 88) -* B: Bisecting. (line 9) -* b: Blaming. (line 115) -* b <1>: Branch Commands. (line 13) -* b <2>: Editing Rebase Sequences. - (line 70) -* B B: Bisecting. (line 16) -* B b: Bisecting. (line 32) -* b b: Branch Commands. (line 47) -* b C: Branch Commands. (line 31) -* b c: Branch Commands. (line 63) -* B g: Bisecting. (line 36) -* B k: Bisecting. (line 46) -* b k: Branch Commands. (line 138) -* b l: Branch Commands. (line 69) -* B m: Bisecting. (line 40) -* b m: Branch Commands. (line 149) -* b n: Branch Commands. (line 54) -* B r: Bisecting. (line 51) -* B s: Bisecting. (line 26) -* b s: Branch Commands. (line 91) -* b S: Branch Commands. (line 118) -* b x: Branch Commands. (line 123) -* c: Blaming. (line 141) -* C: Cloning Repository. (line 20) -* c <1>: Initiating a Commit. (line 9) -* c <2>: Editing Rebase Sequences. - (line 59) -* C >: Cloning Repository. (line 38) -* c a: Initiating a Commit. (line 18) -* c A: Initiating a Commit. (line 59) -* C b: Cloning Repository. (line 44) -* C C: Cloning Repository. (line 28) -* c c: Initiating a Commit. (line 14) -* C d: Cloning Repository. (line 55) -* C e: Cloning Repository. (line 61) -* c e: Initiating a Commit. (line 21) -* c f: Initiating a Commit. (line 39) -* c F: Initiating a Commit. (line 46) -* C m: Cloning Repository. (line 48) -* C s: Cloning Repository. (line 32) -* c s: Initiating a Commit. (line 49) -* c S: Initiating a Commit. (line 56) -* c w: Initiating a Commit. (line 30) -* C-<return>: Visiting Files and Blobs from a Diff. - (line 50) -* C-<tab>: Section Visibility. (line 14) -* C-c C-a: Commit Pseudo Headers. - (line 16) -* C-c C-b: Log Buffer. (line 20) -* C-c C-b <1>: Refreshing Diffs. (line 84) -* C-c C-c: Select from Log. (line 21) -* C-c C-c <1>: Editing Commit Messages. - (line 18) -* C-c C-c <2>: Editing Rebase Sequences. - (line 7) -* C-c C-d: Refreshing Diffs. (line 75) -* C-c C-d <1>: Editing Commit Messages. - (line 54) -* C-c C-e: Commands Available in Diffs. - (line 24) -* C-c C-f: Log Buffer. (line 23) -* C-c C-f <1>: Refreshing Diffs. (line 87) -* C-c C-i: Commit Pseudo Headers. - (line 13) -* C-c C-k: Select from Log. (line 26) -* C-c C-k <1>: Editing Commit Messages. - (line 22) -* C-c C-k <2>: Editing Rebase Sequences. - (line 11) -* C-c C-n: Log Buffer. (line 26) -* C-c C-o: Commit Pseudo Headers. - (line 28) -* C-c C-p: Commit Pseudo Headers. - (line 31) -* C-c C-r: Commit Pseudo Headers. - (line 19) -* C-c C-s: Commit Pseudo Headers. - (line 22) -* C-c C-t: Commands Available in Diffs. - (line 15) -* C-c C-t <1>: Commit Pseudo Headers. - (line 25) -* C-c C-w: Using the Revision Stack. - (line 7) -* C-c f: Commands for Buffers Visiting Files. - (line 52) -* C-c f , c: Commands for Buffers Visiting Files. - (line 52) -* C-c f , k: Commands for Buffers Visiting Files. - (line 52) -* C-c f , r: Commands for Buffers Visiting Files. - (line 52) -* C-c f , x: Commands for Buffers Visiting Files. - (line 52) -* C-c f B: Blaming. (line 28) -* C-c f b: Blaming. (line 28) -* C-c f B <1>: Commands for Buffers Visiting Files. - (line 52) -* C-c f b <1>: Commands for Buffers Visiting Files. - (line 52) -* C-c f B b: Blaming. (line 28) -* C-c f B e: Blaming. (line 28) -* C-c f B f: Blaming. (line 28) -* C-c f B q: Blaming. (line 28) -* C-c f B r: Blaming. (line 28) -* C-c f c: Commands for Buffers Visiting Files. - (line 52) -* C-c f D: Commands for Buffers Visiting Files. - (line 52) -* C-c f d: Commands for Buffers Visiting Files. - (line 52) -* C-c f e: Blaming. (line 28) -* C-c f e <1>: Commands for Buffers Visiting Files. - (line 52) -* C-c f f: Blaming. (line 28) -* C-c f f <1>: Commands for Buffers Visiting Files. - (line 52) -* C-c f g: Commands for Buffers Visiting Files. - (line 52) -* C-c f G: Commands for Buffers Visiting Files. - (line 52) -* C-c f L: Commands for Buffers Visiting Files. - (line 52) -* C-c f l: Commands for Buffers Visiting Files. - (line 52) -* C-c f M: Commands for Buffers Visiting Files. - (line 52) -* C-c f m: Commands for Buffers Visiting Files. - (line 52) -* C-c f n: Commands for Buffers Visiting Files. - (line 52) -* C-c f p: Commands for Buffers Visiting Files. - (line 52) -* C-c f q: Blaming. (line 28) -* C-c f q <1>: Commands for Buffers Visiting Files. - (line 52) -* C-c f r: Blaming. (line 28) -* C-c f r <1>: Commands for Buffers Visiting Files. - (line 52) -* C-c f s: Commands for Buffers Visiting Files. - (line 52) -* C-c f s <1>: Commands for Buffers Visiting Files. - (line 52) -* C-c f t: Commands for Buffers Visiting Files. - (line 52) -* C-c f u: Commands for Buffers Visiting Files. - (line 52) -* C-c f u <1>: Commands for Buffers Visiting Files. - (line 52) -* C-c f v: Commands for Buffers Visiting Files. - (line 52) -* C-c f V: Commands for Buffers Visiting Files. - (line 52) -* C-c g: Transient Commands. (line 20) -* C-c M-g: Commands for Buffers Visiting Files. - (line 58) -* C-c M-g , c: Commands for Buffers Visiting Files. - (line 86) -* C-c M-g , k: Commands for Buffers Visiting Files. - (line 82) -* C-c M-g , r: Commands for Buffers Visiting Files. - (line 78) -* C-c M-g , x: Commands for Buffers Visiting Files. - (line 74) -* C-c M-g B: Blaming. (line 34) -* C-c M-g b: Blaming. (line 45) -* C-c M-g B <1>: Commands for Buffers Visiting Files. - (line 137) -* C-c M-g B b: Blaming. (line 45) -* C-c M-g B e: Blaming. (line 76) -* C-c M-g B f: Blaming. (line 68) -* C-c M-g B q: Blaming. (line 87) -* C-c M-g B r: Blaming. (line 60) -* C-c M-g c: Commands for Buffers Visiting Files. - (line 176) -* C-c M-g D: Commands for Buffers Visiting Files. - (line 91) -* C-c M-g d: Commands for Buffers Visiting Files. - (line 101) -* C-c M-g e: Blaming. (line 76) -* C-c M-g e <1>: Commands for Buffers Visiting Files. - (line 182) -* C-c M-g f: Blaming. (line 68) -* C-c M-g g: Commands for Buffers Visiting Files. - (line 166) -* C-c M-g G: Commands for Buffers Visiting Files. - (line 172) -* C-c M-g L: Commands for Buffers Visiting Files. - (line 109) -* C-c M-g l: Commands for Buffers Visiting Files. - (line 119) -* C-c M-g M: Commands for Buffers Visiting Files. - (line 132) -* C-c M-g n: Commands for Buffers Visiting Files. - (line 153) -* C-c M-g p: Commands for Buffers Visiting Files. - (line 149) -* C-c M-g q: Blaming. (line 87) -* C-c M-g r: Blaming. (line 60) -* C-c M-g s: Commands for Buffers Visiting Files. - (line 63) -* C-c M-g s <1>: Commands for Buffers Visiting Files. - (line 63) -* C-c M-g t: Commands for Buffers Visiting Files. - (line 129) -* C-c M-g u: Commands for Buffers Visiting Files. - (line 69) -* C-c M-g u <1>: Commands for Buffers Visiting Files. - (line 69) -* C-c M-g v: Commands for Buffers Visiting Files. - (line 156) -* C-c M-g V: Commands for Buffers Visiting Files. - (line 160) -* C-c M-i: Commit Pseudo Headers. - (line 35) -* C-c M-s: Editing Commit Messages. - (line 33) -* C-c TAB: Section Visibility. (line 14) -* C-w: Common Commands. (line 22) -* C-x g: Status Buffer. (line 23) -* C-x M-g: Transient Commands. (line 20) -* C-x u: Editing Rebase Sequences. - (line 77) -* d: Diffing. (line 22) -* D: Refreshing Diffs. (line 16) -* d c: Diffing. (line 63) -* d d: Diffing. (line 27) -* D f: Refreshing Diffs. (line 45) -* D F: Refreshing Diffs. (line 49) -* D g: Refreshing Diffs. (line 21) -* d p: Diffing. (line 56) -* d r: Diffing. (line 30) -* D r: Refreshing Diffs. (line 41) -* d s: Diffing. (line 48) -* D s: Refreshing Diffs. (line 25) -* d t: Diffing. (line 67) -* D t: Refreshing Diffs. (line 38) -* d u: Diffing. (line 53) -* d w: Diffing. (line 43) -* D w: Refreshing Diffs. (line 31) -* DEL: Log Buffer. (line 50) -* DEL <1>: Commands Available in Diffs. - (line 56) -* DEL <2>: Blaming. (line 103) -* DEL <3>: Editing Rebase Sequences. - (line 25) -* e: Ediffing. (line 10) -* E: Ediffing. (line 21) -* e <1>: Editing Rebase Sequences. - (line 46) -* E c: Ediffing. (line 100) -* E i: Ediffing. (line 94) -* E m: Ediffing. (line 33) -* E M: Ediffing. (line 48) -* E r: Ediffing. (line 25) -* E s: Ediffing. (line 87) -* E t: Ediffing. (line 79) -* E u: Ediffing. (line 91) -* E w: Ediffing. (line 97) -* E z: Ediffing. (line 103) -* f: Repository List. (line 111) -* f <1>: Editing Rebase Sequences. - (line 52) -* f <2>: Fetching. (line 10) -* F: Pulling. (line 10) -* f a: Fetching. (line 45) -* f C: Branch Commands. (line 31) -* F C: Branch Commands. (line 31) -* f e: Fetching. (line 34) -* F e: Pulling. (line 28) -* f m: Fetching. (line 48) -* f o: Fetching. (line 37) -* f p: Fetching. (line 15) -* F p: Pulling. (line 14) -* f r: Fetching. (line 41) -* f u: Fetching. (line 22) -* F u: Pulling. (line 21) -* g: Automatic Refreshing of Magit Buffers. - (line 26) -* G: Automatic Refreshing of Magit Buffers. - (line 34) -* H: Section Types and Values. - (line 14) -* I: Creating Repository. (line 7) -* j: Log Buffer. (line 31) -* j <1>: Commands Available in Diffs. - (line 43) -* k: Viewing Git Output. (line 24) -* k <1>: Applying. (line 40) -* k <2>: Editing Rebase Sequences. - (line 56) -* k <3>: Stashing. (line 118) -* l: Logging. (line 30) -* L: Refreshing Logs. (line 12) -* L <1>: Log Buffer. (line 7) -* L <2>: Log Margin. (line 52) -* l <1>: Editing Rebase Sequences. - (line 94) -* l a: Logging. (line 61) -* l b: Logging. (line 58) -* L d: Log Margin. (line 66) -* L g: Refreshing Logs. (line 17) -* l h: Logging. (line 40) -* l H: Reflog. (line 18) -* l l: Logging. (line 35) -* l L: Logging. (line 55) -* L L: Refreshing Logs. (line 34) -* L L <1>: Log Margin. (line 60) -* L l: Log Margin. (line 63) -* l o: Logging. (line 49) -* l O: Reflog. (line 15) -* l r: Reflog. (line 12) -* L s: Refreshing Logs. (line 21) -* l u: Logging. (line 43) -* L w: Refreshing Logs. (line 27) -* m: Repository List. (line 105) -* m <1>: Merging. (line 10) -* M: Remote Commands. (line 14) -* m a: Merging. (line 42) -* m a <1>: Merging. (line 91) -* M a: Remote Commands. (line 48) -* M C: Remote Commands. (line 32) -* m e: Merging. (line 30) -* m i: Merging. (line 54) -* M k: Remote Commands. (line 60) -* m m: Merging. (line 18) -* m m <1>: Merging. (line 86) -* m n: Merging. (line 36) -* m p: Merging. (line 75) -* M p: Remote Commands. (line 63) -* M P: Remote Commands. (line 67) -* M r: Remote Commands. (line 52) -* m s: Merging. (line 67) -* M u: Remote Commands. (line 56) -* M-1: Section Visibility. (line 45) -* M-2: Section Visibility. (line 45) -* M-3: Section Visibility. (line 45) -* M-4: Section Visibility. (line 45) -* M-<tab>: Section Visibility. (line 29) -* M-n: Section Movement. (line 24) -* M-n <1>: Editing Commit Messages. - (line 41) -* M-n <2>: Editing Rebase Sequences. - (line 40) -* M-p: Section Movement. (line 19) -* M-p <1>: Editing Commit Messages. - (line 36) -* M-p <2>: Editing Rebase Sequences. - (line 37) -* M-w: Blaming. (line 134) -* M-w <1>: Common Commands. (line 39) -* MM: Editing Rebase Sequences. - (line 102) -* Mt: Editing Rebase Sequences. - (line 108) -* n: Section Movement. (line 16) -* n <1>: Blaming. (line 118) -* N: Blaming. (line 121) -* n <2>: Editing Rebase Sequences. - (line 34) -* n <3>: Minor Mode for Buffers Visiting Blobs. - (line 16) -* o: Submodule Transient. (line 7) -* O: Subtree. (line 9) -* o a: Submodule Transient. (line 20) -* o d: Submodule Transient. (line 45) -* O e: Subtree. (line 37) -* O e p: Subtree. (line 48) -* O e s: Subtree. (line 52) -* o f: Submodule Transient. (line 51) -* O i: Subtree. (line 13) -* O i a: Subtree. (line 24) -* O i c: Subtree. (line 28) -* O i f: Subtree. (line 34) -* O i m: Subtree. (line 31) -* o l: Submodule Transient. (line 48) -* o p: Submodule Transient. (line 32) -* o r: Submodule Transient. (line 26) -* o s: Submodule Transient. (line 40) -* o u: Submodule Transient. (line 36) -* p: Section Movement. (line 11) -* p <1>: Blaming. (line 124) -* P: Blaming. (line 127) -* p <2>: Editing Rebase Sequences. - (line 31) -* P <1>: Pushing. (line 10) -* p <3>: Minor Mode for Buffers Visiting Blobs. - (line 13) -* P C: Branch Commands. (line 31) -* P e: Pushing. (line 29) -* P m: Pushing. (line 45) -* P o: Pushing. (line 33) -* P p: Pushing. (line 15) -* P r: Pushing. (line 37) -* P t: Pushing. (line 52) -* P T: Pushing. (line 59) -* P u: Pushing. (line 22) -* q: Quitting Windows. (line 7) -* q <1>: Log Buffer. (line 14) -* q <2>: Blaming. (line 130) -* q <3>: Minor Mode for Buffers Visiting Blobs. - (line 19) -* r: Rebasing. (line 10) -* r <1>: Editing Rebase Sequences. - (line 43) -* r a: Rebasing. (line 111) -* r e: Rebasing. (line 42) -* r e <1>: Rebasing. (line 107) -* r f: Rebasing. (line 79) -* r i: Rebasing. (line 76) -* r k: Rebasing. (line 91) -* r m: Rebasing. (line 83) -* r p: Rebasing. (line 28) -* r r: Rebasing. (line 97) -* r s: Rebasing. (line 47) -* r s <1>: Rebasing. (line 103) -* r u: Rebasing. (line 35) -* r w: Rebasing. (line 87) -* RET: Repository List. (line 102) -* RET <1>: References Buffer. (line 159) -* RET <2>: Visiting Files and Blobs from a Diff. - (line 9) -* RET <3>: Blaming. (line 91) -* RET <4>: Editing Rebase Sequences. - (line 15) -* s: Staging and Unstaging. - (line 29) -* S: Staging and Unstaging. - (line 36) -* s <1>: Editing Rebase Sequences. - (line 49) -* S-<tab>: Section Visibility. (line 33) -* SPC: Log Buffer. (line 41) -* SPC <1>: Commands Available in Diffs. - (line 53) -* SPC <2>: Blaming. (line 94) -* SPC <3>: Editing Rebase Sequences. - (line 19) -* t: Editing Rebase Sequences. - (line 97) -* t <1>: Tagging. (line 9) -* T: Notes. (line 9) -* T a: Notes. (line 47) -* T c: Notes. (line 43) -* t k: Tagging. (line 37) -* T m: Notes. (line 35) -* t p: Tagging. (line 43) -* T p: Notes. (line 28) -* t r: Tagging. (line 18) -* T r: Notes. (line 21) -* t t: Tagging. (line 14) -* T T: Notes. (line 14) -* TAB: Section Visibility. (line 10) -* u: Repository List. (line 108) -* u <1>: Staging and Unstaging. - (line 42) -* U: Staging and Unstaging. - (line 50) -* v: Applying. (line 47) -* V: Reverting. (line 7) -* V a: Reverting. (line 35) -* V s: Reverting. (line 32) -* V V: Reverting. (line 15) -* V v: Reverting. (line 20) -* V V <1>: Reverting. (line 29) -* W: Plain Patches. (line 7) -* w: Maildir Patches. (line 9) -* w a: Plain Patches. (line 20) -* w a <1>: Maildir Patches. (line 23) -* w a <2>: Maildir Patches. (line 38) -* W c: Plain Patches. (line 12) -* w m: Maildir Patches. (line 20) -* W s: Plain Patches. (line 26) -* w s: Maildir Patches. (line 34) -* w w: Maildir Patches. (line 14) -* w w <1>: Maildir Patches. (line 31) -* x: Editing Rebase Sequences. - (line 62) -* x <1>: Resetting. (line 9) -* X f: Resetting. (line 44) -* X h: Resetting. (line 24) -* X i: Resetting. (line 33) -* X k: Resetting. (line 28) -* X m: Resetting. (line 15) -* X s: Resetting. (line 19) -* X w: Resetting. (line 39) -* X w <1>: Wip Modes. (line 64) -* Y: Cherries. (line 18) -* y: References Buffer. (line 7) -* y <1>: Editing Rebase Sequences. - (line 74) -* y c: References Buffer. (line 25) -* y o: References Buffer. (line 30) -* y r: References Buffer. (line 34) -* y y: References Buffer. (line 21) -* z: Stashing. (line 9) -* Z: Worktree. (line 9) -* z a: Stashing. (line 52) -* z b: Stashing. (line 105) -* z B: Stashing. (line 110) -* Z b: Worktree. (line 13) -* Z c: Worktree. (line 16) -* z f: Stashing. (line 115) -* Z g: Worktree. (line 26) -* z i: Stashing. (line 20) -* z I: Stashing. (line 42) -* z k: Stashing. (line 98) -* Z k: Worktree. (line 22) -* z l: Stashing. (line 121) -* Z m: Worktree. (line 19) -* z p: Stashing. (line 74) -* z v: Stashing. (line 102) -* z w: Stashing. (line 24) -* z W: Stashing. (line 46) -* z x: Stashing. (line 30) -* z z: Stashing. (line 14) -* z Z: Stashing. (line 36) - - -File: magit.info, Node: Function and Command Index, Next: Variable Index, Prev: Keystroke Index, Up: Top - -Appendix D Function and Command Index -************************************* - - -* Menu: - -* bug-reference-mode: Commit Mode and Hooks. - (line 48) -* forward-line: Editing Rebase Sequences. - (line 34) -* git-commit-ack: Commit Pseudo Headers. - (line 16) -* git-commit-cc: Commit Pseudo Headers. - (line 28) -* git-commit-check-style-conventions: Commit Message Conventions. - (line 33) -* git-commit-insert-pseudo-header: Commit Pseudo Headers. - (line 13) -* git-commit-next-message: Editing Commit Messages. - (line 41) -* git-commit-prev-message: Editing Commit Messages. - (line 36) -* git-commit-propertize-diff: Commit Mode and Hooks. - (line 40) -* git-commit-reported: Commit Pseudo Headers. - (line 31) -* git-commit-review: Commit Pseudo Headers. - (line 19) -* git-commit-save-message: Editing Commit Messages. - (line 33) -* git-commit-save-message <1>: Commit Mode and Hooks. - (line 26) -* git-commit-setup-changelog-support: Commit Mode and Hooks. - (line 29) -* git-commit-signoff: Commit Pseudo Headers. - (line 22) -* git-commit-suggested: Commit Pseudo Headers. - (line 35) -* git-commit-test: Commit Pseudo Headers. - (line 25) -* git-commit-turn-on-auto-fill: Commit Mode and Hooks. - (line 33) -* git-commit-turn-on-flyspell: Commit Mode and Hooks. - (line 36) -* git-rebase-backward-line: Editing Rebase Sequences. - (line 31) -* git-rebase-break: Editing Rebase Sequences. - (line 70) -* git-rebase-edit: Editing Rebase Sequences. - (line 46) -* git-rebase-exec: Editing Rebase Sequences. - (line 62) -* git-rebase-fixup: Editing Rebase Sequences. - (line 52) -* git-rebase-insert: Editing Rebase Sequences. - (line 74) -* git-rebase-kill-line: Editing Rebase Sequences. - (line 56) -* git-rebase-label: Editing Rebase Sequences. - (line 94) -* git-rebase-merge: Editing Rebase Sequences. - (line 102) -* git-rebase-merge-toggle-editmsg: Editing Rebase Sequences. - (line 108) -* git-rebase-move-line-down: Editing Rebase Sequences. - (line 40) -* git-rebase-move-line-up: Editing Rebase Sequences. - (line 37) -* git-rebase-pick: Editing Rebase Sequences. - (line 59) -* git-rebase-reset: Editing Rebase Sequences. - (line 97) -* git-rebase-reword: Editing Rebase Sequences. - (line 43) -* git-rebase-show-commit: Editing Rebase Sequences. - (line 15) -* git-rebase-show-or-scroll-down: Editing Rebase Sequences. - (line 25) -* git-rebase-show-or-scroll-up: Editing Rebase Sequences. - (line 19) -* git-rebase-squash: Editing Rebase Sequences. - (line 49) -* git-rebase-undo: Editing Rebase Sequences. - (line 77) -* ido-enter-magit-status: Status Buffer. (line 96) -* magit-add-section-hook: Section Hooks. (line 20) -* magit-after-save-refresh-status: Automatic Refreshing of Magit Buffers. - (line 55) -* magit-am: Maildir Patches. (line 9) -* magit-am-abort: Maildir Patches. (line 38) -* magit-am-apply-maildir: Maildir Patches. (line 20) -* magit-am-apply-patches: Maildir Patches. (line 14) -* magit-am-continue: Maildir Patches. (line 31) -* magit-am-skip: Maildir Patches. (line 34) -* magit-apply: Applying. (line 34) -* magit-bisect: Bisecting. (line 9) -* magit-bisect-bad: Bisecting. (line 32) -* magit-bisect-good: Bisecting. (line 36) -* magit-bisect-mark: Bisecting. (line 40) -* magit-bisect-reset: Bisecting. (line 51) -* magit-bisect-run: Bisecting. (line 26) -* magit-bisect-skip: Bisecting. (line 46) -* magit-bisect-start: Bisecting. (line 16) -* magit-blame: Blaming. (line 28) -* magit-blame <1>: Blaming. (line 34) -* magit-blame <2>: Blaming. (line 115) -* magit-blame <3>: Commands for Buffers Visiting Files. - (line 52) -* magit-blame <4>: Commands for Buffers Visiting Files. - (line 137) -* magit-blame-addition: Blaming. (line 28) -* magit-blame-addition <1>: Blaming. (line 45) -* magit-blame-additions: Commands for Buffers Visiting Files. - (line 52) -* magit-blame-copy-hash: Blaming. (line 134) -* magit-blame-cycle-style: Blaming. (line 141) -* magit-blame-echo: Blaming. (line 28) -* magit-blame-echo <1>: Blaming. (line 76) -* magit-blame-echo <2>: Commands for Buffers Visiting Files. - (line 52) -* magit-blame-next-chunk: Blaming. (line 118) -* magit-blame-next-chunk-same-commit: Blaming. (line 121) -* magit-blame-previous-chunk: Blaming. (line 124) -* magit-blame-previous-chunk-same-commit: Blaming. (line 127) -* magit-blame-quit: Blaming. (line 28) -* magit-blame-quit <1>: Blaming. (line 87) -* magit-blame-quit <2>: Blaming. (line 130) -* magit-blame-quit <3>: Commands for Buffers Visiting Files. - (line 52) -* magit-blame-removal: Blaming. (line 28) -* magit-blame-removal <1>: Blaming. (line 60) -* magit-blame-removal <2>: Commands for Buffers Visiting Files. - (line 52) -* magit-blame-reverse: Blaming. (line 28) -* magit-blame-reverse <1>: Blaming. (line 68) -* magit-blame-reverse <2>: Commands for Buffers Visiting Files. - (line 52) -* magit-blob-next: Commands for Buffers Visiting Files. - (line 52) -* magit-blob-next <1>: Commands for Buffers Visiting Files. - (line 153) -* magit-blob-next <2>: Minor Mode for Buffers Visiting Blobs. - (line 16) -* magit-blob-previous: Commands for Buffers Visiting Files. - (line 52) -* magit-blob-previous <1>: Commands for Buffers Visiting Files. - (line 149) -* magit-blob-previous <2>: Minor Mode for Buffers Visiting Blobs. - (line 13) -* magit-blob-visit-file: Commands for Buffers Visiting Files. - (line 52) -* magit-blob-visit-file <1>: Commands for Buffers Visiting Files. - (line 160) -* magit-branch: Branch Commands. (line 13) -* magit-branch-and-checkout: Branch Commands. (line 63) -* magit-branch-checkout: Branch Commands. (line 69) -* magit-branch-configure: Branch Commands. (line 31) -* magit-branch-create: Branch Commands. (line 54) -* magit-branch-delete: Branch Commands. (line 138) -* magit-branch-or-checkout: Branch Commands. (line 257) -* magit-branch-orphan: Branch Commands. (line 253) -* magit-branch-rename: Branch Commands. (line 149) -* magit-branch-reset: Branch Commands. (line 123) -* magit-branch-shelve: Auxiliary Branch Commands. - (line 9) -* magit-branch-spinoff: Branch Commands. (line 91) -* magit-branch-spinout: Branch Commands. (line 118) -* magit-branch-unshelve: Auxiliary Branch Commands. - (line 19) -* magit-builtin-completing-read: Support for Completion Frameworks. - (line 41) -* magit-bundle: Bundle. (line 8) -* magit-call-git: Calling Git for Effect. - (line 28) -* magit-call-process: Calling Git for Effect. - (line 31) -* magit-cancel-section: Creating Sections. (line 69) -* magit-checkout: Branch Commands. (line 47) -* magit-cherry: Cherries. (line 18) -* magit-cherry-apply: Cherry Picking. (line 23) -* magit-cherry-copy: Cherry Picking. (line 17) -* magit-cherry-donate: Cherry Picking. (line 51) -* magit-cherry-harvest: Cherry Picking. (line 40) -* magit-cherry-pick: Cherry Picking. (line 9) -* magit-cherry-spinoff: Cherry Picking. (line 72) -* magit-cherry-spinout: Cherry Picking. (line 62) -* magit-clone: Cloning Repository. (line 20) -* magit-clone-bare: Cloning Repository. (line 44) -* magit-clone-mirror: Cloning Repository. (line 48) -* magit-clone-regular: Cloning Repository. (line 28) -* magit-clone-shallow: Cloning Repository. (line 32) -* magit-clone-shallow-exclude: Cloning Repository. (line 61) -* magit-clone-shallow-since: Cloning Repository. (line 55) -* magit-clone-sparse: Cloning Repository. (line 38) -* magit-commit: Initiating a Commit. (line 9) -* magit-commit <1>: Commands for Buffers Visiting Files. - (line 52) -* magit-commit <2>: Commands for Buffers Visiting Files. - (line 176) -* magit-commit-amend: Initiating a Commit. (line 18) -* magit-commit-augment: Initiating a Commit. (line 59) -* magit-commit-create: Initiating a Commit. (line 14) -* magit-commit-extend: Initiating a Commit. (line 21) -* magit-commit-fixup: Initiating a Commit. (line 39) -* magit-commit-instant-fixup: Initiating a Commit. (line 46) -* magit-commit-instant-squash: Initiating a Commit. (line 56) -* magit-commit-reword: Initiating a Commit. (line 30) -* magit-commit-squash: Initiating a Commit. (line 49) -* magit-completing-read: Support for Completion Frameworks. - (line 57) -* magit-copy-buffer-revision: Common Commands. (line 39) -* magit-copy-section-value: Common Commands. (line 22) -* magit-current-section: Section Selection. (line 6) -* magit-cycle-margin-style: Log Margin. (line 63) -* magit-debug-git-executable: Git Executable. (line 55) -* magit-debug-git-executable <1>: Debugging Tools. (line 57) -* magit-define-section-jumper: Creating Sections. (line 74) -* magit-describe-section: Section Types and Values. - (line 14) -* magit-describe-section-briefly: Section Types and Values. - (line 17) -* magit-describe-section-briefly <1>: Matching Sections. (line 7) -* magit-diff: Diffing. (line 22) -* magit-diff <1>: Commands for Buffers Visiting Files. - (line 52) -* magit-diff <2>: Commands for Buffers Visiting Files. - (line 91) -* magit-diff-buffer-file: Commands for Buffers Visiting Files. - (line 52) -* magit-diff-buffer-file <1>: Commands for Buffers Visiting Files. - (line 101) -* magit-diff-default-context: Refreshing Diffs. (line 68) -* magit-diff-dwim: Diffing. (line 27) -* magit-diff-edit-hunk-commit: Commands Available in Diffs. - (line 24) -* magit-diff-flip-revs: Refreshing Diffs. (line 45) -* magit-diff-less-context: Refreshing Diffs. (line 62) -* magit-diff-more-context: Refreshing Diffs. (line 65) -* magit-diff-paths: Diffing. (line 56) -* magit-diff-range: Diffing. (line 30) -* magit-diff-refresh: Refreshing Diffs. (line 16) -* magit-diff-refresh <1>: Refreshing Diffs. (line 21) -* magit-diff-save-default-arguments: Refreshing Diffs. (line 31) -* magit-diff-scope: Matching Sections. (line 110) -* magit-diff-set-default-arguments: Refreshing Diffs. (line 25) -* magit-diff-show-or-scroll-down: Log Buffer. (line 50) -* magit-diff-show-or-scroll-down <1>: Blaming. (line 103) -* magit-diff-show-or-scroll-up: Log Buffer. (line 41) -* magit-diff-show-or-scroll-up <1>: Blaming. (line 94) -* magit-diff-staged: Diffing. (line 48) -* magit-diff-switch-range-type: Refreshing Diffs. (line 41) -* magit-diff-toggle-file-filter: Refreshing Diffs. (line 49) -* magit-diff-toggle-refine-hunk: Refreshing Diffs. (line 38) -* magit-diff-trace-definition: Commands Available in Diffs. - (line 15) -* magit-diff-type: Matching Sections. (line 88) -* magit-diff-unstaged: Diffing. (line 53) -* magit-diff-visit-file: Visiting Files and Blobs from a Diff. - (line 9) -* magit-diff-visit-file-other-frame: Visiting Files and Blobs from a Diff. - (line 71) -* magit-diff-visit-file-other-window: Visiting Files and Blobs from a Diff. - (line 70) -* magit-diff-visit-file-worktree: Visiting Files and Blobs from a Diff. - (line 50) -* magit-diff-visit-worktree-file-other-frame: Visiting Files and Blobs from a Diff. - (line 73) -* magit-diff-visit-worktree-file-other-window: Visiting Files and Blobs from a Diff. - (line 72) -* magit-diff-while-committing: Refreshing Diffs. (line 75) -* magit-diff-while-committing <1>: Editing Commit Messages. - (line 54) -* magit-diff-working-tree: Diffing. (line 43) -* magit-disable-section-inserter: Per-Repository Configuration. - (line 31) -* magit-discard: Applying. (line 40) -* magit-dispatch: Transient Commands. (line 20) -* magit-display-buffer: Switching Buffers. (line 6) -* magit-display-buffer-fullcolumn-most-v1: Switching Buffers. (line 68) -* magit-display-buffer-fullframe-status-topleft-v1: Switching Buffers. - (line 59) -* magit-display-buffer-fullframe-status-v1: Switching Buffers. - (line 54) -* magit-display-buffer-same-window-except-diff-v1: Switching Buffers. - (line 49) -* magit-display-buffer-traditional: Switching Buffers. (line 42) -* magit-display-repository-buffer: Common Commands. (line 9) -* magit-display-repository-buffer <1>: Commands for Buffers Visiting Files. - (line 52) -* magit-display-repository-buffer <2>: Commands for Buffers Visiting Files. - (line 172) -* magit-ediff: Ediffing. (line 21) -* magit-ediff-compare: Ediffing. (line 25) -* magit-ediff-dwim: Ediffing. (line 10) -* magit-ediff-resolve-all: Ediffing. (line 48) -* magit-ediff-resolve-rest: Ediffing. (line 33) -* magit-ediff-show-commit: Ediffing. (line 100) -* magit-ediff-show-staged: Ediffing. (line 94) -* magit-ediff-show-stash: Ediffing. (line 103) -* magit-ediff-show-unstaged: Ediffing. (line 91) -* magit-ediff-show-working-tree: Ediffing. (line 97) -* magit-ediff-stage: Ediffing. (line 87) -* magit-edit-line-commit: Commands for Buffers Visiting Files. - (line 52) -* magit-edit-line-commit <1>: Commands for Buffers Visiting Files. - (line 182) -* magit-emacs-Q-command: Debugging Tools. (line 16) -* magit-fetch: Fetching. (line 10) -* magit-fetch-all: Fetching. (line 45) -* magit-fetch-branch: Fetching. (line 37) -* magit-fetch-from-pushremote: Fetching. (line 15) -* magit-fetch-from-upstream: Fetching. (line 22) -* magit-fetch-modules: Submodule Transient. (line 51) -* magit-fetch-other: Fetching. (line 34) -* magit-fetch-refspec: Fetching. (line 41) -* magit-file-checkout: Resetting. (line 44) -* magit-file-checkout <1>: Commands for Buffers Visiting Files. - (line 52) -* magit-file-checkout <2>: Commands for Buffers Visiting Files. - (line 86) -* magit-file-delete: Commands for Buffers Visiting Files. - (line 52) -* magit-file-delete <1>: Commands for Buffers Visiting Files. - (line 82) -* magit-file-dispatch: Commands for Buffers Visiting Files. - (line 52) -* magit-file-dispatch <1>: Commands for Buffers Visiting Files. - (line 58) -* magit-file-rename: Commands for Buffers Visiting Files. - (line 52) -* magit-file-rename <1>: Commands for Buffers Visiting Files. - (line 78) -* magit-file-untrack: Commands for Buffers Visiting Files. - (line 52) -* magit-file-untrack <1>: Commands for Buffers Visiting Files. - (line 74) -* magit-find-file: General-Purpose Visit Commands. - (line 9) -* magit-find-file <1>: Commands for Buffers Visiting Files. - (line 52) -* magit-find-file <2>: Commands for Buffers Visiting Files. - (line 156) -* magit-find-file-other-frame: General-Purpose Visit Commands. - (line 19) -* magit-find-file-other-window: General-Purpose Visit Commands. - (line 14) -* magit-generate-buffer-name-default-function: Naming Buffers. - (line 16) -* magit-get-section: Matching Sections. (line 14) -* magit-git: Calling Git for Effect. - (line 46) -* magit-git-command: Running Git Manually. - (line 25) -* magit-git-command-topdir: Running Git Manually. - (line 17) -* magit-git-exit-code: Getting a Value from Git. - (line 10) -* magit-git-failure: Getting a Value from Git. - (line 17) -* magit-git-false: Getting a Value from Git. - (line 25) -* magit-git-insert: Getting a Value from Git. - (line 29) -* magit-git-items: Getting a Value from Git. - (line 41) -* magit-git-lines: Getting a Value from Git. - (line 37) -* magit-git-mergetool: Running Git Manually. - (line 62) -* magit-git-mergetool <1>: Ediffing. (line 79) -* magit-git-str: Getting a Value from Git. - (line 75) -* magit-git-string: Getting a Value from Git. - (line 32) -* magit-git-success: Getting a Value from Git. - (line 13) -* magit-git-true: Getting a Value from Git. - (line 21) -* magit-git-wash: Calling Git for Effect. - (line 50) -* magit-go-backward: Log Buffer. (line 20) -* magit-go-backward <1>: Refreshing Diffs. (line 84) -* magit-go-forward: Log Buffer. (line 23) -* magit-go-forward <1>: Refreshing Diffs. (line 87) -* magit-hunk-set-window-start: Section Movement. (line 45) -* magit-ido-completing-read: Support for Completion Frameworks. - (line 46) -* magit-init: Creating Repository. (line 7) -* magit-insert-am-sequence: Status Sections. (line 25) -* magit-insert-assumed-unchanged-files: Status Sections. (line 98) -* magit-insert-bisect-log: Status Sections. (line 39) -* magit-insert-bisect-output: Status Sections. (line 33) -* magit-insert-bisect-rest: Status Sections. (line 36) -* magit-insert-diff-filter-header: Status Header Sections. - (line 35) -* magit-insert-error-header: Status Header Sections. - (line 26) -* magit-insert-head-branch-header: Status Header Sections. - (line 38) -* magit-insert-heading: Creating Sections. (line 41) -* magit-insert-ignored-files: Status Sections. (line 83) -* magit-insert-local-branches: References Sections. (line 16) -* magit-insert-merge-log: Status Sections. (line 17) -* magit-insert-modules: Status Module Sections. - (line 12) -* magit-insert-modules-overview: Status Module Sections. - (line 30) -* magit-insert-modules-unpulled-from-pushremote: Status Module Sections. - (line 45) -* magit-insert-modules-unpulled-from-upstream: Status Module Sections. - (line 40) -* magit-insert-modules-unpushed-to-pushremote: Status Module Sections. - (line 55) -* magit-insert-modules-unpushed-to-upstream: Status Module Sections. - (line 50) -* magit-insert-push-branch-header: Status Header Sections. - (line 45) -* magit-insert-rebase-sequence: Status Sections. (line 21) -* magit-insert-recent-commits: Status Sections. (line 110) -* magit-insert-remote-branches: References Sections. (line 19) -* magit-insert-remote-header: Status Header Sections. - (line 58) -* magit-insert-repo-header: Status Header Sections. - (line 55) -* magit-insert-section: Creating Sections. (line 6) -* magit-insert-sequencer-sequence: Status Sections. (line 29) -* magit-insert-skip-worktree-files: Status Sections. (line 92) -* magit-insert-staged-changes: Status Sections. (line 53) -* magit-insert-stashes: Status Sections. (line 56) -* magit-insert-status-headers: Status Header Sections. - (line 12) -* magit-insert-tags: References Sections. (line 22) -* magit-insert-tags-header: Status Header Sections. - (line 49) -* magit-insert-tracked-files: Status Sections. (line 80) -* magit-insert-unpulled-cherries: Status Sections. (line 119) -* magit-insert-unpulled-from-pushremote: Status Sections. (line 66) -* magit-insert-unpulled-from-upstream: Status Sections. (line 62) -* magit-insert-unpulled-or-recent-commits: Status Sections. (line 104) -* magit-insert-unpushed-cherries: Status Sections. (line 125) -* magit-insert-unpushed-to-pushremote: Status Sections. (line 74) -* magit-insert-unpushed-to-upstream: Status Sections. (line 70) -* magit-insert-unstaged-changes: Status Sections. (line 50) -* magit-insert-untracked-files: Status Sections. (line 42) -* magit-insert-upstream-branch-header: Status Header Sections. - (line 41) -* magit-insert-user-header: Status Header Sections. - (line 65) -* magit-jump-to-diffstat-or-diff: Commands Available in Diffs. - (line 43) -* magit-kill-this-buffer: Minor Mode for Buffers Visiting Blobs. - (line 19) -* magit-list-repositories: Repository List. (line 6) -* magit-list-submodules: Listing Submodules. (line 13) -* magit-list-submodules <1>: Submodule Transient. (line 48) -* magit-log: Logging. (line 30) -* magit-log <1>: Commands for Buffers Visiting Files. - (line 52) -* magit-log <2>: Commands for Buffers Visiting Files. - (line 109) -* magit-log-all: Logging. (line 61) -* magit-log-all-branches: Logging. (line 58) -* magit-log-branches: Logging. (line 55) -* magit-log-buffer-file: Commands for Buffers Visiting Files. - (line 52) -* magit-log-buffer-file <1>: Commands for Buffers Visiting Files. - (line 119) -* magit-log-bury-buffer: Log Buffer. (line 14) -* magit-log-current: Logging. (line 35) -* magit-log-double-commit-limit: Log Buffer. (line 64) -* magit-log-half-commit-limit: Log Buffer. (line 67) -* magit-log-head: Logging. (line 40) -* magit-log-maybe-show-more-commits: Section Movement. (line 58) -* magit-log-maybe-update-blob-buffer: Section Movement. (line 72) -* magit-log-maybe-update-revision-buffer: Section Movement. (line 65) -* magit-log-merged: Commands for Buffers Visiting Files. - (line 52) -* magit-log-merged <1>: Commands for Buffers Visiting Files. - (line 132) -* magit-log-move-to-parent: Log Buffer. (line 26) -* magit-log-move-to-revision: Log Buffer. (line 31) -* magit-log-other: Logging. (line 49) -* magit-log-refresh: Refreshing Logs. (line 12) -* magit-log-refresh <1>: Refreshing Logs. (line 17) -* magit-log-refresh <2>: Log Buffer. (line 7) -* magit-log-related: Logging. (line 43) -* magit-log-save-default-arguments: Refreshing Logs. (line 27) -* magit-log-select-pick: Select from Log. (line 21) -* magit-log-select-quit: Select from Log. (line 26) -* magit-log-set-default-arguments: Refreshing Logs. (line 21) -* magit-log-toggle-commit-limit: Log Buffer. (line 59) -* magit-log-trace-definition: Commands for Buffers Visiting Files. - (line 52) -* magit-log-trace-definition <1>: Commands for Buffers Visiting Files. - (line 129) -* magit-margin-settings: Log Margin. (line 52) -* magit-maybe-set-dedicated: Switching Buffers. (line 89) -* magit-merge: Merging. (line 10) -* magit-merge <1>: Merging. (line 86) -* magit-merge-abort: Merging. (line 91) -* magit-merge-absorb: Merging. (line 42) -* magit-merge-editmsg: Merging. (line 30) -* magit-merge-into: Merging. (line 54) -* magit-merge-nocommit: Merging. (line 36) -* magit-merge-plain: Merging. (line 18) -* magit-merge-preview: Merging. (line 75) -* magit-merge-squash: Merging. (line 67) -* magit-mode-bury-buffer: Quitting Windows. (line 7) -* magit-mode-display-buffer: Refreshing Buffers. (line 32) -* magit-mode-quit-window: Quitting Windows. (line 34) -* magit-mode-setup: Refreshing Buffers. (line 17) -* magit-notes: Notes. (line 9) -* magit-notes-edit: Notes. (line 14) -* magit-notes-merge: Notes. (line 35) -* magit-notes-merge-abort: Notes. (line 47) -* magit-notes-merge-commit: Notes. (line 43) -* magit-notes-prune: Notes. (line 28) -* magit-notes-remove: Notes. (line 21) -* magit-patch: Plain Patches. (line 7) -* magit-patch-apply: Plain Patches. (line 20) -* magit-patch-apply <1>: Maildir Patches. (line 23) -* magit-patch-create: Plain Patches. (line 12) -* magit-patch-save: Plain Patches. (line 26) -* magit-pop-revision-stack: Using the Revision Stack. - (line 7) -* magit-process: Viewing Git Output. (line 17) -* magit-process-file: Getting a Value from Git. - (line 57) -* magit-process-git: Getting a Value from Git. - (line 50) -* magit-process-kill: Viewing Git Output. (line 24) -* magit-pull: Pulling. (line 10) -* magit-pull-branch: Pulling. (line 28) -* magit-pull-from-pushremote: Pulling. (line 14) -* magit-pull-from-upstream: Pulling. (line 21) -* magit-push: Pushing. (line 10) -* magit-push-current: Pushing. (line 29) -* magit-push-current-to-pushremote: Pushing. (line 15) -* magit-push-current-to-upstream: Pushing. (line 22) -* magit-push-implicitly: Pushing. (line 74) -* magit-push-matching: Pushing. (line 45) -* magit-push-other: Pushing. (line 33) -* magit-push-refspecs: Pushing. (line 37) -* magit-push-tag: Pushing. (line 59) -* magit-push-tags: Pushing. (line 52) -* magit-push-to-remote: Pushing. (line 91) -* magit-rebase: Rebasing. (line 10) -* magit-rebase-abort: Rebasing. (line 111) -* magit-rebase-autosquash: Rebasing. (line 79) -* magit-rebase-branch: Rebasing. (line 42) -* magit-rebase-continue: Rebasing. (line 97) -* magit-rebase-edit: Rebasing. (line 107) -* magit-rebase-edit-commit: Rebasing. (line 83) -* magit-rebase-interactive: Rebasing. (line 76) -* magit-rebase-onto-pushremote: Rebasing. (line 28) -* magit-rebase-onto-upstream: Rebasing. (line 35) -* magit-rebase-remove-commit: Rebasing. (line 91) -* magit-rebase-reword-commit: Rebasing. (line 87) -* magit-rebase-skip: Rebasing. (line 103) -* magit-rebase-subset: Rebasing. (line 47) -* magit-reflog-current: Reflog. (line 12) -* magit-reflog-head: Reflog. (line 18) -* magit-reflog-other: Reflog. (line 15) -* magit-refresh: Automatic Refreshing of Magit Buffers. - (line 26) -* magit-refresh-all: Automatic Refreshing of Magit Buffers. - (line 34) -* magit-refs-set-show-commit-count: References Buffer. (line 34) -* magit-region-sections: Section Selection. (line 9) -* magit-region-values: Section Selection. (line 35) -* magit-remote: Remote Commands. (line 14) -* magit-remote-add: Remote Commands. (line 48) -* magit-remote-configure: Remote Commands. (line 32) -* magit-remote-prune: Remote Commands. (line 63) -* magit-remote-prune-refspecs: Remote Commands. (line 67) -* magit-remote-remove: Remote Commands. (line 60) -* magit-remote-rename: Remote Commands. (line 52) -* magit-remote-set-url: Remote Commands. (line 56) -* magit-repolist-column-branch: Repository List. (line 51) -* magit-repolist-column-branches: Repository List. (line 58) -* magit-repolist-column-flag: Repository List. (line 64) -* magit-repolist-column-flags: Repository List. (line 76) -* magit-repolist-column-ident: Repository List. (line 40) -* magit-repolist-column-path: Repository List. (line 44) -* magit-repolist-column-stashes: Repository List. (line 61) -* magit-repolist-column-unpulled-from-pushremote: Repository List. - (line 87) -* magit-repolist-column-unpulled-from-upstream: Repository List. - (line 83) -* magit-repolist-column-unpushed-to-pushremote: Repository List. - (line 95) -* magit-repolist-column-unpushed-to-upstream: Repository List. - (line 91) -* magit-repolist-column-upstream: Repository List. (line 54) -* magit-repolist-column-version: Repository List. (line 47) -* magit-repolist-fetch: Repository List. (line 111) -* magit-repolist-find-file-other-frame: Repository List. (line 115) -* magit-repolist-mark: Repository List. (line 105) -* magit-repolist-status: Repository List. (line 102) -* magit-repolist-unmark: Repository List. (line 108) -* magit-reset-hard: Resetting. (line 24) -* magit-reset-index: Staging and Unstaging. - (line 78) -* magit-reset-index <1>: Resetting. (line 33) -* magit-reset-keep: Resetting. (line 28) -* magit-reset-mixed: Resetting. (line 15) -* magit-reset-quickly: Resetting. (line 9) -* magit-reset-soft: Resetting. (line 19) -* magit-reset-worktree: Resetting. (line 39) -* magit-reset-worktree <1>: Wip Modes. (line 64) -* magit-restore-window-configuration: Quitting Windows. (line 24) -* magit-reverse: Applying. (line 47) -* magit-reverse-in-index: Staging and Unstaging. - (line 58) -* magit-revert: Reverting. (line 7) -* magit-revert-and-commit: Reverting. (line 15) -* magit-revert-no-commit: Reverting. (line 20) -* magit-run: Running Git Manually. - (line 13) -* magit-run-git: Calling Git for Effect. - (line 34) -* magit-run-git-async: Calling Git for Effect. - (line 59) -* magit-run-git-gui: Running Git Manually. - (line 59) -* magit-run-git-with-editor: Calling Git for Effect. - (line 71) -* magit-run-git-with-input: Calling Git for Effect. - (line 37) -* magit-run-gitk: Running Git Manually. - (line 50) -* magit-run-gitk-all: Running Git Manually. - (line 53) -* magit-run-gitk-branches: Running Git Manually. - (line 56) -* magit-save-window-configuration: Switching Buffers. (line 80) -* magit-section-backward: Section Movement. (line 11) -* magit-section-backward-siblings: Section Movement. (line 19) -* magit-section-case: Matching Sections. (line 66) -* magit-section-cycle: Section Visibility. (line 14) -* magit-section-cycle-diffs: Section Visibility. (line 29) -* magit-section-cycle-global: Section Visibility. (line 33) -* magit-section-forward: Section Movement. (line 16) -* magit-section-forward-siblings: Section Movement. (line 24) -* magit-section-hide: Section Visibility. (line 55) -* magit-section-hide-children: Section Visibility. (line 67) -* magit-section-ident: Matching Sections. (line 10) -* magit-section-match: Matching Sections. (line 18) -* magit-section-set-window-start: Section Movement. (line 52) -* magit-section-show: Section Visibility. (line 52) -* magit-section-show-children: Section Visibility. (line 62) -* magit-section-show-headings: Section Visibility. (line 58) -* magit-section-show-level-1: Section Visibility. (line 39) -* magit-section-show-level-1-all: Section Visibility. (line 45) -* magit-section-show-level-2: Section Visibility. (line 39) -* magit-section-show-level-2-all: Section Visibility. (line 45) -* magit-section-show-level-3: Section Visibility. (line 39) -* magit-section-show-level-3-all: Section Visibility. (line 45) -* magit-section-show-level-4: Section Visibility. (line 39) -* magit-section-show-level-4-all: Section Visibility. (line 45) -* magit-section-toggle: Section Visibility. (line 10) -* magit-section-toggle-children: Section Visibility. (line 70) -* magit-section-up: Section Movement. (line 28) -* magit-section-value-if: Matching Sections. (line 57) -* magit-sequence-abort: Cherry Picking. (line 91) -* magit-sequence-abort <1>: Reverting. (line 35) -* magit-sequence-continue: Cherry Picking. (line 85) -* magit-sequence-continue <1>: Reverting. (line 29) -* magit-sequence-skip: Cherry Picking. (line 88) -* magit-sequence-skip <1>: Reverting. (line 32) -* magit-shell-command: Running Git Manually. - (line 38) -* magit-shell-command-topdir: Running Git Manually. - (line 34) -* magit-show-commit: Diffing. (line 63) -* magit-show-commit <1>: Blaming. (line 91) -* magit-show-refs: References Buffer. (line 7) -* magit-show-refs-current: References Buffer. (line 25) -* magit-show-refs-head: References Buffer. (line 21) -* magit-show-refs-other: References Buffer. (line 30) -* magit-snapshot-both: Stashing. (line 36) -* magit-snapshot-index: Stashing. (line 42) -* magit-snapshot-worktree: Stashing. (line 46) -* magit-sparse-checkout: Sparse checkouts. (line 17) -* magit-sparse-checkout-add: Sparse checkouts. (line 39) -* magit-sparse-checkout-disable: Sparse checkouts. (line 50) -* magit-sparse-checkout-enable: Sparse checkouts. (line 21) -* magit-sparse-checkout-reapply: Sparse checkouts. (line 44) -* magit-sparse-checkout-set: Sparse checkouts. (line 33) -* magit-stage: Staging and Unstaging. - (line 29) -* magit-stage-buffer-file: Commands for Buffers Visiting Files. - (line 52) -* magit-stage-buffer-file <1>: Commands for Buffers Visiting Files. - (line 63) -* magit-stage-file: Staging from File-Visiting Buffers. - (line 11) -* magit-stage-file <1>: Commands for Buffers Visiting Files. - (line 52) -* magit-stage-file <2>: Commands for Buffers Visiting Files. - (line 63) -* magit-stage-modified: Staging and Unstaging. - (line 36) -* magit-start-git: Calling Git for Effect. - (line 82) -* magit-start-process: Calling Git for Effect. - (line 100) -* magit-stash: Stashing. (line 9) -* magit-stash-apply: Stashing. (line 52) -* magit-stash-both: Stashing. (line 14) -* magit-stash-branch: Stashing. (line 105) -* magit-stash-branch-here: Stashing. (line 110) -* magit-stash-clear: Stashing. (line 118) -* magit-stash-drop: Stashing. (line 98) -* magit-stash-format-patch: Stashing. (line 115) -* magit-stash-index: Stashing. (line 20) -* magit-stash-keep-index: Stashing. (line 30) -* magit-stash-list: Stashing. (line 121) -* magit-stash-pop: Stashing. (line 74) -* magit-stash-show: Diffing. (line 67) -* magit-stash-show <1>: Stashing. (line 102) -* magit-stash-worktree: Stashing. (line 24) -* magit-stashes-maybe-update-stash-buffer: Section Movement. (line 92) -* magit-status: Status Buffer. (line 23) -* magit-status-here: Commands for Buffers Visiting Files. - (line 52) -* magit-status-here <1>: Commands for Buffers Visiting Files. - (line 166) -* magit-status-maybe-update-blob-buffer: Section Movement. (line 87) -* magit-status-maybe-update-revision-buffer: Section Movement. - (line 77) -* magit-status-maybe-update-stash-buffer: Section Movement. (line 82) -* magit-status-quick: Status Buffer. (line 70) -* magit-submodule: Submodule Transient. (line 7) -* magit-submodule-add: Submodule Transient. (line 20) -* magit-submodule-fetch: Fetching. (line 48) -* magit-submodule-populate: Submodule Transient. (line 32) -* magit-submodule-register: Submodule Transient. (line 26) -* magit-submodule-synchronize: Submodule Transient. (line 40) -* magit-submodule-unpopulate: Submodule Transient. (line 45) -* magit-submodule-update: Submodule Transient. (line 36) -* magit-subtree: Subtree. (line 9) -* magit-subtree-add: Subtree. (line 24) -* magit-subtree-add-commit: Subtree. (line 28) -* magit-subtree-export: Subtree. (line 37) -* magit-subtree-import: Subtree. (line 13) -* magit-subtree-merge: Subtree. (line 31) -* magit-subtree-pull: Subtree. (line 34) -* magit-subtree-push: Subtree. (line 48) -* magit-subtree-split: Subtree. (line 52) -* magit-switch-to-repository-buffer: Common Commands. (line 6) -* magit-switch-to-repository-buffer-other-frame: Common Commands. - (line 8) -* magit-switch-to-repository-buffer-other-window: Common Commands. - (line 7) -* magit-tag: Tagging. (line 9) -* magit-tag-create: Tagging. (line 14) -* magit-tag-delete: Tagging. (line 37) -* magit-tag-prune: Tagging. (line 43) -* magit-tag-release: Tagging. (line 18) -* magit-toggle-buffer-lock: Modes and Buffers. (line 18) -* magit-toggle-git-debug: Debugging Tools. (line 29) -* magit-toggle-margin: Refreshing Logs. (line 34) -* magit-toggle-margin <1>: Log Margin. (line 60) -* magit-toggle-margin-details: Log Margin. (line 66) -* magit-toggle-verbose-refresh: Debugging Tools. (line 52) -* magit-unstage: Staging and Unstaging. - (line 42) -* magit-unstage-all: Staging and Unstaging. - (line 50) -* magit-unstage-buffer-file: Commands for Buffers Visiting Files. - (line 52) -* magit-unstage-buffer-file <1>: Commands for Buffers Visiting Files. - (line 69) -* magit-unstage-file: Staging from File-Visiting Buffers. - (line 18) -* magit-unstage-file <1>: Commands for Buffers Visiting Files. - (line 52) -* magit-unstage-file <2>: Commands for Buffers Visiting Files. - (line 69) -* magit-version: Git Executable. (line 59) -* magit-version <1>: Debugging Tools. (line 11) -* magit-visit-ref: References Buffer. (line 159) -* magit-wip-commit: Wip Modes. (line 85) -* magit-wip-log: Wip Modes. (line 47) -* magit-wip-log-current: Wip Modes. (line 55) -* magit-worktree: Worktree. (line 9) -* magit-worktree-branch: Worktree. (line 16) -* magit-worktree-checkout: Worktree. (line 13) -* magit-worktree-delete: Worktree. (line 22) -* magit-worktree-move: Worktree. (line 19) -* magit-worktree-status: Worktree. (line 26) -* scroll-down: Commands Available in Diffs. - (line 56) -* scroll-up: Commands Available in Diffs. - (line 53) -* with-editor-cancel: Editing Commit Messages. - (line 22) -* with-editor-cancel <1>: Editing Rebase Sequences. - (line 11) -* with-editor-debug: Debugging Tools. (line 64) -* with-editor-finish: Editing Commit Messages. - (line 18) -* with-editor-finish <1>: Editing Rebase Sequences. - (line 7) -* with-editor-usage-message: Commit Mode and Hooks. - (line 51) - - -File: magit.info, Node: Variable Index, Prev: Function and Command Index, Up: Top - -Appendix E Variable Index -************************* - - -* Menu: - -* auto-revert-buffer-list-filter: Automatic Reverting of File-Visiting Buffers. - (line 73) -* auto-revert-interval: Automatic Reverting of File-Visiting Buffers. - (line 69) -* auto-revert-mode: Automatic Reverting of File-Visiting Buffers. - (line 57) -* auto-revert-stop-on-user-input: Automatic Reverting of File-Visiting Buffers. - (line 65) -* auto-revert-use-notify: Automatic Reverting of File-Visiting Buffers. - (line 46) -* auto-revert-verbose: Automatic Reverting of File-Visiting Buffers. - (line 94) -* branch.autoSetupMerge: Branch Git Variables. - (line 71) -* branch.autoSetupRebase: Branch Git Variables. - (line 85) -* branch.NAME.description: Branch Git Variables. - (line 42) -* branch.NAME.merge: Branch Git Variables. - (line 10) -* branch.NAME.pushRemote: Branch Git Variables. - (line 29) -* branch.NAME.rebase: Branch Git Variables. - (line 20) -* branch.NAME.remote: Branch Git Variables. - (line 15) -* core.notesRef: Notes. (line 53) -* git-commit-finish-query-functions: Commit Message Conventions. - (line 18) -* git-commit-known-pseudo-headers: Commit Pseudo Headers. - (line 9) -* git-commit-major-mode: Commit Mode and Hooks. - (line 12) -* git-commit-post-finish-hook: Commit Mode and Hooks. - (line 54) -* git-commit-setup-hook: Commit Mode and Hooks. - (line 21) -* git-commit-style-convention-checks: Commit Message Conventions. - (line 38) -* git-commit-summary-max-length: Commit Message Conventions. - (line 13) -* git-rebase-auto-advance: Editing Rebase Sequences. - (line 80) -* git-rebase-confirm-cancel: Editing Rebase Sequences. - (line 86) -* git-rebase-show-instructions: Editing Rebase Sequences. - (line 83) -* global-auto-revert-mode: Automatic Reverting of File-Visiting Buffers. - (line 21) -* magit-auto-revert-immediately: Automatic Reverting of File-Visiting Buffers. - (line 30) -* magit-auto-revert-mode: Automatic Reverting of File-Visiting Buffers. - (line 17) -* magit-auto-revert-tracked-only: Automatic Reverting of File-Visiting Buffers. - (line 51) -* magit-bisect-show-graph: Bisecting. (line 57) -* magit-blame-disable-modes: Blaming. (line 165) -* magit-blame-echo-style: Blaming. (line 151) -* magit-blame-goto-chunk-hook: Blaming. (line 170) -* magit-blame-read-only: Blaming. (line 161) -* magit-blame-styles: Blaming. (line 147) -* magit-blame-time-format: Blaming. (line 157) -* magit-branch-adjust-remote-upstream-alist: Branch Commands. (line 202) -* magit-branch-direct-configure: Branch Commands. (line 19) -* magit-branch-prefer-remote-upstream: Branch Commands. (line 158) -* magit-branch-read-upstream-first: Branch Commands. (line 153) -* magit-buffer-name-format: Naming Buffers. (line 25) -* magit-bury-buffer-function: Quitting Windows. (line 16) -* magit-cherry-margin: Cherries. (line 21) -* magit-clone-always-transient: Cloning Repository. (line 12) -* magit-clone-default-directory: Cloning Repository. (line 84) -* magit-clone-name-alist: Cloning Repository. (line 94) -* magit-clone-set-remote-head: Cloning Repository. (line 66) -* magit-clone-set-remote.pushDefault: Cloning Repository. (line 75) -* magit-clone-url-format: Cloning Repository. (line 114) -* magit-commit-ask-to-stage: Initiating a Commit. (line 65) -* magit-commit-diff-inhibit-same-window: Initiating a Commit. (line 97) -* magit-commit-extend-override-date: Initiating a Commit. (line 72) -* magit-commit-reword-override-date: Initiating a Commit. (line 75) -* magit-commit-show-diff: Initiating a Commit. (line 69) -* magit-commit-squash-confirm: Initiating a Commit. (line 78) -* magit-completing-read-function: Support for Completion Frameworks. - (line 27) -* magit-define-global-key-bindings: Global Bindings. (line 6) -* magit-diff-adjust-tab-width: Diff Options. (line 17) -* magit-diff-buffer-file-locked: Commands for Buffers Visiting Files. - (line 104) -* magit-diff-extra-stat-arguments: Diff Options. (line 112) -* magit-diff-hide-trailing-cr-characters: Diff Options. (line 77) -* magit-diff-highlight-hunk-region-functions: Diff Options. (line 80) -* magit-diff-highlight-indentation: Diff Options. (line 63) -* magit-diff-highlight-trailing: Diff Options. (line 59) -* magit-diff-paint-whitespace: Diff Options. (line 38) -* magit-diff-paint-whitespace-lines: Diff Options. (line 52) -* magit-diff-refine-hunk: Diff Options. (line 6) -* magit-diff-refine-ignore-whitespace: Diff Options. (line 13) -* magit-diff-unmarked-lines-keep-foreground: Diff Options. (line 105) -* magit-diff-visit-previous-blob: Visiting Files and Blobs from a Diff. - (line 38) -* magit-direct-use-buffer-arguments: Transient Arguments and Buffer Variables. - (line 73) -* magit-display-buffer-function: Switching Buffers. (line 25) -* magit-display-buffer-noselect: Switching Buffers. (line 17) -* magit-dwim-selection: Completion and Confirmation. - (line 42) -* magit-ediff-dwim-resolve-function: Ediffing. (line 105) -* magit-ediff-dwim-show-on-hunks: Ediffing. (line 111) -* magit-ediff-quit-hook: Ediffing. (line 124) -* magit-ediff-show-stash-with-index: Ediffing. (line 118) -* magit-generate-buffer-name-function: Naming Buffers. (line 6) -* magit-git-debug: Viewing Git Output. (line 26) -* magit-git-debug <1>: Getting a Value from Git. - (line 68) -* magit-git-executable: Git Executable. (line 26) -* magit-git-global-arguments: Global Git Arguments. - (line 6) -* magit-keep-region-overlay: The Selection. (line 52) -* magit-list-refs-sortby: Additional Completion Options. - (line 6) -* magit-log-auto-more: Log Buffer. (line 69) -* magit-log-buffer-file-locked: Commands for Buffers Visiting Files. - (line 124) -* magit-log-margin: Log Margin. (line 12) -* magit-log-margin-show-committer-date: Log Margin. (line 44) -* magit-log-section-commit-count: Status Sections. (line 114) -* magit-log-select-margin: Select from Log. (line 28) -* magit-log-show-color-graph-limit: Log Buffer. (line 78) -* magit-log-show-refname-after-summary: Log Buffer. (line 74) -* magit-log-show-signatures-limit: Log Buffer. (line 84) -* magit-log-trace-definition-function: Commands Available in Diffs. - (line 17) -* magit-module-sections-hook: Status Module Sections. - (line 19) -* magit-module-sections-nested: Status Module Sections. - (line 22) -* magit-no-confirm: Action Confirmation. (line 18) -* magit-pop-revision-stack-format: Using the Revision Stack. - (line 34) -* magit-post-clone-hook: Cloning Repository. (line 133) -* magit-post-commit-hook: Initiating a Commit. (line 86) -* magit-post-display-buffer-hook: Switching Buffers. (line 85) -* magit-pre-display-buffer-hook: Switching Buffers. (line 76) -* magit-prefer-remote-upstream: Branch Git Variables. - (line 109) -* magit-prefix-use-buffer-arguments: Transient Arguments and Buffer Variables. - (line 65) -* magit-process-extreme-logging: Viewing Git Output. (line 56) -* magit-process-raise-error: Calling Git for Effect. - (line 125) -* magit-pull-or-fetch: Fetching. (line 51) -* magit-reflog-margin: Reflog. (line 20) -* magit-refresh-args: Refreshing Buffers. (line 52) -* magit-refresh-buffer-hook: Automatic Refreshing of Magit Buffers. - (line 41) -* magit-refresh-function: Refreshing Buffers. (line 47) -* magit-refresh-status-buffer: Automatic Refreshing of Magit Buffers. - (line 46) -* magit-refs-filter-alist: References Buffer. (line 137) -* magit-refs-focus-column-width: References Buffer. (line 75) -* magit-refs-margin: References Buffer. (line 89) -* magit-refs-margin-for-tags: References Buffer. (line 112) -* magit-refs-pad-commit-counts: References Buffer. (line 45) -* magit-refs-primary-column-width: References Buffer. (line 63) -* magit-refs-sections-hook: References Sections. (line 13) -* magit-refs-show-commit-count: References Buffer. (line 36) -* magit-refs-show-remote-prefix: References Buffer. (line 57) -* magit-remote-add-set-remote.pushDefault: Remote Commands. (line 83) -* magit-remote-direct-configure: Remote Commands. (line 20) -* magit-remote-git-executable: Git Executable. (line 32) -* magit-repolist-columns: Repository List. (line 12) -* magit-repository-directories: Status Buffer. (line 57) -* magit-revision-filter-files-on-follow: Revision Buffer. (line 55) -* magit-revision-insert-related-refs: Revision Buffer. (line 6) -* magit-revision-show-gravatars: Revision Buffer. (line 15) -* magit-revision-use-hash-sections: Revision Buffer. (line 31) -* magit-root-section: Matching Sections. (line 81) -* magit-save-repository-buffers: Automatic Saving of File-Visiting Buffers. - (line 13) -* magit-section-cache-visibility: Section Visibility. (line 95) -* magit-section-initial-visibility-alist: Section Visibility. (line 79) -* magit-section-movement-hook: Section Movement. (line 41) -* magit-section-set-visibility-hook: Section Visibility. (line 105) -* magit-section-show-child-count: Section Options. (line 9) -* magit-section-visibility-indicator: Section Visibility. (line 122) -* magit-shell-command-verbose-prompt: Running Git Manually. - (line 43) -* magit-stashes-margin: Stashing. (line 123) -* magit-status-headers-hook: Status Header Sections. - (line 17) -* magit-status-margin: Status Options. (line 6) -* magit-status-sections-hook: Status Sections. (line 10) -* magit-submodule-list-columns: Listing Submodules. (line 20) -* magit-this-process: Calling Git for Effect. - (line 121) -* magit-uniquify-buffer-names: Naming Buffers. (line 65) -* magit-unstage-committed: Staging and Unstaging. - (line 52) -* magit-update-other-window-delay: Section Movement. (line 97) -* magit-visit-ref-behavior: References Buffer. (line 168) -* magit-wip-after-apply-mode: Legacy Wip Modes. (line 18) -* magit-wip-after-apply-mode-lighter: Legacy Wip Modes. (line 54) -* magit-wip-after-save-local-mode-lighter: Legacy Wip Modes. (line 51) -* magit-wip-after-save-mode: Legacy Wip Modes. (line 13) -* magit-wip-before-change-mode: Legacy Wip Modes. (line 31) -* magit-wip-before-change-mode-lighter: Legacy Wip Modes. (line 57) -* magit-wip-initial-backup-mode: Legacy Wip Modes. (line 35) -* magit-wip-initial-backup-mode-lighter: Legacy Wip Modes. (line 60) -* magit-wip-merge-branch: Wip Graph. (line 6) -* magit-wip-mode: Wip Modes. (line 30) -* magit-wip-mode-lighter: Wip Modes. (line 98) -* magit-wip-namespace: Wip Modes. (line 91) -* notes.displayRef: Notes. (line 57) -* pull.rebase: Branch Git Variables. - (line 50) -* remote.NAME.fetch: Remote Git Variables. - (line 14) -* remote.NAME.push: Remote Git Variables. - (line 23) -* remote.NAME.pushurl: Remote Git Variables. - (line 18) -* remote.NAME.tagOpts: Remote Git Variables. - (line 27) -* remote.NAME.url: Remote Git Variables. - (line 10) -* remote.pushDefault: Branch Git Variables. - (line 62) - - - -Tag Table: -Node: Top774 -Node: Introduction6566 -Node: Installation11282 -Node: Installing from Melpa11612 -Node: Installing from the Git Repository12687 -Node: Post-Installation Tasks15501 -Node: Getting Started16786 -Node: Interface Concepts22597 -Node: Modes and Buffers22976 -Node: Switching Buffers24687 -Node: Naming Buffers29426 -Node: Quitting Windows32501 -Node: Automatic Refreshing of Magit Buffers34436 -Node: Automatic Saving of File-Visiting Buffers37317 -Node: Automatic Reverting of File-Visiting Buffers38501 -Node: Risk of Reverting Automatically43486 -Node: Sections45868 -Node: Section Movement46794 -Node: Section Visibility51668 -Node: Section Hooks58355 -Node: Section Types and Values60761 -Node: Section Options62176 -Node: Transient Commands62647 -Node: Transient Arguments and Buffer Variables64123 -Node: Completion Confirmation and the Selection71140 -Node: Action Confirmation71586 -Node: Completion and Confirmation80091 -Node: The Selection83276 -Node: The hunk-internal region86174 -Node: Support for Completion Frameworks87263 -Node: Additional Completion Options92148 -Node: Mouse Support92746 -Node: Running Git93322 -Node: Viewing Git Output93567 -Node: Git Process Status96271 -Node: Running Git Manually97236 -Node: Git Executable99926 -Node: Global Git Arguments102934 -Node: Inspecting103739 -Node: Status Buffer104896 -Node: Status Sections109907 -Node: Status Header Sections115434 -Node: Status Module Sections118053 -Node: Status Options120550 -Node: Repository List121913 -Node: Logging126691 -Node: Refreshing Logs129533 -Node: Log Buffer130954 -Node: Log Margin135777 -Node: Select from Log138930 -Node: Reflog141140 -Node: Cherries142777 -Node: Diffing144615 -Node: Refreshing Diffs147649 -Node: Commands Available in Diffs151338 -Node: Diff Options153851 -Node: Revision Buffer159314 -Node: Ediffing162634 -Node: References Buffer168684 -Node: References Sections179278 -Node: Bisecting180135 -Node: Visiting Files and Blobs182446 -Node: General-Purpose Visit Commands182974 -Node: Visiting Files and Blobs from a Diff183927 -Node: Blaming187371 -Node: Manipulating194359 -Node: Creating Repository194701 -Node: Cloning Repository195238 -Node: Staging and Unstaging201679 -Node: Staging from File-Visiting Buffers205660 -Node: Applying206766 -Node: Committing208839 -Node: Initiating a Commit209422 -Node: Editing Commit Messages214612 -Node: Using the Revision Stack217385 -Node: Commit Pseudo Headers220430 -Node: Commit Mode and Hooks221725 -Node: Commit Message Conventions224583 -Node: Branching226570 -Node: The Two Remotes226796 -Node: Branch Commands229449 -Node: Branch Git Variables242299 -Node: Auxiliary Branch Commands247673 -Node: Merging248789 -Node: Resolving Conflicts252945 -Node: Rebasing258319 -Node: Editing Rebase Sequences263108 -Node: Information About In-Progress Rebase267324 -Ref: Information About In-Progress Rebase-Footnote-1276437 -Node: Cherry Picking277033 -Node: Reverting281367 -Node: Resetting282786 -Node: Stashing284612 -Node: Transferring290993 -Node: Remotes291215 -Node: Remote Commands291367 -Node: Remote Git Variables295406 -Node: Fetching296677 -Node: Pulling299123 -Node: Pushing300149 -Node: Plain Patches304440 -Node: Maildir Patches305911 -Node: Miscellaneous307390 -Node: Tagging307736 -Node: Notes309629 -Node: Submodules311964 -Node: Listing Submodules312182 -Node: Submodule Transient314330 -Node: Subtree316817 -Node: Worktree318748 -Node: Sparse checkouts319824 -Node: Bundle322600 -Node: Common Commands322975 -Node: Wip Modes325603 -Node: Wip Graph330494 -Node: Legacy Wip Modes332807 -Node: Commands for Buffers Visiting Files335694 -Node: Minor Mode for Buffers Visiting Blobs343921 -Node: Customizing344719 -Node: Per-Repository Configuration346315 -Node: Essential Settings348569 -Node: Safety348915 -Node: Performance350676 -Ref: Log Performance353639 -Ref: Diff Performance354944 -Ref: Refs Buffer Performance356285 -Ref: Committing Performance356860 -Node: Microsoft Windows Performance357842 -Node: MacOS Performance359033 -Ref: MacOS Performance-Footnote-1360056 -Node: Global Bindings360138 -Node: Plumbing362366 -Node: Calling Git363195 -Node: Getting a Value from Git364720 -Node: Calling Git for Effect368448 -Node: Section Plumbing374342 -Node: Creating Sections374570 -Node: Section Selection378466 -Node: Matching Sections380262 -Node: Refreshing Buffers386183 -Node: Conventions389327 -Node: Theming Faces389519 -Node: FAQ397624 -Node: FAQ - How to ...?398062 -Node: How to pronounce Magit?398419 -Node: How to show git's output?399222 -Node: How to install the gitman info manual?400008 -Node: How to show diffs for gpg-encrypted files?400978 -Node: How does branching and pushing work?401574 -Node: Should I disable VC?401907 -Node: FAQ - Issues and Errors402510 -Node: Magit is slow403455 -Node: I changed several thousand files at once and now Magit is unusable403748 -Node: I am having problems committing404474 -Node: I am using MS Windows and cannot push with Magit404955 -Node: I am using macOS and SOMETHING works in shell but not in Magit405573 -Node: Expanding a file to show the diff causes it to disappear406407 -Node: Point is wrong in the COMMIT_EDITMSG buffer406995 -Node: The mode-line information isn't always up-to-date408040 -Node: A branch and tag sharing the same name breaks SOMETHING409103 -Node: My Git hooks work on the command-line but not inside Magit409990 -Node: git-commit-mode isn't used when committing from the command-line410836 -Node: Point ends up inside invisible text when jumping to a file-visiting buffer413107 -Node: I am no longer able to save popup defaults413956 -Node: Debugging Tools414937 -Node: Keystroke Index418111 -Node: Function and Command Index459725 -Node: Variable Index517926 - -End Tag Table - - -Local Variables: -coding: utf-8 -End: diff --git a/emacs/elpa/magit-20240514.1843/AUTHORS.md b/emacs/elpa/magit-20240522.204/AUTHORS.md diff --git a/emacs/elpa/magit-20240514.1843/LICENSE b/emacs/elpa/magit-20240522.204/LICENSE diff --git a/emacs/elpa/magit-20240514.1843/dir b/emacs/elpa/magit-20240522.204/dir diff --git a/emacs/elpa/magit-20240514.1843/git-rebase.el b/emacs/elpa/magit-20240522.204/git-rebase.el diff --git a/emacs/elpa/magit-20240514.1843/git-rebase.elc b/emacs/elpa/magit-20240522.204/git-rebase.elc Binary files differ. diff --git a/emacs/elpa/magit-20240514.1843/magit-apply.el b/emacs/elpa/magit-20240522.204/magit-apply.el diff --git a/emacs/elpa/magit-20240514.1843/magit-apply.elc b/emacs/elpa/magit-20240522.204/magit-apply.elc Binary files differ. diff --git a/emacs/elpa/magit-20240514.1843/magit-autoloads.el b/emacs/elpa/magit-20240522.204/magit-autoloads.el diff --git a/emacs/elpa/magit-20240514.1843/magit-autorevert.el b/emacs/elpa/magit-20240522.204/magit-autorevert.el diff --git a/emacs/elpa/magit-20240514.1843/magit-autorevert.elc b/emacs/elpa/magit-20240522.204/magit-autorevert.elc Binary files differ. diff --git a/emacs/elpa/magit-20240514.1843/magit-base.el b/emacs/elpa/magit-20240522.204/magit-base.el diff --git a/emacs/elpa/magit-20240514.1843/magit-base.elc b/emacs/elpa/magit-20240522.204/magit-base.elc Binary files differ. diff --git a/emacs/elpa/magit-20240514.1843/magit-bisect.el b/emacs/elpa/magit-20240522.204/magit-bisect.el diff --git a/emacs/elpa/magit-20240514.1843/magit-bisect.elc b/emacs/elpa/magit-20240522.204/magit-bisect.elc Binary files differ. diff --git a/emacs/elpa/magit-20240514.1843/magit-blame.el b/emacs/elpa/magit-20240522.204/magit-blame.el diff --git a/emacs/elpa/magit-20240514.1843/magit-blame.elc b/emacs/elpa/magit-20240522.204/magit-blame.elc Binary files differ. diff --git a/emacs/elpa/magit-20240514.1843/magit-bookmark.el b/emacs/elpa/magit-20240522.204/magit-bookmark.el diff --git a/emacs/elpa/magit-20240514.1843/magit-bookmark.elc b/emacs/elpa/magit-20240522.204/magit-bookmark.elc Binary files differ. diff --git a/emacs/elpa/magit-20240514.1843/magit-branch.el b/emacs/elpa/magit-20240522.204/magit-branch.el diff --git a/emacs/elpa/magit-20240514.1843/magit-branch.elc b/emacs/elpa/magit-20240522.204/magit-branch.elc Binary files differ. diff --git a/emacs/elpa/magit-20240514.1843/magit-bundle.el b/emacs/elpa/magit-20240522.204/magit-bundle.el diff --git a/emacs/elpa/magit-20240514.1843/magit-bundle.elc b/emacs/elpa/magit-20240522.204/magit-bundle.elc Binary files differ. diff --git a/emacs/elpa/magit-20240514.1843/magit-clone.el b/emacs/elpa/magit-20240522.204/magit-clone.el diff --git a/emacs/elpa/magit-20240514.1843/magit-clone.elc b/emacs/elpa/magit-20240522.204/magit-clone.elc Binary files differ. diff --git a/emacs/elpa/magit-20240514.1843/magit-commit.el b/emacs/elpa/magit-20240522.204/magit-commit.el diff --git a/emacs/elpa/magit-20240514.1843/magit-commit.elc b/emacs/elpa/magit-20240522.204/magit-commit.elc Binary files differ. diff --git a/emacs/elpa/magit-20240514.1843/magit-core.el b/emacs/elpa/magit-20240522.204/magit-core.el diff --git a/emacs/elpa/magit-20240514.1843/magit-core.elc b/emacs/elpa/magit-20240522.204/magit-core.elc Binary files differ. diff --git a/emacs/elpa/magit-20240514.1843/magit-diff.el b/emacs/elpa/magit-20240522.204/magit-diff.el diff --git a/emacs/elpa/magit-20240522.204/magit-diff.elc b/emacs/elpa/magit-20240522.204/magit-diff.elc Binary files differ. diff --git a/emacs/elpa/magit-20240514.1843/magit-ediff.el b/emacs/elpa/magit-20240522.204/magit-ediff.el diff --git a/emacs/elpa/magit-20240514.1843/magit-ediff.elc b/emacs/elpa/magit-20240522.204/magit-ediff.elc Binary files differ. diff --git a/emacs/elpa/magit-20240514.1843/magit-extras.el b/emacs/elpa/magit-20240522.204/magit-extras.el diff --git a/emacs/elpa/magit-20240514.1843/magit-extras.elc b/emacs/elpa/magit-20240522.204/magit-extras.elc Binary files differ. diff --git a/emacs/elpa/magit-20240514.1843/magit-fetch.el b/emacs/elpa/magit-20240522.204/magit-fetch.el diff --git a/emacs/elpa/magit-20240514.1843/magit-fetch.elc b/emacs/elpa/magit-20240522.204/magit-fetch.elc Binary files differ. diff --git a/emacs/elpa/magit-20240514.1843/magit-files.el b/emacs/elpa/magit-20240522.204/magit-files.el diff --git a/emacs/elpa/magit-20240514.1843/magit-files.elc b/emacs/elpa/magit-20240522.204/magit-files.elc Binary files differ. diff --git a/emacs/elpa/magit-20240514.1843/magit-git.el b/emacs/elpa/magit-20240522.204/magit-git.el diff --git a/emacs/elpa/magit-20240514.1843/magit-git.elc b/emacs/elpa/magit-20240522.204/magit-git.elc Binary files differ. diff --git a/emacs/elpa/magit-20240514.1843/magit-gitignore.el b/emacs/elpa/magit-20240522.204/magit-gitignore.el diff --git a/emacs/elpa/magit-20240514.1843/magit-gitignore.elc b/emacs/elpa/magit-20240522.204/magit-gitignore.elc Binary files differ. diff --git a/emacs/elpa/magit-20240514.1843/magit-log.el b/emacs/elpa/magit-20240522.204/magit-log.el diff --git a/emacs/elpa/magit-20240514.1843/magit-log.elc b/emacs/elpa/magit-20240522.204/magit-log.elc Binary files differ. diff --git a/emacs/elpa/magit-20240514.1843/magit-margin.el b/emacs/elpa/magit-20240522.204/magit-margin.el diff --git a/emacs/elpa/magit-20240514.1843/magit-margin.elc b/emacs/elpa/magit-20240522.204/magit-margin.elc Binary files differ. diff --git a/emacs/elpa/magit-20240514.1843/magit-merge.el b/emacs/elpa/magit-20240522.204/magit-merge.el diff --git a/emacs/elpa/magit-20240514.1843/magit-merge.elc b/emacs/elpa/magit-20240522.204/magit-merge.elc Binary files differ. diff --git a/emacs/elpa/magit-20240514.1843/magit-mode.el b/emacs/elpa/magit-20240522.204/magit-mode.el diff --git a/emacs/elpa/magit-20240514.1843/magit-mode.elc b/emacs/elpa/magit-20240522.204/magit-mode.elc Binary files differ. diff --git a/emacs/elpa/magit-20240514.1843/magit-notes.el b/emacs/elpa/magit-20240522.204/magit-notes.el diff --git a/emacs/elpa/magit-20240514.1843/magit-notes.elc b/emacs/elpa/magit-20240522.204/magit-notes.elc Binary files differ. diff --git a/emacs/elpa/magit-20240514.1843/magit-patch.el b/emacs/elpa/magit-20240522.204/magit-patch.el diff --git a/emacs/elpa/magit-20240514.1843/magit-patch.elc b/emacs/elpa/magit-20240522.204/magit-patch.elc Binary files differ. diff --git a/emacs/elpa/magit-20240522.204/magit-pkg.el b/emacs/elpa/magit-20240522.204/magit-pkg.el @@ -0,0 +1,20 @@ +(define-package "magit" "20240522.204" "A Git porcelain inside Emacs." + '((emacs "26.1") + (compat "29.1.4.5") + (dash "20240405") + (git-commit "20240429") + (magit-section "20240429") + (seq "2.24") + (transient "20240421") + (with-editor "20240415")) + :commit "f9268a959828d0c6ab26171dd2fb1ffc55e5ae70" :authors + '(("Marius Vollmer" . "marius.vollmer@gmail.com") + ("Jonas Bernoulli" . "emacs.magit@jonas.bernoulli.dev")) + :maintainer + '("Jonas Bernoulli" . "emacs.magit@jonas.bernoulli.dev") + :keywords + '("git" "tools" "vc") + :url "https://github.com/magit/magit") +;; Local Variables: +;; no-byte-compile: t +;; End: diff --git a/emacs/elpa/magit-20240514.1843/magit-process.el b/emacs/elpa/magit-20240522.204/magit-process.el diff --git a/emacs/elpa/magit-20240514.1843/magit-process.elc b/emacs/elpa/magit-20240522.204/magit-process.elc Binary files differ. diff --git a/emacs/elpa/magit-20240514.1843/magit-pull.el b/emacs/elpa/magit-20240522.204/magit-pull.el diff --git a/emacs/elpa/magit-20240514.1843/magit-pull.elc b/emacs/elpa/magit-20240522.204/magit-pull.elc Binary files differ. diff --git a/emacs/elpa/magit-20240514.1843/magit-push.el b/emacs/elpa/magit-20240522.204/magit-push.el diff --git a/emacs/elpa/magit-20240514.1843/magit-push.elc b/emacs/elpa/magit-20240522.204/magit-push.elc Binary files differ. diff --git a/emacs/elpa/magit-20240514.1843/magit-reflog.el b/emacs/elpa/magit-20240522.204/magit-reflog.el diff --git a/emacs/elpa/magit-20240514.1843/magit-reflog.elc b/emacs/elpa/magit-20240522.204/magit-reflog.elc Binary files differ. diff --git a/emacs/elpa/magit-20240514.1843/magit-refs.el b/emacs/elpa/magit-20240522.204/magit-refs.el diff --git a/emacs/elpa/magit-20240514.1843/magit-refs.elc b/emacs/elpa/magit-20240522.204/magit-refs.elc Binary files differ. diff --git a/emacs/elpa/magit-20240514.1843/magit-remote.el b/emacs/elpa/magit-20240522.204/magit-remote.el diff --git a/emacs/elpa/magit-20240514.1843/magit-remote.elc b/emacs/elpa/magit-20240522.204/magit-remote.elc Binary files differ. diff --git a/emacs/elpa/magit-20240514.1843/magit-repos.el b/emacs/elpa/magit-20240522.204/magit-repos.el diff --git a/emacs/elpa/magit-20240514.1843/magit-repos.elc b/emacs/elpa/magit-20240522.204/magit-repos.elc Binary files differ. diff --git a/emacs/elpa/magit-20240514.1843/magit-reset.el b/emacs/elpa/magit-20240522.204/magit-reset.el diff --git a/emacs/elpa/magit-20240514.1843/magit-reset.elc b/emacs/elpa/magit-20240522.204/magit-reset.elc Binary files differ. diff --git a/emacs/elpa/magit-20240514.1843/magit-sequence.el b/emacs/elpa/magit-20240522.204/magit-sequence.el diff --git a/emacs/elpa/magit-20240514.1843/magit-sequence.elc b/emacs/elpa/magit-20240522.204/magit-sequence.elc Binary files differ. diff --git a/emacs/elpa/magit-20240514.1843/magit-sparse-checkout.el b/emacs/elpa/magit-20240522.204/magit-sparse-checkout.el diff --git a/emacs/elpa/magit-20240514.1843/magit-sparse-checkout.elc b/emacs/elpa/magit-20240522.204/magit-sparse-checkout.elc Binary files differ. diff --git a/emacs/elpa/magit-20240514.1843/magit-stash.el b/emacs/elpa/magit-20240522.204/magit-stash.el diff --git a/emacs/elpa/magit-20240514.1843/magit-stash.elc b/emacs/elpa/magit-20240522.204/magit-stash.elc Binary files differ. diff --git a/emacs/elpa/magit-20240514.1843/magit-status.el b/emacs/elpa/magit-20240522.204/magit-status.el diff --git a/emacs/elpa/magit-20240514.1843/magit-status.elc b/emacs/elpa/magit-20240522.204/magit-status.elc Binary files differ. diff --git a/emacs/elpa/magit-20240514.1843/magit-submodule.el b/emacs/elpa/magit-20240522.204/magit-submodule.el diff --git a/emacs/elpa/magit-20240514.1843/magit-submodule.elc b/emacs/elpa/magit-20240522.204/magit-submodule.elc Binary files differ. diff --git a/emacs/elpa/magit-20240514.1843/magit-subtree.el b/emacs/elpa/magit-20240522.204/magit-subtree.el diff --git a/emacs/elpa/magit-20240514.1843/magit-subtree.elc b/emacs/elpa/magit-20240522.204/magit-subtree.elc Binary files differ. diff --git a/emacs/elpa/magit-20240514.1843/magit-tag.el b/emacs/elpa/magit-20240522.204/magit-tag.el diff --git a/emacs/elpa/magit-20240514.1843/magit-tag.elc b/emacs/elpa/magit-20240522.204/magit-tag.elc Binary files differ. diff --git a/emacs/elpa/magit-20240514.1843/magit-transient.el b/emacs/elpa/magit-20240522.204/magit-transient.el diff --git a/emacs/elpa/magit-20240522.204/magit-transient.elc b/emacs/elpa/magit-20240522.204/magit-transient.elc Binary files differ. diff --git a/emacs/elpa/magit-20240514.1843/magit-wip.el b/emacs/elpa/magit-20240522.204/magit-wip.el diff --git a/emacs/elpa/magit-20240514.1843/magit-wip.elc b/emacs/elpa/magit-20240522.204/magit-wip.elc Binary files differ. diff --git a/emacs/elpa/magit-20240514.1843/magit-worktree.el b/emacs/elpa/magit-20240522.204/magit-worktree.el diff --git a/emacs/elpa/magit-20240514.1843/magit-worktree.elc b/emacs/elpa/magit-20240522.204/magit-worktree.elc Binary files differ. diff --git a/emacs/elpa/magit-20240514.1843/magit.el b/emacs/elpa/magit-20240522.204/magit.el diff --git a/emacs/elpa/magit-20240514.1843/magit.elc b/emacs/elpa/magit-20240522.204/magit.elc Binary files differ. diff --git a/emacs/elpa/magit-20240522.204/magit.info b/emacs/elpa/magit-20240522.204/magit.info @@ -0,0 +1,11595 @@ +This is magit.info, produced by makeinfo version 6.7 from magit.texi. + + Copyright (C) 2015-2024 Jonas Bernoulli + <emacs.magit@jonas.bernoulli.dev> + + You can redistribute this document 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 document 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. + +INFO-DIR-SECTION Emacs +START-INFO-DIR-ENTRY +* Magit: (magit). Using Git from Emacs with Magit. +END-INFO-DIR-ENTRY + + +File: magit.info, Node: Top, Next: Introduction, Up: (dir) + +Magit User Manual +***************** + +Magit is an interface to the version control system Git, implemented as +an Emacs package. Magit aspires to be a complete Git porcelain. While +we cannot (yet) claim that Magit wraps and improves upon each and every +Git command, it is complete enough to allow even experienced Git users +to perform almost all of their daily version control tasks directly from +within Emacs. While many fine Git clients exist, only Magit and Git +itself deserve to be called porcelains. + +This manual is for Magit version 3.3.0.50-git. + + Copyright (C) 2015-2024 Jonas Bernoulli + <emacs.magit@jonas.bernoulli.dev> + + You can redistribute this document 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 document 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. + +* Menu: + +* Introduction:: +* Installation:: +* Getting Started:: +* Interface Concepts:: +* Inspecting:: +* Manipulating:: +* Transferring:: +* Miscellaneous:: +* Customizing:: +* Plumbing:: +* FAQ:: +* Debugging Tools:: +* Keystroke Index:: +* Function and Command Index:: +* Variable Index:: + +— The Detailed Node Listing — + +Installation + +* Installing from Melpa:: +* Installing from the Git Repository:: +* Post-Installation Tasks:: + +Interface Concepts + +* Modes and Buffers:: +* Sections:: +* Transient Commands:: +* Transient Arguments and Buffer Variables:: +* Completion, Confirmation and the Selection: Completion Confirmation and the Selection. +* Mouse Support:: +* Running Git:: + +Modes and Buffers + +* Switching Buffers:: +* Naming Buffers:: +* Quitting Windows:: +* Automatic Refreshing of Magit Buffers:: +* Automatic Saving of File-Visiting Buffers:: +* Automatic Reverting of File-Visiting Buffers:: + + +Sections + +* Section Movement:: +* Section Visibility:: +* Section Hooks:: +* Section Types and Values:: +* Section Options:: + + +Completion, Confirmation and the Selection + +* Action Confirmation:: +* Completion and Confirmation:: +* The Selection:: +* The hunk-internal region:: +* Support for Completion Frameworks:: +* Additional Completion Options:: + + +Running Git + +* Viewing Git Output:: +* Git Process Status:: +* Running Git Manually:: +* Git Executable:: +* Global Git Arguments:: + + +Inspecting + +* Status Buffer:: +* Repository List:: +* Logging:: +* Diffing:: +* Ediffing:: +* References Buffer:: +* Bisecting:: +* Visiting Files and Blobs:: +* Blaming:: + +Status Buffer + +* Status Sections:: +* Status Header Sections:: +* Status Module Sections:: +* Status Options:: + + +Logging + +* Refreshing Logs:: +* Log Buffer:: +* Log Margin:: +* Select from Log:: +* Reflog:: +* Cherries:: + + +Diffing + +* Refreshing Diffs:: +* Commands Available in Diffs:: +* Diff Options:: +* Revision Buffer:: + + +References Buffer + +* References Sections:: + + +Visiting Files and Blobs + +* General-Purpose Visit Commands:: +* Visiting Files and Blobs from a Diff:: + + +Manipulating + +* Creating Repository:: +* Cloning Repository:: +* Staging and Unstaging:: +* Applying:: +* Committing:: +* Branching:: +* Merging:: +* Resolving Conflicts:: +* Rebasing:: +* Cherry Picking:: +* Resetting:: +* Stashing:: + +Staging and Unstaging + +* Staging from File-Visiting Buffers:: + + +Committing + +* Initiating a Commit:: +* Editing Commit Messages:: + + +Branching + +* The Two Remotes:: +* Branch Commands:: +* Branch Git Variables:: +* Auxiliary Branch Commands:: + + +Rebasing + +* Editing Rebase Sequences:: +* Information About In-Progress Rebase:: + + +Cherry Picking + +* Reverting:: + + +Transferring + +* Remotes:: +* Fetching:: +* Pulling:: +* Pushing:: +* Plain Patches:: +* Maildir Patches:: + +Remotes + +* Remote Commands:: +* Remote Git Variables:: + + +Miscellaneous + +* Tagging:: +* Notes:: +* Submodules:: +* Subtree:: +* Worktree:: +* Sparse checkouts:: +* Bundle:: +* Common Commands:: +* Wip Modes:: +* Commands for Buffers Visiting Files:: +* Minor Mode for Buffers Visiting Blobs:: + +Submodules + +* Listing Submodules:: +* Submodule Transient:: + + +Wip Modes + +* Wip Graph:: +* Legacy Wip Modes:: + + +Customizing + +* Per-Repository Configuration:: +* Essential Settings:: + +Essential Settings + +* Safety:: +* Performance:: +* Global Bindings:: + + +Plumbing + +* Calling Git:: +* Section Plumbing:: +* Refreshing Buffers:: +* Conventions:: + +Calling Git + +* Getting a Value from Git:: +* Calling Git for Effect:: + + +Section Plumbing + +* Creating Sections:: +* Section Selection:: +* Matching Sections:: + + +Conventions + +* Theming Faces:: + + +FAQ + +* FAQ - How to ...?:: +* FAQ - Issues and Errors:: + +FAQ - How to ...? + +* How to pronounce Magit?:: +* How to show git's output?:: +* How to install the gitman info manual?:: +* How to show diffs for gpg-encrypted files?:: +* How does branching and pushing work?:: +* Should I disable VC?:: + + +FAQ - Issues and Errors + +* Magit is slow:: +* I changed several thousand files at once and now Magit is unusable:: +* I am having problems committing:: +* I am using MS Windows and cannot push with Magit:: +* I am using macOS and SOMETHING works in shell, but not in Magit: I am using macOS and SOMETHING works in shell but not in Magit. +* Expanding a file to show the diff causes it to disappear:: +* Point is wrong in the COMMIT_EDITMSG buffer:: +* The mode-line information isn't always up-to-date:: +* A branch and tag sharing the same name breaks SOMETHING:: +* My Git hooks work on the command-line but not inside Magit:: +* git-commit-mode isn't used when committing from the command-line:: +* Point ends up inside invisible text when jumping to a file-visiting buffer:: +* I am no longer able to save popup defaults:: + + + + +File: magit.info, Node: Introduction, Next: Installation, Prev: Top, Up: Top + +1 Introduction +************** + +Magit is an interface to the version control system Git, implemented as +an Emacs package. Magit aspires to be a complete Git porcelain. While +we cannot (yet) claim that Magit wraps and improves upon each and every +Git command, it is complete enough to allow even experienced Git users +to perform almost all of their daily version control tasks directly from +within Emacs. While many fine Git clients exist, only Magit and Git +itself deserve to be called porcelains. + + Staging and otherwise applying changes is one of the most important +features in a Git porcelain and here Magit outshines anything else, +including Git itself. Git’s own staging interface (‘git add --patch’) +is so cumbersome that many users only use it in exceptional cases. In +Magit staging a hunk or even just part of a hunk is as trivial as +staging all changes made to a file. + + The most visible part of Magit’s interface is the status buffer, +which displays information about the current repository. Its content is +created by running several Git commands and making their output +actionable. Among other things, it displays information about the +current branch, lists unpulled and unpushed changes and contains +sections displaying the staged and unstaged changes. That might sound +noisy, but, since sections are collapsible, it’s not. + + To stage or unstage a change one places the cursor on the change and +then types ‘s’ or ‘u’. The change can be a file or a hunk, or when the +region is active (i.e., when there is a selection) several files or +hunks, or even just part of a hunk. The change or changes that these +commands - and many others - would act on are highlighted. + + Magit also implements several other "apply variants" in addition to +staging and unstaging. One can discard or reverse a change, or apply it +to the working tree. Git’s own porcelain only supports this for staging +and unstaging and you would have to do something like ‘git diff ... | +??? | git apply ...’ to discard, revert, or apply a single hunk on the +command line. In fact that’s exactly what Magit does internally (which +is what lead to the term "apply variants"). + + Magit isn’t just for Git experts, but it does assume some prior +experience with Git as well as Emacs. That being said, many users have +reported that using Magit was what finally taught them what Git is +capable of and how to use it to its fullest. Other users wished they +had switched to Emacs sooner so that they would have gotten their hands +on Magit earlier. + + While one has to know the basic features of Emacs to be able to make +full use of Magit, acquiring just enough Emacs skills doesn’t take long +and is worth it, even for users who prefer other editors. Vim users are +advised to give Evil (https://github.com/emacs-evil/evil), the +"Extensible VI Layer for Emacs", and Spacemacs +(https://github.com/syl20bnr/spacemacs), an "Emacs starter-kit focused +on Evil" a try. + + Magit provides a consistent and efficient Git porcelain. After a +short learning period, you will be able to perform most of your daily +version control tasks faster than you would on the command line. You +will likely also start using features that seemed too daunting in the +past. + + Magit fully embraces Git. It exposes many advanced features using a +simple but flexible interface instead of only wrapping the trivial ones +like many GUI clients do. Of course Magit supports logging, cloning, +pushing, and other commands that usually don’t fail in spectacular ways; +but it also supports tasks that often cannot be completed in a single +step. Magit fully supports tasks such as merging, rebasing, +cherry-picking, reverting, and blaming by not only providing a command +to initiate these tasks but also by displaying context sensitive +information along the way and providing commands that are useful for +resolving conflicts and resuming the sequence after doing so. + + Magit wraps and in many cases improves upon at least the following +Git porcelain commands: ‘add’, ‘am’, ‘bisect’, ‘blame’, ‘branch’, +‘checkout’, ‘cherry’, ‘cherry-pick’, ‘clean’, ‘clone’, ‘commit’, +‘config’, ‘describe’, ‘diff’, ‘fetch’, ‘format-patch’, ‘init’, ‘log’, +‘merge’, ‘merge-tree’, ‘mv’, ‘notes’, ‘pull’, ‘rebase’, ‘reflog’, +‘remote’, ‘request-pull’, ‘reset’, ‘revert’, ‘rm’, ‘show’, ‘stash’, +‘submodule’, ‘subtree’, ‘tag’, and ‘worktree.’ Many more Magit porcelain +commands are implemented on top of Git plumbing commands. + + +File: magit.info, Node: Installation, Next: Getting Started, Prev: Introduction, Up: Top + +2 Installation +************** + +Magit can be installed using Emacs’ package manager or manually from its +development repository. + +* Menu: + +* Installing from Melpa:: +* Installing from the Git Repository:: +* Post-Installation Tasks:: + + +File: magit.info, Node: Installing from Melpa, Next: Installing from the Git Repository, Up: Installation + +2.1 Installing from Melpa +========================= + +Magit is available from Melpa and Melpa-Stable. If you haven’t used +Emacs’ package manager before, then it is high time you familiarize +yourself with it by reading the documentation in the Emacs manual, see +*note (emacs)Packages::. Then add one of the archives to +‘package-archives’: + + • To use Melpa: + + (require 'package) + (add-to-list 'package-archives + '("melpa" . "https://melpa.org/packages/") t) + + • To use Melpa-Stable: + + (require 'package) + (add-to-list 'package-archives + '("melpa-stable" . "https://stable.melpa.org/packages/") t) + + Once you have added your preferred archive, you need to update the +local package list using: + + M-x package-refresh-contents RET + + Once you have done that, you can install Magit and its dependencies +using: + + M-x package-install RET magit RET + + Now see *note Post-Installation Tasks::. + + +File: magit.info, Node: Installing from the Git Repository, Next: Post-Installation Tasks, Prev: Installing from Melpa, Up: Installation + +2.2 Installing from the Git Repository +====================================== + +Magit depends on the ‘compat’, ‘dash’, ‘transient’ and ‘with-editor’ +libraries which are available from Melpa and Melpa-Stable. Install them +using ‘M-x package-install RET <package> RET’. Of course you may also +install them manually from their repository. + + Then clone the Magit repository: + + $ git clone https://github.com/magit/magit.git ~/.emacs.d/site-lisp/magit + $ cd ~/.emacs.d/site-lisp/magit + + Then compile the libraries and generate the info manuals: + + $ make + + If you haven’t installed ‘compat’, ‘dash’, ‘transient’ and +‘with-editor’ from Melpa or at ‘/path/to/magit/../<package>’, then you +have to tell ‘make’ where to find them. To do so create the file +‘/path/to/magit/config.mk’ with the following content before running +‘make’: + + LOAD_PATH = -L ~/.emacs.d/site-lisp/magit/lisp + LOAD_PATH += -L ~/.emacs.d/site-lisp/dash + LOAD_PATH += -L ~/.emacs.d/site-lisp/transient/lisp + LOAD_PATH += -L ~/.emacs.d/site-lisp/with-editor/lisp + LOAD_PATH += -L ~/.emacs.d/site-lisp/compat + + Finally add this to your init file: + + (add-to-list 'load-path "~/.emacs.d/site-lisp/magit/lisp") + (require 'magit) + + (with-eval-after-load 'info + (info-initialize) + (add-to-list 'Info-directory-list + "~/.emacs.d/site-lisp/magit/Documentation/")) + + Of course if you installed the dependencies manually as well, then +you have to tell Emacs about them too, by prefixing the above with: + + (add-to-list 'load-path "~/.emacs.d/site-lisp/dash") + (add-to-list 'load-path "~/.emacs.d/site-lisp/transient/lisp") + (add-to-list 'load-path "~/.emacs.d/site-lisp/with-editor") + + Note that you have to add the ‘lisp’ subdirectory to the ‘load-path’, +not the top-level of the repository, and that elements of ‘load-path’ +should not end with a slash, while those of ‘Info-directory-list’ +should. + + Instead of requiring the feature ‘magit’, you could load just the +autoload definitions, by loading the file ‘magit-autoloads.el’. + + (load "/path/to/magit/lisp/magit-autoloads") + + Instead of running Magit directly from the repository by adding that +to the ‘load-path’, you might want to instead install it in some other +directory using ‘sudo make install’ and setting ‘load-path’ accordingly. + + To update Magit use: + + $ git pull + $ make + + At times it might be necessary to run ‘make clean all’ instead. + + To view all available targets use ‘make help’. + + Now see *note Post-Installation Tasks::. + + +File: magit.info, Node: Post-Installation Tasks, Prev: Installing from the Git Repository, Up: Installation + +2.3 Post-Installation Tasks +=========================== + +After installing Magit you should verify that you are indeed using the +Magit, Git, and Emacs releases you think you are using. It’s best to +restart Emacs before doing so, to make sure you are not using an +outdated value for ‘load-path’. + + M-x magit-version RET + + should display something like + + Magit 2.8.0, Git 2.10.2, Emacs 25.1.1, gnu/linux + + Then you might also want to read about options that many users likely +want to customize. See *note Essential Settings::. + + To be able to follow cross references to Git manpages found in this +manual, you might also have to manually install the ‘gitman’ info +manual, or advice ‘Info-follow-nearest-node’ to instead open the actual +manpage. See *note How to install the gitman info manual?::. + + If you are completely new to Magit then see *note Getting Started::. + + If you run into problems, then please see the *note FAQ::. Also see +the *note Debugging Tools::. + + And last but not least please consider making a donation, to ensure +that I can keep working on Magit. See <https://magit.vc/donations>. +for various donation options. + + +File: magit.info, Node: Getting Started, Next: Interface Concepts, Prev: Installation, Up: Top + +3 Getting Started +***************** + +This short tutorial describes the most essential features that many +Magitians use on a daily basis. It only scratches the surface but +should be enough to get you started. + + IMPORTANT: It is safest if you clone some repository just for this +tutorial. Alternatively you can use an existing local repository, but +if you do that, then you should commit all uncommitted changes before +proceeding. + + Type ‘C-x g’ to display information about the current Git repository +in a dedicated buffer, called the status buffer. + + Most Magit commands are commonly invoked from the status buffer. It +can be considered the primary interface for interacting with Git using +Magit. Many other Magit buffers may exist at a given time, but they are +often created from this buffer. + + Depending on what state your repository is in, this buffer may +contain sections titled "Staged changes", "Unstaged changes", "Unmerged +into origin/master", "Unpushed to origin/master", and many others. + + Since we are starting from a safe state, which you can easily return +to (by doing a ‘git reset --hard PRE-MAGIT-STATE’), there currently are +no staged or unstaged changes. Edit some files and save the changes. +Then go back to the status buffer, while at the same time refreshing it, +by typing ‘C-x g’. (When the status buffer, or any Magit buffer for +that matter, is the current buffer, then you can also use just ‘g’ to +refresh it). + + Move between sections using ‘p’ and ‘n’. Note that the bodies of +some sections are hidden. Type ‘TAB’ to expand or collapse the section +at point. You can also use ‘C-tab’ to cycle the visibility of the +current section and its children. Move to a file section inside the +section named "Unstaged changes" and type ‘s’ to stage the changes you +have made to that file. That file now appears under "Staged changes". + + Magit can stage and unstage individual hunks, not just complete +files. Move to the file you have just staged, expand it using ‘TAB’, +move to one of the hunks using ‘n’, and unstage just that by typing ‘u’. +Note how the staging (‘s’) and unstaging (‘u’) commands operate on the +change at point. Many other commands behave the same way. + + You can also un-/stage just part of a hunk. Inside the body of a +hunk section (move there using ‘C-n’), set the mark using ‘C-SPC’ and +move down until some added and/or removed lines fall inside the region +but not all of them. Again type ‘s’ to stage. + + It is also possible to un-/stage multiple files at once. Move to a +file section, type ‘C-SPC’, move to the next file using ‘n’, and then +‘s’ to stage both files. Note that both the mark and point have to be +on the headings of sibling sections for this to work. If the region +looks like it does in other buffers, then it doesn’t select Magit +sections that can be acted on as a unit. + + And then of course you want to commit your changes. Type ‘c’. This +shows the available commit commands and arguments in a buffer at the +bottom of the frame. Each command and argument is prefixed with the key +that invokes/sets it. Do not worry about this for now. We want to +create a "normal" commit, which is done by typing ‘c’ again. + + Now two new buffers appear. One is for writing the commit message, +the other shows a diff with the changes that you are about to commit. +Write a message and then type ‘C-c C-c’ to actually create the commit. + + You probably don’t want to push the commit you just created because +you just committed some random changes, but if that is not the case you +could push it by typing ‘P’ to show all the available push commands and +arguments and then ‘p’ to push to a branch with the same name as the +local branch onto the remote configured as the push-remote. (If the +push-remote is not configured yet, then you would first be prompted for +the remote to push to.) + + So far we have mentioned the commit and push menu commands. These +are probably among the menus you will be using the most, but many others +exist. To show a menu that lists all other menus (as well as the +various apply commands and some other essential commands), type ‘h’. +Try a few. (Such menus are also called "transient prefix commands" or +just "transients".) + + The key bindings in that menu correspond to the bindings in Magit +buffers, including but not limited to the status buffer. So you could +type ‘h d’ to bring up the diff menu, but once you remember that "d" +stands for "diff", you would usually do so by just typing ‘d’. + + This "prefix of prefixes" is useful even once you have memorized all +the bindings, as it can provide easy access to Magit commands from +non-Magit buffers. So, by default, it is globally bound to ‘C-x M-g’. + + A similar menu featuring (for the most part) commands that act on +just the file being visited in the current buffer, is globally bound to +‘C-c M-g’. That binding can also be used in buffers, which do not visit +a file, but then only a subset of the commands is available. + + The global key bindings mentioned in the previous two paragraphs are +quite inconvenient. We recommend using ‘C-c g’ and ‘C-c f’ instead, but +cannot use those key sequences by default because they are strictly +reserved for bindings added by the user. See *note Global Bindings::, +if you want to explicitly opt-in to the recommended key bindings. + + Magit also provides context menus and other mouse commands, see *note +Mouse Support::. + + It is not necessary that you do so now, but if you stick with Magit, +then it is highly recommended that you read the next section too. + + +File: magit.info, Node: Interface Concepts, Next: Inspecting, Prev: Getting Started, Up: Top + +4 Interface Concepts +******************** + +* Menu: + +* Modes and Buffers:: +* Sections:: +* Transient Commands:: +* Transient Arguments and Buffer Variables:: +* Completion, Confirmation and the Selection: Completion Confirmation and the Selection. +* Mouse Support:: +* Running Git:: + + +File: magit.info, Node: Modes and Buffers, Next: Sections, Up: Interface Concepts + +4.1 Modes and Buffers +===================== + +Magit provides several major-modes. For each of these modes there +usually exists only one buffer per repository. Separate modes and thus +buffers exist for commits, diffs, logs, and some other things. + + Besides these special purpose buffers, there also exists an overview +buffer, called the *status buffer*. It’s usually from this buffer that +the user invokes Git commands, or creates or visits other buffers. + + In this manual we often speak about "Magit buffers". By that we mean +buffers whose major-modes derive from ‘magit-mode’. + +‘M-x magit-toggle-buffer-lock’ + This command locks the current buffer to its value or if the buffer + is already locked, then it unlocks it. + + Locking a buffer to its value prevents it from being reused to + display another value. The name of a locked buffer contains its + value, which allows telling it apart from other locked buffers and + the unlocked buffer. + + Not all Magit buffers can be locked to their values; for example, + it wouldn’t make sense to lock a status buffer. + + There can only be a single unlocked buffer using a certain + major-mode per repository. So when a buffer is being unlocked and + another unlocked buffer already exists for that mode and + repository, then the former buffer is instead deleted and the + latter is displayed in its place. + +* Menu: + +* Switching Buffers:: +* Naming Buffers:: +* Quitting Windows:: +* Automatic Refreshing of Magit Buffers:: +* Automatic Saving of File-Visiting Buffers:: +* Automatic Reverting of File-Visiting Buffers:: + + +File: magit.info, Node: Switching Buffers, Next: Naming Buffers, Up: Modes and Buffers + +4.1.1 Switching Buffers +----------------------- + + -- Function: magit-display-buffer buffer &optional display-function + This function is a wrapper around ‘display-buffer’ and is used to + display any Magit buffer. It displays BUFFER in some window and, + unlike ‘display-buffer’, also selects that window, provided + ‘magit-display-buffer-noselect’ is ‘nil’. It also runs the hooks + mentioned below. + + If optional DISPLAY-FUNCTION is non-nil, then that is used to + display the buffer. Usually that is ‘nil’ and the function + specified by ‘magit-display-buffer-function’ is used. + + -- Variable: magit-display-buffer-noselect + When this is non-nil, then ‘magit-display-buffer’ only displays the + buffer but forgoes also selecting the window. This variable should + not be set globally, it is only intended to be let-bound, by code + that automatically updates "the other window". This is used for + example when the revision buffer is updated when you move inside + the log buffer. + + -- User Option: magit-display-buffer-function + The function specified here is called by ‘magit-display-buffer’ + with one argument, a buffer, to actually display that buffer. This + function should call ‘display-buffer’ with that buffer as first and + a list of display actions as second argument. + + Magit provides several functions, listed below, that are suitable + values for this option. If you want to use different rules, then a + good way of doing that is to start with a copy of one of these + functions and then adjust it to your needs. + + Instead of using a wrapper around ‘display-buffer’, that function + itself can be used here, in which case the display actions have to + be specified by adding them to ‘display-buffer-alist’ instead. + + To learn about display actions, see *note (elisp)Choosing Window::. + + -- Function: magit-display-buffer-traditional buffer + This function is the current default value of the option + ‘magit-display-buffer-function’. Before that option and this + function were added, the behavior was hard-coded in many places all + over the code base but now all the rules are contained in this one + function (except for the "noselect" special case mentioned above). + + -- Function: magit-display-buffer-same-window-except-diff-v1 + This function displays most buffers in the currently selected + window. If a buffer’s mode derives from ‘magit-diff-mode’ or + ‘magit-process-mode’, it is displayed in another window. + + -- Function: magit-display-buffer-fullframe-status-v1 + This function fills the entire frame when displaying a status + buffer. Otherwise, it behaves like + ‘magit-display-buffer-traditional’. + + -- Function: magit-display-buffer-fullframe-status-topleft-v1 + This function fills the entire frame when displaying a status + buffer. It behaves like ‘magit-display-buffer-fullframe-status-v1’ + except that it displays buffers that derive from ‘magit-diff-mode’ + or ‘magit-process-mode’ to the top or left of the current buffer + rather than to the bottom or right. As a result, Magit buffers + tend to pop up on the same side as they would if + ‘magit-display-buffer-traditional’ were in use. + + -- Function: magit-display-buffer-fullcolumn-most-v1 + This function displays most buffers so that they fill the entire + height of the frame. However, the buffer is displayed in another + window if (1) the buffer’s mode derives from ‘magit-process-mode’, + or (2) the buffer’s mode derives from ‘magit-diff-mode’, provided + that the mode of the current buffer derives from ‘magit-log-mode’ + or ‘magit-cherry-mode’. + + -- User Option: magit-pre-display-buffer-hook + This hook is run by ‘magit-display-buffer’ before displaying the + buffer. + + -- Function: magit-save-window-configuration + This function saves the current window configuration. Later when + the buffer is buried, it may be restored by + ‘magit-restore-window-configuration’. + + -- User Option: magit-post-display-buffer-hook + This hook is run by ‘magit-display-buffer’ after displaying the + buffer. + + -- Function: magit-maybe-set-dedicated + This function remembers if a new window had to be created to + display the buffer, or whether an existing window was reused. This + information is later used by ‘magit-mode-quit-window’, to determine + whether the window should be deleted when its last Magit buffer is + buried. + + +File: magit.info, Node: Naming Buffers, Next: Quitting Windows, Prev: Switching Buffers, Up: Modes and Buffers + +4.1.2 Naming Buffers +-------------------- + + -- User Option: magit-generate-buffer-name-function + The function used to generate the names of Magit buffers. + + Such a function should take the options + ‘magit-uniquify-buffer-names’ as well as ‘magit-buffer-name-format’ + into account. If it doesn’t, then should be clearly stated in the + doc-string. And if it supports %-sequences beyond those mentioned + in the doc-string of the option ‘magit-buffer-name-format’, then + its own doc-string should describe the additions. + + -- Function: magit-generate-buffer-name-default-function mode + This function returns a buffer name suitable for a buffer whose + major-mode is MODE and which shows information about the repository + in which ‘default-directory’ is located. + + This function uses ‘magit-buffer-name-format’ and supporting all of + the %-sequences mentioned the documentation of that option. It + also respects the option ‘magit-uniquify-buffer-names’. + + -- User Option: magit-buffer-name-format + The format string used to name Magit buffers. + + At least the following %-sequences are supported: + + • ‘%m’ + + The name of the major-mode, but with the ‘-mode’ suffix + removed. + + • ‘%M’ + + Like ‘%m’ but abbreviate ‘magit-status-mode’ as ‘magit’. + + • ‘%v’ + + The value the buffer is locked to, in parentheses, or an empty + string if the buffer is not locked to a value. + + • ‘%V’ + + Like ‘%v’, but the string is prefixed with a space, unless it + is an empty string. + + • ‘%t’ + + The top-level directory of the working tree of the repository, + or if ‘magit-uniquify-buffer-names’ is non-nil an abbreviation + of that. + + • ‘%x’ + + If ‘magit-uniquify-buffer-names’ is nil "*", otherwise the + empty string. Due to limitations of the ‘uniquify’ package, + buffer names must end with the path. + + The value should always contain ‘%m’ or ‘%M’, ‘%v’ or ‘%V’, and + ‘%t’. If ‘magit-uniquify-buffer-names’ is non-nil, then the value + must end with ‘%t’ or ‘%t%x’. See issue #2841. + + -- User Option: magit-uniquify-buffer-names + This option controls whether the names of Magit buffers are + uniquified. If the names are not being uniquified, then they + contain the full path of the top-level of the working tree of the + corresponding repository. If they are being uniquified, then they + end with the basename of the top-level, or if that would conflict + with the name used for other buffers, then the names of all these + buffers are adjusted until they no longer conflict. + + This is done using the ‘uniquify’ package; customize its options to + control how buffer names are uniquified. + + +File: magit.info, Node: Quitting Windows, Next: Automatic Refreshing of Magit Buffers, Prev: Naming Buffers, Up: Modes and Buffers + +4.1.3 Quitting Windows +---------------------- + +‘q’ (‘magit-mode-bury-buffer’) + This command buries or kills the current Magit buffer. The + function specified by option ‘magit-bury-buffer-function’ is used + to bury the buffer when called without a prefix argument or to kill + it when called with a single prefix argument. + + When called with two or more prefix arguments then it always kills + all Magit buffers, associated with the current project, including + the current buffer. + + -- User Option: magit-bury-buffer-function + The function used to actually bury or kill the current buffer. + + ‘magit-mode-bury-buffer’ calls this function with one argument. If + the argument is non-nil, then the function has to kill the current + buffer. Otherwise it has to bury it alive. The default value + currently is ‘magit-mode-quit-window’. + + -- Function: magit-restore-window-configuration kill-buffer + Bury or kill the current buffer using ‘quit-window’, which is + called with KILL-BUFFER as first and the selected window as second + argument. + + Then restore the window configuration that existed right before the + current buffer was displayed in the selected frame. Unfortunately + that also means that point gets adjusted in all the buffers, which + are being displayed in the selected frame. + + -- Function: magit-mode-quit-window kill-buffer + Bury or kill the current buffer using ‘quit-window’, which is + called with KILL-BUFFER as first and the selected window as second + argument. + + Then, if the window was originally created to display a Magit + buffer and the buried buffer was the last remaining Magit buffer + that was ever displayed in the window, then that is deleted. + + +File: magit.info, Node: Automatic Refreshing of Magit Buffers, Next: Automatic Saving of File-Visiting Buffers, Prev: Quitting Windows, Up: Modes and Buffers + +4.1.4 Automatic Refreshing of Magit Buffers +------------------------------------------- + +After running a command which may change the state of the current +repository, the current Magit buffer and the corresponding status buffer +are refreshed. The status buffer can be automatically refreshed +whenever a buffer is saved to a file inside the respective repository by +adding a hook, like so: + + (with-eval-after-load 'magit-mode + (add-hook 'after-save-hook 'magit-after-save-refresh-status t)) + + Automatically refreshing Magit buffers ensures that the displayed +information is up-to-date most of the time but can lead to a noticeable +delay in big repositories. Other Magit buffers are not refreshed to +keep the delay to a minimum and also because doing so can sometimes be +undesirable. + + Buffers can also be refreshed explicitly, which is useful in buffers +that weren’t current during the last refresh and after changes were made +to the repository outside of Magit. + +‘g’ (‘magit-refresh’) + This command refreshes the current buffer if its major mode derives + from ‘magit-mode’ as well as the corresponding status buffer. + + If the option ‘magit-revert-buffers’ calls for it, then it also + reverts all unmodified buffers that visit files being tracked in + the current repository. + +‘G’ (‘magit-refresh-all’) + This command refreshes all Magit buffers belonging to the current + repository and also reverts all unmodified buffers that visit files + being tracked in the current repository. + + The file-visiting buffers are always reverted, even if + ‘magit-revert-buffers’ is nil. + + -- User Option: magit-refresh-buffer-hook + This hook is run in each Magit buffer that was refreshed during the + current refresh - normally the current buffer and the status + buffer. + + -- User Option: magit-refresh-status-buffer + When this option is non-nil, then the status buffer is + automatically refreshed after running git for side-effects, in + addition to the current Magit buffer, which is always refreshed + automatically. + + Only set this to nil after exhausting all other options to improve + performance. + + -- Function: magit-after-save-refresh-status + This function is intended to be added to ‘after-save-hook’. After + doing that the corresponding status buffer is refreshed whenever a + buffer is saved to a file inside a repository. + + Note that refreshing a Magit buffer is done by re-creating its + contents from scratch, which can be slow in large repositories. If + you are not satisfied with Magit’s performance, then you should + obviously not add this function to that hook. + + +File: magit.info, Node: Automatic Saving of File-Visiting Buffers, Next: Automatic Reverting of File-Visiting Buffers, Prev: Automatic Refreshing of Magit Buffers, Up: Modes and Buffers + +4.1.5 Automatic Saving of File-Visiting Buffers +----------------------------------------------- + +File-visiting buffers are by default saved at certain points in time. +This doesn’t guarantee that Magit buffers are always up-to-date, but, +provided one only edits files by editing them in Emacs and uses only +Magit to interact with Git, one can be fairly confident. When in doubt +or after outside changes, type ‘g’ (‘magit-refresh’) to save and refresh +explicitly. + + -- User Option: magit-save-repository-buffers + This option controls whether file-visiting buffers are saved before + certain events. + + If this is non-nil then all modified file-visiting buffers + belonging to the current repository may be saved before running + commands, before creating new Magit buffers, and before explicitly + refreshing such buffers. If this is ‘dontask’ then this is done + without user intervention. If it is ‘t’ then the user has to + confirm each save. + + +File: magit.info, Node: Automatic Reverting of File-Visiting Buffers, Prev: Automatic Saving of File-Visiting Buffers, Up: Modes and Buffers + +4.1.6 Automatic Reverting of File-Visiting Buffers +-------------------------------------------------- + +By default Magit automatically reverts buffers that are visiting files +that are being tracked in a Git repository, after they have changed on +disk. When using Magit one often changes files on disk by running Git, +i.e., "outside Emacs", making this a rather important feature. + + For example, if you discard a change in the status buffer, then that +is done by running ‘git apply --reverse ...’, and Emacs considers the +file to have "changed on disk". If Magit did not automatically revert +the buffer, then you would have to type ‘M-x revert-buffer RET RET’ in +the visiting buffer before you could continue making changes. + + -- User Option: magit-auto-revert-mode + When this mode is enabled, then buffers that visit tracked files + are automatically reverted after the visited files change on disk. + + -- User Option: global-auto-revert-mode + When this mode is enabled, then any file-visiting buffer is + automatically reverted after the visited file changes on disk. + + If you like buffers that visit tracked files to be automatically + reverted, then you might also like any buffer to be reverted, not + just those visiting tracked files. If that is the case, then + enable this mode _instead of_ ‘magit-auto-revert-mode’. + + -- User Option: magit-auto-revert-immediately + This option controls whether Magit reverts buffers immediately. + + If this is non-nil and either ‘global-auto-revert-mode’ or + ‘magit-auto-revert-mode’ is enabled, then Magit immediately reverts + buffers by explicitly calling ‘auto-revert-buffers’ after running + Git for side-effects. + + If ‘auto-revert-use-notify’ is non-nil (and file notifications are + actually supported), then ‘magit-auto-revert-immediately’ does not + have to be non-nil, because the reverts happen immediately anyway. + + If ‘magit-auto-revert-immediately’ and ‘auto-revert-use-notify’ are + both ‘nil’, then reverts happen after ‘auto-revert-interval’ + seconds of user inactivity. That is not desirable. + + -- User Option: auto-revert-use-notify + This option controls whether file notification functions should be + used. Note that this variable unfortunately defaults to ‘t’ even + on systems on which file notifications cannot be used. + + -- User Option: magit-auto-revert-tracked-only + This option controls whether ‘magit-auto-revert-mode’ only reverts + tracked files or all files that are located inside Git + repositories, including untracked files and files located inside + Git’s control directory. + + -- User Option: auto-revert-mode + The global mode ‘magit-auto-revert-mode’ works by turning on this + local mode in the appropriate buffers (but + ‘global-auto-revert-mode’ is implemented differently). You can + also turn it on or off manually, which might be necessary if Magit + does not notice that a previously untracked file now is being + tracked or vice-versa. + + -- User Option: auto-revert-stop-on-user-input + This option controls whether the arrival of user input suspends the + automatic reverts for ‘auto-revert-interval’ seconds. + + -- User Option: auto-revert-interval + This option controls how many seconds Emacs waits for before + resuming suspended reverts. + + -- User Option: auto-revert-buffer-list-filter + This option specifies an additional filter used by + ‘auto-revert-buffers’ to determine whether a buffer should be + reverted or not. + + This option is provided by Magit, which also advises + ‘auto-revert-buffers’ to respect it. Magit users who do not turn + on the local mode ‘auto-revert-mode’ themselves, are best served by + setting the value to ‘magit-auto-revert-repository-buffer-p’. + + However the default is nil, so as not to disturb users who do use + the local mode directly. If you experience delays when running + Magit commands, then you should consider using one of the + predicates provided by Magit - especially if you also use Tramp. + + Users who do turn on ‘auto-revert-mode’ in buffers in which Magit + doesn’t do that for them, should likely not use any filter. Users + who turn on ‘global-auto-revert-mode’, do not have to worry about + this option, because it is disregarded if the global mode is + enabled. + + -- User Option: auto-revert-verbose + This option controls whether Emacs reports when a buffer has been + reverted. + + The options with the ‘auto-revert-’ prefix are located in the Custom +group named ‘auto-revert’. The other, Magit-specific, options are +located in the ‘magit’ group. + +* Menu: + +* Risk of Reverting Automatically:: + + +File: magit.info, Node: Risk of Reverting Automatically, Up: Automatic Reverting of File-Visiting Buffers + +Risk of Reverting Automatically +............................... + +For the vast majority of users, automatically reverting file-visiting +buffers after they have changed on disk is harmless. + + If a buffer is modified (i.e., it contains changes that haven’t been +saved yet), then Emacs will refuse to automatically revert it. If you +save a previously modified buffer, then that results in what is seen by +Git as an uncommitted change. Git will then refuse to carry out any +commands that would cause these changes to be lost. In other words, if +there is anything that could be lost, then either Git or Emacs will +refuse to discard the changes. + + However, if you use file-visiting buffers as a sort of ad hoc +"staging area", then the automatic reverts could potentially cause data +loss. So far I have heard from only one user who uses such a workflow. + + An example: You visit some file in a buffer, edit it, and save the +changes. Then, outside of Emacs (or at least not using Magit or by +saving the buffer) you change the file on disk again. At this point the +buffer is the only place where the intermediate version still exists. +You have saved the changes to disk, but that has since been overwritten. +Meanwhile Emacs considers the buffer to be unmodified (because you have +not made any changes to it since you last saved it to the visited file) +and therefore would not object to it being automatically reverted. At +this point an Auto-Revert mode would kick in. It would check whether +the buffer is modified and since that is not the case it would revert +it. The intermediate version would be lost. (Actually you could still +get it back using the ‘undo’ command.) + + If your workflow depends on Emacs preserving the intermediate version +in the buffer, then you have to disable all Auto-Revert modes. But +please consider that such a workflow would be dangerous even without +using an Auto-Revert mode, and should therefore be avoided. If Emacs +crashes or if you quit Emacs by mistake, then you would also lose the +buffer content. There would be no autosave file still containing the +intermediate version (because that was deleted when you saved the +buffer) and you would not be asked whether you want to save the buffer +(because it isn’t modified). + + +File: magit.info, Node: Sections, Next: Transient Commands, Prev: Modes and Buffers, Up: Interface Concepts + +4.2 Sections +============ + +Magit buffers are organized into nested sections, which can be collapsed +and expanded, similar to how sections are handled in Org mode. Each +section also has a type, and some sections also have a value. For each +section type there can also be a local keymap, shared by all sections of +that type. + + Taking advantage of the section value and type, many commands operate +on the current section, or when the region is active and selects +sections of the same type, all of the selected sections. Commands that +only make sense for a particular section type (as opposed to just +behaving differently depending on the type) are usually bound in section +type keymaps. + +* Menu: + +* Section Movement:: +* Section Visibility:: +* Section Hooks:: +* Section Types and Values:: +* Section Options:: + + +File: magit.info, Node: Section Movement, Next: Section Visibility, Up: Sections + +4.2.1 Section Movement +---------------------- + +To move within a section use the usual keys (‘C-p’, ‘C-n’, ‘C-b’, ‘C-f’ +etc), whose global bindings are not shadowed. To move to another +section use the following commands. + +‘p’ (‘magit-section-backward’) + When not at the beginning of a section, then move to the beginning + of the current section. At the beginning of a section, instead + move to the beginning of the previous visible section. + +‘n’ (‘magit-section-forward’) + Move to the beginning of the next visible section. + +‘M-p’ (‘magit-section-backward-siblings’) + Move to the beginning of the previous sibling section. If there is + no previous sibling section, then move to the parent section + instead. + +‘M-n’ (‘magit-section-forward-siblings’) + Move to the beginning of the next sibling section. If there is no + next sibling section, then move to the parent section instead. + +‘^’ (‘magit-section-up’) + Move to the beginning of the parent of the current section. + + The above commands all call the hook ‘magit-section-movement-hook’. +Any of the functions listed below can be used as members of this hook. + + You might want to remove some of the functions that Magit adds using +‘add-hook’. In doing so you have to make sure you do not attempt to +remove function that haven’t even been added yet, for example: + + (with-eval-after-load 'magit-diff + (remove-hook 'magit-section-movement-hook + 'magit-hunk-set-window-start)) + + -- Variable: magit-section-movement-hook + This hook is run by all of the above movement commands, after + arriving at the destination. + + -- Function: magit-hunk-set-window-start + This hook function ensures that the beginning of the current + section is visible, provided it is a ‘hunk’ section. Otherwise, it + does nothing. + + Loading ‘magit-diff’ adds this function to the hook. + + -- Function: magit-section-set-window-start + This hook function ensures that the beginning of the current + section is visible, regardless of the section’s type. If you add + this to ‘magit-section-movement-hook’, then you must remove the + hunk-only variant in turn. + + -- Function: magit-log-maybe-show-more-commits + This hook function only has an effect in log buffers, and ‘point’ + is on the "show more" section. If that is the case, then it + doubles the number of commits that are being shown. + + Loading ‘magit-log’ adds this function to the hook. + + -- Function: magit-log-maybe-update-revision-buffer + When moving inside a log buffer, then this function updates the + revision buffer, provided it is already being displayed in another + window of the same frame. + + Loading ‘magit-log’ adds this function to the hook. + + -- Function: magit-log-maybe-update-blob-buffer + When moving inside a log buffer and another window of the same + frame displays a blob buffer, then this function instead displays + the blob buffer for the commit at point in that window. + + -- Function: magit-status-maybe-update-revision-buffer + When moving inside a status buffer, then this function updates the + revision buffer, provided it is already being displayed in another + window of the same frame. + + -- Function: magit-status-maybe-update-stash-buffer + When moving inside a status buffer, then this function updates the + stash buffer, provided it is already being displayed in another + window of the same frame. + + -- Function: magit-status-maybe-update-blob-buffer + When moving inside a status buffer and another window of the same + frame displays a blob buffer, then this function instead displays + the blob buffer for the commit at point in that window. + + -- Function: magit-stashes-maybe-update-stash-buffer + When moving inside a buffer listing stashes, then this function + updates the stash buffer, provided it is already being displayed in + another window of the same frame. + + -- User Option: magit-update-other-window-delay + Delay before automatically updating the other window. + + When moving around in certain buffers, then certain other buffers, + which are being displayed in another window, may optionally be + updated to display information about the section at point. + + When holding down a key to move by more than just one section, then + that would update that buffer for each section on the way. To + prevent that, updating the revision buffer is delayed, and this + option controls for how long. For optimal experience you might + have to adjust this delay and/or the keyboard repeat rate and delay + of your graphical environment or operating system. + + +File: magit.info, Node: Section Visibility, Next: Section Hooks, Prev: Section Movement, Up: Sections + +4.2.2 Section Visibility +------------------------ + +Magit provides many commands for changing the visibility of sections, +but all you need to get started are the next two. + +‘<TAB>’ (‘magit-section-toggle’) + Toggle the visibility of the body of the current section. + +‘C-c <TAB>’ (‘magit-section-cycle’) +‘C-<tab>’ (‘magit-section-cycle’) + Cycle the visibility of current section and its children. + + If this command is invoked using ‘C-<tab>’ and that is globally + bound to ‘tab-next’, then this command pivots to behave like that + command, and you must instead use ‘C-c TAB’ to cycle section + visibility. + + If you would like to keep using ‘C-<tab>’ to cycle section + visibility but also want to use ‘tab-bar-mode’, then you have to + prevent that mode from using this key and instead bind another key + to ‘tab-next’. Because ‘tab-bar-mode’ does not use a mode map but + instead manipulates the global map, this involves advising + ‘tab-bar--define-keys’. + +‘M-<tab>’ (‘magit-section-cycle-diffs’) + Cycle the visibility of diff-related sections in the current + buffer. + +‘S-<tab>’ (‘magit-section-cycle-global’) + Cycle the visibility of all sections in the current buffer. + +‘1’ (‘magit-section-show-level-1’) +‘2’ (‘magit-section-show-level-2’) +‘3’ (‘magit-section-show-level-3’) +‘4’ (‘magit-section-show-level-4’) + Show sections surrounding the current section up to level N. + +‘M-1’ (‘magit-section-show-level-1-all’) +‘M-2’ (‘magit-section-show-level-2-all’) +‘M-3’ (‘magit-section-show-level-3-all’) +‘M-4’ (‘magit-section-show-level-4-all’) + Show all sections up to level N. + + Some functions, which are used to implement the above commands, are +also exposed as commands themselves. By default no keys are bound to +these commands, as they are generally perceived to be much less useful. +But your mileage may vary. + + -- Command: magit-section-show + Show the body of the current section. + + -- Command: magit-section-hide + Hide the body of the current section. + + -- Command: magit-section-show-headings + Recursively show headings of children of the current section. Only + show the headings. Previously shown text-only bodies are hidden. + + -- Command: magit-section-show-children + Recursively show the bodies of children of the current section. + With a prefix argument show children down to the level of the + current section, and hide deeper children. + + -- Command: magit-section-hide-children + Recursively hide the bodies of children of the current section. + + -- Command: magit-section-toggle-children + Toggle visibility of bodies of children of the current section. + + When a buffer is first created then some sections are shown expanded +while others are not. This is hard coded. When a buffer is refreshed +then the previous visibility is preserved. The initial visibility of +certain sections can also be overwritten using the hook +‘magit-section-set-visibility-hook’. + + -- User Option: magit-section-initial-visibility-alist + This options can be used to override the initial visibility of + sections. In the future it will also be used to define the + defaults, but currently a section’s default is still hardcoded. + + The value is an alist. Each element maps a section type or lineage + to the initial visibility state for such sections. The state has + to be one of ‘show’ or ‘hide’, or a function that returns one of + these symbols. A function is called with the section as the only + argument. + + Use the command ‘magit-describe-section-briefly’ to determine a + section’s lineage or type. The vector in the output is the section + lineage and the type is the first element of that vector. + Wildcards can be used, see ‘magit-section-match’. + + -- User Option: magit-section-cache-visibility + This option controls for which sections the previous visibility + state should be restored if a section disappears and later appears + again. The value is a boolean or a list of section types. If t, + then the visibility of all sections is cached. Otherwise this is + only done for sections whose type matches one of the listed types. + + This requires that the function ‘magit-section-cached-visibility’ + is a member of ‘magit-section-set-visibility-hook’. + + -- Variable: magit-section-set-visibility-hook + This hook is run when first creating a buffer and also when + refreshing an existing buffer, and is used to determine the + visibility of the section currently being inserted. + + Each function is called with one argument, the section being + inserted. It should return ‘hide’ or ‘show’, or to leave the + visibility undefined ‘nil’. If no function decides on the + visibility and the buffer is being refreshed, then the visibility + is preserved; or if the buffer is being created, then the hard + coded default is used. + + Usually this should only be used to set the initial visibility but + not during refreshes. If ‘magit-insert-section--oldroot’ is + non-nil, then the buffer is being refreshed and these functions + should immediately return ‘nil’. + + -- User Option: magit-section-visibility-indicator + This option controls whether and how to indicate that a section can + be expanded/collapsed. + + If nil, then no visibility indicators are shown. Otherwise the + value has to have one of these two forms: + + • ‘(EXPANDABLE-BITMAP . COLLAPSIBLE-BITMAP)’ + + Both values have to be variables whose values are fringe + bitmaps. In this case every section that can be expanded or + collapsed gets an indicator in the left fringe. + + To provide extra padding around the indicator, set + ‘left-fringe-width’ in ‘magit-mode-hook’, e.g.: + + (add-hook 'magit-mode-hook (lambda () + (setq left-fringe-width 20))) + + • ‘(STRING . BOOLEAN)’ + + In this case STRING (usually an ellipsis) is shown at the end + of the heading of every collapsed section. Expanded sections + get no indicator. The cdr controls whether the appearance of + these ellipsis take section highlighting into account. Doing + so might potentially have an impact on performance, while not + doing so is kinda ugly. + + +File: magit.info, Node: Section Hooks, Next: Section Types and Values, Prev: Section Visibility, Up: Sections + +4.2.3 Section Hooks +------------------- + +Which sections are inserted into certain buffers is controlled with +hooks. This includes the status and the refs buffers. For other +buffers, e.g., log and diff buffers, this is not possible. The command +‘magit-describe-section’ can be used to see which hook (if any) was +responsible for inserting the section at point. + + For buffers whose sections can be customized by the user, a hook +variable called ‘magit-TYPE-sections-hook’ exists. This hook should be +changed using ‘magit-add-section-hook’. Avoid using ‘add-hooks’ or the +Custom interface. + + The various available section hook variables are described later in +this manual along with the appropriate "section inserter functions". + + -- Function: magit-add-section-hook hook function &optional at append + local + Add the function FUNCTION to the value of section hook HOOK. + + Add FUNCTION at the beginning of the hook list unless optional + APPEND is non-nil, in which case FUNCTION is added at the end. If + FUNCTION already is a member then move it to the new location. + + If optional AT is non-nil and a member of the hook list, then add + FUNCTION next to that instead. Add before or after AT, or replace + AT with FUNCTION depending on APPEND. If APPEND is the symbol + ‘replace’, then replace AT with FUNCTION. For any other non-nil + value place FUNCTION right after AT. If nil, then place FUNCTION + right before AT. If FUNCTION already is a member of the list but + AT is not, then leave FUNCTION where ever it already is. + + If optional LOCAL is non-nil, then modify the hook’s buffer-local + value rather than its global value. This makes the hook local by + copying the default value. That copy is then modified. + + HOOK should be a symbol. If HOOK is void, it is first set to nil. + HOOK’s value must not be a single hook function. FUNCTION should + be a function that takes no arguments and inserts one or multiple + sections at point, moving point forward. FUNCTION may choose not + to insert its section(s), when doing so would not make sense. It + should not be abused for other side-effects. + + To remove a function from a section hook, use ‘remove-hook’. + + +File: magit.info, Node: Section Types and Values, Next: Section Options, Prev: Section Hooks, Up: Sections + +4.2.4 Section Types and Values +------------------------------ + +Each section has a type, for example ‘hunk’, ‘file’, and ‘commit’. +Instances of certain section types also have a value. The value of a +section of type ‘file’, for example, is a file name. + + Users usually do not have to worry about a section’s type and value, +but knowing them can be handy at times. + +‘H’ (‘magit-describe-section’) + This command shows information about the section at point in a + separate buffer. + + -- Command: magit-describe-section-briefly + This command shows information about the section at point in the + echo area, as ‘#<magit-section VALUE [TYPE PARENT-TYPE...] + BEGINNING-END>’. + + Many commands behave differently depending on the type of the section +at point and/or somehow consume the value of that section. But that is +only one of the reasons why the same key may do something different, +depending on what section is current. + + Additionally for each section type a keymap *might* be defined, named +‘magit-TYPE-section-map’. That keymap is used as text property keymap +of all text belonging to any section of the respective type. If such a +map does not exist for a certain type, then you can define it yourself, +and it will automatically be used. + + +File: magit.info, Node: Section Options, Prev: Section Types and Values, Up: Sections + +4.2.5 Section Options +--------------------- + +This section describes options that have an effect on more than just a +certain type of sections. As you can see there are not many of those. + + -- User Option: magit-section-show-child-count + Whether to append the number of children to section headings. This + only affects sections that could benefit from this information. + + +File: magit.info, Node: Transient Commands, Next: Transient Arguments and Buffer Variables, Prev: Sections, Up: Interface Concepts + +4.3 Transient Commands +====================== + +Many Magit commands are implemented as *transient* commands. First the +user invokes a *prefix* command, which causes its *infix* arguments and +*suffix* commands to be displayed in the echo area. The user then +optionally sets some infix arguments and finally invokes one of the +suffix commands. + + This is implemented in the library ‘transient’. Earlier Magit +releases used the package ‘magit-popup’ and even earlier versions +library ‘magit-key-mode’. + + Transient is documented in *note (transient)Top::. + +‘C-x M-g’ (‘magit-dispatch’) +‘C-c g’ (‘magit-dispatch’) + This transient prefix command binds most of Magit’s other prefix + commands as suffix commands and displays them in a temporary buffer + until one of them is invoked. Invoking such a sub-prefix causes + the suffixes of that command to be bound and displayed instead of + those of ‘magit-dispatch’. + + This command is also, or especially, useful outside Magit buffers, + so Magit by default binds it to ‘C-c M-g’ in the global keymap. + ‘C-c g’ would be a better binding, but we cannot use that by + default, because that key sequence is reserved for the user. See + *note Global Bindings:: to learn more default and recommended key + bindings. + + +File: magit.info, Node: Transient Arguments and Buffer Variables, Next: Completion Confirmation and the Selection, Prev: Transient Commands, Up: Interface Concepts + +4.4 Transient Arguments and Buffer Variables +============================================ + +The infix arguments of many of Magit’s transient prefix commands cease +to have an effect once the ‘git’ command that is called with those +arguments has returned. Commands that create a commit are a good +example for this. If the user changes the arguments, then that only +affects the next invocation of a suffix command. If the same transient +prefix command is later invoked again, then the arguments are initially +reset to the default value. This default value can be set for the +current Emacs session or saved permanently, see *note (transient)Saving +Values::. It is also possible to cycle through previously used sets of +arguments using ‘C-M-p’ and ‘C-M-n’, see *note (transient)Using +History::. + + However the infix arguments of many other transient commands continue +to have an effect even after the ‘git’ command that was called with +those arguments has returned. The most important commands like this are +those that display a diff or log in a dedicated buffer. Their arguments +obviously continue to have an effect for as long as the respective diff +or log is being displayed. Furthermore the used arguments are stored in +buffer-local variables for future reference. + + For commands in the second group it isn’t always desirable to reset +their arguments to the global value when the transient prefix command is +invoked again. + + As mentioned above, it is possible to cycle through previously used +sets of arguments while a transient popup is visible. That means that +we could always reset the infix arguments to the default because the set +of arguments that is active in the existing buffer is only a few ‘C-M-p’ +away. Magit can be configured to behave like that, but because I expect +that most users would not find that very convenient, it is not the +default. + + Also note that it is possible to change the diff and log arguments +used in the current buffer (including the status buffer, which contains +both diff and log sections) using the respective "refresh" transient +prefix commands on ‘D’ and ‘L’. (‘d’ and ‘l’ on the other hand are +intended to change *what* diff or log is being displayed. It is +possible to also change *how* the diff or log is being displayed at the +same time, but if you only want to do the latter, then you should use +the refresh variants.) Because these secondary diff and log transient +prefixes are about *changing* the arguments used in the current buffer, +they *always* start out with the set of arguments that are currently in +effect in that buffer. + + Some commands are usually invoked directly even though they can also +be invoked as the suffix of a transient prefix command. Most +prominently ‘magit-show-commit’ is usually invoked by typing ‘RET’ while +point is on a commit in a log, but it can also be invoked from the +‘magit-diff’ transient prefix. + + When such a command is invoked directly, then it is important to +reuse the arguments as specified by the respective buffer-local values, +instead of using the default arguments. Imagine you press ‘RET’ in a +log to display the commit at point in a different buffer and then use +‘D’ to change how the diff is displayed in that buffer. And then you +press ‘RET’ on another commit to show that instead and the diff +arguments are reset to the default. Not cool; so Magit does not do that +by default. + + -- User Option: magit-prefix-use-buffer-arguments + This option controls whether the infix arguments initially shown in + certain transient prefix commands are based on the arguments that + are currently in effect in the buffer that their suffixes update. + + The ‘magit-diff’ and ‘magit-log’ transient prefix commands are + affected by this option. + + -- User Option: magit-direct-use-buffer-arguments + This option controls whether certain commands, when invoked + directly (i.e., not as the suffix of a transient prefix command), + use the arguments that are currently active in the buffer that they + are about to update. The alternative is to use the default value + for these arguments, which might change the arguments that are used + in the buffer. + +Valid values for both of the above options are: + + • ‘always’: Always use the set of arguments that is currently active + in the respective buffer, provided that buffer exists of course. + • ‘selected’ or ‘t’: Use the set of arguments from the respective + buffer, but only if it is displayed in a window of the current + frame. This is the default for both variables. + • ‘current’: Use the set of arguments from the respective buffer, but + only if it is the current buffer. + • ‘never’: Never use the set of arguments from the respective buffer. + +I am afraid it gets more complicated still: + + • The global diff and log arguments are set for each supported mode + individually. The diff arguments for example have different values + in ‘magit-diff-mode’, ‘magit-revision-mode’, + ‘magit-merge-preview-mode’ and ‘magit-status-mode’ buffers. + Setting or saving the value for one mode does not change the value + for other modes. The history however is shared. + + • When ‘magit-show-commit’ is invoked directly from a log buffer, + then the file filter is picked up from that buffer, not from the + revision buffer or the mode’s global diff arguments. + + • Even though they are suffixes of the diff prefix + ‘magit-show-commit’ and ‘magit-stash-show’ do not use the diff + buffer used by the diff commands, instead they use the dedicated + revision and stash buffers. + + At the time you invoke the diff prefix it is unknown to Magit which + of the suffix commands you are going to invoke. While not certain, + more often than not users invoke one of the commands that use the + diff buffer, so the initial infix arguments are those used in that + buffer. However if you invoke one of these commands directly, then + Magit knows that it should use the arguments from the revision + resp. stash buffer. + + • The log prefix also features reflog commands, but these commands do + not use the log arguments. + + • If ‘magit-show-refs’ is invoked from a ‘magit-refs-mode’ buffer, + then it acts as a refresh prefix and therefore unconditionally uses + the buffer’s arguments as initial arguments. If it is invoked + elsewhere with a prefix argument, then it acts as regular prefix + and therefore respects ‘magit-prefix-use-buffer-arguments’. If it + is invoked elsewhere without a prefix argument, then it acts as a + direct command and therefore respects + ‘magit-direct-use-buffer-arguments’. + + +File: magit.info, Node: Completion Confirmation and the Selection, Next: Mouse Support, Prev: Transient Arguments and Buffer Variables, Up: Interface Concepts + +4.5 Completion, Confirmation and the Selection +============================================== + +* Menu: + +* Action Confirmation:: +* Completion and Confirmation:: +* The Selection:: +* The hunk-internal region:: +* Support for Completion Frameworks:: +* Additional Completion Options:: + + +File: magit.info, Node: Action Confirmation, Next: Completion and Confirmation, Up: Completion Confirmation and the Selection + +4.5.1 Action Confirmation +------------------------- + +By default many actions that could potentially lead to data loss have to +be confirmed. This includes many very common actions, so this can +quickly become annoying. Many of these actions can be undone and if you +have thought about how to undo certain mistakes, then it should be safe +to disable confirmation for the respective actions. + + The option ‘magit-no-confirm’ can be used to tell Magit to perform +certain actions without the user having to confirm them. Note that +while this option can only be used to disable confirmation for a +specific set of actions, the next section explains another way of +telling Magit to ask fewer questions. + + -- User Option: magit-no-confirm + The value of this option is a list of symbols, representing actions + that do not have to be confirmed by the user before being carried + out. + + By default many potentially dangerous commands ask the user for + confirmation. Each of the below symbols stands for an action + which, when invoked unintentionally or without being fully aware of + the consequences, could lead to tears. In many cases there are + several commands that perform variations of a certain action, so we + don’t use the command names but more generic symbols. + + • Applying changes: + + • ‘discard’ Discarding one or more changes (i.e., hunks or + the complete diff for a file) loses that change, + obviously. + + • ‘reverse’ Reverting one or more changes can usually be + undone by reverting the reversion. + + • ‘stage-all-changes’, ‘unstage-all-changes’ When there are + both staged and unstaged changes, then un-/staging + everything would destroy that distinction. Of course + that also applies when un-/staging a single change, but + then less is lost and one does that so often that having + to confirm every time would be unacceptable. + + • Files: + + • ‘delete’ When a file that isn’t yet tracked by Git is + deleted, then it is completely lost, not just the last + changes. Very dangerous. + + • ‘trash’ Instead of deleting a file it can also be move to + the system trash. Obviously much less dangerous than + deleting it. + + Also see option ‘magit-delete-by-moving-to-trash’. + + • ‘resurrect’ A deleted file can easily be resurrected by + "deleting" the deletion, which is done using the same + command that was used to delete the same file in the + first place. + + • ‘untrack’ Untracking a file can be undone by tracking it + again. + + • ‘rename’ Renaming a file can easily be undone. + + • Sequences: + + • ‘reset-bisect’ Aborting (known to Git as "resetting") a + bisect operation loses all information collected so far. + + • ‘abort-cherry-pick’ Aborting a cherry-pick throws away + all conflict resolutions which have already been carried + out by the user. + + • ‘abort-revert’ Aborting a revert throws away all conflict + resolutions which have already been carried out by the + user. + + • ‘abort-rebase’ Aborting a rebase throws away all already + modified commits, but it’s possible to restore those from + the reflog. + + • ‘abort-merge’ Aborting a merge throws away all conflict + resolutions which have already been carried out by the + user. + + • ‘merge-dirty’ Merging with a dirty worktree can make it + hard to go back to the state before the merge was + initiated. + + • References: + + • ‘delete-unmerged-branch’ Once a branch has been deleted, + it can only be restored using low-level recovery tools + provided by Git. And even then the reflog is gone. The + user always has to confirm the deletion of a branch by + accepting the default choice (or selecting another + branch), but when a branch has not been merged yet, also + make sure the user is aware of that. + + • ‘delete-pr-remote’ When deleting a branch that was + created from a pull-request and if no other branches + still exist on that remote, then ‘magit-branch-delete’ + offers to delete the remote as well. This should be safe + because it only happens if no other refs exist in the + remotes namespace, and you can recreate the remote if + necessary. + + • ‘drop-stashes’ Dropping a stash is dangerous because Git + stores stashes in the reflog. Once a stash is removed, + there is no going back without using low-level recovery + tools provided by Git. When a single stash is dropped, + then the user always has to confirm by accepting the + default (or selecting another). This action only + concerns the deletion of multiple stashes at once. + + • Publishing: + + • ‘set-and-push’ When pushing to the upstream or the + push-remote and that isn’t actually configured yet, then + the user can first set the target. If s/he confirms the + default too quickly, then s/he might end up pushing to + the wrong branch and if the remote repository is + configured to disallow fixing such mistakes, then that + can be quite embarrassing and annoying. + + • Edit published history: + + Without adding these symbols here, you will be warned before + editing commits that have already been pushed to one of the + branches listed in ‘magit-published-branches’. + + • ‘amend-published’ Affects most commands that amend to + "HEAD". + + • ‘rebase-published’ Affects commands that perform + interactive rebases. This includes commands from the + commit transient that modify a commit other than "HEAD", + namely the various fixup and squash variants. + + • ‘edit-published’ Affects the commands + ‘magit-edit-line-commit’ and + ‘magit-diff-edit-hunk-commit’. These two commands make + it quite easy to accidentally edit a published commit, so + you should think twice before configuring them not to ask + for confirmation. + + To disable confirmation completely, add all three symbols here + or set ‘magit-published-branches’ to ‘nil’. + + • Various: + + • ‘stash-apply-3way’ When a stash cannot be applied using + ‘git stash apply’, then Magit uses ‘git apply’ instead, + possibly using the ‘--3way’ argument, which isn’t always + perfectly safe. See also ‘magit-stash-apply’. + + • ‘kill-process’ There seldom is a reason to kill a + process. + + • Global settings: + + Instead of adding all of the above symbols to the value of + this option, you can also set it to the atom ‘t’, which has + the same effect as adding all of the above symbols. Doing + that most certainly is a bad idea, especially because other + symbols might be added in the future. So even if you don’t + want to be asked for confirmation for any of these actions, + you are still better of adding all of the respective symbols + individually. + + When ‘magit-wip-before-change-mode’ is enabled, then the + following actions can be undone fairly easily: ‘discard’, + ‘reverse’, ‘stage-all-changes’, and ‘unstage-all-changes’. If + and only if this mode is enabled, then ‘safe-with-wip’ has the + same effect as adding all of these symbols individually. + + +File: magit.info, Node: Completion and Confirmation, Next: The Selection, Prev: Action Confirmation, Up: Completion Confirmation and the Selection + +4.5.2 Completion and Confirmation +--------------------------------- + +Many Magit commands ask the user to select from a list of possible +things to act on, while offering the most likely choice as the default. +For many of these commands the default is the thing at point, provided +that it actually is a valid thing to act on. For many commands that act +on a branch, the current branch serves as the default if there is no +branch at point. + + These commands combine asking for confirmation and asking for a +target to act on into a single action. The user can confirm the default +target using ‘RET’ or abort using ‘C-g’. This is similar to a +‘y-or-n-p’ prompt, but the keys to confirm or abort differ. + + At the same time the user is also given the opportunity to select +another target, which is useful because for some commands and/or in some +situations you might want to select the action before selecting the +target by moving to it. + + However you might find that for some commands you always want to use +the default target, if any, or even that you want the command to act on +the default without requiring any confirmation at all. The option +‘magit-dwim-selection’ can be used to configure certain commands to that +effect. + + Note that when the region is active then many commands act on the +things that are selected using a mechanism based on the region, in many +cases after asking for confirmation. This region-based mechanism is +called the "selection" and is described in detail in the next section. +When a selection exists that is valid for the invoked command, then that +command never offers to act on something else, and whether it asks for +confirmation is not controlled by this option. + + Also note that Magit asks for confirmation of certain actions that +are not coupled with completion (or the selection). Such dialogs are +also not affected by this option and are described in the previous +section. + + -- User Option: magit-dwim-selection + This option can be used to tell certain commands to use the thing at +point instead of asking the user to select a candidate to act on, with +or without confirmation. + + The value has the form ‘((COMMAND nil|PROMPT DEFAULT)...)’. + + • COMMAND is the command that should not prompt for a choice. To + have an effect, the command has to use the function + ‘magit-completing-read’ or a utility function which in turn uses + that function. + + • If the command uses ‘magit-completing-read’ multiple times, then + PROMPT can be used to only affect one of these uses. PROMPT, if + non-nil, is a regular expression that is used to match against the + PROMPT argument passed to ‘magit-completing-read’. + + • DEFAULT specifies how to use the default. If it is ‘t’, then the + DEFAULT argument passed to ‘magit-completing-read’ is used without + confirmation. If it is ‘ask’, then the user is given a chance to + abort. DEFAULT can also be ‘nil’, in which case the entry has no + effect. + + +File: magit.info, Node: The Selection, Next: The hunk-internal region, Prev: Completion and Confirmation, Up: Completion Confirmation and the Selection + +4.5.3 The Selection +------------------- + +If the region is active, then many Magit commands act on the things that +are selected using a mechanism based on the region instead of one single +thing. When the region is not active, then these commands act on the +thing at point or read a single thing to act on. This is described in +the previous section — this section only covers how multiple things are +selected, how that is visualized, and how certain commands behave when +that is the case. + + Magit’s mechanism for selecting multiple things, or rather sections +that represent these things, is based on the Emacs region, but the area +that Magit considers to be selected is typically larger than the region +and additional restrictions apply. + + Magit makes a distinction between a region that qualifies as forming +a valid Magit selection and a region that does not. If the region does +not qualify, then it is displayed as it is in other Emacs buffers. If +the region does qualify as a Magit selection, then the selection is +always visualized, while the region itself is only visualized if it +begins and ends on the same line. + + For a region to qualify as a Magit selection, it must begin in the +heading of one section and end in the heading of a sibling section. +Note that if the end of the region is at the very beginning of section +heading (i.e., at the very beginning of a line) then that section is +considered to be *inside* the selection. + + This is not consistent with how the region is normally treated in +Emacs — if the region ends at the beginning of a line, then that line is +outside the region. Due to how Magit visualizes the selection, it +should be obvious that this difference exists. + + Not every command acts on every valid selection. Some commands do +not even consider the location of point, others may act on the section +at point but not support acting on the selection, and even commands that +do support the selection of course only do so if it selects things that +they can act on. + + This is the main reason why the selection must include the section at +point. Even if a selection exists, the invoked command may disregard +it, in which case it may act on the current section only. It is much +safer to only act on the current section but not the other selected +sections than it is to act on the current section *instead* of the +selected sections. The latter would be much more surprising and if the +current section always is part of the selection, then that cannot +happen. + + -- Variable: magit-keep-region-overlay + This variable controls whether the region is visualized as usual + even when a valid Magit selection or a hunk-internal region exists. + See the doc-string for more information. + + +File: magit.info, Node: The hunk-internal region, Next: Support for Completion Frameworks, Prev: The Selection, Up: Completion Confirmation and the Selection + +4.5.4 The hunk-internal region +------------------------------ + +Somewhat related to the Magit selection described in the previous +section is the hunk-internal region. + + Like the selection, the hunk-internal region is based on the Emacs +region but causes that region to not be visualized as it would in other +Emacs buffers, and includes the line on which the region ends even if it +ends at the very beginning of that line. + + Unlike the selection, which is based on a region that must begin in +the heading of one section and ends in the section of a sibling section, +the hunk-internal region must begin inside the *body* of a hunk section +and end in the body of the *same* section. + + The hunk-internal region is honored by "apply" commands, which can, +among other targets, act on a hunk. If the hunk-internal region is +active, then such commands act only on the marked part of the hunk +instead of on the complete hunk. + + +File: magit.info, Node: Support for Completion Frameworks, Next: Additional Completion Options, Prev: The hunk-internal region, Up: Completion Confirmation and the Selection + +4.5.5 Support for Completion Frameworks +--------------------------------------- + +The built-in option ‘completing-read-function’ specifies the low-level +function used by ‘completing-read’ to ask a user to select from a list +of choices. Its default value is ‘completing-read-default’. +Alternative completion frameworks typically activate themselves by +substituting their own implementation. + + Mostly for historic reasons Magit provides a similar option named +‘magit-completing-read-function’, which only controls the low-level +function used by ‘magit-completing-read’. This option also makes it +possible to use a different completing mechanism for Magit than for the +rest of Emacs, but doing that is not recommend. + + You most likely don’t have to customize the magit-specific option to +use an alternative completion framework. For example, if you enable +‘ivy-mode’, then Magit will respect that, and if you enable ‘helm-mode’, +then you are done too. + + However if you want to use Ido, then ‘ido-mode’ won’t do the trick. +You will also have to install the ‘ido-completing-read+’ package and use +‘magit-ido-completing-read’ as ‘magit-completing-read-function’. + + -- User Option: magit-completing-read-function + The value of this variable is the low-level function used to + perform completion by code that uses ‘magit-completing-read’ (as + opposed to the built-in ‘completing-read’). + + The default value, ‘magit-builtin-completing-read’, is suitable for + the standard completion mechanism, ‘ivy-mode’, and ‘helm-mode’ at + least. + + The built-in ‘completing-read’ and ‘completing-read-default’ are + *not* suitable to be used here. ‘magit-builtin-completing-read’ + performs some additional work, and any function used in its place + has to do the same. + + -- Function: magit-builtin-completing-read prompt choices &optional + predicate require-match initial-input hist def + This function performs completion using the built-in + ‘completing-read’ and does some additional magit-specific work. + + -- Function: magit-ido-completing-read prompt choices &optional + predicate require-match initial-input hist def + This function performs completion using ‘ido-completing-read+’ from + the package by the same name (which you have to explicitly install) + and does some additional magit-specific work. + + We have to use ‘ido-completing-read+’ instead of the + ‘ido-completing-read’ that comes with Ido itself, because the + latter, while intended as a drop-in replacement, cannot serve that + purpose because it violates too many of the implicit conventions. + + -- Function: magit-completing-read prompt choices &optional predicate + require-match initial-input hist def fallback + This is the function that Magit commands use when they need the + user to select a single thing to act on. The arguments have the + same meaning as for ‘completing-read’, except for FALLBACK, which + is unique to this function and is described below. + + Instead of asking the user to choose from a list of possible + candidates, this function may just return the default specified by + DEF, with or without requiring user confirmation. Whether that is + the case depends on PROMPT, ‘this-command’ and + ‘magit-dwim-selection’. See the documentation of the latter for + more information. + + If it does read a value in the minibuffer, then this function acts + similar to ‘completing-read’, except for the following: + + • COLLECTION must be a list of choices. A function is not + supported. + + • If REQUIRE-MATCH is ‘nil’ and the user exits without a choice, + then ‘nil’ is returned instead of an empty string. + + • If REQUIRE-MATCH is non-nil and the users exits without a + choice, an user-error is raised. + + • FALLBACK specifies a secondary default that is only used if + the primary default DEF is ‘nil’. The secondary default is + not subject to ‘magit-dwim-selection’ — if DEF is ‘nil’ but + FALLBACK is not, then this function always asks the user to + choose a candidate, just as if both defaults were ‘nil’. + + • ‘format-prompt’ is called on PROMPT and DEF (or FALLBACK if + DEF is ‘nil’). This appends ": " to the prompt and may also + add the default to the prompt, using the format specified by + ‘minibuffer-default-prompt-format’ and depending on + ‘magit-completing-read-default-prompt-predicate’. + + +File: magit.info, Node: Additional Completion Options, Prev: Support for Completion Frameworks, Up: Completion Confirmation and the Selection + +4.5.6 Additional Completion Options +----------------------------------- + + -- User Option: magit-list-refs-sortby + For many commands that read a ref or refs from the user, the value + of this option can be used to control the order of the refs. Valid + values include any key accepted by the ‘--sort’ flag of ‘git + for-each-ref’. By default, refs are sorted alphabetically by their + full name (e.g., "refs/heads/master"). + + +File: magit.info, Node: Mouse Support, Next: Running Git, Prev: Completion Confirmation and the Selection, Up: Interface Concepts + +4.6 Mouse Support +================= + +Double clicking on a section heading toggles the visibility of its body, +if any. Likewise clicking in the left fringe toggles the visibility of +the appropriate section. + + A context menu is provided but has to be enabled explicitly. In +Emacs 28 and greater, enable the global mode ‘context-menu-mode’. If +you use an older Emacs release, set +‘magit-section-show-context-menu-for-emacs<28’. + + +File: magit.info, Node: Running Git, Prev: Mouse Support, Up: Interface Concepts + +4.7 Running Git +=============== + +* Menu: + +* Viewing Git Output:: +* Git Process Status:: +* Running Git Manually:: +* Git Executable:: +* Global Git Arguments:: + + +File: magit.info, Node: Viewing Git Output, Next: Git Process Status, Up: Running Git + +4.7.1 Viewing Git Output +------------------------ + +Magit runs Git either for side-effects (e.g., when pushing) or to get +some value (e.g., the name of the current branch). + + When Git is run for side-effects, the process output is logged in a +per-repository log buffer, which can be consulted using the +‘magit-process’ command when things don’t go as expected. + + The output/errors for up to ‘magit-process-log-max’ Git commands are +retained. + +‘$’ (‘magit-process’) + This commands displays the process buffer for the current + repository. + + Inside that buffer, the usual key bindings for navigating and showing +sections are available. There is one additional command. + +‘k’ (‘magit-process-kill’) + This command kills the process represented by the section at point. + + -- Variable: magit-git-debug + This option controls whether additional reporting of git errors is + enabled. + + Magit basically calls git for one of these two reasons: for + side-effects or to do something with its standard output. + + When git is run for side-effects then its output, including error + messages, go into the process buffer which is shown when using ‘$’. + + When git’s output is consumed in some way, then it would be too + expensive to also insert it into this buffer, but when this option + is non-nil and git returns with a non-zero exit status, then at + least its standard error is inserted into this buffer. + + This is only intended for debugging purposes. Do not enable this + permanently, that would negatively affect performance. + + This is only intended for debugging purposes. Do not enable this + permanently, that would negatively affect performance. Also note + that just because git exits with a non-zero exit status and prints + an error message that usually doesn’t mean that it is an error as + far as Magit is concerned, which is another reason we usually hide + these error messages. Whether some error message is relevant in + the context of some unexpected behavior has to be judged on a case + by case basis. + + The command ‘magit-toggle-git-debug’ changes the value of this + variable. + + -- Variable: magit-process-extreme-logging + This option controls whether ‘magit-process-file’ logs to the + ‘*Messages*’ buffer. + + Only intended for temporary use when you try to figure out how + Magit uses Git behind the scene. Output that normally goes to the + magit-process buffer continues to go there. Not all output goes to + either of these two buffers. + + +File: magit.info, Node: Git Process Status, Next: Running Git Manually, Prev: Viewing Git Output, Up: Running Git + +4.7.2 Git Process Status +------------------------ + +When a Git process is running for side-effects, Magit displays an +indicator in the mode line, using the ‘magit-mode-line-process’ face. + + If the Git process exits successfully, the process indicator is +removed from the mode line immediately. + + In the case of a Git error, the process indicator is not removed, but +is instead highlighted with the ‘magit-mode-line-process-error’ face, +and the error details from the process buffer are provided as a tooltip +for mouse users. This error indicator persists in the mode line until +the next magit buffer refresh. + + If you do not wish process errors to be indicated in the mode line, +customize the ‘magit-process-display-mode-line-error’ user option. + + Process errors are additionally indicated at the top of the status +buffer. + + +File: magit.info, Node: Running Git Manually, Next: Git Executable, Prev: Git Process Status, Up: Running Git + +4.7.3 Running Git Manually +-------------------------- + +While Magit provides many Emacs commands to interact with Git, it does +not cover everything. In those cases your existing Git knowledge will +come in handy. Magit provides some commands for running arbitrary Git +commands by typing them into the minibuffer, instead of having to switch +to a shell. + +‘!’ (‘magit-run’) + This transient prefix command binds the following suffix commands + and displays them in a temporary buffer until a suffix is invoked. + +‘! !’ (‘magit-git-command-topdir’) + This command reads a command from the user and executes it in the + top-level directory of the current working tree. + + The string "git " is used as initial input when prompting the user + for the command. It can be removed to run another command. + +‘:’ (‘magit-git-command’) +‘! p’ + This command reads a command from the user and executes it in + ‘default-directory’. With a prefix argument the command is + executed in the top-level directory of the current working tree + instead. + + The string "git " is used as initial input when prompting the user + for the command. It can be removed to run another command. + +‘! s’ (‘magit-shell-command-topdir’) + This command reads a command from the user and executes it in the + top-level directory of the current working tree. + +‘! S’ (‘magit-shell-command’) + This command reads a command from the user and executes it in + ‘default-directory’. With a prefix argument the command is + executed in the top-level directory of the current working tree + instead. + + -- User Option: magit-shell-command-verbose-prompt + Whether the prompt, used by the above commands when reading a shell + command, shows the directory in which it will be run. + + These suffix commands start external gui tools. + +‘! k’ (‘magit-run-gitk’) + This command runs ‘gitk’ in the current repository. + +‘! a’ (‘magit-run-gitk-all’) + This command runs ‘gitk --all’ in the current repository. + +‘! b’ (‘magit-run-gitk-branches’) + This command runs ‘gitk --branches’ in the current repository. + +‘! g’ (‘magit-run-git-gui’) + This command runs ‘git gui’ in the current repository. + +‘! m’ (‘magit-git-mergetool’) + This command runs ‘git mergetool --gui’ in the current repository. + + With a prefix argument this acts as a transient prefix command, + allowing the user to select the mergetool and change some settings. + + +File: magit.info, Node: Git Executable, Next: Global Git Arguments, Prev: Running Git Manually, Up: Running Git + +4.7.4 Git Executable +-------------------- + +When Magit calls Git, then it may do so using the absolute path to the +‘git’ executable, or using just its name. + + When running ‘git’ locally and the ‘system-type’ is ‘windows-nt’ (any +Windows version) or ‘darwin’ (macOS) then ‘magit-git-executable’ is set +to an absolute path when Magit is loaded. + + On Windows it is necessary to use an absolute path because Git comes +with several wrapper scripts for the actual ‘git’ binary, which are also +placed on ‘$PATH’, and using one of these wrappers instead of the binary +would degrade performance horribly. For some macOS users using just the +name of the executable also performs horribly, so we avoid doing that on +that platform as well. On other platforms, using just the name seems to +work just fine. + + Using an absolute path when running ‘git’ on a remote machine over +Tramp, would be problematic to use an absolute path that is suitable on +the local machine, so a separate option is used to control the name or +path that is used on remote machines. + + -- User Option: magit-git-executable + The ‘git’ executable used by Magit on the local host. This should + be either the absolute path to the executable, or the string "git" + to let Emacs find the executable itself, using the standard + mechanism for doing such things. + + -- User Option: magit-remote-git-executable + The ‘git’ executable used by Magit on remote machines over Tramp. + Normally this should be just the string "git". Consider + customizing ‘tramp-remote-path’ instead of this option. + + If Emacs is unable to find the correct executable, then you can work +around that by explicitly setting the value of one of these two options. +Doing that should be considered a kludge; it is better to make sure that +the order in ‘exec-path’ or ‘tramp-remote-path’ is correct. + + Note that ‘exec-path’ is set based on the value of the ‘PATH’ +environment variable that is in effect when Emacs is started. If you +set ‘PATH’ in your shell’s init files, then that only has an effect on +Emacs if you start it from that shell (because the environment of a +process is only passed to its child processes, not to arbitrary other +processes). If that is not how you start Emacs, then the +‘exec-path-from-shell’ package can help; though honestly I consider that +a kludge too. + + The command ‘magit-debug-git-executable’ can be useful to find out +where Emacs is searching for ‘git’. + +‘M-x magit-debug-git-executable’ + This command displays a buffer with information about + ‘magit-git-executable’ and ‘magit-remote-git-executable’. + +‘M-x magit-version’ + This command shows the currently used versions of Magit, Git, and + Emacs in the echo area. Non-interactively this just returns the + Magit version. + + +File: magit.info, Node: Global Git Arguments, Prev: Git Executable, Up: Running Git + +4.7.5 Global Git Arguments +-------------------------- + + -- User Option: magit-git-global-arguments + The arguments set here are used every time the git executable is + run as a subprocess. They are placed right after the executable + itself and before the git command - as in ‘git HERE... COMMAND + REST’. For valid arguments see *note (gitman)git::. + + Be careful what you add here, especially if you are using Tramp to + connect to servers with ancient Git versions. Never remove + anything that is part of the default value, unless you really know + what you are doing. And think very hard before adding something; + it will be used every time Magit runs Git for any purpose. + + +File: magit.info, Node: Inspecting, Next: Manipulating, Prev: Interface Concepts, Up: Top + +5 Inspecting +************ + +The functionality provided by Magit can be roughly divided into three +groups: inspecting existing data, manipulating existing data or adding +new data, and transferring data. Of course that is a rather crude +distinction that often falls short, but it’s more useful than no +distinction at all. This section is concerned with inspecting data, the +next two with manipulating and transferring it. Then follows a section +about miscellaneous functionality, which cannot easily be fit into this +distinction. + + Of course other distinctions make sense too, e.g., Git’s distinction +between porcelain and plumbing commands, which for the most part is +equivalent to Emacs’ distinction between interactive commands and +non-interactive functions. All of the sections mentioned before are +mainly concerned with the porcelain – Magit’s plumbing layer is +described later. + +* Menu: + +* Status Buffer:: +* Repository List:: +* Logging:: +* Diffing:: +* Ediffing:: +* References Buffer:: +* Bisecting:: +* Visiting Files and Blobs:: +* Blaming:: + + +File: magit.info, Node: Status Buffer, Next: Repository List, Up: Inspecting + +5.1 Status Buffer +================= + +While other Magit buffers contain, e.g., one particular diff or one +particular log, the status buffer contains the diffs for staged and +unstaged changes, logs for unpushed and unpulled commits, lists of +stashes and untracked files, and information related to the current +branch. + + During certain incomplete operations – for example when a merge +resulted in a conflict – additional information is displayed that helps +proceeding with or aborting the operation. + + The command ‘magit-status’ displays the status buffer belonging to +the current repository in another window. This command is used so often +that it should be bound globally. We recommend using ‘C-x g’: + + (global-set-key (kbd "C-x g") 'magit-status) + +‘C-x g’ (‘magit-status’) + When invoked from within an existing Git repository, then this + command shows the status of that repository in a buffer. + + If the current directory isn’t located within a Git repository, + then this command prompts for an existing repository or an + arbitrary directory, depending on the option + ‘magit-repository-directories’, and the status for the selected + repository is shown instead. + + • If that option specifies any existing repositories, then the + user is asked to select one of them. + + • Otherwise the user is asked to select an arbitrary directory + using regular file-name completion. If the selected directory + is the top-level directory of an existing working tree, then + the status buffer for that is shown. + + • Otherwise the user is offered to initialize the selected + directory as a new repository. After creating the repository + its status buffer is shown. + + These fallback behaviors can also be forced using one or more + prefix arguments: + + • With two prefix arguments (or more precisely a numeric prefix + value of 16 or greater) an arbitrary directory is read, which + is then acted on as described above. The same could be + accomplished using the command ‘magit-init’. + + • With a single prefix argument an existing repository is read + from the user, or if no repository can be found based on the + value of ‘magit-repository-directories’, then the behavior is + the same as with two prefix arguments. + + -- User Option: magit-repository-directories + List of directories that are Git repositories or contain Git + repositories. + + Each element has the form ‘(DIRECTORY . DEPTH)’. DIRECTORY has to + be a directory or a directory file-name, a string. DEPTH, an + integer, specifies the maximum depth to look for Git repositories. + If it is 0, then only add DIRECTORY itself. + + This option controls which repositories are being listed by + ‘magit-list-repositories’. It also affects ‘magit-status’ (which + see) in potentially surprising ways (see above). + + -- Command: magit-status-quick + This command is an alternative to ‘magit-status’ that usually + avoids refreshing the status buffer. + + If the status buffer of the current Git repository exists but isn’t + being displayed in the selected frame, then it is displayed without + being refreshed. + + If the status buffer is being displayed in the selected frame, then + this command refreshes it. + + Prefix arguments have the same meaning as for ‘magit-status’, and + additionally cause the buffer to be refresh. + + To use this command add this to your init file: + + (global-set-key (kbd "C-x g") 'magit-status-quick). + + If you do that and then for once want to redisplay the buffer and + also immediately refresh it, then type ‘C-x g’ followed by ‘g’. + + A possible alternative command is + ‘magit-display-repository-buffer’. It supports displaying any + existing Magit buffer that belongs to the current repository; not + just the status buffer. + + -- Command: ido-enter-magit-status + From an Ido prompt used to open a file, instead drop into + ‘magit-status’. This is similar to ‘ido-magic-delete-char’, which, + despite its name, usually causes a Dired buffer to be created. + + To make this command available, use something like: + + (add-hook 'ido-setup-hook + (lambda () + (define-key ido-completion-map + (kbd \"C-x g\") 'ido-enter-magit-status))) + + Starting with Emacs 25.1 the Ido keymaps are defined just once + instead of every time Ido is invoked, so now you can modify it like + pretty much every other keymap: + + (define-key ido-common-completion-map + (kbd \"C-x g\") 'ido-enter-magit-status) + +* Menu: + +* Status Sections:: +* Status Header Sections:: +* Status Module Sections:: +* Status Options:: + + +File: magit.info, Node: Status Sections, Next: Status Header Sections, Up: Status Buffer + +5.1.1 Status Sections +--------------------- + +The contents of status buffers is controlled using the hook +‘magit-status-sections-hook’. See *note Section Hooks:: to learn about +such hooks and how to customize them. + + -- User Option: magit-status-sections-hook + Hook run to insert sections into a status buffer. + + The first function on that hook by default is +‘magit-insert-status-headers’; it is described in the next section. By +default the following functions are also members of that hook: + + -- Function: magit-insert-merge-log + Insert section for the on-going merge. Display the heads that are + being merged. If no merge is in progress, do nothing. + + -- Function: magit-insert-rebase-sequence + Insert section for the on-going rebase sequence. If no such + sequence is in progress, do nothing. + + -- Function: magit-insert-am-sequence + Insert section for the on-going patch applying sequence. If no + such sequence is in progress, do nothing. + + -- Function: magit-insert-sequencer-sequence + Insert section for the on-going cherry-pick or revert sequence. If + no such sequence is in progress, do nothing. + + -- Function: magit-insert-bisect-output + While bisecting, insert section with output from ‘git bisect’. + + -- Function: magit-insert-bisect-rest + While bisecting, insert section visualizing the bisect state. + + -- Function: magit-insert-bisect-log + While bisecting, insert section logging bisect progress. + + -- Function: magit-insert-untracked-files + Maybe insert a list or tree of untracked files. + + Do so depending on the value of ‘status.showUntrackedFiles’. Note + that even if the value is ‘all’, Magit still initially only shows + directories. But the directory sections can then be expanded using + ‘TAB’. + + -- Function: magit-insert-unstaged-changes + Insert section showing unstaged changes. + + -- Function: magit-insert-staged-changes + Insert section showing staged changes. + + -- Function: magit-insert-stashes &optional ref heading + Insert the ‘stashes’ section showing reflog for "refs/stash". If + optional REF is non-nil show reflog for that instead. If optional + HEADING is non-nil use that as section heading instead of + "Stashes:". + + -- Function: magit-insert-unpulled-from-upstream + Insert section showing commits that haven’t been pulled from the + upstream branch yet. + + -- Function: magit-insert-unpulled-from-pushremote + Insert section showing commits that haven’t been pulled from the + push-remote branch yet. + + -- Function: magit-insert-unpushed-to-upstream + Insert section showing commits that haven’t been pushed to the + upstream yet. + + -- Function: magit-insert-unpushed-to-pushremote + Insert section showing commits that haven’t been pushed to the + push-remote yet. + + The following functions can also be added to the above hook: + + -- Function: magit-insert-tracked-files + Insert a tree of tracked files. + + -- Function: magit-insert-ignored-files + Insert a tree of ignored files. Its possible to limit the logs in + the current buffer to a certain directory using ‘D = f <DIRECTORY> + RET g’. If you do that, then that that also affects this command. + + The log filter can be used to limit to multiple files. In that + case this function only respects the first of the files and only if + it is a directory. + + -- Function: magit-insert-skip-worktree-files + Insert a tree of skip-worktree files. If the first element of + ‘magit-buffer-diff-files’ is a directory, then limit the list to + files below that. The value of that variable can be set using ‘D + -- DIRECTORY RET g’. + + -- Function: magit-insert-assumed-unchanged-files + Insert a tree of files that are assumed to be unchanged. If the + first element of ‘magit-buffer-diff-files’ is a directory, then + limit the list to files below that. The value of that variable can + be set using ‘D -- DIRECTORY RET g’. + + -- Function: magit-insert-unpulled-or-recent-commits + Insert section showing unpulled or recent commits. If an upstream + is configured for the current branch and it is ahead of the current + branch, then show the missing commits. Otherwise, show the last + ‘magit-log-section-commit-count’ commits. + + -- Function: magit-insert-recent-commits + Insert section showing the last ‘magit-log-section-commit-count’ + commits. + + -- User Option: magit-log-section-commit-count + How many recent commits ‘magit-insert-recent-commits’ and + ‘magit-insert-unpulled-or-recent-commits’ (provided there are no + unpulled commits) show. + + -- Function: magit-insert-unpulled-cherries + Insert section showing unpulled commits. Like + ‘magit-insert-unpulled-commits’ but prefix each commit that has not + been applied yet (i.e., a commit with a patch-id not shared with + any local commit) with "+", and all others with "-". + + -- Function: magit-insert-unpushed-cherries + Insert section showing unpushed commits. Like + ‘magit-insert-unpushed-commits’ but prefix each commit which has + not been applied to upstream yet (i.e., a commit with a patch-id + not shared with any upstream commit) with "+" and all others with + "-". + + See *note References Buffer:: for some more section inserters, which +could be used here. + + +File: magit.info, Node: Status Header Sections, Next: Status Module Sections, Prev: Status Sections, Up: Status Buffer + +5.1.2 Status Header Sections +---------------------------- + +The contents of status buffers is controlled using the hook +‘magit-status-sections-hook’ (see *note Status Sections::). + + By default ‘magit-insert-status-headers’ is the first member of that +hook variable. + + -- Function: magit-insert-status-headers + Insert headers sections appropriate for ‘magit-status-mode’ + buffers. The sections are inserted by running the functions on the + hook ‘magit-status-headers-hook’. + + -- User Option: magit-status-headers-hook + Hook run to insert headers sections into the status buffer. + + This hook is run by ‘magit-insert-status-headers’, which in turn + has to be a member of ‘magit-status-sections-hook’ to be used at + all. + + By default the following functions are members of the above hook: + + -- Function: magit-insert-error-header + Insert a header line showing the message about the Git error that + just occurred. + + This function is only aware of the last error that occur when Git + was run for side-effects. If, for example, an error occurs while + generating a diff, then that error won’t be inserted. Refreshing + the status buffer causes this section to disappear again. + + -- Function: magit-insert-diff-filter-header + Insert a header line showing the effective diff filters. + + -- Function: magit-insert-head-branch-header + Insert a header line about the current branch or detached ‘HEAD’. + + -- Function: magit-insert-upstream-branch-header + Insert a header line about the branch that is usually pulled into + the current branch. + + -- Function: magit-insert-push-branch-header + Insert a header line about the branch that the current branch is + usually pushed to. + + -- Function: magit-insert-tags-header + Insert a header line about the current and/or next tag, along with + the number of commits between the tag and ‘HEAD’. + + The following functions can also be added to the above hook: + + -- Function: magit-insert-repo-header + Insert a header line showing the path to the repository top-level. + + -- Function: magit-insert-remote-header + Insert a header line about the remote of the current branch. + + If no remote is configured for the current branch, then fall back + showing the "origin" remote, or if that does not exist the first + remote in alphabetic order. + + -- Function: magit-insert-user-header + Insert a header line about the current user. + + +File: magit.info, Node: Status Module Sections, Next: Status Options, Prev: Status Header Sections, Up: Status Buffer + +5.1.3 Status Module Sections +---------------------------- + +The contents of status buffers is controlled using the hook +‘magit-status-sections-hook’ (see *note Status Sections::). + + By default ‘magit-insert-modules’ is _not_ a member of that hook +variable. + + -- Function: magit-insert-modules + Insert submodule sections. + + Hook ‘magit-module-sections-hook’ controls which module sections + are inserted, and option ‘magit-module-sections-nested’ controls + whether they are wrapped in an additional section. + + -- User Option: magit-module-sections-hook + Hook run by ‘magit-insert-modules’. + + -- User Option: magit-module-sections-nested + This option controls whether ‘magit-insert-modules’ wraps inserted + sections in an additional section. + + If this is non-nil, then only a single top-level section is + inserted. If it is nil, then all sections listed in + ‘magit-module-sections-hook’ become top-level sections. + + -- Function: magit-insert-modules-overview + Insert sections for all submodules. For each section insert the + path, the branch, and the output of ‘git describe --tags’, or, + failing that, the abbreviated HEAD commit hash. + + Press ‘RET’ on such a submodule section to show its own status + buffer. Press ‘RET’ on the "Modules" section to display a list of + submodules in a separate buffer. This shows additional information + not displayed in the super-repository’s status buffer. + + -- Function: magit-insert-modules-unpulled-from-upstream + Insert sections for modules that haven’t been pulled from the + upstream yet. These sections can be expanded to show the + respective commits. + + -- Function: magit-insert-modules-unpulled-from-pushremote + Insert sections for modules that haven’t been pulled from the + push-remote yet. These sections can be expanded to show the + respective commits. + + -- Function: magit-insert-modules-unpushed-to-upstream + Insert sections for modules that haven’t been pushed to the + upstream yet. These sections can be expanded to show the + respective commits. + + -- Function: magit-insert-modules-unpushed-to-pushremote + Insert sections for modules that haven’t been pushed to the + push-remote yet. These sections can be expanded to show the + respective commits. + + +File: magit.info, Node: Status Options, Prev: Status Module Sections, Up: Status Buffer + +5.1.4 Status Options +-------------------- + + -- User Option: magit-status-margin + This option specifies whether the margin is initially shown in + Magit-Status mode buffers and how it is formatted. + + The value has the form ‘(INIT STYLE WIDTH AUTHOR AUTHOR-WIDTH)’. + + • If INIT is non-nil, then the margin is shown initially. + • STYLE controls how to format the author or committer date. It + can be one of ‘age’ (to show the age of the commit), + ‘age-abbreviated’ (to abbreviate the time unit to a + character), or a string (suitable for ‘format-time-string’) to + show the actual date. Option + ‘magit-log-margin-show-committer-date’ controls which date is + being displayed. + • WIDTH controls the width of the margin. This exists for + forward compatibility and currently the value should not be + changed. + • AUTHOR controls whether the name of the author is also shown + by default. + • AUTHOR-WIDTH has to be an integer. When the name of the + author is shown, then this specifies how much space is used to + do so. + + Also see the proceeding section for more options concerning status +buffers. + + +File: magit.info, Node: Repository List, Next: Logging, Prev: Status Buffer, Up: Inspecting + +5.2 Repository List +=================== + + -- Command: magit-list-repositories + This command displays a list of repositories in a separate buffer. + + The option ‘magit-repository-directories’ controls which + repositories are displayed. + + -- User Option: magit-repolist-columns + This option controls what columns are displayed by the command + ‘magit-list-repositories’ and how they are displayed. + + Each element has the form ‘(HEADER WIDTH FORMAT PROPS)’. + + HEADER is the string displayed in the header. WIDTH is the width + of the column. FORMAT is a function that is called with one + argument, the repository identification (usually its basename), and + with ‘default-directory’ bound to the toplevel of its working tree. + It has to return a string to be inserted or nil. PROPS is an alist + that supports the keys ‘:right-align’, ‘:pad-right’ and ‘:sort’. + + The ‘:sort’ function has a weird interface described in the + docstring of ‘tabulated-list--get-sort’. Alternatively ‘<’ and + ‘magit-repolist-version<’ can be used as those functions are + automatically replaced with functions that satisfy the interface. + Set ‘:sort’ to ‘nil’ to inhibit sorting; if unspecified, then the + column is sortable using the default sorter. + + You may wish to display a range of numeric columns using just one + character per column and without any padding between columns, in + which case you should use an appropriate HEADER, set WIDTH to 1, + and set ‘:pad-right’ to 9. ‘+’ is substituted for numbers higher + than 9. + +The following functions can be added to the above option: + + -- Function: magit-repolist-column-ident + This function inserts the identification of the repository. + Usually this is just its basename. + + -- Function: magit-repolist-column-path + This function inserts the absolute path of the repository. + + -- Function: magit-repolist-column-version + This function inserts a description of the repository’s ‘HEAD’ + revision. + + -- Function: magit-repolist-column-branch + This function inserts the name of the current branch. + + -- Function: magit-repolist-column-upstream + This function inserts the name of the upstream branch of the + current branch. + + -- Function: magit-repolist-column-branches + This function inserts the number of branches. + + -- Function: magit-repolist-column-stashes + This function inserts the number of stashes. + + -- Function: magit-repolist-column-flag + This function inserts a flag as specified by + ‘magit-repolist-column-flag-alist’. + + By default this indicates whether there are uncommitted changes. + + • ‘N’ if there is at least one untracked file. + • ‘U’ if there is at least one unstaged file. + • ‘S’ if there is at least one staged file. + + Only the first one of these that applies is shown. + + -- Function: magit-repolist-column-flags + This functions insert all flags as specified by + ‘magit-repolist-column-flag-alist’. + + This is an alternative to function ‘magit-repolist-column-flag’, + which only lists the first one found. + + -- Function: magit-repolist-column-unpulled-from-upstream + This function inserts the number of upstream commits not in the + current branch. + + -- Function: magit-repolist-column-unpulled-from-pushremote + This function inserts the number of commits in the push branch but + not the current branch. + + -- Function: magit-repolist-column-unpushed-to-upstream + This function inserts the number of commits in the current branch + but not its upstream. + + -- Function: magit-repolist-column-unpushed-to-pushremote + This function inserts the number of commits in the current branch + but not its push branch. + +The following commands are available in repolist buffers: + +‘<RET>’ (‘magit-repolist-status’) + This command shows the status for the repository at point. + +‘m’ (‘magit-repolist-mark’) + This command marks the repository at point. + +‘u’ (‘magit-repolist-unmark’) + This command unmarks the repository at point. + +‘f’ (‘magit-repolist-fetch’) + This command fetches all marked repositories. If no repositories + are marked, then it offers to fetch all displayed repositories. + +‘5’ (‘magit-repolist-find-file-other-frame’) + This command reads a relative file-name (without completion) and + opens the respective file in each marked repository in a new frame. + If no repositories are marked, then it offers to do this for all + displayed repositories. + + +File: magit.info, Node: Logging, Next: Diffing, Prev: Repository List, Up: Inspecting + +5.3 Logging +=========== + +The status buffer contains logs for the unpushed and unpulled commits, +but that obviously isn’t enough. The transient prefix command +‘magit-log’, on ‘l’, features several suffix commands, which show a +specific log in a separate log buffer. + + Like other transient prefix commands, ‘magit-log’ also features +several infix arguments that can be changed before invoking one of the +suffix commands. However, in the case of the log transient, these +arguments may be taken from those currently in use in the current +repository’s log buffer, depending on the value of +‘magit-prefix-use-buffer-arguments’ (see *note Transient Arguments and +Buffer Variables::). + + For information about the various arguments, see *note +(gitman)git-log::. + + The switch ‘++order=VALUE’ is converted to one of +‘--author-date-order’, ‘--date-order’, or ‘--topo-order’ before being +passed to ‘git log’. + + The log transient also features several reflog commands. See *note +Reflog::. + +‘l’ (‘magit-log’) + This transient prefix command binds the following suffix commands + along with the appropriate infix arguments and displays them in a + temporary buffer until a suffix is invoked. + +‘l l’ (‘magit-log-current’) + Show log for the current branch. When ‘HEAD’ is detached or with a + prefix argument, show log for one or more revs read from the + minibuffer. + +‘l h’ (‘magit-log-head’) + Show log for ‘HEAD’. + +‘l u’ (‘magit-log-related’) + Show log for the current branch, its upstream and its push target. + When the upstream is a local branch, then also show its own + upstream. When ‘HEAD’ is detached, then show log for that, the + previously checked out branch and its upstream and push-target. + +‘l o’ (‘magit-log-other’) + Show log for one or more revs read from the minibuffer. The user + can input any revision or revisions separated by a space, or even + ranges, but only branches, tags, and a representation of the commit + at point are available as completion candidates. + +‘l L’ (‘magit-log-branches’) + Show log for all local branches and ‘HEAD’. + +‘l b’ (‘magit-log-all-branches’) + Show log for all local and remote branches and ‘HEAD’. + +‘l a’ (‘magit-log-all’) + Show log for all references and ‘HEAD’. + + Two additional commands that show the log for the file or blob that +is being visited in the current buffer exists, see *note Commands for +Buffers Visiting Files::. The command ‘magit-cherry’ also shows a log, +see *note Cherries::. + +* Menu: + +* Refreshing Logs:: +* Log Buffer:: +* Log Margin:: +* Select from Log:: +* Reflog:: +* Cherries:: + + +File: magit.info, Node: Refreshing Logs, Next: Log Buffer, Up: Logging + +5.3.1 Refreshing Logs +--------------------- + +The transient prefix command ‘magit-log-refresh’, on ‘L’, can be used to +change the log arguments used in the current buffer, without changing +which log is shown. This works in dedicated log buffers, but also in +the status buffer. + +‘L’ (‘magit-log-refresh’) + This transient prefix command binds the following suffix commands + along with the appropriate infix arguments and displays them in a + temporary buffer until a suffix is invoked. + +‘L g’ (‘magit-log-refresh’) + This suffix command sets the local log arguments for the current + buffer. + +‘L s’ (‘magit-log-set-default-arguments’) + This suffix command sets the default log arguments for buffers of + the same type as that of the current buffer. Other existing + buffers of the same type are not affected because their local + values have already been initialized. + +‘L w’ (‘magit-log-save-default-arguments’) + This suffix command sets the default log arguments for buffers of + the same type as that of the current buffer, and saves the value + for future sessions. Other existing buffers of the same type are + not affected because their local values have already been + initialized. + +‘L L’ (‘magit-toggle-margin’) + Show or hide the margin. + + +File: magit.info, Node: Log Buffer, Next: Log Margin, Prev: Refreshing Logs, Up: Logging + +5.3.2 Log Buffer +---------------- + +‘L’ (‘magit-log-refresh’) + This transient prefix command binds the following suffix commands + along with the appropriate infix arguments and displays them in a + temporary buffer until a suffix is invoked. + + See *note Refreshing Logs::. + +‘q’ (‘magit-log-bury-buffer’) + Bury the current buffer or the revision buffer in the same frame. + Like ‘magit-mode-bury-buffer’ (which see) but with a negative + prefix argument instead bury the revision buffer, provided it is + displayed in the current frame. + +‘C-c C-b’ (‘magit-go-backward’) + Move backward in current buffer’s history. + +‘C-c C-f’ (‘magit-go-forward’) + Move forward in current buffer’s history. + +‘C-c C-n’ (‘magit-log-move-to-parent’) + Move to a parent of the current commit. By default, this is the + first parent, but a numeric prefix can be used to specify another + parent. + +‘j’ (‘magit-log-move-to-revision’) + Read a revision and move to it in current log buffer. + + If the chosen reference or revision isn’t being displayed in the + current log buffer, then inform the user about that and do nothing + else. + + If invoked outside any log buffer, then display the log buffer of + the current repository first; creating it if necessary. + +‘<SPC>’ (‘magit-diff-show-or-scroll-up’) + Update the commit or diff buffer for the thing at point. + + Either show the commit or stash at point in the appropriate buffer, + or if that buffer is already being displayed in the current frame + and contains information about that commit or stash, then instead + scroll the buffer up. If there is no commit or stash at point, + then prompt for a commit. + +‘<DEL>’ (‘magit-diff-show-or-scroll-down’) + Update the commit or diff buffer for the thing at point. + + Either show the commit or stash at point in the appropriate buffer, + or if that buffer is already being displayed in the current frame + and contains information about that commit or stash, then instead + scroll the buffer down. If there is no commit or stash at point, + then prompt for a commit. + +‘=’ (‘magit-log-toggle-commit-limit’) + Toggle the number of commits the current log buffer is limited to. + If the number of commits is currently limited, then remove that + limit. Otherwise set it to 256. + +‘+’ (‘magit-log-double-commit-limit’) + Double the number of commits the current log buffer is limited to. + +‘-’ (‘magit-log-half-commit-limit’) + Half the number of commits the current log buffer is limited to. + + -- User Option: magit-log-auto-more + Insert more log entries automatically when moving past the last + entry. Only considered when moving past the last entry with + ‘magit-goto-*-section’ commands. + + -- User Option: magit-log-show-refname-after-summary + Whether to show the refnames after the commit summaries. This is + useful if you use really long branch names. + + -- User Option: magit-log-show-color-graph-limit + When showing more commits than specified by this option, then the + ‘--color’ argument, if specified, is silently dropped. This is + necessary because the ‘ansi-color’ library, which is used to turn + control sequences into faces, is just too slow. + + -- User Option: magit-log-show-signatures-limit + When showing more commits than specified by this option, then the + ‘--show-signature’ argument, if specified, is silently dropped. + This is necessary because checking the signature of a large number + of commits is just too slow. + + Magit displays references in logs a bit differently from how Git does +it. + + Local branches are blue and remote branches are green. Of course +that depends on the used theme, as do the colors used for other types of +references. The current branch has a box around it, as do remote +branches that are their respective remote’s ‘HEAD’ branch. + + If a local branch and its push-target point at the same commit, then +their names are combined to preserve space and to make that relationship +visible. For example: + + origin/feature + [green][blue-] + + instead of + + feature origin/feature + [blue-] [green-------] + + Also note that while the transient features the ‘--show-signature’ +argument, that won’t actually be used when enabled, because Magit +defaults to use just one line per commit. Instead the commit colorized +to indicate the validity of the signed commit object, using the faces +named ‘magit-signature-*’ (which see). + + For a description of ‘magit-log-margin’ see *note Log Margin::. + + +File: magit.info, Node: Log Margin, Next: Select from Log, Prev: Log Buffer, Up: Logging + +5.3.3 Log Margin +---------------- + +In buffers which show one or more logs, it is possible to show +additional information about each commit in the margin. The options +used to configure the margin are named ‘magit-INFIX-margin’, where INFIX +is the same as in the respective major-mode ‘magit-INFIX-mode’. In +regular log buffers that would be ‘magit-log-margin’. + + -- User Option: magit-log-margin + This option specifies whether the margin is initially shown in + Magit-Log mode buffers and how it is formatted. + + The value has the form ‘(INIT STYLE WIDTH AUTHOR AUTHOR-WIDTH)’. + + • If INIT is non-nil, then the margin is shown initially. + • STYLE controls how to format the author or committer date. It + can be one of ‘age’ (to show the age of the commit), + ‘age-abbreviated’ (to abbreviate the time unit to a + character), or a string (suitable for ‘format-time-string’) to + show the actual date. Option + ‘magit-log-margin-show-committer-date’ controls which date is + being displayed. + • WIDTH controls the width of the margin. This exists for + forward compatibility and currently the value should not be + changed. + • AUTHOR controls whether the name of the author is also shown + by default. + • AUTHOR-WIDTH has to be an integer. When the name of the + author is shown, then this specifies how much space is used to + do so. + + You can change the STYLE and AUTHOR-WIDTH of all ‘magit-INFIX-margin’ +options to the same values by customizing ‘magit-log-margin’ *before* +‘magit’ is loaded. If you do that, then the respective values for the +other options will default to what you have set for that variable. +Likewise if you set INIT in ‘magit-log-margin’ to ‘nil’, then that is +used in the default of all other options. But setting it to ‘t’, i.e. +re-enforcing the default for that option, does not carry to other +options. + + -- User Option: magit-log-margin-show-committer-date + This option specifies whether to show the committer date in the + margin. This option only controls whether the committer date is + displayed instead of the author date. Whether some date is + displayed in the margin and whether the margin is displayed at all + is controlled by other options. + +‘L’ (‘magit-margin-settings’) + This transient prefix command binds the following suffix commands, + each of which changes the appearance of the margin in some way. + + In some buffers that support the margin, ‘L’ is instead bound to +‘magit-log-refresh’, but that transient features the same commands, and +then some other unrelated commands. + +‘L L’ (‘magit-toggle-margin’) + This command shows or hides the margin. + +‘L l’ (‘magit-cycle-margin-style’) + This command cycles the style used for the margin. + +‘L d’ (‘magit-toggle-margin-details’) + This command shows or hides details in the margin. + + +File: magit.info, Node: Select from Log, Next: Reflog, Prev: Log Margin, Up: Logging + +5.3.4 Select from Log +--------------------- + +When the user has to select a recent commit that is reachable from +‘HEAD’, using regular completion would be inconvenient (because most +humans cannot remember hashes or "HEAD~5", at least not without double +checking). Instead a log buffer is used to select the commit, which has +the advantage that commits are presented in order and with the commit +message. + + Such selection logs are used when selecting the beginning of a rebase +and when selecting the commit to be squashed into. + + In addition to the key bindings available in all log buffers, the +following additional key bindings are available in selection log +buffers: + +‘C-c C-c’ (‘magit-log-select-pick’) + Select the commit at point and act on it. Call + ‘magit-log-select-pick-function’ with the selected commit as + argument. + +‘C-c C-k’ (‘magit-log-select-quit’) + Abort selecting a commit, don’t act on any commit. + + -- User Option: magit-log-select-margin + This option specifies whether the margin is initially shown in + Magit-Log-Select mode buffers and how it is formatted. + + The value has the form ‘(INIT STYLE WIDTH AUTHOR AUTHOR-WIDTH)’. + + • If INIT is non-nil, then the margin is shown initially. + • STYLE controls how to format the author or committer date. It + can be one of ‘age’ (to show the age of the commit), + ‘age-abbreviated’ (to abbreviate the time unit to a + character), or a string (suitable for ‘format-time-string’) to + show the actual date. Option + ‘magit-log-margin-show-committer-date’ controls which date is + being displayed. + • WIDTH controls the width of the margin. This exists for + forward compatibility and currently the value should not be + changed. + • AUTHOR controls whether the name of the author is also shown + by default. + • AUTHOR-WIDTH has to be an integer. When the name of the + author is shown, then this specifies how much space is used to + do so. + + +File: magit.info, Node: Reflog, Next: Cherries, Prev: Select from Log, Up: Logging + +5.3.5 Reflog +------------ + +Also see *note (gitman)git-reflog::. + + These reflog commands are available from the log transient. See +*note Logging::. + +‘l r’ (‘magit-reflog-current’) + Display the reflog of the current branch. + +‘l O’ (‘magit-reflog-other’) + Display the reflog of a branch or another ref. + +‘l H’ (‘magit-reflog-head’) + Display the ‘HEAD’ reflog. + + -- User Option: magit-reflog-margin + This option specifies whether the margin is initially shown in + Magit-Reflog mode buffers and how it is formatted. + + The value has the form ‘(INIT STYLE WIDTH AUTHOR AUTHOR-WIDTH)’. + + • If INIT is non-nil, then the margin is shown initially. + • STYLE controls how to format the author or committer date. It + can be one of ‘age’ (to show the age of the commit), + ‘age-abbreviated’ (to abbreviate the time unit to a + character), or a string (suitable for ‘format-time-string’) to + show the actual date. Option + ‘magit-log-margin-show-committer-date’ controls which date is + being displayed. + • WIDTH controls the width of the margin. This exists for + forward compatibility and currently the value should not be + changed. + • AUTHOR controls whether the name of the author is also shown + by default. + • AUTHOR-WIDTH has to be an integer. When the name of the + author is shown, then this specifies how much space is used to + do so. + + +File: magit.info, Node: Cherries, Prev: Reflog, Up: Logging + +5.3.6 Cherries +-------------- + +Cherries are commits that haven’t been applied upstream (yet), and are +usually visualized using a log. Each commit is prefixed with ‘-’ if it +has an equivalent in the upstream and ‘+’ if it does not, i.e., if it is +a cherry. + + The command ‘magit-cherry’ shows cherries for a single branch, but +the references buffer (see *note References Buffer::) can show cherries +for multiple "upstreams" at once. + + Also see *note (gitman)git-reflog::. + +‘Y’ (‘magit-cherry’) + Show commits that are in a certain branch but that have not been + merged in the upstream branch. + + -- User Option: magit-cherry-margin + This option specifies whether the margin is initially shown in + Magit-Cherry mode buffers and how it is formatted. + + The value has the form ‘(INIT STYLE WIDTH AUTHOR AUTHOR-WIDTH)’. + + • If INIT is non-nil, then the margin is shown initially. + • STYLE controls how to format the author or committer date. It + can be one of ‘age’ (to show the age of the commit), + ‘age-abbreviated’ (to abbreviate the time unit to a + character), or a string (suitable for ‘format-time-string’) to + show the actual date. Option + ‘magit-log-margin-show-committer-date’ controls which date is + being displayed. + • WIDTH controls the width of the margin. This exists for + forward compatibility and currently the value should not be + changed. + • AUTHOR controls whether the name of the author is also shown + by default. + • AUTHOR-WIDTH has to be an integer. When the name of the + author is shown, then this specifies how much space is used to + do so. + + +File: magit.info, Node: Diffing, Next: Ediffing, Prev: Logging, Up: Inspecting + +5.4 Diffing +=========== + +The status buffer contains diffs for the staged and unstaged commits, +but that obviously isn’t enough. The transient prefix command +‘magit-diff’, on ‘d’, features several suffix commands, which show a +specific diff in a separate diff buffer. + + Like other transient prefix commands, ‘magit-diff’ also features +several infix arguments that can be changed before invoking one of the +suffix commands. However, in the case of the diff transient, these +arguments may be taken from those currently in use in the current +repository’s diff buffer, depending on the value of +‘magit-prefix-use-buffer-arguments’ (see *note Transient Arguments and +Buffer Variables::). + + Also see *note (gitman)git-diff::. + +‘d’ (‘magit-diff’) + This transient prefix command binds the following suffix commands + along with the appropriate infix arguments and displays them in a + temporary buffer until a suffix is invoked. + +‘d d’ (‘magit-diff-dwim’) + Show changes for the thing at point. + +‘d r’ (‘magit-diff-range’) + Show differences between two commits. + + RANGE should be a range (A..B or A...B) but can also be a single + commit. If one side of the range is omitted, then it defaults to + ‘HEAD’. If just a commit is given, then changes in the working + tree relative to that commit are shown. + + If the region is active, use the revisions on the first and last + line of the region. With a prefix argument, instead of diffing the + revisions, choose a revision to view changes along, starting at the + common ancestor of both revisions (i.e., use a "..." range). + +‘d w’ (‘magit-diff-working-tree’) + Show changes between the current working tree and the ‘HEAD’ + commit. With a prefix argument show changes between the working + tree and a commit read from the minibuffer. + +‘d s’ (‘magit-diff-staged’) + Show changes between the index and the ‘HEAD’ commit. With a + prefix argument show changes between the index and a commit read + from the minibuffer. + +‘d u’ (‘magit-diff-unstaged’) + Show changes between the working tree and the index. + +‘d p’ (‘magit-diff-paths’) + Show changes between any two files on disk. + + All of the above suffix commands update the repository’s diff buffer. +The diff transient also features two commands which show differences in +another buffer: + +‘d c’ (‘magit-show-commit’) + Show the commit at point. If there is no commit at point or with a + prefix argument, prompt for a commit. + +‘d t’ (‘magit-stash-show’) + Show all diffs of a stash in a buffer. + + Two additional commands that show the diff for the file or blob that +is being visited in the current buffer exists, see *note Commands for +Buffers Visiting Files::. + +* Menu: + +* Refreshing Diffs:: +* Commands Available in Diffs:: +* Diff Options:: +* Revision Buffer:: + + +File: magit.info, Node: Refreshing Diffs, Next: Commands Available in Diffs, Up: Diffing + +5.4.1 Refreshing Diffs +---------------------- + +The transient prefix command ‘magit-diff-refresh’, on ‘D’, can be used +to change the diff arguments used in the current buffer, without +changing which diff is shown. This works in dedicated diff buffers, but +also in the status buffer. + + (There is one exception; diff arguments cannot be changed in buffers +created by ‘magit-merge-preview’ because the underlying Git command does +not support these arguments.) + +‘D’ (‘magit-diff-refresh’) + This transient prefix command binds the following suffix commands + along with the appropriate infix arguments and displays them in a + temporary buffer until a suffix is invoked. + +‘D g’ (‘magit-diff-refresh’) + This suffix command sets the local diff arguments for the current + buffer. + +‘D s’ (‘magit-diff-set-default-arguments’) + This suffix command sets the default diff arguments for buffers of + the same type as that of the current buffer. Other existing + buffers of the same type are not affected because their local + values have already been initialized. + +‘D w’ (‘magit-diff-save-default-arguments’) + This suffix command sets the default diff arguments for buffers of + the same type as that of the current buffer, and saves the value + for future sessions. Other existing buffers of the same type are + not affected because their local values have already been + initialized. + +‘D t’ (‘magit-diff-toggle-refine-hunk’) + This command toggles hunk refinement on or off. + +‘D r’ (‘magit-diff-switch-range-type’) + This command converts the diff range type from "revA..revB" to + "revB...revA", or vice versa. + +‘D f’ (‘magit-diff-flip-revs’) + This command swaps revisions in the diff range from "revA..revB" to + "revB..revA", or vice versa. + +‘D F’ (‘magit-diff-toggle-file-filter’) + This command toggles the file restriction of the diffs in the + current buffer, allowing you to quickly switch between viewing all + the changes in the commit and the restricted subset. As a special + case, when this command is called from a log buffer, it toggles the + file restriction in the repository’s revision buffer, which is + useful when you display a revision from a log buffer that is + restricted to a file or files. + + In addition to the above transient, which allows changing any of the +supported arguments, there also exist some commands that change only a +particular argument. + +‘-’ (‘magit-diff-less-context’) + This command decreases the context for diff hunks by COUNT lines. + +‘+’ (‘magit-diff-more-context’) + This command increases the context for diff hunks by COUNT lines. + +‘0’ (‘magit-diff-default-context’) + This command resets the context for diff hunks to the default + height. + + The following commands quickly change what diff is being displayed +without having to using one of the diff transient. + +‘C-c C-d’ (‘magit-diff-while-committing’) + While committing, this command shows the changes that are about to + be committed. While amending, invoking the command again toggles + between showing just the new changes or all the changes that will + be committed. + + This binding is available in the diff buffer as well as the commit + message buffer. + +‘C-c C-b’ (‘magit-go-backward’) + This command moves backward in current buffer’s history. + +‘C-c C-f’ (‘magit-go-forward’) + This command moves forward in current buffer’s history. + + +File: magit.info, Node: Commands Available in Diffs, Next: Diff Options, Prev: Refreshing Diffs, Up: Diffing + +5.4.2 Commands Available in Diffs +--------------------------------- + +Some commands are only available if point is inside a diff. + + ‘magit-diff-visit-file’ and related commands visit the appropriate +version of the file that the diff at point is about. Likewise +‘magit-diff-visit-worktree-file’ and related commands visit the worktree +version of the file that the diff at point is about. See *note Visiting +Files and Blobs from a Diff:: for more information and the key bindings. + +‘C-c C-t’ (‘magit-diff-trace-definition’) + This command shows a log for the definition at point. + + -- User Option: magit-log-trace-definition-function + The function specified by this option is used by + ‘magit-log-trace-definition’ to determine the function at point. + For major-modes that have special needs, you could set the local + value using the mode’s hook. + +‘C-c C-e’ (‘magit-diff-edit-hunk-commit’) + From a hunk, this command edits the respective commit and visits + the file. + + First it visits the file being modified by the hunk at the correct + location using ‘magit-diff-visit-file’. This actually visits a + blob. When point is on a diff header, not within an individual + hunk, then this visits the blob the first hunk is about. + + Then it invokes ‘magit-edit-line-commit’, which uses an interactive + rebase to make the commit editable, or if that is not possible + because the commit is not reachable from ‘HEAD’ by checking out + that commit directly. This also causes the actual worktree file to + be visited. + + Neither the blob nor the file buffer are killed when finishing the + rebase. If that is undesirable, then it might be better to use + ‘magit-rebase-edit-commit’ instead of this command. + +‘j’ (‘magit-jump-to-diffstat-or-diff’) + This command jumps to the diffstat or diff. When point is on a + file inside the diffstat section, then jump to the respective diff + section. Otherwise, jump to the diffstat section or a child + thereof. + + The next two commands are not specific to Magit-Diff mode (or and +Magit buffer for that matter), but it might be worth pointing out that +they are available here too. + +‘<SPC>’ (‘scroll-up’) + This command scrolls text upward. + +‘<DEL>’ (‘scroll-down’) + This command scrolls text downward. + + +File: magit.info, Node: Diff Options, Next: Revision Buffer, Prev: Commands Available in Diffs, Up: Diffing + +5.4.3 Diff Options +------------------ + + -- User Option: magit-diff-refine-hunk + Whether to show word-granularity differences within diff hunks. + + • ‘nil’ Never show fine differences. + • ‘t’ Show fine differences for the current diff hunk only. + • ‘all’ Show fine differences for all displayed diff hunks. + + -- User Option: magit-diff-refine-ignore-whitespace + Whether to ignore whitespace changes in word-granularity + differences. + + -- User Option: magit-diff-adjust-tab-width + Whether to adjust the width of tabs in diffs. + + Determining the correct width can be expensive if it requires + opening large and/or many files, so the widths are cached in the + variable ‘magit-diff--tab-width-cache’. Set that to nil to + invalidate the cache. + + • ‘nil’ Never adjust tab width. Use ‘tab-width’s value from the + Magit buffer itself instead. + + • ‘t’ If the corresponding file-visiting buffer exits, then use + ‘tab-width’’s value from that buffer. Doing this is cheap, so + this value is used even if a corresponding cache entry exists. + + • ‘always’ If there is no such buffer, then temporarily visit + the file to determine the value. + + • NUMBER Like ‘always’, but don’t visit files larger than NUMBER + bytes. + + -- User Option: magit-diff-paint-whitespace + Specify where to highlight whitespace errors. + + See ‘magit-diff-highlight-trailing’, + ‘magit-diff-highlight-indentation’. The symbol ‘t’ means in all + diffs, ‘status’ means only in the status buffer, and nil means + nowhere. + + • ‘nil’ Never highlight whitespace errors. + • ‘t’ Highlight whitespace errors everywhere. + • ‘uncommitted’ Only highlight whitespace errors in diffs + showing uncommitted changes. For backward compatibility + ‘status’ is treated as a synonym. + + -- User Option: magit-diff-paint-whitespace-lines + Specify in what kind of lines to highlight whitespace errors. + + • ‘t’ Highlight only in added lines. + • ‘both’ Highlight in added and removed lines. + • ‘all’ Highlight in added, removed and context lines. + + -- User Option: magit-diff-highlight-trailing + Whether to highlight whitespace at the end of a line in diffs. + Used only when ‘magit-diff-paint-whitespace’ is non-nil. + + -- User Option: magit-diff-highlight-indentation + This option controls whether to highlight the indentation in case + it used the "wrong" indentation style. Indentation is only + highlighted if ‘magit-diff-paint-whitespace’ is also non-nil. + + The value is an alist of the form ‘((REGEXP . INDENT)...)’. The + path to the current repository is matched against each element in + reverse order. Therefore if a REGEXP matches, then earlier + elements are not tried. + + If the used INDENT is ‘tabs’, highlight indentation with tabs. If + INDENT is an integer, highlight indentation with at least that many + spaces. Otherwise, highlight neither. + + -- User Option: magit-diff-hide-trailing-cr-characters + Whether to hide ^M characters at the end of a line in diffs. + + -- User Option: magit-diff-highlight-hunk-region-functions + This option specifies the functions used to highlight the + hunk-internal region. + + ‘magit-diff-highlight-hunk-region-dim-outside’ overlays the outside + of the hunk internal selection with a face that causes the added + and removed lines to have the same background color as context + lines. This function should not be removed from the value of this + option. + + ‘magit-diff-highlight-hunk-region-using-overlays’ and + ‘magit-diff-highlight-hunk-region-using-underline’ emphasize the + region by placing delimiting horizontal lines before and after it. + Both of these functions have glitches which cannot be fixed due to + limitations of Emacs’ display engine. For more information see + <https://github.com/magit/magit/issues/2758> ff. + + Instead of, or in addition to, using delimiting horizontal lines, + to emphasize the boundaries, you may wish to emphasize the text + itself, using ‘magit-diff-highlight-hunk-region-using-face’. + + In terminal frames it’s not possible to draw lines as the overlay + and underline variants normally do, so there they fall back to + calling the face function instead. + + -- User Option: magit-diff-unmarked-lines-keep-foreground + This option controls whether added and removed lines outside the + hunk-internal region only lose their distinct background color or + also the foreground color. Whether the outside of the region is + dimmed at all depends on + ‘magit-diff-highlight-hunk-region-functions’. + + -- User Option: magit-diff-extra-stat-arguments + This option specifies additional arguments to be used alongside + ‘--stat’. + + The value is a list of zero or more arguments or a function that + takes no argument and returns such a list. These arguments are + allowed here: ‘--stat-width’, ‘--stat-name-width’, + ‘--stat-graph-width’ and ‘--compact-summary’. Also see *note + (gitman)git-diff::. + + +File: magit.info, Node: Revision Buffer, Prev: Diff Options, Up: Diffing + +5.4.4 Revision Buffer +--------------------- + + -- User Option: magit-revision-insert-related-refs + Whether to show related branches in revision buffers. + + • ‘nil’ Don’t show any related branches. + • ‘t’ Show related local branches. + • ‘all’ Show related local and remote branches. + • ‘mixed’ Show all containing branches and local merged + branches. + + -- User Option: magit-revision-show-gravatars + Whether to show gravatar images in revision buffers. + + If ‘nil’, then don’t insert any gravatar images. If ‘t’, then + insert both images. If ‘author’ or ‘committer’, then insert only + the respective image. + + If you have customized the option ‘magit-revision-headers-format’ + and want to insert the images then you might also have to specify + where to do so. In that case the value has to be a cons-cell of + two regular expressions. The car specifies where to insert the + author’s image. The top half of the image is inserted right after + the matched text, the bottom half on the next line in the same + column. The cdr specifies where to insert the committer’s image, + accordingly. Either the car or the cdr may be nil." + + -- User Option: magit-revision-use-hash-sections + Whether to turn hashes inside the commit message into sections. + + If non-nil, then hashes inside the commit message are turned into + ‘commit’ sections. There is a trade off to be made between + performance and reliability: + + • ‘slow’ calls git for every word to be absolutely sure. + • ‘quick’ skips words less than seven characters long. + • ‘quicker’ additionally skips words that don’t contain a + number. + • ‘quickest’ uses all words that are at least seven characters + long and which contain at least one number as well as at least + one letter. + + If nil, then no hashes are turned into sections, but you can still + visit the commit at point using "RET". + + The diffs shown in the revision buffer may be automatically +restricted to a subset of the changed files. If the revision buffer is +displayed from a log buffer, the revision buffer will share the same +file restriction as that log buffer (also see the command +‘magit-diff-toggle-file-filter’). + + -- User Option: magit-revision-filter-files-on-follow + Whether showing a commit from a log buffer honors the log’s file + filter when the log arguments include ‘--follow’. + + When this option is nil, displaying a commit from a log ignores the + log’s file filter if the log arguments include ‘--follow’. Doing + so avoids showing an empty diff in revision buffers for commits + before a rename event. In such cases, the ‘--patch’ argument of + the log transient can be used to show the file-restricted diffs + inline. + + Set this option to non-nil to keep the log’s file restriction even + if ‘--follow’ is present in the log arguments. + + If the revision buffer is not displayed from a log buffer, the file +restriction is determined as usual (see *note Transient Arguments and +Buffer Variables::). + + +File: magit.info, Node: Ediffing, Next: References Buffer, Prev: Diffing, Up: Inspecting + +5.5 Ediffing +============ + +This section describes how to enter Ediff from Magit buffers. For +information on how to use Ediff itself, see *note (ediff)Top::. + +‘e’ (‘magit-ediff-dwim’) + Compare, stage, or resolve using Ediff. + + This command tries to guess what file, and what commit or range the + user wants to compare, stage, or resolve using Ediff. It might + only be able to guess either the file, or range/commit, in which + case the user is asked about the other. It might not always guess + right, in which case the appropriate ‘magit-ediff-*’ command has to + be used explicitly. If it cannot read the user’s mind at all, then + it asks the user for a command to run. + +‘E’ (‘magit-ediff’) + This transient prefix command binds the following suffix commands + and displays them in a temporary buffer until a suffix is invoked. + +‘E r’ (‘magit-ediff-compare’) + Compare two revisions of a file using Ediff. + + If the region is active, use the revisions on the first and last + line of the region. With a prefix argument, instead of diffing the + revisions, choose a revision to view changes along, starting at the + common ancestor of both revisions (i.e., use a "..." range). + +‘E m’ (‘magit-ediff-resolve-rest’) + This command allows you to resolve outstanding conflicts in the + file at point using Ediff. If there is no file at point or if it + doesn’t have any unmerged changes, then this command prompts for a + file. + + Provided that the value of ‘merge.conflictstyle’ is ‘diff3’, you + can view the file’s merge-base revision using ‘/’ in the Ediff + control buffer. + + The A, B and Ancestor buffers are constructed from the conflict + markers in the worktree file. Because you and/or Git may have + already resolved some conflicts, that means that these buffers may + not contain the actual versions from the respective blobs. + +‘E M’ (‘magit-ediff-resolve-all’) + This command allows you to resolve all conflicts in the file at + point using Ediff. If there is no file at point or if it doesn’t + have any unmerged changes, then this command prompts for a file. + + Provided that the value of ‘merge.conflictstyle’ is ‘diff3’, you + can view the file’s merge-base revision using ‘/’ in the Ediff + control buffer. + + First the file in the worktree is moved aside, appending the suffix + ‘.ORIG’, so that you could later go back to that version. Then it + is reconstructed from the two sides of the conflict and the + merge-base, if available. + + It would be nice if the worktree file were just used as-is, but + Ediff does not support that. This means that all conflicts, that + Git has already resolved, are restored. On the other hand Ediff + also tries to resolve conflicts, and in many cases Ediff and Git + should produce similar results. + + However if you have already resolved some conflicts manually, then + those changes are discarded (though you can recover them from the + backup file). In such cases ‘magit-ediff-resolve-rest’ might be + more suitable. + + The advantage that this command has over ‘magit-ediff-resolve-rest’ + is that the A, B and Ancestor buffers correspond to blobs from the + respective commits, allowing you to inspect a side in context and + to use Magit commands in these buffers to do so. Blame and log + commands are particularly useful here. + +‘E t’ (‘magit-git-mergetool’) + This command does not actually use Ediff. While it serves the same + purpose as ‘magit-ediff-resolve-rest’, it uses ‘git mergetool + --gui’ to resolve conflicts. + + With a prefix argument this acts as a transient prefix command, + allowing the user to select the mergetool and change some settings. + +‘E s’ (‘magit-ediff-stage’) + Stage and unstage changes to a file using Ediff, defaulting to the + file at point. + +‘E u’ (‘magit-ediff-show-unstaged’) + Show unstaged changes to a file using Ediff. + +‘E i’ (‘magit-ediff-show-staged’) + Show staged changes to a file using Ediff. + +‘E w’ (‘magit-ediff-show-working-tree’) + Show changes in a file between ‘HEAD’ and working tree using Ediff. + +‘E c’ (‘magit-ediff-show-commit’) + Show changes to a file introduced by a commit using Ediff. + +‘E z’ (‘magit-ediff-show-stash’) + Show changes to a file introduced by a stash using Ediff. + + -- User Option: magit-ediff-dwim-resolve-function + This option controls which function ‘magit-ediff-dwim’ uses to + resolve conflicts. One of ‘magit-ediff-resolve-rest’, + ‘magit-ediff-resolve-all’ or ‘magit-git-mergetool’; which are all + discussed above. + + -- User Option: magit-ediff-dwim-show-on-hunks + This option controls what command ‘magit-ediff-dwim’ calls when + point is on uncommitted hunks. When nil, always run + ‘magit-ediff-stage’. Otherwise, use ‘magit-ediff-show-staged’ and + ‘magit-ediff-show-unstaged’ to show staged and unstaged changes, + respectively. + + -- User Option: magit-ediff-show-stash-with-index + This option controls whether ‘magit-ediff-show-stash’ includes a + buffer containing the file’s state in the index at the time the + stash was created. This makes it possible to tell which changes in + the stash were staged. + + -- User Option: magit-ediff-quit-hook + This hook is run after quitting an Ediff session that was created + using a Magit command. The hook functions are run inside the Ediff + control buffer, and should not change the current buffer. + + This is similar to ‘ediff-quit-hook’ but takes the needs of Magit + into account. The regular ‘ediff-quit-hook’ is ignored by Ediff + sessions that were created using a Magit command. + + +File: magit.info, Node: References Buffer, Next: Bisecting, Prev: Ediffing, Up: Inspecting + +5.6 References Buffer +===================== + +‘y’ (‘magit-show-refs’) + This command lists branches and tags in a dedicated buffer. + + However if this command is invoked again from this buffer or if it + is invoked with a prefix argument, then it acts as a transient + prefix command, which binds the following suffix commands and some + infix arguments. + + All of the following suffix commands list exactly the same branches +and tags. The only difference the optional feature that can be enabled +by changing the value of ‘magit-refs-show-commit-count’ (see below). +These commands specify a different branch or commit against which all +the other references are compared. + +‘y y’ (‘magit-show-refs-head’) + This command lists branches and tags in a dedicated buffer. Each + reference is being compared with ‘HEAD’. + +‘y c’ (‘magit-show-refs-current’) + This command lists branches and tags in a dedicated buffer. Each + reference is being compared with the current branch or ‘HEAD’ if it + is detached. + +‘y o’ (‘magit-show-refs-other’) + This command lists branches and tags in a dedicated buffer. Each + reference is being compared with a branch read from the user. + +‘y r’ (‘magit-refs-set-show-commit-count’) + This command changes for which refs the commit count is shown. + + -- User Option: magit-refs-show-commit-count + Whether to show commit counts in Magit-Refs mode buffers. + + • ‘all’ Show counts for branches and tags. + • ‘branch’ Show counts for branches only. + • ‘nil’ Never show counts. + + The default is ‘nil’ because anything else can be very expensive. + + -- User Option: magit-refs-pad-commit-counts + Whether to pad all commit counts on all sides in Magit-Refs mode + buffers. + + If this is nil, then some commit counts are displayed right next to + one of the branches that appear next to the count, without any + space in between. This might look bad if the branch name faces + look too similar to ‘magit-dimmed’. + + If this is non-nil, then spaces are placed on both sides of all + commit counts. + + -- User Option: magit-refs-show-remote-prefix + Whether to show the remote prefix in lists of remote branches. + + Showing the prefix is redundant because the name of the remote is + already shown in the heading preceding the list of its branches. + + -- User Option: magit-refs-primary-column-width + Width of the primary column in ‘magit-refs-mode’ buffers. The + primary column is the column that contains the name of the branch + that the current row is about. + + If this is an integer, then the column is that many columns wide. + Otherwise it has to be a cons-cell of two integers. The first + specifies the minimal width, the second the maximal width. In that + case the actual width is determined using the length of the names + of the shown local branches. (Remote branches and tags are not + taken into account when calculating to optimal width.) + + -- User Option: magit-refs-focus-column-width + Width of the focus column in ‘magit-refs-mode’ buffers. + + The focus column is the first column, which marks one branch + (usually the current branch) as the focused branch using ‘*’ or + ‘@’. For each other reference, this column optionally shows how + many commits it is ahead of the focused branch and ‘<’, or if it + isn’t ahead then the commits it is behind and ‘>’, or if it isn’t + behind either, then a ‘=’. + + This column may also display only ‘*’ or ‘@’ for the focused + branch, in which case this option is ignored. Use ‘L v’ to change + the verbosity of this column. + + -- User Option: magit-refs-margin + This option specifies whether the margin is initially shown in + Magit-Refs mode buffers and how it is formatted. + + The value has the form ‘(INIT STYLE WIDTH AUTHOR AUTHOR-WIDTH)’. + + • If INIT is non-nil, then the margin is shown initially. + • STYLE controls how to format the author or committer date. It + can be one of ‘age’ (to show the age of the commit), + ‘age-abbreviated’ (to abbreviate the time unit to a + character), or a string (suitable for ‘format-time-string’) to + show the actual date. Option + ‘magit-log-margin-show-committer-date’ controls which date is + being displayed. + • WIDTH controls the width of the margin. This exists for + forward compatibility and currently the value should not be + changed. + • AUTHOR controls whether the name of the author is also shown + by default. + • AUTHOR-WIDTH has to be an integer. When the name of the + author is shown, then this specifies how much space is used to + do so. + + -- User Option: magit-refs-margin-for-tags + This option specifies whether to show information about tags in the + margin. This is disabled by default because it is slow if there + are many tags. + + The following variables control how individual refs are displayed. +If you change one of these variables (especially the "%c" part), then +you should also change the others to keep things aligned. The following +%-sequences are supported: + + • ‘%a’ Number of commits this ref has over the one we compare to. + • ‘%b’ Number of commits the ref we compare to has over this one. + • ‘%c’ Number of commits this ref has over the one we compare to. + For the ref which all other refs are compared this is instead "@", + if it is the current branch, or "#" otherwise. + • ‘%C’ For the ref which all other refs are compared this is "@", if + it is the current branch, or "#" otherwise. For all other refs " + ". + • ‘%h’ Hash of this ref’s tip. + • ‘%m’ Commit summary of the tip of this ref. + • ‘%n’ Name of this ref. + • ‘%u’ Upstream of this local branch. + • ‘%U’ Upstream of this local branch and additional local vs. + upstream information. + + -- User Option: magit-refs-filter-alist + The purpose of this option is to forgo displaying certain refs + based on their name. If you want to not display any refs of a + certain type, then you should remove the appropriate function from + ‘magit-refs-sections-hook’ instead. + + This alist controls which tags and branches are omitted from being + displayed in ‘magit-refs-mode’ buffers. If it is ‘nil’, then all + refs are displayed (subject to ‘magit-refs-sections-hook’). + + All keys are tried in order until one matches. Then its value is + used and subsequent elements are ignored. If the value is non-nil, + then the reference is displayed, otherwise it is not. If no + element matches, then the reference is displayed. + + A key can either be a regular expression that the refname has to + match, or a function that takes the refname as only argument and + returns a boolean. A remote branch such as "origin/master" is + displayed as just "master", however for this comparison the former + is used. + +‘<RET>’ (‘magit-visit-ref’) + This command visits the reference or revision at point in another + buffer. If there is no revision at point or with a prefix argument + then it prompts for a revision. + + This command behaves just like ‘magit-show-commit’ as described + above, except if point is on a reference in a ‘magit-refs-mode’ + buffer, in which case the behavior may be different, but only if + you have customized the option ‘magit-visit-ref-behavior’. + + -- User Option: magit-visit-ref-behavior + This option controls how ‘magit-visit-ref’ behaves in + ‘magit-refs-mode’ buffers. + + By default ‘magit-visit-ref’ behaves like ‘magit-show-commit’, in + all buffers, including ‘magit-refs-mode’ buffers. When the type of + the section at point is ‘commit’ then "RET" is bound to + ‘magit-show-commit’, and when the type is either ‘branch’ or ‘tag’ + then it is bound to ‘magit-visit-ref’. + + "RET" is one of Magit’s most essential keys and at least by default + it should behave consistently across all of Magit, especially + because users quickly learn that it does something very harmless; + it shows more information about the thing at point in another + buffer. + + However "RET" used to behave differently in ‘magit-refs-mode’ + buffers, doing surprising things, some of which cannot really be + described as "visit this thing". If you’ve grown accustomed this + behavior, you can restore it by adding one or more of the below + symbols to the value of this option. But keep in mind that by + doing so you don’t only introduce inconsistencies, you also lose + some functionality and might have to resort to ‘M-x + magit-show-commit’ to get it back. + + ‘magit-visit-ref’ looks for these symbols in the order in which + they are described here. If the presence of a symbol applies to + the current situation, then the symbols that follow do not affect + the outcome. + + • ‘focus-on-ref’ + + With a prefix argument update the buffer to show commit counts + and lists of cherry commits relative to the reference at point + instead of relative to the current buffer or ‘HEAD’. + + Instead of adding this symbol, consider pressing "C-u y o + RET". + + • ‘create-branch’ + + If point is on a remote branch, then create a new local branch + with the same name, use the remote branch as its upstream, and + then check out the local branch. + + Instead of adding this symbol, consider pressing "b c RET + RET", like you would do in other buffers. + + • ‘checkout-any’ + + Check out the reference at point. If that reference is a tag + or a remote branch, then this results in a detached ‘HEAD’. + + Instead of adding this symbol, consider pressing "b b RET", + like you would do in other buffers. + + • ‘checkout-branch’ + + Check out the local branch at point. + + Instead of adding this symbol, consider pressing "b b RET", + like you would do in other buffers. + +* Menu: + +* References Sections:: + + +File: magit.info, Node: References Sections, Up: References Buffer + +5.6.1 References Sections +------------------------- + +The contents of references buffers is controlled using the hook +‘magit-refs-sections-hook’. See *note Section Hooks:: to learn about +such hooks and how to customize them. All of the below functions are +members of the default value. Note that it makes much less sense to +customize this hook than it does for the respective hook used for the +status buffer. + + -- User Option: magit-refs-sections-hook + Hook run to insert sections into a references buffer. + + -- Function: magit-insert-local-branches + Insert sections showing all local branches. + + -- Function: magit-insert-remote-branches + Insert sections showing all remote-tracking branches. + + -- Function: magit-insert-tags + Insert sections showing all tags. + + +File: magit.info, Node: Bisecting, Next: Visiting Files and Blobs, Prev: References Buffer, Up: Inspecting + +5.7 Bisecting +============= + +Also see *note (gitman)git-bisect::. + +‘B’ (‘magit-bisect’) + This transient prefix command binds the following suffix commands + and displays them in a temporary buffer until a suffix is invoked. + + When bisecting is not in progress, then the transient features the +following suffix commands. + +‘B B’ (‘magit-bisect-start’) + Start a bisect session. + + Bisecting a bug means to find the commit that introduced it. This + command starts such a bisect session by asking for a known good + commit and a known bad commit. If you’re bisecting a change that + isn’t a regression, you can select alternate terms that are + conceptually more fitting than "bad" and "good", but the infix + arguments to do so are disabled by default. + +‘B s’ (‘magit-bisect-run’) + Bisect automatically by running commands after each step. + + When bisecting in progress, then the transient instead features the +following suffix commands. + +‘B b’ (‘magit-bisect-bad’) + Mark the current commit as bad. Use this after you have asserted + that the commit does contain the bug in question. + +‘B g’ (‘magit-bisect-good’) + Mark the current commit as good. Use this after you have asserted + that the commit does not contain the bug in question. + +‘B m’ (‘magit-bisect-mark’) + Mark the current commit with one of the bisect terms. This command + provides an alternative to ‘magit-bisect-bad’ and + ‘magit-bisect-good’ and is useful when using terms other than "bad" + and "good". This suffix is disabled by default. + +‘B k’ (‘magit-bisect-skip’) + Skip the current commit. Use this if for some reason the current + commit is not a good one to test. This command lets Git choose a + different one. + +‘B r’ (‘magit-bisect-reset’) + After bisecting, cleanup bisection state and return to original + ‘HEAD’. + + By default the status buffer shows information about the ongoing +bisect session. + + -- User Option: magit-bisect-show-graph + This option controls whether a graph is displayed for the log of + commits that still have to be bisected. + + +File: magit.info, Node: Visiting Files and Blobs, Next: Blaming, Prev: Bisecting, Up: Inspecting + +5.8 Visiting Files and Blobs +============================ + +Magit provides several commands that visit a file or blob (the version +of a file that is stored in a certain commit). Actually it provides +several *groups* of such commands and the several *variants* within each +group. + + Also see *note Commands for Buffers Visiting Files::. + +* Menu: + +* General-Purpose Visit Commands:: +* Visiting Files and Blobs from a Diff:: + + +File: magit.info, Node: General-Purpose Visit Commands, Next: Visiting Files and Blobs from a Diff, Up: Visiting Files and Blobs + +5.8.1 General-Purpose Visit Commands +------------------------------------ + +These commands can be used anywhere to open any blob. Currently no keys +are bound to these commands by default, but that is likely to change. + + -- Command: magit-find-file + This command reads a filename and revision from the user and visits + the respective blob in a buffer. The buffer is displayed in the + selected window. + + -- Command: magit-find-file-other-window + This command reads a filename and revision from the user and visits + the respective blob in a buffer. The buffer is displayed in + another window. + + -- Command: magit-find-file-other-frame + This command reads a filename and revision from the user and visits + the respective blob in a buffer. The buffer is displayed in + another frame. + + +File: magit.info, Node: Visiting Files and Blobs from a Diff, Prev: General-Purpose Visit Commands, Up: Visiting Files and Blobs + +5.8.2 Visiting Files and Blobs from a Diff +------------------------------------------ + +These commands can only be used when point is inside a diff. + +‘<RET>’ (‘magit-diff-visit-file’) + This command visits the appropriate version of the file that the + diff at point is about. + + This commands visits the worktree version of the appropriate file. + The location of point inside the diff determines which file is + being visited. The visited version depends on what changes the + diff is about. + + 1. If the diff shows uncommitted changes (i.e., staged or + unstaged changes), then visit the file in the working tree + (i.e., the same "real" file that ‘find-file’ would visit. In + all other cases visit a "blob" (i.e., the version of a file as + stored in some commit). + + 2. If point is on a removed line, then visit the blob for the + first parent of the commit that removed that line, i.e., the + last commit where that line still exists. + + 3. If point is on an added or context line, then visit the blob + that adds that line, or if the diff shows from more than a + single commit, then visit the blob from the last of these + commits. + + In the file-visiting buffer this command goes to the line that + corresponds to the line that point is on in the diff. + + The buffer is displayed in the selected window. With a prefix + argument the buffer is displayed in another window instead. + + -- User Option: magit-diff-visit-previous-blob + This option controls whether ‘magit-diff-visit-file’ may visit the + previous blob. When this is ‘t’ (the default) and point is on a + removed line in a diff for a committed change, then + ‘magit-diff-visit-file’ visits the blob from the last revision + which still had that line. + + Currently this is only supported for committed changes, for staged + and unstaged changes ‘magit-diff-visit-file’ always visits the file + in the working tree. + +‘C-<return>’ (‘magit-diff-visit-file-worktree’) + This command visits the worktree version of the appropriate file. + The location of point inside the diff determines which file is + being visited. Unlike ‘magit-diff-visit-file’ it always visits the + "real" file in the working tree, i.e the "current version" of the + file. + + In the file-visiting buffer this command goes to the line that + corresponds to the line that point is on in the diff. Lines that + were added or removed in the working tree, the index and other + commits in between are automatically accounted for. + + The buffer is displayed in the selected window. With a prefix + argument the buffer is displayed in another window instead. + + Variants of the above two commands exist that instead visit the file +in another window or in another frame. If you prefer such behavior, +then you may want to change the above key bindings, but note that the +above commands also use another window when invoked with a prefix +argument. + + -- Command: magit-diff-visit-file-other-window + -- Command: magit-diff-visit-file-other-frame + -- Command: magit-diff-visit-worktree-file-other-window + -- Command: magit-diff-visit-worktree-file-other-frame + + +File: magit.info, Node: Blaming, Prev: Visiting Files and Blobs, Up: Inspecting + +5.9 Blaming +=========== + +Also see *note (gitman)git-blame::. + + To start blaming, invoke the ‘magit-file-dispatch’ transient prefix +command. When using the default key bindings, that can be done by +pressing ‘C-c M-g’. When using the recommended bindings, this command +is instead bound to ‘C-c f’. Also see *note Global Bindings::. + + The blaming suffix commands can be invoked directly from the file +dispatch transient. However if you want to set an infix argument, then +you have to enter the blaming sub-prefix first. + +‘C-c f B’ (‘magit-blame’) +‘C-c f b’ (‘magit-blame-addition’) +‘C-c f B b’ +‘C-c f r’ (‘magit-blame-removal’) +‘C-c f B r’ +‘C-c f f’ (‘magit-blame-reverse’) +‘C-c f B f’ +‘C-c f e’ (‘magit-blame-echo’) +‘C-c f B e’ +‘C-c f q’ (‘magit-blame-quit’) +‘C-c f B q’ + Each of these commands is documented individually right below, + alongside their default key bindings. The bindings shown above are + the recommended bindings, which you can enable by following the + instructions in *note Global Bindings::. + +‘C-c M-g B’ (‘magit-blame’) + This transient prefix command binds the following suffix commands + along with the appropriate infix arguments and displays them in a + temporary buffer until a suffix is invoked. + + Note that not all of the following suffixes are available at all +times. For example if ‘magit-blame-mode’ is not enabled, then the +command whose purpose is to turn off that mode would not be of any use +and therefore isn’t available. + +‘C-c M-g b’ (‘magit-blame-addition’) +‘C-c M-g B b’ + This command augments each line or chunk of lines in the current + file-visiting or blob-visiting buffer with information about what + commits last touched these lines. + + If the buffer visits a revision of that file, then history up to + that revision is considered. Otherwise, the file’s full history is + considered, including uncommitted changes. + + If Magit-Blame mode is already turned on in the current buffer then + blaming is done recursively, by visiting REVISION:FILE (using + ‘magit-find-file’), where REVISION is a parent of the revision that + added the current line or chunk of lines. + +‘C-c M-g r’ (‘magit-blame-removal’) +‘C-c M-g B r’ + This command augments each line or chunk of lines in the current + blob-visiting buffer with information about the revision that + removes it. It cannot be used in file-visiting buffers. + + Like ‘magit-blame-addition’, this command can be used recursively. + +‘C-c M-g f’ (‘magit-blame-reverse’) +‘C-c M-g B f’ + This command augments each line or chunk of lines in the current + file-visiting or blob-visiting buffer with information about the + last revision in which a line still existed. + + Like ‘magit-blame-addition’, this command can be used recursively. + +‘C-c M-g e’ (‘magit-blame-echo’) +‘C-c M-g B e’ + This command is like ‘magit-blame-addition’ except that it doesn’t + turn on ‘read-only-mode’ and that it initially uses the + visualization style specified by option ‘magit-blame-echo-style’. + + The following key bindings are available when Magit-Blame mode is +enabled and Read-Only mode is not enabled. These commands are also +available in other buffers; here only the behavior is described that is +relevant in file-visiting buffers that are being blamed. + +‘C-c M-g q’ (‘magit-blame-quit’) +‘C-c M-g B q’ + This command turns off Magit-Blame mode. If the buffer was created + during a recursive blame, then it also kills the buffer. + +‘<RET>’ (‘magit-show-commit’) + This command shows the commit that last touched the line at point. + +‘<SPC>’ (‘magit-diff-show-or-scroll-up’) + This command updates the commit buffer. + + This either shows the commit that last touched the line at point in + the appropriate buffer, or if that buffer is already being + displayed in the current frame and if that buffer contains + information about that commit, then the buffer is scrolled up + instead. + +‘<DEL>’ (‘magit-diff-show-or-scroll-down’) + This command updates the commit buffer. + + This either shows the commit that last touched the line at point in + the appropriate buffer, or if that buffer is already being + displayed in the current frame and if that buffer contains + information about that commit, then the buffer is scrolled down + instead. + + The following key bindings are available when both Magit-Blame mode +and Read-Only mode are enabled. + +‘b’ (‘magit-blame’) + See above. + +‘n’ (‘magit-blame-next-chunk’) + This command moves to the next chunk. + +‘N’ (‘magit-blame-next-chunk-same-commit’) + This command moves to the next chunk from the same commit. + +‘p’ (‘magit-blame-previous-chunk’) + This command moves to the previous chunk. + +‘P’ (‘magit-blame-previous-chunk-same-commit’) + This command moves to the previous chunk from the same commit. + +‘q’ (‘magit-blame-quit’) + This command turns off Magit-Blame mode. If the buffer was created + during a recursive blame, then it also kills the buffer. + +‘M-w’ (‘magit-blame-copy-hash’) + This command saves the hash of the current chunk’s commit to the + kill ring. + + When the region is active, the command saves the region’s content + instead of the hash, like ‘kill-ring-save’ would. + +‘c’ (‘magit-blame-cycle-style’) + This command changes how blame information is visualized in the + current buffer by cycling through the styles specified using the + option ‘magit-blame-styles’. + + Blaming is also controlled using the following options. + + -- User Option: magit-blame-styles + This option defines a list of styles used to visualize blame + information. For now see its doc-string to learn more. + + -- User Option: magit-blame-echo-style + This option specifies the blame visualization style used by the + command ‘magit-blame-echo’. This must be a symbol that is used as + the identifier for one of the styles defined in + ‘magit-blame-styles’. + + -- User Option: magit-blame-time-format + This option specifies the format string used to display times when + showing blame information. + + -- User Option: magit-blame-read-only + This option controls whether blaming a buffer also makes + temporarily read-only. + + -- User Option: magit-blame-disable-modes + This option lists incompatible minor-modes that should be disabled + temporarily when a buffer contains blame information. They are + enabled again when the buffer no longer shows blame information. + + -- User Option: magit-blame-goto-chunk-hook + This hook is run when moving between chunks. + + +File: magit.info, Node: Manipulating, Next: Transferring, Prev: Inspecting, Up: Top + +6 Manipulating +************** + +* Menu: + +* Creating Repository:: +* Cloning Repository:: +* Staging and Unstaging:: +* Applying:: +* Committing:: +* Branching:: +* Merging:: +* Resolving Conflicts:: +* Rebasing:: +* Cherry Picking:: +* Resetting:: +* Stashing:: + + +File: magit.info, Node: Creating Repository, Next: Cloning Repository, Up: Manipulating + +6.1 Creating Repository +======================= + +‘I’ (‘magit-init’) + This command initializes a repository and then shows the status + buffer for the new repository. + + If the directory is below an existing repository, then the user has + to confirm that a new one should be created inside. If the + directory is the root of the existing repository, then the user has + to confirm that it should be reinitialized. + + +File: magit.info, Node: Cloning Repository, Next: Staging and Unstaging, Prev: Creating Repository, Up: Manipulating + +6.2 Cloning Repository +====================== + +To clone a remote or local repository use ‘C’, which is bound to the +command ‘magit-clone’. This command either act as a transient prefix +command, which binds several infix arguments and suffix commands, or it +can invoke ‘git clone’ directly, depending on whether a prefix argument +is used and on the value of ‘magit-clone-always-transient’. + + -- User Option: magit-clone-always-transient + This option controls whether the command ‘magit-clone’ always acts + as a transient prefix command, regardless of whether a prefix + argument is used or not. If ‘t’, then that command always acts as + a transient prefix. If ‘nil’, then a prefix argument has to be + used for it to act as a transient. + +‘C’ (‘magit-clone’) + This command either acts as a transient prefix command as described + above or does the same thing as ‘transient-clone-regular’ as + described below. + + If it acts as a transient prefix, then it binds the following + suffix commands and several infix arguments. + +‘C C’ (‘magit-clone-regular’) + This command creates a regular clone of an existing repository. + The repository and the target directory are read from the user. + +‘C s’ (‘magit-clone-shallow’) + This command creates a shallow clone of an existing repository. + The repository and the target directory are read from the user. By + default the depth of the cloned history is a single commit, but + with a prefix argument the depth is read from the user. + +‘C >’ (‘magit-clone-sparse’) + This command creates a clone of an existing repository and + initializes a sparse checkout, avoiding a checkout of the full + working tree. To add more directories, use the + ‘magit-sparse-checkout’ transient (see *note Sparse checkouts::). + +‘C b’ (‘magit-clone-bare’) + This command creates a bare clone of an existing repository. The + repository and the target directory are read from the user. + +‘C m’ (‘magit-clone-mirror’) + This command creates a mirror of an existing repository. The + repository and the target directory are read from the user. + + The following suffixes are disabled by default. See *note +(transient)Enabling and Disabling Suffixes:: for how to enable them. + +‘C d’ (‘magit-clone-shallow-since’) + This command creates a shallow clone of an existing repository. + Only commits that were committed after a date are cloned, which is + read from the user. The repository and the target directory are + also read from the user. + +‘C e’ (‘magit-clone-shallow-exclude’) + This command creates a shallow clone of an existing repository. + This reads a branch or tag from the user. Commits that are + reachable from that are not cloned. The repository and the target + directory are also read from the user. + + -- User Option: magit-clone-set-remote-head + This option controls whether cloning causes the reference + ‘refs/remotes/<remote>/HEAD’ to be created in the clone. The + default is to delete the reference after running ‘git clone’, which + insists on creating it. This is because the reference has not been + found to be particularly useful as it is not automatically updated + when the ‘HEAD’ of the remote changes. Setting this option to ‘t’ + preserves Git’s default behavior of creating the reference. + + -- User Option: magit-clone-set-remote.pushDefault + This option controls whether the value of the Git variable + ‘remote.pushDefault’ is set after cloning. + + • If ‘t’, then it is always set without asking. + • If ‘ask’, then the users are asked every time they clone a + repository. + • If ‘nil’, then it is never set. + + -- User Option: magit-clone-default-directory + This option control the default directory name used when reading + the destination for a cloning operation. + + • If ‘nil’ (the default), then the value of ‘default-directory’ + is used. + • If a directory, then that is used. + • If a function, then that is called with the remote url as the + only argument and the returned value is used. + + -- User Option: magit-clone-name-alist + This option maps regular expressions, which match repository names, + to repository urls, making it possible for users to enter short + names instead of urls when cloning repositories. + + Each element has the form ‘(REGEXP HOSTNAME USER)’. When the user + enters a name when a cloning command asks for a name or url, then + that is looked up in this list. The first element whose REGEXP + matches is used. + + The format specified by option ‘magit-clone-url-format’ is used to + turn the name into an url, using HOSTNAME and the repository name. + If the provided name contains a slash, then that is used. + Otherwise if the name omits the owner of the repository, then the + default user specified in the matched entry is used. + + If USER contains a dot, then it is treated as a Git variable and + the value of that is used as the username. Otherwise it is used as + the username itself. + + -- User Option: magit-clone-url-format + The format specified by this option is used when turning repository + names into urls. ‘%h’ is the hostname and ‘%n’ is the repository + name, including the name of the owner. The value can be a string + (representing a single static format) or an alist with elements + ‘(HOSTNAME . FORMAT)’ mapping hostnames to formats. When an alist + is used, the ‘t’ key represents the default format. + + Example of a single format string: + + (setq magit-clone-url-format + "git@%h:%n.git") + + Example of by-hostname format strings: + + (setq magit-clone-url-format + '(("git.example.com" . "git@%h:~%n") + (nil . "git@%h:%n.git"))) + + -- User Option: magit-post-clone-hook + Hook run after the Git process has successfully finished cloning + the repository. When the hook is called, ‘default-directory’ is + let-bound to the directory where the repository has been cloned. + + +File: magit.info, Node: Staging and Unstaging, Next: Applying, Prev: Cloning Repository, Up: Manipulating + +6.3 Staging and Unstaging +========================= + +Like Git, Magit can of course stage and unstage complete files. Unlike +Git, it also allows users to gracefully un-/stage individual hunks and +even just part of a hunk. To stage individual hunks and parts of hunks +using Git directly, one has to use the very modal and rather clumsy +interface of a ‘git add --interactive’ session. + + With Magit, on the other hand, one can un-/stage individual hunks by +just moving point into the respective section inside a diff displayed in +the status buffer or a separate diff buffer and typing ‘s’ or ‘u’. To +operate on just parts of a hunk, mark the changes that should be +un-/staged using the region and then press the same key that would be +used to un-/stage. To stage multiple files or hunks at once use a +region that starts inside the heading of such a section and ends inside +the heading of a sibling section of the same type. + + Besides staging and unstaging, Magit also provides several other +"apply variants" that can also operate on a file, multiple files at +once, a hunk, multiple hunks at once, and on parts of a hunk. These +apply variants are described in the next section. + + You can also use Ediff to stage and unstage. See *note Ediffing::. + +‘s’ (‘magit-stage’) + Add the change at point to the staging area. + + With a prefix argument and an untracked file (or files) at point, + stage the file but not its content. This makes it possible to + stage only a subset of the new file’s changes. + +‘S’ (‘magit-stage-modified’) + Stage all changes to files modified in the worktree. Stage all new + content of tracked files and remove tracked files that no longer + exist in the working tree from the index also. With a prefix + argument also stage previously untracked (but not ignored) files. + +‘u’ (‘magit-unstage’) + Remove the change at point from the staging area. + + Only staged changes can be unstaged. But by default this command + performs an action that is somewhat similar to unstaging, when it + is called on a committed change: it reverses the change in the + index but not in the working tree. + +‘U’ (‘magit-unstage-all’) + Remove all changes from the staging area. + + -- User Option: magit-unstage-committed + This option controls whether ‘magit-unstage’ "unstages" committed + changes by reversing them in the index but not the working tree. + The alternative is to raise an error. + +‘M-x magit-reverse-in-index’ + This command reverses the committed change at point in the index + but not the working tree. By default no key is bound directly to + this command, but it is indirectly called when ‘u’ + (‘magit-unstage’) is pressed on a committed change. + + This allows extracting a change from ‘HEAD’, while leaving it in + the working tree, so that it can later be committed using a + separate commit. A typical workflow would be: + + 1. Optionally make sure that there are no uncommitted changes. + 2. Visit the ‘HEAD’ commit and navigate to the change that should + not have been included in that commit. + 3. Type ‘u’ (‘magit-unstage’) to reverse it in the index. This + assumes that ‘magit-unstage-committed-changes’ is non-nil. + 4. Type ‘c e’ to extend ‘HEAD’ with the staged changes, including + those that were already staged before. + 5. Optionally stage the remaining changes using ‘s’ or ‘S’ and + then type ‘c c’ to create a new commit. + +‘M-x magit-reset-index’ + Reset the index to some commit. The commit is read from the user + and defaults to the commit at point. If there is no commit at + point, then it defaults to ‘HEAD’. + +* Menu: + +* Staging from File-Visiting Buffers:: + + +File: magit.info, Node: Staging from File-Visiting Buffers, Up: Staging and Unstaging + +6.3.1 Staging from File-Visiting Buffers +---------------------------------------- + +Fine-grained un-/staging has to be done from the status or a diff +buffer, but it’s also possible to un-/stage all changes made to the file +visited in the current buffer right from inside that buffer. + +‘M-x magit-stage-file’ + When invoked inside a file-visiting buffer, then stage all changes + to that file. In a Magit buffer, stage the file at point if any. + Otherwise prompt for a file to be staged. With a prefix argument + always prompt the user for a file, even in a file-visiting buffer + or when there is a file section at point. + +‘M-x magit-unstage-file’ + When invoked inside a file-visiting buffer, then unstage all + changes to that file. In a Magit buffer, unstage the file at point + if any. Otherwise prompt for a file to be unstaged. With a prefix + argument always prompt the user for a file, even in a file-visiting + buffer or when there is a file section at point. + + +File: magit.info, Node: Applying, Next: Committing, Prev: Staging and Unstaging, Up: Manipulating + +6.4 Applying +============ + +Magit provides several "apply variants": stage, unstage, discard, +reverse, and "regular apply". At least when operating on a hunk they +are all implemented using ‘git apply’, which is why they are called +"apply variants". + + • Stage. Apply a change from the working tree to the index. The + change also remains in the working tree. + + • Unstage. Remove a change from the index. The change remains in + the working tree. + + • Discard. On a staged change, remove it from the working tree and + the index. On an unstaged change, remove it from the working tree + only. + + • Reverse. Reverse a change in the working tree. Both committed and + staged changes can be reversed. Unstaged changes cannot be + reversed. Discard them instead. + + • Apply. Apply a change to the working tree. Both committed and + staged changes can be applied. Unstaged changes cannot be applied + - as they already have been applied. + + The previous section described the staging and unstaging commands. +What follows are the commands which implement the remaining apply +variants. + +‘a’ (‘magit-apply’) + Apply the change at point to the working tree. + + With a prefix argument fallback to a 3-way merge. Doing so causes + the change to be applied to the index as well. + +‘k’ (‘magit-discard’) + Remove the change at point from the working tree. + + On a hunk or file with unresolved conflicts prompt which side to + keep (while discarding the other). If point is within the text of + a side, then keep that side without prompting. + +‘v’ (‘magit-reverse’) + Reverse the change at point in the working tree. + + With a prefix argument fallback to a 3-way merge. Doing so causes + the change to be applied to the index as well. + + With a prefix argument all apply variants attempt a 3-way merge when +appropriate (i.e., when ‘git apply’ is used internally). + + +File: magit.info, Node: Committing, Next: Branching, Prev: Applying, Up: Manipulating + +6.5 Committing +============== + +When the user initiates a commit, Magit calls ‘git commit’ without any +arguments, so Git has to get it from the user. It creates the file +‘.git/COMMIT_EDITMSG’ and then opens that file in an editor. Magit +arranges for that editor to be the Emacsclient. Once the user finishes +the editing session, the Emacsclient exits and Git creates the commit +using the file’s content as message. + +* Menu: + +* Initiating a Commit:: +* Editing Commit Messages:: + + +File: magit.info, Node: Initiating a Commit, Next: Editing Commit Messages, Up: Committing + +6.5.1 Initiating a Commit +------------------------- + +Also see *note (gitman)git-commit::. + +‘c’ (‘magit-commit’) + This transient prefix command binds the following suffix commands + along with the appropriate infix arguments and displays them in a + temporary buffer until a suffix is invoked. + +‘c c’ (‘magit-commit-create’) + Create a new commit on ‘HEAD’. With a prefix argument amend to the + commit at ‘HEAD’ instead. + +‘c a’ (‘magit-commit-amend’) + Amend the last commit. + +‘c e’ (‘magit-commit-extend’) + Amend the last commit, without editing the message. With a prefix + argument keep the committer date, otherwise change it. The option + ‘magit-commit-extend-override-date’ can be used to inverse the + meaning of the prefix argument. + + Non-interactively respect the optional OVERRIDE-DATE argument and + ignore the option. + +‘c w’ (‘magit-commit-reword’) + Reword the last commit, ignoring staged changes. With a prefix + argument keep the committer date, otherwise change it. The option + ‘magit-commit-reword-override-date’ can be used to inverse the + meaning of the prefix argument. + + Non-interactively respect the optional OVERRIDE-DATE argument and + ignore the option. + +‘c f’ (‘magit-commit-fixup’) + Create a fixup commit. + + With a prefix argument the target commit has to be confirmed. + Otherwise the commit at point may be used without confirmation + depending on the value of option ‘magit-commit-squash-confirm’. + +‘c F’ (‘magit-commit-instant-fixup’) + Create a fixup commit and instantly rebase. + +‘c s’ (‘magit-commit-squash’) + Create a squash commit, without editing the squash message. + + With a prefix argument the target commit has to be confirmed. + Otherwise the commit at point may be used without confirmation + depending on the value of option ‘magit-commit-squash-confirm’. + +‘c S’ (‘magit-commit-instant-squash’) + Create a squash commit and instantly rebase. + +‘c A’ (‘magit-commit-augment’) + Create a squash commit, editing the squash message. + + With a prefix argument the target commit has to be confirmed. + Otherwise the commit at point may be used without confirmation + depending on the value of option ‘magit-commit-squash-confirm’. + + -- User Option: magit-commit-ask-to-stage + Whether to ask to stage all unstaged changes when committing and + nothing is staged. + + -- User Option: magit-commit-show-diff + Whether the relevant diff is automatically shown when committing. + + -- User Option: magit-commit-extend-override-date + Whether using ‘magit-commit-extend’ changes the committer date. + + -- User Option: magit-commit-reword-override-date + Whether using ‘magit-commit-reword’ changes the committer date. + + -- User Option: magit-commit-squash-confirm + Whether the commit targeted by squash and fixup has to be + confirmed. When non-nil then the commit at point (if any) is used + as default choice. Otherwise it has to be confirmed. This option + only affects ‘magit-commit-squash’ and ‘magit-commit-fixup’. The + "instant" variants always require confirmation because making an + error while using those is harder to recover from. + + -- User Option: magit-post-commit-hook + Hook run after creating a commit without the user editing a + message. + + This hook is run by ‘magit-refresh’ if ‘this-command’ is a member + of ‘magit-post-commit-hook-commands’. This only includes commands + named ‘magit-commit-*’ that do *not* require that the user edits + the commit message in a buffer. + + Also see ‘git-commit-post-finish-hook’. + + -- User Option: magit-commit-diff-inhibit-same-window + Whether to inhibit use of same window when showing diff while + committing. + + When writing a commit, then a diff of the changes to be committed + is automatically shown. The idea is that the diff is shown in a + different window of the same frame and for most users that just + works. In other words most users can completely ignore this option + because its value doesn’t make a difference for them. + + However for users who configured Emacs to never create a new window + even when the package explicitly tries to do so, then displaying + two new buffers necessarily means that the first is immediately + replaced by the second. In our case the message buffer is + immediately replaced by the diff buffer, which is of course highly + undesirable. + + A workaround is to suppress this user configuration in this + particular case. Users have to explicitly opt-in by toggling this + option. We cannot enable the workaround unconditionally because + that again causes issues for other users: if the frame is too tiny + or the relevant settings too aggressive, then the diff buffer would + end up being displayed in a new frame. + + Also see <https://github.com/magit/magit/issues/4132>. + + +File: magit.info, Node: Editing Commit Messages, Prev: Initiating a Commit, Up: Committing + +6.5.2 Editing Commit Messages +----------------------------- + +After initiating a commit as described in the previous section, two new +buffers appear. One shows the changes that are about to be committed, +while the other is used to write the message. + + Commit messages are edited in an edit session - in the background +‘git’ is waiting for the editor, in our case ‘emacsclient’, to save the +commit message in a file (in most cases ‘.git/COMMIT_EDITMSG’) and then +return. If the editor returns with a non-zero exit status then ‘git’ +does not create the commit. So the most important commands are those +for finishing and aborting the commit. + +‘C-c C-c’ (‘with-editor-finish’) + Finish the current editing session by returning with exit code 0. + Git then creates the commit using the message it finds in the file. + +‘C-c C-k’ (‘with-editor-cancel’) + Cancel the current editing session by returning with exit code 1. + Git then cancels the commit, but leaves the file untouched. + + In addition to being used by ‘git commit’, messages may also be +stored in a ring that persists until Emacs is closed. By default the +message is stored at the beginning and the end of an edit session +(regardless of whether the session is finished successfully or was +canceled). It is sometimes useful to bring back messages from that +ring. + +‘C-c M-s’ (‘git-commit-save-message’) + Save the current buffer content to the commit message ring. + +‘M-p’ (‘git-commit-prev-message’) + Cycle backward through the commit message ring, after saving the + current message to the ring. With a numeric prefix ARG, go back + ARG comments. + +‘M-n’ (‘git-commit-next-message’) + Cycle forward through the commit message ring, after saving the + current message to the ring. With a numeric prefix ARG, go back + ARG comments. + + By default the diff for the changes that are about to be committed +are automatically shown when invoking the commit. To prevent that, +remove ‘magit-commit-diff’ from ‘server-switch-hook’. + + When amending to an existing commit it may be useful to show either +the changes that are about to be added to that commit or to show those +changes alongside those that have already been committed. + +‘C-c C-d’ (‘magit-diff-while-committing’) + While committing, show the changes that are about to be committed. + While amending, invoking the command again toggles between showing + just the new changes or all the changes that will be committed. + +* Menu: + +* Using the Revision Stack:: +* Commit Pseudo Headers:: +* Commit Mode and Hooks:: +* Commit Message Conventions:: + + +File: magit.info, Node: Using the Revision Stack, Next: Commit Pseudo Headers, Up: Editing Commit Messages + +Using the Revision Stack +........................ + +‘C-c C-w’ (‘magit-pop-revision-stack’) + This command inserts a representation of a revision into the + current buffer. It can be used inside buffers used to write commit + messages but also in other buffers such as buffers used to edit + emails or ChangeLog files. + + By default this command pops the revision which was last added to + the ‘magit-revision-stack’ and inserts it into the current buffer + according to ‘magit-pop-revision-stack-format’. Revisions can be + put on the stack using ‘magit-copy-section-value’ and + ‘magit-copy-buffer-revision’. + + If the stack is empty or with a prefix argument it instead reads a + revision in the minibuffer. By using the minibuffer history this + allows selecting an item which was popped earlier or to insert an + arbitrary reference or revision without first pushing it onto the + stack. + + When reading the revision from the minibuffer, then it might not be + possible to guess the correct repository. When this command is + called inside a repository (e.g., while composing a commit + message), then that repository is used. Otherwise (e.g., while + composing an email) then the repository recorded for the top + element of the stack is used (even though we insert another + revision). If not called inside a repository and with an empty + stack, or with two prefix arguments, then read the repository in + the minibuffer too. + + -- User Option: magit-pop-revision-stack-format + This option controls how the command ‘magit-pop-revision-stack’ + inserts a revision into the current buffer. + + The entries on the stack have the format ‘(HASH TOPLEVEL)’ and this + option has the format ‘(POINT-FORMAT EOB-FORMAT INDEX-REGEXP)’, all + of which may be nil or a string (though either one of EOB-FORMAT or + POINT-FORMAT should be a string, and if INDEX-REGEXP is non-nil, + then the two formats should be too). + + First INDEX-REGEXP is used to find the previously inserted entry, + by searching backward from point. The first submatch must match + the index number. That number is incremented by one, and becomes + the index number of the entry to be inserted. If you don’t want to + number the inserted revisions, then use nil for INDEX-REGEXP. + + If INDEX-REGEXP is non-nil then both POINT-FORMAT and EOB-FORMAT + should contain \"%N\", which is replaced with the number that was + determined in the previous step. + + Both formats, if non-nil and after removing %N, are then expanded + using ‘git show --format=FORMAT ...’ inside TOPLEVEL. + + The expansion of POINT-FORMAT is inserted at point, and the + expansion of EOB-FORMAT is inserted at the end of the buffer (if + the buffer ends with a comment, then it is inserted right before + that). + + +File: magit.info, Node: Commit Pseudo Headers, Next: Commit Mode and Hooks, Prev: Using the Revision Stack, Up: Editing Commit Messages + +Commit Pseudo Headers +..................... + +Some projects use pseudo headers in commit messages. Magit colorizes +such headers and provides some commands to insert such headers. + + -- User Option: git-commit-known-pseudo-headers + A list of Git pseudo headers to be highlighted. + +‘C-c C-i’ (‘git-commit-insert-pseudo-header’) + Insert a commit message pseudo header. + +‘C-c C-a’ (‘git-commit-ack’) + Insert a header acknowledging that you have looked at the commit. + +‘C-c C-r’ (‘git-commit-review’) + Insert a header acknowledging that you have reviewed the commit. + +‘C-c C-s’ (‘git-commit-signoff’) + Insert a header to sign off the commit. + +‘C-c C-t’ (‘git-commit-test’) + Insert a header acknowledging that you have tested the commit. + +‘C-c C-o’ (‘git-commit-cc’) + Insert a header mentioning someone who might be interested. + +‘C-c C-p’ (‘git-commit-reported’) + Insert a header mentioning the person who reported the issue being + fixed by the commit. + +‘C-c M-i’ (‘git-commit-suggested’) + Insert a header mentioning the person who suggested the change. + + +File: magit.info, Node: Commit Mode and Hooks, Next: Commit Message Conventions, Prev: Commit Pseudo Headers, Up: Editing Commit Messages + +Commit Mode and Hooks +..................... + +‘git-commit-mode’ is a minor mode that is only used to establish certain +key bindings. This makes it possible to use an arbitrary major mode in +buffers used to edit commit messages. It is even possible to use +different major modes in different repositories, which is useful when +different projects impose different commit message conventions. + + -- User Option: git-commit-major-mode + The value of this option is the major mode used to edit Git commit + messages. + + Because ‘git-commit-mode’ is a minor mode, we don’t use its mode hook +to setup the buffer, except for the key bindings. All other setup +happens in the function ‘git-commit-setup’, which among other things +runs the hook ‘git-commit-setup-hook’. + + -- User Option: git-commit-setup-hook + Hook run at the end of ‘git-commit-setup’. + +The following functions are suitable for this hook: + + -- Function: git-commit-save-message + Save the current buffer content to the commit message ring. + + -- Function: git-commit-setup-changelog-support + After this function is called, ChangeLog entries are treated as + paragraphs. + + -- Function: git-commit-turn-on-auto-fill + Turn on ‘auto-fill-mode’. + + -- Function: git-commit-turn-on-flyspell + Turn on Flyspell mode. Also prevent comments from being checked + and finally check current non-comment text. + + -- Function: git-commit-propertize-diff + Propertize the diff shown inside the commit message buffer. Git + inserts such diffs into the commit message template when the + ‘--verbose’ argument is used. ‘magit-commit’ by default does not + offer that argument because the diff that is shown in a separate + buffer is more useful. But some users disagree, which is why this + function exists. + + -- Function: bug-reference-mode + Hyperlink bug references in the buffer. + + -- Function: with-editor-usage-message + Show usage information in the echo area. + + -- User Option: git-commit-post-finish-hook + Hook run after the user finished writing a commit message. + + This hook is only run after pressing ‘C-c C-c’ in a buffer used to + edit a commit message. If a commit is created without the user + typing a message into a buffer, then this hook is not run. + + This hook is not run until the new commit has been created. If + doing so takes Git longer than one second, then this hook isn’t run + at all. For certain commands such as ‘magit-rebase-continue’ this + hook is never run because doing so would lead to a race condition. + + This hook is only run if ‘magit’ is available. + + Also see ‘magit-post-commit-hook’. + + +File: magit.info, Node: Commit Message Conventions, Prev: Commit Mode and Hooks, Up: Editing Commit Messages + +Commit Message Conventions +.......................... + +Git-Commit highlights certain violations of commonly accepted commit +message conventions. Certain violations even cause Git-Commit to ask +you to confirm that you really want to do that. This nagging can of +course be turned off, but the result of doing that usually is that +instead of some code it’s now the human who is reviewing your commits +who has to waste some time telling you to fix your commits. + + -- User Option: git-commit-summary-max-length + The intended maximal length of the summary line of commit messages. + Characters beyond this column are colorized to indicate that this + preference has been violated. + + -- User Option: git-commit-finish-query-functions + List of functions called to query before performing commit. + + The commit message buffer is current while the functions are + called. If any of them returns nil, then the commit is not + performed and the buffer is not killed. The user should then fix + the issue and try again. + + The functions are called with one argument. If it is non-nil then + that indicates that the user used a prefix argument to force + finishing the session despite issues. Functions should usually + honor this wish and return non-nil. + + By default the only member is ‘git-commit-check-style-conventions’. + + -- Function: git-commit-check-style-conventions + This function checks for violations of certain basic style + conventions. For each violation it asks users if they want to + proceed anyway. + + -- User Option: git-commit-style-convention-checks + This option controls what conventions the function by the same name + tries to enforce. The value is a list of self-explanatory symbols + identifying certain conventions; ‘non-empty-second-line’ and + ‘overlong-summary-line’. + + +File: magit.info, Node: Branching, Next: Merging, Prev: Committing, Up: Manipulating + +6.6 Branching +============= + +* Menu: + +* The Two Remotes:: +* Branch Commands:: +* Branch Git Variables:: +* Auxiliary Branch Commands:: + + +File: magit.info, Node: The Two Remotes, Next: Branch Commands, Up: Branching + +6.6.1 The Two Remotes +--------------------- + +The upstream branch of some local branch is the branch into which the +commits on that local branch should eventually be merged, usually +something like ‘origin/master’. For the ‘master’ branch itself the +upstream branch and the branch it is being pushed to, are usually the +same remote branch. But for a feature branch the upstream branch and +the branch it is being pushed to should differ. + + The commits on feature branches too should _eventually_ end up in a +remote branch such as ‘origin/master’ or ‘origin/maint’. Such a branch +should therefore be used as the upstream. But feature branches +shouldn’t be pushed directly to such branches. Instead a feature branch +‘my-feature’ is usually pushed to ‘my-fork/my-feature’ or if you are a +contributor ‘origin/my-feature’. After the new feature has been +reviewed, the maintainer merges the feature into ‘master’. And finally +‘master’ (not ‘my-feature’ itself) is pushed to ‘origin/master’. + + But new features seldom are perfect on the first try, and so feature +branches usually have to be reviewed, improved, and re-pushed several +times. Pushing should therefore be easy to do, and for that reason many +Git users have concluded that it is best to use the remote branch to +which the local feature branch is being pushed as its upstream. + + But luckily Git has long ago gained support for a push-remote which +can be configured separately from the upstream branch, using the +variables ‘branch.<name>.pushRemote’ and ‘remote.pushDefault’. So we no +longer have to choose which of the two remotes should be used as "the +remote". + + Each of the fetching, pulling, and pushing transient commands +features three suffix commands that act on the current branch and some +other branch. Of these, ‘p’ is bound to a command which acts on the +push-remote, ‘u’ is bound to a command which acts on the upstream, and +‘e’ is bound to a command which acts on any other branch. The status +buffer shows unpushed and unpulled commits for both the push-remote and +the upstream. + + It’s fairly simple to configure these two remotes. The values of all +the variables that are related to fetching, pulling, and pushing (as +well as some other branch-related variables) can be inspected and +changed using the command ‘magit-branch-configure’, which is available +from many transient prefix commands that deal with branches. It is also +possible to set the push-remote or upstream while pushing (see *note +Pushing::). + + +File: magit.info, Node: Branch Commands, Next: Branch Git Variables, Prev: The Two Remotes, Up: Branching + +6.6.2 Branch Commands +--------------------- + +The transient prefix command ‘magit-branch’ is used to create and +checkout branches, and to make changes to existing branches. It is not +used to fetch, pull, merge, rebase, or push branches, i.e., this command +deals with branches themselves, not with the commits reachable from +them. Those features are available from separate transient command. + +‘b’ (‘magit-branch’) + This transient prefix command binds the following suffix commands + and displays them in a temporary buffer until a suffix is invoked. + + By default it also binds and displays the values of some + branch-related Git variables and allows changing their values. + + -- User Option: magit-branch-direct-configure + This option controls whether the transient command ‘magit-branch’ + can be used to directly change the values of Git variables. This + defaults to ‘t’ (to avoid changing key bindings). When set to + ‘nil’, then no variables are displayed by that transient command, + and its suffix command ‘magit-branch-configure’ has to be used + instead to view and change branch related variables. + +‘b C’ (‘magit-branch-configure’) +‘f C’ +‘F C’ +‘P C’ + This transient prefix command binds commands that set the value of + branch-related variables and displays them in a temporary buffer + until the transient is exited. + + With a prefix argument, this command always prompts for a branch. + + Without a prefix argument this depends on whether it was invoked as + a suffix of ‘magit-branch’ and on the + ‘magit-branch-direct-configure’ option. If ‘magit-branch’ already + displays the variables for the current branch, then it isn’t useful + to invoke another transient that displays them for the same branch. + In that case this command prompts for a branch. + + The variables are described in *note Branch Git Variables::. + +‘b b’ (‘magit-checkout’) + Checkout a revision read in the minibuffer and defaulting to the + branch or arbitrary revision at point. If the revision is a local + branch then that becomes the current branch. If it is something + else then ‘HEAD’ becomes detached. Checkout fails if the working + tree or the staging area contain changes. + +‘b n’ (‘magit-branch-create’) + Create a new branch. The user is asked for a branch or arbitrary + revision to use as the starting point of the new branch. When a + branch name is provided, then that becomes the upstream branch of + the new branch. The name of the new branch is also read in the + minibuffer. + + Also see option ‘magit-branch-prefer-remote-upstream’. + +‘b c’ (‘magit-branch-and-checkout’) + This command creates a new branch like ‘magit-branch-create’, but + then also checks it out. + + Also see option ‘magit-branch-prefer-remote-upstream’. + +‘b l’ (‘magit-branch-checkout’) + This command checks out an existing or new local branch. It reads + a branch name from the user offering all local branches and a + subset of remote branches as candidates. Remote branches for which + a local branch by the same name exists are omitted from the list of + candidates. The user can also enter a completely new branch name. + + • If the user selects an existing local branch, then that is + checked out. + + • If the user selects a remote branch, then it creates and + checks out a new local branch with the same name, and + configures the selected remote branch as the push target. + + • If the user enters a new branch name, then it creates and + checks that out, after also reading the starting-point from + the user. + + In the latter two cases the upstream is also set. Whether it is + set to the chosen starting point or something else depends on the + value of ‘magit-branch-adjust-remote-upstream-alist’. + +‘b s’ (‘magit-branch-spinoff’) + This command creates and checks out a new branch starting at and + tracking the current branch. That branch in turn is reset to the + last commit it shares with its upstream. If the current branch has + no upstream or no unpushed commits, then the new branch is created + anyway and the previously current branch is not touched. + + This is useful to create a feature branch after work has already + began on the old branch (likely but not necessarily "master"). + + If the current branch is a member of the value of option + ‘magit-branch-prefer-remote-upstream’ (which see), then the current + branch will be used as the starting point as usual, but the + upstream of the starting-point may be used as the upstream of the + new branch, instead of the starting-point itself. + + If optional FROM is non-nil, then the source branch is reset to + ‘FROM~’, instead of to the last commit it shares with its upstream. + Interactively, FROM is only ever non-nil, if the region selects + some commits, and among those commits, FROM is the commit that is + the fewest commits ahead of the source branch. + + The commit at the other end of the selection actually does not + matter, all commits between FROM and ‘HEAD’ are moved to the new + branch. If FROM is not reachable from ‘HEAD’ or is reachable from + the source branch’s upstream, then an error is raised. + +‘b S’ (‘magit-branch-spinout’) + This command behaves like ‘magit-branch-spinoff’, except that it + does not change the current branch. If there are any uncommitted + changes, then it behaves exactly like ‘magit-branch-spinoff’. + +‘b x’ (‘magit-branch-reset’) + This command resets a branch, defaulting to the branch at point, to + the tip of another branch or any other commit. + + When the branch being reset is the current branch, then a hard + reset is performed. If there are any uncommitted changes, then the + user has to confirm the reset because those changes would be lost. + + This is useful when you have started work on a feature branch but + realize it’s all crap and want to start over. + + When resetting to another branch and a prefix argument is used, + then the target branch is set as the upstream of the branch that is + being reset. + +‘b k’ (‘magit-branch-delete’) + Delete one or multiple branches. If the region marks multiple + branches, then offer to delete those. Otherwise, prompt for a + single branch to be deleted, defaulting to the branch at point. + + Require confirmation when deleting branches is dangerous in some + way. Option ‘magit-no-confirm’ can be customized to not require + confirmation in certain cases. See its docstring to learn why + confirmation is required by default in certain cases or if a prompt + is confusing. + +‘b m’ (‘magit-branch-rename’) + Rename a branch. The branch and the new name are read in the + minibuffer. With prefix argument the branch is renamed even if + that name conflicts with an existing branch. + + -- User Option: magit-branch-read-upstream-first + When creating a branch, whether to read the upstream branch before + the name of the branch that is to be created. The default is ‘t’, + and I recommend you leave it at that. + + -- User Option: magit-branch-prefer-remote-upstream + This option specifies whether remote upstreams are favored over + local upstreams when creating new branches. + + When a new branch is created, then the branch, commit, or stash at + point is suggested as the starting point of the new branch, or if + there is no such revision at point the current branch. In either + case the user may choose another starting point. + + If the chosen starting point is a branch, then it may also be set + as the upstream of the new branch, depending on the value of the + Git variable ‘branch.autoSetupMerge’. By default this is done for + remote branches, but not for local branches. + + You might prefer to always use some remote branch as upstream. If + the chosen starting point is (1) a local branch, (2) whose name + matches a member of the value of this option, (3) the upstream of + that local branch is a remote branch with the same name, and (4) + that remote branch can be fast-forwarded to the local branch, then + the chosen branch is used as starting point, but its own upstream + is used as the upstream of the new branch. + + Members of this option’s value are treated as branch names that + have to match exactly unless they contain a character that makes + them invalid as a branch name. Recommended characters to use to + trigger interpretation as a regexp are "*" and "^". Some other + characters which you might expect to be invalid, actually are not, + e.g., ".+$" are all perfectly valid. More precisely, if ‘git + check-ref-format --branch STRING’ exits with a non-zero status, + then treat STRING as a regexp. + + Assuming the chosen branch matches these conditions you would end + up with with e.g.: + + feature --upstream--> origin/master + + instead of + + feature --upstream--> master --upstream--> origin/master + + Which you prefer is a matter of personal preference. If you do + prefer the former, then you should add branches such as ‘master’, + ‘next’, and ‘maint’ to the value of this options. + + -- User Option: magit-branch-adjust-remote-upstream-alist + The value of this option is an alist of branches to be used as the + upstream when branching a remote branch. + + When creating a local branch from an ephemeral branch located on a + remote, e.g., a feature or hotfix branch, then that remote branch + should usually not be used as the upstream branch, since the + push-remote already allows accessing it and having both the + upstream and the push-remote reference the same related branch + would be wasteful. Instead a branch like "maint" or "master" + should be used as the upstream. + + This option allows specifying the branch that should be used as the + upstream when branching certain remote branches. The value is an + alist of the form ‘((UPSTREAM . RULE)...)’. The first matching + element is used, the following elements are ignored. + + UPSTREAM is the branch to be used as the upstream for branches + specified by RULE. It can be a local or a remote branch. + + RULE can either be a regular expression, matching branches whose + upstream should be the one specified by UPSTREAM. Or it can be a + list of the only branches that should *not* use UPSTREAM; all other + branches will. Matching is done after stripping the remote part of + the name of the branch that is being branched from. + + If you use a finite set of non-ephemeral branches across all your + repositories, then you might use something like: + + (("origin/master" . ("master" "next" "maint"))) + + Or if the names of all your ephemeral branches contain a slash, at + least in some repositories, then a good value could be: + + (("origin/master" . "/")) + + Of course you can also fine-tune: + + (("origin/maint" . "\\`hotfix/") + ("origin/master" . "\\`feature/")) + + UPSTREAM can be a local branch: + + (("master" . ("master" "next" "maint"))) + + Because the main branch is no longer almost always named "master" you +should also account for other common names: + + (("main" . ("main" "master" "next" "maint")) + ("master" . ("main" "master" "next" "maint"))) + + -- Command: magit-branch-orphan + This command creates and checks out a new orphan branch with + contents from a given revision. + + -- Command: magit-branch-or-checkout + This command is a hybrid between ‘magit-checkout’ and + ‘magit-branch-and-checkout’ and is intended as a replacement for + the former in ‘magit-branch’. + + It first asks the user for an existing branch or revision. If the + user input actually can be resolved as a branch or revision, then + it checks that out, just like ‘magit-checkout’ would. + + Otherwise it creates and checks out a new branch using the input as + its name. Before doing so it reads the starting-point for the new + branch. This is similar to what ‘magit-branch-and-checkout’ does. + + To use this command instead of ‘magit-checkout’ add this to your + init file: + + (transient-replace-suffix 'magit-branch 'magit-checkout + '("b" "dwim" magit-branch-or-checkout)) + + +File: magit.info, Node: Branch Git Variables, Next: Auxiliary Branch Commands, Prev: Branch Commands, Up: Branching + +6.6.3 Branch Git Variables +-------------------------- + +These variables can be set from the transient prefix command +‘magit-branch-configure’. By default they can also be set from +‘magit-branch’. See *note Branch Commands::. + + -- Variable: branch.NAME.merge + Together with ‘branch.NAME.remote’ this variable defines the + upstream branch of the local branch named NAME. The value of this + variable is the full reference of the upstream _branch_. + + -- Variable: branch.NAME.remote + Together with ‘branch.NAME.merge’ this variable defines the + upstream branch of the local branch named NAME. The value of this + variable is the name of the upstream _remote_. + + -- Variable: branch.NAME.rebase + This variable controls whether pulling into the branch named NAME + is done by rebasing or by merging the fetched branch. + + • When ‘true’ then pulling is done by rebasing. + • When ‘false’ then pulling is done by merging. + • When undefined then the value of ‘pull.rebase’ is used. The + default of that variable is ‘false’. + + -- Variable: branch.NAME.pushRemote + This variable specifies the remote that the branch named NAME is + usually pushed to. The value has to be the name of an existing + remote. + + It is not possible to specify the name of _branch_ to push the + local branch to. The name of the remote branch is always the same + as the name of the local branch. + + If this variable is undefined but ‘remote.pushDefault’ is defined, + then the value of the latter is used. By default + ‘remote.pushDefault’ is undefined. + + -- Variable: branch.NAME.description + This variable can be used to describe the branch named NAME. That + description is used, e.g., when turning the branch into a series of + patches. + + The following variables specify defaults which are used if the above +branch-specific variables are not set. + + -- Variable: pull.rebase + This variable specifies whether pulling is done by rebasing or by + merging. It can be overwritten using ‘branch.NAME.rebase’. + + • When ‘true’ then pulling is done by rebasing. + • When ‘false’ (the default) then pulling is done by merging. + + Since it is never a good idea to merge the upstream branch into a + feature or hotfix branch and most branches are such branches, you + should consider setting this to ‘true’, and ‘branch.master.rebase’ + to ‘false’. + + -- Variable: remote.pushDefault + This variable specifies what remote the local branches are usually + pushed to. This can be overwritten per branch using + ‘branch.NAME.pushRemote’. + + The following variables are used during the creation of a branch and +control whether the various branch-specific variables are automatically +set at this time. + + -- Variable: branch.autoSetupMerge + This variable specifies under what circumstances creating a branch + NAME should result in the variables ‘branch.NAME.merge’ and + ‘branch.NAME.remote’ being set according to the starting point used + to create the branch. If the starting point isn’t a branch, then + these variables are never set. + + • When ‘always’ then the variables are set regardless of whether + the starting point is a local or a remote branch. + • When ‘true’ (the default) then the variables are set when the + starting point is a remote branch, but not when it is a local + branch. + • When ‘false’ then the variables are never set. + + -- Variable: branch.autoSetupRebase + This variable specifies whether creating a branch NAME should + result in the variable ‘branch.NAME.rebase’ being set to ‘true’. + + • When ‘always’ then the variable is set regardless of whether + the starting point is a local or a remote branch. + • When ‘local’ then the variable are set when the starting point + is a local branch, but not when it is a remote branch. + • When ‘remote’ then the variable are set when the starting + point is a remote branch, but not when it is a local branch. + • When ‘never’ (the default) then the variable is never set. + + Note that the respective commands always change the repository-local +values. If you want to change the global value, which is used when the +local value is undefined, then you have to do so on the command line, +e.g.: + + git config --global remote.autoSetupMerge always + + For more information about these variables you should also see + + *note (gitman)git-config::. Also see *note (gitman)git-branch::. , +*note (gitman)git-checkout::. and *note Pushing::. + + -- User Option: magit-prefer-remote-upstream + This option controls whether commands that read a branch from the + user and then set it as the upstream branch, offer a local or a + remote branch as default completion candidate, when they have the + choice. + + This affects all commands that use ‘magit-read-upstream-branch’ or + ‘magit-read-starting-point’, which includes all commands that + change the upstream and many which create new branches. + + +File: magit.info, Node: Auxiliary Branch Commands, Prev: Branch Git Variables, Up: Branching + +6.6.4 Auxiliary Branch Commands +------------------------------- + +These commands are not available from the transient ‘magit-branch’ by +default. + + -- Command: magit-branch-shelve + This command shelves a branch. This is done by deleting the + branch, and creating a new reference "refs/shelved/BRANCH-NAME" + pointing at the same commit as the branch pointed at. If the + deleted branch had a reflog, then that is preserved as the reflog + of the new reference. + + This is useful if you want to move a branch out of sight, but are + not ready to completely discard it yet. + + -- Command: magit-branch-unshelve + This command unshelves a branch that was previously shelved using + ‘magit-branch-shelve’. This is done by deleting the reference + "refs/shelved/BRANCH-NAME" and creating a branch "BRANCH-NAME" + pointing at the same commit as the deleted reference pointed at. + If the deleted reference had a reflog, then that is restored as the + reflog of the branch. + + +File: magit.info, Node: Merging, Next: Resolving Conflicts, Prev: Branching, Up: Manipulating + +6.7 Merging +=========== + +Also see *note (gitman)git-merge::. For information on how to resolve +merge conflicts see the next section. + +‘m’ (‘magit-merge’) + This transient prefix command binds the following suffix commands + along with the appropriate infix arguments and displays them in a + temporary buffer until a suffix is invoked. + + When no merge is in progress, then the transient features the +following suffix commands. + +‘m m’ (‘magit-merge-plain’) + This command merges another branch or an arbitrary revision into + the current branch. The branch or revision to be merged is read in + the minibuffer and defaults to the branch at point. + + Unless there are conflicts or a prefix argument is used, then the + resulting merge commit uses a generic commit message, and the user + does not get a chance to inspect or change it before the commit is + created. With a prefix argument this does not actually create the + merge commit, which makes it possible to inspect how conflicts were + resolved and to adjust the commit message. + +‘m e’ (‘magit-merge-editmsg’) + This command merges another branch or an arbitrary revision into + the current branch and opens a commit message buffer, so that the + user can make adjustments. The commit is not actually created + until the user finishes with ‘C-c C-c’. + +‘m n’ (‘magit-merge-nocommit’) + This command merges another branch or an arbitrary revision into + the current branch, but does not actually create the merge commit. + The user can then further adjust the merge, even when automatic + conflict resolution succeeded and/or adjust the commit message. + +‘m a’ (‘magit-merge-absorb’) + This command merges another local branch into the current branch + and then removes the former. + + Before the source branch is merged, it is first force pushed to its + push-remote, provided the respective remote branch already exists. + This ensures that the respective pull-request (if any) won’t get + stuck on some obsolete version of the commits that are being + merged. Finally, if ‘magit-branch-pull-request’ was used to create + the merged branch, then the respective remote branch is also + removed. + +‘m i’ (‘magit-merge-into’) + This command merges the current branch into another local branch + and then removes the former. The latter becomes the new current + branch. + + Before the source branch is merged, it is first force pushed to its + push-remote, provided the respective remote branch already exists. + This ensures that the respective pull-request (if any) won’t get + stuck on some obsolete version of the commits that are being + merged. Finally, if ‘magit-branch-pull-request’ was used to create + the merged branch, then the respective remote branch is also + removed. + +‘m s’ (‘magit-merge-squash’) + This command squashes the changes introduced by another branch or + an arbitrary revision into the current branch. This only applies + the changes made by the squashed commits. No information is + preserved that would allow creating an actual merge commit. + Instead of this command you should probably use a command from the + apply transient. + +‘m p’ (‘magit-merge-preview’) + This command shows a preview of merging another branch or an + arbitrary revision into the current branch. + + Note that commands, that normally change how a diff is displayed, + do not work in buffers created by this command, because the + underlying Git command does not support diff arguments. + + When a merge is in progress, then the transient instead features the +following suffix commands. + +‘m m’ (‘magit-merge’) + After the user resolved conflicts, this command proceeds with the + merge. If some conflicts weren’t resolved, then this command + fails. + +‘m a’ (‘magit-merge-abort’) + This command aborts the current merge operation. + + +File: magit.info, Node: Resolving Conflicts, Next: Rebasing, Prev: Merging, Up: Manipulating + +6.8 Resolving Conflicts +======================= + +When merging branches (or otherwise combining or changing history) +conflicts can occur. If you edited two completely different parts of +the same file in two branches and then merge one of these branches into +the other, then Git can resolve that on its own, but if you edit the +same area of a file, then a human is required to decide how the two +versions, or "sides of the conflict", are to be combined into one. + + Here we can only provide a brief introduction to the subject and +point you toward some tools that can help. If you are new to this, then +please also consult Git’s own documentation as well as other resources. + + If a file has conflicts and Git cannot resolve them by itself, then +it puts both versions into the affected file along with special markers +whose purpose is to denote the boundaries of the unresolved part of the +file and between the different versions. These boundary lines begin +with the strings consisting of seven times the same character, one of +‘<’, ‘|’, ‘=’ and ‘>’, and are followed by information about the source +of the respective versions, e.g.: + + <<<<<<< HEAD + Take the blue pill. + ======= + Take the red pill. + >>>>>>> feature + + In this case you have chosen to take the red pill on one branch and +on another you picked the blue pill. Now that you are merging these two +diverging branches, Git cannot possibly know which pill you want to +take. + + To resolve that conflict you have to create a version of the affected +area of the file by keeping only one of the sides, possibly by editing +it in order to bring in the changes from the other side, remove the +other versions as well as the markers, and then stage the result. A +possible resolution might be: + + Take both pills. + + Often it is useful to see not only the two sides of the conflict but +also the "original" version from before the same area of the file was +modified twice on different branches. Instruct Git to insert that +version as well by running this command once: + + git config --global merge.conflictStyle diff3 + + The above conflict might then have looked like this: + + <<<<<<< HEAD + Take the blue pill. + ||||||| merged common ancestors + Take either the blue or the red pill, but not both. + ======= + Take the red pill. + >>>>>>> feature + + If that were the case, then the above conflict resolution would not +have been correct, which demonstrates why seeing the original version +alongside the conflicting versions can be useful. + + You can perform the conflict resolution completely by hand, but Emacs +also provides some packages that help in the process: Smerge, Ediff +(*note (ediff)Top::), and Emerge (*note (emacs)Emerge::). Magit does +not provide its own tools for conflict resolution, but it does make +using Smerge and Ediff more convenient. (Ediff supersedes Emerge, so +you probably don’t want to use the latter anyway.) + + In the Magit status buffer, files with unresolved conflicts are +listed in the "Unstaged changes" and/or "Staged changes" sections. They +are prefixed with the word "unmerged", which in this context essentially +is a synonym for "unresolved". + + Pressing ‘RET’ while point is on such a file section shows a buffer +visiting that file, turns on ‘smerge-mode’ in that buffer, and places +point inside the first area with conflicts. You should then resolve +that conflict using regular edit commands and/or Smerge commands. + + Unfortunately Smerge does not have a manual, but you can get a list +of commands and binding ‘C-c ^ C-h’ and press ‘RET’ while point is on a +command name to read its documentation. + + Normally you would edit one version and then tell Smerge to keep only +that version. Use ‘C-c ^ m’ (‘smerge-keep-mine’) to keep the ‘HEAD’ +version or ‘C-c ^ o’ (‘smerge-keep-other’) to keep the version that +follows "|||||||". Then use ‘C-c ^ n’ to move to the next conflicting +area in the same file. Once you are done resolving conflicts, return to +the Magit status buffer. The file should now be shown as "modified", no +longer as "unmerged", because Smerge automatically stages the file when +you save the buffer after resolving the last conflict. + + Magit now wraps the mentioned Smerge commands, allowing you to use +these key bindings without having to go to the file-visiting buffer. +Additionally ‘k’ (‘magit-discard’) on a hunk with unresolved conflicts +asks which side to keep or, if point is on a side, then it keeps it +without prompting. Similarly ‘k’ on a unresolved file ask which side to +keep. + + Alternatively you could use Ediff, which uses separate buffers for +the different versions of the file. To resolve conflicts in a file +using Ediff press ‘e’ while point is on such a file in the status +buffer. + + Ediff can be used for other purposes as well. For more information +on how to enter Ediff from Magit, see *note Ediffing::. Explaining how +to use Ediff is beyond the scope of this manual, instead see *note +(ediff)Top::. + + If you are unsure whether you should Smerge or Ediff, then use the +former. It is much easier to understand and use, and except for truly +complex conflicts, the latter is usually overkill. + + +File: magit.info, Node: Rebasing, Next: Cherry Picking, Prev: Resolving Conflicts, Up: Manipulating + +6.9 Rebasing +============ + +Also see *note (gitman)git-rebase::. For information on how to resolve +conflicts that occur during rebases see the preceding section. + +‘r’ (‘magit-rebase’) + This transient prefix command binds the following suffix commands + along with the appropriate infix arguments and displays them in a + temporary buffer until a suffix is invoked. + + When no rebase is in progress, then the transient features the +following suffix commands. + + Using one of these commands _starts_ a rebase sequence. Git might +then stop somewhere along the way, either because you told it to do so, +or because applying a commit failed due to a conflict. When that +happens, then the status buffer shows information about the rebase +sequence which is in progress in a section similar to a log section. +See *note Information About In-Progress Rebase::. + + For information about the upstream and the push-remote, see *note The +Two Remotes::. + +‘r p’ (‘magit-rebase-onto-pushremote’) + This command rebases the current branch onto its push-remote. + + With a prefix argument or when the push-remote is either not + configured or unusable, then let the user first configure the + push-remote. + +‘r u’ (‘magit-rebase-onto-upstream’) + This command rebases the current branch onto its upstream branch. + + With a prefix argument or when the upstream is either not + configured or unusable, then let the user first configure the + upstream. + +‘r e’ (‘magit-rebase-branch’) + This command rebases the current branch onto a branch read in the + minibuffer. All commits that are reachable from head but not from + the selected branch TARGET are being rebased. + +‘r s’ (‘magit-rebase-subset’) + This command starts a non-interactive rebase sequence to transfer + commits from START to ‘HEAD’ onto NEWBASE. START has to be + selected from a list of recent commits. + + By default Magit uses the ‘--autostash’ argument, which causes +uncommitted changes to be stored in a stash before the rebase begins. +These changes are restored after the rebase completes and if possible +the stash is removed. If the stash does not apply cleanly, then the +stash is not removed. In case something goes wrong when resolving the +conflicts, this allows you to start over. + + Even though one of the actions is dedicated to interactive rebases, +the transient also features the infix argument ‘--interactive’. This +can be used to turn one of the other, non-interactive rebase variants +into an interactive rebase. + + For example if you want to clean up a feature branch and at the same +time rebase it onto ‘master’, then you could use ‘r-iu’. But we +recommend that you instead do that in two steps. First use ‘ri’ to +cleanup the feature branch, and then in a second step ‘ru’ to rebase it +onto ‘master’. That way if things turn out to be more complicated than +you thought and/or you make a mistake and have to start over, then you +only have to redo half the work. + + Explicitly enabling ‘--interactive’ won’t have an effect on the +following commands as they always use that argument anyway, even if it +is not enabled in the transient. + +‘r i’ (‘magit-rebase-interactive’) + This command starts an interactive rebase sequence. + +‘r f’ (‘magit-rebase-autosquash’) + This command combines squash and fixup commits with their intended + targets. + +‘r m’ (‘magit-rebase-edit-commit’) + This command starts an interactive rebase sequence that lets the + user edit a single older commit. + +‘r w’ (‘magit-rebase-reword-commit’) + This command starts an interactive rebase sequence that lets the + user reword a single older commit. + +‘r k’ (‘magit-rebase-remove-commit’) + This command removes a single older commit using rebase. + + When a rebase is in progress, then the transient instead features the +following suffix commands. + +‘r r’ (‘magit-rebase-continue’) + This command restart the current rebasing operation. + + In some cases this pops up a commit message buffer for you do edit. + With a prefix argument the old message is reused as-is. + +‘r s’ (‘magit-rebase-skip’) + This command skips the current commit and restarts the current + rebase operation. + +‘r e’ (‘magit-rebase-edit’) + This command lets the user edit the todo list of the current rebase + operation. + +‘r a’ (‘magit-rebase-abort’) + This command aborts the current rebase operation, restoring the + original branch. + +* Menu: + +* Editing Rebase Sequences:: +* Information About In-Progress Rebase:: + + +File: magit.info, Node: Editing Rebase Sequences, Next: Information About In-Progress Rebase, Up: Rebasing + +6.9.1 Editing Rebase Sequences +------------------------------ + +‘C-c C-c’ (‘with-editor-finish’) + Finish the current editing session by returning with exit code 0. + Git then uses the rebase instructions it finds in the file. + +‘C-c C-k’ (‘with-editor-cancel’) + Cancel the current editing session by returning with exit code 1. + Git then forgoes starting the rebase sequence. + +‘<RET>’ (‘git-rebase-show-commit’) + Show the commit on the current line in another buffer and select + that buffer. + +‘<SPC>’ (‘git-rebase-show-or-scroll-up’) + Show the commit on the current line in another buffer without + selecting that buffer. If the revision buffer is already visible + in another window of the current frame, then instead scroll that + window up. + +‘<DEL>’ (‘git-rebase-show-or-scroll-down’) + Show the commit on the current line in another buffer without + selecting that buffer. If the revision buffer is already visible + in another window of the current frame, then instead scroll that + window down. + +‘p’ (‘git-rebase-backward-line’) + Move to previous line. + +‘n’ (‘forward-line’) + Move to next line. + +‘M-p’ (‘git-rebase-move-line-up’) + Move the current commit (or command) up. + +‘M-n’ (‘git-rebase-move-line-down’) + Move the current commit (or command) down. + +‘r’ (‘git-rebase-reword’) + Edit message of commit on current line. + +‘e’ (‘git-rebase-edit’) + Stop at the commit on the current line. + +‘s’ (‘git-rebase-squash’) + Meld commit on current line into previous commit, and edit message. + +‘f’ (‘git-rebase-fixup’) + Meld commit on current line into previous commit, discarding the + current commit’s message. + +‘k’ (‘git-rebase-kill-line’) + Kill the current action line. + +‘c’ (‘git-rebase-pick’) + Use commit on current line. + +‘x’ (‘git-rebase-exec’) + Insert a shell command to be run after the proceeding commit. + + If there already is such a command on the current line, then edit + that instead. With a prefix argument insert a new command even + when there already is one on the current line. With empty input + remove the command on the current line, if any. + +‘b’ (‘git-rebase-break’) + Insert a break action before the current line, instructing Git to + return control to the user. + +‘y’ (‘git-rebase-insert’) + Read an arbitrary commit and insert it below current line. + +‘C-x u’ (‘git-rebase-undo’) + Undo some previous changes. Like ‘undo’ but works in read-only + buffers. + + -- User Option: git-rebase-auto-advance + Whether to move to next line after changing a line. + + -- User Option: git-rebase-show-instructions + Whether to show usage instructions inside the rebase buffer. + + -- User Option: git-rebase-confirm-cancel + Whether confirmation is required to cancel. + + When a rebase is performed with the ‘--rebase-merges’ option, the +sequence will include a few other types of actions and the following +commands become relevant. + +‘l’ (‘git-rebase-label’) + This commands inserts a label action or edits the one at point. + +‘t’ (‘git-rebase-reset’) + This command inserts a reset action or edits the one at point. The + prompt will offer the labels that are currently present in the + buffer. + +‘MM’ (‘git-rebase-merge’) + The command inserts a merge action or edits the one at point. The + prompt will offer the labels that are currently present in the + buffer. Specifying a message to reuse via ‘-c’ or ‘-C’ is not + supported; an editor will always be invoked for the merge. + +‘Mt’ (‘git-rebase-merge-toggle-editmsg’) + This command toggles between the ‘-C’ and ‘-c’ options of the merge + action at point. These options both specify a commit whose message + should be reused. The lower-case variant instructs Git to invoke + the editor when creating the merge, allowing the user to edit the + message. + + +File: magit.info, Node: Information About In-Progress Rebase, Prev: Editing Rebase Sequences, Up: Rebasing + +6.9.2 Information About In-Progress Rebase +------------------------------------------ + +While a rebase sequence is in progress, the status buffer features a +section that lists the commits that have already been applied as well as +the commits that still have to be applied. + + The commits are split in two halves. When rebase stops at a commit, +either because the user has to deal with a conflict or because s/he +explicitly requested that rebase stops at that commit, then point is +placed on the commit that separates the two groups, i.e., on ‘HEAD’. +The commits above it have not been applied yet, while the ‘HEAD’ and the +commits below it have already been applied. In between these two groups +of applied and yet-to-be applied commits, there sometimes is a commit +which has been dropped. + + Each commit is prefixed with a word and these words are additionally +shown in different colors to indicate the status of the commits. + + The following colors are used: + + • Commits that use the same foreground color as the ‘default’ face + have not been applied yet. + + • Yellow commits have some special relationship to the commit rebase + stopped at. This is used for the words "join", "goal", "same" and + "work" (see below). + + • Gray commits have already been applied. + + • The blue commit is the ‘HEAD’ commit. + + • The green commit is the commit the rebase sequence stopped at. If + this is the same commit as ‘HEAD’ (e.g., because you haven’t done + anything yet after rebase stopped at the commit, then this commit + is shown in blue, not green). There can only be a green *and* a + blue commit at the same time, if you create one or more new commits + after rebase stops at a commit. + + • Red commits have been dropped. They are shown for reference only, + e.g., to make it easier to diff. + + Of course these colors are subject to the color-theme in use. + + The following words are used: + + • Commits prefixed with ‘pick’, ‘reword’, ‘edit’, ‘squash’, and + ‘fixup’ have not been applied yet. These words have the same + meaning here as they do in the buffer used to edit the rebase + sequence. See *note Editing Rebase Sequences::. When the + ‘--rebase-merges’ option was specified, ‘reset’, ‘label’, and + ‘merge’ lines may also be present. + + • Commits prefixed with ‘done’ and ‘onto’ have already been applied. + It is possible for such a commit to be the ‘HEAD’, in which case it + is blue. Otherwise it is grey. + + • The commit prefixed with ‘onto’ is the commit on top of which + all the other commits are being re-applied. This commit + itself did not have to be re-applied, it is the commit rebase + did rewind to before starting to re-apply other commits. + + • Commits prefixed with ‘done’ have already been re-applied. + This includes commits that have been re-applied but also new + commits that you have created during the rebase. + + • All other commits, those not prefixed with any of the above words, + are in some way related to the commit at which rebase stopped. + + To determine whether a commit is related to the stopped-at commit + their hashes, trees and patch-ids (1) are being compared. The + commit message is not used for this purpose. + + Generally speaking commits that are related to the stopped-at + commit can have any of the used colors, though not all color/word + combinations are possible. + + Words used for stopped-at commits are: + + • When a commit is prefixed with ‘void’, then that indicates + that Magit knows for sure that all the changes in that commit + have been applied using several new commits. This commit is + no longer reachable from ‘HEAD’, and it also isn’t one of the + commits that will be applied when resuming the session. + + • When a commit is prefixed with ‘join’, then that indicates + that the rebase sequence stopped at that commit due to a + conflict - you now have to join (merge) the changes with what + has already been applied. In a sense this is the commit + rebase stopped at, but while its effect is already in the + index and in the worktree (with conflict markers), the commit + itself has not actually been applied yet (it isn’t the + ‘HEAD’). So it is shown in yellow, like the other commits + that still have to be applied. + + • When a commit is prefixed with ‘stop’ or a _blue_ or _green_ + ‘same’, then that indicates that rebase stopped at this + commit, that it is still applied or has been applied again, + and that at least its patch-id is unchanged. + + • When a commit is prefixed with ‘stop’, then that + indicates that rebase stopped at that commit because you + requested that earlier, and its patch-id is unchanged. + It might even still be the exact same commit. + + • When a commit is prefixed with a _blue_ or _green_ + ‘same’, then that indicates that while its tree or hash + changed, its patch-id did not. If it is blue, then it is + the ‘HEAD’ commit (as always for blue). When it is + green, then it no longer is ‘HEAD’ because other commit + have been created since (but before continuing the + rebase). + + • When a commit is prefixed with ‘goal’, a _yellow_ ‘same,’ or + ‘work’, then that indicates that rebase applied that commit + but that you then reset ‘HEAD’ to an earlier commit (likely to + split it up into multiple commits), and that there are some + uncommitted changes remaining which likely (but not + necessarily) originate from that commit. + + • When a commit is prefixed with ‘goal’, then that + indicates that it is still possible to create a new + commit with the exact same tree (the "goal") without + manually editing any files, by committing the index, or + by staging all changes and then committing that. This is + the case when the original tree still exists in the index + or worktree in untainted form. + + • When a commit is prefixed with a yellow ‘same’, then that + indicates that it is no longer possible to create a + commit with the exact same tree, but that it is still + possible to create a commit with the same patch-id. This + would be the case if you created a new commit with other + changes, but the changes from the original commit still + exist in the index or working tree in untainted form. + + • When a commit is prefixed with ‘work’, then that + indicates that you reset ‘HEAD’ to an earlier commit, and + that there are some staged and/or unstaged changes + (likely, but not necessarily) originating from that + commit. However it is no longer possible to create a new + commit with the same tree or at least the same patch-id + because you have already made other changes. + + • When a commit is prefixed with ‘poof’ or ‘gone’, then that + indicates that rebase applied that commit but that you then + reset ‘HEAD’ to an earlier commit (likely to split it up into + multiple commits), and that there are no uncommitted changes. + + • When a commit is prefixed with ‘poof’, then that + indicates that it is no longer reachable from ‘HEAD’, but + that it has been replaced with one or more commits, which + together have the exact same effect. + + • When a commit is prefixed with ‘gone’, then that + indicates that it is no longer reachable from ‘HEAD’ and + that we also cannot determine whether its changes are + still in effect in one or more new commits. They might + be, but if so, then there must also be other changes + which makes it impossible to know for sure. + + Do not worry if you do not fully understand the above. That’s okay, +you will acquire a good enough understanding through practice. + + For other sequence operations such as cherry-picking, a similar +section is displayed, but they lack some of the features described +above, due to limitations in the git commands used to implement them. +Most importantly these sequences only support "picking" a commit but not +other actions such as "rewording", and they do not keep track of the +commits which have already been applied. + + ---------- Footnotes ---------- + + (1) The patch-id is a hash of the _changes_ introduced by a commit. +It differs from the hash of the commit itself, which is a hash of the +result of applying that change (i.e., the resulting trees and blobs) as +well as author and committer information, the commit message, and the +hashes of the parents of the commit. The patch-id hash on the other +hand is created only from the added and removed lines, even line numbers +and whitespace changes are ignored when calculating this hash. The +patch-ids of two commits can be used to answer the question "Do these +commits make the same change?". + + +File: magit.info, Node: Cherry Picking, Next: Resetting, Prev: Rebasing, Up: Manipulating + +6.10 Cherry Picking +=================== + +Also see *note (gitman)git-cherry-pick::. + +‘A’ (‘magit-cherry-pick’) + This transient prefix command binds the following suffix commands + along with the appropriate infix arguments and displays them in a + temporary buffer until a suffix is invoked. + + When no cherry-pick or revert is in progress, then the transient +features the following suffix commands. + +‘A A’ (‘magit-cherry-copy’) + This command copies COMMITS from another branch onto the current + branch. If the region selects multiple commits, then those are + copied, without prompting. Otherwise the user is prompted for a + commit or range, defaulting to the commit at point. + +‘A a’ (‘magit-cherry-apply’) + This command applies the changes in COMMITS from another branch + onto the current branch. If the region selects multiple commits, + then those are used, without prompting. Otherwise the user is + prompted for a commit or range, defaulting to the commit at point. + + This command also has a top-level binding, which can be invoked + without using the transient by typing ‘a’ at the top-level. + + The following commands not only apply some commits to some branch, +but also remove them from some other branch. The removal is performed +using either ‘git-update-ref’ or if necessary ‘git-rebase’. Both +applying commits as well as removing them using ‘git-rebase’ can lead to +conflicts. If that happens, then these commands abort and you not only +have to resolve the conflicts but also finish the process the same way +you would have to if these commands didn’t exist at all. + +‘A h’ (‘magit-cherry-harvest’) + This command moves the selected COMMITS that must be located on + another BRANCH onto the current branch instead, removing them from + the former. When this command succeeds, then the same branch is + current as before. + + Applying the commits on the current branch or removing them from + the other branch can lead to conflicts. When that happens, then + this command stops and you have to resolve the conflicts and then + finish the process manually. + +‘A d’ (‘magit-cherry-donate’) + This command moves the selected COMMITS from the current branch + onto another existing BRANCH, removing them from the former. When + this command succeeds, then the same branch is current as before. + ‘HEAD’ is allowed to be detached initially. + + Applying the commits on the other branch or removing them from the + current branch can lead to conflicts. When that happens, then this + command stops and you have to resolve the conflicts and then finish + the process manually. + +‘A n’ (‘magit-cherry-spinout’) + This command moves the selected COMMITS from the current branch + onto a new branch BRANCH, removing them from the former. When this + command succeeds, then the same branch is current as before. + + Applying the commits on the other branch or removing them from the + current branch can lead to conflicts. When that happens, then this + command stops and you have to resolve the conflicts and then finish + the process manually. + +‘A s’ (‘magit-cherry-spinoff’) + This command moves the selected COMMITS from the current branch + onto a new branch BRANCH, removing them from the former. When this + command succeeds, then the new branch is checked out. + + Applying the commits on the other branch or removing them from the + current branch can lead to conflicts. When that happens, then this + command stops and you have to resolve the conflicts and then finish + the process manually. + + When a cherry-pick or revert is in progress, then the transient +instead features the following suffix commands. + +‘A A’ (‘magit-sequence-continue’) + Resume the current cherry-pick or revert sequence. + +‘A s’ (‘magit-sequence-skip’) + Skip the stopped at commit during a cherry-pick or revert sequence. + +‘A a’ (‘magit-sequence-abort’) + Abort the current cherry-pick or revert sequence. This discards + all changes made since the sequence started. + +* Menu: + +* Reverting:: + + +File: magit.info, Node: Reverting, Up: Cherry Picking + +6.10.1 Reverting +---------------- + +‘V’ (‘magit-revert’) + This transient prefix command binds the following suffix commands + along with the appropriate infix arguments and displays them in a + temporary buffer until a suffix is invoked. + + When no cherry-pick or revert is in progress, then the transient +features the following suffix commands. + +‘V V’ (‘magit-revert-and-commit’) + Revert a commit by creating a new commit. Prompt for a commit, + defaulting to the commit at point. If the region selects multiple + commits, then revert all of them, without prompting. + +‘V v’ (‘magit-revert-no-commit’) + Revert a commit by applying it in reverse to the working tree. + Prompt for a commit, defaulting to the commit at point. If the + region selects multiple commits, then revert all of them, without + prompting. + + When a cherry-pick or revert is in progress, then the transient +instead features the following suffix commands. + +‘V V’ (‘magit-sequence-continue’) + Resume the current cherry-pick or revert sequence. + +‘V s’ (‘magit-sequence-skip’) + Skip the stopped at commit during a cherry-pick or revert sequence. + +‘V a’ (‘magit-sequence-abort’) + Abort the current cherry-pick or revert sequence. This discards + all changes made since the sequence started. + + +File: magit.info, Node: Resetting, Next: Stashing, Prev: Cherry Picking, Up: Manipulating + +6.11 Resetting +============== + +Also see *note (gitman)git-reset::. + +‘x’ (‘magit-reset-quickly’) + Reset the ‘HEAD’ and index to some commit read from the user and + defaulting to the commit at point, and possibly also reset the + working tree. With a prefix argument reset the working tree + otherwise don’t. + +‘X m’ (‘magit-reset-mixed’) + Reset the ‘HEAD’ and index to some commit read from the user and + defaulting to the commit at point. The working tree is kept as-is. + +‘X s’ (‘magit-reset-soft’) + Reset the ‘HEAD’ to some commit read from the user and defaulting + to the commit at point. The index and the working tree are kept + as-is. + +‘X h’ (‘magit-reset-hard’) + Reset the ‘HEAD’, index, and working tree to some commit read from + the user and defaulting to the commit at point. + +‘X k’ (‘magit-reset-keep’) + Reset the ‘HEAD’, index, and working tree to some commit read from + the user and defaulting to the commit at point. Uncommitted + changes are kept as-is. + +‘X i’ (‘magit-reset-index’) + Reset the index to some commit read from the user and defaulting to + the commit at point. Keep the ‘HEAD’ and working tree as-is, so if + the commit refers to the ‘HEAD’, then this effectively unstages all + changes. + +‘X w’ (‘magit-reset-worktree’) + Reset the working tree to some commit read from the user and + defaulting to the commit at point. Keep the ‘HEAD’ and index + as-is. + +‘X f’ (‘magit-file-checkout’) + Update file in the working tree and index to the contents from a + revision. Both the revision and file are read from the user. + + +File: magit.info, Node: Stashing, Prev: Resetting, Up: Manipulating + +6.12 Stashing +============= + +Also see *note (gitman)git-stash::. + +‘z’ (‘magit-stash’) + This transient prefix command binds the following suffix commands + along with the appropriate infix arguments and displays them in a + temporary buffer until a suffix is invoked. + +‘z z’ (‘magit-stash-both’) + Create a stash of the index and working tree. Untracked files are + included according to infix arguments. One prefix argument is + equivalent to ‘--include-untracked’ while two prefix arguments are + equivalent to ‘--all’. + +‘z i’ (‘magit-stash-index’) + Create a stash of the index only. Unstaged and untracked changes + are not stashed. + +‘z w’ (‘magit-stash-worktree’) + Create a stash of unstaged changes in the working tree. Untracked + files are included according to infix arguments. One prefix + argument is equivalent to ‘--include-untracked’ while two prefix + arguments are equivalent to ‘--all’. + +‘z x’ (‘magit-stash-keep-index’) + Create a stash of the index and working tree, keeping index intact. + Untracked files are included according to infix arguments. One + prefix argument is equivalent to ‘--include-untracked’ while two + prefix arguments are equivalent to ‘--all’. + +‘z Z’ (‘magit-snapshot-both’) + Create a snapshot of the index and working tree. Untracked files + are included according to infix arguments. One prefix argument is + equivalent to ‘--include-untracked’ while two prefix arguments are + equivalent to ‘--all’. + +‘z I’ (‘magit-snapshot-index’) + Create a snapshot of the index only. Unstaged and untracked + changes are not stashed. + +‘z W’ (‘magit-snapshot-worktree’) + Create a snapshot of unstaged changes in the working tree. + Untracked files are included according to infix arguments. One + prefix argument is equivalent to ‘--include-untracked’ while two + prefix arguments are equivalent to ‘--all’-. + +‘z a’ (‘magit-stash-apply’) + Apply a stash to the working tree. + + First try ‘git stash apply --index’, which tries to preserve the + index stored in the stash, if any. This may fail because applying + the stash could result in conflicts and those have to be stored in + the index, making it impossible to also store the stash’s index + there as well. + + If the above failed, then try ‘git stash apply’. This fails (with + or without ‘--index’) if there are any uncommitted changes to files + that are also modified in the stash. + + If both of the above failed, then apply using ‘git apply’. If + there are no conflicting files, use ‘--3way’. If there are + conflicting files, then using ‘--3way’ requires that those files + are staged first, which may be undesirable, so prompt the user + whether to use ‘--3way’ or ‘--reject’. + + Customize ‘magit-no-confirm’ if you want to always use ‘--3way’, + without being prompted. + +‘z p’ (‘magit-stash-pop’) + Apply a stash to the working tree. On complete success (if the + stash can be applied without any conflicts, and while preserving + the stash’s index) then remove the stash from stash list. + + First try ‘git stash pop --index’, which tries to preserve the + index stored in the stash, if any. This may fail because applying + the stash could result in conflicts and those have to be stored in + the index, making it impossible to also store the stash’s index + there as well. + + If the above failed, then try ‘git stash apply’. This fails (with + or without ‘--index’) if there are any uncommitted changes to files + that are also modified in the stash. + + If both of the above failed, then apply using ‘git apply’. If + there are no conflicting files, use ‘--3way’. If there are + conflicting files, then using ‘--3way’ requires that those files + are staged first, which may be undesirable, so prompt the user + whether to use ‘--3way’ or ‘--reject’. + + Customize ‘magit-no-confirm’ if you want to always use ‘--3way’, + without being prompted. + +‘z k’ (‘magit-stash-drop’) + Remove a stash from the stash list. When the region is active, + offer to drop all contained stashes. + +‘z v’ (‘magit-stash-show’) + Show all diffs of a stash in a buffer. + +‘z b’ (‘magit-stash-branch’) + Create and checkout a new branch from an existing stash. The new + branch starts at the commit that was current when the stash was + created. + +‘z B’ (‘magit-stash-branch-here’) + Create and checkout a new branch from an existing stash. Use the + current branch or ‘HEAD’ as the starting-point of the new branch. + Then apply the stash, dropping it if it applies cleanly. + +‘z f’ (‘magit-stash-format-patch’) + Create a patch from STASH. + +‘k’ (‘magit-stash-clear’) + Remove all stashes saved in REF’s reflog by deleting REF. + +‘z l’ (‘magit-stash-list’) + List all stashes in a buffer. + + -- User Option: magit-stashes-margin + This option specifies whether the margin is initially shown in + stashes buffers and how it is formatted. + + The value has the form ‘(INIT STYLE WIDTH AUTHOR AUTHOR-WIDTH)’. + + • If INIT is non-nil, then the margin is shown initially. + • STYLE controls how to format the author or committer date. It + can be one of ‘age’ (to show the age of the commit), + ‘age-abbreviated’ (to abbreviate the time unit to a + character), or a string (suitable for ‘format-time-string’) to + show the actual date. Option + ‘magit-log-margin-show-committer-date’ controls which date is + being displayed. + • WIDTH controls the width of the margin. This exists for + forward compatibility and currently the value should not be + changed. + • AUTHOR controls whether the name of the author is also shown + by default. + • AUTHOR-WIDTH has to be an integer. When the name of the + author is shown, then this specifies how much space is used to + do so. + + +File: magit.info, Node: Transferring, Next: Miscellaneous, Prev: Manipulating, Up: Top + +7 Transferring +************** + +* Menu: + +* Remotes:: +* Fetching:: +* Pulling:: +* Pushing:: +* Plain Patches:: +* Maildir Patches:: + + +File: magit.info, Node: Remotes, Next: Fetching, Up: Transferring + +7.1 Remotes +=========== + +* Menu: + +* Remote Commands:: +* Remote Git Variables:: + + +File: magit.info, Node: Remote Commands, Next: Remote Git Variables, Up: Remotes + +7.1.1 Remote Commands +--------------------- + +The transient prefix command ‘magit-remote’ is used to add remotes and +to make changes to existing remotes. This command only deals with +remotes themselves, not with branches or the transfer of commits. Those +features are available from separate transient commands. + + Also see *note (gitman)git-remote::. + +‘M’ (‘magit-remote’) + This transient prefix command binds the following suffix commands + and displays them in a temporary buffer until a suffix is invoked. + + By default it also binds and displays the values of some + remote-related Git variables and allows changing their values. + + -- User Option: magit-remote-direct-configure + This option controls whether remote-related Git variables are + accessible directly from the transient ‘magit-remote’. + + If ‘t’ (the default) and a local branch is checked out, then + ‘magit-remote’ features the variables for the upstream remote of + that branch, or if ‘HEAD’ is detached, for ‘origin’, provided that + exists. + + If ‘nil’, then ‘magit-remote-configure’ has to be used to do so. + +‘M C’ (‘magit-remote-configure’) + This transient prefix command binds commands that set the value of + remote-related variables and displays them in a temporary buffer + until the transient is exited. + + With a prefix argument, this command always prompts for a remote. + + Without a prefix argument this depends on whether it was invoked as + a suffix of ‘magit-remote’ and on the + ‘magit-remote-direct-configure’ option. If ‘magit-remote’ already + displays the variables for the upstream, then it does not make + sense to invoke another transient that displays them for the same + remote. In that case this command prompts for a remote. + + The variables are described in *note Remote Git Variables::. + +‘M a’ (‘magit-remote-add’) + This command add a remote and fetches it. The remote name and url + are read in the minibuffer. + +‘M r’ (‘magit-remote-rename’) + This command renames a remote. Both the old and the new names are + read in the minibuffer. + +‘M u’ (‘magit-remote-set-url’) + This command changes the url of a remote. Both the remote and the + new url are read in the minibuffer. + +‘M k’ (‘magit-remote-remove’) + This command deletes a remote, read in the minibuffer. + +‘M p’ (‘magit-remote-prune’) + This command removes stale remote-tracking branches for a remote + read in the minibuffer. + +‘M P’ (‘magit-remote-prune-refspecs’) + This command removes stale refspecs for a remote read in the + minibuffer. + + A refspec is stale if there no longer exists at least one branch on + the remote that would be fetched due to that refspec. A stale + refspec is problematic because its existence causes Git to refuse + to fetch according to the remaining non-stale refspecs. + + If only stale refspecs remain, then this command offers to either + delete the remote or to replace the stale refspecs with the default + refspec ("+refs/heads/*:refs/remotes/REMOTE/*"). + + This command also removes the remote-tracking branches that were + created due to the now stale refspecs. Other stale branches are + not removed. + + -- User Option: magit-remote-add-set-remote.pushDefault + This option controls whether the user is asked whether they want to + set ‘remote.pushDefault’ after adding a remote. + + If ‘ask’, then users is always ask. If ‘ask-if-unset’, then the + user is only if the variable isn’t set already. If ‘nil’, then the + user isn’t asked and the variable isn’t set. If the value is a + string, then the variable is set without the user being asked, + provided that the name of the added remote is equal to that string + and the variable isn’t already set. + + +File: magit.info, Node: Remote Git Variables, Prev: Remote Commands, Up: Remotes + +7.1.2 Remote Git Variables +-------------------------- + +These variables can be set from the transient prefix command +‘magit-remote-configure’. By default they can also be set from +‘magit-remote’. See *note Remote Commands::. + + -- Variable: remote.NAME.url + This variable specifies the url of the remote named NAME. It can + have multiple values. + + -- Variable: remote.NAME.fetch + The refspec used when fetching from the remote named NAME. It can + have multiple values. + + -- Variable: remote.NAME.pushurl + This variable specifies the url used for pushing to the remote + named NAME. If it is not specified, then ‘remote.NAME.url’ is used + instead. It can have multiple values. + + -- Variable: remote.NAME.push + The refspec used when pushing to the remote named NAME. It can + have multiple values. + + -- Variable: remote.NAME.tagOpts + This variable specifies what tags are fetched by default. If the + value is ‘--no-tags’ then no tags are fetched. If the value is + ‘--tags’, then all tags are fetched. If this variable has no + value, then only tags are fetched that are reachable from fetched + branches. + + +File: magit.info, Node: Fetching, Next: Pulling, Prev: Remotes, Up: Transferring + +7.2 Fetching +============ + +Also see *note (gitman)git-fetch::. For information about the upstream +and the push-remote, see *note The Two Remotes::. + +‘f’ (‘magit-fetch’) + This transient prefix command binds the following suffix commands + along with the appropriate infix arguments and displays them in a + temporary buffer until a suffix is invoked. + +‘f p’ (‘magit-fetch-from-pushremote’) + This command fetches from the current push-remote. + + With a prefix argument or when the push-remote is either not + configured or unusable, then let the user first configure the + push-remote. + +‘f u’ (‘magit-fetch-from-upstream’) + This command fetch from the upstream of the current branch. + + If the upstream is configured for the current branch and names an + existing remote, then use that. Otherwise try to use another + remote: If only a single remote is configured, then use that. + Otherwise if a remote named "origin" exists, then use that. + + If no remote can be determined, then this command is not available + from the ‘magit-fetch’ transient prefix and invoking it directly + results in an error. + +‘f e’ (‘magit-fetch-other’) + This command fetch from a repository read from the minibuffer. + +‘f o’ (‘magit-fetch-branch’) + This command fetches a branch from a remote, both of which are read + from the minibuffer. + +‘f r’ (‘magit-fetch-refspec’) + This command fetches from a remote using an explicit refspec, both + of which are read from the minibuffer. + +‘f a’ (‘magit-fetch-all’) + This command fetches from all remotes. + +‘f m’ (‘magit-fetch-modules’) + This command fetches all submodules. With a prefix argument, it + acts as a transient prefix command, allowing the caller to set + options. + + -- User Option: magit-pull-or-fetch + By default fetch and pull commands are available from separate + transient prefix command. Setting this to ‘t’ adds some (but not + all) of the above suffix commands to the ‘magit-pull’ transient. + + If you do that, then you might also want to change the key binding + for these prefix commands, e.g.: + + (setq magit-pull-or-fetch t) + (define-key magit-mode-map "f" 'magit-pull) ; was magit-fetch + (define-key magit-mode-map "F" nil) ; was magit-pull + + +File: magit.info, Node: Pulling, Next: Pushing, Prev: Fetching, Up: Transferring + +7.3 Pulling +=========== + +Also see *note (gitman)git-pull::. For information about the upstream +and the push-remote, see *note The Two Remotes::. + +‘F’ (‘magit-pull’) + This transient prefix command binds the following suffix commands + and displays them in a temporary buffer until a suffix is invoked. + +‘F p’ (‘magit-pull-from-pushremote’) + This command pulls from the push-remote of the current branch. + + With a prefix argument or when the push-remote is either not + configured or unusable, then let the user first configure the + push-remote. + +‘F u’ (‘magit-pull-from-upstream’) + This command pulls from the upstream of the current branch. + + With a prefix argument or when the upstream is either not + configured or unusable, then let the user first configure the + upstream. + +‘F e’ (‘magit-pull-branch’) + This command pulls from a branch read in the minibuffer. + + +File: magit.info, Node: Pushing, Next: Plain Patches, Prev: Pulling, Up: Transferring + +7.4 Pushing +=========== + +Also see *note (gitman)git-push::. For information about the upstream +and the push-remote, see *note The Two Remotes::. + +‘P’ (‘magit-push’) + This transient prefix command binds the following suffix commands + along with the appropriate infix arguments and displays them in a + temporary buffer until a suffix is invoked. + +‘P p’ (‘magit-push-current-to-pushremote’) + This command pushes the current branch to its push-remote. + + With a prefix argument or when the push-remote is either not + configured or unusable, then let the user first configure the + push-remote. + +‘P u’ (‘magit-push-current-to-upstream’) + This command pushes the current branch to its upstream branch. + + With a prefix argument or when the upstream is either not + configured or unusable, then let the user first configure the + upstream. + +‘P e’ (‘magit-push-current’) + This command pushes the current branch to a branch read in the + minibuffer. + +‘P o’ (‘magit-push-other’) + This command pushes an arbitrary branch or commit somewhere. Both + the source and the target are read in the minibuffer. + +‘P r’ (‘magit-push-refspecs’) + This command pushes one or multiple refspecs to a remote, both of + which are read in the minibuffer. + + To use multiple refspecs, separate them with commas. Completion is + only available for the part before the colon, or when no colon is + used. + +‘P m’ (‘magit-push-matching’) + This command pushes all matching branches to another repository. + + If only one remote exists, then push to that. Otherwise prompt for + a remote, offering the remote configured for the current branch as + default. + +‘P t’ (‘magit-push-tags’) + This command pushes all tags to another repository. + + If only one remote exists, then push to that. Otherwise prompt for + a remote, offering the remote configured for the current branch as + default. + +‘P T’ (‘magit-push-tag’) + This command pushes a tag to another repository. + + One of the infix arguments, ‘--force-with-lease’, deserves a word of +caution. It is passed without a value, which means "permit a force push +as long as the remote-tracking branches match their counterparts on the +remote end". If you’ve set up a tool to do automatic fetches (Magit +itself does not provide such functionality), using ‘--force-with-lease’ +can be dangerous because you don’t actually control or know the state of +the remote-tracking refs. In that case, you should consider setting +‘push.useForceIfIncludes’ to ‘true’ (available since Git 2.30). + + Two more push commands exist, which by default are not available from +the push transient. See their doc-strings for instructions on how to +add them to the transient. + + -- Command: magit-push-implicitly args + This command pushes somewhere without using an explicit refspec. + + This command simply runs ‘git push -v [ARGS]’. ARGS are the infix + arguments. No explicit refspec arguments are used. Instead the + behavior depends on at least these Git variables: ‘push.default’, + ‘remote.pushDefault’, ‘branch.<branch>.pushRemote’, + ‘branch.<branch>.remote’, ‘branch.<branch>.merge’, and + ‘remote.<remote>.push’. + + If you add this suffix to a transient prefix without explicitly + specifying the description, then an attempt is made to predict what + this command will do. For example: + + (transient-insert-suffix 'magit-push \"p\" + '(\"i\" magit-push-implicitly))" + + -- Command: magit-push-to-remote remote args + This command pushes to the remote REMOTE without using an explicit + refspec. The remote is read in the minibuffer. + + This command simply runs ‘git push -v [ARGS] REMOTE’. ARGS are the + infix arguments. No refspec arguments are used. Instead the + behavior depends on at least these Git variables: ‘push.default’, + ‘remote.pushDefault’, ‘branch.<branch>.pushRemote’, + ‘branch.<branch>.remote’, ‘branch.<branch>.merge’, and + ‘remote.<remote>.push’. + + +File: magit.info, Node: Plain Patches, Next: Maildir Patches, Prev: Pushing, Up: Transferring + +7.5 Plain Patches +================= + +‘W’ (‘magit-patch’) + This transient prefix command binds the following suffix commands + along with the appropriate infix arguments and displays them in a + temporary buffer until a suffix is invoked. + +‘W c’ (‘magit-patch-create’) + This command creates patches for a set commits. If the region + marks several commits, then it creates patches for all of them. + Otherwise it functions as a transient prefix command, which + features several infix arguments and binds itself as a suffix + command. When this command is invoked as a suffix of itself, then + it creates a patch using the specified infix arguments. + +‘w a’ (‘magit-patch-apply’) + This command applies a patch. This is a transient prefix command, + which features several infix arguments and binds itself as a suffix + command. When this command is invoked as a suffix of itself, then + it applies a patch using the specified infix arguments. + +‘W s’ (‘magit-patch-save’) + This command creates a patch from the current diff. + + Inside ‘magit-diff-mode’ or ‘magit-revision-mode’ buffers, ‘C-x + C-w’ is also bound to this command. + + It is also possible to save a plain patch file by using ‘C-x C-w’ +inside a ‘magit-diff-mode’ or ‘magit-revision-mode’ buffer. + + +File: magit.info, Node: Maildir Patches, Prev: Plain Patches, Up: Transferring + +7.6 Maildir Patches +=================== + +Also see *note (gitman)git-am::. and *note (gitman)git-apply::. + +‘w’ (‘magit-am’) + This transient prefix command binds the following suffix commands + along with the appropriate infix arguments and displays them in a + temporary buffer until a suffix is invoked. + +‘w w’ (‘magit-am-apply-patches’) + This command applies one or more patches. If the region marks + files, then those are applied as patches. Otherwise this command + reads a file-name in the minibuffer, defaulting to the file at + point. + +‘w m’ (‘magit-am-apply-maildir’) + This command applies patches from a maildir. + +‘w a’ (‘magit-patch-apply’) + This command applies a plain patch. For a longer description see + *note Plain Patches::. This command is only available from the + ‘magit-am’ transient for historic reasons. + + When an "am" operation is in progress, then the transient instead +features the following suffix commands. + +‘w w’ (‘magit-am-continue’) + This command resumes the current patch applying sequence. + +‘w s’ (‘magit-am-skip’) + This command skips the stopped at patch during a patch applying + sequence. + +‘w a’ (‘magit-am-abort’) + This command aborts the current patch applying sequence. This + discards all changes made since the sequence started. + + +File: magit.info, Node: Miscellaneous, Next: Customizing, Prev: Transferring, Up: Top + +8 Miscellaneous +*************** + +* Menu: + +* Tagging:: +* Notes:: +* Submodules:: +* Subtree:: +* Worktree:: +* Sparse checkouts:: +* Bundle:: +* Common Commands:: +* Wip Modes:: +* Commands for Buffers Visiting Files:: +* Minor Mode for Buffers Visiting Blobs:: + + +File: magit.info, Node: Tagging, Next: Notes, Up: Miscellaneous + +8.1 Tagging +=========== + +Also see *note (gitman)git-tag::. + +‘t’ (‘magit-tag’) + This transient prefix command binds the following suffix commands + along with the appropriate infix arguments and displays them in a + temporary buffer until a suffix is invoked. + +‘t t’ (‘magit-tag-create’) + This command creates a new tag with the given NAME at REV. With a + prefix argument it creates an annotated tag. + +‘t r’ (‘magit-tag-release’) + This commands creates a release tag. It assumes that release tags + match ‘magit-release-tag-regexp’. + + First it prompts for the name of the new tag using the highest + existing tag as initial input and leaving it to the user to + increment the desired part of the version string. If you use + unconventional release tags or version numbers (e.g., + ‘v1.2.3-custom.1’), you can set the ‘magit-release-tag-regexp’ and + ‘magit-tag-version-regexp-alist’ variables. + + If ‘--annotate’ is enabled then it prompts for the message of the + new tag. The proposed tag message is based on the message of the + highest tag, provided that that contains the corresponding version + string and substituting the new version string for that. Otherwise + it proposes something like "Foo-Bar 1.2.3", given, for example, a + TAG "v1.2.3" and a repository located at something like + "/path/to/foo-bar". + +‘t k’ (‘magit-tag-delete’) + This command deletes one or more tags. If the region marks + multiple tags (and nothing else), then it offers to delete those. + Otherwise, it prompts for a single tag to be deleted, defaulting to + the tag at point. + +‘t p’ (‘magit-tag-prune’) + This command offers to delete tags missing locally from REMOTE, and + vice versa. + + +File: magit.info, Node: Notes, Next: Submodules, Prev: Tagging, Up: Miscellaneous + +8.2 Notes +========= + +Also see *note (gitman)git-notes::. + +‘T’ (‘magit-notes’) + This transient prefix command binds the following suffix commands + along with the appropriate infix arguments and displays them in a + temporary buffer until a suffix is invoked. + +‘T T’ (‘magit-notes-edit’) + Edit the note attached to a commit, defaulting to the commit at + point. + + By default use the value of Git variable ‘core.notesRef’ or + "refs/notes/commits" if that is undefined. + +‘T r’ (‘magit-notes-remove’) + Remove the note attached to a commit, defaulting to the commit at + point. + + By default use the value of Git variable ‘core.notesRef’ or + "refs/notes/commits" if that is undefined. + +‘T p’ (‘magit-notes-prune’) + Remove notes about unreachable commits. + + It is possible to merge one note ref into another. That may result +in conflicts which have to resolved in the temporary worktree +".git/NOTES_MERGE_WORKTREE". + +‘T m’ (‘magit-notes-merge’) + Merge the notes of a ref read from the user into the current notes + ref. The current notes ref is the value of Git variable + ‘core.notesRef’ or "refs/notes/commits" if that is undefined. + + When a notes merge is in progress then the transient features the +following suffix commands, instead of those listed above. + +‘T c’ (‘magit-notes-merge-commit’) + Commit the current notes ref merge, after manually resolving + conflicts. + +‘T a’ (‘magit-notes-merge-abort’) + Abort the current notes ref merge. + + The following variables control what notes reference ‘magit-notes-*’, +‘git notes’ and ‘git show’ act on and display. Both the local and +global values are displayed and can be modified. + + -- Variable: core.notesRef + This variable specifies the notes ref that is displayed by default + and which commands act on by default. + + -- Variable: notes.displayRef + This variable specifies additional notes ref to be displayed in + addition to the ref specified by ‘core.notesRef’. It can have + multiple values and may end with ‘*’ to display all refs in the + ‘refs/notes/’ namespace (or ‘**’ if some names contain slashes). + + +File: magit.info, Node: Submodules, Next: Subtree, Prev: Notes, Up: Miscellaneous + +8.3 Submodules +============== + +Also see *note (gitman)git-submodule::. + +* Menu: + +* Listing Submodules:: +* Submodule Transient:: + + +File: magit.info, Node: Listing Submodules, Next: Submodule Transient, Up: Submodules + +8.3.1 Listing Submodules +------------------------ + +The command ‘magit-list-submodules’ displays a list of the current +repository’s submodules in a separate buffer. It’s also possible to +display information about submodules directly in the status buffer of +the super-repository by adding ‘magit-insert-modules’ to the hook +‘magit-status-sections-hook’ as described in *note Status Module +Sections::. + + -- Command: magit-list-submodules + This command displays a list of the current repository’s populated + submodules in a separate buffer. + + It can be invoked by pressing ‘RET’ on the section titled + "Modules". + + -- User Option: magit-submodule-list-columns + This option controls what columns are displayed by the command + ‘magit-list-submodules’ and how they are displayed. + + Each element has the form ‘(HEADER WIDTH FORMAT PROPS)’. + + HEADER is the string displayed in the header. WIDTH is the width + of the column. FORMAT is a function that is called with one + argument, the repository identification (usually its basename), and + with ‘default-directory’ bound to the toplevel of its working tree. + It has to return a string to be inserted or nil. PROPS is an alist + that supports the keys ‘:right-align’, ‘:pad-right’ and ‘:sort’. + + The ‘:sort’ function has a weird interface described in the + docstring of ‘tabulated-list--get-sort’. Alternatively ‘<’ and + ‘magit-repolist-version<’ can be used as those functions are + automatically replaced with functions that satisfy the interface. + Set ‘:sort’ to ‘nil’ to inhibit sorting; if unspecified, then the + column is sortable using the default sorter. + + You may wish to display a range of numeric columns using just one + character per column and without any padding between columns, in + which case you should use an appropriate HEADER, set WIDTH to 1, + and set ‘:pad-right’ to 9. ‘+’ is substituted for numbers higher + than 9. + + +File: magit.info, Node: Submodule Transient, Prev: Listing Submodules, Up: Submodules + +8.3.2 Submodule Transient +------------------------- + +‘o’ (‘magit-submodule’) + This transient prefix command binds the following suffix commands + along with the appropriate infix arguments and displays them in a + temporary buffer until a suffix is invoked. + + Some of the below commands default to act on the modules that are +selected using the region. For brevity their description talk about +"the selected modules", but if no modules are selected, then they act on +the current module instead, or if point isn’t on a module, then the read +a single module to act on. With a prefix argument these commands ignore +the selection and the current module and instead act on all suitable +modules. + +‘o a’ (‘magit-submodule-add’) + This commands adds the repository at URL as a module. Optional + PATH is the path to the module relative to the root of the + super-project. If it is nil then the path is determined based on + URL. + +‘o r’ (‘magit-submodule-register’) + This command registers the selected modules by copying their urls + from ".gitmodules" to "$GIT_DIR/config". These values can then be + edited before running ‘magit-submodule-populate’. If you don’t + need to edit any urls, then use the latter directly. + +‘o p’ (‘magit-submodule-populate’) + This command creates the working directory or directories of the + selected modules, checking out the recorded commits. + +‘o u’ (‘magit-submodule-update’) + This command updates the selected modules checking out the recorded + commits. + +‘o s’ (‘magit-submodule-synchronize’) + This command synchronizes the urls of the selected modules, copying + the values from ".gitmodules" to the ".git/config" of the + super-project as well those of the modules. + +‘o d’ (‘magit-submodule-unpopulate’) + This command removes the working directory of the selected modules. + +‘o l’ (‘magit-list-submodules’) + This command displays a list of the current repository’s modules. + +‘o f’ (‘magit-fetch-modules’) + This command fetches all populated modules. With a prefix + argument, it acts as a transient prefix command, allowing the + caller to set options. + + Also fetch the super-repository, because ‘git fetch’ does not + support not doing that. + + +File: magit.info, Node: Subtree, Next: Worktree, Prev: Submodules, Up: Miscellaneous + +8.4 Subtree +=========== + +Also see *note (gitman)git-subtree::. + +‘O’ (‘magit-subtree’) + This transient prefix command binds the two sub-transients; one for + importing a subtree and one for exporting a subtree. + +‘O i’ (‘magit-subtree-import’) + This transient prefix command binds the following suffix commands + along with the appropriate infix arguments and displays them in a + temporary buffer until a suffix is invoked. + + The suffixes of this command import subtrees. + + If the ‘--prefix’ argument is set, then the suffix commands use + that prefix without prompting the user. If it is unset, then they + read the prefix in the minibuffer. + +‘O i a’ (‘magit-subtree-add’) + This command adds COMMIT from REPOSITORY as a new subtree at + PREFIX. + +‘O i c’ (‘magit-subtree-add-commit’) + This command add COMMIT as a new subtree at PREFIX. + +‘O i m’ (‘magit-subtree-merge’) + This command merges COMMIT into the PREFIX subtree. + +‘O i f’ (‘magit-subtree-pull’) + This command pulls COMMIT from REPOSITORY into the PREFIX subtree. + +‘O e’ (‘magit-subtree-export’) + This transient prefix command binds the following suffix commands + along with the appropriate infix arguments and displays them in a + temporary buffer until a suffix is invoked. + + The suffixes of this command export subtrees. + + If the ‘--prefix’ argument is set, then the suffix commands use + that prefix without prompting the user. If it is unset, then they + read the prefix in the minibuffer. + +‘O e p’ (‘magit-subtree-push’) + This command extract the history of the subtree PREFIX and pushes + it to REF on REPOSITORY. + +‘O e s’ (‘magit-subtree-split’) + This command extracts the history of the subtree PREFIX. + + +File: magit.info, Node: Worktree, Next: Sparse checkouts, Prev: Subtree, Up: Miscellaneous + +8.5 Worktree +============ + +Also see *note (gitman)git-worktree::. + +‘Z’ (‘magit-worktree’) + This transient prefix command binds the following suffix commands + and displays them in a temporary buffer until a suffix is invoked. + +‘Z b’ (‘magit-worktree-checkout’) + Checkout BRANCH in a new worktree at PATH. + +‘Z c’ (‘magit-worktree-branch’) + Create a new BRANCH and check it out in a new worktree at PATH. + +‘Z m’ (‘magit-worktree-move’) + Move an existing worktree to a new PATH. + +‘Z k’ (‘magit-worktree-delete’) + Delete a worktree, defaulting to the worktree at point. The + primary worktree cannot be deleted. + +‘Z g’ (‘magit-worktree-status’) + Show the status for the worktree at point. + + If there is no worktree at point, then read one in the minibuffer. + If the worktree at point is the one whose status is already being + displayed in the current buffer, then show it in Dired instead. + + +File: magit.info, Node: Sparse checkouts, Next: Bundle, Prev: Worktree, Up: Miscellaneous + +8.6 Sparse checkouts +==================== + +Sparse checkouts provide a way to restrict the working tree to a subset +of directories. See *note (gitman)git-sparse-checkout::. + + *Warning*: Git introduced the ‘git sparse-checkout’ command in +version 2.25 and still advertises it as experimental and subject to +change. Magit’s interface should be considered the same. In +particular, if Git introduces a backward incompatible change, Magit’s +sparse checkout functionality may be updated in a way that requires a +more recent Git version. + +‘>’ (‘magit-sparse-checkout’) + This transient prefix command binds the following suffix commands + and displays them in a temporary buffer until a suffix is invoked. + +‘> e’ (‘magit-sparse-checkout-enable’) + This command initializes a sparse checkout that includes only the + files in the top-level directory. + + Note that ‘magit-sparse-checkout-set’ and + ‘magit-sparse-checkout-add’ automatically initialize a sparse + checkout if necessary. However, you may want to call + ‘magit-sparse-checkout-enable’ explicitly to re-initialize a sparse + checkout after calling ‘magit-sparse-checkout-disable’, to pass + additional arguments to ‘git sparse-checkout init’, or to execute + the initialization asynchronously. + +‘> s’ (‘magit-sparse-checkout-set’) + This command takes a list of directories and configures the sparse + checkout to include only files in those subdirectories. Any + previously included directories are excluded unless they are in the + provided list of directories. + +‘> a’ (‘magit-sparse-checkout-add’) + This command is like ‘magit-sparse-checkout-set’, but instead adds + the specified list of directories to the set of directories that is + already included in the sparse checkout. + +‘> r’ (‘magit-sparse-checkout-reapply’) + This command applies the currently configured sparse checkout + patterns to the working tree. This is useful to call if excluded + files have been checked out after operations such as merging or + rebasing. + +‘> d’ (‘magit-sparse-checkout-disable’) + This command restores the full checkout. To return to the previous + sparse checkout, call ‘magit-sparse-checkout-enable’. + + A sparse checkout can also be initiated when cloning a repository by +using the ‘magit-clone-sparse’ command in the ‘magit-clone’ transient +(see *note Cloning Repository::). + + If you want the status buffer to indicate when a sparse checkout is +enabled, add the function ‘magit-sparse-checkout-insert-header’ to +‘magit-status-headers-hook’. + + +File: magit.info, Node: Bundle, Next: Common Commands, Prev: Sparse checkouts, Up: Miscellaneous + +8.7 Bundle +========== + +Also see *note (gitman)git-bundle::. + + -- Command: magit-bundle + This transient prefix command binds several suffix commands for + running ‘git bundle’ subcommands and displays them in a temporary + buffer until a suffix is invoked. + + +File: magit.info, Node: Common Commands, Next: Wip Modes, Prev: Bundle, Up: Miscellaneous + +8.8 Common Commands +=================== + + -- Command: magit-switch-to-repository-buffer + -- Command: magit-switch-to-repository-buffer-other-window + -- Command: magit-switch-to-repository-buffer-other-frame + -- Command: magit-display-repository-buffer + These commands read any existing Magit buffer that belongs to the + current repository from the user and then switch to the selected + buffer (without refreshing it). + + The last variant uses ‘magit-display-buffer’ to do so and thus + respects ‘magit-display-buffer-function’. + + These are some of the commands that can be used in all buffers whose +major-modes derive from ‘magit-mode’. There are other common commands +beside the ones below, but these didn’t fit well anywhere else. + +‘C-w’ (‘magit-copy-section-value’) + This command saves the value of the current section to the + ‘kill-ring’, and, provided that the current section is a commit, + branch, or tag section, it also pushes the (referenced) revision to + the ‘magit-revision-stack’. + + When the current section is a branch or a tag, and a prefix + argument is used, then it saves the revision at its tip to the + ‘kill-ring’ instead of the reference name. + + When the region is active, this command saves that to the + ‘kill-ring’, like ‘kill-ring-save’ would, instead of behaving as + described above. If a prefix argument is used and the region is + within a hunk, then it strips the diff marker column and keeps only + either the added or removed lines, depending on the sign of the + prefix argument. + +‘M-w’ (‘magit-copy-buffer-revision’) + This command saves the revision being displayed in the current + buffer to the ‘kill-ring’ and also pushes it to the + ‘magit-revision-stack’. It is mainly intended for use in + ‘magit-revision-mode’ buffers, the only buffers where it is always + unambiguous exactly which revision should be saved. + + Most other Magit buffers usually show more than one revision, in + some way or another, so this command has to select one of them, and + that choice might not always be the one you think would have been + the best pick. + + Outside of Magit ‘M-w’ and ‘C-w’ are usually bound to +‘kill-ring-save’ and ‘kill-region’, and these commands would also be +useful in Magit buffers. Therefore when the region is active, then both +of these commands behave like ‘kill-ring-save’ instead of as described +above. + + +File: magit.info, Node: Wip Modes, Next: Commands for Buffers Visiting Files, Prev: Common Commands, Up: Miscellaneous + +8.9 Wip Modes +============= + +Git keeps *committed* changes around long enough for users to recover +changes they have accidentally deleted. It does so by not garbage +collecting any committed but no longer referenced objects for a certain +period of time, by default 30 days. + + But Git does *not* keep track of *uncommitted* changes in the working +tree and not even the index (the staging area). Because Magit makes it +so convenient to modify uncommitted changes, it also makes it easy to +shoot yourself in the foot in the process. + + For that reason Magit provides a global mode that saves *tracked* +files to work-in-progress references after or before certain actions. +(At present untracked files are never saved and for technical reasons +nothing is saved before the first commit has been created). + + Two separate work-in-progress references are used to track the state +of the index and of the working tree: ‘refs/wip/index/<branchref>’ and +‘refs/wip/wtree/<branchref>’, where ‘<branchref>’ is the full ref of the +current branch, e.g., ‘refs/heads/master’. When the ‘HEAD’ is detached +then ‘HEAD’ is used in place of ‘<branchref>’. + + Checking out another branch (or detaching ‘HEAD’) causes the use of +different wip refs for subsequent changes. + + -- User Option: magit-wip-mode + When this mode is enabled, then uncommitted changes are committed + to dedicated work-in-progress refs whenever appropriate (i.e., when + dataloss would be a possibility otherwise). + + Setting this variable directly does not take effect; either use the + Custom interface to do so or call the respective mode function. + + For historic reasons this mode is implemented on top of four other + ‘magit-wip-*’ modes, which can also be used individually, if you + want finer control over when the wip refs are updated; but that is + discouraged. See *note Legacy Wip Modes::. + + To view the log for a branch and its wip refs use the commands +‘magit-wip-log’ and ‘magit-wip-log-current’. You should use ‘--graph’ +when using these commands. + + -- Command: magit-wip-log + This command shows the log for a branch and its wip refs. With a + negative prefix argument only the worktree wip ref is shown. + + The absolute numeric value of the prefix argument controls how many + "branches" of each wip ref are shown. This is only relevant if the + value of ‘magit-wip-merge-branch’ is ‘nil’. + + -- Command: magit-wip-log-current + This command shows the log for the current branch and its wip refs. + With a negative prefix argument only the worktree wip ref is shown. + + The absolute numeric value of the prefix argument controls how many + "branches" of each wip ref are shown. This is only relevant if the + value of ‘magit-wip-merge-branch’ is ‘nil’. + +‘X w’ (‘magit-reset-worktree’) + This command resets the working tree to some commit read from the + user and defaulting to the commit at point, while keeping the + ‘HEAD’ and index as-is. + + This can be used to restore files to the state committed to a wip + ref. Note that this will discard any unstaged changes that might + have existed before invoking this command (but of course only after + committing that to the working tree wip ref). + + Note that even if you enable ‘magit-wip-mode’ this won’t give you +perfect protection. The most likely scenario for losing changes despite +the use of ‘magit-wip-mode’ is making a change outside Emacs and then +destroying it also outside Emacs. In some such a scenario, Magit, being +an Emacs package, didn’t get the opportunity to keep you from shooting +yourself in the foot. + + When you are unsure whether Magit did commit a change to the wip +refs, then you can explicitly request that all changes to all tracked +files are being committed. + +‘M-x magit-wip-commit’ + This command commits all changes to all tracked files to the index + and working tree work-in-progress refs. Like the modes described + above, it does not commit untracked files, but it does check all + tracked files for changes. Use this command when you suspect that + the modes might have overlooked a change made outside Emacs/Magit. + + -- User Option: magit-wip-namespace + The namespace used for work-in-progress refs. It has to end with a + slash. The wip refs are named ‘<namespace>index/<branchref>’ and + ‘<namespace>wtree/<branchref>’. When snapshots are created while + the ‘HEAD’ is detached then ‘HEAD’ is used in place of + ‘<branchref>’. + + -- User Option: magit-wip-mode-lighter + Mode-line lighter for ‘magit-wip--mode’. + +* Menu: + +* Wip Graph:: +* Legacy Wip Modes:: + + +File: magit.info, Node: Wip Graph, Next: Legacy Wip Modes, Up: Wip Modes + +8.9.1 Wip Graph +--------------- + + -- User Option: magit-wip-merge-branch + This option controls whether the current branch is merged into the + wip refs after a new commit was created on the branch. + + If non-nil and the current branch has new commits, then it is + merged into the wip ref before creating a new wip commit. This + makes it easier to inspect wip history and the wip commits are + never garbage collected. + + If nil and the current branch has new commits, then the wip ref is + reset to the tip of the branch before creating a new wip commit. + With this setting wip commits are eventually garbage collected. + + When ‘magit-wip-merge-branch’ is ‘t’, then the history looks like +this: + + *--*--*--*--*--* refs/wip/index/refs/heads/master + / / / + A-----B-----C refs/heads/master + + When ‘magit-wip-merge-branch’ is ‘nil’, then creating a commit on the +real branch and then making a change causes the wip refs to be recreated +to fork from the new commit. But the old commits on the wip refs are +not lost. They are still available from the reflog. To make it easier +to see when the fork point of a wip ref was changed, an additional +commit with the message "restart autosaving" is created on it (‘xxO’ +commits below are such boundary commits). + + Starting with + + BI0---BI1 refs/wip/index/refs/heads/master + / + A---B refs/heads/master + \ + BW0---BW1 refs/wip/wtree/refs/heads/master + + and committing the staged changes and editing and saving a file would +result in + + BI0---BI1 refs/wip/index/refs/heads/master + / + A---B---C refs/heads/master + \ \ + \ CW0---CW1 refs/wip/wtree/refs/heads/master + \ + BW0---BW1 refs/wip/wtree/refs/heads/master@{2} + + The fork-point of the index wip ref is not changed until some change +is being staged. Likewise just checking out a branch or creating a +commit does not change the fork-point of the working tree wip ref. The +fork-points are not adjusted until there actually is a change that +should be committed to the respective wip ref. + + +File: magit.info, Node: Legacy Wip Modes, Prev: Wip Graph, Up: Wip Modes + +8.9.2 Legacy Wip Modes +---------------------- + +It is recommended that you use the mode ‘magit-wip-mode’ (which see) and +ignore the existence of the following modes, which are preserved for +historic reasons. + + Setting the following variables directly does not take effect; either +use the Custom interface to do so or call the respective mode functions. + + -- User Option: magit-wip-after-save-mode + When this mode is enabled, then saving a buffer that visits a file + tracked in a Git repository causes its current state to be + committed to the working tree wip ref for the current branch. + + -- User Option: magit-wip-after-apply-mode + When this mode is enabled, then applying (i.e., staging, unstaging, + discarding, reversing, and regularly applying) a change to a file + tracked in a Git repository causes its current state to be + committed to the index and/or working tree wip refs for the current + branch. + + If you only ever edit files using Emacs and only ever interact with +Git using Magit, then the above two modes should be enough to protect +each and every change from accidental loss. In practice nobody does +that. Two additional modes exists that do commit to the wip refs before +making changes that could cause the loss of earlier changes. + + -- User Option: magit-wip-before-change-mode + When this mode is enabled, then certain commands commit the + existing changes to the files they are about to make changes to. + + -- User Option: magit-wip-initial-backup-mode + When this mode is enabled, then the current version of a file is + committed to the worktree wip ref before the buffer visiting that + file is saved for the first time since the buffer was created. + + This backs up the same version of the file that ‘backup-buffer’ + would save. While ‘backup-buffer’ uses a backup file, this mode + uses the same worktree wip ref as used by the other Magit Wip + modes. Like ‘backup-buffer’, it only does this once; unless you + kill the buffer and visit the file again only one backup will be + created per Emacs session. + + This mode ignores the variables that affect ‘backup-buffer’ and can + be used along-side that function, which is recommended because it + only backs up files that are tracked in a Git repository. + + -- User Option: magit-wip-after-save-local-mode-lighter + Mode-line lighter for ‘magit-wip-after-save-local-mode’. + + -- User Option: magit-wip-after-apply-mode-lighter + Mode-line lighter for ‘magit-wip-after-apply-mode’. + + -- User Option: magit-wip-before-change-mode-lighter + Mode-line lighter for ‘magit-wip-before-change-mode’. + + -- User Option: magit-wip-initial-backup-mode-lighter + Mode-line lighter for ‘magit-wip-initial-backup-mode’. + + +File: magit.info, Node: Commands for Buffers Visiting Files, Next: Minor Mode for Buffers Visiting Blobs, Prev: Wip Modes, Up: Miscellaneous + +8.10 Commands for Buffers Visiting Files +======================================== + +By default Magit defines a few global key bindings. These bindings are +a compromise between providing no bindings at all and providing the +better bindings I would have liked to use instead. Magit cannot provide +the set of recommended bindings by default because those key sequences +are strictly reserved for bindings added by the user. Also see *note +Global Bindings:: and *note (elisp)Key Binding Conventions::. + + To use the recommended bindings, add this to your init file and +restart Emacs. + + (setq magit-define-global-key-bindings 'recommended) + + If you don’t want Magit to add any bindings to the global keymap at +all, add this to your init file and restart Emacs. + + (setq magit-define-global-key-bindings nil) + +‘C-c f’ (‘magit-file-dispatch’) +‘C-c f s’ (‘magit-stage-file’) +‘C-c f s’ (‘magit-stage-buffer-file’) +‘C-c f u’ (‘magit-unstage-file’) +‘C-c f u’ (‘magit-unstage-buffer-file’) +‘C-c f , x’ (‘magit-file-untrack’) +‘C-c f , r’ (‘magit-file-rename’) +‘C-c f , k’ (‘magit-file-delete’) +‘C-c f , c’ (‘magit-file-checkout’) +‘C-c f D’ (‘magit-diff’) +‘C-c f d’ (‘magit-diff-buffer-file’) +‘C-c f L’ (‘magit-log’) +‘C-c f l’ (‘magit-log-buffer-file’) +‘C-c f t’ (‘magit-log-trace-definition’) +‘C-c f M’ (‘magit-log-merged’) +‘C-c f B’ (‘magit-blame’) +‘C-c f b’ (‘magit-blame-additions’) +‘C-c f r’ (‘magit-blame-removal’) +‘C-c f f’ (‘magit-blame-reverse’) +‘C-c f m’ (‘magit-blame-echo’) +‘C-c f q’ (‘magit-blame-quit’) +‘C-c f p’ (‘magit-blob-previous’) +‘C-c f n’ (‘magit-blob-next’) +‘C-c f v’ (‘magit-find-file’) +‘C-c f V’ (‘magit-blob-visit-file’) +‘C-c f g’ (‘magit-status-here’) +‘C-c f G’ (‘magit-display-repository-buffer’) +‘C-c f c’ (‘magit-commit’) +‘C-c f e’ (‘magit-edit-line-commit’) + Each of these commands is documented individually right below, + alongside their default key bindings. The bindings shown above are + the recommended bindings, which you can enable by following the + instructions further up. + +‘C-c M-g’ (‘magit-file-dispatch’) + This transient prefix command binds the following suffix commands + and displays them in a temporary buffer until a suffix is invoked. + +‘C-c M-g s’ (‘magit-stage-file’) +‘C-c M-g s’ (‘magit-stage-buffer-file’) + Stage all changes to the file being visited in the current buffer. + When not visiting a file, then the first command is used, which + prompts for a file. + +‘C-c M-g u’ (‘magit-unstage-file’) +‘C-c M-g u’ (‘magit-unstage-buffer-file’) + Unstage all changes to the file being visited in the current + buffer. When not visiting a file, then the first command is used, + which prompts for a file. + +‘C-c M-g , x’ (‘magit-file-untrack’) + This command untracks a file read from the user, defaulting to the + visited file. + +‘C-c M-g , r’ (‘magit-file-rename’) + This command renames a file read from the user, defaulting to the + visited file. + +‘C-c M-g , k’ (‘magit-file-delete’) + This command deletes a file read from the user, defaulting to the + visited file. + +‘C-c M-g , c’ (‘magit-file-checkout’) + This command updates a file in the working tree and index to the + contents from a revision. Both the revision and file are read from + the user. + +‘C-c M-g D’ (‘magit-diff’) + This transient prefix command binds several diff suffix commands + and infix arguments and displays them in a temporary buffer until a + suffix is invoked. See *note Diffing::. + + This is the same command that ‘d’ is bound to in Magit buffers. If + this command is invoked from a file-visiting buffer, then the + initial value of the option (‘--’) that limits the diff to certain + file(s) is set to the visited file. + +‘C-c M-g d’ (‘magit-diff-buffer-file’) + This command shows the diff for the file of blob that the current + buffer visits. + + -- User Option: magit-diff-buffer-file-locked + This option controls whether ‘magit-diff-buffer-file’ uses a + dedicated buffer. See *note Modes and Buffers::. + +‘C-c M-g L’ (‘magit-log’) + This transient prefix command binds several log suffix commands and + infix arguments and displays them in a temporary buffer until a + suffix is invoked. See *note Logging::. + + This is the same command that ‘l’ is bound to in Magit buffers. If + this command is invoked from a file-visiting buffer, then the + initial value of the option (‘--’) that limits the log to certain + file(s) is set to the visited file. + +‘C-c M-g l’ (‘magit-log-buffer-file’) + This command shows the log for the file of blob that the current + buffer visits. Renames are followed when a prefix argument is used + or when ‘--follow’ is an active log argument. When the region is + active, the log is restricted to the selected line range. + + -- User Option: magit-log-buffer-file-locked + This option controls whether ‘magit-log-buffer-file’ uses a + dedicated buffer. See *note Modes and Buffers::. + +‘C-c M-g t’ (‘magit-log-trace-definition’) + This command shows the log for the definition at point. + +‘C-c M-g M’ (‘magit-log-merged’) + This command reads a commit and a branch in shows a log concerning + the merge of the former into the latter. This shows multiple + commits even in case of a fast-forward merge. + +‘C-c M-g B’ (‘magit-blame’) + This transient prefix command binds all blaming suffix commands + along with the appropriate infix arguments and displays them in a + temporary buffer until a suffix is invoked. + + For more information about this and the following commands also see + *note Blaming::. + + In addition to the ‘magit-blame’ sub-transient, the dispatch + transient also binds several blaming suffix commands directly. See + *note Blaming:: for information about those commands and bindings. + +‘C-c M-g p’ (‘magit-blob-previous’) + This command visits the previous blob which modified the current + file. + +‘C-c M-g n’ (‘magit-blob-next’) + This command visits the next blob which modified the current file. + +‘C-c M-g v’ (‘magit-find-file’) + This command reads a revision and file and visits the respective + blob. + +‘C-c M-g V’ (‘magit-blob-visit-file’) + This command visits the file from the working tree, corresponding + to the current blob. When visiting a blob or the version from the + index, then it goes to the same location in the respective file in + the working tree. + +‘C-c M-g g’ (‘magit-status-here’) + This command displays the status of the current repository in a + buffer, like ‘magit-status’ does. Additionally it tries to go to + the position in that buffer, which corresponds to the position in + the current file-visiting buffer (if any). + +‘C-c M-g G’ (‘magit-display-repository-buffer’) + This command reads and displays a Magit buffer belonging to the + current repository, without refreshing it. + +‘C-c M-g c’ (‘magit-commit’) + This transient prefix command binds the following suffix commands + along with the appropriate infix arguments and displays them in a + temporary buffer until a suffix is invoked. See *note Initiating a + Commit::. + +‘C-c M-g e’ (‘magit-edit-line-commit’) + This command makes the commit editable that added the current line. + + With a prefix argument it makes the commit editable that removes + the line, if any. The commit is determined using ‘git blame’ and + made editable using ‘git rebase --interactive’ if it is reachable + from ‘HEAD’, or by checking out the commit (or a branch that points + at it) otherwise. + + +File: magit.info, Node: Minor Mode for Buffers Visiting Blobs, Prev: Commands for Buffers Visiting Files, Up: Miscellaneous + +8.11 Minor Mode for Buffers Visiting Blobs +========================================== + +The ‘magit-blob-mode’ enables certain Magit features in blob-visiting +buffers. Such buffers can be created using ‘magit-find-file’ and some +of the commands mentioned below, which also take care of turning on this +minor mode. Currently this mode only establishes a few key bindings, +but this might be extended. + +‘p’ (‘magit-blob-previous’) + Visit the previous blob which modified the current file. + +‘n’ (‘magit-blob-next’) + Visit the next blob which modified the current file. + +‘q’ (‘magit-kill-this-buffer’) + Kill the current buffer. + + +File: magit.info, Node: Customizing, Next: Plumbing, Prev: Miscellaneous, Up: Top + +9 Customizing +************* + +Both Git and Emacs are highly customizable. Magit is both a Git +porcelain as well as an Emacs package, so it makes sense to customize it +using both Git variables as well as Emacs options. However this +flexibility doesn’t come without problems, including but not limited to +the following. + + • Some Git variables automatically have an effect in Magit without + requiring any explicit support. Sometimes that is desirable - in + other cases, it breaks Magit. + + When a certain Git setting breaks Magit but you want to keep using + that setting on the command line, then that can be accomplished by + overriding the value for Magit only by appending something like + ‘("-c" "some.variable=compatible-value")’ to + ‘magit-git-global-arguments’. + + • Certain settings like ‘fetch.prune=true’ are respected by Magit + commands (because they simply call the respective Git command) but + their value is not reflected in the respective transient buffers. + In this case the ‘--prune’ argument in ‘magit-fetch’ might be + active or inactive, but that doesn’t keep the Git variable from + being honored by the suffix commands anyway. So pruning might + happen despite the ‘--prune’ arguments being displayed in a way + that seems to indicate that no pruning will happen. + + I intend to address these and similar issues in a future release. + +* Menu: + +* Per-Repository Configuration:: +* Essential Settings:: + + +File: magit.info, Node: Per-Repository Configuration, Next: Essential Settings, Up: Customizing + +9.1 Per-Repository Configuration +================================ + +Magit can be configured on a per-repository level using both Git +variables as well as Emacs options. + + To set a Git variable for one repository only, simply set it in +‘/path/to/repo/.git/config’ instead of ‘$HOME/.gitconfig’ or +‘/etc/gitconfig’. See *note (gitman)git-config::. + + Similarly, Emacs options can be set for one repository only by +editing ‘/path/to/repo/.dir-locals.el’. See *note (emacs)Directory +Variables::. For example to disable automatic refreshes of +file-visiting buffers in just one huge repository use this: + + • ‘/path/to/huge/repo/.dir-locals.el’ + + ((nil . ((magit-refresh-buffers . nil)))) + + It might only be costly to insert certain information into Magit +buffers for repositories that are exceptionally large, in which case you +can disable the respective section inserters just for that repository: + + • ‘/path/to/tag/invested/repo/.dir-locals.el’ + + ((magit-status-mode + . ((eval . (magit-disable-section-inserter 'magit-insert-tags-header))))) + + -- Function: magit-disable-section-inserter fn + This function disables the section inserter FN in the current + repository. It is only intended for use in ‘.dir-locals.el’ and + ‘.dir-locals-2.el’. + + If you want to apply the same settings to several, but not all, +repositories then keeping the repository-local config files in sync +would quickly become annoying. To avoid that you can create config +files for certain classes of repositories (e.g., "huge repositories") +and then include those files in the per-repository config files. For +example: + + • ‘/path/to/huge/repo/.git/config’ + + [include] + path = /path/to/huge-gitconfig + + • ‘/path/to/huge-gitconfig’ + + [status] + showUntrackedFiles = no + + • ‘$HOME/.emacs.d/init.el’ + + (dir-locals-set-class-variables 'huge-git-repository + '((nil . ((magit-refresh-buffers . nil))))) + + (dir-locals-set-directory-class + "/path/to/huge/repo/" 'huge-git-repository) + + +File: magit.info, Node: Essential Settings, Prev: Per-Repository Configuration, Up: Customizing + +9.2 Essential Settings +====================== + +The next three sections list and discuss several variables that many +users might want to customize, for safety and/or performance reasons. + +* Menu: + +* Safety:: +* Performance:: +* Global Bindings:: + + +File: magit.info, Node: Safety, Next: Performance, Up: Essential Settings + +9.2.1 Safety +------------ + +This section discusses various variables that you might want to change +(or *not* change) for safety reasons. + + Git keeps *committed* changes around long enough for users to recover +changes they have accidentally been deleted. It does not do the same +for *uncommitted* changes in the working tree and not even the index +(the staging area). Because Magit makes it so easy to modify +uncommitted changes, it also makes it easy to shoot yourself in the foot +in the process. For that reason Magit provides three global modes that +save *tracked* files to work-in-progress references after or before +certain actions. See *note Wip Modes::. + + These modes are not enabled by default because of performance +concerns. Instead a lot of potentially destructive commands require +confirmation every time they are used. In many cases this can be +disabled by adding a symbol to ‘magit-no-confirm’ (see *note Completion +and Confirmation::). If you enable the various wip modes then you +should add ‘safe-with-wip’ to this list. + + Similarly it isn’t necessary to require confirmation before moving a +file to the system trash - if you trashed a file by mistake then you can +recover it from there. Option ‘magit-delete-by-moving-to-trash’ +controls whether the system trash is used, which is the case by default. +Nevertheless, ‘trash’ isn’t a member of ‘magit-no-confirm’ - you might +want to change that. + + By default buffers visiting files are automatically reverted when the +visited file changes on disk. This isn’t as risky as it might seem, but +to make an informed decision you should see *note Risk of Reverting +Automatically::. + + +File: magit.info, Node: Performance, Next: Global Bindings, Prev: Safety, Up: Essential Settings + +9.2.2 Performance +----------------- + +After Magit has run ‘git’ for side-effects, it also refreshes the +current Magit buffer and the respective status buffer. This is +necessary because otherwise outdated information might be displayed +without the user noticing. Magit buffers are updated by recreating +their content from scratch, which makes updating simpler and less +error-prone, but also more costly. Keeping it simple and just +re-creating everything from scratch is an old design decision and +departing from that will require major refactoring. + + Meanwhile you can tell Magit to only automatically refresh the +current Magit buffer, but not the status buffer. If you do that, then +the status buffer is only refreshed automatically if it is the current +buffer. + + (setq magit-refresh-status-buffer nil) + + You should also check whether any third-party packages have added +anything to ‘magit-refresh-buffer-hook’, ‘magit-pre-refresh-hook’, and +‘magit-post-refresh-hook’. If so, then check whether those additions +impact performance significantly. + + Magit can be told to refresh buffers verbosely using ‘M-x +magit-toggle-verbose-refresh’. Enabling this helps figuring out which +sections are bottlenecks. Each line printed to the ‘*Messages*’ buffer +contains a section name, the number of seconds it took to show this +section, and from 0 to 2 exclamation marks: the more exclamation marks +the slower the section is. + + Magit also reverts buffers for visited files located inside the +current repository when the visited file changes on disk. That is +implemented on top of ‘auto-revert-mode’ from the built-in library +‘autorevert’. To figure out whether that impacts performance, check +whether performance is significantly worse, when many buffers exist +and/or when some buffers visit files using TRAMP. If so, then this +should help. + + (setq auto-revert-buffer-list-filter + 'magit-auto-revert-repository-buffer-p) + + For alternative approaches see *note Automatic Reverting of +File-Visiting Buffers::. + + If you have enabled any features that are disabled by default, then +you should check whether they impact performance significantly. It’s +likely that they were not enabled by default because it is known that +they reduce performance at least in large repositories. + + If performance is only slow inside certain unusually large +repositories, then you might want to disable certain features on a +per-repository or per-repository-class basis only. See *note +Per-Repository Configuration::. For example it takes a long time to +determine the next and current tag in repository with exceptional +numbers of tags. It would therefore be a good idea to disable +‘magit-insert-tags-headers’, as explained at the mentioned node. + +* Menu: + +* Microsoft Windows Performance:: +* MacOS Performance:: + +Log Performance +............... + +When showing logs, Magit limits the number of commits initially shown in +the hope that this avoids unnecessary work. When ‘--graph’ is used, +then this unfortunately does not have the desired effect for large +histories. Junio, Git’s maintainer, said on the git mailing list +(<https://www.spinics.net/lists/git/msg232230.html>): "‘--graph’ wants +to compute the whole history and the max-count only affects the output +phase after ‘--graph’ does its computation". + + In other words, it’s not that Git is slow at outputting the +differences, or that Magit is slow at parsing the output - the problem +is that Git first goes outside and has a smoke. + + We actually work around this issue by limiting the number of commits +not only by using ‘-<N>’ but by also using a range. But unfortunately +that’s not always possible. + + When more than a few thousand commits are shown, then the use of +‘--graph’ can slow things down. + + Using ‘--color --graph’ is even slower. Magit uses code that is part +of Emacs to turn control characters into faces. That code is pretty +slow and this is quite noticeable when showing a log with many branches +and merges. For that reason ‘--color’ is not enabled by default +anymore. Consider leaving it at that. + +Diff Performance +................ + +If diffs are slow, then consider turning off some optional diff features +by setting all or some of the following variables to ‘nil’: +‘magit-diff-highlight-indentation’, ‘magit-diff-highlight-trailing’, +‘magit-diff-paint-whitespace’, ‘magit-diff-highlight-hunk-body’, and +‘magit-diff-refine-hunk’. + + When showing a commit instead of some arbitrary diff, then some +additional information is displayed. Calculating this information can +be quite expensive given certain circumstances. If looking at a commit +using ‘magit-revision-mode’ takes considerably more time than looking at +the same commit in ‘magit-diff-mode’, then consider setting +‘magit-revision-insert-related-refs’ to ‘nil’. + + When you are often confronted with diffs that contain deleted files, +then you might want to enable the ‘--irreversible-delete’ argument. If +you do that then diffs still show that a file was deleted but without +also showing the complete deleted content of the file. This argument is +not available by default, see *note (transient)Enabling and Disabling +Suffixes::. Once you have done that you should enable it and save that +setting, see *note (transient)Saving Values::. You should do this in +both the diff (‘d’) and the diff refresh (‘D’) transient popups. + +Refs Buffer Performance +....................... + +When refreshing the "references buffer" is slow, then that’s usually +because several hundred refs are being displayed. The best way to +address that is to display fewer refs, obviously. + + If you are not, or only mildly, interested in seeing the list of +tags, then start by not displaying them: + + (remove-hook 'magit-refs-sections-hook 'magit-insert-tags) + + Then you should also make sure that the listed remote branches +actually all exist. You can do so by pruning branches which no longer +exist using ‘f-pa’. + +Committing Performance +...................... + +When you initiate a commit, then Magit by default automatically shows a +diff of the changes you are about to commit. For large commits this can +take a long time, which is especially distracting when you are +committing large amounts of generated data which you don’t actually +intend to inspect before committing. This behavior can be turned off +using: + + (remove-hook 'server-switch-hook 'magit-commit-diff) + (remove-hook 'with-editor-filter-visit-hook 'magit-commit-diff) + + Then you can type ‘C-c C-d’ to show the diff when you actually want +to see it, but only then. Alternatively you can leave the hook alone +and just type ‘C-g’ in those cases when it takes too long to generate +the diff. If you do that, then you will end up with a broken diff +buffer, but doing it this way has the advantage that you usually get to +see the diff, which is useful because it increases the odds that you +spot potential issues. + + +File: magit.info, Node: Microsoft Windows Performance, Next: MacOS Performance, Up: Performance + +Microsoft Windows Performance +............................. + +In order to update the status buffer, ‘git’ has to be run a few dozen +times. That is problematic on Microsoft Windows, because that operating +system is exceptionally slow at starting processes. Sadly this is an +issue that can only be fixed by Microsoft itself, and they don’t appear +to be particularly interested in doing so. + + Beside the subprocess issue, there are also other Windows-specific +performance issues. Some of these have workarounds. The maintainers of +"Git for Windows" try to improve performance on Windows. Always use the +latest release in order to benefit from the latest performance tweaks. +Magit too tries to work around some Windows-specific issues. + + According to some sources, setting the following Git variables can +also help. + + git config --global core.preloadindex true # default since v2.1 + git config --global core.fscache true # default since v2.8 + git config --global gc.auto 256 + + You should also check whether an anti-virus program is affecting +performance. + + +File: magit.info, Node: MacOS Performance, Prev: Microsoft Windows Performance, Up: Performance + +MacOS Performance +................. + +Before Emacs 26.1 child processes were created using ‘fork’ on macOS. +That needlessly copied GUI resources, which is expensive. The result +was that forking took about 30 times as long on Darwin than on Linux, +and because Magit starts many ‘git’ processes that made quite a +difference. + + So make sure that you are using at least Emacs 26.1, in which case +the faster ‘vfork’ will be used. (The creation of child processes still +takes about twice as long on Darwin compared to Linux.) See (1) for +more information. + + Additionally, ‘git’ installed from a package manager like ‘brew’ or +‘nix’ seems to be slower than the native executable. Profile the ‘git’ +executable you’re running against the one at ‘/usr/bin/git’, and if you +notice a notable difference try using the latter as +‘magit-git-executable’. + + ---------- Footnotes ---------- + + (1) +<https://lists.gnu.org/archive/html/bug-gnu-emacs/2017-04/msg00201.html> + + +File: magit.info, Node: Global Bindings, Prev: Performance, Up: Essential Settings + +9.2.3 Global Bindings +--------------------- + + -- User Option: magit-define-global-key-bindings + This option controls which set of Magit key bindings, if any, may + be added to the global keymap, even before Magit is first used in + the current Emacs session. + + • If the value is ‘nil’, no bindings are added. + + • If ‘default’, maybe add: + + ‘C-x g’ ‘magit-status’ + ‘C-x M-g’ ‘magit-dispatch’ + ‘C-c M-g’ ‘magit-file-dispatch’ + + • If ‘recommended’, maybe add: + + ‘C-x g’ ‘magit-status’ + ‘C-c g’ ‘magit-dispatch’ + ‘C-c f’ ‘magit-file-dispatch’ + + These bindings are strongly recommended, but we cannot use + them by default, because the ‘C-c <LETTER>’ namespace is + strictly reserved for bindings added by the user (see *note + (elisp)Key Binding Conventions::). + + The bindings in the chosen set may be added when ‘after-init-hook’ + is run. Each binding is added if, and only if, at that time no + other key is bound to the same command, and no other command is + bound to the same key. In other words we try to avoid adding + bindings that are unnecessary, as well as bindings that conflict + with other bindings. + + Adding these bindings is delayed until ‘after-init-hook’ is run to + allow users to set the variable anywhere in their init file + (without having to make sure to do so before ‘magit’ is loaded or + autoloaded) and to increase the likelihood that all the potentially + conflicting user bindings have already been added. + + To set this variable use either ‘setq’ or the Custom interface. Do + not use the function ‘customize-set-variable’ because doing that + would cause Magit to be loaded immediately, when that form is + evaluated (this differs from ‘custom-set-variables’, which doesn’t + load the libraries that define the customized variables). + + Setting this variable has no effect if ‘after-init-hook’ has + already been run. + + +File: magit.info, Node: Plumbing, Next: FAQ, Prev: Customizing, Up: Top + +10 Plumbing +*********** + +The following sections describe how to use several of Magit’s core +abstractions to extend Magit itself or implement a separate extension. + + A few of the low-level features used by Magit have been factored out +into separate libraries/packages, so that they can be used by other +packages, without having to depend on Magit. See *note +(with-editor)Top:: for information about ‘with-editor’. ‘transient’ +doesn’t have a manual yet. + + If you are trying to find an unused key that you can bind to a +command provided by your own Magit extension, then checkout +<https://github.com/magit/magit/wiki/Plugin-Dispatch-Key-Registry>. + +* Menu: + +* Calling Git:: +* Section Plumbing:: +* Refreshing Buffers:: +* Conventions:: + + +File: magit.info, Node: Calling Git, Next: Section Plumbing, Up: Plumbing + +10.1 Calling Git +================ + +Magit provides many specialized functions for calling Git. All of these +functions are defined in either ‘magit-git.el’ or ‘magit-process.el’ and +have one of the prefixes ‘magit-run-’, ‘magit-call-’, ‘magit-start-’, or +‘magit-git-’ (which is also used for other things). + + All of these functions accept an indefinite number of arguments, +which are strings that specify command line arguments for Git (or in +some cases an arbitrary executable). These arguments are flattened +before being passed on to the executable; so instead of strings they can +also be lists of strings and arguments that are ‘nil’ are silently +dropped. Some of these functions also require a single mandatory +argument before these command line arguments. + + Roughly speaking, these functions run Git either to get some value or +for side-effects. The functions that return a value are useful to +collect the information necessary to populate a Magit buffer, while the +others are used to implement Magit commands. + + The functions in the value-only group always run synchronously, and +they never trigger a refresh. The function in the side-effect group can +be further divided into subgroups depending on whether they run Git +synchronously or asynchronously, and depending on whether they trigger a +refresh when the executable has finished. + +* Menu: + +* Getting a Value from Git:: +* Calling Git for Effect:: + + +File: magit.info, Node: Getting a Value from Git, Next: Calling Git for Effect, Up: Calling Git + +10.1.1 Getting a Value from Git +------------------------------- + +These functions run Git in order to get a value, an exit status, or +output. Of course you could also use them to run Git commands that have +side-effects, but that should be avoided. + + -- Function: magit-git-exit-code &rest args + Executes git with ARGS and returns its exit code. + + -- Function: magit-git-success &rest args + Executes git with ARGS and returns ‘t’ if the exit code is ‘0’, + ‘nil’ otherwise. + + -- Function: magit-git-failure &rest args + Executes git with ARGS and returns ‘t’ if the exit code is ‘1’, + ‘nil’ otherwise. + + -- Function: magit-git-true &rest args + Executes git with ARGS and returns ‘t’ if the first line printed by + git is the string "true", ‘nil’ otherwise. + + -- Function: magit-git-false &rest args + Executes git with ARGS and returns ‘t’ if the first line printed by + git is the string "false", ‘nil’ otherwise. + + -- Function: magit-git-insert &rest args + Executes git with ARGS and inserts its output at point. + + -- Function: magit-git-string &rest args + Executes git with ARGS and returns the first line of its output. + If there is no output or if it begins with a newline character, + then this returns ‘nil’. + + -- Function: magit-git-lines &rest args + Executes git with ARGS and returns its output as a list of lines. + Empty lines anywhere in the output are omitted. + + -- Function: magit-git-items &rest args + Executes git with ARGS and returns its null-separated output as a + list. Empty items anywhere in the output are omitted. + + If the value of option ‘magit-git-debug’ is non-nil and git exits + with a non-zero exit status, then warn about that in the echo area + and add a section containing git’s standard error in the current + repository’s process buffer. + + -- Function: magit-process-git destination &rest args + Calls Git synchronously in a separate process, returning its exit + code. DESTINATION specifies how to handle the output, like for + ‘call-process’, except that file handlers are supported. Enables + Cygwin’s "noglob" option during the call and ensures unix eol + conversion. + + -- Function: magit-process-file process &optional infile buffer display + &rest args + Processes files synchronously in a separate process. Identical to + ‘process-file’ but temporarily enables Cygwin’s "noglob" option + during the call and ensures unix eol conversion. + + If an error occurs when using one of the above functions, then that +is usually due to a bug, i.e., using an argument which is not actually +supported. Such errors are usually not reported, but when they occur we +need to be able to debug them. + + -- User Option: magit-git-debug + Whether to report errors that occur when using ‘magit-git-insert’, + ‘magit-git-string’, ‘magit-git-lines’, or ‘magit-git-items’. This + does not actually raise an error. Instead a message is shown in + the echo area, and git’s standard error is insert into a new + section in the current repository’s process buffer. + + -- Function: magit-git-str &rest args + This is a variant of ‘magit-git-string’ that ignores the option + ‘magit-git-debug’. It is mainly intended to be used while handling + errors in functions that do respect that option. Using such a + function while handing an error could cause yet another error and + therefore lead to an infinite recursion. You probably won’t ever + need to use this function. + + +File: magit.info, Node: Calling Git for Effect, Prev: Getting a Value from Git, Up: Calling Git + +10.1.2 Calling Git for Effect +----------------------------- + +These functions are used to run git to produce some effect. Most Magit +commands that actually run git do so by using such a function. + + Because we do not need to consume git’s output when using these +functions, their output is instead logged into a per-repository buffer, +which can be shown using ‘$’ from a Magit buffer or ‘M-x magit-process’ +elsewhere. + + These functions can have an effect in two distinct ways. Firstly, +running git may change something, i.e., create or push a new commit. +Secondly, that change may require that Magit buffers are refreshed to +reflect the changed state of the repository. But refreshing isn’t +always desirable, so only some of these functions do perform such a +refresh after git has returned. + + Sometimes it is useful to run git asynchronously. For example, when +the user has just initiated a push, then there is no reason to make her +wait until that has completed. In other cases it makes sense to wait +for git to complete before letting the user do something else. For +example after staging a change it is useful to wait until after the +refresh because that also automatically moves to the next change. + + -- Function: magit-call-git &rest args + Calls git synchronously with ARGS. + + -- Function: magit-call-process program &rest args + Calls PROGRAM synchronously with ARGS. + + -- Function: magit-run-git &rest args + Calls git synchronously with ARGS and then refreshes. + + -- Function: magit-run-git-with-input &rest args + Calls git synchronously with ARGS and sends it the content of the + current buffer on standard input. + + If the current buffer’s ‘default-directory’ is on a remote + filesystem, this function actually runs git asynchronously. But + then it waits for the process to return, so the function itself is + synchronous. + + -- Function: magit-git &rest args + Calls git synchronously with ARGS for side-effects only. This + function does not refresh the buffer. + + -- Function: magit-git-wash washer &rest args + Execute Git with ARGS, inserting washed output at point. Actually + first insert the raw output at point. If there is no output call + ‘magit-cancel-section’. Otherwise temporarily narrow the buffer to + the inserted text, move to its beginning, and then call function + WASHER with ARGS as its sole argument. + + And now for the asynchronous variants. + + -- Function: magit-run-git-async &rest args + Start Git, prepare for refresh, and return the process object. + ARGS is flattened and then used as arguments to Git. + + Display the command line arguments in the echo area. + + After Git returns some buffers are refreshed: the buffer that was + current when this function was called (if it is a Magit buffer and + still alive), as well as the respective Magit status buffer. + Unmodified buffers visiting files that are tracked in the current + repository are reverted if ‘magit-revert-buffers’ is non-nil. + + -- Function: magit-run-git-with-editor &rest args + Export GIT_EDITOR and start Git. Also prepare for refresh and + return the process object. ARGS is flattened and then used as + arguments to Git. + + Display the command line arguments in the echo area. + + After Git returns some buffers are refreshed: the buffer that was + current when this function was called (if it is a Magit buffer and + still alive), as well as the respective Magit status buffer. + + -- Function: magit-start-git input &rest args + Start Git, prepare for refresh, and return the process object. + + If INPUT is non-nil, it has to be a buffer or the name of an + existing buffer. The buffer content becomes the processes standard + input. + + Option ‘magit-git-executable’ specifies the Git executable and + option ‘magit-git-global-arguments’ specifies constant arguments. + The remaining arguments ARGS specify arguments to Git. They are + flattened before use. + + After Git returns, some buffers are refreshed: the buffer that was + current when this function was called (if it is a Magit buffer and + still alive), as well as the respective Magit status buffer. + Unmodified buffers visiting files that are tracked in the current + repository are reverted if ‘magit-revert-buffers’ is non-nil. + + -- Function: magit-start-process &rest args + Start PROGRAM, prepare for refresh, and return the process object. + + If optional argument INPUT is non-nil, it has to be a buffer or the + name of an existing buffer. The buffer content becomes the + processes standard input. + + The process is started using ‘start-file-process’ and then setup to + use the sentinel ‘magit-process-sentinel’ and the filter + ‘magit-process-filter’. Information required by these functions is + stored in the process object. When this function returns the + process has not started to run yet so it is possible to override + the sentinel and filter. + + After the process returns, ‘magit-process-sentinel’ refreshes the + buffer that was current when ‘magit-start-process’ was called (if + it is a Magit buffer and still alive), as well as the respective + Magit status buffer. Unmodified buffers visiting files that are + tracked in the current repository are reverted if + ‘magit-revert-buffers’ is non-nil. + + -- Variable: magit-this-process + The child process which is about to start. This can be used to + change the filter and sentinel. + + -- Variable: magit-process-raise-error + When this is non-nil, then ‘magit-process-sentinel’ raises an error + if git exits with a non-zero exit status. For debugging purposes. + + +File: magit.info, Node: Section Plumbing, Next: Refreshing Buffers, Prev: Calling Git, Up: Plumbing + +10.2 Section Plumbing +===================== + +* Menu: + +* Creating Sections:: +* Section Selection:: +* Matching Sections:: + + +File: magit.info, Node: Creating Sections, Next: Section Selection, Up: Section Plumbing + +10.2.1 Creating Sections +------------------------ + + -- Macro: magit-insert-section &rest args + Insert a section at point. + + TYPE is the section type, a symbol. Many commands that act on the + current section behave differently depending on that type. Also if + a variable ‘magit-TYPE-section-map’ exists, then use that as the + text-property ‘keymap’ of all text belonging to the section (but + this may be overwritten in subsections). TYPE can also have the + form ‘(eval FORM)’ in which case FORM is evaluated at runtime. + + Optional VALUE is the value of the section, usually a string that + is required when acting on the section. + + When optional HIDE is non-nil collapse the section body by default, + i.e., when first creating the section, but not when refreshing the + buffer. Otherwise, expand it by default. This can be overwritten + using ‘magit-section-set-visibility-hook’. When a section is + recreated during a refresh, then the visibility of predecessor is + inherited and HIDE is ignored (but the hook is still honored). + + BODY is any number of forms that actually insert the section’s + heading and body. Optional NAME, if specified, has to be a symbol, + which is then bound to the struct of the section being inserted. + + Before BODY is evaluated the ‘start’ of the section object is set + to the value of ‘point’ and after BODY was evaluated its ‘end’ is + set to the new value of ‘point’; BODY is responsible for moving + ‘point’ forward. + + If it turns out inside BODY that the section is empty, then + ‘magit-cancel-section’ can be used to abort and remove all traces + of the partially inserted section. This can happen when creating a + section by washing Git’s output and Git didn’t actually output + anything this time around. + + -- Function: magit-insert-heading &rest args + Insert the heading for the section currently being inserted. + + This function should only be used inside ‘magit-insert-section’. + + When called without any arguments, then just set the ‘content’ slot + of the object representing the section being inserted to a marker + at ‘point’. The section should only contain a single line when + this function is used like this. + + When called with arguments ARGS, which have to be strings, then + insert those strings at point. The section should not contain any + text before this happens and afterwards it should again only + contain a single line. If the ‘face’ property is set anywhere + inside any of these strings, then insert all of them unchanged. + Otherwise use the ‘magit-section-heading’ face for all inserted + text. + + The ‘content’ property of the section struct is the end of the + heading (which lasts from ‘start’ to ‘content’) and the beginning + of the body (which lasts from ‘content’ to ‘end’). If the value of + ‘content’ is nil, then the section has no heading and its body + cannot be collapsed. If a section does have a heading then its + height must be exactly one line, including a trailing newline + character. This isn’t enforced; you are responsible for getting it + right. The only exception is that this function does insert a + newline character if necessary. + + -- Function: magit-cancel-section + Cancel the section currently being inserted. This exits the + innermost call to ‘magit-insert-section’ and removes all traces of + what has already happened inside that call. + + -- Function: magit-define-section-jumper sym title &optional value + Define an interactive function to go to section SYM. TITLE is the + displayed title of the section. + + +File: magit.info, Node: Section Selection, Next: Matching Sections, Prev: Creating Sections, Up: Section Plumbing + +10.2.2 Section Selection +------------------------ + + -- Function: magit-current-section + Return the section at point. + + -- Function: magit-region-sections &optional condition multiple + Return a list of the selected sections. + + When the region is active and constitutes a valid section + selection, then return a list of all selected sections. This is + the case when the region begins in the heading of a section and + ends in the heading of the same section or in that of a sibling + section. If optional MULTIPLE is non-nil, then the region cannot + begin and end in the same section. + + When the selection is not valid, then return nil. In this case, + most commands that can act on the selected sections will instead + act on the section at point. + + When the region looks like it would in any other buffer then the + selection is invalid. When the selection is valid then the region + uses the ‘magit-section-highlight’ face. This does not apply to + diffs where things get a bit more complicated, but even here if the + region looks like it usually does, then that’s not a valid + selection as far as this function is concerned. + + If optional CONDITION is non-nil, then the selection not only has + to be valid; all selected sections additionally have to match + CONDITION, or nil is returned. See ‘magit-section-match’ for the + forms CONDITION can take. + + -- Function: magit-region-values &optional condition multiple + Return a list of the values of the selected sections. + + Return the values that themselves would be returned by + ‘magit-region-sections’ (which see). + + +File: magit.info, Node: Matching Sections, Prev: Section Selection, Up: Section Plumbing + +10.2.3 Matching Sections +------------------------ + +‘M-x magit-describe-section-briefly’ + Show information about the section at point. This command is + intended for debugging purposes. + + -- Function: magit-section-ident section + Return an unique identifier for SECTION. The return value has the + form ‘((TYPE . VALUE)...)’. + + -- Function: magit-get-section ident &optional root + Return the section identified by IDENT. IDENT has to be a list as + returned by ‘magit-section-ident’. + + -- Function: magit-section-match condition &optional section + Return ‘t’ if SECTION matches CONDITION. SECTION defaults to the + section at point. If SECTION is not specified and there also is no + section at point, then return ‘nil’. + + CONDITION can take the following forms: + • ‘(CONDITION...)’ + + matches if any of the CONDITIONs matches. + + • ‘[CLASS...]’ + + matches if the section’s class is the same as the first CLASS + or a subclass of that; the section’s parent class matches the + second CLASS; and so on. + + • ‘[* CLASS...]’ + + matches sections that match ‘[CLASS...]’ and also recursively + all their child sections. + + • ‘CLASS’ + + matches if the section’s class is the same as CLASS or a + subclass of that; regardless of the classes of the parent + sections. + + Each CLASS should be a class symbol, identifying a class that + derives from ‘magit-section’. For backward compatibility CLASS can + also be a "type symbol". A section matches such a symbol if the + value of its ‘type’ slot is ‘eq’. If a type symbol has an entry in + ‘magit--section-type-alist’, then a section also matches that type + if its class is a subclass of the class that corresponds to the + type as per that alist. + + Note that it is not necessary to specify the complete section + lineage as printed by ‘magit-describe-section-briefly’, unless of + course you want to be that precise. + + -- Function: magit-section-value-if condition &optional section + If the section at point matches CONDITION, then return its value. + + If optional SECTION is non-nil then test whether that matches + instead. If there is no section at point and SECTION is nil, then + return nil. If the section does not match, then return nil. + + See ‘magit-section-match’ for the forms CONDITION can take. + + -- Function: magit-section-case &rest clauses + Choose among clauses on the type of the section at point. + + Each clause looks like (CONDITION BODY...). The type of the + section is compared against each CONDITION; the BODY forms of the + first match are evaluated sequentially and the value of the last + form is returned. Inside BODY the symbol ‘it’ is bound to the + section at point. If no clause succeeds or if there is no section + at point return nil. + + See ‘magit-section-match’ for the forms CONDITION can take. + Additionally a CONDITION of t is allowed in the final clause and + matches if no other CONDITION match, even if there is no section at + point. + + -- Variable: magit-root-section + The root section in the current buffer. All other sections are + descendants of this section. The value of this variable is set by + ‘magit-insert-section’ and you should never modify it. + + For diff related sections a few additional tools exist. + + -- Function: magit-diff-type &optional section + Return the diff type of SECTION. + + The returned type is one of the symbols ‘staged’, ‘unstaged’, + ‘committed’, or ‘undefined’. This type serves a similar purpose as + the general type common to all sections (which is stored in the + ‘type’ slot of the corresponding ‘magit-section’ struct) but takes + additional information into account. When the SECTION isn’t + related to diffs and the buffer containing it also isn’t a + diff-only buffer, then return nil. + + Currently the type can also be one of ‘tracked’ and ‘untracked’, + but these values are not handled explicitly in every place they + should be. A possible fix could be to just return nil here. + + The section has to be a ‘diff’ or ‘hunk’ section, or a section + whose children are of type ‘diff’. If optional SECTION is nil, + return the diff type for the current section. In buffers whose + major mode is ‘magit-diff-mode’ SECTION is ignored and the type is + determined using other means. In ‘magit-revision-mode’ buffers the + type is always ‘committed’. + + -- Function: magit-diff-scope &optional section strict + Return the diff scope of SECTION or the selected section(s). + + A diff’s "scope" describes what part of a diff is selected, it is a + symbol, one of ‘region’, ‘hunk’, ‘hunks’, ‘file’, ‘files’, or + ‘list’. Do not confuse this with the diff "type", as returned by + ‘magit-diff-type’. + + If optional SECTION is non-nil, then return the scope of that, + ignoring the sections selected by the region. Otherwise return the + scope of the current section, or if the region is active and + selects a valid group of diff related sections, the type of these + sections, i.e., ‘hunks’ or ‘files’. If SECTION (or if the current + section that is nil) is a ‘hunk’ section and the region starts and + ends inside the body of a that section, then the type is ‘region’. + + If optional STRICT is non-nil then return nil if the diff type of + the section at point is ‘untracked’ or the section at point is not + actually a ‘diff’ but a ‘diffstat’ section. + + +File: magit.info, Node: Refreshing Buffers, Next: Conventions, Prev: Section Plumbing, Up: Plumbing + +10.3 Refreshing Buffers +======================= + +All commands that create a new Magit buffer or change what is being +displayed in an existing buffer do so by calling ‘magit-mode-setup’. +Among other things, that function sets the buffer local values of +‘default-directory’ (to the top-level of the repository), +‘magit-refresh-function’, and ‘magit-refresh-args’. + + Buffers are refreshed by calling the function that is the local value +of ‘magit-refresh-function’ (a function named ‘magit-*-refresh-buffer’, +where ‘*’ may be something like ‘diff’) with the value of +‘magit-refresh-args’ as arguments. + + -- Macro: magit-mode-setup buffer switch-func mode refresh-func + &optional refresh-args + This function displays and selects BUFFER, turns on MODE, and + refreshes a first time. + + This function displays and optionally selects BUFFER by calling + ‘magit-mode-display-buffer’ with BUFFER, MODE and SWITCH-FUNC as + arguments. Then it sets the local value of + ‘magit-refresh-function’ to REFRESH-FUNC and that of + ‘magit-refresh-args’ to REFRESH-ARGS. Finally it creates the + buffer content by calling REFRESH-FUNC with REFRESH-ARGS as + arguments. + + All arguments are evaluated before switching to BUFFER. + + -- Function: magit-mode-display-buffer buffer mode &optional + switch-function + This function display BUFFER in some window and select it. BUFFER + may be a buffer or a string, the name of a buffer. The buffer is + returned. + + Unless BUFFER is already displayed in the selected frame, store the + previous window configuration as a buffer local value, so that it + can later be restored by ‘magit-mode-bury-buffer’. + + The buffer is displayed and selected using SWITCH-FUNCTION. If + that is ‘nil’ then ‘pop-to-buffer’ is used if the current buffer’s + major mode derives from ‘magit-mode’. Otherwise ‘switch-to-buffer’ + is used. + + -- Variable: magit-refresh-function + The value of this buffer-local variable is the function used to + refresh the current buffer. It is called with ‘magit-refresh-args’ + as arguments. + + -- Variable: magit-refresh-args + The list of arguments used by ‘magit-refresh-function’ to refresh + the current buffer. ‘magit-refresh-function’ is called with these + arguments. + + The value is usually set using ‘magit-mode-setup’, but in some + cases it’s also useful to provide commands that can change the + value. For example, the ‘magit-diff-refresh’ transient can be used + to change any of the arguments used to display the diff, without + having to specify again which differences should be shown, but + ‘magit-diff-more-context’, ‘magit-diff-less-context’ and + ‘magit-diff-default-context’ change just the ‘-U<N>’ argument. In + both case this is done by changing the value of this variable and + then calling this ‘magit-refresh-function’. + + +File: magit.info, Node: Conventions, Prev: Refreshing Buffers, Up: Plumbing + +10.4 Conventions +================ + +Also see *note Completion and Confirmation::. + +* Menu: + +* Theming Faces:: + + +File: magit.info, Node: Theming Faces, Up: Conventions + +10.4.1 Theming Faces +-------------------- + +The default theme uses blue for local branches, green for remote +branches, and goldenrod (brownish yellow) for tags. When creating a new +theme, you should probably follow that example. If your theme already +uses other colors, then stick to that. + + In older releases these reference faces used to have a background +color and a box around them. The basic default faces no longer do so, +to make Magit buffers much less noisy, and you should follow that +example at least with regards to boxes. (Boxes were used in the past to +work around a conflict between the highlighting overlay and text +property backgrounds. That’s no longer necessary because highlighting +no longer causes other background colors to disappear.) Alternatively +you can keep the background color and/or box, but then have to take +special care to adjust ‘magit-branch-current’ accordingly. By default +it looks mostly like ‘magit-branch-local’, but with a box (by default +the former is the only face that uses a box, exactly so that it sticks +out). If the former also uses a box, then you have to make sure that it +differs in some other way from the latter. + + The most difficult faces to theme are those related to diffs, +headings, highlighting, and the region. There are faces that fall into +all four groups - expect to spend some time getting this right. + + The ‘region’ face in the default theme, in both the light and dark +variants, as well as in many other themes, distributed with Emacs or by +third-parties, is very ugly. It is common to use a background color +that really sticks out, which is ugly but if that were the only problem +then it would be acceptable. Unfortunately many themes also set the +foreground color, which ensures that all text within the region is +readable. Without doing that there might be cases where some foreground +color is too close to the region background color to still be readable. +But it also means that text within the region loses all syntax +highlighting. + + I consider the work that went into getting the ‘region’ face right to +be a good indicator for the general quality of a theme. My +recommendation for the ‘region’ face is this: use a background color +slightly different from the background color of the ‘default’ face, and +do not set the foreground color at all. So for a light theme you might +use a light (possibly tinted) gray as the background color of ‘default’ +and a somewhat darker gray for the background of ‘region’. That should +usually be enough to not collide with the foreground color of any other +face. But if some other faces also set a light gray as background +color, then you should also make sure it doesn’t collide with those (in +some cases it might be acceptable though). + + Magit only uses the ‘region’ face when the region is "invalid" by its +own definition. In a Magit buffer the region is used to either select +multiple sibling sections, so that commands which support it act on all +of these sections instead of just the current section, or to select +lines within a single hunk section. In all other cases, the section is +considered invalid and Magit won’t act on it. But such invalid sections +happen, either because the user has not moved point enough yet to make +it valid or because she wants to use a non-magit command to act on the +region, e.g., ‘kill-region’. + + So using the regular ‘region’ face for invalid sections is a feature. +It tells the user that Magit won’t be able to act on it. It’s +acceptable if that face looks a bit odd and even (but less so) if it +collides with the background colors of section headings and other things +that have a background color. + + Magit highlights the current section. If a section has subsections, +then all of them are highlighted. This is done using faces that have +"highlight" in their names. For most sections, +‘magit-section-highlight’ is used for both the body and the heading. +Like the ‘region’ face, it should only set the background color to +something similar to that of ‘default’. The highlight background color +must be different from both the ‘region’ background color and the +‘default’ background color. + + For diff related sections Magit uses various faces to highlight +different parts of the selected section(s). Note that hunk headings, +unlike all other section headings, by default have a background color, +because it is useful to have very visible separators between hunks. +That face ‘magit-diff-hunk-heading’, should be different from both +‘magit-diff-hunk-heading-highlight’ and ‘magit-section-highlight’, as +well as from ‘magit-diff-context’ and ‘magit-diff-context-highlight’. +By default we do that by changing the foreground color. Changing the +background color would lead to complications, and there are already +enough we cannot get around. (Also note that it is generally a good +idea for section headings to always be bold, but only for sections that +have subsections). + + When there is a valid region selecting diff-related sibling sections, +i.e., multiple files or hunks, then the bodies of all these sections use +the respective highlight faces, but additionally the headings instead +use one of the faces ‘magit-diff-file-heading-selection’ or +‘magit-diff-hunk-heading-selection’. These faces have to be different +from the regular highlight variants to provide explicit visual +indication that the region is active. + + When theming diff related faces, start by setting the option +‘magit-diff-refine-hunk’ to ‘all’. You might personally prefer to only +refine the current hunk or not use hunk refinement at all, but some of +the users of your theme want all hunks to be refined, so you have to +cater to that. + + (Also turn on ‘magit-diff-highlight-indentation’, +‘magit-diff-highlight-trailing’, and ‘magit-diff-paint-whitespace’; and +insert some whitespace errors into the code you use for testing.) + + For added lines you have to adjust three faces: ‘magit-diff-added’, +‘magit-diff-added-highlight’, and ‘diff-refined-added’. Make sure that +the latter works well with both of the former, as well as ‘smerge-other’ +and ‘diff-added’. Then do the same for the removed lines, context +lines, lines added by us, and lines added by them. Also make sure the +respective added, removed, and context faces use approximately the same +saturation for both the highlighted and unhighlighted variants. Also +make sure the file and diff headings work nicely with context lines +(e.g., make them look different). Line faces should set both the +foreground and the background color. For example, for added lines use +two different greens. + + It’s best if the foreground color of both the highlighted and the +unhighlighted variants are the same, so you will need to have to find a +color that works well on the highlight and unhighlighted background, the +refine background, and the highlight context background. When there is +an hunk internal region, then the added- and removed-lines background +color is used only within that region. Outside the region the +highlighted context background color is used. This makes it easier to +see what is being staged. With an hunk internal region the hunk heading +is shown using ‘magit-diff-hunk-heading-selection’, and so are the thin +lines that are added around the lines that fall within the region. The +background color of that has to be distinct enough from the various +other involved background colors. + + Nobody said this would be easy. If your theme restricts itself to a +certain set of colors, then you should make an exception here. +Otherwise it would be impossible to make the diffs look good in each and +every variation. Actually you might want to just stick to the default +definitions for these faces. You have been warned. Also please note +that if you do not get this right, this will in some cases look to users +like bugs in Magit - so please do it right or not at all. + + +File: magit.info, Node: FAQ, Next: Debugging Tools, Prev: Plumbing, Up: Top + +Appendix A FAQ +************** + +The next two nodes lists frequently asked questions. For a list of +frequently *and recently* asked questions, i.e., questions that haven’t +made it into the manual yet, see +<https://github.com/magit/magit/wiki/FAQ>. + + Please also see *note Debugging Tools::. + +* Menu: + +* FAQ - How to ...?:: +* FAQ - Issues and Errors:: + + +File: magit.info, Node: FAQ - How to ...?, Next: FAQ - Issues and Errors, Up: FAQ + +A.1 FAQ - How to ...? +===================== + +* Menu: + +* How to pronounce Magit?:: +* How to show git's output?:: +* How to install the gitman info manual?:: +* How to show diffs for gpg-encrypted files?:: +* How does branching and pushing work?:: +* Should I disable VC?:: + + +File: magit.info, Node: How to pronounce Magit?, Next: How to show git's output?, Up: FAQ - How to ...? + +A.1.1 How to pronounce Magit? +----------------------------- + +Either ‘mu[m's] git’ or ‘magi{c => t}’ is fine. + + The slogan is "It’s Magit! The magical Git client", so it makes +sense to pronounce Magit like magic, while taking into account that C +and T do not sound the same. + + The German "Magie" is not pronounced the same as the English "magic", +so if you speak German then you can use the above rationale to justify +using the former pronunciation; ‘Mag{ie => it}’. + + You can also choose to use the former pronunciation just because you +like it better. + + Also see <https://magit.vc/assets/videos/magic.mp4>. Also see +<https://emacs.stackexchange.com/questions/13696>. + + +File: magit.info, Node: How to show git's output?, Next: How to install the gitman info manual?, Prev: How to pronounce Magit?, Up: FAQ - How to ...? + +A.1.2 How to show git’s output? +------------------------------- + +To show the output of recently run git commands, press ‘$’ (or, if that +isn’t available, ‘M-x magit-process-buffer’). This will show a buffer +containing a section per git invocation; as always press ‘TAB’ to expand +or collapse them. + + By default, git’s output is only inserted into the process buffer if +it is run for side-effects. When the output is consumed in some way, +also inserting it into the process buffer would be too expensive. For +debugging purposes, it’s possible to do so anyway by setting +‘magit-git-debug’ to ‘t’. + + +File: magit.info, Node: How to install the gitman info manual?, Next: How to show diffs for gpg-encrypted files?, Prev: How to show git's output?, Up: FAQ - How to ...? + +A.1.3 How to install the gitman info manual? +-------------------------------------------- + +Git’s manpages can be exported as an info manual called ‘gitman’. +Magit’s own info manual links to nodes in that manual instead of the +actual manpages because Info doesn’t support linking to manpages. + + Unfortunately some distributions do not install the ‘gitman’ manual +by default and you will have to install a separate documentation package +to get it. + + Magit patches Info adding the ability to visit links to the ‘gitman’ +Info manual by instead viewing the respective manpage. If you prefer +that approach, then set the value of ‘magit-view-git-manual-method’ to +one of the supported packages ‘man’ or ‘woman’, e.g.: + + (setq magit-view-git-manual-method 'man) + + +File: magit.info, Node: How to show diffs for gpg-encrypted files?, Next: How does branching and pushing work?, Prev: How to install the gitman info manual?, Up: FAQ - How to ...? + +A.1.4 How to show diffs for gpg-encrypted files? +------------------------------------------------ + +Git supports showing diffs for encrypted files, but has to be told to do +so. Since Magit just uses Git to get the diffs, configuring Git also +affects the diffs displayed inside Magit. + + git config --global diff.gpg.textconv "gpg --no-tty --decrypt" + echo "*.gpg filter=gpg diff=gpg" > .gitattributes + + +File: magit.info, Node: How does branching and pushing work?, Next: Should I disable VC?, Prev: How to show diffs for gpg-encrypted files?, Up: FAQ - How to ...? + +A.1.5 How does branching and pushing work? +------------------------------------------ + +Please see *note Branching:: and +<https://emacsair.me/2016/01/17/magit-2.4> + + +File: magit.info, Node: Should I disable VC?, Prev: How does branching and pushing work?, Up: FAQ - How to ...? + +A.1.6 Should I disable VC? +-------------------------- + +If you don’t use VC (the built-in version control interface) then you +might be tempted to disable it, not least because we used to recommend +that you do that. + + We no longer recommend that you disable VC. Doing so would break +useful third-party packages (such as ‘diff-hl’), which depend on VC +being enabled. + + If you choose to disable VC anyway, then you can do so by changing +the value of ‘vc-handled-backends’. + + +File: magit.info, Node: FAQ - Issues and Errors, Prev: FAQ - How to ...?, Up: FAQ + +A.2 FAQ - Issues and Errors +=========================== + +* Menu: + +* Magit is slow:: +* I changed several thousand files at once and now Magit is unusable:: +* I am having problems committing:: +* I am using MS Windows and cannot push with Magit:: +* I am using macOS and SOMETHING works in shell, but not in Magit: I am using macOS and SOMETHING works in shell but not in Magit. +* Expanding a file to show the diff causes it to disappear:: +* Point is wrong in the COMMIT_EDITMSG buffer:: +* The mode-line information isn't always up-to-date:: +* A branch and tag sharing the same name breaks SOMETHING:: +* My Git hooks work on the command-line but not inside Magit:: +* git-commit-mode isn't used when committing from the command-line:: +* Point ends up inside invisible text when jumping to a file-visiting buffer:: +* I am no longer able to save popup defaults:: + + +File: magit.info, Node: Magit is slow, Next: I changed several thousand files at once and now Magit is unusable, Up: FAQ - Issues and Errors + +A.2.1 Magit is slow +------------------- + +See *note Performance:: and *note I changed several thousand files at +once and now Magit is unusable::. + + +File: magit.info, Node: I changed several thousand files at once and now Magit is unusable, Next: I am having problems committing, Prev: Magit is slow, Up: FAQ - Issues and Errors + +A.2.2 I changed several thousand files at once and now Magit is unusable +------------------------------------------------------------------------ + +Magit is currently not expected to work well under such conditions. It +sure would be nice if it did. Reaching satisfactory performance under +such conditions will require some heavy refactoring. This is no small +task but I hope to eventually find the time to make it happen. + + But for now we recommend you use the command line to complete this +one commit. Also see *note Performance::. + + +File: magit.info, Node: I am having problems committing, Next: I am using MS Windows and cannot push with Magit, Prev: I changed several thousand files at once and now Magit is unusable, Up: FAQ - Issues and Errors + +A.2.3 I am having problems committing +------------------------------------- + +That likely means that Magit is having problems finding an appropriate +emacsclient executable. See *note (with-editor)Configuring +With-Editor:: and *note (with-editor)Debugging::. + + +File: magit.info, Node: I am using MS Windows and cannot push with Magit, Next: I am using macOS and SOMETHING works in shell but not in Magit, Prev: I am having problems committing, Up: FAQ - Issues and Errors + +A.2.4 I am using MS Windows and cannot push with Magit +------------------------------------------------------ + +It’s almost certain that Magit is only incidental to this issue. It is +much more likely that this is a configuration issue, even if you can +push on the command line. + + Detailed setup instructions can be found at +<https://github.com/magit/magit/wiki/Pushing-with-Magit-from-Windows>. + + +File: magit.info, Node: I am using macOS and SOMETHING works in shell but not in Magit, Next: Expanding a file to show the diff causes it to disappear, Prev: I am using MS Windows and cannot push with Magit, Up: FAQ - Issues and Errors + +A.2.5 I am using macOS and SOMETHING works in shell, but not in Magit +--------------------------------------------------------------------- + +This usually occurs because Emacs doesn’t have the same environment +variables as your shell. Try installing and configuring +<https://github.com/purcell/exec-path-from-shell>. By default it +synchronizes ‘$PATH’, which helps Magit find the same ‘git’ as the one +you are using on the shell. + + If SOMETHING is "passphrase caching with gpg-agent for commit and/or +tag signing", then you’ll also need to synchronize ‘$GPG_AGENT_INFO’. + + +File: magit.info, Node: Expanding a file to show the diff causes it to disappear, Next: Point is wrong in the COMMIT_EDITMSG buffer, Prev: I am using macOS and SOMETHING works in shell but not in Magit, Up: FAQ - Issues and Errors + +A.2.6 Expanding a file to show the diff causes it to disappear +-------------------------------------------------------------- + +This is probably caused by a customization of a ‘diff.*’ Git variable. +You probably set that variable for a reason, and should therefore only +undo that setting in Magit by customizing ‘magit-git-global-arguments’. + + +File: magit.info, Node: Point is wrong in the COMMIT_EDITMSG buffer, Next: The mode-line information isn't always up-to-date, Prev: Expanding a file to show the diff causes it to disappear, Up: FAQ - Issues and Errors + +A.2.7 Point is wrong in the ‘COMMIT_EDITMSG’ buffer +--------------------------------------------------- + +Neither Magit nor ‘git-commit‘ fiddle with point in the buffer used to +write commit messages, so something else must be doing it. + + You have probably globally enabled a mode which restores point in +file-visiting buffers. It might be a bit surprising, but when you write +a commit message, then you are actually editing a file. + + So you have to figure out which package is doing it. ‘saveplace’, +‘pointback’, and ‘session’ are likely candidates. These snippets might +help: + + (setq session-name-disable-regexp "\\(?:\\`'\\.git/[A-Z_]+\\'\\)") + + (with-eval-after-load 'pointback + (lambda () + (when (or git-commit-mode git-rebase-mode) + (pointback-mode -1)))) + + +File: magit.info, Node: The mode-line information isn't always up-to-date, Next: A branch and tag sharing the same name breaks SOMETHING, Prev: Point is wrong in the COMMIT_EDITMSG buffer, Up: FAQ - Issues and Errors + +A.2.8 The mode-line information isn’t always up-to-date +------------------------------------------------------- + +Magit is not responsible for the version control information that is +being displayed in the mode-line and looks something like ‘Git-master’. +The built-in "Version Control" package, also known as "VC", updates that +information, and can be told to do so more often: + + (setq auto-revert-check-vc-info t) + + But doing so isn’t good for performance. For more (overly +optimistic) information see *note (emacs)VC Mode Line::. + + If you don’t really care about seeing this information in the +mode-line, but just don’t want to see _incorrect_ information, then +consider simply not displaying it in the mode-line: + + (setq-default mode-line-format + (delete '(vc-mode vc-mode) mode-line-format)) + + +File: magit.info, Node: A branch and tag sharing the same name breaks SOMETHING, Next: My Git hooks work on the command-line but not inside Magit, Prev: The mode-line information isn't always up-to-date, Up: FAQ - Issues and Errors + +A.2.9 A branch and tag sharing the same name breaks SOMETHING +------------------------------------------------------------- + +Or more generally, ambiguous refnames break SOMETHING. + + Magit assumes that refs are named non-ambiguously across the +"refs/heads/", "refs/tags/", and "refs/remotes/" namespaces (i.e., all +the names remain unique when those prefixes are stripped). We consider +ambiguous refnames unsupported and recommend that you use a +non-ambiguous naming scheme. However, if you do work with a repository +that has ambiguous refnames, please report any issues you encounter, so +that we can investigate whether there is a simple fix. + + +File: magit.info, Node: My Git hooks work on the command-line but not inside Magit, Next: git-commit-mode isn't used when committing from the command-line, Prev: A branch and tag sharing the same name breaks SOMETHING, Up: FAQ - Issues and Errors + +A.2.10 My Git hooks work on the command-line but not inside Magit +----------------------------------------------------------------- + +When Magit calls ‘git’ it adds a few global arguments including +‘--literal-pathspecs’ and the ‘git’ process started by Magit then passes +that setting on to other ‘git’ process it starts itself. It does so by +setting the environment variable ‘GIT_LITERAL_PATHSPECS’, not by calling +subprocesses with the ‘--literal-pathspecs’ argument. You can therefore +override this setting in hook scripts using ‘unset +GIT_LITERAL_PATHSPECS’. + + +File: magit.info, Node: git-commit-mode isn't used when committing from the command-line, Next: Point ends up inside invisible text when jumping to a file-visiting buffer, Prev: My Git hooks work on the command-line but not inside Magit, Up: FAQ - Issues and Errors + +A.2.11 ‘git-commit-mode’ isn’t used when committing from the command-line +------------------------------------------------------------------------- + +The reason for this is that ‘git-commit.el’ has not been loaded yet +and/or that the server has not been started yet. These things have +always already been taken care of when you commit from Magit because in +order to do so, Magit has to be loaded and doing that involves loading +‘git-commit’ and starting the server. + + If you want to commit from the command-line, then you have to take +care of these things yourself. Your ‘init.el’ file should contain: + + (require 'git-commit) + (server-mode) + + Instead of ‘(require ’git-commit)‘ you may also use: + + (load "/path/to/magit-autoloads.el") + + You might want to do that because loading ‘git-commit’ causes large +parts of Magit to be loaded. + + There are also some variations of ‘(server-mode)’ that you might want +to try. Personally I use: + + (use-package server + :config (or (server-running-p) (server-mode))) + + Now you can use: + + $ emacs& + $ EDITOR=emacsclient git commit + + However you cannot use: + + $ killall emacs + $ EDITOR="emacsclient --alternate-editor emacs" git commit + + This will actually end up using ‘emacs’, not ‘emacsclient’. If you +do this, then you can still edit the commit message but +‘git-commit-mode’ won’t be used and you have to exit ‘emacs’ to finish +the process. + + Tautology ahead. If you want to be able to use ‘emacsclient’ to +connect to a running ‘emacs’ instance, even though no ‘emacs’ instance +is running, then you cannot use ‘emacsclient’ directly. + + Instead you have to create a script that does something like this: + + Try to use ‘emacsclient’ (without using ‘--alternate-editor’). If +that succeeds, do nothing else. Otherwise start ‘emacs &’ (and +‘init.el’ must call ‘server-start’) and try to use ‘emacsclient’ again. + + +File: magit.info, Node: Point ends up inside invisible text when jumping to a file-visiting buffer, Next: I am no longer able to save popup defaults, Prev: git-commit-mode isn't used when committing from the command-line, Up: FAQ - Issues and Errors + +A.2.12 Point ends up inside invisible text when jumping to a file-visiting buffer +--------------------------------------------------------------------------------- + +This can happen when you type ‘RET’ on a hunk to visit the respective +file at the respective position. One solution to this problem is to use +‘global-reveal-mode’. It makes sure that text around point is always +visible. If that is too drastic for your taste, then you may instead +use ‘magit-diff-visit-file-hook’ to reveal the text, possibly using +‘reveal-post-command’ or for Org buffers ‘org-reveal’. + + +File: magit.info, Node: I am no longer able to save popup defaults, Prev: Point ends up inside invisible text when jumping to a file-visiting buffer, Up: FAQ - Issues and Errors + +A.2.13 I am no longer able to save popup defaults +------------------------------------------------- + +Magit used to use Magit-Popup to implement the transient popup menus. +Now it used Transient instead, which is Magit-Popup’s successor. + + In the older Magit-Popup menus, it was possible to save user settings +(e.g., setting the gpg signing key for commits) by using ‘C-c C-c’ in +the popup buffer. This would dismiss the popup, but save the settings +as the defaults for future popups. + + When switching to Transient menus, this functionality is now +available via ‘C-x C-s’ instead; the ‘C-x’ prefix has other options as +well when using Transient, which will be displayed when it is typed. +See <https://magit.vc/manual/transient/Saving-Values.html#Saving-Values> +for more details. + + +File: magit.info, Node: Debugging Tools, Next: Keystroke Index, Prev: FAQ, Up: Top + +B Debugging Tools +***************** + +Magit and its dependencies provide a few debugging tools, and we +appreciate it very much if you use those tools before reporting an +issue. Please include all relevant output when reporting an issue. + +‘M-x magit-version’ + This command shows the currently used versions of Magit, Git, and + Emacs in the echo area. Non-interactively this just returns the + Magit version. + +‘M-x magit-emacs-Q-command’ + This command shows a debugging shell command in the echo area and + adds it to the kill ring. Paste that command into a shell and run + it. + + This shell command starts ‘emacs’ with only ‘magit’ and its + dependencies loaded. Neither your configuration nor other + installed packages are loaded. This makes it easier to determine + whether some issue lays with Magit or something else. + + If you run Magit from its Git repository, then you should be able + to use ‘make emacs-Q’ instead of the output of this command. + +‘M-x magit-toggle-git-debug’ + This command toggles whether additional git errors are reported. + + Magit basically calls git for one of these two reasons: for + side-effects or to do something with its standard output. + + When git is run for side-effects then its output, including error + messages, go into the process buffer which is shown when using ‘$’. + + When git’s output is consumed in some way, then it would be too + expensive to also insert it into this buffer, but when this option + is non-nil and git returns with a non-zero exit status, then at + least its standard error is inserted into this buffer. + + This is only intended for debugging purposes. Do not enable this + permanently, that would negatively affect performance. Also note + that just because git exits with a non-zero exit status and prints + an error message that usually doesn’t mean that it is an error as + far as Magit is concerned, which is another reason we usually hide + these error messages. Whether some error message is relevant in + the context of some unexpected behavior has to be judged on a case + by case basis. + +‘M-x magit-toggle-verbose-refresh’ + This command toggles whether Magit refreshes buffers verbosely. + Enabling this helps figuring out which sections are bottlenecks. + The additional output can be found in the ‘*Messages*’ buffer. + +‘M-x magit-debug-git-executable’ + This command displays a buffer containing information about the + available and used ‘git’ executable(s), and can be useful when + investigating ‘exec-path’ issues. + + Also see *note Git Executable::. + +‘M-x with-editor-debug’ + This command displays a buffer containing information about the + available and used ‘emacsclient’ executable(s), and can be useful + when investigating why Magit (or rather ‘with-editor’) cannot find + an appropriate ‘emacsclient’ executable. + + Also see *note (with-editor)Debugging::. + +Please also see *note FAQ::. + + +File: magit.info, Node: Keystroke Index, Next: Function and Command Index, Prev: Debugging Tools, Up: Top + +Appendix C Keystroke Index +************************** + + +* Menu: + +* !: Running Git Manually. + (line 13) +* ! !: Running Git Manually. + (line 17) +* ! a: Running Git Manually. + (line 53) +* ! b: Running Git Manually. + (line 56) +* ! g: Running Git Manually. + (line 59) +* ! k: Running Git Manually. + (line 50) +* ! m: Running Git Manually. + (line 62) +* ! p: Running Git Manually. + (line 25) +* ! s: Running Git Manually. + (line 34) +* ! S: Running Git Manually. + (line 38) +* $: Viewing Git Output. (line 17) +* +: Log Buffer. (line 64) +* + <1>: Refreshing Diffs. (line 65) +* -: Log Buffer. (line 67) +* - <1>: Refreshing Diffs. (line 62) +* 0: Refreshing Diffs. (line 68) +* 1: Section Visibility. (line 39) +* 2: Section Visibility. (line 39) +* 3: Section Visibility. (line 39) +* 4: Section Visibility. (line 39) +* 5: Repository List. (line 115) +* :: Running Git Manually. + (line 25) +* =: Log Buffer. (line 59) +* >: Sparse checkouts. (line 17) +* > a: Sparse checkouts. (line 39) +* > d: Sparse checkouts. (line 50) +* > e: Sparse checkouts. (line 21) +* > r: Sparse checkouts. (line 44) +* > s: Sparse checkouts. (line 33) +* ^: Section Movement. (line 28) +* a: Applying. (line 34) +* A: Cherry Picking. (line 9) +* A A: Cherry Picking. (line 17) +* A a: Cherry Picking. (line 23) +* A A <1>: Cherry Picking. (line 85) +* A a <1>: Cherry Picking. (line 91) +* A d: Cherry Picking. (line 51) +* A h: Cherry Picking. (line 40) +* A n: Cherry Picking. (line 62) +* A s: Cherry Picking. (line 72) +* A s <1>: Cherry Picking. (line 88) +* B: Bisecting. (line 9) +* b: Blaming. (line 115) +* b <1>: Branch Commands. (line 13) +* b <2>: Editing Rebase Sequences. + (line 70) +* B B: Bisecting. (line 16) +* B b: Bisecting. (line 32) +* b b: Branch Commands. (line 47) +* b C: Branch Commands. (line 31) +* b c: Branch Commands. (line 63) +* B g: Bisecting. (line 36) +* B k: Bisecting. (line 46) +* b k: Branch Commands. (line 138) +* b l: Branch Commands. (line 69) +* B m: Bisecting. (line 40) +* b m: Branch Commands. (line 149) +* b n: Branch Commands. (line 54) +* B r: Bisecting. (line 51) +* B s: Bisecting. (line 26) +* b s: Branch Commands. (line 91) +* b S: Branch Commands. (line 118) +* b x: Branch Commands. (line 123) +* c: Blaming. (line 141) +* C: Cloning Repository. (line 20) +* c <1>: Initiating a Commit. (line 9) +* c <2>: Editing Rebase Sequences. + (line 59) +* C >: Cloning Repository. (line 38) +* c a: Initiating a Commit. (line 18) +* c A: Initiating a Commit. (line 59) +* C b: Cloning Repository. (line 44) +* C C: Cloning Repository. (line 28) +* c c: Initiating a Commit. (line 14) +* C d: Cloning Repository. (line 55) +* C e: Cloning Repository. (line 61) +* c e: Initiating a Commit. (line 21) +* c f: Initiating a Commit. (line 39) +* c F: Initiating a Commit. (line 46) +* C m: Cloning Repository. (line 48) +* C s: Cloning Repository. (line 32) +* c s: Initiating a Commit. (line 49) +* c S: Initiating a Commit. (line 56) +* c w: Initiating a Commit. (line 30) +* C-<return>: Visiting Files and Blobs from a Diff. + (line 50) +* C-<tab>: Section Visibility. (line 14) +* C-c C-a: Commit Pseudo Headers. + (line 16) +* C-c C-b: Log Buffer. (line 20) +* C-c C-b <1>: Refreshing Diffs. (line 84) +* C-c C-c: Select from Log. (line 21) +* C-c C-c <1>: Editing Commit Messages. + (line 18) +* C-c C-c <2>: Editing Rebase Sequences. + (line 7) +* C-c C-d: Refreshing Diffs. (line 75) +* C-c C-d <1>: Editing Commit Messages. + (line 54) +* C-c C-e: Commands Available in Diffs. + (line 24) +* C-c C-f: Log Buffer. (line 23) +* C-c C-f <1>: Refreshing Diffs. (line 87) +* C-c C-i: Commit Pseudo Headers. + (line 13) +* C-c C-k: Select from Log. (line 26) +* C-c C-k <1>: Editing Commit Messages. + (line 22) +* C-c C-k <2>: Editing Rebase Sequences. + (line 11) +* C-c C-n: Log Buffer. (line 26) +* C-c C-o: Commit Pseudo Headers. + (line 28) +* C-c C-p: Commit Pseudo Headers. + (line 31) +* C-c C-r: Commit Pseudo Headers. + (line 19) +* C-c C-s: Commit Pseudo Headers. + (line 22) +* C-c C-t: Commands Available in Diffs. + (line 15) +* C-c C-t <1>: Commit Pseudo Headers. + (line 25) +* C-c C-w: Using the Revision Stack. + (line 7) +* C-c f: Commands for Buffers Visiting Files. + (line 52) +* C-c f , c: Commands for Buffers Visiting Files. + (line 52) +* C-c f , k: Commands for Buffers Visiting Files. + (line 52) +* C-c f , r: Commands for Buffers Visiting Files. + (line 52) +* C-c f , x: Commands for Buffers Visiting Files. + (line 52) +* C-c f B: Blaming. (line 28) +* C-c f b: Blaming. (line 28) +* C-c f B <1>: Commands for Buffers Visiting Files. + (line 52) +* C-c f b <1>: Commands for Buffers Visiting Files. + (line 52) +* C-c f B b: Blaming. (line 28) +* C-c f B e: Blaming. (line 28) +* C-c f B f: Blaming. (line 28) +* C-c f B q: Blaming. (line 28) +* C-c f B r: Blaming. (line 28) +* C-c f c: Commands for Buffers Visiting Files. + (line 52) +* C-c f D: Commands for Buffers Visiting Files. + (line 52) +* C-c f d: Commands for Buffers Visiting Files. + (line 52) +* C-c f e: Blaming. (line 28) +* C-c f e <1>: Commands for Buffers Visiting Files. + (line 52) +* C-c f f: Blaming. (line 28) +* C-c f f <1>: Commands for Buffers Visiting Files. + (line 52) +* C-c f g: Commands for Buffers Visiting Files. + (line 52) +* C-c f G: Commands for Buffers Visiting Files. + (line 52) +* C-c f L: Commands for Buffers Visiting Files. + (line 52) +* C-c f l: Commands for Buffers Visiting Files. + (line 52) +* C-c f M: Commands for Buffers Visiting Files. + (line 52) +* C-c f m: Commands for Buffers Visiting Files. + (line 52) +* C-c f n: Commands for Buffers Visiting Files. + (line 52) +* C-c f p: Commands for Buffers Visiting Files. + (line 52) +* C-c f q: Blaming. (line 28) +* C-c f q <1>: Commands for Buffers Visiting Files. + (line 52) +* C-c f r: Blaming. (line 28) +* C-c f r <1>: Commands for Buffers Visiting Files. + (line 52) +* C-c f s: Commands for Buffers Visiting Files. + (line 52) +* C-c f s <1>: Commands for Buffers Visiting Files. + (line 52) +* C-c f t: Commands for Buffers Visiting Files. + (line 52) +* C-c f u: Commands for Buffers Visiting Files. + (line 52) +* C-c f u <1>: Commands for Buffers Visiting Files. + (line 52) +* C-c f v: Commands for Buffers Visiting Files. + (line 52) +* C-c f V: Commands for Buffers Visiting Files. + (line 52) +* C-c g: Transient Commands. (line 20) +* C-c M-g: Commands for Buffers Visiting Files. + (line 58) +* C-c M-g , c: Commands for Buffers Visiting Files. + (line 86) +* C-c M-g , k: Commands for Buffers Visiting Files. + (line 82) +* C-c M-g , r: Commands for Buffers Visiting Files. + (line 78) +* C-c M-g , x: Commands for Buffers Visiting Files. + (line 74) +* C-c M-g B: Blaming. (line 34) +* C-c M-g b: Blaming. (line 45) +* C-c M-g B <1>: Commands for Buffers Visiting Files. + (line 137) +* C-c M-g B b: Blaming. (line 45) +* C-c M-g B e: Blaming. (line 76) +* C-c M-g B f: Blaming. (line 68) +* C-c M-g B q: Blaming. (line 87) +* C-c M-g B r: Blaming. (line 60) +* C-c M-g c: Commands for Buffers Visiting Files. + (line 176) +* C-c M-g D: Commands for Buffers Visiting Files. + (line 91) +* C-c M-g d: Commands for Buffers Visiting Files. + (line 101) +* C-c M-g e: Blaming. (line 76) +* C-c M-g e <1>: Commands for Buffers Visiting Files. + (line 182) +* C-c M-g f: Blaming. (line 68) +* C-c M-g g: Commands for Buffers Visiting Files. + (line 166) +* C-c M-g G: Commands for Buffers Visiting Files. + (line 172) +* C-c M-g L: Commands for Buffers Visiting Files. + (line 109) +* C-c M-g l: Commands for Buffers Visiting Files. + (line 119) +* C-c M-g M: Commands for Buffers Visiting Files. + (line 132) +* C-c M-g n: Commands for Buffers Visiting Files. + (line 153) +* C-c M-g p: Commands for Buffers Visiting Files. + (line 149) +* C-c M-g q: Blaming. (line 87) +* C-c M-g r: Blaming. (line 60) +* C-c M-g s: Commands for Buffers Visiting Files. + (line 63) +* C-c M-g s <1>: Commands for Buffers Visiting Files. + (line 63) +* C-c M-g t: Commands for Buffers Visiting Files. + (line 129) +* C-c M-g u: Commands for Buffers Visiting Files. + (line 69) +* C-c M-g u <1>: Commands for Buffers Visiting Files. + (line 69) +* C-c M-g v: Commands for Buffers Visiting Files. + (line 156) +* C-c M-g V: Commands for Buffers Visiting Files. + (line 160) +* C-c M-i: Commit Pseudo Headers. + (line 35) +* C-c M-s: Editing Commit Messages. + (line 33) +* C-c TAB: Section Visibility. (line 14) +* C-w: Common Commands. (line 22) +* C-x g: Status Buffer. (line 23) +* C-x M-g: Transient Commands. (line 20) +* C-x u: Editing Rebase Sequences. + (line 77) +* d: Diffing. (line 22) +* D: Refreshing Diffs. (line 16) +* d c: Diffing. (line 63) +* d d: Diffing. (line 27) +* D f: Refreshing Diffs. (line 45) +* D F: Refreshing Diffs. (line 49) +* D g: Refreshing Diffs. (line 21) +* d p: Diffing. (line 56) +* d r: Diffing. (line 30) +* D r: Refreshing Diffs. (line 41) +* d s: Diffing. (line 48) +* D s: Refreshing Diffs. (line 25) +* d t: Diffing. (line 67) +* D t: Refreshing Diffs. (line 38) +* d u: Diffing. (line 53) +* d w: Diffing. (line 43) +* D w: Refreshing Diffs. (line 31) +* DEL: Log Buffer. (line 50) +* DEL <1>: Commands Available in Diffs. + (line 56) +* DEL <2>: Blaming. (line 103) +* DEL <3>: Editing Rebase Sequences. + (line 25) +* e: Ediffing. (line 10) +* E: Ediffing. (line 21) +* e <1>: Editing Rebase Sequences. + (line 46) +* E c: Ediffing. (line 100) +* E i: Ediffing. (line 94) +* E m: Ediffing. (line 33) +* E M: Ediffing. (line 48) +* E r: Ediffing. (line 25) +* E s: Ediffing. (line 87) +* E t: Ediffing. (line 79) +* E u: Ediffing. (line 91) +* E w: Ediffing. (line 97) +* E z: Ediffing. (line 103) +* f: Repository List. (line 111) +* f <1>: Editing Rebase Sequences. + (line 52) +* f <2>: Fetching. (line 10) +* F: Pulling. (line 10) +* f a: Fetching. (line 45) +* f C: Branch Commands. (line 31) +* F C: Branch Commands. (line 31) +* f e: Fetching. (line 34) +* F e: Pulling. (line 28) +* f m: Fetching. (line 48) +* f o: Fetching. (line 37) +* f p: Fetching. (line 15) +* F p: Pulling. (line 14) +* f r: Fetching. (line 41) +* f u: Fetching. (line 22) +* F u: Pulling. (line 21) +* g: Automatic Refreshing of Magit Buffers. + (line 26) +* G: Automatic Refreshing of Magit Buffers. + (line 34) +* H: Section Types and Values. + (line 14) +* I: Creating Repository. (line 7) +* j: Log Buffer. (line 31) +* j <1>: Commands Available in Diffs. + (line 43) +* k: Viewing Git Output. (line 24) +* k <1>: Applying. (line 40) +* k <2>: Editing Rebase Sequences. + (line 56) +* k <3>: Stashing. (line 118) +* l: Logging. (line 30) +* L: Refreshing Logs. (line 12) +* L <1>: Log Buffer. (line 7) +* L <2>: Log Margin. (line 52) +* l <1>: Editing Rebase Sequences. + (line 94) +* l a: Logging. (line 61) +* l b: Logging. (line 58) +* L d: Log Margin. (line 66) +* L g: Refreshing Logs. (line 17) +* l h: Logging. (line 40) +* l H: Reflog. (line 18) +* l l: Logging. (line 35) +* l L: Logging. (line 55) +* L L: Refreshing Logs. (line 34) +* L L <1>: Log Margin. (line 60) +* L l: Log Margin. (line 63) +* l o: Logging. (line 49) +* l O: Reflog. (line 15) +* l r: Reflog. (line 12) +* L s: Refreshing Logs. (line 21) +* l u: Logging. (line 43) +* L w: Refreshing Logs. (line 27) +* m: Repository List. (line 105) +* m <1>: Merging. (line 10) +* M: Remote Commands. (line 14) +* m a: Merging. (line 42) +* m a <1>: Merging. (line 91) +* M a: Remote Commands. (line 48) +* M C: Remote Commands. (line 32) +* m e: Merging. (line 30) +* m i: Merging. (line 54) +* M k: Remote Commands. (line 60) +* m m: Merging. (line 18) +* m m <1>: Merging. (line 86) +* m n: Merging. (line 36) +* m p: Merging. (line 75) +* M p: Remote Commands. (line 63) +* M P: Remote Commands. (line 67) +* M r: Remote Commands. (line 52) +* m s: Merging. (line 67) +* M u: Remote Commands. (line 56) +* M-1: Section Visibility. (line 45) +* M-2: Section Visibility. (line 45) +* M-3: Section Visibility. (line 45) +* M-4: Section Visibility. (line 45) +* M-<tab>: Section Visibility. (line 29) +* M-n: Section Movement. (line 24) +* M-n <1>: Editing Commit Messages. + (line 41) +* M-n <2>: Editing Rebase Sequences. + (line 40) +* M-p: Section Movement. (line 19) +* M-p <1>: Editing Commit Messages. + (line 36) +* M-p <2>: Editing Rebase Sequences. + (line 37) +* M-w: Blaming. (line 134) +* M-w <1>: Common Commands. (line 39) +* MM: Editing Rebase Sequences. + (line 102) +* Mt: Editing Rebase Sequences. + (line 108) +* n: Section Movement. (line 16) +* n <1>: Blaming. (line 118) +* N: Blaming. (line 121) +* n <2>: Editing Rebase Sequences. + (line 34) +* n <3>: Minor Mode for Buffers Visiting Blobs. + (line 16) +* o: Submodule Transient. (line 7) +* O: Subtree. (line 9) +* o a: Submodule Transient. (line 20) +* o d: Submodule Transient. (line 45) +* O e: Subtree. (line 37) +* O e p: Subtree. (line 48) +* O e s: Subtree. (line 52) +* o f: Submodule Transient. (line 51) +* O i: Subtree. (line 13) +* O i a: Subtree. (line 24) +* O i c: Subtree. (line 28) +* O i f: Subtree. (line 34) +* O i m: Subtree. (line 31) +* o l: Submodule Transient. (line 48) +* o p: Submodule Transient. (line 32) +* o r: Submodule Transient. (line 26) +* o s: Submodule Transient. (line 40) +* o u: Submodule Transient. (line 36) +* p: Section Movement. (line 11) +* p <1>: Blaming. (line 124) +* P: Blaming. (line 127) +* p <2>: Editing Rebase Sequences. + (line 31) +* P <1>: Pushing. (line 10) +* p <3>: Minor Mode for Buffers Visiting Blobs. + (line 13) +* P C: Branch Commands. (line 31) +* P e: Pushing. (line 29) +* P m: Pushing. (line 45) +* P o: Pushing. (line 33) +* P p: Pushing. (line 15) +* P r: Pushing. (line 37) +* P t: Pushing. (line 52) +* P T: Pushing. (line 59) +* P u: Pushing. (line 22) +* q: Quitting Windows. (line 7) +* q <1>: Log Buffer. (line 14) +* q <2>: Blaming. (line 130) +* q <3>: Minor Mode for Buffers Visiting Blobs. + (line 19) +* r: Rebasing. (line 10) +* r <1>: Editing Rebase Sequences. + (line 43) +* r a: Rebasing. (line 111) +* r e: Rebasing. (line 42) +* r e <1>: Rebasing. (line 107) +* r f: Rebasing. (line 79) +* r i: Rebasing. (line 76) +* r k: Rebasing. (line 91) +* r m: Rebasing. (line 83) +* r p: Rebasing. (line 28) +* r r: Rebasing. (line 97) +* r s: Rebasing. (line 47) +* r s <1>: Rebasing. (line 103) +* r u: Rebasing. (line 35) +* r w: Rebasing. (line 87) +* RET: Repository List. (line 102) +* RET <1>: References Buffer. (line 159) +* RET <2>: Visiting Files and Blobs from a Diff. + (line 9) +* RET <3>: Blaming. (line 91) +* RET <4>: Editing Rebase Sequences. + (line 15) +* s: Staging and Unstaging. + (line 29) +* S: Staging and Unstaging. + (line 36) +* s <1>: Editing Rebase Sequences. + (line 49) +* S-<tab>: Section Visibility. (line 33) +* SPC: Log Buffer. (line 41) +* SPC <1>: Commands Available in Diffs. + (line 53) +* SPC <2>: Blaming. (line 94) +* SPC <3>: Editing Rebase Sequences. + (line 19) +* t: Editing Rebase Sequences. + (line 97) +* t <1>: Tagging. (line 9) +* T: Notes. (line 9) +* T a: Notes. (line 47) +* T c: Notes. (line 43) +* t k: Tagging. (line 37) +* T m: Notes. (line 35) +* t p: Tagging. (line 43) +* T p: Notes. (line 28) +* t r: Tagging. (line 18) +* T r: Notes. (line 21) +* t t: Tagging. (line 14) +* T T: Notes. (line 14) +* TAB: Section Visibility. (line 10) +* u: Repository List. (line 108) +* u <1>: Staging and Unstaging. + (line 42) +* U: Staging and Unstaging. + (line 50) +* v: Applying. (line 47) +* V: Reverting. (line 7) +* V a: Reverting. (line 35) +* V s: Reverting. (line 32) +* V V: Reverting. (line 15) +* V v: Reverting. (line 20) +* V V <1>: Reverting. (line 29) +* W: Plain Patches. (line 7) +* w: Maildir Patches. (line 9) +* w a: Plain Patches. (line 20) +* w a <1>: Maildir Patches. (line 23) +* w a <2>: Maildir Patches. (line 38) +* W c: Plain Patches. (line 12) +* w m: Maildir Patches. (line 20) +* W s: Plain Patches. (line 26) +* w s: Maildir Patches. (line 34) +* w w: Maildir Patches. (line 14) +* w w <1>: Maildir Patches. (line 31) +* x: Editing Rebase Sequences. + (line 62) +* x <1>: Resetting. (line 9) +* X f: Resetting. (line 44) +* X h: Resetting. (line 24) +* X i: Resetting. (line 33) +* X k: Resetting. (line 28) +* X m: Resetting. (line 15) +* X s: Resetting. (line 19) +* X w: Resetting. (line 39) +* X w <1>: Wip Modes. (line 64) +* Y: Cherries. (line 18) +* y: References Buffer. (line 7) +* y <1>: Editing Rebase Sequences. + (line 74) +* y c: References Buffer. (line 25) +* y o: References Buffer. (line 30) +* y r: References Buffer. (line 34) +* y y: References Buffer. (line 21) +* z: Stashing. (line 9) +* Z: Worktree. (line 9) +* z a: Stashing. (line 52) +* z b: Stashing. (line 105) +* z B: Stashing. (line 110) +* Z b: Worktree. (line 13) +* Z c: Worktree. (line 16) +* z f: Stashing. (line 115) +* Z g: Worktree. (line 26) +* z i: Stashing. (line 20) +* z I: Stashing. (line 42) +* z k: Stashing. (line 98) +* Z k: Worktree. (line 22) +* z l: Stashing. (line 121) +* Z m: Worktree. (line 19) +* z p: Stashing. (line 74) +* z v: Stashing. (line 102) +* z w: Stashing. (line 24) +* z W: Stashing. (line 46) +* z x: Stashing. (line 30) +* z z: Stashing. (line 14) +* z Z: Stashing. (line 36) + + +File: magit.info, Node: Function and Command Index, Next: Variable Index, Prev: Keystroke Index, Up: Top + +Appendix D Function and Command Index +************************************* + + +* Menu: + +* bug-reference-mode: Commit Mode and Hooks. + (line 48) +* forward-line: Editing Rebase Sequences. + (line 34) +* git-commit-ack: Commit Pseudo Headers. + (line 16) +* git-commit-cc: Commit Pseudo Headers. + (line 28) +* git-commit-check-style-conventions: Commit Message Conventions. + (line 33) +* git-commit-insert-pseudo-header: Commit Pseudo Headers. + (line 13) +* git-commit-next-message: Editing Commit Messages. + (line 41) +* git-commit-prev-message: Editing Commit Messages. + (line 36) +* git-commit-propertize-diff: Commit Mode and Hooks. + (line 40) +* git-commit-reported: Commit Pseudo Headers. + (line 31) +* git-commit-review: Commit Pseudo Headers. + (line 19) +* git-commit-save-message: Editing Commit Messages. + (line 33) +* git-commit-save-message <1>: Commit Mode and Hooks. + (line 26) +* git-commit-setup-changelog-support: Commit Mode and Hooks. + (line 29) +* git-commit-signoff: Commit Pseudo Headers. + (line 22) +* git-commit-suggested: Commit Pseudo Headers. + (line 35) +* git-commit-test: Commit Pseudo Headers. + (line 25) +* git-commit-turn-on-auto-fill: Commit Mode and Hooks. + (line 33) +* git-commit-turn-on-flyspell: Commit Mode and Hooks. + (line 36) +* git-rebase-backward-line: Editing Rebase Sequences. + (line 31) +* git-rebase-break: Editing Rebase Sequences. + (line 70) +* git-rebase-edit: Editing Rebase Sequences. + (line 46) +* git-rebase-exec: Editing Rebase Sequences. + (line 62) +* git-rebase-fixup: Editing Rebase Sequences. + (line 52) +* git-rebase-insert: Editing Rebase Sequences. + (line 74) +* git-rebase-kill-line: Editing Rebase Sequences. + (line 56) +* git-rebase-label: Editing Rebase Sequences. + (line 94) +* git-rebase-merge: Editing Rebase Sequences. + (line 102) +* git-rebase-merge-toggle-editmsg: Editing Rebase Sequences. + (line 108) +* git-rebase-move-line-down: Editing Rebase Sequences. + (line 40) +* git-rebase-move-line-up: Editing Rebase Sequences. + (line 37) +* git-rebase-pick: Editing Rebase Sequences. + (line 59) +* git-rebase-reset: Editing Rebase Sequences. + (line 97) +* git-rebase-reword: Editing Rebase Sequences. + (line 43) +* git-rebase-show-commit: Editing Rebase Sequences. + (line 15) +* git-rebase-show-or-scroll-down: Editing Rebase Sequences. + (line 25) +* git-rebase-show-or-scroll-up: Editing Rebase Sequences. + (line 19) +* git-rebase-squash: Editing Rebase Sequences. + (line 49) +* git-rebase-undo: Editing Rebase Sequences. + (line 77) +* ido-enter-magit-status: Status Buffer. (line 96) +* magit-add-section-hook: Section Hooks. (line 20) +* magit-after-save-refresh-status: Automatic Refreshing of Magit Buffers. + (line 55) +* magit-am: Maildir Patches. (line 9) +* magit-am-abort: Maildir Patches. (line 38) +* magit-am-apply-maildir: Maildir Patches. (line 20) +* magit-am-apply-patches: Maildir Patches. (line 14) +* magit-am-continue: Maildir Patches. (line 31) +* magit-am-skip: Maildir Patches. (line 34) +* magit-apply: Applying. (line 34) +* magit-bisect: Bisecting. (line 9) +* magit-bisect-bad: Bisecting. (line 32) +* magit-bisect-good: Bisecting. (line 36) +* magit-bisect-mark: Bisecting. (line 40) +* magit-bisect-reset: Bisecting. (line 51) +* magit-bisect-run: Bisecting. (line 26) +* magit-bisect-skip: Bisecting. (line 46) +* magit-bisect-start: Bisecting. (line 16) +* magit-blame: Blaming. (line 28) +* magit-blame <1>: Blaming. (line 34) +* magit-blame <2>: Blaming. (line 115) +* magit-blame <3>: Commands for Buffers Visiting Files. + (line 52) +* magit-blame <4>: Commands for Buffers Visiting Files. + (line 137) +* magit-blame-addition: Blaming. (line 28) +* magit-blame-addition <1>: Blaming. (line 45) +* magit-blame-additions: Commands for Buffers Visiting Files. + (line 52) +* magit-blame-copy-hash: Blaming. (line 134) +* magit-blame-cycle-style: Blaming. (line 141) +* magit-blame-echo: Blaming. (line 28) +* magit-blame-echo <1>: Blaming. (line 76) +* magit-blame-echo <2>: Commands for Buffers Visiting Files. + (line 52) +* magit-blame-next-chunk: Blaming. (line 118) +* magit-blame-next-chunk-same-commit: Blaming. (line 121) +* magit-blame-previous-chunk: Blaming. (line 124) +* magit-blame-previous-chunk-same-commit: Blaming. (line 127) +* magit-blame-quit: Blaming. (line 28) +* magit-blame-quit <1>: Blaming. (line 87) +* magit-blame-quit <2>: Blaming. (line 130) +* magit-blame-quit <3>: Commands for Buffers Visiting Files. + (line 52) +* magit-blame-removal: Blaming. (line 28) +* magit-blame-removal <1>: Blaming. (line 60) +* magit-blame-removal <2>: Commands for Buffers Visiting Files. + (line 52) +* magit-blame-reverse: Blaming. (line 28) +* magit-blame-reverse <1>: Blaming. (line 68) +* magit-blame-reverse <2>: Commands for Buffers Visiting Files. + (line 52) +* magit-blob-next: Commands for Buffers Visiting Files. + (line 52) +* magit-blob-next <1>: Commands for Buffers Visiting Files. + (line 153) +* magit-blob-next <2>: Minor Mode for Buffers Visiting Blobs. + (line 16) +* magit-blob-previous: Commands for Buffers Visiting Files. + (line 52) +* magit-blob-previous <1>: Commands for Buffers Visiting Files. + (line 149) +* magit-blob-previous <2>: Minor Mode for Buffers Visiting Blobs. + (line 13) +* magit-blob-visit-file: Commands for Buffers Visiting Files. + (line 52) +* magit-blob-visit-file <1>: Commands for Buffers Visiting Files. + (line 160) +* magit-branch: Branch Commands. (line 13) +* magit-branch-and-checkout: Branch Commands. (line 63) +* magit-branch-checkout: Branch Commands. (line 69) +* magit-branch-configure: Branch Commands. (line 31) +* magit-branch-create: Branch Commands. (line 54) +* magit-branch-delete: Branch Commands. (line 138) +* magit-branch-or-checkout: Branch Commands. (line 257) +* magit-branch-orphan: Branch Commands. (line 253) +* magit-branch-rename: Branch Commands. (line 149) +* magit-branch-reset: Branch Commands. (line 123) +* magit-branch-shelve: Auxiliary Branch Commands. + (line 9) +* magit-branch-spinoff: Branch Commands. (line 91) +* magit-branch-spinout: Branch Commands. (line 118) +* magit-branch-unshelve: Auxiliary Branch Commands. + (line 19) +* magit-builtin-completing-read: Support for Completion Frameworks. + (line 41) +* magit-bundle: Bundle. (line 8) +* magit-call-git: Calling Git for Effect. + (line 28) +* magit-call-process: Calling Git for Effect. + (line 31) +* magit-cancel-section: Creating Sections. (line 69) +* magit-checkout: Branch Commands. (line 47) +* magit-cherry: Cherries. (line 18) +* magit-cherry-apply: Cherry Picking. (line 23) +* magit-cherry-copy: Cherry Picking. (line 17) +* magit-cherry-donate: Cherry Picking. (line 51) +* magit-cherry-harvest: Cherry Picking. (line 40) +* magit-cherry-pick: Cherry Picking. (line 9) +* magit-cherry-spinoff: Cherry Picking. (line 72) +* magit-cherry-spinout: Cherry Picking. (line 62) +* magit-clone: Cloning Repository. (line 20) +* magit-clone-bare: Cloning Repository. (line 44) +* magit-clone-mirror: Cloning Repository. (line 48) +* magit-clone-regular: Cloning Repository. (line 28) +* magit-clone-shallow: Cloning Repository. (line 32) +* magit-clone-shallow-exclude: Cloning Repository. (line 61) +* magit-clone-shallow-since: Cloning Repository. (line 55) +* magit-clone-sparse: Cloning Repository. (line 38) +* magit-commit: Initiating a Commit. (line 9) +* magit-commit <1>: Commands for Buffers Visiting Files. + (line 52) +* magit-commit <2>: Commands for Buffers Visiting Files. + (line 176) +* magit-commit-amend: Initiating a Commit. (line 18) +* magit-commit-augment: Initiating a Commit. (line 59) +* magit-commit-create: Initiating a Commit. (line 14) +* magit-commit-extend: Initiating a Commit. (line 21) +* magit-commit-fixup: Initiating a Commit. (line 39) +* magit-commit-instant-fixup: Initiating a Commit. (line 46) +* magit-commit-instant-squash: Initiating a Commit. (line 56) +* magit-commit-reword: Initiating a Commit. (line 30) +* magit-commit-squash: Initiating a Commit. (line 49) +* magit-completing-read: Support for Completion Frameworks. + (line 57) +* magit-copy-buffer-revision: Common Commands. (line 39) +* magit-copy-section-value: Common Commands. (line 22) +* magit-current-section: Section Selection. (line 6) +* magit-cycle-margin-style: Log Margin. (line 63) +* magit-debug-git-executable: Git Executable. (line 55) +* magit-debug-git-executable <1>: Debugging Tools. (line 57) +* magit-define-section-jumper: Creating Sections. (line 74) +* magit-describe-section: Section Types and Values. + (line 14) +* magit-describe-section-briefly: Section Types and Values. + (line 17) +* magit-describe-section-briefly <1>: Matching Sections. (line 7) +* magit-diff: Diffing. (line 22) +* magit-diff <1>: Commands for Buffers Visiting Files. + (line 52) +* magit-diff <2>: Commands for Buffers Visiting Files. + (line 91) +* magit-diff-buffer-file: Commands for Buffers Visiting Files. + (line 52) +* magit-diff-buffer-file <1>: Commands for Buffers Visiting Files. + (line 101) +* magit-diff-default-context: Refreshing Diffs. (line 68) +* magit-diff-dwim: Diffing. (line 27) +* magit-diff-edit-hunk-commit: Commands Available in Diffs. + (line 24) +* magit-diff-flip-revs: Refreshing Diffs. (line 45) +* magit-diff-less-context: Refreshing Diffs. (line 62) +* magit-diff-more-context: Refreshing Diffs. (line 65) +* magit-diff-paths: Diffing. (line 56) +* magit-diff-range: Diffing. (line 30) +* magit-diff-refresh: Refreshing Diffs. (line 16) +* magit-diff-refresh <1>: Refreshing Diffs. (line 21) +* magit-diff-save-default-arguments: Refreshing Diffs. (line 31) +* magit-diff-scope: Matching Sections. (line 110) +* magit-diff-set-default-arguments: Refreshing Diffs. (line 25) +* magit-diff-show-or-scroll-down: Log Buffer. (line 50) +* magit-diff-show-or-scroll-down <1>: Blaming. (line 103) +* magit-diff-show-or-scroll-up: Log Buffer. (line 41) +* magit-diff-show-or-scroll-up <1>: Blaming. (line 94) +* magit-diff-staged: Diffing. (line 48) +* magit-diff-switch-range-type: Refreshing Diffs. (line 41) +* magit-diff-toggle-file-filter: Refreshing Diffs. (line 49) +* magit-diff-toggle-refine-hunk: Refreshing Diffs. (line 38) +* magit-diff-trace-definition: Commands Available in Diffs. + (line 15) +* magit-diff-type: Matching Sections. (line 88) +* magit-diff-unstaged: Diffing. (line 53) +* magit-diff-visit-file: Visiting Files and Blobs from a Diff. + (line 9) +* magit-diff-visit-file-other-frame: Visiting Files and Blobs from a Diff. + (line 71) +* magit-diff-visit-file-other-window: Visiting Files and Blobs from a Diff. + (line 70) +* magit-diff-visit-file-worktree: Visiting Files and Blobs from a Diff. + (line 50) +* magit-diff-visit-worktree-file-other-frame: Visiting Files and Blobs from a Diff. + (line 73) +* magit-diff-visit-worktree-file-other-window: Visiting Files and Blobs from a Diff. + (line 72) +* magit-diff-while-committing: Refreshing Diffs. (line 75) +* magit-diff-while-committing <1>: Editing Commit Messages. + (line 54) +* magit-diff-working-tree: Diffing. (line 43) +* magit-disable-section-inserter: Per-Repository Configuration. + (line 31) +* magit-discard: Applying. (line 40) +* magit-dispatch: Transient Commands. (line 20) +* magit-display-buffer: Switching Buffers. (line 6) +* magit-display-buffer-fullcolumn-most-v1: Switching Buffers. (line 68) +* magit-display-buffer-fullframe-status-topleft-v1: Switching Buffers. + (line 59) +* magit-display-buffer-fullframe-status-v1: Switching Buffers. + (line 54) +* magit-display-buffer-same-window-except-diff-v1: Switching Buffers. + (line 49) +* magit-display-buffer-traditional: Switching Buffers. (line 42) +* magit-display-repository-buffer: Common Commands. (line 9) +* magit-display-repository-buffer <1>: Commands for Buffers Visiting Files. + (line 52) +* magit-display-repository-buffer <2>: Commands for Buffers Visiting Files. + (line 172) +* magit-ediff: Ediffing. (line 21) +* magit-ediff-compare: Ediffing. (line 25) +* magit-ediff-dwim: Ediffing. (line 10) +* magit-ediff-resolve-all: Ediffing. (line 48) +* magit-ediff-resolve-rest: Ediffing. (line 33) +* magit-ediff-show-commit: Ediffing. (line 100) +* magit-ediff-show-staged: Ediffing. (line 94) +* magit-ediff-show-stash: Ediffing. (line 103) +* magit-ediff-show-unstaged: Ediffing. (line 91) +* magit-ediff-show-working-tree: Ediffing. (line 97) +* magit-ediff-stage: Ediffing. (line 87) +* magit-edit-line-commit: Commands for Buffers Visiting Files. + (line 52) +* magit-edit-line-commit <1>: Commands for Buffers Visiting Files. + (line 182) +* magit-emacs-Q-command: Debugging Tools. (line 16) +* magit-fetch: Fetching. (line 10) +* magit-fetch-all: Fetching. (line 45) +* magit-fetch-branch: Fetching. (line 37) +* magit-fetch-from-pushremote: Fetching. (line 15) +* magit-fetch-from-upstream: Fetching. (line 22) +* magit-fetch-modules: Fetching. (line 48) +* magit-fetch-modules <1>: Submodule Transient. (line 51) +* magit-fetch-other: Fetching. (line 34) +* magit-fetch-refspec: Fetching. (line 41) +* magit-file-checkout: Resetting. (line 44) +* magit-file-checkout <1>: Commands for Buffers Visiting Files. + (line 52) +* magit-file-checkout <2>: Commands for Buffers Visiting Files. + (line 86) +* magit-file-delete: Commands for Buffers Visiting Files. + (line 52) +* magit-file-delete <1>: Commands for Buffers Visiting Files. + (line 82) +* magit-file-dispatch: Commands for Buffers Visiting Files. + (line 52) +* magit-file-dispatch <1>: Commands for Buffers Visiting Files. + (line 58) +* magit-file-rename: Commands for Buffers Visiting Files. + (line 52) +* magit-file-rename <1>: Commands for Buffers Visiting Files. + (line 78) +* magit-file-untrack: Commands for Buffers Visiting Files. + (line 52) +* magit-file-untrack <1>: Commands for Buffers Visiting Files. + (line 74) +* magit-find-file: General-Purpose Visit Commands. + (line 9) +* magit-find-file <1>: Commands for Buffers Visiting Files. + (line 52) +* magit-find-file <2>: Commands for Buffers Visiting Files. + (line 156) +* magit-find-file-other-frame: General-Purpose Visit Commands. + (line 19) +* magit-find-file-other-window: General-Purpose Visit Commands. + (line 14) +* magit-generate-buffer-name-default-function: Naming Buffers. + (line 16) +* magit-get-section: Matching Sections. (line 14) +* magit-git: Calling Git for Effect. + (line 46) +* magit-git-command: Running Git Manually. + (line 25) +* magit-git-command-topdir: Running Git Manually. + (line 17) +* magit-git-exit-code: Getting a Value from Git. + (line 10) +* magit-git-failure: Getting a Value from Git. + (line 17) +* magit-git-false: Getting a Value from Git. + (line 25) +* magit-git-insert: Getting a Value from Git. + (line 29) +* magit-git-items: Getting a Value from Git. + (line 41) +* magit-git-lines: Getting a Value from Git. + (line 37) +* magit-git-mergetool: Running Git Manually. + (line 62) +* magit-git-mergetool <1>: Ediffing. (line 79) +* magit-git-str: Getting a Value from Git. + (line 75) +* magit-git-string: Getting a Value from Git. + (line 32) +* magit-git-success: Getting a Value from Git. + (line 13) +* magit-git-true: Getting a Value from Git. + (line 21) +* magit-git-wash: Calling Git for Effect. + (line 50) +* magit-go-backward: Log Buffer. (line 20) +* magit-go-backward <1>: Refreshing Diffs. (line 84) +* magit-go-forward: Log Buffer. (line 23) +* magit-go-forward <1>: Refreshing Diffs. (line 87) +* magit-hunk-set-window-start: Section Movement. (line 45) +* magit-ido-completing-read: Support for Completion Frameworks. + (line 46) +* magit-init: Creating Repository. (line 7) +* magit-insert-am-sequence: Status Sections. (line 25) +* magit-insert-assumed-unchanged-files: Status Sections. (line 98) +* magit-insert-bisect-log: Status Sections. (line 39) +* magit-insert-bisect-output: Status Sections. (line 33) +* magit-insert-bisect-rest: Status Sections. (line 36) +* magit-insert-diff-filter-header: Status Header Sections. + (line 35) +* magit-insert-error-header: Status Header Sections. + (line 26) +* magit-insert-head-branch-header: Status Header Sections. + (line 38) +* magit-insert-heading: Creating Sections. (line 41) +* magit-insert-ignored-files: Status Sections. (line 83) +* magit-insert-local-branches: References Sections. (line 16) +* magit-insert-merge-log: Status Sections. (line 17) +* magit-insert-modules: Status Module Sections. + (line 12) +* magit-insert-modules-overview: Status Module Sections. + (line 30) +* magit-insert-modules-unpulled-from-pushremote: Status Module Sections. + (line 45) +* magit-insert-modules-unpulled-from-upstream: Status Module Sections. + (line 40) +* magit-insert-modules-unpushed-to-pushremote: Status Module Sections. + (line 55) +* magit-insert-modules-unpushed-to-upstream: Status Module Sections. + (line 50) +* magit-insert-push-branch-header: Status Header Sections. + (line 45) +* magit-insert-rebase-sequence: Status Sections. (line 21) +* magit-insert-recent-commits: Status Sections. (line 110) +* magit-insert-remote-branches: References Sections. (line 19) +* magit-insert-remote-header: Status Header Sections. + (line 58) +* magit-insert-repo-header: Status Header Sections. + (line 55) +* magit-insert-section: Creating Sections. (line 6) +* magit-insert-sequencer-sequence: Status Sections. (line 29) +* magit-insert-skip-worktree-files: Status Sections. (line 92) +* magit-insert-staged-changes: Status Sections. (line 53) +* magit-insert-stashes: Status Sections. (line 56) +* magit-insert-status-headers: Status Header Sections. + (line 12) +* magit-insert-tags: References Sections. (line 22) +* magit-insert-tags-header: Status Header Sections. + (line 49) +* magit-insert-tracked-files: Status Sections. (line 80) +* magit-insert-unpulled-cherries: Status Sections. (line 119) +* magit-insert-unpulled-from-pushremote: Status Sections. (line 66) +* magit-insert-unpulled-from-upstream: Status Sections. (line 62) +* magit-insert-unpulled-or-recent-commits: Status Sections. (line 104) +* magit-insert-unpushed-cherries: Status Sections. (line 125) +* magit-insert-unpushed-to-pushremote: Status Sections. (line 74) +* magit-insert-unpushed-to-upstream: Status Sections. (line 70) +* magit-insert-unstaged-changes: Status Sections. (line 50) +* magit-insert-untracked-files: Status Sections. (line 42) +* magit-insert-upstream-branch-header: Status Header Sections. + (line 41) +* magit-insert-user-header: Status Header Sections. + (line 65) +* magit-jump-to-diffstat-or-diff: Commands Available in Diffs. + (line 43) +* magit-kill-this-buffer: Minor Mode for Buffers Visiting Blobs. + (line 19) +* magit-list-repositories: Repository List. (line 6) +* magit-list-submodules: Listing Submodules. (line 13) +* magit-list-submodules <1>: Submodule Transient. (line 48) +* magit-log: Logging. (line 30) +* magit-log <1>: Commands for Buffers Visiting Files. + (line 52) +* magit-log <2>: Commands for Buffers Visiting Files. + (line 109) +* magit-log-all: Logging. (line 61) +* magit-log-all-branches: Logging. (line 58) +* magit-log-branches: Logging. (line 55) +* magit-log-buffer-file: Commands for Buffers Visiting Files. + (line 52) +* magit-log-buffer-file <1>: Commands for Buffers Visiting Files. + (line 119) +* magit-log-bury-buffer: Log Buffer. (line 14) +* magit-log-current: Logging. (line 35) +* magit-log-double-commit-limit: Log Buffer. (line 64) +* magit-log-half-commit-limit: Log Buffer. (line 67) +* magit-log-head: Logging. (line 40) +* magit-log-maybe-show-more-commits: Section Movement. (line 58) +* magit-log-maybe-update-blob-buffer: Section Movement. (line 72) +* magit-log-maybe-update-revision-buffer: Section Movement. (line 65) +* magit-log-merged: Commands for Buffers Visiting Files. + (line 52) +* magit-log-merged <1>: Commands for Buffers Visiting Files. + (line 132) +* magit-log-move-to-parent: Log Buffer. (line 26) +* magit-log-move-to-revision: Log Buffer. (line 31) +* magit-log-other: Logging. (line 49) +* magit-log-refresh: Refreshing Logs. (line 12) +* magit-log-refresh <1>: Refreshing Logs. (line 17) +* magit-log-refresh <2>: Log Buffer. (line 7) +* magit-log-related: Logging. (line 43) +* magit-log-save-default-arguments: Refreshing Logs. (line 27) +* magit-log-select-pick: Select from Log. (line 21) +* magit-log-select-quit: Select from Log. (line 26) +* magit-log-set-default-arguments: Refreshing Logs. (line 21) +* magit-log-toggle-commit-limit: Log Buffer. (line 59) +* magit-log-trace-definition: Commands for Buffers Visiting Files. + (line 52) +* magit-log-trace-definition <1>: Commands for Buffers Visiting Files. + (line 129) +* magit-margin-settings: Log Margin. (line 52) +* magit-maybe-set-dedicated: Switching Buffers. (line 89) +* magit-merge: Merging. (line 10) +* magit-merge <1>: Merging. (line 86) +* magit-merge-abort: Merging. (line 91) +* magit-merge-absorb: Merging. (line 42) +* magit-merge-editmsg: Merging. (line 30) +* magit-merge-into: Merging. (line 54) +* magit-merge-nocommit: Merging. (line 36) +* magit-merge-plain: Merging. (line 18) +* magit-merge-preview: Merging. (line 75) +* magit-merge-squash: Merging. (line 67) +* magit-mode-bury-buffer: Quitting Windows. (line 7) +* magit-mode-display-buffer: Refreshing Buffers. (line 32) +* magit-mode-quit-window: Quitting Windows. (line 34) +* magit-mode-setup: Refreshing Buffers. (line 17) +* magit-notes: Notes. (line 9) +* magit-notes-edit: Notes. (line 14) +* magit-notes-merge: Notes. (line 35) +* magit-notes-merge-abort: Notes. (line 47) +* magit-notes-merge-commit: Notes. (line 43) +* magit-notes-prune: Notes. (line 28) +* magit-notes-remove: Notes. (line 21) +* magit-patch: Plain Patches. (line 7) +* magit-patch-apply: Plain Patches. (line 20) +* magit-patch-apply <1>: Maildir Patches. (line 23) +* magit-patch-create: Plain Patches. (line 12) +* magit-patch-save: Plain Patches. (line 26) +* magit-pop-revision-stack: Using the Revision Stack. + (line 7) +* magit-process: Viewing Git Output. (line 17) +* magit-process-file: Getting a Value from Git. + (line 57) +* magit-process-git: Getting a Value from Git. + (line 50) +* magit-process-kill: Viewing Git Output. (line 24) +* magit-pull: Pulling. (line 10) +* magit-pull-branch: Pulling. (line 28) +* magit-pull-from-pushremote: Pulling. (line 14) +* magit-pull-from-upstream: Pulling. (line 21) +* magit-push: Pushing. (line 10) +* magit-push-current: Pushing. (line 29) +* magit-push-current-to-pushremote: Pushing. (line 15) +* magit-push-current-to-upstream: Pushing. (line 22) +* magit-push-implicitly: Pushing. (line 74) +* magit-push-matching: Pushing. (line 45) +* magit-push-other: Pushing. (line 33) +* magit-push-refspecs: Pushing. (line 37) +* magit-push-tag: Pushing. (line 59) +* magit-push-tags: Pushing. (line 52) +* magit-push-to-remote: Pushing. (line 91) +* magit-rebase: Rebasing. (line 10) +* magit-rebase-abort: Rebasing. (line 111) +* magit-rebase-autosquash: Rebasing. (line 79) +* magit-rebase-branch: Rebasing. (line 42) +* magit-rebase-continue: Rebasing. (line 97) +* magit-rebase-edit: Rebasing. (line 107) +* magit-rebase-edit-commit: Rebasing. (line 83) +* magit-rebase-interactive: Rebasing. (line 76) +* magit-rebase-onto-pushremote: Rebasing. (line 28) +* magit-rebase-onto-upstream: Rebasing. (line 35) +* magit-rebase-remove-commit: Rebasing. (line 91) +* magit-rebase-reword-commit: Rebasing. (line 87) +* magit-rebase-skip: Rebasing. (line 103) +* magit-rebase-subset: Rebasing. (line 47) +* magit-reflog-current: Reflog. (line 12) +* magit-reflog-head: Reflog. (line 18) +* magit-reflog-other: Reflog. (line 15) +* magit-refresh: Automatic Refreshing of Magit Buffers. + (line 26) +* magit-refresh-all: Automatic Refreshing of Magit Buffers. + (line 34) +* magit-refs-set-show-commit-count: References Buffer. (line 34) +* magit-region-sections: Section Selection. (line 9) +* magit-region-values: Section Selection. (line 35) +* magit-remote: Remote Commands. (line 14) +* magit-remote-add: Remote Commands. (line 48) +* magit-remote-configure: Remote Commands. (line 32) +* magit-remote-prune: Remote Commands. (line 63) +* magit-remote-prune-refspecs: Remote Commands. (line 67) +* magit-remote-remove: Remote Commands. (line 60) +* magit-remote-rename: Remote Commands. (line 52) +* magit-remote-set-url: Remote Commands. (line 56) +* magit-repolist-column-branch: Repository List. (line 51) +* magit-repolist-column-branches: Repository List. (line 58) +* magit-repolist-column-flag: Repository List. (line 64) +* magit-repolist-column-flags: Repository List. (line 76) +* magit-repolist-column-ident: Repository List. (line 40) +* magit-repolist-column-path: Repository List. (line 44) +* magit-repolist-column-stashes: Repository List. (line 61) +* magit-repolist-column-unpulled-from-pushremote: Repository List. + (line 87) +* magit-repolist-column-unpulled-from-upstream: Repository List. + (line 83) +* magit-repolist-column-unpushed-to-pushremote: Repository List. + (line 95) +* magit-repolist-column-unpushed-to-upstream: Repository List. + (line 91) +* magit-repolist-column-upstream: Repository List. (line 54) +* magit-repolist-column-version: Repository List. (line 47) +* magit-repolist-fetch: Repository List. (line 111) +* magit-repolist-find-file-other-frame: Repository List. (line 115) +* magit-repolist-mark: Repository List. (line 105) +* magit-repolist-status: Repository List. (line 102) +* magit-repolist-unmark: Repository List. (line 108) +* magit-reset-hard: Resetting. (line 24) +* magit-reset-index: Staging and Unstaging. + (line 78) +* magit-reset-index <1>: Resetting. (line 33) +* magit-reset-keep: Resetting. (line 28) +* magit-reset-mixed: Resetting. (line 15) +* magit-reset-quickly: Resetting. (line 9) +* magit-reset-soft: Resetting. (line 19) +* magit-reset-worktree: Resetting. (line 39) +* magit-reset-worktree <1>: Wip Modes. (line 64) +* magit-restore-window-configuration: Quitting Windows. (line 24) +* magit-reverse: Applying. (line 47) +* magit-reverse-in-index: Staging and Unstaging. + (line 58) +* magit-revert: Reverting. (line 7) +* magit-revert-and-commit: Reverting. (line 15) +* magit-revert-no-commit: Reverting. (line 20) +* magit-run: Running Git Manually. + (line 13) +* magit-run-git: Calling Git for Effect. + (line 34) +* magit-run-git-async: Calling Git for Effect. + (line 59) +* magit-run-git-gui: Running Git Manually. + (line 59) +* magit-run-git-with-editor: Calling Git for Effect. + (line 71) +* magit-run-git-with-input: Calling Git for Effect. + (line 37) +* magit-run-gitk: Running Git Manually. + (line 50) +* magit-run-gitk-all: Running Git Manually. + (line 53) +* magit-run-gitk-branches: Running Git Manually. + (line 56) +* magit-save-window-configuration: Switching Buffers. (line 80) +* magit-section-backward: Section Movement. (line 11) +* magit-section-backward-siblings: Section Movement. (line 19) +* magit-section-case: Matching Sections. (line 66) +* magit-section-cycle: Section Visibility. (line 14) +* magit-section-cycle-diffs: Section Visibility. (line 29) +* magit-section-cycle-global: Section Visibility. (line 33) +* magit-section-forward: Section Movement. (line 16) +* magit-section-forward-siblings: Section Movement. (line 24) +* magit-section-hide: Section Visibility. (line 55) +* magit-section-hide-children: Section Visibility. (line 67) +* magit-section-ident: Matching Sections. (line 10) +* magit-section-match: Matching Sections. (line 18) +* magit-section-set-window-start: Section Movement. (line 52) +* magit-section-show: Section Visibility. (line 52) +* magit-section-show-children: Section Visibility. (line 62) +* magit-section-show-headings: Section Visibility. (line 58) +* magit-section-show-level-1: Section Visibility. (line 39) +* magit-section-show-level-1-all: Section Visibility. (line 45) +* magit-section-show-level-2: Section Visibility. (line 39) +* magit-section-show-level-2-all: Section Visibility. (line 45) +* magit-section-show-level-3: Section Visibility. (line 39) +* magit-section-show-level-3-all: Section Visibility. (line 45) +* magit-section-show-level-4: Section Visibility. (line 39) +* magit-section-show-level-4-all: Section Visibility. (line 45) +* magit-section-toggle: Section Visibility. (line 10) +* magit-section-toggle-children: Section Visibility. (line 70) +* magit-section-up: Section Movement. (line 28) +* magit-section-value-if: Matching Sections. (line 57) +* magit-sequence-abort: Cherry Picking. (line 91) +* magit-sequence-abort <1>: Reverting. (line 35) +* magit-sequence-continue: Cherry Picking. (line 85) +* magit-sequence-continue <1>: Reverting. (line 29) +* magit-sequence-skip: Cherry Picking. (line 88) +* magit-sequence-skip <1>: Reverting. (line 32) +* magit-shell-command: Running Git Manually. + (line 38) +* magit-shell-command-topdir: Running Git Manually. + (line 34) +* magit-show-commit: Diffing. (line 63) +* magit-show-commit <1>: Blaming. (line 91) +* magit-show-refs: References Buffer. (line 7) +* magit-show-refs-current: References Buffer. (line 25) +* magit-show-refs-head: References Buffer. (line 21) +* magit-show-refs-other: References Buffer. (line 30) +* magit-snapshot-both: Stashing. (line 36) +* magit-snapshot-index: Stashing. (line 42) +* magit-snapshot-worktree: Stashing. (line 46) +* magit-sparse-checkout: Sparse checkouts. (line 17) +* magit-sparse-checkout-add: Sparse checkouts. (line 39) +* magit-sparse-checkout-disable: Sparse checkouts. (line 50) +* magit-sparse-checkout-enable: Sparse checkouts. (line 21) +* magit-sparse-checkout-reapply: Sparse checkouts. (line 44) +* magit-sparse-checkout-set: Sparse checkouts. (line 33) +* magit-stage: Staging and Unstaging. + (line 29) +* magit-stage-buffer-file: Commands for Buffers Visiting Files. + (line 52) +* magit-stage-buffer-file <1>: Commands for Buffers Visiting Files. + (line 63) +* magit-stage-file: Staging from File-Visiting Buffers. + (line 11) +* magit-stage-file <1>: Commands for Buffers Visiting Files. + (line 52) +* magit-stage-file <2>: Commands for Buffers Visiting Files. + (line 63) +* magit-stage-modified: Staging and Unstaging. + (line 36) +* magit-start-git: Calling Git for Effect. + (line 82) +* magit-start-process: Calling Git for Effect. + (line 100) +* magit-stash: Stashing. (line 9) +* magit-stash-apply: Stashing. (line 52) +* magit-stash-both: Stashing. (line 14) +* magit-stash-branch: Stashing. (line 105) +* magit-stash-branch-here: Stashing. (line 110) +* magit-stash-clear: Stashing. (line 118) +* magit-stash-drop: Stashing. (line 98) +* magit-stash-format-patch: Stashing. (line 115) +* magit-stash-index: Stashing. (line 20) +* magit-stash-keep-index: Stashing. (line 30) +* magit-stash-list: Stashing. (line 121) +* magit-stash-pop: Stashing. (line 74) +* magit-stash-show: Diffing. (line 67) +* magit-stash-show <1>: Stashing. (line 102) +* magit-stash-worktree: Stashing. (line 24) +* magit-stashes-maybe-update-stash-buffer: Section Movement. (line 92) +* magit-status: Status Buffer. (line 23) +* magit-status-here: Commands for Buffers Visiting Files. + (line 52) +* magit-status-here <1>: Commands for Buffers Visiting Files. + (line 166) +* magit-status-maybe-update-blob-buffer: Section Movement. (line 87) +* magit-status-maybe-update-revision-buffer: Section Movement. + (line 77) +* magit-status-maybe-update-stash-buffer: Section Movement. (line 82) +* magit-status-quick: Status Buffer. (line 70) +* magit-submodule: Submodule Transient. (line 7) +* magit-submodule-add: Submodule Transient. (line 20) +* magit-submodule-populate: Submodule Transient. (line 32) +* magit-submodule-register: Submodule Transient. (line 26) +* magit-submodule-synchronize: Submodule Transient. (line 40) +* magit-submodule-unpopulate: Submodule Transient. (line 45) +* magit-submodule-update: Submodule Transient. (line 36) +* magit-subtree: Subtree. (line 9) +* magit-subtree-add: Subtree. (line 24) +* magit-subtree-add-commit: Subtree. (line 28) +* magit-subtree-export: Subtree. (line 37) +* magit-subtree-import: Subtree. (line 13) +* magit-subtree-merge: Subtree. (line 31) +* magit-subtree-pull: Subtree. (line 34) +* magit-subtree-push: Subtree. (line 48) +* magit-subtree-split: Subtree. (line 52) +* magit-switch-to-repository-buffer: Common Commands. (line 6) +* magit-switch-to-repository-buffer-other-frame: Common Commands. + (line 8) +* magit-switch-to-repository-buffer-other-window: Common Commands. + (line 7) +* magit-tag: Tagging. (line 9) +* magit-tag-create: Tagging. (line 14) +* magit-tag-delete: Tagging. (line 37) +* magit-tag-prune: Tagging. (line 43) +* magit-tag-release: Tagging. (line 18) +* magit-toggle-buffer-lock: Modes and Buffers. (line 18) +* magit-toggle-git-debug: Debugging Tools. (line 29) +* magit-toggle-margin: Refreshing Logs. (line 34) +* magit-toggle-margin <1>: Log Margin. (line 60) +* magit-toggle-margin-details: Log Margin. (line 66) +* magit-toggle-verbose-refresh: Debugging Tools. (line 52) +* magit-unstage: Staging and Unstaging. + (line 42) +* magit-unstage-all: Staging and Unstaging. + (line 50) +* magit-unstage-buffer-file: Commands for Buffers Visiting Files. + (line 52) +* magit-unstage-buffer-file <1>: Commands for Buffers Visiting Files. + (line 69) +* magit-unstage-file: Staging from File-Visiting Buffers. + (line 18) +* magit-unstage-file <1>: Commands for Buffers Visiting Files. + (line 52) +* magit-unstage-file <2>: Commands for Buffers Visiting Files. + (line 69) +* magit-version: Git Executable. (line 59) +* magit-version <1>: Debugging Tools. (line 11) +* magit-visit-ref: References Buffer. (line 159) +* magit-wip-commit: Wip Modes. (line 85) +* magit-wip-log: Wip Modes. (line 47) +* magit-wip-log-current: Wip Modes. (line 55) +* magit-worktree: Worktree. (line 9) +* magit-worktree-branch: Worktree. (line 16) +* magit-worktree-checkout: Worktree. (line 13) +* magit-worktree-delete: Worktree. (line 22) +* magit-worktree-move: Worktree. (line 19) +* magit-worktree-status: Worktree. (line 26) +* scroll-down: Commands Available in Diffs. + (line 56) +* scroll-up: Commands Available in Diffs. + (line 53) +* with-editor-cancel: Editing Commit Messages. + (line 22) +* with-editor-cancel <1>: Editing Rebase Sequences. + (line 11) +* with-editor-debug: Debugging Tools. (line 64) +* with-editor-finish: Editing Commit Messages. + (line 18) +* with-editor-finish <1>: Editing Rebase Sequences. + (line 7) +* with-editor-usage-message: Commit Mode and Hooks. + (line 51) + + +File: magit.info, Node: Variable Index, Prev: Function and Command Index, Up: Top + +Appendix E Variable Index +************************* + + +* Menu: + +* auto-revert-buffer-list-filter: Automatic Reverting of File-Visiting Buffers. + (line 73) +* auto-revert-interval: Automatic Reverting of File-Visiting Buffers. + (line 69) +* auto-revert-mode: Automatic Reverting of File-Visiting Buffers. + (line 57) +* auto-revert-stop-on-user-input: Automatic Reverting of File-Visiting Buffers. + (line 65) +* auto-revert-use-notify: Automatic Reverting of File-Visiting Buffers. + (line 46) +* auto-revert-verbose: Automatic Reverting of File-Visiting Buffers. + (line 94) +* branch.autoSetupMerge: Branch Git Variables. + (line 71) +* branch.autoSetupRebase: Branch Git Variables. + (line 85) +* branch.NAME.description: Branch Git Variables. + (line 42) +* branch.NAME.merge: Branch Git Variables. + (line 10) +* branch.NAME.pushRemote: Branch Git Variables. + (line 29) +* branch.NAME.rebase: Branch Git Variables. + (line 20) +* branch.NAME.remote: Branch Git Variables. + (line 15) +* core.notesRef: Notes. (line 53) +* git-commit-finish-query-functions: Commit Message Conventions. + (line 18) +* git-commit-known-pseudo-headers: Commit Pseudo Headers. + (line 9) +* git-commit-major-mode: Commit Mode and Hooks. + (line 12) +* git-commit-post-finish-hook: Commit Mode and Hooks. + (line 54) +* git-commit-setup-hook: Commit Mode and Hooks. + (line 21) +* git-commit-style-convention-checks: Commit Message Conventions. + (line 38) +* git-commit-summary-max-length: Commit Message Conventions. + (line 13) +* git-rebase-auto-advance: Editing Rebase Sequences. + (line 80) +* git-rebase-confirm-cancel: Editing Rebase Sequences. + (line 86) +* git-rebase-show-instructions: Editing Rebase Sequences. + (line 83) +* global-auto-revert-mode: Automatic Reverting of File-Visiting Buffers. + (line 21) +* magit-auto-revert-immediately: Automatic Reverting of File-Visiting Buffers. + (line 30) +* magit-auto-revert-mode: Automatic Reverting of File-Visiting Buffers. + (line 17) +* magit-auto-revert-tracked-only: Automatic Reverting of File-Visiting Buffers. + (line 51) +* magit-bisect-show-graph: Bisecting. (line 57) +* magit-blame-disable-modes: Blaming. (line 165) +* magit-blame-echo-style: Blaming. (line 151) +* magit-blame-goto-chunk-hook: Blaming. (line 170) +* magit-blame-read-only: Blaming. (line 161) +* magit-blame-styles: Blaming. (line 147) +* magit-blame-time-format: Blaming. (line 157) +* magit-branch-adjust-remote-upstream-alist: Branch Commands. (line 202) +* magit-branch-direct-configure: Branch Commands. (line 19) +* magit-branch-prefer-remote-upstream: Branch Commands. (line 158) +* magit-branch-read-upstream-first: Branch Commands. (line 153) +* magit-buffer-name-format: Naming Buffers. (line 25) +* magit-bury-buffer-function: Quitting Windows. (line 16) +* magit-cherry-margin: Cherries. (line 21) +* magit-clone-always-transient: Cloning Repository. (line 12) +* magit-clone-default-directory: Cloning Repository. (line 84) +* magit-clone-name-alist: Cloning Repository. (line 94) +* magit-clone-set-remote-head: Cloning Repository. (line 66) +* magit-clone-set-remote.pushDefault: Cloning Repository. (line 75) +* magit-clone-url-format: Cloning Repository. (line 114) +* magit-commit-ask-to-stage: Initiating a Commit. (line 65) +* magit-commit-diff-inhibit-same-window: Initiating a Commit. (line 97) +* magit-commit-extend-override-date: Initiating a Commit. (line 72) +* magit-commit-reword-override-date: Initiating a Commit. (line 75) +* magit-commit-show-diff: Initiating a Commit. (line 69) +* magit-commit-squash-confirm: Initiating a Commit. (line 78) +* magit-completing-read-function: Support for Completion Frameworks. + (line 27) +* magit-define-global-key-bindings: Global Bindings. (line 6) +* magit-diff-adjust-tab-width: Diff Options. (line 17) +* magit-diff-buffer-file-locked: Commands for Buffers Visiting Files. + (line 104) +* magit-diff-extra-stat-arguments: Diff Options. (line 112) +* magit-diff-hide-trailing-cr-characters: Diff Options. (line 77) +* magit-diff-highlight-hunk-region-functions: Diff Options. (line 80) +* magit-diff-highlight-indentation: Diff Options. (line 63) +* magit-diff-highlight-trailing: Diff Options. (line 59) +* magit-diff-paint-whitespace: Diff Options. (line 38) +* magit-diff-paint-whitespace-lines: Diff Options. (line 52) +* magit-diff-refine-hunk: Diff Options. (line 6) +* magit-diff-refine-ignore-whitespace: Diff Options. (line 13) +* magit-diff-unmarked-lines-keep-foreground: Diff Options. (line 105) +* magit-diff-visit-previous-blob: Visiting Files and Blobs from a Diff. + (line 38) +* magit-direct-use-buffer-arguments: Transient Arguments and Buffer Variables. + (line 73) +* magit-display-buffer-function: Switching Buffers. (line 25) +* magit-display-buffer-noselect: Switching Buffers. (line 17) +* magit-dwim-selection: Completion and Confirmation. + (line 42) +* magit-ediff-dwim-resolve-function: Ediffing. (line 105) +* magit-ediff-dwim-show-on-hunks: Ediffing. (line 111) +* magit-ediff-quit-hook: Ediffing. (line 124) +* magit-ediff-show-stash-with-index: Ediffing. (line 118) +* magit-generate-buffer-name-function: Naming Buffers. (line 6) +* magit-git-debug: Viewing Git Output. (line 26) +* magit-git-debug <1>: Getting a Value from Git. + (line 68) +* magit-git-executable: Git Executable. (line 26) +* magit-git-global-arguments: Global Git Arguments. + (line 6) +* magit-keep-region-overlay: The Selection. (line 52) +* magit-list-refs-sortby: Additional Completion Options. + (line 6) +* magit-log-auto-more: Log Buffer. (line 69) +* magit-log-buffer-file-locked: Commands for Buffers Visiting Files. + (line 124) +* magit-log-margin: Log Margin. (line 12) +* magit-log-margin-show-committer-date: Log Margin. (line 44) +* magit-log-section-commit-count: Status Sections. (line 114) +* magit-log-select-margin: Select from Log. (line 28) +* magit-log-show-color-graph-limit: Log Buffer. (line 78) +* magit-log-show-refname-after-summary: Log Buffer. (line 74) +* magit-log-show-signatures-limit: Log Buffer. (line 84) +* magit-log-trace-definition-function: Commands Available in Diffs. + (line 17) +* magit-module-sections-hook: Status Module Sections. + (line 19) +* magit-module-sections-nested: Status Module Sections. + (line 22) +* magit-no-confirm: Action Confirmation. (line 18) +* magit-pop-revision-stack-format: Using the Revision Stack. + (line 34) +* magit-post-clone-hook: Cloning Repository. (line 133) +* magit-post-commit-hook: Initiating a Commit. (line 86) +* magit-post-display-buffer-hook: Switching Buffers. (line 85) +* magit-pre-display-buffer-hook: Switching Buffers. (line 76) +* magit-prefer-remote-upstream: Branch Git Variables. + (line 109) +* magit-prefix-use-buffer-arguments: Transient Arguments and Buffer Variables. + (line 65) +* magit-process-extreme-logging: Viewing Git Output. (line 56) +* magit-process-raise-error: Calling Git for Effect. + (line 125) +* magit-pull-or-fetch: Fetching. (line 52) +* magit-reflog-margin: Reflog. (line 20) +* magit-refresh-args: Refreshing Buffers. (line 52) +* magit-refresh-buffer-hook: Automatic Refreshing of Magit Buffers. + (line 41) +* magit-refresh-function: Refreshing Buffers. (line 47) +* magit-refresh-status-buffer: Automatic Refreshing of Magit Buffers. + (line 46) +* magit-refs-filter-alist: References Buffer. (line 137) +* magit-refs-focus-column-width: References Buffer. (line 75) +* magit-refs-margin: References Buffer. (line 89) +* magit-refs-margin-for-tags: References Buffer. (line 112) +* magit-refs-pad-commit-counts: References Buffer. (line 45) +* magit-refs-primary-column-width: References Buffer. (line 63) +* magit-refs-sections-hook: References Sections. (line 13) +* magit-refs-show-commit-count: References Buffer. (line 36) +* magit-refs-show-remote-prefix: References Buffer. (line 57) +* magit-remote-add-set-remote.pushDefault: Remote Commands. (line 83) +* magit-remote-direct-configure: Remote Commands. (line 20) +* magit-remote-git-executable: Git Executable. (line 32) +* magit-repolist-columns: Repository List. (line 12) +* magit-repository-directories: Status Buffer. (line 57) +* magit-revision-filter-files-on-follow: Revision Buffer. (line 55) +* magit-revision-insert-related-refs: Revision Buffer. (line 6) +* magit-revision-show-gravatars: Revision Buffer. (line 15) +* magit-revision-use-hash-sections: Revision Buffer. (line 31) +* magit-root-section: Matching Sections. (line 81) +* magit-save-repository-buffers: Automatic Saving of File-Visiting Buffers. + (line 13) +* magit-section-cache-visibility: Section Visibility. (line 95) +* magit-section-initial-visibility-alist: Section Visibility. (line 79) +* magit-section-movement-hook: Section Movement. (line 41) +* magit-section-set-visibility-hook: Section Visibility. (line 105) +* magit-section-show-child-count: Section Options. (line 9) +* magit-section-visibility-indicator: Section Visibility. (line 122) +* magit-shell-command-verbose-prompt: Running Git Manually. + (line 43) +* magit-stashes-margin: Stashing. (line 123) +* magit-status-headers-hook: Status Header Sections. + (line 17) +* magit-status-margin: Status Options. (line 6) +* magit-status-sections-hook: Status Sections. (line 10) +* magit-submodule-list-columns: Listing Submodules. (line 20) +* magit-this-process: Calling Git for Effect. + (line 121) +* magit-uniquify-buffer-names: Naming Buffers. (line 65) +* magit-unstage-committed: Staging and Unstaging. + (line 52) +* magit-update-other-window-delay: Section Movement. (line 97) +* magit-visit-ref-behavior: References Buffer. (line 168) +* magit-wip-after-apply-mode: Legacy Wip Modes. (line 18) +* magit-wip-after-apply-mode-lighter: Legacy Wip Modes. (line 54) +* magit-wip-after-save-local-mode-lighter: Legacy Wip Modes. (line 51) +* magit-wip-after-save-mode: Legacy Wip Modes. (line 13) +* magit-wip-before-change-mode: Legacy Wip Modes. (line 31) +* magit-wip-before-change-mode-lighter: Legacy Wip Modes. (line 57) +* magit-wip-initial-backup-mode: Legacy Wip Modes. (line 35) +* magit-wip-initial-backup-mode-lighter: Legacy Wip Modes. (line 60) +* magit-wip-merge-branch: Wip Graph. (line 6) +* magit-wip-mode: Wip Modes. (line 30) +* magit-wip-mode-lighter: Wip Modes. (line 98) +* magit-wip-namespace: Wip Modes. (line 91) +* notes.displayRef: Notes. (line 57) +* pull.rebase: Branch Git Variables. + (line 50) +* remote.NAME.fetch: Remote Git Variables. + (line 14) +* remote.NAME.push: Remote Git Variables. + (line 23) +* remote.NAME.pushurl: Remote Git Variables. + (line 18) +* remote.NAME.tagOpts: Remote Git Variables. + (line 27) +* remote.NAME.url: Remote Git Variables. + (line 10) +* remote.pushDefault: Branch Git Variables. + (line 62) + + + +Tag Table: +Node: Top774 +Node: Introduction6566 +Node: Installation11282 +Node: Installing from Melpa11612 +Node: Installing from the Git Repository12687 +Node: Post-Installation Tasks15501 +Node: Getting Started16786 +Node: Interface Concepts22597 +Node: Modes and Buffers22976 +Node: Switching Buffers24687 +Node: Naming Buffers29426 +Node: Quitting Windows32501 +Node: Automatic Refreshing of Magit Buffers34436 +Node: Automatic Saving of File-Visiting Buffers37317 +Node: Automatic Reverting of File-Visiting Buffers38501 +Node: Risk of Reverting Automatically43486 +Node: Sections45868 +Node: Section Movement46794 +Node: Section Visibility51668 +Node: Section Hooks58355 +Node: Section Types and Values60761 +Node: Section Options62176 +Node: Transient Commands62647 +Node: Transient Arguments and Buffer Variables64123 +Node: Completion Confirmation and the Selection71140 +Node: Action Confirmation71586 +Node: Completion and Confirmation80091 +Node: The Selection83276 +Node: The hunk-internal region86174 +Node: Support for Completion Frameworks87263 +Node: Additional Completion Options92148 +Node: Mouse Support92746 +Node: Running Git93322 +Node: Viewing Git Output93567 +Node: Git Process Status96271 +Node: Running Git Manually97236 +Node: Git Executable99926 +Node: Global Git Arguments102934 +Node: Inspecting103739 +Node: Status Buffer104896 +Node: Status Sections109907 +Node: Status Header Sections115434 +Node: Status Module Sections118053 +Node: Status Options120550 +Node: Repository List121913 +Node: Logging126691 +Node: Refreshing Logs129533 +Node: Log Buffer130954 +Node: Log Margin135777 +Node: Select from Log138930 +Node: Reflog141140 +Node: Cherries142777 +Node: Diffing144615 +Node: Refreshing Diffs147649 +Node: Commands Available in Diffs151338 +Node: Diff Options153851 +Node: Revision Buffer159314 +Node: Ediffing162634 +Node: References Buffer168684 +Node: References Sections179278 +Node: Bisecting180135 +Node: Visiting Files and Blobs182446 +Node: General-Purpose Visit Commands182974 +Node: Visiting Files and Blobs from a Diff183927 +Node: Blaming187371 +Node: Manipulating194359 +Node: Creating Repository194701 +Node: Cloning Repository195238 +Node: Staging and Unstaging201679 +Node: Staging from File-Visiting Buffers205660 +Node: Applying206766 +Node: Committing208839 +Node: Initiating a Commit209422 +Node: Editing Commit Messages214612 +Node: Using the Revision Stack217385 +Node: Commit Pseudo Headers220430 +Node: Commit Mode and Hooks221725 +Node: Commit Message Conventions224583 +Node: Branching226570 +Node: The Two Remotes226796 +Node: Branch Commands229449 +Node: Branch Git Variables242299 +Node: Auxiliary Branch Commands247673 +Node: Merging248789 +Node: Resolving Conflicts252945 +Node: Rebasing258319 +Node: Editing Rebase Sequences263108 +Node: Information About In-Progress Rebase267324 +Ref: Information About In-Progress Rebase-Footnote-1276437 +Node: Cherry Picking277033 +Node: Reverting281367 +Node: Resetting282786 +Node: Stashing284612 +Node: Transferring290993 +Node: Remotes291215 +Node: Remote Commands291367 +Node: Remote Git Variables295406 +Node: Fetching296677 +Node: Pulling299160 +Node: Pushing300186 +Node: Plain Patches304477 +Node: Maildir Patches305948 +Node: Miscellaneous307427 +Node: Tagging307773 +Node: Notes309666 +Node: Submodules312001 +Node: Listing Submodules312219 +Node: Submodule Transient314367 +Node: Subtree316812 +Node: Worktree318743 +Node: Sparse checkouts319819 +Node: Bundle322595 +Node: Common Commands322970 +Node: Wip Modes325598 +Node: Wip Graph330489 +Node: Legacy Wip Modes332802 +Node: Commands for Buffers Visiting Files335689 +Node: Minor Mode for Buffers Visiting Blobs343916 +Node: Customizing344714 +Node: Per-Repository Configuration346310 +Node: Essential Settings348564 +Node: Safety348910 +Node: Performance350671 +Ref: Log Performance353634 +Ref: Diff Performance354939 +Ref: Refs Buffer Performance356280 +Ref: Committing Performance356855 +Node: Microsoft Windows Performance357837 +Node: MacOS Performance359028 +Ref: MacOS Performance-Footnote-1360051 +Node: Global Bindings360133 +Node: Plumbing362361 +Node: Calling Git363190 +Node: Getting a Value from Git364715 +Node: Calling Git for Effect368443 +Node: Section Plumbing374337 +Node: Creating Sections374565 +Node: Section Selection378461 +Node: Matching Sections380257 +Node: Refreshing Buffers386178 +Node: Conventions389322 +Node: Theming Faces389514 +Node: FAQ397619 +Node: FAQ - How to ...?398057 +Node: How to pronounce Magit?398414 +Node: How to show git's output?399217 +Node: How to install the gitman info manual?400003 +Node: How to show diffs for gpg-encrypted files?400973 +Node: How does branching and pushing work?401569 +Node: Should I disable VC?401902 +Node: FAQ - Issues and Errors402505 +Node: Magit is slow403450 +Node: I changed several thousand files at once and now Magit is unusable403743 +Node: I am having problems committing404469 +Node: I am using MS Windows and cannot push with Magit404950 +Node: I am using macOS and SOMETHING works in shell but not in Magit405568 +Node: Expanding a file to show the diff causes it to disappear406402 +Node: Point is wrong in the COMMIT_EDITMSG buffer406990 +Node: The mode-line information isn't always up-to-date408035 +Node: A branch and tag sharing the same name breaks SOMETHING409098 +Node: My Git hooks work on the command-line but not inside Magit409985 +Node: git-commit-mode isn't used when committing from the command-line410831 +Node: Point ends up inside invisible text when jumping to a file-visiting buffer413102 +Node: I am no longer able to save popup defaults413951 +Node: Debugging Tools414932 +Node: Keystroke Index418106 +Node: Function and Command Index459720 +Node: Variable Index517921 + +End Tag Table + + +Local Variables: +coding: utf-8 +End: diff --git a/emacs/elpa/marginalia-20240404.451/marginalia-pkg.el b/emacs/elpa/marginalia-20240404.451/marginalia-pkg.el @@ -1,15 +0,0 @@ -(define-package "marginalia" "20240404.451" "Enrich existing commands with completion annotations" - '((emacs "27.1") - (compat "29.1.4.4")) - :commit "58eb5fd6e5cc21b12c5455ae69e7ae93579647bc" :authors - '(("Omar Antolín Camarena <omar@matem.unam.mx>, Daniel Mendler" . "mail@daniel-mendler.de")) - :maintainers - '(("Omar Antolín Camarena <omar@matem.unam.mx>, Daniel Mendler" . "mail@daniel-mendler.de")) - :maintainer - '("Omar Antolín Camarena <omar@matem.unam.mx>, Daniel Mendler" . "mail@daniel-mendler.de") - :keywords - '("docs" "help" "matching" "completion") - :url "https://github.com/minad/marginalia") -;; Local Variables: -;; no-byte-compile: t -;; End: diff --git a/emacs/elpa/marginalia-20240404.451/marginalia.el b/emacs/elpa/marginalia-20240404.451/marginalia.el @@ -1,1361 +0,0 @@ -;;; marginalia.el --- Enrich existing commands with completion annotations -*- lexical-binding: t -*- - -;; Copyright (C) 2021-2024 Free Software Foundation, Inc. - -;; Author: Omar Antolín Camarena <omar@matem.unam.mx>, Daniel Mendler <mail@daniel-mendler.de> -;; Maintainer: Omar Antolín Camarena <omar@matem.unam.mx>, Daniel Mendler <mail@daniel-mendler.de> -;; Created: 2020 -;; Version: 1.6 -;; Package-Requires: ((emacs "27.1") (compat "29.1.4.4")) -;; Homepage: https://github.com/minad/marginalia -;; Keywords: docs, help, matching, completion - -;; This file is part of GNU Emacs. - -;; 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 <https://www.gnu.org/licenses/>. - -;;; Commentary: - -;; Enrich existing commands with completion annotations - -;;; Code: - -(require 'compat) -(eval-when-compile - (require 'subr-x) - (require 'cl-lib)) - -;;;; Customization - -(defgroup marginalia nil - "Enrich existing commands with completion annotations." - :link '(info-link :tag "Info Manual" "(marginalia)") - :link '(url-link :tag "Homepage" "https://github.com/minad/marginalia") - :link '(emacs-library-link :tag "Library Source" "marginalia.el") - :group 'help - :group 'docs - :group 'minibuffer - :prefix "marginalia-") - -(defcustom marginalia-field-width 80 - "Maximum truncation width of annotation fields. - -This value is adjusted depending on the `window-width'." - :type 'natnum) - -(defcustom marginalia-separator " " - "Annotation field separator." - :type 'string) - -(defcustom marginalia-align 'left - "Alignment of the annotations." - :type '(choice (const :tag "Left" left) - (const :tag "Center" center) - (const :tag "Right" right))) - -(defcustom marginalia-align-offset 0 - "Additional offset added to the alignment." - :type 'natnum) - -(defcustom marginalia-max-relative-age (* 60 60 24 14) - "Maximum relative age in seconds displayed by the file annotator. - -Set to `most-positive-fixnum' to always use a relative age, or 0 to never show -a relative age." - :type 'natnum) - -(defcustom marginalia-remote-file-regexps - '("\\`/\\([^/|:]+\\):") ;; Tramp path - "List of remote file regexps where the files should not be annotated. - -The first match group is displayed instead of the detailed file -attribute information. For Tramp paths, the protocol is -displayed instead." - :type '(repeat regexp)) - -(defcustom marginalia-annotator-registry - (mapcar - (lambda (x) (append x '(builtin none))) - `((command ,#'marginalia-annotate-command ,#'marginalia-annotate-binding) - (embark-keybinding ,#'marginalia-annotate-embark-keybinding) - (customize-group ,#'marginalia-annotate-customize-group) - (variable ,#'marginalia-annotate-variable) - (function ,#'marginalia-annotate-function) - (face ,#'marginalia-annotate-face) - (color ,#'marginalia-annotate-color) - (unicode-name ,#'marginalia-annotate-char) - (minor-mode ,#'marginalia-annotate-minor-mode) - (symbol ,#'marginalia-annotate-symbol) - (environment-variable ,#'marginalia-annotate-environment-variable) - (input-method ,#'marginalia-annotate-input-method) - (coding-system ,#'marginalia-annotate-coding-system) - (charset ,#'marginalia-annotate-charset) - (package ,#'marginalia-annotate-package) - (imenu ,#'marginalia-annotate-imenu) - (bookmark ,#'marginalia-annotate-bookmark) - (file ,#'marginalia-annotate-file) - (project-file ,#'marginalia-annotate-project-file) - (buffer ,#'marginalia-annotate-buffer) - (library ,#'marginalia-annotate-library) - (theme ,#'marginalia-annotate-theme) - (tab ,#'marginalia-annotate-tab) - (multi-category ,#'marginalia-annotate-multi-category))) - "Annotator function registry. -Associates completion categories with annotation functions. -Each annotation function must return a string, -which is appended to the completion candidate." - :type '(alist :key-type symbol :value-type (repeat symbol))) - -(defcustom marginalia-classifiers - (list #'marginalia-classify-by-command-name - #'marginalia-classify-original-category - #'marginalia-classify-by-prompt - #'marginalia-classify-symbol) - "List of functions to determine current completion category. -Each function should take no arguments and return a symbol -indicating the category, or nil to indicate it could not -determine it." - :type 'hook) - -(defcustom marginalia-prompt-categories - '(("\\<customize group\\>" . customize-group) - ("\\<M-x\\>" . command) - ("\\<package\\>" . package) - ("\\<bookmark\\>" . bookmark) - ("\\<color\\>" . color) - ("\\<face\\>" . face) - ("\\<environment variable\\>" . environment-variable) - ("\\<function\\|hook to remove\\>" . function) - ("\\<variable\\>" . variable) - ("\\<input method\\>" . input-method) - ("\\<charset\\>" . charset) - ("\\<coding system\\>" . coding-system) - ("\\<minor mode\\>" . minor-mode) - ("\\<kill-ring\\>" . kill-ring) - ("\\<tab by name\\>" . tab) - ("\\<library\\>" . library) - ("\\<theme\\>" . theme)) - "Associates regexps to match against minibuffer prompts with categories. -The prompts are matched case-insensitively." - :type '(alist :key-type regexp :value-type symbol)) - -(defcustom marginalia-censor-variables - '("pass\\|auth-source-netrc-cache\\|auth-source-.*-nonce\\|api-?key") - "The value of variables matching any of these regular expressions is not shown. -This configuration variable is useful to hide variables which may -hold sensitive data, e.g., passwords. The variable names are -matched case-sensitively." - :type '(repeat (choice symbol regexp))) - -(defcustom marginalia-command-categories - '((imenu . imenu) - (recentf-open . file) - (where-is . command)) - "Associate commands with a completion category. -The value of `this-command' is used as key for the lookup." - :type '(alist :key-type symbol :value-type symbol)) - -(defgroup marginalia-faces nil - "Faces used by `marginalia-mode'." - :group 'marginalia - :group 'faces) - -(defface marginalia-key - '((t :inherit font-lock-keyword-face)) - "Face used to highlight keys.") - -(defface marginalia-type - '((t :inherit marginalia-key)) - "Face used to highlight types.") - -(defface marginalia-char - '((t :inherit marginalia-key)) - "Face used to highlight character annotations.") - -(defface marginalia-lighter - '((t :inherit marginalia-size)) - "Face used to highlight minor mode lighters.") - -(defface marginalia-on - '((t :inherit success)) - "Face used to signal enabled modes.") - -(defface marginalia-off - '((t :inherit error)) - "Face used to signal disabled modes.") - -(defface marginalia-documentation - '((t :inherit completions-annotations)) - "Face used to highlight documentation strings.") - -(defface marginalia-value - '((t :inherit marginalia-key)) - "Face used to highlight general variable values.") - -(defface marginalia-null - '((t :inherit font-lock-comment-face)) - "Face used to highlight null or unbound variable values.") - -(defface marginalia-true - '((t :inherit font-lock-builtin-face)) - "Face used to highlight true variable values.") - -(defface marginalia-function - '((t :inherit font-lock-function-name-face)) - "Face used to highlight function symbols.") - -(defface marginalia-symbol - '((t :inherit font-lock-type-face)) - "Face used to highlight general symbols.") - -(defface marginalia-list - '((t :inherit font-lock-constant-face)) - "Face used to highlight list expressions.") - -(defface marginalia-mode - '((t :inherit marginalia-key)) - "Face used to highlight buffer major modes.") - -(defface marginalia-date - '((t :inherit marginalia-key)) - "Face used to highlight dates.") - -(defface marginalia-version - '((t :inherit marginalia-number)) - "Face used to highlight package versions.") - -(defface marginalia-archive - '((t :inherit warning)) - "Face used to highlight package archives.") - -(defface marginalia-installed - '((t :inherit success)) - "Face used to highlight the status of packages.") - -(defface marginalia-size - '((t :inherit marginalia-number)) - "Face used to highlight sizes.") - -(defface marginalia-number - '((t :inherit font-lock-constant-face)) - "Face used to highlight numeric values.") - -(defface marginalia-string - '((t :inherit font-lock-string-face)) - "Face used to highlight string values.") - -(defface marginalia-modified - '((t :inherit font-lock-negation-char-face)) - "Face used to highlight buffer modification indicators.") - -(defface marginalia-file-name - '((t :inherit marginalia-documentation)) - "Face used to highlight file names.") - -(defface marginalia-file-owner - '((t :inherit font-lock-preprocessor-face)) - "Face used to highlight file owner and group names.") - -(defface marginalia-file-priv-no - '((t :inherit shadow)) - "Face used to highlight the no file privilege attribute.") - -(defface marginalia-file-priv-dir - '((t :inherit font-lock-keyword-face)) - "Face used to highlight the dir file privilege attribute.") - -(defface marginalia-file-priv-link - '((t :inherit font-lock-keyword-face)) - "Face used to highlight the link file privilege attribute.") - -(defface marginalia-file-priv-read - '((t :inherit font-lock-type-face)) - "Face used to highlight the read file privilege attribute.") - -(defface marginalia-file-priv-write - '((t :inherit font-lock-builtin-face)) - "Face used to highlight the write file privilege attribute.") - -(defface marginalia-file-priv-exec - '((t :inherit font-lock-function-name-face)) - "Face used to highlight the exec file privilege attribute.") - -(defface marginalia-file-priv-other - '((t :inherit font-lock-constant-face)) - "Face used to highlight some other file privilege attribute.") - -(defface marginalia-file-priv-rare - '((t :inherit font-lock-variable-name-face)) - "Face used to highlight a rare file privilege attribute.") - -;;;; Pre-declarations for external packages - -(declare-function bookmark-prop-get "bookmark") - -(declare-function project-current "project") - -(defvar package--builtins) -(defvar package-archive-contents) -(declare-function package--from-builtin "package") -(declare-function package-desc-archive "package") -(declare-function package-desc-status "package") -(declare-function package-desc-summary "package") -(declare-function package-desc-version "package") -(declare-function package-version-join "package") - -(declare-function color-rgb-to-hex "color") -(declare-function color-rgb-to-hsl "color") -(declare-function color-hsl-to-rgb "color") - -;;;; Marginalia mode - -(defvar marginalia--pangram "Cwm fjord bank glyphs vext quiz.") - -(defvar marginalia--bookmark-type-transforms - (let ((words (regexp-opt '("handle" "handler" "jump" "bookmark")))) - `((,(format "-+%s-+" words) . "-") - (,(format "\\`%s-+" words) . "") - (,(format "-%s\\'" words) . "") - ("\\`default\\'" . "File") - (".*" . ,#'capitalize))) - "List of bookmark type transformers. -Relying on this mechanism is discouraged in favor of the -`bookmark-handler-type' property. The function names are matched -case-sensitively.") - -(defvar marginalia--cand-width-step 10 - "Round candidate width.") - -(defvar-local marginalia--cand-width-max 20 - "Maximum width of candidates.") - -(defvar marginalia--fontified-file-modes nil - "List of fontified file modes.") - -(defvar-local marginalia--cache nil - "The cache, pair of list and hashtable.") - -(defvar marginalia--cache-size 100 - "Size of the cache, set to 0 to disable the cache. -Disabling the cache is useful on non-incremental UIs like default completion or -for performance profiling of the annotators.") - -(defvar-local marginalia--command nil - "Last command symbol saved in order to allow annotations.") - -(defvar-local marginalia--base-position 0 - "Last completion base position saved to get full file paths.") - -(defvar marginalia--metadata nil - "Completion metadata from the current completion.") - -(defvar marginalia--ellipsis nil) -(defun marginalia--ellipsis () - "Return ellipsis." - (with-memoization marginalia--ellipsis - (cond - ((bound-and-true-p truncate-string-ellipsis)) - ((char-displayable-p ?…) "…") - ("...")))) - -(defun marginalia--truncate (str width) - "Truncate string STR to WIDTH." - (when (floatp width) (setq width (round (* width marginalia-field-width)))) - (when-let (pos (string-search "\n" str)) - (setq str (substring str 0 pos))) - (let* ((face (and (not (equal str "")) - (get-text-property (1- (length str)) 'face str))) - (ell (if face - (propertize (marginalia--ellipsis) 'face face) - (marginalia--ellipsis))) - (trunc - (if (< width 0) - (nreverse (truncate-string-to-width (reverse str) (- width) 0 ?\s ell)) - (truncate-string-to-width str width 0 ?\s ell)))) - (unless (string-prefix-p str trunc) - (put-text-property 0 (length trunc) 'help-echo str trunc)) - trunc)) - -(cl-defmacro marginalia--field (field &key truncate face width format) - "Format FIELD as a string according to some options. -TRUNCATE is the truncation width. -WIDTH is the field width. -FORMAT is a format string. -FACE is the name of the face, with which the field should be propertized." - (setq field (if format `(format ,format ,field) `(or ,field ""))) - (when width (setq field `(format ,(format "%%%ds" (- width)) ,field))) - (when truncate (setq field `(marginalia--truncate ,field ,truncate))) - (when face (setq field `(propertize ,field 'face ,face))) - field) - -(defmacro marginalia--fields (&rest fields) - "Format annotation FIELDS as a string with separators in between." - (let ((left t)) - (cons 'concat - (mapcan - (lambda (field) - (if (not (eq (car field) :left)) - `(,@(when left (setq left nil) `(#(" " 0 1 (marginalia--align t)))) - marginalia-separator (marginalia--field ,@field)) - (unless left (error "Left fields must come first")) - `((marginalia--field ,@(cdr field))))) - fields)))) - -(defmacro marginalia--in-minibuffer (&rest body) - "Run BODY inside minibuffer if minibuffer is active. -Otherwise stay within current buffer." - (declare (indent 0)) - `(with-current-buffer (if-let (win (active-minibuffer-window)) - (window-buffer win) - (current-buffer)) - ,@body)) - -(defun marginalia--documentation (str) - "Format documentation string STR." - (when str - (marginalia--fields - (str :truncate 1.0 :face 'marginalia-documentation)))) - -(defun marginalia-annotate-binding (cand) - "Annotate command CAND with keybinding." - (when-let ((sym (intern-soft cand)) - (key (and (commandp sym) (where-is-internal sym nil 'first-only)))) - (format #(" (%s)" 1 5 (face marginalia-key)) (key-description key)))) - -(defun marginalia--annotator (cat) - "Return annotation function for category CAT." - (pcase (car (alist-get cat marginalia-annotator-registry)) - ('none #'ignore) - ('builtin nil) - (fun fun))) - -(defun marginalia-annotate-multi-category (cand) - "Annotate multi-category CAND with the buffer class." - (if-let ((multi (get-text-property 0 'multi-category cand)) - (annotate (marginalia--annotator (car multi)))) - ;; Use the Marginalia annotator corresponding to the multi category. - (funcall annotate (cdr multi)) - ;; Apply the original annotation function on the original candidate, if - ;; there is one. Use `alist-get' instead of `completion-metadata-get' to - ;; bypass our `marginalia--completion-metadata-get' advice! - (when-let (annotate (alist-get 'annotation-function marginalia--metadata)) - (funcall annotate cand)))) - -(defconst marginalia--advice-regexp - (rx bos - (1+ (seq (? "This function has ") - (or ":before" ":after" ":around" ":override" - ":before-while" ":before-until" ":after-while" - ":after-until" ":filter-args" ":filter-return") - " advice: " (0+ nonl) "\n")) - "\n") - "Regexp to match lines about advice in function documentation strings.") - -;; Taken from advice--make-docstring, is this robust? -(defun marginalia--advised (fun) - "Return t if function FUN is advised." - (let ((flist (indirect-function fun))) - (advice--p (if (eq 'macro (car-safe flist)) (cdr flist) flist)))) - -(defun marginalia--symbol-class (s) - "Return symbol class characters for symbol S. - -This function is an extension of `help--symbol-class'. It returns -more fine-grained and more detailed symbol information. - -Function: -f function -c command -C interactive-only command -m macro -F special-form -M module function -P primitive -g cl-generic -p pure -s side-effect-free -@ autoloaded -! advised -- obsolete -& alias - -Variable: -u custom (U modified compared to global value) -v variable -l local (L modified compared to default value) -- obsolete -& alias - -Other: -a face -t cl-type" - (let ((class - (append - (when (fboundp s) - (list - (cond - ((get s 'pure) '("p" . "pure")) - ((get s 'side-effect-free) '("s" . "side-effect-free"))) - (cond - ((commandp s) - (if (get s 'interactive-only) - '("C" . "interactive-only command") - '("c" . "command"))) - ((cl-generic-p s) '("g" . "cl-generic")) - ((macrop (symbol-function s)) '("m" . "macro")) - ((special-form-p (symbol-function s)) '("F" . "special-form")) - ((subr-primitive-p (symbol-function s)) '("P" . "primitive")) - ((module-function-p (symbol-function s)) '("M" . "module function")) - (t '("f" . "function"))) - (and (autoloadp (symbol-function s)) '("@" . "autoload")) - (and (marginalia--advised s) '("!" . "advised")) - (and (symbolp (symbol-function s)) - (cons "&" (format "alias for `%s'" (symbol-function s)))) - (and (get s 'byte-obsolete-info) '("-" . "obsolete")))) - (when (boundp s) - (list - (when (local-variable-if-set-p s) - (if (ignore-errors - (not (equal (symbol-value s) - (default-value s)))) - '("L" . "local, modified from global") - '("l" . "local, unmodified"))) - (if (custom-variable-p s) - (if (ignore-errors - (not (equal (symbol-value s) - (eval (car (get s 'standard-value)))))) - '("U" . "custom, modified from standard") - '("u" . "custom, unmodified")) - '("v" . "variable")) - (and (not (eq (ignore-errors (indirect-variable s)) s)) - (cons "&" (format "alias for `%s'" (ignore-errors (indirect-variable s))))) - (and (get s 'byte-obsolete-variable) '("-" . "obsolete")))) - (list - (and (facep s) '("a" . "face")) - (and (get s 'cl--class) '("t" . "cl-type")))))) ;; cl-find-class, cl--find-class - (setq class (delq nil class)) - (propertize - (format " %-6s" (mapconcat #'car class "")) - 'help-echo - (mapconcat (pcase-lambda (`(,x . ,y)) (concat x " " y)) class "\n")))) - -(defun marginalia--function-doc (sym) - "Documentation string of function SYM." - (when-let (str (ignore-errors (documentation sym))) - (save-match-data - (if (string-match marginalia--advice-regexp str) - (substring str (match-end 0)) - str)))) - -;; Derived from elisp-get-fnsym-args-string -(defun marginalia--function-args (sym) - "Return function arguments for SYM." - (let ((tmp)) - (elisp-function-argstring - (cond - ((listp (setq tmp (gethash (indirect-function sym) - advertised-signature-table t))) - tmp) - ((setq tmp (help-split-fundoc - (ignore-errors (documentation sym t)) - sym)) - (substitute-command-keys (car tmp))) - ((setq tmp (help-function-arglist sym)) - (and - (if (and (stringp tmp) - (string-search "Arg list not available" tmp)) - ;; A shorter text fits better into the - ;; limited Marginalia space. - "[autoload]" - tmp))))))) - -(defun marginalia-annotate-symbol (cand) - "Annotate symbol CAND with its documentation string." - (when-let (sym (intern-soft cand)) - (marginalia--fields - (:left (marginalia-annotate-binding cand)) - ((marginalia--symbol-class sym) :face 'marginalia-type) - ((if (fboundp sym) (marginalia--function-doc sym) - (cl-loop - for doc in '(variable-documentation - face-documentation - group-documentation) - thereis (ignore-errors (documentation-property sym doc)))) - :truncate 1.0 :face 'marginalia-documentation) - ((abbreviate-file-name (or (symbol-file sym) "")) - :truncate -0.5 :face 'marginalia-file-name)))) - -(defun marginalia-annotate-command (cand) - "Annotate command CAND with its documentation string. -Similar to `marginalia-annotate-symbol', but does not show symbol class." - (when-let (sym (intern-soft cand)) - (concat - (marginalia-annotate-binding cand) - (marginalia--documentation (marginalia--function-doc sym))))) - -(defun marginalia-annotate-embark-keybinding (cand) - "Annotate Embark keybinding CAND with its documentation string. -Similar to `marginalia-annotate-command', but does not show the -keybinding since CAND includes it." - (when-let (cmd (get-text-property 0 'embark-command cand)) - (marginalia--documentation (marginalia--function-doc cmd)))) - -(defun marginalia-annotate-imenu (cand) - "Annotate imenu CAND with its documentation string." - (when (derived-mode-p 'emacs-lisp-mode) - ;; Strip until the last whitespace in order to support flat imenu - (marginalia-annotate-symbol (replace-regexp-in-string "\\`.* " "" cand)))) - -(defun marginalia-annotate-function (cand) - "Annotate function CAND with its documentation string." - (when-let (sym (intern-soft cand)) - (when (fboundp sym) - (marginalia--fields - (:left (marginalia-annotate-binding cand)) - ((marginalia--symbol-class sym) :face 'marginalia-type) - ((marginalia--function-args sym) :face 'marginalia-value - :truncate 0.5) - ((marginalia--function-doc sym) :truncate 1.0 - :face 'marginalia-documentation))))) - -(defun marginalia--variable-value (sym) - "Return the variable value of SYM as string." - (cond - ((not (boundp sym)) - (propertize "#<unbound>" 'face 'marginalia-null)) - ((and marginalia-censor-variables - (let ((name (symbol-name sym)) - case-fold-search) - (cl-loop for r in marginalia-censor-variables - thereis (if (symbolp r) - (eq r sym) - (string-match-p r name))))) - (propertize "*****" - 'face 'marginalia-null - 'help-echo "Hidden due to `marginalia-censor-variables'")) - (t - (let ((val (symbol-value sym))) - (pcase val - ('nil (propertize "nil" 'face 'marginalia-null)) - ('t (propertize "t" 'face 'marginalia-true)) - ((pred keymapp) (propertize "#<keymap>" 'face 'marginalia-value)) - ((pred bool-vector-p) (propertize "#<bool-vector>" 'face 'marginalia-value)) - ((pred hash-table-p) (propertize "#<hash-table>" 'face 'marginalia-value)) - ((pred syntax-table-p) (propertize "#<syntax-table>" 'face 'marginalia-value)) - ;; Emacs bug#53988: abbrev-table-p throws an error - ((and (pred vectorp) (guard (ignore-errors (abbrev-table-p val)))) - (propertize "#<abbrev-table>" 'face 'marginalia-value)) - ((pred char-table-p) (propertize "#<char-table>" 'face 'marginalia-value)) - ;; Emacs 29 comes with callable objects or object closures (OClosures) - ((guard (and (fboundp 'oclosure-type) (oclosure-type val))) - (format (propertize "#<oclosure %s>" 'face 'marginalia-function) - (and (fboundp 'oclosure-type) (oclosure-type val)))) - ((pred byte-code-function-p) (propertize "#<byte-code-function>" 'face 'marginalia-function)) - ((and (pred functionp) (pred symbolp)) - ;; We are not consistent here, values are generally printed - ;; unquoted. But we make an exception for function symbols to visually - ;; distinguish them from symbols. I am not entirely happy with this, - ;; but we should not add quotation to every type. - (format (propertize "#'%s" 'face 'marginalia-function) val)) - ((pred recordp) (format (propertize "#<record %s>" 'face 'marginalia-value) (type-of val))) - ((pred symbolp) (propertize (symbol-name val) 'face 'marginalia-symbol)) - ((pred numberp) (propertize (number-to-string val) 'face 'marginalia-number)) - (_ (let ((print-escape-newlines t) - (print-escape-control-characters t) - ;;(print-escape-multibyte t) - (print-level 3) - (print-length marginalia-field-width)) - (propertize - (replace-regexp-in-string - ;; `print-escape-control-characters' does not escape Unicode control characters. - "[\x0-\x1F\x7f-\x9f\x061c\x200e\x200f\x202a-\x202e\x2066-\x2069]" - (lambda (x) (format "\\x%x" (string-to-char x))) - (prin1-to-string - (if (stringp val) - ;; Get rid of string properties to save some of the precious space - (substring-no-properties - val 0 - (min (length val) marginalia-field-width)) - val)) - 'fixedcase 'literal) - 'face - (cond - ((listp val) 'marginalia-list) - ((stringp val) 'marginalia-string) - (t 'marginalia-value)))))))))) - -(defun marginalia-annotate-variable (cand) - "Annotate variable CAND with its documentation string." - (when-let (sym (intern-soft cand)) - (marginalia--fields - ((marginalia--symbol-class sym) :face 'marginalia-type) - ((marginalia--variable-value sym) :truncate 0.5) - ((documentation-property sym 'variable-documentation) - :truncate 1.0 :face 'marginalia-documentation)))) - -(defun marginalia-annotate-environment-variable (cand) - "Annotate environment variable CAND with its current value." - (when-let (val (getenv cand)) - (marginalia--fields - (val :truncate 1.0 :face 'marginalia-value)))) - -(defun marginalia-annotate-face (cand) - "Annotate face CAND with its documentation string and face example." - (when-let (sym (intern-soft cand)) - (marginalia--fields - ;; HACK: Manual alignment to fix misalignment due to face - ((concat marginalia--pangram #(" " 0 1 (display (space :align-to center)))) - :face sym) - ((documentation-property sym 'face-documentation) - :truncate 1.0 :face 'marginalia-documentation)))) - -(defun marginalia-annotate-color (cand) - "Annotate face CAND with its documentation string and face example." - (when-let (rgb (color-name-to-rgb cand)) - (pcase-let* ((`(,r ,g ,b) rgb) - (`(,h ,s ,l) (apply #'color-rgb-to-hsl rgb)) - (cr (color-rgb-to-hex r 0 0)) - (cg (color-rgb-to-hex 0 g 0)) - (cb (color-rgb-to-hex 0 0 b)) - (ch (apply #'color-rgb-to-hex (color-hsl-to-rgb h 1 0.5))) - (cs (apply #'color-rgb-to-hex (color-hsl-to-rgb h s 0.5))) - (cl (apply #'color-rgb-to-hex (color-hsl-to-rgb 0 0 l)))) - (marginalia--fields - (" " :face `(:background ,(apply #'color-rgb-to-hex rgb))) - ((format - "%s%s%s %s" - (propertize "r" 'face `(:background ,cr :foreground ,(readable-foreground-color cr))) - (propertize "g" 'face `(:background ,cg :foreground ,(readable-foreground-color cg))) - (propertize "b" 'face `(:background ,cb :foreground ,(readable-foreground-color cb))) - (color-rgb-to-hex r g b 2))) - ((format - "%s%s%s %3s° %3s%% %3s%%" - (propertize "h" 'face `(:background ,ch :foreground ,(readable-foreground-color ch))) - (propertize "s" 'face `(:background ,cs :foreground ,(readable-foreground-color cs))) - (propertize "l" 'face `(:background ,cl :foreground ,(readable-foreground-color cl))) - (round (* 360 h)) - (round (* 100 s)) - (round (* 100 l)))))))) - -(defun marginalia-annotate-char (cand) - "Annotate character CAND with its general character category and character code." - (when-let (char (char-from-name cand t)) - (marginalia--fields - (:left char :format" (%c)" :face 'marginalia-char) - (char :format "%06X" :face 'marginalia-number) - ((char-code-property-description - 'general-category - (get-char-code-property char 'general-category)) - :width 30 :face 'marginalia-documentation)))) - -(defun marginalia-annotate-minor-mode (cand) - "Annotate minor-mode CAND with status and documentation string." - (let* ((sym (intern-soft cand)) - (message-log-max nil) - (mode (if (and sym (boundp sym)) - sym - (lookup-minor-mode-from-indicator cand))) - (lighter (cdr (assq mode minor-mode-alist))) - (lighter-str (and lighter (string-trim (format-mode-line (cons t lighter)))))) - (marginalia--fields - ((if (and (boundp mode) (symbol-value mode)) - (propertize "On" 'face 'marginalia-on) - (propertize "Off" 'face 'marginalia-off)) :width 3) - ((if (local-variable-if-set-p mode) "Local" "Global") :width 6 :face 'marginalia-type) - (lighter-str :width 20 :face 'marginalia-lighter) - ((marginalia--function-doc mode) - :truncate 1.0 :face 'marginalia-documentation)))) - -(defun marginalia-annotate-package (cand) - "Annotate package CAND with its description summary." - (when-let ((pkg-alist (bound-and-true-p package-alist)) - (name (replace-regexp-in-string "-[0-9\\.-]+\\'" "" cand)) - (pkg (intern-soft name)) - (desc (or (unless (equal name cand) - (cl-loop with version = (substring cand (1+ (length name))) - for d in (alist-get pkg pkg-alist) - if (equal (package-version-join (package-desc-version d)) version) - return d)) - ;; taken from `describe-package-1' - (car (alist-get pkg pkg-alist)) - (if-let (built-in (assq pkg package--builtins)) - (package--from-builtin built-in) - (car (alist-get pkg package-archive-contents)))))) - (marginalia--fields - ((package-version-join (package-desc-version desc)) :truncate 16 :face 'marginalia-version) - ((cond - ((package-desc-archive desc) (propertize (package-desc-archive desc) 'face 'marginalia-archive)) - (t (propertize (or (package-desc-status desc) "orphan") 'face 'marginalia-installed))) :truncate 12) - ((package-desc-summary desc) :truncate 1.0 :face 'marginalia-documentation)))) - -(defun marginalia--bookmark-type (bm) - "Return bookmark type string of BM. -The string is transformed according to `marginalia--bookmark-type-transforms'." - (let ((handler (or (bookmark-prop-get bm 'handler) 'bookmark-default-handler))) - (and - ;; Some libraries use lambda handlers instead of symbols. For - ;; example the function `xwidget-webkit-bookmark-make-record' is - ;; affected. I consider this bad style since then the lambda is - ;; persisted. - (symbolp handler) - (or (get handler 'bookmark-handler-type) - (let ((str (symbol-name handler)) - case-fold-search) - (dolist (transformer marginalia--bookmark-type-transforms str) - (when (string-match-p (car transformer) str) - (setq str - (if (stringp (cdr transformer)) - (replace-regexp-in-string (car transformer) (cdr transformer) str) - (funcall (cdr transformer) str)))))))))) - -(defun marginalia-annotate-bookmark (cand) - "Annotate bookmark CAND with its file name and front context string." - (when-let ((bm (assoc cand (bound-and-true-p bookmark-alist)))) - (marginalia--fields - ((marginalia--bookmark-type bm) :width 10 :face 'marginalia-type) - ((or (bookmark-prop-get bm 'filename) - (bookmark-prop-get bm 'location)) - :truncate (if (bookmark-prop-get bm 'filename) -0.5 0.5) - :face 'marginalia-file-name) - ((let ((front (or (bookmark-prop-get bm 'front-context-string) "")) - (rear (or (bookmark-prop-get bm 'rear-context-string) ""))) - (unless (and (string-blank-p front) (string-blank-p rear)) - (string-clean-whitespace - (concat front (marginalia--ellipsis) rear)))) - :truncate 0.5 :face 'marginalia-documentation)))) - -(defun marginalia-annotate-customize-group (cand) - "Annotate customization group CAND with its documentation string." - (marginalia--documentation (documentation-property (intern cand) 'group-documentation))) - -(defun marginalia-annotate-input-method (cand) - "Annotate input method CAND with its description." - (marginalia--documentation (nth 4 (assoc cand input-method-alist)))) - -(defun marginalia-annotate-charset (cand) - "Annotate charset CAND with its description." - (marginalia--documentation (charset-description (intern cand)))) - -(defun marginalia-annotate-coding-system (cand) - "Annotate coding system CAND with its description." - (marginalia--documentation (coding-system-doc-string (intern cand)))) - -(defun marginalia--buffer-status (buffer) - "Return the status of BUFFER as a string." - (format-mode-line '((:propertize "%1*%1+%1@" face marginalia-modified) - marginalia-separator - (7 (:propertize "%I" face marginalia-size)) - marginalia-separator - ;; InactiveMinibuffer has 18 letters, but there are longer names. - ;; For example Org-Agenda produces very long mode names. - ;; Therefore we have to truncate. - (20 (-20 (:propertize mode-name face marginalia-mode)))) - nil nil buffer)) - -(defun marginalia--buffer-file (buffer) - "Return the file or process name of BUFFER." - (if-let (proc (get-buffer-process buffer)) - (format "(%s %s) %s" - proc (process-status proc) - (abbreviate-file-name (buffer-local-value 'default-directory buffer))) - (abbreviate-file-name - (or (cond - ;; see ibuffer-buffer-file-name - ((buffer-file-name buffer)) - ((when-let (dir (and (local-variable-p 'dired-directory buffer) - (buffer-local-value 'dired-directory buffer))) - (expand-file-name (if (stringp dir) dir (car dir)) - (buffer-local-value 'default-directory buffer)))) - ((local-variable-p 'list-buffers-directory buffer) - (buffer-local-value 'list-buffers-directory buffer))) - "")))) - -(defun marginalia-annotate-buffer (cand) - "Annotate buffer CAND with modification status, file name and major mode." - (when-let ((buffer (get-buffer cand))) - (if (buffer-live-p buffer) - (marginalia--fields - ((marginalia--buffer-status buffer)) - ((marginalia--buffer-file buffer) - :truncate -0.5 :face 'marginalia-file-name)) - (marginalia--fields ("(dead buffer)" :face 'error))))) - -(defun marginalia--full-candidate (cand) - "Return completion candidate CAND in full. -For some completion tables, the completion candidates offered are -meant to be only a part of the full minibuffer contents. For -example, during file name completion the candidates are one path -component of a full file path." - (if-let (win (active-minibuffer-window)) - (with-current-buffer (window-buffer win) - (concat (let ((end (minibuffer-prompt-end))) - (buffer-substring-no-properties - end (+ end marginalia--base-position))) - cand)) - ;; no minibuffer is active, trust that cand already conveys all - ;; necessary information (there's not much else we can do) - cand)) - -(defun marginalia--remote-file-p (file) - "Return non-nil if FILE is remote. -The return value is a string describing the remote location, -e.g., the protocol." - (save-match-data - (setq file (substitute-in-file-name file)) - (cl-loop for r in marginalia-remote-file-regexps - if (string-match r file) - return (or (match-string 1 file) "remote")))) - -(defun marginalia--annotate-local-file (cand) - "Annotate local file CAND." - (marginalia--in-minibuffer - (when-let (attrs (ignore-errors - ;; may throw permission denied errors - (file-attributes (substitute-in-file-name - (marginalia--full-candidate cand)) - 'integer))) - ;; HACK: Format differently accordingly to alignment, since the file owner - ;; is usually not displayed. Otherwise we will see an excessive amount of - ;; whitespace in front of the file permissions. Furthermore the alignment - ;; in `consult-buffer' will look ugly. Find a better solution! - (if (eq marginalia-align 'right) - (marginalia--fields - ;; File owner at the left - ((marginalia--file-owner attrs) :face 'marginalia-file-owner) - ((marginalia--file-modes attrs)) - ((marginalia--file-size attrs) :face 'marginalia-size :width -7) - ((marginalia--time (file-attribute-modification-time attrs)) - :face 'marginalia-date :width -12)) - (marginalia--fields - ((marginalia--file-modes attrs)) - ((marginalia--file-size attrs) :face 'marginalia-size :width -7) - ((marginalia--time (file-attribute-modification-time attrs)) - :face 'marginalia-date :width -12) - ;; File owner at the right - ((marginalia--file-owner attrs) :face 'marginalia-file-owner)))))) - -(defun marginalia-annotate-file (cand) - "Annotate file CAND with its size, modification time and other attributes. -These annotations are skipped for remote paths." - (if-let (remote (or (marginalia--remote-file-p cand) - (when-let (win (active-minibuffer-window)) - (with-current-buffer (window-buffer win) - (marginalia--remote-file-p (minibuffer-contents-no-properties)))))) - (marginalia--fields (remote :format "*%s*" :face 'marginalia-documentation)) - (marginalia--annotate-local-file cand))) - -(defun marginalia--file-owner (attrs) - "Return file owner given ATTRS." - (let ((uid (file-attribute-user-id attrs)) - (gid (file-attribute-group-id attrs))) - (when (or (/= (user-uid) uid) (/= (group-gid) gid)) - (format "%s:%s" - (or (user-login-name uid) uid) - (or (group-name gid) gid))))) - -(defun marginalia--file-size (attrs) - "Return formatted file size given ATTRS." - (propertize (file-size-human-readable (file-attribute-size attrs)) - 'help-echo (number-to-string (file-attribute-size attrs)))) - -(defun marginalia--file-modes (attrs) - "Return fontified file modes given the ATTRS." - ;; Without caching this can a be significant portion of the time - ;; `marginalia-annotate-file' takes to execute. Caching improves performance - ;; by about a factor of 20. - (setq attrs (file-attribute-modes attrs)) - (or (car (member attrs marginalia--fontified-file-modes)) - (progn - (setq attrs (substring attrs)) ;; copy because attrs is about to be modified - (dotimes (i (length attrs)) - (put-text-property - i (1+ i) 'face - (pcase (aref attrs i) - (?- 'marginalia-file-priv-no) - (?d 'marginalia-file-priv-dir) - (?l 'marginalia-file-priv-link) - (?r 'marginalia-file-priv-read) - (?w 'marginalia-file-priv-write) - (?x 'marginalia-file-priv-exec) - ((or ?s ?S ?t ?T) 'marginalia-file-priv-other) - (_ 'marginalia-file-priv-rare)) - attrs)) - (push attrs marginalia--fontified-file-modes) - attrs))) - -(defconst marginalia--time-relative - `((100 "sec" 1) - (,(* 60 100) "min" 60.0) - (,(* 3600 30) "hour" 3600.0) - (,(* 3600 24 400) "day" ,(* 3600.0 24.0)) - (nil "year" ,(* 365.25 24 3600))) - "Formatting used by the function `marginalia--time-relative'.") - -;; Taken from `seconds-to-string'. -(defun marginalia--time-relative (time) - "Format TIME as a relative age." - (setq time (max 0 (float-time (time-since time)))) - (let ((sts marginalia--time-relative) here) - (while (and (car (setq here (pop sts))) (<= (car here) time))) - (setq time (round time (caddr here))) - (format "%s %s%s ago" time (cadr here) (if (= time 1) "" "s")))) - -(defun marginalia--time-absolute (time) - "Format TIME as an absolute age." - (let ((system-time-locale "C")) - (format-time-string - (if (> (decoded-time-year (decode-time (current-time))) - (decoded-time-year (decode-time time))) - " %Y %b %d" - "%b %d %H:%M") - time))) - -(defun marginalia--time (time) - "Format file age TIME, suitably for use in annotations." - (propertize - (if (< (float-time (time-since time)) marginalia-max-relative-age) - (marginalia--time-relative time) - (marginalia--time-absolute time)) - 'help-echo (format-time-string "%Y-%m-%d %T" time))) - -(defvar-local marginalia--project-root 'unset) -(defun marginalia--project-root () - "Return project root." - (marginalia--in-minibuffer - (when (eq marginalia--project-root 'unset) - (setq marginalia--project-root - (or (let ((prompt (minibuffer-prompt)) - case-fold-search) - (and (string-match - "\\`\\(?:Dired\\|Find file\\) in \\(.*\\): \\'" - prompt) - (match-string 1 prompt))) - (when-let (proj (project-current)) - (cond - ((fboundp 'project-root) (project-root proj)) - ((fboundp 'project-roots) (car (project-roots proj)))))))) - marginalia--project-root)) - -(defun marginalia-annotate-project-file (cand) - "Annotate file CAND with its size, modification time and other attributes." - ;; Absolute project directories also report project-file category - (if (file-name-absolute-p cand) - (marginalia-annotate-file cand) - (when-let (root (marginalia--project-root)) - (marginalia-annotate-file (expand-file-name cand root))))) - -(defvar-local marginalia--library-cache nil) -(defun marginalia--library-cache () - "Return hash table from library name to library file." - (marginalia--in-minibuffer - ;; `locate-file' and `locate-library' are bottlenecks for the - ;; annotator. Therefore we compute all the library paths first. - (unless marginalia--library-cache - (setq marginalia--library-cache (make-hash-table :test #'equal)) - (dolist (dir (delete-dups - (reverse ;; Reverse because of shadowing - (append load-path (custom-theme--load-path))))) ;; Include themes - (dolist (file (ignore-errors - (directory-files dir 'full - "\\.el\\(?:\\.gz\\)?\\'"))) - (puthash (marginalia--library-name file) - file marginalia--library-cache)))) - marginalia--library-cache)) - -(defun marginalia--library-name (file) - "Get name of library FILE." - (replace-regexp-in-string "\\(\\.gz\\|\\.elc?\\)+\\'" "" - (file-name-nondirectory file))) - -(defun marginalia--library-doc (file) - "Return library documentation string for FILE." - (let ((doc (get-text-property 0 'marginalia--library-doc file))) - (unless doc - ;; Extract documentation string. We cannot use `lm-summary' here, - ;; since it decompresses the whole file, which is slower. - (setq doc (or (ignore-errors - (let ((shell-file-name "sh") - (shell-command-switch "-c")) - (shell-command-to-string - (format (if (string-suffix-p ".gz" file) - "gzip -c -q -d %s | head -n1" - "head -n1 %s") - (shell-quote-argument file))))) - "")) - (cond - ((string-match "\\`(define-package\\s-+\"\\([^\"]+\\)\"" doc) - (setq doc (format "Generated package description from %s.el" - (match-string 1 doc)))) - ((string-match "\\`;+\\s-*" doc) - (setq doc (substring doc (match-end 0))) - (when (string-match "\\`[^ \t]+\\s-+-+\\s-+" doc) - (setq doc (substring doc (match-end 0)))) - (when (string-match "\\s-*-\\*-" doc) - (setq doc (substring doc 0 (match-beginning 0))))) - (t (setq doc ""))) - ;; Add the documentation string to the cache - (put-text-property 0 1 'marginalia--library-doc doc file)) - doc)) - -(defun marginalia-annotate-theme (cand) - "Annotate theme CAND with documentation and path." - (marginalia-annotate-library (concat cand "-theme"))) - -(defun marginalia-annotate-library (cand) - "Annotate library CAND with documentation and path." - (setq cand (marginalia--library-name cand)) - (when-let (file (gethash cand (marginalia--library-cache))) - (marginalia--fields - ;; Display if the corresponding feature is loaded. - ;; feature/=library file, but better than nothing. - ((when-let (sym (intern-soft cand)) - (when (memq sym features) - (propertize "Loaded" 'face 'marginalia-on))) - :width 8) - ((marginalia--library-doc file) - :truncate 1.0 :face 'marginalia-documentation) - ((abbreviate-file-name (file-name-directory file)) - :truncate -0.5 :face 'marginalia-file-name)))) - -(defun marginalia-annotate-tab (cand) - "Annotate named tab CAND with tab index, window and buffer information." - (when-let ((tabs (funcall tab-bar-tabs-function)) - (index (seq-position - tabs nil - (lambda (tab _) (equal (alist-get 'name tab) cand))))) - (let* ((tab (nth index tabs)) - (ws (alist-get 'ws tab)) - (bufs (window-state-buffers ws))) - ;; When the buffer key is present in the window state it is added in front - ;; of the window buffer list and gets duplicated. - (when (cadr (assq 'buffer ws)) (pop bufs)) - (marginalia--fields - (:left (1+ index) :format " (%s)" :face 'marginalia-key) - ((if (eq (car tab) 'current-tab) - (length (window-list nil 'no-minibuf)) - (length bufs)) - :format "win:%s" :face 'marginalia-size) - ((or (alist-get 'group tab) 'none) - :format "group:%s" :face 'marginalia-type :truncate 20) - ((if (eq (car tab) 'current-tab) - "(current tab)" - (string-join bufs " ")) - :face 'marginalia-documentation))))) - -(defun marginalia-classify-by-command-name () - "Lookup category for current command." - (and marginalia--command - (or (alist-get marginalia--command marginalia-command-categories) - ;; The command can be an alias, e.g., `recentf' -> `recentf-open'. - (when-let ((chain (function-alias-p marginalia--command))) - (alist-get (car (last chain)) marginalia-command-categories))))) - -(defun marginalia-classify-original-category () - "Return original category reported by completion metadata." - ;; Use `alist-get' instead of `completion-metadata-get' to bypass our - ;; `marginalia--completion-metadata-get' advice! - (when-let (cat (alist-get 'category marginalia--metadata)) - ;; Ignore Emacs 28 symbol-help category in order to ensure that the - ;; categories are refined to our categories function and variable. - (and (not (eq cat 'symbol-help)) cat))) - -(defun marginalia-classify-symbol () - "Determine if currently completing symbols." - (when-let (mct minibuffer-completion-table) - (when (or (eq mct 'help--symbol-completion-table) - (obarrayp mct) - (and (not (functionp mct)) (consp mct) (symbolp (car mct)))) ; assume list of symbols - 'symbol))) - -(defun marginalia-classify-by-prompt () - "Determine category by matching regexps against the minibuffer prompt. -This runs through the `marginalia-prompt-categories' alist -looking for a regexp that matches the prompt." - (when-let (prompt (minibuffer-prompt)) - (setq prompt - (replace-regexp-in-string "(.*?default.*?)\\|\\[.*?\\]" "" prompt)) - (cl-loop with case-fold-search = t - for (regexp . category) in marginalia-prompt-categories - when (string-match-p regexp prompt) - return category))) - -(defun marginalia--cache-reset (&rest _) - "Reset the cache." - (setq marginalia--cache (and marginalia--cache (> marginalia--cache-size 0) - (cons nil (make-hash-table :test #'equal - :size marginalia--cache-size))))) - -(defun marginalia--cached (cache fun key) - "Cached application of function FUN with KEY. -The CACHE keeps around the last `marginalia--cache-size' computed -annotations. The cache is mainly useful when scrolling in -completion UIs like Vertico or Icomplete." - (if cache - (let ((ht (cdr cache))) - (or (gethash key ht) - (let ((val (funcall fun key))) - (push key (car cache)) - (puthash key val ht) - (when (>= (hash-table-count ht) marginalia--cache-size) - (let ((end (last (car cache) 2))) - (remhash (cadr end) ht) - (setcdr end nil))) - val))) - (funcall fun key))) - -(defun marginalia--align (cands) - "Align annotations of CANDS according to `marginalia-align'." - (cl-loop - for (cand . ann) in cands do - (when-let (align (text-property-any 0 (length ann) 'marginalia--align t ann)) - (setq marginalia--cand-width-max - (max marginalia--cand-width-max - (* (ceiling (+ (string-width cand) - (compat-call string-width ann 0 align)) - marginalia--cand-width-step) - marginalia--cand-width-step))))) - (cl-loop - for (cand . ann) in cands collect - (progn - (when-let (align (text-property-any 0 (length ann) 'marginalia--align t ann)) - (put-text-property - align (1+ align) 'display - `(space :align-to - ,(pcase-exhaustive marginalia-align - ('center `(+ center ,marginalia-align-offset)) - ('left `(+ left ,(+ marginalia-align-offset marginalia--cand-width-max))) - ('right `(+ right ,(+ marginalia-align-offset 1 - (- (compat-call string-width ann 0 align) - (string-width ann))))))) - ann)) - (list cand "" ann)))) - -(defun marginalia--affixate (metadata annotator cands) - "Affixate CANDS given METADATA and Marginalia ANNOTATOR." - ;; Compute minimum width of windows, which display the minibuffer, including - ;; the miniwindow. In general the computed width corresponds to the full - ;; frame width, since the miniwindow spans the full frame. For example - ;; `vertico-buffer' displays the minibuffer in a separate window. Similarly, - ;; we could detect other types of completion buffers, e.g., Embark Collect or - ;; the default completion buffer, and compute smaller widths. - (let* ((width (cl-loop for win in (get-buffer-window-list) minimize (window-width win))) - (marginalia-field-width (min (/ width 2) marginalia-field-width)) - (marginalia--metadata metadata) - (cache marginalia--cache)) - (marginalia--align - ;; Run the annotators in the original window. `with-selected-window' - ;; is necessary because of `lookup-minor-mode-from-indicator'. - ;; Otherwise it would suffice to only change the current buffer. We - ;; need the `selected-window' fallback for Embark Occur. - (with-selected-window (or (minibuffer-selected-window) (selected-window)) - (cl-loop for cand in cands collect - (let ((ann (or (marginalia--cached cache annotator cand) ""))) - (cons cand (if (string-blank-p ann) "" ann)))))))) - -(defun marginalia--completion-metadata-get (metadata prop) - "Meant as :before-until advice for `completion-metadata-get'. -METADATA is the metadata. -PROP is the property which is looked up." - (pcase prop - ('annotation-function - ;; We do want the advice triggered for `completion-metadata-get'. - (when-let ((cat (completion-metadata-get metadata 'category)) - (annotator (marginalia--annotator cat))) - (lambda (cand) - (let ((ann (caddar (marginalia--affixate metadata annotator (list cand))))) - (and (not (equal ann "")) ann))))) - ('affixation-function - ;; We do want the advice triggered for `completion-metadata-get'. - (when-let ((cat (completion-metadata-get metadata 'category)) - (annotator (marginalia--annotator cat))) - (apply-partially #'marginalia--affixate metadata annotator))) - ('category - ;; Find the completion category by trying each of our classifiers. - ;; Store the metadata for `marginalia-classify-original-category'. - (let ((marginalia--metadata metadata)) - (run-hook-with-args-until-success 'marginalia-classifiers))))) - -(defun marginalia--minibuffer-setup () - "Setup the minibuffer for Marginalia. -Remember `this-command' for `marginalia-classify-by-command-name'." - (setq marginalia--cache t marginalia--command this-command) - ;; Reset cache if window size changes, recompute alignment - (add-hook 'window-state-change-hook #'marginalia--cache-reset nil 'local) - (marginalia--cache-reset)) - -(defun marginalia--base-position (completions) - "Record the base position of COMPLETIONS." - ;; As a small optimization we track the base position only for file - ;; completions, since `marginalia--full-candidate' is currently used only by - ;; the file annotation function. - (when minibuffer-completing-file-name - (let ((base (or (cdr (last completions)) 0))) - (unless (= marginalia--base-position base) - (marginalia--cache-reset) - (setq marginalia--base-position base - marginalia--cand-width-max (default-value 'marginalia--cand-width-max))))) - completions) - -;;;###autoload -(define-minor-mode marginalia-mode - "Annotate completion candidates with richer information." - :global t :group 'marginalia - (if marginalia-mode - (progn - ;; Remember `this-command' in order to select the annotation function. - (add-hook 'minibuffer-setup-hook #'marginalia--minibuffer-setup) - ;; Replace the metadata function. - (advice-add #'completion-metadata-get :before-until #'marginalia--completion-metadata-get) - ;; Record completion base position, for `marginalia--full-candidate' - (advice-add #'completion-all-completions :filter-return #'marginalia--base-position)) - (advice-remove #'completion-all-completions #'marginalia--base-position) - (advice-remove #'completion-metadata-get #'marginalia--completion-metadata-get) - (remove-hook 'minibuffer-setup-hook #'marginalia--minibuffer-setup))) - -;;;###autoload -(defun marginalia-cycle () - "Cycle between annotators in `marginalia-annotator-registry'." - (interactive) - (with-current-buffer (window-buffer - (or (active-minibuffer-window) - (user-error "Marginalia: No active minibuffer"))) - (let* ((end (minibuffer-prompt-end)) - (pt (max 0 (- (point) end))) - (metadata (completion-metadata (buffer-substring-no-properties end (+ end pt)) - minibuffer-completion-table - minibuffer-completion-predicate)) - (cat (or (completion-metadata-get metadata 'category) - (user-error "Marginalia: Unknown completion category"))) - (ann (or (assq cat marginalia-annotator-registry) - (user-error "Marginalia: No annotators found for category `%s'" cat)))) - (marginalia--cache-reset) - (setcdr ann (append (cddr ann) (list (cadr ann)))) - ;; When the builtin annotator is selected and no builtin function is - ;; available, skip to the next annotator. Note that we cannot use - ;; `completion-metadata-get' to access the metadata since we must - ;; bypass the `marginalia--completion-metadata-get' advice. - (when (and (eq (cadr ann) 'builtin) - (not (assq 'annotation-function metadata)) - (not (assq 'affixation-function metadata)) - (not (plist-get completion-extra-properties :annotation-function)) - (not (plist-get completion-extra-properties :affixation-function))) - (setcdr ann (append (cddr ann) (list (cadr ann))))) - (message "Marginalia: Use annotator `%s' for category `%s'" (cadr ann) (car ann))))) - -;; Emacs 28: Only show `marginalia-cycle' in M-x in recursive minibuffers -(put #'marginalia-cycle 'completion-predicate - (lambda (&rest _) (> (minibuffer-depth) 1))) - -(provide 'marginalia) -;;; marginalia.el ends here diff --git a/emacs/elpa/marginalia-20240404.451/marginalia.elc b/emacs/elpa/marginalia-20240404.451/marginalia.elc Binary files differ. diff --git a/emacs/elpa/marginalia-20240404.451/marginalia-autoloads.el b/emacs/elpa/marginalia-20240523.1240/marginalia-autoloads.el diff --git a/emacs/elpa/marginalia-20240523.1240/marginalia-pkg.el b/emacs/elpa/marginalia-20240523.1240/marginalia-pkg.el @@ -0,0 +1,15 @@ +(define-package "marginalia" "20240523.1240" "Enrich existing commands with completion annotations" + '((emacs "27.1") + (compat "29.1.4.4")) + :commit "da72da4622c7b38741e6968678028f7e0564816c" :authors + '(("Omar Antolín Camarena <omar@matem.unam.mx>, Daniel Mendler" . "mail@daniel-mendler.de")) + :maintainers + '(("Omar Antolín Camarena <omar@matem.unam.mx>, Daniel Mendler" . "mail@daniel-mendler.de")) + :maintainer + '("Omar Antolín Camarena <omar@matem.unam.mx>, Daniel Mendler" . "mail@daniel-mendler.de") + :keywords + '("docs" "help" "matching" "completion") + :url "https://github.com/minad/marginalia") +;; Local Variables: +;; no-byte-compile: t +;; End: diff --git a/emacs/elpa/marginalia-20240523.1240/marginalia.el b/emacs/elpa/marginalia-20240523.1240/marginalia.el @@ -0,0 +1,1363 @@ +;;; marginalia.el --- Enrich existing commands with completion annotations -*- lexical-binding: t -*- + +;; Copyright (C) 2021-2024 Free Software Foundation, Inc. + +;; Author: Omar Antolín Camarena <omar@matem.unam.mx>, Daniel Mendler <mail@daniel-mendler.de> +;; Maintainer: Omar Antolín Camarena <omar@matem.unam.mx>, Daniel Mendler <mail@daniel-mendler.de> +;; Created: 2020 +;; Version: 1.6 +;; Package-Requires: ((emacs "27.1") (compat "29.1.4.4")) +;; Homepage: https://github.com/minad/marginalia +;; Keywords: docs, help, matching, completion + +;; This file is part of GNU Emacs. + +;; 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 <https://www.gnu.org/licenses/>. + +;;; Commentary: + +;; Enrich existing commands with completion annotations + +;;; Code: + +(require 'compat) +(eval-when-compile + (require 'subr-x) + (require 'cl-lib)) + +;;;; Customization + +(defgroup marginalia nil + "Enrich existing commands with completion annotations." + :link '(info-link :tag "Info Manual" "(marginalia)") + :link '(url-link :tag "Homepage" "https://github.com/minad/marginalia") + :link '(emacs-library-link :tag "Library Source" "marginalia.el") + :group 'help + :group 'docs + :group 'minibuffer + :prefix "marginalia-") + +(defcustom marginalia-field-width 80 + "Maximum truncation width of annotation fields. + +This value is adjusted depending on the `window-width'." + :type 'natnum) + +(defcustom marginalia-separator " " + "Annotation field separator." + :type 'string) + +(defcustom marginalia-align 'left + "Alignment of the annotations." + :type '(choice (const :tag "Left" left) + (const :tag "Center" center) + (const :tag "Right" right))) + +(defcustom marginalia-align-offset 0 + "Additional offset added to the alignment." + :type 'natnum) + +(defcustom marginalia-max-relative-age (* 60 60 24 14) + "Maximum relative age in seconds displayed by the file annotator. + +Set to `most-positive-fixnum' to always use a relative age, or 0 to never show +a relative age." + :type 'natnum) + +(defcustom marginalia-remote-file-regexps + '("\\`/\\([^/|:]+\\):") ;; Tramp path + "List of remote file regexps where the files should not be annotated. + +The first match group is displayed instead of the detailed file +attribute information. For Tramp paths, the protocol is +displayed instead." + :type '(repeat regexp)) + +(defcustom marginalia-annotator-registry + (mapcar + (lambda (x) (append x '(builtin none))) + `((command ,#'marginalia-annotate-command ,#'marginalia-annotate-binding) + (embark-keybinding ,#'marginalia-annotate-embark-keybinding) + (customize-group ,#'marginalia-annotate-customize-group) + (variable ,#'marginalia-annotate-variable) + (function ,#'marginalia-annotate-function) + (face ,#'marginalia-annotate-face) + (color ,#'marginalia-annotate-color) + (unicode-name ,#'marginalia-annotate-char) + (minor-mode ,#'marginalia-annotate-minor-mode) + (symbol ,#'marginalia-annotate-symbol) + (environment-variable ,#'marginalia-annotate-environment-variable) + (input-method ,#'marginalia-annotate-input-method) + (coding-system ,#'marginalia-annotate-coding-system) + (charset ,#'marginalia-annotate-charset) + (package ,#'marginalia-annotate-package) + (imenu ,#'marginalia-annotate-imenu) + (bookmark ,#'marginalia-annotate-bookmark) + (file ,#'marginalia-annotate-file) + (project-file ,#'marginalia-annotate-project-file) + (buffer ,#'marginalia-annotate-buffer) + (library ,#'marginalia-annotate-library) + (theme ,#'marginalia-annotate-theme) + (tab ,#'marginalia-annotate-tab) + (multi-category ,#'marginalia-annotate-multi-category))) + "Annotator function registry. +Associates completion categories with annotation functions. +Each annotation function must return a string, +which is appended to the completion candidate." + :type '(alist :key-type symbol :value-type (repeat symbol))) + +(defcustom marginalia-classifiers + (list #'marginalia-classify-by-command-name + #'marginalia-classify-original-category + #'marginalia-classify-by-prompt + #'marginalia-classify-symbol) + "List of functions to determine current completion category. +Each function should take no arguments and return a symbol +indicating the category, or nil to indicate it could not +determine it." + :type 'hook) + +(defcustom marginalia-prompt-categories + '(("\\<customize group\\>" . customize-group) + ("\\<M-x\\>" . command) + ("\\<package\\>" . package) + ("\\<bookmark\\>" . bookmark) + ("\\<color\\>" . color) + ("\\<face\\>" . face) + ("\\<environment variable\\>" . environment-variable) + ("\\<function\\|hook to remove\\>" . function) + ("\\<variable\\>" . variable) + ("\\<input method\\>" . input-method) + ("\\<charset\\>" . charset) + ("\\<coding system\\>" . coding-system) + ("\\<minor mode\\>" . minor-mode) + ("\\<kill-ring\\>" . kill-ring) + ("\\<tab by name\\>" . tab) + ("\\<library\\>" . library) + ("\\<theme\\>" . theme)) + "Associates regexps to match against minibuffer prompts with categories. +The prompts are matched case-insensitively." + :type '(alist :key-type regexp :value-type symbol)) + +(defcustom marginalia-censor-variables + '("pass\\|auth-source-netrc-cache\\|auth-source-.*-nonce\\|api-?key") + "The value of variables matching any of these regular expressions is not shown. +This configuration variable is useful to hide variables which may +hold sensitive data, e.g., passwords. The variable names are +matched case-sensitively." + :type '(repeat (choice symbol regexp))) + +(defcustom marginalia-command-categories + '((imenu . imenu) + (recentf-open . file) + (where-is . command)) + "Associate commands with a completion category. +The value of `this-command' is used as key for the lookup." + :type '(alist :key-type symbol :value-type symbol)) + +(defgroup marginalia-faces nil + "Faces used by `marginalia-mode'." + :group 'marginalia + :group 'faces) + +(defface marginalia-key + '((t :inherit font-lock-keyword-face)) + "Face used to highlight keys.") + +(defface marginalia-type + '((t :inherit marginalia-key)) + "Face used to highlight types.") + +(defface marginalia-char + '((t :inherit marginalia-key)) + "Face used to highlight character annotations.") + +(defface marginalia-lighter + '((t :inherit marginalia-size)) + "Face used to highlight minor mode lighters.") + +(defface marginalia-on + '((t :inherit success)) + "Face used to signal enabled modes.") + +(defface marginalia-off + '((t :inherit error)) + "Face used to signal disabled modes.") + +(defface marginalia-documentation + '((t :inherit completions-annotations)) + "Face used to highlight documentation strings.") + +(defface marginalia-value + '((t :inherit marginalia-key)) + "Face used to highlight general variable values.") + +(defface marginalia-null + '((t :inherit font-lock-comment-face)) + "Face used to highlight null or unbound variable values.") + +(defface marginalia-true + '((t :inherit font-lock-builtin-face)) + "Face used to highlight true variable values.") + +(defface marginalia-function + '((t :inherit font-lock-function-name-face)) + "Face used to highlight function symbols.") + +(defface marginalia-symbol + '((t :inherit font-lock-type-face)) + "Face used to highlight general symbols.") + +(defface marginalia-list + '((t :inherit font-lock-constant-face)) + "Face used to highlight list expressions.") + +(defface marginalia-mode + '((t :inherit marginalia-key)) + "Face used to highlight buffer major modes.") + +(defface marginalia-date + '((t :inherit marginalia-key)) + "Face used to highlight dates.") + +(defface marginalia-version + '((t :inherit marginalia-number)) + "Face used to highlight package versions.") + +(defface marginalia-archive + '((t :inherit warning)) + "Face used to highlight package archives.") + +(defface marginalia-installed + '((t :inherit success)) + "Face used to highlight the status of packages.") + +(defface marginalia-size + '((t :inherit marginalia-number)) + "Face used to highlight sizes.") + +(defface marginalia-number + '((t :inherit font-lock-constant-face)) + "Face used to highlight numeric values.") + +(defface marginalia-string + '((t :inherit font-lock-string-face)) + "Face used to highlight string values.") + +(defface marginalia-modified + '((t :inherit font-lock-negation-char-face)) + "Face used to highlight buffer modification indicators.") + +(defface marginalia-file-name + '((t :inherit marginalia-documentation)) + "Face used to highlight file names.") + +(defface marginalia-file-owner + '((t :inherit font-lock-preprocessor-face)) + "Face used to highlight file owner and group names.") + +(defface marginalia-file-priv-no + '((t :inherit shadow)) + "Face used to highlight the no file privilege attribute.") + +(defface marginalia-file-priv-dir + '((t :inherit font-lock-keyword-face)) + "Face used to highlight the dir file privilege attribute.") + +(defface marginalia-file-priv-link + '((t :inherit font-lock-keyword-face)) + "Face used to highlight the link file privilege attribute.") + +(defface marginalia-file-priv-read + '((t :inherit font-lock-type-face)) + "Face used to highlight the read file privilege attribute.") + +(defface marginalia-file-priv-write + '((t :inherit font-lock-builtin-face)) + "Face used to highlight the write file privilege attribute.") + +(defface marginalia-file-priv-exec + '((t :inherit font-lock-function-name-face)) + "Face used to highlight the exec file privilege attribute.") + +(defface marginalia-file-priv-other + '((t :inherit font-lock-constant-face)) + "Face used to highlight some other file privilege attribute.") + +(defface marginalia-file-priv-rare + '((t :inherit font-lock-variable-name-face)) + "Face used to highlight a rare file privilege attribute.") + +;;;; Pre-declarations for external packages + +(declare-function bookmark-prop-get "bookmark") + +(declare-function project-current "project") + +(defvar package--builtins) +(defvar package-archive-contents) +(declare-function package--from-builtin "package") +(declare-function package-desc-archive "package") +(declare-function package-desc-status "package") +(declare-function package-desc-summary "package") +(declare-function package-desc-version "package") +(declare-function package-version-join "package") + +(declare-function color-rgb-to-hex "color") +(declare-function color-rgb-to-hsl "color") +(declare-function color-hsl-to-rgb "color") + +;;;; Marginalia mode + +(defvar marginalia--pangram "Cwm fjord bank glyphs vext quiz.") + +(defvar marginalia--bookmark-type-transforms + (let ((words (regexp-opt '("handle" "handler" "jump" "bookmark")))) + `((,(format "-+%s-+" words) . "-") + (,(format "\\`%s-+" words) . "") + (,(format "-%s\\'" words) . "") + ("\\`default\\'" . "File") + (".*" . ,#'capitalize))) + "List of bookmark type transformers. +Relying on this mechanism is discouraged in favor of the +`bookmark-handler-type' property. The function names are matched +case-sensitively.") + +(defvar marginalia--cand-width-step 10 + "Round candidate width.") + +(defvar-local marginalia--cand-width-max 20 + "Maximum width of candidates.") + +(defvar marginalia--fontified-file-modes nil + "List of fontified file modes.") + +(defvar-local marginalia--cache nil + "The cache, pair of list and hashtable.") + +(defvar marginalia--cache-size 100 + "Size of the cache, set to 0 to disable the cache. +Disabling the cache is useful on non-incremental UIs like default completion or +for performance profiling of the annotators.") + +(defvar-local marginalia--command nil + "Last command symbol saved in order to allow annotations.") + +(defvar-local marginalia--base-position 0 + "Last completion base position saved to get full file paths.") + +(defvar marginalia--metadata nil + "Completion metadata from the current completion.") + +(defvar marginalia--ellipsis nil) +(defun marginalia--ellipsis () + "Return ellipsis." + (with-memoization marginalia--ellipsis + (cond + ((bound-and-true-p truncate-string-ellipsis)) + ((char-displayable-p ?…) "…") + ("...")))) + +(defun marginalia--truncate (str width) + "Truncate string STR to WIDTH." + (when (floatp width) (setq width (round (* width marginalia-field-width)))) + (when-let (pos (string-search "\n" str)) + (setq str (substring str 0 pos))) + (let* ((face (and (not (equal str "")) + (get-text-property (1- (length str)) 'face str))) + (ell (if face + (propertize (marginalia--ellipsis) 'face face) + (marginalia--ellipsis))) + (trunc + (if (< width 0) + (nreverse (truncate-string-to-width (reverse str) (- width) 0 ?\s ell)) + (truncate-string-to-width str width 0 ?\s ell)))) + (unless (string-prefix-p str trunc) + (put-text-property 0 (length trunc) 'help-echo str trunc)) + trunc)) + +(cl-defmacro marginalia--field (field &key truncate face width format) + "Format FIELD as a string according to some options. +TRUNCATE is the truncation width. +WIDTH is the field width. +FORMAT is a format string. +FACE is the name of the face, with which the field should be propertized." + (setq field (if format `(format ,format ,field) `(or ,field ""))) + (when width (setq field `(format ,(format "%%%ds" (- width)) ,field))) + (when truncate (setq field `(marginalia--truncate ,field ,truncate))) + (when face (setq field `(propertize ,field 'face ,face))) + field) + +(defmacro marginalia--fields (&rest fields) + "Format annotation FIELDS as a string with separators in between." + (let ((left t)) + (cons 'concat + (mapcan + (lambda (field) + (if (not (eq (car field) :left)) + `(,@(when left (setq left nil) `(#(" " 0 1 (marginalia--align t)))) + marginalia-separator (marginalia--field ,@field)) + (unless left (error "Left fields must come first")) + `((marginalia--field ,@(cdr field))))) + fields)))) + +(defmacro marginalia--in-minibuffer (&rest body) + "Run BODY inside minibuffer if minibuffer is active. +Otherwise stay within current buffer." + (declare (indent 0)) + `(with-current-buffer (if-let (win (active-minibuffer-window)) + (window-buffer win) + (current-buffer)) + ,@body)) + +(defun marginalia--documentation (str) + "Format documentation string STR." + (when str + (marginalia--fields + (str :truncate 1.0 :face 'marginalia-documentation)))) + +(defun marginalia-annotate-binding (cand) + "Annotate command CAND with keybinding." + (when-let ((sym (intern-soft cand)) + (key (and (commandp sym) (where-is-internal sym nil 'first-only)))) + (format #(" (%s)" 1 5 (face marginalia-key)) (key-description key)))) + +(defun marginalia--annotator (cat) + "Return annotation function for category CAT." + (pcase (car (alist-get cat marginalia-annotator-registry)) + ('none #'ignore) + ('builtin nil) + (fun fun))) + +(defun marginalia-annotate-multi-category (cand) + "Annotate multi-category CAND with the buffer class." + (if-let ((multi (get-text-property 0 'multi-category cand)) + (annotate (marginalia--annotator (car multi)))) + ;; Use the Marginalia annotator corresponding to the multi category. + (funcall annotate (cdr multi)) + ;; Apply the original annotation function on the original candidate, if + ;; there is one. Use `alist-get' instead of `completion-metadata-get' to + ;; bypass our `marginalia--completion-metadata-get' advice! + (when-let (annotate (alist-get 'annotation-function marginalia--metadata)) + (funcall annotate cand)))) + +(defconst marginalia--advice-regexp + (rx bos + (1+ (seq (? "This function has ") + (or ":before" ":after" ":around" ":override" + ":before-while" ":before-until" ":after-while" + ":after-until" ":filter-args" ":filter-return") + " advice: " (0+ nonl) "\n")) + "\n") + "Regexp to match lines about advice in function documentation strings.") + +;; Taken from advice--make-docstring, is this robust? +(defun marginalia--advised (fun) + "Return t if function FUN is advised." + (let ((flist (indirect-function fun))) + (advice--p (if (eq 'macro (car-safe flist)) (cdr flist) flist)))) + +(defun marginalia--symbol-class (s) + "Return symbol class characters for symbol S. + +This function is an extension of `help--symbol-class'. It returns +more fine-grained and more detailed symbol information. + +Function: +f function +c command +C interactive-only command +m macro +F special-form +M module function +P primitive +g cl-generic +p pure +s side-effect-free +@ autoloaded +! advised +- obsolete +& alias + +Variable: +u custom (U modified compared to global value) +v variable +l local (L modified compared to default value) +- obsolete +& alias + +Other: +a face +t cl-type" + (let ((class + (append + (when (fboundp s) + (list + (cond + ((get s 'pure) '("p" . "pure")) + ((get s 'side-effect-free) '("s" . "side-effect-free"))) + (cond + ((commandp s) + (if (get s 'interactive-only) + '("C" . "interactive-only command") + '("c" . "command"))) + ((cl-generic-p s) '("g" . "cl-generic")) + ((macrop (symbol-function s)) '("m" . "macro")) + ((special-form-p (symbol-function s)) '("F" . "special-form")) + ((subr-primitive-p (symbol-function s)) '("P" . "primitive")) + ((module-function-p (symbol-function s)) '("M" . "module function")) + (t '("f" . "function"))) + (and (autoloadp (symbol-function s)) '("@" . "autoload")) + (and (marginalia--advised s) '("!" . "advised")) + (and (symbolp (symbol-function s)) + (cons "&" (format "alias for `%s'" (symbol-function s)))) + (and (get s 'byte-obsolete-info) '("-" . "obsolete")))) + (when (boundp s) + (list + (when (local-variable-if-set-p s) + (if (ignore-errors + (not (equal (symbol-value s) + (default-value s)))) + '("L" . "local, modified from global") + '("l" . "local, unmodified"))) + (if (custom-variable-p s) + (if (ignore-errors + (not (equal (symbol-value s) + (eval (car (get s 'standard-value)))))) + '("U" . "custom, modified from standard") + '("u" . "custom, unmodified")) + '("v" . "variable")) + (and (not (eq (ignore-errors (indirect-variable s)) s)) + (cons "&" (format "alias for `%s'" (ignore-errors (indirect-variable s))))) + (and (get s 'byte-obsolete-variable) '("-" . "obsolete")))) + (list + (and (facep s) '("a" . "face")) + (and (get s 'cl--class) '("t" . "cl-type")))))) ;; cl-find-class, cl--find-class + (setq class (delq nil class)) + (propertize + (format " %-6s" (mapconcat #'car class "")) + 'help-echo + (mapconcat (pcase-lambda (`(,x . ,y)) (concat x " " y)) class "\n")))) + +(defun marginalia--function-doc (sym) + "Documentation string of function SYM." + (when-let (str (ignore-errors (documentation sym))) + (save-match-data + (if (string-match marginalia--advice-regexp str) + (substring str (match-end 0)) + str)))) + +;; Derived from elisp-get-fnsym-args-string +(defun marginalia--function-args (sym) + "Return function arguments for SYM." + (let ((tmp)) + (elisp-function-argstring + (cond + ((listp (setq tmp (gethash (indirect-function sym) + advertised-signature-table t))) + tmp) + ((setq tmp (help-split-fundoc + (ignore-errors (documentation sym t)) + sym)) + (substitute-command-keys (car tmp))) + ((setq tmp (help-function-arglist sym)) + (and + (if (and (stringp tmp) + (string-search "Arg list not available" tmp)) + ;; A shorter text fits better into the + ;; limited Marginalia space. + "[autoload]" + tmp))))))) + +(defun marginalia-annotate-symbol (cand) + "Annotate symbol CAND with its documentation string." + (when-let (sym (intern-soft cand)) + (marginalia--fields + (:left (marginalia-annotate-binding cand)) + ((marginalia--symbol-class sym) :face 'marginalia-type) + ((if (fboundp sym) (marginalia--function-doc sym) + (cl-loop + for doc in '(variable-documentation + face-documentation + group-documentation) + thereis (ignore-errors (documentation-property sym doc)))) + :truncate 1.0 :face 'marginalia-documentation) + ((abbreviate-file-name (or (symbol-file sym) "")) + :truncate -0.5 :face 'marginalia-file-name)))) + +(defun marginalia-annotate-command (cand) + "Annotate command CAND with its documentation string. +Similar to `marginalia-annotate-symbol', but does not show symbol class." + (when-let (sym (intern-soft cand)) + (concat + (marginalia-annotate-binding cand) + (marginalia--documentation (marginalia--function-doc sym))))) + +(defun marginalia-annotate-embark-keybinding (cand) + "Annotate Embark keybinding CAND with its documentation string. +Similar to `marginalia-annotate-command', but does not show the +keybinding since CAND includes it." + (when-let (cmd (get-text-property 0 'embark-command cand)) + (marginalia--documentation (marginalia--function-doc cmd)))) + +(defun marginalia-annotate-imenu (cand) + "Annotate imenu CAND with its documentation string." + (when (derived-mode-p 'emacs-lisp-mode) + ;; Strip until the last whitespace in order to support flat imenu + (marginalia-annotate-symbol (replace-regexp-in-string "\\`.* " "" cand)))) + +(defun marginalia-annotate-function (cand) + "Annotate function CAND with its documentation string." + (when-let (sym (intern-soft cand)) + (when (fboundp sym) + (marginalia--fields + (:left (marginalia-annotate-binding cand)) + ((marginalia--symbol-class sym) :face 'marginalia-type) + ((marginalia--function-args sym) :face 'marginalia-value + :truncate 0.5) + ((marginalia--function-doc sym) :truncate 1.0 + :face 'marginalia-documentation))))) + +(defun marginalia--variable-value (sym) + "Return the variable value of SYM as string." + (cond + ((not (boundp sym)) + (propertize "#<unbound>" 'face 'marginalia-null)) + ((and marginalia-censor-variables + (let ((name (symbol-name sym)) + case-fold-search) + (cl-loop for r in marginalia-censor-variables + thereis (if (symbolp r) + (eq r sym) + (string-match-p r name))))) + (propertize "*****" + 'face 'marginalia-null + 'help-echo "Hidden due to `marginalia-censor-variables'")) + (t + (let ((val (symbol-value sym))) + (pcase val + ('nil (propertize "nil" 'face 'marginalia-null)) + ('t (propertize "t" 'face 'marginalia-true)) + ((pred keymapp) (propertize "#<keymap>" 'face 'marginalia-value)) + ((pred bool-vector-p) (propertize "#<bool-vector>" 'face 'marginalia-value)) + ((pred hash-table-p) (propertize "#<hash-table>" 'face 'marginalia-value)) + ((pred syntax-table-p) (propertize "#<syntax-table>" 'face 'marginalia-value)) + ;; Emacs bug#53988: abbrev-table-p throws an error + ((guard (or (and (eval-when-compile (< emacs-major-version 30)) + (vectorp val) (ignore-errors (abbrev-table-p val))) + (abbrev-table-p val))) + (propertize "#<abbrev-table>" 'face 'marginalia-value)) + ((pred char-table-p) (propertize "#<char-table>" 'face 'marginalia-value)) + ;; Emacs 29 comes with callable objects or object closures (OClosures) + ((guard (and (fboundp 'oclosure-type) (oclosure-type val))) + (format (propertize "#<oclosure %s>" 'face 'marginalia-function) + (and (fboundp 'oclosure-type) (oclosure-type val)))) + ((pred byte-code-function-p) (propertize "#<byte-code-function>" 'face 'marginalia-function)) + ((and (pred functionp) (pred symbolp)) + ;; We are not consistent here, values are generally printed + ;; unquoted. But we make an exception for function symbols to visually + ;; distinguish them from symbols. I am not entirely happy with this, + ;; but we should not add quotation to every type. + (format (propertize "#'%s" 'face 'marginalia-function) val)) + ((pred recordp) (format (propertize "#<record %s>" 'face 'marginalia-value) (type-of val))) + ((pred symbolp) (propertize (symbol-name val) 'face 'marginalia-symbol)) + ((pred numberp) (propertize (number-to-string val) 'face 'marginalia-number)) + (_ (let ((print-escape-newlines t) + (print-escape-control-characters t) + ;;(print-escape-multibyte t) + (print-level 3) + (print-length marginalia-field-width)) + (propertize + (replace-regexp-in-string + ;; `print-escape-control-characters' does not escape Unicode control characters. + "[\x0-\x1F\x7f-\x9f\x061c\x200e\x200f\x202a-\x202e\x2066-\x2069]" + (lambda (x) (format "\\x%x" (string-to-char x))) + (prin1-to-string + (if (stringp val) + ;; Get rid of string properties to save some of the precious space + (substring-no-properties + val 0 + (min (length val) marginalia-field-width)) + val)) + 'fixedcase 'literal) + 'face + (cond + ((listp val) 'marginalia-list) + ((stringp val) 'marginalia-string) + (t 'marginalia-value)))))))))) + +(defun marginalia-annotate-variable (cand) + "Annotate variable CAND with its documentation string." + (when-let (sym (intern-soft cand)) + (marginalia--fields + ((marginalia--symbol-class sym) :face 'marginalia-type) + ((marginalia--variable-value sym) :truncate 0.5) + ((documentation-property sym 'variable-documentation) + :truncate 1.0 :face 'marginalia-documentation)))) + +(defun marginalia-annotate-environment-variable (cand) + "Annotate environment variable CAND with its current value." + (when-let (val (getenv cand)) + (marginalia--fields + (val :truncate 1.0 :face 'marginalia-value)))) + +(defun marginalia-annotate-face (cand) + "Annotate face CAND with its documentation string and face example." + (when-let (sym (intern-soft cand)) + (marginalia--fields + ;; HACK: Manual alignment to fix misalignment due to face + ((concat marginalia--pangram #(" " 0 1 (display (space :align-to center)))) + :face sym) + ((documentation-property sym 'face-documentation) + :truncate 1.0 :face 'marginalia-documentation)))) + +(defun marginalia-annotate-color (cand) + "Annotate face CAND with its documentation string and face example." + (when-let (rgb (color-name-to-rgb cand)) + (pcase-let* ((`(,r ,g ,b) rgb) + (`(,h ,s ,l) (apply #'color-rgb-to-hsl rgb)) + (cr (color-rgb-to-hex r 0 0)) + (cg (color-rgb-to-hex 0 g 0)) + (cb (color-rgb-to-hex 0 0 b)) + (ch (apply #'color-rgb-to-hex (color-hsl-to-rgb h 1 0.5))) + (cs (apply #'color-rgb-to-hex (color-hsl-to-rgb h s 0.5))) + (cl (apply #'color-rgb-to-hex (color-hsl-to-rgb 0 0 l)))) + (marginalia--fields + (" " :face `(:background ,(apply #'color-rgb-to-hex rgb))) + ((format + "%s%s%s %s" + (propertize "r" 'face `(:background ,cr :foreground ,(readable-foreground-color cr))) + (propertize "g" 'face `(:background ,cg :foreground ,(readable-foreground-color cg))) + (propertize "b" 'face `(:background ,cb :foreground ,(readable-foreground-color cb))) + (color-rgb-to-hex r g b 2))) + ((format + "%s%s%s %3s° %3s%% %3s%%" + (propertize "h" 'face `(:background ,ch :foreground ,(readable-foreground-color ch))) + (propertize "s" 'face `(:background ,cs :foreground ,(readable-foreground-color cs))) + (propertize "l" 'face `(:background ,cl :foreground ,(readable-foreground-color cl))) + (round (* 360 h)) + (round (* 100 s)) + (round (* 100 l)))))))) + +(defun marginalia-annotate-char (cand) + "Annotate character CAND with its general character category and character code." + (when-let (char (char-from-name cand t)) + (marginalia--fields + (:left char :format" (%c)" :face 'marginalia-char) + (char :format "%06X" :face 'marginalia-number) + ((char-code-property-description + 'general-category + (get-char-code-property char 'general-category)) + :width 30 :face 'marginalia-documentation)))) + +(defun marginalia-annotate-minor-mode (cand) + "Annotate minor-mode CAND with status and documentation string." + (let* ((sym (intern-soft cand)) + (message-log-max nil) + (mode (if (and sym (boundp sym)) + sym + (lookup-minor-mode-from-indicator cand))) + (lighter (cdr (assq mode minor-mode-alist))) + (lighter-str (and lighter (string-trim (format-mode-line (cons t lighter)))))) + (marginalia--fields + ((if (and (boundp mode) (symbol-value mode)) + (propertize "On" 'face 'marginalia-on) + (propertize "Off" 'face 'marginalia-off)) :width 3) + ((if (local-variable-if-set-p mode) "Local" "Global") :width 6 :face 'marginalia-type) + (lighter-str :width 20 :face 'marginalia-lighter) + ((marginalia--function-doc mode) + :truncate 1.0 :face 'marginalia-documentation)))) + +(defun marginalia-annotate-package (cand) + "Annotate package CAND with its description summary." + (when-let ((pkg-alist (bound-and-true-p package-alist)) + (name (replace-regexp-in-string "-[0-9\\.-]+\\'" "" cand)) + (pkg (intern-soft name)) + (desc (or (unless (equal name cand) + (cl-loop with version = (substring cand (1+ (length name))) + for d in (alist-get pkg pkg-alist) + if (equal (package-version-join (package-desc-version d)) version) + return d)) + ;; taken from `describe-package-1' + (car (alist-get pkg pkg-alist)) + (if-let (built-in (assq pkg package--builtins)) + (package--from-builtin built-in) + (car (alist-get pkg package-archive-contents)))))) + (marginalia--fields + ((package-version-join (package-desc-version desc)) :truncate 16 :face 'marginalia-version) + ((cond + ((package-desc-archive desc) (propertize (package-desc-archive desc) 'face 'marginalia-archive)) + (t (propertize (or (package-desc-status desc) "orphan") 'face 'marginalia-installed))) :truncate 12) + ((package-desc-summary desc) :truncate 1.0 :face 'marginalia-documentation)))) + +(defun marginalia--bookmark-type (bm) + "Return bookmark type string of BM. +The string is transformed according to `marginalia--bookmark-type-transforms'." + (let ((handler (or (bookmark-prop-get bm 'handler) 'bookmark-default-handler))) + (and + ;; Some libraries use lambda handlers instead of symbols. For + ;; example the function `xwidget-webkit-bookmark-make-record' is + ;; affected. I consider this bad style since then the lambda is + ;; persisted. + (symbolp handler) + (or (get handler 'bookmark-handler-type) + (let ((str (symbol-name handler)) + case-fold-search) + (dolist (transformer marginalia--bookmark-type-transforms str) + (when (string-match-p (car transformer) str) + (setq str + (if (stringp (cdr transformer)) + (replace-regexp-in-string (car transformer) (cdr transformer) str) + (funcall (cdr transformer) str)))))))))) + +(defun marginalia-annotate-bookmark (cand) + "Annotate bookmark CAND with its file name and front context string." + (when-let ((bm (assoc cand (bound-and-true-p bookmark-alist)))) + (marginalia--fields + ((marginalia--bookmark-type bm) :width 10 :face 'marginalia-type) + ((or (bookmark-prop-get bm 'filename) + (bookmark-prop-get bm 'location)) + :truncate (if (bookmark-prop-get bm 'filename) -0.5 0.5) + :face 'marginalia-file-name) + ((let ((front (or (bookmark-prop-get bm 'front-context-string) "")) + (rear (or (bookmark-prop-get bm 'rear-context-string) ""))) + (unless (and (string-blank-p front) (string-blank-p rear)) + (string-clean-whitespace + (concat front (marginalia--ellipsis) rear)))) + :truncate 0.5 :face 'marginalia-documentation)))) + +(defun marginalia-annotate-customize-group (cand) + "Annotate customization group CAND with its documentation string." + (marginalia--documentation (documentation-property (intern cand) 'group-documentation))) + +(defun marginalia-annotate-input-method (cand) + "Annotate input method CAND with its description." + (marginalia--documentation (nth 4 (assoc cand input-method-alist)))) + +(defun marginalia-annotate-charset (cand) + "Annotate charset CAND with its description." + (marginalia--documentation (charset-description (intern cand)))) + +(defun marginalia-annotate-coding-system (cand) + "Annotate coding system CAND with its description." + (marginalia--documentation (coding-system-doc-string (intern cand)))) + +(defun marginalia--buffer-status (buffer) + "Return the status of BUFFER as a string." + (format-mode-line '((:propertize "%1*%1+%1@" face marginalia-modified) + marginalia-separator + (7 (:propertize "%I" face marginalia-size)) + marginalia-separator + ;; InactiveMinibuffer has 18 letters, but there are longer names. + ;; For example Org-Agenda produces very long mode names. + ;; Therefore we have to truncate. + (20 (-20 (:propertize mode-name face marginalia-mode)))) + nil nil buffer)) + +(defun marginalia--buffer-file (buffer) + "Return the file or process name of BUFFER." + (if-let (proc (get-buffer-process buffer)) + (format "(%s %s) %s" + proc (process-status proc) + (abbreviate-file-name (buffer-local-value 'default-directory buffer))) + (abbreviate-file-name + (or (cond + ;; see ibuffer-buffer-file-name + ((buffer-file-name buffer)) + ((when-let (dir (and (local-variable-p 'dired-directory buffer) + (buffer-local-value 'dired-directory buffer))) + (expand-file-name (if (stringp dir) dir (car dir)) + (buffer-local-value 'default-directory buffer)))) + ((local-variable-p 'list-buffers-directory buffer) + (buffer-local-value 'list-buffers-directory buffer))) + "")))) + +(defun marginalia-annotate-buffer (cand) + "Annotate buffer CAND with modification status, file name and major mode." + (when-let ((buffer (get-buffer cand))) + (if (buffer-live-p buffer) + (marginalia--fields + ((marginalia--buffer-status buffer)) + ((marginalia--buffer-file buffer) + :truncate -0.5 :face 'marginalia-file-name)) + (marginalia--fields ("(dead buffer)" :face 'error))))) + +(defun marginalia--full-candidate (cand) + "Return completion candidate CAND in full. +For some completion tables, the completion candidates offered are +meant to be only a part of the full minibuffer contents. For +example, during file name completion the candidates are one path +component of a full file path." + (if-let (win (active-minibuffer-window)) + (with-current-buffer (window-buffer win) + (concat (let ((end (minibuffer-prompt-end))) + (buffer-substring-no-properties + end (+ end marginalia--base-position))) + cand)) + ;; no minibuffer is active, trust that cand already conveys all + ;; necessary information (there's not much else we can do) + cand)) + +(defun marginalia--remote-file-p (file) + "Return non-nil if FILE is remote. +The return value is a string describing the remote location, +e.g., the protocol." + (save-match-data + (setq file (substitute-in-file-name file)) + (cl-loop for r in marginalia-remote-file-regexps + if (string-match r file) + return (or (match-string 1 file) "remote")))) + +(defun marginalia--annotate-local-file (cand) + "Annotate local file CAND." + (marginalia--in-minibuffer + (when-let (attrs (ignore-errors + ;; may throw permission denied errors + (file-attributes (substitute-in-file-name + (marginalia--full-candidate cand)) + 'integer))) + ;; HACK: Format differently accordingly to alignment, since the file owner + ;; is usually not displayed. Otherwise we will see an excessive amount of + ;; whitespace in front of the file permissions. Furthermore the alignment + ;; in `consult-buffer' will look ugly. Find a better solution! + (if (eq marginalia-align 'right) + (marginalia--fields + ;; File owner at the left + ((marginalia--file-owner attrs) :face 'marginalia-file-owner) + ((marginalia--file-modes attrs)) + ((marginalia--file-size attrs) :face 'marginalia-size :width -7) + ((marginalia--time (file-attribute-modification-time attrs)) + :face 'marginalia-date :width -12)) + (marginalia--fields + ((marginalia--file-modes attrs)) + ((marginalia--file-size attrs) :face 'marginalia-size :width -7) + ((marginalia--time (file-attribute-modification-time attrs)) + :face 'marginalia-date :width -12) + ;; File owner at the right + ((marginalia--file-owner attrs) :face 'marginalia-file-owner)))))) + +(defun marginalia-annotate-file (cand) + "Annotate file CAND with its size, modification time and other attributes. +These annotations are skipped for remote paths." + (if-let (remote (or (marginalia--remote-file-p cand) + (when-let (win (active-minibuffer-window)) + (with-current-buffer (window-buffer win) + (marginalia--remote-file-p (minibuffer-contents-no-properties)))))) + (marginalia--fields (remote :format "*%s*" :face 'marginalia-documentation)) + (marginalia--annotate-local-file cand))) + +(defun marginalia--file-owner (attrs) + "Return file owner given ATTRS." + (let ((uid (file-attribute-user-id attrs)) + (gid (file-attribute-group-id attrs))) + (when (or (/= (user-uid) uid) (/= (group-gid) gid)) + (format "%s:%s" + (or (user-login-name uid) uid) + (or (group-name gid) gid))))) + +(defun marginalia--file-size (attrs) + "Return formatted file size given ATTRS." + (propertize (file-size-human-readable (file-attribute-size attrs)) + 'help-echo (number-to-string (file-attribute-size attrs)))) + +(defun marginalia--file-modes (attrs) + "Return fontified file modes given the ATTRS." + ;; Without caching this can a be significant portion of the time + ;; `marginalia-annotate-file' takes to execute. Caching improves performance + ;; by about a factor of 20. + (setq attrs (file-attribute-modes attrs)) + (or (car (member attrs marginalia--fontified-file-modes)) + (progn + (setq attrs (substring attrs)) ;; copy because attrs is about to be modified + (dotimes (i (length attrs)) + (put-text-property + i (1+ i) 'face + (pcase (aref attrs i) + (?- 'marginalia-file-priv-no) + (?d 'marginalia-file-priv-dir) + (?l 'marginalia-file-priv-link) + (?r 'marginalia-file-priv-read) + (?w 'marginalia-file-priv-write) + (?x 'marginalia-file-priv-exec) + ((or ?s ?S ?t ?T) 'marginalia-file-priv-other) + (_ 'marginalia-file-priv-rare)) + attrs)) + (push attrs marginalia--fontified-file-modes) + attrs))) + +(defconst marginalia--time-relative + `((100 "sec" 1) + (,(* 60 100) "min" 60.0) + (,(* 3600 30) "hour" 3600.0) + (,(* 3600 24 400) "day" ,(* 3600.0 24.0)) + (nil "year" ,(* 365.25 24 3600))) + "Formatting used by the function `marginalia--time-relative'.") + +;; Taken from `seconds-to-string'. +(defun marginalia--time-relative (time) + "Format TIME as a relative age." + (setq time (max 0 (float-time (time-since time)))) + (let ((sts marginalia--time-relative) here) + (while (and (car (setq here (pop sts))) (<= (car here) time))) + (setq time (round time (caddr here))) + (format "%s %s%s ago" time (cadr here) (if (= time 1) "" "s")))) + +(defun marginalia--time-absolute (time) + "Format TIME as an absolute age." + (let ((system-time-locale "C")) + (format-time-string + (if (> (decoded-time-year (decode-time (current-time))) + (decoded-time-year (decode-time time))) + " %Y %b %d" + "%b %d %H:%M") + time))) + +(defun marginalia--time (time) + "Format file age TIME, suitably for use in annotations." + (propertize + (if (< (float-time (time-since time)) marginalia-max-relative-age) + (marginalia--time-relative time) + (marginalia--time-absolute time)) + 'help-echo (format-time-string "%Y-%m-%d %T" time))) + +(defvar-local marginalia--project-root 'unset) +(defun marginalia--project-root () + "Return project root." + (marginalia--in-minibuffer + (when (eq marginalia--project-root 'unset) + (setq marginalia--project-root + (or (let ((prompt (minibuffer-prompt)) + case-fold-search) + (and (string-match + "\\`\\(?:Dired\\|Find file\\) in \\(.*\\): \\'" + prompt) + (match-string 1 prompt))) + (when-let (proj (project-current)) + (cond + ((fboundp 'project-root) (project-root proj)) + ((fboundp 'project-roots) (car (project-roots proj)))))))) + marginalia--project-root)) + +(defun marginalia-annotate-project-file (cand) + "Annotate file CAND with its size, modification time and other attributes." + ;; Absolute project directories also report project-file category + (if (file-name-absolute-p cand) + (marginalia-annotate-file cand) + (when-let (root (marginalia--project-root)) + (marginalia-annotate-file (expand-file-name cand root))))) + +(defvar-local marginalia--library-cache nil) +(defun marginalia--library-cache () + "Return hash table from library name to library file." + (marginalia--in-minibuffer + ;; `locate-file' and `locate-library' are bottlenecks for the + ;; annotator. Therefore we compute all the library paths first. + (unless marginalia--library-cache + (setq marginalia--library-cache (make-hash-table :test #'equal)) + (dolist (dir (delete-dups + (reverse ;; Reverse because of shadowing + (append load-path (custom-theme--load-path))))) ;; Include themes + (dolist (file (ignore-errors + (directory-files dir 'full + "\\.el\\(?:\\.gz\\)?\\'"))) + (puthash (marginalia--library-name file) + file marginalia--library-cache)))) + marginalia--library-cache)) + +(defun marginalia--library-name (file) + "Get name of library FILE." + (replace-regexp-in-string "\\(\\.gz\\|\\.elc?\\)+\\'" "" + (file-name-nondirectory file))) + +(defun marginalia--library-doc (file) + "Return library documentation string for FILE." + (let ((doc (get-text-property 0 'marginalia--library-doc file))) + (unless doc + ;; Extract documentation string. We cannot use `lm-summary' here, + ;; since it decompresses the whole file, which is slower. + (setq doc (or (ignore-errors + (let ((shell-file-name "sh") + (shell-command-switch "-c")) + (shell-command-to-string + (format (if (string-suffix-p ".gz" file) + "gzip -c -q -d %s | head -n1" + "head -n1 %s") + (shell-quote-argument file))))) + "")) + (cond + ((string-match "\\`(define-package\\s-+\"\\([^\"]+\\)\"" doc) + (setq doc (format "Generated package description from %s.el" + (match-string 1 doc)))) + ((string-match "\\`;+\\s-*" doc) + (setq doc (substring doc (match-end 0))) + (when (string-match "\\`[^ \t]+\\s-+-+\\s-+" doc) + (setq doc (substring doc (match-end 0)))) + (when (string-match "\\s-*-\\*-" doc) + (setq doc (substring doc 0 (match-beginning 0))))) + (t (setq doc ""))) + ;; Add the documentation string to the cache + (put-text-property 0 1 'marginalia--library-doc doc file)) + doc)) + +(defun marginalia-annotate-theme (cand) + "Annotate theme CAND with documentation and path." + (marginalia-annotate-library (concat cand "-theme"))) + +(defun marginalia-annotate-library (cand) + "Annotate library CAND with documentation and path." + (setq cand (marginalia--library-name cand)) + (when-let (file (gethash cand (marginalia--library-cache))) + (marginalia--fields + ;; Display if the corresponding feature is loaded. + ;; feature/=library file, but better than nothing. + ((when-let (sym (intern-soft cand)) + (when (memq sym features) + (propertize "Loaded" 'face 'marginalia-on))) + :width 8) + ((marginalia--library-doc file) + :truncate 1.0 :face 'marginalia-documentation) + ((abbreviate-file-name (file-name-directory file)) + :truncate -0.5 :face 'marginalia-file-name)))) + +(defun marginalia-annotate-tab (cand) + "Annotate named tab CAND with tab index, window and buffer information." + (when-let ((tabs (funcall tab-bar-tabs-function)) + (index (seq-position + tabs nil + (lambda (tab _) (equal (alist-get 'name tab) cand))))) + (let* ((tab (nth index tabs)) + (ws (alist-get 'ws tab)) + (bufs (window-state-buffers ws))) + ;; When the buffer key is present in the window state it is added in front + ;; of the window buffer list and gets duplicated. + (when (cadr (assq 'buffer ws)) (pop bufs)) + (marginalia--fields + (:left (1+ index) :format " (%s)" :face 'marginalia-key) + ((if (eq (car tab) 'current-tab) + (length (window-list nil 'no-minibuf)) + (length bufs)) + :format "win:%s" :face 'marginalia-size) + ((or (alist-get 'group tab) 'none) + :format "group:%s" :face 'marginalia-type :truncate 20) + ((if (eq (car tab) 'current-tab) + "(current tab)" + (string-join bufs " ")) + :face 'marginalia-documentation))))) + +(defun marginalia-classify-by-command-name () + "Lookup category for current command." + (and marginalia--command + (or (alist-get marginalia--command marginalia-command-categories) + ;; The command can be an alias, e.g., `recentf' -> `recentf-open'. + (when-let ((chain (function-alias-p marginalia--command))) + (alist-get (car (last chain)) marginalia-command-categories))))) + +(defun marginalia-classify-original-category () + "Return original category reported by completion metadata." + ;; Use `alist-get' instead of `completion-metadata-get' to bypass our + ;; `marginalia--completion-metadata-get' advice! + (when-let (cat (alist-get 'category marginalia--metadata)) + ;; Ignore Emacs 28 symbol-help category in order to ensure that the + ;; categories are refined to our categories function and variable. + (and (not (eq cat 'symbol-help)) cat))) + +(defun marginalia-classify-symbol () + "Determine if currently completing symbols." + (when-let (mct minibuffer-completion-table) + (when (or (eq mct 'help--symbol-completion-table) + (obarrayp mct) + (and (not (functionp mct)) (consp mct) (symbolp (car mct)))) ; assume list of symbols + 'symbol))) + +(defun marginalia-classify-by-prompt () + "Determine category by matching regexps against the minibuffer prompt. +This runs through the `marginalia-prompt-categories' alist +looking for a regexp that matches the prompt." + (when-let (prompt (minibuffer-prompt)) + (setq prompt + (replace-regexp-in-string "(.*?default.*?)\\|\\[.*?\\]" "" prompt)) + (cl-loop with case-fold-search = t + for (regexp . category) in marginalia-prompt-categories + when (string-match-p regexp prompt) + return category))) + +(defun marginalia--cache-reset (&rest _) + "Reset the cache." + (setq marginalia--cache (and marginalia--cache (> marginalia--cache-size 0) + (cons nil (make-hash-table :test #'equal + :size marginalia--cache-size))))) + +(defun marginalia--cached (cache fun key) + "Cached application of function FUN with KEY. +The CACHE keeps around the last `marginalia--cache-size' computed +annotations. The cache is mainly useful when scrolling in +completion UIs like Vertico or Icomplete." + (if cache + (let ((ht (cdr cache))) + (or (gethash key ht) + (let ((val (funcall fun key))) + (push key (car cache)) + (puthash key val ht) + (when (>= (hash-table-count ht) marginalia--cache-size) + (let ((end (last (car cache) 2))) + (remhash (cadr end) ht) + (setcdr end nil))) + val))) + (funcall fun key))) + +(defun marginalia--align (cands) + "Align annotations of CANDS according to `marginalia-align'." + (cl-loop + for (cand . ann) in cands do + (when-let (align (text-property-any 0 (length ann) 'marginalia--align t ann)) + (setq marginalia--cand-width-max + (max marginalia--cand-width-max + (* (ceiling (+ (string-width cand) + (compat-call string-width ann 0 align)) + marginalia--cand-width-step) + marginalia--cand-width-step))))) + (cl-loop + for (cand . ann) in cands collect + (progn + (when-let (align (text-property-any 0 (length ann) 'marginalia--align t ann)) + (put-text-property + align (1+ align) 'display + `(space :align-to + ,(pcase-exhaustive marginalia-align + ('center `(+ center ,marginalia-align-offset)) + ('left `(+ left ,(+ marginalia-align-offset marginalia--cand-width-max))) + ('right `(+ right ,(+ marginalia-align-offset 1 + (- (compat-call string-width ann 0 align) + (string-width ann))))))) + ann)) + (list cand "" ann)))) + +(defun marginalia--affixate (metadata annotator cands) + "Affixate CANDS given METADATA and Marginalia ANNOTATOR." + ;; Compute minimum width of windows, which display the minibuffer, including + ;; the miniwindow. In general the computed width corresponds to the full + ;; frame width, since the miniwindow spans the full frame. For example + ;; `vertico-buffer' displays the minibuffer in a separate window. Similarly, + ;; we could detect other types of completion buffers, e.g., Embark Collect or + ;; the default completion buffer, and compute smaller widths. + (let* ((width (cl-loop for win in (get-buffer-window-list) minimize (window-width win))) + (marginalia-field-width (min (/ width 2) marginalia-field-width)) + (marginalia--metadata metadata) + (cache marginalia--cache)) + (marginalia--align + ;; Run the annotators in the original window. `with-selected-window' + ;; is necessary because of `lookup-minor-mode-from-indicator'. + ;; Otherwise it would suffice to only change the current buffer. We + ;; need the `selected-window' fallback for Embark Occur. + (with-selected-window (or (minibuffer-selected-window) (selected-window)) + (cl-loop for cand in cands collect + (let ((ann (or (marginalia--cached cache annotator cand) ""))) + (cons cand (if (string-blank-p ann) "" ann)))))))) + +(defun marginalia--completion-metadata-get (metadata prop) + "Meant as :before-until advice for `completion-metadata-get'. +METADATA is the metadata. +PROP is the property which is looked up." + (pcase prop + ('annotation-function + ;; We do want the advice triggered for `completion-metadata-get'. + (when-let ((cat (completion-metadata-get metadata 'category)) + (annotator (marginalia--annotator cat))) + (lambda (cand) + (let ((ann (caddar (marginalia--affixate metadata annotator (list cand))))) + (and (not (equal ann "")) ann))))) + ('affixation-function + ;; We do want the advice triggered for `completion-metadata-get'. + (when-let ((cat (completion-metadata-get metadata 'category)) + (annotator (marginalia--annotator cat))) + (apply-partially #'marginalia--affixate metadata annotator))) + ('category + ;; Find the completion category by trying each of our classifiers. + ;; Store the metadata for `marginalia-classify-original-category'. + (let ((marginalia--metadata metadata)) + (run-hook-with-args-until-success 'marginalia-classifiers))))) + +(defun marginalia--minibuffer-setup () + "Setup the minibuffer for Marginalia. +Remember `this-command' for `marginalia-classify-by-command-name'." + (setq marginalia--cache t marginalia--command this-command) + ;; Reset cache if window size changes, recompute alignment + (add-hook 'window-state-change-hook #'marginalia--cache-reset nil 'local) + (marginalia--cache-reset)) + +(defun marginalia--base-position (completions) + "Record the base position of COMPLETIONS." + ;; As a small optimization we track the base position only for file + ;; completions, since `marginalia--full-candidate' is currently used only by + ;; the file annotation function. + (when minibuffer-completing-file-name + (let ((base (or (cdr (last completions)) 0))) + (unless (= marginalia--base-position base) + (marginalia--cache-reset) + (setq marginalia--base-position base + marginalia--cand-width-max (default-value 'marginalia--cand-width-max))))) + completions) + +;;;###autoload +(define-minor-mode marginalia-mode + "Annotate completion candidates with richer information." + :global t :group 'marginalia + (if marginalia-mode + (progn + ;; Remember `this-command' in order to select the annotation function. + (add-hook 'minibuffer-setup-hook #'marginalia--minibuffer-setup) + ;; Replace the metadata function. + (advice-add #'completion-metadata-get :before-until #'marginalia--completion-metadata-get) + ;; Record completion base position, for `marginalia--full-candidate' + (advice-add #'completion-all-completions :filter-return #'marginalia--base-position)) + (advice-remove #'completion-all-completions #'marginalia--base-position) + (advice-remove #'completion-metadata-get #'marginalia--completion-metadata-get) + (remove-hook 'minibuffer-setup-hook #'marginalia--minibuffer-setup))) + +;;;###autoload +(defun marginalia-cycle () + "Cycle between annotators in `marginalia-annotator-registry'." + (interactive) + (with-current-buffer (window-buffer + (or (active-minibuffer-window) + (user-error "Marginalia: No active minibuffer"))) + (let* ((end (minibuffer-prompt-end)) + (pt (max 0 (- (point) end))) + (metadata (completion-metadata (buffer-substring-no-properties end (+ end pt)) + minibuffer-completion-table + minibuffer-completion-predicate)) + (cat (or (completion-metadata-get metadata 'category) + (user-error "Marginalia: Unknown completion category"))) + (ann (or (assq cat marginalia-annotator-registry) + (user-error "Marginalia: No annotators found for category `%s'" cat)))) + (marginalia--cache-reset) + (setcdr ann (append (cddr ann) (list (cadr ann)))) + ;; When the builtin annotator is selected and no builtin function is + ;; available, skip to the next annotator. Note that we cannot use + ;; `completion-metadata-get' to access the metadata since we must + ;; bypass the `marginalia--completion-metadata-get' advice. + (when (and (eq (cadr ann) 'builtin) + (not (assq 'annotation-function metadata)) + (not (assq 'affixation-function metadata)) + (not (plist-get completion-extra-properties :annotation-function)) + (not (plist-get completion-extra-properties :affixation-function))) + (setcdr ann (append (cddr ann) (list (cadr ann))))) + (message "Marginalia: Use annotator `%s' for category `%s'" (cadr ann) (car ann))))) + +;; Emacs 28: Only show `marginalia-cycle' in M-x in recursive minibuffers +(put #'marginalia-cycle 'completion-predicate + (lambda (&rest _) (> (minibuffer-depth) 1))) + +(provide 'marginalia) +;;; marginalia.el ends here diff --git a/emacs/elpa/marginalia-20240523.1240/marginalia.elc b/emacs/elpa/marginalia-20240523.1240/marginalia.elc Binary files differ. diff --git a/emacs/elpa/nerd-icons-20240520.1050/nerd-icons-pkg.el b/emacs/elpa/nerd-icons-20240520.1050/nerd-icons-pkg.el @@ -1,14 +0,0 @@ -(define-package "nerd-icons" "20240520.1050" "Emacs Nerd Font Icons Library" - '((emacs "24.3")) - :commit "5ed32f43f2e92ac2600d0ff823ec75e4476cc53e" :authors - '(("Hongyu Ding <rainstormstudio@yahoo.com>, Vincent Zhang" . "seagle0128@gmail.com")) - :maintainers - '(("Hongyu Ding <rainstormstudio@yahoo.com>, Vincent Zhang" . "seagle0128@gmail.com")) - :maintainer - '("Hongyu Ding <rainstormstudio@yahoo.com>, Vincent Zhang" . "seagle0128@gmail.com") - :keywords - '("lisp") - :url "https://github.com/rainstormstudio/nerd-icons.el") -;; Local Variables: -;; no-byte-compile: t -;; End: diff --git a/emacs/elpa/nerd-icons-20240520.1050/nerd-icons.el b/emacs/elpa/nerd-icons-20240520.1050/nerd-icons.el @@ -1,1315 +0,0 @@ -;;; nerd-icons.el --- Emacs Nerd Font Icons Library -*- lexical-binding: t -*- - -;; Copyright (C) 2023 Hongyu Ding <rainstormstudio@yahoo.com> - -;; Author: Hongyu Ding <rainstormstudio@yahoo.com>, Vincent Zhang <seagle0128@gmail.com> -;; Keywords: lisp -;; Version: 0.1.0 -;; Package-Requires: ((emacs "24.3")) -;; URL: https://github.com/rainstormstudio/nerd-icons.el -;; Keywords: convenient, lisp - -;; 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/>. - -;;; Commentary: - -;; This package was inspired by - -;; - `all-the-icons', found at https://github.com/Alexander-Miller/treemacs/blob/master/src/extra/treemacs-all-the-icons.el -;; - `vim-devicons' for Vim, found at https://github.com/ryanoasis/vim-devicons -;; - `nvim-web-devicons' for NeoVim, found at https://github.com/nvim-tree/nvim-web-devicons - -;; This package provides an interface to the Nerd Fonts - -;; - `nerd-fonts', found at https://github.com/ryanoasis/nerd-fonts - -;;; Code: - -(require 'cl-lib) - -(require 'nerd-icons-data) -(require 'nerd-icons-faces) - -(declare-function set-fontset-font "src/fontset.c") - -(defgroup nerd-icons nil - "Manage how Nerd Fonts formats icons." - :prefix "nerd-icons-" - :group 'appearance - :group 'convenience) - -(defcustom nerd-icons-color-icons t - "Whether or not to include a foreground color when formatting the icon." - :group 'nerd-icons - :type 'boolean) - -(defcustom nerd-icons-scale-factor 1.0 - "The base Scale Factor for the `height' face property of an icon." - :group 'nerd-icons - :type 'number) - -(defcustom nerd-icons-default-adjust 0.0 - "The default adjustment to be made to the `raise' display property of an icon." - :group 'nerd-icons - :type 'number) - -(defcustom nerd-icons--cache-limit 2048 - "Maximum cache size for functions cached by `nerd-icons-cache'." - :group 'nerd-icons - :type 'integer) - -(defcustom nerd-icons-font-family "Symbols Nerd Font Mono" - "The Nerd Font for display icons." - :group 'nerd-icons - :type 'string) - -(defcustom nerd-icons-fonts-subdirectory nil - "The subdirectory within the system fonts folder where the icons are installed." - :group 'nerd-icons - :type 'directory) - -(defvar nerd-icons-font-names '("NFM.ttf") - "List of defined font file names.") - -(defvar nerd-icons-glyph-sets '() "List of defined icon glyph sets.") - -(defvar nerd-icons-extension-icon-alist - '( - ("fish" nerd-icons-devicon "nf-dev-terminal" :face nerd-icons-lpink) - ("zsh" nerd-icons-devicon "nf-dev-terminal" :face nerd-icons-lcyan) - ("sh" nerd-icons-devicon "nf-dev-terminal" :face nerd-icons-purple) - ("bat" nerd-icons-codicon "nf-cod-terminal_cmd" :face nerd-icons-lsilver) - ("cmd" nerd-icons-codicon "nf-cod-terminal_cmd" :face nerd-icons-lsilver) - ;; Meta - ("tags" nerd-icons-octicon "nf-oct-tag" :face nerd-icons-blue) - ("log" nerd-icons-octicon "nf-oct-log" :face nerd-icons-maroon) - ;; Config - ("node" nerd-icons-devicon "nf-dev-nodejs_small" :face nerd-icons-green) - ("babelrc" nerd-icons-mdicon "nf-md-babel" :face nerd-icons-yellow) - ("bashrc" nerd-icons-mdicon "nf-md-bash" :face nerd-icons-dpink) - ("bowerrc" nerd-icons-devicon "nf-dev-bower" :face nerd-icons-silver) - ("cr" nerd-icons-sucicon "nf-seti-crystal" :face nerd-icons-yellow) - ("ecr" nerd-icons-sucicon "nf-seti-crystal" :face nerd-icons-yellow) - ("ini" nerd-icons-codicon "nf-cod-settings" :face nerd-icons-yellow) - ("properties" nerd-icons-codicon "nf-cod-settings" :face nerd-icons-yellow) - ("eslintignore" nerd-icons-mdicon "nf-md-eslint" :face nerd-icons-purple) - ("eslint" nerd-icons-mdicon "nf-md-eslint" :face nerd-icons-lpurple) - ("git" nerd-icons-sucicon "nf-seti-git" :face nerd-icons-lred) - ("gitattributes" nerd-icons-sucicon "nf-seti-git" :face nerd-icons-lred) - ("gitignore" nerd-icons-sucicon "nf-seti-git" :face nerd-icons-lred) - ("gitmodules" nerd-icons-sucicon "nf-seti-git" :face nerd-icons-lred) - ("mk" nerd-icons-devicon "nf-dev-gnu" :face nerd-icons-dorange) - ;; ("cmake" nerd-icons-devicon "cmake") TODO: cmake - ("dockerignore" nerd-icons-devicon "nf-dev-docker" :face nerd-icons-dblue) - ("xml" nerd-icons-faicon "nf-fa-file_code_o" :face nerd-icons-lorange) - ("json" nerd-icons-codicon "nf-cod-settings" :face nerd-icons-yellow) - ("jsonl" nerd-icons-codicon "nf-cod-settings" :face nerd-icons-yellow) - ("cson" nerd-icons-codicon "nf-cod-settings" :face nerd-icons-yellow) - ("yml" nerd-icons-codicon "nf-cod-settings" :face nerd-icons-dyellow) - ("yaml" nerd-icons-codicon "nf-cod-settings" :face nerd-icons-dyellow) - ("toml" nerd-icons-codicon "nf-cod-settings" :face nerd-icons-orange) - ("conf" nerd-icons-codicon "nf-cod-settings" :face nerd-icons-dorange) - ("editorconfig" nerd-icons-sucicon "nf-seti-editorconfig" :face nerd-icons-silver) - ;; ? - ("pkg" nerd-icons-octicon "nf-oct-package" :face nerd-icons-dsilver) - ("rpm" nerd-icons-octicon "nf-oct-package" :face nerd-icons-dsilver) - ("pkgbuild" nerd-icons-octicon "nf-oct-package" :face nerd-icons-dsilver) - ("elc" nerd-icons-octicon "nf-oct-file_binary" :face nerd-icons-dsilver) - ("eln" nerd-icons-octicon "nf-oct-file_binary" :face nerd-icons-dsilver) - ("gz" nerd-icons-octicon "nf-oct-file_binary" :face nerd-icons-lmaroon) - ("zip" nerd-icons-octicon "nf-oct-file_zip" :face nerd-icons-lmaroon) - ("7z" nerd-icons-octicon "nf-oct-file_zip" :face nerd-icons-lmaroon) - ("zst" nerd-icons-octicon "nf-oct-file_zip" :face nerd-icons-lmaroon) - ("dat" nerd-icons-faicon "nf-fa-bar_chart" :face nerd-icons-cyan) - ("dmg" nerd-icons-octicon "nf-oct-tools" :face nerd-icons-lsilver) - ("dll" nerd-icons-faicon "nf-fa-cogs" :face nerd-icons-silver) - ("ds_store" nerd-icons-faicon "nf-fa-cogs" :face nerd-icons-silver) - ("exe" nerd-icons-octicon "nf-oct-file_binary" :face nerd-icons-dsilver) - ("msg" nerd-icons-octicon "nf-oct-mail" :face nerd-icons-dsilver) - ;; Source Codes - ("ada" nerd-icons-sucicon "nf-custom-ada" :face nerd-icons-blue) - ("adb" nerd-icons-sucicon "nf-custom-ada" :face nerd-icons-blue) - ("adc" nerd-icons-sucicon "nf-custom-ada" :face nerd-icons-blue) - ("ads" nerd-icons-sucicon "nf-custom-ada" :face nerd-icons-blue) - ("gpr" nerd-icons-sucicon "nf-custom-ada" :face nerd-icons-green) - ("cgpr" nerd-icons-sucicon "nf-custom-ada" :face nerd-icons-green) - ("scpt" nerd-icons-devicon "nf-dev-apple" :face nerd-icons-pink) - ;; ("aup" nerd-icons-fileicon "audacity") TODO: audacity - ("elm" nerd-icons-sucicon "nf-seti-elm" :face nerd-icons-blue) - ("erl" nerd-icons-devicon "nf-dev-erlang" :face nerd-icons-red) - ("hrl" nerd-icons-devicon "nf-dev-erlang" :face nerd-icons-dred) - ("eex" nerd-icons-sucicon "nf-seti-elixir" :face nerd-icons-lorange) - ("leex" nerd-icons-sucicon "nf-seti-elixir" :face nerd-icons-lorange) - ("heex" nerd-icons-sucicon "nf-seti-elixir" :face nerd-icons-lorange) - ("ex" nerd-icons-sucicon "nf-seti-elixir" :face nerd-icons-lpurple) - ("exs" nerd-icons-sucicon "nf-seti-elixir" :face nerd-icons-lred) - ("livemd" nerd-icons-sucicon "nf-seti-elixir" :face nerd-icons-lblue) - ("java" nerd-icons-devicon "nf-dev-java" :face nerd-icons-purple) - ("groovy" nerd-icons-devicon "nf-dev-groovy" :face nerd-icons-cyan) - ("gradle" nerd-icons-sucicon "nf-seti-gradle" :face nerd-icons-silver) - ("ebuild" nerd-icons-mdicon "nf-md-gentoo" :face nerd-icons-cyan) - ("eclass" nerd-icons-mdicon "nf-md-gentoo" :face nerd-icons-blue) - ("go" nerd-icons-devicon "nf-dev-go" :face nerd-icons-blue) - ("jl" nerd-icons-sucicon "nf-seti-julia" :face nerd-icons-purple) - ("magik" nerd-icons-faicon "nf-fa-magic" :face nerd-icons-blue) - ;; ("matlab" nerd-icons-devicon "matlab") TODO: matlab - ("nix" nerd-icons-mdicon "nf-md-nix" :face nerd-icons-blue) - ("pl" nerd-icons-sucicon "nf-seti-perl" :face nerd-icons-lorange) - ("pm" nerd-icons-sucicon "nf-seti-perl" :face nerd-icons-lorange) - ;; ("pl6" nerd-icons-devicon"raku") TODO: raku - ;; ("pm6" nerd-icons-devicon "raku") TODO: raku - ("pod" nerd-icons-devicon "nf-dev-perl" :face nerd-icons-lgreen) - ("php" nerd-icons-devicon "nf-dev-php" :face nerd-icons-lsilver) - ;; ("pony" nerd-icons-devicon "pony") TODO: pony - ("ps1" nerd-icons-mdicon "nf-md-powershell" :face nerd-icons-blue) - ("pro" nerd-icons-sucicon "nf-seti-prolog" :face nerd-icons-lmaroon) - ("proog" nerd-icons-sucicon "nf-seti-prolog" :face nerd-icons-lmaroon) - ("py" nerd-icons-devicon "nf-dev-python" :face nerd-icons-dblue) - ;; ("idr" nerd-icons-devicon "idris") TODO: idris - ;; ("ipynb" nerd-icons-devicon "jupyter") TODO: jupyter - ("gem" nerd-icons-devicon "nf-dev-ruby" :face nerd-icons-red) - ;; ("raku" nerd-icons-devicon "raku") TODO: raku - ;; ("rakumod" nerd-icons-devicon "raku") TODO: raku - ("rb" nerd-icons-octicon "nf-oct-ruby" :face nerd-icons-lred) - ("rs" nerd-icons-devicon "nf-dev-rust" :face nerd-icons-maroon) - ("rlib" nerd-icons-devicon "nf-dev-rust" :face nerd-icons-dmaroon) - ("r" nerd-icons-sucicon "nf-seti-r" :face nerd-icons-lblue) - ("rd" nerd-icons-sucicon "nf-seti-r" :face nerd-icons-lblue) - ("rdx" nerd-icons-sucicon "nf-seti-r" :face nerd-icons-lblue) - ("rsx" nerd-icons-sucicon "nf-seti-r" :face nerd-icons-lblue) - ("svelte" nerd-icons-sucicon "nf-seti-svelte" :face nerd-icons-red) - ("gql" nerd-icons-mdicon "nf-md-graphql" :face nerd-icons-dpink) - ("graphql" nerd-icons-mdicon "nf-md-graphql" :face nerd-icons-dpink) - ;; There seems to be a a bug with this font icon which does not - ;; let you propertise it without it reverting to being a lower - ;; case phi - ("c" nerd-icons-sucicon "nf-custom-c" :face nerd-icons-blue) - ("h" nerd-icons-faicon "nf-fa-h_square" :face nerd-icons-purple) - ("m" nerd-icons-devicon "nf-dev-apple" ) - ("mm" nerd-icons-devicon "nf-dev-apple" ) - ;; - ("cc" nerd-icons-sucicon "nf-custom-cpp" :face nerd-icons-blue) - ("cpp" nerd-icons-sucicon "nf-custom-cpp" :face nerd-icons-blue) - ("cxx" nerd-icons-sucicon "nf-custom-cpp" :face nerd-icons-blue) - ("hh" nerd-icons-sucicon "nf-custom-cpp" :face nerd-icons-purple) - ("hpp" nerd-icons-sucicon "nf-custom-cpp" :face nerd-icons-purple) - ("hxx" nerd-icons-sucicon "nf-custom-cpp" :face nerd-icons-purple) - ;; Lisps - ("cl" nerd-icons-sucicon "nf-custom-common_lisp" :face nerd-icons-lorange) - ("l" nerd-icons-sucicon "nf-custom-scheme" :face nerd-icons-orange) - ("lisp" nerd-icons-sucicon "nf-custom-scheme" :face nerd-icons-orange) - ;; ("hy" nerd-icons-sucicon "nf-custom-hy" :face nerd-icons-blue) - ("el" nerd-icons-sucicon "nf-custom-emacs" :face nerd-icons-purple) - ("clj" nerd-icons-devicon "nf-dev-clojure" :face nerd-icons-blue) - ("cljc" nerd-icons-devicon "nf-dev-clojure" :face nerd-icons-blue) - ("cljs" nerd-icons-devicon "nf-dev-clojure" :face nerd-icons-lyellow) - ("coffee" nerd-icons-devicon "nf-dev-coffeescript" :face nerd-icons-maroon) - ("iced" nerd-icons-devicon "nf-dev-coffeescript" :face nerd-icons-lmaroon) - ("dart" nerd-icons-devicon "nf-dev-dart" :face nerd-icons-blue) - ("ledger" nerd-icons-mdicon "nf-md-file_table_box_multiple" :face nerd-icons-green) - ("rkt" nerd-icons-sucicon "nf-custom-scheme" :face nerd-icons-red) - ("scrbl" nerd-icons-sucicon "nf-custom-scheme" :face nerd-icons-blue) - ;; Stylesheeting - ("css" nerd-icons-devicon "nf-dev-css3" :face nerd-icons-yellow) - ("scss" nerd-icons-mdicon "nf-md-sass" :face nerd-icons-pink) - ("sass" nerd-icons-mdicon "nf-md-sass" :face nerd-icons-dpink) - ("less" nerd-icons-devicon "nf-dev-less" :face nerd-icons-dyellow) - ;; ("postcss" nerd-icons-devicon "postcss") TODO: postcss - ;; ("sss" nerd-icons-devicon "postcss") TODO: postcss - ("styl" nerd-icons-devicon "nf-dev-stylus" :face nerd-icons-lgreen) - ("csv" nerd-icons-octicon "nf-oct-graph" :face nerd-icons-dblue) - ;; haskell - ("hs" nerd-icons-devicon "nf-dev-haskell" :face nerd-icons-red) - ("chs" nerd-icons-devicon "nf-dev-haskell" :face nerd-icons-red) - ("lhs" nerd-icons-devicon "nf-dev-haskell" :face nerd-icons-red) - ("hsc" nerd-icons-devicon "nf-dev-haskell" :face nerd-icons-red) - ;; Web modes - ("inky-haml" nerd-icons-sucicon "nf-seti-haml" :face nerd-icons-lyellow) - ("haml" nerd-icons-sucicon "nf-seti-haml" :face nerd-icons-lyellow) - ("htm" nerd-icons-devicon "nf-dev-html5" :face nerd-icons-orange) - ("html" nerd-icons-devicon "nf-dev-html5" :face nerd-icons-orange) - ("inky-er" nerd-icons-devicon "nf-dev-html5" :face nerd-icons-lred) - ("inky-erb" nerd-icons-devicon "nf-dev-html5" :face nerd-icons-lred) - ("erb" nerd-icons-devicon "nf-dev-html5" :face nerd-icons-lred) - ;; ("hbs" nerd-icons-fileicon "moustache") TODO: moustache - ("inky-slim" nerd-icons-codicon "nf-cod-dashboard" :face nerd-icons-yellow) - ("slim" nerd-icons-codicon "nf-cod-dashboard" :face nerd-icons-yellow) - ("jade" nerd-icons-sucicon "nf-seti-jade" :face nerd-icons-red) - ("pug" nerd-icons-sucicon "nf-seti-pug" :face nerd-icons-red) - ;; Javascript - ;; ("d3js" nerd-icons-devicon "d3") TODO: d3 - ("re" nerd-icons-sucicon "nf-seti-reasonml" :face nerd-icons-red-alt) - ("rei" nerd-icons-sucicon "nf-seti-reasonml" :face nerd-icons-dred) - ("ml" nerd-icons-sucicon "nf-seti-ocaml" :face nerd-icons-lpink) - ("mli" nerd-icons-sucicon "nf-seti-ocaml" :face nerd-icons-dpink) - ("react" nerd-icons-devicon "nf-dev-react" :face nerd-icons-lblue) - ("ts" nerd-icons-sucicon "nf-seti-typescript" :face nerd-icons-blue-alt) - ("js" nerd-icons-devicon "nf-dev-javascript" :face nerd-icons-yellow) - ("es" nerd-icons-devicon "nf-dev-javascript" :face nerd-icons-yellow) - ("jsx" nerd-icons-devicon "nf-dev-javascript" :face nerd-icons-cyan-alt) - ("tsx" nerd-icons-sucicon "nf-seti-typescript" :face nerd-icons-blue-alt) - ("njs" nerd-icons-mdicon "nf-md-nodejs" :face nerd-icons-lgreen) - ("vue" nerd-icons-sucicon "nf-seti-vue" :face nerd-icons-lgreen) - - ("sbt" nerd-icons-sucicon "nf-seti-sbt" :face nerd-icons-red) - ("scala" nerd-icons-devicon "nf-dev-scala" :face nerd-icons-red) - ("scm" nerd-icons-sucicon "nf-custom-scheme" :face nerd-icons-red) - ("swift" nerd-icons-devicon "nf-dev-swift" :face nerd-icons-green) - - ("tcl" nerd-icons-mdicon "nf-md-feather" :face nerd-icons-dred) - ("exp" nerd-icons-mdicon "nf-md-feather" :face nerd-icons-dred) - - ("tf" nerd-icons-mdicon "nf-md-terraform" :face nerd-icons-purple-alt) - ("tfvars" nerd-icons-mdicon "nf-md-terraform" :face nerd-icons-purple-alt) - ("tfstate" nerd-icons-mdicon "nf-md-terraform" :face nerd-icons-purple-alt) - - ("asm" nerd-icons-sucicon "nf-seti-asm" :face nerd-icons-blue) - ;; Verilog(-AMS) and SystemVerilog(-AMS ;; Verilog(-AMS) and SystemVerilog(-AMS) - ("v" nerd-icons-mdicon "nf-md-chip" :face nerd-icons-red) - ("vams" nerd-icons-mdicon "nf-md-chip" :face nerd-icons-red) - ("sv" nerd-icons-mdicon "nf-md-chip" :face nerd-icons-red) - ("sva" nerd-icons-mdicon "nf-md-chip" :face nerd-icons-red) - ("svh" nerd-icons-mdicon "nf-md-chip" :face nerd-icons-red) - ("svams" nerd-icons-mdicon "nf-md-chip" :face nerd-icons-red) - ;; VHDL(-AMS ;; VHDL(-AMS) - ("vhd" nerd-icons-octicon "nf-oct-cpu" :face nerd-icons-blue) - ("vhdl" nerd-icons-octicon "nf-oct-cpu" :face nerd-icons-blue) - ("vhms" nerd-icons-octicon "nf-oct-cpu" :face nerd-icons-blue) - ;; Cabal - ;; ("cabal" nerd-icons-devicon "cabal") TODO: cabal - ;; Kotlin - ("kt" nerd-icons-sucicon "nf-seti-kotlin" :face nerd-icons-orange) - ("kts" nerd-icons-sucicon "nf-seti-kotlin" :face nerd-icons-orange) - ;; Nimrod - ("nim" nerd-icons-sucicon "nf-seti-nim" :face nerd-icons-yellow) - ("nims" nerd-icons-sucicon "nf-seti-nim" :face nerd-icons-yellow) - ;; SQL - ("sql" nerd-icons-octicon "nf-oct-database" :face nerd-icons-silver) - ;; Styles - ;; ("styles" nerd-icons-devicon "style") TODO: style - ;; Lua - ("lua" nerd-icons-sucicon "nf-seti-lua" :face nerd-icons-dblue) - ;; ASCII doc - ;; ("adoc" nerd-icons-devicon "asciidoc") TODO: asciidoc - ;; ("asciidoc" nerd-icons-devicon "asciidoc") TODO: asciidoc - ;; Puppet - ("pp" nerd-icons-sucicon "nf-seti-puppet" :face nerd-icons-yellow) - ;; Jinja - ("j2" nerd-icons-sucicon "nf-seti-jinja" :face nerd-icons-silver) - ("jinja2" nerd-icons-sucicon "nf-seti-jinja" :face nerd-icons-silver) - ;; Docker - ("dockerfile" nerd-icons-sucicon "nf-seti-docker" :face nerd-icons-cyan) - ;; Vagrant - ;; ("vagrantfile" nerd-icons-fileicon "vagrant") TODO: vagrant - ;; GLSL - ("glsl" nerd-icons-faicon "nf-fa-paint_brush" :face nerd-icons-blue) - ("vert" nerd-icons-faicon "nf-fa-paint_brush" :face nerd-icons-blue) - ("tesc" nerd-icons-faicon "nf-fa-paint_brush" :face nerd-icons-purple) - ("tese" nerd-icons-faicon "nf-fa-paint_brush" :face nerd-icons-dpurple) - ("geom" nerd-icons-faicon "nf-fa-paint_brush" :face nerd-icons-green) - ("frag" nerd-icons-faicon "nf-fa-paint_brush" :face nerd-icons-red) - ("comp" nerd-icons-faicon "nf-fa-paint_brush" :face nerd-icons-dblue) - ;; CUDA - ("cu" nerd-icons-sucicon "nf-custom-c" :face nerd-icons-green) - ("cuh" nerd-icons-faicon "nf-fa-h_square" :face nerd-icons-green) - ;; Fortran - ("f90" nerd-icons-mdicon "nf-md-language_fortran" :face nerd-icons-purple) - ;; C# - ("cs" nerd-icons-mdicon "nf-md-language_csharp" :face nerd-icons-dblue) - ("csx" nerd-icons-mdicon "nf-md-language_csharp" :face nerd-icons-dblue) - ;; F# - ("fs" nerd-icons-devicon "nf-dev-fsharp" :face nerd-icons-blue-alt) - ("fsi" nerd-icons-devicon "nf-dev-fsharp" :face nerd-icons-blue-alt) - ("fsx" nerd-icons-devicon "nf-dev-fsharp" :face nerd-icons-blue-alt) - ("fsscript" nerd-icons-devicon "nf-dev-fsharp" :face nerd-icons-blue-alt) - ;; Godot / GDScript - ("gd" nerd-icons-sucicon "nf-seti-godot" :face nerd-icons-blue) - ("tscn" nerd-icons-codicon "nf-cod-settings" :face nerd-icons-orange) - ("tres" nerd-icons-codicon "nf-cod-settings" :face nerd-icons-orange) - ;; zig - ("zig" nerd-icons-sucicon "nf-seti-zig" :face nerd-icons-orange) - ;; odin - ;; ("odin" nerd-icons-fileicon "odin") TODO: odin - ;; File Types - ("ico" nerd-icons-octicon "nf-oct-file_media" :face nerd-icons-blue) - ("png" nerd-icons-mdicon "nf-md-file_png_box" :face nerd-icons-orange) - ("gif" nerd-icons-mdicon "nf-md-file_gif_box" :face nerd-icons-green) - ("jpeg" nerd-icons-mdicon "nf-md-file_jpg_box" :face nerd-icons-dblue) - ("jpg" nerd-icons-mdicon "nf-md-file_jpg_box" :face nerd-icons-dblue) - ("webp" nerd-icons-octicon "nf-oct-file_media" :face nerd-icons-dblue) - ("xpm" nerd-icons-octicon "nf-oct-file_media" :face nerd-icons-dgreen) - ;; Audio - ("mp3" nerd-icons-faicon "nf-fa-music" :face nerd-icons-dred) - ("wav" nerd-icons-faicon "nf-fa-music" :face nerd-icons-dred) - ("m4a" nerd-icons-faicon "nf-fa-music" :face nerd-icons-dred) - ("ogg" nerd-icons-faicon "nf-fa-music" :face nerd-icons-dred) - ("flac" nerd-icons-faicon "nf-fa-music" :face nerd-icons-dred) - ("opus" nerd-icons-faicon "nf-fa-music" :face nerd-icons-dred) - ("au" nerd-icons-faicon "nf-fa-music" :face nerd-icons-dred) - ("aif" nerd-icons-faicon "nf-fa-music" :face nerd-icons-dred) - ("aifc" nerd-icons-faicon "nf-fa-music" :face nerd-icons-dred) - ("aiff" nerd-icons-faicon "nf-fa-music" :face nerd-icons-dred) - ("svg" nerd-icons-sucicon "nf-seti-svg" :face nerd-icons-lgreen) - ;; Video - ("mov" nerd-icons-faicon "nf-fa-film" :face nerd-icons-blue) - ("mp4" nerd-icons-faicon "nf-fa-film" :face nerd-icons-blue) - ("ogv" nerd-icons-faicon "nf-fa-film" :face nerd-icons-dblue) - ("mpg" nerd-icons-faicon "nf-fa-film" :face nerd-icons-blue) - ("mpeg" nerd-icons-faicon "nf-fa-film" :face nerd-icons-blue) - ("flv" nerd-icons-faicon "nf-fa-film" :face nerd-icons-blue) - ("ogv" nerd-icons-faicon "nf-fa-film" :face nerd-icons-dblue) - ("mkv" nerd-icons-faicon "nf-fa-film" :face nerd-icons-blue) - ("webm" nerd-icons-faicon "nf-fa-film" :face nerd-icons-blue) - ;; Fonts - ("ttf" nerd-icons-faicon "nf-fa-font" :face nerd-icons-dcyan) - ("woff" nerd-icons-faicon "nf-fa-font" :face nerd-icons-cyan) - ("woff2" nerd-icons-faicon "nf-fa-font" :face nerd-icons-cyan) - ;; Archives - ("iso" nerd-icons-mdicon "nf-md-disc" :face nerd-icons-orange) - ("tar" nerd-icons-mdicon "nf-md-zip_box" :face nerd-icons-orange) - ("rar" nerd-icons-mdicon "nf-md-zip_box" :face nerd-icons-orange) - ("tgz" nerd-icons-mdicon "nf-md-zip_box" :face nerd-icons-orange) - ("jar" nerd-icons-devicon "nf-dev-java" :face nerd-icons-dpurple) - ;; Doc - ("pdf" nerd-icons-codicon "nf-cod-file_pdf" :face nerd-icons-dred) - ("text" nerd-icons-faicon "nf-fa-file_text" :face nerd-icons-cyan) - ("txt" nerd-icons-faicon "nf-fa-file_text" :face nerd-icons-cyan) - ("doc" nerd-icons-mdicon "nf-md-file_word" :face nerd-icons-blue) - ("docx" nerd-icons-mdicon "nf-md-file_word" :face nerd-icons-blue) - ("docm" nerd-icons-mdicon "nf-md-file_word" :face nerd-icons-blue) - ("texi" nerd-icons-sucicon "nf-seti-tex" :face nerd-icons-lred) - ("tex" nerd-icons-sucicon "nf-seti-tex" :face nerd-icons-lred) - ("ltx" nerd-icons-sucicon "nf-seti-tex" :face nerd-icons-lred) - ("dtx" nerd-icons-sucicon "nf-seti-tex" :face nerd-icons-lred) - ("sty" nerd-icons-sucicon "nf-seti-tex" :face nerd-icons-lred) - ("md" nerd-icons-octicon "nf-oct-markdown" :face nerd-icons-lblue) - ("bib" nerd-icons-mdicon "nf-md-book" :face nerd-icons-lblue) - ("org" nerd-icons-sucicon "nf-custom-orgmode" :face nerd-icons-lgreen) - ("org_archive" nerd-icons-sucicon "nf-custom-orgmode" :face nerd-icons-lgreen) - ("pps" nerd-icons-mdicon "nf-md-file_powerpoint" :face nerd-icons-orange) - ("ppt" nerd-icons-mdicon "nf-md-file_powerpoint" :face nerd-icons-orange) - ("pptsx" nerd-icons-mdicon "nf-md-file_powerpoint" :face nerd-icons-orange) - ("ppttx" nerd-icons-mdicon "nf-md-file_powerpoint" :face nerd-icons-orange) - ("knt" nerd-icons-mdicon "nf-md-file_powerpoint" :face nerd-icons-cyan) - ("xlsx" nerd-icons-mdicon "nf-md-file_excel" :face nerd-icons-dgreen) - ("xlsm" nerd-icons-mdicon "nf-md-file_excel" :face nerd-icons-dgreen) - ("xlsb" nerd-icons-mdicon "nf-md-file_excel" :face nerd-icons-dgreen) - ("xltx" nerd-icons-mdicon "nf-md-file_excel" :face nerd-icons-dgreen) - ("xltm" nerd-icons-mdicon "nf-md-file_excel" :face nerd-icons-dgreen) - ("epub" nerd-icons-mdicon "nf-md-book_open" :face nerd-icons-green) - ("ly" nerd-icons-faicon "nf-fa-music" :face nerd-icons-green) - ;; - ("key" nerd-icons-octicon "nf-oct-key" :face nerd-icons-lblue) - ("pem" nerd-icons-octicon "nf-oct-key" :face nerd-icons-orange) - ("p12" nerd-icons-octicon "nf-oct-key" :face nerd-icons-dorange) - ("crt" nerd-icons-octicon "nf-oct-key" :face nerd-icons-lblue) - ("pub" nerd-icons-octicon "nf-oct-key" :face nerd-icons-blue) - ("gpg" nerd-icons-octicon "nf-oct-key" :face nerd-icons-lblue) - ("kdbx" nerd-icons-octicon "nf-oct-key" :face nerd-icons-green) - ("cache" nerd-icons-octicon "nf-oct-database" :face nerd-icons-green) - ;; backup - ("backup" nerd-icons-mdicon "nf-md-file_restore" :face nerd-icons-lblue) - ("old" nerd-icons-mdicon "nf-md-file_restore" :face nerd-icons-lblue) - ("bak" nerd-icons-mdicon "nf-md-file_restore" :face nerd-icons-lblue))) - -(defvar nerd-icons-regexp-icon-alist - '( - ;; - ("^TAGS$" nerd-icons-octicon "nf-oct-tag" :face nerd-icons-blue) - ("^TODO$" nerd-icons-octicon "nf-oct-checklist" :face nerd-icons-lyellow) - ("^LICENSE$" nerd-icons-octicon "nf-oct-book" :face nerd-icons-blue) - ("^readme" nerd-icons-octicon "nf-oct-book" :face nerd-icons-lcyan) - - ;; Config - ("nginx$" nerd-icons-devicon "nf-dev-nginx" :face nerd-icons-dgreen) - ;; ("apache$" nerd-icons-alltheicon "apache") TODO: apache - - ;; C - ("^Makefile$" nerd-icons-sucicon "nf-seti-makefile" :face nerd-icons-dorange) - ("^CMakeLists.txt$" nerd-icons-sucicon "nf-seti-makefile" :face nerd-icons-red) ;; TODO: cmake - ("^CMakeCache.txt$" nerd-icons-sucicon "nf-seti-makefile" :face nerd-icons-blue) ;; TODO: cmakecache - ("^meson.build$" nerd-icons-sucicon "nf-seti-makefile" :face nerd-icons-purple) ;; TODO: meson - ("^meson_options.txt$" nerd-icons-sucicon "nf-seti-makefile" :face nerd-icons-purple) ;; TODO: meson - - ;; Docker - ("^\\.?Dockerfile" nerd-icons-sucicon "nf-seti-docker" :face nerd-icons-blue) - - ;; Homebrew - ("^Brewfile$" nerd-icons-faicon "nf-fa-beer" :face nerd-icons-lsilver) - - ;; ;; AWS - ("^stack.*.json$" nerd-icons-devicon "nf-dev-aws" :face nerd-icons-orange) - ("^serverless\\.yml$" nerd-icons-faicon "nf-fa-bolt" :face nerd-icons-yellow) - - ;; lock files - ("~$" nerd-icons-octicon "nf-oct-lock" :face nerd-icons-maroon) - - ;; Source Codes - ("^mix.lock$" nerd-icons-sucicon "nf-seti-elixir" :face nerd-icons-lyellow) - - ;; Ruby - ("^Gemfile\\(\\.lock\\)?$" nerd-icons-octicon "nf-oct-ruby" :face nerd-icons-red) - ("_?test\\.rb$" nerd-icons-octicon "nf-oct-ruby" :face nerd-icons-red) - ("_?test_helper\\.rb$" nerd-icons-octicon "nf-oct-ruby" :face nerd-icons-dred) - ("_?spec\\.rb$" nerd-icons-octicon "nf-oct-ruby" :face nerd-icons-red) - ("_?spec_helper\\.rb$" nerd-icons-octicon "nf-oct-ruby" :face nerd-icons-dred) - - ("-?spec\\.ts$" nerd-icons-mdicon "nf-md-language_typescript" :face nerd-icons-blue) - ("-?test\\.ts$" nerd-icons-mdicon "nf-md-language_typescript" :face nerd-icons-blue) - ("-?spec\\.js$" nerd-icons-mdicon "nf-md-language_javascript" :face nerd-icons-lpurple) - ("-?test\\.js$" nerd-icons-mdicon "nf-md-language_javascript" :face nerd-icons-lpurple) - ("-?spec\\.jsx$" nerd-icons-mdicon "nf-md-react" :face nerd-icons-blue-alt) - ("-?test\\.jsx$" nerd-icons-mdicon "nf-md-react" :face nerd-icons-blue-alt) - - ;; Git - ("^MERGE_" nerd-icons-octicon "nf-oct-git_merge" :face nerd-icons-red) - ("^COMMIT_EDITMSG" nerd-icons-octicon "nf-oct-git_commit" :face nerd-icons-red) - - ;; Stylesheeting - ("stylelint" nerd-icons-sucicon "nf-seti-stylelint" :face nerd-icons-lyellow) - - ;; JavaScript - ("^package.json$" nerd-icons-devicon "nf-dev-npm" :face nerd-icons-red) - ("^package.lock.json$" nerd-icons-devicon "nf-dev-npm" :face nerd-icons-dred) - ("^yarn\\.lock" nerd-icons-sucicon "nf-seti-yarn" :face nerd-icons-blue-alt) - ("\\.npmignore$" nerd-icons-devicon "nf-dev-npm" :face nerd-icons-dred) - ("^bower.json$" nerd-icons-devicon "nf-dev-bower" :face nerd-icons-lorange) - ("^gulpfile" nerd-icons-devicon "nf-dev-gulp" :face nerd-icons-lred) - ("^gruntfile" nerd-icons-devicon "nf-dev-grunt" :face nerd-icons-lyellow) - ("^webpack" nerd-icons-mdicon "nf-md-webpack" :face nerd-icons-lblue) - - ;; Go - ("^go.mod$" nerd-icons-sucicon "nf-seti-config" :face nerd-icons-blue-alt) - ("^go.work$" nerd-icons-sucicon "nf-seti-config" :face nerd-icons-blue-alt) - - ;; Groovy - ("Jenkinsfile\\'" nerd-icons-devicon "nf-dev-groovy" :face nerd-icons-cyan-alt) - - ;; Emacs - ("bookmark" nerd-icons-octicon "nf-oct-bookmark" :face nerd-icons-lpink) - - ("^\\*scratch\\*$" nerd-icons-faicon "nf-fa-sticky_note" :face nerd-icons-lyellow) - ("^\\*scratch.*" nerd-icons-faicon "nf-fa-sticky_note" :face nerd-icons-yellow) - ("^\\*new-tab\\*$" nerd-icons-mdicon "nf-md-star" :face nerd-icons-cyan) - ("Cask\\'" nerd-icons-sucicon "nf-custom-emacs" :face nerd-icons-blue) - ("Eask\\'" nerd-icons-sucicon "nf-custom-emacs" :face nerd-icons-blue) - - ("^\\." nerd-icons-octicon "nf-oct-gear"))) - -(defvar nerd-icons-default-file-icon - '(nerd-icons-faicon "nf-fa-file_o")) - -(defvar nerd-icons-dir-icon-alist - '( - ("trash" nerd-icons-faicon "nf-fa-trash_o") - ("dropbox" nerd-icons-faicon "nf-fa-dropbox") - ("google[ _-]drive" nerd-icons-mdicon "nf-md-folder_google_drive") - ("github" nerd-icons-sucicon "nf-custom-folder_github") - ("^atom$" nerd-icons-devicon "nf-dev-atom") - ("documents" nerd-icons-mdicon "nf-md-folder_file") - ("download" nerd-icons-mdicon "nf-md-folder_download") - ("desktop" nerd-icons-octicon "nf-oct-device_desktop") - ("pictures" nerd-icons-mdicon "nf-md-folder_image") - ("photos" nerd-icons-faicon "nf-fa-camera_retro") - ("music" nerd-icons-mdicon "nf-md-folder_music") - ("movies" nerd-icons-faicon "nf-fa-film") - ("code" nerd-icons-octicon "nf-oct-code") - ("workspace" nerd-icons-octicon "nf-oct-code") - ;; ("test" nerd-icons-devicon "test-dir") - ("\\.git" nerd-icons-sucicon "nf-custom-folder_git") - ("\\.config" nerd-icons-sucicon "nf-custom-folder_config") - (".?" nerd-icons-sucicon "nf-custom-folder_oct"))) - -(defvar nerd-icons-weather-icon-alist - '( - ("tornado" nerd-icons-wicon "nf-weather-tornado") - ("hurricane" nerd-icons-wicon "nf-weather-hurricane") - ("thunderstorms" nerd-icons-wicon "nf-weather-thunderstorm") - ("sunny" nerd-icons-wicon "nf-weather-day_sunny") - ("rain.*snow" nerd-icons-wicon "nf-weather-rain_mix") - ("rain.*hail" nerd-icons-wicon "nf-weather-rain_mix") - ("sleet" nerd-icons-wicon "nf-weather-sleet") - ("hail" nerd-icons-wicon "nf-weather-hail") - ("drizzle" nerd-icons-wicon "nf-weather-sprinkle") - ("rain" nerd-icons-wicon "nf-weather-showers") - ("showers" nerd-icons-wicon "nf-weather-showers") - ("blowing.*snow" nerd-icons-wicon "nf-weather-snow_wind") - ("snow" nerd-icons-wicon "nf-weather-snow") - ("dust" nerd-icons-wicon "nf-weather-dust") - ("fog" nerd-icons-wicon "nf-weather-fog") - ("haze" nerd-icons-wicon "nf-weather-day_haze") - ("smoky" nerd-icons-wicon "nf-weather-smoke") - ("blustery" nerd-icons-wicon "nf-weather-cloudy_windy") - ("windy" nerd-icons-wicon "nf-weather-cloudy_gusts") - ("cold" nerd-icons-wicon "nf-weather-snowflake_cold") - ("partly.*cloudy.*night" nerd-icons-wicon "nf-weather-night_alt_partly_cloudy") - ("partly.*cloudy" nerd-icons-wicon "nf-weather-day_cloudy_high") - ("cloudy.*night" nerd-icons-wicon "nf-weather-night_alt_cloudy") - ("cxloudy.*day" nerd-icons-wicon "nf-weather-day_cloudy") - ("cloudy" nerd-icons-wicon "nf-weather-cloudy") - ("clear.*night" nerd-icons-wicon "nf-weather-night_clear") - ("fair.*night" nerd-icons-wicon "nf-weather-stars") - ("fair.*day" nerd-icons-wicon "nf-weather-horizon") - ("hot" nerd-icons-wicon "nf-weather-hot") - ("not.*available" nerd-icons-wicon "nf-weather-na"))) - -(defvar nerd-icons-mode-icon-alist - '( - (emacs-lisp-mode nerd-icons-sucicon "nf-custom-emacs" :face nerd-icons-purple) - (circe-server-mode nerd-icons-faicon "nf-fa-commenting_o") - (circe-channel-mode nerd-icons-faicon "nf-fa-commenting_o") - (circe-query-mode nerd-icons-faicon "nf-fa-commenting_o") - (crystal-mode nerd-icons-sucicon "nf-custom-crystal" :face nerd-icons-yellow) - (erc-mode nerd-icons-faicon "nf-fa-commenting_o") - (inferior-emacs-lisp-mode nerd-icons-sucicon "nf-custom-emacs" :face nerd-icons-lblue) - (dired-mode nerd-icons-octicon "nf-oct-file_directory") - (lisp-interaction-mode nerd-icons-sucicon "nf-custom-emacs" :face nerd-icons-orange) - (sly-mrepl-mode nerd-icons-sucicon "nf-custom-common_lisp" :face nerd-icons-orange) - (slime-repl-mode nerd-icons-sucicon "nf-custom-common_lisp" :face nerd-icons-orange) - (org-mode nerd-icons-sucicon "nf-custom-orgmode" :face nerd-icons-lgreen) - (ledger-mode nerd-icons-mdicon "nf-md-file_table_box_multiple" :face nerd-icons-green) - (typescript-mode nerd-icons-mdicon "nf-md-language_typescript" :face nerd-icons-blue-alt) - (typescript-ts-mode nerd-icons-mdicon "nf-md-language_typescript" :face nerd-icons-blue-alt) - (typescript-tsx-mode nerd-icons-mdicon "nf-md-language_typescript" :face nerd-icons-blue-alt) - (tsx-ts-mode nerd-icons-mdicon "nf-md-language_typescript" :face nerd-icons-blue-alt) - (js-mode nerd-icons-devicon "nf-dev-javascript" :face nerd-icons-yellow) - (js-ts-mode nerd-icons-devicon "nf-dev-javascript" :face nerd-icons-yellow) - (js-jsx-mode nerd-icons-devicon "nf-dev-javascript" :face nerd-icons-yellow) - (js2-mode nerd-icons-devicon "nf-dev-javascript" :face nerd-icons-yellow) - (js3-mode nerd-icons-devicon "nf-dev-javascript" :face nerd-icons-yellow) - (rjsx-mode nerd-icons-devicon "nf-dev-javascript" :face nerd-icons-cyan-alt) - (term-mode nerd-icons-devicon "nf-dev-terminal") - (vterm-mode nerd-icons-devicon "nf-dev-terminal") - (eshell-mode nerd-icons-devicon "nf-dev-terminal" :face nerd-icons-purple) - (magit-refs-mode nerd-icons-devicon "nf-dev-git_branch" :face nerd-icons-red) - (magit-process-mode nerd-icons-octicon "nf-oct-mark_github") - (magit-diff-mode nerd-icons-devicon "nf-dev-git_compare" :face nerd-icons-lblue) - (ediff-mode nerd-icons-devicon "nf-dev-git_compare" :face nerd-icons-red) - (diff-mode nerd-icons-devicon "nf-dev-git_compare" :face nerd-icons-lred) - (comint-mode nerd-icons-faicon "nf-fa-terminal" :face nerd-icons-lblue) - (eww-mode nerd-icons-faicon "nf-fa-firefox" :face nerd-icons-red) - (xwidget-webkit-mode nerd-icons-faicon "nf-fa-chrome" :face nerd-icons-blue) - (org-agenda-mode nerd-icons-octicon "nf-oct-checklist" :face nerd-icons-lgreen) - (cfw:calendar-mode nerd-icons-octicon "nf-oct-calendar") - (ibuffer-mode nerd-icons-faicon "nf-fa-files_o" :face nerd-icons-dsilver) - (messages-buffer-mode nerd-icons-faicon "nf-fa-file_o" :face nerd-icons-dsilver) - (help-mode nerd-icons-faicon "nf-fa-info" :face nerd-icons-purple) - (helpful-mode nerd-icons-faicon "nf-fa-info" :face nerd-icons-purple) - (Info-mode nerd-icons-faicon "nf-fa-info" :face nerd-icons-blue) - (benchmark-init/tree-mode nerd-icons-faicon "nf-fa-dashboard") - (jenkins-mode nerd-icons-devicon "nf-dev-jenkins" :face nerd-icons-blue) - (magit-popup-mode nerd-icons-sucicon "nf-seti-git" :face nerd-icons-red) - (magit-status-mode nerd-icons-sucicon "nf-seti-git" :face nerd-icons-lred) - (magit-log-mode nerd-icons-sucicon "nf-seti-git" :face nerd-icons-green) - (mu4e-compose-mode nerd-icons-octicon "nf-oct-pencil") - (mu4e-headers-mode nerd-icons-octicon "nf-oct-mail") - (mu4e-main-mode nerd-icons-octicon "nf-oct-mail") - (mu4e-view-mode nerd-icons-codicon "nf-cod-mail_read") - (sieve-mode nerd-icons-octicon "nf-oct-mail") - (gnus-group-mode nerd-icons-octicon "nf-oct-mail") - (gnus-summary-mode nerd-icons-octicon "nf-oct-mail") - (gnus-article-mode nerd-icons-codicon "nf-cod-mail_read") - (message-mode nerd-icons-octicon "nf-oct-pencil") - (package-menu-mode nerd-icons-faicon "nf-fa-archive" :face nerd-icons-silver) - (paradox-menu-mode nerd-icons-faicon "nf-fa-archive" :face nerd-icons-silver) - (Custom-mode nerd-icons-codicon "nf-cod-settings") - - ;; Special matcher for Web Mode based on the `web-mode-content-type' of the current buffer - (web-mode nerd-icons--web-mode-icon) - - (fundamental-mode nerd-icons-sucicon "nf-custom-emacs" :face nerd-icons-dsilver) - (special-mode nerd-icons-sucicon "nf-custom-emacs" :face nerd-icons-yellow) - (cask-mode nerd-icons-sucicon "nf-custom-emacs" :face nerd-icons-blue) - (eask-mode nerd-icons-sucicon "nf-custom-emacs" :face nerd-icons-blue) - (text-mode nerd-icons-faicon "nf-fa-file_text" :face nerd-icons-cyan) - (enh-ruby-mode nerd-icons-devicon "nf-dev-ruby" :face nerd-icons-lred) - (ruby-mode nerd-icons-devicon "nf-dev-ruby" :face nerd-icons-lred) - (ruby-ts-mode nerd-icons-devicon "nf-dev-ruby" :face nerd-icons-lred) - (inf-ruby-mode nerd-icons-devicon "nf-dev-ruby" :face nerd-icons-red) - (projectile-rails-compilation-mode nerd-icons-devicon "nf-dev-ruby" :face nerd-icons-red) - (rspec-compilation-mode nerd-icons-devicon "nf-dev-ruby" :face nerd-icons-red) - (rake-compilation-mode nerd-icons-devicon "nf-dev-ruby" :face nerd-icons-red) - (sh-mode nerd-icons-devicon "nf-dev-terminal" :face nerd-icons-purple) - (bash-ts-mode nerd-icons-devicon "nf-dev-terminal" :face nerd-icons-purple) - (shell-mode nerd-icons-devicon "nf-dev-terminal" :face nerd-icons-purple) - (fish-mode nerd-icons-devicon "nf-dev-terminal" :face nerd-icons-lpink) - (bat-mode nerd-icons-codicon "nf-cod-terminal_cmd" :face nerd-icons-lsilver) - (nginx-mode nerd-icons-devicon "nf-dev-nginx" :face nerd-icons-dgreen) - ;; (apache-mode nerd-icons-alltheicon "apache" :face nerd-icons-dgreen) - (makefile-mode nerd-icons-devicon "nf-dev-gnu" :face nerd-icons-dorange) - (makefile-ts-mode nerd-icons-devicon "nf-dev-gnu" :face nerd-icons-dorange) - ;; (cmake-mode nerd-icons-fileicon "cmake" :face nerd-icons-red) - ;; (cmake-ts-mode nerd-icons-fileicon "cmake" :face nerd-icons-red) - (dockerfile-mode nerd-icons-sucicon "nf-seti-docker" :face nerd-icons-blue) - (dockerfile-ts-mode nerd-icons-sucicon "nf-seti-docker" :face nerd-icons-blue) - (docker-compose-mode nerd-icons-sucicon "nf-seti-docker" :face nerd-icons-lblue) - (nxml-mode nerd-icons-faicon "nf-fa-file_code_o" :face nerd-icons-lorange) - (conf-mode nerd-icons-codicon "nf-cod-settings" :face nerd-icons-lyellow) - (json-mode nerd-icons-codicon "nf-cod-settings" :face nerd-icons-yellow) - (json-ts-mode nerd-icons-codicon "nf-cod-settings" :face nerd-icons-yellow) - (jsonian-mode nerd-icons-codicon "nf-cod-settings" :face nerd-icons-yellow) - (yaml-mode nerd-icons-codicon "nf-cod-settings" :face nerd-icons-dyellow) - (yaml-ts-mode nerd-icons-codicon "nf-cod-settings" :face nerd-icons-dyellow) - (toml-mode nerd-icons-codicon "nf-cod-settings" :face nerd-icons-orange) - (toml-ts-mode nerd-icons-codicon "nf-cod-settings" :face nerd-icons-orange) - (elisp-byte-code-mode nerd-icons-octicon "nf-oct-file_binary" :face nerd-icons-dsilver) - (archive-mode nerd-icons-octicon "nf-oct-file_zip" :face nerd-icons-lmaroon) - (elm-mode nerd-icons-sucicon "nf-custom-elm" :face nerd-icons-blue) - (erlang-mode nerd-icons-devicon "nf-dev-erlang" :face nerd-icons-red) - (elixir-mode nerd-icons-sucicon "nf-custom-elixir" :face nerd-icons-lorange) - (elixir-ts-mode nerd-icons-sucicon "nf-custom-elixir" :face nerd-icons-lorange) - (java-mode nerd-icons-devicon "nf-dev-java" :face nerd-icons-purple) - (groovy-mode nerd-icons-devicon "nf-dev-groovy" :face nerd-icons-cyan) - (java-ts-mode nerd-icons-devicon "nf-dev-java" :face nerd-icons-purple) - (go-mode nerd-icons-devicon "nf-dev-go" :face nerd-icons-blue) - (go-ts-mode nerd-icons-devicon "nf-dev-go" :face nerd-icons-blue) - (go-dot-mod-mode nerd-icons-sucicon "nf-seti-config" :face nerd-icons-blue-alt) - (go-mod-ts-mode nerd-icons-sucicon "nf-seti-config" :face nerd-icons-blue-alt) - (go-dot-work-mode nerd-icons-sucicon "nf-seti-config" :face nerd-icons-blue-alt) - (graphql-mode nerd-icons-sucicon "nf-seti-graphql" :face nerd-icons-dpink) - ;; (matlab-mode nerd-icons-fileicon "matlab" :face nerd-icons-orange) - (nix-mode nerd-icons-mdicon "nf-md-nix" :face nerd-icons-blue) - (perl-mode nerd-icons-devicon "nf-dev-perl" :face nerd-icons-lorange) - (cperl-mode nerd-icons-devicon "nf-dev-perl" :face nerd-icons-lorange) - (php-mode nerd-icons-devicon "nf-dev-php" :face nerd-icons-lsilver) - (php-ts-mode nerd-icons-devicon "nf-dev-php" :face nerd-icons-lsilver) - (prolog-mode nerd-icons-devicon "nf-dev-prolog" :face nerd-icons-lmaroon) - (python-mode nerd-icons-devicon "nf-dev-python" :face nerd-icons-dblue) - (python-ts-mode nerd-icons-devicon "nf-dev-python" :face nerd-icons-dblue) - (inferior-python-mode nerd-icons-devicon "nf-dev-python" :face nerd-icons-dblue) - ;; (racket-mode nerd-icons-fileicon "racket" :face nerd-icons-red) - (rust-mode nerd-icons-devicon "nf-dev-rust" :face nerd-icons-maroon) - (rustic-mode nerd-icons-devicon "nf-dev-rust" :face nerd-icons-maroon) - (rust-ts-mode nerd-icons-devicon "nf-dev-rust" :face nerd-icons-maroon) - (scala-mode nerd-icons-devicon "nf-dev-scala" :face nerd-icons-red) - ;; (scheme-mode nerd-icons-fileicon "scheme" :face nerd-icons-red) - (swift-mode nerd-icons-devicon "nf-dev-swift" :face nerd-icons-green) - (svelte-mode nerd-icons-sucicon "nf-seti-svelte" :face nerd-icons-red) - (ada-mode nerd-icons-sucicon "nf-custom-ada" :face nerd-icons-blue) - (ada-ts-mode nerd-icons-sucicon "nf-custom-ada" :face nerd-icons-blue) - (gpr-mode nerd-icons-sucicon "nf-custom-ada" :face nerd-icons-green) - (gpr-ts-mode nerd-icons-sucicon "nf-custom-ada" :face nerd-icons-green) - (c-mode nerd-icons-sucicon "nf-custom-c" :face nerd-icons-blue) - (c-ts-mode nerd-icons-sucicon "nf-custom-c" :face nerd-icons-blue) - (c++-mode nerd-icons-sucicon "nf-custom-cpp" :face nerd-icons-blue) - (c++-ts-mode nerd-icons-sucicon "nf-custom-cpp" :face nerd-icons-blue) - (csharp-mode nerd-icons-mdicon "nf-md-language_csharp" :face nerd-icons-dblue) - (csharp-ts-mode nerd-icons-mdicon "nf-md-language_csharp" :face nerd-icons-dblue) - (clojure-mode nerd-icons-devicon "nf-dev-clojure_alt" :face nerd-icons-blue) - (clojure-ts-mode nerd-icons-devicon "nf-dev-clojure_alt" :face nerd-icons-blue) - (cider-repl-mode nerd-icons-devicon "nf-dev-clojure_alt" :face nerd-icons-green) - (clojurec-mode nerd-icons-sucicon "nf-seti-clojure" :face nerd-icons-blue) - (clojurec-ts-mode nerd-icons-sucicon "nf-seti-clojure" :face nerd-icons-blue) - (clojurescript-mode nerd-icons-devicon "nf-dev-clojure_alt" :face nerd-icons-lyellow) - (clojurescript-ts-mode nerd-icons-devicon "nf-dev-clojure_alt" :face nerd-icons-lyellow) - (coffee-mode nerd-icons-devicon "nf-dev-coffeescript" :face nerd-icons-maroon) - (lisp-mode nerd-icons-sucicon "nf-custom-scheme" :face nerd-icons-orange) - (css-mode nerd-icons-devicon "nf-dev-css3" :face nerd-icons-yellow) - (css-ts-mode nerd-icons-devicon "nf-dev-css3" :face nerd-icons-yellow) - (scss-mode nerd-icons-mdicon "nf-md-sass" :face nerd-icons-pink) - (sass-mode nerd-icons-mdicon "nf-md-sass" :face nerd-icons-dpink) - (less-css-mode nerd-icons-devicon "nf-dev-less" :face nerd-icons-dyellow) - (stylus-mode nerd-icons-devicon "nf-dev-stylus" :face nerd-icons-lgreen) - (csv-mode nerd-icons-octicon "nf-oct-graph" :face nerd-icons-dblue) - (gdscript-mode nerd-icons-sucicon "nf-seti-godot" :face nerd-icons-blue) - (gdscript-ts-mode nerd-icons-sucicon "nf-seti-godot" :face nerd-icons-blue) - (haskell-mode nerd-icons-devicon "nf-dev-haskell" :face nerd-icons-red) - (haskell-c2hs-mode nerd-icons-devicon "nf-dev-haskell" :face nerd-icons-red) - (literate-haskell-mode nerd-icons-devicon "nf-dev-haskell" :face nerd-icons-red) - (haml-mode nerd-icons-sucicon "nf-seti-haml" :face nerd-icons-lyellow) - (html-mode nerd-icons-devicon "nf-dev-html5" :face nerd-icons-orange) - (html-ts-mode nerd-icons-devicon "nf-dev-html5" :face nerd-icons-orange) - (rhtml-mode nerd-icons-devicon "nf-dev-html5" :face nerd-icons-lred) - ;; (mustache-mode nerd-icons-fileicon "moustache" :face nerd-icons-green) - (slim-mode nerd-icons-codicon "nf-cod-dashboard" :face nerd-icons-yellow) - (jade-mode nerd-icons-sucicon "nf-seti-jade" :face nerd-icons-red) - (pug-mode nerd-icons-sucicon "nf-seti-pug" :face nerd-icons-red) - (react-mode nerd-icons-devicon "nf-dev-react" :face nerd-icons-lblue) - (image-mode nerd-icons-octicon "nf-oct-file_media" :face nerd-icons-blue) - (texinfo-mode nerd-icons-sucicon "nf-seti-tex" :face nerd-icons-lred) - (markdown-mode nerd-icons-octicon "nf-oct-markdown" :face nerd-icons-lblue) - (markdown-ts-mode nerd-icons-octicon "nf-oct-markdown" :face nerd-icons-lblue) - ;; (bibtex-mode nerd-icons-fileicon "bib" :face nerd-icons-maroon) - (compilation-mode nerd-icons-faicon "nf-fa-cogs") - (objc-mode nerd-icons-faicon "nf-fa-apple") - (tuareg-mode nerd-icons-sucicon "nf-seti-ocaml") - (purescript-mode nerd-icons-sucicon "nf-seti-purescript") - (verilog-mode nerd-icons-mdicon "nf-md-chip" :face nerd-icons-red) - (verilog-ts-mode nerd-icons-mdicon "nf-md-chip" :face nerd-icons-red) - (vhdl-mode nerd-icons-octicon "nf-oct-cpu" :face nerd-icons-blue) - (vhdl-ts-mode nerd-icons-octicon "nf-oct-cpu" :face nerd-icons-blue) - ;; (haskell-cabal-mode nerd-icons-fileicon "cabal" :face nerd-icons-lblue) - (kotlin-mode nerd-icons-sucicon "nf-custom-kotlin" :face nerd-icons-orange) - (kotlin-ts-mode nerd-icons-sucicon "nf-custom-kotlin" :face nerd-icons-orange) - (nim-mode nerd-icons-sucicon "nf-seti-nim" :face nerd-icons-yellow) - (sql-mode nerd-icons-devicon "nf-dev-database" :face nerd-icons-silver) - (lua-mode nerd-icons-sucicon "nf-seti-lua" :face nerd-icons-dblue) - (lua-ts-mode nerd-icons-sucicon "nf-seti-lua" :face nerd-icons-dblue) - ;; (adoc-mode nerd-icons-fileicon "asciidoc" :face nerd-icons-lblue) - (puppet-mode nerd-icons-sucicon "nf-custom-puppet" :face nerd-icons-yellow) - (jinja2-mode nerd-icons-sucicon "nf-seti-jinja" :face nerd-icons-silver) - (powershell-mode nerd-icons-mdicon "nf-md-powershell" :face nerd-icons-blue) - (tex-mode nerd-icons-sucicon "nf-seti-tex" :face nerd-icons-lred) - (latex-mode nerd-icons-sucicon "nf-seti-tex" :face nerd-icons-lred) - (latex-ts-mode nerd-icons-sucicon "nf-seti-tex" :face nerd-icons-lred) - (doctex-mode nerd-icons-sucicon "nf-seti-tex" :face nerd-icons-lred) - ;; Modes provided by AUCTeX 14.1 and higher - (TeX-mode nerd-icons-sucicon "nf-seti-tex" :face nerd-icons-lred) - (LaTeX-mode nerd-icons-sucicon "nf-seti-tex" :face nerd-icons-lred) - (docTeX-mode nerd-icons-sucicon "nf-seti-tex" :face nerd-icons-lred) - (ConTeXt-mode nerd-icons-sucicon "nf-seti-tex" :face nerd-icons-lred) - (AmSTeX-mode nerd-icons-sucicon "nf-seti-tex" :face nerd-icons-lred) - (plain-TeX-mode nerd-icons-sucicon "nf-seti-tex" :face nerd-icons-lred) - (Texinfo-mode nerd-icons-sucicon "nf-seti-tex" :face nerd-icons-lred) - (japanese-plain-TeX-mode nerd-icons-sucicon "nf-seti-tex" :face nerd-icons-lred) - (japanese-LaTeX-mode nerd-icons-sucicon "nf-seti-tex" :face nerd-icons-lred) - (dart-mode nerd-icons-devicon "nf-dev-dart" :face nerd-icons-blue) - (fsharp-mode nerd-icons-devicon "nf-dev-fsharp" :face nerd-icons-blue) - (asm-mode nerd-icons-sucicon "nf-seti-asm" :face nerd-icons-blue) - (fasm-mode nerd-icons-sucicon "nf-seti-asm" :face nerd-icons-blue) - (masm-mode nerd-icons-sucicon "nf-seti-asm" :face nerd-icons-blue) - (nasm-mode nerd-icons-sucicon "nf-seti-asm" :face nerd-icons-blue) - (gas-mode nerd-icons-sucicon "nf-seti-asm" :face nerd-icons-blue) - ;; (tcl-mode nerd-icons-fileicon "tcl" :face nerd-icons-dred) - ;; (cuda-mode nerd-icons-fileicon "nvidia" :face nerd-icons-green) - (f90-mode nerd-icons-mdicon "nf-md-language_fortran" :face nerd-icons-purple) - ;; (hy-mode nerd-icons-fileicon "hy" :face nerd-icons-blue) - (glsl-mode nerd-icons-faicon "nf-fa-paint_brush" :face nerd-icons-green) - (zig-mode nerd-icons-sucicon "nf-seti-zig" :face nerd-icons-orange) - ;; (odin-mode nerd-icons-fileicon "odin" :face nerd-icons-lblue) - (pdf-view-mode nerd-icons-codicon "nf-cod-file_pdf" :face nerd-icons-dred) - (doc-view-mode nerd-icons-mdicon "nf-md-file_document" :face nerd-icons-lred) - (calibre-library-mode nerd-icons-codicon "nf-cod-library" :face nerd-icons-dblue) - (calibre-edit-mode nerd-icons-codicon "nf-cod-library" :face nerd-icons-lred) - (calibredb-search-mode nerd-icons-codicon "nf-cod-library" :face nerd-icons-dblue) - (calibredb-show-mode nerd-icons-codicon "nf-cod-library" :face nerd-icons-lblue) - (osm-mode nerd-icons-mdicon "nf-md-map_search" :face nerd-icons-lgreen) - (spacemacs-buffer-mode nerd-icons-sucicon "nf-custom-emacs" :face nerd-icons-purple) - - (elfeed-search-mode nerd-icons-faicon "nf-fa-rss_square" :face nerd-icons-orange) - (elfeed-summary-mode nerd-icons-faicon "nf-fa-rss_square" :face nerd-icons-orange) - (elfeed-show-mode nerd-icons-faicon "nf-fa-rss_square" :face nerd-icons-yellow) - (newsticker-treeview-mode nerd-icons-faicon "nf-fa-rss_square" :face nerd-icons-orange) - (newsticker-treeview-list-mode nerd-icons-faicon "nf-fa-rss_square" :face nerd-icons-lorange) - (newsticker-treeview-item-mode nerd-icons-faicon "nf-fa-rss_square" :face nerd-icons-yellow) - - (emms-browser-mode nerd-icons-faicon "nf-fa-music" :face nerd-icons-silver) - (emms-lyrics-mode nerd-icons-faicon "nf-fa-music" :face nerd-icons-silver) - (emms-show-all-mode nerd-icons-faicon "nf-fa-music" :face nerd-icons-silver) - (emms-metaplaylist-mode nerd-icons-faicon "nf-fa-music" :face nerd-icons-silver) - (emms-tag-editor-mode nerd-icons-faicon "nf-fa-music" :face nerd-icons-silver) - (emms-playlist-mode nerd-icons-faicon "nf-fa-music" :face nerd-icons-silver) - (lilypond-mode nerd-icons-faicon "nf-fa-music" :face nerd-icons-green) - (bongo-playlist-mode nerd-icons-faicon "nf-fa-music" :face nerd-icons-silver) - (bongo-library-mode nerd-icons-faicon "nf-fa-music" :face nerd-icons-silver) - (mingus-playlist-mode nerd-icons-faicon "nf-fa-music" :face nerd-icons-silver) - (mingus-help-mode nerd-icons-faicon "nf-fa-music" :face nerd-icons-silver) - (mingus-browse-mode nerd-icons-faicon "nf-fa-music" :face nerd-icons-silver) - (mingus-burn-mode nerd-icons-faicon "nf-fa-music" :face nerd-icons-silver) - (simple-mpc-mode nerd-icons-faicon "nf-fa-music" :face nerd-icons-silver) - (telega-root-mode nerd-icons-faicon "nf-fae-telegram" :face nerd-icons-purple) - (telega-chat-mode nerd-icons-faicon "nf-fae-telegram" :face nerd-icons-blue) - (mastodon-mode nerd-icons-mdicon "nf-md-mastodon" :face nerd-icons-blue) - - (fanyi-mode nerd-icons-codicon "nf-cod-library" :face nerd-icons-lcyan) - (osx-dictionary-mode nerd-icons-codicon "nf-cod-library" :face nerd-icons-lcyan) - (youdao-dictionary-mode nerd-icons-codicon "nf-cod-library" :face nerd-icons-lcyan) - - (magik-mode nerd-icons-faicon "nf-fa-magic" :face nerd-icons-blue) - (magik-ts-mode nerd-icons-faicon "nf-fa-magic" :face nerd-icons-blue) - (magik-session-mode nerd-icons-devicon "nf-dev-terminal" :face nerd-icons-blue) - (magik-cb-mode nerd-icons-faicon "nf-fa-book" :face nerd-icons-blue) - ;; (meson-mode nerd-icons-fileicon "meson" :face nerd-icons-purple) - ;; (man-common nerd-icons-fileicon "man-page" :face nerd-icons-blue) - (heex-mode nerd-icons-sucicon "nf-seti-elixir" :face nerd-icons-lorange) - (heex-ts-mode nerd-icons-sucicon "nf-seti-elixir" :face nerd-icons-lorange) - (julia-mode nerd-icons-sucicon "nf-seti-julia" :face nerd-icons-purple) - (julia-ts-mode nerd-icons-sucicon "nf-seti-julia" :face nerd-icons-purple) - (flycheck-error-list nerd-icons-faicon "nf-fa-list_alt" :face nerd-icons-lred))) - -(defvar nerd-icons-url-alist - '( - ;; Social media and communities - ("^\\(https?://\\)?\\(www\\.\\)?del\\.icio\\.us" nerd-icons-faicon "nf-fa-delicious") - ("^\\(https?://\\)?\\(www\\.\\)?behance\\.net" nerd-icons-faicon "nf-fa-behance") - ("^\\(https?://\\)?\\(www\\.\\)?dribbble\\.com" nerd-icons-faicon "nf-fa-dribbble") - ("^\\(https?://\\)?\\(www\\.\\)?facebook\\.com" nerd-icons-faicon "nf-fa-facebook_official") - ("^\\(https?://\\)?\\(www\\.\\)?glide\\.me" nerd-icons-faicon "nf-fa-glide_g") - ("^\\(https?://\\)?\\(www\\.\\)?plus\\.google\\.com" nerd-icons-faicon "nf-fa-google_plus") - ("linkedin\\.com" nerd-icons-faicon "nf-fa-linkedin") - ("^\\(https?://\\)?\\(www\\.\\)?ok\\.ru" nerd-icons-faicon "nf-fa-odnoklassniki") - ("^\\(https?://\\)?\\(www\\.\\)?reddit\\.com" nerd-icons-faicon "nf-fa-reddit_alien") - ("^\\(https?://\\)?\\(www\\.\\)?slack\\.com" nerd-icons-faicon "nf-fa-slack") - ("^\\(https?://\\)?\\(www\\.\\)?snapchat\\.com" nerd-icons-faicon "nf-fa-snapchat_ghost") - ("^\\(https?://\\)?\\(www\\.\\)?weibo\\.com" nerd-icons-faicon "nf-fa-weibo") - ("^\\(https?://\\)?\\(www\\.\\)?twitter\\.com" nerd-icons-faicon "nf-fa-twitter") - ;; Blogging - ("joomla\\.org" nerd-icons-faicon "nf-fa-joomla") - ("^\\(https?://\\)?\\(www\\.\\)?medium\\.com" nerd-icons-faicon "nf-fa-medium") - ("tumblr\\.com" nerd-icons-faicon "nf-fa-tumblr") - ("^wordpress\\.com" nerd-icons-faicon "nf-fa-wordpress") - ;; Programming - ("^\\(https?://\\)?\\(www\\.\\)?bitbucket\\.org" nerd-icons-faicon "nf-fa-bitbucket") - ("^\\(https?://\\)?\\(www\\.\\)?codepen\\.io" nerd-icons-faicon "nf-fa-codepen") - ("^\\(https?://\\)?\\(www\\.\\)?codiepie\\.com" nerd-icons-faicon "nf-fa-codiepie") - ("^\\(https?://\\)?\\(www\\.\\)?gist\\.github\\.com" nerd-icons-octicon "nf-oct-logo_gist") - ("^\\(https?://\\)?\\(www\\.\\)?github\\.com" nerd-icons-octicon "nf-oct-mark_github") - ("^\\(https?://\\)?\\(www\\.\\)?gitlab\\.com" nerd-icons-faicon "nf-fa-gitlab") - ("^\\(https?://\\)?\\(www\\.\\)?news\\.ycombinator\\.com" nerd-icons-faicon "nf-fa-hacker_news") - ("^\\(https?://\\)?\\(www\\.\\)?jsfiddle\\.net" nerd-icons-faicon "nf-fa-jsfiddle") - ("^\\(https?://\\)?\\(www\\.\\)?maxcdn\\.com" nerd-icons-faicon "nf-fa-maxcdn") - ("^\\(https?://\\)?\\(www\\.\\)?stackoverflow\\.com" nerd-icons-faicon "nf-fa-stack_overflow") - ;; Video - ("^\\(https?://\\)?\\(www\\.\\)?twitch\\.tv" nerd-icons-faicon "nf-fa-twitch") - ("^\\(https?://\\)?\\(www\\.\\)?vimeo\\.com" nerd-icons-faicon "nf-fa-vimeo") - ("^\\(https?://\\)?\\(www\\.\\)?youtube\\.com" nerd-icons-faicon "nf-fa-youtube") - ("^\\(https?://\\)?\\(www\\.\\)?youtu\\.be" nerd-icons-faicon "nf-fa-youtube") - ("^\\(https?://\\)?\\(www\\.\\)?vine\\.co" nerd-icons-faicon "nf-fa-vine") - ;; Sound - ("^\\(https?://\\)?\\(www\\.\\)?last\\.fm" nerd-icons-faicon "nf-fa-lastfm") - ("^\\(https?://\\)?\\(www\\.\\)?mixcloud\\.com" nerd-icons-faicon "nf-fa-mixcloud") - ("^\\(https?://\\)?\\(www\\.\\)?soundcloud\\.com" nerd-icons-faicon "nf-fa-soundcloud") - ("spotify\\.com" nerd-icons-faicon "nf-fa-spotify") - ;; Shopping - ("^\\(https?://\\)?\\(www\\.\\)?amazon\\." nerd-icons-faicon "nf-fa-amazon") - ("^\\(https?://\\)?\\(www\\.\\)?opencart\\.com" nerd-icons-faicon "nf-fa-opencart") - ("^\\(https?://\\)?\\(www\\.\\)?paypal\\.com" nerd-icons-faicon "nf-fa-paypal") - ("^\\(https?://\\)?\\(www\\.\\)?shirtsinbulk\\.com" nerd-icons-faicon "nf-fa-shitsinbulk") - ;; Images - ("^\\(https?://\\)?\\(www\\.\\)?500px\\.com" nerd-icons-faicon "nf-fa-500px") - ("^\\(https?://\\)?\\(www\\.\\)?deviantart\\.com" nerd-icons-faicon "nf-fa-deviantart") - ("^\\(https?://\\)?\\(www\\.\\)?flickr\\.com" nerd-icons-faicon "nf-fa-flickr") - ("^\\(https?://\\)?\\(www\\.\\)?instagram\\.com" nerd-icons-faicon "nf-fa-instagram") - ("^\\(https?://\\)?\\(www\\.\\)?pinterest\\." nerd-icons-faicon "nf-fa-pinterest") - ;; Information and books - ("^\\(https?://\\)?\\(www\\.\\)?digg\\.com" nerd-icons-faicon "nf-fa-digg") - ("^\\(https?://\\)?\\(www\\.\\)?foursquare\\.com" nerd-icons-faicon "nf-fa-foursquare") - ("^\\(https?://\\)?\\(www\\.\\)?getpocket\\.com" nerd-icons-faicon "nf-fa-get_pocket") - ("^\\(https?://\\)?\\(www\\.\\)?scribd\\.com" nerd-icons-faicon "nf-fa-scribd") - ("^\\(https?://\\)?\\(www\\.\\)?slideshare\\.net" nerd-icons-faicon "nf-fa-slideshare") - ("stackexchange\\.com" nerd-icons-faicon "nf-fa-stack_exchange") - ("^\\(https?://\\)?\\(www\\.\\)?stumbleupon\\.com" nerd-icons-faicon "nf-fa-stumbleupon") - ("^\\(https?://\\)?\\(www\\.\\)?tripadvisor\\." nerd-icons-faicon "nf-fa-tripadvisor") - ("^\\(https?://\\)?\\(www\\.\\)?yelp\\." nerd-icons-faicon "nf-fa-yelp") - - ("wikipedia\\.org" nerd-icons-faicon "nf-fa-wikipedia_w") - ;; Various companies and tools - ("^\\(https?://\\)?\\(www\\.\\)?angel\\.co" nerd-icons-faicon "nf-fa-angellist") - ("^\\(https?://\\)?\\(www\\.\\)?apple\\.com" nerd-icons-faicon "nf-fa-apple") - ("^\\(https?://\\)?\\(www\\.\\)?buysellads\\.com" nerd-icons-faicon "nf-fa-buysellads") - ("^\\(https?://\\)?\\(www\\.\\)?connectdevelop\\.com" nerd-icons-faicon "nf-fa-connectdevelop") - ("^\\(https?://\\)?\\(www\\.\\)?dashcube\\.com" nerd-icons-faicon "nf-fa-dashcube") - ("^\\(https?://\\)?\\(www\\.\\)?dropbox\\.com" nerd-icons-faicon "nf-fa-dropbox") - ("^\\(https?://\\)?\\(www\\.\\)?enviragallery\\.com" nerd-icons-faicon "nf-fa-envira") - ("^\\(https?://\\)?\\(www\\.\\)?fortawesome\\.com" nerd-icons-faicon "nf-fa-fort_awesome") - ("^\\(https?://\\)?\\(www\\.\\)?forumbee\\.com" nerd-icons-faicon "nf-fa-forumbee") - ("^\\(https?://\\)?\\(www\\.\\)?gratipay\\.com" nerd-icons-faicon "nf-fa-gratipay") - ("^\\(https?://\\)?\\(www\\.\\)?modx\\.com" nerd-icons-faicon "nf-fa-modx") - ("^\\(https?://\\)?\\(www\\.\\)?pagelines\\.com" nerd-icons-faicon "nf-fa-pagelines") - ("^\\(https?://\\)?\\(www\\.\\)?producthunt\\.com" nerd-icons-faicon "nf-fa-product_hunt") - ("sellsy\\.com" nerd-icons-faicon "nf-fa-sellsy") - ("^\\(https?://\\)?\\(www\\.\\)?simplybuilt\\.com" nerd-icons-faicon "nf-fa-simplybuilt") - ("^\\(https?://\\)?\\(www\\.\\)?skyatlas\\.com" nerd-icons-faicon "nf-fa-skyatlas") - ("^\\(https?://\\)?\\(www\\.\\)?skype\\.com" nerd-icons-faicon "nf-fa-skype") - ("steampowered\\.com" nerd-icons-faicon "nf-fa-steam") - ("^\\(https?://\\)?\\(www\\.\\)?themeisle\\.com" nerd-icons-faicon "nf-fa-themeisle") - ("^\\(https?://\\)?\\(www\\.\\)?trello\\.com" nerd-icons-faicon "nf-fa-trello") - ("^\\(https?://\\)?\\(www\\.\\)?whatsapp\\.com" nerd-icons-faicon "nf-fa-whatsapp") - ("^\\(https?://\\)?\\(www\\.\\)?ycombinator\\.com" nerd-icons-faicon "nf-fa-y_combinator") - ("yahoo\\.com" nerd-icons-faicon "nf-fa-yahoo") - ("^\\(https?://\\)?\\(www\\.\\)?yoast\\.com" nerd-icons-faicon "nf-fa-yoast") - ;; Catch all - ("android" nerd-icons-faicon "nf-fa-android") - ("creativecommons" nerd-icons-faicon "nf-fa-creative_commons") - ("forums?" nerd-icons-codicon "nf-cod-comment_discussion") - ("\\.pdf$" nerd-icons-codicon "nf-cod-file_pdf" :face nerd-icons-dred) - ("google" nerd-icons-faicon "nf-fa-google") - ("\\.rss" nerd-icons-faicon "nf-fa-rss"))) - -(defun nerd-icons-auto-mode-match? (&optional file) - "Whether or not FILE's `major-mode' match against its `auto-mode-alist'." - (let* ((file (or file (buffer-file-name) (buffer-name))) - (auto-mode (nerd-icons-match-to-alist file auto-mode-alist))) - (eq major-mode auto-mode))) - -(defun nerd-icons-match-to-alist (file alist) - "Match FILE against an entry in ALIST using `string-match'." - (cdr (cl-find-if (lambda (it) (string-match (car it) file)) alist))) - -(defun nerd-icons-dir-is-submodule (dir) - "Checker whether or not DIR is a git submodule." - (let* ((gitmodule-dir (locate-dominating-file dir ".gitmodules")) - (modules-file (expand-file-name (format "%s.gitmodules" gitmodule-dir))) - (module-search (format "submodule \".*?%s\"" (file-name-base dir)))) - - (when (and gitmodule-dir (file-exists-p (format "%s/.git" dir))) - (with-temp-buffer - (insert-file-contents modules-file) - (search-forward-regexp module-search (point-max) t))))) - -(defun nerd-icons--read-candidates () - "Helper to build a list of candidates for all glyph sets." - (cl-reduce 'append (mapcar (lambda (it) (nerd-icons--read-candidates-for-glyph-set it t)) nerd-icons-glyph-sets))) - -(defun nerd-icons--read-candidates-for-glyph-set (glyph-set &optional show-glyph-set) - "Helper to build read candidates for GLYPH-SET. - -If SHOW-GLYPH-SET is non-nil, displays the icons glyph set in the candidate -string." - (let ((data (funcall (nerd-icons--data-name glyph-set))) - (icon-f (nerd-icons--function-name glyph-set))) - (mapcar - (lambda (it) - (let* ((icon-name (car it)) - - (icon-display (funcall icon-f icon-name)) - (icon-glyph-set (if show-glyph-set (format "\t[%s]" glyph-set) "")) - - (candidate-name (format "%s\t%s%s" icon-display icon-name icon-glyph-set)) - (candidate-icon (funcall (nerd-icons--function-name glyph-set) icon-name))) - (cons candidate-name candidate-icon))) - data))) - -;;;###autoload -(defun nerd-icons-install-fonts (&optional pfx) - "Helper function to download and install the latests fonts based on OS. -The provided Nerd Font is Symbols Nerd Font Mono. -When PFX is non-nil, ignore the prompt and just install" - (interactive "P") - (when (or pfx (yes-or-no-p "This will download and install fonts, are you sure you want to do this?")) - (let* ((url-format "https://raw.githubusercontent.com/rainstormstudio/nerd-icons.el/main/fonts/%s") - (font-dest (cond - ;; Default Linux install directories - ((member system-type '(gnu gnu/linux gnu/kfreebsd)) - (concat (or (getenv "XDG_DATA_HOME") - (concat (getenv "HOME") "/.local/share")) - "/fonts/" - nerd-icons-fonts-subdirectory)) - ;; Default MacOS install directory - ((eq system-type 'darwin) - (concat (getenv "HOME") - "/Library/Fonts/" - nerd-icons-fonts-subdirectory)))) - (known-dest? (stringp font-dest)) - (font-dest (or font-dest (read-directory-name "Font installation directory: " "~/")))) - - (unless (file-directory-p font-dest) (mkdir font-dest t)) - - (mapc (lambda (font) - (url-copy-file (format url-format font) (expand-file-name font font-dest) t)) - nerd-icons-font-names) - (when known-dest? - (message "Fonts downloaded, updating font cache... <fc-cache -f -v> ") - (shell-command-to-string (format "fc-cache -f -v"))) - (message "%s Successfully %s `nerd-icons' fonts to `%s'!" - (nerd-icons-wicon "nf-weather-stars" :v-adjust 0.0) - (if known-dest? "installed" "downloaded") - font-dest)))) - -;;;###autoload -(defun nerd-icons-insert (&optional arg glyph-set) - "Interactive icon insertion function. -When Prefix ARG is non-nil, insert the propertized icon. -When GLYPH-SET is non-nil, limit the candidates to the icon set matching it." - (interactive "P") - (let* ((standard-output (current-buffer)) - (candidates (if glyph-set - (nerd-icons--read-candidates-for-glyph-set glyph-set) - (nerd-icons--read-candidates))) - (prompt (if glyph-set - (format "%s Icon: " (funcall (nerd-icons--glyph-set-name glyph-set))) - "Icon : ")) - (selection (completing-read prompt candidates nil t)) - (result (cdr (assoc selection candidates)))) - - (if arg (prin1 result) (insert result)))) - -;;;###autoload -(defun nerd-icons-icon-for-dir (dir &rest arg-overrides) - "Get the formatted icon for DIR. -ARG-OVERRIDES should be a plist containining `:height', -`:v-adjust' or `:face' properties like in the normal icon -inserting functions." - (let* ((dir (or dir default-directory "/")) - (dirname (file-name-base (directory-file-name dir))) - (path (if (file-name-absolute-p dir) dir (expand-file-name dir))) - (icon (nerd-icons-match-to-alist dirname nerd-icons-dir-icon-alist)) - (args (cdr icon))) - (when arg-overrides (setq args (append `(,(car args)) arg-overrides (cdr args)))) - (cond - ((file-remote-p path) - (apply #'nerd-icons-codicon "nf-cod-remote" (cdr args))) - ((file-symlink-p path) - (apply #'nerd-icons-codicon "nf-cod-file_symlink_directory" (cdr args))) - ((nerd-icons-dir-is-submodule path) - (apply #'nerd-icons-codicon "nf-cod-file_submodule" (cdr args))) - ((file-exists-p (format "%s/.git" path)) - (apply #'nerd-icons-octicon "nf-oct-repo" (cdr args))) - (t (apply (car icon) args))))) - -;;;###autoload -(defun nerd-icons-icon-for-file (file &rest arg-overrides) - "Get the formatted icon for FILE. -ARG-OVERRIDES should be a plist containining `:height', -`:v-adjust' or `:face' properties like in the normal icon -inserting functions." - (let* ((name (file-name-nondirectory file)) - (ext (file-name-extension name)) - (icon (or (nerd-icons-match-to-alist name nerd-icons-regexp-icon-alist) - (and ext - (cdr (assoc (downcase ext) - nerd-icons-extension-icon-alist))) - nerd-icons-default-file-icon)) - (args (cdr icon))) - (when arg-overrides (setq args (append `(,(car args)) arg-overrides (cdr args)))) - (apply (car icon) args))) - -;;;###autoload -(defun nerd-icons-icon-for-extension (ext &rest arg-overrides) - "Get the formatted icon for EXT. -ARG-OVERRIDES should be a plist containining `:height', -`:v-adjust' or `:face' properties like in the normal icon -inserting functions." - (let* ((icon (or - (and ext - (cdr (assoc (downcase ext) - nerd-icons-extension-icon-alist))) - nerd-icons-default-file-icon)) - (args (cdr icon))) - (when arg-overrides (setq args (append `(,(car args)) arg-overrides (cdr args)))) - (apply (car icon) args))) - -;;;###autoload -(defun nerd-icons-icon-for-mode (mode &rest arg-overrides) - "Get the formatted icon for MODE. -ARG-OVERRIDES should be a plist containining `:height', -`:v-adjust' or `:face' properties like in the normal icon -inserting functions." - (let* ((icon (or (cdr (or (assoc mode nerd-icons-mode-icon-alist) - (assoc (get mode 'derived-mode-parent) nerd-icons-mode-icon-alist))) - nerd-icons-default-file-icon)) - (args (cdr icon))) - (when arg-overrides (setq args (append `(,(car args)) arg-overrides (cdr args)))) - (if icon (apply (car icon) args) mode))) - -;;;###autoload -(defun nerd-icons-icon-for-url (url &rest arg-overrides) - "Get the formatted icon for URL. -If an icon for URL isn't found in `nerd-icons-url-alist', a globe is used. -ARG-OVERRIDES should be a plist containining `:height', -`:v-adjust' or `:face' properties like in the normal icon -inserting functions." - (let* ((icon (nerd-icons-match-to-alist url nerd-icons-url-alist)) - (args (cdr icon))) - (unless icon - (setq icon '(nerd-icons-faicon "nf-fa-globe")) - (setq args (cdr icon))) - (when arg-overrides (setq args (append `(,(car args)) arg-overrides (cdr args)))) - (apply (car icon) args))) - -;;;###autoload -(defun nerd-icons-icon-for-buffer () - "Get the formatted icon for the current buffer. - -This function prioritises the use of the buffers file extension to -discern the icon when its `major-mode' matches its auto mode, -otherwise it will use the buffers `major-mode' to decide its -icon." - (nerd-icons--icon-info-for-buffer)) - -(defun nerd-icons-cache (func) - "Set a cache for FUNC. Does not work on interactive functions." - (unless (get func 'nerd-icons--cached) - (let ((cache (make-hash-table :test #'equal - :size nerd-icons--cache-limit)) - (orig-fn (symbol-function func))) - (fset func - (lambda (&rest args) - (or (gethash args cache) - (progn - (when (> (hash-table-count cache) - nerd-icons--cache-limit) - (clrhash cache)) - (puthash args (apply orig-fn args) cache))))))) - - (put func 'nerd-icons--cached t)) - -(nerd-icons-cache #'nerd-icons-icon-for-dir) -(nerd-icons-cache #'nerd-icons-icon-for-file) -(nerd-icons-cache #'nerd-icons-icon-for-extension) -(nerd-icons-cache #'nerd-icons-icon-for-mode) -(nerd-icons-cache #'nerd-icons-icon-for-url) - -(defun nerd-icons--icon-info-for-buffer (&optional f) - "Get icon info for the current buffer. -When F is provided, the info function is calculated with the format -`nerd-icons-icon-%s-for-file' or `nerd-icons-icon-%s-for-mode'." - (let* ((base-f (concat "nerd-icons-icon" (when f (format "-%s" f)))) - (file-f (intern (concat base-f "-for-file"))) - (mode-f (intern (concat base-f "-for-mode")))) - (if (and (buffer-file-name) - (nerd-icons-auto-mode-match?)) - (funcall file-f (file-name-nondirectory (buffer-file-name))) - (funcall mode-f major-mode)))) - -;; Weather icons -(defun nerd-icons-icon-for-weather (weather) - "Get an icon for a WEATHER status." - (let ((icon (nerd-icons-match-to-alist weather nerd-icons-weather-icon-alist))) - (if icon (apply (car icon) (cdr icon)) weather))) - -;; For `web-mode' -(defun nerd-icons--web-mode-icon (&rest arg-overrides) - "Get icon for a `web-mode' buffer with ARG-OVERRIDES." - (nerd-icons--web-mode arg-overrides)) -(defun nerd-icons--web-mode-icon-family () - "Get icon family for a `web-mode' buffer." - (nerd-icons--web-mode t)) - -(defvar web-mode-content-type) ; external -(defun nerd-icons--web-mode (&optional arg-overrides) - "Return icon or FAMILY for `web-mode' based on `web-mode-content-type'. -Providing ARG-OVERRIDES will modify the creation of the icon." - (let ((non-nil-args (cl-reduce (lambda (acc it) (if it (append acc (list it)) acc)) - arg-overrides :initial-value '()))) - (cond - ((equal web-mode-content-type "jsx") - (apply 'nerd-icons-devicon (append '("javascript") non-nil-args))) - ((equal web-mode-content-type "javascript") - (apply 'nerd-icons-devicon (append '("javascript") non-nil-args))) - ((equal web-mode-content-type "json") - (apply 'nerd-icons-devicon (append '("nf-dev-less") non-nil-args))) - ((equal web-mode-content-type "xml") - (apply 'nerd-icons-faicon (append '("nf-fa-file_code_o") non-nil-args))) - ((equal web-mode-content-type "css") - (apply 'nerd-icons-devicon (append '("nf-dev-css3") non-nil-args))) - (t - (apply 'nerd-icons-devicon (append '("nf-dev-html5") non-nil-args)))))) - -(eval-and-compile - (defun nerd-icons--function-name (name) - "Get the symbol for an icon function name for icon set NAME." - (intern (concat "nerd-icons-" (downcase (symbol-name name))))) - - (defun nerd-icons--family-name (name) - "Get the symbol for an icon family function for icon set NAME." - (intern (concat "nerd-icons-" (downcase (symbol-name name)) "-family"))) - - (defun nerd-icons--glyph-set-name (name) - "Get the symbol for an icon glyph set function for icon set NAME." - (intern (concat "nerd-icons-" (downcase (symbol-name name)) "-glyph-set"))) - - (defun nerd-icons--data-name (name) - "Get the symbol for an icon family function for icon set NAME." - (intern (concat "nerd-icons-" (downcase (symbol-name name)) "-data"))) - - (defun nerd-icons--insert-function-name (name) - "Get the symbol for an icon insert function for icon set NAME." - (intern (concat "nerd-icons-insert-" (downcase (symbol-name name)))))) - -(defun nerd-icons-insert-icons-for (family &optional height duration) - "Insert all of the available icons associated with FAMILY. -If a HEIGHT is provided it will render the icons at this height. -This is useful both to see the icons more clearly and to test -different height rendering. If DURATION is provided, it will -pause for DURATION seconds between printing each character." - (let* ((data-f (nerd-icons--data-name family)) - (insert-f (nerd-icons--function-name family)) - - (height (or height 1.0)) - (data (funcall data-f))) - (mapc - (lambda (it) - (insert (format "%s - %s\n" (funcall insert-f (car it) :height height) (car it))) - (when duration (sit-for duration))) - data))) - -(defun nerd-icons-set-font (&optional font-family frame) - "Modify nerd font charsets to use FONT-FAMILY for FRAME." - (let ((font-f (or font-family nerd-icons-font-family)) - (charsets '((#xe5fa . #xe6b2) ;; Seti-UI + Custom - (#xe700 . #xe7c5) ;; Devicons - (#xf000 . #xf2e0) ;; Font Awesome - (#xe200 . #xe2a9) ;; Font Awesome Extension - (#xf500 . #xfd46) (#xf0001 . #xf1af0) ;; Material Design Icons - (#xe300 . #xe3eb) ;; Weather - (#xf400 . #xf4a8) #x2665 #x26a1 #xf27c ;; Octicons - (#xe0a0 . #xe0a2) (#xe0b0 . #xe0b3) ;; Powerline Symbols - #xe0a3 (#xe0b4 . #xe0c8) (#xe0cc . #xe0d2) #xe0d4 ;; Powerline Extra Symbols - (#x23fb . #x23fe) #x2b58 ;; IEC Power Symbols - (#xf300 . #xf372) ;; Font Logos - (#xe000 . #xe00a) ;; Pomicons - (#xea60 . #xebeb)))) ;; Codicons - (cl-loop for charset in charsets do - (set-fontset-font - (frame-parameter nil 'font) - charset - (font-spec :family font-f - :weight nil - :size nil) - frame - 'prepend)))) - -(defmacro nerd-icons-define-icon (name alist family glyph-set) - "Macro to generate functions for inserting icons for icon set NAME. - -NAME defines is the name of the iconset and will produce a -function of the for `nerd-icon-NAME'. - -ALIST is the alist containing maps between icon names and the -UniCode for the character. All of these can be found in the data -directory of this package. - -FAMILY is the font family to use for the icons. -GLYPH-SET is the glyph set of the icon." - `(progn - (add-to-list 'nerd-icons-glyph-sets (quote ,name)) - (defun ,(nerd-icons--family-name name) () ,family) - (defun ,(nerd-icons--glyph-set-name name) () ,glyph-set) - (defun ,(nerd-icons--data-name name) () ,alist) - (defun ,(nerd-icons--function-name name) (icon-name &rest args) - (let ((icon (cdr (assoc icon-name ,alist))) - (other-face (when nerd-icons-color-icons (plist-get args :face))) - (height (* nerd-icons-scale-factor (or (plist-get args :height) 1.0))) - (v-adjust (* nerd-icons-scale-factor (or (plist-get args :v-adjust) nerd-icons-default-adjust))) - (family ,family)) - (unless icon - (error "Unable to find icon with name `%s' in icon set `%s'" icon-name (quote ,name))) - (let ((face (if other-face - `(:family ,family :height ,height :inherit ,other-face) - `(:family ,family :height ,height)))) - (propertize icon - 'face face - 'font-lock-face face - 'display `(raise ,v-adjust) - 'rear-nonsticky t)))) - (defun ,(nerd-icons--insert-function-name name) (&optional arg) - ,(format "Insert a %s icon at point." glyph-set) - (interactive "P") - (nerd-icons-insert arg (quote ,name))))) - -(nerd-icons-define-icon ipsicon nerd-icons/ipsicon-alist nerd-icons-font-family "IEC Power Symbols") -(nerd-icons-define-icon octicon nerd-icons/octicon-alist nerd-icons-font-family "Octicons") -(nerd-icons-define-icon pomicon nerd-icons/pomicon-alist nerd-icons-font-family "Pomicons") -(nerd-icons-define-icon powerline nerd-icons/powerline-alist nerd-icons-font-family "Powerline Symbols") -(nerd-icons-define-icon faicon nerd-icons/faicon-alist nerd-icons-font-family "Font Awesome") -(nerd-icons-define-icon wicon nerd-icons/wicon-alist nerd-icons-font-family "Weather") -(nerd-icons-define-icon sucicon nerd-icons/sucicon-alist nerd-icons-font-family "Seti-UI + Custom") -(nerd-icons-define-icon devicon nerd-icons/devicon-alist nerd-icons-font-family "Devicons") -(nerd-icons-define-icon codicon nerd-icons/codicon-alist nerd-icons-font-family "Codicons") -(nerd-icons-define-icon flicon nerd-icons/flicon-alist nerd-icons-font-family "Font Logos") -(nerd-icons-define-icon mdicon nerd-icons/mdicon-alist nerd-icons-font-family "Material Design Icons") - -(provide 'nerd-icons) -;;; nerd-icons.el ends here diff --git a/emacs/elpa/nerd-icons-20240520.1050/nerd-icons.elc b/emacs/elpa/nerd-icons-20240520.1050/nerd-icons.elc Binary files differ. diff --git a/emacs/elpa/nerd-icons-20240520.1050/data/nerd-icons-data-codicon.el b/emacs/elpa/nerd-icons-20240524.311/data/nerd-icons-data-codicon.el diff --git a/emacs/elpa/nerd-icons-20240520.1050/data/nerd-icons-data-codicon.elc b/emacs/elpa/nerd-icons-20240524.311/data/nerd-icons-data-codicon.elc Binary files differ. diff --git a/emacs/elpa/nerd-icons-20240520.1050/data/nerd-icons-data-devicon.el b/emacs/elpa/nerd-icons-20240524.311/data/nerd-icons-data-devicon.el diff --git a/emacs/elpa/nerd-icons-20240520.1050/data/nerd-icons-data-devicon.elc b/emacs/elpa/nerd-icons-20240524.311/data/nerd-icons-data-devicon.elc Binary files differ. diff --git a/emacs/elpa/nerd-icons-20240520.1050/data/nerd-icons-data-faicon.el b/emacs/elpa/nerd-icons-20240524.311/data/nerd-icons-data-faicon.el diff --git a/emacs/elpa/nerd-icons-20240520.1050/data/nerd-icons-data-faicon.elc b/emacs/elpa/nerd-icons-20240524.311/data/nerd-icons-data-faicon.elc Binary files differ. diff --git a/emacs/elpa/nerd-icons-20240520.1050/data/nerd-icons-data-flicon.el b/emacs/elpa/nerd-icons-20240524.311/data/nerd-icons-data-flicon.el diff --git a/emacs/elpa/nerd-icons-20240520.1050/data/nerd-icons-data-flicon.elc b/emacs/elpa/nerd-icons-20240524.311/data/nerd-icons-data-flicon.elc Binary files differ. diff --git a/emacs/elpa/nerd-icons-20240520.1050/data/nerd-icons-data-ipsicon.el b/emacs/elpa/nerd-icons-20240524.311/data/nerd-icons-data-ipsicon.el diff --git a/emacs/elpa/nerd-icons-20240520.1050/data/nerd-icons-data-ipsicon.elc b/emacs/elpa/nerd-icons-20240524.311/data/nerd-icons-data-ipsicon.elc Binary files differ. diff --git a/emacs/elpa/nerd-icons-20240520.1050/data/nerd-icons-data-mdicon.el b/emacs/elpa/nerd-icons-20240524.311/data/nerd-icons-data-mdicon.el diff --git a/emacs/elpa/nerd-icons-20240520.1050/data/nerd-icons-data-mdicon.elc b/emacs/elpa/nerd-icons-20240524.311/data/nerd-icons-data-mdicon.elc Binary files differ. diff --git a/emacs/elpa/nerd-icons-20240520.1050/data/nerd-icons-data-octicon.el b/emacs/elpa/nerd-icons-20240524.311/data/nerd-icons-data-octicon.el diff --git a/emacs/elpa/nerd-icons-20240520.1050/data/nerd-icons-data-octicon.elc b/emacs/elpa/nerd-icons-20240524.311/data/nerd-icons-data-octicon.elc Binary files differ. diff --git a/emacs/elpa/nerd-icons-20240520.1050/data/nerd-icons-data-pomicon.el b/emacs/elpa/nerd-icons-20240524.311/data/nerd-icons-data-pomicon.el diff --git a/emacs/elpa/nerd-icons-20240520.1050/data/nerd-icons-data-pomicon.elc b/emacs/elpa/nerd-icons-20240524.311/data/nerd-icons-data-pomicon.elc Binary files differ. diff --git a/emacs/elpa/nerd-icons-20240520.1050/data/nerd-icons-data-powerline.el b/emacs/elpa/nerd-icons-20240524.311/data/nerd-icons-data-powerline.el diff --git a/emacs/elpa/nerd-icons-20240520.1050/data/nerd-icons-data-powerline.elc b/emacs/elpa/nerd-icons-20240524.311/data/nerd-icons-data-powerline.elc Binary files differ. diff --git a/emacs/elpa/nerd-icons-20240520.1050/data/nerd-icons-data-sucicon.el b/emacs/elpa/nerd-icons-20240524.311/data/nerd-icons-data-sucicon.el diff --git a/emacs/elpa/nerd-icons-20240520.1050/data/nerd-icons-data-sucicon.elc b/emacs/elpa/nerd-icons-20240524.311/data/nerd-icons-data-sucicon.elc Binary files differ. diff --git a/emacs/elpa/nerd-icons-20240520.1050/data/nerd-icons-data-wicon.el b/emacs/elpa/nerd-icons-20240524.311/data/nerd-icons-data-wicon.el diff --git a/emacs/elpa/nerd-icons-20240520.1050/data/nerd-icons-data-wicon.elc b/emacs/elpa/nerd-icons-20240524.311/data/nerd-icons-data-wicon.elc Binary files differ. diff --git a/emacs/elpa/nerd-icons-20240520.1050/nerd-icons-autoloads.el b/emacs/elpa/nerd-icons-20240524.311/nerd-icons-autoloads.el diff --git a/emacs/elpa/nerd-icons-20240520.1050/nerd-icons-data.el b/emacs/elpa/nerd-icons-20240524.311/nerd-icons-data.el diff --git a/emacs/elpa/nerd-icons-20240520.1050/nerd-icons-data.elc b/emacs/elpa/nerd-icons-20240524.311/nerd-icons-data.elc Binary files differ. diff --git a/emacs/elpa/nerd-icons-20240520.1050/nerd-icons-faces.el b/emacs/elpa/nerd-icons-20240524.311/nerd-icons-faces.el diff --git a/emacs/elpa/nerd-icons-20240520.1050/nerd-icons-faces.elc b/emacs/elpa/nerd-icons-20240524.311/nerd-icons-faces.elc Binary files differ. diff --git a/emacs/elpa/nerd-icons-20240524.311/nerd-icons-pkg.el b/emacs/elpa/nerd-icons-20240524.311/nerd-icons-pkg.el @@ -0,0 +1,14 @@ +(define-package "nerd-icons" "20240524.311" "Emacs Nerd Font Icons Library" + '((emacs "24.3")) + :commit "3dac80b712fb3043ec2bd7510f587548074484a3" :authors + '(("Hongyu Ding <rainstormstudio@yahoo.com>, Vincent Zhang" . "seagle0128@gmail.com")) + :maintainers + '(("Hongyu Ding <rainstormstudio@yahoo.com>, Vincent Zhang" . "seagle0128@gmail.com")) + :maintainer + '("Hongyu Ding <rainstormstudio@yahoo.com>, Vincent Zhang" . "seagle0128@gmail.com") + :keywords + '("lisp") + :url "https://github.com/rainstormstudio/nerd-icons.el") +;; Local Variables: +;; no-byte-compile: t +;; End: diff --git a/emacs/elpa/nerd-icons-20240524.311/nerd-icons.el b/emacs/elpa/nerd-icons-20240524.311/nerd-icons.el @@ -0,0 +1,1316 @@ +;;; nerd-icons.el --- Emacs Nerd Font Icons Library -*- lexical-binding: t -*- + +;; Copyright (C) 2023 Hongyu Ding <rainstormstudio@yahoo.com> + +;; Author: Hongyu Ding <rainstormstudio@yahoo.com>, Vincent Zhang <seagle0128@gmail.com> +;; Keywords: lisp +;; Version: 0.1.0 +;; Package-Requires: ((emacs "24.3")) +;; URL: https://github.com/rainstormstudio/nerd-icons.el +;; Keywords: convenient, lisp + +;; 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/>. + +;;; Commentary: + +;; This package was inspired by + +;; - `all-the-icons', found at https://github.com/Alexander-Miller/treemacs/blob/master/src/extra/treemacs-all-the-icons.el +;; - `vim-devicons' for Vim, found at https://github.com/ryanoasis/vim-devicons +;; - `nvim-web-devicons' for NeoVim, found at https://github.com/nvim-tree/nvim-web-devicons + +;; This package provides an interface to the Nerd Fonts + +;; - `nerd-fonts', found at https://github.com/ryanoasis/nerd-fonts + +;;; Code: + +(require 'cl-lib) + +(require 'nerd-icons-data) +(require 'nerd-icons-faces) + +(declare-function set-fontset-font "src/fontset.c") + +(defgroup nerd-icons nil + "Manage how Nerd Fonts formats icons." + :prefix "nerd-icons-" + :group 'appearance + :group 'convenience) + +(defcustom nerd-icons-color-icons t + "Whether or not to include a foreground color when formatting the icon." + :group 'nerd-icons + :type 'boolean) + +(defcustom nerd-icons-scale-factor 1.0 + "The base Scale Factor for the `height' face property of an icon." + :group 'nerd-icons + :type 'number) + +(defcustom nerd-icons-default-adjust 0.0 + "The default adjustment to be made to the `raise' display property of an icon." + :group 'nerd-icons + :type 'number) + +(defcustom nerd-icons--cache-limit 2048 + "Maximum cache size for functions cached by `nerd-icons-cache'." + :group 'nerd-icons + :type 'integer) + +(defcustom nerd-icons-font-family "Symbols Nerd Font Mono" + "The Nerd Font for display icons." + :group 'nerd-icons + :type 'string) + +(defcustom nerd-icons-fonts-subdirectory nil + "The subdirectory within the system fonts folder where the icons are installed." + :group 'nerd-icons + :type 'directory) + +(defvar nerd-icons-font-names '("NFM.ttf") + "List of defined font file names.") + +(defvar nerd-icons-glyph-sets '() "List of defined icon glyph sets.") + +(defvar nerd-icons-extension-icon-alist + '( + ("fish" nerd-icons-devicon "nf-dev-terminal" :face nerd-icons-lpink) + ("zsh" nerd-icons-devicon "nf-dev-terminal" :face nerd-icons-lcyan) + ("sh" nerd-icons-devicon "nf-dev-terminal" :face nerd-icons-purple) + ("bat" nerd-icons-codicon "nf-cod-terminal_cmd" :face nerd-icons-lsilver) + ("cmd" nerd-icons-codicon "nf-cod-terminal_cmd" :face nerd-icons-lsilver) + ;; Meta + ("tags" nerd-icons-octicon "nf-oct-tag" :face nerd-icons-blue) + ("log" nerd-icons-octicon "nf-oct-log" :face nerd-icons-maroon) + ;; Config + ("node" nerd-icons-devicon "nf-dev-nodejs_small" :face nerd-icons-green) + ("babelrc" nerd-icons-mdicon "nf-md-babel" :face nerd-icons-yellow) + ("bashrc" nerd-icons-mdicon "nf-md-bash" :face nerd-icons-dpink) + ("bowerrc" nerd-icons-devicon "nf-dev-bower" :face nerd-icons-silver) + ("cr" nerd-icons-sucicon "nf-seti-crystal" :face nerd-icons-yellow) + ("ecr" nerd-icons-sucicon "nf-seti-crystal" :face nerd-icons-yellow) + ("ini" nerd-icons-codicon "nf-cod-settings" :face nerd-icons-yellow) + ("properties" nerd-icons-codicon "nf-cod-settings" :face nerd-icons-yellow) + ("eslintignore" nerd-icons-mdicon "nf-md-eslint" :face nerd-icons-purple) + ("eslint" nerd-icons-mdicon "nf-md-eslint" :face nerd-icons-lpurple) + ("git" nerd-icons-sucicon "nf-seti-git" :face nerd-icons-lred) + ("gitattributes" nerd-icons-sucicon "nf-seti-git" :face nerd-icons-lred) + ("gitignore" nerd-icons-sucicon "nf-seti-git" :face nerd-icons-lred) + ("gitmodules" nerd-icons-sucicon "nf-seti-git" :face nerd-icons-lred) + ("mk" nerd-icons-devicon "nf-dev-gnu" :face nerd-icons-dorange) + ;; ("cmake" nerd-icons-devicon "cmake") TODO: cmake + ("dockerignore" nerd-icons-devicon "nf-dev-docker" :face nerd-icons-dblue) + ("xml" nerd-icons-faicon "nf-fa-file_code_o" :face nerd-icons-lorange) + ("json" nerd-icons-codicon "nf-cod-settings" :face nerd-icons-yellow) + ("jsonl" nerd-icons-codicon "nf-cod-settings" :face nerd-icons-yellow) + ("cson" nerd-icons-codicon "nf-cod-settings" :face nerd-icons-yellow) + ("yml" nerd-icons-codicon "nf-cod-settings" :face nerd-icons-dyellow) + ("yaml" nerd-icons-codicon "nf-cod-settings" :face nerd-icons-dyellow) + ("toml" nerd-icons-codicon "nf-cod-settings" :face nerd-icons-orange) + ("conf" nerd-icons-codicon "nf-cod-settings" :face nerd-icons-dorange) + ("editorconfig" nerd-icons-sucicon "nf-seti-editorconfig" :face nerd-icons-silver) + ;; ? + ("pkg" nerd-icons-octicon "nf-oct-package" :face nerd-icons-dsilver) + ("rpm" nerd-icons-octicon "nf-oct-package" :face nerd-icons-dsilver) + ("pkgbuild" nerd-icons-octicon "nf-oct-package" :face nerd-icons-dsilver) + ("elc" nerd-icons-octicon "nf-oct-file_binary" :face nerd-icons-dsilver) + ("eln" nerd-icons-octicon "nf-oct-file_binary" :face nerd-icons-dsilver) + ("gz" nerd-icons-octicon "nf-oct-file_binary" :face nerd-icons-lmaroon) + ("zip" nerd-icons-octicon "nf-oct-file_zip" :face nerd-icons-lmaroon) + ("7z" nerd-icons-octicon "nf-oct-file_zip" :face nerd-icons-lmaroon) + ("zst" nerd-icons-octicon "nf-oct-file_zip" :face nerd-icons-lmaroon) + ("dat" nerd-icons-faicon "nf-fa-bar_chart" :face nerd-icons-cyan) + ("dmg" nerd-icons-octicon "nf-oct-tools" :face nerd-icons-lsilver) + ("dll" nerd-icons-faicon "nf-fa-cogs" :face nerd-icons-silver) + ("ds_store" nerd-icons-faicon "nf-fa-cogs" :face nerd-icons-silver) + ("exe" nerd-icons-octicon "nf-oct-file_binary" :face nerd-icons-dsilver) + ("msg" nerd-icons-octicon "nf-oct-mail" :face nerd-icons-dsilver) + ;; Source Codes + ("ada" nerd-icons-sucicon "nf-custom-ada" :face nerd-icons-blue) + ("adb" nerd-icons-sucicon "nf-custom-ada" :face nerd-icons-blue) + ("adc" nerd-icons-sucicon "nf-custom-ada" :face nerd-icons-blue) + ("ads" nerd-icons-sucicon "nf-custom-ada" :face nerd-icons-blue) + ("gpr" nerd-icons-sucicon "nf-custom-ada" :face nerd-icons-green) + ("cgpr" nerd-icons-sucicon "nf-custom-ada" :face nerd-icons-green) + ("scpt" nerd-icons-devicon "nf-dev-apple" :face nerd-icons-pink) + ;; ("aup" nerd-icons-fileicon "audacity") TODO: audacity + ("elm" nerd-icons-sucicon "nf-seti-elm" :face nerd-icons-blue) + ("erl" nerd-icons-devicon "nf-dev-erlang" :face nerd-icons-red) + ("hrl" nerd-icons-devicon "nf-dev-erlang" :face nerd-icons-dred) + ("eex" nerd-icons-sucicon "nf-seti-elixir" :face nerd-icons-lorange) + ("leex" nerd-icons-sucicon "nf-seti-elixir" :face nerd-icons-lorange) + ("heex" nerd-icons-sucicon "nf-seti-elixir" :face nerd-icons-lorange) + ("ex" nerd-icons-sucicon "nf-seti-elixir" :face nerd-icons-lpurple) + ("exs" nerd-icons-sucicon "nf-seti-elixir" :face nerd-icons-lred) + ("livemd" nerd-icons-sucicon "nf-seti-elixir" :face nerd-icons-lblue) + ("java" nerd-icons-devicon "nf-dev-java" :face nerd-icons-purple) + ("groovy" nerd-icons-devicon "nf-dev-groovy" :face nerd-icons-cyan) + ("gradle" nerd-icons-sucicon "nf-seti-gradle" :face nerd-icons-silver) + ("ebuild" nerd-icons-mdicon "nf-md-gentoo" :face nerd-icons-cyan) + ("eclass" nerd-icons-mdicon "nf-md-gentoo" :face nerd-icons-blue) + ("go" nerd-icons-devicon "nf-dev-go" :face nerd-icons-blue) + ("jl" nerd-icons-sucicon "nf-seti-julia" :face nerd-icons-purple) + ("magik" nerd-icons-faicon "nf-fa-magic" :face nerd-icons-blue) + ;; ("matlab" nerd-icons-devicon "matlab") TODO: matlab + ("nix" nerd-icons-mdicon "nf-md-nix" :face nerd-icons-blue) + ("pl" nerd-icons-sucicon "nf-seti-perl" :face nerd-icons-lorange) + ("pm" nerd-icons-sucicon "nf-seti-perl" :face nerd-icons-lorange) + ;; ("pl6" nerd-icons-devicon"raku") TODO: raku + ;; ("pm6" nerd-icons-devicon "raku") TODO: raku + ("pod" nerd-icons-devicon "nf-dev-perl" :face nerd-icons-lgreen) + ("php" nerd-icons-devicon "nf-dev-php" :face nerd-icons-lsilver) + ;; ("pony" nerd-icons-devicon "pony") TODO: pony + ("ps1" nerd-icons-mdicon "nf-md-powershell" :face nerd-icons-blue) + ("pro" nerd-icons-sucicon "nf-seti-prolog" :face nerd-icons-lmaroon) + ("proog" nerd-icons-sucicon "nf-seti-prolog" :face nerd-icons-lmaroon) + ("py" nerd-icons-devicon "nf-dev-python" :face nerd-icons-dblue) + ;; ("idr" nerd-icons-devicon "idris") TODO: idris + ;; ("ipynb" nerd-icons-devicon "jupyter") TODO: jupyter + ("gem" nerd-icons-devicon "nf-dev-ruby" :face nerd-icons-red) + ;; ("raku" nerd-icons-devicon "raku") TODO: raku + ;; ("rakumod" nerd-icons-devicon "raku") TODO: raku + ("rb" nerd-icons-octicon "nf-oct-ruby" :face nerd-icons-lred) + ("rs" nerd-icons-devicon "nf-dev-rust" :face nerd-icons-maroon) + ("rlib" nerd-icons-devicon "nf-dev-rust" :face nerd-icons-dmaroon) + ("r" nerd-icons-sucicon "nf-seti-r" :face nerd-icons-lblue) + ("rd" nerd-icons-sucicon "nf-seti-r" :face nerd-icons-lblue) + ("rdx" nerd-icons-sucicon "nf-seti-r" :face nerd-icons-lblue) + ("rsx" nerd-icons-sucicon "nf-seti-r" :face nerd-icons-lblue) + ("svelte" nerd-icons-sucicon "nf-seti-svelte" :face nerd-icons-red) + ("gql" nerd-icons-mdicon "nf-md-graphql" :face nerd-icons-dpink) + ("graphql" nerd-icons-mdicon "nf-md-graphql" :face nerd-icons-dpink) + ;; There seems to be a a bug with this font icon which does not + ;; let you propertise it without it reverting to being a lower + ;; case phi + ("c" nerd-icons-sucicon "nf-custom-c" :face nerd-icons-blue) + ("h" nerd-icons-faicon "nf-fa-h_square" :face nerd-icons-purple) + ("m" nerd-icons-devicon "nf-dev-apple" ) + ("mm" nerd-icons-devicon "nf-dev-apple" ) + ;; + ("cc" nerd-icons-sucicon "nf-custom-cpp" :face nerd-icons-blue) + ("cpp" nerd-icons-sucicon "nf-custom-cpp" :face nerd-icons-blue) + ("cxx" nerd-icons-sucicon "nf-custom-cpp" :face nerd-icons-blue) + ("hh" nerd-icons-sucicon "nf-custom-cpp" :face nerd-icons-purple) + ("hpp" nerd-icons-sucicon "nf-custom-cpp" :face nerd-icons-purple) + ("hxx" nerd-icons-sucicon "nf-custom-cpp" :face nerd-icons-purple) + ;; Lisps + ("cl" nerd-icons-sucicon "nf-custom-common_lisp" :face nerd-icons-lorange) + ("l" nerd-icons-sucicon "nf-custom-scheme" :face nerd-icons-orange) + ("lisp" nerd-icons-sucicon "nf-custom-scheme" :face nerd-icons-orange) + ;; ("hy" nerd-icons-sucicon "nf-custom-hy" :face nerd-icons-blue) + ("el" nerd-icons-sucicon "nf-custom-emacs" :face nerd-icons-purple) + ("clj" nerd-icons-devicon "nf-dev-clojure" :face nerd-icons-blue) + ("cljc" nerd-icons-devicon "nf-dev-clojure" :face nerd-icons-blue) + ("cljs" nerd-icons-devicon "nf-dev-clojure" :face nerd-icons-lyellow) + ("coffee" nerd-icons-devicon "nf-dev-coffeescript" :face nerd-icons-maroon) + ("iced" nerd-icons-devicon "nf-dev-coffeescript" :face nerd-icons-lmaroon) + ("dart" nerd-icons-devicon "nf-dev-dart" :face nerd-icons-blue) + ("ledger" nerd-icons-mdicon "nf-md-file_table_box_multiple" :face nerd-icons-green) + ("rkt" nerd-icons-sucicon "nf-custom-scheme" :face nerd-icons-red) + ("scrbl" nerd-icons-sucicon "nf-custom-scheme" :face nerd-icons-blue) + ;; Stylesheeting + ("css" nerd-icons-devicon "nf-dev-css3" :face nerd-icons-yellow) + ("scss" nerd-icons-mdicon "nf-md-sass" :face nerd-icons-pink) + ("sass" nerd-icons-mdicon "nf-md-sass" :face nerd-icons-dpink) + ("less" nerd-icons-devicon "nf-dev-less" :face nerd-icons-dyellow) + ;; ("postcss" nerd-icons-devicon "postcss") TODO: postcss + ;; ("sss" nerd-icons-devicon "postcss") TODO: postcss + ("styl" nerd-icons-devicon "nf-dev-stylus" :face nerd-icons-lgreen) + ("csv" nerd-icons-octicon "nf-oct-graph" :face nerd-icons-dblue) + ;; haskell + ("hs" nerd-icons-devicon "nf-dev-haskell" :face nerd-icons-red) + ("chs" nerd-icons-devicon "nf-dev-haskell" :face nerd-icons-red) + ("lhs" nerd-icons-devicon "nf-dev-haskell" :face nerd-icons-red) + ("hsc" nerd-icons-devicon "nf-dev-haskell" :face nerd-icons-red) + ;; Web modes + ("inky-haml" nerd-icons-sucicon "nf-seti-haml" :face nerd-icons-lyellow) + ("haml" nerd-icons-sucicon "nf-seti-haml" :face nerd-icons-lyellow) + ("htm" nerd-icons-devicon "nf-dev-html5" :face nerd-icons-orange) + ("html" nerd-icons-devicon "nf-dev-html5" :face nerd-icons-orange) + ("inky-er" nerd-icons-devicon "nf-dev-html5" :face nerd-icons-lred) + ("inky-erb" nerd-icons-devicon "nf-dev-html5" :face nerd-icons-lred) + ("erb" nerd-icons-devicon "nf-dev-html5" :face nerd-icons-lred) + ;; ("hbs" nerd-icons-fileicon "moustache") TODO: moustache + ("inky-slim" nerd-icons-codicon "nf-cod-dashboard" :face nerd-icons-yellow) + ("slim" nerd-icons-codicon "nf-cod-dashboard" :face nerd-icons-yellow) + ("jade" nerd-icons-sucicon "nf-seti-jade" :face nerd-icons-red) + ("pug" nerd-icons-sucicon "nf-seti-pug" :face nerd-icons-red) + ;; Javascript + ;; ("d3js" nerd-icons-devicon "d3") TODO: d3 + ("re" nerd-icons-sucicon "nf-seti-reasonml" :face nerd-icons-red-alt) + ("rei" nerd-icons-sucicon "nf-seti-reasonml" :face nerd-icons-dred) + ("ml" nerd-icons-sucicon "nf-seti-ocaml" :face nerd-icons-lpink) + ("mli" nerd-icons-sucicon "nf-seti-ocaml" :face nerd-icons-dpink) + ("react" nerd-icons-devicon "nf-dev-react" :face nerd-icons-lblue) + ("ts" nerd-icons-sucicon "nf-seti-typescript" :face nerd-icons-blue-alt) + ("js" nerd-icons-devicon "nf-dev-javascript" :face nerd-icons-yellow) + ("es" nerd-icons-devicon "nf-dev-javascript" :face nerd-icons-yellow) + ("jsx" nerd-icons-devicon "nf-dev-javascript" :face nerd-icons-cyan-alt) + ("tsx" nerd-icons-sucicon "nf-seti-typescript" :face nerd-icons-blue-alt) + ("njs" nerd-icons-mdicon "nf-md-nodejs" :face nerd-icons-lgreen) + ("vue" nerd-icons-sucicon "nf-seti-vue" :face nerd-icons-lgreen) + + ("sbt" nerd-icons-sucicon "nf-seti-sbt" :face nerd-icons-red) + ("scala" nerd-icons-devicon "nf-dev-scala" :face nerd-icons-red) + ("scm" nerd-icons-sucicon "nf-custom-scheme" :face nerd-icons-red) + ("swift" nerd-icons-devicon "nf-dev-swift" :face nerd-icons-green) + + ("tcl" nerd-icons-mdicon "nf-md-feather" :face nerd-icons-dred) + ("exp" nerd-icons-mdicon "nf-md-feather" :face nerd-icons-dred) + + ("tf" nerd-icons-mdicon "nf-md-terraform" :face nerd-icons-purple-alt) + ("tfvars" nerd-icons-mdicon "nf-md-terraform" :face nerd-icons-purple-alt) + ("tfstate" nerd-icons-mdicon "nf-md-terraform" :face nerd-icons-purple-alt) + + ("asm" nerd-icons-sucicon "nf-seti-asm" :face nerd-icons-blue) + ;; Verilog(-AMS) and SystemVerilog(-AMS ;; Verilog(-AMS) and SystemVerilog(-AMS) + ("v" nerd-icons-mdicon "nf-md-chip" :face nerd-icons-red) + ("vams" nerd-icons-mdicon "nf-md-chip" :face nerd-icons-red) + ("sv" nerd-icons-mdicon "nf-md-chip" :face nerd-icons-red) + ("sva" nerd-icons-mdicon "nf-md-chip" :face nerd-icons-red) + ("svh" nerd-icons-mdicon "nf-md-chip" :face nerd-icons-red) + ("svams" nerd-icons-mdicon "nf-md-chip" :face nerd-icons-red) + ;; VHDL(-AMS ;; VHDL(-AMS) + ("vhd" nerd-icons-octicon "nf-oct-cpu" :face nerd-icons-blue) + ("vhdl" nerd-icons-octicon "nf-oct-cpu" :face nerd-icons-blue) + ("vhms" nerd-icons-octicon "nf-oct-cpu" :face nerd-icons-blue) + ;; Cabal + ;; ("cabal" nerd-icons-devicon "cabal") TODO: cabal + ;; Kotlin + ("kt" nerd-icons-sucicon "nf-seti-kotlin" :face nerd-icons-orange) + ("kts" nerd-icons-sucicon "nf-seti-kotlin" :face nerd-icons-orange) + ;; Nimrod + ("nim" nerd-icons-sucicon "nf-seti-nim" :face nerd-icons-yellow) + ("nims" nerd-icons-sucicon "nf-seti-nim" :face nerd-icons-yellow) + ;; SQL + ("sql" nerd-icons-octicon "nf-oct-database" :face nerd-icons-silver) + ;; Styles + ;; ("styles" nerd-icons-devicon "style") TODO: style + ;; Lua + ("lua" nerd-icons-sucicon "nf-seti-lua" :face nerd-icons-dblue) + ;; ASCII doc + ;; ("adoc" nerd-icons-devicon "asciidoc") TODO: asciidoc + ;; ("asciidoc" nerd-icons-devicon "asciidoc") TODO: asciidoc + ;; Puppet + ("pp" nerd-icons-sucicon "nf-seti-puppet" :face nerd-icons-yellow) + ;; Jinja + ("j2" nerd-icons-sucicon "nf-seti-jinja" :face nerd-icons-silver) + ("jinja2" nerd-icons-sucicon "nf-seti-jinja" :face nerd-icons-silver) + ;; Docker + ("dockerfile" nerd-icons-sucicon "nf-seti-docker" :face nerd-icons-cyan) + ;; Vagrant + ;; ("vagrantfile" nerd-icons-fileicon "vagrant") TODO: vagrant + ;; GLSL + ("glsl" nerd-icons-faicon "nf-fa-paint_brush" :face nerd-icons-blue) + ("vert" nerd-icons-faicon "nf-fa-paint_brush" :face nerd-icons-blue) + ("tesc" nerd-icons-faicon "nf-fa-paint_brush" :face nerd-icons-purple) + ("tese" nerd-icons-faicon "nf-fa-paint_brush" :face nerd-icons-dpurple) + ("geom" nerd-icons-faicon "nf-fa-paint_brush" :face nerd-icons-green) + ("frag" nerd-icons-faicon "nf-fa-paint_brush" :face nerd-icons-red) + ("comp" nerd-icons-faicon "nf-fa-paint_brush" :face nerd-icons-dblue) + ;; CUDA + ("cu" nerd-icons-sucicon "nf-custom-c" :face nerd-icons-green) + ("cuh" nerd-icons-faicon "nf-fa-h_square" :face nerd-icons-green) + ;; Fortran + ("f90" nerd-icons-mdicon "nf-md-language_fortran" :face nerd-icons-purple) + ;; C# + ("cs" nerd-icons-mdicon "nf-md-language_csharp" :face nerd-icons-dblue) + ("csx" nerd-icons-mdicon "nf-md-language_csharp" :face nerd-icons-dblue) + ;; F# + ("fs" nerd-icons-devicon "nf-dev-fsharp" :face nerd-icons-blue-alt) + ("fsi" nerd-icons-devicon "nf-dev-fsharp" :face nerd-icons-blue-alt) + ("fsx" nerd-icons-devicon "nf-dev-fsharp" :face nerd-icons-blue-alt) + ("fsscript" nerd-icons-devicon "nf-dev-fsharp" :face nerd-icons-blue-alt) + ;; Godot / GDScript + ("gd" nerd-icons-sucicon "nf-seti-godot" :face nerd-icons-blue) + ("tscn" nerd-icons-codicon "nf-cod-settings" :face nerd-icons-orange) + ("tres" nerd-icons-codicon "nf-cod-settings" :face nerd-icons-orange) + ;; zig + ("zig" nerd-icons-sucicon "nf-seti-zig" :face nerd-icons-orange) + ;; odin + ;; ("odin" nerd-icons-fileicon "odin") TODO: odin + ;; File Types + ("ico" nerd-icons-octicon "nf-oct-file_media" :face nerd-icons-blue) + ("png" nerd-icons-mdicon "nf-md-file_png_box" :face nerd-icons-orange) + ("gif" nerd-icons-mdicon "nf-md-file_gif_box" :face nerd-icons-green) + ("jpeg" nerd-icons-mdicon "nf-md-file_jpg_box" :face nerd-icons-dblue) + ("jpg" nerd-icons-mdicon "nf-md-file_jpg_box" :face nerd-icons-dblue) + ("webp" nerd-icons-octicon "nf-oct-file_media" :face nerd-icons-dblue) + ("xpm" nerd-icons-octicon "nf-oct-file_media" :face nerd-icons-dgreen) + ;; Audio + ("mp3" nerd-icons-faicon "nf-fa-music" :face nerd-icons-dred) + ("wav" nerd-icons-faicon "nf-fa-music" :face nerd-icons-dred) + ("m4a" nerd-icons-faicon "nf-fa-music" :face nerd-icons-dred) + ("ogg" nerd-icons-faicon "nf-fa-music" :face nerd-icons-dred) + ("flac" nerd-icons-faicon "nf-fa-music" :face nerd-icons-dred) + ("opus" nerd-icons-faicon "nf-fa-music" :face nerd-icons-dred) + ("au" nerd-icons-faicon "nf-fa-music" :face nerd-icons-dred) + ("aif" nerd-icons-faicon "nf-fa-music" :face nerd-icons-dred) + ("aifc" nerd-icons-faicon "nf-fa-music" :face nerd-icons-dred) + ("aiff" nerd-icons-faicon "nf-fa-music" :face nerd-icons-dred) + ("svg" nerd-icons-sucicon "nf-seti-svg" :face nerd-icons-lgreen) + ;; Video + ("mov" nerd-icons-faicon "nf-fa-film" :face nerd-icons-blue) + ("mp4" nerd-icons-faicon "nf-fa-film" :face nerd-icons-blue) + ("ogv" nerd-icons-faicon "nf-fa-film" :face nerd-icons-dblue) + ("mpg" nerd-icons-faicon "nf-fa-film" :face nerd-icons-blue) + ("mpeg" nerd-icons-faicon "nf-fa-film" :face nerd-icons-blue) + ("flv" nerd-icons-faicon "nf-fa-film" :face nerd-icons-blue) + ("ogv" nerd-icons-faicon "nf-fa-film" :face nerd-icons-dblue) + ("mkv" nerd-icons-faicon "nf-fa-film" :face nerd-icons-blue) + ("webm" nerd-icons-faicon "nf-fa-film" :face nerd-icons-blue) + ;; Fonts + ("ttf" nerd-icons-faicon "nf-fa-font" :face nerd-icons-dcyan) + ("woff" nerd-icons-faicon "nf-fa-font" :face nerd-icons-cyan) + ("woff2" nerd-icons-faicon "nf-fa-font" :face nerd-icons-cyan) + ;; Archives + ("iso" nerd-icons-mdicon "nf-md-disc" :face nerd-icons-orange) + ("tar" nerd-icons-mdicon "nf-md-zip_box" :face nerd-icons-orange) + ("rar" nerd-icons-mdicon "nf-md-zip_box" :face nerd-icons-orange) + ("tgz" nerd-icons-mdicon "nf-md-zip_box" :face nerd-icons-orange) + ("jar" nerd-icons-devicon "nf-dev-java" :face nerd-icons-dpurple) + ;; Doc + ("pdf" nerd-icons-codicon "nf-cod-file_pdf" :face nerd-icons-dred) + ("text" nerd-icons-faicon "nf-fa-file_text" :face nerd-icons-cyan) + ("txt" nerd-icons-faicon "nf-fa-file_text" :face nerd-icons-cyan) + ("doc" nerd-icons-mdicon "nf-md-file_word" :face nerd-icons-blue) + ("docx" nerd-icons-mdicon "nf-md-file_word" :face nerd-icons-blue) + ("docm" nerd-icons-mdicon "nf-md-file_word" :face nerd-icons-blue) + ("texi" nerd-icons-sucicon "nf-seti-tex" :face nerd-icons-lred) + ("tex" nerd-icons-sucicon "nf-seti-tex" :face nerd-icons-lred) + ("ltx" nerd-icons-sucicon "nf-seti-tex" :face nerd-icons-lred) + ("dtx" nerd-icons-sucicon "nf-seti-tex" :face nerd-icons-lred) + ("sty" nerd-icons-sucicon "nf-seti-tex" :face nerd-icons-lred) + ("md" nerd-icons-octicon "nf-oct-markdown" :face nerd-icons-lblue) + ("bib" nerd-icons-mdicon "nf-md-book" :face nerd-icons-lblue) + ("org" nerd-icons-sucicon "nf-custom-orgmode" :face nerd-icons-lgreen) + ("org_archive" nerd-icons-sucicon "nf-custom-orgmode" :face nerd-icons-lgreen) + ("pps" nerd-icons-mdicon "nf-md-file_powerpoint" :face nerd-icons-orange) + ("ppt" nerd-icons-mdicon "nf-md-file_powerpoint" :face nerd-icons-orange) + ("pptx" nerd-icons-mdicon "nf-md-file_powerpoint" :face nerd-icons-orange) + ("pptsx" nerd-icons-mdicon "nf-md-file_powerpoint" :face nerd-icons-orange) + ("ppttx" nerd-icons-mdicon "nf-md-file_powerpoint" :face nerd-icons-orange) + ("knt" nerd-icons-mdicon "nf-md-file_powerpoint" :face nerd-icons-cyan) + ("xlsx" nerd-icons-mdicon "nf-md-file_excel" :face nerd-icons-dgreen) + ("xlsm" nerd-icons-mdicon "nf-md-file_excel" :face nerd-icons-dgreen) + ("xlsb" nerd-icons-mdicon "nf-md-file_excel" :face nerd-icons-dgreen) + ("xltx" nerd-icons-mdicon "nf-md-file_excel" :face nerd-icons-dgreen) + ("xltm" nerd-icons-mdicon "nf-md-file_excel" :face nerd-icons-dgreen) + ("epub" nerd-icons-mdicon "nf-md-book_open" :face nerd-icons-green) + ("ly" nerd-icons-faicon "nf-fa-music" :face nerd-icons-green) + ;; + ("key" nerd-icons-octicon "nf-oct-key" :face nerd-icons-lblue) + ("pem" nerd-icons-octicon "nf-oct-key" :face nerd-icons-orange) + ("p12" nerd-icons-octicon "nf-oct-key" :face nerd-icons-dorange) + ("crt" nerd-icons-octicon "nf-oct-key" :face nerd-icons-lblue) + ("pub" nerd-icons-octicon "nf-oct-key" :face nerd-icons-blue) + ("gpg" nerd-icons-octicon "nf-oct-key" :face nerd-icons-lblue) + ("kdbx" nerd-icons-octicon "nf-oct-key" :face nerd-icons-green) + ("cache" nerd-icons-octicon "nf-oct-database" :face nerd-icons-green) + ;; backup + ("backup" nerd-icons-mdicon "nf-md-file_restore" :face nerd-icons-lblue) + ("old" nerd-icons-mdicon "nf-md-file_restore" :face nerd-icons-lblue) + ("bak" nerd-icons-mdicon "nf-md-file_restore" :face nerd-icons-lblue))) + +(defvar nerd-icons-regexp-icon-alist + '( + ;; + ("^TAGS$" nerd-icons-octicon "nf-oct-tag" :face nerd-icons-blue) + ("^TODO$" nerd-icons-octicon "nf-oct-checklist" :face nerd-icons-lyellow) + ("^LICENSE$" nerd-icons-octicon "nf-oct-book" :face nerd-icons-blue) + ("^readme" nerd-icons-octicon "nf-oct-book" :face nerd-icons-lcyan) + + ;; Config + ("nginx$" nerd-icons-devicon "nf-dev-nginx" :face nerd-icons-dgreen) + ;; ("apache$" nerd-icons-alltheicon "apache") TODO: apache + + ;; C + ("^Makefile$" nerd-icons-sucicon "nf-seti-makefile" :face nerd-icons-dorange) + ("^CMakeLists.txt$" nerd-icons-sucicon "nf-seti-makefile" :face nerd-icons-red) ;; TODO: cmake + ("^CMakeCache.txt$" nerd-icons-sucicon "nf-seti-makefile" :face nerd-icons-blue) ;; TODO: cmakecache + ("^meson.build$" nerd-icons-sucicon "nf-seti-makefile" :face nerd-icons-purple) ;; TODO: meson + ("^meson_options.txt$" nerd-icons-sucicon "nf-seti-makefile" :face nerd-icons-purple) ;; TODO: meson + + ;; Docker + ("^\\.?Dockerfile" nerd-icons-sucicon "nf-seti-docker" :face nerd-icons-blue) + + ;; Homebrew + ("^Brewfile$" nerd-icons-faicon "nf-fa-beer" :face nerd-icons-lsilver) + + ;; ;; AWS + ("^stack.*.json$" nerd-icons-devicon "nf-dev-aws" :face nerd-icons-orange) + ("^serverless\\.yml$" nerd-icons-faicon "nf-fa-bolt" :face nerd-icons-yellow) + + ;; lock files + ("~$" nerd-icons-octicon "nf-oct-lock" :face nerd-icons-maroon) + + ;; Source Codes + ("^mix.lock$" nerd-icons-sucicon "nf-seti-elixir" :face nerd-icons-lyellow) + + ;; Ruby + ("^Gemfile\\(\\.lock\\)?$" nerd-icons-octicon "nf-oct-ruby" :face nerd-icons-red) + ("_?test\\.rb$" nerd-icons-octicon "nf-oct-ruby" :face nerd-icons-red) + ("_?test_helper\\.rb$" nerd-icons-octicon "nf-oct-ruby" :face nerd-icons-dred) + ("_?spec\\.rb$" nerd-icons-octicon "nf-oct-ruby" :face nerd-icons-red) + ("_?spec_helper\\.rb$" nerd-icons-octicon "nf-oct-ruby" :face nerd-icons-dred) + + ("-?spec\\.ts$" nerd-icons-mdicon "nf-md-language_typescript" :face nerd-icons-blue) + ("-?test\\.ts$" nerd-icons-mdicon "nf-md-language_typescript" :face nerd-icons-blue) + ("-?spec\\.js$" nerd-icons-mdicon "nf-md-language_javascript" :face nerd-icons-lpurple) + ("-?test\\.js$" nerd-icons-mdicon "nf-md-language_javascript" :face nerd-icons-lpurple) + ("-?spec\\.jsx$" nerd-icons-mdicon "nf-md-react" :face nerd-icons-blue-alt) + ("-?test\\.jsx$" nerd-icons-mdicon "nf-md-react" :face nerd-icons-blue-alt) + + ;; Git + ("^MERGE_" nerd-icons-octicon "nf-oct-git_merge" :face nerd-icons-red) + ("^COMMIT_EDITMSG" nerd-icons-octicon "nf-oct-git_commit" :face nerd-icons-red) + + ;; Stylesheeting + ("stylelint" nerd-icons-sucicon "nf-seti-stylelint" :face nerd-icons-lyellow) + + ;; JavaScript + ("^package.json$" nerd-icons-devicon "nf-dev-npm" :face nerd-icons-red) + ("^package.lock.json$" nerd-icons-devicon "nf-dev-npm" :face nerd-icons-dred) + ("^yarn\\.lock" nerd-icons-sucicon "nf-seti-yarn" :face nerd-icons-blue-alt) + ("\\.npmignore$" nerd-icons-devicon "nf-dev-npm" :face nerd-icons-dred) + ("^bower.json$" nerd-icons-devicon "nf-dev-bower" :face nerd-icons-lorange) + ("^gulpfile" nerd-icons-devicon "nf-dev-gulp" :face nerd-icons-lred) + ("^gruntfile" nerd-icons-devicon "nf-dev-grunt" :face nerd-icons-lyellow) + ("^webpack" nerd-icons-mdicon "nf-md-webpack" :face nerd-icons-lblue) + + ;; Go + ("^go.mod$" nerd-icons-sucicon "nf-seti-config" :face nerd-icons-blue-alt) + ("^go.work$" nerd-icons-sucicon "nf-seti-config" :face nerd-icons-blue-alt) + + ;; Groovy + ("Jenkinsfile\\'" nerd-icons-devicon "nf-dev-groovy" :face nerd-icons-cyan-alt) + + ;; Emacs + ("bookmark" nerd-icons-octicon "nf-oct-bookmark" :face nerd-icons-lpink) + + ("^\\*scratch\\*$" nerd-icons-faicon "nf-fa-sticky_note" :face nerd-icons-lyellow) + ("^\\*scratch.*" nerd-icons-faicon "nf-fa-sticky_note" :face nerd-icons-yellow) + ("^\\*new-tab\\*$" nerd-icons-mdicon "nf-md-star" :face nerd-icons-cyan) + ("Cask\\'" nerd-icons-sucicon "nf-custom-emacs" :face nerd-icons-blue) + ("Eask\\'" nerd-icons-sucicon "nf-custom-emacs" :face nerd-icons-blue) + + ("^\\." nerd-icons-octicon "nf-oct-gear"))) + +(defvar nerd-icons-default-file-icon + '(nerd-icons-faicon "nf-fa-file_o")) + +(defvar nerd-icons-dir-icon-alist + '( + ("trash" nerd-icons-faicon "nf-fa-trash_o") + ("dropbox" nerd-icons-faicon "nf-fa-dropbox") + ("google[ _-]drive" nerd-icons-mdicon "nf-md-folder_google_drive") + ("github" nerd-icons-sucicon "nf-custom-folder_github") + ("^atom$" nerd-icons-devicon "nf-dev-atom") + ("documents" nerd-icons-mdicon "nf-md-folder_file") + ("download" nerd-icons-mdicon "nf-md-folder_download") + ("desktop" nerd-icons-octicon "nf-oct-device_desktop") + ("pictures" nerd-icons-mdicon "nf-md-folder_image") + ("photos" nerd-icons-faicon "nf-fa-camera_retro") + ("music" nerd-icons-mdicon "nf-md-folder_music") + ("movies" nerd-icons-faicon "nf-fa-film") + ("code" nerd-icons-octicon "nf-oct-code") + ("workspace" nerd-icons-octicon "nf-oct-code") + ;; ("test" nerd-icons-devicon "test-dir") + ("\\.git" nerd-icons-sucicon "nf-custom-folder_git") + ("\\.config" nerd-icons-sucicon "nf-custom-folder_config") + (".?" nerd-icons-sucicon "nf-custom-folder_oct"))) + +(defvar nerd-icons-weather-icon-alist + '( + ("tornado" nerd-icons-wicon "nf-weather-tornado") + ("hurricane" nerd-icons-wicon "nf-weather-hurricane") + ("thunderstorms" nerd-icons-wicon "nf-weather-thunderstorm") + ("sunny" nerd-icons-wicon "nf-weather-day_sunny") + ("rain.*snow" nerd-icons-wicon "nf-weather-rain_mix") + ("rain.*hail" nerd-icons-wicon "nf-weather-rain_mix") + ("sleet" nerd-icons-wicon "nf-weather-sleet") + ("hail" nerd-icons-wicon "nf-weather-hail") + ("drizzle" nerd-icons-wicon "nf-weather-sprinkle") + ("rain" nerd-icons-wicon "nf-weather-showers") + ("showers" nerd-icons-wicon "nf-weather-showers") + ("blowing.*snow" nerd-icons-wicon "nf-weather-snow_wind") + ("snow" nerd-icons-wicon "nf-weather-snow") + ("dust" nerd-icons-wicon "nf-weather-dust") + ("fog" nerd-icons-wicon "nf-weather-fog") + ("haze" nerd-icons-wicon "nf-weather-day_haze") + ("smoky" nerd-icons-wicon "nf-weather-smoke") + ("blustery" nerd-icons-wicon "nf-weather-cloudy_windy") + ("windy" nerd-icons-wicon "nf-weather-cloudy_gusts") + ("cold" nerd-icons-wicon "nf-weather-snowflake_cold") + ("partly.*cloudy.*night" nerd-icons-wicon "nf-weather-night_alt_partly_cloudy") + ("partly.*cloudy" nerd-icons-wicon "nf-weather-day_cloudy_high") + ("cloudy.*night" nerd-icons-wicon "nf-weather-night_alt_cloudy") + ("cxloudy.*day" nerd-icons-wicon "nf-weather-day_cloudy") + ("cloudy" nerd-icons-wicon "nf-weather-cloudy") + ("clear.*night" nerd-icons-wicon "nf-weather-night_clear") + ("fair.*night" nerd-icons-wicon "nf-weather-stars") + ("fair.*day" nerd-icons-wicon "nf-weather-horizon") + ("hot" nerd-icons-wicon "nf-weather-hot") + ("not.*available" nerd-icons-wicon "nf-weather-na"))) + +(defvar nerd-icons-mode-icon-alist + '( + (emacs-lisp-mode nerd-icons-sucicon "nf-custom-emacs" :face nerd-icons-purple) + (circe-server-mode nerd-icons-faicon "nf-fa-commenting_o") + (circe-channel-mode nerd-icons-faicon "nf-fa-commenting_o") + (circe-query-mode nerd-icons-faicon "nf-fa-commenting_o") + (crystal-mode nerd-icons-sucicon "nf-custom-crystal" :face nerd-icons-yellow) + (erc-mode nerd-icons-faicon "nf-fa-commenting_o") + (inferior-emacs-lisp-mode nerd-icons-sucicon "nf-custom-emacs" :face nerd-icons-lblue) + (dired-mode nerd-icons-octicon "nf-oct-file_directory") + (lisp-interaction-mode nerd-icons-sucicon "nf-custom-emacs" :face nerd-icons-orange) + (sly-mrepl-mode nerd-icons-sucicon "nf-custom-common_lisp" :face nerd-icons-orange) + (slime-repl-mode nerd-icons-sucicon "nf-custom-common_lisp" :face nerd-icons-orange) + (org-mode nerd-icons-sucicon "nf-custom-orgmode" :face nerd-icons-lgreen) + (ledger-mode nerd-icons-mdicon "nf-md-file_table_box_multiple" :face nerd-icons-green) + (typescript-mode nerd-icons-mdicon "nf-md-language_typescript" :face nerd-icons-blue-alt) + (typescript-ts-mode nerd-icons-mdicon "nf-md-language_typescript" :face nerd-icons-blue-alt) + (typescript-tsx-mode nerd-icons-mdicon "nf-md-language_typescript" :face nerd-icons-blue-alt) + (tsx-ts-mode nerd-icons-mdicon "nf-md-language_typescript" :face nerd-icons-blue-alt) + (js-mode nerd-icons-devicon "nf-dev-javascript" :face nerd-icons-yellow) + (js-ts-mode nerd-icons-devicon "nf-dev-javascript" :face nerd-icons-yellow) + (js-jsx-mode nerd-icons-devicon "nf-dev-javascript" :face nerd-icons-yellow) + (js2-mode nerd-icons-devicon "nf-dev-javascript" :face nerd-icons-yellow) + (js3-mode nerd-icons-devicon "nf-dev-javascript" :face nerd-icons-yellow) + (rjsx-mode nerd-icons-devicon "nf-dev-javascript" :face nerd-icons-cyan-alt) + (term-mode nerd-icons-devicon "nf-dev-terminal") + (vterm-mode nerd-icons-devicon "nf-dev-terminal") + (eshell-mode nerd-icons-devicon "nf-dev-terminal" :face nerd-icons-purple) + (magit-refs-mode nerd-icons-devicon "nf-dev-git_branch" :face nerd-icons-red) + (magit-process-mode nerd-icons-octicon "nf-oct-mark_github") + (magit-diff-mode nerd-icons-devicon "nf-dev-git_compare" :face nerd-icons-lblue) + (ediff-mode nerd-icons-devicon "nf-dev-git_compare" :face nerd-icons-red) + (diff-mode nerd-icons-devicon "nf-dev-git_compare" :face nerd-icons-lred) + (comint-mode nerd-icons-faicon "nf-fa-terminal" :face nerd-icons-lblue) + (eww-mode nerd-icons-faicon "nf-fa-firefox" :face nerd-icons-red) + (xwidget-webkit-mode nerd-icons-faicon "nf-fa-chrome" :face nerd-icons-blue) + (org-agenda-mode nerd-icons-octicon "nf-oct-checklist" :face nerd-icons-lgreen) + (cfw:calendar-mode nerd-icons-octicon "nf-oct-calendar") + (ibuffer-mode nerd-icons-faicon "nf-fa-files_o" :face nerd-icons-dsilver) + (messages-buffer-mode nerd-icons-faicon "nf-fa-file_o" :face nerd-icons-dsilver) + (help-mode nerd-icons-faicon "nf-fa-info" :face nerd-icons-purple) + (helpful-mode nerd-icons-faicon "nf-fa-info" :face nerd-icons-purple) + (Info-mode nerd-icons-faicon "nf-fa-info" :face nerd-icons-blue) + (benchmark-init/tree-mode nerd-icons-faicon "nf-fa-dashboard") + (jenkins-mode nerd-icons-devicon "nf-dev-jenkins" :face nerd-icons-blue) + (magit-popup-mode nerd-icons-sucicon "nf-seti-git" :face nerd-icons-red) + (magit-status-mode nerd-icons-sucicon "nf-seti-git" :face nerd-icons-lred) + (magit-log-mode nerd-icons-sucicon "nf-seti-git" :face nerd-icons-green) + (mu4e-compose-mode nerd-icons-octicon "nf-oct-pencil") + (mu4e-headers-mode nerd-icons-octicon "nf-oct-mail") + (mu4e-main-mode nerd-icons-octicon "nf-oct-mail") + (mu4e-view-mode nerd-icons-codicon "nf-cod-mail_read") + (sieve-mode nerd-icons-octicon "nf-oct-mail") + (gnus-group-mode nerd-icons-octicon "nf-oct-mail") + (gnus-summary-mode nerd-icons-octicon "nf-oct-mail") + (gnus-article-mode nerd-icons-codicon "nf-cod-mail_read") + (message-mode nerd-icons-octicon "nf-oct-pencil") + (package-menu-mode nerd-icons-faicon "nf-fa-archive" :face nerd-icons-silver) + (paradox-menu-mode nerd-icons-faicon "nf-fa-archive" :face nerd-icons-silver) + (Custom-mode nerd-icons-codicon "nf-cod-settings") + + ;; Special matcher for Web Mode based on the `web-mode-content-type' of the current buffer + (web-mode nerd-icons--web-mode-icon) + + (fundamental-mode nerd-icons-sucicon "nf-custom-emacs" :face nerd-icons-dsilver) + (special-mode nerd-icons-sucicon "nf-custom-emacs" :face nerd-icons-yellow) + (cask-mode nerd-icons-sucicon "nf-custom-emacs" :face nerd-icons-blue) + (eask-mode nerd-icons-sucicon "nf-custom-emacs" :face nerd-icons-blue) + (text-mode nerd-icons-faicon "nf-fa-file_text" :face nerd-icons-cyan) + (enh-ruby-mode nerd-icons-devicon "nf-dev-ruby" :face nerd-icons-lred) + (ruby-mode nerd-icons-devicon "nf-dev-ruby" :face nerd-icons-lred) + (ruby-ts-mode nerd-icons-devicon "nf-dev-ruby" :face nerd-icons-lred) + (inf-ruby-mode nerd-icons-devicon "nf-dev-ruby" :face nerd-icons-red) + (projectile-rails-compilation-mode nerd-icons-devicon "nf-dev-ruby" :face nerd-icons-red) + (rspec-compilation-mode nerd-icons-devicon "nf-dev-ruby" :face nerd-icons-red) + (rake-compilation-mode nerd-icons-devicon "nf-dev-ruby" :face nerd-icons-red) + (sh-mode nerd-icons-devicon "nf-dev-terminal" :face nerd-icons-purple) + (bash-ts-mode nerd-icons-devicon "nf-dev-terminal" :face nerd-icons-purple) + (shell-mode nerd-icons-devicon "nf-dev-terminal" :face nerd-icons-purple) + (fish-mode nerd-icons-devicon "nf-dev-terminal" :face nerd-icons-lpink) + (bat-mode nerd-icons-codicon "nf-cod-terminal_cmd" :face nerd-icons-lsilver) + (nginx-mode nerd-icons-devicon "nf-dev-nginx" :face nerd-icons-dgreen) + ;; (apache-mode nerd-icons-alltheicon "apache" :face nerd-icons-dgreen) + (makefile-mode nerd-icons-devicon "nf-dev-gnu" :face nerd-icons-dorange) + (makefile-ts-mode nerd-icons-devicon "nf-dev-gnu" :face nerd-icons-dorange) + ;; (cmake-mode nerd-icons-fileicon "cmake" :face nerd-icons-red) + ;; (cmake-ts-mode nerd-icons-fileicon "cmake" :face nerd-icons-red) + (dockerfile-mode nerd-icons-sucicon "nf-seti-docker" :face nerd-icons-blue) + (dockerfile-ts-mode nerd-icons-sucicon "nf-seti-docker" :face nerd-icons-blue) + (docker-compose-mode nerd-icons-sucicon "nf-seti-docker" :face nerd-icons-lblue) + (nxml-mode nerd-icons-faicon "nf-fa-file_code_o" :face nerd-icons-lorange) + (conf-mode nerd-icons-codicon "nf-cod-settings" :face nerd-icons-lyellow) + (json-mode nerd-icons-codicon "nf-cod-settings" :face nerd-icons-yellow) + (json-ts-mode nerd-icons-codicon "nf-cod-settings" :face nerd-icons-yellow) + (jsonian-mode nerd-icons-codicon "nf-cod-settings" :face nerd-icons-yellow) + (yaml-mode nerd-icons-codicon "nf-cod-settings" :face nerd-icons-dyellow) + (yaml-ts-mode nerd-icons-codicon "nf-cod-settings" :face nerd-icons-dyellow) + (toml-mode nerd-icons-codicon "nf-cod-settings" :face nerd-icons-orange) + (toml-ts-mode nerd-icons-codicon "nf-cod-settings" :face nerd-icons-orange) + (elisp-byte-code-mode nerd-icons-octicon "nf-oct-file_binary" :face nerd-icons-dsilver) + (archive-mode nerd-icons-octicon "nf-oct-file_zip" :face nerd-icons-lmaroon) + (elm-mode nerd-icons-sucicon "nf-custom-elm" :face nerd-icons-blue) + (erlang-mode nerd-icons-devicon "nf-dev-erlang" :face nerd-icons-red) + (elixir-mode nerd-icons-sucicon "nf-custom-elixir" :face nerd-icons-lorange) + (elixir-ts-mode nerd-icons-sucicon "nf-custom-elixir" :face nerd-icons-lorange) + (java-mode nerd-icons-devicon "nf-dev-java" :face nerd-icons-purple) + (groovy-mode nerd-icons-devicon "nf-dev-groovy" :face nerd-icons-cyan) + (java-ts-mode nerd-icons-devicon "nf-dev-java" :face nerd-icons-purple) + (go-mode nerd-icons-devicon "nf-dev-go" :face nerd-icons-blue) + (go-ts-mode nerd-icons-devicon "nf-dev-go" :face nerd-icons-blue) + (go-dot-mod-mode nerd-icons-sucicon "nf-seti-config" :face nerd-icons-blue-alt) + (go-mod-ts-mode nerd-icons-sucicon "nf-seti-config" :face nerd-icons-blue-alt) + (go-dot-work-mode nerd-icons-sucicon "nf-seti-config" :face nerd-icons-blue-alt) + (graphql-mode nerd-icons-sucicon "nf-seti-graphql" :face nerd-icons-dpink) + ;; (matlab-mode nerd-icons-fileicon "matlab" :face nerd-icons-orange) + (nix-mode nerd-icons-mdicon "nf-md-nix" :face nerd-icons-blue) + (perl-mode nerd-icons-devicon "nf-dev-perl" :face nerd-icons-lorange) + (cperl-mode nerd-icons-devicon "nf-dev-perl" :face nerd-icons-lorange) + (php-mode nerd-icons-devicon "nf-dev-php" :face nerd-icons-lsilver) + (php-ts-mode nerd-icons-devicon "nf-dev-php" :face nerd-icons-lsilver) + (prolog-mode nerd-icons-devicon "nf-dev-prolog" :face nerd-icons-lmaroon) + (python-mode nerd-icons-devicon "nf-dev-python" :face nerd-icons-dblue) + (python-ts-mode nerd-icons-devicon "nf-dev-python" :face nerd-icons-dblue) + (inferior-python-mode nerd-icons-devicon "nf-dev-python" :face nerd-icons-dblue) + ;; (racket-mode nerd-icons-fileicon "racket" :face nerd-icons-red) + (rust-mode nerd-icons-devicon "nf-dev-rust" :face nerd-icons-maroon) + (rustic-mode nerd-icons-devicon "nf-dev-rust" :face nerd-icons-maroon) + (rust-ts-mode nerd-icons-devicon "nf-dev-rust" :face nerd-icons-maroon) + (scala-mode nerd-icons-devicon "nf-dev-scala" :face nerd-icons-red) + ;; (scheme-mode nerd-icons-fileicon "scheme" :face nerd-icons-red) + (swift-mode nerd-icons-devicon "nf-dev-swift" :face nerd-icons-green) + (svelte-mode nerd-icons-sucicon "nf-seti-svelte" :face nerd-icons-red) + (ada-mode nerd-icons-sucicon "nf-custom-ada" :face nerd-icons-blue) + (ada-ts-mode nerd-icons-sucicon "nf-custom-ada" :face nerd-icons-blue) + (gpr-mode nerd-icons-sucicon "nf-custom-ada" :face nerd-icons-green) + (gpr-ts-mode nerd-icons-sucicon "nf-custom-ada" :face nerd-icons-green) + (c-mode nerd-icons-sucicon "nf-custom-c" :face nerd-icons-blue) + (c-ts-mode nerd-icons-sucicon "nf-custom-c" :face nerd-icons-blue) + (c++-mode nerd-icons-sucicon "nf-custom-cpp" :face nerd-icons-blue) + (c++-ts-mode nerd-icons-sucicon "nf-custom-cpp" :face nerd-icons-blue) + (csharp-mode nerd-icons-mdicon "nf-md-language_csharp" :face nerd-icons-dblue) + (csharp-ts-mode nerd-icons-mdicon "nf-md-language_csharp" :face nerd-icons-dblue) + (clojure-mode nerd-icons-devicon "nf-dev-clojure_alt" :face nerd-icons-blue) + (clojure-ts-mode nerd-icons-devicon "nf-dev-clojure_alt" :face nerd-icons-blue) + (cider-repl-mode nerd-icons-devicon "nf-dev-clojure_alt" :face nerd-icons-green) + (clojurec-mode nerd-icons-sucicon "nf-seti-clojure" :face nerd-icons-blue) + (clojurec-ts-mode nerd-icons-sucicon "nf-seti-clojure" :face nerd-icons-blue) + (clojurescript-mode nerd-icons-devicon "nf-dev-clojure_alt" :face nerd-icons-lyellow) + (clojurescript-ts-mode nerd-icons-devicon "nf-dev-clojure_alt" :face nerd-icons-lyellow) + (coffee-mode nerd-icons-devicon "nf-dev-coffeescript" :face nerd-icons-maroon) + (lisp-mode nerd-icons-sucicon "nf-custom-scheme" :face nerd-icons-orange) + (css-mode nerd-icons-devicon "nf-dev-css3" :face nerd-icons-yellow) + (css-ts-mode nerd-icons-devicon "nf-dev-css3" :face nerd-icons-yellow) + (scss-mode nerd-icons-mdicon "nf-md-sass" :face nerd-icons-pink) + (sass-mode nerd-icons-mdicon "nf-md-sass" :face nerd-icons-dpink) + (less-css-mode nerd-icons-devicon "nf-dev-less" :face nerd-icons-dyellow) + (stylus-mode nerd-icons-devicon "nf-dev-stylus" :face nerd-icons-lgreen) + (csv-mode nerd-icons-octicon "nf-oct-graph" :face nerd-icons-dblue) + (gdscript-mode nerd-icons-sucicon "nf-seti-godot" :face nerd-icons-blue) + (gdscript-ts-mode nerd-icons-sucicon "nf-seti-godot" :face nerd-icons-blue) + (haskell-mode nerd-icons-devicon "nf-dev-haskell" :face nerd-icons-red) + (haskell-c2hs-mode nerd-icons-devicon "nf-dev-haskell" :face nerd-icons-red) + (literate-haskell-mode nerd-icons-devicon "nf-dev-haskell" :face nerd-icons-red) + (haml-mode nerd-icons-sucicon "nf-seti-haml" :face nerd-icons-lyellow) + (html-mode nerd-icons-devicon "nf-dev-html5" :face nerd-icons-orange) + (html-ts-mode nerd-icons-devicon "nf-dev-html5" :face nerd-icons-orange) + (rhtml-mode nerd-icons-devicon "nf-dev-html5" :face nerd-icons-lred) + ;; (mustache-mode nerd-icons-fileicon "moustache" :face nerd-icons-green) + (slim-mode nerd-icons-codicon "nf-cod-dashboard" :face nerd-icons-yellow) + (jade-mode nerd-icons-sucicon "nf-seti-jade" :face nerd-icons-red) + (pug-mode nerd-icons-sucicon "nf-seti-pug" :face nerd-icons-red) + (react-mode nerd-icons-devicon "nf-dev-react" :face nerd-icons-lblue) + (image-mode nerd-icons-octicon "nf-oct-file_media" :face nerd-icons-blue) + (texinfo-mode nerd-icons-sucicon "nf-seti-tex" :face nerd-icons-lred) + (markdown-mode nerd-icons-octicon "nf-oct-markdown" :face nerd-icons-lblue) + (markdown-ts-mode nerd-icons-octicon "nf-oct-markdown" :face nerd-icons-lblue) + ;; (bibtex-mode nerd-icons-fileicon "bib" :face nerd-icons-maroon) + (compilation-mode nerd-icons-faicon "nf-fa-cogs") + (objc-mode nerd-icons-faicon "nf-fa-apple") + (tuareg-mode nerd-icons-sucicon "nf-seti-ocaml") + (purescript-mode nerd-icons-sucicon "nf-seti-purescript") + (verilog-mode nerd-icons-mdicon "nf-md-chip" :face nerd-icons-red) + (verilog-ts-mode nerd-icons-mdicon "nf-md-chip" :face nerd-icons-red) + (vhdl-mode nerd-icons-octicon "nf-oct-cpu" :face nerd-icons-blue) + (vhdl-ts-mode nerd-icons-octicon "nf-oct-cpu" :face nerd-icons-blue) + ;; (haskell-cabal-mode nerd-icons-fileicon "cabal" :face nerd-icons-lblue) + (kotlin-mode nerd-icons-sucicon "nf-custom-kotlin" :face nerd-icons-orange) + (kotlin-ts-mode nerd-icons-sucicon "nf-custom-kotlin" :face nerd-icons-orange) + (nim-mode nerd-icons-sucicon "nf-seti-nim" :face nerd-icons-yellow) + (sql-mode nerd-icons-devicon "nf-dev-database" :face nerd-icons-silver) + (lua-mode nerd-icons-sucicon "nf-seti-lua" :face nerd-icons-dblue) + (lua-ts-mode nerd-icons-sucicon "nf-seti-lua" :face nerd-icons-dblue) + ;; (adoc-mode nerd-icons-fileicon "asciidoc" :face nerd-icons-lblue) + (puppet-mode nerd-icons-sucicon "nf-custom-puppet" :face nerd-icons-yellow) + (jinja2-mode nerd-icons-sucicon "nf-seti-jinja" :face nerd-icons-silver) + (powershell-mode nerd-icons-mdicon "nf-md-powershell" :face nerd-icons-blue) + (tex-mode nerd-icons-sucicon "nf-seti-tex" :face nerd-icons-lred) + (latex-mode nerd-icons-sucicon "nf-seti-tex" :face nerd-icons-lred) + (latex-ts-mode nerd-icons-sucicon "nf-seti-tex" :face nerd-icons-lred) + (doctex-mode nerd-icons-sucicon "nf-seti-tex" :face nerd-icons-lred) + ;; Modes provided by AUCTeX 14.1 and higher + (TeX-mode nerd-icons-sucicon "nf-seti-tex" :face nerd-icons-lred) + (LaTeX-mode nerd-icons-sucicon "nf-seti-tex" :face nerd-icons-lred) + (docTeX-mode nerd-icons-sucicon "nf-seti-tex" :face nerd-icons-lred) + (ConTeXt-mode nerd-icons-sucicon "nf-seti-tex" :face nerd-icons-lred) + (AmSTeX-mode nerd-icons-sucicon "nf-seti-tex" :face nerd-icons-lred) + (plain-TeX-mode nerd-icons-sucicon "nf-seti-tex" :face nerd-icons-lred) + (Texinfo-mode nerd-icons-sucicon "nf-seti-tex" :face nerd-icons-lred) + (japanese-plain-TeX-mode nerd-icons-sucicon "nf-seti-tex" :face nerd-icons-lred) + (japanese-LaTeX-mode nerd-icons-sucicon "nf-seti-tex" :face nerd-icons-lred) + (dart-mode nerd-icons-devicon "nf-dev-dart" :face nerd-icons-blue) + (fsharp-mode nerd-icons-devicon "nf-dev-fsharp" :face nerd-icons-blue) + (asm-mode nerd-icons-sucicon "nf-seti-asm" :face nerd-icons-blue) + (fasm-mode nerd-icons-sucicon "nf-seti-asm" :face nerd-icons-blue) + (masm-mode nerd-icons-sucicon "nf-seti-asm" :face nerd-icons-blue) + (nasm-mode nerd-icons-sucicon "nf-seti-asm" :face nerd-icons-blue) + (gas-mode nerd-icons-sucicon "nf-seti-asm" :face nerd-icons-blue) + ;; (tcl-mode nerd-icons-fileicon "tcl" :face nerd-icons-dred) + ;; (cuda-mode nerd-icons-fileicon "nvidia" :face nerd-icons-green) + (f90-mode nerd-icons-mdicon "nf-md-language_fortran" :face nerd-icons-purple) + ;; (hy-mode nerd-icons-fileicon "hy" :face nerd-icons-blue) + (glsl-mode nerd-icons-faicon "nf-fa-paint_brush" :face nerd-icons-green) + (zig-mode nerd-icons-sucicon "nf-seti-zig" :face nerd-icons-orange) + ;; (odin-mode nerd-icons-fileicon "odin" :face nerd-icons-lblue) + (pdf-view-mode nerd-icons-codicon "nf-cod-file_pdf" :face nerd-icons-dred) + (doc-view-mode nerd-icons-mdicon "nf-md-file_document" :face nerd-icons-lred) + (calibre-library-mode nerd-icons-codicon "nf-cod-library" :face nerd-icons-dblue) + (calibre-edit-mode nerd-icons-codicon "nf-cod-library" :face nerd-icons-lred) + (calibredb-search-mode nerd-icons-codicon "nf-cod-library" :face nerd-icons-dblue) + (calibredb-show-mode nerd-icons-codicon "nf-cod-library" :face nerd-icons-lblue) + (osm-mode nerd-icons-mdicon "nf-md-map_search" :face nerd-icons-lgreen) + (spacemacs-buffer-mode nerd-icons-sucicon "nf-custom-emacs" :face nerd-icons-purple) + + (elfeed-search-mode nerd-icons-faicon "nf-fa-rss_square" :face nerd-icons-orange) + (elfeed-summary-mode nerd-icons-faicon "nf-fa-rss_square" :face nerd-icons-orange) + (elfeed-show-mode nerd-icons-faicon "nf-fa-rss_square" :face nerd-icons-yellow) + (newsticker-treeview-mode nerd-icons-faicon "nf-fa-rss_square" :face nerd-icons-orange) + (newsticker-treeview-list-mode nerd-icons-faicon "nf-fa-rss_square" :face nerd-icons-lorange) + (newsticker-treeview-item-mode nerd-icons-faicon "nf-fa-rss_square" :face nerd-icons-yellow) + + (emms-browser-mode nerd-icons-faicon "nf-fa-music" :face nerd-icons-silver) + (emms-lyrics-mode nerd-icons-faicon "nf-fa-music" :face nerd-icons-silver) + (emms-show-all-mode nerd-icons-faicon "nf-fa-music" :face nerd-icons-silver) + (emms-metaplaylist-mode nerd-icons-faicon "nf-fa-music" :face nerd-icons-silver) + (emms-tag-editor-mode nerd-icons-faicon "nf-fa-music" :face nerd-icons-silver) + (emms-playlist-mode nerd-icons-faicon "nf-fa-music" :face nerd-icons-silver) + (lilypond-mode nerd-icons-faicon "nf-fa-music" :face nerd-icons-green) + (bongo-playlist-mode nerd-icons-faicon "nf-fa-music" :face nerd-icons-silver) + (bongo-library-mode nerd-icons-faicon "nf-fa-music" :face nerd-icons-silver) + (mingus-playlist-mode nerd-icons-faicon "nf-fa-music" :face nerd-icons-silver) + (mingus-help-mode nerd-icons-faicon "nf-fa-music" :face nerd-icons-silver) + (mingus-browse-mode nerd-icons-faicon "nf-fa-music" :face nerd-icons-silver) + (mingus-burn-mode nerd-icons-faicon "nf-fa-music" :face nerd-icons-silver) + (simple-mpc-mode nerd-icons-faicon "nf-fa-music" :face nerd-icons-silver) + (telega-root-mode nerd-icons-faicon "nf-fae-telegram" :face nerd-icons-purple) + (telega-chat-mode nerd-icons-faicon "nf-fae-telegram" :face nerd-icons-blue) + (mastodon-mode nerd-icons-mdicon "nf-md-mastodon" :face nerd-icons-blue) + + (fanyi-mode nerd-icons-codicon "nf-cod-library" :face nerd-icons-lcyan) + (osx-dictionary-mode nerd-icons-codicon "nf-cod-library" :face nerd-icons-lcyan) + (youdao-dictionary-mode nerd-icons-codicon "nf-cod-library" :face nerd-icons-lcyan) + + (magik-mode nerd-icons-faicon "nf-fa-magic" :face nerd-icons-blue) + (magik-ts-mode nerd-icons-faicon "nf-fa-magic" :face nerd-icons-blue) + (magik-session-mode nerd-icons-devicon "nf-dev-terminal" :face nerd-icons-blue) + (magik-cb-mode nerd-icons-faicon "nf-fa-book" :face nerd-icons-blue) + ;; (meson-mode nerd-icons-fileicon "meson" :face nerd-icons-purple) + ;; (man-common nerd-icons-fileicon "man-page" :face nerd-icons-blue) + (heex-mode nerd-icons-sucicon "nf-seti-elixir" :face nerd-icons-lorange) + (heex-ts-mode nerd-icons-sucicon "nf-seti-elixir" :face nerd-icons-lorange) + (julia-mode nerd-icons-sucicon "nf-seti-julia" :face nerd-icons-purple) + (julia-ts-mode nerd-icons-sucicon "nf-seti-julia" :face nerd-icons-purple) + (flycheck-error-list nerd-icons-faicon "nf-fa-list_alt" :face nerd-icons-lred))) + +(defvar nerd-icons-url-alist + '( + ;; Social media and communities + ("^\\(https?://\\)?\\(www\\.\\)?del\\.icio\\.us" nerd-icons-faicon "nf-fa-delicious") + ("^\\(https?://\\)?\\(www\\.\\)?behance\\.net" nerd-icons-faicon "nf-fa-behance") + ("^\\(https?://\\)?\\(www\\.\\)?dribbble\\.com" nerd-icons-faicon "nf-fa-dribbble") + ("^\\(https?://\\)?\\(www\\.\\)?facebook\\.com" nerd-icons-faicon "nf-fa-facebook_official") + ("^\\(https?://\\)?\\(www\\.\\)?glide\\.me" nerd-icons-faicon "nf-fa-glide_g") + ("^\\(https?://\\)?\\(www\\.\\)?plus\\.google\\.com" nerd-icons-faicon "nf-fa-google_plus") + ("linkedin\\.com" nerd-icons-faicon "nf-fa-linkedin") + ("^\\(https?://\\)?\\(www\\.\\)?ok\\.ru" nerd-icons-faicon "nf-fa-odnoklassniki") + ("^\\(https?://\\)?\\(www\\.\\)?reddit\\.com" nerd-icons-faicon "nf-fa-reddit_alien") + ("^\\(https?://\\)?\\(www\\.\\)?slack\\.com" nerd-icons-faicon "nf-fa-slack") + ("^\\(https?://\\)?\\(www\\.\\)?snapchat\\.com" nerd-icons-faicon "nf-fa-snapchat_ghost") + ("^\\(https?://\\)?\\(www\\.\\)?weibo\\.com" nerd-icons-faicon "nf-fa-weibo") + ("^\\(https?://\\)?\\(www\\.\\)?twitter\\.com" nerd-icons-faicon "nf-fa-twitter") + ;; Blogging + ("joomla\\.org" nerd-icons-faicon "nf-fa-joomla") + ("^\\(https?://\\)?\\(www\\.\\)?medium\\.com" nerd-icons-faicon "nf-fa-medium") + ("tumblr\\.com" nerd-icons-faicon "nf-fa-tumblr") + ("^wordpress\\.com" nerd-icons-faicon "nf-fa-wordpress") + ;; Programming + ("^\\(https?://\\)?\\(www\\.\\)?bitbucket\\.org" nerd-icons-faicon "nf-fa-bitbucket") + ("^\\(https?://\\)?\\(www\\.\\)?codepen\\.io" nerd-icons-faicon "nf-fa-codepen") + ("^\\(https?://\\)?\\(www\\.\\)?codiepie\\.com" nerd-icons-faicon "nf-fa-codiepie") + ("^\\(https?://\\)?\\(www\\.\\)?gist\\.github\\.com" nerd-icons-octicon "nf-oct-logo_gist") + ("^\\(https?://\\)?\\(www\\.\\)?github\\.com" nerd-icons-octicon "nf-oct-mark_github") + ("^\\(https?://\\)?\\(www\\.\\)?gitlab\\.com" nerd-icons-faicon "nf-fa-gitlab") + ("^\\(https?://\\)?\\(www\\.\\)?news\\.ycombinator\\.com" nerd-icons-faicon "nf-fa-hacker_news") + ("^\\(https?://\\)?\\(www\\.\\)?jsfiddle\\.net" nerd-icons-faicon "nf-fa-jsfiddle") + ("^\\(https?://\\)?\\(www\\.\\)?maxcdn\\.com" nerd-icons-faicon "nf-fa-maxcdn") + ("^\\(https?://\\)?\\(www\\.\\)?stackoverflow\\.com" nerd-icons-faicon "nf-fa-stack_overflow") + ;; Video + ("^\\(https?://\\)?\\(www\\.\\)?twitch\\.tv" nerd-icons-faicon "nf-fa-twitch") + ("^\\(https?://\\)?\\(www\\.\\)?vimeo\\.com" nerd-icons-faicon "nf-fa-vimeo") + ("^\\(https?://\\)?\\(www\\.\\)?youtube\\.com" nerd-icons-faicon "nf-fa-youtube") + ("^\\(https?://\\)?\\(www\\.\\)?youtu\\.be" nerd-icons-faicon "nf-fa-youtube") + ("^\\(https?://\\)?\\(www\\.\\)?vine\\.co" nerd-icons-faicon "nf-fa-vine") + ;; Sound + ("^\\(https?://\\)?\\(www\\.\\)?last\\.fm" nerd-icons-faicon "nf-fa-lastfm") + ("^\\(https?://\\)?\\(www\\.\\)?mixcloud\\.com" nerd-icons-faicon "nf-fa-mixcloud") + ("^\\(https?://\\)?\\(www\\.\\)?soundcloud\\.com" nerd-icons-faicon "nf-fa-soundcloud") + ("spotify\\.com" nerd-icons-faicon "nf-fa-spotify") + ;; Shopping + ("^\\(https?://\\)?\\(www\\.\\)?amazon\\." nerd-icons-faicon "nf-fa-amazon") + ("^\\(https?://\\)?\\(www\\.\\)?opencart\\.com" nerd-icons-faicon "nf-fa-opencart") + ("^\\(https?://\\)?\\(www\\.\\)?paypal\\.com" nerd-icons-faicon "nf-fa-paypal") + ("^\\(https?://\\)?\\(www\\.\\)?shirtsinbulk\\.com" nerd-icons-faicon "nf-fa-shitsinbulk") + ;; Images + ("^\\(https?://\\)?\\(www\\.\\)?500px\\.com" nerd-icons-faicon "nf-fa-500px") + ("^\\(https?://\\)?\\(www\\.\\)?deviantart\\.com" nerd-icons-faicon "nf-fa-deviantart") + ("^\\(https?://\\)?\\(www\\.\\)?flickr\\.com" nerd-icons-faicon "nf-fa-flickr") + ("^\\(https?://\\)?\\(www\\.\\)?instagram\\.com" nerd-icons-faicon "nf-fa-instagram") + ("^\\(https?://\\)?\\(www\\.\\)?pinterest\\." nerd-icons-faicon "nf-fa-pinterest") + ;; Information and books + ("^\\(https?://\\)?\\(www\\.\\)?digg\\.com" nerd-icons-faicon "nf-fa-digg") + ("^\\(https?://\\)?\\(www\\.\\)?foursquare\\.com" nerd-icons-faicon "nf-fa-foursquare") + ("^\\(https?://\\)?\\(www\\.\\)?getpocket\\.com" nerd-icons-faicon "nf-fa-get_pocket") + ("^\\(https?://\\)?\\(www\\.\\)?scribd\\.com" nerd-icons-faicon "nf-fa-scribd") + ("^\\(https?://\\)?\\(www\\.\\)?slideshare\\.net" nerd-icons-faicon "nf-fa-slideshare") + ("stackexchange\\.com" nerd-icons-faicon "nf-fa-stack_exchange") + ("^\\(https?://\\)?\\(www\\.\\)?stumbleupon\\.com" nerd-icons-faicon "nf-fa-stumbleupon") + ("^\\(https?://\\)?\\(www\\.\\)?tripadvisor\\." nerd-icons-faicon "nf-fa-tripadvisor") + ("^\\(https?://\\)?\\(www\\.\\)?yelp\\." nerd-icons-faicon "nf-fa-yelp") + + ("wikipedia\\.org" nerd-icons-faicon "nf-fa-wikipedia_w") + ;; Various companies and tools + ("^\\(https?://\\)?\\(www\\.\\)?angel\\.co" nerd-icons-faicon "nf-fa-angellist") + ("^\\(https?://\\)?\\(www\\.\\)?apple\\.com" nerd-icons-faicon "nf-fa-apple") + ("^\\(https?://\\)?\\(www\\.\\)?buysellads\\.com" nerd-icons-faicon "nf-fa-buysellads") + ("^\\(https?://\\)?\\(www\\.\\)?connectdevelop\\.com" nerd-icons-faicon "nf-fa-connectdevelop") + ("^\\(https?://\\)?\\(www\\.\\)?dashcube\\.com" nerd-icons-faicon "nf-fa-dashcube") + ("^\\(https?://\\)?\\(www\\.\\)?dropbox\\.com" nerd-icons-faicon "nf-fa-dropbox") + ("^\\(https?://\\)?\\(www\\.\\)?enviragallery\\.com" nerd-icons-faicon "nf-fa-envira") + ("^\\(https?://\\)?\\(www\\.\\)?fortawesome\\.com" nerd-icons-faicon "nf-fa-fort_awesome") + ("^\\(https?://\\)?\\(www\\.\\)?forumbee\\.com" nerd-icons-faicon "nf-fa-forumbee") + ("^\\(https?://\\)?\\(www\\.\\)?gratipay\\.com" nerd-icons-faicon "nf-fa-gratipay") + ("^\\(https?://\\)?\\(www\\.\\)?modx\\.com" nerd-icons-faicon "nf-fa-modx") + ("^\\(https?://\\)?\\(www\\.\\)?pagelines\\.com" nerd-icons-faicon "nf-fa-pagelines") + ("^\\(https?://\\)?\\(www\\.\\)?producthunt\\.com" nerd-icons-faicon "nf-fa-product_hunt") + ("sellsy\\.com" nerd-icons-faicon "nf-fa-sellsy") + ("^\\(https?://\\)?\\(www\\.\\)?simplybuilt\\.com" nerd-icons-faicon "nf-fa-simplybuilt") + ("^\\(https?://\\)?\\(www\\.\\)?skyatlas\\.com" nerd-icons-faicon "nf-fa-skyatlas") + ("^\\(https?://\\)?\\(www\\.\\)?skype\\.com" nerd-icons-faicon "nf-fa-skype") + ("steampowered\\.com" nerd-icons-faicon "nf-fa-steam") + ("^\\(https?://\\)?\\(www\\.\\)?themeisle\\.com" nerd-icons-faicon "nf-fa-themeisle") + ("^\\(https?://\\)?\\(www\\.\\)?trello\\.com" nerd-icons-faicon "nf-fa-trello") + ("^\\(https?://\\)?\\(www\\.\\)?whatsapp\\.com" nerd-icons-faicon "nf-fa-whatsapp") + ("^\\(https?://\\)?\\(www\\.\\)?ycombinator\\.com" nerd-icons-faicon "nf-fa-y_combinator") + ("yahoo\\.com" nerd-icons-faicon "nf-fa-yahoo") + ("^\\(https?://\\)?\\(www\\.\\)?yoast\\.com" nerd-icons-faicon "nf-fa-yoast") + ;; Catch all + ("android" nerd-icons-faicon "nf-fa-android") + ("creativecommons" nerd-icons-faicon "nf-fa-creative_commons") + ("forums?" nerd-icons-codicon "nf-cod-comment_discussion") + ("\\.pdf$" nerd-icons-codicon "nf-cod-file_pdf" :face nerd-icons-dred) + ("google" nerd-icons-faicon "nf-fa-google") + ("\\.rss" nerd-icons-faicon "nf-fa-rss"))) + +(defun nerd-icons-auto-mode-match? (&optional file) + "Whether or not FILE's `major-mode' match against its `auto-mode-alist'." + (let* ((file (or file (buffer-file-name) (buffer-name))) + (auto-mode (nerd-icons-match-to-alist file auto-mode-alist))) + (eq major-mode auto-mode))) + +(defun nerd-icons-match-to-alist (file alist) + "Match FILE against an entry in ALIST using `string-match'." + (cdr (cl-find-if (lambda (it) (string-match (car it) file)) alist))) + +(defun nerd-icons-dir-is-submodule (dir) + "Checker whether or not DIR is a git submodule." + (let* ((gitmodule-dir (locate-dominating-file dir ".gitmodules")) + (modules-file (expand-file-name (format "%s.gitmodules" gitmodule-dir))) + (module-search (format "submodule \".*?%s\"" (file-name-base dir)))) + + (when (and gitmodule-dir (file-exists-p (format "%s/.git" dir))) + (with-temp-buffer + (insert-file-contents modules-file) + (search-forward-regexp module-search (point-max) t))))) + +(defun nerd-icons--read-candidates () + "Helper to build a list of candidates for all glyph sets." + (cl-reduce 'append (mapcar (lambda (it) (nerd-icons--read-candidates-for-glyph-set it t)) nerd-icons-glyph-sets))) + +(defun nerd-icons--read-candidates-for-glyph-set (glyph-set &optional show-glyph-set) + "Helper to build read candidates for GLYPH-SET. + +If SHOW-GLYPH-SET is non-nil, displays the icons glyph set in the candidate +string." + (let ((data (funcall (nerd-icons--data-name glyph-set))) + (icon-f (nerd-icons--function-name glyph-set))) + (mapcar + (lambda (it) + (let* ((icon-name (car it)) + + (icon-display (funcall icon-f icon-name)) + (icon-glyph-set (if show-glyph-set (format "\t[%s]" glyph-set) "")) + + (candidate-name (format "%s\t%s%s" icon-display icon-name icon-glyph-set)) + (candidate-icon (funcall (nerd-icons--function-name glyph-set) icon-name))) + (cons candidate-name candidate-icon))) + data))) + +;;;###autoload +(defun nerd-icons-install-fonts (&optional pfx) + "Helper function to download and install the latests fonts based on OS. +The provided Nerd Font is Symbols Nerd Font Mono. +When PFX is non-nil, ignore the prompt and just install" + (interactive "P") + (when (or pfx (yes-or-no-p "This will download and install fonts, are you sure you want to do this?")) + (let* ((url-format "https://raw.githubusercontent.com/rainstormstudio/nerd-icons.el/main/fonts/%s") + (font-dest (cond + ;; Default Linux install directories + ((member system-type '(gnu gnu/linux gnu/kfreebsd)) + (concat (or (getenv "XDG_DATA_HOME") + (concat (getenv "HOME") "/.local/share")) + "/fonts/" + nerd-icons-fonts-subdirectory)) + ;; Default MacOS install directory + ((eq system-type 'darwin) + (concat (getenv "HOME") + "/Library/Fonts/" + nerd-icons-fonts-subdirectory)))) + (known-dest? (stringp font-dest)) + (font-dest (or font-dest (read-directory-name "Font installation directory: " "~/")))) + + (unless (file-directory-p font-dest) (mkdir font-dest t)) + + (mapc (lambda (font) + (url-copy-file (format url-format font) (expand-file-name font font-dest) t)) + nerd-icons-font-names) + (when known-dest? + (message "Fonts downloaded, updating font cache... <fc-cache -f -v> ") + (shell-command-to-string (format "fc-cache -f -v"))) + (message "%s Successfully %s `nerd-icons' fonts to `%s'!" + (nerd-icons-wicon "nf-weather-stars" :v-adjust 0.0) + (if known-dest? "installed" "downloaded") + font-dest)))) + +;;;###autoload +(defun nerd-icons-insert (&optional arg glyph-set) + "Interactive icon insertion function. +When Prefix ARG is non-nil, insert the propertized icon. +When GLYPH-SET is non-nil, limit the candidates to the icon set matching it." + (interactive "P") + (let* ((standard-output (current-buffer)) + (candidates (if glyph-set + (nerd-icons--read-candidates-for-glyph-set glyph-set) + (nerd-icons--read-candidates))) + (prompt (if glyph-set + (format "%s Icon: " (funcall (nerd-icons--glyph-set-name glyph-set))) + "Icon : ")) + (selection (completing-read prompt candidates nil t)) + (result (cdr (assoc selection candidates)))) + + (if arg (prin1 result) (insert result)))) + +;;;###autoload +(defun nerd-icons-icon-for-dir (dir &rest arg-overrides) + "Get the formatted icon for DIR. +ARG-OVERRIDES should be a plist containining `:height', +`:v-adjust' or `:face' properties like in the normal icon +inserting functions." + (let* ((dir (or dir default-directory "/")) + (dirname (file-name-base (directory-file-name dir))) + (path (if (file-name-absolute-p dir) dir (expand-file-name dir))) + (icon (nerd-icons-match-to-alist dirname nerd-icons-dir-icon-alist)) + (args (cdr icon))) + (when arg-overrides (setq args (append `(,(car args)) arg-overrides (cdr args)))) + (cond + ((file-remote-p path) + (apply #'nerd-icons-codicon "nf-cod-remote" (cdr args))) + ((file-symlink-p path) + (apply #'nerd-icons-codicon "nf-cod-file_symlink_directory" (cdr args))) + ((nerd-icons-dir-is-submodule path) + (apply #'nerd-icons-codicon "nf-cod-file_submodule" (cdr args))) + ((file-exists-p (format "%s/.git" path)) + (apply #'nerd-icons-octicon "nf-oct-repo" (cdr args))) + (t (apply (car icon) args))))) + +;;;###autoload +(defun nerd-icons-icon-for-file (file &rest arg-overrides) + "Get the formatted icon for FILE. +ARG-OVERRIDES should be a plist containining `:height', +`:v-adjust' or `:face' properties like in the normal icon +inserting functions." + (let* ((name (file-name-nondirectory file)) + (ext (file-name-extension name)) + (icon (or (nerd-icons-match-to-alist name nerd-icons-regexp-icon-alist) + (and ext + (cdr (assoc (downcase ext) + nerd-icons-extension-icon-alist))) + nerd-icons-default-file-icon)) + (args (cdr icon))) + (when arg-overrides (setq args (append `(,(car args)) arg-overrides (cdr args)))) + (apply (car icon) args))) + +;;;###autoload +(defun nerd-icons-icon-for-extension (ext &rest arg-overrides) + "Get the formatted icon for EXT. +ARG-OVERRIDES should be a plist containining `:height', +`:v-adjust' or `:face' properties like in the normal icon +inserting functions." + (let* ((icon (or + (and ext + (cdr (assoc (downcase ext) + nerd-icons-extension-icon-alist))) + nerd-icons-default-file-icon)) + (args (cdr icon))) + (when arg-overrides (setq args (append `(,(car args)) arg-overrides (cdr args)))) + (apply (car icon) args))) + +;;;###autoload +(defun nerd-icons-icon-for-mode (mode &rest arg-overrides) + "Get the formatted icon for MODE. +ARG-OVERRIDES should be a plist containining `:height', +`:v-adjust' or `:face' properties like in the normal icon +inserting functions." + (let* ((icon (or (cdr (or (assoc mode nerd-icons-mode-icon-alist) + (assoc (get mode 'derived-mode-parent) nerd-icons-mode-icon-alist))) + nerd-icons-default-file-icon)) + (args (cdr icon))) + (when arg-overrides (setq args (append `(,(car args)) arg-overrides (cdr args)))) + (if icon (apply (car icon) args) mode))) + +;;;###autoload +(defun nerd-icons-icon-for-url (url &rest arg-overrides) + "Get the formatted icon for URL. +If an icon for URL isn't found in `nerd-icons-url-alist', a globe is used. +ARG-OVERRIDES should be a plist containining `:height', +`:v-adjust' or `:face' properties like in the normal icon +inserting functions." + (let* ((icon (nerd-icons-match-to-alist url nerd-icons-url-alist)) + (args (cdr icon))) + (unless icon + (setq icon '(nerd-icons-faicon "nf-fa-globe")) + (setq args (cdr icon))) + (when arg-overrides (setq args (append `(,(car args)) arg-overrides (cdr args)))) + (apply (car icon) args))) + +;;;###autoload +(defun nerd-icons-icon-for-buffer () + "Get the formatted icon for the current buffer. + +This function prioritises the use of the buffers file extension to +discern the icon when its `major-mode' matches its auto mode, +otherwise it will use the buffers `major-mode' to decide its +icon." + (nerd-icons--icon-info-for-buffer)) + +(defun nerd-icons-cache (func) + "Set a cache for FUNC. Does not work on interactive functions." + (unless (get func 'nerd-icons--cached) + (let ((cache (make-hash-table :test #'equal + :size nerd-icons--cache-limit)) + (orig-fn (symbol-function func))) + (fset func + (lambda (&rest args) + (or (gethash args cache) + (progn + (when (> (hash-table-count cache) + nerd-icons--cache-limit) + (clrhash cache)) + (puthash args (apply orig-fn args) cache))))))) + + (put func 'nerd-icons--cached t)) + +(nerd-icons-cache #'nerd-icons-icon-for-dir) +(nerd-icons-cache #'nerd-icons-icon-for-file) +(nerd-icons-cache #'nerd-icons-icon-for-extension) +(nerd-icons-cache #'nerd-icons-icon-for-mode) +(nerd-icons-cache #'nerd-icons-icon-for-url) + +(defun nerd-icons--icon-info-for-buffer (&optional f) + "Get icon info for the current buffer. +When F is provided, the info function is calculated with the format +`nerd-icons-icon-%s-for-file' or `nerd-icons-icon-%s-for-mode'." + (let* ((base-f (concat "nerd-icons-icon" (when f (format "-%s" f)))) + (file-f (intern (concat base-f "-for-file"))) + (mode-f (intern (concat base-f "-for-mode")))) + (if (and (buffer-file-name) + (nerd-icons-auto-mode-match?)) + (funcall file-f (file-name-nondirectory (buffer-file-name))) + (funcall mode-f major-mode)))) + +;; Weather icons +(defun nerd-icons-icon-for-weather (weather) + "Get an icon for a WEATHER status." + (let ((icon (nerd-icons-match-to-alist weather nerd-icons-weather-icon-alist))) + (if icon (apply (car icon) (cdr icon)) weather))) + +;; For `web-mode' +(defun nerd-icons--web-mode-icon (&rest arg-overrides) + "Get icon for a `web-mode' buffer with ARG-OVERRIDES." + (nerd-icons--web-mode arg-overrides)) +(defun nerd-icons--web-mode-icon-family () + "Get icon family for a `web-mode' buffer." + (nerd-icons--web-mode t)) + +(defvar web-mode-content-type) ; external +(defun nerd-icons--web-mode (&optional arg-overrides) + "Return icon or FAMILY for `web-mode' based on `web-mode-content-type'. +Providing ARG-OVERRIDES will modify the creation of the icon." + (let ((non-nil-args (cl-reduce (lambda (acc it) (if it (append acc (list it)) acc)) + arg-overrides :initial-value '()))) + (cond + ((equal web-mode-content-type "jsx") + (apply 'nerd-icons-devicon (append '("javascript") non-nil-args))) + ((equal web-mode-content-type "javascript") + (apply 'nerd-icons-devicon (append '("javascript") non-nil-args))) + ((equal web-mode-content-type "json") + (apply 'nerd-icons-devicon (append '("nf-dev-less") non-nil-args))) + ((equal web-mode-content-type "xml") + (apply 'nerd-icons-faicon (append '("nf-fa-file_code_o") non-nil-args))) + ((equal web-mode-content-type "css") + (apply 'nerd-icons-devicon (append '("nf-dev-css3") non-nil-args))) + (t + (apply 'nerd-icons-devicon (append '("nf-dev-html5") non-nil-args)))))) + +(eval-and-compile + (defun nerd-icons--function-name (name) + "Get the symbol for an icon function name for icon set NAME." + (intern (concat "nerd-icons-" (downcase (symbol-name name))))) + + (defun nerd-icons--family-name (name) + "Get the symbol for an icon family function for icon set NAME." + (intern (concat "nerd-icons-" (downcase (symbol-name name)) "-family"))) + + (defun nerd-icons--glyph-set-name (name) + "Get the symbol for an icon glyph set function for icon set NAME." + (intern (concat "nerd-icons-" (downcase (symbol-name name)) "-glyph-set"))) + + (defun nerd-icons--data-name (name) + "Get the symbol for an icon family function for icon set NAME." + (intern (concat "nerd-icons-" (downcase (symbol-name name)) "-data"))) + + (defun nerd-icons--insert-function-name (name) + "Get the symbol for an icon insert function for icon set NAME." + (intern (concat "nerd-icons-insert-" (downcase (symbol-name name)))))) + +(defun nerd-icons-insert-icons-for (family &optional height duration) + "Insert all of the available icons associated with FAMILY. +If a HEIGHT is provided it will render the icons at this height. +This is useful both to see the icons more clearly and to test +different height rendering. If DURATION is provided, it will +pause for DURATION seconds between printing each character." + (let* ((data-f (nerd-icons--data-name family)) + (insert-f (nerd-icons--function-name family)) + + (height (or height 1.0)) + (data (funcall data-f))) + (mapc + (lambda (it) + (insert (format "%s - %s\n" (funcall insert-f (car it) :height height) (car it))) + (when duration (sit-for duration))) + data))) + +(defun nerd-icons-set-font (&optional font-family frame) + "Modify nerd font charsets to use FONT-FAMILY for FRAME." + (let ((font-f (or font-family nerd-icons-font-family)) + (charsets '((#xe5fa . #xe6b2) ;; Seti-UI + Custom + (#xe700 . #xe7c5) ;; Devicons + (#xf000 . #xf2e0) ;; Font Awesome + (#xe200 . #xe2a9) ;; Font Awesome Extension + (#xf500 . #xfd46) (#xf0001 . #xf1af0) ;; Material Design Icons + (#xe300 . #xe3eb) ;; Weather + (#xf400 . #xf4a8) #x2665 #x26a1 #xf27c ;; Octicons + (#xe0a0 . #xe0a2) (#xe0b0 . #xe0b3) ;; Powerline Symbols + #xe0a3 (#xe0b4 . #xe0c8) (#xe0cc . #xe0d2) #xe0d4 ;; Powerline Extra Symbols + (#x23fb . #x23fe) #x2b58 ;; IEC Power Symbols + (#xf300 . #xf372) ;; Font Logos + (#xe000 . #xe00a) ;; Pomicons + (#xea60 . #xebeb)))) ;; Codicons + (cl-loop for charset in charsets do + (set-fontset-font + (frame-parameter nil 'font) + charset + (font-spec :family font-f + :weight nil + :size nil) + frame + 'prepend)))) + +(defmacro nerd-icons-define-icon (name alist family glyph-set) + "Macro to generate functions for inserting icons for icon set NAME. + +NAME defines is the name of the iconset and will produce a +function of the for `nerd-icon-NAME'. + +ALIST is the alist containing maps between icon names and the +UniCode for the character. All of these can be found in the data +directory of this package. + +FAMILY is the font family to use for the icons. +GLYPH-SET is the glyph set of the icon." + `(progn + (add-to-list 'nerd-icons-glyph-sets (quote ,name)) + (defun ,(nerd-icons--family-name name) () ,family) + (defun ,(nerd-icons--glyph-set-name name) () ,glyph-set) + (defun ,(nerd-icons--data-name name) () ,alist) + (defun ,(nerd-icons--function-name name) (icon-name &rest args) + (let ((icon (cdr (assoc icon-name ,alist))) + (other-face (when nerd-icons-color-icons (plist-get args :face))) + (height (* nerd-icons-scale-factor (or (plist-get args :height) 1.0))) + (v-adjust (* nerd-icons-scale-factor (or (plist-get args :v-adjust) nerd-icons-default-adjust))) + (family ,family)) + (unless icon + (error "Unable to find icon with name `%s' in icon set `%s'" icon-name (quote ,name))) + (let ((face (if other-face + `(:family ,family :height ,height :inherit ,other-face) + `(:family ,family :height ,height)))) + (propertize icon + 'face face + 'font-lock-face face + 'display `(raise ,v-adjust) + 'rear-nonsticky t)))) + (defun ,(nerd-icons--insert-function-name name) (&optional arg) + ,(format "Insert a %s icon at point." glyph-set) + (interactive "P") + (nerd-icons-insert arg (quote ,name))))) + +(nerd-icons-define-icon ipsicon nerd-icons/ipsicon-alist nerd-icons-font-family "IEC Power Symbols") +(nerd-icons-define-icon octicon nerd-icons/octicon-alist nerd-icons-font-family "Octicons") +(nerd-icons-define-icon pomicon nerd-icons/pomicon-alist nerd-icons-font-family "Pomicons") +(nerd-icons-define-icon powerline nerd-icons/powerline-alist nerd-icons-font-family "Powerline Symbols") +(nerd-icons-define-icon faicon nerd-icons/faicon-alist nerd-icons-font-family "Font Awesome") +(nerd-icons-define-icon wicon nerd-icons/wicon-alist nerd-icons-font-family "Weather") +(nerd-icons-define-icon sucicon nerd-icons/sucicon-alist nerd-icons-font-family "Seti-UI + Custom") +(nerd-icons-define-icon devicon nerd-icons/devicon-alist nerd-icons-font-family "Devicons") +(nerd-icons-define-icon codicon nerd-icons/codicon-alist nerd-icons-font-family "Codicons") +(nerd-icons-define-icon flicon nerd-icons/flicon-alist nerd-icons-font-family "Font Logos") +(nerd-icons-define-icon mdicon nerd-icons/mdicon-alist nerd-icons-font-family "Material Design Icons") + +(provide 'nerd-icons) +;;; nerd-icons.el ends here diff --git a/emacs/elpa/nerd-icons-20240524.311/nerd-icons.elc b/emacs/elpa/nerd-icons-20240524.311/nerd-icons.elc Binary files differ. diff --git a/emacs/elpa/notmuch-20240406.1803/notmuch-hello.el b/emacs/elpa/notmuch-20240406.1803/notmuch-hello.el @@ -1,1025 +0,0 @@ -;;; notmuch-hello.el --- welcome to notmuch, a frontend -*- lexical-binding: t -*- -;; -;; Copyright © David Edmondson -;; -;; This file is part of Notmuch. -;; -;; Notmuch 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. -;; -;; Notmuch 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 Notmuch. If not, see <https://www.gnu.org/licenses/>. -;; -;; Authors: David Edmondson <dme@dme.org> - -;;; Code: - -(require 'widget) -(require 'wid-edit) ; For `widget-forward'. - -(require 'notmuch-lib) -(require 'notmuch-mua) - -(declare-function notmuch-search "notmuch" - (&optional query oldest-first target-thread target-line - no-display)) -(declare-function notmuch-poll "notmuch-lib" ()) -(declare-function notmuch-tree "notmuch-tree" - (&optional query query-context target buffer-name - open-target unthreaded parent-buffer - oldest-first hide-excluded)) -(declare-function notmuch-unthreaded "notmuch-tree" - (&optional query query-context target buffer-name - open-target oldest-first hide-excluded)) - - -;;; Options - -(defun notmuch-saved-search-get (saved-search field) - "Get FIELD from SAVED-SEARCH. - -If SAVED-SEARCH is a plist, this is just `plist-get', but for -backwards compatibility, this also deals with the two other -possible formats for SAVED-SEARCH: cons cells (NAME . QUERY) and -lists (NAME QUERY COUNT-QUERY)." - (cond - ((keywordp (car saved-search)) - (plist-get saved-search field)) - ;; It is not a plist so it is an old-style entry. - ((consp (cdr saved-search)) - (pcase-let ((`(,name ,query ,count-query) saved-search)) - (cl-case field - (:name name) - (:query query) - (:count-query count-query) - (t nil)))) - (t - (pcase-let ((`(,name . ,query) saved-search)) - (cl-case field - (:name name) - (:query query) - (t nil)))))) - -(defun notmuch-hello-saved-search-to-plist (saved-search) - "Return a copy of SAVED-SEARCH in plist form. - -If saved search is a plist then just return a copy. In other -cases, for backwards compatibility, convert to plist form and -return that." - (if (keywordp (car saved-search)) - (copy-sequence saved-search) - (let ((fields (list :name :query :count-query)) - plist-search) - (dolist (field fields plist-search) - (let ((string (notmuch-saved-search-get saved-search field))) - (when string - (setq plist-search (append plist-search (list field string))))))))) - -(defun notmuch-hello--saved-searches-to-plist (symbol) - "Extract a saved-search variable into plist form. - -The new style saved search is just a plist, but for backwards -compatibility we use this function to extract old style saved -searches so they still work in customize." - (let ((saved-searches (default-value symbol))) - (mapcar #'notmuch-hello-saved-search-to-plist saved-searches))) - -(define-widget 'notmuch-saved-search-plist 'list - "A single saved search property list." - :tag "Saved Search" - :args '((list :inline t - :format "%v" - (group :format "%v" :inline t - (const :format " Name: " :name) - (string :format "%v")) - (group :format "%v" :inline t - (const :format " Query: " :query) - (string :format "%v"))) - (checklist :inline t - :format "%v" - (group :format "%v" :inline t - (const :format "Shortcut key: " :key) - (key-sequence :format "%v")) - (group :format "%v" :inline t - (const :format "Count-Query: " :count-query) - (string :format "%v")) - (group :format "%v" :inline t - (const :format "" :sort-order) - (choice :tag " Sort Order" - (const :tag "Default" nil) - (const :tag "Oldest-first" oldest-first) - (const :tag "Newest-first" newest-first))) - (group :format "%v" :inline t - (const :format "" :search-type) - (choice :tag " Search Type" - (const :tag "Search mode" nil) - (const :tag "Tree mode" tree) - (const :tag "Unthreaded mode" unthreaded)))))) - -(defcustom notmuch-saved-searches - `((:name "inbox" :query "tag:inbox" :key ,(kbd "i")) - (:name "unread" :query "tag:unread" :key ,(kbd "u")) - (:name "flagged" :query "tag:flagged" :key ,(kbd "f")) - (:name "sent" :query "tag:sent" :key ,(kbd "t")) - (:name "drafts" :query "tag:draft" :key ,(kbd "d")) - (:name "all mail" :query "*" :key ,(kbd "a"))) - "A list of saved searches to display. - -The saved search can be given in 3 forms. The preferred way is as -a plist. Supported properties are - - :name Name of the search (required). - :query Search to run (required). - :key Optional shortcut key for `notmuch-jump-search'. - :count-query Optional extra query to generate the count - shown. If not present then the :query property - is used. - :sort-order Specify the sort order to be used for the search. - Possible values are `oldest-first', `newest-first' - or nil. Nil means use the default sort order. - :excluded Whether to show mail with excluded tags in the - search. Possible values are `hide', `show', - or nil. Nil means use the default value of - `notmuch-search-hide-excluded'. - :search-type Specify whether to run the search in search-mode, - tree mode or unthreaded mode. Set to `tree' to - specify tree mode, \\='unthreaded to specify - unthreaded mode, and set to nil (or anything - except tree and unthreaded) to specify search - mode. - -Other accepted forms are a cons cell of the form (NAME . QUERY) -or a list of the form (NAME QUERY COUNT-QUERY)." - ;; The saved-search format is also used by the all-tags notmuch-hello - ;; section. This section generates its own saved-search list in one of - ;; the latter two forms. - :get 'notmuch-hello--saved-searches-to-plist - :type '(repeat notmuch-saved-search-plist) - :tag "List of Saved Searches" - :group 'notmuch-hello) - -(defcustom notmuch-hello-recent-searches-max 10 - "The number of recent searches to display." - :type 'integer - :group 'notmuch-hello) - -(defcustom notmuch-show-empty-saved-searches nil - "Should saved searches with no messages be listed?" - :type 'boolean - :group 'notmuch-hello) - -(defun notmuch-sort-saved-searches (saved-searches) - "Generate an alphabetically sorted saved searches list." - (sort (copy-sequence saved-searches) - (lambda (a b) - (string< (notmuch-saved-search-get a :name) - (notmuch-saved-search-get b :name))))) - -(defcustom notmuch-saved-search-sort-function nil - "Function used to sort the saved searches for the notmuch-hello view. - -This variable controls how saved searches should be sorted. No -sorting (nil) displays the saved searches in the order they are -stored in `notmuch-saved-searches'. Sort alphabetically sorts the -saved searches in alphabetical order. Custom sort function should -be a function or a lambda expression that takes the saved -searches list as a parameter, and returns a new saved searches -list to be used. For compatibility with the various saved-search -formats it should use notmuch-saved-search-get to access the -fields of the search." - :type '(choice (const :tag "No sorting" nil) - (const :tag "Sort alphabetically" notmuch-sort-saved-searches) - (function :tag "Custom sort function" - :value notmuch-sort-saved-searches)) - :group 'notmuch-hello) - -(defvar notmuch-hello-indent 4 - "How much to indent non-headers.") - -(defimage notmuch-hello-logo ((:type svg :file "notmuch-logo.svg"))) - -(defcustom notmuch-show-logo t - "Should the notmuch logo be shown?" - :type 'boolean - :group 'notmuch-hello) - -(defcustom notmuch-show-all-tags-list nil - "Should all tags be shown in the notmuch-hello view?" - :type 'boolean - :group 'notmuch-hello) - -(defcustom notmuch-hello-tag-list-make-query nil - "Function or string to generate queries for the all tags list. - -This variable controls which query results are shown for each tag -in the \"all tags\" list. If nil, it will use all messages with -that tag. If this is set to a string, it is used as a filter for -messages having that tag (equivalent to \"tag:TAG and (THIS-VARIABLE)\"). -Finally this can be a function that will be called for each tag and -should return a filter for that tag, or nil to hide the tag." - :type '(choice (const :tag "All messages" nil) - (const :tag "Unread messages" "tag:unread") - (string :tag "Custom filter" - :value "tag:unread") - (function :tag "Custom filter function")) - :group 'notmuch-hello) - -(defcustom notmuch-hello-hide-tags nil - "List of tags to be hidden in the \"all tags\"-section." - :type '(repeat string) - :group 'notmuch-hello) - -(defface notmuch-hello-logo-background - '((((class color) - (background dark)) - (:background "#5f5f5f")) - (((class color) - (background light)) - (:background "white"))) - "Background colour for the notmuch logo." - :group 'notmuch-hello - :group 'notmuch-faces) - -(defcustom notmuch-column-control t - "Controls the number of columns for saved searches/tags in notmuch view. - -This variable has three potential sets of values: - -- t: automatically calculate the number of columns possible based - on the tags to be shown and the window width, -- an integer: a lower bound on the number of characters that will - be used to display each column, -- a float: a fraction of the window width that is the lower bound - on the number of characters that should be used for each - column. - -So: -- if you would like two columns of tags, set this to 0.5. -- if you would like a single column of tags, set this to 1.0. -- if you would like tags to be 30 characters wide, set this to - 30. -- if you don't want to worry about all of this nonsense, leave - this set to `t'." - :type '(choice - (const :tag "Automatically calculated" t) - (integer :tag "Number of characters") - (float :tag "Fraction of window")) - :group 'notmuch-hello) - -(defcustom notmuch-hello-thousands-separator " " - "The string used as a thousands separator. - -Typically \",\" in the US and UK and \".\" or \" \" in Europe. -The latter is recommended in the SI/ISO 31-0 standard and by the -International Bureau of Weights and Measures." - :type 'string - :group 'notmuch-hello) - -(defcustom notmuch-hello-mode-hook nil - "Functions called after entering `notmuch-hello-mode'." - :type 'hook - :group 'notmuch-hello - :group 'notmuch-hooks) - -(defcustom notmuch-hello-refresh-hook nil - "Functions called after updating a `notmuch-hello' buffer." - :type 'hook - :group 'notmuch-hello - :group 'notmuch-hooks) - -(defconst notmuch-hello-url "https://notmuchmail.org" - "The `notmuch' web site.") - -(defvar notmuch-hello-custom-section-options - '((:filter (string :tag "Filter for each tag")) - (:filter-count (string :tag "Different filter to generate message counts")) - (:initially-hidden (const :tag "Hide this section on startup" t)) - (:show-empty-searches (const :tag "Show queries with no matching messages" t)) - (:hide-if-empty (const :tag "Hide this section if all queries are empty -\(and not shown by show-empty-searches)" t))) - "Various customization-options for notmuch-hello-tags/query-section.") - -(define-widget 'notmuch-hello-tags-section 'lazy - "Customize-type for notmuch-hello tag-list sections." - :tag "Customized tag-list section (see docstring for details)" - :type - `(list :tag "" - (const :tag "" notmuch-hello-insert-tags-section) - (string :tag "Title for this section") - (plist - :inline t - :options - ,(append notmuch-hello-custom-section-options - '((:hide-tags (repeat :tag "Tags that will be hidden" - string))))))) - -(define-widget 'notmuch-hello-query-section 'lazy - "Customize-type for custom saved-search-like sections" - :tag "Customized queries section (see docstring for details)" - :type - `(list :tag "" - (const :tag "" notmuch-hello-insert-searches) - (string :tag "Title for this section") - (repeat :tag "Queries" - (cons (string :tag "Name") (string :tag "Query"))) - (plist :inline t :options ,notmuch-hello-custom-section-options))) - -(defcustom notmuch-hello-sections - (list #'notmuch-hello-insert-header - #'notmuch-hello-insert-saved-searches - #'notmuch-hello-insert-search - #'notmuch-hello-insert-recent-searches - #'notmuch-hello-insert-alltags - #'notmuch-hello-insert-footer) - "Sections for notmuch-hello. - -The list contains functions which are used to construct sections in -notmuch-hello buffer. When notmuch-hello buffer is constructed, -these functions are run in the order they appear in this list. Each -function produces a section simply by adding content to the current -buffer. A section should not end with an empty line, because a -newline will be inserted after each section by `notmuch-hello'. - -Each function should take no arguments. The return value is -ignored. - -For convenience an element can also be a list of the form (FUNC ARG1 -ARG2 .. ARGN) in which case FUNC will be applied to the rest of the -list. - -A \"Customized tag-list section\" item in the customize-interface -displays a list of all tags, optionally hiding some of them. It -is also possible to filter the list of messages matching each tag -by an additional filter query. Similarly, the count of messages -displayed next to the buttons can be generated by applying a -different filter to the tag query. These filters are also -supported for \"Customized queries section\" items." - :group 'notmuch-hello - :type - '(repeat - (choice (function-item notmuch-hello-insert-header) - (function-item notmuch-hello-insert-saved-searches) - (function-item notmuch-hello-insert-search) - (function-item notmuch-hello-insert-recent-searches) - (function-item notmuch-hello-insert-alltags) - (function-item notmuch-hello-insert-footer) - (function-item notmuch-hello-insert-inbox) - notmuch-hello-tags-section - notmuch-hello-query-section - (function :tag "Custom section")))) - -(defcustom notmuch-hello-auto-refresh t - "Automatically refresh when returning to the notmuch-hello buffer." - :group 'notmuch-hello - :type 'boolean) - -;;; Internal variables - -(defvar notmuch-hello-hidden-sections nil - "List of sections titles whose contents are hidden.") - -(defvar notmuch-hello-first-run t - "True if `notmuch-hello' is run for the first time, set to nil afterwards.") - -;;; Widgets for inserters - -(define-widget 'notmuch-search-item 'item - "A recent search." - :format "%v\n" - :value-create 'notmuch-search-item-value-create) - -(defun notmuch-search-item-value-create (widget) - (let ((value (widget-get widget :value))) - (widget-insert (make-string notmuch-hello-indent ?\s)) - (widget-create 'editable-field - :size (widget-get widget :size) - :parent widget - :action #'notmuch-hello-search - value) - (widget-insert " ") - (widget-create 'push-button - :parent widget - :notify #'notmuch-hello-add-saved-search - "save") - (widget-insert " ") - (widget-create 'push-button - :parent widget - :notify #'notmuch-hello-delete-search-from-history - "del"))) - -(defun notmuch-search-item-field-width () - (max 8 ; Don't let the search boxes be less than 8 characters wide. - (- (window-width) - notmuch-hello-indent ; space at bol - notmuch-hello-indent ; space at eol - 1 ; for the space before the [save] button - 6 ; for the [save] button - 1 ; for the space before the [del] button - 5))) ; for the [del] button - -;;; Widget actions - -(defun notmuch-hello-search (widget &rest _event) - (let ((search (widget-value widget))) - (when search - (setq search (string-trim search)) - (let ((history-delete-duplicates t)) - (add-to-history 'notmuch-search-history search))) - (notmuch-search search notmuch-search-oldest-first))) - -(defun notmuch-hello-add-saved-search (widget &rest _event) - (let ((search (widget-value (widget-get widget :parent))) - (name (completing-read "Name for saved search: " - notmuch-saved-searches))) - ;; If an existing saved search with this name exists, remove it. - (setq notmuch-saved-searches - (cl-loop for elem in notmuch-saved-searches - unless (equal name (notmuch-saved-search-get elem :name)) - collect elem)) - ;; Add the new one. - (customize-save-variable 'notmuch-saved-searches - (add-to-list 'notmuch-saved-searches - (list :name name :query search) t)) - (message "Saved '%s' as '%s'." search name) - (notmuch-hello-update))) - -(defun notmuch-hello-delete-search-from-history (widget &rest _event) - (when (y-or-n-p "Are you sure you want to delete this search? ") - (let ((search (widget-value (widget-get widget :parent)))) - (setq notmuch-search-history - (delete search notmuch-search-history))) - (notmuch-hello-update))) - -;;; Button utilities - -;; `notmuch-hello-query-counts', `notmuch-hello-nice-number' and -;; `notmuch-hello-insert-buttons' are used outside this section. -;; All other functions that are defined in this section are only -;; used by these two functions. - -(defun notmuch-hello-longest-label (searches-alist) - (or (cl-loop for elem in searches-alist - maximize (length (notmuch-saved-search-get elem :name))) - 0)) - -(defun notmuch-hello-reflect-generate-row (ncols nrows row list) - (let ((len (length list))) - (cl-loop for col from 0 to (- ncols 1) - collect (let ((offset (+ (* nrows col) row))) - (if (< offset len) - (nth offset list) - ;; Don't forget to insert an empty slot in the - ;; output matrix if there is no corresponding - ;; value in the input matrix. - nil))))) - -(defun notmuch-hello-reflect (list ncols) - "Reflect a `ncols' wide matrix represented by `list' along the -diagonal." - ;; Not very lispy... - (let ((nrows (ceiling (length list) ncols))) - (cl-loop for row from 0 to (- nrows 1) - append (notmuch-hello-reflect-generate-row ncols nrows row list)))) - -(defun notmuch-hello-widget-search (widget &rest _ignore) - (let ((search-terms (widget-get widget :notmuch-search-terms)) - (oldest-first (widget-get widget :notmuch-search-oldest-first)) - (exclude (widget-get widget :notmuch-search-hide-excluded))) - (cl-case (widget-get widget :notmuch-search-type) - (tree - (let ((n (notmuch-search-format-buffer-name (widget-value widget) "tree" t))) - (notmuch-tree search-terms nil nil n nil nil nil oldest-first exclude))) - (unthreaded - (let ((n (notmuch-search-format-buffer-name (widget-value widget) - "unthreaded" t))) - (notmuch-unthreaded search-terms nil nil n nil oldest-first exclude))) - (t - (notmuch-search search-terms oldest-first exclude))))) - -(defun notmuch-saved-search-count (search) - (car (notmuch--process-lines notmuch-command "count" search))) - -(defun notmuch-hello-tags-per-line (widest) - "Determine how many tags to show per line and how wide they -should be. Returns a cons cell `(tags-per-line width)'." - (let ((tags-per-line - (cond - ((integerp notmuch-column-control) - (max 1 - (/ (- (window-width) notmuch-hello-indent) - ;; Count is 9 wide (8 digits plus space), 1 for the space - ;; after the name. - (+ 9 1 (max notmuch-column-control widest))))) - ((floatp notmuch-column-control) - (let* ((available-width (- (window-width) notmuch-hello-indent)) - (proposed-width (max (* available-width notmuch-column-control) - widest))) - (floor available-width proposed-width))) - (t - (max 1 - (/ (- (window-width) notmuch-hello-indent) - ;; Count is 9 wide (8 digits plus space), 1 for the space - ;; after the name. - (+ 9 1 widest))))))) - (cons tags-per-line (/ (max 1 - (- (window-width) notmuch-hello-indent - ;; Count is 9 wide (8 digits plus - ;; space), 1 for the space after the - ;; name. - (* tags-per-line (+ 9 1)))) - tags-per-line)))) - -(defun notmuch-hello-filtered-query (query filter) - "Constructs a query to search all messages matching QUERY and FILTER. - -If FILTER is a string, it is directly used in the returned query. - -If FILTER is a function, it is called with QUERY as a parameter and -the string it returns is used as the query. If nil is returned, -the entry is hidden. - -Otherwise, FILTER is ignored." - (cond - ((functionp filter) (funcall filter query)) - ((stringp filter) - (concat "(" query ") and (" filter ")")) - (t query))) - -(defun notmuch-hello-query-counts (query-list &rest options) - "Compute list of counts of matched messages from QUERY-LIST. - -QUERY-LIST must be a list of saved-searches. Ideally each of -these is a plist but other options are available for backwards -compatibility: see `notmuch-saved-searches' for details. - -The result is a list of plists each of which includes the -properties :name NAME, :query QUERY and :count COUNT, together -with any properties in the original saved-search. - -The values :show-empty-searches, :filter and :filter-count from -options will be handled as specified for -`notmuch-hello-insert-searches'. :disable-includes can be used to -turn off the default exclude processing in `notmuch-count(1)'" - (with-temp-buffer - (dolist (elem query-list nil) - (let ((count-query (or (notmuch-saved-search-get elem :count-query) - (notmuch-saved-search-get elem :query)))) - (insert - (replace-regexp-in-string - "\n" " " - (notmuch-hello-filtered-query count-query - (or (plist-get options :filter-count) - (plist-get options :filter)))) - "\n"))) - (unless (= (notmuch--call-process-region (point-min) (point-max) notmuch-command - t t nil "count" - (if (plist-get options :disable-excludes) - "--exclude=false" - "--exclude=true") - "--batch") 0) - (notmuch-logged-error - "notmuch count --batch failed" - "Please check that the notmuch CLI is new enough to support `count ---batch'. In general we recommend running matching versions of -the CLI and emacs interface.")) - (goto-char (point-min)) - (cl-mapcan - (lambda (elem) - (let* ((elem-plist (notmuch-hello-saved-search-to-plist elem)) - (search-query (plist-get elem-plist :query)) - (filtered-query (notmuch-hello-filtered-query - search-query (plist-get options :filter))) - (message-count (prog1 (read (current-buffer)) - (forward-line 1)))) - (when (and filtered-query (or (plist-get options :show-empty-searches) - (> message-count 0))) - (setq elem-plist (plist-put elem-plist :query filtered-query)) - (list (plist-put elem-plist :count message-count))))) - query-list))) - -(defun notmuch-hello-nice-number (n) - (let (result) - (while (> n 0) - (push (% n 1000) result) - (setq n (/ n 1000))) - (setq result (or result '(0))) - (apply #'concat - (number-to-string (car result)) - (mapcar (lambda (elem) - (format "%s%03d" notmuch-hello-thousands-separator elem)) - (cdr result))))) - -(defun notmuch-hello-insert-buttons (searches) - "Insert buttons for SEARCHES. - -SEARCHES must be a list of plists each of which should contain at -least the properties :name NAME :query QUERY and :count COUNT, -where QUERY is the query to start when the button for the -corresponding entry is activated, and COUNT should be the number -of messages matching the query. Such a plist can be computed -with `notmuch-hello-query-counts'." - (let* ((widest (notmuch-hello-longest-label searches)) - (tags-and-width (notmuch-hello-tags-per-line widest)) - (tags-per-line (car tags-and-width)) - (column-width (cdr tags-and-width)) - (column-indent 0) - (count 0) - (reordered-list (notmuch-hello-reflect searches tags-per-line)) - ;; Hack the display of the buttons used. - (widget-push-button-prefix "") - (widget-push-button-suffix "")) - ;; dme: It feels as though there should be a better way to - ;; implement this loop than using an incrementing counter. - (mapc (lambda (elem) - ;; (not elem) indicates an empty slot in the matrix. - (when elem - (when (> column-indent 0) - (widget-insert (make-string column-indent ? ))) - (let* ((name (plist-get elem :name)) - (query (plist-get elem :query)) - (oldest-first (cl-case (plist-get elem :sort-order) - (newest-first nil) - (oldest-first t) - (otherwise notmuch-search-oldest-first))) - (exclude (cl-case (plist-get elem :excluded) - (hide t) - (show nil) - (otherwise notmuch-search-hide-excluded))) - (search-type (plist-get elem :search-type)) - (msg-count (plist-get elem :count))) - (widget-insert (format "%8s " - (notmuch-hello-nice-number msg-count))) - (widget-create 'push-button - :notify #'notmuch-hello-widget-search - :notmuch-search-terms query - :notmuch-search-oldest-first oldest-first - :notmuch-search-type search-type - :notmuch-search-hide-excluded exclude - name) - (setq column-indent - (1+ (max 0 (- column-width (length name))))))) - (cl-incf count) - (when (eq (% count tags-per-line) 0) - (setq column-indent 0) - (widget-insert "\n"))) - reordered-list) - ;; If the last line was not full (and hence did not include a - ;; carriage return), insert one now. - (unless (eq (% count tags-per-line) 0) - (widget-insert "\n")))) - -;;; Mode - -(defun notmuch-hello-update () - "Update the notmuch-hello buffer." - ;; Lazy - rebuild everything. - (interactive) - (notmuch-hello t)) - -(defun notmuch-hello-window-configuration-change () - "Hook function to update the hello buffer when it is switched to." - (let ((hello-buf (get-buffer "*notmuch-hello*")) - (do-refresh nil)) - ;; Consider all windows in the currently selected frame, since - ;; that's where the configuration change happened. This also - ;; refreshes our snapshot of all windows, so we have to do this - ;; even if we know we won't refresh (e.g., hello-buf is null). - (dolist (window (window-list)) - (let ((last-buf (window-parameter window 'notmuch-hello-last-buffer)) - (cur-buf (window-buffer window))) - (unless (eq last-buf cur-buf) - ;; This window changed or is new. Update recorded buffer - ;; for next time. - (set-window-parameter window 'notmuch-hello-last-buffer cur-buf) - (when (and (eq cur-buf hello-buf) last-buf) - ;; The user just switched to hello in this window (hello - ;; is currently visible, was not visible on the last - ;; configuration change, and this is not a new window) - (setq do-refresh t))))) - (when (and do-refresh notmuch-hello-auto-refresh) - ;; Refresh hello as soon as we get back to redisplay. On Emacs - ;; 24, we can't do it right here because something in this - ;; hook's call stack overrides hello's point placement. - ;; FIXME And on Emacs releases that we still support? - (run-at-time nil nil #'notmuch-hello t)) - (unless hello-buf - ;; Clean up hook - (remove-hook 'window-configuration-change-hook - #'notmuch-hello-window-configuration-change)))) - -(defvar notmuch-hello-mode-map - ;; Inherit both widget-keymap and notmuch-common-keymap. We have - ;; to use make-sparse-keymap to force this to be a new keymap (so - ;; that when we modify map it does not modify widget-keymap). - (let ((map (make-composed-keymap (list (make-sparse-keymap) widget-keymap)))) - (set-keymap-parent map notmuch-common-keymap) - ;; Currently notmuch-hello-mode supports free text entry, but not - ;; tagging operations, so provide standard undo. - (define-key map [remap notmuch-tag-undo] #'undo) - map) - "Keymap for \"notmuch hello\" buffers.") - -(define-derived-mode notmuch-hello-mode fundamental-mode "notmuch-hello" - "Major mode for convenient notmuch navigation. This is your entry -portal into notmuch. - -Saved searches are \"bookmarks\" for arbitrary queries. Hit RET -or click on a saved search to view matching threads. Edit saved -searches with the `edit' button. Type `\\[notmuch-jump-search]' -in any Notmuch screen for quick access to saved searches that -have shortcut keys. - -Type new searches in the search box and hit RET to view matching -threads. Hit RET in a recent search box to re-submit a previous -search. Edit it first if you like. Save a recent search to saved -searches with the `save' button. - -Hit `\\[notmuch-search]' or `\\[notmuch-tree]' in any Notmuch -screen to search for messages and view matching threads or -messages, respectively. Recent searches are available in the -minibuffer history. - -Expand the all tags view with the `show' button (and collapse -again with the `hide' button). Hit RET or click on a tag name to -view matching threads. - -Hit `\\[notmuch-refresh-this-buffer]' to refresh the screen and -`\\[notmuch-bury-or-kill-this-buffer]' to quit. - -The screen may be customized via `\\[customize]'. - -Complete list of currently available key bindings: - -\\{notmuch-hello-mode-map}" - (setq notmuch-buffer-refresh-function #'notmuch-hello-update)) - -;;; Inserters - -(defun notmuch-hello-generate-tag-alist (&optional hide-tags) - "Return an alist from tags to queries to display in the all-tags section." - (cl-mapcan (lambda (tag) - (and (not (member tag hide-tags)) - (list (cons tag - (concat "tag:" - (notmuch-escape-boolean-term tag)))))) - (notmuch--process-lines notmuch-command "search" "--output=tags" "*"))) - -(defun notmuch-hello-insert-header () - "Insert the default notmuch-hello header." - (when notmuch-show-logo - (let ((image notmuch-hello-logo)) - ;; The notmuch logo uses transparency. That can display poorly - ;; when inserting the image into an emacs buffer (black logo on - ;; a black background), so force the background colour of the - ;; image. We use a face to represent the colour so that - ;; `defface' can be used to declare the different possible - ;; colours, which depend on whether the frame has a light or - ;; dark background. - (setq image (cons 'image - (append (cdr image) - (list :background - (face-background - 'notmuch-hello-logo-background))))) - (insert-image image)) - (widget-insert " ")) - - (widget-insert "Welcome to ") - ;; Hack the display of the links used. - (let ((widget-link-prefix "") - (widget-link-suffix "")) - (widget-create 'link - :notify (lambda (&rest _ignore) - (browse-url notmuch-hello-url)) - :help-echo "Visit the notmuch website." - "notmuch") - (widget-insert ". ") - (widget-insert "You have ") - (widget-create 'link - :notify (lambda (&rest _ignore) - (notmuch-hello-update)) - :help-echo "Refresh" - (notmuch-hello-nice-number - (string-to-number - (car (notmuch--process-lines notmuch-command "count" "--exclude=false"))))) - (widget-insert " messages.\n"))) - -(defun notmuch-hello-insert-saved-searches () - "Insert the saved-searches section." - (let ((searches (notmuch-hello-query-counts - (if notmuch-saved-search-sort-function - (funcall notmuch-saved-search-sort-function - notmuch-saved-searches) - notmuch-saved-searches) - :show-empty-searches notmuch-show-empty-saved-searches))) - (when searches - (widget-insert "Saved searches: ") - (widget-create 'push-button - :notify (lambda (&rest _ignore) - (customize-variable 'notmuch-saved-searches)) - "edit") - (widget-insert "\n\n") - (let ((start (point))) - (notmuch-hello-insert-buttons searches) - (indent-rigidly start (point) notmuch-hello-indent))))) - -(defun notmuch-hello-insert-search () - "Insert a search widget." - (widget-insert "Search: ") - (widget-create 'editable-field - ;; Leave some space at the start and end of the - ;; search boxes. - :size (max 8 (- (window-width) notmuch-hello-indent - (length "Search: "))) - :action #'notmuch-hello-search) - ;; Add an invisible dot to make `widget-end-of-line' ignore - ;; trailing spaces in the search widget field. A dot is used - ;; instead of a space to make `show-trailing-whitespace' - ;; happy, i.e. avoid it marking the whole line as trailing - ;; spaces. - (widget-insert (propertize "." 'invisible t)) - (widget-insert "\n")) - -(defun notmuch-hello-insert-recent-searches () - "Insert recent searches." - (when notmuch-search-history - (widget-insert "Recent searches: ") - (widget-create - 'push-button - :notify (lambda (&rest _ignore) - (when (y-or-n-p "Are you sure you want to clear the searches? ") - (setq notmuch-search-history nil) - (notmuch-hello-update))) - "clear") - (widget-insert "\n\n") - (let ((width (notmuch-search-item-field-width))) - (dolist (search (seq-take notmuch-search-history - notmuch-hello-recent-searches-max)) - (widget-create 'notmuch-search-item :value search :size width))))) - -(defun notmuch-hello-insert-searches (title query-list &rest options) - "Insert a section with TITLE showing a list of buttons made from -QUERY-LIST. - -QUERY-LIST should ideally be a plist but for backwards -compatibility other forms are also accepted (see -`notmuch-saved-searches' for details). The plist should -contain keys :name and :query; if :count-query is also present -then it specifies an alternate query to be used to generate the -count for the associated search. - -Supports the following entries in OPTIONS as a plist: -:initially-hidden - if non-nil, section will be hidden on startup -:show-empty-searches - show buttons with no matching messages -:hide-if-empty - hide if no buttons would be shown - (only makes sense without :show-empty-searches) -:filter - This can be a function that takes the search query as - its argument and returns a filter to be used in conjunction - with the query for that search or nil to hide the - element. This can also be a string that is used as a combined - with each query using \"and\". -:filter-count - Separate filter to generate the count displayed - each search. Accepts the same values as :filter. If :filter - and :filter-count are specified, this will be used instead of - :filter, not in conjunction with it." - - (widget-insert title ": ") - (when (and notmuch-hello-first-run (plist-get options :initially-hidden)) - (add-to-list 'notmuch-hello-hidden-sections title)) - (let ((is-hidden (member title notmuch-hello-hidden-sections)) - (start (point))) - (if is-hidden - (widget-create 'push-button - :notify (lambda (&rest _ignore) - (setq notmuch-hello-hidden-sections - (delete title notmuch-hello-hidden-sections)) - (notmuch-hello-update)) - "show") - (widget-create 'push-button - :notify (lambda (&rest _ignore) - (add-to-list 'notmuch-hello-hidden-sections - title) - (notmuch-hello-update)) - "hide")) - (widget-insert "\n") - (unless is-hidden - (let ((searches (apply 'notmuch-hello-query-counts query-list options))) - (when (or (not (plist-get options :hide-if-empty)) - searches) - (widget-insert "\n") - (notmuch-hello-insert-buttons searches) - (indent-rigidly start (point) notmuch-hello-indent)))))) - -(defun notmuch-hello-insert-tags-section (&optional title &rest options) - "Insert a section displaying all tags with message counts. - -TITLE defaults to \"All tags\". -Allowed options are those accepted by `notmuch-hello-insert-searches' and the -following: - -:hide-tags - List of tags that should be excluded." - (apply 'notmuch-hello-insert-searches - (or title "All tags") - (notmuch-hello-generate-tag-alist (plist-get options :hide-tags)) - options)) - -(defun notmuch-hello-insert-inbox () - "Show an entry for each saved search and inboxed messages for each tag." - (notmuch-hello-insert-searches "What's in your inbox" - (append - notmuch-saved-searches - (notmuch-hello-generate-tag-alist)) - :filter "tag:inbox")) - -(defun notmuch-hello-insert-alltags () - "Insert a section displaying all tags and associated message counts." - (notmuch-hello-insert-tags-section - nil - :initially-hidden (not notmuch-show-all-tags-list) - :hide-tags notmuch-hello-hide-tags - :filter notmuch-hello-tag-list-make-query - :disable-excludes t)) - -(defun notmuch-hello-insert-footer () - "Insert the notmuch-hello footer." - (let ((start (point))) - (widget-insert "Hit `?' for context-sensitive help in any Notmuch screen.\n") - (widget-insert "Customize ") - (widget-create 'link - :notify (lambda (&rest _ignore) - (customize-group 'notmuch)) - :button-prefix "" :button-suffix "" - "Notmuch") - (widget-insert " or ") - (widget-create 'link - :notify (lambda (&rest _ignore) - (customize-variable 'notmuch-hello-sections)) - :button-prefix "" :button-suffix "" - "this page.") - (let ((fill-column (- (window-width) notmuch-hello-indent))) - (center-region start (point))))) - -;;; Hello! - -;;;###autoload -(defun notmuch-hello (&optional no-display) - "Run notmuch and display saved searches, known tags, etc." - (interactive) - (notmuch-assert-cli-sane) - ;; This may cause a window configuration change, so if the - ;; auto-refresh hook is already installed, avoid recursive refresh. - (let ((notmuch-hello-auto-refresh nil)) - (if no-display - (set-buffer "*notmuch-hello*") - (pop-to-buffer-same-window "*notmuch-hello*"))) - ;; Install auto-refresh hook - (when notmuch-hello-auto-refresh - (add-hook 'window-configuration-change-hook - #'notmuch-hello-window-configuration-change)) - (let ((target-line (line-number-at-pos)) - (target-column (current-column)) - (inhibit-read-only t)) - ;; Delete all editable widget fields. Editable widget fields are - ;; tracked in a buffer local variable `widget-field-list' (and - ;; others). If we do `erase-buffer' without properly deleting the - ;; widgets, some widget-related functions are confused later. - (mapc 'widget-delete widget-field-list) - (erase-buffer) - (unless (eq major-mode 'notmuch-hello-mode) - (notmuch-hello-mode)) - (let ((all (overlay-lists))) - ;; Delete all the overlays. - (mapc 'delete-overlay (car all)) - (mapc 'delete-overlay (cdr all))) - (mapc - (lambda (section) - (let ((point-before (point))) - (if (functionp section) - (funcall section) - (apply (car section) (cdr section))) - ;; don't insert a newline when the previous section didn't - ;; show anything. - (unless (eq (point) point-before) - (widget-insert "\n")))) - notmuch-hello-sections) - (widget-setup) - ;; Move point back to where it was before refresh. Use line and - ;; column instead of point directly to be insensitive to additions - ;; and removals of text within earlier lines. - (goto-char (point-min)) - (forward-line (1- target-line)) - (move-to-column target-column)) - (run-hooks 'notmuch-hello-refresh-hook) - (setq notmuch-hello-first-run nil)) - -;;; _ - -(provide 'notmuch-hello) - -;;; notmuch-hello.el ends here diff --git a/emacs/elpa/notmuch-20240406.1803/notmuch-hello.elc b/emacs/elpa/notmuch-20240406.1803/notmuch-hello.elc Binary files differ. diff --git a/emacs/elpa/notmuch-20240406.1803/notmuch-pkg.el b/emacs/elpa/notmuch-20240406.1803/notmuch-pkg.el @@ -1,4 +0,0 @@ -(define-package "notmuch" "20240406.1803" "run notmuch within emacs" 'nil :commit "cd89065dc36e36b22a2a53832d2cac9b06fba41c" :url "https://notmuchmail.org") -;; Local Variables: -;; no-byte-compile: t -;; End: diff --git a/emacs/elpa/notmuch-20240406.1803/coolj.el b/emacs/elpa/notmuch-20240529.1054/coolj.el diff --git a/emacs/elpa/notmuch-20240406.1803/coolj.elc b/emacs/elpa/notmuch-20240529.1054/coolj.elc Binary files differ. diff --git a/emacs/elpa/notmuch-20240406.1803/make-deps.el b/emacs/elpa/notmuch-20240529.1054/make-deps.el diff --git a/emacs/elpa/notmuch-20240406.1803/make-deps.elc b/emacs/elpa/notmuch-20240529.1054/make-deps.elc Binary files differ. diff --git a/emacs/elpa/notmuch-20240406.1803/notmuch-address.el b/emacs/elpa/notmuch-20240529.1054/notmuch-address.el diff --git a/emacs/elpa/notmuch-20240406.1803/notmuch-address.elc b/emacs/elpa/notmuch-20240529.1054/notmuch-address.elc Binary files differ. diff --git a/emacs/elpa/notmuch-20240406.1803/notmuch-autoloads.el b/emacs/elpa/notmuch-20240529.1054/notmuch-autoloads.el diff --git a/emacs/elpa/notmuch-20240406.1803/notmuch-company.el b/emacs/elpa/notmuch-20240529.1054/notmuch-company.el diff --git a/emacs/elpa/notmuch-20240406.1803/notmuch-company.elc b/emacs/elpa/notmuch-20240529.1054/notmuch-company.elc Binary files differ. diff --git a/emacs/elpa/notmuch-20240406.1803/notmuch-compat.el b/emacs/elpa/notmuch-20240529.1054/notmuch-compat.el diff --git a/emacs/elpa/notmuch-20240406.1803/notmuch-compat.elc b/emacs/elpa/notmuch-20240529.1054/notmuch-compat.elc Binary files differ. diff --git a/emacs/elpa/notmuch-20240406.1803/notmuch-crypto.el b/emacs/elpa/notmuch-20240529.1054/notmuch-crypto.el diff --git a/emacs/elpa/notmuch-20240406.1803/notmuch-crypto.elc b/emacs/elpa/notmuch-20240529.1054/notmuch-crypto.elc Binary files differ. diff --git a/emacs/elpa/notmuch-20240406.1803/notmuch-draft.el b/emacs/elpa/notmuch-20240529.1054/notmuch-draft.el diff --git a/emacs/elpa/notmuch-20240406.1803/notmuch-draft.elc b/emacs/elpa/notmuch-20240529.1054/notmuch-draft.elc Binary files differ. diff --git a/emacs/elpa/notmuch-20240529.1054/notmuch-hello.el b/emacs/elpa/notmuch-20240529.1054/notmuch-hello.el @@ -0,0 +1,1031 @@ +;;; notmuch-hello.el --- welcome to notmuch, a frontend -*- lexical-binding: t -*- +;; +;; Copyright © David Edmondson +;; +;; This file is part of Notmuch. +;; +;; Notmuch 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. +;; +;; Notmuch 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 Notmuch. If not, see <https://www.gnu.org/licenses/>. +;; +;; Authors: David Edmondson <dme@dme.org> + +;;; Code: + +(require 'widget) +(require 'wid-edit) ; For `widget-forward'. + +(require 'notmuch-lib) +(require 'notmuch-mua) + +(declare-function notmuch-search "notmuch" + (&optional query oldest-first target-thread target-line + no-display)) +(declare-function notmuch-poll "notmuch-lib" ()) +(declare-function notmuch-tree "notmuch-tree" + (&optional query query-context target buffer-name + open-target unthreaded parent-buffer + oldest-first hide-excluded)) +(declare-function notmuch-unthreaded "notmuch-tree" + (&optional query query-context target buffer-name + open-target oldest-first hide-excluded)) + + +;;; Options + +(defun notmuch-saved-search-get (saved-search field) + "Get FIELD from SAVED-SEARCH. + +If SAVED-SEARCH is a plist, this is just `plist-get', but for +backwards compatibility, this also deals with the two other +possible formats for SAVED-SEARCH: cons cells (NAME . QUERY) and +lists (NAME QUERY COUNT-QUERY)." + (cond + ((keywordp (car saved-search)) + (plist-get saved-search field)) + ;; It is not a plist so it is an old-style entry. + ((consp (cdr saved-search)) + (pcase-let ((`(,name ,query ,count-query) saved-search)) + (cl-case field + (:name name) + (:query query) + (:count-query count-query) + (t nil)))) + (t + (pcase-let ((`(,name . ,query) saved-search)) + (cl-case field + (:name name) + (:query query) + (t nil)))))) + +(defun notmuch-hello-saved-search-to-plist (saved-search) + "Return a copy of SAVED-SEARCH in plist form. + +If saved search is a plist then just return a copy. In other +cases, for backwards compatibility, convert to plist form and +return that." + (if (keywordp (car saved-search)) + (copy-sequence saved-search) + (let ((fields (list :name :query :count-query)) + plist-search) + (dolist (field fields plist-search) + (let ((string (notmuch-saved-search-get saved-search field))) + (when string + (setq plist-search (append plist-search (list field string))))))))) + +(defun notmuch-hello--saved-searches-to-plist (symbol) + "Extract a saved-search variable into plist form. + +The new style saved search is just a plist, but for backwards +compatibility we use this function to extract old style saved +searches so they still work in customize." + (let ((saved-searches (default-value symbol))) + (mapcar #'notmuch-hello-saved-search-to-plist saved-searches))) + +(define-widget 'notmuch-saved-search-plist 'list + "A single saved search property list." + :tag "Saved Search" + :args '((list :inline t + :format "%v" + (group :format "%v" :inline t + (const :format " Name: " :name) + (string :format "%v")) + (group :format "%v" :inline t + (const :format " Query: " :query) + (string :format "%v"))) + (checklist :inline t + :format "%v" + (group :format "%v" :inline t + (const :format "Shortcut key: " :key) + (key-sequence :format "%v")) + (group :format "%v" :inline t + (const :format "Count-Query: " :count-query) + (string :format "%v")) + (group :format "%v" :inline t + (const :format "" :sort-order) + (choice :tag " Sort Order" + (const :tag "Default" nil) + (const :tag "Oldest-first" oldest-first) + (const :tag "Newest-first" newest-first))) + (group :format "%v" :inline t + (const :format "" :excluded) + (choice :tag " Hide Excluded" + (const :tag "Default" nil) + (const :tag "Hide" hide) + (const :tag "Show" show))) + (group :format "%v" :inline t + (const :format "" :search-type) + (choice :tag " Search Type" + (const :tag "Search mode" nil) + (const :tag "Tree mode" tree) + (const :tag "Unthreaded mode" unthreaded)))))) + +(defcustom notmuch-saved-searches + `((:name "inbox" :query "tag:inbox" :key ,(kbd "i")) + (:name "unread" :query "tag:unread" :key ,(kbd "u")) + (:name "flagged" :query "tag:flagged" :key ,(kbd "f")) + (:name "sent" :query "tag:sent" :key ,(kbd "t")) + (:name "drafts" :query "tag:draft" :key ,(kbd "d")) + (:name "all mail" :query "*" :key ,(kbd "a"))) + "A list of saved searches to display. + +The saved search can be given in 3 forms. The preferred way is as +a plist. Supported properties are + + :name Name of the search (required). + :query Search to run (required). + :key Optional shortcut key for `notmuch-jump-search'. + :count-query Optional extra query to generate the count + shown. If not present then the :query property + is used. + :sort-order Specify the sort order to be used for the search. + Possible values are `oldest-first', `newest-first' + or nil. Nil means use the default sort order. + :excluded Whether to show mail with excluded tags in the + search. Possible values are `hide', `show', + or nil. Nil means use the default value of + `notmuch-search-hide-excluded'. + :search-type Specify whether to run the search in search-mode, + tree mode or unthreaded mode. Set to `tree' to + specify tree mode, \\='unthreaded to specify + unthreaded mode, and set to nil (or anything + except tree and unthreaded) to specify search + mode. + +Other accepted forms are a cons cell of the form (NAME . QUERY) +or a list of the form (NAME QUERY COUNT-QUERY)." + ;; The saved-search format is also used by the all-tags notmuch-hello + ;; section. This section generates its own saved-search list in one of + ;; the latter two forms. + :get 'notmuch-hello--saved-searches-to-plist + :type '(repeat notmuch-saved-search-plist) + :tag "List of Saved Searches" + :group 'notmuch-hello) + +(defcustom notmuch-hello-recent-searches-max 10 + "The number of recent searches to display." + :type 'integer + :group 'notmuch-hello) + +(defcustom notmuch-show-empty-saved-searches nil + "Should saved searches with no messages be listed?" + :type 'boolean + :group 'notmuch-hello) + +(defun notmuch-sort-saved-searches (saved-searches) + "Generate an alphabetically sorted saved searches list." + (sort (copy-sequence saved-searches) + (lambda (a b) + (string< (notmuch-saved-search-get a :name) + (notmuch-saved-search-get b :name))))) + +(defcustom notmuch-saved-search-sort-function nil + "Function used to sort the saved searches for the notmuch-hello view. + +This variable controls how saved searches should be sorted. No +sorting (nil) displays the saved searches in the order they are +stored in `notmuch-saved-searches'. Sort alphabetically sorts the +saved searches in alphabetical order. Custom sort function should +be a function or a lambda expression that takes the saved +searches list as a parameter, and returns a new saved searches +list to be used. For compatibility with the various saved-search +formats it should use notmuch-saved-search-get to access the +fields of the search." + :type '(choice (const :tag "No sorting" nil) + (const :tag "Sort alphabetically" notmuch-sort-saved-searches) + (function :tag "Custom sort function" + :value notmuch-sort-saved-searches)) + :group 'notmuch-hello) + +(defvar notmuch-hello-indent 4 + "How much to indent non-headers.") + +(defimage notmuch-hello-logo ((:type svg :file "notmuch-logo.svg"))) + +(defcustom notmuch-show-logo t + "Should the notmuch logo be shown?" + :type 'boolean + :group 'notmuch-hello) + +(defcustom notmuch-show-all-tags-list nil + "Should all tags be shown in the notmuch-hello view?" + :type 'boolean + :group 'notmuch-hello) + +(defcustom notmuch-hello-tag-list-make-query nil + "Function or string to generate queries for the all tags list. + +This variable controls which query results are shown for each tag +in the \"all tags\" list. If nil, it will use all messages with +that tag. If this is set to a string, it is used as a filter for +messages having that tag (equivalent to \"tag:TAG and (THIS-VARIABLE)\"). +Finally this can be a function that will be called for each tag and +should return a filter for that tag, or nil to hide the tag." + :type '(choice (const :tag "All messages" nil) + (const :tag "Unread messages" "tag:unread") + (string :tag "Custom filter" + :value "tag:unread") + (function :tag "Custom filter function")) + :group 'notmuch-hello) + +(defcustom notmuch-hello-hide-tags nil + "List of tags to be hidden in the \"all tags\"-section." + :type '(repeat string) + :group 'notmuch-hello) + +(defface notmuch-hello-logo-background + '((((class color) + (background dark)) + (:background "#5f5f5f")) + (((class color) + (background light)) + (:background "white"))) + "Background colour for the notmuch logo." + :group 'notmuch-hello + :group 'notmuch-faces) + +(defcustom notmuch-column-control t + "Controls the number of columns for saved searches/tags in notmuch view. + +This variable has three potential sets of values: + +- t: automatically calculate the number of columns possible based + on the tags to be shown and the window width, +- an integer: a lower bound on the number of characters that will + be used to display each column, +- a float: a fraction of the window width that is the lower bound + on the number of characters that should be used for each + column. + +So: +- if you would like two columns of tags, set this to 0.5. +- if you would like a single column of tags, set this to 1.0. +- if you would like tags to be 30 characters wide, set this to + 30. +- if you don't want to worry about all of this nonsense, leave + this set to `t'." + :type '(choice + (const :tag "Automatically calculated" t) + (integer :tag "Number of characters") + (float :tag "Fraction of window")) + :group 'notmuch-hello) + +(defcustom notmuch-hello-thousands-separator " " + "The string used as a thousands separator. + +Typically \",\" in the US and UK and \".\" or \" \" in Europe. +The latter is recommended in the SI/ISO 31-0 standard and by the +International Bureau of Weights and Measures." + :type 'string + :group 'notmuch-hello) + +(defcustom notmuch-hello-mode-hook nil + "Functions called after entering `notmuch-hello-mode'." + :type 'hook + :group 'notmuch-hello + :group 'notmuch-hooks) + +(defcustom notmuch-hello-refresh-hook nil + "Functions called after updating a `notmuch-hello' buffer." + :type 'hook + :group 'notmuch-hello + :group 'notmuch-hooks) + +(defconst notmuch-hello-url "https://notmuchmail.org" + "The `notmuch' web site.") + +(defvar notmuch-hello-custom-section-options + '((:filter (string :tag "Filter for each tag")) + (:filter-count (string :tag "Different filter to generate message counts")) + (:initially-hidden (const :tag "Hide this section on startup" t)) + (:show-empty-searches (const :tag "Show queries with no matching messages" t)) + (:hide-if-empty (const :tag "Hide this section if all queries are empty +\(and not shown by show-empty-searches)" t))) + "Various customization-options for notmuch-hello-tags/query-section.") + +(define-widget 'notmuch-hello-tags-section 'lazy + "Customize-type for notmuch-hello tag-list sections." + :tag "Customized tag-list section (see docstring for details)" + :type + `(list :tag "" + (const :tag "" notmuch-hello-insert-tags-section) + (string :tag "Title for this section") + (plist + :inline t + :options + ,(append notmuch-hello-custom-section-options + '((:hide-tags (repeat :tag "Tags that will be hidden" + string))))))) + +(define-widget 'notmuch-hello-query-section 'lazy + "Customize-type for custom saved-search-like sections" + :tag "Customized queries section (see docstring for details)" + :type + `(list :tag "" + (const :tag "" notmuch-hello-insert-searches) + (string :tag "Title for this section") + (repeat :tag "Queries" + (cons (string :tag "Name") (string :tag "Query"))) + (plist :inline t :options ,notmuch-hello-custom-section-options))) + +(defcustom notmuch-hello-sections + (list #'notmuch-hello-insert-header + #'notmuch-hello-insert-saved-searches + #'notmuch-hello-insert-search + #'notmuch-hello-insert-recent-searches + #'notmuch-hello-insert-alltags + #'notmuch-hello-insert-footer) + "Sections for notmuch-hello. + +The list contains functions which are used to construct sections in +notmuch-hello buffer. When notmuch-hello buffer is constructed, +these functions are run in the order they appear in this list. Each +function produces a section simply by adding content to the current +buffer. A section should not end with an empty line, because a +newline will be inserted after each section by `notmuch-hello'. + +Each function should take no arguments. The return value is +ignored. + +For convenience an element can also be a list of the form (FUNC ARG1 +ARG2 .. ARGN) in which case FUNC will be applied to the rest of the +list. + +A \"Customized tag-list section\" item in the customize-interface +displays a list of all tags, optionally hiding some of them. It +is also possible to filter the list of messages matching each tag +by an additional filter query. Similarly, the count of messages +displayed next to the buttons can be generated by applying a +different filter to the tag query. These filters are also +supported for \"Customized queries section\" items." + :group 'notmuch-hello + :type + '(repeat + (choice (function-item notmuch-hello-insert-header) + (function-item notmuch-hello-insert-saved-searches) + (function-item notmuch-hello-insert-search) + (function-item notmuch-hello-insert-recent-searches) + (function-item notmuch-hello-insert-alltags) + (function-item notmuch-hello-insert-footer) + (function-item notmuch-hello-insert-inbox) + notmuch-hello-tags-section + notmuch-hello-query-section + (function :tag "Custom section")))) + +(defcustom notmuch-hello-auto-refresh t + "Automatically refresh when returning to the notmuch-hello buffer." + :group 'notmuch-hello + :type 'boolean) + +;;; Internal variables + +(defvar notmuch-hello-hidden-sections nil + "List of sections titles whose contents are hidden.") + +(defvar notmuch-hello-first-run t + "True if `notmuch-hello' is run for the first time, set to nil afterwards.") + +;;; Widgets for inserters + +(define-widget 'notmuch-search-item 'item + "A recent search." + :format "%v\n" + :value-create 'notmuch-search-item-value-create) + +(defun notmuch-search-item-value-create (widget) + (let ((value (widget-get widget :value))) + (widget-insert (make-string notmuch-hello-indent ?\s)) + (widget-create 'editable-field + :size (widget-get widget :size) + :parent widget + :action #'notmuch-hello-search + value) + (widget-insert " ") + (widget-create 'push-button + :parent widget + :notify #'notmuch-hello-add-saved-search + "save") + (widget-insert " ") + (widget-create 'push-button + :parent widget + :notify #'notmuch-hello-delete-search-from-history + "del"))) + +(defun notmuch-search-item-field-width () + (max 8 ; Don't let the search boxes be less than 8 characters wide. + (- (window-width) + notmuch-hello-indent ; space at bol + notmuch-hello-indent ; space at eol + 1 ; for the space before the [save] button + 6 ; for the [save] button + 1 ; for the space before the [del] button + 5))) ; for the [del] button + +;;; Widget actions + +(defun notmuch-hello-search (widget &rest _event) + (let ((search (widget-value widget))) + (when search + (setq search (string-trim search)) + (let ((history-delete-duplicates t)) + (add-to-history 'notmuch-search-history search))) + (notmuch-search search notmuch-search-oldest-first))) + +(defun notmuch-hello-add-saved-search (widget &rest _event) + (let ((search (widget-value (widget-get widget :parent))) + (name (completing-read "Name for saved search: " + notmuch-saved-searches))) + ;; If an existing saved search with this name exists, remove it. + (setq notmuch-saved-searches + (cl-loop for elem in notmuch-saved-searches + unless (equal name (notmuch-saved-search-get elem :name)) + collect elem)) + ;; Add the new one. + (customize-save-variable 'notmuch-saved-searches + (add-to-list 'notmuch-saved-searches + (list :name name :query search) t)) + (message "Saved '%s' as '%s'." search name) + (notmuch-hello-update))) + +(defun notmuch-hello-delete-search-from-history (widget &rest _event) + (when (y-or-n-p "Are you sure you want to delete this search? ") + (let ((search (widget-value (widget-get widget :parent)))) + (setq notmuch-search-history + (delete search notmuch-search-history))) + (notmuch-hello-update))) + +;;; Button utilities + +;; `notmuch-hello-query-counts', `notmuch-hello-nice-number' and +;; `notmuch-hello-insert-buttons' are used outside this section. +;; All other functions that are defined in this section are only +;; used by these two functions. + +(defun notmuch-hello-longest-label (searches-alist) + (or (cl-loop for elem in searches-alist + maximize (length (notmuch-saved-search-get elem :name))) + 0)) + +(defun notmuch-hello-reflect-generate-row (ncols nrows row list) + (let ((len (length list))) + (cl-loop for col from 0 to (- ncols 1) + collect (let ((offset (+ (* nrows col) row))) + (if (< offset len) + (nth offset list) + ;; Don't forget to insert an empty slot in the + ;; output matrix if there is no corresponding + ;; value in the input matrix. + nil))))) + +(defun notmuch-hello-reflect (list ncols) + "Reflect a `ncols' wide matrix represented by `list' along the +diagonal." + ;; Not very lispy... + (let ((nrows (ceiling (length list) ncols))) + (cl-loop for row from 0 to (- nrows 1) + append (notmuch-hello-reflect-generate-row ncols nrows row list)))) + +(defun notmuch-hello-widget-search (widget &rest _ignore) + (let ((search-terms (widget-get widget :notmuch-search-terms)) + (oldest-first (widget-get widget :notmuch-search-oldest-first)) + (exclude (widget-get widget :notmuch-search-hide-excluded))) + (cl-case (widget-get widget :notmuch-search-type) + (tree + (let ((n (notmuch-search-format-buffer-name (widget-value widget) "tree" t))) + (notmuch-tree search-terms nil nil n nil nil nil oldest-first exclude))) + (unthreaded + (let ((n (notmuch-search-format-buffer-name (widget-value widget) + "unthreaded" t))) + (notmuch-unthreaded search-terms nil nil n nil oldest-first exclude))) + (t + (notmuch-search search-terms oldest-first exclude))))) + +(defun notmuch-saved-search-count (search) + (car (notmuch--process-lines notmuch-command "count" search))) + +(defun notmuch-hello-tags-per-line (widest) + "Determine how many tags to show per line and how wide they +should be. Returns a cons cell `(tags-per-line width)'." + (let ((tags-per-line + (cond + ((integerp notmuch-column-control) + (max 1 + (/ (- (window-width) notmuch-hello-indent) + ;; Count is 9 wide (8 digits plus space), 1 for the space + ;; after the name. + (+ 9 1 (max notmuch-column-control widest))))) + ((floatp notmuch-column-control) + (let* ((available-width (- (window-width) notmuch-hello-indent)) + (proposed-width (max (* available-width notmuch-column-control) + widest))) + (floor available-width proposed-width))) + (t + (max 1 + (/ (- (window-width) notmuch-hello-indent) + ;; Count is 9 wide (8 digits plus space), 1 for the space + ;; after the name. + (+ 9 1 widest))))))) + (cons tags-per-line (/ (max 1 + (- (window-width) notmuch-hello-indent + ;; Count is 9 wide (8 digits plus + ;; space), 1 for the space after the + ;; name. + (* tags-per-line (+ 9 1)))) + tags-per-line)))) + +(defun notmuch-hello-filtered-query (query filter) + "Constructs a query to search all messages matching QUERY and FILTER. + +If FILTER is a string, it is directly used in the returned query. + +If FILTER is a function, it is called with QUERY as a parameter and +the string it returns is used as the query. If nil is returned, +the entry is hidden. + +Otherwise, FILTER is ignored." + (cond + ((functionp filter) (funcall filter query)) + ((stringp filter) + (concat "(" query ") and (" filter ")")) + (t query))) + +(defun notmuch-hello-query-counts (query-list &rest options) + "Compute list of counts of matched messages from QUERY-LIST. + +QUERY-LIST must be a list of saved-searches. Ideally each of +these is a plist but other options are available for backwards +compatibility: see `notmuch-saved-searches' for details. + +The result is a list of plists each of which includes the +properties :name NAME, :query QUERY and :count COUNT, together +with any properties in the original saved-search. + +The values :show-empty-searches, :filter and :filter-count from +options will be handled as specified for +`notmuch-hello-insert-searches'. :disable-includes can be used to +turn off the default exclude processing in `notmuch-count(1)'" + (with-temp-buffer + (dolist (elem query-list nil) + (let ((count-query (or (notmuch-saved-search-get elem :count-query) + (notmuch-saved-search-get elem :query)))) + (insert + (replace-regexp-in-string + "\n" " " + (notmuch-hello-filtered-query count-query + (or (plist-get options :filter-count) + (plist-get options :filter)))) + "\n"))) + (unless (= (notmuch--call-process-region (point-min) (point-max) notmuch-command + t t nil "count" + (if (plist-get options :disable-excludes) + "--exclude=false" + "--exclude=true") + "--batch") 0) + (notmuch-logged-error + "notmuch count --batch failed" + "Please check that the notmuch CLI is new enough to support `count +--batch'. In general we recommend running matching versions of +the CLI and emacs interface.")) + (goto-char (point-min)) + (cl-mapcan + (lambda (elem) + (let* ((elem-plist (notmuch-hello-saved-search-to-plist elem)) + (search-query (plist-get elem-plist :query)) + (filtered-query (notmuch-hello-filtered-query + search-query (plist-get options :filter))) + (message-count (prog1 (read (current-buffer)) + (forward-line 1)))) + (when (and filtered-query (or (plist-get options :show-empty-searches) + (> message-count 0))) + (setq elem-plist (plist-put elem-plist :query filtered-query)) + (list (plist-put elem-plist :count message-count))))) + query-list))) + +(defun notmuch-hello-nice-number (n) + (let (result) + (while (> n 0) + (push (% n 1000) result) + (setq n (/ n 1000))) + (setq result (or result '(0))) + (apply #'concat + (number-to-string (car result)) + (mapcar (lambda (elem) + (format "%s%03d" notmuch-hello-thousands-separator elem)) + (cdr result))))) + +(defun notmuch-hello-insert-buttons (searches) + "Insert buttons for SEARCHES. + +SEARCHES must be a list of plists each of which should contain at +least the properties :name NAME :query QUERY and :count COUNT, +where QUERY is the query to start when the button for the +corresponding entry is activated, and COUNT should be the number +of messages matching the query. Such a plist can be computed +with `notmuch-hello-query-counts'." + (let* ((widest (notmuch-hello-longest-label searches)) + (tags-and-width (notmuch-hello-tags-per-line widest)) + (tags-per-line (car tags-and-width)) + (column-width (cdr tags-and-width)) + (column-indent 0) + (count 0) + (reordered-list (notmuch-hello-reflect searches tags-per-line)) + ;; Hack the display of the buttons used. + (widget-push-button-prefix "") + (widget-push-button-suffix "")) + ;; dme: It feels as though there should be a better way to + ;; implement this loop than using an incrementing counter. + (mapc (lambda (elem) + ;; (not elem) indicates an empty slot in the matrix. + (when elem + (when (> column-indent 0) + (widget-insert (make-string column-indent ? ))) + (let* ((name (plist-get elem :name)) + (query (plist-get elem :query)) + (oldest-first (cl-case (plist-get elem :sort-order) + (newest-first nil) + (oldest-first t) + (otherwise notmuch-search-oldest-first))) + (exclude (cl-case (plist-get elem :excluded) + (hide t) + (show nil) + (otherwise notmuch-search-hide-excluded))) + (search-type (plist-get elem :search-type)) + (msg-count (plist-get elem :count))) + (widget-insert (format "%8s " + (notmuch-hello-nice-number msg-count))) + (widget-create 'push-button + :notify #'notmuch-hello-widget-search + :notmuch-search-terms query + :notmuch-search-oldest-first oldest-first + :notmuch-search-type search-type + :notmuch-search-hide-excluded exclude + name) + (setq column-indent + (1+ (max 0 (- column-width (length name))))))) + (cl-incf count) + (when (eq (% count tags-per-line) 0) + (setq column-indent 0) + (widget-insert "\n"))) + reordered-list) + ;; If the last line was not full (and hence did not include a + ;; carriage return), insert one now. + (unless (eq (% count tags-per-line) 0) + (widget-insert "\n")))) + +;;; Mode + +(defun notmuch-hello-update () + "Update the notmuch-hello buffer." + ;; Lazy - rebuild everything. + (interactive) + (notmuch-hello t)) + +(defun notmuch-hello-window-configuration-change () + "Hook function to update the hello buffer when it is switched to." + (let ((hello-buf (get-buffer "*notmuch-hello*")) + (do-refresh nil)) + ;; Consider all windows in the currently selected frame, since + ;; that's where the configuration change happened. This also + ;; refreshes our snapshot of all windows, so we have to do this + ;; even if we know we won't refresh (e.g., hello-buf is null). + (dolist (window (window-list)) + (let ((last-buf (window-parameter window 'notmuch-hello-last-buffer)) + (cur-buf (window-buffer window))) + (unless (eq last-buf cur-buf) + ;; This window changed or is new. Update recorded buffer + ;; for next time. + (set-window-parameter window 'notmuch-hello-last-buffer cur-buf) + (when (and (eq cur-buf hello-buf) last-buf) + ;; The user just switched to hello in this window (hello + ;; is currently visible, was not visible on the last + ;; configuration change, and this is not a new window) + (setq do-refresh t))))) + (when (and do-refresh notmuch-hello-auto-refresh) + ;; Refresh hello as soon as we get back to redisplay. On Emacs + ;; 24, we can't do it right here because something in this + ;; hook's call stack overrides hello's point placement. + ;; FIXME And on Emacs releases that we still support? + (run-at-time nil nil #'notmuch-hello t)) + (unless hello-buf + ;; Clean up hook + (remove-hook 'window-configuration-change-hook + #'notmuch-hello-window-configuration-change)))) + +(defvar notmuch-hello-mode-map + ;; Inherit both widget-keymap and notmuch-common-keymap. We have + ;; to use make-sparse-keymap to force this to be a new keymap (so + ;; that when we modify map it does not modify widget-keymap). + (let ((map (make-composed-keymap (list (make-sparse-keymap) widget-keymap)))) + (set-keymap-parent map notmuch-common-keymap) + ;; Currently notmuch-hello-mode supports free text entry, but not + ;; tagging operations, so provide standard undo. + (define-key map [remap notmuch-tag-undo] #'undo) + map) + "Keymap for \"notmuch hello\" buffers.") + +(define-derived-mode notmuch-hello-mode fundamental-mode "notmuch-hello" + "Major mode for convenient notmuch navigation. This is your entry +portal into notmuch. + +Saved searches are \"bookmarks\" for arbitrary queries. Hit RET +or click on a saved search to view matching threads. Edit saved +searches with the `edit' button. Type `\\[notmuch-jump-search]' +in any Notmuch screen for quick access to saved searches that +have shortcut keys. + +Type new searches in the search box and hit RET to view matching +threads. Hit RET in a recent search box to re-submit a previous +search. Edit it first if you like. Save a recent search to saved +searches with the `save' button. + +Hit `\\[notmuch-search]' or `\\[notmuch-tree]' in any Notmuch +screen to search for messages and view matching threads or +messages, respectively. Recent searches are available in the +minibuffer history. + +Expand the all tags view with the `show' button (and collapse +again with the `hide' button). Hit RET or click on a tag name to +view matching threads. + +Hit `\\[notmuch-refresh-this-buffer]' to refresh the screen and +`\\[notmuch-bury-or-kill-this-buffer]' to quit. + +The screen may be customized via `\\[customize]'. + +Complete list of currently available key bindings: + +\\{notmuch-hello-mode-map}" + (setq notmuch-buffer-refresh-function #'notmuch-hello-update)) + +;;; Inserters + +(defun notmuch-hello-generate-tag-alist (&optional hide-tags) + "Return an alist from tags to queries to display in the all-tags section." + (cl-mapcan (lambda (tag) + (and (not (member tag hide-tags)) + (list (cons tag + (concat "tag:" + (notmuch-escape-boolean-term tag)))))) + (notmuch--process-lines notmuch-command "search" "--output=tags" "*"))) + +(defun notmuch-hello-insert-header () + "Insert the default notmuch-hello header." + (when notmuch-show-logo + (let ((image notmuch-hello-logo)) + ;; The notmuch logo uses transparency. That can display poorly + ;; when inserting the image into an emacs buffer (black logo on + ;; a black background), so force the background colour of the + ;; image. We use a face to represent the colour so that + ;; `defface' can be used to declare the different possible + ;; colours, which depend on whether the frame has a light or + ;; dark background. + (setq image (cons 'image + (append (cdr image) + (list :background + (face-background + 'notmuch-hello-logo-background))))) + (insert-image image)) + (widget-insert " ")) + + (widget-insert "Welcome to ") + ;; Hack the display of the links used. + (let ((widget-link-prefix "") + (widget-link-suffix "")) + (widget-create 'link + :notify (lambda (&rest _ignore) + (browse-url notmuch-hello-url)) + :help-echo "Visit the notmuch website." + "notmuch") + (widget-insert ". ") + (widget-insert "You have ") + (widget-create 'link + :notify (lambda (&rest _ignore) + (notmuch-hello-update)) + :help-echo "Refresh" + (notmuch-hello-nice-number + (string-to-number + (car (notmuch--process-lines notmuch-command "count" "--exclude=false"))))) + (widget-insert " messages.\n"))) + +(defun notmuch-hello-insert-saved-searches () + "Insert the saved-searches section." + (let ((searches (notmuch-hello-query-counts + (if notmuch-saved-search-sort-function + (funcall notmuch-saved-search-sort-function + notmuch-saved-searches) + notmuch-saved-searches) + :show-empty-searches notmuch-show-empty-saved-searches))) + (when searches + (widget-insert "Saved searches: ") + (widget-create 'push-button + :notify (lambda (&rest _ignore) + (customize-variable 'notmuch-saved-searches)) + "edit") + (widget-insert "\n\n") + (let ((start (point))) + (notmuch-hello-insert-buttons searches) + (indent-rigidly start (point) notmuch-hello-indent))))) + +(defun notmuch-hello-insert-search () + "Insert a search widget." + (widget-insert "Search: ") + (widget-create 'editable-field + ;; Leave some space at the start and end of the + ;; search boxes. + :size (max 8 (- (window-width) notmuch-hello-indent + (length "Search: "))) + :action #'notmuch-hello-search) + ;; Add an invisible dot to make `widget-end-of-line' ignore + ;; trailing spaces in the search widget field. A dot is used + ;; instead of a space to make `show-trailing-whitespace' + ;; happy, i.e. avoid it marking the whole line as trailing + ;; spaces. + (widget-insert (propertize "." 'invisible t)) + (widget-insert "\n")) + +(defun notmuch-hello-insert-recent-searches () + "Insert recent searches." + (when notmuch-search-history + (widget-insert "Recent searches: ") + (widget-create + 'push-button + :notify (lambda (&rest _ignore) + (when (y-or-n-p "Are you sure you want to clear the searches? ") + (setq notmuch-search-history nil) + (notmuch-hello-update))) + "clear") + (widget-insert "\n\n") + (let ((width (notmuch-search-item-field-width))) + (dolist (search (seq-take notmuch-search-history + notmuch-hello-recent-searches-max)) + (widget-create 'notmuch-search-item :value search :size width))))) + +(defun notmuch-hello-insert-searches (title query-list &rest options) + "Insert a section with TITLE showing a list of buttons made from +QUERY-LIST. + +QUERY-LIST should ideally be a plist but for backwards +compatibility other forms are also accepted (see +`notmuch-saved-searches' for details). The plist should +contain keys :name and :query; if :count-query is also present +then it specifies an alternate query to be used to generate the +count for the associated search. + +Supports the following entries in OPTIONS as a plist: +:initially-hidden - if non-nil, section will be hidden on startup +:show-empty-searches - show buttons with no matching messages +:hide-if-empty - hide if no buttons would be shown + (only makes sense without :show-empty-searches) +:filter - This can be a function that takes the search query as + its argument and returns a filter to be used in conjunction + with the query for that search or nil to hide the + element. This can also be a string that is used as a combined + with each query using \"and\". +:filter-count - Separate filter to generate the count displayed + each search. Accepts the same values as :filter. If :filter + and :filter-count are specified, this will be used instead of + :filter, not in conjunction with it." + + (widget-insert title ": ") + (when (and notmuch-hello-first-run (plist-get options :initially-hidden)) + (add-to-list 'notmuch-hello-hidden-sections title)) + (let ((is-hidden (member title notmuch-hello-hidden-sections)) + (start (point))) + (if is-hidden + (widget-create 'push-button + :notify (lambda (&rest _ignore) + (setq notmuch-hello-hidden-sections + (delete title notmuch-hello-hidden-sections)) + (notmuch-hello-update)) + "show") + (widget-create 'push-button + :notify (lambda (&rest _ignore) + (add-to-list 'notmuch-hello-hidden-sections + title) + (notmuch-hello-update)) + "hide")) + (widget-insert "\n") + (unless is-hidden + (let ((searches (apply 'notmuch-hello-query-counts query-list options))) + (when (or (not (plist-get options :hide-if-empty)) + searches) + (widget-insert "\n") + (notmuch-hello-insert-buttons searches) + (indent-rigidly start (point) notmuch-hello-indent)))))) + +(defun notmuch-hello-insert-tags-section (&optional title &rest options) + "Insert a section displaying all tags with message counts. + +TITLE defaults to \"All tags\". +Allowed options are those accepted by `notmuch-hello-insert-searches' and the +following: + +:hide-tags - List of tags that should be excluded." + (apply 'notmuch-hello-insert-searches + (or title "All tags") + (notmuch-hello-generate-tag-alist (plist-get options :hide-tags)) + options)) + +(defun notmuch-hello-insert-inbox () + "Show an entry for each saved search and inboxed messages for each tag." + (notmuch-hello-insert-searches "What's in your inbox" + (append + notmuch-saved-searches + (notmuch-hello-generate-tag-alist)) + :filter "tag:inbox")) + +(defun notmuch-hello-insert-alltags () + "Insert a section displaying all tags and associated message counts." + (notmuch-hello-insert-tags-section + nil + :initially-hidden (not notmuch-show-all-tags-list) + :hide-tags notmuch-hello-hide-tags + :filter notmuch-hello-tag-list-make-query + :disable-excludes t)) + +(defun notmuch-hello-insert-footer () + "Insert the notmuch-hello footer." + (let ((start (point))) + (widget-insert "Hit `?' for context-sensitive help in any Notmuch screen.\n") + (widget-insert "Customize ") + (widget-create 'link + :notify (lambda (&rest _ignore) + (customize-group 'notmuch)) + :button-prefix "" :button-suffix "" + "Notmuch") + (widget-insert " or ") + (widget-create 'link + :notify (lambda (&rest _ignore) + (customize-variable 'notmuch-hello-sections)) + :button-prefix "" :button-suffix "" + "this page.") + (let ((fill-column (- (window-width) notmuch-hello-indent))) + (center-region start (point))))) + +;;; Hello! + +;;;###autoload +(defun notmuch-hello (&optional no-display) + "Run notmuch and display saved searches, known tags, etc." + (interactive) + (notmuch-assert-cli-sane) + ;; This may cause a window configuration change, so if the + ;; auto-refresh hook is already installed, avoid recursive refresh. + (let ((notmuch-hello-auto-refresh nil)) + (if no-display + (set-buffer "*notmuch-hello*") + (pop-to-buffer-same-window "*notmuch-hello*"))) + ;; Install auto-refresh hook + (when notmuch-hello-auto-refresh + (add-hook 'window-configuration-change-hook + #'notmuch-hello-window-configuration-change)) + (let ((target-line (line-number-at-pos)) + (target-column (current-column)) + (inhibit-read-only t)) + ;; Delete all editable widget fields. Editable widget fields are + ;; tracked in a buffer local variable `widget-field-list' (and + ;; others). If we do `erase-buffer' without properly deleting the + ;; widgets, some widget-related functions are confused later. + (mapc 'widget-delete widget-field-list) + (erase-buffer) + (unless (eq major-mode 'notmuch-hello-mode) + (notmuch-hello-mode)) + (let ((all (overlay-lists))) + ;; Delete all the overlays. + (mapc 'delete-overlay (car all)) + (mapc 'delete-overlay (cdr all))) + (mapc + (lambda (section) + (let ((point-before (point))) + (if (functionp section) + (funcall section) + (apply (car section) (cdr section))) + ;; don't insert a newline when the previous section didn't + ;; show anything. + (unless (eq (point) point-before) + (widget-insert "\n")))) + notmuch-hello-sections) + (widget-setup) + ;; Move point back to where it was before refresh. Use line and + ;; column instead of point directly to be insensitive to additions + ;; and removals of text within earlier lines. + (goto-char (point-min)) + (forward-line (1- target-line)) + (move-to-column target-column)) + (run-hooks 'notmuch-hello-refresh-hook) + (setq notmuch-hello-first-run nil)) + +;;; _ + +(provide 'notmuch-hello) + +;;; notmuch-hello.el ends here diff --git a/emacs/elpa/notmuch-20240529.1054/notmuch-hello.elc b/emacs/elpa/notmuch-20240529.1054/notmuch-hello.elc Binary files differ. diff --git a/emacs/elpa/notmuch-20240406.1803/notmuch-jump.el b/emacs/elpa/notmuch-20240529.1054/notmuch-jump.el diff --git a/emacs/elpa/notmuch-20240406.1803/notmuch-jump.elc b/emacs/elpa/notmuch-20240529.1054/notmuch-jump.elc Binary files differ. diff --git a/emacs/elpa/notmuch-20240406.1803/notmuch-lib.el b/emacs/elpa/notmuch-20240529.1054/notmuch-lib.el diff --git a/emacs/elpa/notmuch-20240406.1803/notmuch-lib.elc b/emacs/elpa/notmuch-20240529.1054/notmuch-lib.elc Binary files differ. diff --git a/emacs/elpa/notmuch-20240406.1803/notmuch-logo.svg b/emacs/elpa/notmuch-20240529.1054/notmuch-logo.svg diff --git a/emacs/elpa/notmuch-20240406.1803/notmuch-maildir-fcc.el b/emacs/elpa/notmuch-20240529.1054/notmuch-maildir-fcc.el diff --git a/emacs/elpa/notmuch-20240406.1803/notmuch-maildir-fcc.elc b/emacs/elpa/notmuch-20240529.1054/notmuch-maildir-fcc.elc Binary files differ. diff --git a/emacs/elpa/notmuch-20240406.1803/notmuch-message.el b/emacs/elpa/notmuch-20240529.1054/notmuch-message.el diff --git a/emacs/elpa/notmuch-20240406.1803/notmuch-message.elc b/emacs/elpa/notmuch-20240529.1054/notmuch-message.elc Binary files differ. diff --git a/emacs/elpa/notmuch-20240406.1803/notmuch-mua.el b/emacs/elpa/notmuch-20240529.1054/notmuch-mua.el diff --git a/emacs/elpa/notmuch-20240406.1803/notmuch-mua.elc b/emacs/elpa/notmuch-20240529.1054/notmuch-mua.elc Binary files differ. diff --git a/emacs/elpa/notmuch-20240406.1803/notmuch-parser.el b/emacs/elpa/notmuch-20240529.1054/notmuch-parser.el diff --git a/emacs/elpa/notmuch-20240406.1803/notmuch-parser.elc b/emacs/elpa/notmuch-20240529.1054/notmuch-parser.elc Binary files differ. diff --git a/emacs/elpa/notmuch-20240529.1054/notmuch-pkg.el b/emacs/elpa/notmuch-20240529.1054/notmuch-pkg.el @@ -0,0 +1,4 @@ +(define-package "notmuch" "20240529.1054" "run notmuch within emacs" 'nil :commit "e8e2d5247e44d9b402cbcc491b859cd9398f045d" :url "https://notmuchmail.org") +;; Local Variables: +;; no-byte-compile: t +;; End: diff --git a/emacs/elpa/notmuch-20240406.1803/notmuch-print.el b/emacs/elpa/notmuch-20240529.1054/notmuch-print.el diff --git a/emacs/elpa/notmuch-20240406.1803/notmuch-print.elc b/emacs/elpa/notmuch-20240529.1054/notmuch-print.elc Binary files differ. diff --git a/emacs/elpa/notmuch-20240406.1803/notmuch-query.el b/emacs/elpa/notmuch-20240529.1054/notmuch-query.el diff --git a/emacs/elpa/notmuch-20240406.1803/notmuch-query.elc b/emacs/elpa/notmuch-20240529.1054/notmuch-query.elc Binary files differ. diff --git a/emacs/elpa/notmuch-20240406.1803/notmuch-show.el b/emacs/elpa/notmuch-20240529.1054/notmuch-show.el diff --git a/emacs/elpa/notmuch-20240406.1803/notmuch-show.elc b/emacs/elpa/notmuch-20240529.1054/notmuch-show.elc Binary files differ. diff --git a/emacs/elpa/notmuch-20240406.1803/notmuch-tag.el b/emacs/elpa/notmuch-20240529.1054/notmuch-tag.el diff --git a/emacs/elpa/notmuch-20240406.1803/notmuch-tag.elc b/emacs/elpa/notmuch-20240529.1054/notmuch-tag.elc Binary files differ. diff --git a/emacs/elpa/notmuch-20240406.1803/notmuch-tree.el b/emacs/elpa/notmuch-20240529.1054/notmuch-tree.el diff --git a/emacs/elpa/notmuch-20240406.1803/notmuch-tree.elc b/emacs/elpa/notmuch-20240529.1054/notmuch-tree.elc Binary files differ. diff --git a/emacs/elpa/notmuch-20240406.1803/notmuch-wash.el b/emacs/elpa/notmuch-20240529.1054/notmuch-wash.el diff --git a/emacs/elpa/notmuch-20240406.1803/notmuch-wash.elc b/emacs/elpa/notmuch-20240529.1054/notmuch-wash.elc Binary files differ. diff --git a/emacs/elpa/notmuch-20240406.1803/notmuch.el b/emacs/elpa/notmuch-20240529.1054/notmuch.el diff --git a/emacs/elpa/notmuch-20240406.1803/notmuch.elc b/emacs/elpa/notmuch-20240529.1054/notmuch.elc Binary files differ. diff --git a/emacs/elpa/notmuch-20240406.1803/rstdoc.el b/emacs/elpa/notmuch-20240529.1054/rstdoc.el diff --git a/emacs/elpa/notmuch-20240406.1803/rstdoc.elc b/emacs/elpa/notmuch-20240529.1054/rstdoc.elc Binary files differ. diff --git a/emacs/elpa/sort-words-20160929.1335/sort-words-autoloads.el b/emacs/elpa/sort-words-20160929.1335/sort-words-autoloads.el @@ -0,0 +1,34 @@ +;;; sort-words-autoloads.el --- automatically extracted autoloads (do not edit) -*- lexical-binding: t -*- +;; Generated by the `loaddefs-generate' function. + +;; This file is part of GNU Emacs. + +;;; Code: + +(add-to-list 'load-path (or (and load-file-name (directory-file-name (file-name-directory load-file-name))) (car load-path))) + + + +;;; Generated autoloads from sort-words.el + +(autoload 'sort-words "sort-words" "\ +Sort words in region alphabetically. +Then insert them replacing the existing region. +START and END are boundries of the selected region. + +(fn START END)" t) +(register-definition-prefixes "sort-words" '("sort-words-")) + +;;; End of scraped data + +(provide 'sort-words-autoloads) + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; no-native-compile: t +;; coding: utf-8-emacs-unix +;; End: + +;;; sort-words-autoloads.el ends here diff --git a/emacs/elpa/sort-words-20160929.1335/sort-words-pkg.el b/emacs/elpa/sort-words-20160929.1335/sort-words-pkg.el @@ -0,0 +1,12 @@ +(define-package "sort-words" "20160929.1335" "Sort words in a selected region" 'nil :commit "7b6e108f80237363faf7ec28b2c58dec270b8601" :authors + '(("\"Aleksandar Simic\"" . "asimic@gmail.com")) + :maintainers + '(("\"Aleksandar Simic\"" . "asimic@gmail.com")) + :maintainer + '("\"Aleksandar Simic\"" . "asimic@gmail.com") + :keywords + '("tools") + :url "http://github.org/dotemacs/sort-words.el") +;; Local Variables: +;; no-byte-compile: t +;; End: diff --git a/emacs/elpa/sort-words-20160929.1335/sort-words.el b/emacs/elpa/sort-words-20160929.1335/sort-words.el @@ -0,0 +1,71 @@ +;;; sort-words.el --- Sort words in a selected region + +;; Filename: sort-words.el +;; Description: Sort words in a selected region +;; Author: "Aleksandar Simic" <asimic@gmail.com> +;; License: BSD +;; Created: 2016-09-07 +;; Version: 0.0.5 +;; Homepage: http://github.org/dotemacs/sort-words.el +;; Keywords: tools + +;;; This file is NOT part of GNU Emacs +;; +;; Copyright (c) 2016, Aleksandar Simic +;; 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 OWNER 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. + +;;; Commentary: +;; +;; Usage: select a region and then +;; M-x sort-words RET + +;;; Code: + +(defun sort-words-in-region (start end) + "Sort the words in a given region (START and END) and return them as a list." + (sort (split-string (buffer-substring-no-properties start end)) #'string<)) + +(defun sort-words-sorted (start end) + "Sort the words in a given region (START and END) and return them as a string." + (mapconcat 'identity (sort-words-in-region start end) " ")) + +;;;###autoload +(defun sort-words (start end) + "Sort words in region alphabetically. +Then insert them replacing the existing region. +START and END are boundries of the selected region." + (interactive "r") + (save-excursion + (save-restriction + (narrow-to-region start end) + (let ((words (sort-words-sorted (point-min) (point-max)))) + (delete-region (point-min) (point-max)) + (goto-char (point-min)) + (insert words))))) + +(provide 'sort-words) + +;;; sort-words.el ends here diff --git a/emacs/elpa/sort-words-20160929.1335/sort-words.elc b/emacs/elpa/sort-words-20160929.1335/sort-words.elc Binary files differ. diff --git a/emacs/elpa/transient-20240509.1849/transient-pkg.el b/emacs/elpa/transient-20240509.1849/transient-pkg.el @@ -1,16 +0,0 @@ -(define-package "transient" "20240509.1849" "Transient commands" - '((emacs "26.1") - (compat "29.1.4.4") - (seq "2.24")) - :commit "3d395d643b1476b07c6c3d7217f5b2ad2c0b425e" :authors - '(("Jonas Bernoulli" . "emacs.transient@jonas.bernoulli.dev")) - :maintainers - '(("Jonas Bernoulli" . "emacs.transient@jonas.bernoulli.dev")) - :maintainer - '("Jonas Bernoulli" . "emacs.transient@jonas.bernoulli.dev") - :keywords - '("extensions") - :url "https://github.com/magit/transient") -;; Local Variables: -;; no-byte-compile: t -;; End: diff --git a/emacs/elpa/transient-20240509.1849/transient.el b/emacs/elpa/transient-20240509.1849/transient.el @@ -1,4503 +0,0 @@ -;;; transient.el --- Transient commands -*- lexical-binding:t -*- - -;; Copyright (C) 2018-2024 Free Software Foundation, Inc. - -;; Author: Jonas Bernoulli <emacs.transient@jonas.bernoulli.dev> -;; Homepage: https://github.com/magit/transient -;; Keywords: extensions - -;; Package-Version: 0.6.0 -;; Package-Requires: ((emacs "26.1") (compat "29.1.4.4") (seq "2.24")) - -;; SPDX-License-Identifier: GPL-3.0-or-later - -;; This file is part of GNU Emacs. - -;; GNU Emacs 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. -;; -;; GNU Emacs 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 <https://www.gnu.org/licenses/>. - -;;; Commentary: - -;; Transient is the library used to implement the keyboard-driven menus -;; in Magit. It is distributed as a separate package, so that it can be -;; used to implement similar menus in other packages. - -;;; Code: - -(require 'cl-lib) -(require 'compat) -(require 'eieio) -(require 'edmacro) -(require 'format-spec) - -(eval-and-compile - (when (and (featurep' seq) - (not (fboundp 'seq-keep))) - (unload-feature 'seq 'force))) -(require 'seq) -(unless (fboundp 'seq-keep) - (display-warning 'transient (substitute-command-keys "\ -Transient requires `seq' >= 2.24, -but due to bad defaults, Emacs' package manager, refuses to -upgrade this and other built-in packages to higher releases -from GNU Elpa, when a package specifies that this is needed. - -To fix this, you have to add this to your init file: - - (setq package-install-upgrade-built-in t) - -Then evaluate that expression by placing the cursor after it -and typing \\[eval-last-sexp]. - -Once you have done that, you have to explicitly upgrade `seq': - - \\[package-upgrade] seq \\`RET' - -Then you also must make sure the updated version is loaded, -by evaluating this form: - - (progn (unload-feature 'seq t) (require 'seq)) - -Until you do this, you will get random errors about `seq-keep' -being undefined while using Transient. - -If you don't use the `package' package manager but still get -this warning, then your chosen package manager likely has a -similar defect.") :emergency)) - -(eval-when-compile (require 'subr-x)) - -(declare-function info "info" (&optional file-or-node buffer)) -(declare-function Man-find-section "man" (section)) -(declare-function Man-next-section "man" (n)) -(declare-function Man-getpage-in-background "man" (topic)) - -(defvar Man-notify-method) -(defvar pp-default-function) ; since Emacs 29.1 - -(defmacro static-if (condition then-form &rest else-forms) - "A conditional compilation macro. -Evaluate CONDITION at macro-expansion time. If it is non-nil, -expand the macro to THEN-FORM. Otherwise expand it to ELSE-FORMS -enclosed in a `progn' form. ELSE-FORMS may be empty." - (declare (indent 2) - (debug (sexp sexp &rest sexp))) - (if (eval condition lexical-binding) - then-form - (cons 'progn else-forms))) - -(defmacro transient--with-emergency-exit (id &rest body) - (declare (indent defun)) - (unless (keywordp id) - (setq body (cons id body)) - (setq id nil)) - `(condition-case err - (let ((debugger #'transient--exit-and-debug)) - ,(macroexp-progn body)) - ((debug error) - (transient--emergency-exit ,id) - (signal (car err) (cdr err))))) - -(defun transient--exit-and-debug (&rest args) - (transient--emergency-exit :debugger) - (apply #'debug args)) - -;;; Options - -(defgroup transient nil - "Transient commands." - :group 'extensions) - -(defcustom transient-show-popup t - "Whether to show the current transient in a popup buffer. -\\<transient-map> -- If t, then show the popup as soon as a transient prefix command - is invoked. - -- If nil, then do not show the popup unless the user explicitly - requests it, by pressing \\[transient-show] or a prefix key. - -- If a number, then delay displaying the popup and instead show - a brief one-line summary. If zero or negative, then suppress - even showing that summary and display the pressed key only. - - Show the popup when the user explicitly requests it by pressing - \\[transient-show] or a prefix key. Unless zero, then also show the popup - after that many seconds of inactivity (using the absolute value)." - :package-version '(transient . "0.1.0") - :group 'transient - :type '(choice (const :tag "instantly" t) - (const :tag "on demand" nil) - (const :tag "on demand (no summary)" 0) - (number :tag "after delay" 1))) - -(defcustom transient-enable-popup-navigation t - "Whether navigation commands are enabled in the transient popup. - -While a transient is active the transient popup buffer is not the -current buffer, making it necessary to use dedicated commands to -act on that buffer itself. If this is non-nil, then the following -bindings are available: - -\\<transient-popup-navigation-map>\ -- \\[transient-backward-button] moves the cursor to the previous suffix. -- \\[transient-forward-button] moves the cursor to the next suffix. -- \\[transient-push-button] invokes the suffix the cursor is on. -\\<transient-button-map>\ -- \\`<mouse-1>' and \\`<mouse-2>' invoke the clicked on suffix. -\\<transient-popup-navigation-map>\ -- \\[transient-isearch-backward]\ - and \\[transient-isearch-forward] start isearch in the popup buffer. - -\\`<mouse-1>' and \\`<mouse-2>' are bound in `transient-push-button'. -All other bindings are in `transient-popup-navigation-map'. - -By default \\`M-RET' is bound to `transient-push-button', instead of -\\`RET', because if a transient allows the invocation of non-suffixes -then it is likely that you would want \\`RET' to do what it would do -if no transient were active." - :package-version '(transient . "0.4.0") - :group 'transient - :type 'boolean) - -(defcustom transient-display-buffer-action - '(display-buffer-in-side-window - (side . bottom) - (dedicated . t) - (inhibit-same-window . t) - (window-parameters (no-other-window . t))) - "The action used to display the transient popup buffer. - -The transient popup buffer is displayed in a window using - - (display-buffer BUFFER transient-display-buffer-action) - -The value of this option has the form (FUNCTION . ALIST), -where FUNCTION is a function or a list of functions. Each such -function should accept two arguments: a buffer to display and an -alist of the same form as ALIST. See info node `(elisp)Choosing -Window' for details. - -The default is: - - (display-buffer-in-side-window - (side . bottom) - (dedicated . t) - (inhibit-same-window . t) - (window-parameters (no-other-window . t))) - -This displays the window at the bottom of the selected frame. -Another useful FUNCTION is `display-buffer-below-selected', which -is what `magit-popup' used by default. For more alternatives see -info node `(elisp)Display Action Functions' and info node -`(elisp)Buffer Display Action Alists'. - -Note that the buffer that was current before the transient buffer -is shown should remain the current buffer. Many suffix commands -act on the thing at point, if appropriate, and if the transient -buffer became the current buffer, then that would change what is -at point. To that effect `inhibit-same-window' ensures that the -selected window is not used to show the transient buffer. - -It may be possible to display the window in another frame, but -whether that works in practice depends on the window-manager. -If the window manager selects the new window (Emacs frame), -then that unfortunately changes which buffer is current. - -If you change the value of this option, then you might also -want to change the value of `transient-mode-line-format'." - :package-version '(transient . "0.3.0") - :group 'transient - :type '(cons (choice function (repeat :tag "Functions" function)) - alist)) - -(defcustom transient-mode-line-format 'line - "The mode-line format for the transient popup buffer. - -If nil, then the buffer has no mode-line. If the buffer is not -displayed right above the echo area, then this probably is not -a good value. - -If `line' (the default) or a natural number, then the buffer -has no mode-line, but a line is drawn is drawn in its place. -If a number is used, that specifies the thickness of the line. -On termcap frames we cannot draw lines, so there `line' and -numbers are synonyms for nil. - -The color of the line is used to indicate if non-suffixes are -allowed and whether they exit the transient. The foreground -color of `transient-key-noop' (if non-suffix are disallowed), -`transient-key-stay' (if allowed and transient stays active), or -`transient-key-exit' (if allowed and they exit the transient) is -used to draw the line. - -Otherwise this can be any mode-line format. -See `mode-line-format' for details." - :package-version '(transient . "0.2.0") - :group 'transient - :type '(choice (const :tag "hide mode-line" nil) - (const :tag "substitute thin line" line) - (number :tag "substitute line with thickness") - (const :tag "name of prefix command" - ("%e" mode-line-front-space - mode-line-buffer-identification)) - (sexp :tag "custom mode-line format"))) - -(defcustom transient-show-common-commands nil - "Whether to show common transient suffixes in the popup buffer. - -These commands are always shown after typing the prefix key -\"C-x\" when a transient command is active. To toggle the value -of this variable use \"C-x t\" when a transient is active." - :package-version '(transient . "0.1.0") - :group 'transient - :type 'boolean) - -(defcustom transient-read-with-initial-input nil - "Whether to use the last history element as initial minibuffer input." - :package-version '(transient . "0.2.0") - :group 'transient - :type 'boolean) - -(defcustom transient-highlight-mismatched-keys nil - "Whether to highlight keys that do not match their argument. - -This only affects infix arguments that represent command-line -arguments. When this option is non-nil, then the key binding -for infix argument are highlighted when only a long argument -\(e.g., \"--verbose\") is specified but no shorthand (e.g., \"-v\"). -In the rare case that a short-hand is specified but does not -match the key binding, then it is highlighted differently. - -The highlighting is done using `transient-mismatched-key' -and `transient-nonstandard-key'." - :package-version '(transient . "0.1.0") - :group 'transient - :type 'boolean) - -(defcustom transient-highlight-higher-levels nil - "Whether to highlight suffixes on higher levels. - -This is primarily intended for package authors. - -When non-nil then highlight the description of suffixes whose -level is above 4, the default of `transient-default-level'. -Assuming you have set that variable to 7, this highlights all -suffixes that won't be available to users without them making -the same customization." - :package-version '(transient . "0.3.6") - :group 'transient - :type 'boolean) - -(defcustom transient-substitute-key-function nil - "Function used to modify key bindings. - -This function is called with one argument, the prefix object, -and must return a key binding description, either the existing -key description it finds in the `key' slot, or a substitution. - -This is intended to let users replace certain prefix keys. It -could also be used to make other substitutions, but that is -discouraged. - -For example, \"=\" is hard to reach using my custom keyboard -layout, so I substitute \"(\" for that, which is easy to reach -using a layout optimized for Lisp. - - (setq transient-substitute-key-function - (lambda (obj) - (let ((key (oref obj key))) - (if (string-match \"\\\\`\\\\(=\\\\)[a-zA-Z]\" key) - (replace-match \"(\" t t key 1) - key)))))" - :package-version '(transient . "0.1.0") - :group 'transient - :type '(choice (const :tag "Transform no keys (nil)" nil) function)) - -(defcustom transient-semantic-coloring t - "Whether to use colors to indicate transient behavior. - -If non-nil, then the key binding of each suffix is colorized to -indicate whether it exits the transient state or not, and the -line that is drawn below the transient popup buffer is used to -indicate the behavior of non-suffix commands." - :package-version '(transient . "0.5.0") - :group 'transient - :type 'boolean) - -(defcustom transient-detect-key-conflicts nil - "Whether to detect key binding conflicts. - -Conflicts are detected when a transient prefix command is invoked -and results in an error, which prevents the transient from being -used." - :package-version '(transient . "0.1.0") - :group 'transient - :type 'boolean) - -(defcustom transient-align-variable-pitch nil - "Whether to align columns pixel-wise in the popup buffer. - -If this is non-nil, then columns are aligned pixel-wise to -support variable-pitch fonts. Keys are not aligned, so you -should use a fixed-pitch font for the `transient-key' face. -Other key faces inherit from that face unless a theme is -used that breaks that relationship. - -This option is intended for users who use a variable-pitch -font for the `default' face. - -Also see `transient-force-fixed-pitch'." - :package-version '(transient . "0.4.0") - :group 'transient - :type 'boolean) - -(defcustom transient-force-fixed-pitch nil - "Whether to force use of monospaced font in the popup buffer. - -Even if you use a proportional font for the `default' face, -you might still want to use a monospaced font in transient's -popup buffer. Setting this option to t causes `default' to -be remapped to `fixed-pitch' in that buffer. - -Also see `transient-align-variable-pitch'." - :package-version '(transient . "0.2.0") - :group 'transient - :type 'boolean) - -(defcustom transient-force-single-column nil - "Whether to force use of a single column to display suffixes. - -This might be useful for users with low vision who use large -text and might otherwise have to scroll in two dimensions." - :package-version '(transient . "0.3.6") - :group 'transient - :type 'boolean) - -(defcustom transient-hide-during-minibuffer-read nil - "Whether to hide the transient buffer while reading in the minibuffer." - :package-version '(transient . "0.4.0") - :group 'transient - :type 'boolean) - -(defconst transient--max-level 7) -(defconst transient--default-child-level 1) -(defconst transient--default-prefix-level 4) - -(defcustom transient-default-level transient--default-prefix-level - "Control what suffix levels are made available by default. - -Each suffix command is placed on a level and each prefix command -has a level, which controls which suffix commands are available. -Integers between 1 and 7 (inclusive) are valid levels. - -The levels of individual transients and/or their individual -suffixes can be changed individually, by invoking the prefix and -then pressing \"C-x l\". - -The default level for both transients and their suffixes is 4. -This option only controls the default for transients. The default -suffix level is always 4. The author of a transient should place -certain suffixes on a higher level if they expect that it won't be -of use to most users, and they should place very important suffixes -on a lower level so that they remain available even if the user -lowers the transient level. - -\(Magit currently places nearly all suffixes on level 4 and lower -levels are not used at all yet. So for the time being you should -not set a lower level here and using a higher level might not -give you as many additional suffixes as you hoped.)" - :package-version '(transient . "0.1.0") - :group 'transient - :type '(choice (const :tag "1 - fewest suffixes" 1) - (const 2) - (const 3) - (const :tag "4 - default" 4) - (const 5) - (const 6) - (const :tag "7 - most suffixes" 7))) - -(defcustom transient-levels-file - (locate-user-emacs-file "transient/levels.el") - "File used to save levels of transients and their suffixes." - :package-version '(transient . "0.1.0") - :group 'transient - :type 'file) - -(defcustom transient-values-file - (locate-user-emacs-file "transient/values.el") - "File used to save values of transients." - :package-version '(transient . "0.1.0") - :group 'transient - :type 'file) - -(defcustom transient-history-file - (locate-user-emacs-file "transient/history.el") - "File used to save history of transients and their infixes." - :package-version '(transient . "0.1.0") - :group 'transient - :type 'file) - -(defcustom transient-history-limit 10 - "Number of history elements to keep when saving to file." - :package-version '(transient . "0.1.0") - :group 'transient - :type 'integer) - -(defcustom transient-save-history t - "Whether to save history of transient commands when exiting Emacs." - :package-version '(transient . "0.1.0") - :group 'transient - :type 'boolean) - -;;; Faces - -(defgroup transient-faces nil - "Faces used by Transient." - :group 'transient) - -(defface transient-heading '((t :inherit font-lock-keyword-face)) - "Face used for headings." - :group 'transient-faces) - -(defface transient-argument '((t :inherit font-lock-string-face :weight bold)) - "Face used for enabled arguments." - :group 'transient-faces) - -(defface transient-inactive-argument '((t :inherit shadow)) - "Face used for inactive arguments." - :group 'transient-faces) - -(defface transient-value '((t :inherit font-lock-string-face :weight bold)) - "Face used for values." - :group 'transient-faces) - -(defface transient-inactive-value '((t :inherit shadow)) - "Face used for inactive values." - :group 'transient-faces) - -(defface transient-unreachable '((t :inherit shadow)) - "Face used for suffixes unreachable from the current prefix sequence." - :group 'transient-faces) - -(defface transient-inapt-suffix '((t :inherit shadow :italic t)) - "Face used for suffixes that are inapt at this time." - :group 'transient-faces) - -(defface transient-active-infix '((t :inherit highlight)) - "Face used for the infix for which the value is being read." - :group 'transient-faces) - -(defface transient-enabled-suffix - '((t :background "green" :foreground "black" :weight bold)) - "Face used for enabled levels while editing suffix levels. -See info node `(transient)Enabling and Disabling Suffixes'." - :group 'transient-faces) - -(defface transient-disabled-suffix - '((t :background "red" :foreground "black" :weight bold)) - "Face used for disabled levels while editing suffix levels. -See info node `(transient)Enabling and Disabling Suffixes'." - :group 'transient-faces) - -(defface transient-higher-level - `((t :box ( :line-width ,(if (>= emacs-major-version 28) (cons -1 -1) -1) - :color ,(let ((color (face-attribute 'shadow :foreground nil t))) - (or (and (not (eq color 'unspecified)) color) - "grey60"))))) - "Face optionally used to highlight suffixes on higher levels. -Also see option `transient-highlight-higher-levels'." - :group 'transient-faces) - -(defface transient-delimiter '((t :inherit shadow)) - "Face used for delimiters and separators. -This includes the parentheses around values and the pipe -character used to separate possible values from each other." - :group 'transient-faces) - -(defface transient-key '((t :inherit font-lock-builtin-face)) - "Face used for keys." - :group 'transient-faces) - -(defface transient-key-stay - `((((class color) (background light)) - :inherit transient-key - :foreground "#22aa22") - (((class color) (background dark)) - :inherit transient-key - :foreground "#ddffdd")) - "Face used for keys of suffixes that don't exit transient state." - :group 'transient-faces) - -(defface transient-key-noop - `((((class color) (background light)) - :inherit transient-key - :foreground "grey80") - (((class color) (background dark)) - :inherit transient-key - :foreground "grey30")) - "Face used for keys of suffixes that currently cannot be invoked." - :group 'transient-faces) - -(defface transient-key-return - `((((class color) (background light)) - :inherit transient-key - :foreground "#aaaa11") - (((class color) (background dark)) - :inherit transient-key - :foreground "#ffffcc")) - "Face used for keys of suffixes that return to the parent transient." - :group 'transient-faces) - -(defface transient-key-exit - `((((class color) (background light)) - :inherit transient-key - :foreground "#aa2222") - (((class color) (background dark)) - :inherit transient-key - :foreground "#ffdddd")) - "Face used for keys of suffixes that exit transient state." - :group 'transient-faces) - -(defface transient-unreachable-key - '((t :inherit (shadow transient-key) :weight normal)) - "Face used for keys unreachable from the current prefix sequence." - :group 'transient-faces) - -(defface transient-nonstandard-key - `((t :box ( :line-width ,(if (>= emacs-major-version 28) (cons -1 -1) -1) - :color "cyan"))) - "Face optionally used to highlight keys conflicting with short-argument. -Also see option `transient-highlight-mismatched-keys'." - :group 'transient-faces) - -(defface transient-mismatched-key - `((t :box ( :line-width ,(if (>= emacs-major-version 28) (cons -1 -1) -1) - :color "magenta"))) - "Face optionally used to highlight keys without a short-argument. -Also see option `transient-highlight-mismatched-keys'." - :group 'transient-faces) - -;;; Persistence - -(defun transient--read-file-contents (file) - (with-demoted-errors "Transient error: %S" - (and (file-exists-p file) - (with-temp-buffer - (insert-file-contents file) - (read (current-buffer)))))) - -(defun transient--pp-to-file (list file) - (make-directory (file-name-directory file) t) - (setq list (cl-sort (copy-sequence list) #'string< :key #'car)) - (with-temp-file file - (let ((print-level nil) - (print-length nil) - (pp-default-function 'pp-28) - (fill-column 999)) - (pp list (current-buffer))))) - -(defvar transient-values - (transient--read-file-contents transient-values-file) - "Values of transient commands. -The value of this variable persists between Emacs sessions -and you usually should not change it manually.") - -(defun transient-save-values () - (transient--pp-to-file transient-values transient-values-file)) - -(defvar transient-levels - (transient--read-file-contents transient-levels-file) - "Levels of transient commands. -The value of this variable persists between Emacs sessions -and you usually should not change it manually.") - -(defun transient-save-levels () - (transient--pp-to-file transient-levels transient-levels-file)) - -(defvar transient-history - (transient--read-file-contents transient-history-file) - "History of transient commands and infix arguments. -The value of this variable persists between Emacs sessions -\(unless `transient-save-history' is nil) and you usually -should not change it manually.") - -(defun transient-save-history () - (setq transient-history - (cl-sort (mapcar (pcase-lambda (`(,key . ,val)) - (cons key (seq-take (delete-dups val) - transient-history-limit))) - transient-history) - #'string< :key #'car)) - (transient--pp-to-file transient-history transient-history-file)) - -(defun transient-maybe-save-history () - "Save the value of `transient-history'. -If `transient-save-history' is nil, then do nothing." - (when transient-save-history - (transient-save-history))) - -(unless noninteractive - (add-hook 'kill-emacs-hook #'transient-maybe-save-history)) - -;;; Classes -;;;; Prefix - -(defclass transient-prefix () - ((prototype :initarg :prototype) - (command :initarg :command) - (level :initarg :level) - (variable :initarg :variable :initform nil) - (init-value :initarg :init-value) - (value) (default-value :initarg :value) - (scope :initarg :scope :initform nil) - (history :initarg :history :initform nil) - (history-pos :initarg :history-pos :initform 0) - (history-key :initarg :history-key :initform nil) - (show-help :initarg :show-help :initform nil) - (info-manual :initarg :info-manual :initform nil) - (man-page :initarg :man-page :initform nil) - (transient-suffix :initarg :transient-suffix :initform nil) - (transient-non-suffix :initarg :transient-non-suffix :initform nil) - (transient-switch-frame :initarg :transient-switch-frame) - (refresh-suffixes :initarg :refresh-suffixes :initform nil) - (incompatible :initarg :incompatible :initform nil) - (suffix-description :initarg :suffix-description) - (variable-pitch :initarg :variable-pitch :initform nil) - (column-widths :initarg :column-widths :initform nil) - (unwind-suffix :documentation "Internal use." :initform nil)) - "Transient prefix command. - -Each transient prefix command consists of a command, which is -stored in a symbol's function slot and an object, which is -stored in the `transient--prefix' property of the same symbol. - -When a transient prefix command is invoked, then a clone of that -object is stored in the global variable `transient--prefix' and -the prototype is stored in the clone's `prototype' slot.") - -;;;; Suffix - -(defclass transient-child () - ((level - :initarg :level - :initform (symbol-value 'transient--default-child-level) - :documentation "Enable if level of prefix is equal or greater.") - (if - :initarg :if - :initform nil - :documentation "Enable if predicate returns non-nil.") - (if-not - :initarg :if-not - :initform nil - :documentation "Enable if predicate returns nil.") - (if-non-nil - :initarg :if-non-nil - :initform nil - :documentation "Enable if variable's value is non-nil.") - (if-nil - :initarg :if-nil - :initform nil - :documentation "Enable if variable's value is nil.") - (if-mode - :initarg :if-mode - :initform nil - :documentation "Enable if major-mode matches value.") - (if-not-mode - :initarg :if-not-mode - :initform nil - :documentation "Enable if major-mode does not match value.") - (if-derived - :initarg :if-derived - :initform nil - :documentation "Enable if major-mode derives from value.") - (if-not-derived - :initarg :if-not-derived - :initform nil - :documentation "Enable if major-mode does not derive from value.") - (inapt - :initform nil) - (inapt-face - :initarg :inapt-face - :initform 'transient-inapt-suffix) - (inapt-if - :initarg :inapt-if - :initform nil - :documentation "Inapt if predicate returns non-nil.") - (inapt-if-not - :initarg :inapt-if-not - :initform nil - :documentation "Inapt if predicate returns nil.") - (inapt-if-non-nil - :initarg :inapt-if-non-nil - :initform nil - :documentation "Inapt if variable's value is non-nil.") - (inapt-if-nil - :initarg :inapt-if-nil - :initform nil - :documentation "Inapt if variable's value is nil.") - (inapt-if-mode - :initarg :inapt-if-mode - :initform nil - :documentation "Inapt if major-mode matches value.") - (inapt-if-not-mode - :initarg :inapt-if-not-mode - :initform nil - :documentation "Inapt if major-mode does not match value.") - (inapt-if-derived - :initarg :inapt-if-derived - :initform nil - :documentation "Inapt if major-mode derives from value.") - (inapt-if-not-derived - :initarg :inapt-if-not-derived - :initform nil - :documentation "Inapt if major-mode does not derive from value.")) - "Abstract superclass for group and suffix classes. - -It is undefined what happens if more than one `if*' predicate -slot is non-nil." - :abstract t) - -(defclass transient-suffix (transient-child) - ((definition :allocation :class :initform nil) - (key :initarg :key) - (command :initarg :command) - (transient :initarg :transient) - (format :initarg :format :initform " %k %d") - (description :initarg :description :initform nil) - (face :initarg :face :initform nil) - (show-help :initarg :show-help :initform nil)) - "Superclass for suffix command.") - -(defclass transient-information (transient-suffix) - ((format :initform " %k %d") - (key :initform " ")) - "Display-only information, aligned with suffix keys. -Technically a suffix object with no associated command.") - -(defclass transient-information* (transient-information) - ((format :initform " %d")) - "Display-only information, aligned with suffix descriptions. -Technically a suffix object with no associated command.") - -(defclass transient-infix (transient-suffix) - ((transient :initform t) - (argument :initarg :argument) - (shortarg :initarg :shortarg) - (value :initform nil) - (init-value :initarg :init-value) - (unsavable :initarg :unsavable :initform nil) - (multi-value :initarg :multi-value :initform nil) - (always-read :initarg :always-read :initform nil) - (allow-empty :initarg :allow-empty :initform nil) - (history-key :initarg :history-key :initform nil) - (reader :initarg :reader :initform nil) - (prompt :initarg :prompt :initform nil) - (choices :initarg :choices :initform nil) - (format :initform " %k %d (%v)")) - "Transient infix command." - :abstract t) - -(defclass transient-argument (transient-infix) () - "Abstract superclass for infix arguments." - :abstract t) - -(defclass transient-switch (transient-argument) () - "Class used for command-line argument that can be turned on and off.") - -(defclass transient-option (transient-argument) () - "Class used for command-line argument that can take a value.") - -(defclass transient-variable (transient-infix) - ((variable :initarg :variable) - (format :initform " %k %d %v")) - "Abstract superclass for infix commands that set a variable." - :abstract t) - -(defclass transient-switches (transient-argument) - ((argument-format :initarg :argument-format) - (argument-regexp :initarg :argument-regexp)) - "Class used for sets of mutually exclusive command-line switches.") - -(defclass transient-files (transient-option) () - ((key :initform "--") - (argument :initform "--") - (multi-value :initform rest) - (reader :initform transient-read-files)) - "Class used for the \"--\" argument or similar. -All remaining arguments are treated as files. -They become the value of this argument.") - -;;;; Group - -(defclass transient-group (transient-child) - ((suffixes :initarg :suffixes :initform nil) - (hide :initarg :hide :initform nil) - (description :initarg :description :initform nil) - (pad-keys :initarg :pad-keys :initform nil) - (info-format :initarg :info-format :initform nil) - (setup-children :initarg :setup-children)) - "Abstract superclass of all group classes." - :abstract t) - -(defclass transient-column (transient-group) () - "Group class that displays each element on a separate line.") - -(defclass transient-row (transient-group) () - "Group class that displays all elements on a single line.") - -(defclass transient-columns (transient-group) () - "Group class that displays elements organized in columns. -Direct elements have to be groups whose elements have to be -commands or strings. Each subgroup represents a column. -This class takes care of inserting the subgroups' elements.") - -(defclass transient-subgroups (transient-group) () - "Group class that wraps other groups. - -Direct elements have to be groups whose elements have to be -commands or strings. This group inserts an empty line between -subgroups. The subgroups are responsible for displaying their -elements themselves.") - -;;; Define - -(defmacro transient-define-prefix (name arglist &rest args) - "Define NAME as a transient prefix command. - -ARGLIST are the arguments that command takes. -DOCSTRING is the documentation string and is optional. - -These arguments can optionally be followed by key-value pairs. -Each key has to be a keyword symbol, either `:class' or a keyword -argument supported by the constructor of that class. The -`transient-prefix' class is used if the class is not specified -explicitly. - -GROUPs add key bindings for infix and suffix commands and specify -how these bindings are presented in the popup buffer. At least -one GROUP has to be specified. See info node `(transient)Binding -Suffix and Infix Commands'. - -The BODY is optional. If it is omitted, then ARGLIST is also -ignored and the function definition becomes: - - (lambda () - (interactive) - (transient-setup \\='NAME)) - -If BODY is specified, then it must begin with an `interactive' -form that matches ARGLIST, and it must call `transient-setup'. -It may however call that function only when some condition is -satisfied; that is one of the reason why you might want to use -an explicit BODY. - -All transients have a (possibly nil) value, which is exported -when suffix commands are called, so that they can consume that -value. For some transients it might be necessary to have a sort -of secondary value, called a scope. Such a scope would usually -be set in the commands `interactive' form and has to be passed -to the setup function: - - (transient-setup \\='NAME nil nil :scope SCOPE) - -\(fn NAME ARGLIST [DOCSTRING] [KEYWORD VALUE]... GROUP... [BODY...])" - (declare (debug ( &define name lambda-list - [&optional lambda-doc] - [&rest keywordp sexp] - [&rest vectorp] - [&optional ("interactive" interactive) def-body])) - (indent defun) - (doc-string 3)) - (pcase-let ((`(,class ,slots ,suffixes ,docstr ,body ,interactive-only) - (transient--expand-define-args args arglist))) - `(progn - (defalias ',name - ,(if body - `(lambda ,arglist ,@body) - `(lambda () - (interactive) - (transient-setup ',name)))) - (put ',name 'interactive-only ,interactive-only) - (put ',name 'function-documentation ,docstr) - (put ',name 'transient--prefix - (,(or class 'transient-prefix) :command ',name ,@slots)) - (put ',name 'transient--layout - (list ,@(cl-mapcan (lambda (s) (transient--parse-child name s)) - suffixes)))))) - -(defmacro transient-define-suffix (name arglist &rest args) - "Define NAME as a transient suffix command. - -ARGLIST are the arguments that the command takes. -DOCSTRING is the documentation string and is optional. - -These arguments can optionally be followed by key-value pairs. -Each key has to be a keyword symbol, either `:class' or a -keyword argument supported by the constructor of that class. -The `transient-suffix' class is used if the class is not -specified explicitly. - -The BODY must begin with an `interactive' form that matches -ARGLIST. The infix arguments are usually accessed by using -`transient-args' inside `interactive'. - -\(fn NAME ARGLIST [DOCSTRING] [KEYWORD VALUE]... [BODY...])" - (declare (debug ( &define name lambda-list - [&optional lambda-doc] - [&rest keywordp sexp] - [&optional ("interactive" interactive) def-body])) - (indent defun) - (doc-string 3)) - (pcase-let ((`(,class ,slots ,_ ,docstr ,body ,interactive-only) - (transient--expand-define-args args arglist))) - `(progn - (defalias ',name - ,(if (and (not body) class (oref-default class definition)) - `(oref-default ',class definition) - `(lambda ,arglist ,@body))) - (put ',name 'interactive-only ,interactive-only) - (put ',name 'function-documentation ,docstr) - (put ',name 'transient--suffix - (,(or class 'transient-suffix) :command ',name ,@slots))))) - -(defmacro transient-define-infix (name arglist &rest args) - "Define NAME as a transient infix command. - -ARGLIST is always ignored and reserved for future use. -DOCSTRING is the documentation string and is optional. - -At least one key-value pair is required. All transient infix -commands are equal to each other (but not eq). It is meaning- -less to define an infix command, without providing at least one -keyword argument (usually `:argument' or `:variable', depending -on the class). The suffix class defaults to `transient-switch' -and can be set using the `:class' keyword. - -The function definitions is always: - - (lambda () - (interactive) - (let ((obj (transient-suffix-object))) - (transient-infix-set obj (transient-infix-read obj))) - (transient--show)) - -`transient-infix-read' and `transient-infix-set' are generic -functions. Different infix commands behave differently because -the concrete methods are different for different infix command -classes. In rare case the above command function might not be -suitable, even if you define your own infix command class. In -that case you have to use `transient-define-suffix' to define -the infix command and use t as the value of the `:transient' -keyword. - -\(fn NAME ARGLIST [DOCSTRING] KEYWORD VALUE [KEYWORD VALUE]...)" - (declare (debug ( &define name lambda-list - [&optional lambda-doc] - keywordp sexp - [&rest keywordp sexp])) - (indent defun) - (doc-string 3)) - (pcase-let ((`(,class ,slots ,_ ,docstr ,_ ,interactive-only) - (transient--expand-define-args args arglist t))) - `(progn - (defalias ',name #'transient--default-infix-command) - (put ',name 'interactive-only ,interactive-only) - (put ',name 'completion-predicate #'transient--suffix-only) - (put ',name 'function-documentation ,docstr) - (put ',name 'transient--suffix - (,(or class 'transient-switch) :command ',name ,@slots))))) - -(defalias 'transient-define-argument #'transient-define-infix - "Define NAME as a transient infix command. - -Only use this alias to define an infix command that actually -sets an infix argument. To define a infix command that, for -example, sets a variable, use `transient-define-infix' instead. - -\(fn NAME ARGLIST [DOCSTRING] [KEYWORD VALUE]...)") - -(defun transient--default-infix-command () - ;; Most infix commands are but an alias for this command. - "Cannot show any documentation for this transient infix command. - -When you request help for an infix command using `transient-help', that -usually shows the respective man-page and tries to jump to the location -where the respective argument is being described. - -If no man-page is specified for the containing transient menu, then the -docstring is displayed instead, if any. - -If the infix command doesn't have a docstring, as is the case here, then -this docstring is displayed instead, because technically infix commands -are aliases for `transient--default-infix-command'. - -`describe-function' also shows the docstring of the infix command, -falling back to that of the same aliased command." - (interactive) - (let ((obj (transient-suffix-object))) - (transient-infix-set obj (transient-infix-read obj))) - (transient--show)) -(put 'transient--default-infix-command 'interactive-only t) -(put 'transient--default-infix-command 'completion-predicate - #'transient--suffix-only) - -(defun transient--find-function-advised-original (fn func) - "Return nil instead of `transient--default-infix-command'. -When using `find-function' to jump to the definition of a transient -infix command/argument, then we want to actually jump to that, not to -the definition of `transient--default-infix-command', which all infix -commands are aliases for." - (let ((val (funcall fn func))) - (and val (not (eq val 'transient--default-infix-command)) val))) -(advice-add 'find-function-advised-original :around - #'transient--find-function-advised-original) - -(eval-and-compile - (defun transient--expand-define-args (args &optional arglist nobody) - (unless (listp arglist) - (error "Mandatory ARGLIST is missing")) - (let (class keys suffixes docstr declare (interactive-only t)) - (when (stringp (car args)) - (setq docstr (pop args))) - (while (keywordp (car args)) - (let ((k (pop args)) - (v (pop args))) - (if (eq k :class) - (setq class v) - (push k keys) - (push v keys)))) - (while (let ((arg (car args))) - (or (vectorp arg) - (and arg (symbolp arg)))) - (push (pop args) suffixes)) - (when (eq (car-safe (car args)) 'declare) - (setq declare (car args)) - (setq args (cdr args)) - (when-let ((int (assq 'interactive-only declare))) - (setq interactive-only (cadr int)) - (delq int declare)) - (unless (cdr declare) - (setq declare nil))) - (cond - ((not args)) - (nobody - (error "transient-define-infix: No function body allowed")) - ((not (eq (car-safe (nth (if declare 1 0) args)) 'interactive)) - (error "transient-define-*: Interactive form missing"))) - (list (if (eq (car-safe class) 'quote) - (cadr class) - class) - (nreverse keys) - (nreverse suffixes) - docstr - (if declare (cons declare args) args) - interactive-only)))) - -(defun transient--parse-child (prefix spec) - (cl-typecase spec - (null (error "Invalid transient--parse-child spec: %s" spec)) - (symbol (let ((value (symbol-value spec))) - (if (and (listp value) - (or (listp (car value)) - (vectorp (car value)))) - (cl-mapcan (lambda (s) (transient--parse-child prefix s)) value) - (transient--parse-child prefix value)))) - (vector (and-let* ((c (transient--parse-group prefix spec))) (list c))) - (list (and-let* ((c (transient--parse-suffix prefix spec))) (list c))) - (string (list spec)) - (t (error "Invalid transient--parse-child spec: %s" spec)))) - -(defun transient--parse-group (prefix spec) - (setq spec (append spec nil)) - (cl-symbol-macrolet - ((car (car spec)) - (pop (pop spec))) - (let (level class args) - (when (integerp car) - (setq level pop)) - (when (stringp car) - (setq args (plist-put args :description pop))) - (while (keywordp car) - (let ((key pop) - (val pop)) - (cond ((eq key :class) - (setq class (macroexp-quote val))) - ((or (symbolp val) - (and (listp val) (not (eq (car val) 'lambda)))) - (setq args (plist-put args key (macroexp-quote val)))) - ((setq args (plist-put args key val)))))) - (unless (or spec class (not (plist-get args :setup-children))) - (message "WARNING: %s: When %s is used, %s must also be specified" - 'transient-define-prefix :setup-children :class)) - (list 'vector - (or level transient--default-child-level) - (cond (class) - ((or (vectorp car) - (and car (symbolp car))) - (quote 'transient-columns)) - ((quote 'transient-column))) - (and args (cons 'list args)) - (cons 'list - (cl-mapcan (lambda (s) (transient--parse-child prefix s)) - spec)))))) - -(defun transient--parse-suffix (prefix spec) - (let (level class args) - (cl-symbol-macrolet - ((car (car spec)) - (pop (pop spec))) - (when (integerp car) - (setq level pop)) - (when (or (stringp car) - (vectorp car)) - (setq args (plist-put args :key pop))) - (cond - ((or (stringp car) - (and (eq (car-safe car) 'lambda) - (not (commandp car)))) - (setq args (plist-put args :description pop))) - ((and (symbolp car) - (not (keywordp car)) - (not (commandp car)) - (commandp (cadr spec))) - (setq args (plist-put args :description (macroexp-quote pop))))) - (cond - ((memq car '(:info :info*))) - ((keywordp car) - (error "Need command, `:info' or `:info*', got `%s'" car)) - ((symbolp car) - (setq args (plist-put args :command (macroexp-quote pop)))) - ((and (commandp car) - (not (stringp car))) - (let ((cmd pop) - (sym (intern - (format "transient:%s:%s" - prefix - (let ((desc (plist-get args :description))) - (if (and (stringp desc) - (length< desc 16)) - desc - (plist-get args :key))))))) - (setq args (plist-put - args :command - `(prog1 ',sym - (put ',sym 'interactive-only t) - (put ',sym 'completion-predicate #'transient--suffix-only) - (defalias ',sym - ,(if (eq (car-safe cmd) 'lambda) - cmd - (macroexp-quote cmd)))))))) - ((or (stringp car) - (and car (listp car))) - (let ((arg pop) - (sym nil)) - (cl-typecase arg - (list - (setq args (plist-put args :shortarg (car arg))) - (setq args (plist-put args :argument (cadr arg))) - (setq arg (cadr arg))) - (string - (when-let ((shortarg (transient--derive-shortarg arg))) - (setq args (plist-put args :shortarg shortarg))) - (setq args (plist-put args :argument arg)))) - (setq sym (intern (format "transient:%s:%s" prefix arg))) - (setq args (plist-put - args :command - `(prog1 ',sym - (put ',sym 'interactive-only t) - (put ',sym 'completion-predicate #'transient--suffix-only) - (defalias ',sym #'transient--default-infix-command)))) - (cond ((and car (not (keywordp car))) - (setq class 'transient-option) - (setq args (plist-put args :reader (macroexp-quote pop)))) - ((not (string-suffix-p "=" arg)) - (setq class 'transient-switch)) - (t - (setq class 'transient-option))))) - (t - (error "Needed command or argument, got %S" car))) - (while (keywordp car) - (let ((key pop) - (val pop)) - (cond ((eq key :class) (setq class val)) - ((eq key :level) (setq level val)) - ((eq key :info) - (setq class 'transient-information) - (setq args (plist-put args :description val))) - ((eq key :info*) - (setq class 'transient-information*) - (setq args (plist-put args :description val))) - ((eq (car-safe val) '\,) - (setq args (plist-put args key (cadr val)))) - ((or (symbolp val) - (and (listp val) (not (eq (car val) 'lambda)))) - (setq args (plist-put args key (macroexp-quote val)))) - ((setq args (plist-put args key val))))))) - (unless (plist-get args :key) - (when-let ((shortarg (plist-get args :shortarg))) - (setq args (plist-put args :key shortarg)))) - (list 'list - (or level transient--default-child-level) - (macroexp-quote (or class 'transient-suffix)) - (cons 'list args)))) - -(defun transient--derive-shortarg (arg) - (save-match-data - (and (string-match "\\`\\(-[a-zA-Z]\\)\\(\\'\\|=\\)" arg) - (match-string 1 arg)))) - -(defun transient-command-completion-not-suffix-only-p (symbol _buffer) - "Say whether SYMBOL should be offered as a completion. -If the value of SYMBOL's `completion-predicate' property is -`transient--suffix-only', then return nil, otherwise return t. -This is the case when a command should only ever be used as a -suffix of a transient prefix command (as opposed to bindings -in regular keymaps or by using `execute-extended-command')." - (not (eq (get symbol 'completion-predicate) 'transient--suffix-only))) - -(defalias 'transient--suffix-only #'ignore - "Ignore ARGUMENTS, do nothing, and return nil. -Also see `transient-command-completion-not-suffix-only-p'. -Only use this alias as the value of the `completion-predicate' -symbol property.") - -(when (and (boundp 'read-extended-command-predicate) ; since Emacs 28.1 - (not read-extended-command-predicate)) - (setq read-extended-command-predicate - #'transient-command-completion-not-suffix-only-p)) - -(defun transient-parse-suffix (prefix suffix) - "Parse SUFFIX, to be added to PREFIX. -PREFIX is a prefix command, a symbol. -SUFFIX is a suffix command or a group specification (of - the same forms as expected by `transient-define-prefix'). -Intended for use in a group's `:setup-children' function." - (cl-assert (and prefix (symbolp prefix))) - (eval (car (transient--parse-child prefix suffix)) t)) - -(defun transient-parse-suffixes (prefix suffixes) - "Parse SUFFIXES, to be added to PREFIX. -PREFIX is a prefix command, a symbol. -SUFFIXES is a list of suffix command or a group specification - (of the same forms as expected by `transient-define-prefix'). -Intended for use in a group's `:setup-children' function." - (cl-assert (and prefix (symbolp prefix))) - (mapcar (apply-partially #'transient-parse-suffix prefix) suffixes)) - -;;; Edit - -(defun transient--insert-suffix (prefix loc suffix action &optional keep-other) - (let* ((suf (cl-etypecase suffix - (vector (transient--parse-group prefix suffix)) - (list (transient--parse-suffix prefix suffix)) - (string suffix))) - (mem (transient--layout-member loc prefix)) - (elt (car mem))) - (setq suf (eval suf t)) - (cond - ((not mem) - (message "Cannot insert %S into %s; %s not found" - suffix prefix loc)) - ((or (and (vectorp suffix) (not (vectorp elt))) - (and (listp suffix) (vectorp elt)) - (and (stringp suffix) (vectorp elt))) - (message "Cannot place %S into %s at %s; %s" - suffix prefix loc - "suffixes and groups cannot be siblings")) - (t - (when-let* ((bindingp (listp suf)) - (key (transient--spec-key suf)) - (conflict (car (transient--layout-member key prefix))) - (conflictp - (and (not (and (eq action 'replace) - (eq conflict elt))) - (or (not keep-other) - (eq (plist-get (nth 2 suf) :command) - (plist-get (nth 2 conflict) :command))) - (equal (transient--suffix-predicate suf) - (transient--suffix-predicate conflict))))) - (transient-remove-suffix prefix key)) - (pcase-exhaustive action - ('insert (setcdr mem (cons elt (cdr mem))) - (setcar mem suf)) - ('append (setcdr mem (cons suf (cdr mem)))) - ('replace (setcar mem suf))))))) - -;;;###autoload -(defun transient-insert-suffix (prefix loc suffix &optional keep-other) - "Insert a SUFFIX into PREFIX before LOC. -PREFIX is a prefix command, a symbol. -SUFFIX is a suffix command or a group specification (of - the same forms as expected by `transient-define-prefix'). -LOC is a command, a key vector, a key description (a string - as returned by `key-description'), or a coordination list - (whose last element may also be a command or key). -Remove a conflicting binding unless optional KEEP-OTHER is - non-nil. -See info node `(transient)Modifying Existing Transients'." - (declare (indent defun)) - (transient--insert-suffix prefix loc suffix 'insert keep-other)) - -;;;###autoload -(defun transient-append-suffix (prefix loc suffix &optional keep-other) - "Insert a SUFFIX into PREFIX after LOC. -PREFIX is a prefix command, a symbol. -SUFFIX is a suffix command or a group specification (of - the same forms as expected by `transient-define-prefix'). -LOC is a command, a key vector, a key description (a string - as returned by `key-description'), or a coordination list - (whose last element may also be a command or key). -Remove a conflicting binding unless optional KEEP-OTHER is - non-nil. -See info node `(transient)Modifying Existing Transients'." - (declare (indent defun)) - (transient--insert-suffix prefix loc suffix 'append keep-other)) - -;;;###autoload -(defun transient-replace-suffix (prefix loc suffix) - "Replace the suffix at LOC in PREFIX with SUFFIX. -PREFIX is a prefix command, a symbol. -SUFFIX is a suffix command or a group specification (of - the same forms as expected by `transient-define-prefix'). -LOC is a command, a key vector, a key description (a string - as returned by `key-description'), or a coordination list - (whose last element may also be a command or key). -See info node `(transient)Modifying Existing Transients'." - (declare (indent defun)) - (transient--insert-suffix prefix loc suffix 'replace)) - -;;;###autoload -(defun transient-remove-suffix (prefix loc) - "Remove the suffix or group at LOC in PREFIX. -PREFIX is a prefix command, a symbol. -LOC is a command, a key vector, a key description (a string - as returned by `key-description'), or a coordination list - (whose last element may also be a command or key). -See info node `(transient)Modifying Existing Transients'." - (declare (indent defun)) - (transient--layout-member loc prefix 'remove)) - -(defun transient-get-suffix (prefix loc) - "Return the suffix or group at LOC in PREFIX. -PREFIX is a prefix command, a symbol. -LOC is a command, a key vector, a key description (a string - as returned by `key-description'), or a coordination list - (whose last element may also be a command or key). -See info node `(transient)Modifying Existing Transients'." - (if-let ((mem (transient--layout-member loc prefix))) - (car mem) - (error "%s not found in %s" loc prefix))) - -(defun transient-suffix-put (prefix loc prop value) - "Edit the suffix at LOC in PREFIX, setting PROP to VALUE. -PREFIX is a prefix command, a symbol. -SUFFIX is a suffix command or a group specification (of - the same forms as expected by `transient-define-prefix'). -LOC is a command, a key vector, a key description (a string - as returned by `key-description'), or a coordination list - (whose last element may also be a command or key). -See info node `(transient)Modifying Existing Transients'." - (let ((suf (transient-get-suffix prefix loc))) - (setf (elt suf 2) - (plist-put (elt suf 2) prop value)))) - -(defun transient--layout-member (loc prefix &optional remove) - (let ((val (or (get prefix 'transient--layout) - (error "%s is not a transient command" prefix)))) - (when (listp loc) - (while (integerp (car loc)) - (let* ((children (if (vectorp val) (aref val 3) val)) - (mem (transient--nthcdr (pop loc) children))) - (if (and remove (not loc)) - (let ((rest (delq (car mem) children))) - (if (vectorp val) - (aset val 3 rest) - (put prefix 'transient--layout rest)) - (setq val nil)) - (setq val (if loc (car mem) mem))))) - (setq loc (car loc))) - (if loc - (transient--layout-member-1 (transient--kbd loc) val remove) - val))) - -(defun transient--layout-member-1 (loc layout remove) - (cond ((listp layout) - (seq-some (lambda (elt) (transient--layout-member-1 loc elt remove)) - layout)) - ((vectorp (car (aref layout 3))) - (seq-some (lambda (elt) (transient--layout-member-1 loc elt remove)) - (aref layout 3))) - (remove - (aset layout 3 - (delq (car (transient--group-member loc layout)) - (aref layout 3))) - nil) - ((transient--group-member loc layout)))) - -(defun transient--group-member (loc group) - (cl-member-if (lambda (suffix) - (and (listp suffix) - (let* ((def (nth 2 suffix)) - (cmd (plist-get def :command))) - (if (symbolp loc) - (eq cmd loc) - (equal (transient--kbd - (or (plist-get def :key) - (transient--command-key cmd))) - loc))))) - (aref group 3))) - -(defun transient--kbd (keys) - (when (vectorp keys) - (setq keys (key-description keys))) - (when (stringp keys) - (setq keys (kbd keys))) - keys) - -(defun transient--spec-key (spec) - (let ((plist (nth 2 spec))) - (or (plist-get plist :key) - (transient--command-key - (plist-get plist :command))))) - -(defun transient--command-key (cmd) - (and-let* ((obj (transient--suffix-prototype cmd))) - (cond ((slot-boundp obj 'key) - (oref obj key)) - ((slot-exists-p obj 'shortarg) - (if (slot-boundp obj 'shortarg) - (oref obj shortarg) - (transient--derive-shortarg (oref obj argument))))))) - -(defun transient--nthcdr (n list) - (nthcdr (if (< n 0) (- (length list) (abs n)) n) list)) - -;;; Variables - -(defvar transient-current-prefix nil - "The transient from which this suffix command was invoked. -This is an object representing that transient, use -`transient-current-command' to get the respective command.") - -(defvar transient-current-command nil - "The transient from which this suffix command was invoked. -This is a symbol representing that transient, use -`transient-current-prefix' to get the respective object.") - -(defvar transient-current-suffixes nil - "The suffixes of the transient from which this suffix command was invoked. -This is a list of objects. Usually it is sufficient to instead -use the function `transient-args', which returns a list of -values. In complex cases it might be necessary to use this -variable instead.") - -(defvar transient-exit-hook nil - "Hook run after exiting a transient.") - -(defvar transient-setup-buffer-hook nil - "Hook run when setting up the transient buffer. -That buffer is current and empty when this hook runs.") - -(defvar transient--prefix nil) -(defvar transient--layout nil) -(defvar transient--suffixes nil) - -(defconst transient--stay t "Do not exit the transient.") -(defconst transient--exit nil "Do exit the transient.") - -(defvar transient--exitp nil "Whether to exit the transient.") -(defvar transient--showp nil "Whether to show the transient popup buffer.") -(defvar transient--helpp nil "Whether help-mode is active.") -(defvar transient--editp nil "Whether edit-mode is active.") - -(defvar transient--refreshp nil - "Whether to refresh the transient completely.") - -(defvar transient--all-levels-p nil - "Whether temporary display of suffixes on all levels is active.") - -(defvar transient--timer nil) - -(defvar transient--stack nil) - -(defvar transient--minibuffer-depth 0) - -(defvar transient--buffer-name " *transient*" - "Name of the transient buffer.") - -(defvar transient--window nil - "The window used to display the transient popup buffer.") - -(defvar transient--original-window nil - "The window that was selected before the transient was invoked. -Usually it remains selected while the transient is active.") - -(defvar transient--original-buffer nil - "The buffer that was current before the transient was invoked. -Usually it remains current while the transient is active.") - -(defvar transient--restore-winconf nil - "Window configuration to restore after exiting help.") - -(defvar transient--shadowed-buffer nil - "The buffer that is temporarily shadowed by the transient buffer. -This is bound while the suffix predicate is being evaluated and while -drawing in the transient buffer.") - -(defvar transient--pending-suffix nil - "The suffix that is currently being processed. -This is bound while the suffix predicate is being evaluated, -and while functions that return faces are being evaluated.") - -(defvar transient--pending-group nil - "The group that is currently being processed. -This is bound while the suffixes are drawn in the transient buffer.") - -(defvar transient--debug nil - "Whether to put debug information into *Messages*.") - -(defvar transient--history nil) - -(defvar transient--scroll-commands - '(transient-scroll-up - transient-scroll-down - mwheel-scroll - scroll-bar-toolkit-scroll)) - -;;; Identities - -(defun transient-prefix-object () - "Return the current prefix as an object. - -While a transient is being setup or refreshed (which involves -preparing its suffixes) the variable `transient--prefix' can be -used to access the prefix object. Thus this is what has to be -used in suffix methods such as `transient-format-description', -and in object-specific functions that are stored in suffix slots -such as `description'. - -When a suffix command is invoked (i.e., in its `interactive' form -and function body) then the variable `transient-current-prefix' -has to be used instead. - -Two distinct variables are needed, because any prefix may itself -be used as a suffix of another prefix, and such sub-prefixes have -to be able to tell themselves apart from the prefix they were -invoked from. - -Regular suffix commands, which are not prefixes, do not have to -concern themselves with this distinction, so they can use this -function instead. In the context of a plain suffix, it always -returns the value of the appropriate variable." - (or transient--prefix transient-current-prefix)) - -(defun transient-suffix-object (&optional command) - "Return the object associated with the current suffix command. - -Each suffix commands is associated with an object, which holds -additional information about the suffix, such as its value (in -the case of an infix command, which is a kind of suffix command). - -This function is intended to be called by infix commands, which -are usually aliases of `transient--default-infix-command', which -is defined like this: - - (defun transient--default-infix-command () - (interactive) - (let ((obj (transient-suffix-object))) - (transient-infix-set obj (transient-infix-read obj))) - (transient--show)) - -\(User input is read outside of `interactive' to prevent the -command from being added to `command-history'. See #23.) - -Such commands need to be able to access their associated object -to guide how `transient-infix-read' reads the new value and to -store the read value. Other suffix commands (including non-infix -commands) may also need the object to guide their behavior. - -This function attempts to return the object associated with the -current suffix command even if the suffix command was not invoked -from a transient. (For some suffix command that is a valid thing -to do, for others it is not.) In that case nil may be returned, -if the command was not defined using one of the macros intended -to define such commands. - -The optional argument COMMAND is intended for internal use. If -you are contemplating using it in your own code, then you should -probably use this instead: - - (get COMMAND \\='transient--suffix)" - (when command - (cl-check-type command command)) - (cond - (transient--pending-suffix) - ((or transient--prefix - transient-current-prefix) - (let ((suffixes - (cl-remove-if-not - (lambda (obj) - (eq (oref obj command) - (or command - (if (eq this-command 'transient-set-level) - ;; This is how it can look up for which - ;; command it is setting the level. - this-original-command - this-command)))) - (or transient--suffixes - transient-current-suffixes)))) - (or (and (cdr suffixes) - (cl-find-if - (lambda (obj) - (equal (listify-key-sequence (transient--kbd (oref obj key))) - (listify-key-sequence (this-command-keys)))) - suffixes)) - (car suffixes)))) - ((and-let* ((obj (transient--suffix-prototype (or command this-command))) - (obj (clone obj))) - (progn ; work around debbugs#31840 - (transient-init-scope obj) - (transient-init-value obj) - obj))))) - -(defun transient--suffix-prototype (command) - (or (get command 'transient--suffix) - (seq-some (lambda (cmd) (get cmd 'transient--suffix)) - (function-alias-p command)))) - -;;; Keymaps - -(defvar-keymap transient-base-map - :doc "Parent of other keymaps used by Transient. - -This is the parent keymap of all the keymaps that are used in -all transients: `transient-map' (which in turn is the parent -of the transient-specific keymaps), `transient-edit-map' and -`transient-sticky-map'. - -If you change a binding here, then you might also have to edit -`transient-sticky-map' and `transient-common-commands'. While -the latter isn't a proper transient prefix command, it can be -edited using the same functions as used for transients. - -If you add a new command here, then you must also add a binding -to `transient-predicate-map'." - "ESC ESC ESC" #'transient-quit-all - "C-g" #'transient-quit-one - "C-q" #'transient-quit-all - "C-z" #'transient-suspend - "C-v" #'transient-scroll-up - "C-M-v" #'transient-scroll-down - "<next>" #'transient-scroll-up - "<prior>" #'transient-scroll-down) - -(defvar-keymap transient-map - :doc "Top-level keymap used by all transients. - -If you add a new command here, then you must also add a binding -to `transient-predicate-map'. Also see `transient-base-map'." - :parent transient-base-map - "C-u" #'universal-argument - "C--" #'negative-argument - "C-t" #'transient-show - "?" #'transient-help - "C-h" #'transient-help - ;; Also bound to "C-x p" and "C-x n" in transient-common-commands. - "C-M-p" #'transient-history-prev - "C-M-n" #'transient-history-next) - -(defvar-keymap transient-edit-map - :doc "Keymap that is active while a transient in is in \"edit mode\"." - :parent transient-base-map - "?" #'transient-help - "C-h" #'transient-help - "C-x l" #'transient-set-level) - -(defvar-keymap transient-sticky-map - :doc "Keymap that is active while an incomplete key sequence is active." - :parent transient-base-map - "C-g" #'transient-quit-seq) - -(defvar transient--common-command-prefixes '(?\C-x)) - -(put 'transient-common-commands - 'transient--layout - (list - (eval - (car (transient--parse-child - 'transient-common-commands - (vector - :hide - (lambda () - (and (not (memq - (car (bound-and-true-p transient--redisplay-key)) - transient--common-command-prefixes)) - (not transient-show-common-commands))) - (vector - "Value commands" - (list "C-x s " "Set" #'transient-set) - (list "C-x C-s" "Save" #'transient-save) - (list "C-x C-k" "Reset" #'transient-reset) - (list "C-x p " "Previous value" #'transient-history-prev) - (list "C-x n " "Next value" #'transient-history-next)) - (vector - "Sticky commands" - ;; Like `transient-sticky-map' except that - ;; "C-g" has to be bound to a different command. - (list "C-g" "Quit prefix or transient" #'transient-quit-one) - (list "C-q" "Quit transient stack" #'transient-quit-all) - (list "C-z" "Suspend transient stack" #'transient-suspend)) - (vector - "Customize" - (list "C-x t" 'transient-toggle-common :description - (lambda () - (if transient-show-common-commands - "Hide common commands" - "Show common permanently"))) - (list "C-x l" "Show/hide suffixes" #'transient-set-level) - (list "C-x a" #'transient-toggle-level-limit))))) - t))) - -(defvar-keymap transient-popup-navigation-map - :doc "One of the keymaps used when popup navigation is enabled. -See `transient-enable-popup-navigation'." - "<down-mouse-1>" #'transient-noop - "<up>" #'transient-backward-button - "<down>" #'transient-forward-button - "C-r" #'transient-isearch-backward - "C-s" #'transient-isearch-forward - "M-RET" #'transient-push-button) - -(defvar-keymap transient-button-map - :doc "One of the keymaps used when popup navigation is enabled. -See `transient-enable-popup-navigation'." - "<mouse-1>" #'transient-push-button - "<mouse-2>" #'transient-push-button) - -(defvar-keymap transient-resume-mode-map - :doc "Keymap for `transient-resume-mode'. - -This keymap remaps every command that would usually just quit the -documentation buffer to `transient-resume', which additionally -resumes the suspended transient." - "<remap> <Man-quit>" #'transient-resume - "<remap> <Info-exit>" #'transient-resume - "<remap> <quit-window>" #'transient-resume) - -(defvar-keymap transient-predicate-map - :doc "Base keymap used to map common commands to their transient behavior. - -The \"transient behavior\" of a command controls, among other -things, whether invoking the command causes the transient to be -exited or not, and whether infix arguments are exported before -doing so. - -Each \"key\" is a command that is common to all transients and -that is bound in `transient-map', `transient-edit-map', -`transient-sticky-map' and/or `transient-common-command'. - -Each binding is a \"pre-command\", a function that controls the -transient behavior of the respective command. - -For transient commands that are bound in individual transients, -the transient behavior is specified using the `:transient' slot -of the corresponding object." - "<transient-suspend>" #'transient--do-suspend - "<transient-help>" #'transient--do-stay - "<transient-set-level>" #'transient--do-stay - "<transient-history-prev>" #'transient--do-stay - "<transient-history-next>" #'transient--do-stay - "<universal-argument>" #'transient--do-stay - "<universal-argument-more>" #'transient--do-stay - "<negative-argument>" #'transient--do-minus - "<digit-argument>" #'transient--do-stay - "<top-level>" #'transient--do-quit-all - "<transient-quit-all>" #'transient--do-quit-all - "<transient-quit-one>" #'transient--do-quit-one - "<transient-quit-seq>" #'transient--do-stay - "<transient-show>" #'transient--do-stay - "<transient-update>" #'transient--do-stay - "<transient-toggle-common>" #'transient--do-stay - "<transient-set>" #'transient--do-call - "<transient-set-and-exit>" #'transient--do-exit - "<transient-save>" #'transient--do-call - "<transient-save-and-exit>" #'transient--do-exit - "<transient-reset>" #'transient--do-call - "<describe-key-briefly>" #'transient--do-stay - "<describe-key>" #'transient--do-stay - "<transient-scroll-up>" #'transient--do-stay - "<transient-scroll-down>" #'transient--do-stay - "<mwheel-scroll>" #'transient--do-stay - "<scroll-bar-toolkit-scroll>" #'transient--do-stay - "<transient-noop>" #'transient--do-noop - "<transient-mouse-push-button>" #'transient--do-move - "<transient-push-button>" #'transient--do-push-button - "<transient-backward-button>" #'transient--do-move - "<transient-forward-button>" #'transient--do-move - "<transient-isearch-backward>" #'transient--do-move - "<transient-isearch-forward>" #'transient--do-move - ;; If a valid but incomplete prefix sequence is followed by - ;; an unbound key, then Emacs calls the `undefined' command - ;; but does not set `this-command', `this-original-command' - ;; or `real-this-command' accordingly. Instead they are nil. - "<nil>" #'transient--do-warn - ;; Bound to the `mouse-movement' event, this command is similar - ;; to `ignore'. - "<ignore-preserving-kill-region>" #'transient--do-noop) - -(defvar transient--transient-map nil) -(defvar transient--predicate-map nil) -(defvar transient--redisplay-map nil) -(defvar transient--redisplay-key nil) - -(defun transient--push-keymap (var) - (let ((map (symbol-value var))) - (transient--debug " push %s%s" var (if map "" " VOID")) - (when map - (with-demoted-errors "transient--push-keymap: %S" - (internal-push-keymap map 'overriding-terminal-local-map))))) - -(defun transient--pop-keymap (var) - (let ((map (symbol-value var))) - (when map - (transient--debug " pop %s" var) - (with-demoted-errors "transient--pop-keymap: %S" - (internal-pop-keymap map 'overriding-terminal-local-map))))) - -(defun transient--make-transient-map () - (let ((map (make-sparse-keymap))) - (set-keymap-parent map (if transient--editp - transient-edit-map - transient-map)) - (dolist (obj transient--suffixes) - (let ((key (oref obj key))) - (when (vectorp key) - (setq key (key-description key)) - (oset obj key key)) - (when transient-substitute-key-function - (setq key (save-match-data - (funcall transient-substitute-key-function obj))) - (oset obj key key)) - (let* ((kbd (kbd key)) - (cmd (oref obj command)) - (alt (transient--lookup-key map kbd))) - (cond ((not alt) - (define-key map kbd cmd)) - ((eq alt cmd)) - ((transient--inapt-suffix-p obj)) - ((and-let* ((obj (transient-suffix-object alt))) - (transient--inapt-suffix-p obj)) - (define-key map kbd cmd)) - (transient-detect-key-conflicts - (error "Cannot bind %S to %s and also %s" - (string-trim key) cmd alt)) - ((define-key map kbd cmd)))))) - (when-let ((b (keymap-lookup map "-"))) (keymap-set map "<kp-subtract>" b)) - (when-let ((b (keymap-lookup map "="))) (keymap-set map "<kp-equal>" b)) - (when-let ((b (keymap-lookup map "+"))) (keymap-set map "<kp-add>" b)) - (when transient-enable-popup-navigation - ;; `transient--make-redisplay-map' maps only over bindings that are - ;; directly in the base keymap, so that cannot be a composed keymap. - (set-keymap-parent - map (make-composed-keymap - (keymap-parent map) - transient-popup-navigation-map))) - map)) - -(defun transient--make-predicate-map () - (let* ((default (transient--resolve-pre-command - (oref transient--prefix transient-suffix))) - (return (and transient--stack (eq default t))) - (map (make-sparse-keymap))) - (set-keymap-parent map transient-predicate-map) - (when (or (and (slot-boundp transient--prefix 'transient-switch-frame) - (transient--resolve-pre-command - (not (oref transient--prefix transient-switch-frame)))) - (memq (transient--resolve-pre-command - (oref transient--prefix transient-non-suffix)) - '(nil transient--do-warn transient--do-noop))) - (define-key map [handle-switch-frame] #'transient--do-suspend)) - (dolist (obj transient--suffixes) - (let* ((cmd (oref obj command)) - (kind (cond ((get cmd 'transient--prefix) 'prefix) - ((cl-typep obj 'transient-infix) 'infix) - (t 'suffix)))) - (cond - ((oref obj inapt) - (define-key map (vector cmd) #'transient--do-warn-inapt)) - ((slot-boundp obj 'transient) - (define-key map (vector cmd) - (pcase (list kind - (transient--resolve-pre-command (oref obj transient)) - return) - (`(prefix t ,_) #'transient--do-recurse) - (`(prefix nil ,_) #'transient--do-stack) - (`(infix t ,_) #'transient--do-stay) - (`(suffix t ,_) #'transient--do-call) - ('(suffix nil t) #'transient--do-return) - (`(,_ nil ,_) #'transient--do-exit) - (`(,_ ,do ,_) do)))) - ((not (lookup-key transient-predicate-map (vector cmd))) - (define-key map (vector cmd) - (pcase (list kind default return) - (`(prefix ,(or 'transient--do-stay 'transient--do-call) ,_) - #'transient--do-recurse) - (`(prefix t ,_) #'transient--do-recurse) - (`(prefix ,_ ,_) #'transient--do-stack) - (`(infix ,_ ,_) #'transient--do-stay) - (`(suffix t ,_) #'transient--do-call) - ('(suffix nil t) #'transient--do-return) - (`(suffix nil ,_) #'transient--do-exit) - (`(suffix ,do ,_) do))))))) - map)) - -(defun transient--make-redisplay-map () - (setq transient--redisplay-key - (pcase this-command - ('transient-update - (setq transient--showp t) - (setq unread-command-events - (listify-key-sequence (this-single-command-raw-keys)))) - ('transient-quit-seq - (setq unread-command-events - (butlast (listify-key-sequence - (this-single-command-raw-keys)) - 2)) - (butlast transient--redisplay-key)) - (_ nil))) - (let ((topmap (make-sparse-keymap)) - (submap (make-sparse-keymap))) - (when transient--redisplay-key - (define-key topmap (vconcat transient--redisplay-key) submap) - (set-keymap-parent submap transient-sticky-map)) - (map-keymap-internal - (lambda (key def) - (when (and (not (eq key ?\e)) - (listp def) - (keymapp def)) - (define-key topmap (vconcat transient--redisplay-key (list key)) - #'transient-update))) - (if transient--redisplay-key - (let ((key (vconcat transient--redisplay-key))) - (or (lookup-key transient--transient-map key) - (and-let* ((regular (lookup-key local-function-key-map key))) - (lookup-key transient--transient-map (vconcat regular))))) - transient--transient-map)) - topmap)) - -;;; Setup - -(defun transient-setup (&optional name layout edit &rest params) - "Setup the transient specified by NAME. - -This function is called by transient prefix commands to setup the -transient. In that case NAME is mandatory, LAYOUT and EDIT must -be nil and PARAMS may be (but usually is not) used to set, e.g., -the \"scope\" of the transient (see `transient-define-prefix'). - -This function is also called internally in which case LAYOUT and -EDIT may be non-nil." - (transient--debug 'setup) - (transient--with-emergency-exit :setup - (cond - ((not name) - ;; Switching between regular and edit mode. - (transient--pop-keymap 'transient--transient-map) - (transient--pop-keymap 'transient--redisplay-map) - (setq name (oref transient--prefix command)) - (setq params (list :scope (oref transient--prefix scope)))) - (transient--prefix - ;; Invoked as a ":transient-non-suffix 'transient--do-{stay,call}" - ;; of an outer prefix. Unlike the usual `transient--do-stack', - ;; these predicates fail to clean up after the outer prefix. - (transient--pop-keymap 'transient--transient-map) - (transient--pop-keymap 'transient--redisplay-map)) - ((not (or layout ; resuming parent/suspended prefix - transient-current-command)) ; entering child prefix - (transient--stack-zap)) ; replace suspended prefix, if any - (edit - ;; Returning from help to edit. - (setq transient--editp t))) - (transient--init-objects name layout params) - (transient--init-keymaps) - (transient--history-init transient--prefix) - (setq transient--original-window (selected-window)) - (setq transient--original-buffer (current-buffer)) - (setq transient--minibuffer-depth (minibuffer-depth)) - (transient--redisplay) - (transient--init-transient) - (transient--suspend-which-key-mode))) - -(cl-defgeneric transient-setup-children (group children) - "Setup the CHILDREN of GROUP. -If the value of the `setup-children' slot is non-nil, then call -that function with CHILDREN as the only argument and return the -value. Otherwise return CHILDREN as is." - (if (slot-boundp group 'setup-children) - (funcall (oref group setup-children) children) - children)) - -(defun transient--init-keymaps () - (setq transient--predicate-map (transient--make-predicate-map)) - (setq transient--transient-map (transient--make-transient-map)) - (setq transient--redisplay-map (transient--make-redisplay-map))) - -(defun transient--init-objects (&optional name layout params) - (if name - (setq transient--prefix (transient--init-prefix name params)) - (setq name (oref transient--prefix command))) - (setq transient--refreshp (oref transient--prefix refresh-suffixes)) - (setq transient--layout (or layout (transient--init-suffixes name))) - (setq transient--suffixes (transient--flatten-suffixes transient--layout))) - -(defun transient--init-prefix (name &optional params) - (let ((obj (let ((proto (get name 'transient--prefix))) - (apply #'clone proto - :prototype proto - :level (or (alist-get t (alist-get name transient-levels)) - transient-default-level) - params)))) - (transient--setup-recursion obj) - (transient-init-value obj) - obj)) - -(defun transient--init-suffixes (name) - (let ((levels (alist-get name transient-levels))) - (cl-mapcan (lambda (c) (transient--init-child levels c nil)) - (append (get name 'transient--layout) - (and (not transient--editp) - (get 'transient-common-commands - 'transient--layout)))))) - -(defun transient--flatten-suffixes (layout) - (cl-labels ((s (def) - (cond - ((stringp def) nil) - ((cl-typep def 'transient-information) nil) - ((listp def) (cl-mapcan #'s def)) - ((cl-typep def 'transient-group) - (cl-mapcan #'s (oref def suffixes))) - ((cl-typep def 'transient-suffix) - (list def))))) - (cl-mapcan #'s layout))) - -(defun transient--init-child (levels spec parent) - (cl-etypecase spec - (vector (transient--init-group levels spec parent)) - (list (transient--init-suffix levels spec parent)) - (string (list spec)))) - -(defun transient--init-group (levels spec parent) - (pcase-let ((`(,level ,class ,args ,children) (append spec nil))) - (and-let* (((transient--use-level-p level)) - (obj (apply class :level level args)) - ((transient--use-suffix-p obj)) - ((prog1 t - (when (or (and parent (oref parent inapt)) - (transient--inapt-suffix-p obj)) - (oset obj inapt t)))) - (suffixes (cl-mapcan - (lambda (c) (transient--init-child levels c obj)) - (transient-setup-children obj children)))) - (progn ; work around debbugs#31840 - (oset obj suffixes suffixes) - (list obj))))) - -(defun transient--init-suffix (levels spec parent) - (pcase-let* ((`(,level ,class ,args) spec) - (cmd (plist-get args :command)) - (key (transient--kbd (plist-get args :key))) - (level (or (alist-get (cons cmd key) levels nil nil #'equal) - (alist-get cmd levels) - level))) - (let ((fn (and (symbolp cmd) - (symbol-function cmd)))) - (when (autoloadp fn) - (transient--debug " autoload %s" cmd) - (autoload-do-load fn))) - (when (transient--use-level-p level) - (let ((obj (if (child-of-class-p class 'transient-information) - (apply class :level level args) - (unless (and cmd (symbolp cmd)) - (error "BUG: Non-symbolic suffix command: %s" cmd)) - (if-let ((proto (and cmd (transient--suffix-prototype cmd)))) - (apply #'clone proto :level level args) - (apply class :command cmd :level level args))))) - (cond ((not cmd)) - ((commandp cmd)) - ((or (cl-typep obj 'transient-switch) - (cl-typep obj 'transient-option)) - ;; As a temporary special case, if the package was compiled - ;; with an older version of Transient, then we must define - ;; "anonymous" switch and option commands here. - (defalias cmd #'transient--default-infix-command)) - ((transient--use-suffix-p obj) - (error "Suffix command %s is not defined or autoloaded" cmd))) - (unless (cl-typep obj 'transient-information) - (transient--init-suffix-key obj)) - (when (transient--use-suffix-p obj) - (if (or (and parent (oref parent inapt)) - (transient--inapt-suffix-p obj)) - (oset obj inapt t) - (transient-init-scope obj) - (transient-init-value obj)) - (list obj)))))) - -(cl-defmethod transient--init-suffix-key ((obj transient-suffix)) - (unless (slot-boundp obj 'key) - (error "No key for %s" (oref obj command)))) - -(cl-defmethod transient--init-suffix-key ((obj transient-argument)) - (if (transient-switches--eieio-childp obj) - (cl-call-next-method obj) - (unless (slot-boundp obj 'shortarg) - (when-let ((shortarg (transient--derive-shortarg (oref obj argument)))) - (oset obj shortarg shortarg))) - (unless (slot-boundp obj 'key) - (if (slot-boundp obj 'shortarg) - (oset obj key (oref obj shortarg)) - (error "No key for %s" (oref obj command)))))) - -(defun transient--use-level-p (level &optional edit) - (or transient--all-levels-p - (and transient--editp (not edit)) - (and (>= level 1) - (<= level (oref transient--prefix level))))) - -(defun transient--use-suffix-p (obj) - (let ((transient--shadowed-buffer (current-buffer)) - (transient--pending-suffix obj)) - (transient--do-suffix-p - (oref obj if) - (oref obj if-not) - (oref obj if-nil) - (oref obj if-non-nil) - (oref obj if-mode) - (oref obj if-not-mode) - (oref obj if-derived) - (oref obj if-not-derived) - t))) - -(defun transient--inapt-suffix-p (obj) - (let ((transient--shadowed-buffer (current-buffer)) - (transient--pending-suffix obj)) - (transient--do-suffix-p - (oref obj inapt-if) - (oref obj inapt-if-not) - (oref obj inapt-if-nil) - (oref obj inapt-if-non-nil) - (oref obj inapt-if-mode) - (oref obj inapt-if-not-mode) - (oref obj inapt-if-derived) - (oref obj inapt-if-not-derived) - nil))) - -(defun transient--do-suffix-p - (if if-not if-nil if-non-nil if-mode if-not-mode if-derived if-not-derived - default) - (cond - (if (funcall if)) - (if-not (not (funcall if-not))) - (if-non-nil (symbol-value if-non-nil)) - (if-nil (not (symbol-value if-nil))) - (if-mode (if (atom if-mode) - (eq major-mode if-mode) - (memq major-mode if-mode))) - (if-not-mode (not (if (atom if-not-mode) - (eq major-mode if-not-mode) - (memq major-mode if-not-mode)))) - (if-derived (if (or (atom if-derived) - (>= emacs-major-version 30)) - (derived-mode-p if-derived) - (apply #'derived-mode-p if-derived))) - (if-not-derived (not (if (or (atom if-not-derived) - (>= emacs-major-version 30)) - (derived-mode-p if-not-derived) - (apply #'derived-mode-p if-not-derived)))) - (default))) - -(defun transient--suffix-predicate (spec) - (let ((plist (nth 2 spec))) - (seq-some (lambda (prop) - (and-let* ((pred (plist-get plist prop))) - (list prop pred))) - '( :if :if-not - :if-nil :if-non-nil - :if-mode :if-not-mode - :if-derived :if-not-derived - :inapt-if :inapt-if-not - :inapt-if-nil :inapt-if-non-nil - :inapt-if-mode :inapt-if-not-mode - :inapt-if-derived :inapt-if-not-derived)))) - -;;; Flow-Control - -(defun transient--init-transient () - (transient--debug 'init-transient) - (transient--push-keymap 'transient--transient-map) - (transient--push-keymap 'transient--redisplay-map) - (add-hook 'pre-command-hook #'transient--pre-command) - (add-hook 'post-command-hook #'transient--post-command) - (advice-add 'recursive-edit :around #'transient--recursive-edit) - (when transient--exitp - ;; This prefix command was invoked as the suffix of another. - ;; Prevent `transient--post-command' from removing the hooks - ;; that we just added. - (setq transient--exitp 'replace))) - -(defun transient--refresh-transient () - (transient--debug 'refresh-transient) - (transient--pop-keymap 'transient--predicate-map) - (transient--pop-keymap 'transient--transient-map) - (transient--pop-keymap 'transient--redisplay-map) - (transient--init-objects) - (transient--init-keymaps) - (transient--push-keymap 'transient--transient-map) - (transient--push-keymap 'transient--redisplay-map) - (transient--redisplay)) - -(defun transient--pre-command () - (transient--debug 'pre-command) - (transient--with-emergency-exit :pre-command - ;; The use of `overriding-terminal-local-map' does not prevent the - ;; lookup of command remappings in the overridden maps, which can - ;; lead to a suffix being remapped to a non-suffix. We have to undo - ;; the remapping in that case. However, remapping a non-suffix to - ;; another should remain possible. - (when (and (transient--get-pre-command this-original-command 'suffix) - (not (transient--get-pre-command this-command 'suffix))) - (setq this-command this-original-command)) - (cond - ((memq this-command '(transient-update transient-quit-seq)) - (transient--pop-keymap 'transient--redisplay-map)) - ((and transient--helpp - (not (memq this-command '(transient-quit-one - transient-quit-all)))) - (cond - ((transient-help) - (transient--do-suspend) - (setq this-command 'transient-suspend) - (transient--pre-exit)) - ((not (transient--edebug-command-p)) - (setq this-command 'transient-undefined)))) - ((and transient--editp - (transient-suffix-object) - (not (memq this-command '(transient-quit-one - transient-quit-all - transient-help)))) - (setq this-command 'transient-set-level) - (transient--wrap-command)) - (t - (setq transient--exitp nil) - (let ((exitp (eq (transient--call-pre-command) transient--exit))) - (transient--wrap-command) - (when exitp - (transient--pre-exit))))))) - -(defun transient--pre-exit () - (transient--debug 'pre-exit) - (transient--delete-window) - (transient--timer-cancel) - (transient--pop-keymap 'transient--transient-map) - (transient--pop-keymap 'transient--redisplay-map) - (unless transient--showp - (let ((message-log-max nil)) - (message ""))) - (setq transient--transient-map nil) - (setq transient--predicate-map nil) - (setq transient--redisplay-map nil) - (setq transient--redisplay-key nil) - (setq transient--helpp nil) - (setq transient--editp nil) - (setq transient--prefix nil) - (setq transient--layout nil) - (setq transient--suffixes nil) - (setq transient--original-window nil) - (setq transient--original-buffer nil) - (setq transient--window nil)) - -(defun transient--delete-window () - (when (window-live-p transient--window) - (let ((remain-in-minibuffer-window - (and (minibuffer-selected-window) - (selected-window)))) - ;; Only delete the window if it has never shown another buffer. - (unless (eq (car (window-parameter transient--window 'quit-restore)) - 'other) - (with-demoted-errors "Error while exiting transient: %S" - (delete-window transient--window))) - (when-let ((buffer (get-buffer transient--buffer-name))) - (kill-buffer buffer)) - (when remain-in-minibuffer-window - (select-window remain-in-minibuffer-window))))) - -(defun transient--export () - (setq transient-current-prefix transient--prefix) - (setq transient-current-command (oref transient--prefix command)) - (setq transient-current-suffixes transient--suffixes) - (transient--history-push transient--prefix)) - -(defun transient--suspend-override (&optional nohide) - (transient--debug 'suspend-override) - (transient--timer-cancel) - (cond ((and (not nohide) transient-hide-during-minibuffer-read) - (transient--delete-window)) - ((and transient--prefix transient--redisplay-key) - (setq transient--redisplay-key nil) - (when transient--showp - (if-let ((win (minibuffer-selected-window))) - (with-selected-window win - (transient--show)) - (transient--show))))) - (transient--pop-keymap 'transient--transient-map) - (transient--pop-keymap 'transient--redisplay-map) - (remove-hook 'pre-command-hook #'transient--pre-command) - (remove-hook 'post-command-hook #'transient--post-command)) - -(defun transient--resume-override (&optional _ignore) - (transient--debug 'resume-override) - (when (and transient--showp transient-hide-during-minibuffer-read) - (transient--show)) - (transient--push-keymap 'transient--transient-map) - (transient--push-keymap 'transient--redisplay-map) - (add-hook 'pre-command-hook #'transient--pre-command) - (add-hook 'post-command-hook #'transient--post-command)) - -(defun transient--recursive-edit (fn) - (transient--debug 'recursive-edit) - (if (not transient--prefix) - (funcall fn) - (transient--suspend-override (bound-and-true-p edebug-active)) - (funcall fn) ; Already unwind protected. - (cond ((memq this-command '(top-level abort-recursive-edit)) - (setq transient--exitp t) - (transient--post-exit) - (transient--delete-window)) - (transient--prefix - (transient--resume-override))))) - -(defmacro transient--with-suspended-override (&rest body) - (let ((depth (make-symbol "depth")) - (setup (make-symbol "setup")) - (exit (make-symbol "exit"))) - `(if (and transient--transient-map - (memq transient--transient-map - overriding-terminal-local-map)) - (let ((,depth (1+ (minibuffer-depth))) ,setup ,exit) - (setq ,setup - (lambda () "@transient--with-suspended-override" - (transient--debug 'minibuffer-setup) - (remove-hook 'minibuffer-setup-hook ,setup) - (transient--suspend-override))) - (setq ,exit - (lambda () "@transient--with-suspended-override" - (transient--debug 'minibuffer-exit) - (when (= (minibuffer-depth) ,depth) - (transient--resume-override)))) - (unwind-protect - (progn - (add-hook 'minibuffer-setup-hook ,setup) - (add-hook 'minibuffer-exit-hook ,exit) - ,@body) - (remove-hook 'minibuffer-setup-hook ,setup) - (remove-hook 'minibuffer-exit-hook ,exit))) - ,@body))) - -(static-if (>= emacs-major-version 30) ;transient--wrap-command - (defun transient--wrap-command () - (cl-assert - (>= emacs-major-version 30) nil - "Emacs was downgraded, making it necessary to recompile Transient") - (letrec - ((prefix transient--prefix) - (suffix this-command) - (advice - (lambda (fn &rest args) - (interactive - (lambda (spec) - (let ((abort t)) - (unwind-protect - (prog1 (let ((debugger #'transient--exit-and-debug)) - (advice-eval-interactive-spec spec)) - (setq abort nil)) - (when abort - (when-let ((unwind (oref prefix unwind-suffix))) - (transient--debug 'unwind-interactive) - (funcall unwind suffix)) - (advice-remove suffix advice) - (oset prefix unwind-suffix nil)))))) - (unwind-protect - (let ((debugger #'transient--exit-and-debug)) - (apply fn args)) - (when-let ((unwind (oref prefix unwind-suffix))) - (transient--debug 'unwind-command) - (funcall unwind suffix)) - (advice-remove suffix advice) - (oset prefix unwind-suffix nil))))) - (when (symbolp this-command) - (advice-add suffix :around advice '((depth . -99)))))) - - (defun transient--wrap-command () - (let* ((prefix transient--prefix) - (suffix this-command) - (advice nil) - (advice-interactive - (lambda (spec) - (let ((abort t)) - (unwind-protect - (prog1 (let ((debugger #'transient--exit-and-debug)) - (advice-eval-interactive-spec spec)) - (setq abort nil)) - (when abort - (when-let ((unwind (oref prefix unwind-suffix))) - (transient--debug 'unwind-interactive) - (funcall unwind suffix)) - (advice-remove suffix advice) - (oset prefix unwind-suffix nil)))))) - (advice-body - (lambda (fn &rest args) - (unwind-protect - (let ((debugger #'transient--exit-and-debug)) - (apply fn args)) - (when-let ((unwind (oref prefix unwind-suffix))) - (transient--debug 'unwind-command) - (funcall unwind suffix)) - (advice-remove suffix advice) - (oset prefix unwind-suffix nil))))) - (setq advice `(lambda (fn &rest args) - (interactive ,advice-interactive) - (apply ',advice-body fn args))) - (when (symbolp this-command) - (advice-add suffix :around advice '((depth . -99))))))) - -(defun transient--premature-post-command () - (and (equal (this-command-keys-vector) []) - (= (minibuffer-depth) - (1+ transient--minibuffer-depth)) - (progn - (transient--debug 'premature-post-command) - (transient--suspend-override) - (oset (or transient--prefix transient-current-prefix) - unwind-suffix - (if transient--exitp - #'transient--post-exit - #'transient--resume-override)) - t))) - -(defun transient--post-command () - (unless (transient--premature-post-command) - (transient--debug 'post-command) - (transient--with-emergency-exit :post-command - (cond (transient--exitp (transient--post-exit)) - ;; If `this-command' is the current transient prefix, then we - ;; have already taken care of updating the transient buffer... - ((and (eq this-command (oref transient--prefix command)) - ;; ... but if `prefix-arg' is non-nil, then the values - ;; of `this-command' and `real-this-command' are untrue - ;; because `prefix-command-preserve-state' changes them. - ;; We cannot use `current-prefix-arg' because it is set - ;; too late (in `command-execute'), and if it were set - ;; earlier, then we likely still would not be able to - ;; rely on it and `prefix-command-preserve-state-hook' - ;; would have to be used to record that a universal - ;; argument is in effect. - (not prefix-arg))) - (transient--refreshp - (transient--refresh-transient)) - ((let ((old transient--redisplay-map) - (new (transient--make-redisplay-map))) - (unless (equal old new) - (transient--pop-keymap 'transient--redisplay-map) - (setq transient--redisplay-map new) - (transient--push-keymap 'transient--redisplay-map)) - (transient--redisplay))))))) - -(defun transient--post-exit (&optional command) - (transient--debug 'post-exit) - (unless (and (eq transient--exitp 'replace) - (or transient--prefix - ;; The current command could act as a prefix, - ;; but decided not to call `transient-setup', - ;; or it is prevented from doing so because it - ;; uses the minibuffer and the user aborted - ;; that. - (prog1 nil - (if (let ((obj (transient-suffix-object command))) - (and (slot-boundp obj 'transient) - (oref obj transient))) - ;; This sub-prefix is a transient suffix; - ;; go back to outer prefix, by calling - ;; `transient--stack-pop' further down. - (setq transient--exitp nil) - (transient--stack-zap))))) - (remove-hook 'pre-command-hook #'transient--pre-command) - (remove-hook 'post-command-hook #'transient--post-command) - (advice-remove 'recursive-edit #'transient--recursive-edit)) - (setq transient-current-prefix nil) - (setq transient-current-command nil) - (setq transient-current-suffixes nil) - (let ((resume (and transient--stack - (not (memq transient--exitp '(replace suspend)))))) - (unless (or resume (eq transient--exitp 'replace)) - (setq transient--showp nil)) - (setq transient--exitp nil) - (setq transient--helpp nil) - (setq transient--editp nil) - (setq transient--all-levels-p nil) - (setq transient--minibuffer-depth 0) - (run-hooks 'transient-exit-hook) - (when resume - (transient--stack-pop)))) - -(defun transient--stack-push () - (transient--debug 'stack-push) - (push (list (oref transient--prefix command) - transient--layout - transient--editp - :transient-suffix (oref transient--prefix transient-suffix) - :scope (oref transient--prefix scope)) - transient--stack)) - -(defun transient--stack-pop () - (transient--debug 'stack-pop) - (and transient--stack - (prog1 t (apply #'transient-setup (pop transient--stack))))) - -(defun transient--stack-zap () - (transient--debug 'stack-zap) - (setq transient--stack nil)) - -(defun transient--redisplay () - (if (or (eq transient-show-popup t) - transient--showp) - (unless - (or (memq this-command transient--scroll-commands) - (and (or (memq this-command '(mouse-drag-region - mouse-set-region)) - (equal (key-description (this-command-keys-vector)) - "<mouse-movement>")) - (and (eq (current-buffer) - (get-buffer transient--buffer-name))))) - (transient--show)) - (when (and (numberp transient-show-popup) - (not (zerop transient-show-popup)) - (not transient--timer)) - (transient--timer-start)) - (transient--show-brief))) - -(defun transient--timer-start () - (setq transient--timer - (run-at-time (abs transient-show-popup) nil - (lambda () - (transient--timer-cancel) - (transient--show) - (let ((message-log-max nil)) - (message "")))))) - -(defun transient--timer-cancel () - (when transient--timer - (cancel-timer transient--timer) - (setq transient--timer nil))) - -(defun transient--debug (arg &rest args) - (when transient--debug - (let ((inhibit-message (not (eq transient--debug 'message)))) - (if (symbolp arg) - (message "-- %-22s (cmd: %s, event: %S, exit: %s%s)" - arg - (cond ((and (symbolp this-command) this-command)) - ((fboundp 'help-fns-function-name) - (help-fns-function-name this-command)) - ((byte-code-function-p this-command) - "#[...]") - (this-command)) - (key-description (this-command-keys-vector)) - transient--exitp - (cond ((keywordp (car args)) - (format ", from: %s" - (substring (symbol-name (car args)) 1))) - ((stringp (car args)) - (concat ", " (apply #'format args))) - ((functionp (car args)) - (concat ", " (apply (car args) (cdr args)))) - (""))) - (apply #'message arg args))))) - -(defun transient--emergency-exit (&optional id) - "Exit the current transient command after an error occurred. -When no transient is active (i.e., when `transient--prefix' is -nil) then do nothing. Optional ID is a keyword identifying the -exit." - (transient--debug 'emergency-exit id) - (when transient--prefix - (setq transient--stack nil) - (setq transient--exitp t) - (transient--pre-exit) - (transient--post-exit))) - -;;; Pre-Commands - -(defun transient--call-pre-command () - (if-let ((fn (transient--get-pre-command this-command))) - (let ((action (funcall fn))) - (when (eq action transient--exit) - (setq transient--exitp (or transient--exitp t))) - action) - (if (let ((keys (this-command-keys-vector))) - (eq (aref keys (1- (length keys))) ?\C-g)) - (setq this-command 'transient-noop) - (unless (transient--edebug-command-p) - (setq this-command 'transient-undefined))) - transient--stay)) - -(defun transient--get-pre-command (&optional cmd enforce-type) - (or (and (not (eq enforce-type 'non-suffix)) - (symbolp cmd) - (lookup-key transient--predicate-map (vector cmd))) - (and (not (eq enforce-type 'suffix)) - (transient--resolve-pre-command - (oref transient--prefix transient-non-suffix) - t)))) - -(defun transient--resolve-pre-command (pre &optional resolve-boolean) - (cond ((booleanp pre) - (if resolve-boolean - (if pre #'transient--do-stay #'transient--do-warn) - pre)) - ((string-match-p "--do-" (symbol-name pre)) pre) - ((let ((sym (intern (format "transient--do-%s" pre)))) - (if (functionp sym) sym pre))))) - -(defun transient--do-stay () - "Call the command without exporting variables and stay transient." - transient--stay) - -(defun transient--do-noop () - "Call `transient-noop' and stay transient." - (setq this-command 'transient-noop) - transient--stay) - -(defun transient--do-warn () - "Call `transient-undefined' and stay transient." - (setq this-command 'transient-undefined) - transient--stay) - -(defun transient--do-warn-inapt () - "Call `transient-inapt' and stay transient." - (setq this-command 'transient-inapt) - transient--stay) - -(defun transient--do-call () - "Call the command after exporting variables and stay transient." - (transient--export) - transient--stay) - -(defun transient--do-return () - "Call the command after exporting variables and return to parent prefix. -If there is no parent prefix, then behave like `transient--do-exit'." - (if (not transient--stack) - (transient--do-exit) - (transient--export) - transient--exit)) - -(defun transient--do-exit () - "Call the command after exporting variables and exit the transient." - (transient--export) - (transient--stack-zap) - transient--exit) - -(defun transient--do-leave () - "Call the command without exporting variables and exit the transient." - (transient--stack-zap) - transient--exit) - -(defun transient--do-push-button () - "Call the command represented by the activated button. -Use that command's pre-command to determine transient behavior." - (if (and (mouse-event-p last-command-event) - (not (eq (posn-window (event-start last-command-event)) - transient--window))) - transient--stay - (setq this-command - (with-selected-window transient--window - (get-text-property (if (mouse-event-p last-command-event) - (posn-point (event-start last-command-event)) - (point)) - 'command))) - (transient--call-pre-command))) - -(defun transient--do-recurse () - "Call the transient prefix command, preparing for return to active transient. -If there is no parent prefix, then just call the command." - (transient--do-stack)) - -(defun transient--setup-recursion (prefix-obj) - (when transient--stack - (let ((command (oref prefix-obj command))) - (when-let ((suffix-obj (transient-suffix-object command))) - (when (memq (if (slot-boundp suffix-obj 'transient) - (oref suffix-obj transient) - (oref transient-current-prefix transient-suffix)) - (list t #'transient--do-recurse)) - (oset prefix-obj transient-suffix t)))))) - -(defun transient--do-stack () - "Call the transient prefix command, stacking the active transient. -Push the active transient to the transient stack." - (transient--export) - (transient--stack-push) - (setq transient--exitp 'replace) - transient--exit) - -(defun transient--do-replace () - "Call the transient prefix command, replacing the active transient. -Do not push the active transient to the transient stack." - (transient--export) - (setq transient--exitp 'replace) - transient--exit) - -(defun transient--do-suspend () - "Suspend the active transient, saving the transient stack." - (transient--stack-push) - (setq transient--exitp 'suspend) - transient--exit) - -(defun transient--do-quit-one () - "If active, quit help or edit mode, else exit the active transient." - (cond (transient--helpp - (setq transient--helpp nil) - transient--stay) - (transient--editp - (setq transient--editp nil) - (transient-setup) - transient--stay) - (prefix-arg - transient--stay) - (transient--exit))) - -(defun transient--do-quit-all () - "Exit all transients without saving the transient stack." - (transient--stack-zap) - transient--exit) - -(defun transient--do-move () - "Call the command if `transient-enable-popup-navigation' is non-nil. -In that case behave like `transient--do-stay', otherwise similar -to `transient--do-warn'." - (unless transient-enable-popup-navigation - (setq this-command 'transient-inhibit-move)) - transient--stay) - -(defun transient--do-minus () - "Call `negative-argument' or pivot to `transient-update'. -If `negative-argument' is invoked using \"-\" then preserve the -prefix argument and pivot to `transient-update'." - (when (equal (this-command-keys) "-") - (setq this-command 'transient-update)) - transient--stay) - -(put 'transient--do-stay 'transient-face 'transient-key-stay) -(put 'transient--do-noop 'transient-face 'transient-key-noop) -(put 'transient--do-warn 'transient-face 'transient-key-noop) -(put 'transient--do-warn-inapt 'transient-face 'transient-key-noop) -(put 'transient--do-call 'transient-face 'transient-key-stay) -(put 'transient--do-return 'transient-face 'transient-key-return) -(put 'transient--do-exit 'transient-face 'transient-key-exit) -(put 'transient--do-leave 'transient-face 'transient-key-exit) - -(put 'transient--do-recurse 'transient-face 'transient-key-stay) -(put 'transient--do-stack 'transient-face 'transient-key-stay) -(put 'transient--do-replace 'transient-face 'transient-key-exit) -(put 'transient--do-suspend 'transient-face 'transient-key-exit) - -(put 'transient--do-quit-one 'transient-face 'transient-key-return) -(put 'transient--do-quit-all 'transient-face 'transient-key-exit) -(put 'transient--do-move 'transient-face 'transient-key-stay) -(put 'transient--do-minus 'transient-face 'transient-key-stay) - -;;; Commands -;;;; Noop - -(defun transient-noop () - "Do nothing at all." - (interactive)) - -(defun transient-undefined () - "Warn the user that the pressed key is not bound to any suffix." - (interactive) - (transient--invalid "Unbound suffix")) - -(defun transient-inapt () - "Warn the user that the invoked command is inapt." - (interactive) - (transient--invalid "Inapt command")) - -(defun transient--invalid (msg) - (ding) - (message "%s: `%s' (Use `%s' to abort, `%s' for help)%s" - msg - (propertize (key-description (this-single-command-keys)) - 'face 'font-lock-warning-face) - (propertize "C-g" 'face 'transient-key) - (propertize "?" 'face 'transient-key) - ;; `this-command' is `transient-undefined' or `transient-inapt'. - ;; Show the command (`this-original-command') the user actually - ;; tried to invoke. - (if-let ((cmd (or (ignore-errors (symbol-name this-original-command)) - (ignore-errors (symbol-name this-command))))) - (format " [%s]" (propertize cmd 'face 'font-lock-warning-face)) - "")) - (unless (and transient--transient-map - (memq transient--transient-map overriding-terminal-local-map)) - (let ((transient--prefix (or transient--prefix 'sic))) - (transient--emergency-exit)) - (view-lossage) - (other-window 1) - (display-warning 'transient "Inconsistent transient state detected. -This should never happen. -Please open an issue and post the shown command log." :error))) - -(defun transient-inhibit-move () - "Warn the user that popup navigation is disabled." - (interactive) - (message "To enable use of `%s', please customize `%s'" - this-original-command - 'transient-enable-popup-navigation)) - -;;;; Core - -(defun transient-quit-all () - "Exit all transients without saving the transient stack." - (interactive)) - -(defun transient-quit-one () - "Exit the current transients, returning to outer transient, if any." - (interactive)) - -(defun transient-quit-seq () - "Abort the current incomplete key sequence." - (interactive)) - -(defun transient-update () - "Redraw the transient's state in the popup buffer." - (interactive) - (setq prefix-arg current-prefix-arg)) - -(defun transient-show () - "Show the transient's state in the popup buffer." - (interactive) - (setq transient--showp t)) - -(defun transient-push-button () - "Invoke the suffix command represented by this button." - (interactive)) - -;;;; Suspend - -(defun transient-suspend () - "Suspend the current transient. -It can later be resumed using `transient-resume', while no other -transient is active." - (interactive)) - -(define-minor-mode transient-resume-mode - "Auxiliary minor-mode used to resume a transient after viewing help.") - -(defun transient-resume () - "Resume a previously suspended stack of transients." - (interactive) - (cond (transient--stack - (let ((winconf transient--restore-winconf)) - (kill-local-variable 'transient--restore-winconf) - (when transient-resume-mode - (transient-resume-mode -1) - (quit-window)) - (when winconf - (set-window-configuration winconf))) - (transient--stack-pop)) - (transient-resume-mode - (kill-local-variable 'transient--restore-winconf) - (transient-resume-mode -1) - (quit-window)) - (t - (message "No suspended transient command")))) - -;;;; Help - -(defun transient-help (&optional interactive) - "Show help for the active transient or one of its suffixes.\n\n(fn)" - (interactive (list t)) - (if interactive - (setq transient--helpp t) - (with-demoted-errors "transient-help: %S" - (when (lookup-key transient--transient-map - (this-single-command-raw-keys)) - (setq transient--helpp nil) - (let ((winconf (current-window-configuration))) - (transient-show-help - (if (eq this-original-command 'transient-help) - transient--prefix - (or (transient-suffix-object) - this-original-command))) - (setq-local transient--restore-winconf winconf)) - (fit-window-to-buffer nil (frame-height) (window-height)) - (transient-resume-mode) - (message (substitute-command-keys - "Type \\`q' to resume transient command.")) - t)))) - -;;;; Level - -(defun transient-set-level (&optional command level) - "Set the level of the transient or one of its suffix commands." - (interactive - (let ((command this-original-command) - (prefix (oref transient--prefix command))) - (and (or (not (eq command 'transient-set-level)) - (and transient--editp - (setq command prefix))) - (list command - (let ((keys (this-single-command-raw-keys))) - (and (lookup-key transient--transient-map keys) - (progn - (transient--show) - (string-to-number - (transient--read-number-N - (format "Set level for `%s': " command) - nil nil (not (eq command prefix))))))))))) - (cond - ((not command) - (setq transient--editp t) - (transient-setup)) - (level - (let* ((prefix (oref transient--prefix command)) - (alist (alist-get prefix transient-levels)) - (akey command)) - (cond ((eq command prefix) - (oset transient--prefix level level) - (setq akey t)) - (t - (oset (transient-suffix-object command) level level) - (when (cdr (cl-remove-if-not (lambda (obj) - (eq (oref obj command) command)) - transient--suffixes)) - (setq akey (cons command (this-command-keys)))))) - (setf (alist-get akey alist) level) - (setf (alist-get prefix transient-levels) alist)) - (transient-save-levels) - (transient--show)) - (t - (transient-undefined)))) - -(transient-define-suffix transient-toggle-level-limit () - "Toggle whether to temporarily displayed suffixes on all levels." - :description - (lambda () - (cond - ((= transient-default-level transient--max-level) - "Always displaying all levels") - (transient--all-levels-p - (format "Hide suffix %s" - (propertize - (format "levels > %s" (oref (transient-prefix-object) level)) - 'face 'transient-higher-level))) - ("Show all suffix levels"))) - :inapt-if (lambda () (= transient-default-level transient--max-level)) - :transient t - (interactive) - (setq transient--all-levels-p (not transient--all-levels-p)) - (setq transient--refreshp t)) - -;;;; Value - -(defun transient-set () - "Set active transient's value for this Emacs session." - (interactive) - (transient-set-value (transient-prefix-object))) - -(defalias 'transient-set-and-exit #'transient-set - "Set active transient's value for this Emacs session and exit.") - -(defun transient-save () - "Save active transient's value for this and future Emacs sessions." - (interactive) - (transient-save-value (transient-prefix-object))) - -(defalias 'transient-save-and-exit #'transient-save - "Save active transient's value for this and future Emacs sessions and exit.") - -(defun transient-reset () - "Clear the set and saved values of the active transient." - (interactive) - (transient-reset-value (transient-prefix-object))) - -(defun transient-history-next () - "Switch to the next value used for the active transient." - (interactive) - (let* ((obj transient--prefix) - (pos (1- (oref obj history-pos))) - (hst (oref obj history))) - (if (< pos 0) - (user-error "End of history") - (oset obj history-pos pos) - (oset obj value (nth pos hst)) - (mapc #'transient-init-value transient--suffixes)))) - -(defun transient-history-prev () - "Switch to the previous value used for the active transient." - (interactive) - (let* ((obj transient--prefix) - (pos (1+ (oref obj history-pos))) - (hst (oref obj history)) - (len (length hst))) - (if (> pos (1- len)) - (user-error "End of history") - (oset obj history-pos pos) - (oset obj value (nth pos hst)) - (mapc #'transient-init-value transient--suffixes)))) - -;;;; Auxiliary - -(defun transient-toggle-common () - "Toggle whether common commands are permanently shown." - (interactive) - (setq transient-show-common-commands (not transient-show-common-commands))) - -(defun transient-toggle-debug () - "Toggle debugging statements for transient commands." - (interactive) - (setq transient--debug (not transient--debug)) - (message "Debugging transient %s" - (if transient--debug "enabled" "disabled"))) - -(transient-define-suffix transient-echo-arguments (arguments) - "Show the transient's active ARGUMENTS in the echo area. -Intended for use in prefixes used for demonstration purposes, -such as when suggesting a new feature or reporting an issue." - :transient t - :description "Echo arguments" - :key "x" - (interactive (list (transient-args transient-current-command))) - (message "%s: %s" - (key-description (this-command-keys)) - (mapconcat (lambda (arg) - (propertize (if (string-match-p " " arg) - (format "%S" arg) - arg) - 'face 'transient-argument)) - arguments " "))) - -;;; Value -;;;; Init - -(cl-defgeneric transient-init-scope (obj) - "Set the scope of the suffix object OBJ. - -The scope is actually a property of the transient prefix, not of -individual suffixes. However it is possible to invoke a suffix -command directly instead of from a transient. In that case, if -the suffix expects a scope, then it has to determine that itself -and store it in its `scope' slot. - -This function is called for all suffix commands, but unless a -concrete method is implemented this falls through to the default -implementation, which is a noop.") - -(cl-defmethod transient-init-scope ((_ transient-suffix)) - "Noop." nil) - -(cl-defgeneric transient-init-value (_) - "Set the initial value of the object OBJ. - -This function is called for all prefix and suffix commands. - -For suffix commands (including infix argument commands) the -default implementation is a noop. Classes derived from the -abstract `transient-infix' class must implement this function. -Non-infix suffix commands usually don't have a value." - nil) - -(cl-defmethod transient-init-value :around ((obj transient-prefix)) - "If bound, then call OBJ's `init-value' function. -Otherwise call the primary method according to object's class." - (if (slot-boundp obj 'init-value) - (funcall (oref obj init-value) obj) - (cl-call-next-method obj))) - -(cl-defmethod transient-init-value :around ((obj transient-infix)) - "If bound, then call OBJ's `init-value' function. -Otherwise call the primary method according to object's class." - (if (slot-boundp obj 'init-value) - (funcall (oref obj init-value) obj) - (cl-call-next-method obj))) - -(cl-defmethod transient-init-value ((obj transient-prefix)) - (if (slot-boundp obj 'value) - (oref obj value) - (oset obj value - (if-let ((saved (assq (oref obj command) transient-values))) - (cdr saved) - (transient-default-value obj))))) - -(cl-defmethod transient-init-value ((obj transient-argument)) - (oset obj value - (let ((value (oref transient--prefix value)) - (argument (and (slot-boundp obj 'argument) - (oref obj argument))) - (multi-value (oref obj multi-value)) - (case-fold-search nil) - (regexp (if (slot-exists-p obj 'argument-regexp) - (oref obj argument-regexp) - (format "\\`%s\\(.*\\)" (oref obj argument))))) - (if (memq multi-value '(t rest)) - (cdr (assoc argument value)) - (let ((match (lambda (v) - (and (stringp v) - (string-match regexp v) - (match-string 1 v))))) - (if multi-value - (delq nil (mapcar match value)) - (cl-some match value))))))) - -(cl-defmethod transient-init-value ((obj transient-switch)) - (oset obj value - (car (member (oref obj argument) - (oref transient--prefix value))))) - -;;;; Default - -(cl-defgeneric transient-default-value (_) - "Return the default value." - nil) - -(cl-defmethod transient-default-value ((obj transient-prefix)) - (if-let ((default (and (slot-boundp obj 'default-value) - (oref obj default-value)))) - (if (functionp default) - (funcall default) - default) - nil)) - -;;;; Read - -(cl-defgeneric transient-infix-read (obj) - "Determine the new value of the infix object OBJ. - -This function merely determines the value; `transient-infix-set' -is used to actually store the new value in the object. - -For most infix classes this is done by reading a value from the -user using the reader specified by the `reader' slot (using the -`transient-infix' method described below). - -For some infix classes the value is changed without reading -anything in the minibuffer, i.e., the mere act of invoking the -infix command determines what the new value should be, based -on the previous value.") - -(cl-defmethod transient-infix-read :around ((obj transient-infix)) - "Refresh the transient buffer and call the next method. - -Also wrap `cl-call-next-method' with two macros: -- `transient--with-suspended-override' allows use of minibuffer. -- `transient--with-emergency-exit' arranges for the transient to - be exited in case of an error." - (transient--show) - (transient--with-emergency-exit :infix-read - (transient--with-suspended-override - (cl-call-next-method obj)))) - -(cl-defmethod transient-infix-read ((obj transient-infix)) - "Read a value while taking care of history. - -This method is suitable for a wide variety of infix commands, -including but not limited to inline arguments and variables. - -If you do not use this method for your own infix class, then -you should likely replicate a lot of the behavior of this -method. If you fail to do so, then users might not appreciate -the lack of history, for example. - -Only for very simple classes that toggle or cycle through a very -limited number of possible values should you replace this with a -simple method that does not handle history. (E.g., for a command -line switch the only possible values are \"use it\" and \"don't use -it\", in which case it is pointless to preserve history.)" - (with-slots (value multi-value always-read allow-empty choices) obj - (if (and value - (not multi-value) - (not always-read) - transient--prefix) - (oset obj value nil) - (let* ((enable-recursive-minibuffers t) - (reader (oref obj reader)) - (choices (if (functionp choices) (funcall choices) choices)) - (prompt (transient-prompt obj)) - (value (if multi-value (mapconcat #'identity value ",") value)) - (history-key (or (oref obj history-key) - (oref obj command))) - (transient--history (alist-get history-key transient-history)) - (transient--history (if (or (null value) - (eq value (car transient--history))) - transient--history - (cons value transient--history))) - (initial-input (and transient-read-with-initial-input - (car transient--history))) - (history (if initial-input - (cons 'transient--history 1) - 'transient--history)) - (value - (cond - (reader (funcall reader prompt initial-input history)) - (multi-value - (completing-read-multiple prompt choices nil nil - initial-input history)) - (choices - (completing-read prompt choices nil t initial-input history)) - ((read-string prompt initial-input history))))) - (cond ((and (equal value "") (not allow-empty)) - (setq value nil)) - ((and (equal value "\"\"") allow-empty) - (setq value ""))) - (when value - (when (and (bound-and-true-p ivy-mode) - (stringp (car transient--history))) - (set-text-properties 0 (length (car transient--history)) nil - (car transient--history))) - (setf (alist-get history-key transient-history) - (delete-dups transient--history))) - value)))) - -(cl-defmethod transient-infix-read ((obj transient-switch)) - "Toggle the switch on or off." - (if (oref obj value) nil (oref obj argument))) - -(cl-defmethod transient-infix-read ((obj transient-switches)) - "Cycle through the mutually exclusive switches. -The last value is \"don't use any of these switches\"." - (let ((choices (mapcar (apply-partially #'format (oref obj argument-format)) - (oref obj choices)))) - (if-let ((value (oref obj value))) - (cadr (member value choices)) - (car choices)))) - -(cl-defmethod transient-infix-read ((command symbol)) - "Elsewhere use the reader of the infix command COMMAND. -Use this if you want to share an infix's history with a regular -stand-alone command." - (if-let ((obj (transient--suffix-prototype command))) - (cl-letf (((symbol-function #'transient--show) #'ignore)) - (transient-infix-read obj)) - (error "Not a suffix command: `%s'" command))) - -;;;; Readers - -(defun transient-read-file (prompt _initial-input _history) - "Read a file." - (file-local-name (expand-file-name (read-file-name prompt)))) - -(defun transient-read-existing-file (prompt _initial-input _history) - "Read an existing file." - (file-local-name (expand-file-name (read-file-name prompt nil nil t)))) - -(defun transient-read-directory (prompt _initial-input _history) - "Read a directory." - (file-local-name (expand-file-name (read-directory-name prompt)))) - -(defun transient-read-existing-directory (prompt _initial-input _history) - "Read an existing directory." - (file-local-name (expand-file-name (read-directory-name prompt nil nil t)))) - -(defun transient-read-number-N0 (prompt initial-input history) - "Read a natural number (including zero) and return it as a string." - (transient--read-number-N prompt initial-input history t)) - -(defun transient-read-number-N+ (prompt initial-input history) - "Read a natural number (excluding zero) and return it as a string." - (transient--read-number-N prompt initial-input history nil)) - -(defun transient--read-number-N (prompt initial-input history include-zero) - (save-match-data - (cl-block nil - (while t - (let ((str (read-from-minibuffer prompt initial-input nil nil history))) - (when (or (string-equal str "") - (string-match-p (if include-zero - "\\`\\(0\\|[1-9][0-9]*\\)\\'" - "\\`[1-9][0-9]*\\'") - str)) - (cl-return str))) - (message "Please enter a natural number (%s zero)." - (if include-zero "including" "excluding")) - (sit-for 1))))) - -(defun transient-read-date (prompt default-time _history) - "Read a date using `org-read-date' (which see)." - (require 'org) - (when (fboundp 'org-read-date) - (org-read-date 'with-time nil nil prompt default-time))) - -;;;; Prompt - -(cl-defgeneric transient-prompt (obj) - "Return the prompt to be used to read infix object OBJ's value.") - -(cl-defmethod transient-prompt ((obj transient-infix)) - "Return the prompt to be used to read infix object OBJ's value. - -This implementation should be suitable for almost all infix -commands. - -If the value of OBJ's `prompt' slot is non-nil, then it must be -a string or a function. If it is a string, then use that. If -it is a function, then call that with OBJ as the only argument. -That function must return a string, which is then used as the -prompt. - -Otherwise, if the value of either the `argument' or `variable' -slot of OBJ is a string, then base the prompt on that (preferring -the former), appending either \"=\" (if it appears to be a -command-line option) or \": \". - -Finally fall through to using \"(BUG: no prompt): \" as the -prompt." - (if-let ((prompt (oref obj prompt))) - (let ((prompt (if (functionp prompt) - (funcall prompt obj) - prompt))) - (if (stringp prompt) - prompt - "(BUG: no prompt): ")) - (or (and-let* ((arg (and (slot-boundp obj 'argument) (oref obj argument)))) - (if (and (stringp arg) (string-suffix-p "=" arg)) - arg - (concat arg ": "))) - (and-let* ((var (and (slot-boundp obj 'variable) (oref obj variable)))) - (and (stringp var) - (concat var ": "))) - "(BUG: no prompt): "))) - -;;;; Set - -(cl-defgeneric transient-infix-set (obj value) - "Set the value of infix object OBJ to value.") - -(cl-defmethod transient-infix-set ((obj transient-infix) value) - "Set the value of infix object OBJ to value." - (oset obj value value)) - -(cl-defmethod transient-infix-set :after ((obj transient-argument) value) - "Unset incompatible infix arguments." - (when-let* ((value) - (val (transient-infix-value obj)) - (arg (if (slot-boundp obj 'argument) - (oref obj argument) - (oref obj argument-format))) - (spec (oref transient--prefix incompatible)) - (filter (lambda (x rule) - (and (member x rule) - (remove x rule)))) - (incomp (nconc - (cl-mapcan (apply-partially filter arg) spec) - (and (not (equal val arg)) - (cl-mapcan (apply-partially filter val) spec))))) - (dolist (obj transient--suffixes) - (when-let* (((cl-typep obj 'transient-argument)) - (val (transient-infix-value obj)) - (arg (if (slot-boundp obj 'argument) - (oref obj argument) - (oref obj argument-format))) - ((if (equal val arg) - (member arg incomp) - (or (member val incomp) - (member arg incomp))))) - (transient-infix-set obj nil))))) - -(cl-defgeneric transient-set-value (obj) - "Set the value of the transient prefix OBJ.") - -(cl-defmethod transient-set-value ((obj transient-prefix)) - (oset (oref obj prototype) value (transient-get-value)) - (transient--history-push obj)) - -;;;; Save - -(cl-defgeneric transient-save-value (obj) - "Save the value of the transient prefix OBJ.") - -(cl-defmethod transient-save-value ((obj transient-prefix)) - (let ((value (transient-get-value))) - (oset (oref obj prototype) value value) - (setf (alist-get (oref obj command) transient-values) value) - (transient-save-values)) - (transient--history-push obj)) - -;;;; Reset - -(cl-defgeneric transient-reset-value (obj) - "Clear the set and saved values of the transient prefix OBJ.") - -(cl-defmethod transient-reset-value ((obj transient-prefix)) - (let ((value (transient-default-value obj))) - (oset obj value value) - (oset (oref obj prototype) value value) - (setf (alist-get (oref obj command) transient-values nil 'remove) nil) - (transient-save-values)) - (transient--history-push obj) - (mapc #'transient-init-value transient--suffixes)) - -;;;; Get - -(defun transient-args (prefix) - "Return the value of the transient prefix command PREFIX. -If the current command was invoked from the transient prefix -command PREFIX, then return the active infix arguments. If -the current command was not invoked from PREFIX, then return -the set, saved or default value for PREFIX." - (cl-mapcan #'transient--get-wrapped-value (transient-suffixes prefix))) - -(defun transient-suffixes (prefix) - "Return the suffix objects of the transient prefix command PREFIX." - (if (eq transient-current-command prefix) - transient-current-suffixes - (let ((transient--prefix (transient--init-prefix prefix))) - (transient--flatten-suffixes - (transient--init-suffixes prefix))))) - -(defun transient-get-value () - (transient--with-emergency-exit :get-value - (cl-mapcan (lambda (obj) - (and (or (not (slot-exists-p obj 'unsavable)) - (not (oref obj unsavable))) - (transient--get-wrapped-value obj))) - transient-current-suffixes))) - -(defun transient--get-wrapped-value (obj) - (and-let* ((value (transient-infix-value obj))) - (pcase-exhaustive (and (slot-exists-p obj 'multi-value) - (oref obj multi-value)) - ('nil (list value)) - ((or 't 'rest) (list value)) - ('repeat value)))) - -(cl-defgeneric transient-infix-value (obj) - "Return the value of the suffix object OBJ. - -This function is called by `transient-args' (which see), meaning -this function is how the value of a transient is determined so -that the invoked suffix command can use it. - -Currently most values are strings, but that is not set in stone. -Nil is not a value, it means \"no value\". - -Usually only infixes have a value, but see the method for -`transient-suffix'.") - -(cl-defmethod transient-infix-value ((_ transient-suffix)) - "Return nil, which means \"no value\". - -Infix arguments contribute the transient's value while suffix -commands consume it. This function is called for suffixes anyway -because a command that both contributes to the transient's value -and also consumes it is not completely unconceivable. - -If you define such a command, then you must define a derived -class and implement this function because this default method -does nothing." nil) - -(cl-defmethod transient-infix-value ((obj transient-infix)) - "Return the value of OBJ's `value' slot." - (oref obj value)) - -(cl-defmethod transient-infix-value ((obj transient-option)) - "Return ARGUMENT and VALUE as a unit or nil if the latter is nil." - (and-let* ((value (oref obj value))) - (let ((arg (oref obj argument))) - (pcase-exhaustive (oref obj multi-value) - ('nil (concat arg value)) - ((or 't 'rest) (cons arg value)) - ('repeat (mapcar (lambda (v) (concat arg v)) value)))))) - -(cl-defmethod transient-infix-value ((_ transient-variable)) - "Return nil, which means \"no value\". - -Setting the value of a variable is done by, well, setting the -value of the variable. I.e., this is a side-effect and does -not contribute to the value of the transient." - nil) - -;;;; Utilities - -(defun transient-arg-value (arg args) - "Return the value of ARG as it appears in ARGS. - -For a switch return a boolean. For an option return the value as -a string, using the empty string for the empty value, or nil if -the option does not appear in ARGS." - (if (string-suffix-p "=" arg) - (save-match-data - (and-let* ((match (let ((case-fold-search nil) - (re (format "\\`%s\\(?:=\\(.+\\)\\)?\\'" - (substring arg 0 -1)))) - (cl-find-if (lambda (a) - (and (stringp a) - (string-match re a))) - args)))) - (or (match-string 1 match) ""))) - (and (member arg args) t))) - -(defun transient-scope () - "Return the value of the `scope' slot of the current prefix." - (oref (transient-prefix-object) scope)) - -;;; History - -(cl-defgeneric transient--history-key (obj) - "Return OBJ's history key. -If the value of the `history-key' slot is non-nil, then return -that. Otherwise return the value of the `command' slot." - (or (oref obj history-key) - (oref obj command))) - -(cl-defgeneric transient--history-push (obj) - "Push the current value of OBJ to its entry in `transient-history'." - (let ((key (transient--history-key obj))) - (setf (alist-get key transient-history) - (let ((args (transient-get-value))) - (cons args (delete args (alist-get key transient-history))))))) - -(cl-defgeneric transient--history-init (obj) - "Initialize OBJ's `history' slot. -This is the transient-wide history; many individual infixes also -have a history of their own.") - -(cl-defmethod transient--history-init ((obj transient-prefix)) - "Initialize OBJ's `history' slot from the variable `transient-history'." - (let ((val (oref obj value))) - (oset obj history - (cons val (delete val (alist-get (transient--history-key obj) - transient-history)))))) - -;;; Draw - -(defun transient--show-brief () - (let ((message-log-max nil)) - (if (and transient-show-popup (<= transient-show-popup 0)) - (message "%s-" (key-description (this-command-keys))) - (message - "%s- [%s] %s" - (key-description (this-command-keys)) - (oref transient--prefix command) - (mapconcat - #'identity - (sort - (cl-mapcan - (lambda (suffix) - (let ((key (kbd (oref suffix key)))) - ;; Don't list any common commands. - (and (not (memq (oref suffix command) - `(,(lookup-key transient-map key) - ,(lookup-key transient-sticky-map key) - ;; From transient-common-commands: - transient-set - transient-save - transient-history-prev - transient-history-next - transient-quit-one - transient-toggle-common - transient-set-level))) - (list (propertize (oref suffix key) 'face 'transient-key))))) - transient--suffixes) - #'string<) - (propertize "|" 'face 'transient-delimiter)))))) - -(defun transient--show () - (transient--timer-cancel) - (setq transient--showp t) - (let ((transient--shadowed-buffer (current-buffer)) - (buf (get-buffer-create transient--buffer-name)) - (focus nil)) - (with-current-buffer buf - (when transient-enable-popup-navigation - (setq focus (or (button-get (point) 'command) - (and (not (bobp)) - (button-get (1- (point)) 'command)) - (transient--heading-at-point)))) - (erase-buffer) - (run-hooks 'transient-setup-buffer-hook) - (when transient-force-fixed-pitch - (transient--force-fixed-pitch)) - (setq window-size-fixed t) - (when (bound-and-true-p tab-line-format) - (setq tab-line-format nil)) - (setq header-line-format nil) - (setq mode-line-format - (if (or (natnump transient-mode-line-format) - (eq transient-mode-line-format 'line)) - nil - transient-mode-line-format)) - (setq mode-line-buffer-identification - (symbol-name (oref transient--prefix command))) - (if transient-enable-popup-navigation - (setq-local cursor-in-non-selected-windows 'box) - (setq cursor-type nil)) - (setq display-line-numbers nil) - (setq show-trailing-whitespace nil) - (transient--insert-groups) - (when (or transient--helpp transient--editp) - (transient--insert-help)) - (when-let ((line (transient--separator-line))) - (insert line))) - (unless (window-live-p transient--window) - (setq transient--window - (display-buffer buf transient-display-buffer-action))) - (when (window-live-p transient--window) - (with-selected-window transient--window - (goto-char (point-min)) - (when transient-enable-popup-navigation - (transient--goto-button focus)) - (transient--fit-window-to-buffer transient--window))))) - -(defun transient--fit-window-to-buffer (window) - (let ((window-resize-pixelwise t) - (window-size-fixed nil)) - (if (eq (car (window-parameter window 'quit-restore)) 'other) - ;; Grow but never shrink window that previously displayed - ;; another buffer and is going to display that again. - (fit-window-to-buffer window nil (window-height window)) - (fit-window-to-buffer window nil 1)))) - -(defun transient--separator-line () - (and-let* ((height (cond ((not window-system) nil) - ((natnump transient-mode-line-format) - transient-mode-line-format) - ((eq transient-mode-line-format 'line) 1))) - (face `(,@(and (>= emacs-major-version 27) '(:extend t)) - :background - ,(or (face-foreground (transient--key-face nil 'non-suffix) - nil t) - "#gray60")))) - (concat (propertize "__" 'face face 'display `(space :height (,height))) - (propertize "\n" 'face face 'line-height t)))) - -(defmacro transient-with-shadowed-buffer (&rest body) - "While in the transient buffer, temporarly make the shadowed buffer current." - (declare (indent 0) (debug t)) - `(with-current-buffer (or transient--shadowed-buffer (current-buffer)) - ,@body)) - -(defun transient--insert-groups () - (let ((groups (cl-mapcan (lambda (group) - (let ((hide (oref group hide))) - (and (not (and (functionp hide) - (transient-with-shadowed-buffer - (funcall hide)))) - (list group)))) - transient--layout))) - (while-let ((group (pop groups))) - (transient--insert-group group) - (when groups - (insert ?\n))))) - -(defvar transient--max-group-level 1) - -(cl-defgeneric transient--insert-group (group) - "Format GROUP and its elements and insert the result.") - -(cl-defmethod transient--insert-group :around ((group transient-group)) - "Insert GROUP's description, if any." - (when-let ((desc (transient-with-shadowed-buffer - (transient-format-description group)))) - (insert desc ?\n)) - (let ((transient--max-group-level - (max (oref group level) transient--max-group-level)) - (transient--pending-group group)) - (cl-call-next-method group))) - -(cl-defmethod transient--insert-group ((group transient-row)) - (transient--maybe-pad-keys group) - (dolist (suffix (oref group suffixes)) - (insert (transient-with-shadowed-buffer (transient-format suffix))) - (insert " ")) - (insert ?\n)) - -(cl-defmethod transient--insert-group ((group transient-column)) - (transient--maybe-pad-keys group) - (dolist (suffix (oref group suffixes)) - (let ((str (transient-with-shadowed-buffer (transient-format suffix)))) - (insert str) - (unless (string-match-p ".\n\\'" str) - (insert ?\n))))) - -(cl-defmethod transient--insert-group ((group transient-columns)) - (let* ((columns - (mapcar - (lambda (column) - (transient--maybe-pad-keys column group) - (transient-with-shadowed-buffer - (let* ((transient--pending-group column) - (rows (mapcar #'transient-format (oref column suffixes)))) - (when-let ((desc (transient-format-description column))) - (push desc rows)) - (flatten-tree rows)))) - (oref group suffixes))) - (vp (or (oref transient--prefix variable-pitch) - transient-align-variable-pitch)) - (rs (apply #'max (mapcar #'length columns))) - (cs (length columns)) - (cw (mapcar (let ((widths (oref transient--prefix column-widths))) - (lambda (col) - (apply - #'max - (if-let ((min (pop widths))) - (if vp (* min (transient--pixel-width " ")) min) - 0) - (mapcar (if vp #'transient--pixel-width #'length) - col)))) - columns)) - (cc (transient--seq-reductions-from - (apply-partially #'+ (* 3 (if vp (transient--pixel-width " ") 1))) - cw 0))) - (if transient-force-single-column - (dotimes (c cs) - (dotimes (r rs) - (when-let ((cell (nth r (nth c columns)))) - (unless (equal cell "") - (insert cell ?\n)))) - (unless (= c (1- cs)) - (insert ?\n))) - (dotimes (r rs) - (dotimes (c cs) - (if vp - (progn - (when-let ((cell (nth r (nth c columns)))) - (insert cell)) - (if (= c (1- cs)) - (insert ?\n) - (insert (propertize " " 'display - `(space :align-to (,(nth (1+ c) cc))))))) - (when (> c 0) - (insert (make-string (max 1 (- (nth c cc) (current-column))) - ?\s))) - (when-let ((cell (nth r (nth c columns)))) - (insert cell)) - (when (= c (1- cs)) - (insert ?\n)))))))) - -(cl-defmethod transient--insert-group ((group transient-subgroups)) - (let* ((subgroups (oref group suffixes)) - (n (length subgroups))) - (dotimes (s n) - (let ((subgroup (nth s subgroups))) - (transient--maybe-pad-keys subgroup group) - (transient--insert-group subgroup) - (when (< s (1- n)) - (insert ?\n)))))) - -(cl-defgeneric transient-format (obj) - "Format and return OBJ for display. - -When this function is called, then the current buffer is some -temporary buffer. If you need the buffer from which the prefix -command was invoked to be current, then do so by temporarily -making `transient--original-buffer' current.") - -(cl-defmethod transient-format ((arg string)) - "Return the string ARG after applying the `transient-heading' face." - (propertize arg 'face 'transient-heading)) - -(cl-defmethod transient-format ((_ null)) - "Return a string containing just the newline character." - "\n") - -(cl-defmethod transient-format ((arg integer)) - "Return a string containing just the ARG character." - (char-to-string arg)) - -(cl-defmethod transient-format :around ((obj transient-suffix)) - "Add additional formatting if appropriate. -When reading user input for this infix, then highlight it. -When edit-mode is enabled, then prepend the level information. -When `transient-enable-popup-navigation' is non-nil then format -as a button." - (let ((str (cl-call-next-method obj))) - (when (and (cl-typep obj 'transient-infix) - (eq (oref obj command) this-original-command) - (active-minibuffer-window)) - (setq str (transient--add-face str 'transient-active-infix))) - (when transient--editp - (setq str (concat (let ((level (oref obj level))) - (propertize (format " %s " level) - 'face (if (transient--use-level-p level t) - 'transient-enabled-suffix - 'transient-disabled-suffix))) - str))) - (when (and transient-enable-popup-navigation - (slot-boundp obj 'command)) - (setq str (make-text-button str nil - 'type 'transient - 'command (oref obj command)))) - str)) - -(cl-defmethod transient-format ((obj transient-infix)) - "Return a string generated using OBJ's `format'. -%k is formatted using `transient-format-key'. -%d is formatted using `transient-format-description'. -%v is formatted using `transient-format-value'." - (format-spec (oref obj format) - `((?k . ,(transient-format-key obj)) - (?d . ,(transient-format-description obj)) - (?v . ,(transient-format-value obj))))) - -(cl-defmethod transient-format ((obj transient-suffix)) - "Return a string generated using OBJ's `format'. -%k is formatted using `transient-format-key'. -%d is formatted using `transient-format-description'." - (format-spec (oref obj format) - `((?k . ,(transient-format-key obj)) - (?d . ,(transient-format-description obj))))) - -(cl-defgeneric transient-format-key (obj) - "Format OBJ's `key' for display and return the result.") - -(cl-defmethod transient-format-key :around ((obj transient-suffix)) - "Add `transient-inapt-suffix' face if suffix is inapt." - (let ((str (cl-call-next-method))) - (if (oref obj inapt) - (transient--add-face str 'transient-inapt-suffix) - str))) - -(cl-defmethod transient-format-key ((obj transient-suffix)) - "Format OBJ's `key' for display and return the result." - (let ((key (if (slot-boundp obj 'key) (oref obj key) "")) - (cmd (and (slot-boundp obj 'command) (oref obj command)))) - (when-let ((width (oref transient--pending-group pad-keys))) - (setq key (truncate-string-to-width key width nil ?\s))) - (if transient--redisplay-key - (let ((len (length transient--redisplay-key)) - (seq (cl-coerce (edmacro-parse-keys key t) 'list))) - (cond - ((member (seq-take seq len) - (list transient--redisplay-key - (thread-last transient--redisplay-key - (cl-substitute ?- 'kp-subtract) - (cl-substitute ?= 'kp-equal) - (cl-substitute ?+ 'kp-add)))) - (let ((pre (key-description (vconcat (seq-take seq len)))) - (suf (key-description (vconcat (seq-drop seq len))))) - (setq pre (string-replace "RET" "C-m" pre)) - (setq pre (string-replace "TAB" "C-i" pre)) - (setq suf (string-replace "RET" "C-m" suf)) - (setq suf (string-replace "TAB" "C-i" suf)) - ;; We use e.g., "-k" instead of the more correct "- k", - ;; because the former is prettier. If we did that in - ;; the definition, then we want to drop the space that - ;; is reinserted above. False-positives are possible - ;; for silly bindings like "-C-c C-c". - (unless (string-search " " key) - (setq pre (string-replace " " "" pre)) - (setq suf (string-replace " " "" suf))) - (concat (propertize pre 'face 'transient-unreachable-key) - (and (string-prefix-p (concat pre " ") key) " ") - (propertize suf 'face (transient--key-face cmd)) - (save-excursion - (and (string-match " +\\'" key) - (propertize (match-string 0 key) - 'face 'fixed-pitch)))))) - ((transient--lookup-key transient-sticky-map (kbd key)) - (propertize key 'face (transient--key-face cmd))) - (t - (propertize key 'face 'transient-unreachable-key)))) - (propertize key 'face (transient--key-face cmd))))) - -(cl-defmethod transient-format-key :around ((obj transient-argument)) - "Handle `transient-highlight-mismatched-keys'." - (let ((key (cl-call-next-method obj))) - (cond - ((not transient-highlight-mismatched-keys) key) - ((not (slot-boundp obj 'shortarg)) - (transient--add-face key 'transient-nonstandard-key)) - ((not (string-equal key (oref obj shortarg))) - (transient--add-face key 'transient-mismatched-key)) - (key)))) - -(cl-defgeneric transient-format-description (obj) - "Format OBJ's `description' for display and return the result.") - -(cl-defmethod transient-format-description ((obj transient-child)) - "The `description' slot may be a function, in which case that is -called inside the correct buffer (see `transient--insert-group') -and its value is returned to the caller." - (and-let* ((desc (oref obj description)) - (desc (if (functionp desc) - (if (= (car (transient--func-arity desc)) 1) - (funcall desc obj) - (funcall desc)) - desc))) - (if-let* ((face (transient--get-face obj 'face))) - (transient--add-face desc face t) - desc))) - -(cl-defmethod transient-format-description ((obj transient-group)) - "Format the description by calling the next method. If the result -doesn't use the `face' property at all, then apply the face -`transient-heading' to the complete string." - (and-let* ((desc (cl-call-next-method obj))) - (cond ((oref obj inapt) - (propertize desc 'face 'transient-inapt-suffix)) - ((text-property-not-all 0 (length desc) 'face nil desc) - desc) - ((propertize desc 'face 'transient-heading))))) - -(cl-defmethod transient-format-description :around ((obj transient-suffix)) - "Format the description by calling the next method. If the result -is nil, then use \"(BUG: no description)\" as the description. -If the OBJ's `key' is currently unreachable, then apply the face -`transient-unreachable' to the complete string." - (let ((desc (or (cl-call-next-method obj) - (and (slot-boundp transient--prefix 'suffix-description) - (funcall (oref transient--prefix suffix-description) - obj)) - (propertize "(BUG: no description)" 'face 'error)))) - (when (if transient--all-levels-p - (> (oref obj level) transient--default-prefix-level) - (and transient-highlight-higher-levels - (> (max (oref obj level) transient--max-group-level) - transient--default-prefix-level))) - (setq desc (transient--add-face desc 'transient-higher-level))) - (when-let ((inapt-face (and (oref obj inapt) - (transient--get-face obj 'inapt-face)))) - (setq desc (transient--add-face desc inapt-face))) - (when (and (slot-boundp obj 'key) - (transient--key-unreachable-p obj)) - (setq desc (transient--add-face desc 'transient-unreachable))) - desc)) - -(cl-defgeneric transient-format-value (obj) - "Format OBJ's value for display and return the result.") - -(cl-defmethod transient-format-value ((obj transient-suffix)) - (propertize (oref obj argument) - 'face (if (oref obj value) - 'transient-argument - 'transient-inactive-argument))) - -(cl-defmethod transient-format-value ((obj transient-option)) - (let ((argument (oref obj argument))) - (if-let ((value (oref obj value))) - (pcase-exhaustive (oref obj multi-value) - ('nil - (concat (propertize argument 'face 'transient-argument) - (propertize value 'face 'transient-value))) - ((or 't 'rest) - (concat (propertize (if (string-suffix-p " " argument) - argument - (concat argument " ")) - 'face 'transient-argument) - (propertize (mapconcat #'prin1-to-string value " ") - 'face 'transient-value))) - ('repeat - (mapconcat (lambda (value) - (concat (propertize argument 'face 'transient-argument) - (propertize value 'face 'transient-value))) - value " "))) - (propertize argument 'face 'transient-inactive-argument)))) - -(cl-defmethod transient-format-value ((obj transient-switches)) - (with-slots (value argument-format choices) obj - (format (propertize argument-format - 'face (if value - 'transient-argument - 'transient-inactive-argument)) - (format - (propertize "[%s]" 'face 'transient-delimiter) - (mapconcat - (lambda (choice) - (propertize choice 'face - (if (equal (format argument-format choice) value) - 'transient-value - 'transient-inactive-value))) - choices - (propertize "|" 'face 'transient-delimiter)))))) - -(defun transient--add-face (string face &optional append beg end) - (let ((str (copy-sequence string))) - (add-face-text-property (or beg 0) (or end (length str)) face append str) - str)) - -(defun transient--get-face (obj slot) - (and-let* (((slot-exists-p obj slot)) - ((slot-boundp obj slot)) - (face (slot-value obj slot))) - (if (and (not (facep face)) - (functionp face)) - (let ((transient--pending-suffix obj)) - (if (= (car (transient--func-arity face)) 1) - (funcall face obj) - (funcall face))) - face))) - -(defun transient--key-face (&optional cmd enforce-type) - (or (and transient-semantic-coloring - (not transient--helpp) - (not transient--editp) - (or (and cmd (get cmd 'transient-face)) - (get (transient--get-pre-command cmd enforce-type) - 'transient-face))) - (if cmd 'transient-key 'transient-key-noop))) - -(defun transient--key-unreachable-p (obj) - (and transient--redisplay-key - (let ((key (oref obj key))) - (not (or (equal (seq-take (cl-coerce (edmacro-parse-keys key t) 'list) - (length transient--redisplay-key)) - transient--redisplay-key) - (transient--lookup-key transient-sticky-map (kbd key))))))) - -(defun transient--lookup-key (keymap key) - (let ((val (lookup-key keymap key))) - (and val (not (integerp val)) val))) - -(defun transient--maybe-pad-keys (group &optional parent) - (when-let ((pad (or (oref group pad-keys) - (and parent (oref parent pad-keys))))) - (oset group pad-keys - (apply #'max (cons (if (integerp pad) pad 0) - (seq-keep (lambda (suffix) - (and (eieio-object-p suffix) - (slot-boundp suffix 'key) - (length (oref suffix key)))) - (oref group suffixes))))))) - -(defun transient--pixel-width (string) - (save-window-excursion - (with-temp-buffer - (insert string) - (set-window-dedicated-p nil nil) - (set-window-buffer nil (current-buffer)) - (car (window-text-pixel-size - nil (line-beginning-position) (point)))))) - -(defun transient-command-summary-or-name (obj) - "Return the summary or name of the command represented by OBJ. - -If the command has a doc-string, then return the first line of -that, else its name. - -Intended to be temporarily used as the `:suffix-description' of -a prefix command, while porting a regular keymap to a transient." - (let ((command (oref obj command))) - (if-let ((doc (documentation command))) - (propertize (car (split-string doc "\n")) 'face 'font-lock-doc-face) - (propertize (symbol-name command) 'face 'font-lock-function-name-face)))) - -;;; Help - -(cl-defgeneric transient-show-help (obj) - "Show documentation for the command represented by OBJ.") - -(cl-defmethod transient-show-help ((obj transient-prefix)) - "Call `show-help' if non-nil, else show `info-manual', -if non-nil, else show the `man-page' if non-nil, else use -`describe-function'." - (with-slots (show-help info-manual man-page command) obj - (cond (show-help (funcall show-help obj)) - (info-manual (transient--show-manual info-manual)) - (man-page (transient--show-manpage man-page)) - ((transient--describe-function command))))) - -(cl-defmethod transient-show-help ((obj transient-suffix)) - "Call `show-help' if non-nil, else use `describe-function'. -Also used to dispatch showing documentation for the current -prefix. If the suffix is a sub-prefix, then also call the -prefix method." - (cond - ((eq this-command 'transient-help) - (transient-show-help transient--prefix)) - ((let ((prefix (get (oref obj command) - 'transient--prefix))) - (and prefix (not (eq (oref transient--prefix command) this-command)) - (prog1 t (transient-show-help prefix))))) - ((if-let ((show-help (oref obj show-help))) - (funcall show-help obj) - (transient--describe-function this-command))))) - -(cl-defmethod transient-show-help ((obj transient-infix)) - "Call `show-help' if non-nil, else show the `man-page' -if non-nil, else use `describe-function'. When showing the -manpage, then try to jump to the correct location." - (if-let ((show-help (oref obj show-help))) - (funcall show-help obj) - (if-let ((man-page (oref transient--prefix man-page)) - (argument (and (slot-boundp obj 'argument) - (oref obj argument)))) - (transient--show-manpage man-page argument) - (transient--describe-function this-command)))) - -;; `cl-generic-generalizers' doesn't support `command' et al. -(cl-defmethod transient-show-help (cmd) - "Show the command doc-string." - (transient--describe-function cmd)) - -(defun transient--describe-function (fn) - (describe-function fn) - (unless (derived-mode-p 'help-mode) - (when-let* ((buf (get-buffer "*Help*")) - (win (or (and buf (get-buffer-window buf)) - (cl-find-if (lambda (win) - (with-current-buffer (window-buffer win) - (derived-mode-p 'help-mode))) - (window-list))))) - (select-window win)))) - -(defun transient--show-manual (manual) - (info manual)) - -(defun transient--show-manpage (manpage &optional argument) - (require 'man) - (let* ((Man-notify-method 'meek) - (buf (Man-getpage-in-background manpage)) - (proc (get-buffer-process buf))) - (while (and proc (eq (process-status proc) 'run)) - (accept-process-output proc)) - (switch-to-buffer buf) - (when argument - (transient--goto-argument-description argument)))) - -(defun transient--goto-argument-description (arg) - (goto-char (point-min)) - (let ((case-fold-search nil) - ;; This matches preceding/proceeding options. Options - ;; such as "-a", "-S[<keyid>]", and "--grep=<pattern>" - ;; are matched by this regex without the shy group. - ;; The ". " in the shy group is for options such as - ;; "-m parent-number", and the "-[^[:space:]]+ " is - ;; for options such as "--mainline parent-number" - (others "-\\(?:. \\|-[^[:space:]]+ \\)?[^[:space:]]+")) - (when (re-search-forward - (if (equal arg "--") - ;; Special case. - "^[\t\s]+\\(--\\(?: \\|$\\)\\|\\[--\\]\\)" - ;; Should start with whitespace and may have - ;; any number of options before and/or after. - (format - "^[\t\s]+\\(?:%s, \\)*?\\(?1:%s\\)%s\\(?:, %s\\)*$" - others - ;; Options don't necessarily end in an "=" - ;; (e.g., "--gpg-sign[=<keyid>]") - (string-remove-suffix "=" arg) - ;; Simple options don't end in an "=". Splitting this - ;; into 2 cases should make getting false positives - ;; less likely. - (if (string-suffix-p "=" arg) - ;; "[^[:space:]]*[^.[:space:]]" matches the option - ;; value, which is usually after the option name - ;; and either '=' or '[='. The value can't end in - ;; a period, as that means it's being used at the - ;; end of a sentence. The space is for options - ;; such as '--mainline parent-number'. - "\\(?: \\|\\[?=\\)[^[:space:]]*[^.[:space:]]" - ;; Either this doesn't match anything (e.g., "-a"), - ;; or the option is followed by a value delimited - ;; by a "[", "<", or ":". A space might appear - ;; before this value, as in "-f <file>". The - ;; space alternative is for options such as - ;; "-m parent-number". - "\\(?:\\(?: \\| ?[\\[<:]\\)[^[:space:]]*[^.[:space:]]\\)?") - others)) - nil t) - (goto-char (match-beginning 1))))) - -(defun transient--insert-help () - (unless (looking-back "\n\n" 2) - (insert "\n")) - (when transient--helpp - (insert - (format (propertize "\ -Type a %s to show help for that suffix command, or %s to show manual. -Type %s to exit help.\n" - 'face 'transient-heading) - (propertize "<KEY>" 'face 'transient-key) - (propertize "?" 'face 'transient-key) - (propertize "C-g" 'face 'transient-key)))) - (when transient--editp - (unless transient--helpp - (insert - (format (propertize "\ -Type a %s to set level for that suffix command. -Type %s to set what levels are available for this prefix command.\n" - 'face 'transient-heading) - (propertize "<KEY>" 'face 'transient-key) - (propertize "C-x l" 'face 'transient-key)))) - (with-slots (level) transient--prefix - (insert - (format (propertize " -Suffixes on levels %s are available. -Suffixes on levels %s and %s are unavailable.\n" - 'face 'transient-heading) - (propertize (format "1-%s" level) - 'face 'transient-enabled-suffix) - (propertize " 0 " - 'face 'transient-disabled-suffix) - (propertize (format ">=%s" (1+ level)) - 'face 'transient-disabled-suffix)))))) - -;;; Popup Navigation - -(defun transient-scroll-up (&optional arg) - "Scroll text of transient popup window upward ARG lines. -If ARG is nil scroll near full screen. This is a wrapper -around `scroll-up-command' (which see)." - (interactive "^P") - (with-selected-window transient--window - (scroll-up-command arg))) - -(defun transient-scroll-down (&optional arg) - "Scroll text of transient popup window down ARG lines. -If ARG is nil scroll near full screen. This is a wrapper -around `scroll-down-command' (which see)." - (interactive "^P") - (with-selected-window transient--window - (scroll-down-command arg))) - -(defun transient-backward-button (n) - "Move to the previous button in the transient popup buffer. -See `backward-button' for information about N." - (interactive "p") - (with-selected-window transient--window - (backward-button n t))) - -(defun transient-forward-button (n) - "Move to the next button in the transient popup buffer. -See `forward-button' for information about N." - (interactive "p") - (with-selected-window transient--window - (forward-button n t))) - -(define-button-type 'transient - 'face nil - 'keymap transient-button-map) - -(defun transient--goto-button (command) - (cond - ((stringp command) - (when (re-search-forward (concat "^" (regexp-quote command)) nil t) - (goto-char (match-beginning 0)))) - (command - (while (and (ignore-errors (forward-button 1)) - (not (eq (button-get (button-at (point)) 'command) command)))) - (unless (eq (button-get (button-at (point)) 'command) command) - (goto-char (point-min)) - (forward-button 1))))) - -(defun transient--heading-at-point () - (and (eq (get-text-property (point) 'face) 'transient-heading) - (let ((beg (line-beginning-position))) - (buffer-substring-no-properties - beg (next-single-property-change - beg 'face nil (line-end-position)))))) - -;;; Compatibility -;;;; Popup Isearch - -(defvar-keymap transient--isearch-mode-map - :parent isearch-mode-map - "<remap> <isearch-exit>" #'transient-isearch-exit - "<remap> <isearch-cancel>" #'transient-isearch-cancel - "<remap> <isearch-abort>" #'transient-isearch-abort) - -(defun transient-isearch-backward (&optional regexp-p) - "Do incremental search backward. -With a prefix argument, do an incremental regular expression -search instead." - (interactive "P") - (transient--isearch-setup) - (let ((isearch-mode-map transient--isearch-mode-map)) - (isearch-mode nil regexp-p))) - -(defun transient-isearch-forward (&optional regexp-p) - "Do incremental search forward. -With a prefix argument, do an incremental regular expression -search instead." - (interactive "P") - (transient--isearch-setup) - (let ((isearch-mode-map transient--isearch-mode-map)) - (isearch-mode t regexp-p))) - -(defun transient-isearch-exit () - "Like `isearch-exit' but adapted for `transient'." - (interactive) - (isearch-exit) - (transient--isearch-exit)) - -(defun transient-isearch-cancel () - "Like `isearch-cancel' but adapted for `transient'." - (interactive) - (condition-case nil (isearch-cancel) (quit)) - (transient--isearch-exit)) - -(defun transient-isearch-abort () - "Like `isearch-abort' but adapted for `transient'." - (interactive) - (let ((around (lambda (fn) - (condition-case nil (funcall fn) (quit)) - (transient--isearch-exit)))) - (advice-add 'isearch-cancel :around around) - (unwind-protect - (isearch-abort) - (advice-remove 'isearch-cancel around)))) - -(defun transient--isearch-setup () - (select-window transient--window) - (transient--suspend-override t)) - -(defun transient--isearch-exit () - (select-window transient--original-window) - (transient--resume-override)) - -;;;; Edebug - -(defun transient--edebug-command-p () - (and (bound-and-true-p edebug-active) - (or (memq this-command '(top-level abort-recursive-edit)) - (string-prefix-p "edebug" (symbol-name this-command))))) - -;;;; Miscellaneous - -(cl-pushnew (list nil (concat "^\\s-*(" - (eval-when-compile - (regexp-opt - '("transient-define-prefix" - "transient-define-suffix" - "transient-define-infix" - "transient-define-argument") - t)) - "\\s-+\\(" lisp-mode-symbol-regexp "\\)") - 2) - lisp-imenu-generic-expression :test #'equal) - -(declare-function which-key-mode "which-key" (&optional arg)) - -(defun transient--suspend-which-key-mode () - (when (bound-and-true-p which-key-mode) - (which-key-mode -1) - (add-hook 'transient-exit-hook #'transient--resume-which-key-mode))) - -(defun transient--resume-which-key-mode () - (unless transient--prefix - (which-key-mode 1) - (remove-hook 'transient-exit-hook #'transient--resume-which-key-mode))) - -(defun transient-bind-q-to-quit () - "Modify some keymaps to bind \"q\" to the appropriate quit command. - -\"C-g\" is the default binding for such commands now, but Transient's -predecessor Magit-Popup used \"q\" instead. If you would like to get -that binding back, then call this function in your init file like so: - - (with-eval-after-load \\='transient - (transient-bind-q-to-quit)) - -Individual transients may already bind \"q\" to something else -and such a binding would shadow the quit binding. If that is the -case then \"Q\" is bound to whatever \"q\" would have been bound -to by setting `transient-substitute-key-function' to a function -that does that. Of course \"Q\" may already be bound to something -else, so that function binds \"M-q\" to that command instead. -Of course \"M-q\" may already be bound to something else, but -we stop there." - (keymap-set transient-base-map "q" #'transient-quit-one) - (keymap-set transient-sticky-map "q" #'transient-quit-seq) - (setq transient-substitute-key-function - #'transient-rebind-quit-commands)) - -(defun transient-rebind-quit-commands (obj) - "See `transient-bind-q-to-quit'." - (let ((key (oref obj key))) - (cond ((string-equal key "q") "Q") - ((string-equal key "Q") "M-q") - (key)))) - -(defun transient--force-fixed-pitch () - (require 'face-remap) - (face-remap-reset-base 'default) - (face-remap-add-relative 'default 'fixed-pitch)) - -(defun transient--func-arity (fn) - (func-arity (advice--cd*r (if (symbolp fn) (symbol-function fn) fn)))) - -(defun transient--seq-reductions-from (function sequence initial-value) - (let ((acc (list initial-value))) - (seq-doseq (elt sequence) - (push (funcall function (car acc) elt) acc)) - (nreverse acc))) - -;;; Font-Lock - -(defconst transient-font-lock-keywords - (eval-when-compile - `((,(concat "(" - (regexp-opt (list "transient-define-prefix" - "transient-define-infix" - "transient-define-argument" - "transient-define-suffix") - t) - "\\_>[ \t'(]*" - "\\(\\(?:\\sw\\|\\s_\\)+\\)?") - (1 'font-lock-keyword-face) - (2 'font-lock-function-name-face nil t))))) - -(font-lock-add-keywords 'emacs-lisp-mode transient-font-lock-keywords) - -;;; Auxiliary Classes -;;;; `transient-lisp-variable' - -(defclass transient-lisp-variable (transient-variable) - ((reader :initform #'transient-lisp-variable--reader) - (always-read :initform t) - (set-value :initarg :set-value :initform #'set)) - "[Experimental] Class used for Lisp variables.") - -(cl-defmethod transient-init-value ((obj transient-lisp-variable)) - (oset obj value (symbol-value (oref obj variable)))) - -(cl-defmethod transient-infix-set ((obj transient-lisp-variable) value) - (funcall (oref obj set-value) - (oref obj variable) - (oset obj value value))) - -(cl-defmethod transient-format-description ((obj transient-lisp-variable)) - (or (cl-call-next-method obj) - (symbol-name (oref obj variable)))) - -(cl-defmethod transient-format-value ((obj transient-lisp-variable)) - (propertize (prin1-to-string (oref obj value)) - 'face 'transient-value)) - -(cl-defmethod transient-prompt ((obj transient-lisp-variable)) - (if (and (slot-boundp obj 'prompt) - (oref obj prompt)) - (cl-call-next-method obj) - (format "Set %s: " (oref obj variable)))) - -(defun transient-lisp-variable--reader (prompt initial-input _history) - (read--expression prompt initial-input)) - -;;; _ -(provide 'transient) -;; Local Variables: -;; indent-tabs-mode: nil -;; checkdoc-symbol-words: ("command-line" "edit-mode" "help-mode") -;; End: -;;; transient.el ends here diff --git a/emacs/elpa/transient-20240509.1849/transient.elc b/emacs/elpa/transient-20240509.1849/transient.elc Binary files differ. diff --git a/emacs/elpa/transient-20240509.1849/dir b/emacs/elpa/transient-20240525.1118/dir diff --git a/emacs/elpa/transient-20240509.1849/gpl.info b/emacs/elpa/transient-20240525.1118/gpl.info diff --git a/emacs/elpa/transient-20240509.1849/transient-autoloads.el b/emacs/elpa/transient-20240525.1118/transient-autoloads.el diff --git a/emacs/elpa/transient-20240525.1118/transient-pkg.el b/emacs/elpa/transient-20240525.1118/transient-pkg.el @@ -0,0 +1,16 @@ +(define-package "transient" "20240525.1118" "Transient commands" + '((emacs "26.1") + (compat "29.1.4.4") + (seq "2.24")) + :commit "99a68578df4d938598d0fcbb8401e2fe35be6132" :authors + '(("Jonas Bernoulli" . "emacs.transient@jonas.bernoulli.dev")) + :maintainers + '(("Jonas Bernoulli" . "emacs.transient@jonas.bernoulli.dev")) + :maintainer + '("Jonas Bernoulli" . "emacs.transient@jonas.bernoulli.dev") + :keywords + '("extensions") + :url "https://github.com/magit/transient") +;; Local Variables: +;; no-byte-compile: t +;; End: diff --git a/emacs/elpa/transient-20240525.1118/transient.el b/emacs/elpa/transient-20240525.1118/transient.el @@ -0,0 +1,4508 @@ +;;; transient.el --- Transient commands -*- lexical-binding:t -*- + +;; Copyright (C) 2018-2024 Free Software Foundation, Inc. + +;; Author: Jonas Bernoulli <emacs.transient@jonas.bernoulli.dev> +;; Homepage: https://github.com/magit/transient +;; Keywords: extensions + +;; Package-Version: 0.6.0 +;; Package-Requires: ((emacs "26.1") (compat "29.1.4.4") (seq "2.24")) + +;; SPDX-License-Identifier: GPL-3.0-or-later + +;; This file is part of GNU Emacs. + +;; GNU Emacs 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. +;; +;; GNU Emacs 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 <https://www.gnu.org/licenses/>. + +;;; Commentary: + +;; Transient is the library used to implement the keyboard-driven menus +;; in Magit. It is distributed as a separate package, so that it can be +;; used to implement similar menus in other packages. + +;;; Code: + +(require 'cl-lib) +(require 'compat) +(require 'eieio) +(require 'edmacro) +(require 'format-spec) + +(eval-and-compile + (when (and (featurep' seq) + (not (fboundp 'seq-keep))) + (unload-feature 'seq 'force))) +(require 'seq) +(unless (fboundp 'seq-keep) + (display-warning 'transient (substitute-command-keys "\ +Transient requires `seq' >= 2.24, +but due to bad defaults, Emacs' package manager, refuses to +upgrade this and other built-in packages to higher releases +from GNU Elpa, when a package specifies that this is needed. + +To fix this, you have to add this to your init file: + + (setq package-install-upgrade-built-in t) + +Then evaluate that expression by placing the cursor after it +and typing \\[eval-last-sexp]. + +Once you have done that, you have to explicitly upgrade `seq': + + \\[package-upgrade] seq \\`RET' + +Then you also must make sure the updated version is loaded, +by evaluating this form: + + (progn (unload-feature 'seq t) (require 'seq)) + +Until you do this, you will get random errors about `seq-keep' +being undefined while using Transient. + +If you don't use the `package' package manager but still get +this warning, then your chosen package manager likely has a +similar defect.") :emergency)) + +(eval-when-compile (require 'subr-x)) + +(declare-function info "info" (&optional file-or-node buffer)) +(declare-function Man-find-section "man" (section)) +(declare-function Man-next-section "man" (n)) +(declare-function Man-getpage-in-background "man" (topic)) + +(defvar Man-notify-method) +(defvar pp-default-function) ; since Emacs 29.1 + +(defmacro static-if (condition then-form &rest else-forms) + "A conditional compilation macro. +Evaluate CONDITION at macro-expansion time. If it is non-nil, +expand the macro to THEN-FORM. Otherwise expand it to ELSE-FORMS +enclosed in a `progn' form. ELSE-FORMS may be empty." + (declare (indent 2) + (debug (sexp sexp &rest sexp))) + (if (eval condition lexical-binding) + then-form + (cons 'progn else-forms))) + +(defmacro transient--with-emergency-exit (id &rest body) + (declare (indent defun)) + (unless (keywordp id) + (setq body (cons id body)) + (setq id nil)) + `(condition-case err + (let ((debugger #'transient--exit-and-debug)) + ,(macroexp-progn body)) + ((debug error) + (transient--emergency-exit ,id) + (signal (car err) (cdr err))))) + +(defun transient--exit-and-debug (&rest args) + (transient--emergency-exit :debugger) + (apply #'debug args)) + +;;; Options + +(defgroup transient nil + "Transient commands." + :group 'extensions) + +(defcustom transient-show-popup t + "Whether to show the current transient in a popup buffer. +\\<transient-map> +- If t, then show the popup as soon as a transient prefix command + is invoked. + +- If nil, then do not show the popup unless the user explicitly + requests it, by pressing \\[transient-show] or a prefix key. + +- If a number, then delay displaying the popup and instead show + a brief one-line summary. If zero or negative, then suppress + even showing that summary and display the pressed key only. + + Show the popup when the user explicitly requests it by pressing + \\[transient-show] or a prefix key. Unless zero, then also show the popup + after that many seconds of inactivity (using the absolute value)." + :package-version '(transient . "0.1.0") + :group 'transient + :type '(choice (const :tag "instantly" t) + (const :tag "on demand" nil) + (const :tag "on demand (no summary)" 0) + (number :tag "after delay" 1))) + +(defcustom transient-enable-popup-navigation t + "Whether navigation commands are enabled in the transient popup. + +While a transient is active the transient popup buffer is not the +current buffer, making it necessary to use dedicated commands to +act on that buffer itself. If this is non-nil, then the following +bindings are available: + +\\<transient-popup-navigation-map>\ +- \\[transient-backward-button] moves the cursor to the previous suffix. +- \\[transient-forward-button] moves the cursor to the next suffix. +- \\[transient-push-button] invokes the suffix the cursor is on. +\\<transient-button-map>\ +- \\`<mouse-1>' and \\`<mouse-2>' invoke the clicked on suffix. +\\<transient-popup-navigation-map>\ +- \\[transient-isearch-backward]\ + and \\[transient-isearch-forward] start isearch in the popup buffer. + +\\`<mouse-1>' and \\`<mouse-2>' are bound in `transient-push-button'. +All other bindings are in `transient-popup-navigation-map'. + +By default \\`M-RET' is bound to `transient-push-button', instead of +\\`RET', because if a transient allows the invocation of non-suffixes +then it is likely that you would want \\`RET' to do what it would do +if no transient were active." + :package-version '(transient . "0.4.0") + :group 'transient + :type 'boolean) + +(defcustom transient-display-buffer-action + '(display-buffer-in-side-window + (side . bottom) + (dedicated . t) + (inhibit-same-window . t) + (window-parameters (no-other-window . t))) + "The action used to display the transient popup buffer. + +The transient popup buffer is displayed in a window using + + (display-buffer BUFFER transient-display-buffer-action) + +The value of this option has the form (FUNCTION . ALIST), +where FUNCTION is a function or a list of functions. Each such +function should accept two arguments: a buffer to display and an +alist of the same form as ALIST. See info node `(elisp)Choosing +Window' for details. + +The default is: + + (display-buffer-in-side-window + (side . bottom) + (dedicated . t) + (inhibit-same-window . t) + (window-parameters (no-other-window . t))) + +This displays the window at the bottom of the selected frame. +Another useful FUNCTION is `display-buffer-below-selected', which +is what `magit-popup' used by default. For more alternatives see +info node `(elisp)Display Action Functions' and info node +`(elisp)Buffer Display Action Alists'. + +Note that the buffer that was current before the transient buffer +is shown should remain the current buffer. Many suffix commands +act on the thing at point, if appropriate, and if the transient +buffer became the current buffer, then that would change what is +at point. To that effect `inhibit-same-window' ensures that the +selected window is not used to show the transient buffer. + +It may be possible to display the window in another frame, but +whether that works in practice depends on the window-manager. +If the window manager selects the new window (Emacs frame), +then that unfortunately changes which buffer is current. + +If you change the value of this option, then you might also +want to change the value of `transient-mode-line-format'." + :package-version '(transient . "0.3.0") + :group 'transient + :type '(cons (choice function (repeat :tag "Functions" function)) + alist)) + +(defcustom transient-mode-line-format 'line + "The mode-line format for the transient popup buffer. + +If nil, then the buffer has no mode-line. If the buffer is not +displayed right above the echo area, then this probably is not +a good value. + +If `line' (the default) or a natural number, then the buffer +has no mode-line, but a line is drawn is drawn in its place. +If a number is used, that specifies the thickness of the line. +On termcap frames we cannot draw lines, so there `line' and +numbers are synonyms for nil. + +The color of the line is used to indicate if non-suffixes are +allowed and whether they exit the transient. The foreground +color of `transient-key-noop' (if non-suffix are disallowed), +`transient-key-stay' (if allowed and transient stays active), or +`transient-key-exit' (if allowed and they exit the transient) is +used to draw the line. + +Otherwise this can be any mode-line format. +See `mode-line-format' for details." + :package-version '(transient . "0.2.0") + :group 'transient + :type '(choice (const :tag "hide mode-line" nil) + (const :tag "substitute thin line" line) + (number :tag "substitute line with thickness") + (const :tag "name of prefix command" + ("%e" mode-line-front-space + mode-line-buffer-identification)) + (sexp :tag "custom mode-line format"))) + +(defcustom transient-show-common-commands nil + "Whether to show common transient suffixes in the popup buffer. + +These commands are always shown after typing the prefix key +\"C-x\" when a transient command is active. To toggle the value +of this variable use \"C-x t\" when a transient is active." + :package-version '(transient . "0.1.0") + :group 'transient + :type 'boolean) + +(defcustom transient-read-with-initial-input nil + "Whether to use the last history element as initial minibuffer input." + :package-version '(transient . "0.2.0") + :group 'transient + :type 'boolean) + +(defcustom transient-highlight-mismatched-keys nil + "Whether to highlight keys that do not match their argument. + +This only affects infix arguments that represent command-line +arguments. When this option is non-nil, then the key binding +for infix argument are highlighted when only a long argument +\(e.g., \"--verbose\") is specified but no shorthand (e.g., \"-v\"). +In the rare case that a short-hand is specified but does not +match the key binding, then it is highlighted differently. + +The highlighting is done using `transient-mismatched-key' +and `transient-nonstandard-key'." + :package-version '(transient . "0.1.0") + :group 'transient + :type 'boolean) + +(defcustom transient-highlight-higher-levels nil + "Whether to highlight suffixes on higher levels. + +This is primarily intended for package authors. + +When non-nil then highlight the description of suffixes whose +level is above 4, the default of `transient-default-level'. +Assuming you have set that variable to 7, this highlights all +suffixes that won't be available to users without them making +the same customization." + :package-version '(transient . "0.3.6") + :group 'transient + :type 'boolean) + +(defcustom transient-substitute-key-function nil + "Function used to modify key bindings. + +This function is called with one argument, the prefix object, +and must return a key binding description, either the existing +key description it finds in the `key' slot, or a substitution. + +This is intended to let users replace certain prefix keys. It +could also be used to make other substitutions, but that is +discouraged. + +For example, \"=\" is hard to reach using my custom keyboard +layout, so I substitute \"(\" for that, which is easy to reach +using a layout optimized for Lisp. + + (setq transient-substitute-key-function + (lambda (obj) + (let ((key (oref obj key))) + (if (string-match \"\\\\`\\\\(=\\\\)[a-zA-Z]\" key) + (replace-match \"(\" t t key 1) + key)))))" + :package-version '(transient . "0.1.0") + :group 'transient + :type '(choice (const :tag "Transform no keys (nil)" nil) function)) + +(defcustom transient-semantic-coloring t + "Whether to use colors to indicate transient behavior. + +If non-nil, then the key binding of each suffix is colorized to +indicate whether it exits the transient state or not, and the +line that is drawn below the transient popup buffer is used to +indicate the behavior of non-suffix commands." + :package-version '(transient . "0.5.0") + :group 'transient + :type 'boolean) + +(defcustom transient-detect-key-conflicts nil + "Whether to detect key binding conflicts. + +Conflicts are detected when a transient prefix command is invoked +and results in an error, which prevents the transient from being +used." + :package-version '(transient . "0.1.0") + :group 'transient + :type 'boolean) + +(defcustom transient-align-variable-pitch nil + "Whether to align columns pixel-wise in the popup buffer. + +If this is non-nil, then columns are aligned pixel-wise to +support variable-pitch fonts. Keys are not aligned, so you +should use a fixed-pitch font for the `transient-key' face. +Other key faces inherit from that face unless a theme is +used that breaks that relationship. + +This option is intended for users who use a variable-pitch +font for the `default' face. + +Also see `transient-force-fixed-pitch'." + :package-version '(transient . "0.4.0") + :group 'transient + :type 'boolean) + +(defcustom transient-force-fixed-pitch nil + "Whether to force use of monospaced font in the popup buffer. + +Even if you use a proportional font for the `default' face, +you might still want to use a monospaced font in transient's +popup buffer. Setting this option to t causes `default' to +be remapped to `fixed-pitch' in that buffer. + +Also see `transient-align-variable-pitch'." + :package-version '(transient . "0.2.0") + :group 'transient + :type 'boolean) + +(defcustom transient-force-single-column nil + "Whether to force use of a single column to display suffixes. + +This might be useful for users with low vision who use large +text and might otherwise have to scroll in two dimensions." + :package-version '(transient . "0.3.6") + :group 'transient + :type 'boolean) + +(defcustom transient-hide-during-minibuffer-read nil + "Whether to hide the transient buffer while reading in the minibuffer." + :package-version '(transient . "0.4.0") + :group 'transient + :type 'boolean) + +(defconst transient--max-level 7) +(defconst transient--default-child-level 1) +(defconst transient--default-prefix-level 4) + +(defcustom transient-default-level transient--default-prefix-level + "Control what suffix levels are made available by default. + +Each suffix command is placed on a level and each prefix command +has a level, which controls which suffix commands are available. +Integers between 1 and 7 (inclusive) are valid levels. + +The levels of individual transients and/or their individual +suffixes can be changed individually, by invoking the prefix and +then pressing \"C-x l\". + +The default level for both transients and their suffixes is 4. +This option only controls the default for transients. The default +suffix level is always 4. The author of a transient should place +certain suffixes on a higher level if they expect that it won't be +of use to most users, and they should place very important suffixes +on a lower level so that they remain available even if the user +lowers the transient level. + +\(Magit currently places nearly all suffixes on level 4 and lower +levels are not used at all yet. So for the time being you should +not set a lower level here and using a higher level might not +give you as many additional suffixes as you hoped.)" + :package-version '(transient . "0.1.0") + :group 'transient + :type '(choice (const :tag "1 - fewest suffixes" 1) + (const 2) + (const 3) + (const :tag "4 - default" 4) + (const 5) + (const 6) + (const :tag "7 - most suffixes" 7))) + +(defcustom transient-levels-file + (locate-user-emacs-file "transient/levels.el") + "File used to save levels of transients and their suffixes." + :package-version '(transient . "0.1.0") + :group 'transient + :type 'file) + +(defcustom transient-values-file + (locate-user-emacs-file "transient/values.el") + "File used to save values of transients." + :package-version '(transient . "0.1.0") + :group 'transient + :type 'file) + +(defcustom transient-history-file + (locate-user-emacs-file "transient/history.el") + "File used to save history of transients and their infixes." + :package-version '(transient . "0.1.0") + :group 'transient + :type 'file) + +(defcustom transient-history-limit 10 + "Number of history elements to keep when saving to file." + :package-version '(transient . "0.1.0") + :group 'transient + :type 'integer) + +(defcustom transient-save-history t + "Whether to save history of transient commands when exiting Emacs." + :package-version '(transient . "0.1.0") + :group 'transient + :type 'boolean) + +;;; Faces + +(defgroup transient-faces nil + "Faces used by Transient." + :group 'transient) + +(defface transient-heading '((t :inherit font-lock-keyword-face)) + "Face used for headings." + :group 'transient-faces) + +(defface transient-argument '((t :inherit font-lock-string-face :weight bold)) + "Face used for enabled arguments." + :group 'transient-faces) + +(defface transient-inactive-argument '((t :inherit shadow)) + "Face used for inactive arguments." + :group 'transient-faces) + +(defface transient-value '((t :inherit font-lock-string-face :weight bold)) + "Face used for values." + :group 'transient-faces) + +(defface transient-inactive-value '((t :inherit shadow)) + "Face used for inactive values." + :group 'transient-faces) + +(defface transient-unreachable '((t :inherit shadow)) + "Face used for suffixes unreachable from the current prefix sequence." + :group 'transient-faces) + +(defface transient-inapt-suffix '((t :inherit shadow :italic t)) + "Face used for suffixes that are inapt at this time." + :group 'transient-faces) + +(defface transient-active-infix '((t :inherit highlight)) + "Face used for the infix for which the value is being read." + :group 'transient-faces) + +(defface transient-enabled-suffix + '((t :background "green" :foreground "black" :weight bold)) + "Face used for enabled levels while editing suffix levels. +See info node `(transient)Enabling and Disabling Suffixes'." + :group 'transient-faces) + +(defface transient-disabled-suffix + '((t :background "red" :foreground "black" :weight bold)) + "Face used for disabled levels while editing suffix levels. +See info node `(transient)Enabling and Disabling Suffixes'." + :group 'transient-faces) + +(defface transient-higher-level + `((t :box ( :line-width ,(if (>= emacs-major-version 28) (cons -1 -1) -1) + :color ,(let ((color (face-attribute 'shadow :foreground nil t))) + (or (and (not (eq color 'unspecified)) color) + "grey60"))))) + "Face optionally used to highlight suffixes on higher levels. +Also see option `transient-highlight-higher-levels'." + :group 'transient-faces) + +(defface transient-delimiter '((t :inherit shadow)) + "Face used for delimiters and separators. +This includes the parentheses around values and the pipe +character used to separate possible values from each other." + :group 'transient-faces) + +(defface transient-key '((t :inherit font-lock-builtin-face)) + "Face used for keys." + :group 'transient-faces) + +(defface transient-key-stay + `((((class color) (background light)) + :inherit transient-key + :foreground "#22aa22") + (((class color) (background dark)) + :inherit transient-key + :foreground "#ddffdd")) + "Face used for keys of suffixes that don't exit transient state." + :group 'transient-faces) + +(defface transient-key-noop + `((((class color) (background light)) + :inherit transient-key + :foreground "grey80") + (((class color) (background dark)) + :inherit transient-key + :foreground "grey30")) + "Face used for keys of suffixes that currently cannot be invoked." + :group 'transient-faces) + +(defface transient-key-return + `((((class color) (background light)) + :inherit transient-key + :foreground "#aaaa11") + (((class color) (background dark)) + :inherit transient-key + :foreground "#ffffcc")) + "Face used for keys of suffixes that return to the parent transient." + :group 'transient-faces) + +(defface transient-key-exit + `((((class color) (background light)) + :inherit transient-key + :foreground "#aa2222") + (((class color) (background dark)) + :inherit transient-key + :foreground "#ffdddd")) + "Face used for keys of suffixes that exit transient state." + :group 'transient-faces) + +(defface transient-unreachable-key + '((t :inherit (shadow transient-key) :weight normal)) + "Face used for keys unreachable from the current prefix sequence." + :group 'transient-faces) + +(defface transient-nonstandard-key + `((t :box ( :line-width ,(if (>= emacs-major-version 28) (cons -1 -1) -1) + :color "cyan"))) + "Face optionally used to highlight keys conflicting with short-argument. +Also see option `transient-highlight-mismatched-keys'." + :group 'transient-faces) + +(defface transient-mismatched-key + `((t :box ( :line-width ,(if (>= emacs-major-version 28) (cons -1 -1) -1) + :color "magenta"))) + "Face optionally used to highlight keys without a short-argument. +Also see option `transient-highlight-mismatched-keys'." + :group 'transient-faces) + +;;; Persistence + +(defun transient--read-file-contents (file) + (with-demoted-errors "Transient error: %S" + (and (file-exists-p file) + (with-temp-buffer + (insert-file-contents file) + (read (current-buffer)))))) + +(defun transient--pp-to-file (list file) + (make-directory (file-name-directory file) t) + (setq list (cl-sort (copy-sequence list) #'string< :key #'car)) + (with-temp-file file + (let ((print-level nil) + (print-length nil) + (pp-default-function 'pp-28) + (fill-column 999)) + (pp list (current-buffer))))) + +(defvar transient-values + (transient--read-file-contents transient-values-file) + "Values of transient commands. +The value of this variable persists between Emacs sessions +and you usually should not change it manually.") + +(defun transient-save-values () + (transient--pp-to-file transient-values transient-values-file)) + +(defvar transient-levels + (transient--read-file-contents transient-levels-file) + "Levels of transient commands. +The value of this variable persists between Emacs sessions +and you usually should not change it manually.") + +(defun transient-save-levels () + (transient--pp-to-file transient-levels transient-levels-file)) + +(defvar transient-history + (transient--read-file-contents transient-history-file) + "History of transient commands and infix arguments. +The value of this variable persists between Emacs sessions +\(unless `transient-save-history' is nil) and you usually +should not change it manually.") + +(defun transient-save-history () + (setq transient-history + (cl-sort (mapcar (pcase-lambda (`(,key . ,val)) + (cons key (seq-take (delete-dups val) + transient-history-limit))) + transient-history) + #'string< :key #'car)) + (transient--pp-to-file transient-history transient-history-file)) + +(defun transient-maybe-save-history () + "Save the value of `transient-history'. +If `transient-save-history' is nil, then do nothing." + (when transient-save-history + (transient-save-history))) + +(unless noninteractive + (add-hook 'kill-emacs-hook #'transient-maybe-save-history)) + +;;; Classes +;;;; Prefix + +(defclass transient-prefix () + ((prototype :initarg :prototype) + (command :initarg :command) + (level :initarg :level) + (variable :initarg :variable :initform nil) + (init-value :initarg :init-value) + (value) (default-value :initarg :value) + (scope :initarg :scope :initform nil) + (history :initarg :history :initform nil) + (history-pos :initarg :history-pos :initform 0) + (history-key :initarg :history-key :initform nil) + (show-help :initarg :show-help :initform nil) + (info-manual :initarg :info-manual :initform nil) + (man-page :initarg :man-page :initform nil) + (transient-suffix :initarg :transient-suffix :initform nil) + (transient-non-suffix :initarg :transient-non-suffix :initform nil) + (transient-switch-frame :initarg :transient-switch-frame) + (refresh-suffixes :initarg :refresh-suffixes :initform nil) + (incompatible :initarg :incompatible :initform nil) + (suffix-description :initarg :suffix-description) + (variable-pitch :initarg :variable-pitch :initform nil) + (column-widths :initarg :column-widths :initform nil) + (unwind-suffix :documentation "Internal use." :initform nil)) + "Transient prefix command. + +Each transient prefix command consists of a command, which is +stored in a symbol's function slot and an object, which is +stored in the `transient--prefix' property of the same symbol. + +When a transient prefix command is invoked, then a clone of that +object is stored in the global variable `transient--prefix' and +the prototype is stored in the clone's `prototype' slot.") + +;;;; Suffix + +(defclass transient-child () + ((level + :initarg :level + :initform (symbol-value 'transient--default-child-level) + :documentation "Enable if level of prefix is equal or greater.") + (if + :initarg :if + :initform nil + :documentation "Enable if predicate returns non-nil.") + (if-not + :initarg :if-not + :initform nil + :documentation "Enable if predicate returns nil.") + (if-non-nil + :initarg :if-non-nil + :initform nil + :documentation "Enable if variable's value is non-nil.") + (if-nil + :initarg :if-nil + :initform nil + :documentation "Enable if variable's value is nil.") + (if-mode + :initarg :if-mode + :initform nil + :documentation "Enable if major-mode matches value.") + (if-not-mode + :initarg :if-not-mode + :initform nil + :documentation "Enable if major-mode does not match value.") + (if-derived + :initarg :if-derived + :initform nil + :documentation "Enable if major-mode derives from value.") + (if-not-derived + :initarg :if-not-derived + :initform nil + :documentation "Enable if major-mode does not derive from value.") + (inapt + :initform nil) + (inapt-face + :initarg :inapt-face + :initform 'transient-inapt-suffix) + (inapt-if + :initarg :inapt-if + :initform nil + :documentation "Inapt if predicate returns non-nil.") + (inapt-if-not + :initarg :inapt-if-not + :initform nil + :documentation "Inapt if predicate returns nil.") + (inapt-if-non-nil + :initarg :inapt-if-non-nil + :initform nil + :documentation "Inapt if variable's value is non-nil.") + (inapt-if-nil + :initarg :inapt-if-nil + :initform nil + :documentation "Inapt if variable's value is nil.") + (inapt-if-mode + :initarg :inapt-if-mode + :initform nil + :documentation "Inapt if major-mode matches value.") + (inapt-if-not-mode + :initarg :inapt-if-not-mode + :initform nil + :documentation "Inapt if major-mode does not match value.") + (inapt-if-derived + :initarg :inapt-if-derived + :initform nil + :documentation "Inapt if major-mode derives from value.") + (inapt-if-not-derived + :initarg :inapt-if-not-derived + :initform nil + :documentation "Inapt if major-mode does not derive from value.")) + "Abstract superclass for group and suffix classes. + +It is undefined what happens if more than one `if*' predicate +slot is non-nil." + :abstract t) + +(defclass transient-suffix (transient-child) + ((definition :allocation :class :initform nil) + (key :initarg :key) + (command :initarg :command) + (transient :initarg :transient) + (format :initarg :format :initform " %k %d") + (description :initarg :description :initform nil) + (face :initarg :face :initform nil) + (show-help :initarg :show-help :initform nil)) + "Superclass for suffix command.") + +(defclass transient-information (transient-suffix) + ((format :initform " %k %d") + (key :initform " ")) + "Display-only information, aligned with suffix keys. +Technically a suffix object with no associated command.") + +(defclass transient-information* (transient-information) + ((format :initform " %d")) + "Display-only information, aligned with suffix descriptions. +Technically a suffix object with no associated command.") + +(defclass transient-infix (transient-suffix) + ((transient :initform t) + (argument :initarg :argument) + (shortarg :initarg :shortarg) + (value :initform nil) + (init-value :initarg :init-value) + (unsavable :initarg :unsavable :initform nil) + (multi-value :initarg :multi-value :initform nil) + (always-read :initarg :always-read :initform nil) + (allow-empty :initarg :allow-empty :initform nil) + (history-key :initarg :history-key :initform nil) + (reader :initarg :reader :initform nil) + (prompt :initarg :prompt :initform nil) + (choices :initarg :choices :initform nil) + (format :initform " %k %d (%v)")) + "Transient infix command." + :abstract t) + +(defclass transient-argument (transient-infix) () + "Abstract superclass for infix arguments." + :abstract t) + +(defclass transient-switch (transient-argument) () + "Class used for command-line argument that can be turned on and off.") + +(defclass transient-option (transient-argument) () + "Class used for command-line argument that can take a value.") + +(defclass transient-variable (transient-infix) + ((variable :initarg :variable) + (format :initform " %k %d %v")) + "Abstract superclass for infix commands that set a variable." + :abstract t) + +(defclass transient-switches (transient-argument) + ((argument-format :initarg :argument-format) + (argument-regexp :initarg :argument-regexp)) + "Class used for sets of mutually exclusive command-line switches.") + +(defclass transient-files (transient-option) () + ((key :initform "--") + (argument :initform "--") + (multi-value :initform rest) + (reader :initform transient-read-files)) + "Class used for the \"--\" argument or similar. +All remaining arguments are treated as files. +They become the value of this argument.") + +;;;; Group + +(defclass transient-group (transient-child) + ((suffixes :initarg :suffixes :initform nil) + (hide :initarg :hide :initform nil) + (description :initarg :description :initform nil) + (pad-keys :initarg :pad-keys :initform nil) + (info-format :initarg :info-format :initform nil) + (setup-children :initarg :setup-children)) + "Abstract superclass of all group classes." + :abstract t) + +(defclass transient-column (transient-group) () + "Group class that displays each element on a separate line.") + +(defclass transient-row (transient-group) () + "Group class that displays all elements on a single line.") + +(defclass transient-columns (transient-group) () + "Group class that displays elements organized in columns. +Direct elements have to be groups whose elements have to be +commands or strings. Each subgroup represents a column. +This class takes care of inserting the subgroups' elements.") + +(defclass transient-subgroups (transient-group) () + "Group class that wraps other groups. + +Direct elements have to be groups whose elements have to be +commands or strings. This group inserts an empty line between +subgroups. The subgroups are responsible for displaying their +elements themselves.") + +;;; Define + +(defmacro transient-define-prefix (name arglist &rest args) + "Define NAME as a transient prefix command. + +ARGLIST are the arguments that command takes. +DOCSTRING is the documentation string and is optional. + +These arguments can optionally be followed by key-value pairs. +Each key has to be a keyword symbol, either `:class' or a keyword +argument supported by the constructor of that class. The +`transient-prefix' class is used if the class is not specified +explicitly. + +GROUPs add key bindings for infix and suffix commands and specify +how these bindings are presented in the popup buffer. At least +one GROUP has to be specified. See info node `(transient)Binding +Suffix and Infix Commands'. + +The BODY is optional. If it is omitted, then ARGLIST is also +ignored and the function definition becomes: + + (lambda () + (interactive) + (transient-setup \\='NAME)) + +If BODY is specified, then it must begin with an `interactive' +form that matches ARGLIST, and it must call `transient-setup'. +It may however call that function only when some condition is +satisfied; that is one of the reason why you might want to use +an explicit BODY. + +All transients have a (possibly nil) value, which is exported +when suffix commands are called, so that they can consume that +value. For some transients it might be necessary to have a sort +of secondary value, called a scope. Such a scope would usually +be set in the commands `interactive' form and has to be passed +to the setup function: + + (transient-setup \\='NAME nil nil :scope SCOPE) + +\(fn NAME ARGLIST [DOCSTRING] [KEYWORD VALUE]... GROUP... [BODY...])" + (declare (debug ( &define name lambda-list + [&optional lambda-doc] + [&rest keywordp sexp] + [&rest vectorp] + [&optional ("interactive" interactive) def-body])) + (indent defun) + (doc-string 3)) + (pcase-let ((`(,class ,slots ,suffixes ,docstr ,body ,interactive-only) + (transient--expand-define-args args arglist))) + `(progn + (defalias ',name + ,(if body + `(lambda ,arglist ,@body) + `(lambda () + (interactive) + (transient-setup ',name)))) + (put ',name 'interactive-only ,interactive-only) + (put ',name 'function-documentation ,docstr) + (put ',name 'transient--prefix + (,(or class 'transient-prefix) :command ',name ,@slots)) + (put ',name 'transient--layout + (list ,@(cl-mapcan (lambda (s) (transient--parse-child name s)) + suffixes)))))) + +(defmacro transient-define-suffix (name arglist &rest args) + "Define NAME as a transient suffix command. + +ARGLIST are the arguments that the command takes. +DOCSTRING is the documentation string and is optional. + +These arguments can optionally be followed by key-value pairs. +Each key has to be a keyword symbol, either `:class' or a +keyword argument supported by the constructor of that class. +The `transient-suffix' class is used if the class is not +specified explicitly. + +The BODY must begin with an `interactive' form that matches +ARGLIST. The infix arguments are usually accessed by using +`transient-args' inside `interactive'. + +\(fn NAME ARGLIST [DOCSTRING] [KEYWORD VALUE]... [BODY...])" + (declare (debug ( &define name lambda-list + [&optional lambda-doc] + [&rest keywordp sexp] + [&optional ("interactive" interactive) def-body])) + (indent defun) + (doc-string 3)) + (pcase-let ((`(,class ,slots ,_ ,docstr ,body ,interactive-only) + (transient--expand-define-args args arglist))) + `(progn + (defalias ',name + ,(if (and (not body) class (oref-default class definition)) + `(oref-default ',class definition) + `(lambda ,arglist ,@body))) + (put ',name 'interactive-only ,interactive-only) + (put ',name 'function-documentation ,docstr) + (put ',name 'transient--suffix + (,(or class 'transient-suffix) :command ',name ,@slots))))) + +(defmacro transient-define-infix (name arglist &rest args) + "Define NAME as a transient infix command. + +ARGLIST is always ignored and reserved for future use. +DOCSTRING is the documentation string and is optional. + +At least one key-value pair is required. All transient infix +commands are equal to each other (but not eq). It is meaning- +less to define an infix command, without providing at least one +keyword argument (usually `:argument' or `:variable', depending +on the class). The suffix class defaults to `transient-switch' +and can be set using the `:class' keyword. + +The function definitions is always: + + (lambda () + (interactive) + (let ((obj (transient-suffix-object))) + (transient-infix-set obj (transient-infix-read obj))) + (transient--show)) + +`transient-infix-read' and `transient-infix-set' are generic +functions. Different infix commands behave differently because +the concrete methods are different for different infix command +classes. In rare case the above command function might not be +suitable, even if you define your own infix command class. In +that case you have to use `transient-define-suffix' to define +the infix command and use t as the value of the `:transient' +keyword. + +\(fn NAME ARGLIST [DOCSTRING] KEYWORD VALUE [KEYWORD VALUE]...)" + (declare (debug ( &define name lambda-list + [&optional lambda-doc] + keywordp sexp + [&rest keywordp sexp])) + (indent defun) + (doc-string 3)) + (pcase-let ((`(,class ,slots ,_ ,docstr ,_ ,interactive-only) + (transient--expand-define-args args arglist t))) + `(progn + (defalias ',name #'transient--default-infix-command) + (put ',name 'interactive-only ,interactive-only) + (put ',name 'completion-predicate #'transient--suffix-only) + (put ',name 'function-documentation ,docstr) + (put ',name 'transient--suffix + (,(or class 'transient-switch) :command ',name ,@slots))))) + +(defalias 'transient-define-argument #'transient-define-infix + "Define NAME as a transient infix command. + +Only use this alias to define an infix command that actually +sets an infix argument. To define a infix command that, for +example, sets a variable, use `transient-define-infix' instead. + +\(fn NAME ARGLIST [DOCSTRING] [KEYWORD VALUE]...)") + +(defun transient--default-infix-command () + ;; Most infix commands are but an alias for this command. + "Cannot show any documentation for this transient infix command. + +When you request help for an infix command using `transient-help', that +usually shows the respective man-page and tries to jump to the location +where the respective argument is being described. + +If no man-page is specified for the containing transient menu, then the +docstring is displayed instead, if any. + +If the infix command doesn't have a docstring, as is the case here, then +this docstring is displayed instead, because technically infix commands +are aliases for `transient--default-infix-command'. + +`describe-function' also shows the docstring of the infix command, +falling back to that of the same aliased command." + (interactive) + (let ((obj (transient-suffix-object))) + (transient-infix-set obj (transient-infix-read obj))) + (transient--show)) +(put 'transient--default-infix-command 'interactive-only t) +(put 'transient--default-infix-command 'completion-predicate + #'transient--suffix-only) + +(defun transient--find-function-advised-original (fn func) + "Return nil instead of `transient--default-infix-command'. +When using `find-function' to jump to the definition of a transient +infix command/argument, then we want to actually jump to that, not to +the definition of `transient--default-infix-command', which all infix +commands are aliases for." + (let ((val (funcall fn func))) + (and val (not (eq val 'transient--default-infix-command)) val))) +(advice-add 'find-function-advised-original :around + #'transient--find-function-advised-original) + +(eval-and-compile + (defun transient--expand-define-args (args &optional arglist nobody) + (unless (listp arglist) + (error "Mandatory ARGLIST is missing")) + (let (class keys suffixes docstr declare (interactive-only t)) + (when (stringp (car args)) + (setq docstr (pop args))) + (while (keywordp (car args)) + (let ((k (pop args)) + (v (pop args))) + (if (eq k :class) + (setq class v) + (push k keys) + (push v keys)))) + (while (let ((arg (car args))) + (or (vectorp arg) + (and arg (symbolp arg)))) + (push (pop args) suffixes)) + (when (eq (car-safe (car args)) 'declare) + (setq declare (car args)) + (setq args (cdr args)) + (when-let ((int (assq 'interactive-only declare))) + (setq interactive-only (cadr int)) + (delq int declare)) + (unless (cdr declare) + (setq declare nil))) + (cond + ((not args)) + (nobody + (error "transient-define-infix: No function body allowed")) + ((not (eq (car-safe (nth (if declare 1 0) args)) 'interactive)) + (error "transient-define-*: Interactive form missing"))) + (list (if (eq (car-safe class) 'quote) + (cadr class) + class) + (nreverse keys) + (nreverse suffixes) + docstr + (if declare (cons declare args) args) + interactive-only)))) + +(defun transient--parse-child (prefix spec) + (cl-typecase spec + (null (error "Invalid transient--parse-child spec: %s" spec)) + (symbol (let ((value (symbol-value spec))) + (if (and (listp value) + (or (listp (car value)) + (vectorp (car value)))) + (cl-mapcan (lambda (s) (transient--parse-child prefix s)) value) + (transient--parse-child prefix value)))) + (vector (and-let* ((c (transient--parse-group prefix spec))) (list c))) + (list (and-let* ((c (transient--parse-suffix prefix spec))) (list c))) + (string (list spec)) + (t (error "Invalid transient--parse-child spec: %s" spec)))) + +(defun transient--parse-group (prefix spec) + (setq spec (append spec nil)) + (cl-symbol-macrolet + ((car (car spec)) + (pop (pop spec))) + (let (level class args) + (when (integerp car) + (setq level pop)) + (when (stringp car) + (setq args (plist-put args :description pop))) + (while (keywordp car) + (let ((key pop) + (val pop)) + (cond ((eq key :class) + (setq class (macroexp-quote val))) + ((or (symbolp val) + (and (listp val) (not (eq (car val) 'lambda)))) + (setq args (plist-put args key (macroexp-quote val)))) + ((setq args (plist-put args key val)))))) + (unless (or spec class (not (plist-get args :setup-children))) + (message "WARNING: %s: When %s is used, %s must also be specified" + 'transient-define-prefix :setup-children :class)) + (list 'vector + (or level transient--default-child-level) + (cond (class) + ((or (vectorp car) + (and car (symbolp car))) + (quote 'transient-columns)) + ((quote 'transient-column))) + (and args (cons 'list args)) + (cons 'list + (cl-mapcan (lambda (s) (transient--parse-child prefix s)) + spec)))))) + +(defun transient--parse-suffix (prefix spec) + (let (level class args) + (cl-symbol-macrolet + ((car (car spec)) + (pop (pop spec))) + (when (integerp car) + (setq level pop)) + (when (or (stringp car) + (vectorp car)) + (setq args (plist-put args :key pop))) + (cond + ((or (stringp car) + (and (eq (car-safe car) 'lambda) + (not (commandp car)))) + (setq args (plist-put args :description pop))) + ((and (symbolp car) + (not (keywordp car)) + (not (commandp car)) + (commandp (cadr spec))) + (setq args (plist-put args :description (macroexp-quote pop))))) + (cond + ((memq car '(:info :info*))) + ((keywordp car) + (error "Need command, `:info' or `:info*', got `%s'" car)) + ((symbolp car) + (setq args (plist-put args :command (macroexp-quote pop)))) + ((and (commandp car) + (not (stringp car))) + (let ((cmd pop) + (sym (intern + (format "transient:%s:%s" + prefix + (let ((desc (plist-get args :description))) + (if (and (stringp desc) + (length< desc 16)) + desc + (plist-get args :key))))))) + (setq args (plist-put + args :command + `(prog1 ',sym + (put ',sym 'interactive-only t) + (put ',sym 'completion-predicate #'transient--suffix-only) + (defalias ',sym + ,(if (eq (car-safe cmd) 'lambda) + cmd + (macroexp-quote cmd)))))))) + ((or (stringp car) + (and car (listp car))) + (let ((arg pop) + (sym nil)) + (cl-typecase arg + (list + (setq args (plist-put args :shortarg (car arg))) + (setq args (plist-put args :argument (cadr arg))) + (setq arg (cadr arg))) + (string + (when-let ((shortarg (transient--derive-shortarg arg))) + (setq args (plist-put args :shortarg shortarg))) + (setq args (plist-put args :argument arg)))) + (setq sym (intern (format "transient:%s:%s" prefix arg))) + (setq args (plist-put + args :command + `(prog1 ',sym + (put ',sym 'interactive-only t) + (put ',sym 'completion-predicate #'transient--suffix-only) + (defalias ',sym #'transient--default-infix-command)))) + (cond ((and car (not (keywordp car))) + (setq class 'transient-option) + (setq args (plist-put args :reader (macroexp-quote pop)))) + ((not (string-suffix-p "=" arg)) + (setq class 'transient-switch)) + (t + (setq class 'transient-option))))) + (t + (error "Needed command or argument, got %S" car))) + (while (keywordp car) + (let ((key pop) + (val pop)) + (cond ((eq key :class) (setq class val)) + ((eq key :level) (setq level val)) + ((eq key :info) + (setq class 'transient-information) + (setq args (plist-put args :description val))) + ((eq key :info*) + (setq class 'transient-information*) + (setq args (plist-put args :description val))) + ((eq (car-safe val) '\,) + (setq args (plist-put args key (cadr val)))) + ((or (symbolp val) + (and (listp val) (not (eq (car val) 'lambda)))) + (setq args (plist-put args key (macroexp-quote val)))) + ((setq args (plist-put args key val))))))) + (unless (plist-get args :key) + (when-let ((shortarg (plist-get args :shortarg))) + (setq args (plist-put args :key shortarg)))) + (list 'list + (or level transient--default-child-level) + (macroexp-quote (or class 'transient-suffix)) + (cons 'list args)))) + +(defun transient--derive-shortarg (arg) + (save-match-data + (and (string-match "\\`\\(-[a-zA-Z]\\)\\(\\'\\|=\\)" arg) + (match-string 1 arg)))) + +(defun transient-command-completion-not-suffix-only-p (symbol _buffer) + "Say whether SYMBOL should be offered as a completion. +If the value of SYMBOL's `completion-predicate' property is +`transient--suffix-only', then return nil, otherwise return t. +This is the case when a command should only ever be used as a +suffix of a transient prefix command (as opposed to bindings +in regular keymaps or by using `execute-extended-command')." + (not (eq (get symbol 'completion-predicate) 'transient--suffix-only))) + +(defalias 'transient--suffix-only #'ignore + "Ignore ARGUMENTS, do nothing, and return nil. +Also see `transient-command-completion-not-suffix-only-p'. +Only use this alias as the value of the `completion-predicate' +symbol property.") + +(when (and (boundp 'read-extended-command-predicate) ; since Emacs 28.1 + (not read-extended-command-predicate)) + (setq read-extended-command-predicate + #'transient-command-completion-not-suffix-only-p)) + +(defun transient-parse-suffix (prefix suffix) + "Parse SUFFIX, to be added to PREFIX. +PREFIX is a prefix command, a symbol. +SUFFIX is a suffix command or a group specification (of + the same forms as expected by `transient-define-prefix'). +Intended for use in a group's `:setup-children' function." + (cl-assert (and prefix (symbolp prefix))) + (eval (car (transient--parse-child prefix suffix)) t)) + +(defun transient-parse-suffixes (prefix suffixes) + "Parse SUFFIXES, to be added to PREFIX. +PREFIX is a prefix command, a symbol. +SUFFIXES is a list of suffix command or a group specification + (of the same forms as expected by `transient-define-prefix'). +Intended for use in a group's `:setup-children' function." + (cl-assert (and prefix (symbolp prefix))) + (mapcar (apply-partially #'transient-parse-suffix prefix) suffixes)) + +;;; Edit + +(defun transient--insert-suffix (prefix loc suffix action &optional keep-other) + (let* ((suf (cl-etypecase suffix + (vector (transient--parse-group prefix suffix)) + (list (transient--parse-suffix prefix suffix)) + (string suffix))) + (mem (transient--layout-member loc prefix)) + (elt (car mem))) + (setq suf (eval suf t)) + (cond + ((not mem) + (message "Cannot insert %S into %s; %s not found" + suffix prefix loc)) + ((or (and (vectorp suffix) (not (vectorp elt))) + (and (listp suffix) (vectorp elt)) + (and (stringp suffix) (vectorp elt))) + (message "Cannot place %S into %s at %s; %s" + suffix prefix loc + "suffixes and groups cannot be siblings")) + (t + (when-let* ((bindingp (listp suf)) + (key (transient--spec-key suf)) + (conflict (car (transient--layout-member key prefix))) + (conflictp + (and (not (and (eq action 'replace) + (eq conflict elt))) + (or (not keep-other) + (eq (plist-get (nth 2 suf) :command) + (plist-get (nth 2 conflict) :command))) + (equal (transient--suffix-predicate suf) + (transient--suffix-predicate conflict))))) + (transient-remove-suffix prefix key)) + (pcase-exhaustive action + ('insert (setcdr mem (cons elt (cdr mem))) + (setcar mem suf)) + ('append (setcdr mem (cons suf (cdr mem)))) + ('replace (setcar mem suf))))))) + +;;;###autoload +(defun transient-insert-suffix (prefix loc suffix &optional keep-other) + "Insert a SUFFIX into PREFIX before LOC. +PREFIX is a prefix command, a symbol. +SUFFIX is a suffix command or a group specification (of + the same forms as expected by `transient-define-prefix'). +LOC is a command, a key vector, a key description (a string + as returned by `key-description'), or a coordination list + (whose last element may also be a command or key). +Remove a conflicting binding unless optional KEEP-OTHER is + non-nil. +See info node `(transient)Modifying Existing Transients'." + (declare (indent defun)) + (transient--insert-suffix prefix loc suffix 'insert keep-other)) + +;;;###autoload +(defun transient-append-suffix (prefix loc suffix &optional keep-other) + "Insert a SUFFIX into PREFIX after LOC. +PREFIX is a prefix command, a symbol. +SUFFIX is a suffix command or a group specification (of + the same forms as expected by `transient-define-prefix'). +LOC is a command, a key vector, a key description (a string + as returned by `key-description'), or a coordination list + (whose last element may also be a command or key). +Remove a conflicting binding unless optional KEEP-OTHER is + non-nil. +See info node `(transient)Modifying Existing Transients'." + (declare (indent defun)) + (transient--insert-suffix prefix loc suffix 'append keep-other)) + +;;;###autoload +(defun transient-replace-suffix (prefix loc suffix) + "Replace the suffix at LOC in PREFIX with SUFFIX. +PREFIX is a prefix command, a symbol. +SUFFIX is a suffix command or a group specification (of + the same forms as expected by `transient-define-prefix'). +LOC is a command, a key vector, a key description (a string + as returned by `key-description'), or a coordination list + (whose last element may also be a command or key). +See info node `(transient)Modifying Existing Transients'." + (declare (indent defun)) + (transient--insert-suffix prefix loc suffix 'replace)) + +;;;###autoload +(defun transient-remove-suffix (prefix loc) + "Remove the suffix or group at LOC in PREFIX. +PREFIX is a prefix command, a symbol. +LOC is a command, a key vector, a key description (a string + as returned by `key-description'), or a coordination list + (whose last element may also be a command or key). +See info node `(transient)Modifying Existing Transients'." + (declare (indent defun)) + (transient--layout-member loc prefix 'remove)) + +(defun transient-get-suffix (prefix loc) + "Return the suffix or group at LOC in PREFIX. +PREFIX is a prefix command, a symbol. +LOC is a command, a key vector, a key description (a string + as returned by `key-description'), or a coordination list + (whose last element may also be a command or key). +See info node `(transient)Modifying Existing Transients'." + (if-let ((mem (transient--layout-member loc prefix))) + (car mem) + (error "%s not found in %s" loc prefix))) + +(defun transient-suffix-put (prefix loc prop value) + "Edit the suffix at LOC in PREFIX, setting PROP to VALUE. +PREFIX is a prefix command, a symbol. +SUFFIX is a suffix command or a group specification (of + the same forms as expected by `transient-define-prefix'). +LOC is a command, a key vector, a key description (a string + as returned by `key-description'), or a coordination list + (whose last element may also be a command or key). +See info node `(transient)Modifying Existing Transients'." + (let ((suf (transient-get-suffix prefix loc))) + (setf (elt suf 2) + (plist-put (elt suf 2) prop value)))) + +(defun transient--layout-member (loc prefix &optional remove) + (let ((val (or (get prefix 'transient--layout) + (error "%s is not a transient command" prefix)))) + (when (listp loc) + (while (integerp (car loc)) + (let* ((children (if (vectorp val) (aref val 3) val)) + (mem (transient--nthcdr (pop loc) children))) + (if (and remove (not loc)) + (let ((rest (delq (car mem) children))) + (if (vectorp val) + (aset val 3 rest) + (put prefix 'transient--layout rest)) + (setq val nil)) + (setq val (if loc (car mem) mem))))) + (setq loc (car loc))) + (if loc + (transient--layout-member-1 (transient--kbd loc) val remove) + val))) + +(defun transient--layout-member-1 (loc layout remove) + (cond ((listp layout) + (seq-some (lambda (elt) (transient--layout-member-1 loc elt remove)) + layout)) + ((vectorp (car (aref layout 3))) + (seq-some (lambda (elt) (transient--layout-member-1 loc elt remove)) + (aref layout 3))) + (remove + (aset layout 3 + (delq (car (transient--group-member loc layout)) + (aref layout 3))) + nil) + ((transient--group-member loc layout)))) + +(defun transient--group-member (loc group) + (cl-member-if (lambda (suffix) + (and (listp suffix) + (let* ((def (nth 2 suffix)) + (cmd (plist-get def :command))) + (if (symbolp loc) + (eq cmd loc) + (equal (transient--kbd + (or (plist-get def :key) + (transient--command-key cmd))) + loc))))) + (aref group 3))) + +(defun transient--kbd (keys) + (when (vectorp keys) + (setq keys (key-description keys))) + (when (stringp keys) + (setq keys (kbd keys))) + keys) + +(defun transient--spec-key (spec) + (let ((plist (nth 2 spec))) + (or (plist-get plist :key) + (transient--command-key + (plist-get plist :command))))) + +(defun transient--command-key (cmd) + (and-let* ((obj (transient--suffix-prototype cmd))) + (cond ((slot-boundp obj 'key) + (oref obj key)) + ((slot-exists-p obj 'shortarg) + (if (slot-boundp obj 'shortarg) + (oref obj shortarg) + (transient--derive-shortarg (oref obj argument))))))) + +(defun transient--nthcdr (n list) + (nthcdr (if (< n 0) (- (length list) (abs n)) n) list)) + +;;; Variables + +(defvar transient-current-prefix nil + "The transient from which this suffix command was invoked. +This is an object representing that transient, use +`transient-current-command' to get the respective command.") + +(defvar transient-current-command nil + "The transient from which this suffix command was invoked. +This is a symbol representing that transient, use +`transient-current-prefix' to get the respective object.") + +(defvar transient-current-suffixes nil + "The suffixes of the transient from which this suffix command was invoked. +This is a list of objects. Usually it is sufficient to instead +use the function `transient-args', which returns a list of +values. In complex cases it might be necessary to use this +variable instead.") + +(defvar transient-exit-hook nil + "Hook run after exiting a transient.") + +(defvar transient-setup-buffer-hook nil + "Hook run when setting up the transient buffer. +That buffer is current and empty when this hook runs.") + +(defvar transient--prefix nil) +(defvar transient--layout nil) +(defvar transient--suffixes nil) + +(defconst transient--stay t "Do not exit the transient.") +(defconst transient--exit nil "Do exit the transient.") + +(defvar transient--exitp nil "Whether to exit the transient.") +(defvar transient--showp nil "Whether to show the transient popup buffer.") +(defvar transient--helpp nil "Whether help-mode is active.") +(defvar transient--editp nil "Whether edit-mode is active.") + +(defvar transient--refreshp nil + "Whether to refresh the transient completely.") + +(defvar transient--all-levels-p nil + "Whether temporary display of suffixes on all levels is active.") + +(defvar transient--timer nil) + +(defvar transient--stack nil) + +(defvar transient--minibuffer-depth 0) + +(defvar transient--buffer-name " *transient*" + "Name of the transient buffer.") + +(defvar transient--buffer nil + "The transient menu buffer.") + +(defvar transient--window nil + "The window used to display the transient popup buffer.") + +(defvar transient--original-window nil + "The window that was selected before the transient was invoked. +Usually it remains selected while the transient is active.") + +(defvar transient--original-buffer nil + "The buffer that was current before the transient was invoked. +Usually it remains current while the transient is active.") + +(defvar transient--restore-winconf nil + "Window configuration to restore after exiting help.") + +(defvar transient--shadowed-buffer nil + "The buffer that is temporarily shadowed by the transient buffer. +This is bound while the suffix predicate is being evaluated and while +drawing in the transient buffer.") + +(defvar transient--pending-suffix nil + "The suffix that is currently being processed. +This is bound while the suffix predicate is being evaluated, +and while functions that return faces are being evaluated.") + +(defvar transient--pending-group nil + "The group that is currently being processed. +This is bound while the suffixes are drawn in the transient buffer.") + +(defvar transient--debug nil + "Whether to put debug information into *Messages*.") + +(defvar transient--history nil) + +(defvar transient--scroll-commands + '(transient-scroll-up + transient-scroll-down + mwheel-scroll + scroll-bar-toolkit-scroll)) + +;;; Identities + +(defun transient-prefix-object () + "Return the current prefix as an object. + +While a transient is being setup or refreshed (which involves +preparing its suffixes) the variable `transient--prefix' can be +used to access the prefix object. Thus this is what has to be +used in suffix methods such as `transient-format-description', +and in object-specific functions that are stored in suffix slots +such as `description'. + +When a suffix command is invoked (i.e., in its `interactive' form +and function body) then the variable `transient-current-prefix' +has to be used instead. + +Two distinct variables are needed, because any prefix may itself +be used as a suffix of another prefix, and such sub-prefixes have +to be able to tell themselves apart from the prefix they were +invoked from. + +Regular suffix commands, which are not prefixes, do not have to +concern themselves with this distinction, so they can use this +function instead. In the context of a plain suffix, it always +returns the value of the appropriate variable." + (or transient--prefix transient-current-prefix)) + +(defun transient-suffix-object (&optional command) + "Return the object associated with the current suffix command. + +Each suffix commands is associated with an object, which holds +additional information about the suffix, such as its value (in +the case of an infix command, which is a kind of suffix command). + +This function is intended to be called by infix commands, which +are usually aliases of `transient--default-infix-command', which +is defined like this: + + (defun transient--default-infix-command () + (interactive) + (let ((obj (transient-suffix-object))) + (transient-infix-set obj (transient-infix-read obj))) + (transient--show)) + +\(User input is read outside of `interactive' to prevent the +command from being added to `command-history'. See #23.) + +Such commands need to be able to access their associated object +to guide how `transient-infix-read' reads the new value and to +store the read value. Other suffix commands (including non-infix +commands) may also need the object to guide their behavior. + +This function attempts to return the object associated with the +current suffix command even if the suffix command was not invoked +from a transient. (For some suffix command that is a valid thing +to do, for others it is not.) In that case nil may be returned, +if the command was not defined using one of the macros intended +to define such commands. + +The optional argument COMMAND is intended for internal use. If +you are contemplating using it in your own code, then you should +probably use this instead: + + (get COMMAND \\='transient--suffix)" + (when command + (cl-check-type command command)) + (cond + (transient--pending-suffix) + ((or transient--prefix + transient-current-prefix) + (let ((suffixes + (cl-remove-if-not + (lambda (obj) + (eq (oref obj command) + (or command + (if (eq this-command 'transient-set-level) + ;; This is how it can look up for which + ;; command it is setting the level. + this-original-command + this-command)))) + (or transient--suffixes + transient-current-suffixes)))) + (or (and (cdr suffixes) + (cl-find-if + (lambda (obj) + (equal (listify-key-sequence (transient--kbd (oref obj key))) + (listify-key-sequence (this-command-keys)))) + suffixes)) + (car suffixes)))) + ((and-let* ((obj (transient--suffix-prototype (or command this-command))) + (obj (clone obj))) + (progn ; work around debbugs#31840 + (transient-init-scope obj) + (transient-init-value obj) + obj))))) + +(defun transient--suffix-prototype (command) + (or (get command 'transient--suffix) + (seq-some (lambda (cmd) (get cmd 'transient--suffix)) + (function-alias-p command)))) + +;;; Keymaps + +(defvar-keymap transient-base-map + :doc "Parent of other keymaps used by Transient. + +This is the parent keymap of all the keymaps that are used in +all transients: `transient-map' (which in turn is the parent +of the transient-specific keymaps), `transient-edit-map' and +`transient-sticky-map'. + +If you change a binding here, then you might also have to edit +`transient-sticky-map' and `transient-common-commands'. While +the latter isn't a proper transient prefix command, it can be +edited using the same functions as used for transients. + +If you add a new command here, then you must also add a binding +to `transient-predicate-map'." + "ESC ESC ESC" #'transient-quit-all + "C-g" #'transient-quit-one + "C-q" #'transient-quit-all + "C-z" #'transient-suspend + "C-v" #'transient-scroll-up + "C-M-v" #'transient-scroll-down + "<next>" #'transient-scroll-up + "<prior>" #'transient-scroll-down) + +(defvar-keymap transient-map + :doc "Top-level keymap used by all transients. + +If you add a new command here, then you must also add a binding +to `transient-predicate-map'. Also see `transient-base-map'." + :parent transient-base-map + "C-u" #'universal-argument + "C--" #'negative-argument + "C-t" #'transient-show + "?" #'transient-help + "C-h" #'transient-help + ;; Also bound to "C-x p" and "C-x n" in transient-common-commands. + "C-M-p" #'transient-history-prev + "C-M-n" #'transient-history-next) + +(defvar-keymap transient-edit-map + :doc "Keymap that is active while a transient in is in \"edit mode\"." + :parent transient-base-map + "?" #'transient-help + "C-h" #'transient-help + "C-x l" #'transient-set-level) + +(defvar-keymap transient-sticky-map + :doc "Keymap that is active while an incomplete key sequence is active." + :parent transient-base-map + "C-g" #'transient-quit-seq) + +(defvar transient--common-command-prefixes '(?\C-x)) + +(put 'transient-common-commands + 'transient--layout + (list + (eval + (car (transient--parse-child + 'transient-common-commands + (vector + :hide + (lambda () + (and (not (memq + (car (bound-and-true-p transient--redisplay-key)) + transient--common-command-prefixes)) + (not transient-show-common-commands))) + (vector + "Value commands" + (list "C-x s " "Set" #'transient-set) + (list "C-x C-s" "Save" #'transient-save) + (list "C-x C-k" "Reset" #'transient-reset) + (list "C-x p " "Previous value" #'transient-history-prev) + (list "C-x n " "Next value" #'transient-history-next)) + (vector + "Sticky commands" + ;; Like `transient-sticky-map' except that + ;; "C-g" has to be bound to a different command. + (list "C-g" "Quit prefix or transient" #'transient-quit-one) + (list "C-q" "Quit transient stack" #'transient-quit-all) + (list "C-z" "Suspend transient stack" #'transient-suspend)) + (vector + "Customize" + (list "C-x t" 'transient-toggle-common :description + (lambda () + (if transient-show-common-commands + "Hide common commands" + "Show common permanently"))) + (list "C-x l" "Show/hide suffixes" #'transient-set-level) + (list "C-x a" #'transient-toggle-level-limit))))) + t))) + +(defvar-keymap transient-popup-navigation-map + :doc "One of the keymaps used when popup navigation is enabled. +See `transient-enable-popup-navigation'." + "<down-mouse-1>" #'transient-noop + "<up>" #'transient-backward-button + "<down>" #'transient-forward-button + "C-r" #'transient-isearch-backward + "C-s" #'transient-isearch-forward + "M-RET" #'transient-push-button) + +(defvar-keymap transient-button-map + :doc "One of the keymaps used when popup navigation is enabled. +See `transient-enable-popup-navigation'." + "<mouse-1>" #'transient-push-button + "<mouse-2>" #'transient-push-button) + +(defvar-keymap transient-resume-mode-map + :doc "Keymap for `transient-resume-mode'. + +This keymap remaps every command that would usually just quit the +documentation buffer to `transient-resume', which additionally +resumes the suspended transient." + "<remap> <Man-quit>" #'transient-resume + "<remap> <Info-exit>" #'transient-resume + "<remap> <quit-window>" #'transient-resume) + +(defvar-keymap transient-predicate-map + :doc "Base keymap used to map common commands to their transient behavior. + +The \"transient behavior\" of a command controls, among other +things, whether invoking the command causes the transient to be +exited or not, and whether infix arguments are exported before +doing so. + +Each \"key\" is a command that is common to all transients and +that is bound in `transient-map', `transient-edit-map', +`transient-sticky-map' and/or `transient-common-command'. + +Each binding is a \"pre-command\", a function that controls the +transient behavior of the respective command. + +For transient commands that are bound in individual transients, +the transient behavior is specified using the `:transient' slot +of the corresponding object." + "<transient-suspend>" #'transient--do-suspend + "<transient-help>" #'transient--do-stay + "<transient-set-level>" #'transient--do-stay + "<transient-history-prev>" #'transient--do-stay + "<transient-history-next>" #'transient--do-stay + "<universal-argument>" #'transient--do-stay + "<universal-argument-more>" #'transient--do-stay + "<negative-argument>" #'transient--do-minus + "<digit-argument>" #'transient--do-stay + "<top-level>" #'transient--do-quit-all + "<transient-quit-all>" #'transient--do-quit-all + "<transient-quit-one>" #'transient--do-quit-one + "<transient-quit-seq>" #'transient--do-stay + "<transient-show>" #'transient--do-stay + "<transient-update>" #'transient--do-stay + "<transient-toggle-common>" #'transient--do-stay + "<transient-set>" #'transient--do-call + "<transient-set-and-exit>" #'transient--do-exit + "<transient-save>" #'transient--do-call + "<transient-save-and-exit>" #'transient--do-exit + "<transient-reset>" #'transient--do-call + "<describe-key-briefly>" #'transient--do-stay + "<describe-key>" #'transient--do-stay + "<transient-scroll-up>" #'transient--do-stay + "<transient-scroll-down>" #'transient--do-stay + "<mwheel-scroll>" #'transient--do-stay + "<scroll-bar-toolkit-scroll>" #'transient--do-stay + "<transient-noop>" #'transient--do-noop + "<transient-mouse-push-button>" #'transient--do-move + "<transient-push-button>" #'transient--do-push-button + "<transient-backward-button>" #'transient--do-move + "<transient-forward-button>" #'transient--do-move + "<transient-isearch-backward>" #'transient--do-move + "<transient-isearch-forward>" #'transient--do-move + ;; If a valid but incomplete prefix sequence is followed by + ;; an unbound key, then Emacs calls the `undefined' command + ;; but does not set `this-command', `this-original-command' + ;; or `real-this-command' accordingly. Instead they are nil. + "<nil>" #'transient--do-warn + ;; Bound to the `mouse-movement' event, this command is similar + ;; to `ignore'. + "<ignore-preserving-kill-region>" #'transient--do-noop) + +(defvar transient--transient-map nil) +(defvar transient--predicate-map nil) +(defvar transient--redisplay-map nil) +(defvar transient--redisplay-key nil) + +(defun transient--push-keymap (var) + (let ((map (symbol-value var))) + (transient--debug " push %s%s" var (if map "" " VOID")) + (when map + (with-demoted-errors "transient--push-keymap: %S" + (internal-push-keymap map 'overriding-terminal-local-map))))) + +(defun transient--pop-keymap (var) + (let ((map (symbol-value var))) + (when map + (transient--debug " pop %s" var) + (with-demoted-errors "transient--pop-keymap: %S" + (internal-pop-keymap map 'overriding-terminal-local-map))))) + +(defun transient--make-transient-map () + (let ((map (make-sparse-keymap))) + (set-keymap-parent map (if transient--editp + transient-edit-map + transient-map)) + (dolist (obj transient--suffixes) + (let ((key (oref obj key))) + (when (vectorp key) + (setq key (key-description key)) + (oset obj key key)) + (when transient-substitute-key-function + (setq key (save-match-data + (funcall transient-substitute-key-function obj))) + (oset obj key key)) + (let* ((kbd (kbd key)) + (cmd (oref obj command)) + (alt (transient--lookup-key map kbd))) + (cond ((not alt) + (define-key map kbd cmd)) + ((eq alt cmd)) + ((transient--inapt-suffix-p obj)) + ((and-let* ((obj (transient-suffix-object alt))) + (transient--inapt-suffix-p obj)) + (define-key map kbd cmd)) + (transient-detect-key-conflicts + (error "Cannot bind %S to %s and also %s" + (string-trim key) cmd alt)) + ((define-key map kbd cmd)))))) + (when-let ((b (keymap-lookup map "-"))) (keymap-set map "<kp-subtract>" b)) + (when-let ((b (keymap-lookup map "="))) (keymap-set map "<kp-equal>" b)) + (when-let ((b (keymap-lookup map "+"))) (keymap-set map "<kp-add>" b)) + (when transient-enable-popup-navigation + ;; `transient--make-redisplay-map' maps only over bindings that are + ;; directly in the base keymap, so that cannot be a composed keymap. + (set-keymap-parent + map (make-composed-keymap + (keymap-parent map) + transient-popup-navigation-map))) + map)) + +(defun transient--make-predicate-map () + (let* ((default (transient--resolve-pre-command + (oref transient--prefix transient-suffix))) + (return (and transient--stack (eq default t))) + (map (make-sparse-keymap))) + (set-keymap-parent map transient-predicate-map) + (when (or (and (slot-boundp transient--prefix 'transient-switch-frame) + (transient--resolve-pre-command + (not (oref transient--prefix transient-switch-frame)))) + (memq (transient--resolve-pre-command + (oref transient--prefix transient-non-suffix)) + '(nil transient--do-warn transient--do-noop))) + (define-key map [handle-switch-frame] #'transient--do-suspend)) + (dolist (obj transient--suffixes) + (let* ((cmd (oref obj command)) + (kind (cond ((get cmd 'transient--prefix) 'prefix) + ((cl-typep obj 'transient-infix) 'infix) + (t 'suffix)))) + (cond + ((oref obj inapt) + (define-key map (vector cmd) #'transient--do-warn-inapt)) + ((slot-boundp obj 'transient) + (define-key map (vector cmd) + (pcase (list kind + (transient--resolve-pre-command (oref obj transient)) + return) + (`(prefix t ,_) #'transient--do-recurse) + (`(prefix nil ,_) #'transient--do-stack) + (`(infix t ,_) #'transient--do-stay) + (`(suffix t ,_) #'transient--do-call) + ('(suffix nil t) #'transient--do-return) + (`(,_ nil ,_) #'transient--do-exit) + (`(,_ ,do ,_) do)))) + ((not (lookup-key transient-predicate-map (vector cmd))) + (define-key map (vector cmd) + (pcase (list kind default return) + (`(prefix ,(or 'transient--do-stay 'transient--do-call) ,_) + #'transient--do-recurse) + (`(prefix t ,_) #'transient--do-recurse) + (`(prefix ,_ ,_) #'transient--do-stack) + (`(infix ,_ ,_) #'transient--do-stay) + (`(suffix t ,_) #'transient--do-call) + ('(suffix nil t) #'transient--do-return) + (`(suffix nil ,_) #'transient--do-exit) + (`(suffix ,do ,_) do))))))) + map)) + +(defun transient--make-redisplay-map () + (setq transient--redisplay-key + (pcase this-command + ('transient-update + (setq transient--showp t) + (setq unread-command-events + (listify-key-sequence (this-single-command-raw-keys)))) + ('transient-quit-seq + (setq unread-command-events + (butlast (listify-key-sequence + (this-single-command-raw-keys)) + 2)) + (butlast transient--redisplay-key)) + (_ nil))) + (let ((topmap (make-sparse-keymap)) + (submap (make-sparse-keymap))) + (when transient--redisplay-key + (define-key topmap (vconcat transient--redisplay-key) submap) + (set-keymap-parent submap transient-sticky-map)) + (map-keymap-internal + (lambda (key def) + (when (and (not (eq key ?\e)) + (listp def) + (keymapp def)) + (define-key topmap (vconcat transient--redisplay-key (list key)) + #'transient-update))) + (if transient--redisplay-key + (let ((key (vconcat transient--redisplay-key))) + (or (lookup-key transient--transient-map key) + (and-let* ((regular (lookup-key local-function-key-map key))) + (lookup-key transient--transient-map (vconcat regular))))) + transient--transient-map)) + topmap)) + +;;; Setup + +(defun transient-setup (&optional name layout edit &rest params) + "Setup the transient specified by NAME. + +This function is called by transient prefix commands to setup the +transient. In that case NAME is mandatory, LAYOUT and EDIT must +be nil and PARAMS may be (but usually is not) used to set, e.g., +the \"scope\" of the transient (see `transient-define-prefix'). + +This function is also called internally in which case LAYOUT and +EDIT may be non-nil." + (transient--debug 'setup) + (transient--with-emergency-exit :setup + (cond + ((not name) + ;; Switching between regular and edit mode. + (transient--pop-keymap 'transient--transient-map) + (transient--pop-keymap 'transient--redisplay-map) + (setq name (oref transient--prefix command)) + (setq params (list :scope (oref transient--prefix scope)))) + (transient--prefix + ;; Invoked as a ":transient-non-suffix 'transient--do-{stay,call}" + ;; of an outer prefix. Unlike the usual `transient--do-stack', + ;; these predicates fail to clean up after the outer prefix. + (transient--pop-keymap 'transient--transient-map) + (transient--pop-keymap 'transient--redisplay-map)) + ((not (or layout ; resuming parent/suspended prefix + transient-current-command)) ; entering child prefix + (transient--stack-zap)) ; replace suspended prefix, if any + (edit + ;; Returning from help to edit. + (setq transient--editp t))) + (transient--init-objects name layout params) + (transient--init-keymaps) + (transient--history-init transient--prefix) + (setq transient--original-window (selected-window)) + (setq transient--original-buffer (current-buffer)) + (setq transient--minibuffer-depth (minibuffer-depth)) + (transient--redisplay) + (transient--init-transient) + (transient--suspend-which-key-mode))) + +(cl-defgeneric transient-setup-children (group children) + "Setup the CHILDREN of GROUP. +If the value of the `setup-children' slot is non-nil, then call +that function with CHILDREN as the only argument and return the +value. Otherwise return CHILDREN as is." + (if (slot-boundp group 'setup-children) + (funcall (oref group setup-children) children) + children)) + +(defun transient--init-keymaps () + (setq transient--predicate-map (transient--make-predicate-map)) + (setq transient--transient-map (transient--make-transient-map)) + (setq transient--redisplay-map (transient--make-redisplay-map))) + +(defun transient--init-objects (&optional name layout params) + (if name + (setq transient--prefix (transient--init-prefix name params)) + (setq name (oref transient--prefix command))) + (setq transient--refreshp (oref transient--prefix refresh-suffixes)) + (setq transient--layout (or layout (transient--init-suffixes name))) + (setq transient--suffixes (transient--flatten-suffixes transient--layout))) + +(defun transient--init-prefix (name &optional params) + (let ((obj (let ((proto (get name 'transient--prefix))) + (apply #'clone proto + :prototype proto + :level (or (alist-get t (alist-get name transient-levels)) + transient-default-level) + params)))) + (transient--setup-recursion obj) + (transient-init-value obj) + obj)) + +(defun transient--init-suffixes (name) + (let ((levels (alist-get name transient-levels))) + (cl-mapcan (lambda (c) (transient--init-child levels c nil)) + (append (get name 'transient--layout) + (and (not transient--editp) + (get 'transient-common-commands + 'transient--layout)))))) + +(defun transient--flatten-suffixes (layout) + (cl-labels ((s (def) + (cond + ((stringp def) nil) + ((cl-typep def 'transient-information) nil) + ((listp def) (cl-mapcan #'s def)) + ((cl-typep def 'transient-group) + (cl-mapcan #'s (oref def suffixes))) + ((cl-typep def 'transient-suffix) + (list def))))) + (cl-mapcan #'s layout))) + +(defun transient--init-child (levels spec parent) + (cl-etypecase spec + (vector (transient--init-group levels spec parent)) + (list (transient--init-suffix levels spec parent)) + (string (list spec)))) + +(defun transient--init-group (levels spec parent) + (pcase-let ((`(,level ,class ,args ,children) (append spec nil))) + (and-let* (((transient--use-level-p level)) + (obj (apply class :level level args)) + ((transient--use-suffix-p obj)) + ((prog1 t + (when (or (and parent (oref parent inapt)) + (transient--inapt-suffix-p obj)) + (oset obj inapt t)))) + (suffixes (cl-mapcan + (lambda (c) (transient--init-child levels c obj)) + (transient-setup-children obj children)))) + (progn ; work around debbugs#31840 + (oset obj suffixes suffixes) + (list obj))))) + +(defun transient--init-suffix (levels spec parent) + (pcase-let* ((`(,level ,class ,args) spec) + (cmd (plist-get args :command)) + (key (transient--kbd (plist-get args :key))) + (level (or (alist-get (cons cmd key) levels nil nil #'equal) + (alist-get cmd levels) + level))) + (let ((fn (and (symbolp cmd) + (symbol-function cmd)))) + (when (autoloadp fn) + (transient--debug " autoload %s" cmd) + (autoload-do-load fn))) + (when (transient--use-level-p level) + (let ((obj (if (child-of-class-p class 'transient-information) + (apply class :level level args) + (unless (and cmd (symbolp cmd)) + (error "BUG: Non-symbolic suffix command: %s" cmd)) + (if-let ((proto (and cmd (transient--suffix-prototype cmd)))) + (apply #'clone proto :level level args) + (apply class :command cmd :level level args))))) + (cond ((not cmd)) + ((commandp cmd)) + ((or (cl-typep obj 'transient-switch) + (cl-typep obj 'transient-option)) + ;; As a temporary special case, if the package was compiled + ;; with an older version of Transient, then we must define + ;; "anonymous" switch and option commands here. + (defalias cmd #'transient--default-infix-command)) + ((transient--use-suffix-p obj) + (error "Suffix command %s is not defined or autoloaded" cmd))) + (unless (cl-typep obj 'transient-information) + (transient--init-suffix-key obj)) + (when (transient--use-suffix-p obj) + (if (or (and parent (oref parent inapt)) + (transient--inapt-suffix-p obj)) + (oset obj inapt t) + (transient-init-scope obj) + (transient-init-value obj)) + (list obj)))))) + +(cl-defmethod transient--init-suffix-key ((obj transient-suffix)) + (unless (slot-boundp obj 'key) + (error "No key for %s" (oref obj command)))) + +(cl-defmethod transient--init-suffix-key ((obj transient-argument)) + (if (transient-switches--eieio-childp obj) + (cl-call-next-method obj) + (unless (slot-boundp obj 'shortarg) + (when-let ((shortarg (transient--derive-shortarg (oref obj argument)))) + (oset obj shortarg shortarg))) + (unless (slot-boundp obj 'key) + (if (slot-boundp obj 'shortarg) + (oset obj key (oref obj shortarg)) + (error "No key for %s" (oref obj command)))))) + +(defun transient--use-level-p (level &optional edit) + (or transient--all-levels-p + (and transient--editp (not edit)) + (and (>= level 1) + (<= level (oref transient--prefix level))))) + +(defun transient--use-suffix-p (obj) + (let ((transient--shadowed-buffer (current-buffer)) + (transient--pending-suffix obj)) + (transient--do-suffix-p + (oref obj if) + (oref obj if-not) + (oref obj if-nil) + (oref obj if-non-nil) + (oref obj if-mode) + (oref obj if-not-mode) + (oref obj if-derived) + (oref obj if-not-derived) + t))) + +(defun transient--inapt-suffix-p (obj) + (let ((transient--shadowed-buffer (current-buffer)) + (transient--pending-suffix obj)) + (transient--do-suffix-p + (oref obj inapt-if) + (oref obj inapt-if-not) + (oref obj inapt-if-nil) + (oref obj inapt-if-non-nil) + (oref obj inapt-if-mode) + (oref obj inapt-if-not-mode) + (oref obj inapt-if-derived) + (oref obj inapt-if-not-derived) + nil))) + +(defun transient--do-suffix-p + (if if-not if-nil if-non-nil if-mode if-not-mode if-derived if-not-derived + default) + (cond + (if (funcall if)) + (if-not (not (funcall if-not))) + (if-non-nil (symbol-value if-non-nil)) + (if-nil (not (symbol-value if-nil))) + (if-mode (if (atom if-mode) + (eq major-mode if-mode) + (memq major-mode if-mode))) + (if-not-mode (not (if (atom if-not-mode) + (eq major-mode if-not-mode) + (memq major-mode if-not-mode)))) + (if-derived (if (or (atom if-derived) + (>= emacs-major-version 30)) + (derived-mode-p if-derived) + (apply #'derived-mode-p if-derived))) + (if-not-derived (not (if (or (atom if-not-derived) + (>= emacs-major-version 30)) + (derived-mode-p if-not-derived) + (apply #'derived-mode-p if-not-derived)))) + (default))) + +(defun transient--suffix-predicate (spec) + (let ((plist (nth 2 spec))) + (seq-some (lambda (prop) + (and-let* ((pred (plist-get plist prop))) + (list prop pred))) + '( :if :if-not + :if-nil :if-non-nil + :if-mode :if-not-mode + :if-derived :if-not-derived + :inapt-if :inapt-if-not + :inapt-if-nil :inapt-if-non-nil + :inapt-if-mode :inapt-if-not-mode + :inapt-if-derived :inapt-if-not-derived)))) + +;;; Flow-Control + +(defun transient--init-transient () + (transient--debug 'init-transient) + (transient--push-keymap 'transient--transient-map) + (transient--push-keymap 'transient--redisplay-map) + (add-hook 'pre-command-hook #'transient--pre-command) + (add-hook 'post-command-hook #'transient--post-command) + (advice-add 'recursive-edit :around #'transient--recursive-edit) + (when transient--exitp + ;; This prefix command was invoked as the suffix of another. + ;; Prevent `transient--post-command' from removing the hooks + ;; that we just added. + (setq transient--exitp 'replace))) + +(defun transient--refresh-transient () + (transient--debug 'refresh-transient) + (transient--pop-keymap 'transient--predicate-map) + (transient--pop-keymap 'transient--transient-map) + (transient--pop-keymap 'transient--redisplay-map) + (transient--init-objects) + (transient--init-keymaps) + (transient--push-keymap 'transient--transient-map) + (transient--push-keymap 'transient--redisplay-map) + (transient--redisplay)) + +(defun transient--pre-command () + (transient--debug 'pre-command) + (transient--with-emergency-exit :pre-command + ;; The use of `overriding-terminal-local-map' does not prevent the + ;; lookup of command remappings in the overridden maps, which can + ;; lead to a suffix being remapped to a non-suffix. We have to undo + ;; the remapping in that case. However, remapping a non-suffix to + ;; another should remain possible. + (when (and (transient--get-pre-command this-original-command 'suffix) + (not (transient--get-pre-command this-command 'suffix))) + (setq this-command this-original-command)) + (cond + ((memq this-command '(transient-update transient-quit-seq)) + (transient--pop-keymap 'transient--redisplay-map)) + ((and transient--helpp + (not (memq this-command '(transient-quit-one + transient-quit-all)))) + (cond + ((transient-help) + (transient--do-suspend) + (setq this-command 'transient-suspend) + (transient--pre-exit)) + ((not (transient--edebug-command-p)) + (setq this-command 'transient-undefined)))) + ((and transient--editp + (transient-suffix-object) + (not (memq this-command '(transient-quit-one + transient-quit-all + transient-help)))) + (setq this-command 'transient-set-level) + (transient--wrap-command)) + (t + (setq transient--exitp nil) + (let ((exitp (eq (transient--call-pre-command) transient--exit))) + (transient--wrap-command) + (when exitp + (transient--pre-exit))))))) + +(defun transient--pre-exit () + (transient--debug 'pre-exit) + (transient--delete-window) + (transient--timer-cancel) + (transient--pop-keymap 'transient--transient-map) + (transient--pop-keymap 'transient--redisplay-map) + (unless transient--showp + (let ((message-log-max nil)) + (message ""))) + (setq transient--transient-map nil) + (setq transient--predicate-map nil) + (setq transient--redisplay-map nil) + (setq transient--redisplay-key nil) + (setq transient--helpp nil) + (setq transient--editp nil) + (setq transient--prefix nil) + (setq transient--layout nil) + (setq transient--suffixes nil) + (setq transient--original-window nil) + (setq transient--original-buffer nil) + (setq transient--window nil)) + +(defun transient--delete-window () + (when (window-live-p transient--window) + (let ((remain-in-minibuffer-window + (and (minibuffer-selected-window) + (selected-window)))) + ;; Only delete the window if it has never shown another buffer. + (unless (eq (car (window-parameter transient--window 'quit-restore)) + 'other) + (with-demoted-errors "Error while exiting transient: %S" + (delete-window transient--window))) + (when (buffer-live-p transient--buffer) + (kill-buffer transient--buffer)) + (setq transient--buffer nil) + (when remain-in-minibuffer-window + (select-window remain-in-minibuffer-window))))) + +(defun transient--export () + (setq transient-current-prefix transient--prefix) + (setq transient-current-command (oref transient--prefix command)) + (setq transient-current-suffixes transient--suffixes) + (transient--history-push transient--prefix)) + +(defun transient--suspend-override (&optional nohide) + (transient--debug 'suspend-override) + (transient--timer-cancel) + (cond ((and (not nohide) transient-hide-during-minibuffer-read) + (transient--delete-window)) + ((and transient--prefix transient--redisplay-key) + (setq transient--redisplay-key nil) + (when transient--showp + (if-let ((win (minibuffer-selected-window))) + (with-selected-window win + (transient--show)) + (transient--show))))) + (transient--pop-keymap 'transient--transient-map) + (transient--pop-keymap 'transient--redisplay-map) + (remove-hook 'pre-command-hook #'transient--pre-command) + (remove-hook 'post-command-hook #'transient--post-command)) + +(defun transient--resume-override (&optional _ignore) + (transient--debug 'resume-override) + (when (and transient--showp transient-hide-during-minibuffer-read) + (transient--show)) + (transient--push-keymap 'transient--transient-map) + (transient--push-keymap 'transient--redisplay-map) + (add-hook 'pre-command-hook #'transient--pre-command) + (add-hook 'post-command-hook #'transient--post-command)) + +(defun transient--recursive-edit (fn) + (transient--debug 'recursive-edit) + (if (not transient--prefix) + (funcall fn) + (transient--suspend-override (bound-and-true-p edebug-active)) + (funcall fn) ; Already unwind protected. + (cond ((memq this-command '(top-level abort-recursive-edit)) + (setq transient--exitp t) + (transient--post-exit) + (transient--delete-window)) + (transient--prefix + (transient--resume-override))))) + +(defmacro transient--with-suspended-override (&rest body) + (let ((depth (make-symbol "depth")) + (setup (make-symbol "setup")) + (exit (make-symbol "exit"))) + `(if (and transient--transient-map + (memq transient--transient-map + overriding-terminal-local-map)) + (let ((,depth (1+ (minibuffer-depth))) ,setup ,exit) + (setq ,setup + (lambda () "@transient--with-suspended-override" + (transient--debug 'minibuffer-setup) + (remove-hook 'minibuffer-setup-hook ,setup) + (transient--suspend-override))) + (setq ,exit + (lambda () "@transient--with-suspended-override" + (transient--debug 'minibuffer-exit) + (when (= (minibuffer-depth) ,depth) + (transient--resume-override)))) + (unwind-protect + (progn + (add-hook 'minibuffer-setup-hook ,setup) + (add-hook 'minibuffer-exit-hook ,exit) + ,@body) + (remove-hook 'minibuffer-setup-hook ,setup) + (remove-hook 'minibuffer-exit-hook ,exit))) + ,@body))) + +(static-if (>= emacs-major-version 30) ;transient--wrap-command + (defun transient--wrap-command () + (cl-assert + (>= emacs-major-version 30) nil + "Emacs was downgraded, making it necessary to recompile Transient") + (letrec + ((prefix transient--prefix) + (suffix this-command) + (advice + (lambda (fn &rest args) + (interactive + (lambda (spec) + (let ((abort t)) + (unwind-protect + (prog1 (let ((debugger #'transient--exit-and-debug)) + (advice-eval-interactive-spec spec)) + (setq abort nil)) + (when abort + (when-let ((unwind (oref prefix unwind-suffix))) + (transient--debug 'unwind-interactive) + (funcall unwind suffix)) + (advice-remove suffix advice) + (oset prefix unwind-suffix nil)))))) + (unwind-protect + (let ((debugger #'transient--exit-and-debug)) + (apply fn args)) + (when-let ((unwind (oref prefix unwind-suffix))) + (transient--debug 'unwind-command) + (funcall unwind suffix)) + (advice-remove suffix advice) + (oset prefix unwind-suffix nil))))) + (when (symbolp this-command) + (advice-add suffix :around advice '((depth . -99)))))) + + (defun transient--wrap-command () + (let* ((prefix transient--prefix) + (suffix this-command) + (advice nil) + (advice-interactive + (lambda (spec) + (let ((abort t)) + (unwind-protect + (prog1 (let ((debugger #'transient--exit-and-debug)) + (advice-eval-interactive-spec spec)) + (setq abort nil)) + (when abort + (when-let ((unwind (oref prefix unwind-suffix))) + (transient--debug 'unwind-interactive) + (funcall unwind suffix)) + (advice-remove suffix advice) + (oset prefix unwind-suffix nil)))))) + (advice-body + (lambda (fn &rest args) + (unwind-protect + (let ((debugger #'transient--exit-and-debug)) + (apply fn args)) + (when-let ((unwind (oref prefix unwind-suffix))) + (transient--debug 'unwind-command) + (funcall unwind suffix)) + (advice-remove suffix advice) + (oset prefix unwind-suffix nil))))) + (setq advice `(lambda (fn &rest args) + (interactive ,advice-interactive) + (apply ',advice-body fn args))) + (when (symbolp this-command) + (advice-add suffix :around advice '((depth . -99))))))) + +(defun transient--premature-post-command () + (and (equal (this-command-keys-vector) []) + (= (minibuffer-depth) + (1+ transient--minibuffer-depth)) + (progn + (transient--debug 'premature-post-command) + (transient--suspend-override) + (oset (or transient--prefix transient-current-prefix) + unwind-suffix + (if transient--exitp + #'transient--post-exit + #'transient--resume-override)) + t))) + +(defun transient--post-command () + (unless (transient--premature-post-command) + (transient--debug 'post-command) + (transient--with-emergency-exit :post-command + (cond (transient--exitp (transient--post-exit)) + ;; If `this-command' is the current transient prefix, then we + ;; have already taken care of updating the transient buffer... + ((and (eq this-command (oref transient--prefix command)) + ;; ... but if `prefix-arg' is non-nil, then the values + ;; of `this-command' and `real-this-command' are untrue + ;; because `prefix-command-preserve-state' changes them. + ;; We cannot use `current-prefix-arg' because it is set + ;; too late (in `command-execute'), and if it were set + ;; earlier, then we likely still would not be able to + ;; rely on it and `prefix-command-preserve-state-hook' + ;; would have to be used to record that a universal + ;; argument is in effect. + (not prefix-arg))) + (transient--refreshp + (transient--refresh-transient)) + ((let ((old transient--redisplay-map) + (new (transient--make-redisplay-map))) + (unless (equal old new) + (transient--pop-keymap 'transient--redisplay-map) + (setq transient--redisplay-map new) + (transient--push-keymap 'transient--redisplay-map)) + (transient--redisplay))))))) + +(defun transient--post-exit (&optional command) + (transient--debug 'post-exit) + (unless (and (eq transient--exitp 'replace) + (or transient--prefix + ;; The current command could act as a prefix, + ;; but decided not to call `transient-setup', + ;; or it is prevented from doing so because it + ;; uses the minibuffer and the user aborted + ;; that. + (prog1 nil + (if (let ((obj (transient-suffix-object command))) + (and (slot-boundp obj 'transient) + (oref obj transient))) + ;; This sub-prefix is a transient suffix; + ;; go back to outer prefix, by calling + ;; `transient--stack-pop' further down. + (setq transient--exitp nil) + (transient--stack-zap))))) + (remove-hook 'pre-command-hook #'transient--pre-command) + (remove-hook 'post-command-hook #'transient--post-command) + (advice-remove 'recursive-edit #'transient--recursive-edit)) + (setq transient-current-prefix nil) + (setq transient-current-command nil) + (setq transient-current-suffixes nil) + (let ((resume (and transient--stack + (not (memq transient--exitp '(replace suspend)))))) + (unless (or resume (eq transient--exitp 'replace)) + (setq transient--showp nil)) + (setq transient--exitp nil) + (setq transient--helpp nil) + (setq transient--editp nil) + (setq transient--all-levels-p nil) + (setq transient--minibuffer-depth 0) + (run-hooks 'transient-exit-hook) + (when resume + (transient--stack-pop)))) + +(defun transient--stack-push () + (transient--debug 'stack-push) + (push (list (oref transient--prefix command) + transient--layout + transient--editp + :transient-suffix (oref transient--prefix transient-suffix) + :scope (oref transient--prefix scope)) + transient--stack)) + +(defun transient--stack-pop () + (transient--debug 'stack-pop) + (and transient--stack + (prog1 t (apply #'transient-setup (pop transient--stack))))) + +(defun transient--stack-zap () + (transient--debug 'stack-zap) + (setq transient--stack nil)) + +(defun transient--redisplay () + (if (or (eq transient-show-popup t) + transient--showp) + (unless + (or (memq this-command transient--scroll-commands) + (and (or (memq this-command '(mouse-drag-region + mouse-set-region)) + (equal (key-description (this-command-keys-vector)) + "<mouse-movement>")) + (and (eq (current-buffer) transient--buffer)))) + (transient--show)) + (when (and (numberp transient-show-popup) + (not (zerop transient-show-popup)) + (not transient--timer)) + (transient--timer-start)) + (transient--show-brief))) + +(defun transient--timer-start () + (setq transient--timer + (run-at-time (abs transient-show-popup) nil + (lambda () + (transient--timer-cancel) + (transient--show) + (let ((message-log-max nil)) + (message "")))))) + +(defun transient--timer-cancel () + (when transient--timer + (cancel-timer transient--timer) + (setq transient--timer nil))) + +(defun transient--debug (arg &rest args) + (when transient--debug + (let ((inhibit-message (not (eq transient--debug 'message)))) + (if (symbolp arg) + (message "-- %-22s (cmd: %s, event: %S, exit: %s%s)" + arg + (cond ((and (symbolp this-command) this-command)) + ((fboundp 'help-fns-function-name) + (help-fns-function-name this-command)) + ((byte-code-function-p this-command) + "#[...]") + (this-command)) + (key-description (this-command-keys-vector)) + transient--exitp + (cond ((keywordp (car args)) + (format ", from: %s" + (substring (symbol-name (car args)) 1))) + ((stringp (car args)) + (concat ", " (apply #'format args))) + ((functionp (car args)) + (concat ", " (apply (car args) (cdr args)))) + (""))) + (apply #'message arg args))))) + +(defun transient--emergency-exit (&optional id) + "Exit the current transient command after an error occurred. +When no transient is active (i.e., when `transient--prefix' is +nil) then do nothing. Optional ID is a keyword identifying the +exit." + (transient--debug 'emergency-exit id) + (when transient--prefix + (setq transient--stack nil) + (setq transient--exitp t) + (transient--pre-exit) + (transient--post-exit))) + +;;; Pre-Commands + +(defun transient--call-pre-command () + (if-let ((fn (transient--get-pre-command this-command))) + (let ((action (funcall fn))) + (when (eq action transient--exit) + (setq transient--exitp (or transient--exitp t))) + action) + (if (let ((keys (this-command-keys-vector))) + (eq (aref keys (1- (length keys))) ?\C-g)) + (setq this-command 'transient-noop) + (unless (transient--edebug-command-p) + (setq this-command 'transient-undefined))) + transient--stay)) + +(defun transient--get-pre-command (&optional cmd enforce-type) + (or (and (not (eq enforce-type 'non-suffix)) + (symbolp cmd) + (lookup-key transient--predicate-map (vector cmd))) + (and (not (eq enforce-type 'suffix)) + (transient--resolve-pre-command + (oref transient--prefix transient-non-suffix) + t)))) + +(defun transient--resolve-pre-command (pre &optional resolve-boolean) + (cond ((booleanp pre) + (if resolve-boolean + (if pre #'transient--do-stay #'transient--do-warn) + pre)) + ((string-match-p "--do-" (symbol-name pre)) pre) + ((let ((sym (intern (format "transient--do-%s" pre)))) + (if (functionp sym) sym pre))))) + +(defun transient--do-stay () + "Call the command without exporting variables and stay transient." + transient--stay) + +(defun transient--do-noop () + "Call `transient-noop' and stay transient." + (setq this-command 'transient-noop) + transient--stay) + +(defun transient--do-warn () + "Call `transient-undefined' and stay transient." + (setq this-command 'transient-undefined) + transient--stay) + +(defun transient--do-warn-inapt () + "Call `transient-inapt' and stay transient." + (setq this-command 'transient-inapt) + transient--stay) + +(defun transient--do-call () + "Call the command after exporting variables and stay transient." + (transient--export) + transient--stay) + +(defun transient--do-return () + "Call the command after exporting variables and return to parent prefix. +If there is no parent prefix, then behave like `transient--do-exit'." + (if (not transient--stack) + (transient--do-exit) + (transient--export) + transient--exit)) + +(defun transient--do-exit () + "Call the command after exporting variables and exit the transient." + (transient--export) + (transient--stack-zap) + transient--exit) + +(defun transient--do-leave () + "Call the command without exporting variables and exit the transient." + (transient--stack-zap) + transient--exit) + +(defun transient--do-push-button () + "Call the command represented by the activated button. +Use that command's pre-command to determine transient behavior." + (if (and (mouse-event-p last-command-event) + (not (eq (posn-window (event-start last-command-event)) + transient--window))) + transient--stay + (setq this-command + (with-selected-window transient--window + (get-text-property (if (mouse-event-p last-command-event) + (posn-point (event-start last-command-event)) + (point)) + 'command))) + (transient--call-pre-command))) + +(defun transient--do-recurse () + "Call the transient prefix command, preparing for return to active transient. +If there is no parent prefix, then just call the command." + (transient--do-stack)) + +(defun transient--setup-recursion (prefix-obj) + (when transient--stack + (let ((command (oref prefix-obj command))) + (when-let ((suffix-obj (transient-suffix-object command))) + (when (memq (if (slot-boundp suffix-obj 'transient) + (oref suffix-obj transient) + (oref transient-current-prefix transient-suffix)) + (list t #'transient--do-recurse)) + (oset prefix-obj transient-suffix t)))))) + +(defun transient--do-stack () + "Call the transient prefix command, stacking the active transient. +Push the active transient to the transient stack." + (transient--export) + (transient--stack-push) + (setq transient--exitp 'replace) + transient--exit) + +(defun transient--do-replace () + "Call the transient prefix command, replacing the active transient. +Do not push the active transient to the transient stack." + (transient--export) + (setq transient--exitp 'replace) + transient--exit) + +(defun transient--do-suspend () + "Suspend the active transient, saving the transient stack." + (transient--stack-push) + (setq transient--exitp 'suspend) + transient--exit) + +(defun transient--do-quit-one () + "If active, quit help or edit mode, else exit the active transient." + (cond (transient--helpp + (setq transient--helpp nil) + transient--stay) + (transient--editp + (setq transient--editp nil) + (transient-setup) + transient--stay) + (prefix-arg + transient--stay) + (transient--exit))) + +(defun transient--do-quit-all () + "Exit all transients without saving the transient stack." + (transient--stack-zap) + transient--exit) + +(defun transient--do-move () + "Call the command if `transient-enable-popup-navigation' is non-nil. +In that case behave like `transient--do-stay', otherwise similar +to `transient--do-warn'." + (unless transient-enable-popup-navigation + (setq this-command 'transient-inhibit-move)) + transient--stay) + +(defun transient--do-minus () + "Call `negative-argument' or pivot to `transient-update'. +If `negative-argument' is invoked using \"-\" then preserve the +prefix argument and pivot to `transient-update'." + (when (equal (this-command-keys) "-") + (setq this-command 'transient-update)) + transient--stay) + +(put 'transient--do-stay 'transient-face 'transient-key-stay) +(put 'transient--do-noop 'transient-face 'transient-key-noop) +(put 'transient--do-warn 'transient-face 'transient-key-noop) +(put 'transient--do-warn-inapt 'transient-face 'transient-key-noop) +(put 'transient--do-call 'transient-face 'transient-key-stay) +(put 'transient--do-return 'transient-face 'transient-key-return) +(put 'transient--do-exit 'transient-face 'transient-key-exit) +(put 'transient--do-leave 'transient-face 'transient-key-exit) + +(put 'transient--do-recurse 'transient-face 'transient-key-stay) +(put 'transient--do-stack 'transient-face 'transient-key-stay) +(put 'transient--do-replace 'transient-face 'transient-key-exit) +(put 'transient--do-suspend 'transient-face 'transient-key-exit) + +(put 'transient--do-quit-one 'transient-face 'transient-key-return) +(put 'transient--do-quit-all 'transient-face 'transient-key-exit) +(put 'transient--do-move 'transient-face 'transient-key-stay) +(put 'transient--do-minus 'transient-face 'transient-key-stay) + +;;; Commands +;;;; Noop + +(defun transient-noop () + "Do nothing at all." + (interactive)) + +(defun transient-undefined () + "Warn the user that the pressed key is not bound to any suffix." + (interactive) + (transient--invalid "Unbound suffix")) + +(defun transient-inapt () + "Warn the user that the invoked command is inapt." + (interactive) + (transient--invalid "Inapt command")) + +(defun transient--invalid (msg) + (ding) + (message "%s: `%s' (Use `%s' to abort, `%s' for help)%s" + msg + (propertize (key-description (this-single-command-keys)) + 'face 'font-lock-warning-face) + (propertize "C-g" 'face 'transient-key) + (propertize "?" 'face 'transient-key) + ;; `this-command' is `transient-undefined' or `transient-inapt'. + ;; Show the command (`this-original-command') the user actually + ;; tried to invoke. + (if-let ((cmd (or (ignore-errors (symbol-name this-original-command)) + (ignore-errors (symbol-name this-command))))) + (format " [%s]" (propertize cmd 'face 'font-lock-warning-face)) + "")) + (unless (and transient--transient-map + (memq transient--transient-map overriding-terminal-local-map)) + (let ((transient--prefix (or transient--prefix 'sic))) + (transient--emergency-exit)) + (view-lossage) + (other-window 1) + (display-warning 'transient "Inconsistent transient state detected. +This should never happen. +Please open an issue and post the shown command log." :error))) + +(defun transient-inhibit-move () + "Warn the user that popup navigation is disabled." + (interactive) + (message "To enable use of `%s', please customize `%s'" + this-original-command + 'transient-enable-popup-navigation)) + +;;;; Core + +(defun transient-quit-all () + "Exit all transients without saving the transient stack." + (interactive)) + +(defun transient-quit-one () + "Exit the current transients, returning to outer transient, if any." + (interactive)) + +(defun transient-quit-seq () + "Abort the current incomplete key sequence." + (interactive)) + +(defun transient-update () + "Redraw the transient's state in the popup buffer." + (interactive) + (setq prefix-arg current-prefix-arg)) + +(defun transient-show () + "Show the transient's state in the popup buffer." + (interactive) + (setq transient--showp t)) + +(defun transient-push-button () + "Invoke the suffix command represented by this button." + (interactive)) + +;;;; Suspend + +(defun transient-suspend () + "Suspend the current transient. +It can later be resumed using `transient-resume', while no other +transient is active." + (interactive)) + +(define-minor-mode transient-resume-mode + "Auxiliary minor-mode used to resume a transient after viewing help.") + +(defun transient-resume () + "Resume a previously suspended stack of transients." + (interactive) + (cond (transient--stack + (let ((winconf transient--restore-winconf)) + (kill-local-variable 'transient--restore-winconf) + (when transient-resume-mode + (transient-resume-mode -1) + (quit-window)) + (when winconf + (set-window-configuration winconf))) + (transient--stack-pop)) + (transient-resume-mode + (kill-local-variable 'transient--restore-winconf) + (transient-resume-mode -1) + (quit-window)) + (t + (message "No suspended transient command")))) + +;;;; Help + +(defun transient-help (&optional interactive) + "Show help for the active transient or one of its suffixes.\n\n(fn)" + (interactive (list t)) + (if interactive + (setq transient--helpp t) + (with-demoted-errors "transient-help: %S" + (when (lookup-key transient--transient-map + (this-single-command-raw-keys)) + (setq transient--helpp nil) + (let ((winconf (current-window-configuration))) + (transient-show-help + (if (eq this-original-command 'transient-help) + transient--prefix + (or (transient-suffix-object) + this-original-command))) + (setq-local transient--restore-winconf winconf)) + (fit-window-to-buffer nil (frame-height) (window-height)) + (transient-resume-mode) + (message (substitute-command-keys + "Type \\`q' to resume transient command.")) + t)))) + +;;;; Level + +(defun transient-set-level (&optional command level) + "Set the level of the transient or one of its suffix commands." + (interactive + (let ((command this-original-command) + (prefix (oref transient--prefix command))) + (and (or (not (eq command 'transient-set-level)) + (and transient--editp + (setq command prefix))) + (list command + (let ((keys (this-single-command-raw-keys))) + (and (lookup-key transient--transient-map keys) + (progn + (transient--show) + (string-to-number + (transient--read-number-N + (format "Set level for `%s': " command) + nil nil (not (eq command prefix))))))))))) + (cond + ((not command) + (setq transient--editp t) + (transient-setup)) + (level + (let* ((prefix (oref transient--prefix command)) + (alist (alist-get prefix transient-levels)) + (akey command)) + (cond ((eq command prefix) + (oset transient--prefix level level) + (setq akey t)) + (t + (oset (transient-suffix-object command) level level) + (when (cdr (cl-remove-if-not (lambda (obj) + (eq (oref obj command) command)) + transient--suffixes)) + (setq akey (cons command (this-command-keys)))))) + (setf (alist-get akey alist) level) + (setf (alist-get prefix transient-levels) alist)) + (transient-save-levels) + (transient--show)) + (t + (transient-undefined)))) + +(transient-define-suffix transient-toggle-level-limit () + "Toggle whether to temporarily displayed suffixes on all levels." + :description + (lambda () + (cond + ((= transient-default-level transient--max-level) + "Always displaying all levels") + (transient--all-levels-p + (format "Hide suffix %s" + (propertize + (format "levels > %s" (oref (transient-prefix-object) level)) + 'face 'transient-higher-level))) + ("Show all suffix levels"))) + :inapt-if (lambda () (= transient-default-level transient--max-level)) + :transient t + (interactive) + (setq transient--all-levels-p (not transient--all-levels-p)) + (setq transient--refreshp t)) + +;;;; Value + +(defun transient-set () + "Set active transient's value for this Emacs session." + (interactive) + (transient-set-value (transient-prefix-object))) + +(defalias 'transient-set-and-exit #'transient-set + "Set active transient's value for this Emacs session and exit.") + +(defun transient-save () + "Save active transient's value for this and future Emacs sessions." + (interactive) + (transient-save-value (transient-prefix-object))) + +(defalias 'transient-save-and-exit #'transient-save + "Save active transient's value for this and future Emacs sessions and exit.") + +(defun transient-reset () + "Clear the set and saved values of the active transient." + (interactive) + (transient-reset-value (transient-prefix-object))) + +(defun transient-history-next () + "Switch to the next value used for the active transient." + (interactive) + (let* ((obj transient--prefix) + (pos (1- (oref obj history-pos))) + (hst (oref obj history))) + (if (< pos 0) + (user-error "End of history") + (oset obj history-pos pos) + (oset obj value (nth pos hst)) + (mapc #'transient-init-value transient--suffixes)))) + +(defun transient-history-prev () + "Switch to the previous value used for the active transient." + (interactive) + (let* ((obj transient--prefix) + (pos (1+ (oref obj history-pos))) + (hst (oref obj history)) + (len (length hst))) + (if (> pos (1- len)) + (user-error "End of history") + (oset obj history-pos pos) + (oset obj value (nth pos hst)) + (mapc #'transient-init-value transient--suffixes)))) + +;;;; Auxiliary + +(defun transient-toggle-common () + "Toggle whether common commands are permanently shown." + (interactive) + (setq transient-show-common-commands (not transient-show-common-commands))) + +(defun transient-toggle-debug () + "Toggle debugging statements for transient commands." + (interactive) + (setq transient--debug (not transient--debug)) + (message "Debugging transient %s" + (if transient--debug "enabled" "disabled"))) + +(transient-define-suffix transient-echo-arguments (arguments) + "Show the transient's active ARGUMENTS in the echo area. +Intended for use in prefixes used for demonstration purposes, +such as when suggesting a new feature or reporting an issue." + :transient t + :description "Echo arguments" + :key "x" + (interactive (list (transient-args transient-current-command))) + (message "%s: %s" + (key-description (this-command-keys)) + (mapconcat (lambda (arg) + (propertize (if (string-match-p " " arg) + (format "%S" arg) + arg) + 'face 'transient-argument)) + arguments " "))) + +;;; Value +;;;; Init + +(cl-defgeneric transient-init-scope (obj) + "Set the scope of the suffix object OBJ. + +The scope is actually a property of the transient prefix, not of +individual suffixes. However it is possible to invoke a suffix +command directly instead of from a transient. In that case, if +the suffix expects a scope, then it has to determine that itself +and store it in its `scope' slot. + +This function is called for all suffix commands, but unless a +concrete method is implemented this falls through to the default +implementation, which is a noop.") + +(cl-defmethod transient-init-scope ((_ transient-suffix)) + "Noop." nil) + +(cl-defgeneric transient-init-value (_) + "Set the initial value of the object OBJ. + +This function is called for all prefix and suffix commands. + +For suffix commands (including infix argument commands) the +default implementation is a noop. Classes derived from the +abstract `transient-infix' class must implement this function. +Non-infix suffix commands usually don't have a value." + nil) + +(cl-defmethod transient-init-value :around ((obj transient-prefix)) + "If bound, then call OBJ's `init-value' function. +Otherwise call the primary method according to object's class." + (if (slot-boundp obj 'init-value) + (funcall (oref obj init-value) obj) + (cl-call-next-method obj))) + +(cl-defmethod transient-init-value :around ((obj transient-infix)) + "If bound, then call OBJ's `init-value' function. +Otherwise call the primary method according to object's class." + (if (slot-boundp obj 'init-value) + (funcall (oref obj init-value) obj) + (cl-call-next-method obj))) + +(cl-defmethod transient-init-value ((obj transient-prefix)) + (if (slot-boundp obj 'value) + (oref obj value) + (oset obj value + (if-let ((saved (assq (oref obj command) transient-values))) + (cdr saved) + (transient-default-value obj))))) + +(cl-defmethod transient-init-value ((obj transient-argument)) + (oset obj value + (let ((value (oref transient--prefix value)) + (argument (and (slot-boundp obj 'argument) + (oref obj argument))) + (multi-value (oref obj multi-value)) + (case-fold-search nil) + (regexp (if (slot-exists-p obj 'argument-regexp) + (oref obj argument-regexp) + (format "\\`%s\\(.*\\)" (oref obj argument))))) + (if (memq multi-value '(t rest)) + (cdr (assoc argument value)) + (let ((match (lambda (v) + (and (stringp v) + (string-match regexp v) + (match-string 1 v))))) + (if multi-value + (delq nil (mapcar match value)) + (cl-some match value))))))) + +(cl-defmethod transient-init-value ((obj transient-switch)) + (oset obj value + (car (member (oref obj argument) + (oref transient--prefix value))))) + +;;;; Default + +(cl-defgeneric transient-default-value (_) + "Return the default value." + nil) + +(cl-defmethod transient-default-value ((obj transient-prefix)) + (if-let ((default (and (slot-boundp obj 'default-value) + (oref obj default-value)))) + (if (functionp default) + (funcall default) + default) + nil)) + +;;;; Read + +(cl-defgeneric transient-infix-read (obj) + "Determine the new value of the infix object OBJ. + +This function merely determines the value; `transient-infix-set' +is used to actually store the new value in the object. + +For most infix classes this is done by reading a value from the +user using the reader specified by the `reader' slot (using the +`transient-infix' method described below). + +For some infix classes the value is changed without reading +anything in the minibuffer, i.e., the mere act of invoking the +infix command determines what the new value should be, based +on the previous value.") + +(cl-defmethod transient-infix-read :around ((obj transient-infix)) + "Refresh the transient buffer and call the next method. + +Also wrap `cl-call-next-method' with two macros: +- `transient--with-suspended-override' allows use of minibuffer. +- `transient--with-emergency-exit' arranges for the transient to + be exited in case of an error." + (transient--show) + (transient--with-emergency-exit :infix-read + (transient--with-suspended-override + (cl-call-next-method obj)))) + +(cl-defmethod transient-infix-read ((obj transient-infix)) + "Read a value while taking care of history. + +This method is suitable for a wide variety of infix commands, +including but not limited to inline arguments and variables. + +If you do not use this method for your own infix class, then +you should likely replicate a lot of the behavior of this +method. If you fail to do so, then users might not appreciate +the lack of history, for example. + +Only for very simple classes that toggle or cycle through a very +limited number of possible values should you replace this with a +simple method that does not handle history. (E.g., for a command +line switch the only possible values are \"use it\" and \"don't use +it\", in which case it is pointless to preserve history.)" + (with-slots (value multi-value always-read allow-empty choices) obj + (if (and value + (not multi-value) + (not always-read) + transient--prefix) + (oset obj value nil) + (let* ((enable-recursive-minibuffers t) + (reader (oref obj reader)) + (choices (if (functionp choices) (funcall choices) choices)) + (prompt (transient-prompt obj)) + (value (if multi-value (mapconcat #'identity value ",") value)) + (history-key (or (oref obj history-key) + (oref obj command))) + (transient--history (alist-get history-key transient-history)) + (transient--history (if (or (null value) + (eq value (car transient--history))) + transient--history + (cons value transient--history))) + (initial-input (and transient-read-with-initial-input + (car transient--history))) + (history (if initial-input + (cons 'transient--history 1) + 'transient--history)) + (value + (cond + (reader (funcall reader prompt initial-input history)) + (multi-value + (completing-read-multiple prompt choices nil nil + initial-input history)) + (choices + (completing-read prompt choices nil t initial-input history)) + ((read-string prompt initial-input history))))) + (cond ((and (equal value "") (not allow-empty)) + (setq value nil)) + ((and (equal value "\"\"") allow-empty) + (setq value ""))) + (when value + (when (and (bound-and-true-p ivy-mode) + (stringp (car transient--history))) + (set-text-properties 0 (length (car transient--history)) nil + (car transient--history))) + (setf (alist-get history-key transient-history) + (delete-dups transient--history))) + value)))) + +(cl-defmethod transient-infix-read ((obj transient-switch)) + "Toggle the switch on or off." + (if (oref obj value) nil (oref obj argument))) + +(cl-defmethod transient-infix-read ((obj transient-switches)) + "Cycle through the mutually exclusive switches. +The last value is \"don't use any of these switches\"." + (let ((choices (mapcar (apply-partially #'format (oref obj argument-format)) + (oref obj choices)))) + (if-let ((value (oref obj value))) + (cadr (member value choices)) + (car choices)))) + +(cl-defmethod transient-infix-read ((command symbol)) + "Elsewhere use the reader of the infix command COMMAND. +Use this if you want to share an infix's history with a regular +stand-alone command." + (if-let ((obj (transient--suffix-prototype command))) + (cl-letf (((symbol-function #'transient--show) #'ignore)) + (transient-infix-read obj)) + (error "Not a suffix command: `%s'" command))) + +;;;; Readers + +(defun transient-read-file (prompt _initial-input _history) + "Read a file." + (file-local-name (expand-file-name (read-file-name prompt)))) + +(defun transient-read-existing-file (prompt _initial-input _history) + "Read an existing file." + (file-local-name (expand-file-name (read-file-name prompt nil nil t)))) + +(defun transient-read-directory (prompt _initial-input _history) + "Read a directory." + (file-local-name (expand-file-name (read-directory-name prompt)))) + +(defun transient-read-existing-directory (prompt _initial-input _history) + "Read an existing directory." + (file-local-name (expand-file-name (read-directory-name prompt nil nil t)))) + +(defun transient-read-number-N0 (prompt initial-input history) + "Read a natural number (including zero) and return it as a string." + (transient--read-number-N prompt initial-input history t)) + +(defun transient-read-number-N+ (prompt initial-input history) + "Read a natural number (excluding zero) and return it as a string." + (transient--read-number-N prompt initial-input history nil)) + +(defun transient--read-number-N (prompt initial-input history include-zero) + (save-match-data + (cl-block nil + (while t + (let ((str (read-from-minibuffer prompt initial-input nil nil history))) + (when (or (string-equal str "") + (string-match-p (if include-zero + "\\`\\(0\\|[1-9][0-9]*\\)\\'" + "\\`[1-9][0-9]*\\'") + str)) + (cl-return str))) + (message "Please enter a natural number (%s zero)." + (if include-zero "including" "excluding")) + (sit-for 1))))) + +(defun transient-read-date (prompt default-time _history) + "Read a date using `org-read-date' (which see)." + (require 'org) + (when (fboundp 'org-read-date) + (org-read-date 'with-time nil nil prompt default-time))) + +;;;; Prompt + +(cl-defgeneric transient-prompt (obj) + "Return the prompt to be used to read infix object OBJ's value.") + +(cl-defmethod transient-prompt ((obj transient-infix)) + "Return the prompt to be used to read infix object OBJ's value. + +This implementation should be suitable for almost all infix +commands. + +If the value of OBJ's `prompt' slot is non-nil, then it must be +a string or a function. If it is a string, then use that. If +it is a function, then call that with OBJ as the only argument. +That function must return a string, which is then used as the +prompt. + +Otherwise, if the value of either the `argument' or `variable' +slot of OBJ is a string, then base the prompt on that (preferring +the former), appending either \"=\" (if it appears to be a +command-line option) or \": \". + +Finally fall through to using \"(BUG: no prompt): \" as the +prompt." + (if-let ((prompt (oref obj prompt))) + (let ((prompt (if (functionp prompt) + (funcall prompt obj) + prompt))) + (if (stringp prompt) + prompt + "(BUG: no prompt): ")) + (or (and-let* ((arg (and (slot-boundp obj 'argument) (oref obj argument)))) + (if (and (stringp arg) (string-suffix-p "=" arg)) + arg + (concat arg ": "))) + (and-let* ((var (and (slot-boundp obj 'variable) (oref obj variable)))) + (and (stringp var) + (concat var ": "))) + "(BUG: no prompt): "))) + +;;;; Set + +(cl-defgeneric transient-infix-set (obj value) + "Set the value of infix object OBJ to value.") + +(cl-defmethod transient-infix-set ((obj transient-infix) value) + "Set the value of infix object OBJ to value." + (oset obj value value)) + +(cl-defmethod transient-infix-set :after ((obj transient-argument) value) + "Unset incompatible infix arguments." + (when-let* ((value) + (val (transient-infix-value obj)) + (arg (if (slot-boundp obj 'argument) + (oref obj argument) + (oref obj argument-format))) + (spec (oref transient--prefix incompatible)) + (filter (lambda (x rule) + (and (member x rule) + (remove x rule)))) + (incomp (nconc + (cl-mapcan (apply-partially filter arg) spec) + (and (not (equal val arg)) + (cl-mapcan (apply-partially filter val) spec))))) + (dolist (obj transient--suffixes) + (when-let* (((cl-typep obj 'transient-argument)) + (val (transient-infix-value obj)) + (arg (if (slot-boundp obj 'argument) + (oref obj argument) + (oref obj argument-format))) + ((if (equal val arg) + (member arg incomp) + (or (member val incomp) + (member arg incomp))))) + (transient-infix-set obj nil))))) + +(cl-defgeneric transient-set-value (obj) + "Set the value of the transient prefix OBJ.") + +(cl-defmethod transient-set-value ((obj transient-prefix)) + (oset (oref obj prototype) value (transient-get-value)) + (transient--history-push obj)) + +;;;; Save + +(cl-defgeneric transient-save-value (obj) + "Save the value of the transient prefix OBJ.") + +(cl-defmethod transient-save-value ((obj transient-prefix)) + (let ((value (transient-get-value))) + (oset (oref obj prototype) value value) + (setf (alist-get (oref obj command) transient-values) value) + (transient-save-values)) + (transient--history-push obj)) + +;;;; Reset + +(cl-defgeneric transient-reset-value (obj) + "Clear the set and saved values of the transient prefix OBJ.") + +(cl-defmethod transient-reset-value ((obj transient-prefix)) + (let ((value (transient-default-value obj))) + (oset obj value value) + (oset (oref obj prototype) value value) + (setf (alist-get (oref obj command) transient-values nil 'remove) nil) + (transient-save-values)) + (transient--history-push obj) + (mapc #'transient-init-value transient--suffixes)) + +;;;; Get + +(defun transient-args (prefix) + "Return the value of the transient prefix command PREFIX. +If the current command was invoked from the transient prefix +command PREFIX, then return the active infix arguments. If +the current command was not invoked from PREFIX, then return +the set, saved or default value for PREFIX." + (cl-mapcan #'transient--get-wrapped-value (transient-suffixes prefix))) + +(defun transient-suffixes (prefix) + "Return the suffix objects of the transient prefix command PREFIX." + (if (eq transient-current-command prefix) + transient-current-suffixes + (let ((transient--prefix (transient--init-prefix prefix))) + (transient--flatten-suffixes + (transient--init-suffixes prefix))))) + +(defun transient-get-value () + (transient--with-emergency-exit :get-value + (cl-mapcan (lambda (obj) + (and (or (not (slot-exists-p obj 'unsavable)) + (not (oref obj unsavable))) + (transient--get-wrapped-value obj))) + transient-current-suffixes))) + +(defun transient--get-wrapped-value (obj) + (and-let* ((value (transient-infix-value obj))) + (pcase-exhaustive (and (slot-exists-p obj 'multi-value) + (oref obj multi-value)) + ('nil (list value)) + ((or 't 'rest) (list value)) + ('repeat value)))) + +(cl-defgeneric transient-infix-value (obj) + "Return the value of the suffix object OBJ. + +This function is called by `transient-args' (which see), meaning +this function is how the value of a transient is determined so +that the invoked suffix command can use it. + +Currently most values are strings, but that is not set in stone. +Nil is not a value, it means \"no value\". + +Usually only infixes have a value, but see the method for +`transient-suffix'.") + +(cl-defmethod transient-infix-value ((_ transient-suffix)) + "Return nil, which means \"no value\". + +Infix arguments contribute the transient's value while suffix +commands consume it. This function is called for suffixes anyway +because a command that both contributes to the transient's value +and also consumes it is not completely unconceivable. + +If you define such a command, then you must define a derived +class and implement this function because this default method +does nothing." nil) + +(cl-defmethod transient-infix-value ((obj transient-infix)) + "Return the value of OBJ's `value' slot." + (oref obj value)) + +(cl-defmethod transient-infix-value ((obj transient-option)) + "Return ARGUMENT and VALUE as a unit or nil if the latter is nil." + (and-let* ((value (oref obj value))) + (let ((arg (oref obj argument))) + (pcase-exhaustive (oref obj multi-value) + ('nil (concat arg value)) + ((or 't 'rest) (cons arg value)) + ('repeat (mapcar (lambda (v) (concat arg v)) value)))))) + +(cl-defmethod transient-infix-value ((_ transient-variable)) + "Return nil, which means \"no value\". + +Setting the value of a variable is done by, well, setting the +value of the variable. I.e., this is a side-effect and does +not contribute to the value of the transient." + nil) + +;;;; Utilities + +(defun transient-arg-value (arg args) + "Return the value of ARG as it appears in ARGS. + +For a switch return a boolean. For an option return the value as +a string, using the empty string for the empty value, or nil if +the option does not appear in ARGS." + (if (string-suffix-p "=" arg) + (save-match-data + (and-let* ((match (let ((case-fold-search nil) + (re (format "\\`%s\\(?:=\\(.+\\)\\)?\\'" + (substring arg 0 -1)))) + (cl-find-if (lambda (a) + (and (stringp a) + (string-match re a))) + args)))) + (or (match-string 1 match) ""))) + (and (member arg args) t))) + +(defun transient-scope () + "Return the value of the `scope' slot of the current prefix." + (oref (transient-prefix-object) scope)) + +;;; History + +(cl-defgeneric transient--history-key (obj) + "Return OBJ's history key. +If the value of the `history-key' slot is non-nil, then return +that. Otherwise return the value of the `command' slot." + (or (oref obj history-key) + (oref obj command))) + +(cl-defgeneric transient--history-push (obj) + "Push the current value of OBJ to its entry in `transient-history'." + (let ((key (transient--history-key obj))) + (setf (alist-get key transient-history) + (let ((args (transient-get-value))) + (cons args (delete args (alist-get key transient-history))))))) + +(cl-defgeneric transient--history-init (obj) + "Initialize OBJ's `history' slot. +This is the transient-wide history; many individual infixes also +have a history of their own.") + +(cl-defmethod transient--history-init ((obj transient-prefix)) + "Initialize OBJ's `history' slot from the variable `transient-history'." + (let ((val (oref obj value))) + (oset obj history + (cons val (delete val (alist-get (transient--history-key obj) + transient-history)))))) + +;;; Draw + +(defun transient--show-brief () + (let ((message-log-max nil)) + (if (and transient-show-popup (<= transient-show-popup 0)) + (message "%s-" (key-description (this-command-keys))) + (message + "%s- [%s] %s" + (key-description (this-command-keys)) + (oref transient--prefix command) + (mapconcat + #'identity + (sort + (cl-mapcan + (lambda (suffix) + (let ((key (kbd (oref suffix key)))) + ;; Don't list any common commands. + (and (not (memq (oref suffix command) + `(,(lookup-key transient-map key) + ,(lookup-key transient-sticky-map key) + ;; From transient-common-commands: + transient-set + transient-save + transient-history-prev + transient-history-next + transient-quit-one + transient-toggle-common + transient-set-level))) + (list (propertize (oref suffix key) 'face 'transient-key))))) + transient--suffixes) + #'string<) + (propertize "|" 'face 'transient-delimiter)))))) + +(defun transient--show () + (transient--timer-cancel) + (setq transient--showp t) + (let ((transient--shadowed-buffer (current-buffer)) + (focus nil)) + (setq transient--buffer (get-buffer-create transient--buffer-name)) + (with-current-buffer transient--buffer + (when transient-enable-popup-navigation + (setq focus (or (button-get (point) 'command) + (and (not (bobp)) + (button-get (1- (point)) 'command)) + (transient--heading-at-point)))) + (erase-buffer) + (run-hooks 'transient-setup-buffer-hook) + (when transient-force-fixed-pitch + (transient--force-fixed-pitch)) + (setq window-size-fixed t) + (when (bound-and-true-p tab-line-format) + (setq tab-line-format nil)) + (setq header-line-format nil) + (setq mode-line-format + (if (or (natnump transient-mode-line-format) + (eq transient-mode-line-format 'line)) + nil + transient-mode-line-format)) + (setq mode-line-buffer-identification + (symbol-name (oref transient--prefix command))) + (if transient-enable-popup-navigation + (setq-local cursor-in-non-selected-windows 'box) + (setq cursor-type nil)) + (setq display-line-numbers nil) + (setq show-trailing-whitespace nil) + (transient--insert-groups) + (when (or transient--helpp transient--editp) + (transient--insert-help)) + (when-let ((line (transient--separator-line))) + (insert line))) + (unless (window-live-p transient--window) + (setq transient--window + (display-buffer transient--buffer + transient-display-buffer-action))) + (when (window-live-p transient--window) + (with-selected-window transient--window + (goto-char (point-min)) + (when transient-enable-popup-navigation + (transient--goto-button focus)) + (transient--fit-window-to-buffer transient--window))))) + +(defun transient--fit-window-to-buffer (window) + (let ((window-resize-pixelwise t) + (window-size-fixed nil)) + (if (eq (car (window-parameter window 'quit-restore)) 'other) + ;; Grow but never shrink window that previously displayed + ;; another buffer and is going to display that again. + (fit-window-to-buffer window nil (window-height window)) + (fit-window-to-buffer window nil 1)))) + +(defun transient--separator-line () + (and-let* ((height (cond ((not window-system) nil) + ((natnump transient-mode-line-format) + transient-mode-line-format) + ((eq transient-mode-line-format 'line) 1))) + (face `(,@(and (>= emacs-major-version 27) '(:extend t)) + :background + ,(or (face-foreground (transient--key-face nil 'non-suffix) + nil t) + "#gray60")))) + (concat (propertize "__" 'face face 'display `(space :height (,height))) + (propertize "\n" 'face face 'line-height t)))) + +(defmacro transient-with-shadowed-buffer (&rest body) + "While in the transient buffer, temporarly make the shadowed buffer current." + (declare (indent 0) (debug t)) + `(with-current-buffer (or transient--shadowed-buffer (current-buffer)) + ,@body)) + +(defun transient--insert-groups () + (let ((groups (cl-mapcan (lambda (group) + (let ((hide (oref group hide))) + (and (not (and (functionp hide) + (transient-with-shadowed-buffer + (funcall hide)))) + (list group)))) + transient--layout))) + (while-let ((group (pop groups))) + (transient--insert-group group) + (when groups + (insert ?\n))))) + +(defvar transient--max-group-level 1) + +(cl-defgeneric transient--insert-group (group) + "Format GROUP and its elements and insert the result.") + +(cl-defmethod transient--insert-group :around ((group transient-group)) + "Insert GROUP's description, if any." + (when-let ((desc (transient-with-shadowed-buffer + (transient-format-description group)))) + (insert desc ?\n)) + (let ((transient--max-group-level + (max (oref group level) transient--max-group-level)) + (transient--pending-group group)) + (cl-call-next-method group))) + +(cl-defmethod transient--insert-group ((group transient-row)) + (transient--maybe-pad-keys group) + (dolist (suffix (oref group suffixes)) + (insert (transient-with-shadowed-buffer (transient-format suffix))) + (insert " ")) + (insert ?\n)) + +(cl-defmethod transient--insert-group ((group transient-column)) + (transient--maybe-pad-keys group) + (dolist (suffix (oref group suffixes)) + (let ((str (transient-with-shadowed-buffer (transient-format suffix)))) + (insert str) + (unless (string-match-p ".\n\\'" str) + (insert ?\n))))) + +(cl-defmethod transient--insert-group ((group transient-columns)) + (let* ((columns + (mapcar + (lambda (column) + (transient--maybe-pad-keys column group) + (transient-with-shadowed-buffer + (let* ((transient--pending-group column) + (rows (mapcar #'transient-format (oref column suffixes)))) + (when-let ((desc (transient-format-description column))) + (push desc rows)) + (flatten-tree rows)))) + (oref group suffixes))) + (vp (or (oref transient--prefix variable-pitch) + transient-align-variable-pitch)) + (rs (apply #'max (mapcar #'length columns))) + (cs (length columns)) + (cw (mapcar (let ((widths (oref transient--prefix column-widths))) + (lambda (col) + (apply + #'max + (if-let ((min (pop widths))) + (if vp (* min (transient--pixel-width " ")) min) + 0) + (mapcar (if vp #'transient--pixel-width #'length) + col)))) + columns)) + (cc (transient--seq-reductions-from + (apply-partially #'+ (* 3 (if vp (transient--pixel-width " ") 1))) + cw 0))) + (if transient-force-single-column + (dotimes (c cs) + (dotimes (r rs) + (when-let ((cell (nth r (nth c columns)))) + (unless (equal cell "") + (insert cell ?\n)))) + (unless (= c (1- cs)) + (insert ?\n))) + (dotimes (r rs) + (dotimes (c cs) + (if vp + (progn + (when-let ((cell (nth r (nth c columns)))) + (insert cell)) + (if (= c (1- cs)) + (insert ?\n) + (insert (propertize " " 'display + `(space :align-to (,(nth (1+ c) cc))))))) + (when (> c 0) + (insert (make-string (max 1 (- (nth c cc) (current-column))) + ?\s))) + (when-let ((cell (nth r (nth c columns)))) + (insert cell)) + (when (= c (1- cs)) + (insert ?\n)))))))) + +(cl-defmethod transient--insert-group ((group transient-subgroups)) + (let ((subgroups (oref group suffixes))) + (while-let ((subgroup (pop subgroups))) + (transient--maybe-pad-keys subgroup group) + (transient--insert-group subgroup) + (when subgroups + (insert ?\n))))) + +(cl-defgeneric transient-format (obj) + "Format and return OBJ for display. + +When this function is called, then the current buffer is some +temporary buffer. If you need the buffer from which the prefix +command was invoked to be current, then do so by temporarily +making `transient--original-buffer' current.") + +(cl-defmethod transient-format ((arg string)) + "Return the string ARG after applying the `transient-heading' face." + (propertize arg 'face 'transient-heading)) + +(cl-defmethod transient-format ((_ null)) + "Return a string containing just the newline character." + "\n") + +(cl-defmethod transient-format ((arg integer)) + "Return a string containing just the ARG character." + (char-to-string arg)) + +(cl-defmethod transient-format :around ((obj transient-suffix)) + "Add additional formatting if appropriate. +When reading user input for this infix, then highlight it. +When edit-mode is enabled, then prepend the level information. +When `transient-enable-popup-navigation' is non-nil then format +as a button." + (let ((str (cl-call-next-method obj))) + (when (and (cl-typep obj 'transient-infix) + (eq (oref obj command) this-original-command) + (active-minibuffer-window)) + (setq str (transient--add-face str 'transient-active-infix))) + (when transient--editp + (setq str (concat (let ((level (oref obj level))) + (propertize (format " %s " level) + 'face (if (transient--use-level-p level t) + 'transient-enabled-suffix + 'transient-disabled-suffix))) + str))) + (when (and transient-enable-popup-navigation + (slot-boundp obj 'command)) + (setq str (make-text-button str nil + 'type 'transient + 'command (oref obj command)))) + str)) + +(cl-defmethod transient-format ((obj transient-infix)) + "Return a string generated using OBJ's `format'. +%k is formatted using `transient-format-key'. +%d is formatted using `transient-format-description'. +%v is formatted using `transient-format-value'." + (format-spec (oref obj format) + `((?k . ,(transient-format-key obj)) + (?d . ,(transient-format-description obj)) + (?v . ,(transient-format-value obj))))) + +(cl-defmethod transient-format ((obj transient-suffix)) + "Return a string generated using OBJ's `format'. +%k is formatted using `transient-format-key'. +%d is formatted using `transient-format-description'." + (format-spec (oref obj format) + `((?k . ,(transient-format-key obj)) + (?d . ,(transient-format-description obj))))) + +(cl-defgeneric transient-format-key (obj) + "Format OBJ's `key' for display and return the result.") + +(cl-defmethod transient-format-key :around ((obj transient-suffix)) + "Add `transient-inapt-suffix' face if suffix is inapt." + (let ((str (cl-call-next-method))) + (if (oref obj inapt) + (transient--add-face str 'transient-inapt-suffix) + str))) + +(cl-defmethod transient-format-key ((obj transient-suffix)) + "Format OBJ's `key' for display and return the result." + (let ((key (if (slot-boundp obj 'key) (oref obj key) "")) + (cmd (and (slot-boundp obj 'command) (oref obj command)))) + (when-let ((width (oref transient--pending-group pad-keys))) + (setq key (truncate-string-to-width key width nil ?\s))) + (if transient--redisplay-key + (let ((len (length transient--redisplay-key)) + (seq (cl-coerce (edmacro-parse-keys key t) 'list))) + (cond + ((member (seq-take seq len) + (list transient--redisplay-key + (thread-last transient--redisplay-key + (cl-substitute ?- 'kp-subtract) + (cl-substitute ?= 'kp-equal) + (cl-substitute ?+ 'kp-add)))) + (let ((pre (key-description (vconcat (seq-take seq len)))) + (suf (key-description (vconcat (seq-drop seq len))))) + (setq pre (string-replace "RET" "C-m" pre)) + (setq pre (string-replace "TAB" "C-i" pre)) + (setq suf (string-replace "RET" "C-m" suf)) + (setq suf (string-replace "TAB" "C-i" suf)) + ;; We use e.g., "-k" instead of the more correct "- k", + ;; because the former is prettier. If we did that in + ;; the definition, then we want to drop the space that + ;; is reinserted above. False-positives are possible + ;; for silly bindings like "-C-c C-c". + (unless (string-search " " key) + (setq pre (string-replace " " "" pre)) + (setq suf (string-replace " " "" suf))) + (concat (propertize pre 'face 'transient-unreachable-key) + (and (string-prefix-p (concat pre " ") key) " ") + (propertize suf 'face (transient--key-face cmd)) + (save-excursion + (and (string-match " +\\'" key) + (propertize (match-string 0 key) + 'face 'fixed-pitch)))))) + ((transient--lookup-key transient-sticky-map (kbd key)) + (propertize key 'face (transient--key-face cmd))) + (t + (propertize key 'face 'transient-unreachable-key)))) + (propertize key 'face (transient--key-face cmd))))) + +(cl-defmethod transient-format-key :around ((obj transient-argument)) + "Handle `transient-highlight-mismatched-keys'." + (let ((key (cl-call-next-method obj))) + (cond + ((not transient-highlight-mismatched-keys) key) + ((not (slot-boundp obj 'shortarg)) + (transient--add-face key 'transient-nonstandard-key)) + ((not (string-equal key (oref obj shortarg))) + (transient--add-face key 'transient-mismatched-key)) + (key)))) + +(cl-defgeneric transient-format-description (obj) + "Format OBJ's `description' for display and return the result.") + +(cl-defmethod transient-format-description ((obj transient-suffix)) + "The `description' slot may be a function, in which case that is +called inside the correct buffer (see `transient--insert-group') +and its value is returned to the caller." + (transient--get-description obj)) + +(cl-defmethod transient-format-description ((obj transient-group)) + "Format the description by calling the next method. If the result +doesn't use the `face' property at all, then apply the face +`transient-heading' to the complete string." + (and-let* ((desc (transient--get-description obj))) + (cond ((oref obj inapt) + (propertize desc 'face 'transient-inapt-suffix)) + ((text-property-not-all 0 (length desc) 'face nil desc) + desc) + ((propertize desc 'face 'transient-heading))))) + +(cl-defmethod transient-format-description :around ((obj transient-suffix)) + "Format the description by calling the next method. If the result +is nil, then use \"(BUG: no description)\" as the description. +If the OBJ's `key' is currently unreachable, then apply the face +`transient-unreachable' to the complete string." + (let ((desc (or (cl-call-next-method obj) + (and (slot-boundp transient--prefix 'suffix-description) + (funcall (oref transient--prefix suffix-description) + obj))))) + (if desc + (when-let ((face (transient--get-face obj 'face))) + (setq desc (transient--add-face desc face t))) + (setq desc (propertize "(BUG: no description)" 'face 'error))) + (when (if transient--all-levels-p + (> (oref obj level) transient--default-prefix-level) + (and transient-highlight-higher-levels + (> (max (oref obj level) transient--max-group-level) + transient--default-prefix-level))) + (setq desc (transient--add-face desc 'transient-higher-level))) + (when-let ((inapt-face (and (oref obj inapt) + (transient--get-face obj 'inapt-face)))) + (setq desc (transient--add-face desc inapt-face))) + (when (and (slot-boundp obj 'key) + (transient--key-unreachable-p obj)) + (setq desc (transient--add-face desc 'transient-unreachable))) + desc)) + +(cl-defgeneric transient-format-value (obj) + "Format OBJ's value for display and return the result.") + +(cl-defmethod transient-format-value ((obj transient-suffix)) + (propertize (oref obj argument) + 'face (if (oref obj value) + 'transient-argument + 'transient-inactive-argument))) + +(cl-defmethod transient-format-value ((obj transient-option)) + (let ((argument (oref obj argument))) + (if-let ((value (oref obj value))) + (pcase-exhaustive (oref obj multi-value) + ('nil + (concat (propertize argument 'face 'transient-argument) + (propertize value 'face 'transient-value))) + ((or 't 'rest) + (concat (propertize (if (string-suffix-p " " argument) + argument + (concat argument " ")) + 'face 'transient-argument) + (propertize (mapconcat #'prin1-to-string value " ") + 'face 'transient-value))) + ('repeat + (mapconcat (lambda (value) + (concat (propertize argument 'face 'transient-argument) + (propertize value 'face 'transient-value))) + value " "))) + (propertize argument 'face 'transient-inactive-argument)))) + +(cl-defmethod transient-format-value ((obj transient-switches)) + (with-slots (value argument-format choices) obj + (format (propertize argument-format + 'face (if value + 'transient-argument + 'transient-inactive-argument)) + (format + (propertize "[%s]" 'face 'transient-delimiter) + (mapconcat + (lambda (choice) + (propertize choice 'face + (if (equal (format argument-format choice) value) + 'transient-value + 'transient-inactive-value))) + choices + (propertize "|" 'face 'transient-delimiter)))))) + +(cl-defmethod transient--get-description ((obj transient-child)) + (and-let* ((desc (oref obj description))) + (if (functionp desc) + (if (= (car (transient--func-arity desc)) 1) + (funcall desc obj) + (funcall desc)) + desc))) + +(cl-defmethod transient--get-face ((obj transient-suffix) slot) + (and-let* (((slot-boundp obj slot)) + (face (slot-value obj slot))) + (if (and (not (facep face)) + (functionp face)) + (let ((transient--pending-suffix obj)) + (if (= (car (transient--func-arity face)) 1) + (funcall face obj) + (funcall face))) + face))) + +(defun transient--add-face (string face &optional append beg end) + (let ((str (copy-sequence string))) + (add-face-text-property (or beg 0) (or end (length str)) face append str) + str)) + +(defun transient--key-face (&optional cmd enforce-type) + (or (and transient-semantic-coloring + (not transient--helpp) + (not transient--editp) + (or (and cmd (get cmd 'transient-face)) + (get (transient--get-pre-command cmd enforce-type) + 'transient-face))) + (if cmd 'transient-key 'transient-key-noop))) + +(defun transient--key-unreachable-p (obj) + (and transient--redisplay-key + (let ((key (oref obj key))) + (not (or (equal (seq-take (cl-coerce (edmacro-parse-keys key t) 'list) + (length transient--redisplay-key)) + transient--redisplay-key) + (transient--lookup-key transient-sticky-map (kbd key))))))) + +(defun transient--lookup-key (keymap key) + (let ((val (lookup-key keymap key))) + (and val (not (integerp val)) val))) + +(defun transient--maybe-pad-keys (group &optional parent) + (when-let ((pad (or (oref group pad-keys) + (and parent (oref parent pad-keys))))) + (oset group pad-keys + (apply #'max + (if (integerp pad) pad 0) + (seq-keep (lambda (suffix) + (and (eieio-object-p suffix) + (slot-boundp suffix 'key) + (length (oref suffix key)))) + (oref group suffixes)))))) + +(defun transient--pixel-width (string) + (save-window-excursion + (with-temp-buffer + (insert string) + (set-window-dedicated-p nil nil) + (set-window-buffer nil (current-buffer)) + (car (window-text-pixel-size + nil (line-beginning-position) (point)))))) + +(defun transient-command-summary-or-name (obj) + "Return the summary or name of the command represented by OBJ. + +If the command has a doc-string, then return the first line of +that, else its name. + +Intended to be temporarily used as the `:suffix-description' of +a prefix command, while porting a regular keymap to a transient." + (let ((command (oref obj command))) + (if-let ((doc (documentation command))) + (propertize (car (split-string doc "\n")) 'face 'font-lock-doc-face) + (propertize (symbol-name command) 'face 'font-lock-function-name-face)))) + +;;; Help + +(cl-defgeneric transient-show-help (obj) + "Show documentation for the command represented by OBJ.") + +(cl-defmethod transient-show-help ((obj transient-prefix)) + "Call `show-help' if non-nil, else show `info-manual', +if non-nil, else show the `man-page' if non-nil, else use +`describe-function'." + (with-slots (show-help info-manual man-page command) obj + (cond (show-help (funcall show-help obj)) + (info-manual (transient--show-manual info-manual)) + (man-page (transient--show-manpage man-page)) + ((transient--describe-function command))))) + +(cl-defmethod transient-show-help ((obj transient-suffix)) + "Call `show-help' if non-nil, else use `describe-function'. +Also used to dispatch showing documentation for the current +prefix. If the suffix is a sub-prefix, then also call the +prefix method." + (cond + ((eq this-command 'transient-help) + (transient-show-help transient--prefix)) + ((let ((prefix (get (oref obj command) + 'transient--prefix))) + (and prefix (not (eq (oref transient--prefix command) this-command)) + (prog1 t (transient-show-help prefix))))) + ((if-let ((show-help (oref obj show-help))) + (funcall show-help obj) + (transient--describe-function this-command))))) + +(cl-defmethod transient-show-help ((obj transient-infix)) + "Call `show-help' if non-nil, else show the `man-page' +if non-nil, else use `describe-function'. When showing the +manpage, then try to jump to the correct location." + (if-let ((show-help (oref obj show-help))) + (funcall show-help obj) + (if-let ((man-page (oref transient--prefix man-page)) + (argument (and (slot-boundp obj 'argument) + (oref obj argument)))) + (transient--show-manpage man-page argument) + (transient--describe-function this-command)))) + +;; `cl-generic-generalizers' doesn't support `command' et al. +(cl-defmethod transient-show-help (cmd) + "Show the command doc-string." + (transient--describe-function cmd)) + +(defun transient--describe-function (fn) + (describe-function fn) + (unless (derived-mode-p 'help-mode) + (when-let* ((buf (get-buffer "*Help*")) + (win (or (and buf (get-buffer-window buf)) + (cl-find-if (lambda (win) + (with-current-buffer (window-buffer win) + (derived-mode-p 'help-mode))) + (window-list))))) + (select-window win)))) + +(defun transient--show-manual (manual) + (info manual)) + +(defun transient--show-manpage (manpage &optional argument) + (require 'man) + (let* ((Man-notify-method 'meek) + (buf (Man-getpage-in-background manpage)) + (proc (get-buffer-process buf))) + (while (and proc (eq (process-status proc) 'run)) + (accept-process-output proc)) + (switch-to-buffer buf) + (when argument + (transient--goto-argument-description argument)))) + +(defun transient--goto-argument-description (arg) + (goto-char (point-min)) + (let ((case-fold-search nil) + ;; This matches preceding/proceeding options. Options + ;; such as "-a", "-S[<keyid>]", and "--grep=<pattern>" + ;; are matched by this regex without the shy group. + ;; The ". " in the shy group is for options such as + ;; "-m parent-number", and the "-[^[:space:]]+ " is + ;; for options such as "--mainline parent-number" + (others "-\\(?:. \\|-[^[:space:]]+ \\)?[^[:space:]]+")) + (when (re-search-forward + (if (equal arg "--") + ;; Special case. + "^[\t\s]+\\(--\\(?: \\|$\\)\\|\\[--\\]\\)" + ;; Should start with whitespace and may have + ;; any number of options before and/or after. + (format + "^[\t\s]+\\(?:%s, \\)*?\\(?1:%s\\)%s\\(?:, %s\\)*$" + others + ;; Options don't necessarily end in an "=" + ;; (e.g., "--gpg-sign[=<keyid>]") + (string-remove-suffix "=" arg) + ;; Simple options don't end in an "=". Splitting this + ;; into 2 cases should make getting false positives + ;; less likely. + (if (string-suffix-p "=" arg) + ;; "[^[:space:]]*[^.[:space:]]" matches the option + ;; value, which is usually after the option name + ;; and either '=' or '[='. The value can't end in + ;; a period, as that means it's being used at the + ;; end of a sentence. The space is for options + ;; such as '--mainline parent-number'. + "\\(?: \\|\\[?=\\)[^[:space:]]*[^.[:space:]]" + ;; Either this doesn't match anything (e.g., "-a"), + ;; or the option is followed by a value delimited + ;; by a "[", "<", or ":". A space might appear + ;; before this value, as in "-f <file>". The + ;; space alternative is for options such as + ;; "-m parent-number". + "\\(?:\\(?: \\| ?[\\[<:]\\)[^[:space:]]*[^.[:space:]]\\)?") + others)) + nil t) + (goto-char (match-beginning 1))))) + +(defun transient--insert-help () + (unless (looking-back "\n\n" 2) + (insert "\n")) + (when transient--helpp + (insert + (format (propertize "\ +Type a %s to show help for that suffix command, or %s to show manual. +Type %s to exit help.\n" + 'face 'transient-heading) + (propertize "<KEY>" 'face 'transient-key) + (propertize "?" 'face 'transient-key) + (propertize "C-g" 'face 'transient-key)))) + (when transient--editp + (unless transient--helpp + (insert + (format (propertize "\ +Type a %s to set level for that suffix command. +Type %s to set what levels are available for this prefix command.\n" + 'face 'transient-heading) + (propertize "<KEY>" 'face 'transient-key) + (propertize "C-x l" 'face 'transient-key)))) + (with-slots (level) transient--prefix + (insert + (format (propertize " +Suffixes on levels %s are available. +Suffixes on levels %s and %s are unavailable.\n" + 'face 'transient-heading) + (propertize (format "1-%s" level) + 'face 'transient-enabled-suffix) + (propertize " 0 " + 'face 'transient-disabled-suffix) + (propertize (format ">=%s" (1+ level)) + 'face 'transient-disabled-suffix)))))) + +;;; Popup Navigation + +(defun transient-scroll-up (&optional arg) + "Scroll text of transient popup window upward ARG lines. +If ARG is nil scroll near full screen. This is a wrapper +around `scroll-up-command' (which see)." + (interactive "^P") + (with-selected-window transient--window + (scroll-up-command arg))) + +(defun transient-scroll-down (&optional arg) + "Scroll text of transient popup window down ARG lines. +If ARG is nil scroll near full screen. This is a wrapper +around `scroll-down-command' (which see)." + (interactive "^P") + (with-selected-window transient--window + (scroll-down-command arg))) + +(defun transient-backward-button (n) + "Move to the previous button in the transient popup buffer. +See `backward-button' for information about N." + (interactive "p") + (with-selected-window transient--window + (backward-button n t))) + +(defun transient-forward-button (n) + "Move to the next button in the transient popup buffer. +See `forward-button' for information about N." + (interactive "p") + (with-selected-window transient--window + (forward-button n t))) + +(define-button-type 'transient + 'face nil + 'keymap transient-button-map) + +(defun transient--goto-button (command) + (cond + ((stringp command) + (when (re-search-forward (concat "^" (regexp-quote command)) nil t) + (goto-char (match-beginning 0)))) + (command + (while (and (ignore-errors (forward-button 1)) + (not (eq (button-get (button-at (point)) 'command) command)))) + (unless (eq (button-get (button-at (point)) 'command) command) + (goto-char (point-min)) + (forward-button 1))))) + +(defun transient--heading-at-point () + (and (eq (get-text-property (point) 'face) 'transient-heading) + (let ((beg (line-beginning-position))) + (buffer-substring-no-properties + beg (next-single-property-change + beg 'face nil (line-end-position)))))) + +;;; Compatibility +;;;; Popup Isearch + +(defvar-keymap transient--isearch-mode-map + :parent isearch-mode-map + "<remap> <isearch-exit>" #'transient-isearch-exit + "<remap> <isearch-cancel>" #'transient-isearch-cancel + "<remap> <isearch-abort>" #'transient-isearch-abort) + +(defun transient-isearch-backward (&optional regexp-p) + "Do incremental search backward. +With a prefix argument, do an incremental regular expression +search instead." + (interactive "P") + (transient--isearch-setup) + (let ((isearch-mode-map transient--isearch-mode-map)) + (isearch-mode nil regexp-p))) + +(defun transient-isearch-forward (&optional regexp-p) + "Do incremental search forward. +With a prefix argument, do an incremental regular expression +search instead." + (interactive "P") + (transient--isearch-setup) + (let ((isearch-mode-map transient--isearch-mode-map)) + (isearch-mode t regexp-p))) + +(defun transient-isearch-exit () + "Like `isearch-exit' but adapted for `transient'." + (interactive) + (isearch-exit) + (transient--isearch-exit)) + +(defun transient-isearch-cancel () + "Like `isearch-cancel' but adapted for `transient'." + (interactive) + (condition-case nil (isearch-cancel) (quit)) + (transient--isearch-exit)) + +(defun transient-isearch-abort () + "Like `isearch-abort' but adapted for `transient'." + (interactive) + (let ((around (lambda (fn) + (condition-case nil (funcall fn) (quit)) + (transient--isearch-exit)))) + (advice-add 'isearch-cancel :around around) + (unwind-protect + (isearch-abort) + (advice-remove 'isearch-cancel around)))) + +(defun transient--isearch-setup () + (select-window transient--window) + (transient--suspend-override t)) + +(defun transient--isearch-exit () + (select-window transient--original-window) + (transient--resume-override)) + +;;;; Edebug + +(defun transient--edebug-command-p () + (and (bound-and-true-p edebug-active) + (or (memq this-command '(top-level abort-recursive-edit)) + (string-prefix-p "edebug" (symbol-name this-command))))) + +;;;; Miscellaneous + +(cl-pushnew (list nil (concat "^\\s-*(" + (eval-when-compile + (regexp-opt + '("transient-define-prefix" + "transient-define-suffix" + "transient-define-infix" + "transient-define-argument") + t)) + "\\s-+\\(" lisp-mode-symbol-regexp "\\)") + 2) + lisp-imenu-generic-expression :test #'equal) + +(declare-function which-key-mode "which-key" (&optional arg)) + +(defun transient--suspend-which-key-mode () + (when (bound-and-true-p which-key-mode) + (which-key-mode -1) + (add-hook 'transient-exit-hook #'transient--resume-which-key-mode))) + +(defun transient--resume-which-key-mode () + (unless transient--prefix + (which-key-mode 1) + (remove-hook 'transient-exit-hook #'transient--resume-which-key-mode))) + +(defun transient-bind-q-to-quit () + "Modify some keymaps to bind \"q\" to the appropriate quit command. + +\"C-g\" is the default binding for such commands now, but Transient's +predecessor Magit-Popup used \"q\" instead. If you would like to get +that binding back, then call this function in your init file like so: + + (with-eval-after-load \\='transient + (transient-bind-q-to-quit)) + +Individual transients may already bind \"q\" to something else +and such a binding would shadow the quit binding. If that is the +case then \"Q\" is bound to whatever \"q\" would have been bound +to by setting `transient-substitute-key-function' to a function +that does that. Of course \"Q\" may already be bound to something +else, so that function binds \"M-q\" to that command instead. +Of course \"M-q\" may already be bound to something else, but +we stop there." + (keymap-set transient-base-map "q" #'transient-quit-one) + (keymap-set transient-sticky-map "q" #'transient-quit-seq) + (setq transient-substitute-key-function + #'transient-rebind-quit-commands)) + +(defun transient-rebind-quit-commands (obj) + "See `transient-bind-q-to-quit'." + (let ((key (oref obj key))) + (cond ((string-equal key "q") "Q") + ((string-equal key "Q") "M-q") + (key)))) + +(defun transient--force-fixed-pitch () + (require 'face-remap) + (face-remap-reset-base 'default) + (face-remap-add-relative 'default 'fixed-pitch)) + +(defun transient--func-arity (fn) + (func-arity (advice--cd*r (if (symbolp fn) (symbol-function fn) fn)))) + +(defun transient--seq-reductions-from (function sequence initial-value) + (let ((acc (list initial-value))) + (seq-doseq (elt sequence) + (push (funcall function (car acc) elt) acc)) + (nreverse acc))) + +;;; Font-Lock + +(defconst transient-font-lock-keywords + (eval-when-compile + `((,(concat "(" + (regexp-opt (list "transient-define-prefix" + "transient-define-infix" + "transient-define-argument" + "transient-define-suffix") + t) + "\\_>[ \t'(]*" + "\\(\\(?:\\sw\\|\\s_\\)+\\)?") + (1 'font-lock-keyword-face) + (2 'font-lock-function-name-face nil t))))) + +(font-lock-add-keywords 'emacs-lisp-mode transient-font-lock-keywords) + +;;; Auxiliary Classes +;;;; `transient-lisp-variable' + +(defclass transient-lisp-variable (transient-variable) + ((reader :initform #'transient-lisp-variable--reader) + (always-read :initform t) + (set-value :initarg :set-value :initform #'set)) + "[Experimental] Class used for Lisp variables.") + +(cl-defmethod transient-init-value ((obj transient-lisp-variable)) + (oset obj value (symbol-value (oref obj variable)))) + +(cl-defmethod transient-infix-set ((obj transient-lisp-variable) value) + (funcall (oref obj set-value) + (oref obj variable) + (oset obj value value))) + +(cl-defmethod transient-format-description ((obj transient-lisp-variable)) + (or (cl-call-next-method obj) + (symbol-name (oref obj variable)))) + +(cl-defmethod transient-format-value ((obj transient-lisp-variable)) + (propertize (prin1-to-string (oref obj value)) + 'face 'transient-value)) + +(cl-defmethod transient-prompt ((obj transient-lisp-variable)) + (if (and (slot-boundp obj 'prompt) + (oref obj prompt)) + (cl-call-next-method obj) + (format "Set %s: " (oref obj variable)))) + +(defun transient-lisp-variable--reader (prompt initial-input _history) + (read--expression prompt initial-input)) + +;;; _ +(provide 'transient) +;; Local Variables: +;; indent-tabs-mode: nil +;; checkdoc-symbol-words: ("command-line" "edit-mode" "help-mode") +;; End: +;;; transient.el ends here diff --git a/emacs/elpa/transient-20240525.1118/transient.elc b/emacs/elpa/transient-20240525.1118/transient.elc Binary files differ. diff --git a/emacs/elpa/transient-20240509.1849/transient.info b/emacs/elpa/transient-20240525.1118/transient.info