Re: [O] Strings converted to numbers in Org table?

2017-02-27 Thread Alan Schmitt
On 2017-02-27 10:17, "Charles C. Berry"  writes:

> IMHO, it is often best to handle formatting of output in the language of 
> the src block.  There are some tools for doing this in R: the `ascii' 
> package is one. `xtable' is another.

I've had the same problem when working with tables and ocaml, as the
latter requires everything in the table to have the same type, so I need
to make sure everything is a string. To work around this, I did the
following:

#+name: convert-table
#+BEGIN_SRC emacs-lisp :var data=tps
  (mapcar (lambda (row)
(mapcar (lambda (cell)
  (if
  (numberp cell)
  (number-to-string cell)
cell))
row))
  data)
#+END_SRC

#+BEGIN_SRC ocaml :var data=convert-table :results output raw
  (* ocaml code *)
#+END_SRC

Best,

Alan

-- 
OpenPGP Key ID : 040D0A3B4ED2E5C7
Monthly Athmospheric CO₂, Mauna Loa Obs. 2017-01: 406.13, 2016-01: 402.52


signature.asc
Description: PGP signature


Re: [O] resize org-table when exporting to latex

2017-02-27 Thread Nick Dokos
Jeremie Juste  writes:

> Hello,
>
> Is there a way to resize latex table when exporting to latex?
> For now my only recourse is to export the latex table copy the latex
> code back to org-mode apply \scalebox.
>
> Do you have a more convenient way in mind?
>

You need to use tabularx - something like this:

--8<---cut here---start->8---
#+LATEX_HEADER: \usepackage{tabularx}

* Export a table

#+CAPTION: foo
#+NAME: bar
#+ATTR_LATEX: :environment tabularx :width .8\textwidth :align X|X|X|X
| a | b | c | d | 
|---+---+---+---|
| 1 | 2 | 3 | 4 |

--8<---cut here---end--->8---

-- 
Nick




[O] resize org-table when exporting to latex

2017-02-27 Thread Jeremie Juste

Hello,

Is there a way to resize latex table when exporting to latex?
For now my only recourse is to export the latex table copy the latex
code back to org-mode apply \scalebox.

Do you have a more convenient way in mind?

Best wishes,

Jeremie








Re: [O] Bug: Latest org and goto-addr problems [9.0.5 (9.0.5-elpaplus @ /home/tim/.emacs.d/elpa/org-plus-contrib-20170210/)]

2017-02-27 Thread Tim Cross
Hi Nicolas,

now have at least one other report from someone able to reproduce this
error using the minimal config I provided. Note that you only get the error
on the first load of an org file containing source blocks. After the first
one has loaded, all others load file (including re-loading of the first
one).

Have now reproduced the issue just using the base org package instead of
org-plus-contrib and have got the same error using emacs 25.2-rc2

All works fine as soon as you remove the goto-address-prog-mode from the
init.


On 27 February 2017 at 08:49, Tim Cross  wrote:

