Emacs package that provides a client for compiler explorer service.
M-x compiler-explorer is the main entry point. It will ask you for a
language and display source&compilation buffers. Type something in the source
buffer; the compilation buffer will automatically update with compiled asm
code. Another buffer displays output of the compiled and executed program.
M-x compiler-explorer-set-compiler changes the compiler for current session.
M-x compiler-explorer-set-compiler-args sets compilation options.
M-x compiler-explorer-add-library asks for a library version and adds it to
current compilation. M-x compiler-explorer-remove-library removes them.
M-x compiler-explorer-set-execution-args sets the arguments for the executed
program.
M-x compiler-explorer-set-input reads a string from minibuffer that will be
used as input for the executed program.
M-x compiler-explorer-new-session kills the current session and creates a new
one, asking for source language.
M-x compiler-explorer-previous-session lets you restore previous sessions.
M-x compiler-explorer-discard-session kills the current or selected sessions
and forgets about them forever.
M-x compiler-explorer-exit kills the current session.
M-x compiler-explorer-browse-opcode-documentation opens a website that
contains the documentation for the opcode at point.
M-x compiler-explorer-jump jumps to ASM block for the source line at point
and vice versa.
M-x compiler-explorer-add-tool asks for the name of a tool, adds it to
current compilation and displays a new buffer showing the tool's output.
M-x compiler-explorer-remove-tool prompts for the name of an added tool to
remove.
M-x compiler-explorer-set-tool-args sets the arguments for an added tool.
M-x compiler-explorer-set-tool-input reads a string from minibuffer that will
be used as input for an added tool.
M-x compiler-explorer-load-example prompts for a name of a builtin example
and loads it.
M-x compiler-explorer-make-link generates a link for current compilation so
it can be opened in a browser and shared.
M-x compiler-explorer-restore-from-link restores a session from a URL,
generated by the website or by this package.
M-x compiler-explorer-layout cycles between different layouts.
Additional customization is possible via M-x customize-group
compiler-explorer.
The following snippet sets up the built-in eglot package to start a language
server for each session, and to automatically create and update a
compile_flags.txt file (recognized by clangd) to have the same compiler
arguments that are set for the current session. This requires that the
compiler-explorer-make-temp-file custom variable is non-nil.
(add-hook 'compiler-explorer-new-session-hook #'eglot-ensure)
(defun my/compiler-explorer-params-change-hook (what value)
"Hook run when compilation parameters WHAT change to VALUE."
(pcase what
('compiler-args
(with-current-buffer compiler-explorer--buffer
(when (derived-mode-p 'c-mode 'c++-mode)
(with-temp-file "compile_flags.txt"
(insert (mapconcat #'identity
(split-string-and-unquote value) "\n")))
(when (eglot-current-server)
(eglot-reconnect (eglot-current-server))))))))
(add-hook 'compiler-explorer-params-change-hook
#'my/compiler-explorer-params-change-hook)Copyright (C) 2020-2025 Michał Krzywkowski
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/>.