newsticker.el 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. ;;; newsticker.el --- A Newsticker for Emacs.
  2. ;; Copyright (C) 2003-2012 Free Software Foundation, Inc.
  3. ;; Author: Ulf Jasper <ulf.jasper@web.de>
  4. ;; Filename: newsticker.el
  5. ;; URL: http://www.nongnu.org/newsticker
  6. ;; Created: 17. June 2003
  7. ;; Keywords: News, RSS, Atom
  8. ;; Time-stamp: "6. Dezember 2009, 19:15:18 (ulf)"
  9. ;; Version: 1.99
  10. ;; ======================================================================
  11. ;; This file is part of GNU Emacs.
  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. (defconst newsticker-version "1.99" "Version number of newsticker.el.")
  23. ;; ======================================================================
  24. ;;; Commentary:
  25. ;; Overview
  26. ;; --------
  27. ;; Newsticker provides a newsticker for Emacs. A newsticker is a thing
  28. ;; that asynchronously retrieves headlines from a list of news sites,
  29. ;; prepares these headlines for reading, and allows for loading the
  30. ;; corresponding articles in a web browser.
  31. ;; Headlines consist of a title and (possibly) a small description. They
  32. ;; are contained in "RSS" (RDF Site Summary) or "Atom" files. Newsticker
  33. ;; should work with the following RSS formats:
  34. ;; * RSS 0.91
  35. ;; (see http://backend.userland.com/rss091 or
  36. ;; http://my.netscape.com/publish/formats/rss-spec-0.91.html)
  37. ;; * RSS 0.92
  38. ;; (see http://backend.userland.com/rss092)
  39. ;; * RSS 1.0
  40. ;; (see http://purl.org/rss/1.0/spec)
  41. ;; * RSS 2.0
  42. ;; (see http://blogs.law.harvard.edu/tech/rss)
  43. ;; as well as the following Atom formats:
  44. ;; * Atom 0.3
  45. ;; * Atom 1.0
  46. ;; (see http://www.ietf.org/internet-drafts/draft-ietf-atompub-format-11.txt)
  47. ;; That makes Newsticker.el an "Atom aggregator, "RSS reader", "RSS
  48. ;; aggregator", and "Feed Reader".
  49. ;; Newsticker provides several commands for reading headlines, navigating
  50. ;; through them, marking them as read/unread, hiding old headlines
  51. ;; etc. Headlines can be displayed as plain text or as rendered HTML.
  52. ;; Headlines can be displayed in the echo area, either scrolling like
  53. ;; messages in a stock-quote ticker, or just changing.
  54. ;; Newsticker allows for automatic processing of headlines by providing
  55. ;; hooks and (sample) functions for automatically downloading images and
  56. ;; enclosed files (as delivered by podcasts, e.g.).
  57. ;; Requirements
  58. ;; ------------
  59. ;; Newsticker can be used with GNU Emacs version 21.1 or later as well as
  60. ;; XEmacs. It requires an XML-parser (`xml.el') which is part of GNU
  61. ;; Emacs. If you are using XEmacs you want to get the `net-utils' package
  62. ;; which contains `xml.el' for XEmacs.
  63. ;; Newsticker requires a program which can retrieve files via http and
  64. ;; prints them to stdout. By default Newsticker will use wget for this
  65. ;; task.
  66. ;; Installation
  67. ;; ------------
  68. ;; If you are using Newsticker as part of GNU Emacs there is no need to
  69. ;; perform any installation steps in order to use Newsticker. Otherwise
  70. ;; place Newsticker in a directory where Emacs can find it. Add the
  71. ;; following line to your Emacs startup file (`~/.emacs').
  72. ;; (add-to-list 'load-path "/path/to/newsticker/")
  73. ;; (autoload 'newsticker-start "newsticker" "Emacs Newsticker" t)
  74. ;; (autoload 'newsticker-show-news "newsticker" "Emacs Newsticker" t)
  75. ;; If you are using `imenu', which allows for navigating with the help of a
  76. ;; menu, you should add the following to your Emacs startup file
  77. ;; (`~/.emacs').
  78. ;; (add-hook 'newsticker-mode-hook 'imenu-add-menubar-index)
  79. ;; That's it.
  80. ;; Usage
  81. ;; -----
  82. ;; The command newsticker-show-news will display all available headlines in
  83. ;; a special buffer, called `*newsticker*'. It will also start the
  84. ;; asynchronous download of headlines. The modeline in the `*newsticker*'
  85. ;; buffer informs whenever new headlines have arrived. Clicking
  86. ;; mouse-button 2 or pressing RET in this buffer on a headline will call
  87. ;; browse-url to load the corresponding news story in your favorite web
  88. ;; browser.
  89. ;; The scrolling, or flashing of headlines in the echo area, can be started
  90. ;; with the command newsticker-start-ticker. It can be stopped with
  91. ;; newsticker-stop-ticker.
  92. ;; If you just want to start the periodic download of headlines use the
  93. ;; command newsticker-start. Calling newsticker-stop will stop the
  94. ;; periodic download, but will call newsticker-stop-ticker as well.
  95. ;; Configuration
  96. ;; -------------
  97. ;; All Newsticker options are customizable, i.e. they can be changed with
  98. ;; Emacs customization methods: Call the command customize-group and enter
  99. ;; `newsticker' for the customization group.
  100. ;; All Newsticker options have reasonable default values, so that in most
  101. ;; cases it is not necessary to customize settings before starting
  102. ;; Newsticker for the first time.
  103. ;; Newsticker options are organized in the following groups.
  104. ;; * newsticker-feed contains options that define which news
  105. ;; feeds are retrieved and how this is done.
  106. ;; o newsticker-url-list defines the list of headlines which are
  107. ;; retrieved.
  108. ;; o newsticker-retrieval-interval defines how often headlines are
  109. ;; retrieved.
  110. ;; * newsticker-headline-processing contains options that define how the
  111. ;; retrieved headlines are processed.
  112. ;; o newsticker-keep-obsolete-items decides whether unread headlines that
  113. ;; have been removed from the feed are kept in the Newsticker cache.
  114. ;; * newsticker-layout contains options that define how the buffer for
  115. ;; reading news headlines is formatted.
  116. ;; o newsticker-item-format defines how the title of a headline is
  117. ;; formatted.
  118. ;; * newsticker-ticker contains options that define how headlines are shown
  119. ;; in the echo area.
  120. ;; o newsticker-display-interval and newsticker-scroll-smoothly define
  121. ;; how headlines are shown in the echo area.
  122. ;; * newsticker-hooks contains options for hooking other Emacs commands to
  123. ;; newsticker functions.
  124. ;; o newsticker-new-item-functions allows for automatic processing of
  125. ;; headlines. See `newsticker-download-images', and
  126. ;; `newsticker-download-enclosures' for sample functions.
  127. ;; * newsticker-miscellaneous contains other Newsticker options.
  128. ;; Please have a look at the customization buffers for the complete list of
  129. ;; options.
  130. ;; Remarks
  131. ;; -------
  132. ;; This newsticker is designed do its job silently in the background
  133. ;; without disturbing you. However, it is probably impossible to prevent
  134. ;; such a tool from slightly attenuating your Editor's responsiveness every
  135. ;; once in a while.
  136. ;; Byte-compiling newsticker.el is recommended.
  137. ;; ======================================================================
  138. ;;; History:
  139. ;; 1.99
  140. ;; * Lots! of changes.
  141. ;; 1.10x
  142. ;; * Support for download via url. Setting the new variable
  143. ;; `newsticker-download-method' to 'intern will make newsticker
  144. ;; use the url-package instead of the external program
  145. ;; wget. Default value is 'extern.
  146. ;; * Re-enabled `newsticker-default-face'.
  147. ;; * Workaround for broken extra-data.
  148. ;; 1.10 (2007-01-29)
  149. ;; * Bugfixes mostly: `newsticker--decode-iso8601-date',
  150. ;; `newsticker--sentinel', and others.
  151. ;; * Renamed `newsticker--retrieval-timer-list' to
  152. ;; `newsticker-retrieval-timer-list'. Removed
  153. ;; `newsticker-running-p' -- check newsticker-retrieval-timer-list
  154. ;; to find out whether newsticker is running. Removed
  155. ;; `newsticker-ticker-running-p'.
  156. ;; * Try to cache images in w3m-rendered HTML text.
  157. ;; * Other minor changes.
  158. ;; 1.9 (2005-11-01)
  159. ;; * Rewrote feed parsing part. Newsticker now supports RSS 0.91,
  160. ;; 0.92, 1.0, 2.0 as well as Atom 0.3 and 1.0 -- thanks to Thien-Thi
  161. ;; Nguyen.
  162. ;; * Changed auto-marking mechanism: Replaced variable
  163. ;; `newsticker-auto-mark-filter' with new variable
  164. ;; `newsticker-auto-mark-filter-list', which allows for looking not
  165. ;; only at the title but also at the description of a headline.
  166. ;; * Call `newsticker--ticker-text-setup' only after all pending
  167. ;; downloads processes have finished.
  168. ;; * Improved handling of coding systems.
  169. ;; * Added magic autoload comments.
  170. ;; * Bugfixes:
  171. ;; - `hide-entry' was hiding too much when called for the last
  172. ;; headline,
  173. ;; - update mode-line and menu-bar when necessary,
  174. ;; - repaired `newsticker--imenu-goto',
  175. ;; - other minor things.
  176. ;; 1.8 (2005-08-26)
  177. ;; * Added commands `newsticker-show-extra' and `newsticker-hide-extra'
  178. ;; to show and hide extra RSS elements, bound to "sx" and "hx"
  179. ;; resp. Changed default value of `newsticker-show-all-rss-elements'
  180. ;; to nil.
  181. ;; * mode-line: Introduced special mode-line-format for newsticker.
  182. ;; * Get feed logos only once every 24 h.
  183. ;; * Default faces changed.
  184. ;; * Minor fixes.
  185. ;; 1.7 (2005-06-25)
  186. ;; * Tool-bar support: most important commands can be called from
  187. ;; tool-bar buttons.
  188. ;; * Auto-Narrowing introduced: *newsticker* buffer can be narrowed to
  189. ;; a single item (bound to key `xi') or a single feed (bound to
  190. ;; `xf').
  191. ;; * Enclosure support: enclosed items are shown (see
  192. ;; `newsticker-enclosure-face') and can be (automatically) downloaded
  193. ;; (see below). For those of you who read "podcasts".
  194. ;; * Added variable `newsticker-auto-mark-filter' for automatically
  195. ;; marking items as immortal or old.
  196. ;; * Added hook variable `newsticker-new-item-functions' for handling
  197. ;; new items. Added sample functions `newsticker-download-images',
  198. ;; and `newsticker-download-enclosures'.
  199. ;; * Added hook variable `newsticker-select-item-hook' which is run
  200. ;; after `newsticker-(next|previous)-(new-)?-item'.
  201. ;; * Added hook variable `newsticker-select-feed-hook' which is run
  202. ;; after `newsticker-(next|previous)-feed'.
  203. ;; * Added hook variable `newsticker-buffer-change-hook' which is run
  204. ;; after the contents or visibility of the newsticker buffer has
  205. ;; changed, e.g. after `newsticker-buffer-update' or
  206. ;; `newsticker-show-feed-desc'.
  207. ;; * Added command `newsticker-handle-url' for interactively launching
  208. ;; arbitrary programs for URLs, bound to `C-RET'.
  209. ;; * URLs in extra elements are clickable.
  210. ;; * Better support for w3, added command
  211. ;; `newsticker-w3m-show-inline-images' for displaying all inline
  212. ;; images.
  213. ;; * Insert an artificial headline which notifies about failed
  214. ;; retrievals.
  215. ;; * Use pubDate element (RSS 2.0) instead of retrieval time when
  216. ;; available.
  217. ;; * Customizable options grouped.
  218. ;; * Bugfixes: `newsticker--imenu-create-index'; strip whitespace
  219. ;; from links; apply coding-system to extra-elements; time-comparison
  220. ;; for obsolete items; and others which I have forgotten.
  221. ;; * Workaround for another bug in xml-parse-region -- thanks to
  222. ;; anonymous for sending patch.
  223. ;; * Renamed invisible buffers ` *wget-newsticker-<feed>*' to
  224. ;; ` *newsticker-wget-<feed>*'.
  225. ;; * Tested with GNU Emacs versions 21.3 and 22.0 and XEmacs
  226. ;; 21.something.
  227. ;; 1.6 * Support for (some) optional RSS elements: guid, dc:date. See
  228. ;; `newsticker-show-all-rss-elements' `newsticker-extra-face'.
  229. ;; * Better support for w3m -- `newsticker-default-face' is obsolete
  230. ;; now, removed `newsticker-w3m-toggle-inline-image'.
  231. ;; * Added `newsticker-desc-comp-max' -- comparison of item
  232. ;; descriptions can take quite some time.
  233. ;; * Added `newsticker--buffer-make-item-completely-visible' to
  234. ;; ensure that the current item is fully visible.
  235. ;; * Allow for non-positive retrieval-interval, which make newsticker
  236. ;; get news only once.
  237. ;; * Use :set for customizable variables.
  238. ;; * Added `newsticker-buffer-force-update', bound to key `U'.
  239. ;; * Added concept of obsolete items, see
  240. ;; `newsticker-keep-obsolete-items', `newsticker-obsolete-item-face',
  241. ;; `newsticker-obsolete-item-max-age'.
  242. ;; * Added `newsticker-add-url'.
  243. ;; * OPML export.
  244. ;; * Save pre-formatted titles => even better performance!!
  245. ;; * `newsticker-*-new-item' wraps at beginning/end of buffer.
  246. ;; * Always sort obsolete items to end of item list.
  247. ;; * Bugfixes:
  248. ;; - newsticker-hide-entry,
  249. ;; - changes of feed-titles led to duplicate feed items,
  250. ;; - faces for rendered HTML texts,
  251. ;; - length of ticker-text (for "exotic"/multibyte texts),
  252. ;; Thanks to Hiroshi Maruyama.
  253. ;; - suppress items with empty title and description
  254. ;; - newsticker-sort-method was ignored!
  255. ;; - prevent call of fill-region on HTML-rendered descriptions.
  256. ;; 1.5 * Rewrote the visibility stuff. newsticker does not inherit
  257. ;; outline anymore. Now you have complete freedom for
  258. ;; `newsticker-*-format'.
  259. ;; * Save pre-formatted descriptions => incredible performance boost!!
  260. ;; * Introduced `newsticker-(start|stop)-ticker'.
  261. ;; * Introduced statistics for heading-format and
  262. ;; `newsticker-statistics-face'.
  263. ;; * Introduced `newsticker-enable-logo-manipulations'.
  264. ;; * Compare link of items (as well as title and desc).
  265. ;; * Added `newsticker-start-hook' and `newsticker-stop-hook', thanks
  266. ;; to mace.
  267. ;; * Bugfixes -- thanks to Ryan Yeske, Jari Aalto, Bruce Ingalls.
  268. ;; * Tested with Emacs 21.3.50, 21.3.1, 21.2, 21.1; XEmacs 21.4.15
  269. ;; 1.4 * Enabled HTML rendering, added `newsticker-html-renderer' to
  270. ;; choose a HTML rendering engine, thanks to Greg Scott for testing
  271. ;; * New Outline handling using text properties instead of "**"
  272. ;; prefixes.
  273. ;; * Added possibility to mark single item as old (bound to key
  274. ;; `o' (`newsticker-mark-item-at-point-as-read').
  275. ;; * Added possibility to mark single item as immortal (bound to key
  276. ;; `i' (`newsticker-mark-item-at-point-as-immortal').
  277. ;; * Added possibility to display feed logos.
  278. ;; * Added `newsticker-heading-format', `newsticker-item-format'.
  279. ;; * Added `newsticker-date-format'.
  280. ;; * Added `newsticker-justification'.
  281. ;; * Added `newsticker-automatically-mark-visited-items-as-old'.
  282. ;; * Added `newsticker-w3m-toggle-inline-image' which calls
  283. ;; `w3m-toggle-inline-image' if `newsticker-html-renderer' is
  284. ;; `w3m-region'. Exists for convenience only (bound to key
  285. ;; `RET').
  286. ;; 1.3 * Compare title AND desc to check whether item is old, except
  287. ;; for feed desc
  288. ;; * Mark as not-up-to-date only after new items have arrived.
  289. ;; * Added XEmacs compatibility code, tested with XEmacs 21.4.13.
  290. ;; * Tested with Emacs 21.3.50 and Emacs 21.2.something.
  291. ;; * Bugfix: Apply coding-systems to feed title and description,
  292. ;; thanks to OHASHI Akira
  293. ;; * Bugfix: xml-parser-workaround did not work for japanese texts,
  294. ;; thanks to OHASHI Akira
  295. ;; * Kill wget-buffers unless newsticker-debug is not nil.
  296. ;; * Bugfix: xml-parser-workaround for "DOCTYPE rdf:RDF"
  297. ;; 1.2 Peter S Galbraith <psg@debian.org>
  298. ;; * Added `newsticker-url-list-defaults', splitting the URLs into
  299. ;; a customizable selection list, and a user add-on list.
  300. ;; * Minor checkdoc fixes.
  301. ;; 1.1 * Introduced optional feed-specific wget-arguments.
  302. ;; * Keep order of feeds as given in `newsticker-url-list' in
  303. ;; *newsticker* buffer.
  304. ;; * Ignore unsupported coding systems.
  305. ;; 1.0 * Introduced feed-specific retrieval-timers.
  306. ;; * Removed dependency on 'cl (cddddr).
  307. ;; * Thanks to Kevin Rodgers and T.V. Raman for their help.
  308. ;; * Use utf-8 for reading and writing cache data.
  309. ;; * Reported to work with Emacs 21.3.50.
  310. ;; 0.99 * Minor tweaks.
  311. ;; * Tested with Emacs 21.3.2
  312. ;; 0.98 * Check exit status of wget processes. Keep cache data if
  313. ;; something went wrong. Throw error when old wget-processes
  314. ;; are hanging around.
  315. ;; * Introduced newsticker-specific faces.
  316. ;; * Added `newsticker-show-descriptions-of-new-items'.
  317. ;; * Added `newsticker-hide-old-items-in-newsticker-buffer'.
  318. ;; * Added `newsticker-(hide|show)-old-items'.
  319. ;; 0.97 * Minor tweaks.
  320. ;; 0.96 * Added caching.
  321. ;; * newsticker-mode inherits outline-mode.
  322. ;; * newsticker-mode supports imenu.
  323. ;; * Easy buffer-navigation with newsticker-mode's keymap.
  324. ;; * Some bugs fixed.
  325. ;; * Thanks to Moritz Epple for documentation tips.
  326. ;; 0.95 * Added newsticker-mode -- Thanks to T.V. Raman.
  327. ;; * Catch xml-parser errors -- Thanks to T.V. Raman.
  328. ;; * Remove stupid newlines in titles (headlines) -- Thanks to
  329. ;; Jeff Rancier.
  330. ;; 0.94 * Added clickerability and description for channel headings.
  331. ;; * Made it work for (at least some) rss 0.9<something> feeds.
  332. ;; 0.93 * Added some more sites.
  333. ;; * Do not flood the *Messages* buffer.
  334. ;; * First attempt at handling coding systems.
  335. ;; 0.92 * Added `newsticker-wget-name'.
  336. ;; * Try to display message only if minibuffer and echo area are
  337. ;; not in use already.
  338. ;; * Dirty workaround for newer versions of xml.el: Remove
  339. ;; whitespace in rdf.
  340. ;; * Tested with Emacs 21.3.2 and CVS-snapshot of 2003-06-21.
  341. ;; 0.91 * First bugfix: *newsticker* is read-only.
  342. ;; 0.9 * First release.
  343. ;; * Tested with Emacs 21.3.2 and wget 1.8.2.
  344. ;; ======================================================================
  345. ;;; Code:
  346. (require 'newst-backend)
  347. (require 'newst-ticker)
  348. (require 'newst-reader)
  349. (require 'newst-plainview)
  350. (require 'newst-treeview)
  351. (provide 'newsticker)
  352. ;;; newsticker.el ends here