all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Rasmus <rasmus@gmx.us>
To: emacs-orgmode@gnu.org
Subject: Re: merge trees?
Date: Thu, 03 Sep 2015 20:44:38 +0200	[thread overview]
Message-ID: <877fo7s5pl.fsf@gmx.us> (raw)
In-Reply-To: CAN_Dec_ZwM6cThjvzwEEXy7KVf8=FUf82NHQ+FWPr+fQeqCr+w@mail.gmail.com

Matt Price <moptop99@gmail.com> 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
three).

> 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
     :PROPERTIES:
     :outline_prefix:
     :END:
     ** Intro
     :PROPERTIES:
     :outline_class: 1
     :END:
     <2015-09-03 jue>
     Intro text
     ** can I has czz?
     :PROPERTIES:
     :outline_class: 2
     :END:
     <2015-09-05 sáb>
     x
     * labs
     :PROPERTIES:
     :outline_prefix: Lab
     :END:
     ** intro to html
     :PROPERTIES:
     :outline_class: 1
     :END:

     ** lab 
     :PROPERTIES:
     :outline_class: 2
     :END:
     * magic 

     #+BEGIN_SRC emacs-lisp
       (let* ((parse-tree (org-element-parse-buffer))
              (classes (delete-duplicates (org-element-map parse-tree 'headline
                                            (lambda (h) 
                                              (org-element-property :OUTLINE_CLASS 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 'headline
                                                    (lambda (h) (and (equal class
                                                                       (org-element-property :OUTLINE_CLASS h))
                                                                h))))))
                             classes)))
         (with-temp-file "/tmp/outline.org"
           (erase-buffer)
           (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 
                                      (mapcar
                                       ;; 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))
                                      "\n")))
                 dataz)))

     #+END_SRC



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

      parent reply	other threads:[~2015-09-03 18:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-03 17:07 merge trees? Matt Price
2015-09-03 17:48 ` Thomas S. Dye
2015-09-03 18:31   ` Matt Price
2015-09-03 19:15     ` Thomas S. Dye
2015-09-03 18:44 ` Rasmus [this message]

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877fo7s5pl.fsf@gmx.us \
    --to=rasmus@gmx.us \
    --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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.