Re: [O] Best practice for providing an Org-based application?

2019-09-11 Thread Martin Alsinet
Neil,

You could use transient[1], the tool used to build the menus of magit[2].
I really like magit's discoverability and ease of use.

There is a video of a talk where it is used to control kubernetes from
inside emacs in magit style:
https://www.youtube.com/watch?v=w3krYEeqnyk

[1] transient: https://github.com/magit/transient
[2] magit: https://magit.vc


On Wed, Sep 11, 2019 at 2:17 AM Marcin Borkowski  wrote:

>
> On 2019-09-11, at 01:11, John Kitchin  wrote:
>
> > This sounds like an interesting application with a lot of complexities.
> > It definitely blurs the lines between a database where you could run
> > queries to find/update records, and a human readable, structured data
> > file that also does this.
>
> This reminds me of this:
> https://www.joelonsoftware.com/2012/01/06/how-trello-is-different/
>
> I just had a minor enlightenment why Org-mode is so successful (within
> its niche, of course).  It implements a bunch of very general data
> structures - a tree, a table, a dictionary - and a few slightly more
> specific - a clock table, TODOs/tags, markup...
>
> Best,
>
> --
> Marcin Borkowski
> http://mbork.pl
>
>


Re: [O] [Proposal] Source Blocks with Post-Extensions

2019-07-26 Thread Martin Alsinet
Well Ken, you improved my workflow right there, I am going to add the
:prologue trick to my shell properties header and get the test error output
in the results block.

Thank you right back!

On Fri, Jul 26, 2019 at 10:18 AM Ken Mankoff  wrote:

>
> On 2019-07-26 at 08:58 -04, Martin Alsinet 
> wrote...
> > I usually have a shell buffer nearby and go there to inspect the
> > failed tests when I get no output. The problem is that shell blocks do
> > not capture stderr. John Kitchin wrote a blog post
> > <
> http://kitchingroup.cheme.cmu.edu/blog/2015/01/04/Redirecting-stderr-in-org-mode-shell-blocks/
> >
> > about this problem and provided a solution that may work for you, but
> > I have not tried it yet.
>
> Ah yes... from my own comments there:
>
> #+begin_src sh :results raw drawer :prologue "exec 2>&1" :epilogue ":"
> python -m pytest ./utils
> #+end_src
>
> Thanks for reminding me about my past self.
>
>   -k.
>


Re: [O] [Proposal] Source Blocks with Post-Extensions

2019-07-26 Thread Martin Alsinet
Ken,

I usually have a shell buffer nearby and go there to inspect the failed
tests when I get no output.
The problem is that shell blocks do not capture stderr. John Kitchin wrote
a blog post
<http://kitchingroup.cheme.cmu.edu/blog/2015/01/04/Redirecting-stderr-in-org-mode-shell-blocks/>
about this problem and provided a solution that may work for you, but I
have not tried it yet.

Martin

On Fri, Jul 26, 2019 at 7:02 AM Ken Mankoff  wrote:

> Hi Martin,
>
> On 2019-06-26 at 18:09 -04, Martin Alsinet 
> wrote...
> > I use a different approach, where I tangle the source into files in
> > modules and then I import those modules from other blocks. This allows
> > me to organize my document with different sections for the code and
> > its tests, which then get exported into their corresponding files.
>
> Thanks for providing this pytest code below. It runs nicely because your
> tests pass. It does not run if a test fails. The shell block that runs
> pytest reports
>
> Babel evaluation exited with code 1
> Code block produced no output.
>
> Do you have some way of capturing failed pytest tests in Org Babel?
>
> Thanks,
>
>   -k.
>
> > * Square Function
> >
> > This function receives a number and returns its square
> >
> > #+BEGIN_SRC python :tangle ./utils/math.py :mkdirp yes
> > def square(x):
> > return x * x
> > #+END_SRC
> >
> > ** __init__.py (module setup)
> >
> > #+begin_src python :tangle ./utils/__init__.py :mkdirp yes
> > from utils.math import square
> >
> > #+end_src
> >
> > ** Test cases
> >
> > 1. The square of five should be 25
> > 2. The square of zero should be 0
> > 3. The square of a negative number should be positive
> >
> > #+BEGIN_SRC python :tangle ./utils/test_square.py :mkdirp yes
> > from utils.math import square
> >
> > def test_square_of_five():
> > assert square(5) == 25
> >
> > def test_square_of_zero():
> > assert square(0) == 0
> >
> > def test_square_of_negative():
> > assert square(-5) > 0
> > #+END_SRC
> >
> > *** Run tests
> >
> > #+begin_src sh :results output raw
> > pytest ./utils
> > #+end_src
> >
> > #+RESULTS:
> > = test session starts
> > ==
> > platform linux -- Python 3.7.3, pytest-4.6.3, py-1.8.0, pluggy-0.12.0
> > rootdir: /app
> > collected 3 items
> >
> > utils/test_square.py ...
> > [100%]
> >
> > === 3 passed in 0.08 seconds
> > ===
> >
> >
>


Re: [O] [Proposal] Source Blocks with Post-Extensions

2019-06-26 Thread Martin Alsinet
Dmitrii,

I use a different approach, where I tangle the source into files in modules
and then I import those modules from other blocks.
This allows me to organize my document with different sections for the code
and its tests, which then get exported into their corresponding files.


* Square Function

This function receives a number and returns its square

#+BEGIN_SRC python :tangle ./utils/math.py :mkdirp yes
def square(x):
return x * x
#+END_SRC

** __init__.py (module setup)

#+begin_src python :tangle ./utils/__init__.py :mkdirp yes
from utils.math import square

#+end_src

** Test cases

1. The square of five should be 25
2. The square of zero should be 0
3. The square of a negative number should be positive

#+BEGIN_SRC python :tangle ./utils/test_square.py :mkdirp yes
from utils.math import square

def test_square_of_five():
assert square(5) == 25

def test_square_of_zero():
assert square(0) == 0

def test_square_of_negative():
assert square(-5) > 0
#+END_SRC

*** Run tests

#+begin_src sh :results output raw
pytest ./utils
#+end_src

#+RESULTS:
= test session starts
==
platform linux -- Python 3.7.3, pytest-4.6.3, py-1.8.0, pluggy-0.12.0
rootdir: /app
collected 3 items

utils/test_square.py ...
[100%]

=== 3 passed in 0.08 seconds
===






On Wed, Apr 24, 2019 at 2:19 PM Dmitrii Korobeinikov 
wrote:

> Sorry for not answering these two days.
>
> You are right, that's an option.
> But I just don't think that's the best possible one - for usability.
>
> Introducing this would imply architectural decisions, so it might not be
> immediately clear if it's right or not.
> Especially that the improvement might not seem that big.
> So, I understand that.
>
> I have proposed buffer lenses today and they seem like something that can
> solve the issue from the user side. Hopefully they will get some traction.
>
> пн, 22 апр. 2019 г. в 23:31, Berry, Charles :
>
>>
>>
>> > On Apr 22, 2019, at 10:15 AM, Dmitrii Korobeinikov 
>> wrote:
>> >
>> > Thank you!
>> > That's a handy technique and it does help.
>> > As I understand, there's no way to extend that to multiple lines?
>>
>> AFAICS, no there is no way to split the :epilogue arg to multiple lines.
>>
>> Of course, you can always follow a src block that provides a function
>> with another src block that imports the code via noweb and then tests the
>> function with as many lines of code as you need.
>>
>> Chuck
>>
>>
>>
>>


