From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lawrence Bottorff Subject: Re: Library of Babel confusion Date: Fri, 6 Apr 2018 18:15:27 -0400 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000c11da805693564df" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:37198) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f4Zdr-0001lz-52 for emacs-orgmode@gnu.org; Fri, 06 Apr 2018 18:15:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f4Zdp-000575-Hr for emacs-orgmode@gnu.org; Fri, 06 Apr 2018 18:15:31 -0400 Received: from mail-ot0-x22e.google.com ([2607:f8b0:4003:c0f::22e]:40534) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f4Zdp-00055V-9R for emacs-orgmode@gnu.org; Fri, 06 Apr 2018 18:15:29 -0400 Received: by mail-ot0-x22e.google.com with SMTP id j8-v6so2786559ota.7 for ; Fri, 06 Apr 2018 15:15:29 -0700 (PDT) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: "Berry, Charles" , emacs-orgmode Mailinglist --000000000000c11da805693564df Content-Type: text/plain; charset="UTF-8" I guess I need more information. For example, what is C-c C-v v doing exactly? Then C-x C-e? And M-x (symbol-function 'myelsquare) doesn't work. Again, #+name: myelsquare #+header: :var x=0 #+begin_src emacs-lisp :var x=0 (defun myelsquare (x) (* x x)) #+end_src is Lisp code where the last thing should be returned. From library-of-babel.org: #+name: json #+begin_src emacs-lisp :var file='() :var url='() (require 'json) (cond (file (org-babel-with-temp-filebuffer file (goto-char (point-min)) (json-read))) (url (require 'w3m) (with-temp-buffer (w3m-retrieve url) (goto-char (point-min)) (json-read)))) #+end_src And this calling a sample json-containing file gives #+call: json(file="jsontest1") | glossary | (title . example glossary) | (GlossDiv (title . S) (GlossList (GlossEntry (ID . SGML) (SortAs . SGML) (GlossTerm . Standard Generalized Markup Language) (Acronym . SGML) (Abbrev . ISO 8879:1986) (GlossDef (para . A meta-markup language, used to create markup languages such as DocBook.) (GlossSeeAlso . [GML XML])) (GlossSee . markup)))) | which is correct, although not in list form. So again I'm looking at elisp code that is not in the form of a function. So I'm guessing "functions" cannot be #+call'ed, just "headless" elisp code. So what advantage does LOB offer? On Tue, Apr 3, 2018 at 5:39 PM, Berry, Charles wrote: > > > > On Apr 3, 2018, at 1:31 PM, Lawrence Bottorff wrote: > > > > 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, > > > Try > > M-x org-babel-lob-ingest RET org/worg/library-of-babel.org RET > > Don't be a jester, be an ingester. ;-) > > > > so I customized org-babel-lob-files and inserted > .../worg/library-of-babel.el . . . and it did in fact get added to my > init.el under the custom-set-variables: > > > > '(org-babel-lob-files (quote ("~/org/worg/library-of-babel.org"))) > > > > I checked org-babel-library-of-babel variable, and the new things seemed > to be there, although it's rather mind-bending to know I will be calling > LOB code that is internally stored inside of an association list. > > > > Now, in my org file I put this: > > > > #+lob: write(file="jsontest") > > > See (info"(org) Evaluating code blocks") > > The proper idiom is > > #+call: write(file="jsontest") > > Of course, there needs to be a proper 'write' src block in the file you > ingested, etc. > > > > > 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 > > > Is this *verbatim* ? Did you cut and paste everything (including the > trailing `2') all at once? If so, I do not get it. > > I would have expected > > #+RESULTS: > : myelsquare > > which is the correct behavior. > > To see why put point in the myelsquare src block and type C-c C-v v > > then move point to the end of the 'preview' buffer and type C-x C-e. > > Look at the value echo-ed in the minibuffer. > > If it still isn't clear maybe `M-x (symbol-function 'myelsquare)' will > help. > > HTH, > > Chuck > --000000000000c11da805693564df Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I guess I need more information. For example, what is=C2= =A0C-c C-v v doing exactly? Then=C2=A0C-x C-e? And=C2=A0=C2=A0M-x (symbol-f= unction 'myelsquare) doesn't work. Again,=C2=A0

