magit-insert-header: replace magit-insert-line-section

The new function has a name that more explicitly says what this is
intended for, and it is more convenient.
magit-insert-status-remote-line: absorb magit-format-tracked-line
magit-insert-status-remote-line: don't put parens around url

Since we also don't do that for the path on the header inserted
by `magit-insert-status-local-line'.
give each header section a suitable type and value

And for headers that don't have a value use `header' instead of `line'
as type.
clarify distinction between a section's type and value

Originally there were these three related but distinct slots: `type',
`info', and `header'.  The last one was unnecessary and only existed
because someone got confused about the distinction between the other
two and was removed when I last refactored the section code.

Now the time has come to make the distinction between the "type" and the
"info" more clear.  We start by using the term "value" instead of
"info", because that's what it is.

There are two categories of sections: those that represent a thing, and
those that serve as containers for other sections.  A section can fall
into both categories.

Every section has a type, a symbol.  Sections that represent a "thing",
such as a file or hunk also have a value, usually a string (but that is
not enforced).  Sections that only serve as containers do not have a
value (i.e. the value is nil).

Together the type and value of a section and the types of recursively
all parent sections can be used to uniquely identify a section within
a buffer.  For container-only sections the types are sufficient because
there always is only one section of a particular container-only
type.  (That is a convention and isn't enforced.)  Meanwhile there can
be many e.g. `commit' sections and to tell them apart the values (here
the commit hashes) also have to be compared.

Sadly someone got confused along the way and started to use the just
the values (then more ambitiously called "info") to identify sections.
Since many sections don't actually have a value the result was that
for sections that would otherwise not have a value, the type was stored
in the `value' slot as well.

This commit adds function `magit-section-ident' which returns a list of
conses that can be used to uniquely identify a section as described.
Function `magit-find-section' is changed to use that value, instead of
using the value-except-when-it-actually-is-the-type.  For sections that
have no value the value of the `value' slot now is nil.
rename section struct slot BEGINNING to START

This causes the accessor `magit-section-beginning' to be renamed to
`magit-section-start'.  I'll admit it, I am doing this just because
"start" is shorter than "beginning".  Because the section code is
currently being refactored heavily anyway, doing so now causes only
little additional harm (in form of third-party code that might have
to be adapted), if any.
rename section struct slot CONTENT-BEGINNING to CONTENT

Currently this slot always holds a marker (though sometimes it points
somewhere strange and cannot be relied on).  Starting in subsequent
commits this slot will be used to hold either such a marker, nil (to
indicate that the section has no body), or a function (which is then
used to actually create the body on expansion).
magit-with-section: make NAME argument optional, move before ARGLIST

There actually are very few cases where the BODY of `magit-with-section'
has to refer to the section object, so it doesn't make sense to always
have to specify the name of the "symbol which isn't being used".
magit-{insert,put-face-property}: move definitions

These functions are intended for use in `magit-with-section's BODY only.
magit-with-section: insert the heading before the body

Remove the HEADING argument from `magit-with-section' and instead expect
the callers to insert the HEADING themselves, using the new
`magit-insert-heading'.  Besides inserting the heading text in a fashion
similar to how the more general `magit-insert' works, this function also
sets the sections CONTENT slot to the position after the text previously
inserted.  The default value of that slot now is nil, indicating that
the section isn't divided into a heading and a body, i.e. it cannot be
collapsed.

Previously `magit-with-section' did evaluate its BODY to insert the
sections body text, and only then went back to the beginning of the
section and inserted the heading it had received as a separate argument.
This was done because when HEADING ending with ":" indicates that the
number of child sections shall be shown in the heading.  We no longer
delay inserting the heading until we know how many children there are.
Instead we insert the heading without the count and then later go back
and insert the count.  Inserting the heading later than the body
complicated things a lot and lead to difficult to fix bugs.
magit-cancel-section: new function

Previously we depended on the return value of `magit-with-section'
being nil to trigger the cancellation of the section currently being
inserted.  Now we use the new function `magit-cancel-section' which
does a non-local exit from a catch setup in `magit-with-section'.

Doing it this way is not necessary at this point yet, but it does give
us additional flexibility.  I.e. code that inserts a section no longer
has to be lexically within `magit-with-section's BODY.  We will use that
in a subsequent commit.
rename magit-with-section to magit-insert-section

Because this is a macro that does "something with something" the term
"with" actually does make sense.  However the "something it does" is
different from that that macros that are part of Emacs do.  We do not
make something current that already exists and we also don't create
something which is disposed of again after the macros BODY.  I.e. our
macro is neither like `with-current-buffer' nor like `with-temp-buffer'.

The side-effect of inserting a section is the raison d'être of this
macro.  Reflect that in the name.
magit-git-wash: new function

Separate the task of inserting and washing output from a command from
the task of creating a section.  This in a sense was already the case
previously in that `magit-cmd-insert-section' made use of the macro
`magit-insert-section' to do the creation part.

Replace `magit-cmd-insert-section' and `magit-cmd-insert-section' with
`magit-git-wash'.  It is just a thin wrapper around `magit-git-insert'
which additionally calls some function to wash the inserted text.  It
also knows how to cancel the section currently being created if either
Git produces no output or washing the output completely.  That is
different from what `magit-cmd-insert-section' which never canceled
before calling the washer.

Code that previously used `magit-git-insert-section' now has to
explicitly use `magit-insert-section', `magit-insert-heading', and
`magit-git-wash'.  That usually means that it takes four lines of code
instead of tree to do so, but it also makes this more flexible and
prettier to look at.

There is no substitute for `magit-cmd-insert-section', i.e. we now only
provide a "insert-and-wash" function for Git but not arbitrary commands,
because, well that's what Magit is about.  There were only two direct
uses of `magit-cmd-insert-section', one in `magit-stgit.el' and one in
`magit-topgit.el'.  These uses are now replaced with a bit of code
duplication.
magit-insert-header: change signature

This follows similar changes to `magit-insert-section'.
improve process sections

Create all process sections "expanded".  Previously we did initially
collapse sections unless the *magit-process* buffer was already visible
in the current frame.  That was inconvenient because one might switch
to that buffer to see why something is taking long, only to first have
to expand the respective section.

Never-the-less it is useful to hide sections whose output the user
"probably doesn't want to see" in most cases.  So when a process returns
with exit code then the section is automatically collapsed.

Likewise inserting the exit code into the process sections buffer is now
done in a more reasonable way, without ending up putting point somewhere
inside the heading, instead of at its beginning.

Also do not put an extra empty line between sections and remove some
other kludges.  Now that headings are inserted before their bodies we no
longer need to do that.
Merge branch 'n/insert-section' into next