emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Lawrence Bottorff <borgauf@gmail.com>
To: "Berry, Charles" <ccberry@ucsd.edu>,
	emacs-orgmode Mailinglist <emacs-orgmode@gnu.org>
Subject: Re: Library of Babel confusion
Date: Fri, 6 Apr 2018 18:15:27 -0400	[thread overview]
Message-ID: <CAFAhFSVqVLBeou_iGFNpUTPSyk+q60vw2R-YM2SBDF-DXqw5zg@mail.gmail.com> (raw)
In-Reply-To: <A8CC22B9-21A7-4C40-B182-1424C60C05DC@ucsd.edu>

[-- Attachment #1: Type: text/plain, Size: 3654 bytes --]

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 <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 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
>

[-- Attachment #2: Type: text/html, Size: 5233 bytes --]

  reply	other threads:[~2018-04-06 22:15 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-03 20:31 Library of Babel confusion Lawrence Bottorff
2018-04-03 20:44 ` Nicolas Goaziou
2018-04-04 22:52   ` Lawrence Bottorff
2018-04-03 21:39 ` Berry, Charles
2018-04-06 22:15   ` Lawrence Bottorff [this message]
2018-04-06 23:59     ` Thomas S. Dye
2018-04-07  2:38       ` Berry, Charles
2018-04-10 18:55         ` Lawrence Bottorff
2018-04-10 19:26           ` Thomas S. Dye
2018-04-11 13:29             ` Lawrence Bottorff
2018-04-11 16:57               ` Thomas S. Dye
2018-04-11 18:20               ` Berry, Charles

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFAhFSVqVLBeou_iGFNpUTPSyk+q60vw2R-YM2SBDF-DXqw5zg@mail.gmail.com \
    --to=borgauf@gmail.com \
    --cc=ccberry@ucsd.edu \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).