emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Michael Welle <mwe012008@gmx.net>
To: emacs-orgmode@gnu.org
Subject: Re: Concatenating Org property values from parent subtrees
Date: Sat, 29 Sep 2018 21:23:30 +0200	[thread overview]
Message-ID: <87k1n42jm5.fsf@luisa.c0t0d0s0.de> (raw)
In-Reply-To: <CAFyQvY3ZQ2GtxoHuR_te4iO0wWSQUeWUCbS1ofLfMnYrFjXhvg@mail.gmail.com> (Kaushal Modi's message of "Sat, 29 Sep 2018 15:01:26 -0400")

Hello,


Kaushal Modi <kaushal.modi@gmail.com> writes:

> On Sat, Sep 29, 2018 at 2:39 PM Michael Welle <mwe012008@gmx.net> wrote:
>
>>
>> I asked something similar earlier this year (concatenating compiler
>> flags given as header-args property, used for linking against different
>> libs in different sections of the Org file). I ended with a function
>> that grabs the current property value and returns the value concatenated
>> with new value. That function can be used as a 'property value'. That's
>> not a nice and bullet proof solution, but works good enough to me to
>> generate the solutions to the psets for the lecture.
>>
>
> Please share it if you don't mind. I plan to use it or its derivative in
> ox-hugo. The property is planned to be a path property, and with nested
> property values of "a","b" and "c", which I want to parse as "a/b/c".


(defun hmw/org-prop-append(prop value)
  (save-excursion
  (org-up-heading-safe)
  (format "%s %s" value (cdr (assq prop
                                   (car (org-babel-params-from-properties)))))))

(defalias 'A 'hmw/org-prop-append)


I use it like this:


* foo
 :PROPERTIES:
 :header-args: :flags -Wall
 :END:

** bar
#+begin_src C :flags (A :flags "-lm")
#+end_src

** baz
 :PROPERTIES:
 :header-args: :flags (A :flags "-lcunit")
 :END:

#+begin_src C
#+end_src


Regards
hmw

  reply	other threads:[~2018-09-29 19:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-26 22:57 Concatenating Org property values from parent subtrees Kaushal Modi
2018-09-29 18:38 ` Michael Welle
2018-09-29 19:01   ` Kaushal Modi
2018-09-29 19:23     ` Michael Welle [this message]
2018-09-29 19:26       ` Michael Welle
2018-10-01 15:47         ` Ihor Radchenko
2018-10-01 21:00           ` Kaushal Modi

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=87k1n42jm5.fsf@luisa.c0t0d0s0.de \
    --to=mwe012008@gmx.net \
    --cc=emacs-orgmode@gnu.org \
    /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).