org-feed.el 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579
  1. ;;; org-feed.el --- Add RSS feed items to Org files
  2. ;;
  3. ;; Copyright (C) 2009 Free Software Foundation, Inc.
  4. ;;
  5. ;; Author: Carsten Dominik <carsten at orgmode dot org>
  6. ;; Keywords: outlines, hypermedia, calendar, wp
  7. ;; Homepage: http://orgmode.org
  8. ;; Version: 6.24trans
  9. ;;
  10. ;; This file is part of GNU Emacs.
  11. ;;
  12. ;; GNU Emacs is free software: you can redistribute it and/or modify
  13. ;; it under the terms of the GNU General Public License as published by
  14. ;; the Free Software Foundation, either version 3 of the License, or
  15. ;; (at your option) any later version.
  16. ;; GNU Emacs is distributed in the hope that it will be useful,
  17. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. ;; GNU General Public License for more details.
  20. ;; You should have received a copy of the GNU General Public License
  21. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  22. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  23. ;;
  24. ;;; Commentary:
  25. ;;
  26. ;; This module allows to create and change entries in an Org-mode
  27. ;; file triggered by items in an RSS feed. The basic functionality is
  28. ;; geared toward simply adding new items found in a feed as outline nodes
  29. ;; to an Org file. Using hooks, arbitrary actions can be triggered for
  30. ;; new or changed items.
  31. ;;
  32. ;; Selecting feeds and target locations
  33. ;; ------------------------------------
  34. ;;
  35. ;; This module is configured through a single variable, `org-feed-alist'.
  36. ;; Here is an example, using a notes/tasks feed from reQall.com.
  37. ;;
  38. ;; (setq org-feed-alist
  39. ;; '(("ReQall"
  40. ;; "http://www.reqall.com/user/feeds/rss/a1b2c3....."
  41. ;; "~/org/feeds.org" "ReQall Entries")
  42. ;;
  43. ;; With this setup, the command `M-x org-feed-update-all' will
  44. ;; collect new entries in the feed at the given URL and create
  45. ;; entries as subheadings under the "ReQall Entries" heading in the
  46. ;; file "~/org-feeds.org". Each feed needs to have its own heading.
  47. ;;
  48. ;; Besides these standard elements that need to be specified for each
  49. ;; feed,, keyword-value pairs can set additional options. For example,
  50. ;; to de-select transitional entries with a title containing
  51. ;;
  52. ;; "reQall is typing what you said",
  53. ;;
  54. ;; you could use the `:filter' argument:
  55. ;;
  56. ;; (setq org-feed-alist
  57. ;; '(("ReQall"
  58. ;; "http://www.reqall.com/user/feeds/rss/a1b2c3....."
  59. ;; "~/org/feeds.org" "ReQall Entries"
  60. ;; :filter my-reqall-filter)))
  61. ;;
  62. ;; (defun my-reqall-filter (e)
  63. ;; (if (string-match "reQall is typing what you said"
  64. ;; (plist-get e :title))
  65. ;; nil
  66. ;; e))
  67. ;;
  68. ;; See the docstring for `org-feed-alist' for more details.
  69. ;;
  70. ;;
  71. ;; Keeping track of previously added entries
  72. ;; -----------------------------------------
  73. ;;
  74. ;; Since Org allows you to delete, archive, or move outline nodes,
  75. ;; org-feed.el needs to keep track of which feed items have been handled
  76. ;; before, so that they will not be handled again. For this, org-feed.el
  77. ;; stores information in a special drawer, FEEDSTATUS, under the heading
  78. ;; that received the input of the feed. You should add FEEDSTATUS
  79. ;; to your list of drawers in the files that receive feed input:
  80. ;;
  81. ;; #+DRAWERS: PROPERTIES LOGBOOK FEEDSTATUS
  82. ;;
  83. ;; Acknowledgments
  84. ;; ----------------
  85. ;;
  86. ;; org-feed.el is based on ideas by Brad Bozarth who implemented a
  87. ;; similar mechanism using shell and awk scripts.
  88. ;;; Code:
  89. (require 'org)
  90. (declare-function url-retrieve-synchronously "url" (url))
  91. (defgroup org-feed nil
  92. "Options concerning RSS feeds as inputs for Org files."
  93. :tag "Org ID"
  94. :group 'org)
  95. ;;;###autoload
  96. (defcustom org-feed-alist nil
  97. "Alist specifying RSS feeds that should create inputs for Org.
  98. Each entry in this list specified an RSS feed tat should be queried
  99. to create inbox items in Org. Each entry is a list with the following items:
  100. name a custom name for this feed
  101. URL the Feed URL
  102. file the target Org file where entries should be listed
  103. headline the headline under which entries should be listed
  104. Additional arguments can be given using keyword-value pairs. Many of these
  105. specify functions that receive one or a list of \"entries\" as their single
  106. argument. An entry is a property list that describes a feed item. The
  107. property list has properties for each field in the item, for example `:title'
  108. for the `<title>' field and `:pubDate' for the publication date. In addition,
  109. it contains the following properties:
  110. `:item-full-text' the full text in the <item> tag
  111. `:guid-permalink' t when the guid property is a permalink
  112. :drawer drawer-name
  113. The name of the drawer for storing feed information. The default is
  114. \"FEEDSTATUS\". Using different drawers for different feeds allows
  115. several feeds to target the same inbox heading.
  116. :filter filter-function
  117. A function to select interesting entries in the feed. It gets a single
  118. entry as parameter. It should return the entry if it is relevant, or
  119. nil if it is not.
  120. :template template-string
  121. The default action on new items in the feed is to add them as children
  122. under the headline for the feed. The template describes how the entry
  123. should be formatted. If not given, it defaults to
  124. `org-feed-default-template'.
  125. :formatter formatter-function
  126. Instead of relying on a template, you may specify a function to format
  127. the outline node to be inserted as a child. This function gets passed
  128. a property list describing a single feed item, and it should return a
  129. string that is a properly formatted Org outline node of level 1.
  130. :new-handler function
  131. If adding new items as children to the outline is not what you want
  132. to do with new items, define a handler function that is called with
  133. a list of all new items in the feed, each one represented as a property
  134. list. The handler should do what needs to be done, and org-feed will
  135. mark all items given to this handler as \"handled\", i.e. they will not
  136. be passed to this handler again in future readings of the feed.
  137. When the handler is called, point will be at the feed headline.
  138. :changed-handler function
  139. This function gets passed a list of all entries that have been
  140. handled before, but are now still in the feed and have *changed*
  141. since last handled (as evidenced by a different sha1 hash).
  142. When the handler is called, point will be at the feed headline."
  143. :group 'org-feed
  144. :type '(repeat
  145. (list :value ("" "http://" "" "")
  146. (string :tag "Name")
  147. (string :tag "Feed URL")
  148. (file :tag "File for inbox")
  149. (string :tag "Headline for inbox")
  150. (repeat :inline t
  151. (choice
  152. (list :inline t :tag "Filter"
  153. (const :filter)
  154. (symbol :tag "Filter Function"))
  155. (list :inline t :tag "Template"
  156. (const :template)
  157. (string :tag "Template"))
  158. (list :inline t :tag "Formatter"
  159. (const :formatter)
  160. (symbol :tag "Formatter Function"))
  161. (list :inline t :tag "New items handler"
  162. (const :new-handler)
  163. (symbol :tag "Handler Function"))
  164. (list :inline t :tag "Changed items"
  165. (const :changed-handler)
  166. (symbol :tag "Handler Function"))
  167. )))))
  168. (defcustom org-feed-drawer "FEEDSTATUS"
  169. "The name of the drawer for feed status information.
  170. Each feed may also specify its own drawer name using the `:drawer'
  171. parameter in `org-feed-alist'.
  172. Note that in order to make these drawers behave like drawers, they must
  173. be added to the variable `org-drawers' or configured with a #+DRAWERS
  174. line."
  175. :group 'org-feed
  176. :type '(string :tag "Drawer Name"))
  177. (defcustom org-feed-default-template "\n* %h\n %U\n %description\n %a\n"
  178. "Template for the Org node created from RSS feed items.
  179. This is just the default, each feed can specify its own.
  180. Any fields from the feed item can be interpolated into the template with
  181. %name, for example %title, %description, %pubDate etc. In addition, the
  182. following special escapes are valid as well:
  183. %h the title, or the first line of the description
  184. %t the date as a stamp, either from <pubDate> (if present), or
  185. the current date.
  186. %T date and time
  187. %u,%U like %t,%T, but inactive time stamps
  188. %a A link, from <guid> if that is a permalink, else from <link>"
  189. :group 'org-feed
  190. :type '(string :tag "Template"))
  191. (defcustom org-feed-save-after-adding t
  192. "Non-nil means, save buffer after adding new feed items."
  193. :group 'org-feed
  194. :type 'boolean)
  195. (defcustom org-feed-retrieve-method 'url-retrieve-synchronously
  196. "The method to be used to retrieve a feed URL.
  197. This can be `curl' or `wget' to call these external programs, or it can be
  198. an Emacs Lisp function that will return a buffer containing the content
  199. of the file pointed to by the URL."
  200. :group 'org-feed
  201. :type '(choice
  202. (const :tag "Internally with url.el" url-retrieve-synchronously)
  203. (const :tag "Externally with curl" curl)
  204. (const :tag "Externally with wget" wget)
  205. (function :tag "Function")))
  206. (defcustom org-feed-before-adding-hook nil
  207. "Hook that is run before adding new feed items to a file.
  208. You might want to commit the file in its current state to version control,
  209. for example."
  210. :group 'org-feed
  211. :type 'hook)
  212. (defcustom org-feed-after-adding-hook nil
  213. "Hook that is run after new items have been added to a file.
  214. Depending on `org-feed-save-after-adding', the buffer will already
  215. have been saved."
  216. :group 'org-feed
  217. :type 'hook)
  218. (defvar org-feed-buffer "*Org feed*"
  219. "The buffer used to retrieve a feed.")
  220. ;;;###autoload
  221. (defun org-feed-update-all ()
  222. "Get inbox items from all feeds in `org-feed-alist'."
  223. (interactive)
  224. (let ((nfeeds (length org-feed-alist))
  225. (nnew (apply '+ (mapcar 'org-feed-update org-feed-alist))))
  226. (message "%s from %d %s"
  227. (cond ((= nnew 0) "No new entries")
  228. ((= nnew 1) "1 new entry")
  229. (t (format "%d new entries" nnew)))
  230. nfeeds
  231. (if (= nfeeds 1) "feed" "feeds"))))
  232. ;;;###autoload
  233. (defun org-feed-update (feed &optional retrieve-only)
  234. "Get inbox items from FEED.
  235. FEED can be a string with an association in `org-feed-alist', or
  236. it can be a list structured like an entry in `org-feed-alist'."
  237. (interactive (list (org-completing-read "Feed name: " org-feed-alist)))
  238. (if (stringp feed) (setq feed (assoc feed org-feed-alist)))
  239. (unless feed
  240. (error "No such feed in `org-feed-alist"))
  241. (catch 'exit
  242. (let ((name (car feed))
  243. (url (nth 1 feed))
  244. (file (nth 2 feed))
  245. (headline (nth 3 feed))
  246. (filter (nth 1 (memq :filter feed)))
  247. (formatter (nth 1 (memq :formatter feed)))
  248. (new-handler (nth 1 (memq :new-handler feed)))
  249. (changed-handler (nth 1 (memq :changed-handler feed)))
  250. (template (or (nth 1 (memq :template feed))
  251. org-feed-default-template))
  252. (drawer (or (nth 1 (memq :drawer feed))
  253. org-feed-drawer))
  254. feed-buffer inbox-pos
  255. entries old-status status new changed guid-alist e guid olds)
  256. (setq feed-buffer (org-feed-get-feed url))
  257. (unless (and feed-buffer (bufferp feed-buffer))
  258. (error "Cannot get feed %s" name))
  259. (when retrieve-only
  260. (throw 'exit feed-buffer))
  261. (setq entries (org-feed-parse-feed feed-buffer))
  262. (ignore-errors (kill-buffer feed-buffer))
  263. (save-excursion
  264. (save-window-excursion
  265. (setq inbox-pos (org-feed-goto-inbox-internal file headline))
  266. (setq old-status (org-feed-read-previous-status inbox-pos drawer))
  267. ;; Add the "handled" status to the appropriate entries
  268. (setq entries (mapcar (lambda (e)
  269. (setq e (plist-put e :handled
  270. (nth 1 (assoc
  271. (plist-get e :guid)
  272. old-status)))))
  273. entries))
  274. ;; Find out which entries are new and which are changed
  275. (dolist (e entries)
  276. (if (not (plist-get e :handled))
  277. (push e new)
  278. (setq olds (nth 2 (assoc (plist-get e :guid) old-status)))
  279. (if (and olds
  280. (not (string= (sha1-string (plist-get e :item-full-text))
  281. olds)))
  282. (push e changed))))
  283. ;; Parse the relevant entries fully
  284. (setq new (mapcar 'org-feed-parse-entry new)
  285. changed (mapcar 'org-feed-parse-entry changed))
  286. ;; Run the filter
  287. (when filter
  288. (setq new (delq nil (mapcar filter new))
  289. changed (delq nil (mapcar filter new))))
  290. (when (not (or new changed))
  291. (message "No new items in feed %s" name)
  292. (throw 'exit 0))
  293. ;; Get alist based on guid, to look up entries
  294. (setq guid-alist
  295. (append
  296. (mapcar (lambda (e) (list (plist-get e :guid) e)) new)
  297. (mapcar (lambda (e) (list (plist-get e :guid) e)) changed)))
  298. ;; Construct the new status
  299. (setq status
  300. (mapcar
  301. (lambda (e)
  302. (setq guid (plist-get e :guid))
  303. (list guid
  304. ;; things count as handled if we handle them now,
  305. ;; or if they were handled previously
  306. (if (assoc guid guid-alist) t (plist-get e :handled))
  307. ;; A hash, to detect changes
  308. (sha1-string (plist-get e :item-full-text))))
  309. entries))
  310. ;; Handle new items in the feed
  311. (when new
  312. (if new-handler
  313. (progn
  314. (goto-char inbox-pos)
  315. (funcall new-handler new))
  316. ;; No custom handler, do the default adding
  317. ;; Format the new entries into an alist with GUIDs in the car
  318. (setq new-formatted
  319. (mapcar
  320. (lambda (e) (org-feed-format-entry e template formatter))
  321. new)))
  322. ;; Insert the new items
  323. (org-feed-add-items inbox-pos new-formatted))
  324. ;; Handle changed items in the feed
  325. (when (and changed-handler changed)
  326. (goto-char inbox-pos)
  327. (funcall changed-handler changed))
  328. ;; Write the new status
  329. ;; We do this only now, in case something goes wrong above, so
  330. ;; that would would end up with a status that does not reflect
  331. ;; which items truely have been handled
  332. (org-feed-write-status inbox-pos drawer status)
  333. ;; Normalize the visibility of the inbox tree
  334. (goto-char inbox-pos)
  335. (hide-subtree)
  336. (show-children)
  337. (org-cycle-hide-drawers 'children)
  338. ;; Hooks and messages
  339. (when org-feed-save-after-adding (save-buffer))
  340. (message "Added %d new item%s from feed %s to file %s, heading %s"
  341. (length new) (if (> (length new) 1) "s" "")
  342. name
  343. (file-name-nondirectory file) headline)
  344. (run-hooks 'org-feed-after-adding-hook)
  345. (length new))))))
  346. ;;;###autoload
  347. (defun org-feed-goto-inbox (feed)
  348. "Go to the inbox that captures the feed named FEED."
  349. (interactive
  350. (list (if (= (length org-feed-alist) 1)
  351. (car org-feed-alist)
  352. (org-completing-read "Feed name: " org-feed-alist))))
  353. (if (stringp feed) (setq feed (assoc feed org-feed-alist)))
  354. (unless feed
  355. (error "No such feed in `org-feed-alist"))
  356. (org-feed-goto-inbox-internal (nth 2 feed) (nth 3 feed)))
  357. ;;;###autoload
  358. (defun org-feed-show-raw-feed (feed)
  359. "Show the raw feed buffer of a feed."
  360. (interactive
  361. (list (if (= (length org-feed-alist) 1)
  362. (car org-feed-alist)
  363. (org-completing-read "Feed name: " org-feed-alist))))
  364. (if (stringp feed) (setq feed (assoc feed org-feed-alist)))
  365. (unless feed
  366. (error "No such feed in `org-feed-alist"))
  367. (switch-to-buffer
  368. (org-feed-update feed 'retrieve-only))
  369. (goto-char (point-min)))
  370. (defun org-feed-goto-inbox-internal (file heading)
  371. "Find or create HEADING in FILE.
  372. Switch to that buffer, and return the position of that headline."
  373. (find-file file)
  374. (widen)
  375. (goto-char (point-min))
  376. (if (re-search-forward
  377. (concat "^\\*+[ \t]+" heading "[ \t]*\\(:.*?:[ \t]*\\)?$")
  378. nil t)
  379. (goto-char (match-beginning 0))
  380. (goto-char (point-max))
  381. (insert "\n\n* " heading "\n\n")
  382. (org-back-to-heading t))
  383. (point))
  384. (defun org-feed-read-previous-status (pos drawer)
  385. "Get the alist of old GUIDs from the entry at POS.
  386. This will find DRAWER and extract the alist."
  387. (save-excursion
  388. (goto-char pos)
  389. (let ((end (save-excursion (org-end-of-subtree t t))))
  390. (if (re-search-forward
  391. (concat "^[ \t]*:" drawer ":[ \t]*\n\\([^\000]*?\\)\n[ \t]*:END:")
  392. end t)
  393. (read (match-string 1))
  394. nil))))
  395. (defun org-feed-write-status (pos drawer status)
  396. "Write the feed STATUS to DRAWER in entry at POS."
  397. (save-excursion
  398. (goto-char pos)
  399. (let ((end (save-excursion (org-end-of-subtree t t)))
  400. guid)
  401. (if (re-search-forward (concat "^[ \t]*:" drawer ":[ \t]*\n")
  402. end t)
  403. (progn
  404. (goto-char (match-end 0))
  405. (delete-region (point)
  406. (save-excursion
  407. (and (re-search-forward "^[ \t]*:END:" nil t)
  408. (match-beginning 0)))))
  409. (outline-next-heading)
  410. (insert " :" drawer ":\n :END:\n")
  411. (beginning-of-line 0))
  412. (insert (pp-to-string status)))))
  413. (defun org-feed-add-items (pos entries)
  414. "Add the formatted items to the headline as POS."
  415. (let (entry level)
  416. (save-excursion
  417. (goto-char pos)
  418. (unless (looking-at org-complex-heading-regexp)
  419. (error "Wrong position"))
  420. (setq level (org-get-valid-level (length (match-string 1)) 1))
  421. (org-end-of-subtree t t)
  422. (skip-chars-backward " \t\n")
  423. (beginning-of-line 2)
  424. (setq pos (point))
  425. (while (setq entry (pop entries))
  426. (org-paste-subtree level entry 'yank))
  427. (org-mark-ring-push pos))))
  428. (defun org-feed-format-entry (entry template formatter)
  429. "Format ENTRY so that it can be inserted into an Org file.
  430. ENTRY is a property list. This function adds a `:formatted-for-org' property
  431. and returns the full property list.
  432. If that property is already present, nothing changes."
  433. (if formatter
  434. (funcall formatter entry)
  435. (let (dlines fmt tmp indent time
  436. v-h v-t v-T v-u v-U v-a)
  437. (setq dlines (org-split-string (or (plist-get entry :description) "???")
  438. "\n")
  439. v-h (or (plist-get entry :title) (car dlines) "???")
  440. time (or (if (plist-get entry :pubDate)
  441. (org-read-date t t (plist-get entry :pubDate)))
  442. (current-time))
  443. v-t (format-time-string (org-time-stamp-format nil nil) time)
  444. v-T (format-time-string (org-time-stamp-format t nil) time)
  445. v-u (format-time-string (org-time-stamp-format nil t) time)
  446. v-U (format-time-string (org-time-stamp-format t t) time)
  447. v-a (if (setq tmp (or (and (plist-get entry :guid-permalink)
  448. (plist-get entry :guid))
  449. (plist-get entry :link)))
  450. (concat "[[" tmp "]]\n")
  451. ""))
  452. (with-temp-buffer
  453. (insert template)
  454. (goto-char (point-min))
  455. (while (re-search-forward "%\\([a-zA-Z]+\\)" nil t)
  456. (setq name (match-string 1))
  457. (cond
  458. ((member name '("h" "t" "T" "u" "U" "a"))
  459. (replace-match (symbol-value (intern (concat "v-" name))) t t))
  460. ((setq tmp (plist-get entry (intern (concat ":" name))))
  461. (save-excursion
  462. (save-match-data
  463. (beginning-of-line 1)
  464. (when (looking-at (concat "^\\([ \t]*\\)%" name "[ \t]*$"))
  465. (setq tmp (org-feed-make-indented-block
  466. tmp (org-get-indentation))))))
  467. (replace-match tmp t t))))
  468. (buffer-string)))))
  469. (defun org-feed-make-indented-block (s n)
  470. "Add indentaton of N spaces to a multiline string S."
  471. (if (not (string-match "\n" s))
  472. s
  473. (mapconcat 'identity
  474. (org-split-string s "\n")
  475. (concat "\n" (make-string n ?\ )))))
  476. (defun org-feed-get-feed (url)
  477. "Get the RSS feed file at URL and return the buffer."
  478. (cond
  479. ((eq org-feed-retrieve-method 'url-retrieve-synchronously)
  480. (url-retrieve-synchronously url))
  481. ((eq org-feed-retrieve-method 'curl)
  482. (ignore-errors (kill-buffer org-feed-buffer))
  483. (call-process "curl" nil org-feed-buffer nil url)
  484. org-feed-buffer)
  485. ((eq org-feed-retrieve-method 'wget)
  486. (ignore-errors (kill-buffer org-feed-buffer))
  487. (call-process "curl" nil org-feed-buffer nil "-q" "-O" "-" url)
  488. org-feed-buffer)
  489. ((functionp org-feed-retrieve-method)
  490. (funcall org-feed-retrieve-method url))))
  491. (defun org-feed-parse-feed (buffer)
  492. "Parse BUFFER for RS feed entries.
  493. Returns a list of entries, with each entry a property list,
  494. containing the properties `:guid' and `:item-full-text'."
  495. (let (entries beg end item guid entry)
  496. (with-current-buffer buffer
  497. (widen)
  498. (goto-char (point-min))
  499. (while (re-search-forward "<item>" nil t)
  500. (setq beg (point)
  501. end (and (re-search-forward "</item>" nil t)
  502. (match-beginning 0)))
  503. (setq item (buffer-substring beg end)
  504. guid (if (string-match "<guid\\>.*?>\\(.*?\\)</guid>" item)
  505. (org-match-string-no-properties 1 item)))
  506. (setq entry (list :guid guid :item-full-text item))
  507. (push entry entries)
  508. (widen)
  509. (goto-char end))
  510. (nreverse entries))))
  511. (defun org-feed-parse-entry (entry)
  512. "Parse the `:item-full-text' field for xml tags and create new properties."
  513. (with-temp-buffer
  514. (insert (plist-get entry :item-full-text))
  515. (goto-char (point-min))
  516. (while (re-search-forward "<\\([a-zA-Z]+\\>\\).*?>\\([^\000]*?\\)</\\1>"
  517. nil t)
  518. (setq entry (plist-put entry
  519. (intern (concat ":" (match-string 1)))
  520. (match-string 2))))
  521. (goto-char (point-min))
  522. (unless (re-search-forward "isPermaLink[ \t]*=[ \t]*\"false\"" nil t)
  523. (setq entry (plist-put entry :guid-permalink t))))
  524. entry)
  525. (provide 'org-feed)
  526. ;; arch-tag: 0929b557-9bc4-47f4-9633-30a12dbb5ae2
  527. ;;; org-feed.el ends here