Re: [O] [PATCH] key-binding for all plotting styles

2014-10-14 Thread Thierry Banel
Le 14/10/2014 23:08, Nicolas Goaziou a écrit :
> __ _  _   
>/ \   _ __  _ __ | (_) ___  __| |  
>   / _ \ | '_ \| '_ \| | |/ _ \/ _` |  
>  / ___ \| |_) | |_) | | |  __/ (_| |_ 
> /_/   \_\ .__/| .__/|_|_|\___|\__,_(_)
> |_|   |_| 
>
>
>
_
  _(\
 (_)\ \
 \ \
  ) )
 _ / /
 (_)/ /
   (_/




Re: [O] [PATCH] key-binding for all plotting styles

2014-10-14 Thread Nicolas Goaziou
Hello,

Thierry Banel  writes:

> Here is the updated patch.

[...]

>> BTW is-it ASCII-art or ascii-art?
> Changed to capitals.
__ _  _   
   / \   _ __  _ __ | (_) ___  __| |  
  / _ \ | '_ \| '_ \| | |/ _ \/ _` |  
 / ___ \| |_) | |_) | | |  __/ (_| |_ 
/_/   \_\ .__/| .__/|_|_|\___|\__,_(_)
|_|   |_| 


Thank you.


Regards,

-- 
Nicolas Goaziou



Re: [O] [PATCH] key-binding for all plotting styles

2014-10-14 Thread Thierry Banel
Here is the updated patch.

To see the result:
- cd to org-mode tree root
- make info
- launch Emacs
- C-u C-h i doc/org RET
- search for "Org-Plot" chapter

Regards
Thierry


Le 13/10/2014 18:24, Nicolas Goaziou a écrit :
>
> Some comments follow.
> ...
>
> It should be
>
>   @kbd{M-x org-plot/gnuplot @key{RET}}
>   @kbd{M-x orgtbl-ascii-plot @key{RET}}
>   @samp{too small} or @samp{too large}.
>   @samp{12}
Fixed

> Note there is also the macro
>
>   @orgcmd{C-c " g,org-plot/gnuplot}
This macro is used as bullet items in a @table
I cannot use it in the middle of a text.

> BTW is-it ASCII-art or ascii-art?
Changed to capitals.



>From 5168483137640a896501c88740052fe5112bed54 Mon Sep 17 00:00:00 2001
From: Thierry Banel 
Date: Tue, 14 Oct 2014 22:34:54 +0200
Subject: [PATCH] Document ASCII-art plot

* doc/org.texi: Extend Gnuplot chapter to ASCII-art plotting.
* etc/ORG-NEWS: Document ASCII-art plot.
---
 doc/org.texi | 57 -
 etc/ORG-NEWS |  2 ++
 2 files changed, 54 insertions(+), 5 deletions(-)

diff --git a/doc/org.texi b/doc/org.texi
index 05df0eb..767fa1a 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -3258,11 +3258,17 @@ functions.
 @cindex plot tables using Gnuplot
 @cindex #+PLOT
 
-Org-Plot can produce 2D and 3D graphs of information stored in org tables
-using @file{Gnuplot} @uref{http://www.gnuplot.info/} and @file{gnuplot-mode}
+Org-Plot can produce graphs of information stored in org tables, either
+graphically or in ASCII-art.
+
+@subheading Graphical plots using @file{Gnuplot}
+
+Org-Plot produces 2D and 3D graphs using @file{Gnuplot}
+@uref{http://www.gnuplot.info/} and @file{gnuplot-mode}
 @uref{http://xafs.org/BruceRavel/GnuplotMode}.  To see this in action, ensure
 that you have both Gnuplot and Gnuplot mode installed on your system, then
-call @code{org-plot/gnuplot} on the following table.
+call @kbd{C-c " g} or @kbd{M-x org-plot/gnuplot @key{RET}} on the following
+table.
 
 @example
 @group
@@ -3280,8 +3286,8 @@ call @code{org-plot/gnuplot} on the following table.
 Notice that Org Plot is smart enough to apply the table's headers as labels.
 Further control over the labels, type, content, and appearance of plots can
 be exercised through the @code{#+PLOT:} lines preceding a table.  See below
-for a complete list of Org-plot options.  For more information and examples
-see the Org-plot tutorial at
+for a complete list of Org-plot options.  The @code{#+PLOT:} lines are
+optional.  For more information and examples see the Org-plot tutorial at
 @uref{http://orgmode.org/worg/org-tutorials/org-plot.html}.
 
 @subsubheading Plot Options
@@ -3337,6 +3343,47 @@ may still want to specify the plot type, as that can impact the content of
 the data file.
 @end table
 
+@subheading ASCII bar plots
+
+While the cursor is on a column, typing @kbd{C-c \" a} or
+@kbd{M-x orgtbl-ascii-plot @key{RET}} create a new column containing an
+ASCII-art bars plot.  The plot is implemented through a regular column
+formula.  When the source column changes, the bar plot may be updated by
+refreshing the table, for example typing @kbd{C-u C-c *}.
+
+@example
+@group
+| Sede  | Max cites |  |
+|---+---+--|
+| Chile |257.72 |  |
+| Leeds |165.77 | WWWh |
+| Sao Paolo | 71.00 | WWW; |
+| Stockholm |134.19 | WW:  |
+| Morelia   |257.56 | WWWH |
+| Rochefourchat |  0.00 |  |
+#+TBLFM: $3='(orgtbl-ascii-draw $2 0.0 257.72 12)
+@end group
+@end example
+
+The formula is an elisp call:
+@lisp
+(orgtbl-ascii-draw COLUMN MIN MAX WIDTH)
+@end lisp
+
+@table @code
+@item COLUMN
+  is a reference to the source column.
+
+@item MIN MAX
+  are the minimal and maximal values displayed.  Sources values
+  outside this range are displayed as @samp{too small}
+  or @samp{too large}.
+
+@item WIDTH
+  is the width in characters of the bar-plot.  It defaults to @samp{12}.
+
+@end table
+
 @node Hyperlinks
 @chapter Hyperlinks
 @cindex hyperlinks
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 0a5af68..e94dec6 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -96,6 +96,8 @@ would throw an error. A new variable
 ~org-table-formula-create-columns~ was added to adjust this
 behavior. It is now possible to silently add new columns, to do so
 with a warning or to explicitly ask the user each time.
+*** ASCII plot
+Ability to plot values in a column through ASCII-art bars.
 ** Miscellaneous
 *** File names in links accept are now compatible with URI syntax
 Absolute file names can now start with =///= in addition to =/=. E.g.,
-- 
1.9.1



Re: [O] [PATCH] key-binding for all plotting styles

2014-10-13 Thread Thierry Banel
Thanks Nicolas for your feedback.
I'll do the adjustments.

Le 13/10/2014 18:24, Nicolas Goaziou a écrit :
>
> Some comments follow.
>
> ...
> BTW is-it ASCII-art or ascii-art?
>
>

Good question!
When asking Google, we get every possible combination, in decreasing
order of occurrences:
  ASCII Art
  ASCII ART
  Ascii Art
  ASCII art
  ascii art
The Internet seems to vote for capitals.
The Emacs info pages capitalize the whole word: ASCII.
So, you are right, ASCII is the way to go.

jQWBVVVTVH$QQQ
jQQ@?nc?""-  - -""!<2Y$WQQ
jQQWVY+~^  . "->YUWQQQ
j@5)~ .   .   .  ~{7$Q
jQQWT+'   . ..  -"??9QQma. "i9
jQDl~ .  .   )agm
jQQWWwa%>T==T|swwB
jQQmmmQWWW




Re: [O] [PATCH] key-binding for all plotting styles

2014-10-13 Thread Nicolas Goaziou
Hello,

Thierry Banel  writes:

> Done.

Thank you.

> To see the result:
> - cd to org-mode tree root
> - make info
> - launch Emacs
> - C-u C-h i doc/org RET
> - search for "Org-Plot" chapter

Some comments follow.

> -call @code{org-plot/gnuplot} on the following table.
> +call @kbd{C-c " g} or @code{M-x org-plot/gnuplot RET} on the
> following table.

It should be

  @kbd{M-x org-plot/gnuplot @key{RET}}

Note there is also the macro

  @orgcmd{C-c " g,org-plot/gnuplot}

> +While the cursor is on a column, typing @kbd{C-c " a} or
> +@code{M-x orgtbl-ascii-plot RET} create a new column containing an
> ascii-art

  @kbd{M-x orgtbl-ascii-plot @key{RET}}

> +bars plot.  The plot is implemented through a regular column formula.  When
> +the source column changes, the bar plot may be updated by refreshing the
> +table, for example typing @kbd{C-u C-c *}.

> +@item MIN MAX
> +  are the minimal and maximal values displayed.  Sources values
> +  outside this range are displayed as @code{too small}
> +  or @code{too large}.

  @samp{too small} or @samp{too large}.

> +@item WIDTH
> +  is the width in characters of the bar-plot.  It defaults to
> @code{12}.

  @samp{12}

> +*** Ascii plot
> +Ability to plot values in a column through ascii-art bars.

BTW is-it ASCII-art or ascii-art?


Regards,

-- 
Nicolas Goaziou



Re: [O] [PATCH] key-binding for all plotting styles

2014-10-12 Thread Thierry Banel
Le 12/10/2014 11:28, Nicolas Goaziou a écrit :
> Would you mind providing some documentation about the feature in the
> manual, and updating ORG-NEWS?
>
>

Done.

To see the result:
- cd to org-mode tree root
- make info
- launch Emacs
- C-u C-h i doc/org RET
- search for "Org-Plot" chapter


Have fun
Thierry

>From 916f974ed4597e3d03124089d6ce90ccd3d235cf Mon Sep 17 00:00:00 2001
From: Thierry Banel 
Date: Sun, 12 Oct 2014 15:23:12 +0200
Subject: [PATCH] Document ascii art plot

* doc/org.texi: Extend Gnuplot chapter to ascii art plotting.
* etc/ORG-NEWS: Document ascii art plot.
---
 doc/org.texi | 56 +++-
 etc/ORG-NEWS |  2 ++
 2 files changed, 53 insertions(+), 5 deletions(-)

diff --git a/doc/org.texi b/doc/org.texi
index ad872a8..91fa211 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -3258,11 +3258,16 @@ functions.
 @cindex plot tables using Gnuplot
 @cindex #+PLOT
 
-Org-Plot can produce 2D and 3D graphs of information stored in org tables
-using @file{Gnuplot} @uref{http://www.gnuplot.info/} and @file{gnuplot-mode}
+Org-Plot can produce graphs of information stored in org tables, either
+graphically or in ascii-art.
+
+@subheading Graphical plots using @file{Gnuplot}
+
+Org-Plot produces 2D and 3D graphs using @file{Gnuplot}
+@uref{http://www.gnuplot.info/} and @file{gnuplot-mode}
 @uref{http://xafs.org/BruceRavel/GnuplotMode}.  To see this in action, ensure
 that you have both Gnuplot and Gnuplot mode installed on your system, then
-call @code{org-plot/gnuplot} on the following table.
+call @kbd{C-c " g} or @code{M-x org-plot/gnuplot RET} on the following table.
 
 @example
 @group
@@ -3280,8 +3285,8 @@ call @code{org-plot/gnuplot} on the following table.
 Notice that Org Plot is smart enough to apply the table's headers as labels.
 Further control over the labels, type, content, and appearance of plots can
 be exercised through the @code{#+PLOT:} lines preceding a table.  See below
-for a complete list of Org-plot options.  For more information and examples
-see the Org-plot tutorial at
+for a complete list of Org-plot options.  The @code{#+PLOT:} lines are
+optional.  For more information and examples see the Org-plot tutorial at
 @uref{http://orgmode.org/worg/org-tutorials/org-plot.html}.
 
 @subsubheading Plot Options
@@ -3337,6 +3342,47 @@ may still want to specify the plot type, as that can impact the content of
 the data file.
 @end table
 
+@subheading Ascii bar plots
+
+While the cursor is on a column, typing @kbd{C-c " a} or
+@code{M-x orgtbl-ascii-plot RET} create a new column containing an ascii-art
+bars plot.  The plot is implemented through a regular column formula.  When
+the source column changes, the bar plot may be updated by refreshing the
+table, for example typing @kbd{C-u C-c *}.
+
+@example
+@group
+| Sede  | Max cites |  |
+|---+---+--|
+| Chile |257.72 |  |
+| Leeds |165.77 | WWWh |
+| Sao Paolo | 71.00 | WWW; |
+| Stockholm |134.19 | WW:  |
+| Morelia   |257.56 | WWWH |
+| Rochefourchat |  0.00 |  |
+#+TBLFM: $3='(orgtbl-ascii-draw $2 0.0 257.72 12)
+@end group
+@end example
+
+The formula is an elisp call:
+@lisp
+(orgtbl-ascii-draw COLUMN MIN MAX WIDTH)
+@end lisp
+
+@table @code
+@item COLUMN
+  is a reference to the source column.
+
+@item MIN MAX
+  are the minimal and maximal values displayed.  Sources values
+  outside this range are displayed as @code{too small}
+  or @code{too large}.
+
+@item WIDTH
+  is the width in characters of the bar-plot.  It defaults to @code{12}.
+
+@end table
+
 @node Hyperlinks
 @chapter Hyperlinks
 @cindex hyperlinks
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 0a5af68..a29eec6 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -96,6 +96,8 @@ would throw an error. A new variable
 ~org-table-formula-create-columns~ was added to adjust this
 behavior. It is now possible to silently add new columns, to do so
 with a warning or to explicitly ask the user each time.
+*** Ascii plot
+Ability to plot values in a column through ascii-art bars.
 ** Miscellaneous
 *** File names in links accept are now compatible with URI syntax
 Absolute file names can now start with =///= in addition to =/=. E.g.,
-- 
1.9.1



Re: [O] [PATCH] key-binding for all plotting styles

2014-10-12 Thread Thierry Banel
Le 12/10/2014 11:28, Nicolas Goaziou a écrit :
> Applied. Thank you.
>
> Would you mind providing some documentation about the feature in the
> manual, and updating ORG-NEWS?
>
> Regards,
>
Sure! Will do that shortly.




Re: [O] [PATCH] key-binding for all plotting styles

2014-10-12 Thread Nicolas Goaziou
Hello,

Thierry Banel  writes:

> Here is a patch which bindskeys:
>
>   C-c " a   orgtbl-ascii-plot(creates an ascii plot for the column where
> the cursor is)
>   C-c " g   org-plot/gnuplot  (nicely launches Gnuplot for all columns)
>
> It also adds a sub-menu named "Plot" in the "Tbl" menu with those two
> entries.

Applied. Thank you.

Would you mind providing some documentation about the feature in the
manual, and updating ORG-NEWS?

Regards,

-- 
Nicolas Goaziou



Re: [O] [PATCH] key-binding for all plotting styles

2014-10-11 Thread Thierry Banel
Here is a patch which bindskeys:

  C-c " a   orgtbl-ascii-plot(creates an ascii plot for the column where
the cursor is)
  C-c " g   org-plot/gnuplot  (nicely launches Gnuplot for all columns)

It also adds a sub-menu named "Plot" in the "Tbl" menu with those two
entries.

Have fun
Thierry


Le 07/10/2014 16:15, Nicolas Goaziou a écrit :
> Hello,
>
> Thierry Banel  writes:
>
>> C-c "(currently unused)
>> C-c |(currently does weird things within a table)
> I'm fine with any of these, even though they may be shadowed by minor
> modes.
>
>
> Regards,
>

>From 41b262ca69636938bc894bc4b24d8de968e67c68 Mon Sep 17 00:00:00 2001
From: Thierry Banel 
Date: Sat, 11 Oct 2014 15:59:17 +0200
Subject: [PATCH] Ascii and Gnuplot key-bindings

* org.el (org-mode-map): change key-binding
from C-c p to C-c " a
add C-c " g key-binding for Gnuplot
(org-tbl-menu): add sub-menu for plotting
featuring Gnuplot and ascii plot
* org-table.el (orgtbl-setup): add sub-menu
for plotting featuring Gnuplot and ascii plot
---
 lisp/org-table.el | 10 ++
 lisp/org.el   | 14 ++
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/lisp/org-table.el b/lisp/org-table.el
index 7607ead..0f2fda3 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -4276,8 +4276,7 @@ to execute outside of tables."
 	 ["Move Column Left" org-metaleft :active (org-at-table-p) :keys "M-"]
 	 ["Move Column Right" org-metaright :active (org-at-table-p) :keys "M-"]
 	 ["Delete Column" org-shiftmetaleft :active (org-at-table-p) :keys "M-S-"]
-	 ["Insert Column" org-shiftmetaright :active (org-at-table-p) :keys "M-S-"]
-	 ["Ascii plot" orgtbl-ascii-plot :active (org-at-table-p) :keys "C-c p"])
+	 ["Insert Column" org-shiftmetaright :active (org-at-table-p) :keys "M-S-"])
 	("Row"
 	 ["Move Row Up" org-metaup :active (org-at-table-p) :keys "M-"]
 	 ["Move Row Down" org-metadown :active (org-at-table-p) :keys "M-"]
@@ -4315,7 +4314,10 @@ to execute outside of tables."
 	 org-table-toggle-coordinate-overlays :active (org-at-table-p)
 	 :keys "C-c }"
 	 :style toggle :selected org-table-overlay-coordinates]
-	))
+	"--"
+	("Plot"
+	 ["Ascii plot" orgtbl-ascii-plot :active (org-at-table-p) :keys "C-c \" a"]
+	 ["Gnuplot" org-plot/gnuplot :active (org-at-table-p) :keys "C-c \" g"])))
 t))
 
 (defun orgtbl-ctrl-c-ctrl-c (arg)
@@ -5052,7 +5054,7 @@ supported.  It is also possible to use the following ones:
 
 ;; Put the cursor in a column containing numerical values
 ;; of an Org-Mode table,
-;; type C-c p
+;; type C-c " a
 ;; A new column is added with a bar plot.
 ;; When the table is refreshed (C-u C-c *),
 ;; the plot is updated to reflect the new values.
diff --git a/lisp/org.el b/lisp/org.el
index a6d8d1b..724fa62 100755
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -163,6 +163,8 @@ Stars are put in group 1 and the trimmed body in group 2.")
 (declare-function org-table-paste-rectangle "org-table" ())
 (declare-function org-table-maybe-eval-formula "org-table" ())
 (declare-function org-table-maybe-recalculate-line "org-table" ())
+(declare-function orgtbl-ascii-plot "org-table" (&optional ask))
+(declare-function org-plot/gnuplot "org-plot" (&optional params))
 
 (declare-function org-element-at-point "org-element" ())
 (declare-function org-element-cache-reset "org-element" (&optional all))
@@ -19478,7 +19480,8 @@ boundaries."
 (org-defkey org-mode-map "\C-c="'org-table-eval-formula)
 (org-defkey org-mode-map "\C-c'"'org-edit-special)
 (org-defkey org-mode-map "\C-c`"'org-table-edit-field)
-(org-defkey org-mode-map "\C-cp"'orgtbl-ascii-plot)
+(org-defkey org-mode-map "\C-c\"a"  'orgtbl-ascii-plot)
+(org-defkey org-mode-map "\C-c\"g"  'org-plot/gnuplot)
 (org-defkey org-mode-map "\C-c|"'org-table-create-or-convert-from-region)
 (org-defkey org-mode-map [(control ?#)] 'org-table-rotate-recalc-marks)
 (org-defkey org-mode-map "\C-c~"'org-table-create-with-table.el)
@@ -21161,8 +21164,7 @@ on context.  See the individual commands for more information."
  ["Move Column Left" org-metaleft (org-at-table-p)]
  ["Move Column Right" org-metaright (org-at-table-p)]
  ["Delete Column" org-shiftmetaleft (org-at-table-p)]
- ["Insert Column" org-shiftmetaright (org-at-table-p)]
- ["Ascii plot" orgtbl-ascii-plot (org-at-table-p)])
+ ["Insert Column" org-shiftmetaright (org-at-table-p)])
 ("Row"
  ["Move Row Up" org-metaup (org-at-table-p)]
  ["Move Row Down" org-metadown (org-at-table-p)]
@@ -21205,7 +21207,11 @@ on context.  See the individual commands for more information."
 ["Import from File" org-table-import (not (org-at-table-p))]
 ["Export to File" org-table-export (org-at-table-p)]
 "--"
-["Create/Convert from/to table.el" org-table-create-with-table.el t]))
+["Create/Convert from/to table.el" org-table-create-with-table.el t]
+"--"
+("Plot"
+ ["Ascii plot" orgtbl-ascii-plot :active (org-at-table-p) :keys "C-c \" a"]
+ ["Gnuplot" org-plot/gnu