vcs-friendly-patchable-document-line-wrapping.html 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. title: VCS friendly, patchable, document line wrapping
  2. date: 2015-12-17 10:30
  3. author: Christine Lemmer-Webber
  4. tags: writing, hacking
  5. slug: vcs-friendly-patchable-document-line-wrapping
  6. ---
  7. <p>
  8. If you do enough work in any sort of free software environment, you get used
  9. to doing lots of writing of documentation or all sorts of other things in
  10. some plaintext system which exports to some non-plaintext system.
  11. One way or another you have to decide: are you going to wrap your lines with
  12. newlines?
  13. And of course the answer should be "yes" because lines that trail all the way
  14. off the edge of your terminal is a sin against the plaintext gods, who are
  15. deceptively mighty, and whose wrath is to be feared (and blessings to be
  16. embraced).
  17. So okay, of course one line per paragraph is off the table.
  18. So what do you do?
  19. </p>
  20. <p>
  21. For years I've taken the lazy way out.
  22. I'm an emacs user, and emacs comes with the `fill-paragraph' command,
  23. so conveniently mapped to M-q.
  24. So day in and day out I'm either whacking M-q now and then, or
  25. I'm being lazy and letting something like `auto-fill-mode' do the job.
  26. Overall this results in something rather pleasing to the plaintext-loving
  27. eye.
  28. If we take our first paragraph as an example, it would look like this:
  29. </p>
  30. <blockquote style="font-family: monospace">
  31. <pre>If you do enough work in any sort of free software environment, you get used to
  32. doing lots of writing of documentation or all sorts of other things in some
  33. plaintext system which exports to some non-plaintext system. One way or
  34. another you have to decide: are you going to wrap your lines with newlines?
  35. And of course the answer should be "yes" because lines that trail all the way
  36. off the edge of your terminal is a sin against the plaintext gods, who are
  37. deceptively mighty, and whose wrath is to be feared (and blessings to be
  38. embraced). So okay, of course one line per paragraph is off the table. So
  39. what do you do?</pre>
  40. </blockquote>
  41. <p>
  42. But my friends, you know as well as I do: this isn't actually good.
  43. And we know it's not good because one of the primary benefits of plaintext
  44. is that we have nice tools to diff it and patch it and check it into
  45. version control systems and so on.
  46. And the sad reality is, if you make a change at the start of a paragraph
  47. and then you re-fill (or re-wrap for you non-emacs folks) it,
  48. <i>you are going to have a bad time!</i>
  49. Why?
  50. Because imagine you and your friends are working on this document together,
  51. and you're working in some branch of your document, and then your friend
  52. Sarah or whoever sends you a patch and you're so excited to merge it,
  53. and she does a nice job and edits a bunch of paragraphs and re-wraps it or
  54. re-fills them because why <i>wouldn't</i> she do that, it's the best
  55. convention you have, so you happily merge it in and say thanks, you look
  56. forward to future edits, and then you go to merge in your own branch you've
  57. been working on privately, but oh god oh no you were working on your own
  58. overhaul which re-wrapped many of the same paragraphs
  59. <i>and now there are merge conflicts everywhere.</i>
  60. </p>
  61. <p>
  62. That's not an imaginary possibility; if you've worked on a documentation
  63. project big enough, I suspect you've hit it.
  64. And hey, look, maybe you haven't hit it, because maybe most of your writing
  65. projects aren't so fast paced.
  66. But have you ever looked at your version control log?
  67. Ever done a `git/svn/foo blame', `git/svn/foo praise', or whatever
  68. convention?
  69. Eventually you can't figure out what commit anything came from, and my
  70. friends, that is a bad time.
  71. </p>
  72. <p>
  73. In trying to please the plaintext gods, we have defiled their temple.
  74. Can we do better?
  75. </p>
  76. <p>
  77. One interesting suggestion I've heard, but just can't get on board with,
  78. is to keep each sentence on its own line.
  79. It's a nice idea, and I want to like it, because the core idea is good:
  80. each sentence doesn't interfere with the one before or after it,
  81. so if you change a sentence, it's easy for both you and the computer
  82. to tell which one.
  83. This means you can check things in and out of version control,
  84. send and receive patches, and from that whole angle, things are great.
  85. </p>
  86. <p>
  87. But it's a <i>sin to the eye</i> to have stuff scrolling off the edge of
  88. your terminal like that, and each sentence on its own line, well...
  89. it just confuses me.
  90. Let's re-look at that first paragraph again in this style:
  91. </p>
  92. <blockquote style="font-family: monospace">
  93. <pre>If you do enough work in any sort of free software environment, you get used to doing lots of writing of documentation or all sorts of other things in some plaintext system which exports to some non-plaintext system.
  94. One way or another you have to decide: are you going to wrap your lines with newlines?
  95. And of course the answer should be "yes" because lines that trail all the way off the edge of your terminal is a sin against the plaintext gods, who are deceptively mighty, and whose wrath is to be feared (and blessings to be embraced).
  96. So okay, of course one line per paragraph is off the table.
  97. So what do you do?</pre>
  98. </blockquote>
  99. <p>
  100. Ugh, it's hard to put into words why this is so offensive to me.
  101. I guess it's because each sentence can get so long that it looks like
  102. the separation between sentence is a bigger break than the separation
  103. between paragraphs.
  104. And I just hate things scrolling off to the right like that. I don't want
  105. to be halfway through reading a word on my terminal and then have to jump
  106. back so I can keep reading it.
  107. </p>
  108. <p>
  109. So no, this is not good either.
  110. But it <i>is</i> on the right track.
  111. Is there a way to get the best of both worlds?
  112. </p>
  113. <p>
  114. Recently, when talking about this problem with my good friend
  115. <a href="https://dthompson.us/">David Thompson</a>, I came to realize
  116. that there is a potentially great solution that makes a hybrid of the
  117. technical merits of the one-sentence-per-line approach and the visually
  118. pleasing merits of the wrap/fill-your-paragraph approach.
  119. And the answer is: put each sentence on its own line, and wrap each
  120. sentence!
  121. </p>
  122. <p>
  123. This is best seen to be believed, so let's take a look at that first
  124. paragraph again... this time, as I typed it into my blogging system:
  125. </p>
  126. <blockquote style="font-family: monospace">
  127. <pre>If you do enough work in any sort of free software environment, you get used
  128. to doing lots of writing of documentation or all sorts of other things in
  129. some plaintext system which exports to some non-plaintext system.
  130. One way or another you have to decide: are you going to wrap your lines with
  131. newlines?
  132. And of course the answer should be "yes" because lines that trail all the way
  133. off the edge of your terminal is a sin against the plaintext gods, who are
  134. deceptively mighty, and whose wrath is to be feared (and blessings to be
  135. embraced).
  136. So okay, of course one line per paragraph is off the table.
  137. So what do you do?</pre>
  138. </blockquote>
  139. <p>
  140. Yes, yes, yes!
  141. This is what we want!
  142. Now it looks good, and it merges good.
  143. And we still can preserve the multi-line separation between paragraphs.
  144. Also, you might notice that I continue each sentence by giving two spaces
  145. before its wrapped continuation, and I think that's an extra nice touch
  146. (but you don't have to do it).
  147. </p>
  148. <p>
  149. This is how I'm writing all my documentation, and the style in which I will
  150. request all documentation for projects I start be written in, from now
  151. on.
  152. Now if you're writing an email, or something else that's meant to be read
  153. in plaintext as-is (you do read/write your email in plaintext, right?),
  154. then maybe you should just do the traditional fill paragraph approach.
  155. After all, you want that to look nice, and in many of those cases,
  156. the text doesn't change too much.
  157. But if you're writing something where the plaintext version is just
  158. intermediate, and you have some other export which is what people
  159. mostly will read, I think this is a rather dandy approach.
  160. </p>
  161. <p>
  162. I hope you find it useful as well!
  163. Happy documentation hacking!
  164. </p>