[Top][All Lists]

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

Re: [O] merge trees?

From: Rasmus
Subject: Re: [O] merge trees?
Date: Thu, 03 Sep 2015 20:44:38 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

Matt Price <address@hidden> writes:

> * Topics
> ** Introduction
> ** Crowds and Publics
> ** Spatial History
> * Labs
> ** Intro to HTML
> ** Styling with CSS
> ** The Google Maps Javascript API
> The two subtrees can be manipulated independently, then merged to create
> something like:
> * Schedule
> ** <2015-09-15>
> *** Seminar: Introduction
> *** Lab: Intro to HTML

You should probably use a key for matching.  Otherwise I can promise you
it will get messy (it seems you want to match based on the location in the

> Is there an easy way to do this already? Or is the best thing to do to
> write a piece of elisp that generates the appropriate structure using
> org-element, and put that code in a babel block?

Probably the best way might be a custom exporter.  ox-koma-script collects
"special headlines" and insert them later.  You could do the same.

> And if the latter, does anyone, um, want to write the code for me?

Sounds like the job of a personal, underpaid slav...  TA!

You can cook some more on this.

     * topics
     ** Intro
     :outline_class: 1
     <2015-09-03 jue>
     Intro text
     ** can I has czz?
     :outline_class: 2
     <2015-09-05 sáb>
     * labs
     :outline_prefix: Lab
     ** intro to html
     :outline_class: 1

     ** lab 
     :outline_class: 2
     * magic 

     #+BEGIN_SRC emacs-lisp
       (let* ((parse-tree (org-element-parse-buffer))
              (classes (delete-duplicates (org-element-map parse-tree 'headline
                                            (lambda (h) 
                                          :test 'equal))
              (times (org-element-map (org-element-parse-buffer) 'timestamp
                       (lambda (time)
                         (list (org-export-get-node-property :OUTLINE_CLASS 
time t) 
                               (org-element-property :raw-value time))
              (dataz (mapcar (lambda (class)
                               (list :class class
                                     :schedule (cadr (assoc class times))
                                     :heads (delq nil
                                                  (org-element-map parse-tree 
                                                    (lambda (h) (and (equal 
(org-element-property :OUTLINE_CLASS h))
         (with-temp-file "/tmp/outline.org"
           (insert "* schedule\n")
           (mapc (lambda (data)
                   (insert "** " (plist-get data :schedule) "\n")
                   ;; Here you could add sorting to get it in the desired order.
                   (insert (mapconcat 'org-element-interpret-data 
                                       ;; You could add prefixes and so forth
                                       ;; using the outline-prefix property
                                       (lambda (h) (let ((l 
(org-element-property :level h)))
                                                (org-element-put-property h 
:level (1+ l))))
                                       (plist-get data :heads))


I hear there's rumors on the, uh, Internets. . .

reply via email to

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