emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Bug: Blank line when logging state changes [9.0.9 (9.0.9-692-gfbf31d.dirty-elpaplus @ /tmp/emacs/.emacs.d/elpa/org-plus-contrib-20170801/)]
@ 2017-08-01 16:27 Dale Sedivec
  2017-08-01 18:30 ` Nicolas Goaziou
  0 siblings, 1 reply; 2+ messages in thread
From: Dale Sedivec @ 2017-08-01 16:27 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 1329 bytes --]

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

[-- Attachment #1.2: Type: text/html, Size: 2010 bytes --]

[-- Attachment #2: org-store-log-note.diff --]
[-- Type: text/plain, Size: 469 bytes --]

--- 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Bug: Blank line when logging state changes [9.0.9 (9.0.9-692-gfbf31d.dirty-elpaplus @ /tmp/emacs/.emacs.d/elpa/org-plus-contrib-20170801/)]
  2017-08-01 16:27 Bug: Blank line when logging state changes [9.0.9 (9.0.9-692-gfbf31d.dirty-elpaplus @ /tmp/emacs/.emacs.d/elpa/org-plus-contrib-20170801/)] Dale Sedivec
@ 2017-08-01 18:30 ` Nicolas Goaziou
  0 siblings, 0 replies; 2+ messages in thread
From: Nicolas Goaziou @ 2017-08-01 18:30 UTC (permalink / raw)
  To: Dale Sedivec; +Cc: emacs-orgmode

Hello,

Dale Sedivec <dale@codefu.org> writes:

> 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:
>

[...]

> 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.

I agree the current behaviour is correct, since `org-split-string' does
not trim null strings. I applied a patch morally equivalent to yours.

Thank you for the report and the analysis.


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-08-01 18:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-01 16:27 Bug: Blank line when logging state changes [9.0.9 (9.0.9-692-gfbf31d.dirty-elpaplus @ /tmp/emacs/.emacs.d/elpa/org-plus-contrib-20170801/)] Dale Sedivec
2017-08-01 18:30 ` Nicolas Goaziou

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).