From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: how to print org-element of type paragraph as a string? Date: Mon, 09 Dec 2013 20:08:51 -0500 Message-ID: <87vbyxwlzw.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:44038) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VqBp6-0006sd-Dv for emacs-orgmode@gnu.org; Mon, 09 Dec 2013 20:09:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VqBoz-00019U-4x for emacs-orgmode@gnu.org; Mon, 09 Dec 2013 20:09:16 -0500 Received: from plane.gmane.org ([80.91.229.3]:33176) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VqBoy-00018u-UJ for emacs-orgmode@gnu.org; Mon, 09 Dec 2013 20:09:09 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1VqBot-0007jM-1T for emacs-orgmode@gnu.org; Tue, 10 Dec 2013 02:09:03 +0100 Received: from pool-98-110-175-184.bstnma.fios.verizon.net ([98.110.175.184]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 10 Dec 2013 02:09:03 +0100 Received: from ndokos by pool-98-110-175-184.bstnma.fios.verizon.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 10 Dec 2013 02:09:03 +0100 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 Myles English writes: > Hello, > > This should be an easy question for someone. Given the org file > content below, how would you get the result or the source block to be > "here are the contents"? > > Thanks, > Myles > > * heading > here are the contents > > #+begin_src elisp :results output > (dolist > (job (org-element-map (org-element-parse-buffer) 'paragraph 'identity)) > (print (car (org-element-contents job)))) > #+end_src > > #+RESULTS: > : > : #("here are the contents > : " 0 22 (:parent (paragraph (:begin 11 :end 34 :contents-begin 11 > :contents-end 33 :post-blank 1 :post-affiliated 11 :parent (section > (:begin 11 :end 225 :contents-begin 11 :contents-end 224 :post-blank 1 > :parent (headline (:raw-value "heading" :begin 1 :end 225 :pre-blank 0 > :contents-begin 11 :contents-end 224 :level 1 :priority nil :tags nil > :todo-keyword nil :todo-type nil :post-blank 0 :footnote-section-p nil > :archivedp nil :commentedp nil :quotedp nil :CATEGORY nil :title > (#("heading" 0 7 (:parent #6))) :parent (org-data nil #6)) #4)) #2 > (src-block (:language "elisp" :switches nil :parameters ":results > output" :begin 34 :end 207 :number-lines nil :preserve-indent nil > :retain-labels t :use-labels t :label-fmt nil :value "(dolist > : (job (org-element-map (org-element-parse-buffer) 'paragraph 'identity)) > : (print (car (org-element-contents job)))) > : " :post-blank 1 :post-affiliated 34 :parent #4)) (fixed-width > (:begin 207 :end 224 :value "nil > : " :post-blank 0 :post-affiliated 218 :results ("") :parent #4)))) #0))) > > Use substring-no-properties omitting the bounds: ,---- | substring-no-properties is a built-in function in `C source code'. | | (substring-no-properties STRING &optional FROM TO) | | Return a substring of STRING, without text properties. | It starts at index FROM and ends before TO. | TO may be nil or omitted; then the substring runs to the end of STRING. | If FROM is nil or omitted, the substring starts at the beginning of STRING. | If FROM or TO is negative, it counts from the end. | | With one argument, just copy STRING without its properties. `---- -- Nick