* Passing values by reference to src-blocks
@ 2014-06-25 1:26 Thorsten Jolitz
2014-06-25 3:01 ` Eric Schulte
2014-06-25 3:12 ` Thorsten Jolitz
0 siblings, 2 replies; 4+ messages in thread
From: Thorsten Jolitz @ 2014-06-25 1:26 UTC (permalink / raw)
To: emacs-orgmode
Hi List,
this does not work, although I would think it should (at least if there
is no typo or so):
,----
| #+name: project-root
| #+header: :var buf-file=(buffer-file-name)
| #+begin_src emacs-lisp
| (file-name-directory
| (directory-file-name
| (file-name-directory buf-file)))
| #+end_src
`----
#+results: project-root
: /home/tj/News/drafts/
,----
| #+name: project-name
| #+header: :exports none
| #+header: :var root-dir=project-root(buf-file=(buffer-file-name))
| #+begin_src emacs-lisp
| (mapconcat
| 'capitalize
| (split-string
| (file-name-nondirectory root-dir)
| "-" 'OMIT-NULLS)
| " ")
| #+end_src
`----
#+results: project-name
Wrong usage of :var or limitations of header arguments?
--
cheers,
Thorsten
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Passing values by reference to src-blocks
2014-06-25 1:26 Passing values by reference to src-blocks Thorsten Jolitz
@ 2014-06-25 3:01 ` Eric Schulte
2014-06-25 3:38 ` Thorsten Jolitz
2014-06-25 3:12 ` Thorsten Jolitz
1 sibling, 1 reply; 4+ messages in thread
From: Eric Schulte @ 2014-06-25 3:01 UTC (permalink / raw)
To: Thorsten Jolitz; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 277 bytes --]
Thorsten Jolitz <tjolitz@gmail.com> writes:
> Hi List,
>
> this does not work, although I would think it should (at least if there
> is no typo or so):
>
I think everything is doing what it is supposed to from an Org-mode
perspective, see below (with different functions).
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: example.org --]
[-- Type: text/x-org, Size: 380 bytes --]
#+name: plus-foo
#+header: :var buf-file=(buffer-file-name)
#+begin_src emacs-lisp
(concat buf-file "+foo")
#+end_src
#+RESULTS: plus-foo
: /tmp/example.org+foo
#+name: project-name
#+header: :exports none
#+header: :var root-dir=plus-foo(buf-file=(buffer-file-name))
#+begin_src emacs-lisp
(concat root-dir "+bar")
#+end_src
#+RESULTS: project-name
: /tmp/example.org+foo+bar
[-- Attachment #3: Type: text/plain, Size: 1165 bytes --]
>
> ,----
> | #+name: project-root
> | #+header: :var buf-file=(buffer-file-name)
> | #+begin_src emacs-lisp
> | (file-name-directory
> | (directory-file-name
> | (file-name-directory buf-file)))
> | #+end_src
> `----
>
> #+results: project-root
> : /home/tj/News/drafts/
>
> ,----
> | #+name: project-name
> | #+header: :exports none
> | #+header: :var root-dir=project-root(buf-file=(buffer-file-name))
> | #+begin_src emacs-lisp
> | (mapconcat
> | 'capitalize
> | (split-string
> | (file-name-nondirectory root-dir)
> | "-" 'OMIT-NULLS)
> | " ")
> | #+end_src
> `----
>
> #+results: project-name
>
> Wrong usage of :var or limitations of header arguments?
This is to be expected. The two blocks above compose to something like
#+begin_src emacs-lisp
(file-name-nondirectory
(file-name-directory
(directory-file-name
(file-name-directory
(buffer-file-name)))))
#+end_src
Calling `file-name-nondirectory' on the results of `file-name-directory'
seems like it should give you an empty string.
Best,
--
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Passing values by reference to src-blocks
2014-06-25 1:26 Passing values by reference to src-blocks Thorsten Jolitz
2014-06-25 3:01 ` Eric Schulte
@ 2014-06-25 3:12 ` Thorsten Jolitz
1 sibling, 0 replies; 4+ messages in thread
From: Thorsten Jolitz @ 2014-06-25 3:12 UTC (permalink / raw)
To: emacs-orgmode
Thorsten Jolitz <tjolitz@gmail.com> writes:
> Hi List,
>
> this does not work, although I would think it should (at least if there
> is no typo or so):
>
> ,----
> | #+name: project-root
> | #+header: :var buf-file=(buffer-file-name)
> | #+begin_src emacs-lisp
> | (file-name-directory
> | (directory-file-name
> | (file-name-directory buf-file)))
> | #+end_src
> `----
>
> #+results: project-root
> : /home/tj/News/drafts/
>
> ,----
> | #+name: project-name
> | #+header: :exports none
> | #+header: :var root-dir=project-root(buf-file=(buffer-file-name))
> | #+begin_src emacs-lisp
> | (mapconcat
> | 'capitalize
> | (split-string
> | (file-name-nondirectory root-dir)
> | "-" 'OMIT-NULLS)
> | " ")
> | #+end_src
> `----
>
> #+results: project-name
>
> Wrong usage of :var or limitations of header arguments?
This works
,----
| #+name: project-root
| #+header: :var buf-file=(buffer-file-name)
| #+begin_src emacs-lisp
| (file-name-directory
| (directory-file-name
| (file-name-directory buf-file)))
| #+end_src
|
| #+name: project-name
| #+header: :exports none
| #+header: :var root=project-root
| #+begin_src emacs-lisp
| (mapconcat
| 'capitalize
| (split-string
| (file-name-nondirectory
| (directory-file-name root))
| "-" 'OMIT-NULLS)
| " ")
| #+end_src
`----
so it was just wrong usage ... sorry for the noise
--
cheers,
Thorsten
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Passing values by reference to src-blocks
2014-06-25 3:01 ` Eric Schulte
@ 2014-06-25 3:38 ` Thorsten Jolitz
0 siblings, 0 replies; 4+ messages in thread
From: Thorsten Jolitz @ 2014-06-25 3:38 UTC (permalink / raw)
To: emacs-orgmode
Eric Schulte <schulte.eric@gmail.com> writes:
>> Wrong usage of :var or limitations of header arguments?
>
> This is to be expected. The two blocks above compose to something like
>
> #+begin_src emacs-lisp
> (file-name-nondirectory
> (file-name-directory
> (directory-file-name
> (file-name-directory
> (buffer-file-name)))))
> #+end_src
>
> Calling `file-name-nondirectory' on the results of `file-name-directory'
> seems like it should give you an empty string.
Yes, I figured that out myself before I saw your post, there was a
mistake in my code.
Thanks anyway.
--
cheers,
Thorsten
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-06-25 3:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-25 1:26 Passing values by reference to src-blocks Thorsten Jolitz
2014-06-25 3:01 ` Eric Schulte
2014-06-25 3:38 ` Thorsten Jolitz
2014-06-25 3:12 ` Thorsten Jolitz
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).