[O] language support for m4

2018-04-04 Thread Brad Knotwell
Good evening all--
The attached file adds m4 support.  It was tested against org-9.1.7 and used 
ob-sed.el and ob-shell.el for inspiration.  Both code execution and tangling 
have been tested with simple inputs as well as tables (easiest way to verify 
correctness is to inspect the tangled output).  It was good fun for an evening 
project (converting the tables to m4 list syntax was the trickiest part and 
required a foray into ob-shell.el; pcase is a nifty function).
When putting it together, I debated between putting the definitions 
representing variables in as -DNAME=value pairs in the command-line or putting 
them in the body of the generate file.  Even though it's a bit uglier, I 
decided to put them in the body of the file as it makes the generated file 
capable of being run by hand.
Finally, thanks for the work on org-mode and babel.  Vanilla org-mode has made 
my meeting notes are significantly easier and PDF exports look terrific.  
Likewise, while I've written numerous documents using R/knitr, I appreciate 
having a literate environment that supports additional languages.
--Brad

ob-m4.el
Description: Binary data


Re: [O] Library of Babel confusion

2018-04-04 Thread Lawrence Bottorff
The docs  have this
example:

#+name: square
#+header: :var x=0
#+begin_src python
return x*x
#+end_src

#+call: square(x=6)

...so yes, "return", but with

(defun myelsquare (x)
   (* x x))

isn't the final thing evaluated what is "returned" with Elisp? AFAIK there
is no explicit return with Elisp. #+call can't really call a function, only
named blocks of REPL-style calculator snippets?

Also, today I find that a new start of Emacs doesn't load my LOB file, i.e.,