=
#+name: myelsquare
#+header: :var x=3D0
#+begin_sr= c emacs-lisp :var x=3D0
=C2=A0 (defun myelsquare (x)
= =C2=A0 =C2=A0 (* x x))
#+end_src

i= s Lisp code where the last thing should be returned. From library-of-babel.org:

<= div>#+name: json
#+begin_src emacs-lisp :var file=3D'() :var = url=3D'()
=C2=A0 (require 'json)
=C2=A0 (cond
=C2=A0 =C2=A0(file
=C2=A0 =C2=A0 (org-babel-with-temp-fi= lebuffer file
=C2=A0 =C2=A0 =C2=A0 (goto-char (point-min))
<= div>=C2=A0 =C2=A0 =C2=A0 (json-read)))
=C2=A0 =C2=A0(url
=C2=A0 =C2=A0 (require 'w3m)
=C2=A0 =C2=A0 (with-temp-buffe= r
=C2=A0 =C2=A0 =C2=A0 (w3m-retrieve url)
=C2=A0 =C2=A0= =C2=A0 (goto-char (point-min))
=C2=A0 =C2=A0 =C2=A0 (json-read))= ))
#+end_src

And this calling a sa= mple json-containing file gives

#+call: json(file= =3D"jsontest1")

| glossary | (title = . example glossary) | (GlossDiv (title . S) (GlossList (GlossEntry (ID . SG= ML) (SortAs . SGML) (GlossTerm . Standard Generalized Markup Language) (Acr= onym . SGML) (Abbrev . ISO 8879:1986) (GlossDef (para . A meta-markup langu= age, used to create markup languages such as DocBook.) (GlossSeeAlso . [GML= XML])) (GlossSee . markup)))) |

which is corr= ect, although not in list form. So again I'm looking at elisp code that= is not in the form of a function. So I'm guessing "functions"= ; cannot be #+call'ed, just "headless" elisp code. So what ad= vantage does LOB offer?

On Tue, Apr 3, 2018 at 5:39 PM, Berry, Charles <ccberry@= ucsd.edu> wrote:


> On Apr 3, 2018, at 1:31 PM, Lawrence Bottorff <borgauf@gmail.com> wrote:
>
> I've been trying to grok LOB again. So I've cloned the worg gi= t and library-of-babel.el is one of the files. org-babel-lob-injest didn= 9;t work,


Try

M-x org-babel-lob-ingest RET org/worg/library-of-babel.org RET

Don't be a jester, be an ingester. ;-)


> so I customized org-babel-lob-files and inserted .../worg/library-of-b= abel.el . . . and it did in fact get added to my init.el under the custom-s= et-variables:
>
>=C2=A0 '(org-babel-lob-files (quote ("~/org/worg/library-of-= babel.org")))
>
> I checked org-babel-library-of-babel variable, and the new things seem= ed to be there, although it's rather mind-bending to know I will be cal= ling LOB code that is internally stored inside of an association list.
>
> Now, in my org file I put this:
>
> #+lob: write(file=3D"jsontest")


See (info"(org) Evaluating code blocks")

The proper idiom is

=C2=A0 =C2=A0 =C2=A0 =C2=A0 #+call: write(file=3D"jsontest")

Of course, there needs to be a proper 'write' src block in the file= you ingested, etc.

>
> and try C-c C-c on it. Nothing. My minibuffer says "local setup h= as 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=3D0
> #+begin_src emacs-lisp
>=C2=A0 =C2=A0(* x x)
> #+end_src
>
> #+call: myelsquare(x=3D6)
>
> #+RESULTS:
> : 36
>
> but this results in
>
> #+name: myelsquare
> #+header: :var x=3D0
> #+begin_src emacs-lisp
>=C2=A0 =C2=A0(defun myelsquare (x)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0(* x x))
> #+end_src
>
> #+call: myelsquare(x=3D6)
>
> #+RESULTS:
> : myelsquare2


Is this *verbatim* ? Did you cut and paste everything (including the= trailing `2') all at once? If so, I do not get it.

I would have expected

#+RESULTS:
: myelsquare

=C2=A0which is the correct behavior.

To see why put point in the myelsquare src block and type C-c C-v v

then move point to the end of the 'preview' buffer and type C-x C-e= .

Look at the value echo-ed in the minibuffer.

If it still isn't clear maybe `M-x (symbol-function 'myelsquare)= 9; will help.

HTH,

Chuck

--000000000000c11da805693564df--