From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Thomas S. Dye" Subject: Re: Library of Babel confusion Date: Fri, 06 Apr 2018 13:59:05 -1000 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; format=flowed Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:36415) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f4bGl-0005jM-M0 for emacs-orgmode@gnu.org; Fri, 06 Apr 2018 19:59:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f4bGi-0008Db-Jt for emacs-orgmode@gnu.org; Fri, 06 Apr 2018 19:59:47 -0400 Received: from gproxy3-pub.mail.unifiedlayer.com ([69.89.30.42]:44289) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f4bGi-00080p-Be for emacs-orgmode@gnu.org; Fri, 06 Apr 2018 19:59:44 -0400 Received: from CMOut01 (unknown [10.0.90.82]) by gproxy3.mail.unifiedlayer.com (Postfix) with ESMTP id A75DC402BE for ; Fri, 6 Apr 2018 17:59:23 -0600 (MDT) 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: Lawrence Bottorff Cc: emacs-orgmode Mailinglist , "Berry, Charles" Aloha Lawrence, #+name: myelsquare #+header: :var x=0 #+begin_src emacs-lisp :var x=0 (defun myelsquare (x) (* x x)) #+end_src #+RESULTS: myelsquare : myelsquare Assuming myelsquare has been evaluated: #+name: eval-myelsquare #+header: :var y=2 #+BEGIN_SRC emacs-lisp (myelsquare y) #+END_SRC #+RESULTS: eval-myelsquare : 4 #+call: eval-myelsquare(3) #+RESULTS: : 9 hth, Tom Lawrence Bottorff writes: > 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 >> -- Thomas S. Dye http://www.tsdye.com