NonGNU-devel ELPA - reformatter

reformatter Atom Feed

Description
Define commands which run reformatters on the current buffer
Latest
reformatter-0.8.0.20241007.102705.tar (.sig), 2024-Oct-07, 30.0 KiB
Maintainer
Steve Purcell <steve@sanityinc.com>
Website
https://github.com/purcell/emacs-reformatter
Browse ELPA's repository
CGit or Gitweb
Badge

To install this package from Emacs, use package-install or list-packages.

Full description

This library lets elisp authors easily define an idiomatic command
to reformat the current buffer using a command-line program,
together with an optional minor mode which can apply this command
automatically on save.

By default, reformatter.el expects programs to read from stdin and
write to stdout, and you should prefer this mode of operation where
possible.  If this isn't possible with your particular formatting
program, refer to the options for `reformatter-define', and see the
examples in the package's tests.

As an example, let's define a reformat command that applies the
"dhall format" command.  We'll assume here that we've already defined a
variable `dhall-command' which holds the string name or path of the
dhall executable:

    (reformatter-define dhall-format
      :program dhall-command
      :args '("format"))

The `reformatter-define' macro expands to code which generates
`dhall-format-buffer' and `dhall-format-region' interactive
commands, and a local minor mode called
`dhall-format-on-save-mode'.  The :args" and :program expressions
will be evaluated at runtime, so they can refer to variables that
may (later) have a buffer-local value.  A custom variable will be
generated for the mode lighter, with the supplied value becoming
the default.

The generated minor mode allows idiomatic per-directory or per-file
customisation, via the "modes" support baked into Emacs' file-local
and directory-local variables mechanisms.  For example, users of
the above example might add the following to a project-specific
.dir-locals.el file:

    ((dhall-mode
      (mode . dhall-format-on-save)))

See the documentation for `reformatter-define', which provides a
number of options for customising the generated code.

Library authors might like to provide autoloads for the generated
code, e.g.:

    ;;;###autoload (autoload 'dhall-format-buffer "current-file" nil t)
    ;;;###autoload (autoload 'dhall-format-region "current-file" nil t)
    ;;;###autoload (autoload 'dhall-format-on-save-mode "current-file" nil t)

Old versions

reformatter-0.8.0.20240927.92254.tar.lz2024-Sep-276.72 KiB
reformatter-0.8.0.20240913.153354.tar.lz2024-Sep-136.72 KiB
reformatter-0.8.0.20240903.94840.tar.lz2024-Sep-036.71 KiB
reformatter-0.8.0.20240515.204925.tar.lz2024-May-166.63 KiB
reformatter-0.8.0.20240311.102829.tar.lz2024-Mar-316.62 KiB
reformatter-0.8.0.20240112.223344.tar.lz2024-Jan-136.62 KiB
reformatter-0.8.0.20231129.180143.tar.lz2023-Nov-296.62 KiB
reformatter-0.8.0.20231122.83850.tar.lz2023-Nov-226.62 KiB
reformatter-0.7.0.20231110.173142.tar.lz2023-Nov-106.57 KiB
reformatter-0.7.0.20230905.61532.tar.lz2023-Sep-056.52 KiB