emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Concatenate properties


From: Tyler Grinn
Subject: Re: Concatenate properties
Date: Sat, 07 May 2022 10:09:25 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

John Kitchin <jkitchin@andrew.cmu.edu> writes:

> Where did you add that?
>
> John
>
> -----------------------------------
> Professor John Kitchin (he/him/his)
> Doherty Hall A207F
> Department of Chemical Engineering
> Carnegie Mellon University
> Pittsburgh, PA 15213
> 412-268-7803
> @johnkitchin
> http://kitchingroup.cheme.cmu.edu
>
> On Fri, May 6, 2022 at 11:40 AM Tyler Grinn <tylergrinn@gmail.com>
> wrote:
>
>     Thanks for the advice. I've added the caret symbol
>     (:EXPORT_FILE_NAME^:
>     assignment-1) to mean 'concatenate' as opposed to + for 'joining'.
>     If
>     this is something the community would want I will clean it up and
>     send
>     in a patch.

I modified 'org--property-local-values' to return a cons list with the
car being the value of the property and the cdr being either 'concat or
'join.

        ;; Find additional values.
        (let* ((property-extension (org-re-property
                                    (concat (regexp-quote property)
                                            "[+^]")
                                    t t)))
          (while (re-search-forward property-extension end t)
            (push (cons (match-string-no-properties 3)
                        (if (string-match-p "\\^\\'" 
(match-string-no-properties 2))
                            'concat
                          'join))
                  value)))

    I used a single re-search in order to maintain the ordering of
    properties, ie:
    
        :PROP: he
        :PROP^: llo
        :PROP+: world
    
    produces 'hello world'

I then updated both 'org-entry-get' and
'org-entry-get-with-inheritance' to 'cl-reduce' the cons list into the
final string value.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]