Documentation

Commentary

* compiler-explorer.el

Package that provides a client for https://godbolt.org service.


** Usage

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.


*** Compilation

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.


*** Execution

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.


*** Session management

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.


*** ASM

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.


*** Tools

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.


*** Other commands

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.


** Customization

Additional customization is possible via M-x `customize-group'
`compiler-explorer'.


*** Usage with language servers

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)

Consumers

Reverse Dependencies

No reverse dependencies recorded.