emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] org-plot: Handle explicit date/time index
@ 2014-03-10 17:26 Yasushi SHOJI
  2014-03-13 11:58 ` Bastien
  2014-03-23 18:41 ` Bastien
  0 siblings, 2 replies; 6+ messages in thread
From: Yasushi SHOJI @ 2014-03-10 17:26 UTC (permalink / raw)
  To: emacs-orgmode

* lisp/org-plot.el (org-plot-quote-tsv-field): Dump data as is when
  `timeind' is set.

* lisp/org-plot.el (org-plot/gnuplot): By-pass type checking when
  either `textind' or `timeind' is set.

The current org-plot relies on `org-table-number-regexp' and
`org-ts-regexp3' to check the index type.  However, we already have
`timeind' to indicate that the index is the datatype of date/time.

By-pass the type checking in `org-plot/gnuplot' when either `textind'
or `timeind' is set.  The whole point of the check is to determine the
type. We do not need that when we already know.

Also dump the date/time data with `org-plot-quote-tsv-field' as is,
without double quotes, when `timeind' is set.  So that we can use
`timefmt' to read what we have.  Currently we do not have a good way
to specify `timefmt' with the double quotes.
---

Hi,

It seems to me that dates with slash (ie. 2014/03/11) does not work
with the current org-plot.el, even if you set `timeind' and
`timefmt'. That's because the current org-plot treat "2014/03/11" as
string instead of data/time.

Here is an ECM:

	#+PLOT: ind:1
	#+PLOT: timeind:t timefmt:"%Y/%m/%d"
	#+PLOT: set:"format x '%y-%m'"
	#+PLOT: set:"xtics rotate by -45"
	| 2014/03/11 | 0 |
	| 2014/03/12 | 1 |
	| 2014/03/13 | 2 |

This patch fixes my itch but I'm not sure it doesn't break others.
Could you please test it? and tell me how it works.

BTW, do we have any test for org-plot?  Let me know if there is any.

Thanks,
-- 
            yashi

 lisp/org-plot.el | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lisp/org-plot.el b/lisp/org-plot.el
index 556b9ef..b5000ea 100644
--- a/lisp/org-plot.el
+++ b/lisp/org-plot.el
@@ -109,7 +109,8 @@ will be added.  Returns the resulting property list."
 
 (defun org-plot-quote-tsv-field (s)
   "Quote field S for export to gnuplot."
-  (if (string-match org-table-number-regexp s) s
+  (if (or (string-match org-table-number-regexp s)
+          (plist-get params :timeind)) s
     (if (string-match org-ts-regexp3 s)
 	(org-plot-quote-timestamp-field s)
       (concat "\"" (mapconcat 'identity (split-string s "\"") "\"\"") "\""))))
@@ -312,7 +313,9 @@ line directly before or after the table."
 		 (when y-labels (plist-put params :ylabels y-labels)))))
       ;; check for timestamp ind column
       (let ((ind (- (plist-get params :ind) 1)))
-	(when (and (>= ind 0) (equal '2d (plist-get params :plot-type)))
+        (when (and (>= ind 0) (equal '2d (plist-get params :plot-type))
+                   (not (or (plist-get params :timeind)
+                            (plist-get params :textind))))
 	  (if (= (length
 		  (delq 0 (mapcar
 			   (lambda (el)
-- 
1.9.0

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

* Re: [PATCH] org-plot: Handle explicit date/time index
  2014-03-10 17:26 [PATCH] org-plot: Handle explicit date/time index Yasushi SHOJI
@ 2014-03-13 11:58 ` Bastien
  2014-03-13 12:45   ` Yasushi SHOJI
  2014-03-23 18:41 ` Bastien
  1 sibling, 1 reply; 6+ messages in thread
From: Bastien @ 2014-03-13 11:58 UTC (permalink / raw)
  To: Yasushi SHOJI; +Cc: emacs-orgmode

Hi Yasushi,

I applied the patch.  Thanks for it.  I slightly modified
the commit message, please review it:

http://orgmode.org/cgit.cgi/org-mode.git/commit/?id=e2b6c506

