[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] Library of Babel confusion
From: |
Berry, Charles |
Subject: |
Re: [O] Library of Babel confusion |
Date: |
Sat, 7 Apr 2018 02:38:23 +0000 |
> On Apr 6, 2018, at 4:59 PM, Thomas S. Dye <address@hidden> 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
- [O] Library of Babel confusion, Lawrence Bottorff, 2018/04/03
- Re: [O] Library of Babel confusion, Berry, Charles, 2018/04/03
- Re: [O] Library of Babel confusion, Lawrence Bottorff, 2018/04/06
- Re: [O] Library of Babel confusion, Thomas S. Dye, 2018/04/06
- Re: [O] Library of Babel confusion,
Berry, Charles <=
- Re: [O] Library of Babel confusion, Lawrence Bottorff, 2018/04/10
- Re: [O] Library of Babel confusion, Thomas S. Dye, 2018/04/11
- Re: [O] Library of Babel confusion, Lawrence Bottorff, 2018/04/11
- Re: [O] Library of Babel confusion, Berry, Charles, 2018/04/11
- Re: [O] Library of Babel confusion, Thomas S. Dye, 2018/04/11
Re: [O] Library of Babel confusion, Nicolas Goaziou, 2018/04/04