From: "Berry, Charles" <ccberry@ucsd.edu>
To: "Thomas S. Dye" <tsd@tsdye.com>
Cc: emacs-orgmode Mailinglist <emacs-orgmode@gnu.org>,
Lawrence Bottorff <borgauf@gmail.com>
Subject: Re: Library of Babel confusion
Date: Sat, 7 Apr 2018 02:38:23 +0000 [thread overview]
Message-ID: <D06008F2-0BF1-4EDD-8BF7-D91CDA4D99ED@ucsd.edu> (raw)
In-Reply-To: <m2fu47ubsm.fsf@tsdye.com>
> On Apr 6, 2018, at 4:59 PM, Thomas S. Dye <tsd@tsdye.com> wrote:
>
[Tom's response covering the main issues deleted]
> 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.
`C-h k' is really your friend here. If you do not know it, try typing it twice `C-h k C-h k'.
As for the specific keystrokes mentioned above:
,----[ C-h k C-c C-v v ]
| C-c C-v v runs the command org-babel-expand-src-block (found in
| org-mode-map), which is an interactive autoloaded compiled Lisp
| function in ‘ob-core.el’.
|
| It is bound to C-c C-v v, C-c C-v C-v.
|
| (org-babel-expand-src-block &optional ARG INFO PARAMS)
|
| Expand the current source code block.
| Expand according to the source code block’s header
| arguments and pop open the results in a preview buffer.
|
| [back]
`----
In your case, it shows that the `mtelsquare' src block expands to:
,----
| (let ((x (quote 0)))
| (defun myelsquare (x)
| (* x x))
| )
`----
,----[ C-h k C-x C-e ]
| C-x C-e runs the command eval-last-sexp (found in global-map), which
| is an interactive compiled Lisp function in ‘elisp-mode.el’.
|
| It is bound to C-x C-e.
|
| (eval-last-sexp EVAL-LAST-SEXP-ARG-INTERNAL)
|
| Evaluate sexp before point; print value in the echo area.
| Interactively, with prefix argument, print output into current buffer.
|
| Normally, this function truncates long output according to the value
| of the variables ‘eval-expression-print-length’ and
| ‘eval-expression-print-level’. With a prefix argument of zero,
| however, there is no such truncation. Such a prefix argument
| also causes integers to be printed in several additional formats
| (octal, hexadecimal, and character).
|
| If ‘eval-expression-debug-on-error’ is non-nil, which is the default,
| this command arranges for all errors to enter the debugger.
|
| [back]
`----
So with point at the end of the preview buffer for myelsquare (which has one `let' expression it it) it has the same effect as running `eval-buffer'. viz, the elisp function `myelsquare' is created.
If you have gotten this far, there is an lisp function called `myelsquare' and the `symbol-function' expression will return its value when properly `eval'ed. I misspoke before. I should have said
M-: (symbol-function 'myelsquare) RET
And that value is `(lambda (x) (* x x))'. Which simply shows you have defun'ed a function and what it is.
Once you have an elisp function, the natural way to call it is src_emacs-lisp{(myelsquare 1.5)}.
One thing you can do with LOB blocks is use them in header args of src blocks just as you would use calls to ordinary src blocks.
HTH,
Chuck
next prev parent reply other threads:[~2018-04-07 2:38 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
2018-04-06 23:59 ` Thomas S. Dye
2018-04-07 2:38 ` Berry, Charles [this message]
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=D06008F2-0BF1-4EDD-8BF7-D91CDA4D99ED@ucsd.edu \
--to=ccberry@ucsd.edu \
--cc=borgauf@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=tsd@tsdye.com \
/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).