Up to Main Index                          Up to Journal for November, 2016

                    JOURNAL FOR FRIDAY 11TH NOVEMBER, 2016
______________________________________________________________________________

SUBJECT: You think you're coding when really you're digging a hole
   DATE: Fri 11 Nov 23:54:16 GMT 2016

Last night I thought I had better start looking at the regression I had
introduced into the code for folding text. Especially as I was holding back
the updates until it was fixed. The problem boiled down to embedded spaces
being combined into a single space. Normally this is fine. However the the
COMMANDS command uses whitespace for formatting columns. It's output should
look like:

  >commands
  "          EAST       L          NORTHWEST  SAY        SW         WEST
  COMMANDS   EXAM       LOOK       NW         SE         TAKE       WHO
  D          EXAMINE    N          PUT        SNEEZE     U
  DOWN       GET        NE         QUIT       SOUTH      UP
  DROP       INV        NORTH      READ       SOUTHEAST  VERSION
  E          INVENTORY  NORTHEAST  S          SOUTHWEST  W
  >


Instead it was looking like:


  >commands
  " EAST L NORTHWEST SAY SW WEST
  COMMANDS EXAM LOOK NW SE TAKE WHO
  D EXAMINE N PUT SNEEZE U
  DOWN GET NE QUIT SOUTH UP
  DROP INV NORTH READ SOUTHEAST VERSION
  E INVENTORY NORTHEAST S SOUTHWEST W
  >


So I spent several frustrating, fruitless hours trying to fix the problem.
After about the dozenth failure I finally gave up and went to bed. This
evening I finished work and took another stab at solving the problem. Again
multiple attempts and multiple approaches resulted in failure. The code I have
works well except for this specific problem, I don't really want to rewrite
Fold from scratch again right now.

What to do?

I had a long hard, thoughtful think. I also had dinner. Then I cheated! I
wrote a really, really butt ugly hack. It's not documented except in the Git
commit logs and this post either. I wonder how long a hack has to survive
without being rewritten before it becomes a feature?

The feature? Fold now supports hard spaces. A hard space is represented as '␠'
which is the Unicode symbol for a space U+2420 and can be found in the Control
Picture block[1]. If that glyph didn't display properly it looks like a
superscript S over a subscript P. Fold treats them as characters and
translates them to spaces on output. If you are using Vim you can enter the
glyph by using the sequence Ctrl-v u 2420 in insert mode.

Like I said, butt ugly :(

I wanted to add these changes to my textWork branch to keep things tidy.
Problem was I had already merged it into my local dev branch and then branched
my bufferWork branch off of the dev branch! *sigh*

It took me a while but I seem to have untangled the branches. In the middle of
it I misplaced some untracked files on an unrelated branch in a stash. Oops,
sorting that out and a tonne of conflicts was NOT fun. Still need to rebase
the bufferWork and I just know there will be conflicts there that need
resolving.

I may get to finally push out the text and buffer updates over the weekend.
Then again I may find I'm just digging a deeper hole, or starting on a new
one...

--
Diddymus

  [1] https://en.wikipedia.org/wiki/Unicode_control_characters


  Up to Main Index                          Up to Journal for November, 2016