Re: [O] Python with org-mode

2019-03-30 Thread Martin Alsinet
Lawrence,

It depends on what you want to do. Anaconda is a python distribution
intended for data science and machine learning, so if you want to work on
machine learning, it provides an easy way to install all the required
packages for that. You can use any python distribution with org-mode, you
just have to tell org-babel the path to the python interpreter you want to
use.

I would suggest that you pick a project, an application you want to make,
and start from there. I am currently making an application using python and
org-mode, which consists of a single org document and has ~170 python
source blocks. It is a simple podcast database, I am just doing it to try
the literary programming style in python. You can check it out here
, the only problem is that the
document is in spanish, my native language.

In this application I have leveraged python's import feature, so that I
write small functions (each in their corresponding source code block) which
I tangle into files and import from other blocks. This allows the document
to have a logical structure as a document, with sections for each module,
and also being able to call any block from any other.

If you have any doubts or need help starting out, don't hesitate to contact
me, I would be happy to help you.


Martín

On Fri, Mar 29, 2019 at 10:38 PM Lawrence Bottorff 
wrote:

> I've seen many "start using Python" parades, but what is the best way to
> use Python with org-mode, i.e., in babel source blocks? I'm on U18.10,
> which comes with standard 2 (2.7.15+) and 3 (3.6.7). But then I keep
> hearing about Anaconda. Your opinions, experiences, please.
>
> LB
>


Re: [O] Lowercase keywords in 9.2?

2019-02-12 Thread Martin Alsinet
What do you mean with the "uppercase legacy"? You mean all the current
documents we already have?
In my case, those will remain with the upper case tags until I need to edit
them.

I guess it would be enough to patch the sites affected by
>
> https://code.orgmode.org/bzg/org-mode/commit/13424336a6f30c50952d291e7a82906c1210daf0
> and also the templates definition in org-tempo.


Looking at that diff, the changes are not so simple as I initially thought,
I was just thinking about patching org-tempo, but I guess they should cover
all the uppercase tags.
Now I don't feel so confident about doing it :-(

Regards

On Tue, Feb 12, 2019 at 11:10 AM Carlos Pita 
wrote:

> > At first I didn't like the lowercase tags for the blocks, but I got used
> to them after a couple of days.
>
> I prefer the lowercase convention hands down. The problem I pointed
> out is with the uppercase legacy.
>
> > Someone suggested adding a defcustom option to org-tempo to let the user
> choose between lower and upper case tags.
> > It seems a simple enough feature for a first contribution. Maybe we
> could add it? I have never done it before, but I am willing to try.
>
> I wouldn't mind (helping you) doing it as far as there is agreement
> whether this is a desired option or not.
>
> I guess it would be enough to patch the sites affected by
>
> https://code.orgmode.org/bzg/org-mode/commit/13424336a6f30c50952d291e7a82906c1210daf0
> and also the templates definition in org-tempo.
>
> Regards
> --
> Carlos
>


Re: [O] Lowercase keywords in 9.2?

2019-02-12 Thread Martin Alsinet
Carlos,

I recently updated to 9.2 and was also confronted with the org-tempo
change.
At first I didn't like the lowercase tags for the blocks, but I got used to
them after a couple of days.

Someone suggested adding a defcustom option to org-tempo to let the user
choose between lower and upper case tags.
It seems a simple enough feature for a first contribution. Maybe we could
add it? I have never done it before, but I am willing to try.


On Tue, Feb 12, 2019 at 10:30 AM Carlos Pita 
wrote:

> > Here are two previous threads about the subject:
> >
> > Last month:
> http://lists.gnu.org/archive/html/emacs-orgmode/2019-01/msg00349.html
> > A year ago:
> http://lists.gnu.org/archive/html/emacs-orgmode/2018-01/msg00425.html
>
> Interesting, thanks! Although the issue of mostly uppercase external
> snippet collections was not raised there. For now I'm disabling yas in
> org mode and using org-tempo exclusively.
>


Re: [O] Lowercase keywords in 9.2?

2019-02-12 Thread Martin Alsinet
Carlos

Here are two previous threads about the subject:

   - Last month:
   http://lists.gnu.org/archive/html/emacs-orgmode/2019-01/msg00349.html
   - A year ago:
   http://lists.gnu.org/archive/html/emacs-orgmode/2018-01/msg00425.html

Regards

On Tue, Feb 12, 2019 at 9:51 AM Carlos Pita 
wrote:

> > before, didn't they? Is this implying that now lowercase is preferred?
>
> I dug this up from the repo:
>
>org-element: Prefer lower case letters for blocks and keywords
>
>
> https://code.orgmode.org/bzg/org-mode/commit/13424336a6f30c50952d291e7a82906c1210daf0
>
> So the answer is yes. Also the begin/end pairs are lowercase hardcoded
> in org-tempo.el.
>
> This is a problem for available (ya)snippet databases. I've reported
> it in https://github.com/AndreaCrotti/yasnippet-snippets/issues/303,
> requesting an update. But I guess people will prefer uppercase for a
> time so I'm now sure how should they should cope with the transition.
>
> Best regards
> --
> Carlos
>
> >
> > Regards
> > --
> > Carlos
>
>


Re: [O] do you need a separate LaTeX installation to export org mode files to pdf?

2018-01-22 Thread Martin Alsinet
Hello Christopher

I have a docker image with LaTeX installed in order not to "pollute" my
local filesystem with the 4GB of additional libraries a full LaTeX
installation requires.
If your co-worker is a software developer you could use that approach.

Here is mi Dockerfile for LaTeX:

FROM ubuntu:xenial
MAINTAINER Martin Alsinet <martin@alsinet>

ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update -q
RUN apt-get install -y texlive-full gnuplot python-pygments
RUN apt-get clean
RUN rm -rf /var/lib/apt/lists/*

Save that in a file named *Dockerfile* in a blank folder and run *docker
build -t latex .*
This will create a docker image named latex with all the libraries and
executables neatly tucked away.
Then, in order to use it, you can save the following script in
~/bin/pdflatex

#!/bin/sh
export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
docker run --rm \
   -v $(pwd):$(pwd) \
   -v ~/.ssh:/root/.ssh \
   -w $(pwd) \
   latex \
   pdflatex $@
rm *.log *.aux
rm -f *.ent
rm -Rf _minted-*

With that you can use the *pdflatex* command as usual, and docker creates a
temporary container (docker run --rm ...) from the image, runs the pdflatex
command and removes the container after execution.

bash-3.2$ pdflatex --version
pdfTeX 3.14159265-2.6-1.40.16 (TeX Live 2015/Debian)
kpathsea version 6.2.1
Copyright 2015 Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).
There is NO warranty.  Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).
Compiled with libpng 1.6.17; using libpng 1.6.17
Compiled with zlib 1.2.8; using zlib 1.2.8
Compiled with poppler version 0.41.0
rm: *.log: No such file or directory
rm: *.aux: No such file or directory



Martin


On Mon, Jan 22, 2018 at 10:23 AM Kaushal Modi <kaushal.m...@gmail.com>
wrote:

> On Mon, Jan 22, 2018 at 9:57 AM Christopher W Ryan <cr...@binghamton.edu>
> wrote:
>
>> Would they need to install LaTeX too, or is org mode self-contained and
>> able to export to pdf without LaTeX an friends installed?
>>
>
> Yes, they'd need to have a LaTeX distribution installed on their system.
> In my experience, installing the full latest version of TexLive is the
> easiest way.
>
>
> --
>
> Kaushal Modi
>


Re: [O] Hope ob-js can support :session feature

2017-12-24 Thread Martin Alsinet
Hello stardiviner,

I actually don't mind using absoute paths in my org files, and I think that
using something like that header var and expansion is more trouble than it
is worth.
If I wanted to move the org file to another folder, I would just do a
*replace-string* of the old path with the new path and be done with it.

Another approach would be to put a block like the following at the top of
the file:
#+BEGIN_SRC sh
// Make a symbolic link of the current directory into ~/code
ln -s $PWD ~/code
#+END_SRC

And after running that block, I can just use
require("~/code/src/tangled-file.js") in the js blocks and it would work
just fine.
I consider all the tangled js files in ./src as throwaway code, meaning
that I can recreate them at any time, and I would never check them into a
repository.
I usually put them in ./src and add the src folder to my .gitignore.

I find both of these approaches simpler than tangling expanded header
arguments.
Just my 2c.

Happy holidays


Martin

On Sat, Dec 23, 2017 at 10:14 PM numbch...@gmail.com <numbch...@gmail.com>
wrote:

>
> I come up with an idea, use babel header argument :var to pass in the
> absolute path of tangled file.
> And ob-js will expand and replace that :var variable inside of JavaScript
> src block.
> So that you don't need to repeatly manually typing the absolute path of
> the tangled file. Maybe it only one for "require". One question is that I
> don't know whether tangle to auto expand and substitute the :var.
> After a quick test, seems it should be expanded but not indeed. Check out
> the info node of `:no-expand`.
> Here is my quick test:
>
> * Test tangle will auto expand and substitute :var
>
> #+begin_src js :tangle kk.js
> console.log("hello, world!");
> #+end_src
>
> #+begin_src js :var name="chris" :tangle require-kk.js
> // require("kk.js");
> console.log("Hi, ", name);
> #+end_src
>
> #+RESULTS:
> : Hi,  chris
>
> #+NAME: check whether tangle expand and substitute :var
> #+begin_src shell
> cat require-kk.js
> #+end_src
>
> #+RESULTS: check whether tangle expand and substitute :var
> : var name="chris";
> : console.log("Hi, ", name);
>
>
>
>
> [stardiviner] GPG key ID: 47C32433
> IRC(freeenode): stardiviner Twitter:  @numbchild
> Key fingerprint = 9BAA 92BC CDDD B9EF 3B36  CB99 B8C4 B8E5 47C3 2433
> Blog: http://stardiviner.github.io/
>
> On Sat, Dec 23, 2017 at 11:06 AM, Martin Alsinet <mar...@alsinet.com.ar>
> wrote:
>
>> Hello,
>>
>> I don't have a blog yet, it is in my list of new year's resolutions. I
>> will try to explain it here anyway, maybe it can serve as a draft for a
>> blog post.
>>
>> When you hit *C-c* inside of a javascript source block, *ob-js* takes
>> the js code from the js block and saves it into a temp file (in linux the
>> temp file will be in saved /tmp/random-name, while in Mac OS X it will be
>> saved in /var/folders/random-name). Then, it uses *org-babel-eval* to
>> execute the js code, which in turn creates a temp buffer, inserts the
>> contents of the temp file into the temp buffer and uses
>> *shell-command-on-region* to run the js code with *node* as the executed
>> command.
>>
>> That is the reason why you must use absolute paths in the require,
>> because when the code runs it is no longer in the same directory of the org
>> file, but in a temporary folder. If you use
>> require("./src/my-component.js"), require won't find the js file because
>> it is in another directory.
>>
>> Let's try an example (if you want you can send me one of your examples
>> and I can modify it to use my approach)
>>
>> First, I will define two functions to show an array of javascript objects
>> as an org-mode table:
>>
>> #+BEGIN_SRC js :tangle src/table.js
>> function table_row(cells){
>> console.log("|" + cells.join("|") + "|");
>> }
>> function table(rows){
>> console.log("|---|");
>> table_row(Object.keys(rows[0]));
>> console.log("|---|");
>> rows.map(row => table_row(Object.keys(row).map(k => row[k])));
>> console.log("|---|");
>> }
>> module.exports = table;
>> #+END_SRC
>>
>> Notice the :tangle src/table.js property, which I will use to require it
>> in a later block:
>>
>> #+BEGIN_SRC js :results output raw drawer
>> var data = [ { day: 'SUNDAY', accidents: 3986 },
>>   { day: 'MONDAY', accidents: 6109 },
>>   { day: 'SATURDAY', accidents: 6274 },
>>   { day: 'WEDNESDAY',

Re: [O] Hope ob-js can support :session feature

2017-12-22 Thread Martin Alsinet
Hello,

I don't have a blog yet, it is in my list of new year's resolutions. I will
try to explain it here anyway, maybe it can serve as a draft for a blog
post.

When you hit *C-c* inside of a javascript source block, *ob-js* takes the
js code from the js block and saves it into a temp file (in linux the temp
file will be in saved /tmp/random-name, while in Mac OS X it will be saved
in /var/folders/random-name). Then, it uses *org-babel-eval* to execute the
js code, which in turn creates a temp buffer, inserts the contents of the
temp file into the temp buffer and uses *shell-command-on-region* to run
the js code with *node* as the executed command.

That is the reason why you must use absolute paths in the require, because
when the code runs it is no longer in the same directory of the org file,
but in a temporary folder. If you use require("./src/my-component.js"),
require won't find the js file because it is in another directory.

Let's try an example (if you want you can send me one of your examples and
I can modify it to use my approach)

First, I will define two functions to show an array of javascript objects
as an org-mode table:

#+BEGIN_SRC js :tangle src/table.js
function table_row(cells){
console.log("|" + cells.join("|") + "|");
}
function table(rows){
console.log("|---|");
table_row(Object.keys(rows[0]));
console.log("|---|");
rows.map(row => table_row(Object.keys(row).map(k => row[k])));
console.log("|---|");
}
module.exports = table;
#+END_SRC

Notice the :tangle src/table.js property, which I will use to require it in
a later block:

#+BEGIN_SRC js :results output raw drawer
var data = [ { day: 'SUNDAY', accidents: 3986 },
  { day: 'MONDAY', accidents: 6109 },
  { day: 'SATURDAY', accidents: 6274 },
  { day: 'WEDNESDAY', accidents: 6453 },
  { day: 'THURSDAY', accidents: 6546 },
  { day: 'TUESDAY', accidents: 6557 },
  { day: 'FRIDAY', accidents: 6916 } ];

// here you have to use the full path to the table.js file
var view_as_table = require("/app/src/table.js");

view_as_table(data);
#+END_SRC

Then I run *org-babel-tangle* to write the table.js file, and when I hit
*C-c* inside of this last block, it requires the tangled table.js file,
runs the function and we get the following results:

#+RESULTS:
:RESULTS:
|---+---|
| day   | accidents |
|---+---|
| SUNDAY|  3986 |
| MONDAY|  6109 |
| SATURDAY  |  6274 |
| WEDNESDAY |  6453 |
| THURSDAY  |  6546 |
| TUESDAY   |  6557 |
| FRIDAY|  6916 |
|---+---|
:END:

About the order of execution, if you used sessions in my example, you have
to run the first block (which defines the function) before running the
second (which uses it), or it would fail because the table function has not
been loaded.

Now imagine a very long document with dozens of source blocks. In order to
run the block number 23, you will have to run all the preceding blocks on
which that block depends. I don't like that, even if the document is meant
to be read sequentially, from start to finish, I want to be able to open
the org file, go to any section and running  any source code block without
having to remember the sequence of dependencies between them. Worst case,
all I have to do is run org-babel-tangle to update the tangled files. This
has also the added benefit that it forces me to structure my blocks
correctly, from a code architecture point of view.

I hope this makes it clearer for you.


Martin

On Fri, Dec 22, 2017 at 8:07 PM numbch...@gmail.com <numbch...@gmail.com>
wrote:

>
> Can you describe how do you do this in detailed?
> Like:
> > but since I am using docker containers to run node, I always mount the
> current directory as a volume in /app inside the container, so that works
> out fine.
> > I also think that this way forces me to separate the code in modular
> blocks, which is already a good practice in itself.
> How to do this? About this: > With sessions you have to make sure to
> execute the blocks in the correct order to build the "state" that your
> current block needs.
> I think have to use `noweb` reference here.
> (If you have a blog article describe this whole JS literate programming
> setup, that will be useful.)
> Finally, thanks you provide this paradigm.
>
> [stardiviner] GPG key ID: 47C32433
> IRC(freeenode): stardiviner Twitter:  @numbchild
> Key fingerprint = 9BAA 92BC CDDD B9EF 3B36  CB99 B8C4 B8E5 47C3 2433
> Blog: http://stardiviner.github.io/
>
> On Sat, Dec 23, 2017 at 2:32 AM, Martin Alsinet <mar...@alsinet.com.ar>
> wrote:
>
>> Hello stardiviner,
>>
>> On Fri, Dec 22, 2017 at 6:57 AM stardiviner <numbch...@gmail.com> wrote:
>>
>>>
>>> I wish to do Ja

Re: [O] Hope ob-js can support :session feature

2017-12-22 Thread Martin Alsinet
Hello stardiviner,

On Fri, Dec 22, 2017 at 6:57 AM stardiviner  wrote:

>
> I wish to do JavaScript Literate Programming in Org-mode.
>
> So the :session header argument is very necessary.
>
>
I do Literate Programming in Javascript with Org-mode, and I have found a
workaround using a combination of tangled files and require.

I separate the logic in source code blocks which then I tangle into js
files and I require those js files in other source blocks.

Example:

#+BEGIN_SRC js :tangle src/parser.js
const fs = require('fs');
const parse = require('csv-parse')

function columns(line){
return line.map(s => s.toLowerCase());
}
parse_csv = function(filename, fn, limit){
fs.readFile(filename, "utf8", function (err, fileData) {
var opts = {columns: columns, trim: true};
if (limit) {
opts.to = limit;
}
parse(fileData, opts, (err, rows) => fn(rows));
});
}
module.exports = parse_csv;
#+END_SRC

So, I tangle that source block into a js file, and then I can use it from
other blocks, without needing sessions at all:

#+BEGIN_SRC
const parser = require("/app/src/parser.js");
const inputFile = './data/records.csv';
parse_csv(inputFile, console.log);
#+END_SRC

The only drawback is that you have to use absolute paths requiring the js
files, but since I am using docker containers to run node, I always mount
the current directory as a volume in /app inside the container, so that
works out fine.
I also think that this way forces me to separate the code in modular
blocks, which is already a good practice in itself.
With sessions you have to make sure to execute the blocks in the correct
order to build the "state" that your current block needs.
This way source blocks function as standalone units that can be run at any
time, I just run *org-babel-tangle* and then hit *C-c *inside the js block.

I hope that helps you.


Martin


Re: [O] can't get org-mode noweb tangle to work

2017-11-24 Thread Martin Alsinet
Hello Charlie:

I have found that I like better to use a combination of tangle and import
instead of noweb syntax.

#+BEGIN_SRC python :tangle board.py
def init_board(args)
return [[-1 for x in range(3)] for y in range(3)]
#+END_SRC

#+BEGIN_SRC python
import sys
import os
from board import init_board

def main(args):
init_board(args)

if __name__ == "__main__":
main(sys.argv)
#+END_SRC

Then, you do a *M-x org-babel-tangle* and org will write the first block
into board.py. Then you go into the second block and run it with *C-c C-c* and
it will load the init_board function from the tangled file.

Writing it this way forces you to modularize your code blocks to be able to
call them from other blocks and you can even build your whole application
tangling the source blocks into files.

The :noweb syntax seems to me to be a templating solution used for a code
module problem.

I hope it helps you


Martin

On Fri, Nov 24, 2017 at 7:52 PM Charles R (Charlie) Martin <
chasrmar...@gmail.com> wrote:

> Grumble. Okay, this is sorted/ There are amazing numbers of
> not-quite-right examples on the web.
>
> Thanks, Tom, I now have the below, which works.
>
> #+TITLE: Console Tic Tac Toe
> #+SUBTITLE: A Literate Program in EMACS Org-Mode
> #+AUTHOR: Charlie Martin
> #+STARTUP: showall
>
> #+BEGIN_SRC python :tangle yes :noweb yes
>   import sys
>   import os
>
>   def main(args):
>   <>
>
>   if __name__ == "__main__":
>   main(sys.argv)
> #+END_SRC
>
> #+NAME: initialize-the-game-board
> #+BEGIN_SRC python
>   board = [[-1 for x in range(3)] for y in range(3)]
> #+END_SRC
>
>
>
>
> On Fri, Nov 24, 2017 at 5:26 PM, Thomas S. Dye  wrote:
>
>> Aloha Charlie,
>>
>> Charles R (Charlie) Martin writes:
>>
>> > I'm trying to get literate programming with `:noweb` syntax working in
>> > org-mode. I think I'm down to about the minimum case:
>> >
>> > #+TITLE: Console Tic Tac Toe
>> > #+SUBTITLE: A Literate Program in EMACS Org-Mode
>> > #+AUTHOR: Charlie Martin
>> > #+STARTUP: showall
>> >
>> > #+BEGIN_SRC python :tangle yes :noweb
>> >   import sys
>> >   import os
>> >
>> >   def main(args):
>> >   <>
>> >
>> >   if __name__ == "__main__":
>> >   main(sys.argv)
>> > #+END_SRC
>> >
>> > #+NAME: initialize-the-game-board
>> > #+BEGIN_SRC python :tangle yes :noweb
>> >   board = [[-1 for x in range(3)] for y in range(3)]
>> > #+END_SRC
>> >
>> > but when I tangle it I get:
>> >
>> > import sys
>> > import os
>> >
>> > def main(args):
>> > <>
>> >
>> > if __name__ == "__main__":
>> > main(sys.argv)
>> >
>> > board = [[-1 for x in range(3)] for y in range(3)]
>> >
>> > I've tried permuting the argument, flags, and so on to no avail.
>> >
>> > EMACS version is 25.3.1 MacOS, org-mode 9.1.3
>>
>> I think it should be :noweb yes
>>
>> hth,
>> Tom
>>
>> --
>> Thomas S. Dye
>> http://www.tsdye.com
>>
>
>


Re: [O] ob-python newline & indentation behavior

2017-11-18 Thread Martin Alsinet
Sorry Jack, I overlooked the :session bit.
Disregard my email please


On Sat, Nov 18, 2017 at 10:27 PM Martin Alsinet <mar...@alsinet.com.ar>
wrote:

> Hello Jack:
>
> What versions of emacs and org-mode are you using?
>
> I tried your example on Emacs 25.3.1 and org-mode 9.1.2-22 and I got "20"
> as result
> It has happened to me in the past that some bug I was seeing goes away
> just by updating org-mode.
>
> Regards,
>
>
> Martin
>
> On Sat, Nov 18, 2017 at 5:16 PM Jack Kamm <jackk...@gmail.com> wrote:
>
>> Thanks Kyle, and sorry for missing that recent related thread.
>>
>> I adapted your old patch to the current master branch. I also extended it
>> to work for ":results value" (the original patch only worked for ":results
>> output"). I did this by not writing the last line of the code block to the
>> tmpfile, unless it is indented.
>>
>> I've never contributed before so would appreciate any comments on this
>> patch, and how to get it accepted. Cheers, Jack.
>>
>> From a5d553ece9f6ee35cd1e273e554a21a19e80ec3c Mon Sep 17 00:00:00 2001
>>
>> From: Jack Kamm <jackk...@gmail.com>
>> Date: Sat, 18 Nov 2017 21:47:09 +
>> Subject: [PATCH] fix newline/indentation issues in ob-python :session
>>
>> ---
>>  lisp/ob-python.el | 33 +
>>  1 file changed, 33 insertions(+)
>>
>> diff --git a/lisp/ob-python.el b/lisp/ob-python.el
>> index 60ec5fa47..6623ef5fc 100644
>> --- a/lisp/ob-python.el
>> +++ b/lisp/ob-python.el
>> @@ -303,6 +303,10 @@ last statement in BODY, as elisp."
>>(mapc (lambda (line) (insert line) (funcall
>> send-wait))
>>  (split-string body "[\r\n]"))
>>(funcall send-wait)))
>> +(indented-p (org-babel-python--indented-p body))
>> +(body (if indented-p
>> +  (org-babel-python--replace-body-tmpfile body)
>> +body))
>>   (results
>>(pcase result-type
>>  (`output
>> @@ -340,6 +344,35 @@ last statement in BODY, as elisp."
>>(substring string 1 -1)
>>  string))
>>
>> +
>> +(defun org-babel-python--indented-p (input)
>> + "Non-nil if any line in INPUT is indented."
>> + (string-match-p "^[ \t]" input))
>> +
>> +(defun org-babel-python--replace-body-tmpfile (body)
>> +  "Place body in tmpfile, and return string to exec the tmpfile.
>> +If last line of body is not indented, place it at end of exec string
>> +instead of tmpfile, so shell can see the result"
>> +  (let* ((tmp-file (org-babel-temp-file "python-"))
>> +(lines (split-string body "\n" t))
>> +(lastline (car (last lines)))
>> +(newbody (concat
>> +  (format "__pyfilename = '%s'; " tmp-file)
>> +  "__pyfile = open(__pyfilename); "
>> +  "exec(compile("
>> +  "__pyfile.read(), __pyfilename, 'exec'"
>> +  ")); "
>> +  "__pyfile.close()")))
>> +(if (string-match-p "^[ \t]" lastline)
>> +   (progn
>> + (with-temp-file tmp-file (insert body))
>> + newbody)
>> +  (with-temp-file tmp-file
>> +   (insert (mapconcat 'identity
>> +  (butlast lines) "\n")))
>> +  (concat newbody "\n" lastline)))
>> +  )
>> +
>>  (provide 'ob-python)
>>
>>
>> --
>> 2.15.0
>>
>>
>> On Sat, Nov 18, 2017 at 3:05 PM, Kyle Meyer <k...@kyleam.com> wrote:
>>
>>> Hello,
>>>
>>> Jack Kamm <jackk...@gmail.com> writes:
>>>
>>> > ob-python newline & indentation behavior in :session is very ugly and
>>> > possibly broken. For example, consider the following code block:
>>>
>>> [...]
>>>
>>> > There is a 2 year old patch that fixes this behavior but has not yet
>>> > been incorporated:
>>> > https://lists.gnu.org/archive/html/emacs-orgmode/2015-03/msg00505.html
>>>
>>> [...]
>>>
>>> > The patch follows the python.el behavior of using a temporary file and
>>> > executing that from the shell.
>>> >
>>> > Could this patch, or something similar, be incorporated into org-mode,
>>> > to fix this behavior?
>>>
>>> Here's what I said in a recent post about ob-python sessions:
>>>
>>>
>>> https://lists.gnu.org/archive/html/emacs-orgmode/2017-10/msg00198.html
>>>
>>> I dropped my attempt to fix it because 1) I was still having trouble
>>> getting a complete understanding of what the issue was and 2) I
>>> didn't
>>> have the motivation to spend time digging deeper because I don't use
>>> ob-python (and in general am not a heavy Org-Babel user).  Perhaps
>>> you
>>> or some other ob-python user could help make ob-python sessions more
>>> robust?
>>>
>>> Perhaps you are the "you"?
>>>
>>> --
>>> Kyle
>>>
>>
>>


Re: [O] ob-python newline & indentation behavior

2017-11-18 Thread Martin Alsinet
Hello Jack:

What versions of emacs and org-mode are you using?

I tried your example on Emacs 25.3.1 and org-mode 9.1.2-22 and I got "20"
as result
It has happened to me in the past that some bug I was seeing goes away just
by updating org-mode.

Regards,


Martin

On Sat, Nov 18, 2017 at 5:16 PM Jack Kamm  wrote:

> Thanks Kyle, and sorry for missing that recent related thread.
>
> I adapted your old patch to the current master branch. I also extended it
> to work for ":results value" (the original patch only worked for ":results
> output"). I did this by not writing the last line of the code block to the
> tmpfile, unless it is indented.
>
> I've never contributed before so would appreciate any comments on this
> patch, and how to get it accepted. Cheers, Jack.
>
> From a5d553ece9f6ee35cd1e273e554a21a19e80ec3c Mon Sep 17 00:00:00 2001
>
> From: Jack Kamm 
> Date: Sat, 18 Nov 2017 21:47:09 +
> Subject: [PATCH] fix newline/indentation issues in ob-python :session
>
> ---
>  lisp/ob-python.el | 33 +
>  1 file changed, 33 insertions(+)
>
> diff --git a/lisp/ob-python.el b/lisp/ob-python.el
> index 60ec5fa47..6623ef5fc 100644
> --- a/lisp/ob-python.el
> +++ b/lisp/ob-python.el
> @@ -303,6 +303,10 @@ last statement in BODY, as elisp."
>(mapc (lambda (line) (insert line) (funcall
> send-wait))
>  (split-string body "[\r\n]"))
>(funcall send-wait)))
> +(indented-p (org-babel-python--indented-p body))
> +(body (if indented-p
> +  (org-babel-python--replace-body-tmpfile body)
> +body))
>   (results
>(pcase result-type
>  (`output
> @@ -340,6 +344,35 @@ last statement in BODY, as elisp."
>(substring string 1 -1)
>  string))
>
> +
> +(defun org-babel-python--indented-p (input)
> + "Non-nil if any line in INPUT is indented."
> + (string-match-p "^[ \t]" input))
> +
> +(defun org-babel-python--replace-body-tmpfile (body)
> +  "Place body in tmpfile, and return string to exec the tmpfile.
> +If last line of body is not indented, place it at end of exec string
> +instead of tmpfile, so shell can see the result"
> +  (let* ((tmp-file (org-babel-temp-file "python-"))
> +(lines (split-string body "\n" t))
> +(lastline (car (last lines)))
> +(newbody (concat
> +  (format "__pyfilename = '%s'; " tmp-file)
> +  "__pyfile = open(__pyfilename); "
> +  "exec(compile("
> +  "__pyfile.read(), __pyfilename, 'exec'"
> +  ")); "
> +  "__pyfile.close()")))
> +(if (string-match-p "^[ \t]" lastline)
> +   (progn
> + (with-temp-file tmp-file (insert body))
> + newbody)
> +  (with-temp-file tmp-file
> +   (insert (mapconcat 'identity
> +  (butlast lines) "\n")))
> +  (concat newbody "\n" lastline)))
> +  )
> +
>  (provide 'ob-python)
>
>
> --
> 2.15.0
>
>
> On Sat, Nov 18, 2017 at 3:05 PM, Kyle Meyer  wrote:
>
>> Hello,
>>
>> Jack Kamm  writes:
>>
>> > ob-python newline & indentation behavior in :session is very ugly and
>> > possibly broken. For example, consider the following code block:
>>
>> [...]
>>
>> > There is a 2 year old patch that fixes this behavior but has not yet
>> > been incorporated:
>> > https://lists.gnu.org/archive/html/emacs-orgmode/2015-03/msg00505.html
>>
>> [...]
>>
>> > The patch follows the python.el behavior of using a temporary file and
>> > executing that from the shell.
>> >
>> > Could this patch, or something similar, be incorporated into org-mode,
>> > to fix this behavior?
>>
>> Here's what I said in a recent post about ob-python sessions:
>>
>>
>> https://lists.gnu.org/archive/html/emacs-orgmode/2017-10/msg00198.html
>>
>> I dropped my attempt to fix it because 1) I was still having trouble
>> getting a complete understanding of what the issue was and 2) I didn't
>> have the motivation to spend time digging deeper because I don't use
>> ob-python (and in general am not a heavy Org-Babel user).  Perhaps you
>> or some other ob-python user could help make ob-python sessions more
>> robust?
>>
>> Perhaps you are the "you"?
>>
>> --
>> Kyle
>>
>
>


Re: [O] C++ sessions for Babel with cling interpreter

2017-11-05 Thread Martin Alsinet
Hello Garjola:

I have not used C++ source blocks, but I use them frequently with
Javascript and Python, and I don't use sessions.
The thing is, for literate programming, we want to include the code from
one source block in others, and it would seem that sessions are the
solution.
However, I find that for me it is better to use tangle to export the code
to source files and then include the tangled files from the other source
blocks.

Example:

#+BEGIN_SRC js :tangle src/hello.js
function hello(text) {
console.log("hello " + text);
}
module.exports = hello;
#+END_SRC

First I have to run *org-babel-tangle* to export all source blocks to
files, and then I can include them in other blocks.

#+BEGIN_SRC js
const hello = require("./src/hello.js");
hello("Martin");
#+END_SRC

>From what I remember, it is possible to do the same in C++, including the
source files you need from the filesystem.
In my opinion, this approach is better than sessions, because the problem
with sessions is that you have to make sure the blocks are executed
secuentially in the right order to build the "state" that allows you to run
your current block. This way each block is independent of all others, worst
case you have to run org-babel-tangle to create the required files.

Regards,


Martín


On Sun, Nov 5, 2017 at 12:13 PM  wrote:

> Hi all,
>
> I use C++ source code blocks in babel frequently and I am very happy with
> the results. As C++ is a compiled language, ob-C.el does not support
> sessions.
>
> Unfortunately, this breaks a little my litterate programming workflow,
> since I don't know how to use small code snippets without sessions.
>
> I have recently discovered cling [1], [2] a C++ interpreter which comes
> with de Root package [3]. I have also found a cling inferior mode [4] to
> interact with the interpreter in a comint buffer.
>
> I was wondering if it would be difficult to update ob-C.el to use cling
> for session support. My elisp knowledge is too poor to understand what is
> involved in doing such a thing, but I would be interested in trying or
> helping somebody do it. Unfortunately, I have the impression that the
> developers of ob-C.el are not around this list anymore?
>
> I would very much appreciate suggestions on how to proceed.
>
> Thank you.
>
> Garjola.
>
> Footnotes:
> [1]  https://root.cern.ch/cling
> [2]  https://www.youtube.com/watch?v=Lbi7MLS03Yc
> [3]  https://root.cern.ch/
> [4]  https://github.com/brianqq/inferior-cling
>
> --
> Dr. Dindi
> Dad, Philosopher, Hacker
>
>


Re: [O] org-babel source block unevaluated into variable?

2017-10-26 Thread Martin Alsinet
Johan:

Maybe this one would work for you:

#+NAME: first
#+BEGIN_SRC js
function one() {
return 1;
}
#+END_SRC


#+NAME: second
#+BEGIN_SRC js
function two() {
return 2;
}
#+END_SRC


#+NAME: third
#+BEGIN_SRC js
function three() {
return 3;
}
#+END_SRC


#+NAME: all
#+BEGIN_SRC sh :results output :noweb yes
echo "
<>

<>

function test(){ console.log('test');}

<>"
#+END_SRC



#+BEGIN_SRC python :results output :var code=all
print code
#+END_SRC

#+RESULTS:
#+begin_example

function two() {
return 2
}

function one() {
return 1;
}

function test(){ console.log('test');}

function three() {
return 3;
}

#+end_example


On Thu, Oct 26, 2017 at 6:17 AM Johan W. Klüwer <johan.w.klu...@gmail.com>
wrote:

> Thanks Martin,
>
> These are good suggestions, but it's not quite what I am after. In your
> second example, I would like ":var code=example" to make "code" carry the
> full (and expanded) text of the "example" block, i.e. to have
>
>   echo ls -alh
>
> as the result -- the code itself, unevaluated.
>
> Johan
>
> 2017-10-25 17:52 GMT+02:00 Martin Alsinet <mar...@alsinet.com.ar>:
>
>> Johan:
>>
>> To use expanded noweb references you can use text source blocks
>>
>> #+NAME: lscode
>> #+BEGIN_SRC *text*
>> ls -alh
>> #+END_SRC
>>
>>
>> #+NAME: example
>> #+BEGIN_SRC sh :noweb yes
>> echo <>
>> #+END_SRC
>>
>> #+RESULTS: example
>> : ls -alh
>>
>>
>> #+BEGIN_SRC emacs-lisp :var code=example
>> (message code)
>> #+END_SRC
>>
>> #+RESULTS:
>> : ls -alh
>>
>>
>> Martín
>>
>> On Wed, Oct 25, 2017 at 10:36 AM Martin Alsinet <mar...@alsinet.com.ar>
>> wrote:
>>
>>> Johan:
>>>
>>> You can try the following:
>>>
>>> #+NAME: lscode
>>> #+BEGIN_ASCII
>>> ls -alh
>>> #+END_ASCII
>>>
>>> #+BEGIN_SRC emacs-lisp :var code=lscode
>>> (message code)
>>> #+END_SRC
>>>
>>> #+RESULTS:
>>> : ls -alh
>>>
>>> I haven't tried the noweb references, but it does return the code block
>>> in the variable.
>>>
>>>
>>> Martín
>>>
>>> On Wed, Oct 25, 2017 at 9:22 AM Johan W. Klüwer <
>>> johan.w.klu...@gmail.com> wrote:
>>>
>>>> Is there a way to assign the uninterpreted content of an executable
>>>> source block to a variable? Preferably, using a :var header argument? That
>>>> is, return the text in the block, not the result of evaluating it, and
>>>> preferably with noweb references expanded.
>>>>
>>>> "example" blocks return text the way I want, but they can't be
>>>> evaluated, and of course noweb is ruled out for them.
>>>>
>>>> The function org-babel-ref-resolve could to the job if there were a
>>>> switch to block evaluation.
>>>>
>>>>
>>>> Why this is interesting: I wish to use url-hexify-string on the text of
>>>> a named SPARQL query.
>>>>
>>>> Cheers, Johan
>>>>
>>>
>


Re: [O] org-babel source block unevaluated into variable?

2017-10-25 Thread Martin Alsinet
Johan:

To use expanded noweb references you can use text source blocks

#+NAME: lscode
#+BEGIN_SRC *text*
ls -alh
#+END_SRC


#+NAME: example
#+BEGIN_SRC sh :noweb yes
echo <>
#+END_SRC

#+RESULTS: example
: ls -alh


#+BEGIN_SRC emacs-lisp :var code=example
(message code)
#+END_SRC

#+RESULTS:
: ls -alh


Martín

On Wed, Oct 25, 2017 at 10:36 AM Martin Alsinet <mar...@alsinet.com.ar>
wrote:

> Johan:
>
> You can try the following:
>
> #+NAME: lscode
> #+BEGIN_ASCII
> ls -alh
> #+END_ASCII
>
> #+BEGIN_SRC emacs-lisp :var code=lscode
> (message code)
> #+END_SRC
>
> #+RESULTS:
> : ls -alh
>
> I haven't tried the noweb references, but it does return the code block in
> the variable.
>
>
> Martín
>
> On Wed, Oct 25, 2017 at 9:22 AM Johan W. Klüwer <johan.w.klu...@gmail.com>
> wrote:
>
>> Is there a way to assign the uninterpreted content of an executable
>> source block to a variable? Preferably, using a :var header argument? That
>> is, return the text in the block, not the result of evaluating it, and
>> preferably with noweb references expanded.
>>
>> "example" blocks return text the way I want, but they can't be evaluated,
>> and of course noweb is ruled out for them.
>>
>> The function org-babel-ref-resolve could to the job if there were a
>> switch to block evaluation.
>>
>>
>> Why this is interesting: I wish to use url-hexify-string on the text of a
>> named SPARQL query.
>>
>> Cheers, Johan
>>
>


Re: [O] org-babel source block unevaluated into variable?

2017-10-25 Thread Martin Alsinet
Johan:

You can try the following:

#+NAME: lscode
#+BEGIN_ASCII
ls -alh
#+END_ASCII

#+BEGIN_SRC emacs-lisp :var code=lscode
(message code)
#+END_SRC

#+RESULTS:
: ls -alh

I haven't tried the noweb references, but it does return the code block in
the variable.


Martín

On Wed, Oct 25, 2017 at 9:22 AM Johan W. Klüwer 
wrote:

> Is there a way to assign the uninterpreted content of an executable source
> block to a variable? Preferably, using a :var header argument? That is,
> return the text in the block, not the result of evaluating it, and
> preferably with noweb references expanded.
>
> "example" blocks return text the way I want, but they can't be evaluated,
> and of course noweb is ruled out for them.
>
> The function org-babel-ref-resolve could to the job if there were a switch
> to block evaluation.
>
>
> Why this is interesting: I wish to use url-hexify-string on the text of a
> named SPARQL query.
>
> Cheers, Johan
>


Re: [O] enhancement - cross-reference to another file?

2017-10-14 Thread Martin Alsinet
Hello Sharon:

On Sat, Oct 14, 2017 at 7:45 AM Sharon Kimble 
wrote:

>
> Is it possible to cross reference to another org-mode file in a
> different directory?
>

Yes, it is possible, you have to use the following syntax:

[[file:/path/to/other/org/file.org:* heading][My other org file]]

You can check the manual for the different link types and examples
http://orgmode.org/manual/External-links.html




> Example - cooking 1 has an entry for Mayonnaise, so can file 2 have an
> entry for mayonnaise but cross-referenced to cooking 1?
>
> --8<---cut here---start->8---
> id1=cooking1.org
>
> ** Mayonnaise
> [[*Mayonnaise][Mayonnaise]]
> blurb and blah
> --8<---cut here---end--->8---
>
> --8<---cut here---start->8---
> id2=cooking2.org
>
> ** Mayonnaise 3
>
> See also [[*id1:Mayonnaise][Mayonnaise]] and also [[*Mayonnaise
> 2][Mayonnaise 2]]
>
> --8<---cut here---end--->8---
>
>
In your example, the references would be written:

See also [[file:cooking1.org:** Mayonnaise][this mayonnaise recipe]] and
also [[*Mayonnaise 2][this other one]]


Re: [O] *Good* client for Android?

2017-10-12 Thread Martin Alsinet
Hello John:

If your phone screen is big enough, you could use termux
 + emacs +
git & git-remote-gcrypt.
With that you could use the same stack on Android as on your laptop.

Termux is a linux console for Android that lets you install packages with
something similar to apt-get in debian/ubuntu.
I am thinking about getting a cheap Android tablet myself in order to have
a ultra light mobile workstation with termux.
On the other hand, a terminal console on a 5 inch phone screen doesn't seem
to be very practical for prolonged work.


Martin

On Thu, Oct 12, 2017 at 4:32 PM John Goerzen  wrote:

> Hi folks,
>
> All along, I anticipated using this with Android (and, ideally, also
> iOS).  The MobileOrg feature set looked great, and the syncing mechanism
> looked a lot better than sharing Dropbox.
>
> I use git to share my ~/org between two computers (laptop and desktop),
> using git-remote-gcrypt to store on a server.  This makes syncing and
> resolving conflicts easy (I move between the two throughout the day, so
> Dropbox is really not a great option here.)  Sync integrity -- or at
> least robust detection of conflicts -- is a must.  Encryption is a "very
> nice to have."
>
> Suggestions?
>
> Here's what I've found so far:
>
> MobileOrg - supports WebDAV storage.  Has a robust sync system,
> integrated with org-mode, in which it seems to be able to write out its
> changes to a separate file that the computer can integrate.  Sounds
> smart, though I suspect it will require additional hacking to support
> multiple Android devices.  org-mode docs mention encryption for this,
> but the encryption is not supported by MobileOrg.  Also, MobileOrg was
> last updated 4 years ago and seems to have bitrotted.
>
> Orgzly - Supports only Dropbox or local-on-Android storage. The latter
> is insecure, as it permits any app on the system to read the files.  I
> am really not sure how to integrate this with my workflow.  It seems
> like potentials for conflicts are extremely high.
>
> SyncOrg - Shows some promise, but couldn't even test locally due to the
> folder selection screen not working for the "External/Local Only."
> Suspect it's trying to do something insecure as well, or doesn't work on
> Oreo?  ssh support seems to actually be ssh+git, which is nice - except
> that it's unencrypted.  doh.  The documentation made no mention of
> resolving conflicts.  https://github.com/wizmer/syncorg/wiki/FAQ seems
> to suggest it uses the old MobileOrg push/pull in org-mode, but I can't
> see how that possibly works well with Git.  I suspect that FAQ to be
> totally obsolete, because it also talks about a Dropbox synchronizer
> that SyncOrg doesn't even have.  I could use this if I drop
> git-remote-gcrypt, I hope.
>
> MobileOrg-NG - Last updated in 2012.  Didn't really look past that.
>
>
>
>


Re: [O] Nested smart quotes

2017-10-05 Thread Martin Alsinet
On Thu, Oct 5, 2017 at 4:58 PM Adonay Felipe Nogueira 
wrote:

> What about using org-entities for these quotes?
>
> \ldquo{}Hello \lsquo{}World\rsquo{}!\rdquo{}
>
> This is Org mode syntax, not LaTeX.
>
>
Adonay:

I wanted to solve this using smart quotes, that is when I write I don't
have to worry with anything other than writing, and the light formatting of
org-mode is great for that (* for emphasis, / for italics, etc.) While the
solution you are proposing is technically correct, it achieves the result,
I find it too verbose and distracting from the text.

Actually I solved the problem by upgrading to org-mode 9.1.2 and leaving a
space between the inner quote and the enclosing double quote.

Thanks and regards


Martín


Re: [O] Nested smart quotes [fixed]

2017-10-05 Thread Martin Alsinet
On Thu, Oct 5, 2017 at 2:41 PM Martin Alsinet <mar...@alsinet.com.ar> wrote:

> Hello Nick. First, thank you so much for your detailed answer.
>
> I'm not sure whether smart quotes can be made smarter, perhaps by
>> detecting the problem and inserting the small space \, to resolve the
>> ambiguity; but the manual space solution should have worked: what
>> version of org are you using?
>>
>> FWIW, mine is latest master: Org mode version 9.1.2
>> (release_9.1.2-84-geeaf9a @ /home/nick/src/emacs/org/org-mode/lisp/)
>>
>
> I am using Org mode version 8.2.10, I will update my version and try again.
>
>
I updated Org-mode to the last version (9.1.2) from the orgmode.org ELPA
sources and the problem went away.

Separating the nested quotes with a space does the trick:

She said to me: "Rick screamed, 'let's go together' "

Now the closing quote gets "smarted" in the exported PDF file.

Thank you very much


Martin


Re: [O] Nested smart quotes

2017-10-05 Thread Martin Alsinet
Hello Nick. First, thank you so much for your detailed answer.

On Thu, Oct 5, 2017 at 2:16 PM Nick Dokos  wrote:

>
> This example has the additional problem of the apostrophe in "let's", which
> basically causes more mayhem. Let's simplify the example a bit by
> considering
>
> She said to me: "Rick screamed, 'let us go together'"
>
> which when export to TeX becomes:
>
> She said to me: ``Rick screamed, `let us go together'''
>
> and TeX misinterprets the three closing single quotes as (closing
> double quote, closing single quote) instead of (closing single quote,
> closing double quote).
>
>
I was beginning to suspect that, I didn't see it at first, but after
writing and explaining the problem, it dawned on me that it could be LaTeX
that cannot correctly parse the three consecutive single quotes.


> >
> > Internal
> >
> > In this case, the internal single quotes are rendered correctly, but the
> closing quote is not converted into its "smart" version.
> >
> > If the nested quotes are in such a way that there are other characters
> between the quotes, that is they are not together at the start or the end
> of the quote, they get rendered correctly.
>
> I'm not sure whether smart quotes can be made smarter, perhaps by
> detecting the problem and inserting the small space \, to resolve the
> ambiguity; but the manual space solution should have worked: what
> version of org are you using?
>
> FWIW, mine is latest master: Org mode version 9.1.2
> (release_9.1.2-84-geeaf9a @ /home/nick/src/emacs/org/org-mode/lisp/)
>

I am using Org mode version 8.2.10, I will update my version and try again.


Martin


Re: [O] Nested smart quotes

2017-10-05 Thread Martin Alsinet
Colin:

The beauty of smart quotes is that I don't have to see the ugly LaTeX
formatting in my org file, but the final document has the corresponding
opening and closing quote characters. While I do sprinkle some LaTeX here
and there in my org files, I think that would be going a little too far for
my taste.

Thanks anyway!

Martin


On Thu, Oct 5, 2017 at 12:22 PM Colin Baxter <m43...@yandex.com> wrote:

> >>>>> Martin Alsinet <mar...@alsinet.com.ar> writes:
>
>
> > #+TITLE: Smart quotes example #+OPTIONS: toc:nil ':t #+LANGUAGE:
> > en #+LATEX_CLASS: book She said to me: "Rick screamed, 'let's go
> > together'"
>
> > This gets exported to TeX as:
>
> > She said to me: ``Rick screamed, `let's go together'''
>
> > Which gets rendered as PDF as:
>
> > The order of the closing quotes is wrong
>
> > The order of the closing quotes gets reversed, it first closes the
> > outside double quotes and then the nested single quote.
>
> > I have tried leaving a space between them, but that is arguably
> > worse
>
> > Org:
>
> > She said to me: "Rick screamed, 'let's go together' "
>
> > TeX:
>
> > She said to me: ``Rick screamed, `let's go together' "
>
> > PDF:
>
> > Internal quotes are ok, closing double quote is wrong
>
> > In this case, the internal single quotes are rendered correctly,
> > but the closing quote is not converted into its "smart" version.
>
> > If the nested quotes are in such a way that there are other
> > characters between the quotes, that is they are not together at
> > the start or the end of the quote, they get rendered correctly.
>
> > Thanks in advance
>
> > Martin
>
> What about
>
> She said to me: \lq\lq Rick screamed, \lq let's go together\rq\nbsp{}\rq\rq
>
>
> --
> Colin Baxter
> m43...@yandex.com
>


[O] Nested smart quotes

2017-10-05 Thread Martin Alsinet
Hello!

My name is Martin and I use org-mode every day. This is my first message to
the mailing list, and I wanted to ask if somebody could help me with a
problem I encountered when exporting a document with nested smart quotes.

I have submitted the same question

to the emacs Stack Exchange, and someone suggested there to send a message
to this list. I assume many people here reads their email inside emacs, and
since this email has embedded images, you might see it better formatted in
SO.

I have found that the smart-quotes option of org-mode does not export
properly the quotes when they are nested (single quotes inside double
quotes), but only when they coincide at the start or the end of the quote.

Maybe the problem will be clearer with an example:

#+TITLE: Smart quotes example
#+OPTIONS: toc:nil ':t
#+LANGUAGE: en
#+LATEX_CLASS: book
She said to me: "Rick screamed, 'let's go together'"

This gets exported to TeX as:

She said to me: ``Rick screamed, `let's go together'''

Which gets rendered as PDF as:

[image: The order of the closing quotes is wrong]


The order of the closing quotes gets reversed, it first closes the outside
double quotes and then the nested single quote.

I have tried leaving a space between them, but that is arguably worse

Org:

She said to me: "Rick screamed, 'let's go together' "

TeX:

She said to me: ``Rick screamed, `let's go together' "

PDF:

[image: Internal quotes are ok, closing double quote is wrong]


In this case, the internal single quotes are rendered correctly, but the
closing quote is not converted into its "smart" version.

If the nested quotes are in such a way that there are other characters
between the quotes, that is they are not together at the start or the end
of the quote, they get rendered correctly.

Thanks in advance


Martin