> I need some help with this one as I'm running out of ideas.
>
> What I have done -
>
> 1. Completely removed all other org installs to eliminate possible 'mixed
> version' issues. This includes the org bundled with emacs 25.1. Made no
> difference.
>
> 2. Try opeing an org file which does not have any source blocks. All works
> fine. Then tried opening the test file with a single source block and got
> the same error. The source block was not 'fontified'.  Tried opening an org
> file with no source block, did an org-reload and then opened the test file
> with source block. Same error.
>
> 3. This 'looks like' a require load error or timing issue. After opening
> the test file and getting the error message I then kill the buffer and then
> open the file again for a second time, no error and the source block is now
> fontified. Makes me think that perhaps org is trying to fontify the buffer
> before some required library is loaded, reports an error, continues
> processing and loads the missing items and from then is OK when you load
> the next org file with a source block.
>
> Question: How do you get this error to throw a backtrace? It seems
> toggle-on-debug has no effect. If I can get some additional information on
> when this error is being generated, I might be able to track this down
> further.
>
> Tim
>
>
> On 26 February 2017 at 21:59, Tim Cross  wrote:
>
>>
>> thanks Nicolas - will go back and dig further. Not sure where to look
>> next though.
>>
>> Tim
>>
>>
>> On 26 February 2017 at 20:19, Nicolas Goaziou 
>> wrote:
>>
>>> Hello,
>>>
>>> Tim Cross  writes:
>>>
>>> > There appers to be a compatibility issue between latest org-mode and
>>> > goto-addr.el in emacs 25.1. Specifically, the 'goto-address-prog-mode
>>> > funciton. When this function is added to prog-mode-hook, opening an org
>>> > file with src blocks results in an org-mode fontification error.
>>> >
>>> > Minimal init.el used to reproduce this issue is
>>> >
>>> > ;; -- Start init.el --
>>> -
>>> > (require 'package)
>>> >
>>> > (setq package-enable-at-startup nil)
>>> > (add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/;))
>>> > (package-initialize)
>>> >
>>> > (unless (package-installed-p 'org-plus-contrib)
>>> >   (package-refresh-contents)
>>> >   (package-install 'org-plus-contrib))
>>> >
>>> > (require 'org)
>>> >
>>> > (require 'goto-addr)
>>> >
>>> > (add-hook 'prog-mode-hook 'goto-address-prog-mode)
>>> >
>>> > ;;  End init.el --
>>> >
>>> > minimal test org file used to reporduce the problem
>>> >
>>> > ;; --- Start test.org
>>> -
>>> > * Test
>>> >   This is a simple test org file
>>> >
>>> >   #+BEGIN_SRC emacs-lisp
>>> > (message "A Test")
>>> >   #+END_SRC
>>> >
>>> > ;;  End test.org -
>>>
>>> FWIW, I cannot reproduce it.
>>>
>>> Regards,
>>>
>>> --
>>> Nicolas Goaziou
>>>
>>
>>
>>
>> --
>> regards,
>>
>> Tim
>>
>> --
>> Tim Cross
>>
>>
>
>
> --
> regards,
>
> Tim
>
> --
> Tim Cross
>
>


-- 
regards,

Tim

--
Tim Cross


Re: [O] Error on html export

2017-02-27 Thread Thomas S. Dye
Aloha Mark,

Mark Meyer writes:

> On 02/27/17 12:45, Nicolas Goaziou wrote:
>> This is a common issue with mixed installations. You need to re-install
>> Org without any other version loaded otherwise.
>
> Spot on! Uninstalling org-mode `C-c C-x' and reinstalling worked.
>
> Is there a FAQ for this kind of issues?

http://orgmode.org/worg/org-faq.html#mixed-install

All the best,
Tom

--
Thomas S. Dye
http://www.tsdye.com



[O] M-TAB in org manual and org guide

2017-02-27 Thread Thomas Rikl
Emacs  : GNU Emacs 25.1.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.22.7)
 of 2017-02-07
Package: Org mode version 9.0.5 (release_9.0.5-325-g28b847)

Hello,
Can you please add a footnote or a link (to the completion chapter) to
the first (and second) occurence of "M-TAB" in the org manual that
"C-M-i" is a usual alternative.
Naming the alternate key-chord would be also usefull in the completion
chapter.

"M-TAB" is in use by many desktops and so common that it has an own
wikipedia entry. See: https://en.wikipedia.org/wiki/Alt-Tab

Thanks.




Re: [O] org-vcard -- possible to convert .vcf files to .org ?

2017-02-27 Thread Eric Abrahamsen
Saša Janiška  writes:

> Eric Abrahamsen  writes:
>
>> Glad to know you're enthusiastic, and patches are always welcome!
>
> What can you recommend for learning Elisp which might be also useful for
> špssobče contributibution to EBDB?

What would be great is having more country-specific parsing and display
functions. EBDB can display phone numbers, etc, differently depending on
the country code. You can look at ebdb-i18n, and also ebdb-chn, which is
the only country-specific library I've written, which is why I'm hoping
people will pitch in here :) Basically look at your contacts and see if
any them have field data that should be read or displayed in
country-specific ways, and see if you can tackle that.

You'll need a passing familiarity with generic functions, but that part
should mostly be copy-and-paste. The work would be with regular
expressions, string formatting, that sort of thing, which is good
practice!

>> I do expect the DAV server stuff to take me a while, though. I've heard
>> the protocol is a bear, and I don't have much experiences with XML or
>> network programming. I expect to crib a lot of code out of org-caldave
>> :)
>
> org-caldav is nice, but not useful any longer for me due to
> https://github.com/dengste/org-caldav/issues/51 issue. :-(

Oh, I've never hit that bug. That's too bad...

Eric




Re: [O] Error on html export

2017-02-27 Thread Mark Meyer
On 02/27/17 12:45, Nicolas Goaziou wrote:
> This is a common issue with mixed installations. You need to re-install
> Org without any other version loaded otherwise.

Spot on! Uninstalling org-mode `C-c C-x' and reinstalling worked.

Is there a FAQ for this kind of issues?

Cheers, Mark

-- 
  Mark Meyer
  m...@ofosos.org



Re: [O] Strings converted to numbers in Org table?

2017-02-27 Thread Vicente Vera
Yes, it is a rare case indeed. It's not necessary nor appropiate to
change Babel's behavior.

Long story short, I'm building several LaTeX tables from CSV files
which in turn come from Excel files. I'm not the author of these Excel
files and I have to reproduce them as faithful as possible.

The problem is that a comma is used as a decimal mark instead of a
dot. `string-to-number' correctly interprets numbers such as "1.100"
as floating point. But in this particular case this is not the
expected behavior and the tables get messed up.

Your solution is a much better option. Thanks.

2017-02-27 17:33 GMT+00:00 Nicolas Goaziou :

> Hello,
>
> Vicente Vera  writes:
>
> > It would be useful to have a header argument to prevent this
> > conversion. Probably somebody else has had the same issue?
>
> Since this case may be rare, what about inserting a non breaking
> zero-width space right before 3.350?
>
> Regards,
>
> --
> Nicolas Goaziou
>


Re: [O] Bug report: export to HTML does not escape * in example

2017-02-27 Thread Nick Dokos
"Charles C. Berry"  writes:

> On Mon, 27 Feb 2017, dmg wrote:
>
>> On Sun, Feb 26, 2017 at 11:40 PM, Nicolas Goaziou 
>> wrote:
>>
>>>
>>> A star at the beginning of a line is always a headline.
>
> [...]
>
>>
>> ​Thank you. I guess the issue is then with org-babel.
>>
>> I am running a babel script that generates, as one of its line * in the
>> front:
>>
>> ​#+BEGIN_SRC sh
>> echo "* Hello"
>> #+END_SRC
>>
>> #+RESULTS:
>> #+begin_example
>> * Hello
>> #+end_example
>>
>> ​In that case, should babel be the one escaping the * in the RESULTS block?
>
> Is that *really* what it did?
>
> When I run your example, I get:
>
> #+RESULTS:
> : * Hello
>
> and this exports (with the `:exports results' header) to html wrapped
> in a  container:
>
> 
> * Hello
> 
>
> using Org 9.0.5.
>
> Without that header the src code gets wrapped in a  container.
>
> So there must be something in/about your setup you haven't mentioned.
>

Probably org-babel-min-lines-for-block-output is set to a small value,
maybe 0 (?)

-- 
Nick




Re: [O] Strings converted to numbers in Org table?

2017-02-27 Thread Charles C. Berry

On Mon, 27 Feb 2017, Vicente Vera wrote:


Hello again, I'm sorry for being noisy.

OK yes, `org-babel-read' is indeed converting "number strings" to
numbers.



[proposed fix deleted]

I don't have a feeling as to whether the proposed fix is appropriate.

However, there are other ways to solve this issue. See below.



- In R every value is a string. "var2" contains no numbers (is a
  character vector).

- Upon conversion to a table Org removes the zero from "var2" last
  value.

--

#+BEGIN_SRC R :session *mwe* :results value table :colnames yes
  tst <- data.frame(var1 = c("a", "b", "c", "d", "e", "f", "g"),
var2 = c("150", "210", "140", "150", "192", "497",
"3.350"),
stringsAsFactors = FALSE)
  tst
#+END_SRC

#+RESULTS:
| var1 | var2 |
|--+--|
| a|  150 |
| b|  210 |
| c|  140 |
| d|  150 |
| e|  192 |
| f|  497 |
| g| 3.35 |

--

Here's the output as seen in R:

: > tst
:   var1  var2
: 1a   150
: 2b   210
: 3c   140
: 4d   150
: 5e   192
: 6f   497
: 7g 3.350

Details on the data frame:

: > str(tst)
: 'data.frame':7 obs. of  2 variables:
:  $ var1: chr  "a" "b" "c" "d" ...
:  $ var2: chr  "150" "210" "140" "150" ...

It seems Org knows that the values on column "var2" are numbers and
converts the strings to numbers, applying some obscure trimming on the
digits. The "3.350" value needs to be left as is.



IMHO, it is often best to handle formatting of output in the language of 
the src block.  There are some tools for doing this in R: the `ascii' 
package is one. `xtable' is another.


You can always do something like this:

#+BEGIN_SRC R :session *mwe* :results output
 tst <- data.frame(var1 = c("a", "b", "c", "d", "e", "f", "g"),
 var2 = c("150", "210", "140", "150", "192", "497", "3.350"),
 stringsAsFactors = FALSE)

 cat( capture.output( print(tst, row.names=FALSE)), sep="\n")

#+END_SRC


Or you can use `ox-ravel'[1] to convert to one of the knitr-like formats 
and let knitr or rmarkdown handle the output conversion.


Best,

Chuck

[1] https://github.com/chasberry/orgmode-accessories




Re: [O] Bug report: export to HTML does not escape * in example

2017-02-27 Thread Charles C. Berry

On Mon, 27 Feb 2017, dmg wrote:


On Sun, Feb 26, 2017 at 11:40 PM, Nicolas Goaziou 
wrote:



A star at the beginning of a line is always a headline.


[...]



​Thank you. I guess the issue is then with org-babel.

I am running a babel script that generates, as one of its line * in the
front:

​#+BEGIN_SRC sh
echo "* Hello"
#+END_SRC

#+RESULTS:
#+begin_example
* Hello
#+end_example

​In that case, should babel be the one escaping the * in the RESULTS block?


Is that *really* what it did?

When I run your example, I get:

#+RESULTS:
: * Hello

and this exports (with the `:exports results' header) to html wrapped 
in a  container:



* Hello


using Org 9.0.5.

Without that header the src code gets wrapped in a  container.

So there must be something in/about your setup you haven't mentioned.

HTH,

Chuck

Re: [O] Strings converted to numbers in Org table?

2017-02-27 Thread Nicolas Goaziou
Hello,

Vicente Vera  writes:

> It would be useful to have a header argument to prevent this
> conversion. Probably somebody else has had the same issue?

Since this case may be rare, what about inserting a non breaking
zero-width space right before 3.350?

Regards,

-- 
Nicolas Goaziou



[O] org-image-actual-width and org-mime-htmlize

2017-02-27 Thread Uwe Brauer


Hi

I just sent a message to myself  which contained.
[[File:test.png]]

And I used org-mime-htmlize to generate a htmlized message, however the
variable org-image-actual-width did not change the size of the image in
the message.

Is there any possibility to achieve this?

Thanks

Uwe Brauer 




Re: [O] BUG: disparity between popup menu and pulldown menu for Agenda viewing mode

2017-02-27 Thread Kyle Meyer
"J. David Boyd"  writes:

> When I'm viewing the agenda, if I press v, I get a popup menu that states that
> I can get to the for[t]night view, with a 't', which works.
>
> But I if look in the pulldown menu, it tells me that Fortnight View is
> accomplished with v f.  This actually puts the Agenda into follow mode, not at
> all what I wanted to do...

Thanks for reporting.  Fixed with a29525d.

-- 
Kyle



Re: [O] Strings converted to numbers in Org table?

2017-02-27 Thread Vicente Vera
Hello again, I'm sorry for being noisy.

OK yes, `org-babel-read' is indeed converting "number strings" to
numbers.

Basically this is what happens:

: (string-to-number "3.350") => 3.35

To leave cell values unchanged I did this clumsy hack:

#+BEGIN_SRC emacs-lisp
  (defun test-other-org-babel-read (cell  inhibit-lisp-eval)
(if (and (stringp cell) (not (equal cell "")))
;; ;; (or (org-babel--string-to-number cell)
(if (and (not inhibit-lisp-eval)
 (or (member (substring cell 0 1) '("(" "'" "`" "["))
 (string= cell "*this*")))
(eval (read cell) t)
  (if (string= (substring cell 0 1) "\"")
  (read cell)
(progn (set-text-properties 0 (length cell) nil cell) cell)))
  ;; ;; )
  cell))

  ;; Override default behavior
  (fset 'org-babel-read 'test-other-org-babel-read)
#+END_SRC

It would be useful to have a header argument to prevent this
conversion. Probably somebody else has had the same issue?

2017-02-27 13:49 GMT+00:00 Vicente Vera :

> Probably the issue is related to this function in `ob-core.el'?
>
> org-babel-read: "Convert the string value of CELL to a number if
> appropriate."
>
> Behind the curtains lies the built-in function `string-to-number'.
>
> Maybe that conversion should be made optional to leave the strings
> untouched.
>
> 2017-02-24 1:40 GMT+00:00 Vicente Vera :
>
>> Hello. I'm trying to get an Org table from an R data frame but data is
>> lost in the process.
>>
>> Here is a MWE. Note that:
>>
>> - In R every value is a string. "var2" contains no numbers (is a
>>   character vector).
>>
>> - Upon conversion to a table Org removes the zero from "var2" last
>>   value.
>>
>> --
>>
>> #+BEGIN_SRC R :session *mwe* :results value table :colnames yes
>>   tst <- data.frame(var1 = c("a", "b", "c", "d", "e", "f", "g"),
>> var2 = c("150", "210", "140", "150", "192", "497",
>> "3.350"),
>> stringsAsFactors = FALSE)
>>   tst
>> #+END_SRC
>>
>> #+RESULTS:
>> | var1 | var2 |
>> |--+--|
>> | a|  150 |
>> | b|  210 |
>> | c|  140 |
>> | d|  150 |
>> | e|  192 |
>> | f|  497 |
>> | g| 3.35 |
>>
>> --
>>
>> Here's the output as seen in R:
>>
>> : > tst
>> :   var1  var2
>> : 1a   150
>> : 2b   210
>> : 3c   140
>> : 4d   150
>> : 5e   192
>> : 6f   497
>> : 7g 3.350
>>
>> Details on the data frame:
>>
>> : > str(tst)
>> : 'data.frame':7 obs. of  2 variables:
>> :  $ var1: chr  "a" "b" "c" "d" ...
>> :  $ var2: chr  "150" "210" "140" "150" ...
>>
>> It seems Org knows that the values on column "var2" are numbers and
>> converts the strings to numbers, applying some obscure trimming on the
>> digits. The "3.350" value needs to be left as is.
>>
>>
>


[O] BUG: disparity between popup menu and pulldown menu for Agenda viewing mode

2017-02-27 Thread J. David Boyd
When I'm viewing the agenda, if I press v, I get a popup menu that states that
I can get to the for[t]night view, with a 't', which works.

But I if look in the pulldown menu, it tells me that Fortnight View is
accomplished with v f.  This actually puts the Agenda into follow mode, not at
all what I wanted to do...

Thanks for everyone's efforts at making Org better each and every day.  I
couldn't get my daily work done without it!

Dave in Hudson, FL




Re: [O] Strings converted to numbers in Org table?

2017-02-27 Thread Vicente Vera
Probably the issue is related to this function in `ob-core.el'?

org-babel-read: "Convert the string value of CELL to a number if
appropriate."

Behind the curtains lies the built-in function `string-to-number'.

Maybe that conversion should be made optional to leave the strings
untouched.

2017-02-24 1:40 GMT+00:00 Vicente Vera :

> Hello. I'm trying to get an Org table from an R data frame but data is
> lost in the process.
>
> Here is a MWE. Note that:
>
> - In R every value is a string. "var2" contains no numbers (is a
>   character vector).
>
> - Upon conversion to a table Org removes the zero from "var2" last
>   value.
>
> --
>
> #+BEGIN_SRC R :session *mwe* :results value table :colnames yes
>   tst <- data.frame(var1 = c("a", "b", "c", "d", "e", "f", "g"),
> var2 = c("150", "210", "140", "150", "192", "497",
> "3.350"),
> stringsAsFactors = FALSE)
>   tst
> #+END_SRC
>
> #+RESULTS:
> | var1 | var2 |
> |--+--|
> | a|  150 |
> | b|  210 |
> | c|  140 |
> | d|  150 |
> | e|  192 |
> | f|  497 |
> | g| 3.35 |
>
> --
>
> Here's the output as seen in R:
>
> : > tst
> :   var1  var2
> : 1a   150
> : 2b   210
> : 3c   140
> : 4d   150
> : 5e   192
> : 6f   497
> : 7g 3.350
>
> Details on the data frame:
>
> : > str(tst)
> : 'data.frame':7 obs. of  2 variables:
> :  $ var1: chr  "a" "b" "c" "d" ...
> :  $ var2: chr  "150" "210" "140" "150" ...
>
> It seems Org knows that the values on column "var2" are numbers and
> converts the strings to numbers, applying some obscure trimming on the
> digits. The "3.350" value needs to be left as is.
>
>


Re: [O] Error on html export

2017-02-27 Thread Nicolas Goaziou
Hello,

Mark Meyer  writes:

> I'm getting an error on HTML export, as soon as my document has a
> `#+TITLE' set.
>
> Here's part of the stack trace:
>
> Debugger entered--Lisp error: (wrong-type-argument listp #("test" 0 4
> (:parent (#1

This is a common issue with mixed installations. You need to re-install
Org without any other version loaded otherwise.

Regards,

-- 
Nicolas Goaziou



Re: [O] org-vcard -- possible to convert .vcf files to .org ?

2017-02-27 Thread Saša Janiška
Eric Abrahamsen  writes:

> Glad to know you're enthusiastic, and patches are always welcome!

What can you recommend for learning Elisp which might be also useful for
špssobče contributibution to EBDB?

> I do expect the DAV server stuff to take me a while, though. I've heard
> the protocol is a bear, and I don't have much experiences with XML or
> network programming. I expect to crib a lot of code out of org-caldave
> :)

org-caldav is nice, but not useful any longer for me due to
https://github.com/dengste/org-caldav/issues/51 issue. :-(


Sincerely,
Gour

-- 
For him who has conquered the mind, the mind is the best of
friends; but for one who has failed to do so, his mind will
remain the greatest enemy.




Re: [O] Bug report: export to HTML does not escape * in example

2017-02-27 Thread dmg
On Sun, Feb 26, 2017 at 11:40 PM, Nicolas Goaziou 
wrote:

>
> A star at the beginning of a line is always a headline. It has
> precedence over the block around it. You need to escape the star
> character:
>
>   #+begin_example
>   ,* hello world
>   #+end_example
>
> Regards,


​Thank you. I guess the issue is then with org-babel.

I am running a babel script that generates, as one of its line * in the
front:

​#+BEGIN_SRC sh
echo "* Hello"
#+END_SRC

#+RESULTS:
#+begin_example
* Hello
#+end_example

​In that case, should babel be the one escaping the * in the RESULTS block?

thanks again,

--daniel​




-- 
--dmg

---
Daniel M. German
http://turingmachine.org


[O] Error on html export

2017-02-27 Thread Mark Meyer
Hi,
I'm getting an error on HTML export, as soon as my document has a
`#+TITLE' set.

Here's part of the stack trace:

Debugger entered--Lisp error: (wrong-type-argument listp #("test" 0 4
(:parent (#1
  org-element-set-contents(#("test" 0 4 (:parent (#0
  apply(org-element-set-contents #("test" 0 4 (:parent (#0))) nil)
  #[257 "\211\305\306\307#\310\311\211:\204

I see that `org-element-set-contents' expects a list to operate on, but
is getting passed an array. This is with org-mode 9.0.5.

Cheers, Mark
-- 
  Mark Meyer
  m...@ofosos.org