org-agenda.el (org-cmp-ts): Fix call to `type'

* org-agenda.el (org-cmp-ts): Argument `type' is not optional.
Don't quote it.
Merge branch 'maint'
Warn users of malformed property drawers

* org.el (org-buffer-property-keys): When scanning the buffer for
valid property keys, give users a chance to repair any malformed
property drawers.
org.el (org-cycle-internal-local): Fix trailing character bug

* org.el (org-cycle-internal-local): Don't show a trailing
character when cycling a subtree that ends with a non-newline
character at the end of the buffer or the narrowed region.
org.el: Don't advise `outline-end-of-subtree'

* org.el (org-move-subtree-down): Use `org-end-of-subtree'
instead of `outline-end-of-subtree'.
(outline-end-of-subtree): Remove advice.

* org-mouse.el (org-mouse-move-tree, org-mouse-do-remotely):
Use `org-end-of-subtree' instead of `outline-end-of-subtree'.
Merge branch 'maint'
org-agenda.el (org-agenda-remove-filter): Use `save-excursion'

* org-agenda.el (org-agenda-remove-filter): Use `save-excursion'.
Merge branch 'maint'
org-capture.el (org-capture-steal-local-variables): Don't steal `mark-active'

* org-capture.el (org-capture-steal-local-variables): Don't
steal `mark-active', which should be nil in the target buffer.

Thanks to Alex Kosorukoff for raising this issue.
Merge branch 'maint'
org.el: Implement agenda sorting against stats cookies.  Code cleanup

* org.el (org-refresh-category-properties): Don't put the
'org-category-position property.
(org-refresh-stats-properties): New function.
(org-agenda-ignore-properties): Rename from
`org-agenda-ignore-drawer-properties', which is now obsolete.
Allow to use 'stats.
(org-agenda-prepare-buffers): Check stats properties.
(org-get-at-bol): Make a defsubst.
(org-get-at-eol): New function.

* org-agenda.el (org-entries-lessp): Sort by statistic
cookies.
(org-search-view, org-agenda-get-todos)
(org-agenda-get-timestamps, org-agenda-get-sexps)
(org-agenda-get-progress, org-agenda-get-deadlines)
(org-agenda-get-scheduled, org-agenda-get-blocks): Don't set
the 'org-category and 'org-category-pos text properties.
'org-category-pos is useless and 'org-category is set through
`org-agenda-format-item'.
(org-agenda-format-item): Remove useless code.
(org-cmp-priority): Delete.
(org-cmp-values): New function to compare text properties
values.
(org-cmp-effort, org-agenda-to-appt): Check against the end of
the line.
(org-agenda-filter-by-category, org-agenda-filter-apply)
(org-agenda-change-all-lines): Use `org-get-at-eol'.
org-agenda.el (org-agenda-format-item): Don't add the 'effort and 'effort-minutes text properties

* org-agenda.el (org-agenda-format-item): Don't add the
'effort and 'effort-minutes text properties as they are
already accessible through the 'txt property of agenda lines.

* org-clock.el (org-clock-in): Refresh both the 'effort and
'effort-minutes text properties.

* org-rmail.el (rmail, rmail-file-name): Silent byte-compiler.

* org.el (org-refresh-properties): Allow to set several text
properties by passing an alist to the TPROP argument.
(org-set-effort, org-property-next-allowed-value): Use 'effort
instead of 'org-effort.
(org-agenda-prepare-buffers): Update both 'effort and
'effort-minutes.
(org-mark-jump-unhide): Move up to silent the byte-compiler.
org-get-wdays may return fractional number of days
org-deadline-close obeys sub-day "closeness."
org-deadline-close returns T for incomplete, overdue item.
Don't add so many newlines when archiving

This hopefully solves two cases:

1. Extra newline(s) when not archiving under a specific headline
2. Extra newline(s) when archiving under a specific headline.
Add :collapse-steps argument to clocktable

This lets me use :step but have each step generate rows in a single
table.
Don't use insert-before-markers when pasting

This line was first changed from insert to insert-before-markers in
218feee7.  This commit changes it back.

Problem is this: when you capture with a :prepend t template to the
(point-min) in a buffer, capture creates an indirect buffer and then
does (org-paste-subtree) into it, which was using
(insert-before-markers).  As near as I can tell, (point-min) is
implemented with a marker, so (insert-before-markers) at (point-min) in
an indirect buffer actually ends up moving (point-min) forward in the
base buffer.  The result is that you just captured something but you
can't see it in the buffer it was captured into, because that buffer was
narrowed.

I'm not sure what the consequences of this change will be, but I'm
willing to try it so I don't go crazy wondering why my journal entries
are missing until I revert the buffer (or notice that it's narrowed).
Case sensitive match todo keywords in statistics

With my default case-fold-search value this code would match a
headline with text such as "Done back in may" as starting with the
DONE keyword, this inflating my statistics.
Add REFILE_REVERSE_NOTE_ORDER property

This lets you change the value of org-reverse-note-order when refiling
to a subtree.  I use this because I usually like to refile to the
beginning of a heading, but I have some "queue-like" headings where I
want to refile to the end, not the beginning.