From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rasmus Subject: Re: merge trees? Date: Thu, 03 Sep 2015 20:44:38 +0200 Message-ID: <877fo7s5pl.fsf@gmx.us> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46499) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXZVO-0001dl-Lf for emacs-orgmode@gnu.org; Thu, 03 Sep 2015 14:45:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXZVJ-0006eN-ML for emacs-orgmode@gnu.org; Thu, 03 Sep 2015 14:45:02 -0400 Received: from plane.gmane.org ([80.91.229.3]:55939) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXZVJ-0006e7-Br for emacs-orgmode@gnu.org; Thu, 03 Sep 2015 14:44:57 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1ZXZV6-0007NB-Ed for emacs-orgmode@gnu.org; Thu, 03 Sep 2015 20:44:54 +0200 Received: from 62.80.108.13 ([62.80.108.13]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 03 Sep 2015 20:44:44 +0200 Received: from rasmus by 62.80.108.13 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 03 Sep 2015 20:44:44 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Matt Price 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. . .