aboutsummaryrefslogtreecommitdiff
path: root/guix/scripts/style.scm
Commit message (Collapse)AuthorAge
* style: Fix conversion of ‘unquote-splicing’ by ‘-S arguments’.Ludovic Courtès3 days
| | | | | | | | | * guix/scripts/style.scm (unquote->ungexp): Add missing comma for ‘ungexp-splicing’. * tests/style.scm ("gexpify arguments, substitute-keyword-arguments + unquote-splicing"): New test. Change-Id: I17dcdd9b4812d54ddba1137e369360706b137bb4
* style: ‘guix style -f’ warns when passed zero arguments.Ludovic Courtès2023-11-22
| | | | | | | * guix/scripts/style.scm (guix-style): When OPTS has ‘whole-file?’ set, warn when FILES is empty. Change-Id: I494f52ef5d070510d20006e6dd987a6805161bb4
* scripts: style: Handle EPIPE errors when displaying help.Simon Tournier2023-10-17
| | | | * guix/scripts/style.scm (%options): Handle EPIPE errors when displaying help.
* diagnostics: Factorize 'absolute-location'.Ludovic Courtès2023-05-31
| | | | | | * guix/scripts/style.scm (absolute-location): Move to... * guix/diagnostics.scm (absolute-location): ... here. * guix/upstream.scm (update-package-source): Use it.
* style: Add 'arguments' styling rule.Ludovic Courtès2023-05-18
| | | | | | | | | | | | | | | | | | * guix/scripts/style.scm (unquote->ungexp, gexpify-argument-value) (quote-argument-value, gexpify-argument-tail) (gexpify-package-arguments): New procedures. (%gexp-keywords): New variable. (%options): Add "arguments" case for 'styling-procedure. (show-stylings): Update. * tests/style.scm ("gexpify arguments, already gexpified") ("gexpify arguments, non-gexp arguments, margin comment") ("gexpify arguments, phases and flags") ("gexpify arguments, append arguments") ("gexpify arguments, substitute-keyword-arguments") ("gexpify arguments, append substitute-keyword-arguments"): New tests. * doc/guix.texi (package Reference): For 'arguments', add compatibility note and link to 'guix style'. (Invoking guix style): Document the 'arguments' styling rule.
* style: Make 'safe' policy less conservative.Ludovic Courtès2023-05-04
| | | | | | | | | | | | | | Previously, a mere (arguments '(#:tests? #f)) would lead guix style -S inputs --input-simplification=safe to bail out. It now recognizes such trivial argument lists and proceeds. * guix/scripts/style.scm (trivial-package-arguments?): New procedure. (simplify-package-inputs): Use it in the 'safe case instead of 'null?'. * tests/style.scm ("input labels, 'safe' policy, trivial arguments"): New test.
* guix: Strip #:use-module lists.Ludovic Courtès2023-03-13
| | | | | | | | | | | | This was obtained by setting up this environment: guix shell -D guix --with-input=guile@3.0.9=guile-next \ --with-commit=guile-next=e2ed33ef0445c867fe56c247054aa67e834861f2 -- make -j5 then adding 'unused-module' to (@@ (guix build compiler) %warnings), building, and checking all the "unused module" warnings and removing those that were definitely unused.
* style: '-f' reads input files as UTF-8 by default.Ludovic Courtès2022-11-20
| | | | | | | Reported by mirai on #guix. * guix/scripts/style.scm (format-whole-file): Wrap body in 'with-fluids'. Pass #:guess-encoding to 'call-with-input-file'.
* style: Add '--whole-file' option.Ludovic Courtès2022-08-08
| | | | | | | | | * guix/scripts/style.scm (format-whole-file): New procedure. (%options, show-help): Add '--whole-file'. (guix-style): Honor it. * tests/guix-style.sh: New file. * Makefile.am (SH_TESTS): Add it. * doc/guix.texi (Invoking guix style): Document it.
* read-print: Read and render vertical space.Ludovic Courtès2022-08-08
| | | | | | | | | | | | | | | | | * guix/read-print.scm (<vertical-space>, vertical-space?) (vertical-space, vertical-space-height): New variables. (combine-vertical-space, canonicalize-vertical-space) (read-vertical-space): New procedures. (read-with-comments): Use it in the #\newline case. (pretty-print-with-comments): Add #:format-vertical-space and honor it. Add case for 'vertical-space?'. * guix/scripts/style.scm (format-package-definition): Pass #:format-vertical-space to 'object->string*'. * tests/read-print.scm ("read-with-comments: list with blank line") ("read-with-comments: list with multiple blank lines") ("read-with-comments: top-level blank lines") ("pretty-print-with-comments, canonicalize-vertical-space"): New tests. Add a couple of additional round-trip tests.
* read-print: Introduce <blank> parent class of <comment>.Ludovic Courtès2022-08-08
| | | | | | | | | * guix/read-print.scm (<blank>, blank?): New record type. (<comment>): Redefine using the record interface. (read-with-comments, pretty-print-with-comments): Change some uses of 'comment?' to 'blank?'. * guix/scripts/style.scm (simplify-inputs)[simplify-expressions]: Use 'blank?' instead of 'comment?'.
* style: Move reader and printer to (guix read-print).Ludovic Courtès2022-08-08
| | | | | | | | | | | | | | * guix/scripts/style.scm (<comment>, read-with-comments) (vhashq, %special-forms, %newline-forms, prefix?) (special-form-lead, newline-form?, escaped-string) (string-width, canonicalize-comment, pretty-print-with-comments) (object->string*): Move to... * guix/read-print.scm: ... here. New file. * guix/scripts/import.scm: Adjust accordingly. * tests/style.scm: Move 'test-pretty-print' and tests to... * tests/read-print.scm: ... here. New file. * Makefile.am (MODULES): Add 'guix/read-print.scm'. (SCM_TESTS): Add 'tests/read-print.scm'.
* style: Gracefully handle failure to locate a source file.Ludovic Courtès2022-07-12
| | | | | * guix/scripts/style.scm (absolute-location): Raise an error when 'search-path' returns #f.
* style: For 'let' and similar forms, emit one binding per line.Ludovic Courtès2022-07-04
| | | | | | | | | | | | | | | | | | Previously, 'let' bindings could be rendered like this: (let ((x 1) (y 2) (z 3)) ...) With this change, each bindings goes in its own line. Partly fixes <https://issues.guix.gnu.org/56297>. Reported by Maxime Devos <maximedevos@telenet.be>. * guix/scripts/style.scm (pretty-print-with-comments)[list-of-lists?]: New procedure. Use it. * tests/style.scm: Add tests with 'let' and 'substitute-keyword-arguments'.
* style: Add option '--list-stylings'.Hartmut Goebel2022-07-04
| | | | | | * guix/scripts/style.scm (show-stylings): New procedure. (%options, show-help): Add "--list-stylings". * doc/guix.texi (Invoking guix style): Document "-l".
* style: Keep values next to their keyword.Ludovic Courtès2022-06-22
| | | | | | | | | This ensures we print '#:key value' rather than insert a newline between '#:key' and 'value' as was the case before. * guix/scripts/style.scm (pretty-print-with-comments)[print-sequence]: When ITEM is a keyword, loop with FIRST? = true. * tests/style.scm: Add test.
* style: Correctly read dots in pairs and improper lists.Ludovic Courtès2022-04-14
| | | | | | | | | | Until now dots were read as symbols. * guix/scripts/style.scm (read-with-comments)[dot]: New variable. [dot?, reverse/dot]: New procedures. Use 'reverse/dot' instead of 'reverse' when reading lists. * tests/style.scm ("read-with-comments: dot notation") ("((a . 1) (b . 2))", "(a b c . boom)"): New tests.
* style: '-S format' canonicalizes comments.Ludovic Courtès2022-01-10
| | | | | | | | | | * guix/scripts/style.scm (canonicalize-comment): New procedure. (pretty-print-with-comments): Add #:format-comment. and honor it. (object->string*): Add 'args' and honor them. (format-package-definition): Pass #:format-comment to 'object->string*'. * tests/style.scm ("pretty-print-with-comments, canonicalize-comment"): New test.
* style: Add '--styling' option.Ludovic Courtès2022-01-10
| | | | | | | | | | | | | | | | | | | * guix/scripts/style.scm (format-package-definition): New procedure. (%options, show-help): Add "--styling". (%default-options): Add 'styling-procedure'. (guix-style): Honor it. * tests/style.scm (with-test-package) ("input labels, 'safe' policy") ("input labels, 'safe' policy, nothing changed") ("input labels, margin comment") ("input labels, margin comment on long list") ("input labels, line comment") ("input labels, modify-inputs and margin comment"): Pass "-S inputs". * etc/indent-code.el: Remove. * doc/contributing.texi (Formatting Code): Mention "guix style" instead of "etc/indent-code.el". (Submitting Patches): Add item for "guix style". * doc/guix.texi (Invoking guix style): Document "-S" and update.
* style: Add support for "newline forms".Ludovic Courtès2022-01-10
| | | | | | | | | | This allows us to express cases where a newline should be inserted immediately after the head symbol of a list. * guix/scripts/style.scm (%newline-forms): New variable. (newline-form?): New procedure. (pretty-print-with-comments): Handle "newline forms". * tests/style.scm: Add test.
* style: Allow special forms to be scoped.Ludovic Courtès2022-01-10
| | | | | | | | | | | | * guix/scripts/style.scm (vhashq): Add clause for 'lst, and change default clause. (%special-forms): Add context for 'add-after and 'add-before. Add 'replace. (prefix?, special-form-lead): New procedures. (special-form?): Remove. (pretty-print-with-comments): Add 'context' to the threaded state. Adjust 'print-sequence' and adjust 'loop' calls accordingly. * tests/style.scm: Add tests for 'replace.
* style: Improve pretty printer and add tests.Ludovic Courtès2022-01-10
| | | | | | | | | | * guix/scripts/style.scm (vhashq): New macro. (%special-forms): New variable. (special-form?): New procedure. (pretty-print-with-comments): Add many clauses and tweak existing rules. * tests/style.scm (test-pretty-print): New macro. <top level>: Add 'test-pretty-print' tests.
* style: Gracefully handle errors such as EACCES when opening files.Ludovic Courtès2021-12-18
| | | | | * guix/scripts/style.scm (guix-style): Wrap body in 'with-error-handling'.
* style: Refer to source files by absolute file names.Ludovic Courtès2021-12-18
| | | | | | | | | Previously, "guix style PACKAGE" would end up modifying a file looked up under the current directory since the location associated with PACKAGE is usually a relative file name. * guix/scripts/style.scm (absolute-location): New procedure. (simplify-package-inputs): Use it.
* style: Add '--dry-run'.Ludovic Courtès2021-11-23
| | | | | | | * guix/scripts/style.scm (edit-expression/dry-run): New procedure. (simplify-package-inputs): Add #:edit-expression parameter. (%options, show-help): Add '--dry-run'. (guix-style): Honor '--dry-run'.
* style: Really honor '--input-simplification=always'.Ludovic Courtès2021-09-30
| | | | | * guix/scripts/style.scm (simplify-package-inputs): Use (const #t) when POLICY is 'always.
* Add 'guix style'.Ludovic Courtès2021-07-11
* guix/scripts/style.scm, tests/style.scm: New files. * Makefile.am (MODULES, SCM_TESTS): Add them. * po/guix/POTFILES.in: Add 'guix/scripts/style.scm'. * doc/guix.texi (Invoking guix style): New node. (package Reference): Reference it. (Invoking guix lint): Likewise.