(custom-set-variables
...
 '(org-babel-lob-files (quote ("~/org/worg/library-of-babel.org")))
...

was being blown off, i.e., not populating the org-babel-library-of-babel
variable. But today org-babel-lob-injest does seem to work, i.e., it did
populate org-babel-library-of-babel. I wonder what's up.




On Tue, Apr 3, 2018 at 4:44 PM, Nicolas Goaziou 
wrote:

> Lawrence Bottorff  writes:
>
> > I've been trying to grok LOB again. So I've cloned the worg git and
> > library-of-babel.el is one of the files. org-babel-lob-injest didn't
> > work,
>
> What doesn't work? You call `org-babel-lob-ingest', specify a file, and
> it stores all source code blocks in the file for later use.
>
> > Now, in my org file I put this:
> >
> > #+lob: write(file="jsontest")
>
> This should be #+call: write(...)
>
> >
> > and try C-c C-c on it. Nothing. My minibuffer says "local setup has been
> > refreshed". How does one use, call a LOB function? Also, while I'm
> > demonstrating my rank noobian-ness, I try this:
> >
> > #+name: myelsquare
> > #+header: :var x=0
> >
> > #+begin_src emacs-lisp
> >   (* x x)
> > #+end_src
> >
> > #+call: myelsquare(x=6)
> >
> > #+RESULTS: : 36
> >
> > but this results in
> >
> > #+name: myelsquare
> > #+header: :var x=0
> >
> > #+begin_src emacs-lisp
> >   (defun myelsquare (x)
> >   (* x x))
> > #+end_src
> >
> > #+call: myelsquare(x=6)
> >
> > #+RESULTS:
> > : myelsquare2
> >
> > After a #+call:... I use C-c C-c to evaluate it. What am I missing
> > here?
>
> Your second block defines a function, but doesn't return its results.
> "#+call: myelsquare(...)" expects to find a block named "myelsquare",
> not an Elisp function named "myelsquare".
>
> Regards,
>
> --
> Nicolas Goaziou
>


Re: [O] Support showing stars as pretty bullets

2018-04-04 Thread Alex Branham

On Tue 03 Apr 2018 at 15:33, Nicolas Goaziou  wrote:

>> Fair enough. How about the attached patch instead? It only sets up the
>> two local variables in org.el and puts the rest in org-entities.el since
>> that file is also concerned with replacing characters with "prettier"
>> versions of themselves.
>
> I don't think it belongs to "org-entities.el" either. While it is true
> there is some prettification done there, this is not the sole point of
> the library. IOW, it is more than eye-candy; it affects, e.g., export.
>
> I really think it should go into a new "org-art.el" file.

The issue I see with putting it into org-art.el is that users won't be
able to just call M-x prettify-symbols-mode in an org buffer. They'll
have to do something like

(require 'org-art)
(add-hook 'org-mode-hook #'org-art-prettify)

or something like that. It seems like more work for users than setting
two variables in org-mode. There's also no way for users who prefer M-x
customize to easily activate it (unless we add a defcustom to org.el...)
Or am I missing something?

Let me know, everything else below is relatively minor.

Thanks again!

> More comments follow.
>
>> +;; prettify-mode
>> +(defvar-local org-prettify-alist '(("*" . ?•))
>> +  "An alist of symbols to prettify, see `prettify-symbols-alist'.
>> +Whether the symbol actually gets prettified is controlled by
>> +`org-pretty-compose-p', which see.")
>
> Should this be a defcustom?

prettify-symbols-alist isn't, so I don't think this should be either.

> Also, note that the name space must match library, so if it goes into
> "org-art.el", it ought to be named, e.g., `org-art-prettify-alist'.

Will do

>> +(defun org-pretty-compose-p (start end match)
>> +  "Return t if the symbol should be prettified.
>
> "Non-nil if symbol between START and END should be prettified.
> MATCH is ..."

Sure thing

>> +START and END are the start and end points, MATCH is the string
>> +match.  See also `prettify-symbols-compose-predicate'."
>> +  (if (string= match "*")
>> +  ;; prettify asterisks in headings
>> +  (org-at-heading-p)
>
> Doesn't this mean that any bold object in headline is going to be
> prettified?
>
> Maybe something like this (untested):
>
>   (and (org-match-line org-outline-regexp-bol)
>(< end (match-end 0)))

Thanks, this fixes the bug I mentioned in my first email. Seems to work
well on my end, too!

>> +;; else rely on the default function
>
> Nitpick:
>
>   ";; Else rely on the default function."
>
>> +  ;; Setup prettify mode
>
> Ditto:
>
>   ";; Setup prettify mode."

Sure, I'll fix those

>> +  (setq-local prettify-symbols-alist org-prettify-alist)
>> +  (setq-local prettify-symbols-compose-predicate
>> #'org-pretty-compose-p)
>
> This should also go into "org-art.el", which is an optional library. We
> don't want to activate anything related to it every time Org is loaded.
>
> Can it be tested somehow?

I'll look into it



Re: [O] Library of Babel confusion

2018-04-04 Thread Nicolas Goaziou
Lawrence Bottorff  writes:

> I've been trying to grok LOB again. So I've cloned the worg git and
> library-of-babel.el is one of the files. org-babel-lob-injest didn't
> work,

What doesn't work? You call `org-babel-lob-ingest', specify a file, and
it stores all source code blocks in the file for later use.

> Now, in my org file I put this:
>
> #+lob: write(file="jsontest")

This should be #+call: write(...)

>
> and try C-c C-c on it. Nothing. My minibuffer says "local setup has been
> refreshed". How does one use, call a LOB function? Also, while I'm
> demonstrating my rank noobian-ness, I try this:
>
> #+name: myelsquare
> #+header: :var x=0
>
> #+begin_src emacs-lisp
>   (* x x)
> #+end_src
>
> #+call: myelsquare(x=6)
>
> #+RESULTS: : 36
>
> but this results in
>
> #+name: myelsquare
> #+header: :var x=0
>
> #+begin_src emacs-lisp
>   (defun myelsquare (x)
>   (* x x))
> #+end_src
>
> #+call: myelsquare(x=6)
>
> #+RESULTS:
> : myelsquare2
>
> After a #+call:... I use C-c C-c to evaluate it. What am I missing
> here?

Your second block defines a function, but doesn't return its results.
"#+call: myelsquare(...)" expects to find a block named "myelsquare",
not an Elisp function named "myelsquare".

Regards,

-- 
Nicolas Goaziou



Re: [O] Support showing stars as pretty bullets

2018-04-04 Thread Nicolas Goaziou

> Fair enough. How about the attached patch instead? It only sets up the
> two local variables in org.el and puts the rest in org-entities.el since
> that file is also concerned with replacing characters with "prettier"
> versions of themselves.

I don't think it belongs to "org-entities.el" either. While it is true
there is some prettification done there, this is not the sole point of
the library. IOW, it is more than eye-candy; it affects, e.g., export.

I really think it should go into a new "org-art.el" file.

More comments follow.

> +;; prettify-mode
> +(defvar-local org-prettify-alist '(("*" . ?•))
> +  "An alist of symbols to prettify, see `prettify-symbols-alist'.
> +Whether the symbol actually gets prettified is controlled by
> +`org-pretty-compose-p', which see.")

Should this be a defcustom?

Also, note that the name space must match library, so if it goes into
"org-art.el", it ought to be named, e.g., `org-art-prettify-alist'.

> +(defun org-pretty-compose-p (start end match)
> +  "Return t if the symbol should be prettified.

"Non-nil if symbol between START and END should be prettified.
MATCH is ..."

> +START and END are the start and end points, MATCH is the string
> +match.  See also `prettify-symbols-compose-predicate'."
> +  (if (string= match "*")
> +  ;; prettify asterisks in headings
> +  (org-at-heading-p)

Doesn't this mean that any bold object in headline is going to be
prettified?

Maybe something like this (untested):

  (and (org-match-line org-outline-regexp-bol)
   (< end (match-end 0)))

> +;; else rely on the default function

Nitpick:

  ";; Else rely on the default function."
  
> +  ;; Setup prettify mode

Ditto:

  ";; Setup prettify mode."

> +  (setq-local prettify-symbols-alist org-prettify-alist)
> +  (setq-local prettify-symbols-compose-predicate
> #'org-pretty-compose-p)

This should also go into "org-art.el", which is an optional library. We
don't want to activate anything related to it every time Org is loaded.

Can it be tested somehow?



Re: [O] [SOLVED]

2018-04-04 Thread Uwe Brauer



   > To answer my own question

   > | / | / | |   | /   |
   > |   | Name  | Res | Letra | Obs |
   > |---+---+-+---+-|
   > |   | Smith |   0 |   | |
   > |   | Jones | 1.4 |   | |
   > |   | Bond  | 5.6 | * | |

   > All columns starting with / are ignored when exporting. Sorry for the
   > noise and the double posting.


That is not entirely correct. Someone (I forgot who it was, sorry)
provided me with the following hack


(add-hook 'org-export-before-processing-hook
   'f-ox-filter-table-column-del)


(defun f-ox-filter-table-column-del (back-end)
   "Delete the columns $2 to $> marked as \"/\" on a row with \"/\" in $1.
 If you want a non-empty column $1 to be deleted make it $2 by
 inserting an empty column before or rearrange column order in
 some other way. Make sure \"/\" is in $1 again after that."
   (while (re-search-forward
   "^[ \t]*| +/ +|\\(.*?|\\)?? +\\(/\\) +|" nil t)
 (goto-char (match-beginning 2))
 (org-table-delete-column)
 (beginning-of-line)))


That is very useful and I wonder why there is nothing in org vanilla
(but then it might and I did not find it.)




[O] [SOLVED] (was: export table to html, don't display certain columns)

2018-04-04 Thread Uwe Brauer
>>> "Uwe" == Uwe Brauer  writes:

   > Hi
   > I know that in radio tables I can skip columns like this

   > % END RECEIVE ORGTBL firmas \begin{comment} #+ORGTBL: SEND firmas
   > orgtbl-to-latex  :skipcols (1) :lend " \\hline" :environment
   > supertabular 

To answer my own question

| / | / | |   | /   |
|   | Name  | Res | Letra | Obs |
|---+---+-+---+-|
|   | Smith |   0 |   | |
|   | Jones | 1.4 |   | |
|   | Bond  | 5.6 | * | |

All columns starting with / are ignored when exporting. Sorry for the
noise and the double posting.

Uwe Brauer 




Re: [O] Fwd: minor ob-sed.el patch for org-mode

2018-04-04 Thread Marco Wahl
Bjarte Johansen  writes:

> This is a minor patch suggested by Brad Knotwell so that ob-sed can support 
> BSD sed and not only GNU sed.

+1




[O] Fwd: minor ob-sed.el patch for org-mode

2018-04-04 Thread Bjarte Johansen
Hello,

This is a minor patch suggested by Brad Knotwell so that ob-sed can support BSD 
sed and not only GNU sed.

Regards,
Bjarte



0002-ob-sed-Use-f-instead-of-file-to-support-BSD-sed.patch
Description: Binary data


[O] export table to html, don't display certain columns

2018-04-04 Thread Uwe Brauer

Hi

I know that in radio tables I can skip columns like this

% END RECEIVE ORGTBL firmas \begin{comment} #+ORGTBL: SEND firmas 
orgtbl-to-latex  :skipcols (1) :lend " \\hline" :environment 
supertabular 



However how can I achieve that in tables in org file which I want 
to export to html?


Thanks

Uwe Brauer 



[O] export table to html, don't display certain columns

2018-04-04 Thread Uwe Brauer

Hi

I know that in radio tables I can skip columns like this

% END RECEIVE ORGTBL firmas \begin{comment} #+ORGTBL: SEND firmas 
orgtbl-to-latex  :skipcols (1) :lend " \\hline" :environment 
supertabular 



However how can I achieve that in tables in org file which I want 
to export to html?


Thanks

Uwe Brauer