* Noweb: Same function, two string results differ one with double-quotes the other without
@ 2015-09-12 1:41 Grant Rettke
2016-01-31 8:30 ` [babel] is there a chance to split arguments in src block calls or noweb syntax O.Hamann
0 siblings, 1 reply; 4+ messages in thread
From: Grant Rettke @ 2015-09-12 1:41 UTC (permalink / raw)
To: emacs-orgmode@gnu.org
Good evening,
I am studying Noweb-Ref usage. I set up this example:
;; ✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂
#+begin_src emacs-lisp :tangle "test.el" :results value table drawer
replace :noweb yes
(let ((a <<ucase("hEllO, yOU.")>>)
(b <<ucase(emacs-lisp-data)>>))
(list a
(type-of a)
b
(type-of b)))
#+end_src
#+RESULTS:
:RESULTS:
| HELLO, YOU. | string | "HELLO, WORLD." | string |
:END:
#+name: ucase
#+begin_src emacs-lisp :var x="WeAthEr" :results value scalar drawer replace
(upcase x)
#+end_src
#+RESULTS: ucase
:RESULTS:
"WEATHER"
:END:
#+name: emacs-lisp-data
#+begin_src emacs-lisp :results value scalar drawer replace
"Hello, world."
#+end_src
#+RESULTS: emacs-lisp-data
:RESULTS:
"Hello, world."
:END:
;; ✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂
Then I executed each source block.
I was expecting as a result of the first source block to be a list
containing 4 items: double-quoted string, symbol,
double-quoted-string, symbol. Instead what I got was the first string
was not double quoted and the second was. Why doesn't the first value
have double quotes and the third value does have them? The scalar
values return the string and output with double quotes in the last two
source blocks.
Here is how I set up this ECM.
Emacs version: "GNU Emacs 24.4.1 (x86_64-apple-darwin13.4.0, NS
apple-appkit-1265.21)\n of 2015-03-16 on orion"
Org-Mode: "8.3.1" from Git at commit 8c85c990521cc833df9179894f6f8b2934d2231a
Updated autoloads.
I use a ECM startup file to start emacs and org mode for ECMS like this:
=open /Applications/Emacs.app --args --quick --load
~/src/help/.org-mode-ecm.emacs.el= which contains
;; ✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂
;; -*- lexical-binding: t -*-
(setq load-prefer-newer t)
(add-to-list 'load-path "~/src/org-mode/lisp")
(add-to-list 'load-path "~/src/org-mode/contrib/lisp")
(setq org-list-allow-alphabetical t)
(setq org-enforce-todo-checkbox-dependencies t)
(require 'org)
;; ✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂
^ permalink raw reply [flat|nested] 4+ messages in thread
* [babel] is there a chance to split arguments in src block calls or noweb syntax
2015-09-12 1:41 Noweb: Same function, two string results differ one with double-quotes the other without Grant Rettke
@ 2016-01-31 8:30 ` O.Hamann
2016-01-31 19:34 ` Charles C. Berry
0 siblings, 1 reply; 4+ messages in thread
From: O.Hamann @ 2016-01-31 8:30 UTC (permalink / raw)
To: emacs-orgmode
Hi all,
Splitting header arguments for source blocks into different lines works
very fine,
(and leads one to put more and more args in the header... )
Is there a chance or trick to do similarly when calling such src blocks?
Somehow like in shell scripts a backslash at the end of a line will
signal continuation?
(example see below)
Any suggestions or workarounds or best-practices to make the call lines
better readable and editable are welcome!
Kind regards,
Olaf
What I mean:
#+NAME: namedSrcBlock
#+HEADER: :var arg1="val for arg1"
#+HEADER: :var arg2="val for arg2"
...
#+HEADER: :var argN="val for argN"
#+BEGIN_SRC
...
#+END_SRC
results in long call lines for #CALL: or noweb syntax hard to edit
#+CALL: namedSrcBlock(arg1="long argument value",arg2="even longer
argument value",...,argN="many args later ")
<<namedSrcBlock(arg1="....",....,argN="...")>>
How to split those long lines, so that each arg-value pair stands on its
own line?
The 'orgish' way would be sth like this, I guess:
#+CALL namedSrcBlock
#+ARGS: :arg arg1="..:"
#+ARGS: :arg arg2="..."
#+CALL_END
in noweb ref might be
<<namedSrcBlock(arg1="long argument value",\\SPACE
arg2="even longer argument value",\\SPACE
... \\SPACE
argN="many args later")>>
But I did not find such anywhere.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [babel] is there a chance to split arguments in src block calls or noweb syntax
2016-01-31 8:30 ` [babel] is there a chance to split arguments in src block calls or noweb syntax O.Hamann
@ 2016-01-31 19:34 ` Charles C. Berry
2016-02-05 7:49 ` O.Hamann
0 siblings, 1 reply; 4+ messages in thread
From: Charles C. Berry @ 2016-01-31 19:34 UTC (permalink / raw)
To: O.Hamann; +Cc: emacs-orgmode
On Sun, 31 Jan 2016, O.Hamann wrote:
> Hi all,
>
> Splitting header arguments for source blocks into different lines works very
> fine,
> (and leads one to put more and more args in the header... )
>
> Is there a chance or trick to do similarly when calling such src blocks?
> Somehow like in shell scripts a backslash at the end of a line will signal
> continuation?
> (example see below)
>
> Any suggestions or workarounds or best-practices to make the call lines
> better readable and editable are welcome!
>
> Kind regards,
>
> Olaf
>
Try using a custom babel language. Then using variable assignment from
babel block.
Here I define `fundamental' as a language, which means I can edit src
blocks like `lorem' in a src edit buffer in fundamental mode without
needing to do more than execute the `define-fundamental-as-babel' block or
put that defun in my .emacs. And when I execute the lorem block - as when
it is used in `:var txt=lorem()' - it returns the body as a string.
#+NAME: define-fundamental-as-babel
#+BEGIN_SRC emacs-lisp
(defun org-babel-execute:fundamental (body params)
(format "%s" body))
#+END_SRC
#+NAME: lorem
#+BEGIN_SRC fundamental
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
#+END_SRC
#+NAME: abc
#+BEGIN_SRC emacs-lisp :results value :var txt="A B C"
(concat "txt-->" txt "<--txt")
#+END_SRC
#+CALL: abc( lorem() ) :results raw :wrap EXAMPLE
#+RESULTS:
#+BEGIN_EXAMPLE
txt-->Lorem ipsum dolor sit amet, consectetuer adipiscing elit.<--txt
#+END_EXAMPLE
BTW, there is already `org-babel-execute:latex', which is very handy for
editing LaTeX and then handing it to a src block for further processing.
HTH,
Chuck
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [babel] is there a chance to split arguments in src block calls or noweb syntax
2016-01-31 19:34 ` Charles C. Berry
@ 2016-02-05 7:49 ` O.Hamann
0 siblings, 0 replies; 4+ messages in thread
From: O.Hamann @ 2016-02-05 7:49 UTC (permalink / raw)
To: Charles C. Berry; +Cc: emacs-orgmode
Thank you very much for your answer, Chuck!
Your tip to use fundamental mode as an org-executable language was very
useful to me,
thank you very much for your effort to explain the functionality.
At the end, my question was best resolved for me by calling the params
as indexed variable values,
like this:
Instead of calling
#+CALL: namedSrcBlock(arg1="long argument value",arg2="even longer
argument value",...,argN="many args later ")
I created a named table with the argument values
#+NAME: params
|arg1| long argument value|
|arg2| even longer argument value|
...
|argN| many args later|
and called like this:
#+CALL:
namedSrcBlock(arg1=params[0,1],arg2=params[1,1],...,argN=params[N-1,1])
That makes the call line short and the arguments are presented well
readable nearest to the call.
On 31.01.2016 20:34, Charles C. Berry wrote:
> On Sun, 31 Jan 2016, O.Hamann wrote:
>
>> Hi all,
>>
>> Splitting header arguments for source blocks into different lines
>> works very fine,
>> (and leads one to put more and more args in the header... )
>>
>> Is there a chance or trick to do similarly when calling such src blocks?
>> Somehow like in shell scripts a backslash at the end of a line will
>> signal continuation?
>> (example see below)
>>
>> Any suggestions or workarounds or best-practices to make the call
>> lines better readable and editable are welcome!
>>
>> Kind regards,
>>
>> Olaf
>>
>
> Try using a custom babel language. Then using variable assignment from
> babel block.
>
> Here I define `fundamental' as a language, which means I can edit src
> blocks like `lorem' in a src edit buffer in fundamental mode without
> needing to do more than execute the `define-fundamental-as-babel'
> block or put that defun in my .emacs. And when I execute the lorem
> block - as when it is used in `:var txt=lorem()' - it returns the body
> as a string.
>
>
> #+NAME: define-fundamental-as-babel
> #+BEGIN_SRC emacs-lisp
> (defun org-babel-execute:fundamental (body params)
> (format "%s" body))
> #+END_SRC
>
> #+NAME: lorem
> #+BEGIN_SRC fundamental
> Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
> #+END_SRC
>
> #+NAME: abc
> #+BEGIN_SRC emacs-lisp :results value :var txt="A B C"
> (concat "txt-->" txt "<--txt")
> #+END_SRC
>
> #+CALL: abc( lorem() ) :results raw :wrap EXAMPLE
>
> #+RESULTS:
> #+BEGIN_EXAMPLE
> txt-->Lorem ipsum dolor sit amet, consectetuer adipiscing elit.<--txt
> #+END_EXAMPLE
>
>
> BTW, there is already `org-babel-execute:latex', which is very handy
> for editing LaTeX and then handing it to a src block for further
> processing.
>
> HTH,
>
> Chuck
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-02-05 7:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-12 1:41 Noweb: Same function, two string results differ one with double-quotes the other without Grant Rettke
2016-01-31 8:30 ` [babel] is there a chance to split arguments in src block calls or noweb syntax O.Hamann
2016-01-31 19:34 ` Charles C. Berry
2016-02-05 7:49 ` O.Hamann
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).