Hi!

I think a recent change to org-split-string in master may have made logging
of state changes a little uglier, adding "\\" and an empty line with
trailing whitespace.  Steps to reproduce:

1. Start fresh Emacs with no local configuration (e.g. mkdir /tmp/emacs &&
HOME=/tmp/emacs emacs)

2. Install org-plus-contrib package dated 20170731

3. Create an org file with the following two lines:

~~~~~~
#+TODO: TODO(!) DONE(!)
* Test
~~~~~~

4. Move point to the beginning of the "* Test" headline and call org-todo
with C-c C-t to change it to a TODO item

Expected result:

~~~~~~
* TODO Test
  - State "TODO"       from              [2017-08-01 Tue 11:18]
~~~~~~

Actual result:

~~~~~~
* TODO Test
  - State "TODO"       from              [2017-08-01 Tue 11:18] \\

~~~~~~

Note the " \\" and blank line with trailing whitespace in the actual result.

I strongly suspect this is a result of a change in behavior of
org-split-string in f776e65373.  Before that commit, calling

    (org-split-string "" "\n")

as org-store-log-note is doing returned nil.  After f776e65373 it returns
'("").

IMHO the new behavior of org-split-string actually seems correct to me
(splitting a string should arguably never result in nil), so I've fixed
this by patching org-store-log-note as demonstrated in the attached patch.

Regards,
Dale
--- org.el.orig 2017-08-01 10:58:56.000000000 -0500
+++ org.el      2017-08-01 11:26:12.000000000 -0500
@@ -13640,7 +13640,9 @@
       (setq txt (replace-match "" t t txt)))
     (when (string-match "\\s-+\\'" txt)
       (setq txt (replace-match "" t t txt)))
-    (setq lines (org-split-string txt "\n"))
+    (setq lines (if (zerop (length txt))
+                   nil
+                 (org-split-string txt "\n")))
     (when (org-string-nw-p note)
       (setq note
            (org-replace-escapes

Reply via email to