Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: What would you say is the most-used way of indenting case labels



On Aug 11,  8:37pm, Peter Stephenson wrote:
}
} Time for some audience participation.  Do you prefer the following
} style?
} 
} foo () {
}         case $1 in
}                 (a) print alpha
}                 print second
}                 print third
}                 ;;
}                 (b) print beta
}                 ;;
}                 (*) print omega
}                 ;;
}         esac
} }

No, I don't.  Case labels that short are pretty unusual, and with a
long label it'd be much harder to read.  And I prefer the second and
succeeding lines indented.  I also prefer the ;; indented, but that's
not so important.

The best thing IMO would be to use the line numbers that have already
been recorded (used in error messages and warnings) to decide when to
emit a newline, so that when you list a function or whatever you can
match the output to the error.  Lines with comments that were stripped
would be a bit of a problem; perhaps an option to print them as blank
lines, or to note the jump in line number as a comment like CPP:
# line 37

Next best (or when line numbers aren't available) would be to put the
first line on the same line as the case label only when the label is
less than N characters wide (for some value of N that makes sense,
maybe 7 if we're assuming 8-space tabs) and otherwise it goes on the
next line.  Then indent the way zsh currently does.

If that's prohibitively difficult (which I suspect it is) my next
choice is to never put anything on the same line as the case label.



Messages sorted by: Reverse Date, Date, Thread, Author