aboutsummaryrefslogtreecommitdiff
path: root/guix/read-print.scm
Commit message (Collapse)AuthorAge
* guix: import: Optionally import necessary yanked crates.David Elsing2024-01-09
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * doc/guix.texi (Invoking guix import): Mention '--allow-yanked'. * guix/import/crate.scm (make-crate-sexp): Add yanked? argument. For yanked packages, use the full version suffixed by "-yanked" for generated variable names and add a comment and package property. (crate->guix-package): Add allow-yanked? argument and if it is set to #t, allow importing yanked crates if no other version matching the requirements exists. [find-package-version]: Packages previously marked as yanked are only included if allow-yanked? is #t and then take the lowest priority. [find-crate-version]: If allow-yanked? is #t, also consider yanked versions with the lowest priority. [dependency-name+version]: Rename to ... [dependency-name+version+yanked] ...this. Honor allow-yanked? and choose between an existing package and an upstream package. Exit with an error message if no version fulfilling the requirement is found. [version*]: Exit with an error message if the crate version is not found. (cargo-recursive-import): Add allow-yanked? argument. * guix/read-print.scm: Export <comment>. * guix/scripts/import/crate.scm: Add "--allow-yanked". * tests/crate.scm: Add test 'crate-recursive-import-only-yanked-available'. [sort-map-dependencies]: Adjust accordingly. [remove-yanked-info]: New variable. Adjust test 'crate-recursive-import-honors-existing-packages'. (test-bar-dependencies): Add yanked dev-dependencies. (test-leaf-bob-crate): Add yanked versions. (rust-leaf-bob-3.0.2-yanked): New variable. Signed-off-by: Efraim Flashner <efraim@flashner.co.il> Change-Id: I175d89b39774e6b57dcd1f05bf68718d23866bb7
* read-print: Properly indent ‘parameterize’.Ludovic Courtès2023-11-22
| | | | | | | | | | Fixes <https://issues.guix.gnu.org/65427>. * guix/read-print.scm (%special-forms): Add ‘parameterize’. * tests/read-print.scm: Add test. Reported-by: Maxime Devos <maximedevos@telenet.be> Change-Id: I922bffc527ade539cf2eb304acb25bc9c705a459
* read-print: Be more mindful of horizontal space in packages.Tobias Geerinckx-Rice2023-09-24
| | | | | | | | | | | | | | Perhaps due to their staged nature, packages tend to be ‘lopsided’: deeply nested, with the most elaborate code on the {build,right-hand-,in}side, in snippets and phases. When we indent outer forms too eagerly, we can easily run short on columns by the time we get to the build code, reducing readability. A few strategically-placed newlines early on can make a big difference. * guix/read-print.scm (%newline-forms): Add a newline after opening a <package> source field or an argument list. Compensate by removing the base32 special case, which is now unnecessary.
* records: Add MATCH-RECORD-LAMBDA.(unmatched-parenthesis ew syntax2023-06-04
| | | | | | | * guix/records.scm (match-record-lambda): New syntax. * tests/records.scm ("match-record-lambda"): New test. Signed-off-by: Josselin Poiret <dev@jpoiret.xyz>
* read-print: Add 'package/inherit' special form.Ludovic Courtès2023-06-02
| | | | * guix/read-print.scm (%special-forms): Add 'package/inherit'.
* read-print: Recognize 'wrap-program' and 'wrap-script' as special forms.Ludovic Courtès2023-05-05
| | | | | * guix/read-print.scm (%special-forms): Add 'wrap-program' and 'wrap-script'.
* read-print: Correctly read "(. x)".Ludovic Courtès2023-05-05
| | | | | | * guix/read-print.scm (read-with-comments): Check whether REST is a pair before calling 'set-cdr!'. * tests/read-print.scm ("read-with-comments: half dot notation"): New test.
* read-print: 'pretty-print-with-comments' keeps newlines on long strings.Ludovic Courtès2023-04-24
| | | | | | | * guix/read-print.scm (printed-string)[preserve-newlines?]: New procedure. Use it to preserve newlines on long strings. * tests/read-print.scm: Add test.
* read-print: 'read-with-comments' reads comments within gexps.Ludovic Courtès2023-03-16
| | | | | | | | Fixes <https://issues.guix.gnu.org/62059>. Reported by Maxim Cournoyer <maxim.cournoyer@gmail.com>. * guix/read-print.scm (read-with-comments): Special-case #~, #$, and #+. * tests/read-print.scm: Add two tests.
* read-print: Correctly handle comments that follow a list head.Ludovic Courtès2023-03-07
| | | | | | | | | | Fixes <https://issues.guix.gnu.org/61013>. Reported by Maxim Cournoyer <maxim.cournoyer@gmail.com>. * guix/read-print.scm (pretty-print-with-comments)[starts-with-line-comment?]: New procedure. Use it when printing a list. * tests/read-print.scm: Add two tests.
* read-print: Special-case channel-related forms.Ludovic Courtès2023-03-07
| | | | | * guix/read-print.scm (%special-forms, %newline-forms): Add channel-related forms.
* read-print: Do not use extended notation when printing '1+', '1-', etc.Ludovic Courtès2023-01-09
| | | | | | | * guix/read-print.scm (%special-non-extended-symbols): New variable. (symbol->display-string): New procedure. (pretty-print-with-comments): Use it in lieu of 'string->symbol'. * tests/read-print.scm: Add test.
* read-print: Add special forms.Ludovic Courtès2022-12-20
| | | | | * guix/read-print.scm (%special-forms): Add 'define-configuration' and 'match-record'.
* read-print: Recognize 'define-record-type' and 'define-record-type*'.Ludovic Courtès2022-10-17
| | | | | * guix/read-print.scm (%special-forms): Add 'define-record-type' and 'define-record-type*'.
* read-print: Fix indentation rule for 'match-lambda*'.Ludovic Courtès2022-10-02
| | | | | | | | Fixes <https://issues.guix.gnu.org/58040>. Reported by Maxime Devos <maximedevos@telenet.be>. * guix/read-print.scm (%special-forms): Set 'match-lambda*' parameter count to 1.
* read-print: Add rule for 'home-bash-configuration'.Ludovic Courtès2022-09-20
| | | | * guix/read-print.scm (%newline-forms): Add 'home-bash-configuration'.
* read-print: Correctly support multiple same-named newline forms.Ludovic Courtès2022-09-20
| | | | | | | | | Previously (home-environment (services ...)) would not be considered a "newline form". This fixes it. * guix/read-print.scm (newline-form?): Use 'vhash-foldq*' instead of 'vhash-assq' and iterate over candidates. * tests/read-print.scm: Add test.
* read-print: Improve declaration of integer bases.Ludovic Courtès2022-09-02
| | | | | | | | | | This is a followup to c3b1cfe76b7038f4030d7d207ffc417fed9a7ead. * guix/read-print.scm (%symbols-followed-by-octal-integers) (%symbols-followed-by-hexadecimal-integers): Remove. * guix/read-print.scm (%integer-forms): New variable. (integer->string)[form-base, octal?]: New procedures. Rewrite accordingly.
* read-print: Define forms for which \n, \t, etc. are not escaped.Ludovic Courtès2022-09-02
| | | | | | | | | | | | Previously, the pretty-printer would unconditionally leave everything but double-quotes and backslashes unescaped when rendering a string. With this change, the previous behavior only applies to forms listed in %NATURAL-WHITESPACE-STRING-FORMS. * guix/read-print.scm (%natural-whitespace-string-forms): New variable. (printed-string): New procedure. (pretty-print-with-comments): Use it instead of 'escaped-string'. * tests/read-print.scm: Add test.
* read-print: Guess the base to use for integers being printed.Ludovic Courtès2022-09-01
| | | | | | | | | | | Fixes <https://issues.guix.gnu.org/57090>. Reported by Christopher Rodriguez <yewscion@gmail.com>. * guix/read-print.scm (%symbols-followed-by-octal-integers) (%symbols-followed-by-hexadecimal-integers): New variables. * guix/read-print.scm (integer->string): New procedure. (pretty-print-with-comments): Use it. * tests/read-print.scm: Add test.
* read-print: Remove unused procedure.Ludovic Courtès2022-08-10
| | | | * guix/read-print.scm (combine-vertical-space): Remove.
* read-print: Report missing closing parens instead of looping.Ludovic Courtès2022-08-10
| | | | | | | | | | | | | Fixes <https://issues.guix.gnu.org/57093>. Reported by Mohammed AMAR-BENSABER <renken@shione.net>. Previously 'read-with-comments' would enter an infinite loop. * guix/read-print.scm (read-with-comments)[missing-closing-paren-error]: New procedure. Call it when 'loop' as called from 'liip' returns EOF. * tests/read-print.scm ("read-with-comments: missing closing paren"): New test.
* read-print: Add 'case' and 'cond' special forms.Ludovic Courtès2022-08-08
| | | | | * guix/read-print.scm (%special-forms): Add 'case' and 'cond'. * tests/read-print.scm: Add tests.
* read-print: Support printing multi-line comments.Ludovic Courtès2022-08-08
| | | | | | | | * guix/read-print.scm (%not-newline): New variable. (print-multi-line-comment): New procedure. (pretty-print-with-comments): Use it. * tests/read-print.scm ("pretty-print-with-comments, multi-line comment"): New test.
* read-print: 'canonicalize-comment' leaves top-level comments unchanged.Ludovic Courtès2022-08-08
| | | | | | | | | | | This lets users use three leading semicolons, for instance, in top-level comments. * guix/read-print.scm (canonicalize-comment): Add INDENT parameter and honor it. (pretty-print-with-comments): Change default value of #:format-comment. Call FORMAT-COMMENT with INDENT as the second argument. * tests/read-print.scm: Adjust test accordingly.
* read-print: Add code to read and write sequences of expressions/blanks.Ludovic Courtès2022-08-08
| | | | | | | | * guix/read-print.scm (read-with-comments): Add #:blank-line? and honor it. (read-with-comments/sequence, pretty-print-with-comments/splice): New procedures. * tests/read-print.scm (test-pretty-print/sequence): New macro. Add tests using it.
* read-print: Recognize page breaks.Ludovic Courtès2022-08-08
| | | | | | | | | | | | | * guix/read-print.scm (<page-break>, page-break?, page-break) (char-set:whitespace-sans-page-break): New variables. (space?): New procedure. (read-vertical-space): Use it. (read-until-end-of-line): New procedure. (read-with-comments): Add #\page case. (pretty-print-with-comments): Add 'page-break?' case. * tests/read-print.scm ("read-with-comments: top-level page break"): New test. Add round-trip test with page break within an sexp.
* 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?'.
* read-print: Expose comment constructor.Ludovic Courtès2022-08-08
| | | | | | | | * guix/read-print.scm (<comment>): Rename constructor to 'string->comment'. (comment): New procedure. (read-with-comments, canonicalize-comment): Use 'string->comment' instead of 'comment'.
* read-print: Add System and Home special forms.Ludovic Courtès2022-08-08
| | | | | * guix/read-print.scm (%special-forms): Add System and Home forms. (%newline-forms): Add 'services'.
* 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'.