org-add-planning-info: Improve deletion handling
commit5f3d8037a5099ca92db7edbf95ced22f0adefbef
authorKyle Meyer <kyle@kyleam.com>
Sat, 27 Jun 2015 01:33:34 +0000 (26 21:33 -0400)
committerNicolas Goaziou <mail@nicolasgoaziou.fr>
Sun, 28 Jun 2015 07:03:46 +0000 (28 09:03 +0200)
tree17b9da9b3f249333028b6dcf3982805d0cff95bb
parent5a5e4a5eeee6b9b9477726e1a1038f53cb1e8251
org-add-planning-info: Improve deletion handling

* lisp/org.el (org-add-planning-info): Reset point before each
  planning entry search.  Clean up extra spaces.

* testing/lisp/test-org.el (test-org/add-planning-info): Add tests.

- Reposition save-excursion call to reset point every dolist
  iteration.  Otherwise, the order of the entries to be removed
  matters, and a call like

      (org-add-planning-info nil nil 'scheduled 'deadline)

  on

      DEADLINE: <2015-06-26 Fri> SCHEDULED: <2015-06-26 Fri>

  will fail to remove the deadline entry.

- Delete leading white space even when at the beginning of the line so
  that, when org-adapt-indentation is nil, a space is not inserted
  when removing the leading planning info entry.

  This prevents headings with repeating entries like

      SCHEDULED: <2015-06-26 Fri +1w>

  from being closed and recycled with an extra space in front of
  SCHEDULED.

- Add leading white space to the planning info entry regexp to prevent
  leftover white space when removing entries other than the first
  entry.
lisp/org.el
testing/lisp/test-org.el