aboutsummaryrefslogtreecommitdiff
path: root/doc/manual
diff options
context:
space:
mode:
authoralois31 <alois1@gmx-topmail.de>2024-07-19 06:40:13 +0000
committerGerrit Code Review <gerrit@localhost>2024-07-19 06:40:13 +0000
commitaba5f19680b2f4c29d7ce2ff5e2a89128c1cb26d (patch)
treec1c3ce68cd7aab98167a394e11934ebcaed27ade /doc/manual
parent5ee1e6ea9887a54f0af3a66528abc04b17611516 (diff)
parent768d1f29a2dcd9ed9552fafb4ab836ea2e400738 (diff)
Merge changes I829581a3,I0016970d,I5dac8e77,Ib7560fe5 into main
* changes: doc/release-notes: add for pretty printing improvements libexpr/print: do not show elided nested items when there are none libexpr/print: never show empty attrsets or derivations as «repeated» libexpr/print: pretty-print idempotently
Diffstat (limited to 'doc/manual')
-rw-r--r--doc/manual/rl-next/pretty-printing.md58
1 files changed, 58 insertions, 0 deletions
diff --git a/doc/manual/rl-next/pretty-printing.md b/doc/manual/rl-next/pretty-printing.md
new file mode 100644
index 000000000..f7953f9ff
--- /dev/null
+++ b/doc/manual/rl-next/pretty-printing.md
@@ -0,0 +1,58 @@
+---
+synopsis: "Eliminate some pretty-printing surprises"
+cls: [1616, 1617, 1618]
+prs: [11100]
+credits: [alois31, roberth]
+category: Improvements
+---
+
+Some inconsistent and surprising behaviours have been eliminated from the pretty-printing used by the REPL and `nix eval`:
+* Lists and attribute sets that contain only a single item without nested structures are no longer sometimes inappropriately indented in the REPL, depending on internal state of the evaluator.
+* Empty attribute sets and derivations are no longer shown as `«repeated»`, since they are always cheap to print.
+ This matches the existing behaviour of `nix-instantiate` on empty attribute sets.
+ Empty lists were never printed as `«repeated»` already.
+* The REPL by default does not print nested attribute sets and lists, and indicates elided items with an ellipsis.
+ Previously, the ellipsis was printed even when the structure was empty, so that such items do not in fact exist.
+ Since this behaviour was confusing, it does not happen any more.
+
+Before:
+```
+nix-repl> :p let x = 1 + 2; in [ [ x ] [ x ] ]
+[
+ [
+ 3
+ ]
+ [ 3 ]
+]
+
+nix-repl> let inherit (import <nixpkgs> { }) hello; in [ hello hello ]
+[
+ «derivation /nix/store/fqs92lzychkm6p37j7fnj4d65nq9fzla-hello-2.12.1.drv»
+ «repeated»
+]
+
+nix-repl> let x = {}; in [ x ]
+[
+ { ... }
+]
+```
+
+After:
+```
+nix-repl> :p let x = 1 + 2; in [ [ x ] [ x ] ]
+[
+ [ 3 ]
+ [ 3 ]
+]
+
+nix-repl> let inherit (import <nixpkgs> { }) hello; in [ hello hello ]
+[
+ «derivation /nix/store/fqs92lzychkm6p37j7fnj4d65nq9fzla-hello-2.12.1.drv»
+ «derivation /nix/store/fqs92lzychkm6p37j7fnj4d65nq9fzla-hello-2.12.1.drv»
+]
+
+nix-repl> let x = {}; in [ x ]
+[
+ { }
+]
+```