[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] Passing values by reference to src-blocks
From: |
Eric Schulte |
Subject: |
Re: [O] Passing values by reference to src-blocks |
Date: |
Tue, 24 Jun 2014 23:01:25 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
Thorsten Jolitz <address@hidden> 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).
#+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
>
> ,----
> | #+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)