Nick Dokos <ndokos <at> gmail.com> writes: > Try: > > --8<---------------cut here---------------start------------->8--- > (defun hjh-print-src-blocks () > "Iterate src blocks from org-element and print them to *Messages*." > (interactive) > (let ((tree (org-element-parse-buffer))) > (org-element-map tree 'src-block > (lambda (element) > (message "\n\n\nELEMENT:") > (print (substring-no-properties (plist-get (car (cdr element)) :caption))))))) > --8<---------------cut here---------------end--------------->8---
Finally coming back to this. It seems that the actual string-with-properties may be nested at different levels within the :caption object. I tried Nick's version with a different test file, and it failed with a wrong type error. The "while" below seems to work, though I suppose it could throw an error under some circumstances. Is there an easier way to locate the real stringy-thingy in the middle of the structure, when you can't predict exactly what the structure will be? (defun hjh-print-src-blocks () "Iterate src blocks from org-element and print them to *Messages*." (interactive) (let ((tree (org-element-parse-buffer))) (org-element-map tree 'src-block (lambda (element) (setq element (car (cdr element))) (let ((caption (plist-get element :caption))) (while (and caption (not (stringp caption))) (setq caption (car caption))) (message "\n\n\nCAPTION:") (print (substring-no-properties caption))))))) hjh