newsticker.el 18 KB

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