Let's see if other users of org-plot.el report problems.

Thanks!

-- 
 Bastien

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

* Re: [PATCH] org-plot: Handle explicit date/time index
  2014-03-13 11:58 ` Bastien
@ 2014-03-13 12:45   ` Yasushi SHOJI
  0 siblings, 0 replies; 6+ messages in thread
From: Yasushi SHOJI @ 2014-03-13 12:45 UTC (permalink / raw)
  To: bzg; +Cc: emacs-orgmode

Hi Bastien,

At Thu, 13 Mar 2014 12:58:00 +0100,
Bastien wrote:
> 
> I applied the patch.  Thanks for it.  I slightly modified
> the commit message, please review it:
> 
> http://orgmode.org/cgit.cgi/org-mode.git/commit/?id=e2b6c506

No problem at all.

Thanks,
-- 
          yashi

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

* Re: [PATCH] org-plot: Handle explicit date/time index
  2014-03-10 17:26 [PATCH] org-plot: Handle explicit date/time index Yasushi SHOJI
  2014-03-13 11:58 ` Bastien
@ 2014-03-23 18:41 ` Bastien
  2014-03-24 21:37   ` Yasushi SHOJI
  1 sibling, 1 reply; 6+ messages in thread
From: Bastien @ 2014-03-23 18:41 UTC (permalink / raw)
  To: Yasushi SHOJI; +Cc: emacs-orgmode

Hi Yasushi,

Yasushi SHOJI <yashi@atmark-techno.com> writes:

> * lisp/org-plot.el (org-plot-quote-tsv-field): Dump data as is when
>   `timeind' is set.

This change produces a compiler warning:

In org-plot-quote-tsv-field:
org-plot.el:113:22:Warning: reference to free variable `params'

Can you check and fix this?

Thanks in advance,

-- 
 Bastien

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

* Re: [PATCH] org-plot: Handle explicit date/time index
  2014-03-23 18:41 ` Bastien
@ 2014-03-24 21:37   ` Yasushi SHOJI
  2014-03-25  8:26     ` Bastien
  0 siblings, 1 reply; 6+ messages in thread
From: Yasushi SHOJI @ 2014-03-24 21:37 UTC (permalink / raw)
  To: bzg; +Cc: emacs-orgmode

Hi Bastien,

At Sun, 23 Mar 2014 19:41:45 +0100,
Bastien wrote:
> 
> Yasushi SHOJI <yashi@atmark-techno.com> writes:
> 
> > * lisp/org-plot.el (org-plot-quote-tsv-field): Dump data as is when
> >   `timeind' is set.
> 
> This change produces a compiler warning:
> 
> In org-plot-quote-tsv-field:
> org-plot.el:113:22:Warning: reference to free variable `params'

Thank you for catching this.

I guess I have to re-think the whole thing. The current code by-passes
the quoting function for _all_ fields, not just for the index when
`timeind' is present.  This surely breaks for others.

I don't have much time today.  So, please give me a day or two.
Meanwhile, Bastien, would you mind to revert the commit for me?

Thanks,
-- 
             yashi

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

* Re: [PATCH] org-plot: Handle explicit date/time index
  2014-03-24 21:37   ` Yasushi SHOJI
@ 2014-03-25  8:26     ` Bastien
  0 siblings, 0 replies; 6+ messages in thread
From: Bastien @ 2014-03-25  8:26 UTC (permalink / raw)
  To: Yasushi SHOJI; +Cc: emacs-orgmode

Dear Yasushi,

Yasushi SHOJI <yashi@atmark-techno.com> writes:

> Meanwhile, Bastien, would you mind to revert the commit for me?

Done.  There is no hurry on this, thanks in advance for your time,

-- 
 Bastien

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

end of thread, other threads:[~2014-03-25  8:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-10 17:26 [PATCH] org-plot: Handle explicit date/time index Yasushi SHOJI
2014-03-13 11:58 ` Bastien
2014-03-13 12:45   ` Yasushi SHOJI
2014-03-23 18:41 ` Bastien
2014-03-24 21:37   ` Yasushi SHOJI
2014-03-25  8:26     ` Bastien

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