2
我試圖編寫一個elisp函數從組織文件中提取文本。具體而言,我希望能夠將組織表中的值轉換爲列表列表,以便我可以在啓動時從我的.emacs之外的文件填充org-feeds-alist。使用org-element-map獲取組織模式元素的文本
我的功能是這樣的:
(defun·org-config-parse-get-table-rows·(file)
"Return·table·rows·minus·header"
(with-temp-buffer
··(insert-file-contents·file)
··(cddr·(org-element-map·(org-element-parse-buffer)·'(table-row)·'identity))))
(defun·org-config-parse-get-table-cells·(file)
··(org-element-map·(org-config-parse-get-table-rows·file)·'(table-cell)·'identity))
我下面的表格與測試它:
|·Name···········|·Fav·Color·|·Age·|·Sex····|
|----------------+-----------+-----+--------|
|·Jim············|·Blue······|··19·|·Male···|
|·Jane···········|·Green·····|··18·|·Female·|
|·Ort'hlrothl'gr·|·Unkown····|·-29·|·???····|
我能夠去檢索單個單元格的文本中最接近表與以下內容:
(car·(last·(car·(org-config-parse-get-table-cells·"test.org"))))
其計算結果爲:
#("Jim" 0 3
(:parent
...
給出由org-element-parse-buffer返回的組織元素列表,將這些元素的文本作爲字符串提取的正確方法是什麼?
在此先感謝。